[llvm] 0d1b546 - [TableGen][AsmMatcher] Resolve RegClassByHwMode kinds for all operands
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 12:57:18 PDT 2026
Author: Alexander Richardson
Date: 2026-08-04T12:57:13-07:00
New Revision: 0d1b54604dac73adc16af15f433ae0c92069fcc2
URL: https://github.com/llvm/llvm-project/commit/0d1b54604dac73adc16af15f433ae0c92069fcc2
DIFF: https://github.com/llvm/llvm-project/commit/0d1b54604dac73adc16af15f433ae0c92069fcc2.diff
LOG: [TableGen][AsmMatcher] Resolve RegClassByHwMode kinds for all operands
validateOperandClass() only remapped a RegClassByHwMode operand kind
when the actual parsed operand was a register. When the operand was
something else entirely (e.g. a bare immediate where a register was
expected), this fell through to the generic "Kind <= MCK_LAST_REGISTER"
diagnostic check, so we end up with a generic Match_InvalidOperand.
No test changes here, but this is needed to avoid diagnostic regressions
with the RVY load/store support (PR #177073).
Pull Request: https://github.com/llvm/llvm-project/pull/213479
Added:
Modified:
llvm/test/TableGen/RegClassByHwMode.td
llvm/utils/TableGen/AsmMatcherEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/test/TableGen/RegClassByHwMode.td b/llvm/test/TableGen/RegClassByHwMode.td
index ee1e8a32ed711..a9acc154ad933 100644
--- a/llvm/test/TableGen/RegClassByHwMode.td
+++ b/llvm/test/TableGen/RegClassByHwMode.td
@@ -102,7 +102,7 @@ include "Common/RegClassByHwModeCommon.td"
// ASMMATCHER: switch (Kind) {
-// ASMMATCHER: if (Operand.isReg() && Kind > MCK_LAST_REGISTER && Kind <= MCK_LAST_REGCLASS_BY_HWMODE) {
+// ASMMATCHER: if (Kind > MCK_LAST_REGISTER && Kind <= MCK_LAST_REGCLASS_BY_HWMODE) {
// ASMMATCHER-NEXT: static constexpr MatchClassKind RegClassByHwModeMatchTable[4][3] = {
// ASMMATCHER-NEXT: { // DefaultMode
// ASMMATCHER-NEXT: MCK_PtrRegs32, // MyPtrRC
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 119a3da036d91..96188225c472e 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2676,7 +2676,11 @@ static void emitValidateOperandClass(const CodeGenTarget &Target,
unsigned NumClassesByHwMode = RegClassesByHwMode.size();
if (!RegClassesByHwMode.empty()) {
- OS << " if (Operand.isReg() && Kind > MCK_LAST_REGISTER &&"
+ // Resolve RegClassByHwMode kinds to their concrete class regardless of
+ // whether Operand is actually a register, so that the diagnostic
+ // fallback paths below (for both register and non-register operands)
+ // see a concrete class rather than an unresolved by-hwmode one.
+ OS << " if (Kind > MCK_LAST_REGISTER &&"
" Kind <= MCK_LAST_REGCLASS_BY_HWMODE) {\n";
const CodeGenHwModes &CGH = Target.getHwModes();
More information about the llvm-commits
mailing list