CGA.ResultOperands[i].getName() == OperandName) {
// It's safe to go with the first one we find, because CodeGenInstAlias
// validates that all operands with the same name have the same record.
- unsigned ResultIdx =CGA.getResultInstOperandIndexForResultOperandIndex(i);
+ unsigned ResultIdx = CGA.ResultInstOperandIndex[i];
Op.Class = getOperandClass(CGA.ResultInst->Operands[ResultIdx]);
Op.SrcOpName = OperandName;
return;
// Now that it is validated, add it.
ResultOperands.push_back(ResultOperand(ADI->getDef()));
+ ResultInstOperandIndex.push_back(i);
++AliasOpNo;
continue;
}
// Now that it is validated, add it.
ResultOperands.push_back(ResultOperand(static_cast<Record*>(0)));
+ ResultInstOperandIndex.push_back(i);
++AliasOpNo;
continue;
}
// Now that it is validated, add it.
ResultOperands.push_back(ResultOperand(Result->getArgName(AliasOpNo),
ADI->getDef()));
+ ResultInstOperandIndex.push_back(i);
++AliasOpNo;
continue;
}
ResultOpRec->getName() +
" for integer result operand!");
ResultOperands.push_back(ResultOperand(II->getValue()));
+ ResultInstOperandIndex.push_back(i);
++AliasOpNo;
continue;
}
" instruction expects " + utostr(ResultInst->Operands.size())+
" operands!");
}
-
-/// getResultInstOperandIndexForResultOperandIndex - Given an index into the
-/// ResultOperands array, translate it to a valid index in ResultInst's
-/// operand list.
-unsigned CodeGenInstAlias::
-getResultInstOperandIndexForResultOperandIndex(unsigned OpNo) const {
- unsigned OpIdx = 0;
-
- for (unsigned i = 0;; ++i) {
- assert(i != ResultInst->Operands.size() && "Didn't find entry");
- if (ResultInst->Operands[i].getTiedRegister() != -1)
- continue;
-
- if (OpIdx == OpNo) return i;
-
- ++OpIdx;
- }
-}
/// ResultOperands - The decoded operands for the result instruction.
std::vector<ResultOperand> ResultOperands;
+
+ /// ResultInstOperandIndex - For each operand, this vector holds the
+ /// corresponding index of an operand in the result instruction.
+ std::vector<unsigned> ResultInstOperandIndex;
CodeGenInstAlias(Record *R, CodeGenTarget &T);
-
- /// getResultInstOperandIndexForResultOperandIndex - Given an index into the
- /// ResultOperands array, translate it to a valid index in ResultInst's
- /// operand list.
- unsigned getResultInstOperandIndexForResultOperandIndex(unsigned i) const;
};
}