llvm.org GIT mirror llvm / a52c3ac
Add a MachinePostDominator pass This is used in the AMDIL and R600 backends. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164029 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 8 years ago
5 changed file(s) with 143 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //=- llvm/CodeGen/MachineDominators.h ----------------------------*- C++ -*-==//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file exposes interfaces to post dominance information for
10 // target-specific code.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
15 #define LLVM_CODEGEN_MACHINEPOSTDOMINATORS_H
16
17 #include "llvm/CodeGen/MachineFunctionPass.h"
18 #include "llvm/CodeGen/MachineDominators.h"
19 #include "llvm/Analysis/Dominators.h"
20 #include "llvm/Analysis/DominatorInternals.h"
21
22 namespace llvm {
23
24 ///
25 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used
26 /// to compute the a post-dominator tree.
27 ///
28 struct MachinePostDominatorTree : public MachineFunctionPass {
29 static char ID;
30
31 DominatorTreeBase *DT;
32
33 MachinePostDominatorTree();
34
35 ~MachinePostDominatorTree();
36
37 FunctionPass *createMachinePostDominatorTreePass();
38
39 const std::vector &getRoots() const {
40 return DT->getRoots();
41 }
42
43 MachineDomTreeNode *getRootNode() const {
44 return DT->getRootNode();
45 }
46
47 MachineDomTreeNode *operator[](MachineBasicBlock *BB) const {
48 return DT->getNode(BB);
49 }
50
51 MachineDomTreeNode *getNode(MachineBasicBlock *BB) const {
52 return DT->getNode(BB);
53 }
54
55 bool dominates(MachineDomTreeNode *A, MachineDomTreeNode *B) const {
56 return DT->dominates(A, B);
57 }
58
59 bool dominates(MachineBasicBlock *A, MachineBasicBlock *B) const {
60 return DT->dominates(A, B);
61 }
62
63 bool
64 properlyDominates(const MachineDomTreeNode *A, MachineDomTreeNode *B) const {
65 return DT->properlyDominates(A, B);
66 }
67
68 bool
69 properlyDominates(MachineBasicBlock *A, MachineBasicBlock *B) const {
70 return DT->properlyDominates(A, B);
71 }
72
73 MachineBasicBlock *findNearestCommonDominator(MachineBasicBlock *A,
74 MachineBasicBlock *B) {
75 return DT->findNearestCommonDominator(A, B);
76 }
77
78 virtual bool runOnMachineFunction(MachineFunction &MF);
79 virtual void getAnalysisUsage(AnalysisUsage &AU) const;
80 virtual void print(llvm::raw_ostream &OS, const Module *M = 0) const;
81 };
82 } //end of namespace llvm
83
84 #endif
166166 void initializeMachineBranchProbabilityInfoPass(PassRegistry&);
167167 void initializeMachineCSEPass(PassRegistry&);
168168 void initializeMachineDominatorTreePass(PassRegistry&);
169 void initializeMachinePostDominatorTreePass(PassRegistry&);
169170 void initializeMachineLICMPass(PassRegistry&);
170171 void initializeMachineLoopInfoPass(PassRegistry&);
171172 void initializeMachineLoopRangesPass(PassRegistry&);
4444 MachineCopyPropagation.cpp
4545 MachineCSE.cpp
4646 MachineDominators.cpp
47 MachinePostDominators.cpp
4748 MachineFunction.cpp
4849 MachineFunctionAnalysis.cpp
4950 MachineFunctionPass.cpp
4040 initializeMachineCopyPropagationPass(Registry);
4141 initializeMachineCSEPass(Registry);
4242 initializeMachineDominatorTreePass(Registry);
43 initializeMachinePostDominatorTreePass(Registry);
4344 initializeMachineLICMPass(Registry);
4445 initializeMachineLoopInfoPass(Registry);
4546 initializeMachineModuleInfoPass(Registry);
0 //===- MachinePostDominators.cpp -Machine Post Dominator Calculation ------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements simple dominator construction algorithms for finding
10 // post dominators on machine functions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/MachinePostDominators.h"
15
16 using namespace llvm;
17
18 char MachinePostDominatorTree::ID = 0;
19
20 //declare initializeMachinePostDominatorTreePass
21 INITIALIZE_PASS(MachinePostDominatorTree, "machinepostdomtree",
22 "MachinePostDominator Tree Construction", true, true)
23
24 MachinePostDominatorTree::MachinePostDominatorTree() : MachineFunctionPass(ID) {
25 initializeMachinePostDominatorTreePass(*PassRegistry::getPassRegistry());
26 DT = new DominatorTreeBase(true); //true indicate
27 // postdominator
28 }
29
30 FunctionPass *
31 MachinePostDominatorTree::createMachinePostDominatorTreePass() {
32 return new MachinePostDominatorTree();
33 }
34
35 bool
36 MachinePostDominatorTree::runOnMachineFunction(MachineFunction &F) {
37 DT->recalculate(F);
38 return false;
39 }
40
41 MachinePostDominatorTree::~MachinePostDominatorTree() {
42 delete DT;
43 }
44
45 void
46 MachinePostDominatorTree::getAnalysisUsage(AnalysisUsage &AU) const {
47 AU.setPreservesAll();
48 MachineFunctionPass::getAnalysisUsage(AU);
49 }
50
51 void
52 MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const {
53 DT->print(OS);
54 }