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