mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 07:17:32 +00:00
Defer computation of SuperRegs.
Don't compute the SuperRegs list until the sub-register graph is completely finished. This guarantees that the list of super-registers is properly topologically ordered, and has no duplicates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156629 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -83,7 +83,8 @@ CodeGenRegister::CodeGenRegister(Record *R, unsigned Enum)
|
|||||||
EnumValue(Enum),
|
EnumValue(Enum),
|
||||||
CostPerUse(R->getValueAsInt("CostPerUse")),
|
CostPerUse(R->getValueAsInt("CostPerUse")),
|
||||||
CoveredBySubRegs(R->getValueAsBit("CoveredBySubRegs")),
|
CoveredBySubRegs(R->getValueAsBit("CoveredBySubRegs")),
|
||||||
SubRegsComplete(false)
|
SubRegsComplete(false),
|
||||||
|
SuperRegsComplete(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CodeGenRegister::buildObjectGraph(CodeGenRegBank &RegBank) {
|
void CodeGenRegister::buildObjectGraph(CodeGenRegBank &RegBank) {
|
||||||
@@ -219,19 +220,10 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) {
|
|||||||
CodeGenRegister *SR = ExplicitSubRegs[i];
|
CodeGenRegister *SR = ExplicitSubRegs[i];
|
||||||
const SubRegMap &Map = SR->computeSubRegs(RegBank);
|
const SubRegMap &Map = SR->computeSubRegs(RegBank);
|
||||||
|
|
||||||
// Add this as a super-register of SR now all sub-registers are in the list.
|
|
||||||
// This creates a topological ordering, the exact order depends on the
|
|
||||||
// order computeSubRegs is called on all registers.
|
|
||||||
SR->SuperRegs.push_back(this);
|
|
||||||
|
|
||||||
for (SubRegMap::const_iterator SI = Map.begin(), SE = Map.end(); SI != SE;
|
for (SubRegMap::const_iterator SI = Map.begin(), SE = Map.end(); SI != SE;
|
||||||
++SI) {
|
++SI) {
|
||||||
if (!SubRegs.insert(*SI).second)
|
if (!SubRegs.insert(*SI).second)
|
||||||
Orphans.insert(SI->second);
|
Orphans.insert(SI->second);
|
||||||
|
|
||||||
// Noop sub-register indexes are possible, so avoid duplicates.
|
|
||||||
if (SI->second != SR)
|
|
||||||
SI->second->SuperRegs.push_back(this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +431,6 @@ void CodeGenRegister::computeSecondarySubRegs(CodeGenRegBank &RegBank) {
|
|||||||
CodeGenSubRegIndex *NewIdx = NewSubRegs[i].first;
|
CodeGenSubRegIndex *NewIdx = NewSubRegs[i].first;
|
||||||
CodeGenRegister *NewSubReg = NewSubRegs[i].second;
|
CodeGenRegister *NewSubReg = NewSubRegs[i].second;
|
||||||
SubReg2Idx.insert(std::make_pair(NewSubReg, NewIdx));
|
SubReg2Idx.insert(std::make_pair(NewSubReg, NewIdx));
|
||||||
NewSubReg->SuperRegs.push_back(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create sub-register index composition maps for the synthesized indices.
|
// Create sub-register index composition maps for the synthesized indices.
|
||||||
@@ -457,6 +448,30 @@ void CodeGenRegister::computeSecondarySubRegs(CodeGenRegBank &RegBank) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeGenRegister::computeSuperRegs() {
|
||||||
|
// Only visit each register once.
|
||||||
|
if (SuperRegsComplete)
|
||||||
|
return;
|
||||||
|
SuperRegsComplete = true;
|
||||||
|
|
||||||
|
// Make sure all sub-registers have been visited first, so the super-reg
|
||||||
|
// lists will be topologically ordered.
|
||||||
|
for (SubRegMap::const_iterator I = SubRegs.begin(), E = SubRegs.end();
|
||||||
|
I != E; ++I)
|
||||||
|
I->second->computeSuperRegs();
|
||||||
|
|
||||||
|
// Now add this as a super-register on all sub-registers.
|
||||||
|
for (SubRegMap::const_iterator I = SubRegs.begin(), E = SubRegs.end();
|
||||||
|
I != E; ++I) {
|
||||||
|
if (I->second == this)
|
||||||
|
continue;
|
||||||
|
// Don't add duplicate entries.
|
||||||
|
if (!I->second->SuperRegs.empty() && I->second->SuperRegs.back() == this)
|
||||||
|
continue;
|
||||||
|
I->second->SuperRegs.push_back(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CodeGenRegister::addSubRegsPreOrder(SetVector<const CodeGenRegister*> &OSet,
|
CodeGenRegister::addSubRegsPreOrder(SetVector<const CodeGenRegister*> &OSet,
|
||||||
CodeGenRegBank &RegBank) const {
|
CodeGenRegBank &RegBank) const {
|
||||||
@@ -900,6 +915,11 @@ CodeGenRegBank::CodeGenRegBank(RecordKeeper &Records) : Records(Records) {
|
|||||||
if (Registers[i]->CoveredBySubRegs)
|
if (Registers[i]->CoveredBySubRegs)
|
||||||
Registers[i]->computeSecondarySubRegs(*this);
|
Registers[i]->computeSecondarySubRegs(*this);
|
||||||
|
|
||||||
|
// After the sub-register graph is complete, compute the topologically
|
||||||
|
// ordered SuperRegs list.
|
||||||
|
for (unsigned i = 0, e = Registers.size(); i != e; ++i)
|
||||||
|
Registers[i]->computeSuperRegs();
|
||||||
|
|
||||||
// Native register units are associated with a leaf register. They've all been
|
// Native register units are associated with a leaf register. They've all been
|
||||||
// discovered now.
|
// discovered now.
|
||||||
NumNativeRegUnits = NumRegUnits;
|
NumNativeRegUnits = NumRegUnits;
|
||||||
|
@@ -112,6 +112,10 @@ namespace llvm {
|
|||||||
// Compute extra sub-registers by combining the existing sub-registers.
|
// Compute extra sub-registers by combining the existing sub-registers.
|
||||||
void computeSecondarySubRegs(CodeGenRegBank&);
|
void computeSecondarySubRegs(CodeGenRegBank&);
|
||||||
|
|
||||||
|
// Add this as a super-register to all sub-registers after the sub-register
|
||||||
|
// graph has been built.
|
||||||
|
void computeSuperRegs();
|
||||||
|
|
||||||
const SubRegMap &getSubRegs() const {
|
const SubRegMap &getSubRegs() const {
|
||||||
assert(SubRegsComplete && "Must precompute sub-registers");
|
assert(SubRegsComplete && "Must precompute sub-registers");
|
||||||
return SubRegs;
|
return SubRegs;
|
||||||
@@ -169,6 +173,7 @@ namespace llvm {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool SubRegsComplete;
|
bool SubRegsComplete;
|
||||||
|
bool SuperRegsComplete;
|
||||||
|
|
||||||
// The sub-registers explicit in the .td file form a tree.
|
// The sub-registers explicit in the .td file form a tree.
|
||||||
SmallVector<CodeGenSubRegIndex*, 8> ExplicitSubRegIndices;
|
SmallVector<CodeGenSubRegIndex*, 8> ExplicitSubRegIndices;
|
||||||
|
Reference in New Issue
Block a user