@@ -187,10 +187,7 @@ bool CodeGenRegister::inheritRegUnits(CodeGenRegBank &RegBank) {
187
187
unsigned OldNumUnits = RegUnits.size ();
188
188
for (SubRegMap::const_iterator I = SubRegs.begin (), E = SubRegs.end ();
189
189
I != E; ++I) {
190
- // Strangely a register may have itself as a subreg (self-cycle) e.g. XMM.
191
190
CodeGenRegister *SR = I->second ;
192
- if (SR == this )
193
- continue ;
194
191
// Merge the subregister's units into this register's RegUnits.
195
192
mergeRegUnits (RegUnits, SR->RegUnits );
196
193
}
@@ -260,44 +257,6 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
260
257
}
261
258
}
262
259
263
- // Process the composites.
264
- ListInit *Comps = TheDef->getValueAsListInit (" CompositeIndices" );
265
- for (unsigned i = 0 , e = Comps->size (); i != e; ++i) {
266
- DagInit *Pat = dynamic_cast <DagInit*>(Comps->getElement (i));
267
- if (!Pat)
268
- throw TGError (TheDef->getLoc (), " Invalid dag '" +
269
- Comps->getElement (i)->getAsString () +
270
- " ' in CompositeIndices" );
271
- DefInit *BaseIdxInit = dynamic_cast <DefInit*>(Pat->getOperator ());
272
- if (!BaseIdxInit || !BaseIdxInit->getDef ()->isSubClassOf (" SubRegIndex" ))
273
- throw TGError (TheDef->getLoc (), " Invalid SubClassIndex in " +
274
- Pat->getAsString ());
275
- CodeGenSubRegIndex *BaseIdx = RegBank.getSubRegIdx (BaseIdxInit->getDef ());
276
-
277
- // Resolve list of subreg indices into R2.
278
- CodeGenRegister *R2 = this ;
279
- for (DagInit::const_arg_iterator di = Pat->arg_begin (),
280
- de = Pat->arg_end (); di != de; ++di) {
281
- DefInit *IdxInit = dynamic_cast <DefInit*>(*di);
282
- if (!IdxInit || !IdxInit->getDef ()->isSubClassOf (" SubRegIndex" ))
283
- throw TGError (TheDef->getLoc (), " Invalid SubClassIndex in " +
284
- Pat->getAsString ());
285
- CodeGenSubRegIndex *Idx = RegBank.getSubRegIdx (IdxInit->getDef ());
286
- const SubRegMap &R2Subs = R2->computeSubRegs (RegBank);
287
- SubRegMap::const_iterator ni = R2Subs.find (Idx);
288
- if (ni == R2Subs.end ())
289
- throw TGError (TheDef->getLoc (), " Composite " + Pat->getAsString () +
290
- " refers to bad index in " + R2->getName ());
291
- R2 = ni->second ;
292
- }
293
-
294
- // Insert composite index. Allow overriding inherited indices etc.
295
- SubRegs[BaseIdx] = R2;
296
-
297
- // R2 is no longer an orphan.
298
- Orphans.erase (R2);
299
- }
300
-
301
260
// Now Orphans contains the inherited subregisters without a direct index.
302
261
// Create inferred indexes for all missing entries.
303
262
// Work backwards in the Indices vector in order to compose subregs bottom-up.
@@ -327,14 +286,25 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
327
286
// Compute the inverse SubReg -> Idx map.
328
287
for (SubRegMap::const_iterator SI = SubRegs.begin (), SE = SubRegs.end ();
329
288
SI != SE; ++SI) {
330
- // Ignore idempotent sub-register indices.
331
- if (SI->second == this )
289
+ if (SI->second == this ) {
290
+ SMLoc Loc;
291
+ if (TheDef)
292
+ Loc = TheDef->getLoc ();
293
+ throw TGError (Loc, " Register " + getName () +
294
+ " has itself as a sub-register" );
295
+ }
296
+ // Ensure that every sub-register has a unique name.
297
+ DenseMap<const CodeGenRegister*, CodeGenSubRegIndex*>::iterator Ins =
298
+ SubReg2Idx.insert (std::make_pair (SI->second , SI->first )).first ;
299
+ if (Ins->second == SI->first )
332
300
continue ;
333
- // Is is possible to have multiple names for the same sub-register.
334
- // For example, XMM0 appears as sub_xmm, sub_sd, and sub_ss in YMM0.
335
- // Eventually, this degeneration should go away, but for now we simply give
336
- // precedence to the explicit sub-register index over the inherited ones.
337
- SubReg2Idx.insert (std::make_pair (SI->second , SI->first ));
301
+ // Trouble: Two different names for SI->second.
302
+ SMLoc Loc;
303
+ if (TheDef)
304
+ Loc = TheDef->getLoc ();
305
+ throw TGError (Loc, " Sub-register can't have two names: " +
306
+ SI->second ->getName () + " available as " +
307
+ SI->first ->getName () + " and " + Ins->second ->getName ());
338
308
}
339
309
340
310
// Derive possible names for sub-register concatenations from any explicit
@@ -508,8 +478,6 @@ void CodeGenRegister::computeSuperRegs(CodeGenRegBank &RegBank) {
508
478
Id.push_back (I->first ->EnumValue );
509
479
Id.push_back (I->second ->TopoSig );
510
480
511
- if (I->second == this )
512
- continue ;
513
481
// Don't add duplicate entries.
514
482
if (!I->second ->SuperRegs .empty () && I->second ->SuperRegs .back () == this )
515
483
continue ;
@@ -530,8 +498,7 @@ CodeGenRegister::addSubRegsPreOrder(SetVector<const CodeGenRegister*> &OSet,
530
498
// Add any secondary sub-registers that weren't part of the explicit tree.
531
499
for (SubRegMap::const_iterator I = SubRegs.begin (), E = SubRegs.end ();
532
500
I != E; ++I)
533
- if (I->second != this )
534
- OSet.insert (I->second );
501
+ OSet.insert (I->second );
535
502
}
536
503
537
504
// Compute overlapping registers.
0 commit comments