LLVM: lib/Target/VE/VEFrameLowering.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
124
125using namespace llvm;
126
131
136 bool RequireFPUpdate) const {
140
141
142
143
144
145
146
147
159 }
171 }
178}
179
184 bool RequireFPUpdate) const {
188
189
190
191
192
193
194
195
210 }
220 }
221}
222
223void VEFrameLowering::emitSPAdjustment(MachineFunction &MF,
226 int64_t NumBytes,
230
231 if (NumBytes == 0) {
232
233 } else if (isInt<7>(NumBytes)) {
234
238 } else if (isInt<32>(NumBytes)) {
239
244 } else {
245
246
247
248
249
261 }
262
263 if (MaybeAlign) {
264
268 }
269}
270
274 const VEInstrInfo &TII = *STI.getInstrInfo();
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
303}
304
308 assert(&MF.front() == &MBB && "Shrink-wrapping not yet supported");
313 bool NeedsStackRealignment = RegInfo.shouldRealignStack(MF);
314
315
316
318
319 if (NeedsStackRealignment && !RegInfo.canRealignStack(MF))
321 "\" required "
322 "stack re-alignment, but LLVM couldn't handle it "
323 "(probably because it has a dynamic alloca).");
324
325
326
328
329
330
331
333
334 NumBytes = STI.getAdjustedFrameSize(NumBytes);
335 }
336
337
338
340
341
343
344
346
347
348
349
354
355
358 assert((RuntimeAlign == std::nullopt || !FuncInfo->isLeafProc()) &&
359 "SP has to be saved in order to align variable sized stack object!");
360 emitSPAdjustment(MF, MBB, MBBI, -(int64_t)NumBytes, RuntimeAlign);
361
363
367 }
368
369
370 if (NumBytes != 0)
371 emitSPExtend(MF, MBB, MBBI);
372}
373
379 int64_t Size = MI.getOperand(0).getImm();
380 if (MI.getOpcode() == VE::ADJCALLSTACKDOWN)
382
384 emitSPAdjustment(MF, MBB, I, Size);
385 }
387}
388
396
398
399
401
402
406 } else {
407
408 emitSPAdjustment(MF, MBB, MBBI, NumBytes, std::nullopt);
409 }
410
411
413}
414
415
416
417
426
433
440
442 int FI,
447
449
450 if ((MF)) {
451
452 FrameReg = VE::SX11;
455 }
456 if (RegInfo->hasStackRealignment(MF) && !isFixed) {
457
458
460 FrameReg = VE::SX17;
461 else
462 FrameReg = VE::SX11;
465 }
466
467 FrameReg = RegInfo->getFrameRegister(MF);
469}
470
471bool VEFrameLowering::isLeafProc(MachineFunction &MF) const {
472
475
476 return !MFI.hasCalls()
477 && .isPhysRegUsed(VE::SX18)
478
479 && .isPhysRegUsed(VE::SX11)
480 && (MF);
481}
482
487
488
489
490 if (isLeafProc(MF) && (MF)) {
493 }
494}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const TargetInstrInfo & TII
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Register const TargetRegisterInfo * TRI
This file declares the machine register scavenger class.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
MachineInstrBundleIterator< MachineInstr > iterator
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool hasCalls() const
Return true if the current function has any function calls.
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
Align getMaxAlign() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
void setStackSize(uint64_t Size)
Set the size of the stack.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineBasicBlock & front() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
LLVM_ABI bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void emitEpilogueInsns(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, uint64_t NumBytes, bool RequireFPUpdate) const
Definition VEFrameLowering.cpp:180
bool hasBP(const MachineFunction &MF) const
Definition VEFrameLowering.cpp:427
void emitPrologueInsns(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, uint64_t NumBytes, bool RequireFPUpdate) const
Definition VEFrameLowering.cpp:132
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...
Definition VEFrameLowering.cpp:374
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...
Definition VEFrameLowering.cpp:441
bool hasFPImpl(const MachineFunction &MF) const override
Definition VEFrameLowering.cpp:418
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition VEFrameLowering.cpp:483
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition VEFrameLowering.cpp:389
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition VEFrameLowering.cpp:305
VEFrameLowering(const VESubtarget &ST)
Definition VEFrameLowering.cpp:127
bool hasGOT(const MachineFunction &MF) const
Definition VEFrameLowering.cpp:434
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Register getGlobalBaseReg() const
void setLeafProc(bool rhs)
const VEInstrInfo * getInstrInfo() const override
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
unsigned M1(unsigned Val)
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
unsigned M0(unsigned Val)
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.