Finish support for Microsoft ML/MASM. May still be a few rough edges.
[oota-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
index 8f8a852480d8354211ddaee75587d385edc6898d..baeb47c47dfb0194959ab4ac11b8230ebf069eca 100644 (file)
@@ -44,6 +44,7 @@ namespace llvm {
 class TargetData;
 class TargetRegisterClass;
 class Type;
+class MachineDebugInfo;
 class MachineFunction;
 
 class MachineFrameInfo {
@@ -85,6 +86,15 @@ 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.
@@ -97,12 +107,21 @@ class MachineFrameInfo {
   /// 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
@@ -163,6 +182,16 @@ public:
   ///
   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.
   ///
@@ -191,16 +220,14 @@ public:
   /// 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
@@ -208,10 +235,19 @@ public:
   ///
   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
   ///