LLVM: include/llvm/CodeGen/TargetFrameLowering.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_CODEGEN_TARGETFRAMELOWERING_H
14#define LLVM_CODEGEN_TARGETFRAMELOWERING_H
15
21#include
22
23namespace llvm {
28
39
40
41
42
43
44
45
46
48public:
53
54
59
61
62
68 union {
69
71
74 } Location;
75 };
76
77private:
78 StackDirection StackDir;
79 Align StackAlignment;
80 Align TransientStackAlignment;
81 int LocalAreaOffset;
82 bool StackRealignable;
83public:
85 Align TransAl = Align(1), bool StackReal = true)
86 : StackDir(D), StackAlignment(StackAl), TransientStackAlignment(TransAl),
87 LocalAreaOffset(LAO), StackRealignable(StackReal) {}
88
90
91
92
93
94
95
97
98
99
100
101
103
104
105
106
108
109
110
112
113
114
115
117 if (SPAdj < 0) {
118 SPAdj = -alignTo(-SPAdj, StackAlignment);
119 } else {
120 SPAdj = alignTo(SPAdj, StackAlignment);
121 }
122 return SPAdj;
123 }
124
125
126
127
128
130
131
132
134 return StackRealignable;
135 }
136
137
138
142
143
144
145
147
148
149
150
151
152
153 virtual bool allocateScavengingFrameIndexesNearIncomingSP(
155
156
157
158
159
160
161
162 virtual bool
165 std::vector &CSI) const {
166 return false;
167 }
168
169
170
171
172
173
174
175
176
177
178 virtual const SpillSlot *
180 NumEntries = 0;
181 return nullptr;
182 }
183
184
185
186
190
191
195
196
197
198
202
203
204
205 virtual bool enableCalleeSaveSkip(const MachineFunction &MF) const;
206
207
208
213
214
217
218
219
220 virtual void
223
224
225
226 virtual bool enableCFIFixup(const MachineFunction &MF) const;
227
228
229
230
234
235
236
238
239
242
243
245
246
247
250
251
252
255
256
257
258
259
266
267
268
274
275
276
277
278
279
280
281 virtual bool
288
289
290
291
297
298
299
300
301
302
306
307
308
309
310
311
313 return (MF);
314 }
315
316
317
318
319
320
321
322
326
327
328
329
330 virtual bool needsFrameIndexResolution(const MachineFunction &MF) const;
331
332
333
334
337
338
339
340
341
342
343
347 bool IgnoreSPUpdates) const {
348
350 }
351
352
353
354
356 int FI) const {
357
358
361 }
362
363
364
365
366
368 int FI) const;
369
370
371
374
375
376
377
378
379
380
381
382
383
384
387
388
389
390
391
392
396
397
398
399
400 virtual void
403
407
408
409
410
411
412
413
418 llvm_unreachable("Call Frame Pseudo Instructions do not exist on this "
419 "target!");
420 }
421
422
423
424
425
426
427
428
429 virtual void
433
434
435
436
437
438
439
440
441
445
446
447
448
449
450
451
452
453
457
458
462
464 switch (ID) {
465 default:
466 return false;
469 return true;
470 }
471 }
472
473
474
475 static bool isSafeForNoCSROpt(const Function &F);
476
477
481
482
483
484 virtual int getInitialCFAOffset(const MachineFunction &MF) const;
485
486
487
489
490
491
492 virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const;
493
494
495
497
498
499
502
503protected:
505};
506
507}
508
509#endif
static int alignTo(int Num, int PowOf2)
const TargetInstrInfo & TII
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file implements the BitVector class.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Register const TargetRegisterInfo * TRI
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
MachineInstrBundleIterator< MachineInstr > iterator
Function & getFunction()
Return the LLVM function that this machine code represents.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Wrapper class representing virtual and physical registers.
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.
virtual void spillFPBP(MachineFunction &MF) const
If frame pointer or base pointer is clobbered by an instruction, we should spill/restore it around th...
Definition TargetFrameLowering.h:496
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
Definition TargetFrameLowering.h:102
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...
Definition TargetFrameLowering.h:221
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition TargetFrameLowering.h:303
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...
Definition TargetFrameLowering.h:179
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition TargetFrameLowering.h:312
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:199
Align getTransientStackAlign() const
getTransientStackAlignment - This method returns the number of bytes to which the stack pointer must ...
Definition TargetFrameLowering.h:129
virtual uint64_t getStackThreshold() const
getStackThreshold - Return the maximum stack size
Definition TargetFrameLowering.h:111
virtual void processFunctionBeforeFrameFinalized(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameFinalized - This method is called immediately before the specified function...
Definition TargetFrameLowering.h:393
virtual bool enableShrinkWrapping(const MachineFunction &MF) const
Returns true if the target will correctly handle shrink wrapping.
Definition TargetFrameLowering.h:192
virtual void inlineStackProbe(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Replace a StackProbe stub (if any) with the actual probe code inline.
Definition TargetFrameLowering.h:240
virtual void orderFrameObjects(const MachineFunction &MF, SmallVectorImpl< int > &objectsToAllocate) const
Order the symbols in the local stack frame.
Definition TargetFrameLowering.h:430
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:139
StackDirection
Definition TargetFrameLowering.h:49
@ StackGrowsUp
Definition TargetFrameLowering.h:50
@ StackGrowsDown
Definition TargetFrameLowering.h:51
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:253
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:260
virtual bool stackProbeFunctionModifiesSP() const
Does the stack probe function call return with a modified stack pointer?
Definition TargetFrameLowering.h:244
bool isStackRealignable() const
isStackRealignable - This method returns whether the stack can be realigned.
Definition TargetFrameLowering.h:133
virtual TargetStackID::Value getStackIDForScalableVectors() const
Returns the StackID that scalable vectors should be associated with.
Definition TargetFrameLowering.h:459
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
Definition TargetFrameLowering.h:146
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
Definition TargetFrameLowering.h:84
virtual bool isSupportedStackID(TargetStackID::Value ID) const
Definition TargetFrameLowering.h:463
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:415
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
Definition TargetFrameLowering.h:107
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:355
virtual bool assignCalleeSavedSpillSlots(MachineFunction &MF, const TargetRegisterInfo *TRI, std::vector< CalleeSavedInfo > &CSI) const
assignCalleeSavedSpillSlots - Allows target to override spill slot assignment logic.
Definition TargetFrameLowering.h:163
virtual void processFunctionBeforeFrameIndicesReplaced(MachineFunction &MF, RegScavenger *RS=nullptr) const
processFunctionBeforeFrameIndicesReplaced - This method is called immediately before MO_FrameIndex op...
Definition TargetFrameLowering.h:401
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:345
virtual bool isProfitableForNoCSROpt(const Function &F) const
Check if the no-CSR optimisation is profitable for the given function.
Definition TargetFrameLowering.h:478
virtual bool enableFullCFIFixup(const MachineFunction &MF) const
enableFullCFIFixup - Returns true if we may need to fix the unwind information such that it is accura...
Definition TargetFrameLowering.h:231
StackDirection getStackGrowthDirection() const
getStackGrowthDirection - Return the direction the stack grows
Definition TargetFrameLowering.h:96
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:454
virtual void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &PrologueMBB) const
Adjust the prologue to have the function use segmented stacks.
Definition TargetFrameLowering.h:248
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:442
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment.
Definition TargetFrameLowering.h:116
virtual void resetCFIToInitialState(MachineBasicBlock &MBB) const
Emit CFI instructions that recreate the state of the unwind information upon function entry.
Definition TargetFrameLowering.h:237
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:323
virtual bool hasFPImpl(const MachineFunction &MF) const =0
virtual void emitZeroCallUsedRegs(BitVector RegsToZero, MachineBasicBlock &MBB) const
emitZeroCallUsedRegs - Zeros out call used registers.
Definition TargetFrameLowering.h:215
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...
Definition TargetFrameLowering.h:500
virtual bool enableCFIFixup(const MachineFunction &MF) const
Returns true if we may need to fix the unwind information for the function.
virtual ~TargetFrameLowering()
virtual bool targetHandlesStackFrameRounding() const
targetHandlesStackFrameRounding - Returns true if the target is responsible for rounding up the stack...
Definition TargetFrameLowering.h:187
virtual unsigned getWinEHParentFrameOffset(const MachineFunction &MF) const
Definition TargetFrameLowering.h:404
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...
Definition TargetFrameLowering.h:282
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Value
Definition TargetFrameLowering.h:30
@ SGPRSpill
Definition TargetFrameLowering.h:32
@ ScalableVector
Definition TargetFrameLowering.h:33
@ NoAlloc
Definition TargetFrameLowering.h:36
@ WasmLocal
Definition TargetFrameLowering.h:34
@ Default
Definition TargetFrameLowering.h:31
@ ScalablePredicateVector
Definition TargetFrameLowering.h:35
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned Index
Definition TargetFrameLowering.h:66
unsigned Kind
Definition TargetFrameLowering.h:65
int64_t Offset
Definition TargetFrameLowering.h:72
FrameBaseKind
Definition TargetFrameLowering.h:63
@ CFA
Definition TargetFrameLowering.h:63
@ Register
Definition TargetFrameLowering.h:63
unsigned Reg
Definition TargetFrameLowering.h:70
struct WasmFrameBase WasmLoc
Definition TargetFrameLowering.h:73
int64_t Offset
Definition TargetFrameLowering.h:57
unsigned Reg
Definition TargetFrameLowering.h:56