Skip to content

Commit bff9c54

Browse files
authored
[RISCV][MC] Improve GPR Error Messages (#209669)
- 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.
1 parent 69e0994 commit bff9c54

45 files changed

Lines changed: 1118 additions & 1101 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

llvm/lib/Target/RISCV/RISCVRegisterInfo.td

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,10 @@ def GPR : GPRRegisterClass<(add (sequence "X%u", 10, 17),
319319
(sequence "X%u", 28, 31),
320320
(sequence "X%u", 8, 9),
321321
(sequence "X%u", 18, 27),
322-
(sequence "X%u", 0, 4))>;
322+
(sequence "X%u", 0, 4))> {
323+
let DiagnosticType = "InvalidRegClassGPR";
324+
let DiagnosticString = "register must be a GPR";
325+
}
323326

324327
def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
325328
(add (sequence "X%u_Y", 10, 17),
@@ -332,7 +335,10 @@ def YGPR : RegisterClass<"RISCV", [YLenVT], 64,
332335
let DecoderMethod = "DecodeSimpleRegisterClass<RISCV::X0_Y, 32, /*RVELimit=*/16>";
333336
}
334337

335-
def GPRX0 : GPRRegisterClass<(add X0)>;
338+
def GPRX0 : GPRRegisterClass<(add X0)> {
339+
let DiagnosticType = "InvalidRegClassGPRX0";
340+
let DiagnosticString = "register must be zero (x0)";
341+
}
336342

337343
def GPRX1 : GPRRegisterClass<(add X1)> {
338344
let DiagnosticType = "InvalidRegClassGPRX1";
@@ -391,7 +397,10 @@ def SP : GPRRegisterClass<(add X2)> {
391397

392398
// Saved Registers from s0 to s7, for C.MVA01S07 instruction in Zcmp extension
393399
def SR07 : GPRRegisterClass<(add (sequence "X%u", 8, 9),
394-
(sequence "X%u", 18, 23))>;
400+
(sequence "X%u", 18, 23))> {
401+
let DiagnosticType = "InvalidRegClassSR07";
402+
let DiagnosticString = "register must be GPR from s0 to s7 (x8, x9 or x18-x23)";
403+
}
395404

396405
def GPRX1X5 : GPRRegisterClass<(add X1, X5)> {
397406
let DiagnosticType = "InvalidRegClassGPRX1X5";

0 commit comments

Comments
 (0)