66 #define DEBUG_TYPE "arm-frame-lowering" 72 cl::desc(
"Align ARM NEON spills in prolog and epilog"));
76 unsigned NumAlignedDPRCS2Regs);
131 if (CFSize >= ((1 << 12) - 1) / 2)
157 if ((MI.
getOpcode() == ARM::LDR_POST_IMM ||
174 Pred, PredReg, TII, MIFlags);
177 Pred, PredReg, TII, MIFlags);
185 unsigned PredReg = 0) {
187 MIFlags, Pred, PredReg);
193 case ARM::VSTMDDB_UPD:
197 case ARM::t2STMDB_UPD:
201 case ARM::STR_PRE_IMM:
216 size_t StackSizeInBytes) {
224 return (StackSizeInBytes >= StackProbeSize) &&
230 struct StackAdjustingInsts {
240 bool BeforeFPSet =
false) {
241 InstInfo Info = {
I, SPAdjust, BeforeFPSet};
247 llvm::find_if(Insts, [&](InstInfo &Info) {
return Info.I ==
I; });
248 assert(Info != Insts.
end() &&
"invalid sp adjusting instruction");
249 Info->SPAdjust += ExtraBytes;
255 unsigned CFAOffset = 0;
256 for (
auto &Info : Insts) {
257 if (HasFP && !Info.BeforeFPSet)
260 CFAOffset -= Info.SPAdjust;
263 BuildMI(MBB, std::next(Info.I), dl,
264 TII.get(TargetOpcode::CFI_INSTRUCTION))
265 .addCFIIndex(CFIIndex)
285 const unsigned Alignment,
286 const bool MustBeSingleInstruction) {
290 const unsigned AlignMask = Alignment - 1;
308 }
else if (AlignMask <= 255) {
315 assert(!MustBeSingleInstruction &&
316 "Shouldn't call emitAligningInstructions demanding a single " 317 "instruction to be emitted for large stack alignment for a target " 365 "This emitPrologue does not support Thumb1!");
380 unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
381 int FramePtrSpillFI = 0;
389 StackAdjustingInsts DefCFAOffsetCandidates;
390 bool HasFP =
hasFP(MF);
393 if (ArgRegsSaveSize) {
394 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -ArgRegsSaveSize,
396 DefCFAOffsetCandidates.addInst(std::prev(MBBI), ArgRegsSaveSize,
true);
401 if (NumBytes - ArgRegsSaveSize != 0) {
402 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -(NumBytes - ArgRegsSaveSize),
404 DefCFAOffsetCandidates.addInst(std::prev(MBBI),
405 NumBytes - ArgRegsSaveSize,
true);
407 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
412 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
413 unsigned Reg = CSI[i].getReg();
414 int FI = CSI[i].getFrameIdx();
436 FramePtrSpillFI = FI;
450 if (GPRCS1Size > 0) {
451 GPRCS1Push = LastPush = MBBI++;
452 DefCFAOffsetCandidates.addInst(LastPush, GPRCS1Size,
true);
456 unsigned GPRCS1Offset = NumBytes - ArgRegsSaveSize - GPRCS1Size;
457 unsigned GPRCS2Offset = GPRCS1Offset - GPRCS2Size;
458 unsigned DPRAlign = DPRCSSize ? std::min(8U, Align) : 4U;
459 unsigned DPRGapSize = (GPRCS1Size + GPRCS2Size + ArgRegsSaveSize) % DPRAlign;
460 unsigned DPRCSOffset = GPRCS2Offset - DPRGapSize - DPRCSSize;
461 int FramePtrOffsetInPush = 0;
465 "Max FP estimation is wrong");
466 FramePtrOffsetInPush = FPOffset + ArgRegsSaveSize;
475 if (GPRCS2Size > 0) {
476 GPRCS2Push = LastPush = MBBI++;
477 DefCFAOffsetCandidates.addInst(LastPush, GPRCS2Size);
483 assert(DPRGapSize == 4 &&
"unexpected alignment requirements for DPRs");
484 if (LastPush != MBB.
end() &&
486 DefCFAOffsetCandidates.addExtraBytes(LastPush, DPRGapSize);
490 DefCFAOffsetCandidates.addInst(std::prev(MBBI), DPRGapSize);
498 while (MBBI != MBB.
end() && MBBI->getOpcode() == ARM::VSTMDDB_UPD) {
513 NumBytes = DPRCSOffset;
518 if (NumWords < 65536)
532 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBL))
534 .addExternalSymbol(
"__chkstk")
539 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVi32imm), ARM::R12)
540 .addExternalSymbol(
"__chkstk")
543 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBLXr))
551 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2SUBrr), ARM::SP)
564 DefCFAOffsetCandidates.addExtraBytes(LastPush, NumBytes);
568 DefCFAOffsetCandidates.addInst(std::prev(MBBI), NumBytes);
594 PushSize + FramePtrOffsetInPush,
596 if (FramePtrOffsetInPush + PushSize != 0) {
599 -(ArgRegsSaveSize - FramePtrOffsetInPush)));
600 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
601 .addCFIIndex(CFIIndex)
607 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
608 .addCFIIndex(CFIIndex)
616 if (GPRCS1Size > 0) {
619 for (
const auto &Entry : CSI) {
620 unsigned Reg = Entry.getReg();
621 int FI = Entry.getFrameIdx();
642 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
643 .addCFIIndex(CFIIndex)
650 if (GPRCS2Size > 0) {
652 for (
const auto &Entry : CSI) {
653 unsigned Reg = Entry.getReg();
654 int FI = Entry.getFrameIdx();
666 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
667 .addCFIIndex(CFIIndex)
679 for (
const auto &Entry : CSI) {
680 unsigned Reg = Entry.getReg();
681 int FI = Entry.getFrameIdx();
682 if ((Reg >= ARM::D0 && Reg <= ARM::D31) &&
688 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
689 .addCFIIndex(CFIIndex)
699 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
733 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
773 "This emitEpilogue does not support Thumb1!");
778 unsigned FramePtr = RegInfo->getFrameRegister(MF);
790 if (NumBytes - ArgRegsSaveSize != 0)
791 emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes - ArgRegsSaveSize);
794 const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
795 if (MBBI != MBB.
begin()) {
804 NumBytes -= (ArgRegsSaveSize +
827 "No scratch register to restore SP from FP!");
830 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
837 BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP)
842 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
846 }
else if (NumBytes &&
855 while (MBBI != MBB.
end() && MBBI->getOpcode() == ARM::VLDMDIA_UPD)
860 "unexpected DPR alignment gap");
869 emitSPUpdate(isARM, MBB, MBBI, dl, TII, ArgRegsSaveSize);
878 unsigned &FrameReg)
const {
884 int FI,
unsigned &FrameReg,
903 if (RegInfo->needsStackRealignment(MF)) {
904 assert(
hasFP(MF) &&
"dynamic stack realignment without a FP!");
908 }
else if (hasMovingSP) {
910 "VLAs and dynamic stack alignment, but missing base pointer!");
923 }
else if (hasMovingSP) {
929 if (FPOffset >= -255 && FPOffset < 0) {
940 if (Offset >= 0 && (Offset & 3) == 0 && Offset <= 1020)
948 }
else if (Offset > (FPOffset < 0 ? -FPOffset : FPOffset)) {
962 const std::vector<CalleeSavedInfo> &CSI,
963 unsigned StmOpc,
unsigned StrOpc,
965 bool(*Func)(
unsigned,
bool),
966 unsigned NumAlignedDPRCS2Regs,
967 unsigned MIFlags)
const {
974 using RegAndKill = std::pair<unsigned, bool>;
977 unsigned i = CSI.size();
979 unsigned LastReg = 0;
980 for (; i != 0; --i) {
981 unsigned Reg = CSI[i-1].getReg();
985 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
995 if (NoGap && LastReg && LastReg != Reg-1)
1003 Regs.
push_back(std::make_pair(Reg, !isLiveIn));
1010 const RegAndKill &RHS) {
1014 if (Regs.
size() > 1 || StrOpc== 0) {
1019 for (
unsigned i = 0, e = Regs.
size(); i < e; ++i)
1021 }
else if (Regs.
size() == 1) {
1022 BuildMI(MBB, MI, DL, TII.
get(StrOpc), ARM::SP)
1034 if (MI != MBB.
begin())
1041 std::vector<CalleeSavedInfo> &CSI,
1042 unsigned LdmOpc,
unsigned LdrOpc,
1043 bool isVarArg,
bool NoGap,
1044 bool(*Func)(
unsigned,
bool),
1045 unsigned NumAlignedDPRCS2Regs)
const {
1051 bool isTailCall =
false;
1052 bool isInterrupt =
false;
1053 bool isTrap =
false;
1054 if (MBB.
end() !=
MI) {
1055 DL = MI->getDebugLoc();
1056 unsigned RetOpcode = MI->getOpcode();
1057 isTailCall = (RetOpcode == ARM::TCRETURNdi || RetOpcode == ARM::TCRETURNri);
1059 RetOpcode == ARM::SUBS_PC_LR || RetOpcode == ARM::t2SUBS_PC_LR;
1061 RetOpcode ==
ARM::TRAP || RetOpcode == ARM::TRAPNaCl ||
1062 RetOpcode == ARM::tTRAP;
1066 unsigned i = CSI.size();
1068 unsigned LastReg = 0;
1069 bool DeleteRet =
false;
1070 for (; i != 0; --i) {
1076 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1079 if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
1096 if (NoGap && LastReg && LastReg != Reg-1)
1110 if (Regs.
size() > 1 || LdrOpc == 0) {
1114 for (
unsigned i = 0, e = Regs.
size(); i < e; ++i)
1117 if (MI != MBB.
end()) {
1119 MI->eraseFromParent();
1123 }
else if (Regs.
size() == 1) {
1126 if (Regs[0] == ARM::PC)
1129 BuildMI(MBB, MI, DL, TII.
get(LdrOpc), Regs[0])
1134 if (LdrOpc == ARM::LDR_POST_REG || LdrOpc == ARM::LDR_POST_IMM) {
1145 if (MI != MBB.
end())
1155 unsigned NumAlignedDPRCS2Regs,
1156 const std::vector<CalleeSavedInfo> &CSI,
1167 for (
unsigned i = 0, e = CSI.size(); i != e; ++i) {
1168 unsigned DNum = CSI[i].getReg() - ARM::D8;
1169 if (DNum > NumAlignedDPRCS2Regs - 1)
1171 int FI = CSI[i].getFrameIdx();
1199 unsigned Opc = isThumb ? ARM::t2SUBri : ARM::SUBri;
1202 .
addImm(8 * NumAlignedDPRCS2Regs)
1218 Opc = isThumb ? ARM::tMOVr : ARM::MOVr;
1227 unsigned NextReg = ARM::D8;
1231 if (NumAlignedDPRCS2Regs >= 6) {
1233 &ARM::QQPRRegClass);
1242 NumAlignedDPRCS2Regs -= 4;
1247 unsigned R4BaseReg = NextReg;
1250 if (NumAlignedDPRCS2Regs >= 4) {
1252 &ARM::QQPRRegClass);
1261 NumAlignedDPRCS2Regs -= 4;
1265 if (NumAlignedDPRCS2Regs >= 2) {
1275 NumAlignedDPRCS2Regs -= 2;
1279 if (NumAlignedDPRCS2Regs) {
1285 .
addImm((NextReg - R4BaseReg) * 2)
1297 unsigned NumAlignedDPRCS2Regs) {
1302 assert(MI->mayStore() &&
"Expecting spill instruction");
1305 switch(NumAlignedDPRCS2Regs) {
1308 assert(MI->mayStore() &&
"Expecting spill instruction");
1312 assert(MI->mayStore() &&
"Expecting spill instruction");
1328 unsigned NumAlignedDPRCS2Regs,
1329 const std::vector<CalleeSavedInfo> &CSI,
1338 for (
unsigned i = 0, e = CSI.size(); i != e; ++i)
1339 if (CSI[i].
getReg() == ARM::D8) {
1340 D8SpillFI = CSI[i].getFrameIdx();
1352 unsigned Opc = isThumb ? ARM::t2ADDri : ARM::ADDri;
1354 .addFrameIndex(D8SpillFI)
1360 unsigned NextReg = ARM::D8;
1363 if (NumAlignedDPRCS2Regs >= 6) {
1365 &ARM::QQPRRegClass);
1366 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Qwb_fixed), NextReg)
1373 NumAlignedDPRCS2Regs -= 4;
1378 unsigned R4BaseReg = NextReg;
1381 if (NumAlignedDPRCS2Regs >= 4) {
1383 &ARM::QQPRRegClass);
1384 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Q), NextReg)
1390 NumAlignedDPRCS2Regs -= 4;
1394 if (NumAlignedDPRCS2Regs >= 2) {
1397 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1q64), SupReg)
1402 NumAlignedDPRCS2Regs -= 2;
1406 if (NumAlignedDPRCS2Regs)
1407 BuildMI(MBB, MI, DL, TII.
get(ARM::VLDRD), NextReg)
1409 .
addImm(2 * (NextReg - R4BaseReg))
1418 const std::vector<CalleeSavedInfo> &CSI,
1426 unsigned PushOpc = AFI->
isThumbFunction() ? ARM::t2STMDB_UPD : ARM::STMDB_UPD;
1428 ARM::t2STR_PRE : ARM::STR_PRE_IMM;
1429 unsigned FltOpc = ARM::VSTMDDB_UPD;
1441 if (NumAlignedDPRCS2Regs)
1449 std::vector<CalleeSavedInfo> &CSI,
1461 if (NumAlignedDPRCS2Regs)
1464 unsigned PopOpc = AFI->
isThumbFunction() ? ARM::t2LDMIA_UPD : ARM::LDMIA_UPD;
1465 unsigned LdrOpc = AFI->
isThumbFunction() ? ARM::t2LDR_POST :ARM::LDR_POST_IMM;
1466 unsigned FltOpc = ARM::VLDMDIA_UPD;
1468 NumAlignedDPRCS2Regs);
1469 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1471 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1480 unsigned FnSize = 0;
1481 for (
auto &MBB : MF) {
1482 for (
auto &MI : MBB)
1495 unsigned Limit = (1 << 12) - 1;
1496 for (
auto &MBB : MF) {
1497 for (
auto &MI : MBB) {
1498 for (
unsigned i = 0, e = MI.getNumOperands(); i != e; ++i) {
1499 if (!MI.getOperand(i).isFI())
1504 if (MI.getOpcode() == ARM::ADDri) {
1505 Limit = std::min(Limit, (1U << 8) - 1);
1513 Limit = std::min(Limit, (1U << 8) - 1);
1517 Limit = std::min(Limit, ((1U << 8) - 1) * 4);
1523 Limit = std::min(Limit, (1U << 8) - 1);
1555 if (!static_cast<const ARMSubtarget &>(MF.
getSubtarget()).hasNEON())
1563 if (!static_cast<const ARMBaseRegisterInfo *>(
1572 unsigned NumSpills = 0;
1573 for (; NumSpills < 8; ++NumSpills)
1574 if (!SavedRegs.
test(ARM::D8 + NumSpills))
1596 bool CanEliminateFrame =
true;
1597 bool CS1Spilled =
false;
1598 bool LRSpilled =
false;
1599 unsigned NumGPRSpills = 0;
1600 unsigned NumFPRSpills = 0;
1620 (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF)))
1631 SavedRegs.
set(ARM::LR);
1637 SavedRegs.
set(ARM::LR);
1645 if (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF) ||
1646 MFI.estimateStackSize(MF) > 508)
1660 for (
unsigned i = 0; CSRegs[i]; ++i) {
1661 unsigned Reg = CSRegs[i];
1662 bool Spilled =
false;
1663 if (SavedRegs.
test(Reg)) {
1665 CanEliminateFrame =
false;
1668 if (!ARM::GPRRegClass.
contains(Reg)) {
1670 if (ARM::SPRRegClass.
contains(Reg))
1672 else if (ARM::DPRRegClass.
contains(Reg))
1674 else if (ARM::QPRRegClass.
contains(Reg))
1695 case ARM::R0:
case ARM::R1:
1711 case ARM::R0:
case ARM::R1:
1725 bool ForceLRSpill =
false;
1731 if (FnSize >= (1 << 11)) {
1732 CanEliminateFrame =
false;
1733 ForceLRSpill =
true;
1751 unsigned EstimatedStackSize =
1752 MFI.estimateStackSize(MF) + 4 * (NumGPRSpills + NumFPRSpills);
1755 int MaxFixedOffset = 0;
1756 for (
int I = MFI.getObjectIndexBegin();
I < 0; ++
I) {
1757 int MaxObjectOffset = MFI.getObjectOffset(
I) + MFI.getObjectSize(
I);
1758 MaxFixedOffset =
std::max(MaxFixedOffset, MaxObjectOffset);
1761 bool HasFP =
hasFP(MF);
1764 EstimatedStackSize += 4;
1768 EstimatedStackSize += MaxFixedOffset;
1770 EstimatedStackSize += 16;
1774 bool BigFrameOffsets = EstimatedStackSize >= EstimatedRSStackSizeLimit ||
1775 MFI.hasVarSizedObjects() ||
1778 (HasFP && (MaxFixedOffset - MaxFPOffset) >= (int)EstimatedRSStackSizeLimit);
1779 if (BigFrameOffsets ||
1784 SavedRegs.
set(FramePtr);
1788 SavedRegs.
set(ARM::LR);
1791 auto LRPos =
llvm::find(UnspilledCS1GPRs, ARM::LR);
1792 if (LRPos != UnspilledCS1GPRs.
end())
1793 UnspilledCS1GPRs.
erase(LRPos);
1796 if (
FPPos != UnspilledCS1GPRs.
end())
1799 if (FramePtr == ARM::R7)
1805 bool ExtraCSSpill =
false;
1822 int EntryRegDeficit = 0;
1823 for (
unsigned Reg : {ARM::R0, ARM::R1,
ARM::R2, ARM::R3}) {
1828 <<
" is unused argument register, EntryRegDeficit = " 1829 << EntryRegDeficit <<
"\n");
1836 <<
" return regs used, ExitRegDeficit = " 1837 << ExitRegDeficit <<
"\n");
1839 int RegDeficit =
std::max(EntryRegDeficit, ExitRegDeficit);
1848 <<
" is saved low register, RegDeficit = " 1849 << RegDeficit <<
"\n");
1855 <<
" is non-saved low register, adding to AvailableRegs\n");
1861 if (SavedRegs.
test(ARM::R7)) {
1864 << RegDeficit <<
"\n");
1869 <<
"%r7 is non-saved low register, adding to AvailableRegs\n");
1874 for (
unsigned Reg : {ARM::R8, ARM::R9, ARM::R10, ARM::R11}) {
1878 <<
" is saved high register, RegDeficit = " 1879 << RegDeficit <<
"\n");
1886 if ((EntryRegDeficit > ExitRegDeficit) &&
1889 if (SavedRegs.
test(ARM::LR)) {
1892 << RegDeficit <<
"\n");
1895 LLVM_DEBUG(
dbgs() <<
"%lr is not saved, adding to AvailableRegs\n");
1904 LLVM_DEBUG(
dbgs() <<
"Final RegDeficit = " << RegDeficit <<
"\n");
1905 for (; RegDeficit > 0 && !AvailableRegs.
empty(); --RegDeficit) {
1908 <<
" to make up reg deficit\n");
1914 ExtraCSSpill =
true;
1919 LLVM_DEBUG(
dbgs() <<
"After adding spills, RegDeficit = " << RegDeficit
1925 if (!LRSpilled && CS1Spilled) {
1926 SavedRegs.
set(ARM::LR);
1929 LRPos =
llvm::find(UnspilledCS1GPRs, (
unsigned)ARM::LR);
1930 if (LRPos != UnspilledCS1GPRs.
end())
1931 UnspilledCS1GPRs.
erase(LRPos);
1933 ForceLRSpill =
false;
1935 ExtraCSSpill =
true;
1943 if (TargetAlign >= 8 && (NumGPRSpills & 1)) {
1944 if (CS1Spilled && !UnspilledCS1GPRs.
empty()) {
1945 for (
unsigned i = 0, e = UnspilledCS1GPRs.
size(); i != e; ++i) {
1946 unsigned Reg = UnspilledCS1GPRs[i];
1954 <<
" to make up alignment\n");
1956 ExtraCSSpill =
true;
1961 unsigned Reg = UnspilledCS2GPRs.
front();
1964 <<
" to make up alignment\n");
1966 ExtraCSSpill =
true;
1975 if (BigFrameOffsets && !ExtraCSSpill) {
1978 unsigned NumExtras = TargetAlign / 4;
1980 while (NumExtras && !UnspilledCS1GPRs.
empty()) {
1981 unsigned Reg = UnspilledCS1GPRs.
back();
1992 while (NumExtras && !UnspilledCS2GPRs.
empty()) {
1993 unsigned Reg = UnspilledCS2GPRs.
back();
2001 if (NumExtras == 0) {
2002 for (
unsigned Reg : Extras) {
2005 ExtraCSSpill =
true;
2011 assert(RS &&
"Register scavenging not provided");
2021 SavedRegs.
set(ARM::LR);
2037 unsigned Amount = TII.getFrameSize(Old);
2046 "This eliminateCallFramePseudoInstr does not support Thumb1!");
2056 if (Opc == ARM::ADJCALLSTACKDOWN || Opc == ARM::tADJCALLSTACKDOWN) {
2060 assert(Opc == ARM::ADJCALLSTACKUP || Opc == ARM::tADJCALLSTACKUP);
2066 return MBB.
erase(I);
2074 unsigned Shifted = 0;
2079 while (!(Value & 0xC0000000)) {
2084 bool Carry = (Value & 0x00FFFFFF);
2085 Value = ((Value & 0xFF000000) >> 24) + Carry;
2087 if (Value & 0x0000100)
2088 Value = Value & 0x000001FC;
2091 Value = Value >> (Shifted - 24);
2093 Value = Value << (24 - Shifted);
2159 unsigned ScratchReg0 =
ARM::R4;
2160 unsigned ScratchReg1 = ARM::R5;
2161 uint64_t AlignedStackSize;
2177 if (BeforePrologueRegion.
insert(PredBB).second)
2180 }
while (!WalkList.
empty());
2190 BeforePrologueRegion.
insert(
B);
2192 for (
const auto &LI : PrologueMBB.
liveins()) {
2194 PredBB->addLiveIn(LI);
2200 BeforePrologueRegion.
erase(
B);
2227 BuildMI(PrevStackMBB, DL, TII.get(ARM::tPUSH))
2229 .addReg(ScratchReg0)
2230 .addReg(ScratchReg1);
2232 BuildMI(PrevStackMBB, DL, TII.get(ARM::STMDB_UPD))
2244 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2245 .addCFIIndex(CFIIndex);
2248 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2249 .addCFIIndex(CFIIndex);
2252 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2253 .addCFIIndex(CFIIndex);
2257 BuildMI(McrMBB, DL, TII.get(ARM::tMOVr), ScratchReg1)
2260 }
else if (CompareStackPointer) {
2261 BuildMI(McrMBB, DL, TII.get(ARM::MOVr), ScratchReg1)
2268 if (!CompareStackPointer && Thumb) {
2269 BuildMI(McrMBB, DL, TII.get(ARM::tSUBi8), ScratchReg1)
2271 .addReg(ScratchReg1)
2272 .addImm(AlignedStackSize)
2274 }
else if (!CompareStackPointer) {
2275 BuildMI(McrMBB, DL, TII.get(ARM::SUBri), ScratchReg1)
2277 .
addImm(AlignedStackSize)
2290 BuildMI(GetMBB, DL, TII.get(ARM::tLDRpci), ScratchReg0)
2291 .addConstantPoolIndex(CPI)
2295 BuildMI(GetMBB, DL, TII.get(ARM::tLDRi), ScratchReg0)
2296 .addReg(ScratchReg0)
2302 BuildMI(McrMBB, DL, TII.get(ARM::MRC), ScratchReg0)
2316 BuildMI(GetMBB, DL, TII.get(ARM::LDRi12), ScratchReg0)
2317 .addReg(ScratchReg0)
2324 Opcode = Thumb ? ARM::tCMPr : ARM::CMPrr;
2325 BuildMI(GetMBB, DL, TII.get(Opcode))
2326 .addReg(ScratchReg0)
2331 Opcode = Thumb ? ARM::tBcc : ARM::Bcc;
2332 BuildMI(GetMBB, DL, TII.get(Opcode)).addMBB(PostStackMBB)
2344 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg0)
2346 .addImm(AlignedStackSize)
2349 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg0)
2350 .addImm(AlignedStackSize)
2357 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg1)
2362 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg1)
2370 BuildMI(AllocMBB, DL, TII.get(ARM::tPUSH))
2374 BuildMI(AllocMBB, DL, TII.get(ARM::STMDB_UPD))
2385 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2386 .addCFIIndex(CFIIndex);
2389 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2390 .addCFIIndex(CFIIndex);
2394 BuildMI(AllocMBB, DL, TII.get(ARM::tBL))
2396 .addExternalSymbol(
"__morestack");
2399 .addExternalSymbol(
"__morestack");
2405 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2407 .addReg(ScratchReg0);
2408 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVr), ARM::LR)
2409 .addReg(ScratchReg0)
2412 BuildMI(AllocMBB, DL, TII.get(ARM::t2LDR_POST))
2420 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2432 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2434 .addReg(ScratchReg0)
2435 .addReg(ScratchReg1);
2437 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2447 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2448 .addCFIIndex(CFIIndex);
2456 BuildMI(PostStackMBB, DL, TII.get(ARM::tPOP))
2458 .addReg(ScratchReg0)
2459 .addReg(ScratchReg1);
2461 BuildMI(PostStackMBB, DL, TII.get(ARM::LDMIA_UPD))
2471 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2472 .addCFIIndex(CFIIndex);
2478 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2479 .addCFIIndex(CFIIndex);
2482 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2483 .addCFIIndex(CFIIndex);
2486 PostStackMBB->addSuccessor(&PrologueMBB);
2497 #ifdef EXPENSIVE_CHECKS bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void push_back(const T &Elt)
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
static ARMConstantPoolSymbol * Create(LLVMContext &C, StringRef s, unsigned ID, unsigned char PCAdj)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
ARMConstantPoolValue - ARM specific constantpool value.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
unsigned getReg() const
getReg - Returns the register number.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
void adjustForSegmentedStacks(MachineFunction &MF, MachineBasicBlock &MBB) const override
Adjust the prologue to have the function use segmented stacks.
bool test(unsigned Idx) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
unsigned const TargetRegisterInfo * TRI
MachineModuleInfo & getMMI() const
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...
bool isThumb1Only() const
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.
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)
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 ...
return AArch64::GPR64RegClass contains(Reg)
virtual void determineCalleeSaves(MachineFunction &MF, BitVector &SavedRegs, RegScavenger *RS=nullptr) const
This method determines which of the registers reported by TargetRegisterInfo::getCalleeSavedRegs() sh...
const ARMBaseInstrInfo * getInstrInfo() const override
static const uint64_t kSplitStackAvailable
unsigned getSpillAlignment(const TargetRegisterClass &RC) const
Return the minimum required alignment in bytes for a spill slot for a register of this class...
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...
bool isFrameAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
unsigned getFramePred(const MachineInstr &MI) const
Returns predicate register associated with the given frame instruction.
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
unsigned getNumOperands() const
Access to explicit operands of the instruction.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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.
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)
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
This file contains the simple types necessary to represent the attributes associated with functions a...
static int sizeOfSPAdjustment(const MachineInstr &MI)
virtual bool noFramePointerElim(const MachineFunction &MF) const
Return true if the target needs to disable frame pointer elimination.
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 ...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
void setDPRCalleeSavedAreaOffset(unsigned o)
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
bool enableCalleeSaveSkip(const MachineFunction &MF) const override
Returns true if the target can safely skip saving callee-saved registers for noreturn nounwind functi...
unsigned getArgRegsSaveSize() const
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 getDPRCalleeSavedAreaSize() const
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)...
void setDPRCalleeSavedGapSize(unsigned s)
void setShouldRestoreSPFromFP(bool s)
unsigned getNumAlignedDPRCS2Regs() const
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
const MCContext & getContext() const
int alignSPAdjust(int SPAdj) const
alignSPAdjust - This method aligns the stack adjustment to the correct alignment. ...
void setLRIsSpilledForFarJump(bool s)
bool isThumb2Function() const
virtual const TargetInstrInfo * getInstrInfo() const
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 shouldRestoreSPFromFP() const
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
unsigned getKillRegState(bool B)
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)
int ResolveFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg, int SPAdj) const
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.
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...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool cannotEliminateFrame(const MachineFunction &MF) const
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Returns the size of the specified MachineInstr.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
unsigned getGPRCalleeSavedArea1Size() const
int getStackProtectorIndex() const
Return the index for the stack protector object.
unsigned getMaxAlignment() const
Return the alignment in bytes that this function must be aligned to, which is greater than the defaul...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
bool hasBasePointer(const MachineFunction &MF) const
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.
unsigned getReturnRegsCount() const
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()
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
const ARMFrameLowering * getFrameLowering() const override
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
bool isThumb1OnlyFunction() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this 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...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
unsigned getStackAlignment() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void sort(IteratorTy Start, IteratorTy End)
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.
int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const override
getFrameIndexReference - Provide a base+offset reference to an FI slot for debug info.
unsigned getDPRCalleeSavedGapSize() const
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)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
unsigned getAM2Opc(AddrOpc Opc, unsigned Imm12, ShiftOpc SO, unsigned IdxMode=0)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool isTargetLinux() 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...
static bool isARMArea2Register(unsigned Reg, bool isIOS)
bool isTargetAndroid() const
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()
unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
void setOffsetAdjustment(int Adj)
Set the correction for frame offsets.
void sortUniqueLiveIns()
Sorts and uniques the LiveIns vector.
unsigned getBaseRegister() const
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
bool isPhysRegUsed(unsigned PhysReg) const
Return true if the specified register is modified or read in this function.
CodeModel::Model getCodeModel() const
Returns the code model.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
ARMFrameLowering(const ARMSubtarget &sti)
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
unsigned getReturnOpcode() const
Returns the correct return opcode for the current feature set.
unsigned getArgumentStackSize() const
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...
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 isLiveIn(unsigned Reg) const
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
void setHasStackFrame(bool s)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getGPRCalleeSavedArea2Size() const
void setGPRCalleeSavedArea1Offset(unsigned o)
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.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
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...
LLVM_NODISCARD bool empty() 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...
StringRef getValueAsString() const
Return the attribute's value as a string.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
bool isReturnAddressTaken() const
This method may be called any time after instruction selection is complete to determine if there is a...
const ARMBaseRegisterInfo * getRegisterInfo() const override
virtual const TargetFrameLowering * getFrameLowering() const
void setDPRCalleeSavedAreaSize(unsigned s)
bool hasStackFrame() const
int getOffsetAdjustment() const
Return the correction for frame offsets.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
iterator_range< livein_iterator > liveins() const
static bool isARMArea3Register(unsigned Reg, bool isIOS)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void insert(iterator MBBI, MachineBasicBlock *MBB)
static bool WindowsRequiresStackProbe(const MachineFunction &MF, size_t StackSizeInBytes)
const MCRegisterInfo * getRegisterInfo() 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...
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 getFramePtrSpillOffset() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
static const unsigned FramePtr
bool isTargetWindows() const
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static bool isCSRestore(MachineInstr &MI, const ARMBaseInstrInfo &TII, const MCPhysReg *CSRegs)
BitVector getPristineRegs(const MachineFunction &MF) const
Return a set of physical registers that are pristine.
static void checkNumAlignedDPRCS2Regs(MachineFunction &MF, BitVector &SavedRegs)
const MachineOperand & getOperand(unsigned i) const
bool hasTailCall() const
Returns true if the function contains a tail call.
void setObjectAlignment(int ObjectIdx, unsigned Align)
setObjectAlignment - Change the alignment of the specified stack object.
bool isThumbFunction() const
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
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)
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
This class contains meta information specific to a module.