14 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
15 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
18 #include "llvm/Support/DataTypes.h"
25 class TargetRegisterClass;
27 class MachineFunction;
28 class MachineBasicBlock;
29 class TargetFrameLowering;
43 : Reg(R), FrameIdx(FI) {}
46 unsigned getReg()
const {
return Reg; }
118 StackObject(uint64_t Sz,
unsigned Al, int64_t
SP,
bool IM,
120 : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
121 isSpillSlot(isSS), Alloca(Val), PreAllocated(
false), isAliased(A) {}
125 unsigned StackAlignment;
128 bool StackRealignable;
131 std::vector<StackObject> Objects;
136 unsigned NumFixedObjects;
140 bool HasVarSizedObjects;
144 bool FrameAddressTaken;
148 bool ReturnAddressTaken;
173 int OffsetAdjustment;
182 unsigned MaxAlignment;
193 int StackProtectorIdx;
196 int FunctionContextIdx;
202 unsigned MaxCallFrameSize;
208 std::vector<CalleeSavedInfo> CSInfo;
218 int64_t LocalFrameSize;
222 unsigned LocalFrameMaxAlign;
227 bool UseLocalStackAllocationBlock;
234 bool HasOpaqueSPAdjustment;
240 bool HasMustTailInVarArgFunc;
255 : StackAlignment(StackAlign), StackRealignable(isStackRealign),
256 RealignOption(RealignOpt) {
257 StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
258 HasVarSizedObjects =
false;
259 FrameAddressTaken =
false;
260 ReturnAddressTaken =
false;
262 HasPatchPoint =
false;
263 AdjustsStack =
false;
265 StackProtectorIdx = -1;
266 FunctionContextIdx = -1;
267 MaxCallFrameSize = 0;
270 LocalFrameMaxAlign = 0;
271 UseLocalStackAllocationBlock =
false;
272 HasOpaqueSPAdjustment =
false;
274 HasMustTailInVarArgFunc =
false;
335 LocalFrameObjects.
push_back(std::pair<int, int64_t>(ObjectIndex, Offset));
336 Objects[ObjectIndex + NumFixedObjects].PreAllocated =
true;
341 assert (i >= 0 && (
unsigned)i < LocalFrameObjects.
size() &&
342 "Invalid local object reference!");
343 return LocalFrameObjects[i];
370 UseLocalStackAllocationBlock = v;
375 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
376 "Invalid Object Idx!");
377 return Objects[ObjectIdx+NumFixedObjects].PreAllocated;
382 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
383 "Invalid Object Idx!");
384 return Objects[ObjectIdx+NumFixedObjects].Size;
389 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
390 "Invalid Object Idx!");
391 Objects[ObjectIdx+NumFixedObjects].Size = Size;
396 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
397 "Invalid Object Idx!");
398 return Objects[ObjectIdx+NumFixedObjects].Alignment;
403 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
404 "Invalid Object Idx!");
405 Objects[ObjectIdx+NumFixedObjects].Alignment =
Align;
412 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
413 "Invalid Object Idx!");
414 return Objects[ObjectIdx+NumFixedObjects].Alloca;
420 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
421 "Invalid Object Idx!");
423 "Getting frame offset for a dead object?");
424 return Objects[ObjectIdx+NumFixedObjects].SPOffset;
430 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
431 "Invalid Object Idx!");
433 "Setting frame offset for a dead object?");
434 Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
500 bool isAliased =
false);
508 return ObjectIdx < 0 && (ObjectIdx >= -(
int)NumFixedObjects);
514 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
515 "Invalid Object Idx!");
516 return Objects[ObjectIdx+NumFixedObjects].isAliased;
525 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
526 "Invalid Object Idx!");
527 return Objects[ObjectIdx+NumFixedObjects].isImmutable;
532 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
533 "Invalid Object Idx!");
534 return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;
539 assert(
unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
540 "Invalid Object Idx!");
541 return Objects[ObjectIdx+NumFixedObjects].Size == ~0ULL;
547 assert(
unsigned(ObjectIdx + NumFixedObjects) < Objects.size() &&
548 "Invalid Object Idx!");
549 return Objects[ObjectIdx + NumFixedObjects].Size == 0;
564 Objects[ObjectIdx+NumFixedObjects].Size = ~0ULL;
void setHasStackMap(bool s=true)
int getFunctionContextIndex() const
Return the index for the function context object.
void setFrameAddressIsTaken(bool T)
void push_back(const T &Elt)
void setSavePoint(MachineBasicBlock *NewSave)
void setRestorePoint(MachineBasicBlock *NewRestore)
void mapLocalFrameObject(int ObjectIndex, int64_t Offset)
Map a frame index into the local object block.
void setCalleeSavedInfoValid(bool v)
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
MachineBasicBlock * getRestorePoint() const
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
unsigned getNumObjects() const
Return the number of objects.
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
int64_t getLocalFrameSize() const
Get the size of the local object blob.
void setHasPatchPoint(bool s=true)
void setLocalFrameSize(int64_t sz)
Set the size of the local object blob.
void setUseLocalStackAllocationBlock(bool v)
setUseLocalStackAllocationBlock - Set whether the local allocation blob should be allocated together ...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
void setFunctionContextIndex(int I)
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
void print(const MachineFunction &MF, raw_ostream &OS) const
Used by the MachineFunction printer to print information about stack objects.
int getObjectIndexBegin() const
Return the minimum frame object index.
bool hasStackObjects() const
Return true if there are any stack objects in this function.
void setHasMustTailInVarArgFunc(bool B)
int getOffsetAdjustment() const
Return the correction for frame offsets.
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
void setLocalFrameMaxAlign(unsigned Align)
Required alignment of the local object blob, which is the strictest alignment of any object in it...
bool isImmutableObjectIndex(int ObjectIdx) const
isImmutableObjectIndex - Returns true if the specified index corresponds to an immutable object...
unsigned getNumFixedObjects() const
Return the number of fixed objects.
void setStackProtectorIndex(int I)
void setHasOpaqueSPAdjustment(bool B)
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
bool isSpillSlotObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a spill slot.
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
void RemoveStackObject(int ObjectIdx)
Remove or mark dead a statically sized stack object.
bool getUseLocalStackAllocationBlock()
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
bool isAliasedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to an object that might be pointed to by an LLVM IR v...
void setStackSize(uint64_t Size)
Set the size of the stack.
bool hasVAStart() const
Returns true if the function calls the llvm.va_start intrinsic.
void setHasVAStart(bool B)
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
void setObjectSize(int ObjectIdx, int64_t Size)
Change the size of the specified stack object.
int CreateSpillStackObject(uint64_t Size, unsigned Alignment)
Create a new statically sized stack object that represents a spill slot, returning a nonnegative iden...
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
bool hasCalls() const
Return true if the current function has any function calls.
int64_t getLocalFrameObjectCount()
Return the number of objects allocated into the local object block.
bool hasTailCall() const
Returns true if the function contains a tail call.
CalleeSavedInfo(unsigned R, int FI=0)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
void setAdjustsStack(bool V)
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
MachineFrameInfo(unsigned StackAlign, bool isStackRealign, bool RealignOpt)
int getStackProtectorIndex() const
Return the index for the stack protector object.
MachineBasicBlock * getSavePoint() const
void setCalleeSavedInfo(const std::vector< CalleeSavedInfo > &CSI)
Used by prolog/epilog inserter to set the function's callee saved information.
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
void ensureMaxAlignment(unsigned Align)
Make sure the function is at least Align bytes aligned.
void setMaxCallFrameSize(unsigned S)
int CreateFixedSpillStackObject(uint64_t Size, int64_t SPOffset)
Create a spill slot at a fixed location on the stack.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
void setReturnAddressIsTaken(bool s)
void dump(const MachineFunction &MF) const
dump - Print the function to stderr.
This class implements an extremely fast bulk output stream that can only output to a stream...
bool hasOpaqueSPAdjustment() const
Returns true if the function contains opaque dynamic stack adjustments.
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
std::pair< int, int64_t > getLocalFrameObjectMap(int i)
Get the local offset mapping for a for an object.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
int CreateVariableSizedObject(unsigned Alignment, const AllocaInst *Alloca)
Notify the MachineFrameInfo object that a variable sized object has been created. ...
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool hasMustTailInVarArgFunc() const
Returns true if the function is variadic and contains a musttail call.
AllocaInst - an instruction to allocate memory on the stack.