mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 13:10:34 +00:00
Rename registers that do not need copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45759 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2815cbb9c7
commit
0c5714bb99
@ -44,6 +44,7 @@ namespace {
|
|||||||
|
|
||||||
std::map<unsigned, std::vector<unsigned> > Stacks;
|
std::map<unsigned, std::vector<unsigned> > Stacks;
|
||||||
std::set<unsigned> UsedByAnother;
|
std::set<unsigned> UsedByAnother;
|
||||||
|
std::map<unsigned, std::set<unsigned> > RenameSets;
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &Fn);
|
bool runOnMachineFunction(MachineFunction &Fn);
|
||||||
|
|
||||||
@ -442,7 +443,8 @@ void StrongPHIElimination::processBlock(MachineBasicBlock* MBB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Cache renaming information
|
// Cache renaming information
|
||||||
|
RenameSets.insert(std::make_pair(P->getOperand(0).getReg(), PHIUnion));
|
||||||
|
|
||||||
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
|
ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end());
|
||||||
++P;
|
++P;
|
||||||
@ -649,8 +651,22 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
// FIXME: This process should probably preserve LiveVariables
|
// FIXME: This process should probably preserve LiveVariables
|
||||||
InsertCopies(Fn.begin());
|
InsertCopies(Fn.begin());
|
||||||
|
|
||||||
// FIXME: Perform renaming
|
// Perform renaming
|
||||||
// FIXME: Remove Phi instrs
|
typedef std::map<unsigned, std::set<unsigned> > RenameSetType;
|
||||||
|
for (RenameSetType::iterator I = RenameSets.begin(), E = RenameSets.end();
|
||||||
|
I != E; ++I)
|
||||||
|
for (std::set<unsigned>::iterator SI = I->second.begin(),
|
||||||
|
SE = I->second.end(); SI != SE; ++SI)
|
||||||
|
Fn.getRegInfo().replaceRegWith(*SI, I->first);
|
||||||
|
|
||||||
|
// FIXME: Insert last-minute copies
|
||||||
|
|
||||||
|
// Remove PHIs
|
||||||
|
for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
|
||||||
|
for (MachineBasicBlock::iterator BI = I->begin(), BE = I->end();
|
||||||
|
BI != BE; ++BI)
|
||||||
|
if (BI->getOpcode() == TargetInstrInfo::PHI)
|
||||||
|
BI->eraseFromParent();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user