67#define GET_INSTRINFO_CTOR_DTOR
68#include "AArch64GenInstrInfo.inc"
70#define DEBUG_TYPE "AArch64InstrInfo"
72STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
73STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
74 "instructions expanded from canonical COPY");
75STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
76 "instructions expanded from canonical COPY");
77STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
78 "instructions expanded from canonical COPY");
83 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
87 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
91 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
95 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
99 cl::desc(
"Restrict range of B instructions (DEBUG)"));
103 cl::desc(
"Restrict range of instructions to search for the "
104 "machine-combiner gather pattern optimization"));
109 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
119 switch (
MI.getOpcode()) {
130 if (
MI.getOperand(0).getReg() != AArch64::LR)
135 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
136 MI.getOperand(3).getImm() == 1)
144 bool ModifiesLR =
false;
145 bool ModifiesSP =
false;
149 if (MO.getReg() == AArch64::LR)
151 else if (MO.getReg() == AArch64::SP)
160 if (
MI.mayLoadOrStore()) {
168 if (ModifiesSP || ModifiesLR)
186 auto Op =
MI.getOpcode();
187 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
188 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
192 if (
MI.isMetaInstruction())
197 unsigned NumBytes = 0;
207 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
210 if (!MFI->shouldSignReturnAddress(*MF))
213 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
221 switch (
Desc.getOpcode()) {
224 return Desc.getSize();
231 case TargetOpcode::STACKMAP:
234 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
236 case TargetOpcode::PATCHPOINT:
239 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
241 case TargetOpcode::STATEPOINT:
243 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
248 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
253 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
255 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
256 case TargetOpcode::PATCHABLE_TAIL_CALL:
257 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
261 case TargetOpcode::PATCHABLE_EVENT_CALL:
267 NumBytes =
MI.getOperand(1).getImm();
269 case AArch64::MOVaddr:
270 case AArch64::MOVaddrJT:
271 case AArch64::MOVaddrCP:
272 case AArch64::MOVaddrBA:
273 case AArch64::MOVaddrTLS:
274 case AArch64::MOVaddrEXT: {
278 MI.getOperand(1).getTargetFlags(),
279 Subtarget.isTargetMachO(), Insn);
280 NumBytes = Insn.
size() * 4;
284 case AArch64::MOVi32imm:
285 case AArch64::MOVi64imm: {
287 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
290 NumBytes = Insn.
size() * 4;
294 case TargetOpcode::BUNDLE:
295 NumBytes = getInstBundleSize(
MI);
331 case AArch64::CBWPri:
332 case AArch64::CBXPri:
333 case AArch64::CBWPrr:
334 case AArch64::CBXPrr:
342 case AArch64::CBBAssertExt:
343 case AArch64::CBHAssertExt:
374 case AArch64::CBWPri:
375 case AArch64::CBXPri:
376 case AArch64::CBBAssertExt:
377 case AArch64::CBHAssertExt:
378 case AArch64::CBWPrr:
379 case AArch64::CBXPrr:
385 int64_t BrOffset)
const {
387 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
388 "over conditional branch expansion");
389 return isIntN(Bits, BrOffset / 4);
394 switch (
MI.getOpcode()) {
398 return MI.getOperand(0).getMBB();
403 return MI.getOperand(2).getMBB();
409 return MI.getOperand(1).getMBB();
410 case AArch64::CBWPri:
411 case AArch64::CBXPri:
412 case AArch64::CBBAssertExt:
413 case AArch64::CBHAssertExt:
414 case AArch64::CBWPrr:
415 case AArch64::CBXPrr:
416 return MI.getOperand(3).getMBB();
426 assert(RS &&
"RegScavenger required for long branching");
428 "new block should be inserted for expanding unconditional branch");
431 "restore block should be inserted for restoring clobbered registers");
438 "Branch offsets outside of the signed 33-bit range not supported");
449 RS->enterBasicBlockEnd(
MBB);
452 constexpr Register Reg = AArch64::X16;
453 if (!RS->isRegUsed(Reg)) {
454 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
465 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
466 if (Scavenged != AArch64::NoRegister) {
467 buildIndirectBranch(Scavenged, NewDestBB);
468 RS->setRegUsed(Scavenged);
477 "Unable to insert indirect branch inside function that has red zone");
500 bool AllowModify)
const {
507 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
508 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
512 if (!isUnpredicatedTerminator(*
I))
519 unsigned LastOpc = LastInst->
getOpcode();
520 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
535 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
542 LastInst = SecondLastInst;
544 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
549 SecondLastInst = &*
I;
550 SecondLastOpc = SecondLastInst->
getOpcode();
561 LastInst = SecondLastInst;
563 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
565 "unreachable unconditional branches removed above");
574 SecondLastInst = &*
I;
575 SecondLastOpc = SecondLastInst->
getOpcode();
579 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
595 I->eraseFromParent();
604 I->eraseFromParent();
613 MachineBranchPredicate &MBP,
614 bool AllowModify)
const {
626 assert(MBP.TrueDest &&
"expected!");
627 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
629 MBP.ConditionDef =
nullptr;
630 MBP.SingleUseCondition =
false;
640 if (
I ==
MBB.begin())
656 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
657 MBP.ConditionDef = &
MI;
666 case AArch64::CBNZX: {
670 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
671 ? MachineBranchPredicate::PRED_NE
672 : MachineBranchPredicate::PRED_EQ;
673 Register CondReg = MBP.LHS.getReg();
682 case AArch64::TBNZX: {
703 Cond[1].setImm(AArch64::CBNZW);
706 Cond[1].setImm(AArch64::CBZW);
709 Cond[1].setImm(AArch64::CBNZX);
712 Cond[1].setImm(AArch64::CBZX);
715 Cond[1].setImm(AArch64::TBNZW);
718 Cond[1].setImm(AArch64::TBZW);
721 Cond[1].setImm(AArch64::TBNZX);
724 Cond[1].setImm(AArch64::TBZX);
728 case AArch64::CBWPri:
729 case AArch64::CBXPri:
730 case AArch64::CBBAssertExt:
731 case AArch64::CBHAssertExt:
732 case AArch64::CBWPrr:
733 case AArch64::CBXPrr: {
746 int *BytesRemoved)
const {
756 I->eraseFromParent();
760 if (
I ==
MBB.begin()) {
773 I->eraseFromParent();
780void AArch64InstrInfo::instantiateCondBranch(
805 if (
Cond.size() > 5) {
816 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
843 unsigned Opc =
MI.getOpcode();
850 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
851 MI.getOperand(0).getReg() == AArch64::XZR) {
853 dbgs() <<
"Removing always taken branch: " <<
MI);
856 for (
auto *S : Succs)
858 MBB->removeSuccessor(S);
860 while (
MBB->rbegin() != &
MI)
861 MBB->rbegin()->eraseFromParent();
862 MI.eraseFromParent();
872 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
873 MI.getOperand(0).getReg() == AArch64::XZR) {
875 dbgs() <<
"Removing never taken branch: " <<
MI);
877 MI.getParent()->removeSuccessor(
Target);
878 MI.eraseFromParent();
891 if (!
DefMI->isFullCopy())
893 VReg =
DefMI->getOperand(1).getReg();
902 unsigned *NewReg =
nullptr) {
907 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
911 switch (
DefMI->getOpcode()) {
912 case AArch64::SUBREG_TO_REG:
916 if (!
DefMI->getOperand(1).isReg())
918 if (!
DefMI->getOperand(2).isImm() ||
919 DefMI->getOperand(2).getImm() != AArch64::sub_32)
922 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
924 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
927 SrcReg = AArch64::XZR;
928 Opc = AArch64::CSINCXr;
931 case AArch64::MOVi32imm:
932 case AArch64::MOVi64imm:
933 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
935 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
936 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
939 case AArch64::ADDSXri:
940 case AArch64::ADDSWri:
942 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
947 case AArch64::ADDXri:
948 case AArch64::ADDWri:
950 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
951 DefMI->getOperand(3).getImm() != 0)
953 SrcReg =
DefMI->getOperand(1).getReg();
954 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
957 case AArch64::ORNXrr:
958 case AArch64::ORNWrr: {
961 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
963 SrcReg =
DefMI->getOperand(2).getReg();
964 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
968 case AArch64::SUBSXrr:
969 case AArch64::SUBSWrr:
971 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
976 case AArch64::SUBXrr:
977 case AArch64::SUBWrr: {
980 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
982 SrcReg =
DefMI->getOperand(2).getReg();
983 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
989 assert(
Opc && SrcReg &&
"Missing parameters");
1001 int &FalseCycles)
const {
1012 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1016 unsigned ExtraCondLat =
Cond.size() != 1;
1020 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1021 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1023 CondCycles = 1 + ExtraCondLat;
1024 TrueCycles = FalseCycles = 1;
1034 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1035 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1036 CondCycles = 5 + ExtraCondLat;
1037 TrueCycles = FalseCycles = 2;
1054 switch (
Cond.size()) {
1074 case AArch64::CBNZW:
1078 case AArch64::CBNZX:
1109 case AArch64::TBNZW:
1110 case AArch64::TBNZX:
1132 unsigned SubsOpc, SubsDestReg;
1138 case AArch64::CBWPri:
1139 SubsOpc = AArch64::SUBSWri;
1140 SubsDestReg = AArch64::WZR;
1143 case AArch64::CBXPri:
1144 SubsOpc = AArch64::SUBSXri;
1145 SubsDestReg = AArch64::XZR;
1148 case AArch64::CBWPrr:
1149 SubsOpc = AArch64::SUBSWrr;
1150 SubsDestReg = AArch64::WZR;
1153 case AArch64::CBXPrr:
1154 SubsOpc = AArch64::SUBSXrr;
1155 SubsDestReg = AArch64::XZR;
1184 switch (ExtendType) {
1190 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1191 ExtOpc = AArch64::SBFMWri;
1197 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1198 ExtOpc = AArch64::SBFMWri;
1204 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1205 ExtOpc = AArch64::ANDWri;
1211 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1212 ExtOpc = AArch64::ANDWri;
1221 if (ExtOpc != AArch64::ANDWri)
1223 MBBI.addImm(ExtBits);
1251 bool TryFold =
false;
1253 RC = &AArch64::GPR64RegClass;
1254 Opc = AArch64::CSELXr;
1257 RC = &AArch64::GPR32RegClass;
1258 Opc = AArch64::CSELWr;
1261 RC = &AArch64::FPR64RegClass;
1262 Opc = AArch64::FCSELDrrr;
1264 RC = &AArch64::FPR32RegClass;
1265 Opc = AArch64::FCSELSrrr;
1267 assert(RC &&
"Unsupported regclass");
1271 unsigned NewReg = 0;
1294 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1295 FalseReg == AArch64::XZR) &&
1296 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1313 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1318 return Is.
size() <= 2;
1323 assert(
MI.isCopy() &&
"Expected COPY instruction");
1329 if (
Reg.isVirtual())
1331 if (
Reg.isPhysical())
1332 return RI.getMinimalPhysRegClass(
Reg);
1337 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1340 return MI.isAsCheapAsAMove();
1346 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1347 if (isExynosCheapAsMove(
MI))
1349 return MI.isAsCheapAsAMove();
1352 switch (
MI.getOpcode()) {
1354 return MI.isAsCheapAsAMove();
1356 case TargetOpcode::COPY:
1359 case AArch64::ADDWrs:
1360 case AArch64::ADDXrs:
1361 case AArch64::SUBWrs:
1362 case AArch64::SUBXrs:
1363 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1368 case AArch64::MOVi32imm:
1370 case AArch64::MOVi64imm:
1375bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1376 switch (
MI.getOpcode()) {
1380 case AArch64::ADDWrs:
1381 case AArch64::ADDXrs:
1382 case AArch64::ADDSWrs:
1383 case AArch64::ADDSXrs: {
1384 unsigned Imm =
MI.getOperand(3).getImm();
1391 case AArch64::ADDWrx:
1392 case AArch64::ADDXrx:
1393 case AArch64::ADDXrx64:
1394 case AArch64::ADDSWrx:
1395 case AArch64::ADDSXrx:
1396 case AArch64::ADDSXrx64: {
1397 unsigned Imm =
MI.getOperand(3).getImm();
1409 case AArch64::SUBWrs:
1410 case AArch64::SUBSWrs: {
1411 unsigned Imm =
MI.getOperand(3).getImm();
1413 return ShiftVal == 0 ||
1417 case AArch64::SUBXrs:
1418 case AArch64::SUBSXrs: {
1419 unsigned Imm =
MI.getOperand(3).getImm();
1421 return ShiftVal == 0 ||
1425 case AArch64::SUBWrx:
1426 case AArch64::SUBXrx:
1427 case AArch64::SUBXrx64:
1428 case AArch64::SUBSWrx:
1429 case AArch64::SUBSXrx:
1430 case AArch64::SUBSXrx64: {
1431 unsigned Imm =
MI.getOperand(3).getImm();
1443 case AArch64::LDRBBroW:
1444 case AArch64::LDRBBroX:
1445 case AArch64::LDRBroW:
1446 case AArch64::LDRBroX:
1447 case AArch64::LDRDroW:
1448 case AArch64::LDRDroX:
1449 case AArch64::LDRHHroW:
1450 case AArch64::LDRHHroX:
1451 case AArch64::LDRHroW:
1452 case AArch64::LDRHroX:
1453 case AArch64::LDRQroW:
1454 case AArch64::LDRQroX:
1455 case AArch64::LDRSBWroW:
1456 case AArch64::LDRSBWroX:
1457 case AArch64::LDRSBXroW:
1458 case AArch64::LDRSBXroX:
1459 case AArch64::LDRSHWroW:
1460 case AArch64::LDRSHWroX:
1461 case AArch64::LDRSHXroW:
1462 case AArch64::LDRSHXroX:
1463 case AArch64::LDRSWroW:
1464 case AArch64::LDRSWroX:
1465 case AArch64::LDRSroW:
1466 case AArch64::LDRSroX:
1467 case AArch64::LDRWroW:
1468 case AArch64::LDRWroX:
1469 case AArch64::LDRXroW:
1470 case AArch64::LDRXroX:
1471 case AArch64::PRFMroW:
1472 case AArch64::PRFMroX:
1473 case AArch64::STRBBroW:
1474 case AArch64::STRBBroX:
1475 case AArch64::STRBroW:
1476 case AArch64::STRBroX:
1477 case AArch64::STRDroW:
1478 case AArch64::STRDroX:
1479 case AArch64::STRHHroW:
1480 case AArch64::STRHHroX:
1481 case AArch64::STRHroW:
1482 case AArch64::STRHroX:
1483 case AArch64::STRQroW:
1484 case AArch64::STRQroX:
1485 case AArch64::STRSroW:
1486 case AArch64::STRSroX:
1487 case AArch64::STRWroW:
1488 case AArch64::STRWroX:
1489 case AArch64::STRXroW:
1490 case AArch64::STRXroX: {
1491 unsigned IsSigned =
MI.getOperand(3).getImm();
1498 unsigned Opc =
MI.getOpcode();
1502 case AArch64::SEH_StackAlloc:
1503 case AArch64::SEH_SaveFPLR:
1504 case AArch64::SEH_SaveFPLR_X:
1505 case AArch64::SEH_SaveReg:
1506 case AArch64::SEH_SaveReg_X:
1507 case AArch64::SEH_SaveRegP:
1508 case AArch64::SEH_SaveRegP_X:
1509 case AArch64::SEH_SaveFReg:
1510 case AArch64::SEH_SaveFReg_X:
1511 case AArch64::SEH_SaveFRegP:
1512 case AArch64::SEH_SaveFRegP_X:
1513 case AArch64::SEH_SetFP:
1514 case AArch64::SEH_AddFP:
1515 case AArch64::SEH_Nop:
1516 case AArch64::SEH_PrologEnd:
1517 case AArch64::SEH_EpilogStart:
1518 case AArch64::SEH_EpilogEnd:
1519 case AArch64::SEH_PACSignLR:
1520 case AArch64::SEH_SaveAnyRegI:
1521 case AArch64::SEH_SaveAnyRegIP:
1522 case AArch64::SEH_SaveAnyRegQP:
1523 case AArch64::SEH_SaveAnyRegQPX:
1524 case AArch64::SEH_AllocZ:
1525 case AArch64::SEH_SaveZReg:
1526 case AArch64::SEH_SavePReg:
1533 unsigned &SubIdx)
const {
1534 switch (
MI.getOpcode()) {
1537 case AArch64::SBFMXri:
1538 case AArch64::UBFMXri:
1541 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1544 SrcReg =
MI.getOperand(1).getReg();
1545 DstReg =
MI.getOperand(0).getReg();
1546 SubIdx = AArch64::sub_32;
1555 int64_t OffsetA = 0, OffsetB = 0;
1556 TypeSize WidthA(0,
false), WidthB(0,
false);
1557 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1578 OffsetAIsScalable == OffsetBIsScalable) {
1579 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1580 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1581 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1582 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1600 switch (
MI.getOpcode()) {
1603 if (
MI.getOperand(0).getImm() == 0x14)
1610 case AArch64::MSRpstatesvcrImm1:
1617 auto Next = std::next(
MI.getIterator());
1618 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1625 Register &SrcReg2, int64_t &CmpMask,
1626 int64_t &CmpValue)
const {
1630 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1631 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1634 switch (
MI.getOpcode()) {
1637 case AArch64::PTEST_PP:
1638 case AArch64::PTEST_PP_ANY:
1639 case AArch64::PTEST_PP_FIRST:
1640 SrcReg =
MI.getOperand(0).getReg();
1641 SrcReg2 =
MI.getOperand(1).getReg();
1642 if (
MI.getOperand(2).getSubReg())
1649 case AArch64::SUBSWrr:
1650 case AArch64::SUBSWrs:
1651 case AArch64::SUBSWrx:
1652 case AArch64::SUBSXrr:
1653 case AArch64::SUBSXrs:
1654 case AArch64::SUBSXrx:
1655 case AArch64::ADDSWrr:
1656 case AArch64::ADDSWrs:
1657 case AArch64::ADDSWrx:
1658 case AArch64::ADDSXrr:
1659 case AArch64::ADDSXrs:
1660 case AArch64::ADDSXrx:
1662 SrcReg =
MI.getOperand(1).getReg();
1663 SrcReg2 =
MI.getOperand(2).getReg();
1666 if (
MI.getOperand(2).getSubReg())
1672 case AArch64::SUBSWri:
1673 case AArch64::ADDSWri:
1674 case AArch64::SUBSXri:
1675 case AArch64::ADDSXri:
1676 SrcReg =
MI.getOperand(1).getReg();
1679 CmpValue =
MI.getOperand(2).getImm();
1681 case AArch64::ANDSWri:
1682 case AArch64::ANDSXri:
1685 SrcReg =
MI.getOperand(1).getReg();
1689 MI.getOperand(2).getImm(),
1690 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1699 assert(
MBB &&
"Can't get MachineBasicBlock here");
1701 assert(MF &&
"Can't get MachineFunction here");
1706 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1713 if (!OpRegCstraints)
1721 "Operand has register constraints without being a register!");
1724 if (
Reg.isPhysical()) {
1741 bool MIDefinesZeroReg =
false;
1742 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1743 MI.definesRegister(AArch64::XZR,
nullptr))
1744 MIDefinesZeroReg =
true;
1746 switch (
MI.getOpcode()) {
1748 return MI.getOpcode();
1749 case AArch64::ADDSWrr:
1750 return AArch64::ADDWrr;
1751 case AArch64::ADDSWri:
1752 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1753 case AArch64::ADDSWrs:
1754 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1755 case AArch64::ADDSWrx:
1756 return AArch64::ADDWrx;
1757 case AArch64::ADDSXrr:
1758 return AArch64::ADDXrr;
1759 case AArch64::ADDSXri:
1760 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1761 case AArch64::ADDSXrs:
1762 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1763 case AArch64::ADDSXrx:
1764 return AArch64::ADDXrx;
1765 case AArch64::SUBSWrr:
1766 return AArch64::SUBWrr;
1767 case AArch64::SUBSWri:
1768 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1769 case AArch64::SUBSWrs:
1770 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1771 case AArch64::SUBSWrx:
1772 return AArch64::SUBWrx;
1773 case AArch64::SUBSXrr:
1774 return AArch64::SUBXrr;
1775 case AArch64::SUBSXri:
1776 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1777 case AArch64::SUBSXrs:
1778 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1779 case AArch64::SUBSXrx:
1780 return AArch64::SUBXrx;
1795 if (To == To->getParent()->begin())
1800 if (To->getParent() != From->getParent())
1812 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1813 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1819std::optional<unsigned>
1823 unsigned MaskOpcode =
Mask->getOpcode();
1824 unsigned PredOpcode = Pred->
getOpcode();
1825 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1826 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1828 if (PredIsWhileLike) {
1832 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1839 getElementSizeForOpcode(MaskOpcode) ==
1840 getElementSizeForOpcode(PredOpcode))
1846 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1853 if (PredIsPTestLike) {
1858 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1866 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1867 PTestLikeMask->getOperand(1).getReg().isVirtual())
1875 getElementSizeForOpcode(MaskOpcode) ==
1876 getElementSizeForOpcode(PredOpcode)) {
1877 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1903 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1905 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1913 switch (PredOpcode) {
1914 case AArch64::AND_PPzPP:
1915 case AArch64::BIC_PPzPP:
1916 case AArch64::EOR_PPzPP:
1917 case AArch64::NAND_PPzPP:
1918 case AArch64::NOR_PPzPP:
1919 case AArch64::ORN_PPzPP:
1920 case AArch64::ORR_PPzPP:
1921 case AArch64::BRKA_PPzP:
1922 case AArch64::BRKPA_PPzPP:
1923 case AArch64::BRKB_PPzP:
1924 case AArch64::BRKPB_PPzPP:
1925 case AArch64::RDFFR_PPz: {
1929 if (Mask != PredMask)
1933 case AArch64::BRKN_PPzP: {
1937 if ((MaskOpcode != AArch64::PTRUE_B) ||
1938 (
Mask->getOperand(1).getImm() != 31))
1942 case AArch64::PTRUE_B:
1955bool AArch64InstrInfo::optimizePTestInstr(
1956 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1961 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
1965 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
1966 Op.getSubReg() == AArch64::psub0)
1970 unsigned PredOpcode = Pred->
getOpcode();
1971 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
1987 if (*NewOp != PredOpcode) {
1998 for (; i !=
e; ++i) {
2029 if (DeadNZCVIdx != -1) {
2048 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2049 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2050 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2051 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2060 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2062 return (CmpValue == 0 || CmpValue == 1) &&
2063 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2071 switch (Instr.getOpcode()) {
2073 return AArch64::INSTRUCTION_LIST_END;
2075 case AArch64::ADDSWrr:
2076 case AArch64::ADDSWri:
2077 case AArch64::ADDSXrr:
2078 case AArch64::ADDSXri:
2079 case AArch64::ADDSWrx:
2080 case AArch64::ADDSXrx:
2081 case AArch64::ADDSWrs:
2082 case AArch64::ADDSXrs:
2083 case AArch64::SUBSWrr:
2084 case AArch64::SUBSWri:
2085 case AArch64::SUBSWrx:
2086 case AArch64::SUBSWrs:
2087 case AArch64::SUBSXrr:
2088 case AArch64::SUBSXri:
2089 case AArch64::SUBSXrx:
2090 case AArch64::SUBSXrs:
2091 case AArch64::ANDSWri:
2092 case AArch64::ANDSWrr:
2093 case AArch64::ANDSWrs:
2094 case AArch64::ANDSXri:
2095 case AArch64::ANDSXrr:
2096 case AArch64::ANDSXrs:
2097 case AArch64::BICSWrr:
2098 case AArch64::BICSXrr:
2099 case AArch64::BICSWrs:
2100 case AArch64::BICSXrs:
2101 case AArch64::ADCSWr:
2102 case AArch64::ADCSXr:
2103 case AArch64::SBCSWr:
2104 case AArch64::SBCSXr:
2105 return Instr.getOpcode();
2107 case AArch64::ADDWrr:
2108 return AArch64::ADDSWrr;
2109 case AArch64::ADDWri:
2110 return AArch64::ADDSWri;
2111 case AArch64::ADDXrr:
2112 return AArch64::ADDSXrr;
2113 case AArch64::ADDXri:
2114 return AArch64::ADDSXri;
2115 case AArch64::ADDWrx:
2116 return AArch64::ADDSWrx;
2117 case AArch64::ADDXrx:
2118 return AArch64::ADDSXrx;
2119 case AArch64::ADDWrs:
2120 return AArch64::ADDSWrs;
2121 case AArch64::ADDXrs:
2122 return AArch64::ADDSXrs;
2123 case AArch64::ADCWr:
2124 return AArch64::ADCSWr;
2125 case AArch64::ADCXr:
2126 return AArch64::ADCSXr;
2127 case AArch64::SUBWrr:
2128 return AArch64::SUBSWrr;
2129 case AArch64::SUBWri:
2130 return AArch64::SUBSWri;
2131 case AArch64::SUBXrr:
2132 return AArch64::SUBSXrr;
2133 case AArch64::SUBXri:
2134 return AArch64::SUBSXri;
2135 case AArch64::SUBWrx:
2136 return AArch64::SUBSWrx;
2137 case AArch64::SUBXrx:
2138 return AArch64::SUBSXrx;
2139 case AArch64::SUBWrs:
2140 return AArch64::SUBSWrs;
2141 case AArch64::SUBXrs:
2142 return AArch64::SUBSXrs;
2143 case AArch64::SBCWr:
2144 return AArch64::SBCSWr;
2145 case AArch64::SBCXr:
2146 return AArch64::SBCSXr;
2147 case AArch64::ANDWri:
2148 return AArch64::ANDSWri;
2149 case AArch64::ANDXri:
2150 return AArch64::ANDSXri;
2151 case AArch64::ANDWrr:
2152 return AArch64::ANDSWrr;
2153 case AArch64::ANDWrs:
2154 return AArch64::ANDSWrs;
2155 case AArch64::ANDXrr:
2156 return AArch64::ANDSXrr;
2157 case AArch64::ANDXrs:
2158 return AArch64::ANDSXrs;
2159 case AArch64::BICWrr:
2160 return AArch64::BICSWrr;
2161 case AArch64::BICXrr:
2162 return AArch64::BICSXrr;
2163 case AArch64::BICWrs:
2164 return AArch64::BICSWrs;
2165 case AArch64::BICXrs:
2166 return AArch64::BICSXrs;
2172 for (
auto *BB :
MBB->successors())
2173 if (BB->isLiveIn(AArch64::NZCV))
2180int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2182 switch (
Instr.getOpcode()) {
2186 case AArch64::Bcc: {
2187 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2192 case AArch64::CSINVWr:
2193 case AArch64::CSINVXr:
2194 case AArch64::CSINCWr:
2195 case AArch64::CSINCXr:
2196 case AArch64::CSELWr:
2197 case AArch64::CSELXr:
2198 case AArch64::CSNEGWr:
2199 case AArch64::CSNEGXr:
2200 case AArch64::FCSELSrrr:
2201 case AArch64::FCSELDrrr: {
2202 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2214 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2216 Instr.getOperand(CCIdx).
getImm())
2269std::optional<UsedNZCV>
2274 if (
MI.getParent() != CmpParent)
2275 return std::nullopt;
2278 return std::nullopt;
2283 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2286 return std::nullopt;
2291 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2294 return NZCVUsedAfterCmp;
2298 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2302 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2308 case AArch64::ANDSWri:
2309 case AArch64::ANDSWrr:
2310 case AArch64::ANDSWrs:
2311 case AArch64::ANDSXri:
2312 case AArch64::ANDSXrr:
2313 case AArch64::ANDSXrs:
2314 case AArch64::BICSWrr:
2315 case AArch64::BICSXrr:
2316 case AArch64::BICSWrs:
2317 case AArch64::BICSXrs:
2343 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2349 "Caller guarantees that CmpInstr compares with constant 0");
2352 if (!NZVCUsed || NZVCUsed->C)
2373bool AArch64InstrInfo::substituteCmpToZero(
2384 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2391 MI->setDesc(
get(NewOpc));
2396 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2408 assert((CmpValue == 0 || CmpValue == 1) &&
2409 "Only comparisons to 0 or 1 considered for removal!");
2412 unsigned MIOpc =
MI.getOpcode();
2413 if (MIOpc == AArch64::CSINCWr) {
2414 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2415 MI.getOperand(2).getReg() != AArch64::WZR)
2417 }
else if (MIOpc == AArch64::CSINCXr) {
2418 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2419 MI.getOperand(2).getReg() != AArch64::XZR)
2429 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2433 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2435 if (CmpValue && !IsSubsRegImm)
2437 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2442 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2445 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2449 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2452 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2453 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2456 if (MIUsedNZCV.
N && !CmpValue)
2498bool AArch64InstrInfo::removeCmpToZeroOrOne(
2505 SmallVector<MachineInstr *, 4> CCUseInstrs;
2506 bool IsInvertCC =
false;
2514 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2515 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2516 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2517 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2526bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2527 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2528 MI.getOpcode() != AArch64::CATCHRET &&
2529 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2532 MachineBasicBlock &
MBB = *
MI.getParent();
2534 auto TRI = Subtarget.getRegisterInfo();
2537 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2551 if (
MI.getOpcode() == AArch64::CATCHRET) {
2553 const TargetInstrInfo *
TII =
2555 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2560 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2562 FirstEpilogSEH = std::next(FirstEpilogSEH);
2577 if (
M.getStackProtectorGuard() ==
"sysreg") {
2578 const AArch64SysReg::SysReg *SrcReg =
2579 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2587 int Offset =
M.getStackProtectorGuardOffset();
2638 const GlobalValue *GV =
2641 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2644 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2645 Subtarget.isTargetILP32() ? 4 : 8);
2646 if (GuardWidth != 4 && GuardWidth != 8)
2651 if (GuardWidth == 4) {
2652 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2681 if (GuardWidth == 4) {
2682 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2699 if (GuardWidth == 4) {
2700 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2718 if (Subtarget.getTargetTriple().isOSMSVCRT())
2731 switch (
MI.getOpcode()) {
2734 case AArch64::MOVZWi:
2735 case AArch64::MOVZXi:
2736 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2737 assert(
MI.getDesc().getNumOperands() == 3 &&
2738 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2742 case AArch64::ANDWri:
2743 return MI.getOperand(1).getReg() == AArch64::WZR;
2744 case AArch64::ANDXri:
2745 return MI.getOperand(1).getReg() == AArch64::XZR;
2746 case TargetOpcode::COPY:
2747 return MI.getOperand(1).getReg() == AArch64::WZR;
2755 switch (
MI.getOpcode()) {
2758 case TargetOpcode::COPY: {
2761 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2762 AArch64::GPR64RegClass.
contains(DstReg));
2764 case AArch64::ORRXrs:
2765 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2766 assert(
MI.getDesc().getNumOperands() == 4 &&
2767 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2771 case AArch64::ADDXri:
2772 if (
MI.getOperand(2).getImm() == 0) {
2773 assert(
MI.getDesc().getNumOperands() == 4 &&
2774 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2785 switch (
MI.getOpcode()) {
2788 case TargetOpcode::COPY: {
2790 return AArch64::FPR128RegClass.contains(DstReg);
2792 case AArch64::ORRv16i8:
2793 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2794 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2795 "invalid ORRv16i8 operands");
2807 case AArch64::LDRWui:
2808 case AArch64::LDRXui:
2809 case AArch64::LDRBui:
2810 case AArch64::LDRHui:
2811 case AArch64::LDRSui:
2812 case AArch64::LDRDui:
2813 case AArch64::LDRQui:
2814 case AArch64::LDR_PXI:
2820 int &FrameIndex)
const {
2824 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2825 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2826 FrameIndex =
MI.getOperand(1).getIndex();
2827 return MI.getOperand(0).getReg();
2836 case AArch64::STRWui:
2837 case AArch64::STRXui:
2838 case AArch64::STRBui:
2839 case AArch64::STRHui:
2840 case AArch64::STRSui:
2841 case AArch64::STRDui:
2842 case AArch64::STRQui:
2843 case AArch64::STR_PXI:
2849 int &FrameIndex)
const {
2853 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2854 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2855 FrameIndex =
MI.getOperand(1).getIndex();
2856 return MI.getOperand(0).getReg();
2862 int &FrameIndex)
const {
2877 return MI.getOperand(0).getReg();
2883 int &FrameIndex)
const {
2898 return MI.getOperand(0).getReg();
2906 return MMO->getFlags() & MOSuppressPair;
2912 if (
MI.memoperands_empty())
2920 return MMO->getFlags() & MOStridedAccess;
2928 case AArch64::STURSi:
2929 case AArch64::STRSpre:
2930 case AArch64::STURDi:
2931 case AArch64::STRDpre:
2932 case AArch64::STURQi:
2933 case AArch64::STRQpre:
2934 case AArch64::STURBBi:
2935 case AArch64::STURHHi:
2936 case AArch64::STURWi:
2937 case AArch64::STRWpre:
2938 case AArch64::STURXi:
2939 case AArch64::STRXpre:
2940 case AArch64::LDURSi:
2941 case AArch64::LDRSpre:
2942 case AArch64::LDURDi:
2943 case AArch64::LDRDpre:
2944 case AArch64::LDURQi:
2945 case AArch64::LDRQpre:
2946 case AArch64::LDURWi:
2947 case AArch64::LDRWpre:
2948 case AArch64::LDURXi:
2949 case AArch64::LDRXpre:
2950 case AArch64::LDRSWpre:
2951 case AArch64::LDURSWi:
2952 case AArch64::LDURHHi:
2953 case AArch64::LDURBBi:
2954 case AArch64::LDURSBWi:
2955 case AArch64::LDURSHWi:
2963 case AArch64::PRFMui:
return AArch64::PRFUMi;
2964 case AArch64::LDRXui:
return AArch64::LDURXi;
2965 case AArch64::LDRWui:
return AArch64::LDURWi;
2966 case AArch64::LDRBui:
return AArch64::LDURBi;
2967 case AArch64::LDRHui:
return AArch64::LDURHi;
2968 case AArch64::LDRSui:
return AArch64::LDURSi;
2969 case AArch64::LDRDui:
return AArch64::LDURDi;
2970 case AArch64::LDRQui:
return AArch64::LDURQi;
2971 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2972 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2973 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2974 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2975 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2976 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2977 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2978 case AArch64::STRXui:
return AArch64::STURXi;
2979 case AArch64::STRWui:
return AArch64::STURWi;
2980 case AArch64::STRBui:
return AArch64::STURBi;
2981 case AArch64::STRHui:
return AArch64::STURHi;
2982 case AArch64::STRSui:
return AArch64::STURSi;
2983 case AArch64::STRDui:
return AArch64::STURDi;
2984 case AArch64::STRQui:
return AArch64::STURQi;
2985 case AArch64::STRBBui:
return AArch64::STURBBi;
2986 case AArch64::STRHHui:
return AArch64::STURHHi;
2995 case AArch64::LDAPURBi:
2996 case AArch64::LDAPURHi:
2997 case AArch64::LDAPURi:
2998 case AArch64::LDAPURSBWi:
2999 case AArch64::LDAPURSBXi:
3000 case AArch64::LDAPURSHWi:
3001 case AArch64::LDAPURSHXi:
3002 case AArch64::LDAPURSWi:
3003 case AArch64::LDAPURXi:
3004 case AArch64::LDR_PPXI:
3005 case AArch64::LDR_PXI:
3006 case AArch64::LDR_ZXI:
3007 case AArch64::LDR_ZZXI:
3008 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3009 case AArch64::LDR_ZZZXI:
3010 case AArch64::LDR_ZZZZXI:
3011 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3012 case AArch64::LDRBBui:
3013 case AArch64::LDRBui:
3014 case AArch64::LDRDui:
3015 case AArch64::LDRHHui:
3016 case AArch64::LDRHui:
3017 case AArch64::LDRQui:
3018 case AArch64::LDRSBWui:
3019 case AArch64::LDRSBXui:
3020 case AArch64::LDRSHWui:
3021 case AArch64::LDRSHXui:
3022 case AArch64::LDRSui:
3023 case AArch64::LDRSWui:
3024 case AArch64::LDRWui:
3025 case AArch64::LDRXui:
3026 case AArch64::LDURBBi:
3027 case AArch64::LDURBi:
3028 case AArch64::LDURDi:
3029 case AArch64::LDURHHi:
3030 case AArch64::LDURHi:
3031 case AArch64::LDURQi:
3032 case AArch64::LDURSBWi:
3033 case AArch64::LDURSBXi:
3034 case AArch64::LDURSHWi:
3035 case AArch64::LDURSHXi:
3036 case AArch64::LDURSi:
3037 case AArch64::LDURSWi:
3038 case AArch64::LDURWi:
3039 case AArch64::LDURXi:
3040 case AArch64::PRFMui:
3041 case AArch64::PRFUMi:
3042 case AArch64::ST2Gi:
3044 case AArch64::STLURBi:
3045 case AArch64::STLURHi:
3046 case AArch64::STLURWi:
3047 case AArch64::STLURXi:
3048 case AArch64::StoreSwiftAsyncContext:
3049 case AArch64::STR_PPXI:
3050 case AArch64::STR_PXI:
3051 case AArch64::STR_ZXI:
3052 case AArch64::STR_ZZXI:
3053 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3054 case AArch64::STR_ZZZXI:
3055 case AArch64::STR_ZZZZXI:
3056 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3057 case AArch64::STRBBui:
3058 case AArch64::STRBui:
3059 case AArch64::STRDui:
3060 case AArch64::STRHHui:
3061 case AArch64::STRHui:
3062 case AArch64::STRQui:
3063 case AArch64::STRSui:
3064 case AArch64::STRWui:
3065 case AArch64::STRXui:
3066 case AArch64::STURBBi:
3067 case AArch64::STURBi:
3068 case AArch64::STURDi:
3069 case AArch64::STURHHi:
3070 case AArch64::STURHi:
3071 case AArch64::STURQi:
3072 case AArch64::STURSi:
3073 case AArch64::STURWi:
3074 case AArch64::STURXi:
3075 case AArch64::STZ2Gi:
3076 case AArch64::STZGi:
3077 case AArch64::TAGPstack:
3079 case AArch64::LD1B_D_IMM:
3080 case AArch64::LD1B_H_IMM:
3081 case AArch64::LD1B_IMM:
3082 case AArch64::LD1B_S_IMM:
3083 case AArch64::LD1D_IMM:
3084 case AArch64::LD1H_D_IMM:
3085 case AArch64::LD1H_IMM:
3086 case AArch64::LD1H_S_IMM:
3087 case AArch64::LD1RB_D_IMM:
3088 case AArch64::LD1RB_H_IMM:
3089 case AArch64::LD1RB_IMM:
3090 case AArch64::LD1RB_S_IMM:
3091 case AArch64::LD1RD_IMM:
3092 case AArch64::LD1RH_D_IMM:
3093 case AArch64::LD1RH_IMM:
3094 case AArch64::LD1RH_S_IMM:
3095 case AArch64::LD1RSB_D_IMM:
3096 case AArch64::LD1RSB_H_IMM:
3097 case AArch64::LD1RSB_S_IMM:
3098 case AArch64::LD1RSH_D_IMM:
3099 case AArch64::LD1RSH_S_IMM:
3100 case AArch64::LD1RSW_IMM:
3101 case AArch64::LD1RW_D_IMM:
3102 case AArch64::LD1RW_IMM:
3103 case AArch64::LD1SB_D_IMM:
3104 case AArch64::LD1SB_H_IMM:
3105 case AArch64::LD1SB_S_IMM:
3106 case AArch64::LD1SH_D_IMM:
3107 case AArch64::LD1SH_S_IMM:
3108 case AArch64::LD1SW_D_IMM:
3109 case AArch64::LD1W_D_IMM:
3110 case AArch64::LD1W_IMM:
3111 case AArch64::LD2B_IMM:
3112 case AArch64::LD2D_IMM:
3113 case AArch64::LD2H_IMM:
3114 case AArch64::LD2W_IMM:
3115 case AArch64::LD3B_IMM:
3116 case AArch64::LD3D_IMM:
3117 case AArch64::LD3H_IMM:
3118 case AArch64::LD3W_IMM:
3119 case AArch64::LD4B_IMM:
3120 case AArch64::LD4D_IMM:
3121 case AArch64::LD4H_IMM:
3122 case AArch64::LD4W_IMM:
3124 case AArch64::LDNF1B_D_IMM:
3125 case AArch64::LDNF1B_H_IMM:
3126 case AArch64::LDNF1B_IMM:
3127 case AArch64::LDNF1B_S_IMM:
3128 case AArch64::LDNF1D_IMM:
3129 case AArch64::LDNF1H_D_IMM:
3130 case AArch64::LDNF1H_IMM:
3131 case AArch64::LDNF1H_S_IMM:
3132 case AArch64::LDNF1SB_D_IMM:
3133 case AArch64::LDNF1SB_H_IMM:
3134 case AArch64::LDNF1SB_S_IMM:
3135 case AArch64::LDNF1SH_D_IMM:
3136 case AArch64::LDNF1SH_S_IMM:
3137 case AArch64::LDNF1SW_D_IMM:
3138 case AArch64::LDNF1W_D_IMM:
3139 case AArch64::LDNF1W_IMM:
3140 case AArch64::LDNPDi:
3141 case AArch64::LDNPQi:
3142 case AArch64::LDNPSi:
3143 case AArch64::LDNPWi:
3144 case AArch64::LDNPXi:
3145 case AArch64::LDNT1B_ZRI:
3146 case AArch64::LDNT1D_ZRI:
3147 case AArch64::LDNT1H_ZRI:
3148 case AArch64::LDNT1W_ZRI:
3149 case AArch64::LDPDi:
3150 case AArch64::LDPQi:
3151 case AArch64::LDPSi:
3152 case AArch64::LDPWi:
3153 case AArch64::LDPXi:
3154 case AArch64::LDRBBpost:
3155 case AArch64::LDRBBpre:
3156 case AArch64::LDRBpost:
3157 case AArch64::LDRBpre:
3158 case AArch64::LDRDpost:
3159 case AArch64::LDRDpre:
3160 case AArch64::LDRHHpost:
3161 case AArch64::LDRHHpre:
3162 case AArch64::LDRHpost:
3163 case AArch64::LDRHpre:
3164 case AArch64::LDRQpost:
3165 case AArch64::LDRQpre:
3166 case AArch64::LDRSpost:
3167 case AArch64::LDRSpre:
3168 case AArch64::LDRWpost:
3169 case AArch64::LDRWpre:
3170 case AArch64::LDRXpost:
3171 case AArch64::LDRXpre:
3172 case AArch64::ST1B_D_IMM:
3173 case AArch64::ST1B_H_IMM:
3174 case AArch64::ST1B_IMM:
3175 case AArch64::ST1B_S_IMM:
3176 case AArch64::ST1D_IMM:
3177 case AArch64::ST1H_D_IMM:
3178 case AArch64::ST1H_IMM:
3179 case AArch64::ST1H_S_IMM:
3180 case AArch64::ST1W_D_IMM:
3181 case AArch64::ST1W_IMM:
3182 case AArch64::ST2B_IMM:
3183 case AArch64::ST2D_IMM:
3184 case AArch64::ST2H_IMM:
3185 case AArch64::ST2W_IMM:
3186 case AArch64::ST3B_IMM:
3187 case AArch64::ST3D_IMM:
3188 case AArch64::ST3H_IMM:
3189 case AArch64::ST3W_IMM:
3190 case AArch64::ST4B_IMM:
3191 case AArch64::ST4D_IMM:
3192 case AArch64::ST4H_IMM:
3193 case AArch64::ST4W_IMM:
3194 case AArch64::STGPi:
3195 case AArch64::STGPreIndex:
3196 case AArch64::STZGPreIndex:
3197 case AArch64::ST2GPreIndex:
3198 case AArch64::STZ2GPreIndex:
3199 case AArch64::STGPostIndex:
3200 case AArch64::STZGPostIndex:
3201 case AArch64::ST2GPostIndex:
3202 case AArch64::STZ2GPostIndex:
3203 case AArch64::STNPDi:
3204 case AArch64::STNPQi:
3205 case AArch64::STNPSi:
3206 case AArch64::STNPWi:
3207 case AArch64::STNPXi:
3208 case AArch64::STNT1B_ZRI:
3209 case AArch64::STNT1D_ZRI:
3210 case AArch64::STNT1H_ZRI:
3211 case AArch64::STNT1W_ZRI:
3212 case AArch64::STPDi:
3213 case AArch64::STPQi:
3214 case AArch64::STPSi:
3215 case AArch64::STPWi:
3216 case AArch64::STPXi:
3217 case AArch64::STRBBpost:
3218 case AArch64::STRBBpre:
3219 case AArch64::STRBpost:
3220 case AArch64::STRBpre:
3221 case AArch64::STRDpost:
3222 case AArch64::STRDpre:
3223 case AArch64::STRHHpost:
3224 case AArch64::STRHHpre:
3225 case AArch64::STRHpost:
3226 case AArch64::STRHpre:
3227 case AArch64::STRQpost:
3228 case AArch64::STRQpre:
3229 case AArch64::STRSpost:
3230 case AArch64::STRSpre:
3231 case AArch64::STRWpost:
3232 case AArch64::STRWpre:
3233 case AArch64::STRXpost:
3234 case AArch64::STRXpre:
3235 case AArch64::LD1B_2Z_IMM:
3236 case AArch64::LD1B_2Z_STRIDED_IMM:
3237 case AArch64::LD1H_2Z_IMM:
3238 case AArch64::LD1H_2Z_STRIDED_IMM:
3239 case AArch64::LD1W_2Z_IMM:
3240 case AArch64::LD1W_2Z_STRIDED_IMM:
3241 case AArch64::LD1D_2Z_IMM:
3242 case AArch64::LD1D_2Z_STRIDED_IMM:
3243 case AArch64::LD1B_4Z_IMM:
3244 case AArch64::LD1B_4Z_STRIDED_IMM:
3245 case AArch64::LD1H_4Z_IMM:
3246 case AArch64::LD1H_4Z_STRIDED_IMM:
3247 case AArch64::LD1W_4Z_IMM:
3248 case AArch64::LD1W_4Z_STRIDED_IMM:
3249 case AArch64::LD1D_4Z_IMM:
3250 case AArch64::LD1D_4Z_STRIDED_IMM:
3251 case AArch64::LD1B_2Z_IMM_PSEUDO:
3252 case AArch64::LD1H_2Z_IMM_PSEUDO:
3253 case AArch64::LD1W_2Z_IMM_PSEUDO:
3254 case AArch64::LD1D_2Z_IMM_PSEUDO:
3255 case AArch64::LD1B_4Z_IMM_PSEUDO:
3256 case AArch64::LD1H_4Z_IMM_PSEUDO:
3257 case AArch64::LD1W_4Z_IMM_PSEUDO:
3258 case AArch64::LD1D_4Z_IMM_PSEUDO:
3259 case AArch64::ST1B_2Z_IMM:
3260 case AArch64::ST1B_2Z_STRIDED_IMM:
3261 case AArch64::ST1H_2Z_IMM:
3262 case AArch64::ST1H_2Z_STRIDED_IMM:
3263 case AArch64::ST1W_2Z_IMM:
3264 case AArch64::ST1W_2Z_STRIDED_IMM:
3265 case AArch64::ST1D_2Z_IMM:
3266 case AArch64::ST1D_2Z_STRIDED_IMM:
3267 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3268 case AArch64::LDNT1B_2Z_IMM:
3269 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3270 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3271 case AArch64::LDNT1H_2Z_IMM:
3272 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3273 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3274 case AArch64::LDNT1W_2Z_IMM:
3275 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3276 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3277 case AArch64::LDNT1D_2Z_IMM:
3278 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3279 case AArch64::STNT1B_2Z_IMM:
3280 case AArch64::STNT1B_2Z_STRIDED_IMM:
3281 case AArch64::STNT1H_2Z_IMM:
3282 case AArch64::STNT1H_2Z_STRIDED_IMM:
3283 case AArch64::STNT1W_2Z_IMM:
3284 case AArch64::STNT1W_2Z_STRIDED_IMM:
3285 case AArch64::STNT1D_2Z_IMM:
3286 case AArch64::STNT1D_2Z_STRIDED_IMM:
3287 case AArch64::ST1B_4Z_IMM:
3288 case AArch64::ST1B_4Z_STRIDED_IMM:
3289 case AArch64::ST1H_4Z_IMM:
3290 case AArch64::ST1H_4Z_STRIDED_IMM:
3291 case AArch64::ST1W_4Z_IMM:
3292 case AArch64::ST1W_4Z_STRIDED_IMM:
3293 case AArch64::ST1D_4Z_IMM:
3294 case AArch64::ST1D_4Z_STRIDED_IMM:
3295 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3296 case AArch64::LDNT1B_4Z_IMM:
3297 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3298 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3299 case AArch64::LDNT1H_4Z_IMM:
3300 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3301 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3302 case AArch64::LDNT1W_4Z_IMM:
3303 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3304 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3305 case AArch64::LDNT1D_4Z_IMM:
3306 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3307 case AArch64::STNT1B_4Z_IMM:
3308 case AArch64::STNT1B_4Z_STRIDED_IMM:
3309 case AArch64::STNT1H_4Z_IMM:
3310 case AArch64::STNT1H_4Z_STRIDED_IMM:
3311 case AArch64::STNT1W_4Z_IMM:
3312 case AArch64::STNT1W_4Z_STRIDED_IMM:
3313 case AArch64::STNT1D_4Z_IMM:
3314 case AArch64::STNT1D_4Z_STRIDED_IMM:
3316 case AArch64::LDPDpost:
3317 case AArch64::LDPDpre:
3318 case AArch64::LDPQpost:
3319 case AArch64::LDPQpre:
3320 case AArch64::LDPSpost:
3321 case AArch64::LDPSpre:
3322 case AArch64::LDPWpost:
3323 case AArch64::LDPWpre:
3324 case AArch64::LDPXpost:
3325 case AArch64::LDPXpre:
3326 case AArch64::STGPpre:
3327 case AArch64::STGPpost:
3328 case AArch64::STPDpost:
3329 case AArch64::STPDpre:
3330 case AArch64::STPQpost:
3331 case AArch64::STPQpre:
3332 case AArch64::STPSpost:
3333 case AArch64::STPSpre:
3334 case AArch64::STPWpost:
3335 case AArch64::STPWpre:
3336 case AArch64::STPXpost:
3337 case AArch64::STPXpre:
3343 switch (
MI.getOpcode()) {
3347 case AArch64::STRSui:
3348 case AArch64::STRDui:
3349 case AArch64::STRQui:
3350 case AArch64::STRXui:
3351 case AArch64::STRWui:
3352 case AArch64::LDRSui:
3353 case AArch64::LDRDui:
3354 case AArch64::LDRQui:
3355 case AArch64::LDRXui:
3356 case AArch64::LDRWui:
3357 case AArch64::LDRSWui:
3359 case AArch64::STURSi:
3360 case AArch64::STRSpre:
3361 case AArch64::STURDi:
3362 case AArch64::STRDpre:
3363 case AArch64::STURQi:
3364 case AArch64::STRQpre:
3365 case AArch64::STURWi:
3366 case AArch64::STRWpre:
3367 case AArch64::STURXi:
3368 case AArch64::STRXpre:
3369 case AArch64::LDURSi:
3370 case AArch64::LDRSpre:
3371 case AArch64::LDURDi:
3372 case AArch64::LDRDpre:
3373 case AArch64::LDURQi:
3374 case AArch64::LDRQpre:
3375 case AArch64::LDURWi:
3376 case AArch64::LDRWpre:
3377 case AArch64::LDURXi:
3378 case AArch64::LDRXpre:
3379 case AArch64::LDURSWi:
3380 case AArch64::LDRSWpre:
3382 case AArch64::LDR_ZXI:
3383 case AArch64::STR_ZXI:
3389 switch (
MI.getOpcode()) {
3392 "Unexpected instruction - was a new tail call opcode introduced?");
3394 case AArch64::TCRETURNdi:
3395 case AArch64::TCRETURNri:
3396 case AArch64::TCRETURNrix16x17:
3397 case AArch64::TCRETURNrix17:
3398 case AArch64::TCRETURNrinotx16:
3399 case AArch64::TCRETURNriALL:
3400 case AArch64::AUTH_TCRETURN:
3401 case AArch64::AUTH_TCRETURN_BTI:
3411 case AArch64::ADDWri:
3412 return AArch64::ADDSWri;
3413 case AArch64::ADDWrr:
3414 return AArch64::ADDSWrr;
3415 case AArch64::ADDWrs:
3416 return AArch64::ADDSWrs;
3417 case AArch64::ADDWrx:
3418 return AArch64::ADDSWrx;
3419 case AArch64::ANDWri:
3420 return AArch64::ANDSWri;
3421 case AArch64::ANDWrr:
3422 return AArch64::ANDSWrr;
3423 case AArch64::ANDWrs:
3424 return AArch64::ANDSWrs;
3425 case AArch64::BICWrr:
3426 return AArch64::BICSWrr;
3427 case AArch64::BICWrs:
3428 return AArch64::BICSWrs;
3429 case AArch64::SUBWri:
3430 return AArch64::SUBSWri;
3431 case AArch64::SUBWrr:
3432 return AArch64::SUBSWrr;
3433 case AArch64::SUBWrs:
3434 return AArch64::SUBSWrs;
3435 case AArch64::SUBWrx:
3436 return AArch64::SUBSWrx;
3438 case AArch64::ADDXri:
3439 return AArch64::ADDSXri;
3440 case AArch64::ADDXrr:
3441 return AArch64::ADDSXrr;
3442 case AArch64::ADDXrs:
3443 return AArch64::ADDSXrs;
3444 case AArch64::ADDXrx:
3445 return AArch64::ADDSXrx;
3446 case AArch64::ANDXri:
3447 return AArch64::ANDSXri;
3448 case AArch64::ANDXrr:
3449 return AArch64::ANDSXrr;
3450 case AArch64::ANDXrs:
3451 return AArch64::ANDSXrs;
3452 case AArch64::BICXrr:
3453 return AArch64::BICSXrr;
3454 case AArch64::BICXrs:
3455 return AArch64::BICSXrs;
3456 case AArch64::SUBXri:
3457 return AArch64::SUBSXri;
3458 case AArch64::SUBXrr:
3459 return AArch64::SUBSXrr;
3460 case AArch64::SUBXrs:
3461 return AArch64::SUBSXrs;
3462 case AArch64::SUBXrx:
3463 return AArch64::SUBSXrx;
3465 case AArch64::AND_PPzPP:
3466 return AArch64::ANDS_PPzPP;
3467 case AArch64::BIC_PPzPP:
3468 return AArch64::BICS_PPzPP;
3469 case AArch64::EOR_PPzPP:
3470 return AArch64::EORS_PPzPP;
3471 case AArch64::NAND_PPzPP:
3472 return AArch64::NANDS_PPzPP;
3473 case AArch64::NOR_PPzPP:
3474 return AArch64::NORS_PPzPP;
3475 case AArch64::ORN_PPzPP:
3476 return AArch64::ORNS_PPzPP;
3477 case AArch64::ORR_PPzPP:
3478 return AArch64::ORRS_PPzPP;
3479 case AArch64::BRKA_PPzP:
3480 return AArch64::BRKAS_PPzP;
3481 case AArch64::BRKPA_PPzPP:
3482 return AArch64::BRKPAS_PPzPP;
3483 case AArch64::BRKB_PPzP:
3484 return AArch64::BRKBS_PPzP;
3485 case AArch64::BRKPB_PPzPP:
3486 return AArch64::BRKPBS_PPzPP;
3487 case AArch64::BRKN_PPzP:
3488 return AArch64::BRKNS_PPzP;
3489 case AArch64::RDFFR_PPz:
3490 return AArch64::RDFFRS_PPz;
3491 case AArch64::PTRUE_B:
3492 return AArch64::PTRUES_B;
3503 if (
MI.hasOrderedMemoryRef())
3508 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3509 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3510 "Expected a reg or frame index operand.");
3514 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3516 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3529 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3530 Register BaseReg =
MI.getOperand(1).getReg();
3532 if (
MI.modifiesRegister(BaseReg,
TRI))
3538 switch (
MI.getOpcode()) {
3541 case AArch64::LDR_ZXI:
3542 case AArch64::STR_ZXI:
3543 if (!Subtarget.isLittleEndian() ||
3544 Subtarget.getSVEVectorSizeInBits() != 128)
3557 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3565 if (Subtarget.isPaired128Slow()) {
3566 switch (
MI.getOpcode()) {
3569 case AArch64::LDURQi:
3570 case AArch64::STURQi:
3571 case AArch64::LDRQui:
3572 case AArch64::STRQui:
3599std::optional<ExtAddrMode>
3604 bool OffsetIsScalable;
3605 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3606 return std::nullopt;
3609 return std::nullopt;
3624 int64_t OffsetScale = 1;
3629 case AArch64::LDURQi:
3630 case AArch64::STURQi:
3634 case AArch64::LDURDi:
3635 case AArch64::STURDi:
3636 case AArch64::LDURXi:
3637 case AArch64::STURXi:
3641 case AArch64::LDURWi:
3642 case AArch64::LDURSWi:
3643 case AArch64::STURWi:
3647 case AArch64::LDURHi:
3648 case AArch64::STURHi:
3649 case AArch64::LDURHHi:
3650 case AArch64::STURHHi:
3651 case AArch64::LDURSHXi:
3652 case AArch64::LDURSHWi:
3656 case AArch64::LDRBroX:
3657 case AArch64::LDRBBroX:
3658 case AArch64::LDRSBXroX:
3659 case AArch64::LDRSBWroX:
3660 case AArch64::STRBroX:
3661 case AArch64::STRBBroX:
3662 case AArch64::LDURBi:
3663 case AArch64::LDURBBi:
3664 case AArch64::LDURSBXi:
3665 case AArch64::LDURSBWi:
3666 case AArch64::STURBi:
3667 case AArch64::STURBBi:
3668 case AArch64::LDRBui:
3669 case AArch64::LDRBBui:
3670 case AArch64::LDRSBXui:
3671 case AArch64::LDRSBWui:
3672 case AArch64::STRBui:
3673 case AArch64::STRBBui:
3677 case AArch64::LDRQroX:
3678 case AArch64::STRQroX:
3679 case AArch64::LDRQui:
3680 case AArch64::STRQui:
3685 case AArch64::LDRDroX:
3686 case AArch64::STRDroX:
3687 case AArch64::LDRXroX:
3688 case AArch64::STRXroX:
3689 case AArch64::LDRDui:
3690 case AArch64::STRDui:
3691 case AArch64::LDRXui:
3692 case AArch64::STRXui:
3697 case AArch64::LDRWroX:
3698 case AArch64::LDRSWroX:
3699 case AArch64::STRWroX:
3700 case AArch64::LDRWui:
3701 case AArch64::LDRSWui:
3702 case AArch64::STRWui:
3707 case AArch64::LDRHroX:
3708 case AArch64::STRHroX:
3709 case AArch64::LDRHHroX:
3710 case AArch64::STRHHroX:
3711 case AArch64::LDRSHXroX:
3712 case AArch64::LDRSHWroX:
3713 case AArch64::LDRHui:
3714 case AArch64::STRHui:
3715 case AArch64::LDRHHui:
3716 case AArch64::STRHHui:
3717 case AArch64::LDRSHXui:
3718 case AArch64::LDRSHWui:
3726 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3750 case AArch64::SBFMXri:
3763 AM.
Scale = OffsetScale;
3768 case TargetOpcode::SUBREG_TO_REG: {
3784 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3785 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3786 DefMI.getOperand(3).getImm() != 0)
3793 AM.
Scale = OffsetScale;
3804 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3805 int64_t NewOffset) ->
bool {
3806 int64_t MinOffset, MaxOffset;
3823 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3824 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3826 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3828 int64_t NewOffset = OldOffset + Disp;
3829 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3833 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3843 auto canFoldAddRegIntoAddrMode =
3848 if ((
unsigned)Scale != Scale)
3850 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3862 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3863 Subtarget.isSTRQroSlow();
3872 case AArch64::ADDXri:
3878 return canFoldAddSubImmIntoAddrMode(Disp);
3880 case AArch64::SUBXri:
3886 return canFoldAddSubImmIntoAddrMode(-Disp);
3888 case AArch64::ADDXrs: {
3901 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3903 if (avoidSlowSTRQ(MemI))
3906 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3909 case AArch64::ADDXrr:
3917 if (!OptSize && avoidSlowSTRQ(MemI))
3919 return canFoldAddRegIntoAddrMode(1);
3921 case AArch64::ADDXrx:
3929 if (!OptSize && avoidSlowSTRQ(MemI))
3938 return canFoldAddRegIntoAddrMode(
3953 case AArch64::LDURQi:
3954 case AArch64::LDRQui:
3955 return AArch64::LDRQroX;
3956 case AArch64::STURQi:
3957 case AArch64::STRQui:
3958 return AArch64::STRQroX;
3959 case AArch64::LDURDi:
3960 case AArch64::LDRDui:
3961 return AArch64::LDRDroX;
3962 case AArch64::STURDi:
3963 case AArch64::STRDui:
3964 return AArch64::STRDroX;
3965 case AArch64::LDURXi:
3966 case AArch64::LDRXui:
3967 return AArch64::LDRXroX;
3968 case AArch64::STURXi:
3969 case AArch64::STRXui:
3970 return AArch64::STRXroX;
3971 case AArch64::LDURWi:
3972 case AArch64::LDRWui:
3973 return AArch64::LDRWroX;
3974 case AArch64::LDURSWi:
3975 case AArch64::LDRSWui:
3976 return AArch64::LDRSWroX;
3977 case AArch64::STURWi:
3978 case AArch64::STRWui:
3979 return AArch64::STRWroX;
3980 case AArch64::LDURHi:
3981 case AArch64::LDRHui:
3982 return AArch64::LDRHroX;
3983 case AArch64::STURHi:
3984 case AArch64::STRHui:
3985 return AArch64::STRHroX;
3986 case AArch64::LDURHHi:
3987 case AArch64::LDRHHui:
3988 return AArch64::LDRHHroX;
3989 case AArch64::STURHHi:
3990 case AArch64::STRHHui:
3991 return AArch64::STRHHroX;
3992 case AArch64::LDURSHXi:
3993 case AArch64::LDRSHXui:
3994 return AArch64::LDRSHXroX;
3995 case AArch64::LDURSHWi:
3996 case AArch64::LDRSHWui:
3997 return AArch64::LDRSHWroX;
3998 case AArch64::LDURBi:
3999 case AArch64::LDRBui:
4000 return AArch64::LDRBroX;
4001 case AArch64::LDURBBi:
4002 case AArch64::LDRBBui:
4003 return AArch64::LDRBBroX;
4004 case AArch64::LDURSBXi:
4005 case AArch64::LDRSBXui:
4006 return AArch64::LDRSBXroX;
4007 case AArch64::LDURSBWi:
4008 case AArch64::LDRSBWui:
4009 return AArch64::LDRSBWroX;
4010 case AArch64::STURBi:
4011 case AArch64::STRBui:
4012 return AArch64::STRBroX;
4013 case AArch64::STURBBi:
4014 case AArch64::STRBBui:
4015 return AArch64::STRBBroX;
4027 case AArch64::LDURQi:
4029 return AArch64::LDRQui;
4030 case AArch64::STURQi:
4032 return AArch64::STRQui;
4033 case AArch64::LDURDi:
4035 return AArch64::LDRDui;
4036 case AArch64::STURDi:
4038 return AArch64::STRDui;
4039 case AArch64::LDURXi:
4041 return AArch64::LDRXui;
4042 case AArch64::STURXi:
4044 return AArch64::STRXui;
4045 case AArch64::LDURWi:
4047 return AArch64::LDRWui;
4048 case AArch64::LDURSWi:
4050 return AArch64::LDRSWui;
4051 case AArch64::STURWi:
4053 return AArch64::STRWui;
4054 case AArch64::LDURHi:
4056 return AArch64::LDRHui;
4057 case AArch64::STURHi:
4059 return AArch64::STRHui;
4060 case AArch64::LDURHHi:
4062 return AArch64::LDRHHui;
4063 case AArch64::STURHHi:
4065 return AArch64::STRHHui;
4066 case AArch64::LDURSHXi:
4068 return AArch64::LDRSHXui;
4069 case AArch64::LDURSHWi:
4071 return AArch64::LDRSHWui;
4072 case AArch64::LDURBi:
4074 return AArch64::LDRBui;
4075 case AArch64::LDURBBi:
4077 return AArch64::LDRBBui;
4078 case AArch64::LDURSBXi:
4080 return AArch64::LDRSBXui;
4081 case AArch64::LDURSBWi:
4083 return AArch64::LDRSBWui;
4084 case AArch64::STURBi:
4086 return AArch64::STRBui;
4087 case AArch64::STURBBi:
4089 return AArch64::STRBBui;
4090 case AArch64::LDRQui:
4091 case AArch64::STRQui:
4094 case AArch64::LDRDui:
4095 case AArch64::STRDui:
4096 case AArch64::LDRXui:
4097 case AArch64::STRXui:
4100 case AArch64::LDRWui:
4101 case AArch64::LDRSWui:
4102 case AArch64::STRWui:
4105 case AArch64::LDRHui:
4106 case AArch64::STRHui:
4107 case AArch64::LDRHHui:
4108 case AArch64::STRHHui:
4109 case AArch64::LDRSHXui:
4110 case AArch64::LDRSHWui:
4113 case AArch64::LDRBui:
4114 case AArch64::LDRBBui:
4115 case AArch64::LDRSBXui:
4116 case AArch64::LDRSBWui:
4117 case AArch64::STRBui:
4118 case AArch64::STRBBui:
4132 case AArch64::LDURQi:
4133 case AArch64::STURQi:
4134 case AArch64::LDURDi:
4135 case AArch64::STURDi:
4136 case AArch64::LDURXi:
4137 case AArch64::STURXi:
4138 case AArch64::LDURWi:
4139 case AArch64::LDURSWi:
4140 case AArch64::STURWi:
4141 case AArch64::LDURHi:
4142 case AArch64::STURHi:
4143 case AArch64::LDURHHi:
4144 case AArch64::STURHHi:
4145 case AArch64::LDURSHXi:
4146 case AArch64::LDURSHWi:
4147 case AArch64::LDURBi:
4148 case AArch64::STURBi:
4149 case AArch64::LDURBBi:
4150 case AArch64::STURBBi:
4151 case AArch64::LDURSBWi:
4152 case AArch64::LDURSBXi:
4154 case AArch64::LDRQui:
4155 return AArch64::LDURQi;
4156 case AArch64::STRQui:
4157 return AArch64::STURQi;
4158 case AArch64::LDRDui:
4159 return AArch64::LDURDi;
4160 case AArch64::STRDui:
4161 return AArch64::STURDi;
4162 case AArch64::LDRXui:
4163 return AArch64::LDURXi;
4164 case AArch64::STRXui:
4165 return AArch64::STURXi;
4166 case AArch64::LDRWui:
4167 return AArch64::LDURWi;
4168 case AArch64::LDRSWui:
4169 return AArch64::LDURSWi;
4170 case AArch64::STRWui:
4171 return AArch64::STURWi;
4172 case AArch64::LDRHui:
4173 return AArch64::LDURHi;
4174 case AArch64::STRHui:
4175 return AArch64::STURHi;
4176 case AArch64::LDRHHui:
4177 return AArch64::LDURHHi;
4178 case AArch64::STRHHui:
4179 return AArch64::STURHHi;
4180 case AArch64::LDRSHXui:
4181 return AArch64::LDURSHXi;
4182 case AArch64::LDRSHWui:
4183 return AArch64::LDURSHWi;
4184 case AArch64::LDRBBui:
4185 return AArch64::LDURBBi;
4186 case AArch64::LDRBui:
4187 return AArch64::LDURBi;
4188 case AArch64::STRBBui:
4189 return AArch64::STURBBi;
4190 case AArch64::STRBui:
4191 return AArch64::STURBi;
4192 case AArch64::LDRSBWui:
4193 return AArch64::LDURSBWi;
4194 case AArch64::LDRSBXui:
4195 return AArch64::LDURSBXi;
4208 case AArch64::LDRQroX:
4209 case AArch64::LDURQi:
4210 case AArch64::LDRQui:
4211 return AArch64::LDRQroW;
4212 case AArch64::STRQroX:
4213 case AArch64::STURQi:
4214 case AArch64::STRQui:
4215 return AArch64::STRQroW;
4216 case AArch64::LDRDroX:
4217 case AArch64::LDURDi:
4218 case AArch64::LDRDui:
4219 return AArch64::LDRDroW;
4220 case AArch64::STRDroX:
4221 case AArch64::STURDi:
4222 case AArch64::STRDui:
4223 return AArch64::STRDroW;
4224 case AArch64::LDRXroX:
4225 case AArch64::LDURXi:
4226 case AArch64::LDRXui:
4227 return AArch64::LDRXroW;
4228 case AArch64::STRXroX:
4229 case AArch64::STURXi:
4230 case AArch64::STRXui:
4231 return AArch64::STRXroW;
4232 case AArch64::LDRWroX:
4233 case AArch64::LDURWi:
4234 case AArch64::LDRWui:
4235 return AArch64::LDRWroW;
4236 case AArch64::LDRSWroX:
4237 case AArch64::LDURSWi:
4238 case AArch64::LDRSWui:
4239 return AArch64::LDRSWroW;
4240 case AArch64::STRWroX:
4241 case AArch64::STURWi:
4242 case AArch64::STRWui:
4243 return AArch64::STRWroW;
4244 case AArch64::LDRHroX:
4245 case AArch64::LDURHi:
4246 case AArch64::LDRHui:
4247 return AArch64::LDRHroW;
4248 case AArch64::STRHroX:
4249 case AArch64::STURHi:
4250 case AArch64::STRHui:
4251 return AArch64::STRHroW;
4252 case AArch64::LDRHHroX:
4253 case AArch64::LDURHHi:
4254 case AArch64::LDRHHui:
4255 return AArch64::LDRHHroW;
4256 case AArch64::STRHHroX:
4257 case AArch64::STURHHi:
4258 case AArch64::STRHHui:
4259 return AArch64::STRHHroW;
4260 case AArch64::LDRSHXroX:
4261 case AArch64::LDURSHXi:
4262 case AArch64::LDRSHXui:
4263 return AArch64::LDRSHXroW;
4264 case AArch64::LDRSHWroX:
4265 case AArch64::LDURSHWi:
4266 case AArch64::LDRSHWui:
4267 return AArch64::LDRSHWroW;
4268 case AArch64::LDRBroX:
4269 case AArch64::LDURBi:
4270 case AArch64::LDRBui:
4271 return AArch64::LDRBroW;
4272 case AArch64::LDRBBroX:
4273 case AArch64::LDURBBi:
4274 case AArch64::LDRBBui:
4275 return AArch64::LDRBBroW;
4276 case AArch64::LDRSBXroX:
4277 case AArch64::LDURSBXi:
4278 case AArch64::LDRSBXui:
4279 return AArch64::LDRSBXroW;
4280 case AArch64::LDRSBWroX:
4281 case AArch64::LDURSBWi:
4282 case AArch64::LDRSBWui:
4283 return AArch64::LDRSBWroW;
4284 case AArch64::STRBroX:
4285 case AArch64::STURBi:
4286 case AArch64::STRBui:
4287 return AArch64::STRBroW;
4288 case AArch64::STRBBroX:
4289 case AArch64::STURBBi:
4290 case AArch64::STRBBui:
4291 return AArch64::STRBBroW;
4316 return B.getInstr();
4320 "Addressing mode not supported for folding");
4337 return B.getInstr();
4344 "Address offset can be a register or an immediate, but not both");
4365 return B.getInstr();
4369 "Function must not be called with an addressing mode it can't handle");
4378 case AArch64::LD1Fourv16b_POST:
4379 case AArch64::LD1Fourv1d_POST:
4380 case AArch64::LD1Fourv2d_POST:
4381 case AArch64::LD1Fourv2s_POST:
4382 case AArch64::LD1Fourv4h_POST:
4383 case AArch64::LD1Fourv4s_POST:
4384 case AArch64::LD1Fourv8b_POST:
4385 case AArch64::LD1Fourv8h_POST:
4386 case AArch64::LD1Onev16b_POST:
4387 case AArch64::LD1Onev1d_POST:
4388 case AArch64::LD1Onev2d_POST:
4389 case AArch64::LD1Onev2s_POST:
4390 case AArch64::LD1Onev4h_POST:
4391 case AArch64::LD1Onev4s_POST:
4392 case AArch64::LD1Onev8b_POST:
4393 case AArch64::LD1Onev8h_POST:
4394 case AArch64::LD1Rv16b_POST:
4395 case AArch64::LD1Rv1d_POST:
4396 case AArch64::LD1Rv2d_POST:
4397 case AArch64::LD1Rv2s_POST:
4398 case AArch64::LD1Rv4h_POST:
4399 case AArch64::LD1Rv4s_POST:
4400 case AArch64::LD1Rv8b_POST:
4401 case AArch64::LD1Rv8h_POST:
4402 case AArch64::LD1Threev16b_POST:
4403 case AArch64::LD1Threev1d_POST:
4404 case AArch64::LD1Threev2d_POST:
4405 case AArch64::LD1Threev2s_POST:
4406 case AArch64::LD1Threev4h_POST:
4407 case AArch64::LD1Threev4s_POST:
4408 case AArch64::LD1Threev8b_POST:
4409 case AArch64::LD1Threev8h_POST:
4410 case AArch64::LD1Twov16b_POST:
4411 case AArch64::LD1Twov1d_POST:
4412 case AArch64::LD1Twov2d_POST:
4413 case AArch64::LD1Twov2s_POST:
4414 case AArch64::LD1Twov4h_POST:
4415 case AArch64::LD1Twov4s_POST:
4416 case AArch64::LD1Twov8b_POST:
4417 case AArch64::LD1Twov8h_POST:
4418 case AArch64::LD1i16_POST:
4419 case AArch64::LD1i32_POST:
4420 case AArch64::LD1i64_POST:
4421 case AArch64::LD1i8_POST:
4422 case AArch64::LD2Rv16b_POST:
4423 case AArch64::LD2Rv1d_POST:
4424 case AArch64::LD2Rv2d_POST:
4425 case AArch64::LD2Rv2s_POST:
4426 case AArch64::LD2Rv4h_POST:
4427 case AArch64::LD2Rv4s_POST:
4428 case AArch64::LD2Rv8b_POST:
4429 case AArch64::LD2Rv8h_POST:
4430 case AArch64::LD2Twov16b_POST:
4431 case AArch64::LD2Twov2d_POST:
4432 case AArch64::LD2Twov2s_POST:
4433 case AArch64::LD2Twov4h_POST:
4434 case AArch64::LD2Twov4s_POST:
4435 case AArch64::LD2Twov8b_POST:
4436 case AArch64::LD2Twov8h_POST:
4437 case AArch64::LD2i16_POST:
4438 case AArch64::LD2i32_POST:
4439 case AArch64::LD2i64_POST:
4440 case AArch64::LD2i8_POST:
4441 case AArch64::LD3Rv16b_POST:
4442 case AArch64::LD3Rv1d_POST:
4443 case AArch64::LD3Rv2d_POST:
4444 case AArch64::LD3Rv2s_POST:
4445 case AArch64::LD3Rv4h_POST:
4446 case AArch64::LD3Rv4s_POST:
4447 case AArch64::LD3Rv8b_POST:
4448 case AArch64::LD3Rv8h_POST:
4449 case AArch64::LD3Threev16b_POST:
4450 case AArch64::LD3Threev2d_POST:
4451 case AArch64::LD3Threev2s_POST:
4452 case AArch64::LD3Threev4h_POST:
4453 case AArch64::LD3Threev4s_POST:
4454 case AArch64::LD3Threev8b_POST:
4455 case AArch64::LD3Threev8h_POST:
4456 case AArch64::LD3i16_POST:
4457 case AArch64::LD3i32_POST:
4458 case AArch64::LD3i64_POST:
4459 case AArch64::LD3i8_POST:
4460 case AArch64::LD4Fourv16b_POST:
4461 case AArch64::LD4Fourv2d_POST:
4462 case AArch64::LD4Fourv2s_POST:
4463 case AArch64::LD4Fourv4h_POST:
4464 case AArch64::LD4Fourv4s_POST:
4465 case AArch64::LD4Fourv8b_POST:
4466 case AArch64::LD4Fourv8h_POST:
4467 case AArch64::LD4Rv16b_POST:
4468 case AArch64::LD4Rv1d_POST:
4469 case AArch64::LD4Rv2d_POST:
4470 case AArch64::LD4Rv2s_POST:
4471 case AArch64::LD4Rv4h_POST:
4472 case AArch64::LD4Rv4s_POST:
4473 case AArch64::LD4Rv8b_POST:
4474 case AArch64::LD4Rv8h_POST:
4475 case AArch64::LD4i16_POST:
4476 case AArch64::LD4i32_POST:
4477 case AArch64::LD4i64_POST:
4478 case AArch64::LD4i8_POST:
4479 case AArch64::LDAPRWpost:
4480 case AArch64::LDAPRXpost:
4481 case AArch64::LDIAPPWpost:
4482 case AArch64::LDIAPPXpost:
4483 case AArch64::LDPDpost:
4484 case AArch64::LDPQpost:
4485 case AArch64::LDPSWpost:
4486 case AArch64::LDPSpost:
4487 case AArch64::LDPWpost:
4488 case AArch64::LDPXpost:
4489 case AArch64::LDRBBpost:
4490 case AArch64::LDRBpost:
4491 case AArch64::LDRDpost:
4492 case AArch64::LDRHHpost:
4493 case AArch64::LDRHpost:
4494 case AArch64::LDRQpost:
4495 case AArch64::LDRSBWpost:
4496 case AArch64::LDRSBXpost:
4497 case AArch64::LDRSHWpost:
4498 case AArch64::LDRSHXpost:
4499 case AArch64::LDRSWpost:
4500 case AArch64::LDRSpost:
4501 case AArch64::LDRWpost:
4502 case AArch64::LDRXpost:
4503 case AArch64::ST1Fourv16b_POST:
4504 case AArch64::ST1Fourv1d_POST:
4505 case AArch64::ST1Fourv2d_POST:
4506 case AArch64::ST1Fourv2s_POST:
4507 case AArch64::ST1Fourv4h_POST:
4508 case AArch64::ST1Fourv4s_POST:
4509 case AArch64::ST1Fourv8b_POST:
4510 case AArch64::ST1Fourv8h_POST:
4511 case AArch64::ST1Onev16b_POST:
4512 case AArch64::ST1Onev1d_POST:
4513 case AArch64::ST1Onev2d_POST:
4514 case AArch64::ST1Onev2s_POST:
4515 case AArch64::ST1Onev4h_POST:
4516 case AArch64::ST1Onev4s_POST:
4517 case AArch64::ST1Onev8b_POST:
4518 case AArch64::ST1Onev8h_POST:
4519 case AArch64::ST1Threev16b_POST:
4520 case AArch64::ST1Threev1d_POST:
4521 case AArch64::ST1Threev2d_POST:
4522 case AArch64::ST1Threev2s_POST:
4523 case AArch64::ST1Threev4h_POST:
4524 case AArch64::ST1Threev4s_POST:
4525 case AArch64::ST1Threev8b_POST:
4526 case AArch64::ST1Threev8h_POST:
4527 case AArch64::ST1Twov16b_POST:
4528 case AArch64::ST1Twov1d_POST:
4529 case AArch64::ST1Twov2d_POST:
4530 case AArch64::ST1Twov2s_POST:
4531 case AArch64::ST1Twov4h_POST:
4532 case AArch64::ST1Twov4s_POST:
4533 case AArch64::ST1Twov8b_POST:
4534 case AArch64::ST1Twov8h_POST:
4535 case AArch64::ST1i16_POST:
4536 case AArch64::ST1i32_POST:
4537 case AArch64::ST1i64_POST:
4538 case AArch64::ST1i8_POST:
4539 case AArch64::ST2GPostIndex:
4540 case AArch64::ST2Twov16b_POST:
4541 case AArch64::ST2Twov2d_POST:
4542 case AArch64::ST2Twov2s_POST:
4543 case AArch64::ST2Twov4h_POST:
4544 case AArch64::ST2Twov4s_POST:
4545 case AArch64::ST2Twov8b_POST:
4546 case AArch64::ST2Twov8h_POST:
4547 case AArch64::ST2i16_POST:
4548 case AArch64::ST2i32_POST:
4549 case AArch64::ST2i64_POST:
4550 case AArch64::ST2i8_POST:
4551 case AArch64::ST3Threev16b_POST:
4552 case AArch64::ST3Threev2d_POST:
4553 case AArch64::ST3Threev2s_POST:
4554 case AArch64::ST3Threev4h_POST:
4555 case AArch64::ST3Threev4s_POST:
4556 case AArch64::ST3Threev8b_POST:
4557 case AArch64::ST3Threev8h_POST:
4558 case AArch64::ST3i16_POST:
4559 case AArch64::ST3i32_POST:
4560 case AArch64::ST3i64_POST:
4561 case AArch64::ST3i8_POST:
4562 case AArch64::ST4Fourv16b_POST:
4563 case AArch64::ST4Fourv2d_POST:
4564 case AArch64::ST4Fourv2s_POST:
4565 case AArch64::ST4Fourv4h_POST:
4566 case AArch64::ST4Fourv4s_POST:
4567 case AArch64::ST4Fourv8b_POST:
4568 case AArch64::ST4Fourv8h_POST:
4569 case AArch64::ST4i16_POST:
4570 case AArch64::ST4i32_POST:
4571 case AArch64::ST4i64_POST:
4572 case AArch64::ST4i8_POST:
4573 case AArch64::STGPostIndex:
4574 case AArch64::STGPpost:
4575 case AArch64::STPDpost:
4576 case AArch64::STPQpost:
4577 case AArch64::STPSpost:
4578 case AArch64::STPWpost:
4579 case AArch64::STPXpost:
4580 case AArch64::STRBBpost:
4581 case AArch64::STRBpost:
4582 case AArch64::STRDpost:
4583 case AArch64::STRHHpost:
4584 case AArch64::STRHpost:
4585 case AArch64::STRQpost:
4586 case AArch64::STRSpost:
4587 case AArch64::STRWpost:
4588 case AArch64::STRXpost:
4589 case AArch64::STZ2GPostIndex:
4590 case AArch64::STZGPostIndex:
4597 bool &OffsetIsScalable,
TypeSize &Width,
4618 int64_t Dummy1, Dummy2;
4640 return BaseOp->
isReg() || BaseOp->
isFI();
4647 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4652 TypeSize &Width, int64_t &MinOffset,
4653 int64_t &MaxOffset) {
4658 MinOffset = MaxOffset = 0;
4661 case AArch64::LDRQui:
4662 case AArch64::STRQui:
4667 case AArch64::LDRXui:
4668 case AArch64::LDRDui:
4669 case AArch64::STRXui:
4670 case AArch64::STRDui:
4671 case AArch64::PRFMui:
4676 case AArch64::LDRWui:
4677 case AArch64::LDRSui:
4678 case AArch64::LDRSWui:
4679 case AArch64::STRWui:
4680 case AArch64::STRSui:
4685 case AArch64::LDRHui:
4686 case AArch64::LDRHHui:
4687 case AArch64::LDRSHWui:
4688 case AArch64::LDRSHXui:
4689 case AArch64::STRHui:
4690 case AArch64::STRHHui:
4695 case AArch64::LDRBui:
4696 case AArch64::LDRBBui:
4697 case AArch64::LDRSBWui:
4698 case AArch64::LDRSBXui:
4699 case AArch64::STRBui:
4700 case AArch64::STRBBui:
4706 case AArch64::STRQpre:
4707 case AArch64::LDRQpost:
4713 case AArch64::LDRDpost:
4714 case AArch64::LDRDpre:
4715 case AArch64::LDRXpost:
4716 case AArch64::LDRXpre:
4717 case AArch64::STRDpost:
4718 case AArch64::STRDpre:
4719 case AArch64::STRXpost:
4720 case AArch64::STRXpre:
4726 case AArch64::STRWpost:
4727 case AArch64::STRWpre:
4728 case AArch64::LDRWpost:
4729 case AArch64::LDRWpre:
4730 case AArch64::STRSpost:
4731 case AArch64::STRSpre:
4732 case AArch64::LDRSpost:
4733 case AArch64::LDRSpre:
4739 case AArch64::LDRHpost:
4740 case AArch64::LDRHpre:
4741 case AArch64::STRHpost:
4742 case AArch64::STRHpre:
4743 case AArch64::LDRHHpost:
4744 case AArch64::LDRHHpre:
4745 case AArch64::STRHHpost:
4746 case AArch64::STRHHpre:
4752 case AArch64::LDRBpost:
4753 case AArch64::LDRBpre:
4754 case AArch64::STRBpost:
4755 case AArch64::STRBpre:
4756 case AArch64::LDRBBpost:
4757 case AArch64::LDRBBpre:
4758 case AArch64::STRBBpost:
4759 case AArch64::STRBBpre:
4765 case AArch64::LDURQi:
4766 case AArch64::STURQi:
4772 case AArch64::LDURXi:
4773 case AArch64::LDURDi:
4774 case AArch64::LDAPURXi:
4775 case AArch64::STURXi:
4776 case AArch64::STURDi:
4777 case AArch64::STLURXi:
4778 case AArch64::PRFUMi:
4784 case AArch64::LDURWi:
4785 case AArch64::LDURSi:
4786 case AArch64::LDURSWi:
4787 case AArch64::LDAPURi:
4788 case AArch64::LDAPURSWi:
4789 case AArch64::STURWi:
4790 case AArch64::STURSi:
4791 case AArch64::STLURWi:
4797 case AArch64::LDURHi:
4798 case AArch64::LDURHHi:
4799 case AArch64::LDURSHXi:
4800 case AArch64::LDURSHWi:
4801 case AArch64::LDAPURHi:
4802 case AArch64::LDAPURSHWi:
4803 case AArch64::LDAPURSHXi:
4804 case AArch64::STURHi:
4805 case AArch64::STURHHi:
4806 case AArch64::STLURHi:
4812 case AArch64::LDURBi:
4813 case AArch64::LDURBBi:
4814 case AArch64::LDURSBXi:
4815 case AArch64::LDURSBWi:
4816 case AArch64::LDAPURBi:
4817 case AArch64::LDAPURSBWi:
4818 case AArch64::LDAPURSBXi:
4819 case AArch64::STURBi:
4820 case AArch64::STURBBi:
4821 case AArch64::STLURBi:
4827 case AArch64::LDPQi:
4828 case AArch64::LDNPQi:
4829 case AArch64::STPQi:
4830 case AArch64::STNPQi:
4831 case AArch64::LDPQpost:
4832 case AArch64::LDPQpre:
4833 case AArch64::STPQpost:
4834 case AArch64::STPQpre:
4840 case AArch64::LDPXi:
4841 case AArch64::LDPDi:
4842 case AArch64::LDNPXi:
4843 case AArch64::LDNPDi:
4844 case AArch64::STPXi:
4845 case AArch64::STPDi:
4846 case AArch64::STNPXi:
4847 case AArch64::STNPDi:
4848 case AArch64::LDPDpost:
4849 case AArch64::LDPDpre:
4850 case AArch64::LDPXpost:
4851 case AArch64::LDPXpre:
4852 case AArch64::STPDpost:
4853 case AArch64::STPDpre:
4854 case AArch64::STPXpost:
4855 case AArch64::STPXpre:
4861 case AArch64::LDPWi:
4862 case AArch64::LDPSi:
4863 case AArch64::LDNPWi:
4864 case AArch64::LDNPSi:
4865 case AArch64::STPWi:
4866 case AArch64::STPSi:
4867 case AArch64::STNPWi:
4868 case AArch64::STNPSi:
4869 case AArch64::LDPSpost:
4870 case AArch64::LDPSpre:
4871 case AArch64::LDPWpost:
4872 case AArch64::LDPWpre:
4873 case AArch64::STPSpost:
4874 case AArch64::STPSpre:
4875 case AArch64::STPWpost:
4876 case AArch64::STPWpre:
4882 case AArch64::StoreSwiftAsyncContext:
4895 case AArch64::TAGPstack:
4905 case AArch64::STGPreIndex:
4906 case AArch64::STGPostIndex:
4907 case AArch64::STZGi:
4908 case AArch64::STZGPreIndex:
4909 case AArch64::STZGPostIndex:
4915 case AArch64::STR_ZZZZXI:
4916 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4917 case AArch64::LDR_ZZZZXI:
4918 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4924 case AArch64::STR_ZZZXI:
4925 case AArch64::LDR_ZZZXI:
4931 case AArch64::STR_ZZXI:
4932 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4933 case AArch64::LDR_ZZXI:
4934 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4940 case AArch64::LDR_PXI:
4941 case AArch64::STR_PXI:
4946 case AArch64::LDR_PPXI:
4947 case AArch64::STR_PPXI:
4953 case AArch64::LDR_ZXI:
4954 case AArch64::STR_ZXI:
4959 case AArch64::LD1B_IMM:
4960 case AArch64::LD1H_IMM:
4961 case AArch64::LD1W_IMM:
4962 case AArch64::LD1D_IMM:
4963 case AArch64::LDNT1B_ZRI:
4964 case AArch64::LDNT1H_ZRI:
4965 case AArch64::LDNT1W_ZRI:
4966 case AArch64::LDNT1D_ZRI:
4967 case AArch64::ST1B_IMM:
4968 case AArch64::ST1H_IMM:
4969 case AArch64::ST1W_IMM:
4970 case AArch64::ST1D_IMM:
4971 case AArch64::STNT1B_ZRI:
4972 case AArch64::STNT1H_ZRI:
4973 case AArch64::STNT1W_ZRI:
4974 case AArch64::STNT1D_ZRI:
4975 case AArch64::LDNF1B_IMM:
4976 case AArch64::LDNF1H_IMM:
4977 case AArch64::LDNF1W_IMM:
4978 case AArch64::LDNF1D_IMM:
4985 case AArch64::LD2B_IMM:
4986 case AArch64::LD2H_IMM:
4987 case AArch64::LD2W_IMM:
4988 case AArch64::LD2D_IMM:
4989 case AArch64::ST2B_IMM:
4990 case AArch64::ST2H_IMM:
4991 case AArch64::ST2W_IMM:
4992 case AArch64::ST2D_IMM:
4993 case AArch64::LD1B_2Z_IMM:
4994 case AArch64::LD1B_2Z_STRIDED_IMM:
4995 case AArch64::LD1H_2Z_IMM:
4996 case AArch64::LD1H_2Z_STRIDED_IMM:
4997 case AArch64::LD1W_2Z_IMM:
4998 case AArch64::LD1W_2Z_STRIDED_IMM:
4999 case AArch64::LD1D_2Z_IMM:
5000 case AArch64::LD1D_2Z_STRIDED_IMM:
5001 case AArch64::LD1B_2Z_IMM_PSEUDO:
5002 case AArch64::LD1H_2Z_IMM_PSEUDO:
5003 case AArch64::LD1W_2Z_IMM_PSEUDO:
5004 case AArch64::LD1D_2Z_IMM_PSEUDO:
5005 case AArch64::ST1B_2Z_IMM:
5006 case AArch64::ST1B_2Z_STRIDED_IMM:
5007 case AArch64::ST1H_2Z_IMM:
5008 case AArch64::ST1H_2Z_STRIDED_IMM:
5009 case AArch64::ST1W_2Z_IMM:
5010 case AArch64::ST1W_2Z_STRIDED_IMM:
5011 case AArch64::ST1D_2Z_IMM:
5012 case AArch64::ST1D_2Z_STRIDED_IMM:
5013 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5014 case AArch64::LDNT1B_2Z_IMM:
5015 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5016 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5017 case AArch64::LDNT1H_2Z_IMM:
5018 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5019 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5020 case AArch64::LDNT1W_2Z_IMM:
5021 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5022 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5023 case AArch64::LDNT1D_2Z_IMM:
5024 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5025 case AArch64::STNT1B_2Z_IMM:
5026 case AArch64::STNT1B_2Z_STRIDED_IMM:
5027 case AArch64::STNT1H_2Z_IMM:
5028 case AArch64::STNT1H_2Z_STRIDED_IMM:
5029 case AArch64::STNT1W_2Z_IMM:
5030 case AArch64::STNT1W_2Z_STRIDED_IMM:
5031 case AArch64::STNT1D_2Z_IMM:
5032 case AArch64::STNT1D_2Z_STRIDED_IMM:
5037 case AArch64::LD3B_IMM:
5038 case AArch64::LD3H_IMM:
5039 case AArch64::LD3W_IMM:
5040 case AArch64::LD3D_IMM:
5041 case AArch64::ST3B_IMM:
5042 case AArch64::ST3H_IMM:
5043 case AArch64::ST3W_IMM:
5044 case AArch64::ST3D_IMM:
5049 case AArch64::LD4B_IMM:
5050 case AArch64::LD4H_IMM:
5051 case AArch64::LD4W_IMM:
5052 case AArch64::LD4D_IMM:
5053 case AArch64::ST4B_IMM:
5054 case AArch64::ST4H_IMM:
5055 case AArch64::ST4W_IMM:
5056 case AArch64::ST4D_IMM:
5057 case AArch64::LD1B_4Z_IMM:
5058 case AArch64::LD1B_4Z_STRIDED_IMM:
5059 case AArch64::LD1H_4Z_IMM:
5060 case AArch64::LD1H_4Z_STRIDED_IMM:
5061 case AArch64::LD1W_4Z_IMM:
5062 case AArch64::LD1W_4Z_STRIDED_IMM:
5063 case AArch64::LD1D_4Z_IMM:
5064 case AArch64::LD1D_4Z_STRIDED_IMM:
5065 case AArch64::LD1B_4Z_IMM_PSEUDO:
5066 case AArch64::LD1H_4Z_IMM_PSEUDO:
5067 case AArch64::LD1W_4Z_IMM_PSEUDO:
5068 case AArch64::LD1D_4Z_IMM_PSEUDO:
5069 case AArch64::ST1B_4Z_IMM:
5070 case AArch64::ST1B_4Z_STRIDED_IMM:
5071 case AArch64::ST1H_4Z_IMM:
5072 case AArch64::ST1H_4Z_STRIDED_IMM:
5073 case AArch64::ST1W_4Z_IMM:
5074 case AArch64::ST1W_4Z_STRIDED_IMM:
5075 case AArch64::ST1D_4Z_IMM:
5076 case AArch64::ST1D_4Z_STRIDED_IMM:
5077 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5078 case AArch64::LDNT1B_4Z_IMM:
5079 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5080 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5081 case AArch64::LDNT1H_4Z_IMM:
5082 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5083 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5084 case AArch64::LDNT1W_4Z_IMM:
5085 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5086 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5087 case AArch64::LDNT1D_4Z_IMM:
5088 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5089 case AArch64::STNT1B_4Z_IMM:
5090 case AArch64::STNT1B_4Z_STRIDED_IMM:
5091 case AArch64::STNT1H_4Z_IMM:
5092 case AArch64::STNT1H_4Z_STRIDED_IMM:
5093 case AArch64::STNT1W_4Z_IMM:
5094 case AArch64::STNT1W_4Z_STRIDED_IMM:
5095 case AArch64::STNT1D_4Z_IMM:
5096 case AArch64::STNT1D_4Z_STRIDED_IMM:
5101 case AArch64::LD1B_H_IMM:
5102 case AArch64::LD1SB_H_IMM:
5103 case AArch64::LD1H_S_IMM:
5104 case AArch64::LD1SH_S_IMM:
5105 case AArch64::LD1W_D_IMM:
5106 case AArch64::LD1SW_D_IMM:
5107 case AArch64::ST1B_H_IMM:
5108 case AArch64::ST1H_S_IMM:
5109 case AArch64::ST1W_D_IMM:
5110 case AArch64::LDNF1B_H_IMM:
5111 case AArch64::LDNF1SB_H_IMM:
5112 case AArch64::LDNF1H_S_IMM:
5113 case AArch64::LDNF1SH_S_IMM:
5114 case AArch64::LDNF1W_D_IMM:
5115 case AArch64::LDNF1SW_D_IMM:
5122 case AArch64::LD1B_S_IMM:
5123 case AArch64::LD1SB_S_IMM:
5124 case AArch64::LD1H_D_IMM:
5125 case AArch64::LD1SH_D_IMM:
5126 case AArch64::ST1B_S_IMM:
5127 case AArch64::ST1H_D_IMM:
5128 case AArch64::LDNF1B_S_IMM:
5129 case AArch64::LDNF1SB_S_IMM:
5130 case AArch64::LDNF1H_D_IMM:
5131 case AArch64::LDNF1SH_D_IMM:
5138 case AArch64::LD1B_D_IMM:
5139 case AArch64::LD1SB_D_IMM:
5140 case AArch64::ST1B_D_IMM:
5141 case AArch64::LDNF1B_D_IMM:
5142 case AArch64::LDNF1SB_D_IMM:
5149 case AArch64::ST2Gi:
5150 case AArch64::ST2GPreIndex:
5151 case AArch64::ST2GPostIndex:
5152 case AArch64::STZ2Gi:
5153 case AArch64::STZ2GPreIndex:
5154 case AArch64::STZ2GPostIndex:
5160 case AArch64::STGPi:
5161 case AArch64::STGPpost:
5162 case AArch64::STGPpre:
5167 case AArch64::LD1RB_IMM:
5168 case AArch64::LD1RB_H_IMM:
5169 case AArch64::LD1RB_S_IMM:
5170 case AArch64::LD1RB_D_IMM:
5171 case AArch64::LD1RSB_H_IMM:
5172 case AArch64::LD1RSB_S_IMM:
5173 case AArch64::LD1RSB_D_IMM:
5178 case AArch64::LD1RH_IMM:
5179 case AArch64::LD1RH_S_IMM:
5180 case AArch64::LD1RH_D_IMM:
5181 case AArch64::LD1RSH_S_IMM:
5182 case AArch64::LD1RSH_D_IMM:
5187 case AArch64::LD1RW_IMM:
5188 case AArch64::LD1RW_D_IMM:
5189 case AArch64::LD1RSW_IMM:
5194 case AArch64::LD1RD_IMM:
5209 case AArch64::LDRBui:
5210 case AArch64::LDRBBui:
5211 case AArch64::LDURBBi:
5212 case AArch64::LDRSBWui:
5213 case AArch64::LDURSBWi:
5214 case AArch64::STRBui:
5215 case AArch64::STRBBui:
5216 case AArch64::STURBBi:
5218 case AArch64::LDRHui:
5219 case AArch64::LDRHHui:
5220 case AArch64::LDURHHi:
5221 case AArch64::LDRSHWui:
5222 case AArch64::LDURSHWi:
5223 case AArch64::STRHui:
5224 case AArch64::STRHHui:
5225 case AArch64::STURHHi:
5227 case AArch64::LDRSui:
5228 case AArch64::LDURSi:
5229 case AArch64::LDRSpre:
5230 case AArch64::LDRSWui:
5231 case AArch64::LDURSWi:
5232 case AArch64::LDRSWpre:
5233 case AArch64::LDRWpre:
5234 case AArch64::LDRWui:
5235 case AArch64::LDURWi:
5236 case AArch64::STRSui:
5237 case AArch64::STURSi:
5238 case AArch64::STRSpre:
5239 case AArch64::STRWui:
5240 case AArch64::STURWi:
5241 case AArch64::STRWpre:
5242 case AArch64::LDPSi:
5243 case AArch64::LDPSWi:
5244 case AArch64::LDPWi:
5245 case AArch64::STPSi:
5246 case AArch64::STPWi:
5248 case AArch64::LDRDui:
5249 case AArch64::LDURDi:
5250 case AArch64::LDRDpre:
5251 case AArch64::LDRXui:
5252 case AArch64::LDURXi:
5253 case AArch64::LDRXpre:
5254 case AArch64::STRDui:
5255 case AArch64::STURDi:
5256 case AArch64::STRDpre:
5257 case AArch64::STRXui:
5258 case AArch64::STURXi:
5259 case AArch64::STRXpre:
5260 case AArch64::LDPDi:
5261 case AArch64::LDPXi:
5262 case AArch64::STPDi:
5263 case AArch64::STPXi:
5265 case AArch64::LDRQui:
5266 case AArch64::LDURQi:
5267 case AArch64::STRQui:
5268 case AArch64::STURQi:
5269 case AArch64::STRQpre:
5270 case AArch64::LDPQi:
5271 case AArch64::LDRQpre:
5272 case AArch64::STPQi:
5274 case AArch64::STZGi:
5275 case AArch64::ST2Gi:
5276 case AArch64::STZ2Gi:
5277 case AArch64::STGPi:
5283 switch (
MI.getOpcode()) {
5286 case AArch64::LDRWpre:
5287 case AArch64::LDRXpre:
5288 case AArch64::LDRSWpre:
5289 case AArch64::LDRSpre:
5290 case AArch64::LDRDpre:
5291 case AArch64::LDRQpre:
5297 switch (
MI.getOpcode()) {
5300 case AArch64::STRWpre:
5301 case AArch64::STRXpre:
5302 case AArch64::STRSpre:
5303 case AArch64::STRDpre:
5304 case AArch64::STRQpre:
5314 switch (
MI.getOpcode()) {
5317 case AArch64::LDURBBi:
5318 case AArch64::LDURHHi:
5319 case AArch64::LDURWi:
5320 case AArch64::LDRBBui:
5321 case AArch64::LDRHHui:
5322 case AArch64::LDRWui:
5323 case AArch64::LDRBBroX:
5324 case AArch64::LDRHHroX:
5325 case AArch64::LDRWroX:
5326 case AArch64::LDRBBroW:
5327 case AArch64::LDRHHroW:
5328 case AArch64::LDRWroW:
5334 switch (
MI.getOpcode()) {
5337 case AArch64::LDURSBWi:
5338 case AArch64::LDURSHWi:
5339 case AArch64::LDURSBXi:
5340 case AArch64::LDURSHXi:
5341 case AArch64::LDURSWi:
5342 case AArch64::LDRSBWui:
5343 case AArch64::LDRSHWui:
5344 case AArch64::LDRSBXui:
5345 case AArch64::LDRSHXui:
5346 case AArch64::LDRSWui:
5347 case AArch64::LDRSBWroX:
5348 case AArch64::LDRSHWroX:
5349 case AArch64::LDRSBXroX:
5350 case AArch64::LDRSHXroX:
5351 case AArch64::LDRSWroX:
5352 case AArch64::LDRSBWroW:
5353 case AArch64::LDRSHWroW:
5354 case AArch64::LDRSBXroW:
5355 case AArch64::LDRSHXroW:
5356 case AArch64::LDRSWroW:
5362 switch (
MI.getOpcode()) {
5365 case AArch64::LDPSi:
5366 case AArch64::LDPSWi:
5367 case AArch64::LDPDi:
5368 case AArch64::LDPQi:
5369 case AArch64::LDPWi:
5370 case AArch64::LDPXi:
5371 case AArch64::STPSi:
5372 case AArch64::STPDi:
5373 case AArch64::STPQi:
5374 case AArch64::STPWi:
5375 case AArch64::STPXi:
5376 case AArch64::STGPi:
5382 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5386 return MI.getOperand(Idx);
5391 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5395 return MI.getOperand(Idx);
5400 switch (
MI.getOpcode()) {
5403 case AArch64::LDRBroX:
5404 case AArch64::LDRBBroX:
5405 case AArch64::LDRSBXroX:
5406 case AArch64::LDRSBWroX:
5407 case AArch64::LDRHroX:
5408 case AArch64::LDRHHroX:
5409 case AArch64::LDRSHXroX:
5410 case AArch64::LDRSHWroX:
5411 case AArch64::LDRWroX:
5412 case AArch64::LDRSroX:
5413 case AArch64::LDRSWroX:
5414 case AArch64::LDRDroX:
5415 case AArch64::LDRXroX:
5416 case AArch64::LDRQroX:
5417 return MI.getOperand(4);
5423 if (
MI.getParent() ==
nullptr)
5433 auto Reg =
Op.getReg();
5434 if (Reg.isPhysical())
5435 return AArch64::FPR16RegClass.contains(Reg);
5437 return TRC == &AArch64::FPR16RegClass ||
5438 TRC == &AArch64::FPR16_loRegClass;
5447 auto Reg =
Op.getReg();
5448 if (Reg.isPhysical())
5449 return AArch64::FPR128RegClass.contains(Reg);
5451 return TRC == &AArch64::FPR128RegClass ||
5452 TRC == &AArch64::FPR128_loRegClass;
5458 switch (
MI.getOpcode()) {
5461 case AArch64::PACIASP:
5462 case AArch64::PACIBSP:
5465 case AArch64::PAUTH_PROLOGUE:
5468 case AArch64::HINT: {
5469 unsigned Imm =
MI.getOperand(0).getImm();
5471 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
5474 if (Imm == 25 || Imm == 27)
5486 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5487 return AArch64::FPR128RegClass.contains(Reg) ||
5488 AArch64::FPR64RegClass.contains(Reg) ||
5489 AArch64::FPR32RegClass.contains(Reg) ||
5490 AArch64::FPR16RegClass.contains(Reg) ||
5491 AArch64::FPR8RegClass.contains(Reg);
5498 auto Reg =
Op.getReg();
5499 if (Reg.isPhysical())
5503 return TRC == &AArch64::FPR128RegClass ||
5504 TRC == &AArch64::FPR128_loRegClass ||
5505 TRC == &AArch64::FPR64RegClass ||
5506 TRC == &AArch64::FPR64_loRegClass ||
5507 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5508 TRC == &AArch64::FPR8RegClass;
5530 if (FirstOpc == SecondOpc)
5536 case AArch64::STRSui:
5537 case AArch64::STURSi:
5538 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5539 case AArch64::STRDui:
5540 case AArch64::STURDi:
5541 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5542 case AArch64::STRQui:
5543 case AArch64::STURQi:
5544 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5545 case AArch64::STRWui:
5546 case AArch64::STURWi:
5547 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5548 case AArch64::STRXui:
5549 case AArch64::STURXi:
5550 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5551 case AArch64::LDRSui:
5552 case AArch64::LDURSi:
5553 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5554 case AArch64::LDRDui:
5555 case AArch64::LDURDi:
5556 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5557 case AArch64::LDRQui:
5558 case AArch64::LDURQi:
5559 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5560 case AArch64::LDRWui:
5561 case AArch64::LDURWi:
5562 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5563 case AArch64::LDRSWui:
5564 case AArch64::LDURSWi:
5565 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5566 case AArch64::LDRXui:
5567 case AArch64::LDURXi:
5568 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5575 int64_t Offset1,
unsigned Opcode1,
int FI2,
5576 int64_t Offset2,
unsigned Opcode2) {
5582 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5585 if (ObjectOffset1 % Scale1 != 0)
5587 ObjectOffset1 /= Scale1;
5589 if (ObjectOffset2 % Scale2 != 0)
5591 ObjectOffset2 /= Scale2;
5592 ObjectOffset1 += Offset1;
5593 ObjectOffset2 += Offset2;
5594 return ObjectOffset1 + 1 == ObjectOffset2;
5606 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5607 unsigned NumBytes)
const {
5617 "Only base registers and frame indices are supported.");
5624 if (ClusterSize > 2)
5631 unsigned FirstOpc = FirstLdSt.
getOpcode();
5632 unsigned SecondOpc = SecondLdSt.
getOpcode();
5652 if (Offset1 > 63 || Offset1 < -64)
5657 if (BaseOp1.
isFI()) {
5659 "Caller should have ordered offsets.");
5664 BaseOp2.
getIndex(), Offset2, SecondOpc);
5667 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5669 return Offset1 + 1 == Offset2;
5679 if (
Reg.isPhysical())
5688 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
5697 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5699 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5700 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5701 unsigned NumRegs = Indices.
size();
5703 int SubReg = 0, End = NumRegs, Incr = 1;
5705 SubReg = NumRegs - 1;
5710 for (; SubReg != End; SubReg += Incr) {
5722 unsigned Opcode,
unsigned ZeroReg,
5725 unsigned NumRegs = Indices.
size();
5728 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5729 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5730 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5731 "GPR reg sequences should not be able to overlap");
5734 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5755 unsigned Opc =
MI.getOpcode();
5756 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5758 int64_t PState =
MI.getOperand(0).getImm();
5759 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5761 return MI.getOperand(1).getImm() == 1;
5780 bool RenamableSrc)
const {
5782 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5783 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5784 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5786 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5787 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5789 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5790 &AArch64::GPR64spRegClass);
5791 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5792 &AArch64::GPR64spRegClass);
5802 ++NumZCRegMoveInstrsGPR;
5808 if (Subtarget.hasZeroCycleRegMoveGPR32())
5809 ++NumZCRegMoveInstrsGPR;
5811 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5812 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5814 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5815 &AArch64::GPR64spRegClass);
5816 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5817 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5818 &AArch64::GPR64spRegClass);
5828 ++NumZCRegMoveInstrsGPR;
5834 if (Subtarget.hasZeroCycleRegMoveGPR32())
5835 ++NumZCRegMoveInstrsGPR;
5841 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5842 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5843 !Subtarget.hasZeroCycleZeroingGPR32()) {
5844 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5845 &AArch64::GPR64spRegClass);
5846 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5850 ++NumZCZeroingInstrsGPR;
5851 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5855 ++NumZCZeroingInstrsGPR;
5864 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5865 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5866 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5872 if (Subtarget.hasZeroCycleRegMoveGPR64())
5873 ++NumZCRegMoveInstrsGPR;
5879 if (Subtarget.hasZeroCycleRegMoveGPR64())
5880 ++NumZCRegMoveInstrsGPR;
5886 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5887 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5891 ++NumZCZeroingInstrsGPR;
5901 if (AArch64::PPRRegClass.
contains(DestReg) &&
5902 AArch64::PPRRegClass.
contains(SrcReg)) {
5903 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5904 "Unexpected SVE register.");
5914 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5915 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5916 if (DestIsPNR || SrcIsPNR) {
5918 return (R - AArch64::PN0) + AArch64::P0;
5923 if (PPRSrcReg != PPRDestReg) {
5935 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5936 AArch64::ZPRRegClass.
contains(SrcReg)) {
5937 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5938 "Unexpected SVE register.");
5946 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5947 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5948 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5949 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5950 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5951 "Unexpected SVE register.");
5952 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5959 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5960 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5961 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5962 "Unexpected SVE register.");
5963 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5971 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5972 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5973 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5974 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5975 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5976 "Unexpected SVE register.");
5977 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5978 AArch64::zsub2, AArch64::zsub3};
5985 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5986 AArch64::DDDDRegClass.
contains(SrcReg)) {
5987 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5988 AArch64::dsub2, AArch64::dsub3};
5995 if (AArch64::DDDRegClass.
contains(DestReg) &&
5996 AArch64::DDDRegClass.
contains(SrcReg)) {
5997 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6005 if (AArch64::DDRegClass.
contains(DestReg) &&
6006 AArch64::DDRegClass.
contains(SrcReg)) {
6007 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6014 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6015 AArch64::QQQQRegClass.
contains(SrcReg)) {
6016 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6017 AArch64::qsub2, AArch64::qsub3};
6024 if (AArch64::QQQRegClass.
contains(DestReg) &&
6025 AArch64::QQQRegClass.
contains(SrcReg)) {
6026 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6034 if (AArch64::QQRegClass.
contains(DestReg) &&
6035 AArch64::QQRegClass.
contains(SrcReg)) {
6036 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6042 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6043 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6044 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6046 AArch64::XZR, Indices);
6050 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6051 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6052 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6054 AArch64::WZR, Indices);
6058 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6059 AArch64::FPR128RegClass.
contains(SrcReg)) {
6063 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6064 !Subtarget.isNeonAvailable()) ||
6068 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6069 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6070 }
else if (Subtarget.isNeonAvailable()) {
6074 if (Subtarget.hasZeroCycleRegMoveFPR128())
6075 ++NumZCRegMoveInstrsFPR;
6091 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6092 AArch64::FPR64RegClass.
contains(SrcReg)) {
6093 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6094 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6095 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6097 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6098 &AArch64::FPR128RegClass);
6099 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6100 &AArch64::FPR128RegClass);
6109 ++NumZCRegMoveInstrsFPR;
6113 if (Subtarget.hasZeroCycleRegMoveFPR64())
6114 ++NumZCRegMoveInstrsFPR;
6119 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6120 AArch64::FPR32RegClass.
contains(SrcReg)) {
6121 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6122 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6123 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6125 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6126 &AArch64::FPR128RegClass);
6127 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6128 &AArch64::FPR128RegClass);
6137 ++NumZCRegMoveInstrsFPR;
6138 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6139 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6140 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6141 &AArch64::FPR64RegClass);
6142 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6143 &AArch64::FPR64RegClass);
6151 ++NumZCRegMoveInstrsFPR;
6155 if (Subtarget.hasZeroCycleRegMoveFPR32())
6156 ++NumZCRegMoveInstrsFPR;
6161 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6162 AArch64::FPR16RegClass.
contains(SrcReg)) {
6163 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6164 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6165 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6167 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6168 &AArch64::FPR128RegClass);
6169 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6170 &AArch64::FPR128RegClass);
6179 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6180 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6181 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6182 &AArch64::FPR64RegClass);
6183 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6184 &AArch64::FPR64RegClass);
6193 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6194 &AArch64::FPR32RegClass);
6195 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6196 &AArch64::FPR32RegClass);
6203 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6204 AArch64::FPR8RegClass.
contains(SrcReg)) {
6205 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6206 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6207 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6209 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6210 &AArch64::FPR128RegClass);
6211 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6212 &AArch64::FPR128RegClass);
6221 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6222 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6223 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6224 &AArch64::FPR64RegClass);
6225 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6226 &AArch64::FPR64RegClass);
6235 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6236 &AArch64::FPR32RegClass);
6237 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6238 &AArch64::FPR32RegClass);
6246 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6247 AArch64::GPR64RegClass.
contains(SrcReg)) {
6248 if (AArch64::XZR == SrcReg) {
6256 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6257 AArch64::FPR64RegClass.
contains(SrcReg)) {
6263 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6264 AArch64::GPR32RegClass.
contains(SrcReg)) {
6265 if (AArch64::WZR == SrcReg) {
6273 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6274 AArch64::FPR32RegClass.
contains(SrcReg)) {
6280 if (DestReg == AArch64::NZCV) {
6281 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6283 .
addImm(AArch64SysReg::NZCV)
6289 if (SrcReg == AArch64::NZCV) {
6290 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6292 .
addImm(AArch64SysReg::NZCV)
6298 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6309 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6314 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6316 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6329 Register SrcReg,
bool isKill,
int FI,
6344 switch (RI.getSpillSize(*RC)) {
6346 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6347 Opc = AArch64::STRBui;
6350 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6351 Opc = AArch64::STRHui;
6352 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6353 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6354 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6355 "Unexpected register store without SVE store instructions");
6356 Opc = AArch64::STR_PXI;
6362 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6363 Opc = AArch64::STRWui;
6367 assert(SrcReg != AArch64::WSP);
6368 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6369 Opc = AArch64::STRSui;
6370 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6371 Opc = AArch64::STR_PPXI;
6376 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6377 Opc = AArch64::STRXui;
6381 assert(SrcReg != AArch64::SP);
6382 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6383 Opc = AArch64::STRDui;
6384 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6386 get(AArch64::STPWi), SrcReg, isKill,
6387 AArch64::sube32, AArch64::subo32, FI, MMO);
6392 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6393 Opc = AArch64::STRQui;
6394 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6395 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6396 Opc = AArch64::ST1Twov1d;
6398 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6400 get(AArch64::STPXi), SrcReg, isKill,
6401 AArch64::sube64, AArch64::subo64, FI, MMO);
6403 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6404 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6405 "Unexpected register store without SVE store instructions");
6406 Opc = AArch64::STR_ZXI;
6411 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6412 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6413 Opc = AArch64::ST1Threev1d;
6418 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6419 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6420 Opc = AArch64::ST1Fourv1d;
6422 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6423 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6424 Opc = AArch64::ST1Twov2d;
6426 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6427 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6428 "Unexpected register store without SVE store instructions");
6429 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6431 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6432 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6433 "Unexpected register store without SVE store instructions");
6434 Opc = AArch64::STR_ZZXI;
6439 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6440 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6441 Opc = AArch64::ST1Threev2d;
6443 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6444 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6445 "Unexpected register store without SVE store instructions");
6446 Opc = AArch64::STR_ZZZXI;
6451 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6452 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6453 Opc = AArch64::ST1Fourv2d;
6455 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6456 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6457 "Unexpected register store without SVE store instructions");
6458 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6460 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6461 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6462 "Unexpected register store without SVE store instructions");
6463 Opc = AArch64::STR_ZZZZXI;
6468 assert(
Opc &&
"Unknown register class");
6479 MI.addMemOperand(MMO);
6486 Register DestReg,
unsigned SubIdx0,
6487 unsigned SubIdx1,
int FI,
6491 bool IsUndef =
true;
6493 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6495 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6524 switch (
TRI.getSpillSize(*RC)) {
6526 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6527 Opc = AArch64::LDRBui;
6530 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6531 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6532 Opc = AArch64::LDRHui;
6533 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6534 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6535 "Unexpected register load without SVE load instructions");
6538 Opc = AArch64::LDR_PXI;
6544 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6545 Opc = AArch64::LDRWui;
6549 assert(DestReg != AArch64::WSP);
6550 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6551 Opc = AArch64::LDRSui;
6552 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6553 Opc = AArch64::LDR_PPXI;
6558 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6559 Opc = AArch64::LDRXui;
6563 assert(DestReg != AArch64::SP);
6564 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6565 Opc = AArch64::LDRDui;
6566 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6568 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6569 AArch64::subo32, FI, MMO);
6574 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6575 Opc = AArch64::LDRQui;
6576 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6577 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6578 Opc = AArch64::LD1Twov1d;
6580 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6582 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6583 AArch64::subo64, FI, MMO);
6585 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6586 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6587 "Unexpected register load without SVE load instructions");
6588 Opc = AArch64::LDR_ZXI;
6593 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6594 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6595 Opc = AArch64::LD1Threev1d;
6600 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6601 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6602 Opc = AArch64::LD1Fourv1d;
6604 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6605 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6606 Opc = AArch64::LD1Twov2d;
6608 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6609 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6610 "Unexpected register load without SVE load instructions");
6611 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6613 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6614 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6615 "Unexpected register load without SVE load instructions");
6616 Opc = AArch64::LDR_ZZXI;
6621 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6622 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6623 Opc = AArch64::LD1Threev2d;
6625 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6626 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6627 "Unexpected register load without SVE load instructions");
6628 Opc = AArch64::LDR_ZZZXI;
6633 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6634 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6635 Opc = AArch64::LD1Fourv2d;
6637 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6638 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6639 "Unexpected register load without SVE load instructions");
6640 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6642 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6643 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6644 "Unexpected register load without SVE load instructions");
6645 Opc = AArch64::LDR_ZZZZXI;
6651 assert(
Opc &&
"Unknown register class");
6661 MI.addMemOperand(MMO);
6668 UseMI.getIterator()),
6670 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6671 I.readsRegister(AArch64::NZCV, TRI);
6675void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6680 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6687 ByteSized =
Offset.getFixed();
6688 VGSized =
Offset.getScalable() / 2;
6694void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6696 int64_t &NumDataVectors) {
6700 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6702 NumBytes =
Offset.getFixed();
6704 NumPredicateVectors =
Offset.getScalable() / 2;
6709 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6710 NumPredicateVectors > 62) {
6711 NumDataVectors = NumPredicateVectors / 8;
6712 NumPredicateVectors -= NumDataVectors * 8;
6738 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6746 int64_t OffsetFromDefCFA) {
6760 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6761 if (!RegScale.empty())
6771 int64_t NumBytes, NumVGScaledBytes;
6772 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6774 std::string CommentBuffer;
6777 if (
Reg == AArch64::SP)
6779 else if (
Reg == AArch64::FP)
6786 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6787 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6789 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6792 if (NumVGScaledBytes) {
6802 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6810 unsigned FrameReg,
unsigned Reg,
6812 bool LastAdjustmentWasScalable) {
6813 if (
Offset.getScalable())
6816 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6819 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6826 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6827 int64_t NumBytes, NumVGScaledBytes;
6828 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6829 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6831 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6834 if (!NumVGScaledBytes)
6837 std::string CommentBuffer;
6842 assert(NumVGScaledBytes &&
"Expected scalable offset");
6846 if (IncomingVGOffsetFromDefCFA) {
6848 VGRegScale =
"* IncomingVG";
6851 VGRegScale =
"* VG";
6855 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6864 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6879 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6882 bool *HasWinCFI,
bool EmitCFAOffset,
6885 unsigned MaxEncoding, ShiftSize;
6887 case AArch64::ADDXri:
6888 case AArch64::ADDSXri:
6889 case AArch64::SUBXri:
6890 case AArch64::SUBSXri:
6891 MaxEncoding = 0xfff;
6894 case AArch64::ADDVL_XXI:
6895 case AArch64::ADDPL_XXI:
6896 case AArch64::ADDSVL_XXI:
6897 case AArch64::ADDSPL_XXI:
6912 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6914 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6928 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6930 if (TmpReg == AArch64::XZR)
6931 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
6932 &AArch64::GPR64RegClass);
6934 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6935 unsigned LocalShiftSize = 0;
6936 if (ThisVal > MaxEncoding) {
6937 ThisVal = ThisVal >> ShiftSize;
6938 LocalShiftSize = ShiftSize;
6940 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6941 "Encoding cannot handle value that big");
6943 Offset -= ThisVal << LocalShiftSize;
6948 .
addImm(Sign * (
int)ThisVal);
6958 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6959 CFAOffset += Change;
6961 CFAOffset -= Change;
6962 if (EmitCFAOffset && DestReg == TmpReg) {
6975 int Imm = (int)(ThisVal << LocalShiftSize);
6976 if (VScale != 1 && DestReg == AArch64::SP) {
6982 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
6983 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
6984 assert(VScale == 1 &&
"Expected non-scalable operation");
6993 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
6994 "emit a single SEH directive");
6995 }
else if (DestReg == AArch64::SP) {
6996 assert(VScale == 1 &&
"Expected non-scalable operation");
6999 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7012 unsigned DestReg,
unsigned SrcReg,
7015 bool NeedsWinCFI,
bool *HasWinCFI,
7017 unsigned FrameReg) {
7024 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7026 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7027 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7028 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7031 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7032 if (NeedsFinalDefNZCV)
7036 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7037 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7038 "SP increment/decrement not 8-byte aligned");
7039 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7042 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7045 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7047 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7054 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7055 "WinCFI can't allocate fractions of an SVE data vector");
7057 if (NumDataVectors) {
7059 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7060 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7066 if (NumPredicateVectors) {
7067 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7069 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7070 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7074 if (NeedsFinalDefNZCV)
7096 if (
MI.isFullCopy()) {
7099 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7103 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7108 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7136 if (
MI.isCopy() &&
Ops.size() == 1 &&
7138 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7139 bool IsSpill =
Ops[0] == 0;
7140 bool IsFill = !IsSpill;
7152 :
TRI.getMinimalPhysRegClass(Reg);
7158 "Mismatched register size in non subreg COPY");
7165 return &*--InsertPt;
7177 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7180 "Unexpected subreg on physical register");
7182 FrameIndex, &AArch64::GPR64RegClass,
Register());
7183 return &*--InsertPt;
7200 case AArch64::sub_32:
7201 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7202 FillRC = &AArch64::GPR32RegClass;
7205 FillRC = &AArch64::FPR32RegClass;
7208 FillRC = &AArch64::FPR64RegClass;
7214 TRI.getRegSizeInBits(*FillRC) &&
7215 "Mismatched regclass size on folded subreg COPY");
7234 bool *OutUseUnscaledOp,
7235 unsigned *OutUnscaledOp,
7236 int64_t *EmittableOffset) {
7238 if (EmittableOffset)
7239 *EmittableOffset = 0;
7240 if (OutUseUnscaledOp)
7241 *OutUseUnscaledOp =
false;
7247 switch (
MI.getOpcode()) {
7250 case AArch64::LD1Rv1d:
7251 case AArch64::LD1Rv2s:
7252 case AArch64::LD1Rv2d:
7253 case AArch64::LD1Rv4h:
7254 case AArch64::LD1Rv4s:
7255 case AArch64::LD1Rv8b:
7256 case AArch64::LD1Rv8h:
7257 case AArch64::LD1Rv16b:
7258 case AArch64::LD1Twov2d:
7259 case AArch64::LD1Threev2d:
7260 case AArch64::LD1Fourv2d:
7261 case AArch64::LD1Twov1d:
7262 case AArch64::LD1Threev1d:
7263 case AArch64::LD1Fourv1d:
7264 case AArch64::ST1Twov2d:
7265 case AArch64::ST1Threev2d:
7266 case AArch64::ST1Fourv2d:
7267 case AArch64::ST1Twov1d:
7268 case AArch64::ST1Threev1d:
7269 case AArch64::ST1Fourv1d:
7270 case AArch64::ST1i8:
7271 case AArch64::ST1i16:
7272 case AArch64::ST1i32:
7273 case AArch64::ST1i64:
7275 case AArch64::IRGstack:
7276 case AArch64::STGloop:
7277 case AArch64::STZGloop:
7282 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7283 int64_t MinOff, MaxOff;
7289 bool IsMulVL = ScaleValue.isScalable();
7290 unsigned Scale = ScaleValue.getKnownMinValue();
7300 std::optional<unsigned> UnscaledOp =
7302 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7303 if (useUnscaledOp &&
7308 Scale = ScaleValue.getKnownMinValue();
7309 assert(IsMulVL == ScaleValue.isScalable() &&
7310 "Unscaled opcode has different value for scalable");
7312 int64_t Remainder =
Offset % Scale;
7313 assert(!(Remainder && useUnscaledOp) &&
7314 "Cannot have remainder when using unscaled op");
7316 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7317 int64_t NewOffset =
Offset / Scale;
7318 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7326 int64_t HighPart =
Offset & ~0xFFF;
7327 int64_t LowPart =
Offset & 0xFFF;
7328 int64_t LowScaled = LowPart / Scale;
7329 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7330 MinOff <= LowScaled && LowScaled <= MaxOff &&
7332 NewOffset = LowScaled;
7337 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7342 if (EmittableOffset)
7343 *EmittableOffset = NewOffset;
7344 if (OutUseUnscaledOp)
7345 *OutUseUnscaledOp = useUnscaledOp;
7346 if (OutUnscaledOp && UnscaledOp)
7347 *OutUnscaledOp = *UnscaledOp;
7360 unsigned Opcode =
MI.getOpcode();
7361 unsigned ImmIdx = FrameRegIdx + 1;
7363 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7368 MI.eraseFromParent();
7374 unsigned UnscaledOp;
7377 &UnscaledOp, &NewOffset);
7381 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7383 MI.setDesc(
TII->get(UnscaledOp));
7385 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7401bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7406 case AArch64::ADDSWrr:
7407 case AArch64::ADDSWri:
7408 case AArch64::ADDSXrr:
7409 case AArch64::ADDSXri:
7410 case AArch64::SUBSWrr:
7411 case AArch64::SUBSXrr:
7413 case AArch64::SUBSWri:
7414 case AArch64::SUBSXri:
7425 case AArch64::ADDWrr:
7426 case AArch64::ADDWri:
7427 case AArch64::SUBWrr:
7428 case AArch64::ADDSWrr:
7429 case AArch64::ADDSWri:
7430 case AArch64::SUBSWrr:
7432 case AArch64::SUBWri:
7433 case AArch64::SUBSWri:
7444 case AArch64::ADDXrr:
7445 case AArch64::ADDXri:
7446 case AArch64::SUBXrr:
7447 case AArch64::ADDSXrr:
7448 case AArch64::ADDSXri:
7449 case AArch64::SUBSXrr:
7451 case AArch64::SUBXri:
7452 case AArch64::SUBSXri:
7453 case AArch64::ADDv8i8:
7454 case AArch64::ADDv16i8:
7455 case AArch64::ADDv4i16:
7456 case AArch64::ADDv8i16:
7457 case AArch64::ADDv2i32:
7458 case AArch64::ADDv4i32:
7459 case AArch64::SUBv8i8:
7460 case AArch64::SUBv16i8:
7461 case AArch64::SUBv4i16:
7462 case AArch64::SUBv8i16:
7463 case AArch64::SUBv2i32:
7464 case AArch64::SUBv4i32:
7477 case AArch64::FADDHrr:
7478 case AArch64::FADDSrr:
7479 case AArch64::FADDDrr:
7480 case AArch64::FADDv4f16:
7481 case AArch64::FADDv8f16:
7482 case AArch64::FADDv2f32:
7483 case AArch64::FADDv2f64:
7484 case AArch64::FADDv4f32:
7485 case AArch64::FSUBHrr:
7486 case AArch64::FSUBSrr:
7487 case AArch64::FSUBDrr:
7488 case AArch64::FSUBv4f16:
7489 case AArch64::FSUBv8f16:
7490 case AArch64::FSUBv2f32:
7491 case AArch64::FSUBv2f64:
7492 case AArch64::FSUBv4f32:
7511 unsigned CombineOpc,
unsigned ZeroReg = 0,
7512 bool CheckZeroReg =
false) {
7519 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7526 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7527 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7528 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7530 if (
MI->getOperand(3).getReg() != ZeroReg)
7535 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7544 unsigned MulOpc,
unsigned ZeroReg) {
7559bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7560 bool Invert)
const {
7566 case AArch64::FADDHrr:
7567 case AArch64::FADDSrr:
7568 case AArch64::FADDDrr:
7569 case AArch64::FMULHrr:
7570 case AArch64::FMULSrr:
7571 case AArch64::FMULDrr:
7572 case AArch64::FMULX16:
7573 case AArch64::FMULX32:
7574 case AArch64::FMULX64:
7576 case AArch64::FADDv4f16:
7577 case AArch64::FADDv8f16:
7578 case AArch64::FADDv2f32:
7579 case AArch64::FADDv4f32:
7580 case AArch64::FADDv2f64:
7581 case AArch64::FMULv4f16:
7582 case AArch64::FMULv8f16:
7583 case AArch64::FMULv2f32:
7584 case AArch64::FMULv4f32:
7585 case AArch64::FMULv2f64:
7586 case AArch64::FMULXv4f16:
7587 case AArch64::FMULXv8f16:
7588 case AArch64::FMULXv2f32:
7589 case AArch64::FMULXv4f32:
7590 case AArch64::FMULXv2f64:
7594 case AArch64::FADD_ZZZ_H:
7595 case AArch64::FADD_ZZZ_S:
7596 case AArch64::FADD_ZZZ_D:
7597 case AArch64::FMUL_ZZZ_H:
7598 case AArch64::FMUL_ZZZ_S:
7599 case AArch64::FMUL_ZZZ_D:
7610 case AArch64::ADDWrr:
7611 case AArch64::ADDXrr:
7612 case AArch64::ANDWrr:
7613 case AArch64::ANDXrr:
7614 case AArch64::ORRWrr:
7615 case AArch64::ORRXrr:
7616 case AArch64::EORWrr:
7617 case AArch64::EORXrr:
7618 case AArch64::EONWrr:
7619 case AArch64::EONXrr:
7623 case AArch64::ADDv8i8:
7624 case AArch64::ADDv16i8:
7625 case AArch64::ADDv4i16:
7626 case AArch64::ADDv8i16:
7627 case AArch64::ADDv2i32:
7628 case AArch64::ADDv4i32:
7629 case AArch64::ADDv1i64:
7630 case AArch64::ADDv2i64:
7631 case AArch64::MULv8i8:
7632 case AArch64::MULv16i8:
7633 case AArch64::MULv4i16:
7634 case AArch64::MULv8i16:
7635 case AArch64::MULv2i32:
7636 case AArch64::MULv4i32:
7637 case AArch64::ANDv8i8:
7638 case AArch64::ANDv16i8:
7639 case AArch64::ORRv8i8:
7640 case AArch64::ORRv16i8:
7641 case AArch64::EORv8i8:
7642 case AArch64::EORv16i8:
7644 case AArch64::ADD_ZZZ_B:
7645 case AArch64::ADD_ZZZ_H:
7646 case AArch64::ADD_ZZZ_S:
7647 case AArch64::ADD_ZZZ_D:
7648 case AArch64::MUL_ZZZ_B:
7649 case AArch64::MUL_ZZZ_H:
7650 case AArch64::MUL_ZZZ_S:
7651 case AArch64::MUL_ZZZ_D:
7652 case AArch64::AND_ZZZ:
7653 case AArch64::ORR_ZZZ:
7654 case AArch64::EOR_ZZZ:
7685 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7693 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7705 case AArch64::ADDWrr:
7707 "ADDWrr does not have register operands");
7708 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7709 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7711 case AArch64::ADDXrr:
7712 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7713 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7715 case AArch64::SUBWrr:
7716 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7717 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7719 case AArch64::SUBXrr:
7720 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7721 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7723 case AArch64::ADDWri:
7724 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7726 case AArch64::ADDXri:
7727 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7729 case AArch64::SUBWri:
7730 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7732 case AArch64::SUBXri:
7733 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7735 case AArch64::ADDv8i8:
7736 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7737 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7739 case AArch64::ADDv16i8:
7740 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7741 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7743 case AArch64::ADDv4i16:
7744 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7745 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7746 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7747 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7749 case AArch64::ADDv8i16:
7750 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7751 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7752 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7753 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7755 case AArch64::ADDv2i32:
7756 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7757 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7758 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7759 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7761 case AArch64::ADDv4i32:
7762 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7763 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7764 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7765 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7767 case AArch64::SUBv8i8:
7768 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7769 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7771 case AArch64::SUBv16i8:
7772 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7773 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7775 case AArch64::SUBv4i16:
7776 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7777 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7778 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7779 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7781 case AArch64::SUBv8i16:
7782 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7783 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7784 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7785 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7787 case AArch64::SUBv2i32:
7788 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7789 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7790 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7791 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7793 case AArch64::SUBv4i32:
7794 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7795 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7796 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7797 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7803bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7807 case AArch64::UABALB_ZZZ_D:
7808 case AArch64::UABALB_ZZZ_H:
7809 case AArch64::UABALB_ZZZ_S:
7810 case AArch64::UABALT_ZZZ_D:
7811 case AArch64::UABALT_ZZZ_H:
7812 case AArch64::UABALT_ZZZ_S:
7813 case AArch64::SABALB_ZZZ_D:
7814 case AArch64::SABALB_ZZZ_S:
7815 case AArch64::SABALB_ZZZ_H:
7816 case AArch64::SABALT_ZZZ_D:
7817 case AArch64::SABALT_ZZZ_S:
7818 case AArch64::SABALT_ZZZ_H:
7819 case AArch64::UABALv16i8_v8i16:
7820 case AArch64::UABALv2i32_v2i64:
7821 case AArch64::UABALv4i16_v4i32:
7822 case AArch64::UABALv4i32_v2i64:
7823 case AArch64::UABALv8i16_v4i32:
7824 case AArch64::UABALv8i8_v8i16:
7825 case AArch64::UABAv16i8:
7826 case AArch64::UABAv2i32:
7827 case AArch64::UABAv4i16:
7828 case AArch64::UABAv4i32:
7829 case AArch64::UABAv8i16:
7830 case AArch64::UABAv8i8:
7831 case AArch64::SABALv16i8_v8i16:
7832 case AArch64::SABALv2i32_v2i64:
7833 case AArch64::SABALv4i16_v4i32:
7834 case AArch64::SABALv4i32_v2i64:
7835 case AArch64::SABALv8i16_v4i32:
7836 case AArch64::SABALv8i8_v8i16:
7837 case AArch64::SABAv16i8:
7838 case AArch64::SABAv2i32:
7839 case AArch64::SABAv4i16:
7840 case AArch64::SABAv4i32:
7841 case AArch64::SABAv8i16:
7842 case AArch64::SABAv8i8:
7849unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7850 unsigned AccumulationOpcode)
const {
7851 switch (AccumulationOpcode) {
7854 case AArch64::UABALB_ZZZ_D:
7855 return AArch64::UABDLB_ZZZ_D;
7856 case AArch64::UABALB_ZZZ_H:
7857 return AArch64::UABDLB_ZZZ_H;
7858 case AArch64::UABALB_ZZZ_S:
7859 return AArch64::UABDLB_ZZZ_S;
7860 case AArch64::UABALT_ZZZ_D:
7861 return AArch64::UABDLT_ZZZ_D;
7862 case AArch64::UABALT_ZZZ_H:
7863 return AArch64::UABDLT_ZZZ_H;
7864 case AArch64::UABALT_ZZZ_S:
7865 return AArch64::UABDLT_ZZZ_S;
7866 case AArch64::UABALv16i8_v8i16:
7867 return AArch64::UABDLv16i8_v8i16;
7868 case AArch64::UABALv2i32_v2i64:
7869 return AArch64::UABDLv2i32_v2i64;
7870 case AArch64::UABALv4i16_v4i32:
7871 return AArch64::UABDLv4i16_v4i32;
7872 case AArch64::UABALv4i32_v2i64:
7873 return AArch64::UABDLv4i32_v2i64;
7874 case AArch64::UABALv8i16_v4i32:
7875 return AArch64::UABDLv8i16_v4i32;
7876 case AArch64::UABALv8i8_v8i16:
7877 return AArch64::UABDLv8i8_v8i16;
7878 case AArch64::UABAv16i8:
7879 return AArch64::UABDv16i8;
7880 case AArch64::UABAv2i32:
7881 return AArch64::UABDv2i32;
7882 case AArch64::UABAv4i16:
7883 return AArch64::UABDv4i16;
7884 case AArch64::UABAv4i32:
7885 return AArch64::UABDv4i32;
7886 case AArch64::UABAv8i16:
7887 return AArch64::UABDv8i16;
7888 case AArch64::UABAv8i8:
7889 return AArch64::UABDv8i8;
7890 case AArch64::SABALB_ZZZ_D:
7891 return AArch64::SABDLB_ZZZ_D;
7892 case AArch64::SABALB_ZZZ_S:
7893 return AArch64::SABDLB_ZZZ_S;
7894 case AArch64::SABALB_ZZZ_H:
7895 return AArch64::SABDLB_ZZZ_H;
7896 case AArch64::SABALT_ZZZ_D:
7897 return AArch64::SABDLT_ZZZ_D;
7898 case AArch64::SABALT_ZZZ_S:
7899 return AArch64::SABDLT_ZZZ_S;
7900 case AArch64::SABALT_ZZZ_H:
7901 return AArch64::SABDLT_ZZZ_H;
7902 case AArch64::SABALv16i8_v8i16:
7903 return AArch64::SABDLv16i8_v8i16;
7904 case AArch64::SABALv2i32_v2i64:
7905 return AArch64::SABDLv2i32_v2i64;
7906 case AArch64::SABALv4i16_v4i32:
7907 return AArch64::SABDLv4i16_v4i32;
7908 case AArch64::SABALv4i32_v2i64:
7909 return AArch64::SABDLv4i32_v2i64;
7910 case AArch64::SABALv8i16_v4i32:
7911 return AArch64::SABDLv8i16_v4i32;
7912 case AArch64::SABALv8i8_v8i16:
7913 return AArch64::SABDLv8i8_v8i16;
7914 case AArch64::SABAv16i8:
7915 return AArch64::SABDv16i8;
7916 case AArch64::SABAv2i32:
7917 return AArch64::SABAv2i32;
7918 case AArch64::SABAv4i16:
7919 return AArch64::SABDv4i16;
7920 case AArch64::SABAv4i32:
7921 return AArch64::SABDv4i32;
7922 case AArch64::SABAv8i16:
7923 return AArch64::SABDv8i16;
7924 case AArch64::SABAv8i8:
7925 return AArch64::SABDv8i8;
7941 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7953 assert(
false &&
"Unsupported FP instruction in combiner\n");
7955 case AArch64::FADDHrr:
7957 "FADDHrr does not have register operands");
7959 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7960 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7962 case AArch64::FADDSrr:
7964 "FADDSrr does not have register operands");
7966 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7967 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7969 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7970 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7972 case AArch64::FADDDrr:
7973 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7974 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7976 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
7977 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
7979 case AArch64::FADDv4f16:
7980 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
7981 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
7983 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
7984 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
7986 case AArch64::FADDv8f16:
7987 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
7988 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
7990 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
7991 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
7993 case AArch64::FADDv2f32:
7994 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
7995 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
7997 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
7998 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8000 case AArch64::FADDv2f64:
8001 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8002 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8004 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8005 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8007 case AArch64::FADDv4f32:
8008 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8009 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8011 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8012 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8014 case AArch64::FSUBHrr:
8015 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8016 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8017 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8019 case AArch64::FSUBSrr:
8020 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8022 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8023 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8025 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8027 case AArch64::FSUBDrr:
8028 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8030 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8031 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8033 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8035 case AArch64::FSUBv4f16:
8036 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8037 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8039 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8040 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8042 case AArch64::FSUBv8f16:
8043 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8044 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8046 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8047 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8049 case AArch64::FSUBv2f32:
8050 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8051 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8053 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8054 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8056 case AArch64::FSUBv2f64:
8057 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8058 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8060 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8061 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8063 case AArch64::FSUBv4f32:
8064 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8065 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8067 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8068 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8079 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8086 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8087 MI->getOperand(1).getReg().isVirtual())
8089 if (
MI &&
MI->getOpcode() == Opcode) {
8101 case AArch64::FMULv2f32:
8102 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8103 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8105 case AArch64::FMULv2f64:
8106 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8107 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8109 case AArch64::FMULv4f16:
8110 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8111 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8113 case AArch64::FMULv4f32:
8114 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8115 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8117 case AArch64::FMULv8f16:
8118 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8119 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8132 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8135 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8150 case AArch64::FNEGDr:
8152 case AArch64::FNEGSr:
8284 case AArch64::SUBWrr:
8285 case AArch64::SUBSWrr:
8286 case AArch64::SUBXrr:
8287 case AArch64::SUBSXrr:
8332 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8355 while (!RemainingLanes.
empty() && CurrInstr &&
8356 CurrInstr->getOpcode() == LoadLaneOpCode &&
8358 CurrInstr->getNumOperands() == 4) {
8359 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8365 if (!RemainingLanes.
empty())
8369 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8373 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8374 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8375 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8391 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8394 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8395 !RemainingLoadInstrs.
empty();
8396 --MBBItr, --RemainingSteps) {
8400 RemainingLoadInstrs.
erase(&CurrInstr);
8410 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8436 case AArch64::LD1i32:
8438 case AArch64::LD1i16:
8440 case AArch64::LD1i8:
8456 unsigned Pattern,
unsigned NumLanes) {
8464 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8472 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8478 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8484 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8485 Register SrcRegister,
unsigned Lane,
8487 bool OffsetRegisterKillState) {
8496 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8497 InsInstrs.
push_back(LoadIndexIntoRegister);
8503 auto CreateLDRInstruction =
8509 Opcode = AArch64::LDRSui;
8512 Opcode = AArch64::LDRHui;
8515 Opcode = AArch64::LDRBui;
8519 "Got unsupported number of lanes in machine-combiner gather pattern");
8529 auto LanesToLoadToReg0 =
8531 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8532 Register PrevReg = SubregToReg->getOperand(0).getReg();
8534 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8535 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8536 OffsetRegOperand.
getReg(),
8537 OffsetRegOperand.
isKill());
8544 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8546 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8553 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8554 OriginalSplitToLoadOffsetOperand.
getReg(),
8557 InstrIdxForVirtReg.
insert(
8558 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8559 InsInstrs.
push_back(MiddleIndexLoadInstr);
8564 unsigned SubregType;
8567 SubregType = AArch64::ssub;
8570 SubregType = AArch64::hsub;
8573 SubregType = AArch64::bsub;
8577 "Got invalid NumLanes for machine-combiner gather pattern");
8580 auto SubRegToRegInstr =
8582 DestRegForSubregToReg)
8585 InstrIdxForVirtReg.
insert(
8586 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8590 auto LanesToLoadToReg1 =
8592 LoadToLaneInstrsAscending.end());
8593 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8595 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8596 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8597 OffsetRegOperand.
getReg(),
8598 OffsetRegOperand.
isKill());
8601 if (Index == NumLanes / 2 - 2) {
8636bool AArch64InstrInfo::getMachineCombinerPatterns(
8638 bool DoRegPressureReduce)
const {
8659 DoRegPressureReduce);
8688 const Register *ReplacedAddend =
nullptr) {
8689 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8691 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8694 Register SrcReg0 = MUL->getOperand(1).getReg();
8695 bool Src0IsKill = MUL->getOperand(1).isKill();
8696 Register SrcReg1 = MUL->getOperand(2).getReg();
8697 bool Src1IsKill = MUL->getOperand(2).isKill();
8701 if (ReplacedAddend) {
8703 SrcReg2 = *ReplacedAddend;
8730 .
addImm(MUL->getOperand(3).getImm());
8737 assert(
false &&
"Invalid FMA instruction kind \n");
8751 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8752 Opc = AArch64::FNMADDSrrr;
8753 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8754 Opc = AArch64::FNMADDDrrr;
8788 unsigned IdxDupOp,
unsigned MulOpc,
8790 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8791 "Invalid index of FMUL operand");
8799 if (Dup->
getOpcode() == TargetOpcode::COPY)
8808 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8849 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8864 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8891 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8919 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8921 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8925 Register SrcReg0 = MUL->getOperand(1).getReg();
8926 bool Src0IsKill = MUL->getOperand(1).isKill();
8927 Register SrcReg1 = MUL->getOperand(2).getReg();
8928 bool Src1IsKill = MUL->getOperand(2).isKill();
8958 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8959 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8973 if (Opcode == AArch64::SUBSWrr)
8974 Opcode = AArch64::SUBWrr;
8975 else if (Opcode == AArch64::SUBSXrr)
8976 Opcode = AArch64::SUBXrr;
8978 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
8979 "Unexpected instruction opcode.");
8996 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9003unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9004 unsigned int AccumulatorOpCode)
const {
9005 switch (AccumulatorOpCode) {
9006 case AArch64::UABALB_ZZZ_D:
9007 case AArch64::SABALB_ZZZ_D:
9008 case AArch64::UABALT_ZZZ_D:
9009 case AArch64::SABALT_ZZZ_D:
9010 return AArch64::ADD_ZZZ_D;
9011 case AArch64::UABALB_ZZZ_H:
9012 case AArch64::SABALB_ZZZ_H:
9013 case AArch64::UABALT_ZZZ_H:
9014 case AArch64::SABALT_ZZZ_H:
9015 return AArch64::ADD_ZZZ_H;
9016 case AArch64::UABALB_ZZZ_S:
9017 case AArch64::SABALB_ZZZ_S:
9018 case AArch64::UABALT_ZZZ_S:
9019 case AArch64::SABALT_ZZZ_S:
9020 return AArch64::ADD_ZZZ_S;
9021 case AArch64::UABALv16i8_v8i16:
9022 case AArch64::SABALv8i8_v8i16:
9023 case AArch64::SABAv8i16:
9024 case AArch64::UABAv8i16:
9025 return AArch64::ADDv8i16;
9026 case AArch64::SABALv2i32_v2i64:
9027 case AArch64::UABALv2i32_v2i64:
9028 case AArch64::SABALv4i32_v2i64:
9029 return AArch64::ADDv2i64;
9030 case AArch64::UABALv4i16_v4i32:
9031 case AArch64::SABALv4i16_v4i32:
9032 case AArch64::SABALv8i16_v4i32:
9033 case AArch64::SABAv4i32:
9034 case AArch64::UABAv4i32:
9035 return AArch64::ADDv4i32;
9036 case AArch64::UABALv4i32_v2i64:
9037 return AArch64::ADDv2i64;
9038 case AArch64::UABALv8i16_v4i32:
9039 return AArch64::ADDv4i32;
9040 case AArch64::UABALv8i8_v8i16:
9041 case AArch64::SABALv16i8_v8i16:
9042 return AArch64::ADDv8i16;
9043 case AArch64::UABAv16i8:
9044 case AArch64::SABAv16i8:
9045 return AArch64::ADDv16i8;
9046 case AArch64::UABAv4i16:
9047 case AArch64::SABAv4i16:
9048 return AArch64::ADDv4i16;
9049 case AArch64::UABAv2i32:
9050 case AArch64::SABAv2i32:
9051 return AArch64::ADDv2i32;
9052 case AArch64::UABAv8i8:
9053 case AArch64::SABAv8i8:
9054 return AArch64::ADDv8i8;
9063void AArch64InstrInfo::genAlternativeCodeSequence(
9073 MachineInstr *
MUL =
nullptr;
9080 DelInstrs, InstrIdxForVirtReg);
9086 InstrIdxForVirtReg);
9092 InstrIdxForVirtReg);
9101 Opc = AArch64::MADDWrrr;
9102 RC = &AArch64::GPR32RegClass;
9104 Opc = AArch64::MADDXrrr;
9105 RC = &AArch64::GPR64RegClass;
9116 Opc = AArch64::MADDWrrr;
9117 RC = &AArch64::GPR32RegClass;
9119 Opc = AArch64::MADDXrrr;
9120 RC = &AArch64::GPR64RegClass;
9134 unsigned BitSize, MovImm;
9137 MovImm = AArch64::MOVi32imm;
9138 RC = &AArch64::GPR32spRegClass;
9140 Opc = AArch64::MADDWrrr;
9141 RC = &AArch64::GPR32RegClass;
9143 MovImm = AArch64::MOVi64imm;
9144 RC = &AArch64::GPR64spRegClass;
9146 Opc = AArch64::MADDXrrr;
9147 RC = &AArch64::GPR64RegClass;
9158 uint64_t UImm =
SignExtend64(IsSub ? -Imm : Imm, BitSize);
9162 if (Insn.
size() != 1)
9164 MachineInstrBuilder MIB1 =
9165 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9166 .
addImm(IsSub ? -Imm : Imm);
9168 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9180 unsigned SubOpc, ZeroReg;
9182 SubOpc = AArch64::SUBWrr;
9183 SubRC = &AArch64::GPR32spRegClass;
9184 ZeroReg = AArch64::WZR;
9185 Opc = AArch64::MADDWrrr;
9186 RC = &AArch64::GPR32RegClass;
9188 SubOpc = AArch64::SUBXrr;
9189 SubRC = &AArch64::GPR64spRegClass;
9190 ZeroReg = AArch64::XZR;
9191 Opc = AArch64::MADDXrrr;
9192 RC = &AArch64::GPR64RegClass;
9196 MachineInstrBuilder MIB1 =
9197 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9201 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9212 Opc = AArch64::MSUBWrrr;
9213 RC = &AArch64::GPR32RegClass;
9215 Opc = AArch64::MSUBXrrr;
9216 RC = &AArch64::GPR64RegClass;
9221 Opc = AArch64::MLAv8i8;
9222 RC = &AArch64::FPR64RegClass;
9226 Opc = AArch64::MLAv8i8;
9227 RC = &AArch64::FPR64RegClass;
9231 Opc = AArch64::MLAv16i8;
9232 RC = &AArch64::FPR128RegClass;
9236 Opc = AArch64::MLAv16i8;
9237 RC = &AArch64::FPR128RegClass;
9241 Opc = AArch64::MLAv4i16;
9242 RC = &AArch64::FPR64RegClass;
9246 Opc = AArch64::MLAv4i16;
9247 RC = &AArch64::FPR64RegClass;
9251 Opc = AArch64::MLAv8i16;
9252 RC = &AArch64::FPR128RegClass;
9256 Opc = AArch64::MLAv8i16;
9257 RC = &AArch64::FPR128RegClass;
9261 Opc = AArch64::MLAv2i32;
9262 RC = &AArch64::FPR64RegClass;
9266 Opc = AArch64::MLAv2i32;
9267 RC = &AArch64::FPR64RegClass;
9271 Opc = AArch64::MLAv4i32;
9272 RC = &AArch64::FPR128RegClass;
9276 Opc = AArch64::MLAv4i32;
9277 RC = &AArch64::FPR128RegClass;
9282 Opc = AArch64::MLAv8i8;
9283 RC = &AArch64::FPR64RegClass;
9285 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9289 Opc = AArch64::MLSv8i8;
9290 RC = &AArch64::FPR64RegClass;
9294 Opc = AArch64::MLAv16i8;
9295 RC = &AArch64::FPR128RegClass;
9297 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9301 Opc = AArch64::MLSv16i8;
9302 RC = &AArch64::FPR128RegClass;
9306 Opc = AArch64::MLAv4i16;
9307 RC = &AArch64::FPR64RegClass;
9309 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9313 Opc = AArch64::MLSv4i16;
9314 RC = &AArch64::FPR64RegClass;
9318 Opc = AArch64::MLAv8i16;
9319 RC = &AArch64::FPR128RegClass;
9321 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9325 Opc = AArch64::MLSv8i16;
9326 RC = &AArch64::FPR128RegClass;
9330 Opc = AArch64::MLAv2i32;
9331 RC = &AArch64::FPR64RegClass;
9333 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9337 Opc = AArch64::MLSv2i32;
9338 RC = &AArch64::FPR64RegClass;
9342 Opc = AArch64::MLAv4i32;
9343 RC = &AArch64::FPR128RegClass;
9345 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9349 Opc = AArch64::MLSv4i32;
9350 RC = &AArch64::FPR128RegClass;
9355 Opc = AArch64::MLAv4i16_indexed;
9356 RC = &AArch64::FPR64RegClass;
9360 Opc = AArch64::MLAv4i16_indexed;
9361 RC = &AArch64::FPR64RegClass;
9365 Opc = AArch64::MLAv8i16_indexed;
9366 RC = &AArch64::FPR128RegClass;
9370 Opc = AArch64::MLAv8i16_indexed;
9371 RC = &AArch64::FPR128RegClass;
9375 Opc = AArch64::MLAv2i32_indexed;
9376 RC = &AArch64::FPR64RegClass;
9380 Opc = AArch64::MLAv2i32_indexed;
9381 RC = &AArch64::FPR64RegClass;
9385 Opc = AArch64::MLAv4i32_indexed;
9386 RC = &AArch64::FPR128RegClass;
9390 Opc = AArch64::MLAv4i32_indexed;
9391 RC = &AArch64::FPR128RegClass;
9396 Opc = AArch64::MLAv4i16_indexed;
9397 RC = &AArch64::FPR64RegClass;
9399 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9403 Opc = AArch64::MLSv4i16_indexed;
9404 RC = &AArch64::FPR64RegClass;
9408 Opc = AArch64::MLAv8i16_indexed;
9409 RC = &AArch64::FPR128RegClass;
9411 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9415 Opc = AArch64::MLSv8i16_indexed;
9416 RC = &AArch64::FPR128RegClass;
9420 Opc = AArch64::MLAv2i32_indexed;
9421 RC = &AArch64::FPR64RegClass;
9423 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9427 Opc = AArch64::MLSv2i32_indexed;
9428 RC = &AArch64::FPR64RegClass;
9432 Opc = AArch64::MLAv4i32_indexed;
9433 RC = &AArch64::FPR128RegClass;
9435 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9439 Opc = AArch64::MLSv4i32_indexed;
9440 RC = &AArch64::FPR128RegClass;
9446 Opc = AArch64::FMADDHrrr;
9447 RC = &AArch64::FPR16RegClass;
9451 Opc = AArch64::FMADDSrrr;
9452 RC = &AArch64::FPR32RegClass;
9456 Opc = AArch64::FMADDDrrr;
9457 RC = &AArch64::FPR64RegClass;
9462 Opc = AArch64::FMADDHrrr;
9463 RC = &AArch64::FPR16RegClass;
9467 Opc = AArch64::FMADDSrrr;
9468 RC = &AArch64::FPR32RegClass;
9472 Opc = AArch64::FMADDDrrr;
9473 RC = &AArch64::FPR64RegClass;
9478 Opc = AArch64::FMLAv1i32_indexed;
9479 RC = &AArch64::FPR32RegClass;
9484 Opc = AArch64::FMLAv1i32_indexed;
9485 RC = &AArch64::FPR32RegClass;
9491 Opc = AArch64::FMLAv1i64_indexed;
9492 RC = &AArch64::FPR64RegClass;
9497 Opc = AArch64::FMLAv1i64_indexed;
9498 RC = &AArch64::FPR64RegClass;
9504 RC = &AArch64::FPR64RegClass;
9505 Opc = AArch64::FMLAv4i16_indexed;
9510 RC = &AArch64::FPR64RegClass;
9511 Opc = AArch64::FMLAv4f16;
9516 RC = &AArch64::FPR64RegClass;
9517 Opc = AArch64::FMLAv4i16_indexed;
9522 RC = &AArch64::FPR64RegClass;
9523 Opc = AArch64::FMLAv4f16;
9530 RC = &AArch64::FPR64RegClass;
9532 Opc = AArch64::FMLAv2i32_indexed;
9536 Opc = AArch64::FMLAv2f32;
9543 RC = &AArch64::FPR64RegClass;
9545 Opc = AArch64::FMLAv2i32_indexed;
9549 Opc = AArch64::FMLAv2f32;
9556 RC = &AArch64::FPR128RegClass;
9557 Opc = AArch64::FMLAv8i16_indexed;
9562 RC = &AArch64::FPR128RegClass;
9563 Opc = AArch64::FMLAv8f16;
9568 RC = &AArch64::FPR128RegClass;
9569 Opc = AArch64::FMLAv8i16_indexed;
9574 RC = &AArch64::FPR128RegClass;
9575 Opc = AArch64::FMLAv8f16;
9582 RC = &AArch64::FPR128RegClass;
9584 Opc = AArch64::FMLAv2i64_indexed;
9588 Opc = AArch64::FMLAv2f64;
9595 RC = &AArch64::FPR128RegClass;
9597 Opc = AArch64::FMLAv2i64_indexed;
9601 Opc = AArch64::FMLAv2f64;
9609 RC = &AArch64::FPR128RegClass;
9611 Opc = AArch64::FMLAv4i32_indexed;
9615 Opc = AArch64::FMLAv4f32;
9623 RC = &AArch64::FPR128RegClass;
9625 Opc = AArch64::FMLAv4i32_indexed;
9629 Opc = AArch64::FMLAv4f32;
9636 Opc = AArch64::FNMSUBHrrr;
9637 RC = &AArch64::FPR16RegClass;
9641 Opc = AArch64::FNMSUBSrrr;
9642 RC = &AArch64::FPR32RegClass;
9646 Opc = AArch64::FNMSUBDrrr;
9647 RC = &AArch64::FPR64RegClass;
9652 Opc = AArch64::FNMADDHrrr;
9653 RC = &AArch64::FPR16RegClass;
9657 Opc = AArch64::FNMADDSrrr;
9658 RC = &AArch64::FPR32RegClass;
9662 Opc = AArch64::FNMADDDrrr;
9663 RC = &AArch64::FPR64RegClass;
9668 Opc = AArch64::FMSUBHrrr;
9669 RC = &AArch64::FPR16RegClass;
9673 Opc = AArch64::FMSUBSrrr;
9674 RC = &AArch64::FPR32RegClass;
9678 Opc = AArch64::FMSUBDrrr;
9679 RC = &AArch64::FPR64RegClass;
9684 Opc = AArch64::FMLSv1i32_indexed;
9685 RC = &AArch64::FPR32RegClass;
9691 Opc = AArch64::FMLSv1i64_indexed;
9692 RC = &AArch64::FPR64RegClass;
9699 RC = &AArch64::FPR64RegClass;
9701 MachineInstrBuilder MIB1 =
9702 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9705 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9707 Opc = AArch64::FMLAv4f16;
9711 Opc = AArch64::FMLAv4i16_indexed;
9718 RC = &AArch64::FPR64RegClass;
9719 Opc = AArch64::FMLSv4f16;
9724 RC = &AArch64::FPR64RegClass;
9725 Opc = AArch64::FMLSv4i16_indexed;
9732 RC = &AArch64::FPR64RegClass;
9734 Opc = AArch64::FMLSv2i32_indexed;
9738 Opc = AArch64::FMLSv2f32;
9746 RC = &AArch64::FPR128RegClass;
9748 MachineInstrBuilder MIB1 =
9749 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9752 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9754 Opc = AArch64::FMLAv8f16;
9758 Opc = AArch64::FMLAv8i16_indexed;
9765 RC = &AArch64::FPR128RegClass;
9766 Opc = AArch64::FMLSv8f16;
9771 RC = &AArch64::FPR128RegClass;
9772 Opc = AArch64::FMLSv8i16_indexed;
9779 RC = &AArch64::FPR128RegClass;
9781 Opc = AArch64::FMLSv2i64_indexed;
9785 Opc = AArch64::FMLSv2f64;
9793 RC = &AArch64::FPR128RegClass;
9795 Opc = AArch64::FMLSv4i32_indexed;
9799 Opc = AArch64::FMLSv4f32;
9806 RC = &AArch64::FPR64RegClass;
9808 MachineInstrBuilder MIB1 =
9809 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9812 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9814 Opc = AArch64::FMLAv2i32_indexed;
9818 Opc = AArch64::FMLAv2f32;
9826 RC = &AArch64::FPR128RegClass;
9828 MachineInstrBuilder MIB1 =
9829 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9832 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9834 Opc = AArch64::FMLAv4i32_indexed;
9838 Opc = AArch64::FMLAv4f32;
9846 RC = &AArch64::FPR128RegClass;
9848 MachineInstrBuilder MIB1 =
9849 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9852 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9854 Opc = AArch64::FMLAv2i64_indexed;
9858 Opc = AArch64::FMLAv2f64;
9870 &AArch64::FPR128RegClass, MRI);
9879 &AArch64::FPR128RegClass, MRI);
9888 &AArch64::FPR128_loRegClass, MRI);
9897 &AArch64::FPR128RegClass, MRI);
9906 &AArch64::FPR128_loRegClass, MRI);
9940 for (
auto *
MI : InsInstrs)
9941 MI->setFlags(Flags);
9982 bool IsNegativeBranch =
false;
9983 bool IsTestAndBranch =
false;
9984 unsigned TargetBBInMI = 0;
9985 switch (
MI.getOpcode()) {
9989 case AArch64::CBWPri:
9990 case AArch64::CBXPri:
9991 case AArch64::CBBAssertExt:
9992 case AArch64::CBHAssertExt:
9993 case AArch64::CBWPrr:
9994 case AArch64::CBXPrr:
10000 case AArch64::CBNZW:
10001 case AArch64::CBNZX:
10003 IsNegativeBranch =
true;
10005 case AArch64::TBZW:
10006 case AArch64::TBZX:
10008 IsTestAndBranch =
true;
10010 case AArch64::TBNZW:
10011 case AArch64::TBNZX:
10013 IsNegativeBranch =
true;
10014 IsTestAndBranch =
true;
10020 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10024 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10035 while (
DefMI->isCopy()) {
10044 switch (
DefMI->getOpcode()) {
10048 case AArch64::ANDWri:
10049 case AArch64::ANDXri: {
10050 if (IsTestAndBranch)
10057 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10059 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10073 unsigned Imm =
Log2_64(Mask);
10074 unsigned Opc = (Imm < 32)
10075 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10076 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10089 if (!Is32Bit && Imm < 32)
10091 MI.eraseFromParent();
10095 case AArch64::CSINCWr:
10096 case AArch64::CSINCXr: {
10097 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10098 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10099 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10100 DefMI->getOperand(2).getReg() == AArch64::XZR))
10103 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10116 if (IsNegativeBranch)
10119 MI.eraseFromParent();
10125std::pair<unsigned, unsigned>
10126AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10128 return std::make_pair(TF & Mask, TF & ~Mask);
10132AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10135 static const std::pair<unsigned, const char *> TargetFlags[] = {
10136 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10137 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10138 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10144AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10145 using namespace AArch64II;
10147 static const std::pair<unsigned, const char *> TargetFlags[] = {
10149 {
MO_GOT,
"aarch64-got"},
10150 {
MO_NC,
"aarch64-nc"},
10151 {
MO_S,
"aarch64-s"},
10152 {
MO_TLS,
"aarch64-tls"},
10162AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10163 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10265 MachineFunction *MF =
C.getMF();
10267 const AArch64RegisterInfo *ARI =
10268 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10271 for (
unsigned Reg : AArch64::GPR64RegClass) {
10273 Reg != AArch64::LR &&
10274 Reg != AArch64::X16 &&
10275 Reg != AArch64::X17 &&
10276 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10277 C.isAvailableInsideSeq(
Reg,
TRI))
10308 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10311std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10312AArch64InstrInfo::getOutliningCandidateInfo(
10314 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10315 unsigned MinRepeats)
const {
10316 unsigned SequenceSize = 0;
10317 for (
auto &
MI : RepeatedSequenceLocs[0])
10320 unsigned NumBytesToCreateFrame = 0;
10326 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10327 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10328 if (LastMI.
getOpcode() == AArch64::ADRP &&
10331 return std::nullopt;
10336 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10337 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10340 return std::nullopt;
10351 if (std::adjacent_find(
10352 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10353 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10356 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10357 outliningCandidatesSigningKeyConsensus(a, b) &&
10358 outliningCandidatesV8_3OpsConsensus(a, b)) {
10362 }) != RepeatedSequenceLocs.end()) {
10363 return std::nullopt;
10380 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10381 const auto RASignCondition = RepeatedSequenceLocs[0]
10384 ->getSignReturnAddressCondition();
10387 NumBytesToCreateFrame += 8;
10390 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10391 *RepeatedSequenceLocs[0].getMF());
10392 NumBytesToCheckLRInTCEpilogue =
10396 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10397 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10405 for (
auto &
MI :
C) {
10406 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10407 switch (
MI.getOpcode()) {
10408 case AArch64::ADDXri:
10409 case AArch64::ADDWri:
10410 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10411 assert(
MI.getOperand(2).isImm() &&
10412 "Expected operand to be immediate");
10413 assert(
MI.getOperand(1).isReg() &&
10414 "Expected operand to be a register");
10418 if (
MI.getOperand(1).getReg() == AArch64::SP)
10419 SPValue +=
MI.getOperand(2).getImm();
10423 case AArch64::SUBXri:
10424 case AArch64::SUBWri:
10425 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10426 assert(
MI.getOperand(2).isImm() &&
10427 "Expected operand to be immediate");
10428 assert(
MI.getOperand(1).isReg() &&
10429 "Expected operand to be a register");
10433 if (
MI.getOperand(1).getReg() == AArch64::SP)
10434 SPValue -=
MI.getOperand(2).getImm();
10451 if (RepeatedSequenceLocs.size() < MinRepeats)
10452 return std::nullopt;
10456 unsigned FlagsSetInAll = 0xF;
10460 FlagsSetInAll &=
C.Flags;
10462 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10465 auto SetCandidateCallInfo =
10466 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10468 C.setCallInfo(CallID, NumBytesForCall);
10472 NumBytesToCreateFrame += 4;
10480 unsigned CFICount = 0;
10481 for (
auto &
I : RepeatedSequenceLocs[0]) {
10482 if (
I.isCFIInstruction())
10492 std::vector<MCCFIInstruction> CFIInstructions =
10493 C.getMF()->getFrameInstructions();
10495 if (CFICount > 0 && CFICount != CFIInstructions.size())
10496 return std::nullopt;
10504 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10505 !
MI.readsRegister(AArch64::SP, &
TRI))
10511 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10516 if (
MI.mayLoadOrStore()) {
10519 bool OffsetIsScalable;
10523 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10524 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10528 if (OffsetIsScalable)
10536 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10537 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10540 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10541 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10556 bool AllStackInstrsSafe =
10561 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10563 NumBytesToCreateFrame = 0;
10564 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10568 else if (LastInstrOpcode == AArch64::BL ||
10569 ((LastInstrOpcode == AArch64::BLR ||
10570 LastInstrOpcode == AArch64::BLRNoIP) &&
10574 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10582 unsigned NumBytesNoStackCalls = 0;
10583 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10589 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10598 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10601 if (LRAvailable && !IsNoReturn) {
10602 NumBytesNoStackCalls += 4;
10604 CandidatesWithoutStackFixups.push_back(
C);
10609 else if (findRegisterToSaveLRTo(
C)) {
10610 NumBytesNoStackCalls += 12;
10612 CandidatesWithoutStackFixups.push_back(
C);
10617 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10618 NumBytesNoStackCalls += 12;
10620 CandidatesWithoutStackFixups.push_back(
C);
10626 NumBytesNoStackCalls += SequenceSize;
10633 if (!AllStackInstrsSafe ||
10634 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10635 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10637 if (RepeatedSequenceLocs.size() < MinRepeats)
10638 return std::nullopt;
10691 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10692 !findRegisterToSaveLRTo(
C));
10698 if (RepeatedSequenceLocs.size() < MinRepeats)
10699 return std::nullopt;
10708 bool ModStackToSaveLR =
false;
10711 ModStackToSaveLR =
true;
10720 ModStackToSaveLR =
true;
10722 if (ModStackToSaveLR) {
10724 if (!AllStackInstrsSafe)
10725 return std::nullopt;
10728 NumBytesToCreateFrame += 8;
10735 return std::nullopt;
10737 return std::make_unique<outliner::OutlinedFunction>(
10738 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10741void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10742 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10746 const auto &CFn = Candidates.front().getMF()->getFunction();
10748 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10749 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10750 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10751 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10754 if (CFn.hasFnAttribute(
"sign-return-address"))
10755 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10756 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10757 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10759 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10762bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10767 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10774 if (
F.hasSection())
10780 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10781 if (!AFI || AFI->
hasRedZone().value_or(
true))
10801 unsigned &Flags)
const {
10803 "Must track liveness!");
10805 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10820 auto AreAllUnsafeRegsDead = [&LRU]() {
10821 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10822 LRU.available(AArch64::NZCV);
10837 bool LRAvailableEverywhere =
true;
10839 LRU.addLiveOuts(
MBB);
10841 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10842 if (
MI.isCall() && !
MI.isTerminator())
10848 auto CreateNewRangeStartingAt =
10849 [&RangeBegin, &RangeEnd,
10851 RangeBegin = NewBegin;
10852 RangeEnd = std::next(RangeBegin);
10855 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
10861 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10863 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10865 Ranges.emplace_back(RangeBegin, RangeEnd);
10873 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10874 if (!FirstPossibleEndPt->isDebugInstr())
10875 LRU.stepBackward(*FirstPossibleEndPt);
10878 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10879 if (AreAllUnsafeRegsDead())
10886 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10891 if (!
MI.isDebugInstr())
10892 LRU.stepBackward(
MI);
10893 UpdateWholeMBBFlags(
MI);
10894 if (!AreAllUnsafeRegsDead()) {
10895 SaveRangeIfNonEmpty();
10896 CreateNewRangeStartingAt(
MI.getIterator());
10899 LRAvailableEverywhere &= LRU.available(AArch64::LR);
10900 RangeBegin =
MI.getIterator();
10905 if (AreAllUnsafeRegsDead())
10906 SaveRangeIfNonEmpty();
10914 if (!LRAvailableEverywhere)
10922 unsigned Flags)
const {
10923 MachineInstr &
MI = *MIT;
10927 switch (
MI.getOpcode()) {
10928 case AArch64::PACM:
10929 case AArch64::PACIASP:
10930 case AArch64::PACIBSP:
10931 case AArch64::PACIASPPC:
10932 case AArch64::PACIBSPPC:
10933 case AArch64::AUTIASP:
10934 case AArch64::AUTIBSP:
10935 case AArch64::AUTIASPPCi:
10936 case AArch64::AUTIASPPCr:
10937 case AArch64::AUTIBSPPCi:
10938 case AArch64::AUTIBSPPCr:
10939 case AArch64::RETAA:
10940 case AArch64::RETAB:
10941 case AArch64::RETAASPPCi:
10942 case AArch64::RETAASPPCr:
10943 case AArch64::RETABSPPCi:
10944 case AArch64::RETABSPPCr:
10945 case AArch64::EMITBKEY:
10946 case AArch64::PAUTH_PROLOGUE:
10947 case AArch64::PAUTH_EPILOGUE:
10957 if (
MI.isCFIInstruction())
10961 if (
MI.isTerminator())
10967 for (
const MachineOperand &MOP :
MI.operands()) {
10970 assert(!MOP.isCFIIndex());
10973 if (MOP.isReg() && !MOP.isImplicit() &&
10974 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
10981 if (
MI.getOpcode() == AArch64::ADRP)
11001 for (
const MachineOperand &MOP :
MI.operands()) {
11002 if (MOP.isGlobal()) {
11010 if (Callee &&
Callee->getName() ==
"\01_mcount")
11018 if (
MI.getOpcode() == AArch64::BLR ||
11019 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11023 return UnknownCallOutlineType;
11031 return UnknownCallOutlineType;
11039 return UnknownCallOutlineType;
11060 for (MachineInstr &
MI :
MBB) {
11061 const MachineOperand *
Base;
11062 TypeSize Width(0,
false);
11064 bool OffsetIsScalable;
11067 if (!
MI.mayLoadOrStore() ||
11070 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11074 TypeSize Scale(0U,
false);
11075 int64_t Dummy1, Dummy2;
11078 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11080 assert(Scale != 0 &&
"Unexpected opcode!");
11081 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11086 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11087 StackOffsetOperand.
setImm(NewImm);
11093 bool ShouldSignReturnAddr) {
11094 if (!ShouldSignReturnAddr)
11102void AArch64InstrInfo::buildOutlinedFrame(
11106 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11114 unsigned TailOpcode;
11116 TailOpcode = AArch64::TCRETURNdi;
11120 TailOpcode = AArch64::TCRETURNriALL;
11131 bool IsLeafFunction =
true;
11134 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11135 return MI.isCall() && !
MI.isReturn();
11145 "Can only fix up stack references once");
11146 fixupPostOutline(
MBB);
11148 IsLeafFunction =
false;
11159 Et = std::prev(
MBB.
end());
11169 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11173 CFIBuilder.buildDefCFAOffset(16);
11177 CFIBuilder.buildOffset(AArch64::LR, -16);
11191 RASignCondition, !IsLeafFunction);
11220 fixupPostOutline(
MBB);
11231 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11241 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11250 MachineInstr *Save;
11251 MachineInstr *Restore;
11257 assert(
Reg &&
"No callee-saved register available?");
11291 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11299bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11307 bool AllowSideEffects)
const {
11309 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11312 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11325 assert(STI.hasNEON() &&
"Expected to have NEON.");
11331std::optional<DestSourcePair>
11336 if (((
MI.getOpcode() == AArch64::ORRWrs &&
11337 MI.getOperand(1).getReg() == AArch64::WZR &&
11338 MI.getOperand(3).getImm() == 0x0) ||
11339 (
MI.getOpcode() == AArch64::ORRWrr &&
11340 MI.getOperand(1).getReg() == AArch64::WZR)) &&
11342 (!
MI.getOperand(0).getReg().isVirtual() ||
11343 MI.getOperand(0).getSubReg() == 0) &&
11344 (!
MI.getOperand(0).getReg().isPhysical() ||
11349 if (
MI.getOpcode() == AArch64::ORRXrs &&
11350 MI.getOperand(1).getReg() == AArch64::XZR &&
11351 MI.getOperand(3).getImm() == 0x0)
11354 return std::nullopt;
11357std::optional<DestSourcePair>
11359 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11360 MI.getOperand(1).getReg() == AArch64::WZR &&
11361 MI.getOperand(3).getImm() == 0x0) ||
11362 (
MI.getOpcode() == AArch64::ORRWrr &&
11363 MI.getOperand(1).getReg() == AArch64::WZR))
11365 return std::nullopt;
11368std::optional<RegImmPair>
11377 return std::nullopt;
11379 switch (
MI.getOpcode()) {
11381 return std::nullopt;
11382 case AArch64::SUBWri:
11383 case AArch64::SUBXri:
11384 case AArch64::SUBSWri:
11385 case AArch64::SUBSXri:
11388 case AArch64::ADDSWri:
11389 case AArch64::ADDSXri:
11390 case AArch64::ADDWri:
11391 case AArch64::ADDXri: {
11393 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11394 !
MI.getOperand(2).isImm())
11395 return std::nullopt;
11396 int Shift =
MI.getOperand(3).getImm();
11397 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11401 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11407static std::optional<ParamLoadedValue>
11411 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11413 return std::nullopt;
11415 Register DestReg = DestSrc->Destination->getReg();
11416 Register SrcReg = DestSrc->Source->getReg();
11419 return std::nullopt;
11424 if (DestReg == DescribedReg)
11428 if (
MI.getOpcode() == AArch64::ORRWrs &&
11429 TRI->isSuperRegister(DestReg, DescribedReg))
11433 if (
MI.getOpcode() == AArch64::ORRXrs &&
11434 TRI->isSubRegister(DestReg, DescribedReg)) {
11435 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11439 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11440 "Unhandled ORR[XW]rs copy case");
11442 return std::nullopt;
11445bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11450 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11456bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11460 auto isAsmGoto = [](
const MachineInstr &
MI) {
11461 return MI.getOpcode() == AArch64::INLINEASM_BR;
11471 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11478 for (
const MachineInstr &
MI :
MBB) {
11479 switch (
MI.getOpcode()) {
11480 case TargetOpcode::G_BRJT:
11481 case AArch64::JumpTableDest32:
11482 case AArch64::JumpTableDest16:
11483 case AArch64::JumpTableDest8:
11494std::optional<ParamLoadedValue>
11497 const MachineFunction *MF =
MI.getMF();
11499 switch (
MI.getOpcode()) {
11500 case AArch64::MOVZWi:
11501 case AArch64::MOVZXi: {
11504 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11505 return std::nullopt;
11507 if (!
MI.getOperand(1).isImm())
11508 return std::nullopt;
11509 int64_t Immediate =
MI.getOperand(1).getImm();
11510 int Shift =
MI.getOperand(2).getImm();
11514 case AArch64::ORRWrs:
11515 case AArch64::ORRXrs:
11522bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11525 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11526 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11529 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11539 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11542uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11546bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11550bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11555AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11559bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11560 unsigned Scale)
const {
11571 unsigned Shift =
Log2_64(NumBytes);
11572 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11580 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11585 return AArch64::BLRNoIP;
11587 return AArch64::BLR;
11593 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11603 if (Subtarget.hasPAuthLR())
11614 Register TargetReg,
bool FrameSetup)
const {
11615 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11627 MF.
insert(MBBInsertPoint, LoopTestMBB);
11630 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11632 MF.
insert(MBBInsertPoint, ExitMBB);
11642 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11650 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11656 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11673 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11692 MBB.addSuccessor(LoopTestMBB);
11698 return ExitMBB->
begin();
11703 MachineFunction *MF;
11704 const TargetInstrInfo *
TII;
11705 const TargetRegisterInfo *
TRI;
11706 MachineRegisterInfo &MRI;
11709 MachineBasicBlock *LoopBB;
11711 MachineInstr *CondBranch;
11713 MachineInstr *Comp;
11715 unsigned CompCounterOprNum;
11717 MachineInstr *Update;
11719 unsigned UpdateCounterOprNum;
11723 bool IsUpdatePriorComp;
11729 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11730 MachineInstr *Comp,
unsigned CompCounterOprNum,
11731 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11732 Register Init,
bool IsUpdatePriorComp,
11733 const SmallVectorImpl<MachineOperand> &
Cond)
11735 TII(MF->getSubtarget().getInstrInfo()),
11736 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11737 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11738 CompCounterOprNum(CompCounterOprNum), Update(Update),
11739 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11742 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11748 std::optional<bool> createTripCountGreaterCondition(
11749 int TC, MachineBasicBlock &
MBB,
11750 SmallVectorImpl<MachineOperand> &CondParam)
override {
11758 void createRemainingIterationsGreaterCondition(
11759 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11760 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11762 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11764 void adjustTripCount(
int TripCountAdjust)
override {}
11766 bool isMVEExpanderSupported()
override {
return true; }
11785 }
else if (
I == ReplaceOprNum) {
11790 MBB.insert(InsertTo, NewMI);
11794void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
11810 assert(CondBranch->getOpcode() == AArch64::Bcc);
11814 if (CondBranch->getOperand(1).getMBB() == LoopBB)
11821 auto AccumulateCond = [&](
Register CurCond,
11832 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
11836 for (
int I = 0;
I <= TC; ++
I) {
11842 AccCond = AccumulateCond(AccCond, CC);
11846 if (Update != Comp && IsUpdatePriorComp) {
11848 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11849 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11853 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11855 }
else if (Update != Comp) {
11860 Counter = NextCounter;
11864 if (LastStage0Insts.
empty()) {
11868 if (IsUpdatePriorComp)
11873 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11876 for (
int I = 0;
I <= TC; ++
I) {
11880 AccCond = AccumulateCond(AccCond, CC);
11881 if (
I != TC && Update != Comp)
11884 Counter = NextCounter;
11900 assert(Phi.getNumOperands() == 5);
11901 if (Phi.getOperand(2).getMBB() ==
MBB) {
11902 RegMBB = Phi.getOperand(1).getReg();
11903 RegOther = Phi.getOperand(3).getReg();
11905 assert(Phi.getOperand(4).getMBB() ==
MBB);
11906 RegMBB = Phi.getOperand(3).getReg();
11907 RegOther = Phi.getOperand(1).getReg();
11912 if (!
Reg.isVirtual())
11921 unsigned &UpdateCounterOprNum,
Register &InitReg,
11922 bool &IsUpdatePriorComp) {
11936 if (!
Reg.isVirtual())
11939 UpdateInst =
nullptr;
11940 UpdateCounterOprNum = 0;
11942 IsUpdatePriorComp =
true;
11946 if (Def->getParent() != LoopBB)
11948 if (Def->isCopy()) {
11950 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11952 CurReg = Def->getOperand(1).getReg();
11953 }
else if (Def->isPHI()) {
11957 IsUpdatePriorComp =
false;
11962 switch (Def->getOpcode()) {
11963 case AArch64::ADDSXri:
11964 case AArch64::ADDSWri:
11965 case AArch64::SUBSXri:
11966 case AArch64::SUBSWri:
11967 case AArch64::ADDXri:
11968 case AArch64::ADDWri:
11969 case AArch64::SUBXri:
11970 case AArch64::SUBWri:
11972 UpdateCounterOprNum = 1;
11974 case AArch64::ADDSXrr:
11975 case AArch64::ADDSWrr:
11976 case AArch64::SUBSXrr:
11977 case AArch64::SUBSWrr:
11978 case AArch64::ADDXrr:
11979 case AArch64::ADDWrr:
11980 case AArch64::SUBXrr:
11981 case AArch64::SUBWrr:
11984 UpdateCounterOprNum = 1;
11986 UpdateCounterOprNum = 2;
11993 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12008std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12019 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12030 if (
TBB == LoopBB && FBB == LoopBB)
12034 if (
TBB != LoopBB && FBB ==
nullptr)
12037 assert((
TBB == LoopBB || FBB == LoopBB) &&
12038 "The Loop must be a single-basic-block loop");
12043 if (CondBranch->
getOpcode() != AArch64::Bcc)
12051 unsigned CompCounterOprNum = 0;
12053 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12057 switch (
MI.getOpcode()) {
12058 case AArch64::SUBSXri:
12059 case AArch64::SUBSWri:
12060 case AArch64::ADDSXri:
12061 case AArch64::ADDSWri:
12063 CompCounterOprNum = 1;
12065 case AArch64::ADDSWrr:
12066 case AArch64::ADDSXrr:
12067 case AArch64::SUBSWrr:
12068 case AArch64::SUBSXrr:
12072 if (isWhileOpcode(
MI.getOpcode())) {
12079 if (CompCounterOprNum == 0) {
12081 CompCounterOprNum = 2;
12083 CompCounterOprNum = 1;
12095 bool IsUpdatePriorComp;
12096 unsigned UpdateCounterOprNum;
12098 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12101 return std::make_unique<AArch64PipelinerLoopInfo>(
12102 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12112 TypeSize Scale(0U,
false), Width(0U,
false);
12113 int64_t MinOffset, MaxOffset;
12114 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12116 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12117 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
12118 if (Imm < MinOffset || Imm > MaxOffset) {
12119 ErrInfo =
"Unexpected immediate on load/store instruction";
12125 const MCInstrDesc &MCID =
MI.getDesc();
12127 const MachineOperand &MO =
MI.getOperand(
Op);
12131 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12140 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12146 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12152 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12163#define GET_INSTRINFO_HELPERS
12164#define GET_INSTRMAP_INFO
12165#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...
bool branchTargetEnforcement() const
unsigned getArgumentStackToRestore() const
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.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
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
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,...
Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
Get the first element.
size_t size() const
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
bool hasSuperClassEq(const MCRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool hasSubClassEq(const MCRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
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()
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.
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.
const MCAsmInfo & getMCAsmInfo() const
Return target specific asm information.
CodeModel::Model getCodeModel() const
Returns the code model.
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...
constexpr bool isLegalArithImmed(const uint64_t C)
isLegalArithImmed -
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 expandMOVAddr(unsigned Opcode, unsigned TargetFlags, bool IsTargetMachO, SmallVectorImpl< AddrInsnModel > &Insn)
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 isLFIPrePostMemAccess(unsigned Opcode)
Returns true if Opcode is a pre- or post-indexed memory access that the LFI rewriter expands with a b...
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.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
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)
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)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
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.
MCRegisterClass TargetRegisterClass
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.