66#define GET_INSTRINFO_CTOR_DTOR
67#include "AArch64GenInstrInfo.inc"
69#define DEBUG_TYPE "AArch64InstrInfo"
71STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
72STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
73 "instructions expanded from canonical COPY");
74STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
75 "instructions expanded from canonical COPY");
76STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
77 "instructions expanded from canonical COPY");
83 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
93 switch (
MI.getOpcode()) {
103 if (
MI.getOperand(0).getReg() != AArch64::LR)
117 case AArch64::BLRAAZ:
119 case AArch64::BLRABZ:
129 case AArch64::TLSDESC_CALLSEQ:
132 case AArch64::TLSDESC_AUTH_CALLSEQ:
136 case AArch64::AUTIASP:
137 case AArch64::AUTIBSP:
138 case AArch64::AUTIAZ:
139 case AArch64::AUTIBZ:
140 case AArch64::XPACLRI:
145 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
146 MI.getOperand(3).getImm() == 1)
154 bool ModifiesLR =
false;
155 bool ModifiesSP =
false;
159 if (MO.getReg() == AArch64::LR)
161 else if (MO.getReg() == AArch64::SP)
170 if (
MI.mayLoadOrStore()) {
178 if (ModifiesSP || ModifiesLR)
191 if (!
Desc.isPseudo() && !Subtarget.isLFI()) {
192 assert(
Desc.getSize() == 4 &&
"Unexpected instruction size");
196 unsigned NumBytes = getInstSizeInBytesNoGuard(
MI);
201 if (Subtarget.isLFI() && !
MI.isBundle() &&
202 (
MI.isCall() ||
MI.isBranch() ||
MI.isReturn()))
209AArch64InstrInfo::getInstSizeInBytesNoGuard(
const MachineInstr &
MI)
const {
217 auto Op =
MI.getOpcode();
218 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
219 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
223 if (
MI.isMetaInstruction())
228 unsigned NumBytes = 0;
237 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
240 unsigned Opc =
MI.getOpcode();
241 if (
Opc == AArch64::AUTH_TCRETURN ||
Opc == AArch64::AUTH_TCRETURN_BTI) {
244 }
else if (
MI.getOperand(0).isReg()) {
250 const auto *MFI = MF->
getInfo<AArch64FunctionInfo>();
251 if (!MFI->shouldSignReturnAddress(*MF))
254 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
262 switch (
Desc.getOpcode()) {
265 return Desc.getSize();
272 case TargetOpcode::STACKMAP:
274 NumBytes = StackMapOpers(&
MI).getNumPatchBytes();
275 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
277 case TargetOpcode::PATCHPOINT:
279 NumBytes = PatchPointOpers(&
MI).getNumPatchBytes();
280 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
282 case TargetOpcode::STATEPOINT:
283 NumBytes = StatepointOpers(&
MI).getNumPatchBytes();
284 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
289 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
294 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
296 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
297 case TargetOpcode::PATCHABLE_TAIL_CALL:
298 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
302 case TargetOpcode::PATCHABLE_EVENT_CALL:
308 NumBytes =
MI.getOperand(1).getImm();
310 case AArch64::MOVaddr:
311 case AArch64::MOVaddrJT:
312 case AArch64::MOVaddrCP:
313 case AArch64::MOVaddrBA:
314 case AArch64::MOVaddrTLS:
315 case AArch64::MOVaddrEXT: {
319 MI.getOperand(1).getTargetFlags(),
320 Subtarget.isTargetMachO(), Insn);
321 NumBytes = Insn.
size() * 4;
325 case AArch64::MOVi32imm:
326 case AArch64::MOVi64imm: {
328 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
331 NumBytes = Insn.
size() * 4;
335 case TargetOpcode::BUNDLE:
336 NumBytes = getInstBundleSize(
MI);
372 case AArch64::CBWPri:
373 case AArch64::CBXPri:
374 case AArch64::CBWPrr:
375 case AArch64::CBXPrr:
383 case AArch64::CBBAssertExt:
384 case AArch64::CBHAssertExt:
403 return CLOpts.b_offset_bits;
408 return CLOpts.tbz_offset_bits;
413 return CLOpts.cbz_offset_bits;
415 return CLOpts.bcc_offset_bits;
416 case AArch64::CBWPri:
417 case AArch64::CBXPri:
418 case AArch64::CBBAssertExt:
419 case AArch64::CBHAssertExt:
420 case AArch64::CBWPrr:
421 case AArch64::CBXPrr:
422 return CLOpts.cb_offset_bits;
427 int64_t BrOffset)
const {
429 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
430 "over conditional branch expansion");
431 return isIntN(Bits, BrOffset / 4);
436 switch (
MI.getOpcode()) {
440 return MI.getOperand(0).getMBB();
445 return MI.getOperand(2).getMBB();
451 return MI.getOperand(1).getMBB();
452 case AArch64::CBWPri:
453 case AArch64::CBXPri:
454 case AArch64::CBBAssertExt:
455 case AArch64::CBHAssertExt:
456 case AArch64::CBWPrr:
457 case AArch64::CBXPrr:
458 return MI.getOperand(3).getMBB();
468 assert(RS &&
"RegScavenger required for long branching");
470 "new block should be inserted for expanding unconditional branch");
473 "restore block should be inserted for restoring clobbered registers");
480 "Branch offsets outside of the signed 33-bit range not supported");
491 RS->enterBasicBlockEnd(
MBB);
494 constexpr Register Reg = AArch64::X16;
495 if (!RS->isRegUsed(Reg)) {
496 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
507 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
509 buildIndirectBranch(Scavenged, NewDestBB);
510 RS->setRegUsed(Scavenged);
519 "Unable to insert indirect branch inside function that has red zone");
542 bool AllowModify)
const {
549 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
550 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
554 if (!isUnpredicatedTerminator(*
I))
561 unsigned LastOpc = LastInst->
getOpcode();
562 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
577 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
584 LastInst = SecondLastInst;
586 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
591 SecondLastInst = &*
I;
592 SecondLastOpc = SecondLastInst->
getOpcode();
603 LastInst = SecondLastInst;
605 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
607 "unreachable unconditional branches removed above");
616 SecondLastInst = &*
I;
617 SecondLastOpc = SecondLastInst->
getOpcode();
621 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
637 I->eraseFromParent();
646 I->eraseFromParent();
655 MachineBranchPredicate &MBP,
656 bool AllowModify)
const {
668 assert(MBP.TrueDest &&
"expected!");
669 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
671 MBP.ConditionDef =
nullptr;
672 MBP.SingleUseCondition =
false;
682 if (
I ==
MBB.begin())
698 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
699 MBP.ConditionDef = &
MI;
708 case AArch64::CBNZX: {
712 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
713 ? MachineBranchPredicate::PRED_NE
714 : MachineBranchPredicate::PRED_EQ;
715 Register CondReg = MBP.LHS.getReg();
717 MBP.ConditionDef =
MRI.getVRegDef(CondReg);
724 case AArch64::TBNZX: {
727 MBP.ConditionDef =
MRI.getVRegDef(CondReg);
745 Cond[1].setImm(AArch64::CBNZW);
748 Cond[1].setImm(AArch64::CBZW);
751 Cond[1].setImm(AArch64::CBNZX);
754 Cond[1].setImm(AArch64::CBZX);
757 Cond[1].setImm(AArch64::TBNZW);
760 Cond[1].setImm(AArch64::TBZW);
763 Cond[1].setImm(AArch64::TBNZX);
766 Cond[1].setImm(AArch64::TBZX);
770 case AArch64::CBWPri:
771 case AArch64::CBXPri:
772 case AArch64::CBBAssertExt:
773 case AArch64::CBHAssertExt:
774 case AArch64::CBWPrr:
775 case AArch64::CBXPrr: {
788 int *BytesRemoved)
const {
798 I->eraseFromParent();
802 if (
I ==
MBB.begin()) {
815 I->eraseFromParent();
822void AArch64InstrInfo::instantiateCondBranch(
847 if (
Cond.size() > 5) {
858 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
889 return Opc == AArch64::CBBAssertExt;
892 return Opc == AArch64::CBHAssertExt;
904 switch (
Cond.size()) {
936 MRI.constrainRegClass(SrcReg, &AArch64::GPR64spRegClass);
942 MRI.constrainRegClass(SrcReg, &AArch64::GPR32spRegClass);
979 unsigned SubsOpc, SubsDestReg;
985 case AArch64::CBWPri:
986 SubsOpc = AArch64::SUBSWri;
987 SubsDestReg = AArch64::WZR;
990 case AArch64::CBXPri:
991 SubsOpc = AArch64::SUBSXri;
992 SubsDestReg = AArch64::XZR;
995 case AArch64::CBWPrr:
996 SubsOpc = AArch64::SUBSWrr;
997 SubsDestReg = AArch64::WZR;
1000 case AArch64::CBXPrr:
1001 SubsOpc = AArch64::SUBSXrr;
1002 SubsDestReg = AArch64::XZR;
1036 "Unexpected compare-and-branch instruction for extend type");
1037 switch (ExtendType) {
1041 ExtOpc = AArch64::SBFMWri;
1045 ExtOpc = AArch64::SBFMWri;
1049 ExtOpc = AArch64::ANDWri;
1053 ExtOpc = AArch64::ANDWri;
1059 Reg =
MRI.createVirtualRegister(&AArch64::GPR32commonRegClass);
1062 if (ExtOpc != AArch64::ANDWri)
1064 MBBI.addImm(ExtBits);
1069 MRI.constrainRegClass(Reg, &AArch64::GPR32commonRegClass);
1073 "Unexpected compare-and-branch instruction for extend type");
1094 unsigned Opc =
MI.getOpcode();
1101 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1102 MI.getOperand(0).getReg() == AArch64::XZR) {
1104 dbgs() <<
"Removing always taken branch: " <<
MI);
1107 for (
auto *S : Succs)
1109 MBB->removeSuccessor(S);
1111 while (
MBB->rbegin() != &
MI)
1112 MBB->rbegin()->eraseFromParent();
1113 MI.eraseFromParent();
1118 case AArch64::CBNZW:
1119 case AArch64::CBNZX:
1120 case AArch64::TBNZW:
1121 case AArch64::TBNZX:
1123 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1124 MI.getOperand(0).getReg() == AArch64::XZR) {
1126 dbgs() <<
"Removing never taken branch: " <<
MI);
1128 MI.getParent()->removeSuccessor(
Target);
1129 MI.eraseFromParent();
1144 VReg =
DefMI->getOperand(1).getReg();
1153 unsigned *NewReg =
nullptr) {
1158 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(
MRI.getRegClass(VReg));
1163 unsigned SrcReg = 0;
1164 switch (
DefMI->getOpcode()) {
1165 case AArch64::SUBREG_TO_REG:
1169 if (!
DefMI->getOperand(1).isReg())
1171 if (!
DefMI->getOperand(2).isImm() ||
1172 DefMI->getOperand(2).getImm() != AArch64::sub_32)
1175 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
1177 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1180 SrcReg = AArch64::XZR;
1181 Opc = AArch64::CSINCXr;
1184 case AArch64::MOVi32imm:
1185 case AArch64::MOVi64imm:
1186 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1188 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
1189 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1192 case AArch64::ADDSXri:
1193 case AArch64::ADDSWri:
1195 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1200 case AArch64::ADDXri:
1201 case AArch64::ADDWri:
1203 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
1204 DefMI->getOperand(3).getImm() != 0)
1206 SrcReg =
DefMI->getOperand(1).getReg();
1207 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1210 case AArch64::ORNXrr:
1211 case AArch64::ORNWrr: {
1214 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1216 SrcReg =
DefMI->getOperand(2).getReg();
1217 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
1221 case AArch64::SUBSXrr:
1222 case AArch64::SUBSWrr:
1224 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1229 case AArch64::SUBXrr:
1230 case AArch64::SUBWrr: {
1233 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1235 SrcReg =
DefMI->getOperand(2).getReg();
1236 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1242 assert(
Opc && SrcReg &&
"Missing parameters");
1253 SelectExpansion &Exp)
const {
1257 RI.getCommonSubClass(
MRI.getRegClass(TrueReg),
MRI.getRegClass(FalseReg));
1264 if (!RI.getCommonSubClass(RC,
MRI.getRegClass(DstReg)))
1269 unsigned ExtraCondLat =
Cond.size() != 1;
1270 Exp.NumInsts = 1 + ExtraCondLat;
1272 Exp.ClobberedPhysRegs.push_back(AArch64::NZCV);
1276 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1277 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1279 Exp.CondCycles = 1 + ExtraCondLat;
1280 Exp.TrueCycles = Exp.FalseCycles = 1;
1284 Exp.FalseCycles = 0;
1290 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1291 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1292 Exp.CondCycles = 5 + ExtraCondLat;
1293 Exp.TrueCycles = Exp.FalseCycles = 2;
1299 if (AArch64::FPR128RegClass.hasSubClassEq(RC) &&
1300 Subtarget.isNeonAvailable() &&
1301 !
MBB.getParent()->getFunction().hasMinSize()) {
1302 Exp.CondCycles = 8 + ExtraCondLat;
1303 Exp.TrueCycles = Exp.FalseCycles = 2;
1304 Exp.NumInsts = 3 + ExtraCondLat;
1322 if (
MRI.constrainRegClass(DstReg, &AArch64::FPR128RegClass)) {
1323 assert(Subtarget.isNeonAvailable() &&
"Expected NEON for a vector select");
1324 MRI.constrainRegClass(TrueReg, &AArch64::FPR128RegClass);
1325 MRI.constrainRegClass(FalseReg, &AArch64::FPR128RegClass);
1326 Register CondSet =
MRI.createVirtualRegister(&AArch64::GPR64RegClass);
1331 Register Mask =
MRI.createVirtualRegister(&AArch64::FPR128RegClass);
1342 bool TryFold =
false;
1343 if (
MRI.constrainRegClass(DstReg, &AArch64::GPR64RegClass)) {
1344 RC = &AArch64::GPR64RegClass;
1345 Opc = AArch64::CSELXr;
1347 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::GPR32RegClass)) {
1348 RC = &AArch64::GPR32RegClass;
1349 Opc = AArch64::CSELWr;
1351 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR64RegClass)) {
1352 RC = &AArch64::FPR64RegClass;
1353 Opc = AArch64::FCSELDrrr;
1354 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR32RegClass)) {
1355 RC = &AArch64::FPR32RegClass;
1356 Opc = AArch64::FCSELSrrr;
1358 assert(RC &&
"Unsupported regclass");
1362 unsigned NewReg = 0;
1380 MRI.constrainRegClass(TrueReg, RC);
1383 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1384 FalseReg == AArch64::XZR) &&
1385 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1387 MRI.constrainRegClass(FalseReg, RC);
1402 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1407 return Is.
size() <= 2;
1412 assert(
MI.isCopy() &&
"Expected COPY instruction");
1418 if (
Reg.isVirtual())
1419 return MRI.getRegClass(
Reg);
1420 if (
Reg.isPhysical())
1421 return RI.getMinimalPhysRegClass(
Reg);
1426 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1429 return MI.isAsCheapAsAMove();
1435 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1436 if (isExynosCheapAsMove(
MI))
1438 return MI.isAsCheapAsAMove();
1441 switch (
MI.getOpcode()) {
1443 return MI.isAsCheapAsAMove();
1445 case TargetOpcode::COPY:
1448 case AArch64::ADDWrs:
1449 case AArch64::ADDXrs:
1450 case AArch64::SUBWrs:
1451 case AArch64::SUBXrs:
1452 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1457 case AArch64::MOVi32imm:
1459 case AArch64::MOVi64imm:
1464bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1465 switch (
MI.getOpcode()) {
1469 case AArch64::ADDWrs:
1470 case AArch64::ADDXrs:
1471 case AArch64::ADDSWrs:
1472 case AArch64::ADDSXrs: {
1473 unsigned Imm =
MI.getOperand(3).getImm();
1480 case AArch64::ADDWrx:
1481 case AArch64::ADDXrx:
1482 case AArch64::ADDXrx64:
1483 case AArch64::ADDSWrx:
1484 case AArch64::ADDSXrx:
1485 case AArch64::ADDSXrx64: {
1486 unsigned Imm =
MI.getOperand(3).getImm();
1498 case AArch64::SUBWrs:
1499 case AArch64::SUBSWrs: {
1500 unsigned Imm =
MI.getOperand(3).getImm();
1502 return ShiftVal == 0 ||
1506 case AArch64::SUBXrs:
1507 case AArch64::SUBSXrs: {
1508 unsigned Imm =
MI.getOperand(3).getImm();
1510 return ShiftVal == 0 ||
1514 case AArch64::SUBWrx:
1515 case AArch64::SUBXrx:
1516 case AArch64::SUBXrx64:
1517 case AArch64::SUBSWrx:
1518 case AArch64::SUBSXrx:
1519 case AArch64::SUBSXrx64: {
1520 unsigned Imm =
MI.getOperand(3).getImm();
1532 case AArch64::LDRBBroW:
1533 case AArch64::LDRBBroX:
1534 case AArch64::LDRBroW:
1535 case AArch64::LDRBroX:
1536 case AArch64::LDRDroW:
1537 case AArch64::LDRDroX:
1538 case AArch64::LDRHHroW:
1539 case AArch64::LDRHHroX:
1540 case AArch64::LDRHroW:
1541 case AArch64::LDRHroX:
1542 case AArch64::LDRQroW:
1543 case AArch64::LDRQroX:
1544 case AArch64::LDRSBWroW:
1545 case AArch64::LDRSBWroX:
1546 case AArch64::LDRSBXroW:
1547 case AArch64::LDRSBXroX:
1548 case AArch64::LDRSHWroW:
1549 case AArch64::LDRSHWroX:
1550 case AArch64::LDRSHXroW:
1551 case AArch64::LDRSHXroX:
1552 case AArch64::LDRSWroW:
1553 case AArch64::LDRSWroX:
1554 case AArch64::LDRSroW:
1555 case AArch64::LDRSroX:
1556 case AArch64::LDRWroW:
1557 case AArch64::LDRWroX:
1558 case AArch64::LDRXroW:
1559 case AArch64::LDRXroX:
1560 case AArch64::PRFMroW:
1561 case AArch64::PRFMroX:
1562 case AArch64::STRBBroW:
1563 case AArch64::STRBBroX:
1564 case AArch64::STRBroW:
1565 case AArch64::STRBroX:
1566 case AArch64::STRDroW:
1567 case AArch64::STRDroX:
1568 case AArch64::STRHHroW:
1569 case AArch64::STRHHroX:
1570 case AArch64::STRHroW:
1571 case AArch64::STRHroX:
1572 case AArch64::STRQroW:
1573 case AArch64::STRQroX:
1574 case AArch64::STRSroW:
1575 case AArch64::STRSroX:
1576 case AArch64::STRWroW:
1577 case AArch64::STRWroX:
1578 case AArch64::STRXroW:
1579 case AArch64::STRXroX: {
1580 unsigned IsSigned =
MI.getOperand(3).getImm();
1587 unsigned Opc =
MI.getOpcode();
1591 case AArch64::SEH_StartProc:
1592 case AArch64::SEH_EndProc:
1593 case AArch64::SEH_EndC:
1594 case AArch64::SEH_StackAlloc:
1595 case AArch64::SEH_SaveFPLR:
1596 case AArch64::SEH_SaveFPLR_X:
1597 case AArch64::SEH_SaveReg:
1598 case AArch64::SEH_SaveReg_X:
1599 case AArch64::SEH_SaveRegP:
1600 case AArch64::SEH_SaveRegP_X:
1601 case AArch64::SEH_SaveFReg:
1602 case AArch64::SEH_SaveFReg_X:
1603 case AArch64::SEH_SaveFRegP:
1604 case AArch64::SEH_SaveFRegP_X:
1605 case AArch64::SEH_SetFP:
1606 case AArch64::SEH_AddFP:
1607 case AArch64::SEH_Nop:
1608 case AArch64::SEH_PrologEnd:
1609 case AArch64::SEH_EpilogStart:
1610 case AArch64::SEH_EpilogEnd:
1611 case AArch64::SEH_PACSignLR:
1612 case AArch64::SEH_SaveAnyRegI:
1613 case AArch64::SEH_SaveAnyRegIP:
1614 case AArch64::SEH_SaveAnyRegQ:
1615 case AArch64::SEH_SaveAnyRegQX:
1616 case AArch64::SEH_SaveAnyRegQP:
1617 case AArch64::SEH_SaveAnyRegQPX:
1618 case AArch64::SEH_AllocZ:
1619 case AArch64::SEH_SaveZReg:
1620 case AArch64::SEH_SavePReg:
1627 unsigned &SubIdx)
const {
1628 switch (
MI.getOpcode()) {
1631 case AArch64::SBFMXri:
1632 case AArch64::UBFMXri:
1635 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1638 SrcReg =
MI.getOperand(1).getReg();
1639 DstReg =
MI.getOperand(0).getReg();
1640 SubIdx = AArch64::sub_32;
1648 int64_t OffsetA = 0, OffsetB = 0;
1649 TypeSize WidthA(0,
false), WidthB(0,
false);
1650 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1671 OffsetAIsScalable == OffsetBIsScalable) {
1672 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1673 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1674 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1675 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1693 switch (
MI.getOpcode()) {
1694 case AArch64::PAUTH_EPILOGUE:
1700 if (
MI.getOperand(0).getImm() == 0x14)
1707 case AArch64::MSRpstatesvcrImm1:
1717 return Next !=
MBB->instr_end() &&
Next->isCFIInstruction();
1724 Register &SrcReg2, int64_t &CmpMask,
1725 int64_t &CmpValue)
const {
1729 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1730 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1733 switch (
MI.getOpcode()) {
1736 case AArch64::PTEST_PP:
1737 case AArch64::PTEST_PP_ANY:
1738 case AArch64::PTEST_PP_FIRST:
1739 SrcReg =
MI.getOperand(0).getReg();
1740 SrcReg2 =
MI.getOperand(1).getReg();
1741 if (
MI.getOperand(2).getSubReg())
1748 case AArch64::SUBSWrr:
1749 case AArch64::SUBSWrs:
1750 case AArch64::SUBSWrx:
1751 case AArch64::SUBSXrr:
1752 case AArch64::SUBSXrs:
1753 case AArch64::SUBSXrx:
1754 case AArch64::ADDSWrr:
1755 case AArch64::ADDSWrs:
1756 case AArch64::ADDSWrx:
1757 case AArch64::ADDSXrr:
1758 case AArch64::ADDSXrs:
1759 case AArch64::ADDSXrx:
1761 SrcReg =
MI.getOperand(1).getReg();
1762 SrcReg2 =
MI.getOperand(2).getReg();
1765 if (
MI.getOperand(2).getSubReg())
1771 case AArch64::SUBSWri:
1772 case AArch64::ADDSWri:
1773 case AArch64::SUBSXri:
1774 case AArch64::ADDSXri:
1775 SrcReg =
MI.getOperand(1).getReg();
1778 CmpValue =
MI.getOperand(2).getImm();
1780 case AArch64::ANDSWri:
1781 case AArch64::ANDSXri:
1784 SrcReg =
MI.getOperand(1).getReg();
1788 MI.getOperand(2).getImm(),
1789 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1798 assert(
MBB &&
"Can't get MachineBasicBlock here");
1800 assert(MF &&
"Can't get MachineFunction here");
1805 for (
const auto &[OpIdx, MO] :
enumerate(Instr.operands())) {
1806 if (!MO.isReg() || !MO.getReg().isVirtual())
1812 if (!NewRC || !
MRI->constrainRegClass(
Reg, NewRC))
1823 bool MIDefinesZeroReg =
false;
1824 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1825 MI.definesRegister(AArch64::XZR,
nullptr))
1826 MIDefinesZeroReg =
true;
1828 switch (
MI.getOpcode()) {
1830 return MI.getOpcode();
1831 case AArch64::ADDSWrr:
1832 return AArch64::ADDWrr;
1833 case AArch64::ADDSWri:
1834 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1835 case AArch64::ADDSWrs:
1836 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1837 case AArch64::ADDSWrx:
1838 return AArch64::ADDWrx;
1839 case AArch64::ADDSXrr:
1840 return AArch64::ADDXrr;
1841 case AArch64::ADDSXri:
1842 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1843 case AArch64::ADDSXrs:
1844 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1845 case AArch64::ADDSXrx:
1846 return AArch64::ADDXrx;
1847 case AArch64::SUBSWrr:
1848 return AArch64::SUBWrr;
1849 case AArch64::SUBSWri:
1850 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1851 case AArch64::SUBSWrs:
1852 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1853 case AArch64::SUBSWrx:
1854 return AArch64::SUBWrx;
1855 case AArch64::SUBSXrr:
1856 return AArch64::SUBXrr;
1857 case AArch64::SUBSXri:
1858 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1859 case AArch64::SUBSXrs:
1860 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1861 case AArch64::SUBSXrx:
1862 return AArch64::SUBXrx;
1877 if (To == To->getParent()->begin())
1882 if (To->getParent() != From->getParent())
1894 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1895 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1901std::optional<unsigned>
1905 unsigned MaskOpcode =
Mask->getOpcode();
1907 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1908 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1910 if (PredIsWhileLike) {
1914 if ((Mask ==
Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1921 getElementSizeForOpcode(MaskOpcode) ==
1922 getElementSizeForOpcode(PredOpcode))
1928 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1935 if (PredIsPTestLike) {
1940 if ((Mask ==
Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1948 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1949 PTestLikeMask->getOperand(1).getReg().isVirtual())
1957 getElementSizeForOpcode(MaskOpcode) ==
1958 getElementSizeForOpcode(PredOpcode)) {
1959 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1985 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1987 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1995 switch (PredOpcode) {
1996 case AArch64::AND_PPzPP:
1997 case AArch64::BIC_PPzPP:
1998 case AArch64::EOR_PPzPP:
1999 case AArch64::NAND_PPzPP:
2000 case AArch64::NOR_PPzPP:
2001 case AArch64::ORN_PPzPP:
2002 case AArch64::ORR_PPzPP:
2003 case AArch64::BRKA_PPzP:
2004 case AArch64::BRKPA_PPzPP:
2005 case AArch64::BRKB_PPzP:
2006 case AArch64::BRKPB_PPzPP:
2007 case AArch64::RDFFR_PPz: {
2011 if (Mask != PredMask)
2015 case AArch64::BRKN_PPzP: {
2019 if ((MaskOpcode != AArch64::PTRUE_B) ||
2020 (
Mask->getOperand(1).getImm() != 31))
2024 case AArch64::PTRUE_B:
2037bool AArch64InstrInfo::optimizePTestInstr(
2038 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
2043 if (
Pred->isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
2047 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
2048 Op.getSubReg() == AArch64::psub0)
2053 auto NewOp = canRemovePTestInstr(PTest, Mask,
Pred,
MRI);
2069 if (*NewOp != PredOpcode) {
2072 Pred->addRegisterDefined(AArch64::NZCV,
TRI);
2076 if (
Pred->registerDefIsDead(AArch64::NZCV,
TRI)) {
2078 for (; i !=
e; ++i) {
2109 if (DeadNZCVIdx != -1) {
2126 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2127 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2128 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2129 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2,
MRI);
2138 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *
MRI))
2140 return (CmpValue == 0 || CmpValue == 1) &&
2141 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *
MRI);
2149 switch (Instr.getOpcode()) {
2151 return AArch64::INSTRUCTION_LIST_END;
2153 case AArch64::ADDSWrr:
2154 case AArch64::ADDSWri:
2155 case AArch64::ADDSXrr:
2156 case AArch64::ADDSXri:
2157 case AArch64::ADDSWrx:
2158 case AArch64::ADDSXrx:
2159 case AArch64::ADDSWrs:
2160 case AArch64::ADDSXrs:
2161 case AArch64::SUBSWrr:
2162 case AArch64::SUBSWri:
2163 case AArch64::SUBSWrx:
2164 case AArch64::SUBSWrs:
2165 case AArch64::SUBSXrr:
2166 case AArch64::SUBSXri:
2167 case AArch64::SUBSXrx:
2168 case AArch64::SUBSXrs:
2169 case AArch64::ANDSWri:
2170 case AArch64::ANDSWrr:
2171 case AArch64::ANDSWrs:
2172 case AArch64::ANDSXri:
2173 case AArch64::ANDSXrr:
2174 case AArch64::ANDSXrs:
2175 case AArch64::BICSWrr:
2176 case AArch64::BICSXrr:
2177 case AArch64::BICSWrs:
2178 case AArch64::BICSXrs:
2179 case AArch64::ADCSWr:
2180 case AArch64::ADCSXr:
2181 case AArch64::SBCSWr:
2182 case AArch64::SBCSXr:
2183 return Instr.getOpcode();
2185 case AArch64::ADDWrr:
2186 return AArch64::ADDSWrr;
2187 case AArch64::ADDWri:
2188 return AArch64::ADDSWri;
2189 case AArch64::ADDXrr:
2190 return AArch64::ADDSXrr;
2191 case AArch64::ADDXri:
2192 return AArch64::ADDSXri;
2193 case AArch64::ADDWrx:
2194 return AArch64::ADDSWrx;
2195 case AArch64::ADDXrx:
2196 return AArch64::ADDSXrx;
2197 case AArch64::ADDWrs:
2198 return AArch64::ADDSWrs;
2199 case AArch64::ADDXrs:
2200 return AArch64::ADDSXrs;
2201 case AArch64::ADCWr:
2202 return AArch64::ADCSWr;
2203 case AArch64::ADCXr:
2204 return AArch64::ADCSXr;
2205 case AArch64::SUBWrr:
2206 return AArch64::SUBSWrr;
2207 case AArch64::SUBWri:
2208 return AArch64::SUBSWri;
2209 case AArch64::SUBXrr:
2210 return AArch64::SUBSXrr;
2211 case AArch64::SUBXri:
2212 return AArch64::SUBSXri;
2213 case AArch64::SUBWrx:
2214 return AArch64::SUBSWrx;
2215 case AArch64::SUBXrx:
2216 return AArch64::SUBSXrx;
2217 case AArch64::SUBWrs:
2218 return AArch64::SUBSWrs;
2219 case AArch64::SUBXrs:
2220 return AArch64::SUBSXrs;
2221 case AArch64::SBCWr:
2222 return AArch64::SBCSWr;
2223 case AArch64::SBCXr:
2224 return AArch64::SBCSXr;
2225 case AArch64::ANDWri:
2226 return AArch64::ANDSWri;
2227 case AArch64::ANDXri:
2228 return AArch64::ANDSXri;
2229 case AArch64::ANDWrr:
2230 return AArch64::ANDSWrr;
2231 case AArch64::ANDWrs:
2232 return AArch64::ANDSWrs;
2233 case AArch64::ANDXrr:
2234 return AArch64::ANDSXrr;
2235 case AArch64::ANDXrs:
2236 return AArch64::ANDSXrs;
2237 case AArch64::BICWrr:
2238 return AArch64::BICSWrr;
2239 case AArch64::BICXrr:
2240 return AArch64::BICSXrr;
2241 case AArch64::BICWrs:
2242 return AArch64::BICSWrs;
2243 case AArch64::BICXrs:
2244 return AArch64::BICSXrs;
2250 for (
auto *BB :
MBB->successors())
2251 if (BB->isLiveIn(AArch64::NZCV))
2258int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2260 switch (
Instr.getOpcode()) {
2264 case AArch64::Bcc: {
2265 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2270 case AArch64::CSINVWr:
2271 case AArch64::CSINVXr:
2272 case AArch64::CSINCWr:
2273 case AArch64::CSINCXr:
2274 case AArch64::CSELWr:
2275 case AArch64::CSELXr:
2276 case AArch64::CSNEGWr:
2277 case AArch64::CSNEGXr:
2278 case AArch64::FCSELSrrr:
2279 case AArch64::FCSELDrrr: {
2280 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2292 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2294 Instr.getOperand(CCIdx).
getImm())
2347std::optional<UsedNZCV>
2352 if (
MI.getParent() != CmpParent)
2353 return std::nullopt;
2356 return std::nullopt;
2361 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2364 return std::nullopt;
2369 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2372 return NZCVUsedAfterCmp;
2376 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2380 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2386 case AArch64::ANDSWri:
2387 case AArch64::ANDSWrr:
2388 case AArch64::ANDSWrs:
2389 case AArch64::ANDSXri:
2390 case AArch64::ANDSXrr:
2391 case AArch64::ANDSXrs:
2392 case AArch64::BICSWrr:
2393 case AArch64::BICSXrr:
2394 case AArch64::BICSWrs:
2395 case AArch64::BICSXrs:
2421 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2427 "Caller guarantees that CmpInstr compares with constant 0");
2430 if (!NZVCUsed || NZVCUsed->C)
2451bool AArch64InstrInfo::substituteCmpToZero(
2462 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2469 MI->setDesc(
get(NewOpc));
2472 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2484 assert((CmpValue == 0 || CmpValue == 1) &&
2485 "Only comparisons to 0 or 1 considered for removal!");
2488 unsigned MIOpc =
MI.getOpcode();
2489 if (MIOpc == AArch64::CSINCWr) {
2490 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2491 MI.getOperand(2).getReg() != AArch64::WZR)
2493 }
else if (MIOpc == AArch64::CSINCXr) {
2494 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2495 MI.getOperand(2).getReg() != AArch64::XZR)
2505 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2509 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2511 if (CmpValue && !IsSubsRegImm)
2513 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2518 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2521 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2525 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2528 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2529 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2532 if (MIUsedNZCV.
N && !CmpValue)
2574bool AArch64InstrInfo::removeCmpToZeroOrOne(
2581 SmallVector<MachineInstr *, 4> CCUseInstrs;
2582 bool IsInvertCC =
false;
2590 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2591 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2592 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2593 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2602bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2603 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2604 MI.getOpcode() != AArch64::CATCHRET &&
2605 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2610 auto TRI = Subtarget.getRegisterInfo();
2613 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2627 if (
MI.getOpcode() == AArch64::CATCHRET) {
2629 const TargetInstrInfo *
TII =
2631 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2636 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2638 FirstEpilogSEH = std::next(FirstEpilogSEH);
2653 if (
M.getStackProtectorGuard() ==
"sysreg") {
2654 const AArch64SysReg::SysReg *SrcReg =
2655 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2663 int Offset =
M.getStackProtectorGuardOffset();
2714 const GlobalValue *GV =
2717 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2720 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2721 Subtarget.isTargetILP32() ? 4 : 8);
2722 if (GuardWidth != 4 && GuardWidth != 8)
2727 if (GuardWidth == 4) {
2728 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2757 if (GuardWidth == 4) {
2758 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2775 if (GuardWidth == 4) {
2776 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2794 if (Subtarget.getTargetTriple().isOSMSVCRT())
2807 switch (
MI.getOpcode()) {
2810 case AArch64::MOVZWi:
2811 case AArch64::MOVZXi:
2812 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2813 assert(
MI.getDesc().getNumOperands() == 3 &&
2814 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2818 case AArch64::ANDWri:
2819 return MI.getOperand(1).getReg() == AArch64::WZR;
2820 case AArch64::ANDXri:
2821 return MI.getOperand(1).getReg() == AArch64::XZR;
2822 case TargetOpcode::COPY:
2823 return MI.getOperand(1).getReg() == AArch64::WZR;
2831 switch (
MI.getOpcode()) {
2834 case TargetOpcode::COPY: {
2837 return DstReg.
isPhysical() && (AArch64::GPR32RegClass.contains(DstReg) ||
2838 AArch64::GPR64RegClass.
contains(DstReg));
2840 case AArch64::ORRXrs:
2841 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2842 assert(
MI.getDesc().getNumOperands() == 4 &&
2843 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2847 case AArch64::ADDXri:
2848 if (
MI.getOperand(2).getImm() == 0) {
2849 assert(
MI.getDesc().getNumOperands() == 4 &&
2850 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2861 switch (
MI.getOpcode()) {
2864 case TargetOpcode::COPY: {
2866 return DstReg.
isPhysical() && AArch64::FPR128RegClass.contains(DstReg);
2868 case AArch64::ORRv16i8:
2869 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2870 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2871 "invalid ORRv16i8 operands");
2883 case AArch64::LDRWui:
2884 case AArch64::LDRXui:
2885 case AArch64::LDRBui:
2886 case AArch64::LDRHui:
2887 case AArch64::LDRSui:
2888 case AArch64::LDRDui:
2889 case AArch64::LDRQui:
2890 case AArch64::LDR_PXI:
2896 int &FrameIndex)
const {
2900 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2901 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2902 FrameIndex =
MI.getOperand(1).getIndex();
2903 return MI.getOperand(0).getReg();
2912 case AArch64::STRWui:
2913 case AArch64::STRXui:
2914 case AArch64::STRBui:
2915 case AArch64::STRHui:
2916 case AArch64::STRSui:
2917 case AArch64::STRDui:
2918 case AArch64::STRQui:
2919 case AArch64::STR_PXI:
2925 int &FrameIndex)
const {
2929 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2930 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2931 FrameIndex =
MI.getOperand(1).getIndex();
2932 return MI.getOperand(0).getReg();
2938 int &FrameIndex)
const {
2953 return MI.getOperand(0).getReg();
2959 int &FrameIndex)
const {
2974 return MI.getOperand(0).getReg();
2982 return MMO->getFlags() & MOSuppressPair;
2988 if (
MI.memoperands_empty())
2996 return MMO->getFlags() & MOStridedAccess;
3004 case AArch64::STURSi:
3005 case AArch64::STRSpre:
3006 case AArch64::STURDi:
3007 case AArch64::STRDpre:
3008 case AArch64::STURQi:
3009 case AArch64::STRQpre:
3010 case AArch64::STURBBi:
3011 case AArch64::STURHHi:
3012 case AArch64::STURWi:
3013 case AArch64::STRWpre:
3014 case AArch64::STURXi:
3015 case AArch64::STRXpre:
3016 case AArch64::LDURSi:
3017 case AArch64::LDRSpre:
3018 case AArch64::LDURDi:
3019 case AArch64::LDRDpre:
3020 case AArch64::LDURQi:
3021 case AArch64::LDRQpre:
3022 case AArch64::LDURWi:
3023 case AArch64::LDRWpre:
3024 case AArch64::LDURXi:
3025 case AArch64::LDRXpre:
3026 case AArch64::LDRSWpre:
3027 case AArch64::LDURSWi:
3028 case AArch64::LDURHHi:
3029 case AArch64::LDURBBi:
3030 case AArch64::LDURSBWi:
3031 case AArch64::LDURSHWi:
3039 case AArch64::PRFMui:
return AArch64::PRFUMi;
3040 case AArch64::LDRXui:
return AArch64::LDURXi;
3041 case AArch64::LDRWui:
return AArch64::LDURWi;
3042 case AArch64::LDRBui:
return AArch64::LDURBi;
3043 case AArch64::LDRHui:
return AArch64::LDURHi;
3044 case AArch64::LDRSui:
return AArch64::LDURSi;
3045 case AArch64::LDRDui:
return AArch64::LDURDi;
3046 case AArch64::LDRQui:
return AArch64::LDURQi;
3047 case AArch64::LDRBBui:
return AArch64::LDURBBi;
3048 case AArch64::LDRHHui:
return AArch64::LDURHHi;
3049 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
3050 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
3051 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
3052 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3053 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3054 case AArch64::STRXui:
return AArch64::STURXi;
3055 case AArch64::STRWui:
return AArch64::STURWi;
3056 case AArch64::STRBui:
return AArch64::STURBi;
3057 case AArch64::STRHui:
return AArch64::STURHi;
3058 case AArch64::STRSui:
return AArch64::STURSi;
3059 case AArch64::STRDui:
return AArch64::STURDi;
3060 case AArch64::STRQui:
return AArch64::STURQi;
3061 case AArch64::STRBBui:
return AArch64::STURBBi;
3062 case AArch64::STRHHui:
return AArch64::STURHHi;
3071 case AArch64::LDAPURBi:
3072 case AArch64::LDAPURHi:
3073 case AArch64::LDAPURi:
3074 case AArch64::LDAPURSBWi:
3075 case AArch64::LDAPURSBXi:
3076 case AArch64::LDAPURSHWi:
3077 case AArch64::LDAPURSHXi:
3078 case AArch64::LDAPURSWi:
3079 case AArch64::LDAPURXi:
3080 case AArch64::LDR_PPXI:
3081 case AArch64::LDR_PXI:
3082 case AArch64::LDR_ZXI:
3083 case AArch64::LDR_ZZXI:
3084 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3085 case AArch64::LDR_ZZZXI:
3086 case AArch64::LDR_ZZZZXI:
3087 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3088 case AArch64::LDRBBui:
3089 case AArch64::LDRBui:
3090 case AArch64::LDRDui:
3091 case AArch64::LDRHHui:
3092 case AArch64::LDRHui:
3093 case AArch64::LDRQui:
3094 case AArch64::LDRSBWui:
3095 case AArch64::LDRSBXui:
3096 case AArch64::LDRSHWui:
3097 case AArch64::LDRSHXui:
3098 case AArch64::LDRSui:
3099 case AArch64::LDRSWui:
3100 case AArch64::LDRWui:
3101 case AArch64::LDRXui:
3102 case AArch64::LDURBBi:
3103 case AArch64::LDURBi:
3104 case AArch64::LDURDi:
3105 case AArch64::LDURHHi:
3106 case AArch64::LDURHi:
3107 case AArch64::LDURQi:
3108 case AArch64::LDURSBWi:
3109 case AArch64::LDURSBXi:
3110 case AArch64::LDURSHWi:
3111 case AArch64::LDURSHXi:
3112 case AArch64::LDURSi:
3113 case AArch64::LDURSWi:
3114 case AArch64::LDURWi:
3115 case AArch64::LDURXi:
3116 case AArch64::PRFMui:
3117 case AArch64::PRFUMi:
3118 case AArch64::ST2Gi:
3120 case AArch64::STLURBi:
3121 case AArch64::STLURHi:
3122 case AArch64::STLURWi:
3123 case AArch64::STLURXi:
3124 case AArch64::StoreSwiftAsyncContext:
3125 case AArch64::STR_PPXI:
3126 case AArch64::STR_PXI:
3127 case AArch64::STR_ZXI:
3128 case AArch64::STR_ZZXI:
3129 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3130 case AArch64::STR_ZZZXI:
3131 case AArch64::STR_ZZZZXI:
3132 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3133 case AArch64::STRBBui:
3134 case AArch64::STRBui:
3135 case AArch64::STRDui:
3136 case AArch64::STRHHui:
3137 case AArch64::STRHui:
3138 case AArch64::STRQui:
3139 case AArch64::STRSui:
3140 case AArch64::STRWui:
3141 case AArch64::STRXui:
3142 case AArch64::STURBBi:
3143 case AArch64::STURBi:
3144 case AArch64::STURDi:
3145 case AArch64::STURHHi:
3146 case AArch64::STURHi:
3147 case AArch64::STURQi:
3148 case AArch64::STURSi:
3149 case AArch64::STURWi:
3150 case AArch64::STURXi:
3151 case AArch64::STZ2Gi:
3152 case AArch64::STZGi:
3153 case AArch64::TAGPstack:
3154 case AArch64::ATOMIC_STORE_HINT_Bi:
3155 case AArch64::ATOMIC_STORE_HINT_Hi:
3156 case AArch64::ATOMIC_STORE_HINT_Wi:
3157 case AArch64::ATOMIC_STORE_HINT_Si:
3158 case AArch64::ATOMIC_STORE_HINT_Xi:
3159 case AArch64::ATOMIC_STORE_HINT_Di:
3160 case AArch64::ATOMIC_STORE_HINT_Bui:
3161 case AArch64::ATOMIC_STORE_HINT_Hui:
3162 case AArch64::ATOMIC_STORE_HINT_Wui:
3163 case AArch64::ATOMIC_STORE_HINT_Sui:
3164 case AArch64::ATOMIC_STORE_HINT_Xui:
3165 case AArch64::ATOMIC_STORE_HINT_Dui:
3167 case AArch64::LD1B_D_IMM:
3168 case AArch64::LD1B_H_IMM:
3169 case AArch64::LD1B_IMM:
3170 case AArch64::LD1B_S_IMM:
3171 case AArch64::LD1D_IMM:
3172 case AArch64::LD1H_D_IMM:
3173 case AArch64::LD1H_IMM:
3174 case AArch64::LD1H_S_IMM:
3175 case AArch64::LD1RB_D_IMM:
3176 case AArch64::LD1RB_H_IMM:
3177 case AArch64::LD1RB_IMM:
3178 case AArch64::LD1RB_S_IMM:
3179 case AArch64::LD1RD_IMM:
3180 case AArch64::LD1RH_D_IMM:
3181 case AArch64::LD1RH_IMM:
3182 case AArch64::LD1RH_S_IMM:
3183 case AArch64::LD1RSB_D_IMM:
3184 case AArch64::LD1RSB_H_IMM:
3185 case AArch64::LD1RSB_S_IMM:
3186 case AArch64::LD1RSH_D_IMM:
3187 case AArch64::LD1RSH_S_IMM:
3188 case AArch64::LD1RSW_IMM:
3189 case AArch64::LD1RW_D_IMM:
3190 case AArch64::LD1RW_IMM:
3191 case AArch64::LD1SB_D_IMM:
3192 case AArch64::LD1SB_H_IMM:
3193 case AArch64::LD1SB_S_IMM:
3194 case AArch64::LD1SH_D_IMM:
3195 case AArch64::LD1SH_S_IMM:
3196 case AArch64::LD1SW_D_IMM:
3197 case AArch64::LD1W_D_IMM:
3198 case AArch64::LD1W_IMM:
3199 case AArch64::LD2B_IMM:
3200 case AArch64::LD2D_IMM:
3201 case AArch64::LD2H_IMM:
3202 case AArch64::LD2W_IMM:
3203 case AArch64::LD3B_IMM:
3204 case AArch64::LD3D_IMM:
3205 case AArch64::LD3H_IMM:
3206 case AArch64::LD3W_IMM:
3207 case AArch64::LD4B_IMM:
3208 case AArch64::LD4D_IMM:
3209 case AArch64::LD4H_IMM:
3210 case AArch64::LD4W_IMM:
3212 case AArch64::LDNF1B_D_IMM:
3213 case AArch64::LDNF1B_H_IMM:
3214 case AArch64::LDNF1B_IMM:
3215 case AArch64::LDNF1B_S_IMM:
3216 case AArch64::LDNF1D_IMM:
3217 case AArch64::LDNF1H_D_IMM:
3218 case AArch64::LDNF1H_IMM:
3219 case AArch64::LDNF1H_S_IMM:
3220 case AArch64::LDNF1SB_D_IMM:
3221 case AArch64::LDNF1SB_H_IMM:
3222 case AArch64::LDNF1SB_S_IMM:
3223 case AArch64::LDNF1SH_D_IMM:
3224 case AArch64::LDNF1SH_S_IMM:
3225 case AArch64::LDNF1SW_D_IMM:
3226 case AArch64::LDNF1W_D_IMM:
3227 case AArch64::LDNF1W_IMM:
3228 case AArch64::LDNPDi:
3229 case AArch64::LDNPQi:
3230 case AArch64::LDNPSi:
3231 case AArch64::LDNPWi:
3232 case AArch64::LDNPXi:
3233 case AArch64::LDNT1B_ZRI:
3234 case AArch64::LDNT1D_ZRI:
3235 case AArch64::LDNT1H_ZRI:
3236 case AArch64::LDNT1W_ZRI:
3237 case AArch64::LDPDi:
3238 case AArch64::LDPQi:
3239 case AArch64::LDPSi:
3240 case AArch64::LDPWi:
3241 case AArch64::LDPXi:
3242 case AArch64::LDRBBpost:
3243 case AArch64::LDRBBpre:
3244 case AArch64::LDRBpost:
3245 case AArch64::LDRBpre:
3246 case AArch64::LDRDpost:
3247 case AArch64::LDRDpre:
3248 case AArch64::LDRHHpost:
3249 case AArch64::LDRHHpre:
3250 case AArch64::LDRHpost:
3251 case AArch64::LDRHpre:
3252 case AArch64::LDRQpost:
3253 case AArch64::LDRQpre:
3254 case AArch64::LDRSpost:
3255 case AArch64::LDRSpre:
3256 case AArch64::LDRWpost:
3257 case AArch64::LDRWpre:
3258 case AArch64::LDRXpost:
3259 case AArch64::LDRXpre:
3260 case AArch64::ST1B_D_IMM:
3261 case AArch64::ST1B_H_IMM:
3262 case AArch64::ST1B_IMM:
3263 case AArch64::ST1B_S_IMM:
3264 case AArch64::ST1D_IMM:
3265 case AArch64::ST1H_D_IMM:
3266 case AArch64::ST1H_IMM:
3267 case AArch64::ST1H_S_IMM:
3268 case AArch64::ST1W_D_IMM:
3269 case AArch64::ST1W_IMM:
3270 case AArch64::ST2B_IMM:
3271 case AArch64::ST2D_IMM:
3272 case AArch64::ST2H_IMM:
3273 case AArch64::ST2W_IMM:
3274 case AArch64::ST3B_IMM:
3275 case AArch64::ST3D_IMM:
3276 case AArch64::ST3H_IMM:
3277 case AArch64::ST3W_IMM:
3278 case AArch64::ST4B_IMM:
3279 case AArch64::ST4D_IMM:
3280 case AArch64::ST4H_IMM:
3281 case AArch64::ST4W_IMM:
3282 case AArch64::STGPi:
3283 case AArch64::STGPreIndex:
3284 case AArch64::STZGPreIndex:
3285 case AArch64::ST2GPreIndex:
3286 case AArch64::STZ2GPreIndex:
3287 case AArch64::STGPostIndex:
3288 case AArch64::STZGPostIndex:
3289 case AArch64::ST2GPostIndex:
3290 case AArch64::STZ2GPostIndex:
3291 case AArch64::STNPDi:
3292 case AArch64::STNPQi:
3293 case AArch64::STNPSi:
3294 case AArch64::STNPWi:
3295 case AArch64::STNPXi:
3296 case AArch64::STNT1B_ZRI:
3297 case AArch64::STNT1D_ZRI:
3298 case AArch64::STNT1H_ZRI:
3299 case AArch64::STNT1W_ZRI:
3300 case AArch64::STPDi:
3301 case AArch64::STPQi:
3302 case AArch64::STPSi:
3303 case AArch64::STPWi:
3304 case AArch64::STPXi:
3305 case AArch64::STRBBpost:
3306 case AArch64::STRBBpre:
3307 case AArch64::STRBpost:
3308 case AArch64::STRBpre:
3309 case AArch64::STRDpost:
3310 case AArch64::STRDpre:
3311 case AArch64::STRHHpost:
3312 case AArch64::STRHHpre:
3313 case AArch64::STRHpost:
3314 case AArch64::STRHpre:
3315 case AArch64::STRQpost:
3316 case AArch64::STRQpre:
3317 case AArch64::STRSpost:
3318 case AArch64::STRSpre:
3319 case AArch64::STRWpost:
3320 case AArch64::STRWpre:
3321 case AArch64::STRXpost:
3322 case AArch64::STRXpre:
3323 case AArch64::LD1B_2Z_IMM:
3324 case AArch64::LD1B_2Z_STRIDED_IMM:
3325 case AArch64::LD1H_2Z_IMM:
3326 case AArch64::LD1H_2Z_STRIDED_IMM:
3327 case AArch64::LD1W_2Z_IMM:
3328 case AArch64::LD1W_2Z_STRIDED_IMM:
3329 case AArch64::LD1D_2Z_IMM:
3330 case AArch64::LD1D_2Z_STRIDED_IMM:
3331 case AArch64::LD1B_4Z_IMM:
3332 case AArch64::LD1B_4Z_STRIDED_IMM:
3333 case AArch64::LD1H_4Z_IMM:
3334 case AArch64::LD1H_4Z_STRIDED_IMM:
3335 case AArch64::LD1W_4Z_IMM:
3336 case AArch64::LD1W_4Z_STRIDED_IMM:
3337 case AArch64::LD1D_4Z_IMM:
3338 case AArch64::LD1D_4Z_STRIDED_IMM:
3339 case AArch64::LD1B_2Z_IMM_PSEUDO:
3340 case AArch64::LD1H_2Z_IMM_PSEUDO:
3341 case AArch64::LD1W_2Z_IMM_PSEUDO:
3342 case AArch64::LD1D_2Z_IMM_PSEUDO:
3343 case AArch64::LD1B_4Z_IMM_PSEUDO:
3344 case AArch64::LD1H_4Z_IMM_PSEUDO:
3345 case AArch64::LD1W_4Z_IMM_PSEUDO:
3346 case AArch64::LD1D_4Z_IMM_PSEUDO:
3347 case AArch64::ST1B_2Z_IMM:
3348 case AArch64::ST1B_2Z_STRIDED_IMM:
3349 case AArch64::ST1H_2Z_IMM:
3350 case AArch64::ST1H_2Z_STRIDED_IMM:
3351 case AArch64::ST1W_2Z_IMM:
3352 case AArch64::ST1W_2Z_STRIDED_IMM:
3353 case AArch64::ST1D_2Z_IMM:
3354 case AArch64::ST1D_2Z_STRIDED_IMM:
3355 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3356 case AArch64::LDNT1B_2Z_IMM:
3357 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3358 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3359 case AArch64::LDNT1H_2Z_IMM:
3360 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3361 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3362 case AArch64::LDNT1W_2Z_IMM:
3363 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3364 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3365 case AArch64::LDNT1D_2Z_IMM:
3366 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3367 case AArch64::STNT1B_2Z_IMM:
3368 case AArch64::STNT1B_2Z_STRIDED_IMM:
3369 case AArch64::STNT1H_2Z_IMM:
3370 case AArch64::STNT1H_2Z_STRIDED_IMM:
3371 case AArch64::STNT1W_2Z_IMM:
3372 case AArch64::STNT1W_2Z_STRIDED_IMM:
3373 case AArch64::STNT1D_2Z_IMM:
3374 case AArch64::STNT1D_2Z_STRIDED_IMM:
3375 case AArch64::ST1B_2Z_IMM_PSEUDO:
3376 case AArch64::ST1H_2Z_IMM_PSEUDO:
3377 case AArch64::ST1W_2Z_IMM_PSEUDO:
3378 case AArch64::ST1D_2Z_IMM_PSEUDO:
3379 case AArch64::STNT1B_2Z_IMM_PSEUDO:
3380 case AArch64::STNT1H_2Z_IMM_PSEUDO:
3381 case AArch64::STNT1W_2Z_IMM_PSEUDO:
3382 case AArch64::STNT1D_2Z_IMM_PSEUDO:
3383 case AArch64::ST1B_4Z_IMM:
3384 case AArch64::ST1B_4Z_STRIDED_IMM:
3385 case AArch64::ST1H_4Z_IMM:
3386 case AArch64::ST1H_4Z_STRIDED_IMM:
3387 case AArch64::ST1W_4Z_IMM:
3388 case AArch64::ST1W_4Z_STRIDED_IMM:
3389 case AArch64::ST1D_4Z_IMM:
3390 case AArch64::ST1D_4Z_STRIDED_IMM:
3391 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3392 case AArch64::LDNT1B_4Z_IMM:
3393 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3394 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3395 case AArch64::LDNT1H_4Z_IMM:
3396 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3397 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3398 case AArch64::LDNT1W_4Z_IMM:
3399 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3400 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3401 case AArch64::LDNT1D_4Z_IMM:
3402 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3403 case AArch64::STNT1B_4Z_IMM:
3404 case AArch64::STNT1B_4Z_STRIDED_IMM:
3405 case AArch64::STNT1H_4Z_IMM:
3406 case AArch64::STNT1H_4Z_STRIDED_IMM:
3407 case AArch64::STNT1W_4Z_IMM:
3408 case AArch64::STNT1W_4Z_STRIDED_IMM:
3409 case AArch64::STNT1D_4Z_IMM:
3410 case AArch64::STNT1D_4Z_STRIDED_IMM:
3411 case AArch64::ST1B_4Z_IMM_PSEUDO:
3412 case AArch64::ST1H_4Z_IMM_PSEUDO:
3413 case AArch64::ST1W_4Z_IMM_PSEUDO:
3414 case AArch64::ST1D_4Z_IMM_PSEUDO:
3415 case AArch64::STNT1B_4Z_IMM_PSEUDO:
3416 case AArch64::STNT1H_4Z_IMM_PSEUDO:
3417 case AArch64::STNT1W_4Z_IMM_PSEUDO:
3418 case AArch64::STNT1D_4Z_IMM_PSEUDO:
3420 case AArch64::LDPDpost:
3421 case AArch64::LDPDpre:
3422 case AArch64::LDPQpost:
3423 case AArch64::LDPQpre:
3424 case AArch64::LDPSpost:
3425 case AArch64::LDPSpre:
3426 case AArch64::LDPWpost:
3427 case AArch64::LDPWpre:
3428 case AArch64::LDPXpost:
3429 case AArch64::LDPXpre:
3430 case AArch64::STGPpre:
3431 case AArch64::STGPpost:
3432 case AArch64::STPDpost:
3433 case AArch64::STPDpre:
3434 case AArch64::STPQpost:
3435 case AArch64::STPQpre:
3436 case AArch64::STPSpost:
3437 case AArch64::STPSpre:
3438 case AArch64::STPWpost:
3439 case AArch64::STPWpre:
3440 case AArch64::STPXpost:
3441 case AArch64::STPXpre:
3447 switch (
MI.getOpcode()) {
3451 case AArch64::STRSui:
3452 case AArch64::STRDui:
3453 case AArch64::STRQui:
3454 case AArch64::STRXui:
3455 case AArch64::STRWui:
3456 case AArch64::LDRSui:
3457 case AArch64::LDRDui:
3458 case AArch64::LDRQui:
3459 case AArch64::LDRXui:
3460 case AArch64::LDRWui:
3461 case AArch64::LDRSWui:
3463 case AArch64::STURSi:
3464 case AArch64::STRSpre:
3465 case AArch64::STURDi:
3466 case AArch64::STRDpre:
3467 case AArch64::STURQi:
3468 case AArch64::STRQpre:
3469 case AArch64::STURWi:
3470 case AArch64::STRWpre:
3471 case AArch64::STURXi:
3472 case AArch64::STRXpre:
3473 case AArch64::LDURSi:
3474 case AArch64::LDRSpre:
3475 case AArch64::LDURDi:
3476 case AArch64::LDRDpre:
3477 case AArch64::LDURQi:
3478 case AArch64::LDRQpre:
3479 case AArch64::LDURWi:
3480 case AArch64::LDRWpre:
3481 case AArch64::LDURXi:
3482 case AArch64::LDRXpre:
3483 case AArch64::LDURSWi:
3484 case AArch64::LDRSWpre:
3486 case AArch64::LDR_ZXI:
3487 case AArch64::STR_ZXI:
3493 switch (
MI.getOpcode()) {
3496 "Unexpected instruction - was a new tail call opcode introduced?");
3498 case AArch64::TCRETURNdi:
3499 case AArch64::TCRETURNri:
3500 case AArch64::TCRETURNrix16x17:
3501 case AArch64::TCRETURNrix17:
3502 case AArch64::TCRETURNrinotx16:
3503 case AArch64::TCRETURNriALL:
3504 case AArch64::AUTH_TCRETURN:
3505 case AArch64::AUTH_TCRETURN_BTI:
3515 case AArch64::ADDWri:
3516 return AArch64::ADDSWri;
3517 case AArch64::ADDWrr:
3518 return AArch64::ADDSWrr;
3519 case AArch64::ADDWrs:
3520 return AArch64::ADDSWrs;
3521 case AArch64::ADDWrx:
3522 return AArch64::ADDSWrx;
3523 case AArch64::ANDWri:
3524 return AArch64::ANDSWri;
3525 case AArch64::ANDWrr:
3526 return AArch64::ANDSWrr;
3527 case AArch64::ANDWrs:
3528 return AArch64::ANDSWrs;
3529 case AArch64::BICWrr:
3530 return AArch64::BICSWrr;
3531 case AArch64::BICWrs:
3532 return AArch64::BICSWrs;
3533 case AArch64::SUBWri:
3534 return AArch64::SUBSWri;
3535 case AArch64::SUBWrr:
3536 return AArch64::SUBSWrr;
3537 case AArch64::SUBWrs:
3538 return AArch64::SUBSWrs;
3539 case AArch64::SUBWrx:
3540 return AArch64::SUBSWrx;
3542 case AArch64::ADDXri:
3543 return AArch64::ADDSXri;
3544 case AArch64::ADDXrr:
3545 return AArch64::ADDSXrr;
3546 case AArch64::ADDXrs:
3547 return AArch64::ADDSXrs;
3548 case AArch64::ADDXrx:
3549 return AArch64::ADDSXrx;
3550 case AArch64::ANDXri:
3551 return AArch64::ANDSXri;
3552 case AArch64::ANDXrr:
3553 return AArch64::ANDSXrr;
3554 case AArch64::ANDXrs:
3555 return AArch64::ANDSXrs;
3556 case AArch64::BICXrr:
3557 return AArch64::BICSXrr;
3558 case AArch64::BICXrs:
3559 return AArch64::BICSXrs;
3560 case AArch64::SUBXri:
3561 return AArch64::SUBSXri;
3562 case AArch64::SUBXrr:
3563 return AArch64::SUBSXrr;
3564 case AArch64::SUBXrs:
3565 return AArch64::SUBSXrs;
3566 case AArch64::SUBXrx:
3567 return AArch64::SUBSXrx;
3569 case AArch64::AND_PPzPP:
3570 return AArch64::ANDS_PPzPP;
3571 case AArch64::BIC_PPzPP:
3572 return AArch64::BICS_PPzPP;
3573 case AArch64::EOR_PPzPP:
3574 return AArch64::EORS_PPzPP;
3575 case AArch64::NAND_PPzPP:
3576 return AArch64::NANDS_PPzPP;
3577 case AArch64::NOR_PPzPP:
3578 return AArch64::NORS_PPzPP;
3579 case AArch64::ORN_PPzPP:
3580 return AArch64::ORNS_PPzPP;
3581 case AArch64::ORR_PPzPP:
3582 return AArch64::ORRS_PPzPP;
3583 case AArch64::BRKA_PPzP:
3584 return AArch64::BRKAS_PPzP;
3585 case AArch64::BRKPA_PPzPP:
3586 return AArch64::BRKPAS_PPzPP;
3587 case AArch64::BRKB_PPzP:
3588 return AArch64::BRKBS_PPzP;
3589 case AArch64::BRKPB_PPzPP:
3590 return AArch64::BRKPBS_PPzPP;
3591 case AArch64::BRKN_PPzP:
3592 return AArch64::BRKNS_PPzP;
3593 case AArch64::RDFFR_PPz:
3594 return AArch64::RDFFRS_PPz;
3595 case AArch64::PTRUE_B:
3596 return AArch64::PTRUES_B;
3607 if (
MI.hasOrderedMemoryRef())
3612 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3613 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3614 "Expected a reg or frame index operand.");
3618 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3620 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3633 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3634 Register BaseReg =
MI.getOperand(1).getReg();
3636 if (
MI.modifiesRegister(BaseReg,
TRI))
3642 switch (
MI.getOpcode()) {
3645 case AArch64::LDR_ZXI:
3646 case AArch64::STR_ZXI:
3647 if (!Subtarget.isLittleEndian() ||
3648 Subtarget.getSVEVectorSizeInBits() != 128)
3663 MI.getMF()->needsWinCFI())
3667 if (Subtarget.isPaired128Slow()) {
3668 switch (
MI.getOpcode()) {
3671 case AArch64::LDURQi:
3672 case AArch64::STURQi:
3673 case AArch64::LDRQui:
3674 case AArch64::STRQui:
3700std::optional<ExtAddrMode>
3704 bool OffsetIsScalable;
3705 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable))
3706 return std::nullopt;
3709 return std::nullopt;
3724 int64_t OffsetScale = 1;
3729 case AArch64::LDURQi:
3730 case AArch64::STURQi:
3734 case AArch64::LDURDi:
3735 case AArch64::STURDi:
3736 case AArch64::LDURXi:
3737 case AArch64::STURXi:
3741 case AArch64::LDURSi:
3742 case AArch64::STURSi:
3743 case AArch64::LDURWi:
3744 case AArch64::LDURSWi:
3745 case AArch64::STURWi:
3749 case AArch64::LDURHi:
3750 case AArch64::STURHi:
3751 case AArch64::LDURHHi:
3752 case AArch64::STURHHi:
3753 case AArch64::LDURSHXi:
3754 case AArch64::LDURSHWi:
3758 case AArch64::LDRBroX:
3759 case AArch64::LDRBBroX:
3760 case AArch64::LDRSBXroX:
3761 case AArch64::LDRSBWroX:
3762 case AArch64::STRBroX:
3763 case AArch64::STRBBroX:
3764 case AArch64::LDURBi:
3765 case AArch64::LDURBBi:
3766 case AArch64::LDURSBXi:
3767 case AArch64::LDURSBWi:
3768 case AArch64::STURBi:
3769 case AArch64::STURBBi:
3770 case AArch64::LDRBui:
3771 case AArch64::LDRBBui:
3772 case AArch64::LDRSBXui:
3773 case AArch64::LDRSBWui:
3774 case AArch64::STRBui:
3775 case AArch64::STRBBui:
3779 case AArch64::LDRQroX:
3780 case AArch64::STRQroX:
3781 case AArch64::LDRQui:
3782 case AArch64::STRQui:
3787 case AArch64::LDRDroX:
3788 case AArch64::STRDroX:
3789 case AArch64::LDRXroX:
3790 case AArch64::STRXroX:
3791 case AArch64::LDRDui:
3792 case AArch64::STRDui:
3793 case AArch64::LDRXui:
3794 case AArch64::STRXui:
3799 case AArch64::LDRSroX:
3800 case AArch64::STRSroX:
3801 case AArch64::LDRWroX:
3802 case AArch64::LDRSWroX:
3803 case AArch64::STRWroX:
3804 case AArch64::LDRSui:
3805 case AArch64::STRSui:
3806 case AArch64::LDRWui:
3807 case AArch64::LDRSWui:
3808 case AArch64::STRWui:
3813 case AArch64::LDRHroX:
3814 case AArch64::STRHroX:
3815 case AArch64::LDRHHroX:
3816 case AArch64::STRHHroX:
3817 case AArch64::LDRSHXroX:
3818 case AArch64::LDRSHWroX:
3819 case AArch64::LDRHui:
3820 case AArch64::STRHui:
3821 case AArch64::LDRHHui:
3822 case AArch64::STRHHui:
3823 case AArch64::LDRSHXui:
3824 case AArch64::LDRSHWui:
3832 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3856 case AArch64::SBFMXri:
3869 AM.
Scale = OffsetScale;
3874 case TargetOpcode::SUBREG_TO_REG: {
3886 if (!OffsetReg.
isVirtual() || !
MRI.hasOneNonDBGUse(OffsetReg))
3890 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3891 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3892 DefMI.getOperand(3).getImm() != 0)
3899 AM.
Scale = OffsetScale;
3910 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3911 int64_t NewOffset) ->
bool {
3912 int64_t MinOffset, MaxOffset;
3929 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3930 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3932 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3934 int64_t NewOffset = OldOffset + Disp;
3935 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3939 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3949 auto canFoldAddRegIntoAddrMode =
3954 if ((
unsigned)Scale != Scale)
3956 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3968 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3969 Subtarget.isSTRQroSlow();
3978 case AArch64::ADDXri:
3984 return canFoldAddSubImmIntoAddrMode(Disp);
3986 case AArch64::SUBXri:
3992 return canFoldAddSubImmIntoAddrMode(-Disp);
3994 case AArch64::ADDXrs: {
4007 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
4009 if (avoidSlowSTRQ(MemI))
4012 return canFoldAddRegIntoAddrMode(1ULL << Shift);
4015 case AArch64::ADDXrr:
4023 if (!OptSize && avoidSlowSTRQ(MemI))
4025 return canFoldAddRegIntoAddrMode(1);
4027 case AArch64::ADDXrx:
4035 if (!OptSize && avoidSlowSTRQ(MemI))
4044 return canFoldAddRegIntoAddrMode(
4059 case AArch64::LDURQi:
4060 case AArch64::LDRQui:
4061 return AArch64::LDRQroX;
4062 case AArch64::STURQi:
4063 case AArch64::STRQui:
4064 return AArch64::STRQroX;
4065 case AArch64::LDURDi:
4066 case AArch64::LDRDui:
4067 return AArch64::LDRDroX;
4068 case AArch64::STURDi:
4069 case AArch64::STRDui:
4070 return AArch64::STRDroX;
4071 case AArch64::LDURXi:
4072 case AArch64::LDRXui:
4073 return AArch64::LDRXroX;
4074 case AArch64::STURXi:
4075 case AArch64::STRXui:
4076 return AArch64::STRXroX;
4077 case AArch64::LDURSi:
4078 case AArch64::LDRSui:
4079 return AArch64::LDRSroX;
4080 case AArch64::STURSi:
4081 case AArch64::STRSui:
4082 return AArch64::STRSroX;
4083 case AArch64::LDURWi:
4084 case AArch64::LDRWui:
4085 return AArch64::LDRWroX;
4086 case AArch64::LDURSWi:
4087 case AArch64::LDRSWui:
4088 return AArch64::LDRSWroX;
4089 case AArch64::STURWi:
4090 case AArch64::STRWui:
4091 return AArch64::STRWroX;
4092 case AArch64::LDURHi:
4093 case AArch64::LDRHui:
4094 return AArch64::LDRHroX;
4095 case AArch64::STURHi:
4096 case AArch64::STRHui:
4097 return AArch64::STRHroX;
4098 case AArch64::LDURHHi:
4099 case AArch64::LDRHHui:
4100 return AArch64::LDRHHroX;
4101 case AArch64::STURHHi:
4102 case AArch64::STRHHui:
4103 return AArch64::STRHHroX;
4104 case AArch64::LDURSHXi:
4105 case AArch64::LDRSHXui:
4106 return AArch64::LDRSHXroX;
4107 case AArch64::LDURSHWi:
4108 case AArch64::LDRSHWui:
4109 return AArch64::LDRSHWroX;
4110 case AArch64::LDURBi:
4111 case AArch64::LDRBui:
4112 return AArch64::LDRBroX;
4113 case AArch64::LDURBBi:
4114 case AArch64::LDRBBui:
4115 return AArch64::LDRBBroX;
4116 case AArch64::LDURSBXi:
4117 case AArch64::LDRSBXui:
4118 return AArch64::LDRSBXroX;
4119 case AArch64::LDURSBWi:
4120 case AArch64::LDRSBWui:
4121 return AArch64::LDRSBWroX;
4122 case AArch64::STURBi:
4123 case AArch64::STRBui:
4124 return AArch64::STRBroX;
4125 case AArch64::STURBBi:
4126 case AArch64::STRBBui:
4127 return AArch64::STRBBroX;
4139 case AArch64::LDURQi:
4141 return AArch64::LDRQui;
4142 case AArch64::STURQi:
4144 return AArch64::STRQui;
4145 case AArch64::LDURDi:
4147 return AArch64::LDRDui;
4148 case AArch64::STURDi:
4150 return AArch64::STRDui;
4151 case AArch64::LDURXi:
4153 return AArch64::LDRXui;
4154 case AArch64::STURXi:
4156 return AArch64::STRXui;
4157 case AArch64::LDURSi:
4159 return AArch64::LDRSui;
4160 case AArch64::STURSi:
4162 return AArch64::STRSui;
4163 case AArch64::LDURWi:
4165 return AArch64::LDRWui;
4166 case AArch64::LDURSWi:
4168 return AArch64::LDRSWui;
4169 case AArch64::STURWi:
4171 return AArch64::STRWui;
4172 case AArch64::LDURHi:
4174 return AArch64::LDRHui;
4175 case AArch64::STURHi:
4177 return AArch64::STRHui;
4178 case AArch64::LDURHHi:
4180 return AArch64::LDRHHui;
4181 case AArch64::STURHHi:
4183 return AArch64::STRHHui;
4184 case AArch64::LDURSHXi:
4186 return AArch64::LDRSHXui;
4187 case AArch64::LDURSHWi:
4189 return AArch64::LDRSHWui;
4190 case AArch64::LDURBi:
4192 return AArch64::LDRBui;
4193 case AArch64::LDURBBi:
4195 return AArch64::LDRBBui;
4196 case AArch64::LDURSBXi:
4198 return AArch64::LDRSBXui;
4199 case AArch64::LDURSBWi:
4201 return AArch64::LDRSBWui;
4202 case AArch64::STURBi:
4204 return AArch64::STRBui;
4205 case AArch64::STURBBi:
4207 return AArch64::STRBBui;
4208 case AArch64::LDRQui:
4209 case AArch64::STRQui:
4212 case AArch64::LDRDui:
4213 case AArch64::STRDui:
4214 case AArch64::LDRXui:
4215 case AArch64::STRXui:
4218 case AArch64::LDRSui:
4219 case AArch64::STRSui:
4220 case AArch64::LDRWui:
4221 case AArch64::LDRSWui:
4222 case AArch64::STRWui:
4225 case AArch64::LDRHui:
4226 case AArch64::STRHui:
4227 case AArch64::LDRHHui:
4228 case AArch64::STRHHui:
4229 case AArch64::LDRSHXui:
4230 case AArch64::LDRSHWui:
4233 case AArch64::LDRBui:
4234 case AArch64::LDRBBui:
4235 case AArch64::LDRSBXui:
4236 case AArch64::LDRSBWui:
4237 case AArch64::STRBui:
4238 case AArch64::STRBBui:
4252 case AArch64::LDURQi:
4253 case AArch64::STURQi:
4254 case AArch64::LDURDi:
4255 case AArch64::STURDi:
4256 case AArch64::LDURXi:
4257 case AArch64::STURXi:
4258 case AArch64::LDURSi:
4259 case AArch64::STURSi:
4260 case AArch64::LDURWi:
4261 case AArch64::LDURSWi:
4262 case AArch64::STURWi:
4263 case AArch64::LDURHi:
4264 case AArch64::STURHi:
4265 case AArch64::LDURHHi:
4266 case AArch64::STURHHi:
4267 case AArch64::LDURSHXi:
4268 case AArch64::LDURSHWi:
4269 case AArch64::LDURBi:
4270 case AArch64::STURBi:
4271 case AArch64::LDURBBi:
4272 case AArch64::STURBBi:
4273 case AArch64::LDURSBWi:
4274 case AArch64::LDURSBXi:
4276 case AArch64::LDRQui:
4277 return AArch64::LDURQi;
4278 case AArch64::STRQui:
4279 return AArch64::STURQi;
4280 case AArch64::LDRDui:
4281 return AArch64::LDURDi;
4282 case AArch64::STRDui:
4283 return AArch64::STURDi;
4284 case AArch64::LDRXui:
4285 return AArch64::LDURXi;
4286 case AArch64::STRXui:
4287 return AArch64::STURXi;
4288 case AArch64::LDRSui:
4289 return AArch64::LDURSi;
4290 case AArch64::STRSui:
4291 return AArch64::STURSi;
4292 case AArch64::LDRWui:
4293 return AArch64::LDURWi;
4294 case AArch64::LDRSWui:
4295 return AArch64::LDURSWi;
4296 case AArch64::STRWui:
4297 return AArch64::STURWi;
4298 case AArch64::LDRHui:
4299 return AArch64::LDURHi;
4300 case AArch64::STRHui:
4301 return AArch64::STURHi;
4302 case AArch64::LDRHHui:
4303 return AArch64::LDURHHi;
4304 case AArch64::STRHHui:
4305 return AArch64::STURHHi;
4306 case AArch64::LDRSHXui:
4307 return AArch64::LDURSHXi;
4308 case AArch64::LDRSHWui:
4309 return AArch64::LDURSHWi;
4310 case AArch64::LDRBBui:
4311 return AArch64::LDURBBi;
4312 case AArch64::LDRBui:
4313 return AArch64::LDURBi;
4314 case AArch64::STRBBui:
4315 return AArch64::STURBBi;
4316 case AArch64::STRBui:
4317 return AArch64::STURBi;
4318 case AArch64::LDRSBWui:
4319 return AArch64::LDURSBWi;
4320 case AArch64::LDRSBXui:
4321 return AArch64::LDURSBXi;
4334 case AArch64::LDRQroX:
4335 case AArch64::LDURQi:
4336 case AArch64::LDRQui:
4337 return AArch64::LDRQroW;
4338 case AArch64::STRQroX:
4339 case AArch64::STURQi:
4340 case AArch64::STRQui:
4341 return AArch64::STRQroW;
4342 case AArch64::LDRDroX:
4343 case AArch64::LDURDi:
4344 case AArch64::LDRDui:
4345 return AArch64::LDRDroW;
4346 case AArch64::STRDroX:
4347 case AArch64::STURDi:
4348 case AArch64::STRDui:
4349 return AArch64::STRDroW;
4350 case AArch64::LDRXroX:
4351 case AArch64::LDURXi:
4352 case AArch64::LDRXui:
4353 return AArch64::LDRXroW;
4354 case AArch64::STRXroX:
4355 case AArch64::STURXi:
4356 case AArch64::STRXui:
4357 return AArch64::STRXroW;
4358 case AArch64::LDRSroX:
4359 case AArch64::LDURSi:
4360 case AArch64::LDRSui:
4361 return AArch64::LDRSroW;
4362 case AArch64::STRSroX:
4363 case AArch64::STURSi:
4364 case AArch64::STRSui:
4365 return AArch64::STRSroW;
4366 case AArch64::LDRWroX:
4367 case AArch64::LDURWi:
4368 case AArch64::LDRWui:
4369 return AArch64::LDRWroW;
4370 case AArch64::LDRSWroX:
4371 case AArch64::LDURSWi:
4372 case AArch64::LDRSWui:
4373 return AArch64::LDRSWroW;
4374 case AArch64::STRWroX:
4375 case AArch64::STURWi:
4376 case AArch64::STRWui:
4377 return AArch64::STRWroW;
4378 case AArch64::LDRHroX:
4379 case AArch64::LDURHi:
4380 case AArch64::LDRHui:
4381 return AArch64::LDRHroW;
4382 case AArch64::STRHroX:
4383 case AArch64::STURHi:
4384 case AArch64::STRHui:
4385 return AArch64::STRHroW;
4386 case AArch64::LDRHHroX:
4387 case AArch64::LDURHHi:
4388 case AArch64::LDRHHui:
4389 return AArch64::LDRHHroW;
4390 case AArch64::STRHHroX:
4391 case AArch64::STURHHi:
4392 case AArch64::STRHHui:
4393 return AArch64::STRHHroW;
4394 case AArch64::LDRSHXroX:
4395 case AArch64::LDURSHXi:
4396 case AArch64::LDRSHXui:
4397 return AArch64::LDRSHXroW;
4398 case AArch64::LDRSHWroX:
4399 case AArch64::LDURSHWi:
4400 case AArch64::LDRSHWui:
4401 return AArch64::LDRSHWroW;
4402 case AArch64::LDRBroX:
4403 case AArch64::LDURBi:
4404 case AArch64::LDRBui:
4405 return AArch64::LDRBroW;
4406 case AArch64::LDRBBroX:
4407 case AArch64::LDURBBi:
4408 case AArch64::LDRBBui:
4409 return AArch64::LDRBBroW;
4410 case AArch64::LDRSBXroX:
4411 case AArch64::LDURSBXi:
4412 case AArch64::LDRSBXui:
4413 return AArch64::LDRSBXroW;
4414 case AArch64::LDRSBWroX:
4415 case AArch64::LDURSBWi:
4416 case AArch64::LDRSBWui:
4417 return AArch64::LDRSBWroW;
4418 case AArch64::STRBroX:
4419 case AArch64::STURBi:
4420 case AArch64::STRBui:
4421 return AArch64::STRBroW;
4422 case AArch64::STRBBroX:
4423 case AArch64::STURBBi:
4424 case AArch64::STRBBui:
4425 return AArch64::STRBBroW;
4440 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
4450 return B.getInstr();
4454 "Addressing mode not supported for folding");
4471 return B.getInstr();
4478 "Address offset can be a register or an immediate, but not both");
4480 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
4485 OffsetReg =
MRI.createVirtualRegister(&AArch64::GPR32RegClass);
4499 return B.getInstr();
4503 "Function must not be called with an addressing mode it can't handle");
4512 case AArch64::LD1Fourv16b_POST:
4513 case AArch64::LD1Fourv1d_POST:
4514 case AArch64::LD1Fourv2d_POST:
4515 case AArch64::LD1Fourv2s_POST:
4516 case AArch64::LD1Fourv4h_POST:
4517 case AArch64::LD1Fourv4s_POST:
4518 case AArch64::LD1Fourv8b_POST:
4519 case AArch64::LD1Fourv8h_POST:
4520 case AArch64::LD1Onev16b_POST:
4521 case AArch64::LD1Onev1d_POST:
4522 case AArch64::LD1Onev2d_POST:
4523 case AArch64::LD1Onev2s_POST:
4524 case AArch64::LD1Onev4h_POST:
4525 case AArch64::LD1Onev4s_POST:
4526 case AArch64::LD1Onev8b_POST:
4527 case AArch64::LD1Onev8h_POST:
4528 case AArch64::LD1Rv16b_POST:
4529 case AArch64::LD1Rv1d_POST:
4530 case AArch64::LD1Rv2d_POST:
4531 case AArch64::LD1Rv2s_POST:
4532 case AArch64::LD1Rv4h_POST:
4533 case AArch64::LD1Rv4s_POST:
4534 case AArch64::LD1Rv8b_POST:
4535 case AArch64::LD1Rv8h_POST:
4536 case AArch64::LD1Threev16b_POST:
4537 case AArch64::LD1Threev1d_POST:
4538 case AArch64::LD1Threev2d_POST:
4539 case AArch64::LD1Threev2s_POST:
4540 case AArch64::LD1Threev4h_POST:
4541 case AArch64::LD1Threev4s_POST:
4542 case AArch64::LD1Threev8b_POST:
4543 case AArch64::LD1Threev8h_POST:
4544 case AArch64::LD1Twov16b_POST:
4545 case AArch64::LD1Twov1d_POST:
4546 case AArch64::LD1Twov2d_POST:
4547 case AArch64::LD1Twov2s_POST:
4548 case AArch64::LD1Twov4h_POST:
4549 case AArch64::LD1Twov4s_POST:
4550 case AArch64::LD1Twov8b_POST:
4551 case AArch64::LD1Twov8h_POST:
4552 case AArch64::LD1i16_POST:
4553 case AArch64::LD1i32_POST:
4554 case AArch64::LD1i64_POST:
4555 case AArch64::LD1i8_POST:
4556 case AArch64::LD2Rv16b_POST:
4557 case AArch64::LD2Rv1d_POST:
4558 case AArch64::LD2Rv2d_POST:
4559 case AArch64::LD2Rv2s_POST:
4560 case AArch64::LD2Rv4h_POST:
4561 case AArch64::LD2Rv4s_POST:
4562 case AArch64::LD2Rv8b_POST:
4563 case AArch64::LD2Rv8h_POST:
4564 case AArch64::LD2Twov16b_POST:
4565 case AArch64::LD2Twov2d_POST:
4566 case AArch64::LD2Twov2s_POST:
4567 case AArch64::LD2Twov4h_POST:
4568 case AArch64::LD2Twov4s_POST:
4569 case AArch64::LD2Twov8b_POST:
4570 case AArch64::LD2Twov8h_POST:
4571 case AArch64::LD2i16_POST:
4572 case AArch64::LD2i32_POST:
4573 case AArch64::LD2i64_POST:
4574 case AArch64::LD2i8_POST:
4575 case AArch64::LD3Rv16b_POST:
4576 case AArch64::LD3Rv1d_POST:
4577 case AArch64::LD3Rv2d_POST:
4578 case AArch64::LD3Rv2s_POST:
4579 case AArch64::LD3Rv4h_POST:
4580 case AArch64::LD3Rv4s_POST:
4581 case AArch64::LD3Rv8b_POST:
4582 case AArch64::LD3Rv8h_POST:
4583 case AArch64::LD3Threev16b_POST:
4584 case AArch64::LD3Threev2d_POST:
4585 case AArch64::LD3Threev2s_POST:
4586 case AArch64::LD3Threev4h_POST:
4587 case AArch64::LD3Threev4s_POST:
4588 case AArch64::LD3Threev8b_POST:
4589 case AArch64::LD3Threev8h_POST:
4590 case AArch64::LD3i16_POST:
4591 case AArch64::LD3i32_POST:
4592 case AArch64::LD3i64_POST:
4593 case AArch64::LD3i8_POST:
4594 case AArch64::LD4Fourv16b_POST:
4595 case AArch64::LD4Fourv2d_POST:
4596 case AArch64::LD4Fourv2s_POST:
4597 case AArch64::LD4Fourv4h_POST:
4598 case AArch64::LD4Fourv4s_POST:
4599 case AArch64::LD4Fourv8b_POST:
4600 case AArch64::LD4Fourv8h_POST:
4601 case AArch64::LD4Rv16b_POST:
4602 case AArch64::LD4Rv1d_POST:
4603 case AArch64::LD4Rv2d_POST:
4604 case AArch64::LD4Rv2s_POST:
4605 case AArch64::LD4Rv4h_POST:
4606 case AArch64::LD4Rv4s_POST:
4607 case AArch64::LD4Rv8b_POST:
4608 case AArch64::LD4Rv8h_POST:
4609 case AArch64::LD4i16_POST:
4610 case AArch64::LD4i32_POST:
4611 case AArch64::LD4i64_POST:
4612 case AArch64::LD4i8_POST:
4613 case AArch64::LDAPRWpost:
4614 case AArch64::LDAPRXpost:
4615 case AArch64::LDIAPPWpost:
4616 case AArch64::LDIAPPXpost:
4617 case AArch64::LDPDpost:
4618 case AArch64::LDPQpost:
4619 case AArch64::LDPSWpost:
4620 case AArch64::LDPSpost:
4621 case AArch64::LDPWpost:
4622 case AArch64::LDPXpost:
4623 case AArch64::LDRBBpost:
4624 case AArch64::LDRBpost:
4625 case AArch64::LDRDpost:
4626 case AArch64::LDRHHpost:
4627 case AArch64::LDRHpost:
4628 case AArch64::LDRQpost:
4629 case AArch64::LDRSBWpost:
4630 case AArch64::LDRSBXpost:
4631 case AArch64::LDRSHWpost:
4632 case AArch64::LDRSHXpost:
4633 case AArch64::LDRSWpost:
4634 case AArch64::LDRSpost:
4635 case AArch64::LDRWpost:
4636 case AArch64::LDRXpost:
4637 case AArch64::ST1Fourv16b_POST:
4638 case AArch64::ST1Fourv1d_POST:
4639 case AArch64::ST1Fourv2d_POST:
4640 case AArch64::ST1Fourv2s_POST:
4641 case AArch64::ST1Fourv4h_POST:
4642 case AArch64::ST1Fourv4s_POST:
4643 case AArch64::ST1Fourv8b_POST:
4644 case AArch64::ST1Fourv8h_POST:
4645 case AArch64::ST1Onev16b_POST:
4646 case AArch64::ST1Onev1d_POST:
4647 case AArch64::ST1Onev2d_POST:
4648 case AArch64::ST1Onev2s_POST:
4649 case AArch64::ST1Onev4h_POST:
4650 case AArch64::ST1Onev4s_POST:
4651 case AArch64::ST1Onev8b_POST:
4652 case AArch64::ST1Onev8h_POST:
4653 case AArch64::ST1Threev16b_POST:
4654 case AArch64::ST1Threev1d_POST:
4655 case AArch64::ST1Threev2d_POST:
4656 case AArch64::ST1Threev2s_POST:
4657 case AArch64::ST1Threev4h_POST:
4658 case AArch64::ST1Threev4s_POST:
4659 case AArch64::ST1Threev8b_POST:
4660 case AArch64::ST1Threev8h_POST:
4661 case AArch64::ST1Twov16b_POST:
4662 case AArch64::ST1Twov1d_POST:
4663 case AArch64::ST1Twov2d_POST:
4664 case AArch64::ST1Twov2s_POST:
4665 case AArch64::ST1Twov4h_POST:
4666 case AArch64::ST1Twov4s_POST:
4667 case AArch64::ST1Twov8b_POST:
4668 case AArch64::ST1Twov8h_POST:
4669 case AArch64::ST1i16_POST:
4670 case AArch64::ST1i32_POST:
4671 case AArch64::ST1i64_POST:
4672 case AArch64::ST1i8_POST:
4673 case AArch64::ST2GPostIndex:
4674 case AArch64::ST2Twov16b_POST:
4675 case AArch64::ST2Twov2d_POST:
4676 case AArch64::ST2Twov2s_POST:
4677 case AArch64::ST2Twov4h_POST:
4678 case AArch64::ST2Twov4s_POST:
4679 case AArch64::ST2Twov8b_POST:
4680 case AArch64::ST2Twov8h_POST:
4681 case AArch64::ST2i16_POST:
4682 case AArch64::ST2i32_POST:
4683 case AArch64::ST2i64_POST:
4684 case AArch64::ST2i8_POST:
4685 case AArch64::ST3Threev16b_POST:
4686 case AArch64::ST3Threev2d_POST:
4687 case AArch64::ST3Threev2s_POST:
4688 case AArch64::ST3Threev4h_POST:
4689 case AArch64::ST3Threev4s_POST:
4690 case AArch64::ST3Threev8b_POST:
4691 case AArch64::ST3Threev8h_POST:
4692 case AArch64::ST3i16_POST:
4693 case AArch64::ST3i32_POST:
4694 case AArch64::ST3i64_POST:
4695 case AArch64::ST3i8_POST:
4696 case AArch64::ST4Fourv16b_POST:
4697 case AArch64::ST4Fourv2d_POST:
4698 case AArch64::ST4Fourv2s_POST:
4699 case AArch64::ST4Fourv4h_POST:
4700 case AArch64::ST4Fourv4s_POST:
4701 case AArch64::ST4Fourv8b_POST:
4702 case AArch64::ST4Fourv8h_POST:
4703 case AArch64::ST4i16_POST:
4704 case AArch64::ST4i32_POST:
4705 case AArch64::ST4i64_POST:
4706 case AArch64::ST4i8_POST:
4707 case AArch64::STGPostIndex:
4708 case AArch64::STGPpost:
4709 case AArch64::STPDpost:
4710 case AArch64::STPQpost:
4711 case AArch64::STPSpost:
4712 case AArch64::STPWpost:
4713 case AArch64::STPXpost:
4714 case AArch64::STRBBpost:
4715 case AArch64::STRBpost:
4716 case AArch64::STRDpost:
4717 case AArch64::STRHHpost:
4718 case AArch64::STRHpost:
4719 case AArch64::STRQpost:
4720 case AArch64::STRSpost:
4721 case AArch64::STRWpost:
4722 case AArch64::STRXpost:
4723 case AArch64::STZ2GPostIndex:
4724 case AArch64::STZGPostIndex:
4731 bool &OffsetIsScalable,
TypeSize &Width)
const {
4751 int64_t Dummy1, Dummy2;
4773 return BaseOp->
isReg() || BaseOp->
isFI();
4780 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4785 TypeSize &Width, int64_t &MinOffset,
4786 int64_t &MaxOffset) {
4791 MinOffset = MaxOffset = 0;
4794 case AArch64::LDRQui:
4795 case AArch64::STRQui:
4800 case AArch64::LDRXui:
4801 case AArch64::LDRDui:
4802 case AArch64::STRXui:
4803 case AArch64::STRDui:
4804 case AArch64::PRFMui:
4805 case AArch64::ATOMIC_STORE_HINT_Xui:
4806 case AArch64::ATOMIC_STORE_HINT_Dui:
4811 case AArch64::LDRWui:
4812 case AArch64::LDRSui:
4813 case AArch64::LDRSWui:
4814 case AArch64::STRWui:
4815 case AArch64::STRSui:
4816 case AArch64::ATOMIC_STORE_HINT_Wui:
4817 case AArch64::ATOMIC_STORE_HINT_Sui:
4822 case AArch64::LDRHui:
4823 case AArch64::LDRHHui:
4824 case AArch64::LDRSHWui:
4825 case AArch64::LDRSHXui:
4826 case AArch64::STRHui:
4827 case AArch64::STRHHui:
4828 case AArch64::ATOMIC_STORE_HINT_Hui:
4833 case AArch64::LDRBui:
4834 case AArch64::LDRBBui:
4835 case AArch64::LDRSBWui:
4836 case AArch64::LDRSBXui:
4837 case AArch64::STRBui:
4838 case AArch64::STRBBui:
4839 case AArch64::ATOMIC_STORE_HINT_Bui:
4845 case AArch64::STRQpre:
4846 case AArch64::LDRQpost:
4852 case AArch64::LDRDpost:
4853 case AArch64::LDRDpre:
4854 case AArch64::LDRXpost:
4855 case AArch64::LDRXpre:
4856 case AArch64::STRDpost:
4857 case AArch64::STRDpre:
4858 case AArch64::STRXpost:
4859 case AArch64::STRXpre:
4865 case AArch64::STRWpost:
4866 case AArch64::STRWpre:
4867 case AArch64::LDRWpost:
4868 case AArch64::LDRWpre:
4869 case AArch64::STRSpost:
4870 case AArch64::STRSpre:
4871 case AArch64::LDRSpost:
4872 case AArch64::LDRSpre:
4878 case AArch64::LDRHpost:
4879 case AArch64::LDRHpre:
4880 case AArch64::STRHpost:
4881 case AArch64::STRHpre:
4882 case AArch64::LDRHHpost:
4883 case AArch64::LDRHHpre:
4884 case AArch64::STRHHpost:
4885 case AArch64::STRHHpre:
4891 case AArch64::LDRBpost:
4892 case AArch64::LDRBpre:
4893 case AArch64::STRBpost:
4894 case AArch64::STRBpre:
4895 case AArch64::LDRBBpost:
4896 case AArch64::LDRBBpre:
4897 case AArch64::STRBBpost:
4898 case AArch64::STRBBpre:
4904 case AArch64::LDURQi:
4905 case AArch64::STURQi:
4911 case AArch64::LDURXi:
4912 case AArch64::LDURDi:
4913 case AArch64::LDAPURXi:
4914 case AArch64::STURXi:
4915 case AArch64::STURDi:
4916 case AArch64::STLURXi:
4917 case AArch64::PRFUMi:
4918 case AArch64::ATOMIC_STORE_HINT_Xi:
4919 case AArch64::ATOMIC_STORE_HINT_Di:
4925 case AArch64::LDURWi:
4926 case AArch64::LDURSi:
4927 case AArch64::LDURSWi:
4928 case AArch64::LDAPURi:
4929 case AArch64::LDAPURSWi:
4930 case AArch64::STURWi:
4931 case AArch64::STURSi:
4932 case AArch64::STLURWi:
4933 case AArch64::ATOMIC_STORE_HINT_Wi:
4934 case AArch64::ATOMIC_STORE_HINT_Si:
4940 case AArch64::LDURHi:
4941 case AArch64::LDURHHi:
4942 case AArch64::LDURSHXi:
4943 case AArch64::LDURSHWi:
4944 case AArch64::LDAPURHi:
4945 case AArch64::LDAPURSHWi:
4946 case AArch64::LDAPURSHXi:
4947 case AArch64::STURHi:
4948 case AArch64::STURHHi:
4949 case AArch64::STLURHi:
4950 case AArch64::ATOMIC_STORE_HINT_Hi:
4956 case AArch64::LDURBi:
4957 case AArch64::LDURBBi:
4958 case AArch64::LDURSBXi:
4959 case AArch64::LDURSBWi:
4960 case AArch64::LDAPURBi:
4961 case AArch64::LDAPURSBWi:
4962 case AArch64::LDAPURSBXi:
4963 case AArch64::STURBi:
4964 case AArch64::STURBBi:
4965 case AArch64::STLURBi:
4966 case AArch64::ATOMIC_STORE_HINT_Bi:
4972 case AArch64::LDPQi:
4973 case AArch64::LDNPQi:
4974 case AArch64::STPQi:
4975 case AArch64::STNPQi:
4976 case AArch64::LDPQpost:
4977 case AArch64::LDPQpre:
4978 case AArch64::STPQpost:
4979 case AArch64::STPQpre:
4985 case AArch64::LDPXi:
4986 case AArch64::LDPDi:
4987 case AArch64::LDNPXi:
4988 case AArch64::LDNPDi:
4989 case AArch64::STPXi:
4990 case AArch64::STPDi:
4991 case AArch64::STNPXi:
4992 case AArch64::STNPDi:
4993 case AArch64::LDPDpost:
4994 case AArch64::LDPDpre:
4995 case AArch64::LDPXpost:
4996 case AArch64::LDPXpre:
4997 case AArch64::STPDpost:
4998 case AArch64::STPDpre:
4999 case AArch64::STPXpost:
5000 case AArch64::STPXpre:
5006 case AArch64::LDPWi:
5007 case AArch64::LDPSi:
5008 case AArch64::LDNPWi:
5009 case AArch64::LDNPSi:
5010 case AArch64::STPWi:
5011 case AArch64::STPSi:
5012 case AArch64::STNPWi:
5013 case AArch64::STNPSi:
5014 case AArch64::LDPSpost:
5015 case AArch64::LDPSpre:
5016 case AArch64::LDPWpost:
5017 case AArch64::LDPWpre:
5018 case AArch64::STPSpost:
5019 case AArch64::STPSpre:
5020 case AArch64::STPWpost:
5021 case AArch64::STPWpre:
5027 case AArch64::StoreSwiftAsyncContext:
5040 case AArch64::TAGPstack:
5050 case AArch64::STGPreIndex:
5051 case AArch64::STGPostIndex:
5052 case AArch64::STZGi:
5053 case AArch64::STZGPreIndex:
5054 case AArch64::STZGPostIndex:
5060 case AArch64::STR_ZZZZXI:
5061 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
5062 case AArch64::LDR_ZZZZXI:
5063 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
5069 case AArch64::STR_ZZZXI:
5070 case AArch64::LDR_ZZZXI:
5076 case AArch64::STR_ZZXI:
5077 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
5078 case AArch64::LDR_ZZXI:
5079 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
5085 case AArch64::LDR_PXI:
5086 case AArch64::STR_PXI:
5091 case AArch64::LDR_PPXI:
5092 case AArch64::STR_PPXI:
5098 case AArch64::LDR_ZXI:
5099 case AArch64::STR_ZXI:
5104 case AArch64::LD1B_IMM:
5105 case AArch64::LD1H_IMM:
5106 case AArch64::LD1W_IMM:
5107 case AArch64::LD1D_IMM:
5108 case AArch64::LDNT1B_ZRI:
5109 case AArch64::LDNT1H_ZRI:
5110 case AArch64::LDNT1W_ZRI:
5111 case AArch64::LDNT1D_ZRI:
5112 case AArch64::ST1B_IMM:
5113 case AArch64::ST1H_IMM:
5114 case AArch64::ST1W_IMM:
5115 case AArch64::ST1D_IMM:
5116 case AArch64::STNT1B_ZRI:
5117 case AArch64::STNT1H_ZRI:
5118 case AArch64::STNT1W_ZRI:
5119 case AArch64::STNT1D_ZRI:
5120 case AArch64::LDNF1B_IMM:
5121 case AArch64::LDNF1H_IMM:
5122 case AArch64::LDNF1W_IMM:
5123 case AArch64::LDNF1D_IMM:
5130 case AArch64::LD2B_IMM:
5131 case AArch64::LD2H_IMM:
5132 case AArch64::LD2W_IMM:
5133 case AArch64::LD2D_IMM:
5134 case AArch64::ST2B_IMM:
5135 case AArch64::ST2H_IMM:
5136 case AArch64::ST2W_IMM:
5137 case AArch64::ST2D_IMM:
5138 case AArch64::LD1B_2Z_IMM:
5139 case AArch64::LD1B_2Z_STRIDED_IMM:
5140 case AArch64::LD1H_2Z_IMM:
5141 case AArch64::LD1H_2Z_STRIDED_IMM:
5142 case AArch64::LD1W_2Z_IMM:
5143 case AArch64::LD1W_2Z_STRIDED_IMM:
5144 case AArch64::LD1D_2Z_IMM:
5145 case AArch64::LD1D_2Z_STRIDED_IMM:
5146 case AArch64::LD1B_2Z_IMM_PSEUDO:
5147 case AArch64::LD1H_2Z_IMM_PSEUDO:
5148 case AArch64::LD1W_2Z_IMM_PSEUDO:
5149 case AArch64::LD1D_2Z_IMM_PSEUDO:
5150 case AArch64::ST1B_2Z_IMM:
5151 case AArch64::ST1B_2Z_STRIDED_IMM:
5152 case AArch64::ST1H_2Z_IMM:
5153 case AArch64::ST1H_2Z_STRIDED_IMM:
5154 case AArch64::ST1W_2Z_IMM:
5155 case AArch64::ST1W_2Z_STRIDED_IMM:
5156 case AArch64::ST1D_2Z_IMM:
5157 case AArch64::ST1D_2Z_STRIDED_IMM:
5158 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5159 case AArch64::LDNT1B_2Z_IMM:
5160 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5161 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5162 case AArch64::LDNT1H_2Z_IMM:
5163 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5164 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5165 case AArch64::LDNT1W_2Z_IMM:
5166 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5167 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5168 case AArch64::LDNT1D_2Z_IMM:
5169 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5170 case AArch64::STNT1B_2Z_IMM:
5171 case AArch64::STNT1B_2Z_STRIDED_IMM:
5172 case AArch64::STNT1H_2Z_IMM:
5173 case AArch64::STNT1H_2Z_STRIDED_IMM:
5174 case AArch64::STNT1W_2Z_IMM:
5175 case AArch64::STNT1W_2Z_STRIDED_IMM:
5176 case AArch64::STNT1D_2Z_IMM:
5177 case AArch64::STNT1D_2Z_STRIDED_IMM:
5178 case AArch64::ST1B_2Z_IMM_PSEUDO:
5179 case AArch64::ST1H_2Z_IMM_PSEUDO:
5180 case AArch64::ST1W_2Z_IMM_PSEUDO:
5181 case AArch64::ST1D_2Z_IMM_PSEUDO:
5182 case AArch64::STNT1B_2Z_IMM_PSEUDO:
5183 case AArch64::STNT1H_2Z_IMM_PSEUDO:
5184 case AArch64::STNT1W_2Z_IMM_PSEUDO:
5185 case AArch64::STNT1D_2Z_IMM_PSEUDO:
5190 case AArch64::LD3B_IMM:
5191 case AArch64::LD3H_IMM:
5192 case AArch64::LD3W_IMM:
5193 case AArch64::LD3D_IMM:
5194 case AArch64::ST3B_IMM:
5195 case AArch64::ST3H_IMM:
5196 case AArch64::ST3W_IMM:
5197 case AArch64::ST3D_IMM:
5202 case AArch64::LD4B_IMM:
5203 case AArch64::LD4H_IMM:
5204 case AArch64::LD4W_IMM:
5205 case AArch64::LD4D_IMM:
5206 case AArch64::ST4B_IMM:
5207 case AArch64::ST4H_IMM:
5208 case AArch64::ST4W_IMM:
5209 case AArch64::ST4D_IMM:
5210 case AArch64::LD1B_4Z_IMM:
5211 case AArch64::LD1B_4Z_STRIDED_IMM:
5212 case AArch64::LD1H_4Z_IMM:
5213 case AArch64::LD1H_4Z_STRIDED_IMM:
5214 case AArch64::LD1W_4Z_IMM:
5215 case AArch64::LD1W_4Z_STRIDED_IMM:
5216 case AArch64::LD1D_4Z_IMM:
5217 case AArch64::LD1D_4Z_STRIDED_IMM:
5218 case AArch64::LD1B_4Z_IMM_PSEUDO:
5219 case AArch64::LD1H_4Z_IMM_PSEUDO:
5220 case AArch64::LD1W_4Z_IMM_PSEUDO:
5221 case AArch64::LD1D_4Z_IMM_PSEUDO:
5222 case AArch64::ST1B_4Z_IMM:
5223 case AArch64::ST1B_4Z_STRIDED_IMM:
5224 case AArch64::ST1H_4Z_IMM:
5225 case AArch64::ST1H_4Z_STRIDED_IMM:
5226 case AArch64::ST1W_4Z_IMM:
5227 case AArch64::ST1W_4Z_STRIDED_IMM:
5228 case AArch64::ST1D_4Z_IMM:
5229 case AArch64::ST1D_4Z_STRIDED_IMM:
5230 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5231 case AArch64::LDNT1B_4Z_IMM:
5232 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5233 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5234 case AArch64::LDNT1H_4Z_IMM:
5235 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5236 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5237 case AArch64::LDNT1W_4Z_IMM:
5238 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5239 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5240 case AArch64::LDNT1D_4Z_IMM:
5241 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5242 case AArch64::STNT1B_4Z_IMM:
5243 case AArch64::STNT1B_4Z_STRIDED_IMM:
5244 case AArch64::STNT1H_4Z_IMM:
5245 case AArch64::STNT1H_4Z_STRIDED_IMM:
5246 case AArch64::STNT1W_4Z_IMM:
5247 case AArch64::STNT1W_4Z_STRIDED_IMM:
5248 case AArch64::STNT1D_4Z_IMM:
5249 case AArch64::STNT1D_4Z_STRIDED_IMM:
5250 case AArch64::ST1B_4Z_IMM_PSEUDO:
5251 case AArch64::ST1H_4Z_IMM_PSEUDO:
5252 case AArch64::ST1W_4Z_IMM_PSEUDO:
5253 case AArch64::ST1D_4Z_IMM_PSEUDO:
5254 case AArch64::STNT1B_4Z_IMM_PSEUDO:
5255 case AArch64::STNT1H_4Z_IMM_PSEUDO:
5256 case AArch64::STNT1W_4Z_IMM_PSEUDO:
5257 case AArch64::STNT1D_4Z_IMM_PSEUDO:
5262 case AArch64::LD1B_H_IMM:
5263 case AArch64::LD1SB_H_IMM:
5264 case AArch64::LD1H_S_IMM:
5265 case AArch64::LD1SH_S_IMM:
5266 case AArch64::LD1W_D_IMM:
5267 case AArch64::LD1SW_D_IMM:
5268 case AArch64::ST1B_H_IMM:
5269 case AArch64::ST1H_S_IMM:
5270 case AArch64::ST1W_D_IMM:
5271 case AArch64::LDNF1B_H_IMM:
5272 case AArch64::LDNF1SB_H_IMM:
5273 case AArch64::LDNF1H_S_IMM:
5274 case AArch64::LDNF1SH_S_IMM:
5275 case AArch64::LDNF1W_D_IMM:
5276 case AArch64::LDNF1SW_D_IMM:
5283 case AArch64::LD1B_S_IMM:
5284 case AArch64::LD1SB_S_IMM:
5285 case AArch64::LD1H_D_IMM:
5286 case AArch64::LD1SH_D_IMM:
5287 case AArch64::ST1B_S_IMM:
5288 case AArch64::ST1H_D_IMM:
5289 case AArch64::LDNF1B_S_IMM:
5290 case AArch64::LDNF1SB_S_IMM:
5291 case AArch64::LDNF1H_D_IMM:
5292 case AArch64::LDNF1SH_D_IMM:
5299 case AArch64::LD1B_D_IMM:
5300 case AArch64::LD1SB_D_IMM:
5301 case AArch64::ST1B_D_IMM:
5302 case AArch64::LDNF1B_D_IMM:
5303 case AArch64::LDNF1SB_D_IMM:
5310 case AArch64::ST2Gi:
5311 case AArch64::ST2GPreIndex:
5312 case AArch64::ST2GPostIndex:
5313 case AArch64::STZ2Gi:
5314 case AArch64::STZ2GPreIndex:
5315 case AArch64::STZ2GPostIndex:
5321 case AArch64::STGPi:
5322 case AArch64::STGPpost:
5323 case AArch64::STGPpre:
5328 case AArch64::LD1RB_IMM:
5329 case AArch64::LD1RB_H_IMM:
5330 case AArch64::LD1RB_S_IMM:
5331 case AArch64::LD1RB_D_IMM:
5332 case AArch64::LD1RSB_H_IMM:
5333 case AArch64::LD1RSB_S_IMM:
5334 case AArch64::LD1RSB_D_IMM:
5339 case AArch64::LD1RH_IMM:
5340 case AArch64::LD1RH_S_IMM:
5341 case AArch64::LD1RH_D_IMM:
5342 case AArch64::LD1RSH_S_IMM:
5343 case AArch64::LD1RSH_D_IMM:
5348 case AArch64::LD1RW_IMM:
5349 case AArch64::LD1RW_D_IMM:
5350 case AArch64::LD1RSW_IMM:
5355 case AArch64::LD1RD_IMM:
5370 case AArch64::LDRBui:
5371 case AArch64::LDRBBui:
5372 case AArch64::LDURBBi:
5373 case AArch64::LDRSBWui:
5374 case AArch64::LDURSBWi:
5375 case AArch64::STRBui:
5376 case AArch64::STRBBui:
5377 case AArch64::STURBBi:
5379 case AArch64::LDRHui:
5380 case AArch64::LDRHHui:
5381 case AArch64::LDURHHi:
5382 case AArch64::LDRSHWui:
5383 case AArch64::LDURSHWi:
5384 case AArch64::STRHui:
5385 case AArch64::STRHHui:
5386 case AArch64::STURHHi:
5388 case AArch64::LDRSui:
5389 case AArch64::LDURSi:
5390 case AArch64::LDRSpre:
5391 case AArch64::LDRSWui:
5392 case AArch64::LDURSWi:
5393 case AArch64::LDRSWpre:
5394 case AArch64::LDRWpre:
5395 case AArch64::LDRWui:
5396 case AArch64::LDURWi:
5397 case AArch64::STRSui:
5398 case AArch64::STURSi:
5399 case AArch64::STRSpre:
5400 case AArch64::STRWui:
5401 case AArch64::STURWi:
5402 case AArch64::STRWpre:
5403 case AArch64::LDPSi:
5404 case AArch64::LDPSWi:
5405 case AArch64::LDPWi:
5406 case AArch64::STPSi:
5407 case AArch64::STPWi:
5409 case AArch64::LDRDui:
5410 case AArch64::LDURDi:
5411 case AArch64::LDRDpre:
5412 case AArch64::LDRXui:
5413 case AArch64::LDURXi:
5414 case AArch64::LDRXpre:
5415 case AArch64::STRDui:
5416 case AArch64::STURDi:
5417 case AArch64::STRDpre:
5418 case AArch64::STRXui:
5419 case AArch64::STURXi:
5420 case AArch64::STRXpre:
5421 case AArch64::LDPDi:
5422 case AArch64::LDPXi:
5423 case AArch64::STPDi:
5424 case AArch64::STPXi:
5426 case AArch64::LDRQui:
5427 case AArch64::LDURQi:
5428 case AArch64::STRQui:
5429 case AArch64::STURQi:
5430 case AArch64::STRQpre:
5431 case AArch64::LDPQi:
5432 case AArch64::LDRQpre:
5433 case AArch64::STPQi:
5435 case AArch64::STZGi:
5436 case AArch64::ST2Gi:
5437 case AArch64::STZ2Gi:
5438 case AArch64::STGPi:
5444 switch (
MI.getOpcode()) {
5447 case AArch64::LDRWpre:
5448 case AArch64::LDRXpre:
5449 case AArch64::LDRSWpre:
5450 case AArch64::LDRSpre:
5451 case AArch64::LDRDpre:
5452 case AArch64::LDRQpre:
5458 switch (
MI.getOpcode()) {
5461 case AArch64::STRWpre:
5462 case AArch64::STRXpre:
5463 case AArch64::STRSpre:
5464 case AArch64::STRDpre:
5465 case AArch64::STRQpre:
5475 switch (
MI.getOpcode()) {
5478 case AArch64::LDURBBi:
5479 case AArch64::LDURHHi:
5480 case AArch64::LDURWi:
5481 case AArch64::LDRBBui:
5482 case AArch64::LDRHHui:
5483 case AArch64::LDRWui:
5484 case AArch64::LDRBBroX:
5485 case AArch64::LDRHHroX:
5486 case AArch64::LDRWroX:
5487 case AArch64::LDRBBroW:
5488 case AArch64::LDRHHroW:
5489 case AArch64::LDRWroW:
5495 switch (
MI.getOpcode()) {
5498 case AArch64::LDURSBWi:
5499 case AArch64::LDURSHWi:
5500 case AArch64::LDURSBXi:
5501 case AArch64::LDURSHXi:
5502 case AArch64::LDURSWi:
5503 case AArch64::LDRSBWui:
5504 case AArch64::LDRSHWui:
5505 case AArch64::LDRSBXui:
5506 case AArch64::LDRSHXui:
5507 case AArch64::LDRSWui:
5508 case AArch64::LDRSBWroX:
5509 case AArch64::LDRSHWroX:
5510 case AArch64::LDRSBXroX:
5511 case AArch64::LDRSHXroX:
5512 case AArch64::LDRSWroX:
5513 case AArch64::LDRSBWroW:
5514 case AArch64::LDRSHWroW:
5515 case AArch64::LDRSBXroW:
5516 case AArch64::LDRSHXroW:
5517 case AArch64::LDRSWroW:
5523 switch (
MI.getOpcode()) {
5526 case AArch64::LDPSi:
5527 case AArch64::LDPSWi:
5528 case AArch64::LDPDi:
5529 case AArch64::LDPQi:
5530 case AArch64::LDPWi:
5531 case AArch64::LDPXi:
5532 case AArch64::STPSi:
5533 case AArch64::STPDi:
5534 case AArch64::STPQi:
5535 case AArch64::STPWi:
5536 case AArch64::STPXi:
5537 case AArch64::STGPi:
5543 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5547 return MI.getOperand(Idx);
5552 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5556 return MI.getOperand(Idx);
5561 switch (
MI.getOpcode()) {
5564 case AArch64::LDRBroX:
5565 case AArch64::LDRBBroX:
5566 case AArch64::LDRSBXroX:
5567 case AArch64::LDRSBWroX:
5568 case AArch64::LDRHroX:
5569 case AArch64::LDRHHroX:
5570 case AArch64::LDRSHXroX:
5571 case AArch64::LDRSHWroX:
5572 case AArch64::LDRWroX:
5573 case AArch64::LDRSroX:
5574 case AArch64::LDRSWroX:
5575 case AArch64::LDRDroX:
5576 case AArch64::LDRXroX:
5577 case AArch64::LDRQroX:
5578 return MI.getOperand(4);
5584 if (
MI.getParent() ==
nullptr)
5594 auto Reg =
Op.getReg();
5595 if (Reg.isPhysical())
5596 return AArch64::FPR16RegClass.contains(Reg);
5598 return TRC == &AArch64::FPR16RegClass ||
5599 TRC == &AArch64::FPR16_loRegClass;
5608 auto Reg =
Op.getReg();
5609 if (Reg.isPhysical())
5610 return AArch64::FPR128RegClass.contains(Reg);
5612 return TRC == &AArch64::FPR128RegClass ||
5613 TRC == &AArch64::FPR128_loRegClass;
5619 switch (
MI.getOpcode()) {
5622 case AArch64::PACIASP:
5623 case AArch64::PACIBSP:
5624 case AArch64::PACIASPPC:
5625 case AArch64::PACIBSPPC:
5628 case AArch64::PAUTH_PROLOGUE:
5631 case AArch64::HINT: {
5632 unsigned Imm =
MI.getOperand(0).getImm();
5637 if (
Imm == 25 ||
Imm == 27)
5649 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5650 return AArch64::FPR128RegClass.contains(Reg) ||
5651 AArch64::FPR64RegClass.contains(Reg) ||
5652 AArch64::FPR32RegClass.contains(Reg) ||
5653 AArch64::FPR16RegClass.contains(Reg) ||
5654 AArch64::FPR8RegClass.contains(Reg);
5661 auto Reg =
Op.getReg();
5662 if (Reg.isPhysical())
5666 return TRC == &AArch64::FPR128RegClass ||
5667 TRC == &AArch64::FPR128_loRegClass ||
5668 TRC == &AArch64::FPR64RegClass ||
5669 TRC == &AArch64::FPR64_loRegClass ||
5670 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5671 TRC == &AArch64::FPR8RegClass;
5693 if (FirstOpc == SecondOpc)
5699 case AArch64::STRSui:
5700 case AArch64::STURSi:
5701 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5702 case AArch64::STRDui:
5703 case AArch64::STURDi:
5704 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5705 case AArch64::STRQui:
5706 case AArch64::STURQi:
5707 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5708 case AArch64::STRWui:
5709 case AArch64::STURWi:
5710 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5711 case AArch64::STRXui:
5712 case AArch64::STURXi:
5713 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5714 case AArch64::LDRSui:
5715 case AArch64::LDURSi:
5716 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5717 case AArch64::LDRDui:
5718 case AArch64::LDURDi:
5719 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5720 case AArch64::LDRQui:
5721 case AArch64::LDURQi:
5722 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5723 case AArch64::LDRWui:
5724 case AArch64::LDURWi:
5725 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5726 case AArch64::LDRSWui:
5727 case AArch64::LDURSWi:
5728 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5729 case AArch64::LDRXui:
5730 case AArch64::LDURXi:
5731 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5738 int64_t Offset1,
unsigned Opcode1,
int FI2,
5739 int64_t Offset2,
unsigned Opcode2) {
5745 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5748 if (ObjectOffset1 % Scale1 != 0)
5750 ObjectOffset1 /= Scale1;
5752 if (ObjectOffset2 % Scale2 != 0)
5754 ObjectOffset2 /= Scale2;
5755 ObjectOffset1 += Offset1;
5756 ObjectOffset2 += Offset2;
5757 return ObjectOffset1 + 1 == ObjectOffset2;
5769 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5770 unsigned NumBytes)
const {
5780 "Only base registers and frame indices are supported.");
5787 if (ClusterSize > 2)
5794 unsigned FirstOpc = FirstLdSt.
getOpcode();
5795 unsigned SecondOpc = SecondLdSt.
getOpcode();
5815 if (Offset1 > 63 || Offset1 < -64)
5820 if (BaseOp1.
isFI()) {
5822 "Caller should have ordered offsets.");
5827 BaseOp2.
getIndex(), Offset2, SecondOpc);
5830 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5832 return Offset1 + 1 == Offset2;
5842 if (
Reg.isPhysical())
5852 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5854 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5855 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5856 unsigned NumRegs = Indices.
size();
5857 MCRegister DestSubReg =
TRI->getSubReg(DestReg, Indices[0]);
5859 "Unexpected predicate tuple copy");
5860 unsigned MaxRegs = AArch64::PPRRegClass.contains(DestSubReg) ? 15 : 31;
5862 int SubReg = 0,
End = NumRegs, Incr = 1;
5864 if (((DestEncoding - SrcEncoding) & MaxRegs) < NumRegs) {
5865 SubReg = NumRegs - 1;
5870 for (; SubReg !=
End; SubReg += Incr) {
5871 DestSubReg =
TRI->getSubReg(DestReg, Indices[SubReg]);
5872 MCRegister SrcSubReg =
TRI->getSubReg(SrcReg, Indices[SubReg]);
5881 unsigned Opcode,
unsigned ZeroReg,
5884 unsigned NumRegs = Indices.
size();
5887 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5888 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5889 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5890 "GPR reg sequences should not be able to overlap");
5893 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5914 unsigned Opc =
MI.getOpcode();
5915 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5917 int64_t PState =
MI.getOperand(0).getImm();
5918 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5920 return MI.getOperand(1).getImm() == 1;
5939 bool RenamableSrc)
const {
5940 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5941 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5942 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5944 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5945 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5947 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5948 &AArch64::GPR64spRegClass);
5949 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5950 &AArch64::GPR64spRegClass);
5960 ++NumZCRegMoveInstrsGPR;
5966 if (Subtarget.hasZeroCycleRegMoveGPR32())
5967 ++NumZCRegMoveInstrsGPR;
5969 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5970 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5972 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5973 &AArch64::GPR64spRegClass);
5974 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5975 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5976 &AArch64::GPR64spRegClass);
5986 ++NumZCRegMoveInstrsGPR;
5992 if (Subtarget.hasZeroCycleRegMoveGPR32())
5993 ++NumZCRegMoveInstrsGPR;
5999 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
6000 if (Subtarget.hasZeroCycleZeroingGPR64() &&
6001 !Subtarget.hasZeroCycleZeroingGPR32()) {
6002 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
6003 &AArch64::GPR64spRegClass);
6004 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
6008 ++NumZCZeroingInstrsGPR;
6009 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
6013 ++NumZCZeroingInstrsGPR;
6022 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
6023 AArch64::GPR64spRegClass.
contains(SrcReg)) {
6024 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
6030 if (Subtarget.hasZeroCycleRegMoveGPR64())
6031 ++NumZCRegMoveInstrsGPR;
6037 if (Subtarget.hasZeroCycleRegMoveGPR64())
6038 ++NumZCRegMoveInstrsGPR;
6044 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
6045 if (Subtarget.hasZeroCycleZeroingGPR64()) {
6049 ++NumZCZeroingInstrsGPR;
6059 if (AArch64::PPRRegClass.
contains(DestReg) &&
6060 AArch64::PPRRegClass.
contains(SrcReg)) {
6061 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6062 "Unexpected SVE register.");
6072 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
6073 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
6074 if (DestIsPNR || SrcIsPNR) {
6076 return (R - AArch64::PN0) + AArch64::P0;
6081 if (PPRSrcReg != PPRDestReg) {
6093 if (AArch64::PPR2RegClass.
contains(DestReg) &&
6094 AArch64::PPR2RegClass.
contains(SrcReg)) {
6095 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6096 "Unexpected SVE predicate register.");
6097 static const unsigned Indices[] = {AArch64::psub0, AArch64::psub1};
6103 if (AArch64::ZPRRegClass.
contains(DestReg) &&
6104 AArch64::ZPRRegClass.
contains(SrcReg)) {
6105 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6106 "Unexpected SVE register.");
6114 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
6115 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
6116 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
6117 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
6118 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6119 "Unexpected SVE register.");
6120 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
6126 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
6127 AArch64::ZPR3RegClass.
contains(SrcReg)) {
6128 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6129 "Unexpected SVE register.");
6130 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6137 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
6138 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
6139 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
6140 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
6141 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6142 "Unexpected SVE register.");
6143 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6144 AArch64::zsub2, AArch64::zsub3};
6150 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6151 AArch64::DDDDRegClass.
contains(SrcReg)) {
6152 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6153 AArch64::dsub2, AArch64::dsub3};
6159 if (AArch64::DDDRegClass.
contains(DestReg) &&
6160 AArch64::DDDRegClass.
contains(SrcReg)) {
6161 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6168 if (AArch64::DDRegClass.
contains(DestReg) &&
6169 AArch64::DDRegClass.
contains(SrcReg)) {
6170 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6176 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6177 AArch64::QQQQRegClass.
contains(SrcReg)) {
6178 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6179 AArch64::qsub2, AArch64::qsub3};
6185 if (AArch64::QQQRegClass.
contains(DestReg) &&
6186 AArch64::QQQRegClass.
contains(SrcReg)) {
6187 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6194 if (AArch64::QQRegClass.
contains(DestReg) &&
6195 AArch64::QQRegClass.
contains(SrcReg)) {
6196 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6201 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6202 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6203 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6205 AArch64::XZR, Indices);
6209 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6210 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6211 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6213 AArch64::WZR, Indices);
6217 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6218 AArch64::FPR128RegClass.
contains(SrcReg)) {
6222 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6223 !Subtarget.isNeonAvailable()) ||
6227 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6228 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6229 }
else if (Subtarget.isNeonAvailable()) {
6233 if (Subtarget.hasZeroCycleRegMoveFPR128())
6234 ++NumZCRegMoveInstrsFPR;
6250 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6251 AArch64::FPR64RegClass.
contains(SrcReg)) {
6252 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6253 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6254 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6256 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6257 &AArch64::FPR128RegClass);
6258 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6259 &AArch64::FPR128RegClass);
6268 ++NumZCRegMoveInstrsFPR;
6272 if (Subtarget.hasZeroCycleRegMoveFPR64())
6273 ++NumZCRegMoveInstrsFPR;
6278 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6279 AArch64::FPR32RegClass.
contains(SrcReg)) {
6280 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6281 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6282 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6284 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6285 &AArch64::FPR128RegClass);
6286 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6287 &AArch64::FPR128RegClass);
6296 ++NumZCRegMoveInstrsFPR;
6297 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6298 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6299 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6300 &AArch64::FPR64RegClass);
6301 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6302 &AArch64::FPR64RegClass);
6310 ++NumZCRegMoveInstrsFPR;
6314 if (Subtarget.hasZeroCycleRegMoveFPR32())
6315 ++NumZCRegMoveInstrsFPR;
6320 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6321 AArch64::FPR16RegClass.
contains(SrcReg)) {
6322 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6323 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6324 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6326 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6327 &AArch64::FPR128RegClass);
6328 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6329 &AArch64::FPR128RegClass);
6338 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6339 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6340 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6341 &AArch64::FPR64RegClass);
6342 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6343 &AArch64::FPR64RegClass);
6352 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6353 &AArch64::FPR32RegClass);
6354 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6355 &AArch64::FPR32RegClass);
6362 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6363 AArch64::FPR8RegClass.
contains(SrcReg)) {
6364 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6365 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6366 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6368 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6369 &AArch64::FPR128RegClass);
6370 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6371 &AArch64::FPR128RegClass);
6380 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6381 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6382 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6383 &AArch64::FPR64RegClass);
6384 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6385 &AArch64::FPR64RegClass);
6394 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6395 &AArch64::FPR32RegClass);
6396 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6397 &AArch64::FPR32RegClass);
6405 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6406 AArch64::GPR64RegClass.
contains(SrcReg)) {
6407 if (AArch64::XZR == SrcReg) {
6415 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6416 AArch64::FPR64RegClass.
contains(SrcReg)) {
6422 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6423 AArch64::GPR32RegClass.
contains(SrcReg)) {
6424 if (AArch64::WZR == SrcReg) {
6432 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6433 AArch64::FPR32RegClass.
contains(SrcReg)) {
6439 if (DestReg == AArch64::NZCV) {
6440 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6442 .
addImm(AArch64SysReg::NZCV)
6448 if (SrcReg == AArch64::NZCV) {
6449 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6451 .
addImm(AArch64SysReg::NZCV)
6457 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6468 bool RenamableSrc)
const {
6480 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6485 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6487 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6500 Register SrcReg,
bool isKill,
int FI,
6515 switch (RI.getSpillSize(*RC)) {
6517 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6518 Opc = AArch64::STRBui;
6521 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6522 Opc = AArch64::STRHui;
6523 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6524 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6525 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6526 "Unexpected register store without SVE store instructions");
6527 Opc = AArch64::STR_PXI;
6533 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6534 Opc = AArch64::STRWui;
6538 assert(SrcReg != AArch64::WSP);
6539 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6540 Opc = AArch64::STRSui;
6541 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6542 Opc = AArch64::STR_PPXI;
6547 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6548 Opc = AArch64::STRXui;
6552 assert(SrcReg != AArch64::SP);
6553 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6554 Opc = AArch64::STRDui;
6555 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6557 get(AArch64::STPWi), SrcReg, isKill,
6558 AArch64::sube32, AArch64::subo32, FI, MMO);
6563 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6564 Opc = AArch64::STRQui;
6565 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6566 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6567 Opc = AArch64::ST1Twov1d;
6569 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6571 get(AArch64::STPXi), SrcReg, isKill,
6572 AArch64::sube64, AArch64::subo64, FI, MMO);
6574 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6575 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6576 "Unexpected register store without SVE store instructions");
6577 Opc = AArch64::STR_ZXI;
6582 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6583 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6584 Opc = AArch64::ST1Threev1d;
6589 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6590 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6591 Opc = AArch64::ST1Fourv1d;
6593 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6594 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6595 Opc = AArch64::ST1Twov2d;
6597 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6598 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6599 "Unexpected register store without SVE store instructions");
6600 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6602 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6603 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6604 "Unexpected register store without SVE store instructions");
6605 Opc = AArch64::STR_ZZXI;
6610 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6611 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6612 Opc = AArch64::ST1Threev2d;
6614 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6615 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6616 "Unexpected register store without SVE store instructions");
6617 Opc = AArch64::STR_ZZZXI;
6622 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6623 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6624 Opc = AArch64::ST1Fourv2d;
6626 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6627 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6628 "Unexpected register store without SVE store instructions");
6629 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6631 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6632 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6633 "Unexpected register store without SVE store instructions");
6634 Opc = AArch64::STR_ZZZZXI;
6639 assert(
Opc &&
"Unknown register class");
6650 MI.addMemOperand(MMO);
6657 Register DestReg,
unsigned SubIdx0,
6658 unsigned SubIdx1,
int FI,
6662 bool IsUndef =
true;
6664 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6666 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6695 switch (
TRI.getSpillSize(*RC)) {
6697 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6698 Opc = AArch64::LDRBui;
6701 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6702 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6703 Opc = AArch64::LDRHui;
6704 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6705 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6706 "Unexpected register load without SVE load instructions");
6709 Opc = AArch64::LDR_PXI;
6715 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6716 Opc = AArch64::LDRWui;
6720 assert(DestReg != AArch64::WSP);
6721 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6722 Opc = AArch64::LDRSui;
6723 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6724 Opc = AArch64::LDR_PPXI;
6729 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6730 Opc = AArch64::LDRXui;
6734 assert(DestReg != AArch64::SP);
6735 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6736 Opc = AArch64::LDRDui;
6737 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6739 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6740 AArch64::subo32, FI, MMO);
6745 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6746 Opc = AArch64::LDRQui;
6747 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6748 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6749 Opc = AArch64::LD1Twov1d;
6751 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6753 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6754 AArch64::subo64, FI, MMO);
6756 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6757 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6758 "Unexpected register load without SVE load instructions");
6759 Opc = AArch64::LDR_ZXI;
6764 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6765 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6766 Opc = AArch64::LD1Threev1d;
6771 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6772 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6773 Opc = AArch64::LD1Fourv1d;
6775 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6776 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6777 Opc = AArch64::LD1Twov2d;
6779 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6780 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6781 "Unexpected register load without SVE load instructions");
6782 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6784 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6785 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6786 "Unexpected register load without SVE load instructions");
6787 Opc = AArch64::LDR_ZZXI;
6792 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6793 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6794 Opc = AArch64::LD1Threev2d;
6796 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6797 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6798 "Unexpected register load without SVE load instructions");
6799 Opc = AArch64::LDR_ZZZXI;
6804 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6805 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6806 Opc = AArch64::LD1Fourv2d;
6808 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6809 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6810 "Unexpected register load without SVE load instructions");
6811 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6813 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6814 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6815 "Unexpected register load without SVE load instructions");
6816 Opc = AArch64::LDR_ZZZZXI;
6822 assert(
Opc &&
"Unknown register class");
6832 MI.addMemOperand(MMO);
6839 UseMI.getIterator()),
6841 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6842 I.readsRegister(AArch64::NZCV, TRI);
6846void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6851 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6858 ByteSized =
Offset.getFixed();
6859 VGSized =
Offset.getScalable() / 2;
6865void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6867 int64_t &NumDataVectors) {
6871 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6873 NumBytes =
Offset.getFixed();
6875 NumPredicateVectors =
Offset.getScalable() / 2;
6880 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6881 NumPredicateVectors > 62) {
6882 NumDataVectors = NumPredicateVectors / 8;
6883 NumPredicateVectors -= NumDataVectors * 8;
6909 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6917 int64_t OffsetFromDefCFA) {
6931 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6932 if (!RegScale.empty())
6942 int64_t NumBytes, NumVGScaledBytes;
6943 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6945 std::string CommentBuffer;
6948 if (
Reg == AArch64::SP)
6950 else if (
Reg == AArch64::FP)
6957 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6958 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6960 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6963 if (NumVGScaledBytes) {
6973 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6981 unsigned FrameReg,
unsigned Reg,
6983 bool LastAdjustmentWasScalable) {
6984 if (
Offset.getScalable())
6987 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6990 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6997 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6998 int64_t NumBytes, NumVGScaledBytes;
6999 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
7000 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
7002 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
7005 if (!NumVGScaledBytes)
7008 std::string CommentBuffer;
7013 assert(NumVGScaledBytes &&
"Expected scalable offset");
7017 if (IncomingVGOffsetFromDefCFA) {
7019 VGRegScale =
"* IncomingVG";
7022 VGRegScale =
"* VG";
7026 OffsetExpr.
push_back(dwarf::DW_OP_plus);
7035 CfaExpr.
push_back(dwarf::DW_CFA_expression);
7050 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
7053 bool *HasWinCFI,
bool EmitCFAOffset,
7056 unsigned MaxEncoding, ShiftSize;
7058 case AArch64::ADDXri:
7059 case AArch64::ADDSXri:
7060 case AArch64::SUBXri:
7061 case AArch64::SUBSXri:
7062 MaxEncoding = 0xfff;
7065 case AArch64::ADDVL_XXI:
7066 case AArch64::ADDPL_XXI:
7067 case AArch64::ADDSVL_XXI:
7068 case AArch64::ADDSPL_XXI:
7083 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
7085 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
7099 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
7101 if (TmpReg == AArch64::XZR)
7102 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
7103 &AArch64::GPR64RegClass);
7105 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
7106 unsigned LocalShiftSize = 0;
7107 if (ThisVal > MaxEncoding) {
7108 ThisVal = ThisVal >> ShiftSize;
7109 LocalShiftSize = ShiftSize;
7111 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
7112 "Encoding cannot handle value that big");
7114 Offset -= ThisVal << LocalShiftSize;
7129 if (
Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
7130 CFAOffset += Change;
7132 CFAOffset -= Change;
7133 if (EmitCFAOffset && DestReg == TmpReg) {
7146 int Imm = (int)(ThisVal << LocalShiftSize);
7147 if (VScale != 1 && DestReg == AArch64::SP) {
7153 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7154 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7155 assert(VScale == 1 &&
"Expected non-scalable operation");
7164 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7165 "emit a single SEH directive");
7166 }
else if (DestReg == AArch64::SP) {
7167 assert(VScale == 1 &&
"Expected non-scalable operation");
7170 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7183 unsigned DestReg,
unsigned SrcReg,
7186 bool NeedsWinCFI,
bool *HasWinCFI,
7188 unsigned FrameReg) {
7195 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7197 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7198 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7199 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7202 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7203 if (NeedsFinalDefNZCV)
7207 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7208 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7209 "SP increment/decrement not 8-byte aligned");
7210 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7213 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7216 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7218 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7225 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7226 "WinCFI can't allocate fractions of an SVE data vector");
7228 if (NumDataVectors) {
7230 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7231 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7237 if (NumPredicateVectors) {
7238 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7240 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7241 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7245 if (NeedsFinalDefNZCV)
7267 if (
MI.isFullCopy()) {
7270 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7274 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7279 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7307 if (
MI.isCopy() &&
Ops.size() == 1 &&
7309 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7310 bool IsSpill =
Ops[0] == 0;
7311 bool IsFill = !IsSpill;
7323 :
TRI.getMinimalPhysRegClass(Reg);
7329 "Mismatched register size in non subreg COPY");
7348 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7351 "Unexpected subreg on physical register");
7353 FrameIndex, &AArch64::GPR64RegClass,
Register());
7371 case AArch64::sub_32:
7372 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7373 FillRC = &AArch64::GPR32RegClass;
7376 FillRC = &AArch64::FPR32RegClass;
7379 FillRC = &AArch64::FPR64RegClass;
7385 TRI.getRegSizeInBits(*FillRC) &&
7386 "Mismatched regclass size on folded subreg COPY");
7405 bool *OutUseUnscaledOp,
7406 unsigned *OutUnscaledOp,
7407 int64_t *EmittableOffset) {
7409 if (EmittableOffset)
7410 *EmittableOffset = 0;
7411 if (OutUseUnscaledOp)
7412 *OutUseUnscaledOp =
false;
7418 switch (
MI.getOpcode()) {
7421 case AArch64::LD1Rv1d:
7422 case AArch64::LD1Rv2s:
7423 case AArch64::LD1Rv2d:
7424 case AArch64::LD1Rv4h:
7425 case AArch64::LD1Rv4s:
7426 case AArch64::LD1Rv8b:
7427 case AArch64::LD1Rv8h:
7428 case AArch64::LD1Rv16b:
7429 case AArch64::LD1Twov2d:
7430 case AArch64::LD1Threev2d:
7431 case AArch64::LD1Fourv2d:
7432 case AArch64::LD1Twov1d:
7433 case AArch64::LD1Threev1d:
7434 case AArch64::LD1Fourv1d:
7435 case AArch64::ST1Twov2d:
7436 case AArch64::ST1Threev2d:
7437 case AArch64::ST1Fourv2d:
7438 case AArch64::ST1Twov1d:
7439 case AArch64::ST1Threev1d:
7440 case AArch64::ST1Fourv1d:
7441 case AArch64::ST1i8:
7442 case AArch64::ST1i16:
7443 case AArch64::ST1i32:
7444 case AArch64::ST1i64:
7446 case AArch64::IRGstack:
7447 case AArch64::STGloop:
7448 case AArch64::STZGloop:
7453 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7454 int64_t MinOff, MaxOff;
7460 bool IsMulVL = ScaleValue.isScalable();
7461 unsigned Scale = ScaleValue.getKnownMinValue();
7471 std::optional<unsigned> UnscaledOp =
7473 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7474 if (useUnscaledOp &&
7479 Scale = ScaleValue.getKnownMinValue();
7480 assert(IsMulVL == ScaleValue.isScalable() &&
7481 "Unscaled opcode has different value for scalable");
7483 int64_t Remainder =
Offset % Scale;
7484 assert(!(Remainder && useUnscaledOp) &&
7485 "Cannot have remainder when using unscaled op");
7487 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7488 int64_t NewOffset =
Offset / Scale;
7489 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7497 int64_t HighPart =
Offset & ~0xFFF;
7498 int64_t LowPart =
Offset & 0xFFF;
7499 int64_t LowScaled = LowPart / Scale;
7500 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7501 MinOff <= LowScaled && LowScaled <= MaxOff &&
7503 NewOffset = LowScaled;
7508 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7513 if (EmittableOffset)
7514 *EmittableOffset = NewOffset;
7515 if (OutUseUnscaledOp)
7516 *OutUseUnscaledOp = useUnscaledOp;
7517 if (OutUnscaledOp && UnscaledOp)
7518 *OutUnscaledOp = *UnscaledOp;
7531 unsigned Opcode =
MI.getOpcode();
7532 unsigned ImmIdx = FrameRegIdx + 1;
7534 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7539 MI.eraseFromParent();
7545 unsigned UnscaledOp;
7548 &UnscaledOp, &NewOffset);
7552 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7554 MI.setDesc(
TII->get(UnscaledOp));
7556 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7572bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7577 case AArch64::ADDSWrr:
7578 case AArch64::ADDSWri:
7579 case AArch64::ADDSXrr:
7580 case AArch64::ADDSXri:
7581 case AArch64::SUBSWrr:
7582 case AArch64::SUBSXrr:
7584 case AArch64::SUBSWri:
7585 case AArch64::SUBSXri:
7596 case AArch64::ADDWrr:
7597 case AArch64::ADDWri:
7598 case AArch64::ADDWrs:
7599 case AArch64::SUBWrr:
7600 case AArch64::ADDSWrr:
7601 case AArch64::ADDSWri:
7602 case AArch64::SUBSWrr:
7604 case AArch64::SUBWri:
7605 case AArch64::SUBSWri:
7616 case AArch64::ADDXrr:
7617 case AArch64::ADDXri:
7618 case AArch64::ADDXrs:
7619 case AArch64::SUBXrr:
7620 case AArch64::ADDSXrr:
7621 case AArch64::ADDSXri:
7622 case AArch64::SUBSXrr:
7624 case AArch64::SUBXri:
7625 case AArch64::SUBSXri:
7626 case AArch64::ADDv8i8:
7627 case AArch64::ADDv16i8:
7628 case AArch64::ADDv4i16:
7629 case AArch64::ADDv8i16:
7630 case AArch64::ADDv2i32:
7631 case AArch64::ADDv4i32:
7632 case AArch64::SUBv8i8:
7633 case AArch64::SUBv16i8:
7634 case AArch64::SUBv4i16:
7635 case AArch64::SUBv8i16:
7636 case AArch64::SUBv2i32:
7637 case AArch64::SUBv4i32:
7650 case AArch64::FADDHrr:
7651 case AArch64::FADDSrr:
7652 case AArch64::FADDDrr:
7653 case AArch64::FADDv4f16:
7654 case AArch64::FADDv8f16:
7655 case AArch64::FADDv2f32:
7656 case AArch64::FADDv2f64:
7657 case AArch64::FADDv4f32:
7658 case AArch64::FSUBHrr:
7659 case AArch64::FSUBSrr:
7660 case AArch64::FSUBDrr:
7661 case AArch64::FSUBv4f16:
7662 case AArch64::FSUBv8f16:
7663 case AArch64::FSUBv2f32:
7664 case AArch64::FSUBv2f64:
7665 case AArch64::FSUBv4f32:
7682 unsigned CombineOpc,
unsigned ZeroReg = 0,
7683 bool CheckZeroReg =
false) {
7690 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7693 if (!
MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()))
7697 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7698 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7699 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7701 if (
MI->getOperand(3).getReg() != ZeroReg)
7706 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7715 unsigned MulOpc,
unsigned ZeroReg) {
7730bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7731 bool Invert)
const {
7737 case AArch64::FADDHrr:
7738 case AArch64::FADDSrr:
7739 case AArch64::FADDDrr:
7740 case AArch64::FMULHrr:
7741 case AArch64::FMULSrr:
7742 case AArch64::FMULDrr:
7743 case AArch64::FMULX16:
7744 case AArch64::FMULX32:
7745 case AArch64::FMULX64:
7747 case AArch64::FADDv4f16:
7748 case AArch64::FADDv8f16:
7749 case AArch64::FADDv2f32:
7750 case AArch64::FADDv4f32:
7751 case AArch64::FADDv2f64:
7752 case AArch64::FMULv4f16:
7753 case AArch64::FMULv8f16:
7754 case AArch64::FMULv2f32:
7755 case AArch64::FMULv4f32:
7756 case AArch64::FMULv2f64:
7757 case AArch64::FMULXv4f16:
7758 case AArch64::FMULXv8f16:
7759 case AArch64::FMULXv2f32:
7760 case AArch64::FMULXv4f32:
7761 case AArch64::FMULXv2f64:
7765 case AArch64::FADD_ZZZ_H:
7766 case AArch64::FADD_ZZZ_S:
7767 case AArch64::FADD_ZZZ_D:
7768 case AArch64::FMUL_ZZZ_H:
7769 case AArch64::FMUL_ZZZ_S:
7770 case AArch64::FMUL_ZZZ_D:
7781 case AArch64::ADDWrr:
7782 case AArch64::ADDXrr:
7783 case AArch64::ANDWrr:
7784 case AArch64::ANDXrr:
7785 case AArch64::ORRWrr:
7786 case AArch64::ORRXrr:
7787 case AArch64::EORWrr:
7788 case AArch64::EORXrr:
7789 case AArch64::EONWrr:
7790 case AArch64::EONXrr:
7794 case AArch64::ADDv8i8:
7795 case AArch64::ADDv16i8:
7796 case AArch64::ADDv4i16:
7797 case AArch64::ADDv8i16:
7798 case AArch64::ADDv2i32:
7799 case AArch64::ADDv4i32:
7800 case AArch64::ADDv1i64:
7801 case AArch64::ADDv2i64:
7802 case AArch64::MULv8i8:
7803 case AArch64::MULv16i8:
7804 case AArch64::MULv4i16:
7805 case AArch64::MULv8i16:
7806 case AArch64::MULv2i32:
7807 case AArch64::MULv4i32:
7808 case AArch64::ANDv8i8:
7809 case AArch64::ANDv16i8:
7810 case AArch64::ORRv8i8:
7811 case AArch64::ORRv16i8:
7812 case AArch64::EORv8i8:
7813 case AArch64::EORv16i8:
7815 case AArch64::ADD_ZZZ_B:
7816 case AArch64::ADD_ZZZ_H:
7817 case AArch64::ADD_ZZZ_S:
7818 case AArch64::ADD_ZZZ_D:
7819 case AArch64::MUL_ZZZ_B:
7820 case AArch64::MUL_ZZZ_H:
7821 case AArch64::MUL_ZZZ_S:
7822 case AArch64::MUL_ZZZ_D:
7823 case AArch64::AND_ZZZ:
7824 case AArch64::ORR_ZZZ:
7825 case AArch64::EOR_ZZZ:
7856 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7866 auto setShfFound = [&](
int Opcode,
unsigned ZeroReg,
unsigned Pattern) {
7871 if (STI.hasShiftMaddSlow())
7889 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7901 case AArch64::ADDWrr:
7903 "ADDWrr does not have register operands");
7904 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7905 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7907 case AArch64::ADDXrr:
7908 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7909 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7911 case AArch64::SUBWrr:
7912 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7913 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7915 case AArch64::SUBXrr:
7916 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7917 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7919 case AArch64::ADDWri:
7920 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7922 case AArch64::ADDXri:
7923 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7925 case AArch64::SUBWri:
7926 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7928 case AArch64::SUBXri:
7929 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7931 case AArch64::ADDWrs:
7932 setShfFound(AArch64::MADDWrrr, AArch64::WZR, MCP::MULADDWS_OP1);
7934 case AArch64::ADDXrs:
7935 setShfFound(AArch64::MADDXrrr, AArch64::XZR, MCP::MULADDXS_OP1);
7937 case AArch64::ADDv8i8:
7938 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7939 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7941 case AArch64::ADDv16i8:
7942 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7943 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7945 case AArch64::ADDv4i16:
7946 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7947 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7948 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7949 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7951 case AArch64::ADDv8i16:
7952 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7953 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7954 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7955 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7957 case AArch64::ADDv2i32:
7958 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7959 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7960 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7961 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7963 case AArch64::ADDv4i32:
7964 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7965 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7966 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7967 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7969 case AArch64::SUBv8i8:
7970 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7971 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7973 case AArch64::SUBv16i8:
7974 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7975 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7977 case AArch64::SUBv4i16:
7978 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7979 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7980 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7981 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7983 case AArch64::SUBv8i16:
7984 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7985 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7986 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7987 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7989 case AArch64::SUBv2i32:
7990 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7991 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7992 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7993 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7995 case AArch64::SUBv4i32:
7996 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7997 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7998 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7999 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
8005std::optional<TargetInstrInfo::FMAChainLinkInfo>
8006AArch64InstrInfo::getFMAChainLinkInfo(
const MachineInstr &
MI)
const {
8007 switch (
MI.getOpcode()) {
8009 return std::nullopt;
8011 case AArch64::FMADDSrrr:
8012 return FMAChainLinkInfo{AArch64::FADDSrr, AArch64::FMULSrr, 3};
8013 case AArch64::FMADDDrrr:
8014 return FMAChainLinkInfo{AArch64::FADDDrr, AArch64::FMULDrr, 3};
8016 case AArch64::FMLAv1i32_indexed:
8017 return FMAChainLinkInfo{AArch64::FADDSrr, AArch64::FMULv1i32_indexed, 1};
8018 case AArch64::FMLAv1i64_indexed:
8019 return FMAChainLinkInfo{AArch64::FADDDrr, AArch64::FMULv1i64_indexed, 1};
8020 case AArch64::FMLAv2f32:
8021 return FMAChainLinkInfo{AArch64::FADDv2f32, AArch64::FMULv2f32, 1};
8022 case AArch64::FMLAv4f32:
8023 return FMAChainLinkInfo{AArch64::FADDv4f32, AArch64::FMULv4f32, 1};
8024 case AArch64::FMLAv2f64:
8025 return FMAChainLinkInfo{AArch64::FADDv2f64, AArch64::FMULv2f64, 1};
8026 case AArch64::FMLAv2i32_indexed:
8027 return FMAChainLinkInfo{AArch64::FADDv2f32, AArch64::FMULv2i32_indexed, 1};
8028 case AArch64::FMLAv4i32_indexed:
8029 return FMAChainLinkInfo{AArch64::FADDv4f32, AArch64::FMULv4i32_indexed, 1};
8030 case AArch64::FMLAv2i64_indexed:
8031 return FMAChainLinkInfo{AArch64::FADDv2f64, AArch64::FMULv2i64_indexed, 1};
8032 case AArch64::FADDSrr:
8033 case AArch64::FADDDrr:
8034 case AArch64::FADDv2f32:
8035 case AArch64::FADDv4f32:
8036 case AArch64::FADDv2f64:
8037 return FMAChainLinkInfo{
MI.getOpcode(), 0, -1};
8041bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
8045 case AArch64::UABALB_ZZZ_D:
8046 case AArch64::UABALB_ZZZ_H:
8047 case AArch64::UABALB_ZZZ_S:
8048 case AArch64::UABALT_ZZZ_D:
8049 case AArch64::UABALT_ZZZ_H:
8050 case AArch64::UABALT_ZZZ_S:
8051 case AArch64::SABALB_ZZZ_D:
8052 case AArch64::SABALB_ZZZ_S:
8053 case AArch64::SABALB_ZZZ_H:
8054 case AArch64::SABALT_ZZZ_D:
8055 case AArch64::SABALT_ZZZ_S:
8056 case AArch64::SABALT_ZZZ_H:
8057 case AArch64::UABALv16i8_v8i16:
8058 case AArch64::UABALv2i32_v2i64:
8059 case AArch64::UABALv4i16_v4i32:
8060 case AArch64::UABALv4i32_v2i64:
8061 case AArch64::UABALv8i16_v4i32:
8062 case AArch64::UABALv8i8_v8i16:
8063 case AArch64::UABAv16i8:
8064 case AArch64::UABAv2i32:
8065 case AArch64::UABAv4i16:
8066 case AArch64::UABAv4i32:
8067 case AArch64::UABAv8i16:
8068 case AArch64::UABAv8i8:
8069 case AArch64::SABALv16i8_v8i16:
8070 case AArch64::SABALv2i32_v2i64:
8071 case AArch64::SABALv4i16_v4i32:
8072 case AArch64::SABALv4i32_v2i64:
8073 case AArch64::SABALv8i16_v4i32:
8074 case AArch64::SABALv8i8_v8i16:
8075 case AArch64::SABAv16i8:
8076 case AArch64::SABAv2i32:
8077 case AArch64::SABAv4i16:
8078 case AArch64::SABAv4i32:
8079 case AArch64::SABAv8i16:
8080 case AArch64::SABAv8i8:
8087unsigned AArch64InstrInfo::getAccumulationStartOpcode(
8088 unsigned AccumulationOpcode)
const {
8089 switch (AccumulationOpcode) {
8092 case AArch64::UABALB_ZZZ_D:
8093 return AArch64::UABDLB_ZZZ_D;
8094 case AArch64::UABALB_ZZZ_H:
8095 return AArch64::UABDLB_ZZZ_H;
8096 case AArch64::UABALB_ZZZ_S:
8097 return AArch64::UABDLB_ZZZ_S;
8098 case AArch64::UABALT_ZZZ_D:
8099 return AArch64::UABDLT_ZZZ_D;
8100 case AArch64::UABALT_ZZZ_H:
8101 return AArch64::UABDLT_ZZZ_H;
8102 case AArch64::UABALT_ZZZ_S:
8103 return AArch64::UABDLT_ZZZ_S;
8104 case AArch64::UABALv16i8_v8i16:
8105 return AArch64::UABDLv16i8_v8i16;
8106 case AArch64::UABALv2i32_v2i64:
8107 return AArch64::UABDLv2i32_v2i64;
8108 case AArch64::UABALv4i16_v4i32:
8109 return AArch64::UABDLv4i16_v4i32;
8110 case AArch64::UABALv4i32_v2i64:
8111 return AArch64::UABDLv4i32_v2i64;
8112 case AArch64::UABALv8i16_v4i32:
8113 return AArch64::UABDLv8i16_v4i32;
8114 case AArch64::UABALv8i8_v8i16:
8115 return AArch64::UABDLv8i8_v8i16;
8116 case AArch64::UABAv16i8:
8117 return AArch64::UABDv16i8;
8118 case AArch64::UABAv2i32:
8119 return AArch64::UABDv2i32;
8120 case AArch64::UABAv4i16:
8121 return AArch64::UABDv4i16;
8122 case AArch64::UABAv4i32:
8123 return AArch64::UABDv4i32;
8124 case AArch64::UABAv8i16:
8125 return AArch64::UABDv8i16;
8126 case AArch64::UABAv8i8:
8127 return AArch64::UABDv8i8;
8128 case AArch64::SABALB_ZZZ_D:
8129 return AArch64::SABDLB_ZZZ_D;
8130 case AArch64::SABALB_ZZZ_S:
8131 return AArch64::SABDLB_ZZZ_S;
8132 case AArch64::SABALB_ZZZ_H:
8133 return AArch64::SABDLB_ZZZ_H;
8134 case AArch64::SABALT_ZZZ_D:
8135 return AArch64::SABDLT_ZZZ_D;
8136 case AArch64::SABALT_ZZZ_S:
8137 return AArch64::SABDLT_ZZZ_S;
8138 case AArch64::SABALT_ZZZ_H:
8139 return AArch64::SABDLT_ZZZ_H;
8140 case AArch64::SABALv16i8_v8i16:
8141 return AArch64::SABDLv16i8_v8i16;
8142 case AArch64::SABALv2i32_v2i64:
8143 return AArch64::SABDLv2i32_v2i64;
8144 case AArch64::SABALv4i16_v4i32:
8145 return AArch64::SABDLv4i16_v4i32;
8146 case AArch64::SABALv4i32_v2i64:
8147 return AArch64::SABDLv4i32_v2i64;
8148 case AArch64::SABALv8i16_v4i32:
8149 return AArch64::SABDLv8i16_v4i32;
8150 case AArch64::SABALv8i8_v8i16:
8151 return AArch64::SABDLv8i8_v8i16;
8152 case AArch64::SABAv16i8:
8153 return AArch64::SABDv16i8;
8154 case AArch64::SABAv2i32:
8155 return AArch64::SABDv2i32;
8156 case AArch64::SABAv4i16:
8157 return AArch64::SABDv4i16;
8158 case AArch64::SABAv4i32:
8159 return AArch64::SABDv4i32;
8160 case AArch64::SABAv8i16:
8161 return AArch64::SABDv8i16;
8162 case AArch64::SABAv8i8:
8163 return AArch64::SABDv8i8;
8179 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
8191 assert(
false &&
"Unsupported FP instruction in combiner\n");
8193 case AArch64::FADDHrr:
8195 "FADDHrr does not have register operands");
8197 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
8198 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
8200 case AArch64::FADDSrr:
8202 "FADDSrr does not have register operands");
8204 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
8205 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
8207 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
8208 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
8210 case AArch64::FADDDrr:
8211 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
8212 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
8214 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8215 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8217 case AArch64::FADDv4f16:
8218 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8219 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8221 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8222 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8224 case AArch64::FADDv8f16:
8225 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8226 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8228 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8229 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8231 case AArch64::FADDv2f32:
8232 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8233 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8235 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8236 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8238 case AArch64::FADDv2f64:
8239 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8240 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8242 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8243 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8245 case AArch64::FADDv4f32:
8246 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8247 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8249 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8250 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8252 case AArch64::FSUBHrr:
8253 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8254 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8255 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8257 case AArch64::FSUBSrr:
8258 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8260 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8261 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8263 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8265 case AArch64::FSUBDrr:
8266 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8268 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8269 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8271 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8273 case AArch64::FSUBv4f16:
8274 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8275 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8277 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8278 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8280 case AArch64::FSUBv8f16:
8281 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8282 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8284 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8285 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8287 case AArch64::FSUBv2f32:
8288 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8289 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8291 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8292 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8294 case AArch64::FSUBv2f64:
8295 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8296 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8298 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8299 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8301 case AArch64::FSUBv4f32:
8302 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8303 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8305 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8306 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8317 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8324 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8325 MI->getOperand(1).getReg().isVirtual())
8326 MI =
MRI.getUniqueVRegDef(
MI->getOperand(1).getReg());
8327 if (
MI &&
MI->getOpcode() == Opcode) {
8339 case AArch64::FMULv2f32:
8340 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8341 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8343 case AArch64::FMULv2f64:
8344 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8345 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8347 case AArch64::FMULv4f16:
8348 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8349 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8351 case AArch64::FMULv4f32:
8352 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8353 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8355 case AArch64::FMULv8f16:
8356 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8357 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8370 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8373 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8374 MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()) &&
8388 case AArch64::FNEGDr:
8390 case AArch64::FNEGSr:
8522 case AArch64::SUBWrr:
8523 case AArch64::SUBSWrr:
8524 case AArch64::SUBXrr:
8525 case AArch64::SUBSXrr:
8570 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8593 while (!RemainingLanes.
empty() && CurrInstr &&
8594 CurrInstr->getOpcode() == LoadLaneOpCode &&
8595 MRI.hasOneNonDBGUse(CurrInstr->getOperand(0).getReg()) &&
8596 CurrInstr->getNumOperands() == 4) {
8597 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8599 CurrInstr =
MRI.getUniqueVRegDef(CurrInstr->getOperand(1).getReg());
8603 if (!RemainingLanes.
empty())
8607 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8611 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8612 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8613 if (
TRI->getRegSizeInBits(Lane0LoadReg,
MRI) != SingleLaneSizeInBits)
8617 if (!
MRI.hasOneNonDBGUse(Lane0LoadReg))
8620 LoadInstrs.
push_back(
MRI.getUniqueVRegDef(Lane0LoadReg));
8627 unsigned RemainingSteps =
8630 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8633 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8634 !RemainingLoadInstrs.
empty();
8635 --MBBItr, --RemainingSteps) {
8639 RemainingLoadInstrs.
erase(&CurrInstr);
8649 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8675 case AArch64::LD1i32:
8677 case AArch64::LD1i16:
8679 case AArch64::LD1i8:
8695 unsigned Pattern,
unsigned NumLanes) {
8703 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8711 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8716 MRI.getUniqueVRegDef(SubregToReg->getOperand(1).getReg()));
8717 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8723 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8724 Register SrcRegister,
unsigned Lane,
8726 auto NewRegister =
MRI.createVirtualRegister(FPR128RegClass);
8734 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8735 InsInstrs.
push_back(LoadIndexIntoRegister);
8741 auto CreateLDRInstruction =
8747 Opcode = AArch64::LDRSui;
8750 Opcode = AArch64::LDRHui;
8753 Opcode = AArch64::LDRBui;
8757 "Got unsupported number of lanes in machine-combiner gather pattern");
8767 auto LanesToLoadToReg0 =
8769 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8770 Register PrevReg = SubregToReg->getOperand(0).getReg();
8772 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8773 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8774 OffsetRegOperand.
getReg());
8781 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8783 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8784 Register DestRegForMiddleIndex =
MRI.createVirtualRegister(
8790 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8791 OriginalSplitToLoadOffsetOperand.
getReg(),
8794 InstrIdxForVirtReg.
insert(
8795 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8796 InsInstrs.
push_back(MiddleIndexLoadInstr);
8800 Register DestRegForSubregToReg =
MRI.createVirtualRegister(FPR128RegClass);
8801 unsigned SubregType;
8804 SubregType = AArch64::ssub;
8807 SubregType = AArch64::hsub;
8810 SubregType = AArch64::bsub;
8814 "Got invalid NumLanes for machine-combiner gather pattern");
8817 auto SubRegToRegInstr =
8819 DestRegForSubregToReg)
8820 .
addReg(DestRegForMiddleIndex)
8822 InstrIdxForVirtReg.
insert(
8823 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8827 auto LanesToLoadToReg1 =
8829 LoadToLaneInstrsAscending.end());
8830 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8832 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8833 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8834 OffsetRegOperand.
getReg());
8837 if (Index == NumLanes / 2 - 2) {
8872bool AArch64InstrInfo::getMachineCombinerPatterns(
8874 bool DoRegPressureReduce)
const {
8895 DoRegPressureReduce);
8924 const Register *ReplacedAddend =
nullptr) {
8925 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8927 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8930 Register SrcReg0 = MUL->getOperand(1).getReg();
8931 Register SrcReg1 = MUL->getOperand(2).getReg();
8937 MRI.constrainRegClass(ResultReg, RC);
8939 MRI.constrainRegClass(SrcReg0, RC);
8941 MRI.constrainRegClass(SrcReg1, RC);
8943 MRI.constrainRegClass(SrcReg2, RC);
8956 .
addImm(MUL->getOperand(3).getImm());
8963 assert(
false &&
"Invalid FMA instruction kind \n");
8978 unsigned MaddOpc,
bool Is64Bit,
8981 Is64Bit ? &AArch64::GPR64RegClass : &AArch64::GPR32RegClass;
8984 Register SrcReg0 = MUL->getOperand(1).getReg();
8985 Register SrcReg1 = MUL->getOperand(2).getReg();
8989 MRI.constrainRegClass(ResultReg, RC);
8991 MRI.constrainRegClass(SrcReg0, RC);
8993 MRI.constrainRegClass(SrcReg1, RC);
8995 MRI.constrainRegClass(ShiftedReg, RC);
8999 unsigned RegSize = Is64Bit ? 64 : 32;
9001 unsigned ImmR, ImmS;
9004 BFMOpc = Is64Bit ? AArch64::SBFMXri : AArch64::SBFMWri;
9009 BFMOpc = Is64Bit ? AArch64::UBFMXri : AArch64::UBFMWri;
9014 BFMOpc = Is64Bit ? AArch64::UBFMXri : AArch64::UBFMWri;
9016 ImmS =
RegSize - 1 - ShiftVal;
9022 Register ShiftReg =
MRI.createVirtualRegister(RC);
9028 InstrIdxForVirtReg.
insert(std::make_pair(ShiftReg, InsInstrs.
size()));
9054 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
9055 Opc = AArch64::FNMADDSrrr;
9056 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
9057 Opc = AArch64::FNMADDDrrr;
9066 MRI.constrainRegClass(ResultReg, RC);
9068 MRI.constrainRegClass(SrcReg0, RC);
9070 MRI.constrainRegClass(SrcReg1, RC);
9072 MRI.constrainRegClass(SrcReg2, RC);
9088 unsigned IdxDupOp,
unsigned MulOpc,
9090 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
9091 "Invalid index of FMUL operand");
9099 if (Dup->
getOpcode() == TargetOpcode::COPY)
9103 MRI.constrainRegClass(DupSrcReg, RC);
9107 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
9148 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9163 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9190 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9218 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
9220 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
9224 Register SrcReg0 = MUL->getOperand(1).getReg();
9225 Register SrcReg1 = MUL->getOperand(2).getReg();
9228 MRI.constrainRegClass(ResultReg, RC);
9230 MRI.constrainRegClass(SrcReg0, RC);
9232 MRI.constrainRegClass(SrcReg1, RC);
9234 MRI.constrainRegClass(VR, RC);
9255 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
9256 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
9267 if (Opcode == AArch64::SUBSWrr)
9268 Opcode = AArch64::SUBWrr;
9269 else if (Opcode == AArch64::SUBSXrr)
9270 Opcode = AArch64::SUBXrr;
9272 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9273 "Unexpected instruction opcode.");
9290 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9297unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9298 unsigned int AccumulatorOpCode)
const {
9299 switch (AccumulatorOpCode) {
9300 case AArch64::UABALB_ZZZ_D:
9301 case AArch64::SABALB_ZZZ_D:
9302 case AArch64::UABALT_ZZZ_D:
9303 case AArch64::SABALT_ZZZ_D:
9304 return AArch64::ADD_ZZZ_D;
9305 case AArch64::UABALB_ZZZ_H:
9306 case AArch64::SABALB_ZZZ_H:
9307 case AArch64::UABALT_ZZZ_H:
9308 case AArch64::SABALT_ZZZ_H:
9309 return AArch64::ADD_ZZZ_H;
9310 case AArch64::UABALB_ZZZ_S:
9311 case AArch64::SABALB_ZZZ_S:
9312 case AArch64::UABALT_ZZZ_S:
9313 case AArch64::SABALT_ZZZ_S:
9314 return AArch64::ADD_ZZZ_S;
9315 case AArch64::UABALv16i8_v8i16:
9316 case AArch64::SABALv8i8_v8i16:
9317 case AArch64::SABAv8i16:
9318 case AArch64::UABAv8i16:
9319 return AArch64::ADDv8i16;
9320 case AArch64::SABALv2i32_v2i64:
9321 case AArch64::UABALv2i32_v2i64:
9322 case AArch64::SABALv4i32_v2i64:
9323 return AArch64::ADDv2i64;
9324 case AArch64::UABALv4i16_v4i32:
9325 case AArch64::SABALv4i16_v4i32:
9326 case AArch64::SABALv8i16_v4i32:
9327 case AArch64::SABAv4i32:
9328 case AArch64::UABAv4i32:
9329 return AArch64::ADDv4i32;
9330 case AArch64::UABALv4i32_v2i64:
9331 return AArch64::ADDv2i64;
9332 case AArch64::UABALv8i16_v4i32:
9333 return AArch64::ADDv4i32;
9334 case AArch64::UABALv8i8_v8i16:
9335 case AArch64::SABALv16i8_v8i16:
9336 return AArch64::ADDv8i16;
9337 case AArch64::UABAv16i8:
9338 case AArch64::SABAv16i8:
9339 return AArch64::ADDv16i8;
9340 case AArch64::UABAv4i16:
9341 case AArch64::SABAv4i16:
9342 return AArch64::ADDv4i16;
9343 case AArch64::UABAv2i32:
9344 case AArch64::SABAv2i32:
9345 return AArch64::ADDv2i32;
9346 case AArch64::UABAv8i8:
9347 case AArch64::SABAv8i8:
9348 return AArch64::ADDv8i8;
9357void AArch64InstrInfo::genAlternativeCodeSequence(
9367 MachineInstr *
MUL =
nullptr;
9374 DelInstrs, InstrIdxForVirtReg);
9380 InstrIdxForVirtReg);
9386 InstrIdxForVirtReg);
9395 Opc = AArch64::MADDWrrr;
9396 RC = &AArch64::GPR32RegClass;
9398 Opc = AArch64::MADDXrrr;
9399 RC = &AArch64::GPR64RegClass;
9410 Opc = AArch64::MADDWrrr;
9411 RC = &AArch64::GPR32RegClass;
9413 Opc = AArch64::MADDXrrr;
9414 RC = &AArch64::GPR64RegClass;
9428 unsigned BitSize, MovImm;
9431 MovImm = AArch64::MOVi32imm;
9432 RC = &AArch64::GPR32spRegClass;
9434 Opc = AArch64::MADDWrrr;
9435 RC = &AArch64::GPR32RegClass;
9437 MovImm = AArch64::MOVi64imm;
9438 RC = &AArch64::GPR64spRegClass;
9440 Opc = AArch64::MADDXrrr;
9441 RC = &AArch64::GPR64RegClass;
9456 if (Insn.
size() != 1)
9458 MachineInstrBuilder MIB1 =
9459 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9462 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9474 unsigned SubOpc, ZeroReg;
9476 SubOpc = AArch64::SUBWrr;
9477 SubRC = &AArch64::GPR32spRegClass;
9478 ZeroReg = AArch64::WZR;
9479 Opc = AArch64::MADDWrrr;
9480 RC = &AArch64::GPR32RegClass;
9482 SubOpc = AArch64::SUBXrr;
9483 SubRC = &AArch64::GPR64spRegClass;
9484 ZeroReg = AArch64::XZR;
9485 Opc = AArch64::MADDXrrr;
9486 RC = &AArch64::GPR64RegClass;
9490 MachineInstrBuilder MIB1 =
9491 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9495 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9506 Opc = AArch64::MSUBWrrr;
9507 RC = &AArch64::GPR32RegClass;
9509 Opc = AArch64::MSUBXrrr;
9510 RC = &AArch64::GPR64RegClass;
9516 false, InstrIdxForVirtReg);
9520 true, InstrIdxForVirtReg);
9523 Opc = AArch64::MLAv8i8;
9524 RC = &AArch64::FPR64RegClass;
9528 Opc = AArch64::MLAv8i8;
9529 RC = &AArch64::FPR64RegClass;
9533 Opc = AArch64::MLAv16i8;
9534 RC = &AArch64::FPR128RegClass;
9538 Opc = AArch64::MLAv16i8;
9539 RC = &AArch64::FPR128RegClass;
9543 Opc = AArch64::MLAv4i16;
9544 RC = &AArch64::FPR64RegClass;
9548 Opc = AArch64::MLAv4i16;
9549 RC = &AArch64::FPR64RegClass;
9553 Opc = AArch64::MLAv8i16;
9554 RC = &AArch64::FPR128RegClass;
9558 Opc = AArch64::MLAv8i16;
9559 RC = &AArch64::FPR128RegClass;
9563 Opc = AArch64::MLAv2i32;
9564 RC = &AArch64::FPR64RegClass;
9568 Opc = AArch64::MLAv2i32;
9569 RC = &AArch64::FPR64RegClass;
9573 Opc = AArch64::MLAv4i32;
9574 RC = &AArch64::FPR128RegClass;
9578 Opc = AArch64::MLAv4i32;
9579 RC = &AArch64::FPR128RegClass;
9584 Opc = AArch64::MLAv8i8;
9585 RC = &AArch64::FPR64RegClass;
9587 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9591 Opc = AArch64::MLSv8i8;
9592 RC = &AArch64::FPR64RegClass;
9596 Opc = AArch64::MLAv16i8;
9597 RC = &AArch64::FPR128RegClass;
9599 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9603 Opc = AArch64::MLSv16i8;
9604 RC = &AArch64::FPR128RegClass;
9608 Opc = AArch64::MLAv4i16;
9609 RC = &AArch64::FPR64RegClass;
9611 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9615 Opc = AArch64::MLSv4i16;
9616 RC = &AArch64::FPR64RegClass;
9620 Opc = AArch64::MLAv8i16;
9621 RC = &AArch64::FPR128RegClass;
9623 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9627 Opc = AArch64::MLSv8i16;
9628 RC = &AArch64::FPR128RegClass;
9632 Opc = AArch64::MLAv2i32;
9633 RC = &AArch64::FPR64RegClass;
9635 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9639 Opc = AArch64::MLSv2i32;
9640 RC = &AArch64::FPR64RegClass;
9644 Opc = AArch64::MLAv4i32;
9645 RC = &AArch64::FPR128RegClass;
9647 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9651 Opc = AArch64::MLSv4i32;
9652 RC = &AArch64::FPR128RegClass;
9657 Opc = AArch64::MLAv4i16_indexed;
9658 RC = &AArch64::FPR64RegClass;
9662 Opc = AArch64::MLAv4i16_indexed;
9663 RC = &AArch64::FPR64RegClass;
9667 Opc = AArch64::MLAv8i16_indexed;
9668 RC = &AArch64::FPR128RegClass;
9672 Opc = AArch64::MLAv8i16_indexed;
9673 RC = &AArch64::FPR128RegClass;
9677 Opc = AArch64::MLAv2i32_indexed;
9678 RC = &AArch64::FPR64RegClass;
9682 Opc = AArch64::MLAv2i32_indexed;
9683 RC = &AArch64::FPR64RegClass;
9687 Opc = AArch64::MLAv4i32_indexed;
9688 RC = &AArch64::FPR128RegClass;
9692 Opc = AArch64::MLAv4i32_indexed;
9693 RC = &AArch64::FPR128RegClass;
9698 Opc = AArch64::MLAv4i16_indexed;
9699 RC = &AArch64::FPR64RegClass;
9701 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9705 Opc = AArch64::MLSv4i16_indexed;
9706 RC = &AArch64::FPR64RegClass;
9710 Opc = AArch64::MLAv8i16_indexed;
9711 RC = &AArch64::FPR128RegClass;
9713 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9717 Opc = AArch64::MLSv8i16_indexed;
9718 RC = &AArch64::FPR128RegClass;
9722 Opc = AArch64::MLAv2i32_indexed;
9723 RC = &AArch64::FPR64RegClass;
9725 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9729 Opc = AArch64::MLSv2i32_indexed;
9730 RC = &AArch64::FPR64RegClass;
9734 Opc = AArch64::MLAv4i32_indexed;
9735 RC = &AArch64::FPR128RegClass;
9737 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9741 Opc = AArch64::MLSv4i32_indexed;
9742 RC = &AArch64::FPR128RegClass;
9748 Opc = AArch64::FMADDHrrr;
9749 RC = &AArch64::FPR16RegClass;
9753 Opc = AArch64::FMADDSrrr;
9754 RC = &AArch64::FPR32RegClass;
9758 Opc = AArch64::FMADDDrrr;
9759 RC = &AArch64::FPR64RegClass;
9764 Opc = AArch64::FMADDHrrr;
9765 RC = &AArch64::FPR16RegClass;
9769 Opc = AArch64::FMADDSrrr;
9770 RC = &AArch64::FPR32RegClass;
9774 Opc = AArch64::FMADDDrrr;
9775 RC = &AArch64::FPR64RegClass;
9780 Opc = AArch64::FMLAv1i32_indexed;
9781 RC = &AArch64::FPR32RegClass;
9786 Opc = AArch64::FMLAv1i32_indexed;
9787 RC = &AArch64::FPR32RegClass;
9793 Opc = AArch64::FMLAv1i64_indexed;
9794 RC = &AArch64::FPR64RegClass;
9799 Opc = AArch64::FMLAv1i64_indexed;
9800 RC = &AArch64::FPR64RegClass;
9806 RC = &AArch64::FPR64RegClass;
9807 Opc = AArch64::FMLAv4i16_indexed;
9812 RC = &AArch64::FPR64RegClass;
9813 Opc = AArch64::FMLAv4f16;
9818 RC = &AArch64::FPR64RegClass;
9819 Opc = AArch64::FMLAv4i16_indexed;
9824 RC = &AArch64::FPR64RegClass;
9825 Opc = AArch64::FMLAv4f16;
9832 RC = &AArch64::FPR64RegClass;
9834 Opc = AArch64::FMLAv2i32_indexed;
9838 Opc = AArch64::FMLAv2f32;
9845 RC = &AArch64::FPR64RegClass;
9847 Opc = AArch64::FMLAv2i32_indexed;
9851 Opc = AArch64::FMLAv2f32;
9858 RC = &AArch64::FPR128RegClass;
9859 Opc = AArch64::FMLAv8i16_indexed;
9864 RC = &AArch64::FPR128RegClass;
9865 Opc = AArch64::FMLAv8f16;
9870 RC = &AArch64::FPR128RegClass;
9871 Opc = AArch64::FMLAv8i16_indexed;
9876 RC = &AArch64::FPR128RegClass;
9877 Opc = AArch64::FMLAv8f16;
9884 RC = &AArch64::FPR128RegClass;
9886 Opc = AArch64::FMLAv2i64_indexed;
9890 Opc = AArch64::FMLAv2f64;
9897 RC = &AArch64::FPR128RegClass;
9899 Opc = AArch64::FMLAv2i64_indexed;
9903 Opc = AArch64::FMLAv2f64;
9911 RC = &AArch64::FPR128RegClass;
9913 Opc = AArch64::FMLAv4i32_indexed;
9917 Opc = AArch64::FMLAv4f32;
9925 RC = &AArch64::FPR128RegClass;
9927 Opc = AArch64::FMLAv4i32_indexed;
9931 Opc = AArch64::FMLAv4f32;
9938 Opc = AArch64::FNMSUBHrrr;
9939 RC = &AArch64::FPR16RegClass;
9943 Opc = AArch64::FNMSUBSrrr;
9944 RC = &AArch64::FPR32RegClass;
9948 Opc = AArch64::FNMSUBDrrr;
9949 RC = &AArch64::FPR64RegClass;
9954 Opc = AArch64::FNMADDHrrr;
9955 RC = &AArch64::FPR16RegClass;
9959 Opc = AArch64::FNMADDSrrr;
9960 RC = &AArch64::FPR32RegClass;
9964 Opc = AArch64::FNMADDDrrr;
9965 RC = &AArch64::FPR64RegClass;
9970 Opc = AArch64::FMSUBHrrr;
9971 RC = &AArch64::FPR16RegClass;
9975 Opc = AArch64::FMSUBSrrr;
9976 RC = &AArch64::FPR32RegClass;
9980 Opc = AArch64::FMSUBDrrr;
9981 RC = &AArch64::FPR64RegClass;
9986 Opc = AArch64::FMLSv1i32_indexed;
9987 RC = &AArch64::FPR32RegClass;
9993 Opc = AArch64::FMLSv1i64_indexed;
9994 RC = &AArch64::FPR64RegClass;
10001 RC = &AArch64::FPR64RegClass;
10003 MachineInstrBuilder MIB1 =
10004 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
10007 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10009 Opc = AArch64::FMLAv4f16;
10013 Opc = AArch64::FMLAv4i16_indexed;
10020 RC = &AArch64::FPR64RegClass;
10021 Opc = AArch64::FMLSv4f16;
10026 RC = &AArch64::FPR64RegClass;
10027 Opc = AArch64::FMLSv4i16_indexed;
10034 RC = &AArch64::FPR64RegClass;
10036 Opc = AArch64::FMLSv2i32_indexed;
10040 Opc = AArch64::FMLSv2f32;
10048 RC = &AArch64::FPR128RegClass;
10050 MachineInstrBuilder MIB1 =
10051 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
10054 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10056 Opc = AArch64::FMLAv8f16;
10060 Opc = AArch64::FMLAv8i16_indexed;
10067 RC = &AArch64::FPR128RegClass;
10068 Opc = AArch64::FMLSv8f16;
10073 RC = &AArch64::FPR128RegClass;
10074 Opc = AArch64::FMLSv8i16_indexed;
10081 RC = &AArch64::FPR128RegClass;
10083 Opc = AArch64::FMLSv2i64_indexed;
10087 Opc = AArch64::FMLSv2f64;
10095 RC = &AArch64::FPR128RegClass;
10097 Opc = AArch64::FMLSv4i32_indexed;
10101 Opc = AArch64::FMLSv4f32;
10108 RC = &AArch64::FPR64RegClass;
10110 MachineInstrBuilder MIB1 =
10111 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
10114 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10116 Opc = AArch64::FMLAv2i32_indexed;
10120 Opc = AArch64::FMLAv2f32;
10128 RC = &AArch64::FPR128RegClass;
10130 MachineInstrBuilder MIB1 =
10131 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
10134 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10136 Opc = AArch64::FMLAv4i32_indexed;
10140 Opc = AArch64::FMLAv4f32;
10148 RC = &AArch64::FPR128RegClass;
10150 MachineInstrBuilder MIB1 =
10151 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
10154 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10156 Opc = AArch64::FMLAv2i64_indexed;
10160 Opc = AArch64::FMLAv2f64;
10168 unsigned IdxDupOp =
10172 &AArch64::FPR128RegClass,
MRI);
10177 unsigned IdxDupOp =
10181 &AArch64::FPR128RegClass,
MRI);
10186 unsigned IdxDupOp =
10190 &AArch64::FPR128_loRegClass,
MRI);
10195 unsigned IdxDupOp =
10199 &AArch64::FPR128RegClass,
MRI);
10204 unsigned IdxDupOp =
10208 &AArch64::FPR128_loRegClass,
MRI);
10242 for (
auto *
MI : InsInstrs)
10243 MI->setFlags(Flags);
10284 bool IsNegativeBranch =
false;
10285 bool IsTestAndBranch =
false;
10286 unsigned TargetBBInMI = 0;
10287 switch (
MI.getOpcode()) {
10291 case AArch64::CBWPri:
10292 case AArch64::CBXPri:
10293 case AArch64::CBBAssertExt:
10294 case AArch64::CBHAssertExt:
10295 case AArch64::CBWPrr:
10296 case AArch64::CBXPrr:
10298 case AArch64::CBZW:
10299 case AArch64::CBZX:
10302 case AArch64::CBNZW:
10303 case AArch64::CBNZX:
10305 IsNegativeBranch =
true;
10307 case AArch64::TBZW:
10308 case AArch64::TBZX:
10310 IsTestAndBranch =
true;
10312 case AArch64::TBNZW:
10313 case AArch64::TBNZX:
10315 IsNegativeBranch =
true;
10316 IsTestAndBranch =
true;
10322 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10326 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10339 while (
DefMI->isCopy()) {
10343 if (!
MRI->hasOneNonDBGUse(CopyVReg))
10345 DefMI =
MRI->getVRegDef(CopyVReg);
10350 switch (
DefMI->getOpcode()) {
10354 case AArch64::ANDWri:
10355 case AArch64::ANDXri: {
10356 if (IsTestAndBranch)
10360 if (!
MRI->hasOneNonDBGUse(VReg))
10363 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10365 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10374 if (!
MRI->getVRegDef(NewReg))
10381 unsigned Opc = (
Imm < 32)
10382 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10383 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10396 if (!Is32Bit &&
Imm < 32)
10398 MI.eraseFromParent();
10402 case AArch64::CSINCWr:
10403 case AArch64::CSINCXr: {
10404 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10405 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10406 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10407 DefMI->getOperand(2).getReg() == AArch64::XZR))
10410 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10423 if (IsNegativeBranch)
10426 MI.eraseFromParent();
10432std::pair<unsigned, unsigned>
10433AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10435 return std::make_pair(TF & Mask, TF & ~Mask);
10439AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10442 static const std::pair<unsigned, const char *> TargetFlags[] = {
10443 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10444 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10445 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10451AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10452 using namespace AArch64II;
10454 static const std::pair<unsigned, const char *> TargetFlags[] = {
10456 {
MO_GOT,
"aarch64-got"},
10457 {
MO_NC,
"aarch64-nc"},
10458 {
MO_S,
"aarch64-s"},
10459 {
MO_TLS,
"aarch64-tls"},
10469AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10470 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10588 .outliner_compact_unwind_frame &&
10614 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10629 return C.isAvailableInsideSeq(AArch64::FP,
TRI);
10637 const AArch64RegisterInfo *ARI =
10638 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10641 for (
unsigned Reg : AArch64::GPR64RegClass) {
10643 Reg != AArch64::LR &&
10644 Reg != AArch64::X16 &&
10645 Reg != AArch64::X17 &&
10646 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10647 C.isAvailableInsideSeq(
Reg,
TRI))
10687 return !MFIa->branchProtectionPAuthLR() ||
10688 SubtargetA.hasPAuthLR() == SubtargetB.hasPAuthLR();
10697 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10701struct SPAddSubImmEncoding {
10711 if (
MI.getOpcode() != AArch64::ADDXri &&
MI.getOpcode() != AArch64::SUBXri)
10714 assert(
MI.getNumExplicitOperands() == 4 &&
"Wrong number of operands");
10715 assert(
MI.getOperand(0).isReg() &&
MI.getOperand(1).isReg() &&
10716 MI.getOperand(3).isImm() &&
"Unexpected add/sub immediate operands");
10718 if (
MI.getOperand(0).getReg() == AArch64::SP)
10720 if (
MI.getOperand(1).getReg() != AArch64::SP)
10723 return MI.getOperand(2).isImm();
10729static std::optional<SPAddSubImmEncoding>
10732 bool IsSub =
MI.getOpcode() == AArch64::SUBXri;
10736 int64_t ShiftImm =
MI.getOperand(3).getImm();
10738 "Unexpected add/sub immediate shift type");
10740 assert((Shift == 0 || Shift == 12) &&
"Unexpected add/sub immediate shift");
10742 int64_t
Offset =
MI.getOperand(2).getImm() << Shift;
10747 int64_t NewOffset =
Offset + Delta;
10748 int64_t AbsOffset = std::abs(NewOffset);
10750 SPAddSubImmEncoding Enc;
10751 Enc.Opcode = NewOffset < 0 ? AArch64::SUBXri : AArch64::ADDXri;
10754 if (AbsOffset <= 0xfff) {
10755 Enc.Imm = AbsOffset;
10757 }
else if ((AbsOffset & 0xfff) == 0 && (AbsOffset >> 12) <= 0xfff) {
10758 Enc.Imm = AbsOffset >> 12;
10761 return std::nullopt;
10767std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10768AArch64InstrInfo::getOutliningCandidateInfo(
10770 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10771 unsigned MinRepeats)
const {
10772 unsigned SequenceSize = 0;
10773 for (
auto &
MI : RepeatedSequenceLocs[0])
10776 unsigned NumBytesToCreateFrame = 0;
10782 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10783 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10784 if (LastMI.
getOpcode() == AArch64::ADRP &&
10787 return std::nullopt;
10792 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10793 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10796 return std::nullopt;
10807 if (std::adjacent_find(
10808 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10809 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10812 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10813 outliningCandidatesSigningKeyConsensus(a, b) &&
10814 outliningCandidatesV8_3OpsConsensus(a, b) &&
10815 outliningCandidatesPAuthLRConsensus(a, b)) {
10819 }) != RepeatedSequenceLocs.end()) {
10820 return std::nullopt;
10837 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10838 const auto RASignCondition = RepeatedSequenceLocs[0]
10841 ->getSignReturnAddressCondition();
10854 ->shouldHardenSignReturnAddress();
10857 if (RepeatedSequenceLocs.size() < MinRepeats)
10858 return std::nullopt;
10862 *RepeatedSequenceLocs[0].getMF());
10863 NumBytesToCheckLRInTCEpilogue =
10867 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10868 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10872 unsigned FlagsSetInAll = 0xF;
10876 FlagsSetInAll &=
C.Flags;
10878 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10881 auto SetCandidateCallInfo =
10882 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10884 C.setCallInfo(CallID, NumBytesForCall);
10888 NumBytesToCreateFrame += 4;
10896 unsigned CFICount = 0;
10897 for (
auto &
I : RepeatedSequenceLocs[0]) {
10898 if (
I.isCFIInstruction())
10908 std::vector<MCCFIInstruction> CFIInstructions =
10909 C.getMF()->getFrameInstructions();
10911 if (CFICount > 0 && CFICount != CFIInstructions.size())
10912 return std::nullopt;
10920 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10921 !
MI.readsRegister(AArch64::SP, &
TRI))
10927 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10932 if (
MI.mayLoadOrStore()) {
10935 bool OffsetIsScalable;
10939 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable) ||
10940 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10944 if (OffsetIsScalable)
10952 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10953 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10956 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10957 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10974 bool AllStackInstrsSafe =
10979 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10985 return MI.isCall() && !
MI.isReturn();
10987 return std::nullopt;
10990 NumBytesToCreateFrame = 0;
10991 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10995 else if (LastInstrOpcode == AArch64::BL ||
10996 ((LastInstrOpcode == AArch64::BLR ||
10997 LastInstrOpcode == AArch64::BLRNoIP) &&
11001 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
11009 unsigned NumBytesNoStackCalls = 0;
11010 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
11016 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
11025 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
11028 if (LRAvailable && !IsNoReturn) {
11029 NumBytesNoStackCalls += 4;
11031 CandidatesWithoutStackFixups.push_back(
C);
11036 else if (findRegisterToSaveLRTo(
C)) {
11037 NumBytesNoStackCalls += 12;
11039 CandidatesWithoutStackFixups.push_back(
C);
11044 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
11045 NumBytesNoStackCalls += 12;
11047 CandidatesWithoutStackFixups.push_back(
C);
11053 NumBytesNoStackCalls += SequenceSize;
11060 if (!AllStackInstrsSafe ||
11061 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
11062 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
11064 if (RepeatedSequenceLocs.size() < MinRepeats)
11065 return std::nullopt;
11118 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
11119 !findRegisterToSaveLRTo(
C));
11125 if (RepeatedSequenceLocs.size() < MinRepeats)
11126 return std::nullopt;
11131 bool ModStackToSaveLR =
false;
11138 ModStackToSaveLR =
true;
11147 ModStackToSaveLR =
true;
11149 if (ModStackToSaveLR) {
11151 if (!AllStackInstrsSafe)
11152 return std::nullopt;
11155 NumBytesToCreateFrame += 8;
11159 RepeatedSequenceLocs,
TRI))
11160 NumBytesToCreateFrame += 4;
11167 return std::nullopt;
11172 NumBytesToCreateFrame += 8;
11177 if (!
MI.isCall() &&
MI.modifiesRegister(AArch64::SP, &
TRI)) {
11178 switch (
MI.getOpcode()) {
11179 case AArch64::ADDXri:
11180 case AArch64::ADDWri:
11181 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
11182 assert(
MI.getOperand(2).isImm() &&
"Expected immediate");
11183 assert(
MI.getOperand(1).isReg() &&
"Expected register");
11184 if (
MI.getOperand(1).getReg() == AArch64::SP)
11185 SPValue +=
MI.getOperand(2).getImm();
11189 case AArch64::SUBXri:
11190 case AArch64::SUBWri:
11191 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
11192 assert(
MI.getOperand(2).isImm() &&
"Expected immediate");
11193 assert(
MI.getOperand(1).isReg() &&
"Expected register");
11194 if (
MI.getOperand(1).getReg() == AArch64::SP)
11195 SPValue -=
MI.getOperand(2).getImm();
11204 return SPValue != 0;
11207 if (hasIllegalSPModification(RepeatedSequenceLocs[0]))
11208 return std::nullopt;
11211 return std::make_unique<outliner::OutlinedFunction>(
11212 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
11215void AArch64InstrInfo::mergeOutliningCandidateAttributes(
11216 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
11220 const auto &CFn = Candidates.front().getMF()->getFunction();
11222 if (CFn.hasFnAttribute(
"ptrauth-returns"))
11223 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
11224 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
11225 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
11226 if (CFn.hasFnAttribute(
"branch-protection-pauth-lr"))
11227 F.addFnAttr(CFn.getFnAttribute(
"branch-protection-pauth-lr"));
11230 if (CFn.hasFnAttribute(
"sign-return-address"))
11231 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
11232 if (CFn.hasFnAttribute(
"sign-return-address-key"))
11233 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
11238 ->getInfo<AArch64FunctionInfo>()
11239 ->shouldHardenSignReturnAddress();
11242 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
11245bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
11248 OutlineFromLinkOnceODRs))
11254 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
11255 if (!AFI || AFI->
hasRedZone().value_or(
true))
11275 unsigned &Flags)
const {
11277 "Must track liveness!");
11279 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
11294 auto AreAllUnsafeRegsDead = [&LRU]() {
11295 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
11296 LRU.available(AArch64::NZCV);
11311 bool LRAvailableEverywhere =
true;
11313 LRU.addLiveOuts(
MBB);
11315 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
11316 if (
MI.isCall() && !
MI.isTerminator())
11322 auto CreateNewRangeStartingAt =
11323 [&RangeBegin, &RangeEnd,
11325 RangeBegin = NewBegin;
11326 RangeEnd = std::next(RangeBegin);
11329 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
11335 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
11337 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
11339 Ranges.emplace_back(RangeBegin, RangeEnd);
11347 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
11348 if (!FirstPossibleEndPt->isDebugInstr())
11349 LRU.stepBackward(*FirstPossibleEndPt);
11352 UpdateWholeMBBFlags(*FirstPossibleEndPt);
11353 if (AreAllUnsafeRegsDead())
11360 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
11368 LRU.stepBackward(
MI);
11369 UpdateWholeMBBFlags(
MI);
11370 if (!AreAllUnsafeRegsDead()) {
11371 SaveRangeIfNonEmpty();
11372 CreateNewRangeStartingAt(
MI.getIterator());
11375 LRAvailableEverywhere &= LRU.available(AArch64::LR);
11378 RangeBegin =
MI.getIterator();
11383 if (AreAllUnsafeRegsDead())
11384 SaveRangeIfNonEmpty();
11392 if (!LRAvailableEverywhere)
11400 unsigned Flags)
const {
11401 MachineInstr &
MI = *MIT;
11405 switch (
MI.getOpcode()) {
11406 case AArch64::PACM:
11407 case AArch64::PACIASP:
11408 case AArch64::PACIBSP:
11409 case AArch64::PACIASPPC:
11410 case AArch64::PACIBSPPC:
11411 case AArch64::PACNBIASPPC:
11412 case AArch64::PACNBIBSPPC:
11413 case AArch64::AUTIASP:
11414 case AArch64::AUTIBSP:
11415 case AArch64::AUTIASPPCi:
11416 case AArch64::AUTIASPPCr:
11417 case AArch64::AUTIBSPPCi:
11418 case AArch64::AUTIBSPPCr:
11419 case AArch64::RETAA:
11420 case AArch64::RETAB:
11421 case AArch64::RETAASPPCi:
11422 case AArch64::RETAASPPCr:
11423 case AArch64::RETABSPPCi:
11424 case AArch64::RETABSPPCr:
11425 case AArch64::EMITBKEY:
11426 case AArch64::PAUTH_PROLOGUE:
11427 case AArch64::PAUTH_EPILOGUE:
11428 case AArch64::PAUTH_EPILOGUE_ENTRY_SP:
11438 if (
MI.isCFIInstruction())
11442 if (
MI.isTerminator())
11448 for (
const MachineOperand &MOP :
MI.operands()) {
11451 assert(!MOP.isCFIIndex());
11454 if (MOP.isReg() && !MOP.isImplicit() &&
11455 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11462 if (
MI.getOpcode() == AArch64::ADRP)
11482 for (
const MachineOperand &MOP :
MI.operands()) {
11483 if (MOP.isGlobal()) {
11491 if (Callee &&
Callee->getName() ==
"\01_mcount")
11499 if (
MI.getOpcode() == AArch64::BLR ||
11500 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11504 return UnknownCallOutlineType;
11512 return UnknownCallOutlineType;
11520 return UnknownCallOutlineType;
11541 for (MachineInstr &
MI :
MBB) {
11542 const MachineOperand *
Base;
11543 TypeSize Width(0,
false);
11545 bool OffsetIsScalable;
11548 if (
MI.mayLoadOrStore() &&
11551 Base->isReg() &&
Base->getReg() == AArch64::SP) {
11552 TypeSize Scale(0U,
false);
11553 int64_t Dummy1, Dummy2;
11555 MachineOperand &StackOffsetOperand =
11557 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11559 assert(Scale != 0 &&
"Unexpected opcode!");
11560 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11565 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11566 StackOffsetOperand.
setImm(NewImm);
11572 assert(Enc &&
"Unencodable SP add/sub should not have been outlined");
11573 MI.setDesc(
get(Enc->Opcode));
11574 MI.getOperand(2).setImm(Enc->Imm);
11575 MI.getOperand(3).setImm(Enc->Shift);
11582 bool ShouldSignReturnAddr) {
11583 if (!ShouldSignReturnAddr)
11588 if (!
MBB.isLiveIn(AArch64::LR))
11589 MBB.addLiveIn(AArch64::LR);
11596void AArch64InstrInfo::buildOutlinedFrame(
11600 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11608 unsigned TailOpcode;
11610 TailOpcode = AArch64::TCRETURNdi;
11614 TailOpcode = AArch64::TCRETURNriALL;
11625 bool IsLeafFunction =
true;
11628 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11629 return MI.isCall() && !
MI.isReturn();
11639 "Can only fix up stack references once");
11640 fixupPostOutline(
MBB);
11642 IsLeafFunction =
false;
11653 Et = std::prev(
MBB.
end());
11684 CFIBuilder.buildDefCFA(AArch64::FP, 16);
11685 CFIBuilder.buildOffset(AArch64::LR, -8);
11686 CFIBuilder.buildOffset(AArch64::FP, -16);
11705 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11709 CFIBuilder.buildDefCFAOffset(16);
11713 CFIBuilder.buildOffset(AArch64::LR, -16);
11728 RASignCondition, !IsLeafFunction);
11757 fixupPostOutline(
MBB);
11768 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11778 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11787 MachineInstr *Save;
11788 MachineInstr *Restore;
11794 assert(
Reg &&
"No callee-saved register available?");
11828 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11836bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11844 bool AllowSideEffects)
const {
11846 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11849 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11862 assert(STI.hasFPARMv8() &&
"Expected FP to be available.");
11868std::optional<DestSourcePair>
11873 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11874 MI.getOperand(1).getReg() == AArch64::WZR &&
11875 MI.getOperand(3).getImm() == 0x0) ||
11876 (
MI.getOpcode() == AArch64::ORRWrr &&
11877 MI.getOperand(1).getReg() == AArch64::WZR)) {
11879 if ((
MI.getOperand(0).getReg().isPhysical() &&
11880 MI.findRegisterDefOperandIdx(
11883 (
MI.getOperand(0).getReg().isVirtual() &&
11884 !
MI.getOperand(0).getSubReg()))
11888 if (
MI.getOpcode() == AArch64::ORRXrs &&
11889 MI.getOperand(1).getReg() == AArch64::XZR &&
11890 MI.getOperand(3).getImm() == 0x0)
11893 return std::nullopt;
11896std::optional<DestSourcePair>
11898 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11899 MI.getOperand(1).getReg() == AArch64::WZR &&
11900 MI.getOperand(3).getImm() == 0x0) ||
11901 (
MI.getOpcode() == AArch64::ORRWrr &&
11902 MI.getOperand(1).getReg() == AArch64::WZR))
11904 return std::nullopt;
11907std::optional<RegImmPair>
11916 return std::nullopt;
11918 switch (
MI.getOpcode()) {
11920 return std::nullopt;
11921 case AArch64::SUBWri:
11922 case AArch64::SUBXri:
11923 case AArch64::SUBSWri:
11924 case AArch64::SUBSXri:
11927 case AArch64::ADDSWri:
11928 case AArch64::ADDSXri:
11929 case AArch64::ADDWri:
11930 case AArch64::ADDXri: {
11932 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11933 !
MI.getOperand(2).isImm())
11934 return std::nullopt;
11935 int Shift =
MI.getOperand(3).getImm();
11936 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11940 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11946static std::optional<ParamLoadedValue>
11950 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11952 return std::nullopt;
11954 Register DestReg = DestSrc->Destination->getReg();
11955 Register SrcReg = DestSrc->Source->getReg();
11958 return std::nullopt;
11963 if (DestReg == DescribedReg)
11967 if (
MI.getOpcode() == AArch64::ORRWrs &&
11968 TRI->isSuperRegister(DestReg, DescribedReg))
11972 if (
MI.getOpcode() == AArch64::ORRXrs &&
11973 TRI->isSubRegister(DestReg, DescribedReg)) {
11974 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11978 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11979 "Unhandled ORR[XW]rs copy case");
11981 return std::nullopt;
11984bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11989 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11995bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11999 auto isAsmGoto = [](
const MachineInstr &
MI) {
12000 return MI.getOpcode() == AArch64::INLINEASM_BR;
12010 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
12017 for (
const MachineInstr &
MI :
MBB) {
12018 switch (
MI.getOpcode()) {
12019 case TargetOpcode::G_BRJT:
12020 case AArch64::JumpTableDest32:
12021 case AArch64::JumpTableDest16:
12022 case AArch64::JumpTableDest8:
12033std::optional<ParamLoadedValue>
12038 switch (
MI.getOpcode()) {
12039 case AArch64::MOVZWi:
12040 case AArch64::MOVZXi: {
12043 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
12044 return std::nullopt;
12046 if (!
MI.getOperand(1).isImm())
12047 return std::nullopt;
12048 int64_t Immediate =
MI.getOperand(1).getImm();
12049 int Shift =
MI.getOperand(2).getImm();
12053 case AArch64::ORRWrs:
12054 case AArch64::ORRXrs:
12061bool AArch64InstrInfo::isExtendLikelyToBeFolded(
12064 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
12065 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
12068 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
12078 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
12081uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
12085bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
12089bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
12094AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
12098bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
12099 unsigned Scale)
const {
12110 unsigned Shift =
Log2_64(NumBytes);
12111 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
12119 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
12124 return AArch64::BLRNoIP;
12126 return AArch64::BLR;
12153 Register TargetReg,
bool FrameSetup)
const {
12154 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
12166 MF.
insert(MBBInsertPoint, LoopTestMBB);
12169 MF.
insert(MBBInsertPoint, LoopBodyMBB);
12171 MF.
insert(MBBInsertPoint, ExitMBB);
12181 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
12189 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
12195 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
12212 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
12231 MBB.addSuccessor(LoopTestMBB);
12237 return ExitMBB->
begin();
12243 const TargetInstrInfo *
TII;
12244 MachineRegisterInfo &
MRI;
12247 MachineBasicBlock *LoopBB;
12249 MachineInstr *CondBranch;
12251 MachineInstr *Comp;
12253 unsigned CompCounterOprNum;
12255 MachineInstr *Update;
12257 unsigned UpdateCounterOprNum;
12261 bool IsUpdatePriorComp;
12264 SmallVector<MachineOperand, 4>
Cond;
12267 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
12268 MachineInstr *Comp,
unsigned CompCounterOprNum,
12269 MachineInstr *Update,
unsigned UpdateCounterOprNum,
12270 Register Init,
bool IsUpdatePriorComp,
12271 const SmallVectorImpl<MachineOperand> &
Cond)
12273 TII(MF->getSubtarget().getInstrInfo()),
MRI(MF->getRegInfo()),
12274 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
12275 CompCounterOprNum(CompCounterOprNum), Update(Update),
12276 UpdateCounterOprNum(UpdateCounterOprNum),
Init(
Init),
12279 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
12285 std::optional<bool> createTripCountGreaterCondition(
12286 int TC, MachineBasicBlock &
MBB,
12287 SmallVectorImpl<MachineOperand> &CondParam)
override {
12295 void createRemainingIterationsGreaterCondition(
12296 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
12297 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
12299 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
12301 void adjustTripCount(
int TripCountAdjust)
override {}
12303 bool isMVEExpanderSupported()
override {
return true; }
12319 Result =
MRI.createVirtualRegister(
12322 }
else if (
I == ReplaceOprNum) {
12323 MRI.constrainRegClass(ReplaceReg,
TII->getRegClass(NewMI->
getDesc(),
I));
12327 MBB.insert(InsertTo, NewMI);
12331void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
12347 assert(CondBranch->getOpcode() == AArch64::Bcc);
12351 if (CondBranch->getOperand(1).getMBB() == LoopBB)
12358 auto AccumulateCond = [&](
Register CurCond,
12369 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
12373 for (
int I = 0;
I <= TC; ++
I) {
12379 AccCond = AccumulateCond(AccCond,
CC);
12383 if (Update != Comp && IsUpdatePriorComp) {
12385 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12386 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
12390 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
12392 }
else if (Update != Comp) {
12397 Counter = NextCounter;
12401 if (LastStage0Insts.
empty()) {
12405 if (IsUpdatePriorComp)
12410 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12413 for (
int I = 0;
I <= TC; ++
I) {
12417 AccCond = AccumulateCond(AccCond,
CC);
12418 if (
I != TC && Update != Comp)
12421 Counter = NextCounter;
12437 assert(Phi.getNumOperands() == 5);
12438 if (Phi.getOperand(2).getMBB() ==
MBB) {
12439 RegMBB = Phi.getOperand(1).getReg();
12440 RegOther = Phi.getOperand(3).getReg();
12442 assert(Phi.getOperand(4).getMBB() ==
MBB);
12443 RegMBB = Phi.getOperand(3).getReg();
12444 RegOther = Phi.getOperand(1).getReg();
12449 if (!
Reg.isVirtual())
12452 return MRI.getDefBlock(
Reg) != BB;
12458 unsigned &UpdateCounterOprNum,
Register &InitReg,
12459 bool &IsUpdatePriorComp) {
12473 if (!
Reg.isVirtual())
12476 UpdateInst =
nullptr;
12477 UpdateCounterOprNum = 0;
12479 IsUpdatePriorComp =
true;
12483 if (Def->getParent() != LoopBB)
12485 if (Def->isCopy()) {
12487 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
12489 CurReg = Def->getOperand(1).getReg();
12490 }
else if (Def->isPHI()) {
12494 IsUpdatePriorComp =
false;
12499 switch (Def->getOpcode()) {
12500 case AArch64::ADDSXri:
12501 case AArch64::ADDSWri:
12502 case AArch64::SUBSXri:
12503 case AArch64::SUBSWri:
12504 case AArch64::ADDXri:
12505 case AArch64::ADDWri:
12506 case AArch64::SUBXri:
12507 case AArch64::SUBWri:
12509 UpdateCounterOprNum = 1;
12511 case AArch64::ADDSXrr:
12512 case AArch64::ADDSWrr:
12513 case AArch64::SUBSXrr:
12514 case AArch64::SUBSWrr:
12515 case AArch64::ADDXrr:
12516 case AArch64::ADDWrr:
12517 case AArch64::SUBXrr:
12518 case AArch64::SUBWrr:
12521 UpdateCounterOprNum = 1;
12523 UpdateCounterOprNum = 2;
12530 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12545std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12556 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12567 if (
TBB == LoopBB && FBB == LoopBB)
12571 if (
TBB != LoopBB && FBB ==
nullptr)
12574 assert((
TBB == LoopBB || FBB == LoopBB) &&
12575 "The Loop must be a single-basic-block loop");
12580 if (CondBranch->
getOpcode() != AArch64::Bcc)
12588 unsigned CompCounterOprNum = 0;
12590 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12594 switch (
MI.getOpcode()) {
12595 case AArch64::SUBSXri:
12596 case AArch64::SUBSWri:
12597 case AArch64::ADDSXri:
12598 case AArch64::ADDSWri:
12600 CompCounterOprNum = 1;
12602 case AArch64::ADDSWrr:
12603 case AArch64::ADDSXrr:
12604 case AArch64::SUBSWrr:
12605 case AArch64::SUBSXrr:
12609 if (isWhileOpcode(
MI.getOpcode())) {
12616 if (CompCounterOprNum == 0) {
12618 CompCounterOprNum = 2;
12620 CompCounterOprNum = 1;
12632 bool IsUpdatePriorComp;
12633 unsigned UpdateCounterOprNum;
12635 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12638 return std::make_unique<AArch64PipelinerLoopInfo>(
12639 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12649 TypeSize Scale(0U,
false), Width(0U,
false);
12650 int64_t MinOffset, MaxOffset;
12651 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12653 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12654 int64_t
Imm =
MI.getOperand(ImmIdx).getImm();
12656 ErrInfo =
"Unexpected immediate on load/store instruction";
12662 const MCInstrDesc &MCID =
MI.getDesc();
12664 const MachineOperand &MO =
MI.getOperand(
Op);
12668 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12677 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12683 ErrInfo =
"OPERAND_IMM_UINT1 should be 0 or 1";
12689 ErrInfo =
"OPERAND_IMM_UINT4plus1 should be in the range 1 to 16";
12695 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12701 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12712#define GET_INSTRINFO_HELPERS
12713#define GET_INSTRMAP_INFO
12714#include "AArch64GenInstrInfo.inc"
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
const AArch64Subtarget & Subtarget
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 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 void updateOperandRegClass(MachineInstr &Instr)
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 std::optional< SPAddSubImmEncoding > adjustSPAddSubImm(const MachineInstr &MI, int64_t Delta)
Adjust the signed byte offset of MI, which must satisfy isSPAddSubImm, by Delta and re-encode the res...
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 bool predictCompactUnwindFrameRecordForOutlinedFunction(std::vector< outliner::Candidate > &RepeatedSequenceLocs, const TargetRegisterInfo &TRI)
Predict what the above will answer, for use while costing candidates.
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 unsigned getBranchDisplacementBits(const AArch64Options &CLOpts, unsigned Opc)
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 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 genMaddShf(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, unsigned MaddOpc, bool Is64Bit, DenseMap< Register, unsigned > &InstrIdxForVirtReg)
MUL I=A,B,0 ADDrs R,I,C,shift ==> SBFM/UBFM J=C,shift MADD R,A,B,J.
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 shouldUseCompactUnwindFrameRecordForOutlinedFunction(const MachineBasicBlock &MBB)
Return true if the outlined function in MBB should save FP and LR as a frame record instead of saving...
static bool isSUBSRegImm(unsigned Opcode)
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 bool isCompactUnwindFrameRecordEnabled(const MachineFunction &MF)
Return true if the frame-record form of the outlined prologue is enabled for the target of MF.
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 bool outliningCandidatesPAuthLRConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
static bool isValidCBExtend(int64_t Opc, AArch64_AM::ShiftExtendType Ext)
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 isSPAddSubImm(const MachineInstr &MI)
Returns true if MI is an ADD/SUBXri with an immediate offset that reads SP but does not write SP (e....
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 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 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!")
const AArch64InstrInfo MachineBasicBlock::iterator InsertPt
const AArch64InstrInfo & TII
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
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
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.
SmallVector< MachineOperand, 4 > Cond
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
PowerPC Reduce CR logical Operation
MachineRegisterInfo & MRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
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
bool needsDwarfUnwindInfo(const MachineFunction &MF) 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 copyPhysRegImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const
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
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.
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
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) 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.
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, SelectExpansion &) const override
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI) const override
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
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, llvm::ArrayRef< unsigned > Indices) const
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
AArch64CC::CondCode insertCmpForCondBr(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, ArrayRef< MachineOperand > Cond) const
Inserts the compare instruction needed to un-fuse a fused conditional branch instruction and returns ...
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 getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
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.
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,...
AArch64PAuth::AuthCheckMethod getAuthenticatedLRCheckMethod(const MachineFunction &MF) const
Choose a method of checking LR before performing a tail call.
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.
A set of register units used to track register liveness.
bool available(MCRegister Reg) const
Returns true if no part of physical register Reg is live.
LLVM_ABI void accumulate(const MachineInstr &MI)
Adds all register units used, defined or clobbered in MI.
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...
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.
Wrapper class representing physical registers and target specific virtual registers.
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.
iterator insertAfter(iterator I, MachineInstr *MI)
Insert MI into the instruction list after I.
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.
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.
bool usesWindowsUnwindInfo() const
True if this function describes its unwind information with Windows SEH unwind opcodes (....
BasicBlockListType::iterator iterator
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
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 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.
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.
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...
use_instr_nodbg_iterator use_instr_nodbg_begin(Register RegNo) const
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 LLVM_READONLY 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.
const Triple & getTargetTriple() const
Get the target triple which is a string describing the target host.
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.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
unsigned getNumOperands() const
Return the number of values used by this operation.
const SDValue & getOperand(unsigned Num) const
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)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
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)
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 isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const
Return true if the function can safely be outlined from.
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.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
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.
@ ScalablePredicateVector
@ Init
Initialization function, sets up the coroutine frame.
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.
IterT next_nodbg(IterT It, IterT End, bool SkipPseudoOp=true)
Increment It, then continue incrementing it while it points to a debug instruction.
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.
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.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
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
@ End
Run the machine verifier once, at the end of the pipeline.
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.