[llvm] [RISCV] Improve Errors for X1/X5/X1X5 Reg Classes (PR #126184)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 22:52:29 PST 2025


================
@@ -247,7 +247,11 @@ def GPR : GPRRegisterClass<(add (sequence "X%u", 10, 17),
                                 (sequence "X%u", 0, 4))>;
 
 def GPRX0 : GPRRegisterClass<(add X0)>;
+
+let DiagnosticType = "InvalidRegClassGPRX1" in
----------------
wangpc-pp wrote:

And also, why can't we just override `DiagnosticString` so that we don't even need to handle it in C++ code:
```python
  // A diagnostic message to emit when an invalid value is provided for this
  // register class when it is being used as an assembly operand. If this is
  // non-empty, an anonymous diagnostic type enum value will be generated, and
  // the assembly matcher will provide a function to map from diagnostic types
  // to message strings.
  string DiagnosticString = "";
```
The `DiagnosticString` can be an auto-generated string from the list `regList`.

https://github.com/llvm/llvm-project/pull/126184


More information about the llvm-commits mailing list