llvm.org GIT mirror llvm / f1519e8
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 Owen Anderson 11 years ago
1 changed file(s) with 35 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
101101 std::set& PHIUnion,
102102 std::vector& DF,
103103 std::vector >& locals);
104 void ScheduleCopies(MachineBasicBlock* MBB);
104 void ScheduleCopies(MachineBasicBlock* MBB, std::set& pushed);
105 void InsertCopies(MachineBasicBlock* MBB);
105106 };
106107
107108 char StrongPHIElimination::ID = 0;
513514 ///
514515 /// Based on "Practical Improvements to the Construction and Destruction
515516 /// of Static Single Assignment Form" by Briggs, et al.
516 void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB) {
517 void StrongPHIElimination::ScheduleCopies(MachineBasicBlock* MBB,
518 std::set& pushed) {
517519 std::map& copy_set= Waiting[MBB];
518520
519521 std::map worklist;
548550 if (isLiveOut(LV.getVarInfo(curr.second), MBB)) {
549551 // Insert copy from curr.second to a temporary
550552 // Push temporary on Stacks
553 // Insert temporary in pushed
551554 }
552555
553556 // Insert copy from map[curr.first] to curr.second
582585 }
583586 }
584587
588 /// InsertCopies - insert copies into MBB and all of its successors
589 void StrongPHIElimination::InsertCopies(MachineBasicBlock* MBB) {
590 std::set pushed;
591
592 // Rewrite register uses from Stacks
593 for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
594 I != E; ++I)
595 for (unsigned i = 0; i < I->getNumOperands(); ++i)
596 if (I->getOperand(i).isRegister() &&
597 Stacks[I->getOperand(i).getReg()].size()) {
598 I->getOperand(i).setReg(Stacks[I->getOperand(i).getReg()].back());
599 }
600
601 // Schedule the copies for this block
602 ScheduleCopies(MBB, pushed);
603
604 // Recur to our successors
605 for (GraphTraits::ChildIteratorType I =
606 GraphTraits::child_begin(MBB), E =
607 GraphTraits::child_end(MBB); I != E; ++I)
608 InsertCopies(*I);
609
610 // As we exit this block, pop the names we pushed while processing it
611 for (std::set::iterator I = pushed.begin(),
612 E = pushed.end(); I != E; ++I)
613 Stacks[*I].pop_back();
614 }
615
585616 bool StrongPHIElimination::runOnMachineFunction(MachineFunction &Fn) {
586617 // Compute DFS numbers of each block
587618 computeDFS(Fn);
593624 processBlock(I);
594625
595626 // Insert copies
596 MachineDominatorTree& MDT = getAnalysis();
597 for (df_iterator DI = df_begin(MDT.getRootNode()),
598 DE = df_end(MDT.getRootNode()); DI != DE; ++DI) {
599 MachineBasicBlock* block = DI->getBlock();
600
601 // FIXME: Do rewriting with Stacks
602
603 ScheduleCopies(block);
604 }
627 // FIXME: This process should probably preserve LiveVariables
628 InsertCopies(Fn.begin());
605629
606630 // FIXME: Perform renaming
607631