134 using namespace llvm;
136 #define DEBUG_TYPE "frame-info"
139 cl::desc(
"enable use of redzone on AArch64"),
142 STATISTIC(NumRedZoneFunctions,
"Number of functions using red zone");
153 if (
MI.isDebugValue() ||
MI.isPseudo() ||
154 MI.getOpcode() == AArch64::ADDXri ||
155 MI.getOpcode() == AArch64::ADDSXri)
158 for (
unsigned i = 0, e =
MI.getNumOperands(); i != e; ++i) {
159 if (!
MI.getOperand(i).isFI())
216 unsigned Opc = I->getOpcode();
217 bool IsDestroy = Opc == TII->getCallFrameDestroyOpcode();
218 uint64_t CalleePopAmount = IsDestroy ? I->getOperand(1).getImm() : 0;
224 int64_t Amount = I->getOperand(0).getImm();
225 Amount =
alignTo(Amount, Align);
232 if (CalleePopAmount == 0) {
243 assert(Amount > -0xffffff && Amount < 0xffffff &&
"call frame too large");
246 }
else if (CalleePopAmount != 0) {
249 assert(CalleePopAmount < 0xffffff &&
"call frame too large");
250 emitFrameOffset(MBB, I, DL, AArch64::SP, AArch64::SP, -CalleePopAmount,
270 for (
const auto &Info : CSI) {
271 unsigned Reg = Info.getReg();
277 BuildMI(MBB, MBBI, DL, TII->
get(TargetOpcode::CFI_INSTRUCTION))
278 .addCFIIndex(CFIIndex)
298 if (&MF->
front() == MBB)
307 const MCPhysReg *CSRegs = TRI.getCalleeSavedRegs(MF);
308 for (
unsigned i = 0; CSRegs[i]; ++i)
309 LiveRegs.
addReg(CSRegs[i]);
313 if (LiveRegs.
available(MRI, AArch64::X9))
316 for (
unsigned Reg : AArch64::GPR64RegClass) {
320 return AArch64::NoRegister;
331 if (!RegInfo->needsStackRealignment(*MF))
338 bool AArch64FrameLowering::shouldCombineCSRLocalStackBump(
350 if (StackBumpBytes >= 512)
353 if (MFI.hasVarSizedObjects())
356 if (RegInfo->needsStackRealignment(MF))
375 bool NewIsUnscaled =
false;
376 switch (MBBI->getOpcode()) {
380 NewOpc = AArch64::STPXpre;
383 NewOpc = AArch64::STPDpre;
385 case AArch64::STRXui:
386 NewOpc = AArch64::STRXpre;
387 NewIsUnscaled =
true;
389 case AArch64::STRDui:
390 NewOpc = AArch64::STRDpre;
391 NewIsUnscaled =
true;
394 NewOpc = AArch64::LDPXpost;
397 NewOpc = AArch64::LDPDpost;
399 case AArch64::LDRXui:
400 NewOpc = AArch64::LDRXpost;
401 NewIsUnscaled =
true;
403 case AArch64::LDRDui:
404 NewOpc = AArch64::LDRDpost;
405 NewIsUnscaled =
true;
413 unsigned OpndIdx = 0;
414 for (
unsigned OpndEnd = MBBI->getNumOperands() - 1; OpndIdx < OpndEnd;
416 MIB.
add(MBBI->getOperand(OpndIdx));
418 assert(MBBI->getOperand(OpndIdx).getImm() == 0 &&
419 "Unexpected immediate offset in first/last callee-save save/restore "
421 assert(MBBI->getOperand(OpndIdx - 1).getReg() == AArch64::SP &&
422 "Unexpected base register in callee-save save/restore instruction!");
424 assert(CSStackSizeInc % 8 == 0);
425 int64_t CSStackSizeIncImm = CSStackSizeInc;
427 CSStackSizeIncImm /= 8;
428 MIB.
addImm(CSStackSizeIncImm);
431 MIB.
setMemRefs(MBBI->memoperands_begin(), MBBI->memoperands_end());
433 return std::prev(MBB.
erase(MBBI));
439 unsigned LocalStackSize) {
442 assert((Opc == AArch64::STPXi || Opc == AArch64::STPDi ||
443 Opc == AArch64::STRXui || Opc == AArch64::STRDui ||
444 Opc == AArch64::LDPXi || Opc == AArch64::LDPDi ||
445 Opc == AArch64::LDRXui || Opc == AArch64::LDRDui) &&
446 "Unexpected callee-save save/restore opcode!");
450 "Unexpected base register in callee-save save/restore instruction!");
454 assert(LocalStackSize % 8 == 0);
455 OffsetOpnd.setImm(OffsetOpnd.getImm() + LocalStackSize / 8);
469 bool HasFP =
hasFP(MF);
482 assert(!HasFP &&
"unexpected function without stack frame but with FP");
492 ++NumRedZoneFunctions;
494 emitFrameOffset(MBB, MBBI, DL, AArch64::SP, AArch64::SP, -NumBytes, TII,
502 BuildMI(MBB, MBBI, DL, TII->
get(TargetOpcode::CFI_INSTRUCTION))
503 .addCFIIndex(CFIIndex)
517 bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes);
519 emitFrameOffset(MBB, MBBI, DL, AArch64::SP, AArch64::SP, -NumBytes, TII,
522 }
else if (PrologueSaveSize != 0) {
525 NumBytes -= PrologueSaveSize;
527 assert(NumBytes >= 0 &&
"Negative stack allocation size!?");
549 emitFrameOffset(MBB, MBBI, DL, AArch64::FP, AArch64::SP, FPOffset, TII,
555 const bool NeedsRealignment = RegInfo->needsStackRealignment(MF);
556 unsigned scratchSPReg = AArch64::SP;
558 if (NeedsRealignment) {
560 assert(scratchSPReg != AArch64::NoRegister);
568 emitFrameOffset(MBB, MBBI, DL, scratchSPReg, AArch64::SP, -NumBytes, TII,
571 if (NeedsRealignment) {
575 assert(scratchSPReg != AArch64::SP);
585 | ((64 - NrBitsToZero) << 6)
586 | ((64 - NrBitsToZero - 1) << 0);
588 BuildMI(MBB, MBBI, DL, TII->
get(AArch64::ANDXri), AArch64::SP)
602 if (RegInfo->hasBasePointer(MF)) {
603 TII->
copyPhysReg(MBB, MBBI, DL, RegInfo->getBaseRegister(), AArch64::SP,
607 if (needsFrameMoves) {
610 unsigned FramePtr = RegInfo->getFrameRegister(MF);
679 unsigned Reg = RegInfo->getDwarfRegNum(FramePtr,
true);
681 nullptr, Reg, 2 * StackGrowth - FixedObject));
682 BuildMI(MBB, MBBI, DL, TII->
get(TargetOpcode::CFI_INSTRUCTION))
683 .addCFIIndex(CFIIndex)
689 BuildMI(MBB, MBBI, DL, TII->
get(TargetOpcode::CFI_INSTRUCTION))
690 .addCFIIndex(CFIIndex)
707 bool IsTailCallReturn =
false;
708 if (MBB.
end() != MBBI) {
709 DL = MBBI->getDebugLoc();
710 unsigned RetOpcode = MBBI->getOpcode();
711 IsTailCallReturn = RetOpcode == AArch64::TCRETURNdi ||
712 RetOpcode == AArch64::TCRETURNri;
724 uint64_t ArgumentPopSize = 0;
725 if (IsTailCallReturn) {
731 ArgumentPopSize = StackAdjust.
getImm();
772 bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes);
774 if (!CombineSPBump && PrologueSaveSize != 0)
781 while (LastPopI != Begin) {
786 }
else if (CombineSPBump)
793 NumBytes + ArgumentPopSize,
TII,
798 NumBytes -= PrologueSaveSize;
799 assert(NumBytes >= 0 &&
"Negative stack allocation size!?");
805 if (RedZone && ArgumentPopSize == 0)
808 bool NoCalleeSaveRestore = PrologueSaveSize == 0;
809 int StackRestoreBytes = RedZone ? 0 : NumBytes;
810 if (NoCalleeSaveRestore)
811 StackRestoreBytes += ArgumentPopSize;
816 if (NoCalleeSaveRestore || ArgumentPopSize == 0)
830 emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::SP, NumBytes, TII,
847 unsigned &FrameReg)
const {
852 int FI,
unsigned &FrameReg,
853 bool PreferFP)
const {
879 !RegInfo->needsStackRealignment(MF)) {
890 (FPOffset >= -256 && Offset > -FPOffset))
895 assert((isFixed || !RegInfo->needsStackRealignment(MF) || !UseFP) &&
896 "In the presence of dynamic stack pointer realignment, "
897 "non-argument objects cannot be accessed through the frame pointer");
908 FrameReg = AArch64::SP;
934 Attrs.hasAttrSomewhere(Attribute::SwiftError));
940 unsigned Reg1 = AArch64::NoRegister;
941 unsigned Reg2 = AArch64::NoRegister;
946 RegPairInfo() =
default;
948 bool isPaired()
const {
return Reg2 != AArch64::NoRegister; }
963 unsigned Count = CSI.size();
970 "Odd number of callee-saved regs to spill!");
973 for (
unsigned i = 0; i < Count; ++i) {
975 RPI.Reg1 = CSI[i].getReg();
978 AArch64::FPR64RegClass.contains(RPI.Reg1));
979 RPI.IsGPR = AArch64::GPR64RegClass.contains(RPI.Reg1);
983 unsigned NextReg = CSI[i + 1].getReg();
984 if ((RPI.IsGPR && AArch64::GPR64RegClass.contains(NextReg)) ||
985 (!RPI.IsGPR && AArch64::FPR64RegClass.contains(NextReg)))
995 assert((!RPI.isPaired() ||
996 (CSI[i].getFrameIdx() + 1 == CSI[i + 1].getFrameIdx())) &&
997 "Out of order callee saved regs!");
1004 ((RPI.Reg1 == AArch64::LR && RPI.Reg2 == AArch64::FP) ||
1005 RPI.Reg1 + 1 == RPI.Reg2))) &&
1006 "Callee-save registers not saved as adjacent register pair!");
1008 RPI.FrameIdx = CSI[i].getFrameIdx();
1014 assert(MFI.getObjectAlignment(RPI.FrameIdx) <= 16);
1015 MFI.setObjectAlignment(RPI.FrameIdx, 16);
1018 Offset -= RPI.isPaired() ? 16 : 8;
1020 RPI.Offset = Offset / 8;
1021 assert((RPI.Offset >= -64 && RPI.Offset <= 63) &&
1022 "Offset out of bounds for LDP/STP immediate");
1032 const std::vector<CalleeSavedInfo> &CSI,
1042 for (
auto RPII = RegPairs.
rbegin(), RPIE = RegPairs.
rend(); RPII != RPIE;
1044 RegPairInfo
RPI = *RPII;
1045 unsigned Reg1 = RPI.Reg1;
1046 unsigned Reg2 = RPI.Reg2;
1060 StrOpc = RPI.isPaired() ? AArch64::STPXi : AArch64::STRXui;
1062 StrOpc = RPI.isPaired() ? AArch64::STPDi : AArch64::STRDui;
1066 dbgs() <<
") -> fi#(" << RPI.FrameIdx;
1068 dbgs() <<
", " << RPI.FrameIdx+1;
1074 if (RPI.isPaired()) {
1083 .addReg(AArch64::SP)
1095 const std::vector<CalleeSavedInfo> &CSI,
1102 if (MI != MBB.
end())
1103 DL = MI->getDebugLoc();
1107 for (
auto RPII = RegPairs.
begin(), RPIE = RegPairs.
end(); RPII != RPIE;
1109 RegPairInfo
RPI = *RPII;
1110 unsigned Reg1 = RPI.Reg1;
1111 unsigned Reg2 = RPI.Reg2;
1123 LdrOpc = RPI.isPaired() ? AArch64::LDPXi : AArch64::LDRXui;
1125 LdrOpc = RPI.isPaired() ? AArch64::LDPDi : AArch64::LDRDui;
1129 dbgs() <<
") -> fi#(" << RPI.FrameIdx;
1131 dbgs() <<
", " << RPI.FrameIdx+1;
1135 if (RPI.isPaired()) {
1164 unsigned UnspilledCSGPR = AArch64::NoRegister;
1165 unsigned UnspilledCSGPRPaired = AArch64::NoRegister;
1169 SavedRegs.
set(AArch64::FP);
1170 SavedRegs.
set(AArch64::LR);
1173 unsigned BasePointerReg = AArch64::NoRegister;
1177 unsigned ExtraCSSpill = 0;
1180 for (
unsigned i = 0; CSRegs[i]; ++i) {
1181 const unsigned Reg = CSRegs[i];
1184 if (Reg == BasePointerReg)
1187 bool RegUsed = SavedRegs.
test(Reg);
1188 unsigned PairedReg = CSRegs[i ^ 1];
1190 if (AArch64::GPR64RegClass.
contains(Reg) &&
1192 UnspilledCSGPR =
Reg;
1193 UnspilledCSGPRPaired = PairedReg;
1202 SavedRegs.
set(PairedReg);
1203 if (AArch64::GPR64RegClass.
contains(PairedReg) &&
1205 ExtraCSSpill = PairedReg;
1209 DEBUG(
dbgs() <<
"*** determineCalleeSaves\nUsed CSRs:";
1215 unsigned NumRegsSpilled = SavedRegs.
count();
1216 bool CanEliminateFrame = NumRegsSpilled == 0;
1222 DEBUG(
dbgs() <<
"Estimated stack frame size: " << CFSize <<
" bytes.\n");
1224 bool BigStack = (CFSize > EstimatedStackSizeLimit);
1235 if (!ExtraCSSpill && UnspilledCSGPR != AArch64::NoRegister) {
1237 <<
" to get a scratch register.\n");
1238 SavedRegs.
set(UnspilledCSGPR);
1243 SavedRegs.
set(UnspilledCSGPRPaired);
1244 ExtraCSSpill = UnspilledCSGPRPaired;
1245 NumRegsSpilled = SavedRegs.
count();
1257 DEBUG(
dbgs() <<
"No available CS registers, allocated fi#" << FI
1258 <<
" as the emergency spill slot.\n");
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
A parsed version of the target data layout string in and methods for querying it. ...
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool cannotEliminateFrame(const MachineFunction &MF) const
STATISTIC(NumFunctions,"Total number of functions")
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
int resolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, bool PreferFP=false) const
iterator_range< const_set_bits_iterator > set_bits() const
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment for a spill slot for a register of this class.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
return AArch64::GPR64RegClass contains(Reg)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static unsigned findScratchNonCalleeSaveRegister(MachineBasicBlock *MBB)
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
bool supportSwiftError() const override
Return true if the target supports swifterror attribute.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
AttributeList getAttributes() const
Return the attribute list for this Function.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
unsigned getFrameRegister(const MachineFunction &MF) const override
static unsigned getPrologueDeath(MachineFunction &MF, unsigned Reg)
unsigned getBaseRegister() const
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.
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
const HexagonInstrInfo * TII
static MachineBasicBlock::iterator convertCalleeSaveRestoreToSPPrePostIncDec(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const TargetInstrInfo *TII, int CSStackSizeInc)
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.
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...
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
Reg
All possible values of the reg field in the ModR/M byte.
unsigned getArgumentStackToRestore() const
This file contains the simple types necessary to represent the attributes associated with functions a...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
bool hasDebugInfo() const
Returns true if valid debug info is present.
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool canUseAsPrologue(const MachineBasicBlock &MBB) const override
Check whether or not the given MBB can be used as a prologue for the target.
static unsigned estimateRSStackSizeLimit(MachineFunction &MF)
Look at each instruction that references stack frames and return the stack size limit beyond which so...
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
int isAArch64FrameOffsetLegal(const MachineInstr &MI, int &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
const MachineBasicBlock & front() const
bool isLiveIn(unsigned Reg) const
unsigned getCalleeSavedStackSize() const
const AArch64RegisterInfo * getRegisterInfo() const override
bool hasStackFrame() const
bool hasCalleeSaveStackFreeSpace() const
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
unsigned getLocalStackSize() const
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
virtual void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const
Emit instructions to copy a pair of physical registers.
unsigned getKillRegState(bool B)
unsigned estimateStackSize(const MachineFunction &MF) const
Estimate and return the size of the stack frame.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
const AArch64TargetLowering * getTargetLowering() const override
bool hasStackMap() const
This method may be called any time after instruction selection is complete to determine if there is a...
initializer< Ty > init(const Ty &Val)
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
size_type count() const
count - Returns the number of bits which are set.
This file declares the machine register scavenger class.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
unsigned const MachineRegisterInfo * MRI
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
void setLocalStackSize(unsigned Size)
bool isReservedReg(const MachineFunction &MF, unsigned Reg) const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
void addLiveIns(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB.
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE instructions.
const MachineOperand & getOperand(unsigned i) const
bool isTargetMachO() const
void setCalleeSaveStackHasFreeSpace(bool s)
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
static const unsigned End
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
bool isCallingConvWin64(CallingConv::ID CC) const
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
void setHasStackFrame(bool s)
static cl::opt< bool > EnableRedZone("aarch64-redzone", cl::desc("enable use of redzone on AArch64"), cl::init(false), cl::Hidden)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
virtual bool hasReservedCallFrame(const MachineFunction &MF) const
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.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
The memory access writes data.
bool hasCalls() const
Return true if the current function has any function calls.
virtual const TargetFrameLowering * getFrameLowering() const
static void computeCalleeSaveRegisterPairs(MachineFunction &MF, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI, SmallVectorImpl< RegPairInfo > &RegPairs)
const MCContext & getContext() const
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool test(unsigned Idx) const
int getOffsetOfLocalArea() const
getOffsetOfLocalArea - This method returns the offset of the local area from the stack pointer on ent...
void setStackRealigned(bool s)
Information about stack frame layout on the target.
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool enableStackSlotScavenging(const MachineFunction &MF) const override
Returns true if the stack slot holes in the fixed and callee-save stack area should be used when allo...
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Representation of each machine instruction.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
bool hasPatchPoint() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static void fixupCalleeSaveRestoreStackOffset(MachineInstr &MI, unsigned LocalStackSize)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getVarArgsGPRSize() const
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...
bool isStackRealigned() const
MachineBasicBlock::iterator eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const override
This method is called during prolog/epilog code insertion to eliminate call frame setup and destroy p...
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
static bool produceCompactUnwindFrame(MachineFunction &MF)
int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS, const AllocaInst *Alloca=nullptr)
Create a new statically sized stack object, returning a nonnegative identifier to represent it...
unsigned getReg() const
getReg - Returns the register number.
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool canUseRedZone(const MachineFunction &MF) const
Can this function use the red zone for local allocations.
virtual const TargetInstrInfo * getInstrInfo() const
const AArch64InstrInfo * getInstrInfo() const override
bool available(const MachineRegisterInfo &MRI, unsigned Reg) const
Returns true if register Reg and no aliasing register is in the set.
static const unsigned FramePtr
const char * getName(unsigned RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
MachineModuleInfo & getMMI() const
bool needsStackRealignment(const MachineFunction &MF) const
True if storage within the function requires the stack pointer to be aligned more than the normal cal...
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
bool hasBasePointer(const MachineFunction &MF) const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size FIXME: The defaults need to be removed once all of the backends/clients are updat...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
void emitCalleeSavedFrameMoves(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const
void setCalleeSavedStackSize(unsigned Size)
This class contains meta information specific to a module.
void addReg(unsigned Reg)
Adds a physical register and all its sub-registers to the set.