Go to the documentation of this file.
59 bool HasFP =
hasFP(MF);
99 (
MBBI->getOpcode() == AVR::PUSHRr ||
MBBI->getOpcode() == AVR::PUSHWRr)) {
111 I->addLiveIn(AVR::R29R28);
119 unsigned Opcode = (isUInt<6>(FrameSize)) ? AVR::SBIWRdK : AVR::SUBIWRdK;
126 MI->getOperand(3).setIsDead();
166 "Can only insert epilog into returning blocks");
183 int Opc = PI->getOpcode();
185 if (Opc != AVR::POPRd && Opc != AVR::POPWRd && !PI->isTerminator()) {
195 if (isUInt<6>(FrameSize)) {
196 Opcode = AVR::ADIWRdK;
198 Opcode = AVR::SUBIWRdK;
199 FrameSize = -FrameSize;
207 MI->getOperand(3).setIsDead();
239 unsigned CalleeFrameSize = 0;
246 for (
unsigned i = CSI.
size();
i != 0; --
i) {
247 unsigned Reg = CSI[
i - 1].getReg();
248 bool IsNotLiveIn = !
MBB.isLiveIn(
Reg);
250 assert(
TRI->getRegSizeInBits(*
TRI->getMinimalPhysRegClass(
Reg)) == 8 &&
251 "Invalid register size");
285 unsigned Reg = CCSI.getReg();
287 assert(
TRI->getRegSizeInBits(*
TRI->getMinimalPhysRegClass(
Reg)) == 8 &&
288 "Invalid register size");
305 unsigned Opcode =
I->getOpcode();
308 if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr) {
313 assert(
MI.getOperand(0).getReg() == AVR::SP &&
314 "Invalid register, should be SP!");
319 (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
321 MI.setDesc(
TII.get(STOpc));
322 MI.getOperand(0).setReg(FP);
339 return MBB.erase(
MI);
343 unsigned int Opcode =
MI->getOpcode();
344 int Amount =
TII.getFrameSize(*
MI);
351 if (Opcode ==
TII.getCallFrameSetupOpcode()) {
362 New->getOperand(3).setIsDead();
371 assert(Opcode ==
TII.getCallFrameDestroyOpcode());
379 if (isUInt<6>(Amount)) {
380 addOpcode = AVR::ADIWRdK;
382 addOpcode = AVR::SUBIWRdK;
392 New->getOperand(3).setIsDead();
399 return MBB.erase(
MI);
409 SavedRegs.
set(AVR::R29);
410 SavedRegs.
set(AVR::R28);
450 int Opcode =
MI.getOpcode();
452 if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
453 (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr)) {
511 if (!
MBB.empty() &&
MBB.back().isReturn()) {
512 MBBI =
MBB.getLastNonDebugInstr();
523 return "AVR dynalloca stack pointer save/restore";
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
This class represents lattice values for constants.
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
Information about stack frame layout on the target.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getNumFixedObjects() const
Return the number of fixed objects.
void setHasStackArgs(bool B)
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
@ Kill
The last use of a register.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
@ Define
Register definition.
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
int getObjectIndexEnd() const
Return one past the maximum frame object index.
unsigned const TargetRegisterInfo * TRI
bool empty() const
empty - Check if the array is empty.
bool getHasStackArgs() const
void setCalleeSavedFrameSize(unsigned Bytes)
const MachineBasicBlock & front() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
TargetInstrInfo - Interface to description of machine instruction set.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
A specific AVR target MCU.
const HexagonInstrInfo * TII
MachineOperand class - Representation of each machine instruction operand.
const AVRInstrInfo * getInstrInfo() const override
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register.
unsigned getCalleeSavedFrameSize() const
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
Representation of each machine instruction.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
FunctionPass * createAVRDynAllocaSRPass()
createAVRDynAllocaSRPass - returns an instance of the dynalloca stack pointer save/restore pass.
bool isInterruptHandler() const
void setHasAllocas(bool B)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void fixStackStores(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const TargetInstrInfo &TII, Register FP)
Replace pseudo store instructions that pass arguments through the stack with real instructions.
static void restoreStatusRegister(MachineFunction &MF, MachineBasicBlock &MBB)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
MachineBasicBlock MachineBasicBlock::iterator MBBI
bool getHasSpills() const
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Wrapper class representing virtual and physical registers.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool getHasAllocas() const
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
Iterator for intrusive lists based on ilist_node.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
bool isInterruptOrSignalHandler() const
Checks if the function is some form of interrupt service routine.
unsigned getNumObjects() const
Return the number of objects.
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...
unsigned getKillRegState(bool B)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
size_t size() const
size - Get the array size.
Utilities related to the AVR instruction set.
Create the Dynalloca Stack Pointer Save/Restore pass.
Contains AVR-specific information for each MachineFunction.
FunctionPass class - This class is used to implement most global optimizations.
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
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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...
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.