943ea5d6728ed2a5c2b6d72ad8d4525d8d6b6bde
[oota-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 this stack object is originated from an Alloca instruction
105     /// this value saves the original IR allocation. Can be NULL.
106     const AllocaInst *Alloca;
107
108     // If true, the object was mapped into the local frame
109     // block and doesn't need additional handling for allocation beyond that.
110     bool PreAllocated;
111
112     // If true, an LLVM IR value might point to this object.
113     // Normally, spill slots and fixed-offset objects don't alias IR-accessible
114     // objects, but there are exceptions (on PowerPC, for example, some byval
115     // arguments have ABI-prescribed offsets).
116     bool isAliased;
117
118     StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM,
119                 bool isSS, const AllocaInst *Val, bool A)
120       : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
121         isSpillSlot(isSS), Alloca(Val), PreAllocated(false), isAliased(A) {}
122   };
123
124   /// The alignment of the stack.
125   unsigned StackAlignment;
126
127   /// Can the stack be realigned.
128   bool StackRealignable;
129
130   /// The list of stack objects allocated.
131   std::vector<StackObject> Objects;
132
133   /// This contains the number of fixed objects contained on
134   /// the stack.  Because fixed objects are stored at a negative index in the
135   /// Objects list, this is also the index to the 0th object in the list.
136   unsigned NumFixedObjects;
137
138   /// This boolean keeps track of whether any variable
139   /// sized objects have been allocated yet.
140   bool HasVarSizedObjects;
141
142   /// This boolean keeps track of whether there is a call
143   /// to builtin \@llvm.frameaddress.
144   bool FrameAddressTaken;
145
146   /// This boolean keeps track of whether there is a call
147   /// to builtin \@llvm.returnaddress.
148   bool ReturnAddressTaken;
149
150   /// This boolean keeps track of whether there is a call
151   /// to builtin \@llvm.experimental.stackmap.
152   bool HasStackMap;
153
154   /// This boolean keeps track of whether there is a call
155   /// to builtin \@llvm.experimental.patchpoint.
156   bool HasPatchPoint;
157
158   /// The prolog/epilog code inserter calculates the final stack
159   /// offsets for all of the fixed size objects, updating the Objects list
160   /// above.  It then updates StackSize to contain the number of bytes that need
161   /// to be allocated on entry to the function.
162   uint64_t StackSize;
163
164   /// The amount that a frame offset needs to be adjusted to
165   /// have the actual offset from the stack/frame pointer.  The exact usage of
166   /// this is target-dependent, but it is typically used to adjust between
167   /// SP-relative and FP-relative offsets.  E.G., if objects are accessed via
168   /// SP then OffsetAdjustment is zero; if FP is used, OffsetAdjustment is set
169   /// to the distance between the initial SP and the value in FP.  For many
170   /// targets, this value is only used when generating debug info (via
171   /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the
172   /// corresponding adjustments are performed directly.
173   int OffsetAdjustment;
174
175   /// The prolog/epilog code inserter may process objects that require greater
176   /// alignment than the default alignment the target provides.
177   /// To handle this, MaxAlignment is set to the maximum alignment
178   /// needed by the objects on the current frame.  If this is greater than the
179   /// native alignment maintained by the compiler, dynamic alignment code will
180   /// be needed.
181   ///
182   unsigned MaxAlignment;
183
184   /// Set to true if this function adjusts the stack -- e.g.,
185   /// when calling another function. This is only valid during and after
186   /// prolog/epilog code insertion.
187   bool AdjustsStack;
188
189   /// Set to true if this function has any function calls.
190   bool HasCalls;
191
192   /// The frame index for the stack protector.
193   int StackProtectorIdx;
194
195   /// The frame index for the function context. Used for SjLj exceptions.
196   int FunctionContextIdx;
197
198   /// This contains the size of the largest call frame if the target uses frame
199   /// setup/destroy pseudo instructions (as defined in the TargetFrameInfo
200   /// class).  This information is important for frame pointer elimination.
201   /// If is only valid during and after prolog/epilog code insertion.
202   unsigned MaxCallFrameSize;
203
204   /// The prolog/epilog code inserter fills in this vector with each
205   /// callee saved register saved in the frame.  Beyond its use by the prolog/
206   /// epilog code inserter, this data used for debug info and exception
207   /// handling.
208   std::vector<CalleeSavedInfo> CSInfo;
209
210   /// Has CSInfo been set yet?
211   bool CSIValid;
212
213   /// References to frame indices which are mapped
214   /// into the local frame allocation block. <FrameIdx, LocalOffset>
215   SmallVector<std::pair<int, int64_t>, 32> LocalFrameObjects;
216
217   /// Size of the pre-allocated local frame block.
218   int64_t LocalFrameSize;
219
220   /// Required alignment of the local object blob, which is the strictest
221   /// alignment of any object in it.
222   unsigned LocalFrameMaxAlign;
223
224   /// Whether the local object blob needs to be allocated together. If not,
225   /// PEI should ignore the isPreAllocated flags on the stack objects and
226   /// just allocate them normally.
227   bool UseLocalStackAllocationBlock;
228
229   /// Whether the "realign-stack" option is on.
230   bool RealignOption;
231
232   /// True if the function dynamically adjusts the stack pointer through some
233   /// opaque mechanism like inline assembly or Win32 EH.
234   bool HasOpaqueSPAdjustment;
235
236   /// True if the function contains a call to the llvm.vastart intrinsic.
237   bool HasVAStart;
238
239   /// True if this is a varargs function that contains a musttail call.
240   bool HasMustTailInVarArgFunc;
241
242   /// True if this function contains a tail call. If so immutable objects like
243   /// function arguments are no longer so. A tail call *can* override fixed
244   /// stack objects like arguments so we can't treat them as immutable.
245   bool HasTailCall;
246
247   /// Not null, if shrink-wrapping found a better place for the prologue.
248   MachineBasicBlock *Save;
249   /// Not null, if shrink-wrapping found a better place for the epilogue.
250   MachineBasicBlock *Restore;
251
252 public:
253   explicit MachineFrameInfo(unsigned StackAlign, bool isStackRealign,
254                             bool RealignOpt)
255       : StackAlignment(StackAlign), StackRealignable(isStackRealign),
256         RealignOption(RealignOpt) {
257     StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
258     HasVarSizedObjects = false;
259     FrameAddressTaken = false;
260     ReturnAddressTaken = false;
261     HasStackMap = false;
262     HasPatchPoint = false;
263     AdjustsStack = false;
264     HasCalls = false;
265     StackProtectorIdx = -1;
266     FunctionContextIdx = -1;
267     MaxCallFrameSize = 0;
268     CSIValid = false;
269     LocalFrameSize = 0;
270     LocalFrameMaxAlign = 0;
271     UseLocalStackAllocationBlock = false;
272     HasOpaqueSPAdjustment = false;
273     HasVAStart = false;
274     HasMustTailInVarArgFunc = false;
275     Save = nullptr;
276     Restore = nullptr;
277     HasTailCall = false;
278   }
279
280   /// Return true if there are any stack objects in this function.
281   bool hasStackObjects() const { return !Objects.empty(); }
282
283   /// This method may be called any time after instruction
284   /// selection is complete to determine if the stack frame for this function
285   /// contains any variable sized objects.
286   bool hasVarSizedObjects() const { return HasVarSizedObjects; }
287
288   /// Return the index for the stack protector object.
289   int getStackProtectorIndex() const { return StackProtectorIdx; }
290   void setStackProtectorIndex(int I) { StackProtectorIdx = I; }
291
292   /// Return the index for the function context object.
293   /// This object is used for SjLj exceptions.
294   int getFunctionContextIndex() const { return FunctionContextIdx; }
295   void setFunctionContextIndex(int I) { FunctionContextIdx = I; }
296
297   /// This method may be called any time after instruction
298   /// selection is complete to determine if there is a call to
299   /// \@llvm.frameaddress in this function.
300   bool isFrameAddressTaken() const { return FrameAddressTaken; }
301   void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
302
303   /// This method may be called any time after
304   /// instruction selection is complete to determine if there is a call to
305   /// \@llvm.returnaddress in this function.
306   bool isReturnAddressTaken() const { return ReturnAddressTaken; }
307   void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; }
308
309   /// This method may be called any time after instruction
310   /// selection is complete to determine if there is a call to builtin
311   /// \@llvm.experimental.stackmap.
312   bool hasStackMap() const { return HasStackMap; }
313   void setHasStackMap(bool s = true) { HasStackMap = s; }
314
315   /// This method may be called any time after instruction
316   /// selection is complete to determine if there is a call to builtin
317   /// \@llvm.experimental.patchpoint.
318   bool hasPatchPoint() const { return HasPatchPoint; }
319   void setHasPatchPoint(bool s = true) { HasPatchPoint = s; }
320
321   /// Return the minimum frame object index.
322   int getObjectIndexBegin() const { return -NumFixedObjects; }
323
324   /// Return one past the maximum frame object index.
325   int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
326
327   /// Return the number of fixed objects.
328   unsigned getNumFixedObjects() const { return NumFixedObjects; }
329
330   /// Return the number of objects.
331   unsigned getNumObjects() const { return Objects.size(); }
332
333   /// Map a frame index into the local object block
334   void mapLocalFrameObject(int ObjectIndex, int64_t Offset) {
335     LocalFrameObjects.push_back(std::pair<int, int64_t>(ObjectIndex, Offset));
336     Objects[ObjectIndex + NumFixedObjects].PreAllocated = true;
337   }
338
339   /// Get the local offset mapping for a for an object.
340   std::pair<int, int64_t> getLocalFrameObjectMap(int i) const {
341     assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() &&
342             "Invalid local object reference!");
343     return LocalFrameObjects[i];
344   }
345
346   /// Return the number of objects allocated into the local object block.
347   int64_t getLocalFrameObjectCount() const { return LocalFrameObjects.size(); }
348
349   /// Set the size of the local object blob.
350   void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; }
351
352   /// Get the size of the local object blob.
353   int64_t getLocalFrameSize() const { return LocalFrameSize; }
354
355   /// Required alignment of the local object blob,
356   /// which is the strictest alignment of any object in it.
357   void setLocalFrameMaxAlign(unsigned Align) { LocalFrameMaxAlign = Align; }
358
359   /// Return the required alignment of the local object blob.
360   unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; }
361
362   /// Get whether the local allocation blob should be allocated together or
363   /// let PEI allocate the locals in it directly.
364   bool getUseLocalStackAllocationBlock() const {
365     return UseLocalStackAllocationBlock;
366   }
367
368   /// setUseLocalStackAllocationBlock - Set whether the local allocation blob
369   /// should be allocated together or let PEI allocate the locals in it
370   /// directly.
371   void setUseLocalStackAllocationBlock(bool v) {
372     UseLocalStackAllocationBlock = v;
373   }
374
375   /// Return true if the object was pre-allocated into the local block.
376   bool isObjectPreAllocated(int ObjectIdx) const {
377     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
378            "Invalid Object Idx!");
379     return Objects[ObjectIdx+NumFixedObjects].PreAllocated;
380   }
381
382   /// Return the size of the specified object.
383   int64_t getObjectSize(int ObjectIdx) const {
384     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
385            "Invalid Object Idx!");
386     return Objects[ObjectIdx+NumFixedObjects].Size;
387   }
388
389   /// Change the size of the specified stack object.
390   void setObjectSize(int ObjectIdx, int64_t Size) {
391     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
392            "Invalid Object Idx!");
393     Objects[ObjectIdx+NumFixedObjects].Size = Size;
394   }
395
396   /// Return the alignment of the specified stack object.
397   unsigned getObjectAlignment(int ObjectIdx) const {
398     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
399            "Invalid Object Idx!");
400     return Objects[ObjectIdx+NumFixedObjects].Alignment;
401   }
402
403   /// setObjectAlignment - Change the alignment of the specified stack object.
404   void setObjectAlignment(int ObjectIdx, unsigned Align) {
405     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
406            "Invalid Object Idx!");
407     Objects[ObjectIdx+NumFixedObjects].Alignment = Align;
408     ensureMaxAlignment(Align);
409   }
410
411   /// Return the underlying Alloca of the specified
412   /// stack object if it exists. Returns 0 if none exists.
413   const AllocaInst* getObjectAllocation(int ObjectIdx) const {
414     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
415            "Invalid Object Idx!");
416     return Objects[ObjectIdx+NumFixedObjects].Alloca;
417   }
418
419   /// Return the assigned stack offset of the specified object
420   /// from the incoming stack pointer.
421   int64_t getObjectOffset(int ObjectIdx) const {
422     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
423            "Invalid Object Idx!");
424     assert(!isDeadObjectIndex(ObjectIdx) &&
425            "Getting frame offset for a dead object?");
426     return Objects[ObjectIdx+NumFixedObjects].SPOffset;
427   }
428
429   /// Set the stack frame offset of the specified object. The
430   /// offset is relative to the stack pointer on entry to the function.
431   void setObjectOffset(int ObjectIdx, int64_t SPOffset) {
432     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
433            "Invalid Object Idx!");
434     assert(!isDeadObjectIndex(ObjectIdx) &&
435            "Setting frame offset for a dead object?");
436     Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
437   }
438
439   /// Return the number of bytes that must be allocated to hold
440   /// all of the fixed size frame objects.  This is only valid after
441   /// Prolog/Epilog code insertion has finalized the stack frame layout.
442   uint64_t getStackSize() const { return StackSize; }
443
444   /// Set the size of the stack.
445   void setStackSize(uint64_t Size) { StackSize = Size; }
446
447   /// Estimate and return the size of the stack frame.
448   unsigned estimateStackSize(const MachineFunction &MF) const;
449
450   /// Return the correction for frame offsets.
451   int getOffsetAdjustment() const { return OffsetAdjustment; }
452
453   /// Set the correction for frame offsets.
454   void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
455
456   /// Return the alignment in bytes that this function must be aligned to,
457   /// which is greater than the default stack alignment provided by the target.
458   unsigned getMaxAlignment() const { return MaxAlignment; }
459
460   /// Make sure the function is at least Align bytes aligned.
461   void ensureMaxAlignment(unsigned Align);
462
463   /// Return true if this function adjusts the stack -- e.g.,
464   /// when calling another function. This is only valid during and after
465   /// prolog/epilog code insertion.
466   bool adjustsStack() const { return AdjustsStack; }
467   void setAdjustsStack(bool V) { AdjustsStack = V; }
468
469   /// Return true if the current function has any function calls.
470   bool hasCalls() const { return HasCalls; }
471   void setHasCalls(bool V) { HasCalls = V; }
472
473   /// Returns true if the function contains opaque dynamic stack adjustments.
474   bool hasOpaqueSPAdjustment() const { return HasOpaqueSPAdjustment; }
475   void setHasOpaqueSPAdjustment(bool B) { HasOpaqueSPAdjustment = B; }
476
477   /// Returns true if the function calls the llvm.va_start intrinsic.
478   bool hasVAStart() const { return HasVAStart; }
479   void setHasVAStart(bool B) { HasVAStart = B; }
480
481   /// Returns true if the function is variadic and contains a musttail call.
482   bool hasMustTailInVarArgFunc() const { return HasMustTailInVarArgFunc; }
483   void setHasMustTailInVarArgFunc(bool B) { HasMustTailInVarArgFunc = B; }
484
485   /// Returns true if the function contains a tail call.
486   bool hasTailCall() const { return HasTailCall; }
487   void setHasTailCall() { HasTailCall = true; }
488
489   /// Return the maximum size of a call frame that must be
490   /// allocated for an outgoing function call.  This is only available if
491   /// CallFrameSetup/Destroy pseudo instructions are used by the target, and
492   /// then only during or after prolog/epilog code insertion.
493   ///
494   unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
495   void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
496
497   /// Create a new object at a fixed location on the stack.
498   /// All fixed objects should be created before other objects are created for
499   /// efficiency. By default, fixed objects are not pointed to by LLVM IR
500   /// values. This returns an index with a negative value.
501   int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable,
502                         bool isAliased = false);
503
504   /// Create a spill slot at a fixed location on the stack.
505   /// Returns an index with a negative value.
506   int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset);
507
508   /// Returns true if the specified index corresponds to a fixed stack object.
509   bool isFixedObjectIndex(int ObjectIdx) const {
510     return ObjectIdx < 0 && (ObjectIdx >= -(int)NumFixedObjects);
511   }
512
513   /// Returns true if the specified index corresponds
514   /// to an object that might be pointed to by an LLVM IR value.
515   bool isAliasedObjectIndex(int ObjectIdx) const {
516     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
517            "Invalid Object Idx!");
518     return Objects[ObjectIdx+NumFixedObjects].isAliased;
519   }
520
521   /// isImmutableObjectIndex - Returns true if the specified index corresponds
522   /// to an immutable object.
523   bool isImmutableObjectIndex(int ObjectIdx) const {
524     // Tail calling functions can clobber their function arguments.
525     if (HasTailCall)
526       return false;
527     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
528            "Invalid Object Idx!");
529     return Objects[ObjectIdx+NumFixedObjects].isImmutable;
530   }
531
532   /// Returns true if the specified index corresponds to a spill slot.
533   bool isSpillSlotObjectIndex(int ObjectIdx) const {
534     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
535            "Invalid Object Idx!");
536     return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;
537   }
538
539   /// Returns true if the specified index corresponds to a dead object.
540   bool isDeadObjectIndex(int ObjectIdx) const {
541     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
542            "Invalid Object Idx!");
543     return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
544   }
545
546   /// Returns true if the specified index corresponds to a variable sized
547   /// object.
548   bool isVariableSizedObjectIndex(int ObjectIdx) const {
549     assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
550            "Invalid Object Idx!");
551     return Objects[ObjectIdx + NumFixedObjects].Size == 0;
552   }
553
554   /// Create a new statically sized stack object, returning
555   /// a nonnegative identifier to represent it.
556   int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS,
557                         const AllocaInst *Alloca = nullptr);
558
559   /// Create a new statically sized stack object that represents a spill slot,
560   /// returning a nonnegative identifier to represent it.
561   int CreateSpillStackObject(uint64_t Size, unsigned Alignment);
562
563   /// Remove or mark dead a statically sized stack object.
564   void RemoveStackObject(int ObjectIdx) {
565     // Mark it dead.
566     Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
567   }
568
569   /// Notify the MachineFrameInfo object that a variable sized object has been
570   /// created.  This must be created whenever a variable sized object is
571   /// created, whether or not the index returned is actually used.
572   int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca);
573
574   /// Returns a reference to call saved info vector for the current function.
575   const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
576     return CSInfo;
577   }
578
579   /// Used by prolog/epilog inserter to set the function's callee saved
580   /// information.
581   void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) {
582     CSInfo = CSI;
583   }
584
585   /// Has the callee saved info been calculated yet?
586   bool isCalleeSavedInfoValid() const { return CSIValid; }
587
588   void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
589
590   MachineBasicBlock *getSavePoint() const { return Save; }
591   void setSavePoint(MachineBasicBlock *NewSave) { Save = NewSave; }
592   MachineBasicBlock *getRestorePoint() const { return Restore; }
593   void setRestorePoint(MachineBasicBlock *NewRestore) { Restore = NewRestore; }
594
595   /// Return a set of physical registers that are pristine.
596   ///
597   /// Pristine registers hold a value that is useless to the current function,
598   /// but that must be preserved - they are callee saved registers that are not
599   /// saved.
600   ///
601   /// Before the PrologueEpilogueInserter has placed the CSR spill code, this
602   /// method always returns an empty set.
603   BitVector getPristineRegs(const MachineFunction &MF) const;
604
605   /// Used by the MachineFunction printer to print information about
606   /// stack objects. Implemented in MachineFunction.cpp.
607   void print(const MachineFunction &MF, raw_ostream &OS) const;
608
609   /// dump - Print the function to stderr.
610   void dump(const MachineFunction &MF) const;
611 };
612
613 } // End llvm namespace
614
615 #endif