63 #define DEBUG_TYPE "arm-frame-lowering"
69 cl::desc(
"Align ARM NEON spills in prolog and epilog"));
73 unsigned NumAlignedDPRCS2Regs);
116 if (CFSize >= ((1 << 12) - 1) / 2)
142 if ((MI.
getOpcode() == ARM::LDR_POST_IMM ||
159 Pred, PredReg, TII, MIFlags);
162 Pred, PredReg, TII, MIFlags);
170 unsigned PredReg = 0) {
172 MIFlags, Pred, PredReg);
178 case ARM::VSTMDDB_UPD:
182 case ARM::t2STMDB_UPD:
186 case ARM::STR_PRE_IMM:
201 size_t StackSizeInBytes) {
209 return StackSizeInBytes >= StackProbeSize;
214 struct StackAdjustingInsts {
224 bool BeforeFPSet =
false) {
225 InstInfo Info = {
I, SPAdjust, BeforeFPSet};
226 Insts.push_back(Info);
231 llvm::find_if(Insts, [&](InstInfo &Info) {
return Info.I ==
I; });
232 assert(Info != Insts.end() &&
"invalid sp adjusting instruction");
233 Info->SPAdjust += ExtraBytes;
239 unsigned CFAOffset = 0;
240 for (
auto &Info : Insts) {
241 if (HasFP && !Info.BeforeFPSet)
244 CFAOffset -= Info.SPAdjust;
247 BuildMI(MBB, std::next(Info.I), dl,
248 TII.get(TargetOpcode::CFI_INSTRUCTION))
249 .addCFIIndex(CFIIndex)
269 const unsigned Alignment,
270 const bool MustBeSingleInstruction) {
274 const unsigned AlignMask = Alignment - 1;
292 }
else if (AlignMask <= 255) {
299 assert(!MustBeSingleInstruction &&
300 "Shouldn't call emitAligningInstructions demanding a single "
301 "instruction to be emitted for large stack alignment for a target "
349 "This emitPrologue does not support Thumb1!");
364 unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
365 int FramePtrSpillFI = 0;
373 StackAdjustingInsts DefCFAOffsetCandidates;
374 bool HasFP =
hasFP(MF);
377 if (ArgRegsSaveSize) {
378 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -ArgRegsSaveSize,
380 DefCFAOffsetCandidates.addInst(std::prev(MBBI), ArgRegsSaveSize,
true);
385 if (NumBytes - ArgRegsSaveSize != 0) {
386 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -(NumBytes - ArgRegsSaveSize),
388 DefCFAOffsetCandidates.addInst(std::prev(MBBI),
389 NumBytes - ArgRegsSaveSize,
true);
391 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
396 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
397 unsigned Reg = CSI[i].getReg();
398 int FI = CSI[i].getFrameIdx();
420 FramePtrSpillFI = FI;
434 if (GPRCS1Size > 0) {
435 GPRCS1Push = LastPush = MBBI++;
436 DefCFAOffsetCandidates.addInst(LastPush, GPRCS1Size,
true);
440 unsigned GPRCS1Offset = NumBytes - ArgRegsSaveSize - GPRCS1Size;
441 unsigned GPRCS2Offset = GPRCS1Offset - GPRCS2Size;
442 unsigned DPRAlign = DPRCSSize ?
std::min(8U, Align) : 4U;
443 unsigned DPRGapSize = (GPRCS1Size + GPRCS2Size + ArgRegsSaveSize) % DPRAlign;
444 unsigned DPRCSOffset = GPRCS2Offset - DPRGapSize - DPRCSSize;
445 int FramePtrOffsetInPush = 0;
449 "Max FP estimation is wrong");
450 FramePtrOffsetInPush = FPOffset + ArgRegsSaveSize;
459 if (GPRCS2Size > 0) {
460 GPRCS2Push = LastPush = MBBI++;
461 DefCFAOffsetCandidates.addInst(LastPush, GPRCS2Size);
467 assert(DPRGapSize == 4 &&
"unexpected alignment requirements for DPRs");
468 if (LastPush != MBB.
end() &&
470 DefCFAOffsetCandidates.addExtraBytes(LastPush, DPRGapSize);
474 DefCFAOffsetCandidates.addInst(std::prev(MBBI), DPRGapSize);
482 while (MBBI->getOpcode() == ARM::VSTMDDB_UPD) {
497 NumBytes = DPRCSOffset;
502 if (NumWords < 65536)
517 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBL))
519 .addExternalSymbol(
"__chkstk")
525 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVi32imm), ARM::R12)
526 .addExternalSymbol(
"__chkstk")
529 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBLXr))
537 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2SUBrr), ARM::SP)
550 DefCFAOffsetCandidates.addExtraBytes(LastPush, NumBytes);
554 DefCFAOffsetCandidates.addInst(std::prev(MBBI), NumBytes);
580 PushSize + FramePtrOffsetInPush,
582 if (FramePtrOffsetInPush + PushSize != 0) {
585 -(ArgRegsSaveSize - FramePtrOffsetInPush)));
586 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
587 .addCFIIndex(CFIIndex)
593 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
594 .addCFIIndex(CFIIndex)
602 if (GPRCS1Size > 0) {
605 for (
const auto &Entry : CSI) {
606 unsigned Reg = Entry.getReg();
607 int FI = Entry.getFrameIdx();
628 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
629 .addCFIIndex(CFIIndex)
636 if (GPRCS2Size > 0) {
638 for (
const auto &Entry : CSI) {
639 unsigned Reg = Entry.getReg();
640 int FI = Entry.getFrameIdx();
652 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
653 .addCFIIndex(CFIIndex)
665 for (
const auto &Entry : CSI) {
666 unsigned Reg = Entry.getReg();
667 int FI = Entry.getFrameIdx();
668 if ((Reg >= ARM::D0 && Reg <= ARM::D31) &&
674 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
675 .addCFIIndex(CFIIndex)
685 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
719 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
759 "This emitEpilogue does not support Thumb1!");
764 unsigned FramePtr = RegInfo->getFrameRegister(MF);
776 if (NumBytes - ArgRegsSaveSize != 0)
777 emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes - ArgRegsSaveSize);
780 const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
781 if (MBBI != MBB.
begin()) {
790 NumBytes -= (ArgRegsSaveSize +
813 "No scratch register to restore SP from FP!");
816 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
823 BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP)
828 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
832 }
else if (NumBytes &&
841 while (MBBI != MBB.
end() && MBBI->getOpcode() == ARM::VLDMDIA_UPD)
846 "unexpected DPR alignment gap");
855 emitSPUpdate(isARM, MBB, MBBI, dl, TII, ArgRegsSaveSize);
864 unsigned &FrameReg)
const {
870 int FI,
unsigned &FrameReg,
889 if (RegInfo->needsStackRealignment(MF)) {
890 assert(
hasFP(MF) &&
"dynamic stack realignment without a FP!");
894 }
else if (hasMovingSP) {
896 "VLAs and dynamic stack alignment, but missing base pointer!");
909 }
else if (hasMovingSP) {
915 if (FPOffset >= -255 && FPOffset < 0) {
924 if (Offset >= 0 && (Offset & 3) == 0 && Offset <= 1020)
928 if (FPOffset >= -255 && FPOffset < 0) {
932 }
else if (Offset > (FPOffset < 0 ? -FPOffset : FPOffset)) {
946 const std::vector<CalleeSavedInfo> &CSI,
947 unsigned StmOpc,
unsigned StrOpc,
949 bool(*Func)(
unsigned,
bool),
950 unsigned NumAlignedDPRCS2Regs,
951 unsigned MIFlags)
const {
958 typedef std::pair<unsigned, bool> RegAndKill;
960 unsigned i = CSI.size();
962 unsigned LastReg = 0;
963 for (; i != 0; --i) {
964 unsigned Reg = CSI[i-1].getReg();
968 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
978 if (NoGap && LastReg && LastReg != Reg-1)
986 Regs.
push_back(std::make_pair(Reg, !isLiveIn));
993 const RegAndKill &RHS) {
997 if (Regs.
size() > 1 || StrOpc== 0) {
1002 for (
unsigned i = 0, e = Regs.
size(); i < e; ++i)
1004 }
else if (Regs.
size() == 1) {
1005 BuildMI(MBB, MI, DL, TII.
get(StrOpc), ARM::SP)
1017 if (MI != MBB.
begin())
1024 const std::vector<CalleeSavedInfo> &CSI,
1025 unsigned LdmOpc,
unsigned LdrOpc,
1026 bool isVarArg,
bool NoGap,
1027 bool(*Func)(
unsigned,
bool),
1028 unsigned NumAlignedDPRCS2Regs)
const {
1034 bool isTailCall =
false;
1035 bool isInterrupt =
false;
1036 bool isTrap =
false;
1037 if (MBB.
end() !=
MI) {
1038 DL = MI->getDebugLoc();
1039 unsigned RetOpcode = MI->getOpcode();
1040 isTailCall = (RetOpcode == ARM::TCRETURNdi || RetOpcode == ARM::TCRETURNri);
1042 RetOpcode == ARM::SUBS_PC_LR || RetOpcode == ARM::t2SUBS_PC_LR;
1044 RetOpcode ==
ARM::TRAP || RetOpcode == ARM::TRAPNaCl ||
1045 RetOpcode == ARM::tTRAP;
1049 unsigned i = CSI.size();
1051 unsigned LastReg = 0;
1052 bool DeleteRet =
false;
1053 for (; i != 0; --i) {
1054 unsigned Reg = CSI[i-1].getReg();
1058 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1061 if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
1075 if (NoGap && LastReg && LastReg != Reg-1)
1089 if (Regs.
size() > 1 || LdrOpc == 0) {
1093 for (
unsigned i = 0, e = Regs.
size(); i < e; ++i)
1095 if (DeleteRet && MI != MBB.
end()) {
1097 MI->eraseFromParent();
1100 }
else if (Regs.
size() == 1) {
1103 if (Regs[0] == ARM::PC)
1106 BuildMI(MBB, MI, DL, TII.
get(LdrOpc), Regs[0])
1111 if (LdrOpc == ARM::LDR_POST_REG || LdrOpc == ARM::LDR_POST_IMM) {
1122 if (MI != MBB.
end())
1132 unsigned NumAlignedDPRCS2Regs,
1133 const std::vector<CalleeSavedInfo> &CSI,
1144 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1145 unsigned DNum = CSI[i].getReg() - ARM::D8;
1146 if (DNum > NumAlignedDPRCS2Regs - 1)
1148 int FI = CSI[i].getFrameIdx();
1176 unsigned Opc = isThumb ? ARM::t2SUBri : ARM::SUBri;
1179 .
addImm(8 * NumAlignedDPRCS2Regs)
1195 Opc = isThumb ? ARM::tMOVr : ARM::MOVr;
1204 unsigned NextReg = ARM::D8;
1208 if (NumAlignedDPRCS2Regs >= 6) {
1210 &ARM::QQPRRegClass);
1219 NumAlignedDPRCS2Regs -= 4;
1224 unsigned R4BaseReg = NextReg;
1227 if (NumAlignedDPRCS2Regs >= 4) {
1229 &ARM::QQPRRegClass);
1238 NumAlignedDPRCS2Regs -= 4;
1242 if (NumAlignedDPRCS2Regs >= 2) {
1252 NumAlignedDPRCS2Regs -= 2;
1256 if (NumAlignedDPRCS2Regs) {
1262 .
addImm((NextReg - R4BaseReg) * 2)
1274 unsigned NumAlignedDPRCS2Regs) {
1279 assert(MI->mayStore() &&
"Expecting spill instruction");
1282 switch(NumAlignedDPRCS2Regs) {
1285 assert(MI->mayStore() &&
"Expecting spill instruction");
1288 assert(MI->mayStore() &&
"Expecting spill instruction");
1303 unsigned NumAlignedDPRCS2Regs,
1304 const std::vector<CalleeSavedInfo> &CSI,
1313 for (
unsigned i = 0, e = CSI.size(); i != e; ++i)
1314 if (CSI[i].
getReg() == ARM::D8) {
1315 D8SpillFI = CSI[i].getFrameIdx();
1327 unsigned Opc = isThumb ? ARM::t2ADDri : ARM::ADDri;
1329 .addFrameIndex(D8SpillFI)
1335 unsigned NextReg = ARM::D8;
1338 if (NumAlignedDPRCS2Regs >= 6) {
1340 &ARM::QQPRRegClass);
1341 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Qwb_fixed), NextReg)
1348 NumAlignedDPRCS2Regs -= 4;
1353 unsigned R4BaseReg = NextReg;
1356 if (NumAlignedDPRCS2Regs >= 4) {
1358 &ARM::QQPRRegClass);
1359 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Q), NextReg)
1365 NumAlignedDPRCS2Regs -= 4;
1369 if (NumAlignedDPRCS2Regs >= 2) {
1372 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1q64), SupReg)
1377 NumAlignedDPRCS2Regs -= 2;
1381 if (NumAlignedDPRCS2Regs)
1382 BuildMI(MBB, MI, DL, TII.
get(ARM::VLDRD), NextReg)
1384 .
addImm(2 * (NextReg - R4BaseReg))
1393 const std::vector<CalleeSavedInfo> &CSI,
1401 unsigned PushOpc = AFI->
isThumbFunction() ? ARM::t2STMDB_UPD : ARM::STMDB_UPD;
1403 ARM::t2STR_PRE : ARM::STR_PRE_IMM;
1404 unsigned FltOpc = ARM::VSTMDDB_UPD;
1416 if (NumAlignedDPRCS2Regs)
1424 const std::vector<CalleeSavedInfo> &CSI,
1436 if (NumAlignedDPRCS2Regs)
1439 unsigned PopOpc = AFI->
isThumbFunction() ? ARM::t2LDMIA_UPD : ARM::LDMIA_UPD;
1440 unsigned LdrOpc = AFI->
isThumbFunction() ? ARM::t2LDR_POST :ARM::LDR_POST_IMM;
1441 unsigned FltOpc = ARM::VLDMDIA_UPD;
1443 NumAlignedDPRCS2Regs);
1444 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1446 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1455 unsigned FnSize = 0;
1456 for (
auto &MBB : MF) {
1457 for (
auto &MI : MBB)
1470 unsigned Limit = (1 << 12) - 1;
1471 for (
auto &MBB : MF) {
1472 for (
auto &MI : MBB) {
1473 for (
unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
1474 if (!MI.getOperand(i).isFI())
1479 if (MI.getOpcode() == ARM::ADDri) {
1480 Limit =
std::min(Limit, (1U << 8) - 1);
1488 Limit =
std::min(Limit, (1U << 8) - 1);
1492 Limit =
std::min(Limit, ((1U << 8) - 1) * 4);
1498 Limit =
std::min(Limit, (1U << 8) - 1);
1531 if (!static_cast<const ARMSubtarget &>(MF.
getSubtarget()).hasNEON())
1539 if (!static_cast<const ARMBaseRegisterInfo *>(
1548 unsigned NumSpills = 0;
1549 for (; NumSpills < 8; ++NumSpills)
1550 if (!SavedRegs.
test(ARM::D8 + NumSpills))
1572 bool CanEliminateFrame =
true;
1573 bool CS1Spilled =
false;
1574 bool LRSpilled =
false;
1575 unsigned NumGPRSpills = 0;
1576 unsigned NumFPRSpills = 0;
1596 (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF)))
1602 SavedRegs.
set(ARM::LR);
1610 unsigned StackSize = MFI.estimateStackSize(MF);
1611 if (MFI.hasVarSizedObjects() || StackSize > 508)
1625 for (
unsigned i = 0; CSRegs[i]; ++i) {
1626 unsigned Reg = CSRegs[i];
1627 bool Spilled =
false;
1628 if (SavedRegs.
test(Reg)) {
1630 CanEliminateFrame =
false;
1633 if (!ARM::GPRRegClass.
contains(Reg)) {
1635 if (ARM::SPRRegClass.
contains(Reg))
1637 else if (ARM::DPRRegClass.
contains(Reg))
1639 else if (ARM::QPRRegClass.
contains(Reg))
1660 case ARM::R0:
case ARM::R1:
1676 case ARM::R0:
case ARM::R1:
1690 bool ForceLRSpill =
false;
1696 if (FnSize >= (1 << 11)) {
1697 CanEliminateFrame =
false;
1698 ForceLRSpill =
true;
1716 unsigned EstimatedStackSize =
1717 MFI.estimateStackSize(MF) + 4 * (NumGPRSpills + NumFPRSpills);
1720 int MaxFixedOffset = 0;
1721 for (
int I = MFI.getObjectIndexBegin(); I < 0; ++
I) {
1722 int MaxObjectOffset = MFI.getObjectOffset(I) + MFI.getObjectSize(I);
1723 MaxFixedOffset =
std::max(MaxFixedOffset, MaxObjectOffset);
1726 bool HasFP =
hasFP(MF);
1729 EstimatedStackSize += 4;
1733 EstimatedStackSize += MaxFixedOffset;
1735 EstimatedStackSize += 16;
1739 bool BigFrameOffsets = EstimatedStackSize >= EstimatedRSStackSizeLimit ||
1740 MFI.hasVarSizedObjects() ||
1743 (HasFP && (MaxFixedOffset - MaxFPOffset) >= (int)EstimatedRSStackSizeLimit);
1744 bool ExtraCSSpill =
false;
1745 if (BigFrameOffsets ||
1750 SavedRegs.
set(FramePtr);
1754 SavedRegs.
set(ARM::LR);
1757 auto LRPos =
llvm::find(UnspilledCS1GPRs, ARM::LR);
1758 if (LRPos != UnspilledCS1GPRs.
end())
1759 UnspilledCS1GPRs.
erase(LRPos);
1762 if (
FPPos != UnspilledCS1GPRs.
end())
1765 if (FramePtr == ARM::R7)
1784 int EntryRegDeficit = 0;
1785 for (
unsigned Reg : {ARM::R0, ARM::R1,
ARM::R2, ARM::R3}) {
1789 <<
" is unused argument register, EntryRegDeficit = "
1790 << EntryRegDeficit <<
"\n");
1797 <<
" return regs used, ExitRegDeficit = " << ExitRegDeficit
1800 int RegDeficit =
std::max(EntryRegDeficit, ExitRegDeficit);
1801 DEBUG(
dbgs() <<
"RegDeficit = " << RegDeficit <<
"\n");
1806 if (SavedRegs.
test(Reg)) {
1809 <<
" is saved low register, RegDeficit = " << RegDeficit
1815 <<
" is non-saved low register, adding to AvailableRegs\n");
1821 if (SavedRegs.
test(ARM::R7)) {
1823 DEBUG(
dbgs() <<
"%R7 is saved low register, RegDeficit = "
1824 << RegDeficit <<
"\n");
1828 <<
"%R7 is non-saved low register, adding to AvailableRegs\n");
1833 for (
unsigned Reg : {ARM::R8, ARM::R9, ARM::R10, ARM::R11}) {
1834 if (SavedRegs.
test(Reg)) {
1837 <<
" is saved high register, RegDeficit = " << RegDeficit
1845 if ((EntryRegDeficit > ExitRegDeficit) &&
1848 if (SavedRegs.
test(ARM::LR)) {
1850 DEBUG(
dbgs() <<
"%LR is saved register, RegDeficit = " << RegDeficit
1854 DEBUG(
dbgs() <<
"%LR is not saved, adding to AvailableRegs\n");
1863 DEBUG(
dbgs() <<
"Final RegDeficit = " << RegDeficit <<
"\n");
1864 for (; RegDeficit > 0 && !AvailableRegs.
empty(); --RegDeficit) {
1867 <<
" to make up reg deficit\n");
1871 ExtraCSSpill =
true;
1876 DEBUG(
dbgs() <<
"After adding spills, RegDeficit = " << RegDeficit <<
"\n");
1881 if (!LRSpilled && CS1Spilled) {
1882 SavedRegs.
set(ARM::LR);
1885 LRPos =
llvm::find(UnspilledCS1GPRs, (
unsigned)ARM::LR);
1886 if (LRPos != UnspilledCS1GPRs.
end())
1887 UnspilledCS1GPRs.
erase(LRPos);
1889 ForceLRSpill =
false;
1890 ExtraCSSpill =
true;
1896 DEBUG(
dbgs() <<
"NumGPRSpills = " << NumGPRSpills <<
"\n");
1898 if (TargetAlign >= 8 && (NumGPRSpills & 1)) {
1899 if (CS1Spilled && !UnspilledCS1GPRs.
empty()) {
1900 for (
unsigned i = 0, e = UnspilledCS1GPRs.
size(); i != e; ++i) {
1901 unsigned Reg = UnspilledCS1GPRs[i];
1909 <<
" to make up alignment\n");
1911 ExtraCSSpill =
true;
1916 unsigned Reg = UnspilledCS2GPRs.
front();
1919 <<
" to make up alignment\n");
1921 ExtraCSSpill =
true;
1930 if (BigFrameOffsets && !ExtraCSSpill) {
1933 unsigned NumExtras = TargetAlign / 4;
1935 while (NumExtras && !UnspilledCS1GPRs.
empty()) {
1936 unsigned Reg = UnspilledCS1GPRs.
back();
1947 while (NumExtras && !UnspilledCS2GPRs.
empty()) {
1948 unsigned Reg = UnspilledCS2GPRs.
back();
1956 if (Extras.
size() && NumExtras == 0) {
1957 for (
unsigned i = 0, e = Extras.
size(); i != e; ++i) {
1958 SavedRegs.
set(Extras[i]);
1963 assert(RS &&
"Register scavenging not provided");
1973 SavedRegs.
set(ARM::LR);
1989 unsigned Amount = TII.getFrameSize(Old);
1998 "This eliminateCallFramePseudoInstr does not support Thumb1!");
2008 if (Opc == ARM::ADJCALLSTACKDOWN || Opc == ARM::tADJCALLSTACKDOWN) {
2012 assert(Opc == ARM::ADJCALLSTACKUP || Opc == ARM::tADJCALLSTACKUP);
2018 return MBB.
erase(I);
2026 unsigned Shifted = 0;
2031 while (!(Value & 0xC0000000)) {
2036 bool Carry = (Value & 0x00FFFFFF);
2037 Value = ((Value & 0xFF000000) >> 24) + Carry;
2039 if (Value & 0x0000100)
2040 Value = Value & 0x000001FC;
2043 Value = Value >> (Shifted - 24);
2045 Value = Value << (24 - Shifted);
2109 unsigned ScratchReg0 =
ARM::R4;
2110 unsigned ScratchReg1 = ARM::R5;
2111 uint64_t AlignedStackSize;
2127 if (BeforePrologueRegion.
insert(PredBB).second)
2130 }
while (!WalkList.
empty());
2140 BeforePrologueRegion.
insert(
B);
2142 for (
const auto &LI : PrologueMBB.
liveins()) {
2144 PredBB->addLiveIn(LI);
2150 BeforePrologueRegion.
erase(
B);
2177 BuildMI(PrevStackMBB, DL, TII.get(ARM::tPUSH))
2179 .addReg(ScratchReg0)
2180 .addReg(ScratchReg1);
2182 BuildMI(PrevStackMBB, DL, TII.get(ARM::STMDB_UPD))
2194 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2195 .addCFIIndex(CFIIndex);
2198 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2199 .addCFIIndex(CFIIndex);
2202 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2203 .addCFIIndex(CFIIndex);
2207 BuildMI(McrMBB, DL, TII.get(ARM::tMOVr), ScratchReg1)
2210 }
else if (CompareStackPointer) {
2211 BuildMI(McrMBB, DL, TII.get(ARM::MOVr), ScratchReg1)
2218 if (!CompareStackPointer && Thumb) {
2219 BuildMI(McrMBB, DL, TII.get(ARM::tSUBi8), ScratchReg1)
2221 .addReg(ScratchReg1)
2222 .addImm(AlignedStackSize)
2224 }
else if (!CompareStackPointer) {
2225 BuildMI(McrMBB, DL, TII.get(ARM::SUBri), ScratchReg1)
2227 .
addImm(AlignedStackSize)
2240 BuildMI(GetMBB, DL, TII.get(ARM::tLDRpci), ScratchReg0)
2241 .addConstantPoolIndex(CPI)
2245 BuildMI(GetMBB, DL, TII.get(ARM::tLDRi), ScratchReg0)
2246 .addReg(ScratchReg0)
2252 BuildMI(McrMBB, DL, TII.get(ARM::MRC), ScratchReg0)
2266 BuildMI(GetMBB, DL, TII.get(ARM::LDRi12), ScratchReg0)
2267 .addReg(ScratchReg0)
2274 Opcode = Thumb ? ARM::tCMPr : ARM::CMPrr;
2275 BuildMI(GetMBB, DL, TII.get(Opcode))
2276 .addReg(ScratchReg0)
2281 Opcode = Thumb ? ARM::tBcc : ARM::Bcc;
2282 BuildMI(GetMBB, DL, TII.get(Opcode)).addMBB(PostStackMBB)
2294 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg0)
2296 .addImm(AlignedStackSize)
2299 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg0)
2300 .addImm(AlignedStackSize)
2307 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg1)
2312 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg1)
2320 BuildMI(AllocMBB, DL, TII.get(ARM::tPUSH))
2324 BuildMI(AllocMBB, DL, TII.get(ARM::STMDB_UPD))
2335 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2336 .addCFIIndex(CFIIndex);
2339 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2340 .addCFIIndex(CFIIndex);
2344 BuildMI(AllocMBB, DL, TII.get(ARM::tBL))
2346 .addExternalSymbol(
"__morestack");
2348 BuildMI(AllocMBB, DL, TII.get(ARM::BL))
2349 .addExternalSymbol(
"__morestack");
2355 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2357 .addReg(ScratchReg0);
2358 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVr), ARM::LR)
2359 .addReg(ScratchReg0)
2362 BuildMI(AllocMBB, DL, TII.get(ARM::t2LDR_POST))
2370 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2382 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2384 .addReg(ScratchReg0)
2385 .addReg(ScratchReg1);
2387 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2397 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2398 .addCFIIndex(CFIIndex);
2401 Opcode = Thumb ? ARM::tBX_RET : ARM::BX_RET;
2407 BuildMI(PostStackMBB, DL, TII.get(ARM::tPOP))
2409 .addReg(ScratchReg0)
2410 .addReg(ScratchReg1);
2412 BuildMI(PostStackMBB, DL, TII.get(ARM::LDMIA_UPD))
2422 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2423 .addCFIIndex(CFIIndex);
2429 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2430 .addCFIIndex(CFIIndex);
2433 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2434 .addCFIIndex(CFIIndex);
2448 #ifdef EXPENSIVE_CHECKS
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
void emitPrologue(MachineFunction &MF, MachineBasicBlock &MBB) const override
emitProlog/emitEpilog - These methods insert prolog and epilog code into the function.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
bool verify(Pass *p=nullptr, const char *Banner=nullptr, bool AbortOnError=true) const
Run the current MachineFunction through the machine code verifier, useful for debugger use...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
iterator_range< livein_iterator > liveins() const
static ARMConstantPoolSymbol * Create(LLVMContext &C, StringRef s, unsigned ID, unsigned char PCAdj)
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
static unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
static cl::opt< bool > SpillAlignedNEONRegs("align-neon-spills", cl::Hidden, cl::init(true), cl::desc("Align ARM NEON spills in prolog and epilog"))
bool hasFP(const MachineFunction &MF) const override
hasFP - Return true if the specified function should have a dedicated frame pointer register...
ARMConstantPoolValue - ARM specific constantpool value.
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.
unsigned getBaseRegister() const
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
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
bool isThumbFunction() const
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
bool tryFoldSPUpdateIntoPushPop(const ARMSubtarget &Subtarget, MachineFunction &MF, MachineInstr *MI, unsigned NumBytes)
Tries to add registers to the reglist of a given base-updating push/pop instruction to adjust the sta...
void setGPRCalleeSavedArea2Offset(unsigned o)
static uint32_t alignToARMConstant(uint32_t Value)
Get the minimum constant for ARM that is greater than or equal to the argument.
bool isThumb1Only() const
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
unsigned createPICLabelUId()
static bool isThumb(const MCSubtargetInfo &STI)
return AArch64::GPR64RegClass contains(Reg)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned getDPRCalleeSavedAreaSize() const
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
const ARMBaseInstrInfo * getInstrInfo() const override
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
static const uint64_t kSplitStackAvailable
void ReplaceUsesOfBlockWith(MachineBasicBlock *Old, MachineBasicBlock *New)
Given a machine basic block that branched to 'Old', change the code and CFG so that it branches to 'N...
const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const override
Code Generation virtual methods...
unsigned getNumAlignedDPRCS2Regs() 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.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
const HexagonInstrInfo * TII
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
unsigned getFrameRegister(const MachineFunction &MF) const override
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 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...
void emitT2RegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
unsigned getArgRegsSaveSize() const
Reg
All possible values of the reg field in the ModR/M byte.
This file contains the simple types necessary to represent the attributes associated with functions a...
static int sizeOfSPAdjustment(const MachineInstr &MI)
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.
void setDPRCalleeSavedAreaOffset(unsigned o)
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
void setFramePtrSpillOffset(unsigned o)
Context object for machine code objects.
static void emitRegPlusImmediate(bool isARM, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, const ARMBaseInstrInfo &TII, unsigned DestReg, unsigned SrcReg, int NumBytes, unsigned MIFlags=MachineInstr::NoFlags, ARMCC::CondCodes Pred=ARMCC::AL, unsigned PredReg=0)
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
unsigned getArgumentStackSize() const
bool isLiveIn(unsigned Reg) const
void setDPRCalleeSavedGapSize(unsigned s)
int getOffsetAdjustment() const
Return the correction for frame offsets.
void setShouldRestoreSPFromFP(bool s)
unsigned getReturnRegsCount() const
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
void setLRIsSpilledForFarJump(bool s)
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
static bool isARMArea1Register(unsigned Reg, bool isIOS)
isARMArea1Register - Returns true if the register is a low register (r0-r7) or a stack/pc register th...
bool isThumb1OnlyFunction() const
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
unsigned getKillRegState(bool B)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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.
static MachineBasicBlock::iterator skipAlignedDPRCS2Spills(MachineBasicBlock::iterator MI, unsigned NumAlignedDPRCS2Regs)
Skip past the code inserted by emitAlignedDPRCS2Spills, and return an iterator to the following instr...
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
static bool isCalleeSavedRegister(unsigned Reg, const MCPhysReg *CSRegs)
initializer< Ty > init(const Ty &Val)
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
This file declares the machine register scavenger class.
static unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, unsigned IdxMode=0)
bool hasStackFrame() const
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...
CodeModel::Model getCodeModel() const
Returns the code model.
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
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()
const MachineOperand & getOperand(unsigned i) const
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Returns the size of the specified MachineInstr.
bool splitFramePushPop(const MachineFunction &MF) const
Returns true if the frame setup is split into two separate pushes (first r0-r7,lr then r8-r11)...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
unsigned getFramePtrSpillOffset() const
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment. ...
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setGPRCalleeSavedArea2Size(unsigned s)
static int getMaxFPOffset(const Function &F, const ARMFunctionInfo &AFI)
We need the offset of the frame pointer relative to other MachineFrameInfo offsets which are encoded ...
TRAP - Trapping instruction.
static void emitAlignedDPRCS2Restores(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned NumAlignedDPRCS2Regs, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI)
Emit aligned reload instructions for NumAlignedDPRCS2Regs D-registers starting from d8...
self_iterator getIterator()
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const override
iterator_range< pred_iterator > predecessors()
const ARMFrameLowering * getFrameLowering() const override
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS) const override
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
void emitARMRegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of instructions to materializea des...
iterator erase(const_iterator CI)
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...
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...
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
virtual const TargetFrameLowering * getFrameLowering() const
virtual bool noFramePointerElim(const MachineFunction &MF) const
Return true if the target needs to disable frame pointer elimination.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
static void emitAlignedDPRCS2Spills(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned NumAlignedDPRCS2Regs, const std::vector< CalleeSavedInfo > &CSI, const TargetRegisterInfo *TRI)
Emit aligned spill instructions for NumAlignedDPRCS2Regs D-registers starting from d8...
void setGPRCalleeSavedArea1Size(unsigned s)
auto find(R &&Range, const T &Val) -> decltype(std::begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
const MCContext & getContext() const
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool test(unsigned Idx) const
static bool isARMArea2Register(unsigned Reg, bool isIOS)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
Information about stack frame layout on the target.
static void emitAligningInstructions(MachineFunction &MF, ARMFunctionInfo *AFI, const TargetInstrInfo &TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, const unsigned Reg, const unsigned Alignment, const bool MustBeSingleInstruction)
Emit an instruction sequence that will align the address in register Reg by zero-ing out the lower bi...
LLVM_NODISCARD T pop_back_val()
bool isTargetAndroid() const
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
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...
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
unsigned getFramePred(const MachineInstr &MI) const
Returns predicate register associated with the given frame instruction.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool hasBasePointer(const MachineFunction &MF) const
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
ARMFrameLowering(const ARMSubtarget &sti)
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
int getStackProtectorIndex() const
Return the index for the stack protector object.
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.
static unsigned estimateRSStackSizeLimit(MachineFunction &MF, const TargetFrameLowering *TFI)
estimateRSStackSizeLimit - Look at each instruction that references stack frames and return the stack...
const MCRegisterInfo * getRegisterInfo() const
bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override
canSimplifyCallFramePseudos - If there is a reserved call frame, the call frame pseudos can be simpli...
static bool isPopOpcode(int Opc)
bool noFramePointerElim(const MachineFunction &MF) const override
Return true if the target needs to disable frame pointer elimination.
static bool isARMLowRegister(unsigned Reg)
isARMLowRegister - Returns true if the register is a low register (r0-r7).
Representation of each machine instruction.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void setHasStackFrame(bool s)
void setGPRCalleeSavedArea1Offset(unsigned o)
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool isTargetLinux() const
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
const ARMBaseRegisterInfo * getRegisterInfo() const override
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned getDPRCalleeSavedGapSize() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
void setDPRCalleeSavedAreaSize(unsigned s)
bool hasVarSizedObjects() const
This method may be called any time after instruction selection is complete to determine if the stack ...
static bool isARMArea3Register(unsigned Reg, bool isIOS)
unsigned getReg() const
getReg - Returns the register number.
StringRef getValueAsString() const
Return the attribute's value as a string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
static bool WindowsRequiresStackProbe(const MachineFunction &MF, size_t StackSizeInBytes)
bool cannotEliminateFrame(const MachineFunction &MF) const
virtual const TargetInstrInfo * getInstrInfo() const
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
LLVM Value Representation.
static unsigned GetFunctionSizeInBytes(const MachineFunction &MF, const ARMBaseInstrInfo &TII)
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 getGPRCalleeSavedArea1Size() const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static const unsigned FramePtr
Primary interface to the complete machine description for the target machine.
bool addRegisterKilled(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
static bool isCSRestore(MachineInstr &MI, const ARMBaseInstrInfo &TII, const MCPhysReg *CSRegs)
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...
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
unsigned getGPRCalleeSavedArea2Size() 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 isThumb2Function() const
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
static void checkNumAlignedDPRCS2Regs(MachineFunction &MF, BitVector &SavedRegs)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
bool isTargetWindows() const
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
static void emitSPUpdate(bool isARM, MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, const ARMBaseInstrInfo &TII, int NumBytes, unsigned MIFlags=MachineInstr::NoFlags, ARMCC::CondCodes Pred=ARMCC::AL, unsigned PredReg=0)
This class contains meta information specific to a module.
bool shouldRestoreSPFromFP() const