aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-05-01 21:05:34 +0000
committerChris Lattner <sabre@nondot.org>2004-05-01 21:05:34 +0000
commit0aef12a7a96968a80c38144dfc0a7ae6a9152db9 (patch)
tree55f1a10210ec030f587b13d0e403eb460be2fa99
parenta19a3db4465e33eeebcdac94b0f6abeda7801aab (diff)
Move the GraphTraits for MachineBasicBlocks to the MachineBasicBlock file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13299 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/MachineBasicBlock.h70
-rw-r--r--include/llvm/Support/CFG.h124
2 files changed, 70 insertions, 124 deletions
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h
index df2a15a05f..aadc835c25 100644
--- a/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/include/llvm/CodeGen/MachineBasicBlock.h
@@ -15,6 +15,7 @@
#define LLVM_CODEGEN_MACHINEBASICBLOCK_H
#include "llvm/CodeGen/MachineInstr.h"
+#include "Support/GraphTraits.h"
#include "Support/ilist"
#include <iosfwd>
@@ -197,6 +198,75 @@ private: // Methods used to maintain doubly linked list of blocks...
}
};
+
+//===--------------------------------------------------------------------===//
+// GraphTraits specializations for machine basic block graphs (machine-CFGs)
+//===--------------------------------------------------------------------===//
+
+// Provide specializations of GraphTraits to be able to treat a
+// MachineFunction as a graph of MachineBasicBlocks...
+//
+
+template <> struct GraphTraits<MachineBasicBlock *> {
+ typedef MachineBasicBlock NodeType;
+ typedef MachineBasicBlock::succ_iterator ChildIteratorType;
+
+ static NodeType *getEntryNode(MachineBasicBlock *BB) { return BB; }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return N->succ_begin();
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return N->succ_end();
+ }
+};
+
+template <> struct GraphTraits<const MachineBasicBlock *> {
+ typedef const MachineBasicBlock NodeType;
+ typedef MachineBasicBlock::const_succ_iterator ChildIteratorType;
+
+ static NodeType *getEntryNode(const MachineBasicBlock *BB) { return BB; }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return N->succ_begin();
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return N->succ_end();
+ }
+};
+
+// Provide specializations of GraphTraits to be able to treat a
+// MachineFunction as a graph of MachineBasicBlocks... and to walk it
+// in inverse order. Inverse order for a function is considered
+// to be when traversing the predecessor edges of a MBB
+// instead of the successor edges.
+//
+template <> struct GraphTraits<Inverse<MachineBasicBlock*> > {
+ typedef MachineBasicBlock NodeType;
+ typedef MachineBasicBlock::pred_iterator ChildIteratorType;
+ static NodeType *getEntryNode(Inverse<MachineBasicBlock *> G) {
+ return G.Graph;
+ }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return N->pred_begin();
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return N->pred_end();
+ }
+};
+
+template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > {
+ typedef const MachineBasicBlock NodeType;
+ typedef MachineBasicBlock::const_pred_iterator ChildIteratorType;
+ static NodeType *getEntryNode(Inverse<const MachineBasicBlock*> G) {
+ return G.Graph;
+ }
+ static inline ChildIteratorType child_begin(NodeType *N) {
+ return N->pred_begin();
+ }
+ static inline ChildIteratorType child_end(NodeType *N) {
+ return N->pred_end();
+ }
+};
+
} // End llvm namespace
#endif
diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h
index 6b239b5df7..bbe1701da1 100644
--- a/include/llvm/Support/CFG.h
+++ b/include/llvm/Support/CFG.h
@@ -17,7 +17,6 @@
#include "Support/GraphTraits.h"
#include "llvm/Function.h"
-#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/InstrTypes.h"
#include "Support/iterator"
@@ -267,129 +266,6 @@ template <> struct GraphTraits<Inverse<const Function*> > :
}
};
-//===--------------------------------------------------------------------===//
-// GraphTraits specializations for machine basic block graphs (machine-CFGs)
-//===--------------------------------------------------------------------===//
-
-// Provide specializations of GraphTraits to be able to treat a
-// MachineFunction as a graph of MachineBasicBlocks...
-//
-
-template <> struct GraphTraits<MachineBasicBlock *> {
- typedef MachineBasicBlock NodeType;
- typedef MachineBasicBlock::succ_iterator ChildIteratorType;
-
- static NodeType *getEntryNode(MachineBasicBlock *BB) { return BB; }
- static inline ChildIteratorType child_begin(NodeType *N) {
- return N->succ_begin();
- }
- static inline ChildIteratorType child_end(NodeType *N) {
- return N->succ_end();
- }
-};
-
-template <> struct GraphTraits<const MachineBasicBlock *> {
- typedef const MachineBasicBlock NodeType;
- typedef MachineBasicBlock::const_succ_iterator ChildIteratorType;
-
- static NodeType *getEntryNode(const MachineBasicBlock *BB) { return BB; }
- static inline ChildIteratorType child_begin(NodeType *N) {
- return N->succ_begin();
- }
- static inline ChildIteratorType child_end(NodeType *N) {
- return N->succ_end();
- }
-};
-
-// Provide specializations of GraphTraits to be able to treat a
-// MachineFunction as a graph of MachineBasicBlocks... and to walk it
-// in inverse order. Inverse order for a function is considered
-// to be when traversing the predecessor edges of a MBB
-// instead of the successor edges.
-//
-template <> struct GraphTraits<Inverse<MachineBasicBlock*> > {
- typedef MachineBasicBlock NodeType;
- typedef MachineBasicBlock::pred_iterator ChildIteratorType;
- static NodeType *getEntryNode(Inverse<MachineBasicBlock *> G) {
- return G.Graph;
- }
- static inline ChildIteratorType child_begin(NodeType *N) {
- return N->pred_begin();
- }
- static inline ChildIteratorType child_end(NodeType *N) {
- return N->pred_end();
- }
-};
-
-template <> struct GraphTraits<Inverse<const MachineBasicBlock*> > {
- typedef const MachineBasicBlock NodeType;
- typedef MachineBasicBlock::const_pred_iterator ChildIteratorType;
- static NodeType *getEntryNode(Inverse<const MachineBasicBlock*> G) {
- return G.Graph;
- }
- static inline ChildIteratorType child_begin(NodeType *N) {
- return N->pred_begin();
- }
- static inline ChildIteratorType child_end(NodeType *N) {
- return N->pred_end();
- }
-};
-
-
-//===--------------------------------------------------------------------===//
-// GraphTraits specializations for MachineFunction bb graphs (machine-CFGs)
-//===--------------------------------------------------------------------===//
-
-// Provide specializations of GraphTraits to be able to treat a
-// MachineFunction as a graph of MachineBasicBlocks... these are the
-// same as the MachineBasicBlock iterators, except that the root node
-// is implicitly the first node of the MachineFunction.
-//
-template <> struct GraphTraits<MachineFunction*> :
- public GraphTraits<MachineBasicBlock*> {
- static NodeType *getEntryNode(MachineFunction *F) {
- return &F->front();
- }
- // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
- typedef MachineFunction::iterator nodes_iterator;
- static nodes_iterator nodes_begin(MachineFunction *F) { return F->begin(); }
- static nodes_iterator nodes_end (MachineFunction *F) { return F->end(); }
-};
-template <> struct GraphTraits<const MachineFunction*> :
- public GraphTraits<const MachineBasicBlock*> {
- static NodeType *getEntryNode(const MachineFunction *F) {
- return &F->front();
- }
- // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
- typedef MachineFunction::const_iterator nodes_iterator;
- static nodes_iterator nodes_begin(const MachineFunction *F) {
- return F->begin();
- }
- static nodes_iterator nodes_end (const MachineFunction *F) {
- return F->end();
- }
-};
-
-
-// Provide specializations of GraphTraits to be able to treat a
-// MachineFunction as a graph of MachineBasicBlocks... and to walk it
-// in inverse order. Inverse order for a MachineFunction is considered
-// to be when traversing the predecessor edges of a MBB instead of the
-// successor edges.
-//
-template <> struct GraphTraits<Inverse<MachineFunction*> > :
- public GraphTraits<Inverse<MachineBasicBlock*> > {
- static NodeType *getEntryNode(Inverse<MachineFunction*> G) {
- return &G.Graph->front();
- }
-};
-template <> struct GraphTraits<Inverse<const MachineFunction*> > :
- public GraphTraits<Inverse<const MachineBasicBlock*> > {
- static NodeType *getEntryNode(Inverse<const MachineFunction *> G) {
- return &G.Graph->front();
- }
-};
-
} // End llvm namespace
#endif