66 #define DEBUG_TYPE "arm-frame-lowering" 72 cl::desc(
"Align ARM NEON spills in prolog and epilog"));
76 unsigned NumAlignedDPRCS2Regs);
130 if (CFSize >= ((1 << 12) - 1) / 2)
156 if ((MI.
getOpcode() == ARM::LDR_POST_IMM ||
173 Pred, PredReg, TII, MIFlags);
176 Pred, PredReg, TII, MIFlags);
184 unsigned PredReg = 0) {
186 MIFlags, Pred, PredReg);
192 case ARM::VSTMDDB_UPD:
196 case ARM::t2STMDB_UPD:
200 case ARM::STR_PRE_IMM:
215 size_t StackSizeInBytes) {
223 return (StackSizeInBytes >= StackProbeSize) &&
229 struct StackAdjustingInsts {
239 bool BeforeFPSet =
false) {
240 InstInfo
Info = {
I, SPAdjust, BeforeFPSet};
247 assert(Info != Insts.
end() &&
"invalid sp adjusting instruction");
248 Info->SPAdjust += ExtraBytes;
254 unsigned CFAOffset = 0;
255 for (
auto &
Info : Insts) {
256 if (HasFP && !
Info.BeforeFPSet)
259 CFAOffset -=
Info.SPAdjust;
263 TII.get(TargetOpcode::CFI_INSTRUCTION))
264 .addCFIIndex(CFIIndex)
284 const unsigned Alignment,
285 const bool MustBeSingleInstruction) {
289 const unsigned AlignMask = Alignment - 1;
307 }
else if (AlignMask <= 255) {
314 assert(!MustBeSingleInstruction &&
315 "Shouldn't call emitAligningInstructions demanding a single " 316 "instruction to be emitted for large stack alignment for a target " 368 "This emitPrologue does not support Thumb1!");
383 unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
384 int FramePtrSpillFI = 0;
392 StackAdjustingInsts DefCFAOffsetCandidates;
393 bool HasFP =
hasFP(MF);
396 if (ArgRegsSaveSize) {
397 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -ArgRegsSaveSize,
399 DefCFAOffsetCandidates.addInst(std::prev(MBBI), ArgRegsSaveSize,
true);
404 if (NumBytes - ArgRegsSaveSize != 0) {
405 emitSPUpdate(isARM, MBB, MBBI, dl, TII, -(NumBytes - ArgRegsSaveSize),
407 DefCFAOffsetCandidates.addInst(std::prev(MBBI),
408 NumBytes - ArgRegsSaveSize,
true);
410 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
415 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
416 unsigned Reg = CSI[i].getReg();
417 int FI = CSI[i].getFrameIdx();
439 FramePtrSpillFI = FI;
453 if (GPRCS1Size > 0) {
454 GPRCS1Push = LastPush = MBBI++;
455 DefCFAOffsetCandidates.addInst(LastPush, GPRCS1Size,
true);
459 unsigned GPRCS1Offset = NumBytes - ArgRegsSaveSize - GPRCS1Size;
460 unsigned GPRCS2Offset = GPRCS1Offset - GPRCS2Size;
461 unsigned DPRAlign = DPRCSSize ? std::min(8U, Align) : 4U;
462 unsigned DPRGapSize = (GPRCS1Size + GPRCS2Size + ArgRegsSaveSize) % DPRAlign;
463 unsigned DPRCSOffset = GPRCS2Offset - DPRGapSize - DPRCSSize;
464 int FramePtrOffsetInPush = 0;
468 "Max FP estimation is wrong");
469 FramePtrOffsetInPush = FPOffset + ArgRegsSaveSize;
478 if (GPRCS2Size > 0) {
479 GPRCS2Push = LastPush = MBBI++;
480 DefCFAOffsetCandidates.addInst(LastPush, GPRCS2Size);
486 assert(DPRGapSize == 4 &&
"unexpected alignment requirements for DPRs");
487 if (LastPush != MBB.
end() &&
489 DefCFAOffsetCandidates.addExtraBytes(LastPush, DPRGapSize);
493 DefCFAOffsetCandidates.addInst(std::prev(MBBI), DPRGapSize);
501 while (MBBI != MBB.
end() && MBBI->getOpcode() == ARM::VSTMDDB_UPD) {
516 NumBytes = DPRCSOffset;
521 if (NumWords < 65536)
537 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBL))
539 .addExternalSymbol(
"__chkstk")
544 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2MOVi32imm), ARM::R12)
545 .addExternalSymbol(
"__chkstk")
548 BuildMI(MBB, MBBI, dl, TII.get(ARM::tBLXr))
556 BuildMI(MBB, MBBI, dl, TII.get(ARM::t2SUBrr), ARM::SP)
569 DefCFAOffsetCandidates.addExtraBytes(LastPush, NumBytes);
573 DefCFAOffsetCandidates.addInst(std::prev(MBBI), NumBytes);
598 dl,
TII, FramePtr, ARM::SP,
599 PushSize + FramePtrOffsetInPush,
601 if (FramePtrOffsetInPush + PushSize != 0) {
604 -(ArgRegsSaveSize - FramePtrOffsetInPush)));
605 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
606 .addCFIIndex(CFIIndex)
612 BuildMI(MBB, AfterPush, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
613 .addCFIIndex(CFIIndex)
621 if (GPRCS1Size > 0) {
624 for (
const auto &
Entry : CSI) {
626 int FI =
Entry.getFrameIdx();
647 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
648 .addCFIIndex(CFIIndex)
655 if (GPRCS2Size > 0) {
657 for (
const auto &
Entry : CSI) {
659 int FI =
Entry.getFrameIdx();
671 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
672 .addCFIIndex(CFIIndex)
684 for (
const auto &
Entry : CSI) {
686 int FI =
Entry.getFrameIdx();
687 if ((Reg >= ARM::D0 && Reg <= ARM::D31) &&
693 BuildMI(MBB, Pos, dl, TII.get(TargetOpcode::CFI_INSTRUCTION))
694 .addCFIIndex(CFIIndex)
704 DefCFAOffsetCandidates.emitDefCFAOffsets(MBB, dl, TII, HasFP);
738 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
778 "This emitEpilogue does not support Thumb1!");
783 Register FramePtr = RegInfo->getFrameRegister(MF);
795 if (NumBytes - ArgRegsSaveSize != 0)
796 emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes - ArgRegsSaveSize);
799 const MCPhysReg *CSRegs = RegInfo->getCalleeSavedRegs(&MF);
800 if (MBBI != MBB.
begin()) {
809 NumBytes -= (ArgRegsSaveSize +
832 "No scratch register to restore SP from FP!");
835 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
842 BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP)
847 BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVr), ARM::SP)
851 }
else if (NumBytes &&
860 while (MBBI != MBB.
end() && MBBI->getOpcode() == ARM::VLDMDIA_UPD)
865 "unexpected DPR alignment gap");
874 emitSPUpdate(isARM, MBB, MBBI, dl, TII, ArgRegsSaveSize);
883 unsigned &FrameReg)
const {
889 int FI,
unsigned &FrameReg,
908 if (RegInfo->needsStackRealignment(MF)) {
909 assert(
hasFP(MF) &&
"dynamic stack realignment without a FP!");
913 }
else if (hasMovingSP) {
915 "VLAs and dynamic stack alignment, but missing base pointer!");
929 }
else if (hasMovingSP) {
935 if (FPOffset >= -255 && FPOffset < 0) {
946 if (Offset >= 0 && (Offset & 3) == 0 && Offset <= 1020)
954 }
else if (Offset > (FPOffset < 0 ? -FPOffset : FPOffset)) {
972 const std::vector<CalleeSavedInfo> &CSI,
973 unsigned StmOpc,
unsigned StrOpc,
975 bool(*Func)(
unsigned,
bool),
976 unsigned NumAlignedDPRCS2Regs,
977 unsigned MIFlags)
const {
984 using RegAndKill = std::pair<unsigned, bool>;
987 unsigned i = CSI.
size();
989 unsigned LastReg = 0;
990 for (; i != 0; --i) {
991 unsigned Reg = CSI[i-1].getReg();
995 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1005 if (NoGap && LastReg && LastReg != Reg-1)
1013 Regs.
push_back(std::make_pair(Reg, !isLiveIn));
1019 llvm::sort(Regs, [&](
const RegAndKill &LHS,
const RegAndKill &RHS) {
1023 if (Regs.
size() > 1 || StrOpc== 0) {
1028 for (
unsigned i = 0,
e = Regs.
size(); i <
e; ++i)
1030 }
else if (Regs.
size() == 1) {
1031 BuildMI(MBB, MI, DL, TII.
get(StrOpc), ARM::SP)
1043 if (MI != MBB.
begin())
1050 std::vector<CalleeSavedInfo> &CSI,
1051 unsigned LdmOpc,
unsigned LdrOpc,
1052 bool isVarArg,
bool NoGap,
1053 bool(*Func)(
unsigned,
bool),
1054 unsigned NumAlignedDPRCS2Regs)
const {
1060 bool isTailCall =
false;
1061 bool isInterrupt =
false;
1062 bool isTrap =
false;
1063 if (MBB.
end() !=
MI) {
1064 DL = MI->getDebugLoc();
1065 unsigned RetOpcode = MI->getOpcode();
1066 isTailCall = (RetOpcode == ARM::TCRETURNdi || RetOpcode == ARM::TCRETURNri);
1068 RetOpcode == ARM::SUBS_PC_LR || RetOpcode == ARM::t2SUBS_PC_LR;
1070 RetOpcode ==
ARM::TRAP || RetOpcode == ARM::TRAPNaCl ||
1071 RetOpcode == ARM::tTRAP;
1075 unsigned i = CSI.
size();
1077 unsigned LastReg = 0;
1078 bool DeleteRet =
false;
1079 for (; i != 0; --i) {
1085 if (Reg >= ARM::D8 && Reg < ARM::D8 + NumAlignedDPRCS2Regs)
1088 if (Reg == ARM::LR && !isTailCall && !isVarArg && !isInterrupt &&
1105 if (NoGap && LastReg && LastReg != Reg-1)
1115 llvm::sort(Regs, [&](
unsigned LHS,
unsigned RHS) {
1119 if (Regs.
size() > 1 || LdrOpc == 0) {
1123 for (
unsigned i = 0,
e = Regs.
size(); i <
e; ++i)
1126 if (MI != MBB.
end()) {
1128 MI->eraseFromParent();
1132 }
else if (Regs.
size() == 1) {
1135 if (Regs[0] == ARM::PC)
1138 BuildMI(MBB, MI, DL, TII.
get(LdrOpc), Regs[0])
1143 if (LdrOpc == ARM::LDR_POST_REG || LdrOpc == ARM::LDR_POST_IMM) {
1154 if (MI != MBB.
end())
1164 unsigned NumAlignedDPRCS2Regs,
1165 const std::vector<CalleeSavedInfo> &CSI,
1176 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i) {
1177 unsigned DNum = CSI[i].getReg() - ARM::D8;
1178 if (DNum > NumAlignedDPRCS2Regs - 1)
1180 int FI = CSI[i].getFrameIdx();
1208 unsigned Opc = isThumb ? ARM::t2SUBri : ARM::SUBri;
1211 .
addImm(8 * NumAlignedDPRCS2Regs)
1227 Opc = isThumb ? ARM::tMOVr : ARM::MOVr;
1236 unsigned NextReg = ARM::D8;
1240 if (NumAlignedDPRCS2Regs >= 6) {
1242 &ARM::QQPRRegClass);
1251 NumAlignedDPRCS2Regs -= 4;
1256 unsigned R4BaseReg = NextReg;
1259 if (NumAlignedDPRCS2Regs >= 4) {
1261 &ARM::QQPRRegClass);
1270 NumAlignedDPRCS2Regs -= 4;
1274 if (NumAlignedDPRCS2Regs >= 2) {
1284 NumAlignedDPRCS2Regs -= 2;
1288 if (NumAlignedDPRCS2Regs) {
1294 .
addImm((NextReg - R4BaseReg) * 2)
1306 unsigned NumAlignedDPRCS2Regs) {
1311 assert(MI->mayStore() &&
"Expecting spill instruction");
1314 switch(NumAlignedDPRCS2Regs) {
1317 assert(MI->mayStore() &&
"Expecting spill instruction");
1321 assert(MI->mayStore() &&
"Expecting spill instruction");
1337 unsigned NumAlignedDPRCS2Regs,
1338 const std::vector<CalleeSavedInfo> &CSI,
1347 for (
unsigned i = 0,
e = CSI.size(); i !=
e; ++i)
1348 if (CSI[i].
getReg() == ARM::D8) {
1349 D8SpillFI = CSI[i].getFrameIdx();
1361 unsigned Opc = isThumb ? ARM::t2ADDri : ARM::ADDri;
1363 .addFrameIndex(D8SpillFI)
1369 unsigned NextReg = ARM::D8;
1372 if (NumAlignedDPRCS2Regs >= 6) {
1374 &ARM::QQPRRegClass);
1375 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Qwb_fixed), NextReg)
1382 NumAlignedDPRCS2Regs -= 4;
1387 unsigned R4BaseReg = NextReg;
1390 if (NumAlignedDPRCS2Regs >= 4) {
1392 &ARM::QQPRRegClass);
1393 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1d64Q), NextReg)
1399 NumAlignedDPRCS2Regs -= 4;
1403 if (NumAlignedDPRCS2Regs >= 2) {
1406 BuildMI(MBB, MI, DL, TII.
get(ARM::VLD1q64), SupReg)
1411 NumAlignedDPRCS2Regs -= 2;
1415 if (NumAlignedDPRCS2Regs)
1416 BuildMI(MBB, MI, DL, TII.
get(ARM::VLDRD), NextReg)
1418 .
addImm(2 * (NextReg - R4BaseReg))
1427 const std::vector<CalleeSavedInfo> &CSI,
1435 unsigned PushOpc = AFI->
isThumbFunction() ? ARM::t2STMDB_UPD : ARM::STMDB_UPD;
1437 ARM::t2STR_PRE : ARM::STR_PRE_IMM;
1438 unsigned FltOpc = ARM::VSTMDDB_UPD;
1450 if (NumAlignedDPRCS2Regs)
1458 std::vector<CalleeSavedInfo> &CSI,
1470 if (NumAlignedDPRCS2Regs)
1473 unsigned PopOpc = AFI->
isThumbFunction() ? ARM::t2LDMIA_UPD : ARM::LDMIA_UPD;
1474 unsigned LdrOpc = AFI->
isThumbFunction() ? ARM::t2LDR_POST :ARM::LDR_POST_IMM;
1475 unsigned FltOpc = ARM::VLDMDIA_UPD;
1477 NumAlignedDPRCS2Regs);
1478 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1480 emitPopInst(MBB, MI, CSI, PopOpc, LdrOpc, isVarArg,
false,
1489 unsigned FnSize = 0;
1490 for (
auto &MBB : MF) {
1491 for (
auto &MI : MBB)
1494 if (MF.getJumpTableInfo())
1495 for (
auto &Table: MF.getJumpTableInfo()->getJumpTables())
1496 FnSize += Table.MBBs.size() * 4;
1497 FnSize += MF.getConstantPool()->getConstants().size() * 4;
1507 bool &HasNonSPFrameIndex) {
1512 unsigned Limit = (1 << 12) - 1;
1513 for (
auto &MBB : MF) {
1514 for (
auto &MI : MBB) {
1515 if (MI.isDebugInstr())
1517 for (
unsigned i = 0,
e = MI.getNumOperands(); i !=
e; ++i) {
1518 if (!MI.getOperand(i).isFI())
1523 if (MI.getOpcode() == ARM::ADDri) {
1524 Limit = std::min(Limit, (1U << 8) - 1);
1529 if (MI.getOpcode() == ARM::t2ADDri || MI.getOpcode() == ARM::t2ADDri12)
1534 if (RegClass && !RegClass->
contains(ARM::SP))
1535 HasNonSPFrameIndex =
true;
1545 Limit = std::min(Limit, (1U << 8) - 1);
1548 Limit = std::min(Limit, ((1U << 8) - 1) * 2);
1553 Limit = std::min(Limit, ((1U << 8) - 1) * 4);
1559 Limit = std::min(Limit, (1U << 8) - 1);
1567 Limit = std::min(Limit, ((1U << 7) - 1) * 1);
1570 Limit = std::min(Limit, ((1U << 7) - 1) * 2);
1573 Limit = std::min(Limit, ((1U << 7) - 1) * 4);
1576 llvm_unreachable(
"Unhandled addressing mode in stack size limit calculation");
1600 if (!static_cast<const ARMSubtarget &>(MF.
getSubtarget()).hasNEON())
1608 if (!static_cast<const ARMBaseRegisterInfo *>(
1617 unsigned NumSpills = 0;
1618 for (; NumSpills < 8; ++NumSpills)
1619 if (!SavedRegs.
test(ARM::D8 + NumSpills))
1641 bool CanEliminateFrame =
true;
1642 bool CS1Spilled =
false;
1643 bool LRSpilled =
false;
1644 unsigned NumGPRSpills = 0;
1645 unsigned NumFPRSpills = 0;
1665 (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF)))
1676 SavedRegs.
set(ARM::LR);
1682 SavedRegs.
set(ARM::LR);
1690 if (MFI.hasVarSizedObjects() || RegInfo->needsStackRealignment(MF) ||
1691 MFI.estimateStackSize(MF) > 508)
1705 for (
unsigned i = 0; CSRegs[i]; ++i) {
1706 unsigned Reg = CSRegs[i];
1707 bool Spilled =
false;
1708 if (SavedRegs.
test(Reg)) {
1710 CanEliminateFrame =
false;
1713 if (!ARM::GPRRegClass.
contains(Reg)) {
1715 if (ARM::SPRRegClass.
contains(Reg))
1717 else if (ARM::DPRRegClass.
contains(Reg))
1719 else if (ARM::QPRRegClass.
contains(Reg))
1740 case ARM::R0:
case ARM::R1:
1756 case ARM::R0:
case ARM::R1:
1770 bool ForceLRSpill =
false;
1776 if (FnSize >= (1 << 11)) {
1777 CanEliminateFrame =
false;
1778 ForceLRSpill =
true;
1796 unsigned EstimatedStackSize =
1797 MFI.estimateStackSize(MF) + 4 * (NumGPRSpills + NumFPRSpills);
1800 int MaxFixedOffset = 0;
1801 for (
int I = MFI.getObjectIndexBegin();
I < 0; ++
I) {
1802 int MaxObjectOffset = MFI.getObjectOffset(
I) + MFI.getObjectSize(
I);
1803 MaxFixedOffset =
std::max(MaxFixedOffset, MaxObjectOffset);
1806 bool HasFP =
hasFP(MF);
1809 EstimatedStackSize += 4;
1813 EstimatedStackSize += MaxFixedOffset;
1815 EstimatedStackSize += 16;
1817 unsigned EstimatedRSStackSizeLimit, EstimatedRSFixedSizeLimit;
1818 bool HasNonSPFrameIndex =
false;
1834 EstimatedRSStackSizeLimit = (1U << 5) * 4;
1836 EstimatedRSStackSizeLimit = (1U << 8) * 4;
1837 EstimatedRSFixedSizeLimit = (1U << 5) * 4;
1839 EstimatedRSStackSizeLimit =
1841 EstimatedRSFixedSizeLimit = EstimatedRSStackSizeLimit;
1845 bool HasLargeStack = EstimatedStackSize > EstimatedRSStackSizeLimit;
1851 bool HasMovingSP = MFI.hasVarSizedObjects() ||
1853 bool HasBPOrFixedSP = RegInfo->
hasBasePointer(MF) || !HasMovingSP;
1862 bool HasLargeArgumentList =
1863 HasFP && (MaxFixedOffset - MaxFPOffset) > (
int)EstimatedRSFixedSizeLimit;
1865 bool BigFrameOffsets = HasLargeStack || !HasBPOrFixedSP ||
1866 HasLargeArgumentList || HasNonSPFrameIndex;
1867 LLVM_DEBUG(
dbgs() <<
"EstimatedLimit: " << EstimatedRSStackSizeLimit
1868 <<
"; EstimatedStack: " << EstimatedStackSize
1869 <<
"; EstimatedFPStack: " << MaxFixedOffset - MaxFPOffset
1870 <<
"; BigFrameOffsets: " << BigFrameOffsets <<
"\n");
1871 if (BigFrameOffsets ||
1876 SavedRegs.
set(FramePtr);
1880 SavedRegs.
set(ARM::LR);
1883 auto LRPos =
llvm::find(UnspilledCS1GPRs, ARM::LR);
1884 if (LRPos != UnspilledCS1GPRs.
end())
1885 UnspilledCS1GPRs.
erase(LRPos);
1888 if (
FPPos != UnspilledCS1GPRs.
end())
1891 if (FramePtr == ARM::R7)
1906 bool ExtraCSSpill =
false;
1923 int EntryRegDeficit = 0;
1924 for (
unsigned Reg : {ARM::R0, ARM::R1,
ARM::R2, ARM::R3}) {
1929 <<
" is unused argument register, EntryRegDeficit = " 1930 << EntryRegDeficit <<
"\n");
1937 <<
" return regs used, ExitRegDeficit = " 1938 << ExitRegDeficit <<
"\n");
1940 int RegDeficit =
std::max(EntryRegDeficit, ExitRegDeficit);
1949 <<
" is saved low register, RegDeficit = " 1950 << RegDeficit <<
"\n");
1956 <<
" is non-saved low register, adding to AvailableRegs\n");
1962 if (SavedRegs.
test(ARM::R7)) {
1965 << RegDeficit <<
"\n");
1970 <<
"%r7 is non-saved low register, adding to AvailableRegs\n");
1975 for (
unsigned Reg : {ARM::R8, ARM::R9, ARM::R10, ARM::R11}) {
1979 <<
" is saved high register, RegDeficit = " 1980 << RegDeficit <<
"\n");
1987 if ((EntryRegDeficit > ExitRegDeficit) &&
1990 if (SavedRegs.
test(ARM::LR)) {
1993 << RegDeficit <<
"\n");
1996 LLVM_DEBUG(
dbgs() <<
"%lr is not saved, adding to AvailableRegs\n");
2005 LLVM_DEBUG(
dbgs() <<
"Final RegDeficit = " << RegDeficit <<
"\n");
2006 for (; RegDeficit > 0 && !AvailableRegs.
empty(); --RegDeficit) {
2009 <<
" to make up reg deficit\n");
2015 ExtraCSSpill =
true;
2020 LLVM_DEBUG(
dbgs() <<
"After adding spills, RegDeficit = " << RegDeficit
2030 if (!LRSpilled && CS1Spilled && !ExpensiveLRRestore) {
2031 SavedRegs.
set(ARM::LR);
2034 LRPos =
llvm::find(UnspilledCS1GPRs, (
unsigned)ARM::LR);
2035 if (LRPos != UnspilledCS1GPRs.
end())
2036 UnspilledCS1GPRs.
erase(LRPos);
2038 ForceLRSpill =
false;
2041 ExtraCSSpill =
true;
2049 if (TargetAlign >= 8 && (NumGPRSpills & 1)) {
2050 if (CS1Spilled && !UnspilledCS1GPRs.
empty()) {
2051 for (
unsigned i = 0,
e = UnspilledCS1GPRs.
size(); i !=
e; ++i) {
2052 unsigned Reg = UnspilledCS1GPRs[i];
2058 (Reg == ARM::LR && !ExpensiveLRRestore)) {
2061 <<
" to make up alignment\n");
2064 ExtraCSSpill =
true;
2069 unsigned Reg = UnspilledCS2GPRs.
front();
2072 <<
" to make up alignment\n");
2074 ExtraCSSpill =
true;
2083 if (BigFrameOffsets && !ExtraCSSpill) {
2086 unsigned NumExtras = TargetAlign / 4;
2088 while (NumExtras && !UnspilledCS1GPRs.
empty()) {
2089 unsigned Reg = UnspilledCS1GPRs.
back();
2099 while (NumExtras && !UnspilledCS2GPRs.
empty()) {
2100 unsigned Reg = UnspilledCS2GPRs.
back();
2108 if (NumExtras == 0) {
2109 for (
unsigned Reg : Extras) {
2112 ExtraCSSpill =
true;
2115 if (!ExtraCSSpill && RS) {
2127 SavedRegs.
set(ARM::LR);
2142 SavedRegs.
set(ARM::R0);
2156 unsigned Amount = TII.getFrameSize(Old);
2165 "This eliminateCallFramePseudoInstr does not support Thumb1!");
2175 if (Opc == ARM::ADJCALLSTACKDOWN || Opc == ARM::tADJCALLSTACKDOWN) {
2179 assert(Opc == ARM::ADJCALLSTACKUP || Opc == ARM::tADJCALLSTACKUP);
2185 return MBB.
erase(I);
2193 unsigned Shifted = 0;
2198 while (!(Value & 0xC0000000)) {
2203 bool Carry = (Value & 0x00FFFFFF);
2204 Value = ((Value & 0xFF000000) >> 24) + Carry;
2206 if (Value & 0x0000100)
2207 Value = Value & 0x000001FC;
2210 Value = Value >> (Shifted - 24);
2212 Value = Value << (24 - Shifted);
2284 unsigned ScratchReg0 =
ARM::R4;
2285 unsigned ScratchReg1 = ARM::R5;
2286 uint64_t AlignedStackSize;
2302 if (BeforePrologueRegion.
insert(PredBB).second)
2305 }
while (!WalkList.
empty());
2315 BeforePrologueRegion.
insert(
B);
2317 for (
const auto &LI : PrologueMBB.
liveins()) {
2319 PredBB->addLiveIn(LI);
2325 BeforePrologueRegion.
erase(
B);
2352 BuildMI(PrevStackMBB, DL, TII.get(ARM::tPUSH))
2354 .addReg(ScratchReg0)
2355 .addReg(ScratchReg1);
2357 BuildMI(PrevStackMBB, DL, TII.get(ARM::STMDB_UPD))
2369 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2370 .addCFIIndex(CFIIndex);
2373 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2374 .addCFIIndex(CFIIndex);
2377 BuildMI(PrevStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2378 .addCFIIndex(CFIIndex);
2382 BuildMI(McrMBB, DL, TII.get(ARM::tMOVr), ScratchReg1)
2385 }
else if (CompareStackPointer) {
2386 BuildMI(McrMBB, DL, TII.get(ARM::MOVr), ScratchReg1)
2393 if (!CompareStackPointer && Thumb) {
2394 BuildMI(McrMBB, DL, TII.get(ARM::tSUBi8), ScratchReg1)
2396 .addReg(ScratchReg1)
2397 .addImm(AlignedStackSize)
2399 }
else if (!CompareStackPointer) {
2400 BuildMI(McrMBB, DL, TII.get(ARM::SUBri), ScratchReg1)
2402 .
addImm(AlignedStackSize)
2415 BuildMI(GetMBB, DL, TII.get(ARM::tLDRpci), ScratchReg0)
2416 .addConstantPoolIndex(CPI)
2420 BuildMI(GetMBB, DL, TII.get(ARM::tLDRi), ScratchReg0)
2421 .addReg(ScratchReg0)
2427 BuildMI(McrMBB, DL, TII.get(Thumb ? ARM::t2MRC : ARM::MRC),
2442 BuildMI(GetMBB, DL, TII.get(Thumb ? ARM::t2LDRi12 : ARM::LDRi12),
2444 .addReg(ScratchReg0)
2451 Opcode = Thumb ? ARM::tCMPr : ARM::CMPrr;
2452 BuildMI(GetMBB, DL, TII.get(Opcode))
2453 .addReg(ScratchReg0)
2458 Opcode = Thumb ? ARM::tBcc : ARM::Bcc;
2459 BuildMI(GetMBB, DL, TII.get(Opcode)).addMBB(PostStackMBB)
2471 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg0)
2473 .addImm(AlignedStackSize)
2476 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg0)
2477 .addImm(AlignedStackSize)
2484 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVi8), ScratchReg1)
2489 BuildMI(AllocMBB, DL, TII.get(ARM::MOVi), ScratchReg1)
2497 BuildMI(AllocMBB, DL, TII.get(ARM::tPUSH))
2501 BuildMI(AllocMBB, DL, TII.get(ARM::STMDB_UPD))
2512 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2513 .addCFIIndex(CFIIndex);
2516 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2517 .addCFIIndex(CFIIndex);
2521 BuildMI(AllocMBB, DL, TII.get(ARM::tBL))
2523 .addExternalSymbol(
"__morestack");
2526 .addExternalSymbol(
"__morestack");
2532 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2534 .addReg(ScratchReg0);
2535 BuildMI(AllocMBB, DL, TII.get(ARM::tMOVr), ARM::LR)
2536 .addReg(ScratchReg0)
2539 BuildMI(AllocMBB, DL, TII.get(ARM::t2LDR_POST))
2547 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2559 BuildMI(AllocMBB, DL, TII.get(ARM::tPOP))
2561 .addReg(ScratchReg0)
2562 .addReg(ScratchReg1);
2564 BuildMI(AllocMBB, DL, TII.get(ARM::LDMIA_UPD))
2574 BuildMI(AllocMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2575 .addCFIIndex(CFIIndex);
2583 BuildMI(PostStackMBB, DL, TII.get(ARM::tPOP))
2585 .addReg(ScratchReg0)
2586 .addReg(ScratchReg1);
2588 BuildMI(PostStackMBB, DL, TII.get(ARM::LDMIA_UPD))
2598 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2599 .addCFIIndex(CFIIndex);
2605 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2606 .addCFIIndex(CFIIndex);
2609 BuildMI(PostStackMBB, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))
2610 .addCFIIndex(CFIIndex);
2613 PostStackMBB->addSuccessor(&PrologueMBB);
2624 #ifdef EXPENSIVE_CHECKS bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
bool getPreservesR0() const
const MachineInstrBuilder & add(const MachineOperand &MO) const
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.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isReserved(Register PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
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.
This class represents lattice values for constants.
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...
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
ARMConstantPoolValue - ARM specific constantpool value.
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
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.
Register getFrameRegister(const MachineFunction &MF) const override
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
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
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 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...
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
Retuns the total number of operands.
virtual bool hasFP(const MachineFunction &MF) const =0
hasFP - Return true if the specified function should have a dedicated frame pointer register...
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.
MachineBasicBlock iterator that automatically skips over MIs that are inside bundles (i...
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)
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.
bool keepFramePointer(const MachineFunction &MF) const override
Return true if the target wants to keep the frame pointer regardless of the function attribute "frame...
void setDPRCalleeSavedAreaOffset(unsigned o)
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.
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
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...
bool addRegisterKilled(Register IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
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
void setHasNosplitStack(bool b)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
Analysis containing CSE Info
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.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned getDefRegState(bool B)
void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const override
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs...
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)
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
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.
static unsigned EstimateFunctionSizeInBytes(const MachineFunction &MF, const ARMBaseInstrInfo &TII)
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.
static unsigned estimateRSStackSizeLimit(MachineFunction &MF, const TargetFrameLowering *TFI, bool &HasNonSPFrameIndex)
estimateRSStackSizeLimit - Look at each instruction that references stack frames and return the stack...
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.
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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)
Align max(MaybeAlign Lhs, Align Rhs)
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
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
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.
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
static bool isARMLowRegister(unsigned Reg)
isARMLowRegister - Returns true if the register is a low register (r0-r7).
Representation of each machine instruction.
virtual void getCalleeSaves(const MachineFunction &MF, BitVector &SavedRegs) const
Returns the callee-saved registers as computed by determineCalleeSaves in the BitVector SavedRegs...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
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 LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
iterator_range< livein_iterator > liveins() const
static bool isARMArea3Register(unsigned Reg, bool isIOS)
void setLRIsSpilled(bool s)
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.
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
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
bool isTargetWindows() const
Primary interface to the complete machine description for the target machine.
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.
Register getReg() const
getReg - Returns the register number.
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...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
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)
Wrapper class representing virtual and physical registers.
This class contains meta information specific to a module.