[llvm] [AsmMatcherEmitter] Fix the minimum ConversionTable entry size (PR #191977)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 14 00:18:08 PDT 2026
https://github.com/Ouyancheng updated https://github.com/llvm/llvm-project/pull/191977
>From ddf4f5949faaf42ebcad577f7a8d66e7617f0f32 Mon Sep 17 00:00:00 2001
From: Ouyancheng <1024842937 at qq.com>
Date: Tue, 14 Apr 2026 15:06:07 +0800
Subject: [PATCH] [AsmMatchEmitter] Fix the minimum ConversionTable entry size
for targets that uses custom ConversionMethod for all instructions
---
.../AsmMatcherFullCustomConversionMethod.td | 30 +++++++++++++++++++
llvm/utils/TableGen/AsmMatcherEmitter.cpp | 5 +++-
2 files changed, 34 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/TableGen/AsmMatcherFullCustomConversionMethod.td
diff --git a/llvm/test/TableGen/AsmMatcherFullCustomConversionMethod.td b/llvm/test/TableGen/AsmMatcherFullCustomConversionMethod.td
new file mode 100644
index 0000000000000..fce325b9caec9
--- /dev/null
+++ b/llvm/test/TableGen/AsmMatcherFullCustomConversionMethod.td
@@ -0,0 +1,30 @@
+// RUN: llvm-tblgen -gen-asm-matcher -I %p/../../include %s | FileCheck %s
+
+include "llvm/Target/Target.td"
+
+def ArchInstrInfo : InstrInfo { }
+
+def Arch : Target {
+ let InstructionSet = ArchInstrInfo;
+}
+
+def Reg : Register<"reg">;
+def RegClass : RegisterClass<"foo", [i32], 0, (add Reg)>;
+
+class ArchInstruction<string AsmStr, dag OutOperands, dag InOperands> : Instruction {
+ let OutOperandList = OutOperands;
+ let InOperandList = InOperands;
+ let AsmString = AsmStr;
+ let AsmMatchConverter = "ConvertInstr";
+}
+
+def Instr1 : ArchInstruction<"Instr1", (outs), (ins)>;
+def Instr2 : ArchInstruction<"Instr2", (outs), (ins)>;
+
+// Check that the size of ConversionTable is 3
+
+// CHECK: static const uint8_t ConversionTable[CVT_NUM_SIGNATURES][3] = {
+// CHECK-NEXT: // ConvertCustom_ConvertInstr
+// CHECK-NEXT: { CVT_ConvertInstr, 0, CVT_Done },
+// CHECK-NEXT: };
+
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 08d23f45313e0..d4f948e264ecc 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -2010,7 +2010,10 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
SmallSetVector<CachedHashString, 16> OperandConversionKinds;
SmallSetVector<CachedHashString, 16> InstructionConversionKinds;
std::vector<std::vector<uint8_t>> ConversionTable;
- size_t MaxRowLength = 2; // minimum is custom converter plus terminator.
+
+ // minimum is custom converter plus a operand index in parsed OperandVector
+ // (0 for custom converter) and terminator (CVT_Done).
+ size_t MaxRowLength = 3;
// TargetOperandClass - This is the target's operand class, like X86Operand.
std::string TargetOperandClass = Target.getName().str() + "Operand";
More information about the llvm-commits
mailing list