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 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
unsigned getNumFixedObjects() const
Return the number of fixed objects.
bool runOnMachineFunction(MachineFunction &MF)
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Used for AVR interrupt routines.
DILocation * get() const
Get the underlying DILocation.
This class represents lattice values for constants.
unsigned getNumObjects() const
Return the number of objects.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
unsigned getReg() const
getReg - Returns the register number.
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
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...
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.
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 ...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
Utilities related to the AVR instruction set.
StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
void setHasAllocas(bool B)
int getObjectIndexEnd() const
Return one past the maximum frame object index.
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
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.
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool getHasStackArgs() 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 MachineBasicBlock & front() const
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
unsigned getCalleeSavedFrameSize() const
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...
bool getHasSpills() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
Calling convention used for AVR signal routines.
MachineOperand class - Representation of each machine instruction operand.
Information about stack frame layout on the target.
void setCalleeSavedFrameSize(unsigned Bytes)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
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
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
A specific AVR target MCU.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
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...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
void setReg(unsigned Reg)
Change the register this operand corresponds to.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI) const override
restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee saved registers and returns...
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...
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...
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.
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
const MachineOperand & getOperand(unsigned i) const
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
FunctionPass * createAVRDynAllocaSRPass()
createAVRDynAllocaSRPass - returns an instance of the dynalloca stack pointer save/restore pass...
bool getHasAllocas() const
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.