60 bool HasFP =
hasFP(MF);
84 BuildMI(MBB, MBBI, DL, TII.
get(AVR::INRdA), AVR::R0)
109 (MBBI->getOpcode() == AVR::PUSHRr || MBBI->getOpcode() == AVR::PUSHWRr)) {
114 BuildMI(MBB, MBBI, DL, TII.
get(AVR::SPREAD), AVR::R29R28)
121 I->addLiveIn(AVR::R29R28);
129 unsigned Opcode = (isUInt<6>(FrameSize)) ? AVR::SBIWRdK : AVR::SUBIWRdK;
139 BuildMI(MBB, MBBI, DL, TII.
get(AVR::SPWRITE), AVR::SP)
152 if (!
hasFP(MF) && !isHandler) {
157 assert(MBBI->getDesc().isReturn() &&
158 "Can only insert epilog into returning blocks");
170 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), AVR::R0);
171 BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr))
174 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R1R0);
178 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R29R28);
186 while (MBBI != MBB.
begin()) {
188 int Opc = PI->getOpcode();
190 if (Opc != AVR::POPRd && Opc != AVR::POPWRd && !PI->isTerminator()) {
200 if (isUInt<6>(FrameSize)) {
201 Opcode = AVR::ADIWRdK;
203 Opcode = AVR::SUBIWRdK;
204 FrameSize = -FrameSize;
215 BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
237 const std::vector<CalleeSavedInfo> &CSI,
243 unsigned CalleeFrameSize = 0;
250 for (
unsigned i = CSI.size(); i != 0; --i) {
251 unsigned Reg = CSI[i - 1].getReg();
252 bool IsNotLiveIn = !MBB.
isLiveIn(Reg);
255 "Invalid register size");
278 const std::vector<CalleeSavedInfo> &CSI,
290 unsigned Reg = CCSI.getReg();
293 "Invalid register size");
312 for (
auto I = MI,
E = MBB.
end();
I !=
E && !
I->isCall();) {
315 unsigned Opcode =
I->getOpcode();
318 if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr) {
324 "Invalid register, should be SP!");
332 if (Opcode == AVR::STDWSPQRr) {
334 .addReg(TRI.getSubReg(SrcReg, AVR::sub_hi),
337 .addReg(TRI.getSubReg(SrcReg, AVR::sub_lo),
352 (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
371 if (TFI.hasReservedCallFrame(MF)) {
373 return MBB.
erase(MI);
377 unsigned int Opcode = MI->getOpcode();
378 int Amount = TII.getFrameSize(*MI);
385 assert(TFI.getStackAlignment() == 1 &&
"Unsupported stack alignment");
387 if (Opcode == TII.getCallFrameSetupOpcode()) {
390 assert(Opcode == TII.getCallFrameDestroyOpcode());
394 if (isUInt<6>(Amount)) {
395 addOpcode = AVR::ADIWRdK;
397 addOpcode = AVR::SUBIWRdK;
402 BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
409 BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP)
414 return MBB.
erase(MI);
463 int Opcode =
MI.getOpcode();
465 if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
466 (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr)) {
519 BuildMI(EntryMBB, MBBI, DL, TII.
get(AVR::COPY), SPCopy).addReg(AVR::SP);
524 if (!MBB.empty() && MBB.back().isReturn()) {
525 MBBI = MBB.getLastNonDebugInstr();
526 DL = MBBI->getDebugLoc();
527 BuildMI(MBB, MBBI, DL, TII.
get(AVR::COPY), AVR::SP)
536 return "AVR dynalloca stack pointer save/restore";
const AVRInstrInfo * getInstrInfo() const override
bool runOnMachineFunction(MachineFunction &MF)
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Calling convention used for AVR signal routines.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
unsigned getNumObjects() const
Return the number of objects.
bool getHasSpills() const
void setIsDead(bool Val=true)
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
DILocation * get() const
Get the underlying DILocation.
const HexagonInstrInfo * TII
void setHasStackArgs(bool B)
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required, we reserve argument space for call sites in the function immediately on entry to the current function.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool getHasAllocas() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
const MachineBasicBlock & front() const
Utilities related to the AVR instruction set.
bool getHasStackArgs() const
void setHasAllocas(bool B)
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
unsigned getNumFixedObjects() const
Return the number of fixed objects.
Used for AVR interrupt routines.
unsigned getKillRegState(bool B)
TargetInstrInfo - Interface to description of machine instruction set.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
Contains AVR-specific information for each MachineFunction.
StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE instructions.
const MachineOperand & getOperand(unsigned i) const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
FunctionPass class - This class is used to implement most global optimizations.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
Iterator for intrusive lists based on ilist_node.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
MachineOperand class - Representation of each machine instruction operand.
Information about stack frame layout on the target.
void setCalleeSavedFrameSize(unsigned Bytes)
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
A specific AVR target MCU.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Representation of each machine instruction.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static void fixStackStores(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const TargetInstrInfo &TII, bool insertPushes)
Replace pseudo store instructions that pass arguments through the stack with real instructions...
void setReg(unsigned Reg)
Change the register this operand corresponds to.
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool spillCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
spillCalleeSavedRegisters - Issues instruction(s) to spill all callee saved registers and returns tru...
unsigned getCalleeSavedFrameSize() const
FunctionPass * createAVRFrameAnalyzerPass()
Creates instance of the frame analyzer pass.
const TargetFrameLowering * getFrameLowering() const override
const AVRRegisterInfo * getRegisterInfo() const override
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...
StringRef - Represent a constant reference to a string, i.e.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
int getObjectIndexEnd() const
Return one past the maximum frame object index.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
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 runOnMachineFunction(MachineFunction &MF)
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Create the Dynalloca Stack Pointer Save/Restore pass.