Track IR ordering of SelectionDAG nodes 3/4.
[oota-llvm.git] / lib / CodeGen / MachinePostDominators.cpp
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
25 MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
26   initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
27   DT = new DominatorTreeBase<MachineBasicBlock>(true); //true indicate
28                                                        // postdominator
29 }
30
31 FunctionPass *
32 MachinePostDominatorTree::createMachinePostDominatorTreePass() {
33   return new MachinePostDominatorTree();
34 }
35
36 bool
37 MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
38   DT->recalculate(F);
39   return false;
40 }
41
42 MachinePostDominatorTree::~MachinePostDominatorTree() {
43   delete DT;
44 }
45
46 void
47 MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
48   AU.setPreservesAll();
49   MachineFunctionPass::getAnalysisUsage(AU);
50 }
51
52 void
53 MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
54   DT->print(OS);
55 }