68 #define DEBUG_TYPE "arm-instrinfo" 70 #define GET_INSTRINFO_CTOR_DTOR 71 #include "ARMGenInstrInfo.inc" 75 cl::desc(
"Enable ARM 2-addr to 3-addr conv"));
89 { ARM::VMLAS, ARM::VMULS, ARM::VADDS,
false,
false },
90 { ARM::VMLSS, ARM::VMULS, ARM::VSUBS,
false,
false },
91 { ARM::VMLAD, ARM::VMULD, ARM::VADDD,
false,
false },
92 { ARM::VMLSD, ARM::VMULD, ARM::VSUBD,
false,
false },
93 { ARM::VNMLAS, ARM::VNMULS, ARM::VSUBS,
true,
false },
94 { ARM::VNMLSS, ARM::VMULS, ARM::VSUBS,
true,
false },
95 { ARM::VNMLAD, ARM::VNMULD, ARM::VSUBD,
true,
false },
96 { ARM::VNMLSD, ARM::VMULD, ARM::VSUBD,
true,
false },
99 { ARM::VMLAfd, ARM::VMULfd, ARM::VADDfd,
false,
false },
100 { ARM::VMLSfd, ARM::VMULfd, ARM::VSUBfd,
false,
false },
101 { ARM::VMLAfq, ARM::VMULfq, ARM::VADDfq,
false,
false },
102 { ARM::VMLSfq, ARM::VMULfq, ARM::VSUBfq,
false,
false },
103 { ARM::VMLAslfd, ARM::VMULslfd, ARM::VADDfd,
false,
true },
104 { ARM::VMLSslfd, ARM::VMULslfd, ARM::VSUBfd,
false,
true },
105 { ARM::VMLAslfq, ARM::VMULslfq, ARM::VADDfq,
false,
true },
106 { ARM::VMLSslfq, ARM::VMULslfq, ARM::VSUBfq,
false,
true },
113 if (!MLxEntryMap.
insert(std::make_pair(ARM_MLxTable[i].
MLxOpc, i)).second)
115 MLxHazardOpcodes.
insert(ARM_MLxTable[i].AddSubOpc);
116 MLxHazardOpcodes.
insert(ARM_MLxTable[i].MulOpc);
125 if (usePreRAHazardRecognizer()) {
127 static_cast<const ARMSubtarget *
>(STI)->getInstrItineraryData();
152 default:
return nullptr;
191 get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
196 }
else if (Amt != 0) {
200 get(isSub ? ARM::SUBrsi : ARM::ADDrsi), WBReg)
209 get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
222 get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
229 get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
238 std::vector<MachineInstr*> NewMIs;
253 NewMIs.push_back(MemMI);
254 NewMIs.push_back(UpdateMI);
271 NewMIs.push_back(UpdateMI);
272 NewMIs.push_back(MemMI);
284 MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
289 for (
unsigned j = 0; j < 2; ++j) {
296 VI.
Kills.push_back(NewMI);
305 MFI->insert(MBBI, NewMIs[1]);
306 MFI->insert(MBBI, NewMIs[0]);
315 bool AllowModify)
const {
320 if (I == MBB.
begin())
326 while (
isPredicated(*I) || I->isTerminator() || I->isDebugValue()) {
330 bool CantAnalyze =
false;
333 while (I->isDebugInstr() || !I->isTerminator()) {
334 if (I == MBB.
begin())
345 TBB = I->getOperand(0).getMBB();
351 assert(!FBB &&
"FBB should have been null.");
353 TBB = I->getOperand(0).getMBB();
356 }
else if (I->isReturn()) {
379 while (DI != MBB.
end()) {
390 if (I == MBB.
begin())
402 int *BytesRemoved)
const {
403 assert(!BytesRemoved &&
"code size not handled");
414 I->eraseFromParent();
418 if (I == MBB.
begin())
return 1;
424 I->eraseFromParent();
433 int *BytesAdded)
const {
434 assert(!BytesAdded &&
"code size not handled");
443 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
445 "ARM branch conditions have two components!");
486 while (++I != E && I->isInsideBundle()) {
487 int PIdx = I->findFirstPredOperandIdx();
488 if (PIdx != -1 && I->getOperand(PIdx).getImm() !=
ARMCC::AL)
504 .addImm(Pred[0].getImm())
505 .addReg(Pred[1].
getReg());
512 PMO.
setImm(Pred[0].getImm());
521 if (Pred1.
size() > 2 || Pred2.
size() > 2)
561 for (
const auto &MO : MI.
operands())
562 if (MO.isReg() && MO.getReg() == ARM::CPSR && MO.isDef() && !MO.isDead())
570 return Offset.
getReg() != 0;
581 int64_t OpcImm = Opc.
getImm();
584 return (isSub && Offset.
getReg() != 0);
590 unsigned OffImm = Opc.
getImm();
598 unsigned OffImm = Opc.
getImm();
604 bool SimpleScaled = (isAdd && ShiftOpc ==
ARM_AM::lsl && Amt == 2);
605 return !SimpleScaled;
624 default:
return true;
683 for (
unsigned i = 0,
e =
MI->getNumOperands(); i !=
e; ++i) {
687 if (MO.
getReg() != ARM::CPSR)
713 case TargetOpcode::BUNDLE:
714 return getInstBundleLength(MI);
715 case ARM::MOVi16_ga_pcrel:
716 case ARM::MOVTi16_ga_pcrel:
717 case ARM::t2MOVi16_ga_pcrel:
718 case ARM::t2MOVTi16_ga_pcrel:
721 case ARM::t2MOVi32imm:
723 case ARM::CONSTPOOL_ENTRY:
724 case ARM::JUMPTABLE_INSTS:
725 case ARM::JUMPTABLE_ADDRS:
726 case ARM::JUMPTABLE_TBB:
727 case ARM::JUMPTABLE_TBH:
731 case ARM::Int_eh_sjlj_longjmp:
733 case ARM::tInt_eh_sjlj_longjmp:
735 case ARM::tInt_WIN_eh_sjlj_longjmp:
737 case ARM::Int_eh_sjlj_setjmp:
738 case ARM::Int_eh_sjlj_setjmp_nofp:
740 case ARM::tInt_eh_sjlj_setjmp:
741 case ARM::t2Int_eh_sjlj_setjmp:
742 case ARM::t2Int_eh_sjlj_setjmp_nofp:
757 unsigned ARMBaseInstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
761 while (++I != E && I->isInsideBundle()) {
762 assert(!I->isBundle() &&
"No nested bundle!");
770 unsigned DestReg,
bool KillSrc,
772 unsigned Opc = Subtarget.
isThumb()
773 ? (Subtarget.
isMClass() ? ARM::t2MRS_M : ARM::t2MRS_AR)
777 BuildMI(MBB, I, I->getDebugLoc(),
get(Opc), DestReg);
790 unsigned SrcReg,
bool KillSrc,
792 unsigned Opc = Subtarget.
isThumb()
793 ? (Subtarget.
isMClass() ? ARM::t2MSR_M : ARM::t2MSR_AR)
825 unsigned Cond,
unsigned Inactive) {
834 bool GPRDest = ARM::GPRRegClass.contains(DestReg);
835 bool GPRSrc = ARM::GPRRegClass.contains(SrcReg);
837 if (GPRDest && GPRSrc) {
838 BuildMI(MBB, I, DL,
get(ARM::MOVr), DestReg)
845 bool SPRDest = ARM::SPRRegClass.contains(DestReg);
846 bool SPRSrc = ARM::SPRRegClass.contains(SrcReg);
849 if (SPRDest && SPRSrc)
851 else if (GPRDest && SPRSrc)
853 else if (SPRDest && GPRSrc)
855 else if (ARM::DPRRegClass.
contains(DestReg, SrcReg) && Subtarget.hasFP64())
857 else if (ARM::QPRRegClass.
contains(DestReg, SrcReg))
858 Opc = Subtarget.hasNEON() ? ARM::VORRq : ARM::MVE_VORR;
863 if (Opc == ARM::VORRq || Opc == ARM::MVE_VORR)
865 if (Opc == ARM::MVE_VORR)
873 unsigned BeginIdx = 0;
874 unsigned SubRegs = 0;
878 if (ARM::QQPRRegClass.
contains(DestReg, SrcReg)) {
879 Opc = Subtarget.hasNEON() ? ARM::VORRq : ARM::MVE_VORR;
880 BeginIdx = ARM::qsub_0;
882 }
else if (ARM::QQQQPRRegClass.
contains(DestReg, SrcReg)) {
883 Opc = Subtarget.hasNEON() ? ARM::VORRq : ARM::MVE_VORR;
884 BeginIdx = ARM::qsub_0;
887 }
else if (ARM::DPairRegClass.
contains(DestReg, SrcReg)) {
889 BeginIdx = ARM::dsub_0;
891 }
else if (ARM::DTripleRegClass.
contains(DestReg, SrcReg)) {
893 BeginIdx = ARM::dsub_0;
895 }
else if (ARM::DQuadRegClass.
contains(DestReg, SrcReg)) {
897 BeginIdx = ARM::dsub_0;
899 }
else if (ARM::GPRPairRegClass.
contains(DestReg, SrcReg)) {
900 Opc = Subtarget.isThumb2() ? ARM::tMOVr : ARM::MOVr;
901 BeginIdx = ARM::gsub_0;
903 }
else if (ARM::DPairSpcRegClass.
contains(DestReg, SrcReg)) {
905 BeginIdx = ARM::dsub_0;
908 }
else if (ARM::DTripleSpcRegClass.
contains(DestReg, SrcReg)) {
910 BeginIdx = ARM::dsub_0;
913 }
else if (ARM::DQuadSpcRegClass.
contains(DestReg, SrcReg)) {
915 BeginIdx = ARM::dsub_0;
918 }
else if (ARM::DPRRegClass.
contains(DestReg, SrcReg) &&
919 !Subtarget.hasFP64()) {
921 BeginIdx = ARM::ssub_0;
923 }
else if (SrcReg == ARM::CPSR) {
926 }
else if (DestReg == ARM::CPSR) {
927 copyToCPSR(MBB, I, SrcReg, KillSrc, Subtarget);
929 }
else if (DestReg == ARM::VPR) {
931 BuildMI(MBB, I, I->getDebugLoc(),
get(ARM::VMSR_P0), DestReg)
935 }
else if (SrcReg == ARM::VPR) {
937 BuildMI(MBB, I, I->getDebugLoc(),
get(ARM::VMRS_P0), DestReg)
941 }
else if (DestReg == ARM::FPSCR_NZCV) {
943 BuildMI(MBB, I, I->getDebugLoc(),
get(ARM::VMSR_FPSCR_NZCVQC), DestReg)
947 }
else if (SrcReg == ARM::FPSCR_NZCV) {
949 BuildMI(MBB, I, I->getDebugLoc(),
get(ARM::VMRS_FPSCR_NZCVQC), DestReg)
955 assert(Opc &&
"Impossible reg-to-reg copy");
962 BeginIdx = BeginIdx + ((SubRegs - 1) * Spacing);
968 for (
unsigned i = 0; i != SubRegs; ++i) {
971 assert(Dst && Src &&
"Bad sub-register");
973 assert(!DstRegs.
count(Src) &&
"destructive vector copy");
976 Mov =
BuildMI(MBB, I, I->getDebugLoc(),
get(Opc), Dst).
addReg(Src);
978 if (Opc == ARM::VORRq || Opc == ARM::MVE_VORR) {
982 if (Opc == ARM::MVE_VORR)
987 if (Opc == ARM::MOVr)
1014 unsigned SubIdx,
unsigned State,
1017 return MIB.
addReg(Reg, State);
1021 return MIB.
addReg(Reg, State, SubIdx);
1026 unsigned SrcReg,
bool isKill,
int FI,
1039 if (ARM::HPRRegClass.hasSubClassEq(RC)) {
1050 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
1057 }
else if (ARM::SPRRegClass.hasSubClassEq(RC)) {
1064 }
else if (ARM::VCCRRegClass.hasSubClassEq(RC)) {
1075 if (ARM::DPRRegClass.hasSubClassEq(RC)) {
1082 }
else if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
1083 if (Subtarget.hasV5TEOps()) {
1086 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
1097 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
1103 if (ARM::DPairRegClass.hasSubClassEq(RC) && Subtarget.hasNEON()) {
1119 }
else if (ARM::QPRRegClass.hasSubClassEq(RC) &&
1120 Subtarget.hasMVEIntegerOps()) {
1125 .addMemOperand(MMO);
1131 if (ARM::DTripleRegClass.hasSubClassEq(RC)) {
1134 Subtarget.hasNEON()) {
1148 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1149 AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1155 if (ARM::QQPRRegClass.hasSubClassEq(RC) || ARM::DQuadRegClass.hasSubClassEq(RC)) {
1157 Subtarget.hasNEON()) {
1173 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1174 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1175 AddDReg(MIB, SrcReg, ARM::dsub_3, 0, TRI);
1181 if (ARM::QQQQPRRegClass.hasSubClassEq(RC)) {
1187 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1188 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1189 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_3, 0, TRI);
1190 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_4, 0, TRI);
1191 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_5, 0, TRI);
1192 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_6, 0, TRI);
1193 AddDReg(MIB, SrcReg, ARM::dsub_7, 0, TRI);
1226 case ARM::VSTR_P0_off:
1234 case ARM::VST1d64TPseudo:
1235 case ARM::VST1d64QPseudo:
1255 if (MI.
mayStore() && hasStoreToStackSlot(MI, Accesses) &&
1256 Accesses.
size() == 1) {
1258 cast<FixedStackPseudoSourceValue>(Accesses.
front()->getPseudoValue())
1267 unsigned DestReg,
int FI,
1271 if (I != MBB.
end()) DL = I->getDebugLoc();
1281 if (ARM::HPRRegClass.hasSubClassEq(RC)) {
1282 BuildMI(MBB, I, DL,
get(ARM::VLDRH), DestReg)
1291 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
1292 BuildMI(MBB, I, DL,
get(ARM::LDRi12), DestReg)
1297 }
else if (ARM::SPRRegClass.hasSubClassEq(RC)) {
1298 BuildMI(MBB, I, DL,
get(ARM::VLDRS), DestReg)
1303 }
else if (ARM::VCCRRegClass.hasSubClassEq(RC)) {
1304 BuildMI(MBB, I, DL,
get(ARM::VLDR_P0_off), DestReg)
1313 if (ARM::DPRRegClass.hasSubClassEq(RC)) {
1314 BuildMI(MBB, I, DL,
get(ARM::VLDRD), DestReg)
1319 }
else if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
1322 if (Subtarget.hasV5TEOps()) {
1323 MIB =
BuildMI(MBB, I, DL,
get(ARM::LDRD));
1331 MIB =
BuildMI(MBB, I, DL,
get(ARM::LDMIA))
1345 if (ARM::DPairRegClass.hasSubClassEq(RC) && Subtarget.hasNEON()) {
1347 BuildMI(MBB, I, DL,
get(ARM::VLD1q64), DestReg)
1353 BuildMI(MBB, I, DL,
get(ARM::VLDMQIA), DestReg)
1358 }
else if (ARM::QPRRegClass.hasSubClassEq(RC) &&
1359 Subtarget.hasMVEIntegerOps()) {
1360 auto MIB =
BuildMI(MBB, I, DL,
get(ARM::MVE_VLDRWU32), DestReg);
1361 MIB.addFrameIndex(FI)
1363 .addMemOperand(MMO);
1369 if (ARM::DTripleRegClass.hasSubClassEq(RC)) {
1371 Subtarget.hasNEON()) {
1372 BuildMI(MBB, I, DL,
get(ARM::VLD1d64TPseudo), DestReg)
1392 if (ARM::QQPRRegClass.hasSubClassEq(RC) || ARM::DQuadRegClass.hasSubClassEq(RC)) {
1394 Subtarget.hasNEON()) {
1395 BuildMI(MBB, I, DL,
get(ARM::VLD1d64QPseudo), DestReg)
1416 if (ARM::QQQQPRRegClass.hasSubClassEq(RC)) {
1463 case ARM::VLDR_P0_off:
1471 case ARM::VLD1d8TPseudo:
1472 case ARM::VLD1d16TPseudo:
1473 case ARM::VLD1d32TPseudo:
1474 case ARM::VLD1d64TPseudo:
1475 case ARM::VLD1d8QPseudo:
1476 case ARM::VLD1d16QPseudo:
1477 case ARM::VLD1d32QPseudo:
1478 case ARM::VLD1d64QPseudo:
1498 if (MI.
mayLoad() && hasLoadFromStackSlot(MI, Accesses) &&
1499 Accesses.
size() == 1) {
1501 cast<FixedStackPseudoSourceValue>(Accesses.
front()->getPseudoValue())
1511 bool isThumb1 = Subtarget.isThumb1Only();
1512 bool isThumb2 = Subtarget.isThumb2();
1519 if (isThumb1 || !MI->getOperand(1).isDead()) {
1521 LDM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2LDMIA_UPD
1522 : isThumb1 ? ARM::tLDMIA_UPD
1526 LDM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2LDMIA : ARM::LDMIA));
1529 if (isThumb1 || !MI->getOperand(0).isDead()) {
1531 STM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2STMIA_UPD
1532 : isThumb1 ? ARM::tSTMIA_UPD
1536 STM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2STMIA : ARM::STMIA));
1548 for(
unsigned I = 5;
I < MI->getNumOperands(); ++
I)
1549 ScratchRegs.
push_back(MI->getOperand(
I).getReg());
1551 [&TRI](
const unsigned &Reg1,
const unsigned &Reg2) ->
bool {
1556 for (
const auto &
Reg : ScratchRegs) {
1565 if (MI.
getOpcode() == TargetOpcode::LOAD_STACK_GUARD) {
1567 "LOAD_STACK_GUARD currently supported only for MachO.");
1568 expandLoadStackGuard(MI);
1582 if (!MI.
isCopy() || Subtarget.dontWidenVMOVS() || !Subtarget.hasFP64())
1589 if (!ARM::SPRRegClass.
contains(DstRegS, SrcRegS))
1597 if (!DstRegD || !SrcRegD)
1617 if (ImpDefIdx != -1)
1651 assert(MCPE.isMachineConstantPoolEntry() &&
1652 "Expecting a machine constantpool entry!");
1664 if (ACPV->isGlobalValue())
1666 cast<ARMConstantPoolConstant>(ACPV)->getGV(), PCLabelId,
ARMCP::CPValue,
1667 4, ACPV->getModifier(), ACPV->mustAddCurrentAddress());
1668 else if (ACPV->isExtSymbol())
1671 cast<ARMConstantPoolSymbol>(ACPV)->getSymbol(), PCLabelId, 4);
1672 else if (ACPV->isBlockAddress())
1674 Create(cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress(), PCLabelId,
1676 else if (ACPV->isLSDA())
1679 else if (ACPV->isMachineBasicBlock())
1682 cast<ARMConstantPoolMBB>(ACPV)->getMBB(), PCLabelId, 4);
1691 unsigned DestReg,
unsigned SubIdx,
1702 case ARM::tLDRpci_pic:
1703 case ARM::t2LDRpci_pic: {
1723 switch (I->getOpcode()) {
1724 case ARM::tLDRpci_pic:
1725 case ARM::t2LDRpci_pic: {
1727 unsigned CPI = I->getOperand(1).getIndex();
1729 I->getOperand(1).setIndex(CPI);
1730 I->getOperand(2).setImm(PCLabelId);
1734 if (!I->isBundledWithSucc())
1745 if (Opcode == ARM::t2LDRpci ||
1746 Opcode == ARM::t2LDRpci_pic ||
1747 Opcode == ARM::tLDRpci ||
1748 Opcode == ARM::tLDRpci_pic ||
1749 Opcode == ARM::LDRLIT_ga_pcrel ||
1750 Opcode == ARM::LDRLIT_ga_pcrel_ldr ||
1751 Opcode == ARM::tLDRLIT_ga_pcrel ||
1752 Opcode == ARM::MOV_ga_pcrel ||
1753 Opcode == ARM::MOV_ga_pcrel_ldr ||
1754 Opcode == ARM::t2MOV_ga_pcrel) {
1765 if (Opcode == ARM::LDRLIT_ga_pcrel ||
1766 Opcode == ARM::LDRLIT_ga_pcrel_ldr ||
1767 Opcode == ARM::tLDRLIT_ga_pcrel ||
1768 Opcode == ARM::MOV_ga_pcrel ||
1769 Opcode == ARM::MOV_ga_pcrel_ldr ||
1770 Opcode == ARM::t2MOV_ga_pcrel)
1782 if (isARMCP0 && isARMCP1) {
1788 }
else if (!isARMCP0 && !isARMCP1) {
1792 }
else if (Opcode == ARM::PICLDR) {
1800 if (Addr0 != Addr1) {
1837 int64_t &Offset2)
const {
1839 if (Subtarget.isThumb1Only())
return false;
1858 case ARM::t2LDRSHi8:
1860 case ARM::t2LDRBi12:
1861 case ARM::t2LDRSHi12:
1878 case ARM::t2LDRSHi8:
1880 case ARM::t2LDRBi12:
1881 case ARM::t2LDRSHi12:
1895 if (isa<ConstantSDNode>(Load1->
getOperand(1)) &&
1897 Offset1 = cast<ConstantSDNode>(Load1->
getOperand(1))->getSExtValue();
1898 Offset2 = cast<ConstantSDNode>(Load2->
getOperand(1))->getSExtValue();
1917 int64_t Offset1, int64_t Offset2,
1918 unsigned NumLoads)
const {
1920 if (Subtarget.isThumb1Only())
return false;
1922 assert(Offset2 > Offset1);
1924 if ((Offset2 - Offset1) / 8 > 64)
1970 while (++I != MBB->
end() && I->isDebugInstr())
1972 if (I != MBB->
end() && I->getOpcode() == ARM::t2IT)
1991 unsigned NumCycles,
unsigned ExtraPredCycles,
2001 if (!Pred->
empty()) {
2003 if (LastMI->
getOpcode() == ARM::t2Bcc) {
2012 MBB, 0, 0, Probability);
2017 unsigned TCycles,
unsigned TExtra,
2019 unsigned FCycles,
unsigned FExtra,
2036 const unsigned ScalingUpFactor = 1024;
2038 unsigned PredCost = (TCycles + FCycles + TExtra + FExtra) * ScalingUpFactor;
2039 unsigned UnpredCost;
2040 if (!Subtarget.hasBranchPredictor()) {
2043 unsigned NotTakenBranchCost = 1;
2044 unsigned TakenBranchCost = Subtarget.getMispredictionPenalty();
2045 unsigned TUnpredCycles, FUnpredCycles;
2048 TUnpredCycles = TCycles + NotTakenBranchCost;
2049 FUnpredCycles = TakenBranchCost;
2052 TUnpredCycles = TCycles + TakenBranchCost;
2053 FUnpredCycles = FCycles + NotTakenBranchCost;
2056 PredCost -= 1 * ScalingUpFactor;
2059 unsigned TUnpredCost = Probability.
scale(TUnpredCycles * ScalingUpFactor);
2060 unsigned FUnpredCost = Probability.
getCompl().
scale(FUnpredCycles * ScalingUpFactor);
2061 UnpredCost = TUnpredCost + FUnpredCost;
2064 if (Subtarget.isThumb2() && TCycles + FCycles > 4) {
2065 PredCost += ((TCycles + FCycles - 4) / 4) * ScalingUpFactor;
2068 unsigned TUnpredCost = Probability.
scale(TCycles * ScalingUpFactor);
2069 unsigned FUnpredCost =
2071 UnpredCost = TUnpredCost + FUnpredCost;
2072 UnpredCost += 1 * ScalingUpFactor;
2073 UnpredCost += Subtarget.getMispredictionPenalty() * ScalingUpFactor / 10;
2076 return PredCost <= UnpredCost;
2081 unsigned NumInsts)
const {
2085 return Subtarget.isThumb2() ?
divideCeil(NumInsts, 4) * 2 : 0;
2105 if (Subtarget.isThumb2())
2116 return Subtarget.isProfitableToUnpredicate();
2123 unsigned &PredReg) {
2139 if (Opc == ARM::t2B)
2148 unsigned OpIdx2)
const {
2151 case ARM::t2MOVCCr: {
2153 unsigned PredReg = 0;
2156 if (CC ==
ARMCC::AL || PredReg != ARM::CPSR)
2203 bool DontMoveAcrossStores =
true;
2211 unsigned &TrueOp,
unsigned &FalseOp,
2212 bool &Optimizable)
const {
2214 "Unknown select instruction");
2233 bool PreferFalse)
const {
2235 "Unknown select instruction");
2238 bool Invert = !
DefMI;
2258 for (
unsigned i = 1,
e = DefDesc.getNumOperands();
2259 i !=
e && !DefDesc.OpInfo[i].isPredicate(); ++i)
2278 NewMI.
add(FalseReg);
2283 SeenMIs.
erase(DefMI);
2309 {ARM::ADDSri, ARM::ADDri},
2310 {ARM::ADDSrr, ARM::ADDrr},
2311 {ARM::ADDSrsi, ARM::ADDrsi},
2312 {ARM::ADDSrsr, ARM::ADDrsr},
2314 {ARM::SUBSri, ARM::SUBri},
2315 {ARM::SUBSrr, ARM::SUBrr},
2316 {ARM::SUBSrsi, ARM::SUBrsi},
2317 {ARM::SUBSrsr, ARM::SUBrsr},
2319 {ARM::RSBSri, ARM::RSBri},
2320 {ARM::RSBSrsi, ARM::RSBrsi},
2321 {ARM::RSBSrsr, ARM::RSBrsr},
2323 {ARM::tADDSi3, ARM::tADDi3},
2324 {ARM::tADDSi8, ARM::tADDi8},
2325 {ARM::tADDSrr, ARM::tADDrr},
2326 {ARM::tADCS, ARM::tADC},
2328 {ARM::tSUBSi3, ARM::tSUBi3},
2329 {ARM::tSUBSi8, ARM::tSUBi8},
2330 {ARM::tSUBSrr, ARM::tSUBrr},
2331 {ARM::tSBCS, ARM::tSBC},
2332 {ARM::tRSBS, ARM::tRSB},
2333 {ARM::tLSLSri, ARM::tLSLri},
2335 {ARM::t2ADDSri, ARM::t2ADDri},
2336 {ARM::t2ADDSrr, ARM::t2ADDrr},
2337 {ARM::t2ADDSrs, ARM::t2ADDrs},
2339 {ARM::t2SUBSri, ARM::t2SUBri},
2340 {ARM::t2SUBSrr, ARM::t2SUBrr},
2341 {ARM::t2SUBSrs, ARM::t2SUBrs},
2343 {ARM::t2RSBSri, ARM::t2RSBri},
2344 {ARM::t2RSBSrs, ARM::t2RSBrs},
2348 for (
unsigned i = 0,
e =
array_lengthof(AddSubFlagsOpcodeMap); i !=
e; ++i)
2349 if (OldOpc == AddSubFlagsOpcodeMap[i].PseudoOpc)
2356 const DebugLoc &dl,
unsigned DestReg,
2357 unsigned BaseReg,
int NumBytes,
2361 if (NumBytes == 0 && DestReg != BaseReg) {
2362 BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), DestReg)
2370 bool isSub = NumBytes < 0;
2371 if (isSub) NumBytes = -NumBytes;
2376 assert(ThisVal &&
"Didn't extract field correctly");
2379 NumBytes &= ~ThisVal;
2384 unsigned Opc = isSub ? ARM::SUBri : ARM::ADDri;
2385 BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
2397 unsigned NumBytes) {
2408 if (!IsPush && !IsPop)
2411 bool IsVFPPushPop = MI->
getOpcode() == ARM::VSTMDDB_UPD ||
2413 bool IsT1PushPop = MI->
getOpcode() == ARM::tPUSH ||
2419 "trying to fold sp update into non-sp-updating push/pop");
2424 if (NumBytes % (IsVFPPushPop ? 8 : 4) != 0)
2429 int RegListIdx = IsT1PushPop ? 2 : 4;
2432 unsigned RegsNeeded;
2435 RegsNeeded = NumBytes / 8;
2436 RegClass = &ARM::DPRRegClass;
2438 RegsNeeded = NumBytes / 4;
2439 RegClass = &ARM::GPRRegClass;
2449 unsigned FirstRegEnc = -1;
2464 for (
int CurRegEnc = FirstRegEnc - 1; CurRegEnc >= 0 && RegsNeeded;
2466 unsigned CurReg = RegClass->
getRegister(CurRegEnc);
2474 false,
false,
true));
2511 for (
int i = RegList.
size() - 1; i >= 0; --i)
2512 MIB.
add(RegList[i]);
2518 unsigned FrameReg,
int &
Offset,
2529 if (Opcode == ARM::ADDri) {
2533 MI.
setDesc(TII.get(ARM::MOVr));
2538 }
else if (Offset < 0) {
2541 MI.
setDesc(TII.get(ARM::SUBri));
2559 Offset &= ~ThisImmVal;
2563 "Bit extraction didn't work?");
2566 unsigned ImmIdx = 0;
2568 unsigned NumBits = 0;
2572 ImmIdx = FrameRegIdx + 1;
2577 ImmIdx = FrameRegIdx+2;
2584 ImmIdx = FrameRegIdx+2;
2595 ImmIdx = FrameRegIdx+1;
2603 ImmIdx = FrameRegIdx+1;
2613 ImmIdx = FrameRegIdx+1;
2623 Offset += InstrOffs * Scale;
2624 assert((Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
2634 int ImmedOffset = Offset / Scale;
2635 unsigned Mask = (1 << NumBits) - 1;
2636 if ((
unsigned)Offset <= Mask * Scale) {
2644 ImmedOffset = -ImmedOffset;
2646 ImmedOffset |= 1 << NumBits;
2654 ImmedOffset = ImmedOffset &
Mask;
2657 ImmedOffset = -ImmedOffset;
2659 ImmedOffset |= 1 << NumBits;
2662 Offset &= ~(Mask*Scale);
2666 Offset = (isSub) ? -Offset : Offset;
2675 unsigned &SrcReg2,
int &CmpMask,
2676 int &CmpValue)
const {
2712 int CmpMask,
bool CommonUse) {
2746 unsigned SrcReg,
unsigned SrcReg2,
2808 default:
return false;
2882 MachineInstr &CmpInstr,
unsigned SrcReg,
unsigned SrcReg2,
int CmpMask,
2886 if (!MI)
return false;
2889 if (CmpMask != ~0) {
2895 if (UI->getParent() != CmpInstr.
getParent())
2904 if (!MI)
return false;
2913 if (I == B)
return false;
2929 if (CmpInstr.
getOpcode() == ARM::CMPri ||
2937 bool IsThumb1 =
false;
2954 if (MI && IsThumb1) {
2957 bool CanReorder =
true;
2958 for (; I !=
E; --
I) {
2959 if (I->getOpcode() != ARM::tMOVi8) {
2976 bool SubAddIsThumb1 =
false;
3014 IsThumb1 = SubAddIsThumb1;
3029 bool isSafe =
false;
3032 while (!isSafe && ++I != E) {
3035 !isSafe && IO != EO; ++IO) {
3049 bool IsInstrVSel =
true;
3052 IsInstrVSel =
false;
3086 bool IsSub = Opc == ARM::SUBrr || Opc == ARM::t2SUBrr ||
3087 Opc == ARM::SUBri || Opc == ARM::t2SUBri ||
3088 Opc == ARM::tSUBrr || Opc == ARM::tSUBi3 ||
3090 unsigned OpI = Opc != ARM::tSUBrr ? 1 : 2;
3102 std::make_pair(&((*I).getOperand(IO - 1)), NewCC));
3137 if ((*SI)->isLiveIn(ARM::CPSR))
3153 for (
unsigned i = 0,
e = OperandsToUpdate.
size(); i <
e; i++)
3154 OperandsToUpdate[i].
first->setImm(OperandsToUpdate[i].second);
3169 unsigned SrcReg, SrcReg2;
3170 int CmpMask, CmpValue;
3184 if (DefOpc != ARM::t2MOVi32imm && DefOpc != ARM::MOVi32imm)
3213 unsigned NewUseOpc = 0;
3215 uint32_t SOImmValV1 = 0, SOImmValV2 = 0;
3216 bool Commute =
false;
3218 default:
return false;
3226 case ARM::t2EORrr: {
3232 if (UseOpc == ARM::SUBrr && Commute)
3238 NewUseOpc = UseOpc == ARM::ADDrr ? ARM::ADDri : ARM::SUBri;
3241 NewUseOpc = UseOpc == ARM::ADDrr ? ARM::SUBri : ARM::ADDri;
3255 case ARM::ORRrr: NewUseOpc = ARM::ORRri;
break;
3256 case ARM::EORrr: NewUseOpc = ARM::EORri;
break;
3260 case ARM::t2SUBrr: {
3261 if (UseOpc == ARM::t2SUBrr && Commute)
3267 const unsigned t2ADD = ToSP ? ARM::t2ADDspImm : ARM::t2ADDri;
3268 const unsigned t2SUB = ToSP ? ARM::t2SUBspImm : ARM::t2SUBri;
3270 NewUseOpc = UseOpc == ARM::t2ADDrr ? t2ADD : t2SUB;
3273 NewUseOpc = UseOpc == ARM::t2ADDrr ? t2SUB : t2ADD;
3288 case ARM::t2ORRrr: NewUseOpc = ARM::t2ORRri;
break;
3289 case ARM::t2EORrr: NewUseOpc = ARM::t2EORri;
break;
3296 unsigned OpIdx = Commute ? 2 : 1;
3307 UseMI.
setDesc(
get(NewUseOpc));
3318 case ARM::t2ADDspImm:
3319 case ARM::t2SUBspImm:
3333 assert(UOps >= 0 &&
"bad # UOps");
3346 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3362 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3372 case ARM::LDRSB_POST:
3373 case ARM::LDRSH_POST: {
3376 return (Rt == Rm) ? 4 : 3;
3379 case ARM::LDR_PRE_REG:
3380 case ARM::LDRB_PRE_REG: {
3390 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3396 case ARM::STR_PRE_REG:
3397 case ARM::STRB_PRE_REG: {
3403 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3410 case ARM::STRH_PRE: {
3420 case ARM::LDR_POST_REG:
3421 case ARM::LDRB_POST_REG:
3422 case ARM::LDRH_POST: {
3425 return (Rt == Rm) ? 3 : 2;
3428 case ARM::LDR_PRE_IMM:
3429 case ARM::LDRB_PRE_IMM:
3430 case ARM::LDR_POST_IMM:
3431 case ARM::LDRB_POST_IMM:
3432 case ARM::STRB_POST_IMM:
3433 case ARM::STRB_POST_REG:
3434 case ARM::STRB_PRE_IMM:
3435 case ARM::STRH_POST:
3436 case ARM::STR_POST_IMM:
3437 case ARM::STR_POST_REG:
3438 case ARM::STR_PRE_IMM:
3441 case ARM::LDRSB_PRE:
3442 case ARM::LDRSH_PRE: {
3454 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3467 return (Rt == Rn) ? 3 : 2;
3478 case ARM::LDRD_POST:
3479 case ARM::t2LDRD_POST:
3482 case ARM::STRD_POST:
3483 case ARM::t2STRD_POST:
3486 case ARM::LDRD_PRE: {
3493 return (Rt == Rn) ? 4 : 3;
3496 case ARM::t2LDRD_PRE: {
3499 return (Rt == Rn) ? 4 : 3;
3502 case ARM::STRD_PRE: {
3510 case ARM::t2STRD_PRE:
3513 case ARM::t2LDR_POST:
3514 case ARM::t2LDRB_POST:
3515 case ARM::t2LDRB_PRE:
3516 case ARM::t2LDRSBi12:
3517 case ARM::t2LDRSBi8:
3518 case ARM::t2LDRSBpci:
3520 case ARM::t2LDRH_POST:
3521 case ARM::t2LDRH_PRE:
3523 case ARM::t2LDRSB_POST:
3524 case ARM::t2LDRSB_PRE:
3525 case ARM::t2LDRSH_POST:
3526 case ARM::t2LDRSH_PRE:
3527 case ARM::t2LDRSHi12:
3528 case ARM::t2LDRSHi8:
3529 case ARM::t2LDRSHpci:
3533 case ARM::t2LDRDi8: {
3536 return (Rt == Rn) ? 3 : 2;
3539 case ARM::t2STRB_POST:
3540 case ARM::t2STRB_PRE:
3543 case ARM::t2STRH_POST:
3544 case ARM::t2STRH_PRE:
3546 case ARM::t2STR_POST:
3547 case ARM::t2STR_PRE:
3580 Size += (*I)->getSize();
3587 return std::min(Size / 4, 16U);
3592 unsigned UOps = 1 + NumRegs;
3596 case ARM::VLDMDIA_UPD:
3597 case ARM::VLDMDDB_UPD:
3598 case ARM::VLDMSIA_UPD:
3599 case ARM::VLDMSDB_UPD:
3600 case ARM::VSTMDIA_UPD:
3601 case ARM::VSTMDDB_UPD:
3602 case ARM::VSTMSIA_UPD:
3603 case ARM::VSTMSDB_UPD:
3604 case ARM::LDMIA_UPD:
3605 case ARM::LDMDA_UPD:
3606 case ARM::LDMDB_UPD:
3607 case ARM::LDMIB_UPD:
3608 case ARM::STMIA_UPD:
3609 case ARM::STMDA_UPD:
3610 case ARM::STMDB_UPD:
3611 case ARM::STMIB_UPD:
3612 case ARM::tLDMIA_UPD:
3613 case ARM::tSTMIA_UPD:
3614 case ARM::t2LDMIA_UPD:
3615 case ARM::t2LDMDB_UPD:
3616 case ARM::t2STMIA_UPD:
3617 case ARM::t2STMDB_UPD:
3620 case ARM::LDMIA_RET:
3622 case ARM::t2LDMIA_RET:
3631 if (!ItinData || ItinData->
isEmpty())
3637 if (ItinUOps >= 0) {
3663 case ARM::VLDMDIA_UPD:
3664 case ARM::VLDMDDB_UPD:
3666 case ARM::VLDMSIA_UPD:
3667 case ARM::VLDMSDB_UPD:
3669 case ARM::VSTMDIA_UPD:
3670 case ARM::VSTMDDB_UPD:
3672 case ARM::VSTMSIA_UPD:
3673 case ARM::VSTMSDB_UPD: {
3675 return (NumRegs / 2) + (NumRegs % 2) + 1;
3678 case ARM::LDMIA_RET:
3683 case ARM::LDMIA_UPD:
3684 case ARM::LDMDA_UPD:
3685 case ARM::LDMDB_UPD:
3686 case ARM::LDMIB_UPD:
3691 case ARM::STMIA_UPD:
3692 case ARM::STMDA_UPD:
3693 case ARM::STMDB_UPD:
3694 case ARM::STMIB_UPD:
3696 case ARM::tLDMIA_UPD:
3697 case ARM::tSTMIA_UPD:
3701 case ARM::t2LDMIA_RET:
3704 case ARM::t2LDMIA_UPD:
3705 case ARM::t2LDMDB_UPD:
3708 case ARM::t2STMIA_UPD:
3709 case ARM::t2STMDB_UPD: {
3711 switch (Subtarget.getLdStMultipleTiming()) {
3722 unsigned UOps = (NumRegs / 2);
3728 unsigned UOps = (NumRegs / 2);
3746 unsigned DefIdx,
unsigned DefAlign)
const {
3753 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3755 DefCycle = RegNo / 2 + 1;
3758 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3760 bool isSLoad =
false;
3765 case ARM::VLDMSIA_UPD:
3766 case ARM::VLDMSDB_UPD:
3773 if ((isSLoad && (RegNo % 2)) || DefAlign < 8)
3777 DefCycle = RegNo + 2;
3787 if (
Op.isReg() &&
Op.getReg() == BaseReg)
3803 unsigned DefIdx,
unsigned DefAlign)
const {
3810 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3813 DefCycle = RegNo / 2;
3818 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3819 DefCycle = (RegNo / 2);
3822 if ((RegNo % 2) || DefAlign < 8)
3828 DefCycle = RegNo + 2;
3838 unsigned UseIdx,
unsigned UseAlign)
const {
3844 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3846 UseCycle = RegNo / 2 + 1;
3849 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3851 bool isSStore =
false;
3856 case ARM::VSTMSIA_UPD:
3857 case ARM::VSTMSDB_UPD:
3864 if ((isSStore && (RegNo % 2)) || UseAlign < 8)
3868 UseCycle = RegNo + 2;
3878 unsigned UseIdx,
unsigned UseAlign)
const {
3884 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3885 UseCycle = RegNo / 2;
3890 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3891 UseCycle = (RegNo / 2);
3894 if ((RegNo % 2) || UseAlign < 8)
3906 unsigned DefIdx,
unsigned DefAlign,
3908 unsigned UseIdx,
unsigned UseAlign)
const {
3919 bool LdmBypass =
false;
3926 case ARM::VLDMDIA_UPD:
3927 case ARM::VLDMDDB_UPD:
3929 case ARM::VLDMSIA_UPD:
3930 case ARM::VLDMSDB_UPD:
3931 DefCycle = getVLDMDefCycle(ItinData, DefMCID, DefClass, DefIdx, DefAlign);
3934 case ARM::LDMIA_RET:
3939 case ARM::LDMIA_UPD:
3940 case ARM::LDMDA_UPD:
3941 case ARM::LDMDB_UPD:
3942 case ARM::LDMIB_UPD:
3944 case ARM::tLDMIA_UPD:
3946 case ARM::t2LDMIA_RET:
3949 case ARM::t2LDMIA_UPD:
3950 case ARM::t2LDMDB_UPD:
3952 DefCycle = getLDMDefCycle(ItinData, DefMCID, DefClass, DefIdx, DefAlign);
3967 case ARM::VSTMDIA_UPD:
3968 case ARM::VSTMDDB_UPD:
3970 case ARM::VSTMSIA_UPD:
3971 case ARM::VSTMSDB_UPD:
3972 UseCycle = getVSTMUseCycle(ItinData, UseMCID, UseClass, UseIdx, UseAlign);
3979 case ARM::STMIA_UPD:
3980 case ARM::STMDA_UPD:
3981 case ARM::STMDB_UPD:
3982 case ARM::STMIB_UPD:
3983 case ARM::tSTMIA_UPD:
3988 case ARM::t2STMIA_UPD:
3989 case ARM::t2STMDB_UPD:
3990 UseCycle = getSTMUseCycle(ItinData, UseMCID, UseClass, UseIdx, UseAlign);
3998 UseCycle = DefCycle - UseCycle + 1;
4007 UseClass, UseIdx)) {
4017 unsigned &DefIdx,
unsigned &Dist) {
4022 assert(II->isInsideBundle() &&
"Empty bundle?");
4025 while (II->isInsideBundle()) {
4026 Idx = II->findRegisterDefOperandIdx(Reg,
false,
true, TRI);
4033 assert(Idx != -1 &&
"Cannot find bundled definition!");
4040 unsigned &UseIdx,
unsigned &Dist) {
4044 assert(II->isInsideBundle() &&
"Empty bundle?");
4049 while (II != E && II->isInsideBundle()) {
4050 Idx = II->findRegisterUseOperandIdx(Reg,
false, TRI);
4053 if (II->getOpcode() != ARM::t2IT)
4091 case ARM::t2LDRSHs: {
4094 if (ShAmt == 0 || ShAmt == 2)
4099 }
else if (Subtarget.
isSwift()) {
4111 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
4122 case ARM::t2LDRSHs: {
4125 if (ShAmt == 0 || ShAmt == 1 || ShAmt == 2 || ShAmt == 3)
4139 case ARM::VLD1q8wb_fixed:
4140 case ARM::VLD1q16wb_fixed:
4141 case ARM::VLD1q32wb_fixed:
4142 case ARM::VLD1q64wb_fixed:
4143 case ARM::VLD1q8wb_register:
4144 case ARM::VLD1q16wb_register:
4145 case ARM::VLD1q32wb_register:
4146 case ARM::VLD1q64wb_register:
4153 case ARM::VLD2d8wb_fixed:
4154 case ARM::VLD2d16wb_fixed:
4155 case ARM::VLD2d32wb_fixed:
4156 case ARM::VLD2q8wb_fixed:
4157 case ARM::VLD2q16wb_fixed:
4158 case ARM::VLD2q32wb_fixed:
4159 case ARM::VLD2d8wb_register:
4160 case ARM::VLD2d16wb_register:
4161 case ARM::VLD2d32wb_register:
4162 case ARM::VLD2q8wb_register:
4163 case ARM::VLD2q16wb_register:
4164 case ARM::VLD2q32wb_register:
4169 case ARM::VLD3d8_UPD:
4170 case ARM::VLD3d16_UPD:
4171 case ARM::VLD3d32_UPD:
4172 case ARM::VLD1d64Twb_fixed:
4173 case ARM::VLD1d64Twb_register:
4174 case ARM::VLD3q8_UPD:
4175 case ARM::VLD3q16_UPD:
4176 case ARM::VLD3q32_UPD:
4181 case ARM::VLD4d8_UPD:
4182 case ARM::VLD4d16_UPD:
4183 case ARM::VLD4d32_UPD:
4184 case ARM::VLD1d64Qwb_fixed:
4185 case ARM::VLD1d64Qwb_register:
4186 case ARM::VLD4q8_UPD:
4187 case ARM::VLD4q16_UPD:
4188 case ARM::VLD4q32_UPD:
4189 case ARM::VLD1DUPq8:
4190 case ARM::VLD1DUPq16:
4191 case ARM::VLD1DUPq32:
4192 case ARM::VLD1DUPq8wb_fixed:
4193 case ARM::VLD1DUPq16wb_fixed:
4194 case ARM::VLD1DUPq32wb_fixed:
4195 case ARM::VLD1DUPq8wb_register:
4196 case ARM::VLD1DUPq16wb_register:
4197 case ARM::VLD1DUPq32wb_register:
4198 case ARM::VLD2DUPd8:
4199 case ARM::VLD2DUPd16:
4200 case ARM::VLD2DUPd32:
4201 case ARM::VLD2DUPd8wb_fixed:
4202 case ARM::VLD2DUPd16wb_fixed:
4203 case ARM::VLD2DUPd32wb_fixed:
4204 case ARM::VLD2DUPd8wb_register:
4205 case ARM::VLD2DUPd16wb_register:
4206 case ARM::VLD2DUPd32wb_register:
4207 case ARM::VLD4DUPd8:
4208 case ARM::VLD4DUPd16:
4209 case ARM::VLD4DUPd32:
4210 case ARM::VLD4DUPd8_UPD:
4211 case ARM::VLD4DUPd16_UPD:
4212 case ARM::VLD4DUPd32_UPD:
4214 case ARM::VLD1LNd16:
4215 case ARM::VLD1LNd32:
4216 case ARM::VLD1LNd8_UPD:
4217 case ARM::VLD1LNd16_UPD:
4218 case ARM::VLD1LNd32_UPD:
4220 case ARM::VLD2LNd16:
4221 case ARM::VLD2LNd32:
4222 case ARM::VLD2LNq16:
4223 case ARM::VLD2LNq32:
4224 case ARM::VLD2LNd8_UPD:
4225 case ARM::VLD2LNd16_UPD:
4226 case ARM::VLD2LNd32_UPD:
4227 case ARM::VLD2LNq16_UPD:
4228 case ARM::VLD2LNq32_UPD:
4230 case ARM::VLD4LNd16:
4231 case ARM::VLD4LNd32:
4232 case ARM::VLD4LNq16:
4233 case ARM::VLD4LNq32:
4234 case ARM::VLD4LNd8_UPD:
4235 case ARM::VLD4LNd16_UPD:
4236 case ARM::VLD4LNd32_UPD:
4237 case ARM::VLD4LNq16_UPD:
4238 case ARM::VLD4LNq32_UPD:
4252 unsigned UseIdx)
const {
4254 if (!ItinData || ItinData->
isEmpty())
4261 unsigned DefAdj = 0;
4271 unsigned UseAdj = 0;
4279 return getOperandLatencyImpl(
4280 ItinData, *ResolvedDefMI, DefIdx, ResolvedDefMI->
getDesc(), DefAdj, DefMO,
4281 Reg, *ResolvedUseMI, UseIdx, ResolvedUseMI->getDesc(), UseAdj);
4284 int ARMBaseInstrInfo::getOperandLatencyImpl(
4286 unsigned DefIdx,
const MCInstrDesc &DefMCID,
unsigned DefAdj,
4288 unsigned UseIdx,
const MCInstrDesc &UseMCID,
unsigned UseAdj)
const {
4289 if (Reg == ARM::CPSR) {
4292 return Subtarget.isLikeA9() ? 1 : 20;
4300 unsigned Latency = getInstrLatency(ItinData, DefMI);
4306 if (Latency > 0 && Subtarget.isThumb2()) {
4333 int Adj = DefAdj + UseAdj;
4337 if (Adj >= 0 || (
int)Latency > -Adj) {
4338 return Latency + Adj;
4346 SDNode *DefNode,
unsigned DefIdx,
4347 SDNode *UseNode,
unsigned UseIdx)
const {
4353 if (isZeroCost(DefMCID.
Opcode))
4356 if (!ItinData || ItinData->
isEmpty())
4357 return DefMCID.
mayLoad() ? 3 : 1;
4361 int Adj = Subtarget.getPreISelOperandLatencyAdjustment();
4363 return Latency <= Threshold ? 1 : Latency - Adj;
4367 auto *DefMN = cast<MachineSDNode>(DefNode);
4368 unsigned DefAlign = !DefMN->memoperands_empty()
4370 auto *UseMN = cast<MachineSDNode>(UseNode);
4371 unsigned UseAlign = !UseMN->memoperands_empty()
4374 UseMCID, UseIdx, UseAlign);
4377 (Subtarget.isCortexA8() || Subtarget.isLikeA9() ||
4378 Subtarget.isCortexA7())) {
4386 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4396 case ARM::t2LDRSHs: {
4399 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4400 if (ShAmt == 0 || ShAmt == 2)
4405 }
else if (DefIdx == 0 && Latency > 2 && Subtarget.isSwift()) {
4413 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4416 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
4433 if (DefAlign < 8 && Subtarget.checkVLDnAccessAlignment())
4440 case ARM::VLD1q8wb_register:
4441 case ARM::VLD1q16wb_register:
4442 case ARM::VLD1q32wb_register:
4443 case ARM::VLD1q64wb_register:
4444 case ARM::VLD1q8wb_fixed:
4445 case ARM::VLD1q16wb_fixed:
4446 case ARM::VLD1q32wb_fixed:
4447 case ARM::VLD1q64wb_fixed:
4451 case ARM::VLD2q8Pseudo:
4452 case ARM::VLD2q16Pseudo:
4453 case ARM::VLD2q32Pseudo:
4454 case ARM::VLD2d8wb_fixed:
4455 case ARM::VLD2d16wb_fixed:
4456 case ARM::VLD2d32wb_fixed:
4457 case ARM::VLD2q8PseudoWB_fixed:
4458 case ARM::VLD2q16PseudoWB_fixed:
4459 case ARM::VLD2q32PseudoWB_fixed:
4460 case ARM::VLD2d8wb_register:
4461 case ARM::VLD2d16wb_register:
4462 case ARM::VLD2d32wb_register:
4463 case ARM::VLD2q8PseudoWB_register:
4464 case ARM::VLD2q16PseudoWB_register:
4465 case ARM::VLD2q32PseudoWB_register:
4466 case ARM::VLD3d8Pseudo:
4467 case ARM::VLD3d16Pseudo:
4468 case ARM::VLD3d32Pseudo:
4469 case ARM::VLD1d8TPseudo:
4470 case ARM::VLD1d16TPseudo:
4471 case ARM::VLD1d32TPseudo:
4472 case ARM::VLD1d64TPseudo:
4473 case ARM::VLD1d64TPseudoWB_fixed:
4474 case ARM::VLD1d64TPseudoWB_register:
4475 case ARM::VLD3d8Pseudo_UPD:
4476 case ARM::VLD3d16Pseudo_UPD:
4477 case ARM::VLD3d32Pseudo_UPD:
4478 case ARM::VLD3q8Pseudo_UPD:
4479 case ARM::VLD3q16Pseudo_UPD:
4480 case ARM::VLD3q32Pseudo_UPD:
4481 case ARM::VLD3q8oddPseudo:
4482 case ARM::VLD3q16oddPseudo:
4483 case ARM::VLD3q32oddPseudo:
4484 case ARM::VLD3q8oddPseudo_UPD:
4485 case ARM::VLD3q16oddPseudo_UPD:
4486 case ARM::VLD3q32oddPseudo_UPD:
4487 case ARM::VLD4d8Pseudo:
4488 case ARM::VLD4d16Pseudo:
4489 case ARM::VLD4d32Pseudo:
4490 case ARM::VLD1d8QPseudo:
4491 case ARM::VLD1d16QPseudo:
4492 case ARM::VLD1d32QPseudo:
4493 case ARM::VLD1d64QPseudo:
4494 case ARM::VLD1d64QPseudoWB_fixed:
4495 case ARM::VLD1d64QPseudoWB_register:
4496 case ARM::VLD1q8HighQPseudo:
4497 case ARM::VLD1q8LowQPseudo_UPD:
4498 case ARM::VLD1q8HighTPseudo:
4499 case ARM::VLD1q8LowTPseudo_UPD:
4500 case ARM::VLD1q16HighQPseudo:
4501 case ARM::VLD1q16LowQPseudo_UPD:
4502 case ARM::VLD1q16HighTPseudo:
4503 case ARM::VLD1q16LowTPseudo_UPD:
4504 case ARM::VLD1q32HighQPseudo:
4505 case ARM::VLD1q32LowQPseudo_UPD:
4506 case ARM::VLD1q32HighTPseudo:
4507 case ARM::VLD1q32LowTPseudo_UPD:
4508 case ARM::VLD1q64HighQPseudo:
4509 case ARM::VLD1q64LowQPseudo_UPD:
4510 case ARM::VLD1q64HighTPseudo:
4511 case ARM::VLD1q64LowTPseudo_UPD:
4512 case ARM::VLD4d8Pseudo_UPD:
4513 case ARM::VLD4d16Pseudo_UPD:
4514 case ARM::VLD4d32Pseudo_UPD:
4515 case ARM::VLD4q8Pseudo_UPD:
4516 case ARM::VLD4q16Pseudo_UPD:
4517 case ARM::VLD4q32Pseudo_UPD:
4518 case ARM::VLD4q8oddPseudo:
4519 case ARM::VLD4q16oddPseudo:
4520 case ARM::VLD4q32oddPseudo:
4521 case ARM::VLD4q8oddPseudo_UPD:
4522 case ARM::VLD4q16oddPseudo_UPD:
4523 case ARM::VLD4q32oddPseudo_UPD:
4524 case ARM::VLD1DUPq8:
4525 case ARM::VLD1DUPq16:
4526 case ARM::VLD1DUPq32:
4527 case ARM::VLD1DUPq8wb_fixed:
4528 case ARM::VLD1DUPq16wb_fixed:
4529 case ARM::VLD1DUPq32wb_fixed:
4530 case ARM::VLD1DUPq8wb_register:
4531 case ARM::VLD1DUPq16wb_register:
4532 case ARM::VLD1DUPq32wb_register:
4533 case ARM::VLD2DUPd8:
4534 case ARM::VLD2DUPd16:
4535 case ARM::VLD2DUPd32:
4536 case ARM::VLD2DUPd8wb_fixed:
4537 case ARM::VLD2DUPd16wb_fixed:
4538 case ARM::VLD2DUPd32wb_fixed:
4539 case ARM::VLD2DUPd8wb_register:
4540 case ARM::VLD2DUPd16wb_register:
4541 case ARM::VLD2DUPd32wb_register:
4542 case ARM::VLD2DUPq8EvenPseudo:
4543 case ARM::VLD2DUPq8OddPseudo:
4544 case ARM::VLD2DUPq16EvenPseudo:
4545 case ARM::VLD2DUPq16OddPseudo:
4546 case ARM::VLD2DUPq32EvenPseudo:
4547 case ARM::VLD2DUPq32OddPseudo:
4548 case ARM::VLD3DUPq8EvenPseudo:
4549 case ARM::VLD3DUPq8OddPseudo:
4550 case ARM::VLD3DUPq16EvenPseudo:
4551 case ARM::VLD3DUPq16OddPseudo:
4552 case ARM::VLD3DUPq32EvenPseudo:
4553 case ARM::VLD3DUPq32OddPseudo:
4554 case ARM::VLD4DUPd8Pseudo:
4555 case ARM::VLD4DUPd16Pseudo:
4556 case ARM::VLD4DUPd32Pseudo:
4557 case ARM::VLD4DUPd8Pseudo_UPD:
4558 case ARM::VLD4DUPd16Pseudo_UPD:
4559 case ARM::VLD4DUPd32Pseudo_UPD:
4560 case ARM::VLD4DUPq8EvenPseudo:
4561 case ARM::VLD4DUPq8OddPseudo:
4562 case ARM::VLD4DUPq16EvenPseudo:
4563 case ARM::VLD4DUPq16OddPseudo:
4564 case ARM::VLD4DUPq32EvenPseudo:
4565 case ARM::VLD4DUPq32OddPseudo:
4566 case ARM::VLD1LNq8Pseudo:
4567 case ARM::VLD1LNq16Pseudo:
4568 case ARM::VLD1LNq32Pseudo:
4569 case ARM::VLD1LNq8Pseudo_UPD:
4570 case ARM::VLD1LNq16Pseudo_UPD:
4571 case ARM::VLD1LNq32Pseudo_UPD:
4572 case ARM::VLD2LNd8Pseudo:
4573 case ARM::VLD2LNd16Pseudo:
4574 case ARM::VLD2LNd32Pseudo:
4575 case ARM::VLD2LNq16Pseudo:
4576 case ARM::VLD2LNq32Pseudo:
4577 case ARM::VLD2LNd8Pseudo_UPD:
4578 case ARM::VLD2LNd16Pseudo_UPD:
4579 case ARM::VLD2LNd32Pseudo_UPD:
4580 case ARM::VLD2LNq16Pseudo_UPD:
4581 case ARM::VLD2LNq32Pseudo_UPD:
4582 case ARM::VLD4LNd8Pseudo:
4583 case ARM::VLD4LNd16Pseudo:
4584 case ARM::VLD4LNd32Pseudo:
4585 case ARM::VLD4LNq16Pseudo:
4586 case ARM::VLD4LNq32Pseudo:
4587 case ARM::VLD4LNd8Pseudo_UPD:
4588 case ARM::VLD4LNd16Pseudo_UPD:
4589 case ARM::VLD4LNd32Pseudo_UPD:
4590 case ARM::VLD4LNq16Pseudo_UPD:
4591 case ARM::VLD4LNq32Pseudo_UPD:
4601 unsigned ARMBaseInstrInfo::getPredicationCost(
const MachineInstr &MI)
const {
4612 !Subtarget.cheapPredicableCPSRDef())) {
4622 unsigned *PredCost)
const {
4633 while (++I != E && I->isInsideBundle()) {
4634 if (I->getOpcode() != ARM::t2IT)
4635 Latency += getInstrLatency(ItinData, *I, PredCost);
4642 !Subtarget.cheapPredicableCPSRDef()))) {
4665 if (Adj >= 0 || (
int)Latency > -Adj) {
4666 return Latency + Adj;
4676 if (!ItinData || ItinData->
isEmpty())
4689 bool ARMBaseInstrInfo::hasHighOperandLatency(
const TargetSchedModel &SchedModel,
4694 unsigned UseIdx)
const {
4697 if (Subtarget.nonpipelinedVFP() &&
4710 bool ARMBaseInstrInfo::hasLowDefLatency(
const TargetSchedModel &SchedModel,
4712 unsigned DefIdx)
const {
4714 if (!ItinData || ItinData->
isEmpty())
4721 return (DefCycle != -1 && DefCycle <= 2);
4726 bool ARMBaseInstrInfo::verifyInstruction(
const MachineInstr &MI,
4729 ErrInfo =
"Pseudo flag setting opcodes only exist in Selection DAG";
4732 if (MI.
getOpcode() == ARM::tMOVr && !Subtarget.hasV6Ops()) {
4736 ErrInfo =
"Non-flag-setting Thumb1 mov is v6-only";
4748 if (Reg < ARM::R0 || Reg > ARM::R7) {
4749 if (!(MI.
getOpcode() == ARM::tPUSH && Reg == ARM::LR) &&
4750 !(MI.
getOpcode() == ARM::tPOP_RET && Reg == ARM::PC)) {
4751 ErrInfo =
"Unsupported register in Thumb1 push/pop";
4763 unsigned LoadImmOpc,
4764 unsigned LoadOpc)
const {
4765 assert(!Subtarget.isROPI() && !Subtarget.isRWPI() &&
4766 "ROPI/RWPI not currently supported with stack guard");
4770 Register Reg = MI->getOperand(0).getReg();
4772 cast<GlobalValue>((*MI->memoperands_begin())->getValue());
4775 BuildMI(MBB, MI, DL,
get(LoadImmOpc), Reg)
4778 if (Subtarget.isGVIndirectSymbol(GV)) {
4779 MIB =
BuildMI(MBB, MI, DL,
get(LoadOpc), Reg);
4789 MIB =
BuildMI(MBB, MI, DL,
get(LoadOpc), Reg);
4798 unsigned &AddSubOpc,
4799 bool &NegAcc,
bool &HasLane)
const {
4801 if (I == MLxEntryMap.
end())
4832 std::pair<uint16_t, uint16_t>
4836 if (Subtarget.hasNEON()) {
4844 if (Subtarget.useNEONForFPMovs() && !
isPredicated(MI) &&
4853 return std::make_pair(
ExeNEON, 0);
4858 return std::make_pair(
ExeNEON, 0);
4861 return std::make_pair(
ExeVFP, 0);
4867 unsigned SReg,
unsigned &Lane) {
4871 if (DReg != ARM::NoRegister)
4877 assert(DReg &&
"S-register with no D super-register?");
4898 unsigned Lane,
unsigned &ImplicitSReg) {
4908 (Lane & 1) ? ARM::ssub_0 : ARM::ssub_1);
4924 unsigned Domain)
const {
4925 unsigned DstReg, SrcReg, DReg;
4941 assert(Subtarget.hasNEON() &&
"VORRd requires NEON");
4974 MI.
setDesc(
get(ARM::VGETLNi32));
4995 unsigned ImplicitSReg;
5004 MI.
setDesc(
get(ARM::VSETLNi32));
5014 if (ImplicitSReg != 0)
5026 unsigned DstLane = 0, SrcLane = 0, DDst, DSrc;
5030 unsigned ImplicitSReg;
5040 MI.
setDesc(
get(ARM::VDUPLN32d));
5050 if (ImplicitSReg != 0)
5074 unsigned CurReg = SrcLane == 1 && DstLane == 1 ? DSrc : DDst;
5078 CurReg = SrcLane == 0 && DstLane == 0 ? DSrc : DDst;
5084 if (SrcLane == DstLane)
5087 MI.
setDesc(
get(ARM::VEXTd32));
5092 CurReg = SrcLane == 1 && DstLane == 0 ? DSrc : DDst;
5093 CurUndef = CurReg == DSrc && !MI.
readsRegister(CurReg, TRI);
5096 CurReg = SrcLane == 0 && DstLane == 1 ? DSrc : DDst;
5097 CurUndef = CurReg == DSrc && !MI.
readsRegister(CurReg, TRI);
5102 if (SrcLane != DstLane)
5108 if (ImplicitSReg != 0)
5134 auto PartialUpdateClearance = Subtarget.getPartialUpdateClearance();
5135 if (!PartialUpdateClearance)
5138 assert(TRI &&
"Need TRI instance");
5152 case ARM::VMOVv4i16:
5153 case ARM::VMOVv2i32:
5154 case ARM::VMOVv2f32:
5155 case ARM::VMOVv1i64:
5160 case ARM::VLD1LNd32:
5177 }
else if (ARM::SPRRegClass.
contains(Reg)) {
5187 return PartialUpdateClearance;
5195 assert(TRI &&
"Need TRI instance");
5200 "Can't break virtual register dependencies.");
5201 unsigned DReg =
Reg;
5204 if (ARM::SPRRegClass.
contains(Reg)) {
5205 DReg = ARM::D0 + (Reg - ARM::S0) / 2;
5209 assert(ARM::DPRRegClass.
contains(DReg) &&
"Can only break D-reg deps");
5227 return Subtarget.getFeatureBits()[ARM::HasV6KOps];
5237 ((ShImm == 1 || ShImm == 2) &&
5288 InputReg.
SubIdx = DefIdx == 0 ? ARM::ssub_0 : ARM::ssub_1;
5301 case ARM::VSETLNi32:
5311 InsertedReg.
Reg = MOInsertedReg.
getReg();
5313 InsertedReg.
SubIdx = MOIndex.
getImm() == 0 ? ARM::ssub_0 : ARM::ssub_1;
5319 std::pair<unsigned, unsigned>
5322 return std::make_pair(TF & Mask, TF & ~Mask);
5327 using namespace ARMII;
5329 static const std::pair<unsigned, const char *> TargetFlags[] = {
5336 using namespace ARMII;
5338 static const std::pair<unsigned, const char *> TargetFlags[] = {
5360 if (Opcode == ARM::SUBri)
5362 else if (Opcode != ARM::ADDri)
5380 for (
auto I = From;
I != To; ++
I)
5381 if (
I->modifiesRegister(Reg, TRI))
5394 if (CmpMI->modifiesRegister(ARM::CPSR, TRI))
5396 if (CmpMI->readsRegister(ARM::CPSR, TRI))
5402 if (CmpMI->getOpcode() != ARM::tCMPi8 && CmpMI->getOpcode() != ARM::t2CMPri)
5404 Register Reg = CmpMI->getOperand(0).getReg();
5405 unsigned PredReg = 0;
5407 if (Pred !=
ARMCC::AL || CmpMI->getOperand(1).getImm() != 0)
5422 return ForCodesize ? 2 : 1;
5423 if (Subtarget->
hasV6T2Ops() && (Val <= 0xffff ||
5426 return ForCodesize ? 4 : 1;
5428 return ForCodesize ? 4 : 2;
5430 return ForCodesize ? 4 : 2;
5432 return ForCodesize ? 4 : 2;
5435 return ForCodesize ? 4 : 1;
5437 return ForCodesize ? 4 : 1;
5438 if (Subtarget->
hasV6T2Ops() && Val <= 0xffff)
5439 return ForCodesize ? 4 : 1;
5441 return ForCodesize ? 8 : 2;
5444 return ForCodesize ? 8 : 2;
5445 return ForCodesize ? 8 : 3;
bool isLdstSoMinusReg(const MachineInstr &MI, unsigned Op) const
MachineConstantPoolValue * MachineCPVal
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
bool isProfitableToUnpredicate(MachineBasicBlock &TMBB, MachineBasicBlock &FMBB) const override
bool getInsertSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const override
Build the equivalent inputs of a INSERT_SUBREG for the given MI and DefIdx.
union llvm::MachineConstantPoolEntry::@168 Val
The constant itself.
unsigned predictBranchSizeForIfCvt(MachineInstr &MI) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool checkVLDnAccessAlignment() const
BranchProbability getCompl() const
int findFirstPredOperandIdx() const
Find the index of the first operand in the operand list that is used to represent the predicate...
bool isCall(QueryType Type=AnyInBundle) const
Wrapper class representing physical registers. Should be passed by value.
instr_iterator instr_end()
unsigned getT2SOImmTwoPartFirst(unsigned Imm)
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
This class represents lattice values for constants.
bool DefinesPredicate(MachineInstr &MI, std::vector< MachineOperand > &Pred) const override
LivenessQueryResult computeRegisterLiveness(const TargetRegisterInfo *TRI, unsigned Reg, const_iterator Before, unsigned Neighborhood=10) const
Return whether (physical) register Reg has been defined and not killed as of just before Before...
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getRegister(unsigned i) const
Return the specified register in the class.
bool isExtractSubregLike(QueryType Type=IgnoreBundle) const
Return true if this instruction behaves the same way as the generic EXTRACT_SUBREG instructions...
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
ARMConstantPoolValue - ARM specific constantpool value.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
void setIsDef(bool Val=true)
Change a def to a use, or a use to a def.
Describe properties that are true of each instruction in the target description file.
bool expandPostRAPseudo(MachineInstr &MI) const override
void setIsUndef(bool Val=true)
static bool isSuitableForMask(MachineInstr *&MI, unsigned SrcReg, int CmpMask, bool CommonUse)
isSuitableForMask - Identify a suitable 'and' instruction that operates on the given source register ...
int findRegisterDefOperandIdx(Register 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 isPredicated(const MachineInstr &MI) const override
virtual MachineInstr & duplicate(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) const
Clones instruction or the whole instruction bundle Orig and insert into MBB before InsertBefore...
unsigned getSubReg() const
bool isPredicable(QueryType Type=AllInBundle) const
Return true if this instruction has a predicate operand that controls execution.
bool isV8EligibleForIT(const InstrType *Instr)
static unsigned getCorrespondingDRegAndLane(const TargetRegisterInfo *TRI, unsigned SReg, unsigned &Lane)
bool readsVirtualRegister(Register Reg) const
Return true if the MachineInstr reads the specified virtual register.
bool isRegSequence() const
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool isSOImmTwoPartVal(unsigned V)
isSOImmTwoPartVal - Return true if the specified value can be obtained by or'ing together two SOImmVa...
VarInfo - This represents the regions where a virtual register is live in the program.
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
unsigned getPartialRegUpdateClearance(const MachineInstr &, unsigned, const TargetRegisterInfo *) const override
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isLdstScaledRegNotPlusLsl2(const MachineInstr &MI, unsigned Op) const
bool tryFoldSPUpdateIntoPushPop(const ARMSubtarget &Subtarget, MachineFunction &MF, MachineInstr *MI, unsigned NumBytes)
Tries to add registers to the reglist of a given base-updating push/pop instruction to adjust the sta...
bool mayLoad() const
Return true if this instruction could possibly read memory.
unsigned getSOImmTwoPartSecond(unsigned V)
getSOImmTwoPartSecond - If V is a value that satisfies isSOImmTwoPartVal, return the second chunk of ...
iterator_range< mop_iterator > operands()
static bool isRedundantFlagInstr(const MachineInstr *CmpI, unsigned SrcReg, unsigned SrcReg2, int ImmValue, const MachineInstr *OI, bool &IsThumb1)
isRedundantFlagInstr - check whether the first instruction, whose only purpose is to update flags...
bool isCopyLike() const
Return true if the instruction behaves like a copy.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned createPICLabelUId()
static bool isThumb(const MCSubtargetInfo &STI)
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) 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 ...
static bool isOptimizeCompareCandidate(MachineInstr *MI, bool &IsThumb1)
void clearRegisterDeads(Register Reg)
Clear all dead flags on operands defining register Reg.
return AArch64::GPR64RegClass contains(Reg)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
bool registerDefinedBetween(unsigned Reg, MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const TargetRegisterInfo *TRI)
Return true if Reg is defd between From and To.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool removeKill(MachineInstr &MI)
removeKill - Delete a kill corresponding to the specified machine instruction.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
void clearKillInfo()
Clears kill flags on all operands.
static bool isCPSRDefined(const MachineInstr &MI)
Can load/store 1 register/cycle.
static uint32_t getAlignment(const MCSectionCOFF &Sec)
bool isFpMLxInstruction(unsigned Opcode) const
isFpMLxInstruction - Return true if the specified opcode is a fp MLA / MLS instruction.
A description of a memory reference used in the backend.
MO_SBREL - On a symbol operand, this represents a static base relative relocation.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
void addUnpredicatedMveVpredROp(MachineInstrBuilder &MIB, unsigned DestReg)
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
ShiftOpc getAM2ShiftOpc(unsigned AM2Opc)
unsigned getSOImmValRotate(unsigned Imm)
getSOImmValRotate - Try to handle Imm with an immediate shifter operand, computing the rotate amount ...
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Provide an instruction scheduling machine model to CodeGen passes.
const HexagonInstrInfo * TII
void substituteRegister(Register FromReg, Register ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumOperands() const
Retuns the total number of operands.
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 if h...
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void setImplicit(bool Val=true)
static bool isLoad(int Opcode)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool rewriteARMFrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const ARMBaseInstrInfo &TII)
rewriteARMFrameIndex / rewriteT2FrameIndex - Rewrite MI to access 'Offset' bytes from the FP...
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
This file contains the simple types necessary to represent the attributes associated with functions a...
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
const MachineInstrBuilder & AddDReg(MachineInstrBuilder &MIB, unsigned Reg, unsigned SubIdx, unsigned State, const TargetRegisterInfo *TRI) const
void setExecutionDomain(MachineInstr &MI, unsigned Domain) const override
unsigned extraSizeToPredicateInstructions(const MachineFunction &MF, unsigned NumInsts) const override
bool isAm2ScaledReg(const MachineInstr &MI, unsigned Op) const
The memory access is dereferenceable (i.e., doesn't trap).
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
ScheduleHazardRecognizer * CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const override
const InstrItineraryData * getInstrItineraries() const
bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2, int64_t Offset1, int64_t Offset2, unsigned NumLoads) const override
shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to determine (in conjunction w...
const char * getSymbolName() const
static ARMCC::CondCodes getCmpToAddCondition(ARMCC::CondCodes CC)
getCmpToAddCondition - assume the flags are set by CMP(a,b), return the condition code if we modify t...
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.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool analyzeSelect(const MachineInstr &MI, SmallVectorImpl< MachineOperand > &Cond, unsigned &TrueOp, unsigned &FalseOp, bool &Optimizable) const override
INLINEASM - Represents an inline asm block.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
defusechain_iterator - This class provides iterator support for machine operands in the function that...
bool regsOverlap(Register regA, Register regB) const
Returns true if the two registers are equal or alias each other.
Used to describe a register and immediate addition.
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const override
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const override
FoldImmediate - 'Reg' is known to be defined by a move immediate instruction, try to fold the immedia...
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static std::array< MachineOperand, 2 > predOps(ARMCC::CondCodes Pred, unsigned PredReg=0)
Get the operands corresponding to the given Pred value.
unsigned char getAM3Offset(unsigned AM3Opc)
MO_GOT - This flag indicates that a symbol operand represents the address of the GOT entry for the sy...
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
Commutes the operands in the given instruction.
Can load/store 2 registers/cycle, but needs an extra cycle if the access is not 64-bit aligned...
bool addRegisterKilled(Register IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
instr_iterator getInstrIterator() const
unsigned getNumMicroOps(const InstrItineraryData *ItinData, const MachineInstr &MI) const override
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned TargetFlags=0) const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isThumb2Function() const
Itinerary data supplied by a subtarget to be used by a target.
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
const ARMSubtarget & getSubtarget() const
int getNumMicroOps(unsigned ItinClassIndx) const
Return the number of micro-ops that the given class decodes to.
This class is a data container for one entry in a MachineConstantPool.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
void setReg(Register Reg)
Change the register this operand corresponds to.
static const ARM_MLxEntry ARM_MLxTable[]
unsigned getMatchingCondBranchOpcode(unsigned Opc)
ARM_MLxEntry - Record information about MLA / MLS instructions.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getUndefRegState(bool B)
virtual const MCPhysReg * getCalleeSavedRegs(const MachineFunction *MF) const =0
Return a null-terminated list of all of the callee-saved registers on this target.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getStageLatency(unsigned ItinClassIndx) const
Return the total stage latency of the given class.
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()
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
BasicBlockListType::iterator iterator
unsigned getKillRegState(bool B)
void addUnpredicatedMveVpredNOp(MachineInstrBuilder &MIB)
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
TargetInstrInfo - Interface to description of machine instruction set.
AddrOpc getAM2Op(unsigned AM2Opc)
static bool isCondBranchOpcode(int Opc)
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
const Constant * ConstVal
This class is intended to be used as a base class for asm properties and features specific to the tar...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
static bool isCalleeSavedRegister(unsigned Reg, const MCPhysReg *CSRegs)
MO_SECREL - On a symbol operand this indicates that the immediate is the offset from beginning of sec...
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
unsigned char getAM5Offset(unsigned AM5Opc)
const TargetRegisterInfo * getTargetRegisterInfo() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AddrOpc getAM3Op(unsigned AM3Opc)
unsigned const MachineRegisterInfo * MRI
void addPredicatedMveVpredNOp(MachineInstrBuilder &MIB, unsigned Cond)
bool SubsumesPredicate(ArrayRef< MachineOperand > Pred1, ArrayRef< MachineOperand > Pred2) const override
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
bool hasOptionalDef() const
Set if this instruction has an optional definition, e.g.
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...
unsigned getSORegOffset(unsigned Op)
bool isThumbImmShiftedVal(unsigned V)
isThumbImmShiftedVal - Return true if the specified value can be obtained by left shifting a 8-bit im...
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
int getOperandLatency(unsigned DefClass, unsigned DefIdx, unsigned UseClass, unsigned UseIdx) const
Compute and return the use operand latency of a given itinerary class and operand index if the value ...
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const override
areLoadsFromSameBasePtr - This is used by the pre-regalloc scheduler to determine if two loads are lo...
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
const SDValue & getOperand(unsigned Num) const
unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const GlobalValue * getGlobal() const
void expandLoadStackGuardBase(MachineBasicBlock::iterator MI, unsigned LoadImmOpc, unsigned LoadOpc) const
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Returns the size of the specified MachineInstr.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static bool isJumpTableBranchOpcode(int Opc)
bool isAddrMode3OpImm(const MachineInstr &MI, unsigned Op) const
virtual bool hasSameValue(ARMConstantPoolValue *ACPV)
hasSameValue - Return true if this ARM constpool value can share the same constantpool entry as anoth...
static bool isEligibleForITBlock(const MachineInstr *MI)
Register is known to be fully dead.
static const MachineInstr * getBundledUseMI(const TargetRegisterInfo *TRI, const MachineInstr &MI, unsigned Reg, unsigned &UseIdx, unsigned &Dist)
use_instr_iterator use_instr_begin(unsigned RegNo) const
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
int getT2SOImmVal(unsigned Arg)
getT2SOImmVal - Given a 32-bit immediate, if it is something that can fit into a Thumb-2 shifter_oper...
void setImm(int64_t immVal)
unsigned convertAddSubFlagsOpcode(unsigned OldOpc)
Map pseudo instructions that imply an 'S' bit onto real opcodes.
bool isSuperRegister(MCRegister RegA, MCRegister RegB) const
Returns true if RegB is a super-register of RegA.
self_iterator getIterator()
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
const MachineInstrBuilder & addFrameIndex(int Idx) const
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
MachineInstr * findCMPToFoldIntoCBZ(MachineInstr *Br, const TargetRegisterInfo *TRI)
Search backwards from a tBcc to find a tCMPi8 against 0, meaning we can convert them to a tCBZ or tCB...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
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)
Register is known to be (at least partially) live.
unsigned rotr32(unsigned Val, unsigned Amt)
rotr32 - Rotate a 32-bit unsigned value right by a specified # bits.
succ_iterator succ_begin()
void emitARMRegPlusImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator &MBBI, const DebugLoc &dl, unsigned DestReg, unsigned BaseReg, int NumBytes, ARMCC::CondCodes Pred, unsigned PredReg, const ARMBaseInstrInfo &TII, unsigned MIFlags=0)
emitARMRegPlusImmediate / emitT2RegPlusImmediate - Emits a series of instructions to materializea des...
bool isInsertSubregLike(QueryType Type=IgnoreBundle) const
Return true if this instruction behaves the same way as the generic INSERT_SUBREG instructions...
bool isImplicitDef() const
VarInfo & getVarInfo(unsigned RegIdx)
getVarInfo - Return the VarInfo structure for the specified VIRTUAL register.
ARMCC::CondCodes getInstrPredicate(const MachineInstr &MI, unsigned &PredReg)
getInstrPredicate - If instruction is predicated, returns its predicate condition, otherwise returns AL.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
static const MachineInstr * getBundledDefMI(const TargetRegisterInfo *TRI, const MachineInstr *MI, unsigned Reg, unsigned &DefIdx, unsigned &Dist)
bool isDebugInstr() const
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
MO_LO16 - On a symbol operand, this represents a relocation containing lower 16 bit of the address...
This struct is a compact representation of a valid (non-zero power of two) alignment.
unsigned ConstantMaterializationCost(unsigned Val, const ARMSubtarget *Subtarget, bool ForCodesize=false)
Returns the number of instructions required to materialize the given constant in a register...
void setIsKill(bool Val=true)
void sort(IteratorTy Start, IteratorTy End)
The memory access writes data.
std::pair< uint16_t, uint16_t > getExecutionDomain(const MachineInstr &MI) const override
VFP/NEON execution domains.
const std::vector< MachineConstantPoolEntry > & getConstants() const
std::vector< MachineInstr * > Kills
Kills - List of MachineInstruction's which are the last use of this virtual register (kill it) in the...
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
ARMConstantPoolConstant - ARM-specific constant pool values for Constants, Functions, and BlockAddresses.
static bool isIndirectBranchOpcode(int Opc)
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr &Orig, const TargetRegisterInfo &TRI) const override
Iterator for intrusive lists based on ilist_node.
bool isT2SOImmTwoPartVal(unsigned Imm)
int getSOImmVal(unsigned Arg)
getSOImmVal - Given a 32-bit immediate, if it is something that can fit into an shifter_operand immed...
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
static bool isUncondBranchOpcode(int Opc)
virtual unsigned getUnindexedOpcode(unsigned Opc) const =0
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
unsigned getLDMVariableDefsSize(const MachineInstr &MI) const
BlockVerifier::State From
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
ARMConstantPoolSymbol - ARM-specific constantpool values for external symbols.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
static unsigned duplicateCPV(MachineFunction &MF, unsigned &CPI)
Create a copy of a const pool value.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool isInsertSubreg() const
A pair composed of a register and a sub-register index.
MachineInstrBuilder MachineInstrBuilder & DefMI
Map pseudo instructions that imply an 'S' bit onto real opcodes.
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
void breakPartialRegDependency(MachineInstr &, unsigned, const TargetRegisterInfo *TRI) const override
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
unsigned getSORegOpc(ShiftOpc ShOp, unsigned Imm)
uint64_t scale(uint64_t Num) const
Scale a large integer.
unsigned getAM2Offset(unsigned AM2Opc)
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Represents one node in the SelectionDAG.
static bool isPushOpcode(int Opc)
ARMConstantPoolMBB - ARM-specific constantpool value of a machine basic block.
unsigned pred_size() const
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 copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
bool canRealignStack(const MachineFunction &MF) const override
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
unsigned getNumLDMAddresses(const MachineInstr &MI) const
Get the number of addresses by LDM or VLDM or zero for unknown.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
void copyToCPSR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned SrcReg, bool KillSrc, const ARMSubtarget &Subtarget) const
static cl::opt< unsigned > Threshold("loop-unswitch-threshold", cl::desc("Max loop size to unswitch"), cl::init(100), cl::Hidden)
bool mayStore() const
Return true if this instruction could possibly modify memory.
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr *> &SeenMIs, bool) const override
int findRegisterUseOperandIdx(Register 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...
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
ShiftOpc getSORegShOp(unsigned Op)
ARMBaseInstrInfo(const ARMSubtarget &STI)
bool isEmpty() const
Returns true if there are no itineraries.
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.
bool IsCPSRDead< MachineInstr >(const MachineInstr *MI)
TargetSubtargetInfo - Generic base class for all target subtargets.
MachineInstr & duplicate(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore, const MachineInstr &Orig) const override
static bool isPopOpcode(int Opc)
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
static unsigned getNumMicroOpsSwiftLdSt(const InstrItineraryData *ItinData, const MachineInstr &MI)
bool isPredicable(const MachineInstr &MI) const override
isPredicable - Return true if the specified instruction can be predicated.
bool isRegSequenceLike(QueryType Type=IgnoreBundle) const
Return true if this instruction behaves the same way as the generic REG_SEQUENCE instructions.
static bool isARMLowRegister(unsigned Reg)
isARMLowRegister - Returns true if the register is a low register (r0-r7).
Representation of each machine instruction.
bool HasLowerConstantMaterializationCost(unsigned Val1, unsigned Val2, const ARMSubtarget *Subtarget, bool ForCodesize=false)
Returns true if Val1 has a lower Constant Materialization Cost than Val2.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static CondCodes getOppositeCondition(CondCodes CC)
static const AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[]
bool isMoveReg(QueryType Type=IgnoreBundle) const
Return true if this instruction is a register move.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
addVirtualRegisterDead - Add information about the fact that the specified register is dead after bei...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
virtual ScheduleHazardRecognizer * CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
static MachineOperand condCodeOp(unsigned CCReg=0)
Get the operand corresponding to the conditional code result.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
bool isLDMBaseRegInList(const MachineInstr &MI) const
const MachineInstrBuilder & setMIFlags(unsigned Flags) const
bool getExtractSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx, RegSubRegPairAndIdx &InputReg) const override
Build the equivalent inputs of a EXTRACT_SUBREG for the given MI and DefIdx.
MO_COFFSTUB - On a symbol operand "FOO", this indicates that the reference is actually to the "...
void addPredicatedMveVpredROp(MachineInstrBuilder &MIB, unsigned Cond, unsigned Inactive)
LLVM_NODISCARD bool empty() 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...
MO_DLLIMPORT - On a symbol operand, this represents that the reference to the symbol is for an import...
Register liveness not decidable from local neighborhood.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
int64_t getOffset() const
Return the offset from the symbol in this operand.
int getOperandLatency(const InstrItineraryData *ItinData, const MachineInstr &DefMI, unsigned DefIdx, const MachineInstr &UseMI, unsigned UseIdx) const override
bool hasPipelineForwarding(unsigned DefClass, unsigned DefIdx, unsigned UseClass, unsigned UseIdx) const
Return true if there is a pipeline forwarding between instructions of itinerary classes DefClass and ...
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
void ChangeToRegister(Register 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...
bool getRegSequenceLikeInputs(const MachineInstr &MI, unsigned DefIdx, SmallVectorImpl< RegSubRegPairAndIdx > &InputRegs) const override
Build the equivalent inputs of a REG_SEQUENCE for the given MI and DefIdx.
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
The memory access always returns the same value (or traps).
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool isCall() const
Return true if the instruction is a call.
MO_OPTION_MASK - Most flags are mutually exclusive; this mask selects just that part of the flag set...
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int CmpMask, int CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction to set the zero flag so that we can remove a "comparis...
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
bool isSwiftFastImmShift(const MachineInstr *MI) const
Returns true if the instruction has a shift by immediate that can be executed in one cycle less...
unsigned isStoreToStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
bool isAddrMode3OpMinusReg(const MachineInstr &MI, unsigned Op) const
MachineInstr * removeFromParent()
Unlink 'this' from the containing basic block, and return it without deleting it. ...
bool hasOptionalDef(QueryType Type=IgnoreBundle) const
Set if this instruction has an optional definition, e.g.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void copyFromCPSR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, bool KillSrc, const ARMSubtarget &Subtarget) const
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
ARMHazardRecognizer handles special constraints that are not expressed in the scheduling itinerary...
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool shouldSink(const MachineInstr &MI) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isIdenticalTo(const MachineInstr &Other, MICheckType Check=CheckDefs) const
Return true if this instruction is identical to Other.
unsigned getT2SOImmTwoPartSecond(unsigned Imm)
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
static MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
virtual const ARMBaseRegisterInfo & getRegisterInfo() const =0
void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
Can load/store 1 register/cycle, but needs an extra cycle for address computation and potentially als...
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
static use_instr_iterator use_instr_end()
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
int getOperandCycle(unsigned ItinClassIndx, unsigned OperandIdx) const
Return the cycle for the given class and operand.
MO_NONLAZY - This is an independent flag, on a symbol operand "FOO" it represents a symbol which...
unsigned getOpcode() const
Return the opcode number for this descriptor.
Can load/store 2 registers/cycle.
static int adjustDefLatency(const ARMSubtarget &Subtarget, const MachineInstr &DefMI, const MCInstrDesc &DefMCID, unsigned DefAlign)
Return the number of cycles to add to (or subtract from) the static itinerary based on the def opcode...
bool isLdstScaledReg(const MachineInstr &MI, unsigned Op) const
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
StringRef - Represent a constant reference to a string, i.e.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
AddrOpc getAM5Op(unsigned AM5Opc)
Register getReg() const
getReg - Returns the register number.
Optional< RegImmPair > isAddImmediate(const MachineInstr &MI, Register Reg) const override
static bool getImplicitSPRUseForDPRUse(const TargetRegisterInfo *TRI, MachineInstr &MI, unsigned DReg, unsigned Lane, unsigned &ImplicitSReg)
getImplicitSPRUseForDPRUse - Given a use of a DPR register and lane, set ImplicitSReg to a register n...
static X86::CondCode getSwappedCondition(X86::CondCode CC)
Assuming the flags are set by MI(a,b), return the condition code if we modify the instructions such t...
static unsigned getNumMicroOpsSingleIssuePlusExtras(unsigned Opc, unsigned NumRegs)
bool produceSameValue(const MachineInstr &MI0, const MachineInstr &MI1, const MachineRegisterInfo *MRI) const override
bool hasImplicitDefOfPhysReg(unsigned Reg, const MCRegisterInfo *MRI=nullptr) const
Return true if this instruction implicitly defines the specified physical register.
const MachineOperand & getOperand(unsigned i) const
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MFI, MachineInstr &MI, LiveVariables *LV) const override
bool isThumbFunction() const
unsigned getSOImmTwoPartFirst(unsigned V)
getSOImmTwoPartFirst - If V is a value that satisfies isSOImmTwoPartVal, return the first chunk of it...
virtual ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *, const ScheduleDAG *DAG) const
Allocate and return a hazard recognizer to use for this target when scheduling the machine instructio...
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static ARMConstantPoolConstant * Create(const Constant *C, unsigned ID)
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr &MI, bool AddIfNotFound=false)
addVirtualRegisterKilled - Add information about the fact that the specified register is killed after...
std::vector< MachineBasicBlock * >::iterator succ_iterator
MO_HI16 - On a symbol operand, this represents a relocation containing higher 16 bit of the address...
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
static cl::opt< bool > EnableARM3Addr("enable-arm-3-addr-conv", cl::Hidden, cl::desc("Enable ARM 2-addr to 3-addr conv"))
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
mmo_iterator memoperands_end() const
Access to memory operands of the instruction.
A pair composed of a pair of a register and a sub-register index, and another sub-register index...
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.