Support for llvm_ostreams.
[oota-llvm.git] / include / llvm / Analysis / Dominators.h
index 55650f40b55e069ed7c9fb44d4a22df8f8006395..939300f8aca1598ec1970940fde619a31631b02d 100644 (file)
@@ -304,9 +304,9 @@ protected:
   Node *RootNode;
 public:
   class Node {
-    friend struct DominatorTree;
+    friend class DominatorTree;
     friend struct PostDominatorTree;
-    friend struct DominatorTreeBase;
+    friend class DominatorTreeBase;
     BasicBlock *TheBB;
     Node *IDom;
     std::vector<Node*> Children;
@@ -412,6 +412,62 @@ public:
   virtual void print(std::ostream &OS, const Module* = 0) const;
 };
 
+//===-------------------------------------
+/// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to
+/// compute a normal dominator tree.
+///
+class DominatorTree : public DominatorTreeBase {
+public:
+  DominatorTree() : DominatorTreeBase(false) {}
+  
+  BasicBlock *getRoot() const {
+    assert(Roots.size() == 1 && "Should always have entry node!");
+    return Roots[0];
+  }
+  
+  virtual bool runOnFunction(Function &F) {
+    reset();     // Reset from the last time we were run...
+    ImmediateDominators &ID = getAnalysis<ImmediateDominators>();
+    Roots = ID.getRoots();
+    calculate(ID);
+    return false;
+  }
+  
+  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+    AU.setPreservesAll();
+    AU.addRequired<ImmediateDominators>();
+  }
+private:
+  void calculate(const ImmediateDominators &ID);
+  Node *getNodeForBlock(BasicBlock *BB);
+};
+
+//===-------------------------------------
+/// DominatorTree GraphTraits specialization so the DominatorTree can be
+/// iterable by generic graph iterators.
+///
+template <> struct GraphTraits<DominatorTree::Node*> {
+  typedef DominatorTree::Node 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<DominatorTree*>
+  : public GraphTraits<DominatorTree::Node*> {
+  static NodeType *getEntryNode(DominatorTree *DT) {
+    return DT->getRootNode();
+  }
+};
+
 
 //===-------------------------------------
 /// ET-Forest Class - Class used to construct forwards and backwards 
@@ -535,62 +591,6 @@ public:
   ETNode *getNodeForBlock(BasicBlock *BB);
 };
 
-//===-------------------------------------
-/// DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to
-/// compute a normal dominator tree.
-///
-class DominatorTree : public DominatorTreeBase {
-public:
-  DominatorTree() : DominatorTreeBase(false) {}
-
-  BasicBlock *getRoot() const {
-    assert(Roots.size() == 1 && "Should always have entry node!");
-    return Roots[0];
-  }
-
-  virtual bool runOnFunction(Function &F) {
-    reset();     // Reset from the last time we were run...
-    ImmediateDominators &ID = getAnalysis<ImmediateDominators>();
-    Roots = ID.getRoots();
-    calculate(ID);
-    return false;
-  }
-
-  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-    AU.setPreservesAll();
-    AU.addRequired<ImmediateDominators>();
-  }
-private:
-  void calculate(const ImmediateDominators &ID);
-  Node *getNodeForBlock(BasicBlock *BB);
-};
-
-//===-------------------------------------
-/// DominatorTree GraphTraits specialization so the DominatorTree can be
-/// iterable by generic graph iterators.
-///
-template <> struct GraphTraits<DominatorTree::Node*> {
-  typedef DominatorTree::Node 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<DominatorTree*>
-  : public GraphTraits<DominatorTree::Node*> {
-  static NodeType *getEntryNode(DominatorTree *DT) {
-    return DT->getRootNode();
-  }
-};
-
 //===----------------------------------------------------------------------===//
 /// DominanceFrontierBase - Common base class for computing forward and inverse
 /// dominance frontiers for a function.