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)
143 case AArch64::BLRAAZ:
145 case AArch64::BLRABZ:
149 case AArch64::AUTIASP:
150 case AArch64::AUTIBSP:
151 case AArch64::AUTIAZ:
152 case AArch64::AUTIBZ:
153 case AArch64::XPACLRI:
158 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
159 MI.getOperand(3).getImm() == 1)
167 bool ModifiesLR =
false;
168 bool ModifiesSP =
false;
172 if (MO.getReg() == AArch64::LR)
174 else if (MO.getReg() == AArch64::SP)
183 if (
MI.mayLoadOrStore()) {
191 if (ModifiesSP || ModifiesLR)
209 auto Op =
MI.getOpcode();
210 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
211 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
215 if (
MI.isMetaInstruction())
220 unsigned NumBytes = 0;
230 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
233 if (!MFI->shouldSignReturnAddress(*MF))
236 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
244 switch (
Desc.getOpcode()) {
247 return Desc.getSize();
254 case TargetOpcode::STACKMAP:
257 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
259 case TargetOpcode::PATCHPOINT:
262 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
264 case TargetOpcode::STATEPOINT:
266 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
271 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
276 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
278 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
279 case TargetOpcode::PATCHABLE_TAIL_CALL:
280 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
284 case TargetOpcode::PATCHABLE_EVENT_CALL:
290 NumBytes =
MI.getOperand(1).getImm();
292 case AArch64::MOVaddr:
293 case AArch64::MOVaddrJT:
294 case AArch64::MOVaddrCP:
295 case AArch64::MOVaddrBA:
296 case AArch64::MOVaddrTLS:
297 case AArch64::MOVaddrEXT: {
301 MI.getOperand(1).getTargetFlags(),
302 Subtarget.isTargetMachO(), Insn);
303 NumBytes = Insn.
size() * 4;
307 case AArch64::MOVi32imm:
308 case AArch64::MOVi64imm: {
310 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
313 NumBytes = Insn.
size() * 4;
317 case TargetOpcode::BUNDLE:
318 NumBytes = getInstBundleSize(
MI);
354 case AArch64::CBWPri:
355 case AArch64::CBXPri:
356 case AArch64::CBWPrr:
357 case AArch64::CBXPrr:
365 case AArch64::CBBAssertExt:
366 case AArch64::CBHAssertExt:
397 case AArch64::CBWPri:
398 case AArch64::CBXPri:
399 case AArch64::CBBAssertExt:
400 case AArch64::CBHAssertExt:
401 case AArch64::CBWPrr:
402 case AArch64::CBXPrr:
408 int64_t BrOffset)
const {
410 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
411 "over conditional branch expansion");
412 return isIntN(Bits, BrOffset / 4);
417 switch (
MI.getOpcode()) {
421 return MI.getOperand(0).getMBB();
426 return MI.getOperand(2).getMBB();
432 return MI.getOperand(1).getMBB();
433 case AArch64::CBWPri:
434 case AArch64::CBXPri:
435 case AArch64::CBBAssertExt:
436 case AArch64::CBHAssertExt:
437 case AArch64::CBWPrr:
438 case AArch64::CBXPrr:
439 return MI.getOperand(3).getMBB();
449 assert(RS &&
"RegScavenger required for long branching");
451 "new block should be inserted for expanding unconditional branch");
454 "restore block should be inserted for restoring clobbered registers");
461 "Branch offsets outside of the signed 33-bit range not supported");
472 RS->enterBasicBlockEnd(
MBB);
475 constexpr Register Reg = AArch64::X16;
476 if (!RS->isRegUsed(Reg)) {
477 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
488 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
489 if (Scavenged != AArch64::NoRegister) {
490 buildIndirectBranch(Scavenged, NewDestBB);
491 RS->setRegUsed(Scavenged);
500 "Unable to insert indirect branch inside function that has red zone");
523 bool AllowModify)
const {
530 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
531 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
535 if (!isUnpredicatedTerminator(*
I))
542 unsigned LastOpc = LastInst->
getOpcode();
543 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
558 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
565 LastInst = SecondLastInst;
567 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
572 SecondLastInst = &*
I;
573 SecondLastOpc = SecondLastInst->
getOpcode();
584 LastInst = SecondLastInst;
586 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
588 "unreachable unconditional branches removed above");
597 SecondLastInst = &*
I;
598 SecondLastOpc = SecondLastInst->
getOpcode();
602 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
618 I->eraseFromParent();
627 I->eraseFromParent();
636 MachineBranchPredicate &MBP,
637 bool AllowModify)
const {
649 assert(MBP.TrueDest &&
"expected!");
650 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
652 MBP.ConditionDef =
nullptr;
653 MBP.SingleUseCondition =
false;
663 if (
I ==
MBB.begin())
679 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
680 MBP.ConditionDef = &
MI;
689 case AArch64::CBNZX: {
693 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
694 ? MachineBranchPredicate::PRED_NE
695 : MachineBranchPredicate::PRED_EQ;
696 Register CondReg = MBP.LHS.getReg();
705 case AArch64::TBNZX: {
726 Cond[1].setImm(AArch64::CBNZW);
729 Cond[1].setImm(AArch64::CBZW);
732 Cond[1].setImm(AArch64::CBNZX);
735 Cond[1].setImm(AArch64::CBZX);
738 Cond[1].setImm(AArch64::TBNZW);
741 Cond[1].setImm(AArch64::TBZW);
744 Cond[1].setImm(AArch64::TBNZX);
747 Cond[1].setImm(AArch64::TBZX);
751 case AArch64::CBWPri:
752 case AArch64::CBXPri:
753 case AArch64::CBBAssertExt:
754 case AArch64::CBHAssertExt:
755 case AArch64::CBWPrr:
756 case AArch64::CBXPrr: {
769 int *BytesRemoved)
const {
779 I->eraseFromParent();
783 if (
I ==
MBB.begin()) {
796 I->eraseFromParent();
803void AArch64InstrInfo::instantiateCondBranch(
828 if (
Cond.size() > 5) {
839 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
866 unsigned Opc =
MI.getOpcode();
873 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
874 MI.getOperand(0).getReg() == AArch64::XZR) {
876 dbgs() <<
"Removing always taken branch: " <<
MI);
879 for (
auto *S : Succs)
881 MBB->removeSuccessor(S);
883 while (
MBB->rbegin() != &
MI)
884 MBB->rbegin()->eraseFromParent();
885 MI.eraseFromParent();
895 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
896 MI.getOperand(0).getReg() == AArch64::XZR) {
898 dbgs() <<
"Removing never taken branch: " <<
MI);
900 MI.getParent()->removeSuccessor(
Target);
901 MI.eraseFromParent();
914 if (!
DefMI->isFullCopy())
916 VReg =
DefMI->getOperand(1).getReg();
925 unsigned *NewReg =
nullptr) {
930 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
934 switch (
DefMI->getOpcode()) {
935 case AArch64::SUBREG_TO_REG:
939 if (!
DefMI->getOperand(1).isReg())
941 if (!
DefMI->getOperand(2).isImm() ||
942 DefMI->getOperand(2).getImm() != AArch64::sub_32)
945 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
947 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
950 SrcReg = AArch64::XZR;
951 Opc = AArch64::CSINCXr;
954 case AArch64::MOVi32imm:
955 case AArch64::MOVi64imm:
956 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
958 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
959 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
962 case AArch64::ADDSXri:
963 case AArch64::ADDSWri:
965 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
970 case AArch64::ADDXri:
971 case AArch64::ADDWri:
973 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
974 DefMI->getOperand(3).getImm() != 0)
976 SrcReg =
DefMI->getOperand(1).getReg();
977 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
980 case AArch64::ORNXrr:
981 case AArch64::ORNWrr: {
984 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
986 SrcReg =
DefMI->getOperand(2).getReg();
987 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
991 case AArch64::SUBSXrr:
992 case AArch64::SUBSWrr:
994 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
999 case AArch64::SUBXrr:
1000 case AArch64::SUBWrr: {
1003 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1005 SrcReg =
DefMI->getOperand(2).getReg();
1006 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1012 assert(
Opc && SrcReg &&
"Missing parameters");
1022 Register FalseReg,
int &CondCycles,
1024 int &FalseCycles)
const {
1035 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1039 unsigned ExtraCondLat =
Cond.size() != 1;
1043 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1044 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1046 CondCycles = 1 + ExtraCondLat;
1047 TrueCycles = FalseCycles = 1;
1057 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1058 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1059 CondCycles = 5 + ExtraCondLat;
1060 TrueCycles = FalseCycles = 2;
1077 switch (
Cond.size()) {
1097 case AArch64::CBNZW:
1101 case AArch64::CBNZX:
1132 case AArch64::TBNZW:
1133 case AArch64::TBNZX:
1155 unsigned SubsOpc, SubsDestReg;
1161 case AArch64::CBWPri:
1162 SubsOpc = AArch64::SUBSWri;
1163 SubsDestReg = AArch64::WZR;
1166 case AArch64::CBXPri:
1167 SubsOpc = AArch64::SUBSXri;
1168 SubsDestReg = AArch64::XZR;
1171 case AArch64::CBWPrr:
1172 SubsOpc = AArch64::SUBSWrr;
1173 SubsDestReg = AArch64::WZR;
1176 case AArch64::CBXPrr:
1177 SubsOpc = AArch64::SUBSXrr;
1178 SubsDestReg = AArch64::XZR;
1207 switch (ExtendType) {
1213 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1214 ExtOpc = AArch64::SBFMWri;
1220 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1221 ExtOpc = AArch64::SBFMWri;
1227 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1228 ExtOpc = AArch64::ANDWri;
1234 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1235 ExtOpc = AArch64::ANDWri;
1244 if (ExtOpc != AArch64::ANDWri)
1246 MBBI.addImm(ExtBits);
1274 bool TryFold =
false;
1276 RC = &AArch64::GPR64RegClass;
1277 Opc = AArch64::CSELXr;
1280 RC = &AArch64::GPR32RegClass;
1281 Opc = AArch64::CSELWr;
1284 RC = &AArch64::FPR64RegClass;
1285 Opc = AArch64::FCSELDrrr;
1287 RC = &AArch64::FPR32RegClass;
1288 Opc = AArch64::FCSELSrrr;
1290 assert(RC &&
"Unsupported regclass");
1294 unsigned NewReg = 0;
1317 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1318 FalseReg == AArch64::XZR) &&
1319 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1336 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1341 return Is.
size() <= 2;
1346 assert(
MI.isCopy() &&
"Expected COPY instruction");
1352 if (
Reg.isVirtual())
1354 if (
Reg.isPhysical())
1355 return RI.getMinimalPhysRegClass(
Reg);
1360 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1363 return MI.isAsCheapAsAMove();
1369 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1370 if (isExynosCheapAsMove(
MI))
1372 return MI.isAsCheapAsAMove();
1375 switch (
MI.getOpcode()) {
1377 return MI.isAsCheapAsAMove();
1379 case TargetOpcode::COPY:
1382 case AArch64::ADDWrs:
1383 case AArch64::ADDXrs:
1384 case AArch64::SUBWrs:
1385 case AArch64::SUBXrs:
1386 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1391 case AArch64::MOVi32imm:
1393 case AArch64::MOVi64imm:
1398bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1399 switch (
MI.getOpcode()) {
1403 case AArch64::ADDWrs:
1404 case AArch64::ADDXrs:
1405 case AArch64::ADDSWrs:
1406 case AArch64::ADDSXrs: {
1407 unsigned Imm =
MI.getOperand(3).getImm();
1414 case AArch64::ADDWrx:
1415 case AArch64::ADDXrx:
1416 case AArch64::ADDXrx64:
1417 case AArch64::ADDSWrx:
1418 case AArch64::ADDSXrx:
1419 case AArch64::ADDSXrx64: {
1420 unsigned Imm =
MI.getOperand(3).getImm();
1432 case AArch64::SUBWrs:
1433 case AArch64::SUBSWrs: {
1434 unsigned Imm =
MI.getOperand(3).getImm();
1436 return ShiftVal == 0 ||
1440 case AArch64::SUBXrs:
1441 case AArch64::SUBSXrs: {
1442 unsigned Imm =
MI.getOperand(3).getImm();
1444 return ShiftVal == 0 ||
1448 case AArch64::SUBWrx:
1449 case AArch64::SUBXrx:
1450 case AArch64::SUBXrx64:
1451 case AArch64::SUBSWrx:
1452 case AArch64::SUBSXrx:
1453 case AArch64::SUBSXrx64: {
1454 unsigned Imm =
MI.getOperand(3).getImm();
1466 case AArch64::LDRBBroW:
1467 case AArch64::LDRBBroX:
1468 case AArch64::LDRBroW:
1469 case AArch64::LDRBroX:
1470 case AArch64::LDRDroW:
1471 case AArch64::LDRDroX:
1472 case AArch64::LDRHHroW:
1473 case AArch64::LDRHHroX:
1474 case AArch64::LDRHroW:
1475 case AArch64::LDRHroX:
1476 case AArch64::LDRQroW:
1477 case AArch64::LDRQroX:
1478 case AArch64::LDRSBWroW:
1479 case AArch64::LDRSBWroX:
1480 case AArch64::LDRSBXroW:
1481 case AArch64::LDRSBXroX:
1482 case AArch64::LDRSHWroW:
1483 case AArch64::LDRSHWroX:
1484 case AArch64::LDRSHXroW:
1485 case AArch64::LDRSHXroX:
1486 case AArch64::LDRSWroW:
1487 case AArch64::LDRSWroX:
1488 case AArch64::LDRSroW:
1489 case AArch64::LDRSroX:
1490 case AArch64::LDRWroW:
1491 case AArch64::LDRWroX:
1492 case AArch64::LDRXroW:
1493 case AArch64::LDRXroX:
1494 case AArch64::PRFMroW:
1495 case AArch64::PRFMroX:
1496 case AArch64::STRBBroW:
1497 case AArch64::STRBBroX:
1498 case AArch64::STRBroW:
1499 case AArch64::STRBroX:
1500 case AArch64::STRDroW:
1501 case AArch64::STRDroX:
1502 case AArch64::STRHHroW:
1503 case AArch64::STRHHroX:
1504 case AArch64::STRHroW:
1505 case AArch64::STRHroX:
1506 case AArch64::STRQroW:
1507 case AArch64::STRQroX:
1508 case AArch64::STRSroW:
1509 case AArch64::STRSroX:
1510 case AArch64::STRWroW:
1511 case AArch64::STRWroX:
1512 case AArch64::STRXroW:
1513 case AArch64::STRXroX: {
1514 unsigned IsSigned =
MI.getOperand(3).getImm();
1521 unsigned Opc =
MI.getOpcode();
1525 case AArch64::SEH_StackAlloc:
1526 case AArch64::SEH_SaveFPLR:
1527 case AArch64::SEH_SaveFPLR_X:
1528 case AArch64::SEH_SaveReg:
1529 case AArch64::SEH_SaveReg_X:
1530 case AArch64::SEH_SaveRegP:
1531 case AArch64::SEH_SaveRegP_X:
1532 case AArch64::SEH_SaveFReg:
1533 case AArch64::SEH_SaveFReg_X:
1534 case AArch64::SEH_SaveFRegP:
1535 case AArch64::SEH_SaveFRegP_X:
1536 case AArch64::SEH_SetFP:
1537 case AArch64::SEH_AddFP:
1538 case AArch64::SEH_Nop:
1539 case AArch64::SEH_PrologEnd:
1540 case AArch64::SEH_EpilogStart:
1541 case AArch64::SEH_EpilogEnd:
1542 case AArch64::SEH_PACSignLR:
1543 case AArch64::SEH_SaveAnyRegI:
1544 case AArch64::SEH_SaveAnyRegIP:
1545 case AArch64::SEH_SaveAnyRegQP:
1546 case AArch64::SEH_SaveAnyRegQPX:
1547 case AArch64::SEH_AllocZ:
1548 case AArch64::SEH_SaveZReg:
1549 case AArch64::SEH_SavePReg:
1556 unsigned &SubIdx)
const {
1557 switch (
MI.getOpcode()) {
1560 case AArch64::SBFMXri:
1561 case AArch64::UBFMXri:
1564 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1567 SrcReg =
MI.getOperand(1).getReg();
1568 DstReg =
MI.getOperand(0).getReg();
1569 SubIdx = AArch64::sub_32;
1578 int64_t OffsetA = 0, OffsetB = 0;
1579 TypeSize WidthA(0,
false), WidthB(0,
false);
1580 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1601 OffsetAIsScalable == OffsetBIsScalable) {
1602 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1603 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1604 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1605 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1623 switch (
MI.getOpcode()) {
1626 if (
MI.getOperand(0).getImm() == 0x14)
1633 case AArch64::MSRpstatesvcrImm1:
1640 auto Next = std::next(
MI.getIterator());
1641 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1648 Register &SrcReg2, int64_t &CmpMask,
1649 int64_t &CmpValue)
const {
1653 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1654 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1657 switch (
MI.getOpcode()) {
1660 case AArch64::PTEST_PP:
1661 case AArch64::PTEST_PP_ANY:
1662 case AArch64::PTEST_PP_FIRST:
1663 SrcReg =
MI.getOperand(0).getReg();
1664 SrcReg2 =
MI.getOperand(1).getReg();
1665 if (
MI.getOperand(2).getSubReg())
1672 case AArch64::SUBSWrr:
1673 case AArch64::SUBSWrs:
1674 case AArch64::SUBSWrx:
1675 case AArch64::SUBSXrr:
1676 case AArch64::SUBSXrs:
1677 case AArch64::SUBSXrx:
1678 case AArch64::ADDSWrr:
1679 case AArch64::ADDSWrs:
1680 case AArch64::ADDSWrx:
1681 case AArch64::ADDSXrr:
1682 case AArch64::ADDSXrs:
1683 case AArch64::ADDSXrx:
1685 SrcReg =
MI.getOperand(1).getReg();
1686 SrcReg2 =
MI.getOperand(2).getReg();
1689 if (
MI.getOperand(2).getSubReg())
1695 case AArch64::SUBSWri:
1696 case AArch64::ADDSWri:
1697 case AArch64::SUBSXri:
1698 case AArch64::ADDSXri:
1699 SrcReg =
MI.getOperand(1).getReg();
1702 CmpValue =
MI.getOperand(2).getImm();
1704 case AArch64::ANDSWri:
1705 case AArch64::ANDSXri:
1708 SrcReg =
MI.getOperand(1).getReg();
1712 MI.getOperand(2).getImm(),
1713 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1722 assert(
MBB &&
"Can't get MachineBasicBlock here");
1724 assert(MF &&
"Can't get MachineFunction here");
1729 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands();
OpIdx < EndIdx;
1736 if (!OpRegCstraints)
1744 "Operand has register constraints without being a register!");
1747 if (
Reg.isPhysical()) {
1764 bool MIDefinesZeroReg =
false;
1765 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1766 MI.definesRegister(AArch64::XZR,
nullptr))
1767 MIDefinesZeroReg =
true;
1769 switch (
MI.getOpcode()) {
1771 return MI.getOpcode();
1772 case AArch64::ADDSWrr:
1773 return AArch64::ADDWrr;
1774 case AArch64::ADDSWri:
1775 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1776 case AArch64::ADDSWrs:
1777 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1778 case AArch64::ADDSWrx:
1779 return AArch64::ADDWrx;
1780 case AArch64::ADDSXrr:
1781 return AArch64::ADDXrr;
1782 case AArch64::ADDSXri:
1783 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1784 case AArch64::ADDSXrs:
1785 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1786 case AArch64::ADDSXrx:
1787 return AArch64::ADDXrx;
1788 case AArch64::SUBSWrr:
1789 return AArch64::SUBWrr;
1790 case AArch64::SUBSWri:
1791 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1792 case AArch64::SUBSWrs:
1793 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1794 case AArch64::SUBSWrx:
1795 return AArch64::SUBWrx;
1796 case AArch64::SUBSXrr:
1797 return AArch64::SUBXrr;
1798 case AArch64::SUBSXri:
1799 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1800 case AArch64::SUBSXrs:
1801 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1802 case AArch64::SUBSXrx:
1803 return AArch64::SUBXrx;
1818 if (To == To->getParent()->begin())
1823 if (To->getParent() != From->getParent())
1835 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1836 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1842std::optional<unsigned>
1846 unsigned MaskOpcode =
Mask->getOpcode();
1847 unsigned PredOpcode = Pred->
getOpcode();
1848 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1849 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1851 if (PredIsWhileLike) {
1855 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1862 getElementSizeForOpcode(MaskOpcode) ==
1863 getElementSizeForOpcode(PredOpcode))
1869 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1876 if (PredIsPTestLike) {
1881 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1889 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1890 PTestLikeMask->getOperand(1).getReg().isVirtual())
1898 getElementSizeForOpcode(MaskOpcode) ==
1899 getElementSizeForOpcode(PredOpcode)) {
1900 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1926 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1928 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1936 switch (PredOpcode) {
1937 case AArch64::AND_PPzPP:
1938 case AArch64::BIC_PPzPP:
1939 case AArch64::EOR_PPzPP:
1940 case AArch64::NAND_PPzPP:
1941 case AArch64::NOR_PPzPP:
1942 case AArch64::ORN_PPzPP:
1943 case AArch64::ORR_PPzPP:
1944 case AArch64::BRKA_PPzP:
1945 case AArch64::BRKPA_PPzPP:
1946 case AArch64::BRKB_PPzP:
1947 case AArch64::BRKPB_PPzPP:
1948 case AArch64::RDFFR_PPz: {
1952 if (Mask != PredMask)
1956 case AArch64::BRKN_PPzP: {
1960 if ((MaskOpcode != AArch64::PTRUE_B) ||
1961 (
Mask->getOperand(1).getImm() != 31))
1965 case AArch64::PTRUE_B:
1978bool AArch64InstrInfo::optimizePTestInstr(
1979 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1984 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
1988 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
1989 Op.getSubReg() == AArch64::psub0)
1993 unsigned PredOpcode = Pred->
getOpcode();
1994 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
2010 if (*NewOp != PredOpcode) {
2021 for (; i !=
e; ++i) {
2052 if (DeadNZCVIdx != -1) {
2071 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2072 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2073 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2074 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2083 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2085 return (CmpValue == 0 || CmpValue == 1) &&
2086 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2094 switch (Instr.getOpcode()) {
2096 return AArch64::INSTRUCTION_LIST_END;
2098 case AArch64::ADDSWrr:
2099 case AArch64::ADDSWri:
2100 case AArch64::ADDSXrr:
2101 case AArch64::ADDSXri:
2102 case AArch64::ADDSWrx:
2103 case AArch64::ADDSXrx:
2104 case AArch64::ADDSWrs:
2105 case AArch64::ADDSXrs:
2106 case AArch64::SUBSWrr:
2107 case AArch64::SUBSWri:
2108 case AArch64::SUBSWrx:
2109 case AArch64::SUBSWrs:
2110 case AArch64::SUBSXrr:
2111 case AArch64::SUBSXri:
2112 case AArch64::SUBSXrx:
2113 case AArch64::SUBSXrs:
2114 case AArch64::ANDSWri:
2115 case AArch64::ANDSWrr:
2116 case AArch64::ANDSWrs:
2117 case AArch64::ANDSXri:
2118 case AArch64::ANDSXrr:
2119 case AArch64::ANDSXrs:
2120 case AArch64::BICSWrr:
2121 case AArch64::BICSXrr:
2122 case AArch64::BICSWrs:
2123 case AArch64::BICSXrs:
2124 case AArch64::ADCSWr:
2125 case AArch64::ADCSXr:
2126 case AArch64::SBCSWr:
2127 case AArch64::SBCSXr:
2128 return Instr.getOpcode();
2130 case AArch64::ADDWrr:
2131 return AArch64::ADDSWrr;
2132 case AArch64::ADDWri:
2133 return AArch64::ADDSWri;
2134 case AArch64::ADDXrr:
2135 return AArch64::ADDSXrr;
2136 case AArch64::ADDXri:
2137 return AArch64::ADDSXri;
2138 case AArch64::ADDWrx:
2139 return AArch64::ADDSWrx;
2140 case AArch64::ADDXrx:
2141 return AArch64::ADDSXrx;
2142 case AArch64::ADDWrs:
2143 return AArch64::ADDSWrs;
2144 case AArch64::ADDXrs:
2145 return AArch64::ADDSXrs;
2146 case AArch64::ADCWr:
2147 return AArch64::ADCSWr;
2148 case AArch64::ADCXr:
2149 return AArch64::ADCSXr;
2150 case AArch64::SUBWrr:
2151 return AArch64::SUBSWrr;
2152 case AArch64::SUBWri:
2153 return AArch64::SUBSWri;
2154 case AArch64::SUBXrr:
2155 return AArch64::SUBSXrr;
2156 case AArch64::SUBXri:
2157 return AArch64::SUBSXri;
2158 case AArch64::SUBWrx:
2159 return AArch64::SUBSWrx;
2160 case AArch64::SUBXrx:
2161 return AArch64::SUBSXrx;
2162 case AArch64::SUBWrs:
2163 return AArch64::SUBSWrs;
2164 case AArch64::SUBXrs:
2165 return AArch64::SUBSXrs;
2166 case AArch64::SBCWr:
2167 return AArch64::SBCSWr;
2168 case AArch64::SBCXr:
2169 return AArch64::SBCSXr;
2170 case AArch64::ANDWri:
2171 return AArch64::ANDSWri;
2172 case AArch64::ANDXri:
2173 return AArch64::ANDSXri;
2174 case AArch64::ANDWrr:
2175 return AArch64::ANDSWrr;
2176 case AArch64::ANDWrs:
2177 return AArch64::ANDSWrs;
2178 case AArch64::ANDXrr:
2179 return AArch64::ANDSXrr;
2180 case AArch64::ANDXrs:
2181 return AArch64::ANDSXrs;
2182 case AArch64::BICWrr:
2183 return AArch64::BICSWrr;
2184 case AArch64::BICXrr:
2185 return AArch64::BICSXrr;
2186 case AArch64::BICWrs:
2187 return AArch64::BICSWrs;
2188 case AArch64::BICXrs:
2189 return AArch64::BICSXrs;
2195 for (
auto *BB :
MBB->successors())
2196 if (BB->isLiveIn(AArch64::NZCV))
2203int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2205 switch (
Instr.getOpcode()) {
2209 case AArch64::Bcc: {
2210 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2215 case AArch64::CSINVWr:
2216 case AArch64::CSINVXr:
2217 case AArch64::CSINCWr:
2218 case AArch64::CSINCXr:
2219 case AArch64::CSELWr:
2220 case AArch64::CSELXr:
2221 case AArch64::CSNEGWr:
2222 case AArch64::CSNEGXr:
2223 case AArch64::FCSELSrrr:
2224 case AArch64::FCSELDrrr: {
2225 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2237 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2239 Instr.getOperand(CCIdx).
getImm())
2292std::optional<UsedNZCV>
2297 if (
MI.getParent() != CmpParent)
2298 return std::nullopt;
2301 return std::nullopt;
2306 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2309 return std::nullopt;
2314 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2317 return NZCVUsedAfterCmp;
2321 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2325 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2331 case AArch64::ANDSWri:
2332 case AArch64::ANDSWrr:
2333 case AArch64::ANDSWrs:
2334 case AArch64::ANDSXri:
2335 case AArch64::ANDSXrr:
2336 case AArch64::ANDSXrs:
2337 case AArch64::BICSWrr:
2338 case AArch64::BICSXrr:
2339 case AArch64::BICSWrs:
2340 case AArch64::BICSXrs:
2366 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2372 "Caller guarantees that CmpInstr compares with constant 0");
2375 if (!NZVCUsed || NZVCUsed->C)
2396bool AArch64InstrInfo::substituteCmpToZero(
2407 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2414 MI->setDesc(
get(NewOpc));
2419 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2431 assert((CmpValue == 0 || CmpValue == 1) &&
2432 "Only comparisons to 0 or 1 considered for removal!");
2435 unsigned MIOpc =
MI.getOpcode();
2436 if (MIOpc == AArch64::CSINCWr) {
2437 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2438 MI.getOperand(2).getReg() != AArch64::WZR)
2440 }
else if (MIOpc == AArch64::CSINCXr) {
2441 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2442 MI.getOperand(2).getReg() != AArch64::XZR)
2452 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2456 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2458 if (CmpValue && !IsSubsRegImm)
2460 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2465 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2468 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2472 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2475 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2476 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2479 if (MIUsedNZCV.
N && !CmpValue)
2521bool AArch64InstrInfo::removeCmpToZeroOrOne(
2528 SmallVector<MachineInstr *, 4> CCUseInstrs;
2529 bool IsInvertCC =
false;
2537 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2538 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2539 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2540 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2549bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2550 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2551 MI.getOpcode() != AArch64::CATCHRET &&
2552 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2555 MachineBasicBlock &
MBB = *
MI.getParent();
2557 auto TRI = Subtarget.getRegisterInfo();
2560 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2574 if (
MI.getOpcode() == AArch64::CATCHRET) {
2576 const TargetInstrInfo *
TII =
2578 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2583 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2585 FirstEpilogSEH = std::next(FirstEpilogSEH);
2600 if (
M.getStackProtectorGuard() ==
"sysreg") {
2601 const AArch64SysReg::SysReg *SrcReg =
2602 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2610 int Offset =
M.getStackProtectorGuardOffset();
2661 const GlobalValue *GV =
2664 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2667 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2668 Subtarget.isTargetILP32() ? 4 : 8);
2669 if (GuardWidth != 4 && GuardWidth != 8)
2674 if (GuardWidth == 4) {
2675 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2704 if (GuardWidth == 4) {
2705 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2722 if (GuardWidth == 4) {
2723 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2741 if (Subtarget.getTargetTriple().isOSMSVCRT())
2754 switch (
MI.getOpcode()) {
2757 case AArch64::MOVZWi:
2758 case AArch64::MOVZXi:
2759 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2760 assert(
MI.getDesc().getNumOperands() == 3 &&
2761 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2765 case AArch64::ANDWri:
2766 return MI.getOperand(1).getReg() == AArch64::WZR;
2767 case AArch64::ANDXri:
2768 return MI.getOperand(1).getReg() == AArch64::XZR;
2769 case TargetOpcode::COPY:
2770 return MI.getOperand(1).getReg() == AArch64::WZR;
2778 switch (
MI.getOpcode()) {
2781 case TargetOpcode::COPY: {
2784 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2785 AArch64::GPR64RegClass.
contains(DstReg));
2787 case AArch64::ORRXrs:
2788 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2789 assert(
MI.getDesc().getNumOperands() == 4 &&
2790 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2794 case AArch64::ADDXri:
2795 if (
MI.getOperand(2).getImm() == 0) {
2796 assert(
MI.getDesc().getNumOperands() == 4 &&
2797 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2808 switch (
MI.getOpcode()) {
2811 case TargetOpcode::COPY: {
2813 return AArch64::FPR128RegClass.contains(DstReg);
2815 case AArch64::ORRv16i8:
2816 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2817 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2818 "invalid ORRv16i8 operands");
2830 case AArch64::LDRWui:
2831 case AArch64::LDRXui:
2832 case AArch64::LDRBui:
2833 case AArch64::LDRHui:
2834 case AArch64::LDRSui:
2835 case AArch64::LDRDui:
2836 case AArch64::LDRQui:
2837 case AArch64::LDR_PXI:
2843 int &FrameIndex)
const {
2847 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2848 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2849 FrameIndex =
MI.getOperand(1).getIndex();
2850 return MI.getOperand(0).getReg();
2859 case AArch64::STRWui:
2860 case AArch64::STRXui:
2861 case AArch64::STRBui:
2862 case AArch64::STRHui:
2863 case AArch64::STRSui:
2864 case AArch64::STRDui:
2865 case AArch64::STRQui:
2866 case AArch64::STR_PXI:
2872 int &FrameIndex)
const {
2876 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2877 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2878 FrameIndex =
MI.getOperand(1).getIndex();
2879 return MI.getOperand(0).getReg();
2885 int &FrameIndex)
const {
2900 return MI.getOperand(0).getReg();
2906 int &FrameIndex)
const {
2921 return MI.getOperand(0).getReg();
2929 return MMO->getFlags() & MOSuppressPair;
2935 if (
MI.memoperands_empty())
2943 return MMO->getFlags() & MOStridedAccess;
2951 case AArch64::STURSi:
2952 case AArch64::STRSpre:
2953 case AArch64::STURDi:
2954 case AArch64::STRDpre:
2955 case AArch64::STURQi:
2956 case AArch64::STRQpre:
2957 case AArch64::STURBBi:
2958 case AArch64::STURHHi:
2959 case AArch64::STURWi:
2960 case AArch64::STRWpre:
2961 case AArch64::STURXi:
2962 case AArch64::STRXpre:
2963 case AArch64::LDURSi:
2964 case AArch64::LDRSpre:
2965 case AArch64::LDURDi:
2966 case AArch64::LDRDpre:
2967 case AArch64::LDURQi:
2968 case AArch64::LDRQpre:
2969 case AArch64::LDURWi:
2970 case AArch64::LDRWpre:
2971 case AArch64::LDURXi:
2972 case AArch64::LDRXpre:
2973 case AArch64::LDRSWpre:
2974 case AArch64::LDURSWi:
2975 case AArch64::LDURHHi:
2976 case AArch64::LDURBBi:
2977 case AArch64::LDURSBWi:
2978 case AArch64::LDURSHWi:
2986 case AArch64::PRFMui:
return AArch64::PRFUMi;
2987 case AArch64::LDRXui:
return AArch64::LDURXi;
2988 case AArch64::LDRWui:
return AArch64::LDURWi;
2989 case AArch64::LDRBui:
return AArch64::LDURBi;
2990 case AArch64::LDRHui:
return AArch64::LDURHi;
2991 case AArch64::LDRSui:
return AArch64::LDURSi;
2992 case AArch64::LDRDui:
return AArch64::LDURDi;
2993 case AArch64::LDRQui:
return AArch64::LDURQi;
2994 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2995 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2996 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2997 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2998 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2999 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3000 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3001 case AArch64::STRXui:
return AArch64::STURXi;
3002 case AArch64::STRWui:
return AArch64::STURWi;
3003 case AArch64::STRBui:
return AArch64::STURBi;
3004 case AArch64::STRHui:
return AArch64::STURHi;
3005 case AArch64::STRSui:
return AArch64::STURSi;
3006 case AArch64::STRDui:
return AArch64::STURDi;
3007 case AArch64::STRQui:
return AArch64::STURQi;
3008 case AArch64::STRBBui:
return AArch64::STURBBi;
3009 case AArch64::STRHHui:
return AArch64::STURHHi;
3018 case AArch64::LDAPURBi:
3019 case AArch64::LDAPURHi:
3020 case AArch64::LDAPURi:
3021 case AArch64::LDAPURSBWi:
3022 case AArch64::LDAPURSBXi:
3023 case AArch64::LDAPURSHWi:
3024 case AArch64::LDAPURSHXi:
3025 case AArch64::LDAPURSWi:
3026 case AArch64::LDAPURXi:
3027 case AArch64::LDR_PPXI:
3028 case AArch64::LDR_PXI:
3029 case AArch64::LDR_ZXI:
3030 case AArch64::LDR_ZZXI:
3031 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3032 case AArch64::LDR_ZZZXI:
3033 case AArch64::LDR_ZZZZXI:
3034 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3035 case AArch64::LDRBBui:
3036 case AArch64::LDRBui:
3037 case AArch64::LDRDui:
3038 case AArch64::LDRHHui:
3039 case AArch64::LDRHui:
3040 case AArch64::LDRQui:
3041 case AArch64::LDRSBWui:
3042 case AArch64::LDRSBXui:
3043 case AArch64::LDRSHWui:
3044 case AArch64::LDRSHXui:
3045 case AArch64::LDRSui:
3046 case AArch64::LDRSWui:
3047 case AArch64::LDRWui:
3048 case AArch64::LDRXui:
3049 case AArch64::LDURBBi:
3050 case AArch64::LDURBi:
3051 case AArch64::LDURDi:
3052 case AArch64::LDURHHi:
3053 case AArch64::LDURHi:
3054 case AArch64::LDURQi:
3055 case AArch64::LDURSBWi:
3056 case AArch64::LDURSBXi:
3057 case AArch64::LDURSHWi:
3058 case AArch64::LDURSHXi:
3059 case AArch64::LDURSi:
3060 case AArch64::LDURSWi:
3061 case AArch64::LDURWi:
3062 case AArch64::LDURXi:
3063 case AArch64::PRFMui:
3064 case AArch64::PRFUMi:
3065 case AArch64::ST2Gi:
3067 case AArch64::STLURBi:
3068 case AArch64::STLURHi:
3069 case AArch64::STLURWi:
3070 case AArch64::STLURXi:
3071 case AArch64::StoreSwiftAsyncContext:
3072 case AArch64::STR_PPXI:
3073 case AArch64::STR_PXI:
3074 case AArch64::STR_ZXI:
3075 case AArch64::STR_ZZXI:
3076 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3077 case AArch64::STR_ZZZXI:
3078 case AArch64::STR_ZZZZXI:
3079 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3080 case AArch64::STRBBui:
3081 case AArch64::STRBui:
3082 case AArch64::STRDui:
3083 case AArch64::STRHHui:
3084 case AArch64::STRHui:
3085 case AArch64::STRQui:
3086 case AArch64::STRSui:
3087 case AArch64::STRWui:
3088 case AArch64::STRXui:
3089 case AArch64::STURBBi:
3090 case AArch64::STURBi:
3091 case AArch64::STURDi:
3092 case AArch64::STURHHi:
3093 case AArch64::STURHi:
3094 case AArch64::STURQi:
3095 case AArch64::STURSi:
3096 case AArch64::STURWi:
3097 case AArch64::STURXi:
3098 case AArch64::STZ2Gi:
3099 case AArch64::STZGi:
3100 case AArch64::TAGPstack:
3102 case AArch64::LD1B_D_IMM:
3103 case AArch64::LD1B_H_IMM:
3104 case AArch64::LD1B_IMM:
3105 case AArch64::LD1B_S_IMM:
3106 case AArch64::LD1D_IMM:
3107 case AArch64::LD1H_D_IMM:
3108 case AArch64::LD1H_IMM:
3109 case AArch64::LD1H_S_IMM:
3110 case AArch64::LD1RB_D_IMM:
3111 case AArch64::LD1RB_H_IMM:
3112 case AArch64::LD1RB_IMM:
3113 case AArch64::LD1RB_S_IMM:
3114 case AArch64::LD1RD_IMM:
3115 case AArch64::LD1RH_D_IMM:
3116 case AArch64::LD1RH_IMM:
3117 case AArch64::LD1RH_S_IMM:
3118 case AArch64::LD1RSB_D_IMM:
3119 case AArch64::LD1RSB_H_IMM:
3120 case AArch64::LD1RSB_S_IMM:
3121 case AArch64::LD1RSH_D_IMM:
3122 case AArch64::LD1RSH_S_IMM:
3123 case AArch64::LD1RSW_IMM:
3124 case AArch64::LD1RW_D_IMM:
3125 case AArch64::LD1RW_IMM:
3126 case AArch64::LD1SB_D_IMM:
3127 case AArch64::LD1SB_H_IMM:
3128 case AArch64::LD1SB_S_IMM:
3129 case AArch64::LD1SH_D_IMM:
3130 case AArch64::LD1SH_S_IMM:
3131 case AArch64::LD1SW_D_IMM:
3132 case AArch64::LD1W_D_IMM:
3133 case AArch64::LD1W_IMM:
3134 case AArch64::LD2B_IMM:
3135 case AArch64::LD2D_IMM:
3136 case AArch64::LD2H_IMM:
3137 case AArch64::LD2W_IMM:
3138 case AArch64::LD3B_IMM:
3139 case AArch64::LD3D_IMM:
3140 case AArch64::LD3H_IMM:
3141 case AArch64::LD3W_IMM:
3142 case AArch64::LD4B_IMM:
3143 case AArch64::LD4D_IMM:
3144 case AArch64::LD4H_IMM:
3145 case AArch64::LD4W_IMM:
3147 case AArch64::LDNF1B_D_IMM:
3148 case AArch64::LDNF1B_H_IMM:
3149 case AArch64::LDNF1B_IMM:
3150 case AArch64::LDNF1B_S_IMM:
3151 case AArch64::LDNF1D_IMM:
3152 case AArch64::LDNF1H_D_IMM:
3153 case AArch64::LDNF1H_IMM:
3154 case AArch64::LDNF1H_S_IMM:
3155 case AArch64::LDNF1SB_D_IMM:
3156 case AArch64::LDNF1SB_H_IMM:
3157 case AArch64::LDNF1SB_S_IMM:
3158 case AArch64::LDNF1SH_D_IMM:
3159 case AArch64::LDNF1SH_S_IMM:
3160 case AArch64::LDNF1SW_D_IMM:
3161 case AArch64::LDNF1W_D_IMM:
3162 case AArch64::LDNF1W_IMM:
3163 case AArch64::LDNPDi:
3164 case AArch64::LDNPQi:
3165 case AArch64::LDNPSi:
3166 case AArch64::LDNPWi:
3167 case AArch64::LDNPXi:
3168 case AArch64::LDNT1B_ZRI:
3169 case AArch64::LDNT1D_ZRI:
3170 case AArch64::LDNT1H_ZRI:
3171 case AArch64::LDNT1W_ZRI:
3172 case AArch64::LDPDi:
3173 case AArch64::LDPQi:
3174 case AArch64::LDPSi:
3175 case AArch64::LDPWi:
3176 case AArch64::LDPXi:
3177 case AArch64::LDRBBpost:
3178 case AArch64::LDRBBpre:
3179 case AArch64::LDRBpost:
3180 case AArch64::LDRBpre:
3181 case AArch64::LDRDpost:
3182 case AArch64::LDRDpre:
3183 case AArch64::LDRHHpost:
3184 case AArch64::LDRHHpre:
3185 case AArch64::LDRHpost:
3186 case AArch64::LDRHpre:
3187 case AArch64::LDRQpost:
3188 case AArch64::LDRQpre:
3189 case AArch64::LDRSpost:
3190 case AArch64::LDRSpre:
3191 case AArch64::LDRWpost:
3192 case AArch64::LDRWpre:
3193 case AArch64::LDRXpost:
3194 case AArch64::LDRXpre:
3195 case AArch64::ST1B_D_IMM:
3196 case AArch64::ST1B_H_IMM:
3197 case AArch64::ST1B_IMM:
3198 case AArch64::ST1B_S_IMM:
3199 case AArch64::ST1D_IMM:
3200 case AArch64::ST1H_D_IMM:
3201 case AArch64::ST1H_IMM:
3202 case AArch64::ST1H_S_IMM:
3203 case AArch64::ST1W_D_IMM:
3204 case AArch64::ST1W_IMM:
3205 case AArch64::ST2B_IMM:
3206 case AArch64::ST2D_IMM:
3207 case AArch64::ST2H_IMM:
3208 case AArch64::ST2W_IMM:
3209 case AArch64::ST3B_IMM:
3210 case AArch64::ST3D_IMM:
3211 case AArch64::ST3H_IMM:
3212 case AArch64::ST3W_IMM:
3213 case AArch64::ST4B_IMM:
3214 case AArch64::ST4D_IMM:
3215 case AArch64::ST4H_IMM:
3216 case AArch64::ST4W_IMM:
3217 case AArch64::STGPi:
3218 case AArch64::STGPreIndex:
3219 case AArch64::STZGPreIndex:
3220 case AArch64::ST2GPreIndex:
3221 case AArch64::STZ2GPreIndex:
3222 case AArch64::STGPostIndex:
3223 case AArch64::STZGPostIndex:
3224 case AArch64::ST2GPostIndex:
3225 case AArch64::STZ2GPostIndex:
3226 case AArch64::STNPDi:
3227 case AArch64::STNPQi:
3228 case AArch64::STNPSi:
3229 case AArch64::STNPWi:
3230 case AArch64::STNPXi:
3231 case AArch64::STNT1B_ZRI:
3232 case AArch64::STNT1D_ZRI:
3233 case AArch64::STNT1H_ZRI:
3234 case AArch64::STNT1W_ZRI:
3235 case AArch64::STPDi:
3236 case AArch64::STPQi:
3237 case AArch64::STPSi:
3238 case AArch64::STPWi:
3239 case AArch64::STPXi:
3240 case AArch64::STRBBpost:
3241 case AArch64::STRBBpre:
3242 case AArch64::STRBpost:
3243 case AArch64::STRBpre:
3244 case AArch64::STRDpost:
3245 case AArch64::STRDpre:
3246 case AArch64::STRHHpost:
3247 case AArch64::STRHHpre:
3248 case AArch64::STRHpost:
3249 case AArch64::STRHpre:
3250 case AArch64::STRQpost:
3251 case AArch64::STRQpre:
3252 case AArch64::STRSpost:
3253 case AArch64::STRSpre:
3254 case AArch64::STRWpost:
3255 case AArch64::STRWpre:
3256 case AArch64::STRXpost:
3257 case AArch64::STRXpre:
3258 case AArch64::LD1B_2Z_IMM:
3259 case AArch64::LD1B_2Z_STRIDED_IMM:
3260 case AArch64::LD1H_2Z_IMM:
3261 case AArch64::LD1H_2Z_STRIDED_IMM:
3262 case AArch64::LD1W_2Z_IMM:
3263 case AArch64::LD1W_2Z_STRIDED_IMM:
3264 case AArch64::LD1D_2Z_IMM:
3265 case AArch64::LD1D_2Z_STRIDED_IMM:
3266 case AArch64::LD1B_4Z_IMM:
3267 case AArch64::LD1B_4Z_STRIDED_IMM:
3268 case AArch64::LD1H_4Z_IMM:
3269 case AArch64::LD1H_4Z_STRIDED_IMM:
3270 case AArch64::LD1W_4Z_IMM:
3271 case AArch64::LD1W_4Z_STRIDED_IMM:
3272 case AArch64::LD1D_4Z_IMM:
3273 case AArch64::LD1D_4Z_STRIDED_IMM:
3274 case AArch64::LD1B_2Z_IMM_PSEUDO:
3275 case AArch64::LD1H_2Z_IMM_PSEUDO:
3276 case AArch64::LD1W_2Z_IMM_PSEUDO:
3277 case AArch64::LD1D_2Z_IMM_PSEUDO:
3278 case AArch64::LD1B_4Z_IMM_PSEUDO:
3279 case AArch64::LD1H_4Z_IMM_PSEUDO:
3280 case AArch64::LD1W_4Z_IMM_PSEUDO:
3281 case AArch64::LD1D_4Z_IMM_PSEUDO:
3282 case AArch64::ST1B_2Z_IMM:
3283 case AArch64::ST1B_2Z_STRIDED_IMM:
3284 case AArch64::ST1H_2Z_IMM:
3285 case AArch64::ST1H_2Z_STRIDED_IMM:
3286 case AArch64::ST1W_2Z_IMM:
3287 case AArch64::ST1W_2Z_STRIDED_IMM:
3288 case AArch64::ST1D_2Z_IMM:
3289 case AArch64::ST1D_2Z_STRIDED_IMM:
3290 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3291 case AArch64::LDNT1B_2Z_IMM:
3292 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3293 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3294 case AArch64::LDNT1H_2Z_IMM:
3295 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3296 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3297 case AArch64::LDNT1W_2Z_IMM:
3298 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3299 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3300 case AArch64::LDNT1D_2Z_IMM:
3301 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3302 case AArch64::STNT1B_2Z_IMM:
3303 case AArch64::STNT1B_2Z_STRIDED_IMM:
3304 case AArch64::STNT1H_2Z_IMM:
3305 case AArch64::STNT1H_2Z_STRIDED_IMM:
3306 case AArch64::STNT1W_2Z_IMM:
3307 case AArch64::STNT1W_2Z_STRIDED_IMM:
3308 case AArch64::STNT1D_2Z_IMM:
3309 case AArch64::STNT1D_2Z_STRIDED_IMM:
3310 case AArch64::ST1B_4Z_IMM:
3311 case AArch64::ST1B_4Z_STRIDED_IMM:
3312 case AArch64::ST1H_4Z_IMM:
3313 case AArch64::ST1H_4Z_STRIDED_IMM:
3314 case AArch64::ST1W_4Z_IMM:
3315 case AArch64::ST1W_4Z_STRIDED_IMM:
3316 case AArch64::ST1D_4Z_IMM:
3317 case AArch64::ST1D_4Z_STRIDED_IMM:
3318 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3319 case AArch64::LDNT1B_4Z_IMM:
3320 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3321 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3322 case AArch64::LDNT1H_4Z_IMM:
3323 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3324 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3325 case AArch64::LDNT1W_4Z_IMM:
3326 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3327 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3328 case AArch64::LDNT1D_4Z_IMM:
3329 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3330 case AArch64::STNT1B_4Z_IMM:
3331 case AArch64::STNT1B_4Z_STRIDED_IMM:
3332 case AArch64::STNT1H_4Z_IMM:
3333 case AArch64::STNT1H_4Z_STRIDED_IMM:
3334 case AArch64::STNT1W_4Z_IMM:
3335 case AArch64::STNT1W_4Z_STRIDED_IMM:
3336 case AArch64::STNT1D_4Z_IMM:
3337 case AArch64::STNT1D_4Z_STRIDED_IMM:
3339 case AArch64::LDPDpost:
3340 case AArch64::LDPDpre:
3341 case AArch64::LDPQpost:
3342 case AArch64::LDPQpre:
3343 case AArch64::LDPSpost:
3344 case AArch64::LDPSpre:
3345 case AArch64::LDPWpost:
3346 case AArch64::LDPWpre:
3347 case AArch64::LDPXpost:
3348 case AArch64::LDPXpre:
3349 case AArch64::STGPpre:
3350 case AArch64::STGPpost:
3351 case AArch64::STPDpost:
3352 case AArch64::STPDpre:
3353 case AArch64::STPQpost:
3354 case AArch64::STPQpre:
3355 case AArch64::STPSpost:
3356 case AArch64::STPSpre:
3357 case AArch64::STPWpost:
3358 case AArch64::STPWpre:
3359 case AArch64::STPXpost:
3360 case AArch64::STPXpre:
3366 switch (
MI.getOpcode()) {
3370 case AArch64::STRSui:
3371 case AArch64::STRDui:
3372 case AArch64::STRQui:
3373 case AArch64::STRXui:
3374 case AArch64::STRWui:
3375 case AArch64::LDRSui:
3376 case AArch64::LDRDui:
3377 case AArch64::LDRQui:
3378 case AArch64::LDRXui:
3379 case AArch64::LDRWui:
3380 case AArch64::LDRSWui:
3382 case AArch64::STURSi:
3383 case AArch64::STRSpre:
3384 case AArch64::STURDi:
3385 case AArch64::STRDpre:
3386 case AArch64::STURQi:
3387 case AArch64::STRQpre:
3388 case AArch64::STURWi:
3389 case AArch64::STRWpre:
3390 case AArch64::STURXi:
3391 case AArch64::STRXpre:
3392 case AArch64::LDURSi:
3393 case AArch64::LDRSpre:
3394 case AArch64::LDURDi:
3395 case AArch64::LDRDpre:
3396 case AArch64::LDURQi:
3397 case AArch64::LDRQpre:
3398 case AArch64::LDURWi:
3399 case AArch64::LDRWpre:
3400 case AArch64::LDURXi:
3401 case AArch64::LDRXpre:
3402 case AArch64::LDURSWi:
3403 case AArch64::LDRSWpre:
3405 case AArch64::LDR_ZXI:
3406 case AArch64::STR_ZXI:
3412 switch (
MI.getOpcode()) {
3415 "Unexpected instruction - was a new tail call opcode introduced?");
3417 case AArch64::TCRETURNdi:
3418 case AArch64::TCRETURNri:
3419 case AArch64::TCRETURNrix16x17:
3420 case AArch64::TCRETURNrix17:
3421 case AArch64::TCRETURNrinotx16:
3422 case AArch64::TCRETURNriALL:
3423 case AArch64::AUTH_TCRETURN:
3424 case AArch64::AUTH_TCRETURN_BTI:
3434 case AArch64::ADDWri:
3435 return AArch64::ADDSWri;
3436 case AArch64::ADDWrr:
3437 return AArch64::ADDSWrr;
3438 case AArch64::ADDWrs:
3439 return AArch64::ADDSWrs;
3440 case AArch64::ADDWrx:
3441 return AArch64::ADDSWrx;
3442 case AArch64::ANDWri:
3443 return AArch64::ANDSWri;
3444 case AArch64::ANDWrr:
3445 return AArch64::ANDSWrr;
3446 case AArch64::ANDWrs:
3447 return AArch64::ANDSWrs;
3448 case AArch64::BICWrr:
3449 return AArch64::BICSWrr;
3450 case AArch64::BICWrs:
3451 return AArch64::BICSWrs;
3452 case AArch64::SUBWri:
3453 return AArch64::SUBSWri;
3454 case AArch64::SUBWrr:
3455 return AArch64::SUBSWrr;
3456 case AArch64::SUBWrs:
3457 return AArch64::SUBSWrs;
3458 case AArch64::SUBWrx:
3459 return AArch64::SUBSWrx;
3461 case AArch64::ADDXri:
3462 return AArch64::ADDSXri;
3463 case AArch64::ADDXrr:
3464 return AArch64::ADDSXrr;
3465 case AArch64::ADDXrs:
3466 return AArch64::ADDSXrs;
3467 case AArch64::ADDXrx:
3468 return AArch64::ADDSXrx;
3469 case AArch64::ANDXri:
3470 return AArch64::ANDSXri;
3471 case AArch64::ANDXrr:
3472 return AArch64::ANDSXrr;
3473 case AArch64::ANDXrs:
3474 return AArch64::ANDSXrs;
3475 case AArch64::BICXrr:
3476 return AArch64::BICSXrr;
3477 case AArch64::BICXrs:
3478 return AArch64::BICSXrs;
3479 case AArch64::SUBXri:
3480 return AArch64::SUBSXri;
3481 case AArch64::SUBXrr:
3482 return AArch64::SUBSXrr;
3483 case AArch64::SUBXrs:
3484 return AArch64::SUBSXrs;
3485 case AArch64::SUBXrx:
3486 return AArch64::SUBSXrx;
3488 case AArch64::AND_PPzPP:
3489 return AArch64::ANDS_PPzPP;
3490 case AArch64::BIC_PPzPP:
3491 return AArch64::BICS_PPzPP;
3492 case AArch64::EOR_PPzPP:
3493 return AArch64::EORS_PPzPP;
3494 case AArch64::NAND_PPzPP:
3495 return AArch64::NANDS_PPzPP;
3496 case AArch64::NOR_PPzPP:
3497 return AArch64::NORS_PPzPP;
3498 case AArch64::ORN_PPzPP:
3499 return AArch64::ORNS_PPzPP;
3500 case AArch64::ORR_PPzPP:
3501 return AArch64::ORRS_PPzPP;
3502 case AArch64::BRKA_PPzP:
3503 return AArch64::BRKAS_PPzP;
3504 case AArch64::BRKPA_PPzPP:
3505 return AArch64::BRKPAS_PPzPP;
3506 case AArch64::BRKB_PPzP:
3507 return AArch64::BRKBS_PPzP;
3508 case AArch64::BRKPB_PPzPP:
3509 return AArch64::BRKPBS_PPzPP;
3510 case AArch64::BRKN_PPzP:
3511 return AArch64::BRKNS_PPzP;
3512 case AArch64::RDFFR_PPz:
3513 return AArch64::RDFFRS_PPz;
3514 case AArch64::PTRUE_B:
3515 return AArch64::PTRUES_B;
3526 if (
MI.hasOrderedMemoryRef())
3531 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3532 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3533 "Expected a reg or frame index operand.");
3537 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3539 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3552 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3553 Register BaseReg =
MI.getOperand(1).getReg();
3555 if (
MI.modifiesRegister(BaseReg,
TRI))
3561 switch (
MI.getOpcode()) {
3564 case AArch64::LDR_ZXI:
3565 case AArch64::STR_ZXI:
3566 if (!Subtarget.isLittleEndian() ||
3567 Subtarget.getSVEVectorSizeInBits() != 128)
3580 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3588 if (Subtarget.isPaired128Slow()) {
3589 switch (
MI.getOpcode()) {
3592 case AArch64::LDURQi:
3593 case AArch64::STURQi:
3594 case AArch64::LDRQui:
3595 case AArch64::STRQui:
3622std::optional<ExtAddrMode>
3627 bool OffsetIsScalable;
3628 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3629 return std::nullopt;
3632 return std::nullopt;
3647 int64_t OffsetScale = 1;
3652 case AArch64::LDURQi:
3653 case AArch64::STURQi:
3657 case AArch64::LDURDi:
3658 case AArch64::STURDi:
3659 case AArch64::LDURXi:
3660 case AArch64::STURXi:
3664 case AArch64::LDURWi:
3665 case AArch64::LDURSWi:
3666 case AArch64::STURWi:
3670 case AArch64::LDURHi:
3671 case AArch64::STURHi:
3672 case AArch64::LDURHHi:
3673 case AArch64::STURHHi:
3674 case AArch64::LDURSHXi:
3675 case AArch64::LDURSHWi:
3679 case AArch64::LDRBroX:
3680 case AArch64::LDRBBroX:
3681 case AArch64::LDRSBXroX:
3682 case AArch64::LDRSBWroX:
3683 case AArch64::STRBroX:
3684 case AArch64::STRBBroX:
3685 case AArch64::LDURBi:
3686 case AArch64::LDURBBi:
3687 case AArch64::LDURSBXi:
3688 case AArch64::LDURSBWi:
3689 case AArch64::STURBi:
3690 case AArch64::STURBBi:
3691 case AArch64::LDRBui:
3692 case AArch64::LDRBBui:
3693 case AArch64::LDRSBXui:
3694 case AArch64::LDRSBWui:
3695 case AArch64::STRBui:
3696 case AArch64::STRBBui:
3700 case AArch64::LDRQroX:
3701 case AArch64::STRQroX:
3702 case AArch64::LDRQui:
3703 case AArch64::STRQui:
3708 case AArch64::LDRDroX:
3709 case AArch64::STRDroX:
3710 case AArch64::LDRXroX:
3711 case AArch64::STRXroX:
3712 case AArch64::LDRDui:
3713 case AArch64::STRDui:
3714 case AArch64::LDRXui:
3715 case AArch64::STRXui:
3720 case AArch64::LDRWroX:
3721 case AArch64::LDRSWroX:
3722 case AArch64::STRWroX:
3723 case AArch64::LDRWui:
3724 case AArch64::LDRSWui:
3725 case AArch64::STRWui:
3730 case AArch64::LDRHroX:
3731 case AArch64::STRHroX:
3732 case AArch64::LDRHHroX:
3733 case AArch64::STRHHroX:
3734 case AArch64::LDRSHXroX:
3735 case AArch64::LDRSHWroX:
3736 case AArch64::LDRHui:
3737 case AArch64::STRHui:
3738 case AArch64::LDRHHui:
3739 case AArch64::STRHHui:
3740 case AArch64::LDRSHXui:
3741 case AArch64::LDRSHWui:
3749 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3773 case AArch64::SBFMXri:
3786 AM.
Scale = OffsetScale;
3791 case TargetOpcode::SUBREG_TO_REG: {
3807 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3808 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3809 DefMI.getOperand(3).getImm() != 0)
3816 AM.
Scale = OffsetScale;
3827 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3828 int64_t NewOffset) ->
bool {
3829 int64_t MinOffset, MaxOffset;
3846 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3847 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3849 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3851 int64_t NewOffset = OldOffset + Disp;
3852 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3856 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3866 auto canFoldAddRegIntoAddrMode =
3871 if ((
unsigned)Scale != Scale)
3873 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3885 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3886 Subtarget.isSTRQroSlow();
3895 case AArch64::ADDXri:
3901 return canFoldAddSubImmIntoAddrMode(Disp);
3903 case AArch64::SUBXri:
3909 return canFoldAddSubImmIntoAddrMode(-Disp);
3911 case AArch64::ADDXrs: {
3924 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3926 if (avoidSlowSTRQ(MemI))
3929 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3932 case AArch64::ADDXrr:
3940 if (!OptSize && avoidSlowSTRQ(MemI))
3942 return canFoldAddRegIntoAddrMode(1);
3944 case AArch64::ADDXrx:
3952 if (!OptSize && avoidSlowSTRQ(MemI))
3961 return canFoldAddRegIntoAddrMode(
3976 case AArch64::LDURQi:
3977 case AArch64::LDRQui:
3978 return AArch64::LDRQroX;
3979 case AArch64::STURQi:
3980 case AArch64::STRQui:
3981 return AArch64::STRQroX;
3982 case AArch64::LDURDi:
3983 case AArch64::LDRDui:
3984 return AArch64::LDRDroX;
3985 case AArch64::STURDi:
3986 case AArch64::STRDui:
3987 return AArch64::STRDroX;
3988 case AArch64::LDURXi:
3989 case AArch64::LDRXui:
3990 return AArch64::LDRXroX;
3991 case AArch64::STURXi:
3992 case AArch64::STRXui:
3993 return AArch64::STRXroX;
3994 case AArch64::LDURWi:
3995 case AArch64::LDRWui:
3996 return AArch64::LDRWroX;
3997 case AArch64::LDURSWi:
3998 case AArch64::LDRSWui:
3999 return AArch64::LDRSWroX;
4000 case AArch64::STURWi:
4001 case AArch64::STRWui:
4002 return AArch64::STRWroX;
4003 case AArch64::LDURHi:
4004 case AArch64::LDRHui:
4005 return AArch64::LDRHroX;
4006 case AArch64::STURHi:
4007 case AArch64::STRHui:
4008 return AArch64::STRHroX;
4009 case AArch64::LDURHHi:
4010 case AArch64::LDRHHui:
4011 return AArch64::LDRHHroX;
4012 case AArch64::STURHHi:
4013 case AArch64::STRHHui:
4014 return AArch64::STRHHroX;
4015 case AArch64::LDURSHXi:
4016 case AArch64::LDRSHXui:
4017 return AArch64::LDRSHXroX;
4018 case AArch64::LDURSHWi:
4019 case AArch64::LDRSHWui:
4020 return AArch64::LDRSHWroX;
4021 case AArch64::LDURBi:
4022 case AArch64::LDRBui:
4023 return AArch64::LDRBroX;
4024 case AArch64::LDURBBi:
4025 case AArch64::LDRBBui:
4026 return AArch64::LDRBBroX;
4027 case AArch64::LDURSBXi:
4028 case AArch64::LDRSBXui:
4029 return AArch64::LDRSBXroX;
4030 case AArch64::LDURSBWi:
4031 case AArch64::LDRSBWui:
4032 return AArch64::LDRSBWroX;
4033 case AArch64::STURBi:
4034 case AArch64::STRBui:
4035 return AArch64::STRBroX;
4036 case AArch64::STURBBi:
4037 case AArch64::STRBBui:
4038 return AArch64::STRBBroX;
4050 case AArch64::LDURQi:
4052 return AArch64::LDRQui;
4053 case AArch64::STURQi:
4055 return AArch64::STRQui;
4056 case AArch64::LDURDi:
4058 return AArch64::LDRDui;
4059 case AArch64::STURDi:
4061 return AArch64::STRDui;
4062 case AArch64::LDURXi:
4064 return AArch64::LDRXui;
4065 case AArch64::STURXi:
4067 return AArch64::STRXui;
4068 case AArch64::LDURWi:
4070 return AArch64::LDRWui;
4071 case AArch64::LDURSWi:
4073 return AArch64::LDRSWui;
4074 case AArch64::STURWi:
4076 return AArch64::STRWui;
4077 case AArch64::LDURHi:
4079 return AArch64::LDRHui;
4080 case AArch64::STURHi:
4082 return AArch64::STRHui;
4083 case AArch64::LDURHHi:
4085 return AArch64::LDRHHui;
4086 case AArch64::STURHHi:
4088 return AArch64::STRHHui;
4089 case AArch64::LDURSHXi:
4091 return AArch64::LDRSHXui;
4092 case AArch64::LDURSHWi:
4094 return AArch64::LDRSHWui;
4095 case AArch64::LDURBi:
4097 return AArch64::LDRBui;
4098 case AArch64::LDURBBi:
4100 return AArch64::LDRBBui;
4101 case AArch64::LDURSBXi:
4103 return AArch64::LDRSBXui;
4104 case AArch64::LDURSBWi:
4106 return AArch64::LDRSBWui;
4107 case AArch64::STURBi:
4109 return AArch64::STRBui;
4110 case AArch64::STURBBi:
4112 return AArch64::STRBBui;
4113 case AArch64::LDRQui:
4114 case AArch64::STRQui:
4117 case AArch64::LDRDui:
4118 case AArch64::STRDui:
4119 case AArch64::LDRXui:
4120 case AArch64::STRXui:
4123 case AArch64::LDRWui:
4124 case AArch64::LDRSWui:
4125 case AArch64::STRWui:
4128 case AArch64::LDRHui:
4129 case AArch64::STRHui:
4130 case AArch64::LDRHHui:
4131 case AArch64::STRHHui:
4132 case AArch64::LDRSHXui:
4133 case AArch64::LDRSHWui:
4136 case AArch64::LDRBui:
4137 case AArch64::LDRBBui:
4138 case AArch64::LDRSBXui:
4139 case AArch64::LDRSBWui:
4140 case AArch64::STRBui:
4141 case AArch64::STRBBui:
4155 case AArch64::LDURQi:
4156 case AArch64::STURQi:
4157 case AArch64::LDURDi:
4158 case AArch64::STURDi:
4159 case AArch64::LDURXi:
4160 case AArch64::STURXi:
4161 case AArch64::LDURWi:
4162 case AArch64::LDURSWi:
4163 case AArch64::STURWi:
4164 case AArch64::LDURHi:
4165 case AArch64::STURHi:
4166 case AArch64::LDURHHi:
4167 case AArch64::STURHHi:
4168 case AArch64::LDURSHXi:
4169 case AArch64::LDURSHWi:
4170 case AArch64::LDURBi:
4171 case AArch64::STURBi:
4172 case AArch64::LDURBBi:
4173 case AArch64::STURBBi:
4174 case AArch64::LDURSBWi:
4175 case AArch64::LDURSBXi:
4177 case AArch64::LDRQui:
4178 return AArch64::LDURQi;
4179 case AArch64::STRQui:
4180 return AArch64::STURQi;
4181 case AArch64::LDRDui:
4182 return AArch64::LDURDi;
4183 case AArch64::STRDui:
4184 return AArch64::STURDi;
4185 case AArch64::LDRXui:
4186 return AArch64::LDURXi;
4187 case AArch64::STRXui:
4188 return AArch64::STURXi;
4189 case AArch64::LDRWui:
4190 return AArch64::LDURWi;
4191 case AArch64::LDRSWui:
4192 return AArch64::LDURSWi;
4193 case AArch64::STRWui:
4194 return AArch64::STURWi;
4195 case AArch64::LDRHui:
4196 return AArch64::LDURHi;
4197 case AArch64::STRHui:
4198 return AArch64::STURHi;
4199 case AArch64::LDRHHui:
4200 return AArch64::LDURHHi;
4201 case AArch64::STRHHui:
4202 return AArch64::STURHHi;
4203 case AArch64::LDRSHXui:
4204 return AArch64::LDURSHXi;
4205 case AArch64::LDRSHWui:
4206 return AArch64::LDURSHWi;
4207 case AArch64::LDRBBui:
4208 return AArch64::LDURBBi;
4209 case AArch64::LDRBui:
4210 return AArch64::LDURBi;
4211 case AArch64::STRBBui:
4212 return AArch64::STURBBi;
4213 case AArch64::STRBui:
4214 return AArch64::STURBi;
4215 case AArch64::LDRSBWui:
4216 return AArch64::LDURSBWi;
4217 case AArch64::LDRSBXui:
4218 return AArch64::LDURSBXi;
4231 case AArch64::LDRQroX:
4232 case AArch64::LDURQi:
4233 case AArch64::LDRQui:
4234 return AArch64::LDRQroW;
4235 case AArch64::STRQroX:
4236 case AArch64::STURQi:
4237 case AArch64::STRQui:
4238 return AArch64::STRQroW;
4239 case AArch64::LDRDroX:
4240 case AArch64::LDURDi:
4241 case AArch64::LDRDui:
4242 return AArch64::LDRDroW;
4243 case AArch64::STRDroX:
4244 case AArch64::STURDi:
4245 case AArch64::STRDui:
4246 return AArch64::STRDroW;
4247 case AArch64::LDRXroX:
4248 case AArch64::LDURXi:
4249 case AArch64::LDRXui:
4250 return AArch64::LDRXroW;
4251 case AArch64::STRXroX:
4252 case AArch64::STURXi:
4253 case AArch64::STRXui:
4254 return AArch64::STRXroW;
4255 case AArch64::LDRWroX:
4256 case AArch64::LDURWi:
4257 case AArch64::LDRWui:
4258 return AArch64::LDRWroW;
4259 case AArch64::LDRSWroX:
4260 case AArch64::LDURSWi:
4261 case AArch64::LDRSWui:
4262 return AArch64::LDRSWroW;
4263 case AArch64::STRWroX:
4264 case AArch64::STURWi:
4265 case AArch64::STRWui:
4266 return AArch64::STRWroW;
4267 case AArch64::LDRHroX:
4268 case AArch64::LDURHi:
4269 case AArch64::LDRHui:
4270 return AArch64::LDRHroW;
4271 case AArch64::STRHroX:
4272 case AArch64::STURHi:
4273 case AArch64::STRHui:
4274 return AArch64::STRHroW;
4275 case AArch64::LDRHHroX:
4276 case AArch64::LDURHHi:
4277 case AArch64::LDRHHui:
4278 return AArch64::LDRHHroW;
4279 case AArch64::STRHHroX:
4280 case AArch64::STURHHi:
4281 case AArch64::STRHHui:
4282 return AArch64::STRHHroW;
4283 case AArch64::LDRSHXroX:
4284 case AArch64::LDURSHXi:
4285 case AArch64::LDRSHXui:
4286 return AArch64::LDRSHXroW;
4287 case AArch64::LDRSHWroX:
4288 case AArch64::LDURSHWi:
4289 case AArch64::LDRSHWui:
4290 return AArch64::LDRSHWroW;
4291 case AArch64::LDRBroX:
4292 case AArch64::LDURBi:
4293 case AArch64::LDRBui:
4294 return AArch64::LDRBroW;
4295 case AArch64::LDRBBroX:
4296 case AArch64::LDURBBi:
4297 case AArch64::LDRBBui:
4298 return AArch64::LDRBBroW;
4299 case AArch64::LDRSBXroX:
4300 case AArch64::LDURSBXi:
4301 case AArch64::LDRSBXui:
4302 return AArch64::LDRSBXroW;
4303 case AArch64::LDRSBWroX:
4304 case AArch64::LDURSBWi:
4305 case AArch64::LDRSBWui:
4306 return AArch64::LDRSBWroW;
4307 case AArch64::STRBroX:
4308 case AArch64::STURBi:
4309 case AArch64::STRBui:
4310 return AArch64::STRBroW;
4311 case AArch64::STRBBroX:
4312 case AArch64::STURBBi:
4313 case AArch64::STRBBui:
4314 return AArch64::STRBBroW;
4339 return B.getInstr();
4343 "Addressing mode not supported for folding");
4360 return B.getInstr();
4367 "Address offset can be a register or an immediate, but not both");
4388 return B.getInstr();
4392 "Function must not be called with an addressing mode it can't handle");
4401 case AArch64::LD1Fourv16b_POST:
4402 case AArch64::LD1Fourv1d_POST:
4403 case AArch64::LD1Fourv2d_POST:
4404 case AArch64::LD1Fourv2s_POST:
4405 case AArch64::LD1Fourv4h_POST:
4406 case AArch64::LD1Fourv4s_POST:
4407 case AArch64::LD1Fourv8b_POST:
4408 case AArch64::LD1Fourv8h_POST:
4409 case AArch64::LD1Onev16b_POST:
4410 case AArch64::LD1Onev1d_POST:
4411 case AArch64::LD1Onev2d_POST:
4412 case AArch64::LD1Onev2s_POST:
4413 case AArch64::LD1Onev4h_POST:
4414 case AArch64::LD1Onev4s_POST:
4415 case AArch64::LD1Onev8b_POST:
4416 case AArch64::LD1Onev8h_POST:
4417 case AArch64::LD1Rv16b_POST:
4418 case AArch64::LD1Rv1d_POST:
4419 case AArch64::LD1Rv2d_POST:
4420 case AArch64::LD1Rv2s_POST:
4421 case AArch64::LD1Rv4h_POST:
4422 case AArch64::LD1Rv4s_POST:
4423 case AArch64::LD1Rv8b_POST:
4424 case AArch64::LD1Rv8h_POST:
4425 case AArch64::LD1Threev16b_POST:
4426 case AArch64::LD1Threev1d_POST:
4427 case AArch64::LD1Threev2d_POST:
4428 case AArch64::LD1Threev2s_POST:
4429 case AArch64::LD1Threev4h_POST:
4430 case AArch64::LD1Threev4s_POST:
4431 case AArch64::LD1Threev8b_POST:
4432 case AArch64::LD1Threev8h_POST:
4433 case AArch64::LD1Twov16b_POST:
4434 case AArch64::LD1Twov1d_POST:
4435 case AArch64::LD1Twov2d_POST:
4436 case AArch64::LD1Twov2s_POST:
4437 case AArch64::LD1Twov4h_POST:
4438 case AArch64::LD1Twov4s_POST:
4439 case AArch64::LD1Twov8b_POST:
4440 case AArch64::LD1Twov8h_POST:
4441 case AArch64::LD1i16_POST:
4442 case AArch64::LD1i32_POST:
4443 case AArch64::LD1i64_POST:
4444 case AArch64::LD1i8_POST:
4445 case AArch64::LD2Rv16b_POST:
4446 case AArch64::LD2Rv1d_POST:
4447 case AArch64::LD2Rv2d_POST:
4448 case AArch64::LD2Rv2s_POST:
4449 case AArch64::LD2Rv4h_POST:
4450 case AArch64::LD2Rv4s_POST:
4451 case AArch64::LD2Rv8b_POST:
4452 case AArch64::LD2Rv8h_POST:
4453 case AArch64::LD2Twov16b_POST:
4454 case AArch64::LD2Twov2d_POST:
4455 case AArch64::LD2Twov2s_POST:
4456 case AArch64::LD2Twov4h_POST:
4457 case AArch64::LD2Twov4s_POST:
4458 case AArch64::LD2Twov8b_POST:
4459 case AArch64::LD2Twov8h_POST:
4460 case AArch64::LD2i16_POST:
4461 case AArch64::LD2i32_POST:
4462 case AArch64::LD2i64_POST:
4463 case AArch64::LD2i8_POST:
4464 case AArch64::LD3Rv16b_POST:
4465 case AArch64::LD3Rv1d_POST:
4466 case AArch64::LD3Rv2d_POST:
4467 case AArch64::LD3Rv2s_POST:
4468 case AArch64::LD3Rv4h_POST:
4469 case AArch64::LD3Rv4s_POST:
4470 case AArch64::LD3Rv8b_POST:
4471 case AArch64::LD3Rv8h_POST:
4472 case AArch64::LD3Threev16b_POST:
4473 case AArch64::LD3Threev2d_POST:
4474 case AArch64::LD3Threev2s_POST:
4475 case AArch64::LD3Threev4h_POST:
4476 case AArch64::LD3Threev4s_POST:
4477 case AArch64::LD3Threev8b_POST:
4478 case AArch64::LD3Threev8h_POST:
4479 case AArch64::LD3i16_POST:
4480 case AArch64::LD3i32_POST:
4481 case AArch64::LD3i64_POST:
4482 case AArch64::LD3i8_POST:
4483 case AArch64::LD4Fourv16b_POST:
4484 case AArch64::LD4Fourv2d_POST:
4485 case AArch64::LD4Fourv2s_POST:
4486 case AArch64::LD4Fourv4h_POST:
4487 case AArch64::LD4Fourv4s_POST:
4488 case AArch64::LD4Fourv8b_POST:
4489 case AArch64::LD4Fourv8h_POST:
4490 case AArch64::LD4Rv16b_POST:
4491 case AArch64::LD4Rv1d_POST:
4492 case AArch64::LD4Rv2d_POST:
4493 case AArch64::LD4Rv2s_POST:
4494 case AArch64::LD4Rv4h_POST:
4495 case AArch64::LD4Rv4s_POST:
4496 case AArch64::LD4Rv8b_POST:
4497 case AArch64::LD4Rv8h_POST:
4498 case AArch64::LD4i16_POST:
4499 case AArch64::LD4i32_POST:
4500 case AArch64::LD4i64_POST:
4501 case AArch64::LD4i8_POST:
4502 case AArch64::LDAPRWpost:
4503 case AArch64::LDAPRXpost:
4504 case AArch64::LDIAPPWpost:
4505 case AArch64::LDIAPPXpost:
4506 case AArch64::LDPDpost:
4507 case AArch64::LDPQpost:
4508 case AArch64::LDPSWpost:
4509 case AArch64::LDPSpost:
4510 case AArch64::LDPWpost:
4511 case AArch64::LDPXpost:
4512 case AArch64::LDRBBpost:
4513 case AArch64::LDRBpost:
4514 case AArch64::LDRDpost:
4515 case AArch64::LDRHHpost:
4516 case AArch64::LDRHpost:
4517 case AArch64::LDRQpost:
4518 case AArch64::LDRSBWpost:
4519 case AArch64::LDRSBXpost:
4520 case AArch64::LDRSHWpost:
4521 case AArch64::LDRSHXpost:
4522 case AArch64::LDRSWpost:
4523 case AArch64::LDRSpost:
4524 case AArch64::LDRWpost:
4525 case AArch64::LDRXpost:
4526 case AArch64::ST1Fourv16b_POST:
4527 case AArch64::ST1Fourv1d_POST:
4528 case AArch64::ST1Fourv2d_POST:
4529 case AArch64::ST1Fourv2s_POST:
4530 case AArch64::ST1Fourv4h_POST:
4531 case AArch64::ST1Fourv4s_POST:
4532 case AArch64::ST1Fourv8b_POST:
4533 case AArch64::ST1Fourv8h_POST:
4534 case AArch64::ST1Onev16b_POST:
4535 case AArch64::ST1Onev1d_POST:
4536 case AArch64::ST1Onev2d_POST:
4537 case AArch64::ST1Onev2s_POST:
4538 case AArch64::ST1Onev4h_POST:
4539 case AArch64::ST1Onev4s_POST:
4540 case AArch64::ST1Onev8b_POST:
4541 case AArch64::ST1Onev8h_POST:
4542 case AArch64::ST1Threev16b_POST:
4543 case AArch64::ST1Threev1d_POST:
4544 case AArch64::ST1Threev2d_POST:
4545 case AArch64::ST1Threev2s_POST:
4546 case AArch64::ST1Threev4h_POST:
4547 case AArch64::ST1Threev4s_POST:
4548 case AArch64::ST1Threev8b_POST:
4549 case AArch64::ST1Threev8h_POST:
4550 case AArch64::ST1Twov16b_POST:
4551 case AArch64::ST1Twov1d_POST:
4552 case AArch64::ST1Twov2d_POST:
4553 case AArch64::ST1Twov2s_POST:
4554 case AArch64::ST1Twov4h_POST:
4555 case AArch64::ST1Twov4s_POST:
4556 case AArch64::ST1Twov8b_POST:
4557 case AArch64::ST1Twov8h_POST:
4558 case AArch64::ST1i16_POST:
4559 case AArch64::ST1i32_POST:
4560 case AArch64::ST1i64_POST:
4561 case AArch64::ST1i8_POST:
4562 case AArch64::ST2GPostIndex:
4563 case AArch64::ST2Twov16b_POST:
4564 case AArch64::ST2Twov2d_POST:
4565 case AArch64::ST2Twov2s_POST:
4566 case AArch64::ST2Twov4h_POST:
4567 case AArch64::ST2Twov4s_POST:
4568 case AArch64::ST2Twov8b_POST:
4569 case AArch64::ST2Twov8h_POST:
4570 case AArch64::ST2i16_POST:
4571 case AArch64::ST2i32_POST:
4572 case AArch64::ST2i64_POST:
4573 case AArch64::ST2i8_POST:
4574 case AArch64::ST3Threev16b_POST:
4575 case AArch64::ST3Threev2d_POST:
4576 case AArch64::ST3Threev2s_POST:
4577 case AArch64::ST3Threev4h_POST:
4578 case AArch64::ST3Threev4s_POST:
4579 case AArch64::ST3Threev8b_POST:
4580 case AArch64::ST3Threev8h_POST:
4581 case AArch64::ST3i16_POST:
4582 case AArch64::ST3i32_POST:
4583 case AArch64::ST3i64_POST:
4584 case AArch64::ST3i8_POST:
4585 case AArch64::ST4Fourv16b_POST:
4586 case AArch64::ST4Fourv2d_POST:
4587 case AArch64::ST4Fourv2s_POST:
4588 case AArch64::ST4Fourv4h_POST:
4589 case AArch64::ST4Fourv4s_POST:
4590 case AArch64::ST4Fourv8b_POST:
4591 case AArch64::ST4Fourv8h_POST:
4592 case AArch64::ST4i16_POST:
4593 case AArch64::ST4i32_POST:
4594 case AArch64::ST4i64_POST:
4595 case AArch64::ST4i8_POST:
4596 case AArch64::STGPostIndex:
4597 case AArch64::STGPpost:
4598 case AArch64::STPDpost:
4599 case AArch64::STPQpost:
4600 case AArch64::STPSpost:
4601 case AArch64::STPWpost:
4602 case AArch64::STPXpost:
4603 case AArch64::STRBBpost:
4604 case AArch64::STRBpost:
4605 case AArch64::STRDpost:
4606 case AArch64::STRHHpost:
4607 case AArch64::STRHpost:
4608 case AArch64::STRQpost:
4609 case AArch64::STRSpost:
4610 case AArch64::STRWpost:
4611 case AArch64::STRXpost:
4612 case AArch64::STZ2GPostIndex:
4613 case AArch64::STZGPostIndex:
4620 bool &OffsetIsScalable,
TypeSize &Width,
4641 int64_t Dummy1, Dummy2;
4663 return BaseOp->
isReg() || BaseOp->
isFI();
4670 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4675 TypeSize &Width, int64_t &MinOffset,
4676 int64_t &MaxOffset) {
4681 MinOffset = MaxOffset = 0;
4684 case AArch64::LDRQui:
4685 case AArch64::STRQui:
4690 case AArch64::LDRXui:
4691 case AArch64::LDRDui:
4692 case AArch64::STRXui:
4693 case AArch64::STRDui:
4694 case AArch64::PRFMui:
4699 case AArch64::LDRWui:
4700 case AArch64::LDRSui:
4701 case AArch64::LDRSWui:
4702 case AArch64::STRWui:
4703 case AArch64::STRSui:
4708 case AArch64::LDRHui:
4709 case AArch64::LDRHHui:
4710 case AArch64::LDRSHWui:
4711 case AArch64::LDRSHXui:
4712 case AArch64::STRHui:
4713 case AArch64::STRHHui:
4718 case AArch64::LDRBui:
4719 case AArch64::LDRBBui:
4720 case AArch64::LDRSBWui:
4721 case AArch64::LDRSBXui:
4722 case AArch64::STRBui:
4723 case AArch64::STRBBui:
4729 case AArch64::STRQpre:
4730 case AArch64::LDRQpost:
4736 case AArch64::LDRDpost:
4737 case AArch64::LDRDpre:
4738 case AArch64::LDRXpost:
4739 case AArch64::LDRXpre:
4740 case AArch64::STRDpost:
4741 case AArch64::STRDpre:
4742 case AArch64::STRXpost:
4743 case AArch64::STRXpre:
4749 case AArch64::STRWpost:
4750 case AArch64::STRWpre:
4751 case AArch64::LDRWpost:
4752 case AArch64::LDRWpre:
4753 case AArch64::STRSpost:
4754 case AArch64::STRSpre:
4755 case AArch64::LDRSpost:
4756 case AArch64::LDRSpre:
4762 case AArch64::LDRHpost:
4763 case AArch64::LDRHpre:
4764 case AArch64::STRHpost:
4765 case AArch64::STRHpre:
4766 case AArch64::LDRHHpost:
4767 case AArch64::LDRHHpre:
4768 case AArch64::STRHHpost:
4769 case AArch64::STRHHpre:
4775 case AArch64::LDRBpost:
4776 case AArch64::LDRBpre:
4777 case AArch64::STRBpost:
4778 case AArch64::STRBpre:
4779 case AArch64::LDRBBpost:
4780 case AArch64::LDRBBpre:
4781 case AArch64::STRBBpost:
4782 case AArch64::STRBBpre:
4788 case AArch64::LDURQi:
4789 case AArch64::STURQi:
4795 case AArch64::LDURXi:
4796 case AArch64::LDURDi:
4797 case AArch64::LDAPURXi:
4798 case AArch64::STURXi:
4799 case AArch64::STURDi:
4800 case AArch64::STLURXi:
4801 case AArch64::PRFUMi:
4807 case AArch64::LDURWi:
4808 case AArch64::LDURSi:
4809 case AArch64::LDURSWi:
4810 case AArch64::LDAPURi:
4811 case AArch64::LDAPURSWi:
4812 case AArch64::STURWi:
4813 case AArch64::STURSi:
4814 case AArch64::STLURWi:
4820 case AArch64::LDURHi:
4821 case AArch64::LDURHHi:
4822 case AArch64::LDURSHXi:
4823 case AArch64::LDURSHWi:
4824 case AArch64::LDAPURHi:
4825 case AArch64::LDAPURSHWi:
4826 case AArch64::LDAPURSHXi:
4827 case AArch64::STURHi:
4828 case AArch64::STURHHi:
4829 case AArch64::STLURHi:
4835 case AArch64::LDURBi:
4836 case AArch64::LDURBBi:
4837 case AArch64::LDURSBXi:
4838 case AArch64::LDURSBWi:
4839 case AArch64::LDAPURBi:
4840 case AArch64::LDAPURSBWi:
4841 case AArch64::LDAPURSBXi:
4842 case AArch64::STURBi:
4843 case AArch64::STURBBi:
4844 case AArch64::STLURBi:
4850 case AArch64::LDPQi:
4851 case AArch64::LDNPQi:
4852 case AArch64::STPQi:
4853 case AArch64::STNPQi:
4854 case AArch64::LDPQpost:
4855 case AArch64::LDPQpre:
4856 case AArch64::STPQpost:
4857 case AArch64::STPQpre:
4863 case AArch64::LDPXi:
4864 case AArch64::LDPDi:
4865 case AArch64::LDNPXi:
4866 case AArch64::LDNPDi:
4867 case AArch64::STPXi:
4868 case AArch64::STPDi:
4869 case AArch64::STNPXi:
4870 case AArch64::STNPDi:
4871 case AArch64::LDPDpost:
4872 case AArch64::LDPDpre:
4873 case AArch64::LDPXpost:
4874 case AArch64::LDPXpre:
4875 case AArch64::STPDpost:
4876 case AArch64::STPDpre:
4877 case AArch64::STPXpost:
4878 case AArch64::STPXpre:
4884 case AArch64::LDPWi:
4885 case AArch64::LDPSi:
4886 case AArch64::LDNPWi:
4887 case AArch64::LDNPSi:
4888 case AArch64::STPWi:
4889 case AArch64::STPSi:
4890 case AArch64::STNPWi:
4891 case AArch64::STNPSi:
4892 case AArch64::LDPSpost:
4893 case AArch64::LDPSpre:
4894 case AArch64::LDPWpost:
4895 case AArch64::LDPWpre:
4896 case AArch64::STPSpost:
4897 case AArch64::STPSpre:
4898 case AArch64::STPWpost:
4899 case AArch64::STPWpre:
4905 case AArch64::StoreSwiftAsyncContext:
4918 case AArch64::TAGPstack:
4928 case AArch64::STGPreIndex:
4929 case AArch64::STGPostIndex:
4930 case AArch64::STZGi:
4931 case AArch64::STZGPreIndex:
4932 case AArch64::STZGPostIndex:
4938 case AArch64::STR_ZZZZXI:
4939 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4940 case AArch64::LDR_ZZZZXI:
4941 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4947 case AArch64::STR_ZZZXI:
4948 case AArch64::LDR_ZZZXI:
4954 case AArch64::STR_ZZXI:
4955 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4956 case AArch64::LDR_ZZXI:
4957 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
4963 case AArch64::LDR_PXI:
4964 case AArch64::STR_PXI:
4969 case AArch64::LDR_PPXI:
4970 case AArch64::STR_PPXI:
4976 case AArch64::LDR_ZXI:
4977 case AArch64::STR_ZXI:
4982 case AArch64::LD1B_IMM:
4983 case AArch64::LD1H_IMM:
4984 case AArch64::LD1W_IMM:
4985 case AArch64::LD1D_IMM:
4986 case AArch64::LDNT1B_ZRI:
4987 case AArch64::LDNT1H_ZRI:
4988 case AArch64::LDNT1W_ZRI:
4989 case AArch64::LDNT1D_ZRI:
4990 case AArch64::ST1B_IMM:
4991 case AArch64::ST1H_IMM:
4992 case AArch64::ST1W_IMM:
4993 case AArch64::ST1D_IMM:
4994 case AArch64::STNT1B_ZRI:
4995 case AArch64::STNT1H_ZRI:
4996 case AArch64::STNT1W_ZRI:
4997 case AArch64::STNT1D_ZRI:
4998 case AArch64::LDNF1B_IMM:
4999 case AArch64::LDNF1H_IMM:
5000 case AArch64::LDNF1W_IMM:
5001 case AArch64::LDNF1D_IMM:
5008 case AArch64::LD2B_IMM:
5009 case AArch64::LD2H_IMM:
5010 case AArch64::LD2W_IMM:
5011 case AArch64::LD2D_IMM:
5012 case AArch64::ST2B_IMM:
5013 case AArch64::ST2H_IMM:
5014 case AArch64::ST2W_IMM:
5015 case AArch64::ST2D_IMM:
5016 case AArch64::LD1B_2Z_IMM:
5017 case AArch64::LD1B_2Z_STRIDED_IMM:
5018 case AArch64::LD1H_2Z_IMM:
5019 case AArch64::LD1H_2Z_STRIDED_IMM:
5020 case AArch64::LD1W_2Z_IMM:
5021 case AArch64::LD1W_2Z_STRIDED_IMM:
5022 case AArch64::LD1D_2Z_IMM:
5023 case AArch64::LD1D_2Z_STRIDED_IMM:
5024 case AArch64::LD1B_2Z_IMM_PSEUDO:
5025 case AArch64::LD1H_2Z_IMM_PSEUDO:
5026 case AArch64::LD1W_2Z_IMM_PSEUDO:
5027 case AArch64::LD1D_2Z_IMM_PSEUDO:
5028 case AArch64::ST1B_2Z_IMM:
5029 case AArch64::ST1B_2Z_STRIDED_IMM:
5030 case AArch64::ST1H_2Z_IMM:
5031 case AArch64::ST1H_2Z_STRIDED_IMM:
5032 case AArch64::ST1W_2Z_IMM:
5033 case AArch64::ST1W_2Z_STRIDED_IMM:
5034 case AArch64::ST1D_2Z_IMM:
5035 case AArch64::ST1D_2Z_STRIDED_IMM:
5036 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5037 case AArch64::LDNT1B_2Z_IMM:
5038 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5039 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5040 case AArch64::LDNT1H_2Z_IMM:
5041 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5042 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5043 case AArch64::LDNT1W_2Z_IMM:
5044 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5045 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5046 case AArch64::LDNT1D_2Z_IMM:
5047 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5048 case AArch64::STNT1B_2Z_IMM:
5049 case AArch64::STNT1B_2Z_STRIDED_IMM:
5050 case AArch64::STNT1H_2Z_IMM:
5051 case AArch64::STNT1H_2Z_STRIDED_IMM:
5052 case AArch64::STNT1W_2Z_IMM:
5053 case AArch64::STNT1W_2Z_STRIDED_IMM:
5054 case AArch64::STNT1D_2Z_IMM:
5055 case AArch64::STNT1D_2Z_STRIDED_IMM:
5060 case AArch64::LD3B_IMM:
5061 case AArch64::LD3H_IMM:
5062 case AArch64::LD3W_IMM:
5063 case AArch64::LD3D_IMM:
5064 case AArch64::ST3B_IMM:
5065 case AArch64::ST3H_IMM:
5066 case AArch64::ST3W_IMM:
5067 case AArch64::ST3D_IMM:
5072 case AArch64::LD4B_IMM:
5073 case AArch64::LD4H_IMM:
5074 case AArch64::LD4W_IMM:
5075 case AArch64::LD4D_IMM:
5076 case AArch64::ST4B_IMM:
5077 case AArch64::ST4H_IMM:
5078 case AArch64::ST4W_IMM:
5079 case AArch64::ST4D_IMM:
5080 case AArch64::LD1B_4Z_IMM:
5081 case AArch64::LD1B_4Z_STRIDED_IMM:
5082 case AArch64::LD1H_4Z_IMM:
5083 case AArch64::LD1H_4Z_STRIDED_IMM:
5084 case AArch64::LD1W_4Z_IMM:
5085 case AArch64::LD1W_4Z_STRIDED_IMM:
5086 case AArch64::LD1D_4Z_IMM:
5087 case AArch64::LD1D_4Z_STRIDED_IMM:
5088 case AArch64::LD1B_4Z_IMM_PSEUDO:
5089 case AArch64::LD1H_4Z_IMM_PSEUDO:
5090 case AArch64::LD1W_4Z_IMM_PSEUDO:
5091 case AArch64::LD1D_4Z_IMM_PSEUDO:
5092 case AArch64::ST1B_4Z_IMM:
5093 case AArch64::ST1B_4Z_STRIDED_IMM:
5094 case AArch64::ST1H_4Z_IMM:
5095 case AArch64::ST1H_4Z_STRIDED_IMM:
5096 case AArch64::ST1W_4Z_IMM:
5097 case AArch64::ST1W_4Z_STRIDED_IMM:
5098 case AArch64::ST1D_4Z_IMM:
5099 case AArch64::ST1D_4Z_STRIDED_IMM:
5100 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5101 case AArch64::LDNT1B_4Z_IMM:
5102 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5103 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5104 case AArch64::LDNT1H_4Z_IMM:
5105 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5106 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5107 case AArch64::LDNT1W_4Z_IMM:
5108 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5109 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5110 case AArch64::LDNT1D_4Z_IMM:
5111 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5112 case AArch64::STNT1B_4Z_IMM:
5113 case AArch64::STNT1B_4Z_STRIDED_IMM:
5114 case AArch64::STNT1H_4Z_IMM:
5115 case AArch64::STNT1H_4Z_STRIDED_IMM:
5116 case AArch64::STNT1W_4Z_IMM:
5117 case AArch64::STNT1W_4Z_STRIDED_IMM:
5118 case AArch64::STNT1D_4Z_IMM:
5119 case AArch64::STNT1D_4Z_STRIDED_IMM:
5124 case AArch64::LD1B_H_IMM:
5125 case AArch64::LD1SB_H_IMM:
5126 case AArch64::LD1H_S_IMM:
5127 case AArch64::LD1SH_S_IMM:
5128 case AArch64::LD1W_D_IMM:
5129 case AArch64::LD1SW_D_IMM:
5130 case AArch64::ST1B_H_IMM:
5131 case AArch64::ST1H_S_IMM:
5132 case AArch64::ST1W_D_IMM:
5133 case AArch64::LDNF1B_H_IMM:
5134 case AArch64::LDNF1SB_H_IMM:
5135 case AArch64::LDNF1H_S_IMM:
5136 case AArch64::LDNF1SH_S_IMM:
5137 case AArch64::LDNF1W_D_IMM:
5138 case AArch64::LDNF1SW_D_IMM:
5145 case AArch64::LD1B_S_IMM:
5146 case AArch64::LD1SB_S_IMM:
5147 case AArch64::LD1H_D_IMM:
5148 case AArch64::LD1SH_D_IMM:
5149 case AArch64::ST1B_S_IMM:
5150 case AArch64::ST1H_D_IMM:
5151 case AArch64::LDNF1B_S_IMM:
5152 case AArch64::LDNF1SB_S_IMM:
5153 case AArch64::LDNF1H_D_IMM:
5154 case AArch64::LDNF1SH_D_IMM:
5161 case AArch64::LD1B_D_IMM:
5162 case AArch64::LD1SB_D_IMM:
5163 case AArch64::ST1B_D_IMM:
5164 case AArch64::LDNF1B_D_IMM:
5165 case AArch64::LDNF1SB_D_IMM:
5172 case AArch64::ST2Gi:
5173 case AArch64::ST2GPreIndex:
5174 case AArch64::ST2GPostIndex:
5175 case AArch64::STZ2Gi:
5176 case AArch64::STZ2GPreIndex:
5177 case AArch64::STZ2GPostIndex:
5183 case AArch64::STGPi:
5184 case AArch64::STGPpost:
5185 case AArch64::STGPpre:
5190 case AArch64::LD1RB_IMM:
5191 case AArch64::LD1RB_H_IMM:
5192 case AArch64::LD1RB_S_IMM:
5193 case AArch64::LD1RB_D_IMM:
5194 case AArch64::LD1RSB_H_IMM:
5195 case AArch64::LD1RSB_S_IMM:
5196 case AArch64::LD1RSB_D_IMM:
5201 case AArch64::LD1RH_IMM:
5202 case AArch64::LD1RH_S_IMM:
5203 case AArch64::LD1RH_D_IMM:
5204 case AArch64::LD1RSH_S_IMM:
5205 case AArch64::LD1RSH_D_IMM:
5210 case AArch64::LD1RW_IMM:
5211 case AArch64::LD1RW_D_IMM:
5212 case AArch64::LD1RSW_IMM:
5217 case AArch64::LD1RD_IMM:
5232 case AArch64::LDRBui:
5233 case AArch64::LDRBBui:
5234 case AArch64::LDURBBi:
5235 case AArch64::LDRSBWui:
5236 case AArch64::LDURSBWi:
5237 case AArch64::STRBui:
5238 case AArch64::STRBBui:
5239 case AArch64::STURBBi:
5241 case AArch64::LDRHui:
5242 case AArch64::LDRHHui:
5243 case AArch64::LDURHHi:
5244 case AArch64::LDRSHWui:
5245 case AArch64::LDURSHWi:
5246 case AArch64::STRHui:
5247 case AArch64::STRHHui:
5248 case AArch64::STURHHi:
5250 case AArch64::LDRSui:
5251 case AArch64::LDURSi:
5252 case AArch64::LDRSpre:
5253 case AArch64::LDRSWui:
5254 case AArch64::LDURSWi:
5255 case AArch64::LDRSWpre:
5256 case AArch64::LDRWpre:
5257 case AArch64::LDRWui:
5258 case AArch64::LDURWi:
5259 case AArch64::STRSui:
5260 case AArch64::STURSi:
5261 case AArch64::STRSpre:
5262 case AArch64::STRWui:
5263 case AArch64::STURWi:
5264 case AArch64::STRWpre:
5265 case AArch64::LDPSi:
5266 case AArch64::LDPSWi:
5267 case AArch64::LDPWi:
5268 case AArch64::STPSi:
5269 case AArch64::STPWi:
5271 case AArch64::LDRDui:
5272 case AArch64::LDURDi:
5273 case AArch64::LDRDpre:
5274 case AArch64::LDRXui:
5275 case AArch64::LDURXi:
5276 case AArch64::LDRXpre:
5277 case AArch64::STRDui:
5278 case AArch64::STURDi:
5279 case AArch64::STRDpre:
5280 case AArch64::STRXui:
5281 case AArch64::STURXi:
5282 case AArch64::STRXpre:
5283 case AArch64::LDPDi:
5284 case AArch64::LDPXi:
5285 case AArch64::STPDi:
5286 case AArch64::STPXi:
5288 case AArch64::LDRQui:
5289 case AArch64::LDURQi:
5290 case AArch64::STRQui:
5291 case AArch64::STURQi:
5292 case AArch64::STRQpre:
5293 case AArch64::LDPQi:
5294 case AArch64::LDRQpre:
5295 case AArch64::STPQi:
5297 case AArch64::STZGi:
5298 case AArch64::ST2Gi:
5299 case AArch64::STZ2Gi:
5300 case AArch64::STGPi:
5306 switch (
MI.getOpcode()) {
5309 case AArch64::LDRWpre:
5310 case AArch64::LDRXpre:
5311 case AArch64::LDRSWpre:
5312 case AArch64::LDRSpre:
5313 case AArch64::LDRDpre:
5314 case AArch64::LDRQpre:
5320 switch (
MI.getOpcode()) {
5323 case AArch64::STRWpre:
5324 case AArch64::STRXpre:
5325 case AArch64::STRSpre:
5326 case AArch64::STRDpre:
5327 case AArch64::STRQpre:
5337 switch (
MI.getOpcode()) {
5340 case AArch64::LDURBBi:
5341 case AArch64::LDURHHi:
5342 case AArch64::LDURWi:
5343 case AArch64::LDRBBui:
5344 case AArch64::LDRHHui:
5345 case AArch64::LDRWui:
5346 case AArch64::LDRBBroX:
5347 case AArch64::LDRHHroX:
5348 case AArch64::LDRWroX:
5349 case AArch64::LDRBBroW:
5350 case AArch64::LDRHHroW:
5351 case AArch64::LDRWroW:
5357 switch (
MI.getOpcode()) {
5360 case AArch64::LDURSBWi:
5361 case AArch64::LDURSHWi:
5362 case AArch64::LDURSBXi:
5363 case AArch64::LDURSHXi:
5364 case AArch64::LDURSWi:
5365 case AArch64::LDRSBWui:
5366 case AArch64::LDRSHWui:
5367 case AArch64::LDRSBXui:
5368 case AArch64::LDRSHXui:
5369 case AArch64::LDRSWui:
5370 case AArch64::LDRSBWroX:
5371 case AArch64::LDRSHWroX:
5372 case AArch64::LDRSBXroX:
5373 case AArch64::LDRSHXroX:
5374 case AArch64::LDRSWroX:
5375 case AArch64::LDRSBWroW:
5376 case AArch64::LDRSHWroW:
5377 case AArch64::LDRSBXroW:
5378 case AArch64::LDRSHXroW:
5379 case AArch64::LDRSWroW:
5385 switch (
MI.getOpcode()) {
5388 case AArch64::LDPSi:
5389 case AArch64::LDPSWi:
5390 case AArch64::LDPDi:
5391 case AArch64::LDPQi:
5392 case AArch64::LDPWi:
5393 case AArch64::LDPXi:
5394 case AArch64::STPSi:
5395 case AArch64::STPDi:
5396 case AArch64::STPQi:
5397 case AArch64::STPWi:
5398 case AArch64::STPXi:
5399 case AArch64::STGPi:
5405 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5409 return MI.getOperand(Idx);
5414 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5418 return MI.getOperand(Idx);
5423 switch (
MI.getOpcode()) {
5426 case AArch64::LDRBroX:
5427 case AArch64::LDRBBroX:
5428 case AArch64::LDRSBXroX:
5429 case AArch64::LDRSBWroX:
5430 case AArch64::LDRHroX:
5431 case AArch64::LDRHHroX:
5432 case AArch64::LDRSHXroX:
5433 case AArch64::LDRSHWroX:
5434 case AArch64::LDRWroX:
5435 case AArch64::LDRSroX:
5436 case AArch64::LDRSWroX:
5437 case AArch64::LDRDroX:
5438 case AArch64::LDRXroX:
5439 case AArch64::LDRQroX:
5440 return MI.getOperand(4);
5446 if (
MI.getParent() ==
nullptr)
5456 auto Reg =
Op.getReg();
5457 if (Reg.isPhysical())
5458 return AArch64::FPR16RegClass.contains(Reg);
5460 return TRC == &AArch64::FPR16RegClass ||
5461 TRC == &AArch64::FPR16_loRegClass;
5470 auto Reg =
Op.getReg();
5471 if (Reg.isPhysical())
5472 return AArch64::FPR128RegClass.contains(Reg);
5474 return TRC == &AArch64::FPR128RegClass ||
5475 TRC == &AArch64::FPR128_loRegClass;
5481 switch (
MI.getOpcode()) {
5484 case AArch64::PACIASP:
5485 case AArch64::PACIBSP:
5488 case AArch64::PAUTH_PROLOGUE:
5491 case AArch64::HINT: {
5492 unsigned Imm =
MI.getOperand(0).getImm();
5494 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
5497 if (Imm == 25 || Imm == 27)
5509 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5510 return AArch64::FPR128RegClass.contains(Reg) ||
5511 AArch64::FPR64RegClass.contains(Reg) ||
5512 AArch64::FPR32RegClass.contains(Reg) ||
5513 AArch64::FPR16RegClass.contains(Reg) ||
5514 AArch64::FPR8RegClass.contains(Reg);
5521 auto Reg =
Op.getReg();
5522 if (Reg.isPhysical())
5526 return TRC == &AArch64::FPR128RegClass ||
5527 TRC == &AArch64::FPR128_loRegClass ||
5528 TRC == &AArch64::FPR64RegClass ||
5529 TRC == &AArch64::FPR64_loRegClass ||
5530 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5531 TRC == &AArch64::FPR8RegClass;
5553 if (FirstOpc == SecondOpc)
5559 case AArch64::STRSui:
5560 case AArch64::STURSi:
5561 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5562 case AArch64::STRDui:
5563 case AArch64::STURDi:
5564 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5565 case AArch64::STRQui:
5566 case AArch64::STURQi:
5567 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5568 case AArch64::STRWui:
5569 case AArch64::STURWi:
5570 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5571 case AArch64::STRXui:
5572 case AArch64::STURXi:
5573 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5574 case AArch64::LDRSui:
5575 case AArch64::LDURSi:
5576 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5577 case AArch64::LDRDui:
5578 case AArch64::LDURDi:
5579 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5580 case AArch64::LDRQui:
5581 case AArch64::LDURQi:
5582 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5583 case AArch64::LDRWui:
5584 case AArch64::LDURWi:
5585 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5586 case AArch64::LDRSWui:
5587 case AArch64::LDURSWi:
5588 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5589 case AArch64::LDRXui:
5590 case AArch64::LDURXi:
5591 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5598 int64_t Offset1,
unsigned Opcode1,
int FI2,
5599 int64_t Offset2,
unsigned Opcode2) {
5605 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5608 if (ObjectOffset1 % Scale1 != 0)
5610 ObjectOffset1 /= Scale1;
5612 if (ObjectOffset2 % Scale2 != 0)
5614 ObjectOffset2 /= Scale2;
5615 ObjectOffset1 += Offset1;
5616 ObjectOffset2 += Offset2;
5617 return ObjectOffset1 + 1 == ObjectOffset2;
5629 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5630 unsigned NumBytes)
const {
5640 "Only base registers and frame indices are supported.");
5647 if (ClusterSize > 2)
5654 unsigned FirstOpc = FirstLdSt.
getOpcode();
5655 unsigned SecondOpc = SecondLdSt.
getOpcode();
5675 if (Offset1 > 63 || Offset1 < -64)
5680 if (BaseOp1.
isFI()) {
5682 "Caller should have ordered offsets.");
5687 BaseOp2.
getIndex(), Offset2, SecondOpc);
5690 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5692 return Offset1 + 1 == Offset2;
5702 if (
Reg.isPhysical())
5711 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
5720 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5722 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5723 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5724 unsigned NumRegs = Indices.
size();
5726 int SubReg = 0, End = NumRegs, Incr = 1;
5728 SubReg = NumRegs - 1;
5733 for (; SubReg != End; SubReg += Incr) {
5745 unsigned Opcode,
unsigned ZeroReg,
5748 unsigned NumRegs = Indices.
size();
5751 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5752 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5753 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5754 "GPR reg sequences should not be able to overlap");
5757 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5778 unsigned Opc =
MI.getOpcode();
5779 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5781 int64_t PState =
MI.getOperand(0).getImm();
5782 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5784 return MI.getOperand(1).getImm() == 1;
5803 bool RenamableSrc)
const {
5805 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5806 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5807 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5809 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5810 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5812 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5813 &AArch64::GPR64spRegClass);
5814 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5815 &AArch64::GPR64spRegClass);
5825 ++NumZCRegMoveInstrsGPR;
5831 if (Subtarget.hasZeroCycleRegMoveGPR32())
5832 ++NumZCRegMoveInstrsGPR;
5834 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5835 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5837 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5838 &AArch64::GPR64spRegClass);
5839 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5840 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5841 &AArch64::GPR64spRegClass);
5851 ++NumZCRegMoveInstrsGPR;
5857 if (Subtarget.hasZeroCycleRegMoveGPR32())
5858 ++NumZCRegMoveInstrsGPR;
5864 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5865 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5866 !Subtarget.hasZeroCycleZeroingGPR32()) {
5867 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5868 &AArch64::GPR64spRegClass);
5869 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5873 ++NumZCZeroingInstrsGPR;
5874 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5878 ++NumZCZeroingInstrsGPR;
5887 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5888 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5889 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5895 if (Subtarget.hasZeroCycleRegMoveGPR64())
5896 ++NumZCRegMoveInstrsGPR;
5902 if (Subtarget.hasZeroCycleRegMoveGPR64())
5903 ++NumZCRegMoveInstrsGPR;
5909 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5910 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5914 ++NumZCZeroingInstrsGPR;
5924 if (AArch64::PPRRegClass.
contains(DestReg) &&
5925 AArch64::PPRRegClass.
contains(SrcReg)) {
5926 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5927 "Unexpected SVE register.");
5937 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5938 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5939 if (DestIsPNR || SrcIsPNR) {
5941 return (R - AArch64::PN0) + AArch64::P0;
5946 if (PPRSrcReg != PPRDestReg) {
5958 if (AArch64::ZPRRegClass.
contains(DestReg) &&
5959 AArch64::ZPRRegClass.
contains(SrcReg)) {
5960 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5961 "Unexpected SVE register.");
5969 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
5970 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
5971 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
5972 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
5973 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5974 "Unexpected SVE register.");
5975 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
5982 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
5983 AArch64::ZPR3RegClass.
contains(SrcReg)) {
5984 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5985 "Unexpected SVE register.");
5986 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
5994 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
5995 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
5996 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
5997 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
5998 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5999 "Unexpected SVE register.");
6000 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6001 AArch64::zsub2, AArch64::zsub3};
6008 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6009 AArch64::DDDDRegClass.
contains(SrcReg)) {
6010 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6011 AArch64::dsub2, AArch64::dsub3};
6018 if (AArch64::DDDRegClass.
contains(DestReg) &&
6019 AArch64::DDDRegClass.
contains(SrcReg)) {
6020 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6028 if (AArch64::DDRegClass.
contains(DestReg) &&
6029 AArch64::DDRegClass.
contains(SrcReg)) {
6030 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6037 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6038 AArch64::QQQQRegClass.
contains(SrcReg)) {
6039 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6040 AArch64::qsub2, AArch64::qsub3};
6047 if (AArch64::QQQRegClass.
contains(DestReg) &&
6048 AArch64::QQQRegClass.
contains(SrcReg)) {
6049 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6057 if (AArch64::QQRegClass.
contains(DestReg) &&
6058 AArch64::QQRegClass.
contains(SrcReg)) {
6059 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6065 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6066 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6067 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6069 AArch64::XZR, Indices);
6073 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6074 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6075 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6077 AArch64::WZR, Indices);
6081 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6082 AArch64::FPR128RegClass.
contains(SrcReg)) {
6086 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6087 !Subtarget.isNeonAvailable()) ||
6091 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6092 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6093 }
else if (Subtarget.isNeonAvailable()) {
6097 if (Subtarget.hasZeroCycleRegMoveFPR128())
6098 ++NumZCRegMoveInstrsFPR;
6114 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6115 AArch64::FPR64RegClass.
contains(SrcReg)) {
6116 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6117 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6118 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6120 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6121 &AArch64::FPR128RegClass);
6122 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6123 &AArch64::FPR128RegClass);
6132 ++NumZCRegMoveInstrsFPR;
6136 if (Subtarget.hasZeroCycleRegMoveFPR64())
6137 ++NumZCRegMoveInstrsFPR;
6142 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6143 AArch64::FPR32RegClass.
contains(SrcReg)) {
6144 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6145 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6146 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6148 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6149 &AArch64::FPR128RegClass);
6150 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6151 &AArch64::FPR128RegClass);
6160 ++NumZCRegMoveInstrsFPR;
6161 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6162 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6163 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6164 &AArch64::FPR64RegClass);
6165 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6166 &AArch64::FPR64RegClass);
6174 ++NumZCRegMoveInstrsFPR;
6178 if (Subtarget.hasZeroCycleRegMoveFPR32())
6179 ++NumZCRegMoveInstrsFPR;
6184 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6185 AArch64::FPR16RegClass.
contains(SrcReg)) {
6186 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6187 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6188 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6190 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6191 &AArch64::FPR128RegClass);
6192 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6193 &AArch64::FPR128RegClass);
6202 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6203 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6204 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6205 &AArch64::FPR64RegClass);
6206 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6207 &AArch64::FPR64RegClass);
6216 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6217 &AArch64::FPR32RegClass);
6218 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6219 &AArch64::FPR32RegClass);
6226 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6227 AArch64::FPR8RegClass.
contains(SrcReg)) {
6228 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6229 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6230 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6232 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6233 &AArch64::FPR128RegClass);
6234 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6235 &AArch64::FPR128RegClass);
6244 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6245 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6246 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6247 &AArch64::FPR64RegClass);
6248 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6249 &AArch64::FPR64RegClass);
6258 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6259 &AArch64::FPR32RegClass);
6260 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6261 &AArch64::FPR32RegClass);
6269 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6270 AArch64::GPR64RegClass.
contains(SrcReg)) {
6271 if (AArch64::XZR == SrcReg) {
6279 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6280 AArch64::FPR64RegClass.
contains(SrcReg)) {
6286 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6287 AArch64::GPR32RegClass.
contains(SrcReg)) {
6288 if (AArch64::WZR == SrcReg) {
6296 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6297 AArch64::FPR32RegClass.
contains(SrcReg)) {
6303 if (DestReg == AArch64::NZCV) {
6304 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6306 .
addImm(AArch64SysReg::NZCV)
6312 if (SrcReg == AArch64::NZCV) {
6313 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6315 .
addImm(AArch64SysReg::NZCV)
6321 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6332 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6337 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6339 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6352 Register SrcReg,
bool isKill,
int FI,
6367 switch (RI.getSpillSize(*RC)) {
6369 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6370 Opc = AArch64::STRBui;
6373 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6374 Opc = AArch64::STRHui;
6375 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6376 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6377 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6378 "Unexpected register store without SVE store instructions");
6379 Opc = AArch64::STR_PXI;
6385 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6386 Opc = AArch64::STRWui;
6390 assert(SrcReg != AArch64::WSP);
6391 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6392 Opc = AArch64::STRSui;
6393 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6394 Opc = AArch64::STR_PPXI;
6399 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6400 Opc = AArch64::STRXui;
6404 assert(SrcReg != AArch64::SP);
6405 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6406 Opc = AArch64::STRDui;
6407 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6409 get(AArch64::STPWi), SrcReg, isKill,
6410 AArch64::sube32, AArch64::subo32, FI, MMO);
6415 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6416 Opc = AArch64::STRQui;
6417 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6418 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6419 Opc = AArch64::ST1Twov1d;
6421 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6423 get(AArch64::STPXi), SrcReg, isKill,
6424 AArch64::sube64, AArch64::subo64, FI, MMO);
6426 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6427 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6428 "Unexpected register store without SVE store instructions");
6429 Opc = AArch64::STR_ZXI;
6434 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6435 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6436 Opc = AArch64::ST1Threev1d;
6441 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6442 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6443 Opc = AArch64::ST1Fourv1d;
6445 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6446 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6447 Opc = AArch64::ST1Twov2d;
6449 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6450 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6451 "Unexpected register store without SVE store instructions");
6452 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6454 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6455 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6456 "Unexpected register store without SVE store instructions");
6457 Opc = AArch64::STR_ZZXI;
6462 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6463 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6464 Opc = AArch64::ST1Threev2d;
6466 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6467 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6468 "Unexpected register store without SVE store instructions");
6469 Opc = AArch64::STR_ZZZXI;
6474 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6475 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6476 Opc = AArch64::ST1Fourv2d;
6478 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6479 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6480 "Unexpected register store without SVE store instructions");
6481 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6483 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6484 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6485 "Unexpected register store without SVE store instructions");
6486 Opc = AArch64::STR_ZZZZXI;
6491 assert(
Opc &&
"Unknown register class");
6502 MI.addMemOperand(MMO);
6509 Register DestReg,
unsigned SubIdx0,
6510 unsigned SubIdx1,
int FI,
6514 bool IsUndef =
true;
6516 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6518 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6547 switch (
TRI.getSpillSize(*RC)) {
6549 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6550 Opc = AArch64::LDRBui;
6553 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6554 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6555 Opc = AArch64::LDRHui;
6556 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6557 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6558 "Unexpected register load without SVE load instructions");
6561 Opc = AArch64::LDR_PXI;
6567 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6568 Opc = AArch64::LDRWui;
6572 assert(DestReg != AArch64::WSP);
6573 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6574 Opc = AArch64::LDRSui;
6575 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6576 Opc = AArch64::LDR_PPXI;
6581 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6582 Opc = AArch64::LDRXui;
6586 assert(DestReg != AArch64::SP);
6587 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6588 Opc = AArch64::LDRDui;
6589 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6591 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6592 AArch64::subo32, FI, MMO);
6597 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6598 Opc = AArch64::LDRQui;
6599 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6600 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6601 Opc = AArch64::LD1Twov1d;
6603 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6605 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6606 AArch64::subo64, FI, MMO);
6608 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6609 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6610 "Unexpected register load without SVE load instructions");
6611 Opc = AArch64::LDR_ZXI;
6616 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6617 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6618 Opc = AArch64::LD1Threev1d;
6623 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6624 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6625 Opc = AArch64::LD1Fourv1d;
6627 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6628 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6629 Opc = AArch64::LD1Twov2d;
6631 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6632 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6633 "Unexpected register load without SVE load instructions");
6634 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6636 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6637 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6638 "Unexpected register load without SVE load instructions");
6639 Opc = AArch64::LDR_ZZXI;
6644 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6645 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6646 Opc = AArch64::LD1Threev2d;
6648 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6649 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6650 "Unexpected register load without SVE load instructions");
6651 Opc = AArch64::LDR_ZZZXI;
6656 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6657 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6658 Opc = AArch64::LD1Fourv2d;
6660 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6661 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6662 "Unexpected register load without SVE load instructions");
6663 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6665 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6666 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6667 "Unexpected register load without SVE load instructions");
6668 Opc = AArch64::LDR_ZZZZXI;
6674 assert(
Opc &&
"Unknown register class");
6684 MI.addMemOperand(MMO);
6691 UseMI.getIterator()),
6693 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6694 I.readsRegister(AArch64::NZCV, TRI);
6698void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6703 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6710 ByteSized =
Offset.getFixed();
6711 VGSized =
Offset.getScalable() / 2;
6717void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6719 int64_t &NumDataVectors) {
6723 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6725 NumBytes =
Offset.getFixed();
6727 NumPredicateVectors =
Offset.getScalable() / 2;
6732 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6733 NumPredicateVectors > 62) {
6734 NumDataVectors = NumPredicateVectors / 8;
6735 NumPredicateVectors -= NumDataVectors * 8;
6761 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6769 int64_t OffsetFromDefCFA) {
6783 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6784 if (!RegScale.empty())
6794 int64_t NumBytes, NumVGScaledBytes;
6795 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6797 std::string CommentBuffer;
6800 if (
Reg == AArch64::SP)
6802 else if (
Reg == AArch64::FP)
6809 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6810 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6812 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6815 if (NumVGScaledBytes) {
6825 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6833 unsigned FrameReg,
unsigned Reg,
6835 bool LastAdjustmentWasScalable) {
6836 if (
Offset.getScalable())
6839 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6842 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6849 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6850 int64_t NumBytes, NumVGScaledBytes;
6851 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6852 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6854 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6857 if (!NumVGScaledBytes)
6860 std::string CommentBuffer;
6865 assert(NumVGScaledBytes &&
"Expected scalable offset");
6869 if (IncomingVGOffsetFromDefCFA) {
6871 VGRegScale =
"* IncomingVG";
6874 VGRegScale =
"* VG";
6878 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6887 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6902 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6905 bool *HasWinCFI,
bool EmitCFAOffset,
6908 unsigned MaxEncoding, ShiftSize;
6910 case AArch64::ADDXri:
6911 case AArch64::ADDSXri:
6912 case AArch64::SUBXri:
6913 case AArch64::SUBSXri:
6914 MaxEncoding = 0xfff;
6917 case AArch64::ADDVL_XXI:
6918 case AArch64::ADDPL_XXI:
6919 case AArch64::ADDSVL_XXI:
6920 case AArch64::ADDSPL_XXI:
6935 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6937 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
6951 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
6953 if (TmpReg == AArch64::XZR)
6954 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
6955 &AArch64::GPR64RegClass);
6957 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
6958 unsigned LocalShiftSize = 0;
6959 if (ThisVal > MaxEncoding) {
6960 ThisVal = ThisVal >> ShiftSize;
6961 LocalShiftSize = ShiftSize;
6963 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
6964 "Encoding cannot handle value that big");
6966 Offset -= ThisVal << LocalShiftSize;
6971 .
addImm(Sign * (
int)ThisVal);
6981 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
6982 CFAOffset += Change;
6984 CFAOffset -= Change;
6985 if (EmitCFAOffset && DestReg == TmpReg) {
6998 int Imm = (int)(ThisVal << LocalShiftSize);
6999 if (VScale != 1 && DestReg == AArch64::SP) {
7005 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7006 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7007 assert(VScale == 1 &&
"Expected non-scalable operation");
7016 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7017 "emit a single SEH directive");
7018 }
else if (DestReg == AArch64::SP) {
7019 assert(VScale == 1 &&
"Expected non-scalable operation");
7022 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7035 unsigned DestReg,
unsigned SrcReg,
7038 bool NeedsWinCFI,
bool *HasWinCFI,
7040 unsigned FrameReg) {
7047 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7049 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7050 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7051 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7054 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7055 if (NeedsFinalDefNZCV)
7059 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7060 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7061 "SP increment/decrement not 8-byte aligned");
7062 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7065 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7068 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7070 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7077 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7078 "WinCFI can't allocate fractions of an SVE data vector");
7080 if (NumDataVectors) {
7082 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7083 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7089 if (NumPredicateVectors) {
7090 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7092 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7093 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7097 if (NeedsFinalDefNZCV)
7119 if (
MI.isFullCopy()) {
7122 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7126 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7131 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7159 if (
MI.isCopy() &&
Ops.size() == 1 &&
7161 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7162 bool IsSpill =
Ops[0] == 0;
7163 bool IsFill = !IsSpill;
7175 :
TRI.getMinimalPhysRegClass(Reg);
7181 "Mismatched register size in non subreg COPY");
7188 return &*--InsertPt;
7200 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7203 "Unexpected subreg on physical register");
7205 FrameIndex, &AArch64::GPR64RegClass,
Register());
7206 return &*--InsertPt;
7223 case AArch64::sub_32:
7224 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7225 FillRC = &AArch64::GPR32RegClass;
7228 FillRC = &AArch64::FPR32RegClass;
7231 FillRC = &AArch64::FPR64RegClass;
7237 TRI.getRegSizeInBits(*FillRC) &&
7238 "Mismatched regclass size on folded subreg COPY");
7257 bool *OutUseUnscaledOp,
7258 unsigned *OutUnscaledOp,
7259 int64_t *EmittableOffset) {
7261 if (EmittableOffset)
7262 *EmittableOffset = 0;
7263 if (OutUseUnscaledOp)
7264 *OutUseUnscaledOp =
false;
7270 switch (
MI.getOpcode()) {
7273 case AArch64::LD1Rv1d:
7274 case AArch64::LD1Rv2s:
7275 case AArch64::LD1Rv2d:
7276 case AArch64::LD1Rv4h:
7277 case AArch64::LD1Rv4s:
7278 case AArch64::LD1Rv8b:
7279 case AArch64::LD1Rv8h:
7280 case AArch64::LD1Rv16b:
7281 case AArch64::LD1Twov2d:
7282 case AArch64::LD1Threev2d:
7283 case AArch64::LD1Fourv2d:
7284 case AArch64::LD1Twov1d:
7285 case AArch64::LD1Threev1d:
7286 case AArch64::LD1Fourv1d:
7287 case AArch64::ST1Twov2d:
7288 case AArch64::ST1Threev2d:
7289 case AArch64::ST1Fourv2d:
7290 case AArch64::ST1Twov1d:
7291 case AArch64::ST1Threev1d:
7292 case AArch64::ST1Fourv1d:
7293 case AArch64::ST1i8:
7294 case AArch64::ST1i16:
7295 case AArch64::ST1i32:
7296 case AArch64::ST1i64:
7298 case AArch64::IRGstack:
7299 case AArch64::STGloop:
7300 case AArch64::STZGloop:
7305 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7306 int64_t MinOff, MaxOff;
7312 bool IsMulVL = ScaleValue.isScalable();
7313 unsigned Scale = ScaleValue.getKnownMinValue();
7323 std::optional<unsigned> UnscaledOp =
7325 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7326 if (useUnscaledOp &&
7331 Scale = ScaleValue.getKnownMinValue();
7332 assert(IsMulVL == ScaleValue.isScalable() &&
7333 "Unscaled opcode has different value for scalable");
7335 int64_t Remainder =
Offset % Scale;
7336 assert(!(Remainder && useUnscaledOp) &&
7337 "Cannot have remainder when using unscaled op");
7339 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7340 int64_t NewOffset =
Offset / Scale;
7341 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7349 int64_t HighPart =
Offset & ~0xFFF;
7350 int64_t LowPart =
Offset & 0xFFF;
7351 int64_t LowScaled = LowPart / Scale;
7352 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7353 MinOff <= LowScaled && LowScaled <= MaxOff &&
7355 NewOffset = LowScaled;
7360 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7365 if (EmittableOffset)
7366 *EmittableOffset = NewOffset;
7367 if (OutUseUnscaledOp)
7368 *OutUseUnscaledOp = useUnscaledOp;
7369 if (OutUnscaledOp && UnscaledOp)
7370 *OutUnscaledOp = *UnscaledOp;
7383 unsigned Opcode =
MI.getOpcode();
7384 unsigned ImmIdx = FrameRegIdx + 1;
7386 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7391 MI.eraseFromParent();
7397 unsigned UnscaledOp;
7400 &UnscaledOp, &NewOffset);
7404 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7406 MI.setDesc(
TII->get(UnscaledOp));
7408 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7424bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7429 case AArch64::ADDSWrr:
7430 case AArch64::ADDSWri:
7431 case AArch64::ADDSXrr:
7432 case AArch64::ADDSXri:
7433 case AArch64::SUBSWrr:
7434 case AArch64::SUBSXrr:
7436 case AArch64::SUBSWri:
7437 case AArch64::SUBSXri:
7448 case AArch64::ADDWrr:
7449 case AArch64::ADDWri:
7450 case AArch64::SUBWrr:
7451 case AArch64::ADDSWrr:
7452 case AArch64::ADDSWri:
7453 case AArch64::SUBSWrr:
7455 case AArch64::SUBWri:
7456 case AArch64::SUBSWri:
7467 case AArch64::ADDXrr:
7468 case AArch64::ADDXri:
7469 case AArch64::SUBXrr:
7470 case AArch64::ADDSXrr:
7471 case AArch64::ADDSXri:
7472 case AArch64::SUBSXrr:
7474 case AArch64::SUBXri:
7475 case AArch64::SUBSXri:
7476 case AArch64::ADDv8i8:
7477 case AArch64::ADDv16i8:
7478 case AArch64::ADDv4i16:
7479 case AArch64::ADDv8i16:
7480 case AArch64::ADDv2i32:
7481 case AArch64::ADDv4i32:
7482 case AArch64::SUBv8i8:
7483 case AArch64::SUBv16i8:
7484 case AArch64::SUBv4i16:
7485 case AArch64::SUBv8i16:
7486 case AArch64::SUBv2i32:
7487 case AArch64::SUBv4i32:
7500 case AArch64::FADDHrr:
7501 case AArch64::FADDSrr:
7502 case AArch64::FADDDrr:
7503 case AArch64::FADDv4f16:
7504 case AArch64::FADDv8f16:
7505 case AArch64::FADDv2f32:
7506 case AArch64::FADDv2f64:
7507 case AArch64::FADDv4f32:
7508 case AArch64::FSUBHrr:
7509 case AArch64::FSUBSrr:
7510 case AArch64::FSUBDrr:
7511 case AArch64::FSUBv4f16:
7512 case AArch64::FSUBv8f16:
7513 case AArch64::FSUBv2f32:
7514 case AArch64::FSUBv2f64:
7515 case AArch64::FSUBv4f32:
7534 unsigned CombineOpc,
unsigned ZeroReg = 0,
7535 bool CheckZeroReg =
false) {
7542 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7549 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7550 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7551 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7553 if (
MI->getOperand(3).getReg() != ZeroReg)
7558 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7567 unsigned MulOpc,
unsigned ZeroReg) {
7582bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7583 bool Invert)
const {
7589 case AArch64::FADDHrr:
7590 case AArch64::FADDSrr:
7591 case AArch64::FADDDrr:
7592 case AArch64::FMULHrr:
7593 case AArch64::FMULSrr:
7594 case AArch64::FMULDrr:
7595 case AArch64::FMULX16:
7596 case AArch64::FMULX32:
7597 case AArch64::FMULX64:
7599 case AArch64::FADDv4f16:
7600 case AArch64::FADDv8f16:
7601 case AArch64::FADDv2f32:
7602 case AArch64::FADDv4f32:
7603 case AArch64::FADDv2f64:
7604 case AArch64::FMULv4f16:
7605 case AArch64::FMULv8f16:
7606 case AArch64::FMULv2f32:
7607 case AArch64::FMULv4f32:
7608 case AArch64::FMULv2f64:
7609 case AArch64::FMULXv4f16:
7610 case AArch64::FMULXv8f16:
7611 case AArch64::FMULXv2f32:
7612 case AArch64::FMULXv4f32:
7613 case AArch64::FMULXv2f64:
7617 case AArch64::FADD_ZZZ_H:
7618 case AArch64::FADD_ZZZ_S:
7619 case AArch64::FADD_ZZZ_D:
7620 case AArch64::FMUL_ZZZ_H:
7621 case AArch64::FMUL_ZZZ_S:
7622 case AArch64::FMUL_ZZZ_D:
7633 case AArch64::ADDWrr:
7634 case AArch64::ADDXrr:
7635 case AArch64::ANDWrr:
7636 case AArch64::ANDXrr:
7637 case AArch64::ORRWrr:
7638 case AArch64::ORRXrr:
7639 case AArch64::EORWrr:
7640 case AArch64::EORXrr:
7641 case AArch64::EONWrr:
7642 case AArch64::EONXrr:
7646 case AArch64::ADDv8i8:
7647 case AArch64::ADDv16i8:
7648 case AArch64::ADDv4i16:
7649 case AArch64::ADDv8i16:
7650 case AArch64::ADDv2i32:
7651 case AArch64::ADDv4i32:
7652 case AArch64::ADDv1i64:
7653 case AArch64::ADDv2i64:
7654 case AArch64::MULv8i8:
7655 case AArch64::MULv16i8:
7656 case AArch64::MULv4i16:
7657 case AArch64::MULv8i16:
7658 case AArch64::MULv2i32:
7659 case AArch64::MULv4i32:
7660 case AArch64::ANDv8i8:
7661 case AArch64::ANDv16i8:
7662 case AArch64::ORRv8i8:
7663 case AArch64::ORRv16i8:
7664 case AArch64::EORv8i8:
7665 case AArch64::EORv16i8:
7667 case AArch64::ADD_ZZZ_B:
7668 case AArch64::ADD_ZZZ_H:
7669 case AArch64::ADD_ZZZ_S:
7670 case AArch64::ADD_ZZZ_D:
7671 case AArch64::MUL_ZZZ_B:
7672 case AArch64::MUL_ZZZ_H:
7673 case AArch64::MUL_ZZZ_S:
7674 case AArch64::MUL_ZZZ_D:
7675 case AArch64::AND_ZZZ:
7676 case AArch64::ORR_ZZZ:
7677 case AArch64::EOR_ZZZ:
7708 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7716 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7728 case AArch64::ADDWrr:
7730 "ADDWrr does not have register operands");
7731 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7732 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7734 case AArch64::ADDXrr:
7735 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7736 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7738 case AArch64::SUBWrr:
7739 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7740 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7742 case AArch64::SUBXrr:
7743 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7744 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7746 case AArch64::ADDWri:
7747 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7749 case AArch64::ADDXri:
7750 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7752 case AArch64::SUBWri:
7753 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7755 case AArch64::SUBXri:
7756 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7758 case AArch64::ADDv8i8:
7759 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7760 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7762 case AArch64::ADDv16i8:
7763 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7764 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7766 case AArch64::ADDv4i16:
7767 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7768 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7769 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7770 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7772 case AArch64::ADDv8i16:
7773 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7774 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7775 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7776 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7778 case AArch64::ADDv2i32:
7779 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7780 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7781 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7782 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7784 case AArch64::ADDv4i32:
7785 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7786 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7787 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7788 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7790 case AArch64::SUBv8i8:
7791 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7792 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7794 case AArch64::SUBv16i8:
7795 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7796 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7798 case AArch64::SUBv4i16:
7799 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7800 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7801 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7802 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7804 case AArch64::SUBv8i16:
7805 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7806 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7807 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7808 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7810 case AArch64::SUBv2i32:
7811 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7812 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7813 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7814 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7816 case AArch64::SUBv4i32:
7817 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7818 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7819 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7820 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7826bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7830 case AArch64::UABALB_ZZZ_D:
7831 case AArch64::UABALB_ZZZ_H:
7832 case AArch64::UABALB_ZZZ_S:
7833 case AArch64::UABALT_ZZZ_D:
7834 case AArch64::UABALT_ZZZ_H:
7835 case AArch64::UABALT_ZZZ_S:
7836 case AArch64::SABALB_ZZZ_D:
7837 case AArch64::SABALB_ZZZ_S:
7838 case AArch64::SABALB_ZZZ_H:
7839 case AArch64::SABALT_ZZZ_D:
7840 case AArch64::SABALT_ZZZ_S:
7841 case AArch64::SABALT_ZZZ_H:
7842 case AArch64::UABALv16i8_v8i16:
7843 case AArch64::UABALv2i32_v2i64:
7844 case AArch64::UABALv4i16_v4i32:
7845 case AArch64::UABALv4i32_v2i64:
7846 case AArch64::UABALv8i16_v4i32:
7847 case AArch64::UABALv8i8_v8i16:
7848 case AArch64::UABAv16i8:
7849 case AArch64::UABAv2i32:
7850 case AArch64::UABAv4i16:
7851 case AArch64::UABAv4i32:
7852 case AArch64::UABAv8i16:
7853 case AArch64::UABAv8i8:
7854 case AArch64::SABALv16i8_v8i16:
7855 case AArch64::SABALv2i32_v2i64:
7856 case AArch64::SABALv4i16_v4i32:
7857 case AArch64::SABALv4i32_v2i64:
7858 case AArch64::SABALv8i16_v4i32:
7859 case AArch64::SABALv8i8_v8i16:
7860 case AArch64::SABAv16i8:
7861 case AArch64::SABAv2i32:
7862 case AArch64::SABAv4i16:
7863 case AArch64::SABAv4i32:
7864 case AArch64::SABAv8i16:
7865 case AArch64::SABAv8i8:
7872unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7873 unsigned AccumulationOpcode)
const {
7874 switch (AccumulationOpcode) {
7877 case AArch64::UABALB_ZZZ_D:
7878 return AArch64::UABDLB_ZZZ_D;
7879 case AArch64::UABALB_ZZZ_H:
7880 return AArch64::UABDLB_ZZZ_H;
7881 case AArch64::UABALB_ZZZ_S:
7882 return AArch64::UABDLB_ZZZ_S;
7883 case AArch64::UABALT_ZZZ_D:
7884 return AArch64::UABDLT_ZZZ_D;
7885 case AArch64::UABALT_ZZZ_H:
7886 return AArch64::UABDLT_ZZZ_H;
7887 case AArch64::UABALT_ZZZ_S:
7888 return AArch64::UABDLT_ZZZ_S;
7889 case AArch64::UABALv16i8_v8i16:
7890 return AArch64::UABDLv16i8_v8i16;
7891 case AArch64::UABALv2i32_v2i64:
7892 return AArch64::UABDLv2i32_v2i64;
7893 case AArch64::UABALv4i16_v4i32:
7894 return AArch64::UABDLv4i16_v4i32;
7895 case AArch64::UABALv4i32_v2i64:
7896 return AArch64::UABDLv4i32_v2i64;
7897 case AArch64::UABALv8i16_v4i32:
7898 return AArch64::UABDLv8i16_v4i32;
7899 case AArch64::UABALv8i8_v8i16:
7900 return AArch64::UABDLv8i8_v8i16;
7901 case AArch64::UABAv16i8:
7902 return AArch64::UABDv16i8;
7903 case AArch64::UABAv2i32:
7904 return AArch64::UABDv2i32;
7905 case AArch64::UABAv4i16:
7906 return AArch64::UABDv4i16;
7907 case AArch64::UABAv4i32:
7908 return AArch64::UABDv4i32;
7909 case AArch64::UABAv8i16:
7910 return AArch64::UABDv8i16;
7911 case AArch64::UABAv8i8:
7912 return AArch64::UABDv8i8;
7913 case AArch64::SABALB_ZZZ_D:
7914 return AArch64::SABDLB_ZZZ_D;
7915 case AArch64::SABALB_ZZZ_S:
7916 return AArch64::SABDLB_ZZZ_S;
7917 case AArch64::SABALB_ZZZ_H:
7918 return AArch64::SABDLB_ZZZ_H;
7919 case AArch64::SABALT_ZZZ_D:
7920 return AArch64::SABDLT_ZZZ_D;
7921 case AArch64::SABALT_ZZZ_S:
7922 return AArch64::SABDLT_ZZZ_S;
7923 case AArch64::SABALT_ZZZ_H:
7924 return AArch64::SABDLT_ZZZ_H;
7925 case AArch64::SABALv16i8_v8i16:
7926 return AArch64::SABDLv16i8_v8i16;
7927 case AArch64::SABALv2i32_v2i64:
7928 return AArch64::SABDLv2i32_v2i64;
7929 case AArch64::SABALv4i16_v4i32:
7930 return AArch64::SABDLv4i16_v4i32;
7931 case AArch64::SABALv4i32_v2i64:
7932 return AArch64::SABDLv4i32_v2i64;
7933 case AArch64::SABALv8i16_v4i32:
7934 return AArch64::SABDLv8i16_v4i32;
7935 case AArch64::SABALv8i8_v8i16:
7936 return AArch64::SABDLv8i8_v8i16;
7937 case AArch64::SABAv16i8:
7938 return AArch64::SABDv16i8;
7939 case AArch64::SABAv2i32:
7940 return AArch64::SABAv2i32;
7941 case AArch64::SABAv4i16:
7942 return AArch64::SABDv4i16;
7943 case AArch64::SABAv4i32:
7944 return AArch64::SABDv4i32;
7945 case AArch64::SABAv8i16:
7946 return AArch64::SABDv8i16;
7947 case AArch64::SABAv8i8:
7948 return AArch64::SABDv8i8;
7964 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
7976 assert(
false &&
"Unsupported FP instruction in combiner\n");
7978 case AArch64::FADDHrr:
7980 "FADDHrr does not have register operands");
7982 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
7983 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
7985 case AArch64::FADDSrr:
7987 "FADDSrr does not have register operands");
7989 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
7990 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
7992 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
7993 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
7995 case AArch64::FADDDrr:
7996 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
7997 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
7999 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8000 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8002 case AArch64::FADDv4f16:
8003 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8004 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8006 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8007 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8009 case AArch64::FADDv8f16:
8010 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8011 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8013 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8014 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8016 case AArch64::FADDv2f32:
8017 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8018 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8020 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8021 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8023 case AArch64::FADDv2f64:
8024 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8025 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8027 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8028 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8030 case AArch64::FADDv4f32:
8031 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8032 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8034 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8035 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8037 case AArch64::FSUBHrr:
8038 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8039 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8040 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8042 case AArch64::FSUBSrr:
8043 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8045 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8046 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8048 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8050 case AArch64::FSUBDrr:
8051 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8053 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8054 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8056 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8058 case AArch64::FSUBv4f16:
8059 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8060 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8062 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8063 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8065 case AArch64::FSUBv8f16:
8066 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8067 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8069 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8070 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8072 case AArch64::FSUBv2f32:
8073 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8074 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8076 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8077 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8079 case AArch64::FSUBv2f64:
8080 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8081 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8083 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8084 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8086 case AArch64::FSUBv4f32:
8087 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8088 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8090 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8091 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8102 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8109 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8110 MI->getOperand(1).getReg().isVirtual())
8112 if (
MI &&
MI->getOpcode() == Opcode) {
8124 case AArch64::FMULv2f32:
8125 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8126 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8128 case AArch64::FMULv2f64:
8129 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8130 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8132 case AArch64::FMULv4f16:
8133 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8134 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8136 case AArch64::FMULv4f32:
8137 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8138 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8140 case AArch64::FMULv8f16:
8141 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8142 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8155 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8158 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8173 case AArch64::FNEGDr:
8175 case AArch64::FNEGSr:
8307 case AArch64::SUBWrr:
8308 case AArch64::SUBSWrr:
8309 case AArch64::SUBXrr:
8310 case AArch64::SUBSXrr:
8355 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8378 while (!RemainingLanes.
empty() && CurrInstr &&
8379 CurrInstr->getOpcode() == LoadLaneOpCode &&
8381 CurrInstr->getNumOperands() == 4) {
8382 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8388 if (!RemainingLanes.
empty())
8392 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8396 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8397 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8398 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8414 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8417 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8418 !RemainingLoadInstrs.
empty();
8419 --MBBItr, --RemainingSteps) {
8423 RemainingLoadInstrs.
erase(&CurrInstr);
8433 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8459 case AArch64::LD1i32:
8461 case AArch64::LD1i16:
8463 case AArch64::LD1i8:
8479 unsigned Pattern,
unsigned NumLanes) {
8487 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8495 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8501 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8507 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8508 Register SrcRegister,
unsigned Lane,
8510 bool OffsetRegisterKillState) {
8519 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8520 InsInstrs.
push_back(LoadIndexIntoRegister);
8526 auto CreateLDRInstruction =
8532 Opcode = AArch64::LDRSui;
8535 Opcode = AArch64::LDRHui;
8538 Opcode = AArch64::LDRBui;
8542 "Got unsupported number of lanes in machine-combiner gather pattern");
8552 auto LanesToLoadToReg0 =
8554 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8555 Register PrevReg = SubregToReg->getOperand(0).getReg();
8557 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8558 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8559 OffsetRegOperand.
getReg(),
8560 OffsetRegOperand.
isKill());
8567 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8569 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8576 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8577 OriginalSplitToLoadOffsetOperand.
getReg(),
8580 InstrIdxForVirtReg.
insert(
8581 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8582 InsInstrs.
push_back(MiddleIndexLoadInstr);
8587 unsigned SubregType;
8590 SubregType = AArch64::ssub;
8593 SubregType = AArch64::hsub;
8596 SubregType = AArch64::bsub;
8600 "Got invalid NumLanes for machine-combiner gather pattern");
8603 auto SubRegToRegInstr =
8605 DestRegForSubregToReg)
8608 InstrIdxForVirtReg.
insert(
8609 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8613 auto LanesToLoadToReg1 =
8615 LoadToLaneInstrsAscending.end());
8616 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8618 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8619 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8620 OffsetRegOperand.
getReg(),
8621 OffsetRegOperand.
isKill());
8624 if (Index == NumLanes / 2 - 2) {
8659bool AArch64InstrInfo::getMachineCombinerPatterns(
8661 bool DoRegPressureReduce)
const {
8682 DoRegPressureReduce);
8711 const Register *ReplacedAddend =
nullptr) {
8712 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8714 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8717 Register SrcReg0 = MUL->getOperand(1).getReg();
8718 bool Src0IsKill = MUL->getOperand(1).isKill();
8719 Register SrcReg1 = MUL->getOperand(2).getReg();
8720 bool Src1IsKill = MUL->getOperand(2).isKill();
8724 if (ReplacedAddend) {
8726 SrcReg2 = *ReplacedAddend;
8753 .
addImm(MUL->getOperand(3).getImm());
8760 assert(
false &&
"Invalid FMA instruction kind \n");
8774 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8775 Opc = AArch64::FNMADDSrrr;
8776 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8777 Opc = AArch64::FNMADDDrrr;
8811 unsigned IdxDupOp,
unsigned MulOpc,
8813 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8814 "Invalid index of FMUL operand");
8822 if (Dup->
getOpcode() == TargetOpcode::COPY)
8831 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8872 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8887 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8914 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8942 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
8944 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8948 Register SrcReg0 = MUL->getOperand(1).getReg();
8949 bool Src0IsKill = MUL->getOperand(1).isKill();
8950 Register SrcReg1 = MUL->getOperand(2).getReg();
8951 bool Src1IsKill = MUL->getOperand(2).isKill();
8981 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
8982 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
8996 if (Opcode == AArch64::SUBSWrr)
8997 Opcode = AArch64::SUBWrr;
8998 else if (Opcode == AArch64::SUBSXrr)
8999 Opcode = AArch64::SUBXrr;
9001 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9002 "Unexpected instruction opcode.");
9019 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9026unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9027 unsigned int AccumulatorOpCode)
const {
9028 switch (AccumulatorOpCode) {
9029 case AArch64::UABALB_ZZZ_D:
9030 case AArch64::SABALB_ZZZ_D:
9031 case AArch64::UABALT_ZZZ_D:
9032 case AArch64::SABALT_ZZZ_D:
9033 return AArch64::ADD_ZZZ_D;
9034 case AArch64::UABALB_ZZZ_H:
9035 case AArch64::SABALB_ZZZ_H:
9036 case AArch64::UABALT_ZZZ_H:
9037 case AArch64::SABALT_ZZZ_H:
9038 return AArch64::ADD_ZZZ_H;
9039 case AArch64::UABALB_ZZZ_S:
9040 case AArch64::SABALB_ZZZ_S:
9041 case AArch64::UABALT_ZZZ_S:
9042 case AArch64::SABALT_ZZZ_S:
9043 return AArch64::ADD_ZZZ_S;
9044 case AArch64::UABALv16i8_v8i16:
9045 case AArch64::SABALv8i8_v8i16:
9046 case AArch64::SABAv8i16:
9047 case AArch64::UABAv8i16:
9048 return AArch64::ADDv8i16;
9049 case AArch64::SABALv2i32_v2i64:
9050 case AArch64::UABALv2i32_v2i64:
9051 case AArch64::SABALv4i32_v2i64:
9052 return AArch64::ADDv2i64;
9053 case AArch64::UABALv4i16_v4i32:
9054 case AArch64::SABALv4i16_v4i32:
9055 case AArch64::SABALv8i16_v4i32:
9056 case AArch64::SABAv4i32:
9057 case AArch64::UABAv4i32:
9058 return AArch64::ADDv4i32;
9059 case AArch64::UABALv4i32_v2i64:
9060 return AArch64::ADDv2i64;
9061 case AArch64::UABALv8i16_v4i32:
9062 return AArch64::ADDv4i32;
9063 case AArch64::UABALv8i8_v8i16:
9064 case AArch64::SABALv16i8_v8i16:
9065 return AArch64::ADDv8i16;
9066 case AArch64::UABAv16i8:
9067 case AArch64::SABAv16i8:
9068 return AArch64::ADDv16i8;
9069 case AArch64::UABAv4i16:
9070 case AArch64::SABAv4i16:
9071 return AArch64::ADDv4i16;
9072 case AArch64::UABAv2i32:
9073 case AArch64::SABAv2i32:
9074 return AArch64::ADDv2i32;
9075 case AArch64::UABAv8i8:
9076 case AArch64::SABAv8i8:
9077 return AArch64::ADDv8i8;
9086void AArch64InstrInfo::genAlternativeCodeSequence(
9096 MachineInstr *
MUL =
nullptr;
9103 DelInstrs, InstrIdxForVirtReg);
9109 InstrIdxForVirtReg);
9115 InstrIdxForVirtReg);
9124 Opc = AArch64::MADDWrrr;
9125 RC = &AArch64::GPR32RegClass;
9127 Opc = AArch64::MADDXrrr;
9128 RC = &AArch64::GPR64RegClass;
9139 Opc = AArch64::MADDWrrr;
9140 RC = &AArch64::GPR32RegClass;
9142 Opc = AArch64::MADDXrrr;
9143 RC = &AArch64::GPR64RegClass;
9157 unsigned BitSize, MovImm;
9160 MovImm = AArch64::MOVi32imm;
9161 RC = &AArch64::GPR32spRegClass;
9163 Opc = AArch64::MADDWrrr;
9164 RC = &AArch64::GPR32RegClass;
9166 MovImm = AArch64::MOVi64imm;
9167 RC = &AArch64::GPR64spRegClass;
9169 Opc = AArch64::MADDXrrr;
9170 RC = &AArch64::GPR64RegClass;
9181 uint64_t UImm =
SignExtend64(IsSub ? -Imm : Imm, BitSize);
9185 if (Insn.
size() != 1)
9187 MachineInstrBuilder MIB1 =
9188 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9189 .
addImm(IsSub ? -Imm : Imm);
9191 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9203 unsigned SubOpc, ZeroReg;
9205 SubOpc = AArch64::SUBWrr;
9206 SubRC = &AArch64::GPR32spRegClass;
9207 ZeroReg = AArch64::WZR;
9208 Opc = AArch64::MADDWrrr;
9209 RC = &AArch64::GPR32RegClass;
9211 SubOpc = AArch64::SUBXrr;
9212 SubRC = &AArch64::GPR64spRegClass;
9213 ZeroReg = AArch64::XZR;
9214 Opc = AArch64::MADDXrrr;
9215 RC = &AArch64::GPR64RegClass;
9219 MachineInstrBuilder MIB1 =
9220 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9224 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9235 Opc = AArch64::MSUBWrrr;
9236 RC = &AArch64::GPR32RegClass;
9238 Opc = AArch64::MSUBXrrr;
9239 RC = &AArch64::GPR64RegClass;
9244 Opc = AArch64::MLAv8i8;
9245 RC = &AArch64::FPR64RegClass;
9249 Opc = AArch64::MLAv8i8;
9250 RC = &AArch64::FPR64RegClass;
9254 Opc = AArch64::MLAv16i8;
9255 RC = &AArch64::FPR128RegClass;
9259 Opc = AArch64::MLAv16i8;
9260 RC = &AArch64::FPR128RegClass;
9264 Opc = AArch64::MLAv4i16;
9265 RC = &AArch64::FPR64RegClass;
9269 Opc = AArch64::MLAv4i16;
9270 RC = &AArch64::FPR64RegClass;
9274 Opc = AArch64::MLAv8i16;
9275 RC = &AArch64::FPR128RegClass;
9279 Opc = AArch64::MLAv8i16;
9280 RC = &AArch64::FPR128RegClass;
9284 Opc = AArch64::MLAv2i32;
9285 RC = &AArch64::FPR64RegClass;
9289 Opc = AArch64::MLAv2i32;
9290 RC = &AArch64::FPR64RegClass;
9294 Opc = AArch64::MLAv4i32;
9295 RC = &AArch64::FPR128RegClass;
9299 Opc = AArch64::MLAv4i32;
9300 RC = &AArch64::FPR128RegClass;
9305 Opc = AArch64::MLAv8i8;
9306 RC = &AArch64::FPR64RegClass;
9308 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9312 Opc = AArch64::MLSv8i8;
9313 RC = &AArch64::FPR64RegClass;
9317 Opc = AArch64::MLAv16i8;
9318 RC = &AArch64::FPR128RegClass;
9320 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9324 Opc = AArch64::MLSv16i8;
9325 RC = &AArch64::FPR128RegClass;
9329 Opc = AArch64::MLAv4i16;
9330 RC = &AArch64::FPR64RegClass;
9332 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9336 Opc = AArch64::MLSv4i16;
9337 RC = &AArch64::FPR64RegClass;
9341 Opc = AArch64::MLAv8i16;
9342 RC = &AArch64::FPR128RegClass;
9344 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9348 Opc = AArch64::MLSv8i16;
9349 RC = &AArch64::FPR128RegClass;
9353 Opc = AArch64::MLAv2i32;
9354 RC = &AArch64::FPR64RegClass;
9356 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9360 Opc = AArch64::MLSv2i32;
9361 RC = &AArch64::FPR64RegClass;
9365 Opc = AArch64::MLAv4i32;
9366 RC = &AArch64::FPR128RegClass;
9368 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9372 Opc = AArch64::MLSv4i32;
9373 RC = &AArch64::FPR128RegClass;
9378 Opc = AArch64::MLAv4i16_indexed;
9379 RC = &AArch64::FPR64RegClass;
9383 Opc = AArch64::MLAv4i16_indexed;
9384 RC = &AArch64::FPR64RegClass;
9388 Opc = AArch64::MLAv8i16_indexed;
9389 RC = &AArch64::FPR128RegClass;
9393 Opc = AArch64::MLAv8i16_indexed;
9394 RC = &AArch64::FPR128RegClass;
9398 Opc = AArch64::MLAv2i32_indexed;
9399 RC = &AArch64::FPR64RegClass;
9403 Opc = AArch64::MLAv2i32_indexed;
9404 RC = &AArch64::FPR64RegClass;
9408 Opc = AArch64::MLAv4i32_indexed;
9409 RC = &AArch64::FPR128RegClass;
9413 Opc = AArch64::MLAv4i32_indexed;
9414 RC = &AArch64::FPR128RegClass;
9419 Opc = AArch64::MLAv4i16_indexed;
9420 RC = &AArch64::FPR64RegClass;
9422 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9426 Opc = AArch64::MLSv4i16_indexed;
9427 RC = &AArch64::FPR64RegClass;
9431 Opc = AArch64::MLAv8i16_indexed;
9432 RC = &AArch64::FPR128RegClass;
9434 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9438 Opc = AArch64::MLSv8i16_indexed;
9439 RC = &AArch64::FPR128RegClass;
9443 Opc = AArch64::MLAv2i32_indexed;
9444 RC = &AArch64::FPR64RegClass;
9446 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9450 Opc = AArch64::MLSv2i32_indexed;
9451 RC = &AArch64::FPR64RegClass;
9455 Opc = AArch64::MLAv4i32_indexed;
9456 RC = &AArch64::FPR128RegClass;
9458 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9462 Opc = AArch64::MLSv4i32_indexed;
9463 RC = &AArch64::FPR128RegClass;
9469 Opc = AArch64::FMADDHrrr;
9470 RC = &AArch64::FPR16RegClass;
9474 Opc = AArch64::FMADDSrrr;
9475 RC = &AArch64::FPR32RegClass;
9479 Opc = AArch64::FMADDDrrr;
9480 RC = &AArch64::FPR64RegClass;
9485 Opc = AArch64::FMADDHrrr;
9486 RC = &AArch64::FPR16RegClass;
9490 Opc = AArch64::FMADDSrrr;
9491 RC = &AArch64::FPR32RegClass;
9495 Opc = AArch64::FMADDDrrr;
9496 RC = &AArch64::FPR64RegClass;
9501 Opc = AArch64::FMLAv1i32_indexed;
9502 RC = &AArch64::FPR32RegClass;
9507 Opc = AArch64::FMLAv1i32_indexed;
9508 RC = &AArch64::FPR32RegClass;
9514 Opc = AArch64::FMLAv1i64_indexed;
9515 RC = &AArch64::FPR64RegClass;
9520 Opc = AArch64::FMLAv1i64_indexed;
9521 RC = &AArch64::FPR64RegClass;
9527 RC = &AArch64::FPR64RegClass;
9528 Opc = AArch64::FMLAv4i16_indexed;
9533 RC = &AArch64::FPR64RegClass;
9534 Opc = AArch64::FMLAv4f16;
9539 RC = &AArch64::FPR64RegClass;
9540 Opc = AArch64::FMLAv4i16_indexed;
9545 RC = &AArch64::FPR64RegClass;
9546 Opc = AArch64::FMLAv4f16;
9553 RC = &AArch64::FPR64RegClass;
9555 Opc = AArch64::FMLAv2i32_indexed;
9559 Opc = AArch64::FMLAv2f32;
9566 RC = &AArch64::FPR64RegClass;
9568 Opc = AArch64::FMLAv2i32_indexed;
9572 Opc = AArch64::FMLAv2f32;
9579 RC = &AArch64::FPR128RegClass;
9580 Opc = AArch64::FMLAv8i16_indexed;
9585 RC = &AArch64::FPR128RegClass;
9586 Opc = AArch64::FMLAv8f16;
9591 RC = &AArch64::FPR128RegClass;
9592 Opc = AArch64::FMLAv8i16_indexed;
9597 RC = &AArch64::FPR128RegClass;
9598 Opc = AArch64::FMLAv8f16;
9605 RC = &AArch64::FPR128RegClass;
9607 Opc = AArch64::FMLAv2i64_indexed;
9611 Opc = AArch64::FMLAv2f64;
9618 RC = &AArch64::FPR128RegClass;
9620 Opc = AArch64::FMLAv2i64_indexed;
9624 Opc = AArch64::FMLAv2f64;
9632 RC = &AArch64::FPR128RegClass;
9634 Opc = AArch64::FMLAv4i32_indexed;
9638 Opc = AArch64::FMLAv4f32;
9646 RC = &AArch64::FPR128RegClass;
9648 Opc = AArch64::FMLAv4i32_indexed;
9652 Opc = AArch64::FMLAv4f32;
9659 Opc = AArch64::FNMSUBHrrr;
9660 RC = &AArch64::FPR16RegClass;
9664 Opc = AArch64::FNMSUBSrrr;
9665 RC = &AArch64::FPR32RegClass;
9669 Opc = AArch64::FNMSUBDrrr;
9670 RC = &AArch64::FPR64RegClass;
9675 Opc = AArch64::FNMADDHrrr;
9676 RC = &AArch64::FPR16RegClass;
9680 Opc = AArch64::FNMADDSrrr;
9681 RC = &AArch64::FPR32RegClass;
9685 Opc = AArch64::FNMADDDrrr;
9686 RC = &AArch64::FPR64RegClass;
9691 Opc = AArch64::FMSUBHrrr;
9692 RC = &AArch64::FPR16RegClass;
9696 Opc = AArch64::FMSUBSrrr;
9697 RC = &AArch64::FPR32RegClass;
9701 Opc = AArch64::FMSUBDrrr;
9702 RC = &AArch64::FPR64RegClass;
9707 Opc = AArch64::FMLSv1i32_indexed;
9708 RC = &AArch64::FPR32RegClass;
9714 Opc = AArch64::FMLSv1i64_indexed;
9715 RC = &AArch64::FPR64RegClass;
9722 RC = &AArch64::FPR64RegClass;
9724 MachineInstrBuilder MIB1 =
9725 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9728 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9730 Opc = AArch64::FMLAv4f16;
9734 Opc = AArch64::FMLAv4i16_indexed;
9741 RC = &AArch64::FPR64RegClass;
9742 Opc = AArch64::FMLSv4f16;
9747 RC = &AArch64::FPR64RegClass;
9748 Opc = AArch64::FMLSv4i16_indexed;
9755 RC = &AArch64::FPR64RegClass;
9757 Opc = AArch64::FMLSv2i32_indexed;
9761 Opc = AArch64::FMLSv2f32;
9769 RC = &AArch64::FPR128RegClass;
9771 MachineInstrBuilder MIB1 =
9772 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9775 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9777 Opc = AArch64::FMLAv8f16;
9781 Opc = AArch64::FMLAv8i16_indexed;
9788 RC = &AArch64::FPR128RegClass;
9789 Opc = AArch64::FMLSv8f16;
9794 RC = &AArch64::FPR128RegClass;
9795 Opc = AArch64::FMLSv8i16_indexed;
9802 RC = &AArch64::FPR128RegClass;
9804 Opc = AArch64::FMLSv2i64_indexed;
9808 Opc = AArch64::FMLSv2f64;
9816 RC = &AArch64::FPR128RegClass;
9818 Opc = AArch64::FMLSv4i32_indexed;
9822 Opc = AArch64::FMLSv4f32;
9829 RC = &AArch64::FPR64RegClass;
9831 MachineInstrBuilder MIB1 =
9832 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9835 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9837 Opc = AArch64::FMLAv2i32_indexed;
9841 Opc = AArch64::FMLAv2f32;
9849 RC = &AArch64::FPR128RegClass;
9851 MachineInstrBuilder MIB1 =
9852 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9855 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9857 Opc = AArch64::FMLAv4i32_indexed;
9861 Opc = AArch64::FMLAv4f32;
9869 RC = &AArch64::FPR128RegClass;
9871 MachineInstrBuilder MIB1 =
9872 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9875 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9877 Opc = AArch64::FMLAv2i64_indexed;
9881 Opc = AArch64::FMLAv2f64;
9893 &AArch64::FPR128RegClass, MRI);
9902 &AArch64::FPR128RegClass, MRI);
9911 &AArch64::FPR128_loRegClass, MRI);
9920 &AArch64::FPR128RegClass, MRI);
9929 &AArch64::FPR128_loRegClass, MRI);
9963 for (
auto *
MI : InsInstrs)
9964 MI->setFlags(Flags);
10005 bool IsNegativeBranch =
false;
10006 bool IsTestAndBranch =
false;
10007 unsigned TargetBBInMI = 0;
10008 switch (
MI.getOpcode()) {
10012 case AArch64::CBWPri:
10013 case AArch64::CBXPri:
10014 case AArch64::CBBAssertExt:
10015 case AArch64::CBHAssertExt:
10016 case AArch64::CBWPrr:
10017 case AArch64::CBXPrr:
10019 case AArch64::CBZW:
10020 case AArch64::CBZX:
10023 case AArch64::CBNZW:
10024 case AArch64::CBNZX:
10026 IsNegativeBranch =
true;
10028 case AArch64::TBZW:
10029 case AArch64::TBZX:
10031 IsTestAndBranch =
true;
10033 case AArch64::TBNZW:
10034 case AArch64::TBNZX:
10036 IsNegativeBranch =
true;
10037 IsTestAndBranch =
true;
10043 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10047 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10058 while (
DefMI->isCopy()) {
10067 switch (
DefMI->getOpcode()) {
10071 case AArch64::ANDWri:
10072 case AArch64::ANDXri: {
10073 if (IsTestAndBranch)
10080 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10082 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10096 unsigned Imm =
Log2_64(Mask);
10097 unsigned Opc = (Imm < 32)
10098 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10099 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10112 if (!Is32Bit && Imm < 32)
10114 MI.eraseFromParent();
10118 case AArch64::CSINCWr:
10119 case AArch64::CSINCXr: {
10120 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10121 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10122 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10123 DefMI->getOperand(2).getReg() == AArch64::XZR))
10126 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10139 if (IsNegativeBranch)
10142 MI.eraseFromParent();
10148std::pair<unsigned, unsigned>
10149AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10151 return std::make_pair(TF & Mask, TF & ~Mask);
10155AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10158 static const std::pair<unsigned, const char *> TargetFlags[] = {
10159 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10160 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10161 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10167AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10168 using namespace AArch64II;
10170 static const std::pair<unsigned, const char *> TargetFlags[] = {
10172 {
MO_GOT,
"aarch64-got"},
10173 {
MO_NC,
"aarch64-nc"},
10174 {
MO_S,
"aarch64-s"},
10175 {
MO_TLS,
"aarch64-tls"},
10185AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10186 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10288 MachineFunction *MF =
C.getMF();
10290 const AArch64RegisterInfo *ARI =
10291 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10294 for (
unsigned Reg : AArch64::GPR64RegClass) {
10296 Reg != AArch64::LR &&
10297 Reg != AArch64::X16 &&
10298 Reg != AArch64::X17 &&
10299 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10300 C.isAvailableInsideSeq(
Reg,
TRI))
10331 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10334std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10335AArch64InstrInfo::getOutliningCandidateInfo(
10337 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10338 unsigned MinRepeats)
const {
10339 unsigned SequenceSize = 0;
10340 for (
auto &
MI : RepeatedSequenceLocs[0])
10343 unsigned NumBytesToCreateFrame = 0;
10349 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10350 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10351 if (LastMI.
getOpcode() == AArch64::ADRP &&
10354 return std::nullopt;
10359 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10360 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10363 return std::nullopt;
10374 if (std::adjacent_find(
10375 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10376 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10379 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10380 outliningCandidatesSigningKeyConsensus(a, b) &&
10381 outliningCandidatesV8_3OpsConsensus(a, b)) {
10385 }) != RepeatedSequenceLocs.end()) {
10386 return std::nullopt;
10403 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10404 const auto RASignCondition = RepeatedSequenceLocs[0]
10407 ->getSignReturnAddressCondition();
10410 NumBytesToCreateFrame += 8;
10413 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10414 *RepeatedSequenceLocs[0].getMF());
10415 NumBytesToCheckLRInTCEpilogue =
10419 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10420 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10428 for (
auto &
MI :
C) {
10429 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10430 switch (
MI.getOpcode()) {
10431 case AArch64::ADDXri:
10432 case AArch64::ADDWri:
10433 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10434 assert(
MI.getOperand(2).isImm() &&
10435 "Expected operand to be immediate");
10436 assert(
MI.getOperand(1).isReg() &&
10437 "Expected operand to be a register");
10441 if (
MI.getOperand(1).getReg() == AArch64::SP)
10442 SPValue +=
MI.getOperand(2).getImm();
10446 case AArch64::SUBXri:
10447 case AArch64::SUBWri:
10448 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10449 assert(
MI.getOperand(2).isImm() &&
10450 "Expected operand to be immediate");
10451 assert(
MI.getOperand(1).isReg() &&
10452 "Expected operand to be a register");
10456 if (
MI.getOperand(1).getReg() == AArch64::SP)
10457 SPValue -=
MI.getOperand(2).getImm();
10474 if (RepeatedSequenceLocs.size() < MinRepeats)
10475 return std::nullopt;
10479 unsigned FlagsSetInAll = 0xF;
10483 FlagsSetInAll &=
C.Flags;
10485 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10488 auto SetCandidateCallInfo =
10489 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10491 C.setCallInfo(CallID, NumBytesForCall);
10495 NumBytesToCreateFrame += 4;
10503 unsigned CFICount = 0;
10504 for (
auto &
I : RepeatedSequenceLocs[0]) {
10505 if (
I.isCFIInstruction())
10515 std::vector<MCCFIInstruction> CFIInstructions =
10516 C.getMF()->getFrameInstructions();
10518 if (CFICount > 0 && CFICount != CFIInstructions.size())
10519 return std::nullopt;
10527 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10528 !
MI.readsRegister(AArch64::SP, &
TRI))
10534 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10539 if (
MI.mayLoadOrStore()) {
10542 bool OffsetIsScalable;
10546 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10547 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10551 if (OffsetIsScalable)
10559 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10560 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10563 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10564 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10579 bool AllStackInstrsSafe =
10584 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10586 NumBytesToCreateFrame = 0;
10587 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10591 else if (LastInstrOpcode == AArch64::BL ||
10592 ((LastInstrOpcode == AArch64::BLR ||
10593 LastInstrOpcode == AArch64::BLRNoIP) &&
10597 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10605 unsigned NumBytesNoStackCalls = 0;
10606 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10612 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10621 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10624 if (LRAvailable && !IsNoReturn) {
10625 NumBytesNoStackCalls += 4;
10627 CandidatesWithoutStackFixups.push_back(
C);
10632 else if (findRegisterToSaveLRTo(
C)) {
10633 NumBytesNoStackCalls += 12;
10635 CandidatesWithoutStackFixups.push_back(
C);
10640 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10641 NumBytesNoStackCalls += 12;
10643 CandidatesWithoutStackFixups.push_back(
C);
10649 NumBytesNoStackCalls += SequenceSize;
10656 if (!AllStackInstrsSafe ||
10657 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10658 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10660 if (RepeatedSequenceLocs.size() < MinRepeats)
10661 return std::nullopt;
10714 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10715 !findRegisterToSaveLRTo(
C));
10721 if (RepeatedSequenceLocs.size() < MinRepeats)
10722 return std::nullopt;
10731 bool ModStackToSaveLR =
false;
10734 ModStackToSaveLR =
true;
10743 ModStackToSaveLR =
true;
10745 if (ModStackToSaveLR) {
10747 if (!AllStackInstrsSafe)
10748 return std::nullopt;
10751 NumBytesToCreateFrame += 8;
10758 return std::nullopt;
10760 return std::make_unique<outliner::OutlinedFunction>(
10761 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10764void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10765 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10769 const auto &CFn = Candidates.front().getMF()->getFunction();
10771 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10772 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10773 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10774 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10777 if (CFn.hasFnAttribute(
"sign-return-address"))
10778 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10779 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10780 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10782 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10785bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10790 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10797 if (
F.hasSection())
10803 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10804 if (!AFI || AFI->
hasRedZone().value_or(
true))
10824 unsigned &Flags)
const {
10826 "Must track liveness!");
10828 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10843 auto AreAllUnsafeRegsDead = [&LRU]() {
10844 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10845 LRU.available(AArch64::NZCV);
10860 bool LRAvailableEverywhere =
true;
10862 LRU.addLiveOuts(
MBB);
10864 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10865 if (
MI.isCall() && !
MI.isTerminator())
10871 auto CreateNewRangeStartingAt =
10872 [&RangeBegin, &RangeEnd,
10874 RangeBegin = NewBegin;
10875 RangeEnd = std::next(RangeBegin);
10878 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
10884 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
10886 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
10888 Ranges.emplace_back(RangeBegin, RangeEnd);
10896 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
10897 if (!FirstPossibleEndPt->isDebugInstr())
10898 LRU.stepBackward(*FirstPossibleEndPt);
10901 UpdateWholeMBBFlags(*FirstPossibleEndPt);
10902 if (AreAllUnsafeRegsDead())
10909 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
10914 if (!
MI.isDebugInstr())
10915 LRU.stepBackward(
MI);
10916 UpdateWholeMBBFlags(
MI);
10917 if (!AreAllUnsafeRegsDead()) {
10918 SaveRangeIfNonEmpty();
10919 CreateNewRangeStartingAt(
MI.getIterator());
10922 LRAvailableEverywhere &= LRU.available(AArch64::LR);
10923 RangeBegin =
MI.getIterator();
10928 if (AreAllUnsafeRegsDead())
10929 SaveRangeIfNonEmpty();
10937 if (!LRAvailableEverywhere)
10945 unsigned Flags)
const {
10946 MachineInstr &
MI = *MIT;
10950 switch (
MI.getOpcode()) {
10951 case AArch64::PACM:
10952 case AArch64::PACIASP:
10953 case AArch64::PACIBSP:
10954 case AArch64::PACIASPPC:
10955 case AArch64::PACIBSPPC:
10956 case AArch64::AUTIASP:
10957 case AArch64::AUTIBSP:
10958 case AArch64::AUTIASPPCi:
10959 case AArch64::AUTIASPPCr:
10960 case AArch64::AUTIBSPPCi:
10961 case AArch64::AUTIBSPPCr:
10962 case AArch64::RETAA:
10963 case AArch64::RETAB:
10964 case AArch64::RETAASPPCi:
10965 case AArch64::RETAASPPCr:
10966 case AArch64::RETABSPPCi:
10967 case AArch64::RETABSPPCr:
10968 case AArch64::EMITBKEY:
10969 case AArch64::PAUTH_PROLOGUE:
10970 case AArch64::PAUTH_EPILOGUE:
10980 if (
MI.isCFIInstruction())
10984 if (
MI.isTerminator())
10990 for (
const MachineOperand &MOP :
MI.operands()) {
10993 assert(!MOP.isCFIIndex());
10996 if (MOP.isReg() && !MOP.isImplicit() &&
10997 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11004 if (
MI.getOpcode() == AArch64::ADRP)
11024 for (
const MachineOperand &MOP :
MI.operands()) {
11025 if (MOP.isGlobal()) {
11033 if (Callee &&
Callee->getName() ==
"\01_mcount")
11041 if (
MI.getOpcode() == AArch64::BLR ||
11042 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11046 return UnknownCallOutlineType;
11054 return UnknownCallOutlineType;
11062 return UnknownCallOutlineType;
11083 for (MachineInstr &
MI :
MBB) {
11084 const MachineOperand *
Base;
11085 TypeSize Width(0,
false);
11087 bool OffsetIsScalable;
11090 if (!
MI.mayLoadOrStore() ||
11093 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11097 TypeSize Scale(0U,
false);
11098 int64_t Dummy1, Dummy2;
11101 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11103 assert(Scale != 0 &&
"Unexpected opcode!");
11104 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11109 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11110 StackOffsetOperand.
setImm(NewImm);
11116 bool ShouldSignReturnAddr) {
11117 if (!ShouldSignReturnAddr)
11125void AArch64InstrInfo::buildOutlinedFrame(
11129 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11137 unsigned TailOpcode;
11139 TailOpcode = AArch64::TCRETURNdi;
11143 TailOpcode = AArch64::TCRETURNriALL;
11154 bool IsLeafFunction =
true;
11157 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11158 return MI.isCall() && !
MI.isReturn();
11168 "Can only fix up stack references once");
11169 fixupPostOutline(
MBB);
11171 IsLeafFunction =
false;
11182 Et = std::prev(
MBB.
end());
11192 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11196 CFIBuilder.buildDefCFAOffset(16);
11200 CFIBuilder.buildOffset(AArch64::LR, -16);
11214 RASignCondition, !IsLeafFunction);
11243 fixupPostOutline(
MBB);
11254 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11264 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11273 MachineInstr *Save;
11274 MachineInstr *Restore;
11280 assert(
Reg &&
"No callee-saved register available?");
11314 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11322bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11330 bool AllowSideEffects)
const {
11332 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11335 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11348 assert(STI.hasNEON() &&
"Expected to have NEON.");
11354std::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 (!
MI.getOperand(0).getReg().isVirtual() ||
11366 MI.getOperand(0).getSubReg() == 0) &&
11367 (!
MI.getOperand(0).getReg().isPhysical() ||
11372 if (
MI.getOpcode() == AArch64::ORRXrs &&
11373 MI.getOperand(1).getReg() == AArch64::XZR &&
11374 MI.getOperand(3).getImm() == 0x0)
11377 return std::nullopt;
11380std::optional<DestSourcePair>
11382 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11383 MI.getOperand(1).getReg() == AArch64::WZR &&
11384 MI.getOperand(3).getImm() == 0x0) ||
11385 (
MI.getOpcode() == AArch64::ORRWrr &&
11386 MI.getOperand(1).getReg() == AArch64::WZR))
11388 return std::nullopt;
11391std::optional<RegImmPair>
11400 return std::nullopt;
11402 switch (
MI.getOpcode()) {
11404 return std::nullopt;
11405 case AArch64::SUBWri:
11406 case AArch64::SUBXri:
11407 case AArch64::SUBSWri:
11408 case AArch64::SUBSXri:
11411 case AArch64::ADDSWri:
11412 case AArch64::ADDSXri:
11413 case AArch64::ADDWri:
11414 case AArch64::ADDXri: {
11416 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11417 !
MI.getOperand(2).isImm())
11418 return std::nullopt;
11419 int Shift =
MI.getOperand(3).getImm();
11420 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11424 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11430static std::optional<ParamLoadedValue>
11434 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11436 return std::nullopt;
11438 Register DestReg = DestSrc->Destination->getReg();
11439 Register SrcReg = DestSrc->Source->getReg();
11442 return std::nullopt;
11447 if (DestReg == DescribedReg)
11451 if (
MI.getOpcode() == AArch64::ORRWrs &&
11452 TRI->isSuperRegister(DestReg, DescribedReg))
11456 if (
MI.getOpcode() == AArch64::ORRXrs &&
11457 TRI->isSubRegister(DestReg, DescribedReg)) {
11458 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11462 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11463 "Unhandled ORR[XW]rs copy case");
11465 return std::nullopt;
11468bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11473 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11479bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11483 auto isAsmGoto = [](
const MachineInstr &
MI) {
11484 return MI.getOpcode() == AArch64::INLINEASM_BR;
11494 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11501 for (
const MachineInstr &
MI :
MBB) {
11502 switch (
MI.getOpcode()) {
11503 case TargetOpcode::G_BRJT:
11504 case AArch64::JumpTableDest32:
11505 case AArch64::JumpTableDest16:
11506 case AArch64::JumpTableDest8:
11517std::optional<ParamLoadedValue>
11520 const MachineFunction *MF =
MI.getMF();
11522 switch (
MI.getOpcode()) {
11523 case AArch64::MOVZWi:
11524 case AArch64::MOVZXi: {
11527 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11528 return std::nullopt;
11530 if (!
MI.getOperand(1).isImm())
11531 return std::nullopt;
11532 int64_t Immediate =
MI.getOperand(1).getImm();
11533 int Shift =
MI.getOperand(2).getImm();
11537 case AArch64::ORRWrs:
11538 case AArch64::ORRXrs:
11545bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11548 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11549 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11552 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11562 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11565uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11569bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11573bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11578AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11582bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11583 unsigned Scale)
const {
11594 unsigned Shift =
Log2_64(NumBytes);
11595 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11603 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11608 return AArch64::BLRNoIP;
11610 return AArch64::BLR;
11616 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11626 if (Subtarget.hasPAuthLR())
11637 Register TargetReg,
bool FrameSetup)
const {
11638 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11650 MF.
insert(MBBInsertPoint, LoopTestMBB);
11653 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11655 MF.
insert(MBBInsertPoint, ExitMBB);
11665 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11673 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11679 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11696 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11715 MBB.addSuccessor(LoopTestMBB);
11721 return ExitMBB->
begin();
11726 MachineFunction *MF;
11727 const TargetInstrInfo *
TII;
11728 const TargetRegisterInfo *
TRI;
11729 MachineRegisterInfo &MRI;
11732 MachineBasicBlock *LoopBB;
11734 MachineInstr *CondBranch;
11736 MachineInstr *Comp;
11738 unsigned CompCounterOprNum;
11740 MachineInstr *Update;
11742 unsigned UpdateCounterOprNum;
11746 bool IsUpdatePriorComp;
11752 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11753 MachineInstr *Comp,
unsigned CompCounterOprNum,
11754 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11755 Register Init,
bool IsUpdatePriorComp,
11756 const SmallVectorImpl<MachineOperand> &
Cond)
11758 TII(MF->getSubtarget().getInstrInfo()),
11759 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11760 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11761 CompCounterOprNum(CompCounterOprNum), Update(Update),
11762 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11765 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11771 std::optional<bool> createTripCountGreaterCondition(
11772 int TC, MachineBasicBlock &
MBB,
11773 SmallVectorImpl<MachineOperand> &CondParam)
override {
11781 void createRemainingIterationsGreaterCondition(
11782 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11783 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11785 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11787 void adjustTripCount(
int TripCountAdjust)
override {}
11789 bool isMVEExpanderSupported()
override {
return true; }
11808 }
else if (
I == ReplaceOprNum) {
11813 MBB.insert(InsertTo, NewMI);
11817void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
11833 assert(CondBranch->getOpcode() == AArch64::Bcc);
11837 if (CondBranch->getOperand(1).getMBB() == LoopBB)
11844 auto AccumulateCond = [&](
Register CurCond,
11855 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
11859 for (
int I = 0;
I <= TC; ++
I) {
11865 AccCond = AccumulateCond(AccCond, CC);
11869 if (Update != Comp && IsUpdatePriorComp) {
11871 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11872 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
11876 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
11878 }
else if (Update != Comp) {
11883 Counter = NextCounter;
11887 if (LastStage0Insts.
empty()) {
11891 if (IsUpdatePriorComp)
11896 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
11899 for (
int I = 0;
I <= TC; ++
I) {
11903 AccCond = AccumulateCond(AccCond, CC);
11904 if (
I != TC && Update != Comp)
11907 Counter = NextCounter;
11923 assert(Phi.getNumOperands() == 5);
11924 if (Phi.getOperand(2).getMBB() ==
MBB) {
11925 RegMBB = Phi.getOperand(1).getReg();
11926 RegOther = Phi.getOperand(3).getReg();
11928 assert(Phi.getOperand(4).getMBB() ==
MBB);
11929 RegMBB = Phi.getOperand(3).getReg();
11930 RegOther = Phi.getOperand(1).getReg();
11935 if (!
Reg.isVirtual())
11944 unsigned &UpdateCounterOprNum,
Register &InitReg,
11945 bool &IsUpdatePriorComp) {
11959 if (!
Reg.isVirtual())
11962 UpdateInst =
nullptr;
11963 UpdateCounterOprNum = 0;
11965 IsUpdatePriorComp =
true;
11969 if (Def->getParent() != LoopBB)
11971 if (Def->isCopy()) {
11973 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
11975 CurReg = Def->getOperand(1).getReg();
11976 }
else if (Def->isPHI()) {
11980 IsUpdatePriorComp =
false;
11985 switch (Def->getOpcode()) {
11986 case AArch64::ADDSXri:
11987 case AArch64::ADDSWri:
11988 case AArch64::SUBSXri:
11989 case AArch64::SUBSWri:
11990 case AArch64::ADDXri:
11991 case AArch64::ADDWri:
11992 case AArch64::SUBXri:
11993 case AArch64::SUBWri:
11995 UpdateCounterOprNum = 1;
11997 case AArch64::ADDSXrr:
11998 case AArch64::ADDSWrr:
11999 case AArch64::SUBSXrr:
12000 case AArch64::SUBSWrr:
12001 case AArch64::ADDXrr:
12002 case AArch64::ADDWrr:
12003 case AArch64::SUBXrr:
12004 case AArch64::SUBWrr:
12007 UpdateCounterOprNum = 1;
12009 UpdateCounterOprNum = 2;
12016 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12031std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12042 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12053 if (
TBB == LoopBB && FBB == LoopBB)
12057 if (
TBB != LoopBB && FBB ==
nullptr)
12060 assert((
TBB == LoopBB || FBB == LoopBB) &&
12061 "The Loop must be a single-basic-block loop");
12066 if (CondBranch->
getOpcode() != AArch64::Bcc)
12074 unsigned CompCounterOprNum = 0;
12076 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12080 switch (
MI.getOpcode()) {
12081 case AArch64::SUBSXri:
12082 case AArch64::SUBSWri:
12083 case AArch64::ADDSXri:
12084 case AArch64::ADDSWri:
12086 CompCounterOprNum = 1;
12088 case AArch64::ADDSWrr:
12089 case AArch64::ADDSXrr:
12090 case AArch64::SUBSWrr:
12091 case AArch64::SUBSXrr:
12095 if (isWhileOpcode(
MI.getOpcode())) {
12102 if (CompCounterOprNum == 0) {
12104 CompCounterOprNum = 2;
12106 CompCounterOprNum = 1;
12118 bool IsUpdatePriorComp;
12119 unsigned UpdateCounterOprNum;
12121 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12124 return std::make_unique<AArch64PipelinerLoopInfo>(
12125 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12135 TypeSize Scale(0U,
false), Width(0U,
false);
12136 int64_t MinOffset, MaxOffset;
12137 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12139 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12140 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
12141 if (Imm < MinOffset || Imm > MaxOffset) {
12142 ErrInfo =
"Unexpected immediate on load/store instruction";
12148 const MCInstrDesc &MCID =
MI.getDesc();
12150 const MachineOperand &MO =
MI.getOperand(
Op);
12154 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12163 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12169 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12175 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12186#define GET_INSTRINFO_HELPERS
12187#define GET_INSTRMAP_INFO
12188#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.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
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 ...
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.