[llvm] 846f325 - [RISCV] Use simm12 instead of simm12_lo for CORE-V post-increment load/store. (#207067)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 07:07:20 PDT 2026
Author: Craig Topper
Date: 2026-07-02T07:07:16-07:00
New Revision: 846f3250ff859130d1d4db8a60461e61c51b5cef
URL: https://github.com/llvm/llvm-project/commit/846f3250ff859130d1d4db8a60461e61c51b5cef
DIFF: https://github.com/llvm/llvm-project/commit/846f3250ff859130d1d4db8a60461e61c51b5cef.diff
LOG: [RISCV] Use simm12 instead of simm12_lo for CORE-V post-increment load/store. (#207067)
This operand is an immediate representing how much to adjust the pointer
by after the load/store. Having a symbol address here doesn't make
sense.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
llvm/test/MC/RISCV/corev/XCVmem-invalid.s
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
index c136560532142..e10ee7389db0e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td
@@ -349,6 +349,8 @@ def uimm32 : RISCVUImmOp<32>;
def uimm48 : RISCVUImmOp<48>;
def uimm64 : RISCVUImmOp<64>;
+def simm12 : RISCVSImmLeafOp<12>;
+
def simm12_lo : RISCVSImmLeafOp<12> {
let ParserMatchClass = SImmAsmOperand<12, "LO">;
let MCOperandPredicate = [{
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
index f3f3d408c43e7..f43135754c0b5 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td
@@ -272,7 +272,7 @@ class CVInstImmBranch<bits<3> funct3, dag outs, dag ins,
let hasSideEffects = 0, mayLoad = 1, mayStore = 0 in {
class CVLoad_ri_inc<bits<3> funct3, string opcodestr>
: RVInstI<funct3, OPC_CUSTOM_0, (outs GPR:$rd, GPR:$rs1_wb),
- (ins BasePtr:$rs1, simm12_lo:$imm12),
+ (ins BasePtr:$rs1, simm12:$imm12),
opcodestr, "$rd, (${rs1}), ${imm12}"> {
let Constraints = "$rs1_wb = $rs1";
}
@@ -293,7 +293,7 @@ class CVLoad_rr<bits<7> funct7, bits<3> funct3, string opcodestr>
let hasSideEffects = 0, mayLoad = 0, mayStore = 1 in {
class CVStore_ri_inc<bits<3> funct3, string opcodestr>
: RVInstS<funct3, OPC_CUSTOM_1, (outs GPR:$rs1_wb),
- (ins GPR:$rs2, GPR:$rs1, simm12_lo:$imm12),
+ (ins GPR:$rs2, GPR:$rs1, simm12:$imm12),
opcodestr, "$rs2, (${rs1}), ${imm12}"> {
let Constraints = "$rs1_wb = $rs1";
}
@@ -682,8 +682,8 @@ class CVLdrrPat<PatFrag LoadOp, RVInst Inst>
(Inst CVrr:$regreg)>;
class CVStriPat<PatFrag StoreOp, RVInst Inst>
- : Pat<(StoreOp (i32 GPR:$rs2), GPR:$rs1, simm12_lo:$imm12),
- (Inst GPR:$rs2, GPR:$rs1, simm12_lo:$imm12)>;
+ : Pat<(StoreOp (i32 GPR:$rs2), GPR:$rs1, simm12:$imm12),
+ (Inst GPR:$rs2, GPR:$rs1, simm12:$imm12)>;
class CVStrriPat<PatFrag StoreOp, RVInst Inst>
: Pat<(StoreOp (i32 GPR:$rs2), GPR:$rs1, GPR:$rs3),
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
index 20d48bf881029..f6b7c4ddda6ca 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
@@ -1366,8 +1366,6 @@ def PseudoCCQC_E_LHU : SFBQCLoad;
def PseudoCCQC_E_LBU : SFBQCLoad;
}
-def simm12 : RISCVSImmOp<12>;
-
def QCAccessSymbol : AsmOperandClass {
let Name = "QCAccessSymbol";
let RenderMethod = "addImmOperands";
diff --git a/llvm/test/MC/RISCV/corev/XCVmem-invalid.s b/llvm/test/MC/RISCV/corev/XCVmem-invalid.s
index cbec2f406acc0..a89b9c3059ded 100644
--- a/llvm/test/MC/RISCV/corev/XCVmem-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCVmem-invalid.s
@@ -13,12 +13,12 @@ cv.lb 0, (0), t2
cv.lb t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lb t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lb t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
@@ -47,12 +47,12 @@ cv.lbu 0, (0), t0
cv.lbu t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:18: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:18: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:18: note: immediate must be an integer in the range [-2048, 2047]
cv.lbu t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:18: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:18: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:18: note: immediate must be an integer in the range [-2048, 2047]
cv.lbu t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:12: error: invalid operand for instruction
@@ -81,12 +81,12 @@ cv.lh 0, (0), t2
cv.lh t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lh t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lh t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
@@ -118,12 +118,12 @@ cv.lhu 0, 0(t1)
cv.lhu t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:18: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:18: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:18: note: immediate must be an integer in the range [-2048, 2047]
cv.lhu t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:18: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:18: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:18: note: immediate must be an integer in the range [-2048, 2047]
cv.lhu t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:12: error: invalid operand for instruction
@@ -155,12 +155,12 @@ cv.lw 0, (0), t2
cv.lw t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lw t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.lw t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
@@ -192,7 +192,7 @@ cv.sb t0, 0(t1)
cv.sb t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.sb t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
@@ -215,7 +215,7 @@ cv.sh t0, 0(t1)
cv.sh t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.sh t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
@@ -238,7 +238,7 @@ cv.sw t0, 0(t1)
cv.sw t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:1: error: invalid instruction, any one of the following would fix this:
# CHECK-ERROR: :[[@LINE-2]]:17: note: invalid operand for instruction
-# CHECK-ERROR: :[[@LINE-3]]:17: note: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
+# CHECK-ERROR: :[[@LINE-3]]:17: note: immediate must be an integer in the range [-2048, 2047]
cv.sw t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: invalid operand for instruction
More information about the llvm-commits
mailing list