From: Chris Lattner Date: Sun, 7 Apr 2002 20:49:59 +0000 (+0000) Subject: Change references to the Method class to be references to the Function X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2fbfdcffd3e0cf41422aaa6c526c37cb02b81341;p=oota-llvm.git Change references to the Method class to be references to the Function 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 --- diff --git a/include/llvm/Analysis/IntervalIterator.h b/include/llvm/Analysis/IntervalIterator.h index 3c27f1ae8b9..55413d4ada4 100644 --- a/include/llvm/Analysis/IntervalIterator.h +++ b/include/llvm/Analysis/IntervalIterator.h @@ -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 @@ -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 method_interval_iterator; +typedef IntervalIterator function_interval_iterator; typedef IntervalIterator 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 diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index b6aa56e3851..db4c0c322e7 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -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 @@ -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 { @@ -167,9 +167,9 @@ template <> struct GraphTraits { } }; -// 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 > { @@ -201,34 +201,36 @@ template <> struct GraphTraits > { //===--------------------------------------------------------------------===// -// 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 : public GraphTraits { - static NodeType *getEntryNode(Method *M) { return M->front(); } +template <> struct GraphTraits : public GraphTraits { + static NodeType *getEntryNode(Function *F) { return F->getEntryNode(); } }; -template <> struct GraphTraits : +template <> struct GraphTraits : public GraphTraits { - 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 > : +template <> struct GraphTraits > : public GraphTraits > { - static NodeType *getEntryNode(Inverse G) { return G.Graph->front();} + static NodeType *getEntryNode(Inverse G) { + return G.Graph->front(); + } }; -template <> struct GraphTraits > : +template <> struct GraphTraits > : public GraphTraits > { - static NodeType *getEntryNode(Inverse G) { + static NodeType *getEntryNode(Inverse G) { return G.Graph->front(); } }; diff --git a/include/llvm/Support/InstIterator.h b/include/llvm/Support/InstIterator.h index 517e6d26a48..b2b1058056e 100644 --- a/include/llvm/Support/InstIterator.h +++ b/include/llvm/Support/InstIterator.h @@ -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, Method::iterator, - BasicBlock::iterator, Instruction*> inst_iterator; -typedef InstIterator, - Method::const_iterator, +typedef InstIterator, + Function::iterator, BasicBlock::iterator, + Instruction*> inst_iterator; +typedef InstIterator, + 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 diff --git a/include/llvm/Transforms/Scalar/DCE.h b/include/llvm/Transforms/Scalar/DCE.h index a8dcb591467..35b929d7e7b 100644 --- a/include/llvm/Transforms/Scalar/DCE.h +++ b/include/llvm/Transforms/Scalar/DCE.h @@ -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 diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 0179cbb74c8..d689d93cd44 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -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(); diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index e67fe322f71..5c961d2bebe 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -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) { diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index f524d016f16..197bed26d79 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -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 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); 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); diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 48cc86fcaf5..71ee3d74cf9 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -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()); AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create()); -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 It = df_begin(M), End = df_end(M); + df_iterator 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().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 I = df_begin(M), E = df_end(M); I != E; ++I) { + for (df_iterator 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(); diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index 0be903aad0a..c32c6b476ff 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -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!?!?"); diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 43a4591cb8a..9c59f120476 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -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 " <(D) ? "G" : (isa(D) ? "C" : - (isa(D) ? "T" : (isa(D) ? "M" : "o"))))); + (isa(D) ? "T" : (isa(D) ? "F" : "o"))))); SC_DEBUG("]\n"); return (int)DestSlot; } diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index e67ba93f20c..daf4a49bb83 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -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)); } diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index 3efc5274700..1eb507a695b 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -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 @@ -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& 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 } diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index ff43f04a5f9..24efdf1456c 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -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& 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(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); } diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index ef27dbae71c..bb52ef298e5 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -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 @@ -20,57 +20,55 @@ const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits::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(*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"; } diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp index 32951769e00..fb29af2bf19 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp @@ -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 using std::cerr; -LiveRangeInfo::LiveRangeInfo(const Method *M, const TargetMachine &tm, +LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, std::vector &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(); diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 49667e00795..c9d775e2849 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -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 #include @@ -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(), + PhyRegAlloc PRA(F, Target, &getAnalysis(), &getAnalysis()); 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); diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 2260625b66b..484dbe2ee6c 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -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((Value*)O); - if (isa(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(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(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(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 &ArgVals) { +void Interpreter::callMethod(Function *M, const vector &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 &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 &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 &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(PickedVal)) { - CW << M; // Print the method + if (const Function *F = dyn_cast(PickedVal)) { + CW << F; // Print the function } else if (const Type *Ty = dyn_cast(PickedVal)) { CW << "type %" << Name << " = " << Ty->getDescription() << "\n"; } else if (const BasicBlock *BB = dyn_cast(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] << "="; diff --git a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h index 537d18c35a9..03abd20bb45 100644 --- a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h +++ b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h @@ -11,18 +11,18 @@ // 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 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((Value*)O)); // Simply invoke the ctor + return new MethodInfo(cast((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")); diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index c8aa46a186e..8f486e84ceb 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -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 &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::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(M->getFunctionType()),ArgVals); + GenericValue Result = Fn(const_cast(M->getFunctionType()), + ArgVals); return Result; } diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index 8576f9ce225..e7c7942b0c9 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -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 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 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 ECStack; public: @@ -135,7 +135,7 @@ public: void printStackTrace(); // Do the 'backtrace' command // Code execution methods... - void callMethod(Method *Meth, const std::vector &ArgVals); + void callMethod(Function *F, const std::vector &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 &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 LookupMatchingNames(const std::string &Name); diff --git a/lib/ExecutionEngine/Interpreter/Support.cpp b/lib/ExecutionEngine/Interpreter/Support.cpp index ca89ae33332..cac3b74c82c 100644 --- a/lib/ExecutionEngine/Interpreter/Support.cpp +++ b/lib/ExecutionEngine/Interpreter/Support.cpp @@ -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 Interpreter::LookupMatchingNames(const std::string &Name) { std::vector Results; - Method *CurMeth = getCurrentMethod(); + Function *CurMeth = getCurrentMethod(); if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results); if (CurMod ) ::LookupMatchingNames(Name, *CurMod , Results); diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index 99ee6ecaf71..b35463fc0b1 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -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 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(Options[i])) { Options.erase(Options.begin()+i); --i; @@ -263,7 +263,7 @@ bool Interpreter::callMainMethod(const string &Name, const std::vector &InputArgv) { std::vector 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(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() { diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index e67ba93f20c..daf4a49bb83 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -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)); } diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index 3efc5274700..1eb507a695b 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -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 @@ -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& 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 } diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index ff43f04a5f9..24efdf1456c 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -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& 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(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); } diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index 32951769e00..fb29af2bf19 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -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 using std::cerr; -LiveRangeInfo::LiveRangeInfo(const Method *M, const TargetMachine &tm, +LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, std::vector &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(); diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 49667e00795..c9d775e2849 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -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 #include @@ -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(), + PhyRegAlloc PRA(F, Target, &getAnalysis(), &getAnalysis()); 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); diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 91570444830..de4cb82b5dc 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -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(V); - return bool(meth != NULL - && (meth->isExternal() || meth->getName() == "main")); + const Function *F = dyn_cast(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(Val)) toAsm << getID(BB); - else if (const Method *M = dyn_cast(Val)) + else if (const Function *M = dyn_cast(Val)) toAsm << getID(M); else if (const GlobalVariable *GV=dyn_cast(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 { diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index a44dc7fbaf5..aa618c9259a 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -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& minstrVec, - std::vector& tempVec) const + std::vector&minstrVec, + std::vector& 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(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(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& 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& 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]. diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 7b6e597e4dc..2094f6ec41c 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -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 @@ -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 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& 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& 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 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()) diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index 3eac9c0d2a2..09b44f5f2e5 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -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 @@ -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 diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 790f68f7a37..b91a74e1e83 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -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(Ty); if (PTy == 0) return false; // Can't convert to a non-pointer type... FunctionType *MTy = dyn_cast(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 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(NewVal->getType()); FunctionType *NewTy = cast(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); diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index f20de1cfc21..26cf5ca04fd 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -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 #include @@ -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 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); } }; } diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index d78d185e8af..ef51105a474 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -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); } }; diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index ea23dbedda1..ae9bd392707 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -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 -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 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 MethodsToDelete; // Track unused methods + std::vector 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::iterator I = MethodsToDelete.begin(), - E = MethodsToDelete.end(); I != E; ++I) + for (std::vector::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()); + return RemoveUnreachableFunctions(M, getAnalysis()); } // getAnalysisUsageInfo - This function works on the call graph of a module. diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 51cde2e799f..d720c3c2cc7 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -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(*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(*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 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(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(*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(); } diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index 1be6458fea2..aa2cfdd2189 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -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 &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().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 } diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index de647935666..aecf78dc648 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -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); } }; } diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 624e6da39da..8818b5d9673 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -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; } diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index 09bfd5cf340..3a76d6a9577 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -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); } }; } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 1b0196e3e87..9bd95df5089 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -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 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); } }; } diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 8502082a15d..a026fd673a1 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -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 methods -// in a module, and all module level symbols. (method names, etc...) +// doStripGlobalSymbols - Remove all symbolic information from all functions +// 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); } }; diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 796cdc7cb4a..a75aa57bccd 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -6,7 +6,6 @@ //===----------------------------------------------------------------------===// #include "TransformInternals.h" -#include "llvm/Method.h" #include "llvm/Type.h" #include "llvm/ConstantVals.h" #include "llvm/Analysis/Expressions.h" diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index f94632e3df9..79c03864d86 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -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(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()); - return (bool)inst; + virtual bool runOnMethod(Function *F) { + return (bool)PromoteInstance(F, getAnalysis()); } diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index da7b1f609ae..9a3b52c49cf 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -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()); // 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 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((*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); diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 48cc86fcaf5..71ee3d74cf9 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -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()); AnalysisID cfg::DominatorSet::PostDomID(AnalysisID::create()); -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 It = df_begin(M), End = df_end(M); + df_iterator 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().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 I = df_begin(M), E = df_end(M); I != E; ++I) { + for (df_iterator 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(); diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index e729a65a386..9cb493aa21e 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -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!"); diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index 43a4591cb8a..9c59f120476 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -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 " <(D) ? "G" : (isa(D) ? "C" : - (isa(D) ? "T" : (isa(D) ? "M" : "o"))))); + (isa(D) ? "T" : (isa(D) ? "F" : "o"))))); SC_DEBUG("]\n"); return (int)DestSlot; } diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index d757ea2349a..4f1a1c95f4d 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -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 ¶ms, +CallInst::CallInst(Value *Func, const std::vector ¶ms, const std::string &Name) - : Instruction(cast(cast(Meth->getType()) + : Instruction(cast(cast(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(cast(Meth->getType())->getElementType()); + cast(cast(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 ¶ms, const std::string &Name) - : TerminatorInst(cast(cast(Meth->getType()) + : TerminatorInst(cast(cast(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(cast(Meth->getType())->getElementType()); + cast(cast(Func->getType())->getElementType()); const FunctionType::ParamTypes &PL = MTy->getParamTypes(); assert((params.size() == PL.size()) || diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 48a600f14b9..0a6ecf81afa 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -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 -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 : 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(ID), std::cout, M); + virtual bool runOnMethod(Function *F) { + std::cout << Message << " on method '" << F->getName() << "'\n"; + printPass(getAnalysis(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(M); + void doit(Function *F) { + std::cout << analysis::InstForest(F); } }; struct IndVars : public MethodPass { - void doit(Method *M) { + void doit(Function *F) { cfg::LoopInfo &LI = getAnalysis(); - 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(*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 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 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 }, { loops , New }, { instforest , Create > }, diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 61cea325e25..9aa15dc8271 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -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(*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(*Out, "\n")); break; case po: // Post Order - copy(po_begin(M), po_end(M), + copy(po_begin(F), po_end(F), std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order #if 0 // FIXME, GCC 3.0.4 bug - ReversePostOrderTraversal RPOT(M()); + ReversePostOrderTraversal RPOT(F); copy(RPOT.begin(), RPOT.end(), std::ostream_iterator(*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; diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index cb77bb03c06..d00687fcec6 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -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 #include @@ -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"; diff --git a/tools/link/link.cpp b/tools/link/link.cpp index bdd04685ce3..ec77b42efff 100644 --- a/tools/link/link.cpp +++ b/tools/link/link.cpp @@ -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 #include diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 140151b69f6..819c80a2792 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -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 @@ -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 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!"); diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index 61cea325e25..9aa15dc8271 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -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(*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(*Out, "\n")); break; case po: // Post Order - copy(po_begin(M), po_end(M), + copy(po_begin(F), po_end(F), std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order #if 0 // FIXME, GCC 3.0.4 bug - ReversePostOrderTraversal RPOT(M()); + ReversePostOrderTraversal RPOT(F); copy(RPOT.begin(), RPOT.end(), std::ostream_iterator(*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; diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 61cea325e25..9aa15dc8271 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -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(*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(*Out, "\n")); break; case po: // Post Order - copy(po_begin(M), po_end(M), + copy(po_begin(F), po_end(F), std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order #if 0 // FIXME, GCC 3.0.4 bug - ReversePostOrderTraversal RPOT(M()); + ReversePostOrderTraversal RPOT(F); copy(RPOT.begin(), RPOT.end(), std::ostream_iterator(*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; diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index bdd04685ce3..ec77b42efff 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -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 #include