13#ifndef LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H
14#define LLVM_LIB_TARGET_X86_X86FRAMELOWERING_H
22class MachineInstrBuilder;
23class MCCFIInstruction;
60 std::optional<MachineFunction::DebugInstrOperandPair>
61 InstrNum = std::nullopt)
const;
93 std::vector<CalleeSavedInfo> &CSI)
const override;
122 bool IgnoreSPUpdates)
const override;
156 template <
typename FoundT,
typename CalcT>
159 FoundT FoundStackAdjust, CalcT CalcNewOffset,
160 bool doMergeWithPrevious)
const;
162 template <
typename CalcT>
165 bool doMergeWithPrevious)
const {
168 return mergeSPUpdates(
MBB,
MBBI, FoundStackAdjust, CalcNewOffset,
169 doMergeWithPrevious);
180 int64_t AddOffset,
bool doMergeWithPrevious)
const;
185 const DebugLoc &
DL, int64_t NumBytes,
bool InEpilogue)
const;
215 SmallVectorImpl<int> &ObjectsToAllocate)
const override;
219 const DebugLoc &
DL,
const MCCFIInstruction &CFIInst,
227 const DebugLoc &
DL,
bool RestoreSP =
false)
const;
242 bool hasFPImpl(
const MachineFunction &MF)
const override;
245 bool isWin64Prologue(
const MachineFunction &MF)
const;
247 bool needsDwarfCFI(
const MachineFunction &MF)
const;
249 uint64_t calculateMaxStackAlign(
const MachineFunction &MF)
const;
252 void emitStackProbeCall(
253 MachineFunction &MF, MachineBasicBlock &
MBB,
255 std::optional<MachineFunction::DebugInstrOperandPair> InstrNum)
const;
258 void emitStackProbeInline(MachineFunction &MF, MachineBasicBlock &
MBB,
260 const DebugLoc &
DL,
bool InProlog)
const;
261 void emitStackProbeInlineWindowsCoreCLR64(MachineFunction &MF,
262 MachineBasicBlock &
MBB,
265 bool InProlog)
const;
266 void emitStackProbeInlineGeneric(MachineFunction &MF, MachineBasicBlock &
MBB,
268 const DebugLoc &
DL,
bool InProlog)
const;
270 void emitStackProbeInlineGenericBlock(MachineFunction &MF,
271 MachineBasicBlock &
MBB,
276 void emitStackProbeInlineGenericLoop(MachineFunction &MF,
277 MachineBasicBlock &
MBB,
283 void emitZeroCallUsedRegs(BitVector RegsToZero,
284 MachineBasicBlock &
MBB)
const override;
286 void adjustFrameForMsvcCxxEh(MachineFunction &MF)
const;
289 void BuildStackAlignAND(MachineBasicBlock &
MBB,
294 bool adjustStackWithPops(MachineBasicBlock &
MBB,
299 MachineInstrBuilder BuildStackAdjustment(MachineBasicBlock &
MBB,
302 bool InEpilogue)
const;
304 unsigned getPSPSlotOffsetFromSP(
const MachineFunction &MF)
const;
306 unsigned getWinEHFuncletFrameSize(
const MachineFunction &MF)
const;
309 void emitCatchRetReturnValue(MachineBasicBlock &
MBB,
311 MachineInstr *CatchRet)
const;
315 void spillFPBPUsingSP(MachineFunction &MF,
317 Register BP,
int SPAdjust)
const;
321 void restoreFPBPUsingSP(MachineFunction &MF,
323 Register
FP, Register BP,
int SPAdjust)
const;
325 void saveAndRestoreFPBPUsingSP(MachineFunction &MF,
328 bool SpillFP,
bool SpillBP)
const;
330 void checkInterferedAccess(MachineFunction &MF,
333 bool SpillFP,
bool SpillBP)
const;
338 bool skipSpillFPBP(MachineFunction &MF,
MachineInstrBuilder MachineInstrBuilder & DefMI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static constexpr MCPhysReg SPReg
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
MachineInstrBundleIterator< MachineInstr, true > reverse_iterator
MachineInstrBundleIterator< MachineInstr > iterator
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Wrapper class representing virtual and physical registers.
StackOffset holds a fixed and a scalable offset in bytes.
Information about stack frame layout on the target.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool has128ByteRedZone(const MachineFunction &MF) const
Return true if the function has a redzone (accessible bytes past the frame of the top of stack functi...
void spillFPBP(MachineFunction &MF) const override
If a function uses base pointer and the base pointer is clobbered by inline asm, RA doesn't detect th...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
bool needsFrameIndexResolution(const MachineFunction &MF) const override
const X86RegisterInfo * TRI
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool hasFPImpl(const MachineFunction &MF) const override
hasFPImpl - Return true if the specified function should have a dedicated frame pointer register.
MachineBasicBlock::iterator restoreWin32EHStackPointers(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool RestoreSP=false) const
Sets up EBP and optionally ESI based on the incoming EBP value.
int getInitialCFAOffset(const MachineFunction &MF) const override
Return initial CFA offset value i.e.
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a prologue for the target.
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
void emitStackProbe(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool InProlog, std::optional< MachineFunction::DebugInstrOperandPair > InstrNum=std::nullopt) const
Emit target stack probe code.
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, bool IsPrologue) const
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int64_t mergeSPAdd(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, int64_t AddOffset, bool doMergeWithPrevious) const
Equivalent to: mergeSPUpdates(MBB, MBBI, [AddOffset](int64_t Offset) { return AddOffset + Offset; },...
StackOffset getFrameIndexReferenceSP(const MachineFunction &MF, int FI, Register &SPReg, int Adjustment) const
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const override
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologMBB) const override
Replace a StackProbe inline-stub with the actual probe code inline.
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
void emitSPUpdate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &DL, int64_t NumBytes, bool InEpilogue) const
Emit a series of instructions to increment / decrement the stack pointer by a constant value.
bool canUseAsEpilogue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a epilogue for the target.
bool Is64Bit
Is64Bit implies that x86_64 instructions are available.
Register getInitialCFARegister(const MachineFunction &MF) const override
Return initial CFA register value i.e.
bool Uses64BitFramePtr
True if the 64-bit frame or stack pointer should be used.
unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
Adjust the prologue to have the function use segmented stacks.
DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const override
Return the frame base information to be encoded in the DWARF subprogram debug info.
void emitCalleeSavedFrameMovesFullCFA(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const override
Emits Dwarf Info specifying offsets of callee saved registers and frame pointer.
int getWin64EHFrameIndexRef(const MachineFunction &MF, int FI, Register &SPReg) const
bool canUseLEAForSPInEpilogue(const MachineFunction &MF) const
Check that LEA can be used on SP in an epilogue sequence for MF.
bool stackProbeFunctionModifiesSP() const override
Does the stack probe function call return with a modified stack pointer?
void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override
Order the symbols in the local stack.
void BuildCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const MCCFIInstruction &CFIInst, MachineInstr::MIFlag Flag=MachineInstr::NoFlags) const
Wraps up getting a CFI index and building a MachineInstr for it.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
StackOffset getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const override
Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will ...
void restoreWinEHStackPointersInParent(MachineFunction &MF) const
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const override
Erlang programs may need a special prologue to handle the stack size they might need at runtime.
This is an optimization pass for GlobalISel generic memory operations.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.