1*9880d681SAndroid Build Coastguard Worker //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file implements simple dominator construction algorithms for finding 11*9880d681SAndroid Build Coastguard Worker // post dominators on machine functions. 12*9880d681SAndroid Build Coastguard Worker // 13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachinePostDominators.h" 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker using namespace llvm; 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker char MachinePostDominatorTree::ID = 0; 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker //declare initializeMachinePostDominatorTreePass 22*9880d681SAndroid Build Coastguard Worker INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree", 23*9880d681SAndroid Build Coastguard Worker "MachinePostDominator Tree Construction", true, true) 24*9880d681SAndroid Build Coastguard Worker MachinePostDominatorTree()25*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) { 26*9880d681SAndroid Build Coastguard Worker initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry()); 27*9880d681SAndroid Build Coastguard Worker DT = new DominatorTreeBase<MachineBasicBlock>(true); //true indicate 28*9880d681SAndroid Build Coastguard Worker // postdominator 29*9880d681SAndroid Build Coastguard Worker } 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker FunctionPass * createMachinePostDominatorTreePass()32*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::createMachinePostDominatorTreePass() { 33*9880d681SAndroid Build Coastguard Worker return new MachinePostDominatorTree(); 34*9880d681SAndroid Build Coastguard Worker } 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker bool runOnMachineFunction(MachineFunction & F)37*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) { 38*9880d681SAndroid Build Coastguard Worker DT->recalculate(F); 39*9880d681SAndroid Build Coastguard Worker return false; 40*9880d681SAndroid Build Coastguard Worker } 41*9880d681SAndroid Build Coastguard Worker ~MachinePostDominatorTree()42*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::~MachinePostDominatorTree() { 43*9880d681SAndroid Build Coastguard Worker delete DT; 44*9880d681SAndroid Build Coastguard Worker } 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker void getAnalysisUsage(AnalysisUsage & AU) const47*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const { 48*9880d681SAndroid Build Coastguard Worker AU.setPreservesAll(); 49*9880d681SAndroid Build Coastguard Worker MachineFunctionPass::getAnalysisUsage(AU); 50*9880d681SAndroid Build Coastguard Worker } 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Worker void print(llvm::raw_ostream & OS,const Module * M) const53*9880d681SAndroid Build Coastguard WorkerMachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const { 54*9880d681SAndroid Build Coastguard Worker DT->print(OS); 55*9880d681SAndroid Build Coastguard Worker } 56