75 BuildMI(MBB, MBBI, DL, TII.
get(AVR::INRdA), AVR::R0)
100 (MBBI->getOpcode() == AVR::PUSHRr || MBBI->getOpcode() == AVR::PUSHWRr)) {
105 BuildMI(MBB, MBBI, DL, TII.
get(AVR::SPREAD), AVR::R29R28)
112 I->addLiveIn(AVR::R29R28);
120 unsigned Opcode = (isUInt<6>(FrameSize)) ? AVR::SBIWRdK : AVR::SUBIWRdK;
130 BuildMI(MBB, MBBI, DL, TII.
get(AVR::SPWRITE), AVR::SP)
143 if (!
hasFP(MF) && !isHandler) {
148 assert(MBBI->getDesc().isReturn() &&
149 "Can only insert epilog into returning blocks");
161 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPRd), AVR::R0);
162 BuildMI(MBB, MBBI, DL, TII.get(AVR::OUTARr))
165 BuildMI(MBB, MBBI, DL, TII.get(AVR::POPWRd), AVR::R1R0);
174 while (MBBI != MBB.
begin()) {
176 int Opc = PI->getOpcode();
178 if (Opc != AVR::POPRd && Opc != AVR::POPWRd && !PI->isTerminator()) {
188 if (isUInt<6>(FrameSize)) {
189 Opcode = AVR::ADIWRdK;
191 Opcode = AVR::SUBIWRdK;
192 FrameSize = -FrameSize;
203 BuildMI(MBB, MBBI, DL, TII.get(AVR::SPWRITE), AVR::SP)
225 const std::vector<CalleeSavedInfo> &CSI,
231 unsigned CalleeFrameSize = 0;
238 for (
unsigned i = CSI.size();
i != 0; --
i) {
239 unsigned Reg = CSI[
i - 1].getReg();
240 bool IsNotLiveIn = !MBB.
isLiveIn(Reg);
243 "Invalid register size");
266 const std::vector<CalleeSavedInfo> &CSI,
278 unsigned Reg = CCSI.getReg();
281 "Invalid register size");
300 for (
auto I = MI,
E = MBB.
end();
I !=
E && !
I->isCall();) {
303 unsigned Opcode =
I->getOpcode();
306 if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr) {
312 "Invalid register, should be SP!");
320 if (Opcode == AVR::STDWSPQRr) {
322 .addReg(TRI.getSubReg(SrcReg, AVR::sub_hi),
325 .addReg(TRI.getSubReg(SrcReg, AVR::sub_lo),
340 (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
359 if (TFI.hasReservedCallFrame(MF)) {
361 return MBB.
erase(MI);
365 unsigned int Opcode = MI->getOpcode();
366 int Amount = MI->getOperand(0).getImm();
373 assert(TFI.getStackAlignment() == 1 &&
"Unsupported stack alignment");
375 if (Opcode == TII.getCallFrameSetupOpcode()) {
378 assert(Opcode == TII.getCallFrameDestroyOpcode());
382 if (isUInt<6>(Amount)) {
383 addOpcode = AVR::ADIWRdK;
385 addOpcode = AVR::SUBIWRdK;
390 BuildMI(MBB, MI, DL, TII.get(AVR::SPREAD), AVR::R31R30).addReg(AVR::SP);
397 BuildMI(MBB, MI, DL, TII.get(AVR::SPWRITE), AVR::SP)
402 return MBB.
erase(MI);
412 SavedRegs.
set(AVR::R29R28);
413 SavedRegs.
set(AVR::R29);
414 SavedRegs.
set(AVR::R28);
454 int Opcode =
MI.getOpcode();
456 if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
457 (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr)) {
510 BuildMI(EntryMBB, MBBI, DL, TII.
get(AVR::COPY), SPCopy).addReg(AVR::SP);
515 if (!
MBB.empty() &&
MBB.back().isReturn()) {
516 MBBI =
MBB.getLastNonDebugInstr();
517 DL = MBBI->getDebugLoc();
527 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.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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 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...
unsigned getSize() const
Return the size of the register in bytes, which is also the size of a stack slot allocated to hold a ...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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.
unsigned getKillRegState(bool B)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
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.
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.
Used for AVR interrupt routines.
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...
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE instructions.
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
Calling convention used for AVR signal routines.
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.