LLVM 24.0.0git
AVRFrameLowering.cpp
Go to the documentation of this file.
1//===-- AVRFrameLowering.cpp - AVR Frame Information ----------------------===//
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// This file contains the AVR implementation of TargetFrameLowering class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "AVRFrameLowering.h"
14
15#include "AVR.h"
16#include "AVRInstrInfo.h"
18#include "AVRTargetMachine.h"
20
30#include "llvm/IR/Analysis.h"
31#include "llvm/Pass.h"
33
34using namespace llvm;
35
36namespace llvm {
37
41
43 const MachineFunction &MF) const {
44 // Always simplify call frame pseudo instructions, even when
45 // hasReservedCallFrame is false.
46 return true;
47}
48
50 // Reserve call frame memory in function prologue under the following
51 // conditions:
52 // - Y pointer is reserved to be the frame pointer.
53 // - The function does not contain variable sized objects.
54
55 const MachineFrameInfo &MFI = MF.getFrameInfo();
56 return hasFP(MF) && !MFI.hasVarSizedObjects();
57}
58
60 MachineBasicBlock &MBB) const {
62 DebugLoc DL = (MBBI != MBB.end()) ? MBBI->getDebugLoc() : DebugLoc();
63 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
64 const AVRInstrInfo &TII = *STI.getInstrInfo();
67 bool HasFP = hasFP(MF);
68
69 // Interrupt handlers re-enable interrupts in function entry.
70 if (AFI->isInterruptHandler()) {
71 BuildMI(MBB, MBBI, DL, TII.get(AVR::BSETs))
72 .addImm(0x07)
74 }
75
76 // Emit special prologue code to save R1, R0 and SREG in interrupt/signal
77 // handlers before saving any other registers.
78 if (AFI->isInterruptOrSignalHandler()) {
79 BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
82
83 BuildMI(MBB, MBBI, DL, TII.get(AVR::INRdA), STI.getTmpRegister())
84 .addImm(STI.getIORegSREG())
86 BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
89 if (!MRI.reg_empty(STI.getZeroRegister())) {
90 BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
93 BuildMI(MBB, MBBI, DL, TII.get(AVR::EORRdRr))
98 }
99 }
100
101 // Early exit if the frame pointer is not needed in this function.
102 if (!HasFP) {
103 return;
104 }
105
106 const MachineFrameInfo &MFI = MF.getFrameInfo();
107 unsigned FrameSize = MFI.getStackSize() - AFI->getCalleeSavedFrameSize();
108
109 // Skip the callee-saved push instructions.
110 while (
111 (MBBI != MBB.end()) && MBBI->getFlag(MachineInstr::FrameSetup) &&
112 (MBBI->getOpcode() == AVR::PUSHRr || MBBI->getOpcode() == AVR::PUSHWRr)) {
113 ++MBBI;
114 }
115
116 // Update Y with the new base value.
117 BuildMI(MBB, MBBI, DL, TII.get(AVR::SPREAD), AVR::R29R28)
118 .addReg(AVR::SP)
120
121 // Mark the FramePtr as live-in in every block except the entry.
122 for (MachineBasicBlock &MBBJ : llvm::drop_begin(MF)) {
123 MBBJ.addLiveIn(AVR::R29R28);
124 }
125
126 if (!FrameSize) {
127 return;
128 }
129
130 // Reserve the necessary frame memory by doing FP -= <size>.
131 unsigned Opcode = (isUInt<6>(FrameSize) && STI.hasADDSUBIW()) ? AVR::SBIWRdK
132 : AVR::SUBIWRdK;
133
134 MachineInstr *MI = BuildMI(MBB, MBBI, DL, TII.get(Opcode), AVR::R29R28)
135 .addReg(AVR::R29R28, RegState::Kill)
136 .addImm(FrameSize)
138 // The SREG implicit def is dead.
139 MI->getOperand(3).setIsDead();
140
141 // Write back R29R28 to SP and temporarily disable interrupts.
142 BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
143 .addReg(AVR::R29R28)
145}
146
149 const MachineRegisterInfo &MRI = MF.getRegInfo();
150
151 MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
152
153 DebugLoc DL = MBBI->getDebugLoc();
154 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
155 const AVRInstrInfo &TII = *STI.getInstrInfo();
156
157 // Emit special epilogue code to restore R1, R0 and SREG in interrupt/signal
158 // handlers at the very end of the function, just before reti.
159 if (AFI->isInterruptOrSignalHandler()) {
160 if (!MRI.reg_empty(STI.getZeroRegister())) {
161 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getZeroRegister());
162 }
163 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getTmpRegister());
164 BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr))
165 .addImm(STI.getIORegSREG())
167 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getTmpRegister());
168 }
169}
170
172 MachineBasicBlock &MBB) const {
174
175 // Early exit if the frame pointer is not needed in this function except for
176 // signal/interrupt handlers where special code generation is required.
177 if (!hasFP(MF) && !AFI->isInterruptOrSignalHandler()) {
178 return;
179 }
180
181 MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
182 assert(MBBI->getDesc().isReturn() &&
183 "Can only insert epilog into returning blocks");
184
185 DebugLoc DL = MBBI->getDebugLoc();
186 const MachineFrameInfo &MFI = MF.getFrameInfo();
187 unsigned FrameSize = MFI.getStackSize() - AFI->getCalleeSavedFrameSize();
188 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
189 const AVRInstrInfo &TII = *STI.getInstrInfo();
190
191 // Early exit if there is no need to restore the frame pointer.
192 if (!FrameSize && !MF.getFrameInfo().hasVarSizedObjects()) {
194 return;
195 }
196
197 // Skip the callee-saved pop instructions.
198 while (MBBI != MBB.begin()) {
199 MachineBasicBlock::iterator PI = std::prev(MBBI);
200 int Opc = PI->getOpcode();
201
202 if (Opc != AVR::POPRd && Opc != AVR::POPWRd && !PI->isTerminator()) {
203 break;
204 }
205
206 --MBBI;
207 }
208
209 if (FrameSize) {
210 // Restore the frame pointer by doing FP += <size>.
211 BuildMI(MBB, MBBI, DL, TII.get(AVR::ADIWRdKP), AVR::R29R28)
212 .addReg(AVR::R29R28, RegState::Kill)
213 .addImm(FrameSize)
214 .setOperandDead(3); // implicit-def $sreg
215 }
216
217 // Write back R29R28 to SP and temporarily disable interrupts.
218 BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
219 .addReg(AVR::R29R28, RegState::Kill);
220
222}
223
225 int FI,
226 Register &FrameReg) const {
227 int64_t Offset;
228 const MachineFrameInfo &MFI = MF.getFrameInfo();
229
230 switch (MFI.getStackID(FI)) {
232 Offset = MFI.getObjectOffset(FI) + MFI.getOffsetAdjustment() +
234
235 assert(Offset > 0);
236 break;
237
239 Offset = MFI.getObjectOffset(FI);
240 assert(Offset >= 0);
241 break;
242
243 default:
244 llvm_unreachable("Unsupported stack!");
245 }
246
247 // Frame indices are addressed relative to the frame register (see
248 // AVRRegisterInfo::eliminateFrameIndex); callers such as the DWARF
249 // debug info emitter rely on it being reported back here.
250 FrameReg = MF.getSubtarget().getRegisterInfo()->getFrameRegister(MF);
251
253}
254
255// Return true if the specified function should have a dedicated frame
256// pointer register. This is true if the function meets any of the following
257// conditions:
258// - a register has been spilled
259// - has allocas
260// - input arguments are passed using the stack
261// - has variable sized objects
262// - the frame address is taken (llvm.frameaddress)
263// - the return address is taken (llvm.returnaddress)
264//
265// Notice that strictly this is not a frame pointer because it contains SP after
266// frame allocation instead of having the original SP in function entry.
268 const MachineFrameInfo &MFI = MF.getFrameInfo();
270
271 // Note that reading the return address requires a frame index, and that frame
272 // indexes are always referenced through Y (see
273 // AVRRegisterInfo::eliminateFrameIndex).
274 return (FuncInfo->getHasSpills() || FuncInfo->getHasAllocas() ||
275 FuncInfo->getHasStackArgs() || MFI.hasVarSizedObjects() ||
277}
278
282 if (CSI.empty()) {
283 return false;
284 }
285
286 unsigned CalleeFrameSize = 0;
287 DebugLoc DL = MBB.findDebugLoc(MI);
288 MachineFunction &MF = *MBB.getParent();
289 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
290 const TargetInstrInfo &TII = *STI.getInstrInfo();
292
293 for (const CalleeSavedInfo &I : llvm::reverse(CSI)) {
294 MCRegister Reg = I.getReg();
295 bool IsNotLiveIn = !MBB.isLiveIn(Reg);
296
297 // Check if Reg is a sub register of a 16-bit livein register, and then
298 // add it to the livein list.
299 if (IsNotLiveIn)
300 for (const auto &LiveIn : MBB.liveins())
301 if (STI.getRegisterInfo()->isSubRegister(LiveIn.PhysReg, Reg)) {
302 IsNotLiveIn = false;
303 MBB.addLiveIn(Reg);
304 break;
305 }
306
307 assert(TRI->getRegSizeInBits(*TRI->getMinimalPhysRegClass(Reg)) == 8 &&
308 "Invalid register size");
309
310 // Add the callee-saved register as live-in only if it is not already a
311 // live-in register, this usually happens with arguments that are passed
312 // through callee-saved registers.
313 if (IsNotLiveIn) {
314 MBB.addLiveIn(Reg);
315 }
316
317 // Do not kill the register when it is an input argument.
318 BuildMI(MBB, MI, DL, TII.get(AVR::PUSHRr))
319 .addReg(Reg, getKillRegState(IsNotLiveIn))
321 ++CalleeFrameSize;
322 }
323
324 AVRFI->setCalleeSavedFrameSize(CalleeFrameSize);
325
326 return true;
327}
328
332 if (CSI.empty()) {
333 return false;
334 }
335
336 DebugLoc DL = MBB.findDebugLoc(MI);
337 const MachineFunction &MF = *MBB.getParent();
338 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
339 const TargetInstrInfo &TII = *STI.getInstrInfo();
340
341 for (const CalleeSavedInfo &CCSI : CSI) {
342 MCRegister Reg = CCSI.getReg();
343
344 assert(TRI->getRegSizeInBits(*TRI->getMinimalPhysRegClass(Reg)) == 8 &&
345 "Invalid register size");
346
347 BuildMI(MBB, MI, DL, TII.get(AVR::POPRd), Reg);
348 }
349
350 return true;
351}
352
353/// Replace pseudo store instructions that pass arguments through the stack with
354/// real instructions.
357 const TargetInstrInfo &TII) {
358 // Iterate through the BB until we hit a call instruction or we reach the end.
359 for (MachineInstr &MI :
361 if (MI.isCall())
362 break;
363
364 unsigned Opcode = MI.getOpcode();
365
366 // Only care of pseudo store instructions where SP is the base pointer.
367 if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr)
368 continue;
369
370 assert(MI.getOperand(0).getReg() == AVR::SP &&
371 "SP is expected as base pointer");
372
373 // Replace this instruction with a regular store. Use Y as the base
374 // pointer since it is guaranteed to contain a copy of SP.
375 unsigned STOpc =
376 (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
377
378 MI.setDesc(TII.get(STOpc));
379 MI.getOperand(0).setReg(AVR::R31R30);
380 }
381}
382
386 const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
387 const AVRInstrInfo &TII = *STI.getInstrInfo();
388
389 if (hasReservedCallFrame(MF)) {
390 return MBB.erase(MI);
391 }
392
393 DebugLoc DL = MI->getDebugLoc();
394 unsigned int Opcode = MI->getOpcode();
395 int Amount = TII.getFrameSize(*MI);
396
397 if (Amount == 0) {
398 return MBB.erase(MI);
399 }
400
401 assert(getStackAlign() == Align(1) && "Unsupported stack alignment");
402
403 if (Opcode == TII.getCallFrameSetupOpcode()) {
404 // Update the stack pointer.
405 // In many cases this can be done far more efficiently by pushing the
406 // relevant values directly to the stack. However, doing that correctly
407 // (in the right order, possibly skipping some empty space for undef
408 // values, etc) is tricky and thus left to be optimized in the future.
409 BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
410
411 MachineInstr *New =
412 BuildMI(MBB, MI, DL, TII.get(AVR::SUBIWRdK), AVR::R31R30)
413 .addReg(AVR::R31R30, RegState::Kill)
414 .addImm(Amount);
415 New->getOperand(3).setIsDead();
416
417 BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP).addReg(AVR::R31R30);
418
419 // Make sure the remaining stack stores are converted to real store
420 // instructions.
422 } else {
423 assert(Opcode == TII.getCallFrameDestroyOpcode());
424
425 // Note that small stack changes could be implemented more efficiently
426 // with a few pop instructions instead of the 8-9 instructions now
427 // required.
428
429 BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
430
431 BuildMI(MBB, MI, DL, TII.get(AVR::ADIWRdKP), AVR::R31R30)
432 .addReg(AVR::R31R30, RegState::Kill)
433 .addImm(Amount)
434 .setOperandDead(3); // implicit-def $sreg
435
436 BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP)
437 .addReg(AVR::R31R30, RegState::Kill);
438 }
439
440 return MBB.erase(MI);
441}
442
444 BitVector &SavedRegs,
445 RegScavenger *RS) const {
447
448 // If we have a frame pointer, the Y register needs to be saved as well.
449 if (hasFP(MF)) {
450 SavedRegs.set(AVR::R29);
451 SavedRegs.set(AVR::R28);
452 }
453}
454
455} // end of namespace llvm
456
457namespace {
458/// The frame analyzer pass.
459///
460/// Scans the function for allocas and used arguments
461/// that are passed through the stack.
462struct AVRFrameAnalyzerLegacy : public MachineFunctionPass {
463 static char ID;
464 AVRFrameAnalyzerLegacy() : MachineFunctionPass(ID) {}
465
466 bool runOnMachineFunction(MachineFunction &MF) override;
467
468 StringRef getPassName() const override { return "AVR Frame Analyzer"; }
469
470 void getAnalysisUsage(AnalysisUsage &AU) const override {
471 AU.setPreservesAll();
473 }
474};
475
476} // namespace
477
478char AVRFrameAnalyzerLegacy::ID = 0;
479
480/// Creates instance of the frame analyzer pass.
482 return new AVRFrameAnalyzerLegacy();
483}
484
486 const MachineFrameInfo &MFI = MF.getFrameInfo();
488
489 // If there are no fixed frame indexes during this stage it means there
490 // are allocas present in the function.
491 if (MFI.getNumObjects() != MFI.getNumFixedObjects()) {
492 // Check for the type of allocas present in the function. We only care
493 // about fixed size allocas so do not give false positives if only
494 // variable sized allocas are present.
495 for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
496 if (!MFI.isVariableSizedObjectIndex(i) && !MFI.isDeadObjectIndex(i)) {
497 AFI->setHasAllocas(true);
498 break;
499 }
500 }
501 }
502
503 // If there are fixed frame indexes present, scan the function to see if
504 // they are really being used.
505 if (MFI.getNumFixedObjects() == 0) {
506 return false;
507 }
508
509 // Ok fixed frame indexes present, now scan the function to see if they
510 // are really being used, otherwise we can ignore them.
511 for (const MachineBasicBlock &BB : MF) {
512 for (const MachineInstr &MI : BB) {
513 int Opcode = MI.getOpcode();
514
515 if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
516 (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr) &&
517 (Opcode != AVR::FRMIDX)) {
518 continue;
519 }
520
521 for (const MachineOperand &MO : MI.operands()) {
522 if (!MO.isFI()) {
523 continue;
524 }
525
526 if (MFI.isFixedObjectIndex(MO.getIndex())) {
527 AFI->setHasStackArgs(true);
528 return false;
529 }
530 }
531 }
532 }
533
534 return false;
535}
536
537bool AVRFrameAnalyzerLegacy::runOnMachineFunction(MachineFunction &MF) {
538 return runFrameAnalyzer(MF);
539}
540
541PreservedAnalyses
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static bool runFrameAnalyzer(MachineFunction &MF)
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
MachineRegisterInfo & MRI
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
AVRFrameLowering(const AVRSubtarget &STI)
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
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...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
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...
bool hasFPImpl(const MachineFunction &MF) const override
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
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...
Utilities related to the AVR instruction set.
Contains AVR-specific information for each MachineFunction.
void setCalleeSavedFrameSize(unsigned Bytes)
bool isInterruptOrSignalHandler() const
Checks if the function is some form of interrupt service routine.
A specific AVR target MCU.
Register getTmpRegister() const
Register getZeroRegister() const
const AVRInstrInfo * getInstrInfo() const override
int getIORegSREG() const
const AVRRegisterInfo * getRegisterInfo() const override
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
bool empty() const
Check if the array is empty.
Definition ArrayRef.h:136
BitVector & set()
Set all bits in the bitvector.
Definition BitVector.h:367
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
A debug info location.
Definition DebugLoc.h:127
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
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 isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
int64_t getOffsetAdjustment() const
Return the correction for frame offsets.
unsigned getNumObjects() const
Return the number of objects.
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
uint8_t getStackID(int ObjectIdx) const
unsigned getNumFixedObjects() const
Return the number of fixed objects.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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 MachineInstrBuilder & setOperandDead(unsigned OpIdx) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
Wrapper class representing virtual and physical registers.
Definition Register.h:20
StackOffset holds a fixed and a scalable offset in bytes.
Definition TypeSize.h:31
int64_t getFixed() const
Returns the fixed component of the stack.
Definition TypeSize.h:47
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...
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)
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Pass manager infrastructure for declaring and invalidating analyses.
#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.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition STLExtras.h:316
@ Offset
Definition DWP.cpp:577
static void fixStackStores(MachineBasicBlock &MBB, MachineBasicBlock::iterator StartMI, const TargetInstrInfo &TII)
Replace pseudo store instructions that pass arguments through the stack with real instructions.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
@ Define
Register definition.
constexpr RegState getKillRegState(bool B)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
Definition STLExtras.h:649
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
auto reverse(ContainerTy &&C)
Definition STLExtras.h:408
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Definition MathExtras.h:190
static void restoreStatusRegister(MachineFunction &MF, MachineBasicBlock &MBB)
FunctionPass * createAVRFrameAnalyzerLegacyPass()
Creates instance of the frame analyzer pass.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39