From 1ce075bcaa841f213c17d645a6fe39a9d5d5f941 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 25 Jan 2008 07:19:06 +0000 Subject: [PATCH] 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 --- include/llvm/CodeGen/MachineFrameInfo.h | 25 +++++++++++++------------ lib/CodeGen/MachineFunction.cpp | 15 ++++++++++++++- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 0aad1838914..43166838bb5 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -19,6 +19,7 @@ class TargetRegisterClass; class Type; class MachineModuleInfo; class MachineFunction; +class TargetFrameInfo; /// The CalleeSavedInfo class tracks the information need to locate where a /// callee saved register in the current frame. @@ -82,17 +83,17 @@ class MachineFrameInfo { // Alignment - The required alignment of this stack slot. 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 // entering the function and is not modified inside the function. By // default, fixed objects are immutable unless marked otherwise. 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) - : Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {} + : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {} }; /// Objects - The list of stack objects allocated... @@ -159,8 +160,11 @@ class MachineFrameInfo { /// of frame layouts. MachineModuleInfo *MMI; + /// TargetFrameInfo - Target information about frame layout. + /// + const TargetFrameInfo &TFI; public: - MachineFrameInfo() { + MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; HasVarSizedObjects = false; HasCalls = false; @@ -264,12 +268,9 @@ public: /// index with a negative value. /// int CreateFixedObject(uint64_t Size, int64_t SPOffset, - bool Immutable = true) { - assert(Size != 0 && "Cannot allocate zero size fixed stack objects!"); - Objects.insert(Objects.begin(), StackObject(Size, 1, SPOffset, Immutable)); - return -++NumFixedObjects; - } - + bool Immutable = true); + + /// isFixedObjectIndex - Returns true if the specified index corresponds to a /// fixed stack object. bool isFixedObjectIndex(int ObjectIdx) const { diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 3f2c1194863..8c9bbf3293c 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -126,7 +126,7 @@ MachineFunction::MachineFunction(const Function *F, : Annotation(MF_AID), Fn(F), Target(TM) { RegInfo = new MachineRegisterInfo(*TM.getRegisterInfo()); MFInfo = 0; - FrameInfo = new MachineFrameInfo(); + FrameInfo = new MachineFrameInfo(*TM.getFrameInfo()); ConstantPool = new MachineConstantPool(TM.getTargetData()); // Set up jump table. @@ -331,6 +331,19 @@ MachineFunction& MachineFunction::get(const Function *F) // 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{ int ValOffset = MF.getTarget().getFrameInfo()->getOffsetOfLocalArea();