-//===- 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:
#define LLVM_ANALYSIS_INSTFOREST_H
#include "llvm/Instruction.h"
+#include "llvm/BasicBlock.h"
#include "Support/Tree.h"
#include <map>
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));
+ }
+ }
}
}
if (!isa<Instruction>(V)) {
assert((isa<Constant>(V) || isa<BasicBlock>(V) ||
- isa<MethodArgument>(V) || isa<GlobalVariable>(V)) &&
+ isa<Argument>(V) || isa<GlobalValue>(V)) &&
"Unrecognized value type for InstForest Partition!");
if (isa<Constant>(V))
getTreeData().first.second = ConstNode;