Skip to content

Commit 214f558

Browse files
authored
[RISCV] Add ($rs1) InstAliases with no immediate for Zilsd/Zclsd. (#132094)
This matches what we do for other loads and stores.
1 parent 0dcc201 commit 214f558

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZclsd.td

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class PairCStore_rri<bits<3> funct3, string OpcodeStr,
6060
DAGOperand RC, DAGOperand opnd>
6161
: RVInst16CS<funct3, 0b00, (outs), (ins RC:$rs2,GPRCMem:$rs1, opnd:$imm),
6262
OpcodeStr, "$rs2, ${imm}(${rs1})">;
63-
63+
6464
//===----------------------------------------------------------------------===//
6565
// Instructions
6666
//===----------------------------------------------------------------------===//
@@ -91,6 +91,21 @@ def C_SD_RV32 : PairCStore_rri<0b111, "c.sd", GPRPairCRV32, uimm8_lsb000>,
9191
}
9292
}// Predicates = [HasStdExtZclsd, IsRV32], DecoderNamespace = "ZcOverlap"
9393

94+
//===----------------------------------------------------------------------===//
95+
// Assembler Pseudo Instructions
96+
//===----------------------------------------------------------------------===//
97+
98+
let Predicates = [HasStdExtZclsd, IsRV32] in {
99+
def : InstAlias<"c.ld $rd, (${rs1})",
100+
(C_LD_RV32 GPRPairCRV32:$rd, GPRCMem:$rs1, 0), 0>;
101+
def : InstAlias<"c.sd $rs2, (${rs1})",
102+
(C_SD_RV32 GPRPairCRV32:$rs2, GPRCMem:$rs1, 0), 0>;
103+
def : InstAlias<"c.ldsp $rd, (${rs1})",
104+
(C_LDSP_RV32 GPRPairNoX0RV32:$rd, SPMem:$rs1, 0), 0>;
105+
def : InstAlias<"c.sdsp $rs2, (${rs1})",
106+
(C_SDSP_RV32 GPRPairRV32:$rs2, SPMem:$rs1, 0), 0>;
107+
}
108+
94109
//===----------------------------------------------------------------------===//
95110
// Compress Instruction tablegen backend.
96111
//===----------------------------------------------------------------------===//

llvm/lib/Target/RISCV/RISCVInstrInfoZilsd.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,12 @@ def LD_RV32 : PairLoad_ri<"ld", GPRPairRV32>, Sched<[WriteLDD, ReadMemBase]>;
3636
def SD_RV32 : PairStore_rri<"sd", GPRPairRV32>, Sched<[WriteSTD, ReadStoreData,
3737
ReadMemBase]>;
3838
} // Predicates = [HasStdExtZilsd, IsRV32], DecoderNamespace = "RV32Only"
39+
40+
//===----------------------------------------------------------------------===//
41+
// Assembler Pseudo Instructions
42+
//===----------------------------------------------------------------------===//
43+
44+
let Predicates = [HasStdExtZilsd, IsRV32] in {
45+
def : InstAlias<"ld $rd, (${rs1})", (LD_RV32 GPRPairRV32:$rd, GPR:$rs1, 0), 0>;
46+
def : InstAlias<"sd $rs2, (${rs1})", (SD_RV32 GPRPairRV32:$rs2, GPR:$rs1, 0), 0>;
47+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# RUN: llvm-mc -triple=riscv32 -mattr=+zclsd -M no-aliases < %s \
2+
# RUN: | FileCheck -check-prefixes=CHECK-EXPAND %s
3+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zclsd < %s \
4+
# RUN: | llvm-objdump --no-print-imm-hex --mattr=+zclsd -d -M no-aliases - \
5+
# RUN: | FileCheck -check-prefixes=CHECK-EXPAND %s
6+
7+
# CHECK-EXPAND: c.ld s0, 0(s1)
8+
c.ld x8, (x9)
9+
# CHECK-EXPAND: c.sd s0, 0(s1)
10+
c.sd x8, (x9)
11+
# CHECK-EXPAND: c.ldsp s0, 0(sp)
12+
c.ldsp x8, (x2)
13+
# CHECK-EXPAND: c.sdsp s0, 0(sp)
14+
c.sdsp x8, (x2)
15+
# CHECK-EXPAND: c.ldsp s2, 0(sp)
16+
c.ldsp x18, (x2)
17+
# CHECK-EXPAND: c.sdsp s2, 0(sp)
18+
c.sdsp x18, (x2)
19+
# CHECK-EXPAND: c.sdsp zero, 0(sp)
20+
c.sdsp x0, (x2)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: llvm-mc %s -triple=riscv32 -mattr=+zilsd -M no-aliases \
2+
# RUN: | FileCheck -check-prefixes=CHECK-EXPAND %s
3+
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zilsd < %s \
4+
# RUN: | llvm-objdump --no-print-imm-hex --mattr=+zilsd -M no-aliases -d - \
5+
# RUN: | FileCheck -check-prefixes=CHECK-EXPAND %s
6+
7+
# CHECK-EXPAND: ld a0, 0(a1)
8+
ld x10, (x11)
9+
# CHECK-EXPAND: sd a0, 0(a1)
10+
sd x10, (x11)

0 commit comments

Comments
 (0)