Convert to the new MachineFunctionInfo interface
authorChris Lattner <sabre@nondot.org>
Wed, 18 Aug 2004 18:13:37 +0000 (18:13 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 18 Aug 2004 18:13:37 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15904 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SparcV9/MachineCodeForInstruction.cpp
lib/Target/SparcV9/MachineFunctionInfo.cpp
lib/Target/SparcV9/MachineFunctionInfo.h
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9BurgISel.cpp
lib/Target/SparcV9/SparcV9FrameInfo.cpp
lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp
lib/Target/SparcV9/SparcV9RegInfo.cpp
lib/Target/SparcV9/SparcV9StackSlots.cpp
lib/Target/SparcV9/SparcV9TargetMachine.cpp

index 96cedbacedcb373ba3aaabed824b0e8410ba2652..44cf57247fc1e54ab375aca63e42006e9838b285 100644 (file)
@@ -35,11 +35,11 @@ using namespace llvm;
 
 MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
   MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
-  return MF.getInfo()->MCFIEntries[I];
+  return MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries[I];
 }
 void MachineCodeForInstruction::destroy(const Instruction *I) {
   MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
-  MF.getInfo()->MCFIEntries.erase(I);
+  MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries.erase(I);
 }
 
 void
index eb66aa00ec28ec9e1de14cb00a56eb294907d634..f308bf5f66845a618aa44785f35d98a4ffc7a8ab 100644 (file)
@@ -1,4 +1,4 @@
-//===-- MachineFunctionInfo.cpp -------------------------------------------===//
+//===-- SparcV9FunctionInfo.cpp -------------------------------------------===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
 #include "llvm/Target/TargetFrameInfo.h"
 using namespace llvm;
 
-MachineFunctionInfo *MachineFunction::getInfo() const {
-  if (!MFInfo) {
-    MFInfo = new MachineFunctionInfo(*const_cast<MachineFunction*>(this));
-  }
-  return static_cast<MachineFunctionInfo*>(MFInfo);
-}
-
-
-
 static unsigned
 ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
                            unsigned &maxOptionalNumArgs)
@@ -78,7 +69,7 @@ SizeToAlignment(unsigned size, const TargetMachine& target)
 }
 
 
-void MachineFunctionInfo::CalculateArgSize() {
+void SparcV9FunctionInfo::CalculateArgSize() {
   maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
                                                   MF.getFunction(),
                                                    maxOptionalNumArgs);
@@ -86,7 +77,7 @@ void MachineFunctionInfo::CalculateArgSize() {
 }
 
 int
-MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
+SparcV9FunctionInfo::computeOffsetforLocalVar(const Value* val,
                                              unsigned &getPaddedSize,
                                              unsigned  sizeToUse)
 {
@@ -112,7 +103,7 @@ MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
 }
 
 
-int MachineFunctionInfo::allocateLocalVar(const Value* val,
+int SparcV9FunctionInfo::allocateLocalVar(const Value* val,
                                           unsigned sizeToUse) {
   assert(! automaticVarsAreaFrozen &&
          "Size of auto vars area has been used to compute an offset so "
@@ -132,7 +123,7 @@ int MachineFunctionInfo::allocateLocalVar(const Value* val,
 }
 
 int
-MachineFunctionInfo::allocateSpilledValue(const Type* type)
+SparcV9FunctionInfo::allocateSpilledValue(const Type* type)
 {
   assert(! spillsAreaFrozen &&
          "Size of reg spills area has been used to compute an offset so "
@@ -156,7 +147,7 @@ MachineFunctionInfo::allocateSpilledValue(const Type* type)
 }
 
 int
-MachineFunctionInfo::pushTempValue(unsigned size)
+SparcV9FunctionInfo::pushTempValue(unsigned size)
 {
   unsigned align = SizeToAlignment(size, MF.getTarget());
 
@@ -175,6 +166,6 @@ MachineFunctionInfo::pushTempValue(unsigned size)
   return aligned;
 }
 
-void MachineFunctionInfo::popAllTempValues() {
+void SparcV9FunctionInfo::popAllTempValues() {
   resetTmpAreaSize();            // clear tmp area to reuse
 }
index f0c970f9ff7a48c2afdab80b95651af8fc1861db..70bbccded589cdc9dcacd1b39fb700ff36b8a677 100644 (file)
@@ -1,4 +1,4 @@
-//===-- MachineFunctionInfo.h -----------------------------------*- C++ -*-===//
+//===-- SparcV9FunctionInfo.h -----------------------------------*- C++ -*-===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
@@ -29,7 +29,7 @@ class MachineFunction;
 class Constant;
 class Type;
 
-class MachineFunctionInfo : public MachineFunctionInfoBase {
+class SparcV9FunctionInfo : public MachineFunctionInfo {
   hash_set<const Constant*> constantsForConstPool;
   hash_map<const Value*, int> offsets;
 
@@ -48,7 +48,7 @@ class MachineFunctionInfo : public MachineFunctionInfoBase {
 public:
   hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries;
 
-  MachineFunctionInfo(MachineFunction &mf) : MF(mf) {
+  SparcV9FunctionInfo(MachineFunction &mf) : MF(mf) {
     staticStackSize = automaticVarsSize = regSpillsSize = 0;
     maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
     maxTmpValuesSize = 0;
index 073724982bf2941305139697d23db3be49a319d8..2fd8e558fdc7d7773e19dd1a5e3e9a3d20463e23 100644 (file)
@@ -424,7 +424,7 @@ void PhyRegAlloc::updateInstruction(MachineBasicBlock::iterator& MII,
   unsigned Opcode = MInst->getOpcode();
 
   // Reset tmp stack positions so they can be reused for each machine instr.
-  MF->getInfo()->popAllTempValues();  
+  MF->getInfo<SparcV9FunctionInfo>()->popAllTempValues();  
 
   // Mark the operands for which regs have been allocated.
   bool instrNeedsSpills = markAllocatedRegs(MII);
@@ -643,7 +643,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
   }
 #endif
 
-  MF->getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType));
+  MF->getInfo<SparcV9FunctionInfo>()->pushTempValue(MRI.getSpilledRegSize(RegType));
   
   std::vector<MachineInstr*> MIBef, MIAft;
   std::vector<MachineInstr*> AdIMid;
@@ -796,7 +796,7 @@ PhyRegAlloc::insertCallerSavingCode(std::vector<MachineInstr*> &instrnsBefore,
            // and add them to InstrnsBefore and InstrnsAfter of the
            // call instruction
            int StackOff =
-              MF->getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType));
+              MF->getInfo<SparcV9FunctionInfo>()->pushTempValue(MRI.getSpilledRegSize(RegType));
             
            //---- Insert code for pushing the reg on stack ----------
             
@@ -895,7 +895,7 @@ int PhyRegAlloc::getUsableUniRegAtMI(const int RegType,
     // we couldn't find an unused register. Generate code to free up a reg by
     // saving it on stack and restoring after the instruction
     
-    int TmpOff = MF->getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType));
+    int TmpOff = MF->getInfo<SparcV9FunctionInfo>()->pushTempValue(MRI.getSpilledRegSize(RegType));
     
     RegU = getUniRegNotUsedByThisInst(RC, RegType, MInst);
     
@@ -1103,7 +1103,7 @@ void PhyRegAlloc::allocateStackSpace4SpilledLRs() {
     if (HMI->first && HMI->second) {
       LiveRange *L = HMI->second;       // get the LiveRange
       if (L->isMarkedForSpill()) {      // NOTE: allocating size of long Type **
-        int stackOffset = MF->getInfo()->allocateSpilledValue(Type::LongTy);
+        int stackOffset = MF->getInfo<SparcV9FunctionInfo>()->allocateSpilledValue(Type::LongTy);
         L->setSpillOffFromFP(stackOffset);
         if (DEBUG_RA)
           std::cerr << "  LR# " << L->getUserIGNode()->getIndex()
@@ -1323,7 +1323,7 @@ bool PhyRegAlloc::runOnFunction (Function &F) {
 
   // Reset the temp. area on the stack before use by the first instruction.
   // This will also happen after updating each instruction.
-  MF->getInfo()->popAllTempValues();
+  MF->getInfo<SparcV9FunctionInfo>()->popAllTempValues();
 
   // color incoming args - if the correct color was not received
   // insert code to copy to the correct register
index 895b73bba510f834e698a8539c2c697450119b2f..0b4685c3a47d10fc5e2d15bd4624aa33322e6233 100644 (file)
@@ -1149,7 +1149,7 @@ void CreateCodeToCopyFloatToInt(const TargetMachine& target, Function* F,
   // FIXME: For now, we allocate permanent space because the stack frame
   // manager does not allow locals to be allocated (e.g., for alloca) after
   // a temp is allocated!
-  int offset = MachineFunction::get(F).getInfo()->allocateLocalVar(val); 
+  int offset = MachineFunction::get(F).getInfo<SparcV9FunctionInfo>()->allocateLocalVar(val); 
 
   unsigned FPReg = target.getRegInfo()->getFramePointer();
 
@@ -1248,7 +1248,7 @@ void CreateCodeToCopyIntToFloat(const TargetMachine& target,
          && "Dest type must be float/double");
 
   // Get a stack slot to use for the copy
-  int offset = MachineFunction::get(F).getInfo()->allocateLocalVar(val);
+  int offset = MachineFunction::get(F).getInfo<SparcV9FunctionInfo>()->allocateLocalVar(val);
 
   // Get the size of the source value being copied. 
   size_t srcSize = target.getTargetData().getTypeSize(val->getType());
@@ -2568,7 +2568,7 @@ CreateCodeForFixedSizeAlloca(const TargetMachine& target,
   // You've gotta love having only 13 bits for constant offset values :-|.
   // 
   unsigned paddedSize;
-  int offsetFromFP = mcInfo.getInfo()->computeOffsetforLocalVar(result,
+  int offsetFromFP = mcInfo.getInfo<SparcV9FunctionInfo>()->computeOffsetforLocalVar(result,
                                                                 paddedSize,
                                                          tsize * numElements);
 
@@ -2581,7 +2581,7 @@ CreateCodeForFixedSizeAlloca(const TargetMachine& target,
   }
   
   // else offset fits in immediate field so go ahead and allocate it.
-  offsetFromFP = mcInfo.getInfo()->allocateLocalVar(result, tsize *numElements);
+  offsetFromFP = mcInfo.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(result, tsize *numElements);
   
   // Create a temporary Value to hold the constant offset.
   // This is needed because it may not fit in the immediate field.
@@ -3924,8 +3924,8 @@ void GetInstructionsByRule(InstructionNode* subtreeRoot, int ruleForNode,
                 // allocated (e.g., for alloca) after a temp is
                 // allocated!
                 // 
-                // int tmpOffset = MF.getInfo()->pushTempValue(argSize);
-                int tmpOffset = MF.getInfo()->allocateLocalVar(argVReg);
+                // int tmpOffset = MF.getInfo<SparcV9FunctionInfo>()->pushTempValue(argSize);
+                int tmpOffset = MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(argVReg);
                     
                 // Generate the store from FP reg to stack
                 unsigned StoreOpcode = ChooseStoreInstruction(argType);
@@ -4083,7 +4083,7 @@ void GetInstructionsByRule(InstructionNode* subtreeRoot, int ruleForNode,
           if (isa<Function>(callee))
             callMI->addImplicitRef(retAddrReg, /*isDef*/ true);
 
-          MF.getInfo()->popAllTempValues();  // free temps used for this inst
+          MF.getInfo<SparcV9FunctionInfo>()->popAllTempValues();  // free temps used for this inst
         }
 
         break;
index 59e8113b8a7df161add9990d970b9675393fa202..bdddad6be912c95204bde5ac582f40af29c5c8ca 100644 (file)
@@ -22,15 +22,15 @@ int
 SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const 
 {
   // ensure no more auto vars are added
-  mcInfo.getInfo()->freezeAutomaticVarsArea();
+  mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea();
   
   pos = false;                          // static stack area grows downwards
-  unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize();
+  unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize();
   return StaticAreaOffsetFromFP - autoVarsSize; 
 }
 
 int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const {
-  MachineFunctionInfo *MFI = mcInfo.getInfo();
+  SparcV9FunctionInfo *MFI = mcInfo.getInfo<SparcV9FunctionInfo>();
   MFI->freezeAutomaticVarsArea();     // ensure no more auto vars are added
   MFI->freezeSpillsArea();            // ensure no more spill slots are added
   
@@ -48,7 +48,7 @@ SparcV9FrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& pos) const
   // during calls and traps, so they are shifted downwards on each
   // dynamic-size alloca.
   pos = false;
-  unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize();
+  unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize();
   if (int extra = optArgsSize % 16)
     optArgsSize += (16 - extra);
   int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
index 419b1108a7c8dfb34da638ef4d0894fc2856ffdf..47cab90601a124114ff9934734189930727eb545 100644 (file)
@@ -36,7 +36,7 @@ namespace {
     const char *getPassName() const { return "SparcV9 Prolog/Epilog Inserter"; }
     
     bool runOnMachineFunction(MachineFunction &F) {
-      if (!F.getInfo()->isCompiledAsLeafMethod()) {
+      if (!F.getInfo<SparcV9FunctionInfo>()->isCompiledAsLeafMethod()) {
         InsertPrologCode(F);
         InsertEpilogCode(F);
       }
@@ -51,7 +51,7 @@ namespace {
 
 static unsigned getStaticStackSize (MachineFunction &MF) {
   const TargetFrameInfo& frameInfo = *MF.getTarget().getFrameInfo();
-  unsigned staticStackSize = MF.getInfo()->getStaticStackSize();
+  unsigned staticStackSize = MF.getInfo<SparcV9FunctionInfo>()->getStaticStackSize();
   if (staticStackSize < (unsigned)SparcV9FrameInfo::MinStackFrameSize)
     staticStackSize = SparcV9FrameInfo::MinStackFrameSize;
   if (unsigned padsz = staticStackSize % 
index 7e6281941cd7a7457621667373ad1a87404a135e..e5f4073603868ca74e39371cfaad66cfb8633127 100644 (file)
@@ -466,7 +466,7 @@ void SparcV9RegInfo::colorMethodArgs(const Function *Meth,
                  regClassIDOfArgReg == IntRegClassID &&
                  "This should only be an Int register for an FP argument");
           
-         int TmpOff = MachineFunction::get(Meth).getInfo()->pushTempValue(
+         int TmpOff = MachineFunction::get(Meth).getInfo<SparcV9FunctionInfo>()->pushTempValue(
                                                 getSpilledRegSize(regType));
          cpReg2MemMI(InstrnsBefore,
                       UniArgReg, getFramePointer(), TmpOff, IntRegType);
index 693d29e50d9957f7eeb546e6cc69c68fbb5090dc..90aca0d86456a9519b2bdcb6e9fd71ac25a7800e 100644 (file)
@@ -40,7 +40,7 @@ namespace {
       unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
       
       Value *V = Constant::getNullValue(Type::IntTy);
-      MF.getInfo()->allocateLocalVar(V, 2*Size);
+      MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size);
       return true;
     }
   };
index bca50ab083d6a393a8bd0a86347daa0ec9bddb75..29a208c68c1a0e9d5f0befeb9eda832ca04e8f04 100644 (file)
@@ -98,7 +98,7 @@ namespace {
     }
     
     bool runOnFunction(Function &F) {
-      MachineFunction::construct(&F, Target).getInfo()->CalculateArgSize();
+      MachineFunction::construct(&F, Target).getInfo<SparcV9FunctionInfo>()->CalculateArgSize();
       return false;
     }
   };