Convert to the new MachineFunctionInfo interface

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2004-08-18 18:13:37 +00:00
parent 8bdf87d1d8
commit a1e51ff2aa
10 changed files with 34 additions and 43 deletions

View File

@@ -35,11 +35,11 @@ using namespace llvm;
MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){ MachineCodeForInstruction &MachineCodeForInstruction::get(const Instruction *I){
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent()); MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
return MF.getInfo()->MCFIEntries[I]; return MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries[I];
} }
void MachineCodeForInstruction::destroy(const Instruction *I) { void MachineCodeForInstruction::destroy(const Instruction *I) {
MachineFunction &MF = MachineFunction::get(I->getParent()->getParent()); MachineFunction &MF = MachineFunction::get(I->getParent()->getParent());
MF.getInfo()->MCFIEntries.erase(I); MF.getInfo<SparcV9FunctionInfo>()->MCFIEntries.erase(I);
} }
void void

View File

@@ -1,4 +1,4 @@
//===-- MachineFunctionInfo.cpp -------------------------------------------===// //===-- SparcV9FunctionInfo.cpp -------------------------------------------===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@@ -20,15 +20,6 @@
#include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetFrameInfo.h"
using namespace llvm; using namespace llvm;
MachineFunctionInfo *MachineFunction::getInfo() const {
if (!MFInfo) {
MFInfo = new MachineFunctionInfo(*const_cast<MachineFunction*>(this));
}
return static_cast<MachineFunctionInfo*>(MFInfo);
}
static unsigned static unsigned
ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F, ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
unsigned &maxOptionalNumArgs) unsigned &maxOptionalNumArgs)
@@ -78,7 +69,7 @@ SizeToAlignment(unsigned size, const TargetMachine& target)
} }
void MachineFunctionInfo::CalculateArgSize() { void SparcV9FunctionInfo::CalculateArgSize() {
maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(), maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
MF.getFunction(), MF.getFunction(),
maxOptionalNumArgs); maxOptionalNumArgs);
@@ -86,7 +77,7 @@ void MachineFunctionInfo::CalculateArgSize() {
} }
int int
MachineFunctionInfo::computeOffsetforLocalVar(const Value* val, SparcV9FunctionInfo::computeOffsetforLocalVar(const Value* val,
unsigned &getPaddedSize, unsigned &getPaddedSize,
unsigned sizeToUse) 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) { unsigned sizeToUse) {
assert(! automaticVarsAreaFrozen && assert(! automaticVarsAreaFrozen &&
"Size of auto vars area has been used to compute an offset so " "Size of auto vars area has been used to compute an offset so "
@@ -132,7 +123,7 @@ int MachineFunctionInfo::allocateLocalVar(const Value* val,
} }
int int
MachineFunctionInfo::allocateSpilledValue(const Type* type) SparcV9FunctionInfo::allocateSpilledValue(const Type* type)
{ {
assert(! spillsAreaFrozen && assert(! spillsAreaFrozen &&
"Size of reg spills area has been used to compute an offset so " "Size of reg spills area has been used to compute an offset so "
@@ -156,7 +147,7 @@ MachineFunctionInfo::allocateSpilledValue(const Type* type)
} }
int int
MachineFunctionInfo::pushTempValue(unsigned size) SparcV9FunctionInfo::pushTempValue(unsigned size)
{ {
unsigned align = SizeToAlignment(size, MF.getTarget()); unsigned align = SizeToAlignment(size, MF.getTarget());
@@ -175,6 +166,6 @@ MachineFunctionInfo::pushTempValue(unsigned size)
return aligned; return aligned;
} }
void MachineFunctionInfo::popAllTempValues() { void SparcV9FunctionInfo::popAllTempValues() {
resetTmpAreaSize(); // clear tmp area to reuse resetTmpAreaSize(); // clear tmp area to reuse
} }

View File

@@ -1,4 +1,4 @@
//===-- MachineFunctionInfo.h -----------------------------------*- C++ -*-===// //===-- SparcV9FunctionInfo.h -----------------------------------*- C++ -*-===//
// //
// The LLVM Compiler Infrastructure // The LLVM Compiler Infrastructure
// //
@@ -29,7 +29,7 @@ class MachineFunction;
class Constant; class Constant;
class Type; class Type;
class MachineFunctionInfo : public MachineFunctionInfoBase { class SparcV9FunctionInfo : public MachineFunctionInfo {
hash_set<const Constant*> constantsForConstPool; hash_set<const Constant*> constantsForConstPool;
hash_map<const Value*, int> offsets; hash_map<const Value*, int> offsets;
@@ -48,7 +48,7 @@ class MachineFunctionInfo : public MachineFunctionInfoBase {
public: public:
hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries; hash_map<const Instruction*, MachineCodeForInstruction> MCFIEntries;
MachineFunctionInfo(MachineFunction &mf) : MF(mf) { SparcV9FunctionInfo(MachineFunction &mf) : MF(mf) {
staticStackSize = automaticVarsSize = regSpillsSize = 0; staticStackSize = automaticVarsSize = regSpillsSize = 0;
maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0; maxOptionalArgsSize = maxOptionalNumArgs = currentTmpValuesSize = 0;
maxTmpValuesSize = 0; maxTmpValuesSize = 0;

View File

@@ -424,7 +424,7 @@ void PhyRegAlloc::updateInstruction(MachineBasicBlock::iterator& MII,
unsigned Opcode = MInst->getOpcode(); unsigned Opcode = MInst->getOpcode();
// Reset tmp stack positions so they can be reused for each machine instr. // 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. // Mark the operands for which regs have been allocated.
bool instrNeedsSpills = markAllocatedRegs(MII); bool instrNeedsSpills = markAllocatedRegs(MII);
@@ -643,7 +643,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
} }
#endif #endif
MF->getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType)); MF->getInfo<SparcV9FunctionInfo>()->pushTempValue(MRI.getSpilledRegSize(RegType));
std::vector<MachineInstr*> MIBef, MIAft; std::vector<MachineInstr*> MIBef, MIAft;
std::vector<MachineInstr*> AdIMid; std::vector<MachineInstr*> AdIMid;
@@ -796,7 +796,7 @@ PhyRegAlloc::insertCallerSavingCode(std::vector<MachineInstr*> &instrnsBefore,
// and add them to InstrnsBefore and InstrnsAfter of the // and add them to InstrnsBefore and InstrnsAfter of the
// call instruction // call instruction
int StackOff = int StackOff =
MF->getInfo()->pushTempValue(MRI.getSpilledRegSize(RegType)); MF->getInfo<SparcV9FunctionInfo>()->pushTempValue(MRI.getSpilledRegSize(RegType));
//---- Insert code for pushing the reg on stack ---------- //---- 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 // we couldn't find an unused register. Generate code to free up a reg by
// saving it on stack and restoring after the instruction // 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); RegU = getUniRegNotUsedByThisInst(RC, RegType, MInst);
@@ -1103,7 +1103,7 @@ void PhyRegAlloc::allocateStackSpace4SpilledLRs() {
if (HMI->first && HMI->second) { if (HMI->first && HMI->second) {
LiveRange *L = HMI->second; // get the LiveRange LiveRange *L = HMI->second; // get the LiveRange
if (L->isMarkedForSpill()) { // NOTE: allocating size of long Type ** 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); L->setSpillOffFromFP(stackOffset);
if (DEBUG_RA) if (DEBUG_RA)
std::cerr << " LR# " << L->getUserIGNode()->getIndex() 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. // Reset the temp. area on the stack before use by the first instruction.
// This will also happen after updating each 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 // color incoming args - if the correct color was not received
// insert code to copy to the correct register // insert code to copy to the correct register

View File

@@ -1149,7 +1149,7 @@ void CreateCodeToCopyFloatToInt(const TargetMachine& target, Function* F,
// FIXME: For now, we allocate permanent space because the stack frame // FIXME: For now, we allocate permanent space because the stack frame
// manager does not allow locals to be allocated (e.g., for alloca) after // manager does not allow locals to be allocated (e.g., for alloca) after
// a temp is allocated! // 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(); unsigned FPReg = target.getRegInfo()->getFramePointer();
@@ -1248,7 +1248,7 @@ void CreateCodeToCopyIntToFloat(const TargetMachine& target,
&& "Dest type must be float/double"); && "Dest type must be float/double");
// Get a stack slot to use for the copy // 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. // Get the size of the source value being copied.
size_t srcSize = target.getTargetData().getTypeSize(val->getType()); 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 :-|. // You've gotta love having only 13 bits for constant offset values :-|.
// //
unsigned paddedSize; unsigned paddedSize;
int offsetFromFP = mcInfo.getInfo()->computeOffsetforLocalVar(result, int offsetFromFP = mcInfo.getInfo<SparcV9FunctionInfo>()->computeOffsetforLocalVar(result,
paddedSize, paddedSize,
tsize * numElements); tsize * numElements);
@@ -2581,7 +2581,7 @@ CreateCodeForFixedSizeAlloca(const TargetMachine& target,
} }
// else offset fits in immediate field so go ahead and allocate it. // 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. // Create a temporary Value to hold the constant offset.
// This is needed because it may not fit in the immediate field. // 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 (e.g., for alloca) after a temp is
// allocated! // allocated!
// //
// int tmpOffset = MF.getInfo()->pushTempValue(argSize); // int tmpOffset = MF.getInfo<SparcV9FunctionInfo>()->pushTempValue(argSize);
int tmpOffset = MF.getInfo()->allocateLocalVar(argVReg); int tmpOffset = MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(argVReg);
// Generate the store from FP reg to stack // Generate the store from FP reg to stack
unsigned StoreOpcode = ChooseStoreInstruction(argType); unsigned StoreOpcode = ChooseStoreInstruction(argType);
@@ -4083,7 +4083,7 @@ void GetInstructionsByRule(InstructionNode* subtreeRoot, int ruleForNode,
if (isa<Function>(callee)) if (isa<Function>(callee))
callMI->addImplicitRef(retAddrReg, /*isDef*/ true); 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; break;

View File

@@ -22,15 +22,15 @@ int
SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const SparcV9FrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& pos) const
{ {
// ensure no more auto vars are added // ensure no more auto vars are added
mcInfo.getInfo()->freezeAutomaticVarsArea(); mcInfo.getInfo<SparcV9FunctionInfo>()->freezeAutomaticVarsArea();
pos = false; // static stack area grows downwards pos = false; // static stack area grows downwards
unsigned autoVarsSize = mcInfo.getInfo()->getAutomaticVarsSize(); unsigned autoVarsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getAutomaticVarsSize();
return StaticAreaOffsetFromFP - autoVarsSize; return StaticAreaOffsetFromFP - autoVarsSize;
} }
int SparcV9FrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& pos) const { 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->freezeAutomaticVarsArea(); // ensure no more auto vars are added
MFI->freezeSpillsArea(); // ensure no more spill slots 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 // during calls and traps, so they are shifted downwards on each
// dynamic-size alloca. // dynamic-size alloca.
pos = false; pos = false;
unsigned optArgsSize = mcInfo.getInfo()->getMaxOptionalArgsSize(); unsigned optArgsSize = mcInfo.getInfo<SparcV9FunctionInfo>()->getMaxOptionalArgsSize();
if (int extra = optArgsSize % 16) if (int extra = optArgsSize % 16)
optArgsSize += (16 - extra); optArgsSize += (16 - extra);
int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP; int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;

View File

@@ -36,7 +36,7 @@ namespace {
const char *getPassName() const { return "SparcV9 Prolog/Epilog Inserter"; } const char *getPassName() const { return "SparcV9 Prolog/Epilog Inserter"; }
bool runOnMachineFunction(MachineFunction &F) { bool runOnMachineFunction(MachineFunction &F) {
if (!F.getInfo()->isCompiledAsLeafMethod()) { if (!F.getInfo<SparcV9FunctionInfo>()->isCompiledAsLeafMethod()) {
InsertPrologCode(F); InsertPrologCode(F);
InsertEpilogCode(F); InsertEpilogCode(F);
} }
@@ -51,7 +51,7 @@ namespace {
static unsigned getStaticStackSize (MachineFunction &MF) { static unsigned getStaticStackSize (MachineFunction &MF) {
const TargetFrameInfo& frameInfo = *MF.getTarget().getFrameInfo(); const TargetFrameInfo& frameInfo = *MF.getTarget().getFrameInfo();
unsigned staticStackSize = MF.getInfo()->getStaticStackSize(); unsigned staticStackSize = MF.getInfo<SparcV9FunctionInfo>()->getStaticStackSize();
if (staticStackSize < (unsigned)SparcV9FrameInfo::MinStackFrameSize) if (staticStackSize < (unsigned)SparcV9FrameInfo::MinStackFrameSize)
staticStackSize = SparcV9FrameInfo::MinStackFrameSize; staticStackSize = SparcV9FrameInfo::MinStackFrameSize;
if (unsigned padsz = staticStackSize % if (unsigned padsz = staticStackSize %

View File

@@ -466,7 +466,7 @@ void SparcV9RegInfo::colorMethodArgs(const Function *Meth,
regClassIDOfArgReg == IntRegClassID && regClassIDOfArgReg == IntRegClassID &&
"This should only be an Int register for an FP argument"); "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)); getSpilledRegSize(regType));
cpReg2MemMI(InstrnsBefore, cpReg2MemMI(InstrnsBefore,
UniArgReg, getFramePointer(), TmpOff, IntRegType); UniArgReg, getFramePointer(), TmpOff, IntRegType);

View File

@@ -40,7 +40,7 @@ namespace {
unsigned Size = Target.getTargetData().getTypeSize(PtrInt); unsigned Size = Target.getTargetData().getTypeSize(PtrInt);
Value *V = Constant::getNullValue(Type::IntTy); Value *V = Constant::getNullValue(Type::IntTy);
MF.getInfo()->allocateLocalVar(V, 2*Size); MF.getInfo<SparcV9FunctionInfo>()->allocateLocalVar(V, 2*Size);
return true; return true;
} }
}; };

View File

@@ -98,7 +98,7 @@ namespace {
} }
bool runOnFunction(Function &F) { bool runOnFunction(Function &F) {
MachineFunction::construct(&F, Target).getInfo()->CalculateArgSize(); MachineFunction::construct(&F, Target).getInfo<SparcV9FunctionInfo>()->CalculateArgSize();
return false; return false;
} }
}; };