LLVM 19.0.0git
Go to the documentation of this file.
1//==-- AArch64FrameLowering.h - TargetFrameLowering for AArch64 --*- C++ -*-==//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
19namespace llvm {
25 true /*StackRealignable*/) {}
27 void resetCFIToInitialState(MachineBasicBlock &MBB) const override;
31 MachineBasicBlock::iterator I) const override;
33 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
34 /// the function.
35 void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
36 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override;
38 bool enableCFIFixup(MachineFunction &MF) const override;
40 bool canUseAsPrologue(const MachineBasicBlock &MBB) const override;
43 Register &FrameReg) const override;
45 Register &FrameReg, bool PreferFP,
46 bool ForSimm) const;
48 int64_t ObjectOffset, bool isFixed,
49 bool isSVE, Register &FrameReg,
50 bool PreferFP, bool ForSimm) const;
54 const TargetRegisterInfo *TRI) const override;
56 bool
60 const TargetRegisterInfo *TRI) const override;
62 /// Can this function use the red zone for local allocations.
63 bool canUseRedZone(const MachineFunction &MF) const;
65 bool hasFP(const MachineFunction &MF) const override;
66 bool hasReservedCallFrame(const MachineFunction &MF) const override;
70 std::vector<CalleeSavedInfo> &CSI,
71 unsigned &MinCSFrameIndex,
72 unsigned &MaxCSFrameIndex) const override;
75 RegScavenger *RS) const override;
77 /// Returns true if the target will correctly handle shrink wrapping.
78 bool enableShrinkWrapping(const MachineFunction &MF) const override {
79 return true;
80 }
82 bool enableStackSlotScavenging(const MachineFunction &MF) const override;
86 RegScavenger *RS) const override;
88 void
90 RegScavenger *RS) const override;
92 unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override;
94 unsigned getWinEHFuncletFrameSize(const MachineFunction &MF) const;
98 Register &FrameReg,
99 bool IgnoreSPUpdates) const override;
101 int FI) const override;
102 int getSEHFrameIndexOffset(const MachineFunction &MF, int FI) const;
105 switch (ID) {
106 default:
107 return false;
111 return true;
112 }
113 }
115 bool isStackIdSafeForLocalArea(unsigned StackId) const override {
116 // We don't support putting SVE objects into the pre-allocated local
117 // frame block at the moment.
118 return StackId != TargetStackID::ScalableVector;
119 }
121 void
123 SmallVectorImpl<int> &ObjectsToAllocate) const override;
126 /// Returns true if a homogeneous prolog or epilog code can be emitted
127 /// for the size optimization. If so, HOM_Prolog/HOM_Epilog pseudo
128 /// instructions are emitted in place. When Exit block is given, this check is
129 /// for epilog.
130 bool homogeneousPrologEpilog(MachineFunction &MF,
131 MachineBasicBlock *Exit = nullptr) const;
133 /// Returns true if CSRs should be paired.
134 bool producePairRegisters(MachineFunction &MF) const;
136 bool shouldCombineCSRLocalStackBump(MachineFunction &MF,
137 uint64_t StackBumpBytes) const;
139 int64_t estimateSVEStackObjectOffsets(MachineFrameInfo &MF) const;
140 int64_t assignSVEStackObjectOffsets(MachineFrameInfo &MF,
141 int &MinCSFrameIndex,
142 int &MaxCSFrameIndex) const;
143 bool shouldCombineCSRLocalStackBumpInEpilogue(MachineBasicBlock &MBB,
144 unsigned StackBumpBytes) const;
145 void emitCalleeSavedGPRLocations(MachineBasicBlock &MBB,
147 void emitCalleeSavedSVELocations(MachineBasicBlock &MBB,
149 void emitCalleeSavedGPRRestores(MachineBasicBlock &MBB,
151 void emitCalleeSavedSVERestores(MachineBasicBlock &MBB,
153 void allocateStackSpace(MachineBasicBlock &MBB,
155 int64_t RealignmentPadding, StackOffset AllocSize,
156 bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFI,
157 StackOffset InitialOffset, bool FollowupAllocs) const;
159 /// Emit target zero call-used regs.
160 void emitZeroCallUsedRegs(BitVector RegsToZero,
161 MachineBasicBlock &MBB) const override;
163 /// Replace a StackProbe stub (if any) with the actual probe code inline
164 void inlineStackProbe(MachineFunction &MF,
165 MachineBasicBlock &PrologueMBB) const override;
167 void inlineStackProbeFixed(MachineBasicBlock::iterator MBBI,
168 Register ScratchReg, int64_t FrameSize,
169 StackOffset CFAOffset) const;
172 inlineStackProbeLoopExactMultiple(MachineBasicBlock::iterator MBBI,
173 int64_t NegProbeSize,
174 Register TargetReg) const;
177} // End llvm namespace
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator MBBI
basic Basic Alias true
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned const TargetRegisterInfo * TRI
void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a prologue for the target.
bool enableStackSlotScavenging(const MachineFunction &MF) const override
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
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...
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...
StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const override
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
TargetStackID::Value getStackIDForScalableVectors() const override
Returns the StackID that scalable vectors should be associated with.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool enableCFIFixup(MachineFunction &MF) const override
Returns true if we may need to fix the unwind information for the function.
void resetCFIToInitialState(MachineBasicBlock &MBB) const override
Emit CFI instructions that recreate the state of the unwind information upon fucntion entry.
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
bool enableShrinkWrapping(const MachineFunction &MF) const override
Returns true if the target will correctly handle shrink wrapping.
bool canUseRedZone(const MachineFunction &MF) const
Can this function use the red zone for local allocations.
bool isSupportedStackID(TargetStackID::Value ID) const override
void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS) const override
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
int getSEHFrameIndexOffset(const MachineFunction &MF, int FI) const
unsigned getWinEHFuncletFrameSize(const MachineFunction &MF) const
Funclets only need to account for space for the callee saved registers, as the locals are accounted f...
void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &ObjectsToAllocate) const override
Order the symbols in the local stack frame.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
StackOffset resolveFrameOffsetReference(const MachineFunction &MF, int64_t ObjectOffset, bool isFixed, bool isSVE, Register &FrameReg, bool PreferFP, bool ForSimm) const
bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex) const override
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
StackOffset getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const override
For Win64 AArch64 EH, the offset to the Unwind object is from the SP before the update.
bool isStackIdSafeForLocalArea(unsigned StackId) const override
This method returns whether or not it is safe for an object with the given stack id to be bundled int...
StackOffset resolveFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg, bool PreferFP, bool ForSimm) const
unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const override
The parent frame offset (aka dispFrame) is only used on X86_64 to retrieve the parent's frame pointer...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:33
Information about stack frame layout on the target.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39