Skip to content

Commit 3128c20

Browse files
[TableGen] Bug fix for tied optional operands resolution (#83588)
This fixes tied operand resolution in cases where there are optional operands before the tied operand.
1 parent 5cc2281 commit 3128c20

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/utils/TableGen/AsmMatcherEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,16 +1986,16 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
19861986
}
19871987
CvtOS << " assert(Kind < CVT_NUM_SIGNATURES && \"Invalid signature!\");\n";
19881988
CvtOS << " const uint8_t *Converter = ConversionTable[Kind];\n";
1989-
CvtOS << " unsigned OpIdx;\n";
19901989
CvtOS << " Inst.setOpcode(Opcode);\n";
19911990
CvtOS << " for (const uint8_t *p = Converter; *p; p += 2) {\n";
19921991
if (HasOptionalOperands) {
19931992
// When optional operands are involved, formal and actual operand indices
19941993
// may differ. Map the former to the latter by subtracting the number of
19951994
// absent optional operands.
1996-
CvtOS << " OpIdx = *(p + 1) - DefaultsOffset[*(p + 1)];\n";
1995+
// FIXME: This is not an operand index in the CVT_Tied case
1996+
CvtOS << " unsigned OpIdx = *(p + 1) - DefaultsOffset[*(p + 1)];\n";
19971997
} else {
1998-
CvtOS << " OpIdx = *(p + 1);\n";
1998+
CvtOS << " unsigned OpIdx = *(p + 1);\n";
19991999
}
20002000
CvtOS << " switch (*p) {\n";
20012001
CvtOS << " default: llvm_unreachable(\"invalid conversion entry!\");\n";
@@ -2004,11 +2004,11 @@ emitConvertFuncs(CodeGenTarget &Target, StringRef ClassName,
20042004
<< " &>(*Operands[OpIdx]).addRegOperands(Inst, 1);\n";
20052005
CvtOS << " break;\n";
20062006
CvtOS << " case CVT_Tied: {\n";
2007-
CvtOS << " assert(OpIdx < (size_t)(std::end(TiedAsmOperandTable) -\n";
2007+
CvtOS << " assert(*(p + 1) < (size_t)(std::end(TiedAsmOperandTable) -\n";
20082008
CvtOS
20092009
<< " std::begin(TiedAsmOperandTable)) &&\n";
20102010
CvtOS << " \"Tied operand not found\");\n";
2011-
CvtOS << " unsigned TiedResOpnd = TiedAsmOperandTable[OpIdx][0];\n";
2011+
CvtOS << " unsigned TiedResOpnd = TiedAsmOperandTable[*(p + 1)][0];\n";
20122012
CvtOS << " if (TiedResOpnd != (uint8_t)-1)\n";
20132013
CvtOS << " Inst.addOperand(Inst.getOperand(TiedResOpnd));\n";
20142014
CvtOS << " break;\n";

0 commit comments

Comments
 (0)