LLVM  16.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"
17 #include "AVRMachineFunctionInfo.h"
18 #include "AVRTargetMachine.h"
20 
26 #include "llvm/IR/Function.h"
27 
28 #include <vector>
29 
30 namespace llvm {
31 
33  : TargetFrameLowering(TargetFrameLowering::StackGrowsDown, Align(1), -2) {}
34 
36  const MachineFunction &MF) const {
37  // Always simplify call frame pseudo instructions, even when
38  // hasReservedCallFrame is false.
39  return true;
40 }
41 
43  // Reserve call frame memory in function prologue under the following
44  // conditions:
45  // - Y pointer is reserved to be the frame pointer.
46  // - The function does not contain variable sized objects.
47 
48  const MachineFrameInfo &MFI = MF.getFrameInfo();
49  return hasFP(MF) && !MFI.hasVarSizedObjects();
50 }
51 
53  MachineBasicBlock &MBB) const {
55  DebugLoc DL = (MBBI != MBB.end()) ? MBBI->getDebugLoc() : DebugLoc();
56  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
57  const AVRInstrInfo &TII = *STI.getInstrInfo();
59  const MachineRegisterInfo &MRI = MF.getRegInfo();
60  bool HasFP = hasFP(MF);
61 
62  // Interrupt handlers re-enable interrupts in function entry.
63  if (AFI->isInterruptHandler()) {
64  BuildMI(MBB, MBBI, DL, TII.get(AVR::BSETs))
65  .addImm(0x07)
67  }
68 
69  // Emit special prologue code to save R1, R0 and SREG in interrupt/signal
70  // handlers before saving any other registers.
71  if (AFI->isInterruptOrSignalHandler()) {
72  BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
75 
76  BuildMI(MBB, MBBI, DL, TII.get(AVR::INRdA), STI.getTmpRegister())
77  .addImm(STI.getIORegSREG())
79  BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
82  if (!MRI.reg_empty(STI.getZeroRegister())) {
83  BuildMI(MBB, MBBI, DL, TII.get(AVR::PUSHRr))
86  BuildMI(MBB, MBBI, DL, TII.get(AVR::EORRdRr))
91  }
92  }
93 
94  // Early exit if the frame pointer is not needed in this function.
95  if (!HasFP) {
96  return;
97  }
98 
99  const MachineFrameInfo &MFI = MF.getFrameInfo();
100  unsigned FrameSize = MFI.getStackSize() - AFI->getCalleeSavedFrameSize();
101 
102  // Skip the callee-saved push instructions.
103  while (
104  (MBBI != MBB.end()) && MBBI->getFlag(MachineInstr::FrameSetup) &&
105  (MBBI->getOpcode() == AVR::PUSHRr || MBBI->getOpcode() == AVR::PUSHWRr)) {
106  ++MBBI;
107  }
108 
109  // Update Y with the new base value.
110  BuildMI(MBB, MBBI, DL, TII.get(AVR::SPREAD), AVR::R29R28)
111  .addReg(AVR::SP)
113 
114  // Mark the FramePtr as live-in in every block except the entry.
115  for (MachineBasicBlock &MBBJ : llvm::drop_begin(MF)) {
116  MBBJ.addLiveIn(AVR::R29R28);
117  }
118 
119  if (!FrameSize) {
120  return;
121  }
122 
123  // Reserve the necessary frame memory by doing FP -= <size>.
124  unsigned Opcode = (isUInt<6>(FrameSize)) ? AVR::SBIWRdK : AVR::SUBIWRdK;
125 
126  MachineInstr *MI = BuildMI(MBB, MBBI, DL, TII.get(Opcode), AVR::R29R28)
127  .addReg(AVR::R29R28, RegState::Kill)
128  .addImm(FrameSize)
130  // The SREG implicit def is dead.
131  MI->getOperand(3).setIsDead();
132 
133  // Write back R29R28 to SP and temporarily disable interrupts.
134  BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
135  .addReg(AVR::R29R28)
137 }
138 
141  const MachineRegisterInfo &MRI = MF.getRegInfo();
142 
144 
145  DebugLoc DL = MBBI->getDebugLoc();
146  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
147  const AVRInstrInfo &TII = *STI.getInstrInfo();
148 
149  // Emit special epilogue code to restore R1, R0 and SREG in interrupt/signal
150  // handlers at the very end of the function, just before reti.
151  if (AFI->isInterruptOrSignalHandler()) {
152  if (!MRI.reg_empty(STI.getZeroRegister())) {
153  BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getZeroRegister());
154  }
155  BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getTmpRegister());
156  BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr))
157  .addImm(STI.getIORegSREG())
159  BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), STI.getTmpRegister());
160  }
161 }
162 
164  MachineBasicBlock &MBB) const {
166 
167  // Early exit if the frame pointer is not needed in this function except for
168  // signal/interrupt handlers where special code generation is required.
169  if (!hasFP(MF) && !AFI->isInterruptOrSignalHandler()) {
170  return;
171  }
172 
173  MachineBasicBlock::iterator MBBI = MBB.getLastNonDebugInstr();
174  assert(MBBI->getDesc().isReturn() &&
175  "Can only insert epilog into returning blocks");
176 
177  DebugLoc DL = MBBI->getDebugLoc();
178  const MachineFrameInfo &MFI = MF.getFrameInfo();
179  unsigned FrameSize = MFI.getStackSize() - AFI->getCalleeSavedFrameSize();
180  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
181  const AVRInstrInfo &TII = *STI.getInstrInfo();
182 
183  // Early exit if there is no need to restore the frame pointer.
184  if (!FrameSize && !MF.getFrameInfo().hasVarSizedObjects()) {
186  return;
187  }
188 
189  // Skip the callee-saved pop instructions.
190  while (MBBI != MBB.begin()) {
191  MachineBasicBlock::iterator PI = std::prev(MBBI);
192  int Opc = PI->getOpcode();
193 
194  if (Opc != AVR::POPRd && Opc != AVR::POPWRd && !PI->isTerminator()) {
195  break;
196  }
197 
198  --MBBI;
199  }
200 
201  if (FrameSize) {
202  unsigned Opcode;
203 
204  // Select the optimal opcode depending on how big it is.
205  if (isUInt<6>(FrameSize)) {
206  Opcode = AVR::ADIWRdK;
207  } else {
208  Opcode = AVR::SUBIWRdK;
209  FrameSize = -FrameSize;
210  }
211 
212  // Restore the frame pointer by doing FP += <size>.
213  MachineInstr *MI = BuildMI(MBB, MBBI, DL, TII.get(Opcode), AVR::R29R28)
214  .addReg(AVR::R29R28, RegState::Kill)
215  .addImm(FrameSize);
216  // The SREG implicit def is dead.
217  MI->getOperand(3).setIsDead();
218  }
219 
220  // Write back R29R28 to SP and temporarily disable interrupts.
221  BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
222  .addReg(AVR::R29R28, RegState::Kill);
223 
225 }
226 
227 // Return true if the specified function should have a dedicated frame
228 // pointer register. This is true if the function meets any of the following
229 // conditions:
230 // - a register has been spilled
231 // - has allocas
232 // - input arguments are passed using the stack
233 //
234 // Notice that strictly this is not a frame pointer because it contains SP after
235 // frame allocation instead of having the original SP in function entry.
237  const AVRMachineFunctionInfo *FuncInfo = MF.getInfo<AVRMachineFunctionInfo>();
238 
239  return (FuncInfo->getHasSpills() || FuncInfo->getHasAllocas() ||
240  FuncInfo->getHasStackArgs() ||
242 }
243 
247  if (CSI.empty()) {
248  return false;
249  }
250 
251  unsigned CalleeFrameSize = 0;
252  DebugLoc DL = MBB.findDebugLoc(MI);
253  MachineFunction &MF = *MBB.getParent();
254  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
255  const TargetInstrInfo &TII = *STI.getInstrInfo();
257 
258  for (const CalleeSavedInfo &I : llvm::reverse(CSI)) {
259  Register Reg = I.getReg();
260  bool IsNotLiveIn = !MBB.isLiveIn(Reg);
261 
262  assert(TRI->getRegSizeInBits(*TRI->getMinimalPhysRegClass(Reg)) == 8 &&
263  "Invalid register size");
264 
265  // Add the callee-saved register as live-in only if it is not already a
266  // live-in register, this usually happens with arguments that are passed
267  // through callee-saved registers.
268  if (IsNotLiveIn) {
269  MBB.addLiveIn(Reg);
270  }
271 
272  // Do not kill the register when it is an input argument.
273  BuildMI(MBB, MI, DL, TII.get(AVR::PUSHRr))
274  .addReg(Reg, getKillRegState(IsNotLiveIn))
276  ++CalleeFrameSize;
277  }
278 
279  AVRFI->setCalleeSavedFrameSize(CalleeFrameSize);
280 
281  return true;
282 }
283 
287  if (CSI.empty()) {
288  return false;
289  }
290 
291  DebugLoc DL = MBB.findDebugLoc(MI);
292  const MachineFunction &MF = *MBB.getParent();
293  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
294  const TargetInstrInfo &TII = *STI.getInstrInfo();
295 
296  for (const CalleeSavedInfo &CCSI : CSI) {
297  Register Reg = CCSI.getReg();
298 
299  assert(TRI->getRegSizeInBits(*TRI->getMinimalPhysRegClass(Reg)) == 8 &&
300  "Invalid register size");
301 
302  BuildMI(MBB, MI, DL, TII.get(AVR::POPRd), Reg);
303  }
304 
305  return true;
306 }
307 
308 /// Replace pseudo store instructions that pass arguments through the stack with
309 /// real instructions.
312  const TargetInstrInfo &TII) {
313  // Iterate through the BB until we hit a call instruction or we reach the end.
314  for (MachineInstr &MI :
316  if (MI.isCall())
317  break;
318 
319  unsigned Opcode = MI.getOpcode();
320 
321  // Only care of pseudo store instructions where SP is the base pointer.
322  if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr)
323  continue;
324 
325  assert(MI.getOperand(0).getReg() == AVR::SP &&
326  "SP is expected as base pointer");
327 
328  // Replace this instruction with a regular store. Use Y as the base
329  // pointer since it is guaranteed to contain a copy of SP.
330  unsigned STOpc =
331  (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
332 
333  MI.setDesc(TII.get(STOpc));
334  MI.getOperand(0).setReg(AVR::R31R30);
335  }
336 }
337 
341  const AVRSubtarget &STI = MF.getSubtarget<AVRSubtarget>();
342  const AVRInstrInfo &TII = *STI.getInstrInfo();
343 
344  if (hasReservedCallFrame(MF)) {
345  return MBB.erase(MI);
346  }
347 
348  DebugLoc DL = MI->getDebugLoc();
349  unsigned int Opcode = MI->getOpcode();
350  int Amount = TII.getFrameSize(*MI);
351 
352  if (Amount == 0) {
353  return MBB.erase(MI);
354  }
355 
356  assert(getStackAlign() == Align(1) && "Unsupported stack alignment");
357 
358  if (Opcode == TII.getCallFrameSetupOpcode()) {
359  // Update the stack pointer.
360  // In many cases this can be done far more efficiently by pushing the
361  // relevant values directly to the stack. However, doing that correctly
362  // (in the right order, possibly skipping some empty space for undef
363  // values, etc) is tricky and thus left to be optimized in the future.
364  BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
365 
366  MachineInstr *New =
367  BuildMI(MBB, MI, DL, TII.get(AVR::SUBIWRdK), AVR::R31R30)
368  .addReg(AVR::R31R30, RegState::Kill)
369  .addImm(Amount);
370  New->getOperand(3).setIsDead();
371 
372  BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP).addReg(AVR::R31R30);
373 
374  // Make sure the remaining stack stores are converted to real store
375  // instructions.
377  } else {
378  assert(Opcode == TII.getCallFrameDestroyOpcode());
379 
380  // Note that small stack changes could be implemented more efficiently
381  // with a few pop instructions instead of the 8-9 instructions now
382  // required.
383 
384  // Select the best opcode to adjust SP based on the offset size.
385  unsigned AddOpcode;
386 
387  if (isUInt<6>(Amount)) {
388  AddOpcode = AVR::ADIWRdK;
389  } else {
390  AddOpcode = AVR::SUBIWRdK;
391  Amount = -Amount;
392  }
393 
394  // Build the instruction sequence.
395  BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
396 
397  MachineInstr *New = BuildMI(MBB, MI, DL, TII.get(AddOpcode), AVR::R31R30)
398  .addReg(AVR::R31R30, RegState::Kill)
399  .addImm(Amount);
400  New->getOperand(3).setIsDead();
401 
402  BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP)
403  .addReg(AVR::R31R30, RegState::Kill);
404  }
405 
406  return MBB.erase(MI);
407 }
408 
410  BitVector &SavedRegs,
411  RegScavenger *RS) const {
413 
414  // If we have a frame pointer, the Y register needs to be saved as well.
415  if (hasFP(MF)) {
416  SavedRegs.set(AVR::R29);
417  SavedRegs.set(AVR::R28);
418  }
419 }
420 /// The frame analyzer pass.
421 ///
422 /// Scans the function for allocas and used arguments
423 /// that are passed through the stack.
425  static char ID;
427 
429  const MachineFrameInfo &MFI = MF.getFrameInfo();
431 
432  // If there are no fixed frame indexes during this stage it means there
433  // are allocas present in the function.
434  if (MFI.getNumObjects() != MFI.getNumFixedObjects()) {
435  // Check for the type of allocas present in the function. We only care
436  // about fixed size allocas so do not give false positives if only
437  // variable sized allocas are present.
438  for (unsigned i = 0, e = MFI.getObjectIndexEnd(); i != e; ++i) {
439  // Variable sized objects have size 0.
440  if (MFI.getObjectSize(i)) {
441  AFI->setHasAllocas(true);
442  break;
443  }
444  }
445  }
446 
447  // If there are fixed frame indexes present, scan the function to see if
448  // they are really being used.
449  if (MFI.getNumFixedObjects() == 0) {
450  return false;
451  }
452 
453  // Ok fixed frame indexes present, now scan the function to see if they
454  // are really being used, otherwise we can ignore them.
455  for (const MachineBasicBlock &BB : MF) {
456  for (const MachineInstr &MI : BB) {
457  int Opcode = MI.getOpcode();
458 
459  if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
460  (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr)) {
461  continue;
462  }
463 
464  for (const MachineOperand &MO : MI.operands()) {
465  if (!MO.isFI()) {
466  continue;
467  }
468 
469  if (MFI.isFixedObjectIndex(MO.getIndex())) {
470  AFI->setHasStackArgs(true);
471  return false;
472  }
473  }
474  }
475  }
476 
477  return false;
478  }
479 
480  StringRef getPassName() const override { return "AVR Frame Analyzer"; }
481 };
482 
483 char AVRFrameAnalyzer::ID = 0;
484 
485 /// Creates instance of the frame analyzer pass.
487 
488 } // end of namespace llvm
i
i
Definition: README.txt:29
llvm::MachineFrameInfo::hasVarSizedObjects
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
Definition: MachineFrameInfo.h:355
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
llvm::MachineInstrBuilder::addImm
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Definition: MachineInstrBuilder.h:131
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::AVRFrameLowering::hasReservedCallFrame
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Definition: AVRFrameLowering.cpp:42
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
llvm::drop_begin
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Definition: STLExtras.h:387
llvm::TargetFrameLowering
Information about stack frame layout on the target.
Definition: TargetFrameLowering.h:43
llvm::MachineFrameInfo::getNumFixedObjects
unsigned getNumFixedObjects() const
Return the number of fixed objects.
Definition: MachineFrameInfo.h:413
llvm::AVRMachineFunctionInfo::setHasStackArgs
void setHasStackArgs(bool B)
Definition: AVRMachineFunctionInfo.h:78
llvm::AVRFrameLowering::determineCalleeSaves
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Definition: AVRFrameLowering.cpp:409
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:50
llvm::BitVector::set
BitVector & set()
Definition: BitVector.h:344
llvm::AVRFrameLowering::canSimplifyCallFramePseudos
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
Definition: AVRFrameLowering.cpp:35
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
llvm::MachineFunctionPass
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Definition: MachineFunctionPass.h:30
llvm::RegState::Define
@ Define
Register definition.
Definition: MachineInstrBuilder.h:44
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:237
llvm::AVRFrameLowering::emitEpilogue
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
Definition: AVRFrameLowering.cpp:163
llvm::fixStackStores
static void fixStackStores(MachineBasicBlock &MBB, MachineBasicBlock::iterator StartMI, const TargetInstrInfo &TII)
Replace pseudo store instructions that pass arguments through the stack with real instructions.
Definition: AVRFrameLowering.cpp:310
llvm::MachineFrameInfo::getObjectIndexEnd
int getObjectIndexEnd() const
Return one past the maximum frame object index.
Definition: MachineFrameInfo.h:410
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1628
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:159
MachineRegisterInfo.h
llvm::AVRMachineFunctionInfo::getHasStackArgs
bool getHasStackArgs() const
Definition: AVRMachineFunctionInfo.h:77
llvm::AVRMachineFunctionInfo::setCalleeSavedFrameSize
void setCalleeSavedFrameSize(unsigned Bytes)
Definition: AVRMachineFunctionInfo.h:89
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:667
llvm::TargetInstrInfo
TargetInstrInfo - Interface to description of machine instruction set.
Definition: TargetInstrInfo.h:98
llvm::MutableArrayRef
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:28
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:755
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::AVRSubtarget::getTmpRegister
Register getTmpRegister() const
Definition: AVRSubtarget.h:106
llvm::AVRSubtarget
A specific AVR target MCU.
Definition: AVRSubtarget.h:32
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:125
llvm::MachineOperand
MachineOperand class - Representation of each machine instruction operand.
Definition: MachineOperand.h:48
llvm::MachineInstr::FrameSetup
@ FrameSetup
Definition: MachineInstr.h:84
llvm::AVRSubtarget::getInstrInfo
const AVRInstrInfo * getInstrInfo() const override
Definition: AVRSubtarget.h:42
llvm::MachineFrameInfo::getStackSize
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
Definition: MachineFrameInfo.h:585
llvm::AVRFrameLowering::hasFP
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
Definition: AVRFrameLowering.cpp:236
llvm::AVRMachineFunctionInfo::getCalleeSavedFrameSize
unsigned getCalleeSavedFrameSize() const
Definition: AVRMachineFunctionInfo.h:88
llvm::BitVector
Definition: BitVector.h:75
Align
uint64_t Align
Definition: ELFObjHandler.cpp:82
llvm::MachineFrameInfo::isFixedObjectIndex
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
Definition: MachineFrameInfo.h:688
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::AVRFrameAnalyzer::ID
static char ID
Definition: AVRFrameLowering.cpp:425
llvm::AVRFrameLowering::eliminateCallFramePseudoInstr
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...
Definition: AVRFrameLowering.cpp:338
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::MachineBasicBlock
Definition: MachineBasicBlock.h:94
llvm::AVRSubtarget::getZeroRegister
Register getZeroRegister() const
Definition: AVRSubtarget.h:109
llvm::MachineFunction::getSubtarget
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Definition: MachineFunction.h:657
llvm::MachineInstrBuilder::setMIFlag
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
Definition: MachineInstrBuilder.h:278
llvm::AVRFrameAnalyzer
The frame analyzer pass.
Definition: AVRFrameLowering.cpp:424
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
llvm::MachineFrameInfo::getObjectSize
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
Definition: MachineFrameInfo.h:470
AVRFrameLowering.h
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:53
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::RegScavenger
Definition: RegisterScavenging.h:34
llvm::make_early_inc_range
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:716
llvm::AVRMachineFunctionInfo::isInterruptHandler
bool isInterruptHandler() const
Definition: AVRMachineFunctionInfo.h:85
llvm::MachineBasicBlock::getLastNonDebugInstr
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
Definition: MachineBasicBlock.cpp:264
MachineFunctionPass.h
AVRTargetMachine.h
llvm::AVRMachineFunctionInfo::setHasAllocas
void setHasAllocas(bool B)
Definition: AVRMachineFunctionInfo.h:75
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::restoreStatusRegister
static void restoreStatusRegister(MachineFunction &MF, MachineBasicBlock &MBB)
Definition: AVRFrameLowering.cpp:139
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:673
AVRMCTargetDesc.h
llvm::MachineInstrBuilder::addReg
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Definition: MachineInstrBuilder.h:97
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
MBBI
MachineBasicBlock MachineBasicBlock::iterator MBBI
Definition: AArch64SLSHardening.cpp:75
llvm::AVRMachineFunctionInfo::getHasSpills
bool getHasSpills() const
Definition: AVRMachineFunctionInfo.h:71
AVRMachineFunctionInfo.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::AVRFrameLowering::emitPrologue
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
Definition: AVRFrameLowering.cpp:52
llvm::AVRMachineFunctionInfo::getHasAllocas
bool getHasAllocas() const
Definition: AVRMachineFunctionInfo.h:74
MBB
MachineBasicBlock & MBB
Definition: AArch64SLSHardening.cpp:74
llvm::CalleeSavedInfo
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
Definition: MachineFrameInfo.h:34
llvm::createAVRFrameAnalyzerPass
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
Definition: AVRFrameLowering.cpp:486
MachineFrameInfo.h
llvm::RegState::Kill
@ Kill
The last use of a register.
Definition: MachineInstrBuilder.h:48
Function.h
llvm::MachineRegisterInfo::reg_empty
bool reg_empty(Register RegNo) const
reg_empty - Return true if there are no instructions using or defining the specified register (it may...
Definition: MachineRegisterInfo.h:331
AVR.h
llvm::AVRMachineFunctionInfo::isInterruptOrSignalHandler
bool isInterruptOrSignalHandler() const
Checks if the function is some form of interrupt service routine.
Definition: AVRMachineFunctionInfo.h:81
llvm::MachineFrameInfo::getNumObjects
unsigned getNumObjects() const
Return the number of objects.
Definition: MachineFrameInfo.h:416
llvm::AVRFrameLowering::spillCalleeSavedRegisters
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...
Definition: AVRFrameLowering.cpp:244
llvm::AVRFrameLowering::AVRFrameLowering
AVRFrameLowering()
Definition: AVRFrameLowering.cpp:32
llvm::getKillRegState
unsigned getKillRegState(bool B)
Definition: MachineInstrBuilder.h:546
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:106
llvm::BuildMI
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
Definition: MachineInstrBuilder.h:357
MachineInstrBuilder.h
llvm::AVRInstrInfo
Utilities related to the AVR instruction set.
Definition: AVRInstrInfo.h:64
llvm::AVRMachineFunctionInfo
Contains AVR-specific information for each MachineFunction.
Definition: AVRMachineFunctionInfo.h:21
llvm::reverse
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:485
AVRInstrInfo.h
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:308
BB
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
Definition: README.txt:39
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:83
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::AVRSubtarget::getIORegSREG
int getIORegSREG() const
Definition: AVRSubtarget.h:100
MachineFunction.h
llvm::AVRFrameAnalyzer::runOnMachineFunction
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Definition: AVRFrameLowering.cpp:428
llvm::MachineInstrBundleIterator< MachineInstr >
llvm::AVRFrameAnalyzer::AVRFrameAnalyzer
AVRFrameAnalyzer()
Definition: AVRFrameLowering.cpp:426
llvm::MachineBasicBlock::end
iterator end()
Definition: MachineBasicBlock.h:307
llvm::AVRFrameLowering::restoreCalleeSavedRegisters
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...
Definition: AVRFrameLowering.cpp:284
llvm::AVRFrameAnalyzer::getPassName
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
Definition: AVRFrameLowering.cpp:480