Skip to content

[RISCV][MC] Improve GPR Error Messages#209669

Merged
lenary merged 2 commits into
llvm:mainfrom
lenary:pr/riscv-gpr-errors
Jul 15, 2026
Merged

[RISCV][MC] Improve GPR Error Messages#209669
lenary merged 2 commits into
llvm:mainfrom
lenary:pr/riscv-gpr-errors

Conversation

@lenary

@lenary lenary commented Jul 15, 2026

Copy link
Copy Markdown
Member
  • For the usual GPR RegClass
  • For the GPRX0 RegClass as used by the PseudoC_ADDI_NOP instruction.

This PR was prepared with the help of AI.

- For the usual GPR RegClass
- For the GPRX0 RegClass as used by the `PseudoC_ADDI_NOP` instruction.
@llvmorg-github-actions

llvmorg-github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

@llvm/pr-subscribers-backend-mips

@llvm/pr-subscribers-backend-risc-v

Author: Sam Elliott (lenary)

Changes
  • For the usual GPR RegClass
  • For the GPRX0 RegClass as used by the PseudoC_ADDI_NOP instruction.

This PR was prepared with the help of AI.


Patch is 230.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/209669.diff

41 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+8-2)
  • (modified) llvm/test/MC/RISCV/corev/XCValu-invalid.s (+86-86)
  • (modified) llvm/test/MC/RISCV/corev/XCVbi-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s (+16-16)
  • (modified) llvm/test/MC/RISCV/corev/XCVelw-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/corev/XCVmac-invalid.s (+66-66)
  • (modified) llvm/test/MC/RISCV/corev/XCVmem-invalid.s (+33-33)
  • (modified) llvm/test/MC/RISCV/corev/XCVsimd-invalid.s (+732-732)
  • (modified) llvm/test/MC/RISCV/function-call-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/priv-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv32d-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32f-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32i-aliases-invalid.s (+7-7)
  • (modified) llvm/test/MC/RISCV/rv32i-invalid.s (+9-9)
  • (modified) llvm/test/MC/RISCV/rv32q-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32zdinx-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv32zfh-invalid.s (+4-4)
  • (modified) llvm/test/MC/RISCV/rv32zhinx-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv64d-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv64f-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64i-aliases-invalid.s (+12-12)
  • (modified) llvm/test/MC/RISCV/rv64q-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64xtheadfmemidx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64xtheadmemidx-invalid.s (+4-4)
  • (modified) llvm/test/MC/RISCV/rv64zdinx-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv64zfh-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64zfinx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64zhinx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rve-invalid.s (+34-34)
  • (modified) llvm/test/MC/RISCV/rvzfbfmin-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rvzfhmin-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rvzicond-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/tlsdesc.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xmips-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/xqcibm-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xqcili-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/xqcilo-invalid.s (+16-16)
  • (modified) llvm/test/MC/RISCV/xqcisim-invalid.s (+5-5)
  • (modified) llvm/test/MC/RISCV/xqcisls-invalid.s (+8-8)
  • (modified) llvm/test/MC/RISCV/xtheadcondmov-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xtheadmac-invalid.s (+14-6)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 07f002fccfa66..a595f0b6ec063 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -319,7 +319,10 @@ def GPR : GPRRegisterClass<(add (sequence "X%u", 10, 17),
                                 (sequence "X%u", 28, 31),
                                 (sequence "X%u", 8, 9),
                                 (sequence "X%u", 18, 27),
-                                (sequence "X%u", 0, 4))>;
+                                (sequence "X%u", 0, 4))> {
+  let DiagnosticType = "InvalidRegClassGPR";
+  let DiagnosticString = "register must be a GPR";
+}
 
 def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
                          (add (sequence "X%u_Y", 10, 17),
@@ -332,7 +335,10 @@ def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
   let DecoderMethod = "DecodeSimpleRegisterClass<RISCV::X0_Y, 32, /*RVELimit=*/16>";
 }
 
-def GPRX0 : GPRRegisterClass<(add X0)>;
+def GPRX0 : GPRRegisterClass<(add X0)> {
+  let DiagnosticType = "InvalidRegClassGPRX0";
+  let DiagnosticString = "register must be zero (x0)";
+}
 
 def GPRX1 : GPRRegisterClass<(add X1)> {
   let DiagnosticType = "InvalidRegClassGPRX1";
diff --git a/llvm/test/MC/RISCV/corev/XCValu-invalid.s b/llvm/test/MC/RISCV/corev/XCValu-invalid.s
index 5a2a1be3db9f7..1caf5b5756ff2 100644
--- a/llvm/test/MC/RISCV/corev/XCValu-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCValu-invalid.s
@@ -2,13 +2,13 @@
 # RUN:        | FileCheck %s --check-prefixes=CHECK-ERROR
 
 cv.addrnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -26,13 +26,13 @@ cv.addun t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addun t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -41,10 +41,10 @@ cv.addun t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.extbz t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbz 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbz t0
 # CHECK-ERROR: too few operands for instruction
@@ -53,13 +53,13 @@ cv.extbz t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -77,10 +77,10 @@ cv.clipu t0, t1, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.clipu t0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipu 0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -89,13 +89,13 @@ cv.clipu t0, t1, 0, 0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.minu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -104,10 +104,10 @@ cv.minu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.abs t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.abs 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.abs t0
 # CHECK-ERROR: too few operands for instruction
@@ -125,13 +125,13 @@ cv.addrn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addrn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -149,13 +149,13 @@ cv.suburn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.suburn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -173,10 +173,10 @@ cv.clip t0, t1, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.clip t0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clip 0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clip t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -185,13 +185,13 @@ cv.clip t0, t1, 0, 0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addunr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -209,13 +209,13 @@ cv.addurn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addurn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -233,13 +233,13 @@ cv.subun t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subun t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -257,13 +257,13 @@ cv.subn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -272,13 +272,13 @@ cv.subn t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subrnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -287,13 +287,13 @@ cv.subrnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.slet t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -302,13 +302,13 @@ cv.slet t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.suburnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -317,13 +317,13 @@ cv.suburnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.maxu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -332,10 +332,10 @@ cv.maxu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.extbs t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbs 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbs t0
 # CHECK-ERROR: too few operands for instruction
@@ -344,10 +344,10 @@ cv.extbs t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.exths t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exths 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exths t0
 # CHECK-ERROR: too few operands for instruction
@@ -356,13 +356,13 @@ cv.exths t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.max t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -371,13 +371,13 @@ cv.max t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subunr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -386,10 +386,10 @@ cv.subunr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.exthz t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exthz 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exthz t0
 # CHECK-ERROR: too few operands for instruction
@@ -398,13 +398,13 @@ cv.exthz t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.clipur t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -413,13 +413,13 @@ cv.clipur t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addurnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -437,13 +437,13 @@ cv.addn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -461,13 +461,13 @@ cv.subrn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subrn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -476,13 +476,13 @@ cv.subrn t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -491,13 +491,13 @@ cv.subnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.clipr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -506,13 +506,13 @@ cv.clipr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.sletu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -521,13 +521,13 @@ cv.sletu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.min t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min t0, t1
 # CHECK-ERROR: too few operands for instruction
diff --git a/llvm/test/MC/RISCV/corev/XCVbi-invalid.s b/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
index 336fef62a41b1..c35083200b804 100644
--- a/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
@@ -6,7 +6,7 @@
 //===----------------------------------------------------------------------===//
 
 cv.beqimm 0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.beqimm t0, t1, 0
 # CHECK-ERROR: immediate must be an integer in the range [-16, 15]
@@ -34,7 +34,7 @@ cv.beqimm t0, 0, -4098
 //===----------------------------------------------------------------------===//
 
 cv.bneimm 0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bneimm t0, t1, 0
 # CHECK-ERROR: immediate must be an integer in the range [-16, 15]
diff --git a/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s b/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
index 38a097d1f71a8..5ce4a0c2687ca 100644
--- a/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
@@ -149,10 +149,10 @@ cv.extractr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.extractr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -161,10 +161,10 @@ cv.extractur t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.extractur t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractur t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractur t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -173,10 +173,10 @@ cv.insertr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.insertr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.insertr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.insertr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -185,10 +185,10 @@ cv.bclrr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.bclrr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bclrr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bclrr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -197,10 +197,10 @@ cv.bsetr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.bsetr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bsetr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bsetr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -209,10 +209,10 @@ cv.ror t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.ror t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ror t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ror t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -221,7 +221,7 @@ cv.ff1 t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.ff1 t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ff1 t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -233,7 +233,7 @@ cv.fl1 t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.fl1 t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.fl1 t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -245,7 +245,7 @@ cv.clb t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.clb t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clb t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -257,7 +257,7 @@ cv.cnt t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.cnt t0, 0
-# CHECK-ERROR: invalid operand...
[truncated]

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-backend-mips

Author: Sam Elliott (lenary)

Changes
  • For the usual GPR RegClass
  • For the GPRX0 RegClass as used by the PseudoC_ADDI_NOP instruction.

This PR was prepared with the help of AI.


Patch is 230.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/209669.diff

41 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+8-2)
  • (modified) llvm/test/MC/RISCV/corev/XCValu-invalid.s (+86-86)
  • (modified) llvm/test/MC/RISCV/corev/XCVbi-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s (+16-16)
  • (modified) llvm/test/MC/RISCV/corev/XCVelw-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/corev/XCVmac-invalid.s (+66-66)
  • (modified) llvm/test/MC/RISCV/corev/XCVmem-invalid.s (+33-33)
  • (modified) llvm/test/MC/RISCV/corev/XCVsimd-invalid.s (+732-732)
  • (modified) llvm/test/MC/RISCV/function-call-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/priv-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv32d-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32f-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32i-aliases-invalid.s (+7-7)
  • (modified) llvm/test/MC/RISCV/rv32i-invalid.s (+9-9)
  • (modified) llvm/test/MC/RISCV/rv32q-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv32zdinx-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv32zfh-invalid.s (+4-4)
  • (modified) llvm/test/MC/RISCV/rv32zhinx-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/rv64d-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv64f-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64i-aliases-invalid.s (+12-12)
  • (modified) llvm/test/MC/RISCV/rv64q-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64xtheadfmemidx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64xtheadmemidx-invalid.s (+4-4)
  • (modified) llvm/test/MC/RISCV/rv64zdinx-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/rv64zfh-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64zfinx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rv64zhinx-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rve-invalid.s (+34-34)
  • (modified) llvm/test/MC/RISCV/rvzfbfmin-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rvzfhmin-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/rvzicond-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/tlsdesc.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xmips-invalid.s (+3-3)
  • (modified) llvm/test/MC/RISCV/xqcibm-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xqcili-invalid.s (+1-1)
  • (modified) llvm/test/MC/RISCV/xqcilo-invalid.s (+16-16)
  • (modified) llvm/test/MC/RISCV/xqcisim-invalid.s (+5-5)
  • (modified) llvm/test/MC/RISCV/xqcisls-invalid.s (+8-8)
  • (modified) llvm/test/MC/RISCV/xtheadcondmov-invalid.s (+2-2)
  • (modified) llvm/test/MC/RISCV/xtheadmac-invalid.s (+14-6)
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 07f002fccfa66..a595f0b6ec063 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -319,7 +319,10 @@ def GPR : GPRRegisterClass<(add (sequence "X%u", 10, 17),
                                 (sequence "X%u", 28, 31),
                                 (sequence "X%u", 8, 9),
                                 (sequence "X%u", 18, 27),
-                                (sequence "X%u", 0, 4))>;
+                                (sequence "X%u", 0, 4))> {
+  let DiagnosticType = "InvalidRegClassGPR";
+  let DiagnosticString = "register must be a GPR";
+}
 
 def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
                          (add (sequence "X%u_Y", 10, 17),
@@ -332,7 +335,10 @@ def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
   let DecoderMethod = "DecodeSimpleRegisterClass<RISCV::X0_Y, 32, /*RVELimit=*/16>";
 }
 
-def GPRX0 : GPRRegisterClass<(add X0)>;
+def GPRX0 : GPRRegisterClass<(add X0)> {
+  let DiagnosticType = "InvalidRegClassGPRX0";
+  let DiagnosticString = "register must be zero (x0)";
+}
 
 def GPRX1 : GPRRegisterClass<(add X1)> {
   let DiagnosticType = "InvalidRegClassGPRX1";
diff --git a/llvm/test/MC/RISCV/corev/XCValu-invalid.s b/llvm/test/MC/RISCV/corev/XCValu-invalid.s
index 5a2a1be3db9f7..1caf5b5756ff2 100644
--- a/llvm/test/MC/RISCV/corev/XCValu-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCValu-invalid.s
@@ -2,13 +2,13 @@
 # RUN:        | FileCheck %s --check-prefixes=CHECK-ERROR
 
 cv.addrnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -26,13 +26,13 @@ cv.addun t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addun t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addun t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -41,10 +41,10 @@ cv.addun t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.extbz t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbz 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbz t0
 # CHECK-ERROR: too few operands for instruction
@@ -53,13 +53,13 @@ cv.extbz t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -77,10 +77,10 @@ cv.clipu t0, t1, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.clipu t0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipu 0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -89,13 +89,13 @@ cv.clipu t0, t1, 0, 0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.minu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.minu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -104,10 +104,10 @@ cv.minu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.abs t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.abs 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.abs t0
 # CHECK-ERROR: too few operands for instruction
@@ -125,13 +125,13 @@ cv.addrn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addrn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addrn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -149,13 +149,13 @@ cv.suburn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.suburn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -173,10 +173,10 @@ cv.clip t0, t1, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.clip t0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clip 0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clip t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -185,13 +185,13 @@ cv.clip t0, t1, 0, 0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addunr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addunr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -209,13 +209,13 @@ cv.addurn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addurn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -233,13 +233,13 @@ cv.subun t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subun t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subun t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -257,13 +257,13 @@ cv.subn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -272,13 +272,13 @@ cv.subn t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subrnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -287,13 +287,13 @@ cv.subrnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.slet t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.slet t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -302,13 +302,13 @@ cv.slet t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.suburnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.suburnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -317,13 +317,13 @@ cv.suburnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.maxu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.maxu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -332,10 +332,10 @@ cv.maxu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.extbs t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbs 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extbs t0
 # CHECK-ERROR: too few operands for instruction
@@ -344,10 +344,10 @@ cv.extbs t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.exths t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exths 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exths t0
 # CHECK-ERROR: too few operands for instruction
@@ -356,13 +356,13 @@ cv.exths t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.max t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.max t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -371,13 +371,13 @@ cv.max t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subunr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subunr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -386,10 +386,10 @@ cv.subunr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.exthz t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exthz 0, t1
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.exthz t0
 # CHECK-ERROR: too few operands for instruction
@@ -398,13 +398,13 @@ cv.exthz t0, t1, t2
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.clipur t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipur t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -413,13 +413,13 @@ cv.clipur t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.addurnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addurnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -437,13 +437,13 @@ cv.addn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.addn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.addn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -461,13 +461,13 @@ cv.subrn t0, t1, t2, a0
 # CHECK-ERROR: immediate must be an integer in the range [0, 31]
 
 cv.subrn t0, t1, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn t0, 0, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn 0, t1, t2, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subrn t0, t1, t2
 # CHECK-ERROR: too few operands for instruction
@@ -476,13 +476,13 @@ cv.subrn t0, t1, t2, 0, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.subnr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.subnr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -491,13 +491,13 @@ cv.subnr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.clipr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clipr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -506,13 +506,13 @@ cv.clipr t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.sletu t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.sletu t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -521,13 +521,13 @@ cv.sletu t0, t1, t2, a0
 # CHECK-ERROR: unexpected extra operand for instruction
 
 cv.min t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min t0, 0, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min 0, t1, t2
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.min t0, t1
 # CHECK-ERROR: too few operands for instruction
diff --git a/llvm/test/MC/RISCV/corev/XCVbi-invalid.s b/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
index 336fef62a41b1..c35083200b804 100644
--- a/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCVbi-invalid.s
@@ -6,7 +6,7 @@
 //===----------------------------------------------------------------------===//
 
 cv.beqimm 0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.beqimm t0, t1, 0
 # CHECK-ERROR: immediate must be an integer in the range [-16, 15]
@@ -34,7 +34,7 @@ cv.beqimm t0, 0, -4098
 //===----------------------------------------------------------------------===//
 
 cv.bneimm 0, 0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bneimm t0, t1, 0
 # CHECK-ERROR: immediate must be an integer in the range [-16, 15]
diff --git a/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s b/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
index 38a097d1f71a8..5ce4a0c2687ca 100644
--- a/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
+++ b/llvm/test/MC/RISCV/corev/XCVbitmanip-invalid.s
@@ -149,10 +149,10 @@ cv.extractr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.extractr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -161,10 +161,10 @@ cv.extractur t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.extractur t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractur t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.extractur t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -173,10 +173,10 @@ cv.insertr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.insertr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.insertr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.insertr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -185,10 +185,10 @@ cv.bclrr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.bclrr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bclrr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bclrr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -197,10 +197,10 @@ cv.bsetr t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.bsetr t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bsetr t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.bsetr t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -209,10 +209,10 @@ cv.ror t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.ror t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ror t0, t1, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ror t0, t1
 # CHECK-ERROR: too few operands for instruction
@@ -221,7 +221,7 @@ cv.ff1 t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.ff1 t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.ff1 t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -233,7 +233,7 @@ cv.fl1 t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.fl1 t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.fl1 t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -245,7 +245,7 @@ cv.clb t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.clb t0, 0
-# CHECK-ERROR: invalid operand for instruction
+# CHECK-ERROR: register must be a GPR
 
 cv.clb t0, t1, 0
 # CHECK-ERROR: unexpected extra operand for instruction
@@ -257,7 +257,7 @@ cv.cnt t0
 # CHECK-ERROR: too few operands for instruction
 
 cv.cnt t0, 0
-# CHECK-ERROR: invalid operand...
[truncated]

@zqb-all

zqb-all commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

LGTM

@@ -391,7 +397,10 @@ def SP : GPRRegisterClass<(add X2)> {

// Saved Registers from s0 to s7, for C.MVA01S07 instruction in Zcmp extension

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by nit, is this an old mnemonic name? Should this be cm.mvsa01

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix this :) thanks for spotting it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually going to fix this in a follow up because I want to rename the regclass.

@wangpc-pp wangpc-pp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@lenary
lenary merged commit bff9c54 into llvm:main Jul 15, 2026
12 checks passed
@lenary
lenary deleted the pr/riscv-gpr-errors branch July 15, 2026 07:12
pedroMVicente pushed a commit to pedroMVicente/llvm-project that referenced this pull request Jul 15, 2026
- For the usual GPR RegClass
- For the GPRX0 RegClass as used by the `PseudoC_ADDI_NOP` instruction.
- For the SR07 regclass used by Zcmp and Xqccmp instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants