diff options
Diffstat (limited to 'include/llvm/Function.h')
-rw-r--r-- | include/llvm/Function.h | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 6ec28a87a3..a7075af0cc 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -13,7 +13,6 @@ #include "llvm/SymTabValue.h" #include "llvm/BasicBlock.h" -#include <list> class Instruction; class BasicBlock; @@ -201,4 +200,32 @@ public: inline inst_const_iterator inst_end() const { return inst_const_iterator(*this, true); } }; +// Provide specializations of GraphTraits to be able to treat a method as a +// graph of basic blocks... these are the same as the basic block iterators, +// except that the root node is implicitly the first node of the method. +// +template <> struct GraphTraits<Method*> : public GraphTraits<BasicBlock*> { + static NodeType *getEntryNode(Method *M) { return M->front(); } +}; +template <> struct GraphTraits<const Method*> : + public GraphTraits<const BasicBlock*> { + static NodeType *getEntryNode(const Method *M) { return M->front(); } +}; + +// Provide specializations of GraphTraits to be able to treat a method as a +// graph of basic blocks... and to walk it in inverse order. Inverse order for +// a method is considered to be when traversing the predecessor edges of a BB +// instead of the successor edges. +// +template <> struct GraphTraits<Inverse<Method*> > : + public GraphTraits<Inverse<BasicBlock*> > { + static NodeType *getEntryNode(Inverse<Method *> G) { return G.Graph->front();} +}; +template <> struct GraphTraits<Inverse<const Method*> > : + public GraphTraits<Inverse<const BasicBlock*> > { + static NodeType *getEntryNode(Inverse<const Method *> G) { + return G.Graph->front(); + } +}; + #endif |