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))
990 Opc = (Subtarget.
hasP9Vector()) ? PPC::XSCPSGNDP : PPC::XXLORf;
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)));
1439 .addImm(Pred[0].getImm())
1444 }
else if (OpC ==
PPC::B) {
1445 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR) {
1446 bool isPPC64 = Subtarget.
isPPC64();
1448 : (isPPC64 ? PPC::BDZ8 :
PPC::BDZ)));
1471 .addImm(Pred[0].getImm())
1477 }
else if (OpC == PPC::BCTR || OpC == PPC::BCTR8 || OpC ==
PPC::BCTRL ||
1478 OpC == PPC::BCTRL8) {
1479 if (Pred[1].
getReg() == PPC::CTR8 || Pred[1].
getReg() == PPC::CTR)
1482 bool setLR = OpC ==
PPC::BCTRL || OpC == PPC::BCTRL8;
1483 bool isPPC64 = Subtarget.
isPPC64();
1486 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8 : PPC::BCCTR8)
1487 : (setLR ? PPC::BCCTRL : PPC::BCCTR)));
1491 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCTRL8n : PPC::BCCTR8n)
1492 : (setLR ? PPC::BCCTRLn : PPC::BCCTRn)));
1497 MI.
setDesc(
get(isPPC64 ? (setLR ? PPC::BCCCTRL8 : PPC::BCCCTR8)
1498 : (setLR ? PPC::BCCCTRL : PPC::BCCCTR)));
1500 .addImm(Pred[0].getImm())
1510 assert(Pred1.
size() == 2 &&
"Invalid PPC first predicate");
1511 assert(Pred2.
size() == 2 &&
"Invalid PPC second predicate");
1513 if (Pred1[1].
getReg() == PPC::CTR8 || Pred1[1].getReg() == PPC::CTR)
1515 if (Pred2[1].
getReg() == PPC::CTR8 || Pred2[1].getReg() == PPC::CTR)
1519 if (Pred1[1].
getReg() != Pred2[1].getReg())
1540 std::vector<MachineOperand> &Pred)
const {
1548 { &PPC::CRRCRegClass, &PPC::CRBITRCRegClass,
1549 &PPC::CTRRCRegClass, &PPC::CTRRC8RegClass };
1592 unsigned &SrcReg2,
int &
Mask,
1597 default:
return false;
1632 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;
1650 if (!MI)
return false;
1652 bool equalityOnly =
false;
1655 if (is32BitSignedCompare) {
1661 }
else if (is32BitUnsignedCompare) {
1666 equalityOnly =
true;
1670 equalityOnly = is64BitUnsignedCompare;
1672 equalityOnly = is32BitUnsignedCompare;
1687 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1690 if (SubIdx != PPC::sub_eq)
1702 bool FoundUse =
false;
1731 else if (Value != 0) {
1740 if (equalityOnly || !MRI->
hasOneUse(CRReg))
1751 int16_t Immed = (int16_t)Value;
1782 for (; I != E && !noSub; --
I) {
1796 if ((OpC == PPC::CMPW || OpC == PPC::CMPLW ||
1797 OpC == PPC::CMPD || OpC == PPC::CMPLD) &&
1798 (IOpC == PPC::SUBF || IOpC == PPC::SUBF8) &&
1821 if (MIOpC == PPC::ANDIo || MIOpC == PPC::ANDIo8 ||
1822 MIOpC == PPC::ANDISo || MIOpC == PPC::ANDISo8)
1825 NewOpC = PPC::getRecordFormOpcode(MIOpC);
1845 bool ShouldSwap =
false;
1846 if (Sub && Value == 0) {
1852 ShouldSwap = !ShouldSwap;
1865 "Invalid predicate for equality-only optimization");
1869 }
else if (UseMI->
getOpcode() == PPC::ISEL ||
1872 assert((!equalityOnly || NewSubReg == PPC::sub_eq) &&
1873 "Invalid CR bit for equality-only optimization");
1875 if (NewSubReg == PPC::sub_lt)
1876 NewSubReg = PPC::sub_gt;
1877 else if (NewSubReg == PPC::sub_gt)
1878 NewSubReg = PPC::sub_lt;
1885 assert(!(Value != 0 && ShouldSwap) &&
1886 "Non-zero immediate support and ShouldSwap" 1887 "may conflict in updating predicate");
1896 get(TargetOpcode::COPY), CRReg)
1903 if (MIOpC != NewOpC) {
1913 if (MIOpC == PPC::RLWINM || MIOpC == PPC::RLWINM8) {
1920 bool MBInLoHWord = MB >= 16;
1921 bool MEInLoHWord = ME >= 16;
1922 uint64_t Mask = ~0LLU;
1924 if (MB <= ME && MBInLoHWord == MEInLoHWord && SH == 0) {
1925 Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
1927 Mask >>= MBInLoHWord ? 0 : 16;
1928 NewOpC = MIOpC == PPC::RLWINM ?
1929 (MBInLoHWord ? PPC::ANDIo : PPC::ANDISo) :
1930 (MBInLoHWord ? PPC::ANDIo8 :PPC::ANDISo8);
1931 }
else if (MRI->
use_empty(GPRRes) && (ME == 31) &&
1932 (ME - MB + 1 == SH) && (MB >= 16)) {
1936 Mask = ((1LLU << 32) - 1) & ~((1LLU << (32 - SH)) - 1);
1938 NewOpC = MIOpC == PPC::RLWINM ? PPC::ANDISo :PPC::ANDISo8;
1941 if (Mask != ~0LLU) {
1945 NumRcRotatesConvertedToRcAnd++;
1950 uint64_t Mask = (1LLU << (63 - MB + 1)) - 1;
1951 NewOpC = PPC::ANDIo8;
1954 NumRcRotatesConvertedToRcAnd++;
1963 *ImpDefs; ++ImpDefs)
1969 *ImpUses; ++ImpUses)
1975 "Record-form instruction does not define cr0?");
1980 for (
unsigned i = 0, e = PredsToUpdate.
size(); i < e; i++)
1981 PredsToUpdate[i].
first->setImm(PredsToUpdate[i].second);
1983 for (
unsigned i = 0, e = SubRegsToUpdate.
size(); i < e; i++)
1984 SubRegsToUpdate[i].
first->setSubReg(SubRegsToUpdate[i].second);
1999 }
else if (Opcode == TargetOpcode::STACKMAP) {
2002 }
else if (Opcode == TargetOpcode::PATCHPOINT) {
2006 return get(Opcode).getSize();
2010 std::pair<unsigned, unsigned>
2013 return std::make_pair(TF & Mask, TF & ~Mask);
2018 using namespace PPCII;
2019 static const std::pair<unsigned, const char *>
TargetFlags[] = {
2033 using namespace PPCII;
2034 static const std::pair<unsigned, const char *>
TargetFlags[] = {
2049 unsigned UpperOpcode, LowerOpcode;
2051 case PPC::DFLOADf32:
2052 UpperOpcode = PPC::LXSSP;
2053 LowerOpcode = PPC::LFS;
2055 case PPC::DFLOADf64:
2056 UpperOpcode = PPC::LXSD;
2057 LowerOpcode = PPC::LFD;
2059 case PPC::DFSTOREf32:
2060 UpperOpcode = PPC::STXSSP;
2061 LowerOpcode = PPC::STFS;
2063 case PPC::DFSTOREf64:
2064 UpperOpcode = PPC::STXSD;
2065 LowerOpcode = PPC::STFD;
2067 case PPC::XFLOADf32:
2068 UpperOpcode = PPC::LXSSPX;
2069 LowerOpcode = PPC::LFSX;
2071 case PPC::XFLOADf64:
2072 UpperOpcode = PPC::LXSDX;
2073 LowerOpcode = PPC::LFDX;
2075 case PPC::XFSTOREf32:
2076 UpperOpcode = PPC::STXSSPX;
2077 LowerOpcode = PPC::STFSX;
2079 case PPC::XFSTOREf64:
2080 UpperOpcode = PPC::STXSDX;
2081 LowerOpcode = PPC::STFDX;
2084 UpperOpcode = PPC::LXSIWAX;
2088 UpperOpcode = PPC::LXSIWZX;
2092 UpperOpcode = PPC::STXSIWX;
2101 if ((TargetReg >= PPC::F0 && TargetReg <= PPC::F31) ||
2102 (TargetReg >= PPC::VSL0 && TargetReg <= PPC::VSL31))
2103 Opcode = LowerOpcode;
2105 Opcode = UpperOpcode;
2119 case TargetOpcode::LOAD_STACK_GUARD: {
2120 assert(Subtarget.isTargetLinux() &&
2121 "Only Linux target is expected to contain LOAD_STACK_GUARD");
2122 const int64_t
Offset = Subtarget.isPPC64() ? -0x7010 : -0x7008;
2123 const unsigned Reg = Subtarget.isPPC64() ? PPC::X13 :
PPC::R2;
2130 case PPC::DFLOADf32:
2131 case PPC::DFLOADf64:
2132 case PPC::DFSTOREf32:
2133 case PPC::DFSTOREf64: {
2134 assert(Subtarget.hasP9Vector() &&
2135 "Invalid D-Form Pseudo-ops on Pre-P9 target.");
2138 "D-form op must have register and immediate operands");
2141 case PPC::XFLOADf32:
2142 case PPC::XFSTOREf32:
2146 assert(Subtarget.hasP8Vector() &&
2147 "Invalid X-Form Pseudo-ops on Pre-P8 target.");
2149 "X-form op must have register and register operands");
2152 case PPC::XFLOADf64:
2153 case PPC::XFSTOREf64: {
2154 assert(Subtarget.hasVSX() &&
2155 "Invalid X-Form Pseudo-ops on target that has no VSX.");
2157 "X-form op must have register and register operands");
2160 case PPC::SPILLTOVSR_LD: {
2162 if (PPC::VSFRCRegClass.
contains(TargetReg)) {
2163 MI.
setDesc(
get(PPC::DFLOADf64));
2170 case PPC::SPILLTOVSR_ST: {
2172 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2173 NumStoreSPILLVSRRCAsVec++;
2174 MI.
setDesc(
get(PPC::DFSTOREf64));
2177 NumStoreSPILLVSRRCAsGpr++;
2182 case PPC::SPILLTOVSR_LDX: {
2184 if (PPC::VSFRCRegClass.
contains(TargetReg))
2190 case PPC::SPILLTOVSR_STX: {
2192 if (PPC::VSFRCRegClass.
contains(SrcReg)) {
2193 NumStoreSPILLVSRRCAsVec++;
2196 NumStoreSPILLVSRRCAsGpr++;
2202 case PPC::CFENCE8: {
2205 BuildMI(MBB, MI, DL,
get(PPC::CTRL_DEP))
2221 static unsigned selectReg(int64_t Imm1, int64_t Imm2,
unsigned CompareOpc,
2222 unsigned TrueReg,
unsigned FalseReg,
2223 unsigned CRSubReg) {
2225 if (CompareOpc == PPC::CMPWI || CompareOpc == PPC::CMPDI) {
2229 return Imm1 < Imm2 ? TrueReg : FalseReg;
2231 return Imm1 > Imm2 ? TrueReg : FalseReg;
2233 return Imm1 == Imm2 ? TrueReg : FalseReg;
2237 else if (CompareOpc == PPC::CMPLWI || CompareOpc == PPC::CMPLDI) {
2241 return (uint64_t)Imm1 < (uint64_t)Imm2 ? TrueReg : FalseReg;
2243 return (uint64_t)Imm1 > (uint64_t)Imm2 ? TrueReg : FalseReg;
2245 return Imm1 == Imm2 ? TrueReg : FalseReg;
2248 return PPC::NoRegister;
2253 int64_t Imm)
const {
2266 if (UseOpIdx >= 0) {
2285 int OperandToKeep = LII.
SetCR ? 1 : 0;
2307 unsigned &OpNoForForwarding,
2308 bool &SeenIntermediateUse)
const {
2309 OpNoForForwarding = ~0U;
2326 OpNoForForwarding = i;
2337 bool ConvertibleImmForm =
2338 Opc == PPC::CMPWI || Opc == PPC::CMPLWI ||
2339 Opc == PPC::CMPDI || Opc == PPC::CMPLDI ||
2340 Opc == PPC::ADDI || Opc == PPC::ADDI8 ||
2341 Opc == PPC::ORI || Opc == PPC::ORI8 ||
2342 Opc == PPC::XORI || Opc == PPC::XORI8 ||
2343 Opc == PPC::RLDICL || Opc == PPC::RLDICLo ||
2344 Opc == PPC::RLDICL_32 || Opc == PPC::RLDICL_32_64 ||
2345 Opc == PPC::RLWINM || Opc == PPC::RLWINMo ||
2346 Opc == PPC::RLWINM8 || Opc == PPC::RLWINM8o;
2351 if ((Opc ==
PPC::OR || Opc == PPC::OR8) &&
2356 SeenIntermediateUse =
false;
2366 if (PPC::G8RCRegClass.
contains(Reg))
2367 Reg = Reg - PPC::X0 + PPC::R0;
2371 for ( ; It !=
E; ++It) {
2373 switch (It->getOpcode()) {
2380 OpNoForForwarding = i;
2387 SeenIntermediateUse =
true;
2392 return OpNoForForwarding == ~0U ? nullptr :
DefMI;
2395 const unsigned *PPCInstrInfo::getStoreOpcodesForSpillArray()
const {
2398 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2399 PPC::SPILL_CRBIT, PPC::STVX,
PPC::STXVD2X, PPC::STXSDX, PPC::STXSSPX,
2400 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2401 PPC::SPILLTOVSR_ST, PPC::EVSTDD, PPC::SPESTW},
2403 {PPC::STW, PPC::STD, PPC::STFD, PPC::STFS, PPC::SPILL_CR,
2404 PPC::SPILL_CRBIT, PPC::STVX, PPC::STXV, PPC::DFSTOREf64, PPC::DFSTOREf32,
2405 PPC::SPILL_VRSAVE, PPC::QVSTFDX, PPC::QVSTFSXs, PPC::QVSTFDXb,
2406 PPC::SPILLTOVSR_ST}};
2408 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2411 const unsigned *PPCInstrInfo::getLoadOpcodesForSpillArray()
const {
2414 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2415 PPC::RESTORE_CRBIT, PPC::LVX,
PPC::LXVD2X, PPC::LXSDX, PPC::LXSSPX,
2416 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2417 PPC::SPILLTOVSR_LD, PPC::EVLDD, PPC::SPELWZ},
2419 {PPC::LWZ,
PPC::LD, PPC::LFD, PPC::LFS, PPC::RESTORE_CR,
2420 PPC::RESTORE_CRBIT, PPC::LVX, PPC::LXV, PPC::DFLOADf64, PPC::DFLOADf32,
2421 PPC::RESTORE_VRSAVE, PPC::QVLFDX, PPC::QVLFSXs, PPC::QVLFDXb,
2422 PPC::SPILLTOVSR_LD}};
2424 return OpcodesForSpill[(Subtarget.hasP9Vector()) ? 1 : 0];
2434 bool PostRA = !MRI->
isSSA();
2435 bool SeenIntermediateUse =
true;
2436 unsigned ForwardingOperand = ~0U;
2438 SeenIntermediateUse);
2442 "The forwarding operand needs to be valid at this point");
2443 bool KillFwdDefMI = !SeenIntermediateUse &&
2445 if (KilledDef && KillFwdDefMI)
2453 if (HasImmForm && transformToImmFormFedByAdd(MI, III, ForwardingOperand,
2454 *DefMI, KillFwdDefMI))
2463 int64_t SExtImm = ((uint64_t)Immediate & ~0x7FFFuLL) != 0 ?
2464 (Immediate | 0xFFFFFFFFFFFF0000) : Immediate;
2469 return transformToImmFormFedByLI(MI, III, ForwardingOperand, SExtImm);
2471 bool ReplaceWithLI =
false;
2472 bool Is64BitLI =
false;
2477 default:
return false;
2493 bool Changed =
false;
2496 int64_t SExtComparand = ((uint64_t)Comparand & ~0x7FFFuLL) != 0 ?
2497 (Comparand | 0xFFFFFFFFFFFF0000) : Comparand;
2500 unsigned UseOpc = CompareUseMI.getOpcode();
2501 if (UseOpc != PPC::ISEL && UseOpc != PPC::ISEL8)
2503 unsigned CRSubReg = CompareUseMI.getOperand(3).getSubReg();
2504 unsigned TrueReg = CompareUseMI.getOperand(1).getReg();
2505 unsigned FalseReg = CompareUseMI.getOperand(2).getReg();
2506 unsigned RegToCopy =
selectReg(SExtImm, SExtComparand, Opc, TrueReg,
2507 FalseReg, CRSubReg);
2508 if (RegToCopy == PPC::NoRegister)
2511 if (RegToCopy == PPC::ZERO || RegToCopy == PPC::ZERO8) {
2512 CompareUseMI.setDesc(
get(UseOpc == PPC::ISEL8 ? PPC::LI8 : PPC::LI));
2514 CompareUseMI.RemoveOperand(3);
2515 CompareUseMI.RemoveOperand(2);
2519 dbgs() <<
"Found LI -> CMPI -> ISEL, replacing with a copy.\n");
2523 CompareUseMI.setDesc(
get(PPC::COPY));
2524 CompareUseMI.RemoveOperand(3);
2525 CompareUseMI.RemoveOperand(RegToCopy == TrueReg ? 2 : 1);
2526 CmpIselsConverted++;
2535 MissedConvertibleImmediateInstrs++;
2545 ReplaceWithLI =
true;
2546 Is64BitLI = Opc == PPC::ADDI8;
2547 NewImm = Addend + SExtImm;
2554 case PPC::RLDICL_32:
2555 case PPC::RLDICL_32_64: {
2559 APInt InVal((Opc == PPC::RLDICL || Opc == PPC::RLDICLo) ?
2560 64 : 32, SExtImm,
true);
2561 InVal = InVal.
rotl(SH);
2562 uint64_t
Mask = (1LLU << (63 - MB + 1)) - 1;
2569 ReplaceWithLI =
true;
2570 Is64BitLI = Opc != PPC::RLDICL_32;
2572 SetCR = Opc == PPC::RLDICLo;
2580 case PPC::RLWINM8o: {
2584 APInt InVal(32, SExtImm,
true);
2585 InVal = InVal.
rotl(SH);
2587 uint64_t
Mask = ((1LLU << (32 - MB)) - 1) & ~((1LLU << (31 - ME)) - 1);
2593 ValueFits |= ((Opc == PPC::RLWINMo || Opc == PPC::RLWINM8o) &&
2596 ReplaceWithLI =
true;
2597 Is64BitLI = Opc == PPC::RLWINM8 || Opc == PPC::RLWINM8o;
2599 SetCR = Opc == PPC::RLWINMo || Opc == PPC::RLWINM8o;
2610 if (Opc == PPC::ORI || Opc == PPC::ORI8)
2611 Result = LogicalImm | SExtImm;
2613 Result = LogicalImm ^ SExtImm;
2615 ReplaceWithLI =
true;
2616 Is64BitLI = Opc == PPC::ORI8 || Opc == PPC::XORI8;
2624 if (ReplaceWithLI) {
2629 bool ImmChanged = (SExtImm & NewImm) != NewImm;
2630 if (PostRA && ImmChanged)
2643 assert(Immediate &&
"Transformation converted zero to non-zero?");
2647 else if (ImmChanged)
2658 LII.Is64Bit = Is64BitLI;
2662 if (KilledDef && SetCR)
2663 *KilledDef =
nullptr;
2673 return PPC::VFRCRegClass.contains(Reg);
2690 default:
return false;
2698 III.
ImmOpcode = Opc == PPC::ADD4 ? PPC::ADDI : PPC::ADDI8;
2723 III.
ImmOpcode = Opc == PPC::SUBFC ? PPC::SUBFIC : PPC::SUBFIC8;
2731 III.
ImmOpcode = Opc == PPC::CMPW ? PPC::CMPWI : PPC::CMPDI;
2739 III.
ImmOpcode = Opc == PPC::CMPLW ? PPC::CMPLWI : PPC::CMPLDI;
2753 case PPC::ANDo: III.
ImmOpcode = PPC::ANDIo;
break;
2754 case PPC::AND8o: III.
ImmOpcode = PPC::ANDIo8;
break;
2756 case PPC::OR8: III.
ImmOpcode = PPC::ORI8;
break;
2758 case PPC::XOR8: III.
ImmOpcode = PPC::XORI8;
break;
2784 if (Opc == PPC::RLWNM || Opc == PPC::RLWNM8 ||
2785 Opc == PPC::RLWNMo || Opc == PPC::RLWNM8o)
2791 case PPC::RLWNM: III.
ImmOpcode = PPC::RLWINM;
break;
2792 case PPC::RLWNM8: III.
ImmOpcode = PPC::RLWINM8;
break;
2793 case PPC::RLWNMo: III.
ImmOpcode = PPC::RLWINMo;
break;
2794 case PPC::RLWNM8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2795 case PPC::SLW: III.
ImmOpcode = PPC::RLWINM;
break;
2796 case PPC::SLW8: III.
ImmOpcode = PPC::RLWINM8;
break;
2797 case PPC::SLWo: III.
ImmOpcode = PPC::RLWINMo;
break;
2798 case PPC::SLW8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2799 case PPC::SRW: III.
ImmOpcode = PPC::RLWINM;
break;
2800 case PPC::SRW8: III.
ImmOpcode = PPC::RLWINM8;
break;
2801 case PPC::SRWo: III.
ImmOpcode = PPC::RLWINMo;
break;
2802 case PPC::SRW8o: III.
ImmOpcode = PPC::RLWINM8o;
break;
2834 if (Opc == PPC::RLDCL || Opc == PPC::RLDCLo ||
2835 Opc == PPC::RLDCR || Opc == PPC::RLDCRo)
2841 case PPC::RLDCL: III.
ImmOpcode = PPC::RLDICL;
break;
2842 case PPC::RLDCLo: III.
ImmOpcode = PPC::RLDICLo;
break;
2843 case PPC::RLDCR: III.
ImmOpcode = PPC::RLDICR;
break;
2844 case PPC::RLDCRo: III.
ImmOpcode = PPC::RLDICRo;
break;
2845 case PPC::SLD: III.
ImmOpcode = PPC::RLDICR;
break;
2846 case PPC::SLDo: III.
ImmOpcode = PPC::RLDICRo;
break;
2847 case PPC::SRD: III.
ImmOpcode = PPC::RLDICL;
break;
2848 case PPC::SRDo: III.
ImmOpcode = PPC::RLDICLo;
break;
2892 case PPC::LBZX: III.
ImmOpcode = PPC::LBZ;
break;
2893 case PPC::LBZX8: III.
ImmOpcode = PPC::LBZ8;
break;
2894 case PPC::LHZX: III.
ImmOpcode = PPC::LHZ;
break;
2895 case PPC::LHZX8: III.
ImmOpcode = PPC::LHZ8;
break;
2896 case PPC::LHAX: III.
ImmOpcode = PPC::LHA;
break;
2897 case PPC::LHAX8: III.
ImmOpcode = PPC::LHA8;
break;
2898 case PPC::LWZX: III.
ImmOpcode = PPC::LWZ;
break;
2899 case PPC::LWZX8: III.
ImmOpcode = PPC::LWZ8;
break;
2905 case PPC::LFSX: III.
ImmOpcode = PPC::LFS;
break;
2906 case PPC::LFDX: III.
ImmOpcode = PPC::LFD;
break;
2907 case PPC::STBX: III.
ImmOpcode = PPC::STB;
break;
2908 case PPC::STBX8: III.
ImmOpcode = PPC::STB8;
break;
2909 case PPC::STHX: III.
ImmOpcode = PPC::STH;
break;
2910 case PPC::STHX8: III.
ImmOpcode = PPC::STH8;
break;
2911 case PPC::STWX: III.
ImmOpcode = PPC::STW;
break;
2912 case PPC::STWX8: III.
ImmOpcode = PPC::STW8;
break;
2917 case PPC::STFSX: III.
ImmOpcode = PPC::STFS;
break;
2918 case PPC::STFDX: III.
ImmOpcode = PPC::STFD;
break;
2950 case PPC::LBZUX: III.
ImmOpcode = PPC::LBZU;
break;
2951 case PPC::LBZUX8: III.
ImmOpcode = PPC::LBZU8;
break;
2952 case PPC::LHZUX: III.
ImmOpcode = PPC::LHZU;
break;
2953 case PPC::LHZUX8: III.
ImmOpcode = PPC::LHZU8;
break;
2954 case PPC::LHAUX: III.
ImmOpcode = PPC::LHAU;
break;
2955 case PPC::LHAUX8: III.
ImmOpcode = PPC::LHAU8;
break;
2956 case PPC::LWZUX: III.
ImmOpcode = PPC::LWZU;
break;
2957 case PPC::LWZUX8: III.
ImmOpcode = PPC::LWZU8;
break;
2962 case PPC::LFSUX: III.
ImmOpcode = PPC::LFSU;
break;
2963 case PPC::LFDUX: III.
ImmOpcode = PPC::LFDU;
break;
2964 case PPC::STBUX: III.
ImmOpcode = PPC::STBU;
break;
2965 case PPC::STBUX8: III.
ImmOpcode = PPC::STBU8;
break;
2966 case PPC::STHUX: III.
ImmOpcode = PPC::STHU;
break;
2967 case PPC::STHUX8: III.
ImmOpcode = PPC::STHU8;
break;
2968 case PPC::STWUX: III.
ImmOpcode = PPC::STWU;
break;
2969 case PPC::STWUX8: III.
ImmOpcode = PPC::STWU8;
break;
2974 case PPC::STFSUX: III.
ImmOpcode = PPC::STFSU;
break;
2975 case PPC::STFDUX: III.
ImmOpcode = PPC::STFDU;
break;
2988 case PPC::XFLOADf32:
2989 case PPC::XFLOADf64:
2990 case PPC::XFSTOREf32:
2991 case PPC::XFSTOREf64:
2992 if (!Subtarget.hasP9Vector())
3019 case PPC::XFLOADf32:
3033 case PPC::XFLOADf64:
3051 case PPC::XFSTOREf32:
3065 case PPC::XFSTOREf64:
3076 assert(Op1 != Op2 &&
"Cannot swap operand with itself.");
3078 unsigned MaxOp =
std::max(Op1, Op2);
3079 unsigned MinOp = std::min(Op1, Op2);
3115 bool PPCInstrInfo::isUseMIElgibleForForwarding(
MachineInstr &MI,
3117 unsigned OpNoForForwarding
3158 if (Opc != PPC::ADDItocL && Opc != PPC::ADDI && Opc != PPC::ADDI8)
3162 "Add inst must have at least three operands");
3172 bool PPCInstrInfo::isRegElgibleForForwarding(
const MachineOperand &RegMO,
3193 if (PPC::G8RCRegClass.
contains(Reg))
3194 Reg = Reg - PPC::X0 + PPC::R0;
3200 for (; It !=
E; ++It) {
3201 if (It->modifiesRegister(Reg, &
getRegisterInfo()) && (&*It) != &DefMI)
3204 if ((&*It) == &
DefMI)
3207 assert((&*It) == &DefMI &&
"DefMI is missing");
3217 bool PPCInstrInfo::isImmElgibleForForwarding(
const MachineOperand &ImmMO,
3220 int64_t &Imm)
const {
3222 if (DefMI.
getOpcode() == PPC::ADDItocL) {
3241 if (ImmMO.
isImm()) {
3243 int64_t Immediate = ImmMO.
getImm();
3245 Imm = ((uint64_t)Immediate & ~0x7FFFuLL) != 0 ?
3246 (Immediate | 0xFFFFFFFFFFFF0000) : Immediate;
3253 APInt ActualValue(64, Imm,
true);
3257 uint64_t UnsignedMax = (1 << III.
ImmWidth) - 1;
3258 if ((uint64_t)Imm > UnsignedMax)
3274 bool PPCInstrInfo::transformToImmFormFedByAdd(
MachineInstr &MI,
3276 unsigned OpNoForForwarding,
3278 bool KillDefMI)
const {
3286 if (!isUseMIElgibleForForwarding(MI, III, OpNoForForwarding))
3293 if (!isDefMIElgibleForForwarding(DefMI, III, ImmMO, RegMO))
3295 assert(ImmMO && RegMO &&
"Imm and Reg operand must have been set");
3300 if (!isImmElgibleForForwarding(*ImmMO, DefMI, III, Imm))
3304 if (!isRegElgibleForForwarding(*RegMO, DefMI, MI, KillDefMI))
3321 if (ImmMO->
isImm()) {
3350 for (
auto &MO : MOps)
3363 bool PPCInstrInfo::transformToImmFormFedByLI(
MachineInstr &MI,
3365 unsigned ConstantOpNo,
3366 int64_t Imm)
const {
3368 bool PostRA = !MRI.
isSSA();
3377 APInt ActualValue(64, Imm,
true);
3381 uint64_t UnsignedMax = (1 << III.
ImmWidth) - 1;
3382 if ((uint64_t)Imm > UnsignedMax)
3396 if ((NewZeroReg == PPC::R0 || NewZeroReg == PPC::X0) &&
3399 if ((OrigZeroReg == PPC::R0 || OrigZeroReg == PPC::X0) &&
3400 ConstantOpNo != PosForOrigZero)
3405 bool SpecialShift32 =
3406 Opc == PPC::SLW || Opc == PPC::SLWo || Opc == PPC::SRW || Opc == PPC::SRWo;
3407 bool SpecialShift64 =
3408 Opc == PPC::SLD || Opc == PPC::SLDo || Opc == PPC::SRD || Opc == PPC::SRDo;
3409 bool SetCR = Opc == PPC::SLWo || Opc == PPC::SRWo ||
3410 Opc == PPC::SLDo || Opc == PPC::SRDo;
3412 Opc == PPC::SRW || Opc == PPC::SRWo || Opc == PPC::SRD || Opc == PPC::SRDo;
3422 if (SpecialShift32 || SpecialShift64) {
3427 uint64_t ShAmt = Imm & (SpecialShift32 ? 0x1F : 0x3F);
3428 if (Imm & (SpecialShift32 ? 0x20 : 0x40))
3433 else if (!SetCR && ShAmt == 0 && !PostRA) {
3438 if (SpecialShift32) {
3440 uint64_t SH = RightShift ? 32 - ShAmt : ShAmt;
3441 uint64_t MB = RightShift ? ShAmt : 0;
3442 uint64_t ME = RightShift ? 31 : 31 - ShAmt;
3448 uint64_t SH = RightShift ? 64 - ShAmt : ShAmt;
3449 uint64_t ME = RightShift ? ShAmt : 63 - ShAmt;
3481 &PPC::GPRC_and_GPRC_NOR0RegClass : &PPC::G8RC_and_G8RC_NOX0RegClass;
3491 if (Subtarget.hasVSX() && RC == &PPC::VRRCRegClass)
3492 return &PPC::VSRCRegClass;
3497 return PPC::getRecordFormOpcode(Opcode);
3505 if (Opcode == PPC::LI || Opcode == PPC::LI8 ||
3506 Opcode == PPC::LIS || Opcode == PPC::LIS8 ||
3507 Opcode == PPC::SRAW || Opcode == PPC::SRAWo ||
3508 Opcode == PPC::SRAWI || Opcode == PPC::SRAWIo ||
3509 Opcode == PPC::LWA || Opcode == PPC::LWAX ||
3510 Opcode == PPC::LWA_32 || Opcode == PPC::LWAX_32 ||
3511 Opcode == PPC::LHA || Opcode == PPC::LHAX ||
3512 Opcode == PPC::LHA8 || Opcode == PPC::LHAX8 ||
3513 Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
3514 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
3515 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
3516 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3517 Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
3518 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
3519 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
3520 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8 ||
3521 Opcode == PPC::EXTSB || Opcode == PPC::EXTSBo ||
3522 Opcode == PPC::EXTSH || Opcode == PPC::EXTSHo ||
3523 Opcode == PPC::EXTSB8 || Opcode == PPC::EXTSH8 ||
3524 Opcode == PPC::EXTSW || Opcode == PPC::EXTSWo ||
3525 Opcode == PPC::SETB || Opcode == PPC::SETB8 ||
3526 Opcode == PPC::EXTSH8_32_64 || Opcode == PPC::EXTSW_32_64 ||
3527 Opcode == PPC::EXTSB8_32_64)
3533 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINMo ||
3534 Opcode == PPC::RLWNM || Opcode == PPC::RLWNMo) &&
3548 if (Opcode == PPC::LI || Opcode == PPC::LI8 ||
3549 Opcode == PPC::LIS || Opcode == PPC::LIS8) {
3551 if (((uint64_t)Imm & ~0x7FFFuLL) == 0)
3557 if ((Opcode == PPC::RLDICL || Opcode == PPC::RLDICLo ||
3558 Opcode == PPC::RLDCL || Opcode == PPC::RLDCLo ||
3559 Opcode == PPC::RLDICL_32_64) &&
3563 if ((Opcode == PPC::RLDIC || Opcode == PPC::RLDICo) &&
3568 if ((Opcode == PPC::RLWINM || Opcode == PPC::RLWINMo ||
3569 Opcode == PPC::RLWNM || Opcode == PPC::RLWNMo ||
3570 Opcode == PPC::RLWINM8 || Opcode == PPC::RLWNM8) &&
3575 if (Opcode == PPC::CNTLZW || Opcode == PPC::CNTLZWo ||
3576 Opcode == PPC::CNTTZW || Opcode == PPC::CNTTZWo ||
3577 Opcode == PPC::CNTLZW8 || Opcode == PPC::CNTTZW8 ||
3578 Opcode == PPC::CNTLZD || Opcode == PPC::CNTLZDo ||
3579 Opcode == PPC::CNTTZD || Opcode == PPC::CNTTZDo ||
3580 Opcode == PPC::POPCNTD || Opcode == PPC::POPCNTW ||
3581 Opcode == PPC::SLW || Opcode == PPC::SLWo ||
3582 Opcode == PPC::SRW || Opcode == PPC::SRWo ||
3583 Opcode == PPC::SLW8 || Opcode == PPC::SRW8 ||
3584 Opcode == PPC::SLWI || Opcode == PPC::SLWIo ||
3585 Opcode == PPC::SRWI || Opcode == PPC::SRWIo ||
3586 Opcode == PPC::LWZ || Opcode == PPC::LWZX ||
3587 Opcode == PPC::LWZU || Opcode == PPC::LWZUX ||
3588 Opcode == PPC::LWBRX || Opcode == PPC::LHBRX ||
3589 Opcode == PPC::LHZ || Opcode == PPC::LHZX ||
3590 Opcode == PPC::LHZU || Opcode == PPC::LHZUX ||
3591 Opcode == PPC::LBZ || Opcode == PPC::LBZX ||
3592 Opcode == PPC::LBZU || Opcode == PPC::LBZUX ||
3593 Opcode == PPC::LWZ8 || Opcode == PPC::LWZX8 ||
3594 Opcode == PPC::LWZU8 || Opcode == PPC::LWZUX8 ||
3595 Opcode == PPC::LWBRX8 || Opcode == PPC::LHBRX8 ||
3596 Opcode == PPC::LHZ8 || Opcode == PPC::LHZX8 ||
3597 Opcode == PPC::LHZU8 || Opcode == PPC::LHZUX8 ||
3598 Opcode == PPC::LBZ8 || Opcode == PPC::LBZX8 ||
3599 Opcode == PPC::LBZU8 || Opcode == PPC::LBZUX8 ||
3600 Opcode == PPC::ANDIo || Opcode == PPC::ANDISo ||
3601 Opcode == PPC::ROTRWI || Opcode == PPC::ROTRWIo ||
3602 Opcode == PPC::EXTLWI || Opcode == PPC::EXTLWIo ||
3603 Opcode == PPC::MFVSRWZ)
3614 unsigned TOCSaveOffset = Subtarget.getFrameLowering()->getTOCSaveOffset();
3617 if (StackReg == PPC::X1 && StackOffset == TOCSaveOffset)
3629 const unsigned Depth)
const {
3662 if (SrcReg == PPC::X3) {
3667 (--II)->
getOpcode() == PPC::ADJCALLSTACKUP) {
3726 if (Depth >= MAX_DEPTH)
3731 unsigned E = 3,
D = 1;
3737 for (
unsigned I = 1;
I !=
E;
I +=
D) {
3757 if (Depth >= MAX_DEPTH)
3771 if (!MISrc1 || !MISrc2)
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
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.
This class represents lattice values for constants.
uint64_t ZeroIsSpecialNew
void setTargetFlags(unsigned F)
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
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)
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.
uint64_t OpNoForForwarding
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
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.
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)
bool instrHasImmForm(const MachineInstr &MI, ImmInstrInfo &III, bool PostRA) const
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
Retuns the total number of operands.
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
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)
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.
static bool isVFReg(unsigned Reg)
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.
unsigned getAlignment() 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.
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.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
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.
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.
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 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 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"))
int findRegisterUseOperandIdx(unsigned Reg, bool isKill=false, const TargetRegisterInfo *TRI=nullptr) const
Returns the operand index that is a use of the specific register or -1 if it is not found...
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...