LLVM 24.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
16#include "llvm/ADT/BitVector.h"
22#include <vector>
23
24namespace llvm {
25 class BitVector;
26 class CalleeSavedInfo;
27 class MachineFunction;
28 class RegScavenger;
29
41
42/// Information about stack frame layout on the target. It holds the direction
43/// of stack growth, the known stack alignment on entry to each function, and
44/// the offset to the locals area.
45///
46/// The offset to the local area is the offset from the stack pointer on
47/// function entry to the first location where function data (local variables,
48/// spill locations) can be stored.
50public:
52 StackGrowsUp, // Adding to the stack increases the stack address
53 StackGrowsDown // Adding to the stack decreases the stack address
54 };
55
56 // Maps a callee saved register to a stack slot with a fixed offset.
57 struct SpillSlot {
58 unsigned Reg;
59 int64_t Offset; // Offset relative to stack pointer on function entry.
60 };
61
63 // The frame base may be either a register (the default), the CFA with an
64 // offset, or a WebAssembly-specific location description.
67 unsigned Kind; // Wasm local, global, or value stack
68 unsigned Index;
69 };
70 union {
71 // Used with FrameBaseKind::Register.
72 unsigned Reg;
73 // Used with FrameBaseKind::CFA.
74 int64_t Offset;
76 } Location;
77 };
78
79private:
80 StackDirection StackDir;
81 Align StackAlignment;
82 Align TransientStackAlignment;
83 int LocalAreaOffset;
84 bool StackRealignable;
85public:
87 Align TransAl = Align(1), bool StackReal = true)
88 : StackDir(D), StackAlignment(StackAl), TransientStackAlignment(TransAl),
89 LocalAreaOffset(LAO), StackRealignable(StackReal) {}
90
92
93 // These methods return information that describes the abstract stack layout
94 // of the target machine.
95
96 /// getStackGrowthDirection - Return the direction the stack grows
97 ///
98 StackDirection getStackGrowthDirection() const { return StackDir; }
99
100 /// getStackAlignment - This method returns the number of bytes to which the
101 /// stack pointer must be aligned on entry to a function. Typically, this
102 /// is the largest alignment for any data object in the target.
103 ///
104 unsigned getStackAlignment() const { return StackAlignment.value(); }
105 /// getStackAlignment - This method returns the number of bytes to which the
106 /// stack pointer must be aligned on entry to a function. Typically, this
107 /// is the largest alignment for any data object in the target.
108 ///
109 Align getStackAlign() const { return StackAlignment; }
110
111 /// getStackThreshold - Return the maximum stack size
112 ///
113 virtual uint64_t getStackThreshold() const { return UINT_MAX; }
114
115 /// alignSPAdjust - This method aligns the stack adjustment to the correct
116 /// alignment.
117 ///
118 int alignSPAdjust(int SPAdj) const {
119 if (SPAdj < 0) {
120 SPAdj = -alignTo(-SPAdj, StackAlignment);
121 } else {
122 SPAdj = alignTo(SPAdj, StackAlignment);
123 }
124 return SPAdj;
125 }
126
127 /// getTransientStackAlignment - This method returns the number of bytes to
128 /// which the stack pointer must be aligned at all times, even between
129 /// calls.
130 ///
131 Align getTransientStackAlign() const { return TransientStackAlignment; }
132
133 /// isStackRealignable - This method returns whether the stack can be
134 /// realigned.
135 bool isStackRealignable() const {
136 return StackRealignable;
137 }
138
139 /// This method returns whether or not it is safe for an object with the
140 /// given stack id to be bundled into the local area.
141 virtual bool isStackIdSafeForLocalArea(unsigned StackId) const {
142 return true;
143 }
144
145 /// getOffsetOfLocalArea - This method returns the offset of the local area
146 /// from the stack pointer on entrance to a function.
147 ///
148 int getOffsetOfLocalArea() const { return LocalAreaOffset; }
149
150 /// Control the placement of special register scavenging spill slots when
151 /// allocating a stack frame.
152 ///
153 /// If this returns true, the frame indexes used by the RegScavenger will be
154 /// allocated closest to the incoming stack pointer.
155 virtual bool allocateScavengingFrameIndexesNearIncomingSP(
156 const MachineFunction &MF) const;
157
158 /// assignCalleeSavedSpillSlots - Allows target to override spill slot
159 /// assignment logic. If implemented, assignCalleeSavedSpillSlots() should
160 /// assign frame slots to all CSI entries and return true. If this method
161 /// returns false, spill slots will be assigned using generic implementation.
162 /// assignCalleeSavedSpillSlots() may add, delete or rearrange elements of
163 /// CSI.
164 virtual bool
166 const TargetRegisterInfo *TRI,
167 std::vector<CalleeSavedInfo> &CSI) const {
168 return false;
169 }
170
171 /// getCalleeSavedSpillSlots - This method returns a pointer to an array of
172 /// pairs, that contains an entry for each callee saved register that must be
173 /// spilled to a particular stack location if it is spilled.
174 ///
175 /// Each entry in this array contains a <register,offset> pair, indicating the
176 /// fixed offset from the incoming stack pointer that each register should be
177 /// spilled at. If a register is not listed here, the code generator is
178 /// allowed to spill it anywhere it chooses.
179 ///
180 virtual const SpillSlot *
181 getCalleeSavedSpillSlots(unsigned &NumEntries) const {
182 NumEntries = 0;
183 return nullptr;
184 }
185
186 /// targetHandlesStackFrameRounding - Returns true if the target is
187 /// responsible for rounding up the stack frame (probably at emitPrologue
188 /// time).
189 virtual bool targetHandlesStackFrameRounding() const {
190 return false;
191 }
192
193 /// Returns true if the target will correctly handle shrink wrapping.
194 virtual bool enableShrinkWrapping(const MachineFunction &MF) const {
195 return false;
196 }
197
198 /// Returns true if Windows CFI shrink wrapping should be enabled by default.
199 /// Explicitly enabling shrink wrapping overrides this; mandatory restrictions
200 /// should be enforced by canUseAsPrologue() or canUseAsEpilogue().
201 virtual bool enableWindowsCFIShrinkWrapping(const MachineFunction &MF) const {
202 return false;
203 }
204
205 /// Returns true if the stack slot holes in the fixed and callee-save stack
206 /// area should be used when allocating other stack locations to reduce stack
207 /// size.
208 virtual bool enableStackSlotScavenging(const MachineFunction &MF) const {
209 return false;
210 }
211
212 /// Returns true if the target can safely skip saving callee-saved registers
213 /// for noreturn nounwind functions.
214 virtual bool enableCalleeSaveSkip(const MachineFunction &MF) const;
215
216 /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
217 /// the function.
219 MachineBasicBlock &MBB) const = 0;
221 MachineBasicBlock &MBB) const = 0;
222
223 /// emitZeroCallUsedRegs - Zeros out call used registers.
224 virtual void emitZeroCallUsedRegs(BitVector RegsToZero,
226 RegScavenger *RS) const {}
227
228 /// With basic block sections, emit callee saved frame moves for basic blocks
229 /// that are in a different section.
230 virtual void
233
234 /// Returns true if we may need to fix the unwind information for the
235 /// function.
236 virtual bool enableCFIFixup(const MachineFunction &MF) const;
237
238 /// enableFullCFIFixup - Returns true if we may need to fix the unwind
239 /// information such that it is accurate for *every* instruction in the
240 /// function (e.g. if the function has an async unwind table).
241 virtual bool enableFullCFIFixup(const MachineFunction &MF) const {
242 return enableCFIFixup(MF);
243 };
244
245 /// Emit CFI instructions that recreate the state of the unwind information
246 /// upon function entry.
248
249 /// Replace a StackProbe stub (if any) with the actual probe code inline
251 MachineBasicBlock &PrologueMBB) const {}
252
253 /// Does the stack probe function call return with a modified stack pointer?
254 virtual bool stackProbeFunctionModifiesSP() const { return false; }
255
256 /// Adjust the prologue to have the function use segmented stacks. This works
257 /// by adding a check even before the "normal" function prologue.
259 MachineBasicBlock &PrologueMBB) const {}
260
261 /// Adjust the prologue to add Erlang Run-Time System (ERTS) specific code in
262 /// the assembly prologue to explicitly handle the stack.
264 MachineBasicBlock &PrologueMBB) const {}
265
266 /// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
267 /// saved registers and returns true if it isn't possible / profitable to do
268 /// so by issuing a series of store instructions via
269 /// storeRegToStackSlot(). Returns false otherwise.
276
277 /// spillCalleeSavedRegister - Default implementation for spilling a single
278 /// callee saved register.
279 void spillCalleeSavedRegister(MachineBasicBlock &SaveBlock,
281 const CalleeSavedInfo &CS,
282 const TargetInstrInfo *TII,
283 const TargetRegisterInfo *TRI) const;
284
285 /// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
286 /// saved registers and returns true if it isn't possible / profitable to do
287 /// so by issuing a series of load instructions via loadRegToStackSlot().
288 /// If it returns true, and any of the registers in CSI is not restored,
289 /// it sets the corresponding Restored flag in CSI to false.
290 /// Returns false otherwise.
291 virtual bool
298
299 // restoreCalleeSavedRegister - Default implementation for restoring a single
300 // callee saved register. Should be called in reverse order. Can insert
301 // multiple instructions.
302 void restoreCalleeSavedRegister(MachineBasicBlock &MBB,
304 const CalleeSavedInfo &CS,
305 const TargetInstrInfo *TII,
306 const TargetRegisterInfo *TRI) const;
307
308 /// hasFP - Return true if the specified function should have a dedicated
309 /// frame pointer register. For most targets this is true only if the function
310 /// has variable sized allocas or if frame pointer elimination is disabled.
311 /// For all targets, this is false if the function has the naked attribute
312 /// since there is no prologue to set up the frame pointer.
313 bool hasFP(const MachineFunction &MF) const {
314 return !MF.getFunction().hasFnAttribute(Attribute::Naked) && hasFPImpl(MF);
315 }
316
317 /// hasReservedCallFrame - Under normal circumstances, when a frame pointer is
318 /// not required, we reserve argument space for call sites in the function
319 /// immediately on entry to the current function. This eliminates the need for
320 /// add/sub sp brackets around call sites. Returns true if the call frame is
321 /// included as part of the stack frame.
322 virtual bool hasReservedCallFrame(const MachineFunction &MF) const {
323 return !hasFP(MF);
324 }
325
326 /// canSimplifyCallFramePseudos - When possible, it's best to simplify the
327 /// call frame pseudo ops before doing frame index elimination. This is
328 /// possible only when frame index references between the pseudos won't
329 /// need adjusting for the call frame adjustments. Normally, that's true
330 /// if the function has a reserved call frame or a frame pointer. Some
331 /// targets (Thumb2, for example) may have more complicated criteria,
332 /// however, and can override this behavior.
333 virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const {
334 return hasReservedCallFrame(MF) || hasFP(MF);
335 }
336
337 // needsFrameIndexResolution - Do we need to perform FI resolution for
338 // this function. Normally, this is required only when the function
339 // has any stack objects. However, targets may want to override this.
340 virtual bool needsFrameIndexResolution(const MachineFunction &MF) const;
341
342 /// getFrameIndexReference - This method should return the base register
343 /// and offset used to reference a frame index location. The offset is
344 /// returned directly, and the base register is returned via FrameReg.
345 virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI,
346 Register &FrameReg) const;
347
348 /// Same as \c getFrameIndexReference, except that the stack pointer (as
349 /// opposed to the frame pointer) will be the preferred value for \p
350 /// FrameReg. This is generally used for emitting statepoint or EH tables that
351 /// use offsets from RSP. If \p IgnoreSPUpdates is true, the returned
352 /// offset is only guaranteed to be valid with respect to the value of SP at
353 /// the end of the prologue.
354 virtual StackOffset
356 Register &FrameReg,
357 bool IgnoreSPUpdates) const {
358 // Always safe to dispatch to getFrameIndexReference.
359 return getFrameIndexReference(MF, FI, FrameReg);
360 }
361
362 /// getNonLocalFrameIndexReference - This method returns the offset used to
363 /// reference a frame index location. The offset can be from either FP/BP/SP
364 /// based on which base register is returned by llvm.localaddress.
366 int FI) const {
367 // By default, dispatch to getFrameIndexReference. Interested targets can
368 // override this.
369 Register FrameReg;
370 return getFrameIndexReference(MF, FI, FrameReg);
371 }
372
373 /// getFrameIndexReferenceFromSP - This method returns the offset from the
374 /// stack pointer to the slot of the specified index. This function serves to
375 /// provide a comparable offset from a single reference point (the value of
376 /// the stack-pointer at function entry) that can be used for analysis.
377 virtual StackOffset getFrameIndexReferenceFromSP(const MachineFunction &MF,
378 int FI) const;
379
380 /// Return the list of registers which must be preserved by the function: the
381 /// value on exit must be the same as the value on entry. A register from this
382 /// list does may not need to be saved / reloaded if the function did not use
383 /// it.
384 const MCPhysReg *getMustPreserveRegisters(const MachineFunction &MF) const;
385
386 /// This method determines which of the registers reported by
387 /// getMustPreserveRegisters() must be saved in prolog and reloaded in epilog
388 /// regardless of whether or not they were modified by the function.
389 void determineUncondPrologCalleeSaves(MachineFunction &MF,
390 const MCPhysReg *CSRegs,
391 BitVector &UncondPrologCSRs) const;
392
393 /// Returns the callee-saved registers as computed by determineCalleeSaves
394 /// in the BitVector \p SavedRegs.
395 virtual void getCalleeSaves(const MachineFunction &MF,
396 BitVector &SavedRegs) const;
397
398 /// This method determines which of the registers reported by
399 /// TargetRegisterInfo::getCalleeSavedRegs() should actually get saved.
400 /// The default implementation checks populates the \p SavedRegs bitset with
401 /// all registers which are modified in the function, targets may override
402 /// this function to save additional registers.
403 /// This method also sets up the register scavenger ensuring there is a free
404 /// register or a frameindex available.
405 /// This method should not be called by any passes outside of PEI, because
406 /// it may change state passed in by \p MF and \p RS. The preferred
407 /// interface outside PEI is getCalleeSaves.
408 virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs,
409 RegScavenger *RS = nullptr) const;
410
411 /// processFunctionBeforeFrameFinalized - This method is called immediately
412 /// before the specified function's frame layout (MF.getFrameInfo()) is
413 /// finalized. Once the frame is finalized, MO_FrameIndex operands are
414 /// replaced with direct constants. This method is optional.
415 ///
417 RegScavenger *RS = nullptr) const {
418 }
419
420 /// processFunctionBeforeFrameIndicesReplaced - This method is called
421 /// immediately before MO_FrameIndex operands are eliminated, but after the
422 /// frame is finalized. This method is optional.
423 virtual void
426
427 virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const {
428 reportFatalUsageError("WinEH not implemented for this target");
429 }
430
431 /// This method is called during prolog/epilog code insertion to eliminate
432 /// call frame setup and destroy pseudo instructions (but only if the Target
433 /// is using them). It is responsible for eliminating these instructions,
434 /// replacing them with concrete instructions. This method need only be
435 /// implemented if using call frame setup/destroy pseudo instructions.
436 /// Returns an iterator pointing to the instruction after the replaced one.
441 llvm_unreachable("Call Frame Pseudo Instructions do not exist on this "
442 "target!");
443 }
444
445
446 /// Order the symbols in the local stack frame.
447 /// The list of objects that we want to order is in \p objectsToAllocate as
448 /// indices into the MachineFrameInfo. The array can be reordered in any way
449 /// upon return. The contents of the array, however, may not be modified (i.e.
450 /// only their order may be changed).
451 /// By default, just maintain the original order.
452 virtual void
454 SmallVectorImpl<int> &objectsToAllocate) const {
455 }
456
457 /// Check whether or not the given \p MBB can be used as a prologue
458 /// for the target.
459 /// The prologue will be inserted first in this basic block.
460 /// This method is used by the shrink-wrapping pass to decide if
461 /// \p MBB will be correctly handled by the target.
462 /// As soon as the target enable shrink-wrapping without overriding
463 /// this method, we assume that each basic block is a valid
464 /// prologue.
465 virtual bool canUseAsPrologue(const MachineBasicBlock &MBB) const {
466 return true;
467 }
468
469 /// Check whether or not the given \p MBB can be used as a epilogue
470 /// for the target.
471 /// The epilogue will be inserted before the first terminator of that block.
472 /// This method is used by the shrink-wrapping pass to decide if
473 /// \p MBB will be correctly handled by the target.
474 /// As soon as the target enable shrink-wrapping without overriding
475 /// this method, we assume that each basic block is a valid
476 /// epilogue.
477 virtual bool canUseAsEpilogue(const MachineBasicBlock &MBB) const {
478 return true;
479 }
480
481 /// Returns the StackID that scalable vectors should be associated with.
485
487 switch (ID) {
488 default:
489 return false;
492 return true;
493 }
494 }
495
496 /// Check if given function is safe for not having callee saved registers.
497 /// This is used when interprocedural register allocation is enabled.
498 static bool isSafeForNoCSROpt(const Function &F);
499
500 /// Check if the no-CSR optimisation is profitable for the given function.
501 virtual bool isProfitableForNoCSROpt(const Function &F) const {
502 return true;
503 }
504
505 /// Return initial CFA offset value i.e. the one valid at the beginning of the
506 /// function (before any stack operations).
507 virtual int getInitialCFAOffset(const MachineFunction &MF) const;
508
509 /// Return initial CFA register value i.e. the one valid at the beginning of
510 /// the function (before any stack operations).
511 virtual Register getInitialCFARegister(const MachineFunction &MF) const;
512
513 /// Return the frame base information to be encoded in the DWARF subprogram
514 /// debug info.
515 virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const;
516
517 /// If frame pointer or base pointer is clobbered by an instruction, we should
518 /// spill/restore it around that instruction.
519 virtual void spillFPBP(MachineFunction &MF) const {}
520
521 /// This method is called at the end of prolog/epilog code insertion, so
522 /// targets can emit remarks based on the final frame layout.
523 virtual void emitRemarks(const MachineFunction &MF,
525
526protected:
527 virtual bool hasFPImpl(const MachineFunction &MF) const = 0;
528};
529
530} // End llvm namespace
531
532#endif
static int alignTo(int Num, int PowOf2)
const AArch64InstrInfo & TII
uint64_t uint64_t
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file implements the BitVector class.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_ABI
Definition Compiler.h:211
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
===- MachineOptimizationRemarkEmitter.h - Opt Diagnostics -*- C++ -*-—===//
Register const TargetRegisterInfo * TRI
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Definition Function.cpp:731
MachineInstrBundleIterator< MachineInstr > iterator
Function & getFunction()
Return the LLVM function that this machine code represents.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StackOffset holds a fixed and a scalable offset in bytes.
Definition TypeSize.h:31
virtual void spillFPBP(MachineFunction &MF) const
If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around th...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual void emitCalleeSavedFrameMovesFullCFA(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const
With basic block sections, emit callee saved frame moves for basic blocks that are in a different sec...
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
virtual const SpillSlot * getCalleeSavedSpillSlots(unsigned &NumEntries) const
getCalleeSavedSpillSlots - This method returns a pointer to an array of pairs, that contains an entry...
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
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...
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
virtual uint64_t getStackThreshold() const
getStackThreshold - Return the maximum stack size
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
virtual bool enableShrinkWrapping(const MachineFunction &MF) const
Returns true if the target will correctly handle shrink wrapping.
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
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...
virtual bool enableWindowsCFIShrinkWrapping(const MachineFunction &MF) const
Returns true if Windows CFI shrink wrapping should be enabled by default.
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...
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...
virtual bool stackProbeFunctionModifiesSP() const
Does the stack probe function call return with a modified stack pointer?
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
virtual TargetStackID::Value getStackIDForScalableVectors() const
Returns the StackID that scalable vectors should be associated with.
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
virtual bool isSupportedStackID(TargetStackID::Value ID) const
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...
virtual void emitZeroCallUsedRegs(BitVector RegsToZero, MachineBasicBlock &MBB, RegScavenger *RS) const
emitZeroCallUsedRegs - Zeros out call used registers.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
virtual StackOffset getNonLocalFrameIndexReference(const MachineFunction &MF, int FI) const
getNonLocalFrameIndexReference - This method returns the offset used to reference a frame index locat...
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
virtual void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
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 ...
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
virtual bool enableFullCFIFixup(const MachineFunction &MF) const
enableFullCFIFixup - Returns true if we may need to fix the unwind information such that it is accura...
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
virtual bool canUseAsEpilogue(const MachineBasicBlock &MBB) const
Check whether or not the given MBB can be used as a epilogue for the target.
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
virtual bool canUseAsPrologue(const MachineBasicBlock &MBB) const
Check whether or not the given MBB can be used as a prologue for the target.
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
virtual void resetCFIToInitialState(MachineBasicBlock &MBB) const
Emit CFI instructions that recreate the state of the unwind information upon function entry.
virtual bool canSimplifyCallFramePseudos(const MachineFunction &MF) const
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
virtual bool hasFPImpl(const MachineFunction &MF) const =0
virtual void emitRemarks(const MachineFunction &MF, MachineOptimizationRemarkEmitter *ORE) const
This method is called at the end of prolog/epilog code insertion, so targets can emit remarks based o...
virtual bool enableCFIFixup(const MachineFunction &MF) const
Returns true if we may need to fix the unwind information for the function.
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const
virtual void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const =0
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
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...
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...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39