OSDN Git Service

Fix comment typos. NFC.
[android-x86/external-llvm.git] / include / llvm / CodeGen / MachineFrameInfo.h
1 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // The file defines the MachineFrameInfo class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
15 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
16
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/Support/DataTypes.h"
19 #include <cassert>
20 #include <vector>
21
22 namespace llvm {
23 class raw_ostream;
24 class DataLayout;
25 class TargetRegisterClass;
26 class Type;
27 class MachineFunction;
28 class MachineBasicBlock;
29 class TargetFrameLowering;
30 class TargetMachine;
31 class BitVector;
32 class Value;
33 class AllocaInst;
34
35 /// The CalleeSavedInfo class tracks the information need to locate where a
36 /// callee saved register is in the current frame.
37 class CalleeSavedInfo {
38   unsigned Reg;
39   int FrameIdx;
40
41 public:
42   explicit CalleeSavedInfo(unsigned R, int FI = 0)
43   : Reg(R), FrameIdx(FI) {}
44
45   // Accessors.
46   unsigned getReg()                        const { return Reg; }
47   int getFrameIdx()                        const { return FrameIdx; }
48   void setFrameIdx(int FI)                       { FrameIdx = FI; }
49 };
50
51 /// The MachineFrameInfo class represents an abstract stack frame until
52 /// prolog/epilog code is inserted.  This class is key to allowing stack frame
53 /// representation optimizations, such as frame pointer elimination.  It also
54 /// allows more mundane (but still important) optimizations, such as reordering
55 /// of abstract objects on the stack frame.
56 ///
57 /// To support this, the class assigns unique integer identifiers to stack
58 /// objects requested clients.  These identifiers are negative integers for
59 /// fixed stack objects (such as arguments passed on the stack) or nonnegative
60 /// for objects that may be reordered.  Instructions which refer to stack
61 /// objects use a special MO_FrameIndex operand to represent these frame
62 /// indexes.
63 ///
64 /// Because this class keeps track of all references to the stack frame, it
65 /// knows when a variable sized object is allocated on the stack.  This is the
66 /// sole condition which prevents frame pointer elimination, which is an
67 /// important optimization on register-poor architectures.  Because original
68 /// variable sized alloca's in the source program are the only source of
69 /// variable sized stack objects, it is safe to decide whether there will be
70 /// any variable sized objects before all stack objects are known (for
71 /// example, register allocator spill code never needs variable sized
72 /// objects).
73 ///
74 /// When prolog/epilog code emission is performed, the final stack frame is
75 /// built and the machine instructions are modified to refer to the actual
76 /// stack offsets of the object, eliminating all MO_FrameIndex operands from
77 /// the program.
78 ///
79 /// @brief Abstract Stack Frame Information
80 class MachineFrameInfo {
81
82   // Represent a single object allocated on the stack.
83   struct StackObject {
84     // The offset of this object from the stack pointer on entry to
85     // the function.  This field has no meaning for a variable sized element.
86     int64_t SPOffset;
87
88     // The size of this object on the stack. 0 means a variable sized object,
89     // ~0ULL means a dead object.
90     uint64_t Size;
91
92     // The required alignment of this stack slot.
93     unsigned Alignment;
94
95     // If true, the value of the stack object is set before
96     // entering the function and is not modified inside the function. By
97     // default, fixed objects are immutable unless marked otherwise.
98     bool isImmutable;
99
100     // If true the stack object is used as spill slot. It
101     // cannot alias any other memory objects.
102     bool isSpillSlot;
103
104     /// If true, this stack slot is used to spill a value (could be deopt
105     /// and/or GC related) over a statepoint. We know that the address of the
106     /// slot can't alias any LLVM IR value.  This is very similar to a Spill
107     /// Slot, but is created by statepoint lowering is SelectionDAG, not the
108     /// register allocator. 
109     bool isStatepointSpillSlot;
110
111     /// If this stack object is originated from an Alloca instruction
112     /// this value saves the original IR allocation. Can be NULL.
113     const AllocaInst *Alloca;
114
115     // If true, the object was mapped into the local frame
116     // block and doesn't need additional handling for allocation beyond that.
117     bool PreAllocated;
118
119     // If true, an LLVM IR value might point to this object.
120     // Normally, spill slots and fixed-offset objects don't alias IR-accessible
121     // objects, but there are exceptions (on PowerPC, for example, some byval
122     // arguments have ABI-prescribed offsets).
123     bool isAliased;
124
125     /// If true, the object has been zero-extended.
126     bool isZExt;
127
128     /// If true, the object has been zero-extended.
129     bool isSExt;
130
131     StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM,
132                 bool isSS, const AllocaInst *Val, bool A)
133       : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
134         isSpillSlot(isSS), isStatepointSpillSlot(false), Alloca(Val),
135         PreAllocated(false), isAliased(A), isZExt(false), isSExt(false) {}
136   };
137
138   /// The alignment of the stack.
139   unsigned StackAlignment;
140
141   /// Can the stack be realigned. This can be false if the target does not
142   /// support stack realignment, or if the user asks us not to realign the
143   /// stack. In this situation, overaligned allocas are all treated as dynamic
144   /// allocations and the target must handle them as part of DYNAMIC_STACKALLOC
145   /// lowering. All non-alloca stack objects have their alignment clamped to the
146   /// base ABI stack alignment.
147   /// FIXME: There is room for improvement in this case, in terms of
148   /// grouping overaligned allocas into a "secondary stack frame" and
149   /// then only use a single alloca to allocate this frame and only a
150   /// single virtual register to access it. Currently, without such an
151   /// optimization, each such alloca gets it's own dynamic
152   /// realignment.
153   bool StackRealignable;
154
155   /// Whether the function has the \c alignstack attribute.
156   bool ForcedRealign;
157
158   /// The list of stack objects allocated.
159   std::vector<StackObject> Objects;
160
161   /// This contains the number of fixed objects contained on
162   /// the stack.  Because fixed objects are stored at a negative index in the
163   /// Objects list, this is also the index to the 0th object in the list.
164   unsigned NumFixedObjects = 0;
165
166   /// This boolean keeps track of whether any variable
167   /// sized objects have been allocated yet.
168   bool HasVarSizedObjects = false;
169
170   /// This boolean keeps track of whether there is a call
171   /// to builtin \@llvm.frameaddress.
172   bool FrameAddressTaken = false;
173
174   /// This boolean keeps track of whether there is a call
175   /// to builtin \@llvm.returnaddress.
176   bool ReturnAddressTaken = false;
177
178   /// This boolean keeps track of whether there is a call
179   /// to builtin \@llvm.experimental.stackmap.
180   bool HasStackMap = false;
181
182   /// This boolean keeps track of whether there is a call
183   /// to builtin \@llvm.experimental.patchpoint.
184   bool HasPatchPoint = false;
185
186   /// The prolog/epilog code inserter calculates the final stack
187   /// offsets for all of the fixed size objects, updating the Objects list
188   /// above.  It then updates StackSize to contain the number of bytes that need
189   /// to be allocated on entry to the function.
190   uint64_t StackSize = 0;
191
192   /// The amount that a frame offset needs to be adjusted to
193   /// have the actual offset from the stack/frame pointer.  The exact usage of
194   /// this is target-dependent, but it is typically used to adjust between
195   /// SP-relative and FP-relative offsets.  E.G., if objects are accessed via
196   /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set
197   /// to the distance between the initial SP and the value in FP.  For many
198   /// targets, this value is only used when generating debug info (via
199   /// TargetRegisterInfo::getFrameIndexReference); when generating code, the
200   /// corresponding adjustments are performed directly.
201   int OffsetAdjustment = 0;
202
203   /// The prolog/epilog code inserter may process objects that require greater
204   /// alignment than the default alignment the target provides.
205   /// To handle this, MaxAlignment is set to the maximum alignment
206   /// needed by the objects on the current frame.  If this is greater than the
207   /// native alignment maintained by the compiler, dynamic alignment code will
208   /// be needed.
209   ///
210   unsigned MaxAlignment = 0;
211
212   /// Set to true if this function adjusts the stack -- e.g.,
213   /// when calling another function. This is only valid during and after
214   /// prolog/epilog code insertion.
215   bool AdjustsStack = false;
216
217   /// Set to true if this function has any function calls.
218   bool HasCalls = false;
219
220   /// The frame index for the stack protector.
221   int StackProtectorIdx = -1;
222
223   /// The frame index for the function context. Used for SjLj exceptions.
224   int FunctionContextIdx = -1;
225
226   /// This contains the size of the largest call frame if the target uses frame
227   /// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
228   /// class).  This information is important for frame pointer elimination.
229   /// It is only valid during and after prolog/epilog code insertion.
230   unsigned MaxCallFrameSize = 0;
231
232   /// The prolog/epilog code inserter fills in this vector with each
233   /// callee saved register saved in the frame.  Beyond its use by the prolog/
234   /// epilog code inserter, this data used for debug info and exception
235   /// handling.
236   std::vector<CalleeSavedInfo> CSInfo;
237
238   /// Has CSInfo been set yet?
239   bool CSIValid = false;
240
241   /// References to frame indices which are mapped
242   /// into the local frame allocation block. <FrameIdx, LocalOffset>
243   SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects;
244
245   /// Size of the pre-allocated local frame block.
246   int64_t LocalFrameSize = 0;
247
248   /// Required alignment of the local object blob, which is the strictest
249   /// alignment of any object in it.
250   unsigned LocalFrameMaxAlign = 0;
251
252   /// Whether the local object blob needs to be allocated together. If not,
253   /// PEI should ignore the isPreAllocated flags on the stack objects and
254   /// just allocate them normally.
255   bool UseLocalStackAllocationBlock = false;
256
257   /// True if the function dynamically adjusts the stack pointer through some
258   /// opaque mechanism like inline assembly or Win32 EH.
259   bool HasOpaqueSPAdjustment = false;
260
261   /// True if the function contains operations which will lower down to
262   /// instructions which manipulate the stack pointer.
263   bool HasCopyImplyingStackAdjustment = false;
264
265   /// True if the function contains a call to the llvm.vastart intrinsic.
266   bool HasVAStart = false;
267
268   /// True if this is a varargs function that contains a musttail call.
269   bool HasMustTailInVarArgFunc = false;
270
271   /// True if this function contains a tail call. If so immutable objects like
272   /// function arguments are no longer so. A tail call *can* override fixed
273   /// stack objects like arguments so we can't treat them as immutable.
274   bool HasTailCall = false;
275
276   /// Not null, if shrink-wrapping found a better place for the prologue.
277   MachineBasicBlock *Save = nullptr;
278   /// Not null, if shrink-wrapping found a better place for the epilogue.
279   MachineBasicBlock *Restore = nullptr;
280
281 public:
282   explicit MachineFrameInfo(unsigned StackAlignment, bool StackRealignable,
283                             bool ForcedRealign)
284       : StackAlignment(StackAlignment), StackRealignable(StackRealignable),
285         ForcedRealign(ForcedRealign) {}
286
287   /// Return true if there are any stack objects in this function.
288   bool hasStackObjects() const { return !Objects.empty(); }
289
290   /// This method may be called any time after instruction
291   /// selection is complete to determine if the stack frame for this function
292   /// contains any variable sized objects.
293   bool hasVarSizedObjects() const { return HasVarSizedObjects; }
294
295   /// Return the index for the stack protector object.
296   int getStackProtectorIndex() const { return StackProtectorIdx; }
297   void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
298   bool hasStackProtectorIndex() const { return StackProtectorIdx != -1; }
299
300   /// Return the index for the function context object.
301   /// This object is used for SjLj exceptions.
302   int getFunctionContextIndex() const { return FunctionContextIdx; }
303   void setFunctionContextIndex(int I) { FunctionContextIdx = I; }
304
305   /// This method may be called any time after instruction
306   /// selection is complete to determine if there is a call to
307   /// \@llvm.frameaddress in this function.
308   bool isFrameAddressTaken() const { return FrameAddressTaken; }
309   void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
310
311   /// This method may be called any time after
312   /// instruction selection is complete to determine if there is a call to
313   /// \@llvm.returnaddress in this function.
314   bool isReturnAddressTaken() const { return ReturnAddressTaken; }
315   void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; }
316
317   /// This method may be called any time after instruction
318   /// selection is complete to determine if there is a call to builtin
319   /// \@llvm.experimental.stackmap.
320   bool hasStackMap() const { return HasStackMap; }
321   void setHasStackMap(bool s = true) { HasStackMap = s; }
322
323   /// This method may be called any time after instruction
324   /// selection is complete to determine if there is a call to builtin
325   /// \@llvm.experimental.patchpoint.
326   bool hasPatchPoint() const { return HasPatchPoint; }
327   void setHasPatchPoint(bool s = true) { HasPatchPoint = s; }
328
329   /// Return the minimum frame object index.
330   int getObjectIndexBegin() const { return -NumFixedObjects; }
331
332   /// Return one past the maximum frame object index.
333   int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
334
335   /// Return the number of fixed objects.
336   unsigned getNumFixedObjects() const { return NumFixedObjects; }
337
338   /// Return the number of objects.
339   unsigned getNumObjects() const { return Objects.size(); }
340
341   /// Map a frame index into the local object block
342   void mapLocalFrameObject(int ObjectIndex, int64_t Offset) {
343     LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset));
344     Objects[ObjectIndex + NumFixedObjects].PreAllocated = true;
345   }
346
347   /// Get the local offset mapping for a for an object.
348   std::pair<int, int64_t> getLocalFrameObjectMap(int i) const {
349     assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() &&
350             "Invalid local object reference!");
351     return LocalFrameObjects[i];
352   }
353
354   /// Return the number of objects allocated into the local object block.
355   int64_t getLocalFrameObjectCount() const { return LocalFrameObjects.size(); }
356
357   /// Set the size of the local object blob.
358   void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; }
359
360   /// Get the size of the local object blob.
361   int64_t getLocalFrameSize() const { return LocalFrameSize; }
362
363   /// Required alignment of the local object blob,
364   /// which is the strictest alignment of any object in it.
365   void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; }
366
367   /// Return the required alignment of the local object blob.
368   unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; }
369
370   /// Get whether the local allocation blob should be allocated together or
371   /// let PEI allocate the locals in it directly.
372   bool getUseLocalStackAllocationBlock() const {
373     return UseLocalStackAllocationBlock;
374   }
375
376   /// setUseLocalStackAllocationBlock - Set whether the local allocation blob
377   /// should be allocated together or let PEI allocate the locals in it
378   /// directly.
379   void setUseLocalStackAllocationBlock(bool v) {
380     UseLocalStackAllocationBlock = v;
381   }
382
383   /// Return true if the object was pre-allocated into the local block.
384   bool isObjectPreAllocated(int ObjectIdx) const {
385     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
386            "Invalid Object Idx!");
387     return Objects[ObjectIdx+NumFixedObjects].PreAllocated;
388   }
389
390   /// Return the size of the specified object.
391   int64_t getObjectSize(int ObjectIdx) const {
392     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
393            "Invalid Object Idx!");
394     return Objects[ObjectIdx+NumFixedObjects].Size;
395   }
396
397   /// Change the size of the specified stack object.
398   void setObjectSize(int ObjectIdx, int64_t Size) {
399     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
400            "Invalid Object Idx!");
401     Objects[ObjectIdx+NumFixedObjects].Size = Size;
402   }
403
404   /// Return the alignment of the specified stack object.
405   unsigned getObjectAlignment(int ObjectIdx) const {
406     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
407            "Invalid Object Idx!");
408     return Objects[ObjectIdx+NumFixedObjects].Alignment;
409   }
410
411   /// setObjectAlignment - Change the alignment of the specified stack object.
412   void setObjectAlignment(int ObjectIdx, unsigned Align) {
413     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
414            "Invalid Object Idx!");
415     Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
416     ensureMaxAlignment(Align);
417   }
418
419   /// Return the underlying Alloca of the specified
420   /// stack object if it exists. Returns 0 if none exists.
421   const AllocaInst* getObjectAllocation(int ObjectIdx) const {
422     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
423            "Invalid Object Idx!");
424     return Objects[ObjectIdx+NumFixedObjects].Alloca;
425   }
426
427   /// Return the assigned stack offset of the specified object
428   /// from the incoming stack pointer.
429   int64_t getObjectOffset(int ObjectIdx) const {
430     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
431            "Invalid Object Idx!");
432     assert(!isDeadObjectIndex(ObjectIdx) &&
433            "Getting frame offset for a dead object?");
434     return Objects[ObjectIdx+NumFixedObjects].SPOffset;
435   }
436
437   bool isObjectZExt(int ObjectIdx) const {
438     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
439            "Invalid Object Idx!");
440     return Objects[ObjectIdx+NumFixedObjects].isZExt;
441   }
442
443   void setObjectZExt(int ObjectIdx, bool IsZExt) {
444     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
445            "Invalid Object Idx!");
446     Objects[ObjectIdx+NumFixedObjects].isZExt = IsZExt;
447   }
448
449   bool isObjectSExt(int ObjectIdx) const {
450     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
451            "Invalid Object Idx!");
452     return Objects[ObjectIdx+NumFixedObjects].isSExt;
453   }
454
455   void setObjectSExt(int ObjectIdx, bool IsSExt) {
456     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
457            "Invalid Object Idx!");
458     Objects[ObjectIdx+NumFixedObjects].isSExt = IsSExt;
459   }
460
461   /// Set the stack frame offset of the specified object. The
462   /// offset is relative to the stack pointer on entry to the function.
463   void setObjectOffset(int ObjectIdx, int64_t SPOffset) {
464     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
465            "Invalid Object Idx!");
466     assert(!isDeadObjectIndex(ObjectIdx) &&
467            "Setting frame offset for a dead object?");
468     Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
469   }
470
471   /// Return the number of bytes that must be allocated to hold
472   /// all of the fixed size frame objects.  This is only valid after
473   /// Prolog/Epilog code insertion has finalized the stack frame layout.
474   uint64_t getStackSize() const { return StackSize; }
475
476   /// Set the size of the stack.
477   void setStackSize(uint64_t Size) { StackSize = Size; }
478
479   /// Estimate and return the size of the stack frame.
480   unsigned estimateStackSize(const MachineFunction &MF) const;
481
482   /// Return the correction for frame offsets.
483   int getOffsetAdjustment() const { return OffsetAdjustment; }
484
485   /// Set the correction for frame offsets.
486   void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
487
488   /// Return the alignment in bytes that this function must be aligned to,
489   /// which is greater than the default stack alignment provided by the target.
490   unsigned getMaxAlignment() const { return MaxAlignment; }
491
492   /// Make sure the function is at least Align bytes aligned.
493   void ensureMaxAlignment(unsigned Align);
494
495   /// Return true if this function adjusts the stack -- e.g.,
496   /// when calling another function. This is only valid during and after
497   /// prolog/epilog code insertion.
498   bool adjustsStack() const { return AdjustsStack; }
499   void setAdjustsStack(bool V) { AdjustsStack = V; }
500
501   /// Return true if the current function has any function calls.
502   bool hasCalls() const { return HasCalls; }
503   void setHasCalls(bool V) { HasCalls = V; }
504
505   /// Returns true if the function contains opaque dynamic stack adjustments.
506   bool hasOpaqueSPAdjustment() const { return HasOpaqueSPAdjustment; }
507   void setHasOpaqueSPAdjustment(bool B) { HasOpaqueSPAdjustment = B; }
508
509   /// Returns true if the function contains operations which will lower down to
510   /// instructions which manipulate the stack pointer.
511   bool hasCopyImplyingStackAdjustment() const {
512     return HasCopyImplyingStackAdjustment;
513   }
514   void setHasCopyImplyingStackAdjustment(bool B) {
515     HasCopyImplyingStackAdjustment = B;
516   }
517
518   /// Returns true if the function calls the llvm.va_start intrinsic.
519   bool hasVAStart() const { return HasVAStart; }
520   void setHasVAStart(bool B) { HasVAStart = B; }
521
522   /// Returns true if the function is variadic and contains a musttail call.
523   bool hasMustTailInVarArgFunc() const { return HasMustTailInVarArgFunc; }
524   void setHasMustTailInVarArgFunc(bool B) { HasMustTailInVarArgFunc = B; }
525
526   /// Returns true if the function contains a tail call.
527   bool hasTailCall() const { return HasTailCall; }
528   void setHasTailCall() { HasTailCall = true; }
529
530   /// Return the maximum size of a call frame that must be
531   /// allocated for an outgoing function call.  This is only available if
532   /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
533   /// then only during or after prolog/epilog code insertion.
534   ///
535   unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
536   void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
537
538   /// Create a new object at a fixed location on the stack.
539   /// All fixed objects should be created before other objects are created for
540   /// efficiency. By default, fixed objects are not pointed to by LLVM IR
541   /// values. This returns an index with a negative value.
542   int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable,
543                         bool isAliased = false);
544
545   /// Create a spill slot at a fixed location on the stack.
546   /// Returns an index with a negative value.
547   int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset,
548                                   bool Immutable = false);
549
550   /// Returns true if the specified index corresponds to a fixed stack object.
551   bool isFixedObjectIndex(int ObjectIdx) const {
552     return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
553   }
554
555   /// Returns true if the specified index corresponds
556   /// to an object that might be pointed to by an LLVM IR value.
557   bool isAliasedObjectIndex(int ObjectIdx) const {
558     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
559            "Invalid Object Idx!");
560     return Objects[ObjectIdx+NumFixedObjects].isAliased;
561   }
562
563   /// isImmutableObjectIndex - Returns true if the specified index corresponds
564   /// to an immutable object.
565   bool isImmutableObjectIndex(int ObjectIdx) const {
566     // Tail calling functions can clobber their function arguments.
567     if (HasTailCall)
568       return false;
569     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
570            "Invalid Object Idx!");
571     return Objects[ObjectIdx+NumFixedObjects].isImmutable;
572   }
573
574   /// Returns true if the specified index corresponds to a spill slot.
575   bool isSpillSlotObjectIndex(int ObjectIdx) const {
576     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
577            "Invalid Object Idx!");
578     return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;
579   }
580
581   bool isStatepointSpillSlotObjectIndex(int ObjectIdx) const {
582     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
583            "Invalid Object Idx!");
584     return Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot;
585   }
586
587   /// Returns true if the specified index corresponds to a dead object.
588   bool isDeadObjectIndex(int ObjectIdx) const {
589     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
590            "Invalid Object Idx!");
591     return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
592   }
593
594   /// Returns true if the specified index corresponds to a variable sized
595   /// object.
596   bool isVariableSizedObjectIndex(int ObjectIdx) const {
597     assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
598            "Invalid Object Idx!");
599     return Objects[ObjectIdx + NumFixedObjects].Size == 0;
600   }
601
602   void markAsStatepointSpillSlotObjectIndex(int ObjectIdx) {
603     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
604            "Invalid Object Idx!");
605     Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot = true;
606     assert(isStatepointSpillSlotObjectIndex(ObjectIdx) && "inconsistent");
607   }
608
609   /// Create a new statically sized stack object, returning
610   /// a nonnegative identifier to represent it.
611   int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
612                         const AllocaInst *Alloca = nullptr);
613
614   /// Create a new statically sized stack object that represents a spill slot,
615   /// returning a nonnegative identifier to represent it.
616   int CreateSpillStackObject(uint64_t Size, unsigned Alignment);
617
618   /// Remove or mark dead a statically sized stack object.
619   void RemoveStackObject(int ObjectIdx) {
620     // Mark it dead.
621     Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
622   }
623
624   /// Notify the MachineFrameInfo object that a variable sized object has been
625   /// created.  This must be created whenever a variable sized object is
626   /// created, whether or not the index returned is actually used.
627   int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca);
628
629   /// Returns a reference to call saved info vector for the current function.
630   const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
631     return CSInfo;
632   }
633
634   /// Used by prolog/epilog inserter to set the function's callee saved
635   /// information.
636   void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) {
637     CSInfo = CSI;
638   }
639
640   /// Has the callee saved info been calculated yet?
641   bool isCalleeSavedInfoValid() const { return CSIValid; }
642
643   void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
644
645   MachineBasicBlock *getSavePoint() const { return Save; }
646   void setSavePoint(MachineBasicBlock *NewSave) { Save = NewSave; }
647   MachineBasicBlock *getRestorePoint() const { return Restore; }
648   void setRestorePoint(MachineBasicBlock *NewRestore) { Restore = NewRestore; }
649
650   /// Return a set of physical registers that are pristine.
651   ///
652   /// Pristine registers hold a value that is useless to the current function,
653   /// but that must be preserved - they are callee saved registers that are not
654   /// saved.
655   ///
656   /// Before the PrologueEpilogueInserter has placed the CSR spill code, this
657   /// method always returns an empty set.
658   BitVector getPristineRegs(const MachineFunction &MF) const;
659
660   /// Used by the MachineFunction printer to print information about
661   /// stack objects. Implemented in MachineFunction.cpp.
662   void print(const MachineFunction &MF, raw_ostream &OS) const;
663
664   /// dump - Print the function to stderr.
665   void dump(const MachineFunction &MF) const;
666 };
667
668 } // End llvm namespace
669
670 #endif