42 #define DEBUG_TYPE "ppc-instr-info" 44 #define GET_INSTRMAP_INFO 45 #define GET_INSTRINFO_CTOR_DTOR 46 #include "PPCGenInstrInfo.inc" 49 "Number of spillvsrrc spilled to stack as vec");
51 "Number of spillvsrrc spilled to stack as gpr");
52 STATISTIC(NumGPRtoVSRSpill,
"Number of gpr spills to spillvsrrc");
54 "Number of ISELs that depend on comparison of constants converted");
55 STATISTIC(MissedConvertibleImmediateInstrs,
56 "Number of compare-immediate instructions fed by constants");
58 "Number of record-form rotates converted to record-form andi");
62 cl::desc(
"Disable analysis for CTR loops"));
68 cl::desc(
"Causes the backend to crash instead of generating a nop VSX copy"),
73 cl::desc(
"Use the old (incorrect) instruction latency calculation"));
97 void PPCInstrInfo::anchor() {}
102 STI.isPPC64() ? PPC::BLR8 : PPC::BLR),
103 Subtarget(STI), RI(STI.getTargetMachine()) {}
111 static_cast<const PPCSubtarget *
>(STI)->getCPUDirective();
115 static_cast<const PPCSubtarget *
>(STI)->getInstrItineraryData();
147 unsigned *PredCost)
const {
149 return PPCGenInstrInfo::getInstrLatency(ItinData, MI, PredCost);
169 Latency =
std::max(Latency, (
unsigned) Cycle);
178 unsigned UseIdx)
const {
179 int Latency = PPCGenInstrInfo::getOperandLatency(ItinData, DefMI, DefIdx,
195 IsRegCR = PPC::CRRCRegClass.contains(Reg) ||
196 PPC::CRBITRCRegClass.contains(Reg);
284 unsigned &SrcReg,
unsigned &DstReg,
285 unsigned &SubIdx)
const {
287 default:
return false;
290 case PPC::EXTSW_32_64:
293 SubIdx = PPC::sub_32;
301 const unsigned *OpcodesForSpill = getLoadOpcodesForSpillArray();
304 if (End !=
std::find(OpcodesForSpill, End, Opcode)) {
331 case PPC::ADDIStocHA:
332 case PPC::ADDIStocHA8:
334 case PPC::LOAD_STACK_GUARD:
338 case PPC::XXLEQVOnes:
342 case PPC::V_SETALLONESB:
343 case PPC::V_SETALLONESH:
344 case PPC::V_SETALLONES:
355 const unsigned *OpcodesForSpill = getStoreOpcodesForSpillArray();
358 if (End !=
std::find(OpcodesForSpill, End, Opcode)) {
370 unsigned OpIdx2)
const {
393 assert(((OpIdx1 == 1 && OpIdx2 == 2) || (OpIdx1 == 2 && OpIdx2 == 1)) &&
394 "Only the operands 1 and 2 can be swapped in RLSIMI/RLWIMI_rec.");
402 bool ChangeReg0 =
false;
408 "Expecting a two-address instruction!");
420 if (MB == 0 && ME == 31)
431 .addImm((ME + 1) & 31)
432 .addImm((MB - 1) & 31);
454 unsigned &SrcOpIdx2)
const {
465 return fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2, 2, 3);
475 default: Opcode = PPC::NOP;
break;
484 BuildMI(MBB, MI, DL,
get(Opcode));
499 bool AllowModify)
const {
500 bool isPPC64 = Subtarget.
isPPC64();
513 if (I->getOpcode() ==
PPC::B &&
515 I->eraseFromParent();
534 }
else if (LastInst.
getOpcode() == PPC::BCC) {
542 }
else if (LastInst.
getOpcode() == PPC::BC) {
550 }
else if (LastInst.
getOpcode() == PPC::BCn) {
558 }
else if (LastInst.
getOpcode() == PPC::BDNZ8 ||
569 }
else if (LastInst.
getOpcode() == PPC::BDZ8 ||
594 if (SecondLastInst.
getOpcode() == PPC::BCC &&
604 }
else if (SecondLastInst.
getOpcode() == PPC::BC &&
614 }
else if (SecondLastInst.
getOpcode() == PPC::BCn &&
624 }
else if ((SecondLastInst.
getOpcode() == PPC::BDNZ8 ||
638 }
else if ((SecondLastInst.
getOpcode() == PPC::BDZ8 ||
662 I->eraseFromParent();
671 int *BytesRemoved)
const {
672 assert(!BytesRemoved &&
"code size not handled");
678 if (I->getOpcode() !=
PPC::B && I->getOpcode() != PPC::BCC &&
679 I->getOpcode() != PPC::BC && I->getOpcode() != PPC::BCn &&
680 I->getOpcode() != PPC::BDNZ8 && I->getOpcode() !=
PPC::BDNZ &&
681 I->getOpcode() != PPC::BDZ8 && I->getOpcode() !=
PPC::BDZ)
685 I->eraseFromParent();
689 if (I == MBB.
begin())
return 1;
691 if (I->getOpcode() != PPC::BCC &&
692 I->getOpcode() != PPC::BC && I->getOpcode() != PPC::BCn &&
693 I->getOpcode() != PPC::BDNZ8 && I->getOpcode() !=
PPC::BDNZ &&
694 I->getOpcode() != PPC::BDZ8 && I->getOpcode() !=
PPC::BDZ)
698 I->eraseFromParent();
707 int *BytesAdded)
const {
709 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
711 "PPC branch conditions have two components!");
712 assert(!BytesAdded &&
"code size not handled");
714 bool isPPC64 = Subtarget.
isPPC64();
720 else if (Cond[1].
getReg() == PPC::CTR || Cond[1].getReg() == PPC::CTR8)
721 BuildMI(&MBB, DL,
get(Cond[0].getImm() ?
723 (isPPC64 ? PPC::BDZ8 :
PPC::BDZ))).addMBB(TBB);
725 BuildMI(&MBB, DL,
get(PPC::BC)).
add(Cond[1]).addMBB(TBB);
729 BuildMI(&MBB, DL,
get(PPC::BCC))
737 if (Cond[1].
getReg() == PPC::CTR || Cond[1].
getReg() == PPC::CTR8)
738 BuildMI(&MBB, DL,
get(Cond[0].getImm() ?
746 BuildMI(&MBB, DL,
get(PPC::BCC))
757 unsigned TrueReg,
unsigned FalseReg,
758 int &CondCycles,
int &TrueCycles,
int &FalseCycles)
const {
759 if (Cond.
size() != 2)
764 if (Cond[1].
getReg() == PPC::CTR || Cond[1].getReg() == PPC::CTR8)
775 if (!PPC::GPRCRegClass.hasSubClassEq(RC) &&
776 !PPC::GPRC_NOR0RegClass.hasSubClassEq(RC) &&
777 !PPC::G8RCRegClass.hasSubClassEq(RC) &&
778 !PPC::G8RC_NOX0RegClass.hasSubClassEq(RC))
794 const DebugLoc &dl,
unsigned DestReg,
796 unsigned FalseReg)
const {
798 "PPC branch conditions have two components!");
803 RI.getCommonSubClass(MRI.getRegClass(TrueReg), MRI.getRegClass(FalseReg));
804 assert(RC &&
"TrueReg and FalseReg must have overlapping register classes");
806 bool Is64Bit = PPC::G8RCRegClass.hasSubClassEq(RC) ||
807 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC);
809 PPC::GPRCRegClass.hasSubClassEq(RC) ||
810 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) &&
811 "isel is for regular integer GPRs only");
813 unsigned OpCode = Is64Bit ? PPC::ISEL8 : PPC::ISEL;
817 bool SwapOps =
false;
818 switch (SelectPred) {
822 SubIdx = PPC::sub_eq; SwapOps =
false;
break;
826 SubIdx = PPC::sub_eq; SwapOps =
true;
break;
830 SubIdx = PPC::sub_lt; SwapOps =
false;
break;
834 SubIdx = PPC::sub_lt; SwapOps =
true;
break;
838 SubIdx = PPC::sub_gt; SwapOps =
false;
break;
842 SubIdx = PPC::sub_gt; SwapOps =
true;
break;
846 SubIdx = PPC::sub_un; SwapOps =
false;
break;
850 SubIdx = PPC::sub_un; SwapOps =
true;
break;
855 unsigned FirstReg = SwapOps ? FalseReg : TrueReg,
856 SecondReg = SwapOps ? TrueReg : FalseReg;
861 if (MRI.getRegClass(FirstReg)->contains(PPC::R0) ||
862 MRI.getRegClass(FirstReg)->contains(PPC::X0)) {
864 MRI.getRegClass(FirstReg)->
contains(PPC::X0) ?
865 &PPC::G8RC_NOX0RegClass : &PPC::GPRC_NOR0RegClass;
866 unsigned OldFirstReg = FirstReg;
867 FirstReg = MRI.createVirtualRegister(FirstRC);
868 BuildMI(MBB, MI, dl,
get(TargetOpcode::COPY), FirstReg)
872 BuildMI(MBB, MI, dl,
get(OpCode), DestReg)
879 if (CRBit == PPC::CR0LT || CRBit == PPC::CR1LT ||
880 CRBit == PPC::CR2LT || CRBit == PPC::CR3LT ||
881 CRBit == PPC::CR4LT || CRBit == PPC::CR5LT ||
882 CRBit == PPC::CR6LT || CRBit == PPC::CR7LT)
884 if (CRBit == PPC::CR0GT || CRBit == PPC::CR1GT ||
885 CRBit == PPC::CR2GT || CRBit == PPC::CR3GT ||
886 CRBit == PPC::CR4GT || CRBit == PPC::CR5GT ||
887 CRBit == PPC::CR6GT || CRBit == PPC::CR7GT)
889 if (CRBit == PPC::CR0EQ || CRBit == PPC::CR1EQ ||
890 CRBit == PPC::CR2EQ || CRBit == PPC::CR3EQ ||
891 CRBit == PPC::CR4EQ || CRBit == PPC::CR5EQ ||
892 CRBit == PPC::CR6EQ || CRBit == PPC::CR7EQ)
894 if (CRBit == PPC::CR0UN || CRBit == PPC::CR1UN ||
895 CRBit == PPC::CR2UN || CRBit == PPC::CR3UN ||
896 CRBit == PPC::CR4UN || CRBit == PPC::CR5UN ||
897 CRBit == PPC::CR6UN || CRBit == PPC::CR7UN)
900 assert(Ret != 4 &&
"Invalid CR bit register");
911 if (PPC::F8RCRegClass.
contains(DestReg) &&
912 PPC::VSRCRegClass.
contains(SrcReg)) {
920 }
else if (PPC::F8RCRegClass.
contains(SrcReg) &&
921 PPC::VSRCRegClass.
contains(DestReg)) {
932 if (PPC::CRBITRCRegClass.
contains(SrcReg) &&
933 PPC::GPRCRegClass.
contains(DestReg)) {
939 BuildMI(MBB, I, DL,
get(PPC::RLWINM), DestReg)
945 }
else if (PPC::CRRCRegClass.
contains(SrcReg) &&
946 PPC::G8RCRegClass.
contains(DestReg)) {
947 BuildMI(MBB, I, DL,
get(PPC::MFOCRF8), DestReg).
addReg(SrcReg);
950 }
else if (PPC::CRRCRegClass.
contains(SrcReg) &&
951 PPC::GPRCRegClass.
contains(DestReg)) {
955 }
else if (PPC::G8RCRegClass.
contains(SrcReg) &&
956 PPC::VSFRCRegClass.
contains(DestReg)) {
958 "Subtarget doesn't support directmove, don't know how to copy.");
959 BuildMI(MBB, I, DL,
get(PPC::MTVSRD), DestReg).
addReg(SrcReg);
963 }
else if (PPC::VSFRCRegClass.
contains(SrcReg) &&
964 PPC::G8RCRegClass.
contains(DestReg)) {
966 "Subtarget doesn't support directmove, don't know how to copy.");
967 BuildMI(MBB, I, DL,
get(PPC::MFVSRD), DestReg).
addReg(SrcReg);
970 }
else if (PPC::SPERCRegClass.
contains(SrcReg) &&
971 PPC::GPRCRegClass.
contains(DestReg)) {
972 BuildMI(MBB, I, DL,
get(PPC::EFSCFD), DestReg).
addReg(SrcReg);
975 }
else if (PPC::GPRCRegClass.
contains(SrcReg) &&
976 PPC::SPERCRegClass.
contains(DestReg)) {
977 BuildMI(MBB, I, DL,
get(PPC::EFDCFS), DestReg).
addReg(SrcReg);
983 if (PPC::GPRCRegClass.
contains(DestReg, SrcReg))
985 else if (PPC::G8RCRegClass.
contains(DestReg, SrcReg))
987 else if (PPC::F4RCRegClass.
contains(DestReg, SrcReg))
989 else if (PPC::CRRCRegClass.
contains(DestReg, SrcReg))
991 else if (PPC::VRRCRegClass.
contains(DestReg, SrcReg))
993 else if (PPC::VSRCRegClass.
contains(DestReg, SrcReg))
1003 else if (PPC::VSFRCRegClass.
contains(DestReg, SrcReg) ||
1004 PPC::VSSRCRegClass.
contains(DestReg, SrcReg))
1005 Opc = (Subtarget.
hasP9Vector()) ? PPC::XSCPSGNDP : PPC::XXLORf;
1006 else if (PPC::QFRCRegClass.
contains(DestReg, SrcReg))
1008 else if (PPC::QSRCRegClass.
contains(DestReg, SrcReg))
1010 else if (PPC::QBRCRegClass.
contains(DestReg, SrcReg))
1012 else if (PPC::CRBITRCRegClass.
contains(DestReg, SrcReg))
1014 else if (PPC::SPERCRegClass.
contains(DestReg, SrcReg))
1021 BuildMI(MBB, I, DL, MCID, DestReg)
1030 const unsigned *OpcodesForSpill = getStoreOpcodesForSpillArray();
1033 if (RC !=
nullptr) {
1034 if (PPC::GPRCRegClass.hasSubClassEq(RC) ||
1035 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) {
1037 }
else if (PPC::G8RCRegClass.hasSubClassEq(RC) ||
1038 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC)) {
1040 }
else if (PPC::F8RCRegClass.hasSubClassEq(RC)) {
1042 }
else if (PPC::F4RCRegClass.hasSubClassEq(RC)) {
1044 }
else if (PPC::SPERCRegClass.hasSubClassEq(RC)) {
1046 }
else if (PPC::CRRCRegClass.hasSubClassEq(RC)) {
1048 }
else if (PPC::CRBITRCRegClass.hasSubClassEq(RC)) {
1050 }
else if (PPC::VRRCRegClass.hasSubClassEq(RC)) {
1052 }
else if (PPC::VSRCRegClass.hasSubClassEq(RC)) {
1054 }
else if (PPC::VSFRCRegClass.hasSubClassEq(RC)) {
1056 }
else if (PPC::VSSRCRegClass.hasSubClassEq(RC)) {
1058 }
else if (PPC::VRSAVERCRegClass.hasSubClassEq(RC)) {
1060 }
else if (PPC::QFRCRegClass.hasSubClassEq(RC)) {
1062 }
else if (PPC::QSRCRegClass.hasSubClassEq(RC)) {
1064 }
else if (PPC::QBRCRegClass.hasSubClassEq(RC)) {
1066 }
else if (PPC::SPILLTOVSRRCRegClass.hasSubClassEq(RC)) {
1072 if (PPC::GPRCRegClass.
contains(Reg) ||
1073 PPC::GPRC_NOR0RegClass.
contains(Reg)) {
1075 }
else if (PPC::G8RCRegClass.
contains(Reg) ||
1076 PPC::G8RC_NOX0RegClass.
contains(Reg)) {
1078 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1080 }
else if (PPC::F4RCRegClass.
contains(Reg)) {
1082 }
else if (PPC::SPERCRegClass.
contains(Reg)) {
1084 }
else if (PPC::CRRCRegClass.
contains(Reg)) {
1086 }
else if (PPC::CRBITRCRegClass.
contains(Reg)) {
1088 }
else if (PPC::VRRCRegClass.
contains(Reg)) {
1090 }
else if (PPC::VSRCRegClass.
contains(Reg)) {
1092 }
else if (PPC::VSFRCRegClass.
contains(Reg)) {
1094 }
else if (PPC::VSSRCRegClass.
contains(Reg)) {
1096 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1098 }
else if (PPC::QFRCRegClass.
contains(Reg)) {
1100 }
else if (PPC::QSRCRegClass.
contains(Reg)) {
1102 }
else if (PPC::QBRCRegClass.
contains(Reg)) {
1104 }
else if (PPC::SPILLTOVSRRCRegClass.
contains(Reg)) {
1116 const unsigned *OpcodesForSpill = getLoadOpcodesForSpillArray();
1119 if (RC !=
nullptr) {
1120 if (PPC::GPRCRegClass.hasSubClassEq(RC) ||
1121 PPC::GPRC_NOR0RegClass.hasSubClassEq(RC)) {
1123 }
else if (PPC::G8RCRegClass.hasSubClassEq(RC) ||
1124 PPC::G8RC_NOX0RegClass.hasSubClassEq(RC)) {
1126 }
else if (PPC::F8RCRegClass.hasSubClassEq(RC)) {
1128 }
else if (PPC::F4RCRegClass.hasSubClassEq(RC)) {
1130 }
else if (PPC::SPERCRegClass.hasSubClassEq(RC)) {
1132 }
else if (PPC::CRRCRegClass.hasSubClassEq(RC)) {
1134 }
else if (PPC::CRBITRCRegClass.hasSubClassEq(RC)) {
1136 }
else if (PPC::VRRCRegClass.hasSubClassEq(RC)) {
1138 }
else if (PPC::VSRCRegClass.hasSubClassEq(RC)) {
1140 }
else if (PPC::VSFRCRegClass.hasSubClassEq(RC)) {
1142 }
else if (PPC::VSSRCRegClass.hasSubClassEq(RC)) {
1144 }
else if (PPC::VRSAVERCRegClass.hasSubClassEq(RC)) {
1146 }
else if (PPC::QFRCRegClass.hasSubClassEq(RC)) {
1148 }
else if (PPC::QSRCRegClass.hasSubClassEq(RC)) {
1150 }
else if (PPC::QBRCRegClass.hasSubClassEq(RC)) {
1152 }
else if (PPC::SPILLTOVSRRCRegClass.hasSubClassEq(RC)) {
1158 if (PPC::GPRCRegClass.
contains(Reg) ||
1159 PPC::GPRC_NOR0RegClass.
contains(Reg)) {
1161 }
else if (PPC::G8RCRegClass.
contains(Reg) ||
1162 PPC::G8RC_NOX0RegClass.
contains(Reg)) {
1164 }
else if (PPC::F8RCRegClass.
contains(Reg)) {
1166 }
else if (PPC::F4RCRegClass.
contains(Reg)) {
1168 }
else if (PPC::SPERCRegClass.
contains(Reg)) {
1170 }
else if (PPC::CRRCRegClass.
contains(Reg)) {
1172 }
else if (PPC::CRBITRCRegClass.
contains(Reg)) {
1174 }
else if (PPC::VRRCRegClass.
contains(Reg)) {
1176 }
else if (PPC::VSRCRegClass.
contains(Reg)) {
1178 }
else if (PPC::VSFRCRegClass.
contains(Reg)) {
1180 }
else if (PPC::VSSRCRegClass.
contains(Reg)) {
1182 }
else if (PPC::VRSAVERCRegClass.
contains(Reg)) {
1184 }
else if (PPC::QFRCRegClass.
contains(Reg)) {
1186 }
else if (PPC::QSRCRegClass.
contains(Reg)) {
1188 }
else if (PPC::QBRCRegClass.
contains(Reg)) {
1190 }
else if (PPC::SPILLTOVSRRCRegClass.
contains(Reg)) {
1199 void PPCInstrInfo::StoreRegToStackSlot(
1213 if (PPC::CRRCRegClass.hasSubClassEq(RC) ||
1214 PPC::CRBITRCRegClass.hasSubClassEq(RC))
1217 if (PPC::VRSAVERCRegClass.hasSubClassEq(RC))
1226 unsigned SrcReg,
bool isKill,
1242 StoreRegToStackSlot(MF, SrcReg, isKill, FrameIdx, RC, NewMIs);
1244 for (
unsigned i = 0,
e = NewMIs.
size(); i !=
e; ++i)
1245 MBB.
insert(MI, NewMIs[i]);
1252 NewMIs.
back()->addMemOperand(MF, MMO);
1256 unsigned DestReg,
int FrameIdx,
1265 if (PPC::CRRCRegClass.hasSubClassEq(RC) ||
1266 PPC::CRBITRCRegClass.hasSubClassEq(RC))
1269 if (PPC::VRSAVERCRegClass.hasSubClassEq(RC))
1279 unsigned DestReg,
int FrameIdx,
1285 if (MI != MBB.
end()) DL = MI->getDebugLoc();
1297 if (Subtarget.
hasVSX() && RC == &PPC::VRRCRegClass)
1298 RC = &PPC::VSRCRegClass;
1300 LoadRegFromStackSlot(MF, DL, DestReg, FrameIdx, RC, NewMIs);
1302 for (
unsigned i = 0,
e = NewMIs.
size(); i !=
e; ++i)
1303 MBB.
insert(MI, NewMIs[i]);
1310 NewMIs.
back()->addMemOperand(MF, MMO);
1315 assert(Cond.
size() == 2 &&
"Invalid PPC branch opcode!");
1316 if (Cond[1].
getReg() == PPC::CTR8 || Cond[1].getReg() == PPC::CTR)
1317 Cond[0].setImm(Cond[0].getImm() == 0 ? 1 : 0);
1329 if (DefOpc != PPC::LI && DefOpc != PPC::LI8)
1359 if (UseInfo->isLookupPtrRegClass()) {
1360 if (UseInfo->RegClass != 1)
1363 if (UseInfo->RegClass != PPC::GPRC_NOR0RegClassID &&
1364 UseInfo->RegClass != PPC::G8RC_NOX0RegClassID)
1371 if (UseInfo->Constraints != 0)
1375 if (UseInfo->isLookupPtrRegClass()) {
1376 bool isPPC64 = Subtarget.
isPPC64();
1377 ZeroReg = isPPC64 ? PPC::ZERO8 : PPC::ZERO;
1379 ZeroReg = UseInfo->RegClass == PPC::G8RC_NOX0RegClassID ?
1380 PPC::ZERO8 : PPC::ZERO;
1395 if (
I->definesRegister(PPC::CTR) ||
I->definesRegister(PPC::CTR8))
1407 unsigned NumT,
unsigned ExtraT,
1409 unsigned NumF,
unsigned ExtraF,
1440 if (OpC == PPC::BLR || OpC == PPC::BLR8) {
1441 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR) {
1442 bool isPPC64 = Subtarget.
isPPC64();
1443 MI.
setDesc(
get(Pred[0].getImm() ? (isPPC64 ? PPC::BDNZLR8 : PPC::BDNZLR)
1444 : (isPPC64 ? PPC::BDZLR8 : PPC::BDZLR)));
1454 .addImm(Pred[0].getImm())
1459 }
else if (OpC ==
PPC::B) {
1460 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR) {
1461 bool isPPC64 = Subtarget.
isPPC64();
1463 : (isPPC64 ? PPC::BDZ8 :
PPC::BDZ)));
1486 .addImm(Pred[0].getImm())
1492 }
else if (OpC == PPC::BCTR || OpC == PPC::BCTR8 || OpC ==
PPC::BCTRL ||
1493 OpC == PPC::BCTRL8) {
1494 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR)
1497 bool setLR = OpC ==
PPC::BCTRL || OpC == PPC::BCTRL8;
1498 bool isPPC64 = Subtarget.
isPPC64();
1501 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8 : PPC::BCCTR8)
1502 : (setLR ? PPC::BCCTRL : PPC::BCCTR)));
1506 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8n : PPC::BCCTR8n)
1507 : (setLR ? PPC::BCCTRLn : PPC::BCCTRn)));
1512 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCCTRL8 : PPC::BCCCTR8)
1513 : (setLR ? PPC::BCCCTRL : PPC::BCCCTR)));
1515 .addImm(Pred[0].getImm())
1525 assert(Pred1.
size() == 2 &&
"Invalid PPC first predicate");
1526 assert(Pred2.
size() == 2 &&
"Invalid PPC second predicate");
1528 if (Pred1[1].
getReg() == PPC::CTR8 || Pred1[1].getReg() == PPC::CTR)
1530 if (Pred2[1].
getReg() == PPC::CTR8 || Pred2[1].getReg() == PPC::CTR)
1534 if (Pred1[1].
getReg() != Pred2[1].getReg())
1555 std::vector<MachineOperand> &Pred)
const {
1563 { &PPC::CRRCRegClass, &PPC::CRBITRCRegClass,
1564 &PPC::CTRRCRegClass, &PPC::CTRRC8RegClass };
1591 unsigned &SrcReg2,
int &
Mask,
1596 default:
return false;
1631 if (OpC == PPC::FCMPUS || OpC == PPC::FCMPUD)
1643 bool isPPC64 = Subtarget.
isPPC64();
1644 bool is32BitSignedCompare = OpC == PPC::CMPWI || OpC == PPC::CMPW;
1645 bool is32BitUnsignedCompare = OpC == PPC::CMPLWI || OpC == PPC::CMPLW;
1646 bool is64BitUnsignedCompare = OpC == PPC::CMPLDI || OpC == PPC::CMPLD;
1655 if (!MI)
return false;
1657 bool equalityOnly =
false;
1660 if (is32BitSignedCompare) {
1666 }
else if (is32BitUnsignedCompare) {
1671 equalityOnly =
true;
1675 equalityOnly = is64BitUnsignedCompare;
1677 equalityOnly = is32BitUnsignedCompare;
1692 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1695 if (SubIdx != PPC::sub_eq)
1707 bool FoundUse =
false;
1736 else if (Value != 0) {
1745 if (equalityOnly || !MRI->
hasOneUse(CRReg))
1755 int16_t Immed = (int16_t)Value;
1784 for (; I != E && !noSub; --
I) {
1798 if ((OpC == PPC::CMPW || OpC == PPC::CMPLW ||
1799 OpC == PPC::CMPD || OpC == PPC::CMPLD) &&
1800 (IOpC == PPC::SUBF || IOpC == PPC::SUBF8) &&
1823 if (MIOpC == PPC::ANDI_rec || MIOpC == PPC::ANDI8_rec ||
1824 MIOpC == PPC::ANDIS_rec || MIOpC == PPC::ANDIS8_rec)
1827 NewOpC = PPC::getRecordFormOpcode(MIOpC);
1847 bool ShouldSwap =
false;
1848 if (Sub && Value == 0) {
1854 ShouldSwap = !ShouldSwap;
1867 "Invalid predicate for equality-only optimization");
1871 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1874 assert((!equalityOnly || NewSubReg == PPC::sub_eq) &&
1875 "Invalid CR bit for equality-only optimization");
1877 if (NewSubReg == PPC::sub_lt)
1878 NewSubReg = PPC::sub_gt;
1879 else if (NewSubReg == PPC::sub_gt)
1880 NewSubReg = PPC::sub_lt;
1887 assert(!(Value != 0 && ShouldSwap) &&
1888 "Non-zero immediate support and ShouldSwap" 1889 "may conflict in updating predicate");
1898 get(TargetOpcode::COPY), CRReg)
1905 if (MIOpC != NewOpC) {
1915 if (MIOpC == PPC::RLWINM || MIOpC == PPC::RLWINM8) {
1922 bool MBInLoHWord = MB >= 16;
1923 bool MEInLoHWord = ME >= 16;
1924 uint64_t Mask = ~0LLU;
1926 if (MB <= ME && MBInLoHWord == MEInLoHWord && SH == 0) {
1927 Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
1929 Mask >>= MBInLoHWord ? 0 : 16;
1930 NewOpC = MIOpC == PPC::RLWINM
1931 ? (MBInLoHWord ? PPC::ANDI_rec : PPC::ANDIS_rec)
1932 : (MBInLoHWord ? PPC::ANDI8_rec : PPC::ANDIS8_rec);
1933 }
else if (MRI->
use_empty(GPRRes) && (ME == 31) &&
1934 (ME - MB + 1 == SH) && (MB >= 16)) {
1938 Mask = ((1LLU << 32) - 1) & ~((1LLU << (32 - SH)) - 1);
1940 NewOpC = MIOpC == PPC::RLWINM ? PPC::ANDIS_rec : PPC::ANDIS8_rec;
1943 if (Mask != ~0LLU) {
1947 NumRcRotatesConvertedToRcAnd++;
1952 uint64_t Mask = (1LLU << (63 - MB + 1)) - 1;
1953 NewOpC = PPC::ANDI8_rec;
1956 NumRcRotatesConvertedToRcAnd++;
1965 *ImpDefs; ++ImpDefs)
1971 *ImpUses; ++ImpUses)
1977 "Record-form instruction does not define cr0?");
1982 for (
unsigned i = 0,
e = PredsToUpdate.
size(); i <
e; i++)
1983 PredsToUpdate[i].
first->setImm(PredsToUpdate[i].second);
1985 for (
unsigned i = 0, e = SubRegsToUpdate.
size(); i <
e; i++)
1986 SubRegsToUpdate[i].
first->setSubReg(SubRegsToUpdate[i].second);
2001 }
else if (Opcode == TargetOpcode::STACKMAP) {
2004 }
else if (Opcode == TargetOpcode::PATCHPOINT) {
2008 return get(Opcode).getSize();
2012 std::pair<unsigned, unsigned>
2015 return std::make_pair(TF & Mask, TF & ~Mask);
2020 using namespace PPCII;
2021 static const std::pair<unsigned, const char *> TargetFlags[] = {
2035 using namespace PPCII;
2036 static const std::pair<unsigned, const char *> TargetFlags[] = {
2051 unsigned UpperOpcode, LowerOpcode;
2053 case PPC::DFLOADf32:
2054 UpperOpcode = PPC::LXSSP;
2055 LowerOpcode = PPC::LFS;
2057 case PPC::DFLOADf64:
2058 UpperOpcode = PPC::LXSD;
2059 LowerOpcode = PPC::LFD;
2061 case PPC::DFSTOREf32:
2062 UpperOpcode = PPC::STXSSP;
2063 LowerOpcode = PPC::STFS;
2065 case PPC::DFSTOREf64:
2066 UpperOpcode = PPC::STXSD;
2067 LowerOpcode = PPC::STFD;
2069 case PPC::XFLOADf32:
2070 UpperOpcode = PPC::LXSSPX;
2071 LowerOpcode = PPC::LFSX;
2073 case PPC::XFLOADf64:
2074 UpperOpcode = PPC::LXSDX;
2075 LowerOpcode = PPC::LFDX;
2077 case PPC::XFSTOREf32:
2078 UpperOpcode = PPC::STXSSPX;
2079 LowerOpcode = PPC::STFSX;
2081 case PPC::XFSTOREf64:
2082 UpperOpcode = PPC::STXSDX;
2083 LowerOpcode = PPC::STFDX;
2086 UpperOpcode = PPC::LXSIWAX;
2090 UpperOpcode = PPC::LXSIWZX;
2094 UpperOpcode = PPC::STXSIWX;
2103 if ((TargetReg >= PPC::F0 && TargetReg <= PPC::F31) ||
2104 (TargetReg >= PPC::VSL0 && TargetReg <= PPC::VSL31))
2105 Opcode = LowerOpcode;
2107 Opcode = UpperOpcode;
2121 case TargetOpcode::LOAD_STACK_GUARD: {
2122 assert(Subtarget.isTargetLinux() &&
2123 "Only Linux target is expected to contain LOAD_STACK_GUARD");
2124 const int64_t
Offset = Subtarget.isPPC64() ? -0x7010 : -0x7008;
2125 const unsigned Reg = Subtarget.isPPC64() ? PPC::X13 :
PPC::R2;
2132 case PPC::DFLOADf32:
2133 case PPC::DFLOADf64:
2134 case PPC::DFSTOREf32:
2135 case PPC::DFSTOREf64: {
2136 assert(Subtarget.hasP9Vector() &&
2137 "Invalid D-Form Pseudo-ops on Pre-P9 target.");
2140 "D-form op must have register and immediate operands");
2143 case PPC::XFLOADf32:
2144 case PPC::XFSTOREf32:
2148 assert(Subtarget.hasP8Vector() &&
2149 "Invalid X-Form Pseudo-ops on Pre-P8 target.");
2151 "X-form op must have register and register operands");
2154 case PPC::XFLOADf64:
2155 case PPC::XFSTOREf64: {
2156 assert(Subtarget.hasVSX() &&
2157 "Invalid X-Form Pseudo-ops on target that has no VSX.");
2159 "X-form op must have register and register operands");
2162 case PPC::SPILLTOVSR_LD: {
2164 if (PPC::VSFRCRegClass.
contains(TargetReg)) {
2165 MI.
setDesc(
get(PPC::DFLOADf64));
2172 case PPC::SPILLTOVSR_ST: {
2174 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2175 NumStoreSPILLVSRRCAsVec++;
2176 MI.
setDesc(
get(PPC::DFSTOREf64));
2179 NumStoreSPILLVSRRCAsGpr++;
2184 case PPC::SPILLTOVSR_LDX: {
2186 if (PPC::VSFRCRegClass.
contains(TargetReg))
2192 case PPC::SPILLTOVSR_STX: {
2194 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2195 NumStoreSPILLVSRRCAsVec++;
2198 NumStoreSPILLVSRRCAsGpr++;
2204 case PPC::CFENCE8: {
2207 BuildMI(MBB, MI, DL,
get(PPC::CTRL_DEP))
2223 static unsigned selectReg(int64_t Imm1, int64_t Imm2,
unsigned CompareOpc,
2224 unsigned TrueReg,
unsigned FalseReg,
2225 unsigned CRSubReg) {
2227 if (CompareOpc == PPC::CMPWI || CompareOpc == PPC::CMPDI) {
2231 return Imm1 < Imm2 ? TrueReg : FalseReg;
2233 return Imm1 > Imm2 ? TrueReg : FalseReg;
2235 return Imm1 == Imm2 ? TrueReg : FalseReg;
2239 else if (CompareOpc == PPC::CMPLWI || CompareOpc == PPC::CMPLDI) {
2243 return (uint64_t)Imm1 < (uint64_t)Imm2 ? TrueReg : FalseReg;
2245 return (uint64_t)Imm1 > (uint64_t)Imm2 ? TrueReg : FalseReg;
2247 return Imm1 == Imm2 ? TrueReg : FalseReg;
2250 return PPC::NoRegister;
2255 int64_t Imm)
const {
2268 if (UseOpIdx >= 0) {
2287 int OperandToKeep = LII.
SetCR ? 1 : 0;
2308 bool &SeenIntermediateUse)
const {
2310 "Should be called after register allocation.");
2314 SeenIntermediateUse =
false;
2315 for (; It !=
E; ++It) {
2316 if (It->modifiesRegister(Reg, TRI))
2318 if (It->readsRegister(Reg, TRI))
2319 SeenIntermediateUse =
true;
2326 unsigned &OpNoForForwarding,
2327 bool &SeenIntermediateUse)
const {
2328 OpNoForForwarding = ~0U;
2345 OpNoForForwarding = i;
2356 bool ConvertibleImmForm =
2357 Opc == PPC::CMPWI || Opc == PPC::CMPLWI || Opc == PPC::CMPDI ||
2358 Opc == PPC::CMPLDI || Opc == PPC::ADDI || Opc == PPC::ADDI8 ||
2359 Opc == PPC::ORI || Opc == PPC::ORI8 || Opc == PPC::XORI ||
2360 Opc == PPC::XORI8 || Opc == PPC::RLDICL || Opc == PPC::RLDICL_rec ||
2361 Opc == PPC::RLDICL_32 || Opc == PPC::RLDICL_32_64 ||
2362 Opc == PPC::RLWINM || Opc == PPC::RLWINM_rec || Opc == PPC::RLWINM8 ||
2363 Opc == PPC::RLWINM8_rec;
2371 if ((Opc ==
PPC::OR || Opc == PPC::OR8) &&
2376 SeenIntermediateUse =
false;
2393 OpNoForForwarding = i;
2400 return OpNoForForwarding == ~0U ? nullptr :
DefMI;
2403 const unsigned *PPCInstrInfo::getStoreOpcodesForSpillArray()
const {
2406 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2407 PPC::SPILL_CRBIT, PPC::STVX,
PPC::STXVD2X, PPC::STXSDX, PPC::STXSSPX,
2408 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2409 PPC::SPILLTOVSR_ST, PPC::EVSTDD},
2411 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2412 PPC::SPILL_CRBIT, PPC::STVX, PPC::STXV, PPC::DFSTOREf64, PPC::DFSTOREf32,
2413 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2414 PPC::SPILLTOVSR_ST}};
2416 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2419 const unsigned *PPCInstrInfo::getLoadOpcodesForSpillArray()
const {
2422 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2423 PPC::RESTORE_CRBIT, PPC::LVX,
PPC::LXVD2X, PPC::LXSDX, PPC::LXSSPX,
2424 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2425 PPC::SPILLTOVSR_LD, PPC::EVLDD},
2427 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2428 PPC::RESTORE_CRBIT, PPC::LVX, PPC::LXV, PPC::DFLOADf64, PPC::DFLOADf32,
2429 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2430 PPC::SPILLTOVSR_LD}};
2432 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2436 unsigned RegNo)
const {
2444 "Instructions are not in same basic block");
2446 bool IsKillSet =
false;
2459 if (UseIndex != -1) {
2467 clearOperandKillInfo(EndMI, i);
2476 for (; It !=
E; ++It) {
2478 if (It->isDebugInstr() || It->isPosition())
2484 for (
int i = 0,
e = It->getNumOperands(); i !=
e; ++i)
2485 clearOperandKillInfo(*It, i);
2490 if ((MO = It->findRegisterUseOperand(RegNo,
false, &
getRegisterInfo()))) {
2495 }
else if ((MO = It->findRegisterDefOperand(RegNo,
false,
true,
2498 assert(&*It == &StartMI &&
"No new def between StartMI and EndMI.");
2504 if ((&*It) == &StartMI)
2509 "RegNo should be killed or dead");
2539 bool PostRA = !MRI->
isSSA();
2545 unsigned ToBeDeletedReg = 0;
2546 int64_t OffsetImm = 0;
2547 unsigned XFormOpcode = 0;
2555 bool OtherIntermediateUse =
false;
2559 if (OtherIntermediateUse || !ADDMI)
2566 unsigned ScaleRegIdx = 0;
2567 int64_t OffsetAddi = 0;
2581 assert(ADDIMI &&
"There should be ADDIMI for valid ToBeChangedReg.");
2586 for (
auto It = ++Start; It != End; It++)
2593 if (NewDefFor(ToBeChangedReg, *ADDMI, MI) || NewDefFor(ScaleReg, *ADDMI, MI))
2627 int64_t &Imm)
const {
2631 if (Opc != PPC::ADDI && Opc != PPC::ADDI8)
2643 return Opc == PPC::ADD4 || Opc == PPC::ADD8;
2647 unsigned &ToBeDeletedReg,
2648 unsigned &XFormOpcode,
2657 XFormOpcode = RI.getMappedIdxOpcForImmOpc(Opc);
2660 if (XFormOpcode == PPC::INSTRUCTION_LIST_END)
2674 if (!ImmOperand.
isImm())
2677 assert(RegOperand.
isReg() &&
"Instruction format is not right");
2680 if (!RegOperand.
isKill())
2683 ToBeDeletedReg = RegOperand.
getReg();
2684 OffsetImm = ImmOperand.
getImm();
2691 int64_t &OffsetAddi,
2692 int64_t OffsetImm)
const {
2693 assert((Index == 1 || Index == 2) &&
"Invalid operand index for add.");
2699 bool OtherIntermediateUse =
false;
2720 if (OtherIntermediateUse || !ADDIMI)
2738 bool PostRA = !MRI->
isSSA();
2739 bool SeenIntermediateUse =
true;
2740 unsigned ForwardingOperand = ~0U;
2742 SeenIntermediateUse);
2746 "The forwarding operand needs to be valid at this point");
2747 bool IsForwardingOperandKilled = MI.
getOperand(ForwardingOperand).
isKill();
2748 bool KillFwdDefMI = !SeenIntermediateUse && IsForwardingOperandKilled;
2750 if (KilledDef && KillFwdDefMI)
2762 transformToImmFormFedByAdd(MI, III, ForwardingOperand, *DefMI,
2772 int64_t SExtImm = ((uint64_t)Immediate & ~0x7FFFuLL) != 0 ?
2773 (Immediate | 0xFFFFFFFFFFFF0000) : Immediate;
2778 return transformToImmFormFedByLI(MI, III, ForwardingOperand, *DefMI, SExtImm);
2780 bool ReplaceWithLI =
false;
2781 bool Is64BitLI =
false;
2786 default:
return false;
2804 bool Changed =
false;
2807 int64_t SExtComparand = ((uint64_t)Comparand & ~0x7FFFuLL) != 0 ?
2808 (Comparand | 0xFFFFFFFFFFFF0000) : Comparand;
2811 unsigned UseOpc = CompareUseMI.getOpcode();
2812 if (UseOpc != PPC::ISEL && UseOpc != PPC::ISEL8)
2814 unsigned CRSubReg = CompareUseMI.getOperand(3).getSubReg();
2815 Register TrueReg = CompareUseMI.getOperand(1).getReg();
2816 Register FalseReg = CompareUseMI.getOperand(2).getReg();
2817 unsigned RegToCopy =
selectReg(SExtImm, SExtComparand, Opc, TrueReg,
2818 FalseReg, CRSubReg);
2819 if (RegToCopy == PPC::NoRegister)
2822 if (RegToCopy == PPC::ZERO || RegToCopy == PPC::ZERO8) {
2823 CompareUseMI.setDesc(
get(UseOpc == PPC::ISEL8 ? PPC::LI8 : PPC::LI));
2825 CompareUseMI.RemoveOperand(3);
2826 CompareUseMI.RemoveOperand(2);
2830 dbgs() <<
"Found LI -> CMPI -> ISEL, replacing with a copy.\n");
2834 CompareUseMI.setDesc(
get(PPC::COPY));
2835 CompareUseMI.RemoveOperand(3);
2836 CompareUseMI.RemoveOperand(RegToCopy == TrueReg ? 2 : 1);
2837 CmpIselsConverted++;
2846 MissedConvertibleImmediateInstrs++;
2856 ReplaceWithLI =
true;
2857 Is64BitLI = Opc == PPC::ADDI8;
2858 NewImm = Addend + SExtImm;
2864 case PPC::RLDICL_rec:
2865 case PPC::RLDICL_32:
2866 case PPC::RLDICL_32_64: {
2870 APInt InVal((Opc == PPC::RLDICL || Opc == PPC::RLDICL_rec) ? 64 : 32,
2872 InVal = InVal.
rotl(SH);
2873 uint64_t
Mask = (1LLU << (63 - MB + 1)) - 1;
2880 ReplaceWithLI =
true;
2881 Is64BitLI = Opc != PPC::RLDICL_32;
2883 SetCR = Opc == PPC::RLDICL_rec;
2890 case PPC::RLWINM_rec:
2891 case PPC::RLWINM8_rec: {
2895 APInt InVal(32, SExtImm,
true);
2896 InVal = InVal.
rotl(SH);
2898 uint64_t
Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
2904 ValueFits |= ((Opc == PPC::RLWINM_rec || Opc == PPC::RLWINM8_rec) &&
2907 ReplaceWithLI =
true;
2908 Is64BitLI = Opc == PPC::RLWINM8 || Opc == PPC::RLWINM8_rec;
2910 SetCR = Opc == PPC::RLWINM_rec || Opc == PPC::RLWINM8_rec;
2921 if (Opc == PPC::ORI || Opc == PPC::ORI8)
2922 Result = LogicalImm | SExtImm;
2924 Result = LogicalImm ^ SExtImm;
2926 ReplaceWithLI =
true;
2927 Is64BitLI = Opc == PPC::ORI8 || Opc == PPC::XORI8;
2935 if (ReplaceWithLI) {
2940 bool ImmChanged = (SExtImm & NewImm) != NewImm;
2941 if (PostRA && ImmChanged)
2954 assert(Immediate &&
"Transformation converted zero to non-zero?");
2958 else if (ImmChanged)
2969 LII.Is64Bit = Is64BitLI;
2973 if (KilledDef && SetCR)
2974 *KilledDef =
nullptr;
2981 if (IsForwardingOperandKilled)
3004 default:
return false;
3012 III.
ImmOpcode = Opc == PPC::ADD4 ? PPC::ADDI : PPC::ADDI8;
3037 III.
ImmOpcode = Opc == PPC::SUBFC ? PPC::SUBFIC : PPC::SUBFIC8;
3045 III.
ImmOpcode = Opc == PPC::CMPW ? PPC::CMPWI : PPC::CMPDI;
3053 III.
ImmOpcode = Opc == PPC::CMPLW ? PPC::CMPLWI : PPC::CMPLDI;
3074 case PPC::OR8: III.
ImmOpcode = PPC::ORI8;
break;
3076 case PPC::XOR8: III.
ImmOpcode = PPC::XORI8;
break;
3081 case PPC::RLWNM_rec:
3082 case PPC::RLWNM8_rec:
3102 if (Opc == PPC::RLWNM || Opc == PPC::RLWNM8 || Opc == PPC::RLWNM_rec ||
3103 Opc == PPC::RLWNM8_rec)
3109 case PPC::RLWNM: III.
ImmOpcode = PPC::RLWINM;
break;
3110 case PPC::RLWNM8: III.
ImmOpcode = PPC::RLWINM8;
break;
3111 case PPC::RLWNM_rec:
3114 case PPC::RLWNM8_rec:
3117 case PPC::SLW: III.
ImmOpcode = PPC::RLWINM;
break;
3118 case PPC::SLW8: III.
ImmOpcode = PPC::RLWINM8;
break;
3125 case PPC::SRW: III.
ImmOpcode = PPC::RLWINM;
break;
3126 case PPC::SRW8: III.
ImmOpcode = PPC::RLWINM8;
break;
3146 case PPC::RLDCL_rec:
3148 case PPC::RLDCR_rec:
3164 if (Opc == PPC::RLDCL || Opc == PPC::RLDCL_rec || Opc == PPC::RLDCR ||
3165 Opc == PPC::RLDCR_rec)
3171 case PPC::RLDCL: III.
ImmOpcode = PPC::RLDICL;
break;
3172 case PPC::RLDCL_rec:
3175 case PPC::RLDCR: III.
ImmOpcode = PPC::RLDICR;
break;
3176 case PPC::RLDCR_rec:
3179 case PPC::SLD: III.
ImmOpcode = PPC::RLDICR;
break;
3183 case PPC::SRD: III.
ImmOpcode = PPC::RLDICL;
break;
3230 case PPC::LBZX: III.
ImmOpcode = PPC::LBZ;
break;
3231 case PPC::LBZX8: III.
ImmOpcode = PPC::LBZ8;
break;
3232 case PPC::LHZX: III.
ImmOpcode = PPC::LHZ;
break;
3233 case PPC::LHZX8: III.
ImmOpcode = PPC::LHZ8;
break;
3234 case PPC::LHAX: III.
ImmOpcode = PPC::LHA;
break;
3235 case PPC::LHAX8: III.
ImmOpcode = PPC::LHA8;
break;
3236 case PPC::LWZX: III.
ImmOpcode = PPC::LWZ;
break;
3237 case PPC::LWZX8: III.
ImmOpcode = PPC::LWZ8;
break;
3243 case PPC::LFSX: III.
ImmOpcode = PPC::LFS;
break;
3244 case PPC::LFDX: III.
ImmOpcode = PPC::LFD;
break;
3245 case PPC::STBX: III.
ImmOpcode = PPC::STB;
break;
3246 case PPC::STBX8: III.
ImmOpcode = PPC::STB8;
break;
3247 case PPC::STHX: III.
ImmOpcode = PPC::STH;
break;
3248 case PPC::STHX8: III.
ImmOpcode = PPC::STH8;
break;
3249 case PPC::STWX: III.
ImmOpcode = PPC::STW;
break;
3250 case PPC::STWX8: III.
ImmOpcode = PPC::STW8;
break;
3255 case PPC::STFSX: III.
ImmOpcode = PPC::STFS;
break;
3256 case PPC::STFDX: III.
ImmOpcode = PPC::STFD;
break;
3288 case PPC::LBZUX: III.
ImmOpcode = PPC::LBZU;
break;
3289 case PPC::LBZUX8: III.
ImmOpcode = PPC::LBZU8;
break;
3290 case PPC::LHZUX: III.
ImmOpcode = PPC::LHZU;
break;
3291 case PPC::LHZUX8: III.
ImmOpcode = PPC::LHZU8;
break;
3292 case PPC::LHAUX: III.
ImmOpcode = PPC::LHAU;
break;
3293 case PPC::LHAUX8: III.
ImmOpcode = PPC::LHAU8;
break;
3294 case PPC::LWZUX: III.
ImmOpcode = PPC::LWZU;
break;
3295 case PPC::LWZUX8: III.
ImmOpcode = PPC::LWZU8;
break;
3300 case PPC::LFSUX: III.
ImmOpcode = PPC::LFSU;
break;
3301 case PPC::LFDUX: III.
ImmOpcode = PPC::LFDU;
break;
3302 case PPC::STBUX: III.
ImmOpcode = PPC::STBU;
break;
3303 case PPC::STBUX8: III.
ImmOpcode = PPC::STBU8;
break;
3304 case PPC::STHUX: III.
ImmOpcode = PPC::STHU;
break;
3305 case PPC::STHUX8: III.
ImmOpcode = PPC::STHU8;
break;
3306 case PPC::STWUX: III.
ImmOpcode = PPC::STWU;
break;
3307 case PPC::STWUX8: III.
ImmOpcode = PPC::STWU8;
break;
3312 case PPC::STFSUX: III.
ImmOpcode = PPC::STFSU;
break;
3313 case PPC::STFDUX: III.
ImmOpcode = PPC::STFDU;
break;
3326 case PPC::XFLOADf32:
3327 case PPC::XFLOADf64:
3328 case PPC::XFSTOREf32:
3329 case PPC::XFSTOREf64:
3330 if (!Subtarget.hasP9Vector())
3357 case PPC::XFLOADf32:
3371 case PPC::XFLOADf64:
3389 case PPC::XFSTOREf32:
3403 case PPC::XFSTOREf64:
3414 assert(Op1 != Op2 &&
"Cannot swap operand with itself.");
3416 unsigned MaxOp =
std::max(Op1, Op2);
3417 unsigned MinOp = std::min(Op1, Op2);
3453 bool PPCInstrInfo::isUseMIElgibleForForwarding(
MachineInstr &MI,
3455 unsigned OpNoForForwarding
3496 if (Opc != PPC::ADDItocL && Opc != PPC::ADDI && Opc != PPC::ADDI8)
3500 "Add inst must have at least three operands");
3510 bool PPCInstrInfo::isRegElgibleForForwarding(
3513 bool &IsFwdFeederRegKilled)
const {
3530 for (; It !=
E; ++It) {
3531 if (It->modifiesRegister(Reg, &
getRegisterInfo()) && (&*It) != &DefMI)
3533 else if (It->killsRegister(Reg, &
getRegisterInfo()) && (&*It) != &DefMI)
3534 IsFwdFeederRegKilled =
true;
3536 if ((&*It) == &
DefMI)
3539 assert((&*It) == &DefMI &&
"DefMI is missing");
3549 bool PPCInstrInfo::isImmElgibleForForwarding(
const MachineOperand &ImmMO,
3552 int64_t &Imm)
const {
3554 if (DefMI.
getOpcode() == PPC::ADDItocL) {
3573 if (ImmMO.
isImm()) {
3575 int64_t Immediate = ImmMO.
getImm();
3577 Imm = ((uint64_t)Immediate & ~0x7FFFuLL) != 0 ?
3578 (Immediate | 0xFFFFFFFFFFFF0000) : Immediate;
3585 APInt ActualValue(64, Imm,
true);
3589 uint64_t UnsignedMax = (1 << III.
ImmWidth) - 1;
3590 if ((uint64_t)Imm > UnsignedMax)
3606 bool PPCInstrInfo::transformToImmFormFedByAdd(
3616 if (!isUseMIElgibleForForwarding(MI, III, OpNoForForwarding))
3623 if (!isDefMIElgibleForForwarding(DefMI, III, ImmMO, RegMO))
3625 assert(ImmMO && RegMO &&
"Imm and Reg operand must have been set");
3630 if (!isImmElgibleForForwarding(*ImmMO, DefMI, III, Imm))
3633 bool IsFwdFeederRegKilled =
false;
3635 if (!isRegElgibleForForwarding(*RegMO, DefMI, MI, KillDefMI,
3636 IsFwdFeederRegKilled))
3640 unsigned ForwardKilledOperandReg = ~0U;
3642 bool PostRA = !MRI.
isSSA();
3660 if (ImmMO->
isImm()) {
3689 for (
auto &MO : MOps)
3704 if (IsFwdFeederRegKilled || RegMO->
isKill())
3709 if (ForwardKilledOperandReg != ~0U)
3718 bool PPCInstrInfo::transformToImmFormFedByLI(
MachineInstr &MI,
3720 unsigned ConstantOpNo,
3722 int64_t Imm)
const {
3724 bool PostRA = !MRI.
isSSA();
3733 APInt ActualValue(64, Imm,
true);
3737 uint64_t UnsignedMax = (1 << III.
ImmWidth) - 1;
3738 if ((uint64_t)Imm > UnsignedMax)
3752 if ((NewZeroReg == PPC::R0 || NewZeroReg == PPC::X0) &&
3755 if ((OrigZeroReg == PPC::R0 || OrigZeroReg == PPC::X0) &&
3756 ConstantOpNo != PosForOrigZero)
3761 unsigned ForwardKilledOperandReg = ~0U;
3766 bool SpecialShift32 = Opc == PPC::SLW || Opc == PPC::SLW_rec ||
3767 Opc == PPC::SRW || Opc == PPC::SRW_rec ||
3768 Opc == PPC::SLW8 || Opc == PPC::SLW8_rec ||
3769 Opc == PPC::SRW8 || Opc == PPC::SRW8_rec;
3770 bool SpecialShift64 = Opc == PPC::SLD || Opc == PPC::SLD_rec ||
3771 Opc == PPC::SRD || Opc == PPC::SRD_rec;
3772 bool SetCR = Opc == PPC::SLW_rec || Opc == PPC::SRW_rec ||
3773 Opc == PPC::SLD_rec || Opc == PPC::SRD_rec;
3774 bool RightShift = Opc == PPC::SRW || Opc == PPC::SRW_rec || Opc == PPC::SRD ||
3775 Opc == PPC::SRD_rec;
3785 if (SpecialShift32 || SpecialShift64) {
3790 uint64_t ShAmt = Imm & (SpecialShift32 ? 0x1F : 0x3F);
3791 if (Imm & (SpecialShift32 ? 0x20 : 0x40))
3796 else if (!SetCR && ShAmt == 0 && !PostRA) {
3801 if (SpecialShift32) {
3805 uint64_t SH = ShAmt == 0 ? 0 : RightShift ? 32 - ShAmt : ShAmt;
3806 uint64_t MB = RightShift ? ShAmt : 0;
3807 uint64_t ME = RightShift ? 31 : 31 - ShAmt;
3815 uint64_t SH = ShAmt == 0 ? 0 : RightShift ? 64 - ShAmt : ShAmt;
3816 uint64_t ME = RightShift ? ShAmt : 63 - ShAmt;
3848 &PPC::GPRC_and_GPRC_NOR0RegClass : &PPC::G8RC_and_G8RC_NOX0RegClass;
3858 if (ForwardKilledOperandReg != ~0U)
3865 if (Subtarget.hasVSX() && RC == &PPC::VRRCRegClass)
3866 return &PPC::VSRCRegClass;
3871 return PPC::getRecordFormOpcode(Opcode);
3879 if (Opcode == PPC::LI || Opcode == PPC::LI8 || Opcode == PPC::LIS ||
3880 Opcode == PPC::LIS8 || Opcode ==
PPC::SRAW || Opcode == PPC::SRAW_rec ||
3881 Opcode == PPC::SRAWI || Opcode == PPC::SRAWI_rec || Opcode == PPC::LWA ||
3882 Opcode == PPC::LWAX || Opcode == PPC::LWA_32 || Opcode == PPC::LWAX_32 ||
3883 Opcode == PPC::LHA || Opcode == PPC::LHAX || Opcode == PPC::LHA8 ||
3884 Opcode == PPC::LHAX8 || Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
3885 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 || Opcode == PPC::LBZU ||
3886 Opcode == PPC::LBZUX || Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3887 Opcode == PPC::LHZ || Opcode == PPC::LHZX || Opcode == PPC::LHZ8 ||
3888 Opcode == PPC::LHZX8 || Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
3889 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8 || Opcode == PPC::EXTSB ||
3890 Opcode == PPC::EXTSB_rec || Opcode == PPC::EXTSH ||
3891 Opcode == PPC::EXTSH_rec || Opcode == PPC::EXTSB8 ||
3892 Opcode == PPC::EXTSH8 || Opcode == PPC::EXTSW ||
3893 Opcode == PPC::EXTSW_rec || Opcode == PPC::SETB || Opcode == PPC::SETB8 ||
3894 Opcode == PPC::EXTSH8_32_64 || Opcode == PPC::EXTSW_32_64 ||
3895 Opcode == PPC::EXTSB8_32_64)
3901 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINM_rec ||
3902 Opcode == PPC::RLWNM || Opcode == PPC::RLWNM_rec) &&
3916 if (Opcode == PPC::LI || Opcode == PPC::LI8 ||
3917 Opcode == PPC::LIS || Opcode == PPC::LIS8) {
3919 if (((uint64_t)Imm & ~0x7FFFuLL) == 0)
3925 if ((Opcode == PPC::RLDICL || Opcode == PPC::RLDICL_rec ||
3926 Opcode == PPC::RLDCL || Opcode == PPC::RLDCL_rec ||
3927 Opcode == PPC::RLDICL_32_64) &&
3931 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDIC_rec) &&
3936 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINM_rec ||
3937 Opcode == PPC::RLWNM || Opcode == PPC::RLWNM_rec ||
3938 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
3943 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZW_rec ||
3944 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZW_rec ||
3945 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8 ||
3946 Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZD_rec ||
3947 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZD_rec ||
3948 Opcode == PPC::POPCNTD || Opcode == PPC::POPCNTW || Opcode == PPC::SLW ||
3949 Opcode == PPC::SLW_rec || Opcode == PPC::SRW || Opcode == PPC::SRW_rec ||
3950 Opcode == PPC::SLW8 || Opcode == PPC::SRW8 || Opcode == PPC::SLWI ||
3951 Opcode == PPC::SLWI_rec || Opcode == PPC::SRWI ||
3952 Opcode == PPC::SRWI_rec || Opcode == PPC::LWZ || Opcode == PPC::LWZX ||
3953 Opcode == PPC::LWZU || Opcode == PPC::LWZUX || Opcode == PPC::LWBRX ||
3954 Opcode == PPC::LHBRX || Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
3955 Opcode == PPC::LHZU || Opcode == PPC::LHZUX || Opcode == PPC::LBZ ||
3956 Opcode == PPC::LBZX || Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
3957 Opcode == PPC::LWZ8 || Opcode == PPC::LWZX8 || Opcode == PPC::LWZU8 ||
3958 Opcode == PPC::LWZUX8 || Opcode == PPC::LWBRX8 || Opcode == PPC::LHBRX8 ||
3959 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 || Opcode == PPC::LHZU8 ||
3960 Opcode == PPC::LHZUX8 || Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
3961 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3962 Opcode == PPC::ANDI_rec || Opcode == PPC::ANDIS_rec ||
3963 Opcode == PPC::ROTRWI || Opcode == PPC::ROTRWI_rec ||
3964 Opcode == PPC::EXTLWI || Opcode == PPC::EXTLWI_rec ||
3965 Opcode == PPC::MFVSRWZ)
3976 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
3979 if (StackReg == PPC::X1 && StackOffset == TOCSaveOffset)
3991 const unsigned Depth)
const {
4024 if (SrcReg == PPC::X3) {
4029 (--II)->
getOpcode() == PPC::ADJCALLSTACKUP) {
4059 case PPC::ANDIS_rec:
4064 case PPC::ANDI8_rec:
4065 case PPC::ANDIS8_rec:
4088 if (Depth >= MAX_DEPTH)
4093 unsigned E = 3,
D = 1;
4099 for (
unsigned I = 1;
I !=
E;
I +=
D) {
4119 if (Depth >= MAX_DEPTH)
4133 if (!MISrc1 || !MISrc2)
4151 return (Opcode == (Subtarget.isPPC64() ? PPC::BDNZ8 :
PPC::BDNZ));
4164 : Loop(Loop), EndLoop(EndLoop), LoopCount(LoopCount),
4175 bool shouldIgnoreForPipelining(
const MachineInstr *MI)
const override {
4177 return MI == EndLoop;
4183 if (TripCount == -1) {
4193 return TripCount > TC;
4201 void adjustTripCount(
int TripCountAdjust)
override {
4204 if (LoopCount->
getOpcode() == PPC::LI8 ||
4215 void disposed()
override {
4223 std::unique_ptr<TargetInstrInfo::PipelinerLoopInfo>
4228 if (Preheader == LoopBB)
4229 Preheader = *std::next(LoopBB->
pred_begin());
4232 if (I != LoopBB->
end() &&
isBDNZ(I->getOpcode())) {
4235 Register LoopCountReg = LoopInst->getOperand(0).getReg();
4238 return std::make_unique<PPCPipelinerLoopInfo>(LoopInst, &*
I, LoopCount);
4248 unsigned LOOPi = (Subtarget.isPPC64() ? PPC::MTCTR8loop : PPC::MTCTRloop);
4251 for (
auto &
I : PreHeader.
instrs())
4252 if (
I.getOpcode() == LOOPi)
4296 int64_t OffsetA = 0, OffsetB = 0;
4297 unsigned int WidthA = 0, WidthB = 0;
4301 int LowOffset = std::min(OffsetA, OffsetB);
4302 int HighOffset =
std::max(OffsetA, OffsetB);
4303 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
4304 if (LowOffset + LowWidth <= HighOffset)
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
void replaceInstrWithLI(MachineInstr &MI, const LoadImmediateInfo &LII) const
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
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.
StackOffset is a wrapper around scalable and non-scalable offsets and is used in several functions su...
bool isCall(QueryType Type=AnyInBundle) const
Wrapper class representing physical registers. Should be passed by value.
int getNonRecordFormOpcode(uint16_t)
MachineBasicBlock * getMBB() const
Object returned by analyzeLoopForPipelining.
This class represents lattice values for constants.
uint64_t ZeroIsSpecialNew
void setTargetFlags(unsigned F)
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.
void push_back(const T &Elt)
bool instrHasImmForm(unsigned Opc, bool IsVFReg, ImmInstrInfo &III, bool PostRA) const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
MachineInstr * findLoopInstr(MachineBasicBlock &PreHeader, SmallPtrSet< MachineBasicBlock *, 8 > &Visited) const
Find the hardware loop instruction used to set-up the specified loop.
const MCPhysReg * getImplicitUses() const
Return a list of registers that are potentially read by any instance of this machine instruction...
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
static int getRecordFormOpcode(unsigned Opcode)
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
bool getMemOperandWithOffsetWidth(const MachineInstr &LdSt, const MachineOperand *&BaseOp, int64_t &Offset, unsigned &Width, const TargetRegisterInfo *TRI) const
Return true if get the base operand, byte offset of an instruction and the memory width...
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
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.
uint64_t OpNoForForwarding
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
uint64_t IsSummingOperands
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.
void clearRegisterDeads(Register Reg)
Clear all dead flags on operands defining register Reg.
return AArch64::GPR64RegClass contains(Reg)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
ScheduleHazardRecognizer * CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const override
CreateTargetHazardRecognizer - Return the hazard recognizer to use for this target when scheduling th...
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.
const HexagonInstrInfo * TII
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumOperands() const
Retuns the total number of operands.
bool hasDirectMove() const
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
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
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)
void replaceInstrOperandWithImm(MachineInstr &MI, unsigned OpNo, int64_t Imm) const
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.
Directive
IDs for all OpenMP directives.
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.
void setReg(Register Reg)
Change the register this operand corresponds to.
virtual const TargetInstrInfo * getInstrInfo() const
unsigned getAlignment() const
bool foldFrameOffset(MachineInstr &MI) const
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.
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.
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
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...
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
const GlobalValue * getGlobal() const
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
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr fully defines the specified register.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
GPRC, CHAIN = LFIWAX CHAIN, Ptr - This is a floating-point load which sign-extends from a 32-bit inte...
unsigned getCPUDirective() const
getCPUDirective - Returns the -m directive specified for the cpu.
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.
bool isADDIInstrEligibleForFolding(MachineInstr &ADDIMI, int64_t &Imm) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
uint16_t getEncodingValue(MCRegister RegNo) const
Returns the encoding for RegNo.
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
unsigned getStoreOpcodeForSpill(unsigned Reg, const TargetRegisterClass *RC=nullptr) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
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.
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
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
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)
bool isImmInstrEligibleForFolding(MachineInstr &MI, unsigned &BaseReg, unsigned &XFormOpcode, int64_t &OffsetOfImmInstr, ImmInstrInfo &III) const
bool isBDNZ(unsigned Opcode) const
Check Opcode is BDNZ (Decrement CTR and branch if it is still nonzero).
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.
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
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
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
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.
Align max(MaybeAlign Lhs, Align Rhs)
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
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
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
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 hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
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
static bool isVFRegister(unsigned Reg)
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.
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)
MachineInstr * getDefMIPostRA(unsigned Reg, MachineInstr &MI, bool &SeenIntermediateUse) const
iterator_range< mop_iterator > implicit_operands()
bool use_empty(unsigned RegNo) const
use_empty - Return true if there are no instructions using the specified register.
int findRegisterUseOperandIdx(Register Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
On a symbol operand, this represents the lo part.
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. != -> ==, < -> >=.
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AAResults *AA) const override
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...
Represents a single loop in the control flow graph.
virtual bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
Returns true iff the routine could find two commutable operands in the given machine instruction...
bool isValidToBeChangedReg(MachineInstr *ADDMI, unsigned Index, MachineInstr *&ADDIMI, int64_t &OffsetAddi, int64_t OffsetImm) const
static bool isSignExtendingOp(const MachineInstr &MI)
static MachineOperand CreateImm(int64_t Val)
unsigned getLoadOpcodeForSpill(unsigned Reg, const TargetRegisterClass *RC=nullptr) const
void ChangeToRegister(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
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.
void fixupIsDeadOrKill(MachineInstr &StartMI, MachineInstr &EndMI, unsigned RegNo) const
Fixup killed/dead flag for register RegNo between instructions [StartMI, EndMI].
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)
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
const TargetInstrInfo * TII
Target instruction information.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
constexpr bool isUInt< 16 >(uint64_t x)
bool isSignedIntN(unsigned N) const
Check if this APInt has an N-bits signed integer value.
bool isADDInstrEligibleForFolding(MachineInstr &ADDMI) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
Return true if two MIs access different memory addresses and false otherwise.
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.
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
LLVM Value Representation.
static use_instr_iterator use_instr_end()
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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 hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
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...
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
Register getReg() const
getReg - Returns the register number.
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
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
GPRC, CHAIN = LFIWZX CHAIN, Ptr - This is a floating-point load which zero-extends from a 32-bit inte...
std::unique_ptr< TargetInstrInfo::PipelinerLoopInfo > analyzeLoopForPipelining(MachineBasicBlock *LoopBB) const override
Analyze loop L, which must be a single-basic-block loop, and if the conditions can be understood enou...
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
Wrapper class representing virtual and physical registers.
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...