diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-18 04:05:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-18 04:05:53 +0000 |
commit | d3400b4c86a0c7027aec4082db5d114be2d8cdf1 (patch) | |
tree | 825291c3e9e679b9d2986828679d80ef95df9a95 | |
parent | 0013afb6acc7eff3fb7eee2cd2ad77f55f7ad517 (diff) | |
download | llvm-d3400b4c86a0c7027aec4082db5d114be2d8cdf1.zip llvm-d3400b4c86a0c7027aec4082db5d114be2d8cdf1.tar.gz llvm-d3400b4c86a0c7027aec4082db5d114be2d8cdf1.tar.bz2 |
add nodes_begin/end/iterator for dominfo, patch by Tobias Grosser!
llvm-svn: 84395
-rw-r--r-- | llvm/include/llvm/Analysis/Dominators.h | 27 | ||||
-rw-r--r-- | llvm/include/llvm/Analysis/PostDominators.h | 15 |
2 files changed, 38 insertions, 4 deletions
diff --git a/llvm/include/llvm/Analysis/Dominators.h b/llvm/include/llvm/Analysis/Dominators.h index f63e31c..59ce6e7 100644 --- a/llvm/include/llvm/Analysis/Dominators.h +++ b/llvm/include/llvm/Analysis/Dominators.h @@ -25,6 +25,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -824,26 +825,44 @@ public: /// DominatorTree GraphTraits specialization so the DominatorTree can be /// iterable by generic graph iterators. /// -template <> struct GraphTraits<DomTreeNode *> { +template <> struct GraphTraits<DomTreeNode*> { typedef DomTreeNode NodeType; typedef NodeType::iterator ChildIteratorType; static NodeType *getEntryNode(NodeType *N) { return N; } - static inline ChildIteratorType child_begin(NodeType* N) { + static inline ChildIteratorType child_begin(NodeType *N) { return N->begin(); } - static inline ChildIteratorType child_end(NodeType* N) { + static inline ChildIteratorType child_end(NodeType *N) { return N->end(); } + + typedef df_iterator<DomTreeNode*> nodes_iterator; + + static nodes_iterator nodes_begin(DomTreeNode *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DomTreeNode *N) { + return df_end(getEntryNode(N)); + } }; template <> struct GraphTraits<DominatorTree*> - : public GraphTraits<DomTreeNode *> { + : public GraphTraits<DomTreeNode*> { static NodeType *getEntryNode(DominatorTree *DT) { return DT->getRootNode(); } + + static nodes_iterator nodes_begin(DominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(DominatorTree *N) { + return df_end(getEntryNode(N)); + } }; diff --git a/llvm/include/llvm/Analysis/PostDominators.h b/llvm/include/llvm/Analysis/PostDominators.h index 171cfdb..42a16e7 100644 --- a/llvm/include/llvm/Analysis/PostDominators.h +++ b/llvm/include/llvm/Analysis/PostDominators.h @@ -74,6 +74,21 @@ struct PostDominatorTree : public FunctionPass { FunctionPass* createPostDomTree(); +template <> struct GraphTraits<PostDominatorTree*> + : public GraphTraits<DomTreeNode*> { + static NodeType *getEntryNode(PostDominatorTree *DT) { + return DT->getRootNode(); + } + + static nodes_iterator nodes_begin(PostDominatorTree *N) { + return df_begin(getEntryNode(N)); + } + + static nodes_iterator nodes_end(PostDominatorTree *N) { + return df_end(getEntryNode(N)); + } +}; + /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is /// used to compute the a post-dominance frontier. /// |