[llvm] [TableGen][AsmMatcher] Resolve RegClassByHwMode kinds for all operands (PR #213479)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 1 11:44:59 PDT 2026
https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/213479
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).
>From 004ebf744c0af06cb801ad3afdd447e5a2eb9ba8 Mon Sep 17 00:00:00 2001
From: Alexander Richardson <mail at alexrichardson.me>
Date: Sat, 1 Aug 2026 11:44:30 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.8-beta.1-arichardson
---
llvm/test/TableGen/RegClassByHwMode.td | 2 +-
llvm/utils/TableGen/AsmMatcherEmitter.cpp | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/test/TableGen/RegClassByHwMode.td b/llvm/test/TableGen/RegClassByHwMode.td
index 46aef05ebc9c2..044b0716c97d8 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 4af5c8510bffb..d96391e73979c 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2569,7 +2569,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