44 #define GET_INSTRINFO_CTOR_DTOR
45 #define GET_INSTRMAP_INFO
46 #include "SystemZGenInstrInfo.inc"
49 static uint64_t
allOnes(
unsigned int Count) {
50 return Count == 0 ? 0 : (uint64_t(1) << (Count - 1) << 1) - 1;
56 if (SystemZ::GRH32BitRegClass.
contains(Reg))
63 void SystemZInstrInfo::anchor() {}
73 unsigned NewOpcode)
const {
80 MBB->
insert(MI, EarlierMI);
85 unsigned Reg128 = LowRegOp.
getReg();
88 HighRegOp.
setReg(RI.getSubReg(HighRegOp.
getReg(), SystemZ::subreg_h64));
89 LowRegOp.
setReg(RI.getSubReg(LowRegOp.
getReg(), SystemZ::subreg_l64));
116 assert(HighOpcode && LowOpcode &&
"Both offsets should be in range");
118 EarlierMI->
setDesc(
get(HighOpcode));
119 MI->setDesc(
get(LowOpcode));
133 assert(NewOpcode &&
"No support for huge argument lists yet");
134 MI->setDesc(
get(NewOpcode));
144 void SystemZInstrInfo::expandRIPseudo(
MachineInstr &MI,
unsigned LowOpcode,
146 bool ConvertHigh)
const {
149 MI.
setDesc(
get(IsHigh ? HighOpcode : LowOpcode));
150 if (IsHigh && ConvertHigh)
158 void SystemZInstrInfo::expandRIEPseudo(
MachineInstr &MI,
unsigned LowOpcode,
160 unsigned HighOpcode)
const {
165 if (!DestIsHigh && !SrcIsHigh)
171 MI.
setDesc(
get(DestIsHigh ? HighOpcode : LowOpcode));
180 void SystemZInstrInfo::expandRXYPseudo(
MachineInstr &MI,
unsigned LowOpcode,
181 unsigned HighOpcode)
const {
191 void SystemZInstrInfo::expandLOCPseudo(
MachineInstr &MI,
unsigned LowOpcode,
192 unsigned HighOpcode)
const {
194 unsigned Opcode =
isHighReg(Reg) ? HighOpcode : LowOpcode;
201 void SystemZInstrInfo::expandLOCRPseudo(
MachineInstr &MI,
unsigned LowOpcode,
202 unsigned HighOpcode)
const {
208 if (!DestIsHigh && !SrcIsHigh)
210 else if (DestIsHigh && SrcIsHigh)
222 void SystemZInstrInfo::expandZExtPseudo(
MachineInstr &MI,
unsigned LowOpcode,
223 unsigned Size)
const {
236 void SystemZInstrInfo::expandLoadStackGuard(
MachineInstr *MI)
const {
240 const unsigned Reg32 = RI.getSubReg(Reg64, SystemZ::subreg_l32);
274 unsigned SrcReg,
unsigned LowLowOpcode,
275 unsigned Size,
bool KillSrc,
276 bool UndefSrc)
const {
280 if (DestIsHigh && SrcIsHigh)
281 Opcode = SystemZ::RISBHH;
282 else if (DestIsHigh && !SrcIsHigh)
283 Opcode = SystemZ::RISBHL;
284 else if (!DestIsHigh && SrcIsHigh)
285 Opcode = SystemZ::RISBLH;
287 return BuildMI(MBB, MBBI, DL,
get(LowLowOpcode), DestReg)
290 unsigned Rotate = (DestIsHigh != SrcIsHigh ? 32 : 0);
291 return BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
300 unsigned OpIdx2)
const {
308 case SystemZ::LOCRMux:
309 case SystemZ::LOCFHR:
311 case SystemZ::LOCGR: {
312 auto &WorkingMI = cloneIfNew(MI);
314 unsigned CCValid = WorkingMI.getOperand(3).getImm();
315 unsigned CCMask = WorkingMI.getOperand(4).getImm();
316 WorkingMI.getOperand(4).setImm(CCMask ^ CCValid);
353 int &SrcFrameIndex)
const {
369 DestFrameIndex = FI1;
378 bool AllowModify)
const {
384 while (I != MBB.
begin()) {
386 if (I->isDebugValue())
391 if (!isUnpredicatedTerminator(*I))
416 while (std::next(I) != MBB.
end())
425 I->eraseFromParent();
446 assert(Cond.
size() == 2 && TBB &&
"Should have seen a conditional branch");
454 unsigned OldCCValid = Cond[0].getImm();
455 unsigned OldCCMask = Cond[1].getImm();
456 if (OldCCValid == Branch.
CCValid && OldCCMask == Branch.
CCMask)
467 int *BytesRemoved)
const {
468 assert(!BytesRemoved &&
"code size not handled");
474 while (I != MBB.
begin()) {
476 if (I->isDebugValue())
483 I->eraseFromParent();
493 assert(Cond.
size() == 2 &&
"Invalid condition");
494 Cond[1].setImm(Cond[1].getImm() ^ Cond[0].getImm());
503 int *BytesAdded)
const {
509 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
511 "SystemZ branch conditions have one component!");
512 assert(!BytesAdded &&
"code size not handled");
516 assert(!FBB &&
"Unconditional branch with multiple successors!");
523 unsigned CCValid = Cond[0].getImm();
524 unsigned CCMask = Cond[1].getImm();
525 BuildMI(&MBB, DL,
get(SystemZ::BRC))
538 unsigned &SrcReg2,
int &
Mask,
540 assert(MI.
isCompare() &&
"Caller should have checked for a comparison");
584 if (RLL && RLL->
getOpcode() == SystemZ::LGFR) {
588 if (!RLL || !
isShift(RLL, SystemZ::RLL, 31))
603 for (++MBBI; MBBI != MBBE; ++MBBI) {
622 assert(!SrcReg2 &&
"Only optimizing constant comparisons so far");
624 return Value == 0 && !IsLogical &&
630 unsigned TrueReg,
unsigned FalseReg,
631 int &CondCycles,
int &TrueCycles,
632 int &FalseCycles)
const {
636 if (Pred.
size() != 2)
648 SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) ||
649 SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
650 SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
663 const DebugLoc &DL,
unsigned DstReg,
666 unsigned FalseReg)
const {
670 assert(Pred.
size() == 2 &&
"Invalid condition");
671 unsigned CCValid = Pred[0].getImm();
672 unsigned CCMask = Pred[1].getImm();
675 if (SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) {
677 Opc = SystemZ::LOCRMux;
683 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), TReg).
addReg(TrueReg);
684 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), FReg).
addReg(FalseReg);
688 }
else if (SystemZ::GR64BitRegClass.hasSubClassEq(RC))
689 Opc = SystemZ::LOCGR;
693 BuildMI(MBB, I, DL,
get(Opc), DstReg)
702 if (DefOpc != SystemZ::LHIMux && DefOpc != SystemZ::LHI &&
703 DefOpc != SystemZ::LGHI)
714 case SystemZ::LOCRMux:
717 NewUseOpc = SystemZ::LOCHIMux;
721 UseIdx = 2, CommuteIdx = 1;
728 NewUseOpc = SystemZ::LOCGHI;
732 UseIdx = 2, CommuteIdx = 1;
740 if (CommuteIdx != -1)
741 if (!commuteInstruction(UseMI,
false, CommuteIdx, UseIdx))
756 Opcode == SystemZ::Trap ||
757 Opcode == SystemZ::CallJG ||
758 Opcode == SystemZ::CallBR)
765 unsigned NumCycles,
unsigned ExtraPredCycles,
779 return NumCycles == 1;
784 unsigned NumCyclesT,
unsigned ExtraPredCyclesT,
786 unsigned NumCyclesF,
unsigned ExtraPredCyclesF,
796 return NumCycles == 1;
801 assert(Pred.
size() == 2 &&
"Invalid condition");
802 unsigned CCValid = Pred[0].getImm();
803 unsigned CCMask = Pred[1].getImm();
804 assert(CCMask > 0 && CCMask < 15 &&
"Invalid predicate");
806 if (Opcode == SystemZ::Trap) {
807 MI.
setDesc(
get(SystemZ::CondTrap));
809 .addImm(CCValid).
addImm(CCMask)
814 MI.
setDesc(
get(SystemZ::CondReturn));
816 .addImm(CCValid).
addImm(CCMask)
820 if (Opcode == SystemZ::CallJG) {
825 MI.
setDesc(
get(SystemZ::CallBRCL));
834 if (Opcode == SystemZ::CallBR) {
837 MI.
setDesc(
get(SystemZ::CallBCR));
839 .addImm(CCValid).
addImm(CCMask)
849 const DebugLoc &DL,
unsigned DestReg,
850 unsigned SrcReg,
bool KillSrc)
const {
854 if (SystemZ::GR128BitRegClass.
contains(DestReg, SrcReg)) {
855 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_h64),
856 RI.getSubReg(SrcReg, SystemZ::subreg_h64), KillSrc);
859 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_l64),
860 RI.getSubReg(SrcReg, SystemZ::subreg_l64), KillSrc);
861 MachineInstrBuilder(*MBB.
getParent(), std::prev(MBBI))
866 if (SystemZ::GRX32BitRegClass.
contains(DestReg, SrcReg)) {
867 emitGRX32Move(MBB, MBBI, DL, DestReg, SrcReg, SystemZ::LR, 32, KillSrc,
873 if (SystemZ::VR128BitRegClass.
contains(DestReg) &&
874 SystemZ::FP128BitRegClass.
contains(SrcReg)) {
876 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_h64),
877 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
879 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_l64),
880 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
882 BuildMI(MBB, MBBI, DL,
get(SystemZ::VMRHG), DestReg)
887 if (SystemZ::FP128BitRegClass.
contains(DestReg) &&
888 SystemZ::VR128BitRegClass.
contains(SrcReg)) {
890 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_h64),
891 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
893 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_l64),
894 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
896 if (DestRegHi != SrcReg)
897 copyPhysReg(MBB, MBBI, DL, DestRegHi, SrcReg,
false);
898 BuildMI(MBB, MBBI, DL,
get(SystemZ::VREPG), DestRegLo)
905 if (SystemZ::GR64BitRegClass.
contains(DestReg, SrcReg))
906 Opcode = SystemZ::LGR;
907 else if (SystemZ::FP32BitRegClass.
contains(DestReg, SrcReg))
909 Opcode = STI.
hasVector() ? SystemZ::LDR32 : SystemZ::LER;
910 else if (SystemZ::FP64BitRegClass.
contains(DestReg, SrcReg))
912 else if (SystemZ::FP128BitRegClass.
contains(DestReg, SrcReg))
913 Opcode = SystemZ::LXR;
914 else if (SystemZ::VR32BitRegClass.
contains(DestReg, SrcReg))
915 Opcode = SystemZ::VLR32;
916 else if (SystemZ::VR64BitRegClass.
contains(DestReg, SrcReg))
917 Opcode = SystemZ::VLR64;
918 else if (SystemZ::VR128BitRegClass.
contains(DestReg, SrcReg))
919 Opcode = SystemZ::VLR;
920 else if (SystemZ::AR32BitRegClass.
contains(DestReg, SrcReg))
921 Opcode = SystemZ::CPYA;
922 else if (SystemZ::AR32BitRegClass.
contains(DestReg) &&
923 SystemZ::GR32BitRegClass.
contains(SrcReg))
924 Opcode = SystemZ::SAR;
925 else if (SystemZ::GR32BitRegClass.
contains(DestReg) &&
926 SystemZ::AR32BitRegClass.
contains(SrcReg))
927 Opcode = SystemZ::EAR;
931 BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
943 unsigned LoadOpcode, StoreOpcode;
958 unsigned LoadOpcode, StoreOpcode;
968 return ((MCID.
TSFlags & Flag) &&
977 LogicOp(
unsigned regSize,
unsigned immLSB,
unsigned immSize)
978 : RegSize(regSize), ImmLSB(immLSB), ImmSize(immSize) {}
980 explicit operator bool()
const {
return RegSize; }
982 unsigned RegSize = 0;
984 unsigned ImmSize = 0;
991 case SystemZ::NILMux:
return LogicOp(32, 0, 16);
992 case SystemZ::NIHMux:
return LogicOp(32, 16, 16);
993 case SystemZ::NILL64:
return LogicOp(64, 0, 16);
994 case SystemZ::NILH64:
return LogicOp(64, 16, 16);
995 case SystemZ::NIHL64:
return LogicOp(64, 32, 16);
996 case SystemZ::NIHH64:
return LogicOp(64, 48, 16);
997 case SystemZ::NIFMux:
return LogicOp(32, 0, 32);
998 case SystemZ::NILF64:
return LogicOp(64, 0, 32);
999 case SystemZ::NIHF64:
return LogicOp(64, 32, 32);
1000 default:
return LogicOp();
1007 if (CCDef !=
nullptr)
1019 for (
unsigned I = 1;
I < NumOps; ++
I) {
1045 unsigned DestReg = Dest.
getReg();
1046 unsigned SrcReg = Src.
getReg();
1050 if (Opcode == SystemZ::AHIMux &&
1058 int ThreeOperandOpcode = SystemZ::getThreeOperandOpcode(Opcode);
1059 if (ThreeOperandOpcode >= 0) {
1070 for (
unsigned I = 2;
I < NumOps; ++
I)
1081 Imm |=
allOnes(And.RegSize) & ~(
allOnes(And.ImmSize) << And.ImmLSB);
1082 unsigned Start,
End;
1085 if (And.RegSize == 64) {
1086 NewOpcode = SystemZ::RISBG;
1089 NewOpcode = SystemZ::RISBGN;
1091 NewOpcode = SystemZ::RISBMux;
1121 if (Ops.
size() == 2 && Ops[0] == 0 && Ops[1] == 1) {
1122 if (LIS !=
nullptr && (Opcode == SystemZ::LA || Opcode == SystemZ::LAY) &&
1133 if (!CCLiveRange.
liveAt(MISlot)) {
1149 if (Ops.
size() != 1)
1152 unsigned OpNum = Ops[0];
1156 "Invalid size combination");
1158 if ((Opcode == SystemZ::AHI || Opcode == SystemZ::AGHI) && OpNum == 0 &&
1161 Opcode = (Opcode == SystemZ::AHI ? SystemZ::ASI : SystemZ::AGSI);
1171 if (Opcode == SystemZ::LGDR || Opcode == SystemZ::LDGR) {
1172 bool Op0IsGPR = (Opcode == SystemZ::LGDR);
1173 bool Op1IsGPR = (Opcode == SystemZ::LDGR);
1177 unsigned StoreOpcode = Op1IsGPR ? SystemZ::STG : SystemZ::STD;
1181 .addFrameIndex(FrameIndex)
1188 unsigned LoadOpcode = Op0IsGPR ? SystemZ::LG :
SystemZ::LD;
1192 .addFrameIndex(FrameIndex)
1223 .addMemOperand(MMO);
1241 int MemOpcode = SystemZ::getMemOpcode(Opcode);
1242 if (MemOpcode >= 0) {
1244 if (OpNum == NumOps - 1) {
1247 assert(AccessBytes != 0 &&
"Size of access should be known");
1248 assert(AccessBytes <= Size &&
"Access outside the frame index");
1249 uint64_t Offset = Size - AccessBytes;
1252 for (
unsigned I = 0;
I < OpNum; ++
I)
1275 splitMove(MI, SystemZ::LG);
1278 case SystemZ::ST128:
1279 splitMove(MI, SystemZ::STG);
1287 splitMove(MI, SystemZ::STD);
1290 case SystemZ::LBMux:
1291 expandRXYPseudo(MI, SystemZ::LB, SystemZ::LBH);
1294 case SystemZ::LHMux:
1295 expandRXYPseudo(MI, SystemZ::LH, SystemZ::LHH);
1298 case SystemZ::LLCRMux:
1299 expandZExtPseudo(MI, SystemZ::LLCR, 8);
1302 case SystemZ::LLHRMux:
1303 expandZExtPseudo(MI, SystemZ::LLHR, 16);
1306 case SystemZ::LLCMux:
1307 expandRXYPseudo(MI, SystemZ::LLC, SystemZ::LLCH);
1310 case SystemZ::LLHMux:
1311 expandRXYPseudo(MI, SystemZ::LLH, SystemZ::LLHH);
1315 expandRXYPseudo(MI,
SystemZ::L, SystemZ::LFH);
1318 case SystemZ::LOCMux:
1319 expandLOCPseudo(MI, SystemZ::LOC, SystemZ::LOCFH);
1322 case SystemZ::LOCHIMux:
1323 expandLOCPseudo(MI, SystemZ::LOCHI, SystemZ::LOCHHI);
1326 case SystemZ::LOCRMux:
1327 expandLOCRPseudo(MI, SystemZ::LOCR, SystemZ::LOCFHR);
1330 case SystemZ::STCMux:
1331 expandRXYPseudo(MI, SystemZ::STC, SystemZ::STCH);
1334 case SystemZ::STHMux:
1335 expandRXYPseudo(MI, SystemZ::STH, SystemZ::STHH);
1338 case SystemZ::STMux:
1342 case SystemZ::STOCMux:
1343 expandLOCPseudo(MI, SystemZ::STOC, SystemZ::STOCFH);
1346 case SystemZ::LHIMux:
1347 expandRIPseudo(MI, SystemZ::LHI, SystemZ::IIHF,
true);
1350 case SystemZ::IIFMux:
1351 expandRIPseudo(MI, SystemZ::IILF, SystemZ::IIHF,
false);
1354 case SystemZ::IILMux:
1355 expandRIPseudo(MI, SystemZ::IILL, SystemZ::IIHL,
false);
1358 case SystemZ::IIHMux:
1359 expandRIPseudo(MI, SystemZ::IILH, SystemZ::IIHH,
false);
1362 case SystemZ::NIFMux:
1363 expandRIPseudo(MI, SystemZ::NILF, SystemZ::NIHF,
false);
1366 case SystemZ::NILMux:
1367 expandRIPseudo(MI, SystemZ::NILL, SystemZ::NIHL,
false);
1370 case SystemZ::NIHMux:
1371 expandRIPseudo(MI, SystemZ::NILH, SystemZ::NIHH,
false);
1374 case SystemZ::OIFMux:
1375 expandRIPseudo(MI, SystemZ::OILF, SystemZ::OIHF,
false);
1378 case SystemZ::OILMux:
1379 expandRIPseudo(MI, SystemZ::OILL, SystemZ::OIHL,
false);
1382 case SystemZ::OIHMux:
1383 expandRIPseudo(MI, SystemZ::OILH, SystemZ::OIHH,
false);
1386 case SystemZ::XIFMux:
1387 expandRIPseudo(MI, SystemZ::XILF, SystemZ::XIHF,
false);
1390 case SystemZ::TMLMux:
1391 expandRIPseudo(MI, SystemZ::TMLL, SystemZ::TMHL,
false);
1394 case SystemZ::TMHMux:
1395 expandRIPseudo(MI, SystemZ::TMLH, SystemZ::TMHH,
false);
1398 case SystemZ::AHIMux:
1399 expandRIPseudo(MI, SystemZ::AHI, SystemZ::AIH,
false);
1402 case SystemZ::AHIMuxK:
1403 expandRIEPseudo(MI, SystemZ::AHI, SystemZ::AHIK, SystemZ::AIH);
1406 case SystemZ::AFIMux:
1407 expandRIPseudo(MI, SystemZ::AFI, SystemZ::AIH,
false);
1410 case SystemZ::CHIMux:
1411 expandRIPseudo(MI, SystemZ::CHI, SystemZ::CIH,
false);
1414 case SystemZ::CFIMux:
1415 expandRIPseudo(MI, SystemZ::CFI, SystemZ::CIH,
false);
1418 case SystemZ::CLFIMux:
1419 expandRIPseudo(MI, SystemZ::CLFI, SystemZ::CLIH,
false);
1423 expandRXYPseudo(MI,
SystemZ::C, SystemZ::CHF);
1426 case SystemZ::CLMux:
1427 expandRXYPseudo(MI, SystemZ::CL, SystemZ::CLHF);
1430 case SystemZ::RISBMux: {
1433 if (SrcIsHigh == DestIsHigh)
1434 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHH : SystemZ::RISBLL));
1436 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHL : SystemZ::RISBLH));
1443 splitAdjDynAlloc(MI);
1446 case TargetOpcode::LOAD_STACK_GUARD:
1447 expandLoadStackGuard(&MI);
1480 case SystemZ::BRCTH:
1484 case SystemZ::BRCTG:
1503 case SystemZ::CLGIJ:
1504 case SystemZ::CLGRJ:
1514 unsigned &LoadOpcode,
1515 unsigned &StoreOpcode)
const {
1516 if (RC == &SystemZ::GR32BitRegClass || RC == &SystemZ::ADDR32BitRegClass) {
1519 }
else if (RC == &SystemZ::GRH32BitRegClass) {
1520 LoadOpcode = SystemZ::LFH;
1521 StoreOpcode = SystemZ::STFH;
1522 }
else if (RC == &SystemZ::GRX32BitRegClass) {
1523 LoadOpcode = SystemZ::LMux;
1524 StoreOpcode = SystemZ::STMux;
1525 }
else if (RC == &SystemZ::GR64BitRegClass ||
1526 RC == &SystemZ::ADDR64BitRegClass) {
1527 LoadOpcode = SystemZ::LG;
1528 StoreOpcode = SystemZ::STG;
1529 }
else if (RC == &SystemZ::GR128BitRegClass ||
1530 RC == &SystemZ::ADDR128BitRegClass) {
1531 LoadOpcode = SystemZ::L128;
1532 StoreOpcode = SystemZ::ST128;
1533 }
else if (RC == &SystemZ::FP32BitRegClass) {
1535 StoreOpcode = SystemZ::STE;
1536 }
else if (RC == &SystemZ::FP64BitRegClass) {
1538 StoreOpcode = SystemZ::STD;
1539 }
else if (RC == &SystemZ::FP128BitRegClass) {
1540 LoadOpcode = SystemZ::LX;
1541 StoreOpcode = SystemZ::STX;
1542 }
else if (RC == &SystemZ::VR32BitRegClass) {
1543 LoadOpcode = SystemZ::VL32;
1544 StoreOpcode = SystemZ::VST32;
1545 }
else if (RC == &SystemZ::VR64BitRegClass) {
1546 LoadOpcode = SystemZ::VL64;
1547 StoreOpcode = SystemZ::VST64;
1548 }
else if (RC == &SystemZ::VF128BitRegClass ||
1549 RC == &SystemZ::VR128BitRegClass) {
1550 LoadOpcode = SystemZ::VL;
1551 StoreOpcode = SystemZ::VST;
1557 int64_t Offset)
const {
1560 if (isUInt<12>(Offset) && isUInt<12>(Offset2)) {
1562 int Disp12Opcode = SystemZ::getDisp12Opcode(Opcode);
1563 if (Disp12Opcode >= 0)
1564 return Disp12Opcode;
1570 if (isInt<20>(Offset) && isInt<20>(Offset2)) {
1572 int Disp20Opcode = SystemZ::getDisp20Opcode(Opcode);
1573 if (Disp20Opcode >= 0)
1574 return Disp20Opcode;
1587 case SystemZ::LG:
return SystemZ::LTG;
1588 case SystemZ::LGF:
return SystemZ::LTGF;
1589 case SystemZ::LR:
return SystemZ::LTR;
1590 case SystemZ::LGFR:
return SystemZ::LTGFR;
1591 case SystemZ::LGR:
return SystemZ::LTGR;
1592 case SystemZ::LER:
return SystemZ::LTEBR;
1594 case SystemZ::LXR:
return SystemZ::LTXBR;
1595 case SystemZ::LCDFR:
return SystemZ::LCDBR;
1596 case SystemZ::LPDFR:
return SystemZ::LPDBR;
1597 case SystemZ::LNDFR:
return SystemZ::LNDBR;
1598 case SystemZ::LCDFR_32:
return SystemZ::LCEBR;
1599 case SystemZ::LPDFR_32:
return SystemZ::LPEBR;
1600 case SystemZ::LNDFR_32:
return SystemZ::LNEBR;
1605 case SystemZ::RISBGN:
return SystemZ::RISBG;
1615 uint64_t Top = (Mask >> First) + 1;
1616 if ((Top & -Top) == Top) {
1625 unsigned &Start,
unsigned &
End)
const {
1633 unsigned LSB, Length;
1635 Start = 63 - (LSB + Length - 1);
1643 assert(LSB > 0 &&
"Bottom bit must be set");
1644 assert(LSB + Length < BitSize &&
"Top bit must be set");
1645 Start = 63 - (LSB - 1);
1646 End = 63 - (LSB + Length);
1663 case SystemZ::CLGFI:
1679 return SystemZ::CRJ;
1681 return SystemZ::CGRJ;
1683 return SystemZ::CIJ;
1685 return SystemZ::CGIJ;
1687 return SystemZ::CLRJ;
1689 return SystemZ::CLGRJ;
1691 return SystemZ::CLIJ;
1692 case SystemZ::CLGFI:
1693 return SystemZ::CLGIJ;
1700 return SystemZ::CRBReturn;
1702 return SystemZ::CGRBReturn;
1704 return SystemZ::CIBReturn;
1706 return SystemZ::CGIBReturn;
1708 return SystemZ::CLRBReturn;
1710 return SystemZ::CLGRBReturn;
1712 return SystemZ::CLIBReturn;
1713 case SystemZ::CLGFI:
1714 return SystemZ::CLGIBReturn;
1721 return SystemZ::CRBCall;
1723 return SystemZ::CGRBCall;
1725 return SystemZ::CIBCall;
1727 return SystemZ::CGIBCall;
1729 return SystemZ::CLRBCall;
1731 return SystemZ::CLGRBCall;
1733 return SystemZ::CLIBCall;
1734 case SystemZ::CLGFI:
1735 return SystemZ::CLGIBCall;
1742 return SystemZ::CRT;
1744 return SystemZ::CGRT;
1746 return SystemZ::CIT;
1748 return SystemZ::CGIT;
1750 return SystemZ::CLRT;
1752 return SystemZ::CLGRT;
1754 return SystemZ::CLFIT;
1755 case SystemZ::CLGFI:
1756 return SystemZ::CLGIT;
1758 return SystemZ::CLT;
1760 return SystemZ::CLGT;
1774 return SystemZ::LAT;
1776 return SystemZ::LGAT;
1778 return SystemZ::LFHAT;
1780 return SystemZ::LLGFAT;
1782 return SystemZ::LLGTAT;
1789 unsigned Reg, uint64_t
Value)
const {
1793 Opcode = SystemZ::LGHI;
1795 Opcode = SystemZ::LLILL;
1797 Opcode = SystemZ::LLILH;
1801 Opcode = SystemZ::LGFI;
1821 bool SameVal = (VALa && VALb && (VALa == VALb));
1825 if (PSVa && PSVb && (PSVa == PSVb))
1831 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1832 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1833 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1834 if (LowOffset + LowWidth <= HighOffset)
SystemZII::Branch getBranchInfo(const MachineInstr &MI) const
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
unsigned getLoadAndTrap(unsigned Opcode) const
bool expandPostRAPseudo(MachineInstr &MBBI) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
const int64_t CallFrameSize
SystemZInstrInfo(SystemZSubtarget &STI)
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
MachineOperand * findRegisterDefOperand(unsigned Reg, bool isDead=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
MachineBasicBlock * getMBB() const
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr) const override
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &Mask, int &Value) const override
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
Describe properties that are true of each instruction in the target description file.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
static void eraseIfDead(MachineInstr *MI, const MachineRegisterInfo *MRI)
constexpr bool isInt< 8 >(int64_t x)
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
const char * getSymbolName() const
constexpr bool isInt< 16 >(int64_t x)
void setIsDead(bool Val=true)
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
MachineInstr * CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, bool NoImp=false)
CreateMachineInstr - Allocate a new MachineInstr.
const unsigned CCMASK_ICMP
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const override
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const override
return AArch64::GPR64RegClass contains(Reg)
static uint64_t allOnes(unsigned int Count)
This class represents the liveness of a register, stack slot, etc.
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
unsigned getLoadAndTest(unsigned Opcode) const
static bool removeIPMBasedCompare(MachineInstr &Compare, unsigned SrcReg, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)
bool hasLoadStoreOnCond() const
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
A description of a memory reference used in the backend.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Reg, uint64_t Value) const
VNInfo::Allocator & getVNInfoAllocator()
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
Reg
All possible values of the reg field in the ModR/M byte.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
INLINEASM - Represents an inline asm block.
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int Mask, int Value, const MachineRegisterInfo *MRI) const override
void RemoveOperand(unsigned i)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
bool hasLoadStoreOnCond2() const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
void getLoadStoreOpcodes(const TargetRegisterClass *RC, unsigned &LoadOpcode, unsigned &StoreOpcode) const
static LogicOp interpretAndImmediate(unsigned Opcode)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool isPredicable(const MachineInstr &MI) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const MachineOperand * Target
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
const unsigned CCMASK_ANY
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
unsigned getUndefRegState(bool B)
size_t size() const
size - Get the array size.
bool isStackSlotCopy(const MachineInstr &MI, int &DestFrameIndex, int &SrcFrameIndex) const override
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
unsigned getKillRegState(bool B)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
Flag
These should be considered private to the implementation of the MCInstrDesc class.
const MachineBasicBlock * getParent() const
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned CommuteOpIdx1, unsigned CommuteOpIdx2) const override
Commutes the operands in the given instruction by changing the operands order and/or changing the ins...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static void transferDeadCC(MachineInstr *OldMI, MachineInstr *NewMI)
SlotIndexes * getSlotIndexes() const
Control flow instructions. These all have token chains.
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset) const
constexpr bool isUInt< 8 >(uint64_t x)
unsigned const MachineRegisterInfo * MRI
The instances of the Type class are immutable: once they are created, they are never changed...
static unsigned getAccessSize(unsigned int Flags)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
const MachineOperand & getOperand(unsigned i) const
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, BranchProbability Probability) const override
static const unsigned End
void setImm(int64_t immVal)
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
bool registerDefIsDead(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Returns true if the register is dead in this machine instruction.
self_iterator getIterator()
const PseudoSourceValue * getPseudoValue() const
bool empty() const
empty - Check if the array is empty.
bool isRxSBGMask(uint64_t Mask, unsigned BitSize, unsigned &Start, unsigned &End) const
unsigned getSubReg() const
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIdx, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool liveAt(SlotIndex index) const
static bool isImmLH(uint64_t Val)
T findFirstSet(T Val, ZeroBehavior ZB=ZB_Max)
Get the index of the first set bit starting from the least significant bit.
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...
static bool isHighReg(unsigned int Reg)
Iterator for intrusive lists based on ilist_node.
void replaceKillInstruction(unsigned Reg, MachineInstr &OldMI, MachineInstr &NewMI)
replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one...
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
constexpr bool isInt< 32 >(int64_t x)
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
CloneMachineInstr - Create a new MachineInstr which is a copy of the 'Orig' instruction, identical in all ways except the instruction has no parent, prev, or next.
MachineOperand class - Representation of each machine instruction operand.
static bool isStringOfOnes(uint64_t Mask, unsigned &LSB, unsigned &Length)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
const unsigned CCMASK_CMP_NE
const MachineInstrBuilder & addFrameIndex(int Idx) const
bool isCompare(QueryType Type=IgnoreBundle) const
Return true if this instruction is a comparison.
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MFI, MachineInstr &MI, LiveVariables *LV) const override
const Value * getValue() const
Return the base address of the memory access.
Special value supplied for machine level alias analysis.
static MachineInstr * finishConvertToThreeAddress(MachineInstr *OldMI, MachineInstr *NewMI, LiveVariables *LV)
static int isSimpleMove(const MachineInstr &MI, int &FrameIndex, unsigned Flag)
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
bool hasMiscellaneousExtensions() const
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
static MachineInstr * getDef(unsigned Reg, const MachineRegisterInfo *MRI)
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator)
createDeadDef - Make sure the range has a value defined at Def.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
void setReg(unsigned Reg)
Change the register this operand corresponds to.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
static MachineOperand CreateImm(int64_t Val)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
static bool isSimpleBD12Move(const MachineInstr *MI, unsigned Flag)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
unsigned getFusedCompare(unsigned Opcode, SystemZII::FusedCompareType Type, const MachineInstr *MI=nullptr) const
bool hasLoadAndTrap() const
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
unsigned getReg() const
getReg - Returns the register number.
bool hasDistinctOps() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
static bool isShift(MachineInstr *MI, unsigned Opcode, int64_t Imm)
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.
uint64_t getSize() const
Return the size in bytes of the memory reference.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
static bool isImmLL(uint64_t Val)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
SlotIndex - An opaque wrapper around machine indexes.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.