Expand the pass to unify all of the unwind blocks as well
[oota-llvm.git] / include / llvm / Analysis / PostDominators.h
1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation -*- C++ -*--=//
2 //
3 // This file exposes interfaces to post dominance information.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
8 #define LLVM_ANALYSIS_POST_DOMINATORS_H
9
10 #include "llvm/Analysis/Dominators.h"
11
12
13 //===-------------------------------------
14 // DominatorSet Class - Concrete subclass of DominatorSetBase that is used to
15 // compute the post-dominator set.
16 //
17 struct PostDominatorSet : public DominatorSetBase {
18   PostDominatorSet() : DominatorSetBase(true) {}
19
20   virtual bool runOnFunction(Function &F);
21
22   // getAnalysisUsage - This obviously provides a dominator set, but it also
23   // uses the UnifyFunctionExitNode pass if building post-dominators
24   //
25   virtual void getAnalysisUsage(AnalysisUsage &AU) const;
26 };
27
28
29
30 //===-------------------------------------
31 // ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
32 // that is used to compute the immediate post-dominators.
33 //
34 struct ImmediatePostDominators : public ImmediateDominatorsBase {
35   ImmediatePostDominators() : ImmediateDominatorsBase(true) {}
36
37   virtual bool runOnFunction(Function &F) {
38     IDoms.clear();     // Reset from the last time we were run...
39     PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
40     Root = DS.getRoot();
41     calcIDoms(DS);
42     return false;
43   }
44
45   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
46     AU.setPreservesAll();
47     AU.addRequired<PostDominatorSet>();
48   }
49 };
50
51
52 //===-------------------------------------
53 // PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
54 // compute the a post-dominator tree.
55 //
56 struct PostDominatorTree : public DominatorTreeBase {
57   PostDominatorTree() : DominatorTreeBase(true) {}
58
59   virtual bool runOnFunction(Function &F) {
60     reset();     // Reset from the last time we were run...
61     PostDominatorSet &DS = getAnalysis<PostDominatorSet>();
62     Root = DS.getRoot();
63     calculate(DS);
64     return false;
65   }
66
67   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
68     AU.setPreservesAll();
69     AU.addRequired<PostDominatorSet>();
70   }
71 private:
72   void calculate(const PostDominatorSet &DS);
73 };
74
75
76 //===-------------------------------------
77 // PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
78 // used to compute the a post-dominance frontier.
79 //
80 struct PostDominanceFrontier : public DominanceFrontierBase {
81   PostDominanceFrontier() : DominanceFrontierBase(true) {}
82
83   virtual bool runOnFunction(Function &) {
84     Frontiers.clear();
85     PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
86     Root = DT.getRoot();
87     calculate(DT, DT[Root]);
88     return false;
89   }
90
91   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
92     AU.setPreservesAll();
93     AU.addRequired<PostDominatorTree>();
94   }
95
96   // stub - dummy function, just ignore it
97   static void stub();
98
99 private:
100   const DomSetType &calculate(const PostDominatorTree &DT,
101                               const DominatorTree::Node *Node);
102 };
103
104 // Make sure that any clients of this file link in PostDominators.cpp
105 static IncludeFile
106 POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub);
107
108 #endif