69 #define DEBUG_TYPE "arm-instrinfo" 71 #define GET_INSTRINFO_CTOR_DTOR 72 #include "ARMGenInstrInfo.inc" 76 cl::desc(
"Enable ARM 2-addr to 3-addr conv"));
90 { ARM::VMLAS, ARM::VMULS, ARM::VADDS,
false,
false },
91 { ARM::VMLSS, ARM::VMULS, ARM::VSUBS,
false,
false },
92 { ARM::VMLAD, ARM::VMULD, ARM::VADDD,
false,
false },
93 { ARM::VMLSD, ARM::VMULD, ARM::VSUBD,
false,
false },
94 { ARM::VNMLAS, ARM::VNMULS, ARM::VSUBS,
true,
false },
95 { ARM::VNMLSS, ARM::VMULS, ARM::VSUBS,
true,
false },
96 { ARM::VNMLAD, ARM::VNMULD, ARM::VSUBD,
true,
false },
97 { ARM::VNMLSD, ARM::VMULD, ARM::VSUBD,
true,
false },
100 { ARM::VMLAfd, ARM::VMULfd, ARM::VADDfd,
false,
false },
101 { ARM::VMLSfd, ARM::VMULfd, ARM::VSUBfd,
false,
false },
102 { ARM::VMLAfq, ARM::VMULfq, ARM::VADDfq,
false,
false },
103 { ARM::VMLSfq, ARM::VMULfq, ARM::VSUBfq,
false,
false },
104 { ARM::VMLAslfd, ARM::VMULslfd, ARM::VADDfd,
false,
true },
105 { ARM::VMLSslfd, ARM::VMULslfd, ARM::VSUBfd,
false,
true },
106 { ARM::VMLAslfq, ARM::VMULslfq, ARM::VADDfq,
false,
true },
107 { ARM::VMLSslfq, ARM::VMULslfq, ARM::VSUBfq,
false,
true },
113 for (
unsigned i = 0, e =
array_lengthof(ARM_MLxTable); i != e; ++i) {
114 if (!MLxEntryMap.
insert(std::make_pair(ARM_MLxTable[i].
MLxOpc, i)).second)
116 MLxHazardOpcodes.
insert(ARM_MLxTable[i].AddSubOpc);
117 MLxHazardOpcodes.
insert(ARM_MLxTable[i].MulOpc);
126 if (usePreRAHazardRecognizer()) {
128 static_cast<const ARMSubtarget *
>(STI)->getInstrItineraryData();
153 default:
return nullptr;
176 unsigned WBReg = WB.
getReg();
177 unsigned BaseReg = Base.
getReg();
178 unsigned OffReg = Offset.
getReg();
192 get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
197 }
else if (Amt != 0) {
201 get(isSub ? ARM::SUBrsi : ARM::ADDrsi), WBReg)
210 get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
223 get(isSub ? ARM::SUBri : ARM::ADDri), WBReg)
230 get(isSub ? ARM::SUBrr : ARM::ADDrr), WBReg)
239 std::vector<MachineInstr*> NewMIs;
254 NewMIs.push_back(MemMI);
255 NewMIs.push_back(UpdateMI);
272 NewMIs.push_back(UpdateMI);
273 NewMIs.push_back(MemMI);
285 MachineInstr *NewMI = (Reg == WBReg) ? UpdateMI : MemMI;
290 for (
unsigned j = 0; j < 2; ++j) {
297 VI.
Kills.push_back(NewMI);
306 MFI->insert(MBBI, NewMIs[1]);
307 MFI->insert(MBBI, NewMIs[0]);
316 bool AllowModify)
const {
321 if (I == MBB.
begin())
327 while (
isPredicated(*I) || I->isTerminator() || I->isDebugValue()) {
331 bool CantAnalyze =
false;
334 while (I->isDebugInstr() || !I->isTerminator()) {
335 if (I == MBB.
begin())
346 TBB = I->getOperand(0).getMBB();
352 assert(!FBB &&
"FBB should have been null.");
354 TBB = I->getOperand(0).getMBB();
357 }
else if (I->isReturn()) {
380 while (DI != MBB.
end()) {
391 if (I == MBB.
begin())
403 int *BytesRemoved)
const {
404 assert(!BytesRemoved &&
"code size not handled");
415 I->eraseFromParent();
419 if (I == MBB.
begin())
return 1;
425 I->eraseFromParent();
434 int *BytesAdded)
const {
435 assert(!BytesAdded &&
"code size not handled");
444 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
446 "ARM branch conditions have two components!");
487 while (++I != E && I->isInsideBundle()) {
488 int PIdx = I->findFirstPredOperandIdx();
489 if (PIdx != -1 && I->getOperand(PIdx).getImm() !=
ARMCC::AL)
505 .addImm(Pred[0].getImm())
506 .addReg(Pred[1].
getReg());
513 PMO.
setImm(Pred[0].getImm());
522 if (Pred1.
size() > 2 || Pred2.
size() > 2)
562 for (
const auto &MO : MI.
operands())
563 if (MO.isReg() && MO.getReg() == ARM::CPSR && MO.isDef() && !MO.isDead())
571 return Offset.
getReg() != 0;
582 int64_t OpcImm = Opc.
getImm();
585 return (isSub && Offset.
getReg() != 0);
591 unsigned OffImm = Opc.
getImm();
599 unsigned OffImm = Opc.
getImm();
605 bool SimpleScaled = (isAdd && ShiftOpc ==
ARM_AM::lsl && Amt == 2);
606 return !SimpleScaled;
625 default:
return true;
684 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
688 if (MO.
getReg() != ARM::CPSR)
718 case TargetOpcode::BUNDLE:
719 return getInstBundleLength(MI);
720 case ARM::MOVi16_ga_pcrel:
721 case ARM::MOVTi16_ga_pcrel:
722 case ARM::t2MOVi16_ga_pcrel:
723 case ARM::t2MOVTi16_ga_pcrel:
726 case ARM::t2MOVi32imm:
728 case ARM::CONSTPOOL_ENTRY:
729 case ARM::JUMPTABLE_INSTS:
730 case ARM::JUMPTABLE_ADDRS:
731 case ARM::JUMPTABLE_TBB:
732 case ARM::JUMPTABLE_TBH:
736 case ARM::Int_eh_sjlj_longjmp:
738 case ARM::tInt_eh_sjlj_longjmp:
740 case ARM::tInt_WIN_eh_sjlj_longjmp:
742 case ARM::Int_eh_sjlj_setjmp:
743 case ARM::Int_eh_sjlj_setjmp_nofp:
745 case ARM::tInt_eh_sjlj_setjmp:
746 case ARM::t2Int_eh_sjlj_setjmp:
747 case ARM::t2Int_eh_sjlj_setjmp_nofp:
754 unsigned ARMBaseInstrInfo::getInstBundleLength(
const MachineInstr &
MI)
const {
758 while (++I != E && I->isInsideBundle()) {
759 assert(!I->isBundle() &&
"No nested bundle!");
767 unsigned DestReg,
bool KillSrc,
769 unsigned Opc = Subtarget.
isThumb()
770 ? (Subtarget.
isMClass() ? ARM::t2MRS_M : ARM::t2MRS_AR)
774 BuildMI(MBB, I, I->getDebugLoc(),
get(Opc), DestReg);
787 unsigned SrcReg,
bool KillSrc,
789 unsigned Opc = Subtarget.
isThumb()
790 ? (Subtarget.
isMClass() ? ARM::t2MSR_M : ARM::t2MSR_AR)
807 const DebugLoc &DL,
unsigned DestReg,
808 unsigned SrcReg,
bool KillSrc)
const {
809 bool GPRDest = ARM::GPRRegClass.contains(DestReg);
810 bool GPRSrc = ARM::GPRRegClass.contains(SrcReg);
812 if (GPRDest && GPRSrc) {
813 BuildMI(MBB, I, DL,
get(ARM::MOVr), DestReg)
820 bool SPRDest = ARM::SPRRegClass.contains(DestReg);
821 bool SPRSrc = ARM::SPRRegClass.contains(SrcReg);
824 if (SPRDest && SPRSrc)
826 else if (GPRDest && SPRSrc)
828 else if (SPRDest && GPRSrc)
830 else if (ARM::DPRRegClass.
contains(DestReg, SrcReg) && !Subtarget.isFPOnlySP())
832 else if (ARM::QPRRegClass.
contains(DestReg, SrcReg))
838 if (Opc == ARM::VORRq)
845 unsigned BeginIdx = 0;
846 unsigned SubRegs = 0;
850 if (ARM::QQPRRegClass.
contains(DestReg, SrcReg)) {
852 BeginIdx = ARM::qsub_0;
854 }
else if (ARM::QQQQPRRegClass.
contains(DestReg, SrcReg)) {
856 BeginIdx = ARM::qsub_0;
859 }
else if (ARM::DPairRegClass.
contains(DestReg, SrcReg)) {
861 BeginIdx = ARM::dsub_0;
863 }
else if (ARM::DTripleRegClass.
contains(DestReg, SrcReg)) {
865 BeginIdx = ARM::dsub_0;
867 }
else if (ARM::DQuadRegClass.
contains(DestReg, SrcReg)) {
869 BeginIdx = ARM::dsub_0;
871 }
else if (ARM::GPRPairRegClass.
contains(DestReg, SrcReg)) {
872 Opc = Subtarget.isThumb2() ? ARM::tMOVr : ARM::MOVr;
873 BeginIdx = ARM::gsub_0;
875 }
else if (ARM::DPairSpcRegClass.
contains(DestReg, SrcReg)) {
877 BeginIdx = ARM::dsub_0;
880 }
else if (ARM::DTripleSpcRegClass.
contains(DestReg, SrcReg)) {
882 BeginIdx = ARM::dsub_0;
885 }
else if (ARM::DQuadSpcRegClass.
contains(DestReg, SrcReg)) {
887 BeginIdx = ARM::dsub_0;
890 }
else if (ARM::DPRRegClass.
contains(DestReg, SrcReg) && Subtarget.isFPOnlySP()) {
892 BeginIdx = ARM::ssub_0;
894 }
else if (SrcReg == ARM::CPSR) {
897 }
else if (DestReg == ARM::CPSR) {
898 copyToCPSR(MBB, I, SrcReg, KillSrc, Subtarget);
902 assert(Opc &&
"Impossible reg-to-reg copy");
909 BeginIdx = BeginIdx + ((SubRegs - 1) * Spacing);
915 for (
unsigned i = 0; i != SubRegs; ++i) {
916 unsigned Dst = TRI->
getSubReg(DestReg, BeginIdx + i * Spacing);
917 unsigned Src = TRI->
getSubReg(SrcReg, BeginIdx + i * Spacing);
918 assert(Dst && Src &&
"Bad sub-register");
920 assert(!DstRegs.
count(Src) &&
"destructive vector copy");
923 Mov =
BuildMI(MBB, I, I->getDebugLoc(),
get(Opc), Dst).
addReg(Src);
925 if (Opc == ARM::VORRq)
929 if (Opc == ARM::MOVr)
959 unsigned SubIdx,
unsigned State,
962 return MIB.
addReg(Reg, State);
966 return MIB.
addReg(Reg, State, SubIdx);
971 unsigned SrcReg,
bool isKill,
int FI,
975 if (I != MBB.
end()) DL = I->getDebugLoc();
986 if (ARM::HPRRegClass.hasSubClassEq(RC)) {
987 BuildMI(MBB, I, DL,
get(ARM::VSTRH))
997 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
998 BuildMI(MBB, I, DL,
get(ARM::STRi12))
1004 }
else if (ARM::SPRRegClass.hasSubClassEq(RC)) {
1005 BuildMI(MBB, I, DL,
get(ARM::VSTRS))
1015 if (ARM::DPRRegClass.hasSubClassEq(RC)) {
1016 BuildMI(MBB, I, DL,
get(ARM::VSTRD))
1022 }
else if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
1023 if (Subtarget.hasV5TEOps()) {
1026 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
1037 AddDReg(MIB, SrcReg, ARM::gsub_1, 0, TRI);
1043 if (ARM::DPairRegClass.hasSubClassEq(RC)) {
1046 BuildMI(MBB, I, DL,
get(ARM::VST1q64))
1053 BuildMI(MBB, I, DL,
get(ARM::VSTMQIA))
1063 if (ARM::DTripleRegClass.hasSubClassEq(RC)) {
1066 BuildMI(MBB, I, DL,
get(ARM::VST1d64TPseudo))
1078 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1079 AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1085 if (ARM::QQPRRegClass.hasSubClassEq(RC) || ARM::DQuadRegClass.hasSubClassEq(RC)) {
1089 BuildMI(MBB, I, DL,
get(ARM::VST1d64QPseudo))
1101 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1102 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1103 AddDReg(MIB, SrcReg, ARM::dsub_3, 0, TRI);
1109 if (ARM::QQQQPRRegClass.hasSubClassEq(RC)) {
1115 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_1, 0, TRI);
1116 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_2, 0, TRI);
1117 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_3, 0, TRI);
1118 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_4, 0, TRI);
1119 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_5, 0, TRI);
1120 MIB =
AddDReg(MIB, SrcReg, ARM::dsub_6, 0, TRI);
1121 AddDReg(MIB, SrcReg, ARM::dsub_7, 0, TRI);
1155 case ARM::VST1d64TPseudo:
1156 case ARM::VST1d64QPseudo:
1176 return MI.
mayStore() && hasStoreToStackSlot(MI, Dummy, FrameIndex);
1181 unsigned DestReg,
int FI,
1185 if (I != MBB.
end()) DL = I->getDebugLoc();
1195 if (ARM::HPRRegClass.hasSubClassEq(RC)) {
1196 BuildMI(MBB, I, DL,
get(ARM::VLDRH), DestReg)
1205 if (ARM::GPRRegClass.hasSubClassEq(RC)) {
1206 BuildMI(MBB, I, DL,
get(ARM::LDRi12), DestReg)
1211 }
else if (ARM::SPRRegClass.hasSubClassEq(RC)) {
1212 BuildMI(MBB, I, DL,
get(ARM::VLDRS), DestReg)
1221 if (ARM::DPRRegClass.hasSubClassEq(RC)) {
1222 BuildMI(MBB, I, DL,
get(ARM::VLDRD), DestReg)
1227 }
else if (ARM::GPRPairRegClass.hasSubClassEq(RC)) {
1230 if (Subtarget.hasV5TEOps()) {
1231 MIB =
BuildMI(MBB, I, DL,
get(ARM::LDRD));
1239 MIB =
BuildMI(MBB, I, DL,
get(ARM::LDMIA))
1253 if (ARM::DPairRegClass.hasSubClassEq(RC)) {
1255 BuildMI(MBB, I, DL,
get(ARM::VLD1q64), DestReg)
1261 BuildMI(MBB, I, DL,
get(ARM::VLDMQIA), DestReg)
1270 if (ARM::DTripleRegClass.hasSubClassEq(RC)) {
1272 BuildMI(MBB, I, DL,
get(ARM::VLD1d64TPseudo), DestReg)
1292 if (ARM::QQPRRegClass.hasSubClassEq(RC) || ARM::DQuadRegClass.hasSubClassEq(RC)) {
1294 BuildMI(MBB, I, DL,
get(ARM::VLD1d64QPseudo), DestReg)
1315 if (ARM::QQQQPRRegClass.hasSubClassEq(RC)) {
1363 case ARM::VLD1d8TPseudo:
1364 case ARM::VLD1d16TPseudo:
1365 case ARM::VLD1d32TPseudo:
1366 case ARM::VLD1d64TPseudo:
1367 case ARM::VLD1d8QPseudo:
1368 case ARM::VLD1d16QPseudo:
1369 case ARM::VLD1d32QPseudo:
1370 case ARM::VLD1d64QPseudo:
1390 return MI.
mayLoad() && hasLoadFromStackSlot(MI, Dummy, FrameIndex);
1396 bool isThumb1 = Subtarget.isThumb1Only();
1397 bool isThumb2 = Subtarget.isThumb2();
1404 if (isThumb1 || !MI->getOperand(1).isDead()) {
1406 LDM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2LDMIA_UPD
1407 : isThumb1 ? ARM::tLDMIA_UPD
1411 LDM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2LDMIA : ARM::LDMIA));
1414 if (isThumb1 || !MI->getOperand(0).isDead()) {
1416 STM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2STMIA_UPD
1417 : isThumb1 ? ARM::tSTMIA_UPD
1421 STM =
BuildMI(*BB, MI, dl, TII->get(isThumb2 ? ARM::t2STMIA : ARM::STMIA));
1433 for(
unsigned I = 5;
I < MI->getNumOperands(); ++
I)
1434 ScratchRegs.
push_back(MI->getOperand(
I).getReg());
1436 [&
TRI](
const unsigned &Reg1,
1437 const unsigned &Reg2) ->
bool {
1442 for (
const auto &
Reg : ScratchRegs) {
1451 if (MI.
getOpcode() == TargetOpcode::LOAD_STACK_GUARD) {
1453 "LOAD_STACK_GUARD currently supported only for MachO.");
1454 expandLoadStackGuard(MI);
1468 if (!MI.
isCopy() || Subtarget.dontWidenVMOVS() || Subtarget.isFPOnlySP())
1475 if (!ARM::SPRRegClass.
contains(DstRegS, SrcRegS))
1483 if (!DstRegD || !SrcRegD)
1503 if (ImpDefIdx != -1)
1537 assert(MCPE.isMachineConstantPoolEntry() &&
1538 "Expecting a machine constantpool entry!");
1550 if (ACPV->isGlobalValue())
1552 cast<ARMConstantPoolConstant>(ACPV)->getGV(), PCLabelId,
ARMCP::CPValue,
1553 4, ACPV->getModifier(), ACPV->mustAddCurrentAddress());
1554 else if (ACPV->isExtSymbol())
1557 cast<ARMConstantPoolSymbol>(ACPV)->
getSymbol(), PCLabelId, 4);
1558 else if (ACPV->isBlockAddress())
1560 Create(cast<ARMConstantPoolConstant>(ACPV)->getBlockAddress(), PCLabelId,
1562 else if (ACPV->isLSDA())
1565 else if (ACPV->isMachineBasicBlock())
1568 cast<ARMConstantPoolMBB>(ACPV)->getMBB(), PCLabelId, 4);
1577 unsigned DestReg,
unsigned SubIdx,
1588 case ARM::tLDRpci_pic:
1589 case ARM::t2LDRpci_pic: {
1610 switch (I->getOpcode()) {
1611 case ARM::tLDRpci_pic:
1612 case ARM::t2LDRpci_pic: {
1614 unsigned CPI = I->getOperand(1).getIndex();
1616 I->getOperand(1).setIndex(CPI);
1617 I->getOperand(2).setImm(PCLabelId);
1621 if (!I->isBundledWithSucc())
1632 if (Opcode == ARM::t2LDRpci ||
1633 Opcode == ARM::t2LDRpci_pic ||
1634 Opcode == ARM::tLDRpci ||
1635 Opcode == ARM::tLDRpci_pic ||
1636 Opcode == ARM::LDRLIT_ga_pcrel ||
1637 Opcode == ARM::LDRLIT_ga_pcrel_ldr ||
1638 Opcode == ARM::tLDRLIT_ga_pcrel ||
1639 Opcode == ARM::MOV_ga_pcrel ||
1640 Opcode == ARM::MOV_ga_pcrel_ldr ||
1641 Opcode == ARM::t2MOV_ga_pcrel) {
1652 if (Opcode == ARM::LDRLIT_ga_pcrel ||
1653 Opcode == ARM::LDRLIT_ga_pcrel_ldr ||
1654 Opcode == ARM::tLDRLIT_ga_pcrel ||
1655 Opcode == ARM::MOV_ga_pcrel ||
1656 Opcode == ARM::MOV_ga_pcrel_ldr ||
1657 Opcode == ARM::t2MOV_ga_pcrel)
1669 if (isARMCP0 && isARMCP1) {
1675 }
else if (!isARMCP0 && !isARMCP1) {
1679 }
else if (Opcode == ARM::PICLDR) {
1687 if (Addr0 != Addr1) {
1725 int64_t &Offset2)
const {
1727 if (Subtarget.isThumb1Only())
return false;
1746 case ARM::t2LDRSHi8:
1748 case ARM::t2LDRBi12:
1749 case ARM::t2LDRSHi12:
1766 case ARM::t2LDRSHi8:
1768 case ARM::t2LDRBi12:
1769 case ARM::t2LDRSHi12:
1783 if (isa<ConstantSDNode>(Load1->
getOperand(1)) &&
1785 Offset1 = cast<ConstantSDNode>(Load1->
getOperand(1))->getSExtValue();
1786 Offset2 = cast<ConstantSDNode>(Load2->
getOperand(1))->getSExtValue();
1805 int64_t Offset1, int64_t Offset2,
1806 unsigned NumLoads)
const {
1808 if (Subtarget.isThumb1Only())
return false;
1810 assert(Offset2 > Offset1);
1812 if ((Offset2 - Offset1) / 8 > 64)
1858 while (++I != MBB->
end() && I->isDebugInstr())
1860 if (I != MBB->
end() && I->getOpcode() == ARM::t2IT)
1879 unsigned NumCycles,
unsigned ExtraPredCycles,
1889 if (!Pred->
empty()) {
1891 if (LastMI->
getOpcode() == ARM::t2Bcc) {
1893 if (CmpMI != Pred->
begin()) {
1895 if (CmpMI->getOpcode() == ARM::tCMPi8 ||
1896 CmpMI->getOpcode() == ARM::t2CMPri) {
1897 unsigned Reg = CmpMI->getOperand(0).getReg();
1898 unsigned PredReg = 0;
1900 if (P ==
ARMCC::AL && CmpMI->getOperand(1).getImm() == 0 &&
1909 MBB, 0, 0, Probability);
1914 unsigned TCycles,
unsigned TExtra,
1916 unsigned FCycles,
unsigned FExtra,
1924 const unsigned ScalingUpFactor = 1024;
1926 unsigned PredCost = (TCycles + FCycles + TExtra + FExtra) * ScalingUpFactor;
1927 unsigned UnpredCost;
1928 if (!Subtarget.hasBranchPredictor()) {
1931 unsigned NotTakenBranchCost = 1;
1932 unsigned TakenBranchCost = Subtarget.getMispredictionPenalty();
1933 unsigned TUnpredCycles, FUnpredCycles;
1936 TUnpredCycles = TCycles + NotTakenBranchCost;
1937 FUnpredCycles = TakenBranchCost;
1940 TUnpredCycles = TCycles + TakenBranchCost;
1941 FUnpredCycles = FCycles + NotTakenBranchCost;
1944 PredCost -= 1 * ScalingUpFactor;
1947 unsigned TUnpredCost = Probability.
scale(TUnpredCycles * ScalingUpFactor);
1948 unsigned FUnpredCost = Probability.
getCompl().
scale(FUnpredCycles * ScalingUpFactor);
1949 UnpredCost = TUnpredCost + FUnpredCost;
1952 if (Subtarget.isThumb2() && TCycles + FCycles > 4) {
1953 PredCost += ((TCycles + FCycles - 4) / 4) * ScalingUpFactor;
1956 unsigned TUnpredCost = Probability.
scale(TCycles * ScalingUpFactor);
1957 unsigned FUnpredCost =
1959 UnpredCost = TUnpredCost + FUnpredCost;
1960 UnpredCost += 1 * ScalingUpFactor;
1961 UnpredCost += Subtarget.getMispredictionPenalty() * ScalingUpFactor / 10;
1964 return PredCost <= UnpredCost;
1972 return Subtarget.isProfitableToUnpredicate();
1979 unsigned &PredReg) {
1995 if (Opc == ARM::t2B)
2004 unsigned OpIdx2)
const {
2007 case ARM::t2MOVCCr: {
2009 unsigned PredReg = 0;
2012 if (CC ==
ARMCC::AL || PredReg != ARM::CPSR)
2059 bool DontMoveAcrossStores =
true;
2067 unsigned &TrueOp,
unsigned &FalseOp,
2068 bool &Optimizable)
const {
2070 "Unknown select instruction");
2089 bool PreferFalse)
const {
2091 "Unknown select instruction");
2094 bool Invert = !
DefMI;
2114 for (
unsigned i = 1, e = DefDesc.getNumOperands();
2115 i != e && !DefDesc.OpInfo[i].isPredicate(); ++i)
2134 NewMI.
add(FalseReg);
2139 SeenMIs.
erase(DefMI);
2165 {ARM::ADDSri, ARM::ADDri},
2166 {ARM::ADDSrr, ARM::ADDrr},
2167 {ARM::ADDSrsi, ARM::ADDrsi},
2168 {ARM::ADDSrsr, ARM::ADDrsr},
2170 {ARM::SUBSri, ARM::SUBri},
2171 {ARM::SUBSrr, ARM::SUBrr},
2172 {ARM::SUBSrsi, ARM::SUBrsi},
2173 {ARM::SUBSrsr, ARM::SUBrsr},
2175 {ARM::RSBSri, ARM::RSBri},
2176 {ARM::RSBSrsi, ARM::RSBrsi},
2177 {ARM::RSBSrsr, ARM::RSBrsr},
2179 {ARM::tADDSi3, ARM::tADDi3},
2180 {ARM::tADDSi8, ARM::tADDi8},
2181 {ARM::tADDSrr, ARM::tADDrr},
2182 {ARM::tADCS, ARM::tADC},
2184 {ARM::tSUBSi3, ARM::tSUBi3},
2185 {ARM::tSUBSi8, ARM::tSUBi8},
2186 {ARM::tSUBSrr, ARM::tSUBrr},
2187 {ARM::tSBCS, ARM::tSBC},
2189 {ARM::t2ADDSri, ARM::t2ADDri},
2190 {ARM::t2ADDSrr, ARM::t2ADDrr},
2191 {ARM::t2ADDSrs, ARM::t2ADDrs},
2193 {ARM::t2SUBSri, ARM::t2SUBri},
2194 {ARM::t2SUBSrr, ARM::t2SUBrr},
2195 {ARM::t2SUBSrs, ARM::t2SUBrs},
2197 {ARM::t2RSBSri, ARM::t2RSBri},
2198 {ARM::t2RSBSrs, ARM::t2RSBrs},
2202 for (
unsigned i = 0, e =
array_lengthof(AddSubFlagsOpcodeMap); i != e; ++i)
2203 if (OldOpc == AddSubFlagsOpcodeMap[i].PseudoOpc)
2210 const DebugLoc &dl,
unsigned DestReg,
2211 unsigned BaseReg,
int NumBytes,
2215 if (NumBytes == 0 && DestReg != BaseReg) {
2216 BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), DestReg)
2224 bool isSub = NumBytes < 0;
2225 if (isSub) NumBytes = -NumBytes;
2230 assert(ThisVal &&
"Didn't extract field correctly");
2233 NumBytes &= ~ThisVal;
2238 unsigned Opc = isSub ? ARM::SUBri : ARM::ADDri;
2239 BuildMI(MBB, MBBI, dl, TII.get(Opc), DestReg)
2251 unsigned NumBytes) {
2262 if (!IsPush && !IsPop)
2265 bool IsVFPPushPop = MI->
getOpcode() == ARM::VSTMDDB_UPD ||
2267 bool IsT1PushPop = MI->
getOpcode() == ARM::tPUSH ||
2273 "trying to fold sp update into non-sp-updating push/pop");
2278 if (NumBytes % (IsVFPPushPop ? 8 : 4) != 0)
2283 int RegListIdx = IsT1PushPop ? 2 : 4;
2286 unsigned RegsNeeded;
2289 RegsNeeded = NumBytes / 8;
2290 RegClass = &ARM::DPRRegClass;
2292 RegsNeeded = NumBytes / 4;
2293 RegClass = &ARM::GPRRegClass;
2303 unsigned FirstRegEnc = -1;
2317 for (
int CurRegEnc = FirstRegEnc - 1; CurRegEnc >= 0 && RegsNeeded;
2319 unsigned CurReg = RegClass->
getRegister(CurRegEnc);
2325 false,
false,
true));
2362 for (
int i = RegList.
size() - 1; i >= 0; --i)
2363 MIB.
add(RegList[i]);
2369 unsigned FrameReg,
int &
Offset,
2380 if (Opcode == ARM::ADDri) {
2384 MI.
setDesc(TII.get(ARM::MOVr));
2389 }
else if (Offset < 0) {
2392 MI.
setDesc(TII.get(ARM::SUBri));
2410 Offset &= ~ThisImmVal;
2414 "Bit extraction didn't work?");
2417 unsigned ImmIdx = 0;
2419 unsigned NumBits = 0;
2423 ImmIdx = FrameRegIdx + 1;
2428 ImmIdx = FrameRegIdx+2;
2435 ImmIdx = FrameRegIdx+2;
2446 ImmIdx = FrameRegIdx+1;
2454 ImmIdx = FrameRegIdx+1;
2465 Offset += InstrOffs * Scale;
2466 assert((Offset & (Scale-1)) == 0 &&
"Can't encode this offset!");
2476 int ImmedOffset = Offset / Scale;
2477 unsigned Mask = (1 << NumBits) - 1;
2478 if ((
unsigned)Offset <= Mask * Scale) {
2486 ImmedOffset = -ImmedOffset;
2488 ImmedOffset |= 1 << NumBits;
2496 ImmedOffset = ImmedOffset &
Mask;
2499 ImmedOffset = -ImmedOffset;
2501 ImmedOffset |= 1 << NumBits;
2504 Offset &= ~(Mask*Scale);
2508 Offset = (isSub) ? -Offset : Offset;
2517 unsigned &SrcReg2,
int &CmpMask,
2518 int &CmpValue)
const {
2553 int CmpMask,
bool CommonUse) {
2606 unsigned SrcReg,
unsigned SrcReg2,
2638 default:
return false;
2701 MachineInstr &CmpInstr,
unsigned SrcReg,
unsigned SrcReg2,
int CmpMask,
2705 if (!MI)
return false;
2708 if (CmpMask != ~0) {
2714 if (UI->getParent() != CmpInstr.
getParent())
2723 if (!MI)
return false;
2732 if (I == B)
return false;
2748 if (CmpInstr.
getOpcode() == ARM::CMPri ||
2755 bool IsThumb1 =
false;
2771 if (MI && IsThumb1) {
2773 bool CanReorder =
true;
2774 const bool HasStmts = I !=
E;
2775 for (; I !=
E; --
I) {
2776 if (I->getOpcode() != ARM::tMOVi8) {
2781 if (HasStmts && CanReorder) {
2819 if (!MI) MI = SubAdd;
2833 bool isSafe =
false;
2836 while (!isSafe && ++I != E) {
2839 !isSafe && IO != EO; ++IO) {
2853 bool IsInstrVSel =
true;
2856 IsInstrVSel =
false;
2886 bool IsSub = Opc == ARM::SUBrr || Opc == ARM::t2SUBrr ||
2887 Opc == ARM::SUBri || Opc == ARM::t2SUBri;
2888 if (!IsSub || (SrcReg2 != 0 && SubAdd->
getOperand(1).
getReg() == SrcReg2 &&
2898 std::make_pair(&((*I).getOperand(IO - 1)), NewCC));
2933 if ((*SI)->isLiveIn(ARM::CPSR))
2949 for (
unsigned i = 0, e = OperandsToUpdate.
size(); i < e; i++)
2950 OperandsToUpdate[i].
first->setImm(OperandsToUpdate[i].second);
2963 unsigned SrcReg, SrcReg2;
2964 int CmpMask, CmpValue;
2977 if (DefOpc != ARM::t2MOVi32imm && DefOpc != ARM::MOVi32imm)
3006 unsigned NewUseOpc = 0;
3008 uint32_t SOImmValV1 = 0, SOImmValV2 = 0;
3009 bool Commute =
false;
3011 default:
return false;
3019 case ARM::t2EORrr: {
3025 if (UseOpc == ARM::SUBrr && Commute)
3031 NewUseOpc = UseOpc == ARM::ADDrr ? ARM::ADDri : ARM::SUBri;
3034 NewUseOpc = UseOpc == ARM::ADDrr ? ARM::SUBri : ARM::ADDri;
3048 case ARM::ORRrr: NewUseOpc = ARM::ORRri;
break;
3049 case ARM::EORrr: NewUseOpc = ARM::EORri;
break;
3054 if (UseOpc == ARM::t2SUBrr && Commute)
3060 NewUseOpc = UseOpc == ARM::t2ADDrr ? ARM::t2ADDri : ARM::t2SUBri;
3063 NewUseOpc = UseOpc == ARM::t2ADDrr ? ARM::t2SUBri : ARM::t2ADDri;
3077 case ARM::t2ORRrr: NewUseOpc = ARM::t2ORRri;
break;
3078 case ARM::t2EORrr: NewUseOpc = ARM::t2EORri;
break;
3085 unsigned OpIdx = Commute ? 2 : 1;
3095 UseMI.
setDesc(
get(NewUseOpc));
3109 assert(UOps >= 0 &&
"bad # UOps");
3122 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3138 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3148 case ARM::LDRSB_POST:
3149 case ARM::LDRSH_POST: {
3152 return (Rt == Rm) ? 4 : 3;
3155 case ARM::LDR_PRE_REG:
3156 case ARM::LDRB_PRE_REG: {
3166 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3172 case ARM::STR_PRE_REG:
3173 case ARM::STRB_PRE_REG: {
3179 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3186 case ARM::STRH_PRE: {
3196 case ARM::LDR_POST_REG:
3197 case ARM::LDRB_POST_REG:
3198 case ARM::LDRH_POST: {
3201 return (Rt == Rm) ? 3 : 2;
3204 case ARM::LDR_PRE_IMM:
3205 case ARM::LDRB_PRE_IMM:
3206 case ARM::LDR_POST_IMM:
3207 case ARM::LDRB_POST_IMM:
3208 case ARM::STRB_POST_IMM:
3209 case ARM::STRB_POST_REG:
3210 case ARM::STRB_PRE_IMM:
3211 case ARM::STRH_POST:
3212 case ARM::STR_POST_IMM:
3213 case ARM::STR_POST_REG:
3214 case ARM::STR_PRE_IMM:
3217 case ARM::LDRSB_PRE:
3218 case ARM::LDRSH_PRE: {
3230 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3243 return (Rt == Rn) ? 3 : 2;
3254 case ARM::LDRD_POST:
3255 case ARM::t2LDRD_POST:
3258 case ARM::STRD_POST:
3259 case ARM::t2STRD_POST:
3262 case ARM::LDRD_PRE: {
3269 return (Rt == Rn) ? 4 : 3;
3272 case ARM::t2LDRD_PRE: {
3275 return (Rt == Rn) ? 4 : 3;
3278 case ARM::STRD_PRE: {
3286 case ARM::t2STRD_PRE:
3289 case ARM::t2LDR_POST:
3290 case ARM::t2LDRB_POST:
3291 case ARM::t2LDRB_PRE:
3292 case ARM::t2LDRSBi12:
3293 case ARM::t2LDRSBi8:
3294 case ARM::t2LDRSBpci:
3296 case ARM::t2LDRH_POST:
3297 case ARM::t2LDRH_PRE:
3299 case ARM::t2LDRSB_POST:
3300 case ARM::t2LDRSB_PRE:
3301 case ARM::t2LDRSH_POST:
3302 case ARM::t2LDRSH_PRE:
3303 case ARM::t2LDRSHi12:
3304 case ARM::t2LDRSHi8:
3305 case ARM::t2LDRSHpci:
3309 case ARM::t2LDRDi8: {
3312 return (Rt == Rn) ? 3 : 2;
3315 case ARM::t2STRB_POST:
3316 case ARM::t2STRB_PRE:
3319 case ARM::t2STRH_POST:
3320 case ARM::t2STRH_PRE:
3322 case ARM::t2STR_POST:
3323 case ARM::t2STR_PRE:
3356 Size += (*I)->getSize();
3363 unsigned UOps = 1 + NumRegs;
3367 case ARM::VLDMDIA_UPD:
3368 case ARM::VLDMDDB_UPD:
3369 case ARM::VLDMSIA_UPD:
3370 case ARM::VLDMSDB_UPD:
3371 case ARM::VSTMDIA_UPD:
3372 case ARM::VSTMDDB_UPD:
3373 case ARM::VSTMSIA_UPD:
3374 case ARM::VSTMSDB_UPD:
3375 case ARM::LDMIA_UPD:
3376 case ARM::LDMDA_UPD:
3377 case ARM::LDMDB_UPD:
3378 case ARM::LDMIB_UPD:
3379 case ARM::STMIA_UPD:
3380 case ARM::STMDA_UPD:
3381 case ARM::STMDB_UPD:
3382 case ARM::STMIB_UPD:
3383 case ARM::tLDMIA_UPD:
3384 case ARM::tSTMIA_UPD:
3385 case ARM::t2LDMIA_UPD:
3386 case ARM::t2LDMDB_UPD:
3387 case ARM::t2STMIA_UPD:
3388 case ARM::t2STMDB_UPD:
3391 case ARM::LDMIA_RET:
3393 case ARM::t2LDMIA_RET:
3402 if (!ItinData || ItinData->
isEmpty())
3408 if (ItinUOps >= 0) {
3434 case ARM::VLDMDIA_UPD:
3435 case ARM::VLDMDDB_UPD:
3437 case ARM::VLDMSIA_UPD:
3438 case ARM::VLDMSDB_UPD:
3440 case ARM::VSTMDIA_UPD:
3441 case ARM::VSTMDDB_UPD:
3443 case ARM::VSTMSIA_UPD:
3444 case ARM::VSTMSDB_UPD: {
3446 return (NumRegs / 2) + (NumRegs % 2) + 1;
3449 case ARM::LDMIA_RET:
3454 case ARM::LDMIA_UPD:
3455 case ARM::LDMDA_UPD:
3456 case ARM::LDMDB_UPD:
3457 case ARM::LDMIB_UPD:
3462 case ARM::STMIA_UPD:
3463 case ARM::STMDA_UPD:
3464 case ARM::STMDB_UPD:
3465 case ARM::STMIB_UPD:
3467 case ARM::tLDMIA_UPD:
3468 case ARM::tSTMIA_UPD:
3472 case ARM::t2LDMIA_RET:
3475 case ARM::t2LDMIA_UPD:
3476 case ARM::t2LDMDB_UPD:
3479 case ARM::t2STMIA_UPD:
3480 case ARM::t2STMDB_UPD: {
3482 switch (Subtarget.getLdStMultipleTiming()) {
3493 unsigned UOps = (NumRegs / 2);
3499 unsigned UOps = (NumRegs / 2);
3517 unsigned DefIdx,
unsigned DefAlign)
const {
3524 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3526 DefCycle = RegNo / 2 + 1;
3529 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3531 bool isSLoad =
false;
3536 case ARM::VLDMSIA_UPD:
3537 case ARM::VLDMSDB_UPD:
3544 if ((isSLoad && (RegNo % 2)) || DefAlign < 8)
3548 DefCycle = RegNo + 2;
3558 if (
Op.isReg() &&
Op.getReg() == BaseReg)
3574 unsigned DefIdx,
unsigned DefAlign)
const {
3581 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3584 DefCycle = RegNo / 2;
3589 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3590 DefCycle = (RegNo / 2);
3593 if ((RegNo % 2) || DefAlign < 8)
3599 DefCycle = RegNo + 2;
3609 unsigned UseIdx,
unsigned UseAlign)
const {
3615 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3617 UseCycle = RegNo / 2 + 1;
3620 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3622 bool isSStore =
false;
3627 case ARM::VSTMSIA_UPD:
3628 case ARM::VSTMSDB_UPD:
3635 if ((isSStore && (RegNo % 2)) || UseAlign < 8)
3639 UseCycle = RegNo + 2;
3649 unsigned UseIdx,
unsigned UseAlign)
const {
3655 if (Subtarget.isCortexA8() || Subtarget.isCortexA7()) {
3656 UseCycle = RegNo / 2;
3661 }
else if (Subtarget.isLikeA9() || Subtarget.isSwift()) {
3662 UseCycle = (RegNo / 2);
3665 if ((RegNo % 2) || UseAlign < 8)
3677 unsigned DefIdx,
unsigned DefAlign,
3679 unsigned UseIdx,
unsigned UseAlign)
const {
3690 bool LdmBypass =
false;
3697 case ARM::VLDMDIA_UPD:
3698 case ARM::VLDMDDB_UPD:
3700 case ARM::VLDMSIA_UPD:
3701 case ARM::VLDMSDB_UPD:
3702 DefCycle = getVLDMDefCycle(ItinData, DefMCID, DefClass, DefIdx, DefAlign);
3705 case ARM::LDMIA_RET:
3710 case ARM::LDMIA_UPD:
3711 case ARM::LDMDA_UPD:
3712 case ARM::LDMDB_UPD:
3713 case ARM::LDMIB_UPD:
3715 case ARM::tLDMIA_UPD:
3717 case ARM::t2LDMIA_RET:
3720 case ARM::t2LDMIA_UPD:
3721 case ARM::t2LDMDB_UPD:
3723 DefCycle = getLDMDefCycle(ItinData, DefMCID, DefClass, DefIdx, DefAlign);
3738 case ARM::VSTMDIA_UPD:
3739 case ARM::VSTMDDB_UPD:
3741 case ARM::VSTMSIA_UPD:
3742 case ARM::VSTMSDB_UPD:
3743 UseCycle = getVSTMUseCycle(ItinData, UseMCID, UseClass, UseIdx, UseAlign);
3750 case ARM::STMIA_UPD:
3751 case ARM::STMDA_UPD:
3752 case ARM::STMDB_UPD:
3753 case ARM::STMIB_UPD:
3754 case ARM::tSTMIA_UPD:
3759 case ARM::t2STMIA_UPD:
3760 case ARM::t2STMDB_UPD:
3761 UseCycle = getSTMUseCycle(ItinData, UseMCID, UseClass, UseIdx, UseAlign);
3769 UseCycle = DefCycle - UseCycle + 1;
3778 UseClass, UseIdx)) {
3788 unsigned &DefIdx,
unsigned &Dist) {
3793 assert(II->isInsideBundle() &&
"Empty bundle?");
3796 while (II->isInsideBundle()) {
3797 Idx = II->findRegisterDefOperandIdx(Reg,
false,
true, TRI);
3804 assert(Idx != -1 &&
"Cannot find bundled definition!");
3811 unsigned &UseIdx,
unsigned &Dist) {
3815 assert(II->isInsideBundle() &&
"Empty bundle?");
3820 while (II != E && II->isInsideBundle()) {
3821 Idx = II->findRegisterUseOperandIdx(Reg,
false, TRI);
3824 if (II->getOpcode() != ARM::t2IT)
3862 case ARM::t2LDRSHs: {
3865 if (ShAmt == 0 || ShAmt == 2)
3870 }
else if (Subtarget.
isSwift()) {
3882 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
3893 case ARM::t2LDRSHs: {
3896 if (ShAmt == 0 || ShAmt == 1 || ShAmt == 2 || ShAmt == 3)
3910 case ARM::VLD1q8wb_fixed:
3911 case ARM::VLD1q16wb_fixed:
3912 case ARM::VLD1q32wb_fixed:
3913 case ARM::VLD1q64wb_fixed:
3914 case ARM::VLD1q8wb_register:
3915 case ARM::VLD1q16wb_register:
3916 case ARM::VLD1q32wb_register:
3917 case ARM::VLD1q64wb_register:
3924 case ARM::VLD2d8wb_fixed:
3925 case ARM::VLD2d16wb_fixed:
3926 case ARM::VLD2d32wb_fixed:
3927 case ARM::VLD2q8wb_fixed:
3928 case ARM::VLD2q16wb_fixed:
3929 case ARM::VLD2q32wb_fixed:
3930 case ARM::VLD2d8wb_register:
3931 case ARM::VLD2d16wb_register:
3932 case ARM::VLD2d32wb_register:
3933 case ARM::VLD2q8wb_register:
3934 case ARM::VLD2q16wb_register:
3935 case ARM::VLD2q32wb_register:
3940 case ARM::VLD3d8_UPD:
3941 case ARM::VLD3d16_UPD:
3942 case ARM::VLD3d32_UPD:
3943 case ARM::VLD1d64Twb_fixed:
3944 case ARM::VLD1d64Twb_register:
3945 case ARM::VLD3q8_UPD:
3946 case ARM::VLD3q16_UPD:
3947 case ARM::VLD3q32_UPD:
3952 case ARM::VLD4d8_UPD:
3953 case ARM::VLD4d16_UPD:
3954 case ARM::VLD4d32_UPD:
3955 case ARM::VLD1d64Qwb_fixed:
3956 case ARM::VLD1d64Qwb_register:
3957 case ARM::VLD4q8_UPD:
3958 case ARM::VLD4q16_UPD:
3959 case ARM::VLD4q32_UPD:
3960 case ARM::VLD1DUPq8:
3961 case ARM::VLD1DUPq16:
3962 case ARM::VLD1DUPq32:
3963 case ARM::VLD1DUPq8wb_fixed:
3964 case ARM::VLD1DUPq16wb_fixed:
3965 case ARM::VLD1DUPq32wb_fixed:
3966 case ARM::VLD1DUPq8wb_register:
3967 case ARM::VLD1DUPq16wb_register:
3968 case ARM::VLD1DUPq32wb_register:
3969 case ARM::VLD2DUPd8:
3970 case ARM::VLD2DUPd16:
3971 case ARM::VLD2DUPd32:
3972 case ARM::VLD2DUPd8wb_fixed:
3973 case ARM::VLD2DUPd16wb_fixed:
3974 case ARM::VLD2DUPd32wb_fixed:
3975 case ARM::VLD2DUPd8wb_register:
3976 case ARM::VLD2DUPd16wb_register:
3977 case ARM::VLD2DUPd32wb_register:
3978 case ARM::VLD4DUPd8:
3979 case ARM::VLD4DUPd16:
3980 case ARM::VLD4DUPd32:
3981 case ARM::VLD4DUPd8_UPD:
3982 case ARM::VLD4DUPd16_UPD:
3983 case ARM::VLD4DUPd32_UPD:
3985 case ARM::VLD1LNd16:
3986 case ARM::VLD1LNd32:
3987 case ARM::VLD1LNd8_UPD:
3988 case ARM::VLD1LNd16_UPD:
3989 case ARM::VLD1LNd32_UPD:
3991 case ARM::VLD2LNd16:
3992 case ARM::VLD2LNd32:
3993 case ARM::VLD2LNq16:
3994 case ARM::VLD2LNq32:
3995 case ARM::VLD2LNd8_UPD:
3996 case ARM::VLD2LNd16_UPD:
3997 case ARM::VLD2LNd32_UPD:
3998 case ARM::VLD2LNq16_UPD:
3999 case ARM::VLD2LNq32_UPD:
4001 case ARM::VLD4LNd16:
4002 case ARM::VLD4LNd32:
4003 case ARM::VLD4LNq16:
4004 case ARM::VLD4LNq32:
4005 case ARM::VLD4LNd8_UPD:
4006 case ARM::VLD4LNd16_UPD:
4007 case ARM::VLD4LNd32_UPD:
4008 case ARM::VLD4LNq16_UPD:
4009 case ARM::VLD4LNq32_UPD:
4023 unsigned UseIdx)
const {
4025 if (!ItinData || ItinData->
isEmpty())
4032 unsigned DefAdj = 0;
4042 unsigned UseAdj = 0;
4050 return getOperandLatencyImpl(
4051 ItinData, *ResolvedDefMI, DefIdx, ResolvedDefMI->
getDesc(), DefAdj, DefMO,
4052 Reg, *ResolvedUseMI, UseIdx, ResolvedUseMI->getDesc(), UseAdj);
4055 int ARMBaseInstrInfo::getOperandLatencyImpl(
4057 unsigned DefIdx,
const MCInstrDesc &DefMCID,
unsigned DefAdj,
4059 unsigned UseIdx,
const MCInstrDesc &UseMCID,
unsigned UseAdj)
const {
4060 if (Reg == ARM::CPSR) {
4063 return Subtarget.isLikeA9() ? 1 : 20;
4071 unsigned Latency = getInstrLatency(ItinData, DefMI);
4077 if (Latency > 0 && Subtarget.isThumb2()) {
4104 int Adj = DefAdj + UseAdj;
4108 if (Adj >= 0 || (
int)Latency > -Adj) {
4109 return Latency + Adj;
4117 SDNode *DefNode,
unsigned DefIdx,
4118 SDNode *UseNode,
unsigned UseIdx)
const {
4124 if (isZeroCost(DefMCID.
Opcode))
4127 if (!ItinData || ItinData->
isEmpty())
4128 return DefMCID.
mayLoad() ? 3 : 1;
4132 int Adj = Subtarget.getPreISelOperandLatencyAdjustment();
4134 return Latency <= Threshold ? 1 : Latency - Adj;
4145 UseMCID, UseIdx, UseAlign);
4148 (Subtarget.isCortexA8() || Subtarget.isLikeA9() ||
4149 Subtarget.isCortexA7())) {
4157 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4167 case ARM::t2LDRSHs: {
4170 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4171 if (ShAmt == 0 || ShAmt == 2)
4176 }
else if (DefIdx == 0 && Latency > 2 && Subtarget.isSwift()) {
4184 cast<ConstantSDNode>(DefNode->
getOperand(2))->getZExtValue();
4187 ((ShImm == 1 || ShImm == 2 || ShImm == 3) &&
4204 if (DefAlign < 8 && Subtarget.checkVLDnAccessAlignment())
4211 case ARM::VLD1q8wb_register:
4212 case ARM::VLD1q16wb_register:
4213 case ARM::VLD1q32wb_register:
4214 case ARM::VLD1q64wb_register:
4215 case ARM::VLD1q8wb_fixed:
4216 case ARM::VLD1q16wb_fixed:
4217 case ARM::VLD1q32wb_fixed:
4218 case ARM::VLD1q64wb_fixed:
4222 case ARM::VLD2q8Pseudo:
4223 case ARM::VLD2q16Pseudo:
4224 case ARM::VLD2q32Pseudo:
4225 case ARM::VLD2d8wb_fixed:
4226 case ARM::VLD2d16wb_fixed:
4227 case ARM::VLD2d32wb_fixed:
4228 case ARM::VLD2q8PseudoWB_fixed:
4229 case ARM::VLD2q16PseudoWB_fixed:
4230 case ARM::VLD2q32PseudoWB_fixed:
4231 case ARM::VLD2d8wb_register:
4232 case ARM::VLD2d16wb_register:
4233 case ARM::VLD2d32wb_register:
4234 case ARM::VLD2q8PseudoWB_register:
4235 case ARM::VLD2q16PseudoWB_register:
4236 case ARM::VLD2q32PseudoWB_register:
4237 case ARM::VLD3d8Pseudo:
4238 case ARM::VLD3d16Pseudo:
4239 case ARM::VLD3d32Pseudo:
4240 case ARM::VLD1d8TPseudo:
4241 case ARM::VLD1d16TPseudo:
4242 case ARM::VLD1d32TPseudo:
4243 case ARM::VLD1d64TPseudo:
4244 case ARM::VLD1d64TPseudoWB_fixed:
4245 case ARM::VLD1d64TPseudoWB_register:
4246 case ARM::VLD3d8Pseudo_UPD:
4247 case ARM::VLD3d16Pseudo_UPD:
4248 case ARM::VLD3d32Pseudo_UPD:
4249 case ARM::VLD3q8Pseudo_UPD:
4250 case ARM::VLD3q16Pseudo_UPD:
4251 case ARM::VLD3q32Pseudo_UPD:
4252 case ARM::VLD3q8oddPseudo:
4253 case ARM::VLD3q16oddPseudo:
4254 case ARM::VLD3q32oddPseudo:
4255 case ARM::VLD3q8oddPseudo_UPD:
4256 case ARM::VLD3q16oddPseudo_UPD:
4257 case ARM::VLD3q32oddPseudo_UPD:
4258 case ARM::VLD4d8Pseudo:
4259 case ARM::VLD4d16Pseudo:
4260 case ARM::VLD4d32Pseudo:
4261 case ARM::VLD1d8QPseudo:
4262 case ARM::VLD1d16QPseudo:
4263 case ARM::VLD1d32QPseudo:
4264 case ARM::VLD1d64QPseudo:
4265 case ARM::VLD1d64QPseudoWB_fixed:
4266 case ARM::VLD1d64QPseudoWB_register:
4267 case ARM::VLD1q8HighQPseudo:
4268 case ARM::VLD1q8LowQPseudo_UPD:
4269 case ARM::VLD1q8HighTPseudo:
4270 case ARM::VLD1q8LowTPseudo_UPD:
4271 case ARM::VLD1q16HighQPseudo:
4272 case ARM::VLD1q16LowQPseudo_UPD:
4273 case ARM::VLD1q16HighTPseudo:
4274 case ARM::VLD1q16LowTPseudo_UPD:
4275 case ARM::VLD1q32HighQPseudo:
4276 case ARM::VLD1q32LowQPseudo_UPD:
4277 case ARM::VLD1q32HighTPseudo:
4278 case ARM::VLD1q32LowTPseudo_UPD:
4279 case ARM::VLD1q64HighQPseudo:
4280 case ARM::VLD1q64LowQPseudo_UPD:
4281 case ARM::VLD1q64HighTPseudo:
4282 case ARM::VLD1q64LowTPseudo_UPD:
4283 case ARM::VLD4d8Pseudo_UPD:
4284 case ARM::VLD4d16Pseudo_UPD:
4285 case ARM::VLD4d32Pseudo_UPD:
4286 case ARM::VLD4q8Pseudo_UPD:
4287 case ARM::VLD4q16Pseudo_UPD:
4288 case ARM::VLD4q32Pseudo_UPD:
4289 case ARM::VLD4q8oddPseudo:
4290 case ARM::VLD4q16oddPseudo:
4291 case ARM::VLD4q32oddPseudo:
4292 case ARM::VLD4q8oddPseudo_UPD:
4293 case ARM::VLD4q16oddPseudo_UPD:
4294 case ARM::VLD4q32oddPseudo_UPD:
4295 case ARM::VLD1DUPq8:
4296 case ARM::VLD1DUPq16:
4297 case ARM::VLD1DUPq32:
4298 case ARM::VLD1DUPq8wb_fixed:
4299 case ARM::VLD1DUPq16wb_fixed:
4300 case ARM::VLD1DUPq32wb_fixed:
4301 case ARM::VLD1DUPq8wb_register:
4302 case ARM::VLD1DUPq16wb_register:
4303 case ARM::VLD1DUPq32wb_register:
4304 case ARM::VLD2DUPd8:
4305 case ARM::VLD2DUPd16:
4306 case ARM::VLD2DUPd32:
4307 case ARM::VLD2DUPd8wb_fixed:
4308 case ARM::VLD2DUPd16wb_fixed:
4309 case ARM::VLD2DUPd32wb_fixed:
4310 case ARM::VLD2DUPd8wb_register:
4311 case ARM::VLD2DUPd16wb_register:
4312 case ARM::VLD2DUPd32wb_register:
4313 case ARM::VLD2DUPq8EvenPseudo:
4314 case ARM::VLD2DUPq8OddPseudo:
4315 case ARM::VLD2DUPq16EvenPseudo:
4316 case ARM::VLD2DUPq16OddPseudo:
4317 case ARM::VLD2DUPq32EvenPseudo:
4318 case ARM::VLD2DUPq32OddPseudo:
4319 case ARM::VLD3DUPq8EvenPseudo:
4320 case ARM::VLD3DUPq8OddPseudo:
4321 case ARM::VLD3DUPq16EvenPseudo:
4322 case ARM::VLD3DUPq16OddPseudo:
4323 case ARM::VLD3DUPq32EvenPseudo:
4324 case ARM::VLD3DUPq32OddPseudo:
4325 case ARM::VLD4DUPd8Pseudo:
4326 case ARM::VLD4DUPd16Pseudo:
4327 case ARM::VLD4DUPd32Pseudo:
4328 case ARM::VLD4DUPd8Pseudo_UPD:
4329 case ARM::VLD4DUPd16Pseudo_UPD:
4330 case ARM::VLD4DUPd32Pseudo_UPD:
4331 case ARM::VLD4DUPq8EvenPseudo:
4332 case ARM::VLD4DUPq8OddPseudo:
4333 case ARM::VLD4DUPq16EvenPseudo:
4334 case ARM::VLD4DUPq16OddPseudo:
4335 case ARM::VLD4DUPq32EvenPseudo:
4336 case ARM::VLD4DUPq32OddPseudo:
4337 case ARM::VLD1LNq8Pseudo:
4338 case ARM::VLD1LNq16Pseudo:
4339 case ARM::VLD1LNq32Pseudo:
4340 case ARM::VLD1LNq8Pseudo_UPD:
4341 case ARM::VLD1LNq16Pseudo_UPD:
4342 case ARM::VLD1LNq32Pseudo_UPD:
4343 case ARM::VLD2LNd8Pseudo:
4344 case ARM::VLD2LNd16Pseudo:
4345 case ARM::VLD2LNd32Pseudo:
4346 case ARM::VLD2LNq16Pseudo:
4347 case ARM::VLD2LNq32Pseudo:
4348 case ARM::VLD2LNd8Pseudo_UPD:
4349 case ARM::VLD2LNd16Pseudo_UPD:
4350 case ARM::VLD2LNd32Pseudo_UPD:
4351 case ARM::VLD2LNq16Pseudo_UPD:
4352 case ARM::VLD2LNq32Pseudo_UPD:
4353 case ARM::VLD4LNd8Pseudo:
4354 case ARM::VLD4LNd16Pseudo:
4355 case ARM::VLD4LNd32Pseudo:
4356 case ARM::VLD4LNq16Pseudo:
4357 case ARM::VLD4LNq32Pseudo:
4358 case ARM::VLD4LNd8Pseudo_UPD:
4359 case ARM::VLD4LNd16Pseudo_UPD:
4360 case ARM::VLD4LNd32Pseudo_UPD:
4361 case ARM::VLD4LNq16Pseudo_UPD:
4362 case ARM::VLD4LNq32Pseudo_UPD:
4372 unsigned ARMBaseInstrInfo::getPredicationCost(
const MachineInstr &MI)
const {
4383 !Subtarget.cheapPredicableCPSRDef())) {
4393 unsigned *PredCost)
const {
4404 while (++I != E && I->isInsideBundle()) {
4405 if (I->getOpcode() != ARM::t2IT)
4406 Latency += getInstrLatency(ItinData, *I, PredCost);
4413 !Subtarget.cheapPredicableCPSRDef()))) {
4436 if (Adj >= 0 || (
int)Latency > -Adj) {
4437 return Latency + Adj;
4447 if (!ItinData || ItinData->
isEmpty())
4460 bool ARMBaseInstrInfo::hasHighOperandLatency(
const TargetSchedModel &SchedModel,
4465 unsigned UseIdx)
const {
4468 if (Subtarget.nonpipelinedVFP() &&
4481 bool ARMBaseInstrInfo::hasLowDefLatency(
const TargetSchedModel &SchedModel,
4483 unsigned DefIdx)
const {
4485 if (!ItinData || ItinData->
isEmpty())
4492 return (DefCycle != -1 && DefCycle <= 2);
4497 bool ARMBaseInstrInfo::verifyInstruction(
const MachineInstr &MI,
4500 ErrInfo =
"Pseudo flag setting opcodes only exist in Selection DAG";
4509 unsigned LoadImmOpc,
4510 unsigned LoadOpc)
const {
4511 assert(!Subtarget.isROPI() && !Subtarget.isRWPI() &&
4512 "ROPI/RWPI not currently supported with stack guard");
4516 unsigned Reg = MI->getOperand(0).getReg();
4518 cast<GlobalValue>((*MI->memoperands_begin())->getValue());
4521 BuildMI(MBB, MI, DL,
get(LoadImmOpc), Reg)
4524 if (Subtarget.isGVIndirectSymbol(GV)) {
4525 MIB =
BuildMI(MBB, MI, DL,
get(LoadOpc), Reg);
4535 MIB =
BuildMI(MBB, MI, DL,
get(LoadOpc), Reg);
4538 .setMemRefs(MI->memoperands_begin(), MI->memoperands_end())
4544 unsigned &AddSubOpc,
4545 bool &NegAcc,
bool &HasLane)
const {
4547 if (I == MLxEntryMap.
end())
4578 std::pair<uint16_t, uint16_t>
4582 if (Subtarget.hasNEON()) {
4590 if (Subtarget.useNEONForFPMovs() && !
isPredicated(MI) &&
4599 return std::make_pair(
ExeNEON, 0);
4604 return std::make_pair(
ExeNEON, 0);
4607 return std::make_pair(
ExeVFP, 0);
4613 unsigned SReg,
unsigned &Lane) {
4617 if (DReg != ARM::NoRegister)
4623 assert(DReg &&
"S-register with no D super-register?");
4644 unsigned Lane,
unsigned &ImplicitSReg) {
4654 (Lane & 1) ? ARM::ssub_0 : ARM::ssub_1);
4670 unsigned Domain)
const {
4671 unsigned DstReg, SrcReg, DReg;
4687 assert(Subtarget.hasNEON() &&
"VORRd requires NEON");
4720 MI.
setDesc(
get(ARM::VGETLNi32));
4741 unsigned ImplicitSReg;
4750 MI.
setDesc(
get(ARM::VSETLNi32));
4760 if (ImplicitSReg != 0)
4772 unsigned DstLane = 0, SrcLane = 0, DDst, DSrc;
4776 unsigned ImplicitSReg;
4786 MI.
setDesc(
get(ARM::VDUPLN32d));
4796 if (ImplicitSReg != 0)
4820 unsigned CurReg = SrcLane == 1 && DstLane == 1 ? DSrc : DDst;
4824 CurReg = SrcLane == 0 && DstLane == 0 ? DSrc : DDst;
4830 if (SrcLane == DstLane)
4833 MI.
setDesc(
get(ARM::VEXTd32));
4838 CurReg = SrcLane == 1 && DstLane == 0 ? DSrc : DDst;
4839 CurUndef = CurReg == DSrc && !MI.
readsRegister(CurReg, TRI);
4842 CurReg = SrcLane == 0 && DstLane == 1 ? DSrc : DDst;
4843 CurUndef = CurReg == DSrc && !MI.
readsRegister(CurReg, TRI);
4848 if (SrcLane != DstLane)
4854 if (ImplicitSReg != 0)
4880 auto PartialUpdateClearance = Subtarget.getPartialUpdateClearance();
4881 if (!PartialUpdateClearance)
4884 assert(TRI &&
"Need TRI instance");
4889 unsigned Reg = MO.
getReg();
4898 case ARM::VMOVv4i16:
4899 case ARM::VMOVv2i32:
4900 case ARM::VMOVv2f32:
4901 case ARM::VMOVv1i64:
4906 case ARM::VLD1LNd32:
4923 }
else if (ARM::SPRRegClass.
contains(Reg)) {
4933 return PartialUpdateClearance;
4941 assert(TRI &&
"Need TRI instance");
4944 unsigned Reg = MO.
getReg();
4946 "Can't break virtual register dependencies.");
4947 unsigned DReg =
Reg;
4950 if (ARM::SPRRegClass.
contains(Reg)) {
4951 DReg = ARM::D0 + (Reg - ARM::S0) / 2;
4955 assert(ARM::DPRRegClass.
contains(DReg) &&
"Can only break D-reg deps");
4973 return Subtarget.getFeatureBits()[ARM::HasV6KOps];
4983 ((ShImm == 1 || ShImm == 2) &&
5034 InputReg.
SubIdx = DefIdx == 0 ? ARM::ssub_0 : ARM::ssub_1;
5047 case ARM::VSETLNi32:
5057 InsertedReg.
Reg = MOInsertedReg.
getReg();
5059 InsertedReg.
SubIdx = MOIndex.
getImm() == 0 ? ARM::ssub_0 : ARM::ssub_1;
bool isLdstSoMinusReg(const MachineInstr &MI, unsigned Op) const
MachineConstantPoolValue * MachineCPVal
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
void push_back(const T &Elt)
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.
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
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
instr_iterator instr_end()
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
unsigned getT2SOImmTwoPartFirst(unsigned Imm)
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
Compute iterated dominance frontiers using a linear time algorithm.
bool DefinesPredicate(MachineInstr &MI, std::vector< MachineOperand > &Pred) 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...
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...
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...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
ARMConstantPoolValue - ARM specific constantpool value.
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.
unsigned getReg() const
getReg - Returns the register number.
bool expandPostRAPseudo(MachineInstr &MI) const override
void setIsUndef(bool Val=true)
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
static bool isSuitableForMask(MachineInstr *&MI, unsigned SrcReg, int CmpMask, bool CommonUse)
isSuitableForMask - Identify a suitable 'and' instruction that operates on the given source register ...
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 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
setjmp/longjmp based exceptions
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...
const MachineInstrBuilder & addGlobalAddress(const GlobalValue *GV, int64_t Offset=0, unsigned char TargetFlags=0) const
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()
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)
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)
return AArch64::GPR64RegClass contains(Reg)
static MachineOperand CreateReg(unsigned 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)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
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.
bool isMachineConstantPoolEntry() const
isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry is indeed a target specific ...
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
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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
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 ...
defusechain_iterator - This class provides iterator support for machine operands in the function that...
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.
static ARMCC::CondCodes getSwappedCondition(ARMCC::CondCodes CC)
getSwappedCondition - assume the flags are set by MI(a,b), return the condition code if we modify the...
unsigned char getAM3Offset(unsigned AM3Opc)
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...
instr_iterator getInstrIterator() const
unsigned getNumMicroOps(const InstrItineraryData *ItinData, const MachineInstr &MI) const override
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...
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.
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
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.
unsigned getKillRegState(bool B)
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
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)
bool isSuperRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a super-register of RegA.
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)
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
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.
bool readsVirtualRegister(unsigned Reg) const
Return true if the MachineInstr reads the specified virtual register.
unsigned getSORegOffset(unsigned Op)
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")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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)
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
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 optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
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.
unsigned convertAddSubFlagsOpcode(unsigned OldOpc)
Map pseudo instructions that imply an 'S' bit onto real opcodes.
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.
const MachineInstrBuilder & addFrameIndex(int Idx) const
LivenessQueryResult
Possible outcome of a register liveness query to computeRegisterLiveness()
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
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.
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...
bool isCopyInstr(const MachineInstr &MI, const MachineOperand *&Src, const MachineOperand *&Dest) const override
ARMConstantPoolConstant - ARM-specific constant pool values for Constants, Functions, and BlockAddresses.
static bool isIndirectBranchOpcode(int Opc)
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr &Orig, const TargetRegisterInfo &TRI) const override
bool memoperands_empty() const
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
void substituteRegister(unsigned FromReg, unsigned ToReg, unsigned SubIdx, const TargetRegisterInfo &RegInfo)
Replace all occurrences of FromReg with ToReg:SubIdx, properly composing subreg indices where necessa...
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.
bool regsOverlap(unsigned regA, unsigned regB) const
Returns true if the two registers are equal or alias each other.
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.
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.
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
void breakPartialRegDependency(MachineInstr &, unsigned, const TargetRegisterInfo *TRI) const override
An SDNode that represents everything that will be needed to construct a MachineInstr.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned char TargetFlags=0) 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.
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.
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.
void addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
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
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...
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
bool readsRegister(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
void copyToCPSR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned SrcReg, bool KillSrc, const ARMSubtarget &Subtarget) const
AddrMode
ARM Addressing Modes.
bool mayStore() const
Return true if this instruction could possibly modify memory.
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr *> &SeenMIs, bool) 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.
static MachineInstr * canFoldIntoMOVCC(unsigned Reg, const MachineRegisterInfo &MRI, const TargetInstrInfo *TII)
Identify instructions that can be folded into a MOVCC instruction, and return the defining instructio...
mmo_iterator memoperands_begin() const
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 CondCodes getOppositeCondition(CondCodes CC)
static const AddSubFlagsOpcodePair AddSubFlagsOpcodeMap[]
bool isMoveReg(QueryType Type=IgnoreBundle) const
Return true if this instruction is a register move.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
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...
union llvm::MachineConstantPoolEntry::@146 Val
The constant itself.
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.
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...
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.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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 ...
bool optForMinSize() const
Optimize this function for minimum size (-Oz).
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.
The memory access always returns the same value (or traps).
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
static bool isRedundantFlagInstr(const MachineInstr *CmpI, unsigned SrcReg, unsigned SrcReg2, int ImmValue, const MachineInstr *OI)
isRedundantFlagInstr - check whether the first instruction, whose only purpose is to update flags...
bool isCall() const
Return true if the instruction is a call.
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 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...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
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
static int const Threshold
TODO: Write a new FunctionPass AliasAnalysis so that it can keep a cache.
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)
static MachinePointerInfo getGOT(MachineFunction &MF)
Return a MachinePointerInfo record that refers to a GOT entry.
virtual const ARMBaseRegisterInfo & getRegisterInfo() const =0
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static use_instr_iterator use_instr_end()
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.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
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.
bool addRegisterKilled(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
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
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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)
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
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 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...
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...
void setMemRefs(mmo_iterator NewMemRefs, mmo_iterator NewMemRefsEnd)
Assign this MachineInstr's memory reference descriptor list.
bool isSafeToMove(AliasAnalysis *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
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
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.
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
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.