44 #define GET_INSTRINFO_CTOR_DTOR 45 #define GET_INSTRMAP_INFO 46 #include "SystemZGenInstrInfo.inc" 48 #define DEBUG_TYPE "systemz-II" 51 static uint64_t
allOnes(
unsigned int Count) {
52 return Count == 0 ? 0 : (uint64_t(1) << (Count - 1) << 1) - 1;
56 void SystemZInstrInfo::anchor() {}
66 unsigned NewOpcode)
const {
73 MBB->
insert(MI, EarlierMI);
81 HighRegOp.
setReg(RI.getSubReg(HighRegOp.
getReg(), SystemZ::subreg_h64));
82 LowRegOp.
setReg(RI.getSubReg(LowRegOp.
getReg(), SystemZ::subreg_l64));
109 assert(HighOpcode && LowOpcode &&
"Both offsets should be in range");
111 EarlierMI->
setDesc(
get(HighOpcode));
112 MI->setDesc(
get(LowOpcode));
126 assert(NewOpcode &&
"No support for huge argument lists yet");
127 MI->setDesc(
get(NewOpcode));
137 void SystemZInstrInfo::expandRIPseudo(
MachineInstr &MI,
unsigned LowOpcode,
139 bool ConvertHigh)
const {
142 MI.
setDesc(
get(IsHigh ? HighOpcode : LowOpcode));
143 if (IsHigh && ConvertHigh)
151 void SystemZInstrInfo::expandRIEPseudo(
MachineInstr &MI,
unsigned LowOpcode,
153 unsigned HighOpcode)
const {
158 if (!DestIsHigh && !SrcIsHigh)
161 if (DestReg != SrcReg) {
167 MI.
setDesc(
get(DestIsHigh ? HighOpcode : LowOpcode));
175 void SystemZInstrInfo::expandRXYPseudo(
MachineInstr &MI,
unsigned LowOpcode,
176 unsigned HighOpcode)
const {
187 void SystemZInstrInfo::expandLOCPseudo(
MachineInstr &MI,
unsigned LowOpcode,
188 unsigned HighOpcode)
const {
197 void SystemZInstrInfo::expandZExtPseudo(
MachineInstr &MI,
unsigned LowOpcode,
198 unsigned Size)
const {
211 void SystemZInstrInfo::expandLoadStackGuard(
MachineInstr *MI)
const {
215 const Register Reg32 = RI.getSubReg(Reg64, SystemZ::subreg_l32);
248 const DebugLoc &DL,
unsigned DestReg,
249 unsigned SrcReg,
unsigned LowLowOpcode,
250 unsigned Size,
bool KillSrc,
251 bool UndefSrc)
const {
255 if (DestIsHigh && SrcIsHigh)
256 Opcode = SystemZ::RISBHH;
257 else if (DestIsHigh && !SrcIsHigh)
258 Opcode = SystemZ::RISBHL;
259 else if (!DestIsHigh && SrcIsHigh)
260 Opcode = SystemZ::RISBLH;
262 return BuildMI(MBB, MBBI, DL,
get(LowLowOpcode), DestReg)
265 unsigned Rotate = (DestIsHigh != SrcIsHigh ? 32 : 0);
266 return BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
275 unsigned OpIdx2)
const {
283 case SystemZ::SELRMux:
284 case SystemZ::SELFHR:
287 case SystemZ::LOCRMux:
288 case SystemZ::LOCFHR:
290 case SystemZ::LOCGR: {
291 auto &WorkingMI = cloneIfNew(MI);
293 unsigned CCValid = WorkingMI.getOperand(3).getImm();
294 unsigned CCMask = WorkingMI.getOperand(4).getImm();
295 WorkingMI.getOperand(4).setImm(CCMask ^ CCValid);
332 int &SrcFrameIndex)
const {
348 DestFrameIndex = FI1;
357 bool AllowModify)
const {
363 while (I != MBB.
begin()) {
365 if (I->isDebugInstr())
370 if (!isUnpredicatedTerminator(*I))
395 while (std::next(I) != MBB.
end())
404 I->eraseFromParent();
425 assert(Cond.
size() == 2 && TBB &&
"Should have seen a conditional branch");
433 unsigned OldCCValid = Cond[0].getImm();
434 unsigned OldCCMask = Cond[1].getImm();
435 if (OldCCValid == Branch.
CCValid && OldCCMask == Branch.
CCMask)
446 int *BytesRemoved)
const {
447 assert(!BytesRemoved &&
"code size not handled");
453 while (I != MBB.
begin()) {
455 if (I->isDebugInstr())
462 I->eraseFromParent();
472 assert(Cond.
size() == 2 &&
"Invalid condition");
473 Cond[1].setImm(Cond[1].getImm() ^ Cond[0].getImm());
482 int *BytesAdded)
const {
488 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
490 "SystemZ branch conditions have one component!");
491 assert(!BytesAdded &&
"code size not handled");
495 assert(!FBB &&
"Unconditional branch with multiple successors!");
502 unsigned CCValid = Cond[0].getImm();
503 unsigned CCMask = Cond[1].getImm();
504 BuildMI(&MBB, DL,
get(SystemZ::BRC))
517 unsigned &SrcReg2,
int &
Mask,
519 assert(MI.
isCompare() &&
"Caller should have checked for a comparison");
535 unsigned TrueReg,
unsigned FalseReg,
536 int &CondCycles,
int &TrueCycles,
537 int &FalseCycles)
const {
541 if (Pred.
size() != 2)
553 SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) ||
554 SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
555 SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
568 const DebugLoc &DL,
unsigned DstReg,
571 unsigned FalseReg)
const {
575 assert(Pred.
size() == 2 &&
"Invalid condition");
576 unsigned CCValid = Pred[0].getImm();
577 unsigned CCMask = Pred[1].getImm();
580 if (SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) {
582 Opc = SystemZ::SELRMux;
584 Opc = SystemZ::LOCRMux;
590 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), TReg).
addReg(TrueReg);
591 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), FReg).
addReg(FalseReg);
595 }
else if (SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
597 Opc = SystemZ::SELGR;
599 Opc = SystemZ::LOCGR;
603 BuildMI(MBB, I, DL,
get(Opc), DstReg)
612 if (DefOpc != SystemZ::LHIMux && DefOpc != SystemZ::LHI &&
613 DefOpc != SystemZ::LGHI)
625 case SystemZ::SELRMux:
628 case SystemZ::LOCRMux:
631 NewUseOpc = SystemZ::LOCHIMux;
635 UseIdx = 2, CommuteIdx = 1;
645 NewUseOpc = SystemZ::LOCGHI;
649 UseIdx = 2, CommuteIdx = 1;
657 if (CommuteIdx != -1)
658 if (!commuteInstruction(UseMI,
false, CommuteIdx, UseIdx))
675 Opcode == SystemZ::Trap ||
676 Opcode == SystemZ::CallJG ||
677 Opcode == SystemZ::CallBR)
684 unsigned NumCycles,
unsigned ExtraPredCycles,
698 return NumCycles == 1;
703 unsigned NumCyclesT,
unsigned ExtraPredCyclesT,
705 unsigned NumCyclesF,
unsigned ExtraPredCyclesF,
715 return NumCycles == 1;
720 assert(Pred.
size() == 2 &&
"Invalid condition");
721 unsigned CCValid = Pred[0].getImm();
722 unsigned CCMask = Pred[1].getImm();
723 assert(CCMask > 0 && CCMask < 15 &&
"Invalid predicate");
725 if (Opcode == SystemZ::Trap) {
726 MI.
setDesc(
get(SystemZ::CondTrap));
728 .addImm(CCValid).
addImm(CCMask)
733 MI.
setDesc(
get(SystemZ::CondReturn));
735 .addImm(CCValid).
addImm(CCMask)
739 if (Opcode == SystemZ::CallJG) {
744 MI.
setDesc(
get(SystemZ::CallBRCL));
753 if (Opcode == SystemZ::CallBR) {
756 MI.
setDesc(
get(SystemZ::CallBCR));
758 .addImm(CCValid).
addImm(CCMask)
773 if (SystemZ::GR128BitRegClass.
contains(DestReg, SrcReg)) {
774 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_h64),
775 RI.getSubReg(SrcReg, SystemZ::subreg_h64), KillSrc);
778 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_l64),
779 RI.getSubReg(SrcReg, SystemZ::subreg_l64), KillSrc);
780 MachineInstrBuilder(*MBB.
getParent(), std::prev(MBBI))
785 if (SystemZ::GRX32BitRegClass.
contains(DestReg, SrcReg)) {
786 emitGRX32Move(MBB, MBBI, DL, DestReg, SrcReg, SystemZ::LR, 32, KillSrc,
792 if (SystemZ::VR128BitRegClass.
contains(DestReg) &&
793 SystemZ::FP128BitRegClass.
contains(SrcReg)) {
795 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_h64),
796 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
798 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_l64),
799 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
801 BuildMI(MBB, MBBI, DL,
get(SystemZ::VMRHG), DestReg)
806 if (SystemZ::FP128BitRegClass.
contains(DestReg) &&
807 SystemZ::VR128BitRegClass.
contains(SrcReg)) {
809 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_h64),
810 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
812 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_l64),
813 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
815 if (DestRegHi != SrcReg)
816 copyPhysReg(MBB, MBBI, DL, DestRegHi, SrcReg,
false);
817 BuildMI(MBB, MBBI, DL,
get(SystemZ::VREPG), DestRegLo)
823 if (SrcReg == SystemZ::CC) {
828 MIB->addRegisterKilled(SrcReg, TRI);
832 if (DestReg == SystemZ::CC) {
833 BuildMI(MBB, MBBI, DL,
get(SystemZ::TMLH))
841 if (SystemZ::GR64BitRegClass.
contains(DestReg, SrcReg))
842 Opcode = SystemZ::LGR;
843 else if (SystemZ::FP32BitRegClass.
contains(DestReg, SrcReg))
845 Opcode = STI.
hasVector() ? SystemZ::LDR32 : SystemZ::LER;
846 else if (SystemZ::FP64BitRegClass.
contains(DestReg, SrcReg))
848 else if (SystemZ::FP128BitRegClass.
contains(DestReg, SrcReg))
849 Opcode = SystemZ::LXR;
850 else if (SystemZ::VR32BitRegClass.
contains(DestReg, SrcReg))
851 Opcode = SystemZ::VLR32;
852 else if (SystemZ::VR64BitRegClass.
contains(DestReg, SrcReg))
853 Opcode = SystemZ::VLR64;
854 else if (SystemZ::VR128BitRegClass.
contains(DestReg, SrcReg))
855 Opcode = SystemZ::VLR;
856 else if (SystemZ::AR32BitRegClass.
contains(DestReg, SrcReg))
857 Opcode = SystemZ::CPYA;
858 else if (SystemZ::AR32BitRegClass.
contains(DestReg) &&
859 SystemZ::GR32BitRegClass.
contains(SrcReg))
860 Opcode = SystemZ::SAR;
861 else if (SystemZ::GR32BitRegClass.
contains(DestReg) &&
862 SystemZ::AR32BitRegClass.
contains(SrcReg))
863 Opcode = SystemZ::EAR;
867 BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
879 unsigned LoadOpcode, StoreOpcode;
894 unsigned LoadOpcode, StoreOpcode;
904 return ((MCID.
TSFlags & Flag) &&
913 LogicOp(
unsigned regSize,
unsigned immLSB,
unsigned immSize)
914 : RegSize(regSize), ImmLSB(immLSB), ImmSize(immSize) {}
916 explicit operator bool()
const {
return RegSize; }
918 unsigned RegSize = 0;
920 unsigned ImmSize = 0;
927 case SystemZ::NILMux:
return LogicOp(32, 0, 16);
928 case SystemZ::NIHMux:
return LogicOp(32, 16, 16);
929 case SystemZ::NILL64:
return LogicOp(64, 0, 16);
930 case SystemZ::NILH64:
return LogicOp(64, 16, 16);
931 case SystemZ::NIHL64:
return LogicOp(64, 32, 16);
932 case SystemZ::NIHH64:
return LogicOp(64, 48, 16);
933 case SystemZ::NIFMux:
return LogicOp(32, 0, 32);
934 case SystemZ::NILF64:
return LogicOp(64, 0, 32);
935 case SystemZ::NIHF64:
return LogicOp(64, 32, 32);
936 default:
return LogicOp();
943 if (CCDef !=
nullptr)
963 Imm |=
allOnes(And.RegSize) & ~(
allOnes(And.ImmSize) << And.ImmLSB);
967 if (And.RegSize == 64) {
968 NewOpcode = SystemZ::RISBG;
970 if (STI.hasMiscellaneousExtensions())
971 NewOpcode = SystemZ::RISBGN;
973 NewOpcode = SystemZ::RISBMux;
990 for (
unsigned I = 1;
I < NumOps; ++
I) {
1012 if (Ops.
size() == 2 && Ops[0] == 0 && Ops[1] == 1) {
1013 if (LIS !=
nullptr && (Opcode == SystemZ::LA || Opcode == SystemZ::LAY) &&
1024 if (!CCLiveRange.
liveAt(MISlot)) {
1040 if (Ops.
size() != 1)
1043 unsigned OpNum = Ops[0];
1047 "Invalid size combination");
1049 if ((Opcode == SystemZ::AHI || Opcode == SystemZ::AGHI) && OpNum == 0 &&
1052 Opcode = (Opcode == SystemZ::AHI ? SystemZ::ASI : SystemZ::AGSI);
1063 if ((Opcode == SystemZ::ALFI && OpNum == 0 &&
1065 (Opcode == SystemZ::ALGFI && OpNum == 0 &&
1068 Opcode = (Opcode == SystemZ::ALFI ? SystemZ::ALSI : SystemZ::ALGSI);
1078 if ((Opcode == SystemZ::SLFI && OpNum == 0 &&
1080 (Opcode == SystemZ::SLGFI && OpNum == 0 &&
1083 Opcode = (Opcode == SystemZ::SLFI ? SystemZ::ALSI : SystemZ::ALGSI);
1093 if (Opcode == SystemZ::LGDR || Opcode == SystemZ::LDGR) {
1094 bool Op0IsGPR = (Opcode == SystemZ::LGDR);
1095 bool Op1IsGPR = (Opcode == SystemZ::LDGR);
1099 unsigned StoreOpcode = Op1IsGPR ?
SystemZ::STG : SystemZ::STD;
1103 .addFrameIndex(FrameIndex)
1110 unsigned LoadOpcode = Op0IsGPR ? SystemZ::LG :
SystemZ::LD;
1114 .addFrameIndex(FrameIndex)
1145 .addMemOperand(MMO);
1164 int MemOpcode = SystemZ::getMemOpcode(Opcode);
1169 bool NeedsCommute =
false;
1174 assert(NumOps == 3 &&
"Expected two source registers.");
1182 if (DstPhys && !SystemZ::GRH32BitRegClass.
contains(DstPhys) && SrcReg &&
1184 DstPhys == VRM->
getPhys(SrcReg))
1185 NeedsCommute = (OpNum == 1);
1191 if (MemOpcode >= 0) {
1192 if ((OpNum == NumOps - 1) || NeedsCommute) {
1195 assert(AccessBytes != 0 &&
"Size of access should be known");
1196 assert(AccessBytes <= Size &&
"Access outside the frame index");
1197 uint64_t
Offset = Size - AccessBytes;
1204 for (
unsigned I = 1;
I < OpNum; ++
I)
1228 splitMove(MI, SystemZ::LG);
1231 case SystemZ::ST128:
1240 splitMove(MI, SystemZ::STD);
1243 case SystemZ::LBMux:
1244 expandRXYPseudo(MI, SystemZ::LB, SystemZ::LBH);
1247 case SystemZ::LHMux:
1248 expandRXYPseudo(MI, SystemZ::LH, SystemZ::LHH);
1251 case SystemZ::LLCRMux:
1252 expandZExtPseudo(MI, SystemZ::LLCR, 8);
1255 case SystemZ::LLHRMux:
1256 expandZExtPseudo(MI, SystemZ::LLHR, 16);
1259 case SystemZ::LLCMux:
1260 expandRXYPseudo(MI, SystemZ::LLC, SystemZ::LLCH);
1263 case SystemZ::LLHMux:
1264 expandRXYPseudo(MI, SystemZ::LLH, SystemZ::LLHH);
1268 expandRXYPseudo(MI, SystemZ::L, SystemZ::LFH);
1271 case SystemZ::LOCMux:
1272 expandLOCPseudo(MI, SystemZ::LOC, SystemZ::LOCFH);
1275 case SystemZ::LOCHIMux:
1276 expandLOCPseudo(MI, SystemZ::LOCHI, SystemZ::LOCHHI);
1279 case SystemZ::STCMux:
1280 expandRXYPseudo(MI, SystemZ::STC, SystemZ::STCH);
1283 case SystemZ::STHMux:
1284 expandRXYPseudo(MI, SystemZ::STH, SystemZ::STHH);
1287 case SystemZ::STMux:
1291 case SystemZ::STOCMux:
1292 expandLOCPseudo(MI, SystemZ::STOC, SystemZ::STOCFH);
1295 case SystemZ::LHIMux:
1296 expandRIPseudo(MI, SystemZ::LHI, SystemZ::IIHF,
true);
1299 case SystemZ::IIFMux:
1300 expandRIPseudo(MI, SystemZ::IILF, SystemZ::IIHF,
false);
1303 case SystemZ::IILMux:
1304 expandRIPseudo(MI, SystemZ::IILL, SystemZ::IIHL,
false);
1307 case SystemZ::IIHMux:
1308 expandRIPseudo(MI, SystemZ::IILH, SystemZ::IIHH,
false);
1311 case SystemZ::NIFMux:
1312 expandRIPseudo(MI, SystemZ::NILF, SystemZ::NIHF,
false);
1315 case SystemZ::NILMux:
1316 expandRIPseudo(MI, SystemZ::NILL, SystemZ::NIHL,
false);
1319 case SystemZ::NIHMux:
1320 expandRIPseudo(MI, SystemZ::NILH, SystemZ::NIHH,
false);
1323 case SystemZ::OIFMux:
1324 expandRIPseudo(MI, SystemZ::OILF, SystemZ::OIHF,
false);
1327 case SystemZ::OILMux:
1328 expandRIPseudo(MI, SystemZ::OILL, SystemZ::OIHL,
false);
1331 case SystemZ::OIHMux:
1332 expandRIPseudo(MI, SystemZ::OILH, SystemZ::OIHH,
false);
1335 case SystemZ::XIFMux:
1336 expandRIPseudo(MI, SystemZ::XILF, SystemZ::XIHF,
false);
1339 case SystemZ::TMLMux:
1340 expandRIPseudo(MI, SystemZ::TMLL, SystemZ::TMHL,
false);
1343 case SystemZ::TMHMux:
1344 expandRIPseudo(MI, SystemZ::TMLH, SystemZ::TMHH,
false);
1347 case SystemZ::AHIMux:
1348 expandRIPseudo(MI, SystemZ::AHI, SystemZ::AIH,
false);
1351 case SystemZ::AHIMuxK:
1352 expandRIEPseudo(MI, SystemZ::AHI, SystemZ::AHIK, SystemZ::AIH);
1355 case SystemZ::AFIMux:
1356 expandRIPseudo(MI, SystemZ::AFI, SystemZ::AIH,
false);
1359 case SystemZ::CHIMux:
1360 expandRIPseudo(MI, SystemZ::CHI, SystemZ::CIH,
false);
1363 case SystemZ::CFIMux:
1364 expandRIPseudo(MI, SystemZ::CFI, SystemZ::CIH,
false);
1367 case SystemZ::CLFIMux:
1368 expandRIPseudo(MI, SystemZ::CLFI, SystemZ::CLIH,
false);
1372 expandRXYPseudo(MI,
SystemZ::C, SystemZ::CHF);
1375 case SystemZ::CLMux:
1376 expandRXYPseudo(MI, SystemZ::CL, SystemZ::CLHF);
1379 case SystemZ::RISBMux: {
1382 if (SrcIsHigh == DestIsHigh)
1383 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHH : SystemZ::RISBLL));
1385 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHL : SystemZ::RISBLH));
1392 splitAdjDynAlloc(MI);
1395 case TargetOpcode::LOAD_STACK_GUARD:
1396 expandLoadStackGuard(&MI);
1429 case SystemZ::BRCTH:
1433 case SystemZ::BRCTG:
1452 case SystemZ::CLGIJ:
1453 case SystemZ::CLGRJ:
1467 unsigned &LoadOpcode,
1468 unsigned &StoreOpcode)
const {
1469 if (RC == &SystemZ::GR32BitRegClass || RC == &SystemZ::ADDR32BitRegClass) {
1470 LoadOpcode = SystemZ::L;
1472 }
else if (RC == &SystemZ::GRH32BitRegClass) {
1473 LoadOpcode = SystemZ::LFH;
1474 StoreOpcode = SystemZ::STFH;
1475 }
else if (RC == &SystemZ::GRX32BitRegClass) {
1476 LoadOpcode = SystemZ::LMux;
1477 StoreOpcode = SystemZ::STMux;
1478 }
else if (RC == &SystemZ::GR64BitRegClass ||
1479 RC == &SystemZ::ADDR64BitRegClass) {
1480 LoadOpcode = SystemZ::LG;
1482 }
else if (RC == &SystemZ::GR128BitRegClass ||
1483 RC == &SystemZ::ADDR128BitRegClass) {
1484 LoadOpcode = SystemZ::L128;
1485 StoreOpcode = SystemZ::ST128;
1486 }
else if (RC == &SystemZ::FP32BitRegClass) {
1488 StoreOpcode = SystemZ::STE;
1489 }
else if (RC == &SystemZ::FP64BitRegClass) {
1491 StoreOpcode = SystemZ::STD;
1492 }
else if (RC == &SystemZ::FP128BitRegClass) {
1493 LoadOpcode = SystemZ::LX;
1494 StoreOpcode = SystemZ::STX;
1495 }
else if (RC == &SystemZ::VR32BitRegClass) {
1496 LoadOpcode = SystemZ::VL32;
1497 StoreOpcode = SystemZ::VST32;
1498 }
else if (RC == &SystemZ::VR64BitRegClass) {
1499 LoadOpcode = SystemZ::VL64;
1500 StoreOpcode = SystemZ::VST64;
1501 }
else if (RC == &SystemZ::VF128BitRegClass ||
1502 RC == &SystemZ::VR128BitRegClass) {
1503 LoadOpcode = SystemZ::VL;
1504 StoreOpcode = SystemZ::VST;
1513 if (isUInt<12>(Offset) && isUInt<12>(Offset2)) {
1515 int Disp12Opcode = SystemZ::getDisp12Opcode(Opcode);
1516 if (Disp12Opcode >= 0)
1517 return Disp12Opcode;
1523 if (isInt<20>(Offset) && isInt<20>(Offset2)) {
1525 int Disp20Opcode = SystemZ::getDisp20Opcode(Opcode);
1526 if (Disp20Opcode >= 0)
1527 return Disp20Opcode;
1540 case SystemZ::LG:
return SystemZ::LTG;
1541 case SystemZ::LGF:
return SystemZ::LTGF;
1542 case SystemZ::LR:
return SystemZ::LTR;
1543 case SystemZ::LGFR:
return SystemZ::LTGFR;
1544 case SystemZ::LGR:
return SystemZ::LTGR;
1545 case SystemZ::LER:
return SystemZ::LTEBR;
1547 case SystemZ::LXR:
return SystemZ::LTXBR;
1548 case SystemZ::LCDFR:
return SystemZ::LCDBR;
1549 case SystemZ::LPDFR:
return SystemZ::LPDBR;
1550 case SystemZ::LNDFR:
return SystemZ::LNDBR;
1551 case SystemZ::LCDFR_32:
return SystemZ::LCEBR;
1552 case SystemZ::LPDFR_32:
return SystemZ::LPEBR;
1553 case SystemZ::LNDFR_32:
return SystemZ::LNEBR;
1558 case SystemZ::RISBGN:
return SystemZ::RISBG;
1568 uint64_t Top = (Mask >> First) + 1;
1569 if ((Top & -Top) == Top) {
1578 unsigned &Start,
unsigned &End)
const {
1586 unsigned LSB, Length;
1588 Start = 63 - (LSB + Length - 1);
1596 assert(LSB > 0 &&
"Bottom bit must be set");
1597 assert(LSB + Length < BitSize &&
"Top bit must be set");
1598 Start = 63 - (LSB - 1);
1599 End = 63 - (LSB + Length);
1616 case SystemZ::CLGFI:
1622 if (!STI.hasMiscellaneousExtensions())
1632 return SystemZ::CRJ;
1634 return SystemZ::CGRJ;
1636 return SystemZ::CIJ;
1638 return SystemZ::CGIJ;
1640 return SystemZ::CLRJ;
1642 return SystemZ::CLGRJ;
1644 return SystemZ::CLIJ;
1645 case SystemZ::CLGFI:
1646 return SystemZ::CLGIJ;
1653 return SystemZ::CRBReturn;
1655 return SystemZ::CGRBReturn;
1657 return SystemZ::CIBReturn;
1659 return SystemZ::CGIBReturn;
1661 return SystemZ::CLRBReturn;
1663 return SystemZ::CLGRBReturn;
1665 return SystemZ::CLIBReturn;
1666 case SystemZ::CLGFI:
1667 return SystemZ::CLGIBReturn;
1674 return SystemZ::CRBCall;
1676 return SystemZ::CGRBCall;
1678 return SystemZ::CIBCall;
1680 return SystemZ::CGIBCall;
1682 return SystemZ::CLRBCall;
1684 return SystemZ::CLGRBCall;
1686 return SystemZ::CLIBCall;
1687 case SystemZ::CLGFI:
1688 return SystemZ::CLGIBCall;
1695 return SystemZ::CRT;
1697 return SystemZ::CGRT;
1699 return SystemZ::CIT;
1701 return SystemZ::CGIT;
1703 return SystemZ::CLRT;
1705 return SystemZ::CLGRT;
1707 return SystemZ::CLFIT;
1708 case SystemZ::CLGFI:
1709 return SystemZ::CLGIT;
1711 return SystemZ::CLT;
1713 return SystemZ::CLGT;
1722 if (!STI.hasLoadAndTrap())
1727 return SystemZ::LAT;
1729 return SystemZ::LGAT;
1731 return SystemZ::LFHAT;
1733 return SystemZ::LLGFAT;
1735 return SystemZ::LLGTAT;
1742 unsigned Reg, uint64_t
Value)
const {
1746 Opcode = SystemZ::LGHI;
1748 Opcode = SystemZ::LLILL;
1750 Opcode = SystemZ::LLILH;
1754 Opcode = SystemZ::LGFI;
1773 ErrInfo =
"Addressing mode operands corrupt!";
1796 bool SameVal = (VALa && VALb && (VALa == VALb));
1800 if (PSVa && PSVb && (PSVa == PSVb))
1806 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1807 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1808 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1809 if (LowOffset + LowWidth <= HighOffset)
static void transferMIFlag(MachineInstr *OldMI, MachineInstr *NewMI, MachineInstr::MIFlag Flag)
void loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Reg, uint64_t Value) const
const MachineInstrBuilder & add(const MachineOperand &MO) const
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
bool expandPostRAPseudo(MachineInstr &MBBI) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Wrapper class representing physical registers. Should be passed by value.
const int64_t CallFrameSize
SystemZInstrInfo(SystemZSubtarget &STI)
This class represents lattice values for constants.
MachineBasicBlock * getMBBTarget()
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &Mask, int &Value) const override
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Describe properties that are true of each instruction in the target description file.
unsigned getSubReg() const
bool hasLoadStoreOnCond() const
constexpr bool isInt< 8 >(int64_t x)
uint64_t getSize() const
Return the size in bytes of the memory reference.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
void setIsDead(bool Val=true)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
const unsigned CCMASK_ICMP
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const override
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const override
return AArch64::GPR64RegClass contains(Reg)
static uint64_t allOnes(unsigned int Count)
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
This class represents the liveness of a register, stack slot, etc.
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher...
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
A description of a memory reference used in the backend.
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
unsigned getNumOperands() const
Retuns the total number of operands.
VNInfo::Allocator & getVNInfoAllocator()
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.
SlotIndex getInstructionIndex(const MachineInstr &MI) const
Returns the base index for the given instruction.
unsigned getLoadAndTest(unsigned Opcode) const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const char * getSymbolName() const
unsigned getLoadAndTrap(unsigned Opcode) const
uint8_t OperandType
Information about the type of the operand.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static LogicOp interpretAndImmediate(unsigned Opcode)
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool isHighReg(unsigned int Reg)
bool isPredicable(const MachineInstr &MI) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
void setReg(Register Reg)
Change the register this operand corresponds to.
const unsigned CCMASK_ANY
int getTwoOperandOpcode(uint16_t Opcode)
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
bool hasMiscellaneousExtensions3() const
unsigned getUndefRegState(bool B)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
bool isStackSlotCopy(const MachineInstr &MI, int &DestFrameIndex, int &SrcFrameIndex) const override
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc)
createDeadDef - Make sure the range has a value defined at Def.
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...
BasicBlockListType::iterator iterator
unsigned getKillRegState(bool B)
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 Value * getValue() const
Return the base address of the memory access.
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.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
static void transferDeadCC(MachineInstr *OldMI, MachineInstr *NewMI)
Control flow instructions. These all have token chains.
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...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static unsigned getAccessSize(unsigned int Flags)
bool isCompare(QueryType Type=IgnoreBundle) const
Return true if this instruction is a comparison.
bool liveAt(SlotIndex index) const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset) const
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
void setFlag(MIFlag Flag)
Set a MI flag.
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, BranchProbability Probability) const override
const PseudoSourceValue * getPseudoValue() const
void setImm(int64_t immVal)
const MachineInstrBuilder & addFrameIndex(int Idx) 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...
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
MachineOperand * findRegisterDefOperand(Register Reg, bool isDead=false, bool Overlap=false, const TargetRegisterInfo *TRI=nullptr)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
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...
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
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)
unsigned getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call...
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
MachineOperand class - Representation of each machine instruction operand.
MachineInstrBuilder MachineInstrBuilder & DefMI
static bool isStringOfOnes(uint64_t Mask, unsigned &LSB, unsigned &Length)
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Promote Memory to Register
const unsigned CCMASK_CMP_NE
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MFI, MachineInstr &MI, LiveVariables *LV) 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...
const uint32_t * getRegMask() const
getRegMask - Returns a bit mask of registers preserved by this RegMask operand.
Special value supplied for machine level alias analysis.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
static int isSimpleMove(const MachineInstr &MI, int &FrameIndex, unsigned Flag)
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
void getLoadStoreOpcodes(const TargetRegisterClass *RC, unsigned &LoadOpcode, unsigned &StoreOpcode) const
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Register getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
LLVM_NODISCARD bool empty() const
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
unsigned getFusedCompare(unsigned Opcode, SystemZII::FusedCompareType Type, const MachineInstr *MI=nullptr) const
static MachineOperand CreateImm(int64_t Val)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
static bool isSimpleBD12Move(const MachineInstr *MI, unsigned Flag)
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
SlotIndexes * getSlotIndexes() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Returns true if the register is dead in this machine instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
SystemZII::Branch getBranchInfo(const MachineInstr &MI) const
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
LLVM Value Representation.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const MCOperandInfo * OpInfo
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
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)
bool isRxSBGMask(uint64_t Mask, unsigned BitSize, unsigned &Start, unsigned &End) const
StringRef - Represent a constant reference to a string, i.e.
void RemoveOperand(unsigned OpNo)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
Register getReg() const
getReg - Returns the register number.
This holds information about one operand of a machine instruction, indicating the register class for ...
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool hasLoadStoreOnCond2() const
const MachineOperand & getOperand(unsigned i) const
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
SlotIndex - An opaque wrapper around machine indexes.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
bool isCommutable(QueryType Type=IgnoreBundle) const
Return true if this may be a 2- or 3-address instruction (of the form "X = op Y, Z, ..."), which produces the same result if Y and Z are exchanged.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.