53 #define GET_INSTRINFO_CTOR_DTOR 54 #include "AArch64GenInstrInfo.inc" 58 cl::desc(
"Restrict range of TB[N]Z instructions (DEBUG)"));
62 cl::desc(
"Restrict range of CB[N]Z instructions (DEBUG)"));
66 cl::desc(
"Restrict range of Bcc instructions (DEBUG)"));
70 RI(STI.getTargetTriple()), Subtarget(STI) {}
84 unsigned NumBytes = 0;
91 case TargetOpcode::DBG_VALUE:
93 case TargetOpcode::IMPLICIT_DEF:
97 case TargetOpcode::STACKMAP:
100 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
102 case TargetOpcode::PATCHPOINT:
105 assert(NumBytes % 4 == 0 &&
"Invalid number of NOP bytes requested!");
169 int64_t BrOffset)
const {
171 assert(Bits >= 3 &&
"max branch displacement must be enough to jump" 172 "over conditional branch expansion");
173 return isIntN(Bits, BrOffset / 4);
202 bool AllowModify)
const {
208 if (!isUnpredicatedTerminator(*I))
215 unsigned LastOpc = LastInst->
getOpcode();
216 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
231 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
238 LastInst = SecondLastInst;
240 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
245 SecondLastInst = &*
I;
246 SecondLastOpc = SecondLastInst->
getOpcode();
252 if (SecondLastInst && I != MBB.
begin() && isUnpredicatedTerminator(*--I))
268 I->eraseFromParent();
277 I->eraseFromParent();
287 if (Cond[0].getImm() != -1) {
293 switch (Cond[1].getImm()) {
297 Cond[1].setImm(AArch64::CBNZW);
300 Cond[1].setImm(AArch64::CBZW);
303 Cond[1].setImm(AArch64::CBNZX);
306 Cond[1].setImm(AArch64::CBZX);
309 Cond[1].setImm(AArch64::TBNZW);
312 Cond[1].setImm(AArch64::TBZW);
315 Cond[1].setImm(AArch64::TBNZX);
318 Cond[1].setImm(AArch64::TBZX);
327 int *BytesRemoved)
const {
337 I->eraseFromParent();
341 if (I == MBB.
begin()) {
354 I->eraseFromParent();
361 void AArch64InstrInfo::instantiateCondBranch(
364 if (Cond[0].getImm() != -1) {
371 BuildMI(&MBB, DL,
get(Cond[1].getImm())).
add(Cond[2]);
373 MIB.
addImm(Cond[3].getImm());
382 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
388 instantiateCondBranch(MBB, DL, TBB, Cond);
397 instantiateCondBranch(MBB, DL, TBB, Cond);
421 unsigned *NewVReg =
nullptr) {
426 bool Is64Bit = AArch64::GPR64allRegClass.hasSubClassEq(MRI.
getRegClass(VReg));
429 unsigned SrcOpNum = 0;
431 case AArch64::ADDSXri:
432 case AArch64::ADDSWri:
438 case AArch64::ADDXri:
439 case AArch64::ADDWri:
445 Opc = Is64Bit ? AArch64::CSINCXr : AArch64::CSINCWr;
448 case AArch64::ORNXrr:
449 case AArch64::ORNWrr: {
452 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
455 Opc = Is64Bit ? AArch64::CSINVXr : AArch64::CSINVWr;
459 case AArch64::SUBSXrr:
460 case AArch64::SUBSWrr:
466 case AArch64::SUBXrr:
467 case AArch64::SUBWrr: {
470 if (ZReg != AArch64::XZR && ZReg != AArch64::WZR)
473 Opc = Is64Bit ? AArch64::CSNEGXr : AArch64::CSNEGWr;
479 assert(Opc && SrcOpNum &&
"Missing parameters");
488 unsigned TrueReg,
unsigned FalseReg,
489 int &CondCycles,
int &TrueCycles,
490 int &FalseCycles)
const {
499 unsigned ExtraCondLat = Cond.
size() != 1;
503 if (AArch64::GPR64allRegClass.hasSubClassEq(RC) ||
504 AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
506 CondCycles = 1 + ExtraCondLat;
507 TrueCycles = FalseCycles = 1;
517 if (AArch64::FPR64RegClass.hasSubClassEq(RC) ||
518 AArch64::FPR32RegClass.hasSubClassEq(RC)) {
519 CondCycles = 5 + ExtraCondLat;
520 TrueCycles = FalseCycles = 2;
530 const DebugLoc &DL,
unsigned DstReg,
532 unsigned TrueReg,
unsigned FalseReg)
const {
537 switch (Cond.
size()) {
546 switch (Cond[1].getImm()) {
566 unsigned SrcReg = Cond[2].getReg();
570 BuildMI(MBB, I, DL,
get(AArch64::SUBSXri), AArch64::XZR)
576 BuildMI(MBB, I, DL,
get(AArch64::SUBSWri), AArch64::WZR)
585 switch (Cond[1].getImm()) {
598 if (Cond[1].getImm() == AArch64::TBZW || Cond[1].getImm() == AArch64::TBNZW)
599 BuildMI(MBB, I, DL,
get(AArch64::ANDSWri), AArch64::WZR)
604 BuildMI(MBB, I, DL,
get(AArch64::ANDSXri), AArch64::XZR)
614 bool TryFold =
false;
616 RC = &AArch64::GPR64RegClass;
617 Opc = AArch64::CSELXr;
620 RC = &AArch64::GPR32RegClass;
621 Opc = AArch64::CSELWr;
624 RC = &AArch64::FPR64RegClass;
625 Opc = AArch64::FCSELDrrr;
627 RC = &AArch64::FPR32RegClass;
628 Opc = AArch64::FCSELSrrr;
630 assert(RC &&
"Unsupported regclass");
634 unsigned NewVReg = 0;
658 BuildMI(MBB, I, DL,
get(Opc), DstReg)
667 uint64_t UImm = Imm << (64 - BitSize) >> (64 - BitSize);
690 case AArch64::ADDWri:
691 case AArch64::ADDXri:
692 case AArch64::SUBWri:
693 case AArch64::SUBXri:
697 case AArch64::ANDWri:
698 case AArch64::ANDXri:
699 case AArch64::EORWri:
700 case AArch64::EORXri:
701 case AArch64::ORRWri:
702 case AArch64::ORRXri:
706 case AArch64::ANDWrr:
707 case AArch64::ANDXrr:
708 case AArch64::BICWrr:
709 case AArch64::BICXrr:
710 case AArch64::EONWrr:
711 case AArch64::EONXrr:
712 case AArch64::EORWrr:
713 case AArch64::EORXrr:
714 case AArch64::ORNWrr:
715 case AArch64::ORNXrr:
716 case AArch64::ORRWrr:
717 case AArch64::ORRXrr:
722 case AArch64::MOVi32imm:
724 case AArch64::MOVi64imm:
729 case AArch64::FMOVH0:
730 case AArch64::FMOVS0:
731 case AArch64::FMOVD0:
733 case TargetOpcode::COPY:
743 unsigned Reg, Imm, Shift;
750 case AArch64::ADDWri:
751 case AArch64::ADDXri:
757 return ((Reg == AArch64::WSP || Reg == AArch64::SP) && Imm == 0);
766 case AArch64::MOVIv8b_ns:
767 case AArch64::MOVIv2d_ns:
768 case AArch64::MOVIv16b_ns:
773 case AArch64::MOVIv2i32:
774 case AArch64::MOVIv4i16:
775 case AArch64::MOVIv4i32:
776 case AArch64::MOVIv8i16:
779 return (Imm == 0 && Shift == 0);
782 case AArch64::MOVNWi:
783 case AArch64::MOVNXi:
786 case AArch64::MOVZWi:
787 case AArch64::MOVZXi:
791 case AArch64::ORRWri:
792 case AArch64::ORRXri:
798 return ((Reg == AArch64::WZR || Reg == AArch64::XZR) && Imm == 0);
801 case AArch64::ORRWrs:
802 case AArch64::ORRXrs:
809 return ((Reg == AArch64::WZR || Reg == AArch64::XZR) && Shift == 0);
822 case AArch64::ADDSWri:
823 case AArch64::ADDSXri:
824 case AArch64::ADDWri:
825 case AArch64::ADDXri:
826 case AArch64::SUBSWri:
827 case AArch64::SUBSXri:
828 case AArch64::SUBWri:
829 case AArch64::SUBXri:
833 case AArch64::ADDSWrs:
834 case AArch64::ADDSXrs:
835 case AArch64::ADDWrs:
836 case AArch64::ADDXrs:
837 case AArch64::ANDSWrs:
838 case AArch64::ANDSXrs:
839 case AArch64::ANDWrs:
840 case AArch64::ANDXrs:
841 case AArch64::BICSWrs:
842 case AArch64::BICSXrs:
843 case AArch64::BICWrs:
844 case AArch64::BICXrs:
845 case AArch64::EONWrs:
846 case AArch64::EONXrs:
847 case AArch64::EORWrs:
848 case AArch64::EORXrs:
849 case AArch64::ORNWrs:
850 case AArch64::ORNXrs:
851 case AArch64::ORRWrs:
852 case AArch64::ORRXrs:
853 case AArch64::SUBSWrs:
854 case AArch64::SUBSXrs:
855 case AArch64::SUBWrs:
856 case AArch64::SUBXrs:
863 case AArch64::ADDSWrx:
864 case AArch64::ADDSXrx:
865 case AArch64::ADDSXrx64:
866 case AArch64::ADDWrx:
867 case AArch64::ADDXrx:
868 case AArch64::ADDXrx64:
869 case AArch64::SUBSWrx:
870 case AArch64::SUBSXrx:
871 case AArch64::SUBSXrx64:
872 case AArch64::SUBWrx:
873 case AArch64::SUBXrx:
874 case AArch64::SUBXrx64:
880 case AArch64::PRFMroW:
881 case AArch64::PRFMroX:
884 case AArch64::LDRBBroW:
885 case AArch64::LDRBBroX:
886 case AArch64::LDRHHroW:
887 case AArch64::LDRHHroX:
888 case AArch64::LDRSBWroW:
889 case AArch64::LDRSBWroX:
890 case AArch64::LDRSBXroW:
891 case AArch64::LDRSBXroX:
892 case AArch64::LDRSHWroW:
893 case AArch64::LDRSHWroX:
894 case AArch64::LDRSHXroW:
895 case AArch64::LDRSHXroX:
896 case AArch64::LDRSWroW:
897 case AArch64::LDRSWroX:
898 case AArch64::LDRWroW:
899 case AArch64::LDRWroX:
900 case AArch64::LDRXroW:
901 case AArch64::LDRXroX:
903 case AArch64::LDRBroW:
904 case AArch64::LDRBroX:
905 case AArch64::LDRDroW:
906 case AArch64::LDRDroX:
907 case AArch64::LDRHroW:
908 case AArch64::LDRHroX:
909 case AArch64::LDRSroW:
910 case AArch64::LDRSroX:
913 case AArch64::STRBBroW:
914 case AArch64::STRBBroX:
915 case AArch64::STRHHroW:
916 case AArch64::STRHHroX:
917 case AArch64::STRWroW:
918 case AArch64::STRWroX:
919 case AArch64::STRXroW:
920 case AArch64::STRXroX:
922 case AArch64::STRBroW:
923 case AArch64::STRBroX:
924 case AArch64::STRDroW:
925 case AArch64::STRDroX:
926 case AArch64::STRHroW:
927 case AArch64::STRHroX:
928 case AArch64::STRSroW:
929 case AArch64::STRSroX:
941 case AArch64::ADDWrs:
942 case AArch64::ADDXrs:
943 case AArch64::ADDSWrs:
944 case AArch64::ADDSXrs: {
952 case AArch64::ADDWrx:
953 case AArch64::ADDXrx:
954 case AArch64::ADDXrx64:
955 case AArch64::ADDSWrx:
956 case AArch64::ADDSXrx:
957 case AArch64::ADDSXrx64: {
970 case AArch64::SUBWrs:
971 case AArch64::SUBSWrs: {
974 return ShiftVal == 0 ||
978 case AArch64::SUBXrs:
979 case AArch64::SUBSXrs: {
982 return ShiftVal == 0 ||
986 case AArch64::SUBWrx:
987 case AArch64::SUBXrx:
988 case AArch64::SUBXrx64:
989 case AArch64::SUBSWrx:
990 case AArch64::SUBSXrx:
991 case AArch64::SUBSXrx64: {
1004 case AArch64::LDRBBroW:
1005 case AArch64::LDRBBroX:
1006 case AArch64::LDRBroW:
1007 case AArch64::LDRBroX:
1008 case AArch64::LDRDroW:
1009 case AArch64::LDRDroX:
1010 case AArch64::LDRHHroW:
1011 case AArch64::LDRHHroX:
1012 case AArch64::LDRHroW:
1013 case AArch64::LDRHroX:
1014 case AArch64::LDRQroW:
1015 case AArch64::LDRQroX:
1016 case AArch64::LDRSBWroW:
1017 case AArch64::LDRSBWroX:
1018 case AArch64::LDRSBXroW:
1019 case AArch64::LDRSBXroX:
1020 case AArch64::LDRSHWroW:
1021 case AArch64::LDRSHWroX:
1022 case AArch64::LDRSHXroW:
1023 case AArch64::LDRSHXroX:
1024 case AArch64::LDRSWroW:
1025 case AArch64::LDRSWroX:
1026 case AArch64::LDRSroW:
1027 case AArch64::LDRSroX:
1028 case AArch64::LDRWroW:
1029 case AArch64::LDRWroX:
1030 case AArch64::LDRXroW:
1031 case AArch64::LDRXroX:
1032 case AArch64::PRFMroW:
1033 case AArch64::PRFMroX:
1034 case AArch64::STRBBroW:
1035 case AArch64::STRBBroX:
1036 case AArch64::STRBroW:
1037 case AArch64::STRBroX:
1038 case AArch64::STRDroW:
1039 case AArch64::STRDroX:
1040 case AArch64::STRHHroW:
1041 case AArch64::STRHHroX:
1042 case AArch64::STRHroW:
1043 case AArch64::STRHroX:
1044 case AArch64::STRQroW:
1045 case AArch64::STRQroX:
1046 case AArch64::STRSroW:
1047 case AArch64::STRSroX:
1048 case AArch64::STRWroW:
1049 case AArch64::STRWroX:
1050 case AArch64::STRXroW:
1051 case AArch64::STRXroX: {
1059 unsigned &SrcReg,
unsigned &DstReg,
1060 unsigned &SubIdx)
const {
1064 case AArch64::SBFMXri:
1065 case AArch64::UBFMXri:
1073 SubIdx = AArch64::sub_32;
1081 unsigned BaseRegA = 0, BaseRegB = 0;
1082 int64_t OffsetA = 0, OffsetB = 0;
1083 unsigned WidthA = 0, WidthB = 0;
1099 if (BaseRegA == BaseRegB) {
1100 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1101 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1102 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1103 if (LowOffset + LowWidth <= HighOffset)
1114 unsigned &SrcReg2,
int &CmpMask,
1115 int &CmpValue)
const {
1125 case AArch64::SUBSWrr:
1126 case AArch64::SUBSWrs:
1127 case AArch64::SUBSWrx:
1128 case AArch64::SUBSXrr:
1129 case AArch64::SUBSXrs:
1130 case AArch64::SUBSXrx:
1131 case AArch64::ADDSWrr:
1132 case AArch64::ADDSWrs:
1133 case AArch64::ADDSWrx:
1134 case AArch64::ADDSXrr:
1135 case AArch64::ADDSXrs:
1136 case AArch64::ADDSXrx:
1143 case AArch64::SUBSWri:
1144 case AArch64::ADDSWri:
1145 case AArch64::SUBSXri:
1146 case AArch64::ADDSXri:
1153 case AArch64::ANDSWri:
1154 case AArch64::ANDSXri:
1167 MI.
getOpcode() == AArch64::ANDSWri ? 32 : 64) != 0;
1176 assert(MBB &&
"Can't get MachineBasicBlock here");
1178 assert(MF &&
"Can't get MachineFunction here");
1183 for (
unsigned OpIdx = 0, EndIdx = Instr.
getNumOperands(); OpIdx < EndIdx;
1190 if (!OpRegCstraints)
1198 "Operand has register constraints without being a register!");
1202 if (!OpRegCstraints->
contains(Reg))
1218 bool MIDefinesZeroReg =
false;
1220 MIDefinesZeroReg =
true;
1225 case AArch64::ADDSWrr:
1226 return AArch64::ADDWrr;
1227 case AArch64::ADDSWri:
1228 return MIDefinesZeroReg ? AArch64::ADDSWri : AArch64::ADDWri;
1229 case AArch64::ADDSWrs:
1230 return MIDefinesZeroReg ? AArch64::ADDSWrs : AArch64::ADDWrs;
1231 case AArch64::ADDSWrx:
1232 return AArch64::ADDWrx;
1233 case AArch64::ADDSXrr:
1234 return AArch64::ADDXrr;
1235 case AArch64::ADDSXri:
1236 return MIDefinesZeroReg ? AArch64::ADDSXri : AArch64::ADDXri;
1237 case AArch64::ADDSXrs:
1238 return MIDefinesZeroReg ? AArch64::ADDSXrs : AArch64::ADDXrs;
1239 case AArch64::ADDSXrx:
1240 return AArch64::ADDXrx;
1241 case AArch64::SUBSWrr:
1242 return AArch64::SUBWrr;
1243 case AArch64::SUBSWri:
1244 return MIDefinesZeroReg ? AArch64::SUBSWri : AArch64::SUBWri;
1245 case AArch64::SUBSWrs:
1246 return MIDefinesZeroReg ? AArch64::SUBSWrs : AArch64::SUBWrs;
1247 case AArch64::SUBSWrx:
1248 return AArch64::SUBWrx;
1249 case AArch64::SUBSXrr:
1250 return AArch64::SUBXrr;
1251 case AArch64::SUBSXri:
1252 return MIDefinesZeroReg ? AArch64::SUBSXri : AArch64::SUBXri;
1253 case AArch64::SUBSXrs:
1254 return MIDefinesZeroReg ? AArch64::SUBSXrs : AArch64::SUBXrs;
1255 case AArch64::SUBSXrx:
1256 return AArch64::SUBXrx;
1271 if (To == To->getParent()->begin())
1276 if (To->getParent() != From->getParent())
1282 return MI.getIterator() == From;
1283 }) != To->getParent()->rend());
1286 for (--To; To != From; --To) {
1309 MachineInstr &CmpInstr,
unsigned SrcReg,
unsigned SrcReg2,
int CmpMask,
1316 if (DeadNZCVIdx != -1) {
1331 assert(succeeded &&
"Some operands reg class are incompatible!");
1338 assert((CmpValue == 0 || CmpValue == 1) &&
"CmpValue must be 0 or 1!");
1339 if (CmpValue != 0 || SrcReg2 != 0)
1346 return substituteCmpToZero(CmpInstr, SrcReg, MRI);
1356 return AArch64::INSTRUCTION_LIST_END;
1358 case AArch64::ADDSWrr:
1359 case AArch64::ADDSWri:
1360 case AArch64::ADDSXrr:
1361 case AArch64::ADDSXri:
1362 case AArch64::SUBSWrr:
1363 case AArch64::SUBSWri:
1364 case AArch64::SUBSXrr:
1365 case AArch64::SUBSXri:
1368 case AArch64::ADDWrr:
1369 return AArch64::ADDSWrr;
1370 case AArch64::ADDWri:
1371 return AArch64::ADDSWri;
1372 case AArch64::ADDXrr:
1373 return AArch64::ADDSXrr;
1374 case AArch64::ADDXri:
1375 return AArch64::ADDSXri;
1376 case AArch64::ADCWr:
1377 return AArch64::ADCSWr;
1378 case AArch64::ADCXr:
1379 return AArch64::ADCSXr;
1380 case AArch64::SUBWrr:
1381 return AArch64::SUBSWrr;
1382 case AArch64::SUBWri:
1383 return AArch64::SUBSWri;
1384 case AArch64::SUBXrr:
1385 return AArch64::SUBSXrr;
1386 case AArch64::SUBXri:
1387 return AArch64::SUBSXri;
1388 case AArch64::SBCWr:
1389 return AArch64::SBCSWr;
1390 case AArch64::SBCXr:
1391 return AArch64::SBCSXr;
1392 case AArch64::ANDWri:
1393 return AArch64::ANDSWri;
1394 case AArch64::ANDXri:
1395 return AArch64::ANDSXri;
1402 if (BB->isLiveIn(AArch64::NZCV))
1415 UsedNZCV() =
default;
1417 UsedNZCV &
operator|=(
const UsedNZCV &UsedFlags) {
1418 this->N |= UsedFlags.N;
1419 this->Z |= UsedFlags.Z;
1420 this->C |= UsedFlags.C;
1421 this->V |= UsedFlags.V;
1436 case AArch64::Bcc: {
1442 case AArch64::CSINVWr:
1443 case AArch64::CSINVXr:
1444 case AArch64::CSINCWr:
1445 case AArch64::CSINCXr:
1446 case AArch64::CSELWr:
1447 case AArch64::CSELXr:
1448 case AArch64::CSNEGWr:
1449 case AArch64::CSNEGXr:
1450 case AArch64::FCSELSrrr:
1451 case AArch64::FCSELDrrr: {
1504 return Opcode == AArch64::ADDSWri || Opcode == AArch64::ADDSXri;
1508 return Opcode == AArch64::SUBSWri || Opcode == AArch64::SUBSXri;
1525 assert(
sForm(*MI) != AArch64::INSTRUCTION_LIST_END);
1528 const unsigned CmpOpcode = CmpInstr->
getOpcode();
1544 UsedNZCV NZCVUsedAfterCmp;
1560 return !NZCVUsedAfterCmp.C && !NZCVUsedAfterCmp.V;
1567 bool AArch64InstrInfo::substituteCmpToZero(
1578 unsigned NewOpc =
sForm(*MI);
1579 if (NewOpc == AArch64::INSTRUCTION_LIST_END)
1590 assert(succeeded &&
"Some operands reg class are incompatible!");
1596 if (MI.
getOpcode() != TargetOpcode::LOAD_STACK_GUARD)
1605 unsigned char OpFlags = Subtarget.ClassifyGlobalReference(GV, TM);
1611 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1616 BuildMI(MBB, MI, DL,
get(AArch64::MOVZXi), Reg)
1619 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1623 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1627 BuildMI(MBB, MI, DL,
get(AArch64::MOVKXi), Reg)
1631 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1639 BuildMI(MBB, MI, DL,
get(AArch64::LDRXui), Reg)
1655 case AArch64::ADDSWrs:
1656 case AArch64::ADDSXrs:
1657 case AArch64::ADDWrs:
1658 case AArch64::ADDXrs:
1659 case AArch64::ANDSWrs:
1660 case AArch64::ANDSXrs:
1661 case AArch64::ANDWrs:
1662 case AArch64::ANDXrs:
1663 case AArch64::BICSWrs:
1664 case AArch64::BICSXrs:
1665 case AArch64::BICWrs:
1666 case AArch64::BICXrs:
1667 case AArch64::EONWrs:
1668 case AArch64::EONXrs:
1669 case AArch64::EORWrs:
1670 case AArch64::EORXrs:
1671 case AArch64::ORNWrs:
1672 case AArch64::ORNXrs:
1673 case AArch64::ORRWrs:
1674 case AArch64::ORRXrs:
1675 case AArch64::SUBSWrs:
1676 case AArch64::SUBSXrs:
1677 case AArch64::SUBWrs:
1678 case AArch64::SUBXrs:
1693 case AArch64::ADDSWrx:
1694 case AArch64::ADDSXrx:
1695 case AArch64::ADDSXrx64:
1696 case AArch64::ADDWrx:
1697 case AArch64::ADDXrx:
1698 case AArch64::ADDXrx64:
1699 case AArch64::SUBSWrx:
1700 case AArch64::SUBSXrx:
1701 case AArch64::SUBSXrx64:
1702 case AArch64::SUBWrx:
1703 case AArch64::SUBXrx:
1704 case AArch64::SUBXrx64:
1721 case AArch64::MOVZWi:
1722 case AArch64::MOVZXi:
1729 case AArch64::ANDWri:
1731 case AArch64::ANDXri:
1733 case TargetOpcode::COPY:
1745 case TargetOpcode::COPY: {
1748 return (AArch64::GPR32RegClass.
contains(DstReg) ||
1749 AArch64::GPR64RegClass.
contains(DstReg));
1751 case AArch64::ORRXrs:
1758 case AArch64::ADDXri:
1775 case TargetOpcode::COPY: {
1778 return (AArch64::FPR64RegClass.
contains(DstReg) ||
1779 AArch64::FPR128RegClass.
contains(DstReg));
1781 case AArch64::ORRv16i8:
1784 "invalid ORRv16i8 operands");
1797 case AArch64::LDRWui:
1798 case AArch64::LDRXui:
1799 case AArch64::LDRBui:
1800 case AArch64::LDRHui:
1801 case AArch64::LDRSui:
1802 case AArch64::LDRDui:
1803 case AArch64::LDRQui:
1820 case AArch64::STRWui:
1821 case AArch64::STRXui:
1822 case AArch64::STRBui:
1823 case AArch64::STRHui:
1824 case AArch64::STRSui:
1825 case AArch64::STRDui:
1826 case AArch64::STRQui:
1844 case AArch64::LDRBBroW:
1845 case AArch64::LDRBroW:
1846 case AArch64::LDRDroW:
1847 case AArch64::LDRHHroW:
1848 case AArch64::LDRHroW:
1849 case AArch64::LDRQroW:
1850 case AArch64::LDRSBWroW:
1851 case AArch64::LDRSBXroW:
1852 case AArch64::LDRSHWroW:
1853 case AArch64::LDRSHXroW:
1854 case AArch64::LDRSWroW:
1855 case AArch64::LDRSroW:
1856 case AArch64::LDRWroW:
1857 case AArch64::LDRXroW:
1858 case AArch64::STRBBroW:
1859 case AArch64::STRBroW:
1860 case AArch64::STRDroW:
1861 case AArch64::STRHHroW:
1862 case AArch64::STRHroW:
1863 case AArch64::STRQroW:
1864 case AArch64::STRSroW:
1865 case AArch64::STRWroW:
1866 case AArch64::STRXroW:
1867 case AArch64::LDRBBroX:
1868 case AArch64::LDRBroX:
1869 case AArch64::LDRDroX:
1870 case AArch64::LDRHHroX:
1871 case AArch64::LDRHroX:
1872 case AArch64::LDRQroX:
1873 case AArch64::LDRSBWroX:
1874 case AArch64::LDRSBXroX:
1875 case AArch64::LDRSHWroX:
1876 case AArch64::LDRSHXroX:
1877 case AArch64::LDRSWroX:
1878 case AArch64::LDRSroX:
1879 case AArch64::LDRWroX:
1880 case AArch64::LDRXroX:
1881 case AArch64::STRBBroX:
1882 case AArch64::STRBroX:
1883 case AArch64::STRDroX:
1884 case AArch64::STRHHroX:
1885 case AArch64::STRHroX:
1886 case AArch64::STRQroX:
1887 case AArch64::STRSroX:
1888 case AArch64::STRWroX:
1889 case AArch64::STRXroX:
1923 case AArch64::STURSi:
1924 case AArch64::STURDi:
1925 case AArch64::STURQi:
1926 case AArch64::STURBBi:
1927 case AArch64::STURHHi:
1928 case AArch64::STURWi:
1929 case AArch64::STURXi:
1930 case AArch64::LDURSi:
1931 case AArch64::LDURDi:
1932 case AArch64::LDURQi:
1933 case AArch64::LDURWi:
1934 case AArch64::LDURXi:
1935 case AArch64::LDURSWi:
1936 case AArch64::LDURHHi:
1937 case AArch64::LDURBBi:
1938 case AArch64::LDURSBWi:
1939 case AArch64::LDURSHWi:
1949 case AArch64::STRSui:
1950 case AArch64::STRDui:
1951 case AArch64::STRQui:
1952 case AArch64::STRXui:
1953 case AArch64::STRWui:
1954 case AArch64::LDRSui:
1955 case AArch64::LDRDui:
1956 case AArch64::LDRQui:
1957 case AArch64::LDRXui:
1958 case AArch64::LDRWui:
1959 case AArch64::LDRSWui:
1961 case AArch64::STURSi:
1962 case AArch64::STURDi:
1963 case AArch64::STURQi:
1964 case AArch64::STURWi:
1965 case AArch64::STURXi:
1966 case AArch64::LDURSi:
1967 case AArch64::LDURDi:
1968 case AArch64::LDURQi:
1969 case AArch64::LDURWi:
1970 case AArch64::LDURXi:
1971 case AArch64::LDURSWi:
1982 case AArch64::ADDWri:
1984 return AArch64::ADDSWri;
1985 case AArch64::ADDWrr:
1987 return AArch64::ADDSWrr;
1988 case AArch64::ADDWrs:
1990 return AArch64::ADDSWrs;
1991 case AArch64::ADDWrx:
1993 return AArch64::ADDSWrx;
1994 case AArch64::ANDWri:
1996 return AArch64::ANDSWri;
1997 case AArch64::ANDWrr:
1999 return AArch64::ANDSWrr;
2000 case AArch64::ANDWrs:
2002 return AArch64::ANDSWrs;
2003 case AArch64::BICWrr:
2005 return AArch64::BICSWrr;
2006 case AArch64::BICWrs:
2008 return AArch64::BICSWrs;
2009 case AArch64::SUBWri:
2011 return AArch64::SUBSWri;
2012 case AArch64::SUBWrr:
2014 return AArch64::SUBSWrr;
2015 case AArch64::SUBWrs:
2017 return AArch64::SUBSWrs;
2018 case AArch64::SUBWrx:
2020 return AArch64::SUBSWrx;
2022 case AArch64::ADDXri:
2024 return AArch64::ADDSXri;
2025 case AArch64::ADDXrr:
2027 return AArch64::ADDSXrr;
2028 case AArch64::ADDXrs:
2030 return AArch64::ADDSXrs;
2031 case AArch64::ADDXrx:
2033 return AArch64::ADDSXrx;
2034 case AArch64::ANDXri:
2036 return AArch64::ANDSXri;
2037 case AArch64::ANDXrr:
2039 return AArch64::ANDSXrr;
2040 case AArch64::ANDXrs:
2042 return AArch64::ANDSXrs;
2043 case AArch64::BICXrr:
2045 return AArch64::BICSXrr;
2046 case AArch64::BICXrs:
2048 return AArch64::BICSXrs;
2049 case AArch64::SUBXri:
2051 return AArch64::SUBSXri;
2052 case AArch64::SUBXrr:
2054 return AArch64::SUBSXrr;
2055 case AArch64::SUBXrs:
2057 return AArch64::SUBSXrs;
2058 case AArch64::SUBXrx:
2060 return AArch64::SUBSXrx;
2089 if (Subtarget.isPaired128Slow()) {
2093 case AArch64::LDURQi:
2094 case AArch64::STURQi:
2095 case AArch64::LDRQui:
2096 case AArch64::STRQui:
2131 int64_t Dummy1, Dummy2;
2155 assert(OfsOp.isImm() &&
"Offset operand wasn't immediate.");
2160 unsigned &Width, int64_t &MinOffset,
2161 int64_t &MaxOffset)
const {
2166 MinOffset = MaxOffset = 0;
2168 case AArch64::STRWpost:
2169 case AArch64::LDRWpost:
2175 case AArch64::LDURQi:
2176 case AArch64::STURQi:
2182 case AArch64::LDURXi:
2183 case AArch64::LDURDi:
2184 case AArch64::STURXi:
2185 case AArch64::STURDi:
2191 case AArch64::LDURWi:
2192 case AArch64::LDURSi:
2193 case AArch64::LDURSWi:
2194 case AArch64::STURWi:
2195 case AArch64::STURSi:
2201 case AArch64::LDURHi:
2202 case AArch64::LDURHHi:
2203 case AArch64::LDURSHXi:
2204 case AArch64::LDURSHWi:
2205 case AArch64::STURHi:
2206 case AArch64::STURHHi:
2212 case AArch64::LDURBi:
2213 case AArch64::LDURBBi:
2214 case AArch64::LDURSBXi:
2215 case AArch64::LDURSBWi:
2216 case AArch64::STURBi:
2217 case AArch64::STURBBi:
2223 case AArch64::LDPQi:
2224 case AArch64::LDNPQi:
2225 case AArch64::STPQi:
2226 case AArch64::STNPQi:
2232 case AArch64::LDRQui:
2233 case AArch64::STRQui:
2238 case AArch64::LDPXi:
2239 case AArch64::LDPDi:
2240 case AArch64::LDNPXi:
2241 case AArch64::LDNPDi:
2242 case AArch64::STPXi:
2243 case AArch64::STPDi:
2244 case AArch64::STNPXi:
2245 case AArch64::STNPDi:
2251 case AArch64::LDRXui:
2252 case AArch64::LDRDui:
2253 case AArch64::STRXui:
2254 case AArch64::STRDui:
2259 case AArch64::LDPWi:
2260 case AArch64::LDPSi:
2261 case AArch64::LDNPWi:
2262 case AArch64::LDNPSi:
2263 case AArch64::STPWi:
2264 case AArch64::STPSi:
2265 case AArch64::STNPWi:
2266 case AArch64::STNPSi:
2272 case AArch64::LDRWui:
2273 case AArch64::LDRSui:
2274 case AArch64::LDRSWui:
2275 case AArch64::STRWui:
2276 case AArch64::STRSui:
2281 case AArch64::LDRHui:
2282 case AArch64::LDRHHui:
2283 case AArch64::STRHui:
2284 case AArch64::STRHHui:
2289 case AArch64::LDRBui:
2290 case AArch64::LDRBBui:
2291 case AArch64::STRBui:
2292 case AArch64::STRBBui:
2305 unsigned OffsetStride = 1;
2309 case AArch64::LDURQi:
2310 case AArch64::STURQi:
2313 case AArch64::LDURXi:
2314 case AArch64::LDURDi:
2315 case AArch64::STURXi:
2316 case AArch64::STURDi:
2319 case AArch64::LDURWi:
2320 case AArch64::LDURSi:
2321 case AArch64::LDURSWi:
2322 case AArch64::STURWi:
2323 case AArch64::STURSi:
2329 if (Offset % OffsetStride != 0)
2334 Offset /= OffsetStride;
2339 if (FirstOpc == SecondOpc)
2345 case AArch64::LDRWui:
2346 case AArch64::LDURWi:
2347 return SecondOpc == AArch64::LDRSWui || SecondOpc == AArch64::LDURSWi;
2348 case AArch64::LDRSWui:
2349 case AArch64::LDURSWi:
2350 return SecondOpc == AArch64::LDRWui || SecondOpc == AArch64::LDURWi;
2363 unsigned NumLoads)
const {
2364 if (BaseReg1 != BaseReg2)
2375 unsigned FirstOpc = FirstLdSt.
getOpcode();
2376 unsigned SecondOpc = SecondLdSt.
getOpcode();
2396 if (Offset1 > 63 || Offset1 < -64)
2400 assert(Offset1 <= Offset2 &&
"Caller should have ordered offsets.");
2401 return Offset1 + 1 == Offset2;
2405 unsigned Reg,
unsigned SubIdx,
2409 return MIB.
addReg(Reg, State);
2413 return MIB.
addReg(Reg, State, SubIdx);
2420 return ((DestReg - SrcReg) & 0x1f) < NumRegs;
2425 const DebugLoc &DL,
unsigned DestReg,
2426 unsigned SrcReg,
bool KillSrc,
2429 assert(Subtarget.hasNEON() &&
"Unexpected register copy without NEON");
2431 uint16_t DestEncoding = TRI->getEncodingValue(DestReg);
2432 uint16_t SrcEncoding = TRI->getEncodingValue(SrcReg);
2433 unsigned NumRegs = Indices.
size();
2435 int SubReg = 0, End = NumRegs, Incr = 1;
2437 SubReg = NumRegs - 1;
2442 for (; SubReg != End; SubReg += Incr) {
2445 AddSubReg(MIB, SrcReg, Indices[SubReg], 0, TRI);
2452 const DebugLoc &DL,
unsigned DestReg,
2453 unsigned SrcReg,
bool KillSrc)
const {
2454 if (AArch64::GPR32spRegClass.
contains(DestReg) &&
2455 (AArch64::GPR32spRegClass.
contains(SrcReg) || SrcReg == AArch64::WZR)) {
2458 if (DestReg == AArch64::WSP || SrcReg == AArch64::WSP) {
2460 if (Subtarget.hasZeroCycleRegMove()) {
2463 &AArch64::GPR64spRegClass);
2465 &AArch64::GPR64spRegClass);
2470 BuildMI(MBB, I, DL,
get(AArch64::ADDXri), DestRegX)
2476 BuildMI(MBB, I, DL,
get(AArch64::ADDWri), DestReg)
2481 }
else if (SrcReg == AArch64::WZR && Subtarget.hasZeroCycleZeroing()) {
2482 BuildMI(MBB, I, DL,
get(AArch64::MOVZWi), DestReg)
2486 if (Subtarget.hasZeroCycleRegMove()) {
2489 &AArch64::GPR64spRegClass);
2491 &AArch64::GPR64spRegClass);
2496 BuildMI(MBB, I, DL,
get(AArch64::ORRXrr), DestRegX)
2502 BuildMI(MBB, I, DL,
get(AArch64::ORRWrr), DestReg)
2510 if (AArch64::GPR64spRegClass.
contains(DestReg) &&
2511 (AArch64::GPR64spRegClass.
contains(SrcReg) || SrcReg == AArch64::XZR)) {
2512 if (DestReg == AArch64::SP || SrcReg == AArch64::SP) {
2514 BuildMI(MBB, I, DL,
get(AArch64::ADDXri), DestReg)
2518 }
else if (SrcReg == AArch64::XZR && Subtarget.hasZeroCycleZeroing()) {
2519 BuildMI(MBB, I, DL,
get(AArch64::MOVZXi), DestReg)
2524 BuildMI(MBB, I, DL,
get(AArch64::ORRXrr), DestReg)
2532 if (AArch64::DDDDRegClass.
contains(DestReg) &&
2533 AArch64::DDDDRegClass.
contains(SrcReg)) {
2534 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
2535 AArch64::dsub2, AArch64::dsub3};
2542 if (AArch64::DDDRegClass.
contains(DestReg) &&
2543 AArch64::DDDRegClass.
contains(SrcReg)) {
2544 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1,
2552 if (AArch64::DDRegClass.
contains(DestReg) &&
2553 AArch64::DDRegClass.
contains(SrcReg)) {
2554 static const unsigned Indices[] = {AArch64::dsub0, AArch64::dsub1};
2561 if (AArch64::QQQQRegClass.
contains(DestReg) &&
2562 AArch64::QQQQRegClass.
contains(SrcReg)) {
2563 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
2564 AArch64::qsub2, AArch64::qsub3};
2571 if (AArch64::QQQRegClass.
contains(DestReg) &&
2572 AArch64::QQQRegClass.
contains(SrcReg)) {
2573 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1,
2581 if (AArch64::QQRegClass.
contains(DestReg) &&
2582 AArch64::QQRegClass.
contains(SrcReg)) {
2583 static const unsigned Indices[] = {AArch64::qsub0, AArch64::qsub1};
2589 if (AArch64::FPR128RegClass.
contains(DestReg) &&
2590 AArch64::FPR128RegClass.
contains(SrcReg)) {
2591 if (Subtarget.hasNEON()) {
2592 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2596 BuildMI(MBB, I, DL,
get(AArch64::STRQpre))
2601 BuildMI(MBB, I, DL,
get(AArch64::LDRQpre))
2610 if (AArch64::FPR64RegClass.
contains(DestReg) &&
2611 AArch64::FPR64RegClass.
contains(SrcReg)) {
2612 if (Subtarget.hasNEON()) {
2613 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::dsub,
2614 &AArch64::FPR128RegClass);
2615 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::dsub,
2616 &AArch64::FPR128RegClass);
2617 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2621 BuildMI(MBB, I, DL,
get(AArch64::FMOVDr), DestReg)
2627 if (AArch64::FPR32RegClass.
contains(DestReg) &&
2628 AArch64::FPR32RegClass.
contains(SrcReg)) {
2629 if (Subtarget.hasNEON()) {
2630 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::ssub,
2631 &AArch64::FPR128RegClass);
2632 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::ssub,
2633 &AArch64::FPR128RegClass);
2634 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2638 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2644 if (AArch64::FPR16RegClass.
contains(DestReg) &&
2645 AArch64::FPR16RegClass.
contains(SrcReg)) {
2646 if (Subtarget.hasNEON()) {
2647 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
2648 &AArch64::FPR128RegClass);
2649 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
2650 &AArch64::FPR128RegClass);
2651 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2655 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::hsub,
2656 &AArch64::FPR32RegClass);
2657 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::hsub,
2658 &AArch64::FPR32RegClass);
2659 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2665 if (AArch64::FPR8RegClass.
contains(DestReg) &&
2666 AArch64::FPR8RegClass.
contains(SrcReg)) {
2667 if (Subtarget.hasNEON()) {
2668 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
2669 &AArch64::FPR128RegClass);
2670 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
2671 &AArch64::FPR128RegClass);
2672 BuildMI(MBB, I, DL,
get(AArch64::ORRv16i8), DestReg)
2676 DestReg = RI.getMatchingSuperReg(DestReg, AArch64::bsub,
2677 &AArch64::FPR32RegClass);
2678 SrcReg = RI.getMatchingSuperReg(SrcReg, AArch64::bsub,
2679 &AArch64::FPR32RegClass);
2680 BuildMI(MBB, I, DL,
get(AArch64::FMOVSr), DestReg)
2687 if (AArch64::FPR64RegClass.
contains(DestReg) &&
2688 AArch64::GPR64RegClass.
contains(SrcReg)) {
2689 BuildMI(MBB, I, DL,
get(AArch64::FMOVXDr), DestReg)
2693 if (AArch64::GPR64RegClass.
contains(DestReg) &&
2694 AArch64::FPR64RegClass.
contains(SrcReg)) {
2695 BuildMI(MBB, I, DL,
get(AArch64::FMOVDXr), DestReg)
2700 if (AArch64::FPR32RegClass.
contains(DestReg) &&
2701 AArch64::GPR32RegClass.
contains(SrcReg)) {
2702 BuildMI(MBB, I, DL,
get(AArch64::FMOVWSr), DestReg)
2706 if (AArch64::GPR32RegClass.
contains(DestReg) &&
2707 AArch64::FPR32RegClass.
contains(SrcReg)) {
2708 BuildMI(MBB, I, DL,
get(AArch64::FMOVSWr), DestReg)
2713 if (DestReg == AArch64::NZCV) {
2714 assert(AArch64::GPR64RegClass.
contains(SrcReg) &&
"Invalid NZCV copy");
2715 BuildMI(MBB, I, DL,
get(AArch64::MSR))
2716 .
addImm(AArch64SysReg::NZCV)
2722 if (SrcReg == AArch64::NZCV) {
2723 assert(AArch64::GPR64RegClass.
contains(DestReg) &&
"Invalid NZCV copy");
2724 BuildMI(MBB, I, DL,
get(AArch64::MRS), DestReg)
2725 .
addImm(AArch64SysReg::NZCV)
2738 if (MBBI != MBB.
end())
2739 DL = MBBI->getDebugLoc();
2751 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
2752 Opc = AArch64::STRBui;
2755 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
2756 Opc = AArch64::STRHui;
2759 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
2760 Opc = AArch64::STRWui;
2764 assert(SrcReg != AArch64::WSP);
2765 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
2766 Opc = AArch64::STRSui;
2769 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
2770 Opc = AArch64::STRXui;
2774 assert(SrcReg != AArch64::SP);
2775 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
2776 Opc = AArch64::STRDui;
2779 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
2780 Opc = AArch64::STRQui;
2781 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
2782 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2783 Opc = AArch64::ST1Twov1d;
2785 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
2786 BuildMI(MBB, MBBI, DL,
get(AArch64::STPXi))
2789 .addReg(TRI->
getSubReg(SrcReg, AArch64::subo64),
2798 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
2799 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2800 Opc = AArch64::ST1Threev1d;
2805 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
2806 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2807 Opc = AArch64::ST1Fourv1d;
2809 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
2810 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2811 Opc = AArch64::ST1Twov2d;
2816 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
2817 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2818 Opc = AArch64::ST1Threev2d;
2823 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
2824 assert(Subtarget.hasNEON() &&
"Unexpected register store without NEON");
2825 Opc = AArch64::ST1Fourv2d;
2830 assert(Opc &&
"Unknown register class");
2846 if (MBBI != MBB.
end())
2847 DL = MBBI->getDebugLoc();
2859 if (AArch64::FPR8RegClass.hasSubClassEq(RC))
2860 Opc = AArch64::LDRBui;
2863 if (AArch64::FPR16RegClass.hasSubClassEq(RC))
2864 Opc = AArch64::LDRHui;
2867 if (AArch64::GPR32allRegClass.hasSubClassEq(RC)) {
2868 Opc = AArch64::LDRWui;
2872 assert(DestReg != AArch64::WSP);
2873 }
else if (AArch64::FPR32RegClass.hasSubClassEq(RC))
2874 Opc = AArch64::LDRSui;
2877 if (AArch64::GPR64allRegClass.hasSubClassEq(RC)) {
2878 Opc = AArch64::LDRXui;
2882 assert(DestReg != AArch64::SP);
2883 }
else if (AArch64::FPR64RegClass.hasSubClassEq(RC))
2884 Opc = AArch64::LDRDui;
2887 if (AArch64::FPR128RegClass.hasSubClassEq(RC))
2888 Opc = AArch64::LDRQui;
2889 else if (AArch64::DDRegClass.hasSubClassEq(RC)) {
2890 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2891 Opc = AArch64::LD1Twov1d;
2893 }
else if (AArch64::XSeqPairsClassRegClass.hasSubClassEq(RC)) {
2894 BuildMI(MBB, MBBI, DL,
get(AArch64::LDPXi))
2897 .addReg(TRI->
getSubReg(DestReg, AArch64::subo64),
2906 if (AArch64::DDDRegClass.hasSubClassEq(RC)) {
2907 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2908 Opc = AArch64::LD1Threev1d;
2913 if (AArch64::DDDDRegClass.hasSubClassEq(RC)) {
2914 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2915 Opc = AArch64::LD1Fourv1d;
2917 }
else if (AArch64::QQRegClass.hasSubClassEq(RC)) {
2918 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2919 Opc = AArch64::LD1Twov2d;
2924 if (AArch64::QQQRegClass.hasSubClassEq(RC)) {
2925 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2926 Opc = AArch64::LD1Threev2d;
2931 if (AArch64::QQQQRegClass.hasSubClassEq(RC)) {
2932 assert(Subtarget.hasNEON() &&
"Unexpected register load without NEON");
2933 Opc = AArch64::LD1Fourv2d;
2938 assert(Opc &&
"Unknown register class");
2950 unsigned DestReg,
unsigned SrcReg,
int Offset,
2953 if (DestReg == SrcReg && Offset == 0)
2956 assert((DestReg != AArch64::SP || Offset % 16 == 0) &&
2957 "SP increment/decrement not 16-byte aligned");
2959 bool isSub = Offset < 0;
2976 Opc = isSub ? AArch64::SUBSXri : AArch64::ADDSXri;
2978 Opc = isSub ? AArch64::SUBXri : AArch64::ADDXri;
2979 const unsigned MaxEncoding = 0xfff;
2980 const unsigned ShiftSize = 12;
2981 const unsigned MaxEncodableValue = MaxEncoding << ShiftSize;
2982 while (((
unsigned)Offset) >= (1 << ShiftSize)) {
2984 if (((
unsigned)Offset) > MaxEncodableValue) {
2985 ThisVal = MaxEncodableValue;
2987 ThisVal = Offset & MaxEncodableValue;
2989 assert((ThisVal >> ShiftSize) <= MaxEncoding &&
2990 "Encoding cannot handle value that big");
2991 BuildMI(MBB, MBBI, DL, TII->
get(Opc), DestReg)
2993 .
addImm(ThisVal >> ShiftSize)
3002 BuildMI(MBB, MBBI, DL, TII->
get(Opc), DestReg)
3029 if (SrcReg == AArch64::SP &&
3034 if (DstReg == AArch64::SP &&
3067 (Ops[0] == 0 || Ops[0] == 1)) {
3068 bool IsSpill = Ops[0] == 0;
3069 bool IsFill = !IsSpill;
3075 unsigned DstReg = DstMO.
getReg();
3076 unsigned SrcReg = SrcMO.
getReg();
3088 "Mismatched register size in non subreg COPY");
3095 return &*--InsertPt;
3107 if (IsSpill && DstMO.
isUndef() &&
3110 "Unexpected subreg on physical register");
3112 unsigned SpillSubreg;
3117 case AArch64::sub_32:
3119 if (AArch64::GPR32RegClass.
contains(SrcReg)) {
3120 SpillRC = &AArch64::GPR64RegClass;
3121 SpillSubreg = AArch64::sub_32;
3122 }
else if (AArch64::FPR32RegClass.
contains(SrcReg)) {
3123 SpillRC = &AArch64::FPR64RegClass;
3124 SpillSubreg = AArch64::ssub;
3129 if (AArch64::FPR64RegClass.
contains(SrcReg)) {
3130 SpillRC = &AArch64::FPR128RegClass;
3131 SpillSubreg = AArch64::dsub;
3138 if (
unsigned WidenedSrcReg =
3142 return &*--InsertPt;
3161 case AArch64::sub_32:
3162 FillRC = &AArch64::GPR32RegClass;
3165 FillRC = &AArch64::FPR32RegClass;
3168 FillRC = &AArch64::FPR64RegClass;
3175 "Mismatched regclass size on folded subreg COPY");
3192 bool *OutUseUnscaledOp,
3193 unsigned *OutUnscaledOp,
3194 int *EmittableOffset) {
3196 bool IsSigned =
false;
3198 unsigned ImmIdx = 2;
3199 unsigned UnscaledOp = 0;
3201 if (EmittableOffset)
3202 *EmittableOffset = 0;
3203 if (OutUseUnscaledOp)
3204 *OutUseUnscaledOp =
false;
3211 case AArch64::LD1Twov2d:
3212 case AArch64::LD1Threev2d:
3213 case AArch64::LD1Fourv2d:
3214 case AArch64::LD1Twov1d:
3215 case AArch64::LD1Threev1d:
3216 case AArch64::LD1Fourv1d:
3217 case AArch64::ST1Twov2d:
3218 case AArch64::ST1Threev2d:
3219 case AArch64::ST1Fourv2d:
3220 case AArch64::ST1Twov1d:
3221 case AArch64::ST1Threev1d:
3222 case AArch64::ST1Fourv1d:
3224 case AArch64::PRFMui:
3226 UnscaledOp = AArch64::PRFUMi;
3228 case AArch64::LDRXui:
3230 UnscaledOp = AArch64::LDURXi;
3232 case AArch64::LDRWui:
3234 UnscaledOp = AArch64::LDURWi;
3236 case AArch64::LDRBui:
3238 UnscaledOp = AArch64::LDURBi;
3240 case AArch64::LDRHui:
3242 UnscaledOp = AArch64::LDURHi;
3244 case AArch64::LDRSui:
3246 UnscaledOp = AArch64::LDURSi;
3248 case AArch64::LDRDui:
3250 UnscaledOp = AArch64::LDURDi;
3252 case AArch64::LDRQui:
3254 UnscaledOp = AArch64::LDURQi;
3256 case AArch64::LDRBBui:
3258 UnscaledOp = AArch64::LDURBBi;
3260 case AArch64::LDRHHui:
3262 UnscaledOp = AArch64::LDURHHi;
3264 case AArch64::LDRSBXui:
3266 UnscaledOp = AArch64::LDURSBXi;
3268 case AArch64::LDRSBWui:
3270 UnscaledOp = AArch64::LDURSBWi;
3272 case AArch64::LDRSHXui:
3274 UnscaledOp = AArch64::LDURSHXi;
3276 case AArch64::LDRSHWui:
3278 UnscaledOp = AArch64::LDURSHWi;
3280 case AArch64::LDRSWui:
3282 UnscaledOp = AArch64::LDURSWi;
3285 case AArch64::STRXui:
3287 UnscaledOp = AArch64::STURXi;
3289 case AArch64::STRWui:
3291 UnscaledOp = AArch64::STURWi;
3293 case AArch64::STRBui:
3295 UnscaledOp = AArch64::STURBi;
3297 case AArch64::STRHui:
3299 UnscaledOp = AArch64::STURHi;
3301 case AArch64::STRSui:
3303 UnscaledOp = AArch64::STURSi;
3305 case AArch64::STRDui:
3307 UnscaledOp = AArch64::STURDi;
3309 case AArch64::STRQui:
3311 UnscaledOp = AArch64::STURQi;
3313 case AArch64::STRBBui:
3315 UnscaledOp = AArch64::STURBBi;
3317 case AArch64::STRHHui:
3319 UnscaledOp = AArch64::STURHHi;
3322 case AArch64::LDPXi:
3323 case AArch64::LDPDi:
3324 case AArch64::STPXi:
3325 case AArch64::STPDi:
3326 case AArch64::LDNPXi:
3327 case AArch64::LDNPDi:
3328 case AArch64::STNPXi:
3329 case AArch64::STNPDi:
3334 case AArch64::LDPQi:
3335 case AArch64::STPQi:
3336 case AArch64::LDNPQi:
3337 case AArch64::STNPQi:
3342 case AArch64::LDPWi:
3343 case AArch64::LDPSi:
3344 case AArch64::STPWi:
3345 case AArch64::STPSi:
3346 case AArch64::LDNPWi:
3347 case AArch64::LDNPSi:
3348 case AArch64::STNPWi:
3349 case AArch64::STNPSi:
3355 case AArch64::LDURXi:
3356 case AArch64::LDURWi:
3357 case AArch64::LDURBi:
3358 case AArch64::LDURHi:
3359 case AArch64::LDURSi:
3360 case AArch64::LDURDi:
3361 case AArch64::LDURQi:
3362 case AArch64::LDURHHi:
3363 case AArch64::LDURBBi:
3364 case AArch64::LDURSBXi:
3365 case AArch64::LDURSBWi:
3366 case AArch64::LDURSHXi:
3367 case AArch64::LDURSHWi:
3368 case AArch64::LDURSWi:
3369 case AArch64::STURXi:
3370 case AArch64::STURWi:
3371 case AArch64::STURBi:
3372 case AArch64::STURHi:
3373 case AArch64::STURSi:
3374 case AArch64::STURDi:
3375 case AArch64::STURQi:
3376 case AArch64::STURBBi:
3377 case AArch64::STURHHi:
3384 bool useUnscaledOp =
false;
3388 if ((Offset & (Scale - 1)) != 0 || (Offset < 0 && UnscaledOp != 0))
3389 useUnscaledOp =
true;
3398 }
else if (UnscaledOp == 0 || useUnscaledOp) {
3409 int MaxOff = (1 << (MaskBits - IsSigned)) - 1;
3410 int MinOff = (IsSigned ? (-MaxOff - 1) : 0);
3411 if (Offset >= MinOff && Offset <= MaxOff) {
3412 if (EmittableOffset)
3413 *EmittableOffset =
Offset;
3416 int NewOff = Offset < 0 ? MinOff : MaxOff;
3417 if (EmittableOffset)
3418 *EmittableOffset = NewOff;
3419 Offset = (Offset - NewOff) * Scale;
3421 if (OutUseUnscaledOp)
3422 *OutUseUnscaledOp = useUnscaledOp;
3424 *OutUnscaledOp = UnscaledOp;
3430 unsigned FrameReg,
int &
Offset,
3433 unsigned ImmIdx = FrameRegIdx + 1;
3435 if (Opcode == AArch64::ADDSXri || Opcode == AArch64::ADDXri) {
3446 unsigned UnscaledOp;
3449 &UnscaledOp, &NewOffset);
3455 MI.
setDesc(TII->get(UnscaledOp));
3475 case AArch64::ADDSWrr:
3476 case AArch64::ADDSWri:
3477 case AArch64::ADDSXrr:
3478 case AArch64::ADDSXri:
3479 case AArch64::SUBSWrr:
3480 case AArch64::SUBSXrr:
3482 case AArch64::SUBSWri:
3483 case AArch64::SUBSXri:
3494 case AArch64::ADDWrr:
3495 case AArch64::ADDWri:
3496 case AArch64::SUBWrr:
3497 case AArch64::ADDSWrr:
3498 case AArch64::ADDSWri:
3499 case AArch64::SUBSWrr:
3501 case AArch64::SUBWri:
3502 case AArch64::SUBSWri:
3513 case AArch64::ADDXrr:
3514 case AArch64::ADDXri:
3515 case AArch64::SUBXrr:
3516 case AArch64::ADDSXrr:
3517 case AArch64::ADDSXri:
3518 case AArch64::SUBSXrr:
3520 case AArch64::SUBXri:
3521 case AArch64::SUBSXri:
3534 case AArch64::FADDSrr:
3535 case AArch64::FADDDrr:
3536 case AArch64::FADDv2f32:
3537 case AArch64::FADDv2f64:
3538 case AArch64::FADDv4f32:
3539 case AArch64::FSUBSrr:
3540 case AArch64::FSUBDrr:
3541 case AArch64::FSUBv2f32:
3542 case AArch64::FSUBv2f64:
3543 case AArch64::FSUBv4f32:
3560 unsigned CombineOpc,
unsigned ZeroReg = 0,
3561 bool CheckZeroReg =
false) {
3589 unsigned MulOpc,
unsigned ZeroReg) {
3590 return canCombine(MBB, MO, MulOpc, ZeroReg,
true);
3607 case AArch64::FADDDrr:
3608 case AArch64::FADDSrr:
3609 case AArch64::FADDv2f32:
3610 case AArch64::FADDv2f64:
3611 case AArch64::FADDv4f32:
3612 case AArch64::FMULDrr:
3613 case AArch64::FMULSrr:
3614 case AArch64::FMULX32:
3615 case AArch64::FMULX64:
3616 case AArch64::FMULXv2f32:
3617 case AArch64::FMULXv2f64:
3618 case AArch64::FMULXv4f32:
3619 case AArch64::FMULv2f32:
3620 case AArch64::FMULv2f64:
3621 case AArch64::FMULv4f32:
3653 case AArch64::ADDWrr:
3655 "ADDWrr does not have register operands");
3667 case AArch64::ADDXrr:
3679 case AArch64::SUBWrr:
3691 case AArch64::SUBXrr:
3703 case AArch64::ADDWri:
3710 case AArch64::ADDXri:
3717 case AArch64::SUBWri:
3724 case AArch64::SUBXri:
3748 assert(
false &&
"Unsupported FP instruction in combiner\n");
3750 case AArch64::FADDSrr:
3752 "FADDWrr does not have register operands");
3757 AArch64::FMULv1i32_indexed)) {
3765 AArch64::FMULv1i32_indexed)) {
3770 case AArch64::FADDDrr:
3775 AArch64::FMULv1i64_indexed)) {
3783 AArch64::FMULv1i64_indexed)) {
3788 case AArch64::FADDv2f32:
3790 AArch64::FMULv2i32_indexed)) {
3794 AArch64::FMULv2f32)) {
3799 AArch64::FMULv2i32_indexed)) {
3803 AArch64::FMULv2f32)) {
3808 case AArch64::FADDv2f64:
3810 AArch64::FMULv2i64_indexed)) {
3814 AArch64::FMULv2f64)) {
3819 AArch64::FMULv2i64_indexed)) {
3823 AArch64::FMULv2f64)) {
3828 case AArch64::FADDv4f32:
3830 AArch64::FMULv4i32_indexed)) {
3834 AArch64::FMULv4f32)) {
3839 AArch64::FMULv4i32_indexed)) {
3843 AArch64::FMULv4f32)) {
3849 case AArch64::FSUBSrr:
3858 AArch64::FMULv1i32_indexed)) {
3867 case AArch64::FSUBDrr:
3876 AArch64::FMULv1i64_indexed)) {
3885 case AArch64::FSUBv2f32:
3887 AArch64::FMULv2i32_indexed)) {
3891 AArch64::FMULv2f32)) {
3896 AArch64::FMULv2i32_indexed)) {
3900 AArch64::FMULv2f32)) {
3905 case AArch64::FSUBv2f64:
3907 AArch64::FMULv2i64_indexed)) {
3911 AArch64::FMULv2f64)) {
3916 AArch64::FMULv2i64_indexed)) {
3920 AArch64::FMULv2f64)) {
3925 case AArch64::FSUBv4f32:
3927 AArch64::FMULv4i32_indexed)) {
3931 AArch64::FMULv4f32)) {
3936 AArch64::FMULv4i32_indexed)) {
3940 AArch64::FMULv4f32)) {
4039 const unsigned *ReplacedAddend =
nullptr) {
4040 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
4042 unsigned IdxOtherOpd = IdxMulOpd == 1 ? 2 : 1;
4052 if (ReplacedAddend) {
4054 SrcReg2 = *ReplacedAddend;
4088 assert(
false &&
"Invalid FMA instruction kind \n");
4116 unsigned IdxMulOpd,
unsigned MaddOpc,
unsigned VR,
4118 assert(IdxMulOpd == 1 || IdxMulOpd == 2);
4166 DelInstrs, InstrIdxForVirtReg);
4175 Opc = AArch64::MADDWrrr;
4176 RC = &AArch64::GPR32RegClass;
4178 Opc = AArch64::MADDXrrr;
4179 RC = &AArch64::GPR64RegClass;
4190 Opc = AArch64::MADDWrrr;
4191 RC = &AArch64::GPR32RegClass;
4193 Opc = AArch64::MADDXrrr;
4194 RC = &AArch64::GPR64RegClass;
4206 unsigned BitSize, OrrOpc, ZeroReg;
4208 OrrOpc = AArch64::ORRWri;
4209 OrrRC = &AArch64::GPR32spRegClass;
4211 ZeroReg = AArch64::WZR;
4212 Opc = AArch64::MADDWrrr;
4213 RC = &AArch64::GPR32RegClass;
4215 OrrOpc = AArch64::ORRXri;
4216 OrrRC = &AArch64::GPR64spRegClass;
4218 ZeroReg = AArch64::XZR;
4219 Opc = AArch64::MADDXrrr;
4220 RC = &AArch64::GPR64RegClass;
4237 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4238 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4250 unsigned SubOpc, ZeroReg;
4252 SubOpc = AArch64::SUBWrr;
4253 SubRC = &AArch64::GPR32spRegClass;
4254 ZeroReg = AArch64::WZR;
4255 Opc = AArch64::MADDWrrr;
4256 RC = &AArch64::GPR32RegClass;
4258 SubOpc = AArch64::SUBXrr;
4259 SubRC = &AArch64::GPR64spRegClass;
4260 ZeroReg = AArch64::XZR;
4261 Opc = AArch64::MADDXrrr;
4262 RC = &AArch64::GPR64RegClass;
4271 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4272 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4282 Opc = AArch64::MSUBWrrr;
4283 RC = &AArch64::GPR32RegClass;
4285 Opc = AArch64::MSUBXrrr;
4286 RC = &AArch64::GPR64RegClass;
4298 unsigned BitSize, OrrOpc, ZeroReg;
4300 OrrOpc = AArch64::ORRWri;
4301 OrrRC = &AArch64::GPR32spRegClass;
4303 ZeroReg = AArch64::WZR;
4304 Opc = AArch64::MADDWrrr;
4305 RC = &AArch64::GPR32RegClass;
4307 OrrOpc = AArch64::ORRXri;
4308 OrrRC = &AArch64::GPR64spRegClass;
4310 ZeroReg = AArch64::XZR;
4311 Opc = AArch64::MADDXrrr;
4312 RC = &AArch64::GPR64RegClass;
4328 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4329 MUL =
genMaddR(MF, MRI, TII, Root, InsInstrs, 1, Opc, NewVR, RC);
4341 Opc = AArch64::FMADDSrrr;
4342 RC = &AArch64::FPR32RegClass;
4344 Opc = AArch64::FMADDDrrr;
4345 RC = &AArch64::FPR64RegClass;
4356 Opc = AArch64::FMADDSrrr;
4357 RC = &AArch64::FPR32RegClass;
4359 Opc = AArch64::FMADDDrrr;
4360 RC = &AArch64::FPR64RegClass;
4366 Opc = AArch64::FMLAv1i32_indexed;
4367 RC = &AArch64::FPR32RegClass;
4372 Opc = AArch64::FMLAv1i32_indexed;
4373 RC = &AArch64::FPR32RegClass;
4379 Opc = AArch64::FMLAv1i64_indexed;
4380 RC = &AArch64::FPR64RegClass;
4385 Opc = AArch64::FMLAv1i64_indexed;
4386 RC = &AArch64::FPR64RegClass;
4393 RC = &AArch64::FPR64RegClass;
4395 Opc = AArch64::FMLAv2i32_indexed;
4399 Opc = AArch64::FMLAv2f32;
4406 RC = &AArch64::FPR64RegClass;
4408 Opc = AArch64::FMLAv2i32_indexed;
4412 Opc = AArch64::FMLAv2f32;
4420 RC = &AArch64::FPR128RegClass;
4422 Opc = AArch64::FMLAv2i64_indexed;
4426 Opc = AArch64::FMLAv2f64;
4433 RC = &AArch64::FPR128RegClass;
4435 Opc = AArch64::FMLAv2i64_indexed;
4439 Opc = AArch64::FMLAv2f64;
4447 RC = &AArch64::FPR128RegClass;
4449 Opc = AArch64::FMLAv4i32_indexed;
4453 Opc = AArch64::FMLAv4f32;
4461 RC = &AArch64::FPR128RegClass;
4463 Opc = AArch64::FMLAv4i32_indexed;
4467 Opc = AArch64::FMLAv4f32;
4480 Opc = AArch64::FNMSUBSrrr;
4481 RC = &AArch64::FPR32RegClass;
4483 Opc = AArch64::FNMSUBDrrr;
4484 RC = &AArch64::FPR64RegClass;
4497 Opc = AArch64::FNMADDSrrr;
4498 RC = &AArch64::FPR32RegClass;
4500 Opc = AArch64::FNMADDDrrr;
4501 RC = &AArch64::FPR64RegClass;
4514 Opc = AArch64::FMSUBSrrr;
4515 RC = &AArch64::FPR32RegClass;
4517 Opc = AArch64::FMSUBDrrr;
4518 RC = &AArch64::FPR64RegClass;
4525 Opc = AArch64::FMLSv1i32_indexed;
4526 RC = &AArch64::FPR32RegClass;
4532 Opc = AArch64::FMLSv1i64_indexed;
4533 RC = &AArch64::FPR64RegClass;
4540 RC = &AArch64::FPR64RegClass;
4542 Opc = AArch64::FMLSv2i32_indexed;
4546 Opc = AArch64::FMLSv2f32;
4554 RC = &AArch64::FPR128RegClass;
4556 Opc = AArch64::FMLSv2i64_indexed;
4560 Opc = AArch64::FMLSv2f64;
4568 RC = &AArch64::FPR128RegClass;
4570 Opc = AArch64::FMLSv4i32_indexed;
4574 Opc = AArch64::FMLSv4f32;
4581 RC = &AArch64::FPR64RegClass;
4587 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4589 Opc = AArch64::FMLAv2i32_indexed;
4593 Opc = AArch64::FMLAv2f32;
4601 RC = &AArch64::FPR128RegClass;
4607 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4609 Opc = AArch64::FMLAv4i32_indexed;
4613 Opc = AArch64::FMLAv4f32;
4621 RC = &AArch64::FPR128RegClass;
4627 InstrIdxForVirtReg.
insert(std::make_pair(NewVR, 0));
4629 Opc = AArch64::FMLAv2i64_indexed;
4633 Opc = AArch64::FMLAv2f64;
4683 bool IsNegativeBranch =
false;
4684 bool IsTestAndBranch =
false;
4685 unsigned TargetBBInMI = 0;
4695 case AArch64::CBNZW:
4696 case AArch64::CBNZX:
4698 IsNegativeBranch =
true;
4703 IsTestAndBranch =
true;
4705 case AArch64::TBNZW:
4706 case AArch64::TBNZX:
4708 IsNegativeBranch =
true;
4709 IsTestAndBranch =
true;
4730 while (DefMI->
isCopy()) {
4743 case AArch64::ANDWri:
4744 case AArch64::ANDXri: {
4745 if (IsTestAndBranch)
4752 bool Is32Bit = (DefMI->
getOpcode() == AArch64::ANDWri);
4759 unsigned NewReg = MO.
getReg();
4769 unsigned Opc = (Imm < 32)
4770 ? (IsNegativeBranch ? AArch64::TBNZW : AArch64::TBZW)
4771 : (IsNegativeBranch ? AArch64::TBNZX : AArch64::TBZX);
4784 if (!Is32Bit && Imm < 32)
4790 case AArch64::CSINCWr:
4791 case AArch64::CSINCXr: {
4810 if (IsNegativeBranch)
4819 std::pair<unsigned, unsigned>
4822 return std::make_pair(TF & Mask, TF & ~Mask);
4827 using namespace AArch64II;
4829 static const std::pair<unsigned, const char *>
TargetFlags[] = {
4831 {
MO_G3,
"aarch64-g3"}, {
MO_G2,
"aarch64-g2"},
4832 {
MO_G1,
"aarch64-g1"}, {
MO_G0,
"aarch64-g0"},
4839 using namespace AArch64II;
4841 static const std::pair<unsigned, const char *>
TargetFlags[] = {
4848 static const std::pair<MachineMemOperand::Flags, const char *>
TargetFlags[] =
4955 for (
unsigned Reg : AArch64::GPR64RegClass) {
4957 Reg != AArch64::LR &&
4958 Reg != AArch64::X16 &&
4959 Reg != AArch64::X17 &&
4970 std::vector<outliner::Candidate> &RepeatedSequenceLocs)
const {
4971 unsigned SequenceSize = std::accumulate(
4972 RepeatedSequenceLocs[0].front(),
4973 std::next(RepeatedSequenceLocs[0].back()),
4980 std::for_each(RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
5003 RepeatedSequenceLocs.erase(
std::remove_if(RepeatedSequenceLocs.begin(),
5004 RepeatedSequenceLocs.end(),
5005 CantGuaranteeValueAcrossCall),
5006 RepeatedSequenceLocs.end());
5009 if (RepeatedSequenceLocs.empty())
5015 unsigned LastInstrOpcode = RepeatedSequenceLocs[0].back()->getOpcode();
5018 auto SetCandidateCallInfo =
5019 [&RepeatedSequenceLocs](
unsigned CallID,
unsigned NumBytesForCall) {
5021 C.setCallInfo(CallID, NumBytesForCall);
5025 unsigned NumBytesToCreateFrame = 4;
5029 if (RepeatedSequenceLocs[0].back()->isTerminator()) {
5031 NumBytesToCreateFrame = 0;
5035 else if (LastInstrOpcode ==
AArch64::BL || LastInstrOpcode == AArch64::BLR) {
5038 NumBytesToCreateFrame = 0;
5046 else if (
std::all_of(RepeatedSequenceLocs.begin(),
5047 RepeatedSequenceLocs.end(),
5049 return C.LRU.available(AArch64::LR);
5052 NumBytesToCreateFrame = 4;
5059 if (
std::all_of(RepeatedSequenceLocs.begin(), RepeatedSequenceLocs.end(),
5061 return findRegisterToSaveLRTo(
C);
5066 NumBytesToCreateFrame = 4;
5074 NumBytesToCreateFrame = 4;
5082 RepeatedSequenceLocs[0].back(),
5084 NumBytesToCreateFrame += 8;
5092 RepeatedSequenceLocs[0].back()->isCall())
5093 NumBytesToCreateFrame += 8;
5096 NumBytesToCreateFrame, FrameID);
5127 unsigned Flags = 0x0;
5137 "Suitable Machine Function for outlining must track liveness");
5139 LRU.addLiveOuts(MBB);
5145 if (!LRU.available(AArch64::LR))
5153 unsigned Flags)
const {
5185 if (MOP.isCPI() || MOP.isJTI() || MOP.isCFIIndex() || MOP.isFI() ||
5186 MOP.isTargetIndex())
5190 if (MOP.isReg() && !MOP.isImplicit() &&
5191 (MOP.getReg() == AArch64::LR || MOP.getReg() == AArch64::W30))
5219 if (MOP.isGlobal()) {
5227 if (Callee && Callee->
getName() ==
"\01_mcount")
5239 return UnknownCallOutlineType;
5247 return UnknownCallOutlineType;
5255 return UnknownCallOutlineType;
5281 bool MightNeedStackFixUp =
5317 if (!MightNeedStackFixUp)
5331 unsigned DummyWidth;
5335 Base != AArch64::SP)
5340 int64_t MinOffset, MaxOffset;
5348 if (Offset < MinOffset * Scale || Offset > MaxOffset * Scale)
5366 unsigned Base, Width;
5370 if (!
MI.mayLoadOrStore() ||
5372 Base != AArch64::SP)
5377 int64_t Dummy1, Dummy2;
5380 assert(StackOffsetOperand.
isImm() &&
"Stack offset wasn't immediate!");
5382 assert(Scale != 0 &&
"Unexpected opcode!");
5387 int64_t NewImm = (Offset + 16) / Scale;
5388 StackOffsetOperand.
setImm(NewImm);
5399 unsigned TailOpcode;
5401 TailOpcode = AArch64::TCRETURNdi;
5404 TailOpcode = AArch64::TCRETURNri;
5415 return MI.isCall() && !
MI.isReturn();
5421 "Can only fix up stack references once");
5422 fixupPostOutline(MBB);
5432 Et = std::prev(MBB.
end());
5440 It = MBB.
insert(It, STRXpre);
5447 int64_t StackPosEntry =
5455 int64_t LRPosEntry =
5467 Et = MBB.
insert(Et, LDRXpost);
5486 fixupPostOutline(MBB);
5522 unsigned Reg = findRegisterToSaveLRTo(C);
5523 assert(Reg != 0 &&
"No callee-saved register available?");
5548 It = MBB.
insert(It, Save);
5557 It = MBB.
insert(It, Restore);
static bool isStridedAccess(const MachineInstr &MI)
Return true if the given load or store is a strided memory access.
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
void push_back(const T &Elt)
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
MO_G3 - A symbol operand with this flag (granule 3) represents the high 16-bits of a 64-bit address...
static bool isFPRCopy(const MachineInstr &MI)
Does this instruction rename an FPR without modifying bits?
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
instr_iterator instr_begin()
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
AArch64FunctionInfo - This class is derived from MachineFunctionInfo and contains private AArch64-spe...
static unsigned getArithShiftValue(unsigned Imm)
getArithShiftValue - get the arithmetic shift value.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isCall(QueryType Type=AnyInBundle) const
instr_iterator instr_end()
MachineBasicBlock * getMBB() const
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
Compute iterated dominance frontiers using a linear time algorithm.
unsigned getNumObjects() const
Return the number of objects.
MO_PAGE - A symbol operand with this flag represents the pc-relative offset of the 4K page containing...
bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) const override
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
A Module instance is used to store all the information related to an LLVM module. ...
static bool isGPRCopy(const MachineInstr &MI)
Does this instruction rename a GPR without modifying bits?
static bool getFMAPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns)
Floating-Point Support.
static unsigned sForm(MachineInstr &Instr)
Get opcode of S version of Instr.
const MachineInstrBuilder & addCFIIndex(unsigned CFIIndex) const
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool hasZeroCycleZeroing() const
static CondCode getInvertedCondCode(CondCode Code)
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
void setIsUndef(bool Val=true)
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION
static bool isSUBSRegImm(unsigned Opcode)
static bool processLogicalImmediate(uint64_t Imm, unsigned RegSize, uint64_t &Encoding)
processLogicalImmediate - Determine if an immediate value can be encoded as the immediate operand of ...
static bool hasShiftedReg(const MachineInstr &MI)
Returns true if there is a shiftable register and that the shift value is non-zero.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr) const override
unsigned getSubReg() const
LiveRegUnits LRU
Contains physical register liveness information for the MBB containing this Candidate.
Offset can apply, at least partly.
const SetOfInstructions & getLOHRelated() const
Emit a save, restore, call, and return.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
unsigned const TargetRegisterInfo * TRI
MO_G0 - A symbol operand with this flag (granule 0) represents the bits 0-15 of a 64-bit address...
MachineModuleInfo & getMMI() const
bool hasOneDef(unsigned RegNo) const
Return true if there is exactly one operand defining the specified register.
iterator_range< mmo_iterator > memoperands()
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
iterator_range< mop_iterator > operands()
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static unsigned convertToNonFlagSettingOpc(const MachineInstr &MI)
Return the opcode that does not set flags when possible - otherwise return the original opcode...
bool hasCustomCheapAsMoveHandling() const
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
An individual sequence of instructions to be replaced with a call to an outlined function.
static bool isLdStPairSuppressed(const MachineInstr &MI)
Return true if pairing the given load or store is hinted to be unprofitable.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
static bool isUnscaledLdSt(unsigned Opc)
Return true if this is an unscaled load/store.
return AArch64::GPR64RegClass contains(Reg)
iterator_range< succ_iterator > successors()
static const MachineInstrBuilder & AddSubReg(const MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI)
MO_G2 - A symbol operand with this flag (granule 2) represents the bits 32-47 of a 64-bit address...
static bool getMemDoShift(unsigned Imm)
getMemDoShift - Extract the "do shift" flag value for load/store instructions.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
A description of a memory reference used in the backend.
bool isAssociativeAndCommutative(const MachineInstr &Inst) const override
Return true when Inst is associative and commutative so that it can be reassociated.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
unsigned getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const override
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
static void suppressLdStPair(MachineInstr &MI)
Hint that pairing the given load or store is unprofitable.
const HexagonInstrInfo * TII
static bool isPairableLdStInst(const MachineInstr &MI)
Return true if pairing the given load or store may be paired with another.
static AArch64CC::CondCode findCondCodeUsedByInstr(const MachineInstr &Instr)
Find a condition code used by the instruction.
static bool canBeExpandedToORR(const MachineInstr &MI, unsigned BitSize)
Returns true if a MOVi32imm or MOVi64imm can be expanded to an ORRxx.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
bool getMemOpInfo(unsigned Opcode, unsigned &Scale, unsigned &Width, int64_t &MinOffset, int64_t &MaxOffset) const
Returns true if opcode Opc is a memory operation.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, const outliner::Candidate &C) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOutlinerClass
Constants defining how certain sequences should be outlined.
bool useMachineCombiner() const override
AArch64 supports MachineCombiner.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
static int getRegClass(RegisterKind Is, unsigned RegWidth)
unsigned FrameConstructionID
Target-defined identifier for constructing a frame for this function.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
static UsedNZCV getUsedNZCV(AArch64CC::CondCode CC)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
static bool canCombineWithMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc, unsigned ZeroReg)
const char * getSymbolName() const
LLVM_NODISCARD unsigned addFrameInst(const MCCFIInstruction &Inst)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned 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.
zlib-gnu style compression
INLINEASM - Represents an inline asm block.
static bool isCombineInstrCandidate64(unsigned Opc)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool isExynosResetFast(const MachineInstr &MI) const
Returns true if the instruction sets to an immediate value that can be executed more efficiently...
int isAArch64FrameOffsetLegal(const MachineInstr &MI, int &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
AArch64InstrInfo(const AArch64Subtarget &STI)
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
static AArch64_AM::ShiftExtendType getMemExtendType(unsigned Imm)
getExtendType - Extract the extend type for the offset operand of loads/stores.
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
static bool canCombineWithFMUL(MachineBasicBlock &MBB, MachineOperand &MO, unsigned MulOpc)
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
reverse_iterator getReverse() const
Get a reverse iterator to the same node.
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
static bool canCombine(MachineBasicBlock &MBB, MachineOperand &MO, unsigned CombineOpc, unsigned ZeroReg=0, bool CheckZeroReg=false)
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
virtual const TargetInstrInfo * getInstrInfo() const
static const MachineMemOperand::Flags MOSuppressPair
bool shouldClusterMemOps(MachineInstr &FirstLdSt, unsigned BaseReg1, MachineInstr &SecondLdSt, unsigned BaseReg2, unsigned NumLoads) const override
Detect opportunities for ldp/stp formation.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool isExynosShiftLeftFast(const MachineInstr &MI) const
Returns true if the instruction has a shift left that can be executed more efficiently.
amdgpu Simplify well known AMD library false Value * Callee
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
static bool canPairLdStOpc(unsigned FirstOpc, unsigned SecondOpc)
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
reverse_iterator rbegin()
Instances of this class represent a single low-level machine instruction.
unsigned getKillRegState(bool B)
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
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 emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
TargetInstrInfo - Interface to description of machine instruction set.
static bool isCondBranchOpcode(int Opc)
This class is intended to be used as a base class for asm properties and features specific to the tar...
unsigned getDefRegState(bool B)
static bool isCombineInstrCandidateFP(const MachineInstr &Inst)
static unsigned getShiftValue(unsigned Imm)
getShiftValue - Extract the shift value.
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
bool hasLinkOnceODRLinkage() const
initializer< Ty > init(const Ty &Val)
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
FPOpFusion::FPOpFusionMode AllowFPOpFusion
AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option.
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MO_G1 - A symbol operand with this flag (granule 1) represents the bits 16-31 of a 64-bit address...
unsigned const MachineRegisterInfo * MRI
InstrType
Represents how an instruction should be mapped by the outliner.
LiveRegUnits UsedInSequence
Contains the accumulated register liveness information for the instructions in this Candidate...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr *> &InsInstrs, SmallVectorImpl< MachineInstr *> &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
bool hasExynosCheapAsMoveHandling() const
unsigned CallConstructionID
Identifier denoting the instructions to emit to call an outlined function from this point...
static cl::opt< unsigned > BCCDisplacementBits("aarch64-bcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of Bcc instructions (DEBUG)"))
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static AArch64_AM::ShiftExtendType getArithExtendType(unsigned Imm)
The information necessary to create an outlined function for some class of candidate.
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
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...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
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 bool canInstrSubstituteCmpInstr(MachineInstr *MI, MachineInstr *CmpInstr, const TargetRegisterInfo *TRI)
Check if CmpInstr can be substituted by MI.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
bool any_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
bool definesRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
bool def_empty(unsigned RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
static bool isScaledAddr(const MachineInstr &MI)
Return true if this is load/store scales or extends its register offset.
static bool hasExtendedReg(const MachineInstr &MI)
Returns true if there is an extendable register and that the extending value is non-zero.
MI-level patchpoint operands.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
self_iterator getIterator()
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
const MachineInstrBuilder & addFrameIndex(int Idx) const
bool isThroughputPattern(MachineCombinerPattern Pattern) const override
Return true when a code sequence can improve throughput.
MachineCombinerPattern
These are instruction patterns matched by the machine combiner pass.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const override
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
MO_HI12 - This flag indicates that a symbol operand represents the bits 13-24 of a 64-bit address...
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
Emit a call and tail-call.
bool isDebugInstr() const
This class contains a discriminated union of information about pointers in memory operands...
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
bool isCoalescableExtInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned &SubIdx) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
bool hasSubClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a sub-class of or equal to this class.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void setIsKill(bool Val=true)
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
The memory access writes data.
static unsigned canFoldIntoCSel(const MachineRegisterInfo &MRI, unsigned VReg, unsigned *NewVReg=nullptr)
static uint64_t encodeLogicalImmediate(uint64_t imm, unsigned regSize)
encodeLogicalImmediate - Return the encoded immediate value for a logical immediate instruction of th...
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
static bool isIndirectBranchOpcode(int Opc)
void setOpcode(unsigned Op)
static bool isUncondBranchOpcode(int Opc)
void getNoop(MCInst &NopInst) const override
bool shouldOutlineFromFunctionByDefault(MachineFunction &MF) const override
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
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.
bool hasSection() const
Check if this global has a custom object file section.
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
MachineInstrBuilder MachineInstrBuilder & DefMI
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
static bool isCombineInstrCandidate(unsigned Opc)
outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
void addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
Target - Wrapper for Target specific information.
bool isCandidateToMergeOrPair(MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
static bool getMaddPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns)
Find instructions that can be turned into madd.
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
int findRegisterDefOperandIdx(unsigned Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a def of the specified register or -1 if it is not found...
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
static unsigned convertToFlagSettingOpc(unsigned Opc, bool &Is64Bit)
Return the opcode that set flags when possible.
static cl::opt< unsigned > TBZDisplacementBits("aarch64-tbz-offset-bits", cl::Hidden, cl::init(14), cl::desc("Restrict range of TB[N]Z instructions (DEBUG)"))
Optional< bool > hasRedZone() const
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
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 MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isReservedReg(const MachineFunction &MF, unsigned Reg) const
Representation of each machine instruction.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static bool isGPRZero(const MachineInstr &MI)
Does this instruction set its full destination register to zero?
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int CmpMask, int CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction supplying the argument to the comparison into one that...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const override
analyzeCompare - For a comparison instruction, return the source registers in SrcReg and SrcReg2...
static AArch64_AM::ShiftExtendType getShiftType(unsigned Imm)
getShiftType - Extract the shift type.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
MI-level stackmap operands.
virtual void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr *> &InsInstrs, SmallVectorImpl< MachineInstr *> &DelInstrs, DenseMap< unsigned, unsigned > &InstIdxForVirtReg) const
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
static bool areCFlagsAliveInSuccessors(MachineBasicBlock *MBB)
Check if AArch64::NZCV should be alive in successors of MBB.
bool available(unsigned Reg) const
Returns true if no part of physical register Reg is live.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
StringRef getName() const
Return a constant reference to the value's name.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
static MachineOperand CreateImm(int64_t Val)
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
MO_PAGEOFF - A symbol operand with this flag represents the offset of that symbol within a 4K page...
void setSubReg(unsigned subReg)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool getMemOpBaseRegImmOfsWidth(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, unsigned &Width, const TargetRegisterInfo *TRI) const
bool tracksLiveness() const
tracksLiveness - Returns true when tracking register liveness accurately.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
static unsigned getBranchDisplacementBits(unsigned Opc)
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
A set of register units used to track register liveness.
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
static unsigned removeCopies(const MachineRegisterInfo &MRI, unsigned VReg)
static bool isCombineInstrCandidate32(unsigned Opc)
static bool scaleOffset(unsigned Opc, int64_t &Offset)
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
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...
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned getOpcode() const
Return the opcode number for this descriptor.
Primary interface to the complete machine description for the target machine.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
void addOperand(const MCOperand &Op)
MO_NC - Indicates whether the linker is expected to check the symbol reference for overflow...
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
UnaryPredicate for_each(R &&Range, UnaryPredicate P)
Provide wrappers to std::for_each which take ranges instead of having to pass begin/end explicitly...
bool isFalkorShiftExtFast(const MachineInstr &MI) const
Returns true if the instruction has a shift by immediate that can be executed in one cycle less...
static bool isCombineInstrSettingFlag(unsigned Opc)
const MachineOperand & getOperand(unsigned i) const
outliner::OutlinedFunction getOutliningCandidateInfo(std::vector< outliner::Candidate > &RepeatedSequenceLocs) const override
bool isIndirectDebugValue() const
A DBG_VALUE is indirect iff the first operand is a register and the second operand is an immediate...
uint64_t getStackSize() const
Return the number of bytes that must be allocated to hold all of the fixed size frame objects...
static MCOperand createImm(int64_t Val)
MachineFunction * getMF() const
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 unsigned *ReplacedAddend=nullptr)
genFusedMultiply - Generate fused multiply instructions.
int findRegisterUseOperandIdx(unsigned Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
The operation is expected to be selectable directly by the target, and no transformation is necessary...
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static const MachineMemOperand::Flags MOStridedAccess
static bool forwardCopyWillClobberTuple(unsigned DestReg, unsigned SrcReg, unsigned NumRegs)
bool isAsCheapAsAMove(QueryType Type=AllInBundle) const
Returns true if this instruction has the same cost (or less) than a move instruction.
static bool UpdateOperandRegClass(MachineInstr &Instr)
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool empty() const
empty - Check if the array is empty.
void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::OutlinedFunction &OF) const override
static bool isADDSRegImm(unsigned Opcode)