[llvm] 69721ac - [TableGen] Report a better error when an InstAlias does not use a RegClass

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 09:22:42 PST 2025


Author: Alexander Richardson
Date: 2025-12-05T09:22:38-08:00
New Revision: 69721ac37c0c741337f65c9d451a1c4d41e83114

URL: https://github.com/llvm/llvm-project/commit/69721ac37c0c741337f65c9d451a1c4d41e83114
DIFF: https://github.com/llvm/llvm-project/commit/69721ac37c0c741337f65c9d451a1c4d41e83114.diff

LOG: [TableGen] Report a better error when an InstAlias does not use a RegClass

Also fix the missing space in the error message. I notice while changing
RISC-V's loads and stores to use RegClassByHwMode and got a non-descriptive
error from `T.getRegisterClass(OpRC)` when parsing the InstAliases.

Reviewed By: arsenm

Pull Request: https://github.com/llvm/llvm-project/pull/168444

Added: 
    

Modified: 
    llvm/utils/TableGen/Common/CodeGenInstAlias.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
index 6c1a3e9977c28..2de27986fa04a 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
@@ -55,9 +55,10 @@ static Expected<ResultOperand> matchSimpleOperand(const Init *Arg,
       // Match 'RegClass:$name' or 'RegOp:$name'.
       if (const Record *ArgRC = T.getInitValueAsRegClassLike(Arg)) {
         if (ArgRC->isSubClassOf("RegisterClass")) {
-          if (!T.getRegisterClass(OpRC).hasSubClass(&T.getRegisterClass(ArgRC)))
+          if (!OpRC->isSubClassOf("RegisterClass") ||
+              !T.getRegisterClass(OpRC).hasSubClass(&T.getRegisterClass(ArgRC)))
             return createStringError(
-                "argument register class" + ArgRC->getName() +
+                "argument register class " + ArgRC->getName() +
                 " is not a subclass of operand register class " +
                 OpRC->getName());
           if (!ArgName)


        


More information about the llvm-commits mailing list