67#define GET_INSTRINFO_CTOR_DTOR
68#include "AArch64GenInstrInfo.inc"
70#define DEBUG_TYPE "AArch64InstrInfo"
72STATISTIC(NumCopyInstrs,
"Number of COPY instructions expanded");
73STATISTIC(NumZCRegMoveInstrsGPR,
"Number of zero-cycle GPR register move "
74 "instructions expanded from canonical COPY");
75STATISTIC(NumZCRegMoveInstrsFPR,
"Number of zero-cycle FPR register move "
76 "instructions expanded from canonical COPY");
77STATISTIC(NumZCZeroingInstrsGPR,
"Number of zero-cycle GPR zeroing "
78 "instructions expanded from canonical COPY");
83 cl::desc(
"Restrict range of CB instructions (DEBUG)"));
87 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
91 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
95 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
99 cl::desc(
"Restrict range of B instructions (DEBUG)"));
103 cl::desc(
"Restrict range of instructions to search for the "
104 "machine-combiner gather pattern optimization"));
108 cl::desc(
"Use a frame record for Mach-O non-leaf outlined functions"));
113 RI(STI.getTargetTriple(), STI.getHwMode()), Subtarget(STI) {}
123 switch (
MI.getOpcode()) {
134 if (
MI.getOperand(0).getReg() != AArch64::LR)
147 case AArch64::BLRAAZ:
149 case AArch64::BLRABZ:
153 case AArch64::AUTIASP:
154 case AArch64::AUTIBSP:
155 case AArch64::AUTIAZ:
156 case AArch64::AUTIBZ:
157 case AArch64::XPACLRI:
162 if (
MI.getOperand(0).getImm() == 3 &&
MI.getOperand(1).getImm() == 7 &&
163 MI.getOperand(3).getImm() == 1)
171 bool ModifiesLR =
false;
172 bool ModifiesSP =
false;
176 if (MO.getReg() == AArch64::LR)
178 else if (MO.getReg() == AArch64::SP)
187 if (
MI.mayLoadOrStore()) {
195 if (ModifiesSP || ModifiesLR)
208 if (!
Desc.isPseudo() && !Subtarget.isLFI()) {
209 assert(
Desc.getSize() == 4 &&
"Unexpected instruction size");
219 auto Op =
MI.getOpcode();
220 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
221 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), MAI);
225 if (
MI.isMetaInstruction())
230 unsigned NumBytes = 0;
239 NumBytes =
Desc.getSize() ?
Desc.getSize() : 4;
242 if (!MFI->shouldSignReturnAddress(*MF))
245 auto Method = STI.getAuthenticatedLRCheckMethod(*MF);
253 switch (
Desc.getOpcode()) {
256 return Desc.getSize();
263 case TargetOpcode::STACKMAP:
266 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
268 case TargetOpcode::PATCHPOINT:
271 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
273 case TargetOpcode::STATEPOINT:
275 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
280 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
285 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
287 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
288 case TargetOpcode::PATCHABLE_TAIL_CALL:
289 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
293 case TargetOpcode::PATCHABLE_EVENT_CALL:
299 NumBytes =
MI.getOperand(1).getImm();
301 case AArch64::MOVaddr:
302 case AArch64::MOVaddrJT:
303 case AArch64::MOVaddrCP:
304 case AArch64::MOVaddrBA:
305 case AArch64::MOVaddrTLS:
306 case AArch64::MOVaddrEXT: {
310 MI.getOperand(1).getTargetFlags(),
311 Subtarget.isTargetMachO(), Insn);
312 NumBytes = Insn.
size() * 4;
316 case AArch64::MOVi32imm:
317 case AArch64::MOVi64imm: {
319 unsigned BitSize =
Desc.getOpcode() == AArch64::MOVi32imm ? 32 : 64;
322 NumBytes = Insn.
size() * 4;
326 case TargetOpcode::BUNDLE:
327 NumBytes = getInstBundleSize(
MI);
363 case AArch64::CBWPri:
364 case AArch64::CBXPri:
365 case AArch64::CBWPrr:
366 case AArch64::CBXPrr:
374 case AArch64::CBBAssertExt:
375 case AArch64::CBHAssertExt:
406 case AArch64::CBWPri:
407 case AArch64::CBXPri:
408 case AArch64::CBBAssertExt:
409 case AArch64::CBHAssertExt:
410 case AArch64::CBWPrr:
411 case AArch64::CBXPrr:
417 int64_t BrOffset)
const {
419 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
420 "over conditional branch expansion");
421 return isIntN(Bits, BrOffset / 4);
426 switch (
MI.getOpcode()) {
430 return MI.getOperand(0).getMBB();
435 return MI.getOperand(2).getMBB();
441 return MI.getOperand(1).getMBB();
442 case AArch64::CBWPri:
443 case AArch64::CBXPri:
444 case AArch64::CBBAssertExt:
445 case AArch64::CBHAssertExt:
446 case AArch64::CBWPrr:
447 case AArch64::CBXPrr:
448 return MI.getOperand(3).getMBB();
458 assert(RS &&
"RegScavenger required for long branching");
460 "new block should be inserted for expanding unconditional branch");
463 "restore block should be inserted for restoring clobbered registers");
470 "Branch offsets outside of the signed 33-bit range not supported");
481 RS->enterBasicBlockEnd(
MBB);
484 constexpr Register Reg = AArch64::X16;
485 if (!RS->isRegUsed(Reg)) {
486 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
497 Register Scavenged = RS->FindUnusedReg(&AArch64::GPR64RegClass);
498 if (Scavenged != AArch64::NoRegister) {
499 buildIndirectBranch(Scavenged, NewDestBB);
500 RS->setRegUsed(Scavenged);
509 "Unable to insert indirect branch inside function that has red zone");
532 bool AllowModify)
const {
539 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
540 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
544 if (!isUnpredicatedTerminator(*
I))
551 unsigned LastOpc = LastInst->
getOpcode();
552 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
567 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
574 LastInst = SecondLastInst;
576 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
581 SecondLastInst = &*
I;
582 SecondLastOpc = SecondLastInst->
getOpcode();
593 LastInst = SecondLastInst;
595 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
597 "unreachable unconditional branches removed above");
606 SecondLastInst = &*
I;
607 SecondLastOpc = SecondLastInst->
getOpcode();
611 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
627 I->eraseFromParent();
636 I->eraseFromParent();
645 MachineBranchPredicate &MBP,
646 bool AllowModify)
const {
658 assert(MBP.TrueDest &&
"expected!");
659 MBP.FalseDest = FBB ? FBB :
MBB.getNextNode();
661 MBP.ConditionDef =
nullptr;
662 MBP.SingleUseCondition =
false;
672 if (
I ==
MBB.begin())
688 if (
MI.modifiesRegister(AArch64::NZCV,
nullptr)) {
689 MBP.ConditionDef = &
MI;
698 case AArch64::CBNZX: {
702 MBP.Predicate = (
Opc == AArch64::CBNZX ||
Opc == AArch64::CBNZW)
703 ? MachineBranchPredicate::PRED_NE
704 : MachineBranchPredicate::PRED_EQ;
705 Register CondReg = MBP.LHS.getReg();
714 case AArch64::TBNZX: {
735 Cond[1].setImm(AArch64::CBNZW);
738 Cond[1].setImm(AArch64::CBZW);
741 Cond[1].setImm(AArch64::CBNZX);
744 Cond[1].setImm(AArch64::CBZX);
747 Cond[1].setImm(AArch64::TBNZW);
750 Cond[1].setImm(AArch64::TBZW);
753 Cond[1].setImm(AArch64::TBNZX);
756 Cond[1].setImm(AArch64::TBZX);
760 case AArch64::CBWPri:
761 case AArch64::CBXPri:
762 case AArch64::CBBAssertExt:
763 case AArch64::CBHAssertExt:
764 case AArch64::CBWPrr:
765 case AArch64::CBXPrr: {
778 int *BytesRemoved)
const {
788 I->eraseFromParent();
792 if (
I ==
MBB.begin()) {
805 I->eraseFromParent();
812void AArch64InstrInfo::instantiateCondBranch(
837 if (
Cond.size() > 5) {
848 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
879 switch (
Cond.size()) {
954 unsigned SubsOpc, SubsDestReg;
960 case AArch64::CBWPri:
961 SubsOpc = AArch64::SUBSWri;
962 SubsDestReg = AArch64::WZR;
965 case AArch64::CBXPri:
966 SubsOpc = AArch64::SUBSXri;
967 SubsDestReg = AArch64::XZR;
970 case AArch64::CBWPrr:
971 SubsOpc = AArch64::SUBSWrr;
972 SubsDestReg = AArch64::WZR;
975 case AArch64::CBXPrr:
976 SubsOpc = AArch64::SUBSXrr;
977 SubsDestReg = AArch64::XZR;
1010 switch (ExtendType) {
1016 "Unexpected compare-and-branch instruction for SXTB shift-extend");
1017 ExtOpc = AArch64::SBFMWri;
1023 "Unexpected compare-and-branch instruction for SXTH shift-extend");
1024 ExtOpc = AArch64::SBFMWri;
1030 "Unexpected compare-and-branch instruction for UXTB shift-extend");
1031 ExtOpc = AArch64::ANDWri;
1037 "Unexpected compare-and-branch instruction for UXTH shift-extend");
1038 ExtOpc = AArch64::ANDWri;
1047 if (ExtOpc != AArch64::ANDWri)
1049 MBBI.addImm(ExtBits);
1080 unsigned Opc =
MI.getOpcode();
1087 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1088 MI.getOperand(0).getReg() == AArch64::XZR) {
1090 dbgs() <<
"Removing always taken branch: " <<
MI);
1093 for (
auto *S : Succs)
1095 MBB->removeSuccessor(S);
1097 while (
MBB->rbegin() != &
MI)
1098 MBB->rbegin()->eraseFromParent();
1099 MI.eraseFromParent();
1104 case AArch64::CBNZW:
1105 case AArch64::CBNZX:
1106 case AArch64::TBNZW:
1107 case AArch64::TBNZX:
1109 if (
MI.getOperand(0).getReg() == AArch64::WZR ||
1110 MI.getOperand(0).getReg() == AArch64::XZR) {
1112 dbgs() <<
"Removing never taken branch: " <<
MI);
1114 MI.getParent()->removeSuccessor(
Target);
1115 MI.eraseFromParent();
1130 VReg =
DefMI->getOperand(1).getReg();
1139 unsigned *NewReg =
nullptr) {
1144 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
1149 unsigned SrcReg = 0;
1150 switch (
DefMI->getOpcode()) {
1151 case AArch64::SUBREG_TO_REG:
1155 if (!
DefMI->getOperand(1).isReg())
1157 if (!
DefMI->getOperand(2).isImm() ||
1158 DefMI->getOperand(2).getImm() != AArch64::sub_32)
1161 if (
DefMI->getOpcode() != AArch64::MOVi32imm)
1163 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1166 SrcReg = AArch64::XZR;
1167 Opc = AArch64::CSINCXr;
1170 case AArch64::MOVi32imm:
1171 case AArch64::MOVi64imm:
1172 if (!
DefMI->getOperand(1).isImm() ||
DefMI->getOperand(1).getImm() != 1)
1174 SrcReg = Is64Bit ? AArch64::XZR : AArch64::WZR;
1175 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1178 case AArch64::ADDSXri:
1179 case AArch64::ADDSWri:
1181 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1186 case AArch64::ADDXri:
1187 case AArch64::ADDWri:
1189 if (!
DefMI->getOperand(2).isImm() ||
DefMI->getOperand(2).getImm() != 1 ||
1190 DefMI->getOperand(3).getImm() != 0)
1192 SrcReg =
DefMI->getOperand(1).getReg();
1193 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
1196 case AArch64::ORNXrr:
1197 case AArch64::ORNWrr: {
1200 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1202 SrcReg =
DefMI->getOperand(2).getReg();
1203 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
1207 case AArch64::SUBSXrr:
1208 case AArch64::SUBSWrr:
1210 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
1215 case AArch64::SUBXrr:
1216 case AArch64::SUBWrr: {
1219 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
1221 SrcReg =
DefMI->getOperand(2).getReg();
1222 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
1228 assert(
Opc && SrcReg &&
"Missing parameters");
1238 Register FalseReg,
int &CondCycles,
1240 int &FalseCycles)
const {
1251 if (!RI.getCommonSubClass(RC, MRI.
getRegClass(DstReg)))
1255 unsigned ExtraCondLat =
Cond.size() != 1;
1259 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
1260 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
1262 CondCycles = 1 + ExtraCondLat;
1263 TrueCycles = FalseCycles = 1;
1273 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
1274 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
1275 CondCycles = 5 + ExtraCondLat;
1276 TrueCycles = FalseCycles = 2;
1295 bool TryFold =
false;
1297 RC = &AArch64::GPR64RegClass;
1298 Opc = AArch64::CSELXr;
1301 RC = &AArch64::GPR32RegClass;
1302 Opc = AArch64::CSELWr;
1305 RC = &AArch64::FPR64RegClass;
1306 Opc = AArch64::FCSELDrrr;
1308 RC = &AArch64::FPR32RegClass;
1309 Opc = AArch64::FCSELSrrr;
1311 assert(RC &&
"Unsupported regclass");
1315 unsigned NewReg = 0;
1338 (FalseReg.
isVirtual() || FalseReg == AArch64::WZR ||
1339 FalseReg == AArch64::XZR) &&
1340 "FalseReg was folded into a non-virtual register other than WZR or XZR");
1357 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
1362 return Is.
size() <= 2;
1367 assert(
MI.isCopy() &&
"Expected COPY instruction");
1373 if (
Reg.isVirtual())
1375 if (
Reg.isPhysical())
1376 return RI.getMinimalPhysRegClass(
Reg);
1381 if (DstRC && SrcRC && !RI.getCommonSubClass(DstRC, SrcRC))
1384 return MI.isAsCheapAsAMove();
1390 if (Subtarget.hasExynosCheapAsMoveHandling()) {
1391 if (isExynosCheapAsMove(
MI))
1393 return MI.isAsCheapAsAMove();
1396 switch (
MI.getOpcode()) {
1398 return MI.isAsCheapAsAMove();
1400 case TargetOpcode::COPY:
1403 case AArch64::ADDWrs:
1404 case AArch64::ADDXrs:
1405 case AArch64::SUBWrs:
1406 case AArch64::SUBXrs:
1407 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
1412 case AArch64::MOVi32imm:
1414 case AArch64::MOVi64imm:
1419bool AArch64InstrInfo::isFalkorShiftExtFast(
const MachineInstr &
MI) {
1420 switch (
MI.getOpcode()) {
1424 case AArch64::ADDWrs:
1425 case AArch64::ADDXrs:
1426 case AArch64::ADDSWrs:
1427 case AArch64::ADDSXrs: {
1428 unsigned Imm =
MI.getOperand(3).getImm();
1435 case AArch64::ADDWrx:
1436 case AArch64::ADDXrx:
1437 case AArch64::ADDXrx64:
1438 case AArch64::ADDSWrx:
1439 case AArch64::ADDSXrx:
1440 case AArch64::ADDSXrx64: {
1441 unsigned Imm =
MI.getOperand(3).getImm();
1453 case AArch64::SUBWrs:
1454 case AArch64::SUBSWrs: {
1455 unsigned Imm =
MI.getOperand(3).getImm();
1457 return ShiftVal == 0 ||
1461 case AArch64::SUBXrs:
1462 case AArch64::SUBSXrs: {
1463 unsigned Imm =
MI.getOperand(3).getImm();
1465 return ShiftVal == 0 ||
1469 case AArch64::SUBWrx:
1470 case AArch64::SUBXrx:
1471 case AArch64::SUBXrx64:
1472 case AArch64::SUBSWrx:
1473 case AArch64::SUBSXrx:
1474 case AArch64::SUBSXrx64: {
1475 unsigned Imm =
MI.getOperand(3).getImm();
1487 case AArch64::LDRBBroW:
1488 case AArch64::LDRBBroX:
1489 case AArch64::LDRBroW:
1490 case AArch64::LDRBroX:
1491 case AArch64::LDRDroW:
1492 case AArch64::LDRDroX:
1493 case AArch64::LDRHHroW:
1494 case AArch64::LDRHHroX:
1495 case AArch64::LDRHroW:
1496 case AArch64::LDRHroX:
1497 case AArch64::LDRQroW:
1498 case AArch64::LDRQroX:
1499 case AArch64::LDRSBWroW:
1500 case AArch64::LDRSBWroX:
1501 case AArch64::LDRSBXroW:
1502 case AArch64::LDRSBXroX:
1503 case AArch64::LDRSHWroW:
1504 case AArch64::LDRSHWroX:
1505 case AArch64::LDRSHXroW:
1506 case AArch64::LDRSHXroX:
1507 case AArch64::LDRSWroW:
1508 case AArch64::LDRSWroX:
1509 case AArch64::LDRSroW:
1510 case AArch64::LDRSroX:
1511 case AArch64::LDRWroW:
1512 case AArch64::LDRWroX:
1513 case AArch64::LDRXroW:
1514 case AArch64::LDRXroX:
1515 case AArch64::PRFMroW:
1516 case AArch64::PRFMroX:
1517 case AArch64::STRBBroW:
1518 case AArch64::STRBBroX:
1519 case AArch64::STRBroW:
1520 case AArch64::STRBroX:
1521 case AArch64::STRDroW:
1522 case AArch64::STRDroX:
1523 case AArch64::STRHHroW:
1524 case AArch64::STRHHroX:
1525 case AArch64::STRHroW:
1526 case AArch64::STRHroX:
1527 case AArch64::STRQroW:
1528 case AArch64::STRQroX:
1529 case AArch64::STRSroW:
1530 case AArch64::STRSroX:
1531 case AArch64::STRWroW:
1532 case AArch64::STRWroX:
1533 case AArch64::STRXroW:
1534 case AArch64::STRXroX: {
1535 unsigned IsSigned =
MI.getOperand(3).getImm();
1542 unsigned Opc =
MI.getOpcode();
1546 case AArch64::SEH_StackAlloc:
1547 case AArch64::SEH_SaveFPLR:
1548 case AArch64::SEH_SaveFPLR_X:
1549 case AArch64::SEH_SaveReg:
1550 case AArch64::SEH_SaveReg_X:
1551 case AArch64::SEH_SaveRegP:
1552 case AArch64::SEH_SaveRegP_X:
1553 case AArch64::SEH_SaveFReg:
1554 case AArch64::SEH_SaveFReg_X:
1555 case AArch64::SEH_SaveFRegP:
1556 case AArch64::SEH_SaveFRegP_X:
1557 case AArch64::SEH_SetFP:
1558 case AArch64::SEH_AddFP:
1559 case AArch64::SEH_Nop:
1560 case AArch64::SEH_PrologEnd:
1561 case AArch64::SEH_EpilogStart:
1562 case AArch64::SEH_EpilogEnd:
1563 case AArch64::SEH_PACSignLR:
1564 case AArch64::SEH_SaveAnyRegI:
1565 case AArch64::SEH_SaveAnyRegIP:
1566 case AArch64::SEH_SaveAnyRegQP:
1567 case AArch64::SEH_SaveAnyRegQPX:
1568 case AArch64::SEH_AllocZ:
1569 case AArch64::SEH_SaveZReg:
1570 case AArch64::SEH_SavePReg:
1577 unsigned &SubIdx)
const {
1578 switch (
MI.getOpcode()) {
1581 case AArch64::SBFMXri:
1582 case AArch64::UBFMXri:
1585 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1588 SrcReg =
MI.getOperand(1).getReg();
1589 DstReg =
MI.getOperand(0).getReg();
1590 SubIdx = AArch64::sub_32;
1599 int64_t OffsetA = 0, OffsetB = 0;
1600 TypeSize WidthA(0,
false), WidthB(0,
false);
1601 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1622 OffsetAIsScalable == OffsetBIsScalable) {
1623 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1624 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1625 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1626 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1644 switch (
MI.getOpcode()) {
1647 if (
MI.getOperand(0).getImm() == 0x14)
1654 case AArch64::MSRpstatesvcrImm1:
1661 auto Next = std::next(
MI.getIterator());
1662 return Next !=
MBB->end() &&
Next->isCFIInstruction();
1669 Register &SrcReg2, int64_t &CmpMask,
1670 int64_t &CmpValue)
const {
1674 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1675 if (!
MI.getOperand(1).isReg() ||
MI.getOperand(1).getSubReg())
1678 switch (
MI.getOpcode()) {
1681 case AArch64::PTEST_PP:
1682 case AArch64::PTEST_PP_ANY:
1683 case AArch64::PTEST_PP_FIRST:
1684 SrcReg =
MI.getOperand(0).getReg();
1685 SrcReg2 =
MI.getOperand(1).getReg();
1686 if (
MI.getOperand(2).getSubReg())
1693 case AArch64::SUBSWrr:
1694 case AArch64::SUBSWrs:
1695 case AArch64::SUBSWrx:
1696 case AArch64::SUBSXrr:
1697 case AArch64::SUBSXrs:
1698 case AArch64::SUBSXrx:
1699 case AArch64::ADDSWrr:
1700 case AArch64::ADDSWrs:
1701 case AArch64::ADDSWrx:
1702 case AArch64::ADDSXrr:
1703 case AArch64::ADDSXrs:
1704 case AArch64::ADDSXrx:
1706 SrcReg =
MI.getOperand(1).getReg();
1707 SrcReg2 =
MI.getOperand(2).getReg();
1710 if (
MI.getOperand(2).getSubReg())
1716 case AArch64::SUBSWri:
1717 case AArch64::ADDSWri:
1718 case AArch64::SUBSXri:
1719 case AArch64::ADDSXri:
1720 SrcReg =
MI.getOperand(1).getReg();
1723 CmpValue =
MI.getOperand(2).getImm();
1725 case AArch64::ANDSWri:
1726 case AArch64::ANDSXri:
1729 SrcReg =
MI.getOperand(1).getReg();
1733 MI.getOperand(2).getImm(),
1734 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1743 assert(
MBB &&
"Can't get MachineBasicBlock here");
1745 assert(MF &&
"Can't get MachineFunction here");
1750 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands(); OpIdx < EndIdx;
1754 Instr.getRegClassConstraint(OpIdx,
TII,
TRI);
1757 if (!OpRegCstraints)
1765 "Operand has register constraints without being a register!");
1768 if (
Reg.isPhysical()) {
1785 bool MIDefinesZeroReg =
false;
1786 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1787 MI.definesRegister(AArch64::XZR,
nullptr))
1788 MIDefinesZeroReg =
true;
1790 switch (
MI.getOpcode()) {
1792 return MI.getOpcode();
1793 case AArch64::ADDSWrr:
1794 return AArch64::ADDWrr;
1795 case AArch64::ADDSWri:
1796 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1797 case AArch64::ADDSWrs:
1798 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1799 case AArch64::ADDSWrx:
1800 return AArch64::ADDWrx;
1801 case AArch64::ADDSXrr:
1802 return AArch64::ADDXrr;
1803 case AArch64::ADDSXri:
1804 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1805 case AArch64::ADDSXrs:
1806 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1807 case AArch64::ADDSXrx:
1808 return AArch64::ADDXrx;
1809 case AArch64::SUBSWrr:
1810 return AArch64::SUBWrr;
1811 case AArch64::SUBSWri:
1812 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1813 case AArch64::SUBSWrs:
1814 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1815 case AArch64::SUBSWrx:
1816 return AArch64::SUBWrx;
1817 case AArch64::SUBSXrr:
1818 return AArch64::SUBXrr;
1819 case AArch64::SUBSXri:
1820 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1821 case AArch64::SUBSXrs:
1822 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1823 case AArch64::SUBSXrx:
1824 return AArch64::SUBXrx;
1839 if (To == To->getParent()->begin())
1844 if (To->getParent() != From->getParent())
1856 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1857 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1863std::optional<unsigned>
1867 unsigned MaskOpcode =
Mask->getOpcode();
1868 unsigned PredOpcode = Pred->
getOpcode();
1869 bool PredIsPTestLike = isPTestLikeOpcode(PredOpcode);
1870 bool PredIsWhileLike = isWhileOpcode(PredOpcode);
1872 if (PredIsWhileLike) {
1876 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1883 getElementSizeForOpcode(MaskOpcode) ==
1884 getElementSizeForOpcode(PredOpcode))
1890 if (PTest->
getOpcode() == AArch64::PTEST_PP_FIRST &&
1897 if (PredIsPTestLike) {
1902 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1910 if (Mask != PTestLikeMask && PTestLikeMask->isFullCopy() &&
1911 PTestLikeMask->getOperand(1).getReg().isVirtual())
1919 getElementSizeForOpcode(MaskOpcode) ==
1920 getElementSizeForOpcode(PredOpcode)) {
1921 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1947 uint64_t PredElementSize = getElementSizeForOpcode(PredOpcode);
1949 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1957 switch (PredOpcode) {
1958 case AArch64::AND_PPzPP:
1959 case AArch64::BIC_PPzPP:
1960 case AArch64::EOR_PPzPP:
1961 case AArch64::NAND_PPzPP:
1962 case AArch64::NOR_PPzPP:
1963 case AArch64::ORN_PPzPP:
1964 case AArch64::ORR_PPzPP:
1965 case AArch64::BRKA_PPzP:
1966 case AArch64::BRKPA_PPzPP:
1967 case AArch64::BRKB_PPzP:
1968 case AArch64::BRKPB_PPzPP:
1969 case AArch64::RDFFR_PPz: {
1973 if (Mask != PredMask)
1977 case AArch64::BRKN_PPzP: {
1981 if ((MaskOpcode != AArch64::PTRUE_B) ||
1982 (
Mask->getOperand(1).getImm() != 31))
1986 case AArch64::PTRUE_B:
1999bool AArch64InstrInfo::optimizePTestInstr(
2000 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
2005 if (Pred->
isCopy() && PTest->
getOpcode() == AArch64::PTEST_PP_FIRST) {
2009 if (
Op.isReg() &&
Op.getReg().isVirtual() &&
2010 Op.getSubReg() == AArch64::psub0)
2014 unsigned PredOpcode = Pred->
getOpcode();
2015 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred, MRI);
2031 if (*NewOp != PredOpcode) {
2042 for (; i !=
e; ++i) {
2073 if (DeadNZCVIdx != -1) {
2092 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
2093 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY ||
2094 CmpInstr.
getOpcode() == AArch64::PTEST_PP_FIRST)
2095 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2, MRI);
2104 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *MRI))
2106 return (CmpValue == 0 || CmpValue == 1) &&
2107 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *MRI);
2115 switch (Instr.getOpcode()) {
2117 return AArch64::INSTRUCTION_LIST_END;
2119 case AArch64::ADDSWrr:
2120 case AArch64::ADDSWri:
2121 case AArch64::ADDSXrr:
2122 case AArch64::ADDSXri:
2123 case AArch64::ADDSWrx:
2124 case AArch64::ADDSXrx:
2125 case AArch64::ADDSWrs:
2126 case AArch64::ADDSXrs:
2127 case AArch64::SUBSWrr:
2128 case AArch64::SUBSWri:
2129 case AArch64::SUBSWrx:
2130 case AArch64::SUBSWrs:
2131 case AArch64::SUBSXrr:
2132 case AArch64::SUBSXri:
2133 case AArch64::SUBSXrx:
2134 case AArch64::SUBSXrs:
2135 case AArch64::ANDSWri:
2136 case AArch64::ANDSWrr:
2137 case AArch64::ANDSWrs:
2138 case AArch64::ANDSXri:
2139 case AArch64::ANDSXrr:
2140 case AArch64::ANDSXrs:
2141 case AArch64::BICSWrr:
2142 case AArch64::BICSXrr:
2143 case AArch64::BICSWrs:
2144 case AArch64::BICSXrs:
2145 case AArch64::ADCSWr:
2146 case AArch64::ADCSXr:
2147 case AArch64::SBCSWr:
2148 case AArch64::SBCSXr:
2149 return Instr.getOpcode();
2151 case AArch64::ADDWrr:
2152 return AArch64::ADDSWrr;
2153 case AArch64::ADDWri:
2154 return AArch64::ADDSWri;
2155 case AArch64::ADDXrr:
2156 return AArch64::ADDSXrr;
2157 case AArch64::ADDXri:
2158 return AArch64::ADDSXri;
2159 case AArch64::ADDWrx:
2160 return AArch64::ADDSWrx;
2161 case AArch64::ADDXrx:
2162 return AArch64::ADDSXrx;
2163 case AArch64::ADDWrs:
2164 return AArch64::ADDSWrs;
2165 case AArch64::ADDXrs:
2166 return AArch64::ADDSXrs;
2167 case AArch64::ADCWr:
2168 return AArch64::ADCSWr;
2169 case AArch64::ADCXr:
2170 return AArch64::ADCSXr;
2171 case AArch64::SUBWrr:
2172 return AArch64::SUBSWrr;
2173 case AArch64::SUBWri:
2174 return AArch64::SUBSWri;
2175 case AArch64::SUBXrr:
2176 return AArch64::SUBSXrr;
2177 case AArch64::SUBXri:
2178 return AArch64::SUBSXri;
2179 case AArch64::SUBWrx:
2180 return AArch64::SUBSWrx;
2181 case AArch64::SUBXrx:
2182 return AArch64::SUBSXrx;
2183 case AArch64::SUBWrs:
2184 return AArch64::SUBSWrs;
2185 case AArch64::SUBXrs:
2186 return AArch64::SUBSXrs;
2187 case AArch64::SBCWr:
2188 return AArch64::SBCSWr;
2189 case AArch64::SBCXr:
2190 return AArch64::SBCSXr;
2191 case AArch64::ANDWri:
2192 return AArch64::ANDSWri;
2193 case AArch64::ANDXri:
2194 return AArch64::ANDSXri;
2195 case AArch64::ANDWrr:
2196 return AArch64::ANDSWrr;
2197 case AArch64::ANDWrs:
2198 return AArch64::ANDSWrs;
2199 case AArch64::ANDXrr:
2200 return AArch64::ANDSXrr;
2201 case AArch64::ANDXrs:
2202 return AArch64::ANDSXrs;
2203 case AArch64::BICWrr:
2204 return AArch64::BICSWrr;
2205 case AArch64::BICXrr:
2206 return AArch64::BICSXrr;
2207 case AArch64::BICWrs:
2208 return AArch64::BICSWrs;
2209 case AArch64::BICXrs:
2210 return AArch64::BICSXrs;
2216 for (
auto *BB :
MBB->successors())
2217 if (BB->isLiveIn(AArch64::NZCV))
2224int AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(
2226 switch (
Instr.getOpcode()) {
2230 case AArch64::Bcc: {
2231 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2236 case AArch64::CSINVWr:
2237 case AArch64::CSINVXr:
2238 case AArch64::CSINCWr:
2239 case AArch64::CSINCXr:
2240 case AArch64::CSELWr:
2241 case AArch64::CSELXr:
2242 case AArch64::CSNEGWr:
2243 case AArch64::CSNEGXr:
2244 case AArch64::FCSELSrrr:
2245 case AArch64::FCSELDrrr: {
2246 int Idx =
Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
2258 AArch64InstrInfo::findCondCodeUseOperandIdxForBranchOrSelect(Instr);
2260 Instr.getOperand(CCIdx).
getImm())
2313std::optional<UsedNZCV>
2318 if (
MI.getParent() != CmpParent)
2319 return std::nullopt;
2322 return std::nullopt;
2327 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
2330 return std::nullopt;
2335 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
2338 return NZCVUsedAfterCmp;
2342 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
2346 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
2352 case AArch64::ANDSWri:
2353 case AArch64::ANDSWrr:
2354 case AArch64::ANDSWrs:
2355 case AArch64::ANDSXri:
2356 case AArch64::ANDSXrr:
2357 case AArch64::ANDSXrs:
2358 case AArch64::BICSWrr:
2359 case AArch64::BICSXrr:
2360 case AArch64::BICSWrs:
2361 case AArch64::BICSXrs:
2387 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2393 "Caller guarantees that CmpInstr compares with constant 0");
2396 if (!NZVCUsed || NZVCUsed->C)
2417bool AArch64InstrInfo::substituteCmpToZero(
2428 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
2435 MI->setDesc(
get(NewOpc));
2440 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
2452 assert((CmpValue == 0 || CmpValue == 1) &&
2453 "Only comparisons to 0 or 1 considered for removal!");
2456 unsigned MIOpc =
MI.getOpcode();
2457 if (MIOpc == AArch64::CSINCWr) {
2458 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
2459 MI.getOperand(2).getReg() != AArch64::WZR)
2461 }
else if (MIOpc == AArch64::CSINCXr) {
2462 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
2463 MI.getOperand(2).getReg() != AArch64::XZR)
2473 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
2477 const unsigned CmpOpcode = CmpInstr.
getOpcode();
2479 if (CmpValue && !IsSubsRegImm)
2481 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
2486 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
2489 std::optional<UsedNZCV> NZCVUsedAfterCmp =
2493 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
2496 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
2497 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
2500 if (MIUsedNZCV.
N && !CmpValue)
2542bool AArch64InstrInfo::removeCmpToZeroOrOne(
2549 SmallVector<MachineInstr *, 4> CCUseInstrs;
2550 bool IsInvertCC =
false;
2558 for (MachineInstr *CCUseInstr : CCUseInstrs) {
2559 int Idx = findCondCodeUseOperandIdxForBranchOrSelect(*CCUseInstr);
2560 assert(Idx >= 0 &&
"Unexpected instruction using CC.");
2561 MachineOperand &CCOperand = CCUseInstr->getOperand(Idx);
2570bool AArch64InstrInfo::expandPostRAPseudo(
MachineInstr &
MI)
const {
2571 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
2572 MI.getOpcode() != AArch64::CATCHRET &&
2573 MI.getOpcode() != AArch64::STACK_GUARD_UNMIX)
2578 auto TRI = Subtarget.getRegisterInfo();
2581 if (
MI.getOpcode() == AArch64::STACK_GUARD_UNMIX) {
2595 if (
MI.getOpcode() == AArch64::CATCHRET) {
2597 const TargetInstrInfo *
TII =
2599 MachineBasicBlock *TargetMBB =
MI.getOperand(0).getMBB();
2604 FirstEpilogSEH = std::prev(FirstEpilogSEH);
2606 FirstEpilogSEH = std::next(FirstEpilogSEH);
2621 if (
M.getStackProtectorGuard() ==
"sysreg") {
2622 const AArch64SysReg::SysReg *SrcReg =
2623 AArch64SysReg::lookupSysRegByName(
M.getStackProtectorGuardReg());
2631 int Offset =
M.getStackProtectorGuardOffset();
2682 const GlobalValue *GV =
2685 unsigned OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
2688 unsigned GuardWidth =
M.getStackProtectorGuardValueWidth().value_or(
2689 Subtarget.isTargetILP32() ? 4 : 8);
2690 if (GuardWidth != 4 && GuardWidth != 8)
2695 if (GuardWidth == 4) {
2696 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2725 if (GuardWidth == 4) {
2726 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2743 if (GuardWidth == 4) {
2744 unsigned Reg32 =
TRI->getSubReg(
Reg, AArch64::sub_32);
2762 if (Subtarget.getTargetTriple().isOSMSVCRT())
2775 switch (
MI.getOpcode()) {
2778 case AArch64::MOVZWi:
2779 case AArch64::MOVZXi:
2780 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2781 assert(
MI.getDesc().getNumOperands() == 3 &&
2782 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2786 case AArch64::ANDWri:
2787 return MI.getOperand(1).getReg() == AArch64::WZR;
2788 case AArch64::ANDXri:
2789 return MI.getOperand(1).getReg() == AArch64::XZR;
2790 case TargetOpcode::COPY:
2791 return MI.getOperand(1).getReg() == AArch64::WZR;
2799 switch (
MI.getOpcode()) {
2802 case TargetOpcode::COPY: {
2805 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2806 AArch64::GPR64RegClass.
contains(DstReg));
2808 case AArch64::ORRXrs:
2809 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2810 assert(
MI.getDesc().getNumOperands() == 4 &&
2811 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2815 case AArch64::ADDXri:
2816 if (
MI.getOperand(2).getImm() == 0) {
2817 assert(
MI.getDesc().getNumOperands() == 4 &&
2818 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2829 switch (
MI.getOpcode()) {
2832 case TargetOpcode::COPY: {
2834 return AArch64::FPR128RegClass.contains(DstReg);
2836 case AArch64::ORRv16i8:
2837 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2838 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2839 "invalid ORRv16i8 operands");
2851 case AArch64::LDRWui:
2852 case AArch64::LDRXui:
2853 case AArch64::LDRBui:
2854 case AArch64::LDRHui:
2855 case AArch64::LDRSui:
2856 case AArch64::LDRDui:
2857 case AArch64::LDRQui:
2858 case AArch64::LDR_PXI:
2864 int &FrameIndex)
const {
2868 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2869 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2870 FrameIndex =
MI.getOperand(1).getIndex();
2871 return MI.getOperand(0).getReg();
2880 case AArch64::STRWui:
2881 case AArch64::STRXui:
2882 case AArch64::STRBui:
2883 case AArch64::STRHui:
2884 case AArch64::STRSui:
2885 case AArch64::STRDui:
2886 case AArch64::STRQui:
2887 case AArch64::STR_PXI:
2893 int &FrameIndex)
const {
2897 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2898 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2899 FrameIndex =
MI.getOperand(1).getIndex();
2900 return MI.getOperand(0).getReg();
2906 int &FrameIndex)
const {
2921 return MI.getOperand(0).getReg();
2927 int &FrameIndex)
const {
2942 return MI.getOperand(0).getReg();
2950 return MMO->getFlags() & MOSuppressPair;
2956 if (
MI.memoperands_empty())
2964 return MMO->getFlags() & MOStridedAccess;
2972 case AArch64::STURSi:
2973 case AArch64::STRSpre:
2974 case AArch64::STURDi:
2975 case AArch64::STRDpre:
2976 case AArch64::STURQi:
2977 case AArch64::STRQpre:
2978 case AArch64::STURBBi:
2979 case AArch64::STURHHi:
2980 case AArch64::STURWi:
2981 case AArch64::STRWpre:
2982 case AArch64::STURXi:
2983 case AArch64::STRXpre:
2984 case AArch64::LDURSi:
2985 case AArch64::LDRSpre:
2986 case AArch64::LDURDi:
2987 case AArch64::LDRDpre:
2988 case AArch64::LDURQi:
2989 case AArch64::LDRQpre:
2990 case AArch64::LDURWi:
2991 case AArch64::LDRWpre:
2992 case AArch64::LDURXi:
2993 case AArch64::LDRXpre:
2994 case AArch64::LDRSWpre:
2995 case AArch64::LDURSWi:
2996 case AArch64::LDURHHi:
2997 case AArch64::LDURBBi:
2998 case AArch64::LDURSBWi:
2999 case AArch64::LDURSHWi:
3007 case AArch64::PRFMui:
return AArch64::PRFUMi;
3008 case AArch64::LDRXui:
return AArch64::LDURXi;
3009 case AArch64::LDRWui:
return AArch64::LDURWi;
3010 case AArch64::LDRBui:
return AArch64::LDURBi;
3011 case AArch64::LDRHui:
return AArch64::LDURHi;
3012 case AArch64::LDRSui:
return AArch64::LDURSi;
3013 case AArch64::LDRDui:
return AArch64::LDURDi;
3014 case AArch64::LDRQui:
return AArch64::LDURQi;
3015 case AArch64::LDRBBui:
return AArch64::LDURBBi;
3016 case AArch64::LDRHHui:
return AArch64::LDURHHi;
3017 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
3018 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
3019 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
3020 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
3021 case AArch64::LDRSWui:
return AArch64::LDURSWi;
3022 case AArch64::STRXui:
return AArch64::STURXi;
3023 case AArch64::STRWui:
return AArch64::STURWi;
3024 case AArch64::STRBui:
return AArch64::STURBi;
3025 case AArch64::STRHui:
return AArch64::STURHi;
3026 case AArch64::STRSui:
return AArch64::STURSi;
3027 case AArch64::STRDui:
return AArch64::STURDi;
3028 case AArch64::STRQui:
return AArch64::STURQi;
3029 case AArch64::STRBBui:
return AArch64::STURBBi;
3030 case AArch64::STRHHui:
return AArch64::STURHHi;
3039 case AArch64::LDAPURBi:
3040 case AArch64::LDAPURHi:
3041 case AArch64::LDAPURi:
3042 case AArch64::LDAPURSBWi:
3043 case AArch64::LDAPURSBXi:
3044 case AArch64::LDAPURSHWi:
3045 case AArch64::LDAPURSHXi:
3046 case AArch64::LDAPURSWi:
3047 case AArch64::LDAPURXi:
3048 case AArch64::LDR_PPXI:
3049 case AArch64::LDR_PXI:
3050 case AArch64::LDR_ZXI:
3051 case AArch64::LDR_ZZXI:
3052 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
3053 case AArch64::LDR_ZZZXI:
3054 case AArch64::LDR_ZZZZXI:
3055 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
3056 case AArch64::LDRBBui:
3057 case AArch64::LDRBui:
3058 case AArch64::LDRDui:
3059 case AArch64::LDRHHui:
3060 case AArch64::LDRHui:
3061 case AArch64::LDRQui:
3062 case AArch64::LDRSBWui:
3063 case AArch64::LDRSBXui:
3064 case AArch64::LDRSHWui:
3065 case AArch64::LDRSHXui:
3066 case AArch64::LDRSui:
3067 case AArch64::LDRSWui:
3068 case AArch64::LDRWui:
3069 case AArch64::LDRXui:
3070 case AArch64::LDURBBi:
3071 case AArch64::LDURBi:
3072 case AArch64::LDURDi:
3073 case AArch64::LDURHHi:
3074 case AArch64::LDURHi:
3075 case AArch64::LDURQi:
3076 case AArch64::LDURSBWi:
3077 case AArch64::LDURSBXi:
3078 case AArch64::LDURSHWi:
3079 case AArch64::LDURSHXi:
3080 case AArch64::LDURSi:
3081 case AArch64::LDURSWi:
3082 case AArch64::LDURWi:
3083 case AArch64::LDURXi:
3084 case AArch64::PRFMui:
3085 case AArch64::PRFUMi:
3086 case AArch64::ST2Gi:
3088 case AArch64::STLURBi:
3089 case AArch64::STLURHi:
3090 case AArch64::STLURWi:
3091 case AArch64::STLURXi:
3092 case AArch64::StoreSwiftAsyncContext:
3093 case AArch64::STR_PPXI:
3094 case AArch64::STR_PXI:
3095 case AArch64::STR_ZXI:
3096 case AArch64::STR_ZZXI:
3097 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
3098 case AArch64::STR_ZZZXI:
3099 case AArch64::STR_ZZZZXI:
3100 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
3101 case AArch64::STRBBui:
3102 case AArch64::STRBui:
3103 case AArch64::STRDui:
3104 case AArch64::STRHHui:
3105 case AArch64::STRHui:
3106 case AArch64::STRQui:
3107 case AArch64::STRSui:
3108 case AArch64::STRWui:
3109 case AArch64::STRXui:
3110 case AArch64::STURBBi:
3111 case AArch64::STURBi:
3112 case AArch64::STURDi:
3113 case AArch64::STURHHi:
3114 case AArch64::STURHi:
3115 case AArch64::STURQi:
3116 case AArch64::STURSi:
3117 case AArch64::STURWi:
3118 case AArch64::STURXi:
3119 case AArch64::STZ2Gi:
3120 case AArch64::STZGi:
3121 case AArch64::TAGPstack:
3123 case AArch64::LD1B_D_IMM:
3124 case AArch64::LD1B_H_IMM:
3125 case AArch64::LD1B_IMM:
3126 case AArch64::LD1B_S_IMM:
3127 case AArch64::LD1D_IMM:
3128 case AArch64::LD1H_D_IMM:
3129 case AArch64::LD1H_IMM:
3130 case AArch64::LD1H_S_IMM:
3131 case AArch64::LD1RB_D_IMM:
3132 case AArch64::LD1RB_H_IMM:
3133 case AArch64::LD1RB_IMM:
3134 case AArch64::LD1RB_S_IMM:
3135 case AArch64::LD1RD_IMM:
3136 case AArch64::LD1RH_D_IMM:
3137 case AArch64::LD1RH_IMM:
3138 case AArch64::LD1RH_S_IMM:
3139 case AArch64::LD1RSB_D_IMM:
3140 case AArch64::LD1RSB_H_IMM:
3141 case AArch64::LD1RSB_S_IMM:
3142 case AArch64::LD1RSH_D_IMM:
3143 case AArch64::LD1RSH_S_IMM:
3144 case AArch64::LD1RSW_IMM:
3145 case AArch64::LD1RW_D_IMM:
3146 case AArch64::LD1RW_IMM:
3147 case AArch64::LD1SB_D_IMM:
3148 case AArch64::LD1SB_H_IMM:
3149 case AArch64::LD1SB_S_IMM:
3150 case AArch64::LD1SH_D_IMM:
3151 case AArch64::LD1SH_S_IMM:
3152 case AArch64::LD1SW_D_IMM:
3153 case AArch64::LD1W_D_IMM:
3154 case AArch64::LD1W_IMM:
3155 case AArch64::LD2B_IMM:
3156 case AArch64::LD2D_IMM:
3157 case AArch64::LD2H_IMM:
3158 case AArch64::LD2W_IMM:
3159 case AArch64::LD3B_IMM:
3160 case AArch64::LD3D_IMM:
3161 case AArch64::LD3H_IMM:
3162 case AArch64::LD3W_IMM:
3163 case AArch64::LD4B_IMM:
3164 case AArch64::LD4D_IMM:
3165 case AArch64::LD4H_IMM:
3166 case AArch64::LD4W_IMM:
3168 case AArch64::LDNF1B_D_IMM:
3169 case AArch64::LDNF1B_H_IMM:
3170 case AArch64::LDNF1B_IMM:
3171 case AArch64::LDNF1B_S_IMM:
3172 case AArch64::LDNF1D_IMM:
3173 case AArch64::LDNF1H_D_IMM:
3174 case AArch64::LDNF1H_IMM:
3175 case AArch64::LDNF1H_S_IMM:
3176 case AArch64::LDNF1SB_D_IMM:
3177 case AArch64::LDNF1SB_H_IMM:
3178 case AArch64::LDNF1SB_S_IMM:
3179 case AArch64::LDNF1SH_D_IMM:
3180 case AArch64::LDNF1SH_S_IMM:
3181 case AArch64::LDNF1SW_D_IMM:
3182 case AArch64::LDNF1W_D_IMM:
3183 case AArch64::LDNF1W_IMM:
3184 case AArch64::LDNPDi:
3185 case AArch64::LDNPQi:
3186 case AArch64::LDNPSi:
3187 case AArch64::LDNPWi:
3188 case AArch64::LDNPXi:
3189 case AArch64::LDNT1B_ZRI:
3190 case AArch64::LDNT1D_ZRI:
3191 case AArch64::LDNT1H_ZRI:
3192 case AArch64::LDNT1W_ZRI:
3193 case AArch64::LDPDi:
3194 case AArch64::LDPQi:
3195 case AArch64::LDPSi:
3196 case AArch64::LDPWi:
3197 case AArch64::LDPXi:
3198 case AArch64::LDRBBpost:
3199 case AArch64::LDRBBpre:
3200 case AArch64::LDRBpost:
3201 case AArch64::LDRBpre:
3202 case AArch64::LDRDpost:
3203 case AArch64::LDRDpre:
3204 case AArch64::LDRHHpost:
3205 case AArch64::LDRHHpre:
3206 case AArch64::LDRHpost:
3207 case AArch64::LDRHpre:
3208 case AArch64::LDRQpost:
3209 case AArch64::LDRQpre:
3210 case AArch64::LDRSpost:
3211 case AArch64::LDRSpre:
3212 case AArch64::LDRWpost:
3213 case AArch64::LDRWpre:
3214 case AArch64::LDRXpost:
3215 case AArch64::LDRXpre:
3216 case AArch64::ST1B_D_IMM:
3217 case AArch64::ST1B_H_IMM:
3218 case AArch64::ST1B_IMM:
3219 case AArch64::ST1B_S_IMM:
3220 case AArch64::ST1D_IMM:
3221 case AArch64::ST1H_D_IMM:
3222 case AArch64::ST1H_IMM:
3223 case AArch64::ST1H_S_IMM:
3224 case AArch64::ST1W_D_IMM:
3225 case AArch64::ST1W_IMM:
3226 case AArch64::ST2B_IMM:
3227 case AArch64::ST2D_IMM:
3228 case AArch64::ST2H_IMM:
3229 case AArch64::ST2W_IMM:
3230 case AArch64::ST3B_IMM:
3231 case AArch64::ST3D_IMM:
3232 case AArch64::ST3H_IMM:
3233 case AArch64::ST3W_IMM:
3234 case AArch64::ST4B_IMM:
3235 case AArch64::ST4D_IMM:
3236 case AArch64::ST4H_IMM:
3237 case AArch64::ST4W_IMM:
3238 case AArch64::STGPi:
3239 case AArch64::STGPreIndex:
3240 case AArch64::STZGPreIndex:
3241 case AArch64::ST2GPreIndex:
3242 case AArch64::STZ2GPreIndex:
3243 case AArch64::STGPostIndex:
3244 case AArch64::STZGPostIndex:
3245 case AArch64::ST2GPostIndex:
3246 case AArch64::STZ2GPostIndex:
3247 case AArch64::STNPDi:
3248 case AArch64::STNPQi:
3249 case AArch64::STNPSi:
3250 case AArch64::STNPWi:
3251 case AArch64::STNPXi:
3252 case AArch64::STNT1B_ZRI:
3253 case AArch64::STNT1D_ZRI:
3254 case AArch64::STNT1H_ZRI:
3255 case AArch64::STNT1W_ZRI:
3256 case AArch64::STPDi:
3257 case AArch64::STPQi:
3258 case AArch64::STPSi:
3259 case AArch64::STPWi:
3260 case AArch64::STPXi:
3261 case AArch64::STRBBpost:
3262 case AArch64::STRBBpre:
3263 case AArch64::STRBpost:
3264 case AArch64::STRBpre:
3265 case AArch64::STRDpost:
3266 case AArch64::STRDpre:
3267 case AArch64::STRHHpost:
3268 case AArch64::STRHHpre:
3269 case AArch64::STRHpost:
3270 case AArch64::STRHpre:
3271 case AArch64::STRQpost:
3272 case AArch64::STRQpre:
3273 case AArch64::STRSpost:
3274 case AArch64::STRSpre:
3275 case AArch64::STRWpost:
3276 case AArch64::STRWpre:
3277 case AArch64::STRXpost:
3278 case AArch64::STRXpre:
3279 case AArch64::LD1B_2Z_IMM:
3280 case AArch64::LD1B_2Z_STRIDED_IMM:
3281 case AArch64::LD1H_2Z_IMM:
3282 case AArch64::LD1H_2Z_STRIDED_IMM:
3283 case AArch64::LD1W_2Z_IMM:
3284 case AArch64::LD1W_2Z_STRIDED_IMM:
3285 case AArch64::LD1D_2Z_IMM:
3286 case AArch64::LD1D_2Z_STRIDED_IMM:
3287 case AArch64::LD1B_4Z_IMM:
3288 case AArch64::LD1B_4Z_STRIDED_IMM:
3289 case AArch64::LD1H_4Z_IMM:
3290 case AArch64::LD1H_4Z_STRIDED_IMM:
3291 case AArch64::LD1W_4Z_IMM:
3292 case AArch64::LD1W_4Z_STRIDED_IMM:
3293 case AArch64::LD1D_4Z_IMM:
3294 case AArch64::LD1D_4Z_STRIDED_IMM:
3295 case AArch64::LD1B_2Z_IMM_PSEUDO:
3296 case AArch64::LD1H_2Z_IMM_PSEUDO:
3297 case AArch64::LD1W_2Z_IMM_PSEUDO:
3298 case AArch64::LD1D_2Z_IMM_PSEUDO:
3299 case AArch64::LD1B_4Z_IMM_PSEUDO:
3300 case AArch64::LD1H_4Z_IMM_PSEUDO:
3301 case AArch64::LD1W_4Z_IMM_PSEUDO:
3302 case AArch64::LD1D_4Z_IMM_PSEUDO:
3303 case AArch64::ST1B_2Z_IMM:
3304 case AArch64::ST1B_2Z_STRIDED_IMM:
3305 case AArch64::ST1H_2Z_IMM:
3306 case AArch64::ST1H_2Z_STRIDED_IMM:
3307 case AArch64::ST1W_2Z_IMM:
3308 case AArch64::ST1W_2Z_STRIDED_IMM:
3309 case AArch64::ST1D_2Z_IMM:
3310 case AArch64::ST1D_2Z_STRIDED_IMM:
3311 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
3312 case AArch64::LDNT1B_2Z_IMM:
3313 case AArch64::LDNT1B_2Z_STRIDED_IMM:
3314 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
3315 case AArch64::LDNT1H_2Z_IMM:
3316 case AArch64::LDNT1H_2Z_STRIDED_IMM:
3317 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
3318 case AArch64::LDNT1W_2Z_IMM:
3319 case AArch64::LDNT1W_2Z_STRIDED_IMM:
3320 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
3321 case AArch64::LDNT1D_2Z_IMM:
3322 case AArch64::LDNT1D_2Z_STRIDED_IMM:
3323 case AArch64::STNT1B_2Z_IMM:
3324 case AArch64::STNT1B_2Z_STRIDED_IMM:
3325 case AArch64::STNT1H_2Z_IMM:
3326 case AArch64::STNT1H_2Z_STRIDED_IMM:
3327 case AArch64::STNT1W_2Z_IMM:
3328 case AArch64::STNT1W_2Z_STRIDED_IMM:
3329 case AArch64::STNT1D_2Z_IMM:
3330 case AArch64::STNT1D_2Z_STRIDED_IMM:
3331 case AArch64::ST1B_2Z_IMM_PSEUDO:
3332 case AArch64::ST1H_2Z_IMM_PSEUDO:
3333 case AArch64::ST1W_2Z_IMM_PSEUDO:
3334 case AArch64::ST1D_2Z_IMM_PSEUDO:
3335 case AArch64::STNT1B_2Z_IMM_PSEUDO:
3336 case AArch64::STNT1H_2Z_IMM_PSEUDO:
3337 case AArch64::STNT1W_2Z_IMM_PSEUDO:
3338 case AArch64::STNT1D_2Z_IMM_PSEUDO:
3339 case AArch64::ST1B_4Z_IMM:
3340 case AArch64::ST1B_4Z_STRIDED_IMM:
3341 case AArch64::ST1H_4Z_IMM:
3342 case AArch64::ST1H_4Z_STRIDED_IMM:
3343 case AArch64::ST1W_4Z_IMM:
3344 case AArch64::ST1W_4Z_STRIDED_IMM:
3345 case AArch64::ST1D_4Z_IMM:
3346 case AArch64::ST1D_4Z_STRIDED_IMM:
3347 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
3348 case AArch64::LDNT1B_4Z_IMM:
3349 case AArch64::LDNT1B_4Z_STRIDED_IMM:
3350 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
3351 case AArch64::LDNT1H_4Z_IMM:
3352 case AArch64::LDNT1H_4Z_STRIDED_IMM:
3353 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
3354 case AArch64::LDNT1W_4Z_IMM:
3355 case AArch64::LDNT1W_4Z_STRIDED_IMM:
3356 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
3357 case AArch64::LDNT1D_4Z_IMM:
3358 case AArch64::LDNT1D_4Z_STRIDED_IMM:
3359 case AArch64::STNT1B_4Z_IMM:
3360 case AArch64::STNT1B_4Z_STRIDED_IMM:
3361 case AArch64::STNT1H_4Z_IMM:
3362 case AArch64::STNT1H_4Z_STRIDED_IMM:
3363 case AArch64::STNT1W_4Z_IMM:
3364 case AArch64::STNT1W_4Z_STRIDED_IMM:
3365 case AArch64::STNT1D_4Z_IMM:
3366 case AArch64::STNT1D_4Z_STRIDED_IMM:
3367 case AArch64::ST1B_4Z_IMM_PSEUDO:
3368 case AArch64::ST1H_4Z_IMM_PSEUDO:
3369 case AArch64::ST1W_4Z_IMM_PSEUDO:
3370 case AArch64::ST1D_4Z_IMM_PSEUDO:
3371 case AArch64::STNT1B_4Z_IMM_PSEUDO:
3372 case AArch64::STNT1H_4Z_IMM_PSEUDO:
3373 case AArch64::STNT1W_4Z_IMM_PSEUDO:
3374 case AArch64::STNT1D_4Z_IMM_PSEUDO:
3376 case AArch64::LDPDpost:
3377 case AArch64::LDPDpre:
3378 case AArch64::LDPQpost:
3379 case AArch64::LDPQpre:
3380 case AArch64::LDPSpost:
3381 case AArch64::LDPSpre:
3382 case AArch64::LDPWpost:
3383 case AArch64::LDPWpre:
3384 case AArch64::LDPXpost:
3385 case AArch64::LDPXpre:
3386 case AArch64::STGPpre:
3387 case AArch64::STGPpost:
3388 case AArch64::STPDpost:
3389 case AArch64::STPDpre:
3390 case AArch64::STPQpost:
3391 case AArch64::STPQpre:
3392 case AArch64::STPSpost:
3393 case AArch64::STPSpre:
3394 case AArch64::STPWpost:
3395 case AArch64::STPWpre:
3396 case AArch64::STPXpost:
3397 case AArch64::STPXpre:
3403 switch (
MI.getOpcode()) {
3407 case AArch64::STRSui:
3408 case AArch64::STRDui:
3409 case AArch64::STRQui:
3410 case AArch64::STRXui:
3411 case AArch64::STRWui:
3412 case AArch64::LDRSui:
3413 case AArch64::LDRDui:
3414 case AArch64::LDRQui:
3415 case AArch64::LDRXui:
3416 case AArch64::LDRWui:
3417 case AArch64::LDRSWui:
3419 case AArch64::STURSi:
3420 case AArch64::STRSpre:
3421 case AArch64::STURDi:
3422 case AArch64::STRDpre:
3423 case AArch64::STURQi:
3424 case AArch64::STRQpre:
3425 case AArch64::STURWi:
3426 case AArch64::STRWpre:
3427 case AArch64::STURXi:
3428 case AArch64::STRXpre:
3429 case AArch64::LDURSi:
3430 case AArch64::LDRSpre:
3431 case AArch64::LDURDi:
3432 case AArch64::LDRDpre:
3433 case AArch64::LDURQi:
3434 case AArch64::LDRQpre:
3435 case AArch64::LDURWi:
3436 case AArch64::LDRWpre:
3437 case AArch64::LDURXi:
3438 case AArch64::LDRXpre:
3439 case AArch64::LDURSWi:
3440 case AArch64::LDRSWpre:
3442 case AArch64::LDR_ZXI:
3443 case AArch64::STR_ZXI:
3449 switch (
MI.getOpcode()) {
3452 "Unexpected instruction - was a new tail call opcode introduced?");
3454 case AArch64::TCRETURNdi:
3455 case AArch64::TCRETURNri:
3456 case AArch64::TCRETURNrix16x17:
3457 case AArch64::TCRETURNrix17:
3458 case AArch64::TCRETURNrinotx16:
3459 case AArch64::TCRETURNriALL:
3460 case AArch64::AUTH_TCRETURN:
3461 case AArch64::AUTH_TCRETURN_BTI:
3471 case AArch64::ADDWri:
3472 return AArch64::ADDSWri;
3473 case AArch64::ADDWrr:
3474 return AArch64::ADDSWrr;
3475 case AArch64::ADDWrs:
3476 return AArch64::ADDSWrs;
3477 case AArch64::ADDWrx:
3478 return AArch64::ADDSWrx;
3479 case AArch64::ANDWri:
3480 return AArch64::ANDSWri;
3481 case AArch64::ANDWrr:
3482 return AArch64::ANDSWrr;
3483 case AArch64::ANDWrs:
3484 return AArch64::ANDSWrs;
3485 case AArch64::BICWrr:
3486 return AArch64::BICSWrr;
3487 case AArch64::BICWrs:
3488 return AArch64::BICSWrs;
3489 case AArch64::SUBWri:
3490 return AArch64::SUBSWri;
3491 case AArch64::SUBWrr:
3492 return AArch64::SUBSWrr;
3493 case AArch64::SUBWrs:
3494 return AArch64::SUBSWrs;
3495 case AArch64::SUBWrx:
3496 return AArch64::SUBSWrx;
3498 case AArch64::ADDXri:
3499 return AArch64::ADDSXri;
3500 case AArch64::ADDXrr:
3501 return AArch64::ADDSXrr;
3502 case AArch64::ADDXrs:
3503 return AArch64::ADDSXrs;
3504 case AArch64::ADDXrx:
3505 return AArch64::ADDSXrx;
3506 case AArch64::ANDXri:
3507 return AArch64::ANDSXri;
3508 case AArch64::ANDXrr:
3509 return AArch64::ANDSXrr;
3510 case AArch64::ANDXrs:
3511 return AArch64::ANDSXrs;
3512 case AArch64::BICXrr:
3513 return AArch64::BICSXrr;
3514 case AArch64::BICXrs:
3515 return AArch64::BICSXrs;
3516 case AArch64::SUBXri:
3517 return AArch64::SUBSXri;
3518 case AArch64::SUBXrr:
3519 return AArch64::SUBSXrr;
3520 case AArch64::SUBXrs:
3521 return AArch64::SUBSXrs;
3522 case AArch64::SUBXrx:
3523 return AArch64::SUBSXrx;
3525 case AArch64::AND_PPzPP:
3526 return AArch64::ANDS_PPzPP;
3527 case AArch64::BIC_PPzPP:
3528 return AArch64::BICS_PPzPP;
3529 case AArch64::EOR_PPzPP:
3530 return AArch64::EORS_PPzPP;
3531 case AArch64::NAND_PPzPP:
3532 return AArch64::NANDS_PPzPP;
3533 case AArch64::NOR_PPzPP:
3534 return AArch64::NORS_PPzPP;
3535 case AArch64::ORN_PPzPP:
3536 return AArch64::ORNS_PPzPP;
3537 case AArch64::ORR_PPzPP:
3538 return AArch64::ORRS_PPzPP;
3539 case AArch64::BRKA_PPzP:
3540 return AArch64::BRKAS_PPzP;
3541 case AArch64::BRKPA_PPzPP:
3542 return AArch64::BRKPAS_PPzPP;
3543 case AArch64::BRKB_PPzP:
3544 return AArch64::BRKBS_PPzP;
3545 case AArch64::BRKPB_PPzPP:
3546 return AArch64::BRKPBS_PPzPP;
3547 case AArch64::BRKN_PPzP:
3548 return AArch64::BRKNS_PPzP;
3549 case AArch64::RDFFR_PPz:
3550 return AArch64::RDFFRS_PPz;
3551 case AArch64::PTRUE_B:
3552 return AArch64::PTRUES_B;
3563 if (
MI.hasOrderedMemoryRef())
3568 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
3569 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
3570 "Expected a reg or frame index operand.");
3574 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
3576 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
3589 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
3590 Register BaseReg =
MI.getOperand(1).getReg();
3592 if (
MI.modifiesRegister(BaseReg,
TRI))
3598 switch (
MI.getOpcode()) {
3601 case AArch64::LDR_ZXI:
3602 case AArch64::STR_ZXI:
3603 if (!Subtarget.isLittleEndian() ||
3604 Subtarget.getSVEVectorSizeInBits() != 128)
3617 const MCAsmInfo &MAI =
MI.getMF()->getTarget().getMCAsmInfo();
3625 if (Subtarget.isPaired128Slow()) {
3626 switch (
MI.getOpcode()) {
3629 case AArch64::LDURQi:
3630 case AArch64::STURQi:
3631 case AArch64::LDRQui:
3632 case AArch64::STRQui:
3659std::optional<ExtAddrMode>
3664 bool OffsetIsScalable;
3665 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
3666 return std::nullopt;
3669 return std::nullopt;
3684 int64_t OffsetScale = 1;
3689 case AArch64::LDURQi:
3690 case AArch64::STURQi:
3694 case AArch64::LDURDi:
3695 case AArch64::STURDi:
3696 case AArch64::LDURXi:
3697 case AArch64::STURXi:
3701 case AArch64::LDURWi:
3702 case AArch64::LDURSWi:
3703 case AArch64::STURWi:
3707 case AArch64::LDURHi:
3708 case AArch64::STURHi:
3709 case AArch64::LDURHHi:
3710 case AArch64::STURHHi:
3711 case AArch64::LDURSHXi:
3712 case AArch64::LDURSHWi:
3716 case AArch64::LDRBroX:
3717 case AArch64::LDRBBroX:
3718 case AArch64::LDRSBXroX:
3719 case AArch64::LDRSBWroX:
3720 case AArch64::STRBroX:
3721 case AArch64::STRBBroX:
3722 case AArch64::LDURBi:
3723 case AArch64::LDURBBi:
3724 case AArch64::LDURSBXi:
3725 case AArch64::LDURSBWi:
3726 case AArch64::STURBi:
3727 case AArch64::STURBBi:
3728 case AArch64::LDRBui:
3729 case AArch64::LDRBBui:
3730 case AArch64::LDRSBXui:
3731 case AArch64::LDRSBWui:
3732 case AArch64::STRBui:
3733 case AArch64::STRBBui:
3737 case AArch64::LDRQroX:
3738 case AArch64::STRQroX:
3739 case AArch64::LDRQui:
3740 case AArch64::STRQui:
3745 case AArch64::LDRDroX:
3746 case AArch64::STRDroX:
3747 case AArch64::LDRXroX:
3748 case AArch64::STRXroX:
3749 case AArch64::LDRDui:
3750 case AArch64::STRDui:
3751 case AArch64::LDRXui:
3752 case AArch64::STRXui:
3757 case AArch64::LDRWroX:
3758 case AArch64::LDRSWroX:
3759 case AArch64::STRWroX:
3760 case AArch64::LDRWui:
3761 case AArch64::LDRSWui:
3762 case AArch64::STRWui:
3767 case AArch64::LDRHroX:
3768 case AArch64::STRHroX:
3769 case AArch64::LDRHHroX:
3770 case AArch64::STRHHroX:
3771 case AArch64::LDRSHXroX:
3772 case AArch64::LDRSHWroX:
3773 case AArch64::LDRHui:
3774 case AArch64::STRHui:
3775 case AArch64::LDRHHui:
3776 case AArch64::STRHHui:
3777 case AArch64::LDRSHXui:
3778 case AArch64::LDRSHWui:
3786 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
3810 case AArch64::SBFMXri:
3823 AM.
Scale = OffsetScale;
3828 case TargetOpcode::SUBREG_TO_REG: {
3844 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3845 DefMI.getOperand(1).getReg() != AArch64::WZR ||
3846 DefMI.getOperand(3).getImm() != 0)
3853 AM.
Scale = OffsetScale;
3864 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3865 int64_t NewOffset) ->
bool {
3866 int64_t MinOffset, MaxOffset;
3883 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3884 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3886 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3888 int64_t NewOffset = OldOffset + Disp;
3889 if (!isLegalAddressingMode(NumBytes, NewOffset, 0))
3893 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3903 auto canFoldAddRegIntoAddrMode =
3908 if ((
unsigned)Scale != Scale)
3910 if (!isLegalAddressingMode(NumBytes, 0, Scale))
3922 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3923 Subtarget.isSTRQroSlow();
3932 case AArch64::ADDXri:
3938 return canFoldAddSubImmIntoAddrMode(Disp);
3940 case AArch64::SUBXri:
3946 return canFoldAddSubImmIntoAddrMode(-Disp);
3948 case AArch64::ADDXrs: {
3961 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3963 if (avoidSlowSTRQ(MemI))
3966 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3969 case AArch64::ADDXrr:
3977 if (!OptSize && avoidSlowSTRQ(MemI))
3979 return canFoldAddRegIntoAddrMode(1);
3981 case AArch64::ADDXrx:
3989 if (!OptSize && avoidSlowSTRQ(MemI))
3998 return canFoldAddRegIntoAddrMode(
4013 case AArch64::LDURQi:
4014 case AArch64::LDRQui:
4015 return AArch64::LDRQroX;
4016 case AArch64::STURQi:
4017 case AArch64::STRQui:
4018 return AArch64::STRQroX;
4019 case AArch64::LDURDi:
4020 case AArch64::LDRDui:
4021 return AArch64::LDRDroX;
4022 case AArch64::STURDi:
4023 case AArch64::STRDui:
4024 return AArch64::STRDroX;
4025 case AArch64::LDURXi:
4026 case AArch64::LDRXui:
4027 return AArch64::LDRXroX;
4028 case AArch64::STURXi:
4029 case AArch64::STRXui:
4030 return AArch64::STRXroX;
4031 case AArch64::LDURWi:
4032 case AArch64::LDRWui:
4033 return AArch64::LDRWroX;
4034 case AArch64::LDURSWi:
4035 case AArch64::LDRSWui:
4036 return AArch64::LDRSWroX;
4037 case AArch64::STURWi:
4038 case AArch64::STRWui:
4039 return AArch64::STRWroX;
4040 case AArch64::LDURHi:
4041 case AArch64::LDRHui:
4042 return AArch64::LDRHroX;
4043 case AArch64::STURHi:
4044 case AArch64::STRHui:
4045 return AArch64::STRHroX;
4046 case AArch64::LDURHHi:
4047 case AArch64::LDRHHui:
4048 return AArch64::LDRHHroX;
4049 case AArch64::STURHHi:
4050 case AArch64::STRHHui:
4051 return AArch64::STRHHroX;
4052 case AArch64::LDURSHXi:
4053 case AArch64::LDRSHXui:
4054 return AArch64::LDRSHXroX;
4055 case AArch64::LDURSHWi:
4056 case AArch64::LDRSHWui:
4057 return AArch64::LDRSHWroX;
4058 case AArch64::LDURBi:
4059 case AArch64::LDRBui:
4060 return AArch64::LDRBroX;
4061 case AArch64::LDURBBi:
4062 case AArch64::LDRBBui:
4063 return AArch64::LDRBBroX;
4064 case AArch64::LDURSBXi:
4065 case AArch64::LDRSBXui:
4066 return AArch64::LDRSBXroX;
4067 case AArch64::LDURSBWi:
4068 case AArch64::LDRSBWui:
4069 return AArch64::LDRSBWroX;
4070 case AArch64::STURBi:
4071 case AArch64::STRBui:
4072 return AArch64::STRBroX;
4073 case AArch64::STURBBi:
4074 case AArch64::STRBBui:
4075 return AArch64::STRBBroX;
4087 case AArch64::LDURQi:
4089 return AArch64::LDRQui;
4090 case AArch64::STURQi:
4092 return AArch64::STRQui;
4093 case AArch64::LDURDi:
4095 return AArch64::LDRDui;
4096 case AArch64::STURDi:
4098 return AArch64::STRDui;
4099 case AArch64::LDURXi:
4101 return AArch64::LDRXui;
4102 case AArch64::STURXi:
4104 return AArch64::STRXui;
4105 case AArch64::LDURWi:
4107 return AArch64::LDRWui;
4108 case AArch64::LDURSWi:
4110 return AArch64::LDRSWui;
4111 case AArch64::STURWi:
4113 return AArch64::STRWui;
4114 case AArch64::LDURHi:
4116 return AArch64::LDRHui;
4117 case AArch64::STURHi:
4119 return AArch64::STRHui;
4120 case AArch64::LDURHHi:
4122 return AArch64::LDRHHui;
4123 case AArch64::STURHHi:
4125 return AArch64::STRHHui;
4126 case AArch64::LDURSHXi:
4128 return AArch64::LDRSHXui;
4129 case AArch64::LDURSHWi:
4131 return AArch64::LDRSHWui;
4132 case AArch64::LDURBi:
4134 return AArch64::LDRBui;
4135 case AArch64::LDURBBi:
4137 return AArch64::LDRBBui;
4138 case AArch64::LDURSBXi:
4140 return AArch64::LDRSBXui;
4141 case AArch64::LDURSBWi:
4143 return AArch64::LDRSBWui;
4144 case AArch64::STURBi:
4146 return AArch64::STRBui;
4147 case AArch64::STURBBi:
4149 return AArch64::STRBBui;
4150 case AArch64::LDRQui:
4151 case AArch64::STRQui:
4154 case AArch64::LDRDui:
4155 case AArch64::STRDui:
4156 case AArch64::LDRXui:
4157 case AArch64::STRXui:
4160 case AArch64::LDRWui:
4161 case AArch64::LDRSWui:
4162 case AArch64::STRWui:
4165 case AArch64::LDRHui:
4166 case AArch64::STRHui:
4167 case AArch64::LDRHHui:
4168 case AArch64::STRHHui:
4169 case AArch64::LDRSHXui:
4170 case AArch64::LDRSHWui:
4173 case AArch64::LDRBui:
4174 case AArch64::LDRBBui:
4175 case AArch64::LDRSBXui:
4176 case AArch64::LDRSBWui:
4177 case AArch64::STRBui:
4178 case AArch64::STRBBui:
4192 case AArch64::LDURQi:
4193 case AArch64::STURQi:
4194 case AArch64::LDURDi:
4195 case AArch64::STURDi:
4196 case AArch64::LDURXi:
4197 case AArch64::STURXi:
4198 case AArch64::LDURWi:
4199 case AArch64::LDURSWi:
4200 case AArch64::STURWi:
4201 case AArch64::LDURHi:
4202 case AArch64::STURHi:
4203 case AArch64::LDURHHi:
4204 case AArch64::STURHHi:
4205 case AArch64::LDURSHXi:
4206 case AArch64::LDURSHWi:
4207 case AArch64::LDURBi:
4208 case AArch64::STURBi:
4209 case AArch64::LDURBBi:
4210 case AArch64::STURBBi:
4211 case AArch64::LDURSBWi:
4212 case AArch64::LDURSBXi:
4214 case AArch64::LDRQui:
4215 return AArch64::LDURQi;
4216 case AArch64::STRQui:
4217 return AArch64::STURQi;
4218 case AArch64::LDRDui:
4219 return AArch64::LDURDi;
4220 case AArch64::STRDui:
4221 return AArch64::STURDi;
4222 case AArch64::LDRXui:
4223 return AArch64::LDURXi;
4224 case AArch64::STRXui:
4225 return AArch64::STURXi;
4226 case AArch64::LDRWui:
4227 return AArch64::LDURWi;
4228 case AArch64::LDRSWui:
4229 return AArch64::LDURSWi;
4230 case AArch64::STRWui:
4231 return AArch64::STURWi;
4232 case AArch64::LDRHui:
4233 return AArch64::LDURHi;
4234 case AArch64::STRHui:
4235 return AArch64::STURHi;
4236 case AArch64::LDRHHui:
4237 return AArch64::LDURHHi;
4238 case AArch64::STRHHui:
4239 return AArch64::STURHHi;
4240 case AArch64::LDRSHXui:
4241 return AArch64::LDURSHXi;
4242 case AArch64::LDRSHWui:
4243 return AArch64::LDURSHWi;
4244 case AArch64::LDRBBui:
4245 return AArch64::LDURBBi;
4246 case AArch64::LDRBui:
4247 return AArch64::LDURBi;
4248 case AArch64::STRBBui:
4249 return AArch64::STURBBi;
4250 case AArch64::STRBui:
4251 return AArch64::STURBi;
4252 case AArch64::LDRSBWui:
4253 return AArch64::LDURSBWi;
4254 case AArch64::LDRSBXui:
4255 return AArch64::LDURSBXi;
4268 case AArch64::LDRQroX:
4269 case AArch64::LDURQi:
4270 case AArch64::LDRQui:
4271 return AArch64::LDRQroW;
4272 case AArch64::STRQroX:
4273 case AArch64::STURQi:
4274 case AArch64::STRQui:
4275 return AArch64::STRQroW;
4276 case AArch64::LDRDroX:
4277 case AArch64::LDURDi:
4278 case AArch64::LDRDui:
4279 return AArch64::LDRDroW;
4280 case AArch64::STRDroX:
4281 case AArch64::STURDi:
4282 case AArch64::STRDui:
4283 return AArch64::STRDroW;
4284 case AArch64::LDRXroX:
4285 case AArch64::LDURXi:
4286 case AArch64::LDRXui:
4287 return AArch64::LDRXroW;
4288 case AArch64::STRXroX:
4289 case AArch64::STURXi:
4290 case AArch64::STRXui:
4291 return AArch64::STRXroW;
4292 case AArch64::LDRWroX:
4293 case AArch64::LDURWi:
4294 case AArch64::LDRWui:
4295 return AArch64::LDRWroW;
4296 case AArch64::LDRSWroX:
4297 case AArch64::LDURSWi:
4298 case AArch64::LDRSWui:
4299 return AArch64::LDRSWroW;
4300 case AArch64::STRWroX:
4301 case AArch64::STURWi:
4302 case AArch64::STRWui:
4303 return AArch64::STRWroW;
4304 case AArch64::LDRHroX:
4305 case AArch64::LDURHi:
4306 case AArch64::LDRHui:
4307 return AArch64::LDRHroW;
4308 case AArch64::STRHroX:
4309 case AArch64::STURHi:
4310 case AArch64::STRHui:
4311 return AArch64::STRHroW;
4312 case AArch64::LDRHHroX:
4313 case AArch64::LDURHHi:
4314 case AArch64::LDRHHui:
4315 return AArch64::LDRHHroW;
4316 case AArch64::STRHHroX:
4317 case AArch64::STURHHi:
4318 case AArch64::STRHHui:
4319 return AArch64::STRHHroW;
4320 case AArch64::LDRSHXroX:
4321 case AArch64::LDURSHXi:
4322 case AArch64::LDRSHXui:
4323 return AArch64::LDRSHXroW;
4324 case AArch64::LDRSHWroX:
4325 case AArch64::LDURSHWi:
4326 case AArch64::LDRSHWui:
4327 return AArch64::LDRSHWroW;
4328 case AArch64::LDRBroX:
4329 case AArch64::LDURBi:
4330 case AArch64::LDRBui:
4331 return AArch64::LDRBroW;
4332 case AArch64::LDRBBroX:
4333 case AArch64::LDURBBi:
4334 case AArch64::LDRBBui:
4335 return AArch64::LDRBBroW;
4336 case AArch64::LDRSBXroX:
4337 case AArch64::LDURSBXi:
4338 case AArch64::LDRSBXui:
4339 return AArch64::LDRSBXroW;
4340 case AArch64::LDRSBWroX:
4341 case AArch64::LDURSBWi:
4342 case AArch64::LDRSBWui:
4343 return AArch64::LDRSBWroW;
4344 case AArch64::STRBroX:
4345 case AArch64::STURBi:
4346 case AArch64::STRBui:
4347 return AArch64::STRBroW;
4348 case AArch64::STRBBroX:
4349 case AArch64::STURBBi:
4350 case AArch64::STRBBui:
4351 return AArch64::STRBBroW;
4376 return B.getInstr();
4380 "Addressing mode not supported for folding");
4397 return B.getInstr();
4404 "Address offset can be a register or an immediate, but not both");
4425 return B.getInstr();
4429 "Function must not be called with an addressing mode it can't handle");
4438 case AArch64::LD1Fourv16b_POST:
4439 case AArch64::LD1Fourv1d_POST:
4440 case AArch64::LD1Fourv2d_POST:
4441 case AArch64::LD1Fourv2s_POST:
4442 case AArch64::LD1Fourv4h_POST:
4443 case AArch64::LD1Fourv4s_POST:
4444 case AArch64::LD1Fourv8b_POST:
4445 case AArch64::LD1Fourv8h_POST:
4446 case AArch64::LD1Onev16b_POST:
4447 case AArch64::LD1Onev1d_POST:
4448 case AArch64::LD1Onev2d_POST:
4449 case AArch64::LD1Onev2s_POST:
4450 case AArch64::LD1Onev4h_POST:
4451 case AArch64::LD1Onev4s_POST:
4452 case AArch64::LD1Onev8b_POST:
4453 case AArch64::LD1Onev8h_POST:
4454 case AArch64::LD1Rv16b_POST:
4455 case AArch64::LD1Rv1d_POST:
4456 case AArch64::LD1Rv2d_POST:
4457 case AArch64::LD1Rv2s_POST:
4458 case AArch64::LD1Rv4h_POST:
4459 case AArch64::LD1Rv4s_POST:
4460 case AArch64::LD1Rv8b_POST:
4461 case AArch64::LD1Rv8h_POST:
4462 case AArch64::LD1Threev16b_POST:
4463 case AArch64::LD1Threev1d_POST:
4464 case AArch64::LD1Threev2d_POST:
4465 case AArch64::LD1Threev2s_POST:
4466 case AArch64::LD1Threev4h_POST:
4467 case AArch64::LD1Threev4s_POST:
4468 case AArch64::LD1Threev8b_POST:
4469 case AArch64::LD1Threev8h_POST:
4470 case AArch64::LD1Twov16b_POST:
4471 case AArch64::LD1Twov1d_POST:
4472 case AArch64::LD1Twov2d_POST:
4473 case AArch64::LD1Twov2s_POST:
4474 case AArch64::LD1Twov4h_POST:
4475 case AArch64::LD1Twov4s_POST:
4476 case AArch64::LD1Twov8b_POST:
4477 case AArch64::LD1Twov8h_POST:
4478 case AArch64::LD1i16_POST:
4479 case AArch64::LD1i32_POST:
4480 case AArch64::LD1i64_POST:
4481 case AArch64::LD1i8_POST:
4482 case AArch64::LD2Rv16b_POST:
4483 case AArch64::LD2Rv1d_POST:
4484 case AArch64::LD2Rv2d_POST:
4485 case AArch64::LD2Rv2s_POST:
4486 case AArch64::LD2Rv4h_POST:
4487 case AArch64::LD2Rv4s_POST:
4488 case AArch64::LD2Rv8b_POST:
4489 case AArch64::LD2Rv8h_POST:
4490 case AArch64::LD2Twov16b_POST:
4491 case AArch64::LD2Twov2d_POST:
4492 case AArch64::LD2Twov2s_POST:
4493 case AArch64::LD2Twov4h_POST:
4494 case AArch64::LD2Twov4s_POST:
4495 case AArch64::LD2Twov8b_POST:
4496 case AArch64::LD2Twov8h_POST:
4497 case AArch64::LD2i16_POST:
4498 case AArch64::LD2i32_POST:
4499 case AArch64::LD2i64_POST:
4500 case AArch64::LD2i8_POST:
4501 case AArch64::LD3Rv16b_POST:
4502 case AArch64::LD3Rv1d_POST:
4503 case AArch64::LD3Rv2d_POST:
4504 case AArch64::LD3Rv2s_POST:
4505 case AArch64::LD3Rv4h_POST:
4506 case AArch64::LD3Rv4s_POST:
4507 case AArch64::LD3Rv8b_POST:
4508 case AArch64::LD3Rv8h_POST:
4509 case AArch64::LD3Threev16b_POST:
4510 case AArch64::LD3Threev2d_POST:
4511 case AArch64::LD3Threev2s_POST:
4512 case AArch64::LD3Threev4h_POST:
4513 case AArch64::LD3Threev4s_POST:
4514 case AArch64::LD3Threev8b_POST:
4515 case AArch64::LD3Threev8h_POST:
4516 case AArch64::LD3i16_POST:
4517 case AArch64::LD3i32_POST:
4518 case AArch64::LD3i64_POST:
4519 case AArch64::LD3i8_POST:
4520 case AArch64::LD4Fourv16b_POST:
4521 case AArch64::LD4Fourv2d_POST:
4522 case AArch64::LD4Fourv2s_POST:
4523 case AArch64::LD4Fourv4h_POST:
4524 case AArch64::LD4Fourv4s_POST:
4525 case AArch64::LD4Fourv8b_POST:
4526 case AArch64::LD4Fourv8h_POST:
4527 case AArch64::LD4Rv16b_POST:
4528 case AArch64::LD4Rv1d_POST:
4529 case AArch64::LD4Rv2d_POST:
4530 case AArch64::LD4Rv2s_POST:
4531 case AArch64::LD4Rv4h_POST:
4532 case AArch64::LD4Rv4s_POST:
4533 case AArch64::LD4Rv8b_POST:
4534 case AArch64::LD4Rv8h_POST:
4535 case AArch64::LD4i16_POST:
4536 case AArch64::LD4i32_POST:
4537 case AArch64::LD4i64_POST:
4538 case AArch64::LD4i8_POST:
4539 case AArch64::LDAPRWpost:
4540 case AArch64::LDAPRXpost:
4541 case AArch64::LDIAPPWpost:
4542 case AArch64::LDIAPPXpost:
4543 case AArch64::LDPDpost:
4544 case AArch64::LDPQpost:
4545 case AArch64::LDPSWpost:
4546 case AArch64::LDPSpost:
4547 case AArch64::LDPWpost:
4548 case AArch64::LDPXpost:
4549 case AArch64::LDRBBpost:
4550 case AArch64::LDRBpost:
4551 case AArch64::LDRDpost:
4552 case AArch64::LDRHHpost:
4553 case AArch64::LDRHpost:
4554 case AArch64::LDRQpost:
4555 case AArch64::LDRSBWpost:
4556 case AArch64::LDRSBXpost:
4557 case AArch64::LDRSHWpost:
4558 case AArch64::LDRSHXpost:
4559 case AArch64::LDRSWpost:
4560 case AArch64::LDRSpost:
4561 case AArch64::LDRWpost:
4562 case AArch64::LDRXpost:
4563 case AArch64::ST1Fourv16b_POST:
4564 case AArch64::ST1Fourv1d_POST:
4565 case AArch64::ST1Fourv2d_POST:
4566 case AArch64::ST1Fourv2s_POST:
4567 case AArch64::ST1Fourv4h_POST:
4568 case AArch64::ST1Fourv4s_POST:
4569 case AArch64::ST1Fourv8b_POST:
4570 case AArch64::ST1Fourv8h_POST:
4571 case AArch64::ST1Onev16b_POST:
4572 case AArch64::ST1Onev1d_POST:
4573 case AArch64::ST1Onev2d_POST:
4574 case AArch64::ST1Onev2s_POST:
4575 case AArch64::ST1Onev4h_POST:
4576 case AArch64::ST1Onev4s_POST:
4577 case AArch64::ST1Onev8b_POST:
4578 case AArch64::ST1Onev8h_POST:
4579 case AArch64::ST1Threev16b_POST:
4580 case AArch64::ST1Threev1d_POST:
4581 case AArch64::ST1Threev2d_POST:
4582 case AArch64::ST1Threev2s_POST:
4583 case AArch64::ST1Threev4h_POST:
4584 case AArch64::ST1Threev4s_POST:
4585 case AArch64::ST1Threev8b_POST:
4586 case AArch64::ST1Threev8h_POST:
4587 case AArch64::ST1Twov16b_POST:
4588 case AArch64::ST1Twov1d_POST:
4589 case AArch64::ST1Twov2d_POST:
4590 case AArch64::ST1Twov2s_POST:
4591 case AArch64::ST1Twov4h_POST:
4592 case AArch64::ST1Twov4s_POST:
4593 case AArch64::ST1Twov8b_POST:
4594 case AArch64::ST1Twov8h_POST:
4595 case AArch64::ST1i16_POST:
4596 case AArch64::ST1i32_POST:
4597 case AArch64::ST1i64_POST:
4598 case AArch64::ST1i8_POST:
4599 case AArch64::ST2GPostIndex:
4600 case AArch64::ST2Twov16b_POST:
4601 case AArch64::ST2Twov2d_POST:
4602 case AArch64::ST2Twov2s_POST:
4603 case AArch64::ST2Twov4h_POST:
4604 case AArch64::ST2Twov4s_POST:
4605 case AArch64::ST2Twov8b_POST:
4606 case AArch64::ST2Twov8h_POST:
4607 case AArch64::ST2i16_POST:
4608 case AArch64::ST2i32_POST:
4609 case AArch64::ST2i64_POST:
4610 case AArch64::ST2i8_POST:
4611 case AArch64::ST3Threev16b_POST:
4612 case AArch64::ST3Threev2d_POST:
4613 case AArch64::ST3Threev2s_POST:
4614 case AArch64::ST3Threev4h_POST:
4615 case AArch64::ST3Threev4s_POST:
4616 case AArch64::ST3Threev8b_POST:
4617 case AArch64::ST3Threev8h_POST:
4618 case AArch64::ST3i16_POST:
4619 case AArch64::ST3i32_POST:
4620 case AArch64::ST3i64_POST:
4621 case AArch64::ST3i8_POST:
4622 case AArch64::ST4Fourv16b_POST:
4623 case AArch64::ST4Fourv2d_POST:
4624 case AArch64::ST4Fourv2s_POST:
4625 case AArch64::ST4Fourv4h_POST:
4626 case AArch64::ST4Fourv4s_POST:
4627 case AArch64::ST4Fourv8b_POST:
4628 case AArch64::ST4Fourv8h_POST:
4629 case AArch64::ST4i16_POST:
4630 case AArch64::ST4i32_POST:
4631 case AArch64::ST4i64_POST:
4632 case AArch64::ST4i8_POST:
4633 case AArch64::STGPostIndex:
4634 case AArch64::STGPpost:
4635 case AArch64::STPDpost:
4636 case AArch64::STPQpost:
4637 case AArch64::STPSpost:
4638 case AArch64::STPWpost:
4639 case AArch64::STPXpost:
4640 case AArch64::STRBBpost:
4641 case AArch64::STRBpost:
4642 case AArch64::STRDpost:
4643 case AArch64::STRHHpost:
4644 case AArch64::STRHpost:
4645 case AArch64::STRQpost:
4646 case AArch64::STRSpost:
4647 case AArch64::STRWpost:
4648 case AArch64::STRXpost:
4649 case AArch64::STZ2GPostIndex:
4650 case AArch64::STZGPostIndex:
4657 bool &OffsetIsScalable,
TypeSize &Width,
4678 int64_t Dummy1, Dummy2;
4700 return BaseOp->
isReg() || BaseOp->
isFI();
4707 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
4712 TypeSize &Width, int64_t &MinOffset,
4713 int64_t &MaxOffset) {
4718 MinOffset = MaxOffset = 0;
4721 case AArch64::LDRQui:
4722 case AArch64::STRQui:
4727 case AArch64::LDRXui:
4728 case AArch64::LDRDui:
4729 case AArch64::STRXui:
4730 case AArch64::STRDui:
4731 case AArch64::PRFMui:
4736 case AArch64::LDRWui:
4737 case AArch64::LDRSui:
4738 case AArch64::LDRSWui:
4739 case AArch64::STRWui:
4740 case AArch64::STRSui:
4745 case AArch64::LDRHui:
4746 case AArch64::LDRHHui:
4747 case AArch64::LDRSHWui:
4748 case AArch64::LDRSHXui:
4749 case AArch64::STRHui:
4750 case AArch64::STRHHui:
4755 case AArch64::LDRBui:
4756 case AArch64::LDRBBui:
4757 case AArch64::LDRSBWui:
4758 case AArch64::LDRSBXui:
4759 case AArch64::STRBui:
4760 case AArch64::STRBBui:
4766 case AArch64::STRQpre:
4767 case AArch64::LDRQpost:
4773 case AArch64::LDRDpost:
4774 case AArch64::LDRDpre:
4775 case AArch64::LDRXpost:
4776 case AArch64::LDRXpre:
4777 case AArch64::STRDpost:
4778 case AArch64::STRDpre:
4779 case AArch64::STRXpost:
4780 case AArch64::STRXpre:
4786 case AArch64::STRWpost:
4787 case AArch64::STRWpre:
4788 case AArch64::LDRWpost:
4789 case AArch64::LDRWpre:
4790 case AArch64::STRSpost:
4791 case AArch64::STRSpre:
4792 case AArch64::LDRSpost:
4793 case AArch64::LDRSpre:
4799 case AArch64::LDRHpost:
4800 case AArch64::LDRHpre:
4801 case AArch64::STRHpost:
4802 case AArch64::STRHpre:
4803 case AArch64::LDRHHpost:
4804 case AArch64::LDRHHpre:
4805 case AArch64::STRHHpost:
4806 case AArch64::STRHHpre:
4812 case AArch64::LDRBpost:
4813 case AArch64::LDRBpre:
4814 case AArch64::STRBpost:
4815 case AArch64::STRBpre:
4816 case AArch64::LDRBBpost:
4817 case AArch64::LDRBBpre:
4818 case AArch64::STRBBpost:
4819 case AArch64::STRBBpre:
4825 case AArch64::LDURQi:
4826 case AArch64::STURQi:
4832 case AArch64::LDURXi:
4833 case AArch64::LDURDi:
4834 case AArch64::LDAPURXi:
4835 case AArch64::STURXi:
4836 case AArch64::STURDi:
4837 case AArch64::STLURXi:
4838 case AArch64::PRFUMi:
4844 case AArch64::LDURWi:
4845 case AArch64::LDURSi:
4846 case AArch64::LDURSWi:
4847 case AArch64::LDAPURi:
4848 case AArch64::LDAPURSWi:
4849 case AArch64::STURWi:
4850 case AArch64::STURSi:
4851 case AArch64::STLURWi:
4857 case AArch64::LDURHi:
4858 case AArch64::LDURHHi:
4859 case AArch64::LDURSHXi:
4860 case AArch64::LDURSHWi:
4861 case AArch64::LDAPURHi:
4862 case AArch64::LDAPURSHWi:
4863 case AArch64::LDAPURSHXi:
4864 case AArch64::STURHi:
4865 case AArch64::STURHHi:
4866 case AArch64::STLURHi:
4872 case AArch64::LDURBi:
4873 case AArch64::LDURBBi:
4874 case AArch64::LDURSBXi:
4875 case AArch64::LDURSBWi:
4876 case AArch64::LDAPURBi:
4877 case AArch64::LDAPURSBWi:
4878 case AArch64::LDAPURSBXi:
4879 case AArch64::STURBi:
4880 case AArch64::STURBBi:
4881 case AArch64::STLURBi:
4887 case AArch64::LDPQi:
4888 case AArch64::LDNPQi:
4889 case AArch64::STPQi:
4890 case AArch64::STNPQi:
4891 case AArch64::LDPQpost:
4892 case AArch64::LDPQpre:
4893 case AArch64::STPQpost:
4894 case AArch64::STPQpre:
4900 case AArch64::LDPXi:
4901 case AArch64::LDPDi:
4902 case AArch64::LDNPXi:
4903 case AArch64::LDNPDi:
4904 case AArch64::STPXi:
4905 case AArch64::STPDi:
4906 case AArch64::STNPXi:
4907 case AArch64::STNPDi:
4908 case AArch64::LDPDpost:
4909 case AArch64::LDPDpre:
4910 case AArch64::LDPXpost:
4911 case AArch64::LDPXpre:
4912 case AArch64::STPDpost:
4913 case AArch64::STPDpre:
4914 case AArch64::STPXpost:
4915 case AArch64::STPXpre:
4921 case AArch64::LDPWi:
4922 case AArch64::LDPSi:
4923 case AArch64::LDNPWi:
4924 case AArch64::LDNPSi:
4925 case AArch64::STPWi:
4926 case AArch64::STPSi:
4927 case AArch64::STNPWi:
4928 case AArch64::STNPSi:
4929 case AArch64::LDPSpost:
4930 case AArch64::LDPSpre:
4931 case AArch64::LDPWpost:
4932 case AArch64::LDPWpre:
4933 case AArch64::STPSpost:
4934 case AArch64::STPSpre:
4935 case AArch64::STPWpost:
4936 case AArch64::STPWpre:
4942 case AArch64::StoreSwiftAsyncContext:
4955 case AArch64::TAGPstack:
4965 case AArch64::STGPreIndex:
4966 case AArch64::STGPostIndex:
4967 case AArch64::STZGi:
4968 case AArch64::STZGPreIndex:
4969 case AArch64::STZGPostIndex:
4975 case AArch64::STR_ZZZZXI:
4976 case AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS:
4977 case AArch64::LDR_ZZZZXI:
4978 case AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS:
4984 case AArch64::STR_ZZZXI:
4985 case AArch64::LDR_ZZZXI:
4991 case AArch64::STR_ZZXI:
4992 case AArch64::STR_ZZXI_STRIDED_CONTIGUOUS:
4993 case AArch64::LDR_ZZXI:
4994 case AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS:
5000 case AArch64::LDR_PXI:
5001 case AArch64::STR_PXI:
5006 case AArch64::LDR_PPXI:
5007 case AArch64::STR_PPXI:
5013 case AArch64::LDR_ZXI:
5014 case AArch64::STR_ZXI:
5019 case AArch64::LD1B_IMM:
5020 case AArch64::LD1H_IMM:
5021 case AArch64::LD1W_IMM:
5022 case AArch64::LD1D_IMM:
5023 case AArch64::LDNT1B_ZRI:
5024 case AArch64::LDNT1H_ZRI:
5025 case AArch64::LDNT1W_ZRI:
5026 case AArch64::LDNT1D_ZRI:
5027 case AArch64::ST1B_IMM:
5028 case AArch64::ST1H_IMM:
5029 case AArch64::ST1W_IMM:
5030 case AArch64::ST1D_IMM:
5031 case AArch64::STNT1B_ZRI:
5032 case AArch64::STNT1H_ZRI:
5033 case AArch64::STNT1W_ZRI:
5034 case AArch64::STNT1D_ZRI:
5035 case AArch64::LDNF1B_IMM:
5036 case AArch64::LDNF1H_IMM:
5037 case AArch64::LDNF1W_IMM:
5038 case AArch64::LDNF1D_IMM:
5045 case AArch64::LD2B_IMM:
5046 case AArch64::LD2H_IMM:
5047 case AArch64::LD2W_IMM:
5048 case AArch64::LD2D_IMM:
5049 case AArch64::ST2B_IMM:
5050 case AArch64::ST2H_IMM:
5051 case AArch64::ST2W_IMM:
5052 case AArch64::ST2D_IMM:
5053 case AArch64::LD1B_2Z_IMM:
5054 case AArch64::LD1B_2Z_STRIDED_IMM:
5055 case AArch64::LD1H_2Z_IMM:
5056 case AArch64::LD1H_2Z_STRIDED_IMM:
5057 case AArch64::LD1W_2Z_IMM:
5058 case AArch64::LD1W_2Z_STRIDED_IMM:
5059 case AArch64::LD1D_2Z_IMM:
5060 case AArch64::LD1D_2Z_STRIDED_IMM:
5061 case AArch64::LD1B_2Z_IMM_PSEUDO:
5062 case AArch64::LD1H_2Z_IMM_PSEUDO:
5063 case AArch64::LD1W_2Z_IMM_PSEUDO:
5064 case AArch64::LD1D_2Z_IMM_PSEUDO:
5065 case AArch64::ST1B_2Z_IMM:
5066 case AArch64::ST1B_2Z_STRIDED_IMM:
5067 case AArch64::ST1H_2Z_IMM:
5068 case AArch64::ST1H_2Z_STRIDED_IMM:
5069 case AArch64::ST1W_2Z_IMM:
5070 case AArch64::ST1W_2Z_STRIDED_IMM:
5071 case AArch64::ST1D_2Z_IMM:
5072 case AArch64::ST1D_2Z_STRIDED_IMM:
5073 case AArch64::LDNT1B_2Z_IMM_PSEUDO:
5074 case AArch64::LDNT1B_2Z_IMM:
5075 case AArch64::LDNT1B_2Z_STRIDED_IMM:
5076 case AArch64::LDNT1H_2Z_IMM_PSEUDO:
5077 case AArch64::LDNT1H_2Z_IMM:
5078 case AArch64::LDNT1H_2Z_STRIDED_IMM:
5079 case AArch64::LDNT1W_2Z_IMM_PSEUDO:
5080 case AArch64::LDNT1W_2Z_IMM:
5081 case AArch64::LDNT1W_2Z_STRIDED_IMM:
5082 case AArch64::LDNT1D_2Z_IMM_PSEUDO:
5083 case AArch64::LDNT1D_2Z_IMM:
5084 case AArch64::LDNT1D_2Z_STRIDED_IMM:
5085 case AArch64::STNT1B_2Z_IMM:
5086 case AArch64::STNT1B_2Z_STRIDED_IMM:
5087 case AArch64::STNT1H_2Z_IMM:
5088 case AArch64::STNT1H_2Z_STRIDED_IMM:
5089 case AArch64::STNT1W_2Z_IMM:
5090 case AArch64::STNT1W_2Z_STRIDED_IMM:
5091 case AArch64::STNT1D_2Z_IMM:
5092 case AArch64::STNT1D_2Z_STRIDED_IMM:
5093 case AArch64::ST1B_2Z_IMM_PSEUDO:
5094 case AArch64::ST1H_2Z_IMM_PSEUDO:
5095 case AArch64::ST1W_2Z_IMM_PSEUDO:
5096 case AArch64::ST1D_2Z_IMM_PSEUDO:
5097 case AArch64::STNT1B_2Z_IMM_PSEUDO:
5098 case AArch64::STNT1H_2Z_IMM_PSEUDO:
5099 case AArch64::STNT1W_2Z_IMM_PSEUDO:
5100 case AArch64::STNT1D_2Z_IMM_PSEUDO:
5105 case AArch64::LD3B_IMM:
5106 case AArch64::LD3H_IMM:
5107 case AArch64::LD3W_IMM:
5108 case AArch64::LD3D_IMM:
5109 case AArch64::ST3B_IMM:
5110 case AArch64::ST3H_IMM:
5111 case AArch64::ST3W_IMM:
5112 case AArch64::ST3D_IMM:
5117 case AArch64::LD4B_IMM:
5118 case AArch64::LD4H_IMM:
5119 case AArch64::LD4W_IMM:
5120 case AArch64::LD4D_IMM:
5121 case AArch64::ST4B_IMM:
5122 case AArch64::ST4H_IMM:
5123 case AArch64::ST4W_IMM:
5124 case AArch64::ST4D_IMM:
5125 case AArch64::LD1B_4Z_IMM:
5126 case AArch64::LD1B_4Z_STRIDED_IMM:
5127 case AArch64::LD1H_4Z_IMM:
5128 case AArch64::LD1H_4Z_STRIDED_IMM:
5129 case AArch64::LD1W_4Z_IMM:
5130 case AArch64::LD1W_4Z_STRIDED_IMM:
5131 case AArch64::LD1D_4Z_IMM:
5132 case AArch64::LD1D_4Z_STRIDED_IMM:
5133 case AArch64::LD1B_4Z_IMM_PSEUDO:
5134 case AArch64::LD1H_4Z_IMM_PSEUDO:
5135 case AArch64::LD1W_4Z_IMM_PSEUDO:
5136 case AArch64::LD1D_4Z_IMM_PSEUDO:
5137 case AArch64::ST1B_4Z_IMM:
5138 case AArch64::ST1B_4Z_STRIDED_IMM:
5139 case AArch64::ST1H_4Z_IMM:
5140 case AArch64::ST1H_4Z_STRIDED_IMM:
5141 case AArch64::ST1W_4Z_IMM:
5142 case AArch64::ST1W_4Z_STRIDED_IMM:
5143 case AArch64::ST1D_4Z_IMM:
5144 case AArch64::ST1D_4Z_STRIDED_IMM:
5145 case AArch64::LDNT1B_4Z_IMM_PSEUDO:
5146 case AArch64::LDNT1B_4Z_IMM:
5147 case AArch64::LDNT1B_4Z_STRIDED_IMM:
5148 case AArch64::LDNT1H_4Z_IMM_PSEUDO:
5149 case AArch64::LDNT1H_4Z_IMM:
5150 case AArch64::LDNT1H_4Z_STRIDED_IMM:
5151 case AArch64::LDNT1W_4Z_IMM_PSEUDO:
5152 case AArch64::LDNT1W_4Z_IMM:
5153 case AArch64::LDNT1W_4Z_STRIDED_IMM:
5154 case AArch64::LDNT1D_4Z_IMM_PSEUDO:
5155 case AArch64::LDNT1D_4Z_IMM:
5156 case AArch64::LDNT1D_4Z_STRIDED_IMM:
5157 case AArch64::STNT1B_4Z_IMM:
5158 case AArch64::STNT1B_4Z_STRIDED_IMM:
5159 case AArch64::STNT1H_4Z_IMM:
5160 case AArch64::STNT1H_4Z_STRIDED_IMM:
5161 case AArch64::STNT1W_4Z_IMM:
5162 case AArch64::STNT1W_4Z_STRIDED_IMM:
5163 case AArch64::STNT1D_4Z_IMM:
5164 case AArch64::STNT1D_4Z_STRIDED_IMM:
5165 case AArch64::ST1B_4Z_IMM_PSEUDO:
5166 case AArch64::ST1H_4Z_IMM_PSEUDO:
5167 case AArch64::ST1W_4Z_IMM_PSEUDO:
5168 case AArch64::ST1D_4Z_IMM_PSEUDO:
5169 case AArch64::STNT1B_4Z_IMM_PSEUDO:
5170 case AArch64::STNT1H_4Z_IMM_PSEUDO:
5171 case AArch64::STNT1W_4Z_IMM_PSEUDO:
5172 case AArch64::STNT1D_4Z_IMM_PSEUDO:
5177 case AArch64::LD1B_H_IMM:
5178 case AArch64::LD1SB_H_IMM:
5179 case AArch64::LD1H_S_IMM:
5180 case AArch64::LD1SH_S_IMM:
5181 case AArch64::LD1W_D_IMM:
5182 case AArch64::LD1SW_D_IMM:
5183 case AArch64::ST1B_H_IMM:
5184 case AArch64::ST1H_S_IMM:
5185 case AArch64::ST1W_D_IMM:
5186 case AArch64::LDNF1B_H_IMM:
5187 case AArch64::LDNF1SB_H_IMM:
5188 case AArch64::LDNF1H_S_IMM:
5189 case AArch64::LDNF1SH_S_IMM:
5190 case AArch64::LDNF1W_D_IMM:
5191 case AArch64::LDNF1SW_D_IMM:
5198 case AArch64::LD1B_S_IMM:
5199 case AArch64::LD1SB_S_IMM:
5200 case AArch64::LD1H_D_IMM:
5201 case AArch64::LD1SH_D_IMM:
5202 case AArch64::ST1B_S_IMM:
5203 case AArch64::ST1H_D_IMM:
5204 case AArch64::LDNF1B_S_IMM:
5205 case AArch64::LDNF1SB_S_IMM:
5206 case AArch64::LDNF1H_D_IMM:
5207 case AArch64::LDNF1SH_D_IMM:
5214 case AArch64::LD1B_D_IMM:
5215 case AArch64::LD1SB_D_IMM:
5216 case AArch64::ST1B_D_IMM:
5217 case AArch64::LDNF1B_D_IMM:
5218 case AArch64::LDNF1SB_D_IMM:
5225 case AArch64::ST2Gi:
5226 case AArch64::ST2GPreIndex:
5227 case AArch64::ST2GPostIndex:
5228 case AArch64::STZ2Gi:
5229 case AArch64::STZ2GPreIndex:
5230 case AArch64::STZ2GPostIndex:
5236 case AArch64::STGPi:
5237 case AArch64::STGPpost:
5238 case AArch64::STGPpre:
5243 case AArch64::LD1RB_IMM:
5244 case AArch64::LD1RB_H_IMM:
5245 case AArch64::LD1RB_S_IMM:
5246 case AArch64::LD1RB_D_IMM:
5247 case AArch64::LD1RSB_H_IMM:
5248 case AArch64::LD1RSB_S_IMM:
5249 case AArch64::LD1RSB_D_IMM:
5254 case AArch64::LD1RH_IMM:
5255 case AArch64::LD1RH_S_IMM:
5256 case AArch64::LD1RH_D_IMM:
5257 case AArch64::LD1RSH_S_IMM:
5258 case AArch64::LD1RSH_D_IMM:
5263 case AArch64::LD1RW_IMM:
5264 case AArch64::LD1RW_D_IMM:
5265 case AArch64::LD1RSW_IMM:
5270 case AArch64::LD1RD_IMM:
5285 case AArch64::LDRBui:
5286 case AArch64::LDRBBui:
5287 case AArch64::LDURBBi:
5288 case AArch64::LDRSBWui:
5289 case AArch64::LDURSBWi:
5290 case AArch64::STRBui:
5291 case AArch64::STRBBui:
5292 case AArch64::STURBBi:
5294 case AArch64::LDRHui:
5295 case AArch64::LDRHHui:
5296 case AArch64::LDURHHi:
5297 case AArch64::LDRSHWui:
5298 case AArch64::LDURSHWi:
5299 case AArch64::STRHui:
5300 case AArch64::STRHHui:
5301 case AArch64::STURHHi:
5303 case AArch64::LDRSui:
5304 case AArch64::LDURSi:
5305 case AArch64::LDRSpre:
5306 case AArch64::LDRSWui:
5307 case AArch64::LDURSWi:
5308 case AArch64::LDRSWpre:
5309 case AArch64::LDRWpre:
5310 case AArch64::LDRWui:
5311 case AArch64::LDURWi:
5312 case AArch64::STRSui:
5313 case AArch64::STURSi:
5314 case AArch64::STRSpre:
5315 case AArch64::STRWui:
5316 case AArch64::STURWi:
5317 case AArch64::STRWpre:
5318 case AArch64::LDPSi:
5319 case AArch64::LDPSWi:
5320 case AArch64::LDPWi:
5321 case AArch64::STPSi:
5322 case AArch64::STPWi:
5324 case AArch64::LDRDui:
5325 case AArch64::LDURDi:
5326 case AArch64::LDRDpre:
5327 case AArch64::LDRXui:
5328 case AArch64::LDURXi:
5329 case AArch64::LDRXpre:
5330 case AArch64::STRDui:
5331 case AArch64::STURDi:
5332 case AArch64::STRDpre:
5333 case AArch64::STRXui:
5334 case AArch64::STURXi:
5335 case AArch64::STRXpre:
5336 case AArch64::LDPDi:
5337 case AArch64::LDPXi:
5338 case AArch64::STPDi:
5339 case AArch64::STPXi:
5341 case AArch64::LDRQui:
5342 case AArch64::LDURQi:
5343 case AArch64::STRQui:
5344 case AArch64::STURQi:
5345 case AArch64::STRQpre:
5346 case AArch64::LDPQi:
5347 case AArch64::LDRQpre:
5348 case AArch64::STPQi:
5350 case AArch64::STZGi:
5351 case AArch64::ST2Gi:
5352 case AArch64::STZ2Gi:
5353 case AArch64::STGPi:
5359 switch (
MI.getOpcode()) {
5362 case AArch64::LDRWpre:
5363 case AArch64::LDRXpre:
5364 case AArch64::LDRSWpre:
5365 case AArch64::LDRSpre:
5366 case AArch64::LDRDpre:
5367 case AArch64::LDRQpre:
5373 switch (
MI.getOpcode()) {
5376 case AArch64::STRWpre:
5377 case AArch64::STRXpre:
5378 case AArch64::STRSpre:
5379 case AArch64::STRDpre:
5380 case AArch64::STRQpre:
5390 switch (
MI.getOpcode()) {
5393 case AArch64::LDURBBi:
5394 case AArch64::LDURHHi:
5395 case AArch64::LDURWi:
5396 case AArch64::LDRBBui:
5397 case AArch64::LDRHHui:
5398 case AArch64::LDRWui:
5399 case AArch64::LDRBBroX:
5400 case AArch64::LDRHHroX:
5401 case AArch64::LDRWroX:
5402 case AArch64::LDRBBroW:
5403 case AArch64::LDRHHroW:
5404 case AArch64::LDRWroW:
5410 switch (
MI.getOpcode()) {
5413 case AArch64::LDURSBWi:
5414 case AArch64::LDURSHWi:
5415 case AArch64::LDURSBXi:
5416 case AArch64::LDURSHXi:
5417 case AArch64::LDURSWi:
5418 case AArch64::LDRSBWui:
5419 case AArch64::LDRSHWui:
5420 case AArch64::LDRSBXui:
5421 case AArch64::LDRSHXui:
5422 case AArch64::LDRSWui:
5423 case AArch64::LDRSBWroX:
5424 case AArch64::LDRSHWroX:
5425 case AArch64::LDRSBXroX:
5426 case AArch64::LDRSHXroX:
5427 case AArch64::LDRSWroX:
5428 case AArch64::LDRSBWroW:
5429 case AArch64::LDRSHWroW:
5430 case AArch64::LDRSBXroW:
5431 case AArch64::LDRSHXroW:
5432 case AArch64::LDRSWroW:
5438 switch (
MI.getOpcode()) {
5441 case AArch64::LDPSi:
5442 case AArch64::LDPSWi:
5443 case AArch64::LDPDi:
5444 case AArch64::LDPQi:
5445 case AArch64::LDPWi:
5446 case AArch64::LDPXi:
5447 case AArch64::STPSi:
5448 case AArch64::STPDi:
5449 case AArch64::STPQi:
5450 case AArch64::STPWi:
5451 case AArch64::STPXi:
5452 case AArch64::STGPi:
5458 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5462 return MI.getOperand(Idx);
5467 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
5471 return MI.getOperand(Idx);
5476 switch (
MI.getOpcode()) {
5479 case AArch64::LDRBroX:
5480 case AArch64::LDRBBroX:
5481 case AArch64::LDRSBXroX:
5482 case AArch64::LDRSBWroX:
5483 case AArch64::LDRHroX:
5484 case AArch64::LDRHHroX:
5485 case AArch64::LDRSHXroX:
5486 case AArch64::LDRSHWroX:
5487 case AArch64::LDRWroX:
5488 case AArch64::LDRSroX:
5489 case AArch64::LDRSWroX:
5490 case AArch64::LDRDroX:
5491 case AArch64::LDRXroX:
5492 case AArch64::LDRQroX:
5493 return MI.getOperand(4);
5499 if (
MI.getParent() ==
nullptr)
5509 auto Reg =
Op.getReg();
5510 if (Reg.isPhysical())
5511 return AArch64::FPR16RegClass.contains(Reg);
5513 return TRC == &AArch64::FPR16RegClass ||
5514 TRC == &AArch64::FPR16_loRegClass;
5523 auto Reg =
Op.getReg();
5524 if (Reg.isPhysical())
5525 return AArch64::FPR128RegClass.contains(Reg);
5527 return TRC == &AArch64::FPR128RegClass ||
5528 TRC == &AArch64::FPR128_loRegClass;
5534 switch (
MI.getOpcode()) {
5537 case AArch64::PACIASP:
5538 case AArch64::PACIBSP:
5541 case AArch64::PAUTH_PROLOGUE:
5544 case AArch64::HINT: {
5545 unsigned Imm =
MI.getOperand(0).getImm();
5550 if (
Imm == 25 ||
Imm == 27)
5562 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
5563 return AArch64::FPR128RegClass.contains(Reg) ||
5564 AArch64::FPR64RegClass.contains(Reg) ||
5565 AArch64::FPR32RegClass.contains(Reg) ||
5566 AArch64::FPR16RegClass.contains(Reg) ||
5567 AArch64::FPR8RegClass.contains(Reg);
5574 auto Reg =
Op.getReg();
5575 if (Reg.isPhysical())
5579 return TRC == &AArch64::FPR128RegClass ||
5580 TRC == &AArch64::FPR128_loRegClass ||
5581 TRC == &AArch64::FPR64RegClass ||
5582 TRC == &AArch64::FPR64_loRegClass ||
5583 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
5584 TRC == &AArch64::FPR8RegClass;
5606 if (FirstOpc == SecondOpc)
5612 case AArch64::STRSui:
5613 case AArch64::STURSi:
5614 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
5615 case AArch64::STRDui:
5616 case AArch64::STURDi:
5617 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
5618 case AArch64::STRQui:
5619 case AArch64::STURQi:
5620 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
5621 case AArch64::STRWui:
5622 case AArch64::STURWi:
5623 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
5624 case AArch64::STRXui:
5625 case AArch64::STURXi:
5626 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
5627 case AArch64::LDRSui:
5628 case AArch64::LDURSi:
5629 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
5630 case AArch64::LDRDui:
5631 case AArch64::LDURDi:
5632 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
5633 case AArch64::LDRQui:
5634 case AArch64::LDURQi:
5635 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
5636 case AArch64::LDRWui:
5637 case AArch64::LDURWi:
5638 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
5639 case AArch64::LDRSWui:
5640 case AArch64::LDURSWi:
5641 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
5642 case AArch64::LDRXui:
5643 case AArch64::LDURXi:
5644 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
5651 int64_t Offset1,
unsigned Opcode1,
int FI2,
5652 int64_t Offset2,
unsigned Opcode2) {
5658 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
5661 if (ObjectOffset1 % Scale1 != 0)
5663 ObjectOffset1 /= Scale1;
5665 if (ObjectOffset2 % Scale2 != 0)
5667 ObjectOffset2 /= Scale2;
5668 ObjectOffset1 += Offset1;
5669 ObjectOffset2 += Offset2;
5670 return ObjectOffset1 + 1 == ObjectOffset2;
5682 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
5683 unsigned NumBytes)
const {
5693 "Only base registers and frame indices are supported.");
5700 if (ClusterSize > 2)
5707 unsigned FirstOpc = FirstLdSt.
getOpcode();
5708 unsigned SecondOpc = SecondLdSt.
getOpcode();
5728 if (Offset1 > 63 || Offset1 < -64)
5733 if (BaseOp1.
isFI()) {
5735 "Caller should have ordered offsets.");
5740 BaseOp2.
getIndex(), Offset2, SecondOpc);
5743 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
5745 return Offset1 + 1 == Offset2;
5755 if (
Reg.isPhysical())
5765 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
5767 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5768 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5769 unsigned NumRegs = Indices.
size();
5770 MCRegister DestSubReg =
TRI->getSubReg(DestReg, Indices[0]);
5772 "Unexpected predicate tuple copy");
5773 unsigned MaxRegs = AArch64::PPRRegClass.contains(DestSubReg) ? 15 : 31;
5775 int SubReg = 0, End = NumRegs, Incr = 1;
5777 if (((DestEncoding - SrcEncoding) & MaxRegs) < NumRegs) {
5778 SubReg = NumRegs - 1;
5783 for (; SubReg != End; SubReg += Incr) {
5784 DestSubReg =
TRI->getSubReg(DestReg, Indices[SubReg]);
5785 MCRegister SrcSubReg =
TRI->getSubReg(SrcReg, Indices[SubReg]);
5794 unsigned Opcode,
unsigned ZeroReg,
5797 unsigned NumRegs = Indices.
size();
5800 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
5801 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
5802 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
5803 "GPR reg sequences should not be able to overlap");
5806 for (
unsigned SubReg = 0; SubReg != NumRegs; ++SubReg) {
5827 unsigned Opc =
MI.getOpcode();
5828 if (
Opc == AArch64::MSRpstatesvcrImm1 ||
Opc == AArch64::MSRpstatePseudo) {
5830 int64_t PState =
MI.getOperand(0).getImm();
5831 if (PState == AArch64SVCR::SVCRSM || PState == AArch64SVCR::SVCRSMZA) {
5833 return MI.getOperand(1).getImm() == 1;
5852 bool RenamableSrc)
const {
5853 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
5854 AArch64::GPR32spRegClass.
contains(SrcReg)) {
5855 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
5857 if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5858 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5860 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5861 &AArch64::GPR64spRegClass);
5862 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5863 &AArch64::GPR64spRegClass);
5873 ++NumZCRegMoveInstrsGPR;
5879 if (Subtarget.hasZeroCycleRegMoveGPR32())
5880 ++NumZCRegMoveInstrsGPR;
5882 }
else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5883 !Subtarget.hasZeroCycleRegMoveGPR32()) {
5885 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5886 &AArch64::GPR64spRegClass);
5887 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5888 MCRegister SrcRegX = RI.getMatchingSuperReg(SrcReg, AArch64::sub_32,
5889 &AArch64::GPR64spRegClass);
5899 ++NumZCRegMoveInstrsGPR;
5905 if (Subtarget.hasZeroCycleRegMoveGPR32())
5906 ++NumZCRegMoveInstrsGPR;
5912 if (AArch64::GPR32spRegClass.
contains(DestReg) && SrcReg == AArch64::WZR) {
5913 if (Subtarget.hasZeroCycleZeroingGPR64() &&
5914 !Subtarget.hasZeroCycleZeroingGPR32()) {
5915 MCRegister DestRegX = RI.getMatchingSuperReg(DestReg, AArch64::sub_32,
5916 &AArch64::GPR64spRegClass);
5917 assert(DestRegX.
isValid() &&
"Destination super-reg not valid");
5921 ++NumZCZeroingInstrsGPR;
5922 }
else if (Subtarget.hasZeroCycleZeroingGPR32()) {
5926 ++NumZCZeroingInstrsGPR;
5935 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
5936 AArch64::GPR64spRegClass.
contains(SrcReg)) {
5937 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5943 if (Subtarget.hasZeroCycleRegMoveGPR64())
5944 ++NumZCRegMoveInstrsGPR;
5950 if (Subtarget.hasZeroCycleRegMoveGPR64())
5951 ++NumZCRegMoveInstrsGPR;
5957 if (AArch64::GPR64spRegClass.
contains(DestReg) && SrcReg == AArch64::XZR) {
5958 if (Subtarget.hasZeroCycleZeroingGPR64()) {
5962 ++NumZCZeroingInstrsGPR;
5972 if (AArch64::PPRRegClass.
contains(DestReg) &&
5973 AArch64::PPRRegClass.
contains(SrcReg)) {
5974 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
5975 "Unexpected SVE register.");
5985 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
5986 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
5987 if (DestIsPNR || SrcIsPNR) {
5989 return (R - AArch64::PN0) + AArch64::P0;
5994 if (PPRSrcReg != PPRDestReg) {
6006 if (AArch64::PPR2RegClass.
contains(DestReg) &&
6007 AArch64::PPR2RegClass.
contains(SrcReg)) {
6008 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6009 "Unexpected SVE predicate register.");
6010 static const unsigned Indices[] = {AArch64::psub0, AArch64::psub1};
6016 if (AArch64::ZPRRegClass.
contains(DestReg) &&
6017 AArch64::ZPRRegClass.
contains(SrcReg)) {
6018 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6019 "Unexpected SVE register.");
6027 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
6028 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
6029 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
6030 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
6031 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6032 "Unexpected SVE register.");
6033 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
6039 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
6040 AArch64::ZPR3RegClass.
contains(SrcReg)) {
6041 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6042 "Unexpected SVE register.");
6043 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6050 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
6051 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
6052 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
6053 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
6054 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6055 "Unexpected SVE register.");
6056 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
6057 AArch64::zsub2, AArch64::zsub3};
6063 if (AArch64::DDDDRegClass.
contains(DestReg) &&
6064 AArch64::DDDDRegClass.
contains(SrcReg)) {
6065 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6066 AArch64::dsub2, AArch64::dsub3};
6072 if (AArch64::DDDRegClass.
contains(DestReg) &&
6073 AArch64::DDDRegClass.
contains(SrcReg)) {
6074 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
6081 if (AArch64::DDRegClass.
contains(DestReg) &&
6082 AArch64::DDRegClass.
contains(SrcReg)) {
6083 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
6089 if (AArch64::QQQQRegClass.
contains(DestReg) &&
6090 AArch64::QQQQRegClass.
contains(SrcReg)) {
6091 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6092 AArch64::qsub2, AArch64::qsub3};
6098 if (AArch64::QQQRegClass.
contains(DestReg) &&
6099 AArch64::QQQRegClass.
contains(SrcReg)) {
6100 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
6107 if (AArch64::QQRegClass.
contains(DestReg) &&
6108 AArch64::QQRegClass.
contains(SrcReg)) {
6109 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
6114 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
6115 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
6116 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
6118 AArch64::XZR, Indices);
6122 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
6123 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
6124 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
6126 AArch64::WZR, Indices);
6130 if (AArch64::FPR128RegClass.
contains(DestReg) &&
6131 AArch64::FPR128RegClass.
contains(SrcReg)) {
6135 if ((Subtarget.isSVEorStreamingSVEAvailable() &&
6136 !Subtarget.isNeonAvailable()) ||
6140 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
6141 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
6142 }
else if (Subtarget.isNeonAvailable()) {
6146 if (Subtarget.hasZeroCycleRegMoveFPR128())
6147 ++NumZCRegMoveInstrsFPR;
6163 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6164 AArch64::FPR64RegClass.
contains(SrcReg)) {
6165 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6166 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6167 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6169 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
6170 &AArch64::FPR128RegClass);
6171 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
6172 &AArch64::FPR128RegClass);
6181 ++NumZCRegMoveInstrsFPR;
6185 if (Subtarget.hasZeroCycleRegMoveFPR64())
6186 ++NumZCRegMoveInstrsFPR;
6191 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6192 AArch64::FPR32RegClass.
contains(SrcReg)) {
6193 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6194 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6195 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6197 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6198 &AArch64::FPR128RegClass);
6199 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6200 &AArch64::FPR128RegClass);
6209 ++NumZCRegMoveInstrsFPR;
6210 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6211 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6212 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
6213 &AArch64::FPR64RegClass);
6214 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
6215 &AArch64::FPR64RegClass);
6223 ++NumZCRegMoveInstrsFPR;
6227 if (Subtarget.hasZeroCycleRegMoveFPR32())
6228 ++NumZCRegMoveInstrsFPR;
6233 if (AArch64::FPR16RegClass.
contains(DestReg) &&
6234 AArch64::FPR16RegClass.
contains(SrcReg)) {
6235 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6236 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6237 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6239 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6240 &AArch64::FPR128RegClass);
6241 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6242 &AArch64::FPR128RegClass);
6251 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6252 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6253 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6254 &AArch64::FPR64RegClass);
6255 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6256 &AArch64::FPR64RegClass);
6265 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
6266 &AArch64::FPR32RegClass);
6267 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
6268 &AArch64::FPR32RegClass);
6275 if (AArch64::FPR8RegClass.
contains(DestReg) &&
6276 AArch64::FPR8RegClass.
contains(SrcReg)) {
6277 if (Subtarget.hasZeroCycleRegMoveFPR128() &&
6278 !Subtarget.hasZeroCycleRegMoveFPR64() &&
6279 !Subtarget.hasZeroCycleRegMoveFPR32() && Subtarget.isNeonAvailable() &&
6281 MCRegister DestRegQ = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6282 &AArch64::FPR128RegClass);
6283 MCRegister SrcRegQ = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6284 &AArch64::FPR128RegClass);
6293 }
else if (Subtarget.hasZeroCycleRegMoveFPR64() &&
6294 !Subtarget.hasZeroCycleRegMoveFPR32()) {
6295 MCRegister DestRegD = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6296 &AArch64::FPR64RegClass);
6297 MCRegister SrcRegD = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6298 &AArch64::FPR64RegClass);
6307 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
6308 &AArch64::FPR32RegClass);
6309 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
6310 &AArch64::FPR32RegClass);
6318 if (AArch64::FPR64RegClass.
contains(DestReg) &&
6319 AArch64::GPR64RegClass.
contains(SrcReg)) {
6320 if (AArch64::XZR == SrcReg) {
6328 if (AArch64::GPR64RegClass.
contains(DestReg) &&
6329 AArch64::FPR64RegClass.
contains(SrcReg)) {
6335 if (AArch64::FPR32RegClass.
contains(DestReg) &&
6336 AArch64::GPR32RegClass.
contains(SrcReg)) {
6337 if (AArch64::WZR == SrcReg) {
6345 if (AArch64::GPR32RegClass.
contains(DestReg) &&
6346 AArch64::FPR32RegClass.
contains(SrcReg)) {
6352 if (DestReg == AArch64::NZCV) {
6353 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
6355 .
addImm(AArch64SysReg::NZCV)
6361 if (SrcReg == AArch64::NZCV) {
6362 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
6364 .
addImm(AArch64SysReg::NZCV)
6370 errs() << RI.getRegAsmName(DestReg) <<
" = COPY " << RI.getRegAsmName(SrcReg)
6381 bool RenamableSrc)
const {
6393 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
6398 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
6400 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
6413 Register SrcReg,
bool isKill,
int FI,
6428 switch (RI.getSpillSize(*RC)) {
6430 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6431 Opc = AArch64::STRBui;
6434 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6435 Opc = AArch64::STRHui;
6436 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
6437 AArch64::PPRRegClass.hasSubClassEq(RC)) {
6438 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6439 "Unexpected register store without SVE store instructions");
6440 Opc = AArch64::STR_PXI;
6446 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6447 Opc = AArch64::STRWui;
6451 assert(SrcReg != AArch64::WSP);
6452 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6453 Opc = AArch64::STRSui;
6454 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6455 Opc = AArch64::STR_PPXI;
6460 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6461 Opc = AArch64::STRXui;
6465 assert(SrcReg != AArch64::SP);
6466 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6467 Opc = AArch64::STRDui;
6468 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6470 get(AArch64::STPWi), SrcReg, isKill,
6471 AArch64::sube32, AArch64::subo32, FI, MMO);
6476 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6477 Opc = AArch64::STRQui;
6478 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6479 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6480 Opc = AArch64::ST1Twov1d;
6482 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6484 get(AArch64::STPXi), SrcReg, isKill,
6485 AArch64::sube64, AArch64::subo64, FI, MMO);
6487 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6488 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6489 "Unexpected register store without SVE store instructions");
6490 Opc = AArch64::STR_ZXI;
6495 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6496 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6497 Opc = AArch64::ST1Threev1d;
6502 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6503 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6504 Opc = AArch64::ST1Fourv1d;
6506 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6507 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6508 Opc = AArch64::ST1Twov2d;
6510 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6511 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6512 "Unexpected register store without SVE store instructions");
6513 Opc = AArch64::STR_ZZXI_STRIDED_CONTIGUOUS;
6515 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6516 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6517 "Unexpected register store without SVE store instructions");
6518 Opc = AArch64::STR_ZZXI;
6523 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6524 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6525 Opc = AArch64::ST1Threev2d;
6527 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6528 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6529 "Unexpected register store without SVE store instructions");
6530 Opc = AArch64::STR_ZZZXI;
6535 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6536 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
6537 Opc = AArch64::ST1Fourv2d;
6539 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6540 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6541 "Unexpected register store without SVE store instructions");
6542 Opc = AArch64::STR_ZZZZXI_STRIDED_CONTIGUOUS;
6544 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6545 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6546 "Unexpected register store without SVE store instructions");
6547 Opc = AArch64::STR_ZZZZXI;
6552 assert(
Opc &&
"Unknown register class");
6563 MI.addMemOperand(MMO);
6570 Register DestReg,
unsigned SubIdx0,
6571 unsigned SubIdx1,
int FI,
6575 bool IsUndef =
true;
6577 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
6579 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
6608 switch (
TRI.getSpillSize(*RC)) {
6610 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
6611 Opc = AArch64::LDRBui;
6614 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
6615 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
6616 Opc = AArch64::LDRHui;
6617 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
6618 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6619 "Unexpected register load without SVE load instructions");
6622 Opc = AArch64::LDR_PXI;
6628 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
6629 Opc = AArch64::LDRWui;
6633 assert(DestReg != AArch64::WSP);
6634 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
6635 Opc = AArch64::LDRSui;
6636 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
6637 Opc = AArch64::LDR_PPXI;
6642 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
6643 Opc = AArch64::LDRXui;
6647 assert(DestReg != AArch64::SP);
6648 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
6649 Opc = AArch64::LDRDui;
6650 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
6652 get(AArch64::LDPWi), DestReg, AArch64::sube32,
6653 AArch64::subo32, FI, MMO);
6658 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
6659 Opc = AArch64::LDRQui;
6660 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
6661 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6662 Opc = AArch64::LD1Twov1d;
6664 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
6666 get(AArch64::LDPXi), DestReg, AArch64::sube64,
6667 AArch64::subo64, FI, MMO);
6669 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
6670 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6671 "Unexpected register load without SVE load instructions");
6672 Opc = AArch64::LDR_ZXI;
6677 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
6678 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6679 Opc = AArch64::LD1Threev1d;
6684 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
6685 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6686 Opc = AArch64::LD1Fourv1d;
6688 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
6689 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6690 Opc = AArch64::LD1Twov2d;
6692 }
else if (AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6693 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6694 "Unexpected register load without SVE load instructions");
6695 Opc = AArch64::LDR_ZZXI_STRIDED_CONTIGUOUS;
6697 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC)) {
6698 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6699 "Unexpected register load without SVE load instructions");
6700 Opc = AArch64::LDR_ZZXI;
6705 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
6706 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6707 Opc = AArch64::LD1Threev2d;
6709 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
6710 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6711 "Unexpected register load without SVE load instructions");
6712 Opc = AArch64::LDR_ZZZXI;
6717 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
6718 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
6719 Opc = AArch64::LD1Fourv2d;
6721 }
else if (AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
6722 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6723 "Unexpected register load without SVE load instructions");
6724 Opc = AArch64::LDR_ZZZZXI_STRIDED_CONTIGUOUS;
6726 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC)) {
6727 assert(Subtarget.isSVEorStreamingSVEAvailable() &&
6728 "Unexpected register load without SVE load instructions");
6729 Opc = AArch64::LDR_ZZZZXI;
6735 assert(
Opc &&
"Unknown register class");
6745 MI.addMemOperand(MMO);
6752 UseMI.getIterator()),
6754 return I.modifiesRegister(AArch64::NZCV, TRI) ||
6755 I.readsRegister(AArch64::NZCV, TRI);
6759void AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6764 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6771 ByteSized =
Offset.getFixed();
6772 VGSized =
Offset.getScalable() / 2;
6778void AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
6780 int64_t &NumDataVectors) {
6784 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
6786 NumBytes =
Offset.getFixed();
6788 NumPredicateVectors =
Offset.getScalable() / 2;
6793 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
6794 NumPredicateVectors > 62) {
6795 NumDataVectors = NumPredicateVectors / 8;
6796 NumPredicateVectors -= NumDataVectors * 8;
6822 Expr.
push_back((
char)dwarf::DW_OP_bregx);
6830 int64_t OffsetFromDefCFA) {
6844 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
6845 if (!RegScale.empty())
6855 int64_t NumBytes, NumVGScaledBytes;
6856 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
Offset, NumBytes,
6858 std::string CommentBuffer;
6861 if (
Reg == AArch64::SP)
6863 else if (
Reg == AArch64::FP)
6870 unsigned DwarfReg =
TRI.getDwarfRegNum(
Reg,
true);
6871 assert(DwarfReg <= 31 &&
"DwarfReg out of bounds (0..31)");
6873 Expr.
push_back(dwarf::DW_OP_breg0 + DwarfReg);
6876 if (NumVGScaledBytes) {
6886 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
6894 unsigned FrameReg,
unsigned Reg,
6896 bool LastAdjustmentWasScalable) {
6897 if (
Offset.getScalable())
6900 if (FrameReg == Reg && !LastAdjustmentWasScalable)
6903 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6910 std::optional<int64_t> IncomingVGOffsetFromDefCFA) {
6911 int64_t NumBytes, NumVGScaledBytes;
6912 AArch64InstrInfo::decomposeStackOffsetForDwarfOffsets(
6913 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
6915 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
6918 if (!NumVGScaledBytes)
6921 std::string CommentBuffer;
6926 assert(NumVGScaledBytes &&
"Expected scalable offset");
6930 if (IncomingVGOffsetFromDefCFA) {
6932 VGRegScale =
"* IncomingVG";
6935 VGRegScale =
"* VG";
6939 OffsetExpr.
push_back(dwarf::DW_OP_plus);
6948 CfaExpr.
push_back(dwarf::DW_CFA_expression);
6963 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
6966 bool *HasWinCFI,
bool EmitCFAOffset,
6969 unsigned MaxEncoding, ShiftSize;
6971 case AArch64::ADDXri:
6972 case AArch64::ADDSXri:
6973 case AArch64::SUBXri:
6974 case AArch64::SUBSXri:
6975 MaxEncoding = 0xfff;
6978 case AArch64::ADDVL_XXI:
6979 case AArch64::ADDPL_XXI:
6980 case AArch64::ADDSVL_XXI:
6981 case AArch64::ADDSPL_XXI:
6996 if (
Opc == AArch64::ADDVL_XXI ||
Opc == AArch64::ADDSVL_XXI)
6998 else if (
Opc == AArch64::ADDPL_XXI ||
Opc == AArch64::ADDSPL_XXI)
7012 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
7014 if (TmpReg == AArch64::XZR)
7015 TmpReg =
MBB.getParent()->getRegInfo().createVirtualRegister(
7016 &AArch64::GPR64RegClass);
7018 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
7019 unsigned LocalShiftSize = 0;
7020 if (ThisVal > MaxEncoding) {
7021 ThisVal = ThisVal >> ShiftSize;
7022 LocalShiftSize = ShiftSize;
7024 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
7025 "Encoding cannot handle value that big");
7027 Offset -= ThisVal << LocalShiftSize;
7032 .
addImm(Sign * (
int)ThisVal);
7042 if (Sign == -1 ||
Opc == AArch64::SUBXri ||
Opc == AArch64::SUBSXri)
7043 CFAOffset += Change;
7045 CFAOffset -= Change;
7046 if (EmitCFAOffset && DestReg == TmpReg) {
7059 int Imm = (int)(ThisVal << LocalShiftSize);
7060 if (VScale != 1 && DestReg == AArch64::SP) {
7066 }
else if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
7067 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
7068 assert(VScale == 1 &&
"Expected non-scalable operation");
7077 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
7078 "emit a single SEH directive");
7079 }
else if (DestReg == AArch64::SP) {
7080 assert(VScale == 1 &&
"Expected non-scalable operation");
7083 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
7096 unsigned DestReg,
unsigned SrcReg,
7099 bool NeedsWinCFI,
bool *HasWinCFI,
7101 unsigned FrameReg) {
7108 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
7110 int64_t Bytes, NumPredicateVectors, NumDataVectors;
7111 AArch64InstrInfo::decomposeStackOffsetForFrameOffsets(
7112 Offset, Bytes, NumPredicateVectors, NumDataVectors);
7115 bool NeedsFinalDefNZCV = SetNZCV && (NumPredicateVectors || NumDataVectors);
7116 if (NeedsFinalDefNZCV)
7120 if (Bytes || (!
Offset && SrcReg != DestReg)) {
7121 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
7122 "SP increment/decrement not 8-byte aligned");
7123 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
7126 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
7129 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7131 CFAOffset += (
Opc == AArch64::ADDXri ||
Opc == AArch64::ADDSXri)
7138 assert(!(NeedsWinCFI && NumPredicateVectors) &&
7139 "WinCFI can't allocate fractions of an SVE data vector");
7141 if (NumDataVectors) {
7143 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
TII,
7144 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7150 if (NumPredicateVectors) {
7151 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
7153 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
TII,
7154 Flag, NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
7158 if (NeedsFinalDefNZCV)
7180 if (
MI.isFullCopy()) {
7183 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
7187 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
7192 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
7220 if (
MI.isCopy() &&
Ops.size() == 1 &&
7222 (
Ops[0] == 0 ||
Ops[0] == 1)) {
7223 bool IsSpill =
Ops[0] == 0;
7224 bool IsFill = !IsSpill;
7236 :
TRI.getMinimalPhysRegClass(Reg);
7242 "Mismatched register size in non subreg COPY");
7249 return &*--InsertPt;
7261 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
7264 "Unexpected subreg on physical register");
7266 FrameIndex, &AArch64::GPR64RegClass,
Register());
7267 return &*--InsertPt;
7284 case AArch64::sub_32:
7285 if (AArch64::GPR64RegClass.hasSubClassEq(
getRegClass(DstReg)))
7286 FillRC = &AArch64::GPR32RegClass;
7289 FillRC = &AArch64::FPR32RegClass;
7292 FillRC = &AArch64::FPR64RegClass;
7298 TRI.getRegSizeInBits(*FillRC) &&
7299 "Mismatched regclass size on folded subreg COPY");
7318 bool *OutUseUnscaledOp,
7319 unsigned *OutUnscaledOp,
7320 int64_t *EmittableOffset) {
7322 if (EmittableOffset)
7323 *EmittableOffset = 0;
7324 if (OutUseUnscaledOp)
7325 *OutUseUnscaledOp =
false;
7331 switch (
MI.getOpcode()) {
7334 case AArch64::LD1Rv1d:
7335 case AArch64::LD1Rv2s:
7336 case AArch64::LD1Rv2d:
7337 case AArch64::LD1Rv4h:
7338 case AArch64::LD1Rv4s:
7339 case AArch64::LD1Rv8b:
7340 case AArch64::LD1Rv8h:
7341 case AArch64::LD1Rv16b:
7342 case AArch64::LD1Twov2d:
7343 case AArch64::LD1Threev2d:
7344 case AArch64::LD1Fourv2d:
7345 case AArch64::LD1Twov1d:
7346 case AArch64::LD1Threev1d:
7347 case AArch64::LD1Fourv1d:
7348 case AArch64::ST1Twov2d:
7349 case AArch64::ST1Threev2d:
7350 case AArch64::ST1Fourv2d:
7351 case AArch64::ST1Twov1d:
7352 case AArch64::ST1Threev1d:
7353 case AArch64::ST1Fourv1d:
7354 case AArch64::ST1i8:
7355 case AArch64::ST1i16:
7356 case AArch64::ST1i32:
7357 case AArch64::ST1i64:
7359 case AArch64::IRGstack:
7360 case AArch64::STGloop:
7361 case AArch64::STZGloop:
7366 TypeSize ScaleValue(0U,
false), Width(0U,
false);
7367 int64_t MinOff, MaxOff;
7373 bool IsMulVL = ScaleValue.isScalable();
7374 unsigned Scale = ScaleValue.getKnownMinValue();
7384 std::optional<unsigned> UnscaledOp =
7386 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
7387 if (useUnscaledOp &&
7392 Scale = ScaleValue.getKnownMinValue();
7393 assert(IsMulVL == ScaleValue.isScalable() &&
7394 "Unscaled opcode has different value for scalable");
7396 int64_t Remainder =
Offset % Scale;
7397 assert(!(Remainder && useUnscaledOp) &&
7398 "Cannot have remainder when using unscaled op");
7400 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
7401 int64_t NewOffset =
Offset / Scale;
7402 if (MinOff <= NewOffset && NewOffset <= MaxOff)
7410 int64_t HighPart =
Offset & ~0xFFF;
7411 int64_t LowPart =
Offset & 0xFFF;
7412 int64_t LowScaled = LowPart / Scale;
7413 if (!IsMulVL && NewOffset >= 0 && LowPart % Scale == 0 &&
7414 MinOff <= LowScaled && LowScaled <= MaxOff &&
7416 NewOffset = LowScaled;
7421 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
7426 if (EmittableOffset)
7427 *EmittableOffset = NewOffset;
7428 if (OutUseUnscaledOp)
7429 *OutUseUnscaledOp = useUnscaledOp;
7430 if (OutUnscaledOp && UnscaledOp)
7431 *OutUnscaledOp = *UnscaledOp;
7444 unsigned Opcode =
MI.getOpcode();
7445 unsigned ImmIdx = FrameRegIdx + 1;
7447 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
7452 MI.eraseFromParent();
7458 unsigned UnscaledOp;
7461 &UnscaledOp, &NewOffset);
7465 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
7467 MI.setDesc(
TII->get(UnscaledOp));
7469 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
7485bool AArch64InstrInfo::useMachineCombiner()
const {
return true; }
7490 case AArch64::ADDSWrr:
7491 case AArch64::ADDSWri:
7492 case AArch64::ADDSXrr:
7493 case AArch64::ADDSXri:
7494 case AArch64::SUBSWrr:
7495 case AArch64::SUBSXrr:
7497 case AArch64::SUBSWri:
7498 case AArch64::SUBSXri:
7509 case AArch64::ADDWrr:
7510 case AArch64::ADDWri:
7511 case AArch64::SUBWrr:
7512 case AArch64::ADDSWrr:
7513 case AArch64::ADDSWri:
7514 case AArch64::SUBSWrr:
7516 case AArch64::SUBWri:
7517 case AArch64::SUBSWri:
7528 case AArch64::ADDXrr:
7529 case AArch64::ADDXri:
7530 case AArch64::SUBXrr:
7531 case AArch64::ADDSXrr:
7532 case AArch64::ADDSXri:
7533 case AArch64::SUBSXrr:
7535 case AArch64::SUBXri:
7536 case AArch64::SUBSXri:
7537 case AArch64::ADDv8i8:
7538 case AArch64::ADDv16i8:
7539 case AArch64::ADDv4i16:
7540 case AArch64::ADDv8i16:
7541 case AArch64::ADDv2i32:
7542 case AArch64::ADDv4i32:
7543 case AArch64::SUBv8i8:
7544 case AArch64::SUBv16i8:
7545 case AArch64::SUBv4i16:
7546 case AArch64::SUBv8i16:
7547 case AArch64::SUBv2i32:
7548 case AArch64::SUBv4i32:
7561 case AArch64::FADDHrr:
7562 case AArch64::FADDSrr:
7563 case AArch64::FADDDrr:
7564 case AArch64::FADDv4f16:
7565 case AArch64::FADDv8f16:
7566 case AArch64::FADDv2f32:
7567 case AArch64::FADDv2f64:
7568 case AArch64::FADDv4f32:
7569 case AArch64::FSUBHrr:
7570 case AArch64::FSUBSrr:
7571 case AArch64::FSUBDrr:
7572 case AArch64::FSUBv4f16:
7573 case AArch64::FSUBv8f16:
7574 case AArch64::FSUBv2f32:
7575 case AArch64::FSUBv2f64:
7576 case AArch64::FSUBv4f32:
7593 unsigned CombineOpc,
unsigned ZeroReg = 0,
7594 bool CheckZeroReg =
false) {
7601 if (!
MI ||
MI->getParent() != &
MBB ||
MI->getOpcode() != CombineOpc)
7608 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
7609 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
7610 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
7612 if (
MI->getOperand(3).getReg() != ZeroReg)
7617 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
7626 unsigned MulOpc,
unsigned ZeroReg) {
7641bool AArch64InstrInfo::isAssociativeAndCommutative(
const MachineInstr &Inst,
7642 bool Invert)
const {
7648 case AArch64::FADDHrr:
7649 case AArch64::FADDSrr:
7650 case AArch64::FADDDrr:
7651 case AArch64::FMULHrr:
7652 case AArch64::FMULSrr:
7653 case AArch64::FMULDrr:
7654 case AArch64::FMULX16:
7655 case AArch64::FMULX32:
7656 case AArch64::FMULX64:
7658 case AArch64::FADDv4f16:
7659 case AArch64::FADDv8f16:
7660 case AArch64::FADDv2f32:
7661 case AArch64::FADDv4f32:
7662 case AArch64::FADDv2f64:
7663 case AArch64::FMULv4f16:
7664 case AArch64::FMULv8f16:
7665 case AArch64::FMULv2f32:
7666 case AArch64::FMULv4f32:
7667 case AArch64::FMULv2f64:
7668 case AArch64::FMULXv4f16:
7669 case AArch64::FMULXv8f16:
7670 case AArch64::FMULXv2f32:
7671 case AArch64::FMULXv4f32:
7672 case AArch64::FMULXv2f64:
7676 case AArch64::FADD_ZZZ_H:
7677 case AArch64::FADD_ZZZ_S:
7678 case AArch64::FADD_ZZZ_D:
7679 case AArch64::FMUL_ZZZ_H:
7680 case AArch64::FMUL_ZZZ_S:
7681 case AArch64::FMUL_ZZZ_D:
7692 case AArch64::ADDWrr:
7693 case AArch64::ADDXrr:
7694 case AArch64::ANDWrr:
7695 case AArch64::ANDXrr:
7696 case AArch64::ORRWrr:
7697 case AArch64::ORRXrr:
7698 case AArch64::EORWrr:
7699 case AArch64::EORXrr:
7700 case AArch64::EONWrr:
7701 case AArch64::EONXrr:
7705 case AArch64::ADDv8i8:
7706 case AArch64::ADDv16i8:
7707 case AArch64::ADDv4i16:
7708 case AArch64::ADDv8i16:
7709 case AArch64::ADDv2i32:
7710 case AArch64::ADDv4i32:
7711 case AArch64::ADDv1i64:
7712 case AArch64::ADDv2i64:
7713 case AArch64::MULv8i8:
7714 case AArch64::MULv16i8:
7715 case AArch64::MULv4i16:
7716 case AArch64::MULv8i16:
7717 case AArch64::MULv2i32:
7718 case AArch64::MULv4i32:
7719 case AArch64::ANDv8i8:
7720 case AArch64::ANDv16i8:
7721 case AArch64::ORRv8i8:
7722 case AArch64::ORRv16i8:
7723 case AArch64::EORv8i8:
7724 case AArch64::EORv16i8:
7726 case AArch64::ADD_ZZZ_B:
7727 case AArch64::ADD_ZZZ_H:
7728 case AArch64::ADD_ZZZ_S:
7729 case AArch64::ADD_ZZZ_D:
7730 case AArch64::MUL_ZZZ_B:
7731 case AArch64::MUL_ZZZ_H:
7732 case AArch64::MUL_ZZZ_S:
7733 case AArch64::MUL_ZZZ_D:
7734 case AArch64::AND_ZZZ:
7735 case AArch64::ORR_ZZZ:
7736 case AArch64::EOR_ZZZ:
7767 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
7775 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
7787 case AArch64::ADDWrr:
7789 "ADDWrr does not have register operands");
7790 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
7791 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
7793 case AArch64::ADDXrr:
7794 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
7795 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
7797 case AArch64::SUBWrr:
7798 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
7799 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
7801 case AArch64::SUBXrr:
7802 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
7803 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
7805 case AArch64::ADDWri:
7806 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
7808 case AArch64::ADDXri:
7809 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
7811 case AArch64::SUBWri:
7812 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
7814 case AArch64::SUBXri:
7815 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
7817 case AArch64::ADDv8i8:
7818 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
7819 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
7821 case AArch64::ADDv16i8:
7822 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
7823 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
7825 case AArch64::ADDv4i16:
7826 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
7827 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
7828 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
7829 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
7831 case AArch64::ADDv8i16:
7832 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
7833 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
7834 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
7835 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
7837 case AArch64::ADDv2i32:
7838 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
7839 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
7840 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
7841 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
7843 case AArch64::ADDv4i32:
7844 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
7845 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
7846 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
7847 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
7849 case AArch64::SUBv8i8:
7850 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
7851 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
7853 case AArch64::SUBv16i8:
7854 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
7855 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
7857 case AArch64::SUBv4i16:
7858 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
7859 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
7860 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
7861 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
7863 case AArch64::SUBv8i16:
7864 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
7865 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
7866 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
7867 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
7869 case AArch64::SUBv2i32:
7870 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
7871 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
7872 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
7873 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
7875 case AArch64::SUBv4i32:
7876 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
7877 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
7878 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
7879 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
7885bool AArch64InstrInfo::isAccumulationOpcode(
unsigned Opcode)
const {
7889 case AArch64::UABALB_ZZZ_D:
7890 case AArch64::UABALB_ZZZ_H:
7891 case AArch64::UABALB_ZZZ_S:
7892 case AArch64::UABALT_ZZZ_D:
7893 case AArch64::UABALT_ZZZ_H:
7894 case AArch64::UABALT_ZZZ_S:
7895 case AArch64::SABALB_ZZZ_D:
7896 case AArch64::SABALB_ZZZ_S:
7897 case AArch64::SABALB_ZZZ_H:
7898 case AArch64::SABALT_ZZZ_D:
7899 case AArch64::SABALT_ZZZ_S:
7900 case AArch64::SABALT_ZZZ_H:
7901 case AArch64::UABALv16i8_v8i16:
7902 case AArch64::UABALv2i32_v2i64:
7903 case AArch64::UABALv4i16_v4i32:
7904 case AArch64::UABALv4i32_v2i64:
7905 case AArch64::UABALv8i16_v4i32:
7906 case AArch64::UABALv8i8_v8i16:
7907 case AArch64::UABAv16i8:
7908 case AArch64::UABAv2i32:
7909 case AArch64::UABAv4i16:
7910 case AArch64::UABAv4i32:
7911 case AArch64::UABAv8i16:
7912 case AArch64::UABAv8i8:
7913 case AArch64::SABALv16i8_v8i16:
7914 case AArch64::SABALv2i32_v2i64:
7915 case AArch64::SABALv4i16_v4i32:
7916 case AArch64::SABALv4i32_v2i64:
7917 case AArch64::SABALv8i16_v4i32:
7918 case AArch64::SABALv8i8_v8i16:
7919 case AArch64::SABAv16i8:
7920 case AArch64::SABAv2i32:
7921 case AArch64::SABAv4i16:
7922 case AArch64::SABAv4i32:
7923 case AArch64::SABAv8i16:
7924 case AArch64::SABAv8i8:
7931unsigned AArch64InstrInfo::getAccumulationStartOpcode(
7932 unsigned AccumulationOpcode)
const {
7933 switch (AccumulationOpcode) {
7936 case AArch64::UABALB_ZZZ_D:
7937 return AArch64::UABDLB_ZZZ_D;
7938 case AArch64::UABALB_ZZZ_H:
7939 return AArch64::UABDLB_ZZZ_H;
7940 case AArch64::UABALB_ZZZ_S:
7941 return AArch64::UABDLB_ZZZ_S;
7942 case AArch64::UABALT_ZZZ_D:
7943 return AArch64::UABDLT_ZZZ_D;
7944 case AArch64::UABALT_ZZZ_H:
7945 return AArch64::UABDLT_ZZZ_H;
7946 case AArch64::UABALT_ZZZ_S:
7947 return AArch64::UABDLT_ZZZ_S;
7948 case AArch64::UABALv16i8_v8i16:
7949 return AArch64::UABDLv16i8_v8i16;
7950 case AArch64::UABALv2i32_v2i64:
7951 return AArch64::UABDLv2i32_v2i64;
7952 case AArch64::UABALv4i16_v4i32:
7953 return AArch64::UABDLv4i16_v4i32;
7954 case AArch64::UABALv4i32_v2i64:
7955 return AArch64::UABDLv4i32_v2i64;
7956 case AArch64::UABALv8i16_v4i32:
7957 return AArch64::UABDLv8i16_v4i32;
7958 case AArch64::UABALv8i8_v8i16:
7959 return AArch64::UABDLv8i8_v8i16;
7960 case AArch64::UABAv16i8:
7961 return AArch64::UABDv16i8;
7962 case AArch64::UABAv2i32:
7963 return AArch64::UABDv2i32;
7964 case AArch64::UABAv4i16:
7965 return AArch64::UABDv4i16;
7966 case AArch64::UABAv4i32:
7967 return AArch64::UABDv4i32;
7968 case AArch64::UABAv8i16:
7969 return AArch64::UABDv8i16;
7970 case AArch64::UABAv8i8:
7971 return AArch64::UABDv8i8;
7972 case AArch64::SABALB_ZZZ_D:
7973 return AArch64::SABDLB_ZZZ_D;
7974 case AArch64::SABALB_ZZZ_S:
7975 return AArch64::SABDLB_ZZZ_S;
7976 case AArch64::SABALB_ZZZ_H:
7977 return AArch64::SABDLB_ZZZ_H;
7978 case AArch64::SABALT_ZZZ_D:
7979 return AArch64::SABDLT_ZZZ_D;
7980 case AArch64::SABALT_ZZZ_S:
7981 return AArch64::SABDLT_ZZZ_S;
7982 case AArch64::SABALT_ZZZ_H:
7983 return AArch64::SABDLT_ZZZ_H;
7984 case AArch64::SABALv16i8_v8i16:
7985 return AArch64::SABDLv16i8_v8i16;
7986 case AArch64::SABALv2i32_v2i64:
7987 return AArch64::SABDLv2i32_v2i64;
7988 case AArch64::SABALv4i16_v4i32:
7989 return AArch64::SABDLv4i16_v4i32;
7990 case AArch64::SABALv4i32_v2i64:
7991 return AArch64::SABDLv4i32_v2i64;
7992 case AArch64::SABALv8i16_v4i32:
7993 return AArch64::SABDLv8i16_v4i32;
7994 case AArch64::SABALv8i8_v8i16:
7995 return AArch64::SABDLv8i8_v8i16;
7996 case AArch64::SABAv16i8:
7997 return AArch64::SABDv16i8;
7998 case AArch64::SABAv2i32:
7999 return AArch64::SABAv2i32;
8000 case AArch64::SABAv4i16:
8001 return AArch64::SABDv4i16;
8002 case AArch64::SABAv4i32:
8003 return AArch64::SABDv4i32;
8004 case AArch64::SABAv8i16:
8005 return AArch64::SABDv8i16;
8006 case AArch64::SABAv8i8:
8007 return AArch64::SABDv8i8;
8023 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
8035 assert(
false &&
"Unsupported FP instruction in combiner\n");
8037 case AArch64::FADDHrr:
8039 "FADDHrr does not have register operands");
8041 Found = Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
8042 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
8044 case AArch64::FADDSrr:
8046 "FADDSrr does not have register operands");
8048 Found |= Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
8049 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
8051 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
8052 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
8054 case AArch64::FADDDrr:
8055 Found |= Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
8056 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
8058 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
8059 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
8061 case AArch64::FADDv4f16:
8062 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
8063 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
8065 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
8066 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
8068 case AArch64::FADDv8f16:
8069 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
8070 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
8072 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
8073 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
8075 case AArch64::FADDv2f32:
8076 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
8077 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
8079 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
8080 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
8082 case AArch64::FADDv2f64:
8083 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
8084 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
8086 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
8087 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
8089 case AArch64::FADDv4f32:
8090 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
8091 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
8093 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
8094 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
8096 case AArch64::FSUBHrr:
8097 Found = Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
8098 Found |= Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
8099 Found |= Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
8101 case AArch64::FSUBSrr:
8102 Found = Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
8104 Found |= Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
8105 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
8107 Found |= Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
8109 case AArch64::FSUBDrr:
8110 Found = Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
8112 Found |= Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
8113 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
8115 Found |= Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
8117 case AArch64::FSUBv4f16:
8118 Found |= Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
8119 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
8121 Found |= Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
8122 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
8124 case AArch64::FSUBv8f16:
8125 Found |= Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
8126 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
8128 Found |= Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
8129 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
8131 case AArch64::FSUBv2f32:
8132 Found |= Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
8133 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
8135 Found |= Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
8136 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
8138 case AArch64::FSUBv2f64:
8139 Found |= Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
8140 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
8142 Found |= Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
8143 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
8145 case AArch64::FSUBv4f32:
8146 Found |= Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
8147 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
8149 Found |= Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
8150 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
8161 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
8168 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
8169 MI->getOperand(1).getReg().isVirtual())
8171 if (
MI &&
MI->getOpcode() == Opcode) {
8183 case AArch64::FMULv2f32:
8184 Found = Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
8185 Found |= Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
8187 case AArch64::FMULv2f64:
8188 Found = Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
8189 Found |= Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
8191 case AArch64::FMULv4f16:
8192 Found = Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
8193 Found |= Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
8195 case AArch64::FMULv4f32:
8196 Found = Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
8197 Found |= Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
8199 case AArch64::FMULv8f16:
8200 Found = Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
8201 Found |= Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
8214 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
8217 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
8232 case AArch64::FNEGDr:
8234 case AArch64::FNEGSr:
8366 case AArch64::SUBWrr:
8367 case AArch64::SUBSWrr:
8368 case AArch64::SUBXrr:
8369 case AArch64::SUBSXrr:
8414 unsigned LoadLaneOpCode,
unsigned NumLanes) {
8437 while (!RemainingLanes.
empty() && CurrInstr &&
8438 CurrInstr->getOpcode() == LoadLaneOpCode &&
8440 CurrInstr->getNumOperands() == 4) {
8441 RemainingLanes.
erase(CurrInstr->getOperand(2).getImm());
8447 if (!RemainingLanes.
empty())
8451 if (CurrInstr->getOpcode() != TargetOpcode::SUBREG_TO_REG)
8455 auto Lane0LoadReg = CurrInstr->getOperand(1).getReg();
8456 unsigned SingleLaneSizeInBits = 128 / NumLanes;
8457 if (
TRI->getRegSizeInBits(Lane0LoadReg, MRI) != SingleLaneSizeInBits)
8473 RemainingLoadInstrs.
insert(LoadInstrs.
begin(), LoadInstrs.
end());
8476 for (; MBBItr !=
MBB->begin() && RemainingSteps > 0 &&
8477 !RemainingLoadInstrs.
empty();
8478 --MBBItr, --RemainingSteps) {
8482 RemainingLoadInstrs.
erase(&CurrInstr);
8492 if (RemainingSteps == 0 && !RemainingLoadInstrs.
empty())
8518 case AArch64::LD1i32:
8520 case AArch64::LD1i16:
8522 case AArch64::LD1i8:
8538 unsigned Pattern,
unsigned NumLanes) {
8546 for (
unsigned i = 0; i < NumLanes - 1; ++i) {
8554 return A->getOperand(2).getImm() >
B->getOperand(2).getImm();
8560 auto LoadToLaneInstrsAscending =
llvm::reverse(LoadToLaneInstrs);
8566 auto CreateLD1Instruction = [&](
MachineInstr *OriginalInstr,
8567 Register SrcRegister,
unsigned Lane,
8569 bool OffsetRegisterKillState) {
8578 InstrIdxForVirtReg.
insert(std::make_pair(NewRegister, InsInstrs.
size()));
8579 InsInstrs.
push_back(LoadIndexIntoRegister);
8585 auto CreateLDRInstruction =
8591 Opcode = AArch64::LDRSui;
8594 Opcode = AArch64::LDRHui;
8597 Opcode = AArch64::LDRBui;
8601 "Got unsupported number of lanes in machine-combiner gather pattern");
8611 auto LanesToLoadToReg0 =
8613 LoadToLaneInstrsAscending.begin() + NumLanes / 2);
8614 Register PrevReg = SubregToReg->getOperand(0).getReg();
8616 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8617 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8618 OffsetRegOperand.
getReg(),
8619 OffsetRegOperand.
isKill());
8626 MachineInstr *Lane0Load = *LoadToLaneInstrsAscending.begin();
8628 *std::next(LoadToLaneInstrsAscending.begin(), NumLanes / 2);
8635 CreateLDRInstruction(NumLanes, DestRegForMiddleIndex,
8636 OriginalSplitToLoadOffsetOperand.
getReg(),
8639 InstrIdxForVirtReg.
insert(
8640 std::make_pair(DestRegForMiddleIndex, InsInstrs.
size()));
8641 InsInstrs.
push_back(MiddleIndexLoadInstr);
8646 unsigned SubregType;
8649 SubregType = AArch64::ssub;
8652 SubregType = AArch64::hsub;
8655 SubregType = AArch64::bsub;
8659 "Got invalid NumLanes for machine-combiner gather pattern");
8662 auto SubRegToRegInstr =
8664 DestRegForSubregToReg)
8667 InstrIdxForVirtReg.
insert(
8668 std::make_pair(DestRegForSubregToReg, InsInstrs.
size()));
8672 auto LanesToLoadToReg1 =
8674 LoadToLaneInstrsAscending.end());
8675 PrevReg = SubRegToRegInstr->getOperand(0).getReg();
8677 const MachineOperand &OffsetRegOperand = LoadInstr->getOperand(3);
8678 PrevReg = CreateLD1Instruction(LoadInstr, PrevReg, Index + 1,
8679 OffsetRegOperand.
getReg(),
8680 OffsetRegOperand.
isKill());
8683 if (Index == NumLanes / 2 - 2) {
8718bool AArch64InstrInfo::getMachineCombinerPatterns(
8720 bool DoRegPressureReduce)
const {
8741 DoRegPressureReduce);
8770 const Register *ReplacedAddend =
nullptr) {
8771 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
8773 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
8776 Register SrcReg0 = MUL->getOperand(1).getReg();
8777 bool Src0IsKill = MUL->getOperand(1).isKill();
8778 Register SrcReg1 = MUL->getOperand(2).getReg();
8779 bool Src1IsKill = MUL->getOperand(2).isKill();
8783 if (ReplacedAddend) {
8785 SrcReg2 = *ReplacedAddend;
8812 .
addImm(MUL->getOperand(3).getImm());
8819 assert(
false &&
"Invalid FMA instruction kind \n");
8833 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
8834 Opc = AArch64::FNMADDSrrr;
8835 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
8836 Opc = AArch64::FNMADDDrrr;
8870 unsigned IdxDupOp,
unsigned MulOpc,
8872 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
8873 "Invalid index of FMUL operand");
8881 if (Dup->
getOpcode() == TargetOpcode::COPY)
8890 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
8931 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8946 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
8973 genNeg(MF, MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
9001 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
9003 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
9007 Register SrcReg0 = MUL->getOperand(1).getReg();
9008 bool Src0IsKill = MUL->getOperand(1).isKill();
9009 Register SrcReg1 = MUL->getOperand(2).getReg();
9010 bool Src1IsKill = MUL->getOperand(2).isKill();
9040 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
9041 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
9055 if (Opcode == AArch64::SUBSWrr)
9056 Opcode = AArch64::SUBWrr;
9057 else if (Opcode == AArch64::SUBSXrr)
9058 Opcode = AArch64::SUBXrr;
9060 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
9061 "Unexpected instruction opcode.");
9078 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9085unsigned AArch64InstrInfo::getReduceOpcodeForAccumulator(
9086 unsigned int AccumulatorOpCode)
const {
9087 switch (AccumulatorOpCode) {
9088 case AArch64::UABALB_ZZZ_D:
9089 case AArch64::SABALB_ZZZ_D:
9090 case AArch64::UABALT_ZZZ_D:
9091 case AArch64::SABALT_ZZZ_D:
9092 return AArch64::ADD_ZZZ_D;
9093 case AArch64::UABALB_ZZZ_H:
9094 case AArch64::SABALB_ZZZ_H:
9095 case AArch64::UABALT_ZZZ_H:
9096 case AArch64::SABALT_ZZZ_H:
9097 return AArch64::ADD_ZZZ_H;
9098 case AArch64::UABALB_ZZZ_S:
9099 case AArch64::SABALB_ZZZ_S:
9100 case AArch64::UABALT_ZZZ_S:
9101 case AArch64::SABALT_ZZZ_S:
9102 return AArch64::ADD_ZZZ_S;
9103 case AArch64::UABALv16i8_v8i16:
9104 case AArch64::SABALv8i8_v8i16:
9105 case AArch64::SABAv8i16:
9106 case AArch64::UABAv8i16:
9107 return AArch64::ADDv8i16;
9108 case AArch64::SABALv2i32_v2i64:
9109 case AArch64::UABALv2i32_v2i64:
9110 case AArch64::SABALv4i32_v2i64:
9111 return AArch64::ADDv2i64;
9112 case AArch64::UABALv4i16_v4i32:
9113 case AArch64::SABALv4i16_v4i32:
9114 case AArch64::SABALv8i16_v4i32:
9115 case AArch64::SABAv4i32:
9116 case AArch64::UABAv4i32:
9117 return AArch64::ADDv4i32;
9118 case AArch64::UABALv4i32_v2i64:
9119 return AArch64::ADDv2i64;
9120 case AArch64::UABALv8i16_v4i32:
9121 return AArch64::ADDv4i32;
9122 case AArch64::UABALv8i8_v8i16:
9123 case AArch64::SABALv16i8_v8i16:
9124 return AArch64::ADDv8i16;
9125 case AArch64::UABAv16i8:
9126 case AArch64::SABAv16i8:
9127 return AArch64::ADDv16i8;
9128 case AArch64::UABAv4i16:
9129 case AArch64::SABAv4i16:
9130 return AArch64::ADDv4i16;
9131 case AArch64::UABAv2i32:
9132 case AArch64::SABAv2i32:
9133 return AArch64::ADDv2i32;
9134 case AArch64::UABAv8i8:
9135 case AArch64::SABAv8i8:
9136 return AArch64::ADDv8i8;
9145void AArch64InstrInfo::genAlternativeCodeSequence(
9155 MachineInstr *
MUL =
nullptr;
9162 DelInstrs, InstrIdxForVirtReg);
9168 InstrIdxForVirtReg);
9174 InstrIdxForVirtReg);
9183 Opc = AArch64::MADDWrrr;
9184 RC = &AArch64::GPR32RegClass;
9186 Opc = AArch64::MADDXrrr;
9187 RC = &AArch64::GPR64RegClass;
9198 Opc = AArch64::MADDWrrr;
9199 RC = &AArch64::GPR32RegClass;
9201 Opc = AArch64::MADDXrrr;
9202 RC = &AArch64::GPR64RegClass;
9216 unsigned BitSize, MovImm;
9219 MovImm = AArch64::MOVi32imm;
9220 RC = &AArch64::GPR32spRegClass;
9222 Opc = AArch64::MADDWrrr;
9223 RC = &AArch64::GPR32RegClass;
9225 MovImm = AArch64::MOVi64imm;
9226 RC = &AArch64::GPR64spRegClass;
9228 Opc = AArch64::MADDXrrr;
9229 RC = &AArch64::GPR64RegClass;
9244 if (Insn.
size() != 1)
9246 MachineInstrBuilder MIB1 =
9247 BuildMI(MF, MIMetadata(Root),
TII->get(MovImm), NewVR)
9250 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9262 unsigned SubOpc, ZeroReg;
9264 SubOpc = AArch64::SUBWrr;
9265 SubRC = &AArch64::GPR32spRegClass;
9266 ZeroReg = AArch64::WZR;
9267 Opc = AArch64::MADDWrrr;
9268 RC = &AArch64::GPR32RegClass;
9270 SubOpc = AArch64::SUBXrr;
9271 SubRC = &AArch64::GPR64spRegClass;
9272 ZeroReg = AArch64::XZR;
9273 Opc = AArch64::MADDXrrr;
9274 RC = &AArch64::GPR64RegClass;
9278 MachineInstrBuilder MIB1 =
9279 BuildMI(MF, MIMetadata(Root),
TII->get(SubOpc), NewVR)
9283 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9294 Opc = AArch64::MSUBWrrr;
9295 RC = &AArch64::GPR32RegClass;
9297 Opc = AArch64::MSUBXrrr;
9298 RC = &AArch64::GPR64RegClass;
9303 Opc = AArch64::MLAv8i8;
9304 RC = &AArch64::FPR64RegClass;
9308 Opc = AArch64::MLAv8i8;
9309 RC = &AArch64::FPR64RegClass;
9313 Opc = AArch64::MLAv16i8;
9314 RC = &AArch64::FPR128RegClass;
9318 Opc = AArch64::MLAv16i8;
9319 RC = &AArch64::FPR128RegClass;
9323 Opc = AArch64::MLAv4i16;
9324 RC = &AArch64::FPR64RegClass;
9328 Opc = AArch64::MLAv4i16;
9329 RC = &AArch64::FPR64RegClass;
9333 Opc = AArch64::MLAv8i16;
9334 RC = &AArch64::FPR128RegClass;
9338 Opc = AArch64::MLAv8i16;
9339 RC = &AArch64::FPR128RegClass;
9343 Opc = AArch64::MLAv2i32;
9344 RC = &AArch64::FPR64RegClass;
9348 Opc = AArch64::MLAv2i32;
9349 RC = &AArch64::FPR64RegClass;
9353 Opc = AArch64::MLAv4i32;
9354 RC = &AArch64::FPR128RegClass;
9358 Opc = AArch64::MLAv4i32;
9359 RC = &AArch64::FPR128RegClass;
9364 Opc = AArch64::MLAv8i8;
9365 RC = &AArch64::FPR64RegClass;
9367 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i8,
9371 Opc = AArch64::MLSv8i8;
9372 RC = &AArch64::FPR64RegClass;
9376 Opc = AArch64::MLAv16i8;
9377 RC = &AArch64::FPR128RegClass;
9379 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv16i8,
9383 Opc = AArch64::MLSv16i8;
9384 RC = &AArch64::FPR128RegClass;
9388 Opc = AArch64::MLAv4i16;
9389 RC = &AArch64::FPR64RegClass;
9391 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9395 Opc = AArch64::MLSv4i16;
9396 RC = &AArch64::FPR64RegClass;
9400 Opc = AArch64::MLAv8i16;
9401 RC = &AArch64::FPR128RegClass;
9403 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9407 Opc = AArch64::MLSv8i16;
9408 RC = &AArch64::FPR128RegClass;
9412 Opc = AArch64::MLAv2i32;
9413 RC = &AArch64::FPR64RegClass;
9415 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9419 Opc = AArch64::MLSv2i32;
9420 RC = &AArch64::FPR64RegClass;
9424 Opc = AArch64::MLAv4i32;
9425 RC = &AArch64::FPR128RegClass;
9427 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9431 Opc = AArch64::MLSv4i32;
9432 RC = &AArch64::FPR128RegClass;
9437 Opc = AArch64::MLAv4i16_indexed;
9438 RC = &AArch64::FPR64RegClass;
9442 Opc = AArch64::MLAv4i16_indexed;
9443 RC = &AArch64::FPR64RegClass;
9447 Opc = AArch64::MLAv8i16_indexed;
9448 RC = &AArch64::FPR128RegClass;
9452 Opc = AArch64::MLAv8i16_indexed;
9453 RC = &AArch64::FPR128RegClass;
9457 Opc = AArch64::MLAv2i32_indexed;
9458 RC = &AArch64::FPR64RegClass;
9462 Opc = AArch64::MLAv2i32_indexed;
9463 RC = &AArch64::FPR64RegClass;
9467 Opc = AArch64::MLAv4i32_indexed;
9468 RC = &AArch64::FPR128RegClass;
9472 Opc = AArch64::MLAv4i32_indexed;
9473 RC = &AArch64::FPR128RegClass;
9478 Opc = AArch64::MLAv4i16_indexed;
9479 RC = &AArch64::FPR64RegClass;
9481 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i16,
9485 Opc = AArch64::MLSv4i16_indexed;
9486 RC = &AArch64::FPR64RegClass;
9490 Opc = AArch64::MLAv8i16_indexed;
9491 RC = &AArch64::FPR128RegClass;
9493 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv8i16,
9497 Opc = AArch64::MLSv8i16_indexed;
9498 RC = &AArch64::FPR128RegClass;
9502 Opc = AArch64::MLAv2i32_indexed;
9503 RC = &AArch64::FPR64RegClass;
9505 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv2i32,
9509 Opc = AArch64::MLSv2i32_indexed;
9510 RC = &AArch64::FPR64RegClass;
9514 Opc = AArch64::MLAv4i32_indexed;
9515 RC = &AArch64::FPR128RegClass;
9517 InstrIdxForVirtReg, 1,
Opc, AArch64::NEGv4i32,
9521 Opc = AArch64::MLSv4i32_indexed;
9522 RC = &AArch64::FPR128RegClass;
9528 Opc = AArch64::FMADDHrrr;
9529 RC = &AArch64::FPR16RegClass;
9533 Opc = AArch64::FMADDSrrr;
9534 RC = &AArch64::FPR32RegClass;
9538 Opc = AArch64::FMADDDrrr;
9539 RC = &AArch64::FPR64RegClass;
9544 Opc = AArch64::FMADDHrrr;
9545 RC = &AArch64::FPR16RegClass;
9549 Opc = AArch64::FMADDSrrr;
9550 RC = &AArch64::FPR32RegClass;
9554 Opc = AArch64::FMADDDrrr;
9555 RC = &AArch64::FPR64RegClass;
9560 Opc = AArch64::FMLAv1i32_indexed;
9561 RC = &AArch64::FPR32RegClass;
9566 Opc = AArch64::FMLAv1i32_indexed;
9567 RC = &AArch64::FPR32RegClass;
9573 Opc = AArch64::FMLAv1i64_indexed;
9574 RC = &AArch64::FPR64RegClass;
9579 Opc = AArch64::FMLAv1i64_indexed;
9580 RC = &AArch64::FPR64RegClass;
9586 RC = &AArch64::FPR64RegClass;
9587 Opc = AArch64::FMLAv4i16_indexed;
9592 RC = &AArch64::FPR64RegClass;
9593 Opc = AArch64::FMLAv4f16;
9598 RC = &AArch64::FPR64RegClass;
9599 Opc = AArch64::FMLAv4i16_indexed;
9604 RC = &AArch64::FPR64RegClass;
9605 Opc = AArch64::FMLAv4f16;
9612 RC = &AArch64::FPR64RegClass;
9614 Opc = AArch64::FMLAv2i32_indexed;
9618 Opc = AArch64::FMLAv2f32;
9625 RC = &AArch64::FPR64RegClass;
9627 Opc = AArch64::FMLAv2i32_indexed;
9631 Opc = AArch64::FMLAv2f32;
9638 RC = &AArch64::FPR128RegClass;
9639 Opc = AArch64::FMLAv8i16_indexed;
9644 RC = &AArch64::FPR128RegClass;
9645 Opc = AArch64::FMLAv8f16;
9650 RC = &AArch64::FPR128RegClass;
9651 Opc = AArch64::FMLAv8i16_indexed;
9656 RC = &AArch64::FPR128RegClass;
9657 Opc = AArch64::FMLAv8f16;
9664 RC = &AArch64::FPR128RegClass;
9666 Opc = AArch64::FMLAv2i64_indexed;
9670 Opc = AArch64::FMLAv2f64;
9677 RC = &AArch64::FPR128RegClass;
9679 Opc = AArch64::FMLAv2i64_indexed;
9683 Opc = AArch64::FMLAv2f64;
9691 RC = &AArch64::FPR128RegClass;
9693 Opc = AArch64::FMLAv4i32_indexed;
9697 Opc = AArch64::FMLAv4f32;
9705 RC = &AArch64::FPR128RegClass;
9707 Opc = AArch64::FMLAv4i32_indexed;
9711 Opc = AArch64::FMLAv4f32;
9718 Opc = AArch64::FNMSUBHrrr;
9719 RC = &AArch64::FPR16RegClass;
9723 Opc = AArch64::FNMSUBSrrr;
9724 RC = &AArch64::FPR32RegClass;
9728 Opc = AArch64::FNMSUBDrrr;
9729 RC = &AArch64::FPR64RegClass;
9734 Opc = AArch64::FNMADDHrrr;
9735 RC = &AArch64::FPR16RegClass;
9739 Opc = AArch64::FNMADDSrrr;
9740 RC = &AArch64::FPR32RegClass;
9744 Opc = AArch64::FNMADDDrrr;
9745 RC = &AArch64::FPR64RegClass;
9750 Opc = AArch64::FMSUBHrrr;
9751 RC = &AArch64::FPR16RegClass;
9755 Opc = AArch64::FMSUBSrrr;
9756 RC = &AArch64::FPR32RegClass;
9760 Opc = AArch64::FMSUBDrrr;
9761 RC = &AArch64::FPR64RegClass;
9766 Opc = AArch64::FMLSv1i32_indexed;
9767 RC = &AArch64::FPR32RegClass;
9773 Opc = AArch64::FMLSv1i64_indexed;
9774 RC = &AArch64::FPR64RegClass;
9781 RC = &AArch64::FPR64RegClass;
9783 MachineInstrBuilder MIB1 =
9784 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f16), NewVR)
9787 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9789 Opc = AArch64::FMLAv4f16;
9793 Opc = AArch64::FMLAv4i16_indexed;
9800 RC = &AArch64::FPR64RegClass;
9801 Opc = AArch64::FMLSv4f16;
9806 RC = &AArch64::FPR64RegClass;
9807 Opc = AArch64::FMLSv4i16_indexed;
9814 RC = &AArch64::FPR64RegClass;
9816 Opc = AArch64::FMLSv2i32_indexed;
9820 Opc = AArch64::FMLSv2f32;
9828 RC = &AArch64::FPR128RegClass;
9830 MachineInstrBuilder MIB1 =
9831 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv8f16), NewVR)
9834 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9836 Opc = AArch64::FMLAv8f16;
9840 Opc = AArch64::FMLAv8i16_indexed;
9847 RC = &AArch64::FPR128RegClass;
9848 Opc = AArch64::FMLSv8f16;
9853 RC = &AArch64::FPR128RegClass;
9854 Opc = AArch64::FMLSv8i16_indexed;
9861 RC = &AArch64::FPR128RegClass;
9863 Opc = AArch64::FMLSv2i64_indexed;
9867 Opc = AArch64::FMLSv2f64;
9875 RC = &AArch64::FPR128RegClass;
9877 Opc = AArch64::FMLSv4i32_indexed;
9881 Opc = AArch64::FMLSv4f32;
9888 RC = &AArch64::FPR64RegClass;
9890 MachineInstrBuilder MIB1 =
9891 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f32), NewVR)
9894 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9896 Opc = AArch64::FMLAv2i32_indexed;
9900 Opc = AArch64::FMLAv2f32;
9908 RC = &AArch64::FPR128RegClass;
9910 MachineInstrBuilder MIB1 =
9911 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv4f32), NewVR)
9914 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9916 Opc = AArch64::FMLAv4i32_indexed;
9920 Opc = AArch64::FMLAv4f32;
9928 RC = &AArch64::FPR128RegClass;
9930 MachineInstrBuilder MIB1 =
9931 BuildMI(MF, MIMetadata(Root),
TII->get(AArch64::FNEGv2f64), NewVR)
9934 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
9936 Opc = AArch64::FMLAv2i64_indexed;
9940 Opc = AArch64::FMLAv2f64;
9952 &AArch64::FPR128RegClass, MRI);
9961 &AArch64::FPR128RegClass, MRI);
9970 &AArch64::FPR128_loRegClass, MRI);
9979 &AArch64::FPR128RegClass, MRI);
9988 &AArch64::FPR128_loRegClass, MRI);
10022 for (
auto *
MI : InsInstrs)
10023 MI->setFlags(Flags);
10064 bool IsNegativeBranch =
false;
10065 bool IsTestAndBranch =
false;
10066 unsigned TargetBBInMI = 0;
10067 switch (
MI.getOpcode()) {
10071 case AArch64::CBWPri:
10072 case AArch64::CBXPri:
10073 case AArch64::CBBAssertExt:
10074 case AArch64::CBHAssertExt:
10075 case AArch64::CBWPrr:
10076 case AArch64::CBXPrr:
10078 case AArch64::CBZW:
10079 case AArch64::CBZX:
10082 case AArch64::CBNZW:
10083 case AArch64::CBNZX:
10085 IsNegativeBranch =
true;
10087 case AArch64::TBZW:
10088 case AArch64::TBZX:
10090 IsTestAndBranch =
true;
10092 case AArch64::TBNZW:
10093 case AArch64::TBNZX:
10095 IsNegativeBranch =
true;
10096 IsTestAndBranch =
true;
10102 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
10106 assert(
MI.getParent() &&
"Incomplete machine instruction\n");
10119 while (
DefMI->isCopy()) {
10130 switch (
DefMI->getOpcode()) {
10134 case AArch64::ANDWri:
10135 case AArch64::ANDXri: {
10136 if (IsTestAndBranch)
10143 bool Is32Bit = (
DefMI->getOpcode() == AArch64::ANDWri);
10145 DefMI->getOperand(2).getImm(), Is32Bit ? 32 : 64);
10161 unsigned Opc = (
Imm < 32)
10162 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
10163 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
10176 if (!Is32Bit &&
Imm < 32)
10178 MI.eraseFromParent();
10182 case AArch64::CSINCWr:
10183 case AArch64::CSINCXr: {
10184 if (!(
DefMI->getOperand(1).getReg() == AArch64::WZR &&
10185 DefMI->getOperand(2).getReg() == AArch64::WZR) &&
10186 !(
DefMI->getOperand(1).getReg() == AArch64::XZR &&
10187 DefMI->getOperand(2).getReg() == AArch64::XZR))
10190 if (
DefMI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
10203 if (IsNegativeBranch)
10206 MI.eraseFromParent();
10212std::pair<unsigned, unsigned>
10213AArch64InstrInfo::decomposeMachineOperandsTargetFlags(
unsigned TF)
const {
10215 return std::make_pair(TF & Mask, TF & ~Mask);
10219AArch64InstrInfo::getSerializableDirectMachineOperandTargetFlags()
const {
10222 static const std::pair<unsigned, const char *> TargetFlags[] = {
10223 {MO_PAGE,
"aarch64-page"}, {
MO_PAGEOFF,
"aarch64-pageoff"},
10224 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
10225 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
10231AArch64InstrInfo::getSerializableBitmaskMachineOperandTargetFlags()
const {
10232 using namespace AArch64II;
10234 static const std::pair<unsigned, const char *> TargetFlags[] = {
10236 {
MO_GOT,
"aarch64-got"},
10237 {
MO_NC,
"aarch64-nc"},
10238 {
MO_S,
"aarch64-s"},
10239 {
MO_TLS,
"aarch64-tls"},
10249AArch64InstrInfo::getSerializableMachineMemOperandTargetFlags()
const {
10250 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
10384 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10399 return C.isAvailableInsideSeq(AArch64::FP,
TRI);
10407 const AArch64RegisterInfo *ARI =
10408 static_cast<const AArch64RegisterInfo *
>(&
TRI);
10411 for (
unsigned Reg : AArch64::GPR64RegClass) {
10413 Reg != AArch64::LR &&
10414 Reg != AArch64::X16 &&
10415 Reg != AArch64::X17 &&
10416 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
10417 C.isAvailableInsideSeq(
Reg,
TRI))
10448 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
10451std::optional<std::unique_ptr<outliner::OutlinedFunction>>
10452AArch64InstrInfo::getOutliningCandidateInfo(
10454 std::vector<outliner::Candidate> &RepeatedSequenceLocs,
10455 unsigned MinRepeats)
const {
10456 unsigned SequenceSize = 0;
10457 for (
auto &
MI : RepeatedSequenceLocs[0])
10460 unsigned NumBytesToCreateFrame = 0;
10466 MachineInstr &LastMI = RepeatedSequenceLocs[0].back();
10467 MachineInstr &FirstMI = RepeatedSequenceLocs[0].front();
10468 if (LastMI.
getOpcode() == AArch64::ADRP &&
10471 return std::nullopt;
10476 if ((FirstMI.
getOpcode() == AArch64::ADDXri ||
10477 FirstMI.
getOpcode() == AArch64::LDRXui) &&
10480 return std::nullopt;
10491 if (std::adjacent_find(
10492 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
10493 [](
const outliner::Candidate &a,
const outliner::Candidate &b) {
10496 if (outliningCandidatesSigningScopeConsensus(a, b) &&
10497 outliningCandidatesSigningKeyConsensus(a, b) &&
10498 outliningCandidatesV8_3OpsConsensus(a, b)) {
10502 }) != RepeatedSequenceLocs.end()) {
10503 return std::nullopt;
10520 unsigned NumBytesToCheckLRInTCEpilogue = 0;
10521 const auto RASignCondition = RepeatedSequenceLocs[0]
10524 ->getSignReturnAddressCondition();
10527 NumBytesToCreateFrame += 8;
10530 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
10531 *RepeatedSequenceLocs[0].getMF());
10532 NumBytesToCheckLRInTCEpilogue =
10536 if (isTailCallReturnInst(RepeatedSequenceLocs[0].
back()))
10537 SequenceSize += NumBytesToCheckLRInTCEpilogue;
10545 for (
auto &
MI :
C) {
10546 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
10547 switch (
MI.getOpcode()) {
10548 case AArch64::ADDXri:
10549 case AArch64::ADDWri:
10550 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10551 assert(
MI.getOperand(2).isImm() &&
10552 "Expected operand to be immediate");
10553 assert(
MI.getOperand(1).isReg() &&
10554 "Expected operand to be a register");
10558 if (
MI.getOperand(1).getReg() == AArch64::SP)
10559 SPValue +=
MI.getOperand(2).getImm();
10563 case AArch64::SUBXri:
10564 case AArch64::SUBWri:
10565 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
10566 assert(
MI.getOperand(2).isImm() &&
10567 "Expected operand to be immediate");
10568 assert(
MI.getOperand(1).isReg() &&
10569 "Expected operand to be a register");
10573 if (
MI.getOperand(1).getReg() == AArch64::SP)
10574 SPValue -=
MI.getOperand(2).getImm();
10591 if (RepeatedSequenceLocs.size() < MinRepeats)
10592 return std::nullopt;
10596 unsigned FlagsSetInAll = 0xF;
10600 FlagsSetInAll &=
C.Flags;
10602 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
10605 auto SetCandidateCallInfo =
10606 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
10608 C.setCallInfo(CallID, NumBytesForCall);
10612 NumBytesToCreateFrame += 4;
10620 unsigned CFICount = 0;
10621 for (
auto &
I : RepeatedSequenceLocs[0]) {
10622 if (
I.isCFIInstruction())
10632 std::vector<MCCFIInstruction> CFIInstructions =
10633 C.getMF()->getFrameInstructions();
10635 if (CFICount > 0 && CFICount != CFIInstructions.size())
10636 return std::nullopt;
10644 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
10645 !
MI.readsRegister(AArch64::SP, &
TRI))
10651 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
10656 if (
MI.mayLoadOrStore()) {
10659 bool OffsetIsScalable;
10663 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
10664 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
10668 if (OffsetIsScalable)
10676 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
10677 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
10680 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
10681 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
10696 bool AllStackInstrsSafe =
10701 if (RepeatedSequenceLocs[0].
back().isTerminator()) {
10703 NumBytesToCreateFrame = 0;
10704 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
10708 else if (LastInstrOpcode == AArch64::BL ||
10709 ((LastInstrOpcode == AArch64::BLR ||
10710 LastInstrOpcode == AArch64::BLRNoIP) &&
10714 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
10722 unsigned NumBytesNoStackCalls = 0;
10723 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
10729 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
10738 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
10741 if (LRAvailable && !IsNoReturn) {
10742 NumBytesNoStackCalls += 4;
10744 CandidatesWithoutStackFixups.push_back(
C);
10749 else if (findRegisterToSaveLRTo(
C)) {
10750 NumBytesNoStackCalls += 12;
10752 CandidatesWithoutStackFixups.push_back(
C);
10757 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
10758 NumBytesNoStackCalls += 12;
10760 CandidatesWithoutStackFixups.push_back(
C);
10766 NumBytesNoStackCalls += SequenceSize;
10773 if (!AllStackInstrsSafe ||
10774 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
10775 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
10777 if (RepeatedSequenceLocs.size() < MinRepeats)
10778 return std::nullopt;
10831 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
10832 !findRegisterToSaveLRTo(
C));
10838 if (RepeatedSequenceLocs.size() < MinRepeats)
10839 return std::nullopt;
10848 bool ModStackToSaveLR =
false;
10851 ModStackToSaveLR =
true;
10860 ModStackToSaveLR =
true;
10862 if (ModStackToSaveLR) {
10864 if (!AllStackInstrsSafe)
10865 return std::nullopt;
10868 NumBytesToCreateFrame += 8;
10872 RepeatedSequenceLocs,
TRI))
10873 NumBytesToCreateFrame += 4;
10880 return std::nullopt;
10882 return std::make_unique<outliner::OutlinedFunction>(
10883 RepeatedSequenceLocs, SequenceSize, NumBytesToCreateFrame, FrameID);
10886void AArch64InstrInfo::mergeOutliningCandidateAttributes(
10887 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
10891 const auto &CFn = Candidates.front().getMF()->getFunction();
10893 if (CFn.hasFnAttribute(
"ptrauth-returns"))
10894 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
10895 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
10896 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
10899 if (CFn.hasFnAttribute(
"sign-return-address"))
10900 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
10901 if (CFn.hasFnAttribute(
"sign-return-address-key"))
10902 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
10904 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
10907bool AArch64InstrInfo::isFunctionSafeToOutlineFrom(
10912 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
10919 if (
F.hasSection())
10925 AArch64FunctionInfo *AFI = MF.
getInfo<AArch64FunctionInfo>();
10926 if (!AFI || AFI->
hasRedZone().value_or(
true))
10946 unsigned &Flags)
const {
10948 "Must track liveness!");
10950 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
10965 auto AreAllUnsafeRegsDead = [&LRU]() {
10966 return LRU.available(AArch64::W16) && LRU.available(AArch64::W17) &&
10967 LRU.available(AArch64::NZCV);
10982 bool LRAvailableEverywhere =
true;
10984 LRU.addLiveOuts(
MBB);
10986 auto UpdateWholeMBBFlags = [&
Flags](
const MachineInstr &
MI) {
10987 if (
MI.isCall() && !
MI.isTerminator())
10993 auto CreateNewRangeStartingAt =
10994 [&RangeBegin, &RangeEnd,
10996 RangeBegin = NewBegin;
10997 RangeEnd = std::next(RangeBegin);
11000 auto SaveRangeIfNonEmpty = [&RangeLen, &
Ranges, &RangeBegin, &RangeEnd]() {
11006 if (!RangeBegin.isEnd() && RangeBegin->isBundledWithPred())
11008 if (!RangeEnd.isEnd() && RangeEnd->isBundledWithPred())
11010 Ranges.emplace_back(RangeBegin, RangeEnd);
11018 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
11019 if (!FirstPossibleEndPt->isDebugInstr())
11020 LRU.stepBackward(*FirstPossibleEndPt);
11023 UpdateWholeMBBFlags(*FirstPossibleEndPt);
11024 if (AreAllUnsafeRegsDead())
11031 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
11036 if (!
MI.isDebugInstr())
11037 LRU.stepBackward(
MI);
11038 UpdateWholeMBBFlags(
MI);
11039 if (!AreAllUnsafeRegsDead()) {
11040 SaveRangeIfNonEmpty();
11041 CreateNewRangeStartingAt(
MI.getIterator());
11044 LRAvailableEverywhere &= LRU.available(AArch64::LR);
11048 RangeBegin =
MI.getIterator();
11049 if (!
MI.isDebugInstr())
11054 if (AreAllUnsafeRegsDead())
11055 SaveRangeIfNonEmpty();
11063 if (!LRAvailableEverywhere)
11071 unsigned Flags)
const {
11072 MachineInstr &
MI = *MIT;
11076 switch (
MI.getOpcode()) {
11077 case AArch64::PACM:
11078 case AArch64::PACIASP:
11079 case AArch64::PACIBSP:
11080 case AArch64::PACIASPPC:
11081 case AArch64::PACIBSPPC:
11082 case AArch64::AUTIASP:
11083 case AArch64::AUTIBSP:
11084 case AArch64::AUTIASPPCi:
11085 case AArch64::AUTIASPPCr:
11086 case AArch64::AUTIBSPPCi:
11087 case AArch64::AUTIBSPPCr:
11088 case AArch64::RETAA:
11089 case AArch64::RETAB:
11090 case AArch64::RETAASPPCi:
11091 case AArch64::RETAASPPCr:
11092 case AArch64::RETABSPPCi:
11093 case AArch64::RETABSPPCr:
11094 case AArch64::EMITBKEY:
11095 case AArch64::PAUTH_PROLOGUE:
11096 case AArch64::PAUTH_EPILOGUE:
11106 if (
MI.isCFIInstruction())
11110 if (
MI.isTerminator())
11116 for (
const MachineOperand &MOP :
MI.operands()) {
11119 assert(!MOP.isCFIIndex());
11122 if (MOP.isReg() && !MOP.isImplicit() &&
11123 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
11130 if (
MI.getOpcode() == AArch64::ADRP)
11150 for (
const MachineOperand &MOP :
MI.operands()) {
11151 if (MOP.isGlobal()) {
11159 if (Callee &&
Callee->getName() ==
"\01_mcount")
11167 if (
MI.getOpcode() == AArch64::BLR ||
11168 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
11172 return UnknownCallOutlineType;
11180 return UnknownCallOutlineType;
11188 return UnknownCallOutlineType;
11209 for (MachineInstr &
MI :
MBB) {
11210 const MachineOperand *
Base;
11211 TypeSize Width(0,
false);
11213 bool OffsetIsScalable;
11216 if (!
MI.mayLoadOrStore() ||
11219 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
11223 TypeSize Scale(0U,
false);
11224 int64_t Dummy1, Dummy2;
11227 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
11229 assert(Scale != 0 &&
"Unexpected opcode!");
11230 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
11235 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
11236 StackOffsetOperand.
setImm(NewImm);
11242 bool ShouldSignReturnAddr) {
11243 if (!ShouldSignReturnAddr)
11251void AArch64InstrInfo::buildOutlinedFrame(
11255 AArch64FunctionInfo *FI = MF.
getInfo<AArch64FunctionInfo>();
11263 unsigned TailOpcode;
11265 TailOpcode = AArch64::TCRETURNdi;
11269 TailOpcode = AArch64::TCRETURNriALL;
11280 bool IsLeafFunction =
true;
11283 auto IsNonTailCall = [](
const MachineInstr &
MI) {
11284 return MI.isCall() && !
MI.isReturn();
11294 "Can only fix up stack references once");
11295 fixupPostOutline(
MBB);
11297 IsLeafFunction =
false;
11308 Et = std::prev(
MBB.
end());
11339 CFIBuilder.buildDefCFA(AArch64::FP, 16);
11340 CFIBuilder.buildOffset(AArch64::LR, -8);
11341 CFIBuilder.buildOffset(AArch64::FP, -16);
11360 if (MF.
getInfo<AArch64FunctionInfo>()->needsDwarfUnwindInfo(MF)) {
11364 CFIBuilder.buildDefCFAOffset(16);
11368 CFIBuilder.buildOffset(AArch64::LR, -16);
11383 RASignCondition, !IsLeafFunction);
11412 fixupPostOutline(
MBB);
11423 .addGlobalAddress(
M.getNamedValue(MF.
getName()))
11433 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11442 MachineInstr *Save;
11443 MachineInstr *Restore;
11449 assert(
Reg &&
"No callee-saved register available?");
11483 .addGlobalAddress(
M.getNamedValue(MF.
getName())));
11491bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
11499 bool AllowSideEffects)
const {
11501 const AArch64Subtarget &STI = MF.
getSubtarget<AArch64Subtarget>();
11504 if (
TRI.isGeneralPurposeRegister(MF,
Reg)) {
11517 assert(STI.hasFPARMv8() &&
"Expected FP to be available.");
11523std::optional<DestSourcePair>
11528 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11529 MI.getOperand(1).getReg() == AArch64::WZR &&
11530 MI.getOperand(3).getImm() == 0x0) ||
11531 (
MI.getOpcode() == AArch64::ORRWrr &&
11532 MI.getOperand(1).getReg() == AArch64::WZR)) {
11534 if ((
MI.getOperand(0).getReg().isPhysical() &&
11535 MI.findRegisterDefOperandIdx(
11538 (
MI.getOperand(0).getReg().isVirtual() &&
11539 !
MI.getOperand(0).getSubReg()))
11543 if (
MI.getOpcode() == AArch64::ORRXrs &&
11544 MI.getOperand(1).getReg() == AArch64::XZR &&
11545 MI.getOperand(3).getImm() == 0x0)
11548 return std::nullopt;
11551std::optional<DestSourcePair>
11553 if ((
MI.getOpcode() == AArch64::ORRWrs &&
11554 MI.getOperand(1).getReg() == AArch64::WZR &&
11555 MI.getOperand(3).getImm() == 0x0) ||
11556 (
MI.getOpcode() == AArch64::ORRWrr &&
11557 MI.getOperand(1).getReg() == AArch64::WZR))
11559 return std::nullopt;
11562std::optional<RegImmPair>
11571 return std::nullopt;
11573 switch (
MI.getOpcode()) {
11575 return std::nullopt;
11576 case AArch64::SUBWri:
11577 case AArch64::SUBXri:
11578 case AArch64::SUBSWri:
11579 case AArch64::SUBSXri:
11582 case AArch64::ADDSWri:
11583 case AArch64::ADDSXri:
11584 case AArch64::ADDWri:
11585 case AArch64::ADDXri: {
11587 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
11588 !
MI.getOperand(2).isImm())
11589 return std::nullopt;
11590 int Shift =
MI.getOperand(3).getImm();
11591 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
11595 return RegImmPair{
MI.getOperand(1).getReg(),
Offset};
11601static std::optional<ParamLoadedValue>
11605 auto DestSrc =
TII->isCopyLikeInstr(
MI);
11607 return std::nullopt;
11609 Register DestReg = DestSrc->Destination->getReg();
11610 Register SrcReg = DestSrc->Source->getReg();
11613 return std::nullopt;
11618 if (DestReg == DescribedReg)
11622 if (
MI.getOpcode() == AArch64::ORRWrs &&
11623 TRI->isSuperRegister(DestReg, DescribedReg))
11627 if (
MI.getOpcode() == AArch64::ORRXrs &&
11628 TRI->isSubRegister(DestReg, DescribedReg)) {
11629 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
11633 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
11634 "Unhandled ORR[XW]rs copy case");
11636 return std::nullopt;
11639bool AArch64InstrInfo::isFunctionSafeToSplit(
const MachineFunction &MF)
const {
11644 if (MF.
getInfo<AArch64FunctionInfo>()->hasRedZone().value_or(
true))
11650bool AArch64InstrInfo::isMBBSafeToSplitToCold(
11654 auto isAsmGoto = [](
const MachineInstr &
MI) {
11655 return MI.getOpcode() == AArch64::INLINEASM_BR;
11665 auto containsMBB = [&
MBB](
const MachineJumpTableEntry &JTE) {
11672 for (
const MachineInstr &
MI :
MBB) {
11673 switch (
MI.getOpcode()) {
11674 case TargetOpcode::G_BRJT:
11675 case AArch64::JumpTableDest32:
11676 case AArch64::JumpTableDest16:
11677 case AArch64::JumpTableDest8:
11688std::optional<ParamLoadedValue>
11693 switch (
MI.getOpcode()) {
11694 case AArch64::MOVZWi:
11695 case AArch64::MOVZXi: {
11698 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(),
Reg))
11699 return std::nullopt;
11701 if (!
MI.getOperand(1).isImm())
11702 return std::nullopt;
11703 int64_t Immediate =
MI.getOperand(1).getImm();
11704 int Shift =
MI.getOperand(2).getImm();
11708 case AArch64::ORRWrs:
11709 case AArch64::ORRXrs:
11716bool AArch64InstrInfo::isExtendLikelyToBeFolded(
11719 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
11720 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
11723 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
11733 return UserMI->
getOpcode() == TargetOpcode::G_PTR_ADD;
11736uint64_t AArch64InstrInfo::getElementSizeForOpcode(
unsigned Opc)
const {
11740bool AArch64InstrInfo::isPTestLikeOpcode(
unsigned Opc)
const {
11744bool AArch64InstrInfo::isWhileOpcode(
unsigned Opc)
const {
11749AArch64InstrInfo::getTailDuplicateSize(
CodeGenOptLevel OptLevel)
const {
11753bool AArch64InstrInfo::isLegalAddressingMode(
unsigned NumBytes, int64_t
Offset,
11754 unsigned Scale)
const {
11765 unsigned Shift =
Log2_64(NumBytes);
11766 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
11774 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
11779 return AArch64::BLRNoIP;
11781 return AArch64::BLR;
11787 auto Builder =
BuildMI(
MBB, InsertPt,
DL,
get(AArch64::PAUTH_EPILOGUE))
11808 Register TargetReg,
bool FrameSetup)
const {
11809 assert(TargetReg != AArch64::SP &&
"New top of stack cannot already be in SP");
11821 MF.
insert(MBBInsertPoint, LoopTestMBB);
11824 MF.
insert(MBBInsertPoint, LoopBodyMBB);
11826 MF.
insert(MBBInsertPoint, ExitMBB);
11836 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
11844 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::Bcc))
11850 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::LDRXui))
11867 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
11886 MBB.addSuccessor(LoopTestMBB);
11892 return ExitMBB->
begin();
11898 const TargetInstrInfo *
TII;
11899 const TargetRegisterInfo *
TRI;
11900 MachineRegisterInfo &MRI;
11903 MachineBasicBlock *LoopBB;
11905 MachineInstr *CondBranch;
11907 MachineInstr *Comp;
11909 unsigned CompCounterOprNum;
11911 MachineInstr *Update;
11913 unsigned UpdateCounterOprNum;
11917 bool IsUpdatePriorComp;
11923 AArch64PipelinerLoopInfo(MachineBasicBlock *LoopBB, MachineInstr *CondBranch,
11924 MachineInstr *Comp,
unsigned CompCounterOprNum,
11925 MachineInstr *Update,
unsigned UpdateCounterOprNum,
11926 Register Init,
bool IsUpdatePriorComp,
11927 const SmallVectorImpl<MachineOperand> &
Cond)
11929 TII(MF->getSubtarget().getInstrInfo()),
11930 TRI(MF->getSubtarget().getRegisterInfo()), MRI(MF->getRegInfo()),
11931 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
11932 CompCounterOprNum(CompCounterOprNum), Update(Update),
11933 UpdateCounterOprNum(UpdateCounterOprNum), Init(Init),
11936 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
11942 std::optional<bool> createTripCountGreaterCondition(
11943 int TC, MachineBasicBlock &
MBB,
11944 SmallVectorImpl<MachineOperand> &CondParam)
override {
11952 void createRemainingIterationsGreaterCondition(
11953 int TC, MachineBasicBlock &
MBB, SmallVectorImpl<MachineOperand> &
Cond,
11954 DenseMap<MachineInstr *, MachineInstr *> &LastStage0Insts)
override;
11956 void setPreheader(MachineBasicBlock *NewPreheader)
override {}
11958 void adjustTripCount(
int TripCountAdjust)
override {}
11960 bool isMVEExpanderSupported()
override {
return true; }
11979 }
else if (
I == ReplaceOprNum) {
11984 MBB.insert(InsertTo, NewMI);
11988void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
12004 assert(CondBranch->getOpcode() == AArch64::Bcc);
12008 if (CondBranch->getOperand(1).getMBB() == LoopBB)
12015 auto AccumulateCond = [&](
Register CurCond,
12026 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
12030 for (
int I = 0;
I <= TC; ++
I) {
12036 AccCond = AccumulateCond(AccCond, CC);
12040 if (Update != Comp && IsUpdatePriorComp) {
12042 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12043 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
12047 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
12049 }
else if (Update != Comp) {
12054 Counter = NextCounter;
12058 if (LastStage0Insts.
empty()) {
12062 if (IsUpdatePriorComp)
12067 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
12070 for (
int I = 0;
I <= TC; ++
I) {
12074 AccCond = AccumulateCond(AccCond, CC);
12075 if (
I != TC && Update != Comp)
12078 Counter = NextCounter;
12094 assert(Phi.getNumOperands() == 5);
12095 if (Phi.getOperand(2).getMBB() ==
MBB) {
12096 RegMBB = Phi.getOperand(1).getReg();
12097 RegOther = Phi.getOperand(3).getReg();
12099 assert(Phi.getOperand(4).getMBB() ==
MBB);
12100 RegMBB = Phi.getOperand(3).getReg();
12101 RegOther = Phi.getOperand(1).getReg();
12106 if (!
Reg.isVirtual())
12115 unsigned &UpdateCounterOprNum,
Register &InitReg,
12116 bool &IsUpdatePriorComp) {
12130 if (!
Reg.isVirtual())
12133 UpdateInst =
nullptr;
12134 UpdateCounterOprNum = 0;
12136 IsUpdatePriorComp =
true;
12140 if (Def->getParent() != LoopBB)
12142 if (Def->isCopy()) {
12144 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
12146 CurReg = Def->getOperand(1).getReg();
12147 }
else if (Def->isPHI()) {
12151 IsUpdatePriorComp =
false;
12156 switch (Def->getOpcode()) {
12157 case AArch64::ADDSXri:
12158 case AArch64::ADDSWri:
12159 case AArch64::SUBSXri:
12160 case AArch64::SUBSWri:
12161 case AArch64::ADDXri:
12162 case AArch64::ADDWri:
12163 case AArch64::SUBXri:
12164 case AArch64::SUBWri:
12166 UpdateCounterOprNum = 1;
12168 case AArch64::ADDSXrr:
12169 case AArch64::ADDSWrr:
12170 case AArch64::SUBSXrr:
12171 case AArch64::SUBSWrr:
12172 case AArch64::ADDXrr:
12173 case AArch64::ADDWrr:
12174 case AArch64::SUBXrr:
12175 case AArch64::SUBWrr:
12178 UpdateCounterOprNum = 1;
12180 UpdateCounterOprNum = 2;
12187 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
12202std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
12213 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
12224 if (
TBB == LoopBB && FBB == LoopBB)
12228 if (
TBB != LoopBB && FBB ==
nullptr)
12231 assert((
TBB == LoopBB || FBB == LoopBB) &&
12232 "The Loop must be a single-basic-block loop");
12237 if (CondBranch->
getOpcode() != AArch64::Bcc)
12245 unsigned CompCounterOprNum = 0;
12247 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
12251 switch (
MI.getOpcode()) {
12252 case AArch64::SUBSXri:
12253 case AArch64::SUBSWri:
12254 case AArch64::ADDSXri:
12255 case AArch64::ADDSWri:
12257 CompCounterOprNum = 1;
12259 case AArch64::ADDSWrr:
12260 case AArch64::ADDSXrr:
12261 case AArch64::SUBSWrr:
12262 case AArch64::SUBSXrr:
12266 if (isWhileOpcode(
MI.getOpcode())) {
12273 if (CompCounterOprNum == 0) {
12275 CompCounterOprNum = 2;
12277 CompCounterOprNum = 1;
12289 bool IsUpdatePriorComp;
12290 unsigned UpdateCounterOprNum;
12292 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
12295 return std::make_unique<AArch64PipelinerLoopInfo>(
12296 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
12306 TypeSize Scale(0U,
false), Width(0U,
false);
12307 int64_t MinOffset, MaxOffset;
12308 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
12310 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
12311 int64_t
Imm =
MI.getOperand(ImmIdx).getImm();
12313 ErrInfo =
"Unexpected immediate on load/store instruction";
12319 const MCInstrDesc &MCID =
MI.getDesc();
12321 const MachineOperand &MO =
MI.getOperand(
Op);
12325 ErrInfo =
"OPERAND_IMPLICIT_IMM_0 should be 0";
12334 ErrInfo =
"OPERAND_SHIFT_MSL should be msl shift of 8 or 16";
12340 ErrInfo =
"OPERAND_IMM_UINT1 should be 0 or 1";
12346 ErrInfo =
"OPERAND_IMM_UINT4plus1 should be in the range 1 to 16";
12352 ErrInfo =
"OPERAND_IMM_UINT5 should be in the range 0 to 31";
12358 ErrInfo =
"OPERAND_IMM_UINT8 should be in the range 0 to 255";
12369#define GET_INSTRINFO_HELPERS
12370#define GET_INSTRMAP_INFO
12371#include "AArch64GenInstrInfo.inc"
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
static Register genNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned MnegOpc, const TargetRegisterClass *RC)
genNeg - Helper to generate an intermediate negation of the second operand of Root
static bool isFrameStoreOpcode(int Opcode)
static cl::opt< unsigned > GatherOptSearchLimit("aarch64-search-limit", cl::Hidden, cl::init(2048), cl::desc("Restrict range of instructions to search for the " "machine-combiner gather pattern optimization"))
static bool getMaddPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find instructions that can be turned into madd.
static AArch64CC::CondCode findCondCodeUsedByInstr(const MachineInstr &Instr)
Find a condition code used by the instruction.
static MachineInstr * genFusedMultiplyAcc(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyAcc - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate64(unsigned Opc)
static bool isFrameLoadOpcode(int Opcode)
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool areCFlagsAccessedBetweenInstrs(MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI, const AccessKind AccessToCheck=AK_All)
True when condition flags are accessed (either by writing or reading) on the instruction trace starti...
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Floating-Point Support.
static bool isADDSRegImm(unsigned Opcode)
static bool isCheapCopy(const MachineInstr &MI, const AArch64RegisterInfo &RI)
static bool isANDOpcode(MachineInstr &MI)
static 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 bool isCombineInstrSettingFlag(unsigned Opc)
static bool getFNEGPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static bool getIndVarInfo(Register Reg, const MachineBasicBlock *LoopBB, MachineInstr *&UpdateInst, unsigned &UpdateCounterOprNum, Register &InitReg, bool &IsUpdatePriorComp)
If Reg is an induction variable, return true and set some parameters.
static bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
static bool mustAvoidNeonAtMBBI(const AArch64Subtarget &Subtarget, MachineBasicBlock &MBB, MachineBasicBlock::iterator I)
Returns true if in a streaming call site region without SME-FA64.
static bool isPostIndexLdStOpcode(unsigned Opcode)
Return true if the opcode is a post-index ld/st instruction, which really loads from base+0.
static std::optional< unsigned > getLFIInstSizeInBytes(const MachineInstr &MI)
Return the maximum number of bytes of code the specified instruction may be after LFI rewriting.
static unsigned getBranchDisplacementBits(unsigned Opc)
static cl::opt< unsigned > CBDisplacementBits("aarch64-cb-offset-bits", cl::Hidden, cl::init(9), cl::desc("Restrict range of CB instructions (DEBUG)"))
static std::optional< ParamLoadedValue > describeORRLoadedValue(const MachineInstr &MI, Register DescribedReg, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
If the given ORR instruction is a copy, and DescribedReg overlaps with the destination register then,...
static bool getFMULPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
static void appendReadRegExpr(SmallVectorImpl< char > &Expr, unsigned RegNum)
static MachineInstr * genMaddR(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, unsigned VR, const TargetRegisterClass *RC)
genMaddR - Generate madd instruction and combine mul and add using an extra virtual register Example ...
static Register cloneInstr(const MachineInstr *MI, unsigned ReplaceOprNum, Register ReplaceReg, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertTo)
Clone an instruction from MI.
static bool scaleOffset(unsigned Opc, int64_t &Offset)
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
unsigned scaledOffsetOpcode(unsigned Opcode, unsigned &Scale)
static MachineInstr * genFusedMultiplyIdx(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyIdx - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genIndexedMultiply(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxDupOp, unsigned MulOpc, const TargetRegisterClass *RC, MachineRegisterInfo &MRI)
Fold (FMUL x (DUP y lane)) into (FMUL_indexed x y lane)
static cl::opt< bool > UseCompactUnwindFrameRecordForOutlinedFunctions("aarch64-outliner-compact-unwind-frame", cl::Hidden, cl::init(true), cl::desc("Use a frame record for Mach-O non-leaf outlined functions"))
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 cl::opt< unsigned > TBZDisplacementBits("aarch64-tbz-offset-bits", cl::Hidden, cl::init(14), cl::desc("Restrict range of TB[N]Z instructions (DEBUG)"))
static void extractPhiReg(const MachineInstr &Phi, const MachineBasicBlock *MBB, Register &RegMBB, Register &RegOther)
static MCCFIInstruction createDefCFAExpression(const TargetRegisterInfo &TRI, unsigned Reg, const StackOffset &Offset)
static bool isDefinedOutside(Register Reg, const MachineBasicBlock *BB)
static MachineInstr * genFusedMultiply(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC, FMAInstKind kind=FMAInstKind::Default, const Register *ReplacedAddend=nullptr)
genFusedMultiply - Generate fused multiply instructions.
static bool getGatherLanePattern(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, unsigned LoadLaneOpCode, unsigned NumLanes)
Check if the given instruction forms a gather load pattern that can be optimized for better Memory-Le...
static MachineInstr * genFusedMultiplyIdxNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< Register, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static bool isCombineInstrCandidate(unsigned Opc)
static unsigned regOffsetOpcode(unsigned Opcode)
MachineOutlinerClass
Constants defining how certain sequences should be outlined.
@ MachineOutlinerTailCall
Emit a save, restore, call, and return.
@ MachineOutlinerRegSave
Emit a call and tail-call.
@ MachineOutlinerNoLRSave
Only emit a branch.
@ MachineOutlinerThunk
Emit a call and return.
static cl::opt< unsigned > BDisplacementBits("aarch64-b-offset-bits", cl::Hidden, cl::init(26), cl::desc("Restrict range of B instructions (DEBUG)"))
static bool areCFlagsAliveInSuccessors(const MachineBasicBlock *MBB)
Check if AArch64::NZCV should be alive in successors of MBB.
static void emitFrameOffsetAdj(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int64_t Offset, unsigned Opc, const TargetInstrInfo *TII, MachineInstr::MIFlag Flag, bool NeedsWinCFI, bool *HasWinCFI, bool EmitCFAOffset, StackOffset CFAOffset, unsigned FrameReg)
static bool isCheapImmediate(const MachineInstr &MI, unsigned BitSize)
static cl::opt< unsigned > CBZDisplacementBits("aarch64-cbz-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of CB[N]Z instructions (DEBUG)"))
static void genSubAdd2SubSub(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, unsigned IdxOpd1, DenseMap< Register, unsigned > &InstrIdxForVirtReg)
Do the following transformation A - (B + C) ==> (A - B) - C A - (B + C) ==> (A - C) - B.
static unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewReg=nullptr)
static void signOutlinedFunction(MachineFunction &MF, MachineBasicBlock &MBB, const AArch64InstrInfo *TII, bool ShouldSignReturnAddr)
static MachineInstr * genFNegatedMAD(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs)
static bool canCombineWithMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc, unsigned ZeroReg)
static void storeRegPairToStackSlot(const TargetRegisterInfo &TRI, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MCInstrDesc &MCID, Register SrcReg, bool IsKill, unsigned SubIdx0, unsigned SubIdx1, int FI, MachineMemOperand *MMO)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static const Function * getParent(const Value *V)
static GCRegistry::Add< 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
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
Register isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
static const MachineOperand & getLdStOffsetOp(const MachineInstr &MI)
Returns the immediate offset operator of a load/store.
bool isCoalescableExtInstr(const MachineInstr &MI, Register &SrcReg, Register &DstReg, unsigned &SubIdx) const override
static std::optional< unsigned > getUnscaledLdSt(unsigned Opc)
Returns the unscaled load/store for the scaled load/store opcode, if there is a corresponding unscale...
static bool hasUnscaledLdStOffset(unsigned Opc)
Return true if it has an unscaled load/store offset.
static const MachineOperand & getLdStAmountOp(const MachineInstr &MI)
Returns the shift amount operator of a load/store.
static bool isPreLdSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed load/store.
std::optional< ExtAddrMode > getAddrModeFromMemoryOp(const MachineInstr &MemI, const TargetRegisterInfo *TRI) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &MI, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width, const TargetRegisterInfo *TRI) const override
bool analyzeBranchPredicate(MachineBasicBlock &MBB, MachineBranchPredicate &MBP, bool AllowModify) const override
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
static bool isSExtLoad(const MachineInstr &MI)
Returns whether the instruction is a sign-extending load.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static bool isPreSt(const MachineInstr &MI)
Returns whether the instruction is a pre-indexed store.
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
AArch64InstrInfo(const AArch64Subtarget &STI)
static bool isPairedLdSt(const MachineInstr &MI)
Returns whether the instruction is a paired load/store.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, int FrameIndex, MachineInstr *&CopyMI, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool getMemOperandWithOffsetWidth(const MachineInstr &MI, const MachineOperand *&BaseOp, int64_t &Offset, bool &OffsetIsScalable, TypeSize &Width, const TargetRegisterInfo *TRI) const
If OffsetIsScalable is set to 'true', the offset is scaled by vscale.
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
bool shouldClusterMemOps(ArrayRef< const MachineOperand * > BaseOps1, int64_t Offset1, bool OffsetIsScalable1, ArrayRef< const MachineOperand * > BaseOps2, int64_t Offset2, bool OffsetIsScalable2, unsigned ClusterSize, unsigned NumBytes) const override
Detect opportunities for ldp/stp formation.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool canFoldIntoAddrMode(const MachineInstr &MemI, Register Reg, const MachineInstr &AddrI, ExtAddrMode &AM) const override
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
Register isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
Check for post-frame ptr elimination stack locations as well.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
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 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...
bool usesWindowsCFI() const
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static MCCFIInstruction cfiDefCfaOffset(MCSymbol *L, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa_offset modifies a rule for computing CFA.
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals, SMLoc Loc={}, StringRef Comment="")
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
bool hasSuperClassEq(const MCRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
bool hasSubClassEq(const MCRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
Wrapper class representing physical registers. Should be passed by value.
constexpr bool isValid() const
static constexpr unsigned NoRegister
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isInlineAsmBrIndirectTarget() const
Returns true if this is the indirect dest of an INLINEASM_BR.
unsigned pred_size() const
LLVM_ABI void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
LLVM_ABI instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
reverse_instr_iterator instr_rbegin()
LLVM_ABI iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
LLVM_ABI void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
reverse_instr_iterator instr_rend()
Instructions::iterator instr_iterator
instr_iterator instr_end()
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
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.
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.
MI-level patchpoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
Wrapper class representing virtual and physical registers.
MCRegister asMCReg() const
Utility to check-convert this value to a MCRegister.
constexpr bool isValid() const
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
static constexpr bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
Represents a location in source code.
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
StringRef str() const
Explicit conversion to StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
MI-level stackmap operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
StackOffset holds a fixed and a scalable offset in bytes.
int64_t getFixed() const
Returns the fixed component of the stack.
int64_t getScalable() const
Returns the scalable component of the stack.
static StackOffset get(int64_t Fixed, int64_t Scalable)
static StackOffset getScalable(int64_t Scalable)
static StackOffset getFixed(int64_t Fixed)
MI-level Statepoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given statepoint should emit.
Represent a constant reference to a string, i.e.
Object returned by analyzeLoopForPipelining.
TargetInstrInfo - Interface to description of machine instruction set.
virtual void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< Register, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
virtual std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) const
Produce the expression describing the MI loading a value into the physical register Reg.
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
virtual CombinerObjective getCombinerObjective(unsigned Pattern) const
Return the objective of a combiner pattern.
virtual bool isFunctionSafeToSplit(const MachineFunction &MF) const
Return true if the function is a viable candidate for machine function splitting.
const Triple & getTargetTriple() const
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
initializer< Ty > init(const Ty &Val)
InstrType
Represents how an instruction should be mapped by the outliner.
NodeAddr< InstrNode * > Instr
LLVM_ABI Instruction & back() const
LLVM_ABI iterator begin() const
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
static bool isCondBranchOpcode(int Opc)
MCCFIInstruction createDefCFA(const TargetRegisterInfo &TRI, unsigned FrameReg, unsigned Reg, const StackOffset &Offset, bool LastAdjustmentWasScalable=true)
static bool isPTrueOpcode(unsigned Opc)
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool succeeded(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
int isAArch64FrameOffsetLegal(const MachineInstr &MI, StackOffset &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int64_t *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
RegState
Flags to represent properties of register accesses.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
@ Define
Register definition.
@ Renamable
Register that may be renamed.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
constexpr RegState getKillRegState(bool B)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static bool isIndirectBranchOpcode(int Opc)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getBLRCallOpcode(const MachineFunction &MF)
Return opcode to be used for indirect calls.
@ AArch64FrameOffsetIsLegal
Offset is legal.
@ AArch64FrameOffsetCanUpdate
Offset can apply, at least partly.
@ AArch64FrameOffsetCannotUpdate
Offset cannot apply.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static bool isSEHInstruction(const MachineInstr &MI)
bool isLFIPrePostMemAccess(unsigned Opcode)
Returns true if Opcode is a pre- or post-indexed memory access that the LFI rewriter expands with a b...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
auto reverse(ContainerTy &&C)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
AArch64MachineCombinerPattern
@ MULSUBv2i32_indexed_OP1
@ MULADDv4i16_indexed_OP2
@ MULSUBv8i16_indexed_OP2
@ MULSUBv4i16_indexed_OP2
@ MULSUBv4i32_indexed_OP2
@ MULADDv2i32_indexed_OP1
@ MULADDv4i32_indexed_OP1
@ MULADDv2i32_indexed_OP2
@ MULSUBv4i16_indexed_OP1
@ MULADDv4i32_indexed_OP2
@ MULSUBv8i16_indexed_OP1
@ MULSUBv2i32_indexed_OP2
@ MULADDv8i16_indexed_OP1
@ MULSUBv4i32_indexed_OP1
@ MULADDv8i16_indexed_OP2
@ MULADDv4i16_indexed_OP1
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, StackOffset Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false, bool NeedsWinCFI=false, bool *HasWinCFI=nullptr, bool EmitCFAOffset=false, StackOffset InitialOffset={}, unsigned FrameReg=AArch64::SP)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
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
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.