llvm.org GIT mirror llvm / 335d5c3
s/method/function git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4338 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 18 years ago
2 changed file(s) with 31 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
2626 Pass *createMachineCodeDestructionPass();
2727
2828 class MachineFunction : private Annotation {
29 const Function *method;
29 const Function *Fn;
30 const TargetMachine &Target;
3031
3132 // List of machine basic blocks in function
3233 iplist BasicBlocks;
4647 bool automaticVarsAreaFrozen;
4748
4849 public:
49 MachineFunction(const Function* function,
50 const TargetMachine& target);
50 MachineFunction(const Function *Fn, const TargetMachine& target);
51
52 /// getFunction - Return the LLVM function that this machine code represents
53 ///
54 const Function *getFunction() const { return Fn; }
55
56 /// getTarget - Return the target machine this machine code is compiled with
57 ///
58 const TargetMachine &getTarget() const { return Target; }
5159
5260 // The next two methods are used to construct and to retrieve
5361 // the MachineFunction object for the given method.
5664 // This should not be called before "construct()"
5765 // for a given Method.
5866 //
59 static MachineFunction& construct(const Function *method,
60 const TargetMachine &target);
67 static MachineFunction& construct(const Function *Fn,
68 const TargetMachine &target);
6169 static void destruct(const Function *F);
6270 static MachineFunction& get(const Function *F);
6371
9898 // for a given Function.
9999 //
100100 MachineFunction&
101 MachineFunction::construct(const Function *M, const TargetMachine &Tar)
102 {
103 assert(M->getAnnotation(MCFM_AID) == 0 &&
101 MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
102 {
103 assert(Fn->getAnnotation(MCFM_AID) == 0 &&
104104 "Object already exists for this function!");
105 MachineFunction* mcInfo = new MachineFunction(M, Tar);
106 M->addAnnotation(mcInfo);
105 MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
106 Fn->addAnnotation(mcInfo);
107107 return *mcInfo;
108108 }
109109
110110 void
111 MachineFunction::destruct(const Function *M)
112 {
113 bool Deleted = M->deleteAnnotation(MCFM_AID);
111 MachineFunction::destruct(const Function *Fn)
112 {
113 bool Deleted = Fn->deleteAnnotation(MCFM_AID);
114114 assert(Deleted && "Machine code did not exist for function!");
115115 }
116116
117 MachineFunction&
118 MachineFunction::get(const Function *F)
117 MachineFunction& MachineFunction::get(const Function *F)
119118 {
120119 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MCFM_AID);
121120 assert(mc && "Call construct() method first to allocate the object");
190189
191190 /*ctor*/
192191 MachineFunction::MachineFunction(const Function *F,
193 const TargetMachine& target)
192 const TargetMachine& target)
194193 : Annotation(MCFM_AID),
195 method(F), staticStackSize(0),
194 Fn(F), Target(target), staticStackSize(0),
196195 automaticVarsSize(0), regSpillsSize(0),
197196 maxOptionalArgsSize(0), maxOptionalNumArgs(0),
198197 currentTmpValuesSize(0), maxTmpValuesSize(0), compiledAsLeaf(false),
199198 spillsAreaFrozen(false), automaticVarsAreaFrozen(false)
200199 {
201 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, method,
200 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, Fn,
202201 maxOptionalNumArgs);
203202 staticStackSize = maxOptionalArgsSize
204203 + target.getFrameInfo().getMinStackFrameSize();
309308 void
310309 MachineFunction::dump() const
311310 {
312 std::cerr << "\n" << method->getReturnType()
313 << " \"" << method->getName() << "\"\n";
314
315 for (Function::const_iterator BB = method->begin(); BB != method->end(); ++BB)
311 std::cerr << "\n" << Fn->getReturnType()
312 << " \"" << Fn->getName() << "\"\n";
313
314 for (Function::const_iterator BB = Fn->begin(); BB != Fn->end(); ++BB)
316315 {
317316 std::cerr << "\n" << BB->getName() << " (" << (const void*)BB
318317 << ")" << ":" << "\n";
320319 for (unsigned i=0; i < mvec.size(); i++)
321320 std::cerr << "\t" << *mvec[i];
322321 }
323 std::cerr << "\nEnd function \"" << method->getName() << "\"\n\n";
324 }
322 std::cerr << "\nEnd function \"" << Fn->getName() << "\"\n\n";
323 }