in builds without asserts we do not need to allocate the Next pointer in "ghostly...
[oota-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
index a38bc971cd4b48abf2df527d5bcd805a84bc6445..4c981f7caf027e25dad71905836e1ed06c2078b3 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "llvm/Support/DataTypes.h"
 #include <cassert>
+#include <iosfwd>
 #include <vector>
 
 namespace llvm {
@@ -98,7 +99,7 @@ class MachineFrameInfo {
     // 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)
+    StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false)
       : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {}
   };
 
@@ -117,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
@@ -145,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
@@ -170,10 +178,12 @@ class MachineFrameInfo {
   ///
   const TargetFrameInfo &TFI;
 public:
-  MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
+  explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
     StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
     HasVarSizedObjects = false;
+    FrameAddressTaken = false;
     HasCalls = false;
+    StackProtectorIdx = -1;
     MaxCallFrameSize = 0;
     MMI = 0;
   }
@@ -189,11 +199,23 @@ 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; }
 
@@ -204,7 +226,7 @@ public:
   ///
   unsigned getNumObjects() const { return Objects.size(); }
 
-  /// getObjectSize - Return the size of the specified object
+  /// getObjectSize - Return the size of the specified object.
   ///
   int64_t getObjectSize(int ObjectIdx) const {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
@@ -212,21 +234,21 @@ public:
     return Objects[ObjectIdx+NumFixedObjects].Size;
   }
 
-  // setObjectSize - Change the size 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...
+  /// 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 specified 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!");
@@ -333,7 +355,7 @@ public:
   ///
   int CreateStackObject(uint64_t Size, unsigned Alignment) {
     assert(Size != 0 && "Cannot allocate zero size stack objects!");
-    Objects.push_back(StackObject(Size, Alignment, -1));
+    Objects.push_back(StackObject(Size, Alignment));
     return (int)Objects.size()-NumFixedObjects-1;
   }
 
@@ -351,7 +373,7 @@ public:
   ///
   int CreateVariableSizedObject() {
     HasVarSizedObjects = true;
-    Objects.push_back(StackObject(0, 1, -1));
+    Objects.push_back(StackObject(0, 1));
     return (int)Objects.size()-NumFixedObjects-1;
   }