[llvm] [TableGen][RISCV] Support sub-operands in CompressInstEmitter.cpp. (PR #133039)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 27 14:18:59 PDT 2025
================
@@ -207,90 +207,109 @@ void CompressInstEmitter::addDagOperandMapping(const Record *Rec,
const CodeGenInstruction &Inst,
IndexedMap<OpData> &OperandMap,
bool IsSourceInst) {
+ unsigned NumMIOperands = 0;
+ for (const auto &Op : Inst.Operands)
+ NumMIOperands += Op.MINumOperands;
+ OperandMap.grow(NumMIOperands);
+
// TiedCount keeps track of the number of operands skipped in Inst
// operands list to get to the corresponding Dag operand. This is
// necessary because the number of operands in Inst might be greater
// than number of operands in the Dag due to how tied operands
// are represented.
unsigned TiedCount = 0;
- for (unsigned I = 0, E = Inst.Operands.size(); I != E; ++I) {
- int TiedOpIdx = Inst.Operands[I].getTiedRegister();
+ unsigned OpNo = 0;
+ for (const auto &Opnd : Inst.Operands) {
+ int TiedOpIdx = Opnd.getTiedRegister();
if (-1 != TiedOpIdx) {
// Set the entry in OperandMap for the tied operand we're skipping.
- OperandMap[I].Kind = OperandMap[TiedOpIdx].Kind;
- OperandMap[I].Data = OperandMap[TiedOpIdx].Data;
- TiedCount++;
+ OperandMap[OpNo].Kind = OperandMap[TiedOpIdx].Kind;
+ OperandMap[OpNo].Data = OperandMap[TiedOpIdx].Data;
+ ++OpNo;
+ ++TiedCount;
continue;
}
- if (const DefInit *DI = dyn_cast<DefInit>(Dag->getArg(I - TiedCount))) {
- if (DI->getDef()->isSubClassOf("Register")) {
- // Check if the fixed register belongs to the Register class.
- if (!validateRegister(DI->getDef(), Inst.Operands[I].Rec))
+ for (unsigned SubOp = 0; SubOp != Opnd.MINumOperands; ++SubOp, ++OpNo) {
----------------
mshockwave wrote:
> Opnd is already a const reference
good point.
https://github.com/llvm/llvm-project/pull/133039
More information about the llvm-commits
mailing list