66 bool HasFP =
hasFP(MF);
111 (
MBBI->getOpcode() == AVR::PUSHRr ||
MBBI->getOpcode() == AVR::PUSHWRr)) {
122 MBBJ.addLiveIn(AVR::R29R28);
130 unsigned Opcode = (
isUInt<6>(FrameSize) && STI.hasADDSUBIW()) ? AVR::SBIWRdK
138 MI->getOperand(3).setIsDead();
182 "Can only insert epilog into returning blocks");
199 int Opc = PI->getOpcode();
201 if (
Opc != AVR::POPRd &&
Opc != AVR::POPWRd && !PI->isTerminator()) {
285 unsigned CalleeFrameSize = 0;
294 bool IsNotLiveIn = !
MBB.isLiveIn(Reg);
299 for (
const auto &LiveIn :
MBB.liveins())
306 assert(
TRI->getRegSizeInBits(*
TRI->getMinimalPhysRegClass(Reg)) == 8 &&
307 "Invalid register size");
343 assert(
TRI->getRegSizeInBits(*
TRI->getMinimalPhysRegClass(Reg)) == 8 &&
344 "Invalid register size");
363 unsigned Opcode =
MI.getOpcode();
366 if (Opcode != AVR::STDSPQRr && Opcode != AVR::STDWSPQRr)
369 assert(
MI.getOperand(0).getReg() == AVR::SP &&
370 "SP is expected as base pointer");
375 (Opcode == AVR::STDWSPQRr) ? AVR::STDWPtrQRr : AVR::STDPtrQRr;
377 MI.setDesc(
TII.get(STOpc));
378 MI.getOperand(0).setReg(AVR::R31R30);
389 return MBB.erase(
MI);
393 unsigned int Opcode =
MI->getOpcode();
394 int Amount =
TII.getFrameSize(*
MI);
397 return MBB.erase(
MI);
402 if (Opcode ==
TII.getCallFrameSetupOpcode()) {
414 New->getOperand(3).setIsDead();
422 assert(Opcode ==
TII.getCallFrameDestroyOpcode());
439 return MBB.erase(
MI);
449 SavedRegs.
set(AVR::R29);
450 SavedRegs.
set(AVR::R28);
467 StringRef getPassName()
const override {
return "AVR Frame Analyzer"; }
469 void getAnalysisUsage(AnalysisUsage &AU)
const override {
477char AVRFrameAnalyzerLegacy::ID = 0;
481 return new AVRFrameAnalyzerLegacy();
512 int Opcode =
MI.getOpcode();
514 if ((Opcode != AVR::LDDRdPtrQ) && (Opcode != AVR::LDDWRdPtrQ) &&
515 (Opcode != AVR::STDPtrQRr) && (Opcode != AVR::STDWPtrQRr) &&
516 (Opcode != AVR::FRMIDX)) {
536bool AVRFrameAnalyzerLegacy::runOnMachineFunction(
MachineFunction &MF) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static bool runFrameAnalyzer(MachineFunction &MF)
const HexagonInstrInfo * TII
Register const TargetRegisterInfo * TRI
MachineRegisterInfo & MRI
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
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...
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
bool hasReservedCallFrame(const MachineFunction &MF) const override
hasReservedCallFrame - Under normal circumstances, when a frame pointer is not required,...
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...
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - When possible, it's best to simplify the call frame pseudo ops before d...
StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const override
getFrameIndexReference - This method should return the base register and offset used to reference a f...
bool hasFPImpl(const MachineFunction &MF) const override
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
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...
Utilities related to the AVR instruction set.
Contains AVR-specific information for each MachineFunction.
bool isInterruptHandler() const
bool getHasSpills() const
void setCalleeSavedFrameSize(unsigned Bytes)
unsigned getCalleeSavedFrameSize() const
bool getHasStackArgs() const
bool getHasAllocas() const
void setHasStackArgs(bool B)
void setHasAllocas(bool B)
bool isInterruptOrSignalHandler() const
Checks if the function is some form of interrupt service routine.
A specific AVR target MCU.
Register getTmpRegister() const
Register getZeroRegister() const
const AVRInstrInfo * getInstrInfo() const override
const AVRRegisterInfo * getRegisterInfo() const override
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
BitVector & set()
Set all bits in the bitvector.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
FunctionPass class - This class is used to implement most global optimizations.
Wrapper class representing physical registers. Should be passed by value.
MachineInstrBundleIterator< MachineInstr > iterator
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 ...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
int64_t getOffsetAdjustment() const
Return the correction for frame offsets.
unsigned getNumObjects() const
Return the number of objects.
bool isVariableSizedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a variable sized object.
int getObjectIndexEnd() const
Return one past the maximum frame object index.
uint8_t getStackID(int ObjectIdx) const
unsigned getNumFixedObjects() const
Return the number of fixed objects.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
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.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineInstrBuilder & setOperandDead(unsigned OpIdx) const
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
bool hasFP(const MachineFunction &MF) const
hasFP - Return true if the specified function should have a dedicated frame pointer register.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
TargetFrameLowering(StackDirection D, Align StackAl, int LAO, Align TransAl=Align(1), bool StackReal=true)
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual Register getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Pass manager infrastructure for declaring and invalidating analyses.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
static void fixStackStores(MachineBasicBlock &MBB, MachineBasicBlock::iterator StartMI, const TargetInstrInfo &TII)
Replace pseudo store instructions that pass arguments through the stack with real instructions.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
@ Kill
The last use of a register.
@ Define
Register definition.
constexpr RegState getKillRegState(bool B)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
auto reverse(ContainerTy &&C)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
static void restoreStatusRegister(MachineFunction &MF, MachineBasicBlock &MBB)
FunctionPass * createAVRFrameAnalyzerLegacyPass()
Creates instance of the frame analyzer pass.
This struct is a compact representation of a valid (non-zero power of two) alignment.