Skip to content

Commit 5995936

Browse files
committed
Remove support for 'CompositeIndices' and sub-register cycles.
Now that the weird X86 sub_ss and sub_sd sub-register indexes are gone, there is no longer a need for the CompositeIndices construct in .td files. Sub-register index composition can be specified on the SubRegIndex itself using the ComposedOf field. Also enforce unique names for sub-registers in TableGen. The same sub-register cannot be available with multiple sub-register indexes. llvm-svn: 160842
1 parent 97ba769 commit 5995936

File tree

2 files changed

+19
-67
lines changed

2 files changed

+19
-67
lines changed

llvm/include/llvm/Target/Target.td

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,6 @@ class Register<string n, list<string> altNames = []> {
6464
// register.
6565
list<RegAltNameIndex> RegAltNameIndices = [];
6666

67-
// CompositeIndices - Specify subreg indices that don't correspond directly to
68-
// a register in SubRegs and are not inherited. The following formats are
69-
// supported:
70-
//
71-
// (a) Identity - Reg:a == Reg
72-
// (a b) Alias - Reg:a == Reg:b
73-
// (a b,c) Composite - Reg:a == (Reg:b):c
74-
//
75-
// This can be used to disambiguate a sub-sub-register that exists in more
76-
// than one subregister and other weird stuff.
77-
list<dag> CompositeIndices = [];
78-
7967
// DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
8068
// These values can be determined by locating the <target>.h file in the
8169
// directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
@@ -252,9 +240,6 @@ class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs> {
252240
// SubRegIndices - N SubRegIndex instances. This provides the names of the
253241
// sub-registers in the synthesized super-registers.
254242
list<SubRegIndex> SubRegIndices = Indices;
255-
256-
// Compose sub-register indices like in a normal Register.
257-
list<dag> CompositeIndices = [];
258243
}
259244

260245

llvm/utils/TableGen/CodeGenRegisters.cpp

Lines changed: 19 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ bool CodeGenRegister::inheritRegUnits(CodeGenRegBank &RegBank) {
187187
unsigned OldNumUnits = RegUnits.size();
188188
for (SubRegMap::const_iterator I = SubRegs.begin(), E = SubRegs.end();
189189
I != E; ++I) {
190-
// Strangely a register may have itself as a subreg (self-cycle) e.g. XMM.
191190
CodeGenRegister *SR = I->second;
192-
if (SR == this)
193-
continue;
194191
// Merge the subregister's units into this register's RegUnits.
195192
mergeRegUnits(RegUnits, SR->RegUnits);
196193
}
@@ -260,44 +257,6 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
260257
}
261258
}
262259

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-
301260
// Now Orphans contains the inherited subregisters without a direct index.
302261
// Create inferred indexes for all missing entries.
303262
// Work backwards in the Indices vector in order to compose subregs bottom-up.
@@ -327,14 +286,25 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
327286
// Compute the inverse SubReg -> Idx map.
328287
for (SubRegMap::const_iterator SI = SubRegs.begin(), SE = SubRegs.end();
329288
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)
332300
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());
338308
}
339309

340310
// Derive possible names for sub-register concatenations from any explicit
@@ -508,8 +478,6 @@ void CodeGenRegister::computeSuperRegs(CodeGenRegBank &RegBank) {
508478
Id.push_back(I->first->EnumValue);
509479
Id.push_back(I->second->TopoSig);
510480

511-
if (I->second == this)
512-
continue;
513481
// Don't add duplicate entries.
514482
if (!I->second->SuperRegs.empty() && I->second->SuperRegs.back() == this)
515483
continue;
@@ -530,8 +498,7 @@ CodeGenRegister::addSubRegsPreOrder(SetVector<const CodeGenRegister*> &OSet,
530498
// Add any secondary sub-registers that weren't part of the explicit tree.
531499
for (SubRegMap::const_iterator I = SubRegs.begin(), E = SubRegs.end();
532500
I != E; ++I)
533-
if (I->second != this)
534-
OSet.insert(I->second);
501+
OSet.insert(I->second);
535502
}
536503

537504
// Compute overlapping registers.

0 commit comments

Comments
 (0)