Skip to content

[RISCV][MC] Implicit 0-offset aliases for JR/JALR #94688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,9 @@ def : InstAlias<"ret", (JALR X0, X1, 0), 4>;
def : InstAlias<"jr $rs, $offset", (JALR X0, GPR:$rs, simm12:$offset), 0>;
def : InstAlias<"jalr $rs, $offset", (JALR X1, GPR:$rs, simm12:$offset), 0>;
def : InstAlias<"jalr $rd, $rs, $offset", (JALR GPR:$rd, GPR:$rs, simm12:$offset), 0>;
def : InstAlias<"jr (${rs})", (JALR X0, GPR:$rs, 0), 0>;
def : InstAlias<"jalr (${rs})", (JALR X1, GPR:$rs, 0), 0>;
def : InstAlias<"jalr $rd, (${rs})", (JALR GPR:$rd, GPR:$rs, 0), 0>;

def : InstAlias<"fence", (FENCE 0xF, 0xF)>; // 0xF == iorw

Expand Down
10 changes: 10 additions & 0 deletions llvm/test/MC/RISCV/rvi-aliases-valid.s
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@ jalr x25, x26, 11
# CHECK-S-OBJ-NOALIAS: jalr zero, 0(ra)
# CHECK-S-OBJ: ret
ret
# CHECK-S-OBJ-NOALIAS: jalr zero, 0(s11)
# CHECK-S-OBJ: jr s11
jr (x27)
# CHECK-S-OBJ-NOALIAS: jalr ra, 0(t3)
# CHECK-S-OBJ: jalr t3
jalr (x28)
# CHECK-S-OBJ-NOALIAS: jalr t4, 0(t5)
# CHECK-S-OBJ: jalr t4, t5
jalr x29, (x30)

# TODO call
# TODO tail

Expand Down
Loading