s/method/function
authorChris Lattner <sabre@nondot.org>
Mon, 28 Oct 2002 05:58:46 +0000 (05:58 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 28 Oct 2002 05:58:46 +0000 (05:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4338 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineFunction.h
lib/CodeGen/MachineFunction.cpp

index 33f9efc281bce56b989f5adc38f0530aab63f5b5..e429fc4f11148744c35b91c26f9de2e6c2a70920 100644 (file)
@@ -27,7 +27,8 @@ Pass *createMachineCodeConstructionPass(TargetMachine &Target);
 Pass *createMachineCodeDestructionPass();
 
 class MachineFunction : private Annotation {
-  const Function *method;
+  const Function *Fn;
+  const TargetMachine &Target;
 
   // List of machine basic blocks in function
   iplist<MachineBasicBlock> BasicBlocks;
@@ -47,8 +48,15 @@ class MachineFunction : private Annotation {
   bool          automaticVarsAreaFrozen;
   
 public:
-  MachineFunction(const Function* function,
-                  const TargetMachine& target);
+  MachineFunction(const Function *Fn, const TargetMachine& target);
+
+  /// getFunction - Return the LLVM function that this machine code represents
+  ///
+  const Function *getFunction() const { return Fn; }
+
+  /// getTarget - Return the target machine this machine code is compiled with
+  ///
+  const TargetMachine &getTarget() const { return Target; }
   
   // The next two methods are used to construct and to retrieve
   // the MachineFunction object for the given method.
@@ -57,8 +65,8 @@ public:
   //                This should not be called before "construct()"
   //                for a given Method.
   // 
-  static MachineFunction& construct(const Function *method,
-                                         const TargetMachine &target);
+  static MachineFunction& construct(const Function *Fn,
+                                    const TargetMachine &target);
   static void destruct(const Function *F);
   static MachineFunction& get(const Function *F);
 
index 15036a4d077ed9531910bf69fb0fb237a26be9d4..c06c008baded8bf9c2bb3892b63fa2696b1c9cad 100644 (file)
@@ -99,24 +99,23 @@ MachineBasicBlock& MachineBasicBlock::get(const BasicBlock *BB) {
 //                for a given Function.
 // 
 MachineFunction&
-MachineFunction::construct(const Function *M, const TargetMachine &Tar)
+MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
 {
-  assert(M->getAnnotation(MCFM_AID) == 0 &&
+  assert(Fn->getAnnotation(MCFM_AID) == 0 &&
          "Object already exists for this function!");
-  MachineFunction* mcInfo = new MachineFunction(M, Tar);
-  M->addAnnotation(mcInfo);
+  MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
+  Fn->addAnnotation(mcInfo);
   return *mcInfo;
 }
 
 void
-MachineFunction::destruct(const Function *M)
+MachineFunction::destruct(const Function *Fn)
 {
-  bool Deleted = M->deleteAnnotation(MCFM_AID);
+  bool Deleted = Fn->deleteAnnotation(MCFM_AID);
   assert(Deleted && "Machine code did not exist for function!");
 }
 
-MachineFunction&
-MachineFunction::get(const Function *F)
+MachineFunction& MachineFunction::get(const Function *F)
 {
   MachineFunction *mc = (MachineFunction*)F->getAnnotation(MCFM_AID);
   assert(mc && "Call construct() method first to allocate the object");
@@ -191,15 +190,15 @@ SizeToAlignment(unsigned int size, const TargetMachine& target)
 
 /*ctor*/
 MachineFunction::MachineFunction(const Function *F,
-                                           const TargetMachine& target)
+                                 const TargetMachine& target)
   : Annotation(MCFM_AID),
-    method(F), staticStackSize(0),
+    Fn(F), Target(target), staticStackSize(0),
     automaticVarsSize(0), regSpillsSize(0),
     maxOptionalArgsSize(0), maxOptionalNumArgs(0),
     currentTmpValuesSize(0), maxTmpValuesSize(0), compiledAsLeaf(false),
     spillsAreaFrozen(false), automaticVarsAreaFrozen(false)
 {
-  maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, method,
+  maxOptionalArgsSize = ComputeMaxOptionalArgsSize(target, Fn,
                                                    maxOptionalNumArgs);
   staticStackSize = maxOptionalArgsSize
                     + target.getFrameInfo().getMinStackFrameSize();
@@ -310,10 +309,10 @@ MachineFunction::getOffset(const Value* val) const
 void
 MachineFunction::dump() const
 {
-  std::cerr << "\n" << method->getReturnType()
-            << " \"" << method->getName() << "\"\n";
+  std::cerr << "\n" << Fn->getReturnType()
+            << " \"" << Fn->getName() << "\"\n";
   
-  for (Function::const_iterator BB = method->begin(); BB != method->end(); ++BB)
+  for (Function::const_iterator BB = Fn->begin(); BB != Fn->end(); ++BB)
     {
       std::cerr << "\n" << BB->getName() << " (" << (const void*)BB
                 << ")" << ":" << "\n";
@@ -321,5 +320,5 @@ MachineFunction::dump() const
       for (unsigned i=0; i < mvec.size(); i++)
        std::cerr << "\t" << *mvec[i];
     } 
-  std::cerr << "\nEnd function \"" << method->getName() << "\"\n\n";
+  std::cerr << "\nEnd function \"" << Fn->getName() << "\"\n\n";
 }