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()) {
116 case AArch64::BLRAAZ:
118 case AArch64::BLRABZ:
122 case AArch64::AUTIASP:
123 case AArch64::AUTIBSP:
124 case AArch64::AUTIAZ:
125 case AArch64::AUTIBZ:
126 case AArch64::XPACLRI:
131 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
132 MI.getOperand(3).getImm() == 1)
140 bool ModifiesLR =
false;
141 bool ModifiesSP =
false;
145 if (MO.getReg() == AArch64::LR)
147 else if (MO.getReg() == AArch64::SP)
156 if (
MI.mayLoadOrStore()) {
164 if (ModifiesSP || ModifiesLR)
177 if (!
Desc.isPseudo() && !Subtarget.isLFI()) {
178 assert(
Desc.getSize() == 4 &&
"Unexpected instruction size");
188 auto Op =
MI.getOpcode();
189 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
190 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
194 if (
MI.isMetaInstruction())
199 unsigned NumBytes = 0;
208 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
211 if (!MFI->shouldSignReturnAddress(*MF))
214 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
222 switch (
Desc.getOpcode()) {
225 return Desc.getSize();
232 case TargetOpcode::STACKMAP:
235 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
237 case TargetOpcode::PATCHPOINT:
240 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
242 case TargetOpcode::STATEPOINT:
244 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
249 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
254 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
256 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
257 case TargetOpcode::PATCHABLE_TAIL_CALL:
258 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
262 case TargetOpcode::PATCHABLE_EVENT_CALL:
268 NumBytes =
MI.getOperand(1).getImm();
270 case AArch64::MOVaddr:
271 case AArch64::MOVaddrJT:
272 case AArch64::MOVaddrCP:
273 case AArch64::MOVaddrBA:
274 case AArch64::MOVaddrTLS:
275 case AArch64::MOVaddrEXT: {
279 MI.getOperand(1).getTargetFlags(),
280 Subtarget.isTargetMachO(), Insn);
281 NumBytes = Insn.
size() * 4;
285 case AArch64::MOVi32imm:
286 case AArch64::MOVi64imm: {
288 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
291 NumBytes = Insn.
size() * 4;
295 case TargetOpcode::BUNDLE:
296 NumBytes = getInstBundleSize(
MI);
332 case AArch64::CBWPri:
333 case AArch64::CBXPri:
334 case AArch64::CBWPrr:
335 case AArch64::CBXPrr:
343 case AArch64::CBBAssertExt:
344 case AArch64::CBHAssertExt:
363 return CLOpts.b_offset_bits;
368 return CLOpts.tbz_offset_bits;
373 return CLOpts.cbz_offset_bits;
375 return CLOpts.bcc_offset_bits;
376 case AArch64::CBWPri:
377 case AArch64::CBXPri:
378 case AArch64::CBBAssertExt:
379 case AArch64::CBHAssertExt:
380 case AArch64::CBWPrr:
381 case AArch64::CBXPrr:
382 return CLOpts.cb_offset_bits;
387 int64_t BrOffset)
const {
389 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
390 "over conditional branch expansion");
391 return isIntN(Bits, BrOffset / 4);
396 switch (
MI.getOpcode()) {
400 return MI.getOperand(0).getMBB();
405 return MI.getOperand(2).getMBB();
411 return MI.getOperand(1).getMBB();
412 case AArch64::CBWPri:
413 case AArch64::CBXPri:
414 case AArch64::CBBAssertExt:
415 case AArch64::CBHAssertExt:
416 case AArch64::CBWPrr:
417 case AArch64::CBXPrr:
418 return MI.getOperand(3).getMBB();
428 assert(RS &&
"RegScavenger required for long branching");
430 "new block should be inserted for expanding unconditional branch");
433 "restore block should be inserted for restoring clobbered registers");
440 "Branch offsets outside of the signed 33-bit range not supported");
451 RS->enterBasicBlockEnd(
MBB);
454 constexpr Register Reg = AArch64::X16;
455 if (!RS->isRegUsed(Reg)) {
456 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
467 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
469 buildIndirectBranch(Scavenged, NewDestBB);
470 RS->setRegUsed(Scavenged);
479 "Unable to insert indirect branch inside function that has red zone");
502 bool AllowModify)
const {
509 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
510 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
514 if (!isUnpredicatedTerminator(*
I))
521 unsigned LastOpc = LastInst->
getOpcode();
522 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
537 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
544 LastInst = SecondLastInst;
546 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
551 SecondLastInst = &*
I;
552 SecondLastOpc = SecondLastInst->
getOpcode();
563 LastInst = SecondLastInst;
565 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
567 "unreachable unconditional branches removed above");
576 SecondLastInst = &*
I;
577 SecondLastOpc = SecondLastInst->
getOpcode();
581 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
597 I->eraseFromParent();
606 I->eraseFromParent();
615 MachineBranchPredicate &MBP,
616 bool AllowModify)
const {
628 assert(MBP.TrueDest &&
"expected!");
629 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
631 MBP.ConditionDef =
nullptr;
632 MBP.SingleUseCondition =
false;
642 if (
I ==
MBB.begin())
658 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
659 MBP.ConditionDef = &
MI;
668 case AArch64::CBNZX: {
672 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
673 ? MachineBranchPredicate::PRED_NE
674 : MachineBranchPredicate::PRED_EQ;
675 Register CondReg = MBP.LHS.getReg();
684 case AArch64::TBNZX: {
705 Cond[1].setImm(AArch64::CBNZW);
708 Cond[1].setImm(AArch64::CBZW);
711 Cond[1].setImm(AArch64::CBNZX);
714 Cond[1].setImm(AArch64::CBZX);
717 Cond[1].setImm(AArch64::TBNZW);
720 Cond[1].setImm(AArch64::TBZW);
723 Cond[1].setImm(AArch64::TBNZX);
726 Cond[1].setImm(AArch64::TBZX);
730 case AArch64::CBWPri:
731 case AArch64::CBXPri:
732 case AArch64::CBBAssertExt:
733 case AArch64::CBHAssertExt:
734 case AArch64::CBWPrr:
735 case AArch64::CBXPrr: {
748 int *BytesRemoved)
const {
758 I->eraseFromParent();
762 if (
I ==
MBB.begin()) {
775 I->eraseFromParent();
782void AArch64InstrInfo::instantiateCondBranch(
807 if (
Cond.size() > 5) {
818 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
849 return Opc == AArch64::CBBAssertExt;
852 return Opc == AArch64::CBHAssertExt;
864 switch (
Cond.size()) {
939 unsigned SubsOpc, SubsDestReg;
945 case AArch64::CBWPri:
946 SubsOpc = AArch64::SUBSWri;
947 SubsDestReg = AArch64::WZR;
950 case AArch64::CBXPri:
951 SubsOpc = AArch64::SUBSXri;
952 SubsDestReg = AArch64::XZR;
955 case AArch64::CBWPrr:
956 SubsOpc = AArch64::SUBSWrr;
957 SubsDestReg = AArch64::WZR;
960 case AArch64::CBXPrr:
961 SubsOpc = AArch64::SUBSXrr;
962 SubsDestReg = AArch64::XZR;
996 "Unexpected compare-and-branch instruction for extend type");
997 switch (ExtendType) {
1001 ExtOpc = AArch64::SBFMWri;
1005 ExtOpc = AArch64::SBFMWri;
1009 ExtOpc = AArch64::ANDWri;
1013 ExtOpc = AArch64::ANDWri;
1022 if (ExtOpc != AArch64::ANDWri)
1024 MBBI.addImm(ExtBits);
1033 "Unexpected compare-and-branch instruction for extend type");
1054 unsigned Opc =
MI.getOpcode();
1061 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1062 MI.getOperand(0).getReg() == AArch64::XZR) {
1064 dbgs() <<
"Removing always taken branch: " <<
MI);
1067 for (
auto *S : Succs)
1069 MBB->removeSuccessor(S);
1071 while (
MBB->rbegin() != &
MI)
1072 MBB->rbegin()->eraseFromParent();
1073 MI.eraseFromParent();
1078 case AArch64::CBNZW:
1079 case AArch64::CBNZX:
1080 case AArch64::TBNZW:
1081 case AArch64::TBNZX:
1083 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1084 MI.getOperand(0).getReg() == AArch64::XZR) {
1086 dbgs() <<
"Removing never taken branch: " <<
MI);
1088 MI.getParent()->removeSuccessor(
Target);
1089 MI.eraseFromParent();
1104 VReg =
DefMI->getOperand(1).getReg();
1113 unsigned *NewReg =
nullptr) {
1118 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
1123 unsigned SrcReg = 0;
1124 switch (
DefMI->getOpcode()) {
1125 case AArch64::SUBREG_TO_REG:
1129 if (!
DefMI->getOperand(1).isReg())
1131 if (!
DefMI->getOperand(2).isImm() ||
1132 DefMI->getOperand(2).getImm() != AArch64::sub_32)
1135 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
1137 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1140 SrcReg = AArch64::XZR;
1141 Opc = AArch64::CSINCXr;
1144 case AArch64::MOVi32imm:
1145 case AArch64::MOVi64imm:
1146 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1148 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
1149 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1152 case AArch64::ADDSXri:
1153 case AArch64::ADDSWri:
1155 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1160 case AArch64::ADDXri:
1161 case AArch64::ADDWri:
1163 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
1164 DefMI->getOperand(3).getImm() != 0)
1166 SrcReg =
DefMI->getOperand(1).getReg();
1167 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1170 case AArch64::ORNXrr:
1171 case AArch64::ORNWrr: {
1174 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1176 SrcReg =
DefMI->getOperand(2).getReg();
1177 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
1181 case AArch64::SUBSXrr:
1182 case AArch64::SUBSWrr:
1184 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1189 case AArch64::SUBXrr:
1190 case AArch64::SUBWrr: {
1193 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1195 SrcReg =
DefMI->getOperand(2).getReg();
1196 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1202 assert(
Opc && SrcReg &&
"Missing parameters");
1213 SelectExpansion &Exp)
const {
1224 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1229 unsigned ExtraCondLat =
Cond.size() != 1;
1230 Exp.NumInsts = 1 + ExtraCondLat;
1232 Exp.ClobberedPhysRegs.push_back(AArch64::NZCV);
1236 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1237 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1239 Exp.CondCycles = 1 + ExtraCondLat;
1240 Exp.TrueCycles = Exp.FalseCycles = 1;
1244 Exp.FalseCycles = 0;
1250 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1251 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1252 Exp.CondCycles = 5 + ExtraCondLat;
1253 Exp.TrueCycles = Exp.FalseCycles = 2;
1259 if (AArch64::FPR128RegClass.hasSubClassEq(RC) &&
1260 Subtarget.isNeonAvailable() &&
1261 !
MBB.getParent()->getFunction().hasMinSize()) {
1262 Exp.CondCycles = 8 + ExtraCondLat;
1263 Exp.TrueCycles = Exp.FalseCycles = 2;
1264 Exp.NumInsts = 3 + ExtraCondLat;
1283 assert(Subtarget.isNeonAvailable() &&
"Expected NEON for a vector select");
1302 bool TryFold =
false;
1304 RC = &AArch64::GPR64RegClass;
1305 Opc = AArch64::CSELXr;
1308 RC = &AArch64::GPR32RegClass;
1309 Opc = AArch64::CSELWr;
1312 RC = &AArch64::FPR64RegClass;
1313 Opc = AArch64::FCSELDrrr;
1315 RC = &AArch64::FPR32RegClass;
1316 Opc = AArch64::FCSELSrrr;
1318 assert(RC &&
"Unsupported regclass");
1322 unsigned NewReg = 0;
1345 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1346 FalseReg == AArch64::XZR) &&
1347 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1364 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1369 return Is.
size() <= 2;
1374 assert(
MI.isCopy() &&
"Expected COPY instruction");
1380 if (
Reg.isVirtual())
1382 if (
Reg.isPhysical())
1383 return RI.getMinimalPhysRegClass(
Reg);
1388 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1391 return MI.isAsCheapAsAMove();
1397 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1398 if (isExynosCheapAsMove(
MI))
1400 return MI.isAsCheapAsAMove();
1403 switch (
MI.getOpcode()) {
1405 return MI.isAsCheapAsAMove();
1407 case TargetOpcode::COPY:
1410 case AArch64::ADDWrs:
1411 case AArch64::ADDXrs:
1412 case AArch64::SUBWrs:
1413 case AArch64::SUBXrs:
1414 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1419 case AArch64::MOVi32imm:
1421 case AArch64::MOVi64imm:
1426bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1427 switch (
MI.getOpcode()) {
1431 case AArch64::ADDWrs:
1432 case AArch64::ADDXrs:
1433 case AArch64::ADDSWrs:
1434 case AArch64::ADDSXrs: {
1435 unsigned Imm =
MI.getOperand(3).getImm();
1442 case AArch64::ADDWrx:
1443 case AArch64::ADDXrx:
1444 case AArch64::ADDXrx64:
1445 case AArch64::ADDSWrx:
1446 case AArch64::ADDSXrx:
1447 case AArch64::ADDSXrx64: {
1448 unsigned Imm =
MI.getOperand(3).getImm();
1460 case AArch64::SUBWrs:
1461 case AArch64::SUBSWrs: {
1462 unsigned Imm =
MI.getOperand(3).getImm();
1464 return ShiftVal == 0 ||
1468 case AArch64::SUBXrs:
1469 case AArch64::SUBSXrs: {
1470 unsigned Imm =
MI.getOperand(3).getImm();
1472 return ShiftVal == 0 ||
1476 case AArch64::SUBWrx:
1477 case AArch64::SUBXrx:
1478 case AArch64::SUBXrx64:
1479 case AArch64::SUBSWrx:
1480 case AArch64::SUBSXrx:
1481 case AArch64::SUBSXrx64: {
1482 unsigned Imm =
MI.getOperand(3).getImm();
1494 case AArch64::LDRBBroW:
1495 case AArch64::LDRBBroX:
1496 case AArch64::LDRBroW:
1497 case AArch64::LDRBroX:
1498 case AArch64::LDRDroW:
1499 case AArch64::LDRDroX:
1500 case AArch64::LDRHHroW:
1501 case AArch64::LDRHHroX:
1502 case AArch64::LDRHroW:
1503 case AArch64::LDRHroX:
1504 case AArch64::LDRQroW:
1505 case AArch64::LDRQroX:
1506 case AArch64::LDRSBWroW:
1507 case AArch64::LDRSBWroX:
1508 case AArch64::LDRSBXroW:
1509 case AArch64::LDRSBXroX:
1510 case AArch64::LDRSHWroW:
1511 case AArch64::LDRSHWroX:
1512 case AArch64::LDRSHXroW:
1513 case AArch64::LDRSHXroX:
1514 case AArch64::LDRSWroW:
1515 case AArch64::LDRSWroX:
1516 case AArch64::LDRSroW:
1517 case AArch64::LDRSroX:
1518 case AArch64::LDRWroW:
1519 case AArch64::LDRWroX:
1520 case AArch64::LDRXroW:
1521 case AArch64::LDRXroX:
1522 case AArch64::PRFMroW:
1523 case AArch64::PRFMroX:
1524 case AArch64::STRBBroW:
1525 case AArch64::STRBBroX:
1526 case AArch64::STRBroW:
1527 case AArch64::STRBroX:
1528 case AArch64::STRDroW:
1529 case AArch64::STRDroX:
1530 case AArch64::STRHHroW:
1531 case AArch64::STRHHroX:
1532 case AArch64::STRHroW:
1533 case AArch64::STRHroX:
1534 case AArch64::STRQroW:
1535 case AArch64::STRQroX:
1536 case AArch64::STRSroW:
1537 case AArch64::STRSroX:
1538 case AArch64::STRWroW:
1539 case AArch64::STRWroX:
1540 case AArch64::STRXroW:
1541 case AArch64::STRXroX: {
1542 unsigned IsSigned =
MI.getOperand(3).getImm();
1549 unsigned Opc =
MI.getOpcode();
1553 case AArch64::SEH_StackAlloc:
1554 case AArch64::SEH_SaveFPLR:
1555 case AArch64::SEH_SaveFPLR_X:
1556 case AArch64::SEH_SaveReg:
1557 case AArch64::SEH_SaveReg_X:
1558 case AArch64::SEH_SaveRegP:
1559 case AArch64::SEH_SaveRegP_X:
1560 case AArch64::SEH_SaveFReg:
1561 case AArch64::SEH_SaveFReg_X:
1562 case AArch64::SEH_SaveFRegP:
1563 case AArch64::SEH_SaveFRegP_X:
1564 case AArch64::SEH_SetFP:
1565 case AArch64::SEH_AddFP:
1566 case AArch64::SEH_Nop:
1567 case AArch64::SEH_PrologEnd:
1568 case AArch64::SEH_EpilogStart:
1569 case AArch64::SEH_EpilogEnd:
1570 case AArch64::SEH_PACSignLR:
1571 case AArch64::SEH_SaveAnyRegI:
1572 case AArch64::SEH_SaveAnyRegIP:
1573 case AArch64::SEH_SaveAnyRegQP:
1574 case AArch64::SEH_SaveAnyRegQPX:
1575 case AArch64::SEH_AllocZ:
1576 case AArch64::SEH_SaveZReg:
1577 case AArch64::SEH_SavePReg:
1584 unsigned &SubIdx)
const {
1585 switch (
MI.getOpcode()) {
1588 case AArch64::SBFMXri:
1589 case AArch64::UBFMXri:
1592 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1595 SrcReg =
MI.getOperand(1).getReg();
1596 DstReg =
MI.getOperand(0).getReg();
1597 SubIdx = AArch64::sub_32;
1605 int64_t OffsetA = 0, OffsetB = 0;
1606 TypeSize WidthA(0,
false), WidthB(0,
false);
1607 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1628 OffsetAIsScalable == OffsetBIsScalable) {
1629 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1630 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1631 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1632 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1650 switch (
MI.getOpcode()) {
1653 if (
MI.getOperand(0).getImm() == 0x14)
1660 case AArch64::MSRpstatesvcrImm1:
1667 auto Next = std::next(
MI.getIterator());
1668 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1675 Register &SrcReg2, int64_t &CmpMask,
1676 int64_t &CmpValue)
const {
1680 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1681 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1684 switch (
MI.getOpcode()) {
1687 case AArch64::PTEST_PP:
1688 case AArch64::PTEST_PP_ANY:
1689 case AArch64::PTEST_PP_FIRST:
1690 SrcReg =
MI.getOperand(0).getReg();
1691 SrcReg2 =
MI.getOperand(1).getReg();
1692 if (
MI.getOperand(2).getSubReg())
1699 case AArch64::SUBSWrr:
1700 case AArch64::SUBSWrs:
1701 case AArch64::SUBSWrx:
1702 case AArch64::SUBSXrr:
1703 case AArch64::SUBSXrs:
1704 case AArch64::SUBSXrx:
1705 case AArch64::ADDSWrr:
1706 case AArch64::ADDSWrs:
1707 case AArch64::ADDSWrx:
1708 case AArch64::ADDSXrr:
1709 case AArch64::ADDSXrs:
1710 case AArch64::ADDSXrx:
1712 SrcReg =
MI.getOperand(1).getReg();
1713 SrcReg2 =
MI.getOperand(2).getReg();
1716 if (
MI.getOperand(2).getSubReg())
1722 case AArch64::SUBSWri:
1723 case AArch64::ADDSWri:
1724 case AArch64::SUBSXri:
1725 case AArch64::ADDSXri:
1726 SrcReg =
MI.getOperand(1).getReg();
1729 CmpValue =
MI.getOperand(2).getImm();
1731 case AArch64::ANDSWri:
1732 case AArch64::ANDSXri:
1735 SrcReg =
MI.getOperand(1).getReg();
1739 MI.getOperand(2).getImm(),
1740 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1749 assert(
MBB &&
"Can't get MachineBasicBlock here");
1751 assert(MF &&
"Can't get MachineFunction here");
1756 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands(); OpIdx < EndIdx;
1760 Instr.getRegClassConstraint(OpIdx,
TII,
TRI);
1763 if (!OpRegCstraints)
1771 "Operand has register constraints without being a register!");
1774 if (
Reg.isPhysical()) {
1791 bool MIDefinesZeroReg =
false;
1792 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1793 MI.definesRegister(AArch64::XZR,
nullptr))
1794 MIDefinesZeroReg =
true;
1796 switch (
MI.getOpcode()) {
1798 return MI.getOpcode();
1799 case AArch64::ADDSWrr:
1800 return AArch64::ADDWrr;
1801 case AArch64::ADDSWri:
1802 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1803 case AArch64::ADDSWrs:
1804 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1805 case AArch64::ADDSWrx:
1806 return AArch64::ADDWrx;
1807 case AArch64::ADDSXrr:
1808 return AArch64::ADDXrr;
1809 case AArch64::ADDSXri:
1810 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1811 case AArch64::ADDSXrs:
1812 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1813 case AArch64::ADDSXrx:
1814 return AArch64::ADDXrx;
1815 case AArch64::SUBSWrr:
1816 return AArch64::SUBWrr;
1817 case AArch64::SUBSWri:
1818 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1819 case AArch64::SUBSWrs:
1820 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1821 case AArch64::SUBSWrx:
1822 return AArch64::SUBWrx;
1823 case AArch64::SUBSXrr:
1824 return AArch64::SUBXrr;
1825 case AArch64::SUBSXri:
1826 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1827 case AArch64::SUBSXrs:
1828 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1829 case AArch64::SUBSXrx:
1830 return AArch64::SUBXrx;
1845 if (To == To->getParent()->begin())
1850 if (To->getParent() != From->getParent())
1862 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1863 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1869std::optional<unsigned>
1873 unsigned MaskOpcode =
Mask->getOpcode();
1874 unsigned PredOpcode = Pred->
getOpcode();
1875 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1876 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1878 if (PredIsWhileLike) {
1882 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1889 getElementSizeForOpcode(MaskOpcode) ==
1890 getElementSizeForOpcode(PredOpcode))
1896 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1903 if (PredIsPTestLike) {
1908 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1916 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1917 PTestLikeMask->getOperand(1).getReg().isVirtual())
1925 getElementSizeForOpcode(MaskOpcode) ==
1926 getElementSizeForOpcode(PredOpcode)) {
1927 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1953 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1955 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1963 switch (PredOpcode) {
1964 case AArch64::AND_PPzPP:
1965 case AArch64::BIC_PPzPP:
1966 case AArch64::EOR_PPzPP:
1967 case AArch64::NAND_PPzPP:
1968 case AArch64::NOR_PPzPP:
1969 case AArch64::ORN_PPzPP:
1970 case AArch64::ORR_PPzPP:
1971 case AArch64::BRKA_PPzP:
1972 case AArch64::BRKPA_PPzPP:
1973 case AArch64::BRKB_PPzP:
1974 case AArch64::BRKPB_PPzPP:
1975 case AArch64::RDFFR_PPz: {
1979 if (Mask != PredMask)
1983 case AArch64::BRKN_PPzP: {
1987 if ((MaskOpcode != AArch64::PTRUE_B) ||
1988 (
Mask->getOperand(1).getImm() != 31))
1992 case AArch64::PTRUE_B:
2005bool AArch64InstrInfo::optimizePTestInstr(
2006 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
2011 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
2015 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
2016 Op.getSubReg() == AArch64::psub0)
2020 unsigned PredOpcode = Pred->
getOpcode();
2021 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
2037 if (*NewOp != PredOpcode) {
2048 for (; i !=
e; ++i) {
2079 if (DeadNZCVIdx != -1) {
2098 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2099 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2100 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2101 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2110 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2112 return (CmpValue == 0 || CmpValue == 1) &&
2113 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2121 switch (Instr.getOpcode()) {
2123 return AArch64::INSTRUCTION_LIST_END;
2125 case AArch64::ADDSWrr:
2126 case AArch64::ADDSWri:
2127 case AArch64::ADDSXrr:
2128 case AArch64::ADDSXri:
2129 case AArch64::ADDSWrx:
2130 case AArch64::ADDSXrx:
2131 case AArch64::ADDSWrs:
2132 case AArch64::ADDSXrs:
2133 case AArch64::SUBSWrr:
2134 case AArch64::SUBSWri:
2135 case AArch64::SUBSWrx:
2136 case AArch64::SUBSWrs:
2137 case AArch64::SUBSXrr:
2138 case AArch64::SUBSXri:
2139 case AArch64::SUBSXrx:
2140 case AArch64::SUBSXrs:
2141 case AArch64::ANDSWri:
2142 case AArch64::ANDSWrr:
2143 case AArch64::ANDSWrs:
2144 case AArch64::ANDSXri:
2145 case AArch64::ANDSXrr:
2146 case AArch64::ANDSXrs:
2147 case AArch64::BICSWrr:
2148 case AArch64::BICSXrr:
2149 case AArch64::BICSWrs:
2150 case AArch64::BICSXrs:
2151 case AArch64::ADCSWr:
2152 case AArch64::ADCSXr:
2153 case AArch64::SBCSWr:
2154 case AArch64::SBCSXr:
2155 return Instr.getOpcode();
2157 case AArch64::ADDWrr:
2158 return AArch64::ADDSWrr;
2159 case AArch64::ADDWri:
2160 return AArch64::ADDSWri;
2161 case AArch64::ADDXrr:
2162 return AArch64::ADDSXrr;
2163 case AArch64::ADDXri:
2164 return AArch64::ADDSXri;
2165 case AArch64::ADDWrx:
2166 return AArch64::ADDSWrx;
2167 case AArch64::ADDXrx:
2168 return AArch64::ADDSXrx;
2169 case AArch64::ADDWrs:
2170 return AArch64::ADDSWrs;
2171 case AArch64::ADDXrs:
2172 return AArch64::ADDSXrs;
2173 case AArch64::ADCWr:
2174 return AArch64::ADCSWr;
2175 case AArch64::ADCXr:
2176 return AArch64::ADCSXr;
2177 case AArch64::SUBWrr:
2178 return AArch64::SUBSWrr;
2179 case AArch64::SUBWri:
2180 return AArch64::SUBSWri;
2181 case AArch64::SUBXrr:
2182 return AArch64::SUBSXrr;
2183 case AArch64::SUBXri:
2184 return AArch64::SUBSXri;
2185 case AArch64::SUBWrx:
2186 return AArch64::SUBSWrx;
2187 case AArch64::SUBXrx:
2188 return AArch64::SUBSXrx;
2189 case AArch64::SUBWrs:
2190 return AArch64::SUBSWrs;
2191 case AArch64::SUBXrs:
2192 return AArch64::SUBSXrs;
2193 case AArch64::SBCWr:
2194 return AArch64::SBCSWr;
2195 case AArch64::SBCXr:
2196 return AArch64::SBCSXr;
2197 case AArch64::ANDWri:
2198 return AArch64::ANDSWri;
2199 case AArch64::ANDXri:
2200 return AArch64::ANDSXri;
2201 case AArch64::ANDWrr:
2202 return AArch64::ANDSWrr;
2203 case AArch64::ANDWrs:
2204 return AArch64::ANDSWrs;
2205 case AArch64::ANDXrr:
2206 return AArch64::ANDSXrr;
2207 case AArch64::ANDXrs:
2208 return AArch64::ANDSXrs;
2209 case AArch64::BICWrr:
2210 return AArch64::BICSWrr;
2211 case AArch64::BICXrr:
2212 return AArch64::BICSXrr;
2213 case AArch64::BICWrs:
2214 return AArch64::BICSWrs;
2215 case AArch64::BICXrs:
2216 return AArch64::BICSXrs;
2222 for (
auto *BB :
MBB->successors())
2223 if (BB->isLiveIn(AArch64::NZCV))
2230int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2232 switch (
Instr.getOpcode()) {
2236 case AArch64::Bcc: {
2237 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2242 case AArch64::CSINVWr:
2243 case AArch64::CSINVXr:
2244 case AArch64::CSINCWr:
2245 case AArch64::CSINCXr:
2246 case AArch64::CSELWr:
2247 case AArch64::CSELXr:
2248 case AArch64::CSNEGWr:
2249 case AArch64::CSNEGXr:
2250 case AArch64::FCSELSrrr:
2251 case AArch64::FCSELDrrr: {
2252 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2264 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2266 Instr.getOperand(CCIdx).
getImm())
2319std::optional<UsedNZCV>
2324 if (
MI.getParent() != CmpParent)
2325 return std::nullopt;
2328 return std::nullopt;
2333 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2336 return std::nullopt;
2341 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2344 return NZCVUsedAfterCmp;
2348 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2352 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2358 case AArch64::ANDSWri:
2359 case AArch64::ANDSWrr:
2360 case AArch64::ANDSWrs:
2361 case AArch64::ANDSXri:
2362 case AArch64::ANDSXrr:
2363 case AArch64::ANDSXrs:
2364 case AArch64::BICSWrr:
2365 case AArch64::BICSXrr:
2366 case AArch64::BICSWrs:
2367 case AArch64::BICSXrs:
2393 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2399 "Caller guarantees that CmpInstr compares with constant 0");
2402 if (!NZVCUsed || NZVCUsed->C)
2423bool AArch64InstrInfo::substituteCmpToZero(
2434 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2441 MI->setDesc(
get(NewOpc));
2446 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2458 assert((CmpValue == 0 || CmpValue == 1) &&
2459 "Only comparisons to 0 or 1 considered for removal!");
2462 unsigned MIOpc =
MI.getOpcode();
2463 if (MIOpc == AArch64::CSINCWr) {
2464 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2465 MI.getOperand(2).getReg() != AArch64::WZR)
2467 }
else if (MIOpc == AArch64::CSINCXr) {
2468 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2469 MI.getOperand(2).getReg() != AArch64::XZR)
2479 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2483 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2485 if (CmpValue && !IsSubsRegImm)
2487 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2492 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2495 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2499 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2502 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2503 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2506 if (MIUsedNZCV.
N && !CmpValue)
2548bool AArch64InstrInfo::removeCmpToZeroOrOne(
2555 SmallVector<MachineInstr *, 4> CCUseInstrs;
2556 bool IsInvertCC =
false;
2564 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2565 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2566 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2567 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2576bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2577 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2578 MI.getOpcode() != AArch64::CATCHRET &&
2579 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2584 auto TRI = Subtarget.getRegisterInfo();
2587 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2601 if (
MI.getOpcode() == AArch64::CATCHRET) {
2603 const TargetInstrInfo *
TII =
2605 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2610 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2612 FirstEpilogSEH = std::next(FirstEpilogSEH);
2627 if (
M.getStackProtectorGuard() ==
"sysreg") {
2628 const AArch64SysReg::SysReg *SrcReg =
2629 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2637 int Offset =
M.getStackProtectorGuardOffset();
2688 const GlobalValue *GV =
2691 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2694 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2695 Subtarget.isTargetILP32() ? 4 : 8);
2696 if (GuardWidth != 4 && GuardWidth != 8)
2701 if (GuardWidth == 4) {
2702 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2731 if (GuardWidth == 4) {
2732 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2749 if (GuardWidth == 4) {
2750 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2768 if (Subtarget.getTargetTriple().isOSMSVCRT())
2781 switch (
MI.getOpcode()) {
2784 case AArch64::MOVZWi:
2785 case AArch64::MOVZXi:
2786 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2787 assert(
MI.getDesc().getNumOperands() == 3 &&
2788 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2792 case AArch64::ANDWri:
2793 return MI.getOperand(1).getReg() == AArch64::WZR;
2794 case AArch64::ANDXri:
2795 return MI.getOperand(1).getReg() == AArch64::XZR;
2796 case TargetOpcode::COPY:
2797 return MI.getOperand(1).getReg() == AArch64::WZR;
2805 switch (
MI.getOpcode()) {
2808 case TargetOpcode::COPY: {
2811 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2812 AArch64::GPR64RegClass.
contains(DstReg));
2814 case AArch64::ORRXrs:
2815 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2816 assert(
MI.getDesc().getNumOperands() == 4 &&
2817 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2821 case AArch64::ADDXri:
2822 if (
MI.getOperand(2).getImm() == 0) {
2823 assert(
MI.getDesc().getNumOperands() == 4 &&
2824 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2835 switch (
MI.getOpcode()) {
2838 case TargetOpcode::COPY: {
2840 return AArch64::FPR128RegClass.contains(DstReg);
2842 case AArch64::ORRv16i8:
2843 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2844 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2845 "invalid ORRv16i8 operands");
2857 case AArch64::LDRWui:
2858 case AArch64::LDRXui:
2859 case AArch64::LDRBui:
2860 case AArch64::LDRHui:
2861 case AArch64::LDRSui:
2862 case AArch64::LDRDui:
2863 case AArch64::LDRQui:
2864 case AArch64::LDR_PXI:
2870 int &FrameIndex)
const {
2874 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2875 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2876 FrameIndex =
MI.getOperand(1).getIndex();
2877 return MI.getOperand(0).getReg();
2886 case AArch64::STRWui:
2887 case AArch64::STRXui:
2888 case AArch64::STRBui:
2889 case AArch64::STRHui:
2890 case AArch64::STRSui:
2891 case AArch64::STRDui:
2892 case AArch64::STRQui:
2893 case AArch64::STR_PXI:
2899 int &FrameIndex)
const {
2903 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2904 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2905 FrameIndex =
MI.getOperand(1).getIndex();
2906 return MI.getOperand(0).getReg();
2912 int &FrameIndex)
const {
2927 return MI.getOperand(0).getReg();
2933 int &FrameIndex)
const {
2948 return MI.getOperand(0).getReg();
2956 return MMO->getFlags() & MOSuppressPair;
2962 if (
MI.memoperands_empty())
2970 return MMO->getFlags() & MOStridedAccess;
2978 case AArch64::STURSi:
2979 case AArch64::STRSpre:
2980 case AArch64::STURDi:
2981 case AArch64::STRDpre:
2982 case AArch64::STURQi:
2983 case AArch64::STRQpre:
2984 case AArch64::STURBBi:
2985 case AArch64::STURHHi:
2986 case AArch64::STURWi:
2987 case AArch64::STRWpre:
2988 case AArch64::STURXi:
2989 case AArch64::STRXpre:
2990 case AArch64::LDURSi:
2991 case AArch64::LDRSpre:
2992 case AArch64::LDURDi:
2993 case AArch64::LDRDpre:
2994 case AArch64::LDURQi:
2995 case AArch64::LDRQpre:
2996 case AArch64::LDURWi:
2997 case AArch64::LDRWpre:
2998 case AArch64::LDURXi:
2999 case AArch64::LDRXpre:
3000 case AArch64::LDRSWpre:
3001 case AArch64::LDURSWi:
3002 case AArch64::LDURHHi:
3003 case AArch64::LDURBBi:
3004 case AArch64::LDURSBWi:
3005 case AArch64::LDURSHWi:
3013 case AArch64::PRFMui:
return AArch64::PRFUMi;
3014 case AArch64::LDRXui:
return AArch64::LDURXi;
3015 case AArch64::LDRWui:
return AArch64::LDURWi;
3016 case AArch64::LDRBui:
return AArch64::LDURBi;
3017 case AArch64::LDRHui:
return AArch64::LDURHi;
3018 case AArch64::LDRSui:
return AArch64::LDURSi;
3019 case AArch64::LDRDui:
return AArch64::LDURDi;
3020 case AArch64::LDRQui:
return AArch64::LDURQi;
3021 case AArch64::LDRBBui:
return AArch64::LDURBBi;
3022 case AArch64::LDRHHui:
return AArch64::LDURHHi;
3023 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
3024 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
3025 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
3026 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3027 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3028 case AArch64::STRXui:
return AArch64::STURXi;
3029 case AArch64::STRWui:
return AArch64::STURWi;
3030 case AArch64::STRBui:
return AArch64::STURBi;
3031 case AArch64::STRHui:
return AArch64::STURHi;
3032 case AArch64::STRSui:
return AArch64::STURSi;
3033 case AArch64::STRDui:
return AArch64::STURDi;
3034 case AArch64::STRQui:
return AArch64::STURQi;
3035 case AArch64::STRBBui:
return AArch64::STURBBi;
3036 case AArch64::STRHHui:
return AArch64::STURHHi;
3045 case AArch64::LDAPURBi:
3046 case AArch64::LDAPURHi:
3047 case AArch64::LDAPURi:
3048 case AArch64::LDAPURSBWi:
3049 case AArch64::LDAPURSBXi:
3050 case AArch64::LDAPURSHWi:
3051 case AArch64::LDAPURSHXi:
3052 case AArch64::LDAPURSWi:
3053 case AArch64::LDAPURXi:
3054 case AArch64::LDR_PPXI:
3055 case AArch64::LDR_PXI:
3056 case AArch64::LDR_ZXI:
3057 case AArch64::LDR_ZZXI:
3058 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3059 case AArch64::LDR_ZZZXI:
3060 case AArch64::LDR_ZZZZXI:
3061 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3062 case AArch64::LDRBBui:
3063 case AArch64::LDRBui:
3064 case AArch64::LDRDui:
3065 case AArch64::LDRHHui:
3066 case AArch64::LDRHui:
3067 case AArch64::LDRQui:
3068 case AArch64::LDRSBWui:
3069 case AArch64::LDRSBXui:
3070 case AArch64::LDRSHWui:
3071 case AArch64::LDRSHXui:
3072 case AArch64::LDRSui:
3073 case AArch64::LDRSWui:
3074 case AArch64::LDRWui:
3075 case AArch64::LDRXui:
3076 case AArch64::LDURBBi:
3077 case AArch64::LDURBi:
3078 case AArch64::LDURDi:
3079 case AArch64::LDURHHi:
3080 case AArch64::LDURHi:
3081 case AArch64::LDURQi:
3082 case AArch64::LDURSBWi:
3083 case AArch64::LDURSBXi:
3084 case AArch64::LDURSHWi:
3085 case AArch64::LDURSHXi:
3086 case AArch64::LDURSi:
3087 case AArch64::LDURSWi:
3088 case AArch64::LDURWi:
3089 case AArch64::LDURXi:
3090 case AArch64::PRFMui:
3091 case AArch64::PRFUMi:
3092 case AArch64::ST2Gi:
3094 case AArch64::STLURBi:
3095 case AArch64::STLURHi:
3096 case AArch64::STLURWi:
3097 case AArch64::STLURXi:
3098 case AArch64::StoreSwiftAsyncContext:
3099 case AArch64::STR_PPXI:
3100 case AArch64::STR_PXI:
3101 case AArch64::STR_ZXI:
3102 case AArch64::STR_ZZXI:
3103 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3104 case AArch64::STR_ZZZXI:
3105 case AArch64::STR_ZZZZXI:
3106 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3107 case AArch64::STRBBui:
3108 case AArch64::STRBui:
3109 case AArch64::STRDui:
3110 case AArch64::STRHHui:
3111 case AArch64::STRHui:
3112 case AArch64::STRQui:
3113 case AArch64::STRSui:
3114 case AArch64::STRWui:
3115 case AArch64::STRXui:
3116 case AArch64::STURBBi:
3117 case AArch64::STURBi:
3118 case AArch64::STURDi:
3119 case AArch64::STURHHi:
3120 case AArch64::STURHi:
3121 case AArch64::STURQi:
3122 case AArch64::STURSi:
3123 case AArch64::STURWi:
3124 case AArch64::STURXi:
3125 case AArch64::STZ2Gi:
3126 case AArch64::STZGi:
3127 case AArch64::TAGPstack:
3128 case AArch64::ATOMIC_STORE_HINT_Bi:
3129 case AArch64::ATOMIC_STORE_HINT_Hi:
3130 case AArch64::ATOMIC_STORE_HINT_Wi:
3131 case AArch64::ATOMIC_STORE_HINT_Si:
3132 case AArch64::ATOMIC_STORE_HINT_Xi:
3133 case AArch64::ATOMIC_STORE_HINT_Di:
3134 case AArch64::ATOMIC_STORE_HINT_Bui:
3135 case AArch64::ATOMIC_STORE_HINT_Hui:
3136 case AArch64::ATOMIC_STORE_HINT_Wui:
3137 case AArch64::ATOMIC_STORE_HINT_Sui:
3138 case AArch64::ATOMIC_STORE_HINT_Xui:
3139 case AArch64::ATOMIC_STORE_HINT_Dui:
3141 case AArch64::LD1B_D_IMM:
3142 case AArch64::LD1B_H_IMM:
3143 case AArch64::LD1B_IMM:
3144 case AArch64::LD1B_S_IMM:
3145 case AArch64::LD1D_IMM:
3146 case AArch64::LD1H_D_IMM:
3147 case AArch64::LD1H_IMM:
3148 case AArch64::LD1H_S_IMM:
3149 case AArch64::LD1RB_D_IMM:
3150 case AArch64::LD1RB_H_IMM:
3151 case AArch64::LD1RB_IMM:
3152 case AArch64::LD1RB_S_IMM:
3153 case AArch64::LD1RD_IMM:
3154 case AArch64::LD1RH_D_IMM:
3155 case AArch64::LD1RH_IMM:
3156 case AArch64::LD1RH_S_IMM:
3157 case AArch64::LD1RSB_D_IMM:
3158 case AArch64::LD1RSB_H_IMM:
3159 case AArch64::LD1RSB_S_IMM:
3160 case AArch64::LD1RSH_D_IMM:
3161 case AArch64::LD1RSH_S_IMM:
3162 case AArch64::LD1RSW_IMM:
3163 case AArch64::LD1RW_D_IMM:
3164 case AArch64::LD1RW_IMM:
3165 case AArch64::LD1SB_D_IMM:
3166 case AArch64::LD1SB_H_IMM:
3167 case AArch64::LD1SB_S_IMM:
3168 case AArch64::LD1SH_D_IMM:
3169 case AArch64::LD1SH_S_IMM:
3170 case AArch64::LD1SW_D_IMM:
3171 case AArch64::LD1W_D_IMM:
3172 case AArch64::LD1W_IMM:
3173 case AArch64::LD2B_IMM:
3174 case AArch64::LD2D_IMM:
3175 case AArch64::LD2H_IMM:
3176 case AArch64::LD2W_IMM:
3177 case AArch64::LD3B_IMM:
3178 case AArch64::LD3D_IMM:
3179 case AArch64::LD3H_IMM:
3180 case AArch64::LD3W_IMM:
3181 case AArch64::LD4B_IMM:
3182 case AArch64::LD4D_IMM:
3183 case AArch64::LD4H_IMM:
3184 case AArch64::LD4W_IMM:
3186 case AArch64::LDNF1B_D_IMM:
3187 case AArch64::LDNF1B_H_IMM:
3188 case AArch64::LDNF1B_IMM:
3189 case AArch64::LDNF1B_S_IMM:
3190 case AArch64::LDNF1D_IMM:
3191 case AArch64::LDNF1H_D_IMM:
3192 case AArch64::LDNF1H_IMM:
3193 case AArch64::LDNF1H_S_IMM:
3194 case AArch64::LDNF1SB_D_IMM:
3195 case AArch64::LDNF1SB_H_IMM:
3196 case AArch64::LDNF1SB_S_IMM:
3197 case AArch64::LDNF1SH_D_IMM:
3198 case AArch64::LDNF1SH_S_IMM:
3199 case AArch64::LDNF1SW_D_IMM:
3200 case AArch64::LDNF1W_D_IMM:
3201 case AArch64::LDNF1W_IMM:
3202 case AArch64::LDNPDi:
3203 case AArch64::LDNPQi:
3204 case AArch64::LDNPSi:
3205 case AArch64::LDNPWi:
3206 case AArch64::LDNPXi:
3207 case AArch64::LDNT1B_ZRI:
3208 case AArch64::LDNT1D_ZRI:
3209 case AArch64::LDNT1H_ZRI:
3210 case AArch64::LDNT1W_ZRI:
3211 case AArch64::LDPDi:
3212 case AArch64::LDPQi:
3213 case AArch64::LDPSi:
3214 case AArch64::LDPWi:
3215 case AArch64::LDPXi:
3216 case AArch64::LDRBBpost:
3217 case AArch64::LDRBBpre:
3218 case AArch64::LDRBpost:
3219 case AArch64::LDRBpre:
3220 case AArch64::LDRDpost:
3221 case AArch64::LDRDpre:
3222 case AArch64::LDRHHpost:
3223 case AArch64::LDRHHpre:
3224 case AArch64::LDRHpost:
3225 case AArch64::LDRHpre:
3226 case AArch64::LDRQpost:
3227 case AArch64::LDRQpre:
3228 case AArch64::LDRSpost:
3229 case AArch64::LDRSpre:
3230 case AArch64::LDRWpost:
3231 case AArch64::LDRWpre:
3232 case AArch64::LDRXpost:
3233 case AArch64::LDRXpre:
3234 case AArch64::ST1B_D_IMM:
3235 case AArch64::ST1B_H_IMM:
3236 case AArch64::ST1B_IMM:
3237 case AArch64::ST1B_S_IMM:
3238 case AArch64::ST1D_IMM:
3239 case AArch64::ST1H_D_IMM:
3240 case AArch64::ST1H_IMM:
3241 case AArch64::ST1H_S_IMM:
3242 case AArch64::ST1W_D_IMM:
3243 case AArch64::ST1W_IMM:
3244 case AArch64::ST2B_IMM:
3245 case AArch64::ST2D_IMM:
3246 case AArch64::ST2H_IMM:
3247 case AArch64::ST2W_IMM:
3248 case AArch64::ST3B_IMM:
3249 case AArch64::ST3D_IMM:
3250 case AArch64::ST3H_IMM:
3251 case AArch64::ST3W_IMM:
3252 case AArch64::ST4B_IMM:
3253 case AArch64::ST4D_IMM:
3254 case AArch64::ST4H_IMM:
3255 case AArch64::ST4W_IMM:
3256 case AArch64::STGPi:
3257 case AArch64::STGPreIndex:
3258 case AArch64::STZGPreIndex:
3259 case AArch64::ST2GPreIndex:
3260 case AArch64::STZ2GPreIndex:
3261 case AArch64::STGPostIndex:
3262 case AArch64::STZGPostIndex:
3263 case AArch64::ST2GPostIndex:
3264 case AArch64::STZ2GPostIndex:
3265 case AArch64::STNPDi:
3266 case AArch64::STNPQi:
3267 case AArch64::STNPSi:
3268 case AArch64::STNPWi:
3269 case AArch64::STNPXi:
3270 case AArch64::STNT1B_ZRI:
3271 case AArch64::STNT1D_ZRI:
3272 case AArch64::STNT1H_ZRI:
3273 case AArch64::STNT1W_ZRI:
3274 case AArch64::STPDi:
3275 case AArch64::STPQi:
3276 case AArch64::STPSi:
3277 case AArch64::STPWi:
3278 case AArch64::STPXi:
3279 case AArch64::STRBBpost:
3280 case AArch64::STRBBpre:
3281 case AArch64::STRBpost:
3282 case AArch64::STRBpre:
3283 case AArch64::STRDpost:
3284 case AArch64::STRDpre:
3285 case AArch64::STRHHpost:
3286 case AArch64::STRHHpre:
3287 case AArch64::STRHpost:
3288 case AArch64::STRHpre:
3289 case AArch64::STRQpost:
3290 case AArch64::STRQpre:
3291 case AArch64::STRSpost:
3292 case AArch64::STRSpre:
3293 case AArch64::STRWpost:
3294 case AArch64::STRWpre:
3295 case AArch64::STRXpost:
3296 case AArch64::STRXpre:
3297 case AArch64::LD1B_2Z_IMM:
3298 case AArch64::LD1B_2Z_STRIDED_IMM:
3299 case AArch64::LD1H_2Z_IMM:
3300 case AArch64::LD1H_2Z_STRIDED_IMM:
3301 case AArch64::LD1W_2Z_IMM:
3302 case AArch64::LD1W_2Z_STRIDED_IMM:
3303 case AArch64::LD1D_2Z_IMM:
3304 case AArch64::LD1D_2Z_STRIDED_IMM:
3305 case AArch64::LD1B_4Z_IMM:
3306 case AArch64::LD1B_4Z_STRIDED_IMM:
3307 case AArch64::LD1H_4Z_IMM:
3308 case AArch64::LD1H_4Z_STRIDED_IMM:
3309 case AArch64::LD1W_4Z_IMM:
3310 case AArch64::LD1W_4Z_STRIDED_IMM:
3311 case AArch64::LD1D_4Z_IMM:
3312 case AArch64::LD1D_4Z_STRIDED_IMM:
3313 case AArch64::LD1B_2Z_IMM_PSEUDO:
3314 case AArch64::LD1H_2Z_IMM_PSEUDO:
3315 case AArch64::LD1W_2Z_IMM_PSEUDO:
3316 case AArch64::LD1D_2Z_IMM_PSEUDO:
3317 case AArch64::LD1B_4Z_IMM_PSEUDO:
3318 case AArch64::LD1H_4Z_IMM_PSEUDO:
3319 case AArch64::LD1W_4Z_IMM_PSEUDO:
3320 case AArch64::LD1D_4Z_IMM_PSEUDO:
3321 case AArch64::ST1B_2Z_IMM:
3322 case AArch64::ST1B_2Z_STRIDED_IMM:
3323 case AArch64::ST1H_2Z_IMM:
3324 case AArch64::ST1H_2Z_STRIDED_IMM:
3325 case AArch64::ST1W_2Z_IMM:
3326 case AArch64::ST1W_2Z_STRIDED_IMM:
3327 case AArch64::ST1D_2Z_IMM:
3328 case AArch64::ST1D_2Z_STRIDED_IMM:
3329 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3330 case AArch64::LDNT1B_2Z_IMM:
3331 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3332 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3333 case AArch64::LDNT1H_2Z_IMM:
3334 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3335 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3336 case AArch64::LDNT1W_2Z_IMM:
3337 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3338 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3339 case AArch64::LDNT1D_2Z_IMM:
3340 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3341 case AArch64::STNT1B_2Z_IMM:
3342 case AArch64::STNT1B_2Z_STRIDED_IMM:
3343 case AArch64::STNT1H_2Z_IMM:
3344 case AArch64::STNT1H_2Z_STRIDED_IMM:
3345 case AArch64::STNT1W_2Z_IMM:
3346 case AArch64::STNT1W_2Z_STRIDED_IMM:
3347 case AArch64::STNT1D_2Z_IMM:
3348 case AArch64::STNT1D_2Z_STRIDED_IMM:
3349 case AArch64::ST1B_2Z_IMM_PSEUDO:
3350 case AArch64::ST1H_2Z_IMM_PSEUDO:
3351 case AArch64::ST1W_2Z_IMM_PSEUDO:
3352 case AArch64::ST1D_2Z_IMM_PSEUDO:
3353 case AArch64::STNT1B_2Z_IMM_PSEUDO:
3354 case AArch64::STNT1H_2Z_IMM_PSEUDO:
3355 case AArch64::STNT1W_2Z_IMM_PSEUDO:
3356 case AArch64::STNT1D_2Z_IMM_PSEUDO:
3357 case AArch64::ST1B_4Z_IMM:
3358 case AArch64::ST1B_4Z_STRIDED_IMM:
3359 case AArch64::ST1H_4Z_IMM:
3360 case AArch64::ST1H_4Z_STRIDED_IMM:
3361 case AArch64::ST1W_4Z_IMM:
3362 case AArch64::ST1W_4Z_STRIDED_IMM:
3363 case AArch64::ST1D_4Z_IMM:
3364 case AArch64::ST1D_4Z_STRIDED_IMM:
3365 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3366 case AArch64::LDNT1B_4Z_IMM:
3367 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3368 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3369 case AArch64::LDNT1H_4Z_IMM:
3370 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3371 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3372 case AArch64::LDNT1W_4Z_IMM:
3373 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3374 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3375 case AArch64::LDNT1D_4Z_IMM:
3376 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3377 case AArch64::STNT1B_4Z_IMM:
3378 case AArch64::STNT1B_4Z_STRIDED_IMM:
3379 case AArch64::STNT1H_4Z_IMM:
3380 case AArch64::STNT1H_4Z_STRIDED_IMM:
3381 case AArch64::STNT1W_4Z_IMM:
3382 case AArch64::STNT1W_4Z_STRIDED_IMM:
3383 case AArch64::STNT1D_4Z_IMM:
3384 case AArch64::STNT1D_4Z_STRIDED_IMM:
3385 case AArch64::ST1B_4Z_IMM_PSEUDO:
3386 case AArch64::ST1H_4Z_IMM_PSEUDO:
3387 case AArch64::ST1W_4Z_IMM_PSEUDO:
3388 case AArch64::ST1D_4Z_IMM_PSEUDO:
3389 case AArch64::STNT1B_4Z_IMM_PSEUDO:
3390 case AArch64::STNT1H_4Z_IMM_PSEUDO:
3391 case AArch64::STNT1W_4Z_IMM_PSEUDO:
3392 case AArch64::STNT1D_4Z_IMM_PSEUDO:
3394 case AArch64::LDPDpost:
3395 case AArch64::LDPDpre:
3396 case AArch64::LDPQpost:
3397 case AArch64::LDPQpre:
3398 case AArch64::LDPSpost:
3399 case AArch64::LDPSpre:
3400 case AArch64::LDPWpost:
3401 case AArch64::LDPWpre:
3402 case AArch64::LDPXpost:
3403 case AArch64::LDPXpre:
3404 case AArch64::STGPpre:
3405 case AArch64::STGPpost:
3406 case AArch64::STPDpost:
3407 case AArch64::STPDpre:
3408 case AArch64::STPQpost:
3409 case AArch64::STPQpre:
3410 case AArch64::STPSpost:
3411 case AArch64::STPSpre:
3412 case AArch64::STPWpost:
3413 case AArch64::STPWpre:
3414 case AArch64::STPXpost:
3415 case AArch64::STPXpre:
3421 switch (
MI.getOpcode()) {
3425 case AArch64::STRSui:
3426 case AArch64::STRDui:
3427 case AArch64::STRQui:
3428 case AArch64::STRXui:
3429 case AArch64::STRWui:
3430 case AArch64::LDRSui:
3431 case AArch64::LDRDui:
3432 case AArch64::LDRQui:
3433 case AArch64::LDRXui:
3434 case AArch64::LDRWui:
3435 case AArch64::LDRSWui:
3437 case AArch64::STURSi:
3438 case AArch64::STRSpre:
3439 case AArch64::STURDi:
3440 case AArch64::STRDpre:
3441 case AArch64::STURQi:
3442 case AArch64::STRQpre:
3443 case AArch64::STURWi:
3444 case AArch64::STRWpre:
3445 case AArch64::STURXi:
3446 case AArch64::STRXpre:
3447 case AArch64::LDURSi:
3448 case AArch64::LDRSpre:
3449 case AArch64::LDURDi:
3450 case AArch64::LDRDpre:
3451 case AArch64::LDURQi:
3452 case AArch64::LDRQpre:
3453 case AArch64::LDURWi:
3454 case AArch64::LDRWpre:
3455 case AArch64::LDURXi:
3456 case AArch64::LDRXpre:
3457 case AArch64::LDURSWi:
3458 case AArch64::LDRSWpre:
3460 case AArch64::LDR_ZXI:
3461 case AArch64::STR_ZXI:
3467 switch (
MI.getOpcode()) {
3470 "Unexpected instruction - was a new tail call opcode introduced?");
3472 case AArch64::TCRETURNdi:
3473 case AArch64::TCRETURNri:
3474 case AArch64::TCRETURNrix16x17:
3475 case AArch64::TCRETURNrix17:
3476 case AArch64::TCRETURNrinotx16:
3477 case AArch64::TCRETURNriALL:
3478 case AArch64::AUTH_TCRETURN:
3479 case AArch64::AUTH_TCRETURN_BTI:
3489 case AArch64::ADDWri:
3490 return AArch64::ADDSWri;
3491 case AArch64::ADDWrr:
3492 return AArch64::ADDSWrr;
3493 case AArch64::ADDWrs:
3494 return AArch64::ADDSWrs;
3495 case AArch64::ADDWrx:
3496 return AArch64::ADDSWrx;
3497 case AArch64::ANDWri:
3498 return AArch64::ANDSWri;
3499 case AArch64::ANDWrr:
3500 return AArch64::ANDSWrr;
3501 case AArch64::ANDWrs:
3502 return AArch64::ANDSWrs;
3503 case AArch64::BICWrr:
3504 return AArch64::BICSWrr;
3505 case AArch64::BICWrs:
3506 return AArch64::BICSWrs;
3507 case AArch64::SUBWri:
3508 return AArch64::SUBSWri;
3509 case AArch64::SUBWrr:
3510 return AArch64::SUBSWrr;
3511 case AArch64::SUBWrs:
3512 return AArch64::SUBSWrs;
3513 case AArch64::SUBWrx:
3514 return AArch64::SUBSWrx;
3516 case AArch64::ADDXri:
3517 return AArch64::ADDSXri;
3518 case AArch64::ADDXrr:
3519 return AArch64::ADDSXrr;
3520 case AArch64::ADDXrs:
3521 return AArch64::ADDSXrs;
3522 case AArch64::ADDXrx:
3523 return AArch64::ADDSXrx;
3524 case AArch64::ANDXri:
3525 return AArch64::ANDSXri;
3526 case AArch64::ANDXrr:
3527 return AArch64::ANDSXrr;
3528 case AArch64::ANDXrs:
3529 return AArch64::ANDSXrs;
3530 case AArch64::BICXrr:
3531 return AArch64::BICSXrr;
3532 case AArch64::BICXrs:
3533 return AArch64::BICSXrs;
3534 case AArch64::SUBXri:
3535 return AArch64::SUBSXri;
3536 case AArch64::SUBXrr:
3537 return AArch64::SUBSXrr;
3538 case AArch64::SUBXrs:
3539 return AArch64::SUBSXrs;
3540 case AArch64::SUBXrx:
3541 return AArch64::SUBSXrx;
3543 case AArch64::AND_PPzPP:
3544 return AArch64::ANDS_PPzPP;
3545 case AArch64::BIC_PPzPP:
3546 return AArch64::BICS_PPzPP;
3547 case AArch64::EOR_PPzPP:
3548 return AArch64::EORS_PPzPP;
3549 case AArch64::NAND_PPzPP:
3550 return AArch64::NANDS_PPzPP;
3551 case AArch64::NOR_PPzPP:
3552 return AArch64::NORS_PPzPP;
3553 case AArch64::ORN_PPzPP:
3554 return AArch64::ORNS_PPzPP;
3555 case AArch64::ORR_PPzPP:
3556 return AArch64::ORRS_PPzPP;
3557 case AArch64::BRKA_PPzP:
3558 return AArch64::BRKAS_PPzP;
3559 case AArch64::BRKPA_PPzPP:
3560 return AArch64::BRKPAS_PPzPP;
3561 case AArch64::BRKB_PPzP:
3562 return AArch64::BRKBS_PPzP;
3563 case AArch64::BRKPB_PPzPP:
3564 return AArch64::BRKPBS_PPzPP;
3565 case AArch64::BRKN_PPzP:
3566 return AArch64::BRKNS_PPzP;
3567 case AArch64::RDFFR_PPz:
3568 return AArch64::RDFFRS_PPz;
3569 case AArch64::PTRUE_B:
3570 return AArch64::PTRUES_B;
3581 if (
MI.hasOrderedMemoryRef())
3586 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3587 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3588 "Expected a reg or frame index operand.");
3592 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3594 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3607 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3608 Register BaseReg =
MI.getOperand(1).getReg();
3610 if (
MI.modifiesRegister(BaseReg,
TRI))
3616 switch (
MI.getOpcode()) {
3619 case AArch64::LDR_ZXI:
3620 case AArch64::STR_ZXI:
3621 if (!Subtarget.isLittleEndian() ||
3622 Subtarget.getSVEVectorSizeInBits() != 128)
3637 MI.getMF()->needsWinCFI())
3641 if (Subtarget.isPaired128Slow()) {
3642 switch (
MI.getOpcode()) {
3645 case AArch64::LDURQi:
3646 case AArch64::STURQi:
3647 case AArch64::LDRQui:
3648 case AArch64::STRQui:
3674std::optional<ExtAddrMode>
3678 bool OffsetIsScalable;
3679 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable))
3680 return std::nullopt;
3683 return std::nullopt;
3698 int64_t OffsetScale = 1;
3703 case AArch64::LDURQi:
3704 case AArch64::STURQi:
3708 case AArch64::LDURDi:
3709 case AArch64::STURDi:
3710 case AArch64::LDURXi:
3711 case AArch64::STURXi:
3715 case AArch64::LDURWi:
3716 case AArch64::LDURSWi:
3717 case AArch64::STURWi:
3721 case AArch64::LDURHi:
3722 case AArch64::STURHi:
3723 case AArch64::LDURHHi:
3724 case AArch64::STURHHi:
3725 case AArch64::LDURSHXi:
3726 case AArch64::LDURSHWi:
3730 case AArch64::LDRBroX:
3731 case AArch64::LDRBBroX:
3732 case AArch64::LDRSBXroX:
3733 case AArch64::LDRSBWroX:
3734 case AArch64::STRBroX:
3735 case AArch64::STRBBroX:
3736 case AArch64::LDURBi:
3737 case AArch64::LDURBBi:
3738 case AArch64::LDURSBXi:
3739 case AArch64::LDURSBWi:
3740 case AArch64::STURBi:
3741 case AArch64::STURBBi:
3742 case AArch64::LDRBui:
3743 case AArch64::LDRBBui:
3744 case AArch64::LDRSBXui:
3745 case AArch64::LDRSBWui:
3746 case AArch64::STRBui:
3747 case AArch64::STRBBui:
3751 case AArch64::LDRQroX:
3752 case AArch64::STRQroX:
3753 case AArch64::LDRQui:
3754 case AArch64::STRQui:
3759 case AArch64::LDRDroX:
3760 case AArch64::STRDroX:
3761 case AArch64::LDRXroX:
3762 case AArch64::STRXroX:
3763 case AArch64::LDRDui:
3764 case AArch64::STRDui:
3765 case AArch64::LDRXui:
3766 case AArch64::STRXui:
3771 case AArch64::LDRWroX:
3772 case AArch64::LDRSWroX:
3773 case AArch64::STRWroX:
3774 case AArch64::LDRWui:
3775 case AArch64::LDRSWui:
3776 case AArch64::STRWui:
3781 case AArch64::LDRHroX:
3782 case AArch64::STRHroX:
3783 case AArch64::LDRHHroX:
3784 case AArch64::STRHHroX:
3785 case AArch64::LDRSHXroX:
3786 case AArch64::LDRSHWroX:
3787 case AArch64::LDRHui:
3788 case AArch64::STRHui:
3789 case AArch64::LDRHHui:
3790 case AArch64::STRHHui:
3791 case AArch64::LDRSHXui:
3792 case AArch64::LDRSHWui:
3800 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3824 case AArch64::SBFMXri:
3837 AM.
Scale = OffsetScale;
3842 case TargetOpcode::SUBREG_TO_REG: {
3858 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3859 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3860 DefMI.getOperand(3).getImm() != 0)
3867 AM.
Scale = OffsetScale;
3878 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3879 int64_t NewOffset) ->
bool {
3880 int64_t MinOffset, MaxOffset;
3897 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3898 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3900 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3902 int64_t NewOffset = OldOffset + Disp;
3903 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3907 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3917 auto canFoldAddRegIntoAddrMode =
3922 if ((
unsigned)Scale != Scale)
3924 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3936 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3937 Subtarget.isSTRQroSlow();
3946 case AArch64::ADDXri:
3952 return canFoldAddSubImmIntoAddrMode(Disp);
3954 case AArch64::SUBXri:
3960 return canFoldAddSubImmIntoAddrMode(-Disp);
3962 case AArch64::ADDXrs: {
3975 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3977 if (avoidSlowSTRQ(MemI))
3980 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3983 case AArch64::ADDXrr:
3991 if (!OptSize && avoidSlowSTRQ(MemI))
3993 return canFoldAddRegIntoAddrMode(1);
3995 case AArch64::ADDXrx:
4003 if (!OptSize && avoidSlowSTRQ(MemI))
4012 return canFoldAddRegIntoAddrMode(
4027 case AArch64::LDURQi:
4028 case AArch64::LDRQui:
4029 return AArch64::LDRQroX;
4030 case AArch64::STURQi:
4031 case AArch64::STRQui:
4032 return AArch64::STRQroX;
4033 case AArch64::LDURDi:
4034 case AArch64::LDRDui:
4035 return AArch64::LDRDroX;
4036 case AArch64::STURDi:
4037 case AArch64::STRDui:
4038 return AArch64::STRDroX;
4039 case AArch64::LDURXi:
4040 case AArch64::LDRXui:
4041 return AArch64::LDRXroX;
4042 case AArch64::STURXi:
4043 case AArch64::STRXui:
4044 return AArch64::STRXroX;
4045 case AArch64::LDURWi:
4046 case AArch64::LDRWui:
4047 return AArch64::LDRWroX;
4048 case AArch64::LDURSWi:
4049 case AArch64::LDRSWui:
4050 return AArch64::LDRSWroX;
4051 case AArch64::STURWi:
4052 case AArch64::STRWui:
4053 return AArch64::STRWroX;
4054 case AArch64::LDURHi:
4055 case AArch64::LDRHui:
4056 return AArch64::LDRHroX;
4057 case AArch64::STURHi:
4058 case AArch64::STRHui:
4059 return AArch64::STRHroX;
4060 case AArch64::LDURHHi:
4061 case AArch64::LDRHHui:
4062 return AArch64::LDRHHroX;
4063 case AArch64::STURHHi:
4064 case AArch64::STRHHui:
4065 return AArch64::STRHHroX;
4066 case AArch64::LDURSHXi:
4067 case AArch64::LDRSHXui:
4068 return AArch64::LDRSHXroX;
4069 case AArch64::LDURSHWi:
4070 case AArch64::LDRSHWui:
4071 return AArch64::LDRSHWroX;
4072 case AArch64::LDURBi:
4073 case AArch64::LDRBui:
4074 return AArch64::LDRBroX;
4075 case AArch64::LDURBBi:
4076 case AArch64::LDRBBui:
4077 return AArch64::LDRBBroX;
4078 case AArch64::LDURSBXi:
4079 case AArch64::LDRSBXui:
4080 return AArch64::LDRSBXroX;
4081 case AArch64::LDURSBWi:
4082 case AArch64::LDRSBWui:
4083 return AArch64::LDRSBWroX;
4084 case AArch64::STURBi:
4085 case AArch64::STRBui:
4086 return AArch64::STRBroX;
4087 case AArch64::STURBBi:
4088 case AArch64::STRBBui:
4089 return AArch64::STRBBroX;
4101 case AArch64::LDURQi:
4103 return AArch64::LDRQui;
4104 case AArch64::STURQi:
4106 return AArch64::STRQui;
4107 case AArch64::LDURDi:
4109 return AArch64::LDRDui;
4110 case AArch64::STURDi:
4112 return AArch64::STRDui;
4113 case AArch64::LDURXi:
4115 return AArch64::LDRXui;
4116 case AArch64::STURXi:
4118 return AArch64::STRXui;
4119 case AArch64::LDURWi:
4121 return AArch64::LDRWui;
4122 case AArch64::LDURSWi:
4124 return AArch64::LDRSWui;
4125 case AArch64::STURWi:
4127 return AArch64::STRWui;
4128 case AArch64::LDURHi:
4130 return AArch64::LDRHui;
4131 case AArch64::STURHi:
4133 return AArch64::STRHui;
4134 case AArch64::LDURHHi:
4136 return AArch64::LDRHHui;
4137 case AArch64::STURHHi:
4139 return AArch64::STRHHui;
4140 case AArch64::LDURSHXi:
4142 return AArch64::LDRSHXui;
4143 case AArch64::LDURSHWi:
4145 return AArch64::LDRSHWui;
4146 case AArch64::LDURBi:
4148 return AArch64::LDRBui;
4149 case AArch64::LDURBBi:
4151 return AArch64::LDRBBui;
4152 case AArch64::LDURSBXi:
4154 return AArch64::LDRSBXui;
4155 case AArch64::LDURSBWi:
4157 return AArch64::LDRSBWui;
4158 case AArch64::STURBi:
4160 return AArch64::STRBui;
4161 case AArch64::STURBBi:
4163 return AArch64::STRBBui;
4164 case AArch64::LDRQui:
4165 case AArch64::STRQui:
4168 case AArch64::LDRDui:
4169 case AArch64::STRDui:
4170 case AArch64::LDRXui:
4171 case AArch64::STRXui:
4174 case AArch64::LDRWui:
4175 case AArch64::LDRSWui:
4176 case AArch64::STRWui:
4179 case AArch64::LDRHui:
4180 case AArch64::STRHui:
4181 case AArch64::LDRHHui:
4182 case AArch64::STRHHui:
4183 case AArch64::LDRSHXui:
4184 case AArch64::LDRSHWui:
4187 case AArch64::LDRBui:
4188 case AArch64::LDRBBui:
4189 case AArch64::LDRSBXui:
4190 case AArch64::LDRSBWui:
4191 case AArch64::STRBui:
4192 case AArch64::STRBBui:
4206 case AArch64::LDURQi:
4207 case AArch64::STURQi:
4208 case AArch64::LDURDi:
4209 case AArch64::STURDi:
4210 case AArch64::LDURXi:
4211 case AArch64::STURXi:
4212 case AArch64::LDURWi:
4213 case AArch64::LDURSWi:
4214 case AArch64::STURWi:
4215 case AArch64::LDURHi:
4216 case AArch64::STURHi:
4217 case AArch64::LDURHHi:
4218 case AArch64::STURHHi:
4219 case AArch64::LDURSHXi:
4220 case AArch64::LDURSHWi:
4221 case AArch64::LDURBi:
4222 case AArch64::STURBi:
4223 case AArch64::LDURBBi:
4224 case AArch64::STURBBi:
4225 case AArch64::LDURSBWi:
4226 case AArch64::LDURSBXi:
4228 case AArch64::LDRQui:
4229 return AArch64::LDURQi;
4230 case AArch64::STRQui:
4231 return AArch64::STURQi;
4232 case AArch64::LDRDui:
4233 return AArch64::LDURDi;
4234 case AArch64::STRDui:
4235 return AArch64::STURDi;
4236 case AArch64::LDRXui:
4237 return AArch64::LDURXi;
4238 case AArch64::STRXui:
4239 return AArch64::STURXi;
4240 case AArch64::LDRWui:
4241 return AArch64::LDURWi;
4242 case AArch64::LDRSWui:
4243 return AArch64::LDURSWi;
4244 case AArch64::STRWui:
4245 return AArch64::STURWi;
4246 case AArch64::LDRHui:
4247 return AArch64::LDURHi;
4248 case AArch64::STRHui:
4249 return AArch64::STURHi;
4250 case AArch64::LDRHHui:
4251 return AArch64::LDURHHi;
4252 case AArch64::STRHHui:
4253 return AArch64::STURHHi;
4254 case AArch64::LDRSHXui:
4255 return AArch64::LDURSHXi;
4256 case AArch64::LDRSHWui:
4257 return AArch64::LDURSHWi;
4258 case AArch64::LDRBBui:
4259 return AArch64::LDURBBi;
4260 case AArch64::LDRBui:
4261 return AArch64::LDURBi;
4262 case AArch64::STRBBui:
4263 return AArch64::STURBBi;
4264 case AArch64::STRBui:
4265 return AArch64::STURBi;
4266 case AArch64::LDRSBWui:
4267 return AArch64::LDURSBWi;
4268 case AArch64::LDRSBXui:
4269 return AArch64::LDURSBXi;
4282 case AArch64::LDRQroX:
4283 case AArch64::LDURQi:
4284 case AArch64::LDRQui:
4285 return AArch64::LDRQroW;
4286 case AArch64::STRQroX:
4287 case AArch64::STURQi:
4288 case AArch64::STRQui:
4289 return AArch64::STRQroW;
4290 case AArch64::LDRDroX:
4291 case AArch64::LDURDi:
4292 case AArch64::LDRDui:
4293 return AArch64::LDRDroW;
4294 case AArch64::STRDroX:
4295 case AArch64::STURDi:
4296 case AArch64::STRDui:
4297 return AArch64::STRDroW;
4298 case AArch64::LDRXroX:
4299 case AArch64::LDURXi:
4300 case AArch64::LDRXui:
4301 return AArch64::LDRXroW;
4302 case AArch64::STRXroX:
4303 case AArch64::STURXi:
4304 case AArch64::STRXui:
4305 return AArch64::STRXroW;
4306 case AArch64::LDRWroX:
4307 case AArch64::LDURWi:
4308 case AArch64::LDRWui:
4309 return AArch64::LDRWroW;
4310 case AArch64::LDRSWroX:
4311 case AArch64::LDURSWi:
4312 case AArch64::LDRSWui:
4313 return AArch64::LDRSWroW;
4314 case AArch64::STRWroX:
4315 case AArch64::STURWi:
4316 case AArch64::STRWui:
4317 return AArch64::STRWroW;
4318 case AArch64::LDRHroX:
4319 case AArch64::LDURHi:
4320 case AArch64::LDRHui:
4321 return AArch64::LDRHroW;
4322 case AArch64::STRHroX:
4323 case AArch64::STURHi:
4324 case AArch64::STRHui:
4325 return AArch64::STRHroW;
4326 case AArch64::LDRHHroX:
4327 case AArch64::LDURHHi:
4328 case AArch64::LDRHHui:
4329 return AArch64::LDRHHroW;
4330 case AArch64::STRHHroX:
4331 case AArch64::STURHHi:
4332 case AArch64::STRHHui:
4333 return AArch64::STRHHroW;
4334 case AArch64::LDRSHXroX:
4335 case AArch64::LDURSHXi:
4336 case AArch64::LDRSHXui:
4337 return AArch64::LDRSHXroW;
4338 case AArch64::LDRSHWroX:
4339 case AArch64::LDURSHWi:
4340 case AArch64::LDRSHWui:
4341 return AArch64::LDRSHWroW;
4342 case AArch64::LDRBroX:
4343 case AArch64::LDURBi:
4344 case AArch64::LDRBui:
4345 return AArch64::LDRBroW;
4346 case AArch64::LDRBBroX:
4347 case AArch64::LDURBBi:
4348 case AArch64::LDRBBui:
4349 return AArch64::LDRBBroW;
4350 case AArch64::LDRSBXroX:
4351 case AArch64::LDURSBXi:
4352 case AArch64::LDRSBXui:
4353 return AArch64::LDRSBXroW;
4354 case AArch64::LDRSBWroX:
4355 case AArch64::LDURSBWi:
4356 case AArch64::LDRSBWui:
4357 return AArch64::LDRSBWroW;
4358 case AArch64::STRBroX:
4359 case AArch64::STURBi:
4360 case AArch64::STRBui:
4361 return AArch64::STRBroW;
4362 case AArch64::STRBBroX:
4363 case AArch64::STURBBi:
4364 case AArch64::STRBBui:
4365 return AArch64::STRBBroW;
4390 return B.getInstr();
4394 "Addressing mode not supported for folding");
4411 return B.getInstr();
4418 "Address offset can be a register or an immediate, but not both");
4439 return B.getInstr();
4443 "Function must not be called with an addressing mode it can't handle");
4452 case AArch64::LD1Fourv16b_POST:
4453 case AArch64::LD1Fourv1d_POST:
4454 case AArch64::LD1Fourv2d_POST:
4455 case AArch64::LD1Fourv2s_POST:
4456 case AArch64::LD1Fourv4h_POST:
4457 case AArch64::LD1Fourv4s_POST:
4458 case AArch64::LD1Fourv8b_POST:
4459 case AArch64::LD1Fourv8h_POST:
4460 case AArch64::LD1Onev16b_POST:
4461 case AArch64::LD1Onev1d_POST:
4462 case AArch64::LD1Onev2d_POST:
4463 case AArch64::LD1Onev2s_POST:
4464 case AArch64::LD1Onev4h_POST:
4465 case AArch64::LD1Onev4s_POST:
4466 case AArch64::LD1Onev8b_POST:
4467 case AArch64::LD1Onev8h_POST:
4468 case AArch64::LD1Rv16b_POST:
4469 case AArch64::LD1Rv1d_POST:
4470 case AArch64::LD1Rv2d_POST:
4471 case AArch64::LD1Rv2s_POST:
4472 case AArch64::LD1Rv4h_POST:
4473 case AArch64::LD1Rv4s_POST:
4474 case AArch64::LD1Rv8b_POST:
4475 case AArch64::LD1Rv8h_POST:
4476 case AArch64::LD1Threev16b_POST:
4477 case AArch64::LD1Threev1d_POST:
4478 case AArch64::LD1Threev2d_POST:
4479 case AArch64::LD1Threev2s_POST:
4480 case AArch64::LD1Threev4h_POST:
4481 case AArch64::LD1Threev4s_POST:
4482 case AArch64::LD1Threev8b_POST:
4483 case AArch64::LD1Threev8h_POST:
4484 case AArch64::LD1Twov16b_POST:
4485 case AArch64::LD1Twov1d_POST:
4486 case AArch64::LD1Twov2d_POST:
4487 case AArch64::LD1Twov2s_POST:
4488 case AArch64::LD1Twov4h_POST:
4489 case AArch64::LD1Twov4s_POST:
4490 case AArch64::LD1Twov8b_POST:
4491 case AArch64::LD1Twov8h_POST:
4492 case AArch64::LD1i16_POST:
4493 case AArch64::LD1i32_POST:
4494 case AArch64::LD1i64_POST:
4495 case AArch64::LD1i8_POST:
4496 case AArch64::LD2Rv16b_POST:
4497 case AArch64::LD2Rv1d_POST:
4498 case AArch64::LD2Rv2d_POST:
4499 case AArch64::LD2Rv2s_POST:
4500 case AArch64::LD2Rv4h_POST:
4501 case AArch64::LD2Rv4s_POST:
4502 case AArch64::LD2Rv8b_POST:
4503 case AArch64::LD2Rv8h_POST:
4504 case AArch64::LD2Twov16b_POST:
4505 case AArch64::LD2Twov2d_POST:
4506 case AArch64::LD2Twov2s_POST:
4507 case AArch64::LD2Twov4h_POST:
4508 case AArch64::LD2Twov4s_POST:
4509 case AArch64::LD2Twov8b_POST:
4510 case AArch64::LD2Twov8h_POST:
4511 case AArch64::LD2i16_POST:
4512 case AArch64::LD2i32_POST:
4513 case AArch64::LD2i64_POST:
4514 case AArch64::LD2i8_POST:
4515 case AArch64::LD3Rv16b_POST:
4516 case AArch64::LD3Rv1d_POST:
4517 case AArch64::LD3Rv2d_POST:
4518 case AArch64::LD3Rv2s_POST:
4519 case AArch64::LD3Rv4h_POST:
4520 case AArch64::LD3Rv4s_POST:
4521 case AArch64::LD3Rv8b_POST:
4522 case AArch64::LD3Rv8h_POST:
4523 case AArch64::LD3Threev16b_POST:
4524 case AArch64::LD3Threev2d_POST:
4525 case AArch64::LD3Threev2s_POST:
4526 case AArch64::LD3Threev4h_POST:
4527 case AArch64::LD3Threev4s_POST:
4528 case AArch64::LD3Threev8b_POST:
4529 case AArch64::LD3Threev8h_POST:
4530 case AArch64::LD3i16_POST:
4531 case AArch64::LD3i32_POST:
4532 case AArch64::LD3i64_POST:
4533 case AArch64::LD3i8_POST:
4534 case AArch64::LD4Fourv16b_POST:
4535 case AArch64::LD4Fourv2d_POST:
4536 case AArch64::LD4Fourv2s_POST:
4537 case AArch64::LD4Fourv4h_POST:
4538 case AArch64::LD4Fourv4s_POST:
4539 case AArch64::LD4Fourv8b_POST:
4540 case AArch64::LD4Fourv8h_POST:
4541 case AArch64::LD4Rv16b_POST:
4542 case AArch64::LD4Rv1d_POST:
4543 case AArch64::LD4Rv2d_POST:
4544 case AArch64::LD4Rv2s_POST:
4545 case AArch64::LD4Rv4h_POST:
4546 case AArch64::LD4Rv4s_POST:
4547 case AArch64::LD4Rv8b_POST:
4548 case AArch64::LD4Rv8h_POST:
4549 case AArch64::LD4i16_POST:
4550 case AArch64::LD4i32_POST:
4551 case AArch64::LD4i64_POST:
4552 case AArch64::LD4i8_POST:
4553 case AArch64::LDAPRWpost:
4554 case AArch64::LDAPRXpost:
4555 case AArch64::LDIAPPWpost:
4556 case AArch64::LDIAPPXpost:
4557 case AArch64::LDPDpost:
4558 case AArch64::LDPQpost:
4559 case AArch64::LDPSWpost:
4560 case AArch64::LDPSpost:
4561 case AArch64::LDPWpost:
4562 case AArch64::LDPXpost:
4563 case AArch64::LDRBBpost:
4564 case AArch64::LDRBpost:
4565 case AArch64::LDRDpost:
4566 case AArch64::LDRHHpost:
4567 case AArch64::LDRHpost:
4568 case AArch64::LDRQpost:
4569 case AArch64::LDRSBWpost:
4570 case AArch64::LDRSBXpost:
4571 case AArch64::LDRSHWpost:
4572 case AArch64::LDRSHXpost:
4573 case AArch64::LDRSWpost:
4574 case AArch64::LDRSpost:
4575 case AArch64::LDRWpost:
4576 case AArch64::LDRXpost:
4577 case AArch64::ST1Fourv16b_POST:
4578 case AArch64::ST1Fourv1d_POST:
4579 case AArch64::ST1Fourv2d_POST:
4580 case AArch64::ST1Fourv2s_POST:
4581 case AArch64::ST1Fourv4h_POST:
4582 case AArch64::ST1Fourv4s_POST:
4583 case AArch64::ST1Fourv8b_POST:
4584 case AArch64::ST1Fourv8h_POST:
4585 case AArch64::ST1Onev16b_POST:
4586 case AArch64::ST1Onev1d_POST:
4587 case AArch64::ST1Onev2d_POST:
4588 case AArch64::ST1Onev2s_POST:
4589 case AArch64::ST1Onev4h_POST:
4590 case AArch64::ST1Onev4s_POST:
4591 case AArch64::ST1Onev8b_POST:
4592 case AArch64::ST1Onev8h_POST:
4593 case AArch64::ST1Threev16b_POST:
4594 case AArch64::ST1Threev1d_POST:
4595 case AArch64::ST1Threev2d_POST:
4596 case AArch64::ST1Threev2s_POST:
4597 case AArch64::ST1Threev4h_POST:
4598 case AArch64::ST1Threev4s_POST:
4599 case AArch64::ST1Threev8b_POST:
4600 case AArch64::ST1Threev8h_POST:
4601 case AArch64::ST1Twov16b_POST:
4602 case AArch64::ST1Twov1d_POST:
4603 case AArch64::ST1Twov2d_POST:
4604 case AArch64::ST1Twov2s_POST:
4605 case AArch64::ST1Twov4h_POST:
4606 case AArch64::ST1Twov4s_POST:
4607 case AArch64::ST1Twov8b_POST:
4608 case AArch64::ST1Twov8h_POST:
4609 case AArch64::ST1i16_POST:
4610 case AArch64::ST1i32_POST:
4611 case AArch64::ST1i64_POST:
4612 case AArch64::ST1i8_POST:
4613 case AArch64::ST2GPostIndex:
4614 case AArch64::ST2Twov16b_POST:
4615 case AArch64::ST2Twov2d_POST:
4616 case AArch64::ST2Twov2s_POST:
4617 case AArch64::ST2Twov4h_POST:
4618 case AArch64::ST2Twov4s_POST:
4619 case AArch64::ST2Twov8b_POST:
4620 case AArch64::ST2Twov8h_POST:
4621 case AArch64::ST2i16_POST:
4622 case AArch64::ST2i32_POST:
4623 case AArch64::ST2i64_POST:
4624 case AArch64::ST2i8_POST:
4625 case AArch64::ST3Threev16b_POST:
4626 case AArch64::ST3Threev2d_POST:
4627 case AArch64::ST3Threev2s_POST:
4628 case AArch64::ST3Threev4h_POST:
4629 case AArch64::ST3Threev4s_POST:
4630 case AArch64::ST3Threev8b_POST:
4631 case AArch64::ST3Threev8h_POST:
4632 case AArch64::ST3i16_POST:
4633 case AArch64::ST3i32_POST:
4634 case AArch64::ST3i64_POST:
4635 case AArch64::ST3i8_POST:
4636 case AArch64::ST4Fourv16b_POST:
4637 case AArch64::ST4Fourv2d_POST:
4638 case AArch64::ST4Fourv2s_POST:
4639 case AArch64::ST4Fourv4h_POST:
4640 case AArch64::ST4Fourv4s_POST:
4641 case AArch64::ST4Fourv8b_POST:
4642 case AArch64::ST4Fourv8h_POST:
4643 case AArch64::ST4i16_POST:
4644 case AArch64::ST4i32_POST:
4645 case AArch64::ST4i64_POST:
4646 case AArch64::ST4i8_POST:
4647 case AArch64::STGPostIndex:
4648 case AArch64::STGPpost:
4649 case AArch64::STPDpost:
4650 case AArch64::STPQpost:
4651 case AArch64::STPSpost:
4652 case AArch64::STPWpost:
4653 case AArch64::STPXpost:
4654 case AArch64::STRBBpost:
4655 case AArch64::STRBpost:
4656 case AArch64::STRDpost:
4657 case AArch64::STRHHpost:
4658 case AArch64::STRHpost:
4659 case AArch64::STRQpost:
4660 case AArch64::STRSpost:
4661 case AArch64::STRWpost:
4662 case AArch64::STRXpost:
4663 case AArch64::STZ2GPostIndex:
4664 case AArch64::STZGPostIndex:
4671 bool &OffsetIsScalable,
TypeSize &Width)
const {
4691 int64_t Dummy1, Dummy2;
4713 return BaseOp->
isReg() || BaseOp->
isFI();
4720 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4725 TypeSize &Width, int64_t &MinOffset,
4726 int64_t &MaxOffset) {
4731 MinOffset = MaxOffset = 0;
4734 case AArch64::LDRQui:
4735 case AArch64::STRQui:
4740 case AArch64::LDRXui:
4741 case AArch64::LDRDui:
4742 case AArch64::STRXui:
4743 case AArch64::STRDui:
4744 case AArch64::PRFMui:
4745 case AArch64::ATOMIC_STORE_HINT_Xui:
4746 case AArch64::ATOMIC_STORE_HINT_Dui:
4751 case AArch64::LDRWui:
4752 case AArch64::LDRSui:
4753 case AArch64::LDRSWui:
4754 case AArch64::STRWui:
4755 case AArch64::STRSui:
4756 case AArch64::ATOMIC_STORE_HINT_Wui:
4757 case AArch64::ATOMIC_STORE_HINT_Sui:
4762 case AArch64::LDRHui:
4763 case AArch64::LDRHHui:
4764 case AArch64::LDRSHWui:
4765 case AArch64::LDRSHXui:
4766 case AArch64::STRHui:
4767 case AArch64::STRHHui:
4768 case AArch64::ATOMIC_STORE_HINT_Hui:
4773 case AArch64::LDRBui:
4774 case AArch64::LDRBBui:
4775 case AArch64::LDRSBWui:
4776 case AArch64::LDRSBXui:
4777 case AArch64::STRBui:
4778 case AArch64::STRBBui:
4779 case AArch64::ATOMIC_STORE_HINT_Bui:
4785 case AArch64::STRQpre:
4786 case AArch64::LDRQpost:
4792 case AArch64::LDRDpost:
4793 case AArch64::LDRDpre:
4794 case AArch64::LDRXpost:
4795 case AArch64::LDRXpre:
4796 case AArch64::STRDpost:
4797 case AArch64::STRDpre:
4798 case AArch64::STRXpost:
4799 case AArch64::STRXpre:
4805 case AArch64::STRWpost:
4806 case AArch64::STRWpre:
4807 case AArch64::LDRWpost:
4808 case AArch64::LDRWpre:
4809 case AArch64::STRSpost:
4810 case AArch64::STRSpre:
4811 case AArch64::LDRSpost:
4812 case AArch64::LDRSpre:
4818 case AArch64::LDRHpost:
4819 case AArch64::LDRHpre:
4820 case AArch64::STRHpost:
4821 case AArch64::STRHpre:
4822 case AArch64::LDRHHpost:
4823 case AArch64::LDRHHpre:
4824 case AArch64::STRHHpost:
4825 case AArch64::STRHHpre:
4831 case AArch64::LDRBpost:
4832 case AArch64::LDRBpre:
4833 case AArch64::STRBpost:
4834 case AArch64::STRBpre:
4835 case AArch64::LDRBBpost:
4836 case AArch64::LDRBBpre:
4837 case AArch64::STRBBpost:
4838 case AArch64::STRBBpre:
4844 case AArch64::LDURQi:
4845 case AArch64::STURQi:
4851 case AArch64::LDURXi:
4852 case AArch64::LDURDi:
4853 case AArch64::LDAPURXi:
4854 case AArch64::STURXi:
4855 case AArch64::STURDi:
4856 case AArch64::STLURXi:
4857 case AArch64::PRFUMi:
4858 case AArch64::ATOMIC_STORE_HINT_Xi:
4859 case AArch64::ATOMIC_STORE_HINT_Di:
4865 case AArch64::LDURWi:
4866 case AArch64::LDURSi:
4867 case AArch64::LDURSWi:
4868 case AArch64::LDAPURi:
4869 case AArch64::LDAPURSWi:
4870 case AArch64::STURWi:
4871 case AArch64::STURSi:
4872 case AArch64::STLURWi:
4873 case AArch64::ATOMIC_STORE_HINT_Wi:
4874 case AArch64::ATOMIC_STORE_HINT_Si:
4880 case AArch64::LDURHi:
4881 case AArch64::LDURHHi:
4882 case AArch64::LDURSHXi:
4883 case AArch64::LDURSHWi:
4884 case AArch64::LDAPURHi:
4885 case AArch64::LDAPURSHWi:
4886 case AArch64::LDAPURSHXi:
4887 case AArch64::STURHi:
4888 case AArch64::STURHHi:
4889 case AArch64::STLURHi:
4890 case AArch64::ATOMIC_STORE_HINT_Hi:
4896 case AArch64::LDURBi:
4897 case AArch64::LDURBBi:
4898 case AArch64::LDURSBXi:
4899 case AArch64::LDURSBWi:
4900 case AArch64::LDAPURBi:
4901 case AArch64::LDAPURSBWi:
4902 case AArch64::LDAPURSBXi:
4903 case AArch64::STURBi:
4904 case AArch64::STURBBi:
4905 case AArch64::STLURBi:
4906 case AArch64::ATOMIC_STORE_HINT_Bi:
4912 case AArch64::LDPQi:
4913 case AArch64::LDNPQi:
4914 case AArch64::STPQi:
4915 case AArch64::STNPQi:
4916 case AArch64::LDPQpost:
4917 case AArch64::LDPQpre:
4918 case AArch64::STPQpost:
4919 case AArch64::STPQpre:
4925 case AArch64::LDPXi:
4926 case AArch64::LDPDi:
4927 case AArch64::LDNPXi:
4928 case AArch64::LDNPDi:
4929 case AArch64::STPXi:
4930 case AArch64::STPDi:
4931 case AArch64::STNPXi:
4932 case AArch64::STNPDi:
4933 case AArch64::LDPDpost:
4934 case AArch64::LDPDpre:
4935 case AArch64::LDPXpost:
4936 case AArch64::LDPXpre:
4937 case AArch64::STPDpost:
4938 case AArch64::STPDpre:
4939 case AArch64::STPXpost:
4940 case AArch64::STPXpre:
4946 case AArch64::LDPWi:
4947 case AArch64::LDPSi:
4948 case AArch64::LDNPWi:
4949 case AArch64::LDNPSi:
4950 case AArch64::STPWi:
4951 case AArch64::STPSi:
4952 case AArch64::STNPWi:
4953 case AArch64::STNPSi:
4954 case AArch64::LDPSpost:
4955 case AArch64::LDPSpre:
4956 case AArch64::LDPWpost:
4957 case AArch64::LDPWpre:
4958 case AArch64::STPSpost:
4959 case AArch64::STPSpre:
4960 case AArch64::STPWpost:
4961 case AArch64::STPWpre:
4967 case AArch64::StoreSwiftAsyncContext:
4980 case AArch64::TAGPstack:
4990 case AArch64::STGPreIndex:
4991 case AArch64::STGPostIndex:
4992 case AArch64::STZGi:
4993 case AArch64::STZGPreIndex:
4994 case AArch64::STZGPostIndex:
5000 case AArch64::STR_ZZZZXI:
5001 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
5002 case AArch64::LDR_ZZZZXI:
5003 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
5009 case AArch64::STR_ZZZXI:
5010 case AArch64::LDR_ZZZXI:
5016 case AArch64::STR_ZZXI:
5017 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
5018 case AArch64::LDR_ZZXI:
5019 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
5025 case AArch64::LDR_PXI:
5026 case AArch64::STR_PXI:
5031 case AArch64::LDR_PPXI:
5032 case AArch64::STR_PPXI:
5038 case AArch64::LDR_ZXI:
5039 case AArch64::STR_ZXI:
5044 case AArch64::LD1B_IMM:
5045 case AArch64::LD1H_IMM:
5046 case AArch64::LD1W_IMM:
5047 case AArch64::LD1D_IMM:
5048 case AArch64::LDNT1B_ZRI:
5049 case AArch64::LDNT1H_ZRI:
5050 case AArch64::LDNT1W_ZRI:
5051 case AArch64::LDNT1D_ZRI:
5052 case AArch64::ST1B_IMM:
5053 case AArch64::ST1H_IMM:
5054 case AArch64::ST1W_IMM:
5055 case AArch64::ST1D_IMM:
5056 case AArch64::STNT1B_ZRI:
5057 case AArch64::STNT1H_ZRI:
5058 case AArch64::STNT1W_ZRI:
5059 case AArch64::STNT1D_ZRI:
5060 case AArch64::LDNF1B_IMM:
5061 case AArch64::LDNF1H_IMM:
5062 case AArch64::LDNF1W_IMM:
5063 case AArch64::LDNF1D_IMM:
5070 case AArch64::LD2B_IMM:
5071 case AArch64::LD2H_IMM:
5072 case AArch64::LD2W_IMM:
5073 case AArch64::LD2D_IMM:
5074 case AArch64::ST2B_IMM:
5075 case AArch64::ST2H_IMM:
5076 case AArch64::ST2W_IMM:
5077 case AArch64::ST2D_IMM:
5078 case AArch64::LD1B_2Z_IMM:
5079 case AArch64::LD1B_2Z_STRIDED_IMM:
5080 case AArch64::LD1H_2Z_IMM:
5081 case AArch64::LD1H_2Z_STRIDED_IMM:
5082 case AArch64::LD1W_2Z_IMM:
5083 case AArch64::LD1W_2Z_STRIDED_IMM:
5084 case AArch64::LD1D_2Z_IMM:
5085 case AArch64::LD1D_2Z_STRIDED_IMM:
5086 case AArch64::LD1B_2Z_IMM_PSEUDO:
5087 case AArch64::LD1H_2Z_IMM_PSEUDO:
5088 case AArch64::LD1W_2Z_IMM_PSEUDO:
5089 case AArch64::LD1D_2Z_IMM_PSEUDO:
5090 case AArch64::ST1B_2Z_IMM:
5091 case AArch64::ST1B_2Z_STRIDED_IMM:
5092 case AArch64::ST1H_2Z_IMM:
5093 case AArch64::ST1H_2Z_STRIDED_IMM:
5094 case AArch64::ST1W_2Z_IMM:
5095 case AArch64::ST1W_2Z_STRIDED_IMM:
5096 case AArch64::ST1D_2Z_IMM:
5097 case AArch64::ST1D_2Z_STRIDED_IMM:
5098 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5099 case AArch64::LDNT1B_2Z_IMM:
5100 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5101 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5102 case AArch64::LDNT1H_2Z_IMM:
5103 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5104 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5105 case AArch64::LDNT1W_2Z_IMM:
5106 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5107 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5108 case AArch64::LDNT1D_2Z_IMM:
5109 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5110 case AArch64::STNT1B_2Z_IMM:
5111 case AArch64::STNT1B_2Z_STRIDED_IMM:
5112 case AArch64::STNT1H_2Z_IMM:
5113 case AArch64::STNT1H_2Z_STRIDED_IMM:
5114 case AArch64::STNT1W_2Z_IMM:
5115 case AArch64::STNT1W_2Z_STRIDED_IMM:
5116 case AArch64::STNT1D_2Z_IMM:
5117 case AArch64::STNT1D_2Z_STRIDED_IMM:
5118 case AArch64::ST1B_2Z_IMM_PSEUDO:
5119 case AArch64::ST1H_2Z_IMM_PSEUDO:
5120 case AArch64::ST1W_2Z_IMM_PSEUDO:
5121 case AArch64::ST1D_2Z_IMM_PSEUDO:
5122 case AArch64::STNT1B_2Z_IMM_PSEUDO:
5123 case AArch64::STNT1H_2Z_IMM_PSEUDO:
5124 case AArch64::STNT1W_2Z_IMM_PSEUDO:
5125 case AArch64::STNT1D_2Z_IMM_PSEUDO:
5130 case AArch64::LD3B_IMM:
5131 case AArch64::LD3H_IMM:
5132 case AArch64::LD3W_IMM:
5133 case AArch64::LD3D_IMM:
5134 case AArch64::ST3B_IMM:
5135 case AArch64::ST3H_IMM:
5136 case AArch64::ST3W_IMM:
5137 case AArch64::ST3D_IMM:
5142 case AArch64::LD4B_IMM:
5143 case AArch64::LD4H_IMM:
5144 case AArch64::LD4W_IMM:
5145 case AArch64::LD4D_IMM:
5146 case AArch64::ST4B_IMM:
5147 case AArch64::ST4H_IMM:
5148 case AArch64::ST4W_IMM:
5149 case AArch64::ST4D_IMM:
5150 case AArch64::LD1B_4Z_IMM:
5151 case AArch64::LD1B_4Z_STRIDED_IMM:
5152 case AArch64::LD1H_4Z_IMM:
5153 case AArch64::LD1H_4Z_STRIDED_IMM:
5154 case AArch64::LD1W_4Z_IMM:
5155 case AArch64::LD1W_4Z_STRIDED_IMM:
5156 case AArch64::LD1D_4Z_IMM:
5157 case AArch64::LD1D_4Z_STRIDED_IMM:
5158 case AArch64::LD1B_4Z_IMM_PSEUDO:
5159 case AArch64::LD1H_4Z_IMM_PSEUDO:
5160 case AArch64::LD1W_4Z_IMM_PSEUDO:
5161 case AArch64::LD1D_4Z_IMM_PSEUDO:
5162 case AArch64::ST1B_4Z_IMM:
5163 case AArch64::ST1B_4Z_STRIDED_IMM:
5164 case AArch64::ST1H_4Z_IMM:
5165 case AArch64::ST1H_4Z_STRIDED_IMM:
5166 case AArch64::ST1W_4Z_IMM:
5167 case AArch64::ST1W_4Z_STRIDED_IMM:
5168 case AArch64::ST1D_4Z_IMM:
5169 case AArch64::ST1D_4Z_STRIDED_IMM:
5170 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5171 case AArch64::LDNT1B_4Z_IMM:
5172 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5173 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5174 case AArch64::LDNT1H_4Z_IMM:
5175 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5176 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5177 case AArch64::LDNT1W_4Z_IMM:
5178 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5179 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5180 case AArch64::LDNT1D_4Z_IMM:
5181 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5182 case AArch64::STNT1B_4Z_IMM:
5183 case AArch64::STNT1B_4Z_STRIDED_IMM:
5184 case AArch64::STNT1H_4Z_IMM:
5185 case AArch64::STNT1H_4Z_STRIDED_IMM:
5186 case AArch64::STNT1W_4Z_IMM:
5187 case AArch64::STNT1W_4Z_STRIDED_IMM:
5188 case AArch64::STNT1D_4Z_IMM:
5189 case AArch64::STNT1D_4Z_STRIDED_IMM:
5190 case AArch64::ST1B_4Z_IMM_PSEUDO:
5191 case AArch64::ST1H_4Z_IMM_PSEUDO:
5192 case AArch64::ST1W_4Z_IMM_PSEUDO:
5193 case AArch64::ST1D_4Z_IMM_PSEUDO:
5194 case AArch64::STNT1B_4Z_IMM_PSEUDO:
5195 case AArch64::STNT1H_4Z_IMM_PSEUDO:
5196 case AArch64::STNT1W_4Z_IMM_PSEUDO:
5197 case AArch64::STNT1D_4Z_IMM_PSEUDO:
5202 case AArch64::LD1B_H_IMM:
5203 case AArch64::LD1SB_H_IMM:
5204 case AArch64::LD1H_S_IMM:
5205 case AArch64::LD1SH_S_IMM:
5206 case AArch64::LD1W_D_IMM:
5207 case AArch64::LD1SW_D_IMM:
5208 case AArch64::ST1B_H_IMM:
5209 case AArch64::ST1H_S_IMM:
5210 case AArch64::ST1W_D_IMM:
5211 case AArch64::LDNF1B_H_IMM:
5212 case AArch64::LDNF1SB_H_IMM:
5213 case AArch64::LDNF1H_S_IMM:
5214 case AArch64::LDNF1SH_S_IMM:
5215 case AArch64::LDNF1W_D_IMM:
5216 case AArch64::LDNF1SW_D_IMM:
5223 case AArch64::LD1B_S_IMM:
5224 case AArch64::LD1SB_S_IMM:
5225 case AArch64::LD1H_D_IMM:
5226 case AArch64::LD1SH_D_IMM:
5227 case AArch64::ST1B_S_IMM:
5228 case AArch64::ST1H_D_IMM:
5229 case AArch64::LDNF1B_S_IMM:
5230 case AArch64::LDNF1SB_S_IMM:
5231 case AArch64::LDNF1H_D_IMM:
5232 case AArch64::LDNF1SH_D_IMM:
5239 case AArch64::LD1B_D_IMM:
5240 case AArch64::LD1SB_D_IMM:
5241 case AArch64::ST1B_D_IMM:
5242 case AArch64::LDNF1B_D_IMM:
5243 case AArch64::LDNF1SB_D_IMM:
5250 case AArch64::ST2Gi:
5251 case AArch64::ST2GPreIndex:
5252 case AArch64::ST2GPostIndex:
5253 case AArch64::STZ2Gi:
5254 case AArch64::STZ2GPreIndex:
5255 case AArch64::STZ2GPostIndex:
5261 case AArch64::STGPi:
5262 case AArch64::STGPpost:
5263 case AArch64::STGPpre:
5268 case AArch64::LD1RB_IMM:
5269 case AArch64::LD1RB_H_IMM:
5270 case AArch64::LD1RB_S_IMM:
5271 case AArch64::LD1RB_D_IMM:
5272 case AArch64::LD1RSB_H_IMM:
5273 case AArch64::LD1RSB_S_IMM:
5274 case AArch64::LD1RSB_D_IMM:
5279 case AArch64::LD1RH_IMM:
5280 case AArch64::LD1RH_S_IMM:
5281 case AArch64::LD1RH_D_IMM:
5282 case AArch64::LD1RSH_S_IMM:
5283 case AArch64::LD1RSH_D_IMM:
5288 case AArch64::LD1RW_IMM:
5289 case AArch64::LD1RW_D_IMM:
5290 case AArch64::LD1RSW_IMM:
5295 case AArch64::LD1RD_IMM:
5310 case AArch64::LDRBui:
5311 case AArch64::LDRBBui:
5312 case AArch64::LDURBBi:
5313 case AArch64::LDRSBWui:
5314 case AArch64::LDURSBWi:
5315 case AArch64::STRBui:
5316 case AArch64::STRBBui:
5317 case AArch64::STURBBi:
5319 case AArch64::LDRHui:
5320 case AArch64::LDRHHui:
5321 case AArch64::LDURHHi:
5322 case AArch64::LDRSHWui:
5323 case AArch64::LDURSHWi:
5324 case AArch64::STRHui:
5325 case AArch64::STRHHui:
5326 case AArch64::STURHHi:
5328 case AArch64::LDRSui:
5329 case AArch64::LDURSi:
5330 case AArch64::LDRSpre:
5331 case AArch64::LDRSWui:
5332 case AArch64::LDURSWi:
5333 case AArch64::LDRSWpre:
5334 case AArch64::LDRWpre:
5335 case AArch64::LDRWui:
5336 case AArch64::LDURWi:
5337 case AArch64::STRSui:
5338 case AArch64::STURSi:
5339 case AArch64::STRSpre:
5340 case AArch64::STRWui:
5341 case AArch64::STURWi:
5342 case AArch64::STRWpre:
5343 case AArch64::LDPSi:
5344 case AArch64::LDPSWi:
5345 case AArch64::LDPWi:
5346 case AArch64::STPSi:
5347 case AArch64::STPWi:
5349 case AArch64::LDRDui:
5350 case AArch64::LDURDi:
5351 case AArch64::LDRDpre:
5352 case AArch64::LDRXui:
5353 case AArch64::LDURXi:
5354 case AArch64::LDRXpre:
5355 case AArch64::STRDui:
5356 case AArch64::STURDi:
5357 case AArch64::STRDpre:
5358 case AArch64::STRXui:
5359 case AArch64::STURXi:
5360 case AArch64::STRXpre:
5361 case AArch64::LDPDi:
5362 case AArch64::LDPXi:
5363 case AArch64::STPDi:
5364 case AArch64::STPXi:
5366 case AArch64::LDRQui:
5367 case AArch64::LDURQi:
5368 case AArch64::STRQui:
5369 case AArch64::STURQi:
5370 case AArch64::STRQpre:
5371 case AArch64::LDPQi:
5372 case AArch64::LDRQpre:
5373 case AArch64::STPQi:
5375 case AArch64::STZGi:
5376 case AArch64::ST2Gi:
5377 case AArch64::STZ2Gi:
5378 case AArch64::STGPi:
5384 switch (
MI.getOpcode()) {
5387 case AArch64::LDRWpre:
5388 case AArch64::LDRXpre:
5389 case AArch64::LDRSWpre:
5390 case AArch64::LDRSpre:
5391 case AArch64::LDRDpre:
5392 case AArch64::LDRQpre:
5398 switch (
MI.getOpcode()) {
5401 case AArch64::STRWpre:
5402 case AArch64::STRXpre:
5403 case AArch64::STRSpre:
5404 case AArch64::STRDpre:
5405 case AArch64::STRQpre:
5415 switch (
MI.getOpcode()) {
5418 case AArch64::LDURBBi:
5419 case AArch64::LDURHHi:
5420 case AArch64::LDURWi:
5421 case AArch64::LDRBBui:
5422 case AArch64::LDRHHui:
5423 case AArch64::LDRWui:
5424 case AArch64::LDRBBroX:
5425 case AArch64::LDRHHroX:
5426 case AArch64::LDRWroX:
5427 case AArch64::LDRBBroW:
5428 case AArch64::LDRHHroW:
5429 case AArch64::LDRWroW:
5435 switch (
MI.getOpcode()) {
5438 case AArch64::LDURSBWi:
5439 case AArch64::LDURSHWi:
5440 case AArch64::LDURSBXi:
5441 case AArch64::LDURSHXi:
5442 case AArch64::LDURSWi:
5443 case AArch64::LDRSBWui:
5444 case AArch64::LDRSHWui:
5445 case AArch64::LDRSBXui:
5446 case AArch64::LDRSHXui:
5447 case AArch64::LDRSWui:
5448 case AArch64::LDRSBWroX:
5449 case AArch64::LDRSHWroX:
5450 case AArch64::LDRSBXroX:
5451 case AArch64::LDRSHXroX:
5452 case AArch64::LDRSWroX:
5453 case AArch64::LDRSBWroW:
5454 case AArch64::LDRSHWroW:
5455 case AArch64::LDRSBXroW:
5456 case AArch64::LDRSHXroW:
5457 case AArch64::LDRSWroW:
5463 switch (
MI.getOpcode()) {
5466 case AArch64::LDPSi:
5467 case AArch64::LDPSWi:
5468 case AArch64::LDPDi:
5469 case AArch64::LDPQi:
5470 case AArch64::LDPWi:
5471 case AArch64::LDPXi:
5472 case AArch64::STPSi:
5473 case AArch64::STPDi:
5474 case AArch64::STPQi:
5475 case AArch64::STPWi:
5476 case AArch64::STPXi:
5477 case AArch64::STGPi:
5483 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5487 return MI.getOperand(Idx);
5492 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5496 return MI.getOperand(Idx);
5501 switch (
MI.getOpcode()) {
5504 case AArch64::LDRBroX:
5505 case AArch64::LDRBBroX:
5506 case AArch64::LDRSBXroX:
5507 case AArch64::LDRSBWroX:
5508 case AArch64::LDRHroX:
5509 case AArch64::LDRHHroX:
5510 case AArch64::LDRSHXroX:
5511 case AArch64::LDRSHWroX:
5512 case AArch64::LDRWroX:
5513 case AArch64::LDRSroX:
5514 case AArch64::LDRSWroX:
5515 case AArch64::LDRDroX:
5516 case AArch64::LDRXroX:
5517 case AArch64::LDRQroX:
5518 return MI.getOperand(4);
5524 if (
MI.getParent() ==
nullptr)
5534 auto Reg =
Op.getReg();
5535 if (Reg.isPhysical())
5536 return AArch64::FPR16RegClass.contains(Reg);
5538 return TRC == &AArch64::FPR16RegClass ||
5539 TRC == &AArch64::FPR16_loRegClass;
5548 auto Reg =
Op.getReg();
5549 if (Reg.isPhysical())
5550 return AArch64::FPR128RegClass.contains(Reg);
5552 return TRC == &AArch64::FPR128RegClass ||
5553 TRC == &AArch64::FPR128_loRegClass;
5559 switch (
MI.getOpcode()) {
5562 case AArch64::PACIASP:
5563 case AArch64::PACIBSP:
5566 case AArch64::PAUTH_PROLOGUE:
5569 case AArch64::HINT: {
5570 unsigned Imm =
MI.getOperand(0).getImm();
5575 if (
Imm == 25 ||
Imm == 27)
5587 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5588 return AArch64::FPR128RegClass.contains(Reg) ||
5589 AArch64::FPR64RegClass.contains(Reg) ||
5590 AArch64::FPR32RegClass.contains(Reg) ||
5591 AArch64::FPR16RegClass.contains(Reg) ||
5592 AArch64::FPR8RegClass.contains(Reg);
5599 auto Reg =
Op.getReg();
5600 if (Reg.isPhysical())
5604 return TRC == &AArch64::FPR128RegClass ||
5605 TRC == &AArch64::FPR128_loRegClass ||
5606 TRC == &AArch64::FPR64RegClass ||
5607 TRC == &AArch64::FPR64_loRegClass ||
5608 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5609 TRC == &AArch64::FPR8RegClass;
5631 if (FirstOpc == SecondOpc)
5637 case AArch64::STRSui:
5638 case AArch64::STURSi:
5639 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5640 case AArch64::STRDui:
5641 case AArch64::STURDi:
5642 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5643 case AArch64::STRQui:
5644 case AArch64::STURQi:
5645 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5646 case AArch64::STRWui:
5647 case AArch64::STURWi:
5648 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5649 case AArch64::STRXui:
5650 case AArch64::STURXi:
5651 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5652 case AArch64::LDRSui:
5653 case AArch64::LDURSi:
5654 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5655 case AArch64::LDRDui:
5656 case AArch64::LDURDi:
5657 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5658 case AArch64::LDRQui:
5659 case AArch64::LDURQi:
5660 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5661 case AArch64::LDRWui:
5662 case AArch64::LDURWi:
5663 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5664 case AArch64::LDRSWui:
5665 case AArch64::LDURSWi:
5666 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5667 case AArch64::LDRXui:
5668 case AArch64::LDURXi:
5669 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5676 int64_t Offset1,
unsigned Opcode1,
int FI2,
5677 int64_t Offset2,
unsigned Opcode2) {
5683 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5686 if (ObjectOffset1 % Scale1 != 0)
5688 ObjectOffset1 /= Scale1;
5690 if (ObjectOffset2 % Scale2 != 0)
5692 ObjectOffset2 /= Scale2;
5693 ObjectOffset1 += Offset1;
5694 ObjectOffset2 += Offset2;
5695 return ObjectOffset1 + 1 == ObjectOffset2;
5707 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5708 unsigned NumBytes)
const {
5718 "Only base registers and frame indices are supported.");
5725 if (ClusterSize > 2)
5732 unsigned FirstOpc = FirstLdSt.
getOpcode();
5733 unsigned SecondOpc = SecondLdSt.
getOpcode();
5753 if (Offset1 > 63 || Offset1 < -64)
5758 if (BaseOp1.
isFI()) {
5760 "Caller should have ordered offsets.");
5765 BaseOp2.
getIndex(), Offset2, SecondOpc);
5768 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5770 return Offset1 + 1 == Offset2;
5780 if (
Reg.isPhysical())
5790 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5792 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5793 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5794 unsigned NumRegs = Indices.
size();
5795 MCRegister DestSubReg =
TRI->getSubReg(DestReg, Indices[0]);
5797 "Unexpected predicate tuple copy");
5798 unsigned MaxRegs = AArch64::PPRRegClass.contains(DestSubReg) ? 15 : 31;
5800 int SubReg = 0,
End = NumRegs, Incr = 1;
5802 if (((DestEncoding - SrcEncoding) & MaxRegs) < NumRegs) {
5803 SubReg = NumRegs - 1;
5808 for (; SubReg !=
End; SubReg += Incr) {
5809 DestSubReg =
TRI->getSubReg(DestReg, Indices[SubReg]);
5810 MCRegister SrcSubReg =
TRI->getSubReg(SrcReg, Indices[SubReg]);
5819 unsigned Opcode,
unsigned ZeroReg,
5822 unsigned NumRegs = Indices.
size();
5825 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5826 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5827 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5828 "GPR reg sequences should not be able to overlap");
5831 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5852 unsigned Opc =
MI.getOpcode();
5853 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5855 int64_t PState =
MI.getOperand(0).getImm();
5856 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5858 return MI.getOperand(1).getImm() == 1;
5877 bool RenamableSrc)
const {
5878 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5879 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5880 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5882 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5883 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5885 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5886 &AArch64::GPR64spRegClass);
5887 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5888 &AArch64::GPR64spRegClass);
5898 ++NumZCRegMoveInstrsGPR;
5904 if (Subtarget.hasZeroCycleRegMoveGPR32())
5905 ++NumZCRegMoveInstrsGPR;
5907 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5908 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5910 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5911 &AArch64::GPR64spRegClass);
5912 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5913 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5914 &AArch64::GPR64spRegClass);
5924 ++NumZCRegMoveInstrsGPR;
5930 if (Subtarget.hasZeroCycleRegMoveGPR32())
5931 ++NumZCRegMoveInstrsGPR;
5937 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5938 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5939 !Subtarget.hasZeroCycleZeroingGPR32()) {
5940 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5941 &AArch64::GPR64spRegClass);
5942 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5946 ++NumZCZeroingInstrsGPR;
5947 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5951 ++NumZCZeroingInstrsGPR;
5960 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5961 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5962 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5968 if (Subtarget.hasZeroCycleRegMoveGPR64())
5969 ++NumZCRegMoveInstrsGPR;
5975 if (Subtarget.hasZeroCycleRegMoveGPR64())
5976 ++NumZCRegMoveInstrsGPR;
5982 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5983 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5987 ++NumZCZeroingInstrsGPR;
5997 if (AArch64::PPRRegClass.
contains(DestReg) &&
5998 AArch64::PPRRegClass.
contains(SrcReg)) {
5999 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6000 "Unexpected SVE register.");
6010 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
6011 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
6012 if (DestIsPNR || SrcIsPNR) {
6014 return (R - AArch64::PN0) + AArch64::P0;
6019 if (PPRSrcReg != PPRDestReg) {
6031 if (AArch64::PPR2RegClass.
contains(DestReg) &&
6032 AArch64::PPR2RegClass.
contains(SrcReg)) {
6033 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6034 "Unexpected SVE predicate register.");
6035 static const unsigned Indices[] = {AArch64::psub0, AArch64::psub1};
6041 if (AArch64::ZPRRegClass.
contains(DestReg) &&
6042 AArch64::ZPRRegClass.
contains(SrcReg)) {
6043 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6044 "Unexpected SVE register.");
6052 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
6053 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
6054 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
6055 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
6056 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6057 "Unexpected SVE register.");
6058 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
6064 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
6065 AArch64::ZPR3RegClass.
contains(SrcReg)) {
6066 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6067 "Unexpected SVE register.");
6068 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6075 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
6076 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
6077 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
6078 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
6079 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6080 "Unexpected SVE register.");
6081 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6082 AArch64::zsub2, AArch64::zsub3};
6088 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6089 AArch64::DDDDRegClass.
contains(SrcReg)) {
6090 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6091 AArch64::dsub2, AArch64::dsub3};
6097 if (AArch64::DDDRegClass.
contains(DestReg) &&
6098 AArch64::DDDRegClass.
contains(SrcReg)) {
6099 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6106 if (AArch64::DDRegClass.
contains(DestReg) &&
6107 AArch64::DDRegClass.
contains(SrcReg)) {
6108 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6114 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6115 AArch64::QQQQRegClass.
contains(SrcReg)) {
6116 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6117 AArch64::qsub2, AArch64::qsub3};
6123 if (AArch64::QQQRegClass.
contains(DestReg) &&
6124 AArch64::QQQRegClass.
contains(SrcReg)) {
6125 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6132 if (AArch64::QQRegClass.
contains(DestReg) &&
6133 AArch64::QQRegClass.
contains(SrcReg)) {
6134 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6139 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6140 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6141 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6143 AArch64::XZR, Indices);
6147 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6148 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6149 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6151 AArch64::WZR, Indices);
6155 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6156 AArch64::FPR128RegClass.
contains(SrcReg)) {
6160 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6161 !Subtarget.isNeonAvailable()) ||
6165 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6166 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6167 }
else if (Subtarget.isNeonAvailable()) {
6171 if (Subtarget.hasZeroCycleRegMoveFPR128())
6172 ++NumZCRegMoveInstrsFPR;
6188 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6189 AArch64::FPR64RegClass.
contains(SrcReg)) {
6190 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6191 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6192 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6194 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6195 &AArch64::FPR128RegClass);
6196 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6197 &AArch64::FPR128RegClass);
6206 ++NumZCRegMoveInstrsFPR;
6210 if (Subtarget.hasZeroCycleRegMoveFPR64())
6211 ++NumZCRegMoveInstrsFPR;
6216 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6217 AArch64::FPR32RegClass.
contains(SrcReg)) {
6218 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6219 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6220 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6222 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6223 &AArch64::FPR128RegClass);
6224 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6225 &AArch64::FPR128RegClass);
6234 ++NumZCRegMoveInstrsFPR;
6235 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6236 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6237 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6238 &AArch64::FPR64RegClass);
6239 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6240 &AArch64::FPR64RegClass);
6248 ++NumZCRegMoveInstrsFPR;
6252 if (Subtarget.hasZeroCycleRegMoveFPR32())
6253 ++NumZCRegMoveInstrsFPR;
6258 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6259 AArch64::FPR16RegClass.
contains(SrcReg)) {
6260 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6261 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6262 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6264 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6265 &AArch64::FPR128RegClass);
6266 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6267 &AArch64::FPR128RegClass);
6276 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6277 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6278 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6279 &AArch64::FPR64RegClass);
6280 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6281 &AArch64::FPR64RegClass);
6290 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6291 &AArch64::FPR32RegClass);
6292 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6293 &AArch64::FPR32RegClass);
6300 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6301 AArch64::FPR8RegClass.
contains(SrcReg)) {
6302 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6303 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6304 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6306 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6307 &AArch64::FPR128RegClass);
6308 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6309 &AArch64::FPR128RegClass);
6318 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6319 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6320 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6321 &AArch64::FPR64RegClass);
6322 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6323 &AArch64::FPR64RegClass);
6332 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6333 &AArch64::FPR32RegClass);
6334 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6335 &AArch64::FPR32RegClass);
6343 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6344 AArch64::GPR64RegClass.
contains(SrcReg)) {
6345 if (AArch64::XZR == SrcReg) {
6353 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6354 AArch64::FPR64RegClass.
contains(SrcReg)) {
6360 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6361 AArch64::GPR32RegClass.
contains(SrcReg)) {
6362 if (AArch64::WZR == SrcReg) {
6370 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6371 AArch64::FPR32RegClass.
contains(SrcReg)) {
6377 if (DestReg == AArch64::NZCV) {
6378 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6380 .
addImm(AArch64SysReg::NZCV)
6386 if (SrcReg == AArch64::NZCV) {
6387 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6389 .
addImm(AArch64SysReg::NZCV)
6395 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6406 bool RenamableSrc)
const {
6418 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6423 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6425 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6438 Register SrcReg,
bool isKill,
int FI,
6453 switch (RI.getSpillSize(*RC)) {
6455 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6456 Opc = AArch64::STRBui;
6459 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6460 Opc = AArch64::STRHui;
6461 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6462 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6463 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6464 "Unexpected register store without SVE store instructions");
6465 Opc = AArch64::STR_PXI;
6471 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6472 Opc = AArch64::STRWui;
6476 assert(SrcReg != AArch64::WSP);
6477 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6478 Opc = AArch64::STRSui;
6479 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6480 Opc = AArch64::STR_PPXI;
6485 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6486 Opc = AArch64::STRXui;
6490 assert(SrcReg != AArch64::SP);
6491 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6492 Opc = AArch64::STRDui;
6493 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6495 get(AArch64::STPWi), SrcReg, isKill,
6496 AArch64::sube32, AArch64::subo32, FI, MMO);
6501 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6502 Opc = AArch64::STRQui;
6503 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6504 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6505 Opc = AArch64::ST1Twov1d;
6507 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6509 get(AArch64::STPXi), SrcReg, isKill,
6510 AArch64::sube64, AArch64::subo64, FI, MMO);
6512 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6513 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6514 "Unexpected register store without SVE store instructions");
6515 Opc = AArch64::STR_ZXI;
6520 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6521 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6522 Opc = AArch64::ST1Threev1d;
6527 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6528 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6529 Opc = AArch64::ST1Fourv1d;
6531 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6532 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6533 Opc = AArch64::ST1Twov2d;
6535 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6536 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6537 "Unexpected register store without SVE store instructions");
6538 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6540 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6541 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6542 "Unexpected register store without SVE store instructions");
6543 Opc = AArch64::STR_ZZXI;
6548 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6549 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6550 Opc = AArch64::ST1Threev2d;
6552 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6553 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6554 "Unexpected register store without SVE store instructions");
6555 Opc = AArch64::STR_ZZZXI;
6560 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6561 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6562 Opc = AArch64::ST1Fourv2d;
6564 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6565 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6566 "Unexpected register store without SVE store instructions");
6567 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6569 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6570 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6571 "Unexpected register store without SVE store instructions");
6572 Opc = AArch64::STR_ZZZZXI;
6577 assert(
Opc &&
"Unknown register class");
6588 MI.addMemOperand(MMO);
6595 Register DestReg,
unsigned SubIdx0,
6596 unsigned SubIdx1,
int FI,
6600 bool IsUndef =
true;
6602 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6604 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6633 switch (
TRI.getSpillSize(*RC)) {
6635 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6636 Opc = AArch64::LDRBui;
6639 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6640 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6641 Opc = AArch64::LDRHui;
6642 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6643 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6644 "Unexpected register load without SVE load instructions");
6647 Opc = AArch64::LDR_PXI;
6653 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6654 Opc = AArch64::LDRWui;
6658 assert(DestReg != AArch64::WSP);
6659 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6660 Opc = AArch64::LDRSui;
6661 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6662 Opc = AArch64::LDR_PPXI;
6667 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6668 Opc = AArch64::LDRXui;
6672 assert(DestReg != AArch64::SP);
6673 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6674 Opc = AArch64::LDRDui;
6675 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6677 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6678 AArch64::subo32, FI, MMO);
6683 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6684 Opc = AArch64::LDRQui;
6685 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6686 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6687 Opc = AArch64::LD1Twov1d;
6689 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6691 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6692 AArch64::subo64, FI, MMO);
6694 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6695 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6696 "Unexpected register load without SVE load instructions");
6697 Opc = AArch64::LDR_ZXI;
6702 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6703 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6704 Opc = AArch64::LD1Threev1d;
6709 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6710 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6711 Opc = AArch64::LD1Fourv1d;
6713 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6714 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6715 Opc = AArch64::LD1Twov2d;
6717 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6718 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6719 "Unexpected register load without SVE load instructions");
6720 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6722 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6723 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6724 "Unexpected register load without SVE load instructions");
6725 Opc = AArch64::LDR_ZZXI;
6730 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6731 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6732 Opc = AArch64::LD1Threev2d;
6734 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6735 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6736 "Unexpected register load without SVE load instructions");
6737 Opc = AArch64::LDR_ZZZXI;
6742 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6743 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6744 Opc = AArch64::LD1Fourv2d;
6746 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6747 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6748 "Unexpected register load without SVE load instructions");
6749 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6751 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6752 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6753 "Unexpected register load without SVE load instructions");
6754 Opc = AArch64::LDR_ZZZZXI;
6760 assert(
Opc &&
"Unknown register class");
6770 MI.addMemOperand(MMO);
6777 UseMI.getIterator()),
6779 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6780 I.readsRegister(AArch64::NZCV, TRI);
6784void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6789 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6796 ByteSized =
Offset.getFixed();
6797 VGSized =
Offset.getScalable() / 2;
6803void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6805 int64_t &NumDataVectors) {
6809 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6811 NumBytes =
Offset.getFixed();
6813 NumPredicateVectors =
Offset.getScalable() / 2;
6818 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6819 NumPredicateVectors > 62) {
6820 NumDataVectors = NumPredicateVectors / 8;
6821 NumPredicateVectors -= NumDataVectors * 8;
6847 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6855 int64_t OffsetFromDefCFA) {
6869 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6870 if (!RegScale.empty())
6880 int64_t NumBytes, NumVGScaledBytes;
6881 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6883 std::string CommentBuffer;
6886 if (
Reg == AArch64::SP)
6888 else if (
Reg == AArch64::FP)
6895 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6896 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6898 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6901 if (NumVGScaledBytes) {
6911 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6919 unsigned FrameReg,
unsigned Reg,
6921 bool LastAdjustmentWasScalable) {
6922 if (
Offset.getScalable())
6925 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6928 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6935 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6936 int64_t NumBytes, NumVGScaledBytes;
6937 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6938 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6940 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6943 if (!NumVGScaledBytes)
6946 std::string CommentBuffer;
6951 assert(NumVGScaledBytes &&
"Expected scalable offset");
6955 if (IncomingVGOffsetFromDefCFA) {
6957 VGRegScale =
"* IncomingVG";
6960 VGRegScale =
"* VG";
6964 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6973 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6988 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6991 bool *HasWinCFI,
bool EmitCFAOffset,
6994 unsigned MaxEncoding, ShiftSize;
6996 case AArch64::ADDXri:
6997 case AArch64::ADDSXri:
6998 case AArch64::SUBXri:
6999 case AArch64::SUBSXri:
7000 MaxEncoding = 0xfff;
7003 case AArch64::ADDVL_XXI:
7004 case AArch64::ADDPL_XXI:
7005 case AArch64::ADDSVL_XXI:
7006 case AArch64::ADDSPL_XXI:
7021 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
7023 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
7037 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
7039 if (TmpReg == AArch64::XZR)
7040 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
7041 &AArch64::GPR64RegClass);
7043 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
7044 unsigned LocalShiftSize = 0;
7045 if (ThisVal > MaxEncoding) {
7046 ThisVal = ThisVal >> ShiftSize;
7047 LocalShiftSize = ShiftSize;
7049 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
7050 "Encoding cannot handle value that big");
7052 Offset -= ThisVal << LocalShiftSize;
7057 .
addImm(Sign * (
int)ThisVal);
7067 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
7068 CFAOffset += Change;
7070 CFAOffset -= Change;
7071 if (EmitCFAOffset && DestReg == TmpReg) {
7084 int Imm = (int)(ThisVal << LocalShiftSize);
7085 if (VScale != 1 && DestReg == AArch64::SP) {
7091 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7092 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7093 assert(VScale == 1 &&
"Expected non-scalable operation");
7102 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7103 "emit a single SEH directive");
7104 }
else if (DestReg == AArch64::SP) {
7105 assert(VScale == 1 &&
"Expected non-scalable operation");
7108 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7121 unsigned DestReg,
unsigned SrcReg,
7124 bool NeedsWinCFI,
bool *HasWinCFI,
7126 unsigned FrameReg) {
7133 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7135 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7136 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7137 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7140 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7141 if (NeedsFinalDefNZCV)
7145 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7146 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7147 "SP increment/decrement not 8-byte aligned");
7148 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7151 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7154 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7156 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7163 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7164 "WinCFI can't allocate fractions of an SVE data vector");
7166 if (NumDataVectors) {
7168 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7169 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7175 if (NumPredicateVectors) {
7176 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7178 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7179 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7183 if (NeedsFinalDefNZCV)
7205 if (
MI.isFullCopy()) {
7208 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7212 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7217 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7245 if (
MI.isCopy() &&
Ops.size() == 1 &&
7247 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7248 bool IsSpill =
Ops[0] == 0;
7249 bool IsFill = !IsSpill;
7261 :
TRI.getMinimalPhysRegClass(Reg);
7267 "Mismatched register size in non subreg COPY");
7274 return &*--InsertPt;
7286 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7289 "Unexpected subreg on physical register");
7291 FrameIndex, &AArch64::GPR64RegClass,
Register());
7292 return &*--InsertPt;
7309 case AArch64::sub_32:
7310 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7311 FillRC = &AArch64::GPR32RegClass;
7314 FillRC = &AArch64::FPR32RegClass;
7317 FillRC = &AArch64::FPR64RegClass;
7323 TRI.getRegSizeInBits(*FillRC) &&
7324 "Mismatched regclass size on folded subreg COPY");
7343 bool *OutUseUnscaledOp,
7344 unsigned *OutUnscaledOp,
7345 int64_t *EmittableOffset) {
7347 if (EmittableOffset)
7348 *EmittableOffset = 0;
7349 if (OutUseUnscaledOp)
7350 *OutUseUnscaledOp =
false;
7356 switch (
MI.getOpcode()) {
7359 case AArch64::LD1Rv1d:
7360 case AArch64::LD1Rv2s:
7361 case AArch64::LD1Rv2d:
7362 case AArch64::LD1Rv4h:
7363 case AArch64::LD1Rv4s:
7364 case AArch64::LD1Rv8b:
7365 case AArch64::LD1Rv8h:
7366 case AArch64::LD1Rv16b:
7367 case AArch64::LD1Twov2d:
7368 case AArch64::LD1Threev2d:
7369 case AArch64::LD1Fourv2d:
7370 case AArch64::LD1Twov1d:
7371 case AArch64::LD1Threev1d:
7372 case AArch64::LD1Fourv1d:
7373 case AArch64::ST1Twov2d:
7374 case AArch64::ST1Threev2d:
7375 case AArch64::ST1Fourv2d:
7376 case AArch64::ST1Twov1d:
7377 case AArch64::ST1Threev1d:
7378 case AArch64::ST1Fourv1d:
7379 case AArch64::ST1i8:
7380 case AArch64::ST1i16:
7381 case AArch64::ST1i32:
7382 case AArch64::ST1i64:
7384 case AArch64::IRGstack:
7385 case AArch64::STGloop:
7386 case AArch64::STZGloop:
7391 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7392 int64_t MinOff, MaxOff;
7398 bool IsMulVL = ScaleValue.isScalable();
7399 unsigned Scale = ScaleValue.getKnownMinValue();
7409 std::optional<unsigned> UnscaledOp =
7411 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7412 if (useUnscaledOp &&
7417 Scale = ScaleValue.getKnownMinValue();
7418 assert(IsMulVL == ScaleValue.isScalable() &&
7419 "Unscaled opcode has different value for scalable");
7421 int64_t Remainder =
Offset % Scale;
7422 assert(!(Remainder && useUnscaledOp) &&
7423 "Cannot have remainder when using unscaled op");
7425 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7426 int64_t NewOffset =
Offset / Scale;
7427 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7435 int64_t HighPart =
Offset & ~0xFFF;
7436 int64_t LowPart =
Offset & 0xFFF;
7437 int64_t LowScaled = LowPart / Scale;
7438 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7439 MinOff <= LowScaled && LowScaled <= MaxOff &&
7441 NewOffset = LowScaled;
7446 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7451 if (EmittableOffset)
7452 *EmittableOffset = NewOffset;
7453 if (OutUseUnscaledOp)
7454 *OutUseUnscaledOp = useUnscaledOp;
7455 if (OutUnscaledOp && UnscaledOp)
7456 *OutUnscaledOp = *UnscaledOp;
7469 unsigned Opcode =
MI.getOpcode();
7470 unsigned ImmIdx = FrameRegIdx + 1;
7472 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7477 MI.eraseFromParent();
7483 unsigned UnscaledOp;
7486 &UnscaledOp, &NewOffset);
7490 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7492 MI.setDesc(
TII->get(UnscaledOp));
7494 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7510bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7515 case AArch64::ADDSWrr:
7516 case AArch64::ADDSWri:
7517 case AArch64::ADDSXrr:
7518 case AArch64::ADDSXri:
7519 case AArch64::SUBSWrr:
7520 case AArch64::SUBSXrr:
7522 case AArch64::SUBSWri:
7523 case AArch64::SUBSXri:
7534 case AArch64::ADDWrr:
7535 case AArch64::ADDWri:
7536 case AArch64::ADDWrs:
7537 case AArch64::SUBWrr:
7538 case AArch64::ADDSWrr:
7539 case AArch64::ADDSWri:
7540 case AArch64::SUBSWrr:
7542 case AArch64::SUBWri:
7543 case AArch64::SUBSWri:
7554 case AArch64::ADDXrr:
7555 case AArch64::ADDXri:
7556 case AArch64::ADDXrs:
7557 case AArch64::SUBXrr:
7558 case AArch64::ADDSXrr:
7559 case AArch64::ADDSXri:
7560 case AArch64::SUBSXrr:
7562 case AArch64::SUBXri:
7563 case AArch64::SUBSXri:
7564 case AArch64::ADDv8i8:
7565 case AArch64::ADDv16i8:
7566 case AArch64::ADDv4i16:
7567 case AArch64::ADDv8i16:
7568 case AArch64::ADDv2i32:
7569 case AArch64::ADDv4i32:
7570 case AArch64::SUBv8i8:
7571 case AArch64::SUBv16i8:
7572 case AArch64::SUBv4i16:
7573 case AArch64::SUBv8i16:
7574 case AArch64::SUBv2i32:
7575 case AArch64::SUBv4i32:
7588 case AArch64::FADDHrr:
7589 case AArch64::FADDSrr:
7590 case AArch64::FADDDrr:
7591 case AArch64::FADDv4f16:
7592 case AArch64::FADDv8f16:
7593 case AArch64::FADDv2f32:
7594 case AArch64::FADDv2f64:
7595 case AArch64::FADDv4f32:
7596 case AArch64::FSUBHrr:
7597 case AArch64::FSUBSrr:
7598 case AArch64::FSUBDrr:
7599 case AArch64::FSUBv4f16:
7600 case AArch64::FSUBv8f16:
7601 case AArch64::FSUBv2f32:
7602 case AArch64::FSUBv2f64:
7603 case AArch64::FSUBv4f32:
7620 unsigned CombineOpc,
unsigned ZeroReg = 0,
7621 bool CheckZeroReg =
false) {
7628 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7635 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7636 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7637 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7639 if (
MI->getOperand(3).getReg() != ZeroReg)
7644 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7653 unsigned MulOpc,
unsigned ZeroReg) {
7668bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7669 bool Invert)
const {
7675 case AArch64::FADDHrr:
7676 case AArch64::FADDSrr:
7677 case AArch64::FADDDrr:
7678 case AArch64::FMULHrr:
7679 case AArch64::FMULSrr:
7680 case AArch64::FMULDrr:
7681 case AArch64::FMULX16:
7682 case AArch64::FMULX32:
7683 case AArch64::FMULX64:
7685 case AArch64::FADDv4f16:
7686 case AArch64::FADDv8f16:
7687 case AArch64::FADDv2f32:
7688 case AArch64::FADDv4f32:
7689 case AArch64::FADDv2f64:
7690 case AArch64::FMULv4f16:
7691 case AArch64::FMULv8f16:
7692 case AArch64::FMULv2f32:
7693 case AArch64::FMULv4f32:
7694 case AArch64::FMULv2f64:
7695 case AArch64::FMULXv4f16:
7696 case AArch64::FMULXv8f16:
7697 case AArch64::FMULXv2f32:
7698 case AArch64::FMULXv4f32:
7699 case AArch64::FMULXv2f64:
7703 case AArch64::FADD_ZZZ_H:
7704 case AArch64::FADD_ZZZ_S:
7705 case AArch64::FADD_ZZZ_D:
7706 case AArch64::FMUL_ZZZ_H:
7707 case AArch64::FMUL_ZZZ_S:
7708 case AArch64::FMUL_ZZZ_D:
7719 case AArch64::ADDWrr:
7720 case AArch64::ADDXrr:
7721 case AArch64::ANDWrr:
7722 case AArch64::ANDXrr:
7723 case AArch64::ORRWrr:
7724 case AArch64::ORRXrr:
7725 case AArch64::EORWrr:
7726 case AArch64::EORXrr:
7727 case AArch64::EONWrr:
7728 case AArch64::EONXrr:
7732 case AArch64::ADDv8i8:
7733 case AArch64::ADDv16i8:
7734 case AArch64::ADDv4i16:
7735 case AArch64::ADDv8i16:
7736 case AArch64::ADDv2i32:
7737 case AArch64::ADDv4i32:
7738 case AArch64::ADDv1i64:
7739 case AArch64::ADDv2i64:
7740 case AArch64::MULv8i8:
7741 case AArch64::MULv16i8:
7742 case AArch64::MULv4i16:
7743 case AArch64::MULv8i16:
7744 case AArch64::MULv2i32:
7745 case AArch64::MULv4i32:
7746 case AArch64::ANDv8i8:
7747 case AArch64::ANDv16i8:
7748 case AArch64::ORRv8i8:
7749 case AArch64::ORRv16i8:
7750 case AArch64::EORv8i8:
7751 case AArch64::EORv16i8:
7753 case AArch64::ADD_ZZZ_B:
7754 case AArch64::ADD_ZZZ_H:
7755 case AArch64::ADD_ZZZ_S:
7756 case AArch64::ADD_ZZZ_D:
7757 case AArch64::MUL_ZZZ_B:
7758 case AArch64::MUL_ZZZ_H:
7759 case AArch64::MUL_ZZZ_S:
7760 case AArch64::MUL_ZZZ_D:
7761 case AArch64::AND_ZZZ:
7762 case AArch64::ORR_ZZZ:
7763 case AArch64::EOR_ZZZ:
7794 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7802 auto setShfFound = [&](
int Opcode,
unsigned ZeroReg,
unsigned Pattern) {
7818 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7830 case AArch64::ADDWrr:
7832 "ADDWrr does not have register operands");
7833 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7834 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7836 case AArch64::ADDXrr:
7837 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7838 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7840 case AArch64::SUBWrr:
7841 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7842 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7844 case AArch64::SUBXrr:
7845 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7846 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7848 case AArch64::ADDWri:
7849 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7851 case AArch64::ADDXri:
7852 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7854 case AArch64::SUBWri:
7855 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7857 case AArch64::SUBXri:
7858 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7860 case AArch64::ADDWrs:
7861 setShfFound(AArch64::MADDWrrr, AArch64::WZR, MCP::MULADDWS_OP1);
7863 case AArch64::ADDXrs:
7864 setShfFound(AArch64::MADDXrrr, AArch64::XZR, MCP::MULADDXS_OP1);
7866 case AArch64::ADDv8i8:
7867 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7868 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7870 case AArch64::ADDv16i8:
7871 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7872 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7874 case AArch64::ADDv4i16:
7875 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7876 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7877 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7878 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7880 case AArch64::ADDv8i16:
7881 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7882 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7883 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7884 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7886 case AArch64::ADDv2i32:
7887 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7888 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7889 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7890 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7892 case AArch64::ADDv4i32:
7893 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7894 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7895 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7896 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7898 case AArch64::SUBv8i8:
7899 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7900 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7902 case AArch64::SUBv16i8:
7903 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7904 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7906 case AArch64::SUBv4i16:
7907 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7908 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7909 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7910 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7912 case AArch64::SUBv8i16:
7913 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7914 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7915 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7916 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7918 case AArch64::SUBv2i32:
7919 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7920 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7921 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7922 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7924 case AArch64::SUBv4i32:
7925 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7926 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7927 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7928 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7934bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7938 case AArch64::UABALB_ZZZ_D:
7939 case AArch64::UABALB_ZZZ_H:
7940 case AArch64::UABALB_ZZZ_S:
7941 case AArch64::UABALT_ZZZ_D:
7942 case AArch64::UABALT_ZZZ_H:
7943 case AArch64::UABALT_ZZZ_S:
7944 case AArch64::SABALB_ZZZ_D:
7945 case AArch64::SABALB_ZZZ_S:
7946 case AArch64::SABALB_ZZZ_H:
7947 case AArch64::SABALT_ZZZ_D:
7948 case AArch64::SABALT_ZZZ_S:
7949 case AArch64::SABALT_ZZZ_H:
7950 case AArch64::UABALv16i8_v8i16:
7951 case AArch64::UABALv2i32_v2i64:
7952 case AArch64::UABALv4i16_v4i32:
7953 case AArch64::UABALv4i32_v2i64:
7954 case AArch64::UABALv8i16_v4i32:
7955 case AArch64::UABALv8i8_v8i16:
7956 case AArch64::UABAv16i8:
7957 case AArch64::UABAv2i32:
7958 case AArch64::UABAv4i16:
7959 case AArch64::UABAv4i32:
7960 case AArch64::UABAv8i16:
7961 case AArch64::UABAv8i8:
7962 case AArch64::SABALv16i8_v8i16:
7963 case AArch64::SABALv2i32_v2i64:
7964 case AArch64::SABALv4i16_v4i32:
7965 case AArch64::SABALv4i32_v2i64:
7966 case AArch64::SABALv8i16_v4i32:
7967 case AArch64::SABALv8i8_v8i16:
7968 case AArch64::SABAv16i8:
7969 case AArch64::SABAv2i32:
7970 case AArch64::SABAv4i16:
7971 case AArch64::SABAv4i32:
7972 case AArch64::SABAv8i16:
7973 case AArch64::SABAv8i8:
7980unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7981 unsigned AccumulationOpcode)
const {
7982 switch (AccumulationOpcode) {
7985 case AArch64::UABALB_ZZZ_D:
7986 return AArch64::UABDLB_ZZZ_D;
7987 case AArch64::UABALB_ZZZ_H:
7988 return AArch64::UABDLB_ZZZ_H;
7989 case AArch64::UABALB_ZZZ_S:
7990 return AArch64::UABDLB_ZZZ_S;
7991 case AArch64::UABALT_ZZZ_D:
7992 return AArch64::UABDLT_ZZZ_D;
7993 case AArch64::UABALT_ZZZ_H:
7994 return AArch64::UABDLT_ZZZ_H;
7995 case AArch64::UABALT_ZZZ_S:
7996 return AArch64::UABDLT_ZZZ_S;
7997 case AArch64::UABALv16i8_v8i16:
7998 return AArch64::UABDLv16i8_v8i16;
7999 case AArch64::UABALv2i32_v2i64:
8000 return AArch64::UABDLv2i32_v2i64;
8001 case AArch64::UABALv4i16_v4i32:
8002 return AArch64::UABDLv4i16_v4i32;
8003 case AArch64::UABALv4i32_v2i64:
8004 return AArch64::UABDLv4i32_v2i64;
8005 case AArch64::UABALv8i16_v4i32:
8006 return AArch64::UABDLv8i16_v4i32;
8007 case AArch64::UABALv8i8_v8i16:
8008 return AArch64::UABDLv8i8_v8i16;
8009 case AArch64::UABAv16i8:
8010 return AArch64::UABDv16i8;
8011 case AArch64::UABAv2i32:
8012 return AArch64::UABDv2i32;
8013 case AArch64::UABAv4i16:
8014 return AArch64::UABDv4i16;
8015 case AArch64::UABAv4i32:
8016 return AArch64::UABDv4i32;
8017 case AArch64::UABAv8i16:
8018 return AArch64::UABDv8i16;
8019 case AArch64::UABAv8i8:
8020 return AArch64::UABDv8i8;
8021 case AArch64::SABALB_ZZZ_D:
8022 return AArch64::SABDLB_ZZZ_D;
8023 case AArch64::SABALB_ZZZ_S:
8024 return AArch64::SABDLB_ZZZ_S;
8025 case AArch64::SABALB_ZZZ_H:
8026 return AArch64::SABDLB_ZZZ_H;
8027 case AArch64::SABALT_ZZZ_D:
8028 return AArch64::SABDLT_ZZZ_D;
8029 case AArch64::SABALT_ZZZ_S:
8030 return AArch64::SABDLT_ZZZ_S;
8031 case AArch64::SABALT_ZZZ_H:
8032 return AArch64::SABDLT_ZZZ_H;
8033 case AArch64::SABALv16i8_v8i16:
8034 return AArch64::SABDLv16i8_v8i16;
8035 case AArch64::SABALv2i32_v2i64:
8036 return AArch64::SABDLv2i32_v2i64;
8037 case AArch64::SABALv4i16_v4i32:
8038 return AArch64::SABDLv4i16_v4i32;
8039 case AArch64::SABALv4i32_v2i64:
8040 return AArch64::SABDLv4i32_v2i64;
8041 case AArch64::SABALv8i16_v4i32:
8042 return AArch64::SABDLv8i16_v4i32;
8043 case AArch64::SABALv8i8_v8i16:
8044 return AArch64::SABDLv8i8_v8i16;
8045 case AArch64::SABAv16i8:
8046 return AArch64::SABDv16i8;
8047 case AArch64::SABAv2i32:
8048 return AArch64::SABDv2i32;
8049 case AArch64::SABAv4i16:
8050 return AArch64::SABDv4i16;
8051 case AArch64::SABAv4i32:
8052 return AArch64::SABDv4i32;
8053 case AArch64::SABAv8i16:
8054 return AArch64::SABDv8i16;
8055 case AArch64::SABAv8i8:
8056 return AArch64::SABDv8i8;
8072 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
8084 assert(
false &&
"Unsupported FP instruction in combiner\n");
8086 case AArch64::FADDHrr:
8088 "FADDHrr does not have register operands");
8090 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
8091 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
8093 case AArch64::FADDSrr:
8095 "FADDSrr does not have register operands");
8097 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
8098 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
8100 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
8101 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
8103 case AArch64::FADDDrr:
8104 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
8105 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
8107 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8108 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8110 case AArch64::FADDv4f16:
8111 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8112 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8114 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8115 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8117 case AArch64::FADDv8f16:
8118 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8119 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8121 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8122 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8124 case AArch64::FADDv2f32:
8125 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8126 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8128 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8129 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8131 case AArch64::FADDv2f64:
8132 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8133 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8135 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8136 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8138 case AArch64::FADDv4f32:
8139 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8140 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8142 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8143 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8145 case AArch64::FSUBHrr:
8146 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8147 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8148 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8150 case AArch64::FSUBSrr:
8151 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8153 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8154 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8156 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8158 case AArch64::FSUBDrr:
8159 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8161 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8162 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8164 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8166 case AArch64::FSUBv4f16:
8167 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8168 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8170 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8171 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8173 case AArch64::FSUBv8f16:
8174 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8175 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8177 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8178 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8180 case AArch64::FSUBv2f32:
8181 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8182 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8184 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8185 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8187 case AArch64::FSUBv2f64:
8188 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8189 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8191 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8192 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8194 case AArch64::FSUBv4f32:
8195 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8196 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8198 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8199 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8210 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8217 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8218 MI->getOperand(1).getReg().isVirtual())
8220 if (
MI &&
MI->getOpcode() == Opcode) {
8232 case AArch64::FMULv2f32:
8233 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8234 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8236 case AArch64::FMULv2f64:
8237 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8238 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8240 case AArch64::FMULv4f16:
8241 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8242 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8244 case AArch64::FMULv4f32:
8245 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8246 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8248 case AArch64::FMULv8f16:
8249 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8250 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8263 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8266 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8281 case AArch64::FNEGDr:
8283 case AArch64::FNEGSr:
8415 case AArch64::SUBWrr:
8416 case AArch64::SUBSWrr:
8417 case AArch64::SUBXrr:
8418 case AArch64::SUBSXrr:
8463 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8486 while (!RemainingLanes.
empty() && CurrInstr &&
8487 CurrInstr->getOpcode() == LoadLaneOpCode &&
8489 CurrInstr->getNumOperands() == 4) {
8490 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8496 if (!RemainingLanes.
empty())
8500 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8504 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8505 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8506 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8520 unsigned RemainingSteps =
8523 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8526 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8527 !RemainingLoadInstrs.
empty();
8528 --MBBItr, --RemainingSteps) {
8532 RemainingLoadInstrs.
erase(&CurrInstr);
8542 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8568 case AArch64::LD1i32:
8570 case AArch64::LD1i16:
8572 case AArch64::LD1i8:
8588 unsigned Pattern,
unsigned NumLanes) {
8596 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8604 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8610 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8616 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8617 Register SrcRegister,
unsigned Lane,
8627 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8628 InsInstrs.
push_back(LoadIndexIntoRegister);
8634 auto CreateLDRInstruction =
8640 Opcode = AArch64::LDRSui;
8643 Opcode = AArch64::LDRHui;
8646 Opcode = AArch64::LDRBui;
8650 "Got unsupported number of lanes in machine-combiner gather pattern");
8660 auto LanesToLoadToReg0 =
8662 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8663 Register PrevReg = SubregToReg->getOperand(0).getReg();
8665 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8666 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8667 OffsetRegOperand.
getReg());
8674 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8676 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8683 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8684 OriginalSplitToLoadOffsetOperand.
getReg(),
8687 InstrIdxForVirtReg.
insert(
8688 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8689 InsInstrs.
push_back(MiddleIndexLoadInstr);
8694 unsigned SubregType;
8697 SubregType = AArch64::ssub;
8700 SubregType = AArch64::hsub;
8703 SubregType = AArch64::bsub;
8707 "Got invalid NumLanes for machine-combiner gather pattern");
8710 auto SubRegToRegInstr =
8712 DestRegForSubregToReg)
8713 .
addReg(DestRegForMiddleIndex)
8715 InstrIdxForVirtReg.
insert(
8716 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8720 auto LanesToLoadToReg1 =
8722 LoadToLaneInstrsAscending.end());
8723 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8725 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8726 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8727 OffsetRegOperand.
getReg());
8730 if (Index == NumLanes / 2 - 2) {
8765bool AArch64InstrInfo::getMachineCombinerPatterns(
8767 bool DoRegPressureReduce)
const {
8788 DoRegPressureReduce);
8817 const Register *ReplacedAddend =
nullptr) {
8818 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8820 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8823 Register SrcReg0 = MUL->getOperand(1).getReg();
8824 Register SrcReg1 = MUL->getOperand(2).getReg();
8849 .
addImm(MUL->getOperand(3).getImm());
8856 assert(
false &&
"Invalid FMA instruction kind \n");
8871 unsigned MaddOpc,
bool Is64Bit,
8874 Is64Bit ? &AArch64::GPR64RegClass : &AArch64::GPR32RegClass;
8877 Register SrcReg0 = MUL->getOperand(1).getReg();
8878 Register SrcReg1 = MUL->getOperand(2).getReg();
8892 unsigned RegSize = Is64Bit ? 64 : 32;
8894 unsigned ImmR, ImmS;
8897 BFMOpc = Is64Bit ? AArch64::SBFMXri : AArch64::SBFMWri;
8902 BFMOpc = Is64Bit ? AArch64::UBFMXri : AArch64::UBFMWri;
8907 BFMOpc = Is64Bit ? AArch64::UBFMXri : AArch64::UBFMWri;
8909 ImmS =
RegSize - 1 - ShiftVal;
8921 InstrIdxForVirtReg.
insert(std::make_pair(ShiftReg, InsInstrs.
size()));
8947 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8948 Opc = AArch64::FNMADDSrrr;
8949 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8950 Opc = AArch64::FNMADDDrrr;
8981 unsigned IdxDupOp,
unsigned MulOpc,
8983 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8984 "Invalid index of FMUL operand");
8992 if (Dup->
getOpcode() == TargetOpcode::COPY)
9001 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
9042 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9057 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9084 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9112 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
9114 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
9118 Register SrcReg0 = MUL->getOperand(1).getReg();
9119 Register SrcReg1 = MUL->getOperand(2).getReg();
9149 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
9150 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
9161 if (Opcode == AArch64::SUBSWrr)
9162 Opcode = AArch64::SUBWrr;
9163 else if (Opcode == AArch64::SUBSXrr)
9164 Opcode = AArch64::SUBXrr;
9166 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9167 "Unexpected instruction opcode.");
9184 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9191unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9192 unsigned int AccumulatorOpCode)
const {
9193 switch (AccumulatorOpCode) {
9194 case AArch64::UABALB_ZZZ_D:
9195 case AArch64::SABALB_ZZZ_D:
9196 case AArch64::UABALT_ZZZ_D:
9197 case AArch64::SABALT_ZZZ_D:
9198 return AArch64::ADD_ZZZ_D;
9199 case AArch64::UABALB_ZZZ_H:
9200 case AArch64::SABALB_ZZZ_H:
9201 case AArch64::UABALT_ZZZ_H:
9202 case AArch64::SABALT_ZZZ_H:
9203 return AArch64::ADD_ZZZ_H;
9204 case AArch64::UABALB_ZZZ_S:
9205 case AArch64::SABALB_ZZZ_S:
9206 case AArch64::UABALT_ZZZ_S:
9207 case AArch64::SABALT_ZZZ_S:
9208 return AArch64::ADD_ZZZ_S;
9209 case AArch64::UABALv16i8_v8i16:
9210 case AArch64::SABALv8i8_v8i16:
9211 case AArch64::SABAv8i16:
9212 case AArch64::UABAv8i16:
9213 return AArch64::ADDv8i16;
9214 case AArch64::SABALv2i32_v2i64:
9215 case AArch64::UABALv2i32_v2i64:
9216 case AArch64::SABALv4i32_v2i64:
9217 return AArch64::ADDv2i64;
9218 case AArch64::UABALv4i16_v4i32:
9219 case AArch64::SABALv4i16_v4i32:
9220 case AArch64::SABALv8i16_v4i32:
9221 case AArch64::SABAv4i32:
9222 case AArch64::UABAv4i32:
9223 return AArch64::ADDv4i32;
9224 case AArch64::UABALv4i32_v2i64:
9225 return AArch64::ADDv2i64;
9226 case AArch64::UABALv8i16_v4i32:
9227 return AArch64::ADDv4i32;
9228 case AArch64::UABALv8i8_v8i16:
9229 case AArch64::SABALv16i8_v8i16:
9230 return AArch64::ADDv8i16;
9231 case AArch64::UABAv16i8:
9232 case AArch64::SABAv16i8:
9233 return AArch64::ADDv16i8;
9234 case AArch64::UABAv4i16:
9235 case AArch64::SABAv4i16:
9236 return AArch64::ADDv4i16;
9237 case AArch64::UABAv2i32:
9238 case AArch64::SABAv2i32:
9239 return AArch64::ADDv2i32;
9240 case AArch64::UABAv8i8:
9241 case AArch64::SABAv8i8:
9242 return AArch64::ADDv8i8;
9251void AArch64InstrInfo::genAlternativeCodeSequence(
9261 MachineInstr *
MUL =
nullptr;
9268 DelInstrs, InstrIdxForVirtReg);
9274 InstrIdxForVirtReg);
9280 InstrIdxForVirtReg);
9289 Opc = AArch64::MADDWrrr;
9290 RC = &AArch64::GPR32RegClass;
9292 Opc = AArch64::MADDXrrr;
9293 RC = &AArch64::GPR64RegClass;
9304 Opc = AArch64::MADDWrrr;
9305 RC = &AArch64::GPR32RegClass;
9307 Opc = AArch64::MADDXrrr;
9308 RC = &AArch64::GPR64RegClass;
9322 unsigned BitSize, MovImm;
9325 MovImm = AArch64::MOVi32imm;
9326 RC = &AArch64::GPR32spRegClass;
9328 Opc = AArch64::MADDWrrr;
9329 RC = &AArch64::GPR32RegClass;
9331 MovImm = AArch64::MOVi64imm;
9332 RC = &AArch64::GPR64spRegClass;
9334 Opc = AArch64::MADDXrrr;
9335 RC = &AArch64::GPR64RegClass;
9350 if (Insn.
size() != 1)
9352 MachineInstrBuilder MIB1 =
9353 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9356 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9368 unsigned SubOpc, ZeroReg;
9370 SubOpc = AArch64::SUBWrr;
9371 SubRC = &AArch64::GPR32spRegClass;
9372 ZeroReg = AArch64::WZR;
9373 Opc = AArch64::MADDWrrr;
9374 RC = &AArch64::GPR32RegClass;
9376 SubOpc = AArch64::SUBXrr;
9377 SubRC = &AArch64::GPR64spRegClass;
9378 ZeroReg = AArch64::XZR;
9379 Opc = AArch64::MADDXrrr;
9380 RC = &AArch64::GPR64RegClass;
9384 MachineInstrBuilder MIB1 =
9385 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9389 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9400 Opc = AArch64::MSUBWrrr;
9401 RC = &AArch64::GPR32RegClass;
9403 Opc = AArch64::MSUBXrrr;
9404 RC = &AArch64::GPR64RegClass;
9409 genMaddShf(MF, MRI,
TII, Root, InsInstrs, DelInstrs, AArch64::MADDWrrr,
9410 false, InstrIdxForVirtReg);
9413 genMaddShf(MF, MRI,
TII, Root, InsInstrs, DelInstrs, AArch64::MADDXrrr,
9414 true, InstrIdxForVirtReg);
9417 Opc = AArch64::MLAv8i8;
9418 RC = &AArch64::FPR64RegClass;
9422 Opc = AArch64::MLAv8i8;
9423 RC = &AArch64::FPR64RegClass;
9427 Opc = AArch64::MLAv16i8;
9428 RC = &AArch64::FPR128RegClass;
9432 Opc = AArch64::MLAv16i8;
9433 RC = &AArch64::FPR128RegClass;
9437 Opc = AArch64::MLAv4i16;
9438 RC = &AArch64::FPR64RegClass;
9442 Opc = AArch64::MLAv4i16;
9443 RC = &AArch64::FPR64RegClass;
9447 Opc = AArch64::MLAv8i16;
9448 RC = &AArch64::FPR128RegClass;
9452 Opc = AArch64::MLAv8i16;
9453 RC = &AArch64::FPR128RegClass;
9457 Opc = AArch64::MLAv2i32;
9458 RC = &AArch64::FPR64RegClass;
9462 Opc = AArch64::MLAv2i32;
9463 RC = &AArch64::FPR64RegClass;
9467 Opc = AArch64::MLAv4i32;
9468 RC = &AArch64::FPR128RegClass;
9472 Opc = AArch64::MLAv4i32;
9473 RC = &AArch64::FPR128RegClass;
9478 Opc = AArch64::MLAv8i8;
9479 RC = &AArch64::FPR64RegClass;
9481 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9485 Opc = AArch64::MLSv8i8;
9486 RC = &AArch64::FPR64RegClass;
9490 Opc = AArch64::MLAv16i8;
9491 RC = &AArch64::FPR128RegClass;
9493 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9497 Opc = AArch64::MLSv16i8;
9498 RC = &AArch64::FPR128RegClass;
9502 Opc = AArch64::MLAv4i16;
9503 RC = &AArch64::FPR64RegClass;
9505 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9509 Opc = AArch64::MLSv4i16;
9510 RC = &AArch64::FPR64RegClass;
9514 Opc = AArch64::MLAv8i16;
9515 RC = &AArch64::FPR128RegClass;
9517 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9521 Opc = AArch64::MLSv8i16;
9522 RC = &AArch64::FPR128RegClass;
9526 Opc = AArch64::MLAv2i32;
9527 RC = &AArch64::FPR64RegClass;
9529 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9533 Opc = AArch64::MLSv2i32;
9534 RC = &AArch64::FPR64RegClass;
9538 Opc = AArch64::MLAv4i32;
9539 RC = &AArch64::FPR128RegClass;
9541 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9545 Opc = AArch64::MLSv4i32;
9546 RC = &AArch64::FPR128RegClass;
9551 Opc = AArch64::MLAv4i16_indexed;
9552 RC = &AArch64::FPR64RegClass;
9556 Opc = AArch64::MLAv4i16_indexed;
9557 RC = &AArch64::FPR64RegClass;
9561 Opc = AArch64::MLAv8i16_indexed;
9562 RC = &AArch64::FPR128RegClass;
9566 Opc = AArch64::MLAv8i16_indexed;
9567 RC = &AArch64::FPR128RegClass;
9571 Opc = AArch64::MLAv2i32_indexed;
9572 RC = &AArch64::FPR64RegClass;
9576 Opc = AArch64::MLAv2i32_indexed;
9577 RC = &AArch64::FPR64RegClass;
9581 Opc = AArch64::MLAv4i32_indexed;
9582 RC = &AArch64::FPR128RegClass;
9586 Opc = AArch64::MLAv4i32_indexed;
9587 RC = &AArch64::FPR128RegClass;
9592 Opc = AArch64::MLAv4i16_indexed;
9593 RC = &AArch64::FPR64RegClass;
9595 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9599 Opc = AArch64::MLSv4i16_indexed;
9600 RC = &AArch64::FPR64RegClass;
9604 Opc = AArch64::MLAv8i16_indexed;
9605 RC = &AArch64::FPR128RegClass;
9607 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9611 Opc = AArch64::MLSv8i16_indexed;
9612 RC = &AArch64::FPR128RegClass;
9616 Opc = AArch64::MLAv2i32_indexed;
9617 RC = &AArch64::FPR64RegClass;
9619 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9623 Opc = AArch64::MLSv2i32_indexed;
9624 RC = &AArch64::FPR64RegClass;
9628 Opc = AArch64::MLAv4i32_indexed;
9629 RC = &AArch64::FPR128RegClass;
9631 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9635 Opc = AArch64::MLSv4i32_indexed;
9636 RC = &AArch64::FPR128RegClass;
9642 Opc = AArch64::FMADDHrrr;
9643 RC = &AArch64::FPR16RegClass;
9647 Opc = AArch64::FMADDSrrr;
9648 RC = &AArch64::FPR32RegClass;
9652 Opc = AArch64::FMADDDrrr;
9653 RC = &AArch64::FPR64RegClass;
9658 Opc = AArch64::FMADDHrrr;
9659 RC = &AArch64::FPR16RegClass;
9663 Opc = AArch64::FMADDSrrr;
9664 RC = &AArch64::FPR32RegClass;
9668 Opc = AArch64::FMADDDrrr;
9669 RC = &AArch64::FPR64RegClass;
9674 Opc = AArch64::FMLAv1i32_indexed;
9675 RC = &AArch64::FPR32RegClass;
9680 Opc = AArch64::FMLAv1i32_indexed;
9681 RC = &AArch64::FPR32RegClass;
9687 Opc = AArch64::FMLAv1i64_indexed;
9688 RC = &AArch64::FPR64RegClass;
9693 Opc = AArch64::FMLAv1i64_indexed;
9694 RC = &AArch64::FPR64RegClass;
9700 RC = &AArch64::FPR64RegClass;
9701 Opc = AArch64::FMLAv4i16_indexed;
9706 RC = &AArch64::FPR64RegClass;
9707 Opc = AArch64::FMLAv4f16;
9712 RC = &AArch64::FPR64RegClass;
9713 Opc = AArch64::FMLAv4i16_indexed;
9718 RC = &AArch64::FPR64RegClass;
9719 Opc = AArch64::FMLAv4f16;
9726 RC = &AArch64::FPR64RegClass;
9728 Opc = AArch64::FMLAv2i32_indexed;
9732 Opc = AArch64::FMLAv2f32;
9739 RC = &AArch64::FPR64RegClass;
9741 Opc = AArch64::FMLAv2i32_indexed;
9745 Opc = AArch64::FMLAv2f32;
9752 RC = &AArch64::FPR128RegClass;
9753 Opc = AArch64::FMLAv8i16_indexed;
9758 RC = &AArch64::FPR128RegClass;
9759 Opc = AArch64::FMLAv8f16;
9764 RC = &AArch64::FPR128RegClass;
9765 Opc = AArch64::FMLAv8i16_indexed;
9770 RC = &AArch64::FPR128RegClass;
9771 Opc = AArch64::FMLAv8f16;
9778 RC = &AArch64::FPR128RegClass;
9780 Opc = AArch64::FMLAv2i64_indexed;
9784 Opc = AArch64::FMLAv2f64;
9791 RC = &AArch64::FPR128RegClass;
9793 Opc = AArch64::FMLAv2i64_indexed;
9797 Opc = AArch64::FMLAv2f64;
9805 RC = &AArch64::FPR128RegClass;
9807 Opc = AArch64::FMLAv4i32_indexed;
9811 Opc = AArch64::FMLAv4f32;
9819 RC = &AArch64::FPR128RegClass;
9821 Opc = AArch64::FMLAv4i32_indexed;
9825 Opc = AArch64::FMLAv4f32;
9832 Opc = AArch64::FNMSUBHrrr;
9833 RC = &AArch64::FPR16RegClass;
9837 Opc = AArch64::FNMSUBSrrr;
9838 RC = &AArch64::FPR32RegClass;
9842 Opc = AArch64::FNMSUBDrrr;
9843 RC = &AArch64::FPR64RegClass;
9848 Opc = AArch64::FNMADDHrrr;
9849 RC = &AArch64::FPR16RegClass;
9853 Opc = AArch64::FNMADDSrrr;
9854 RC = &AArch64::FPR32RegClass;
9858 Opc = AArch64::FNMADDDrrr;
9859 RC = &AArch64::FPR64RegClass;
9864 Opc = AArch64::FMSUBHrrr;
9865 RC = &AArch64::FPR16RegClass;
9869 Opc = AArch64::FMSUBSrrr;
9870 RC = &AArch64::FPR32RegClass;
9874 Opc = AArch64::FMSUBDrrr;
9875 RC = &AArch64::FPR64RegClass;
9880 Opc = AArch64::FMLSv1i32_indexed;
9881 RC = &AArch64::FPR32RegClass;
9887 Opc = AArch64::FMLSv1i64_indexed;
9888 RC = &AArch64::FPR64RegClass;
9895 RC = &AArch64::FPR64RegClass;
9897 MachineInstrBuilder MIB1 =
9898 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9901 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9903 Opc = AArch64::FMLAv4f16;
9907 Opc = AArch64::FMLAv4i16_indexed;
9914 RC = &AArch64::FPR64RegClass;
9915 Opc = AArch64::FMLSv4f16;
9920 RC = &AArch64::FPR64RegClass;
9921 Opc = AArch64::FMLSv4i16_indexed;
9928 RC = &AArch64::FPR64RegClass;
9930 Opc = AArch64::FMLSv2i32_indexed;
9934 Opc = AArch64::FMLSv2f32;
9942 RC = &AArch64::FPR128RegClass;
9944 MachineInstrBuilder MIB1 =
9945 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9948 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9950 Opc = AArch64::FMLAv8f16;
9954 Opc = AArch64::FMLAv8i16_indexed;
9961 RC = &AArch64::FPR128RegClass;
9962 Opc = AArch64::FMLSv8f16;
9967 RC = &AArch64::FPR128RegClass;
9968 Opc = AArch64::FMLSv8i16_indexed;
9975 RC = &AArch64::FPR128RegClass;
9977 Opc = AArch64::FMLSv2i64_indexed;
9981 Opc = AArch64::FMLSv2f64;
9989 RC = &AArch64::FPR128RegClass;
9991 Opc = AArch64::FMLSv4i32_indexed;
9995 Opc = AArch64::FMLSv4f32;
10002 RC = &AArch64::FPR64RegClass;
10004 MachineInstrBuilder MIB1 =
10005 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
10008 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10010 Opc = AArch64::FMLAv2i32_indexed;
10014 Opc = AArch64::FMLAv2f32;
10022 RC = &AArch64::FPR128RegClass;
10024 MachineInstrBuilder MIB1 =
10025 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
10028 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10030 Opc = AArch64::FMLAv4i32_indexed;
10034 Opc = AArch64::FMLAv4f32;
10042 RC = &AArch64::FPR128RegClass;
10044 MachineInstrBuilder MIB1 =
10045 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
10048 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
10050 Opc = AArch64::FMLAv2i64_indexed;
10054 Opc = AArch64::FMLAv2f64;
10062 unsigned IdxDupOp =
10066 &AArch64::FPR128RegClass, MRI);
10071 unsigned IdxDupOp =
10075 &AArch64::FPR128RegClass, MRI);
10080 unsigned IdxDupOp =
10084 &AArch64::FPR128_loRegClass, MRI);
10089 unsigned IdxDupOp =
10093 &AArch64::FPR128RegClass, MRI);
10098 unsigned IdxDupOp =
10102 &AArch64::FPR128_loRegClass, MRI);
10136 for (
auto *
MI : InsInstrs)
10137 MI->setFlags(Flags);
10178 bool IsNegativeBranch =
false;
10179 bool IsTestAndBranch =
false;
10180 unsigned TargetBBInMI = 0;
10181 switch (
MI.getOpcode()) {
10185 case AArch64::CBWPri:
10186 case AArch64::CBXPri:
10187 case AArch64::CBBAssertExt:
10188 case AArch64::CBHAssertExt:
10189 case AArch64::CBWPrr:
10190 case AArch64::CBXPrr:
10192 case AArch64::CBZW:
10193 case AArch64::CBZX:
10196 case AArch64::CBNZW:
10197 case AArch64::CBNZX:
10199 IsNegativeBranch =
true;
10201 case AArch64::TBZW:
10202 case AArch64::TBZX:
10204 IsTestAndBranch =
true;
10206 case AArch64::TBNZW:
10207 case AArch64::TBNZX:
10209 IsNegativeBranch =
true;
10210 IsTestAndBranch =
true;
10216 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10220 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10233 while (
DefMI->isCopy()) {
10244 switch (
DefMI->getOpcode()) {
10248 case AArch64::ANDWri:
10249 case AArch64::ANDXri: {
10250 if (IsTestAndBranch)
10257 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10259 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10275 unsigned Opc = (
Imm < 32)
10276 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10277 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10290 if (!Is32Bit &&
Imm < 32)
10292 MI.eraseFromParent();
10296 case AArch64::CSINCWr:
10297 case AArch64::CSINCXr: {
10298 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10299 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10300 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10301 DefMI->getOperand(2).getReg() == AArch64::XZR))
10304 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10317 if (IsNegativeBranch)
10320 MI.eraseFromParent();
10326std::pair<unsigned, unsigned>
10327AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10329 return std::make_pair(TF & Mask, TF & ~Mask);
10333AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10336 static const std::pair<unsigned, const char *> TargetFlags[] = {
10337 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10338 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10339 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10345AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10346 using namespace AArch64II;
10348 static const std::pair<unsigned, const char *> TargetFlags[] = {
10350 {
MO_GOT,
"aarch64-got"},
10351 {
MO_NC,
"aarch64-nc"},
10352 {
MO_S,
"aarch64-s"},
10353 {
MO_TLS,
"aarch64-tls"},
10363AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10364 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10474 .outliner_compact_unwind_frame &&
10500 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10515 return C.isAvailableInsideSeq(AArch64::FP,
TRI);
10523 const AArch64RegisterInfo *ARI =
10524 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10527 for (
unsigned Reg : AArch64::GPR64RegClass) {
10529 Reg != AArch64::LR &&
10530 Reg != AArch64::X16 &&
10531 Reg != AArch64::X17 &&
10532 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10533 C.isAvailableInsideSeq(
Reg,
TRI))
10564 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10567std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10568AArch64InstrInfo::getOutliningCandidateInfo(
10570 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10571 unsigned MinRepeats)
const {
10572 unsigned SequenceSize = 0;
10573 for (
auto &
MI : RepeatedSequenceLocs[0])
10576 unsigned NumBytesToCreateFrame = 0;
10582 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10583 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10584 if (LastMI.
getOpcode() == AArch64::ADRP &&
10587 return std::nullopt;
10592 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10593 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10596 return std::nullopt;
10607 if (std::adjacent_find(
10608 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10609 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10612 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10613 outliningCandidatesSigningKeyConsensus(a, b) &&
10614 outliningCandidatesV8_3OpsConsensus(a, b)) {
10618 }) != RepeatedSequenceLocs.end()) {
10619 return std::nullopt;
10636 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10637 const auto RASignCondition = RepeatedSequenceLocs[0]
10640 ->getSignReturnAddressCondition();
10653 ->shouldHardenSignReturnAddress();
10656 if (RepeatedSequenceLocs.size() < MinRepeats)
10657 return std::nullopt;
10660 NumBytesToCreateFrame += 8;
10663 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10664 *RepeatedSequenceLocs[0].getMF());
10665 NumBytesToCheckLRInTCEpilogue =
10669 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10670 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10678 for (
auto &
MI :
C) {
10679 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10680 switch (
MI.getOpcode()) {
10681 case AArch64::ADDXri:
10682 case AArch64::ADDWri:
10683 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10684 assert(
MI.getOperand(2).isImm() &&
10685 "Expected operand to be immediate");
10686 assert(
MI.getOperand(1).isReg() &&
10687 "Expected operand to be a register");
10691 if (
MI.getOperand(1).getReg() == AArch64::SP)
10692 SPValue +=
MI.getOperand(2).getImm();
10696 case AArch64::SUBXri:
10697 case AArch64::SUBWri:
10698 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10699 assert(
MI.getOperand(2).isImm() &&
10700 "Expected operand to be immediate");
10701 assert(
MI.getOperand(1).isReg() &&
10702 "Expected operand to be a register");
10706 if (
MI.getOperand(1).getReg() == AArch64::SP)
10707 SPValue -=
MI.getOperand(2).getImm();
10724 if (RepeatedSequenceLocs.size() < MinRepeats)
10725 return std::nullopt;
10729 unsigned FlagsSetInAll = 0xF;
10733 FlagsSetInAll &=
C.Flags;
10735 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10738 auto SetCandidateCallInfo =
10739 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10741 C.setCallInfo(CallID, NumBytesForCall);
10745 NumBytesToCreateFrame += 4;
10753 unsigned CFICount = 0;
10754 for (
auto &
I : RepeatedSequenceLocs[0]) {
10755 if (
I.isCFIInstruction())
10765 std::vector<MCCFIInstruction> CFIInstructions =
10766 C.getMF()->getFrameInstructions();
10768 if (CFICount > 0 && CFICount != CFIInstructions.size())
10769 return std::nullopt;
10777 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10778 !
MI.readsRegister(AArch64::SP, &
TRI))
10784 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10789 if (
MI.mayLoadOrStore()) {
10792 bool OffsetIsScalable;
10796 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable) ||
10797 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10801 if (OffsetIsScalable)
10809 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10810 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10813 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10814 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10829 bool AllStackInstrsSafe =
10834 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10836 NumBytesToCreateFrame = 0;
10837 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10841 else if (LastInstrOpcode == AArch64::BL ||
10842 ((LastInstrOpcode == AArch64::BLR ||
10843 LastInstrOpcode == AArch64::BLRNoIP) &&
10847 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10855 unsigned NumBytesNoStackCalls = 0;
10856 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10862 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10871 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10874 if (LRAvailable && !IsNoReturn) {
10875 NumBytesNoStackCalls += 4;
10877 CandidatesWithoutStackFixups.push_back(
C);
10882 else if (findRegisterToSaveLRTo(
C)) {
10883 NumBytesNoStackCalls += 12;
10885 CandidatesWithoutStackFixups.push_back(
C);
10890 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10891 NumBytesNoStackCalls += 12;
10893 CandidatesWithoutStackFixups.push_back(
C);
10899 NumBytesNoStackCalls += SequenceSize;
10906 if (!AllStackInstrsSafe ||
10907 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10908 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10910 if (RepeatedSequenceLocs.size() < MinRepeats)
10911 return std::nullopt;
10964 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10965 !findRegisterToSaveLRTo(
C));
10971 if (RepeatedSequenceLocs.size() < MinRepeats)
10972 return std::nullopt;
10981 bool ModStackToSaveLR =
false;
10984 ModStackToSaveLR =
true;
10993 ModStackToSaveLR =
true;
10995 if (ModStackToSaveLR) {
10997 if (!AllStackInstrsSafe)
10998 return std::nullopt;
11001 NumBytesToCreateFrame += 8;
11005 RepeatedSequenceLocs,
TRI))
11006 NumBytesToCreateFrame += 4;
11013 return std::nullopt;
11015 return std::make_unique<outliner::OutlinedFunction>(
11016 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
11019void AArch64InstrInfo::mergeOutliningCandidateAttributes(
11020 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
11024 const auto &CFn = Candidates.front().getMF()->getFunction();
11026 if (CFn.hasFnAttribute(
"ptrauth-returns"))
11027 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
11028 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
11029 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
11032 if (CFn.hasFnAttribute(
"sign-return-address"))
11033 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
11034 if (CFn.hasFnAttribute(
"sign-return-address-key"))
11035 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
11040 ->getInfo<AArch64FunctionInfo>()
11041 ->shouldHardenSignReturnAddress();
11044 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
11047bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
11050 OutlineFromLinkOnceODRs))
11056 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
11057 if (!AFI || AFI->
hasRedZone().value_or(
true))
11077 unsigned &Flags)
const {
11079 "Must track liveness!");
11081 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
11096 auto AreAllUnsafeRegsDead = [&LRU]() {
11097 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
11098 LRU.available(AArch64::NZCV);
11113 bool LRAvailableEverywhere =
true;
11115 LRU.addLiveOuts(
MBB);
11117 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
11118 if (
MI.isCall() && !
MI.isTerminator())
11124 auto CreateNewRangeStartingAt =
11125 [&RangeBegin, &RangeEnd,
11127 RangeBegin = NewBegin;
11128 RangeEnd = std::next(RangeBegin);
11131 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
11137 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
11139 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
11141 Ranges.emplace_back(RangeBegin, RangeEnd);
11149 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
11150 if (!FirstPossibleEndPt->isDebugInstr())
11151 LRU.stepBackward(*FirstPossibleEndPt);
11154 UpdateWholeMBBFlags(*FirstPossibleEndPt);
11155 if (AreAllUnsafeRegsDead())
11162 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
11170 LRU.stepBackward(
MI);
11171 UpdateWholeMBBFlags(
MI);
11172 if (!AreAllUnsafeRegsDead()) {
11173 SaveRangeIfNonEmpty();
11174 CreateNewRangeStartingAt(
MI.getIterator());
11177 LRAvailableEverywhere &= LRU.available(AArch64::LR);
11180 RangeBegin =
MI.getIterator();
11185 if (AreAllUnsafeRegsDead())
11186 SaveRangeIfNonEmpty();
11194 if (!LRAvailableEverywhere)
11202 unsigned Flags)
const {
11203 MachineInstr &
MI = *MIT;
11207 switch (
MI.getOpcode()) {
11208 case AArch64::PACM:
11209 case AArch64::PACIASP:
11210 case AArch64::PACIBSP:
11211 case AArch64::PACIASPPC:
11212 case AArch64::PACIBSPPC:
11213 case AArch64::AUTIASP:
11214 case AArch64::AUTIBSP:
11215 case AArch64::AUTIASPPCi:
11216 case AArch64::AUTIASPPCr:
11217 case AArch64::AUTIBSPPCi:
11218 case AArch64::AUTIBSPPCr:
11219 case AArch64::RETAA:
11220 case AArch64::RETAB:
11221 case AArch64::RETAASPPCi:
11222 case AArch64::RETAASPPCr:
11223 case AArch64::RETABSPPCi:
11224 case AArch64::RETABSPPCr:
11225 case AArch64::EMITBKEY:
11226 case AArch64::PAUTH_PROLOGUE:
11227 case AArch64::PAUTH_EPILOGUE:
11237 if (
MI.isCFIInstruction())
11241 if (
MI.isTerminator())
11247 for (
const MachineOperand &MOP :
MI.operands()) {
11250 assert(!MOP.isCFIIndex());
11253 if (MOP.isReg() && !MOP.isImplicit() &&
11254 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11261 if (
MI.getOpcode() == AArch64::ADRP)
11281 for (
const MachineOperand &MOP :
MI.operands()) {
11282 if (MOP.isGlobal()) {
11290 if (Callee &&
Callee->getName() ==
"\01_mcount")
11298 if (
MI.getOpcode() == AArch64::BLR ||
11299 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11303 return UnknownCallOutlineType;
11311 return UnknownCallOutlineType;
11319 return UnknownCallOutlineType;
11340 for (MachineInstr &
MI :
MBB) {
11341 const MachineOperand *
Base;
11342 TypeSize Width(0,
false);
11344 bool OffsetIsScalable;
11347 if (!
MI.mayLoadOrStore() ||
11350 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11354 TypeSize Scale(0U,
false);
11355 int64_t Dummy1, Dummy2;
11358 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11360 assert(Scale != 0 &&
"Unexpected opcode!");
11361 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11366 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11367 StackOffsetOperand.
setImm(NewImm);
11373 bool ShouldSignReturnAddr) {
11374 if (!ShouldSignReturnAddr)
11382void AArch64InstrInfo::buildOutlinedFrame(
11386 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11394 unsigned TailOpcode;
11396 TailOpcode = AArch64::TCRETURNdi;
11400 TailOpcode = AArch64::TCRETURNriALL;
11411 bool IsLeafFunction =
true;
11414 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11415 return MI.isCall() && !
MI.isReturn();
11425 "Can only fix up stack references once");
11426 fixupPostOutline(
MBB);
11428 IsLeafFunction =
false;
11439 Et = std::prev(
MBB.
end());
11470 CFIBuilder.buildDefCFA(AArch64::FP, 16);
11471 CFIBuilder.buildOffset(AArch64::LR, -8);
11472 CFIBuilder.buildOffset(AArch64::FP, -16);
11491 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11495 CFIBuilder.buildDefCFAOffset(16);
11499 CFIBuilder.buildOffset(AArch64::LR, -16);
11514 RASignCondition, !IsLeafFunction);
11543 fixupPostOutline(
MBB);
11554 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11564 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11573 MachineInstr *Save;
11574 MachineInstr *Restore;
11580 assert(
Reg &&
"No callee-saved register available?");
11614 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11622bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11630 bool AllowSideEffects)
const {
11632 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11635 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11648 assert(STI.hasFPARMv8() &&
"Expected FP to be available.");
11654std::optional<DestSourcePair>
11659 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11660 MI.getOperand(1).getReg() == AArch64::WZR &&
11661 MI.getOperand(3).getImm() == 0x0) ||
11662 (
MI.getOpcode() == AArch64::ORRWrr &&
11663 MI.getOperand(1).getReg() == AArch64::WZR)) {
11665 if ((
MI.getOperand(0).getReg().isPhysical() &&
11666 MI.findRegisterDefOperandIdx(
11669 (
MI.getOperand(0).getReg().isVirtual() &&
11670 !
MI.getOperand(0).getSubReg()))
11674 if (
MI.getOpcode() == AArch64::ORRXrs &&
11675 MI.getOperand(1).getReg() == AArch64::XZR &&
11676 MI.getOperand(3).getImm() == 0x0)
11679 return std::nullopt;
11682std::optional<DestSourcePair>
11684 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11685 MI.getOperand(1).getReg() == AArch64::WZR &&
11686 MI.getOperand(3).getImm() == 0x0) ||
11687 (
MI.getOpcode() == AArch64::ORRWrr &&
11688 MI.getOperand(1).getReg() == AArch64::WZR))
11690 return std::nullopt;
11693std::optional<RegImmPair>
11702 return std::nullopt;
11704 switch (
MI.getOpcode()) {
11706 return std::nullopt;
11707 case AArch64::SUBWri:
11708 case AArch64::SUBXri:
11709 case AArch64::SUBSWri:
11710 case AArch64::SUBSXri:
11713 case AArch64::ADDSWri:
11714 case AArch64::ADDSXri:
11715 case AArch64::ADDWri:
11716 case AArch64::ADDXri: {
11718 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11719 !
MI.getOperand(2).isImm())
11720 return std::nullopt;
11721 int Shift =
MI.getOperand(3).getImm();
11722 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11726 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11732static std::optional<ParamLoadedValue>
11736 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11738 return std::nullopt;
11740 Register DestReg = DestSrc->Destination->getReg();
11741 Register SrcReg = DestSrc->Source->getReg();
11744 return std::nullopt;
11749 if (DestReg == DescribedReg)
11753 if (
MI.getOpcode() == AArch64::ORRWrs &&
11754 TRI->isSuperRegister(DestReg, DescribedReg))
11758 if (
MI.getOpcode() == AArch64::ORRXrs &&
11759 TRI->isSubRegister(DestReg, DescribedReg)) {
11760 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11764 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11765 "Unhandled ORR[XW]rs copy case");
11767 return std::nullopt;
11770bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11775 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11781bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11785 auto isAsmGoto = [](
const MachineInstr &
MI) {
11786 return MI.getOpcode() == AArch64::INLINEASM_BR;
11796 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11803 for (
const MachineInstr &
MI :
MBB) {
11804 switch (
MI.getOpcode()) {
11805 case TargetOpcode::G_BRJT:
11806 case AArch64::JumpTableDest32:
11807 case AArch64::JumpTableDest16:
11808 case AArch64::JumpTableDest8:
11819std::optional<ParamLoadedValue>
11824 switch (
MI.getOpcode()) {
11825 case AArch64::MOVZWi:
11826 case AArch64::MOVZXi: {
11829 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11830 return std::nullopt;
11832 if (!
MI.getOperand(1).isImm())
11833 return std::nullopt;
11834 int64_t Immediate =
MI.getOperand(1).getImm();
11835 int Shift =
MI.getOperand(2).getImm();
11839 case AArch64::ORRWrs:
11840 case AArch64::ORRXrs:
11847bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11850 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11851 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11854 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11864 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11867uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11871bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11875bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11880AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11884bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11885 unsigned Scale)
const {
11896 unsigned Shift =
Log2_64(NumBytes);
11897 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11905 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11910 return AArch64::BLRNoIP;
11912 return AArch64::BLR;
11918 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11939 Register TargetReg,
bool FrameSetup)
const {
11940 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11952 MF.
insert(MBBInsertPoint, LoopTestMBB);
11955 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11957 MF.
insert(MBBInsertPoint, ExitMBB);
11967 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11975 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11981 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11998 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
12017 MBB.addSuccessor(LoopTestMBB);
12023 return ExitMBB->
begin();
12029 const TargetInstrInfo *
TII;
12030 const TargetRegisterInfo *
TRI;
12031 MachineRegisterInfo &MRI;
12034 MachineBasicBlock *LoopBB;
12036 MachineInstr *CondBranch;
12038 MachineInstr *Comp;
12040 unsigned CompCounterOprNum;
12042 MachineInstr *Update;
12044 unsigned UpdateCounterOprNum;
12048 bool IsUpdatePriorComp;
12051 SmallVector<MachineOperand, 4>
Cond;
12054 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
12055 MachineInstr *Comp,
unsigned CompCounterOprNum,
12056 MachineInstr *Update,
unsigned UpdateCounterOprNum,
12057 Register Init,
bool IsUpdatePriorComp,
12058 const SmallVectorImpl<MachineOperand> &
Cond)
12060 TII(MF->getSubtarget().getInstrInfo()),
12061 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
12062 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
12063 CompCounterOprNum(CompCounterOprNum), Update(Update),
12064 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
12067 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
12073 std::optional<bool> createTripCountGreaterCondition(
12074 int TC, MachineBasicBlock &
MBB,
12075 SmallVectorImpl<MachineOperand> &CondParam)
override {
12083 void createRemainingIterationsGreaterCondition(
12084 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
12085 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
12087 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
12089 void adjustTripCount(
int TripCountAdjust)
override {}
12091 bool isMVEExpanderSupported()
override {
return true; }
12110 }
else if (
I == ReplaceOprNum) {
12115 MBB.insert(InsertTo, NewMI);
12119void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
12135 assert(CondBranch->getOpcode() == AArch64::Bcc);
12139 if (CondBranch->getOperand(1).getMBB() == LoopBB)
12146 auto AccumulateCond = [&](
Register CurCond,
12157 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
12161 for (
int I = 0;
I <= TC; ++
I) {
12167 AccCond = AccumulateCond(AccCond, CC);
12171 if (Update != Comp && IsUpdatePriorComp) {
12173 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12174 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
12178 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
12180 }
else if (Update != Comp) {
12185 Counter = NextCounter;
12189 if (LastStage0Insts.
empty()) {
12193 if (IsUpdatePriorComp)
12198 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12201 for (
int I = 0;
I <= TC; ++
I) {
12205 AccCond = AccumulateCond(AccCond, CC);
12206 if (
I != TC && Update != Comp)
12209 Counter = NextCounter;
12225 assert(Phi.getNumOperands() == 5);
12226 if (Phi.getOperand(2).getMBB() ==
MBB) {
12227 RegMBB = Phi.getOperand(1).getReg();
12228 RegOther = Phi.getOperand(3).getReg();
12230 assert(Phi.getOperand(4).getMBB() ==
MBB);
12231 RegMBB = Phi.getOperand(3).getReg();
12232 RegOther = Phi.getOperand(1).getReg();
12237 if (!
Reg.isVirtual())
12246 unsigned &UpdateCounterOprNum,
Register &InitReg,
12247 bool &IsUpdatePriorComp) {
12261 if (!
Reg.isVirtual())
12264 UpdateInst =
nullptr;
12265 UpdateCounterOprNum = 0;
12267 IsUpdatePriorComp =
true;
12271 if (Def->getParent() != LoopBB)
12273 if (Def->isCopy()) {
12275 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
12277 CurReg = Def->getOperand(1).getReg();
12278 }
else if (Def->isPHI()) {
12282 IsUpdatePriorComp =
false;
12287 switch (Def->getOpcode()) {
12288 case AArch64::ADDSXri:
12289 case AArch64::ADDSWri:
12290 case AArch64::SUBSXri:
12291 case AArch64::SUBSWri:
12292 case AArch64::ADDXri:
12293 case AArch64::ADDWri:
12294 case AArch64::SUBXri:
12295 case AArch64::SUBWri:
12297 UpdateCounterOprNum = 1;
12299 case AArch64::ADDSXrr:
12300 case AArch64::ADDSWrr:
12301 case AArch64::SUBSXrr:
12302 case AArch64::SUBSWrr:
12303 case AArch64::ADDXrr:
12304 case AArch64::ADDWrr:
12305 case AArch64::SUBXrr:
12306 case AArch64::SUBWrr:
12309 UpdateCounterOprNum = 1;
12311 UpdateCounterOprNum = 2;
12318 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12333std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12344 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12355 if (
TBB == LoopBB && FBB == LoopBB)
12359 if (
TBB != LoopBB && FBB ==
nullptr)
12362 assert((
TBB == LoopBB || FBB == LoopBB) &&
12363 "The Loop must be a single-basic-block loop");
12368 if (CondBranch->
getOpcode() != AArch64::Bcc)
12376 unsigned CompCounterOprNum = 0;
12378 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12382 switch (
MI.getOpcode()) {
12383 case AArch64::SUBSXri:
12384 case AArch64::SUBSWri:
12385 case AArch64::ADDSXri:
12386 case AArch64::ADDSWri:
12388 CompCounterOprNum = 1;
12390 case AArch64::ADDSWrr:
12391 case AArch64::ADDSXrr:
12392 case AArch64::SUBSWrr:
12393 case AArch64::SUBSXrr:
12397 if (isWhileOpcode(
MI.getOpcode())) {
12404 if (CompCounterOprNum == 0) {
12406 CompCounterOprNum = 2;
12408 CompCounterOprNum = 1;
12420 bool IsUpdatePriorComp;
12421 unsigned UpdateCounterOprNum;
12423 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12426 return std::make_unique<AArch64PipelinerLoopInfo>(
12427 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12437 TypeSize Scale(0U,
false), Width(0U,
false);
12438 int64_t MinOffset, MaxOffset;
12439 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12441 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12442 int64_t
Imm =
MI.getOperand(ImmIdx).getImm();
12444 ErrInfo =
"Unexpected immediate on load/store instruction";
12450 const MCInstrDesc &MCID =
MI.getDesc();
12452 const MachineOperand &MO =
MI.getOperand(
Op);
12456 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12465 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12471 ErrInfo =
"OPERAND_IMM_UINT1 should be 0 or 1";
12477 ErrInfo =
"OPERAND_IMM_UINT4plus1 should be in the range 1 to 16";
12483 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12489 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12500#define GET_INSTRINFO_HELPERS
12501#define GET_INSTRMAP_INFO
12502#include "AArch64GenInstrInfo.inc"
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
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 MachineInstr * genFusedMultiplyAcc(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyAcc - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate64(unsigned Opc)
static bool isFrameLoadOpcode(int Opcode)
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool areCFlagsAccessedBetweenInstrs(MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI, const AccessKind AccessToCheck=AK_All)
True when condition flags are accessed (either by writing or reading) on the instruction trace starti...
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Floating-Point Support.
static bool isADDSRegImm(unsigned Opcode)
static bool isCheapCopy(const MachineInstr &MI, const AArch64RegisterInfo &RI)
static bool isANDOpcode(MachineInstr &MI)
static 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 bool UpdateOperandRegClass(MachineInstr &Instr)
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
static bool isInStreamingCallSiteRegion(MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if the instruction at I is in a streaming call site region, within a single basic block.
static bool canCmpInstrBeRemoved(MachineInstr &MI, MachineInstr &CmpInstr, int CmpValue, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > &CCUseInstrs, bool &IsInvertCC)
unsigned unscaledOffsetOpcode(unsigned Opcode)
static bool getLoadPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Search for patterns of LD instructions we can optimize.
static bool canInstrSubstituteCmpInstr(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI)
Check if CmpInstr can be substituted by MI.
static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC)
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static 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 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 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!")
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
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
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
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file declares the machine register scavenger class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
#define DEBUG_WITH_TYPE(TYPE,...)
DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug information.
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc=0)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool branchTargetEnforcement() const
unsigned getArgumentStackToRestore() const
SignReturnAddress getSignReturnAddressCondition() const
bool hasStreamingModeChanges() const
void setOutliningStyle(const std::string &Style)
bool branchProtectionPAuthLR() const
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,...
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.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool hasSubClassEq(const MCRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
static constexpr unsigned NoRegister
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
reverse_instr_iterator instr_rbegin()
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
reverse_instr_iterator instr_rend()
Instructions::iterator instr_iterator
instr_iterator instr_end()
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
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 registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI) const
Returns true if the register is dead in this machine instruction.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr fully defines the specified register.
LLVM_ABI void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
LLVM_ABI const MachineFunction * getMF() const
Return the function that contains the basic block that this instruction belongs to.
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
LLVM_ABI bool isLoadFoldBarrier() const
Returns true if it is illegal to fold a load across this instruction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
LLVM_ABI void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
LLVM_ABI void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
const MachineOperand & getOperand(unsigned i) const
uint32_t getFlags() const
Return the MI flags bitvector.
LLVM_ABI int findRegisterDefOperandIdx(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false) const
Returns the operand index that is a def of the specified register or -1 if it is not found.
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
@ MOVolatile
The memory access is volatile.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
LLVM_ABI MachineFunction * getMachineFunction(const Function &F) const
Returns the MachineFunction associated to IR function F if there is one, otherwise nullptr.
MachineOperand class - Representation of each machine instruction operand.
void setSubReg(unsigned subReg)
unsigned getSubReg() const
void setImm(int64_t immVal)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
void setIsDead(bool Val=true)
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void setIsKill(bool Val=true)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
unsigned getTargetFlags() const
static MachineOperand CreateImm(int64_t Val)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void setIsUndef(bool Val=true)
Register getReg() const
getReg - Returns the register number.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI void clearKillFlags(Register Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool use_nodbg_empty(Register RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register.
MachineBasicBlock * getDefBlock(Register Reg) const
Return the machine basic block in which the specified virtual register is defined,...
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.
MI-level patchpoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Represents a location in source code.
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level stackmap operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
int64_t getScalable() const
Returns the scalable component of the stack.
static StackOffset get(int64_t Fixed, int64_t Scalable)
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
MI-level Statepoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given statepoint should emit.
Represent a constant reference to a string, i.e.
Object returned by analyzeLoopForPipelining.
TargetInstrInfo - Interface to description of machine instruction set.
virtual void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
virtual std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg.
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
virtual bool 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
InstrType
Represents how an instruction should be mapped by the outliner.
NodeAddr< InstrNode * > Instr
LLVM_ABI Instruction & back() const
LLVM_ABI iterator begin() const
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static bool isCondBranchOpcode(int Opc)
MCCFIInstruction createDefCFA(const TargetRegisterInfo &TRI, unsigned FrameReg, unsigned Reg, const StackOffset &Offset, bool LastAdjustmentWasScalable=true)
static bool isPTrueOpcode(unsigned Opc)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool succeeded(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
constexpr RegState getKillRegState(bool B)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static bool isIndirectBranchOpcode(int Opc)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getBLRCallOpcode(const MachineFunction &MF)
Return opcode to be used for indirect calls.
@ AArch64FrameOffsetIsLegal
Offset is legal.
@ AArch64FrameOffsetCanUpdate
Offset can apply, at least partly.
@ AArch64FrameOffsetCannotUpdate
Offset cannot apply.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static bool isSEHInstruction(const MachineInstr &MI)
bool isLFIPrePostMemAccess(unsigned Opcode)
Returns true if Opcode is a pre- or post-indexed memory access that the LFI rewriter expands with a b...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
AArch64MachineCombinerPattern
@ MULSUBv2i32_indexed_OP1
@ MULADDv4i16_indexed_OP2
@ MULSUBv8i16_indexed_OP2
@ MULSUBv4i16_indexed_OP2
@ MULSUBv4i32_indexed_OP2
@ MULADDv2i32_indexed_OP1
@ MULADDv4i32_indexed_OP1
@ MULADDv2i32_indexed_OP2
@ MULSUBv4i16_indexed_OP1
@ MULADDv4i32_indexed_OP2
@ MULSUBv8i16_indexed_OP1
@ MULSUBv2i32_indexed_OP2
@ MULADDv8i16_indexed_OP1
@ MULSUBv4i32_indexed_OP1
@ MULADDv8i16_indexed_OP2
@ MULADDv4i16_indexed_OP1
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr, bool EmitCFAOffset=false, StackOffset InitialOffset={}, unsigned FrameReg=AArch64::SP)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
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.