class TargetData;
class TargetRegisterClass;
class Type;
+class MachineDebugInfo;
class MachineFunction;
class MachineFrameInfo {
/// to be allocated on entry to the function.
///
unsigned StackSize;
+
+ /// MaxAlignment - The prolog/epilog code inserter may process objects
+ /// that require greater alignment than the default alignment the target
+ /// provides. To handle this, MaxAlignment is set to the maximum alignment
+ /// needed by the objects on the current frame. If this is greater than the
+ /// native alignment maintained by the compiler, dynamic alignment code will
+ /// be needed.
+ ///
+ unsigned MaxAlignment;
/// HasCalls - Set to true if this function has any function calls. This is
/// only valid during and after prolog/epilog code insertion.
/// insertion.
///
unsigned MaxCallFrameSize;
+
+ /// DebugInfo - This field is set (via setMachineDebugInfo) by a debug info
+ /// consumer (ex. DwarfWriter) to indicate that frame layout information
+ /// should be acquired. Typically, it's the responsibility of the target's
+ /// MRegisterInfo prologue/epilogue emitting code to inform MachineDebugInfo
+ /// of frame layouts.
+ MachineDebugInfo *DebugInfo;
+
public:
MachineFrameInfo() {
- NumFixedObjects = StackSize = 0;
+ NumFixedObjects = StackSize = MaxAlignment = 0;
HasVarSizedObjects = false;
HasCalls = false;
MaxCallFrameSize = 0;
+ DebugInfo = 0;
}
/// hasStackObjects - Return true if there are any stack objects in this
///
void setStackSize(unsigned Size) { StackSize = Size; }
+ /// getMaxAlignment - Return the alignment in bytes that this function must be
+ /// aligned to, which is greater than the default stack alignment provided by
+ /// the target.
+ ///
+ unsigned getMaxAlignment() const { return MaxAlignment; }
+
+ /// setMaxAlignment - Set the preferred alignment.
+ ///
+ void setMaxAlignment(unsigned Align) { MaxAlignment = Align; }
+
/// hasCalls - Return true if the current function has no function calls.
/// This is only valid during or after prolog/epilog code emission.
///
/// a postive identifier to represent it.
///
int CreateStackObject(unsigned Size, unsigned Alignment) {
+ // Keep track of the maximum alignment.
+ if (MaxAlignment < Alignment) MaxAlignment = Alignment;
+
assert(Size != 0 && "Cannot allocate zero size stack objects!");
Objects.push_back(StackObject(Size, Alignment, -1));
return Objects.size()-NumFixedObjects-1;
}
- /// CreateStackObject - Create a stack object for a value of the specified
- /// LLVM type.
- ///
- int CreateStackObject(const Type *Ty, const TargetData &TD);
-
/// CreateVariableSizedObject - Notify the MachineFrameInfo object that a
/// variable sized object has been created. This must be created whenever a
/// variable sized object is created, whether or not the index returned is
///
int CreateVariableSizedObject() {
HasVarSizedObjects = true;
+ if (MaxAlignment < 1) MaxAlignment = 1;
Objects.push_back(StackObject(0, 1, -1));
return Objects.size()-NumFixedObjects-1;
}
+ /// getMachineDebugInfo - Used by a prologue/epilogue emitter (MRegisterInfo)
+ /// to provide frame layout information.
+ MachineDebugInfo *getMachineDebugInfo() const { return DebugInfo; }
+
+ /// setMachineDebugInfo - Used by a debug consumer (DwarfWriter) to indicate
+ /// that frame layout information should be gathered.
+ void setMachineDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; }
+
/// print - Used by the MachineFunction printer to print information about
/// stack objects. Implemented in MachineFunction.cpp
///