Skip to content

Commit e810157

Browse files
committed
[TableGen] More accurately calculate where the source variable ops start in PseudoLoweringEmitter::emitLoweringEmitter.
The code was using the number or 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 PseudLowering 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 4c67bdd commit e810157

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
@@ -247,9 +247,9 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
247247
// FIXME: Instruction operands with defaults values (predicates and cc_out
248248
// in ARM, for example shouldn't need explicit values in the
249249
// expansion DAG.
250-
unsigned MIOpNo = 0;
251250
for (const auto &DestOperand : Dest.Operands) {
252251
o << " // Operand: " << DestOperand.Name << "\n";
252+
unsigned MIOpNo = DestOperand.MIOperandNo;
253253
for (unsigned i = 0, e = DestOperand.MINumOperands; i != e; ++i) {
254254
switch (Expansion.OperandMap[MIOpNo + i].Kind) {
255255
case OpData::Operand:
@@ -277,12 +277,13 @@ void PseudoLoweringEmitter::emitLoweringEmitter(raw_ostream &o) {
277277
}
278278
}
279279
}
280-
MIOpNo += DestOperand.MINumOperands;
281280
}
282281
if (Dest.Operands.isVariadic) {
283-
MIOpNo = Source.Operands.size() + 1;
282+
unsigned LastOpNo = 0;
283+
for (const auto &Op : Source.Operands)
284+
LastOpNo += Op.MINumOperands;
284285
o << " // variable_ops\n";
285-
o << " for (unsigned i = " << MIOpNo
286+
o << " for (unsigned i = " << LastOpNo
286287
<< ", e = MI->getNumOperands(); i != e; ++i)\n"
287288
<< " if (lowerOperand(MI->getOperand(i), MCOp))\n"
288289
<< " Inst.addOperand(MCOp);\n";

0 commit comments

Comments
 (0)