diff options
author | Chris Lattner <sabre@nondot.org> | 2006-10-03 05:24:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-10-03 05:24:56 +0000 |
commit | b62ff3f7f18de9e7c84d14e91132e07199663f42 (patch) | |
tree | b169b2c46bdd4c4cb13978493a56e75522aff28b /include/llvm/Analysis | |
parent | 9e071f0ae3eb92c61de4860fdb12d4499b50e392 (diff) | |
download | external_llvm-b62ff3f7f18de9e7c84d14e91132e07199663f42.zip external_llvm-b62ff3f7f18de9e7c84d14e91132e07199663f42.tar.gz external_llvm-b62ff3f7f18de9e7c84d14e91132e07199663f42.tar.bz2 |
Move DominatorTree to immediately follow DominatorTreeBase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30693 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r-- | include/llvm/Analysis/Dominators.h | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 55650f4..7cf8256 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -412,6 +412,62 @@ public: virtual void print(std::ostream &OS, const Module* = 0) const; }; +//===------------------------------------- +/// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to +/// compute a normal dominator tree. +/// +class DominatorTree : public DominatorTreeBase { +public: + DominatorTree() : DominatorTreeBase(false) {} + + BasicBlock *getRoot() const { + assert(Roots.size() == 1 && "Should always have entry node!"); + return Roots[0]; + } + + virtual bool runOnFunction(Function &F) { + reset(); // Reset from the last time we were run... + ImmediateDominators &ID = getAnalysis<ImmediateDominators>(); + Roots = ID.getRoots(); + calculate(ID); + return false; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + AU.addRequired<ImmediateDominators>(); + } +private: + void calculate(const ImmediateDominators &ID); + Node *getNodeForBlock(BasicBlock *BB); +}; + +//===------------------------------------- +/// DominatorTree GraphTraits specialization so the DominatorTree can be +/// iterable by generic graph iterators. +/// +template <> struct GraphTraits<DominatorTree::Node*> { + typedef DominatorTree::Node NodeType; + typedef NodeType::iterator ChildIteratorType; + + static NodeType *getEntryNode(NodeType *N) { + return N; + } + static inline ChildIteratorType child_begin(NodeType* N) { + return N->begin(); + } + static inline ChildIteratorType child_end(NodeType* N) { + return N->end(); + } +}; + +template <> struct GraphTraits<DominatorTree*> + : public GraphTraits<DominatorTree::Node*> { + static NodeType *getEntryNode(DominatorTree *DT) { + return DT->getRootNode(); + } +}; + //===------------------------------------- /// ET-Forest Class - Class used to construct forwards and backwards @@ -535,62 +591,6 @@ public: ETNode *getNodeForBlock(BasicBlock *BB); }; -//===------------------------------------- -/// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to -/// compute a normal dominator tree. -/// -class DominatorTree : public DominatorTreeBase { -public: - DominatorTree() : DominatorTreeBase(false) {} - - BasicBlock *getRoot() const { - assert(Roots.size() == 1 && "Should always have entry node!"); - return Roots[0]; - } - - virtual bool runOnFunction(Function &F) { - reset(); // Reset from the last time we were run... - ImmediateDominators &ID = getAnalysis<ImmediateDominators>(); - Roots = ID.getRoots(); - calculate(ID); - return false; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - AU.addRequired<ImmediateDominators>(); - } -private: - void calculate(const ImmediateDominators &ID); - Node *getNodeForBlock(BasicBlock *BB); -}; - -//===------------------------------------- -/// DominatorTree GraphTraits specialization so the DominatorTree can be -/// iterable by generic graph iterators. -/// -template <> struct GraphTraits<DominatorTree::Node*> { - typedef DominatorTree::Node NodeType; - typedef NodeType::iterator ChildIteratorType; - - static NodeType *getEntryNode(NodeType *N) { - return N; - } - static inline ChildIteratorType child_begin(NodeType* N) { - return N->begin(); - } - static inline ChildIteratorType child_end(NodeType* N) { - return N->end(); - } -}; - -template <> struct GraphTraits<DominatorTree*> - : public GraphTraits<DominatorTree::Node*> { - static NodeType *getEntryNode(DominatorTree *DT) { - return DT->getRootNode(); - } -}; - //===----------------------------------------------------------------------===// /// DominanceFrontierBase - Common base class for computing forward and inverse /// dominance frontiers for a function. |