mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
Flesh out the Briggs implementation a little bit more, fix a few FIXMEs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45347 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ebe807597f
commit
f1519e8361
@ -102,7 +102,8 @@ namespace {
|
|||||||
std::set<unsigned>& PHIUnion,
|
std::set<unsigned>& PHIUnion,
|
||||||
std::vector<StrongPHIElimination::DomForestNode*>& DF,
|
std::vector<StrongPHIElimination::DomForestNode*>& DF,
|
||||||
std::vector<std::pair<unsigned, unsigned> >& locals);
|
std::vector<std::pair<unsigned, unsigned> >& locals);
|
||||||
void ScheduleCopies(MachineBasicBlock* MBB);
|
void ScheduleCopies(MachineBasicBlock* MBB, std::set<unsigned>& pushed);
|
||||||
|
void InsertCopies(MachineBasicBlock* MBB);
|
||||||
};
|
};
|
||||||
|
|
||||||
char StrongPHIElimination::ID = 0;
|
char StrongPHIElimination::ID = 0;
|
||||||
@ -514,7 +515,8 @@ void StrongPHIElimination::processPHIUnion(MachineInstr* Inst,
|
|||||||
///
|
///
|
||||||
/// Based on "Practical Improvements to the Construction and Destruction
|
/// Based on "Practical Improvements to the Construction and Destruction
|
||||||
/// of Static Single Assignment Form" by Briggs, et al.
|
/// of Static Single Assignment Form" by Briggs, et al.
|
||||||
void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB) {
|
void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB,
|
||||||
|
std::set<unsigned>& pushed) {
|
||||||
std::map<unsigned, unsigned>& copy_set= Waiting[MBB];
|
std::map<unsigned, unsigned>& copy_set= Waiting[MBB];
|
||||||
|
|
||||||
std::map<unsigned, unsigned> worklist;
|
std::map<unsigned, unsigned> worklist;
|
||||||
@ -549,6 +551,7 @@ void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB) {
|
|||||||
if (isLiveOut(LV.getVarInfo(curr.second), MBB)) {
|
if (isLiveOut(LV.getVarInfo(curr.second), MBB)) {
|
||||||
// Insert copy from curr.second to a temporary
|
// Insert copy from curr.second to a temporary
|
||||||
// Push temporary on Stacks
|
// Push temporary on Stacks
|
||||||
|
// Insert temporary in pushed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert copy from map[curr.first] to curr.second
|
// Insert copy from map[curr.first] to curr.second
|
||||||
@ -583,6 +586,34 @@ void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// InsertCopies - insert copies into MBB and all of its successors
|
||||||
|
void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) {
|
||||||
|
std::set<unsigned> pushed;
|
||||||
|
|
||||||
|
// Rewrite register uses from Stacks
|
||||||
|
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
|
||||||
|
I != E; ++I)
|
||||||
|
for (unsigned i = 0; i < I->getNumOperands(); ++i)
|
||||||
|
if (I->getOperand(i).isRegister() &&
|
||||||
|
Stacks[I->getOperand(i).getReg()].size()) {
|
||||||
|
I->getOperand(i).setReg(Stacks[I->getOperand(i).getReg()].back());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schedule the copies for this block
|
||||||
|
ScheduleCopies(MBB, pushed);
|
||||||
|
|
||||||
|
// Recur to our successors
|
||||||
|
for (GraphTraits<MachineBasicBlock*>::ChildIteratorType I =
|
||||||
|
GraphTraits<MachineBasicBlock*>::child_begin(MBB), E =
|
||||||
|
GraphTraits<MachineBasicBlock*>::child_end(MBB); I != E; ++I)
|
||||||
|
InsertCopies(*I);
|
||||||
|
|
||||||
|
// As we exit this block, pop the names we pushed while processing it
|
||||||
|
for (std::set<unsigned>::iterator I = pushed.begin(),
|
||||||
|
E = pushed.end(); I != E; ++I)
|
||||||
|
Stacks[*I].pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
||||||
// Compute DFS numbers of each block
|
// Compute DFS numbers of each block
|
||||||
computeDFS(Fn);
|
computeDFS(Fn);
|
||||||
@ -594,15 +625,8 @@ bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
|
|||||||
processBlock(I);
|
processBlock(I);
|
||||||
|
|
||||||
// Insert copies
|
// Insert copies
|
||||||
MachineDominatorTree& MDT = getAnalysis<MachineDominatorTree>();
|
// FIXME: This process should probably preserve LiveVariables
|
||||||
for (df_iterator<MachineDomTreeNode*> DI = df_begin(MDT.getRootNode()),
|
InsertCopies(Fn.begin());
|
||||||
DE = df_end(MDT.getRootNode()); DI != DE; ++DI) {
|
|
||||||
MachineBasicBlock* block = DI->getBlock();
|
|
||||||
|
|
||||||
// FIXME: Do rewriting with Stacks
|
|
||||||
|
|
||||||
ScheduleCopies(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Perform renaming
|
// FIXME: Perform renaming
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user