Skip to content

Commit 009971a

Browse files
authored
[TableGen] Accurately calculate where the source variable ops start in PseudoLoweringEmitter::emitLoweringEmitter. (llvm#135465)
The code was using the number of source operands plus one. The plus one seems to be an ARM specific value accounting for one of the source operands having 2 sub operands. No other target in tree uses PseudoLowering with variadic instructions so this worked. This patch replaces it with a proper count of the number of sub operands of all operands. While there I update the loop to use MIOperandNo so we don't need to count up the sub operands as we go.
1 parent b233d79 commit 009971a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

llvm/utils/TableGen/PseudoLoweringEmitter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
246246
// FIXME: Instruction operands with defaults values (predicates and cc_out
247247
// in ARM, for example shouldn't need explicit values in the
248248
// expansion DAG.
249-
unsigned MIOpNo = 0;
250249
for (const auto &DestOperand : Dest.Operands) {
251250
o << " // Operand: " << DestOperand.Name << "\n";
251+
unsigned MIOpNo = DestOperand.MIOperandNo;
252252
for (unsigned i = 0, e = DestOperand.MINumOperands; i != e; ++i) {
253253
switch (Expansion.OperandMap[MIOpNo + i].Kind) {
254254
case OpData::Operand:
@@ -276,12 +276,13 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
276276
}
277277
}
278278
}
279-
MIOpNo += DestOperand.MINumOperands;
280279
}
281280
if (Dest.Operands.isVariadic) {
282-
MIOpNo = Source.Operands.size() + 1;
281+
unsigned LastOpNo = 0;
282+
for (const auto &Op : Source.Operands)
283+
LastOpNo += Op.MINumOperands;
283284
o << " // variable_ops\n";
284-
o << " for (unsigned i = " << MIOpNo
285+
o << " for (unsigned i = " << LastOpNo
285286
<< ", e = MI->getNumOperands(); i != e; ++i)\n"
286287
<< " if (lowerOperand(MI->getOperand(i), MCOp))\n"
287288
<< " Inst.addOperand(MCOp);\n";

0 commit comments

Comments
 (0)