Move FunctionArgument out of iOther.h into Argument.h and rename class to
[oota-llvm.git] / include / llvm / Analysis / InstForest.h
index efcbf519f6682aa7fd5ef4b9799e5560654afb36..68f71420a852e6019e0c54d867c25c6ed57b1db2 100644 (file)
@@ -1,4 +1,4 @@
-//===- llvm/Analysis/InstForest.h - Partition Method into forest -*- C++ -*--=//
+//===- llvm/Analysis/InstForest.h - Partition Func into forest ---*- C++ -*--=//
 //
 // This interface is used to partition a method into a forest of instruction
 // trees, where the following invariants hold:
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_INSTFOREST_H
 
 #include "llvm/Instruction.h"
+#include "llvm/BasicBlock.h"
 #include "Support/Tree.h"
 #include <map>
 
@@ -162,13 +163,17 @@ class InstForest : public std::vector<InstTreeNode<Payload> *> {
 
 public:
   // ctor - Create an instruction forest for the specified method...
-  InstForest(Method *M) {
-    for (Method::inst_iterator I = M->inst_begin(), E = M->inst_end();
-        I != E; ++I) {
-      Instruction *Inst = *I;
-      if (!getInstNode(Inst))   // Do we already have a tree for this inst?
-       push_back(new InstTreeNode<Payload>(*this, Inst, 0));  // No create one!
-      // InstTreeNode ctor automatically adds the created node into our InstMap
+  InstForest(Function *F) {
+    for (Function::iterator MI = F->begin(), ME = F->end(); MI != ME; ++MI) {
+      BasicBlock *BB = *MI;
+      for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
+        Instruction *Inst = *I;
+        if (!getInstNode(Inst)) {  // Do we already have a tree for this inst?
+          // No, create one!  InstTreeNode ctor automatically adds the
+          // created node into our InstMap
+          push_back(new InstTreeNode<Payload>(*this, Inst, 0));
+        }
+      }
     }
   }
 
@@ -235,7 +240,7 @@ InstTreeNode<Payload>::InstTreeNode(InstForest<Payload> &IF, Value *V,
  
   if (!isa<Instruction>(V)) {
     assert((isa<Constant>(V) || isa<BasicBlock>(V) ||
-           isa<MethodArgument>(V) || isa<GlobalValue>(V)) &&
+           isa<Argument>(V) || isa<GlobalValue>(V)) &&
           "Unrecognized value type for InstForest Partition!");
     if (isa<Constant>(V))
       getTreeData().first.second = ConstNode;