30 #define DEBUG_TYPE "nvptx-prolog-epilog" 46 return new NVPTXPrologEpilogPass();
57 calculateFrameObjectOffsets(MF);
61 for (
unsigned i = 0, e =
MI.getNumOperands(); i != e; ++i) {
62 if (!
MI.getOperand(i).isFI())
68 if (
MI.isDebugValue()) {
69 assert(i == 0 &&
"Frame indices can only appear as the first " 70 "operand of a DBG_VALUE machine instruction");
74 MI.getOperand(0).ChangeToRegister(Reg,
false);
75 MI.getOperand(0).setIsDebug();
78 MI.getOperand(3).setMetadata(DIExpr);
93 if (
I->isReturnBlock())
103 bool StackGrowsDown, int64_t &
Offset,
104 unsigned &MaxAlign) {
113 MaxAlign =
std::max(MaxAlign, Align);
116 Offset = (Offset + Align - 1) / Align * Align;
118 if (StackGrowsDown) {
119 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << -Offset
123 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << FrameIdx <<
") at SP[" << Offset
131 NVPTXPrologEpilogPass::calculateFrameObjectOffsets(
MachineFunction &Fn) {
135 bool StackGrowsDown =
146 LocalAreaOffset = -LocalAreaOffset;
147 assert(LocalAreaOffset >= 0
148 &&
"Local area offset should be in direction of stack growth");
149 int64_t
Offset = LocalAreaOffset;
158 if (StackGrowsDown) {
168 if (FixedOff > Offset) Offset = FixedOff;
185 Offset = (Offset + Align - 1) / Align * Align;
187 LLVM_DEBUG(
dbgs() <<
"Local frame base offset: " << Offset <<
"\n");
192 int64_t FIOffset = (StackGrowsDown ? -
Offset :
Offset) + Entry.second;
193 LLVM_DEBUG(
dbgs() <<
"alloc FI(" << Entry.first <<
") at SP[" << FIOffset
200 MaxAlign =
std::max(Align, MaxAlign);
240 StackAlign =
std::max(StackAlign, MaxAlign);
241 unsigned AlignMask = StackAlign - 1;
242 Offset = (Offset + AlignMask) & ~uint64_t(AlignMask);
246 int64_t StackSize = Offset - LocalAreaOffset;
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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, bool DerefBefore, int64_t Offset=0, bool DerefAfter=false, bool StackValue=false)
Prepend DIExpr with a deref and offset operation and optionally turn it into a stack value...
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...
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.
Iterator for intrusive lists based on ilist_node.
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.
unsigned getLocalFrameMaxAlign() const
Return the required alignment of the local object blob.
virtual const TargetFrameLowering * getFrameLowering() const
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.