Initial support for carrying MachineInstrs in SUnits.
[oota-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
index 5ad523fdf4193b5d26c40479bf7c284d78f48fdc..4190bcd9a36c3d26a644056dda21e29c92f69599 100644 (file)
@@ -14,6 +14,9 @@
 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
 
+#include "llvm/Support/DataTypes.h"
+#include <cassert>
+#include <iosfwd>
 #include <vector>
 
 namespace llvm {
@@ -55,7 +58,7 @@ public:
 ///
 /// To support this, the class assigns unique integer identifiers to stack
 /// objects requested clients.  These identifiers are negative integers for
-/// fixed stack objects (such as arguments passed on the stack) or positive
+/// fixed stack objects (such as arguments passed on the stack) or nonnegative
 /// for objects that may be reordered.  Instructions which refer to stack
 /// objects use a special MO_FrameIndex operand to represent these frame
 /// indexes.
@@ -115,6 +118,10 @@ class MachineFrameInfo {
   ///
   bool HasVarSizedObjects;
 
+  /// FrameAddressTaken - This boolean keeps track of whether there is a call
+  /// to builtin @llvm.frameaddress.
+  bool FrameAddressTaken;
+
   /// StackSize - The prolog/epilog code inserter calculates the final stack
   /// offsets for all of the fixed size objects, updating the Objects list
   /// above.  It then updates StackSize to contain the number of bytes that need
@@ -143,6 +150,9 @@ class MachineFrameInfo {
   /// only valid during and after prolog/epilog code insertion.
   bool HasCalls;
 
+  /// StackProtectorIdx - The frame index for the stack protector.
+  int StackProtectorIdx;
+
   /// MaxCallFrameSize - This contains the size of the largest call frame if the
   /// target uses frame setup/destroy pseudo instructions (as defined in the
   /// TargetFrameInfo class).  This information is important for frame pointer
@@ -171,7 +181,9 @@ public:
   MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
     StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
     HasVarSizedObjects = false;
+    FrameAddressTaken = false;
     HasCalls = false;
+    StackProtectorIdx = -1;
     MaxCallFrameSize = 0;
     MMI = 0;
   }
@@ -187,15 +199,34 @@ public:
   ///
   bool hasVarSizedObjects() const { return HasVarSizedObjects; }
 
-  /// getObjectIndexBegin - Return the minimum frame object index...
+  /// getStackProtectorIndex/setStackProtectorIndex - Return the index for the
+  /// stack protector object.
+  ///
+  int getStackProtectorIndex() const { return StackProtectorIdx; }
+  void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
+
+  /// isFrameAddressTaken - This method may be called any time after instruction
+  /// selection is complete to determine if there is a call to
+  /// @llvm.frameaddress in this function.
+  bool isFrameAddressTaken() const { return FrameAddressTaken; }
+  void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
+
+  /// getObjectIndexBegin - Return the minimum frame object index.
   ///
   int getObjectIndexBegin() const { return -NumFixedObjects; }
 
-  /// getObjectIndexEnd - Return one past the maximum frame object index...
+  /// getObjectIndexEnd - Return one past the maximum frame object index.
   ///
   int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
 
-  /// getObjectSize - Return the size of the specified object
+  /// getNumFixedObjects() - Return the number of fixed objects.
+  unsigned getNumFixedObjects() const { return NumFixedObjects; }
+
+  /// getNumObjects() - Return the number of objects.
+  ///
+  unsigned getNumObjects() const { return Objects.size(); }
+
+  /// getObjectSize - Return the size of the specified object.
   ///
   int64_t getObjectSize(int ObjectIdx) const {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
@@ -203,14 +234,21 @@ public:
     return Objects[ObjectIdx+NumFixedObjects].Size;
   }
 
-  /// getObjectAlignment - Return the alignment of the specified stack object...
+  /// setObjectSize - Change the size of the specified stack object.
+  void setObjectSize(int ObjectIdx, int64_t Size) {
+    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+           "Invalid Object Idx!");
+    Objects[ObjectIdx+NumFixedObjects].Size = Size;
+  }
+
+  /// getObjectAlignment - Return the alignment of the specified stack object.
   unsigned getObjectAlignment(int ObjectIdx) const {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
            "Invalid Object Idx!");
     return Objects[ObjectIdx+NumFixedObjects].Alignment;
   }
 
-  /// setObjectAlignment - Change the alignment of the spcified stack object...
+  /// setObjectAlignment - Change the alignment of the specified stack object.
   void setObjectAlignment(int ObjectIdx, unsigned Align) {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
            "Invalid Object Idx!");
@@ -313,7 +351,7 @@ public:
   }
 
   /// CreateStackObject - Create a new statically sized stack object, returning
-  /// a postive identifier to represent it.
+  /// a nonnegative identifier to represent it.
   ///
   int CreateStackObject(uint64_t Size, unsigned Alignment) {
     assert(Size != 0 && "Cannot allocate zero size stack objects!");
@@ -324,12 +362,8 @@ public:
   /// RemoveStackObject - Remove or mark dead a statically sized stack object.
   ///
   void RemoveStackObject(int ObjectIdx) {
-    if (ObjectIdx == (int)(Objects.size()-NumFixedObjects-1))
-      // Last object, simply pop it off the list.
-      Objects.pop_back();
-    else
-      // Mark it dead.
-      Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
+    // Mark it dead.
+    Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
   }
 
   /// CreateVariableSizedObject - Notify the MachineFrameInfo object that a