LLVM  14.0.0git
TargetFrameLowering.h
Go to the documentation of this file.
1 //===-- llvm/CodeGen/TargetFrameLowering.h ----------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Interface to describe the layout of a stack frame on the target machine.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CODEGEN_TARGETFRAMELOWERING_H
14 #define LLVM_CODEGEN_TARGETFRAMELOWERING_H
15 
17 #include "llvm/Support/TypeSize.h"
18 #include <vector>
19 
20 namespace llvm {
21  class BitVector;
22  class CalleeSavedInfo;
23  class MachineFunction;
24  class RegScavenger;
25 
26 namespace TargetStackID {
27 enum Value {
28  Default = 0,
29  SGPRSpill = 1,
31  WasmLocal = 3,
32  NoAlloc = 255
33 };
34 }
35 
36 /// Information about stack frame layout on the target. It holds the direction
37 /// of stack growth, the known stack alignment on entry to each function, and
38 /// the offset to the locals area.
39 ///
40 /// The offset to the local area is the offset from the stack pointer on
41 /// function entry to the first location where function data (local variables,
42 /// spill locations) can be stored.
44 public:
46  StackGrowsUp, // Adding to the stack increases the stack address
47  StackGrowsDown // Adding to the stack decreases the stack address
48  };
49 
50  // Maps a callee saved register to a stack slot with a fixed offset.
51  struct SpillSlot {
52  unsigned Reg;
53  int Offset; // Offset relative to stack pointer on function entry.
54  };
55 
56  struct DwarfFrameBase {
57  // The frame base may be either a register (the default), the CFA,
58  // or a WebAssembly-specific location description.
60  struct WasmFrameBase {
61  unsigned Kind; // Wasm local, global, or value stack
62  unsigned Index;
63  };
64  union {
65  unsigned Reg;
67  } Location;
68  };
69 
70 private:
71  StackDirection StackDir;
72  Align StackAlignment;
73  Align TransientStackAlignment;
74  int LocalAreaOffset;
75  bool StackRealignable;
76 public:
78  Align TransAl = Align(1), bool StackReal = true)
79  : StackDir(D), StackAlignment(StackAl), TransientStackAlignment(TransAl),
80  LocalAreaOffset(LAO), StackRealignable(StackReal) {}
81 
82  virtual ~TargetFrameLowering();
83 
84  // These methods return information that describes the abstract stack layout
85  // of the target machine.
86 
87  /// getStackGrowthDirection - Return the direction the stack grows
88  ///
89  StackDirection getStackGrowthDirection() const { return StackDir; }
90 
91  /// getStackAlignment - This method returns the number of bytes to which the
92  /// stack pointer must be aligned on entry to a function. Typically, this
93  /// is the largest alignment for any data object in the target.
94  ///
95  unsigned getStackAlignment() const { return StackAlignment.value(); }
96  /// getStackAlignment - This method returns the number of bytes to which the
97  /// stack pointer must be aligned on entry to a function. Typically, this
98  /// is the largest alignment for any data object in the target.
99  ///
100  Align getStackAlign() const { return StackAlignment; }
101 
102  /// alignSPAdjust - This method aligns the stack adjustment to the correct
103  /// alignment.
104  ///
105  int alignSPAdjust(int SPAdj) const {
106  if (SPAdj < 0) {
107  SPAdj = -alignTo(-SPAdj, StackAlignment);
108  } else {
109  SPAdj = alignTo(SPAdj, StackAlignment);
110  }
111  return SPAdj;
112  }
113 
114  /// getTransientStackAlignment - This method returns the number of bytes to
115  /// which the stack pointer must be aligned at all times, even between
116  /// calls.
117  ///
118  Align getTransientStackAlign() const { return TransientStackAlignment; }
119 
120  /// isStackRealignable - This method returns whether the stack can be
121  /// realigned.
122  bool isStackRealignable() const {
123  return StackRealignable;
124  }
125 
126  /// Return the skew that has to be applied to stack alignment under
127  /// certain conditions (e.g. stack was adjusted before function \p MF
128  /// was called).
129  virtual unsigned getStackAlignmentSkew(const MachineFunction &MF) const;
130 
131  /// This method returns whether or not it is safe for an object with the
132  /// given stack id to be bundled into the local area.
133  virtual bool isStackIdSafeForLocalArea(unsigned StackId) const {
134  return true;
135  }
136 
137  /// getOffsetOfLocalArea - This method returns the offset of the local area
138  /// from the stack pointer on entrance to a function.
139  ///
140  int getOffsetOfLocalArea() const { return LocalAreaOffset; }
141 
142  /// isFPCloseToIncomingSP - Return true if the frame pointer is close to
143  /// the incoming stack pointer, false if it is close to the post-prologue
144  /// stack pointer.
145  virtual bool isFPCloseToIncomingSP() const { return true; }
146 
147  /// assignCalleeSavedSpillSlots - Allows target to override spill slot
148  /// assignment logic. If implemented, assignCalleeSavedSpillSlots() should
149  /// assign frame slots to all CSI entries and return true. If this method
150  /// returns false, spill slots will be assigned using generic implementation.
151  /// assignCalleeSavedSpillSlots() may add, delete or rearrange elements of
152  /// CSI.
154  const TargetRegisterInfo *TRI,
155  std::vector<CalleeSavedInfo> &CSI,
156  unsigned &MinCSFrameIndex,
157  unsigned &MaxCSFrameIndex) const {
158  return assignCalleeSavedSpillSlots(MF, TRI, CSI);
159  }
160 
161  virtual bool
163  const TargetRegisterInfo *TRI,
164  std::vector<CalleeSavedInfo> &CSI) const {
165  return false;
166  }
167 
168  /// getCalleeSavedSpillSlots - This method returns a pointer to an array of
169  /// pairs, that contains an entry for each callee saved register that must be
170  /// spilled to a particular stack location if it is spilled.
171  ///
172  /// Each entry in this array contains a <register,offset> pair, indicating the
173  /// fixed offset from the incoming stack pointer that each register should be
174  /// spilled at. If a register is not listed here, the code generator is
175  /// allowed to spill it anywhere it chooses.
176  ///
177  virtual const SpillSlot *
178  getCalleeSavedSpillSlots(unsigned &NumEntries) const {
179  NumEntries = 0;
180  return nullptr;
181  }
182 
183  /// targetHandlesStackFrameRounding - Returns true if the target is
184  /// responsible for rounding up the stack frame (probably at emitPrologue
185  /// time).
186  virtual bool targetHandlesStackFrameRounding() const {
187  return false;
188  }
189 
190  /// Returns true if the target will correctly handle shrink wrapping.
191  virtual bool enableShrinkWrapping(const MachineFunction &MF) const {
192  return false;
193  }
194 
195  /// Returns true if the stack slot holes in the fixed and callee-save stack
196  /// area should be used when allocating other stack locations to reduce stack
197  /// size.
198  virtual bool enableStackSlotScavenging(const MachineFunction &MF) const {
199  return false;
200  }
201 
202  /// Returns true if the target can safely skip saving callee-saved registers
203  /// for noreturn nounwind functions.
204  virtual bool enableCalleeSaveSkip(const MachineFunction &MF) const;
205 
206  /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
207  /// the function.
208  virtual void emitPrologue(MachineFunction &MF,
209  MachineBasicBlock &MBB) const = 0;
210  virtual void emitEpilogue(MachineFunction &MF,
211  MachineBasicBlock &MBB) const = 0;
212 
213  /// With basic block sections, emit callee saved frame moves for basic blocks
214  /// that are in a different section.
215  virtual void
218 
219  /// Replace a StackProbe stub (if any) with the actual probe code inline
221  MachineBasicBlock &PrologueMBB) const {}
222 
223  /// Adjust the prologue to have the function use segmented stacks. This works
224  /// by adding a check even before the "normal" function prologue.
226  MachineBasicBlock &PrologueMBB) const {}
227 
228  /// Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in
229  /// the assembly prologue to explicitly handle the stack.
231  MachineBasicBlock &PrologueMBB) const {}
232 
233  /// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
234  /// saved registers and returns true if it isn't possible / profitable to do
235  /// so by issuing a series of store instructions via
236  /// storeRegToStackSlot(). Returns false otherwise.
240  const TargetRegisterInfo *TRI) const {
241  return false;
242  }
243 
244  /// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
245  /// saved registers and returns true if it isn't possible / profitable to do
246  /// so by issuing a series of load instructions via loadRegToStackSlot().
247  /// If it returns true, and any of the registers in CSI is not restored,
248  /// it sets the corresponding Restored flag in CSI to false.
249  /// Returns false otherwise.
250  virtual bool
254  const TargetRegisterInfo *TRI) const {
255  return false;
256  }
257 
258  /// Return true if the target wants to keep the frame pointer regardless of
259  /// the function attribute "frame-pointer".
260  virtual bool keepFramePointer(const MachineFunction &MF) const {
261  return false;
262  }
263 
264  /// hasFP - Return true if the specified function should have a dedicated
265  /// frame pointer register. For most targets this is true only if the function
266  /// has variable sized allocas or if frame pointer elimination is disabled.
267  virtual bool hasFP(const MachineFunction &MF) const = 0;
268 
269  /// hasReservedCallFrame - Under normal circumstances, when a frame pointer is
270  /// not required, we reserve argument space for call sites in the function
271  /// immediately on entry to the current function. This eliminates the need for
272  /// add/sub sp brackets around call sites. Returns true if the call frame is
273  /// included as part of the stack frame.
274  virtual bool hasReservedCallFrame(const MachineFunction &MF) const {
275  return !hasFP(MF);
276  }
277 
278  /// canSimplifyCallFramePseudos - When possible, it's best to simplify the
279  /// call frame pseudo ops before doing frame index elimination. This is
280  /// possible only when frame index references between the pseudos won't
281  /// need adjusting for the call frame adjustments. Normally, that's true
282  /// if the function has a reserved call frame or a frame pointer. Some
283  /// targets (Thumb2, for example) may have more complicated criteria,
284  /// however, and can override this behavior.
285  virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const {
286  return hasReservedCallFrame(MF) || hasFP(MF);
287  }
288 
289  // needsFrameIndexResolution - Do we need to perform FI resolution for
290  // this function. Normally, this is required only when the function
291  // has any stack objects. However, targets may want to override this.
292  virtual bool needsFrameIndexResolution(const MachineFunction &MF) const;
293 
294  /// getFrameIndexReference - This method should return the base register
295  /// and offset used to reference a frame index location. The offset is
296  /// returned directly, and the base register is returned via FrameReg.
297  virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
298  Register &FrameReg) const;
299 
300  /// Same as \c getFrameIndexReference, except that the stack pointer (as
301  /// opposed to the frame pointer) will be the preferred value for \p
302  /// FrameReg. This is generally used for emitting statepoint or EH tables that
303  /// use offsets from RSP. If \p IgnoreSPUpdates is true, the returned
304  /// offset is only guaranteed to be valid with respect to the value of SP at
305  /// the end of the prologue.
306  virtual StackOffset
308  Register &FrameReg,
309  bool IgnoreSPUpdates) const {
310  // Always safe to dispatch to getFrameIndexReference.
311  return getFrameIndexReference(MF, FI, FrameReg);
312  }
313 
314  /// getNonLocalFrameIndexReference - This method returns the offset used to
315  /// reference a frame index location. The offset can be from either FP/BP/SP
316  /// based on which base register is returned by llvm.localaddress.
318  int FI) const {
319  // By default, dispatch to getFrameIndexReference. Interested targets can
320  // override this.
321  Register FrameReg;
322  return getFrameIndexReference(MF, FI, FrameReg);
323  }
324 
325  /// Returns the callee-saved registers as computed by determineCalleeSaves
326  /// in the BitVector \p SavedRegs.
327  virtual void getCalleeSaves(const MachineFunction &MF,
328  BitVector &SavedRegs) const;
329 
330  /// This method determines which of the registers reported by
331  /// TargetRegisterInfo::getCalleeSavedRegs() should actually get saved.
332  /// The default implementation checks populates the \p SavedRegs bitset with
333  /// all registers which are modified in the function, targets may override
334  /// this function to save additional registers.
335  /// This method also sets up the register scavenger ensuring there is a free
336  /// register or a frameindex available.
337  /// This method should not be called by any passes outside of PEI, because
338  /// it may change state passed in by \p MF and \p RS. The preferred
339  /// interface outside PEI is getCalleeSaves.
340  virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
341  RegScavenger *RS = nullptr) const;
342 
343  /// processFunctionBeforeFrameFinalized - This method is called immediately
344  /// before the specified function's frame layout (MF.getFrameInfo()) is
345  /// finalized. Once the frame is finalized, MO_FrameIndex operands are
346  /// replaced with direct constants. This method is optional.
347  ///
349  RegScavenger *RS = nullptr) const {
350  }
351 
352  /// processFunctionBeforeFrameIndicesReplaced - This method is called
353  /// immediately before MO_FrameIndex operands are eliminated, but after the
354  /// frame is finalized. This method is optional.
355  virtual void
357  RegScavenger *RS = nullptr) const {}
358 
359  virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const {
360  report_fatal_error("WinEH not implemented for this target");
361  }
362 
363  /// This method is called during prolog/epilog code insertion to eliminate
364  /// call frame setup and destroy pseudo instructions (but only if the Target
365  /// is using them). It is responsible for eliminating these instructions,
366  /// replacing them with concrete instructions. This method need only be
367  /// implemented if using call frame setup/destroy pseudo instructions.
368  /// Returns an iterator pointing to the instruction after the replaced one.
373  llvm_unreachable("Call Frame Pseudo Instructions do not exist on this "
374  "target!");
375  }
376 
377 
378  /// Order the symbols in the local stack frame.
379  /// The list of objects that we want to order is in \p objectsToAllocate as
380  /// indices into the MachineFrameInfo. The array can be reordered in any way
381  /// upon return. The contents of the array, however, may not be modified (i.e.
382  /// only their order may be changed).
383  /// By default, just maintain the original order.
384  virtual void
386  SmallVectorImpl<int> &objectsToAllocate) const {
387  }
388 
389  /// Check whether or not the given \p MBB can be used as a prologue
390  /// for the target.
391  /// The prologue will be inserted first in this basic block.
392  /// This method is used by the shrink-wrapping pass to decide if
393  /// \p MBB will be correctly handled by the target.
394  /// As soon as the target enable shrink-wrapping without overriding
395  /// this method, we assume that each basic block is a valid
396  /// prologue.
397  virtual bool canUseAsPrologue(const MachineBasicBlock &MBB) const {
398  return true;
399  }
400 
401  /// Check whether or not the given \p MBB can be used as a epilogue
402  /// for the target.
403  /// The epilogue will be inserted before the first terminator of that block.
404  /// This method is used by the shrink-wrapping pass to decide if
405  /// \p MBB will be correctly handled by the target.
406  /// As soon as the target enable shrink-wrapping without overriding
407  /// this method, we assume that each basic block is a valid
408  /// epilogue.
409  virtual bool canUseAsEpilogue(const MachineBasicBlock &MBB) const {
410  return true;
411  }
412 
413  /// Returns the StackID that scalable vectors should be associated with.
415  return TargetStackID::Default;
416  }
417 
419  switch (ID) {
420  default:
421  return false;
424  return true;
425  }
426  }
427 
428  /// Check if given function is safe for not having callee saved registers.
429  /// This is used when interprocedural register allocation is enabled.
430  static bool isSafeForNoCSROpt(const Function &F);
431 
432  /// Check if the no-CSR optimisation is profitable for the given function.
433  virtual bool isProfitableForNoCSROpt(const Function &F) const {
434  return true;
435  }
436 
437  /// Return initial CFA offset value i.e. the one valid at the beginning of the
438  /// function (before any stack operations).
439  virtual int getInitialCFAOffset(const MachineFunction &MF) const;
440 
441  /// Return initial CFA register value i.e. the one valid at the beginning of
442  /// the function (before any stack operations).
443  virtual Register getInitialCFARegister(const MachineFunction &MF) const;
444 
445  /// Return the frame base information to be encoded in the DWARF subprogram
446  /// debug info.
447  virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const;
448 };
449 
450 } // End llvm namespace
451 
452 #endif
llvm::TargetFrameLowering::orderFrameObjects
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
Definition: TargetFrameLowering.h:385
llvm::TargetFrameLowering::getCalleeSaves
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs.
Definition: TargetFrameLoweringImpl.cpp:65
llvm::alignTo
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:148
llvm::TargetFrameLowering::DwarfFrameBase::WasmFrameBase::Index
unsigned Index
Definition: TargetFrameLowering.h:62
llvm::TargetFrameLowering::DwarfFrameBase::Reg
unsigned Reg
Definition: TargetFrameLowering.h:65
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::TargetStackID::WasmLocal
@ WasmLocal
Definition: TargetFrameLowering.h:31
llvm::TargetFrameLowering::needsFrameIndexResolution
virtual bool needsFrameIndexResolution(const MachineFunction &MF) const
Definition: TargetFrameLoweringImpl.cpp:60
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::Function
Definition: Function.h:61
TypeSize.h
llvm::TargetFrameLowering::getInitialCFARegister
virtual Register getInitialCFARegister(const MachineFunction &MF) const
Return initial CFA register value i.e.
Definition: TargetFrameLoweringImpl.cpp:156
llvm::TargetFrameLowering::isStackIdSafeForLocalArea
virtual bool isStackIdSafeForLocalArea(unsigned StackId) const
This method returns whether or not it is safe for an object with the given stack id to be bundled int...
Definition: TargetFrameLowering.h:133
MachineBasicBlock.h
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
llvm::TargetFrameLowering::DwarfFrameBase
Definition: TargetFrameLowering.h:56
llvm::TargetFrameLowering::getDwarfFrameBase
virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const
Return the frame base information to be encoded in the DWARF subprogram debug info.
Definition: TargetFrameLoweringImpl.cpp:161
llvm::TargetFrameLowering::processFunctionBeforeFrameIndicesReplaced
virtual void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
Definition: TargetFrameLowering.h:356
llvm::TargetFrameLowering::~TargetFrameLowering
virtual ~TargetFrameLowering()
llvm::TargetFrameLowering::enableCalleeSaveSkip
virtual bool enableCalleeSaveSkip(const MachineFunction &MF) const
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functi...
Definition: TargetFrameLoweringImpl.cpp:33
llvm::TargetFrameLowering::getStackIDForScalableVectors
virtual TargetStackID::Value getStackIDForScalableVectors() const
Returns the StackID that scalable vectors should be associated with.
Definition: TargetFrameLowering.h:414
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::TargetFrameLowering::StackDirection
StackDirection
Definition: TargetFrameLowering.h:45
llvm::TargetFrameLowering::getTransientStackAlign
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
Definition: TargetFrameLowering.h:118
llvm::TargetFrameLowering::DwarfFrameBase::WasmLoc
struct WasmFrameBase WasmLoc
Definition: TargetFrameLowering.h:66
llvm::TargetFrameLowering::eliminateCallFramePseudoInstr
virtual MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
Definition: TargetFrameLowering.h:370
llvm::TargetFrameLowering::processFunctionBeforeFrameFinalized
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition: TargetFrameLowering.h:348
llvm::TargetFrameLowering::getStackAlignment
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
Definition: TargetFrameLowering.h:95
llvm::TargetFrameLowering::isProfitableForNoCSROpt
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
Definition: TargetFrameLowering.h:433
llvm::TargetFrameLowering::getOffsetOfLocalArea
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
Definition: TargetFrameLowering.h:140
llvm::TargetFrameLowering::DwarfFrameBase::Register
@ Register
Definition: TargetFrameLowering.h:59
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
llvm::TargetFrameLowering::enableShrinkWrapping
virtual bool enableShrinkWrapping(const MachineFunction &MF) const
Returns true if the target will correctly handle shrink wrapping.
Definition: TargetFrameLowering.h:191
llvm::TargetFrameLowering::getNonLocalFrameIndexReference
virtual StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
Definition: TargetFrameLowering.h:317
llvm::TargetFrameLowering::canUseAsEpilogue
virtual bool canUseAsEpilogue(const MachineBasicBlock &MBB) const
Check whether or not the given MBB can be used as a epilogue for the target.
Definition: TargetFrameLowering.h:409
llvm::TargetFrameLowering::getStackAlign
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
Definition: TargetFrameLowering.h:100
llvm::TargetFrameLowering::DwarfFrameBase::CFA
@ CFA
Definition: TargetFrameLowering.h:59
llvm::TargetFrameLowering::hasReservedCallFrame
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: TargetFrameLowering.h:274
llvm::TargetFrameLowering::inlineStackProbe
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
Definition: TargetFrameLowering.h:220
llvm::TargetFrameLowering::keepFramePointer
virtual bool keepFramePointer(const MachineFunction &MF) const
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame...
Definition: TargetFrameLowering.h:260
llvm::TargetFrameLowering::isStackRealignable
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
Definition: TargetFrameLowering.h:122
llvm::TargetFrameLowering::hasFP
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register.
llvm::TargetFrameLowering::assignCalleeSavedSpillSlots
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
Definition: TargetFrameLowering.h:162
llvm::TargetFrameLowering::spillCalleeSavedRegisters
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, ArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
Definition: TargetFrameLowering.h:237
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::BitVector
Definition: BitVector.h:74
llvm::TargetFrameLowering::DwarfFrameBase::Kind
enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::TargetFrameLowering::DwarfFrameBase::WasmFrameBase::Kind
unsigned Kind
Definition: TargetFrameLowering.h:61
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:95
llvm::TargetFrameLowering::isFPCloseToIncomingSP
virtual bool isFPCloseToIncomingSP() const
isFPCloseToIncomingSP - Return true if the frame pointer is close to the incoming stack pointer,...
Definition: TargetFrameLowering.h:145
llvm::TargetFrameLowering::alignSPAdjust
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
Definition: TargetFrameLowering.h:105
llvm::TargetFrameLowering::isSupportedStackID
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition: TargetFrameLowering.h:418
llvm::TargetFrameLowering::getCalleeSavedSpillSlots
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
Definition: TargetFrameLowering.h:178
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind
FrameBaseKind
Definition: TargetFrameLowering.h:59
llvm::TargetFrameLowering::adjustForSegmentedStacks
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
Definition: TargetFrameLowering.h:225
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::TargetFrameLowering::restoreCalleeSavedRegisters
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, MutableArrayRef< CalleeSavedInfo > CSI, const TargetRegisterInfo *TRI) const
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
Definition: TargetFrameLowering.h:251
llvm::TargetStackID::ScalableVector
@ ScalableVector
Definition: TargetFrameLowering.h:30
llvm::TargetFrameLowering::isSafeForNoCSROpt
static bool isSafeForNoCSROpt(const Function &F)
Check if given function is safe for not having callee saved registers.
Definition: TargetFrameLoweringImpl.cpp:139
llvm::TargetFrameLowering::adjustForHiPEPrologue
virtual void adjustForHiPEPrologue(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in the assembly prologue to ex...
Definition: TargetFrameLowering.h:230
llvm::TargetFrameLowering::emitCalleeSavedFrameMoves
virtual void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const
With basic block sections, emit callee saved frame moves for basic blocks that are in a different sec...
Definition: TargetFrameLowering.h:216
llvm::TargetFrameLowering::getStackGrowthDirection
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
Definition: TargetFrameLowering.h:89
llvm::TargetFrameLowering::assignCalleeSavedSpillSlots
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI, unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
Definition: TargetFrameLowering.h:153
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::TargetFrameLowering::DwarfFrameBase::Location
union llvm::TargetFrameLowering::DwarfFrameBase::@219 Location
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::TargetFrameLowering::enableStackSlotScavenging
virtual bool enableStackSlotScavenging(const MachineFunction &MF) const
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
Definition: TargetFrameLowering.h:198
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm::TargetStackID::NoAlloc
@ NoAlloc
Definition: TargetFrameLowering.h:32
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::TargetFrameLowering::DwarfFrameBase::WasmFrameBase
Definition: TargetFrameLowering.h:60
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::TargetFrameLowering::canUseAsPrologue
virtual bool canUseAsPrologue(const MachineBasicBlock &MBB) const
Check whether or not the given MBB can be used as a prologue for the target.
Definition: TargetFrameLowering.h:397
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::Align::value
uint64_t value() const
This is a hole in the type system and should not be abused.
Definition: Alignment.h:85
llvm::TargetFrameLowering::getFrameIndexReference
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...
Definition: TargetFrameLoweringImpl.cpp:45
llvm::TargetFrameLowering::SpillSlot::Offset
int Offset
Definition: TargetFrameLowering.h:53
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::TargetStackID::Default
@ Default
Definition: TargetFrameLowering.h:28
llvm::TargetFrameLowering::canSimplifyCallFramePseudos
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
Definition: TargetFrameLowering.h:285
llvm::TargetFrameLowering::SpillSlot::Reg
unsigned Reg
Definition: TargetFrameLowering.h:52
llvm::TargetStackID::SGPRSpill
@ SGPRSpill
Definition: TargetFrameLowering.h:29
llvm::TargetFrameLowering::targetHandlesStackFrameRounding
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
Definition: TargetFrameLowering.h:186
llvm::TargetFrameLowering::getWinEHParentFrameOffset
virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const
Definition: TargetFrameLowering.h:359
llvm::TargetFrameLowering::TargetFrameLowering
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
Definition: TargetFrameLowering.h:77
llvm::SmallVectorImpl< int >
llvm::TargetFrameLowering::StackGrowsDown
@ StackGrowsDown
Definition: TargetFrameLowering.h:47
llvm::TargetFrameLowering::getInitialCFAOffset
virtual int getInitialCFAOffset(const MachineFunction &MF) const
Return initial CFA offset value i.e.
Definition: TargetFrameLoweringImpl.cpp:151
llvm::TargetFrameLowering::emitPrologue
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
llvm::TargetFrameLowering::determineCalleeSaves
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition: TargetFrameLoweringImpl.cpp:78
llvm::TargetFrameLowering::getFrameIndexReferencePreferSP
virtual StackOffset getFrameIndexReferencePreferSP(const MachineFunction &MF, int FI, Register &FrameReg, bool IgnoreSPUpdates) const
Same as getFrameIndexReference, except that the stack pointer (as opposed to the frame pointer) will ...
Definition: TargetFrameLowering.h:307
llvm::TargetFrameLowering::emitEpilogue
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::TargetFrameLowering::SpillSlot
Definition: TargetFrameLowering.h:51
llvm::TargetFrameLowering::StackGrowsUp
@ StackGrowsUp
Definition: TargetFrameLowering.h:46
llvm::TargetFrameLowering::getStackAlignmentSkew
virtual unsigned getStackAlignmentSkew(const MachineFunction &MF) const
Return the skew that has to be applied to stack alignment under certain conditions (e....
Definition: TargetFrameLoweringImpl.cpp:129
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37