Skip to content

Commit 5ac8c52

Browse files
authored
[RISCV] Correct the register class in the C_SWSP and C_SDSP InstAliases. (#132086)
These instructions use GPR not GPRNoX0. Only the load forms prohibit X0.
1 parent 4c36c42 commit 5ac8c52

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoC.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,14 +715,14 @@ let Predicates = [HasStdExtCOrZca] in {
715715
def : InstAlias<"c.lw $rd, (${rs1})", (C_LW GPRC:$rd, GPRCMem:$rs1, 0)>;
716716
def : InstAlias<"c.sw $rs2, (${rs1})", (C_SW GPRC:$rs2, GPRCMem:$rs1, 0)>;
717717
def : InstAlias<"c.lwsp $rd, (${rs1})", (C_LWSP GPRNoX0:$rd, SPMem:$rs1, 0)>;
718-
def : InstAlias<"c.swsp $rs2, (${rs1})", (C_SWSP GPRNoX0:$rs2, SPMem:$rs1, 0)>;
718+
def : InstAlias<"c.swsp $rs2, (${rs1})", (C_SWSP GPR:$rs2, SPMem:$rs1, 0)>;
719719
}
720720

721721
let Predicates = [HasStdExtCOrZca, IsRV64] in {
722722
def : InstAlias<"c.ld $rd, (${rs1})", (C_LD GPRC:$rd, GPRCMem:$rs1, 0)>;
723723
def : InstAlias<"c.sd $rs2, (${rs1})", (C_SD GPRC:$rs2, GPRCMem:$rs1, 0)>;
724724
def : InstAlias<"c.ldsp $rd, (${rs1})", (C_LDSP GPRNoX0:$rd, SPMem:$rs1, 0)>;
725-
def : InstAlias<"c.sdsp $rs2, (${rs1})", (C_SDSP GPRNoX0:$rs2, SPMem:$rs1, 0)>;
725+
def : InstAlias<"c.sdsp $rs2, (${rs1})", (C_SDSP GPR:$rs2, SPMem:$rs1, 0)>;
726726
}
727727

728728
let Predicates = [HasStdExtCOrZcfOrZce, HasStdExtF, IsRV32] in {

llvm/test/MC/RISCV/rv64c-aliases-valid.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,5 @@ c.sdsp x8, (x2)
112112
c.ldsp x18, (x2)
113113
# CHECK-EXPAND: c.sdsp s2, 0(sp)
114114
c.sdsp x18, (x2)
115+
# CHECK-EXPAND: c.sdsp zero, 0(sp)
116+
c.sdsp x0, (x2)

llvm/test/MC/RISCV/rvc-aliases-valid.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ c.swsp x8, (x2)
2121
c.lwsp x18, (x2)
2222
# CHECK-EXPAND: c.swsp s2, 0(sp)
2323
c.swsp x18, (x2)
24+
# CHECK-EXPAND: c.swsp zero, 0(sp)
25+
c.swsp x0, (x2)

0 commit comments

Comments
 (0)