diff options
author | Chris Lattner <sabre@nondot.org> | 2003-02-28 03:05:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-02-28 03:05:15 +0000 |
commit | 1db0a400370466e187ae06c96a1586c2c21409dd (patch) | |
tree | 698f7e503e346d17f9e051fda3fbd7407a2e6f91 | |
parent | 46f1785def6b300d8f398705b2c1aa1687b9ce70 (diff) |
Add graph traits specializations for loop nesting information...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5666 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 6b96625c63..a90296599a 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -19,6 +19,7 @@ #define LLVM_ANALYSIS_LOOP_INFO_H #include "llvm/Pass.h" +#include "Support/GraphTraits.h" #include <set> class DominatorSet; @@ -186,4 +187,31 @@ private: static IncludeFile LOOP_INFO_INCLUDE_FILE((void*)&LoopInfo::stub); +// Allow clients to walk the list of nested loops... +template <> struct GraphTraits<const Loop*> { + typedef const Loop NodeType; + typedef std::vector<Loop*>::const_iterator ChildIteratorType; + + static NodeType *getEntryNode(const Loop *L) { return L; } + static inline ChildIteratorType child_begin(NodeType *N) { + return N->getSubLoops().begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->getSubLoops().end(); + } +}; + +template <> struct GraphTraits<Loop*> { + typedef Loop NodeType; + typedef std::vector<Loop*>::const_iterator ChildIteratorType; + + static NodeType *getEntryNode(Loop *L) { return L; } + static inline ChildIteratorType child_begin(NodeType *N) { + return N->getSubLoops().begin(); + } + static inline ChildIteratorType child_end(NodeType *N) { + return N->getSubLoops().end(); + } +}; + #endif |