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