@@ -76,8 +76,8 @@ unsigned PseudoLoweringEmitter::addDagOperandMapping(
76
76
unsigned OpsAdded = 0 ;
77
77
for (unsigned i = 0 , e = Dag->getNumArgs (); i != e; ++i) {
78
78
if (DefInit *DI = dyn_cast<DefInit>(Dag->getArg (i))) {
79
- // Physical register reference. Explicit check for the special case
80
- // "zero_reg" definition.
79
+ // Physical register reference.
80
+ // Explicit check for the special case "zero_reg" definition.
81
81
if (DI->getDef ()->isSubClassOf (" Register" ) ||
82
82
DI->getDef ()->getName () == " zero_reg" ) {
83
83
OperandMap[BaseIdx + i].Kind = OpData::Reg;
@@ -88,23 +88,26 @@ unsigned PseudoLoweringEmitter::addDagOperandMapping(
88
88
89
89
// Normal operands should always have the same type, or we have a
90
90
// problem.
91
- // FIXME: We probably shouldn't ever get a non-zero BaseIdx here.
92
- assert (BaseIdx == 0 && " Named subargument in pseudo expansion?!" );
91
+
93
92
// FIXME: Are the message operand types backward?
94
- if (DI->getDef () != Insn.Operands [BaseIdx + i].Rec ) {
93
+ if (DI->getDef () != Insn.Operands [i].Rec ) {
95
94
PrintError (Rec, " In pseudo instruction '" + Rec->getName () +
96
95
" ', operand type '" + DI->getDef ()->getName () +
97
96
" ' does not match expansion operand type '" +
98
- Insn.Operands [BaseIdx + i].Rec ->getName () + " '" );
97
+ Insn.Operands [i].Rec ->getName () + " '" );
99
98
PrintFatalNote (DI->getDef (),
100
99
" Value was assigned at the following location:" );
101
100
}
102
101
// Source operand maps to destination operand. The Data element
103
102
// will be filled in later, just set the Kind for now. Do it
104
103
// for each corresponding MachineInstr operand, not just the first.
105
- for (unsigned I = 0 , E = Insn.Operands [i].MINumOperands ; I != E; ++I)
104
+ for (unsigned I = 0 , E = Insn.Operands [i].MINumOperands ; I != E; ++I) {
106
105
OperandMap[BaseIdx + i + I].Kind = OpData::Operand;
106
+ }
107
107
OpsAdded += Insn.Operands [i].MINumOperands ;
108
+ if (Insn.Operands [i].MINumOperands > 0 )
109
+ BaseIdx += Insn.Operands [i].MINumOperands - 1 ;
110
+
108
111
} else if (IntInit *II = dyn_cast<IntInit>(Dag->getArg (i))) {
109
112
OperandMap[BaseIdx + i].Kind = OpData::Imm;
110
113
OperandMap[BaseIdx + i].Data .Imm = II->getValue ();
@@ -164,21 +167,21 @@ void PseudoLoweringEmitter::evaluateExpansion(Record *Rec) {
164
167
" Result was assigned at the following location:" );
165
168
}
166
169
167
- if (Insn.Operands .size () != Dag->getNumArgs ()) {
168
- PrintError (Rec, " In pseudo instruction '" + Rec->getName () +
169
- " ', result operator '" + Operator->getName () +
170
- " ' has the wrong number of operands" );
171
- PrintFatalNote (Rec->getValue (" ResultInst" ),
172
- " Result was assigned at the following location:" );
173
- }
174
-
175
170
unsigned NumMIOperands = 0 ;
176
171
for (unsigned i = 0 , e = Insn.Operands .size (); i != e; ++i)
177
172
NumMIOperands += Insn.Operands [i].MINumOperands ;
178
173
IndexedMap<OpData> OperandMap;
179
174
OperandMap.grow (NumMIOperands);
180
175
181
- addDagOperandMapping (Rec, Dag, Insn, OperandMap, 0 );
176
+ unsigned NumOps = addDagOperandMapping (Rec, Dag, Insn, OperandMap, 0 );
177
+
178
+ if (NumOps < Dag->getNumArgs ()) {
179
+ PrintError (Rec, " In pseudo instruction '" + Rec->getName () +
180
+ " ', result operator '" + Operator->getName () +
181
+ " ' has the wrong number of operands" );
182
+ PrintFatalNote (Rec->getValue (" ResultInst" ),
183
+ " Result was assigned at the following location:" );
184
+ }
182
185
183
186
// If there are more operands that weren't in the DAG, they have to
184
187
// be operands that have default values, or we have an error. Currently,
@@ -196,7 +199,7 @@ void PseudoLoweringEmitter::evaluateExpansion(Record *Rec) {
196
199
SourceOperands[SourceInsn.Operands [i].Name ] = i;
197
200
198
201
LLVM_DEBUG (dbgs () << " Operand mapping:\n " );
199
- for (unsigned i = 0 , e = Insn. Operands . size (); i != e; ++i) {
202
+ for (unsigned i = 0 , e = Dag-> getNumArgs (); i != e; ++i) {
200
203
// We've already handled constant values. Just map instruction operands
201
204
// here.
202
205
if (OperandMap[Insn.Operands [i].MIOperandNo ].Kind != OpData::Operand)
0 commit comments