Revert Christopher Lamb's load/store alignment changes.
[oota-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
index 870d2f16877da33d23a8f9afb7974b273361ccb9..189c5cc97903fc80b183c2e03217514b12e840e2 100644 (file)
@@ -17,9 +17,31 @@ namespace llvm {
 class TargetData;
 class TargetRegisterClass;
 class Type;
-class MachineDebugInfo;
+class MachineModuleInfo;
 class MachineFunction;
 
+/// The CalleeSavedInfo class tracks the information need to locate where a
+/// callee saved register in the current frame.  
+class CalleeSavedInfo {
+
+private:
+  unsigned Reg;
+  const TargetRegisterClass *RegClass;
+  int FrameIdx;
+  
+public:
+  CalleeSavedInfo(unsigned R, const TargetRegisterClass *RC, int FI = 0)
+  : Reg(R)
+  , RegClass(RC)
+  , FrameIdx(FI)
+  {}
+  
+  // Accessors.
+  unsigned getReg()                        const { return Reg; }
+  const TargetRegisterClass *getRegClass() const { return RegClass; }
+  int getFrameIdx()                        const { return FrameIdx; }
+  void setFrameIdx(int FI)                       { FrameIdx = FI; }
+};
 
 /// The MachineFrameInfo class represents an abstract stack frame until
 /// prolog/epilog code is inserted.  This class is key to allowing stack frame
@@ -90,6 +112,14 @@ class MachineFrameInfo {
   ///
   unsigned StackSize;
   
+  /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to
+  /// have the actual offset from the stack/frame pointer.  The calculation is 
+  /// MFI->getObjectOffset(Index) + StackSize - TFI.getOffsetOfLocalArea() +
+  /// OffsetAdjustment.  If OffsetAdjustment is zero (default) then offsets are
+  /// away from TOS. If OffsetAdjustment == StackSize then offsets are toward
+  /// TOS.
+  int OffsetAdjustment;
+  
   /// 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 
@@ -111,20 +141,26 @@ class MachineFrameInfo {
   ///
   unsigned MaxCallFrameSize;
   
-  /// DebugInfo - This field is set (via setMachineDebugInfo) by a debug info
+  /// CSInfo - The prolog/epilog code inserter fills in this vector with each
+  /// callee saved register saved in the frame.  Beyond its use by the prolog/
+  /// epilog code inserter, this data used for debug info and exception
+  /// handling.
+  std::vector<CalleeSavedInfo> CSInfo;
+  
+  /// MMI - This field is set (via setMachineModuleInfo) by a module 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
+  /// MRegisterInfo prologue/epilogue emitting code to inform MachineModuleInfo
   /// of frame layouts.
-  MachineDebugInfo *DebugInfo;
+  MachineModuleInfo *MMI;
   
 public:
   MachineFrameInfo() {
-    NumFixedObjects = StackSize = MaxAlignment = 0;
+    NumFixedObjects = StackSize = OffsetAdjustment = MaxAlignment = 0;
     HasVarSizedObjects = false;
     HasCalls = false;
     MaxCallFrameSize = 0;
-    DebugInfo = 0;
+    MMI = 0;
   }
 
   /// hasStackObjects - Return true if there are any stack objects in this
@@ -184,6 +220,14 @@ public:
   /// setStackSize - Set the size of the stack...
   ///
   void setStackSize(unsigned Size) { StackSize = Size; }
+  
+  /// getOffsetAdjustment - Return the correction for frame offsets.
+  ///
+  int getOffsetAdjustment() const { return OffsetAdjustment; }
+  
+  /// setOffsetAdjustment - Set the correction for frame offsets.
+  ///
+  void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
 
   /// getMaxAlignment - Return the alignment in bytes that this function must be 
   /// aligned to, which is greater than the default stack alignment provided by 
@@ -219,6 +263,12 @@ public:
     return -++NumFixedObjects;
   }
 
+  /// isFixedObjectIndex - Returns true if the specified index corresponds to a
+  /// fixed stack object.
+  bool isFixedObjectIndex(int ObjectIdx) const {
+    return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
+  }
+
   /// CreateStackObject - Create a new statically sized stack object, returning
   /// a postive identifier to represent it.
   ///
@@ -242,14 +292,26 @@ public:
     Objects.push_back(StackObject(0, 1, -1));
     return Objects.size()-NumFixedObjects-1;
   }
+  
+  /// getCalleeSavedInfo - Returns a reference to call saved info vector for the
+  /// current function.
+  const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
+    return CSInfo;
+  }
+
+  /// setCalleeSavedInfo - Used by prolog/epilog inserter to set the function's
+  /// callee saved information.
+  void  setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) {
+    CSInfo = CSI;
+  }
 
-  /// getMachineDebugInfo - Used by a prologue/epilogue emitter (MRegisterInfo)
+  /// getMachineModuleInfo - Used by a prologue/epilogue emitter (MRegisterInfo)
   /// to provide frame layout information. 
-  MachineDebugInfo *getMachineDebugInfo() const { return DebugInfo; }
+  MachineModuleInfo *getMachineModuleInfo() const { return MMI; }
 
-  /// setMachineDebugInfo - Used by a debug consumer (DwarfWriter) to indicate
-  /// that frame layout information should be gathered.
-  void setMachineDebugInfo(MachineDebugInfo *DI) { DebugInfo = DI; }
+  /// setMachineModuleInfo - Used by a meta info consumer (DwarfWriter) to
+  /// indicate that frame layout information should be gathered.
+  void setMachineModuleInfo(MachineModuleInfo *mmi) { MMI = mmi; }
 
   /// print - Used by the MachineFunction printer to print information about
   /// stack objects.  Implemented in MachineFunction.cpp