aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Function.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-28 22:56:31 +0000
committerChris Lattner <sabre@nondot.org>2001-09-28 22:56:31 +0000
commit3ff4387113d7e74a8aa73f80c3518cb95f09a64b (patch)
tree7e55b84e841721d133477294b2fee246ee6ceaed /include/llvm/Function.h
parentc56d779501901e22103a1236768cb97fd9b5c9b0 (diff)
Pull iterators out of CFG.h and CFGdecls and put them in Support directory
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Function.h')
-rw-r--r--include/llvm/Function.h29
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