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()) {
68 assert(i == 0 &&
"Frame indices can only appear as the first " 69 "operand of a DBG_VALUE machine instruction");
73 MI.getOperand(0).ChangeToRegister(Reg,
false);
74 MI.getOperand(0).setIsDebug();
77 MI.getOperand(3).setMetadata(DIExpr);
92 if (
I->isReturnBlock())
102 bool StackGrowsDown, int64_t &
Offset,
103 unsigned &MaxAlign) {
112 MaxAlign =
std::max(MaxAlign, Align);
115 Offset = (Offset + Align - 1) / Align * Align;
117 if (StackGrowsDown) {
118 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
122 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
130 NVPTXPrologEpilogPass::calculateFrameObjectOffsets(
MachineFunction &Fn) {
134 bool StackGrowsDown =
145 LocalAreaOffset = -LocalAreaOffset;
146 assert(LocalAreaOffset >= 0
147 &&
"Local area offset should be in direction of stack growth");
148 int64_t
Offset = LocalAreaOffset;
157 if (StackGrowsDown) {
167 if (FixedOff > Offset) Offset = FixedOff;
184 Offset = (Offset + Align - 1) / Align * Align;
186 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
191 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
192 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
199 MaxAlign =
std::max(Align, MaxAlign);
239 StackAlign =
std::max(StackAlign, MaxAlign);
240 unsigned AlignMask = StackAlign - 1;
241 Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
245 int64_t StackSize = Offset - LocalAreaOffset;
This class represents lattice values for constants.
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
int64_t getLocalFrameSize() const
Get the size of the local object blob.
MachineFunctionPass * createNVPTXPrologEpilogPass()
unsigned const TargetRegisterInfo * TRI
bool adjustsStack() const
Return true if this function adjusts the stack – e.g., when calling another function.
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
static DIExpression * prepend(const DIExpression *Expr, uint8_t Flags, int64_t Offset=0)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value or/and an ...
std::pair< int, int64_t > getLocalFrameObjectMap(int i) const
Get the local offset mapping for a for an object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
bool getUseLocalStackAllocationBlock() const
Get whether the local allocation blob should be allocated together or let PEI allocate the locals in ...
static void AdjustStackOffset(MachineFrameInfo &MFI, int FrameIdx, bool StackGrowsDown, int64_t &Offset, unsigned &MaxAlign)
AdjustStackOffset - Helper function used to adjust the stack frame offset.
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
int getObjectIndexBegin() const
Return the minimum frame object index.
bool isObjectPreAllocated(int ObjectIdx) const
Return true if the object was pre-allocated into the local block.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
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...
uint64_t value() const
This is a hole in the type system and should not be abused.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void setStackSize(uint64_t Size)
Set the size of the stack.
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned getStackAlignment() 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, we reserve argument space for call sites in the function immediately on entry to the current function.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Iterator for intrusive lists based on ilist_node.
Align max(MaybeAlign Lhs, Align Rhs)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
Information about stack frame layout on the target.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getTransientStackAlignment() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
TargetSubtargetInfo - Generic base class for all target subtargets.
Representation of each machine instruction.
virtual const TargetFrameLowering * getFrameLowering() const
Align getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
void setObjectOffset(int ObjectIdx, int64_t SPOffset)
Set the stack frame offset of the specified object.
int64_t getLocalFrameObjectCount() const
Return the number of objects allocated into the local object block.