43 #define DEBUG_TYPE "ppc-instr-info" 45 #define GET_INSTRMAP_INFO 46 #define GET_INSTRINFO_CTOR_DTOR 47 #include "PPCGenInstrInfo.inc" 50 "Number of spillvsrrc spilled to stack as vec");
52 "Number of spillvsrrc spilled to stack as gpr");
53 STATISTIC(NumGPRtoVSRSpill,
"Number of gpr spills to spillvsrrc");
55 "Number of ISELs that depend on comparison of constants converted");
56 STATISTIC(MissedConvertibleImmediateInstrs,
57 "Number of compare-immediate instructions fed by constants");
59 "Number of record-form rotates converted to record-form andi");
63 cl::desc(
"Disable analysis for CTR loops"));
69 cl::desc(
"Causes the backend to crash instead of generating a nop VSX copy"),
74 cl::desc(
"Use the old (incorrect) instruction latency calculation"));
99 void PPCInstrInfo::anchor() {}
104 STI.isPPC64() ? PPC::BLR8 : PPC::BLR),
105 Subtarget(STI), RI(STI.getTargetMachine()) {}
113 static_cast<const PPCSubtarget *
>(STI)->getDarwinDirective();
117 static_cast<const PPCSubtarget *
>(STI)->getInstrItineraryData();
149 unsigned *PredCost)
const {
151 return PPCGenInstrInfo::getInstrLatency(ItinData, MI, PredCost);
171 Latency =
std::max(Latency, (
unsigned) Cycle);
180 unsigned UseIdx)
const {
181 int Latency = PPCGenInstrInfo::getOperandLatency(ItinData, DefMI, DefIdx,
197 IsRegCR = PPC::CRRCRegClass.contains(Reg) ||
198 PPC::CRBITRCRegClass.contains(Reg);
286 unsigned &SrcReg,
unsigned &DstReg,
287 unsigned &SubIdx)
const {
289 default:
return false;
292 case PPC::EXTSW_32_64:
295 SubIdx = PPC::sub_32;
303 const unsigned *OpcodesForSpill = getLoadOpcodesForSpillArray();
306 if (End !=
std::find(OpcodesForSpill, End, Opcode)) {
333 case PPC::ADDIStocHA:
335 case PPC::LOAD_STACK_GUARD:
344 const unsigned *OpcodesForSpill = getStoreOpcodesForSpillArray();
347 if (End !=
std::find(OpcodesForSpill, End, Opcode)) {
359 unsigned OpIdx2)
const {
382 assert(((OpIdx1 == 1 && OpIdx2 == 2) || (OpIdx1 == 2 && OpIdx2 == 1)) &&
383 "Only the operands 1 and 2 can be swapped in RLSIMI/RLWIMIo.");
391 bool ChangeReg0 =
false;
397 "Expecting a two-address instruction!");
409 if (MB == 0 && ME == 31)
420 .addImm((ME + 1) & 31)
421 .addImm((MB - 1) & 31);
442 unsigned &SrcOpIdx2)
const {
453 return fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2, 2, 3);
463 default: Opcode = PPC::NOP;
break;
472 BuildMI(MBB, MI, DL,
get(Opcode));
487 bool AllowModify)
const {
488 bool isPPC64 = Subtarget.
isPPC64();
501 if (I->getOpcode() ==
PPC::B &&
503 I->eraseFromParent();
522 }
else if (LastInst.
getOpcode() == PPC::BCC) {
530 }
else if (LastInst.
getOpcode() == PPC::BC) {
538 }
else if (LastInst.
getOpcode() == PPC::BCn) {
546 }
else if (LastInst.
getOpcode() == PPC::BDNZ8 ||
557 }
else if (LastInst.
getOpcode() == PPC::BDZ8 ||
582 if (SecondLastInst.
getOpcode() == PPC::BCC &&
592 }
else if (SecondLastInst.
getOpcode() == PPC::BC &&
602 }
else if (SecondLastInst.
getOpcode() == PPC::BCn &&
612 }
else if ((SecondLastInst.
getOpcode() == PPC::BDNZ8 ||
626 }
else if ((SecondLastInst.
getOpcode() == PPC::BDZ8 ||
650 I->eraseFromParent();
659 int *BytesRemoved)
const {
660 assert(!BytesRemoved &&
"code size not handled");
666 if (I->getOpcode() !=
PPC::B && I->getOpcode() != PPC::BCC &&
667 I->getOpcode() != PPC::BC && I->getOpcode() != PPC::BCn &&
668 I->getOpcode() != PPC::BDNZ8 && I->getOpcode() !=
PPC::BDNZ &&
669 I->getOpcode() != PPC::BDZ8 && I->getOpcode() !=
PPC::BDZ)
673 I->eraseFromParent();
677 if (I == MBB.
begin())
return 1;
679 if (I->getOpcode() != PPC::BCC &&
680 I->getOpcode() != PPC::BC && I->getOpcode() != PPC::BCn &&
681 I->getOpcode() != PPC::BDNZ8 && I->getOpcode() !=
PPC::BDNZ &&
682 I->getOpcode() != PPC::BDZ8 && I->getOpcode() !=
PPC::BDZ)
686 I->eraseFromParent();
695 int *BytesAdded)
const {
697 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
699 "PPC branch conditions have two components!");
700 assert(!BytesAdded &&
"code size not handled");
702 bool isPPC64 = Subtarget.
isPPC64();
708 else if (Cond[1].
getReg() == PPC::CTR || Cond[1].getReg() == PPC::CTR8)
709 BuildMI(&MBB, DL,
get(Cond[0].getImm() ?
711 (isPPC64 ? PPC::BDZ8 :
PPC::BDZ))).addMBB(TBB);
713 BuildMI(&MBB, DL,
get(PPC::BC)).
add(Cond[1]).addMBB(TBB);
717 BuildMI(&MBB, DL,
get(PPC::BCC))
725 if (Cond[1].
getReg() == PPC::CTR || Cond[1].
getReg() == PPC::CTR8)
726 BuildMI(&MBB, DL,
get(Cond[0].getImm() ?
734 BuildMI(&MBB, DL,
get(PPC::BCC))
745 unsigned TrueReg,
unsigned FalseReg,
746 int &CondCycles,
int &TrueCycles,
int &FalseCycles)
const {
747 if (Cond.
size() != 2)
752 if (Cond[1].
getReg() == PPC::CTR || Cond[1].getReg() == PPC::CTR8)
763 if (!PPC::GPRCRegClass.hasSubClassEq(RC) &&
764 !PPC::GPRC_NOR0RegClass.hasSubClassEq(RC) &&
765 !PPC::G8RCRegClass.hasSubClassEq(RC) &&
766 !PPC::G8RC_NOX0RegClass.hasSubClassEq(RC))
782 const DebugLoc &dl,
unsigned DestReg,
784 unsigned FalseReg)
const {
786 "PPC branch conditions have two components!");
791 RI.getCommonSubClass(MRI.getRegClass(TrueReg), MRI.getRegClass(FalseReg));
792 assert(RC &&
"TrueReg and FalseReg must have overlapping register classes");
794 bool Is64Bit = PPC::G8RCRegClass.hasSubClassEq(RC) ||
795 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC);
797 PPC::GPRCRegClass.hasSubClassEq(RC) ||
798 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) &&
799 "isel is for regular integer GPRs only");
801 unsigned OpCode = Is64Bit ? PPC::ISEL8 : PPC::ISEL;
805 bool SwapOps =
false;
806 switch (SelectPred) {
810 SubIdx = PPC::sub_eq; SwapOps =
false;
break;
814 SubIdx = PPC::sub_eq; SwapOps =
true;
break;
818 SubIdx = PPC::sub_lt; SwapOps =
false;
break;
822 SubIdx = PPC::sub_lt; SwapOps =
true;
break;
826 SubIdx = PPC::sub_gt; SwapOps =
false;
break;
830 SubIdx = PPC::sub_gt; SwapOps =
true;
break;
834 SubIdx = PPC::sub_un; SwapOps =
false;
break;
838 SubIdx = PPC::sub_un; SwapOps =
true;
break;
843 unsigned FirstReg = SwapOps ? FalseReg : TrueReg,
844 SecondReg = SwapOps ? TrueReg : FalseReg;
849 if (MRI.getRegClass(FirstReg)->contains(PPC::R0) ||
850 MRI.getRegClass(FirstReg)->contains(PPC::X0)) {
852 MRI.getRegClass(FirstReg)->
contains(PPC::X0) ?
853 &PPC::G8RC_NOX0RegClass : &PPC::GPRC_NOR0RegClass;
854 unsigned OldFirstReg = FirstReg;
855 FirstReg = MRI.createVirtualRegister(FirstRC);
856 BuildMI(MBB, MI, dl,
get(TargetOpcode::COPY), FirstReg)
860 BuildMI(MBB, MI, dl,
get(OpCode), DestReg)
867 if (CRBit == PPC::CR0LT || CRBit == PPC::CR1LT ||
868 CRBit == PPC::CR2LT || CRBit == PPC::CR3LT ||
869 CRBit == PPC::CR4LT || CRBit == PPC::CR5LT ||
870 CRBit == PPC::CR6LT || CRBit == PPC::CR7LT)
872 if (CRBit == PPC::CR0GT || CRBit == PPC::CR1GT ||
873 CRBit == PPC::CR2GT || CRBit == PPC::CR3GT ||
874 CRBit == PPC::CR4GT || CRBit == PPC::CR5GT ||
875 CRBit == PPC::CR6GT || CRBit == PPC::CR7GT)
877 if (CRBit == PPC::CR0EQ || CRBit == PPC::CR1EQ ||
878 CRBit == PPC::CR2EQ || CRBit == PPC::CR3EQ ||
879 CRBit == PPC::CR4EQ || CRBit == PPC::CR5EQ ||
880 CRBit == PPC::CR6EQ || CRBit == PPC::CR7EQ)
882 if (CRBit == PPC::CR0UN || CRBit == PPC::CR1UN ||
883 CRBit == PPC::CR2UN || CRBit == PPC::CR3UN ||
884 CRBit == PPC::CR4UN || CRBit == PPC::CR5UN ||
885 CRBit == PPC::CR6UN || CRBit == PPC::CR7UN)
888 assert(Ret != 4 &&
"Invalid CR bit register");
894 const DebugLoc &DL,
unsigned DestReg,
895 unsigned SrcReg,
bool KillSrc)
const {
899 if (PPC::F8RCRegClass.
contains(DestReg) &&
900 PPC::VSRCRegClass.
contains(SrcReg)) {
908 }
else if (PPC::F8RCRegClass.
contains(SrcReg) &&
909 PPC::VSRCRegClass.
contains(DestReg)) {
920 if (PPC::CRBITRCRegClass.
contains(SrcReg) &&
921 PPC::GPRCRegClass.
contains(DestReg)) {
927 BuildMI(MBB, I, DL,
get(PPC::RLWINM), DestReg)
933 }
else if (PPC::CRRCRegClass.
contains(SrcReg) &&
934 PPC::G8RCRegClass.
contains(DestReg)) {
935 BuildMI(MBB, I, DL,
get(PPC::MFOCRF8), DestReg).
addReg(SrcReg);
938 }
else if (PPC::CRRCRegClass.
contains(SrcReg) &&
939 PPC::GPRCRegClass.
contains(DestReg)) {
943 }
else if (PPC::G8RCRegClass.
contains(SrcReg) &&
944 PPC::VSFRCRegClass.
contains(DestReg)) {
945 BuildMI(MBB, I, DL,
get(PPC::MTVSRD), DestReg).
addReg(SrcReg);
949 }
else if (PPC::VSFRCRegClass.
contains(SrcReg) &&
950 PPC::G8RCRegClass.
contains(DestReg)) {
951 BuildMI(MBB, I, DL,
get(PPC::MFVSRD), DestReg).
addReg(SrcReg);
954 }
else if (PPC::SPERCRegClass.
contains(SrcReg) &&
955 PPC::SPE4RCRegClass.
contains(DestReg)) {
956 BuildMI(MBB, I, DL,
get(PPC::EFSCFD), DestReg).
addReg(SrcReg);
959 }
else if (PPC::SPE4RCRegClass.
contains(SrcReg) &&
960 PPC::SPERCRegClass.
contains(DestReg)) {
961 BuildMI(MBB, I, DL,
get(PPC::EFDCFS), DestReg).
addReg(SrcReg);
968 if (PPC::GPRCRegClass.
contains(DestReg, SrcReg))
970 else if (PPC::G8RCRegClass.
contains(DestReg, SrcReg))
972 else if (PPC::F4RCRegClass.
contains(DestReg, SrcReg))
974 else if (PPC::CRRCRegClass.
contains(DestReg, SrcReg))
976 else if (PPC::VRRCRegClass.
contains(DestReg, SrcReg))
978 else if (PPC::VSRCRegClass.
contains(DestReg, SrcReg))
988 else if (PPC::VSFRCRegClass.
contains(DestReg, SrcReg) ||
989 PPC::VSSRCRegClass.
contains(DestReg, SrcReg))
991 else if (PPC::QFRCRegClass.
contains(DestReg, SrcReg))
993 else if (PPC::QSRCRegClass.
contains(DestReg, SrcReg))
995 else if (PPC::QBRCRegClass.
contains(DestReg, SrcReg))
997 else if (PPC::CRBITRCRegClass.
contains(DestReg, SrcReg))
999 else if (PPC::SPERCRegClass.
contains(DestReg, SrcReg))
1006 BuildMI(MBB, I, DL, MCID, DestReg)
1015 const unsigned *OpcodesForSpill = getStoreOpcodesForSpillArray();
1018 if (RC !=
nullptr) {
1019 if (PPC::GPRCRegClass.hasSubClassEq(RC) ||
1020 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) {
1022 }
else if (PPC::G8RCRegClass.hasSubClassEq(RC) ||
1023 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC)) {
1025 }
else if (PPC::F8RCRegClass.hasSubClassEq(RC)) {
1027 }
else if (PPC::F4RCRegClass.hasSubClassEq(RC)) {
1029 }
else if (PPC::SPERCRegClass.hasSubClassEq(RC)) {
1031 }
else if (PPC::SPE4RCRegClass.hasSubClassEq(RC)) {
1033 }
else if (PPC::CRRCRegClass.hasSubClassEq(RC)) {
1035 }
else if (PPC::CRBITRCRegClass.hasSubClassEq(RC)) {
1037 }
else if (PPC::VRRCRegClass.hasSubClassEq(RC)) {
1039 }
else if (PPC::VSRCRegClass.hasSubClassEq(RC)) {
1041 }
else if (PPC::VSFRCRegClass.hasSubClassEq(RC)) {
1043 }
else if (PPC::VSSRCRegClass.hasSubClassEq(RC)) {
1045 }
else if (PPC::VRSAVERCRegClass.hasSubClassEq(RC)) {
1047 }
else if (PPC::QFRCRegClass.hasSubClassEq(RC)) {
1049 }
else if (PPC::QSRCRegClass.hasSubClassEq(RC)) {
1051 }
else if (PPC::QBRCRegClass.hasSubClassEq(RC)) {
1053 }
else if (PPC::SPILLTOVSRRCRegClass.hasSubClassEq(RC)) {
1059 if (PPC::GPRCRegClass.
contains(Reg) ||
1060 PPC::GPRC_NOR0RegClass.
contains(Reg)) {
1062 }
else if (PPC::G8RCRegClass.
contains(Reg) ||
1063 PPC::G8RC_NOX0RegClass.
contains(Reg)) {
1065 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1067 }
else if (PPC::F4RCRegClass.
contains(Reg)) {
1069 }
else if (PPC::CRRCRegClass.
contains(Reg)) {
1071 }
else if (PPC::CRBITRCRegClass.
contains(Reg)) {
1073 }
else if (PPC::VRRCRegClass.
contains(Reg)) {
1075 }
else if (PPC::VSRCRegClass.
contains(Reg)) {
1077 }
else if (PPC::VSFRCRegClass.
contains(Reg)) {
1079 }
else if (PPC::VSSRCRegClass.
contains(Reg)) {
1081 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1083 }
else if (PPC::QFRCRegClass.
contains(Reg)) {
1085 }
else if (PPC::QSRCRegClass.
contains(Reg)) {
1087 }
else if (PPC::QBRCRegClass.
contains(Reg)) {
1089 }
else if (PPC::SPILLTOVSRRCRegClass.
contains(Reg)) {
1101 const unsigned *OpcodesForSpill = getLoadOpcodesForSpillArray();
1104 if (RC !=
nullptr) {
1105 if (PPC::GPRCRegClass.hasSubClassEq(RC) ||
1106 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) {
1108 }
else if (PPC::G8RCRegClass.hasSubClassEq(RC) ||
1109 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC)) {
1111 }
else if (PPC::F8RCRegClass.hasSubClassEq(RC)) {
1113 }
else if (PPC::F4RCRegClass.hasSubClassEq(RC)) {
1115 }
else if (PPC::SPERCRegClass.hasSubClassEq(RC)) {
1117 }
else if (PPC::SPE4RCRegClass.hasSubClassEq(RC)) {
1119 }
else if (PPC::CRRCRegClass.hasSubClassEq(RC)) {
1121 }
else if (PPC::CRBITRCRegClass.hasSubClassEq(RC)) {
1123 }
else if (PPC::VRRCRegClass.hasSubClassEq(RC)) {
1125 }
else if (PPC::VSRCRegClass.hasSubClassEq(RC)) {
1127 }
else if (PPC::VSFRCRegClass.hasSubClassEq(RC)) {
1129 }
else if (PPC::VSSRCRegClass.hasSubClassEq(RC)) {
1131 }
else if (PPC::VRSAVERCRegClass.hasSubClassEq(RC)) {
1133 }
else if (PPC::QFRCRegClass.hasSubClassEq(RC)) {
1135 }
else if (PPC::QSRCRegClass.hasSubClassEq(RC)) {
1137 }
else if (PPC::QBRCRegClass.hasSubClassEq(RC)) {
1139 }
else if (PPC::SPILLTOVSRRCRegClass.hasSubClassEq(RC)) {
1145 if (PPC::GPRCRegClass.
contains(Reg) ||
1146 PPC::GPRC_NOR0RegClass.
contains(Reg)) {
1148 }
else if (PPC::G8RCRegClass.
contains(Reg) ||
1149 PPC::G8RC_NOX0RegClass.
contains(Reg)) {
1151 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1153 }
else if (PPC::F4RCRegClass.
contains(Reg)) {
1155 }
else if (PPC::CRRCRegClass.
contains(Reg)) {
1157 }
else if (PPC::CRBITRCRegClass.
contains(Reg)) {
1159 }
else if (PPC::VRRCRegClass.
contains(Reg)) {
1161 }
else if (PPC::VSRCRegClass.
contains(Reg)) {
1163 }
else if (PPC::VSFRCRegClass.
contains(Reg)) {
1165 }
else if (PPC::VSSRCRegClass.
contains(Reg)) {
1167 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1169 }
else if (PPC::QFRCRegClass.
contains(Reg)) {
1171 }
else if (PPC::QSRCRegClass.
contains(Reg)) {
1173 }
else if (PPC::QBRCRegClass.
contains(Reg)) {
1175 }
else if (PPC::SPILLTOVSRRCRegClass.
contains(Reg)) {
1184 void PPCInstrInfo::StoreRegToStackSlot(
1198 if (PPC::CRRCRegClass.hasSubClassEq(RC) ||
1199 PPC::CRBITRCRegClass.hasSubClassEq(RC))
1202 if (PPC::VRSAVERCRegClass.hasSubClassEq(RC))
1211 unsigned SrcReg,
bool isKill,
1227 StoreRegToStackSlot(MF, SrcReg, isKill, FrameIdx, RC, NewMIs);
1229 for (
unsigned i = 0, e = NewMIs.
size(); i != e; ++i)
1230 MBB.
insert(MI, NewMIs[i]);
1237 NewMIs.
back()->addMemOperand(MF, MMO);
1241 unsigned DestReg,
int FrameIdx,
1250 if (PPC::CRRCRegClass.hasSubClassEq(RC) ||
1251 PPC::CRBITRCRegClass.hasSubClassEq(RC))
1254 if (PPC::VRSAVERCRegClass.hasSubClassEq(RC))
1264 unsigned DestReg,
int FrameIdx,
1270 if (MI != MBB.
end()) DL = MI->getDebugLoc();
1282 if (Subtarget.
hasVSX() && RC == &PPC::VRRCRegClass)
1283 RC = &PPC::VSRCRegClass;
1285 LoadRegFromStackSlot(MF, DL, DestReg, FrameIdx, RC, NewMIs);
1287 for (
unsigned i = 0, e = NewMIs.
size(); i != e; ++i)
1288 MBB.
insert(MI, NewMIs[i]);
1295 NewMIs.
back()->addMemOperand(MF, MMO);
1300 assert(Cond.
size() == 2 &&
"Invalid PPC branch opcode!");
1301 if (Cond[1].
getReg() == PPC::CTR8 || Cond[1].getReg() == PPC::CTR)
1302 Cond[0].setImm(Cond[0].getImm() == 0 ? 1 : 0);
1314 if (DefOpc != PPC::LI && DefOpc != PPC::LI8)
1344 if (UseInfo->isLookupPtrRegClass()) {
1345 if (UseInfo->RegClass != 1)
1348 if (UseInfo->RegClass != PPC::GPRC_NOR0RegClassID &&
1349 UseInfo->RegClass != PPC::G8RC_NOX0RegClassID)
1356 if (UseInfo->Constraints != 0)
1360 if (UseInfo->isLookupPtrRegClass()) {
1361 bool isPPC64 = Subtarget.
isPPC64();
1362 ZeroReg = isPPC64 ? PPC::ZERO8 : PPC::ZERO;
1364 ZeroReg = UseInfo->RegClass == PPC::G8RC_NOX0RegClassID ?
1365 PPC::ZERO8 : PPC::ZERO;
1380 if (
I->definesRegister(PPC::CTR) ||
I->definesRegister(PPC::CTR8))
1392 unsigned NumT,
unsigned ExtraT,
1394 unsigned NumF,
unsigned ExtraF,
1425 if (OpC == PPC::BLR || OpC == PPC::BLR8) {
1426 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR) {
1427 bool isPPC64 = Subtarget.
isPPC64();
1428 MI.
setDesc(
get(Pred[0].getImm() ? (isPPC64 ? PPC::BDNZLR8 : PPC::BDNZLR)
1429 : (isPPC64 ? PPC::BDZLR8 : PPC::BDZLR)));
1433 .addReg(Pred[1].
getReg());
1437 .addReg(Pred[1].
getReg());
1441 .addImm(Pred[0].getImm())
1442 .addReg(Pred[1].
getReg());
1446 }
else if (OpC ==
PPC::B) {
1447 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].getReg() == PPC::CTR) {
1448 bool isPPC64 = Subtarget.
isPPC64();
1450 : (isPPC64 ? PPC::BDZ8 :
PPC::BDZ)));
1457 .addReg(Pred[1].
getReg())
1465 .addReg(Pred[1].
getReg())
1473 .addImm(Pred[0].getImm())
1474 .addReg(Pred[1].
getReg())
1479 }
else if (OpC == PPC::BCTR || OpC == PPC::BCTR8 ||
1481 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR)
1484 bool setLR = OpC ==
PPC::BCTRL || OpC == PPC::BCTRL8;
1485 bool isPPC64 = Subtarget.
isPPC64();
1488 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8 : PPC::BCCTR8)
1489 : (setLR ? PPC::BCCTRL : PPC::BCCTR)));
1491 .addReg(Pred[1].
getReg());
1494 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8n : PPC::BCCTR8n)
1495 : (setLR ? PPC::BCCTRLn : PPC::BCCTRn)));
1497 .addReg(Pred[1].
getReg());
1501 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCCTRL8 : PPC::BCCCTR8)
1502 : (setLR ? PPC::BCCCTRL : PPC::BCCCTR)));
1504 .addImm(Pred[0].getImm())
1505 .addReg(Pred[1].
getReg());
1514 assert(Pred1.
size() == 2 &&
"Invalid PPC first predicate");
1515 assert(Pred2.
size() == 2 &&
"Invalid PPC second predicate");
1517 if (Pred1[1].
getReg() == PPC::CTR8 || Pred1[1].getReg() == PPC::CTR)
1519 if (Pred2[1].
getReg() == PPC::CTR8 || Pred2[1].getReg() == PPC::CTR)
1523 if (Pred1[1].
getReg() != Pred2[1].getReg())
1544 std::vector<MachineOperand> &Pred)
const {
1552 { &PPC::CRRCRegClass, &PPC::CRBITRCRegClass,
1553 &PPC::CTRRCRegClass, &PPC::CTRRC8RegClass };
1596 unsigned &SrcReg2,
int &
Mask,
1601 default:
return false;
1636 if (OpC == PPC::FCMPUS || OpC == PPC::FCMPUD)
1647 bool isPPC64 = Subtarget.
isPPC64();
1648 bool is32BitSignedCompare = OpC == PPC::CMPWI || OpC == PPC::CMPW;
1649 bool is32BitUnsignedCompare = OpC == PPC::CMPLWI || OpC == PPC::CMPLW;
1650 bool is64BitUnsignedCompare = OpC == PPC::CMPLDI || OpC == PPC::CMPLD;
1654 if (!MI)
return false;
1656 bool equalityOnly =
false;
1659 if (is32BitSignedCompare) {
1665 }
else if (is32BitUnsignedCompare) {
1670 equalityOnly =
true;
1674 equalityOnly = is64BitUnsignedCompare;
1676 equalityOnly = is32BitUnsignedCompare;
1691 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1694 if (SubIdx != PPC::sub_eq)
1706 bool FoundUse =
false;
1735 else if (Value != 0) {
1744 if (equalityOnly || !MRI->
hasOneUse(CRReg))
1755 int16_t Immed = (int16_t)Value;
1786 for (; I != E && !noSub; --
I) {
1800 if ((OpC == PPC::CMPW || OpC == PPC::CMPLW ||
1801 OpC == PPC::CMPD || OpC == PPC::CMPLD) &&
1802 (IOpC == PPC::SUBF || IOpC == PPC::SUBF8) &&
1825 if (MIOpC == PPC::ANDIo || MIOpC == PPC::ANDIo8)
1828 NewOpC = PPC::getRecordFormOpcode(MIOpC);
1848 bool ShouldSwap =
false;
1849 if (Sub && Value == 0) {
1855 ShouldSwap = !ShouldSwap;
1868 "Invalid predicate for equality-only optimization");
1872 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1875 assert((!equalityOnly || NewSubReg == PPC::sub_eq) &&
1876 "Invalid CR bit for equality-only optimization");
1878 if (NewSubReg == PPC::sub_lt)
1879 NewSubReg = PPC::sub_gt;
1880 else if (NewSubReg == PPC::sub_gt)
1881 NewSubReg = PPC::sub_lt;
1888 assert(!(Value != 0 && ShouldSwap) &&
1889 "Non-zero immediate support and ShouldSwap" 1890 "may conflict in updating predicate");
1899 get(TargetOpcode::COPY), CRReg)
1906 if (MIOpC != NewOpC) {
1916 if ((MIOpC == PPC::RLWINM || MIOpC == PPC::RLWINM8) &&
1920 if (MB < ME && MB >= 16) {
1921 uint64_t Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
1922 NewOpC = MIOpC == PPC::RLWINM ? PPC::ANDIo : PPC::ANDIo8;
1926 NumRcRotatesConvertedToRcAnd++;
1931 uint64_t Mask = (1LLU << (63 - MB + 1)) - 1;
1932 NewOpC = PPC::ANDIo8;
1935 NumRcRotatesConvertedToRcAnd++;
1944 *ImpDefs; ++ImpDefs)
1950 *ImpUses; ++ImpUses)
1956 "Record-form instruction does not define cr0?");
1961 for (
unsigned i = 0, e = PredsToUpdate.
size(); i < e; i++)
1962 PredsToUpdate[i].
first->setImm(PredsToUpdate[i].second);
1964 for (
unsigned i = 0, e = SubRegsToUpdate.
size(); i < e; i++)
1965 SubRegsToUpdate[i].
first->setSubReg(SubRegsToUpdate[i].second);
1980 }
else if (Opcode == TargetOpcode::STACKMAP) {
1983 }
else if (Opcode == TargetOpcode::PATCHPOINT) {
1987 return get(Opcode).getSize();
1991 std::pair<unsigned, unsigned>
1994 return std::make_pair(TF & Mask, TF & ~Mask);
1999 using namespace PPCII;
2000 static const std::pair<unsigned, const char *>
TargetFlags[] = {
2014 using namespace PPCII;
2015 static const std::pair<unsigned, const char *>
TargetFlags[] = {
2030 unsigned UpperOpcode, LowerOpcode;
2032 case PPC::DFLOADf32:
2033 UpperOpcode = PPC::LXSSP;
2034 LowerOpcode = PPC::LFS;
2036 case PPC::DFLOADf64:
2037 UpperOpcode = PPC::LXSD;
2038 LowerOpcode = PPC::LFD;
2040 case PPC::DFSTOREf32:
2041 UpperOpcode = PPC::STXSSP;
2042 LowerOpcode = PPC::STFS;
2044 case PPC::DFSTOREf64:
2045 UpperOpcode = PPC::STXSD;
2046 LowerOpcode = PPC::STFD;
2048 case PPC::XFLOADf32:
2049 UpperOpcode = PPC::LXSSPX;
2050 LowerOpcode = PPC::LFSX;
2052 case PPC::XFLOADf64:
2053 UpperOpcode = PPC::LXSDX;
2054 LowerOpcode = PPC::LFDX;
2056 case PPC::XFSTOREf32:
2057 UpperOpcode = PPC::STXSSPX;
2058 LowerOpcode = PPC::STFSX;
2060 case PPC::XFSTOREf64:
2061 UpperOpcode = PPC::STXSDX;
2062 LowerOpcode = PPC::STFDX;
2065 UpperOpcode = PPC::LXSIWAX;
2069 UpperOpcode = PPC::LXSIWZX;
2073 UpperOpcode = PPC::STXSIWX;
2082 if ((TargetReg >= PPC::F0 && TargetReg <= PPC::F31) ||
2083 (TargetReg >= PPC::VSL0 && TargetReg <= PPC::VSL31))
2084 Opcode = LowerOpcode;
2086 Opcode = UpperOpcode;
2102 case TargetOpcode::LOAD_STACK_GUARD: {
2103 assert(Subtarget.isTargetLinux() &&
2104 "Only Linux target is expected to contain LOAD_STACK_GUARD");
2105 const int64_t
Offset = Subtarget.isPPC64() ? -0x7010 : -0x7008;
2106 const unsigned Reg = Subtarget.isPPC64() ? PPC::X13 :
PPC::R2;
2113 case PPC::DFLOADf32:
2114 case PPC::DFLOADf64:
2115 case PPC::DFSTOREf32:
2116 case PPC::DFSTOREf64: {
2117 assert(Subtarget.hasP9Vector() &&
2118 "Invalid D-Form Pseudo-ops on Pre-P9 target.");
2121 "D-form op must have register and immediate operands");
2124 case PPC::XFLOADf32:
2125 case PPC::XFSTOREf32:
2129 assert(Subtarget.hasP8Vector() &&
2130 "Invalid X-Form Pseudo-ops on Pre-P8 target.");
2132 "X-form op must have register and register operands");
2135 case PPC::XFLOADf64:
2136 case PPC::XFSTOREf64: {
2137 assert(Subtarget.hasVSX() &&
2138 "Invalid X-Form Pseudo-ops on target that has no VSX.");
2140 "X-form op must have register and register operands");
2143 case PPC::SPILLTOVSR_LD: {
2145 if (PPC::VSFRCRegClass.
contains(TargetReg)) {
2146 MI.
setDesc(
get(PPC::DFLOADf64));
2153 case PPC::SPILLTOVSR_ST: {
2155 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2156 NumStoreSPILLVSRRCAsVec++;
2157 MI.
setDesc(
get(PPC::DFSTOREf64));
2160 NumStoreSPILLVSRRCAsGpr++;
2165 case PPC::SPILLTOVSR_LDX: {
2167 if (PPC::VSFRCRegClass.
contains(TargetReg))
2173 case PPC::SPILLTOVSR_STX: {
2175 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2176 NumStoreSPILLVSRRCAsVec++;
2179 NumStoreSPILLVSRRCAsGpr++;
2185 case PPC::CFENCE8: {
2188 BuildMI(MBB, MI, DL,
get(PPC::CTRL_DEP))
2204 static unsigned selectReg(int64_t Imm1, int64_t Imm2,
unsigned CompareOpc,
2205 unsigned TrueReg,
unsigned FalseReg,
2206 unsigned CRSubReg) {
2208 if (CompareOpc == PPC::CMPWI || CompareOpc == PPC::CMPDI) {
2212 return Imm1 < Imm2 ? TrueReg : FalseReg;
2214 return Imm1 > Imm2 ? TrueReg : FalseReg;
2216 return Imm1 == Imm2 ? TrueReg : FalseReg;
2220 else if (CompareOpc == PPC::CMPLWI || CompareOpc == PPC::CMPLDI) {
2224 return (uint64_t)Imm1 < (uint64_t)Imm2 ? TrueReg : FalseReg;
2226 return (uint64_t)Imm1 > (uint64_t)Imm2 ? TrueReg : FalseReg;
2228 return Imm1 == Imm2 ? TrueReg : FalseReg;
2231 return PPC::NoRegister;
2239 int OperandToKeep = LII.
SetCR ? 1 : 0;
2261 bool &SeenIntermediateUse)
const {
2290 bool ConvertibleImmForm =
2291 Opc == PPC::CMPWI || Opc == PPC::CMPLWI ||
2292 Opc == PPC::CMPDI || Opc == PPC::CMPLDI ||
2293 Opc == PPC::ADDI || Opc == PPC::ADDI8 ||
2294 Opc == PPC::ORI || Opc == PPC::ORI8 ||
2295 Opc == PPC::XORI || Opc == PPC::XORI8 ||
2296 Opc == PPC::RLDICL || Opc == PPC::RLDICLo ||
2297 Opc == PPC::RLDICL_32 || Opc == PPC::RLDICL_32_64 ||
2298 Opc == PPC::RLWINM || Opc == PPC::RLWINMo ||
2299 Opc == PPC::RLWINM8 || Opc == PPC::RLWINM8o;
2304 if ((Opc ==
PPC::OR || Opc == PPC::OR8) &&
2309 SeenIntermediateUse =
false;
2319 if (PPC::G8RCRegClass.
contains(Reg))
2320 Reg = Reg - PPC::X0 + PPC::R0;
2323 for ( ; It !=
E; ++It) {
2325 if (It->getOpcode() == PPC::LI || It->getOpcode() == PPC::LI8) {
2333 SeenIntermediateUse =
true;
2338 return ConstOp == ~0U ? nullptr :
DefMI;
2341 const unsigned *PPCInstrInfo::getStoreOpcodesForSpillArray()
const {
2344 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2345 PPC::SPILL_CRBIT, PPC::STVX,
PPC::STXVD2X, PPC::STXSDX, PPC::STXSSPX,
2346 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2347 PPC::SPILLTOVSR_ST, PPC::EVSTDD, PPC::SPESTW},
2349 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2350 PPC::SPILL_CRBIT, PPC::STVX, PPC::STXV, PPC::DFSTOREf64, PPC::DFSTOREf32,
2351 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2352 PPC::SPILLTOVSR_ST}};
2354 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2357 const unsigned *PPCInstrInfo::getLoadOpcodesForSpillArray()
const {
2360 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2361 PPC::RESTORE_CRBIT, PPC::LVX,
PPC::LXVD2X, PPC::LXSDX, PPC::LXSSPX,
2362 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2363 PPC::SPILLTOVSR_LD, PPC::EVLDD, PPC::SPELWZ},
2365 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2366 PPC::RESTORE_CRBIT, PPC::LVX, PPC::LXV, PPC::DFLOADf64, PPC::DFLOADf32,
2367 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2368 PPC::SPILLTOVSR_LD}};
2370 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2380 bool PostRA = !MRI->
isSSA();
2381 bool SeenIntermediateUse =
true;
2382 unsigned ConstantOperand = ~0U;
2384 SeenIntermediateUse);
2388 "The constant operand needs to be valid at this point");
2392 int64_t SExtImm = ((uint64_t)Immediate & ~0x7FFFuLL) != 0 ?
2393 (Immediate | 0xFFFFFFFFFFFF0000) : Immediate;
2396 !SeenIntermediateUse)
2402 return transformToImmForm(MI, III, ConstantOperand, SExtImm);
2404 bool ReplaceWithLI =
false;
2405 bool Is64BitLI =
false;
2410 default:
return false;
2426 bool Changed =
false;
2429 int64_t SExtComparand = ((uint64_t)Comparand & ~0x7FFFuLL) != 0 ?
2430 (Comparand | 0xFFFFFFFFFFFF0000) : Comparand;
2433 unsigned UseOpc = CompareUseMI.getOpcode();
2434 if (UseOpc != PPC::ISEL && UseOpc != PPC::ISEL8)
2436 unsigned CRSubReg = CompareUseMI.getOperand(3).getSubReg();
2437 unsigned TrueReg = CompareUseMI.getOperand(1).getReg();
2438 unsigned FalseReg = CompareUseMI.getOperand(2).getReg();
2439 unsigned RegToCopy =
selectReg(SExtImm, SExtComparand, Opc, TrueReg,
2440 FalseReg, CRSubReg);
2441 if (RegToCopy == PPC::NoRegister)
2444 if (RegToCopy == PPC::ZERO || RegToCopy == PPC::ZERO8) {
2445 CompareUseMI.setDesc(
get(UseOpc == PPC::ISEL8 ? PPC::LI8 : PPC::LI));
2446 CompareUseMI.getOperand(1).ChangeToImmediate(0);
2447 CompareUseMI.RemoveOperand(3);
2448 CompareUseMI.RemoveOperand(2);
2452 dbgs() <<
"Found LI -> CMPI -> ISEL, replacing with a copy.\n");
2456 CompareUseMI.setDesc(
get(PPC::COPY));
2457 CompareUseMI.RemoveOperand(3);
2458 CompareUseMI.RemoveOperand(RegToCopy == TrueReg ? 2 : 1);
2459 CmpIselsConverted++;
2468 MissedConvertibleImmediateInstrs++;
2478 ReplaceWithLI =
true;
2479 Is64BitLI = Opc == PPC::ADDI8;
2480 NewImm = Addend + SExtImm;
2487 case PPC::RLDICL_32:
2488 case PPC::RLDICL_32_64: {
2492 APInt InVal((Opc == PPC::RLDICL || Opc == PPC::RLDICLo) ?
2493 64 : 32, SExtImm,
true);
2494 InVal = InVal.
rotl(SH);
2495 uint64_t
Mask = (1LLU << (63 - MB + 1)) - 1;
2502 ReplaceWithLI =
true;
2503 Is64BitLI = Opc != PPC::RLDICL_32;
2505 SetCR = Opc == PPC::RLDICLo;
2513 case PPC::RLWINM8o: {
2517 APInt InVal(32, SExtImm,
true);
2518 InVal = InVal.
rotl(SH);
2520 uint64_t
Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
2526 ValueFits |= ((Opc == PPC::RLWINMo || Opc == PPC::RLWINM8o) &&
2529 ReplaceWithLI =
true;
2530 Is64BitLI = Opc == PPC::RLWINM8 || Opc == PPC::RLWINM8o;
2532 SetCR = Opc == PPC::RLWINMo || Opc == PPC::RLWINM8o;
2543 if (Opc == PPC::ORI || Opc == PPC::ORI8)
2544 Result = LogicalImm | SExtImm;
2546 Result = LogicalImm ^ SExtImm;
2548 ReplaceWithLI =
true;
2549 Is64BitLI = Opc == PPC::ORI8 || Opc == PPC::XORI8;
2557 if (ReplaceWithLI) {
2562 bool ImmChanged = (SExtImm & NewImm) != NewImm;
2563 if (PostRA && ImmChanged)
2576 assert(Immediate &&
"Transformation converted zero to non-zero?");
2580 else if (ImmChanged)
2591 LII.Is64Bit = Is64BitLI;
2595 if (KilledDef && SetCR)
2596 *KilledDef =
nullptr;
2618 default:
return false;
2625 III.
ImmOpcode = Opc == PPC::ADD4 ? PPC::ADDI : PPC::ADDI8;
2648 III.
ImmOpcode = Opc == PPC::SUBFC ? PPC::SUBFIC : PPC::SUBFIC8;
2656 III.
ImmOpcode = Opc == PPC::CMPW ? PPC::CMPWI : PPC::CMPDI;
2664 III.
ImmOpcode = Opc == PPC::CMPLW ? PPC::CMPLWI : PPC::CMPLDI;
2678 case PPC::ANDo: III.
ImmOpcode = PPC::ANDIo;
break;
2679 case PPC::AND8o: III.
ImmOpcode = PPC::ANDIo8;
break;
2681 case PPC::OR8: III.
ImmOpcode = PPC::ORI8;
break;
2683 case PPC::XOR8: III.
ImmOpcode = PPC::XORI8;
break;
2709 if (Opc == PPC::RLWNM || Opc == PPC::RLWNM8 ||
2710 Opc == PPC::RLWNMo || Opc == PPC::RLWNM8o)
2716 case PPC::RLWNM: III.
ImmOpcode = PPC::RLWINM;
break;
2717 case PPC::RLWNM8: III.
ImmOpcode = PPC::RLWINM8;
break;
2718 case PPC::RLWNMo: III.
ImmOpcode = PPC::RLWINMo;
break;
2719 case PPC::RLWNM8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2720 case PPC::SLW: III.
ImmOpcode = PPC::RLWINM;
break;
2721 case PPC::SLW8: III.
ImmOpcode = PPC::RLWINM8;
break;
2722 case PPC::SLWo: III.
ImmOpcode = PPC::RLWINMo;
break;
2723 case PPC::SLW8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2724 case PPC::SRW: III.
ImmOpcode = PPC::RLWINM;
break;
2725 case PPC::SRW8: III.
ImmOpcode = PPC::RLWINM8;
break;
2726 case PPC::SRWo: III.
ImmOpcode = PPC::RLWINMo;
break;
2727 case PPC::SRW8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2759 if (Opc == PPC::RLDCL || Opc == PPC::RLDCLo ||
2760 Opc == PPC::RLDCR || Opc == PPC::RLDCRo)
2766 case PPC::RLDCL: III.
ImmOpcode = PPC::RLDICL;
break;
2767 case PPC::RLDCLo: III.
ImmOpcode = PPC::RLDICLo;
break;
2768 case PPC::RLDCR: III.
ImmOpcode = PPC::RLDICR;
break;
2769 case PPC::RLDCRo: III.
ImmOpcode = PPC::RLDICRo;
break;
2770 case PPC::SLD: III.
ImmOpcode = PPC::RLDICR;
break;
2771 case PPC::SLDo: III.
ImmOpcode = PPC::RLDICRo;
break;
2772 case PPC::SRD: III.
ImmOpcode = PPC::RLDICL;
break;
2773 case PPC::SRDo: III.
ImmOpcode = PPC::RLDICLo;
break;
2816 case PPC::LBZX: III.
ImmOpcode = PPC::LBZ;
break;
2817 case PPC::LBZX8: III.
ImmOpcode = PPC::LBZ8;
break;
2818 case PPC::LHZX: III.
ImmOpcode = PPC::LHZ;
break;
2819 case PPC::LHZX8: III.
ImmOpcode = PPC::LHZ8;
break;
2820 case PPC::LHAX: III.
ImmOpcode = PPC::LHA;
break;
2821 case PPC::LHAX8: III.
ImmOpcode = PPC::LHA8;
break;
2822 case PPC::LWZX: III.
ImmOpcode = PPC::LWZ;
break;
2823 case PPC::LWZX8: III.
ImmOpcode = PPC::LWZ8;
break;
2829 case PPC::LFSX: III.
ImmOpcode = PPC::LFS;
break;
2830 case PPC::LFDX: III.
ImmOpcode = PPC::LFD;
break;
2831 case PPC::STBX: III.
ImmOpcode = PPC::STB;
break;
2832 case PPC::STBX8: III.
ImmOpcode = PPC::STB8;
break;
2833 case PPC::STHX: III.
ImmOpcode = PPC::STH;
break;
2834 case PPC::STHX8: III.
ImmOpcode = PPC::STH8;
break;
2835 case PPC::STWX: III.
ImmOpcode = PPC::STW;
break;
2836 case PPC::STWX8: III.
ImmOpcode = PPC::STW8;
break;
2841 case PPC::STFSX: III.
ImmOpcode = PPC::STFS;
break;
2842 case PPC::STFDX: III.
ImmOpcode = PPC::STFD;
break;
2873 case PPC::LBZUX: III.
ImmOpcode = PPC::LBZU;
break;
2874 case PPC::LBZUX8: III.
ImmOpcode = PPC::LBZU8;
break;
2875 case PPC::LHZUX: III.
ImmOpcode = PPC::LHZU;
break;
2876 case PPC::LHZUX8: III.
ImmOpcode = PPC::LHZU8;
break;
2877 case PPC::LHAUX: III.
ImmOpcode = PPC::LHAU;
break;
2878 case PPC::LHAUX8: III.
ImmOpcode = PPC::LHAU8;
break;
2879 case PPC::LWZUX: III.
ImmOpcode = PPC::LWZU;
break;
2880 case PPC::LWZUX8: III.
ImmOpcode = PPC::LWZU8;
break;
2885 case PPC::LFSUX: III.
ImmOpcode = PPC::LFSU;
break;
2886 case PPC::LFDUX: III.
ImmOpcode = PPC::LFDU;
break;
2887 case PPC::STBUX: III.
ImmOpcode = PPC::STBU;
break;
2888 case PPC::STBUX8: III.
ImmOpcode = PPC::STBU8;
break;
2889 case PPC::STHUX: III.
ImmOpcode = PPC::STHU;
break;
2890 case PPC::STHUX8: III.
ImmOpcode = PPC::STHU8;
break;
2891 case PPC::STWUX: III.
ImmOpcode = PPC::STWU;
break;
2892 case PPC::STWUX8: III.
ImmOpcode = PPC::STWU8;
break;
2897 case PPC::STFSUX: III.
ImmOpcode = PPC::STFSU;
break;
2898 case PPC::STFDUX: III.
ImmOpcode = PPC::STFDU;
break;
2908 if (!Subtarget.hasP9Vector())
2950 assert(Op1 != Op2 &&
"Cannot swap operand with itself.");
2952 unsigned MaxOp =
std::max(Op1, Op2);
2953 unsigned MinOp = std::min(Op1, Op2);
2988 unsigned ConstantOpNo,
2989 int64_t Imm)
const {
2991 bool PostRA = !MRI.
isSSA();
3000 APInt ActualValue(64, Imm,
true);
3004 uint64_t UnsignedMax = (1 << III.
ImmWidth) - 1;
3005 if ((uint64_t)Imm > UnsignedMax)
3019 if ((NewZeroReg == PPC::R0 || NewZeroReg == PPC::X0) &&
3022 if ((OrigZeroReg == PPC::R0 || OrigZeroReg == PPC::X0) &&
3023 ConstantOpNo != PosForOrigZero)
3028 bool SpecialShift32 =
3029 Opc == PPC::SLW || Opc == PPC::SLWo || Opc == PPC::SRW || Opc == PPC::SRWo;
3030 bool SpecialShift64 =
3031 Opc == PPC::SLD || Opc == PPC::SLDo || Opc == PPC::SRD || Opc == PPC::SRDo;
3032 bool SetCR = Opc == PPC::SLWo || Opc == PPC::SRWo ||
3033 Opc == PPC::SLDo || Opc == PPC::SRDo;
3035 Opc == PPC::SRW || Opc == PPC::SRWo || Opc == PPC::SRD || Opc == PPC::SRDo;
3045 if (SpecialShift32 || SpecialShift64) {
3050 uint64_t ShAmt = Imm & (SpecialShift32 ? 0x1F : 0x3F);
3051 if (Imm & (SpecialShift32 ? 0x20 : 0x40))
3056 else if (!SetCR && ShAmt == 0 && !PostRA) {
3061 if (SpecialShift32) {
3063 uint64_t SH = RightShift ? 32 - ShAmt : ShAmt;
3064 uint64_t MB = RightShift ? ShAmt : 0;
3065 uint64_t ME = RightShift ? 31 : 31 - ShAmt;
3071 uint64_t SH = RightShift ? 64 - ShAmt : ShAmt;
3072 uint64_t ME = RightShift ? ShAmt : 63 - ShAmt;
3100 &PPC::GPRC_and_GPRC_NOR0RegClass : &PPC::G8RC_and_G8RC_NOX0RegClass;
3109 if (Subtarget.hasVSX() && RC == &PPC::VRRCRegClass)
3110 return &PPC::VSRCRegClass;
3115 return PPC::getRecordFormOpcode(Opcode);
3123 if (Opcode == PPC::LI || Opcode == PPC::LI8 ||
3124 Opcode == PPC::LIS || Opcode == PPC::LIS8 ||
3125 Opcode == PPC::SRAW || Opcode == PPC::SRAWo ||
3126 Opcode == PPC::SRAWI || Opcode == PPC::SRAWIo ||
3127 Opcode == PPC::LWA || Opcode == PPC::LWAX ||
3128 Opcode == PPC::LWA_32 || Opcode == PPC::LWAX_32 ||
3129 Opcode == PPC::LHA || Opcode == PPC::LHAX ||
3130 Opcode == PPC::LHA8 || Opcode == PPC::LHAX8 ||
3131 Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
3132 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
3133 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
3134 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3135 Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
3136 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
3137 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
3138 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8 ||
3139 Opcode == PPC::EXTSB || Opcode == PPC::EXTSBo ||
3140 Opcode == PPC::EXTSH || Opcode == PPC::EXTSHo ||
3141 Opcode == PPC::EXTSB8 || Opcode == PPC::EXTSH8 ||
3142 Opcode == PPC::EXTSW || Opcode == PPC::EXTSWo ||
3143 Opcode == PPC::EXTSH8_32_64 || Opcode == PPC::EXTSW_32_64 ||
3144 Opcode == PPC::EXTSB8_32_64)
3150 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINMo ||
3151 Opcode == PPC::RLWNM || Opcode == PPC::RLWNMo) &&
3165 if (Opcode == PPC::LI || Opcode == PPC::LI8 ||
3166 Opcode == PPC::LIS || Opcode == PPC::LIS8) {
3168 if (((uint64_t)Imm & ~0x7FFFuLL) == 0)
3174 if ((Opcode == PPC::RLDICL || Opcode == PPC::RLDICLo ||
3175 Opcode == PPC::RLDCL || Opcode == PPC::RLDCLo ||
3176 Opcode == PPC::RLDICL_32_64) &&
3180 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDICo) &&
3185 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINMo ||
3186 Opcode == PPC::RLWNM || Opcode == PPC::RLWNMo ||
3187 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
3192 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZWo ||
3193 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZWo ||
3194 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8 ||
3195 Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZDo ||
3196 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZDo ||
3197 Opcode == PPC::POPCNTD || Opcode == PPC::POPCNTW ||
3198 Opcode == PPC::SLW || Opcode == PPC::SLWo ||
3199 Opcode == PPC::SRW || Opcode == PPC::SRWo ||
3200 Opcode == PPC::SLW8 || Opcode == PPC::SRW8 ||
3201 Opcode == PPC::SLWI || Opcode == PPC::SLWIo ||
3202 Opcode == PPC::SRWI || Opcode == PPC::SRWIo ||
3203 Opcode == PPC::LWZ || Opcode == PPC::LWZX ||
3204 Opcode == PPC::LWZU || Opcode == PPC::LWZUX ||
3205 Opcode == PPC::LWBRX || Opcode == PPC::LHBRX ||
3206 Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
3207 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
3208 Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
3209 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
3210 Opcode == PPC::LWZ8 || Opcode == PPC::LWZX8 ||
3211 Opcode == PPC::LWZU8 || Opcode == PPC::LWZUX8 ||
3212 Opcode == PPC::LWBRX8 || Opcode == PPC::LHBRX8 ||
3213 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
3214 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8 ||
3215 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
3216 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3217 Opcode == PPC::ANDIo || Opcode == PPC::ANDISo ||
3218 Opcode == PPC::ROTRWI || Opcode == PPC::ROTRWIo ||
3219 Opcode == PPC::EXTLWI || Opcode == PPC::EXTLWIo ||
3220 Opcode == PPC::MFVSRWZ)
3231 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
3234 if (StackReg == PPC::X1 && StackOffset == TOCSaveOffset)
3246 const unsigned Depth)
const {
3279 if (SrcReg == PPC::X3) {
3284 (--II)->getOpcode() == PPC::ADJCALLSTACKUP) {
3343 if (Depth >= MAX_DEPTH)
3348 unsigned E = 3,
D = 1;
3354 for (
unsigned I = 1;
I !=
E;
I +=
D) {
3374 if (Depth >= MAX_DEPTH)
3388 if (!MISrc1 || !MISrc2)
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
void replaceInstrWithLI(MachineInstr &MI, const LoadImmediateInfo &LII) const
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
instr_iterator instr_begin()
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
bool isCoalescableExtInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned &SubIdx) const override
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
bool isCall(QueryType Type=AnyInBundle) const
int getNonRecordFormOpcode(uint16_t)
MachineBasicBlock * getMBB() const
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
Compute iterated dominance frontiers using a linear time algorithm.
uint64_t ZeroIsSpecialNew
iterator begin() const
begin/end - Return all of the registers in this class.
bool isPPC64() const
isPPC64 - Return true if we are generating code for 64-bit pointer mode.
Carry-setting nodes for multiple precision addition and subtraction.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static int getRecordFormOpcode(unsigned Opcode)
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getSubReg() const
static cl::opt< bool > DisableCmpOpt("disable-ppc-cmp-opt", cl::desc("Disable compare instruction optimization"), cl::Hidden)
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
bool isPseudo() const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction...
CHAIN,FLAG = BCTRL(CHAIN, INFLAG) - Directly corresponds to a BCTRL instruction.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool instrHasImmForm(const MachineInstr &MI, ImmInstrInfo &III) const
bool isSignExtended(const MachineInstr &MI, const unsigned depth=0) const
Return true if the output of the instruction is always a sign-extended, i.e.
return AArch64::GPR64RegClass contains(Reg)
ScheduleHazardRecognizer * CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const override
CreateTargetHazardRecognizer - Return the hazard recognizer to use for this target when scheduling th...
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)
MachineFunction & MF
Machine function.
bool isXFormMemOp(unsigned Opcode) const
bool isAssociativeAndCommutative(const MachineInstr &Inst) const override
PPCDispatchGroupSBHazardRecognizer - This class implements a scoreboard-based hazard recognizer for P...
A description of a memory reference used in the backend.
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &Mask, int &Value) const override
PPCFunctionInfo - This class is derived from MachineFunction private PowerPC target-specific informat...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const TargetRegisterClass * updatedRC(const TargetRegisterClass *RC) const
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AliasAnalysis *AA) const override
uint64_t ZeroIsSpecialOrig
const char * getSymbolName() const
static bool isZeroExtendingOp(const MachineInstr &MI)
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.
INLINEASM - Represents an inline asm block.
static void swapMIOperands(MachineInstr &MI, unsigned Op1, unsigned Op2)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
bool isTOCSaveMI(const MachineInstr &MI) const
defusechain_iterator - This class provides iterator support for machine operands in the function that...
PPCInstrInfo(PPCSubtarget &STI)
int64_t getSExtValue() const
Get sign extended value.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
CHAIN = BDNZ CHAIN, DESTBB - These are used to create counter-based loops.
R32 = MFOCRF(CRREG, INFLAG) - Represents the MFOCRF instruction.
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int Mask, int Value, const MachineRegisterInfo *MRI) const override
MO_NLP_HIDDEN_FLAG - If this bit is set, the symbol reference is to a symbol with hidden visibility...
virtual bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
CHAIN = STXVD2X CHAIN, VSRC, Ptr - Occurs only for little endian.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Itinerary data supplied by a subtarget to be used by a target.
const PPCTargetMachine & getTargetMachine() const
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
AttributeList getAttributes() const
Return the attribute list for this Function.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
Instances of this class represent a single low-level machine instruction.
unsigned getKillRegState(bool B)
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
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...
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
unsigned getDeadRegState(bool B)
VSRC, CHAIN = LXVD2X_LE CHAIN, Ptr - Occurs only for little endian.
const BasicBlock & getEntryBlock() const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
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.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
bool isSignOrZeroExtended(const MachineInstr &MI, bool SignExt, const unsigned PhiDepth) const
Type * getReturnType() const
Returns the type of the ret val.
const MCPhysReg * getImplicitDefs() const
Return a list of registers that are potentially written by any instance of this machine instruction...
unsigned UnsafeFPMath
UnsafeFPMath - This flag is enabled when the -enable-unsafe-fp-math flag is specified on the command ...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static unsigned selectReg(int64_t Imm1, int64_t Imm2, unsigned CompareOpc, unsigned TrueReg, unsigned FalseReg, unsigned CRSubReg)
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
unsigned const MachineRegisterInfo * MRI
bool isLiveInSExt(unsigned VReg) const
This function returns true if the specified vreg is a live-in register and sign-extended.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
int getAltVSXFMAOpcode(uint16_t Opcode)
Simple binary floating point operators.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
void clearRegisterDeads(unsigned Reg)
Clear all dead flags on operands defining register Reg.
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
MO_NLP_FLAG - If this bit is set, the symbol reference is actually to the non_lazy_ptr for the global...
const GlobalValue * getGlobal() const
static ManagedStatic< OptionRegistry > OR
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
const MCPhysReg * ImplicitDefs
STFIWX - The STFIWX instruction.
use_instr_iterator use_instr_begin(unsigned RegNo) const
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.
GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point load which sign-extends from a 32-bit inte...
MI-level patchpoint operands.
Class to represent integer types.
PPCHazardRecognizer970 - This class defines a finite state automata that models the dispatch logic on...
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
Commutes the operands in the given instruction.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
unsigned getStoreOpcodeForSpill(unsigned Reg, const TargetRegisterClass *RC=nullptr) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
unsigned getPredicateHint(Predicate Opcode)
Return the hint bits of the predicate.
unsigned getDarwinDirective() const
getDarwinDirective - Returns the -m directive specified for the cpu.
static unsigned getCRFromCRBit(unsigned SrcReg)
MO_TLS - Indicates that the operand being accessed is some kind of thread-local symbol.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
void setIsKill(bool Val=true)
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
addFrameReference - This function is used to add a reference to the base of an abstract object on the...
The next are not flags but distinct values.
The memory access writes data.
static bool MBBDefinesCTR(MachineBasicBlock &MBB)
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specific constraint if it is set.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given stackmap should emit.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
Iterator for intrusive lists based on ilist_node.
void setOpcode(unsigned Op)
bool isUnpredicatedTerminator(const MachineInstr &MI) const override
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
void getNoop(MCInst &NopInst) const override
Return the noop instruction to use for a noop.
static unsigned getCRBitValue(unsigned CRBit)
MachineOperand class - Representation of each machine instruction operand.
MachineInstrBuilder MachineInstrBuilder & DefMI
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
static cl::opt< bool > VSXSelfCopyCrash("crash-on-ppc-vsx-self-copy", cl::desc("Causes the backend to crash instead of generating a nop VSX copy"), cl::Hidden)
static cl::opt< bool > UseOldLatencyCalc("ppc-old-latency-calc", cl::Hidden, cl::desc("Use the old (incorrect) instruction latency calculation"))
APInt rotl(unsigned rotateAmt) const
Rotate left by rotateAmt.
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const override
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
bool SubsumesPredicate(ArrayRef< MachineOperand > Pred1, ArrayRef< MachineOperand > Pred2) const override
bool DefinesPredicate(MachineInstr &MI, std::vector< MachineOperand > &Pred) const override
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
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.
virtual bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
Returns true iff the routine could find two commutable operands in the given machine instruction...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
Class for arbitrary precision integers.
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
QVGPCI = This corresponds to the QPX qvgpci instruction.
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.
bool use_empty(unsigned RegNo) const
use_empty - Return true if there are no instructions using the specified register.
On a symbol operand, this represents the lo part.
const MCPhysReg * iterator
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &P) const override
Return true when there is potentially a faster code sequence for an instruction chain ending in <Root...
bool isPredicated(const MachineInstr &MI) const override
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isLiveIn(unsigned Reg) const
Representation of each machine instruction.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Predicate InvertPredicate(Predicate Opcode)
Invert the specified predicate. != -> ==, < -> >=.
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Bitwise operators - logical and, logical or, logical xor.
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const override
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...
bool hasOneUse(unsigned RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MI-level stackmap operands.
unsigned getMatchingSuperReg(unsigned Reg, unsigned SubIdx, const TargetRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg...
static bool isSignExtendingOp(const MachineInstr &MI)
void setReg(unsigned Reg)
Change the register this operand corresponds to.
static MachineOperand CreateImm(int64_t Val)
unsigned getLoadOpcodeForSpill(unsigned Reg, const TargetRegisterClass *RC=nullptr) const
void setSubReg(unsigned subReg)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
const TargetInstrInfo * TII
Target instruction information.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
constexpr bool isUInt< 16 >(uint64_t x)
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
iterator_range< use_instr_iterator > use_instructions(unsigned Reg) const
uint64_t ImmMustBeMultipleOf
unsigned getPredicateCondition(Predicate Opcode)
Return the condition without hint bits.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
int getOperandLatency(const InstrItineraryData *ItinData, const MachineInstr &DefMI, unsigned DefIdx, const MachineInstr &UseMI, unsigned UseIdx) const override
bool isLiveInZExt(unsigned VReg) const
This function returns true if the specified vreg is a live-in register and zero-extended.
LLVM Value Representation.
static use_instr_iterator use_instr_end()
const MCOperandInfo * OpInfo
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.
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
CreateTargetPostRAHazardRecognizer - Return the postRA hazard recognizer to use for this target when ...
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
bool isPredicable(const MachineInstr &MI) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
This holds information about one operand of a machine instruction, indicating the register class for ...
const MachineOperand & getOperand(unsigned i) const
On a symbol operand "FOO", this indicates that the reference is actually to "FOO@plt".
const PPCRegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
virtual unsigned lookThruCopyLike(unsigned SrcReg, const MachineRegisterInfo *MRI) const
Returns the original SrcReg unless it is the target of a copy-like operation, in which case we chain ...
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
static cl::opt< bool > DisableCTRLoopAnal("disable-ppc-ctrloop-analysis", cl::Hidden, cl::desc("Disable analysis for CTR loops"))
Instructions::const_iterator const_instr_iterator
GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point load which zero-extends from a 32-bit inte...
MO_PIC_FLAG - If this bit is set, the symbol reference is relative to the function's picbase...
bool convertToImmediateForm(MachineInstr &MI, MachineInstr **KilledDef=nullptr) const
static bool isAnImmediateOperand(const MachineOperand &MO)
bool expandPostRAPseudo(MachineInstr &MI) const override
bool empty() const
empty - Check if the array is empty.
const MCPhysReg * ImplicitUses
bool expandVSXMemPseudo(MachineInstr &MI) const
bool isZeroExtended(const MachineInstr &MI, const unsigned depth=0) const
Return true if the output of the instruction is always zero-extended, i.e.
Predicate getSwappedPredicate(Predicate Opcode)
Assume the condition register is set by MI(a,b), return the predicate if we modify the instructions s...