66#define GET_INSTRINFO_CTOR_DTOR
67#include "AArch64GenInstrInfo.inc"
69#define DEBUG_TYPE "AArch64InstrInfo"
71STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
72STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
73 "instructions expanded from canonical COPY");
74STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
75 "instructions expanded from canonical COPY");
76STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
77 "instructions expanded from canonical COPY");
82 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
86 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
90 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
94 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
98 cl::desc(
"Restrict range of B instructions (DEBUG)"));
102 cl::desc(
"Restrict range of instructions to search for the "
103 "machine-combiner gather pattern optimization"));
108 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
118 switch (
MI.getOpcode()) {
139 auto Op =
MI.getOpcode();
140 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
141 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), *MAI);
145 if (
MI.isMetaInstruction())
150 unsigned NumBytes = 0;
160 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
163 if (!MFI->shouldSignReturnAddress(*MF))
166 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
174 switch (
Desc.getOpcode()) {
177 return Desc.getSize();
184 case TargetOpcode::STACKMAP:
187 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
189 case TargetOpcode::PATCHPOINT:
192 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
194 case TargetOpcode::STATEPOINT:
196 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
201 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
206 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
208 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
209 case TargetOpcode::PATCHABLE_TAIL_CALL:
210 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
214 case TargetOpcode::PATCHABLE_EVENT_CALL:
220 NumBytes =
MI.getOperand(1).getImm();
222 case TargetOpcode::BUNDLE:
223 NumBytes = getInstBundleLength(
MI);
230unsigned AArch64InstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
234 while (++
I != E &&
I->isInsideBundle()) {
235 assert(!
I->isBundle() &&
"No nested bundle!");
270 case AArch64::CBWPri:
271 case AArch64::CBXPri:
272 case AArch64::CBWPrr:
273 case AArch64::CBXPrr:
281 case AArch64::CBBAssertExt:
282 case AArch64::CBHAssertExt:
313 case AArch64::CBWPri:
314 case AArch64::CBXPri:
315 case AArch64::CBBAssertExt:
316 case AArch64::CBHAssertExt:
317 case AArch64::CBWPrr:
318 case AArch64::CBXPrr:
324 int64_t BrOffset)
const {
326 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
327 "over conditional branch expansion");
328 return isIntN(Bits, BrOffset / 4);
333 switch (
MI.getOpcode()) {
337 return MI.getOperand(0).getMBB();
342 return MI.getOperand(2).getMBB();
348 return MI.getOperand(1).getMBB();
349 case AArch64::CBWPri:
350 case AArch64::CBXPri:
351 case AArch64::CBBAssertExt:
352 case AArch64::CBHAssertExt:
353 case AArch64::CBWPrr:
354 case AArch64::CBXPrr:
355 return MI.getOperand(3).getMBB();
365 assert(RS &&
"RegScavenger required for long branching");
367 "new block should be inserted for expanding unconditional branch");
370 "restore block should be inserted for restoring clobbered registers");
377 "Branch offsets outside of the signed 33-bit range not supported");
388 RS->enterBasicBlockEnd(
MBB);
391 constexpr Register Reg = AArch64::X16;
392 if (!RS->isRegUsed(Reg)) {
393 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
400 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
401 if (Scavenged != AArch64::NoRegister &&
403 buildIndirectBranch(Scavenged, NewDestBB);
404 RS->setRegUsed(Scavenged);
413 "Unable to insert indirect branch inside function that has red zone");
436 bool AllowModify)
const {
443 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
444 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
448 if (!isUnpredicatedTerminator(*
I))
455 unsigned LastOpc = LastInst->
getOpcode();
456 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
471 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
478 LastInst = SecondLastInst;
480 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
485 SecondLastInst = &*
I;
486 SecondLastOpc = SecondLastInst->
getOpcode();
497 LastInst = SecondLastInst;
499 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
501 "unreachable unconditional branches removed above");
510 SecondLastInst = &*
I;
511 SecondLastOpc = SecondLastInst->
getOpcode();
515 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
531 I->eraseFromParent();
540 I->eraseFromParent();
549 MachineBranchPredicate &MBP,
550 bool AllowModify)
const {
562 assert(MBP.TrueDest &&
"expected!");
563 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
565 MBP.ConditionDef =
nullptr;
566 MBP.SingleUseCondition =
false;
576 if (
I ==
MBB.begin())
592 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
593 MBP.ConditionDef = &
MI;
602 case AArch64::CBNZX: {
606 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
607 ? MachineBranchPredicate::PRED_NE
608 : MachineBranchPredicate::PRED_EQ;
609 Register CondReg = MBP.LHS.getReg();
618 case AArch64::TBNZX: {
639 Cond[1].setImm(AArch64::CBNZW);
642 Cond[1].setImm(AArch64::CBZW);
645 Cond[1].setImm(AArch64::CBNZX);
648 Cond[1].setImm(AArch64::CBZX);
651 Cond[1].setImm(AArch64::TBNZW);
654 Cond[1].setImm(AArch64::TBZW);
657 Cond[1].setImm(AArch64::TBNZX);
660 Cond[1].setImm(AArch64::TBZX);
664 case AArch64::CBWPri:
665 case AArch64::CBXPri:
666 case AArch64::CBBAssertExt:
667 case AArch64::CBHAssertExt:
668 case AArch64::CBWPrr:
669 case AArch64::CBXPrr: {
682 int *BytesRemoved)
const {
692 I->eraseFromParent();
696 if (
I ==
MBB.begin()) {
709 I->eraseFromParent();
716void AArch64InstrInfo::instantiateCondBranch(
741 if (
Cond.size() > 5) {
752 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
779 unsigned Opc =
MI.getOpcode();
786 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
787 MI.getOperand(0).getReg() == AArch64::XZR) {
789 dbgs() <<
"Removing always taken branch: " <<
MI);
792 for (
auto *S : Succs)
794 MBB->removeSuccessor(S);
796 while (
MBB->rbegin() != &
MI)
797 MBB->rbegin()->eraseFromParent();
798 MI.eraseFromParent();
808 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
809 MI.getOperand(0).getReg() == AArch64::XZR) {
811 dbgs() <<
"Removing never taken branch: " <<
MI);
813 MI.getParent()->removeSuccessor(
Target);
814 MI.eraseFromParent();
827 if (!
DefMI->isFullCopy())
829 VReg =
DefMI->getOperand(1).getReg();
838 unsigned *NewReg =
nullptr) {
843 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
847 switch (
DefMI->getOpcode()) {
848 case AArch64::SUBREG_TO_REG:
852 if (!
DefMI->getOperand(1).isReg())
854 if (!
DefMI->getOperand(2).isImm() ||
855 DefMI->getOperand(2).getImm() != AArch64::sub_32)
858 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
860 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
863 SrcReg = AArch64::XZR;
864 Opc = AArch64::CSINCXr;
867 case AArch64::MOVi32imm:
868 case AArch64::MOVi64imm:
869 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
871 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
872 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
875 case AArch64::ADDSXri:
876 case AArch64::ADDSWri:
878 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
883 case AArch64::ADDXri:
884 case AArch64::ADDWri:
886 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
887 DefMI->getOperand(3).getImm() != 0)
889 SrcReg =
DefMI->getOperand(1).getReg();
890 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
893 case AArch64::ORNXrr:
894 case AArch64::ORNWrr: {
897 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
899 SrcReg =
DefMI->getOperand(2).getReg();
900 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
904 case AArch64::SUBSXrr:
905 case AArch64::SUBSWrr:
907 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
912 case AArch64::SUBXrr:
913 case AArch64::SUBWrr: {
916 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
918 SrcReg =
DefMI->getOperand(2).getReg();
919 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
925 assert(
Opc && SrcReg &&
"Missing parameters");
937 int &FalseCycles)
const {
948 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
952 unsigned ExtraCondLat =
Cond.size() != 1;
956 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
957 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
959 CondCycles = 1 + ExtraCondLat;
960 TrueCycles = FalseCycles = 1;
970 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
971 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
972 CondCycles = 5 + ExtraCondLat;
973 TrueCycles = FalseCycles = 2;
990 switch (
Cond.size()) {
1010 case AArch64::CBNZW:
1014 case AArch64::CBNZX:
1045 case AArch64::TBNZW:
1046 case AArch64::TBNZX:
1068 unsigned SubsOpc, SubsDestReg;
1074 case AArch64::CBWPri:
1075 SubsOpc = AArch64::SUBSWri;
1076 SubsDestReg = AArch64::WZR;
1079 case AArch64::CBXPri:
1080 SubsOpc = AArch64::SUBSXri;
1081 SubsDestReg = AArch64::XZR;
1084 case AArch64::CBWPrr:
1085 SubsOpc = AArch64::SUBSWrr;
1086 SubsDestReg = AArch64::WZR;
1089 case AArch64::CBXPrr:
1090 SubsOpc = AArch64::SUBSXrr;
1091 SubsDestReg = AArch64::XZR;
1120 switch (ExtendType) {
1126 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1127 ExtOpc = AArch64::SBFMWri;
1133 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1134 ExtOpc = AArch64::SBFMWri;
1140 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1141 ExtOpc = AArch64::ANDWri;
1147 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1148 ExtOpc = AArch64::ANDWri;
1157 if (ExtOpc != AArch64::ANDWri)
1159 MBBI.addImm(ExtBits);
1187 bool TryFold =
false;
1189 RC = &AArch64::GPR64RegClass;
1190 Opc = AArch64::CSELXr;
1193 RC = &AArch64::GPR32RegClass;
1194 Opc = AArch64::CSELWr;
1197 RC = &AArch64::FPR64RegClass;
1198 Opc = AArch64::FCSELDrrr;
1200 RC = &AArch64::FPR32RegClass;
1201 Opc = AArch64::FCSELSrrr;
1203 assert(RC &&
"Unsupported regclass");
1207 unsigned NewReg = 0;
1230 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1231 FalseReg == AArch64::XZR) &&
1232 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1249 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1254 return Is.
size() <= 2;
1259 assert(
MI.isCopy() &&
"Expected COPY instruction");
1265 if (
Reg.isVirtual())
1267 if (
Reg.isPhysical())
1268 return RI.getMinimalPhysRegClass(
Reg);
1273 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1276 return MI.isAsCheapAsAMove();
1282 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1283 if (isExynosCheapAsMove(
MI))
1285 return MI.isAsCheapAsAMove();
1288 switch (
MI.getOpcode()) {
1290 return MI.isAsCheapAsAMove();
1292 case TargetOpcode::COPY:
1295 case AArch64::ADDWrs:
1296 case AArch64::ADDXrs:
1297 case AArch64::SUBWrs:
1298 case AArch64::SUBXrs:
1299 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1304 case AArch64::MOVi32imm:
1306 case AArch64::MOVi64imm:
1311bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1312 switch (
MI.getOpcode()) {
1316 case AArch64::ADDWrs:
1317 case AArch64::ADDXrs:
1318 case AArch64::ADDSWrs:
1319 case AArch64::ADDSXrs: {
1320 unsigned Imm =
MI.getOperand(3).getImm();
1327 case AArch64::ADDWrx:
1328 case AArch64::ADDXrx:
1329 case AArch64::ADDXrx64:
1330 case AArch64::ADDSWrx:
1331 case AArch64::ADDSXrx:
1332 case AArch64::ADDSXrx64: {
1333 unsigned Imm =
MI.getOperand(3).getImm();
1345 case AArch64::SUBWrs:
1346 case AArch64::SUBSWrs: {
1347 unsigned Imm =
MI.getOperand(3).getImm();
1349 return ShiftVal == 0 ||
1353 case AArch64::SUBXrs:
1354 case AArch64::SUBSXrs: {
1355 unsigned Imm =
MI.getOperand(3).getImm();
1357 return ShiftVal == 0 ||
1361 case AArch64::SUBWrx:
1362 case AArch64::SUBXrx:
1363 case AArch64::SUBXrx64:
1364 case AArch64::SUBSWrx:
1365 case AArch64::SUBSXrx:
1366 case AArch64::SUBSXrx64: {
1367 unsigned Imm =
MI.getOperand(3).getImm();
1379 case AArch64::LDRBBroW:
1380 case AArch64::LDRBBroX:
1381 case AArch64::LDRBroW:
1382 case AArch64::LDRBroX:
1383 case AArch64::LDRDroW:
1384 case AArch64::LDRDroX:
1385 case AArch64::LDRHHroW:
1386 case AArch64::LDRHHroX:
1387 case AArch64::LDRHroW:
1388 case AArch64::LDRHroX:
1389 case AArch64::LDRQroW:
1390 case AArch64::LDRQroX:
1391 case AArch64::LDRSBWroW:
1392 case AArch64::LDRSBWroX:
1393 case AArch64::LDRSBXroW:
1394 case AArch64::LDRSBXroX:
1395 case AArch64::LDRSHWroW:
1396 case AArch64::LDRSHWroX:
1397 case AArch64::LDRSHXroW:
1398 case AArch64::LDRSHXroX:
1399 case AArch64::LDRSWroW:
1400 case AArch64::LDRSWroX:
1401 case AArch64::LDRSroW:
1402 case AArch64::LDRSroX:
1403 case AArch64::LDRWroW:
1404 case AArch64::LDRWroX:
1405 case AArch64::LDRXroW:
1406 case AArch64::LDRXroX:
1407 case AArch64::PRFMroW:
1408 case AArch64::PRFMroX:
1409 case AArch64::STRBBroW:
1410 case AArch64::STRBBroX:
1411 case AArch64::STRBroW:
1412 case AArch64::STRBroX:
1413 case AArch64::STRDroW:
1414 case AArch64::STRDroX:
1415 case AArch64::STRHHroW:
1416 case AArch64::STRHHroX:
1417 case AArch64::STRHroW:
1418 case AArch64::STRHroX:
1419 case AArch64::STRQroW:
1420 case AArch64::STRQroX:
1421 case AArch64::STRSroW:
1422 case AArch64::STRSroX:
1423 case AArch64::STRWroW:
1424 case AArch64::STRWroX:
1425 case AArch64::STRXroW:
1426 case AArch64::STRXroX: {
1427 unsigned IsSigned =
MI.getOperand(3).getImm();
1434 unsigned Opc =
MI.getOpcode();
1438 case AArch64::SEH_StackAlloc:
1439 case AArch64::SEH_SaveFPLR:
1440 case AArch64::SEH_SaveFPLR_X:
1441 case AArch64::SEH_SaveReg:
1442 case AArch64::SEH_SaveReg_X:
1443 case AArch64::SEH_SaveRegP:
1444 case AArch64::SEH_SaveRegP_X:
1445 case AArch64::SEH_SaveFReg:
1446 case AArch64::SEH_SaveFReg_X:
1447 case AArch64::SEH_SaveFRegP:
1448 case AArch64::SEH_SaveFRegP_X:
1449 case AArch64::SEH_SetFP:
1450 case AArch64::SEH_AddFP:
1451 case AArch64::SEH_Nop:
1452 case AArch64::SEH_PrologEnd:
1453 case AArch64::SEH_EpilogStart:
1454 case AArch64::SEH_EpilogEnd:
1455 case AArch64::SEH_PACSignLR:
1456 case AArch64::SEH_SaveAnyRegI:
1457 case AArch64::SEH_SaveAnyRegIP:
1458 case AArch64::SEH_SaveAnyRegQP:
1459 case AArch64::SEH_SaveAnyRegQPX:
1460 case AArch64::SEH_AllocZ:
1461 case AArch64::SEH_SaveZReg:
1462 case AArch64::SEH_SavePReg:
1469 unsigned &SubIdx)
const {
1470 switch (
MI.getOpcode()) {
1473 case AArch64::SBFMXri:
1474 case AArch64::UBFMXri:
1477 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1480 SrcReg =
MI.getOperand(1).getReg();
1481 DstReg =
MI.getOperand(0).getReg();
1482 SubIdx = AArch64::sub_32;
1491 int64_t OffsetA = 0, OffsetB = 0;
1492 TypeSize WidthA(0,
false), WidthB(0,
false);
1493 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1514 OffsetAIsScalable == OffsetBIsScalable) {
1515 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1516 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1517 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1518 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1536 switch (
MI.getOpcode()) {
1539 if (
MI.getOperand(0).getImm() == 0x14)
1546 case AArch64::MSRpstatesvcrImm1:
1553 auto Next = std::next(
MI.getIterator());
1554 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1561 Register &SrcReg2, int64_t &CmpMask,
1562 int64_t &CmpValue)
const {
1566 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1567 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1570 switch (
MI.getOpcode()) {
1573 case AArch64::PTEST_PP:
1574 case AArch64::PTEST_PP_ANY:
1575 case AArch64::PTEST_PP_FIRST:
1576 SrcReg =
MI.getOperand(0).getReg();
1577 SrcReg2 =
MI.getOperand(1).getReg();
1578 if (
MI.getOperand(2).getSubReg())
1585 case AArch64::SUBSWrr:
1586 case AArch64::SUBSWrs:
1587 case AArch64::SUBSWrx:
1588 case AArch64::SUBSXrr:
1589 case AArch64::SUBSXrs:
1590 case AArch64::SUBSXrx:
1591 case AArch64::ADDSWrr:
1592 case AArch64::ADDSWrs:
1593 case AArch64::ADDSWrx:
1594 case AArch64::ADDSXrr:
1595 case AArch64::ADDSXrs:
1596 case AArch64::ADDSXrx:
1598 SrcReg =
MI.getOperand(1).getReg();
1599 SrcReg2 =
MI.getOperand(2).getReg();
1602 if (
MI.getOperand(2).getSubReg())
1608 case AArch64::SUBSWri:
1609 case AArch64::ADDSWri:
1610 case AArch64::SUBSXri:
1611 case AArch64::ADDSXri:
1612 SrcReg =
MI.getOperand(1).getReg();
1615 CmpValue =
MI.getOperand(2).getImm();
1617 case AArch64::ANDSWri:
1618 case AArch64::ANDSXri:
1621 SrcReg =
MI.getOperand(1).getReg();
1625 MI.getOperand(2).getImm(),
1626 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1635 assert(
MBB &&
"Can't get MachineBasicBlock here");
1637 assert(MF &&
"Can't get MachineFunction here");
1642 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1649 if (!OpRegCstraints)
1657 "Operand has register constraints without being a register!");
1660 if (
Reg.isPhysical()) {
1677 bool MIDefinesZeroReg =
false;
1678 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1679 MI.definesRegister(AArch64::XZR,
nullptr))
1680 MIDefinesZeroReg =
true;
1682 switch (
MI.getOpcode()) {
1684 return MI.getOpcode();
1685 case AArch64::ADDSWrr:
1686 return AArch64::ADDWrr;
1687 case AArch64::ADDSWri:
1688 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1689 case AArch64::ADDSWrs:
1690 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1691 case AArch64::ADDSWrx:
1692 return AArch64::ADDWrx;
1693 case AArch64::ADDSXrr:
1694 return AArch64::ADDXrr;
1695 case AArch64::ADDSXri:
1696 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1697 case AArch64::ADDSXrs:
1698 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1699 case AArch64::ADDSXrx:
1700 return AArch64::ADDXrx;
1701 case AArch64::SUBSWrr:
1702 return AArch64::SUBWrr;
1703 case AArch64::SUBSWri:
1704 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1705 case AArch64::SUBSWrs:
1706 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1707 case AArch64::SUBSWrx:
1708 return AArch64::SUBWrx;
1709 case AArch64::SUBSXrr:
1710 return AArch64::SUBXrr;
1711 case AArch64::SUBSXri:
1712 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1713 case AArch64::SUBSXrs:
1714 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1715 case AArch64::SUBSXrx:
1716 return AArch64::SUBXrx;
1731 if (To == To->getParent()->begin())
1736 if (To->getParent() != From->getParent())
1748 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1749 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1755std::optional<unsigned>
1759 unsigned MaskOpcode =
Mask->getOpcode();
1760 unsigned PredOpcode = Pred->
getOpcode();
1761 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1762 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1764 if (PredIsWhileLike) {
1768 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1775 getElementSizeForOpcode(MaskOpcode) ==
1776 getElementSizeForOpcode(PredOpcode))
1782 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1789 if (PredIsPTestLike) {
1794 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1802 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1803 PTestLikeMask->getOperand(1).getReg().isVirtual())
1811 getElementSizeForOpcode(MaskOpcode) ==
1812 getElementSizeForOpcode(PredOpcode)) {
1813 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1839 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1841 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1849 switch (PredOpcode) {
1850 case AArch64::AND_PPzPP:
1851 case AArch64::BIC_PPzPP:
1852 case AArch64::EOR_PPzPP:
1853 case AArch64::NAND_PPzPP:
1854 case AArch64::NOR_PPzPP:
1855 case AArch64::ORN_PPzPP:
1856 case AArch64::ORR_PPzPP:
1857 case AArch64::BRKA_PPzP:
1858 case AArch64::BRKPA_PPzPP:
1859 case AArch64::BRKB_PPzP:
1860 case AArch64::BRKPB_PPzPP:
1861 case AArch64::RDFFR_PPz: {
1865 if (Mask != PredMask)
1869 case AArch64::BRKN_PPzP: {
1873 if ((MaskOpcode != AArch64::PTRUE_B) ||
1874 (
Mask->getOperand(1).getImm() != 31))
1878 case AArch64::PTRUE_B:
1891bool AArch64InstrInfo::optimizePTestInstr(
1892 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1897 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
1901 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
1902 Op.getSubReg() == AArch64::psub0)
1906 unsigned PredOpcode = Pred->
getOpcode();
1907 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
1923 if (*NewOp != PredOpcode) {
1934 for (; i !=
e; ++i) {
1965 if (DeadNZCVIdx != -1) {
1984 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
1985 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
1986 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
1987 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
1996 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
1998 return (CmpValue == 0 || CmpValue == 1) &&
1999 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2007 switch (Instr.getOpcode()) {
2009 return AArch64::INSTRUCTION_LIST_END;
2011 case AArch64::ADDSWrr:
2012 case AArch64::ADDSWri:
2013 case AArch64::ADDSXrr:
2014 case AArch64::ADDSXri:
2015 case AArch64::ADDSWrx:
2016 case AArch64::ADDSXrx:
2017 case AArch64::SUBSWrr:
2018 case AArch64::SUBSWri:
2019 case AArch64::SUBSWrx:
2020 case AArch64::SUBSXrr:
2021 case AArch64::SUBSXri:
2022 case AArch64::SUBSXrx:
2023 case AArch64::ANDSWri:
2024 case AArch64::ANDSWrr:
2025 case AArch64::ANDSWrs:
2026 case AArch64::ANDSXri:
2027 case AArch64::ANDSXrr:
2028 case AArch64::ANDSXrs:
2029 case AArch64::BICSWrr:
2030 case AArch64::BICSXrr:
2031 case AArch64::BICSWrs:
2032 case AArch64::BICSXrs:
2033 return Instr.getOpcode();
2035 case AArch64::ADDWrr:
2036 return AArch64::ADDSWrr;
2037 case AArch64::ADDWri:
2038 return AArch64::ADDSWri;
2039 case AArch64::ADDXrr:
2040 return AArch64::ADDSXrr;
2041 case AArch64::ADDXri:
2042 return AArch64::ADDSXri;
2043 case AArch64::ADDWrx:
2044 return AArch64::ADDSWrx;
2045 case AArch64::ADDXrx:
2046 return AArch64::ADDSXrx;
2047 case AArch64::ADCWr:
2048 return AArch64::ADCSWr;
2049 case AArch64::ADCXr:
2050 return AArch64::ADCSXr;
2051 case AArch64::SUBWrr:
2052 return AArch64::SUBSWrr;
2053 case AArch64::SUBWri:
2054 return AArch64::SUBSWri;
2055 case AArch64::SUBXrr:
2056 return AArch64::SUBSXrr;
2057 case AArch64::SUBXri:
2058 return AArch64::SUBSXri;
2059 case AArch64::SUBWrx:
2060 return AArch64::SUBSWrx;
2061 case AArch64::SUBXrx:
2062 return AArch64::SUBSXrx;
2063 case AArch64::SBCWr:
2064 return AArch64::SBCSWr;
2065 case AArch64::SBCXr:
2066 return AArch64::SBCSXr;
2067 case AArch64::ANDWri:
2068 return AArch64::ANDSWri;
2069 case AArch64::ANDXri:
2070 return AArch64::ANDSXri;
2071 case AArch64::ANDWrr:
2072 return AArch64::ANDSWrr;
2073 case AArch64::ANDWrs:
2074 return AArch64::ANDSWrs;
2075 case AArch64::ANDXrr:
2076 return AArch64::ANDSXrr;
2077 case AArch64::ANDXrs:
2078 return AArch64::ANDSXrs;
2079 case AArch64::BICWrr:
2080 return AArch64::BICSWrr;
2081 case AArch64::BICXrr:
2082 return AArch64::BICSXrr;
2083 case AArch64::BICWrs:
2084 return AArch64::BICSWrs;
2085 case AArch64::BICXrs:
2086 return AArch64::BICSXrs;
2092 for (
auto *BB :
MBB->successors())
2093 if (BB->isLiveIn(AArch64::NZCV))
2100int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2102 switch (
Instr.getOpcode()) {
2106 case AArch64::Bcc: {
2107 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2112 case AArch64::CSINVWr:
2113 case AArch64::CSINVXr:
2114 case AArch64::CSINCWr:
2115 case AArch64::CSINCXr:
2116 case AArch64::CSELWr:
2117 case AArch64::CSELXr:
2118 case AArch64::CSNEGWr:
2119 case AArch64::CSNEGXr:
2120 case AArch64::FCSELSrrr:
2121 case AArch64::FCSELDrrr: {
2122 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2134 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2136 Instr.getOperand(CCIdx).
getImm())
2189std::optional<UsedNZCV>
2194 if (
MI.getParent() != CmpParent)
2195 return std::nullopt;
2198 return std::nullopt;
2203 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2206 return std::nullopt;
2211 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2214 return NZCVUsedAfterCmp;
2218 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2222 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2228 case AArch64::ANDSWri:
2229 case AArch64::ANDSWrr:
2230 case AArch64::ANDSWrs:
2231 case AArch64::ANDSXri:
2232 case AArch64::ANDSXrr:
2233 case AArch64::ANDSXrs:
2234 case AArch64::BICSWrr:
2235 case AArch64::BICSXrr:
2236 case AArch64::BICSWrs:
2237 case AArch64::BICSXrs:
2263 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2269 "Caller guarantees that CmpInstr compares with constant 0");
2272 if (!NZVCUsed || NZVCUsed->C)
2295bool AArch64InstrInfo::substituteCmpToZero(
2306 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2313 MI->setDesc(
get(NewOpc));
2318 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2330 assert((CmpValue == 0 || CmpValue == 1) &&
2331 "Only comparisons to 0 or 1 considered for removal!");
2334 unsigned MIOpc =
MI.getOpcode();
2335 if (MIOpc == AArch64::CSINCWr) {
2336 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2337 MI.getOperand(2).getReg() != AArch64::WZR)
2339 }
else if (MIOpc == AArch64::CSINCXr) {
2340 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2341 MI.getOperand(2).getReg() != AArch64::XZR)
2351 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2355 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2357 if (CmpValue && !IsSubsRegImm)
2359 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2364 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2367 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2371 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2374 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2375 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2378 if (MIUsedNZCV.
N && !CmpValue)
2420bool AArch64InstrInfo::removeCmpToZeroOrOne(
2427 SmallVector<MachineInstr *, 4> CCUseInstrs;
2428 bool IsInvertCC =
false;
2436 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2437 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2438 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2439 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2448bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2449 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2450 MI.getOpcode() != AArch64::CATCHRET)
2453 MachineBasicBlock &
MBB = *
MI.getParent();
2455 auto TRI = Subtarget.getRegisterInfo();
2458 if (
MI.getOpcode() == AArch64::CATCHRET) {
2460 const TargetInstrInfo *
TII =
2462 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2467 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2469 FirstEpilogSEH = std::next(FirstEpilogSEH);
2484 if (
M.getStackProtectorGuard() ==
"sysreg") {
2485 const AArch64SysReg::SysReg *SrcReg =
2486 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2494 int Offset =
M.getStackProtectorGuardOffset();
2545 const GlobalValue *GV =
2548 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2554 if (Subtarget.isTargetILP32()) {
2555 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2569 assert(!Subtarget.isTargetILP32() &&
"how can large exist in ILP32?");
2596 if (Subtarget.isTargetILP32()) {
2597 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2620 switch (
MI.getOpcode()) {
2623 case AArch64::MOVZWi:
2624 case AArch64::MOVZXi:
2625 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2626 assert(
MI.getDesc().getNumOperands() == 3 &&
2627 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2631 case AArch64::ANDWri:
2632 return MI.getOperand(1).getReg() == AArch64::WZR;
2633 case AArch64::ANDXri:
2634 return MI.getOperand(1).getReg() == AArch64::XZR;
2635 case TargetOpcode::COPY:
2636 return MI.getOperand(1).getReg() == AArch64::WZR;
2644 switch (
MI.getOpcode()) {
2647 case TargetOpcode::COPY: {
2650 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2651 AArch64::GPR64RegClass.
contains(DstReg));
2653 case AArch64::ORRXrs:
2654 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2655 assert(
MI.getDesc().getNumOperands() == 4 &&
2656 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2660 case AArch64::ADDXri:
2661 if (
MI.getOperand(2).getImm() == 0) {
2662 assert(
MI.getDesc().getNumOperands() == 4 &&
2663 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2674 switch (
MI.getOpcode()) {
2677 case TargetOpcode::COPY: {
2679 return AArch64::FPR128RegClass.contains(DstReg);
2681 case AArch64::ORRv16i8:
2682 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2683 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2684 "invalid ORRv16i8 operands");
2696 case AArch64::LDRWui:
2697 case AArch64::LDRXui:
2698 case AArch64::LDRBui:
2699 case AArch64::LDRHui:
2700 case AArch64::LDRSui:
2701 case AArch64::LDRDui:
2702 case AArch64::LDRQui:
2703 case AArch64::LDR_PXI:
2709 int &FrameIndex)
const {
2713 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2714 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2715 FrameIndex =
MI.getOperand(1).getIndex();
2716 return MI.getOperand(0).getReg();
2725 case AArch64::STRWui:
2726 case AArch64::STRXui:
2727 case AArch64::STRBui:
2728 case AArch64::STRHui:
2729 case AArch64::STRSui:
2730 case AArch64::STRDui:
2731 case AArch64::STRQui:
2732 case AArch64::STR_PXI:
2738 int &FrameIndex)
const {
2742 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2743 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2744 FrameIndex =
MI.getOperand(1).getIndex();
2745 return MI.getOperand(0).getReg();
2751 int &FrameIndex)
const {
2766 return MI.getOperand(0).getReg();
2772 int &FrameIndex)
const {
2787 return MI.getOperand(0).getReg();
2795 return MMO->getFlags() & MOSuppressPair;
2801 if (
MI.memoperands_empty())
2809 return MMO->getFlags() & MOStridedAccess;
2817 case AArch64::STURSi:
2818 case AArch64::STRSpre:
2819 case AArch64::STURDi:
2820 case AArch64::STRDpre:
2821 case AArch64::STURQi:
2822 case AArch64::STRQpre:
2823 case AArch64::STURBBi:
2824 case AArch64::STURHHi:
2825 case AArch64::STURWi:
2826 case AArch64::STRWpre:
2827 case AArch64::STURXi:
2828 case AArch64::STRXpre:
2829 case AArch64::LDURSi:
2830 case AArch64::LDRSpre:
2831 case AArch64::LDURDi:
2832 case AArch64::LDRDpre:
2833 case AArch64::LDURQi:
2834 case AArch64::LDRQpre:
2835 case AArch64::LDURWi:
2836 case AArch64::LDRWpre:
2837 case AArch64::LDURXi:
2838 case AArch64::LDRXpre:
2839 case AArch64::LDRSWpre:
2840 case AArch64::LDURSWi:
2841 case AArch64::LDURHHi:
2842 case AArch64::LDURBBi:
2843 case AArch64::LDURSBWi:
2844 case AArch64::LDURSHWi:
2852 case AArch64::PRFMui:
return AArch64::PRFUMi;
2853 case AArch64::LDRXui:
return AArch64::LDURXi;
2854 case AArch64::LDRWui:
return AArch64::LDURWi;
2855 case AArch64::LDRBui:
return AArch64::LDURBi;
2856 case AArch64::LDRHui:
return AArch64::LDURHi;
2857 case AArch64::LDRSui:
return AArch64::LDURSi;
2858 case AArch64::LDRDui:
return AArch64::LDURDi;
2859 case AArch64::LDRQui:
return AArch64::LDURQi;
2860 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2861 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2862 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2863 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2864 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2865 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2866 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2867 case AArch64::STRXui:
return AArch64::STURXi;
2868 case AArch64::STRWui:
return AArch64::STURWi;
2869 case AArch64::STRBui:
return AArch64::STURBi;
2870 case AArch64::STRHui:
return AArch64::STURHi;
2871 case AArch64::STRSui:
return AArch64::STURSi;
2872 case AArch64::STRDui:
return AArch64::STURDi;
2873 case AArch64::STRQui:
return AArch64::STURQi;
2874 case AArch64::STRBBui:
return AArch64::STURBBi;
2875 case AArch64::STRHHui:
return AArch64::STURHHi;
2884 case AArch64::LDAPURBi:
2885 case AArch64::LDAPURHi:
2886 case AArch64::LDAPURi:
2887 case AArch64::LDAPURSBWi:
2888 case AArch64::LDAPURSBXi:
2889 case AArch64::LDAPURSHWi:
2890 case AArch64::LDAPURSHXi:
2891 case AArch64::LDAPURSWi:
2892 case AArch64::LDAPURXi:
2893 case AArch64::LDR_PPXI:
2894 case AArch64::LDR_PXI:
2895 case AArch64::LDR_ZXI:
2896 case AArch64::LDR_ZZXI:
2897 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
2898 case AArch64::LDR_ZZZXI:
2899 case AArch64::LDR_ZZZZXI:
2900 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
2901 case AArch64::LDRBBui:
2902 case AArch64::LDRBui:
2903 case AArch64::LDRDui:
2904 case AArch64::LDRHHui:
2905 case AArch64::LDRHui:
2906 case AArch64::LDRQui:
2907 case AArch64::LDRSBWui:
2908 case AArch64::LDRSBXui:
2909 case AArch64::LDRSHWui:
2910 case AArch64::LDRSHXui:
2911 case AArch64::LDRSui:
2912 case AArch64::LDRSWui:
2913 case AArch64::LDRWui:
2914 case AArch64::LDRXui:
2915 case AArch64::LDURBBi:
2916 case AArch64::LDURBi:
2917 case AArch64::LDURDi:
2918 case AArch64::LDURHHi:
2919 case AArch64::LDURHi:
2920 case AArch64::LDURQi:
2921 case AArch64::LDURSBWi:
2922 case AArch64::LDURSBXi:
2923 case AArch64::LDURSHWi:
2924 case AArch64::LDURSHXi:
2925 case AArch64::LDURSi:
2926 case AArch64::LDURSWi:
2927 case AArch64::LDURWi:
2928 case AArch64::LDURXi:
2929 case AArch64::PRFMui:
2930 case AArch64::PRFUMi:
2931 case AArch64::ST2Gi:
2933 case AArch64::STLURBi:
2934 case AArch64::STLURHi:
2935 case AArch64::STLURWi:
2936 case AArch64::STLURXi:
2937 case AArch64::StoreSwiftAsyncContext:
2938 case AArch64::STR_PPXI:
2939 case AArch64::STR_PXI:
2940 case AArch64::STR_ZXI:
2941 case AArch64::STR_ZZXI:
2942 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
2943 case AArch64::STR_ZZZXI:
2944 case AArch64::STR_ZZZZXI:
2945 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
2946 case AArch64::STRBBui:
2947 case AArch64::STRBui:
2948 case AArch64::STRDui:
2949 case AArch64::STRHHui:
2950 case AArch64::STRHui:
2951 case AArch64::STRQui:
2952 case AArch64::STRSui:
2953 case AArch64::STRWui:
2954 case AArch64::STRXui:
2955 case AArch64::STURBBi:
2956 case AArch64::STURBi:
2957 case AArch64::STURDi:
2958 case AArch64::STURHHi:
2959 case AArch64::STURHi:
2960 case AArch64::STURQi:
2961 case AArch64::STURSi:
2962 case AArch64::STURWi:
2963 case AArch64::STURXi:
2964 case AArch64::STZ2Gi:
2965 case AArch64::STZGi:
2966 case AArch64::TAGPstack:
2968 case AArch64::LD1B_D_IMM:
2969 case AArch64::LD1B_H_IMM:
2970 case AArch64::LD1B_IMM:
2971 case AArch64::LD1B_S_IMM:
2972 case AArch64::LD1D_IMM:
2973 case AArch64::LD1H_D_IMM:
2974 case AArch64::LD1H_IMM:
2975 case AArch64::LD1H_S_IMM:
2976 case AArch64::LD1RB_D_IMM:
2977 case AArch64::LD1RB_H_IMM:
2978 case AArch64::LD1RB_IMM:
2979 case AArch64::LD1RB_S_IMM:
2980 case AArch64::LD1RD_IMM:
2981 case AArch64::LD1RH_D_IMM:
2982 case AArch64::LD1RH_IMM:
2983 case AArch64::LD1RH_S_IMM:
2984 case AArch64::LD1RSB_D_IMM:
2985 case AArch64::LD1RSB_H_IMM:
2986 case AArch64::LD1RSB_S_IMM:
2987 case AArch64::LD1RSH_D_IMM:
2988 case AArch64::LD1RSH_S_IMM:
2989 case AArch64::LD1RSW_IMM:
2990 case AArch64::LD1RW_D_IMM:
2991 case AArch64::LD1RW_IMM:
2992 case AArch64::LD1SB_D_IMM:
2993 case AArch64::LD1SB_H_IMM:
2994 case AArch64::LD1SB_S_IMM:
2995 case AArch64::LD1SH_D_IMM:
2996 case AArch64::LD1SH_S_IMM:
2997 case AArch64::LD1SW_D_IMM:
2998 case AArch64::LD1W_D_IMM:
2999 case AArch64::LD1W_IMM:
3000 case AArch64::LD2B_IMM:
3001 case AArch64::LD2D_IMM:
3002 case AArch64::LD2H_IMM:
3003 case AArch64::LD2W_IMM:
3004 case AArch64::LD3B_IMM:
3005 case AArch64::LD3D_IMM:
3006 case AArch64::LD3H_IMM:
3007 case AArch64::LD3W_IMM:
3008 case AArch64::LD4B_IMM:
3009 case AArch64::LD4D_IMM:
3010 case AArch64::LD4H_IMM:
3011 case AArch64::LD4W_IMM:
3013 case AArch64::LDNF1B_D_IMM:
3014 case AArch64::LDNF1B_H_IMM:
3015 case AArch64::LDNF1B_IMM:
3016 case AArch64::LDNF1B_S_IMM:
3017 case AArch64::LDNF1D_IMM:
3018 case AArch64::LDNF1H_D_IMM:
3019 case AArch64::LDNF1H_IMM:
3020 case AArch64::LDNF1H_S_IMM:
3021 case AArch64::LDNF1SB_D_IMM:
3022 case AArch64::LDNF1SB_H_IMM:
3023 case AArch64::LDNF1SB_S_IMM:
3024 case AArch64::LDNF1SH_D_IMM:
3025 case AArch64::LDNF1SH_S_IMM:
3026 case AArch64::LDNF1SW_D_IMM:
3027 case AArch64::LDNF1W_D_IMM:
3028 case AArch64::LDNF1W_IMM:
3029 case AArch64::LDNPDi:
3030 case AArch64::LDNPQi:
3031 case AArch64::LDNPSi:
3032 case AArch64::LDNPWi:
3033 case AArch64::LDNPXi:
3034 case AArch64::LDNT1B_ZRI:
3035 case AArch64::LDNT1D_ZRI:
3036 case AArch64::LDNT1H_ZRI:
3037 case AArch64::LDNT1W_ZRI:
3038 case AArch64::LDPDi:
3039 case AArch64::LDPQi:
3040 case AArch64::LDPSi:
3041 case AArch64::LDPWi:
3042 case AArch64::LDPXi:
3043 case AArch64::LDRBBpost:
3044 case AArch64::LDRBBpre:
3045 case AArch64::LDRBpost:
3046 case AArch64::LDRBpre:
3047 case AArch64::LDRDpost:
3048 case AArch64::LDRDpre:
3049 case AArch64::LDRHHpost:
3050 case AArch64::LDRHHpre:
3051 case AArch64::LDRHpost:
3052 case AArch64::LDRHpre:
3053 case AArch64::LDRQpost:
3054 case AArch64::LDRQpre:
3055 case AArch64::LDRSpost:
3056 case AArch64::LDRSpre:
3057 case AArch64::LDRWpost:
3058 case AArch64::LDRWpre:
3059 case AArch64::LDRXpost:
3060 case AArch64::LDRXpre:
3061 case AArch64::ST1B_D_IMM:
3062 case AArch64::ST1B_H_IMM:
3063 case AArch64::ST1B_IMM:
3064 case AArch64::ST1B_S_IMM:
3065 case AArch64::ST1D_IMM:
3066 case AArch64::ST1H_D_IMM:
3067 case AArch64::ST1H_IMM:
3068 case AArch64::ST1H_S_IMM:
3069 case AArch64::ST1W_D_IMM:
3070 case AArch64::ST1W_IMM:
3071 case AArch64::ST2B_IMM:
3072 case AArch64::ST2D_IMM:
3073 case AArch64::ST2H_IMM:
3074 case AArch64::ST2W_IMM:
3075 case AArch64::ST3B_IMM:
3076 case AArch64::ST3D_IMM:
3077 case AArch64::ST3H_IMM:
3078 case AArch64::ST3W_IMM:
3079 case AArch64::ST4B_IMM:
3080 case AArch64::ST4D_IMM:
3081 case AArch64::ST4H_IMM:
3082 case AArch64::ST4W_IMM:
3083 case AArch64::STGPi:
3084 case AArch64::STGPreIndex:
3085 case AArch64::STZGPreIndex:
3086 case AArch64::ST2GPreIndex:
3087 case AArch64::STZ2GPreIndex:
3088 case AArch64::STGPostIndex:
3089 case AArch64::STZGPostIndex:
3090 case AArch64::ST2GPostIndex:
3091 case AArch64::STZ2GPostIndex:
3092 case AArch64::STNPDi:
3093 case AArch64::STNPQi:
3094 case AArch64::STNPSi:
3095 case AArch64::STNPWi:
3096 case AArch64::STNPXi:
3097 case AArch64::STNT1B_ZRI:
3098 case AArch64::STNT1D_ZRI:
3099 case AArch64::STNT1H_ZRI:
3100 case AArch64::STNT1W_ZRI:
3101 case AArch64::STPDi:
3102 case AArch64::STPQi:
3103 case AArch64::STPSi:
3104 case AArch64::STPWi:
3105 case AArch64::STPXi:
3106 case AArch64::STRBBpost:
3107 case AArch64::STRBBpre:
3108 case AArch64::STRBpost:
3109 case AArch64::STRBpre:
3110 case AArch64::STRDpost:
3111 case AArch64::STRDpre:
3112 case AArch64::STRHHpost:
3113 case AArch64::STRHHpre:
3114 case AArch64::STRHpost:
3115 case AArch64::STRHpre:
3116 case AArch64::STRQpost:
3117 case AArch64::STRQpre:
3118 case AArch64::STRSpost:
3119 case AArch64::STRSpre:
3120 case AArch64::STRWpost:
3121 case AArch64::STRWpre:
3122 case AArch64::STRXpost:
3123 case AArch64::STRXpre:
3125 case AArch64::LDPDpost:
3126 case AArch64::LDPDpre:
3127 case AArch64::LDPQpost:
3128 case AArch64::LDPQpre:
3129 case AArch64::LDPSpost:
3130 case AArch64::LDPSpre:
3131 case AArch64::LDPWpost:
3132 case AArch64::LDPWpre:
3133 case AArch64::LDPXpost:
3134 case AArch64::LDPXpre:
3135 case AArch64::STGPpre:
3136 case AArch64::STGPpost:
3137 case AArch64::STPDpost:
3138 case AArch64::STPDpre:
3139 case AArch64::STPQpost:
3140 case AArch64::STPQpre:
3141 case AArch64::STPSpost:
3142 case AArch64::STPSpre:
3143 case AArch64::STPWpost:
3144 case AArch64::STPWpre:
3145 case AArch64::STPXpost:
3146 case AArch64::STPXpre:
3152 switch (
MI.getOpcode()) {
3156 case AArch64::STRSui:
3157 case AArch64::STRDui:
3158 case AArch64::STRQui:
3159 case AArch64::STRXui:
3160 case AArch64::STRWui:
3161 case AArch64::LDRSui:
3162 case AArch64::LDRDui:
3163 case AArch64::LDRQui:
3164 case AArch64::LDRXui:
3165 case AArch64::LDRWui:
3166 case AArch64::LDRSWui:
3168 case AArch64::STURSi:
3169 case AArch64::STRSpre:
3170 case AArch64::STURDi:
3171 case AArch64::STRDpre:
3172 case AArch64::STURQi:
3173 case AArch64::STRQpre:
3174 case AArch64::STURWi:
3175 case AArch64::STRWpre:
3176 case AArch64::STURXi:
3177 case AArch64::STRXpre:
3178 case AArch64::LDURSi:
3179 case AArch64::LDRSpre:
3180 case AArch64::LDURDi:
3181 case AArch64::LDRDpre:
3182 case AArch64::LDURQi:
3183 case AArch64::LDRQpre:
3184 case AArch64::LDURWi:
3185 case AArch64::LDRWpre:
3186 case AArch64::LDURXi:
3187 case AArch64::LDRXpre:
3188 case AArch64::LDURSWi:
3189 case AArch64::LDRSWpre:
3191 case AArch64::LDR_ZXI:
3192 case AArch64::STR_ZXI:
3198 switch (
MI.getOpcode()) {
3201 "Unexpected instruction - was a new tail call opcode introduced?");
3203 case AArch64::TCRETURNdi:
3204 case AArch64::TCRETURNri:
3205 case AArch64::TCRETURNrix16x17:
3206 case AArch64::TCRETURNrix17:
3207 case AArch64::TCRETURNrinotx16:
3208 case AArch64::TCRETURNriALL:
3209 case AArch64::AUTH_TCRETURN:
3210 case AArch64::AUTH_TCRETURN_BTI:
3220 case AArch64::ADDWri:
3221 return AArch64::ADDSWri;
3222 case AArch64::ADDWrr:
3223 return AArch64::ADDSWrr;
3224 case AArch64::ADDWrs:
3225 return AArch64::ADDSWrs;
3226 case AArch64::ADDWrx:
3227 return AArch64::ADDSWrx;
3228 case AArch64::ANDWri:
3229 return AArch64::ANDSWri;
3230 case AArch64::ANDWrr:
3231 return AArch64::ANDSWrr;
3232 case AArch64::ANDWrs:
3233 return AArch64::ANDSWrs;
3234 case AArch64::BICWrr:
3235 return AArch64::BICSWrr;
3236 case AArch64::BICWrs:
3237 return AArch64::BICSWrs;
3238 case AArch64::SUBWri:
3239 return AArch64::SUBSWri;
3240 case AArch64::SUBWrr:
3241 return AArch64::SUBSWrr;
3242 case AArch64::SUBWrs:
3243 return AArch64::SUBSWrs;
3244 case AArch64::SUBWrx:
3245 return AArch64::SUBSWrx;
3247 case AArch64::ADDXri:
3248 return AArch64::ADDSXri;
3249 case AArch64::ADDXrr:
3250 return AArch64::ADDSXrr;
3251 case AArch64::ADDXrs:
3252 return AArch64::ADDSXrs;
3253 case AArch64::ADDXrx:
3254 return AArch64::ADDSXrx;
3255 case AArch64::ANDXri:
3256 return AArch64::ANDSXri;
3257 case AArch64::ANDXrr:
3258 return AArch64::ANDSXrr;
3259 case AArch64::ANDXrs:
3260 return AArch64::ANDSXrs;
3261 case AArch64::BICXrr:
3262 return AArch64::BICSXrr;
3263 case AArch64::BICXrs:
3264 return AArch64::BICSXrs;
3265 case AArch64::SUBXri:
3266 return AArch64::SUBSXri;
3267 case AArch64::SUBXrr:
3268 return AArch64::SUBSXrr;
3269 case AArch64::SUBXrs:
3270 return AArch64::SUBSXrs;
3271 case AArch64::SUBXrx:
3272 return AArch64::SUBSXrx;
3274 case AArch64::AND_PPzPP:
3275 return AArch64::ANDS_PPzPP;
3276 case AArch64::BIC_PPzPP:
3277 return AArch64::BICS_PPzPP;
3278 case AArch64::EOR_PPzPP:
3279 return AArch64::EORS_PPzPP;
3280 case AArch64::NAND_PPzPP:
3281 return AArch64::NANDS_PPzPP;
3282 case AArch64::NOR_PPzPP:
3283 return AArch64::NORS_PPzPP;
3284 case AArch64::ORN_PPzPP:
3285 return AArch64::ORNS_PPzPP;
3286 case AArch64::ORR_PPzPP:
3287 return AArch64::ORRS_PPzPP;
3288 case AArch64::BRKA_PPzP:
3289 return AArch64::BRKAS_PPzP;
3290 case AArch64::BRKPA_PPzPP:
3291 return AArch64::BRKPAS_PPzPP;
3292 case AArch64::BRKB_PPzP:
3293 return AArch64::BRKBS_PPzP;
3294 case AArch64::BRKPB_PPzPP:
3295 return AArch64::BRKPBS_PPzPP;
3296 case AArch64::BRKN_PPzP:
3297 return AArch64::BRKNS_PPzP;
3298 case AArch64::RDFFR_PPz:
3299 return AArch64::RDFFRS_PPz;
3300 case AArch64::PTRUE_B:
3301 return AArch64::PTRUES_B;
3312 if (
MI.hasOrderedMemoryRef())
3317 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3318 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3319 "Expected a reg or frame index operand.");
3323 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3325 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3338 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3339 Register BaseReg =
MI.getOperand(1).getReg();
3341 if (
MI.modifiesRegister(BaseReg,
TRI))
3347 switch (
MI.getOpcode()) {
3350 case AArch64::LDR_ZXI:
3351 case AArch64::STR_ZXI:
3352 if (!Subtarget.isLittleEndian() ||
3353 Subtarget.getSVEVectorSizeInBits() != 128)
3366 const MCAsmInfo *MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3368 MI.getMF()->getFunction().needsUnwindTableEntry();
3374 if (Subtarget.isPaired128Slow()) {
3375 switch (
MI.getOpcode()) {
3378 case AArch64::LDURQi:
3379 case AArch64::STURQi:
3380 case AArch64::LDRQui:
3381 case AArch64::STRQui:
3408std::optional<ExtAddrMode>
3413 bool OffsetIsScalable;
3414 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3415 return std::nullopt;
3418 return std::nullopt;
3433 int64_t OffsetScale = 1;
3438 case AArch64::LDURQi:
3439 case AArch64::STURQi:
3443 case AArch64::LDURDi:
3444 case AArch64::STURDi:
3445 case AArch64::LDURXi:
3446 case AArch64::STURXi:
3450 case AArch64::LDURWi:
3451 case AArch64::LDURSWi:
3452 case AArch64::STURWi:
3456 case AArch64::LDURHi:
3457 case AArch64::STURHi:
3458 case AArch64::LDURHHi:
3459 case AArch64::STURHHi:
3460 case AArch64::LDURSHXi:
3461 case AArch64::LDURSHWi:
3465 case AArch64::LDRBroX:
3466 case AArch64::LDRBBroX:
3467 case AArch64::LDRSBXroX:
3468 case AArch64::LDRSBWroX:
3469 case AArch64::STRBroX:
3470 case AArch64::STRBBroX:
3471 case AArch64::LDURBi:
3472 case AArch64::LDURBBi:
3473 case AArch64::LDURSBXi:
3474 case AArch64::LDURSBWi:
3475 case AArch64::STURBi:
3476 case AArch64::STURBBi:
3477 case AArch64::LDRBui:
3478 case AArch64::LDRBBui:
3479 case AArch64::LDRSBXui:
3480 case AArch64::LDRSBWui:
3481 case AArch64::STRBui:
3482 case AArch64::STRBBui:
3486 case AArch64::LDRQroX:
3487 case AArch64::STRQroX:
3488 case AArch64::LDRQui:
3489 case AArch64::STRQui:
3494 case AArch64::LDRDroX:
3495 case AArch64::STRDroX:
3496 case AArch64::LDRXroX:
3497 case AArch64::STRXroX:
3498 case AArch64::LDRDui:
3499 case AArch64::STRDui:
3500 case AArch64::LDRXui:
3501 case AArch64::STRXui:
3506 case AArch64::LDRWroX:
3507 case AArch64::LDRSWroX:
3508 case AArch64::STRWroX:
3509 case AArch64::LDRWui:
3510 case AArch64::LDRSWui:
3511 case AArch64::STRWui:
3516 case AArch64::LDRHroX:
3517 case AArch64::STRHroX:
3518 case AArch64::LDRHHroX:
3519 case AArch64::STRHHroX:
3520 case AArch64::LDRSHXroX:
3521 case AArch64::LDRSHWroX:
3522 case AArch64::LDRHui:
3523 case AArch64::STRHui:
3524 case AArch64::LDRHHui:
3525 case AArch64::STRHHui:
3526 case AArch64::LDRSHXui:
3527 case AArch64::LDRSHWui:
3535 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3559 case AArch64::SBFMXri:
3572 AM.
Scale = OffsetScale;
3577 case TargetOpcode::SUBREG_TO_REG: {
3593 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3594 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3595 DefMI.getOperand(3).getImm() != 0)
3602 AM.
Scale = OffsetScale;
3613 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3614 int64_t NewOffset) ->
bool {
3615 int64_t MinOffset, MaxOffset;
3632 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3633 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3635 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3637 int64_t NewOffset = OldOffset + Disp;
3638 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3642 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3652 auto canFoldAddRegIntoAddrMode =
3657 if ((
unsigned)Scale != Scale)
3659 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3671 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3672 Subtarget.isSTRQroSlow();
3681 case AArch64::ADDXri:
3687 return canFoldAddSubImmIntoAddrMode(Disp);
3689 case AArch64::SUBXri:
3695 return canFoldAddSubImmIntoAddrMode(-Disp);
3697 case AArch64::ADDXrs: {
3710 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3712 if (avoidSlowSTRQ(MemI))
3715 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3718 case AArch64::ADDXrr:
3726 if (!OptSize && avoidSlowSTRQ(MemI))
3728 return canFoldAddRegIntoAddrMode(1);
3730 case AArch64::ADDXrx:
3738 if (!OptSize && avoidSlowSTRQ(MemI))
3747 return canFoldAddRegIntoAddrMode(
3762 case AArch64::LDURQi:
3763 case AArch64::LDRQui:
3764 return AArch64::LDRQroX;
3765 case AArch64::STURQi:
3766 case AArch64::STRQui:
3767 return AArch64::STRQroX;
3768 case AArch64::LDURDi:
3769 case AArch64::LDRDui:
3770 return AArch64::LDRDroX;
3771 case AArch64::STURDi:
3772 case AArch64::STRDui:
3773 return AArch64::STRDroX;
3774 case AArch64::LDURXi:
3775 case AArch64::LDRXui:
3776 return AArch64::LDRXroX;
3777 case AArch64::STURXi:
3778 case AArch64::STRXui:
3779 return AArch64::STRXroX;
3780 case AArch64::LDURWi:
3781 case AArch64::LDRWui:
3782 return AArch64::LDRWroX;
3783 case AArch64::LDURSWi:
3784 case AArch64::LDRSWui:
3785 return AArch64::LDRSWroX;
3786 case AArch64::STURWi:
3787 case AArch64::STRWui:
3788 return AArch64::STRWroX;
3789 case AArch64::LDURHi:
3790 case AArch64::LDRHui:
3791 return AArch64::LDRHroX;
3792 case AArch64::STURHi:
3793 case AArch64::STRHui:
3794 return AArch64::STRHroX;
3795 case AArch64::LDURHHi:
3796 case AArch64::LDRHHui:
3797 return AArch64::LDRHHroX;
3798 case AArch64::STURHHi:
3799 case AArch64::STRHHui:
3800 return AArch64::STRHHroX;
3801 case AArch64::LDURSHXi:
3802 case AArch64::LDRSHXui:
3803 return AArch64::LDRSHXroX;
3804 case AArch64::LDURSHWi:
3805 case AArch64::LDRSHWui:
3806 return AArch64::LDRSHWroX;
3807 case AArch64::LDURBi:
3808 case AArch64::LDRBui:
3809 return AArch64::LDRBroX;
3810 case AArch64::LDURBBi:
3811 case AArch64::LDRBBui:
3812 return AArch64::LDRBBroX;
3813 case AArch64::LDURSBXi:
3814 case AArch64::LDRSBXui:
3815 return AArch64::LDRSBXroX;
3816 case AArch64::LDURSBWi:
3817 case AArch64::LDRSBWui:
3818 return AArch64::LDRSBWroX;
3819 case AArch64::STURBi:
3820 case AArch64::STRBui:
3821 return AArch64::STRBroX;
3822 case AArch64::STURBBi:
3823 case AArch64::STRBBui:
3824 return AArch64::STRBBroX;
3836 case AArch64::LDURQi:
3838 return AArch64::LDRQui;
3839 case AArch64::STURQi:
3841 return AArch64::STRQui;
3842 case AArch64::LDURDi:
3844 return AArch64::LDRDui;
3845 case AArch64::STURDi:
3847 return AArch64::STRDui;
3848 case AArch64::LDURXi:
3850 return AArch64::LDRXui;
3851 case AArch64::STURXi:
3853 return AArch64::STRXui;
3854 case AArch64::LDURWi:
3856 return AArch64::LDRWui;
3857 case AArch64::LDURSWi:
3859 return AArch64::LDRSWui;
3860 case AArch64::STURWi:
3862 return AArch64::STRWui;
3863 case AArch64::LDURHi:
3865 return AArch64::LDRHui;
3866 case AArch64::STURHi:
3868 return AArch64::STRHui;
3869 case AArch64::LDURHHi:
3871 return AArch64::LDRHHui;
3872 case AArch64::STURHHi:
3874 return AArch64::STRHHui;
3875 case AArch64::LDURSHXi:
3877 return AArch64::LDRSHXui;
3878 case AArch64::LDURSHWi:
3880 return AArch64::LDRSHWui;
3881 case AArch64::LDURBi:
3883 return AArch64::LDRBui;
3884 case AArch64::LDURBBi:
3886 return AArch64::LDRBBui;
3887 case AArch64::LDURSBXi:
3889 return AArch64::LDRSBXui;
3890 case AArch64::LDURSBWi:
3892 return AArch64::LDRSBWui;
3893 case AArch64::STURBi:
3895 return AArch64::STRBui;
3896 case AArch64::STURBBi:
3898 return AArch64::STRBBui;
3899 case AArch64::LDRQui:
3900 case AArch64::STRQui:
3903 case AArch64::LDRDui:
3904 case AArch64::STRDui:
3905 case AArch64::LDRXui:
3906 case AArch64::STRXui:
3909 case AArch64::LDRWui:
3910 case AArch64::LDRSWui:
3911 case AArch64::STRWui:
3914 case AArch64::LDRHui:
3915 case AArch64::STRHui:
3916 case AArch64::LDRHHui:
3917 case AArch64::STRHHui:
3918 case AArch64::LDRSHXui:
3919 case AArch64::LDRSHWui:
3922 case AArch64::LDRBui:
3923 case AArch64::LDRBBui:
3924 case AArch64::LDRSBXui:
3925 case AArch64::LDRSBWui:
3926 case AArch64::STRBui:
3927 case AArch64::STRBBui:
3941 case AArch64::LDURQi:
3942 case AArch64::STURQi:
3943 case AArch64::LDURDi:
3944 case AArch64::STURDi:
3945 case AArch64::LDURXi:
3946 case AArch64::STURXi:
3947 case AArch64::LDURWi:
3948 case AArch64::LDURSWi:
3949 case AArch64::STURWi:
3950 case AArch64::LDURHi:
3951 case AArch64::STURHi:
3952 case AArch64::LDURHHi:
3953 case AArch64::STURHHi:
3954 case AArch64::LDURSHXi:
3955 case AArch64::LDURSHWi:
3956 case AArch64::LDURBi:
3957 case AArch64::STURBi:
3958 case AArch64::LDURBBi:
3959 case AArch64::STURBBi:
3960 case AArch64::LDURSBWi:
3961 case AArch64::LDURSBXi:
3963 case AArch64::LDRQui:
3964 return AArch64::LDURQi;
3965 case AArch64::STRQui:
3966 return AArch64::STURQi;
3967 case AArch64::LDRDui:
3968 return AArch64::LDURDi;
3969 case AArch64::STRDui:
3970 return AArch64::STURDi;
3971 case AArch64::LDRXui:
3972 return AArch64::LDURXi;
3973 case AArch64::STRXui:
3974 return AArch64::STURXi;
3975 case AArch64::LDRWui:
3976 return AArch64::LDURWi;
3977 case AArch64::LDRSWui:
3978 return AArch64::LDURSWi;
3979 case AArch64::STRWui:
3980 return AArch64::STURWi;
3981 case AArch64::LDRHui:
3982 return AArch64::LDURHi;
3983 case AArch64::STRHui:
3984 return AArch64::STURHi;
3985 case AArch64::LDRHHui:
3986 return AArch64::LDURHHi;
3987 case AArch64::STRHHui:
3988 return AArch64::STURHHi;
3989 case AArch64::LDRSHXui:
3990 return AArch64::LDURSHXi;
3991 case AArch64::LDRSHWui:
3992 return AArch64::LDURSHWi;
3993 case AArch64::LDRBBui:
3994 return AArch64::LDURBBi;
3995 case AArch64::LDRBui:
3996 return AArch64::LDURBi;
3997 case AArch64::STRBBui:
3998 return AArch64::STURBBi;
3999 case AArch64::STRBui:
4000 return AArch64::STURBi;
4001 case AArch64::LDRSBWui:
4002 return AArch64::LDURSBWi;
4003 case AArch64::LDRSBXui:
4004 return AArch64::LDURSBXi;
4017 case AArch64::LDRQroX:
4018 case AArch64::LDURQi:
4019 case AArch64::LDRQui:
4020 return AArch64::LDRQroW;
4021 case AArch64::STRQroX:
4022 case AArch64::STURQi:
4023 case AArch64::STRQui:
4024 return AArch64::STRQroW;
4025 case AArch64::LDRDroX:
4026 case AArch64::LDURDi:
4027 case AArch64::LDRDui:
4028 return AArch64::LDRDroW;
4029 case AArch64::STRDroX:
4030 case AArch64::STURDi:
4031 case AArch64::STRDui:
4032 return AArch64::STRDroW;
4033 case AArch64::LDRXroX:
4034 case AArch64::LDURXi:
4035 case AArch64::LDRXui:
4036 return AArch64::LDRXroW;
4037 case AArch64::STRXroX:
4038 case AArch64::STURXi:
4039 case AArch64::STRXui:
4040 return AArch64::STRXroW;
4041 case AArch64::LDRWroX:
4042 case AArch64::LDURWi:
4043 case AArch64::LDRWui:
4044 return AArch64::LDRWroW;
4045 case AArch64::LDRSWroX:
4046 case AArch64::LDURSWi:
4047 case AArch64::LDRSWui:
4048 return AArch64::LDRSWroW;
4049 case AArch64::STRWroX:
4050 case AArch64::STURWi:
4051 case AArch64::STRWui:
4052 return AArch64::STRWroW;
4053 case AArch64::LDRHroX:
4054 case AArch64::LDURHi:
4055 case AArch64::LDRHui:
4056 return AArch64::LDRHroW;
4057 case AArch64::STRHroX:
4058 case AArch64::STURHi:
4059 case AArch64::STRHui:
4060 return AArch64::STRHroW;
4061 case AArch64::LDRHHroX:
4062 case AArch64::LDURHHi:
4063 case AArch64::LDRHHui:
4064 return AArch64::LDRHHroW;
4065 case AArch64::STRHHroX:
4066 case AArch64::STURHHi:
4067 case AArch64::STRHHui:
4068 return AArch64::STRHHroW;
4069 case AArch64::LDRSHXroX:
4070 case AArch64::LDURSHXi:
4071 case AArch64::LDRSHXui:
4072 return AArch64::LDRSHXroW;
4073 case AArch64::LDRSHWroX:
4074 case AArch64::LDURSHWi:
4075 case AArch64::LDRSHWui:
4076 return AArch64::LDRSHWroW;
4077 case AArch64::LDRBroX:
4078 case AArch64::LDURBi:
4079 case AArch64::LDRBui:
4080 return AArch64::LDRBroW;
4081 case AArch64::LDRBBroX:
4082 case AArch64::LDURBBi:
4083 case AArch64::LDRBBui:
4084 return AArch64::LDRBBroW;
4085 case AArch64::LDRSBXroX:
4086 case AArch64::LDURSBXi:
4087 case AArch64::LDRSBXui:
4088 return AArch64::LDRSBXroW;
4089 case AArch64::LDRSBWroX:
4090 case AArch64::LDURSBWi:
4091 case AArch64::LDRSBWui:
4092 return AArch64::LDRSBWroW;
4093 case AArch64::STRBroX:
4094 case AArch64::STURBi:
4095 case AArch64::STRBui:
4096 return AArch64::STRBroW;
4097 case AArch64::STRBBroX:
4098 case AArch64::STURBBi:
4099 case AArch64::STRBBui:
4100 return AArch64::STRBBroW;
4125 return B.getInstr();
4129 "Addressing mode not supported for folding");
4146 return B.getInstr();
4153 "Address offset can be a register or an immediate, but not both");
4174 return B.getInstr();
4178 "Function must not be called with an addressing mode it can't handle");
4187 case AArch64::LD1Fourv16b_POST:
4188 case AArch64::LD1Fourv1d_POST:
4189 case AArch64::LD1Fourv2d_POST:
4190 case AArch64::LD1Fourv2s_POST:
4191 case AArch64::LD1Fourv4h_POST:
4192 case AArch64::LD1Fourv4s_POST:
4193 case AArch64::LD1Fourv8b_POST:
4194 case AArch64::LD1Fourv8h_POST:
4195 case AArch64::LD1Onev16b_POST:
4196 case AArch64::LD1Onev1d_POST:
4197 case AArch64::LD1Onev2d_POST:
4198 case AArch64::LD1Onev2s_POST:
4199 case AArch64::LD1Onev4h_POST:
4200 case AArch64::LD1Onev4s_POST:
4201 case AArch64::LD1Onev8b_POST:
4202 case AArch64::LD1Onev8h_POST:
4203 case AArch64::LD1Rv16b_POST:
4204 case AArch64::LD1Rv1d_POST:
4205 case AArch64::LD1Rv2d_POST:
4206 case AArch64::LD1Rv2s_POST:
4207 case AArch64::LD1Rv4h_POST:
4208 case AArch64::LD1Rv4s_POST:
4209 case AArch64::LD1Rv8b_POST:
4210 case AArch64::LD1Rv8h_POST:
4211 case AArch64::LD1Threev16b_POST:
4212 case AArch64::LD1Threev1d_POST:
4213 case AArch64::LD1Threev2d_POST:
4214 case AArch64::LD1Threev2s_POST:
4215 case AArch64::LD1Threev4h_POST:
4216 case AArch64::LD1Threev4s_POST:
4217 case AArch64::LD1Threev8b_POST:
4218 case AArch64::LD1Threev8h_POST:
4219 case AArch64::LD1Twov16b_POST:
4220 case AArch64::LD1Twov1d_POST:
4221 case AArch64::LD1Twov2d_POST:
4222 case AArch64::LD1Twov2s_POST:
4223 case AArch64::LD1Twov4h_POST:
4224 case AArch64::LD1Twov4s_POST:
4225 case AArch64::LD1Twov8b_POST:
4226 case AArch64::LD1Twov8h_POST:
4227 case AArch64::LD1i16_POST:
4228 case AArch64::LD1i32_POST:
4229 case AArch64::LD1i64_POST:
4230 case AArch64::LD1i8_POST:
4231 case AArch64::LD2Rv16b_POST:
4232 case AArch64::LD2Rv1d_POST:
4233 case AArch64::LD2Rv2d_POST:
4234 case AArch64::LD2Rv2s_POST:
4235 case AArch64::LD2Rv4h_POST:
4236 case AArch64::LD2Rv4s_POST:
4237 case AArch64::LD2Rv8b_POST:
4238 case AArch64::LD2Rv8h_POST:
4239 case AArch64::LD2Twov16b_POST:
4240 case AArch64::LD2Twov2d_POST:
4241 case AArch64::LD2Twov2s_POST:
4242 case AArch64::LD2Twov4h_POST:
4243 case AArch64::LD2Twov4s_POST:
4244 case AArch64::LD2Twov8b_POST:
4245 case AArch64::LD2Twov8h_POST:
4246 case AArch64::LD2i16_POST:
4247 case AArch64::LD2i32_POST:
4248 case AArch64::LD2i64_POST:
4249 case AArch64::LD2i8_POST:
4250 case AArch64::LD3Rv16b_POST:
4251 case AArch64::LD3Rv1d_POST:
4252 case AArch64::LD3Rv2d_POST:
4253 case AArch64::LD3Rv2s_POST:
4254 case AArch64::LD3Rv4h_POST:
4255 case AArch64::LD3Rv4s_POST:
4256 case AArch64::LD3Rv8b_POST:
4257 case AArch64::LD3Rv8h_POST:
4258 case AArch64::LD3Threev16b_POST:
4259 case AArch64::LD3Threev2d_POST:
4260 case AArch64::LD3Threev2s_POST:
4261 case AArch64::LD3Threev4h_POST:
4262 case AArch64::LD3Threev4s_POST:
4263 case AArch64::LD3Threev8b_POST:
4264 case AArch64::LD3Threev8h_POST:
4265 case AArch64::LD3i16_POST:
4266 case AArch64::LD3i32_POST:
4267 case AArch64::LD3i64_POST:
4268 case AArch64::LD3i8_POST:
4269 case AArch64::LD4Fourv16b_POST:
4270 case AArch64::LD4Fourv2d_POST:
4271 case AArch64::LD4Fourv2s_POST:
4272 case AArch64::LD4Fourv4h_POST:
4273 case AArch64::LD4Fourv4s_POST:
4274 case AArch64::LD4Fourv8b_POST:
4275 case AArch64::LD4Fourv8h_POST:
4276 case AArch64::LD4Rv16b_POST:
4277 case AArch64::LD4Rv1d_POST:
4278 case AArch64::LD4Rv2d_POST:
4279 case AArch64::LD4Rv2s_POST:
4280 case AArch64::LD4Rv4h_POST:
4281 case AArch64::LD4Rv4s_POST:
4282 case AArch64::LD4Rv8b_POST:
4283 case AArch64::LD4Rv8h_POST:
4284 case AArch64::LD4i16_POST:
4285 case AArch64::LD4i32_POST:
4286 case AArch64::LD4i64_POST:
4287 case AArch64::LD4i8_POST:
4288 case AArch64::LDAPRWpost:
4289 case AArch64::LDAPRXpost:
4290 case AArch64::LDIAPPWpost:
4291 case AArch64::LDIAPPXpost:
4292 case AArch64::LDPDpost:
4293 case AArch64::LDPQpost:
4294 case AArch64::LDPSWpost:
4295 case AArch64::LDPSpost:
4296 case AArch64::LDPWpost:
4297 case AArch64::LDPXpost:
4298 case AArch64::LDRBBpost:
4299 case AArch64::LDRBpost:
4300 case AArch64::LDRDpost:
4301 case AArch64::LDRHHpost:
4302 case AArch64::LDRHpost:
4303 case AArch64::LDRQpost:
4304 case AArch64::LDRSBWpost:
4305 case AArch64::LDRSBXpost:
4306 case AArch64::LDRSHWpost:
4307 case AArch64::LDRSHXpost:
4308 case AArch64::LDRSWpost:
4309 case AArch64::LDRSpost:
4310 case AArch64::LDRWpost:
4311 case AArch64::LDRXpost:
4312 case AArch64::ST1Fourv16b_POST:
4313 case AArch64::ST1Fourv1d_POST:
4314 case AArch64::ST1Fourv2d_POST:
4315 case AArch64::ST1Fourv2s_POST:
4316 case AArch64::ST1Fourv4h_POST:
4317 case AArch64::ST1Fourv4s_POST:
4318 case AArch64::ST1Fourv8b_POST:
4319 case AArch64::ST1Fourv8h_POST:
4320 case AArch64::ST1Onev16b_POST:
4321 case AArch64::ST1Onev1d_POST:
4322 case AArch64::ST1Onev2d_POST:
4323 case AArch64::ST1Onev2s_POST:
4324 case AArch64::ST1Onev4h_POST:
4325 case AArch64::ST1Onev4s_POST:
4326 case AArch64::ST1Onev8b_POST:
4327 case AArch64::ST1Onev8h_POST:
4328 case AArch64::ST1Threev16b_POST:
4329 case AArch64::ST1Threev1d_POST:
4330 case AArch64::ST1Threev2d_POST:
4331 case AArch64::ST1Threev2s_POST:
4332 case AArch64::ST1Threev4h_POST:
4333 case AArch64::ST1Threev4s_POST:
4334 case AArch64::ST1Threev8b_POST:
4335 case AArch64::ST1Threev8h_POST:
4336 case AArch64::ST1Twov16b_POST:
4337 case AArch64::ST1Twov1d_POST:
4338 case AArch64::ST1Twov2d_POST:
4339 case AArch64::ST1Twov2s_POST:
4340 case AArch64::ST1Twov4h_POST:
4341 case AArch64::ST1Twov4s_POST:
4342 case AArch64::ST1Twov8b_POST:
4343 case AArch64::ST1Twov8h_POST:
4344 case AArch64::ST1i16_POST:
4345 case AArch64::ST1i32_POST:
4346 case AArch64::ST1i64_POST:
4347 case AArch64::ST1i8_POST:
4348 case AArch64::ST2GPostIndex:
4349 case AArch64::ST2Twov16b_POST:
4350 case AArch64::ST2Twov2d_POST:
4351 case AArch64::ST2Twov2s_POST:
4352 case AArch64::ST2Twov4h_POST:
4353 case AArch64::ST2Twov4s_POST:
4354 case AArch64::ST2Twov8b_POST:
4355 case AArch64::ST2Twov8h_POST:
4356 case AArch64::ST2i16_POST:
4357 case AArch64::ST2i32_POST:
4358 case AArch64::ST2i64_POST:
4359 case AArch64::ST2i8_POST:
4360 case AArch64::ST3Threev16b_POST:
4361 case AArch64::ST3Threev2d_POST:
4362 case AArch64::ST3Threev2s_POST:
4363 case AArch64::ST3Threev4h_POST:
4364 case AArch64::ST3Threev4s_POST:
4365 case AArch64::ST3Threev8b_POST:
4366 case AArch64::ST3Threev8h_POST:
4367 case AArch64::ST3i16_POST:
4368 case AArch64::ST3i32_POST:
4369 case AArch64::ST3i64_POST:
4370 case AArch64::ST3i8_POST:
4371 case AArch64::ST4Fourv16b_POST:
4372 case AArch64::ST4Fourv2d_POST:
4373 case AArch64::ST4Fourv2s_POST:
4374 case AArch64::ST4Fourv4h_POST:
4375 case AArch64::ST4Fourv4s_POST:
4376 case AArch64::ST4Fourv8b_POST:
4377 case AArch64::ST4Fourv8h_POST:
4378 case AArch64::ST4i16_POST:
4379 case AArch64::ST4i32_POST:
4380 case AArch64::ST4i64_POST:
4381 case AArch64::ST4i8_POST:
4382 case AArch64::STGPostIndex:
4383 case AArch64::STGPpost:
4384 case AArch64::STPDpost:
4385 case AArch64::STPQpost:
4386 case AArch64::STPSpost:
4387 case AArch64::STPWpost:
4388 case AArch64::STPXpost:
4389 case AArch64::STRBBpost:
4390 case AArch64::STRBpost:
4391 case AArch64::STRDpost:
4392 case AArch64::STRHHpost:
4393 case AArch64::STRHpost:
4394 case AArch64::STRQpost:
4395 case AArch64::STRSpost:
4396 case AArch64::STRWpost:
4397 case AArch64::STRXpost:
4398 case AArch64::STZ2GPostIndex:
4399 case AArch64::STZGPostIndex:
4406 bool &OffsetIsScalable,
TypeSize &Width,
4427 int64_t Dummy1, Dummy2;
4449 return BaseOp->
isReg() || BaseOp->
isFI();
4456 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4461 TypeSize &Width, int64_t &MinOffset,
4462 int64_t &MaxOffset) {
4468 MinOffset = MaxOffset = 0;
4471 case AArch64::LDRQui:
4472 case AArch64::STRQui:
4478 case AArch64::LDRXui:
4479 case AArch64::LDRDui:
4480 case AArch64::STRXui:
4481 case AArch64::STRDui:
4482 case AArch64::PRFMui:
4488 case AArch64::LDRWui:
4489 case AArch64::LDRSui:
4490 case AArch64::LDRSWui:
4491 case AArch64::STRWui:
4492 case AArch64::STRSui:
4498 case AArch64::LDRHui:
4499 case AArch64::LDRHHui:
4500 case AArch64::LDRSHWui:
4501 case AArch64::LDRSHXui:
4502 case AArch64::STRHui:
4503 case AArch64::STRHHui:
4509 case AArch64::LDRBui:
4510 case AArch64::LDRBBui:
4511 case AArch64::LDRSBWui:
4512 case AArch64::LDRSBXui:
4513 case AArch64::STRBui:
4514 case AArch64::STRBBui:
4521 case AArch64::STRQpre:
4522 case AArch64::LDRQpost:
4528 case AArch64::LDRDpost:
4529 case AArch64::LDRDpre:
4530 case AArch64::LDRXpost:
4531 case AArch64::LDRXpre:
4532 case AArch64::STRDpost:
4533 case AArch64::STRDpre:
4534 case AArch64::STRXpost:
4535 case AArch64::STRXpre:
4541 case AArch64::STRWpost:
4542 case AArch64::STRWpre:
4543 case AArch64::LDRWpost:
4544 case AArch64::LDRWpre:
4545 case AArch64::STRSpost:
4546 case AArch64::STRSpre:
4547 case AArch64::LDRSpost:
4548 case AArch64::LDRSpre:
4554 case AArch64::LDRHpost:
4555 case AArch64::LDRHpre:
4556 case AArch64::STRHpost:
4557 case AArch64::STRHpre:
4558 case AArch64::LDRHHpost:
4559 case AArch64::LDRHHpre:
4560 case AArch64::STRHHpost:
4561 case AArch64::STRHHpre:
4567 case AArch64::LDRBpost:
4568 case AArch64::LDRBpre:
4569 case AArch64::STRBpost:
4570 case AArch64::STRBpre:
4571 case AArch64::LDRBBpost:
4572 case AArch64::LDRBBpre:
4573 case AArch64::STRBBpost:
4574 case AArch64::STRBBpre:
4581 case AArch64::LDURQi:
4582 case AArch64::STURQi:
4588 case AArch64::LDURXi:
4589 case AArch64::LDURDi:
4590 case AArch64::LDAPURXi:
4591 case AArch64::STURXi:
4592 case AArch64::STURDi:
4593 case AArch64::STLURXi:
4594 case AArch64::PRFUMi:
4600 case AArch64::LDURWi:
4601 case AArch64::LDURSi:
4602 case AArch64::LDURSWi:
4603 case AArch64::LDAPURi:
4604 case AArch64::LDAPURSWi:
4605 case AArch64::STURWi:
4606 case AArch64::STURSi:
4607 case AArch64::STLURWi:
4613 case AArch64::LDURHi:
4614 case AArch64::LDURHHi:
4615 case AArch64::LDURSHXi:
4616 case AArch64::LDURSHWi:
4617 case AArch64::LDAPURHi:
4618 case AArch64::LDAPURSHWi:
4619 case AArch64::LDAPURSHXi:
4620 case AArch64::STURHi:
4621 case AArch64::STURHHi:
4622 case AArch64::STLURHi:
4628 case AArch64::LDURBi:
4629 case AArch64::LDURBBi:
4630 case AArch64::LDURSBXi:
4631 case AArch64::LDURSBWi:
4632 case AArch64::LDAPURBi:
4633 case AArch64::LDAPURSBWi:
4634 case AArch64::LDAPURSBXi:
4635 case AArch64::STURBi:
4636 case AArch64::STURBBi:
4637 case AArch64::STLURBi:
4644 case AArch64::LDPQi:
4645 case AArch64::LDNPQi:
4646 case AArch64::STPQi:
4647 case AArch64::STNPQi:
4648 case AArch64::LDPQpost:
4649 case AArch64::LDPQpre:
4650 case AArch64::STPQpost:
4651 case AArch64::STPQpre:
4657 case AArch64::LDPXi:
4658 case AArch64::LDPDi:
4659 case AArch64::LDNPXi:
4660 case AArch64::LDNPDi:
4661 case AArch64::STPXi:
4662 case AArch64::STPDi:
4663 case AArch64::STNPXi:
4664 case AArch64::STNPDi:
4665 case AArch64::LDPDpost:
4666 case AArch64::LDPDpre:
4667 case AArch64::LDPXpost:
4668 case AArch64::LDPXpre:
4669 case AArch64::STPDpost:
4670 case AArch64::STPDpre:
4671 case AArch64::STPXpost:
4672 case AArch64::STPXpre:
4678 case AArch64::LDPWi:
4679 case AArch64::LDPSi:
4680 case AArch64::LDNPWi:
4681 case AArch64::LDNPSi:
4682 case AArch64::STPWi:
4683 case AArch64::STPSi:
4684 case AArch64::STNPWi:
4685 case AArch64::STNPSi:
4686 case AArch64::LDPSpost:
4687 case AArch64::LDPSpre:
4688 case AArch64::LDPWpost:
4689 case AArch64::LDPWpre:
4690 case AArch64::STPSpost:
4691 case AArch64::STPSpre:
4692 case AArch64::STPWpost:
4693 case AArch64::STPWpre:
4699 case AArch64::StoreSwiftAsyncContext:
4712 case AArch64::TAGPstack:
4722 case AArch64::STGPreIndex:
4723 case AArch64::STGPostIndex:
4724 case AArch64::STZGi:
4725 case AArch64::STZGPreIndex:
4726 case AArch64::STZGPostIndex:
4733 case AArch64::STR_ZZZZXI:
4734 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4735 case AArch64::LDR_ZZZZXI:
4736 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4742 case AArch64::STR_ZZZXI:
4743 case AArch64::LDR_ZZZXI:
4749 case AArch64::STR_ZZXI:
4750 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4751 case AArch64::LDR_ZZXI:
4752 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4758 case AArch64::LDR_PXI:
4759 case AArch64::STR_PXI:
4765 case AArch64::LDR_PPXI:
4766 case AArch64::STR_PPXI:
4772 case AArch64::LDR_ZXI:
4773 case AArch64::STR_ZXI:
4779 case AArch64::LD1B_IMM:
4780 case AArch64::LD1H_IMM:
4781 case AArch64::LD1W_IMM:
4782 case AArch64::LD1D_IMM:
4783 case AArch64::LDNT1B_ZRI:
4784 case AArch64::LDNT1H_ZRI:
4785 case AArch64::LDNT1W_ZRI:
4786 case AArch64::LDNT1D_ZRI:
4787 case AArch64::ST1B_IMM:
4788 case AArch64::ST1H_IMM:
4789 case AArch64::ST1W_IMM:
4790 case AArch64::ST1D_IMM:
4791 case AArch64::STNT1B_ZRI:
4792 case AArch64::STNT1H_ZRI:
4793 case AArch64::STNT1W_ZRI:
4794 case AArch64::STNT1D_ZRI:
4795 case AArch64::LDNF1B_IMM:
4796 case AArch64::LDNF1H_IMM:
4797 case AArch64::LDNF1W_IMM:
4798 case AArch64::LDNF1D_IMM:
4806 case AArch64::LD2B_IMM:
4807 case AArch64::LD2H_IMM:
4808 case AArch64::LD2W_IMM:
4809 case AArch64::LD2D_IMM:
4810 case AArch64::ST2B_IMM:
4811 case AArch64::ST2H_IMM:
4812 case AArch64::ST2W_IMM:
4813 case AArch64::ST2D_IMM:
4819 case AArch64::LD3B_IMM:
4820 case AArch64::LD3H_IMM:
4821 case AArch64::LD3W_IMM:
4822 case AArch64::LD3D_IMM:
4823 case AArch64::ST3B_IMM:
4824 case AArch64::ST3H_IMM:
4825 case AArch64::ST3W_IMM:
4826 case AArch64::ST3D_IMM:
4832 case AArch64::LD4B_IMM:
4833 case AArch64::LD4H_IMM:
4834 case AArch64::LD4W_IMM:
4835 case AArch64::LD4D_IMM:
4836 case AArch64::ST4B_IMM:
4837 case AArch64::ST4H_IMM:
4838 case AArch64::ST4W_IMM:
4839 case AArch64::ST4D_IMM:
4845 case AArch64::LD1B_H_IMM:
4846 case AArch64::LD1SB_H_IMM:
4847 case AArch64::LD1H_S_IMM:
4848 case AArch64::LD1SH_S_IMM:
4849 case AArch64::LD1W_D_IMM:
4850 case AArch64::LD1SW_D_IMM:
4851 case AArch64::ST1B_H_IMM:
4852 case AArch64::ST1H_S_IMM:
4853 case AArch64::ST1W_D_IMM:
4854 case AArch64::LDNF1B_H_IMM:
4855 case AArch64::LDNF1SB_H_IMM:
4856 case AArch64::LDNF1H_S_IMM:
4857 case AArch64::LDNF1SH_S_IMM:
4858 case AArch64::LDNF1W_D_IMM:
4859 case AArch64::LDNF1SW_D_IMM:
4867 case AArch64::LD1B_S_IMM:
4868 case AArch64::LD1SB_S_IMM:
4869 case AArch64::LD1H_D_IMM:
4870 case AArch64::LD1SH_D_IMM:
4871 case AArch64::ST1B_S_IMM:
4872 case AArch64::ST1H_D_IMM:
4873 case AArch64::LDNF1B_S_IMM:
4874 case AArch64::LDNF1SB_S_IMM:
4875 case AArch64::LDNF1H_D_IMM:
4876 case AArch64::LDNF1SH_D_IMM:
4884 case AArch64::LD1B_D_IMM:
4885 case AArch64::LD1SB_D_IMM:
4886 case AArch64::ST1B_D_IMM:
4887 case AArch64::LDNF1B_D_IMM:
4888 case AArch64::LDNF1SB_D_IMM:
4896 case AArch64::ST2Gi:
4897 case AArch64::ST2GPreIndex:
4898 case AArch64::ST2GPostIndex:
4899 case AArch64::STZ2Gi:
4900 case AArch64::STZ2GPreIndex:
4901 case AArch64::STZ2GPostIndex:
4907 case AArch64::STGPi:
4908 case AArch64::STGPpost:
4909 case AArch64::STGPpre:
4915 case AArch64::LD1RB_IMM:
4916 case AArch64::LD1RB_H_IMM:
4917 case AArch64::LD1RB_S_IMM:
4918 case AArch64::LD1RB_D_IMM:
4919 case AArch64::LD1RSB_H_IMM:
4920 case AArch64::LD1RSB_S_IMM:
4921 case AArch64::LD1RSB_D_IMM:
4927 case AArch64::LD1RH_IMM:
4928 case AArch64::LD1RH_S_IMM:
4929 case AArch64::LD1RH_D_IMM:
4930 case AArch64::LD1RSH_S_IMM:
4931 case AArch64::LD1RSH_D_IMM:
4937 case AArch64::LD1RW_IMM:
4938 case AArch64::LD1RW_D_IMM:
4939 case AArch64::LD1RSW_IMM:
4945 case AArch64::LD1RD_IMM:
4961 case AArch64::LDRBui:
4962 case AArch64::LDRBBui:
4963 case AArch64::LDURBBi:
4964 case AArch64::LDRSBWui:
4965 case AArch64::LDURSBWi:
4966 case AArch64::STRBui:
4967 case AArch64::STRBBui:
4968 case AArch64::STURBBi:
4970 case AArch64::LDRHui:
4971 case AArch64::LDRHHui:
4972 case AArch64::LDURHHi:
4973 case AArch64::LDRSHWui:
4974 case AArch64::LDURSHWi:
4975 case AArch64::STRHui:
4976 case AArch64::STRHHui:
4977 case AArch64::STURHHi:
4979 case AArch64::LDRSui:
4980 case AArch64::LDURSi:
4981 case AArch64::LDRSpre:
4982 case AArch64::LDRSWui:
4983 case AArch64::LDURSWi:
4984 case AArch64::LDRSWpre:
4985 case AArch64::LDRWpre:
4986 case AArch64::LDRWui:
4987 case AArch64::LDURWi:
4988 case AArch64::STRSui:
4989 case AArch64::STURSi:
4990 case AArch64::STRSpre:
4991 case AArch64::STRWui:
4992 case AArch64::STURWi:
4993 case AArch64::STRWpre:
4994 case AArch64::LDPSi:
4995 case AArch64::LDPSWi:
4996 case AArch64::LDPWi:
4997 case AArch64::STPSi:
4998 case AArch64::STPWi:
5000 case AArch64::LDRDui:
5001 case AArch64::LDURDi:
5002 case AArch64::LDRDpre:
5003 case AArch64::LDRXui:
5004 case AArch64::LDURXi:
5005 case AArch64::LDRXpre:
5006 case AArch64::STRDui:
5007 case AArch64::STURDi:
5008 case AArch64::STRDpre:
5009 case AArch64::STRXui:
5010 case AArch64::STURXi:
5011 case AArch64::STRXpre:
5012 case AArch64::LDPDi:
5013 case AArch64::LDPXi:
5014 case AArch64::STPDi:
5015 case AArch64::STPXi:
5017 case AArch64::LDRQui:
5018 case AArch64::LDURQi:
5019 case AArch64::STRQui:
5020 case AArch64::STURQi:
5021 case AArch64::STRQpre:
5022 case AArch64::LDPQi:
5023 case AArch64::LDRQpre:
5024 case AArch64::STPQi:
5026 case AArch64::STZGi:
5027 case AArch64::ST2Gi:
5028 case AArch64::STZ2Gi:
5029 case AArch64::STGPi:
5035 switch (
MI.getOpcode()) {
5038 case AArch64::LDRWpre:
5039 case AArch64::LDRXpre:
5040 case AArch64::LDRSWpre:
5041 case AArch64::LDRSpre:
5042 case AArch64::LDRDpre:
5043 case AArch64::LDRQpre:
5049 switch (
MI.getOpcode()) {
5052 case AArch64::STRWpre:
5053 case AArch64::STRXpre:
5054 case AArch64::STRSpre:
5055 case AArch64::STRDpre:
5056 case AArch64::STRQpre:
5066 switch (
MI.getOpcode()) {
5069 case AArch64::LDURBBi:
5070 case AArch64::LDURHHi:
5071 case AArch64::LDURWi:
5072 case AArch64::LDRBBui:
5073 case AArch64::LDRHHui:
5074 case AArch64::LDRWui:
5075 case AArch64::LDRBBroX:
5076 case AArch64::LDRHHroX:
5077 case AArch64::LDRWroX:
5078 case AArch64::LDRBBroW:
5079 case AArch64::LDRHHroW:
5080 case AArch64::LDRWroW:
5086 switch (
MI.getOpcode()) {
5089 case AArch64::LDURSBWi:
5090 case AArch64::LDURSHWi:
5091 case AArch64::LDURSBXi:
5092 case AArch64::LDURSHXi:
5093 case AArch64::LDURSWi:
5094 case AArch64::LDRSBWui:
5095 case AArch64::LDRSHWui:
5096 case AArch64::LDRSBXui:
5097 case AArch64::LDRSHXui:
5098 case AArch64::LDRSWui:
5099 case AArch64::LDRSBWroX:
5100 case AArch64::LDRSHWroX:
5101 case AArch64::LDRSBXroX:
5102 case AArch64::LDRSHXroX:
5103 case AArch64::LDRSWroX:
5104 case AArch64::LDRSBWroW:
5105 case AArch64::LDRSHWroW:
5106 case AArch64::LDRSBXroW:
5107 case AArch64::LDRSHXroW:
5108 case AArch64::LDRSWroW:
5114 switch (
MI.getOpcode()) {
5117 case AArch64::LDPSi:
5118 case AArch64::LDPSWi:
5119 case AArch64::LDPDi:
5120 case AArch64::LDPQi:
5121 case AArch64::LDPWi:
5122 case AArch64::LDPXi:
5123 case AArch64::STPSi:
5124 case AArch64::STPDi:
5125 case AArch64::STPQi:
5126 case AArch64::STPWi:
5127 case AArch64::STPXi:
5128 case AArch64::STGPi:
5134 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5138 return MI.getOperand(Idx);
5143 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5147 return MI.getOperand(Idx);
5152 switch (
MI.getOpcode()) {
5155 case AArch64::LDRBroX:
5156 case AArch64::LDRBBroX:
5157 case AArch64::LDRSBXroX:
5158 case AArch64::LDRSBWroX:
5159 case AArch64::LDRHroX:
5160 case AArch64::LDRHHroX:
5161 case AArch64::LDRSHXroX:
5162 case AArch64::LDRSHWroX:
5163 case AArch64::LDRWroX:
5164 case AArch64::LDRSroX:
5165 case AArch64::LDRSWroX:
5166 case AArch64::LDRDroX:
5167 case AArch64::LDRXroX:
5168 case AArch64::LDRQroX:
5169 return MI.getOperand(4);
5175 if (
MI.getParent() ==
nullptr)
5185 auto Reg =
Op.getReg();
5186 if (Reg.isPhysical())
5187 return AArch64::FPR16RegClass.contains(Reg);
5189 return TRC == &AArch64::FPR16RegClass ||
5190 TRC == &AArch64::FPR16_loRegClass;
5199 auto Reg =
Op.getReg();
5200 if (Reg.isPhysical())
5201 return AArch64::FPR128RegClass.contains(Reg);
5203 return TRC == &AArch64::FPR128RegClass ||
5204 TRC == &AArch64::FPR128_loRegClass;
5210 switch (
MI.getOpcode()) {
5213 case AArch64::PACIASP:
5214 case AArch64::PACIBSP:
5217 case AArch64::PAUTH_PROLOGUE:
5220 case AArch64::HINT: {
5221 unsigned Imm =
MI.getOperand(0).getImm();
5223 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
5226 if (Imm == 25 || Imm == 27)
5238 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5239 return AArch64::FPR128RegClass.contains(Reg) ||
5240 AArch64::FPR64RegClass.contains(Reg) ||
5241 AArch64::FPR32RegClass.contains(Reg) ||
5242 AArch64::FPR16RegClass.contains(Reg) ||
5243 AArch64::FPR8RegClass.contains(Reg);
5250 auto Reg =
Op.getReg();
5251 if (Reg.isPhysical())
5255 return TRC == &AArch64::FPR128RegClass ||
5256 TRC == &AArch64::FPR128_loRegClass ||
5257 TRC == &AArch64::FPR64RegClass ||
5258 TRC == &AArch64::FPR64_loRegClass ||
5259 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5260 TRC == &AArch64::FPR8RegClass;
5282 if (FirstOpc == SecondOpc)
5288 case AArch64::STRSui:
5289 case AArch64::STURSi:
5290 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5291 case AArch64::STRDui:
5292 case AArch64::STURDi:
5293 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5294 case AArch64::STRQui:
5295 case AArch64::STURQi:
5296 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5297 case AArch64::STRWui:
5298 case AArch64::STURWi:
5299 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5300 case AArch64::STRXui:
5301 case AArch64::STURXi:
5302 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5303 case AArch64::LDRSui:
5304 case AArch64::LDURSi:
5305 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5306 case AArch64::LDRDui:
5307 case AArch64::LDURDi:
5308 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5309 case AArch64::LDRQui:
5310 case AArch64::LDURQi:
5311 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5312 case AArch64::LDRWui:
5313 case AArch64::LDURWi:
5314 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5315 case AArch64::LDRSWui:
5316 case AArch64::LDURSWi:
5317 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5318 case AArch64::LDRXui:
5319 case AArch64::LDURXi:
5320 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5327 int64_t Offset1,
unsigned Opcode1,
int FI2,
5328 int64_t Offset2,
unsigned Opcode2) {
5334 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5337 if (ObjectOffset1 % Scale1 != 0)
5339 ObjectOffset1 /= Scale1;
5341 if (ObjectOffset2 % Scale2 != 0)
5343 ObjectOffset2 /= Scale2;
5344 ObjectOffset1 += Offset1;
5345 ObjectOffset2 += Offset2;
5346 return ObjectOffset1 + 1 == ObjectOffset2;
5358 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5359 unsigned NumBytes)
const {
5369 "Only base registers and frame indices are supported.");
5376 if (ClusterSize > 2)
5383 unsigned FirstOpc = FirstLdSt.
getOpcode();
5384 unsigned SecondOpc = SecondLdSt.
getOpcode();
5404 if (Offset1 > 63 || Offset1 < -64)
5409 if (BaseOp1.
isFI()) {
5411 "Caller should have ordered offsets.");
5416 BaseOp2.
getIndex(), Offset2, SecondOpc);
5419 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5421 return Offset1 + 1 == Offset2;
5431 if (
Reg.isPhysical())
5440 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
5449 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5451 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5452 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5453 unsigned NumRegs = Indices.
size();
5455 int SubReg = 0, End = NumRegs, Incr = 1;
5457 SubReg = NumRegs - 1;
5462 for (; SubReg != End; SubReg += Incr) {
5474 unsigned Opcode,
unsigned ZeroReg,
5477 unsigned NumRegs = Indices.
size();
5480 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5481 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5482 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5483 "GPR reg sequences should not be able to overlap");
5486 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5507 unsigned Opc =
MI.getOpcode();
5508 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5510 int64_t PState =
MI.getOperand(0).getImm();
5511 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5513 return MI.getOperand(1).getImm() == 1;
5532 bool RenamableSrc)
const {
5534 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5535 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5536 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5538 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5539 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5541 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5542 &AArch64::GPR64spRegClass);
5543 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5544 &AArch64::GPR64spRegClass);
5554 ++NumZCRegMoveInstrsGPR;
5560 if (Subtarget.hasZeroCycleRegMoveGPR32())
5561 ++NumZCRegMoveInstrsGPR;
5563 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5564 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5566 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5567 &AArch64::GPR64spRegClass);
5568 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5569 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5570 &AArch64::GPR64spRegClass);
5580 ++NumZCRegMoveInstrsGPR;
5586 if (Subtarget.hasZeroCycleRegMoveGPR32())
5587 ++NumZCRegMoveInstrsGPR;
5593 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5594 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5595 !Subtarget.hasZeroCycleZeroingGPR32()) {
5596 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5597 &AArch64::GPR64spRegClass);
5598 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5602 ++NumZCZeroingInstrsGPR;
5603 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5607 ++NumZCZeroingInstrsGPR;
5616 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5617 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5618 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5624 if (Subtarget.hasZeroCycleRegMoveGPR64())
5625 ++NumZCRegMoveInstrsGPR;
5631 if (Subtarget.hasZeroCycleRegMoveGPR64())
5632 ++NumZCRegMoveInstrsGPR;
5638 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5639 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5643 ++NumZCZeroingInstrsGPR;
5653 if (AArch64::PPRRegClass.
contains(DestReg) &&
5654 AArch64::PPRRegClass.
contains(SrcReg)) {
5655 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5656 "Unexpected SVE register.");
5666 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5667 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5668 if (DestIsPNR || SrcIsPNR) {
5670 return (R - AArch64::PN0) + AArch64::P0;
5675 if (PPRSrcReg != PPRDestReg) {
5687 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5688 AArch64::ZPRRegClass.
contains(SrcReg)) {
5689 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5690 "Unexpected SVE register.");
5698 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5699 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5700 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5701 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5702 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5703 "Unexpected SVE register.");
5704 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5711 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5712 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5713 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5714 "Unexpected SVE register.");
5715 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5723 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5724 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5725 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5726 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5727 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5728 "Unexpected SVE register.");
5729 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5730 AArch64::zsub2, AArch64::zsub3};
5737 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5738 AArch64::DDDDRegClass.
contains(SrcReg)) {
5739 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5740 AArch64::dsub2, AArch64::dsub3};
5747 if (AArch64::DDDRegClass.
contains(DestReg) &&
5748 AArch64::DDDRegClass.
contains(SrcReg)) {
5749 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5757 if (AArch64::DDRegClass.
contains(DestReg) &&
5758 AArch64::DDRegClass.
contains(SrcReg)) {
5759 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
5766 if (AArch64::QQQQRegClass.
contains(DestReg) &&
5767 AArch64::QQQQRegClass.
contains(SrcReg)) {
5768 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5769 AArch64::qsub2, AArch64::qsub3};
5776 if (AArch64::QQQRegClass.
contains(DestReg) &&
5777 AArch64::QQQRegClass.
contains(SrcReg)) {
5778 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5786 if (AArch64::QQRegClass.
contains(DestReg) &&
5787 AArch64::QQRegClass.
contains(SrcReg)) {
5788 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
5794 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
5795 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
5796 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
5798 AArch64::XZR, Indices);
5802 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
5803 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
5804 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
5806 AArch64::WZR, Indices);
5810 if (AArch64::FPR128RegClass.
contains(DestReg) &&
5811 AArch64::FPR128RegClass.
contains(SrcReg)) {
5815 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
5816 !Subtarget.isNeonAvailable()) ||
5820 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
5821 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
5822 }
else if (Subtarget.isNeonAvailable()) {
5826 if (Subtarget.hasZeroCycleRegMoveFPR128())
5827 ++NumZCRegMoveInstrsFPR;
5843 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5844 AArch64::FPR64RegClass.
contains(SrcReg)) {
5845 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5846 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5847 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5849 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
5850 &AArch64::FPR128RegClass);
5851 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
5852 &AArch64::FPR128RegClass);
5861 ++NumZCRegMoveInstrsFPR;
5865 if (Subtarget.hasZeroCycleRegMoveFPR64())
5866 ++NumZCRegMoveInstrsFPR;
5871 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5872 AArch64::FPR32RegClass.
contains(SrcReg)) {
5873 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5874 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5875 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5877 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5878 &AArch64::FPR128RegClass);
5879 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5880 &AArch64::FPR128RegClass);
5889 ++NumZCRegMoveInstrsFPR;
5890 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5891 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5892 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
5893 &AArch64::FPR64RegClass);
5894 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
5895 &AArch64::FPR64RegClass);
5903 ++NumZCRegMoveInstrsFPR;
5907 if (Subtarget.hasZeroCycleRegMoveFPR32())
5908 ++NumZCRegMoveInstrsFPR;
5913 if (AArch64::FPR16RegClass.
contains(DestReg) &&
5914 AArch64::FPR16RegClass.
contains(SrcReg)) {
5915 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5916 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5917 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5919 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5920 &AArch64::FPR128RegClass);
5921 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5922 &AArch64::FPR128RegClass);
5931 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5932 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5933 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5934 &AArch64::FPR64RegClass);
5935 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5936 &AArch64::FPR64RegClass);
5945 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
5946 &AArch64::FPR32RegClass);
5947 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
5948 &AArch64::FPR32RegClass);
5955 if (AArch64::FPR8RegClass.
contains(DestReg) &&
5956 AArch64::FPR8RegClass.
contains(SrcReg)) {
5957 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
5958 !Subtarget.hasZeroCycleRegMoveFPR64() &&
5959 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
5961 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5962 &AArch64::FPR128RegClass);
5963 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5964 &AArch64::FPR128RegClass);
5973 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
5974 !Subtarget.hasZeroCycleRegMoveFPR32()) {
5975 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5976 &AArch64::FPR64RegClass);
5977 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5978 &AArch64::FPR64RegClass);
5987 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
5988 &AArch64::FPR32RegClass);
5989 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
5990 &AArch64::FPR32RegClass);
5998 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5999 AArch64::GPR64RegClass.
contains(SrcReg)) {
6000 if (AArch64::XZR == SrcReg) {
6008 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6009 AArch64::FPR64RegClass.
contains(SrcReg)) {
6015 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6016 AArch64::GPR32RegClass.
contains(SrcReg)) {
6017 if (AArch64::WZR == SrcReg) {
6025 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6026 AArch64::FPR32RegClass.
contains(SrcReg)) {
6032 if (DestReg == AArch64::NZCV) {
6033 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6035 .
addImm(AArch64SysReg::NZCV)
6041 if (SrcReg == AArch64::NZCV) {
6042 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6044 .
addImm(AArch64SysReg::NZCV)
6050 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6061 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6066 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6068 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6081 Register SrcReg,
bool isKill,
int FI,
6096 switch (RI.getSpillSize(*RC)) {
6098 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6099 Opc = AArch64::STRBui;
6102 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6103 Opc = AArch64::STRHui;
6104 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6105 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6106 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6107 "Unexpected register store without SVE store instructions");
6108 Opc = AArch64::STR_PXI;
6114 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6115 Opc = AArch64::STRWui;
6119 assert(SrcReg != AArch64::WSP);
6120 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6121 Opc = AArch64::STRSui;
6122 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6123 Opc = AArch64::STR_PPXI;
6128 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6129 Opc = AArch64::STRXui;
6133 assert(SrcReg != AArch64::SP);
6134 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6135 Opc = AArch64::STRDui;
6136 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6138 get(AArch64::STPWi), SrcReg, isKill,
6139 AArch64::sube32, AArch64::subo32, FI, MMO);
6144 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6145 Opc = AArch64::STRQui;
6146 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6147 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6148 Opc = AArch64::ST1Twov1d;
6150 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6152 get(AArch64::STPXi), SrcReg, isKill,
6153 AArch64::sube64, AArch64::subo64, FI, MMO);
6155 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6156 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6157 "Unexpected register store without SVE store instructions");
6158 Opc = AArch64::STR_ZXI;
6163 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6164 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6165 Opc = AArch64::ST1Threev1d;
6170 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6171 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6172 Opc = AArch64::ST1Fourv1d;
6174 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6175 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6176 Opc = AArch64::ST1Twov2d;
6178 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6179 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6180 "Unexpected register store without SVE store instructions");
6181 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6183 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6184 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6185 "Unexpected register store without SVE store instructions");
6186 Opc = AArch64::STR_ZZXI;
6191 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6192 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6193 Opc = AArch64::ST1Threev2d;
6195 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6196 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6197 "Unexpected register store without SVE store instructions");
6198 Opc = AArch64::STR_ZZZXI;
6203 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6204 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6205 Opc = AArch64::ST1Fourv2d;
6207 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6208 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6209 "Unexpected register store without SVE store instructions");
6210 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6212 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6213 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6214 "Unexpected register store without SVE store instructions");
6215 Opc = AArch64::STR_ZZZZXI;
6220 assert(
Opc &&
"Unknown register class");
6231 MI.addMemOperand(MMO);
6238 Register DestReg,
unsigned SubIdx0,
6239 unsigned SubIdx1,
int FI,
6243 bool IsUndef =
true;
6245 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6247 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6276 switch (
TRI.getSpillSize(*RC)) {
6278 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6279 Opc = AArch64::LDRBui;
6282 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6283 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6284 Opc = AArch64::LDRHui;
6285 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6286 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6287 "Unexpected register load without SVE load instructions");
6290 Opc = AArch64::LDR_PXI;
6296 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6297 Opc = AArch64::LDRWui;
6301 assert(DestReg != AArch64::WSP);
6302 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6303 Opc = AArch64::LDRSui;
6304 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6305 Opc = AArch64::LDR_PPXI;
6310 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6311 Opc = AArch64::LDRXui;
6315 assert(DestReg != AArch64::SP);
6316 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6317 Opc = AArch64::LDRDui;
6318 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6320 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6321 AArch64::subo32, FI, MMO);
6326 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6327 Opc = AArch64::LDRQui;
6328 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6329 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6330 Opc = AArch64::LD1Twov1d;
6332 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6334 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6335 AArch64::subo64, FI, MMO);
6337 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6338 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6339 "Unexpected register load without SVE load instructions");
6340 Opc = AArch64::LDR_ZXI;
6345 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6346 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6347 Opc = AArch64::LD1Threev1d;
6352 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6353 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6354 Opc = AArch64::LD1Fourv1d;
6356 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6357 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6358 Opc = AArch64::LD1Twov2d;
6360 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6361 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6362 "Unexpected register load without SVE load instructions");
6363 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6365 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6366 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6367 "Unexpected register load without SVE load instructions");
6368 Opc = AArch64::LDR_ZZXI;
6373 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6374 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6375 Opc = AArch64::LD1Threev2d;
6377 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6378 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6379 "Unexpected register load without SVE load instructions");
6380 Opc = AArch64::LDR_ZZZXI;
6385 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6386 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6387 Opc = AArch64::LD1Fourv2d;
6389 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6390 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6391 "Unexpected register load without SVE load instructions");
6392 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6394 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6395 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6396 "Unexpected register load without SVE load instructions");
6397 Opc = AArch64::LDR_ZZZZXI;
6403 assert(
Opc &&
"Unknown register class");
6413 MI.addMemOperand(MMO);
6420 UseMI.getIterator()),
6422 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6423 I.readsRegister(AArch64::NZCV, TRI);
6427void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6432 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6439 ByteSized =
Offset.getFixed();
6440 VGSized =
Offset.getScalable() / 2;
6446void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6448 int64_t &NumDataVectors) {
6452 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6454 NumBytes =
Offset.getFixed();
6456 NumPredicateVectors =
Offset.getScalable() / 2;
6461 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6462 NumPredicateVectors > 62) {
6463 NumDataVectors = NumPredicateVectors / 8;
6464 NumPredicateVectors -= NumDataVectors * 8;
6490 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6498 int64_t OffsetFromDefCFA) {
6512 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6513 if (!RegScale.empty())
6523 int64_t NumBytes, NumVGScaledBytes;
6524 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6526 std::string CommentBuffer;
6529 if (
Reg == AArch64::SP)
6531 else if (
Reg == AArch64::FP)
6538 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6539 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6541 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6544 if (NumVGScaledBytes) {
6554 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6562 unsigned FrameReg,
unsigned Reg,
6564 bool LastAdjustmentWasScalable) {
6565 if (
Offset.getScalable())
6568 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6571 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6578 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6579 int64_t NumBytes, NumVGScaledBytes;
6580 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6581 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6583 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6586 if (!NumVGScaledBytes)
6589 std::string CommentBuffer;
6594 assert(NumVGScaledBytes &&
"Expected scalable offset");
6598 if (IncomingVGOffsetFromDefCFA) {
6600 VGRegScale =
"* IncomingVG";
6603 VGRegScale =
"* VG";
6607 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6616 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6631 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6634 bool *HasWinCFI,
bool EmitCFAOffset,
6637 unsigned MaxEncoding, ShiftSize;
6639 case AArch64::ADDXri:
6640 case AArch64::ADDSXri:
6641 case AArch64::SUBXri:
6642 case AArch64::SUBSXri:
6643 MaxEncoding = 0xfff;
6646 case AArch64::ADDVL_XXI:
6647 case AArch64::ADDPL_XXI:
6648 case AArch64::ADDSVL_XXI:
6649 case AArch64::ADDSPL_XXI:
6664 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6666 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6680 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6682 if (TmpReg == AArch64::XZR)
6683 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
6684 &AArch64::GPR64RegClass);
6686 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6687 unsigned LocalShiftSize = 0;
6688 if (ThisVal > MaxEncoding) {
6689 ThisVal = ThisVal >> ShiftSize;
6690 LocalShiftSize = ShiftSize;
6692 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6693 "Encoding cannot handle value that big");
6695 Offset -= ThisVal << LocalShiftSize;
6700 .
addImm(Sign * (
int)ThisVal);
6710 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6711 CFAOffset += Change;
6713 CFAOffset -= Change;
6714 if (EmitCFAOffset && DestReg == TmpReg) {
6727 int Imm = (int)(ThisVal << LocalShiftSize);
6728 if (VScale != 1 && DestReg == AArch64::SP) {
6734 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
6735 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
6736 assert(VScale == 1 &&
"Expected non-scalable operation");
6745 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
6746 "emit a single SEH directive");
6747 }
else if (DestReg == AArch64::SP) {
6748 assert(VScale == 1 &&
"Expected non-scalable operation");
6751 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
6764 unsigned DestReg,
unsigned SrcReg,
6767 bool NeedsWinCFI,
bool *HasWinCFI,
6769 unsigned FrameReg) {
6776 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
6778 int64_t Bytes, NumPredicateVectors, NumDataVectors;
6779 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6780 Offset, Bytes, NumPredicateVectors, NumDataVectors);
6783 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
6784 if (NeedsFinalDefNZCV)
6788 if (Bytes || (!
Offset && SrcReg != DestReg)) {
6789 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
6790 "SP increment/decrement not 8-byte aligned");
6791 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
6794 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
6797 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6799 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
6806 assert(!(NeedsWinCFI && NumPredicateVectors) &&
6807 "WinCFI can't allocate fractions of an SVE data vector");
6809 if (NumDataVectors) {
6811 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
6812 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6818 if (NumPredicateVectors) {
6819 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
6821 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
6822 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
6826 if (NeedsFinalDefNZCV)
6847 if (
MI.isFullCopy()) {
6850 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
6854 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
6859 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
6887 if (
MI.isCopy() &&
Ops.size() == 1 &&
6889 (
Ops[0] == 0 ||
Ops[0] == 1)) {
6890 bool IsSpill =
Ops[0] == 0;
6891 bool IsFill = !IsSpill;
6903 :
TRI.getMinimalPhysRegClass(Reg);
6909 "Mismatched register size in non subreg COPY");
6916 return &*--InsertPt;
6928 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
6931 "Unexpected subreg on physical register");
6933 FrameIndex, &AArch64::GPR64RegClass,
Register());
6934 return &*--InsertPt;
6951 case AArch64::sub_32:
6952 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
6953 FillRC = &AArch64::GPR32RegClass;
6956 FillRC = &AArch64::FPR32RegClass;
6959 FillRC = &AArch64::FPR64RegClass;
6965 TRI.getRegSizeInBits(*FillRC) &&
6966 "Mismatched regclass size on folded subreg COPY");
6985 bool *OutUseUnscaledOp,
6986 unsigned *OutUnscaledOp,
6987 int64_t *EmittableOffset) {
6989 if (EmittableOffset)
6990 *EmittableOffset = 0;
6991 if (OutUseUnscaledOp)
6992 *OutUseUnscaledOp =
false;
6998 switch (
MI.getOpcode()) {
7001 case AArch64::LD1Rv1d:
7002 case AArch64::LD1Rv2s:
7003 case AArch64::LD1Rv2d:
7004 case AArch64::LD1Rv4h:
7005 case AArch64::LD1Rv4s:
7006 case AArch64::LD1Rv8b:
7007 case AArch64::LD1Rv8h:
7008 case AArch64::LD1Rv16b:
7009 case AArch64::LD1Twov2d:
7010 case AArch64::LD1Threev2d:
7011 case AArch64::LD1Fourv2d:
7012 case AArch64::LD1Twov1d:
7013 case AArch64::LD1Threev1d:
7014 case AArch64::LD1Fourv1d:
7015 case AArch64::ST1Twov2d:
7016 case AArch64::ST1Threev2d:
7017 case AArch64::ST1Fourv2d:
7018 case AArch64::ST1Twov1d:
7019 case AArch64::ST1Threev1d:
7020 case AArch64::ST1Fourv1d:
7021 case AArch64::ST1i8:
7022 case AArch64::ST1i16:
7023 case AArch64::ST1i32:
7024 case AArch64::ST1i64:
7026 case AArch64::IRGstack:
7027 case AArch64::STGloop:
7028 case AArch64::STZGloop:
7033 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7034 int64_t MinOff, MaxOff;
7040 bool IsMulVL = ScaleValue.isScalable();
7041 unsigned Scale = ScaleValue.getKnownMinValue();
7051 std::optional<unsigned> UnscaledOp =
7053 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7054 if (useUnscaledOp &&
7059 Scale = ScaleValue.getKnownMinValue();
7060 assert(IsMulVL == ScaleValue.isScalable() &&
7061 "Unscaled opcode has different value for scalable");
7063 int64_t Remainder =
Offset % Scale;
7064 assert(!(Remainder && useUnscaledOp) &&
7065 "Cannot have remainder when using unscaled op");
7067 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7068 int64_t NewOffset =
Offset / Scale;
7069 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7072 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7076 if (EmittableOffset)
7077 *EmittableOffset = NewOffset;
7078 if (OutUseUnscaledOp)
7079 *OutUseUnscaledOp = useUnscaledOp;
7080 if (OutUnscaledOp && UnscaledOp)
7081 *OutUnscaledOp = *UnscaledOp;
7094 unsigned Opcode =
MI.getOpcode();
7095 unsigned ImmIdx = FrameRegIdx + 1;
7097 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7102 MI.eraseFromParent();
7108 unsigned UnscaledOp;
7111 &UnscaledOp, &NewOffset);
7115 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7117 MI.setDesc(
TII->get(UnscaledOp));
7119 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7135bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7140 case AArch64::ADDSWrr:
7141 case AArch64::ADDSWri:
7142 case AArch64::ADDSXrr:
7143 case AArch64::ADDSXri:
7144 case AArch64::SUBSWrr:
7145 case AArch64::SUBSXrr:
7147 case AArch64::SUBSWri:
7148 case AArch64::SUBSXri:
7159 case AArch64::ADDWrr:
7160 case AArch64::ADDWri:
7161 case AArch64::SUBWrr:
7162 case AArch64::ADDSWrr:
7163 case AArch64::ADDSWri:
7164 case AArch64::SUBSWrr:
7166 case AArch64::SUBWri:
7167 case AArch64::SUBSWri:
7178 case AArch64::ADDXrr:
7179 case AArch64::ADDXri:
7180 case AArch64::SUBXrr:
7181 case AArch64::ADDSXrr:
7182 case AArch64::ADDSXri:
7183 case AArch64::SUBSXrr:
7185 case AArch64::SUBXri:
7186 case AArch64::SUBSXri:
7187 case AArch64::ADDv8i8:
7188 case AArch64::ADDv16i8:
7189 case AArch64::ADDv4i16:
7190 case AArch64::ADDv8i16:
7191 case AArch64::ADDv2i32:
7192 case AArch64::ADDv4i32:
7193 case AArch64::SUBv8i8:
7194 case AArch64::SUBv16i8:
7195 case AArch64::SUBv4i16:
7196 case AArch64::SUBv8i16:
7197 case AArch64::SUBv2i32:
7198 case AArch64::SUBv4i32:
7211 case AArch64::FADDHrr:
7212 case AArch64::FADDSrr:
7213 case AArch64::FADDDrr:
7214 case AArch64::FADDv4f16:
7215 case AArch64::FADDv8f16:
7216 case AArch64::FADDv2f32:
7217 case AArch64::FADDv2f64:
7218 case AArch64::FADDv4f32:
7219 case AArch64::FSUBHrr:
7220 case AArch64::FSUBSrr:
7221 case AArch64::FSUBDrr:
7222 case AArch64::FSUBv4f16:
7223 case AArch64::FSUBv8f16:
7224 case AArch64::FSUBv2f32:
7225 case AArch64::FSUBv2f64:
7226 case AArch64::FSUBv4f32:
7245 unsigned CombineOpc,
unsigned ZeroReg = 0,
7246 bool CheckZeroReg =
false) {
7253 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7260 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7261 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7262 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7264 if (
MI->getOperand(3).getReg() != ZeroReg)
7269 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7278 unsigned MulOpc,
unsigned ZeroReg) {
7293bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7294 bool Invert)
const {
7300 case AArch64::FADDHrr:
7301 case AArch64::FADDSrr:
7302 case AArch64::FADDDrr:
7303 case AArch64::FMULHrr:
7304 case AArch64::FMULSrr:
7305 case AArch64::FMULDrr:
7306 case AArch64::FMULX16:
7307 case AArch64::FMULX32:
7308 case AArch64::FMULX64:
7310 case AArch64::FADDv4f16:
7311 case AArch64::FADDv8f16:
7312 case AArch64::FADDv2f32:
7313 case AArch64::FADDv4f32:
7314 case AArch64::FADDv2f64:
7315 case AArch64::FMULv4f16:
7316 case AArch64::FMULv8f16:
7317 case AArch64::FMULv2f32:
7318 case AArch64::FMULv4f32:
7319 case AArch64::FMULv2f64:
7320 case AArch64::FMULXv4f16:
7321 case AArch64::FMULXv8f16:
7322 case AArch64::FMULXv2f32:
7323 case AArch64::FMULXv4f32:
7324 case AArch64::FMULXv2f64:
7328 case AArch64::FADD_ZZZ_H:
7329 case AArch64::FADD_ZZZ_S:
7330 case AArch64::FADD_ZZZ_D:
7331 case AArch64::FMUL_ZZZ_H:
7332 case AArch64::FMUL_ZZZ_S:
7333 case AArch64::FMUL_ZZZ_D:
7344 case AArch64::ADDWrr:
7345 case AArch64::ADDXrr:
7346 case AArch64::ANDWrr:
7347 case AArch64::ANDXrr:
7348 case AArch64::ORRWrr:
7349 case AArch64::ORRXrr:
7350 case AArch64::EORWrr:
7351 case AArch64::EORXrr:
7352 case AArch64::EONWrr:
7353 case AArch64::EONXrr:
7357 case AArch64::ADDv8i8:
7358 case AArch64::ADDv16i8:
7359 case AArch64::ADDv4i16:
7360 case AArch64::ADDv8i16:
7361 case AArch64::ADDv2i32:
7362 case AArch64::ADDv4i32:
7363 case AArch64::ADDv1i64:
7364 case AArch64::ADDv2i64:
7365 case AArch64::MULv8i8:
7366 case AArch64::MULv16i8:
7367 case AArch64::MULv4i16:
7368 case AArch64::MULv8i16:
7369 case AArch64::MULv2i32:
7370 case AArch64::MULv4i32:
7371 case AArch64::ANDv8i8:
7372 case AArch64::ANDv16i8:
7373 case AArch64::ORRv8i8:
7374 case AArch64::ORRv16i8:
7375 case AArch64::EORv8i8:
7376 case AArch64::EORv16i8:
7378 case AArch64::ADD_ZZZ_B:
7379 case AArch64::ADD_ZZZ_H:
7380 case AArch64::ADD_ZZZ_S:
7381 case AArch64::ADD_ZZZ_D:
7382 case AArch64::MUL_ZZZ_B:
7383 case AArch64::MUL_ZZZ_H:
7384 case AArch64::MUL_ZZZ_S:
7385 case AArch64::MUL_ZZZ_D:
7386 case AArch64::AND_ZZZ:
7387 case AArch64::ORR_ZZZ:
7388 case AArch64::EOR_ZZZ:
7419 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7427 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7439 case AArch64::ADDWrr:
7441 "ADDWrr does not have register operands");
7442 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7443 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7445 case AArch64::ADDXrr:
7446 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7447 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7449 case AArch64::SUBWrr:
7450 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7451 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7453 case AArch64::SUBXrr:
7454 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7455 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7457 case AArch64::ADDWri:
7458 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7460 case AArch64::ADDXri:
7461 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7463 case AArch64::SUBWri:
7464 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7466 case AArch64::SUBXri:
7467 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7469 case AArch64::ADDv8i8:
7470 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7471 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7473 case AArch64::ADDv16i8:
7474 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7475 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7477 case AArch64::ADDv4i16:
7478 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7479 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7480 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7481 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7483 case AArch64::ADDv8i16:
7484 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7485 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7486 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7487 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7489 case AArch64::ADDv2i32:
7490 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7491 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7492 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7493 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7495 case AArch64::ADDv4i32:
7496 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7497 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7498 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7499 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7501 case AArch64::SUBv8i8:
7502 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7503 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7505 case AArch64::SUBv16i8:
7506 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7507 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7509 case AArch64::SUBv4i16:
7510 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7511 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7512 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7513 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7515 case AArch64::SUBv8i16:
7516 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7517 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7518 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7519 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7521 case AArch64::SUBv2i32:
7522 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7523 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7524 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7525 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7527 case AArch64::SUBv4i32:
7528 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7529 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7530 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7531 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7537bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7541 case AArch64::UABALB_ZZZ_D:
7542 case AArch64::UABALB_ZZZ_H:
7543 case AArch64::UABALB_ZZZ_S:
7544 case AArch64::UABALT_ZZZ_D:
7545 case AArch64::UABALT_ZZZ_H:
7546 case AArch64::UABALT_ZZZ_S:
7547 case AArch64::SABALB_ZZZ_D:
7548 case AArch64::SABALB_ZZZ_S:
7549 case AArch64::SABALB_ZZZ_H:
7550 case AArch64::SABALT_ZZZ_D:
7551 case AArch64::SABALT_ZZZ_S:
7552 case AArch64::SABALT_ZZZ_H:
7553 case AArch64::UABALv16i8_v8i16:
7554 case AArch64::UABALv2i32_v2i64:
7555 case AArch64::UABALv4i16_v4i32:
7556 case AArch64::UABALv4i32_v2i64:
7557 case AArch64::UABALv8i16_v4i32:
7558 case AArch64::UABALv8i8_v8i16:
7559 case AArch64::UABAv16i8:
7560 case AArch64::UABAv2i32:
7561 case AArch64::UABAv4i16:
7562 case AArch64::UABAv4i32:
7563 case AArch64::UABAv8i16:
7564 case AArch64::UABAv8i8:
7565 case AArch64::SABALv16i8_v8i16:
7566 case AArch64::SABALv2i32_v2i64:
7567 case AArch64::SABALv4i16_v4i32:
7568 case AArch64::SABALv4i32_v2i64:
7569 case AArch64::SABALv8i16_v4i32:
7570 case AArch64::SABALv8i8_v8i16:
7571 case AArch64::SABAv16i8:
7572 case AArch64::SABAv2i32:
7573 case AArch64::SABAv4i16:
7574 case AArch64::SABAv4i32:
7575 case AArch64::SABAv8i16:
7576 case AArch64::SABAv8i8:
7583unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7584 unsigned AccumulationOpcode)
const {
7585 switch (AccumulationOpcode) {
7588 case AArch64::UABALB_ZZZ_D:
7589 return AArch64::UABDLB_ZZZ_D;
7590 case AArch64::UABALB_ZZZ_H:
7591 return AArch64::UABDLB_ZZZ_H;
7592 case AArch64::UABALB_ZZZ_S:
7593 return AArch64::UABDLB_ZZZ_S;
7594 case AArch64::UABALT_ZZZ_D:
7595 return AArch64::UABDLT_ZZZ_D;
7596 case AArch64::UABALT_ZZZ_H:
7597 return AArch64::UABDLT_ZZZ_H;
7598 case AArch64::UABALT_ZZZ_S:
7599 return AArch64::UABDLT_ZZZ_S;
7600 case AArch64::UABALv16i8_v8i16:
7601 return AArch64::UABDLv16i8_v8i16;
7602 case AArch64::UABALv2i32_v2i64:
7603 return AArch64::UABDLv2i32_v2i64;
7604 case AArch64::UABALv4i16_v4i32:
7605 return AArch64::UABDLv4i16_v4i32;
7606 case AArch64::UABALv4i32_v2i64:
7607 return AArch64::UABDLv4i32_v2i64;
7608 case AArch64::UABALv8i16_v4i32:
7609 return AArch64::UABDLv8i16_v4i32;
7610 case AArch64::UABALv8i8_v8i16:
7611 return AArch64::UABDLv8i8_v8i16;
7612 case AArch64::UABAv16i8:
7613 return AArch64::UABDv16i8;
7614 case AArch64::UABAv2i32:
7615 return AArch64::UABDv2i32;
7616 case AArch64::UABAv4i16:
7617 return AArch64::UABDv4i16;
7618 case AArch64::UABAv4i32:
7619 return AArch64::UABDv4i32;
7620 case AArch64::UABAv8i16:
7621 return AArch64::UABDv8i16;
7622 case AArch64::UABAv8i8:
7623 return AArch64::UABDv8i8;
7624 case AArch64::SABALB_ZZZ_D:
7625 return AArch64::SABDLB_ZZZ_D;
7626 case AArch64::SABALB_ZZZ_S:
7627 return AArch64::SABDLB_ZZZ_S;
7628 case AArch64::SABALB_ZZZ_H:
7629 return AArch64::SABDLB_ZZZ_H;
7630 case AArch64::SABALT_ZZZ_D:
7631 return AArch64::SABDLT_ZZZ_D;
7632 case AArch64::SABALT_ZZZ_S:
7633 return AArch64::SABDLT_ZZZ_S;
7634 case AArch64::SABALT_ZZZ_H:
7635 return AArch64::SABDLT_ZZZ_H;
7636 case AArch64::SABALv16i8_v8i16:
7637 return AArch64::SABDLv16i8_v8i16;
7638 case AArch64::SABALv2i32_v2i64:
7639 return AArch64::SABDLv2i32_v2i64;
7640 case AArch64::SABALv4i16_v4i32:
7641 return AArch64::SABDLv4i16_v4i32;
7642 case AArch64::SABALv4i32_v2i64:
7643 return AArch64::SABDLv4i32_v2i64;
7644 case AArch64::SABALv8i16_v4i32:
7645 return AArch64::SABDLv8i16_v4i32;
7646 case AArch64::SABALv8i8_v8i16:
7647 return AArch64::SABDLv8i8_v8i16;
7648 case AArch64::SABAv16i8:
7649 return AArch64::SABDv16i8;
7650 case AArch64::SABAv2i32:
7651 return AArch64::SABAv2i32;
7652 case AArch64::SABAv4i16:
7653 return AArch64::SABDv4i16;
7654 case AArch64::SABAv4i32:
7655 return AArch64::SABDv4i32;
7656 case AArch64::SABAv8i16:
7657 return AArch64::SABDv8i16;
7658 case AArch64::SABAv8i8:
7659 return AArch64::SABDv8i8;
7675 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7687 assert(
false &&
"Unsupported FP instruction in combiner\n");
7689 case AArch64::FADDHrr:
7691 "FADDHrr does not have register operands");
7693 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7694 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7696 case AArch64::FADDSrr:
7698 "FADDSrr does not have register operands");
7700 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7701 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7703 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7704 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7706 case AArch64::FADDDrr:
7707 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7708 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7710 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
7711 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
7713 case AArch64::FADDv4f16:
7714 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
7715 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
7717 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
7718 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
7720 case AArch64::FADDv8f16:
7721 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
7722 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
7724 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
7725 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
7727 case AArch64::FADDv2f32:
7728 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
7729 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
7731 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
7732 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
7734 case AArch64::FADDv2f64:
7735 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
7736 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
7738 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
7739 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
7741 case AArch64::FADDv4f32:
7742 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
7743 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
7745 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
7746 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
7748 case AArch64::FSUBHrr:
7749 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
7750 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
7751 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
7753 case AArch64::FSUBSrr:
7754 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
7756 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
7757 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
7759 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
7761 case AArch64::FSUBDrr:
7762 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
7764 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
7765 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
7767 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
7769 case AArch64::FSUBv4f16:
7770 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
7771 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
7773 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
7774 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
7776 case AArch64::FSUBv8f16:
7777 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
7778 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
7780 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
7781 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
7783 case AArch64::FSUBv2f32:
7784 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
7785 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
7787 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
7788 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
7790 case AArch64::FSUBv2f64:
7791 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
7792 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
7794 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
7795 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
7797 case AArch64::FSUBv4f32:
7798 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
7799 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
7801 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
7802 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
7813 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
7820 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
7821 MI->getOperand(1).getReg().isVirtual())
7823 if (
MI &&
MI->getOpcode() == Opcode) {
7835 case AArch64::FMULv2f32:
7836 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
7837 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
7839 case AArch64::FMULv2f64:
7840 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
7841 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
7843 case AArch64::FMULv4f16:
7844 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
7845 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
7847 case AArch64::FMULv4f32:
7848 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
7849 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
7851 case AArch64::FMULv8f16:
7852 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
7853 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
7866 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
7869 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
7884 case AArch64::FNEGDr:
7886 case AArch64::FNEGSr:
8018 case AArch64::SUBWrr:
8019 case AArch64::SUBSWrr:
8020 case AArch64::SUBXrr:
8021 case AArch64::SUBSXrr:
8066 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8089 while (!RemainingLanes.
empty() && CurrInstr &&
8090 CurrInstr->getOpcode() == LoadLaneOpCode &&
8092 CurrInstr->getNumOperands() == 4) {
8093 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8099 if (!RemainingLanes.
empty())
8103 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8107 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8108 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8109 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8125 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8128 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8129 !RemainingLoadInstrs.
empty();
8130 --MBBItr, --RemainingSteps) {
8134 RemainingLoadInstrs.
erase(&CurrInstr);
8144 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8170 case AArch64::LD1i32:
8172 case AArch64::LD1i16:
8174 case AArch64::LD1i8:
8190 unsigned Pattern,
unsigned NumLanes) {
8198 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8206 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8212 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8218 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8219 Register SrcRegister,
unsigned Lane,
8221 bool OffsetRegisterKillState) {
8229 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8230 InsInstrs.
push_back(LoadIndexIntoRegister);
8236 auto CreateLDRInstruction = [&](
unsigned NumLanes,
Register DestReg,
8242 Opcode = AArch64::LDRSui;
8245 Opcode = AArch64::LDRHui;
8248 Opcode = AArch64::LDRBui;
8252 "Got unsupported number of lanes in machine-combiner gather pattern");
8261 auto LanesToLoadToReg0 =
8263 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8264 Register PrevReg = SubregToReg->getOperand(0).getReg();
8266 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8267 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8268 OffsetRegOperand.
getReg(),
8269 OffsetRegOperand.
isKill());
8276 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8278 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8285 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8286 OriginalSplitToLoadOffsetOperand.
getReg(),
8287 OriginalSplitToLoadOffsetOperand.
isKill());
8289 InstrIdxForVirtReg.
insert(
8290 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8291 InsInstrs.
push_back(MiddleIndexLoadInstr);
8296 unsigned SubregType;
8299 SubregType = AArch64::ssub;
8302 SubregType = AArch64::hsub;
8305 SubregType = AArch64::bsub;
8309 "Got invalid NumLanes for machine-combiner gather pattern");
8312 auto SubRegToRegInstr =
8314 DestRegForSubregToReg)
8317 InstrIdxForVirtReg.
insert(
8318 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8322 auto LanesToLoadToReg1 =
8324 LoadToLaneInstrsAscending.end());
8325 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8327 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8328 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8329 OffsetRegOperand.
getReg(),
8330 OffsetRegOperand.
isKill());
8333 if (Index == NumLanes / 2 - 2) {
8368bool AArch64InstrInfo::getMachineCombinerPatterns(
8370 bool DoRegPressureReduce)
const {
8391 DoRegPressureReduce);
8420 const Register *ReplacedAddend =
nullptr) {
8421 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8423 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8426 Register SrcReg0 = MUL->getOperand(1).getReg();
8427 bool Src0IsKill = MUL->getOperand(1).isKill();
8428 Register SrcReg1 = MUL->getOperand(2).getReg();
8429 bool Src1IsKill = MUL->getOperand(2).isKill();
8433 if (ReplacedAddend) {
8435 SrcReg2 = *ReplacedAddend;
8462 .
addImm(MUL->getOperand(3).getImm());
8469 assert(
false &&
"Invalid FMA instruction kind \n");
8483 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8484 Opc = AArch64::FNMADDSrrr;
8485 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8486 Opc = AArch64::FNMADDDrrr;
8520 unsigned IdxDupOp,
unsigned MulOpc,
8522 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8523 "Invalid index of FMUL operand");
8531 if (Dup->
getOpcode() == TargetOpcode::COPY)
8540 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8581 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8596 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8623 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8651 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8653 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8657 Register SrcReg0 = MUL->getOperand(1).getReg();
8658 bool Src0IsKill = MUL->getOperand(1).isKill();
8659 Register SrcReg1 = MUL->getOperand(2).getReg();
8660 bool Src1IsKill = MUL->getOperand(2).isKill();
8690 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8691 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8705 if (Opcode == AArch64::SUBSWrr)
8706 Opcode = AArch64::SUBWrr;
8707 else if (Opcode == AArch64::SUBSXrr)
8708 Opcode = AArch64::SUBXrr;
8710 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
8711 "Unexpected instruction opcode.");
8728 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8735unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
8736 unsigned int AccumulatorOpCode)
const {
8737 switch (AccumulatorOpCode) {
8738 case AArch64::UABALB_ZZZ_D:
8739 case AArch64::SABALB_ZZZ_D:
8740 case AArch64::UABALT_ZZZ_D:
8741 case AArch64::SABALT_ZZZ_D:
8742 return AArch64::ADD_ZZZ_D;
8743 case AArch64::UABALB_ZZZ_H:
8744 case AArch64::SABALB_ZZZ_H:
8745 case AArch64::UABALT_ZZZ_H:
8746 case AArch64::SABALT_ZZZ_H:
8747 return AArch64::ADD_ZZZ_H;
8748 case AArch64::UABALB_ZZZ_S:
8749 case AArch64::SABALB_ZZZ_S:
8750 case AArch64::UABALT_ZZZ_S:
8751 case AArch64::SABALT_ZZZ_S:
8752 return AArch64::ADD_ZZZ_S;
8753 case AArch64::UABALv16i8_v8i16:
8754 case AArch64::SABALv8i8_v8i16:
8755 case AArch64::SABAv8i16:
8756 case AArch64::UABAv8i16:
8757 return AArch64::ADDv8i16;
8758 case AArch64::SABALv2i32_v2i64:
8759 case AArch64::UABALv2i32_v2i64:
8760 case AArch64::SABALv4i32_v2i64:
8761 return AArch64::ADDv2i64;
8762 case AArch64::UABALv4i16_v4i32:
8763 case AArch64::SABALv4i16_v4i32:
8764 case AArch64::SABALv8i16_v4i32:
8765 case AArch64::SABAv4i32:
8766 case AArch64::UABAv4i32:
8767 return AArch64::ADDv4i32;
8768 case AArch64::UABALv4i32_v2i64:
8769 return AArch64::ADDv2i64;
8770 case AArch64::UABALv8i16_v4i32:
8771 return AArch64::ADDv4i32;
8772 case AArch64::UABALv8i8_v8i16:
8773 case AArch64::SABALv16i8_v8i16:
8774 return AArch64::ADDv8i16;
8775 case AArch64::UABAv16i8:
8776 case AArch64::SABAv16i8:
8777 return AArch64::ADDv16i8;
8778 case AArch64::UABAv4i16:
8779 case AArch64::SABAv4i16:
8780 return AArch64::ADDv4i16;
8781 case AArch64::UABAv2i32:
8782 case AArch64::SABAv2i32:
8783 return AArch64::ADDv2i32;
8784 case AArch64::UABAv8i8:
8785 case AArch64::SABAv8i8:
8786 return AArch64::ADDv8i8;
8795void AArch64InstrInfo::genAlternativeCodeSequence(
8805 MachineInstr *
MUL =
nullptr;
8806 const TargetRegisterClass *RC;
8812 DelInstrs, InstrIdxForVirtReg);
8818 InstrIdxForVirtReg);
8824 InstrIdxForVirtReg);
8833 Opc = AArch64::MADDWrrr;
8834 RC = &AArch64::GPR32RegClass;
8836 Opc = AArch64::MADDXrrr;
8837 RC = &AArch64::GPR64RegClass;
8848 Opc = AArch64::MADDWrrr;
8849 RC = &AArch64::GPR32RegClass;
8851 Opc = AArch64::MADDXrrr;
8852 RC = &AArch64::GPR64RegClass;
8865 const TargetRegisterClass *RC;
8866 unsigned BitSize, MovImm;
8869 MovImm = AArch64::MOVi32imm;
8870 RC = &AArch64::GPR32spRegClass;
8872 Opc = AArch64::MADDWrrr;
8873 RC = &AArch64::GPR32RegClass;
8875 MovImm = AArch64::MOVi64imm;
8876 RC = &AArch64::GPR64spRegClass;
8878 Opc = AArch64::MADDXrrr;
8879 RC = &AArch64::GPR64RegClass;
8890 uint64_t UImm =
SignExtend64(IsSub ? -Imm : Imm, BitSize);
8894 if (Insn.
size() != 1)
8896 MachineInstrBuilder MIB1 =
8897 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
8898 .
addImm(IsSub ? -Imm : Imm);
8900 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8911 const TargetRegisterClass *SubRC;
8912 unsigned SubOpc, ZeroReg;
8914 SubOpc = AArch64::SUBWrr;
8915 SubRC = &AArch64::GPR32spRegClass;
8916 ZeroReg = AArch64::WZR;
8917 Opc = AArch64::MADDWrrr;
8918 RC = &AArch64::GPR32RegClass;
8920 SubOpc = AArch64::SUBXrr;
8921 SubRC = &AArch64::GPR64spRegClass;
8922 ZeroReg = AArch64::XZR;
8923 Opc = AArch64::MADDXrrr;
8924 RC = &AArch64::GPR64RegClass;
8928 MachineInstrBuilder MIB1 =
8929 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
8933 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8944 Opc = AArch64::MSUBWrrr;
8945 RC = &AArch64::GPR32RegClass;
8947 Opc = AArch64::MSUBXrrr;
8948 RC = &AArch64::GPR64RegClass;
8953 Opc = AArch64::MLAv8i8;
8954 RC = &AArch64::FPR64RegClass;
8958 Opc = AArch64::MLAv8i8;
8959 RC = &AArch64::FPR64RegClass;
8963 Opc = AArch64::MLAv16i8;
8964 RC = &AArch64::FPR128RegClass;
8968 Opc = AArch64::MLAv16i8;
8969 RC = &AArch64::FPR128RegClass;
8973 Opc = AArch64::MLAv4i16;
8974 RC = &AArch64::FPR64RegClass;
8978 Opc = AArch64::MLAv4i16;
8979 RC = &AArch64::FPR64RegClass;
8983 Opc = AArch64::MLAv8i16;
8984 RC = &AArch64::FPR128RegClass;
8988 Opc = AArch64::MLAv8i16;
8989 RC = &AArch64::FPR128RegClass;
8993 Opc = AArch64::MLAv2i32;
8994 RC = &AArch64::FPR64RegClass;
8998 Opc = AArch64::MLAv2i32;
8999 RC = &AArch64::FPR64RegClass;
9003 Opc = AArch64::MLAv4i32;
9004 RC = &AArch64::FPR128RegClass;
9008 Opc = AArch64::MLAv4i32;
9009 RC = &AArch64::FPR128RegClass;
9014 Opc = AArch64::MLAv8i8;
9015 RC = &AArch64::FPR64RegClass;
9017 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9021 Opc = AArch64::MLSv8i8;
9022 RC = &AArch64::FPR64RegClass;
9026 Opc = AArch64::MLAv16i8;
9027 RC = &AArch64::FPR128RegClass;
9029 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9033 Opc = AArch64::MLSv16i8;
9034 RC = &AArch64::FPR128RegClass;
9038 Opc = AArch64::MLAv4i16;
9039 RC = &AArch64::FPR64RegClass;
9041 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9045 Opc = AArch64::MLSv4i16;
9046 RC = &AArch64::FPR64RegClass;
9050 Opc = AArch64::MLAv8i16;
9051 RC = &AArch64::FPR128RegClass;
9053 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9057 Opc = AArch64::MLSv8i16;
9058 RC = &AArch64::FPR128RegClass;
9062 Opc = AArch64::MLAv2i32;
9063 RC = &AArch64::FPR64RegClass;
9065 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9069 Opc = AArch64::MLSv2i32;
9070 RC = &AArch64::FPR64RegClass;
9074 Opc = AArch64::MLAv4i32;
9075 RC = &AArch64::FPR128RegClass;
9077 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9081 Opc = AArch64::MLSv4i32;
9082 RC = &AArch64::FPR128RegClass;
9087 Opc = AArch64::MLAv4i16_indexed;
9088 RC = &AArch64::FPR64RegClass;
9092 Opc = AArch64::MLAv4i16_indexed;
9093 RC = &AArch64::FPR64RegClass;
9097 Opc = AArch64::MLAv8i16_indexed;
9098 RC = &AArch64::FPR128RegClass;
9102 Opc = AArch64::MLAv8i16_indexed;
9103 RC = &AArch64::FPR128RegClass;
9107 Opc = AArch64::MLAv2i32_indexed;
9108 RC = &AArch64::FPR64RegClass;
9112 Opc = AArch64::MLAv2i32_indexed;
9113 RC = &AArch64::FPR64RegClass;
9117 Opc = AArch64::MLAv4i32_indexed;
9118 RC = &AArch64::FPR128RegClass;
9122 Opc = AArch64::MLAv4i32_indexed;
9123 RC = &AArch64::FPR128RegClass;
9128 Opc = AArch64::MLAv4i16_indexed;
9129 RC = &AArch64::FPR64RegClass;
9131 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9135 Opc = AArch64::MLSv4i16_indexed;
9136 RC = &AArch64::FPR64RegClass;
9140 Opc = AArch64::MLAv8i16_indexed;
9141 RC = &AArch64::FPR128RegClass;
9143 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9147 Opc = AArch64::MLSv8i16_indexed;
9148 RC = &AArch64::FPR128RegClass;
9152 Opc = AArch64::MLAv2i32_indexed;
9153 RC = &AArch64::FPR64RegClass;
9155 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9159 Opc = AArch64::MLSv2i32_indexed;
9160 RC = &AArch64::FPR64RegClass;
9164 Opc = AArch64::MLAv4i32_indexed;
9165 RC = &AArch64::FPR128RegClass;
9167 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9171 Opc = AArch64::MLSv4i32_indexed;
9172 RC = &AArch64::FPR128RegClass;
9178 Opc = AArch64::FMADDHrrr;
9179 RC = &AArch64::FPR16RegClass;
9183 Opc = AArch64::FMADDSrrr;
9184 RC = &AArch64::FPR32RegClass;
9188 Opc = AArch64::FMADDDrrr;
9189 RC = &AArch64::FPR64RegClass;
9194 Opc = AArch64::FMADDHrrr;
9195 RC = &AArch64::FPR16RegClass;
9199 Opc = AArch64::FMADDSrrr;
9200 RC = &AArch64::FPR32RegClass;
9204 Opc = AArch64::FMADDDrrr;
9205 RC = &AArch64::FPR64RegClass;
9210 Opc = AArch64::FMLAv1i32_indexed;
9211 RC = &AArch64::FPR32RegClass;
9216 Opc = AArch64::FMLAv1i32_indexed;
9217 RC = &AArch64::FPR32RegClass;
9223 Opc = AArch64::FMLAv1i64_indexed;
9224 RC = &AArch64::FPR64RegClass;
9229 Opc = AArch64::FMLAv1i64_indexed;
9230 RC = &AArch64::FPR64RegClass;
9236 RC = &AArch64::FPR64RegClass;
9237 Opc = AArch64::FMLAv4i16_indexed;
9242 RC = &AArch64::FPR64RegClass;
9243 Opc = AArch64::FMLAv4f16;
9248 RC = &AArch64::FPR64RegClass;
9249 Opc = AArch64::FMLAv4i16_indexed;
9254 RC = &AArch64::FPR64RegClass;
9255 Opc = AArch64::FMLAv4f16;
9262 RC = &AArch64::FPR64RegClass;
9264 Opc = AArch64::FMLAv2i32_indexed;
9268 Opc = AArch64::FMLAv2f32;
9275 RC = &AArch64::FPR64RegClass;
9277 Opc = AArch64::FMLAv2i32_indexed;
9281 Opc = AArch64::FMLAv2f32;
9288 RC = &AArch64::FPR128RegClass;
9289 Opc = AArch64::FMLAv8i16_indexed;
9294 RC = &AArch64::FPR128RegClass;
9295 Opc = AArch64::FMLAv8f16;
9300 RC = &AArch64::FPR128RegClass;
9301 Opc = AArch64::FMLAv8i16_indexed;
9306 RC = &AArch64::FPR128RegClass;
9307 Opc = AArch64::FMLAv8f16;
9314 RC = &AArch64::FPR128RegClass;
9316 Opc = AArch64::FMLAv2i64_indexed;
9320 Opc = AArch64::FMLAv2f64;
9327 RC = &AArch64::FPR128RegClass;
9329 Opc = AArch64::FMLAv2i64_indexed;
9333 Opc = AArch64::FMLAv2f64;
9341 RC = &AArch64::FPR128RegClass;
9343 Opc = AArch64::FMLAv4i32_indexed;
9347 Opc = AArch64::FMLAv4f32;
9355 RC = &AArch64::FPR128RegClass;
9357 Opc = AArch64::FMLAv4i32_indexed;
9361 Opc = AArch64::FMLAv4f32;
9368 Opc = AArch64::FNMSUBHrrr;
9369 RC = &AArch64::FPR16RegClass;
9373 Opc = AArch64::FNMSUBSrrr;
9374 RC = &AArch64::FPR32RegClass;
9378 Opc = AArch64::FNMSUBDrrr;
9379 RC = &AArch64::FPR64RegClass;
9384 Opc = AArch64::FNMADDHrrr;
9385 RC = &AArch64::FPR16RegClass;
9389 Opc = AArch64::FNMADDSrrr;
9390 RC = &AArch64::FPR32RegClass;
9394 Opc = AArch64::FNMADDDrrr;
9395 RC = &AArch64::FPR64RegClass;
9400 Opc = AArch64::FMSUBHrrr;
9401 RC = &AArch64::FPR16RegClass;
9405 Opc = AArch64::FMSUBSrrr;
9406 RC = &AArch64::FPR32RegClass;
9410 Opc = AArch64::FMSUBDrrr;
9411 RC = &AArch64::FPR64RegClass;
9416 Opc = AArch64::FMLSv1i32_indexed;
9417 RC = &AArch64::FPR32RegClass;
9423 Opc = AArch64::FMLSv1i64_indexed;
9424 RC = &AArch64::FPR64RegClass;
9431 RC = &AArch64::FPR64RegClass;
9433 MachineInstrBuilder MIB1 =
9434 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9437 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9439 Opc = AArch64::FMLAv4f16;
9443 Opc = AArch64::FMLAv4i16_indexed;
9450 RC = &AArch64::FPR64RegClass;
9451 Opc = AArch64::FMLSv4f16;
9456 RC = &AArch64::FPR64RegClass;
9457 Opc = AArch64::FMLSv4i16_indexed;
9464 RC = &AArch64::FPR64RegClass;
9466 Opc = AArch64::FMLSv2i32_indexed;
9470 Opc = AArch64::FMLSv2f32;
9478 RC = &AArch64::FPR128RegClass;
9480 MachineInstrBuilder MIB1 =
9481 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9484 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9486 Opc = AArch64::FMLAv8f16;
9490 Opc = AArch64::FMLAv8i16_indexed;
9497 RC = &AArch64::FPR128RegClass;
9498 Opc = AArch64::FMLSv8f16;
9503 RC = &AArch64::FPR128RegClass;
9504 Opc = AArch64::FMLSv8i16_indexed;
9511 RC = &AArch64::FPR128RegClass;
9513 Opc = AArch64::FMLSv2i64_indexed;
9517 Opc = AArch64::FMLSv2f64;
9525 RC = &AArch64::FPR128RegClass;
9527 Opc = AArch64::FMLSv4i32_indexed;
9531 Opc = AArch64::FMLSv4f32;
9538 RC = &AArch64::FPR64RegClass;
9540 MachineInstrBuilder MIB1 =
9541 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9544 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9546 Opc = AArch64::FMLAv2i32_indexed;
9550 Opc = AArch64::FMLAv2f32;
9558 RC = &AArch64::FPR128RegClass;
9560 MachineInstrBuilder MIB1 =
9561 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9564 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9566 Opc = AArch64::FMLAv4i32_indexed;
9570 Opc = AArch64::FMLAv4f32;
9578 RC = &AArch64::FPR128RegClass;
9580 MachineInstrBuilder MIB1 =
9581 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9584 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9586 Opc = AArch64::FMLAv2i64_indexed;
9590 Opc = AArch64::FMLAv2f64;
9602 &AArch64::FPR128RegClass, MRI);
9611 &AArch64::FPR128RegClass, MRI);
9620 &AArch64::FPR128_loRegClass, MRI);
9629 &AArch64::FPR128RegClass, MRI);
9638 &AArch64::FPR128_loRegClass, MRI);
9672 for (
auto *
MI : InsInstrs)
9673 MI->setFlags(Flags);
9714 bool IsNegativeBranch =
false;
9715 bool IsTestAndBranch =
false;
9716 unsigned TargetBBInMI = 0;
9717 switch (
MI.getOpcode()) {
9721 case AArch64::CBWPri:
9722 case AArch64::CBXPri:
9723 case AArch64::CBBAssertExt:
9724 case AArch64::CBHAssertExt:
9725 case AArch64::CBWPrr:
9726 case AArch64::CBXPrr:
9732 case AArch64::CBNZW:
9733 case AArch64::CBNZX:
9735 IsNegativeBranch =
true;
9740 IsTestAndBranch =
true;
9742 case AArch64::TBNZW:
9743 case AArch64::TBNZX:
9745 IsNegativeBranch =
true;
9746 IsTestAndBranch =
true;
9752 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
9756 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
9767 while (
DefMI->isCopy()) {
9776 switch (
DefMI->getOpcode()) {
9780 case AArch64::ANDWri:
9781 case AArch64::ANDXri: {
9782 if (IsTestAndBranch)
9789 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
9791 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
9806 unsigned Opc = (Imm < 32)
9807 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
9808 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
9821 if (!Is32Bit && Imm < 32)
9823 MI.eraseFromParent();
9827 case AArch64::CSINCWr:
9828 case AArch64::CSINCXr: {
9829 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
9830 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
9831 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
9832 DefMI->getOperand(2).getReg() == AArch64::XZR))
9835 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
9848 if (IsNegativeBranch)
9851 MI.eraseFromParent();
9857std::pair<unsigned, unsigned>
9858AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
9860 return std::make_pair(TF & Mask, TF & ~Mask);
9864AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
9867 static const std::pair<unsigned, const char *> TargetFlags[] = {
9868 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
9869 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
9870 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
9876AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
9877 using namespace AArch64II;
9879 static const std::pair<unsigned, const char *> TargetFlags[] = {
9882 {
MO_NC,
"aarch64-nc"},
9883 {
MO_S,
"aarch64-s"},
9894AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
9895 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
9997 MachineFunction *MF =
C.getMF();
9999 const AArch64RegisterInfo *ARI =
10000 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10003 for (
unsigned Reg : AArch64::GPR64RegClass) {
10005 Reg != AArch64::LR &&
10006 Reg != AArch64::X16 &&
10007 Reg != AArch64::X17 &&
10008 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10009 C.isAvailableInsideSeq(
Reg,
TRI))
10040 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10043std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10044AArch64InstrInfo::getOutliningCandidateInfo(
10046 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10047 unsigned MinRepeats)
const {
10048 unsigned SequenceSize = 0;
10049 for (
auto &
MI : RepeatedSequenceLocs[0])
10052 unsigned NumBytesToCreateFrame = 0;
10058 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10059 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10060 if (LastMI.
getOpcode() == AArch64::ADRP &&
10063 return std::nullopt;
10068 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10069 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10072 return std::nullopt;
10083 if (std::adjacent_find(
10084 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10085 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10088 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10089 outliningCandidatesSigningKeyConsensus(a, b) &&
10090 outliningCandidatesV8_3OpsConsensus(a, b)) {
10094 }) != RepeatedSequenceLocs.end()) {
10095 return std::nullopt;
10112 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10113 const auto RASignCondition = RepeatedSequenceLocs[0]
10116 ->getSignReturnAddressCondition();
10119 NumBytesToCreateFrame += 8;
10122 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10123 *RepeatedSequenceLocs[0].getMF());
10124 NumBytesToCheckLRInTCEpilogue =
10128 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10129 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10137 for (
auto &
MI :
C) {
10138 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10139 switch (
MI.getOpcode()) {
10140 case AArch64::ADDXri:
10141 case AArch64::ADDWri:
10142 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10143 assert(
MI.getOperand(2).isImm() &&
10144 "Expected operand to be immediate");
10145 assert(
MI.getOperand(1).isReg() &&
10146 "Expected operand to be a register");
10150 if (
MI.getOperand(1).getReg() == AArch64::SP)
10151 SPValue +=
MI.getOperand(2).getImm();
10155 case AArch64::SUBXri:
10156 case AArch64::SUBWri:
10157 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10158 assert(
MI.getOperand(2).isImm() &&
10159 "Expected operand to be immediate");
10160 assert(
MI.getOperand(1).isReg() &&
10161 "Expected operand to be a register");
10165 if (
MI.getOperand(1).getReg() == AArch64::SP)
10166 SPValue -=
MI.getOperand(2).getImm();
10183 if (RepeatedSequenceLocs.size() < MinRepeats)
10184 return std::nullopt;
10188 unsigned FlagsSetInAll = 0xF;
10192 FlagsSetInAll &=
C.Flags;
10194 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10197 auto SetCandidateCallInfo =
10198 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10200 C.setCallInfo(CallID, NumBytesForCall);
10204 NumBytesToCreateFrame += 4;
10212 unsigned CFICount = 0;
10213 for (
auto &
I : RepeatedSequenceLocs[0]) {
10214 if (
I.isCFIInstruction())
10224 std::vector<MCCFIInstruction> CFIInstructions =
10225 C.getMF()->getFrameInstructions();
10227 if (CFICount > 0 && CFICount != CFIInstructions.size())
10228 return std::nullopt;
10236 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10237 !
MI.readsRegister(AArch64::SP, &
TRI))
10243 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10248 if (
MI.mayLoadOrStore()) {
10251 bool OffsetIsScalable;
10255 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10256 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10260 if (OffsetIsScalable)
10268 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10269 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10272 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10273 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10288 bool AllStackInstrsSafe =
10293 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10295 NumBytesToCreateFrame = 0;
10296 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10300 else if (LastInstrOpcode == AArch64::BL ||
10301 ((LastInstrOpcode == AArch64::BLR ||
10302 LastInstrOpcode == AArch64::BLRNoIP) &&
10306 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10314 unsigned NumBytesNoStackCalls = 0;
10315 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10321 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10330 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10333 if (LRAvailable && !IsNoReturn) {
10334 NumBytesNoStackCalls += 4;
10336 CandidatesWithoutStackFixups.push_back(
C);
10341 else if (findRegisterToSaveLRTo(
C)) {
10342 NumBytesNoStackCalls += 12;
10344 CandidatesWithoutStackFixups.push_back(
C);
10349 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10350 NumBytesNoStackCalls += 12;
10352 CandidatesWithoutStackFixups.push_back(
C);
10358 NumBytesNoStackCalls += SequenceSize;
10365 if (!AllStackInstrsSafe ||
10366 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10367 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10369 if (RepeatedSequenceLocs.size() < MinRepeats)
10370 return std::nullopt;
10423 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10424 !findRegisterToSaveLRTo(
C));
10430 if (RepeatedSequenceLocs.size() < MinRepeats)
10431 return std::nullopt;
10440 bool ModStackToSaveLR =
false;
10443 ModStackToSaveLR =
true;
10452 ModStackToSaveLR =
true;
10454 if (ModStackToSaveLR) {
10456 if (!AllStackInstrsSafe)
10457 return std::nullopt;
10460 NumBytesToCreateFrame += 8;
10467 return std::nullopt;
10469 return std::make_unique<outliner::OutlinedFunction>(
10470 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10473void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10474 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10478 const auto &CFn = Candidates.front().getMF()->getFunction();
10480 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10481 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10482 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10483 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10486 if (CFn.hasFnAttribute(
"sign-return-address"))
10487 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10488 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10489 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10491 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10494bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10499 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10506 if (
F.hasSection())
10512 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10513 if (!AFI || AFI->
hasRedZone().value_or(
true))
10533 unsigned &Flags)
const {
10535 "Must track liveness!");
10537 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10552 auto AreAllUnsafeRegsDead = [&LRU]() {
10553 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10554 LRU.available(AArch64::NZCV);
10569 bool LRAvailableEverywhere =
true;
10571 LRU.addLiveOuts(
MBB);
10573 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10574 if (
MI.isCall() && !
MI.isTerminator())
10580 auto CreateNewRangeStartingAt =
10581 [&RangeBegin, &RangeEnd,
10583 RangeBegin = NewBegin;
10584 RangeEnd = std::next(RangeBegin);
10587 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
10593 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10595 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10597 Ranges.emplace_back(RangeBegin, RangeEnd);
10605 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10606 LRU.stepBackward(*FirstPossibleEndPt);
10609 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10610 if (AreAllUnsafeRegsDead())
10617 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10622 LRU.stepBackward(
MI);
10623 UpdateWholeMBBFlags(
MI);
10624 if (!AreAllUnsafeRegsDead()) {
10625 SaveRangeIfNonEmpty();
10626 CreateNewRangeStartingAt(
MI.getIterator());
10629 LRAvailableEverywhere &= LRU.available(AArch64::LR);
10630 RangeBegin =
MI.getIterator();
10635 if (AreAllUnsafeRegsDead())
10636 SaveRangeIfNonEmpty();
10644 if (!LRAvailableEverywhere)
10652 unsigned Flags)
const {
10653 MachineInstr &
MI = *MIT;
10657 switch (
MI.getOpcode()) {
10658 case AArch64::PACM:
10659 case AArch64::PACIASP:
10660 case AArch64::PACIBSP:
10661 case AArch64::PACIASPPC:
10662 case AArch64::PACIBSPPC:
10663 case AArch64::AUTIASP:
10664 case AArch64::AUTIBSP:
10665 case AArch64::AUTIASPPCi:
10666 case AArch64::AUTIASPPCr:
10667 case AArch64::AUTIBSPPCi:
10668 case AArch64::AUTIBSPPCr:
10669 case AArch64::RETAA:
10670 case AArch64::RETAB:
10671 case AArch64::RETAASPPCi:
10672 case AArch64::RETAASPPCr:
10673 case AArch64::RETABSPPCi:
10674 case AArch64::RETABSPPCr:
10675 case AArch64::EMITBKEY:
10676 case AArch64::PAUTH_PROLOGUE:
10677 case AArch64::PAUTH_EPILOGUE:
10687 if (
MI.isCFIInstruction())
10691 if (
MI.isTerminator())
10697 for (
const MachineOperand &MOP :
MI.operands()) {
10700 assert(!MOP.isCFIIndex());
10703 if (MOP.isReg() && !MOP.isImplicit() &&
10704 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
10711 if (
MI.getOpcode() == AArch64::ADRP)
10731 for (
const MachineOperand &MOP :
MI.operands()) {
10732 if (MOP.isGlobal()) {
10740 if (Callee &&
Callee->getName() ==
"\01_mcount")
10748 if (
MI.getOpcode() == AArch64::BLR ||
10749 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
10753 return UnknownCallOutlineType;
10761 return UnknownCallOutlineType;
10769 return UnknownCallOutlineType;
10790 for (MachineInstr &
MI :
MBB) {
10791 const MachineOperand *
Base;
10792 TypeSize Width(0,
false);
10794 bool OffsetIsScalable;
10797 if (!
MI.mayLoadOrStore() ||
10800 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
10804 TypeSize Scale(0U,
false);
10805 int64_t Dummy1, Dummy2;
10808 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
10810 assert(Scale != 0 &&
"Unexpected opcode!");
10811 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
10816 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
10817 StackOffsetOperand.
setImm(NewImm);
10823 bool ShouldSignReturnAddr) {
10824 if (!ShouldSignReturnAddr)
10832void AArch64InstrInfo::buildOutlinedFrame(
10836 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
10844 unsigned TailOpcode;
10846 TailOpcode = AArch64::TCRETURNdi;
10850 TailOpcode = AArch64::TCRETURNriALL;
10861 bool IsLeafFunction =
true;
10864 auto IsNonTailCall = [](
const MachineInstr &
MI) {
10865 return MI.isCall() && !
MI.isReturn();
10875 "Can only fix up stack references once");
10876 fixupPostOutline(
MBB);
10878 IsLeafFunction =
false;
10889 Et = std::prev(
MBB.
end());
10899 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
10903 CFIBuilder.buildDefCFAOffset(16);
10907 CFIBuilder.buildOffset(AArch64::LR, -16);
10921 RASignCondition, !IsLeafFunction);
10950 fixupPostOutline(
MBB);
10961 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
10971 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
10980 MachineInstr *Save;
10981 MachineInstr *Restore;
10987 assert(
Reg &&
"No callee-saved register available?");
11021 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11029bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11037 bool AllowSideEffects)
const {
11039 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11042 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11055 assert(STI.hasNEON() &&
"Expected to have NEON.");
11061std::optional<DestSourcePair>
11066 if (((
MI.getOpcode() == AArch64::ORRWrs &&
11067 MI.getOperand(1).getReg() == AArch64::WZR &&
11068 MI.getOperand(3).getImm() == 0x0) ||
11069 (
MI.getOpcode() == AArch64::ORRWrr &&
11070 MI.getOperand(1).getReg() == AArch64::WZR)) &&
11072 (!
MI.getOperand(0).getReg().isVirtual() ||
11073 MI.getOperand(0).getSubReg() == 0) &&
11074 (!
MI.getOperand(0).getReg().isPhysical() ||
11079 if (
MI.getOpcode() == AArch64::ORRXrs &&
11080 MI.getOperand(1).getReg() == AArch64::XZR &&
11081 MI.getOperand(3).getImm() == 0x0)
11084 return std::nullopt;
11087std::optional<DestSourcePair>
11089 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11090 MI.getOperand(1).getReg() == AArch64::WZR &&
11091 MI.getOperand(3).getImm() == 0x0) ||
11092 (
MI.getOpcode() == AArch64::ORRWrr &&
11093 MI.getOperand(1).getReg() == AArch64::WZR))
11095 return std::nullopt;
11098std::optional<RegImmPair>
11107 return std::nullopt;
11109 switch (
MI.getOpcode()) {
11111 return std::nullopt;
11112 case AArch64::SUBWri:
11113 case AArch64::SUBXri:
11114 case AArch64::SUBSWri:
11115 case AArch64::SUBSXri:
11118 case AArch64::ADDSWri:
11119 case AArch64::ADDSXri:
11120 case AArch64::ADDWri:
11121 case AArch64::ADDXri: {
11123 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11124 !
MI.getOperand(2).isImm())
11125 return std::nullopt;
11126 int Shift =
MI.getOperand(3).getImm();
11127 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11131 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11137static std::optional<ParamLoadedValue>
11141 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11143 return std::nullopt;
11145 Register DestReg = DestSrc->Destination->getReg();
11146 Register SrcReg = DestSrc->Source->getReg();
11149 return std::nullopt;
11154 if (DestReg == DescribedReg)
11158 if (
MI.getOpcode() == AArch64::ORRWrs &&
11159 TRI->isSuperRegister(DestReg, DescribedReg))
11163 if (
MI.getOpcode() == AArch64::ORRXrs &&
11164 TRI->isSubRegister(DestReg, DescribedReg)) {
11165 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11169 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11170 "Unhandled ORR[XW]rs copy case");
11172 return std::nullopt;
11175bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11180 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11186bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11190 auto isAsmGoto = [](
const MachineInstr &
MI) {
11191 return MI.getOpcode() == AArch64::INLINEASM_BR;
11201 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11208 for (
const MachineInstr &
MI :
MBB) {
11209 switch (
MI.getOpcode()) {
11210 case TargetOpcode::G_BRJT:
11211 case AArch64::JumpTableDest32:
11212 case AArch64::JumpTableDest16:
11213 case AArch64::JumpTableDest8:
11224std::optional<ParamLoadedValue>
11227 const MachineFunction *MF =
MI.getMF();
11229 switch (
MI.getOpcode()) {
11230 case AArch64::MOVZWi:
11231 case AArch64::MOVZXi: {
11234 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11235 return std::nullopt;
11237 if (!
MI.getOperand(1).isImm())
11238 return std::nullopt;
11239 int64_t Immediate =
MI.getOperand(1).getImm();
11240 int Shift =
MI.getOperand(2).getImm();
11244 case AArch64::ORRWrs:
11245 case AArch64::ORRXrs:
11252bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11255 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11256 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11259 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11269 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11272uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11276bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11280bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11285AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11289bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11290 unsigned Scale)
const {
11301 unsigned Shift =
Log2_64(NumBytes);
11302 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11310 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11315 return AArch64::BLRNoIP;
11317 return AArch64::BLR;
11323 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11333 Register TargetReg,
bool FrameSetup)
const {
11334 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11346 MF.
insert(MBBInsertPoint, LoopTestMBB);
11349 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11351 MF.
insert(MBBInsertPoint, ExitMBB);
11361 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11369 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11375 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11392 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11411 MBB.addSuccessor(LoopTestMBB);
11417 return ExitMBB->
begin();
11422 MachineFunction *MF;
11423 const TargetInstrInfo *
TII;
11424 const TargetRegisterInfo *
TRI;
11425 MachineRegisterInfo &MRI;
11428 MachineBasicBlock *LoopBB;
11430 MachineInstr *CondBranch;
11432 MachineInstr *Comp;
11434 unsigned CompCounterOprNum;
11436 MachineInstr *Update;
11438 unsigned UpdateCounterOprNum;
11442 bool IsUpdatePriorComp;
11448 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11449 MachineInstr *Comp,
unsigned CompCounterOprNum,
11450 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11451 Register Init,
bool IsUpdatePriorComp,
11452 const SmallVectorImpl<MachineOperand> &
Cond)
11454 TII(MF->getSubtarget().getInstrInfo()),
11455 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11456 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11457 CompCounterOprNum(CompCounterOprNum), Update(Update),
11458 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11461 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11467 std::optional<bool> createTripCountGreaterCondition(
11468 int TC, MachineBasicBlock &
MBB,
11469 SmallVectorImpl<MachineOperand> &CondParam)
override {
11477 void createRemainingIterationsGreaterCondition(
11478 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11479 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11481 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11483 void adjustTripCount(
int TripCountAdjust)
override {}
11485 bool isMVEExpanderSupported()
override {
return true; }
11504 }
else if (
I == ReplaceOprNum) {
11509 MBB.insert(InsertTo, NewMI);
11513void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
11529 assert(CondBranch->getOpcode() == AArch64::Bcc);
11533 if (CondBranch->getOperand(1).getMBB() == LoopBB)
11540 auto AccumulateCond = [&](
Register CurCond,
11551 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
11555 for (
int I = 0;
I <= TC; ++
I) {
11561 AccCond = AccumulateCond(AccCond, CC);
11565 if (Update != Comp && IsUpdatePriorComp) {
11567 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11568 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11572 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11574 }
else if (Update != Comp) {
11579 Counter = NextCounter;
11583 if (LastStage0Insts.
empty()) {
11587 if (IsUpdatePriorComp)
11592 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11595 for (
int I = 0;
I <= TC; ++
I) {
11599 AccCond = AccumulateCond(AccCond, CC);
11600 if (
I != TC && Update != Comp)
11603 Counter = NextCounter;
11619 assert(Phi.getNumOperands() == 5);
11620 if (Phi.getOperand(2).getMBB() ==
MBB) {
11621 RegMBB = Phi.getOperand(1).getReg();
11622 RegOther = Phi.getOperand(3).getReg();
11624 assert(Phi.getOperand(4).getMBB() ==
MBB);
11625 RegMBB = Phi.getOperand(3).getReg();
11626 RegOther = Phi.getOperand(1).getReg();
11631 if (!
Reg.isVirtual())
11640 unsigned &UpdateCounterOprNum,
Register &InitReg,
11641 bool &IsUpdatePriorComp) {
11655 if (!
Reg.isVirtual())
11658 UpdateInst =
nullptr;
11659 UpdateCounterOprNum = 0;
11661 IsUpdatePriorComp =
true;
11665 if (Def->getParent() != LoopBB)
11667 if (Def->isCopy()) {
11669 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11671 CurReg = Def->getOperand(1).getReg();
11672 }
else if (Def->isPHI()) {
11676 IsUpdatePriorComp =
false;
11681 switch (Def->getOpcode()) {
11682 case AArch64::ADDSXri:
11683 case AArch64::ADDSWri:
11684 case AArch64::SUBSXri:
11685 case AArch64::SUBSWri:
11686 case AArch64::ADDXri:
11687 case AArch64::ADDWri:
11688 case AArch64::SUBXri:
11689 case AArch64::SUBWri:
11691 UpdateCounterOprNum = 1;
11693 case AArch64::ADDSXrr:
11694 case AArch64::ADDSWrr:
11695 case AArch64::SUBSXrr:
11696 case AArch64::SUBSWrr:
11697 case AArch64::ADDXrr:
11698 case AArch64::ADDWrr:
11699 case AArch64::SUBXrr:
11700 case AArch64::SUBWrr:
11703 UpdateCounterOprNum = 1;
11705 UpdateCounterOprNum = 2;
11712 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
11727std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
11738 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
11749 if (
TBB == LoopBB && FBB == LoopBB)
11753 if (
TBB != LoopBB && FBB ==
nullptr)
11756 assert((
TBB == LoopBB || FBB == LoopBB) &&
11757 "The Loop must be a single-basic-block loop");
11762 if (CondBranch->
getOpcode() != AArch64::Bcc)
11770 unsigned CompCounterOprNum = 0;
11772 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
11776 switch (
MI.getOpcode()) {
11777 case AArch64::SUBSXri:
11778 case AArch64::SUBSWri:
11779 case AArch64::ADDSXri:
11780 case AArch64::ADDSWri:
11782 CompCounterOprNum = 1;
11784 case AArch64::ADDSWrr:
11785 case AArch64::ADDSXrr:
11786 case AArch64::SUBSWrr:
11787 case AArch64::SUBSXrr:
11791 if (isWhileOpcode(
MI.getOpcode())) {
11798 if (CompCounterOprNum == 0) {
11800 CompCounterOprNum = 2;
11802 CompCounterOprNum = 1;
11814 bool IsUpdatePriorComp;
11815 unsigned UpdateCounterOprNum;
11817 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
11820 return std::make_unique<AArch64PipelinerLoopInfo>(
11821 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
11831 TypeSize Scale(0U,
false), Width(0U,
false);
11832 int64_t MinOffset, MaxOffset;
11833 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
11835 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
11836 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
11837 if (Imm < MinOffset || Imm > MaxOffset) {
11838 ErrInfo =
"Unexpected immediate on load/store instruction";
11844 const MCInstrDesc &MCID =
MI.getDesc();
11846 const MachineOperand &MO =
MI.getOperand(
Op);
11850 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
11859 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
11870#define GET_INSTRINFO_HELPERS
11871#define GET_INSTRMAP_INFO
11872#include "AArch64GenInstrInfo.inc"
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool forwardCopyWillClobberTuple(unsigned DestReg, unsigned SrcReg, unsigned NumRegs)
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
static Register genNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned MnegOpc, const TargetRegisterClass *RC)
genNeg - Helper to generate an intermediate negation of the second operand of Root
static bool isFrameStoreOpcode(int Opcode)
static cl::opt< unsigned > GatherOptSearchLimit("aarch64-search-limit", cl::Hidden, cl::init(2048), cl::desc("Restrict range of instructions to search for the " "machine-combiner gather pattern optimization"))
static bool getMaddPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find instructions that can be turned into madd.
static AArch64CC::CondCode findCondCodeUsedByInstr(const MachineInstr &Instr)
Find a condition code used by the instruction.
static MachineInstr * genFusedMultiplyAcc(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyAcc - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate64(unsigned Opc)
static bool isFrameLoadOpcode(int Opcode)
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool areCFlagsAccessedBetweenInstrs(MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI, const AccessKind AccessToCheck=AK_All)
True when condition flags are accessed (either by writing or reading) on the instruction trace starti...
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Floating-Point Support.
static bool isADDSRegImm(unsigned Opcode)
static bool isCheapCopy(const MachineInstr &MI, const AArch64RegisterInfo &RI)
static bool isANDOpcode(MachineInstr &MI)
static void appendOffsetComment(int NumBytes, llvm::raw_string_ostream &Comment, StringRef RegScale={})
static unsigned sForm(MachineInstr &Instr)
Get opcode of S version of Instr.
static bool isCombineInstrSettingFlag(unsigned Opc)
static bool getFNEGPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static bool getIndVarInfo(Register Reg, const MachineBasicBlock *LoopBB, MachineInstr *&UpdateInst, unsigned &UpdateCounterOprNum, Register &InitReg, bool &IsUpdatePriorComp)
If Reg is an induction variable, return true and set some parameters.
static bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
static bool mustAvoidNeonAtMBBI(const AArch64Subtarget &Subtarget, MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if in a streaming call site region without SME-FA64.
static bool isPostIndexLdStOpcode(unsigned Opcode)
Return true if the opcode is a post-index ld/st instruction, which really loads from base+0.
static std::optional< unsigned > getLFIInstSizeInBytes(const MachineInstr &MI)
Return the maximum number of bytes of code the specified instruction may be after LFI rewriting.
static unsigned getBranchDisplacementBits(unsigned Opc)
static cl::opt< unsigned > CBDisplacementBits("aarch64-cb-offset-bits", cl::Hidden, cl::init(9), cl::desc("Restrict range of CB instructions (DEBUG)"))
static std::optional< ParamLoadedValue > describeORRLoadedValue(const MachineInstr &MI, Register DescribedReg, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
If the given ORR instruction is a copy, and DescribedReg overlaps with the destination register then,...
static bool getFMULPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static void appendReadRegExpr(SmallVectorImpl< char > &Expr, unsigned RegNum)
static MachineInstr * genMaddR(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, unsigned VR, const TargetRegisterClass *RC)
genMaddR - Generate madd instruction and combine mul and add using an extra virtual register Example ...
static Register cloneInstr(const MachineInstr *MI, unsigned ReplaceOprNum, Register ReplaceReg, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertTo)
Clone an instruction from MI.
static bool scaleOffset(unsigned Opc, int64_t &Offset)
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
unsigned scaledOffsetOpcode(unsigned Opcode, unsigned &Scale)
static MachineInstr * genFusedMultiplyIdx(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyIdx - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genIndexedMultiply(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxDupOp, unsigned MulOpc, const TargetRegisterClass *RC, MachineRegisterInfo &MRI)
Fold (FMUL x (DUP y lane)) into (FMUL_indexed x y lane)
static bool isSUBSRegImm(unsigned Opcode)
static bool UpdateOperandRegClass(MachineInstr &Instr)
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
static bool isInStreamingCallSiteRegion(MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if the instruction at I is in a streaming call site region, within a single basic block.
static bool canCmpInstrBeRemoved(MachineInstr &MI, MachineInstr &CmpInstr, int CmpValue, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > &CCUseInstrs, bool &IsInvertCC)
unsigned unscaledOffsetOpcode(unsigned Opcode)
static bool getLoadPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Search for patterns of LD instructions we can optimize.
static bool canInstrSubstituteCmpInstr(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI)
Check if CmpInstr can be substituted by MI.
static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC)
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static void appendLoadRegExpr(SmallVectorImpl< char > &Expr, int64_t OffsetFromDefCFA)
static void appendConstantExpr(SmallVectorImpl< char > &Expr, int64_t Constant, dwarf::LocationAtom Operation)
static unsigned convertToNonFlagSettingOpc(const MachineInstr &MI)
Return the opcode that does not set flags when possible - otherwise return the original opcode.
static bool outliningCandidatesV8_3OpsConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool isCombineInstrCandidate32(unsigned Opc)
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
static unsigned offsetExtendOpcode(unsigned Opcode)
static void loadRegPairFromStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, Register DestReg, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
static void generateGatherLanePattern(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned Pattern, unsigned NumLanes)
Generate optimized instruction sequence for gather load patterns to improve Memory-Level Parallelism ...
static bool getMiscPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find other MI combine patterns.
static bool outliningCandidatesSigningKeyConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, MCRegister Reg, unsigned SubIdx, RegState State, const TargetRegisterInfo *TRI)
static bool outliningCandidatesSigningScopeConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool shouldClusterFI(const MachineFrameInfo &MFI, int FI1, int64_t Offset1, unsigned Opcode1, int FI2, int64_t Offset2, unsigned Opcode2)
static cl::opt< unsigned > TBZDisplacementBits("aarch64-tbz-offset-bits", cl::Hidden, cl::init(14), cl::desc("Restrict range of TB[N]Z instructions (DEBUG)"))
static void extractPhiReg(const MachineInstr &Phi, const MachineBasicBlock *MBB, Register &RegMBB, Register &RegOther)
static MCCFIInstruction createDefCFAExpression(const TargetRegisterInfo &TRI, unsigned Reg, const StackOffset &Offset)
static bool isDefinedOutside(Register Reg, const MachineBasicBlock *BB)
static MachineInstr * genFusedMultiply(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC, FMAInstKind kind=FMAInstKind::Default, const Register *ReplacedAddend=nullptr)
genFusedMultiply - Generate fused multiply instructions.
static bool getGatherLanePattern(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, unsigned LoadLaneOpCode, unsigned NumLanes)
Check if the given instruction forms a gather load pattern that can be optimized for better Memory-Le...
static MachineInstr * genFusedMultiplyIdxNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate(unsigned Opc)
static unsigned regOffsetOpcode(unsigned Opcode)
MachineOutlinerClass
Constants defining how certain sequences should be outlined.
@ MachineOutlinerTailCall
Emit a save, restore, call, and return.
@ MachineOutlinerRegSave
Emit a call and tail-call.
@ MachineOutlinerNoLRSave
Only emit a branch.
@ MachineOutlinerThunk
Emit a call and return.
static cl::opt< unsigned > BDisplacementBits("aarch64-b-offset-bits", cl::Hidden, cl::init(26), cl::desc("Restrict range of B instructions (DEBUG)"))
static bool areCFlagsAliveInSuccessors(const MachineBasicBlock *MBB)
Check if AArch64::NZCV should be alive in successors of MBB.
static void emitFrameOffsetAdj(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int64_t Offset, unsigned Opc, const TargetInstrInfo *TII, MachineInstr::MIFlag Flag, bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFAOffset, StackOffset CFAOffset, unsigned FrameReg)
static bool isCheapImmediate(const MachineInstr &MI, unsigned BitSize)
static cl::opt< unsigned > CBZDisplacementBits("aarch64-cbz-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of CB[N]Z instructions (DEBUG)"))
static void genSubAdd2SubSub(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, unsigned IdxOpd1, DenseMap< Register, unsigned > &InstrIdxForVirtReg)
Do the following transformation A - (B + C) ==> (A - B) - C A - (B + C) ==> (A - C) - B.
static unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewReg=nullptr)
static void signOutlinedFunction(MachineFunction &MF, MachineBasicBlock &MBB, const AArch64InstrInfo *TII, bool ShouldSignReturnAddr)
static MachineInstr * genFNegatedMAD(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs)
static bool canCombineWithMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc, unsigned ZeroReg)
static void storeRegPairToStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, Register SrcReg, bool IsKill, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static const Function * getParent(const Value *V)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Forward Handle Accesses
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
Machine Check Debug Module
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
MachineInstr unsigned OpIdx
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
PowerPC Reduce CR logical Operation
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file declares the machine register scavenger class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc=0)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setOutliningStyle(const std::string &Style)
bool branchProtectionPAuthLR() const
std::optional< bool > hasRedZone() const
static bool shouldSignReturnAddress(SignReturnAddress Condition, bool IsLRSpilled)
bool shouldSignWithBKey() const
static bool isHForm(const MachineInstr &MI)
Returns whether the instruction is in H form (16 bit operands)
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
static bool hasBTISemantics(const MachineInstr &MI)
Returns whether the instruction can be compatible with non-zero BTYPE.
static bool isQForm(const MachineInstr &MI)
Returns whether the instruction is in Q form (128 bit operands)
static bool getMemOpInfo(unsigned Opcode, TypeSize &Scale, TypeSize &Width, int64_t &MinOffset, int64_t &MaxOffset)
Returns true if opcode Opc is a memory operation.
static bool isTailCallReturnInst(const MachineInstr &MI)
Returns true if MI is one of the TCRETURN* instructions.
static bool isFPRCopy(const MachineInstr &MI)
Does this instruction rename an FPR without modifying bits?
MachineInstr * emitLdStWithAddr(MachineInstr &MemI, const ExtAddrMode &AM) const override
std::optional< DestSourcePair > isCopyInstrImpl(const MachineInstr &MI) const override
If the specific machine instruction is an instruction that moves/copies value from one register to an...
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
static bool isZExtLoad(const MachineInstr &MI)
Returns whether the instruction is a zero-extending load.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
static bool isGPRCopy(const MachineInstr &MI)
Does this instruction rename a GPR without modifying bits?
static unsigned convertToFlagSettingOpc(unsigned Opc)
Return the opcode that set flags when possible.
void createPauthEpilogueInstr(MachineBasicBlock &MBB, DebugLoc DL) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
Register isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
static const MachineOperand & getLdStOffsetOp(const MachineInstr &MI)
Returns the immediate offset operator of a load/store.
bool isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg, Register &DstReg, unsigned &SubIdx) const override
static std::optional< unsigned > getUnscaledLdSt(unsigned Opc)
Returns the unscaled load/store for the scaled load/store opcode, if there is a corresponding unscale...
static bool hasUnscaledLdStOffset(unsigned Opc)
Return true if it has an unscaled load/store offset.
static const MachineOperand & getLdStAmountOp(const MachineInstr &MI)
Returns the shift amount operator of a load/store.
static bool isPreLdSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed load/store.
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI, const TargetRegisterInfo *TRI) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width, const TargetRegisterInfo *TRI) const override
bool analyzeBranchPredicate(MachineBasicBlock &MBB, MachineBranchPredicate &MBP, bool AllowModify) const override
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isSExtLoad(const MachineInstr &MI)
Returns whether the instruction is a sign-extending load.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static bool isPreSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed store.
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
AArch64InstrInfo(const AArch64Subtarget &STI)
static bool isPairedLdSt(const MachineInstr &MI)
Returns whether the instruction is a paired load/store.
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width, const TargetRegisterInfo *TRI) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
bool shouldClusterMemOps(ArrayRef< const MachineOperand * > BaseOps1, int64_t Offset1, bool OffsetIsScalable1, ArrayRef< const MachineOperand * > BaseOps2, int64_t Offset2, bool OffsetIsScalable2, unsigned ClusterSize, unsigned NumBytes) const override
Detect opportunities for ldp/stp formation.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg, const MachineInstr &AddrI, ExtAddrMode &AM) const override
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
Register isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2, int64_t CmpMask, int64_t CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction supplying the argument to the comparison into one that...
static unsigned getLoadStoreImmIdx(unsigned Opc)
Returns the index for the immediate for a given instruction.
static bool isGPRZero(const MachineInstr &MI)
Does this instruction set its full destination register to zero?
void copyGPRRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, unsigned ZeroReg, llvm::ArrayRef< unsigned > Indices) const
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &CmpMask, int64_t &CmpValue) const override
analyzeCompare - For a comparison instruction, return the source registers in SrcReg and SrcReg2,...
CombinerObjective getCombinerObjective(unsigned Pattern) const override
static bool isFpOrNEON(Register Reg)
Returns whether the physical register is FP or NEON.
bool isAsCheapAsAMove(const MachineInstr &MI) const override
std::optional< DestSourcePair > isCopyLikeInstrImpl(const MachineInstr &MI) const override
static void suppressLdStPair(MachineInstr &MI)
Hint that pairing the given load or store is unprofitable.
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
static bool isPreLd(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed load.
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
static int getMemScale(unsigned Opc)
Scaling factor for (scaled or unscaled) load or store.
bool isCandidateToMergeOrPair(const MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
MCInst getNop() const override
static const MachineOperand & getLdStBaseOp(const MachineInstr &MI)
Returns the base register operator of a load/store.
bool isReservedReg(const MachineFunction &MF, MCRegister Reg) const
const AArch64RegisterInfo * getRegisterInfo() const override
bool isNeonAvailable() const
Returns true if the target has NEON and the function at runtime is known to have NEON enabled (e....
bool isSVEorStreamingSVEAvailable() const
Returns true if the target has access to either the full range of SVE instructions,...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
This is an important base class in LLVM.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static LocationSize precise(uint64_t Value)
This class is intended to be used as a base class for asm properties and features specific to the tar...
bool usesWindowsCFI() const
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
static constexpr unsigned NoRegister
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
reverse_instr_iterator instr_rbegin()
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
reverse_instr_iterator instr_rend()
Instructions::iterator instr_iterator
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstrBundleIterator< MachineInstr > iterator
void setMachineBlockAddressTaken()
Set this block to indicate that its address is used as something other than the target of a terminato...
LLVM_ABI bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
void setStackID(int ObjectIdx, uint8_t ID)
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getNumObjects() const
Return the number of objects.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineInstr - Allocate a new MachineInstr.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
const MachineInstrBuilder & addUse(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addSym(MCSymbol *Sym, unsigned char TargetFlags=0) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
bool isCall(QueryType Type=AnyInBundle) const
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
LLVM_ABI uint32_t mergeFlagsWith(const MachineInstr &Other) const
Return the MIFlags which represent both MachineInstrs.
unsigned getNumOperands() const
Retuns the total number of operands.
LLVM_ABI unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
LLVM_ABI bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore,...
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI) const
Returns true if the register is dead in this machine instruction.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr fully defines the specified register.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
LLVM_ABI bool isLoadFoldBarrier() const
Returns true if it is illegal to fold a load across this instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
LLVM_ABI void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
const MachineOperand & getOperand(unsigned i) const
uint32_t getFlags() const
Return the MI flags bitvector.
LLVM_ABI int findRegisterDefOperandIdx(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false) const
Returns the operand index that is a def of the specified register or -1 if it is not found.
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
@ MOVolatile
The memory access is volatile.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
void setImm(int64_t immVal)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
void setIsDead(bool Val=true)
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsKill(bool Val=true)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
unsigned getTargetFlags() const
static MachineOperand CreateImm(int64_t Val)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void setIsUndef(bool Val=true)
Register getReg() const
getReg - Returns the register number.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI void clearKillFlags(Register Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
LLVM_ABI MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
LLVM_ABI Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool reservedRegsFrozen() const
reservedRegsFrozen - Returns true after freezeReservedRegs() was called to ensure the set of reserved...
bool def_empty(Register RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
use_instr_nodbg_iterator use_instr_nodbg_begin(Register RegNo) const
bool hasOneDef(Register RegNo) const
Return true if there is exactly one operand defining the specified register.
const TargetRegisterClass * getRegClassOrNull(Register Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet.
LLVM_ABI const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
LLVM_ABI MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
A Module instance is used to store all the information related to an LLVM module.
MI-level patchpoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Represents a location in source code.
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level stackmap operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
int64_t getScalable() const
Returns the scalable component of the stack.
static StackOffset get(int64_t Fixed, int64_t Scalable)
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
MI-level Statepoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given statepoint should emit.
StringRef - Represent a constant reference to a string, i.e.
Object returned by analyzeLoopForPipelining.
TargetInstrInfo - Interface to description of machine instruction set.
virtual void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
virtual std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg.
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
virtual CombinerObjective getCombinerObjective(unsigned Pattern) const
Return the objective of a combiner pattern.
virtual bool isFunctionSafeToSplit(const MachineFunction &MF) const
Return true if the function is a viable candidate for machine function splitting.
CodeModel::Model getCodeModel() const
Returns the code model.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
Target - Wrapper for Target specific information.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
Value * getOperand(unsigned i) const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
self_iterator getIterator()
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static CondCode getInvertedCondCode(CondCode Code)
@ MO_DLLIMPORT
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
@ MO_NC
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow.
@ MO_G1
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address,...
@ MO_S
MO_S - Indicates that the bits of the symbol operand represented by MO_G0 etc are signed.
@ MO_PAGEOFF
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page.
@ MO_GOT
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
@ MO_PREL
MO_PREL - Indicates that the bits of the symbol operand represented by MO_G0 etc are PC relative.
@ MO_G0
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...
@ MO_ARM64EC_CALLMANGLE
MO_ARM64EC_CALLMANGLE - Operand refers to the Arm64EC-mangled version of a symbol,...
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
@ MO_HI12
MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address,...
@ MO_TLS
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
@ MO_G2
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...
@ MO_TAGGED
MO_TAGGED - With MO_PAGE, indicates that the page includes a memory tag in bits 56-63.
@ MO_G3
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...
@ MO_COFFSTUB
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "....
unsigned getCheckerSizeInBytes(AuthCheckMethod Method)
Returns the number of bytes added by checkAuthenticatedRegister.
static uint64_t decodeLogicalImmediate(uint64_t val, unsigned regSize)
decodeLogicalImmediate - Decode a logical immediate value in the form "N:immr:imms" (where the immr a...
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
static unsigned getArithShiftValue(unsigned Imm)
getArithShiftValue - get the arithmetic shift value.
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
static AArch64_AM::ShiftExtendType getExtendType(unsigned Imm)
getExtendType - Extract the extend type for operands of arithmetic ops.
static AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm)
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
static unsigned getShifterImm(AArch64_AM::ShiftExtendType ST, unsigned Imm)
getShifterImm - Encode the shift type and amount: imm: 6-bit shift amount shifter: 000 ==> lsl 001 ==...
void expandMOVImm(uint64_t Imm, unsigned BitSize, SmallVectorImpl< ImmInsnModel > &Insn)
Expand a MOVi32imm or MOVi64imm pseudo instruction to one or more real move-immediate instructions to...
static const uint64_t InstrFlagIsWhile
static const uint64_t InstrFlagIsPTestLike
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
@ ScalablePredicateVector
initializer< Ty > init(const Ty &Val)
InstrType
Represents how an instruction should be mapped by the outliner.
NodeAddr< InstrNode * > Instr
LLVM_ABI Instruction & back() const
LLVM_ABI iterator begin() const
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static bool isCondBranchOpcode(int Opc)
MCCFIInstruction createDefCFA(const TargetRegisterInfo &TRI, unsigned FrameReg, unsigned Reg, const StackOffset &Offset, bool LastAdjustmentWasScalable=true)
static bool isPTrueOpcode(unsigned Opc)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool succeeded(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
constexpr RegState getKillRegState(bool B)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static bool isIndirectBranchOpcode(int Opc)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getBLRCallOpcode(const MachineFunction &MF)
Return opcode to be used for indirect calls.
@ AArch64FrameOffsetIsLegal
Offset is legal.
@ AArch64FrameOffsetCanUpdate
Offset can apply, at least partly.
@ AArch64FrameOffsetCannotUpdate
Offset cannot apply.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static bool isSEHInstruction(const MachineInstr &MI)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
AArch64MachineCombinerPattern
@ MULSUBv2i32_indexed_OP1
@ MULADDv4i16_indexed_OP2
@ MULSUBv8i16_indexed_OP2
@ MULSUBv4i16_indexed_OP2
@ MULSUBv4i32_indexed_OP2
@ MULADDv2i32_indexed_OP1
@ MULADDv4i32_indexed_OP1
@ MULADDv2i32_indexed_OP2
@ MULSUBv4i16_indexed_OP1
@ MULADDv4i32_indexed_OP2
@ MULSUBv8i16_indexed_OP1
@ MULSUBv2i32_indexed_OP2
@ MULADDv8i16_indexed_OP1
@ MULSUBv4i32_indexed_OP1
@ MULADDv8i16_indexed_OP2
@ MULADDv4i16_indexed_OP1
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr, bool EmitCFAOffset=false, StackOffset InitialOffset={}, unsigned FrameReg=AArch64::SP)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr RegState getDefRegState(bool B)
CombinerObjective
The combiner's goal may differ based on which pattern it is attempting to optimize.
std::optional< UsedNZCV > examineCFlagsUse(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > *CCUseInstrs=nullptr)
CodeGenOptLevel
Code generation optimization level.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
static MCRegister getXRegFromWReg(MCRegister Reg)
MCCFIInstruction createCFAOffset(const TargetRegisterInfo &MRI, unsigned Reg, const StackOffset &OffsetFromDefCFA, std::optional< int64_t > IncomingVGOffsetFromDefCFA)
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
static bool isUncondBranchOpcode(int Opc)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, StackOffset &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
static const MachineMemOperand::Flags MOSuppressPair
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
void appendLEB128(SmallVectorImpl< U > &Buffer, T Value)
bool optimizeTerminators(MachineBasicBlock *MBB, const TargetInstrInfo &TII)
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
bool isNZCVTouchedInInstructionRange(const MachineInstr &DefMI, const MachineInstr &UseMI, const TargetRegisterInfo *TRI)
Return true if there is an instruction /after/ DefMI and before UseMI which either reads or clobbers ...
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
static const MachineMemOperand::Flags MOStridedAccess
constexpr RegState getUndefRegState(bool B)
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.
LLVM_ABI 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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Used to describe addressing mode similar to ExtAddrMode in CodeGenPrepare.
LLVM_ABI static const MBBSectionID ColdSectionID
This class contains a discriminated union of information about pointers in memory operands,...
static LLVM_ABI MachinePointerInfo getUnknownStack(MachineFunction &MF)
Stack memory without other information.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
An individual sequence of instructions to be replaced with a call to an outlined function.
MachineFunction * getMF() const
The information necessary to create an outlined function for some class of candidate.