1 //===-- CodeGen/MachineFrameInfo.h - Abstract Stack Frame Rep. --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // The file defines the MachineFrameInfo class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
15 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/Support/DataTypes.h"
25 class TargetRegisterClass;
27 class MachineFunction;
28 class MachineBasicBlock;
29 class TargetFrameLowering;
35 /// The CalleeSavedInfo class tracks the information need to locate where a
36 /// callee saved register is in the current frame.
37 class CalleeSavedInfo {
42 explicit CalleeSavedInfo(unsigned R, int FI = 0)
43 : Reg(R), FrameIdx(FI) {}
46 unsigned getReg() const { return Reg; }
47 int getFrameIdx() const { return FrameIdx; }
48 void setFrameIdx(int FI) { FrameIdx = FI; }
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.
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
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
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
79 /// @brief Abstract Stack Frame Information
80 class MachineFrameInfo {
82 // Represent a single object allocated on the stack.
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.
88 // The size of this object on the stack. 0 means a variable sized object,
89 // ~0ULL means a dead object.
92 // The required alignment of this stack slot.
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.
100 // If true the stack object is used as spill slot. It
101 // cannot alias any other memory objects.
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;
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;
115 // If true, the object was mapped into the local frame
116 // block and doesn't need additional handling for allocation beyond that.
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).
125 /// If true, the object has been zero-extended.
128 /// If true, the object has been zero-extended.
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) {}
138 /// The alignment of the stack.
139 unsigned StackAlignment;
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
153 bool StackRealignable;
155 /// Whether the function has the \c alignstack attribute.
158 /// The list of stack objects allocated.
159 std::vector<StackObject> Objects;
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;
166 /// This boolean keeps track of whether any variable
167 /// sized objects have been allocated yet.
168 bool HasVarSizedObjects = false;
170 /// This boolean keeps track of whether there is a call
171 /// to builtin \@llvm.frameaddress.
172 bool FrameAddressTaken = false;
174 /// This boolean keeps track of whether there is a call
175 /// to builtin \@llvm.returnaddress.
176 bool ReturnAddressTaken = false;
178 /// This boolean keeps track of whether there is a call
179 /// to builtin \@llvm.experimental.stackmap.
180 bool HasStackMap = false;
182 /// This boolean keeps track of whether there is a call
183 /// to builtin \@llvm.experimental.patchpoint.
184 bool HasPatchPoint = false;
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;
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;
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
210 unsigned MaxAlignment = 0;
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;
217 /// Set to true if this function has any function calls.
218 bool HasCalls = false;
220 /// The frame index for the stack protector.
221 int StackProtectorIdx = -1;
223 /// The frame index for the function context. Used for SjLj exceptions.
224 int FunctionContextIdx = -1;
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;
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
236 std::vector<CalleeSavedInfo> CSInfo;
238 /// Has CSInfo been set yet?
239 bool CSIValid = false;
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;
245 /// Size of the pre-allocated local frame block.
246 int64_t LocalFrameSize = 0;
248 /// Required alignment of the local object blob, which is the strictest
249 /// alignment of any object in it.
250 unsigned LocalFrameMaxAlign = 0;
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;
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;
261 /// True if the function contains operations which will lower down to
262 /// instructions which manipulate the stack pointer.
263 bool HasCopyImplyingStackAdjustment = false;
265 /// True if the function contains a call to the llvm.vastart intrinsic.
266 bool HasVAStart = false;
268 /// True if this is a varargs function that contains a musttail call.
269 bool HasMustTailInVarArgFunc = false;
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;
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;
282 explicit MachineFrameInfo(unsigned StackAlignment, bool StackRealignable,
284 : StackAlignment(StackAlignment), StackRealignable(StackRealignable),
285 ForcedRealign(ForcedRealign) {}
287 /// Return true if there are any stack objects in this function.
288 bool hasStackObjects() const { return !Objects.empty(); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
329 /// Return the minimum frame object index.
330 int getObjectIndexBegin() const { return -NumFixedObjects; }
332 /// Return one past the maximum frame object index.
333 int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; }
335 /// Return the number of fixed objects.
336 unsigned getNumFixedObjects() const { return NumFixedObjects; }
338 /// Return the number of objects.
339 unsigned getNumObjects() const { return Objects.size(); }
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;
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];
354 /// Return the number of objects allocated into the local object block.
355 int64_t getLocalFrameObjectCount() const { return LocalFrameObjects.size(); }
357 /// Set the size of the local object blob.
358 void setLocalFrameSize(int64_t sz) { LocalFrameSize = sz; }
360 /// Get the size of the local object blob.
361 int64_t getLocalFrameSize() const { return LocalFrameSize; }
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; }
367 /// Return the required alignment of the local object blob.
368 unsigned getLocalFrameMaxAlign() const { return LocalFrameMaxAlign; }
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;
376 /// setUseLocalStackAllocationBlock - Set whether the local allocation blob
377 /// should be allocated together or let PEI allocate the locals in it
379 void setUseLocalStackAllocationBlock(bool v) {
380 UseLocalStackAllocationBlock = v;
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;
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;
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;
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;
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);
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;
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;
437 bool isObjectZExt(int ObjectIdx) const {
438 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
439 "Invalid Object Idx!");
440 return Objects[ObjectIdx+NumFixedObjects].isZExt;
443 void setObjectZExt(int ObjectIdx, bool IsZExt) {
444 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
445 "Invalid Object Idx!");
446 Objects[ObjectIdx+NumFixedObjects].isZExt = IsZExt;
449 bool isObjectSExt(int ObjectIdx) const {
450 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
451 "Invalid Object Idx!");
452 return Objects[ObjectIdx+NumFixedObjects].isSExt;
455 void setObjectSExt(int ObjectIdx, bool IsSExt) {
456 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
457 "Invalid Object Idx!");
458 Objects[ObjectIdx+NumFixedObjects].isSExt = IsSExt;
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;
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; }
476 /// Set the size of the stack.
477 void setStackSize(uint64_t Size) { StackSize = Size; }
479 /// Estimate and return the size of the stack frame.
480 unsigned estimateStackSize(const MachineFunction &MF) const;
482 /// Return the correction for frame offsets.
483 int getOffsetAdjustment() const { return OffsetAdjustment; }
485 /// Set the correction for frame offsets.
486 void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; }
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; }
492 /// Make sure the function is at least Align bytes aligned.
493 void ensureMaxAlignment(unsigned Align);
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; }
501 /// Return true if the current function has any function calls.
502 bool hasCalls() const { return HasCalls; }
503 void setHasCalls(bool V) { HasCalls = V; }
505 /// Returns true if the function contains opaque dynamic stack adjustments.
506 bool hasOpaqueSPAdjustment() const { return HasOpaqueSPAdjustment; }
507 void setHasOpaqueSPAdjustment(bool B) { HasOpaqueSPAdjustment = B; }
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;
514 void setHasCopyImplyingStackAdjustment(bool B) {
515 HasCopyImplyingStackAdjustment = B;
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; }
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; }
526 /// Returns true if the function contains a tail call.
527 bool hasTailCall() const { return HasTailCall; }
528 void setHasTailCall() { HasTailCall = true; }
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.
535 unsigned getMaxCallFrameSize() const { return MaxCallFrameSize; }
536 void setMaxCallFrameSize(unsigned S) { MaxCallFrameSize = S; }
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);
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);
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);
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;
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.
569 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
570 "Invalid Object Idx!");
571 return Objects[ObjectIdx+NumFixedObjects].isImmutable;
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;
581 bool isStatepointSpillSlotObjectIndex(int ObjectIdx) const {
582 assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
583 "Invalid Object Idx!");
584 return Objects[ObjectIdx+NumFixedObjects].isStatepointSpillSlot;
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;
594 /// Returns true if the specified index corresponds to a variable sized
596 bool isVariableSizedObjectIndex(int ObjectIdx) const {
597 assert(unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
598 "Invalid Object Idx!");
599 return Objects[ObjectIdx + NumFixedObjects].Size == 0;
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");
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);
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);
618 /// Remove or mark dead a statically sized stack object.
619 void RemoveStackObject(int ObjectIdx) {
621 Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
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);
629 /// Returns a reference to call saved info vector for the current function.
630 const std::vector<CalleeSavedInfo> &getCalleeSavedInfo() const {
634 /// Used by prolog/epilog inserter to set the function's callee saved
636 void setCalleeSavedInfo(const std::vector<CalleeSavedInfo> &CSI) {
640 /// Has the callee saved info been calculated yet?
641 bool isCalleeSavedInfoValid() const { return CSIValid; }
643 void setCalleeSavedInfoValid(bool v) { CSIValid = v; }
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; }
650 /// Return a set of physical registers that are pristine.
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
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;
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;
664 /// dump - Print the function to stderr.
665 void dump(const MachineFunction &MF) const;
668 } // End llvm namespace