Change references to the Method class to be references to the Function
authorChris Lattner <sabre@nondot.org>
Sun, 7 Apr 2002 20:49:59 +0000 (20:49 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 7 Apr 2002 20:49:59 +0000 (20:49 +0000)
class.  The Method class is obsolete (renamed) and all references to it
are being converted over to Function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2144 91177308-0d34-0410-b5e6-96231b3b80d8

57 files changed:
include/llvm/Analysis/IntervalIterator.h
include/llvm/Support/CFG.h
include/llvm/Support/InstIterator.h
include/llvm/Transforms/Scalar/DCE.h
lib/Analysis/IPA/FindUnsafePointerTypes.cpp
lib/Analysis/IPA/FindUsedTypes.cpp
lib/Analysis/IntervalPartition.cpp
lib/Analysis/PostDominators.cpp
lib/Bytecode/Writer/InstructionWriter.cpp
lib/Bytecode/Writer/SlotCalculator.cpp
lib/CodeGen/InstrSched/SchedGraph.cpp
lib/CodeGen/InstrSelection/InstrSelection.cpp
lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
lib/CodeGen/MachineFunction.cpp
lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/ExecutionEngine/Interpreter/Execution.cpp
lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
lib/ExecutionEngine/Interpreter/Interpreter.h
lib/ExecutionEngine/Interpreter/Support.cpp
lib/ExecutionEngine/Interpreter/UserInput.cpp
lib/Target/SparcV9/InstrSched/SchedGraph.cpp
lib/Target/SparcV9/InstrSelection/InstrSelection.cpp
lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9AsmPrinter.cpp
lib/Target/SparcV9/SparcV9InstrInfo.cpp
lib/Target/SparcV9/SparcV9InstrSelection.cpp
lib/Target/SparcV9/SparcV9TargetMachine.cpp
lib/Transforms/ExprTypeConvert.cpp
lib/Transforms/HoistPHIConstants.cpp
lib/Transforms/IPO/ConstantMerge.cpp
lib/Transforms/IPO/GlobalDCE.cpp
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp
lib/Transforms/LevelRaise.cpp
lib/Transforms/Scalar/ConstantProp.cpp
lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/Transforms/Scalar/SymbolStripping.cpp
lib/Transforms/TransformInternals.cpp
lib/Transforms/Utils/PromoteMemoryToRegister.cpp
lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
lib/VMCore/Dominators.cpp
lib/VMCore/Instruction.cpp
lib/VMCore/SlotCalculator.cpp
lib/VMCore/iCall.cpp
tools/analyze/analyze.cpp
tools/dis/dis.cpp
tools/gccld/gccld.cpp
tools/link/link.cpp
tools/llc/llc.cpp
tools/llvm-dis/dis.cpp
tools/llvm-dis/llvm-dis.cpp
tools/llvm-link/llvm-link.cpp

index 3c27f1ae8b97880d528b390a3635a561c85377a1..55413d4ada494131e4b44b2513119e349834c291 100644 (file)
@@ -4,7 +4,7 @@
 // graph of some sort.  This iterator is parametric, allowing iterator over the
 // following types of graphs:
 // 
-//  1. A Method* object, composed of BasicBlock nodes.
+//  1. A Function* object, composed of BasicBlock nodes.
 //  2. An IntervalPartition& object, composed of Interval nodes.
 //
 // This iterator is defined to walk the control flow graph, returning intervals
@@ -27,7 +27,7 @@
 #define LLVM_INTERVAL_ITERATOR_H
 
 #include "llvm/Analysis/IntervalPartition.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Support/CFG.h"
 #include <stack>
@@ -47,7 +47,7 @@ inline BasicBlock *getNodeHeader(Interval *I) { return I->getHeaderNode(); }
 // source graph node that corresponds to the BasicBlock.  This is the opposite
 // of getNodeHeader.
 //
-inline BasicBlock *getSourceGraphNode(Method *, BasicBlock *BB) {
+inline BasicBlock *getSourceGraphNode(Function *, BasicBlock *BB) {
   return BB; 
 }
 inline Interval *getSourceGraphNode(IntervalPartition *IP, BasicBlock *BB) { 
@@ -93,7 +93,7 @@ public:
   typedef std::forward_iterator_tag iterator_category;
  
   IntervalIterator() {} // End iterator, empty stack
-  IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) {
+  IntervalIterator(Function *M, bool OwnMemory) : IOwnMem(OwnMemory) {
     OrigContainer = M;
     if (!ProcessInterval(M->front())) {
       assert(0 && "ProcessInterval should never fail for first interval!");
@@ -227,16 +227,16 @@ private:
   }
 };
 
-typedef IntervalIterator<BasicBlock, Method> method_interval_iterator;
+typedef IntervalIterator<BasicBlock, Function> function_interval_iterator;
 typedef IntervalIterator<Interval, IntervalPartition> interval_part_interval_iterator;
 
 
-inline method_interval_iterator intervals_begin(Method *M
-                                               bool DeleteInts = true) {
-  return method_interval_iterator(M, DeleteInts);
+inline function_interval_iterator intervals_begin(Function *F
+                                                  bool DeleteInts = true) {
+  return function_interval_iterator(F, DeleteInts);
 }
-inline method_interval_iterator intervals_end(Method *M) {
-  return method_interval_iterator();
+inline function_interval_iterator intervals_end(Function *) {
+  return function_interval_iterator();
 }
 
 inline interval_part_interval_iterator 
index b6aa56e38519cf590f804fb6dc2536a087d4949d..db4c0c322e7d1c5e75be0879ac4b5ed29888936d 100644 (file)
@@ -1,6 +1,6 @@
 //===-- llvm/Support/CFG.h - Process LLVM structures as graphs ---*- C++ -*--=//
 //
-// This file defines specializations of GraphTraits that allow Methods and
+// This file defines specializations of GraphTraits that allow Function and
 // BasicBlock graphs to be treated as proper graphs for generic algorithms.
 //
 //===----------------------------------------------------------------------===//
@@ -9,7 +9,7 @@
 #define LLVM_CFG_H
 
 #include "Support/GraphTraits.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/InstrTypes.h"
 #include <iterator>
@@ -137,7 +137,7 @@ inline succ_const_iterator succ_end(const BasicBlock *BB) {
 // GraphTraits specializations for basic block graphs (CFGs)
 //===--------------------------------------------------------------------===//
 
-// Provide specializations of GraphTraits to be able to treat a method as a 
+// Provide specializations of GraphTraits to be able to treat a function as a 
 // graph of basic blocks...
 
 template <> struct GraphTraits<BasicBlock*> {
@@ -167,9 +167,9 @@ template <> struct GraphTraits<const BasicBlock*> {
   }
 };
 
-// Provide specializations of GraphTraits to be able to treat a method as a 
+// Provide specializations of GraphTraits to be able to treat a function as a 
 // graph of basic blocks... and to walk it in inverse order.  Inverse order for
-// a method is considered to be when traversing the predecessor edges of a BB
+// a function is considered to be when traversing the predecessor edges of a BB
 // instead of the successor edges.
 //
 template <> struct GraphTraits<Inverse<BasicBlock*> > {
@@ -201,34 +201,36 @@ template <> struct GraphTraits<Inverse<const BasicBlock*> > {
 
 
 //===--------------------------------------------------------------------===//
-// GraphTraits specializations for method basic block graphs (CFGs)
+// GraphTraits specializations for function basic block graphs (CFGs)
 //===--------------------------------------------------------------------===//
 
-// Provide specializations of GraphTraits to be able to treat a method as a 
+// Provide specializations of GraphTraits to be able to treat a function as a 
 // graph of basic blocks... these are the same as the basic block iterators,
-// except that the root node is implicitly the first node of the method.
+// except that the root node is implicitly the first node of the function.
 //
-template <> struct GraphTraits<Method*> : public GraphTraits<BasicBlock*> {
-  static NodeType *getEntryNode(Method *M) { return M->front(); }
+template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> {
+  static NodeType *getEntryNode(Function *F) { return F->getEntryNode(); }
 };
-template <> struct GraphTraits<const Method*> :
+template <> struct GraphTraits<const Function*> :
   public GraphTraits<const BasicBlock*> {
-  static NodeType *getEntryNode(const Method *M) { return M->front(); }
+  static NodeType *getEntryNode(const Function *F) { return F->getEntryNode(); }
 };
 
 
-// Provide specializations of GraphTraits to be able to treat a method as a 
+// Provide specializations of GraphTraits to be able to treat a function as a 
 // graph of basic blocks... and to walk it in inverse order.  Inverse order for
-// a method is considered to be when traversing the predecessor edges of a BB
+// a function is considered to be when traversing the predecessor edges of a BB
 // instead of the successor edges.
 //
-template <> struct GraphTraits<Inverse<Method*> > :
+template <> struct GraphTraits<Inverse<Function*> > :
   public GraphTraits<Inverse<BasicBlock*> > {
-  static NodeType *getEntryNode(Inverse<Method *> G) { return G.Graph->front();}
+  static NodeType *getEntryNode(Inverse<Function*> G) {
+    return G.Graph->front();
+  }
 };
-template <> struct GraphTraits<Inverse<const Method*> > :
+template <> struct GraphTraits<Inverse<const Function*> > :
   public GraphTraits<Inverse<const BasicBlock*> > {
-  static NodeType *getEntryNode(Inverse<const Method *> G) {
+  static NodeType *getEntryNode(Inverse<const Function *> G) {
     return G.Graph->front();
   }
 };
index 517e6d26a489c31b2e06edab498ce5762e13e9be..b2b1058056e30e488ac155ad6219bc79dba345fe 100644 (file)
@@ -1,7 +1,7 @@
 //===-- llvm/Support/InstIterator.h - Classes for inst iteration -*- C++ -*--=//
 //
 // This file contains definitions of two iterators for iterating over the
-// instructions in a method.  This is effectively a wrapper around a two level
+// instructions in a function.  This is effectively a wrapper around a two level
 // iterator that can probably be genericized later.
 //
 // Note that this iterator gets invalidated any time that basic blocks or
@@ -13,7 +13,7 @@
 #define LLVM_INST_ITERATOR_H
 
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 
 // This class is implements inst_begin() & inst_end() for
 // inst_iterator and const_inst_iterator's.
@@ -96,20 +96,21 @@ private:
 };
 
 
-typedef InstIterator<ValueHolder<BasicBlock, Method, Method>, Method::iterator, 
-                     BasicBlock::iterator, Instruction*> inst_iterator;
-typedef InstIterator<const ValueHolder<BasicBlock, Method, Method>,
-                     Method::const_iterator, 
+typedef InstIterator<ValueHolder<BasicBlock, Function, Function>,
+                     Function::iterator, BasicBlock::iterator,
+                     Instruction*> inst_iterator;
+typedef InstIterator<const ValueHolder<BasicBlock, Function, Function>,
+                     Function::const_iterator, 
                      BasicBlock::const_iterator,
                      const Instruction*> const_inst_iterator;
 
-inline inst_iterator inst_begin(Method *M) { return inst_iterator(*M); }
-inline inst_iterator inst_end(Method *M)   { return inst_iterator(*M, true); }
-inline const_inst_iterator inst_begin(const Method *M) {
-  return const_inst_iterator(*M);
+inline inst_iterator inst_begin(Function *F) { return inst_iterator(*F); }
+inline inst_iterator inst_end(Function *F)   { return inst_iterator(*F, true); }
+inline const_inst_iterator inst_begin(const Function *F) {
+  return const_inst_iterator(*F);
 }
-inline const_inst_iterator inst_end(const Method *M) {
-  return const_inst_iterator(*M, true);
+inline const_inst_iterator inst_end(const Function *F) {
+  return const_inst_iterator(*F, true);
 }
 
 #endif
index a8dcb591467fc087dff708a74b0fbaaeb5d96a5d..35b929d7e7bd36f70b72deac5f3b0c1cf122b92d 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef LLVM_TRANSFORMS_SCALAR_DCE_H
 #define LLVM_TRANSFORMS_SCALAR_DCE_H
 
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 class Pass;
 
@@ -60,6 +60,6 @@ Pass *createAgressiveDCEPass();
 //
 // WARNING:  The entry node of a method may not be simplified.
 //
-bool SimplifyCFG(Method::iterator &BBIt);
+bool SimplifyCFG(Function::iterator &BBIt);
 
 #endif
index 0179cbb74c884c317d24baf1e583602532de2f12..d689d93cd4433f8b29a6779d33d2d2443eb4168b 100644 (file)
@@ -1,4 +1,4 @@
-//===- SafePointerAccess.cpp - Check pointer usage safety -------------------=//
+//===- FindUnsafePointerTypes.cpp - Check pointer usage safety --------------=//
 //
 // This file defines a pass that can be used to determine, interprocedurally, 
 // which pointer types are accessed unsafely in a program.  If there is an
@@ -20,7 +20,7 @@
 #include "llvm/Assembly/CachedWriter.h"
 #include "llvm/Type.h"
 #include "llvm/Instruction.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Module.h"
 #include "llvm/Support/InstIterator.h"
 #include "Support/CommandLine.h"
@@ -51,14 +51,10 @@ static inline bool isSafeInstruction(const Instruction *I) {
 }
 
 
-// runOnMethod - Inspect the operations that the specified method does on
-// values of various types.  If they are deemed to be 'unsafe' note that the
-// type is not safe to transform.
-//
 bool FindUnsafePointerTypes::run(Module *Mod) {
   for (Module::iterator MI = Mod->begin(), ME = Mod->end();
        MI != ME; ++MI) {
-    const Method *M = *MI;  // We don't need/want write access
+    const Function *M = *MI;  // We don't need/want write access
     for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
       const Instruction *Inst = *I;
       const Type *ITy = Inst->getType();
index e67fe322f713856cdc9826afd0937057525ac7e0..5c961d2bebe7b72d8e3fc04a4ca68514152460ae 100644 (file)
@@ -1,4 +1,4 @@
-//===- FindUsedTypes.h - Find all Types used by a module --------------------=//
+//===- FindUsedTypes.cpp - Find all Types used by a module ------------------=//
 //
 // This pass is used to seek out all of the types in use by the program.
 //
@@ -10,7 +10,7 @@
 #include "llvm/GlobalVariable.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Instruction.h"
 #include "llvm/Support/InstIterator.h"
 
@@ -41,7 +41,7 @@ void FindUsedTypes::IncorporateSymbolTable(const SymbolTable *ST) {
   assert(0 && "Unimp");
 }
 
-// doPerMethodWork - This incorporates all types used by the specified method
+// run - This incorporates all types used by the specified module
 //
 bool FindUsedTypes::run(Module *m) {
   UsedTypes.clear();  // reset if run multiple times...
@@ -54,12 +54,12 @@ bool FindUsedTypes::run(Module *m) {
     IncorporateType((*I)->getType());
 
   for (Module::iterator MI = m->begin(), ME = m->end(); MI != ME; ++MI) {
-    const Method *M = *MI;
+    const Function *M = *MI;
     if (IncludeSymbolTables && M->hasSymbolTable())
       IncorporateSymbolTable(M->getSymbolTable()); // Add symtab first...
   
-    // Loop over all of the instructions in the method, adding their return type
-    // as well as the types of their operands.
+    // Loop over all of the instructions in the function, adding their return
+    // type as well as the types of their operands.
     //
     for (const_inst_iterator II = inst_begin(M), IE = inst_end(M);
          II != IE; ++II) {
index f524d016f16843c9f4fe3a176068d359590efd56..197bed26d79dbb44da83313ed72ce2e3880d5b37 100644 (file)
@@ -1,7 +1,7 @@
 //===- IntervalPartition.cpp - Interval Partition module code ----*- C++ -*--=//
 //
 // This file contains the definition of the cfg::IntervalPartition class, which
-// calculates and represent the interval partition of a method.
+// calculates and represent the interval partition of a function.
 //
 //===----------------------------------------------------------------------===//
 
@@ -17,7 +17,7 @@ AnalysisID IntervalPartition::ID(AnalysisID::create<IntervalPartition>());
 // IntervalPartition Implementation
 //===----------------------------------------------------------------------===//
 
-// destroy - Reset state back to before method was analyzed
+// destroy - Reset state back to before function was analyzed
 void IntervalPartition::destroy() {
   for_each(begin(), end(), deleter<cfg::Interval>);
   IntervalMap.clear();
@@ -50,14 +50,14 @@ void IntervalPartition::updatePredecessors(cfg::Interval *Int) {
 }
 
 // IntervalPartition ctor - Build the first level interval partition for the
-// specified method...
+// specified function...
 //
-bool IntervalPartition::runOnMethod(Method *M) {
+bool IntervalPartition::runOnMethod(Function *M) {
   assert(M->front() && "Cannot operate on prototypes!");
 
   // Pass false to intervals_begin because we take ownership of it's memory
-  method_interval_iterator I = intervals_begin(M, false);
-  assert(I != intervals_end(M) && "No intervals in method!?!?!");
+  function_interval_iterator I = intervals_begin(M, false);
+  assert(I != intervals_end(M) && "No intervals in function!?!?!");
 
   addIntervalToPartition(RootInterval = *I);
 
@@ -80,8 +80,8 @@ bool IntervalPartition::runOnMethod(Method *M) {
 // distinguish it from a copy constructor.  Always pass in false for now.
 //
 IntervalPartition::IntervalPartition(IntervalPartition &IP, bool) {
-  Interval *MethodStart = IP.getRootInterval();
-  assert(MethodStart && "Cannot operate on empty IntervalPartitions!");
+  Interval *FunctionStart = IP.getRootInterval();
+  assert(FunctionStart && "Cannot operate on empty IntervalPartitions!");
 
   // Pass false to intervals_begin because we take ownership of it's memory
   interval_part_interval_iterator I = intervals_begin(IP, false);
index 48cc86fcaf542dc3612e1f1d6046112ad84ce7a2..71ee3d74cf99d17e483b2621f3c4bc3731e9db54 100644 (file)
@@ -1,12 +1,13 @@
 //===- DominatorSet.cpp - Dominator Set Calculation --------------*- C++ -*--=//
 //
-// This file provides a simple class to calculate the dominator set of a method.
+// This file provides a simple class to calculate the dominator set of a
+// function.
 //
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Transforms/UnifyMethodExitNodes.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Support/CFG.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/STLExtras.h"
@@ -21,31 +22,31 @@ using std::set;
 AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>());
 AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>());
 
-bool cfg::DominatorSet::runOnMethod(Method *M) {
+bool cfg::DominatorSet::runOnMethod(Function *F) {
   Doms.clear();   // Reset from the last time we were run...
 
   if (isPostDominator())
-    calcPostDominatorSet(M);
+    calcPostDominatorSet(F);
   else
-    calcForwardDominatorSet(M);
+    calcForwardDominatorSet(F);
   return false;
 }
 
 
 // calcForwardDominatorSet - This method calculates the forward dominator sets
-// for the specified method.
+// for the specified function.
 //
-void cfg::DominatorSet::calcForwardDominatorSet(Method *M) {
+void cfg::DominatorSet::calcForwardDominatorSet(Function *M) {
   Root = M->getEntryNode();
   assert(pred_begin(Root) == pred_end(Root) &&
-        "Root node has predecessors in method!");
+        "Root node has predecessors in function!");
 
   bool Changed;
   do {
     Changed = false;
 
     DomSetType WorkingSet;
-    df_iterator<Method*> It = df_begin(M), End = df_end(M);
+    df_iterator<Function*> It = df_begin(M), End = df_end(M);
     for ( ; It != End; ++It) {
       const BasicBlock *BB = *It;
       pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
@@ -75,19 +76,19 @@ void cfg::DominatorSet::calcForwardDominatorSet(Method *M) {
   } while (Changed);
 }
 
-// Postdominator set constructor.  This ctor converts the specified method to
+// Postdominator set constructor.  This ctor converts the specified function to
 // only have a single exit node (return stmt), then calculates the post
-// dominance sets for the method.
+// dominance sets for the function.
 //
-void cfg::DominatorSet::calcPostDominatorSet(Method *M) {
+void cfg::DominatorSet::calcPostDominatorSet(Function *M) {
   // Since we require that the unify all exit nodes pass has been run, we know
-  // that there can be at most one return instruction in the method left.
+  // that there can be at most one return instruction in the function left.
   // Get it.
   //
   Root = getAnalysis<UnifyMethodExitNodes>().getExitNode();
 
-  if (Root == 0) {  // No exit node for the method?  Postdomsets are all empty
-    for (Method::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
+  if (Root == 0) {  // No exit node for the function?  Postdomsets are all empty
+    for (Function::const_iterator MI = M->begin(), ME = M->end(); MI!=ME; ++MI)
       Doms[*MI] = DomSetType();
     return;
   }
@@ -207,12 +208,12 @@ void cfg::DominatorTree::reset() {
 // Given immediate dominators, we can also calculate the dominator tree
 cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms) 
   : DominatorBase(IDoms.getRoot()) {
-  const Method *M = Root->getParent();
+  const Function *M = Root->getParent();
 
   Nodes[Root] = new Node(Root, 0);   // Add a node for the root...
 
   // Iterate over all nodes in depth first order...
-  for (df_iterator<const Method*> I = df_begin(M), E = df_end(M); I != E; ++I) {
+  for (df_iterator<const Function*> I = df_begin(M), E = df_end(M); I!=E; ++I) {
     const BasicBlock *BB = *I, *IDom = IDoms[*I];
 
     if (IDom != 0) {   // Ignore the root node and other nasty nodes
@@ -249,7 +250,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
       // current node, and it is our idom!  We know that we have already added
       // a DominatorTree node for our idom, because the idom must be a
       // predecessor in the depth first order that we are iterating through the
-      // method.
+      // function.
       //
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
@@ -290,7 +291,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
       // chain than the current node, and it is our idom!  We know that we have
       // already added a DominatorTree node for our idom, because the idom must
       // be a predecessor in the depth first order that we are iterating through
-      // the method.
+      // the function.
       //
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
index 0be903aad0afae1c353a23f09b23bd9f3539af57..c32c6b476ffe8a2753178caaaa0484e06677c3a4 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "WriterInternals.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Instruction.h"
 #include "llvm/DerivedTypes.h"
@@ -52,7 +52,7 @@ static void outputInstructionFormat0(const Instruction *I,
 }
 
 
-// outputInstrVarArgsCall - Output the obsurdly annoying varargs method calls.
+// outputInstrVarArgsCall - Output the obsurdly annoying varargs function calls.
 // This are more annoying than most because the signature of the call does not
 // tell us anything about the types of the arguments in the varargs portion.
 // Because of this, we encode (as type 0) all of the argument types explicitly
@@ -71,10 +71,10 @@ static void outputInstrVarArgsCall(const Instruction *I,
 
   unsigned NumArgs = I->getNumOperands();
   output_vbr(NumArgs*2, Out);
-  // TODO: Don't need to emit types for the fixed types of the varargs method
+  // TODO: Don't need to emit types for the fixed types of the varargs function
   // prototype...
 
-  // The type for the method has already been emitted in the type field of the
+  // The type for the function has already been emitted in the type field of the
   // instruction.  Just emit the slot # now.
   int Slot = Table.getValSlot(I->getOperand(0));
   assert(Slot >= 0 && "No slot number for value!?!?");      
index 43a4591cb8ad567fd54ffb3716e88b1585266ad0..9c59f1204766242f959780d7ac33280a8d959dec 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "llvm/Analysis/SlotCalculator.h"
 #include "llvm/Analysis/ConstantsScanner.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Module.h"
 #include "llvm/BasicBlock.h"
@@ -45,7 +45,7 @@ SlotCalculator::SlotCalculator(const Module *M, bool IgnoreNamed) {
   processModule();
 }
 
-SlotCalculator::SlotCalculator(const Method *M, bool IgnoreNamed) {
+SlotCalculator::SlotCalculator(const Function *M, bool IgnoreNamed) {
   IgnoreNamedNodes = IgnoreNamed;
   TheModule = M ? M->getParent() : 0;
 
@@ -64,7 +64,7 @@ SlotCalculator::SlotCalculator(const Method *M, bool IgnoreNamed) {
 }
 
 
-// processModule - Process all of the module level method declarations and
+// processModule - Process all of the module level function declarations and
 // types that are available.
 //
 void SlotCalculator::processModule() {
@@ -83,10 +83,10 @@ void SlotCalculator::processModule() {
   for_each(TheModule->gbegin(), TheModule->gend(),
           bind_obj(this, &SlotCalculator::insertValue));
 
-  // Scavenge the types out of the methods, then add the methods themselves to
-  // the value table...
+  // Scavenge the types out of the functions, then add the functions themselves
+  // to the value table...
   //
-  for_each(TheModule->begin(), TheModule->end(),  // Insert methods...
+  for_each(TheModule->begin(), TheModule->end(),  // Insert functions...
           bind_obj(this, &SlotCalculator::insertValue));
 
   // Insert constants that are named at module level into the slot pool so that
@@ -119,28 +119,28 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
 }
 
 
-void SlotCalculator::incorporateMethod(const Method *M) {
+void SlotCalculator::incorporateMethod(const Function *M) {
   assert(ModuleLevel.size() == 0 && "Module already incorporated!");
 
-  SC_DEBUG("begin processMethod!\n");
+  SC_DEBUG("begin processFunction!\n");
 
-  // Save the Table state before we process the method...
+  // Save the Table state before we process the function...
   for (unsigned i = 0; i < Table.size(); ++i)
     ModuleLevel.push_back(Table[i].size());
 
-  SC_DEBUG("Inserting method arguments\n");
+  SC_DEBUG("Inserting function arguments\n");
 
-  // Iterate over method arguments, adding them to the value table...
+  // Iterate over function arguments, adding them to the value table...
   for_each(M->getArgumentList().begin(), M->getArgumentList().end(),
           bind_obj(this, &SlotCalculator::insertValue));
 
-  // Iterate over all of the instructions in the method, looking for constant
+  // Iterate over all of the instructions in the function, looking for constant
   // values that are referenced.  Add these to the value pools before any
   // nonconstant values.  This will be turned into the constant pool for the
   // bytecode writer.
   //
   if (!IgnoreNamedNodes) {                // Assembly writer does not need this!
-    SC_DEBUG("Inserting method constants:\n";
+    SC_DEBUG("Inserting function constants:\n";
             for (constant_iterator I = constant_begin(M), E = constant_end(M);
                  I != E; ++I) {
               cerr << "  " << I->getType()->getDescription() 
@@ -148,7 +148,7 @@ void SlotCalculator::incorporateMethod(const Method *M) {
             });
 
     // Emit all of the constants that are being used by the instructions in the
-    // method...
+    // function...
     for_each(constant_begin(M), constant_end(M),
             bind_obj(this, &SlotCalculator::insertValue));
 
@@ -179,18 +179,18 @@ void SlotCalculator::incorporateMethod(const Method *M) {
     processSymbolTable(M->getSymbolTable());
   }
 
-  SC_DEBUG("end processMethod!\n");
+  SC_DEBUG("end processFunction!\n");
 }
 
 void SlotCalculator::purgeMethod() {
   assert(ModuleLevel.size() != 0 && "Module not incorporated!");
   unsigned NumModuleTypes = ModuleLevel.size();
 
-  SC_DEBUG("begin purgeMethod!\n");
+  SC_DEBUG("begin purgeFunction!\n");
 
   // First, remove values from existing type planes
   for (unsigned i = 0; i < NumModuleTypes; ++i) {
-    unsigned ModuleSize = ModuleLevel[i];  // Size of plane before method came
+    unsigned ModuleSize = ModuleLevel[i];  // Size of plane before function came
     TypePlane &CurPlane = Table[i];
     //SC_DEBUG("Processing Plane " <<i<< " of size " << CurPlane.size() <<endl);
             
@@ -207,7 +207,7 @@ void SlotCalculator::purgeMethod() {
   // We don't need this state anymore, free it up.
   ModuleLevel.clear();
 
-  // Next, remove any type planes defined by the method...
+  // Next, remove any type planes defined by the function...
   while (NumModuleTypes != Table.size()) {
     TypePlane &Plane = Table.back();
     SC_DEBUG("Removing Plane " << (Table.size()-1) << " of size "
@@ -220,7 +220,7 @@ void SlotCalculator::purgeMethod() {
     Table.pop_back();                      // Nuke the plane, we don't like it.
   }
 
-  SC_DEBUG("end purgeMethod!\n");
+  SC_DEBUG("end purgeFunction!\n");
 }
 
 int SlotCalculator::getValSlot(const Value *D) const {
@@ -337,9 +337,9 @@ int SlotCalculator::doInsertVal(const Value *D) {
 
   SC_DEBUG("  Inserting value [" << Ty << "] = " << D << " slot=" << 
           DestSlot << " [");
-  // G = Global, C = Constant, T = Type, M = Method, o = other
+  // G = Global, C = Constant, T = Type, F = Function, o = other
   SC_DEBUG((isa<GlobalVariable>(D) ? "G" : (isa<Constant>(D) ? "C" : 
-           (isa<Type>(D) ? "T" : (isa<Method>(D) ? "M" : "o")))));
+           (isa<Type>(D) ? "T" : (isa<Function>(D) ? "F" : "o")))));
   SC_DEBUG("]\n");
   return (int)DestSlot;
 }
index e67ba93f20cbd325219e6db48246907fccbd11a0..daf4a49bb83b2f8a778f761443d1e4070076a24b 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "Support/StringExtras.h"
 #include "Support/STLExtras.h"
@@ -955,9 +955,9 @@ SchedGraph::buildGraph(const TargetMachine& target)
 // 
 
 /*ctor*/
-SchedGraphSet::SchedGraphSet(const Method* _method,
+SchedGraphSet::SchedGraphSet(const Function* _function,
                             const TargetMachine& target) :
-  method(_method)
+  method(_function)
 {
   buildGraphsForMethod(method, target);
 }
@@ -975,23 +975,23 @@ SchedGraphSet::~SchedGraphSet()
 void
 SchedGraphSet::dump() const
 {
-  cerr << "======== Sched graphs for method `" << method->getName()
+  cerr << "======== Sched graphs for function `" << method->getName()
        << "' ========\n\n";
   
   for (const_iterator I=begin(); I != end(); ++I)
     (*I)->dump();
   
-  cerr << "\n====== End graphs for method `" << method->getName()
+  cerr << "\n====== End graphs for function `" << method->getName()
        << "' ========\n\n";
 }
 
 
 void
-SchedGraphSet::buildGraphsForMethod(const Method *method,
+SchedGraphSet::buildGraphsForMethod(const Function *F,
                                    const TargetMachine& target)
 {
-  for (Method::const_iterator BI = method->begin(); BI != method->end(); ++BI)
-    this->addGraph(new SchedGraph(*BI, target));
+  for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
+    addGraph(new SchedGraph(*BI, target));
 }
 
 
index 3efc5274700a56177f6fd3fdcdf73805611f6e1c..1eb507a695b1ca97b499cd7c0d3f9ed4bcc31b5c 100644 (file)
@@ -23,7 +23,7 @@
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iPHINode.h"
 #include "Support/CommandLine.h"
 #include <iostream>
@@ -60,7 +60,7 @@ static void PostprocessMachineCodeForTree(InstructionNode* instrNode,
                                           short* nts,
                                           TargetMachine &target);
 
-static void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target);
+static void InsertCode4AllPhisInMeth(Function *F, TargetMachine &target);
 
 
 
@@ -73,25 +73,23 @@ static void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target);
 //---------------------------------------------------------------------------
 
 bool
-SelectInstructionsForMethod(Method* method, TargetMachine &target)
+SelectInstructionsForMethod(Function *F, TargetMachine &target)
 {
   bool failed = false;
   
   //
   // Build the instruction trees to be given as inputs to BURG.
   // 
-  InstrForest instrForest(method);
+  InstrForest instrForest(F);
   
   if (SelectDebugLevel >= Select_DebugInstTrees)
     {
-      cerr << "\n\n*** Input to instruction selection for method "
-          << (method->hasName()? method->getName() : "")
-          << "\n\n";
-      method->dump();
+      cerr << "\n\n*** Input to instruction selection for function "
+          << F->getName() << "\n\n";
+      F->dump();
       
-      cerr << "\n\n*** Instruction trees for method "
-          << (method->hasName()? method->getName() : "")
-          << "\n\n";
+      cerr << "\n\n*** Instruction trees for function "
+          << F->getName() << "\n\n";
       instrForest.dump();
     }
   
@@ -125,7 +123,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
   //
   // Record instructions in the vector for each basic block
   // 
-  for (Method::iterator BI = method->begin(); BI != method->end(); ++BI)
+  for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
     {
       MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec();
       for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
@@ -137,13 +135,13 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
     }
 
   // Insert phi elimination code -- added by Ruchira
-  InsertCode4AllPhisInMeth(method, target);
+  InsertCode4AllPhisInMeth(F, target);
 
   
   if (SelectDebugLevel >= Select_PrintMachineCode)
     {
       cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n";
-      MachineCodeForMethod::get(method).dump();
+      MachineCodeForMethod::get(F).dump();
     }
   
   return false;
@@ -190,11 +188,11 @@ InsertPhiElimInstructions(BasicBlock *BB, const vector<MachineInstr*>& CpVec)
 //-------------------------------------------------------------------------
 
 void
-InsertCode4AllPhisInMeth(Method *method, TargetMachine &target)
+InsertCode4AllPhisInMeth(Function *F, TargetMachine &target)
 {
-  // for all basic blocks in method
+  // for all basic blocks in function
   //
-  for (Method::iterator BI = method->begin(); BI != method->end(); ++BI) {
+  for (Function::iterator BI = F->begin(); BI != F->end(); ++BI) {
 
     BasicBlock *BB = *BI;
     const BasicBlock::InstListType &InstList = BB->getInstList();
@@ -236,9 +234,7 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target)
       else break;   // since PHI nodes can only be at the top
       
     }  // for each Phi Instr in BB
-
-  } // for all BBs in method
-
+  } // for all BBs in function
 }
 
 
index ff43f04a5f9941892f43410e0490adbf90b7cf42..24efdf1456c6c186edd6c9fe968d57b240886d90 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/ConstantVals.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Type.h"
 #include "llvm/iMemory.h"
@@ -30,7 +30,7 @@ using std::vector;
 
 
 static TmpInstruction*
-InsertCodeToLoadConstant(Method* method,
+InsertCodeToLoadConstant(Function *F,
                          Value* opValue,
                          Instruction* vmInstr,
                          vector<MachineInstr*>& loadConstVec,
@@ -43,7 +43,7 @@ InsertCodeToLoadConstant(Method* method,
   MachineCodeForInstruction &MCFI = MachineCodeForInstruction::get(vmInstr);
   MCFI.addTemp(tmpReg);
   
-  target.getInstrInfo().CreateCodeToLoadConst(method, opValue, tmpReg,
+  target.getInstrInfo().CreateCodeToLoadConst(F, opValue, tmpReg,
                                               loadConstVec, tempVec);
   
   // Register the new tmp values created for this m/c instruction sequence
@@ -344,7 +344,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
   const MachineInstrDescriptor& instrDesc =
     target.getInstrInfo().getDescriptor(minstr->getOpCode());
   
-  Method* method = vmInstr->getParent()->getParent();
+  Function *F = vmInstr->getParent()->getParent();
   
   for (unsigned op=0; op < minstr->getNumOperands(); op++)
     {
@@ -381,8 +381,9 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
       
       if (constantThatMustBeLoaded || isa<GlobalValue>(opValue))
         { // opValue is a constant that must be explicitly loaded into a reg.
-          TmpInstruction* tmpReg = InsertCodeToLoadConstant(method, opValue, vmInstr,
-                                                            loadConstVec, target);
+          TmpInstruction* tmpReg = InsertCodeToLoadConstant(F, opValue, vmInstr,
+                                                            loadConstVec,
+                                                            target);
           minstr->SetMachineOperandVal(op, MachineOperand::MO_VirtualRegister,
                                        tmpReg);
         }
@@ -404,7 +405,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
       {
         Value* oldVal = minstr->getImplicitRef(i);
         TmpInstruction* tmpReg =
-          InsertCodeToLoadConstant(method, oldVal, vmInstr, loadConstVec, target);
+          InsertCodeToLoadConstant(F, oldVal, vmInstr, loadConstVec, target);
         minstr->setImplicitRef(i, tmpReg);
       }
   
index ef27dbae71c97500dbaf60741dddbabaa39ee549..bb52ef298e5ab4bf4cf65c6870c0716cd2699f04 100644 (file)
@@ -1,9 +1,9 @@
-//===-- MachineCodeForMethod.cpp --------------------------------------------=//
+//===-- MachineCodeForFunction.cpp ------------------------------------------=//
 // 
 // Purpose:
-//   Collect native machine code information for a method.
+//   Collect native machine code information for a function.
 //   This allows target-specific information about the generated code
-//   to be stored with each method.
+//   to be stored with each function.
 //===----------------------------------------------------------------------===//
 
 #include "llvm/CodeGen/MachineCodeForMethod.h"
@@ -11,7 +11,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineFrameInfo.h"
 #include "llvm/Target/MachineCacheInfo.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/iOther.h"
 #include <limits.h>
 const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
 
 static AnnotationID MCFM_AID(
-                 AnnotationManager::getID("CodeGen::MachineCodeForMethod"));
+                 AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
 
 // The next two methods are used to construct and to retrieve
-// the MachineCodeForMethod object for the given method.
-// construct() -- Allocates and initializes for a given method and target
+// the MachineCodeForFunction object for the given function.
+// construct() -- Allocates and initializes for a given function and target
 // get()       -- Returns a handle to the object.
 //                This should not be called before "construct()"
-//                for a given Method.
+//                for a given Function.
 // 
 MachineCodeForMethod&
-MachineCodeForMethod::construct(const Method *M, const TargetMachine &Tar)
+MachineCodeForMethod::construct(const Function *M, const TargetMachine &Tar)
 {
   assert(M->getAnnotation(MCFM_AID) == 0 &&
-         "Object already exists for this method!");
+         "Object already exists for this function!");
   MachineCodeForMethod* mcInfo = new MachineCodeForMethod(M, Tar);
   M->addAnnotation(mcInfo);
   return *mcInfo;
 }
 
 void
-MachineCodeForMethod::destruct(const Method *M)
+MachineCodeForMethod::destruct(const Function *M)
 {
   bool Deleted = M->deleteAnnotation(MCFM_AID);
-  assert(Deleted && "Machine code did not exist for method!");
+  assert(Deleted && "Machine code did not exist for function!");
 }
 
 MachineCodeForMethod&
-MachineCodeForMethod::get(const Method* method)
+MachineCodeForMethod::get(const Function *F)
 {
-  MachineCodeForMethod* mc = (MachineCodeForMethod*)
-    method->getAnnotation(MCFM_AID);
+  MachineCodeForMethod *mc = (MachineCodeForMethod*)F->getAnnotation(MCFM_AID);
   assert(mc && "Call construct() method first to allocate the object");
   return *mc;
 }
 
 static unsigned
-ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
+ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F)
 {
   const MachineFrameInfo& frameInfo = target.getFrameInfo();
   
   unsigned int maxSize = 0;
   
-  for (Method::const_iterator MI=method->begin(), ME=method->end();
-       MI != ME; ++MI)
+  for (Function::const_iterator MI = F->begin(), ME = F->end(); MI != ME; ++MI)
     {
       const BasicBlock *BB = *MI;
-      for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+      for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I)
         if (CallInst *callInst = dyn_cast<CallInst>(*I))
           {
             unsigned int numOperands = callInst->getNumOperands() - 1;
-            int numExtra = (int) numOperands - frameInfo.getNumFixedOutgoingArgs();
+            int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
             if (numExtra <= 0)
               continue;
             
@@ -82,7 +80,9 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
               }
             else
               {
-                assert(0 && "UNTESTED CODE: Size per stack argument is not fixed on this architecture: use actual arg sizes to compute MaxOptionalArgsSize");
+                assert(0 && "UNTESTED CODE: Size per stack argument is not "
+                       "fixed on this architecture: use actual arg sizes to "
+                       "compute MaxOptionalArgsSize");
                 sizeForThisCall = 0;
                 for (unsigned i=0; i < numOperands; ++i)
                   sizeForThisCall += target.findOptimalStorageSize(callInst->
@@ -118,10 +118,10 @@ SizeToAlignment(unsigned int size, const TargetMachine& target)
 
 
 /*ctor*/
-MachineCodeForMethod::MachineCodeForMethod(const Method* _M,
+MachineCodeForMethod::MachineCodeForMethod(const Function *F,
                                            const TargetMachine& target)
   : Annotation(MCFM_AID),
-    method(_M), compiledAsLeaf(false), staticStackSize(0),
+    method(F), compiledAsLeaf(false), staticStackSize(0),
     automaticVarsSize(0), regSpillsSize(0),
     currentOptionalArgsSize(0), maxOptionalArgsSize(0),
     currentTmpValuesSize(0), maxTmpValuesSize(0)
@@ -307,7 +307,7 @@ MachineCodeForMethod::dump() const
   std::cerr << "\n" << method->getReturnType()
             << " \"" << method->getName() << "\"\n";
   
-  for (Method::const_iterator BI = method->begin(); BI != method->end(); ++BI)
+  for (Function::const_iterator BI = method->begin(); BI != method->end(); ++BI)
     {
       BasicBlock* bb = *BI;
       std::cerr << "\n" << bb->getName() << " (" << bb << ")" << ":\n";
@@ -316,5 +316,5 @@ MachineCodeForMethod::dump() const
       for (unsigned i=0; i < mvec.size(); i++)
        std::cerr << "\t" << *mvec[i];
     } 
-  std::cerr << "\nEnd method \"" << method->getName() << "\"\n\n";
+  std::cerr << "\nEnd function \"" << method->getName() << "\"\n\n";
 }
index 32951769e00a20cd14bafa1d18ed3b9b926743a0..fb29af2bf192a75becb904aacb90d018ee46464b 100644 (file)
@@ -2,15 +2,15 @@
 #include "llvm/CodeGen/RegClass.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "Support/SetOperations.h"
 #include <iostream>
 using std::cerr;
 
-LiveRangeInfo::LiveRangeInfo(const Method *M, const TargetMachine &tm,
+LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm,
                             std::vector<RegClass *> &RCL)
-  : Meth(M), TM(tm), RegClassList(RCL), MRI(tm.getRegInfo()) { }
+  : Meth(F), TM(tm), RegClassList(RCL), MRI(tm.getRegInfo()) { }
 
 
 LiveRangeInfo::~LiveRangeInfo() {
@@ -48,7 +48,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *L1, LiveRange *L2) {
     //assert(( L1->getTypeID() == L2->getTypeID()) && "Merge:Different types");
 
     L1->insert(*L2It);                  // add the var in L2 to L1
-    LiveRangeMap[*L2It] = L1;         // now the elements in L2 should map 
+    LiveRangeMap[*L2It] = L1;           // now the elements in L2 should map 
                                         //to L1    
   }
 
@@ -73,24 +73,22 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *L1, LiveRange *L2) {
 
 
 //---------------------------------------------------------------------------
-// Method for constructing all live ranges in a method. It creates live 
+// Method for constructing all live ranges in a function. It creates live 
 // ranges for all values defined in the instruction stream. Also, it
-// creates live ranges for all incoming arguments of the method.
+// creates live ranges for all incoming arguments of the function.
 //---------------------------------------------------------------------------
 void LiveRangeInfo::constructLiveRanges() {  
 
   if (DEBUG_RA) 
     cerr << "Consturcting Live Ranges ...\n";
 
-  // first find the live ranges for all incoming args of the method since
-  // those LRs start from the start of the method
+  // first find the live ranges for all incoming args of the function since
+  // those LRs start from the start of the function
       
-                                                 // get the argument list
-  const Method::ArgumentListType& ArgList = Meth->getArgumentList();           
-                                                 // get an iterator to arg list
-  Method::ArgumentListType::const_iterator ArgIt = ArgList.begin(); 
+  // get the argument list
+  const Function::ArgumentListType& ArgList = Meth->getArgumentList();
 
-             
+  Function::ArgumentListType::const_iterator ArgIt = ArgList.begin();
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {     // for each argument
     LiveRange * ArgRange = new LiveRange();      // creates a new LR and 
     const Value *Val = (const Value *) *ArgIt;
@@ -111,15 +109,14 @@ void LiveRangeInfo::constructLiveRanges() {
     }
   }
 
-  // Now suggest hardware registers for these method args 
+  // Now suggest hardware registers for these function args 
   MRI.suggestRegs4MethodArgs(Meth, *this);
 
 
-
   // Now find speical LLVM instructions (CALL, RET) and LRs in machine
   // instructions.
   //
-  for (Method::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI) {
+  for (Function::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI){
     // Now find all LRs for machine the instructions. A new LR will be created 
     // only for defs in the machine instr since, we assume that all Values are
     // defined before they are used. However, there can be multiple defs for
@@ -207,7 +204,7 @@ void LiveRangeInfo::constructLiveRanges() {
 
     } // for all machine instructions in the BB
 
-  } // for all BBs in method
+  } // for all BBs in function
   
 
   // Now we have to suggest clors for call and return arg live ranges.
@@ -225,16 +222,14 @@ void LiveRangeInfo::constructLiveRanges() {
 //---------------------------------------------------------------------------
 // If some live ranges must be colored with specific hardware registers
 // (e.g., for outgoing call args), suggesting of colors for such live
-// ranges is done using target specific method. Those methods are called
+// ranges is done using target specific function. Those functions are called
 // from this function. The target specific methods must:
 //    1) suggest colors for call and return args. 
 //    2) create new LRs for implicit defs in machine instructions
 //---------------------------------------------------------------------------
 void LiveRangeInfo::suggestRegs4CallRets()
 {
-
   CallRetInstrListType::const_iterator It =  CallRetInstrList.begin();
-
   for( ; It !=  CallRetInstrList.end(); ++It ) {
 
     const MachineInstr *MInst = *It;
@@ -259,7 +254,7 @@ void LiveRangeInfo::suggestRegs4CallRets()
 
 
 /* Algorithm:
-   for each BB in method
+   for each BB in function
      for each machine instruction (inst)
        for each definition (def) in inst
          for each operand (op) of inst that is a use
@@ -273,12 +268,11 @@ void LiveRangeInfo::suggestRegs4CallRets()
 //---------------------------------------------------------------------------
 void LiveRangeInfo::coalesceLRs()  
 {
-  if( DEBUG_RA) 
+  if(DEBUG_RA) 
     cerr << "\nCoalscing LRs ...\n";
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
+  for(Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+      BBI != BBE; ++BBI) {
 
     // get the iterator for machine instructions
     const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
index 49667e00795d678b85edbb1de48eab7fdbb86f5d..c9d775e28498df7391938a95f97a2410fc32f438 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineFrameInfo.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Type.h"
 #include <iostream>
 #include <math.h>
@@ -45,12 +45,12 @@ namespace {
   public:
     inline RegisterAllocator(TargetMachine &T) : Target(T) {}
     
-    bool runOnMethod(Method *M) {
+    bool runOnMethod(Function *F) {
       if (DEBUG_RA)
-        cerr << "\n******************** Method "<< M->getName()
+        cerr << "\n******************** Method "<< F->getName()
              << " ********************\n";
       
-      PhyRegAlloc PRA(M, Target, &getAnalysis<MethodLiveVarInfo>(),
+      PhyRegAlloc PRA(F, Target, &getAnalysis<MethodLiveVarInfo>(),
                       &getAnalysis<cfg::LoopInfo>());
       PRA.allocateRegisters();
       
@@ -75,22 +75,22 @@ MethodPass *getRegisterAllocator(TargetMachine &T) {
 //----------------------------------------------------------------------------
 // Constructor: Init local composite objects and create register classes.
 //----------------------------------------------------------------------------
-PhyRegAlloc::PhyRegAlloc(Method *M
+PhyRegAlloc::PhyRegAlloc(Function *F
                         const TargetMachine& tm, 
                         MethodLiveVarInfo *Lvi,
                          cfg::LoopInfo *LDC) 
-                       :  TM(tm), Meth(M),
-                          mcInfo(MachineCodeForMethod::get(M)),
-                          LVI(Lvi), LRI(M, tm, RegClassList), 
-                         MRI( tm.getRegInfo() ),
+                       :  TM(tm), Meth(F),
+                          mcInfo(MachineCodeForMethod::get(F)),
+                          LVI(Lvi), LRI(F, tm, RegClassList), 
+                         MRI(tm.getRegInfo()),
                           NumOfRegClasses(MRI.getNumOfRegClasses()),
                          LoopDepthCalc(LDC) {
 
   // create each RegisterClass and put in RegClassList
   //
   for(unsigned int rc=0; rc < NumOfRegClasses; rc++)  
-    RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc), 
-                                        &ResColList) );
+    RegClassList.push_back(new RegClass(F, MRI.getMachineRegClass(rc),
+                                        &ResColList));
 }
 
 
@@ -278,13 +278,12 @@ void PhyRegAlloc::buildInterferenceGraphs()
   if(DEBUG_RA) cerr << "Creating interference graphs ...\n";
 
   unsigned BBLoopDepthCost;
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
 
     // find the 10^(loop_depth) of this BB 
     //
-    BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc->getLoopDepth(*BBI));
+    BBLoopDepthCost = (unsigned) pow(10.0, LoopDepthCalc->getLoopDepth(*BBI));
 
     // get the iterator for machine instructions
     //
@@ -346,12 +345,11 @@ void PhyRegAlloc::buildInterferenceGraphs()
 
 
     } // for all machine instructions in BB
-    
-  } // for all BBs in method
+  } // for all BBs in function
 
 
-  // add interferences for method arguments. Since there are no explict 
-  // defs in method for args, we have to add them manually
+  // add interferences for function arguments. Since there are no explict 
+  // defs in the function for args, we have to add them manually
   //  
   addInterferencesForArgs();          
 
@@ -405,17 +403,17 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
 
 
 //----------------------------------------------------------------------------
-// This method will add interferences for incoming arguments to a method.
+// This method will add interferences for incoming arguments to a function.
 //----------------------------------------------------------------------------
 void PhyRegAlloc::addInterferencesForArgs() {
   // get the InSet of root BB
   const ValueSet &InSet = LVI->getInSetOfBB(Meth->front());  
 
   // get the argument list
-  const Method::ArgumentListType& ArgList = Meth->getArgumentList();  
+  const Function::ArgumentListType &ArgList = Meth->getArgumentList();  
 
   // get an iterator to arg list
-  Method::ArgumentListType::const_iterator ArgIt = ArgList.begin();          
+  Function::ArgumentListType::const_iterator ArgIt = ArgList.begin();          
 
 
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {  // for each argument
@@ -441,10 +439,8 @@ void PhyRegAlloc::addInterferencesForArgs() {
 void PhyRegAlloc::updateMachineCode()
 {
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
-
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
     // get the iterator for machine instructions
     //
     MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -955,14 +951,12 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
 void PhyRegAlloc::printMachineCode()
 {
 
-  cerr << "\n;************** Method " << Meth->getName()
+  cerr << "\n;************** Function " << Meth->getName()
        << " *****************\n";
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
-
-    cerr << "\n"; printLabel( *BBI); cerr << ": ";
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
+    cerr << "\n"; printLabel(*BBI); cerr << ": ";
 
     // get the iterator for machine instructions
     MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -970,18 +964,12 @@ void PhyRegAlloc::printMachineCode()
 
     // iterate over all the machine instructions in BB
     for( ; MInstIterator != MIVec.end(); ++MInstIterator) {  
-      
       MachineInstr *const MInst = *MInstIterator; 
 
-
       cerr << "\n\t";
       cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
-      
-
-      //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
 
       for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
-
        MachineOperand& Op = MInst->getOperand(OpNum);
 
        if( Op.getOperandType() ==  MachineOperand::MO_VirtualRegister || 
@@ -1074,7 +1062,6 @@ void PhyRegAlloc::colorCallRetArgs()
     // So reset it before we call each such method
     //mcInfo.popAllTempValues(TM);  
 
-
     
     if (TM.getInstrInfo().isCall(OpCode))
       MRI.colorCallArgs(CRMI, LRI, AI, *this);
index 2260625b66b8025a1b318f5d10f5c71d88711e83..484dbe2ee6c6809d597d57effa743643b71d7d55 100644 (file)
@@ -233,15 +233,15 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){
   // This annotation will only be created on GlobalValue objects...
   GlobalValue *GVal = cast<GlobalValue>((Value*)O);
 
-  if (isa<Method>(GVal)) {
-    // The GlobalAddress object for a method is just a pointer to method itself.
-    // Don't delete it when the annotation is gone though!
+  if (isa<Function>(GVal)) {
+    // The GlobalAddress object for a function is just a pointer to function
+    // itself.  Don't delete it when the annotation is gone though!
     return new GlobalAddress(GVal, false);
   }
 
   // Handle the case of a global variable...
   assert(isa<GlobalVariable>(GVal) && 
-         "Global value found that isn't a method or global variable!");
+         "Global value found that isn't a function or global variable!");
   GlobalVariable *GV = cast<GlobalVariable>(GVal);
   
   // First off, we must allocate space for the global variable to point at...
@@ -667,7 +667,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
   }
 
   // Save previously executing meth
-  const Method *M = ECStack.back().CurMethod;
+  const Function *M = ECStack.back().CurMethod;
 
   // Pop the current stack frame... this invalidates SF
   ECStack.pop_back();
@@ -675,7 +675,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
   if (ECStack.empty()) {  // Finished main.  Put result into exit code...
     if (RetTy) {          // Nonvoid return type?
       if (!QuietMode) {
-        CW << "Method " << M->getType() << " \"" << M->getName()
+        CW << "Function " << M->getType() << " \"" << M->getName()
            << "\" returned ";
         print(RetTy, Result);
         cout << "\n";
@@ -703,7 +703,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) {
   } else if (!QuietMode) {
     // This must be a function that is executing because of a user 'call'
     // instruction.
-    CW << "Method " << M->getType() << " \"" << M->getName()
+    CW << "Function " << M->getType() << " \"" << M->getName()
        << "\" returned ";
     print(RetTy, Result);
     cout << "\n";
@@ -894,10 +894,10 @@ void Interpreter::executeCallInst(CallInst *I, ExecutionContext &SF) {
     ArgVals.push_back(getOperandValue(I->getOperand(i), SF));
 
   // To handle indirect calls, we must get the pointer value from the argument 
-  // and treat it as a method pointer.
+  // and treat it as a function pointer.
   GenericValue SRC = getOperandValue(I->getCalledValue(), SF);
   
-  callMethod((Method*)SRC.PointerVal, ArgVals);
+  callMethod((Function*)SRC.PointerVal, ArgVals);
 }
 
 static void executePHINode(PHINode *I, ExecutionContext &SF) {
@@ -1024,16 +1024,16 @@ static void executeCastInst(CastInst *I, ExecutionContext &SF) {
 //                        Dispatch and Execution Code
 //===----------------------------------------------------------------------===//
 
-MethodInfo::MethodInfo(Method *M) : Annotation(MethodInfoAID) {
-  // Assign slot numbers to the method arguments...
-  const Method::ArgumentListType &ArgList = M->getArgumentList();
-  for (Method::ArgumentListType::const_iterator AI = ArgList.begin(), 
+MethodInfo::MethodInfo(Function *M) : Annotation(MethodInfoAID) {
+  // Assign slot numbers to the function arguments...
+  const Function::ArgumentListType &ArgList = M->getArgumentList();
+  for (Function::ArgumentListType::const_iterator AI = ArgList.begin(), 
         AE = ArgList.end(); AI != AE; ++AI)
     (*AI)->addAnnotation(new SlotNumber(getValueSlot(*AI)));
 
   // Iterate over all of the instructions...
   unsigned InstNum = 0;
-  for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+  for (Function::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
     BasicBlock *BB = *MI;
     for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){
       Instruction *I = *II;          // For each instruction... Add Annote
@@ -1051,9 +1051,9 @@ unsigned MethodInfo::getValueSlot(const Value *V) {
 
 
 //===----------------------------------------------------------------------===//
-// callMethod - Execute the specified method...
+// callMethod - Execute the specified function...
 //
-void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
+void Interpreter::callMethod(Function *M, const vector<GenericValue> &ArgVals) {
   assert((ECStack.empty() || ECStack.back().Caller == 0 || 
          ECStack.back().Caller->getNumOperands()-1 == ArgVals.size()) &&
         "Incorrect number of arguments passed into function call!");
@@ -1071,7 +1071,7 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
         SF.Caller = 0;          // We returned from the call...
       } else if (!QuietMode) {
         // print it.
-        CW << "Method " << M->getType() << " \"" << M->getName()
+        CW << "Function " << M->getType() << " \"" << M->getName()
            << "\" returned ";
         print(RetTy, Result); 
         cout << "\n";
@@ -1084,8 +1084,9 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
     return;
   }
 
-  // Process the method, assigning instruction numbers to the instructions in
-  // the method.  Also calculate the number of values for each type slot active.
+  // Process the function, assigning instruction numbers to the instructions in
+  // the function.  Also calculate the number of values for each type slot
+  // active.
   //
   MethodInfo *MethInfo = (MethodInfo*)M->getOrCreateAnnotation(MethodInfoAID);
   ECStack.push_back(ExecutionContext());         // Make a new stack frame...
@@ -1109,11 +1110,11 @@ void Interpreter::callMethod(Method *M, const vector<GenericValue> &ArgVals) {
   StackFrame.PrevBB = 0;  // No previous BB for PHI nodes...
 
 
-  // Run through the method arguments and initialize their values...
+  // Run through the function arguments and initialize their values...
   assert(ArgVals.size() == M->getArgumentList().size() &&
-         "Invalid number of values passed to method invocation!");
+         "Invalid number of values passed to function invocation!");
   unsigned i = 0;
-  for (Method::ArgumentListType::iterator MI = M->getArgumentList().begin(),
+  for (Function::ArgumentListType::iterator MI = M->getArgumentList().begin(),
         ME = M->getArgumentList().end(); MI != ME; ++MI, ++i) {
     SetValue(*MI, ArgVals[i], StackFrame);
   }
@@ -1319,8 +1320,8 @@ void Interpreter::print(const std::string &Name) {
   Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name));
   if (!PickedVal) return;
 
-  if (const Method *M = dyn_cast<const Method>(PickedVal)) {
-    CW << M;  // Print the method
+  if (const Function *F = dyn_cast<const Function>(PickedVal)) {
+    CW << F;  // Print the function
   } else if (const Type *Ty = dyn_cast<const Type>(PickedVal)) {
     CW << "type %" << Name << " = " << Ty->getDescription() << "\n";
   } else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(PickedVal)) {
@@ -1348,13 +1349,13 @@ void Interpreter::infoValue(const std::string &Name) {
 //
 void Interpreter::printStackFrame(int FrameNo = -1) {
   if (FrameNo == -1) FrameNo = CurFrame;
-  Method *Meth = ECStack[FrameNo].CurMethod;
-  const Type *RetTy = Meth->getReturnType();
+  Function *Func = ECStack[FrameNo].CurMethod;
+  const Type *RetTy = Func->getReturnType();
 
   CW << ((FrameNo == CurFrame) ? '>' : '-') << "#" << FrameNo << ". "
-     << (Value*)RetTy << " \"" << Meth->getName() << "\"(";
+     << (Value*)RetTy << " \"" << Func->getName() << "\"(";
   
-  Method::ArgumentListType &Args = Meth->getArgumentList();
+  Function::ArgumentListType &Args = Func->getArgumentList();
   for (unsigned i = 0; i < Args.size(); ++i) {
     if (i != 0) cout << ", ";
     CW << (Value*)Args[i] << "=";
index 537d18c35a9ea947889f7d81f885ec5548bae040..03abd20bb454985a401d15d0da11c64a031f5715 100644 (file)
 // Support for MethodInfo annotations
 //===----------------------------------------------------------------------===//
 
-// This annotation (attached only to Method objects) is used to cache useful
-// information about the method, including the number of types present in the
-// method, and the number of values for each type.
+// This annotation (attached only to Function objects) is used to cache useful
+// information about the function, including the number of types present in the
+// function, and the number of values for each type.
 //
 // This annotation object is created on demand, and attaches other annotation
-// objects to the instructions in the method when it's created.
+// objects to the instructions in the function when it's created.
 //
 static AnnotationID MethodInfoAID(
-                   AnnotationManager::getID("Interpreter::MethodInfo"));
+                   AnnotationManager::getID("Interpreter::FunctionInfo"));
 
 struct MethodInfo : public Annotation {
-  MethodInfo(Method *M);
+  MethodInfo(Function *F);
   std::vector<unsigned> NumPlaneElements;
 
 
@@ -31,7 +31,7 @@ struct MethodInfo : public Annotation {
   //
   static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
     assert(AID == MethodInfoAID);
-    return new MethodInfo(cast<Method>((Value*)O));  // Simply invoke the ctor
+    return new MethodInfo(cast<Function>((Value*)O));  // Simply invoke the ctor
   }
 
 private:
@@ -47,7 +47,7 @@ private:
 // used to hold the the slot number for the value in its type plane.
 //
 // Entities have this annotation attached to them when the containing
-// method has it's MethodInfo created (by the MethodInfo ctor).
+// function has it's MethodInfo created (by the MethodInfo ctor).
 //
 static AnnotationID SlotNumberAID(
                    AnnotationManager::getID("Interpreter::SlotNumber"));
@@ -71,8 +71,8 @@ struct SlotNumber : public Annotation {
 // its type plane.  InstNumber's are used for user interaction, and for
 // calculating which value slot to store the result of the instruction in.
 //
-// Instructions have this annotation attached to them when the containing method
-// has it's MethodInfo created (by the MethodInfo ctor).
+// Instructions have this annotation attached to them when the containing
+// function has it's MethodInfo created (by the MethodInfo ctor).
 //
 struct InstNumber : public SlotNumber {
   unsigned InstNum;   // Ranges from 1->
@@ -95,10 +95,11 @@ static AnnotationID BreakpointAID(
 //===----------------------------------------------------------------------===//
 
 // This annotation (attached only to GlobalValue objects) is used to hold the
-// address of the chunk of memory that represents a global value.  For Method's,
-// this pointer is the Method object pointer that represents it.  For global
-// variables, this is the dynamically allocated (and potentially initialized)
-// chunk of memory for the global.  This annotation is created on demand.
+// address of the chunk of memory that represents a global value.  For
+// Functions, this pointer is the Function object pointer that represents it.
+// For global variables, this is the dynamically allocated (and potentially
+// initialized) chunk of memory for the global.  This annotation is created on
+// demand.
 //
 static AnnotationID GlobalAddressAID(
                    AnnotationManager::getID("Interpreter::GlobalAddress"));
index c8aa46a186e384f9cc69519fe2f8041426cb494b..8f486e84cebcbfdb447a7851432d7d6e834805d2 100644 (file)
@@ -1,11 +1,12 @@
-//===-- ExternalMethods.cpp - Implement External Functions ----------------===//
+//===-- ExternalFunctions.cpp - Implement External Functions --------------===//
 // 
-//  This file contains both code to deal with invoking "external" methods, but
-//  also contains code that implements "exported" external methods. 
+//  This file contains both code to deal with invoking "external" functions, but
+//  also contains code that implements "exported" external functions.
 //
-//  External methods in LLI are implemented by dlopen'ing the lli executable and
-//  using dlsym to look op the methods that we want to invoke.  If a method is
-//  found, then the arguments are mangled and passed in to the function call.
+//  External functions in LLI are implemented by dlopen'ing the lli executable
+//  and using dlsym to look op the functions that we want to invoke.  If a
+//  function is found, then the arguments are mangled and passed in to the
+//  function call.
 //
 //===----------------------------------------------------------------------===//
 
@@ -91,18 +92,19 @@ GenericValue Interpreter::callExternalMethod(Function *M,
                                          const vector<GenericValue> &ArgVals) {
   TheInterpreter = this;
 
-  // Do a lookup to see if the method is in our cache... this should just be a
+  // Do a lookup to see if the function is in our cache... this should just be a
   // defered annotation!
   std::map<const Function *, ExFunc>::iterator FI = Functions.find(M);
   ExFunc Fn = (FI == Functions.end()) ? lookupFunction(M) : FI->second;
   if (Fn == 0) {
-    cout << "Tried to execute an unknown external method: "
+    cout << "Tried to execute an unknown external function: "
         << M->getType()->getDescription() << " " << M->getName() << "\n";
     return GenericValue();
   }
 
   // TODO: FIXME when types are not const!
-  GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),ArgVals);
+  GenericValue Result = Fn(const_cast<FunctionType*>(M->getFunctionType()),
+                           ArgVals);
   return Result;
 }
 
index 8576f9ce2257843ea3f51f346eeb0b29aa62aab2..e7c7942b0c9383affc622c19ac0b22812b6d7bb0 100644 (file)
@@ -12,7 +12,7 @@
 
 
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "Support/DataTypes.h"
 #include "llvm/Assembly/CachedWriter.h"
@@ -78,10 +78,10 @@ typedef std::vector<GenericValue> ValuePlaneTy;
 // executing.
 //
 struct ExecutionContext {
-  Method               *CurMethod;  // The currently executing method
+  Function             *CurMethod;  // The currently executing function
   BasicBlock           *CurBB;      // The currently executing BB
   BasicBlock::iterator  CurInst;    // The next instruction to execute
-  MethodInfo           *MethInfo;   // The MethInfo annotation for the method
+  MethodInfo           *MethInfo;   // The MethInfo annotation for the function
   std::vector<ValuePlaneTy>  Values;// ValuePlanes for each type
 
   BasicBlock           *PrevBB;     // The previous BB or null if in first BB
@@ -100,7 +100,7 @@ class Interpreter {
   int CurFrame;                // The current stack frame being inspected
 
   // The runtime stack of executing code.  The top of the stack is the current
-  // method record.
+  // function record.
   std::vector<ExecutionContext> ECStack;
 
 public:
@@ -135,7 +135,7 @@ public:
   void printStackTrace();  // Do the 'backtrace' command
 
   // Code execution methods...
-  void callMethod(Method *Meth, const std::vector<GenericValue> &ArgVals);
+  void callMethod(Function *F, const std::vector<GenericValue> &ArgVals);
   bool executeInstruction(); // Execute one instruction...
 
   void stepInstruction();  // Do the 'step' command
@@ -148,12 +148,12 @@ public:
   void executeRetInst(ReturnInst *I, ExecutionContext &SF);
   void executeBrInst(BranchInst *I, ExecutionContext &SF);
   void executeAllocInst(AllocationInst *I, ExecutionContext &SF);
-  GenericValue callExternalMethod(Method *Meth
+  GenericValue callExternalMethod(Function *F
                                   const std::vector<GenericValue> &ArgVals);
   void exitCalled(GenericValue GV);
 
   // getCurrentMethod - Return the currently executing method
-  inline Method *getCurrentMethod() const {
+  inline Function *getCurrentMethod() const {
     return CurFrame < 0 ? 0 : ECStack[CurFrame].CurMethod;
   }
 
@@ -178,10 +178,10 @@ private:  // Helper functions
   //
   void printStackFrame(int FrameNo = -1);
 
-  // LookupMatchingNames - Search the current method namespace, then the global
-  // namespace looking for values that match the specified name.  Return ALL
-  // matches to that name.  This is obviously slow, and should only be used for
-  // user interaction.
+  // LookupMatchingNames - Search the current function namespace, then the
+  // global namespace looking for values that match the specified name.  Return
+  // ALL matches to that name.  This is obviously slow, and should only be used
+  // for user interaction.
   //
   std::vector<Value*> LookupMatchingNames(const std::string &Name);
 
index ca89ae33332cc061126fb58dac0cc746eeea54f7..cac3b74c82c21c5fb9390fb47474765e2efdee81 100644 (file)
@@ -31,14 +31,14 @@ static inline void LookupMatchingNames(const std::string &Name,SymTabValue &STV,
   }
 }
 
-// LookupMatchingNames - Search the current method namespace, then the global
+// LookupMatchingNames - Search the current function namespace, then the global
 // namespace looking for values that match the specified name.  Return ALL
 // matches to that name.  This is obviously slow, and should only be used for
 // user interaction.
 //
 std::vector<Value*> Interpreter::LookupMatchingNames(const std::string &Name) {
   std::vector<Value*> Results;
-  Method *CurMeth = getCurrentMethod();
+  Function *CurMeth = getCurrentMethod();
   
   if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results);
   if (CurMod ) ::LookupMatchingNames(Name, *CurMod , Results);
index 99ee6ecaf711ea44490a5d8a20aee271910dd1e3..b35463fc0b1c55f6358c9a19e7bf53100d5325f5 100644 (file)
@@ -124,7 +124,7 @@ void Interpreter::handleUserInput() {
     case Finish:     finish();          break;
     case Call:
       cin >> Command;
-      callMethod(Command);    // Enter the specified method
+      callMethod(Command);    // Enter the specified function
       finish();               // Run until it's complete
       break;
 
@@ -215,7 +215,7 @@ void Interpreter::setBreakpoint(const string &Name) {
 bool Interpreter::callMethod(const string &Name) {
   std::vector<Value*> Options = LookupMatchingNames(Name);
 
-  for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
+  for (unsigned i = 0; i < Options.size(); ++i) { // Remove non-fn matches...
     if (!isa<Function>(Options[i])) {
       Options.erase(Options.begin()+i);
       --i;
@@ -263,7 +263,7 @@ bool Interpreter::callMainMethod(const string &Name,
                                  const std::vector<string> &InputArgv) {
   std::vector<Value*> Options = LookupMatchingNames(Name);
 
-  for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches...
+  for (unsigned i = 0; i < Options.size(); ++i) { // Remove non-fn matches...
     if (!isa<Function>(Options[i])) {
       Options.erase(Options.begin()+i);
       --i;
@@ -321,7 +321,7 @@ void Interpreter::list() {
   if (ECStack.empty())
     cout << "Error: No program executing!\n";
   else
-    CW << ECStack[CurFrame].CurMethod;   // Just print the method out...
+    CW << ECStack[CurFrame].CurMethod;   // Just print the function out...
 }
 
 void Interpreter::printStackTrace() {
index e67ba93f20cbd325219e6db48246907fccbd11a0..daf4a49bb83b2f8a778f761443d1e4070076a24b 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "Support/StringExtras.h"
 #include "Support/STLExtras.h"
@@ -955,9 +955,9 @@ SchedGraph::buildGraph(const TargetMachine& target)
 // 
 
 /*ctor*/
-SchedGraphSet::SchedGraphSet(const Method* _method,
+SchedGraphSet::SchedGraphSet(const Function* _function,
                             const TargetMachine& target) :
-  method(_method)
+  method(_function)
 {
   buildGraphsForMethod(method, target);
 }
@@ -975,23 +975,23 @@ SchedGraphSet::~SchedGraphSet()
 void
 SchedGraphSet::dump() const
 {
-  cerr << "======== Sched graphs for method `" << method->getName()
+  cerr << "======== Sched graphs for function `" << method->getName()
        << "' ========\n\n";
   
   for (const_iterator I=begin(); I != end(); ++I)
     (*I)->dump();
   
-  cerr << "\n====== End graphs for method `" << method->getName()
+  cerr << "\n====== End graphs for function `" << method->getName()
        << "' ========\n\n";
 }
 
 
 void
-SchedGraphSet::buildGraphsForMethod(const Method *method,
+SchedGraphSet::buildGraphsForMethod(const Function *F,
                                    const TargetMachine& target)
 {
-  for (Method::const_iterator BI = method->begin(); BI != method->end(); ++BI)
-    this->addGraph(new SchedGraph(*BI, target));
+  for (Function::const_iterator BI = F->begin(); BI != F->end(); ++BI)
+    addGraph(new SchedGraph(*BI, target));
 }
 
 
index 3efc5274700a56177f6fd3fdcdf73805611f6e1c..1eb507a695b1ca97b499cd7c0d3f9ed4bcc31b5c 100644 (file)
@@ -23,7 +23,7 @@
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iPHINode.h"
 #include "Support/CommandLine.h"
 #include <iostream>
@@ -60,7 +60,7 @@ static void PostprocessMachineCodeForTree(InstructionNode* instrNode,
                                           short* nts,
                                           TargetMachine &target);
 
-static void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target);
+static void InsertCode4AllPhisInMeth(Function *F, TargetMachine &target);
 
 
 
@@ -73,25 +73,23 @@ static void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target);
 //---------------------------------------------------------------------------
 
 bool
-SelectInstructionsForMethod(Method* method, TargetMachine &target)
+SelectInstructionsForMethod(Function *F, TargetMachine &target)
 {
   bool failed = false;
   
   //
   // Build the instruction trees to be given as inputs to BURG.
   // 
-  InstrForest instrForest(method);
+  InstrForest instrForest(F);
   
   if (SelectDebugLevel >= Select_DebugInstTrees)
     {
-      cerr << "\n\n*** Input to instruction selection for method "
-          << (method->hasName()? method->getName() : "")
-          << "\n\n";
-      method->dump();
+      cerr << "\n\n*** Input to instruction selection for function "
+          << F->getName() << "\n\n";
+      F->dump();
       
-      cerr << "\n\n*** Instruction trees for method "
-          << (method->hasName()? method->getName() : "")
-          << "\n\n";
+      cerr << "\n\n*** Instruction trees for function "
+          << F->getName() << "\n\n";
       instrForest.dump();
     }
   
@@ -125,7 +123,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
   //
   // Record instructions in the vector for each basic block
   // 
-  for (Method::iterator BI = method->begin(); BI != method->end(); ++BI)
+  for (Function::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
     {
       MachineCodeForBasicBlock& bbMvec = (*BI)->getMachineInstrVec();
       for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
@@ -137,13 +135,13 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target)
     }
 
   // Insert phi elimination code -- added by Ruchira
-  InsertCode4AllPhisInMeth(method, target);
+  InsertCode4AllPhisInMeth(F, target);
 
   
   if (SelectDebugLevel >= Select_PrintMachineCode)
     {
       cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n";
-      MachineCodeForMethod::get(method).dump();
+      MachineCodeForMethod::get(F).dump();
     }
   
   return false;
@@ -190,11 +188,11 @@ InsertPhiElimInstructions(BasicBlock *BB, const vector<MachineInstr*>& CpVec)
 //-------------------------------------------------------------------------
 
 void
-InsertCode4AllPhisInMeth(Method *method, TargetMachine &target)
+InsertCode4AllPhisInMeth(Function *F, TargetMachine &target)
 {
-  // for all basic blocks in method
+  // for all basic blocks in function
   //
-  for (Method::iterator BI = method->begin(); BI != method->end(); ++BI) {
+  for (Function::iterator BI = F->begin(); BI != F->end(); ++BI) {
 
     BasicBlock *BB = *BI;
     const BasicBlock::InstListType &InstList = BB->getInstList();
@@ -236,9 +234,7 @@ InsertCode4AllPhisInMeth(Method *method, TargetMachine &target)
       else break;   // since PHI nodes can only be at the top
       
     }  // for each Phi Instr in BB
-
-  } // for all BBs in method
-
+  } // for all BBs in function
 }
 
 
index ff43f04a5f9941892f43410e0490adbf90b7cf42..24efdf1456c6c186edd6c9fe968d57b240886d90 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/ConstantVals.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Type.h"
 #include "llvm/iMemory.h"
@@ -30,7 +30,7 @@ using std::vector;
 
 
 static TmpInstruction*
-InsertCodeToLoadConstant(Method* method,
+InsertCodeToLoadConstant(Function *F,
                          Value* opValue,
                          Instruction* vmInstr,
                          vector<MachineInstr*>& loadConstVec,
@@ -43,7 +43,7 @@ InsertCodeToLoadConstant(Method* method,
   MachineCodeForInstruction &MCFI = MachineCodeForInstruction::get(vmInstr);
   MCFI.addTemp(tmpReg);
   
-  target.getInstrInfo().CreateCodeToLoadConst(method, opValue, tmpReg,
+  target.getInstrInfo().CreateCodeToLoadConst(F, opValue, tmpReg,
                                               loadConstVec, tempVec);
   
   // Register the new tmp values created for this m/c instruction sequence
@@ -344,7 +344,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
   const MachineInstrDescriptor& instrDesc =
     target.getInstrInfo().getDescriptor(minstr->getOpCode());
   
-  Method* method = vmInstr->getParent()->getParent();
+  Function *F = vmInstr->getParent()->getParent();
   
   for (unsigned op=0; op < minstr->getNumOperands(); op++)
     {
@@ -381,8 +381,9 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
       
       if (constantThatMustBeLoaded || isa<GlobalValue>(opValue))
         { // opValue is a constant that must be explicitly loaded into a reg.
-          TmpInstruction* tmpReg = InsertCodeToLoadConstant(method, opValue, vmInstr,
-                                                            loadConstVec, target);
+          TmpInstruction* tmpReg = InsertCodeToLoadConstant(F, opValue, vmInstr,
+                                                            loadConstVec,
+                                                            target);
           minstr->SetMachineOperandVal(op, MachineOperand::MO_VirtualRegister,
                                        tmpReg);
         }
@@ -404,7 +405,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
       {
         Value* oldVal = minstr->getImplicitRef(i);
         TmpInstruction* tmpReg =
-          InsertCodeToLoadConstant(method, oldVal, vmInstr, loadConstVec, target);
+          InsertCodeToLoadConstant(F, oldVal, vmInstr, loadConstVec, target);
         minstr->setImplicitRef(i, tmpReg);
       }
   
index 32951769e00a20cd14bafa1d18ed3b9b926743a0..fb29af2bf192a75becb904aacb90d018ee46464b 100644 (file)
@@ -2,15 +2,15 @@
 #include "llvm/CodeGen/RegClass.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "Support/SetOperations.h"
 #include <iostream>
 using std::cerr;
 
-LiveRangeInfo::LiveRangeInfo(const Method *M, const TargetMachine &tm,
+LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm,
                             std::vector<RegClass *> &RCL)
-  : Meth(M), TM(tm), RegClassList(RCL), MRI(tm.getRegInfo()) { }
+  : Meth(F), TM(tm), RegClassList(RCL), MRI(tm.getRegInfo()) { }
 
 
 LiveRangeInfo::~LiveRangeInfo() {
@@ -48,7 +48,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *L1, LiveRange *L2) {
     //assert(( L1->getTypeID() == L2->getTypeID()) && "Merge:Different types");
 
     L1->insert(*L2It);                  // add the var in L2 to L1
-    LiveRangeMap[*L2It] = L1;         // now the elements in L2 should map 
+    LiveRangeMap[*L2It] = L1;           // now the elements in L2 should map 
                                         //to L1    
   }
 
@@ -73,24 +73,22 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *L1, LiveRange *L2) {
 
 
 //---------------------------------------------------------------------------
-// Method for constructing all live ranges in a method. It creates live 
+// Method for constructing all live ranges in a function. It creates live 
 // ranges for all values defined in the instruction stream. Also, it
-// creates live ranges for all incoming arguments of the method.
+// creates live ranges for all incoming arguments of the function.
 //---------------------------------------------------------------------------
 void LiveRangeInfo::constructLiveRanges() {  
 
   if (DEBUG_RA) 
     cerr << "Consturcting Live Ranges ...\n";
 
-  // first find the live ranges for all incoming args of the method since
-  // those LRs start from the start of the method
+  // first find the live ranges for all incoming args of the function since
+  // those LRs start from the start of the function
       
-                                                 // get the argument list
-  const Method::ArgumentListType& ArgList = Meth->getArgumentList();           
-                                                 // get an iterator to arg list
-  Method::ArgumentListType::const_iterator ArgIt = ArgList.begin(); 
+  // get the argument list
+  const Function::ArgumentListType& ArgList = Meth->getArgumentList();
 
-             
+  Function::ArgumentListType::const_iterator ArgIt = ArgList.begin();
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {     // for each argument
     LiveRange * ArgRange = new LiveRange();      // creates a new LR and 
     const Value *Val = (const Value *) *ArgIt;
@@ -111,15 +109,14 @@ void LiveRangeInfo::constructLiveRanges() {
     }
   }
 
-  // Now suggest hardware registers for these method args 
+  // Now suggest hardware registers for these function args 
   MRI.suggestRegs4MethodArgs(Meth, *this);
 
 
-
   // Now find speical LLVM instructions (CALL, RET) and LRs in machine
   // instructions.
   //
-  for (Method::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI) {
+  for (Function::const_iterator BBI = Meth->begin(); BBI != Meth->end(); ++BBI){
     // Now find all LRs for machine the instructions. A new LR will be created 
     // only for defs in the machine instr since, we assume that all Values are
     // defined before they are used. However, there can be multiple defs for
@@ -207,7 +204,7 @@ void LiveRangeInfo::constructLiveRanges() {
 
     } // for all machine instructions in the BB
 
-  } // for all BBs in method
+  } // for all BBs in function
   
 
   // Now we have to suggest clors for call and return arg live ranges.
@@ -225,16 +222,14 @@ void LiveRangeInfo::constructLiveRanges() {
 //---------------------------------------------------------------------------
 // If some live ranges must be colored with specific hardware registers
 // (e.g., for outgoing call args), suggesting of colors for such live
-// ranges is done using target specific method. Those methods are called
+// ranges is done using target specific function. Those functions are called
 // from this function. The target specific methods must:
 //    1) suggest colors for call and return args. 
 //    2) create new LRs for implicit defs in machine instructions
 //---------------------------------------------------------------------------
 void LiveRangeInfo::suggestRegs4CallRets()
 {
-
   CallRetInstrListType::const_iterator It =  CallRetInstrList.begin();
-
   for( ; It !=  CallRetInstrList.end(); ++It ) {
 
     const MachineInstr *MInst = *It;
@@ -259,7 +254,7 @@ void LiveRangeInfo::suggestRegs4CallRets()
 
 
 /* Algorithm:
-   for each BB in method
+   for each BB in function
      for each machine instruction (inst)
        for each definition (def) in inst
          for each operand (op) of inst that is a use
@@ -273,12 +268,11 @@ void LiveRangeInfo::suggestRegs4CallRets()
 //---------------------------------------------------------------------------
 void LiveRangeInfo::coalesceLRs()  
 {
-  if( DEBUG_RA) 
+  if(DEBUG_RA) 
     cerr << "\nCoalscing LRs ...\n";
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
+  for(Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+      BBI != BBE; ++BBI) {
 
     // get the iterator for machine instructions
     const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
index 49667e00795d678b85edbb1de48eab7fdbb86f5d..c9d775e28498df7391938a95f97a2410fc32f438 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/MachineFrameInfo.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Type.h"
 #include <iostream>
 #include <math.h>
@@ -45,12 +45,12 @@ namespace {
   public:
     inline RegisterAllocator(TargetMachine &T) : Target(T) {}
     
-    bool runOnMethod(Method *M) {
+    bool runOnMethod(Function *F) {
       if (DEBUG_RA)
-        cerr << "\n******************** Method "<< M->getName()
+        cerr << "\n******************** Method "<< F->getName()
              << " ********************\n";
       
-      PhyRegAlloc PRA(M, Target, &getAnalysis<MethodLiveVarInfo>(),
+      PhyRegAlloc PRA(F, Target, &getAnalysis<MethodLiveVarInfo>(),
                       &getAnalysis<cfg::LoopInfo>());
       PRA.allocateRegisters();
       
@@ -75,22 +75,22 @@ MethodPass *getRegisterAllocator(TargetMachine &T) {
 //----------------------------------------------------------------------------
 // Constructor: Init local composite objects and create register classes.
 //----------------------------------------------------------------------------
-PhyRegAlloc::PhyRegAlloc(Method *M
+PhyRegAlloc::PhyRegAlloc(Function *F
                         const TargetMachine& tm, 
                         MethodLiveVarInfo *Lvi,
                          cfg::LoopInfo *LDC) 
-                       :  TM(tm), Meth(M),
-                          mcInfo(MachineCodeForMethod::get(M)),
-                          LVI(Lvi), LRI(M, tm, RegClassList), 
-                         MRI( tm.getRegInfo() ),
+                       :  TM(tm), Meth(F),
+                          mcInfo(MachineCodeForMethod::get(F)),
+                          LVI(Lvi), LRI(F, tm, RegClassList), 
+                         MRI(tm.getRegInfo()),
                           NumOfRegClasses(MRI.getNumOfRegClasses()),
                          LoopDepthCalc(LDC) {
 
   // create each RegisterClass and put in RegClassList
   //
   for(unsigned int rc=0; rc < NumOfRegClasses; rc++)  
-    RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc), 
-                                        &ResColList) );
+    RegClassList.push_back(new RegClass(F, MRI.getMachineRegClass(rc),
+                                        &ResColList));
 }
 
 
@@ -278,13 +278,12 @@ void PhyRegAlloc::buildInterferenceGraphs()
   if(DEBUG_RA) cerr << "Creating interference graphs ...\n";
 
   unsigned BBLoopDepthCost;
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
 
     // find the 10^(loop_depth) of this BB 
     //
-    BBLoopDepthCost = (unsigned) pow( 10.0, LoopDepthCalc->getLoopDepth(*BBI));
+    BBLoopDepthCost = (unsigned) pow(10.0, LoopDepthCalc->getLoopDepth(*BBI));
 
     // get the iterator for machine instructions
     //
@@ -346,12 +345,11 @@ void PhyRegAlloc::buildInterferenceGraphs()
 
 
     } // for all machine instructions in BB
-    
-  } // for all BBs in method
+  } // for all BBs in function
 
 
-  // add interferences for method arguments. Since there are no explict 
-  // defs in method for args, we have to add them manually
+  // add interferences for function arguments. Since there are no explict 
+  // defs in the function for args, we have to add them manually
   //  
   addInterferencesForArgs();          
 
@@ -405,17 +403,17 @@ void PhyRegAlloc::addInterf4PseudoInstr(const MachineInstr *MInst) {
 
 
 //----------------------------------------------------------------------------
-// This method will add interferences for incoming arguments to a method.
+// This method will add interferences for incoming arguments to a function.
 //----------------------------------------------------------------------------
 void PhyRegAlloc::addInterferencesForArgs() {
   // get the InSet of root BB
   const ValueSet &InSet = LVI->getInSetOfBB(Meth->front());  
 
   // get the argument list
-  const Method::ArgumentListType& ArgList = Meth->getArgumentList();  
+  const Function::ArgumentListType &ArgList = Meth->getArgumentList();  
 
   // get an iterator to arg list
-  Method::ArgumentListType::const_iterator ArgIt = ArgList.begin();          
+  Function::ArgumentListType::const_iterator ArgIt = ArgList.begin();          
 
 
   for( ; ArgIt != ArgList.end() ; ++ArgIt) {  // for each argument
@@ -441,10 +439,8 @@ void PhyRegAlloc::addInterferencesForArgs() {
 void PhyRegAlloc::updateMachineCode()
 {
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
-
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
     // get the iterator for machine instructions
     //
     MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -955,14 +951,12 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI,
 void PhyRegAlloc::printMachineCode()
 {
 
-  cerr << "\n;************** Method " << Meth->getName()
+  cerr << "\n;************** Function " << Meth->getName()
        << " *****************\n";
 
-  Method::const_iterator BBI = Meth->begin();  // random iterator for BBs   
-
-  for( ; BBI != Meth->end(); ++BBI) {          // traverse BBs in random order
-
-    cerr << "\n"; printLabel( *BBI); cerr << ": ";
+  for (Function::const_iterator BBI = Meth->begin(), BBE = Meth->end();
+       BBI != BBE; ++BBI) {
+    cerr << "\n"; printLabel(*BBI); cerr << ": ";
 
     // get the iterator for machine instructions
     MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec();
@@ -970,18 +964,12 @@ void PhyRegAlloc::printMachineCode()
 
     // iterate over all the machine instructions in BB
     for( ; MInstIterator != MIVec.end(); ++MInstIterator) {  
-      
       MachineInstr *const MInst = *MInstIterator; 
 
-
       cerr << "\n\t";
       cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString;
-      
-
-      //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) {
 
       for(unsigned OpNum=0; OpNum < MInst->getNumOperands(); ++OpNum) {
-
        MachineOperand& Op = MInst->getOperand(OpNum);
 
        if( Op.getOperandType() ==  MachineOperand::MO_VirtualRegister || 
@@ -1074,7 +1062,6 @@ void PhyRegAlloc::colorCallRetArgs()
     // So reset it before we call each such method
     //mcInfo.popAllTempValues(TM);  
 
-
     
     if (TM.getInstrInfo().isCall(OpCode))
       MRI.colorCallArgs(CRMI, LRI, AI, *this);
index 91570444830756e1d918efd9378d1b8e5e074f26..de4cb82b5dc400c36b027e0697eeb0f7fda25dad 100644 (file)
@@ -20,7 +20,7 @@
 #include "llvm/DerivedTypes.h"
 #include "llvm/Annotation.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Module.h"
 #include "Support/StringExtras.h"
 #include "Support/HashExtras.h"
@@ -74,7 +74,7 @@ public:
   AsmPrinter(std::ostream &os, const TargetMachine &T)
     : idTable(0), toAsm(os), Target(T), CurSection(Unknown) {}
   
-  // (start|end)(Module|Method) - Callback methods to be invoked by subclasses
+  // (start|end)(Module|Function) - Callback methods to be invoked by subclasses
   void startModule(Module *M) {
     // Create the global id table if it does not already exist
     idTable = (GlobalIdTable*) M->getAnnotation(GlobalIdTable::AnnotId);
@@ -83,12 +83,12 @@ public:
       M->addAnnotation(idTable);
     }
   }
-  void startMethod(Method *M) {
+  void startFunction(Function *F) {
     // Make sure the slot table has information about this method...
-    idTable->Table->incorporateMethod(M);
+    idTable->Table->incorporateMethod(F);
   }
-  void endMethod(Method *M) {
-    idTable->Table->purgeMethod();  // Forget all about M.
+  void endFunction(Function *F) {
+    idTable->Table->purgeMethod();  // Forget all about F
   }
   void endModule() {
   }
@@ -97,9 +97,8 @@ public:
   // Only functions can currently be external.  "main" is the only name
   // that is visible externally.
   bool isExternal(const Value* V) {
-    const Method* meth = dyn_cast<Method>(V);
-    return bool(meth != NULL
-                && (meth->isExternal() || meth->getName() == "main"));
+    const Function *F = dyn_cast<Function>(V);
+    return F && (F->isExternal() || F->getName() == "main");
   }
   
   // enterSection - Use this method to enter a different section of the output
@@ -177,8 +176,8 @@ public:
   string getID(const Module *M) {
     return getID(M, "LLVMModule_");
   }
-  string getID(const Method *M) {
-    return getID(M, "LLVMMethod_");
+  string getID(const Function *F) {
+    return getID(F, "LLVMFunction_");
   }
   string getID(const BasicBlock *BB) {
     return getID(BB, "LL", (".L_"+getID(BB->getParent())+"_").c_str());
@@ -194,11 +193,11 @@ public:
 
 
 //===----------------------------------------------------------------------===//
-//   SparcMethodAsmPrinter Code
+//   SparcFunctionAsmPrinter Code
 //===----------------------------------------------------------------------===//
 
-struct SparcMethodAsmPrinter : public MethodPass, public AsmPrinter {
-  inline SparcMethodAsmPrinter(std::ostream &os, const TargetMachine &t)
+struct SparcFunctionAsmPrinter : public MethodPass, public AsmPrinter {
+  inline SparcFunctionAsmPrinter(std::ostream &os, const TargetMachine &t)
     : AsmPrinter(os, t) {}
 
   virtual bool doInitialization(Module *M) {
@@ -206,10 +205,10 @@ struct SparcMethodAsmPrinter : public MethodPass, public AsmPrinter {
     return false;
   }
 
-  virtual bool runOnMethod(Method *M) {
-    startMethod(M);
-    emitMethod(M);
-    endMethod(M);
+  virtual bool runOnMethod(Function *F) {
+    startFunction(F);
+    emitFunction(F);
+    endFunction(F);
     return false;
   }
 
@@ -218,7 +217,7 @@ struct SparcMethodAsmPrinter : public MethodPass, public AsmPrinter {
     return false;
   }
 
-  void emitMethod(const Method *M);
+  void emitFunction(const Function *F);
 private :
   void emitBasicBlock(const BasicBlock *BB);
   void emitMachineInst(const MachineInstr *MI);
@@ -239,8 +238,8 @@ private :
 };
 
 inline bool
-SparcMethodAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI,
-                                       unsigned int opNum) {
+SparcFunctionAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI,
+                                               unsigned int opNum) {
   switch (MI->getOpCode()) {
   case JMPLCALL:
   case JMPLRET: return (opNum == 0);
@@ -250,8 +249,8 @@ SparcMethodAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI,
 
 
 inline bool
-SparcMethodAsmPrinter::OpIsMemoryAddressBase(const MachineInstr *MI,
-                                       unsigned int opNum) {
+SparcFunctionAsmPrinter::OpIsMemoryAddressBase(const MachineInstr *MI,
+                                               unsigned int opNum) {
   if (Target.getInstrInfo().isLoad(MI->getOpCode()))
     return (opNum == 0);
   else if (Target.getInstrInfo().isStore(MI->getOpCode()))
@@ -267,7 +266,7 @@ SparcMethodAsmPrinter::OpIsMemoryAddressBase(const MachineInstr *MI,
   printOneOperand(Op2);
 
 unsigned int
-SparcMethodAsmPrinter::printOperands(const MachineInstr *MI,
+SparcFunctionAsmPrinter::printOperands(const MachineInstr *MI,
                                unsigned int opNum)
 {
   const MachineOperand& Op = MI->getOperand(opNum);
@@ -293,7 +292,7 @@ SparcMethodAsmPrinter::printOperands(const MachineInstr *MI,
 
 
 void
-SparcMethodAsmPrinter::printOneOperand(const MachineOperand &op)
+SparcFunctionAsmPrinter::printOneOperand(const MachineOperand &op)
 {
   switch (op.getOperandType())
     {
@@ -319,7 +318,7 @@ SparcMethodAsmPrinter::printOneOperand(const MachineOperand &op)
           toAsm << "\t<*NULL Value*>";
         else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(Val))
           toAsm << getID(BB);
-        else if (const Method *M = dyn_cast<const Method>(Val))
+        else if (const Function *M = dyn_cast<const Function>(Val))
           toAsm << getID(M);
         else if (const GlobalVariable *GV=dyn_cast<const GlobalVariable>(Val))
           toAsm << getID(GV);
@@ -343,7 +342,7 @@ SparcMethodAsmPrinter::printOneOperand(const MachineOperand &op)
 
 
 void
-SparcMethodAsmPrinter::emitMachineInst(const MachineInstr *MI)
+SparcFunctionAsmPrinter::emitMachineInst(const MachineInstr *MI)
 {
   unsigned Opcode = MI->getOpCode();
 
@@ -369,7 +368,7 @@ SparcMethodAsmPrinter::emitMachineInst(const MachineInstr *MI)
 }
 
 void
-SparcMethodAsmPrinter::emitBasicBlock(const BasicBlock *BB)
+SparcFunctionAsmPrinter::emitBasicBlock(const BasicBlock *BB)
 {
   // Emit a label for the basic block
   toAsm << getID(BB) << ":\n";
@@ -385,18 +384,18 @@ SparcMethodAsmPrinter::emitBasicBlock(const BasicBlock *BB)
 }
 
 void
-SparcMethodAsmPrinter::emitMethod(const Method *M)
+SparcFunctionAsmPrinter::emitFunction(const Function *M)
 {
   string methName = getID(M);
-  toAsm << "!****** Outputing Method: " << methName << " ******\n";
+  toAsm << "!****** Outputing Function: " << methName << " ******\n";
   enterSection(AsmPrinter::Text);
   toAsm << "\t.align\t4\n\t.global\t" << methName << "\n";
   //toAsm << "\t.type\t" << methName << ",#function\n";
   toAsm << "\t.type\t" << methName << ", 2\n";
   toAsm << methName << ":\n";
 
-  // Output code for all of the basic blocks in the method...
-  for (Method::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
+  // Output code for all of the basic blocks in the function...
+  for (Function::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
     emitBasicBlock(*I);
 
   // Output a .size directive so the debugger knows the extents of the function
@@ -404,14 +403,14 @@ SparcMethodAsmPrinter::emitMethod(const Method *M)
            << methName << ", .EndOf_"
            << methName << "-" << methName << "\n";
 
-  // Put some spaces between the methods
+  // Put some spaces between the functions
   toAsm << "\n\n";
 }
 
 }  // End anonymous namespace
 
 Pass *UltraSparc::getMethodAsmPrinterPass(PassManager &PM, std::ostream &Out) {
-  return new SparcMethodAsmPrinter(Out, *this);
+  return new SparcFunctionAsmPrinter(Out, *this);
 }
 
 
@@ -419,7 +418,7 @@ Pass *UltraSparc::getMethodAsmPrinterPass(PassManager &PM, std::ostream &Out) {
 
 
 //===----------------------------------------------------------------------===//
-//   SparcMethodAsmPrinter Code
+//   SparcFunctionAsmPrinter Code
 //===----------------------------------------------------------------------===//
 
 namespace {
index a44dc7fbaf5b146a38d0692e8261edadc58d8776..aa618c9259aef4f1d5545834065ee1f0da72becd 100644 (file)
@@ -17,7 +17,7 @@
 #include "llvm/CodeGen/InstrSelectionSupport.h"
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineCodeForMethod.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/ConstantVals.h"
 #include "llvm/DerivedTypes.h"
 
@@ -136,11 +136,10 @@ UltraSparcInstrInfo::UltraSparcInstrInfo(const TargetMachine& tgt)
 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
 // 
 void
-UltraSparcInstrInfo::CreateCodeToLoadConst(Method* method,
-                                           Value* val,
+UltraSparcInstrInfo::CreateCodeToLoadConst(Function *F, Value* val,
                                            Instruction* dest,
-                                           std::vector<MachineInstr*>& minstrVec,
-                                           std::vector<TmpInstruction*>& tempVec) const
+                                           std::vector<MachineInstr*>&minstrVec,
+                                    std::vector<TmpInstruction*>& tempVec) const
 {
   MachineInstr* minstr;
   
@@ -197,22 +196,23 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Method* method,
       
       minstr = new MachineInstr(SETX);
       minstr->SetMachineOperandVal(0, MachineOperand::MO_PCRelativeDisp, val);
-      minstr->SetMachineOperandVal(1, MachineOperand::MO_VirtualRegister, tmpReg,
+      minstr->SetMachineOperandVal(1, MachineOperand::MO_VirtualRegister,tmpReg,
                                    /*isdef*/ true);
-      minstr->SetMachineOperandVal(2, MachineOperand::MO_VirtualRegister,addrVal);
+      minstr->SetMachineOperandVal(2, MachineOperand::MO_VirtualRegister,
+                                   addrVal);
       minstrVec.push_back(minstr);
       
       if (isa<Constant>(val))
         {
           // Make sure constant is emitted to constant pool in assembly code.
-          MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method);
+          MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(F);
           mcinfo.addToConstantPool(cast<Constant>(val));
           
           // Generate the load instruction
           minstr = new MachineInstr(ChooseLoadInstruction(val->getType()));
           minstr->SetMachineOperandVal(0, MachineOperand::MO_VirtualRegister,
                                        addrVal);
-          minstr->SetMachineOperandConst(1, MachineOperand::MO_SignExtendedImmed,
+          minstr->SetMachineOperandConst(1,MachineOperand::MO_SignExtendedImmed,
                                        zeroOffset);
           minstr->SetMachineOperandVal(2, MachineOperand::MO_VirtualRegister,
                                        dest);
@@ -229,7 +229,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Method* method,
 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
 // 
 void
-UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
+UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Function *F,
                                          Value* val,
                                          Instruction* dest,
                                          std::vector<MachineInstr*>& minstrVec,
@@ -238,10 +238,10 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
 {
   assert((val->getType()->isIntegral() || val->getType()->isPointerType())
          && "Source type must be integral");
-  assert((dest->getType() ==Type::FloatTy || dest->getType() ==Type::DoubleTy)
+  assert((dest->getType() == Type::FloatTy || dest->getType() == Type::DoubleTy)
          && "Dest type must be float/double");
   
-  MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method);
+  MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(F);
   int offset = mcinfo.allocateLocalVar(target, val); 
   
   // Store instruction stores `val' to [%fp+offset].
@@ -255,7 +255,7 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
   MachineInstr* store = new MachineInstr(ChooseStoreInstruction(tmpType));
   store->SetMachineOperandVal(0, MachineOperand::MO_VirtualRegister, val);
   store->SetMachineOperandReg(1, target.getRegInfo().getFramePointer());
-  store->SetMachineOperandConst(2, MachineOperand::MO_SignExtendedImmed, offset);
+  store->SetMachineOperandConst(2,MachineOperand::MO_SignExtendedImmed, offset);
   minstrVec.push_back(store);
 
   // Load instruction loads [%fp+offset] to `dest'.
@@ -273,7 +273,7 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method,
 // See the previous function for information about return values.
 // 
 void
-UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Method* method,
+UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Function *F,
                                         Value* val,
                                         Instruction* dest,
                                         std::vector<MachineInstr*>& minstrVec,
@@ -285,7 +285,7 @@ UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Method* method,
   assert((dest->getType()->isIntegral() || dest->getType()->isPointerType())
          && "Dest type must be integral");
   
-  MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method);
+  MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(F);
   int offset = mcinfo.allocateLocalVar(target, val); 
   
   // Store instruction stores `val' to [%fp+offset].
index 7b6e597e4dc5db818301d44440c8187843d8fb6f..2094f6ec41c8ecbf804ac0eb03e9af54775855bf 100644 (file)
@@ -24,7 +24,7 @@
 #include "llvm/iMemory.h"
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/ConstantVals.h"
 #include "Support/MathExtras.h"
 #include <math.h>
@@ -141,20 +141,20 @@ ChooseBFpccInstruction(const InstructionNode* instrNode,
 // Eventually the entire BURG instruction selection should be put
 // into a separate class that can hold such information.
 // The static cache is not too bad because the memory for these
-// TmpInstructions will be freed along with the rest of the Method anyway.
+// TmpInstructions will be freed along with the rest of the Function anyway.
 // 
 static TmpInstruction*
-GetTmpForCC(Value* boolVal, const Method* method, const Type* ccType)
+GetTmpForCC(Value* boolVal, const Function *F, const Type* ccType)
 {
   typedef std::hash_map<const Value*, TmpInstruction*> BoolTmpCache;
   static BoolTmpCache boolToTmpCache;     // Map boolVal -> TmpInstruction*
-  static const Method* lastMethod = NULL; // Use to flush cache between methods
+  static const Function *lastFunction = 0;// Use to flush cache between funcs
   
   assert(boolVal->getType() == Type::BoolTy && "Weird but ok! Delete assert");
   
-  if (lastMethod != method)
+  if (lastFunction != F)
     {
-      lastMethod = method;
+      lastFunction = F;
       boolToTmpCache.clear();
     }
   
@@ -809,9 +809,9 @@ CreateCodeForVariableSizeAlloca(const TargetMachine& target,
 
   // Get the constant offset from SP for dynamically allocated storage
   // and create a temporary Value to hold it.
-  assert(result && result->getParent() && "Result value is not part of a method?");
-  Method* method = result->getParent()->getParent();
-  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(method);
+  assert(result && result->getParent() && "Result value is not part of a fn?");
+  Function *F = result->getParent()->getParent();
+  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(F);
   bool growUp;
   ConstantSInt* dynamicAreaOffset =
     ConstantSInt::get(Type::IntTy,
@@ -853,13 +853,14 @@ CreateCodeForFixedSizeAlloca(const TargetMachine& target,
                              vector<MachineInstr*>& getMvec)
 {
   assert(result && result->getParent() &&
-         "Result value is not part of a method?");
-  Method* method = result->getParent()->getParent();
-  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(method);
-
-  // Check if the offset would small enough to use as an immediate in load/stores
-  // (check LDX because all load/stores have the same-size immediate field).
-  // If not, put the variable in the dynamically sized area of the frame.
+         "Result value is not part of a function?");
+  Function *F = result->getParent()->getParent();
+  MachineCodeForMethod &mcInfo = MachineCodeForMethod::get(F);
+
+  // Check if the offset would small enough to use as an immediate in
+  // load/stores (check LDX because all load/stores have the same-size immediate
+  // field).  If not, put the variable in the dynamically sized area of the
+  // frame.
   unsigned int paddedSizeIgnored;
   int offsetFromFP = mcInfo.computeOffsetforLocalVar(target, result,
                                                      paddedSizeIgnored,
@@ -1148,7 +1149,7 @@ ForwardOperand(InstructionNode* treeNode,
 
 void UltraSparcInstrInfo::
 CreateCopyInstructionsByType(const TargetMachine& target,
-                             Method* method,
+                             Function *F,
                              Value* src,
                              Instruction* dest,
                              vector<MachineInstr*>& minstrVec) const
@@ -1186,8 +1187,8 @@ CreateCopyInstructionsByType(const TargetMachine& target,
     { // `src' is constant and cannot fit in immed field for the ADD
       // Insert instructions to "load" the constant into a register
       vector<TmpInstruction*> tempVec;
-      target.getInstrInfo().CreateCodeToLoadConst(method, src, dest,
-                                                  minstrVec,tempVec);
+      target.getInstrInfo().CreateCodeToLoadConst(F, src, dest,
+                                                  minstrVec, tempVec);
       for (unsigned i=0; i < tempVec.size(); i++)
         MachineCodeForInstruction::get(dest).addTemp(tempVec[i]);
     }
@@ -1235,8 +1236,8 @@ GetInstructionsForProlog(BasicBlock* entryBB,
   // We will assume that local register `l0' is unused since the SAVE
   // instruction must be the first instruction in each procedure.
   // 
-  Method* method = entryBB->getParent();
-  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(method);
+  Function *F = entryBB->getParent();
+  MachineCodeForMethod& mcInfo = MachineCodeForMethod::get(F);
   unsigned int staticStackSize = mcInfo.getStaticStackSize();
   
   if (staticStackSize < (unsigned) frameInfo.getMinStackFrameSize())
index 3eac9c0d2a2b3d4091ac25756da63b2427704a0c..09b44f5f2e52b230be424934235dd50f0bbb52ac 100644 (file)
@@ -18,7 +18,7 @@
 #include "llvm/CodeGen/MachineCodeForMethod.h"
 #include "llvm/CodeGen/RegisterAllocation.h"
 #include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/PassManager.h"
 #include <iostream>
@@ -45,12 +45,12 @@ TargetMachine *allocateSparcTargetMachine() { return new UltraSparc(); }
 //---------------------------------------------------------------------------
 // class InsertPrologEpilogCode
 //
-// Insert SAVE/RESTORE instructions for the method
+// Insert SAVE/RESTORE instructions for the function
 //
-// Insert prolog code at the unique method entry point.
-// Insert epilog code at each method exit point.
-// InsertPrologEpilog invokes these only if the method is not compiled
-// with the leaf method optimization.
+// Insert prolog code at the unique function entry point.
+// Insert epilog code at each function exit point.
+// InsertPrologEpilog invokes these only if the function is not compiled
+// with the leaf function optimization.
 //
 //---------------------------------------------------------------------------
 static MachineInstr* minstrVec[MAX_INSTR_PER_VMINSTR];
@@ -59,22 +59,22 @@ class InsertPrologEpilogCode : public MethodPass {
   TargetMachine &Target;
 public:
   inline InsertPrologEpilogCode(TargetMachine &T) : Target(T) {}
-  bool runOnMethod(Method *M) {
-    MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(M);
+  bool runOnMethod(Function *F) {
+    MachineCodeForMethod &mcodeInfo = MachineCodeForMethod::get(F);
     if (!mcodeInfo.isCompiledAsLeafMethod()) {
-      InsertPrologCode(M);
-      InsertEpilogCode(M);
+      InsertPrologCode(F);
+      InsertEpilogCode(F);
     }
     return false;
   }
 
-  void InsertPrologCode(Method *M);
-  void InsertEpilogCode(Method *M);
+  void InsertPrologCode(Function *F);
+  void InsertEpilogCode(Function *F);
 };
 
-void InsertPrologEpilogCode::InsertPrologCode(Method* method)
+void InsertPrologEpilogCode::InsertPrologCode(Function *F)
 {
-  BasicBlock* entryBB = method->getEntryNode();
+  BasicBlock *entryBB = F->getEntryNode();
   unsigned N = GetInstructionsForProlog(entryBB, Target, minstrVec);
   assert(N <= MAX_INSTR_PER_VMINSTR);
   MachineCodeForBasicBlock& bbMvec = entryBB->getMachineInstrVec();
@@ -82,9 +82,9 @@ void InsertPrologEpilogCode::InsertPrologCode(Method* method)
 }
 
 
-void InsertPrologEpilogCode::InsertEpilogCode(Method* method)
+void InsertPrologEpilogCode::InsertEpilogCode(Function *F)
 {
-  for (Method::iterator I=method->begin(), E=method->end(); I != E; ++I) {
+  for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) {
     Instruction *TermInst = (Instruction*)(*I)->getTerminator();
     if (TermInst->getOpcode() == Instruction::Ret)
       {
@@ -209,12 +209,12 @@ UltraSparc::UltraSparc()
 // Native code generation for a specified target.
 //===---------------------------------------------------------------------===//
 
-class ConstructMachineCodeForMethod : public MethodPass {
+class ConstructMachineCodeForFunction : public MethodPass {
   TargetMachine &Target;
 public:
-  inline ConstructMachineCodeForMethod(TargetMachine &T) : Target(T) {}
-  bool runOnMethod(Method *M) {
-    MachineCodeForMethod::construct(M, Target);
+  inline ConstructMachineCodeForFunction(TargetMachine &T) : Target(T) {}
+  bool runOnMethod(Function *F) {
+    MachineCodeForMethod::construct(F, Target);
     return false;
   }
 };
@@ -223,26 +223,28 @@ class InstructionSelection : public MethodPass {
   TargetMachine &Target;
 public:
   inline InstructionSelection(TargetMachine &T) : Target(T) {}
-  bool runOnMethod(Method *M) {
-    if (SelectInstructionsForMethod(M, Target))
-      cerr << "Instr selection failed for method " << M->getName() << "\n";
+  bool runOnMethod(Function *F) {
+    if (SelectInstructionsForMethod(F, Target)) {
+      cerr << "Instr selection failed for function " << F->getName() << "\n";
+      abort();
+    }
     return false;
   }
 };
 
-struct FreeMachineCodeForMethod : public MethodPass {
+struct FreeMachineCodeForFunction : public MethodPass {
   static void freeMachineCode(Instruction *I) {
     MachineCodeForInstruction::destroy(I);
   }
   
-  bool runOnMethod(Method *M) {
-    for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
-      for (BasicBlock::iterator I = (*MI)->begin(), E = (*MI)->end();
+  bool runOnMethod(Function *F) {
+    for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
+      for (BasicBlock::iterator I = (*FI)->begin(), E = (*FI)->end();
            I != E; ++I)
         MachineCodeForInstruction::get(*I).dropAllReferences();
     
-    for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
-      for (BasicBlock::iterator I = (*MI)->begin(), E = (*MI)->end();
+    for (Method::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
+      for (BasicBlock::iterator I = (*FI)->begin(), E = (*FI)->end();
            I != E; ++I)
         freeMachineCode(*I);
     
@@ -256,8 +258,8 @@ struct FreeMachineCodeForMethod : public MethodPass {
 // process for the ultra sparc.
 //
 void UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
-  // Construct and initialize the MachineCodeForMethod object for this method.
-  PM.add(new ConstructMachineCodeForMethod(*this));
+  // Construct and initialize the MachineCodeForMethod object for this fn.
+  PM.add(new ConstructMachineCodeForFunction(*this));
 
   PM.add(new InstructionSelection(*this));
 
@@ -273,15 +275,15 @@ void UltraSparc::addPassesToEmitAssembly(PassManager &PM, std::ostream &Out) {
   PM.add(new InsertPrologEpilogCode(*this));
   
   // Output assembly language to the .s file.  Assembly emission is split into
-  // two parts: Method output and Global value output.  This is because method
-  // output is pipelined with all of the rest of code generation stuff,
-  // allowing machine code representations for methods to be free'd after the
-  // method has been emitted.
+  // two parts: Function output and Global value output.  This is because
+  // function output is pipelined with all of the rest of code generation stuff,
+  // allowing machine code representations for functions to be free'd after the
+  // function has been emitted.
   //
   PM.add(getMethodAsmPrinterPass(PM, Out));
-  PM.add(new FreeMachineCodeForMethod());  // Free stuff no longer needed
+  PM.add(new FreeMachineCodeForFunction());  // Free stuff no longer needed
 
-  // Emit Module level assembly after all of the methods have been processed.
+  // Emit Module level assembly after all of the functions have been processed.
   PM.add(getModuleAsmPrinterPass(PM, Out));
 
   // Emit bytecode to the sparc assembly file into its special section next
index 790f68f7a37bb01713d430e09ed94c37a9677da2..b91a74e1e839e5093fbef51f7466596d733fda6e 100644 (file)
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "TransformInternals.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "llvm/iPHINode.h"
 #include "llvm/iMemory.h"
@@ -828,34 +828,34 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
     assert (OI != I->op_end() && "Not using value!");
     unsigned OpNum = OI - I->op_begin();
 
-    // Are we trying to change the method pointer value to a new type?
+    // Are we trying to change the function pointer value to a new type?
     if (OpNum == 0) {
       PointerType *PTy = dyn_cast<PointerType>(Ty);
       if (PTy == 0) return false;  // Can't convert to a non-pointer type...
       FunctionType *MTy = dyn_cast<FunctionType>(PTy->getElementType());
-      if (MTy == 0) return false;  // Can't convert to a non ptr to method...
+      if (MTy == 0) return false;  // Can't convert to a non ptr to function...
 
-      // Perform sanity checks to make sure that new method type has the
+      // Perform sanity checks to make sure that new function type has the
       // correct number of arguments...
       //
-      unsigned NumArgs = I->getNumOperands()-1;  // Don't include method ptr
+      unsigned NumArgs = I->getNumOperands()-1;  // Don't include function ptr
 
       // Cannot convert to a type that requires more fixed arguments than
       // the call provides...
       //
       if (NumArgs < MTy->getParamTypes().size()) return false;
       
-      // Unless this is a vararg method type, we cannot provide more arguments
+      // Unless this is a vararg function type, we cannot provide more arguments
       // than are desired...
       //
       if (!MTy->isVarArg() && NumArgs > MTy->getParamTypes().size())
         return false;
 
-      // Okay, at this point, we know that the call and the method type match
+      // Okay, at this point, we know that the call and the function type match
       // number of arguments.  Now we see if we can convert the arguments
       // themselves.  Note that we do not require operands to be convertable,
       // we can insert casts if they are convertible but not compatible.  The
-      // reason for this is that we prefer to have resolved methods but casted
+      // reason for this is that we prefer to have resolved functions but casted
       // arguments if possible.
       //
       const FunctionType::ParamTypes &PTs = MTy->getParamTypes();
@@ -878,7 +878,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty,
       return false;  // It's not in the varargs section...
 
     // If we get this far, we know the value is in the varargs section of the
-    // method!  We can convert if we don't reinterpret the value...
+    // function!  We can convert if we don't reinterpret the value...
     //
     return Ty->isLosslesslyConvertableTo(V->getType());
   }
@@ -1098,7 +1098,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
     Value *Meth = I->getOperand(0);
     std::vector<Value*> Params(I->op_begin()+1, I->op_end());
 
-    if (Meth == OldVal) {   // Changing the method pointer?
+    if (Meth == OldVal) {   // Changing the function pointer?
       PointerType *NewPTy = cast<PointerType>(NewVal->getType());
       FunctionType *NewTy = cast<FunctionType>(NewPTy->getElementType());
       const FunctionType::ParamTypes &PTs = NewTy->getParamTypes();
@@ -1107,7 +1107,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
       // operands if needbe.  Note that we do not require operands to be
       // convertable, we can insert casts if they are convertible but not
       // compatible.  The reason for this is that we prefer to have resolved
-      // methods but casted arguments if possible.
+      // functions but casted arguments if possible.
       //
       BasicBlock::iterator It = find(BIL.begin(), BIL.end(), I);
 
index f20de1cfc2105ded48cf6874a880663cc8eef879..26cf5ca04fdf03a793ddb711ba956504823d453a 100644 (file)
@@ -10,7 +10,7 @@
 #include "llvm/iPHINode.h"
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Pass.h"
 #include <map>
 #include <vector>
@@ -42,11 +42,11 @@ static Value *NormalizePhiOperand(PHINode *PN, Value *CPV,
 // Entry point for normalizing constant args in PHIs
 //---------------------------------------------------------------------------
 
-static bool doHoistPHIConstants(Method *M) {
+static bool doHoistPHIConstants(Function *M) {
   CachedCopyMap Cache;
   bool Changed = false;
   
-  for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) {
+  for (Function::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) {
     std::vector<PHINode*> phis;          // normalizing invalidates BB iterator
       
     for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) {
@@ -75,7 +75,7 @@ static bool doHoistPHIConstants(Method *M) {
 
 namespace {
   struct HoistPHIConstants : public MethodPass {
-    virtual bool runOnMethod(Method *M) { return doHoistPHIConstants(M); }
+    virtual bool runOnMethod(Function *F) { return doHoistPHIConstants(F); }
   };
 }
 
index d78d185e8afdf23b45b26cf1ba56ad1f9940c853..ef51105a474c2c9ef526f1d91fbec8848c527dc3 100644 (file)
@@ -9,7 +9,7 @@
 // and elminate duplicates when it is initialized.
 //
 // The DynamicConstantMerge method is a superset of the ConstantMerge algorithm
-// that checks for each method to see if constants have been added to the
+// that checks for each function to see if constants have been added to the
 // constant pool since it was last run... if so, it processes them.
 //
 //===----------------------------------------------------------------------===//
@@ -17,7 +17,7 @@
 #include "llvm/Transforms/ConstantMerge.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Pass.h"
 
 // mergeDuplicateConstants - Workhorse for the pass.  This eliminates duplicate
@@ -73,7 +73,7 @@ namespace {
       return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
     }
     
-    bool runOnMethod(Method*) { return false; }
+    bool runOnMethod(Function *) { return false; }
     
     // doFinalization - Clean up internal state for this module
     //
@@ -85,11 +85,11 @@ namespace {
   };
   
   struct DynamicConstantMerge : public ConstantMerge {
-    // doPerMethodWork - Check to see if any globals have been added to the 
+    // runOnMethod - Check to see if any globals have been added to the 
     // global list for the module.  If so, eliminate them.
     //
-    bool runOnMethod(Method *M) {
-      return ::mergeDuplicateConstants(M->getParent(), LastConstantSeen,
+    bool runOnMethod(Function *F) {
+      return ::mergeDuplicateConstants(F->getParent(), LastConstantSeen,
                                        Constants);
     }
   };
index ea23dbedda12006972417a9075a402b21fda5280..ae9bd39270717efaf68eb4b173fc726fe73b5e34 100644 (file)
@@ -1,4 +1,4 @@
-//===-- GlobalDCE.cpp - DCE unreachable internal methods ---------*- C++ -*--=//
+//===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===//
 //
 // This transform is designed to eliminate unreachable internal globals
 //
@@ -7,40 +7,40 @@
 #include "llvm/Transforms/IPO/GlobalDCE.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Pass.h"
 #include "Support/DepthFirstIterator.h"
 #include <set>
 
-static bool RemoveUnreachableMethods(Module *M, CallGraph &CallGraph) {
-  // Calculate which methods are reachable from the external methods in the call
-  // graph.
+static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) {
+  // Calculate which functions are reachable from the external functions in the
+  // call graph.
   //
   std::set<CallGraphNode*> ReachableNodes(df_begin(&CallGraph),
                                           df_end(&CallGraph));
 
-  // Loop over the methods in the module twice.  The first time is used to drop
-  // references that methods have to each other before they are deleted.  The
-  // second pass removes the methods that need to be removed.
+  // Loop over the functions in the module twice.  The first time is used to
+  // drop references that functions have to each other before they are deleted.
+  // The second pass removes the functions that need to be removed.
   //
-  std::vector<CallGraphNode*> MethodsToDelete;   // Track unused methods
+  std::vector<CallGraphNode*> FunctionsToDelete;   // Track unused functions
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
     CallGraphNode *N = CallGraph[*I];
     if (!ReachableNodes.count(N)) {              // Not reachable??
       (*I)->dropAllReferences();
       N->removeAllCalledMethods();
-      MethodsToDelete.push_back(N);
+      FunctionsToDelete.push_back(N);
     }
   }
 
-  // Nothing to do if no unreachable methods have been found...
-  if (MethodsToDelete.empty()) return false;
+  // Nothing to do if no unreachable functions have been found...
+  if (FunctionsToDelete.empty()) return false;
 
-  // Unreachables methods have been found and should have no references to them,
-  // delete them now.
+  // Unreachables functions have been found and should have no references to
+  // them, delete them now.
   //
-  for (std::vector<CallGraphNode*>::iterator I = MethodsToDelete.begin(),
-        E = MethodsToDelete.end(); I != E; ++I)
+  for (std::vector<CallGraphNode*>::iterator I = FunctionsToDelete.begin(),
+        E = FunctionsToDelete.end(); I != E; ++I)
     delete CallGraph.removeMethodFromModule(*I);
 
   return true;
@@ -52,7 +52,7 @@ namespace {
     // the specified callgraph to reflect the changes.
     //
     bool run(Module *M) {
-      return RemoveUnreachableMethods(M, getAnalysis<CallGraph>());
+      return RemoveUnreachableFunctions(M, getAnalysis<CallGraph>());
     }
 
     // getAnalysisUsageInfo - This function works on the call graph of a module.
index 51cde2e799f5880af41e7992b50ad8b3fe5c87b0..d720c3c2cc78b279a5eaa83c2d11ee44171c4ad1 100644 (file)
@@ -1,26 +1,23 @@
-//===- MethodInlining.cpp - Code to perform method inlining ---------------===//
+//===- FunctionInlining.cpp - Code to perform function inlining -----------===//
 //
-// This file implements inlining of methods.
+// This file implements inlining of functions.
 //
 // Specifically, this:
-//   * Exports functionality to inline any method call
-//   * Inlines methods that consist of a single basic block
-//   * Is able to inline ANY method call
-//   . Has a smart heuristic for when to inline a method
+//   * Exports functionality to inline any function call
+//   * Inlines functions that consist of a single basic block
+//   * Is able to inline ANY function call
+//   . Has a smart heuristic for when to inline a function
 //
 // Notice that:
 //   * This pass opens up a lot of opportunities for constant propogation.  It
 //     is a good idea to to run a constant propogation pass, then a DCE pass 
 //     sometime after running this pass.
 //
-// TODO: Currently this throws away all of the symbol names in the method being
-//       inlined.  This shouldn't happen.
-//
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Transforms/MethodInlining.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Pass.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iPHINode.h"
@@ -53,7 +50,7 @@ static inline void RemapInstruction(Instruction *I,
   }
 }
 
-// InlineMethod - This function forcibly inlines the called method into the
+// InlineMethod - This function forcibly inlines the called function into the
 // basic block of the caller.  This returns false if it is not possible to
 // inline this call.  The program is still in a well defined state if this 
 // occurs though.
@@ -61,16 +58,16 @@ static inline void RemapInstruction(Instruction *I,
 // Note that this only does one level of inlining.  For example, if the 
 // instruction 'call B' is inlined, and 'B' calls 'C', then the call to 'C' now 
 // exists in the instruction stream.  Similiarly this will inline a recursive
-// method by one level.
+// function by one level.
 //
 bool InlineMethod(BasicBlock::iterator CIIt) {
   assert(isa<CallInst>(*CIIt) && "InlineMethod only works on CallInst nodes!");
   assert((*CIIt)->getParent() && "Instruction not embedded in basic block!");
-  assert((*CIIt)->getParent()->getParent() && "Instruction not in method!");
+  assert((*CIIt)->getParent()->getParent() && "Instruction not in function!");
 
   CallInst *CI = cast<CallInst>(*CIIt);
   const Function *CalledMeth = CI->getCalledFunction();
-  if (CalledMeth == 0 ||   // Can't inline external method or indirect call!
+  if (CalledMeth == 0 ||   // Can't inline external function or indirect call!
       CalledMeth->isExternal()) return false;
 
   //cerr << "Inlining " << CalledMeth->getName() << " into " 
@@ -90,7 +87,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) {
 
   // If we have a return value generated by this call, convert it into a PHI 
   // node that gets values from each of the old RET instructions in the original
-  // method.
+  // function.
   //
   PHINode *PHI = 0;
   if (CalledMeth->getReturnType() != Type::VoidTy) {
@@ -107,26 +104,26 @@ bool InlineMethod(BasicBlock::iterator CIIt) {
     CI->replaceAllUsesWith(PHI);
   }
 
-  // Keep a mapping between the original method's values and the new duplicated
-  // code's values.  This includes all of: Method arguments, instruction values,
-  // constant pool entries, and basic blocks.
+  // Keep a mapping between the original function's values and the new
+  // duplicated code's values.  This includes all of: Function arguments,
+  // instruction values, constant pool entries, and basic blocks.
   //
   std::map<const Value *, Value*> ValueMap;
 
-  // Add the method arguments to the mapping: (start counting at 1 to skip the
-  // method reference itself)
+  // Add the function arguments to the mapping: (start counting at 1 to skip the
+  // function reference itself)
   //
-  Method::ArgumentListType::const_iterator PTI = 
+  Function::ArgumentListType::const_iterator PTI = 
     CalledMeth->getArgumentList().begin();
   for (unsigned a = 1, E = CI->getNumOperands(); a != E; ++a, ++PTI)
     ValueMap[*PTI] = CI->getOperand(a);
   
   ValueMap[NewBB] = NewBB;  // Returns get converted to reference NewBB
 
-  // Loop over all of the basic blocks in the method, inlining them as 
-  // appropriate.  Keep track of the first basic block of the method...
+  // Loop over all of the basic blocks in the function, inlining them as 
+  // appropriate.  Keep track of the first basic block of the function...
   //
-  for (Method::const_iterator BI = CalledMeth->begin(); 
+  for (Function::const_iterator BI = CalledMeth->begin(); 
        BI != CalledMeth->end(); ++BI) {
     const BasicBlock *BB = *BI;
     assert(BB->getTerminator() && "BasicBlock doesn't have terminator!?!?");
@@ -161,7 +158,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) {
       if (PHI) {   // The PHI node should include this value!
        assert(RI->getReturnValue() && "Ret should have value!");
        assert(RI->getReturnValue()->getType() == PHI->getType() && 
-              "Ret value not consistent in method!");
+              "Ret value not consistent in function!");
        PHI->addIncoming((Value*)RI->getReturnValue(), cast<BasicBlock>(BB));
       }
 
@@ -174,16 +171,16 @@ bool InlineMethod(BasicBlock::iterator CIIt) {
       break;
 
     default:
-      cerr << "MethodInlining: Don't know how to handle terminator: " << TI;
+      cerr << "FunctionInlining: Don't know how to handle terminator: " << TI;
       abort();
     }
   }
 
 
-  // Loop over all of the instructions in the method, fixing up operand 
+  // Loop over all of the instructions in the function, fixing up operand 
   // references as we go.  This uses ValueMap to do all the hard work.
   //
-  for (Method::const_iterator BI = CalledMeth->begin(); 
+  for (Function::const_iterator BI = CalledMeth->begin(); 
        BI != CalledMeth->end(); ++BI) {
     const BasicBlock *BB = *BI;
     BasicBlock *NBB = (BasicBlock*)ValueMap[BB];
@@ -197,7 +194,7 @@ bool InlineMethod(BasicBlock::iterator CIIt) {
   if (PHI) RemapInstruction(PHI, ValueMap);  // Fix the PHI node also...
 
   // Change the branch that used to go to NewBB to branch to the first basic 
-  // block of the inlined method.
+  // block of the inlined function.
   //
   TerminatorInst *Br = OrigBB->getTerminator();
   assert(Br && Br->getOpcode() == Instruction::Br && 
@@ -220,15 +217,15 @@ bool InlineMethod(CallInst *CI) {
   return InlineMethod(CallIt);
 }
 
-static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) {
+static inline bool ShouldInlineFunction(const CallInst *CI, const Function *F) {
   assert(CI->getParent() && CI->getParent()->getParent() && 
         "Call not embedded into a method!");
 
   // Don't inline a recursive call.
-  if (CI->getParent()->getParent() == M) return false;
+  if (CI->getParent()->getParent() == F) return false;
 
   // Don't inline something too big.  This is a really crappy heuristic
-  if (M->size() > 3) return false;
+  if (F->size() > 3) return false;
 
   // Don't inline into something too big. This is a **really** crappy heuristic
   if (CI->getParent()->getParent()->size() > 10) return false;
@@ -238,30 +235,30 @@ static inline bool ShouldInlineMethod(const CallInst *CI, const Method *M) {
 }
 
 
-static inline bool DoMethodInlining(BasicBlock *BB) {
+static inline bool DoFunctionInlining(BasicBlock *BB) {
   for (BasicBlock::iterator I = BB->begin(); I != BB->end(); ++I) {
     if (CallInst *CI = dyn_cast<CallInst>(*I)) {
-      // Check to see if we should inline this method
-      Method *F = CI->getCalledFunction();
-      if (F && ShouldInlineMethod(CI, F))
+      // Check to see if we should inline this function
+      Function *F = CI->getCalledFunction();
+      if (F && ShouldInlineFunction(CI, F))
        return InlineMethod(I);
     }
   }
   return false;
 }
 
-// doMethodInlining - Use a heuristic based approach to inline methods that
+// doFunctionInlining - Use a heuristic based approach to inline functions that
 // seem to look good.
 //
-static bool doMethodInlining(Method *M) {
+static bool doFunctionInlining(Function *F) {
   bool Changed = false;
 
   // Loop through now and inline instructions a basic block at a time...
-  for (Method::iterator I = M->begin(); I != M->end(); )
-    if (DoMethodInlining(*I)) {
+  for (Function::iterator I = F->begin(); I != F->end(); )
+    if (DoFunctionInlining(*I)) {
       Changed = true;
       // Iterator is now invalidated by new basic blocks inserted
-      I = M->begin();
+      I = F->begin();
     } else {
       ++I;
     }
@@ -270,11 +267,11 @@ static bool doMethodInlining(Method *M) {
 }
 
 namespace {
-  struct MethodInlining : public MethodPass {
-    virtual bool runOnMethod(Method *M) {
-      return doMethodInlining(M);
+  struct FunctionInlining : public MethodPass {
+    virtual bool runOnMethod(Function *F) {
+      return doFunctionInlining(F);
     }
   };
 }
 
-Pass *createMethodInliningPass() { return new MethodInlining(); }
+Pass *createMethodInliningPass() { return new FunctionInlining(); }
index 1be6458fea2c3100719d0b97aa2d9e28781e9952..aa2cfdd2189609065994ce771303af73fdde1289 100644 (file)
@@ -1,8 +1,8 @@
 //===-- ProfilePaths.cpp - interface to insert instrumentation ---*- C++ -*--=//
 //
 // This inserts intrumentation for counting
-// execution of paths though a given method
-// Its implemented as a "Method" Pass, and called using opt
+// execution of paths though a given function
+// Its implemented as a "Function" Pass, and called using opt
 //
 // This pass is implemented by using algorithms similar to 
 // 1."Efficient Path Profiling": Ball, T. and Larus, J. R., 
@@ -18,7 +18,7 @@
 // (code inserted through EdgeCode.cpp).
 // 
 // The algorithm inserts code such that every acyclic path in the CFG
-// of a method is identified through a unique number. the code insertion
+// of a function is identified through a unique number. the code insertion
 // is optimal in the sense that its inserted over a minimal set of edges. Also,
 // the algorithm makes sure than initialization, path increment and counter
 // update can be collapsed into minmimum number of edges.
@@ -27,7 +27,7 @@
 #include "llvm/Transforms/Instrumentation/ProfilePaths.h"
 #include "llvm/Transforms/UnifyMethodExitNodes.h"
 #include "llvm/Support/CFG.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/ConstantVals.h"
 #include "llvm/DerivedTypes.h"
@@ -39,10 +39,10 @@ using std::vector;
 
 class ProfilePaths: public MethodPass {
  public:
-  bool runOnMethod(Method *M);
+  bool runOnMethod(Function *M);
 
   // Before this pass, make sure that there is only one 
-  // entry and only one exit node for the method in the CFG of the method
+  // entry and only one exit node for the function in the CFG of the function
   //
   void ProfilePaths::getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
                                          Pass::AnalysisSet &Destroyed,
@@ -67,8 +67,8 @@ static Node *findBB(std::set<Node *> &st, BasicBlock *BB){
   return NULL;
 }
 
-//Per method pass for inserting counters and trigger code
-bool ProfilePaths::runOnMethod(Method *M){
+//Per function pass for inserting counters and trigger code
+bool ProfilePaths::runOnMethod(Function *M){
   //Transform the cfg s.t. we have just one exit node
   BasicBlock *ExitNode = 
     getAnalysis<UnifyMethodExitNodes>().getExitNode();  
@@ -83,7 +83,7 @@ bool ProfilePaths::runOnMethod(Method *M){
   //That is, no two nodes must hav same BB*
   
   //First enter just nodes: later enter edges
-  for (Method::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){
+  for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){
     Node *nd=new Node(*BB);
     nodes.insert(nd); 
     if(*BB==ExitNode)
@@ -93,7 +93,7 @@ bool ProfilePaths::runOnMethod(Method *M){
   }
 
   //now do it againto insert edges
-  for (Method::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){
+  for (Function::iterator BB = M->begin(), BE=M->end(); BB != BE; ++BB){
     Node *nd=findBB(nodes, *BB);
     assert(nd && "No node for this edge!");
     for(BasicBlock::succ_iterator s=succ_begin(*BB), se=succ_end(*BB); 
@@ -165,5 +165,5 @@ bool ProfilePaths::runOnMethod(Method *M){
     processGraph(g, rVar, countVar, be, stDummy, exDummy);
   }
 
-  return true;  // Always modifies method
+  return true;  // Always modifies function
 }
index de647935666ed78cecf54a2b3c26556dbe0b8eae..aecf78dc648165b3f28f5ee6515224e2ccb7fdc8 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "llvm/Transforms/LevelChange.h"
 #include "TransformInternals.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iOther.h"
 #include "llvm/iMemory.h"
 #include "llvm/ConstantVals.h"
@@ -417,9 +417,9 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
 
 
 
-static bool DoRaisePass(Method *M) {
+static bool DoRaisePass(Function *F) {
   bool Changed = false;
-  for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+  for (Method::iterator MI = F->begin(), ME = F->end(); MI != ME; ++MI) {
     BasicBlock *BB = *MI;
     BasicBlock::InstListType &BIL = BB->getInstList();
 
@@ -445,9 +445,9 @@ static bool DoRaisePass(Method *M) {
 // RaisePointerReferences::doit - Raise a method representation to a higher
 // level.
 //
-static bool doRPR(Method *M) {
+static bool doRPR(Function *F) {
 #ifdef DEBUG_PEEPHOLE_INSTS
-  cerr << "\n\n\nStarting to work on Method '" << M->getName() << "'\n";
+  cerr << "\n\n\nStarting to work on Function '" << F->getName() << "'\n";
 #endif
 
   // Insert casts for all incoming pointer pointer values that are treated as
@@ -457,13 +457,13 @@ static bool doRPR(Method *M) {
   
   do {
 #ifdef DEBUG_PEEPHOLE_INSTS
-    cerr << "Looping: \n" << M;
+    cerr << "Looping: \n" << F;
 #endif
 
     // Iterate over the method, refining it, until it converges on a stable
     // state
     LocalChange = false;
-    while (DoRaisePass(M)) LocalChange = true;
+    while (DoRaisePass(F)) LocalChange = true;
     Changed |= LocalChange;
 
   } while (LocalChange);
@@ -473,7 +473,7 @@ static bool doRPR(Method *M) {
 
 namespace {
   struct RaisePointerReferences : public MethodPass {
-    virtual bool runOnMethod(Method *M) { return doRPR(M); }
+    virtual bool runOnMethod(Function *F) { return doRPR(F); }
   };
 }
 
index 624e6da39da276ec8b39af85962e7511d4a13b9f..8818b5d967389497c084157ee173cafaf2ab4712 100644 (file)
@@ -24,7 +24,7 @@
 #include "llvm/Transforms/Scalar/ConstantProp.h"
 #include "llvm/Transforms/Scalar/ConstantHandling.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iPHINode.h"
@@ -116,7 +116,7 @@ bool ConstantFoldTerminator(BasicBlock *BB, BasicBlock::iterator &II,
       BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
       BasicBlock *OldDest     = Cond->getValue() ? Dest2 : Dest1;
 
-      //cerr << "Method: " << T->getParent()->getParent() 
+      //cerr << "Function: " << T->getParent()->getParent() 
       //     << "\nRemoving branch from " << T->getParent() 
       //     << "\n\nTo: " << OldDest << endl;
 
@@ -196,10 +196,10 @@ bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) {
 // DoConstPropPass - Propogate constants and do constant folding on instructions
 // this returns true if something was changed, false if nothing was changed.
 //
-static bool DoConstPropPass(Method *M) {
+static bool DoConstPropPass(Function *F) {
   bool SomethingChanged = false;
 
-  for (Method::iterator BBI = M->begin(); BBI != M->end(); ++BBI) {
+  for (Method::iterator BBI = F->begin(); BBI != F->end(); ++BBI) {
     BasicBlock *BB = *BBI;
     for (BasicBlock::iterator I = BB->begin(); I != BB->end(); )
       if (doConstantPropogation(BB, I))
@@ -212,11 +212,11 @@ static bool DoConstPropPass(Method *M) {
 
 namespace {
   struct ConstantPropogation : public MethodPass {
-    inline bool runOnMethod(Method *M) {
+    inline bool runOnMethod(Function *F) {
       bool Modified = false;
 
       // Fold constants until we make no progress...
-      while (DoConstPropPass(M)) Modified = true;
+      while (DoConstPropPass(F)) Modified = true;
       
       return Modified;
     }
index 09bfd5cf340943460f4b258bd4e7fe6021d6132c..3a76d6a95777b093613dd3fbd9e5d307ed8da74c 100644 (file)
@@ -14,7 +14,7 @@
 #include "llvm/iMemory.h"
 #include "llvm/iOther.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Pass.h"
 
 
@@ -149,12 +149,12 @@ decomposeArrayRef(BasicBlock::iterator& BBI)
 //---------------------------------------------------------------------------
 
 static bool
-doDecomposeMultiDimRefs(Method *M)
+doDecomposeMultiDimRefs(Function *F)
 {
   bool changed = false;
   
-  for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI)
-    for (BasicBlock::iterator newI, II=(*BI)->begin();
+  for (Method::iterator BI = F->begin(), BE = F->end(); BI != BE; ++BI)
+    for (BasicBlock::iterator newI, II = (*BI)->begin();
          II != (*BI)->end(); II = ++newI)
       {
         newI = II;
@@ -172,7 +172,7 @@ doDecomposeMultiDimRefs(Method *M)
 
 namespace {
   struct DecomposeMultiDimRefsPass : public MethodPass {
-    virtual bool runOnMethod(Method *M) { return doDecomposeMultiDimRefs(M); }
+    virtual bool runOnMethod(Function *F) { return doDecomposeMultiDimRefs(F); }
   };
 }
 
index 1b0196e3e8759e81909ccc61da0a734a91b3b0b7..9bd95df50899c66b4be1474f41e1f71f7748eec7 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "llvm/Transforms/Scalar/InstructionCombining.h"
 #include "llvm/Transforms/Scalar/ConstantHandling.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iMemory.h"
 #include "llvm/InstrTypes.h"
 #include "llvm/Pass.h"
@@ -147,8 +147,8 @@ static bool CombineInstruction(Instruction *I) {
   return true;
 }
 
-static bool doInstCombining(Method *M) {
-  // Start the worklist out with all of the instructions in the method in it.
+static bool doInstCombining(Function *M) {
+  // Start the worklist out with all of the instructions in the function in it.
   std::vector<Instruction*> WorkList(inst_begin(M), inst_end(M));
 
   while (!WorkList.empty()) {
@@ -172,7 +172,7 @@ static bool doInstCombining(Method *M) {
 
 namespace {
   struct InstructionCombining : public MethodPass {
-    virtual bool runOnMethod(Method *M) { return doInstCombining(M); }
+    virtual bool runOnMethod(Function *F) { return doInstCombining(F); }
   };
 }
 
index 8502082a15dc5ead3f4aab143ffa90f9589dc0f4..a026fd673a18f5ec375aa1fd23e578023c3c8974 100644 (file)
@@ -1,11 +1,11 @@
-//===- SymbolStripping.cpp - Code to string symbols for methods and modules -=//
+//===- SymbolStripping.cpp - Strip symbols for functions and modules ------===//
 //
 // This file implements stripping symbols out of symbol tables.
 //
 // Specifically, this allows you to strip all of the symbols out of:
-//   * A method
-//   * All methods in a module
-//   * All symbols in a module (all method symbols + all module scope symbols)
+//   * A function
+//   * All functions in a module
+//   * All symbols in a module (all function symbols + all module scope symbols)
 //
 // Notice that:
 //   * This pass makes code much less readable, so it should only be used in
@@ -16,7 +16,7 @@
 
 #include "llvm/Transforms/SymbolStripping.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/SymbolTable.h"
 #include "llvm/Pass.h"
 
@@ -43,26 +43,26 @@ static bool StripSymbolTable(SymbolTable *SymTab) {
 }
 
 
-// DoSymbolStripping - Remove all symbolic information from a method
+// DoSymbolStripping - Remove all symbolic information from a function
 //
-static bool doSymbolStripping(Method *M) {
-  return StripSymbolTable(M->getSymbolTable());
+static bool doSymbolStripping(Function *F) {
+  return StripSymbolTable(F->getSymbolTable());
 }
 
-// doStripGlobalSymbols - Remove all symbolic information from all method
-// in a module, and all module level symbols. (method names, etc...)
+// doStripGlobalSymbols - Remove all symbolic information from all function
+// in a module, and all module level symbols. (function names, etc...)
 //
 static bool doStripGlobalSymbols(Module *M) {
-  // Remove all symbols from methods in this module... and then strip all of the
-  // symbols in this module...
+  // Remove all symbols from functions in this module... and then strip all of
+  // the symbols in this module...
   //  
   return StripSymbolTable(M->getSymbolTable());
 }
 
 namespace {
   struct SymbolStripping : public MethodPass {
-    virtual bool runOnMethod(Method *M) {
-      return doSymbolStripping(M);
+    virtual bool runOnMethod(Function *F) {
+      return doSymbolStripping(F);
     }
   };
 
index 796cdc7cb4a96db360008c9ddb49623968a98fc9..a75aa57bccd96ac1df59d73198152d74b7333fc1 100644 (file)
@@ -6,7 +6,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "TransformInternals.h"
-#include "llvm/Method.h"
 #include "llvm/Type.h"
 #include "llvm/ConstantVals.h"
 #include "llvm/Analysis/Expressions.h"
index f94632e3df975e987497c51e473f937f83edad72..79c03864d86259ce29dd519afe1ab9f26b8d43fb 100644 (file)
@@ -21,7 +21,7 @@
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/iMemory.h"
 #include "llvm/Pass.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/Assembly/Writer.h"  // For debugging
 #include "llvm/iPHINode.h"
@@ -34,8 +34,8 @@ using cfg::DominanceFrontier;
 
 namespace {
 
-//instance of the promoter -- to keep all the local method data.
-// gets re-created for each method processed
+//instance of the promoter -- to keep all the local function data.
+// gets re-created for each function processed
 class PromoteInstance
 {
        protected:
@@ -54,15 +54,15 @@ class PromoteInstance
 
 
        void traverse(BasicBlock *f, BasicBlock * predecessor);
-       bool PromoteMethod(Method *M, DominanceFrontier & DF);
+       bool PromoteFunction(Function *F, DominanceFrontier &DF);
        bool queuePhiNode(BasicBlock *bb, int alloca_index);
-       void findSafeAllocas(Method *M);
+       void findSafeAllocas(Function *M);
        bool didchange;
        public:
        // I do this so that I can force the deconstruction of the local variables
-       PromoteInstance(Method *M, DominanceFrontier & DF)
+       PromoteInstance(Function *F, DominanceFrontier &DF)
        {
-               didchange=PromoteMethod(M, DF);
+               didchange=PromoteFunction(F, DF);
        }
        //This returns whether the pass changes anything
        operator bool () { return didchange; }
@@ -72,9 +72,9 @@ class PromoteInstance
 
 // findSafeAllocas - Find allocas that are safe to promote
 //
-void PromoteInstance::findSafeAllocas(Method *M)  
+void PromoteInstance::findSafeAllocas(Function *F)  
 {
-  BasicBlock *BB = M->front();  // Get the entry node for the method
+  BasicBlock *BB = F->getEntryNode();  // Get the entry node for the function
 
   // Look at all instructions in the entry node
   for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
@@ -107,9 +107,9 @@ void PromoteInstance::findSafeAllocas(Method *M)
 
 
 
-bool PromoteInstance::PromoteMethod(Method *M, DominanceFrontier & DF) {
+bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) {
        // Calculate the set of safe allocas
-       findSafeAllocas(M);
+       findSafeAllocas(F);
 
        // Add each alloca to the killlist
        // note: killlist is destroyed MOST recently added to least recently.
@@ -158,10 +158,10 @@ bool PromoteInstance::PromoteMethod(Method *M, DominanceFrontier & DF) {
                }
        }
 
-       // Walks all basic blocks in the method
+       // Walks all basic blocks in the function
        // performing the SSA rename algorithm
        // and inserting the phi nodes we marked as necessary
-       BasicBlock * f = M->front(); //get root basic-block
+       BasicBlock * f = F->front(); //get root basic-block
 
        CurrentValue.push_back(vector<Value *>(Allocas.size()));
 
@@ -309,16 +309,13 @@ bool PromoteInstance::queuePhiNode(BasicBlock *bb, int i /*the alloca*/)
 
 
 namespace {
-  class PromotePass : public MethodPass {
-  public:
+  struct PromotePass : public MethodPass {
 
     // runOnMethod - To run this pass, first we calculate the alloca
     // instructions that are safe for promotion, then we promote each one.
     //
-    virtual bool runOnMethod(Method *M)
-    {
-      PromoteInstance inst(M, getAnalysis<DominanceFrontier>());
-      return (bool)inst;
+    virtual bool runOnMethod(Function *F) {
+      return (bool)PromoteInstance(F, getAnalysis<DominanceFrontier>());
     }
     
 
index da7b1f609aea8f8ab610cff4237b219f4ad2cf7c..9a3b52c49cfa8240d0e17e2337af4787685b2328 100644 (file)
@@ -1,4 +1,4 @@
-//===- SimplifyCFG.cpp - CFG Simplification Routines -------------*- C++ -*--=//
+//===- UnifyFunctionExitNodes.cpp - Make all functions have a single exit -===//
 //
 // This file provides several routines that are useful for simplifying CFGs in
 // various ways...
@@ -7,7 +7,7 @@
 
 #include "llvm/Transforms/UnifyMethodExitNodes.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iPHINode.h"
 #include "llvm/Type.h"
@@ -20,14 +20,14 @@ AnalysisID UnifyMethodExitNodes::ID(AnalysisID::create<UnifyMethodExitNodes>());
 // BasicBlock, and converting all returns to unconditional branches to this
 // new basic block.  The singular exit node is returned.
 //
-// If there are no return stmts in the Method, a null pointer is returned.
+// If there are no return stmts in the Function, a null pointer is returned.
 //
-bool UnifyMethodExitNodes::doit(Method *M, BasicBlock *&ExitNode) {
-  // Loop over all of the blocks in a method, tracking all of the blocks that
+bool UnifyMethodExitNodes::doit(Function *M, BasicBlock *&ExitNode) {
+  // Loop over all of the blocks in a function, tracking all of the blocks that
   // return.
   //
   vector<BasicBlock*> ReturningBlocks;
-  for(Method::iterator I = M->begin(), E = M->end(); I != E; ++I)
+  for(Function::iterator I = M->begin(), E = M->end(); I != E; ++I)
     if (isa<ReturnInst>((*I)->getTerminator()))
       ReturningBlocks.push_back(*I);
 
@@ -39,14 +39,14 @@ bool UnifyMethodExitNodes::doit(Method *M, BasicBlock *&ExitNode) {
     return false;
   }
 
-  // Otherwise, we need to insert a new basic block into the method, add a PHI
+  // Otherwise, we need to insert a new basic block into the function, add a PHI
   // node (if the function returns a value), and convert all of the return 
   // instructions into unconditional branches.
   //
   BasicBlock *NewRetBlock = new BasicBlock("UnifiedExitNode", M);
 
   if (M->getReturnType() != Type::VoidTy) {
-    // If the method doesn't return void... add a PHI node to the block...
+    // If the function doesn't return void... add a PHI node to the block...
     PHINode *PN = new PHINode(M->getReturnType());
     NewRetBlock->getInstList().push_back(PN);
 
index 48cc86fcaf542dc3612e1f1d6046112ad84ce7a2..71ee3d74cf99d17e483b2621f3c4bc3731e9db54 100644 (file)
@@ -1,12 +1,13 @@
 //===- DominatorSet.cpp - Dominator Set Calculation --------------*- C++ -*--=//
 //
-// This file provides a simple class to calculate the dominator set of a method.
+// This file provides a simple class to calculate the dominator set of a
+// function.
 //
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/Transforms/UnifyMethodExitNodes.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Support/CFG.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/STLExtras.h"
@@ -21,31 +22,31 @@ using std::set;
 AnalysisID cfg::DominatorSet::ID(AnalysisID::create<cfg::DominatorSet>());
 AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create<cfg::DominatorSet>());
 
-bool cfg::DominatorSet::runOnMethod(Method *M) {
+bool cfg::DominatorSet::runOnMethod(Function *F) {
   Doms.clear();   // Reset from the last time we were run...
 
   if (isPostDominator())
-    calcPostDominatorSet(M);
+    calcPostDominatorSet(F);
   else
-    calcForwardDominatorSet(M);
+    calcForwardDominatorSet(F);
   return false;
 }
 
 
 // calcForwardDominatorSet - This method calculates the forward dominator sets
-// for the specified method.
+// for the specified function.
 //
-void cfg::DominatorSet::calcForwardDominatorSet(Method *M) {
+void cfg::DominatorSet::calcForwardDominatorSet(Function *M) {
   Root = M->getEntryNode();
   assert(pred_begin(Root) == pred_end(Root) &&
-        "Root node has predecessors in method!");
+        "Root node has predecessors in function!");
 
   bool Changed;
   do {
     Changed = false;
 
     DomSetType WorkingSet;
-    df_iterator<Method*> It = df_begin(M), End = df_end(M);
+    df_iterator<Function*> It = df_begin(M), End = df_end(M);
     for ( ; It != End; ++It) {
       const BasicBlock *BB = *It;
       pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
@@ -75,19 +76,19 @@ void cfg::DominatorSet::calcForwardDominatorSet(Method *M) {
   } while (Changed);
 }
 
-// Postdominator set constructor.  This ctor converts the specified method to
+// Postdominator set constructor.  This ctor converts the specified function to
 // only have a single exit node (return stmt), then calculates the post
-// dominance sets for the method.
+// dominance sets for the function.
 //
-void cfg::DominatorSet::calcPostDominatorSet(Method *M) {
+void cfg::DominatorSet::calcPostDominatorSet(Function *M) {
   // Since we require that the unify all exit nodes pass has been run, we know
-  // that there can be at most one return instruction in the method left.
+  // that there can be at most one return instruction in the function left.
   // Get it.
   //
   Root = getAnalysis<UnifyMethodExitNodes>().getExitNode();
 
-  if (Root == 0) {  // No exit node for the method?  Postdomsets are all empty
-    for (Method::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
+  if (Root == 0) {  // No exit node for the function?  Postdomsets are all empty
+    for (Function::const_iterator MI = M->begin(), ME = M->end(); MI!=ME; ++MI)
       Doms[*MI] = DomSetType();
     return;
   }
@@ -207,12 +208,12 @@ void cfg::DominatorTree::reset() {
 // Given immediate dominators, we can also calculate the dominator tree
 cfg::DominatorTree::DominatorTree(const ImmediateDominators &IDoms) 
   : DominatorBase(IDoms.getRoot()) {
-  const Method *M = Root->getParent();
+  const Function *M = Root->getParent();
 
   Nodes[Root] = new Node(Root, 0);   // Add a node for the root...
 
   // Iterate over all nodes in depth first order...
-  for (df_iterator<const Method*> I = df_begin(M), E = df_end(M); I != E; ++I) {
+  for (df_iterator<const Function*> I = df_begin(M), E = df_end(M); I!=E; ++I) {
     const BasicBlock *BB = *I, *IDom = IDoms[*I];
 
     if (IDom != 0) {   // Ignore the root node and other nasty nodes
@@ -249,7 +250,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
       // current node, and it is our idom!  We know that we have already added
       // a DominatorTree node for our idom, because the idom must be a
       // predecessor in the depth first order that we are iterating through the
-      // method.
+      // function.
       //
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
@@ -290,7 +291,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) {
       // chain than the current node, and it is our idom!  We know that we have
       // already added a DominatorTree node for our idom, because the idom must
       // be a predecessor in the depth first order that we are iterating through
-      // the method.
+      // the function.
       //
       DominatorSet::DomSetType::const_iterator I = Dominators.begin();
       DominatorSet::DomSetType::const_iterator End = Dominators.end();
index e729a65a3864ce9c9b3c1d7a057be8229834391a..9cb493aa21e3a1d0ae05a12bba31788c223b8d34 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "llvm/Instruction.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/SymbolTable.h"
 
 Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) 
@@ -17,7 +17,7 @@ Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name)
 
 // Specialize setName to take care of symbol table majik
 void Instruction::setName(const std::string &name, SymbolTable *ST) {
-  BasicBlock *P = 0; Method *PP = 0;
+  BasicBlock *P = 0; Function *PP = 0;
   assert((ST == 0 || !getParent() || !getParent()->getParent() || 
          ST == getParent()->getParent()->getSymbolTable()) &&
         "Invalid symtab argument!");
index 43a4591cb8ad567fd54ffb3716e88b1585266ad0..9c59f1204766242f959780d7ac33280a8d959dec 100644 (file)
@@ -11,7 +11,7 @@
 
 #include "llvm/Analysis/SlotCalculator.h"
 #include "llvm/Analysis/ConstantsScanner.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Module.h"
 #include "llvm/BasicBlock.h"
@@ -45,7 +45,7 @@ SlotCalculator::SlotCalculator(const Module *M, bool IgnoreNamed) {
   processModule();
 }
 
-SlotCalculator::SlotCalculator(const Method *M, bool IgnoreNamed) {
+SlotCalculator::SlotCalculator(const Function *M, bool IgnoreNamed) {
   IgnoreNamedNodes = IgnoreNamed;
   TheModule = M ? M->getParent() : 0;
 
@@ -64,7 +64,7 @@ SlotCalculator::SlotCalculator(const Method *M, bool IgnoreNamed) {
 }
 
 
-// processModule - Process all of the module level method declarations and
+// processModule - Process all of the module level function declarations and
 // types that are available.
 //
 void SlotCalculator::processModule() {
@@ -83,10 +83,10 @@ void SlotCalculator::processModule() {
   for_each(TheModule->gbegin(), TheModule->gend(),
           bind_obj(this, &SlotCalculator::insertValue));
 
-  // Scavenge the types out of the methods, then add the methods themselves to
-  // the value table...
+  // Scavenge the types out of the functions, then add the functions themselves
+  // to the value table...
   //
-  for_each(TheModule->begin(), TheModule->end(),  // Insert methods...
+  for_each(TheModule->begin(), TheModule->end(),  // Insert functions...
           bind_obj(this, &SlotCalculator::insertValue));
 
   // Insert constants that are named at module level into the slot pool so that
@@ -119,28 +119,28 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
 }
 
 
-void SlotCalculator::incorporateMethod(const Method *M) {
+void SlotCalculator::incorporateMethod(const Function *M) {
   assert(ModuleLevel.size() == 0 && "Module already incorporated!");
 
-  SC_DEBUG("begin processMethod!\n");
+  SC_DEBUG("begin processFunction!\n");
 
-  // Save the Table state before we process the method...
+  // Save the Table state before we process the function...
   for (unsigned i = 0; i < Table.size(); ++i)
     ModuleLevel.push_back(Table[i].size());
 
-  SC_DEBUG("Inserting method arguments\n");
+  SC_DEBUG("Inserting function arguments\n");
 
-  // Iterate over method arguments, adding them to the value table...
+  // Iterate over function arguments, adding them to the value table...
   for_each(M->getArgumentList().begin(), M->getArgumentList().end(),
           bind_obj(this, &SlotCalculator::insertValue));
 
-  // Iterate over all of the instructions in the method, looking for constant
+  // Iterate over all of the instructions in the function, looking for constant
   // values that are referenced.  Add these to the value pools before any
   // nonconstant values.  This will be turned into the constant pool for the
   // bytecode writer.
   //
   if (!IgnoreNamedNodes) {                // Assembly writer does not need this!
-    SC_DEBUG("Inserting method constants:\n";
+    SC_DEBUG("Inserting function constants:\n";
             for (constant_iterator I = constant_begin(M), E = constant_end(M);
                  I != E; ++I) {
               cerr << "  " << I->getType()->getDescription() 
@@ -148,7 +148,7 @@ void SlotCalculator::incorporateMethod(const Method *M) {
             });
 
     // Emit all of the constants that are being used by the instructions in the
-    // method...
+    // function...
     for_each(constant_begin(M), constant_end(M),
             bind_obj(this, &SlotCalculator::insertValue));
 
@@ -179,18 +179,18 @@ void SlotCalculator::incorporateMethod(const Method *M) {
     processSymbolTable(M->getSymbolTable());
   }
 
-  SC_DEBUG("end processMethod!\n");
+  SC_DEBUG("end processFunction!\n");
 }
 
 void SlotCalculator::purgeMethod() {
   assert(ModuleLevel.size() != 0 && "Module not incorporated!");
   unsigned NumModuleTypes = ModuleLevel.size();
 
-  SC_DEBUG("begin purgeMethod!\n");
+  SC_DEBUG("begin purgeFunction!\n");
 
   // First, remove values from existing type planes
   for (unsigned i = 0; i < NumModuleTypes; ++i) {
-    unsigned ModuleSize = ModuleLevel[i];  // Size of plane before method came
+    unsigned ModuleSize = ModuleLevel[i];  // Size of plane before function came
     TypePlane &CurPlane = Table[i];
     //SC_DEBUG("Processing Plane " <<i<< " of size " << CurPlane.size() <<endl);
             
@@ -207,7 +207,7 @@ void SlotCalculator::purgeMethod() {
   // We don't need this state anymore, free it up.
   ModuleLevel.clear();
 
-  // Next, remove any type planes defined by the method...
+  // Next, remove any type planes defined by the function...
   while (NumModuleTypes != Table.size()) {
     TypePlane &Plane = Table.back();
     SC_DEBUG("Removing Plane " << (Table.size()-1) << " of size "
@@ -220,7 +220,7 @@ void SlotCalculator::purgeMethod() {
     Table.pop_back();                      // Nuke the plane, we don't like it.
   }
 
-  SC_DEBUG("end purgeMethod!\n");
+  SC_DEBUG("end purgeFunction!\n");
 }
 
 int SlotCalculator::getValSlot(const Value *D) const {
@@ -337,9 +337,9 @@ int SlotCalculator::doInsertVal(const Value *D) {
 
   SC_DEBUG("  Inserting value [" << Ty << "] = " << D << " slot=" << 
           DestSlot << " [");
-  // G = Global, C = Constant, T = Type, M = Method, o = other
+  // G = Global, C = Constant, T = Type, F = Function, o = other
   SC_DEBUG((isa<GlobalVariable>(D) ? "G" : (isa<Constant>(D) ? "C" : 
-           (isa<Type>(D) ? "T" : (isa<Method>(D) ? "M" : "o")))));
+           (isa<Type>(D) ? "T" : (isa<Function>(D) ? "F" : "o")))));
   SC_DEBUG("]\n");
   return (int)DestSlot;
 }
index d757ea2349a2a9c24f8aac0428d4f207f4bef4fe..4f1a1c95f4df265dd9f776afcbb678e4b2726adf 100644 (file)
@@ -7,22 +7,22 @@
 #include "llvm/iOther.h"
 #include "llvm/iTerminators.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 
 //===----------------------------------------------------------------------===//
 //                        CallInst Implementation
 //===----------------------------------------------------------------------===//
 
-CallInst::CallInst(Value *Meth, const std::vector<Value*> &params, 
+CallInst::CallInst(Value *Func, const std::vector<Value*> &params, 
                    const std::string &Name) 
-  : Instruction(cast<FunctionType>(cast<PointerType>(Meth->getType())
+  : Instruction(cast<FunctionType>(cast<PointerType>(Func->getType())
                                 ->getElementType())->getReturnType(),
                Instruction::Call, Name) {
   Operands.reserve(1+params.size());
-  Operands.push_back(Use(Meth, this));
+  Operands.push_back(Use(Func, this));
 
   const FunctionType *MTy = 
-    cast<FunctionType>(cast<PointerType>(Meth->getType())->getElementType());
+    cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
 
   const FunctionType::ParamTypes &PL = MTy->getParamTypes();
   assert((params.size() == PL.size()) || 
@@ -43,19 +43,19 @@ CallInst::CallInst(const CallInst &CI)
 //                        InvokeInst Implementation
 //===----------------------------------------------------------------------===//
 
-InvokeInst::InvokeInst(Value *Meth, BasicBlock *IfNormal, \
+InvokeInst::InvokeInst(Value *Func, BasicBlock *IfNormal, \
                       BasicBlock *IfException,
                        const std::vector<Value*> &params,
                       const std::string &Name)
-  : TerminatorInst(cast<FunctionType>(cast<PointerType>(Meth->getType())
+  : TerminatorInst(cast<FunctionType>(cast<PointerType>(Func->getType())
                                    ->getElementType())->getReturnType(),
                   Instruction::Invoke, Name) {
   Operands.reserve(3+params.size());
-  Operands.push_back(Use(Meth, this));
+  Operands.push_back(Use(Func, this));
   Operands.push_back(Use(IfNormal, this));
   Operands.push_back(Use(IfException, this));
   const FunctionType *MTy = 
-    cast<FunctionType>(cast<PointerType>(Meth->getType())->getElementType());
+    cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
   
   const FunctionType::ParamTypes &PL = MTy->getParamTypes();
   assert((params.size() == PL.size()) || 
index 48a600f14b9be26bb9a542e49bb945b381c510cc..0a6ecf81afa1dbb890e8229d3f3f63abd2f65f38 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "llvm/Instruction.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/iPHINode.h"
 #include "llvm/PassManager.h"
 #include "llvm/Bytecode/Reader.h"
@@ -47,7 +47,7 @@ static void printPass(PassType &P, ostream &O, Module *M) {
 }
 
 template<class PassType>
-static void printPass(PassType &P, ostream &O, Method *M) {
+static void printPass(PassType &P, ostream &O, Function *F) {
   O << P;
 }
 
@@ -102,9 +102,9 @@ class PassPrinter<MethodPass, PassName> : public MethodPass {
 public:
   PassPrinter(const string &M, AnalysisID id) : Message(M), ID(id) {}
   
-  virtual bool runOnMethod(Method *M) {
-    std::cout << Message << " on method '" << M->getName() << "'\n";
-    printPass(getAnalysis<PassName>(ID), std::cout, M);
+  virtual bool runOnMethod(Function *F) {
+    std::cout << Message << " on method '" << F->getName() << "'\n";
+    printPass(getAnalysis<PassName>(ID), std::cout, F);
     return false;
   }
 
@@ -128,7 +128,7 @@ Pass *New(const string &Message) {
 
 
 
-Pass *NewPrintMethod(const string &Message) {
+Pass *NewPrintFunction(const string &Message) {
   return new PrintMethodPass(Message, &std::cout);
 }
 Pass *NewPrintModule(const string &Message) {
@@ -136,15 +136,15 @@ Pass *NewPrintModule(const string &Message) {
 }
 
 struct InstForest : public MethodPass {
-  void doit(Method *M) {
-    std::cout << analysis::InstForest<char>(M);
+  void doit(Function *F) {
+    std::cout << analysis::InstForest<char>(F);
   }
 };
 
 struct IndVars : public MethodPass {
-  void doit(Method *M) {
+  void doit(Function *F) {
     cfg::LoopInfo &LI = getAnalysis<cfg::LoopInfo>();
-    for (inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I)
+    for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
       if (PHINode *PN = dyn_cast<PHINode>(*I)) {
         InductionVariable IV(PN, &LI);
         if (IV.InductionType != InductionVariable::Unknown)
@@ -159,9 +159,9 @@ struct IndVars : public MethodPass {
 };
 
 struct Exprs : public MethodPass {
-  static void doit(Method *M) {
-    std::cout << "Classified expressions for: " << M->getName() << "\n";
-    for (inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
+  static void doit(Function *F) {
+    std::cout << "Classified expressions for: " << F->getName() << "\n";
+    for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) {
       std::cout << *I;
       
       if ((*I)->getType() == Type::VoidTy) continue;
@@ -195,10 +195,10 @@ class PrinterPass : public TraitClass {
 public:
   PrinterPass(const string &M) : Message(M) {}
   
-  virtual bool runOnMethod(Method *M) {
-    std::cout << Message << " on method '" << M->getName() << "'\n";
+  virtual bool runOnMethod(Function *F) {
+    std::cout << Message << " on method '" << F->getName() << "'\n";
 
-    TraitClass::doit(M);
+    TraitClass::doit(F);
     return false;
   }
 };
@@ -226,7 +226,7 @@ cl::String InputFilename ("", "Load <arg> file to analyze", cl::NoFlags, "-");
 cl::Flag   Quiet         ("q", "Don't print analysis pass names");
 cl::Alias  QuietA        ("quiet", "Alias for -q", cl::NoFlags, Quiet);
 cl::EnumList<enum Ans> AnalysesList(cl::NoFlags,
-  clEnumVal(print          , "Print each method"),
+  clEnumVal(print          , "Print each function"),
   clEnumVal(intervals      , "Print Interval Partitions"),
   clEnumVal(exprs          , "Classify Expressions"),
   clEnumVal(instforest     , "Print Instruction Forest"),
@@ -256,7 +256,7 @@ struct {
   Pass *(*PassConstructor)(const string &Message);
 } AnTable[] = {
   // Global analyses
-  { print             , NewPrintMethod                          },
+  { print             , NewPrintFunction                        },
   { intervals         , New<MethodPass, cfg::IntervalPartition> },
   { loops             , New<MethodPass, cfg::LoopInfo>          },
   { instforest        , Create<PrinterPass<InstForest> >        },
index 61cea325e251c958d900f1409b0d89ee98c6df11..9aa15dc827156c66e62df757e201d572c44d67da 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/Module.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Bytecode/Reader.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Support/CFG.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
@@ -30,7 +30,7 @@ using std::cerr;
 
 // OutputMode - The different orderings to print basic blocks in...
 enum OutputMode {
-  Default = 0,           // Method Order (list order)
+  Default = 0,           // Function Order (list order)
   dfo,                   // Depth First ordering
   rdfo,                  // Reverse Depth First ordering
   po,                    // Post Order
@@ -52,8 +52,8 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
   std::ostream *Out = &std::cout;  // Default to printing to stdout...
 
-  Module *C = ParseBytecodeFile(InputFilename);
-  if (C == 0) {
+  Module *M = ParseBytecodeFile(InputFilename);
+  if (M == 0) {
     cerr << "bytecode didn't read correctly.\n";
     return 1;
   }
@@ -100,32 +100,32 @@ int main(int argc, char **argv) {
   // what the writer library is supposed to do...
   //
   if (WriteMode == Default) {
-    (*Out) << C;           // Print out in list order
+    (*Out) << M;           // Print out in list order
   } else {
     // TODO: This does not print anything other than the basic blocks in the
-    // methods... more should definately be printed.  It should be valid output
-    // consumable by the assembler.
+    // functions... more should definately be printed.  It should be valid
+    // output consumable by the assembler.
     //
-    for (Module::iterator I = C->begin(), End = C->end(); I != End; ++I) {
-      Method *M = *I;
-      (*Out) << "-------------- Method: " << M->getName() << " -------------\n";
+    for (Module::iterator I = M->begin(), End = M->end(); I != End; ++I) {
+      Function *F = *I;
+      (*Out) << "-------------- Method: " << F->getName() << " -------------\n";
 
       switch (WriteMode) {
       case dfo:                   // Depth First ordering
-       copy(df_begin(M), df_end(M),
+       copy(df_begin(F), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rdfo:            // Reverse Depth First ordering
-       copy(df_begin(M, true), df_end(M),
+       copy(df_begin(F, true), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case po:                    // Post Order
-       copy(po_begin(M), po_end(M),
+       copy(po_begin(F), po_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rpo: {           // Reverse Post Order
 #if 0  // FIXME, GCC 3.0.4 bug
-       ReversePostOrderTraversal<Method*> RPOT(M());
+       ReversePostOrderTraversal<Function*> RPOT(F);
        copy(RPOT.begin(), RPOT.end(),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
 #endif
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
       }
     }
   }
-  delete C;
+  delete M;
 
   if (Out != &std::cout) delete Out;
   return 0;
index cb77bb03c064a34d80188af8c163bc58540ca149..d00687fcec6ffc8a96fbbb9e1aa81c4e60fc0f33 100644 (file)
@@ -18,7 +18,6 @@
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
 #include "Support/CommandLine.h"
 #include <fstream>
 #include <memory>
@@ -116,6 +115,15 @@ int main(int argc, char **argv) {
     }
   }
 
+  // Now that composite has been compiled, scan through the module, looking for
+  // a main function.  If main is defined, mark all other functions internal.
+  //
+
+  // Next run globaldce...
+
+  // next ?
+
+
   std::ofstream Out((OutputFilename+".bc").c_str());
   if (!Out.good()) {
     cerr << "Error opening '" << OutputFilename << ".bc' for writing!\n";
index bdd04685ce3a7bdc24737f98a1c94e6ae9e2910f..ec77b42efff0999869c77836440c33fe7a135921 100644 (file)
@@ -14,7 +14,6 @@
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
 #include "Support/CommandLine.h"
 #include <fstream>
 #include <memory>
index 140151b69f658f156187afbc4eebd54c7038c7f9..819c80a27922a16f2e6bf35a938ab2da7dc28e2c 100644 (file)
@@ -15,7 +15,7 @@
 #include "llvm/Bytecode/WriteBytecodePass.h"
 #include "llvm/Transforms/ConstantMerge.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/PassManager.h"
 #include "Support/CommandLine.h"
 #include <memory>
@@ -29,13 +29,13 @@ static cl::Flag   Force         ("f", "Overwrite output files");
 static cl::Flag   DumpAsm       ("d", "Print bytecode before native code generation", cl::Hidden);
 
 enum TraceLevel {
-  TraceOff, TraceMethods, TraceBasicBlocks
+  TraceOff, TraceFunctions, TraceBasicBlocks
 };
 
 static cl::Enum<enum TraceLevel> TraceValues("trace", cl::NoFlags,
-  "Trace values through methods or basic blocks",
+  "Trace values through functions or basic blocks",
   clEnumValN(TraceOff        , "off",        "Disable trace code"),
-  clEnumValN(TraceMethods    , "method",     "Trace each method"),
+  clEnumValN(TraceFunctions  , "function",   "Trace each function"),
   clEnumValN(TraceBasicBlocks, "basicblock", "Trace each basic block"), 0);
 
 
@@ -83,10 +83,10 @@ int main(int argc, char **argv) {
   Passes.add(createHoistPHIConstantsPass());
 
   if (TraceValues != TraceOff) {   // If tracing enabled...
-    // Insert trace code in all methods in the module
+    // Insert trace code in all functions in the module
     if (TraceValues == TraceBasicBlocks)
       Passes.add(createTraceValuesPassForBasicBlocks());
-    else if (TraceValues == TraceMethods)
+    else if (TraceValues == TraceFunctions)
       Passes.add(createTraceValuesPassForMethod());
     else
       assert(0 && "Bad value for TraceValues!");
index 61cea325e251c958d900f1409b0d89ee98c6df11..9aa15dc827156c66e62df757e201d572c44d67da 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/Module.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Bytecode/Reader.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Support/CFG.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
@@ -30,7 +30,7 @@ using std::cerr;
 
 // OutputMode - The different orderings to print basic blocks in...
 enum OutputMode {
-  Default = 0,           // Method Order (list order)
+  Default = 0,           // Function Order (list order)
   dfo,                   // Depth First ordering
   rdfo,                  // Reverse Depth First ordering
   po,                    // Post Order
@@ -52,8 +52,8 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
   std::ostream *Out = &std::cout;  // Default to printing to stdout...
 
-  Module *C = ParseBytecodeFile(InputFilename);
-  if (C == 0) {
+  Module *M = ParseBytecodeFile(InputFilename);
+  if (M == 0) {
     cerr << "bytecode didn't read correctly.\n";
     return 1;
   }
@@ -100,32 +100,32 @@ int main(int argc, char **argv) {
   // what the writer library is supposed to do...
   //
   if (WriteMode == Default) {
-    (*Out) << C;           // Print out in list order
+    (*Out) << M;           // Print out in list order
   } else {
     // TODO: This does not print anything other than the basic blocks in the
-    // methods... more should definately be printed.  It should be valid output
-    // consumable by the assembler.
+    // functions... more should definately be printed.  It should be valid
+    // output consumable by the assembler.
     //
-    for (Module::iterator I = C->begin(), End = C->end(); I != End; ++I) {
-      Method *M = *I;
-      (*Out) << "-------------- Method: " << M->getName() << " -------------\n";
+    for (Module::iterator I = M->begin(), End = M->end(); I != End; ++I) {
+      Function *F = *I;
+      (*Out) << "-------------- Method: " << F->getName() << " -------------\n";
 
       switch (WriteMode) {
       case dfo:                   // Depth First ordering
-       copy(df_begin(M), df_end(M),
+       copy(df_begin(F), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rdfo:            // Reverse Depth First ordering
-       copy(df_begin(M, true), df_end(M),
+       copy(df_begin(F, true), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case po:                    // Post Order
-       copy(po_begin(M), po_end(M),
+       copy(po_begin(F), po_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rpo: {           // Reverse Post Order
 #if 0  // FIXME, GCC 3.0.4 bug
-       ReversePostOrderTraversal<Method*> RPOT(M());
+       ReversePostOrderTraversal<Function*> RPOT(F);
        copy(RPOT.begin(), RPOT.end(),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
 #endif
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
       }
     }
   }
-  delete C;
+  delete M;
 
   if (Out != &std::cout) delete Out;
   return 0;
index 61cea325e251c958d900f1409b0d89ee98c6df11..9aa15dc827156c66e62df757e201d572c44d67da 100644 (file)
@@ -19,7 +19,7 @@
 #include "llvm/Module.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Bytecode/Reader.h"
-#include "llvm/Method.h"
+#include "llvm/Function.h"
 #include "llvm/Support/CFG.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/PostOrderIterator.h"
@@ -30,7 +30,7 @@ using std::cerr;
 
 // OutputMode - The different orderings to print basic blocks in...
 enum OutputMode {
-  Default = 0,           // Method Order (list order)
+  Default = 0,           // Function Order (list order)
   dfo,                   // Depth First ordering
   rdfo,                  // Reverse Depth First ordering
   po,                    // Post Order
@@ -52,8 +52,8 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n");
   std::ostream *Out = &std::cout;  // Default to printing to stdout...
 
-  Module *C = ParseBytecodeFile(InputFilename);
-  if (C == 0) {
+  Module *M = ParseBytecodeFile(InputFilename);
+  if (M == 0) {
     cerr << "bytecode didn't read correctly.\n";
     return 1;
   }
@@ -100,32 +100,32 @@ int main(int argc, char **argv) {
   // what the writer library is supposed to do...
   //
   if (WriteMode == Default) {
-    (*Out) << C;           // Print out in list order
+    (*Out) << M;           // Print out in list order
   } else {
     // TODO: This does not print anything other than the basic blocks in the
-    // methods... more should definately be printed.  It should be valid output
-    // consumable by the assembler.
+    // functions... more should definately be printed.  It should be valid
+    // output consumable by the assembler.
     //
-    for (Module::iterator I = C->begin(), End = C->end(); I != End; ++I) {
-      Method *M = *I;
-      (*Out) << "-------------- Method: " << M->getName() << " -------------\n";
+    for (Module::iterator I = M->begin(), End = M->end(); I != End; ++I) {
+      Function *F = *I;
+      (*Out) << "-------------- Method: " << F->getName() << " -------------\n";
 
       switch (WriteMode) {
       case dfo:                   // Depth First ordering
-       copy(df_begin(M), df_end(M),
+       copy(df_begin(F), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rdfo:            // Reverse Depth First ordering
-       copy(df_begin(M, true), df_end(M),
+       copy(df_begin(F, true), df_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case po:                    // Post Order
-       copy(po_begin(M), po_end(M),
+       copy(po_begin(F), po_end(F),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
        break;
       case rpo: {           // Reverse Post Order
 #if 0  // FIXME, GCC 3.0.4 bug
-       ReversePostOrderTraversal<Method*> RPOT(M());
+       ReversePostOrderTraversal<Function*> RPOT(F);
        copy(RPOT.begin(), RPOT.end(),
             std::ostream_iterator<BasicBlock*>(*Out, "\n"));
 #endif
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
       }
     }
   }
-  delete C;
+  delete M;
 
   if (Out != &std::cout) delete Out;
   return 0;
index bdd04685ce3a7bdc24737f98a1c94e6ae9e2910f..ec77b42efff0999869c77836440c33fe7a135921 100644 (file)
@@ -14,7 +14,6 @@
 #include "llvm/Bytecode/Writer.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/Module.h"
-#include "llvm/Method.h"
 #include "Support/CommandLine.h"
 #include <fstream>
 #include <memory>