Completely purge DomSet. This is the (hopefully) final patch for PR1171.
[oota-llvm.git] / include / llvm / Analysis / PostDominators.h
1 //=- llvm/Analysis/PostDominators.h - Post Dominator Calculation-*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file exposes interfaces to post dominance information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_ANALYSIS_POST_DOMINATORS_H
15 #define LLVM_ANALYSIS_POST_DOMINATORS_H
16
17 #include "llvm/Analysis/Dominators.h"
18
19 namespace llvm {
20
21 //===-------------------------------------
22 /// ImmediatePostDominators Class - Concrete subclass of ImmediateDominatorsBase
23 /// that is used to compute a normal immediate dominator set.
24 ///
25 struct ImmediatePostDominators : public ImmediateDominatorsBase {
26   ImmediatePostDominators() : ImmediateDominatorsBase(false) {}
27   
28   virtual bool runOnFunction(Function &F);
29   
30   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
31     AU.setPreservesAll();
32   }
33   
34 private:
35   unsigned DFSPass(BasicBlock *V, InfoRec &VInfo, unsigned N);
36   void Compress(BasicBlock *V, InfoRec &VInfo);
37   BasicBlock *Eval(BasicBlock *v);
38   void Link(BasicBlock *V, BasicBlock *W, InfoRec &WInfo);
39 };
40
41 /// PostDominatorTree Class - Concrete subclass of DominatorTree that is used to
42 /// compute the a post-dominator tree.
43 ///
44 struct PostDominatorTree : public DominatorTreeBase {
45   PostDominatorTree() : DominatorTreeBase(true) {}
46
47   virtual bool runOnFunction(Function &F) {
48     reset();     // Reset from the last time we were run...
49     ImmediatePostDominators &IPD = getAnalysis<ImmediatePostDominators>();
50     Roots = IPD.getRoots();
51     calculate(IPD);
52     return false;
53   }
54
55   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
56     AU.setPreservesAll();
57     AU.addRequired<ImmediatePostDominators>();
58   }
59 private:
60   void calculate(const ImmediatePostDominators &IPD);
61   Node *getNodeForBlock(BasicBlock *BB);
62 };
63
64
65 /// PostETForest Class - Concrete subclass of ETForestBase that is used to
66 /// compute a forwards post-dominator ET-Forest.
67 struct PostETForest : public ETForestBase {
68   PostETForest() : ETForestBase(true) {}
69
70   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
71     AU.setPreservesAll();
72     AU.addRequired<ImmediatePostDominators>();
73   }
74
75   virtual bool runOnFunction(Function &F) {
76     reset();     // Reset from the last time we were run...
77     ImmediatePostDominators &ID = getAnalysis<ImmediatePostDominators>();
78     Roots = ID.getRoots();
79     calculate(ID);
80     return false;
81   }
82
83   void calculate(const ImmediatePostDominators &ID);
84   ETNode *getNodeForBlock(BasicBlock *BB);
85 };
86
87
88 /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
89 /// used to compute the a post-dominance frontier.
90 ///
91 struct PostDominanceFrontier : public DominanceFrontierBase {
92   PostDominanceFrontier() : DominanceFrontierBase(true) {}
93
94   virtual bool runOnFunction(Function &) {
95     Frontiers.clear();
96     PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
97     Roots = DT.getRoots();
98     if (const DominatorTree::Node *Root = DT.getRootNode())
99       calculate(DT, Root);
100     return false;
101   }
102
103   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
104     AU.setPreservesAll();
105     AU.addRequired<PostDominatorTree>();
106   }
107
108 private:
109   const DomSetType &calculate(const PostDominatorTree &DT,
110                               const DominatorTree::Node *Node);
111 };
112
113 } // End llvm namespace
114
115 // Make sure that any clients of this file link in PostDominators.cpp
116 FORCE_DEFINING_FILE_TO_BE_LINKED(PostDominanceFrontier)
117
118 #endif