63#define GET_INSTRINFO_CTOR_DTOR
64#include "AArch64GenInstrInfo.inc"
68 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
72 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
76 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
80 cl::desc(
"Restrict range of B instructions (DEBUG)"));
85 RI(STI.getTargetTriple()), Subtarget(STI) {}
96 auto Op =
MI.getOpcode();
97 if (
Op == AArch64::INLINEASM ||
Op == AArch64::INLINEASM_BR)
98 return getInlineAsmLength(
MI.getOperand(0).getSymbolName(), *MAI);
102 if (
MI.isMetaInstruction())
107 unsigned NumBytes = 0;
113 switch (
Desc.getOpcode()) {
116 return Desc.getSize();
123 case TargetOpcode::STACKMAP:
126 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
128 case TargetOpcode::PATCHPOINT:
131 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
133 case TargetOpcode::STATEPOINT:
135 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
140 case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
145 F.getFnAttributeAsParsedInteger(
"patchable-function-entry", 9) * 4;
147 case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
148 case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
152 case TargetOpcode::PATCHABLE_EVENT_CALL:
158 NumBytes =
MI.getOperand(1).getImm();
160 case TargetOpcode::BUNDLE:
161 NumBytes = getInstBundleLength(
MI);
168unsigned AArch64InstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
172 while (++
I != E &&
I->isInsideBundle()) {
173 assert(!
I->isBundle() &&
"No nested bundle!");
232 int64_t BrOffset)
const {
234 assert(Bits >= 3 &&
"max branch displacement must be enough to jump"
235 "over conditional branch expansion");
236 return isIntN(Bits, BrOffset / 4);
241 switch (
MI.getOpcode()) {
245 return MI.getOperand(0).getMBB();
250 return MI.getOperand(2).getMBB();
256 return MI.getOperand(1).getMBB();
266 assert(RS &&
"RegScavenger required for long branching");
268 "new block should be inserted for expanding unconditional branch");
271 "restore block should be inserted for restoring clobbered registers");
276 if (!isInt<33>(BrOffset))
278 "Branch offsets outside of the signed 33-bit range not supported");
292 constexpr Register Reg = AArch64::X16;
294 insertUnconditionalBranch(
MBB, &NewDestBB,
DL);
302 if (Scavenged != AArch64::NoRegister &&
304 buildIndirectBranch(Scavenged, NewDestBB);
314 "Unable to insert indirect branch inside function that has red zone");
337 bool AllowModify)
const {
344 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
345 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
349 if (!isUnpredicatedTerminator(*
I))
356 unsigned LastOpc = LastInst->
getOpcode();
357 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
372 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
379 LastInst = SecondLastInst;
381 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
386 SecondLastInst = &*
I;
387 SecondLastOpc = SecondLastInst->
getOpcode();
398 LastInst = SecondLastInst;
400 if (
I ==
MBB.
begin() || !isUnpredicatedTerminator(*--
I)) {
402 "unreachable unconditional branches removed above");
411 SecondLastInst = &*
I;
412 SecondLastOpc = SecondLastInst->
getOpcode();
416 if (SecondLastInst &&
I !=
MBB.
begin() && isUnpredicatedTerminator(*--
I))
432 I->eraseFromParent();
441 I->eraseFromParent();
450 MachineBranchPredicate &MBP,
451 bool AllowModify)
const {
461 if (
I->getOpcode() == AArch64::SpeculationBarrierISBDSBEndBB ||
462 I->getOpcode() == AArch64::SpeculationBarrierSBEndBB) {
466 if (!isUnpredicatedTerminator(*
I))
471 unsigned LastOpc = LastInst->
getOpcode();
486 assert(MBP.TrueDest &&
"expected!");
489 MBP.ConditionDef =
nullptr;
490 MBP.SingleUseCondition =
false;
494 MBP.Predicate = LastOpc == AArch64::CBNZX ? MachineBranchPredicate::PRED_NE
495 : MachineBranchPredicate::PRED_EQ;
501 if (
Cond[0].getImm() != -1) {
507 switch (
Cond[1].getImm()) {
511 Cond[1].setImm(AArch64::CBNZW);
514 Cond[1].setImm(AArch64::CBZW);
517 Cond[1].setImm(AArch64::CBNZX);
520 Cond[1].setImm(AArch64::CBZX);
523 Cond[1].setImm(AArch64::TBNZW);
526 Cond[1].setImm(AArch64::TBZW);
529 Cond[1].setImm(AArch64::TBNZX);
532 Cond[1].setImm(AArch64::TBZX);
541 int *BytesRemoved)
const {
551 I->eraseFromParent();
568 I->eraseFromParent();
575void AArch64InstrInfo::instantiateCondBranch(
578 if (
Cond[0].getImm() != -1) {
596 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
635 unsigned *NewVReg =
nullptr) {
640 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(
MRI.getRegClass(VReg));
643 unsigned SrcOpNum = 0;
645 case AArch64::ADDSXri:
646 case AArch64::ADDSWri:
653 case AArch64::ADDXri:
654 case AArch64::ADDWri:
660 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
663 case AArch64::ORNXrr:
664 case AArch64::ORNWrr: {
667 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
670 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
674 case AArch64::SUBSXrr:
675 case AArch64::SUBSWrr:
682 case AArch64::SUBXrr:
683 case AArch64::SUBWrr: {
686 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
689 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
695 assert(Opc && SrcOpNum &&
"Missing parameters");
707 int &FalseCycles)
const {
711 RI.getCommonSubClass(
MRI.getRegClass(TrueReg),
MRI.getRegClass(FalseReg));
718 if (!RI.getCommonSubClass(RC,
MRI.getRegClass(DstReg)))
722 unsigned ExtraCondLat =
Cond.size() != 1;
726 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
727 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
729 CondCycles = 1 + ExtraCondLat;
730 TrueCycles = FalseCycles = 1;
740 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
741 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
742 CondCycles = 5 + ExtraCondLat;
743 TrueCycles = FalseCycles = 2;
760 switch (
Cond.size()) {
769 switch (
Cond[1].getImm()) {
792 MRI.constrainRegClass(SrcReg, &AArch64::GPR64spRegClass);
798 MRI.constrainRegClass(SrcReg, &AArch64::GPR32spRegClass);
808 switch (
Cond[1].getImm()) {
821 if (
Cond[1].getImm() == AArch64::TBZW ||
Cond[1].getImm() == AArch64::TBNZW)
837 bool TryFold =
false;
838 if (
MRI.constrainRegClass(DstReg, &AArch64::GPR64RegClass)) {
839 RC = &AArch64::GPR64RegClass;
840 Opc = AArch64::CSELXr;
842 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::GPR32RegClass)) {
843 RC = &AArch64::GPR32RegClass;
844 Opc = AArch64::CSELWr;
846 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR64RegClass)) {
847 RC = &AArch64::FPR64RegClass;
848 Opc = AArch64::FCSELDrrr;
849 }
else if (
MRI.constrainRegClass(DstReg, &AArch64::FPR32RegClass)) {
850 RC = &AArch64::FPR32RegClass;
851 Opc = AArch64::FCSELSrrr;
853 assert(RC &&
"Unsupported regclass");
857 unsigned NewVReg = 0;
872 MRI.clearKillFlags(NewVReg);
877 MRI.constrainRegClass(TrueReg, RC);
878 MRI.constrainRegClass(FalseReg, RC);
893 assert(BitSize == 64 &&
"Only bit sizes of 32 or 64 allowed");
898 return Is.
size() <= 2;
904 if (Subtarget.hasExynosCheapAsMoveHandling()) {
905 if (isExynosCheapAsMove(
MI))
907 return MI.isAsCheapAsAMove();
910 switch (
MI.getOpcode()) {
912 return MI.isAsCheapAsAMove();
914 case AArch64::ADDWrs:
915 case AArch64::ADDXrs:
916 case AArch64::SUBWrs:
917 case AArch64::SUBXrs:
918 return Subtarget.hasALULSLFast() &&
MI.getOperand(3).getImm() <= 4;
923 case AArch64::MOVi32imm:
925 case AArch64::MOVi64imm:
931 switch (
MI.getOpcode()) {
935 case AArch64::ADDWrs:
936 case AArch64::ADDXrs:
937 case AArch64::ADDSWrs:
938 case AArch64::ADDSXrs: {
939 unsigned Imm =
MI.getOperand(3).getImm();
946 case AArch64::ADDWrx:
947 case AArch64::ADDXrx:
948 case AArch64::ADDXrx64:
949 case AArch64::ADDSWrx:
950 case AArch64::ADDSXrx:
951 case AArch64::ADDSXrx64: {
952 unsigned Imm =
MI.getOperand(3).getImm();
964 case AArch64::SUBWrs:
965 case AArch64::SUBSWrs: {
966 unsigned Imm =
MI.getOperand(3).getImm();
968 return ShiftVal == 0 ||
972 case AArch64::SUBXrs:
973 case AArch64::SUBSXrs: {
974 unsigned Imm =
MI.getOperand(3).getImm();
976 return ShiftVal == 0 ||
980 case AArch64::SUBWrx:
981 case AArch64::SUBXrx:
982 case AArch64::SUBXrx64:
983 case AArch64::SUBSWrx:
984 case AArch64::SUBSXrx:
985 case AArch64::SUBSXrx64: {
986 unsigned Imm =
MI.getOperand(3).getImm();
998 case AArch64::LDRBBroW:
999 case AArch64::LDRBBroX:
1000 case AArch64::LDRBroW:
1001 case AArch64::LDRBroX:
1002 case AArch64::LDRDroW:
1003 case AArch64::LDRDroX:
1004 case AArch64::LDRHHroW:
1005 case AArch64::LDRHHroX:
1006 case AArch64::LDRHroW:
1007 case AArch64::LDRHroX:
1008 case AArch64::LDRQroW:
1009 case AArch64::LDRQroX:
1010 case AArch64::LDRSBWroW:
1011 case AArch64::LDRSBWroX:
1012 case AArch64::LDRSBXroW:
1013 case AArch64::LDRSBXroX:
1014 case AArch64::LDRSHWroW:
1015 case AArch64::LDRSHWroX:
1016 case AArch64::LDRSHXroW:
1017 case AArch64::LDRSHXroX:
1018 case AArch64::LDRSWroW:
1019 case AArch64::LDRSWroX:
1020 case AArch64::LDRSroW:
1021 case AArch64::LDRSroX:
1022 case AArch64::LDRWroW:
1023 case AArch64::LDRWroX:
1024 case AArch64::LDRXroW:
1025 case AArch64::LDRXroX:
1026 case AArch64::PRFMroW:
1027 case AArch64::PRFMroX:
1028 case AArch64::STRBBroW:
1029 case AArch64::STRBBroX:
1030 case AArch64::STRBroW:
1031 case AArch64::STRBroX:
1032 case AArch64::STRDroW:
1033 case AArch64::STRDroX:
1034 case AArch64::STRHHroW:
1035 case AArch64::STRHHroX:
1036 case AArch64::STRHroW:
1037 case AArch64::STRHroX:
1038 case AArch64::STRQroW:
1039 case AArch64::STRQroX:
1040 case AArch64::STRSroW:
1041 case AArch64::STRSroX:
1042 case AArch64::STRWroW:
1043 case AArch64::STRWroX:
1044 case AArch64::STRXroW:
1045 case AArch64::STRXroX: {
1046 unsigned IsSigned =
MI.getOperand(3).getImm();
1053 unsigned Opc =
MI.getOpcode();
1057 case AArch64::SEH_StackAlloc:
1058 case AArch64::SEH_SaveFPLR:
1059 case AArch64::SEH_SaveFPLR_X:
1060 case AArch64::SEH_SaveReg:
1061 case AArch64::SEH_SaveReg_X:
1062 case AArch64::SEH_SaveRegP:
1063 case AArch64::SEH_SaveRegP_X:
1064 case AArch64::SEH_SaveFReg:
1065 case AArch64::SEH_SaveFReg_X:
1066 case AArch64::SEH_SaveFRegP:
1067 case AArch64::SEH_SaveFRegP_X:
1068 case AArch64::SEH_SetFP:
1069 case AArch64::SEH_AddFP:
1070 case AArch64::SEH_Nop:
1071 case AArch64::SEH_PrologEnd:
1072 case AArch64::SEH_EpilogStart:
1073 case AArch64::SEH_EpilogEnd:
1074 case AArch64::SEH_PACSignLR:
1075 case AArch64::SEH_SaveAnyRegQP:
1076 case AArch64::SEH_SaveAnyRegQPX:
1083 unsigned &SubIdx)
const {
1084 switch (
MI.getOpcode()) {
1087 case AArch64::SBFMXri:
1088 case AArch64::UBFMXri:
1091 if (
MI.getOperand(2).getImm() != 0 ||
MI.getOperand(3).getImm() != 31)
1094 SrcReg =
MI.getOperand(1).getReg();
1095 DstReg =
MI.getOperand(0).getReg();
1096 SubIdx = AArch64::sub_32;
1105 int64_t OffsetA = 0, OffsetB = 0;
1106 TypeSize WidthA(0,
false), WidthB(0,
false);
1107 bool OffsetAIsScalable =
false, OffsetBIsScalable =
false;
1128 OffsetAIsScalable == OffsetBIsScalable) {
1129 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1130 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1131 TypeSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1132 if (LowWidth.
isScalable() == OffsetAIsScalable &&
1150 switch (
MI.getOpcode()) {
1153 if (
MI.getOperand(0).getImm() == 0x14)
1160 case AArch64::MSRpstatesvcrImm1:
1167 auto Next = std::next(
MI.getIterator());
1168 return Next !=
MBB->
end() && Next->isCFIInstruction();
1175 Register &SrcReg2, int64_t &CmpMask,
1176 int64_t &CmpValue)
const {
1179 assert(
MI.getNumOperands() >= 2 &&
"All AArch64 cmps should have 2 operands");
1180 if (!
MI.getOperand(1).isReg())
1183 switch (
MI.getOpcode()) {
1186 case AArch64::PTEST_PP:
1187 case AArch64::PTEST_PP_ANY:
1188 SrcReg =
MI.getOperand(0).getReg();
1189 SrcReg2 =
MI.getOperand(1).getReg();
1194 case AArch64::SUBSWrr:
1195 case AArch64::SUBSWrs:
1196 case AArch64::SUBSWrx:
1197 case AArch64::SUBSXrr:
1198 case AArch64::SUBSXrs:
1199 case AArch64::SUBSXrx:
1200 case AArch64::ADDSWrr:
1201 case AArch64::ADDSWrs:
1202 case AArch64::ADDSWrx:
1203 case AArch64::ADDSXrr:
1204 case AArch64::ADDSXrs:
1205 case AArch64::ADDSXrx:
1207 SrcReg =
MI.getOperand(1).getReg();
1208 SrcReg2 =
MI.getOperand(2).getReg();
1212 case AArch64::SUBSWri:
1213 case AArch64::ADDSWri:
1214 case AArch64::SUBSXri:
1215 case AArch64::ADDSXri:
1216 SrcReg =
MI.getOperand(1).getReg();
1219 CmpValue =
MI.getOperand(2).getImm();
1221 case AArch64::ANDSWri:
1222 case AArch64::ANDSXri:
1225 SrcReg =
MI.getOperand(1).getReg();
1229 MI.getOperand(2).getImm(),
1230 MI.getOpcode() == AArch64::ANDSWri ? 32 : 64);
1239 assert(
MBB &&
"Can't get MachineBasicBlock here");
1241 assert(MF &&
"Can't get MachineFunction here");
1246 for (
unsigned OpIdx = 0, EndIdx = Instr.getNumOperands(); OpIdx < EndIdx;
1250 Instr.getRegClassConstraint(OpIdx,
TII,
TRI);
1253 if (!OpRegCstraints)
1261 "Operand has register constraints without being a register!");
1264 if (Reg.isPhysical()) {
1265 if (!OpRegCstraints->
contains(Reg))
1268 !
MRI->constrainRegClass(Reg, OpRegCstraints))
1281 bool MIDefinesZeroReg =
false;
1282 if (
MI.definesRegister(AArch64::WZR,
nullptr) ||
1283 MI.definesRegister(AArch64::XZR,
nullptr))
1284 MIDefinesZeroReg =
true;
1286 switch (
MI.getOpcode()) {
1288 return MI.getOpcode();
1289 case AArch64::ADDSWrr:
1290 return AArch64::ADDWrr;
1291 case AArch64::ADDSWri:
1292 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1293 case AArch64::ADDSWrs:
1294 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1295 case AArch64::ADDSWrx:
1296 return AArch64::ADDWrx;
1297 case AArch64::ADDSXrr:
1298 return AArch64::ADDXrr;
1299 case AArch64::ADDSXri:
1300 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1301 case AArch64::ADDSXrs:
1302 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1303 case AArch64::ADDSXrx:
1304 return AArch64::ADDXrx;
1305 case AArch64::SUBSWrr:
1306 return AArch64::SUBWrr;
1307 case AArch64::SUBSWri:
1308 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1309 case AArch64::SUBSWrs:
1310 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1311 case AArch64::SUBSWrx:
1312 return AArch64::SUBWrx;
1313 case AArch64::SUBSXrr:
1314 return AArch64::SUBXrr;
1315 case AArch64::SUBSXri:
1316 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1317 case AArch64::SUBSXrs:
1318 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1319 case AArch64::SUBSXrx:
1320 return AArch64::SUBXrx;
1335 if (To == To->getParent()->begin())
1340 if (To->getParent() !=
From->getParent())
1352 Instr.modifiesRegister(AArch64::NZCV,
TRI)) ||
1353 ((AccessToCheck &
AK_Read) && Instr.readsRegister(AArch64::NZCV,
TRI)))
1359std::optional<unsigned>
1363 unsigned MaskOpcode =
Mask->getOpcode();
1364 unsigned PredOpcode = Pred->
getOpcode();
1368 if (PredIsWhileLike) {
1372 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1386 if (PredIsPTestLike) {
1391 if ((Mask == Pred) && PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1401 if (Mask == PTestLikeMask || PTest->
getOpcode() == AArch64::PTEST_PP_ANY)
1430 PTest->
getOpcode() == AArch64::PTEST_PP_ANY))
1438 switch (PredOpcode) {
1439 case AArch64::AND_PPzPP:
1440 case AArch64::BIC_PPzPP:
1441 case AArch64::EOR_PPzPP:
1442 case AArch64::NAND_PPzPP:
1443 case AArch64::NOR_PPzPP:
1444 case AArch64::ORN_PPzPP:
1445 case AArch64::ORR_PPzPP:
1446 case AArch64::BRKA_PPzP:
1447 case AArch64::BRKPA_PPzPP:
1448 case AArch64::BRKB_PPzP:
1449 case AArch64::BRKPB_PPzPP:
1450 case AArch64::RDFFR_PPz: {
1454 if (Mask != PredMask)
1458 case AArch64::BRKN_PPzP: {
1462 if ((MaskOpcode != AArch64::PTRUE_B) ||
1463 (
Mask->getOperand(1).getImm() != 31))
1467 case AArch64::PTRUE_B:
1480bool AArch64InstrInfo::optimizePTestInstr(
1481 MachineInstr *PTest,
unsigned MaskReg,
unsigned PredReg,
1483 auto *
Mask =
MRI->getUniqueVRegDef(MaskReg);
1484 auto *Pred =
MRI->getUniqueVRegDef(PredReg);
1485 unsigned PredOpcode = Pred->
getOpcode();
1486 auto NewOp = canRemovePTestInstr(PTest, Mask, Pred,
MRI);
1502 if (*NewOp != PredOpcode) {
1513 for (; i !=
e; ++i) {
1544 if (DeadNZCVIdx != -1) {
1563 if (CmpInstr.
getOpcode() == AArch64::PTEST_PP ||
1564 CmpInstr.
getOpcode() == AArch64::PTEST_PP_ANY)
1565 return optimizePTestInstr(&CmpInstr, SrcReg, SrcReg2,
MRI);
1574 if (CmpValue == 0 && substituteCmpToZero(CmpInstr, SrcReg, *
MRI))
1576 return (CmpValue == 0 || CmpValue == 1) &&
1577 removeCmpToZeroOrOne(CmpInstr, SrcReg, CmpValue, *
MRI);
1585 switch (Instr.getOpcode()) {
1587 return AArch64::INSTRUCTION_LIST_END;
1589 case AArch64::ADDSWrr:
1590 case AArch64::ADDSWri:
1591 case AArch64::ADDSXrr:
1592 case AArch64::ADDSXri:
1593 case AArch64::SUBSWrr:
1594 case AArch64::SUBSWri:
1595 case AArch64::SUBSXrr:
1596 case AArch64::SUBSXri:
1597 return Instr.getOpcode();
1599 case AArch64::ADDWrr:
1600 return AArch64::ADDSWrr;
1601 case AArch64::ADDWri:
1602 return AArch64::ADDSWri;
1603 case AArch64::ADDXrr:
1604 return AArch64::ADDSXrr;
1605 case AArch64::ADDXri:
1606 return AArch64::ADDSXri;
1607 case AArch64::ADCWr:
1608 return AArch64::ADCSWr;
1609 case AArch64::ADCXr:
1610 return AArch64::ADCSXr;
1611 case AArch64::SUBWrr:
1612 return AArch64::SUBSWrr;
1613 case AArch64::SUBWri:
1614 return AArch64::SUBSWri;
1615 case AArch64::SUBXrr:
1616 return AArch64::SUBSXrr;
1617 case AArch64::SUBXri:
1618 return AArch64::SUBSXri;
1619 case AArch64::SBCWr:
1620 return AArch64::SBCSWr;
1621 case AArch64::SBCXr:
1622 return AArch64::SBCSXr;
1623 case AArch64::ANDWri:
1624 return AArch64::ANDSWri;
1625 case AArch64::ANDXri:
1626 return AArch64::ANDSXri;
1633 if (BB->isLiveIn(AArch64::NZCV))
1642 switch (Instr.getOpcode()) {
1646 case AArch64::Bcc: {
1647 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
1652 case AArch64::CSINVWr:
1653 case AArch64::CSINVXr:
1654 case AArch64::CSINCWr:
1655 case AArch64::CSINCXr:
1656 case AArch64::CSELWr:
1657 case AArch64::CSELXr:
1658 case AArch64::CSNEGWr:
1659 case AArch64::CSNEGXr:
1660 case AArch64::FCSELSrrr:
1661 case AArch64::FCSELDrrr: {
1662 int Idx = Instr.findRegisterUseOperandIdx(AArch64::NZCV,
nullptr);
1675 Instr.getOperand(CCIdx).getImm())
1728std::optional<UsedNZCV>
1733 if (
MI.getParent() != CmpParent)
1734 return std::nullopt;
1737 return std::nullopt;
1742 if (Instr.readsRegister(AArch64::NZCV, &
TRI)) {
1745 return std::nullopt;
1750 if (Instr.modifiesRegister(AArch64::NZCV, &
TRI))
1753 return NZCVUsedAfterCmp;
1757 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
1761 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
1783 const unsigned CmpOpcode = CmpInstr.
getOpcode();
1789 "Caller guarantees that CmpInstr compares with constant 0");
1792 if (!NZVCUsed || NZVCUsed->C)
1814bool AArch64InstrInfo::substituteCmpToZero(
1825 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
1832 MI->setDesc(
get(NewOpc));
1837 MI->addRegisterDefined(AArch64::NZCV, &
TRI);
1849 assert((CmpValue == 0 || CmpValue == 1) &&
1850 "Only comparisons to 0 or 1 considered for removal!");
1853 unsigned MIOpc =
MI.getOpcode();
1854 if (MIOpc == AArch64::CSINCWr) {
1855 if (
MI.getOperand(1).getReg() != AArch64::WZR ||
1856 MI.getOperand(2).getReg() != AArch64::WZR)
1858 }
else if (MIOpc == AArch64::CSINCXr) {
1859 if (
MI.getOperand(1).getReg() != AArch64::XZR ||
1860 MI.getOperand(2).getReg() != AArch64::XZR)
1870 if (
MI.findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) != -1)
1874 const unsigned CmpOpcode = CmpInstr.
getOpcode();
1876 if (CmpValue && !IsSubsRegImm)
1878 if (!CmpValue && !IsSubsRegImm && !
isADDSRegImm(CmpOpcode))
1883 if (MIUsedNZCV.
C || MIUsedNZCV.
V)
1886 std::optional<UsedNZCV> NZCVUsedAfterCmp =
1890 if (!NZCVUsedAfterCmp || NZCVUsedAfterCmp->C || NZCVUsedAfterCmp->V)
1893 if ((MIUsedNZCV.
Z && NZCVUsedAfterCmp->N) ||
1894 (MIUsedNZCV.
N && NZCVUsedAfterCmp->Z))
1897 if (MIUsedNZCV.
N && !CmpValue)
1939bool AArch64InstrInfo::removeCmpToZeroOrOne(
1947 bool IsInvertCC =
false;
1957 assert(
Idx >= 0 &&
"Unexpected instruction using CC.");
1968 if (
MI.getOpcode() != TargetOpcode::LOAD_STACK_GUARD &&
1969 MI.getOpcode() != AArch64::CATCHRET)
1977 if (
MI.getOpcode() == AArch64::CATCHRET) {
1986 FirstEpilogSEH = std::prev(FirstEpilogSEH);
1988 FirstEpilogSEH = std::next(FirstEpilogSEH);
2002 if (M.getStackProtectorGuard() ==
"sysreg") {
2012 int Offset = M.getStackProtectorGuardOffset();
2064 cast<GlobalValue>((*
MI.memoperands_begin())->getValue());
2073 unsigned Reg32 =
TRI->getSubReg(Reg, AArch64::sub_32);
2115 unsigned Reg32 =
TRI->getSubReg(Reg, AArch64::sub_32);
2138 switch (
MI.getOpcode()) {
2141 case AArch64::MOVZWi:
2142 case AArch64::MOVZXi:
2143 if (
MI.getOperand(1).isImm() &&
MI.getOperand(1).getImm() == 0) {
2144 assert(
MI.getDesc().getNumOperands() == 3 &&
2145 MI.getOperand(2).getImm() == 0 &&
"invalid MOVZi operands");
2149 case AArch64::ANDWri:
2150 return MI.getOperand(1).getReg() == AArch64::WZR;
2151 case AArch64::ANDXri:
2152 return MI.getOperand(1).getReg() == AArch64::XZR;
2153 case TargetOpcode::COPY:
2154 return MI.getOperand(1).getReg() == AArch64::WZR;
2162 switch (
MI.getOpcode()) {
2165 case TargetOpcode::COPY: {
2168 return (AArch64::GPR32RegClass.
contains(DstReg) ||
2169 AArch64::GPR64RegClass.
contains(DstReg));
2171 case AArch64::ORRXrs:
2172 if (
MI.getOperand(1).getReg() == AArch64::XZR) {
2173 assert(
MI.getDesc().getNumOperands() == 4 &&
2174 MI.getOperand(3).getImm() == 0 &&
"invalid ORRrs operands");
2178 case AArch64::ADDXri:
2179 if (
MI.getOperand(2).getImm() == 0) {
2180 assert(
MI.getDesc().getNumOperands() == 4 &&
2181 MI.getOperand(3).getImm() == 0 &&
"invalid ADDXri operands");
2192 switch (
MI.getOpcode()) {
2195 case TargetOpcode::COPY: {
2197 return AArch64::FPR128RegClass.contains(DstReg);
2199 case AArch64::ORRv16i8:
2200 if (
MI.getOperand(1).getReg() ==
MI.getOperand(2).getReg()) {
2201 assert(
MI.getDesc().getNumOperands() == 3 &&
MI.getOperand(0).isReg() &&
2202 "invalid ORRv16i8 operands");
2211 int &FrameIndex)
const {
2212 switch (
MI.getOpcode()) {
2215 case AArch64::LDRWui:
2216 case AArch64::LDRXui:
2217 case AArch64::LDRBui:
2218 case AArch64::LDRHui:
2219 case AArch64::LDRSui:
2220 case AArch64::LDRDui:
2221 case AArch64::LDRQui:
2222 case AArch64::LDR_PXI:
2223 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2224 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2225 FrameIndex =
MI.getOperand(1).getIndex();
2226 return MI.getOperand(0).getReg();
2235 int &FrameIndex)
const {
2236 switch (
MI.getOpcode()) {
2239 case AArch64::STRWui:
2240 case AArch64::STRXui:
2241 case AArch64::STRBui:
2242 case AArch64::STRHui:
2243 case AArch64::STRSui:
2244 case AArch64::STRDui:
2245 case AArch64::STRQui:
2246 case AArch64::STR_PXI:
2247 if (
MI.getOperand(0).getSubReg() == 0 &&
MI.getOperand(1).isFI() &&
2248 MI.getOperand(2).isImm() &&
MI.getOperand(2).getImm() == 0) {
2249 FrameIndex =
MI.getOperand(1).getIndex();
2250 return MI.getOperand(0).getReg();
2260 return MMO->getFlags() & MOSuppressPair;
2266 if (
MI.memoperands_empty())
2274 return MMO->getFlags() & MOStridedAccess;
2282 case AArch64::STURSi:
2283 case AArch64::STRSpre:
2284 case AArch64::STURDi:
2285 case AArch64::STRDpre:
2286 case AArch64::STURQi:
2287 case AArch64::STRQpre:
2288 case AArch64::STURBBi:
2289 case AArch64::STURHHi:
2290 case AArch64::STURWi:
2291 case AArch64::STRWpre:
2292 case AArch64::STURXi:
2293 case AArch64::STRXpre:
2294 case AArch64::LDURSi:
2295 case AArch64::LDRSpre:
2296 case AArch64::LDURDi:
2297 case AArch64::LDRDpre:
2298 case AArch64::LDURQi:
2299 case AArch64::LDRQpre:
2300 case AArch64::LDURWi:
2301 case AArch64::LDRWpre:
2302 case AArch64::LDURXi:
2303 case AArch64::LDRXpre:
2304 case AArch64::LDRSWpre:
2305 case AArch64::LDURSWi:
2306 case AArch64::LDURHHi:
2307 case AArch64::LDURBBi:
2308 case AArch64::LDURSBWi:
2309 case AArch64::LDURSHWi:
2317 case AArch64::PRFMui:
return AArch64::PRFUMi;
2318 case AArch64::LDRXui:
return AArch64::LDURXi;
2319 case AArch64::LDRWui:
return AArch64::LDURWi;
2320 case AArch64::LDRBui:
return AArch64::LDURBi;
2321 case AArch64::LDRHui:
return AArch64::LDURHi;
2322 case AArch64::LDRSui:
return AArch64::LDURSi;
2323 case AArch64::LDRDui:
return AArch64::LDURDi;
2324 case AArch64::LDRQui:
return AArch64::LDURQi;
2325 case AArch64::LDRBBui:
return AArch64::LDURBBi;
2326 case AArch64::LDRHHui:
return AArch64::LDURHHi;
2327 case AArch64::LDRSBXui:
return AArch64::LDURSBXi;
2328 case AArch64::LDRSBWui:
return AArch64::LDURSBWi;
2329 case AArch64::LDRSHXui:
return AArch64::LDURSHXi;
2330 case AArch64::LDRSHWui:
return AArch64::LDURSHWi;
2331 case AArch64::LDRSWui:
return AArch64::LDURSWi;
2332 case AArch64::STRXui:
return AArch64::STURXi;
2333 case AArch64::STRWui:
return AArch64::STURWi;
2334 case AArch64::STRBui:
return AArch64::STURBi;
2335 case AArch64::STRHui:
return AArch64::STURHi;
2336 case AArch64::STRSui:
return AArch64::STURSi;
2337 case AArch64::STRDui:
return AArch64::STURDi;
2338 case AArch64::STRQui:
return AArch64::STURQi;
2339 case AArch64::STRBBui:
return AArch64::STURBBi;
2340 case AArch64::STRHHui:
return AArch64::STURHHi;
2349 case AArch64::LDAPURBi:
2350 case AArch64::LDAPURHi:
2351 case AArch64::LDAPURi:
2352 case AArch64::LDAPURSBWi:
2353 case AArch64::LDAPURSBXi:
2354 case AArch64::LDAPURSHWi:
2355 case AArch64::LDAPURSHXi:
2356 case AArch64::LDAPURSWi:
2357 case AArch64::LDAPURXi:
2358 case AArch64::LDR_PPXI:
2359 case AArch64::LDR_PXI:
2360 case AArch64::LDR_ZXI:
2361 case AArch64::LDR_ZZXI:
2362 case AArch64::LDR_ZZZXI:
2363 case AArch64::LDR_ZZZZXI:
2364 case AArch64::LDRBBui:
2365 case AArch64::LDRBui:
2366 case AArch64::LDRDui:
2367 case AArch64::LDRHHui:
2368 case AArch64::LDRHui:
2369 case AArch64::LDRQui:
2370 case AArch64::LDRSBWui:
2371 case AArch64::LDRSBXui:
2372 case AArch64::LDRSHWui:
2373 case AArch64::LDRSHXui:
2374 case AArch64::LDRSui:
2375 case AArch64::LDRSWui:
2376 case AArch64::LDRWui:
2377 case AArch64::LDRXui:
2378 case AArch64::LDURBBi:
2379 case AArch64::LDURBi:
2380 case AArch64::LDURDi:
2381 case AArch64::LDURHHi:
2382 case AArch64::LDURHi:
2383 case AArch64::LDURQi:
2384 case AArch64::LDURSBWi:
2385 case AArch64::LDURSBXi:
2386 case AArch64::LDURSHWi:
2387 case AArch64::LDURSHXi:
2388 case AArch64::LDURSi:
2389 case AArch64::LDURSWi:
2390 case AArch64::LDURWi:
2391 case AArch64::LDURXi:
2392 case AArch64::PRFMui:
2393 case AArch64::PRFUMi:
2394 case AArch64::ST2Gi:
2396 case AArch64::STLURBi:
2397 case AArch64::STLURHi:
2398 case AArch64::STLURWi:
2399 case AArch64::STLURXi:
2400 case AArch64::StoreSwiftAsyncContext:
2401 case AArch64::STR_PPXI:
2402 case AArch64::STR_PXI:
2403 case AArch64::STR_ZXI:
2404 case AArch64::STR_ZZXI:
2405 case AArch64::STR_ZZZXI:
2406 case AArch64::STR_ZZZZXI:
2407 case AArch64::STRBBui:
2408 case AArch64::STRBui:
2409 case AArch64::STRDui:
2410 case AArch64::STRHHui:
2411 case AArch64::STRHui:
2412 case AArch64::STRQui:
2413 case AArch64::STRSui:
2414 case AArch64::STRWui:
2415 case AArch64::STRXui:
2416 case AArch64::STURBBi:
2417 case AArch64::STURBi:
2418 case AArch64::STURDi:
2419 case AArch64::STURHHi:
2420 case AArch64::STURHi:
2421 case AArch64::STURQi:
2422 case AArch64::STURSi:
2423 case AArch64::STURWi:
2424 case AArch64::STURXi:
2425 case AArch64::STZ2Gi:
2426 case AArch64::STZGi:
2427 case AArch64::TAGPstack:
2429 case AArch64::LD1B_D_IMM:
2430 case AArch64::LD1B_H_IMM:
2431 case AArch64::LD1B_IMM:
2432 case AArch64::LD1B_S_IMM:
2433 case AArch64::LD1D_IMM:
2434 case AArch64::LD1H_D_IMM:
2435 case AArch64::LD1H_IMM:
2436 case AArch64::LD1H_S_IMM:
2437 case AArch64::LD1RB_D_IMM:
2438 case AArch64::LD1RB_H_IMM:
2439 case AArch64::LD1RB_IMM:
2440 case AArch64::LD1RB_S_IMM:
2441 case AArch64::LD1RD_IMM:
2442 case AArch64::LD1RH_D_IMM:
2443 case AArch64::LD1RH_IMM:
2444 case AArch64::LD1RH_S_IMM:
2445 case AArch64::LD1RSB_D_IMM:
2446 case AArch64::LD1RSB_H_IMM:
2447 case AArch64::LD1RSB_S_IMM:
2448 case AArch64::LD1RSH_D_IMM:
2449 case AArch64::LD1RSH_S_IMM:
2450 case AArch64::LD1RSW_IMM:
2451 case AArch64::LD1RW_D_IMM:
2452 case AArch64::LD1RW_IMM:
2453 case AArch64::LD1SB_D_IMM:
2454 case AArch64::LD1SB_H_IMM:
2455 case AArch64::LD1SB_S_IMM:
2456 case AArch64::LD1SH_D_IMM:
2457 case AArch64::LD1SH_S_IMM:
2458 case AArch64::LD1SW_D_IMM:
2459 case AArch64::LD1W_D_IMM:
2460 case AArch64::LD1W_IMM:
2461 case AArch64::LD2B_IMM:
2462 case AArch64::LD2D_IMM:
2463 case AArch64::LD2H_IMM:
2464 case AArch64::LD2W_IMM:
2465 case AArch64::LD3B_IMM:
2466 case AArch64::LD3D_IMM:
2467 case AArch64::LD3H_IMM:
2468 case AArch64::LD3W_IMM:
2469 case AArch64::LD4B_IMM:
2470 case AArch64::LD4D_IMM:
2471 case AArch64::LD4H_IMM:
2472 case AArch64::LD4W_IMM:
2474 case AArch64::LDNF1B_D_IMM:
2475 case AArch64::LDNF1B_H_IMM:
2476 case AArch64::LDNF1B_IMM:
2477 case AArch64::LDNF1B_S_IMM:
2478 case AArch64::LDNF1D_IMM:
2479 case AArch64::LDNF1H_D_IMM:
2480 case AArch64::LDNF1H_IMM:
2481 case AArch64::LDNF1H_S_IMM:
2482 case AArch64::LDNF1SB_D_IMM:
2483 case AArch64::LDNF1SB_H_IMM:
2484 case AArch64::LDNF1SB_S_IMM:
2485 case AArch64::LDNF1SH_D_IMM:
2486 case AArch64::LDNF1SH_S_IMM:
2487 case AArch64::LDNF1SW_D_IMM:
2488 case AArch64::LDNF1W_D_IMM:
2489 case AArch64::LDNF1W_IMM:
2490 case AArch64::LDNPDi:
2491 case AArch64::LDNPQi:
2492 case AArch64::LDNPSi:
2493 case AArch64::LDNPWi:
2494 case AArch64::LDNPXi:
2495 case AArch64::LDNT1B_ZRI:
2496 case AArch64::LDNT1D_ZRI:
2497 case AArch64::LDNT1H_ZRI:
2498 case AArch64::LDNT1W_ZRI:
2499 case AArch64::LDPDi:
2500 case AArch64::LDPQi:
2501 case AArch64::LDPSi:
2502 case AArch64::LDPWi:
2503 case AArch64::LDPXi:
2504 case AArch64::LDRBBpost:
2505 case AArch64::LDRBBpre:
2506 case AArch64::LDRBpost:
2507 case AArch64::LDRBpre:
2508 case AArch64::LDRDpost:
2509 case AArch64::LDRDpre:
2510 case AArch64::LDRHHpost:
2511 case AArch64::LDRHHpre:
2512 case AArch64::LDRHpost:
2513 case AArch64::LDRHpre:
2514 case AArch64::LDRQpost:
2515 case AArch64::LDRQpre:
2516 case AArch64::LDRSpost:
2517 case AArch64::LDRSpre:
2518 case AArch64::LDRWpost:
2519 case AArch64::LDRWpre:
2520 case AArch64::LDRXpost:
2521 case AArch64::LDRXpre:
2522 case AArch64::ST1B_D_IMM:
2523 case AArch64::ST1B_H_IMM:
2524 case AArch64::ST1B_IMM:
2525 case AArch64::ST1B_S_IMM:
2526 case AArch64::ST1D_IMM:
2527 case AArch64::ST1H_D_IMM:
2528 case AArch64::ST1H_IMM:
2529 case AArch64::ST1H_S_IMM:
2530 case AArch64::ST1W_D_IMM:
2531 case AArch64::ST1W_IMM:
2532 case AArch64::ST2B_IMM:
2533 case AArch64::ST2D_IMM:
2534 case AArch64::ST2H_IMM:
2535 case AArch64::ST2W_IMM:
2536 case AArch64::ST3B_IMM:
2537 case AArch64::ST3D_IMM:
2538 case AArch64::ST3H_IMM:
2539 case AArch64::ST3W_IMM:
2540 case AArch64::ST4B_IMM:
2541 case AArch64::ST4D_IMM:
2542 case AArch64::ST4H_IMM:
2543 case AArch64::ST4W_IMM:
2544 case AArch64::STGPi:
2545 case AArch64::STNPDi:
2546 case AArch64::STNPQi:
2547 case AArch64::STNPSi:
2548 case AArch64::STNPWi:
2549 case AArch64::STNPXi:
2550 case AArch64::STNT1B_ZRI:
2551 case AArch64::STNT1D_ZRI:
2552 case AArch64::STNT1H_ZRI:
2553 case AArch64::STNT1W_ZRI:
2554 case AArch64::STPDi:
2555 case AArch64::STPQi:
2556 case AArch64::STPSi:
2557 case AArch64::STPWi:
2558 case AArch64::STPXi:
2559 case AArch64::STRBBpost:
2560 case AArch64::STRBBpre:
2561 case AArch64::STRBpost:
2562 case AArch64::STRBpre:
2563 case AArch64::STRDpost:
2564 case AArch64::STRDpre:
2565 case AArch64::STRHHpost:
2566 case AArch64::STRHHpre:
2567 case AArch64::STRHpost:
2568 case AArch64::STRHpre:
2569 case AArch64::STRQpost:
2570 case AArch64::STRQpre:
2571 case AArch64::STRSpost:
2572 case AArch64::STRSpre:
2573 case AArch64::STRWpost:
2574 case AArch64::STRWpre:
2575 case AArch64::STRXpost:
2576 case AArch64::STRXpre:
2578 case AArch64::LDPDpost:
2579 case AArch64::LDPDpre:
2580 case AArch64::LDPQpost:
2581 case AArch64::LDPQpre:
2582 case AArch64::LDPSpost:
2583 case AArch64::LDPSpre:
2584 case AArch64::LDPWpost:
2585 case AArch64::LDPWpre:
2586 case AArch64::LDPXpost:
2587 case AArch64::LDPXpre:
2588 case AArch64::STPDpost:
2589 case AArch64::STPDpre:
2590 case AArch64::STPQpost:
2591 case AArch64::STPQpre:
2592 case AArch64::STPSpost:
2593 case AArch64::STPSpre:
2594 case AArch64::STPWpost:
2595 case AArch64::STPWpre:
2596 case AArch64::STPXpost:
2597 case AArch64::STPXpre:
2603 switch (
MI.getOpcode()) {
2607 case AArch64::STRSui:
2608 case AArch64::STRDui:
2609 case AArch64::STRQui:
2610 case AArch64::STRXui:
2611 case AArch64::STRWui:
2612 case AArch64::LDRSui:
2613 case AArch64::LDRDui:
2614 case AArch64::LDRQui:
2615 case AArch64::LDRXui:
2616 case AArch64::LDRWui:
2617 case AArch64::LDRSWui:
2619 case AArch64::STURSi:
2620 case AArch64::STRSpre:
2621 case AArch64::STURDi:
2622 case AArch64::STRDpre:
2623 case AArch64::STURQi:
2624 case AArch64::STRQpre:
2625 case AArch64::STURWi:
2626 case AArch64::STRWpre:
2627 case AArch64::STURXi:
2628 case AArch64::STRXpre:
2629 case AArch64::LDURSi:
2630 case AArch64::LDRSpre:
2631 case AArch64::LDURDi:
2632 case AArch64::LDRDpre:
2633 case AArch64::LDURQi:
2634 case AArch64::LDRQpre:
2635 case AArch64::LDURWi:
2636 case AArch64::LDRWpre:
2637 case AArch64::LDURXi:
2638 case AArch64::LDRXpre:
2639 case AArch64::LDURSWi:
2640 case AArch64::LDRSWpre:
2646 switch (
MI.getOpcode()) {
2649 "Unexpected instruction - was a new tail call opcode introduced?");
2651 case AArch64::TCRETURNdi:
2652 case AArch64::TCRETURNri:
2653 case AArch64::TCRETURNrix16x17:
2654 case AArch64::TCRETURNrix17:
2655 case AArch64::TCRETURNrinotx16:
2656 case AArch64::TCRETURNriALL:
2657 case AArch64::AUTH_TCRETURN:
2658 case AArch64::AUTH_TCRETURN_BTI:
2668 case AArch64::ADDWri:
2669 return AArch64::ADDSWri;
2670 case AArch64::ADDWrr:
2671 return AArch64::ADDSWrr;
2672 case AArch64::ADDWrs:
2673 return AArch64::ADDSWrs;
2674 case AArch64::ADDWrx:
2675 return AArch64::ADDSWrx;
2676 case AArch64::ANDWri:
2677 return AArch64::ANDSWri;
2678 case AArch64::ANDWrr:
2679 return AArch64::ANDSWrr;
2680 case AArch64::ANDWrs:
2681 return AArch64::ANDSWrs;
2682 case AArch64::BICWrr:
2683 return AArch64::BICSWrr;
2684 case AArch64::BICWrs:
2685 return AArch64::BICSWrs;
2686 case AArch64::SUBWri:
2687 return AArch64::SUBSWri;
2688 case AArch64::SUBWrr:
2689 return AArch64::SUBSWrr;
2690 case AArch64::SUBWrs:
2691 return AArch64::SUBSWrs;
2692 case AArch64::SUBWrx:
2693 return AArch64::SUBSWrx;
2695 case AArch64::ADDXri:
2696 return AArch64::ADDSXri;
2697 case AArch64::ADDXrr:
2698 return AArch64::ADDSXrr;
2699 case AArch64::ADDXrs:
2700 return AArch64::ADDSXrs;
2701 case AArch64::ADDXrx:
2702 return AArch64::ADDSXrx;
2703 case AArch64::ANDXri:
2704 return AArch64::ANDSXri;
2705 case AArch64::ANDXrr:
2706 return AArch64::ANDSXrr;
2707 case AArch64::ANDXrs:
2708 return AArch64::ANDSXrs;
2709 case AArch64::BICXrr:
2710 return AArch64::BICSXrr;
2711 case AArch64::BICXrs:
2712 return AArch64::BICSXrs;
2713 case AArch64::SUBXri:
2714 return AArch64::SUBSXri;
2715 case AArch64::SUBXrr:
2716 return AArch64::SUBSXrr;
2717 case AArch64::SUBXrs:
2718 return AArch64::SUBSXrs;
2719 case AArch64::SUBXrx:
2720 return AArch64::SUBSXrx;
2722 case AArch64::AND_PPzPP:
2723 return AArch64::ANDS_PPzPP;
2724 case AArch64::BIC_PPzPP:
2725 return AArch64::BICS_PPzPP;
2726 case AArch64::EOR_PPzPP:
2727 return AArch64::EORS_PPzPP;
2728 case AArch64::NAND_PPzPP:
2729 return AArch64::NANDS_PPzPP;
2730 case AArch64::NOR_PPzPP:
2731 return AArch64::NORS_PPzPP;
2732 case AArch64::ORN_PPzPP:
2733 return AArch64::ORNS_PPzPP;
2734 case AArch64::ORR_PPzPP:
2735 return AArch64::ORRS_PPzPP;
2736 case AArch64::BRKA_PPzP:
2737 return AArch64::BRKAS_PPzP;
2738 case AArch64::BRKPA_PPzPP:
2739 return AArch64::BRKPAS_PPzPP;
2740 case AArch64::BRKB_PPzP:
2741 return AArch64::BRKBS_PPzP;
2742 case AArch64::BRKPB_PPzPP:
2743 return AArch64::BRKPBS_PPzPP;
2744 case AArch64::BRKN_PPzP:
2745 return AArch64::BRKNS_PPzP;
2746 case AArch64::RDFFR_PPz:
2747 return AArch64::RDFFRS_PPz;
2748 case AArch64::PTRUE_B:
2749 return AArch64::PTRUES_B;
2760 if (
MI.hasOrderedMemoryRef())
2765 assert((
MI.getOperand(IsPreLdSt ? 2 : 1).isReg() ||
2766 MI.getOperand(IsPreLdSt ? 2 : 1).isFI()) &&
2767 "Expected a reg or frame index operand.");
2771 bool IsImmPreLdSt = IsPreLdSt &&
MI.getOperand(3).isImm();
2773 if (!
MI.getOperand(2).isImm() && !IsImmPreLdSt)
2786 if (
MI.getOperand(1).isReg() && !IsPreLdSt) {
2787 Register BaseReg =
MI.getOperand(1).getReg();
2789 if (
MI.modifiesRegister(BaseReg,
TRI))
2802 const MCAsmInfo *MAI =
MI.getMF()->getTarget().getMCAsmInfo();
2804 MI.getMF()->getFunction().needsUnwindTableEntry();
2810 if (Subtarget.isPaired128Slow()) {
2811 switch (
MI.getOpcode()) {
2814 case AArch64::LDURQi:
2815 case AArch64::STURQi:
2816 case AArch64::LDRQui:
2817 case AArch64::STRQui:
2844std::optional<ExtAddrMode>
2849 bool OffsetIsScalable;
2850 if (!getMemOperandWithOffset(MemI,
Base,
Offset, OffsetIsScalable,
TRI))
2851 return std::nullopt;
2854 return std::nullopt;
2869 int64_t OffsetScale = 1;
2874 case AArch64::LDURQi:
2875 case AArch64::STURQi:
2879 case AArch64::LDURDi:
2880 case AArch64::STURDi:
2881 case AArch64::LDURXi:
2882 case AArch64::STURXi:
2886 case AArch64::LDURWi:
2887 case AArch64::LDURSWi:
2888 case AArch64::STURWi:
2892 case AArch64::LDURHi:
2893 case AArch64::STURHi:
2894 case AArch64::LDURHHi:
2895 case AArch64::STURHHi:
2896 case AArch64::LDURSHXi:
2897 case AArch64::LDURSHWi:
2901 case AArch64::LDRBroX:
2902 case AArch64::LDRBBroX:
2903 case AArch64::LDRSBXroX:
2904 case AArch64::LDRSBWroX:
2905 case AArch64::STRBroX:
2906 case AArch64::STRBBroX:
2907 case AArch64::LDURBi:
2908 case AArch64::LDURBBi:
2909 case AArch64::LDURSBXi:
2910 case AArch64::LDURSBWi:
2911 case AArch64::STURBi:
2912 case AArch64::STURBBi:
2913 case AArch64::LDRBui:
2914 case AArch64::LDRBBui:
2915 case AArch64::LDRSBXui:
2916 case AArch64::LDRSBWui:
2917 case AArch64::STRBui:
2918 case AArch64::STRBBui:
2922 case AArch64::LDRQroX:
2923 case AArch64::STRQroX:
2924 case AArch64::LDRQui:
2925 case AArch64::STRQui:
2930 case AArch64::LDRDroX:
2931 case AArch64::STRDroX:
2932 case AArch64::LDRXroX:
2933 case AArch64::STRXroX:
2934 case AArch64::LDRDui:
2935 case AArch64::STRDui:
2936 case AArch64::LDRXui:
2937 case AArch64::STRXui:
2942 case AArch64::LDRWroX:
2943 case AArch64::LDRSWroX:
2944 case AArch64::STRWroX:
2945 case AArch64::LDRWui:
2946 case AArch64::LDRSWui:
2947 case AArch64::STRWui:
2952 case AArch64::LDRHroX:
2953 case AArch64::STRHroX:
2954 case AArch64::LDRHHroX:
2955 case AArch64::STRHHroX:
2956 case AArch64::LDRSHXroX:
2957 case AArch64::LDRSHWroX:
2958 case AArch64::LDRHui:
2959 case AArch64::STRHui:
2960 case AArch64::LDRHHui:
2961 case AArch64::STRHHui:
2962 case AArch64::LDRSHXui:
2963 case AArch64::LDRSHWui:
2971 if (BaseRegOp.
isReg() && BaseRegOp.
getReg() == Reg)
2995 case AArch64::SBFMXri:
3008 AM.
Scale = OffsetScale;
3013 case TargetOpcode::SUBREG_TO_REG: {
3026 if (!OffsetReg.
isVirtual() || !
MRI.hasOneNonDBGUse(OffsetReg))
3030 if (
DefMI.getOpcode() != AArch64::ORRWrs ||
3032 DefMI.getOperand(3).getImm() != 0)
3039 AM.
Scale = OffsetScale;
3050 auto validateOffsetForLDP = [](
unsigned NumBytes, int64_t OldOffset,
3051 int64_t NewOffset) ->
bool {
3052 int64_t MinOffset, MaxOffset;
3069 return OldOffset < MinOffset || OldOffset > MaxOffset ||
3070 (NewOffset >= MinOffset && NewOffset <= MaxOffset);
3072 auto canFoldAddSubImmIntoAddrMode = [&](int64_t Disp) ->
bool {
3074 int64_t NewOffset = OldOffset + Disp;
3079 if (!validateOffsetForLDP(NumBytes, OldOffset, NewOffset))
3089 auto canFoldAddRegIntoAddrMode =
3106 return (Opcode == AArch64::STURQi || Opcode == AArch64::STRQui) &&
3107 Subtarget.isSTRQroSlow();
3116 case AArch64::ADDXri:
3122 return canFoldAddSubImmIntoAddrMode(Disp);
3124 case AArch64::SUBXri:
3130 return canFoldAddSubImmIntoAddrMode(-Disp);
3132 case AArch64::ADDXrs: {
3145 if (Shift != 2 && Shift != 3 && Subtarget.hasAddrLSLSlow14())
3147 if (avoidSlowSTRQ(MemI))
3150 return canFoldAddRegIntoAddrMode(1ULL << Shift);
3153 case AArch64::ADDXrr:
3161 if (!OptSize && avoidSlowSTRQ(MemI))
3163 return canFoldAddRegIntoAddrMode(1);
3165 case AArch64::ADDXrx:
3173 if (!OptSize && avoidSlowSTRQ(MemI))
3182 return canFoldAddRegIntoAddrMode(
3197 case AArch64::LDURQi:
3198 case AArch64::LDRQui:
3199 return AArch64::LDRQroX;
3200 case AArch64::STURQi:
3201 case AArch64::STRQui:
3202 return AArch64::STRQroX;
3203 case AArch64::LDURDi:
3204 case AArch64::LDRDui:
3205 return AArch64::LDRDroX;
3206 case AArch64::STURDi:
3207 case AArch64::STRDui:
3208 return AArch64::STRDroX;
3209 case AArch64::LDURXi:
3210 case AArch64::LDRXui:
3211 return AArch64::LDRXroX;
3212 case AArch64::STURXi:
3213 case AArch64::STRXui:
3214 return AArch64::STRXroX;
3215 case AArch64::LDURWi:
3216 case AArch64::LDRWui:
3217 return AArch64::LDRWroX;
3218 case AArch64::LDURSWi:
3219 case AArch64::LDRSWui:
3220 return AArch64::LDRSWroX;
3221 case AArch64::STURWi:
3222 case AArch64::STRWui:
3223 return AArch64::STRWroX;
3224 case AArch64::LDURHi:
3225 case AArch64::LDRHui:
3226 return AArch64::LDRHroX;
3227 case AArch64::STURHi:
3228 case AArch64::STRHui:
3229 return AArch64::STRHroX;
3230 case AArch64::LDURHHi:
3231 case AArch64::LDRHHui:
3232 return AArch64::LDRHHroX;
3233 case AArch64::STURHHi:
3234 case AArch64::STRHHui:
3235 return AArch64::STRHHroX;
3236 case AArch64::LDURSHXi:
3237 case AArch64::LDRSHXui:
3238 return AArch64::LDRSHXroX;
3239 case AArch64::LDURSHWi:
3240 case AArch64::LDRSHWui:
3241 return AArch64::LDRSHWroX;
3242 case AArch64::LDURBi:
3243 case AArch64::LDRBui:
3244 return AArch64::LDRBroX;
3245 case AArch64::LDURBBi:
3246 case AArch64::LDRBBui:
3247 return AArch64::LDRBBroX;
3248 case AArch64::LDURSBXi:
3249 case AArch64::LDRSBXui:
3250 return AArch64::LDRSBXroX;
3251 case AArch64::LDURSBWi:
3252 case AArch64::LDRSBWui:
3253 return AArch64::LDRSBWroX;
3254 case AArch64::STURBi:
3255 case AArch64::STRBui:
3256 return AArch64::STRBroX;
3257 case AArch64::STURBBi:
3258 case AArch64::STRBBui:
3259 return AArch64::STRBBroX;
3271 case AArch64::LDURQi:
3273 return AArch64::LDRQui;
3274 case AArch64::STURQi:
3276 return AArch64::STRQui;
3277 case AArch64::LDURDi:
3279 return AArch64::LDRDui;
3280 case AArch64::STURDi:
3282 return AArch64::STRDui;
3283 case AArch64::LDURXi:
3285 return AArch64::LDRXui;
3286 case AArch64::STURXi:
3288 return AArch64::STRXui;
3289 case AArch64::LDURWi:
3291 return AArch64::LDRWui;
3292 case AArch64::LDURSWi:
3294 return AArch64::LDRSWui;
3295 case AArch64::STURWi:
3297 return AArch64::STRWui;
3298 case AArch64::LDURHi:
3300 return AArch64::LDRHui;
3301 case AArch64::STURHi:
3303 return AArch64::STRHui;
3304 case AArch64::LDURHHi:
3306 return AArch64::LDRHHui;
3307 case AArch64::STURHHi:
3309 return AArch64::STRHHui;
3310 case AArch64::LDURSHXi:
3312 return AArch64::LDRSHXui;
3313 case AArch64::LDURSHWi:
3315 return AArch64::LDRSHWui;
3316 case AArch64::LDURBi:
3318 return AArch64::LDRBui;
3319 case AArch64::LDURBBi:
3321 return AArch64::LDRBBui;
3322 case AArch64::LDURSBXi:
3324 return AArch64::LDRSBXui;
3325 case AArch64::LDURSBWi:
3327 return AArch64::LDRSBWui;
3328 case AArch64::STURBi:
3330 return AArch64::STRBui;
3331 case AArch64::STURBBi:
3333 return AArch64::STRBBui;
3334 case AArch64::LDRQui:
3335 case AArch64::STRQui:
3338 case AArch64::LDRDui:
3339 case AArch64::STRDui:
3340 case AArch64::LDRXui:
3341 case AArch64::STRXui:
3344 case AArch64::LDRWui:
3345 case AArch64::LDRSWui:
3346 case AArch64::STRWui:
3349 case AArch64::LDRHui:
3350 case AArch64::STRHui:
3351 case AArch64::LDRHHui:
3352 case AArch64::STRHHui:
3353 case AArch64::LDRSHXui:
3354 case AArch64::LDRSHWui:
3357 case AArch64::LDRBui:
3358 case AArch64::LDRBBui:
3359 case AArch64::LDRSBXui:
3360 case AArch64::LDRSBWui:
3361 case AArch64::STRBui:
3362 case AArch64::STRBBui:
3376 case AArch64::LDURQi:
3377 case AArch64::STURQi:
3378 case AArch64::LDURDi:
3379 case AArch64::STURDi:
3380 case AArch64::LDURXi:
3381 case AArch64::STURXi:
3382 case AArch64::LDURWi:
3383 case AArch64::LDURSWi:
3384 case AArch64::STURWi:
3385 case AArch64::LDURHi:
3386 case AArch64::STURHi:
3387 case AArch64::LDURHHi:
3388 case AArch64::STURHHi:
3389 case AArch64::LDURSHXi:
3390 case AArch64::LDURSHWi:
3391 case AArch64::LDURBi:
3392 case AArch64::STURBi:
3393 case AArch64::LDURBBi:
3394 case AArch64::STURBBi:
3395 case AArch64::LDURSBWi:
3396 case AArch64::LDURSBXi:
3398 case AArch64::LDRQui:
3399 return AArch64::LDURQi;
3400 case AArch64::STRQui:
3401 return AArch64::STURQi;
3402 case AArch64::LDRDui:
3403 return AArch64::LDURDi;
3404 case AArch64::STRDui:
3405 return AArch64::STURDi;
3406 case AArch64::LDRXui:
3407 return AArch64::LDURXi;
3408 case AArch64::STRXui:
3409 return AArch64::STURXi;
3410 case AArch64::LDRWui:
3411 return AArch64::LDURWi;
3412 case AArch64::LDRSWui:
3413 return AArch64::LDURSWi;
3414 case AArch64::STRWui:
3415 return AArch64::STURWi;
3416 case AArch64::LDRHui:
3417 return AArch64::LDURHi;
3418 case AArch64::STRHui:
3419 return AArch64::STURHi;
3420 case AArch64::LDRHHui:
3421 return AArch64::LDURHHi;
3422 case AArch64::STRHHui:
3423 return AArch64::STURHHi;
3424 case AArch64::LDRSHXui:
3425 return AArch64::LDURSHXi;
3426 case AArch64::LDRSHWui:
3427 return AArch64::LDURSHWi;
3428 case AArch64::LDRBBui:
3429 return AArch64::LDURBBi;
3430 case AArch64::LDRBui:
3431 return AArch64::LDURBi;
3432 case AArch64::STRBBui:
3433 return AArch64::STURBBi;
3434 case AArch64::STRBui:
3435 return AArch64::STURBi;
3436 case AArch64::LDRSBWui:
3437 return AArch64::LDURSBWi;
3438 case AArch64::LDRSBXui:
3439 return AArch64::LDURSBXi;
3452 case AArch64::LDRQroX:
3453 case AArch64::LDURQi:
3454 case AArch64::LDRQui:
3455 return AArch64::LDRQroW;
3456 case AArch64::STRQroX:
3457 case AArch64::STURQi:
3458 case AArch64::STRQui:
3459 return AArch64::STRQroW;
3460 case AArch64::LDRDroX:
3461 case AArch64::LDURDi:
3462 case AArch64::LDRDui:
3463 return AArch64::LDRDroW;
3464 case AArch64::STRDroX:
3465 case AArch64::STURDi:
3466 case AArch64::STRDui:
3467 return AArch64::STRDroW;
3468 case AArch64::LDRXroX:
3469 case AArch64::LDURXi:
3470 case AArch64::LDRXui:
3471 return AArch64::LDRXroW;
3472 case AArch64::STRXroX:
3473 case AArch64::STURXi:
3474 case AArch64::STRXui:
3475 return AArch64::STRXroW;
3476 case AArch64::LDRWroX:
3477 case AArch64::LDURWi:
3478 case AArch64::LDRWui:
3479 return AArch64::LDRWroW;
3480 case AArch64::LDRSWroX:
3481 case AArch64::LDURSWi:
3482 case AArch64::LDRSWui:
3483 return AArch64::LDRSWroW;
3484 case AArch64::STRWroX:
3485 case AArch64::STURWi:
3486 case AArch64::STRWui:
3487 return AArch64::STRWroW;
3488 case AArch64::LDRHroX:
3489 case AArch64::LDURHi:
3490 case AArch64::LDRHui:
3491 return AArch64::LDRHroW;
3492 case AArch64::STRHroX:
3493 case AArch64::STURHi:
3494 case AArch64::STRHui:
3495 return AArch64::STRHroW;
3496 case AArch64::LDRHHroX:
3497 case AArch64::LDURHHi:
3498 case AArch64::LDRHHui:
3499 return AArch64::LDRHHroW;
3500 case AArch64::STRHHroX:
3501 case AArch64::STURHHi:
3502 case AArch64::STRHHui:
3503 return AArch64::STRHHroW;
3504 case AArch64::LDRSHXroX:
3505 case AArch64::LDURSHXi:
3506 case AArch64::LDRSHXui:
3507 return AArch64::LDRSHXroW;
3508 case AArch64::LDRSHWroX:
3509 case AArch64::LDURSHWi:
3510 case AArch64::LDRSHWui:
3511 return AArch64::LDRSHWroW;
3512 case AArch64::LDRBroX:
3513 case AArch64::LDURBi:
3514 case AArch64::LDRBui:
3515 return AArch64::LDRBroW;
3516 case AArch64::LDRBBroX:
3517 case AArch64::LDURBBi:
3518 case AArch64::LDRBBui:
3519 return AArch64::LDRBBroW;
3520 case AArch64::LDRSBXroX:
3521 case AArch64::LDURSBXi:
3522 case AArch64::LDRSBXui:
3523 return AArch64::LDRSBXroW;
3524 case AArch64::LDRSBWroX:
3525 case AArch64::LDURSBWi:
3526 case AArch64::LDRSBWui:
3527 return AArch64::LDRSBWroW;
3528 case AArch64::STRBroX:
3529 case AArch64::STURBi:
3530 case AArch64::STRBui:
3531 return AArch64::STRBroW;
3532 case AArch64::STRBBroX:
3533 case AArch64::STURBBi:
3534 case AArch64::STRBBui:
3535 return AArch64::STRBBroW;
3550 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
3560 return B.getInstr();
3564 "Addressing mode not supported for folding");
3581 return B.getInstr();
3588 "Address offset can be a register or an immediate, but not both");
3590 MRI.constrainRegClass(AM.
BaseReg, &AArch64::GPR64spRegClass);
3595 OffsetReg =
MRI.createVirtualRegister(&AArch64::GPR32RegClass);
3609 return B.getInstr();
3613 "Function must not be called with an addressing mode it can't handle");
3622 case AArch64::LD1Fourv16b_POST:
3623 case AArch64::LD1Fourv1d_POST:
3624 case AArch64::LD1Fourv2d_POST:
3625 case AArch64::LD1Fourv2s_POST:
3626 case AArch64::LD1Fourv4h_POST:
3627 case AArch64::LD1Fourv4s_POST:
3628 case AArch64::LD1Fourv8b_POST:
3629 case AArch64::LD1Fourv8h_POST:
3630 case AArch64::LD1Onev16b_POST:
3631 case AArch64::LD1Onev1d_POST:
3632 case AArch64::LD1Onev2d_POST:
3633 case AArch64::LD1Onev2s_POST:
3634 case AArch64::LD1Onev4h_POST:
3635 case AArch64::LD1Onev4s_POST:
3636 case AArch64::LD1Onev8b_POST:
3637 case AArch64::LD1Onev8h_POST:
3638 case AArch64::LD1Rv16b_POST:
3639 case AArch64::LD1Rv1d_POST:
3640 case AArch64::LD1Rv2d_POST:
3641 case AArch64::LD1Rv2s_POST:
3642 case AArch64::LD1Rv4h_POST:
3643 case AArch64::LD1Rv4s_POST:
3644 case AArch64::LD1Rv8b_POST:
3645 case AArch64::LD1Rv8h_POST:
3646 case AArch64::LD1Threev16b_POST:
3647 case AArch64::LD1Threev1d_POST:
3648 case AArch64::LD1Threev2d_POST:
3649 case AArch64::LD1Threev2s_POST:
3650 case AArch64::LD1Threev4h_POST:
3651 case AArch64::LD1Threev4s_POST:
3652 case AArch64::LD1Threev8b_POST:
3653 case AArch64::LD1Threev8h_POST:
3654 case AArch64::LD1Twov16b_POST:
3655 case AArch64::LD1Twov1d_POST:
3656 case AArch64::LD1Twov2d_POST:
3657 case AArch64::LD1Twov2s_POST:
3658 case AArch64::LD1Twov4h_POST:
3659 case AArch64::LD1Twov4s_POST:
3660 case AArch64::LD1Twov8b_POST:
3661 case AArch64::LD1Twov8h_POST:
3662 case AArch64::LD1i16_POST:
3663 case AArch64::LD1i32_POST:
3664 case AArch64::LD1i64_POST:
3665 case AArch64::LD1i8_POST:
3666 case AArch64::LD2Rv16b_POST:
3667 case AArch64::LD2Rv1d_POST:
3668 case AArch64::LD2Rv2d_POST:
3669 case AArch64::LD2Rv2s_POST:
3670 case AArch64::LD2Rv4h_POST:
3671 case AArch64::LD2Rv4s_POST:
3672 case AArch64::LD2Rv8b_POST:
3673 case AArch64::LD2Rv8h_POST:
3674 case AArch64::LD2Twov16b_POST:
3675 case AArch64::LD2Twov2d_POST:
3676 case AArch64::LD2Twov2s_POST:
3677 case AArch64::LD2Twov4h_POST:
3678 case AArch64::LD2Twov4s_POST:
3679 case AArch64::LD2Twov8b_POST:
3680 case AArch64::LD2Twov8h_POST:
3681 case AArch64::LD2i16_POST:
3682 case AArch64::LD2i32_POST:
3683 case AArch64::LD2i64_POST:
3684 case AArch64::LD2i8_POST:
3685 case AArch64::LD3Rv16b_POST:
3686 case AArch64::LD3Rv1d_POST:
3687 case AArch64::LD3Rv2d_POST:
3688 case AArch64::LD3Rv2s_POST:
3689 case AArch64::LD3Rv4h_POST:
3690 case AArch64::LD3Rv4s_POST:
3691 case AArch64::LD3Rv8b_POST:
3692 case AArch64::LD3Rv8h_POST:
3693 case AArch64::LD3Threev16b_POST:
3694 case AArch64::LD3Threev2d_POST:
3695 case AArch64::LD3Threev2s_POST:
3696 case AArch64::LD3Threev4h_POST:
3697 case AArch64::LD3Threev4s_POST:
3698 case AArch64::LD3Threev8b_POST:
3699 case AArch64::LD3Threev8h_POST:
3700 case AArch64::LD3i16_POST:
3701 case AArch64::LD3i32_POST:
3702 case AArch64::LD3i64_POST:
3703 case AArch64::LD3i8_POST:
3704 case AArch64::LD4Fourv16b_POST:
3705 case AArch64::LD4Fourv2d_POST:
3706 case AArch64::LD4Fourv2s_POST:
3707 case AArch64::LD4Fourv4h_POST:
3708 case AArch64::LD4Fourv4s_POST:
3709 case AArch64::LD4Fourv8b_POST:
3710 case AArch64::LD4Fourv8h_POST:
3711 case AArch64::LD4Rv16b_POST:
3712 case AArch64::LD4Rv1d_POST:
3713 case AArch64::LD4Rv2d_POST:
3714 case AArch64::LD4Rv2s_POST:
3715 case AArch64::LD4Rv4h_POST:
3716 case AArch64::LD4Rv4s_POST:
3717 case AArch64::LD4Rv8b_POST:
3718 case AArch64::LD4Rv8h_POST:
3719 case AArch64::LD4i16_POST:
3720 case AArch64::LD4i32_POST:
3721 case AArch64::LD4i64_POST:
3722 case AArch64::LD4i8_POST:
3723 case AArch64::LDAPRWpost:
3724 case AArch64::LDAPRXpost:
3725 case AArch64::LDIAPPWpost:
3726 case AArch64::LDIAPPXpost:
3727 case AArch64::LDPDpost:
3728 case AArch64::LDPQpost:
3729 case AArch64::LDPSWpost:
3730 case AArch64::LDPSpost:
3731 case AArch64::LDPWpost:
3732 case AArch64::LDPXpost:
3733 case AArch64::LDRBBpost:
3734 case AArch64::LDRBpost:
3735 case AArch64::LDRDpost:
3736 case AArch64::LDRHHpost:
3737 case AArch64::LDRHpost:
3738 case AArch64::LDRQpost:
3739 case AArch64::LDRSBWpost:
3740 case AArch64::LDRSBXpost:
3741 case AArch64::LDRSHWpost:
3742 case AArch64::LDRSHXpost:
3743 case AArch64::LDRSWpost:
3744 case AArch64::LDRSpost:
3745 case AArch64::LDRWpost:
3746 case AArch64::LDRXpost:
3747 case AArch64::ST1Fourv16b_POST:
3748 case AArch64::ST1Fourv1d_POST:
3749 case AArch64::ST1Fourv2d_POST:
3750 case AArch64::ST1Fourv2s_POST:
3751 case AArch64::ST1Fourv4h_POST:
3752 case AArch64::ST1Fourv4s_POST:
3753 case AArch64::ST1Fourv8b_POST:
3754 case AArch64::ST1Fourv8h_POST:
3755 case AArch64::ST1Onev16b_POST:
3756 case AArch64::ST1Onev1d_POST:
3757 case AArch64::ST1Onev2d_POST:
3758 case AArch64::ST1Onev2s_POST:
3759 case AArch64::ST1Onev4h_POST:
3760 case AArch64::ST1Onev4s_POST:
3761 case AArch64::ST1Onev8b_POST:
3762 case AArch64::ST1Onev8h_POST:
3763 case AArch64::ST1Threev16b_POST:
3764 case AArch64::ST1Threev1d_POST:
3765 case AArch64::ST1Threev2d_POST:
3766 case AArch64::ST1Threev2s_POST:
3767 case AArch64::ST1Threev4h_POST:
3768 case AArch64::ST1Threev4s_POST:
3769 case AArch64::ST1Threev8b_POST:
3770 case AArch64::ST1Threev8h_POST:
3771 case AArch64::ST1Twov16b_POST:
3772 case AArch64::ST1Twov1d_POST:
3773 case AArch64::ST1Twov2d_POST:
3774 case AArch64::ST1Twov2s_POST:
3775 case AArch64::ST1Twov4h_POST:
3776 case AArch64::ST1Twov4s_POST:
3777 case AArch64::ST1Twov8b_POST:
3778 case AArch64::ST1Twov8h_POST:
3779 case AArch64::ST1i16_POST:
3780 case AArch64::ST1i32_POST:
3781 case AArch64::ST1i64_POST:
3782 case AArch64::ST1i8_POST:
3783 case AArch64::ST2GPostIndex:
3784 case AArch64::ST2Twov16b_POST:
3785 case AArch64::ST2Twov2d_POST:
3786 case AArch64::ST2Twov2s_POST:
3787 case AArch64::ST2Twov4h_POST:
3788 case AArch64::ST2Twov4s_POST:
3789 case AArch64::ST2Twov8b_POST:
3790 case AArch64::ST2Twov8h_POST:
3791 case AArch64::ST2i16_POST:
3792 case AArch64::ST2i32_POST:
3793 case AArch64::ST2i64_POST:
3794 case AArch64::ST2i8_POST:
3795 case AArch64::ST3Threev16b_POST:
3796 case AArch64::ST3Threev2d_POST:
3797 case AArch64::ST3Threev2s_POST:
3798 case AArch64::ST3Threev4h_POST:
3799 case AArch64::ST3Threev4s_POST:
3800 case AArch64::ST3Threev8b_POST:
3801 case AArch64::ST3Threev8h_POST:
3802 case AArch64::ST3i16_POST:
3803 case AArch64::ST3i32_POST:
3804 case AArch64::ST3i64_POST:
3805 case AArch64::ST3i8_POST:
3806 case AArch64::ST4Fourv16b_POST:
3807 case AArch64::ST4Fourv2d_POST:
3808 case AArch64::ST4Fourv2s_POST:
3809 case AArch64::ST4Fourv4h_POST:
3810 case AArch64::ST4Fourv4s_POST:
3811 case AArch64::ST4Fourv8b_POST:
3812 case AArch64::ST4Fourv8h_POST:
3813 case AArch64::ST4i16_POST:
3814 case AArch64::ST4i32_POST:
3815 case AArch64::ST4i64_POST:
3816 case AArch64::ST4i8_POST:
3817 case AArch64::STGPostIndex:
3818 case AArch64::STGPpost:
3819 case AArch64::STPDpost:
3820 case AArch64::STPQpost:
3821 case AArch64::STPSpost:
3822 case AArch64::STPWpost:
3823 case AArch64::STPXpost:
3824 case AArch64::STRBBpost:
3825 case AArch64::STRBpost:
3826 case AArch64::STRDpost:
3827 case AArch64::STRHHpost:
3828 case AArch64::STRHpost:
3829 case AArch64::STRQpost:
3830 case AArch64::STRSpost:
3831 case AArch64::STRWpost:
3832 case AArch64::STRXpost:
3833 case AArch64::STZ2GPostIndex:
3834 case AArch64::STZGPostIndex:
3841 bool &OffsetIsScalable,
TypeSize &Width,
3862 int64_t Dummy1, Dummy2;
3884 return BaseOp->
isReg() || BaseOp->
isFI();
3891 assert(OfsOp.
isImm() &&
"Offset operand wasn't immediate.");
3896 TypeSize &Width, int64_t &MinOffset,
3897 int64_t &MaxOffset) {
3903 MinOffset = MaxOffset = 0;
3906 case AArch64::LDRQui:
3907 case AArch64::STRQui:
3913 case AArch64::LDRXui:
3914 case AArch64::LDRDui:
3915 case AArch64::STRXui:
3916 case AArch64::STRDui:
3917 case AArch64::PRFMui:
3923 case AArch64::LDRWui:
3924 case AArch64::LDRSui:
3925 case AArch64::LDRSWui:
3926 case AArch64::STRWui:
3927 case AArch64::STRSui:
3933 case AArch64::LDRHui:
3934 case AArch64::LDRHHui:
3935 case AArch64::LDRSHWui:
3936 case AArch64::LDRSHXui:
3937 case AArch64::STRHui:
3938 case AArch64::STRHHui:
3944 case AArch64::LDRBui:
3945 case AArch64::LDRBBui:
3946 case AArch64::LDRSBWui:
3947 case AArch64::LDRSBXui:
3948 case AArch64::STRBui:
3949 case AArch64::STRBBui:
3956 case AArch64::STRQpre:
3957 case AArch64::LDRQpost:
3963 case AArch64::LDRDpost:
3964 case AArch64::LDRDpre:
3965 case AArch64::LDRXpost:
3966 case AArch64::LDRXpre:
3967 case AArch64::STRDpost:
3968 case AArch64::STRDpre:
3969 case AArch64::STRXpost:
3970 case AArch64::STRXpre:
3976 case AArch64::STRWpost:
3977 case AArch64::STRWpre:
3978 case AArch64::LDRWpost:
3979 case AArch64::LDRWpre:
3980 case AArch64::STRSpost:
3981 case AArch64::STRSpre:
3982 case AArch64::LDRSpost:
3983 case AArch64::LDRSpre:
3989 case AArch64::LDRHpost:
3990 case AArch64::LDRHpre:
3991 case AArch64::STRHpost:
3992 case AArch64::STRHpre:
3993 case AArch64::LDRHHpost:
3994 case AArch64::LDRHHpre:
3995 case AArch64::STRHHpost:
3996 case AArch64::STRHHpre:
4002 case AArch64::LDRBpost:
4003 case AArch64::LDRBpre:
4004 case AArch64::STRBpost:
4005 case AArch64::STRBpre:
4006 case AArch64::LDRBBpost:
4007 case AArch64::LDRBBpre:
4008 case AArch64::STRBBpost:
4009 case AArch64::STRBBpre:
4016 case AArch64::LDURQi:
4017 case AArch64::STURQi:
4023 case AArch64::LDURXi:
4024 case AArch64::LDURDi:
4025 case AArch64::LDAPURXi:
4026 case AArch64::STURXi:
4027 case AArch64::STURDi:
4028 case AArch64::STLURXi:
4029 case AArch64::PRFUMi:
4035 case AArch64::LDURWi:
4036 case AArch64::LDURSi:
4037 case AArch64::LDURSWi:
4038 case AArch64::LDAPURi:
4039 case AArch64::LDAPURSWi:
4040 case AArch64::STURWi:
4041 case AArch64::STURSi:
4042 case AArch64::STLURWi:
4048 case AArch64::LDURHi:
4049 case AArch64::LDURHHi:
4050 case AArch64::LDURSHXi:
4051 case AArch64::LDURSHWi:
4052 case AArch64::LDAPURHi:
4053 case AArch64::LDAPURSHWi:
4054 case AArch64::LDAPURSHXi:
4055 case AArch64::STURHi:
4056 case AArch64::STURHHi:
4057 case AArch64::STLURHi:
4063 case AArch64::LDURBi:
4064 case AArch64::LDURBBi:
4065 case AArch64::LDURSBXi:
4066 case AArch64::LDURSBWi:
4067 case AArch64::LDAPURBi:
4068 case AArch64::LDAPURSBWi:
4069 case AArch64::LDAPURSBXi:
4070 case AArch64::STURBi:
4071 case AArch64::STURBBi:
4072 case AArch64::STLURBi:
4079 case AArch64::LDPQi:
4080 case AArch64::LDNPQi:
4081 case AArch64::STPQi:
4082 case AArch64::STNPQi:
4083 case AArch64::LDPQpost:
4084 case AArch64::LDPQpre:
4085 case AArch64::STPQpost:
4086 case AArch64::STPQpre:
4092 case AArch64::LDPXi:
4093 case AArch64::LDPDi:
4094 case AArch64::LDNPXi:
4095 case AArch64::LDNPDi:
4096 case AArch64::STPXi:
4097 case AArch64::STPDi:
4098 case AArch64::STNPXi:
4099 case AArch64::STNPDi:
4100 case AArch64::LDPDpost:
4101 case AArch64::LDPDpre:
4102 case AArch64::LDPXpost:
4103 case AArch64::LDPXpre:
4104 case AArch64::STPDpost:
4105 case AArch64::STPDpre:
4106 case AArch64::STPXpost:
4107 case AArch64::STPXpre:
4113 case AArch64::LDPWi:
4114 case AArch64::LDPSi:
4115 case AArch64::LDNPWi:
4116 case AArch64::LDNPSi:
4117 case AArch64::STPWi:
4118 case AArch64::STPSi:
4119 case AArch64::STNPWi:
4120 case AArch64::STNPSi:
4121 case AArch64::LDPSpost:
4122 case AArch64::LDPSpre:
4123 case AArch64::LDPWpost:
4124 case AArch64::LDPWpre:
4125 case AArch64::STPSpost:
4126 case AArch64::STPSpre:
4127 case AArch64::STPWpost:
4128 case AArch64::STPWpre:
4134 case AArch64::StoreSwiftAsyncContext:
4147 case AArch64::TAGPstack:
4157 case AArch64::STZGi:
4164 case AArch64::STR_ZZZZXI:
4165 case AArch64::LDR_ZZZZXI:
4171 case AArch64::STR_ZZZXI:
4172 case AArch64::LDR_ZZZXI:
4178 case AArch64::STR_ZZXI:
4179 case AArch64::LDR_ZZXI:
4185 case AArch64::LDR_PXI:
4186 case AArch64::STR_PXI:
4192 case AArch64::LDR_PPXI:
4193 case AArch64::STR_PPXI:
4199 case AArch64::LDR_ZXI:
4200 case AArch64::STR_ZXI:
4206 case AArch64::LD1B_IMM:
4207 case AArch64::LD1H_IMM:
4208 case AArch64::LD1W_IMM:
4209 case AArch64::LD1D_IMM:
4210 case AArch64::LDNT1B_ZRI:
4211 case AArch64::LDNT1H_ZRI:
4212 case AArch64::LDNT1W_ZRI:
4213 case AArch64::LDNT1D_ZRI:
4214 case AArch64::ST1B_IMM:
4215 case AArch64::ST1H_IMM:
4216 case AArch64::ST1W_IMM:
4217 case AArch64::ST1D_IMM:
4218 case AArch64::STNT1B_ZRI:
4219 case AArch64::STNT1H_ZRI:
4220 case AArch64::STNT1W_ZRI:
4221 case AArch64::STNT1D_ZRI:
4222 case AArch64::LDNF1B_IMM:
4223 case AArch64::LDNF1H_IMM:
4224 case AArch64::LDNF1W_IMM:
4225 case AArch64::LDNF1D_IMM:
4233 case AArch64::LD2B_IMM:
4234 case AArch64::LD2H_IMM:
4235 case AArch64::LD2W_IMM:
4236 case AArch64::LD2D_IMM:
4237 case AArch64::ST2B_IMM:
4238 case AArch64::ST2H_IMM:
4239 case AArch64::ST2W_IMM:
4240 case AArch64::ST2D_IMM:
4246 case AArch64::LD3B_IMM:
4247 case AArch64::LD3H_IMM:
4248 case AArch64::LD3W_IMM:
4249 case AArch64::LD3D_IMM:
4250 case AArch64::ST3B_IMM:
4251 case AArch64::ST3H_IMM:
4252 case AArch64::ST3W_IMM:
4253 case AArch64::ST3D_IMM:
4259 case AArch64::LD4B_IMM:
4260 case AArch64::LD4H_IMM:
4261 case AArch64::LD4W_IMM:
4262 case AArch64::LD4D_IMM:
4263 case AArch64::ST4B_IMM:
4264 case AArch64::ST4H_IMM:
4265 case AArch64::ST4W_IMM:
4266 case AArch64::ST4D_IMM:
4272 case AArch64::LD1B_H_IMM:
4273 case AArch64::LD1SB_H_IMM:
4274 case AArch64::LD1H_S_IMM:
4275 case AArch64::LD1SH_S_IMM:
4276 case AArch64::LD1W_D_IMM:
4277 case AArch64::LD1SW_D_IMM:
4278 case AArch64::ST1B_H_IMM:
4279 case AArch64::ST1H_S_IMM:
4280 case AArch64::ST1W_D_IMM:
4281 case AArch64::LDNF1B_H_IMM:
4282 case AArch64::LDNF1SB_H_IMM:
4283 case AArch64::LDNF1H_S_IMM:
4284 case AArch64::LDNF1SH_S_IMM:
4285 case AArch64::LDNF1W_D_IMM:
4286 case AArch64::LDNF1SW_D_IMM:
4294 case AArch64::LD1B_S_IMM:
4295 case AArch64::LD1SB_S_IMM:
4296 case AArch64::LD1H_D_IMM:
4297 case AArch64::LD1SH_D_IMM:
4298 case AArch64::ST1B_S_IMM:
4299 case AArch64::ST1H_D_IMM:
4300 case AArch64::LDNF1B_S_IMM:
4301 case AArch64::LDNF1SB_S_IMM:
4302 case AArch64::LDNF1H_D_IMM:
4303 case AArch64::LDNF1SH_D_IMM:
4311 case AArch64::LD1B_D_IMM:
4312 case AArch64::LD1SB_D_IMM:
4313 case AArch64::ST1B_D_IMM:
4314 case AArch64::LDNF1B_D_IMM:
4315 case AArch64::LDNF1SB_D_IMM:
4323 case AArch64::ST2Gi:
4324 case AArch64::STZ2Gi:
4330 case AArch64::STGPi:
4336 case AArch64::LD1RB_IMM:
4337 case AArch64::LD1RB_H_IMM:
4338 case AArch64::LD1RB_S_IMM:
4339 case AArch64::LD1RB_D_IMM:
4340 case AArch64::LD1RSB_H_IMM:
4341 case AArch64::LD1RSB_S_IMM:
4342 case AArch64::LD1RSB_D_IMM:
4348 case AArch64::LD1RH_IMM:
4349 case AArch64::LD1RH_S_IMM:
4350 case AArch64::LD1RH_D_IMM:
4351 case AArch64::LD1RSH_S_IMM:
4352 case AArch64::LD1RSH_D_IMM:
4358 case AArch64::LD1RW_IMM:
4359 case AArch64::LD1RW_D_IMM:
4360 case AArch64::LD1RSW_IMM:
4366 case AArch64::LD1RD_IMM:
4382 case AArch64::LDRBBui:
4383 case AArch64::LDURBBi:
4384 case AArch64::LDRSBWui:
4385 case AArch64::LDURSBWi:
4386 case AArch64::STRBBui:
4387 case AArch64::STURBBi:
4389 case AArch64::LDRHHui:
4390 case AArch64::LDURHHi:
4391 case AArch64::LDRSHWui:
4392 case AArch64::LDURSHWi:
4393 case AArch64::STRHHui:
4394 case AArch64::STURHHi:
4396 case AArch64::LDRSui:
4397 case AArch64::LDURSi:
4398 case AArch64::LDRSpre:
4399 case AArch64::LDRSWui:
4400 case AArch64::LDURSWi:
4401 case AArch64::LDRSWpre:
4402 case AArch64::LDRWpre:
4403 case AArch64::LDRWui:
4404 case AArch64::LDURWi:
4405 case AArch64::STRSui:
4406 case AArch64::STURSi:
4407 case AArch64::STRSpre:
4408 case AArch64::STRWui:
4409 case AArch64::STURWi:
4410 case AArch64::STRWpre:
4411 case AArch64::LDPSi:
4412 case AArch64::LDPSWi:
4413 case AArch64::LDPWi:
4414 case AArch64::STPSi:
4415 case AArch64::STPWi:
4417 case AArch64::LDRDui:
4418 case AArch64::LDURDi:
4419 case AArch64::LDRDpre:
4420 case AArch64::LDRXui:
4421 case AArch64::LDURXi:
4422 case AArch64::LDRXpre:
4423 case AArch64::STRDui:
4424 case AArch64::STURDi:
4425 case AArch64::STRDpre:
4426 case AArch64::STRXui:
4427 case AArch64::STURXi:
4428 case AArch64::STRXpre:
4429 case AArch64::LDPDi:
4430 case AArch64::LDPXi:
4431 case AArch64::STPDi:
4432 case AArch64::STPXi:
4434 case AArch64::LDRQui:
4435 case AArch64::LDURQi:
4436 case AArch64::STRQui:
4437 case AArch64::STURQi:
4438 case AArch64::STRQpre:
4439 case AArch64::LDPQi:
4440 case AArch64::LDRQpre:
4441 case AArch64::STPQi:
4443 case AArch64::STZGi:
4444 case AArch64::ST2Gi:
4445 case AArch64::STZ2Gi:
4446 case AArch64::STGPi:
4452 switch (
MI.getOpcode()) {
4455 case AArch64::LDRWpre:
4456 case AArch64::LDRXpre:
4457 case AArch64::LDRSWpre:
4458 case AArch64::LDRSpre:
4459 case AArch64::LDRDpre:
4460 case AArch64::LDRQpre:
4466 switch (
MI.getOpcode()) {
4469 case AArch64::STRWpre:
4470 case AArch64::STRXpre:
4471 case AArch64::STRSpre:
4472 case AArch64::STRDpre:
4473 case AArch64::STRQpre:
4483 switch (
MI.getOpcode()) {
4486 case AArch64::LDPSi:
4487 case AArch64::LDPSWi:
4488 case AArch64::LDPDi:
4489 case AArch64::LDPQi:
4490 case AArch64::LDPWi:
4491 case AArch64::LDPXi:
4492 case AArch64::STPSi:
4493 case AArch64::STPDi:
4494 case AArch64::STPQi:
4495 case AArch64::STPWi:
4496 case AArch64::STPXi:
4497 case AArch64::STGPi:
4503 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
4507 return MI.getOperand(
Idx);
4512 assert(
MI.mayLoadOrStore() &&
"Load or store instruction expected");
4516 return MI.getOperand(
Idx);
4521 switch (
MI.getOpcode()) {
4524 case AArch64::LDRBBroX:
4525 return MI.getOperand(4);
4531 if (
MI.getParent() ==
nullptr)
4541 auto Reg =
Op.getReg();
4542 if (Reg.isPhysical())
4543 return AArch64::FPR16RegClass.
contains(Reg);
4545 return TRC == &AArch64::FPR16RegClass ||
4546 TRC == &AArch64::FPR16_loRegClass;
4555 auto Reg =
Op.getReg();
4556 if (Reg.isPhysical())
4557 return AArch64::FPR128RegClass.
contains(Reg);
4559 return TRC == &AArch64::FPR128RegClass ||
4560 TRC == &AArch64::FPR128_loRegClass;
4566 switch (
MI.getOpcode()) {
4569 case AArch64::PACIASP:
4570 case AArch64::PACIBSP:
4573 case AArch64::PAUTH_PROLOGUE:
4576 case AArch64::HINT: {
4577 unsigned Imm =
MI.getOperand(0).getImm();
4579 if (Imm == 32 || Imm == 34 || Imm == 36 || Imm == 38)
4582 if (Imm == 25 || Imm == 27)
4594 assert(Reg.isPhysical() &&
"Expected physical register in isFpOrNEON");
4595 return AArch64::FPR128RegClass.contains(Reg) ||
4596 AArch64::FPR64RegClass.contains(Reg) ||
4597 AArch64::FPR32RegClass.contains(Reg) ||
4598 AArch64::FPR16RegClass.contains(Reg) ||
4599 AArch64::FPR8RegClass.contains(Reg);
4606 auto Reg =
Op.getReg();
4607 if (Reg.isPhysical())
4611 return TRC == &AArch64::FPR128RegClass ||
4612 TRC == &AArch64::FPR128_loRegClass ||
4613 TRC == &AArch64::FPR64RegClass ||
4614 TRC == &AArch64::FPR64_loRegClass ||
4615 TRC == &AArch64::FPR32RegClass || TRC == &AArch64::FPR16RegClass ||
4616 TRC == &AArch64::FPR8RegClass;
4638 if (FirstOpc == SecondOpc)
4644 case AArch64::STRSui:
4645 case AArch64::STURSi:
4646 return SecondOpc == AArch64::STRSui || SecondOpc == AArch64::STURSi;
4647 case AArch64::STRDui:
4648 case AArch64::STURDi:
4649 return SecondOpc == AArch64::STRDui || SecondOpc == AArch64::STURDi;
4650 case AArch64::STRQui:
4651 case AArch64::STURQi:
4652 return SecondOpc == AArch64::STRQui || SecondOpc == AArch64::STURQi;
4653 case AArch64::STRWui:
4654 case AArch64::STURWi:
4655 return SecondOpc == AArch64::STRWui || SecondOpc == AArch64::STURWi;
4656 case AArch64::STRXui:
4657 case AArch64::STURXi:
4658 return SecondOpc == AArch64::STRXui || SecondOpc == AArch64::STURXi;
4659 case AArch64::LDRSui:
4660 case AArch64::LDURSi:
4661 return SecondOpc == AArch64::LDRSui || SecondOpc == AArch64::LDURSi;
4662 case AArch64::LDRDui:
4663 case AArch64::LDURDi:
4664 return SecondOpc == AArch64::LDRDui || SecondOpc == AArch64::LDURDi;
4665 case AArch64::LDRQui:
4666 case AArch64::LDURQi:
4667 return SecondOpc == AArch64::LDRQui || SecondOpc == AArch64::LDURQi;
4668 case AArch64::LDRWui:
4669 case AArch64::LDURWi:
4670 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
4671 case AArch64::LDRSWui:
4672 case AArch64::LDURSWi:
4673 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
4674 case AArch64::LDRXui:
4675 case AArch64::LDURXi:
4676 return SecondOpc == AArch64::LDRXui || SecondOpc == AArch64::LDURXi;
4683 int64_t Offset1,
unsigned Opcode1,
int FI2,
4684 int64_t Offset2,
unsigned Opcode2) {
4690 assert(ObjectOffset1 <= ObjectOffset2 &&
"Object offsets are not ordered.");
4693 if (ObjectOffset1 % Scale1 != 0)
4695 ObjectOffset1 /= Scale1;
4697 if (ObjectOffset2 % Scale2 != 0)
4699 ObjectOffset2 /= Scale2;
4700 ObjectOffset1 += Offset1;
4701 ObjectOffset2 += Offset2;
4702 return ObjectOffset1 + 1 == ObjectOffset2;
4714 int64_t OpOffset2,
bool OffsetIsScalable2,
unsigned ClusterSize,
4715 unsigned NumBytes)
const {
4725 "Only base registers and frame indices are supported.");
4732 if (ClusterSize > 2)
4739 unsigned FirstOpc = FirstLdSt.
getOpcode();
4740 unsigned SecondOpc = SecondLdSt.
getOpcode();
4760 if (Offset1 > 63 || Offset1 < -64)
4765 if (BaseOp1.
isFI()) {
4767 "Caller should have ordered offsets.");
4772 BaseOp2.
getIndex(), Offset2, SecondOpc);
4775 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
4777 return Offset1 + 1 == Offset2;
4781 unsigned Reg,
unsigned SubIdx,
4785 return MIB.
addReg(Reg, State);
4788 return MIB.
addReg(
TRI->getSubReg(Reg, SubIdx), State);
4789 return MIB.
addReg(Reg, State, SubIdx);
4796 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
4805 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
4807 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
4808 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
4809 unsigned NumRegs = Indices.
size();
4811 int SubReg = 0,
End = NumRegs, Incr = 1;
4829 unsigned SrcReg,
bool KillSrc,
4830 unsigned Opcode,
unsigned ZeroReg,
4833 unsigned NumRegs = Indices.
size();
4836 uint16_t DestEncoding =
TRI->getEncodingValue(DestReg);
4837 uint16_t SrcEncoding =
TRI->getEncodingValue(SrcReg);
4838 assert(DestEncoding % NumRegs == 0 && SrcEncoding % NumRegs == 0 &&
4839 "GPR reg sequences should not be able to overlap");
4855 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
4856 (AArch64::GPR32spRegClass.
contains(SrcReg) || SrcReg == AArch64::WZR)) {
4859 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
4861 if (Subtarget.hasZeroCycleRegMove()) {
4864 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
4866 SrcReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
4882 }
else if (SrcReg == AArch64::WZR && Subtarget.hasZeroCycleZeroingGP()) {
4887 if (Subtarget.hasZeroCycleRegMove()) {
4890 DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
4892 SrcReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
4912 if (AArch64::PPRRegClass.
contains(DestReg) &&
4913 AArch64::PPRRegClass.
contains(SrcReg)) {
4915 "Unexpected SVE register.");
4925 bool DestIsPNR = AArch64::PNRRegClass.contains(DestReg);
4926 bool SrcIsPNR = AArch64::PNRRegClass.contains(SrcReg);
4927 if (DestIsPNR || SrcIsPNR) {
4929 return (R - AArch64::PN0) + AArch64::P0;
4931 MCRegister PPRSrcReg = SrcIsPNR ? ToPPR(SrcReg) : SrcReg;
4932 MCRegister PPRDestReg = DestIsPNR ? ToPPR(DestReg) : DestReg;
4934 if (PPRSrcReg != PPRDestReg) {
4946 if (AArch64::ZPRRegClass.
contains(DestReg) &&
4947 AArch64::ZPRRegClass.
contains(SrcReg)) {
4949 "Unexpected SVE register.");
4957 if ((AArch64::ZPR2RegClass.
contains(DestReg) ||
4958 AArch64::ZPR2StridedOrContiguousRegClass.
contains(DestReg)) &&
4959 (AArch64::ZPR2RegClass.
contains(SrcReg) ||
4960 AArch64::ZPR2StridedOrContiguousRegClass.
contains(SrcReg))) {
4962 "Unexpected SVE register.");
4963 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1};
4970 if (AArch64::ZPR3RegClass.
contains(DestReg) &&
4971 AArch64::ZPR3RegClass.
contains(SrcReg)) {
4973 "Unexpected SVE register.");
4974 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
4982 if ((AArch64::ZPR4RegClass.
contains(DestReg) ||
4983 AArch64::ZPR4StridedOrContiguousRegClass.
contains(DestReg)) &&
4984 (AArch64::ZPR4RegClass.
contains(SrcReg) ||
4985 AArch64::ZPR4StridedOrContiguousRegClass.
contains(SrcReg))) {
4987 "Unexpected SVE register.");
4988 static const unsigned Indices[] = {AArch64::zsub0, AArch64::zsub1,
4989 AArch64::zsub2, AArch64::zsub3};
4995 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
4996 (AArch64::GPR64spRegClass.
contains(SrcReg) || SrcReg == AArch64::XZR)) {
4997 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
5003 }
else if (SrcReg == AArch64::XZR && Subtarget.hasZeroCycleZeroingGP()) {
5017 if (AArch64::DDDDRegClass.
contains(DestReg) &&
5018 AArch64::DDDDRegClass.
contains(SrcReg)) {
5019 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5020 AArch64::dsub2, AArch64::dsub3};
5027 if (AArch64::DDDRegClass.
contains(DestReg) &&
5028 AArch64::DDDRegClass.
contains(SrcReg)) {
5029 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
5037 if (AArch64::DDRegClass.
contains(DestReg) &&
5038 AArch64::DDRegClass.
contains(SrcReg)) {
5039 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
5046 if (AArch64::QQQQRegClass.
contains(DestReg) &&
5047 AArch64::QQQQRegClass.
contains(SrcReg)) {
5048 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5049 AArch64::qsub2, AArch64::qsub3};
5056 if (AArch64::QQQRegClass.
contains(DestReg) &&
5057 AArch64::QQQRegClass.
contains(SrcReg)) {
5058 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
5066 if (AArch64::QQRegClass.
contains(DestReg) &&
5067 AArch64::QQRegClass.
contains(SrcReg)) {
5068 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
5074 if (AArch64::XSeqPairsClassRegClass.
contains(DestReg) &&
5075 AArch64::XSeqPairsClassRegClass.
contains(SrcReg)) {
5076 static const unsigned Indices[] = {AArch64::sube64, AArch64::subo64};
5078 AArch64::XZR, Indices);
5082 if (AArch64::WSeqPairsClassRegClass.
contains(DestReg) &&
5083 AArch64::WSeqPairsClassRegClass.
contains(SrcReg)) {
5084 static const unsigned Indices[] = {AArch64::sube32, AArch64::subo32};
5086 AArch64::WZR, Indices);
5090 if (AArch64::FPR128RegClass.
contains(DestReg) &&
5091 AArch64::FPR128RegClass.
contains(SrcReg)) {
5096 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0))
5097 .
addReg(AArch64::Z0 + (SrcReg - AArch64::Q0));
5117 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5118 AArch64::FPR64RegClass.
contains(SrcReg)) {
5124 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5125 AArch64::FPR32RegClass.
contains(SrcReg)) {
5131 if (AArch64::FPR16RegClass.
contains(DestReg) &&
5132 AArch64::FPR16RegClass.
contains(SrcReg)) {
5134 RI.getMatchingSuperReg(DestReg, AArch64::hsub, &AArch64::FPR32RegClass);
5136 RI.getMatchingSuperReg(SrcReg, AArch64::hsub, &AArch64::FPR32RegClass);
5142 if (AArch64::FPR8RegClass.
contains(DestReg) &&
5143 AArch64::FPR8RegClass.
contains(SrcReg)) {
5145 RI.getMatchingSuperReg(DestReg, AArch64::bsub, &AArch64::FPR32RegClass);
5147 RI.getMatchingSuperReg(SrcReg, AArch64::bsub, &AArch64::FPR32RegClass);
5154 if (AArch64::FPR64RegClass.
contains(DestReg) &&
5155 AArch64::GPR64RegClass.
contains(SrcReg)) {
5160 if (AArch64::GPR64RegClass.
contains(DestReg) &&
5161 AArch64::FPR64RegClass.
contains(SrcReg)) {
5167 if (AArch64::FPR32RegClass.
contains(DestReg) &&
5168 AArch64::GPR32RegClass.
contains(SrcReg)) {
5173 if (AArch64::GPR32RegClass.
contains(DestReg) &&
5174 AArch64::FPR32RegClass.
contains(SrcReg)) {
5180 if (DestReg == AArch64::NZCV) {
5181 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
5183 .
addImm(AArch64SysReg::NZCV)
5189 if (SrcReg == AArch64::NZCV) {
5190 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
5192 .
addImm(AArch64SysReg::NZCV)
5199 errs() <<
TRI.getRegAsmName(DestReg) <<
" = COPY "
5200 <<
TRI.getRegAsmName(SrcReg) <<
"\n";
5210 unsigned SubIdx0,
unsigned SubIdx1,
int FI,
5215 SrcReg0 =
TRI.getSubReg(SrcReg, SubIdx0);
5217 SrcReg1 =
TRI.getSubReg(SrcReg, SubIdx1);
5230 Register SrcReg,
bool isKill,
int FI,
5245 switch (
TRI->getSpillSize(*RC)) {
5247 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
5248 Opc = AArch64::STRBui;
5251 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
5252 Opc = AArch64::STRHui;
5253 else if (AArch64::PNRRegClass.hasSubClassEq(RC) ||
5254 AArch64::PPRRegClass.hasSubClassEq(RC)) {
5256 "Unexpected register store without SVE store instructions");
5257 Opc = AArch64::STR_PXI;
5263 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
5264 Opc = AArch64::STRWui;
5268 assert(SrcReg != AArch64::WSP);
5269 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
5270 Opc = AArch64::STRSui;
5271 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
5272 Opc = AArch64::STR_PPXI;
5277 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
5278 Opc = AArch64::STRXui;
5282 assert(SrcReg != AArch64::SP);
5283 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
5284 Opc = AArch64::STRDui;
5285 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
5287 get(AArch64::STPWi), SrcReg, isKill,
5288 AArch64::sube32, AArch64::subo32, FI, MMO);
5293 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
5294 Opc = AArch64::STRQui;
5295 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
5296 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5297 Opc = AArch64::ST1Twov1d;
5299 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
5301 get(AArch64::STPXi), SrcReg, isKill,
5302 AArch64::sube64, AArch64::subo64, FI, MMO);
5304 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
5306 "Unexpected register store without SVE store instructions");
5307 Opc = AArch64::STR_ZXI;
5312 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
5313 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5314 Opc = AArch64::ST1Threev1d;
5319 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
5320 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5321 Opc = AArch64::ST1Fourv1d;
5323 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
5324 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5325 Opc = AArch64::ST1Twov2d;
5327 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC) ||
5328 AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5330 "Unexpected register store without SVE store instructions");
5331 Opc = AArch64::STR_ZZXI;
5336 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
5337 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5338 Opc = AArch64::ST1Threev2d;
5340 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
5342 "Unexpected register store without SVE store instructions");
5343 Opc = AArch64::STR_ZZZXI;
5348 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
5349 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
5350 Opc = AArch64::ST1Fourv2d;
5352 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC) ||
5353 AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5355 "Unexpected register store without SVE store instructions");
5356 Opc = AArch64::STR_ZZZZXI;
5361 assert(Opc &&
"Unknown register class");
5372 MI.addMemOperand(MMO);
5379 Register DestReg,
unsigned SubIdx0,
5380 unsigned SubIdx1,
int FI,
5384 bool IsUndef =
true;
5386 DestReg0 =
TRI.getSubReg(DestReg, SubIdx0);
5388 DestReg1 =
TRI.getSubReg(DestReg, SubIdx1);
5417 switch (
TRI->getSpillSize(*RC)) {
5419 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
5420 Opc = AArch64::LDRBui;
5423 bool IsPNR = AArch64::PNRRegClass.hasSubClassEq(RC);
5424 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
5425 Opc = AArch64::LDRHui;
5426 else if (IsPNR || AArch64::PPRRegClass.hasSubClassEq(RC)) {
5428 "Unexpected register load without SVE load instructions");
5431 Opc = AArch64::LDR_PXI;
5437 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
5438 Opc = AArch64::LDRWui;
5442 assert(DestReg != AArch64::WSP);
5443 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
5444 Opc = AArch64::LDRSui;
5445 else if (AArch64::PPR2RegClass.hasSubClassEq(RC)) {
5446 Opc = AArch64::LDR_PPXI;
5451 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
5452 Opc = AArch64::LDRXui;
5456 assert(DestReg != AArch64::SP);
5457 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC)) {
5458 Opc = AArch64::LDRDui;
5459 }
else if (AArch64::WSeqPairsClassRegClass.hasSubClassEq(RC)) {
5461 get(AArch64::LDPWi), DestReg, AArch64::sube32,
5462 AArch64::subo32, FI, MMO);
5467 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
5468 Opc = AArch64::LDRQui;
5469 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
5470 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5471 Opc = AArch64::LD1Twov1d;
5473 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
5475 get(AArch64::LDPXi), DestReg, AArch64::sube64,
5476 AArch64::subo64, FI, MMO);
5478 }
else if (AArch64::ZPRRegClass.hasSubClassEq(RC)) {
5480 "Unexpected register load without SVE load instructions");
5481 Opc = AArch64::LDR_ZXI;
5486 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
5487 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5488 Opc = AArch64::LD1Threev1d;
5493 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
5494 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5495 Opc = AArch64::LD1Fourv1d;
5497 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
5498 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5499 Opc = AArch64::LD1Twov2d;
5501 }
else if (AArch64::ZPR2RegClass.hasSubClassEq(RC) ||
5502 AArch64::ZPR2StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5504 "Unexpected register load without SVE load instructions");
5505 Opc = AArch64::LDR_ZZXI;
5510 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
5511 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5512 Opc = AArch64::LD1Threev2d;
5514 }
else if (AArch64::ZPR3RegClass.hasSubClassEq(RC)) {
5516 "Unexpected register load without SVE load instructions");
5517 Opc = AArch64::LDR_ZZZXI;
5522 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
5523 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
5524 Opc = AArch64::LD1Fourv2d;
5526 }
else if (AArch64::ZPR4RegClass.hasSubClassEq(RC) ||
5527 AArch64::ZPR4StridedOrContiguousRegClass.hasSubClassEq(RC)) {
5529 "Unexpected register load without SVE load instructions");
5530 Opc = AArch64::LDR_ZZZZXI;
5536 assert(Opc &&
"Unknown register class");
5546 MI.addMemOperand(MMO);
5557 UseMI.getIterator()),
5559 return I.modifiesRegister(AArch64::NZCV, TRI) ||
5560 I.readsRegister(AArch64::NZCV, TRI);
5569 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
5576 ByteSized =
Offset.getFixed();
5577 VGSized =
Offset.getScalable() / 2;
5585 int64_t &NumDataVectors) {
5589 assert(
Offset.getScalable() % 2 == 0 &&
"Invalid frame offset");
5591 NumBytes =
Offset.getFixed();
5593 NumPredicateVectors =
Offset.getScalable() / 2;
5598 if (NumPredicateVectors % 8 == 0 || NumPredicateVectors < -64 ||
5599 NumPredicateVectors > 62) {
5600 NumDataVectors = NumPredicateVectors / 8;
5601 NumPredicateVectors -= NumDataVectors * 8;
5608 int NumVGScaledBytes,
unsigned VG,
5615 Expr.
push_back((uint8_t)dwarf::DW_OP_plus);
5616 Comment << (NumBytes < 0 ?
" - " :
" + ") << std::abs(NumBytes);
5619 if (NumVGScaledBytes) {
5620 Expr.
push_back((uint8_t)dwarf::DW_OP_consts);
5623 Expr.
push_back((uint8_t)dwarf::DW_OP_bregx);
5627 Expr.
push_back((uint8_t)dwarf::DW_OP_mul);
5628 Expr.
push_back((uint8_t)dwarf::DW_OP_plus);
5630 Comment << (NumVGScaledBytes < 0 ?
" - " :
" + ")
5631 << std::abs(NumVGScaledBytes) <<
" * VG";
5640 int64_t NumBytes, NumVGScaledBytes;
5643 std::string CommentBuffer;
5646 if (Reg == AArch64::SP)
5648 else if (Reg == AArch64::FP)
5655 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
5656 Expr.
push_back((uint8_t)(dwarf::DW_OP_breg0 + DwarfReg));
5659 TRI.getDwarfRegNum(AArch64::VG,
true), Comment);
5663 DefCfaExpr.
push_back(dwarf::DW_CFA_def_cfa_expression);
5672 unsigned FrameReg,
unsigned Reg,
5674 bool LastAdjustmentWasScalable) {
5675 if (
Offset.getScalable())
5678 if (FrameReg == Reg && !LastAdjustmentWasScalable)
5681 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
5688 int64_t NumBytes, NumVGScaledBytes;
5690 OffsetFromDefCFA, NumBytes, NumVGScaledBytes);
5692 unsigned DwarfReg =
TRI.getDwarfRegNum(Reg,
true);
5695 if (!NumVGScaledBytes)
5698 std::string CommentBuffer;
5705 TRI.getDwarfRegNum(AArch64::VG,
true), Comment);
5709 CfaExpr.
push_back(dwarf::DW_CFA_expression);
5725 unsigned SrcReg, int64_t
Offset,
unsigned Opc,
5728 bool *HasWinCFI,
bool EmitCFAOffset,
5731 unsigned MaxEncoding, ShiftSize;
5733 case AArch64::ADDXri:
5734 case AArch64::ADDSXri:
5735 case AArch64::SUBXri:
5736 case AArch64::SUBSXri:
5737 MaxEncoding = 0xfff;
5740 case AArch64::ADDVL_XXI:
5741 case AArch64::ADDPL_XXI:
5742 case AArch64::ADDSVL_XXI:
5743 case AArch64::ADDSPL_XXI:
5758 if (Opc == AArch64::ADDVL_XXI || Opc == AArch64::ADDSVL_XXI)
5760 else if (Opc == AArch64::ADDPL_XXI || Opc == AArch64::ADDSPL_XXI)
5774 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
5776 if (TmpReg == AArch64::XZR)
5778 &AArch64::GPR64RegClass);
5780 uint64_t ThisVal = std::min<uint64_t>(
Offset, MaxEncodableValue);
5781 unsigned LocalShiftSize = 0;
5782 if (ThisVal > MaxEncoding) {
5783 ThisVal = ThisVal >> ShiftSize;
5784 LocalShiftSize = ShiftSize;
5786 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
5787 "Encoding cannot handle value that big");
5789 Offset -= ThisVal << LocalShiftSize;
5794 .
addImm(Sign * (
int)ThisVal);
5804 if (Sign == -1 || Opc == AArch64::SUBXri || Opc == AArch64::SUBSXri)
5805 CFAOffset += Change;
5807 CFAOffset -= Change;
5808 if (EmitCFAOffset && DestReg == TmpReg) {
5821 assert(Sign == 1 &&
"SEH directives should always have a positive sign");
5822 int Imm = (int)(ThisVal << LocalShiftSize);
5823 if ((DestReg == AArch64::FP && SrcReg == AArch64::SP) ||
5824 (SrcReg == AArch64::FP && DestReg == AArch64::SP)) {
5833 assert(
Offset == 0 &&
"Expected remaining offset to be zero to "
5834 "emit a single SEH directive");
5835 }
else if (DestReg == AArch64::SP) {
5838 assert(SrcReg == AArch64::SP &&
"Unexpected SrcReg for SEH_StackAlloc");
5851 unsigned DestReg,
unsigned SrcReg,
5854 bool NeedsWinCFI,
bool *HasWinCFI,
5856 unsigned FrameReg) {
5863 bool UseSVL =
F.hasFnAttribute(
"aarch64_pstate_sm_body");
5865 int64_t Bytes, NumPredicateVectors, NumDataVectors;
5867 Offset, Bytes, NumPredicateVectors, NumDataVectors);
5870 if (Bytes || (!
Offset && SrcReg != DestReg)) {
5871 assert((DestReg != AArch64::SP || Bytes % 8 == 0) &&
5872 "SP increment/decrement not 8-byte aligned");
5873 unsigned Opc = SetNZCV ? AArch64::ADDSXri : AArch64::ADDXri;
5876 Opc = SetNZCV ? AArch64::SUBSXri : AArch64::SUBXri;
5879 NeedsWinCFI, HasWinCFI, EmitCFAOffset, CFAOffset,
5881 CFAOffset += (Opc == AArch64::ADDXri || Opc == AArch64::ADDSXri)
5888 assert(!(SetNZCV && (NumPredicateVectors || NumDataVectors)) &&
5889 "SetNZCV not supported with SVE vectors");
5890 assert(!(NeedsWinCFI && (NumPredicateVectors || NumDataVectors)) &&
5891 "WinCFI not supported with SVE vectors");
5893 if (NumDataVectors) {
5895 UseSVL ? AArch64::ADDSVL_XXI : AArch64::ADDVL_XXI,
5896 TII, Flag, NeedsWinCFI,
nullptr, EmitCFAOffset,
5897 CFAOffset, FrameReg);
5902 if (NumPredicateVectors) {
5903 assert(DestReg != AArch64::SP &&
"Unaligned access to SP");
5905 UseSVL ? AArch64::ADDSPL_XXI : AArch64::ADDPL_XXI,
5906 TII, Flag, NeedsWinCFI,
nullptr, EmitCFAOffset,
5907 CFAOffset, FrameReg);
5925 if (
MI.isFullCopy()) {
5928 if (SrcReg == AArch64::SP && DstReg.
isVirtual()) {
5932 if (DstReg == AArch64::SP && SrcReg.
isVirtual()) {
5937 if (SrcReg == AArch64::NZCV || DstReg == AArch64::NZCV)
5965 if (
MI.isCopy() && Ops.
size() == 1 &&
5967 (Ops[0] == 0 || Ops[0] == 1)) {
5968 bool IsSpill = Ops[0] == 0;
5969 bool IsFill = !IsSpill;
5981 :
TRI.getMinimalPhysRegClass(Reg);
5987 "Mismatched register size in non subreg COPY");
5994 return &*--InsertPt;
6006 if (IsSpill && DstMO.
isUndef() && SrcReg == AArch64::WZR &&
6009 "Unexpected subreg on physical register");
6011 FrameIndex, &AArch64::GPR64RegClass, &
TRI,
6013 return &*--InsertPt;
6031 case AArch64::sub_32:
6032 FillRC = &AArch64::GPR32RegClass;
6035 FillRC = &AArch64::FPR32RegClass;
6038 FillRC = &AArch64::FPR64RegClass;
6044 TRI.getRegSizeInBits(*FillRC) &&
6045 "Mismatched regclass size on folded subreg COPY");
6064 bool *OutUseUnscaledOp,
6065 unsigned *OutUnscaledOp,
6066 int64_t *EmittableOffset) {
6068 if (EmittableOffset)
6069 *EmittableOffset = 0;
6070 if (OutUseUnscaledOp)
6071 *OutUseUnscaledOp =
false;
6077 switch (
MI.getOpcode()) {
6080 case AArch64::LD1Rv1d:
6081 case AArch64::LD1Rv2s:
6082 case AArch64::LD1Rv2d:
6083 case AArch64::LD1Rv4h:
6084 case AArch64::LD1Rv4s:
6085 case AArch64::LD1Rv8b:
6086 case AArch64::LD1Rv8h:
6087 case AArch64::LD1Rv16b:
6088 case AArch64::LD1Twov2d:
6089 case AArch64::LD1Threev2d:
6090 case AArch64::LD1Fourv2d:
6091 case AArch64::LD1Twov1d:
6092 case AArch64::LD1Threev1d:
6093 case AArch64::LD1Fourv1d:
6094 case AArch64::ST1Twov2d:
6095 case AArch64::ST1Threev2d:
6096 case AArch64::ST1Fourv2d:
6097 case AArch64::ST1Twov1d:
6098 case AArch64::ST1Threev1d:
6099 case AArch64::ST1Fourv1d:
6100 case AArch64::ST1i8:
6101 case AArch64::ST1i16:
6102 case AArch64::ST1i32:
6103 case AArch64::ST1i64:
6105 case AArch64::IRGstack:
6106 case AArch64::STGloop:
6107 case AArch64::STZGloop:
6112 TypeSize ScaleValue(0U,
false), Width(0U,
false);
6113 int64_t MinOff, MaxOff;
6119 bool IsMulVL = ScaleValue.isScalable();
6120 unsigned Scale = ScaleValue.getKnownMinValue();
6130 std::optional<unsigned> UnscaledOp =
6132 bool useUnscaledOp = UnscaledOp && (
Offset % Scale ||
Offset < 0);
6133 if (useUnscaledOp &&
6138 Scale = ScaleValue.getKnownMinValue();
6139 assert(IsMulVL == ScaleValue.isScalable() &&
6140 "Unscaled opcode has different value for scalable");
6142 int64_t Remainder =
Offset % Scale;
6143 assert(!(Remainder && useUnscaledOp) &&
6144 "Cannot have remainder when using unscaled op");
6146 assert(MinOff < MaxOff &&
"Unexpected Min/Max offsets");
6147 int64_t NewOffset =
Offset / Scale;
6148 if (MinOff <= NewOffset && NewOffset <= MaxOff)
6151 NewOffset = NewOffset < 0 ? MinOff : MaxOff;
6155 if (EmittableOffset)
6156 *EmittableOffset = NewOffset;
6157 if (OutUseUnscaledOp)
6158 *OutUseUnscaledOp = useUnscaledOp;
6159 if (OutUnscaledOp && UnscaledOp)
6160 *OutUnscaledOp = *UnscaledOp;
6173 unsigned Opcode =
MI.getOpcode();
6174 unsigned ImmIdx = FrameRegIdx + 1;
6176 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
6181 MI.eraseFromParent();
6187 unsigned UnscaledOp;
6190 &UnscaledOp, &NewOffset);
6194 MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg,
false);
6196 MI.setDesc(
TII->get(UnscaledOp));
6198 MI.getOperand(ImmIdx).ChangeToImmediate(NewOffset);
6221 case AArch64::ADDSWrr:
6222 case AArch64::ADDSWri:
6223 case AArch64::ADDSXrr:
6224 case AArch64::ADDSXri:
6225 case AArch64::SUBSWrr:
6226 case AArch64::SUBSXrr:
6228 case AArch64::SUBSWri:
6229 case AArch64::SUBSXri:
6240 case AArch64::ADDWrr:
6241 case AArch64::ADDWri:
6242 case AArch64::SUBWrr:
6243 case AArch64::ADDSWrr:
6244 case AArch64::ADDSWri:
6245 case AArch64::SUBSWrr:
6247 case AArch64::SUBWri:
6248 case AArch64::SUBSWri:
6259 case AArch64::ADDXrr:
6260 case AArch64::ADDXri:
6261 case AArch64::SUBXrr:
6262 case AArch64::ADDSXrr:
6263 case AArch64::ADDSXri:
6264 case AArch64::SUBSXrr:
6266 case AArch64::SUBXri:
6267 case AArch64::SUBSXri:
6268 case AArch64::ADDv8i8:
6269 case AArch64::ADDv16i8:
6270 case AArch64::ADDv4i16:
6271 case AArch64::ADDv8i16:
6272 case AArch64::ADDv2i32:
6273 case AArch64::ADDv4i32:
6274 case AArch64::SUBv8i8:
6275 case AArch64::SUBv16i8:
6276 case AArch64::SUBv4i16:
6277 case AArch64::SUBv8i16:
6278 case AArch64::SUBv2i32:
6279 case AArch64::SUBv4i32:
6292 case AArch64::FADDHrr:
6293 case AArch64::FADDSrr:
6294 case AArch64::FADDDrr:
6295 case AArch64::FADDv4f16:
6296 case AArch64::FADDv8f16:
6297 case AArch64::FADDv2f32:
6298 case AArch64::FADDv2f64:
6299 case AArch64::FADDv4f32:
6300 case AArch64::FSUBHrr:
6301 case AArch64::FSUBSrr:
6302 case AArch64::FSUBDrr:
6303 case AArch64::FSUBv4f16:
6304 case AArch64::FSUBv8f16:
6305 case AArch64::FSUBv2f32:
6306 case AArch64::FSUBv2f64:
6307 case AArch64::FSUBv4f32:
6311 return Options.UnsafeFPMath ||
6328 unsigned CombineOpc,
unsigned ZeroReg = 0,
6329 bool CheckZeroReg =
false) {
6336 if (!
MI ||
MI->getParent() != &
MBB || (
unsigned)
MI->getOpcode() != CombineOpc)
6339 if (!
MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()))
6343 assert(
MI->getNumOperands() >= 4 &&
MI->getOperand(0).isReg() &&
6344 MI->getOperand(1).isReg() &&
MI->getOperand(2).isReg() &&
6345 MI->getOperand(3).isReg() &&
"MAdd/MSub must have a least 4 regs");
6347 if (
MI->getOperand(3).getReg() != ZeroReg)
6352 MI->findRegisterDefOperandIdx(AArch64::NZCV,
nullptr,
true) == -1)
6361 unsigned MulOpc,
unsigned ZeroReg) {
6377 bool Invert)
const {
6383 case AArch64::FADDHrr:
6384 case AArch64::FADDSrr:
6385 case AArch64::FADDDrr:
6386 case AArch64::FMULHrr:
6387 case AArch64::FMULSrr:
6388 case AArch64::FMULDrr:
6389 case AArch64::FMULX16:
6390 case AArch64::FMULX32:
6391 case AArch64::FMULX64:
6393 case AArch64::FADDv4f16:
6394 case AArch64::FADDv8f16:
6395 case AArch64::FADDv2f32:
6396 case AArch64::FADDv4f32:
6397 case AArch64::FADDv2f64:
6398 case AArch64::FMULv4f16:
6399 case AArch64::FMULv8f16:
6400 case AArch64::FMULv2f32:
6401 case AArch64::FMULv4f32:
6402 case AArch64::FMULv2f64:
6403 case AArch64::FMULXv4f16:
6404 case AArch64::FMULXv8f16:
6405 case AArch64::FMULXv2f32:
6406 case AArch64::FMULXv4f32:
6407 case AArch64::FMULXv2f64:
6411 case AArch64::FADD_ZZZ_H:
6412 case AArch64::FADD_ZZZ_S:
6413 case AArch64::FADD_ZZZ_D:
6414 case AArch64::FMUL_ZZZ_H:
6415 case AArch64::FMUL_ZZZ_S:
6416 case AArch64::FMUL_ZZZ_D:
6428 case AArch64::ADDWrr:
6429 case AArch64::ADDXrr:
6430 case AArch64::ANDWrr:
6431 case AArch64::ANDXrr:
6432 case AArch64::ORRWrr:
6433 case AArch64::ORRXrr:
6434 case AArch64::EORWrr:
6435 case AArch64::EORXrr:
6436 case AArch64::EONWrr:
6437 case AArch64::EONXrr:
6441 case AArch64::ADDv8i8:
6442 case AArch64::ADDv16i8:
6443 case AArch64::ADDv4i16:
6444 case AArch64::ADDv8i16:
6445 case AArch64::ADDv2i32:
6446 case AArch64::ADDv4i32:
6447 case AArch64::ADDv1i64:
6448 case AArch64::ADDv2i64:
6449 case AArch64::MULv8i8:
6450 case AArch64::MULv16i8:
6451 case AArch64::MULv4i16:
6452 case AArch64::MULv8i16:
6453 case AArch64::MULv2i32:
6454 case AArch64::MULv4i32:
6455 case AArch64::ANDv8i8:
6456 case AArch64::ANDv16i8:
6457 case AArch64::ORRv8i8:
6458 case AArch64::ORRv16i8:
6459 case AArch64::EORv8i8:
6460 case AArch64::EORv16i8:
6462 case AArch64::ADD_ZZZ_B:
6463 case AArch64::ADD_ZZZ_H:
6464 case AArch64::ADD_ZZZ_S:
6465 case AArch64::ADD_ZZZ_D:
6466 case AArch64::MUL_ZZZ_B:
6467 case AArch64::MUL_ZZZ_H:
6468 case AArch64::MUL_ZZZ_S:
6469 case AArch64::MUL_ZZZ_D:
6470 case AArch64::AND_ZZZ:
6471 case AArch64::ORR_ZZZ:
6472 case AArch64::EOR_ZZZ:
6503 auto setFound = [&](
int Opcode,
int Operand,
unsigned ZeroReg,
6511 auto setVFound = [&](
int Opcode,
int Operand,
unsigned Pattern) {
6523 case AArch64::ADDWrr:
6525 "ADDWrr does not have register operands");
6526 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDW_OP1);
6527 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULADDW_OP2);
6529 case AArch64::ADDXrr:
6530 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDX_OP1);
6531 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULADDX_OP2);
6533 case AArch64::SUBWrr:
6534 setFound(AArch64::MADDWrrr, 2, AArch64::WZR, MCP::MULSUBW_OP2);
6535 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBW_OP1);
6537 case AArch64::SUBXrr:
6538 setFound(AArch64::MADDXrrr, 2, AArch64::XZR, MCP::MULSUBX_OP2);
6539 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBX_OP1);
6541 case AArch64::ADDWri:
6542 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULADDWI_OP1);
6544 case AArch64::ADDXri:
6545 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULADDXI_OP1);
6547 case AArch64::SUBWri:
6548 setFound(AArch64::MADDWrrr, 1, AArch64::WZR, MCP::MULSUBWI_OP1);
6550 case AArch64::SUBXri:
6551 setFound(AArch64::MADDXrrr, 1, AArch64::XZR, MCP::MULSUBXI_OP1);
6553 case AArch64::ADDv8i8:
6554 setVFound(AArch64::MULv8i8, 1, MCP::MULADDv8i8_OP1);
6555 setVFound(AArch64::MULv8i8, 2, MCP::MULADDv8i8_OP2);
6557 case AArch64::ADDv16i8:
6558 setVFound(AArch64::MULv16i8, 1, MCP::MULADDv16i8_OP1);
6559 setVFound(AArch64::MULv16i8, 2, MCP::MULADDv16i8_OP2);
6561 case AArch64::ADDv4i16:
6562 setVFound(AArch64::MULv4i16, 1, MCP::MULADDv4i16_OP1);
6563 setVFound(AArch64::MULv4i16, 2, MCP::MULADDv4i16_OP2);
6564 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULADDv4i16_indexed_OP1);
6565 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULADDv4i16_indexed_OP2);
6567 case AArch64::ADDv8i16:
6568 setVFound(AArch64::MULv8i16, 1, MCP::MULADDv8i16_OP1);
6569 setVFound(AArch64::MULv8i16, 2, MCP::MULADDv8i16_OP2);
6570 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULADDv8i16_indexed_OP1);
6571 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULADDv8i16_indexed_OP2);
6573 case AArch64::ADDv2i32:
6574 setVFound(AArch64::MULv2i32, 1, MCP::MULADDv2i32_OP1);
6575 setVFound(AArch64::MULv2i32, 2, MCP::MULADDv2i32_OP2);
6576 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULADDv2i32_indexed_OP1);
6577 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULADDv2i32_indexed_OP2);
6579 case AArch64::ADDv4i32:
6580 setVFound(AArch64::MULv4i32, 1, MCP::MULADDv4i32_OP1);
6581 setVFound(AArch64::MULv4i32, 2, MCP::MULADDv4i32_OP2);
6582 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULADDv4i32_indexed_OP1);
6583 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULADDv4i32_indexed_OP2);
6585 case AArch64::SUBv8i8:
6586 setVFound(AArch64::MULv8i8, 1, MCP::MULSUBv8i8_OP1);
6587 setVFound(AArch64::MULv8i8, 2, MCP::MULSUBv8i8_OP2);
6589 case AArch64::SUBv16i8:
6590 setVFound(AArch64::MULv16i8, 1, MCP::MULSUBv16i8_OP1);
6591 setVFound(AArch64::MULv16i8, 2, MCP::MULSUBv16i8_OP2);
6593 case AArch64::SUBv4i16:
6594 setVFound(AArch64::MULv4i16, 1, MCP::MULSUBv4i16_OP1);
6595 setVFound(AArch64::MULv4i16, 2, MCP::MULSUBv4i16_OP2);
6596 setVFound(AArch64::MULv4i16_indexed, 1, MCP::MULSUBv4i16_indexed_OP1);
6597 setVFound(AArch64::MULv4i16_indexed, 2, MCP::MULSUBv4i16_indexed_OP2);
6599 case AArch64::SUBv8i16:
6600 setVFound(AArch64::MULv8i16, 1, MCP::MULSUBv8i16_OP1);
6601 setVFound(AArch64::MULv8i16, 2, MCP::MULSUBv8i16_OP2);
6602 setVFound(AArch64::MULv8i16_indexed, 1, MCP::MULSUBv8i16_indexed_OP1);
6603 setVFound(AArch64::MULv8i16_indexed, 2, MCP::MULSUBv8i16_indexed_OP2);
6605 case AArch64::SUBv2i32:
6606 setVFound(AArch64::MULv2i32, 1, MCP::MULSUBv2i32_OP1);
6607 setVFound(AArch64::MULv2i32, 2, MCP::MULSUBv2i32_OP2);
6608 setVFound(AArch64::MULv2i32_indexed, 1, MCP::MULSUBv2i32_indexed_OP1);
6609 setVFound(AArch64::MULv2i32_indexed, 2, MCP::MULSUBv2i32_indexed_OP2);
6611 case AArch64::SUBv4i32:
6612 setVFound(AArch64::MULv4i32, 1, MCP::MULSUBv4i32_OP1);
6613 setVFound(AArch64::MULv4i32, 2, MCP::MULSUBv4i32_OP2);
6614 setVFound(AArch64::MULv4i32_indexed, 1, MCP::MULSUBv4i32_indexed_OP1);
6615 setVFound(AArch64::MULv4i32_indexed, 2, MCP::MULSUBv4i32_indexed_OP2);
6632 auto Match = [&](
int Opcode,
int Operand,
unsigned Pattern) ->
bool {
6644 assert(
false &&
"Unsupported FP instruction in combiner\n");
6646 case AArch64::FADDHrr:
6648 "FADDHrr does not have register operands");
6650 Found =
Match(AArch64::FMULHrr, 1, MCP::FMULADDH_OP1);
6651 Found |=
Match(AArch64::FMULHrr, 2, MCP::FMULADDH_OP2);
6653 case AArch64::FADDSrr:
6655 "FADDSrr does not have register operands");
6657 Found |=
Match(AArch64::FMULSrr, 1, MCP::FMULADDS_OP1) ||
6658 Match(AArch64::FMULv1i32_indexed, 1, MCP::FMLAv1i32_indexed_OP1);
6660 Found |=
Match(AArch64::FMULSrr, 2, MCP::FMULADDS_OP2) ||
6661 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLAv1i32_indexed_OP2);
6663 case AArch64::FADDDrr:
6664 Found |=
Match(AArch64::FMULDrr, 1, MCP::FMULADDD_OP1) ||
6665 Match(AArch64::FMULv1i64_indexed, 1, MCP::FMLAv1i64_indexed_OP1);
6667 Found |=
Match(AArch64::FMULDrr, 2, MCP::FMULADDD_OP2) ||
6668 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLAv1i64_indexed_OP2);
6670 case AArch64::FADDv4f16:
6671 Found |=
Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLAv4i16_indexed_OP1) ||
6672 Match(AArch64::FMULv4f16, 1, MCP::FMLAv4f16_OP1);
6674 Found |=
Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLAv4i16_indexed_OP2) ||
6675 Match(AArch64::FMULv4f16, 2, MCP::FMLAv4f16_OP2);
6677 case AArch64::FADDv8f16:
6678 Found |=
Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLAv8i16_indexed_OP1) ||
6679 Match(AArch64::FMULv8f16, 1, MCP::FMLAv8f16_OP1);
6681 Found |=
Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLAv8i16_indexed_OP2) ||
6682 Match(AArch64::FMULv8f16, 2, MCP::FMLAv8f16_OP2);
6684 case AArch64::FADDv2f32:
6685 Found |=
Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLAv2i32_indexed_OP1) ||
6686 Match(AArch64::FMULv2f32, 1, MCP::FMLAv2f32_OP1);
6688 Found |=
Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLAv2i32_indexed_OP2) ||
6689 Match(AArch64::FMULv2f32, 2, MCP::FMLAv2f32_OP2);
6691 case AArch64::FADDv2f64:
6692 Found |=
Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLAv2i64_indexed_OP1) ||
6693 Match(AArch64::FMULv2f64, 1, MCP::FMLAv2f64_OP1);
6695 Found |=
Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLAv2i64_indexed_OP2) ||
6696 Match(AArch64::FMULv2f64, 2, MCP::FMLAv2f64_OP2);
6698 case AArch64::FADDv4f32:
6699 Found |=
Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLAv4i32_indexed_OP1) ||
6700 Match(AArch64::FMULv4f32, 1, MCP::FMLAv4f32_OP1);
6702 Found |=
Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLAv4i32_indexed_OP2) ||
6703 Match(AArch64::FMULv4f32, 2, MCP::FMLAv4f32_OP2);
6705 case AArch64::FSUBHrr:
6706 Found =
Match(AArch64::FMULHrr, 1, MCP::FMULSUBH_OP1);
6707 Found |=
Match(AArch64::FMULHrr, 2, MCP::FMULSUBH_OP2);
6708 Found |=
Match(AArch64::FNMULHrr, 1, MCP::FNMULSUBH_OP1);
6710 case AArch64::FSUBSrr:
6711 Found =
Match(AArch64::FMULSrr, 1, MCP::FMULSUBS_OP1);
6713 Found |=
Match(AArch64::FMULSrr, 2, MCP::FMULSUBS_OP2) ||
6714 Match(AArch64::FMULv1i32_indexed, 2, MCP::FMLSv1i32_indexed_OP2);
6716 Found |=
Match(AArch64::FNMULSrr, 1, MCP::FNMULSUBS_OP1);
6718 case AArch64::FSUBDrr:
6719 Found =
Match(AArch64::FMULDrr, 1, MCP::FMULSUBD_OP1);
6721 Found |=
Match(AArch64::FMULDrr, 2, MCP::FMULSUBD_OP2) ||
6722 Match(AArch64::FMULv1i64_indexed, 2, MCP::FMLSv1i64_indexed_OP2);
6724 Found |=
Match(AArch64::FNMULDrr, 1, MCP::FNMULSUBD_OP1);
6726 case AArch64::FSUBv4f16:
6727 Found |=
Match(AArch64::FMULv4i16_indexed, 2, MCP::FMLSv4i16_indexed_OP2) ||
6728 Match(AArch64::FMULv4f16, 2, MCP::FMLSv4f16_OP2);
6730 Found |=
Match(AArch64::FMULv4i16_indexed, 1, MCP::FMLSv4i16_indexed_OP1) ||
6731 Match(AArch64::FMULv4f16, 1, MCP::FMLSv4f16_OP1);
6733 case AArch64::FSUBv8f16:
6734 Found |=
Match(AArch64::FMULv8i16_indexed, 2, MCP::FMLSv8i16_indexed_OP2) ||
6735 Match(AArch64::FMULv8f16, 2, MCP::FMLSv8f16_OP2);
6737 Found |=
Match(AArch64::FMULv8i16_indexed, 1, MCP::FMLSv8i16_indexed_OP1) ||
6738 Match(AArch64::FMULv8f16, 1, MCP::FMLSv8f16_OP1);
6740 case AArch64::FSUBv2f32:
6741 Found |=
Match(AArch64::FMULv2i32_indexed, 2, MCP::FMLSv2i32_indexed_OP2) ||
6742 Match(AArch64::FMULv2f32, 2, MCP::FMLSv2f32_OP2);
6744 Found |=
Match(AArch64::FMULv2i32_indexed, 1, MCP::FMLSv2i32_indexed_OP1) ||
6745 Match(AArch64::FMULv2f32, 1, MCP::FMLSv2f32_OP1);
6747 case AArch64::FSUBv2f64:
6748 Found |=
Match(AArch64::FMULv2i64_indexed, 2, MCP::FMLSv2i64_indexed_OP2) ||
6749 Match(AArch64::FMULv2f64, 2, MCP::FMLSv2f64_OP2);
6751 Found |=
Match(AArch64::FMULv2i64_indexed, 1, MCP::FMLSv2i64_indexed_OP1) ||
6752 Match(AArch64::FMULv2f64, 1, MCP::FMLSv2f64_OP1);
6754 case AArch64::FSUBv4f32:
6755 Found |=
Match(AArch64::FMULv4i32_indexed, 2, MCP::FMLSv4i32_indexed_OP2) ||
6756 Match(AArch64::FMULv4f32, 2, MCP::FMLSv4f32_OP2);
6758 Found |=
Match(AArch64::FMULv4i32_indexed, 1, MCP::FMLSv4i32_indexed_OP1) ||
6759 Match(AArch64::FMULv4f32, 1, MCP::FMLSv4f32_OP1);
6770 auto Match = [&](
unsigned Opcode,
int Operand,
unsigned Pattern) ->
bool {
6777 if (
MI &&
MI->getOpcode() == TargetOpcode::COPY &&
6778 MI->getOperand(1).getReg().isVirtual())
6779 MI =
MRI.getUniqueVRegDef(
MI->getOperand(1).getReg());
6780 if (
MI &&
MI->getOpcode() == Opcode) {
6792 case AArch64::FMULv2f32:
6793 Found =
Match(AArch64::DUPv2i32lane, 1, MCP::FMULv2i32_indexed_OP1);
6794 Found |=
Match(AArch64::DUPv2i32lane, 2, MCP::FMULv2i32_indexed_OP2);
6796 case AArch64::FMULv2f64:
6797 Found =
Match(AArch64::DUPv2i64lane, 1, MCP::FMULv2i64_indexed_OP1);
6798 Found |=
Match(AArch64::DUPv2i64lane, 2, MCP::FMULv2i64_indexed_OP2);
6800 case AArch64::FMULv4f16:
6801 Found =
Match(AArch64::DUPv4i16lane, 1, MCP::FMULv4i16_indexed_OP1);
6802 Found |=
Match(AArch64::DUPv4i16lane, 2, MCP::FMULv4i16_indexed_OP2);
6804 case AArch64::FMULv4f32:
6805 Found =
Match(AArch64::DUPv4i32lane, 1, MCP::FMULv4i32_indexed_OP1);
6806 Found |=
Match(AArch64::DUPv4i32lane, 2, MCP::FMULv4i32_indexed_OP2);
6808 case AArch64::FMULv8f16:
6809 Found =
Match(AArch64::DUPv8i16lane, 1, MCP::FMULv8i16_indexed_OP1);
6810 Found |=
Match(AArch64::DUPv8i16lane, 2, MCP::FMULv8i16_indexed_OP2);
6823 auto Match = [&](
unsigned Opcode,
unsigned Pattern) ->
bool {
6826 if (
MI !=
nullptr && (
MI->getOpcode() == Opcode) &&
6827 MRI.hasOneNonDBGUse(
MI->getOperand(0).getReg()) &&
6841 case AArch64::FNEGDr:
6843 case AArch64::FNEGSr:
6975 case AArch64::SUBWrr:
6976 case AArch64::SUBSWrr:
6977 case AArch64::SUBXrr:
6978 case AArch64::SUBSXrr:
7020 bool DoRegPressureReduce)
const {
7037 DoRegPressureReduce);
7066 const Register *ReplacedAddend =
nullptr) {
7067 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
7069 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
7072 Register SrcReg0 = MUL->getOperand(1).getReg();
7073 bool Src0IsKill = MUL->getOperand(1).isKill();
7074 Register SrcReg1 = MUL->getOperand(2).getReg();
7075 bool Src1IsKill = MUL->getOperand(2).isKill();
7079 if (ReplacedAddend) {
7081 SrcReg2 = *ReplacedAddend;
7089 MRI.constrainRegClass(ResultReg, RC);
7091 MRI.constrainRegClass(SrcReg0, RC);
7093 MRI.constrainRegClass(SrcReg1, RC);
7095 MRI.constrainRegClass(SrcReg2, RC);
7098 if (kind == FMAInstKind::Default)
7103 else if (kind == FMAInstKind::Indexed)
7108 .
addImm(MUL->getOperand(3).getImm());
7109 else if (kind == FMAInstKind::Accumulator)
7115 assert(
false &&
"Invalid FMA instruction kind \n");
7129 if (AArch64::FPR32RegClass.hasSubClassEq(RC))
7130 Opc = AArch64::FNMADDSrrr;
7131 else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
7132 Opc = AArch64::FNMADDDrrr;
7144 MRI.constrainRegClass(ResultReg, RC);
7146 MRI.constrainRegClass(SrcReg0, RC);
7148 MRI.constrainRegClass(SrcReg1, RC);
7150 MRI.constrainRegClass(SrcReg2, RC);
7166 unsigned IdxDupOp,
unsigned MulOpc,
7168 assert(((IdxDupOp == 1) || (IdxDupOp == 2)) &&
7169 "Invalid index of FMUL operand");
7177 if (Dup->
getOpcode() == TargetOpcode::COPY)
7181 MRI.clearKillFlags(DupSrcReg);
7182 MRI.constrainRegClass(DupSrcReg, RC);
7186 unsigned IdxMulOp = IdxDupOp == 1 ? 2 : 1;
7210 FMAInstKind::Accumulator);
7227 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
7242 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
7244 FMAInstKind::Accumulator, &NewVR);
7256 FMAInstKind::Indexed);
7269 genNeg(MF,
MRI,
TII, Root, InsInstrs, InstrIdxForVirtReg, MnegOpc, RC);
7272 FMAInstKind::Indexed, &NewVR);
7297 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
7299 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
7303 Register SrcReg0 = MUL->getOperand(1).getReg();
7304 bool Src0IsKill = MUL->getOperand(1).isKill();
7305 Register SrcReg1 = MUL->getOperand(2).getReg();
7306 bool Src1IsKill = MUL->getOperand(2).isKill();
7309 MRI.constrainRegClass(ResultReg, RC);
7311 MRI.constrainRegClass(SrcReg0, RC);
7313 MRI.constrainRegClass(SrcReg1, RC);
7315 MRI.constrainRegClass(VR, RC);
7337 assert(IdxOpd1 == 1 || IdxOpd1 == 2);
7338 unsigned IdxOtherOpd = IdxOpd1 == 1 ? 2 : 1;
7348 Register NewVR =
MRI.createVirtualRegister(
MRI.getRegClass(RegA));
7351 if (Opcode == AArch64::SUBSWrr)
7352 Opcode = AArch64::SUBWrr;
7353 else if (Opcode == AArch64::SUBSXrr)
7354 Opcode = AArch64::SUBXrr;
7356 assert((Opcode == AArch64::SUBWrr || Opcode == AArch64::SUBXrr) &&
7357 "Unexpected instruction opcode.");
7374 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
7401 DelInstrs, InstrIdxForVirtReg);
7407 InstrIdxForVirtReg);
7413 InstrIdxForVirtReg);
7422 Opc = AArch64::MADDWrrr;
7423 RC = &AArch64::GPR32RegClass;
7425 Opc = AArch64::MADDXrrr;
7426 RC = &AArch64::GPR64RegClass;
7437 Opc = AArch64::MADDWrrr;
7438 RC = &AArch64::GPR32RegClass;
7440 Opc = AArch64::MADDXrrr;
7441 RC = &AArch64::GPR64RegClass;
7453 unsigned BitSize, OrrOpc, ZeroReg;
7455 OrrOpc = AArch64::ORRWri;
7456 OrrRC = &AArch64::GPR32spRegClass;
7458 ZeroReg = AArch64::WZR;
7459 Opc = AArch64::MADDWrrr;
7460 RC = &AArch64::GPR32RegClass;
7462 OrrOpc = AArch64::ORRXri;
7463 OrrRC = &AArch64::GPR64spRegClass;
7465 ZeroReg = AArch64::XZR;
7466 Opc = AArch64::MADDXrrr;
7467 RC = &AArch64::GPR64RegClass;
7469 Register NewVR =
MRI.createVirtualRegister(OrrRC);
7480 if (
Insn.size() != 1)
7482 auto MovI =
Insn.begin();
7485 if (MovI->Opcode == OrrOpc)
7491 assert((MovI->Opcode == AArch64::MOVNWi ||
7492 MovI->Opcode == AArch64::MOVZWi) &&
7495 assert((MovI->Opcode == AArch64::MOVNXi ||
7496 MovI->Opcode == AArch64::MOVZXi) &&
7503 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
7504 MUL =
genMaddR(MF,
MRI,
TII, Root, InsInstrs, 1, Opc, NewVR, RC);
7515 unsigned SubOpc, ZeroReg;
7517 SubOpc = AArch64::SUBWrr;
7518 SubRC = &AArch64::GPR32spRegClass;
7519 ZeroReg = AArch64::WZR;
7520 Opc = AArch64::MADDWrrr;
7521 RC = &AArch64::GPR32RegClass;
7523 SubOpc = AArch64::SUBXrr;
7524 SubRC = &AArch64::GPR64spRegClass;
7525 ZeroReg = AArch64::XZR;
7526 Opc = AArch64::MADDXrrr;
7527 RC = &AArch64::GPR64RegClass;
7529 Register NewVR =
MRI.createVirtualRegister(SubRC);
7536 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
7537 MUL =
genMaddR(MF,
MRI,
TII, Root, InsInstrs, 1, Opc, NewVR, RC);
7547 Opc = AArch64::MSUBWrrr;
7548 RC = &AArch64::GPR32RegClass;
7550 Opc = AArch64::MSUBXrrr;
7551 RC = &AArch64::GPR64RegClass;
7563 unsigned BitSize, OrrOpc, ZeroReg;
7565 OrrOpc = AArch64::ORRWri;
7566 OrrRC = &AArch64::GPR32spRegClass;
7568 ZeroReg = AArch64::WZR;
7569 Opc = AArch64::MADDWrrr;
7570 RC = &AArch64::GPR32RegClass;
7572 OrrOpc = AArch64::ORRXri;
7573 OrrRC = &AArch64::GPR64spRegClass;
7575 ZeroReg = AArch64::XZR;
7576 Opc = AArch64::MADDXrrr;
7577 RC = &AArch64::GPR64RegClass;
7579 Register NewVR =
MRI.createVirtualRegister(OrrRC);
7589 if (
Insn.size() != 1)
7591 auto MovI =
Insn.begin();
7594 if (MovI->Opcode == OrrOpc)
7600 assert((MovI->Opcode == AArch64::MOVNWi ||
7601 MovI->Opcode == AArch64::MOVZWi) &&
7604 assert((MovI->Opcode == AArch64::MOVNXi ||
7605 MovI->Opcode == AArch64::MOVZXi) &&
7612 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
7613 MUL =
genMaddR(MF,
MRI,
TII, Root, InsInstrs, 1, Opc, NewVR, RC);
7618 Opc = AArch64::MLAv8i8;
7619 RC = &AArch64::FPR64RegClass;
7623 Opc = AArch64::MLAv8i8;
7624 RC = &AArch64::FPR64RegClass;
7628 Opc = AArch64::MLAv16i8;
7629 RC = &AArch64::FPR128RegClass;
7633 Opc = AArch64::MLAv16i8;
7634 RC = &AArch64::FPR128RegClass;
7638 Opc = AArch64::MLAv4i16;
7639 RC = &AArch64::FPR64RegClass;
7643 Opc = AArch64::MLAv4i16;
7644 RC = &AArch64::FPR64RegClass;
7648 Opc = AArch64::MLAv8i16;
7649 RC = &AArch64::FPR128RegClass;
7653 Opc = AArch64::MLAv8i16;
7654 RC = &AArch64::FPR128RegClass;
7658 Opc = AArch64::MLAv2i32;
7659 RC = &AArch64::FPR64RegClass;
7663 Opc = AArch64::MLAv2i32;
7664 RC = &AArch64::FPR64RegClass;
7668 Opc = AArch64::MLAv4i32;
7669 RC = &AArch64::FPR128RegClass;
7673 Opc = AArch64::MLAv4i32;
7674 RC = &AArch64::FPR128RegClass;
7679 Opc = AArch64::MLAv8i8;
7680 RC = &AArch64::FPR64RegClass;
7682 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i8,
7686 Opc = AArch64::MLSv8i8;
7687 RC = &AArch64::FPR64RegClass;
7691 Opc = AArch64::MLAv16i8;
7692 RC = &AArch64::FPR128RegClass;
7694 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv16i8,
7698 Opc = AArch64::MLSv16i8;
7699 RC = &AArch64::FPR128RegClass;
7703 Opc = AArch64::MLAv4i16;
7704 RC = &AArch64::FPR64RegClass;
7706 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i16,
7710 Opc = AArch64::MLSv4i16;
7711 RC = &AArch64::FPR64RegClass;
7715 Opc = AArch64::MLAv8i16;
7716 RC = &AArch64::FPR128RegClass;
7718 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i16,
7722 Opc = AArch64::MLSv8i16;
7723 RC = &AArch64::FPR128RegClass;
7727 Opc = AArch64::MLAv2i32;
7728 RC = &AArch64::FPR64RegClass;
7730 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv2i32,
7734 Opc = AArch64::MLSv2i32;
7735 RC = &AArch64::FPR64RegClass;
7739 Opc = AArch64::MLAv4i32;
7740 RC = &AArch64::FPR128RegClass;
7742 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i32,
7746 Opc = AArch64::MLSv4i32;
7747 RC = &AArch64::FPR128RegClass;
7752 Opc = AArch64::MLAv4i16_indexed;
7753 RC = &AArch64::FPR64RegClass;
7757 Opc = AArch64::MLAv4i16_indexed;
7758 RC = &AArch64::FPR64RegClass;
7762 Opc = AArch64::MLAv8i16_indexed;
7763 RC = &AArch64::FPR128RegClass;
7767 Opc = AArch64::MLAv8i16_indexed;
7768 RC = &AArch64::FPR128RegClass;
7772 Opc = AArch64::MLAv2i32_indexed;
7773 RC = &AArch64::FPR64RegClass;
7777 Opc = AArch64::MLAv2i32_indexed;
7778 RC = &AArch64::FPR64RegClass;
7782 Opc = AArch64::MLAv4i32_indexed;
7783 RC = &AArch64::FPR128RegClass;
7787 Opc = AArch64::MLAv4i32_indexed;
7788 RC = &AArch64::FPR128RegClass;
7793 Opc = AArch64::MLAv4i16_indexed;
7794 RC = &AArch64::FPR64RegClass;
7796 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i16,
7800 Opc = AArch64::MLSv4i16_indexed;
7801 RC = &AArch64::FPR64RegClass;
7805 Opc = AArch64::MLAv8i16_indexed;
7806 RC = &AArch64::FPR128RegClass;
7808 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv8i16,
7812 Opc = AArch64::MLSv8i16_indexed;
7813 RC = &AArch64::FPR128RegClass;
7817 Opc = AArch64::MLAv2i32_indexed;
7818 RC = &AArch64::FPR64RegClass;
7820 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv2i32,
7824 Opc = AArch64::MLSv2i32_indexed;
7825 RC = &AArch64::FPR64RegClass;
7829 Opc = AArch64::MLAv4i32_indexed;
7830 RC = &AArch64::FPR128RegClass;
7832 InstrIdxForVirtReg, 1, Opc, AArch64::NEGv4i32,
7836 Opc = AArch64::MLSv4i32_indexed;
7837 RC = &AArch64::FPR128RegClass;
7843 Opc = AArch64::FMADDHrrr;
7844 RC = &AArch64::FPR16RegClass;
7848 Opc = AArch64::FMADDSrrr;
7849 RC = &AArch64::FPR32RegClass;
7853 Opc = AArch64::FMADDDrrr;
7854 RC = &AArch64::FPR64RegClass;
7859 Opc = AArch64::FMADDHrrr;
7860 RC = &AArch64::FPR16RegClass;
7864 Opc = AArch64::FMADDSrrr;
7865 RC = &AArch64::FPR32RegClass;
7869 Opc = AArch64::FMADDDrrr;
7870 RC = &AArch64::FPR64RegClass;
7875 Opc = AArch64::FMLAv1i32_indexed;
7876 RC = &AArch64::FPR32RegClass;
7878 FMAInstKind::Indexed);
7881 Opc = AArch64::FMLAv1i32_indexed;
7882 RC = &AArch64::FPR32RegClass;
7884 FMAInstKind::Indexed);
7888 Opc = AArch64::FMLAv1i64_indexed;
7889 RC = &AArch64::FPR64RegClass;
7891 FMAInstKind::Indexed);
7894 Opc = AArch64::FMLAv1i64_indexed;
7895 RC = &AArch64::FPR64RegClass;
7897 FMAInstKind::Indexed);
7901 RC = &AArch64::FPR64RegClass;
7902 Opc = AArch64::FMLAv4i16_indexed;
7904 FMAInstKind::Indexed);
7907 RC = &AArch64::FPR64RegClass;
7908 Opc = AArch64::FMLAv4f16;
7910 FMAInstKind::Accumulator);
7913 RC = &AArch64::FPR64RegClass;
7914 Opc = AArch64::FMLAv4i16_indexed;
7916 FMAInstKind::Indexed);
7919 RC = &AArch64::FPR64RegClass;
7920 Opc = AArch64::FMLAv4f16;
7922 FMAInstKind::Accumulator);
7927 RC = &AArch64::FPR64RegClass;
7929 Opc = AArch64::FMLAv2i32_indexed;
7931 FMAInstKind::Indexed);
7933 Opc = AArch64::FMLAv2f32;
7935 FMAInstKind::Accumulator);
7940 RC = &AArch64::FPR64RegClass;
7942 Opc = AArch64::FMLAv2i32_indexed;
7944 FMAInstKind::Indexed);
7946 Opc = AArch64::FMLAv2f32;
7948 FMAInstKind::Accumulator);
7953 RC = &AArch64::FPR128RegClass;
7954 Opc = AArch64::FMLAv8i16_indexed;
7956 FMAInstKind::Indexed);
7959 RC = &AArch64::FPR128RegClass;
7960 Opc = AArch64::FMLAv8f16;
7962 FMAInstKind::Accumulator);
7965 RC = &AArch64::FPR128RegClass;
7966 Opc = AArch64::FMLAv8i16_indexed;
7968 FMAInstKind::Indexed);
7971 RC = &AArch64::FPR128RegClass;
7972 Opc = AArch64::FMLAv8f16;
7974 FMAInstKind::Accumulator);
7979 RC = &AArch64::FPR128RegClass;
7981 Opc = AArch64::FMLAv2i64_indexed;
7983 FMAInstKind::Indexed);
7985 Opc = AArch64::FMLAv2f64;
7987 FMAInstKind::Accumulator);
7992 RC = &AArch64::FPR128RegClass;
7994 Opc = AArch64::FMLAv2i64_indexed;
7996 FMAInstKind::Indexed);
7998 Opc = AArch64::FMLAv2f64;
8000 FMAInstKind::Accumulator);
8006 RC = &AArch64::FPR128RegClass;
8008 Opc = AArch64::FMLAv4i32_indexed;
8010 FMAInstKind::Indexed);
8012 Opc = AArch64::FMLAv4f32;
8014 FMAInstKind::Accumulator);
8020 RC = &AArch64::FPR128RegClass;
8022 Opc = AArch64::FMLAv4i32_indexed;
8024 FMAInstKind::Indexed);
8026 Opc = AArch64::FMLAv4f32;
8028 FMAInstKind::Accumulator);
8033 Opc = AArch64::FNMSUBHrrr;
8034 RC = &AArch64::FPR16RegClass;
8038 Opc = AArch64::FNMSUBSrrr;
8039 RC = &AArch64::FPR32RegClass;
8043 Opc = AArch64::FNMSUBDrrr;
8044 RC = &AArch64::FPR64RegClass;
8049 Opc = AArch64::FNMADDHrrr;
8050 RC = &AArch64::FPR16RegClass;
8054 Opc = AArch64::FNMADDSrrr;
8055 RC = &AArch64::FPR32RegClass;
8059 Opc = AArch64::FNMADDDrrr;
8060 RC = &AArch64::FPR64RegClass;
8065 Opc = AArch64::FMSUBHrrr;
8066 RC = &AArch64::FPR16RegClass;
8070 Opc = AArch64::FMSUBSrrr;
8071 RC = &AArch64::FPR32RegClass;
8075 Opc = AArch64::FMSUBDrrr;
8076 RC = &AArch64::FPR64RegClass;
8081 Opc = AArch64::FMLSv1i32_indexed;
8082 RC = &AArch64::FPR32RegClass;
8084 FMAInstKind::Indexed);
8088 Opc = AArch64::FMLSv1i64_indexed;
8089 RC = &AArch64::FPR64RegClass;
8091 FMAInstKind::Indexed);
8096 RC = &AArch64::FPR64RegClass;
8102 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8104 Opc = AArch64::FMLAv4f16;
8106 FMAInstKind::Accumulator, &NewVR);
8108 Opc = AArch64::FMLAv4i16_indexed;
8110 FMAInstKind::Indexed, &NewVR);
8115 RC = &AArch64::FPR64RegClass;
8116 Opc = AArch64::FMLSv4f16;
8118 FMAInstKind::Accumulator);
8121 RC = &AArch64::FPR64RegClass;
8122 Opc = AArch64::FMLSv4i16_indexed;
8124 FMAInstKind::Indexed);
8129 RC = &AArch64::FPR64RegClass;
8131 Opc = AArch64::FMLSv2i32_indexed;
8133 FMAInstKind::Indexed);
8135 Opc = AArch64::FMLSv2f32;
8137 FMAInstKind::Accumulator);
8143 RC = &AArch64::FPR128RegClass;
8149 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8151 Opc = AArch64::FMLAv8f16;
8153 FMAInstKind::Accumulator, &NewVR);
8155 Opc = AArch64::FMLAv8i16_indexed;
8157 FMAInstKind::Indexed, &NewVR);
8162 RC = &AArch64::FPR128RegClass;
8163 Opc = AArch64::FMLSv8f16;
8165 FMAInstKind::Accumulator);
8168 RC = &AArch64::FPR128RegClass;
8169 Opc = AArch64::FMLSv8i16_indexed;
8171 FMAInstKind::Indexed);
8176 RC = &AArch64::FPR128RegClass;
8178 Opc = AArch64::FMLSv2i64_indexed;
8180 FMAInstKind::Indexed);
8182 Opc = AArch64::FMLSv2f64;
8184 FMAInstKind::Accumulator);
8190 RC = &AArch64::FPR128RegClass;
8192 Opc = AArch64::FMLSv4i32_indexed;
8194 FMAInstKind::Indexed);
8196 Opc = AArch64::FMLSv4f32;
8198 FMAInstKind::Accumulator);
8203 RC = &AArch64::FPR64RegClass;
8209 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8211 Opc = AArch64::FMLAv2i32_indexed;
8213 FMAInstKind::Indexed, &NewVR);
8215 Opc = AArch64::FMLAv2f32;
8217 FMAInstKind::Accumulator, &NewVR);
8223 RC = &AArch64::FPR128RegClass;
8229 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8231 Opc = AArch64::FMLAv4i32_indexed;
8233 FMAInstKind::Indexed, &NewVR);
8235 Opc = AArch64::FMLAv4f32;
8237 FMAInstKind::Accumulator, &NewVR);
8243 RC = &AArch64::FPR128RegClass;
8249 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
8251 Opc = AArch64::FMLAv2i64_indexed;
8253 FMAInstKind::Indexed, &NewVR);
8255 Opc = AArch64::FMLAv2f64;
8257 FMAInstKind::Accumulator, &NewVR);
8267 &AArch64::FPR128RegClass,
MRI);
8276 &AArch64::FPR128RegClass,
MRI);
8285 &AArch64::FPR128_loRegClass,
MRI);
8294 &AArch64::FPR128RegClass,
MRI);
8303 &AArch64::FPR128_loRegClass,
MRI);
8322 for (
auto *
MI : InsInstrs)
8323 MI->setFlags(Flags);
8364 bool IsNegativeBranch =
false;
8365 bool IsTestAndBranch =
false;
8366 unsigned TargetBBInMI = 0;
8367 switch (
MI.getOpcode()) {
8376 case AArch64::CBNZW:
8377 case AArch64::CBNZX:
8379 IsNegativeBranch =
true;
8384 IsTestAndBranch =
true;
8386 case AArch64::TBNZW:
8387 case AArch64::TBNZX:
8389 IsNegativeBranch =
true;
8390 IsTestAndBranch =
true;
8396 if (IsTestAndBranch &&
MI.getOperand(1).getImm())
8400 assert(
MI.getParent() &&
"Incomplete machine instruciton\n");
8413 if (!
MRI->hasOneNonDBGUse(CopyVReg))
8415 if (!
MRI->hasOneDef(CopyVReg))
8424 case AArch64::ANDWri:
8425 case AArch64::ANDXri: {
8426 if (IsTestAndBranch)
8430 if (!
MRI->hasOneNonDBGUse(VReg))
8444 assert(!
MRI->def_empty(NewReg) &&
"Register must be defined.");
8450 unsigned Opc = (Imm < 32)
8451 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
8452 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
8465 if (!Is32Bit && Imm < 32)
8467 MI.eraseFromParent();
8471 case AArch64::CSINCWr:
8472 case AArch64::CSINCXr: {
8492 if (IsNegativeBranch)
8495 MI.eraseFromParent();
8501std::pair<unsigned, unsigned>
8504 return std::make_pair(TF & Mask, TF & ~Mask);
8509 using namespace AArch64II;
8511 static const std::pair<unsigned, const char *> TargetFlags[] = {
8512 {MO_PAGE,
"aarch64-page"}, {MO_PAGEOFF,
"aarch64-pageoff"},
8513 {MO_G3,
"aarch64-g3"}, {MO_G2,
"aarch64-g2"},
8514 {MO_G1,
"aarch64-g1"}, {MO_G0,
"aarch64-g0"},
8515 {MO_HI12,
"aarch64-hi12"}};
8521 using namespace AArch64II;
8523 static const std::pair<unsigned, const char *> TargetFlags[] = {
8524 {MO_COFFSTUB,
"aarch64-coffstub"},
8525 {MO_GOT,
"aarch64-got"},
8526 {MO_NC,
"aarch64-nc"},
8527 {MO_S,
"aarch64-s"},
8528 {MO_TLS,
"aarch64-tls"},
8529 {MO_DLLIMPORT,
"aarch64-dllimport"},
8530 {MO_PREL,
"aarch64-prel"},
8531 {MO_TAGGED,
"aarch64-tagged"},
8532 {MO_ARM64EC_CALLMANGLE,
"aarch64-arm64ec-callmangle"},
8539 static const std::pair<MachineMemOperand::Flags, const char *> TargetFlags[] =
8647 for (
unsigned Reg : AArch64::GPR64RegClass) {
8649 Reg != AArch64::LR &&
8650 Reg != AArch64::X16 &&
8651 Reg != AArch64::X17 &&
8652 C.isAvailableAcrossAndOutOfSeq(
Reg,
TRI) &&
8653 C.isAvailableInsideSeq(
Reg,
TRI))
8684 return SubtargetA.hasV8_3aOps() == SubtargetB.hasV8_3aOps();
8687std::optional<outliner::OutlinedFunction>
8690 std::vector<outliner::Candidate> &RepeatedSequenceLocs)
const {
8691 unsigned SequenceSize = 0;
8692 for (
auto &
MI : RepeatedSequenceLocs[0])
8695 unsigned NumBytesToCreateFrame = 0;
8705 if (std::adjacent_find(
8706 RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
8710 if (outliningCandidatesSigningScopeConsensus(a, b) &&
8711 outliningCandidatesSigningKeyConsensus(a, b) &&
8712 outliningCandidatesV8_3OpsConsensus(a, b)) {
8716 }) != RepeatedSequenceLocs.end()) {
8717 return std::nullopt;
8734 unsigned NumBytesToCheckLRInTCEpilogue = 0;
8735 if (RepeatedSequenceLocs[0]
8737 ->getInfo<AArch64FunctionInfo>()
8738 ->shouldSignReturnAddress(
true)) {
8740 NumBytesToCreateFrame += 8;
8743 auto LRCheckMethod = Subtarget.getAuthenticatedLRCheckMethod(
8744 *RepeatedSequenceLocs[0].getMF());
8745 NumBytesToCheckLRInTCEpilogue =
8749 if (isTailCallReturnInst(RepeatedSequenceLocs[0].back()))
8750 SequenceSize += NumBytesToCheckLRInTCEpilogue;
8758 for (
auto &
MI :
C) {
8759 if (
MI.modifiesRegister(AArch64::SP, &
TRI)) {
8760 switch (
MI.getOpcode()) {
8761 case AArch64::ADDXri:
8762 case AArch64::ADDWri:
8763 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
8765 "Expected operand to be immediate");
8767 "Expected operand to be a register");
8771 if (
MI.getOperand(1).getReg() == AArch64::SP)
8772 SPValue +=
MI.getOperand(2).getImm();
8776 case AArch64::SUBXri:
8777 case AArch64::SUBWri:
8778 assert(
MI.getNumOperands() == 4 &&
"Wrong number of operands");
8780 "Expected operand to be immediate");
8782 "Expected operand to be a register");
8786 if (
MI.getOperand(1).getReg() == AArch64::SP)
8787 SPValue -=
MI.getOperand(2).getImm();
8804 if (RepeatedSequenceLocs.size() < 2)
8805 return std::nullopt;
8809 unsigned FlagsSetInAll = 0xF;
8813 FlagsSetInAll &=
C.Flags;
8815 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back().getOpcode();
8818 auto SetCandidateCallInfo =
8819 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
8821 C.setCallInfo(CallID, NumBytesForCall);
8825 NumBytesToCreateFrame += 4;
8828 return C.getMF()->getInfo<AArch64FunctionInfo>()->branchTargetEnforcement();
8833 unsigned CFICount = 0;
8834 for (
auto &
I : RepeatedSequenceLocs[0]) {
8835 if (
I.isCFIInstruction())
8845 std::vector<MCCFIInstruction> CFIInstructions =
8846 C.getMF()->getFrameInstructions();
8848 if (CFICount > 0 && CFICount != CFIInstructions.size())
8849 return std::nullopt;
8857 if (!
MI.modifiesRegister(AArch64::SP, &
TRI) &&
8858 !
MI.readsRegister(AArch64::SP, &
TRI))
8864 if (
MI.modifiesRegister(AArch64::SP, &
TRI))
8869 if (
MI.mayLoadOrStore()) {
8872 bool OffsetIsScalable;
8876 if (!getMemOperandWithOffset(
MI,
Base,
Offset, OffsetIsScalable, &
TRI) ||
8877 !
Base->isReg() ||
Base->getReg() != AArch64::SP)
8881 if (OffsetIsScalable)
8889 TypeSize Scale(0U,
false), DummyWidth(0U,
false);
8890 getMemOpInfo(
MI.getOpcode(), Scale, DummyWidth, MinOffset, MaxOffset);
8893 if (
Offset < MinOffset * (int64_t)Scale.getFixedValue() ||
8894 Offset > MaxOffset * (int64_t)Scale.getFixedValue())
8909 bool AllStackInstrsSafe =
8914 if (RepeatedSequenceLocs[0].back().isTerminator()) {
8916 NumBytesToCreateFrame = 0;
8917 unsigned NumBytesForCall = 4 + NumBytesToCheckLRInTCEpilogue;
8921 else if (LastInstrOpcode == AArch64::BL ||
8922 ((LastInstrOpcode == AArch64::BLR ||
8923 LastInstrOpcode == AArch64::BLRNoIP) &&
8927 NumBytesToCreateFrame = NumBytesToCheckLRInTCEpilogue;
8935 unsigned NumBytesNoStackCalls = 0;
8936 std::vector<outliner::Candidate> CandidatesWithoutStackFixups;
8941 (
C.Flags & MachineOutlinerMBBFlags::LRUnavailableSomewhere)
8942 ?
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI)
8951 C.getMF()->getFunction().hasFnAttribute(Attribute::NoReturn);
8954 if (LRAvailable && !IsNoReturn) {
8955 NumBytesNoStackCalls += 4;
8957 CandidatesWithoutStackFixups.push_back(
C);
8962 else if (findRegisterToSaveLRTo(
C)) {
8963 NumBytesNoStackCalls += 12;
8965 CandidatesWithoutStackFixups.push_back(
C);
8970 else if (
C.isAvailableInsideSeq(AArch64::SP,
TRI)) {
8971 NumBytesNoStackCalls += 12;
8973 CandidatesWithoutStackFixups.push_back(
C);
8979 NumBytesNoStackCalls += SequenceSize;
8986 if (!AllStackInstrsSafe ||
8987 NumBytesNoStackCalls <= RepeatedSequenceLocs.size() * 12) {
8988 RepeatedSequenceLocs = CandidatesWithoutStackFixups;
8990 if (RepeatedSequenceLocs.size() < 2)
8991 return std::nullopt;
9040 if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
9044 (!
C.isAvailableAcrossAndOutOfSeq(AArch64::LR,
TRI) ||
9045 !findRegisterToSaveLRTo(
C));
9051 if (RepeatedSequenceLocs.size() < 2) {
9052 RepeatedSequenceLocs.clear();
9053 return std::nullopt;
9059 if (FlagsSetInAll & MachineOutlinerMBBFlags::HasCalls) {
9063 bool ModStackToSaveLR =
false;
9066 ModStackToSaveLR =
true;
9075 ModStackToSaveLR =
true;
9077 if (ModStackToSaveLR) {
9079 if (!AllStackInstrsSafe) {
9080 RepeatedSequenceLocs.clear();
9081 return std::nullopt;
9085 NumBytesToCreateFrame += 8;
9092 return std::nullopt;
9095 NumBytesToCreateFrame, FrameID);
9099 Function &
F, std::vector<outliner::Candidate> &Candidates)
const {
9103 const auto &CFn = Candidates.front().getMF()->getFunction();
9105 if (CFn.hasFnAttribute(
"ptrauth-returns"))
9106 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-returns"));
9107 if (CFn.hasFnAttribute(
"ptrauth-auth-traps"))
9108 F.addFnAttr(CFn.getFnAttribute(
"ptrauth-auth-traps"));
9111 if (CFn.hasFnAttribute(
"sign-return-address"))
9112 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address"));
9113 if (CFn.hasFnAttribute(
"sign-return-address-key"))
9114 F.addFnAttr(CFn.getFnAttribute(
"sign-return-address-key"));
9116 AArch64GenInstrInfo::mergeOutliningCandidateAttributes(
F, Candidates);
9124 if (!OutlineFromLinkOnceODRs &&
F.hasLinkOnceODRLinkage())
9138 if (!AFI || AFI->
hasRedZone().value_or(
true))
9158 unsigned &Flags)
const {
9160 "Must track liveness!");
9162 std::pair<MachineBasicBlock::iterator, MachineBasicBlock::iterator>>
9177 auto AreAllUnsafeRegsDead = [&LRU]() {
9194 bool LRAvailableEverywhere =
true;
9199 if (
MI.isCall() && !
MI.isTerminator())
9200 Flags |= MachineOutlinerMBBFlags::HasCalls;
9205 auto CreateNewRangeStartingAt =
9206 [&RangeBegin, &RangeEnd,
9208 RangeBegin = NewBegin;
9209 RangeEnd = std::next(RangeBegin);
9212 auto SaveRangeIfNonEmpty = [&RangeLen, &Ranges, &RangeBegin, &RangeEnd]() {
9217 Ranges.push_back(std::make_pair(RangeBegin, RangeEnd));
9225 for (; FirstPossibleEndPt !=
MBB.
instr_rend(); ++FirstPossibleEndPt) {
9229 UpdateWholeMBBFlags(*FirstPossibleEndPt);
9230 if (AreAllUnsafeRegsDead())
9237 CreateNewRangeStartingAt(FirstPossibleEndPt->getIterator());
9243 UpdateWholeMBBFlags(
MI);
9244 if (!AreAllUnsafeRegsDead()) {
9245 SaveRangeIfNonEmpty();
9246 CreateNewRangeStartingAt(
MI.getIterator());
9249 LRAvailableEverywhere &= LRU.
available(AArch64::LR);
9250 RangeBegin =
MI.getIterator();
9255 if (AreAllUnsafeRegsDead())
9256 SaveRangeIfNonEmpty();
9261 std::reverse(Ranges.begin(), Ranges.end());
9264 if (!LRAvailableEverywhere)
9265 Flags |= MachineOutlinerMBBFlags::LRUnavailableSomewhere;
9272 unsigned Flags)
const {
9280 switch (
MI.getOpcode()) {
9282 case AArch64::PACIASP:
9283 case AArch64::PACIBSP:
9284 case AArch64::PACIASPPC:
9285 case AArch64::PACIBSPPC:
9286 case AArch64::AUTIASP:
9287 case AArch64::AUTIBSP:
9288 case AArch64::AUTIASPPCi:
9289 case AArch64::AUTIASPPCr:
9290 case AArch64::AUTIBSPPCi:
9291 case AArch64::AUTIBSPPCr:
9292 case AArch64::RETAA:
9293 case AArch64::RETAB:
9294 case AArch64::RETAASPPCi:
9295 case AArch64::RETAASPPCr:
9296 case AArch64::RETABSPPCi:
9297 case AArch64::RETABSPPCr:
9298 case AArch64::EMITBKEY:
9299 case AArch64::PAUTH_PROLOGUE:
9300 case AArch64::PAUTH_EPILOGUE:
9314 if (
MI.isCFIInstruction())
9318 if (
MI.isTerminator())
9327 assert(!MOP.isCFIIndex());
9330 if (MOP.isReg() && !MOP.isImplicit() &&
9331 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
9338 if (
MI.getOpcode() == AArch64::ADRP)
9359 if (MOP.isGlobal()) {
9360 Callee = dyn_cast<Function>(MOP.getGlobal());
9367 if (Callee && Callee->getName() ==
"\01_mcount")
9375 if (
MI.getOpcode() == AArch64::BLR ||
9376 MI.getOpcode() == AArch64::BLRNoIP ||
MI.getOpcode() == AArch64::BL)
9380 return UnknownCallOutlineType;
9388 return UnknownCallOutlineType;
9396 return UnknownCallOutlineType;
9421 bool OffsetIsScalable;
9424 if (!
MI.mayLoadOrStore() ||
9427 (
Base->isReg() &&
Base->getReg() != AArch64::SP))
9432 int64_t Dummy1, Dummy2;
9435 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
9437 assert(Scale != 0 &&
"Unexpected opcode!");
9438 assert(!OffsetIsScalable &&
"Expected offset to be a byte offset");
9443 int64_t NewImm = (
Offset + 16) / (int64_t)Scale.getFixedValue();
9444 StackOffsetOperand.
setImm(NewImm);
9450 bool ShouldSignReturnAddr) {
9451 if (!ShouldSignReturnAddr)
9457 TII->get(AArch64::PAUTH_EPILOGUE))
9473 unsigned TailOpcode;
9474 if (Call->getOpcode() == AArch64::BL) {
9475 TailOpcode = AArch64::TCRETURNdi;
9477 assert(Call->getOpcode() == AArch64::BLR ||
9478 Call->getOpcode() == AArch64::BLRNoIP);
9479 TailOpcode = AArch64::TCRETURNriALL;
9482 .
add(Call->getOperand(0))
9485 Call->eraseFromParent();
9490 bool IsLeafFunction =
true;
9494 return MI.isCall() && !
MI.isReturn();
9504 "Can only fix up stack references once");
9505 fixupPostOutline(
MBB);
9507 IsLeafFunction =
false;
9518 Et = std::prev(
MBB.
end());
9531 unsigned DwarfReg =
MRI->getDwarfRegNum(AArch64::LR,
true);
9534 int64_t StackPosEntry =
9587 fixupPostOutline(
MBB);
9598 .addGlobalAddress(M.getNamedValue(MF.
getName()))
9608 .addGlobalAddress(M.getNamedValue(MF.
getName())));
9623 Register Reg = findRegisterToSaveLRTo(
C);
9624 assert(Reg &&
"No callee-saved register available?");
9658 .addGlobalAddress(M.getNamedValue(MF.
getName())));
9674 bool AllowSideEffects)
const {
9679 if (
TRI.isGeneralPurposeRegister(MF, Reg)) {
9681 }
else if (STI.hasSVE()) {
9691std::optional<DestSourcePair>
9696 if (
MI.getOpcode() == AArch64::ORRWrs &&
9697 MI.getOperand(1).getReg() == AArch64::WZR &&
9698 MI.getOperand(3).getImm() == 0x0 &&
9700 (!
MI.getOperand(0).getReg().isVirtual() ||
9701 MI.getOperand(0).getSubReg() == 0) &&
9702 (!
MI.getOperand(0).getReg().isPhysical() ||
9703 MI.findRegisterDefOperandIdx(
MI.getOperand(0).getReg() - AArch64::W0 +
9708 if (
MI.getOpcode() == AArch64::ORRXrs &&
9709 MI.getOperand(1).getReg() == AArch64::XZR &&
9710 MI.getOperand(3).getImm() == 0x0)
9713 return std::nullopt;
9716std::optional<DestSourcePair>
9718 if (
MI.getOpcode() == AArch64::ORRWrs &&
9719 MI.getOperand(1).getReg() == AArch64::WZR &&
9720 MI.getOperand(3).getImm() == 0x0)
9722 return std::nullopt;
9725std::optional<RegImmPair>
9734 return std::nullopt;
9736 switch (
MI.getOpcode()) {
9738 return std::nullopt;
9739 case AArch64::SUBWri:
9740 case AArch64::SUBXri:
9741 case AArch64::SUBSWri:
9742 case AArch64::SUBSXri:
9745 case AArch64::ADDSWri:
9746 case AArch64::ADDSXri:
9747 case AArch64::ADDWri:
9748 case AArch64::ADDXri: {
9750 if (!
MI.getOperand(0).isReg() || !
MI.getOperand(1).isReg() ||
9751 !
MI.getOperand(2).isImm())
9752 return std::nullopt;
9753 int Shift =
MI.getOperand(3).getImm();
9754 assert((Shift == 0 || Shift == 12) &&
"Shift can be either 0 or 12");
9755 Offset = Sign * (
MI.getOperand(2).getImm() << Shift);
9764static std::optional<ParamLoadedValue>
9768 auto DestSrc =
TII->isCopyLikeInstr(
MI);
9770 return std::nullopt;
9772 Register DestReg = DestSrc->Destination->getReg();
9773 Register SrcReg = DestSrc->Source->getReg();
9778 if (DestReg == DescribedReg)
9782 if (
MI.getOpcode() == AArch64::ORRWrs &&
9783 TRI->isSuperRegister(DestReg, DescribedReg))
9787 if (
MI.getOpcode() == AArch64::ORRXrs &&
9788 TRI->isSubRegister(DestReg, DescribedReg)) {
9789 Register SrcSubReg =
TRI->getSubReg(SrcReg, AArch64::sub_32);
9793 assert(!
TRI->isSuperOrSubRegisterEq(DestReg, DescribedReg) &&
9794 "Unhandled ORR[XW]rs copy case");
9796 return std::nullopt;
9815 return MI.getOpcode() == AArch64::INLINEASM_BR;
9833 switch (
MI.getOpcode()) {
9834 case TargetOpcode::G_BRJT:
9835 case AArch64::JumpTableDest32:
9836 case AArch64::JumpTableDest16:
9837 case AArch64::JumpTableDest8:
9848std::optional<ParamLoadedValue>
9853 switch (
MI.getOpcode()) {
9854 case AArch64::MOVZWi:
9855 case AArch64::MOVZXi: {
9858 if (!
TRI->isSuperRegisterEq(
MI.getOperand(0).getReg(), Reg))
9859 return std::nullopt;
9861 if (!
MI.getOperand(1).isImm())
9862 return std::nullopt;
9863 int64_t Immediate =
MI.getOperand(1).getImm();
9864 int Shift =
MI.getOperand(2).getImm();
9868 case AArch64::ORRWrs:
9869 case AArch64::ORRXrs:
9879 ExtMI.
getOpcode() == TargetOpcode::G_ZEXT ||
9880 ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT);
9883 if (ExtMI.
getOpcode() == TargetOpcode::G_ANYEXT)
9887 if (!
MRI.hasOneNonDBGUse(DefReg))
9892 auto *UserMI = &*
MRI.use_instr_nodbg_begin(DefReg);
9893 return UserMI->getOpcode() == TargetOpcode::G_PTR_ADD;
9914 unsigned Scale)
const {
9925 unsigned Shift =
Log2_64(NumBytes);
9926 if (NumBytes &&
Offset > 0 && (
Offset / NumBytes) <= (1LL << 12) - 1 &&
9934 return Scale == 1 || (Scale > 0 && Scale == NumBytes);
9939 return AArch64::BLRNoIP;
9941 return AArch64::BLR;
9946 Register TargetReg,
bool FrameSetup)
const {
9947 assert(TargetReg != AArch64::SP &&
"New top of stack cannot aleady be in SP");
9959 MF.
insert(MBBInsertPoint, LoopTestMBB);
9962 MF.
insert(MBBInsertPoint, LoopBodyMBB);
9964 MF.
insert(MBBInsertPoint, ExitMBB);
9974 BuildMI(*LoopTestMBB, LoopTestMBB->
end(),
DL,
TII->get(AArch64::SUBSXrx64),
9988 BuildMI(*LoopBodyMBB, LoopBodyMBB->
end(),
DL,
TII->get(AArch64::STRXui))
10001 BuildMI(*ExitMBB, ExitMBB->
end(),
DL,
TII->get(AArch64::ADDXri), AArch64::SP)
10026 return ExitMBB->
begin();
10043 unsigned CompCounterOprNum;
10047 unsigned UpdateCounterOprNum;
10051 bool IsUpdatePriorComp;
10063 TII(MF->getSubtarget().getInstrInfo()),
10064 TRI(MF->getSubtarget().getRegisterInfo()),
MRI(MF->getRegInfo()),
10065 LoopBB(LoopBB), CondBranch(CondBranch), Comp(Comp),
10066 CompCounterOprNum(CompCounterOprNum), Update(Update),
10067 UpdateCounterOprNum(UpdateCounterOprNum),
Init(
Init),
10068 IsUpdatePriorComp(IsUpdatePriorComp),
Cond(
Cond.begin(),
Cond.end()) {}
10070 bool shouldIgnoreForPipelining(
const MachineInstr *
MI)
const override {
10076 std::optional<bool> createTripCountGreaterCondition(
10086 void createRemainingIterationsGreaterCondition(
10092 void adjustTripCount(
int TripCountAdjust)
override {}
10094 void disposed()
override {}
10095 bool isMVEExpanderSupported()
override {
return true; }
10113 Result =
MRI.createVirtualRegister(
10116 }
else if (
I == ReplaceOprNum) {
10117 MRI.constrainRegClass(
10127void AArch64PipelinerLoopInfo::createRemainingIterationsGreaterCondition(
10143 assert(CondBranch->getOpcode() == AArch64::Bcc);
10147 if (CondBranch->getOperand(1).getMBB() == LoopBB)
10154 auto AccumulateCond = [&](
Register CurCond,
10156 Register NewCond =
MRI.createVirtualRegister(&AArch64::GPR64commonRegClass);
10165 if (!LastStage0Insts.
empty() && LastStage0Insts[Comp]->getParent() == &
MBB) {
10169 for (
int I = 0;
I <= TC; ++
I) {
10175 AccCond = AccumulateCond(AccCond,
CC);
10179 if (Update != Comp && IsUpdatePriorComp) {
10181 LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
10182 NextCounter =
cloneInstr(Update, UpdateCounterOprNum, Counter,
MBB,
10186 NextCounter = LastStage0Insts[Update]->getOperand(0).getReg();
10188 }
else if (Update != Comp) {
10193 Counter = NextCounter;
10197 if (LastStage0Insts.
empty()) {
10201 if (IsUpdatePriorComp)
10206 Counter = LastStage0Insts[Comp]->getOperand(CompCounterOprNum).getReg();
10209 for (
int I = 0;
I <= TC; ++
I) {
10213 AccCond = AccumulateCond(AccCond,
CC);
10214 if (
I != TC && Update != Comp)
10217 Counter = NextCounter;
10233 assert(Phi.getNumOperands() == 5);
10234 if (Phi.getOperand(2).getMBB() ==
MBB) {
10235 RegMBB = Phi.getOperand(1).getReg();
10236 RegOther = Phi.getOperand(3).getReg();
10238 assert(Phi.getOperand(4).getMBB() ==
MBB);
10239 RegMBB = Phi.getOperand(3).getReg();
10240 RegOther = Phi.getOperand(1).getReg();
10245 if (!Reg.isVirtual())
10248 return MRI.getVRegDef(Reg)->getParent() != BB;
10254 unsigned &UpdateCounterOprNum,
Register &InitReg,
10255 bool &IsUpdatePriorComp) {
10269 if (!Reg.isVirtual())
10272 UpdateInst =
nullptr;
10273 UpdateCounterOprNum = 0;
10275 IsUpdatePriorComp =
true;
10279 if (Def->getParent() != LoopBB)
10281 if (Def->isCopy()) {
10283 if (Def->getOperand(0).getSubReg() || Def->getOperand(1).getSubReg())
10285 CurReg = Def->getOperand(1).getReg();
10286 }
else if (Def->isPHI()) {
10290 IsUpdatePriorComp =
false;
10295 switch (Def->getOpcode()) {
10296 case AArch64::ADDSXri:
10297 case AArch64::ADDSWri:
10298 case AArch64::SUBSXri:
10299 case AArch64::SUBSWri:
10300 case AArch64::ADDXri:
10301 case AArch64::ADDWri:
10302 case AArch64::SUBXri:
10303 case AArch64::SUBWri:
10305 UpdateCounterOprNum = 1;
10307 case AArch64::ADDSXrr:
10308 case AArch64::ADDSWrr:
10309 case AArch64::SUBSXrr:
10310 case AArch64::SUBSWrr:
10311 case AArch64::ADDXrr:
10312 case AArch64::ADDWrr:
10313 case AArch64::SUBXrr:
10314 case AArch64::SUBWrr:
10317 UpdateCounterOprNum = 1;
10319 UpdateCounterOprNum = 2;
10326 CurReg = Def->getOperand(UpdateCounterOprNum).getReg();
10341std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
10352 if (
MI.isCall() ||
MI.hasUnmodeledSideEffects())
10363 if (
TBB == LoopBB && FBB == LoopBB)
10367 if (
TBB != LoopBB && FBB ==
nullptr)
10370 assert((
TBB == LoopBB || FBB == LoopBB) &&
10371 "The Loop must be a single-basic-block loop");
10376 if (CondBranch->
getOpcode() != AArch64::Bcc)
10384 unsigned CompCounterOprNum = 0;
10386 if (
MI.modifiesRegister(AArch64::NZCV, &
TRI)) {
10390 switch (
MI.getOpcode()) {
10391 case AArch64::SUBSXri:
10392 case AArch64::SUBSWri:
10393 case AArch64::ADDSXri:
10394 case AArch64::ADDSWri:
10396 CompCounterOprNum = 1;
10398 case AArch64::ADDSWrr:
10399 case AArch64::ADDSXrr:
10400 case AArch64::SUBSWrr:
10401 case AArch64::SUBSXrr:
10412 if (CompCounterOprNum == 0) {
10414 CompCounterOprNum = 2;
10416 CompCounterOprNum = 1;
10428 bool IsUpdatePriorComp;
10429 unsigned UpdateCounterOprNum;
10431 Update, UpdateCounterOprNum,
Init, IsUpdatePriorComp))
10434 return std::make_unique<AArch64PipelinerLoopInfo>(
10435 LoopBB, CondBranch, Comp, CompCounterOprNum, Update, UpdateCounterOprNum,
10446 TypeSize Scale(0U,
false), Width(0U,
false);
10447 int64_t MinOffset, MaxOffset;
10448 if (
getMemOpInfo(
MI.getOpcode(), Scale, Width, MinOffset, MaxOffset)) {
10450 if (
MI.getOperand(ImmIdx).isImm() && !
MI.getOperand(ImmIdx - 1).isFI()) {
10451 int64_t Imm =
MI.getOperand(ImmIdx).getImm();
10452 if (Imm < MinOffset || Imm > MaxOffset) {
10453 ErrInfo =
"Unexpected immediate on load/store instruction";
10461#define GET_INSTRINFO_HELPERS
10462#define GET_INSTRMAP_INFO
10463#include "AArch64GenInstrInfo.inc"
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool forwardCopyWillClobberTuple(unsigned DestReg, unsigned SrcReg, unsigned NumRegs)
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
static void genSubAdd2SubSub(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, unsigned IdxOpd1, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg)
Do the following transformation A - (B + C) ==> (A - B) - C A - (B + C) ==> (A - C) - B.
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 bool isCombineInstrCandidate64(unsigned Opc)
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 MachineInstr * genFusedMultiplyIdxNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
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 int findCondCodeUseOperandIdxForBranchOrSelect(const MachineInstr &Instr)
static bool isPostIndexLdStOpcode(unsigned Opcode)
Return true if the opcode is a post-index ld/st instruction, which really loads from base+0.
static unsigned getBranchDisplacementBits(unsigned Opc)
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 MachineInstr * genFusedMultiplyAccNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned IdxMulOpd, unsigned MaddOpc, unsigned MnegOpc, const TargetRegisterClass *RC)
genFusedMultiplyAccNeg - Helper to generate fused multiply accumulate instructions with an additional...
static void appendVGScaledOffsetExpr(SmallVectorImpl< char > &Expr, int NumBytes, int NumVGScaledBytes, unsigned VG, llvm::raw_string_ostream &Comment)
static MachineInstr * genMaddR(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, unsigned VR, const TargetRegisterClass *RC)
genMaddR - Generate madd instruction and combine mul and add using an extra virtual register Example ...
static Register cloneInstr(const MachineInstr *MI, unsigned ReplaceOprNum, Register ReplaceReg, MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertTo)
Clone an instruction from MI.
static bool scaleOffset(unsigned Opc, int64_t &Offset)
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
unsigned scaledOffsetOpcode(unsigned Opcode, unsigned &Scale)
static MachineInstr * genFusedMultiplyIdx(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxMulOpd, unsigned MaddOpc, const TargetRegisterClass *RC)
genFusedMultiplyIdx - Helper to generate fused multiply accumulate instructions.
static MachineInstr * genIndexedMultiply(MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, unsigned IdxDupOp, unsigned MulOpc, const TargetRegisterClass *RC, MachineRegisterInfo &MRI)
Fold (FMUL x (DUP y lane)) into (FMUL_indexed x y lane)
static bool isSUBSRegImm(unsigned Opcode)
static bool UpdateOperandRegClass(MachineInstr &Instr)
static const TargetRegisterClass * getRegClass(const MachineInstr &MI, Register Reg)
static bool canCmpInstrBeRemoved(MachineInstr &MI, MachineInstr &CmpInstr, int CmpValue, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > &CCUseInstrs, bool &IsInvertCC)
unsigned unscaledOffsetOpcode(unsigned Opcode)
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 Register genNeg(MachineFunction &MF, MachineRegisterInfo &MRI, const TargetInstrInfo *TII, MachineInstr &Root, SmallVectorImpl< MachineInstr * > &InsInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg, unsigned MnegOpc, const TargetRegisterClass *RC)
genNeg - Helper to generate an intermediate negation of the second operand of Root
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc, unsigned ZeroReg=0, bool CheckZeroReg=false)
static unsigned convertToNonFlagSettingOpc(const MachineInstr &MI)
Return the opcode that does not set flags when possible - otherwise return the original opcode.
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI)
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 bool getMiscPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns)
Find other MI combine patterns.
static bool outliningCandidatesSigningKeyConsensus(const outliner::Candidate &a, const outliner::Candidate &b)
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 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 unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewVReg=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)
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static const Function * getParent(const Value *V)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const HexagonInstrInfo * TII
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
unsigned const TargetRegisterInfo * TRI
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
Module.h This file contains the declarations for the Module class.
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file declares the machine register scavenger class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
bool hasStreamingModeChanges() const
bool shouldSignReturnAddress(const MachineFunction &MF) const
const SetOfInstructions & getLOHRelated() const
bool needsDwarfUnwindInfo(const MachineFunction &MF) const
void setOutliningStyle(std::string Style)
std::optional< bool > hasRedZone() const
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 void decomposeStackOffsetForFrameOffsets(const StackOffset &Offset, int64_t &NumBytes, int64_t &NumPredicateVectors, int64_t &NumDataVectors)
Returns the offset in parts to which this frame offset can be decomposed for the purpose of describin...
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
std::optional< RegImmPair > isAddImmediate(const MachineInstr &MI, Register Reg) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
uint64_t getElementSizeForOpcode(unsigned Opc) const
Returns the vector element size (B, H, S or D) of an SVE opcode.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) 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.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< unsigned > &Patterns, bool DoRegPressureReduce) const override
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
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
bool isWhileOpcode(unsigned Opc) const
Returns true if the opcode is for an SVE WHILE## instruction.
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.
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, outliner::Candidate &C) const override
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
static bool isSEHInstruction(const MachineInstr &MI)
Return true if the instructions is a SEH instruciton used for unwinding on Windows.
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS) const override
SmallVector< std::pair< MachineBasicBlock::iterator, MachineBasicBlock::iterator > > getOutlinableRanges(MachineBasicBlock &MBB, unsigned &Flags) const override
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
void genAlternativeCodeSequence(MachineInstr &Root, unsigned Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
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.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
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.
outliner::InstrType getOutliningTypeImpl(const MachineModuleInfo &MMI, MachineBasicBlock::iterator &MIT, unsigned Flags) const override
bool useMachineCombiner() const override
AArch64 supports MachineCombiner.
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
std::optional< outliner::OutlinedFunction > getOutliningCandidateInfo(const MachineModuleInfo &MMI, std::vector< outliner::Candidate > &RepeatedSequenceLocs) const override
bool isExtendLikelyToBeFolded(MachineInstr &ExtMI, MachineRegisterInfo &MRI) const override
static bool isFalkorShiftExtFast(const MachineInstr &MI)
Returns true if the instruction has a shift by immediate that can be executed in one cycle less.
std::optional< ParamLoadedValue > describeLoadedValue(const MachineInstr &MI, Register Reg) 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.
bool expandPostRAPseudo(MachineInstr &MI) const override
unsigned int getTailDuplicateSize(CodeGenOptLevel OptLevel) const override
bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isThroughputPattern(unsigned Pattern) const override
Return true when a code sequence can improve throughput.
void copyGPRRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc, unsigned Opcode, unsigned ZeroReg, llvm::ArrayRef< unsigned > Indices) const
void buildClearRegister(Register Reg, MachineBasicBlock &MBB, MachineBasicBlock::iterator Iter, DebugLoc &DL, bool AllowSideEffects=true) const override
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
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.
bool isFunctionSafeToSplit(const MachineFunction &MF) const override
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
Return true when Inst is associative and commutative so that it can be reassociated.
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineBasicBlock::iterator probedStackAlloc(MachineBasicBlock::iterator MBBI, Register TargetReg, bool FrameSetup) const
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?
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
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 isMBBSafeToSplitToCold(const MachineBasicBlock &MBB) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool isLegalAddressingMode(unsigned NumBytes, int64_t Offset, unsigned Scale) const
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.
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
static int getMemScale(unsigned Opc)
Scaling factor for (scaled or unscaled) load or store.
bool isCandidateToMergeOrPair(const MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
MCInst getNop() const override
static const MachineOperand & getLdStBaseOp(const MachineInstr &MI)
Returns the base register operator of a load/store.
bool isPTestLikeOpcode(unsigned Opc) const
Returns true if the opcode is for an SVE instruction that sets the condition codes as if it's results...
void mergeOutliningCandidateAttributes(Function &F, std::vector< outliner::Candidate > &Candidates) const override
static void decomposeStackOffsetForDwarfOffsets(const StackOffset &Offset, int64_t &ByteSized, int64_t &VGSized)
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 isTargetILP32() const
bool isSVEorStreamingSVEAvailable() const
Returns true if the target has access to either the full range of SVE instructions,...
unsigned ClassifyGlobalReference(const GlobalValue *GV, const TargetMachine &TM) const
ClassifyGlobalReference - Find the target operand flags that describe how a global value should be re...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
This class represents an Operation in the Expression.
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...
A set of register units used to track register liveness.
bool available(MCPhysReg Reg) const
Returns true if no part of physical register Reg is live.
void stepBackward(const MachineInstr &MI)
Updates liveness when stepping backwards over the instruction MI.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
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.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
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
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
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()
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
MBBSectionID getSectionID() const
Returns the section ID of this basic block.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
reverse_instr_iterator instr_rend()
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any debug instructions.
Instructions::iterator instr_iterator
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
instr_iterator instr_end()
Instructions::const_iterator const_instr_iterator
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.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
iterator_range< succ_iterator > successors()
instr_iterator getFirstInstrTerminator()
Same getFirstTerminator but it ignores bundles and return an instr_iterator instead.
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
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects.
void setStackID(int ObjectIdx, uint8_t ID)
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getNumObjects() const
Return the number of objects.
int64_t getObjectOffset(int ObjectIdx) const
Return the assigned stack offset of the specified object from the incoming stack pointer.
bool isFixedObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a fixed stack object.
unsigned addFrameInst(const MCCFIInstruction &Inst)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
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)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void insert(iterator MBBI, MachineBasicBlock *MBB)
Register getReg(unsigned Idx) const
Get the register for the operand index.
const MachineInstrBuilder & setMemRefs(ArrayRef< MachineMemOperand * > MMOs) const
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
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 & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
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.
uint32_t mergeFlagsWith(const MachineInstr &Other) const
Return the MIFlags which represent both MachineInstrs.
unsigned getNumOperands() const
Retuns the total number of operands.
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.
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.
void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
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.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
void removeOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with.
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.
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.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
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)
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.
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.
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,...
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
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...
const TargetRegisterClass * getRegClassOrNull(Register Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet.
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...
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.
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
bool isRegUsed(Register Reg, bool includeReserved=true) const
Return if a specific register is currently used.
Register FindUnusedReg(const TargetRegisterClass *RC) const
Find an unused register of the specified register class.
void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
Wrapper class representing virtual and physical registers.
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.
static constexpr bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical 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.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
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 append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
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.
StringRef - 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< unsigned, 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.
Primary interface to the complete machine description for the target machine.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
bool contains(Register Reg) const
Return true if the specified register is included in this register class.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetInstrInfo * getInstrInfo() const
Target - Wrapper for Target specific information.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
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()
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
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_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_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_G0
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address,...
@ MO_PAGE
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
@ MO_G2
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address,...
@ MO_G3
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address,...
unsigned getCheckerSizeInBytes(AuthCheckMethod Method)
Returns the number of bytes added by checkAuthenticatedRegister.
const SysReg * lookupSysRegByName(StringRef)
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...
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 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 expandMOVImm(uint64_t Imm, unsigned BitSize, SmallVectorImpl< ImmInsnModel > &Insn)
Expand a MOVi32imm or MOVi64imm pseudo instruction to one or more real move-immediate instructions to...
static const uint64_t InstrFlagIsWhile
static const uint64_t InstrFlagIsPTestLike
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Renamable
Register that may be renamed.
@ Define
Register definition.
@ Kill
The last use of a register.
@ Undef
Value of the register doesn't matter.
Reg
All possible values of the reg field in the ModR/M byte.
initializer< Ty > init(const Ty &Val)
InstrType
Represents how an instruction should be mapped by the outliner.
This is an optimization pass for GlobalISel generic memory operations.
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)
std::pair< MachineOperand, DIExpression * > ParamLoadedValue
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.
static bool isIndirectBranchOpcode(int Opc)
MCCFIInstruction createCFAOffset(const TargetRegisterInfo &MRI, unsigned Reg, const StackOffset &OffsetFromDefCFA)
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.
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)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
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
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.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
CombinerObjective
The combiner's goal may differ based on which pattern it is attempting to optimize.
std::optional< UsedNZCV > examineCFlagsUse(MachineInstr &MI, MachineInstr &CmpInstr, const TargetRegisterInfo &TRI, SmallVectorImpl< MachineInstr * > *CCUseInstrs=nullptr)
CodeGenOptLevel
Code generation optimization level.
auto instructionsWithoutDebug(IterT It, IterT End, bool SkipPseudoOp=true)
Construct a range iterator which begins at It and moves forwards until End is reached,...
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.
unsigned getUndefRegState(bool B)
unsigned getDefRegState(bool B)
unsigned getKillRegState(bool B)
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
DWARFExpression::Operation Op
static bool isUncondBranchOpcode(int Opc)
unsigned encodeSLEB128(int64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a SLEB128 value to an output stream.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
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
unsigned encodeULEB128(uint64_t Value, raw_ostream &OS, unsigned PadTo=0)
Utility function to encode a ULEB128 value to an output stream.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
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
@ Default
The result values are uniform if and only if all operands are uniform.
void fullyRecomputeLiveIns(ArrayRef< MachineBasicBlock * > MBBs)
Convenience function for recomputing live-in's for a set of MBBs until the computation converges.
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.
Description of the encoding of one expression Op.
Used to describe addressing mode similar to ExtAddrMode in CodeGenPrepare.
static const MBBSectionID ColdSectionID
MachineJumpTableEntry - One jump table in the jump table info.
This class contains a discriminated union of information about pointers in memory operands,...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Used to describe a register and immediate addition.
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.
unsigned FrameConstructionID
Target-defined identifier for constructing a frame for this function.