[llvm] [TableGen] Fix validateOperandClass for non Phyical Reg (PR #118146)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 30 07:47:54 PST 2024
================
@@ -2522,8 +2522,9 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
for (auto &MatchClassName : Table)
OS << " " << MatchClassName << ",\n";
OS << " };\n\n";
- OS << " MatchClassKind OpKind = "
- "(MatchClassKind)Table[Operand.getReg().id()];\n";
+ OS << " auto RegID=Operand.getReg().id();\n";
+ OS << " MatchClassKind OpKind = MCRegister::isPhysicalRegister(RegID)?"
+ "(MatchClassKind)Table[RegID]: InvalidMatchClass;\n";
----------------
s-barannikov wrote:
nitpicking
* `auto` is discouraged by the coding standard
* the generated code is misformatted around '=', '?' and ':'
https://github.com/llvm/llvm-project/pull/118146
More information about the llvm-commits
mailing list