move MachineFrameInfo::CreateFixedObject out of line, give MachineFrameInfo

a reference to TargetFrameInfo.  Rearrange order of fields in StackObject to
save a word.

llvm-svn: 46348
This commit is contained in:
Chris Lattner 2008-01-25 07:19:06 +00:00
parent 74d4792eb2
commit 1ce075bcaa
2 changed files with 27 additions and 13 deletions

View File

@ -19,6 +19,7 @@ class TargetRegisterClass;
class Type; class Type;
class MachineModuleInfo; class MachineModuleInfo;
class MachineFunction; class MachineFunction;
class TargetFrameInfo;
/// The CalleeSavedInfo class tracks the information need to locate where a /// The CalleeSavedInfo class tracks the information need to locate where a
/// callee saved register in the current frame. /// callee saved register in the current frame.
@ -82,17 +83,17 @@ class MachineFrameInfo {
// Alignment - The required alignment of this stack slot. // Alignment - The required alignment of this stack slot.
unsigned Alignment; unsigned Alignment;
// SPOffset - The offset of this object from the stack pointer on entry to
// the function. This field has no meaning for a variable sized element.
int64_t SPOffset;
// isImmutable - If true, the value of the stack object is set before // isImmutable - If true, the value of the stack object is set before
// entering the function and is not modified inside the function. By // entering the function and is not modified inside the function. By
// default, fixed objects are immutable unless marked otherwise. // default, fixed objects are immutable unless marked otherwise.
bool isImmutable; bool isImmutable;
// SPOffset - The offset of this object from the stack pointer on entry to
// the function. This field has no meaning for a variable sized element.
int64_t SPOffset;
StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false) StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false)
: Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {} : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {}
}; };
/// Objects - The list of stack objects allocated... /// Objects - The list of stack objects allocated...
@ -159,8 +160,11 @@ class MachineFrameInfo {
/// of frame layouts. /// of frame layouts.
MachineModuleInfo *MMI; MachineModuleInfo *MMI;
/// TargetFrameInfo - Target information about frame layout.
///
const TargetFrameInfo &TFI;
public: public:
MachineFrameInfo() { MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
HasVarSizedObjects = false; HasVarSizedObjects = false;
HasCalls = false; HasCalls = false;
@ -264,12 +268,9 @@ public:
/// index with a negative value. /// index with a negative value.
/// ///
int CreateFixedObject(uint64_t Size, int64_t SPOffset, int CreateFixedObject(uint64_t Size, int64_t SPOffset,
bool Immutable = true) { bool Immutable = true);
assert(Size != 0 && "Cannot allocate zero size fixed stack objects!");
Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable));
return -++NumFixedObjects;
}
/// isFixedObjectIndex - Returns true if the specified index corresponds to a /// isFixedObjectIndex - Returns true if the specified index corresponds to a
/// fixed stack object. /// fixed stack object.
bool isFixedObjectIndex(int ObjectIdx) const { bool isFixedObjectIndex(int ObjectIdx) const {

View File

@ -126,7 +126,7 @@ MachineFunction::MachineFunction(const Function *F,
: Annotation(MF_AID), Fn(F), Target(TM) { : Annotation(MF_AID), Fn(F), Target(TM) {
RegInfo = new MachineRegisterInfo(*TM.getRegisterInfo()); RegInfo = new MachineRegisterInfo(*TM.getRegisterInfo());
MFInfo = 0; MFInfo = 0;
FrameInfo = new MachineFrameInfo(); FrameInfo = new MachineFrameInfo(*TM.getFrameInfo());
ConstantPool = new MachineConstantPool(TM.getTargetData()); ConstantPool = new MachineConstantPool(TM.getTargetData());
// Set up jump table. // Set up jump table.
@ -331,6 +331,19 @@ MachineFunction& MachineFunction::get(const Function *F)
// MachineFrameInfo implementation // MachineFrameInfo implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// CreateFixedObject - Create a new object at a fixed location on the stack.
/// All fixed objects should be created before other objects are created for
/// efficiency. By default, fixed objects are immutable. This returns an
/// index with a negative value.
///
int MachineFrameInfo::CreateFixedObject(uint64_t Size, int64_t SPOffset,
bool Immutable) {
assert(Size != 0 && "Cannot allocate zero size fixed stack objects!");
Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable));
return -++NumFixedObjects;
}
void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{ void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
int ValOffset = MF.getTarget().getFrameInfo()->getOffsetOfLocalArea(); int ValOffset = MF.getTarget().getFrameInfo()->getOffsetOfLocalArea();