[llvm-commits] [llvm] r45333 - /llvm/trunk/include/llvm/CodeGen/MachineDominators.h

Owen Anderson resistor at mac.com
Sun Dec 23 07:16:50 PST 2007


Author: resistor
Date: Sun Dec 23 09:16:46 2007
New Revision: 45333

URL: http://llvm.org/viewvc/llvm-project?rev=45333&view=rev
Log:
Add GraphTraits specializations for machine dominators.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineDominators.h

Modified: llvm/trunk/include/llvm/CodeGen/MachineDominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineDominators.h?rev=45333&r1=45332&r2=45333&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineDominators.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineDominators.h Sun Dec 23 09:16:46 2007
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Analysis/DominatorInternals.h"
+#include "llvm/ADT/GraphTraits.h"
 
 namespace llvm {
 
@@ -182,6 +183,32 @@
   }
 };
 
+//===-------------------------------------
+/// DominatorTree GraphTraits specialization so the DominatorTree can be
+/// iterable by generic graph iterators.
+///
+template <> struct GraphTraits<MachineDomTreeNode *> {
+  typedef MachineDomTreeNode NodeType;
+  typedef NodeType::iterator  ChildIteratorType;
+  
+  static NodeType *getEntryNode(NodeType *N) {
+    return N;
+  }
+  static inline ChildIteratorType child_begin(NodeType* N) {
+    return N->begin();
+  }
+  static inline ChildIteratorType child_end(NodeType* N) {
+    return N->end();
+  }
+};
+
+template <> struct GraphTraits<MachineDominatorTree*>
+  : public GraphTraits<MachineDomTreeNode *> {
+  static NodeType *getEntryNode(MachineDominatorTree *DT) {
+    return DT->getRootNode();
+  }
+};
+
 }
 
 #endif





More information about the llvm-commits mailing list