Go to the documentation of this file.
29 #define DEBUG_TYPE "nvptx-prolog-epilog"
45 return new NVPTXPrologEpilogPass();
56 calculateFrameObjectOffsets(MF);
60 for (
unsigned i = 0,
e =
MI.getNumOperands();
i !=
e; ++
i) {
61 if (!
MI.getOperand(
i).isFI())
67 if (
MI.isDebugValue()) {
70 MI.isDebugOperand(&
Op) &&
71 "Frame indices can only appear as a debug operand in a DBG_VALUE*"
72 " machine instruction");
76 Op.ChangeToRegister(
Reg,
false);
78 if (
MI.isNonListDebugValue()) {
83 unsigned OpIdx =
MI.getDebugOperandIndex(&
Op);
86 MI.getDebugExpressionOp().setMetadata(DIExpr);
101 if (
I->isReturnBlock())
110 bool StackGrowsDown, int64_t &Offset,
120 MaxAlign =
std::max(MaxAlign, Alignment);
123 Offset =
alignTo(Offset, Alignment);
125 if (StackGrowsDown) {
126 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
130 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
138 NVPTXPrologEpilogPass::calculateFrameObjectOffsets(
MachineFunction &Fn) {
142 bool StackGrowsDown =
153 LocalAreaOffset = -LocalAreaOffset;
154 assert(LocalAreaOffset >= 0
155 &&
"Local area offset should be in direction of stack growth");
156 int64_t
Offset = LocalAreaOffset;
165 if (StackGrowsDown) {
175 if (FixedOff > Offset)
Offset = FixedOff;
194 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
199 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
200 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
207 MaxAlign =
std::max(Alignment, MaxAlign);
251 int64_t StackSize =
Offset - LocalAreaOffset;
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
This is an optimization pass for GlobalISel generic memory operations.
Information about stack frame layout on the target.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
Reg
All possible values of the reg field in the ModR/M byte.
virtual void getOffsetOpcodes(const StackOffset &Offset, SmallVectorImpl< uint64_t > &Ops) const
Gets the DWARF expression opcodes for Offset.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void setStackSize(uint64_t Size)
Set the size of the stack.
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
int getObjectIndexEnd() const
Return one past the maximum frame object index.
unsigned const TargetRegisterInfo * TRI
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static DIExpression * appendOpsToArg(const DIExpression *Expr, ArrayRef< uint64_t > Ops, unsigned ArgNo, bool StackValue=false)
Create a copy of Expr by appending the given list of Ops to each instance of the operand DW_OP_LLVM_a...
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
MachineOperand class - Representation of each machine instruction operand.
MachineFunctionPass * createNVPTXPrologEpilogPass()
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
This struct is a compact representation of a valid (non-zero power of two) alignment.
int getObjectIndexBegin() const
Return the minimum frame object index.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
int64_t getLocalFrameSize() const
Get the size of the local object blob.
Representation of each machine instruction.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
virtual void eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const =0
This method must be overriden to eliminate abstract frame indices from instructions which may use the...
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
TargetSubtargetInfo - Generic base class for all target subtargets.
static void AdjustStackOffset(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, Align &MaxAlign)
AdjustStackOffset - Helper function used to adjust the stack frame offset.
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Wrapper class representing virtual and physical registers.
virtual const TargetFrameLowering * getFrameLowering() const
Iterator for intrusive lists based on ilist_node.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
bool hasStackRealignment(const MachineFunction &MF) const
True if stack realignment is required and still possible.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
DIExpression * prependOffsetExpression(const DIExpression *Expr, unsigned PrependFlags, const StackOffset &Offset) const
Prepends a DWARF expression for Offset to DIExpression Expr.