llvm.org GIT mirror llvm / e7506a3
Rename Method to Function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1957 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 18 years ago
39 changed file(s) with 164 addition(s) and 166 deletion(s). Raw diff Collapse all Expand all
4242
4343 #include "Support/GraphTraits.h"
4444 #include "llvm/Pass.h"
45 class Method;
45 class Function;
4646 class Module;
4747 class CallGraphNode;
4848
5252 class CallGraph : public Pass {
5353 Module *Mod; // The module this call graph represents
5454
55 typedef std::mapMethod *, CallGraphNode *> MethodMapTy;
55 typedef std::mapFunction *, CallGraphNode *> MethodMapTy;
5656 MethodMapTy MethodMap; // Map from a method to its node
5757
5858 // Root is root of the call graph, or the external node if a 'main' function
7676
7777
7878 // Subscripting operators, return the call graph node for the provided method
79 inline const CallGraphNode *operator[](const Method *M) const {
80 const_iterator I = MethodMap.find(M);
79 inline const CallGraphNode *operator[](const Function *F) const {
80 const_iterator I = MethodMap.find(F);
8181 assert(I != MethodMap.end() && "Method not in callgraph!");
8282 return I->second;
8383 }
84 inline CallGraphNode *operator[](const Method *M) {
85 const_iterator I = MethodMap.find(M);
84 inline CallGraphNode *operator[](const Function *F) {
85 const_iterator I = MethodMap.find(F);
8686 assert(I != MethodMap.end() && "Method not in callgraph!");
8787 return I->second;
8888 }
9191 // Methods to keep a call graph up to date with a method that has been
9292 // modified
9393 //
94 void addMethodToModule(Method *Meth);
94 void addMethodToModule(Function *Meth);
9595
9696
9797 // removeMethodFromModule - Unlink the method from this module, returning it.
100100 // methods (ie, there are no edges in it's CGN). The easiest way to do this
101101 // is to dropAllReferences before calling this.
102102 //
103 Method *removeMethodFromModule(CallGraphNode *CGN);
104 Method *removeMethodFromModule(Method *Meth) {
103 Function *removeMethodFromModule(CallGraphNode *CGN);
104 Function *removeMethodFromModule(Function *Meth) {
105105 return removeMethodFromModule((*this)[Meth]);
106106 }
107107
134134 // Implementation of CallGraph construction
135135 //
136136
137 // getNodeFor - Return the node for the specified method or create one if it
137 // getNodeFor - Return the node for the specified function or create one if it
138138 // does not already exist.
139139 //
140 CallGraphNode *getNodeFor(Method *M);
141
142 // addToCallGraph - Add a method to the call graph, and link the node to all
140 CallGraphNode *getNodeFor(Function *F);
141
142 // addToCallGraph - Add a function to the call graph, and link the node to all
143143 // of the methods that it calls.
144144 //
145 void addToCallGraph(Method *M);
145 void addToCallGraph(Function *F);
146146
147147 // destroy - Release memory for the call graph
148148 void destroy();
153153 // CallGraphNode class definition
154154 //
155155 class CallGraphNode {
156 Method *Meth;
156 Function *Meth;
157157 std::vector CalledMethods;
158158
159159 CallGraphNode(const CallGraphNode &); // Do not implement
166166 typedef std::vector::const_iterator const_iterator;
167167
168168 // getMethod - Return the method that this call graph node represents...
169 Method *getMethod() const { return Meth; }
169 Function *getMethod() const { return Meth; }
170170
171171 inline iterator begin() { return CalledMethods.begin(); }
172172 inline iterator end() { return CalledMethods.end(); }
192192 friend class CallGraph;
193193
194194 // CallGraphNode ctor - Create a node for the specified method...
195 inline CallGraphNode(Method *M) : Meth(M) {}
195 inline CallGraphNode(Function *F) : Meth(F) {}
196196
197197 // addCalledMethod add a method to the list of methods called by this one
198198 void addCalledMethod(CallGraphNode *M) {
2727 }
2828
2929 public:
30 inline constant_iterator(const Method *M) : InstI(inst_begin(M)), OpIdx(0) {
30 inline constant_iterator(const Function *F) : InstI(inst_begin(F)), OpIdx(0) {
3131 // Advance to first constant... if we are not already at constant or end
32 if (InstI != inst_end(M) && // InstI is valid?
32 if (InstI != inst_end(F) && // InstI is valid?
3333 (InstI->getNumOperands() == 0 || !isAtConstant())) // Not at constant?
3434 operator++();
3535 }
3636
37 inline constant_iterator(const Method *M, bool) // end ctor
38 : InstI(inst_end(M)), OpIdx(0) {
37 inline constant_iterator(const Function *F, bool) // end ctor
38 : InstI(inst_end(F)), OpIdx(0) {
3939 }
4040
4141 inline bool operator==(const _Self& x) const { return OpIdx == x.OpIdx &&
7171 inline bool atEnd() const { return InstI.atEnd(); }
7272 };
7373
74 inline constant_iterator constant_begin(const Method *M) {
75 return constant_iterator(M);
74 inline constant_iterator constant_begin(const Function *F) {
75 return constant_iterator(F);
7676 }
7777
78 inline constant_iterator constant_end(const Method *M) {
79 return constant_iterator(M, true);
78 inline constant_iterator constant_end(const Function *F) {
79 return constant_iterator(F, true);
8080 }
8181
8282 #endif
5454 private:
5555 DomSetMapType Doms;
5656
57 void calcForwardDominatorSet(Method *M);
58 void calcPostDominatorSet(Method *M);
57 void calcForwardDominatorSet(Function *F);
58 void calcPostDominatorSet(Function *F);
5959 public:
6060 // DominatorSet ctor - Build either the dominator set or the post-dominator
6161 // set for a method...
6565
6666 DominatorSet(AnalysisID id) : DominatorBase(id == PostDomID) {}
6767
68 virtual bool runOnMethod(Method *M);
68 virtual bool runOnMethod(Function *F);
6969
7070 // Accessor interface:
7171 typedef DomSetMapType::const_iterator const_iterator;
119119
120120 ImmediateDominators(AnalysisID id) : DominatorBase(id == PostDomID) {}
121121
122 virtual bool runOnMethod(Method *M) {
122 virtual bool runOnMethod(Function *F) {
123123 IDoms.clear(); // Reset from the last time we were run...
124124 DominatorSet *DS;
125125 if (isPostDominator())
212212 DominatorTree(AnalysisID id) : DominatorBase(id == PostDomID) {}
213213 ~DominatorTree() { reset(); }
214214
215 virtual bool runOnMethod(Method *M) {
215 virtual bool runOnMethod(Function *F) {
216216 reset();
217217 DominatorSet *DS;
218218 if (isPostDominator())
269269
270270 DominanceFrontier(AnalysisID id) : DominatorBase(id == PostDomID) {}
271271
272 virtual bool runOnMethod(Method *M) {
272 virtual bool runOnMethod(Function *) {
273273 Frontiers.clear();
274274 DominatorTree *DT;
275275 if (isPostDominator())
4141 IntervalPartition(AnalysisID AID) : RootInterval(0) { assert(AID == ID); }
4242
4343 // run - Calculate the interval partition for this method
44 virtual bool runOnMethod(Method *M);
44 virtual bool runOnMethod(Function *F);
4545
4646 // IntervalPartition ctor - Build a reduced interval partition from an
4747 // existing interval graph. This takes an additional boolean parameter to
77
88 It must be called like:
99
10 MethodLiveVarInfo MLVI( Mehtod *); // initializes data structures
10 MethodLiveVarInfo MLVI(Function *); // initializes data structures
1111 MLVI.analyze(); // do the actural live variable anal
1212
1313 After the analysis, getInSetOfBB or getOutSetofBB can be called to get
8585 // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst
8686 std::map MInst2LVSetAI;
8787
88 // Stored Method that the data is computed with respect to
89 const Method *M;
88 // Stored Function that the data is computed with respect to
89 const Function *M;
9090
9191 // --------- private methods -----------------------------------------
9292
9393 // constructs BBLiveVars and init Def and In sets
94 void constructBBs(const Method *M);
94 void constructBBs(const Function *F);
9595
9696 // do one backward pass over the CFG
97 bool doSingleBackwardPass(const Method *M, unsigned int iter);
97 bool doSingleBackwardPass(const Function *F, unsigned int iter);
9898
9999 // calculates live var sets for instructions in a BB
100100 void calcLiveVarSetsForBB(const BasicBlock *BB);
107107 // --------- Implement the MethodPass interface ----------------------
108108
109109 // runOnMethod - Perform analysis, update internal data structures.
110 virtual bool runOnMethod(Method *M);
110 virtual bool runOnMethod(Function *F);
111111
112112 // releaseMemory - After LiveVariable analysis has been used, forget!
113113 virtual void releaseMemory();
100100 #endif
101101
102102 // runOnMethod - Pass framework implementation
103 virtual bool runOnMethod(Method *M);
103 virtual bool runOnMethod(Function *F);
104104
105105 // getAnalysisUsageInfo - Provide loop info, require dominator set
106106 //
1313 #include
1414 class Value;
1515 class Module;
16 class Method;
16 class Function;
1717 class MethodArgument;
1818 class BasicBlock;
1919 class Instruction;
3333
3434 public:
3535 SlotCalculator(const Module *M, bool IgnoreNamed);
36 SlotCalculator(const Method *M, bool IgnoreNamed);// Start out in incorp state
36 // Start out in incorp state
37 SlotCalculator(const Function *M, bool IgnoreNamed);
3738 inline ~SlotCalculator() {}
3839
3940 // getValSlot returns < 0 on error!
5152 // If you'd like to deal with a method, use these two methods to get its data
5253 // into the SlotCalculator!
5354 //
54 void incorporateMethod(const Method *M);
55 void incorporateMethod(const Function *F);
5556 void purgeMethod();
5657
5758 protected:
1414
1515 class Pass;
1616 class Module;
17 class Method;
17 class Function;
1818
1919 // createVerifierPass - Check a module or method for validity. If errors are
2020 // detected, error messages corresponding to the problem are printed to stderr.
2828
2929 // verifyMethod - Check a method for errors, useful for use when debugging a
3030 // pass.
31 bool verifyMethod(const Method *M);
31 bool verifyMethod(const Function *M);
3232
3333 #endif
2020
2121 class Module;
2222 class GlobalVariable;
23 class Method;
23 class Function;
2424 class BasicBlock;
2525 class Instruction;
2626 class SlotCalculator;
3131 //
3232 void WriteToAssembly(const Module *Module, std::ostream &o);
3333 void WriteToAssembly(const GlobalVariable *G, std::ostream &o);
34 void WriteToAssembly(const Method *Method, std::ostream &o);
34 void WriteToAssembly(const Function *F , std::ostream &o);
3535 void WriteToAssembly(const BasicBlock *BB, std::ostream &o);
3636 void WriteToAssembly(const Instruction *In, std::ostream &o);
3737 void WriteToAssembly(const Constant *V, std::ostream &o);
5757 // suffix.
5858 //
5959 void WriteToVCG(const Module *Module, const std::string &Filename);
60 void WriteToVCG(const Method *Method, const std::string &Filename);
60 void WriteToVCG(const Function *Func, const std::string &Filename);
6161
6262
6363
7373 WriteToAssembly(G, o); return o;
7474 }
7575
76 inline std::ostream &operator<<(std::ostream &o, const Method *M) {
77 WriteToAssembly(M, o); return o;
76 inline std::ostream &operator<<(std::ostream &o, const Function *F) {
77 WriteToAssembly(F, o); return o;
7878 }
7979
8080 inline std::ostream &operator<<(std::ostream &o, const BasicBlock *B) {
102102 case Value::MethodArgumentVal: return o << I->getType() << " "<< I->getName();
103103 case Value::InstructionVal:WriteToAssembly(cast(I) , o); break;
104104 case Value::BasicBlockVal: WriteToAssembly(cast(I) , o); break;
105 case Value::MethodVal: WriteToAssembly(cast<Method>(I) , o); break;
105 case Value::MethodVal: WriteToAssembly(cast<Function>(I) , o); break;
106106 case Value::GlobalVariableVal:
107107 WriteToAssembly(cast(I), o); break;
108108 case Value::ModuleVal: WriteToAssembly(cast(I) , o); break;
77
88 It must be called like:
99
10 MethodLiveVarInfo MLVI( Mehtod *); // initializes data structures
10 MethodLiveVarInfo MLVI(Function *); // initializes data structures
1111 MLVI.analyze(); // do the actural live variable anal
1212
1313 After the analysis, getInSetOfBB or getOutSetofBB can be called to get
8585 // Machine Instr to LiveVarSet Map for providing LVset AFTER each inst
8686 std::map MInst2LVSetAI;
8787
88 // Stored Method that the data is computed with respect to
89 const Method *M;
88 // Stored Function that the data is computed with respect to
89 const Function *M;
9090
9191 // --------- private methods -----------------------------------------
9292
9393 // constructs BBLiveVars and init Def and In sets
94 void constructBBs(const Method *M);
94 void constructBBs(const Function *F);
9595
9696 // do one backward pass over the CFG
97 bool doSingleBackwardPass(const Method *M, unsigned int iter);
97 bool doSingleBackwardPass(const Function *F, unsigned int iter);
9898
9999 // calculates live var sets for instructions in a BB
100100 void calcLiveVarSetsForBB(const BasicBlock *BB);
107107 // --------- Implement the MethodPass interface ----------------------
108108
109109 // runOnMethod - Perform analysis, update internal data structures.
110 virtual bool runOnMethod(Method *M);
110 virtual bool runOnMethod(Function *F);
111111
112112 // releaseMemory - After LiveVariable analysis has been used, forget!
113113 virtual void releaseMemory();
3030
3131 class Constant;
3232 class BasicBlock;
33 class Method;
33 class Function;
3434 class InstrTreeNode;
3535 class InstrForest;
3636
242242 std::hash_set treeRoots;
243243
244244 public:
245 /*ctor*/ InstrForest (Method *M);
245 /*ctor*/ InstrForest (Function *F);
246246 /*dtor*/ ~InstrForest ();
247247
248248 inline InstructionNode *getTreeNodeForInstr(Instruction* instr) {
1313 #define LLVM_CODEGEN_INSTR_SELECTION_H
1414
1515 #include "llvm/Instruction.h"
16 class Method;
16 class Function;
1717 class InstrForest;
1818 class MachineInstr;
1919 class InstructionNode;
5454 // Implemented in machine-specific instruction selection file.
5555 //---------------------------------------------------------------------------
5656
57 bool SelectInstructionsForMethod (Method* method,
57 bool SelectInstructionsForMethod (Function* function,
5858 TargetMachine &Target);
5959
6060
1313 #include "Support/HashExtras.h"
1414 #include
1515 class Value;
16 class Method;
16 class Function;
1717 class Constant;
1818 class Type;
1919 class TargetMachine;
2020
2121
2222 class MachineCodeForMethod : private Annotation {
23 const Method* method;
23 const Function* method;
2424 bool compiledAsLeaf;
2525 unsigned staticStackSize;
2626 unsigned automaticVarsSize;
3232 std::hash_map offsets;
3333
3434 public:
35 /*ctor*/ MachineCodeForMethod(const Method* method,
35 /*ctor*/ MachineCodeForMethod(const Function* function,
3636 const TargetMachine& target);
3737
3838 // The next two methods are used to construct and to retrieve
4242 // This should not be called before "construct()"
4343 // for a given Method.
4444 //
45 static MachineCodeForMethod& construct(const Method *method,
45 static MachineCodeForMethod& construct(const Function *method,
4646 const TargetMachine &target);
47 static void destruct(const Method *M);
48 static MachineCodeForMethod& get(const Method* method);
47 static void destruct(const Function *F);
48 static MachineCodeForMethod& get(const Function* function);
4949
5050 //
5151 // Accessors for global information about generated code for a method.
1313 #include "Support/HashExtras.h"
1414 #include
1515 class Value;
16 class Method;
16 class Function;
1717 class Constant;
1818 class Type;
1919 class TargetMachine;
2020
2121
2222 class MachineCodeForMethod : private Annotation {
23 const Method* method;
23 const Function* method;
2424 bool compiledAsLeaf;
2525 unsigned staticStackSize;
2626 unsigned automaticVarsSize;
3232 std::hash_map offsets;
3333
3434 public:
35 /*ctor*/ MachineCodeForMethod(const Method* method,
35 /*ctor*/ MachineCodeForMethod(const Function* function,
3636 const TargetMachine& target);
3737
3838 // The next two methods are used to construct and to retrieve
4242 // This should not be called before "construct()"
4343 // for a given Method.
4444 //
45 static MachineCodeForMethod& construct(const Method *method,
45 static MachineCodeForMethod& construct(const Function *method,
4646 const TargetMachine &target);
47 static void destruct(const Method *M);
48 static MachineCodeForMethod& get(const Method* method);
47 static void destruct(const Function *F);
48 static MachineCodeForMethod& get(const Function* function);
4949
5050 //
5151 // Accessors for global information about generated code for a method.
451451 std::ostream& operator<< (std::ostream& os, const MachineOperand& mop);
452452
453453
454 void PrintMachineInstructions(const Method *method);
454 void PrintMachineInstructions(const Function *F);
455455
456456
457457 //**************************************************************************/
2121 #include
2222 class Value;
2323 class BasicBlock;
24 class Method;
24 class Function;
2525 class Module;
2626 class AnalysisID;
2727 class Pass;
104104
105105 private:
106106 friend class PassManagerT;
107 friend class PassManagerT<Method>;
107 friend class PassManagerT<Function>;
108108 friend class PassManagerT;
109109 virtual void addToPassManager(PassManagerT *PM, AnalysisSet &Req,
110110 AnalysisSet &Destroyed, AnalysisSet &Provided);
128128 // runOnMethod - Virtual method overriden by subclasses to do the per-method
129129 // processing of the pass.
130130 //
131 virtual bool runOnMethod(Method *M) = 0;
131 virtual bool runOnMethod(Function *M) = 0;
132132
133133 // doFinalization - Virtual method overriden by subclasses to do any post
134134 // processing needed after all passes have run.
142142
143143 // run - On a method, we simply initialize, run the method, then finalize.
144144 //
145 bool run(Method *M);
145 bool run(Function *M);
146146
147147 private:
148148 friend class PassManagerT;
149 friend class PassManagerT<Method>;
149 friend class PassManagerT<Function>;
150150 friend class PassManagerT;
151151 virtual void addToPassManager(PassManagerT *PM, AnalysisSet &Req,
152152 AnalysisSet &Dest, AnalysisSet &Prov);
153 virtual void addToPassManager(PassManagerT<Method> *PM,AnalysisSet &Req,
153 virtual void addToPassManager(PassManagerT<Function> *PM,AnalysisSet &Req,
154154 AnalysisSet &Dest, AnalysisSet &Prov);
155155 };
156156
175175 // To run this pass on a method, we simply call runOnBasicBlock once for each
176176 // method.
177177 //
178 virtual bool runOnMethod(Method *BB);
178 virtual bool runOnMethod(Function *F);
179179
180180 // To run directly on the basic block, we initialize, runOnBasicBlock, then
181181 // finalize.
183183 bool run(BasicBlock *BB);
184184
185185 private:
186 friend class PassManagerT<Method>;
186 friend class PassManagerT<Function>;
187187 friend class PassManagerT;
188 virtual void addToPassManager(PassManagerT<Method> *PM, AnalysisSet &,
188 virtual void addToPassManager(PassManagerT<Function> *PM, AnalysisSet &,
189189 AnalysisSet &, AnalysisSet &);
190190 virtual void addToPassManager(PassManagerT *PM, AnalysisSet &,
191191 AnalysisSet &, AnalysisSet &);
1313 #include
1414 class Value;
1515 class Module;
16 class Method;
16 class Function;
1717 class MethodArgument;
1818 class BasicBlock;
1919 class Instruction;
3333
3434 public:
3535 SlotCalculator(const Module *M, bool IgnoreNamed);
36 SlotCalculator(const Method *M, bool IgnoreNamed);// Start out in incorp state
36 // Start out in incorp state
37 SlotCalculator(const Function *M, bool IgnoreNamed);
3738 inline ~SlotCalculator() {}
3839
3940 // getValSlot returns < 0 on error!
5152 // If you'd like to deal with a method, use these two methods to get its data
5253 // into the SlotCalculator!
5354 //
54 void incorporateMethod(const Method *M);
55 void incorporateMethod(const Function *F);
5556 void purgeMethod();
5657
5758 protected:
1717 class TargetMachine;
1818 class Value;
1919 class Instruction;
20 class Method;
20 class Function;
2121
2222 //---------------------------------------------------------------------------
2323 // Data types used to define information about a single machine instruction
247247 // The generated instructions are returned in `minstrVec'.
248248 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
249249 //
250 virtual void CreateCodeToLoadConst(Method* method,
250 virtual void CreateCodeToLoadConst(Function* method,
251251 Value* val,
252252 Instruction* dest,
253253 std::vector& minstrVec,
259259 // The generated instructions are returned in `minstrVec'.
260260 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
261261 //
262 virtual void CreateCodeToCopyIntToFloat(Method* method,
262 virtual void CreateCodeToCopyIntToFloat(Function* method,
263263 Value* val,
264264 Instruction* dest,
265265 std::vector& minstVec,
270270 // `val' to an integer value `dest' by copying to memory and back.
271271 // See the previous function for information about return values.
272272 //
273 virtual void CreateCodeToCopyFloatToInt(Method* method,
273 virtual void CreateCodeToCopyFloatToInt(Function* method,
274274 Value* val,
275275 Instruction* dest,
276276 std::vector& minstVec,
280280
281281 // create copy instruction(s)
282282 virtual void CreateCopyInstructionsByType(const TargetMachine& target,
283 Method* method,
283 Function* method,
284284 Value* src,
285285 Instruction* dest,
286286 std::vector& minstrVec)
1717 class TargetMachine;
1818 class Value;
1919 class Instruction;
20 class Method;
20 class Function;
2121
2222 //---------------------------------------------------------------------------
2323 // Data types used to define information about a single machine instruction
247247 // The generated instructions are returned in `minstrVec'.
248248 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
249249 //
250 virtual void CreateCodeToLoadConst(Method* method,
250 virtual void CreateCodeToLoadConst(Function* method,
251251 Value* val,
252252 Instruction* dest,
253253 std::vector& minstrVec,
259259 // The generated instructions are returned in `minstrVec'.
260260 // Any temp. registers (TmpInstruction) created are returned in `tempVec'.
261261 //
262 virtual void CreateCodeToCopyIntToFloat(Method* method,
262 virtual void CreateCodeToCopyIntToFloat(Function* method,
263263 Value* val,
264264 Instruction* dest,
265265 std::vector& minstVec,
270270 // `val' to an integer value `dest' by copying to memory and back.
271271 // See the previous function for information about return values.
272272 //
273 virtual void CreateCodeToCopyFloatToInt(Method* method,
273 virtual void CreateCodeToCopyFloatToInt(Function* method,
274274 Value* val,
275275 Instruction* dest,
276276 std::vector& minstVec,
280280
281281 // create copy instruction(s)
282282 virtual void CreateCopyInstructionsByType(const TargetMachine& target,
283 Method* method,
283 Function* method,
284284 Value* src,
285285 Instruction* dest,
286286 std::vector& minstrVec)
1616 class Type;
1717 class Value;
1818 class LiveRangeInfo;
19 class Method;
19 class Function;
2020 class Instruction;
2121 class LiveRange;
2222 class AddedInstrns;
107107 // method args and return values etc.) with specific hardware registers
108108 // as required. See SparcRegInfo.cpp for the implementation for Sparc.
109109 //
110 virtual void suggestRegs4MethodArgs(const Method *Meth,
110 virtual void suggestRegs4MethodArgs(const Function *Func,
111111 LiveRangeInfo &LRI) const = 0;
112112
113113 virtual void suggestRegs4CallArgs(const MachineInstr *CallI,
116116 virtual void suggestReg4RetValue(const MachineInstr *RetI,
117117 LiveRangeInfo &LRI) const = 0;
118118
119 virtual void colorMethodArgs(const Method *Meth, LiveRangeInfo &LRI,
119 virtual void colorMethodArgs(const Function *Func, LiveRangeInfo &LRI,
120120 AddedInstrns *FirstAI) const = 0;
121121
122122 virtual void colorCallArgs(const MachineInstr *CalI,
8787 // transformMethod - This transforms the instructions of the method to use the
8888 // new types.
8989 //
90 void transformMethod(Method *M);
90 void transformMethod(Function *F);
9191
9292 // removeDeadGlobals - This removes the old versions of methods that are no
9393 // longer needed.
1313 struct InductionVariableCannonicalize : public MethodPass {
1414 // doInductionVariableCannonicalize - Simplify induction variables in loops
1515 //
16 static bool doIt(Method *M, cfg::IntervalPartition &IP);
16 static bool doIt(Function *M, cfg::IntervalPartition &IP);
1717
18 virtual bool runOnMethod(Method *M);
18 virtual bool runOnMethod(Function *M);
1919
2020 // getAnalysisUsageInfo - Declare that we need IntervalPartitions
2121 void getAnalysisUsageInfo(Pass::AnalysisSet &Required,
2222 //
2323 // If there are no return stmts in the Method, a null pointer is returned.
2424 //
25 static bool doit(Method *M, BasicBlock *&ExitNode);
25 static bool doit(Function *F, BasicBlock *&ExitNode);
2626
2727
28 virtual bool runOnMethod(Method *M) {
29 return doit(M, ExitNode);
28 virtual bool runOnMethod(Function *F) {
29 return doit(F, ExitNode);
3030 }
3131
3232 BasicBlock *getExitNode() const { return ExitNode; }
2222 class Instruction;
2323 class BasicBlock;
2424 class GlobalValue;
25 class Method;
25 class Function;
26 typedef Function Method;
2627 class GlobalVariable;
2728 class Module;
2829 class SymbolTable;
273274 template <> inline bool isa(Value *Val) {
274275 return Val->getValueType() == Value::BasicBlockVal;
275276 }
276 template <> inline bool isa<Method, const Value*>(const Value *Val) {
277 template <> inline bool isa<Function, const Value*>(const Value *Val) {
277278 return Val->getValueType() == Value::MethodVal;
278279 }
279 template <> inline bool isa<Method, Value*>(Value *Val) {
280 template <> inline bool isa<Function, Value*>(Value *Val) {
280281 return Val->getValueType() == Value::MethodVal;
281282 }
282283 template <> inline bool isa(const Value *Val) {
286287 return Val->getValueType() == Value::GlobalVariableVal;
287288 }
288289 template <> inline bool isa(const Value *Val) {
289 return isa(Val) || isa<Method>(Val);
290 return isa(Val) || isa<Function>(Val);
290291 }
291292 template <> inline bool isa(Value *Val) {
292 return isa(Val) || isa<Method>(Val);
293 return isa(Val) || isa<Function>(Val);
293294 }
294295 template <> inline bool isa(const Value *Val) {
295296 return Val->getValueType() == Value::ModuleVal;
204204 // getCalledMethod - Return the method called, or null if this is an indirect
205205 // method invocation...
206206 //
207 inline const Method *getCalledMethod() const {
208 return dyn_cast(Operands[0].get());
207 inline const Function *getCalledMethod() const {
208 return dyn_cast(Operands[0].get());
209209 }
210210 inline Method *getCalledMethod() {
211211 return dyn_cast(Operands[0].get());
1010 #include "llvm/Analysis/LiveVar/ValueSet.h"
1111 #include "llvm/Annotation.h"
1212 #include
13 class Method;
1413 class BasicBlock;
1514 class Value;
1615
22
33 LIBRARYNAME = analysis
44
5 DIRS = LiveVar IPA
5 DIRS = LiveVar IPA DataStructure
66
77 include $(LEVEL)/Makefile.common
88
2525 #else
2626 #define BCR_TRACE(n, X)
2727 #endif
28
29 class BasicBlock;
30 class Method;
31 class Module;
32 class Type;
33 class PointerType;
3428
3529 typedef unsigned char uchar;
3630
1313 #include
1414 class Value;
1515 class Module;
16 class Method;
16 class Function;
1717 class MethodArgument;
1818 class BasicBlock;
1919 class Instruction;
3333
3434 public:
3535 SlotCalculator(const Module *M, bool IgnoreNamed);
36 SlotCalculator(const Method *M, bool IgnoreNamed);// Start out in incorp state
36 // Start out in incorp state
37 SlotCalculator(const Function *M, bool IgnoreNamed);
3738 inline ~SlotCalculator() {}
3839
3940 // getValSlot returns < 0 on error!
5152 // If you'd like to deal with a method, use these two methods to get its data
5253 // into the SlotCalculator!
5354 //
54 void incorporateMethod(const Method *M);
55 void incorporateMethod(const Function *F);
5556 void purgeMethod();
5657
5758 protected:
2727 class Instruction;
2828 class TerminatorInst;
2929 class BasicBlock;
30 class Method;
30 class Function;
3131 class TargetMachine;
3232 class SchedGraphEdge;
3333 class SchedGraphNode;
338338 private std::hash_map
339339 {
340340 private:
341 const Method* method;
341 const Function* method;
342342
343343 public:
344344 typedef std::hash_map map_base;
346346 using map_base::const_iterator;
347347
348348 public:
349 /*ctor*/ SchedGraphSet (const Method* _method,
349 /*ctor*/ SchedGraphSet (const Function * function,
350350 const TargetMachine& target);
351351 /*dtor*/ ~SchedGraphSet ();
352352
378378 //
379379 // Graph builder
380380 //
381 void buildGraphsForMethod (const Method *method,
381 void buildGraphsForMethod (const Function *F,
382382 const TargetMachine& target);
383383 };
384384
2727 #include
2828 #include
2929 #include
30 class Method;
30 class Function;
3131 class MachineInstr;
3232 class SchedulingManager;
3333 class MethodLiveVarInfo;
124124
125125 class SchedPriorities: public NonCopyable {
126126 public:
127 SchedPriorities(const Method *M, const SchedGraph *G, MethodLiveVarInfo &LVI);
127 SchedPriorities(const Function *F, const SchedGraph *G,
128 MethodLiveVarInfo &LVI);
128129
129130
130131 // This must be called before scheduling begins.
None //===-- LiveRangeInfo.h - Track all LiveRanges for a Method ------*- C++ -*-==//
0 //===-- LiveRangeInfo.h - Track all LiveRanges for a Function ----*- C++ -*-==//
11 //
22 // This file contains the class LiveRangeInfo which constructs and keeps
33 // the LiveRangMap which contains all the live ranges used in a method.
2727 class MachineRegInfo;
2828 class TargetMachine;
2929 class Value;
30 class Method;
30 class Function;
3131 class Instruction;
3232
3333 typedef std::hash_map LiveRangeMapType;
4141 //----------------------------------------------------------------------------
4242
4343 class LiveRangeInfo {
44 const Method *const Meth; // Method for which live range info is held
44 const Function *const Meth; // Func for which live range info is held
4545 LiveRangeMapType LiveRangeMap; // A map from Value * to LiveRange * to
4646 // record all live ranges in a method
4747 // created by constructLiveRanges
6363
6464 void suggestRegs4CallRets();
6565
66 const Method* getMethod() { return Meth; }
66 const Function *getMethod() { return Meth; }
6767
6868 public:
6969
70 LiveRangeInfo(const Method *M,
70 LiveRangeInfo(const Function *F,
7171 const TargetMachine& tm,
7272 std::vector & RCList);
7373
2727 class Instruction;
2828 class TerminatorInst;
2929 class BasicBlock;
30 class Method;
30 class Function;
3131 class TargetMachine;
3232 class SchedGraphEdge;
3333 class SchedGraphNode;
338338 private std::hash_map
339339 {
340340 private:
341 const Method* method;
341 const Function* method;
342342
343343 public:
344344 typedef std::hash_map map_base;
346346 using map_base::const_iterator;
347347
348348 public:
349 /*ctor*/ SchedGraphSet (const Method* _method,
349 /*ctor*/ SchedGraphSet (const Function * function,
350350 const TargetMachine& target);
351351 /*dtor*/ ~SchedGraphSet ();
352352
378378 //
379379 // Graph builder
380380 //
381 void buildGraphsForMethod (const Method *method,
381 void buildGraphsForMethod (const Function *F,
382382 const TargetMachine& target);
383383 };
384384
2727 #include
2828 #include
2929 #include
30 class Method;
30 class Function;
3131 class MachineInstr;
3232 class SchedulingManager;
3333 class MethodLiveVarInfo;
124124
125125 class SchedPriorities: public NonCopyable {
126126 public:
127 SchedPriorities(const Method *M, const SchedGraph *G, MethodLiveVarInfo &LVI);
127 SchedPriorities(const Function *F, const SchedGraph *G,
128 MethodLiveVarInfo &LVI);
128129
129130
130131 // This must be called before scheduling begins.
1010 #include "llvm/Analysis/LiveVar/ValueSet.h"
1111 #include "llvm/Annotation.h"
1212 #include
13 class Method;
1413 class BasicBlock;
1514 class Value;
1615
None //===-- LiveRangeInfo.h - Track all LiveRanges for a Method ------*- C++ -*-==//
0 //===-- LiveRangeInfo.h - Track all LiveRanges for a Function ----*- C++ -*-==//
11 //
22 // This file contains the class LiveRangeInfo which constructs and keeps
33 // the LiveRangMap which contains all the live ranges used in a method.
2727 class MachineRegInfo;
2828 class TargetMachine;
2929 class Value;
30 class Method;
30 class Function;
3131 class Instruction;
3232
3333 typedef std::hash_map LiveRangeMapType;
4141 //----------------------------------------------------------------------------
4242
4343 class LiveRangeInfo {
44 const Method *const Meth; // Method for which live range info is held
44 const Function *const Meth; // Func for which live range info is held
4545 LiveRangeMapType LiveRangeMap; // A map from Value * to LiveRange * to
4646 // record all live ranges in a method
4747 // created by constructLiveRanges
6363
6464 void suggestRegs4CallRets();
6565
66 const Method* getMethod() { return Meth; }
66 const Function *getMethod() { return Meth; }
6767
6868 public:
6969
70 LiveRangeInfo(const Method *M,
70 LiveRangeInfo(const Function *F,
7171 const TargetMachine& tm,
7272 std::vector & RCList);
7373
1515 #include "llvm/iOperators.h"
1616 #include "llvm/iPHINode.h"
1717
18 class Method;
1918 using std::vector;
2019
2120 //get the code to be inserted on the edge
2424 template class ValueHolder;
2525 template class ValueHolder;
2626
27 Method::Method(const MethodType *Ty, bool isInternal, const std::string &name)
27 Function::Function(const MethodType *Ty, bool isInternal,
28 const std::string &name)
2829 : GlobalValue(PointerType::get(Ty), Value::MethodVal, isInternal, name),
2930 SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) {
3031 assert(::isa(Ty) && "Method signature must be of method type!");
3132 }
3233
33 Method::~Method() {
34 Function::~Function() {
3435 dropAllReferences(); // After this it is safe to delete instructions.
3536
3637 // TODO: Should remove from the end, not the beginning of vector!
4445 }
4546
4647 // Specialize setName to take care of symbol table majik
47 void Method::setName(const std::string &name, SymbolTable *ST) {
48 void Function::setName(const std::string &name, SymbolTable *ST) {
4849 Module *P;
4950 assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) &&
5051 "Invalid symtab argument!");
5354 if (P && getName() != "") P->getSymbolTableSure()->insert(this);
5455 }
5556
56 void Method::setParent(Module *parent) {
57 void Function::setParent(Module *parent) {
5758 Parent = parent;
5859
5960 // Relink symbol tables together...
6061 setParentSymTab(Parent ? Parent->getSymbolTableSure() : 0);
6162 }
6263
63 const MethodType *Method::getMethodType() const {
64 const MethodType *Function::getMethodType() const {
6465 return cast(cast(getType())->getElementType());
6566 }
6667
67 const Type *Method::getReturnType() const {
68 const Type *Function::getReturnType() const {
6869 return getMethodType()->getReturnType();
6970 }
7071
7677 // valid on an object that has "dropped all references", except operator
7778 // delete.
7879 //
79 void Method::dropAllReferences() {
80 void Function::dropAllReferences() {
8081 for_each(begin(), end(), std::mem_fun(&BasicBlock::dropAllReferences));
8182 }
8283
346346 typedef PassClass BatcherClass;
347347
348348 // ParentClass - The type of the parent PassManager...
349 typedef PassManagerT<Method> ParentClass;
349 typedef PassManagerT<Function> ParentClass;
350350
351351 // PMType - The type of the passmanager that subclasses this class
352352 typedef PassManagerT PMType;
370370
371371
372372 //===----------------------------------------------------------------------===//
373 // PassManagerTraits<Method> Specialization
373 // PassManagerTraits<Function> Specialization
374374 //
375375 // This pass manager is used to group together all of the MethodPass's
376376 // into a single unit.
377377 //
378 template<> struct PassManagerTraits<Method> : public MethodPass {
378 template<> struct PassManagerTraits<Function> : public MethodPass {
379379 // PassClass - The type of passes tracked by this PassManager
380380 typedef MethodPass PassClass;
381381
389389 typedef PassManagerT ParentClass;
390390
391391 // PMType - The type of the passmanager that subclasses this class
392 typedef PassManagerT<Method> PMType;
392 typedef PassManagerT<Function> PMType;
393393
394394 // runPass - Specify how the pass should be run on the UnitType
395 static bool runPass(PassClass *P, Method *M) {
395 static bool runPass(PassClass *P, Function *M) {
396396 return P->runOnMethod(M);
397397 }
398398
399399 // getPMName() - Return the name of the unit the PassManager operates on for
400400 // debugging.
401 const char *getPMName() const { return "Method"; }
401 const char *getPMName() const { return "Function"; }
402402
403403 // Implement the MethodPass interface...
404404 virtual bool doInitialization(Module *M);
405 virtual bool runOnMethod(Method *M);
405 virtual bool runOnMethod(Function *M);
406406 virtual bool doFinalization(Module *M);
407407 };
408408
421421 typedef MethodPass SubPassClass;
422422
423423 // BatcherClass - The type to use for collation of subtypes...
424 typedef PassManagerT<Method> BatcherClass;
424 typedef PassManagerT<Function> BatcherClass;
425425
426426 // ParentClass - The type of the parent PassManager...
427427 typedef AnalysisResolver ParentClass;
466466 }
467467
468468
469 // PassManagerTraits Implementations
470 //
471 inline bool PassManagerTraits::doInitialization(Module *M) {
469 // PassManagerTraits Implementations
470 //
471 inline bool PassManagerTraits::doInitialization(Module *M) {
472472 bool Changed = false;
473473 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
474474 ((PMType*)this)->Passes[i]->doInitialization(M);
475475 return Changed;
476476 }
477477
478 inline bool PassManagerTraits<Method>::runOnMethod(Method *M) {
478 inline bool PassManagerTraits<Function>::runOnMethod(Function *M) {
479479 return ((PMType*)this)->runOnUnit(M);
480480 }
481481
482 inline bool PassManagerTraits<Method>::doFinalization(Module *M) {
482 inline bool PassManagerTraits<Function>::doFinalization(Module *M) {
483483 bool Changed = false;
484484 for (unsigned i = 0, e = ((PMType*)this)->Passes.size(); i != e; ++i)
485485 ((PMType*)this)->Passes[i]->doFinalization(M);