45 #define GET_INSTRINFO_CTOR_DTOR 46 #define GET_INSTRMAP_INFO 47 #include "SystemZGenInstrInfo.inc" 49 #define DEBUG_TYPE "systemz-II" 50 STATISTIC(LOCRMuxJumps,
"Number of LOCRMux jump-sequences (lower is better)");
53 static uint64_t
allOnes(
unsigned int Count) {
54 return Count == 0 ? 0 : (uint64_t(1) << (Count - 1) << 1) - 1;
60 if (SystemZ::GRH32BitRegClass.
contains(Reg))
67 void SystemZInstrInfo::anchor() {}
77 unsigned NewOpcode)
const {
84 MBB->
insert(MI, EarlierMI);
89 unsigned Reg128 = LowRegOp.
getReg();
92 HighRegOp.
setReg(RI.getSubReg(HighRegOp.
getReg(), SystemZ::subreg_h64));
93 LowRegOp.
setReg(RI.getSubReg(LowRegOp.
getReg(), SystemZ::subreg_l64));
120 assert(HighOpcode && LowOpcode &&
"Both offsets should be in range");
122 EarlierMI->
setDesc(
get(HighOpcode));
123 MI->setDesc(
get(LowOpcode));
137 assert(NewOpcode &&
"No support for huge argument lists yet");
138 MI->setDesc(
get(NewOpcode));
148 void SystemZInstrInfo::expandRIPseudo(
MachineInstr &MI,
unsigned LowOpcode,
150 bool ConvertHigh)
const {
153 MI.
setDesc(
get(IsHigh ? HighOpcode : LowOpcode));
154 if (IsHigh && ConvertHigh)
162 void SystemZInstrInfo::expandRIEPseudo(
MachineInstr &MI,
unsigned LowOpcode,
164 unsigned HighOpcode)
const {
169 if (!DestIsHigh && !SrcIsHigh)
175 MI.
setDesc(
get(DestIsHigh ? HighOpcode : LowOpcode));
184 void SystemZInstrInfo::expandRXYPseudo(
MachineInstr &MI,
unsigned LowOpcode,
185 unsigned HighOpcode)
const {
195 void SystemZInstrInfo::expandLOCPseudo(
MachineInstr &MI,
unsigned LowOpcode,
196 unsigned HighOpcode)
const {
198 unsigned Opcode =
isHighReg(Reg) ? HighOpcode : LowOpcode;
205 void SystemZInstrInfo::expandLOCRPseudo(
MachineInstr &MI,
unsigned LowOpcode,
206 unsigned HighOpcode)
const {
212 if (!DestIsHigh && !SrcIsHigh)
214 else if (DestIsHigh && SrcIsHigh)
228 void SystemZInstrInfo::expandZExtPseudo(
MachineInstr &MI,
unsigned LowOpcode,
229 unsigned Size)
const {
242 void SystemZInstrInfo::expandLoadStackGuard(
MachineInstr *MI)
const {
246 const unsigned Reg32 = RI.getSubReg(Reg64, SystemZ::subreg_l32);
279 const DebugLoc &DL,
unsigned DestReg,
280 unsigned SrcReg,
unsigned LowLowOpcode,
281 unsigned Size,
bool KillSrc,
282 bool UndefSrc)
const {
286 if (DestIsHigh && SrcIsHigh)
287 Opcode = SystemZ::RISBHH;
288 else if (DestIsHigh && !SrcIsHigh)
289 Opcode = SystemZ::RISBHL;
290 else if (!DestIsHigh && SrcIsHigh)
291 Opcode = SystemZ::RISBLH;
293 return BuildMI(MBB, MBBI, DL,
get(LowLowOpcode), DestReg)
296 unsigned Rotate = (DestIsHigh != SrcIsHigh ? 32 : 0);
297 return BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
306 unsigned OpIdx2)
const {
314 case SystemZ::LOCRMux:
315 case SystemZ::LOCFHR:
317 case SystemZ::LOCGR: {
318 auto &WorkingMI = cloneIfNew(MI);
320 unsigned CCValid = WorkingMI.getOperand(3).getImm();
321 unsigned CCMask = WorkingMI.getOperand(4).getImm();
322 WorkingMI.getOperand(4).setImm(CCMask ^ CCValid);
359 int &SrcFrameIndex)
const {
375 DestFrameIndex = FI1;
384 bool AllowModify)
const {
390 while (I != MBB.
begin()) {
392 if (I->isDebugInstr())
397 if (!isUnpredicatedTerminator(*I))
422 while (std::next(I) != MBB.
end())
431 I->eraseFromParent();
452 assert(Cond.
size() == 2 && TBB &&
"Should have seen a conditional branch");
460 unsigned OldCCValid = Cond[0].getImm();
461 unsigned OldCCMask = Cond[1].getImm();
462 if (OldCCValid == Branch.
CCValid && OldCCMask == Branch.
CCMask)
473 int *BytesRemoved)
const {
474 assert(!BytesRemoved &&
"code size not handled");
480 while (I != MBB.
begin()) {
482 if (I->isDebugInstr())
489 I->eraseFromParent();
499 assert(Cond.
size() == 2 &&
"Invalid condition");
500 Cond[1].setImm(Cond[1].getImm() ^ Cond[0].getImm());
509 int *BytesAdded)
const {
515 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
517 "SystemZ branch conditions have one component!");
518 assert(!BytesAdded &&
"code size not handled");
522 assert(!FBB &&
"Unconditional branch with multiple successors!");
529 unsigned CCValid = Cond[0].getImm();
530 unsigned CCMask = Cond[1].getImm();
531 BuildMI(&MBB, DL,
get(SystemZ::BRC))
544 unsigned &SrcReg2,
int &
Mask,
546 assert(MI.
isCompare() &&
"Caller should have checked for a comparison");
590 if (RLL && RLL->
getOpcode() == SystemZ::LGFR) {
594 if (!RLL || !
isShift(RLL, SystemZ::RLL, 31))
609 for (++MBBI; MBBI != MBBE; ++MBBI) {
628 assert(!SrcReg2 &&
"Only optimizing constant comparisons so far");
630 return Value == 0 && !IsLogical &&
636 unsigned TrueReg,
unsigned FalseReg,
637 int &CondCycles,
int &TrueCycles,
638 int &FalseCycles)
const {
642 if (Pred.
size() != 2)
654 SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) ||
655 SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
656 SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
669 const DebugLoc &DL,
unsigned DstReg,
672 unsigned FalseReg)
const {
676 assert(Pred.
size() == 2 &&
"Invalid condition");
677 unsigned CCValid = Pred[0].getImm();
678 unsigned CCMask = Pred[1].getImm();
681 if (SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) {
683 Opc = SystemZ::LOCRMux;
689 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), TReg).
addReg(TrueReg);
690 BuildMI(MBB, I, DL,
get(TargetOpcode::COPY), FReg).
addReg(FalseReg);
694 }
else if (SystemZ::GR64BitRegClass.hasSubClassEq(RC))
695 Opc = SystemZ::LOCGR;
699 BuildMI(MBB, I, DL,
get(Opc), DstReg)
708 if (DefOpc != SystemZ::LHIMux && DefOpc != SystemZ::LHI &&
709 DefOpc != SystemZ::LGHI)
720 case SystemZ::LOCRMux:
723 NewUseOpc = SystemZ::LOCHIMux;
727 UseIdx = 2, CommuteIdx = 1;
734 NewUseOpc = SystemZ::LOCGHI;
738 UseIdx = 2, CommuteIdx = 1;
746 if (CommuteIdx != -1)
747 if (!commuteInstruction(UseMI,
false, CommuteIdx, UseIdx))
763 Opcode == SystemZ::CallJG ||
764 Opcode == SystemZ::CallBR)
771 unsigned NumCycles,
unsigned ExtraPredCycles,
785 return NumCycles == 1;
790 unsigned NumCyclesT,
unsigned ExtraPredCyclesT,
792 unsigned NumCyclesF,
unsigned ExtraPredCyclesF,
802 return NumCycles == 1;
807 assert(Pred.
size() == 2 &&
"Invalid condition");
808 unsigned CCValid = Pred[0].getImm();
809 unsigned CCMask = Pred[1].getImm();
810 assert(CCMask > 0 && CCMask < 15 &&
"Invalid predicate");
813 MI.
setDesc(
get(SystemZ::CondTrap));
815 .addImm(CCValid).
addImm(CCMask)
820 MI.
setDesc(
get(SystemZ::CondReturn));
822 .addImm(CCValid).
addImm(CCMask)
826 if (Opcode == SystemZ::CallJG) {
831 MI.
setDesc(
get(SystemZ::CallBRCL));
840 if (Opcode == SystemZ::CallBR) {
843 MI.
setDesc(
get(SystemZ::CallBCR));
845 .addImm(CCValid).
addImm(CCMask)
855 const DebugLoc &DL,
unsigned DestReg,
856 unsigned SrcReg,
bool KillSrc)
const {
860 if (SystemZ::GR128BitRegClass.
contains(DestReg, SrcReg)) {
861 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_h64),
862 RI.getSubReg(SrcReg, SystemZ::subreg_h64), KillSrc);
865 copyPhysReg(MBB, MBBI, DL, RI.getSubReg(DestReg, SystemZ::subreg_l64),
866 RI.getSubReg(SrcReg, SystemZ::subreg_l64), KillSrc);
867 MachineInstrBuilder(*MBB.
getParent(), std::prev(MBBI))
872 if (SystemZ::GRX32BitRegClass.
contains(DestReg, SrcReg)) {
873 emitGRX32Move(MBB, MBBI, DL, DestReg, SrcReg, SystemZ::LR, 32, KillSrc,
879 if (SystemZ::VR128BitRegClass.
contains(DestReg) &&
880 SystemZ::FP128BitRegClass.
contains(SrcReg)) {
882 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_h64),
883 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
885 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_l64),
886 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
888 BuildMI(MBB, MBBI, DL,
get(SystemZ::VMRHG), DestReg)
893 if (SystemZ::FP128BitRegClass.
contains(DestReg) &&
894 SystemZ::VR128BitRegClass.
contains(SrcReg)) {
896 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_h64),
897 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
899 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_l64),
900 SystemZ::subreg_r64, &SystemZ::VR128BitRegClass);
902 if (DestRegHi != SrcReg)
903 copyPhysReg(MBB, MBBI, DL, DestRegHi, SrcReg,
false);
904 BuildMI(MBB, MBBI, DL,
get(SystemZ::VREPG), DestRegLo)
910 if (SrcReg == SystemZ::CC) {
915 MIB->addRegisterKilled(SrcReg, TRI);
919 if (DestReg == SystemZ::CC) {
920 BuildMI(MBB, MBBI, DL,
get(SystemZ::TMLH))
928 if (SystemZ::GR64BitRegClass.
contains(DestReg, SrcReg))
929 Opcode = SystemZ::LGR;
930 else if (SystemZ::FP32BitRegClass.
contains(DestReg, SrcReg))
932 Opcode = STI.
hasVector() ? SystemZ::LDR32 : SystemZ::LER;
933 else if (SystemZ::FP64BitRegClass.
contains(DestReg, SrcReg))
935 else if (SystemZ::FP128BitRegClass.
contains(DestReg, SrcReg))
936 Opcode = SystemZ::LXR;
937 else if (SystemZ::VR32BitRegClass.
contains(DestReg, SrcReg))
938 Opcode = SystemZ::VLR32;
939 else if (SystemZ::VR64BitRegClass.
contains(DestReg, SrcReg))
940 Opcode = SystemZ::VLR64;
941 else if (SystemZ::VR128BitRegClass.
contains(DestReg, SrcReg))
942 Opcode = SystemZ::VLR;
943 else if (SystemZ::AR32BitRegClass.
contains(DestReg, SrcReg))
944 Opcode = SystemZ::CPYA;
945 else if (SystemZ::AR32BitRegClass.
contains(DestReg) &&
946 SystemZ::GR32BitRegClass.
contains(SrcReg))
947 Opcode = SystemZ::SAR;
948 else if (SystemZ::GR32BitRegClass.
contains(DestReg) &&
949 SystemZ::AR32BitRegClass.
contains(SrcReg))
950 Opcode = SystemZ::EAR;
954 BuildMI(MBB, MBBI, DL,
get(Opcode), DestReg)
966 unsigned LoadOpcode, StoreOpcode;
981 unsigned LoadOpcode, StoreOpcode;
991 return ((MCID.
TSFlags & Flag) &&
1000 LogicOp(
unsigned regSize,
unsigned immLSB,
unsigned immSize)
1001 : RegSize(regSize), ImmLSB(immLSB), ImmSize(immSize) {}
1003 explicit operator bool()
const {
return RegSize; }
1005 unsigned RegSize = 0;
1006 unsigned ImmLSB = 0;
1007 unsigned ImmSize = 0;
1014 case SystemZ::NILMux:
return LogicOp(32, 0, 16);
1015 case SystemZ::NIHMux:
return LogicOp(32, 16, 16);
1016 case SystemZ::NILL64:
return LogicOp(64, 0, 16);
1017 case SystemZ::NILH64:
return LogicOp(64, 16, 16);
1018 case SystemZ::NIHL64:
return LogicOp(64, 32, 16);
1019 case SystemZ::NIHH64:
return LogicOp(64, 48, 16);
1020 case SystemZ::NIFMux:
return LogicOp(32, 0, 32);
1021 case SystemZ::NILF64:
return LogicOp(64, 0, 32);
1022 case SystemZ::NIHF64:
return LogicOp(64, 32, 32);
1023 default:
return LogicOp();
1030 if (CCDef !=
nullptr)
1042 for (
unsigned I = 1;
I < NumOps; ++
I) {
1065 if (STI.hasDistinctOps()) {
1068 unsigned DestReg = Dest.
getReg();
1069 unsigned SrcReg = Src.
getReg();
1073 if (Opcode == SystemZ::AHIMux &&
1081 int ThreeOperandOpcode = SystemZ::getThreeOperandOpcode(Opcode);
1082 if (ThreeOperandOpcode >= 0) {
1093 for (
unsigned I = 2;
I < NumOps; ++
I)
1104 Imm |=
allOnes(And.RegSize) & ~(
allOnes(And.ImmSize) << And.ImmLSB);
1105 unsigned Start, End;
1108 if (And.RegSize == 64) {
1109 NewOpcode = SystemZ::RISBG;
1111 if (STI.hasMiscellaneousExtensions())
1112 NewOpcode = SystemZ::RISBGN;
1114 NewOpcode = SystemZ::RISBMux;
1144 if (Ops.
size() == 2 && Ops[0] == 0 && Ops[1] == 1) {
1145 if (LIS !=
nullptr && (Opcode == SystemZ::LA || Opcode == SystemZ::LAY) &&
1156 if (!CCLiveRange.
liveAt(MISlot)) {
1172 if (Ops.
size() != 1)
1175 unsigned OpNum = Ops[0];
1179 "Invalid size combination");
1181 if ((Opcode == SystemZ::AHI || Opcode == SystemZ::AGHI) && OpNum == 0 &&
1184 Opcode = (Opcode == SystemZ::AHI ? SystemZ::ASI : SystemZ::AGSI);
1194 if ((Opcode == SystemZ::ALFI && OpNum == 0 &&
1196 (Opcode == SystemZ::ALGFI && OpNum == 0 &&
1199 Opcode = (Opcode == SystemZ::ALFI ? SystemZ::ALSI : SystemZ::ALGSI);
1209 if ((Opcode == SystemZ::SLFI && OpNum == 0 &&
1211 (Opcode == SystemZ::SLGFI && OpNum == 0 &&
1214 Opcode = (Opcode == SystemZ::SLFI ? SystemZ::ALSI : SystemZ::ALGSI);
1224 if (Opcode == SystemZ::LGDR || Opcode == SystemZ::LDGR) {
1225 bool Op0IsGPR = (Opcode == SystemZ::LGDR);
1226 bool Op1IsGPR = (Opcode == SystemZ::LDGR);
1230 unsigned StoreOpcode = Op1IsGPR ? SystemZ::STG : SystemZ::STD;
1234 .addFrameIndex(FrameIndex)
1241 unsigned LoadOpcode = Op0IsGPR ? SystemZ::LG :
SystemZ::LD;
1245 .addFrameIndex(FrameIndex)
1276 .addMemOperand(MMO);
1294 int MemOpcode = SystemZ::getMemOpcode(Opcode);
1295 if (MemOpcode >= 0) {
1297 if (OpNum == NumOps - 1) {
1300 assert(AccessBytes != 0 &&
"Size of access should be known");
1301 assert(AccessBytes <= Size &&
"Access outside the frame index");
1302 uint64_t
Offset = Size - AccessBytes;
1305 for (
unsigned I = 0;
I < OpNum; ++
I)
1328 splitMove(MI, SystemZ::LG);
1331 case SystemZ::ST128:
1332 splitMove(MI, SystemZ::STG);
1340 splitMove(MI, SystemZ::STD);
1343 case SystemZ::LBMux:
1344 expandRXYPseudo(MI, SystemZ::LB, SystemZ::LBH);
1347 case SystemZ::LHMux:
1348 expandRXYPseudo(MI, SystemZ::LH, SystemZ::LHH);
1351 case SystemZ::LLCRMux:
1352 expandZExtPseudo(MI, SystemZ::LLCR, 8);
1355 case SystemZ::LLHRMux:
1356 expandZExtPseudo(MI, SystemZ::LLHR, 16);
1359 case SystemZ::LLCMux:
1360 expandRXYPseudo(MI, SystemZ::LLC, SystemZ::LLCH);
1363 case SystemZ::LLHMux:
1364 expandRXYPseudo(MI, SystemZ::LLH, SystemZ::LLHH);
1368 expandRXYPseudo(MI, SystemZ::L, SystemZ::LFH);
1371 case SystemZ::LOCMux:
1372 expandLOCPseudo(MI, SystemZ::LOC, SystemZ::LOCFH);
1375 case SystemZ::LOCHIMux:
1376 expandLOCPseudo(MI, SystemZ::LOCHI, SystemZ::LOCHHI);
1379 case SystemZ::LOCRMux:
1380 expandLOCRPseudo(MI, SystemZ::LOCR, SystemZ::LOCFHR);
1383 case SystemZ::STCMux:
1384 expandRXYPseudo(MI, SystemZ::STC, SystemZ::STCH);
1387 case SystemZ::STHMux:
1388 expandRXYPseudo(MI, SystemZ::STH, SystemZ::STHH);
1391 case SystemZ::STMux:
1395 case SystemZ::STOCMux:
1396 expandLOCPseudo(MI, SystemZ::STOC, SystemZ::STOCFH);
1399 case SystemZ::LHIMux:
1400 expandRIPseudo(MI, SystemZ::LHI, SystemZ::IIHF,
true);
1403 case SystemZ::IIFMux:
1404 expandRIPseudo(MI, SystemZ::IILF, SystemZ::IIHF,
false);
1407 case SystemZ::IILMux:
1408 expandRIPseudo(MI, SystemZ::IILL, SystemZ::IIHL,
false);
1411 case SystemZ::IIHMux:
1412 expandRIPseudo(MI, SystemZ::IILH, SystemZ::IIHH,
false);
1415 case SystemZ::NIFMux:
1416 expandRIPseudo(MI, SystemZ::NILF, SystemZ::NIHF,
false);
1419 case SystemZ::NILMux:
1420 expandRIPseudo(MI, SystemZ::NILL, SystemZ::NIHL,
false);
1423 case SystemZ::NIHMux:
1424 expandRIPseudo(MI, SystemZ::NILH, SystemZ::NIHH,
false);
1427 case SystemZ::OIFMux:
1428 expandRIPseudo(MI, SystemZ::OILF, SystemZ::OIHF,
false);
1431 case SystemZ::OILMux:
1432 expandRIPseudo(MI, SystemZ::OILL, SystemZ::OIHL,
false);
1435 case SystemZ::OIHMux:
1436 expandRIPseudo(MI, SystemZ::OILH, SystemZ::OIHH,
false);
1439 case SystemZ::XIFMux:
1440 expandRIPseudo(MI, SystemZ::XILF, SystemZ::XIHF,
false);
1443 case SystemZ::TMLMux:
1444 expandRIPseudo(MI, SystemZ::TMLL, SystemZ::TMHL,
false);
1447 case SystemZ::TMHMux:
1448 expandRIPseudo(MI, SystemZ::TMLH, SystemZ::TMHH,
false);
1451 case SystemZ::AHIMux:
1452 expandRIPseudo(MI, SystemZ::AHI, SystemZ::AIH,
false);
1455 case SystemZ::AHIMuxK:
1456 expandRIEPseudo(MI, SystemZ::AHI, SystemZ::AHIK, SystemZ::AIH);
1459 case SystemZ::AFIMux:
1460 expandRIPseudo(MI, SystemZ::AFI, SystemZ::AIH,
false);
1463 case SystemZ::CHIMux:
1464 expandRIPseudo(MI, SystemZ::CHI, SystemZ::CIH,
false);
1467 case SystemZ::CFIMux:
1468 expandRIPseudo(MI, SystemZ::CFI, SystemZ::CIH,
false);
1471 case SystemZ::CLFIMux:
1472 expandRIPseudo(MI, SystemZ::CLFI, SystemZ::CLIH,
false);
1476 expandRXYPseudo(MI,
SystemZ::C, SystemZ::CHF);
1479 case SystemZ::CLMux:
1480 expandRXYPseudo(MI, SystemZ::CL, SystemZ::CLHF);
1483 case SystemZ::RISBMux: {
1486 if (SrcIsHigh == DestIsHigh)
1487 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHH : SystemZ::RISBLL));
1489 MI.
setDesc(
get(DestIsHigh ? SystemZ::RISBHL : SystemZ::RISBLH));
1496 splitAdjDynAlloc(MI);
1499 case TargetOpcode::LOAD_STACK_GUARD:
1500 expandLoadStackGuard(&MI);
1533 case SystemZ::BRCTH:
1537 case SystemZ::BRCTG:
1556 case SystemZ::CLGIJ:
1557 case SystemZ::CLGRJ:
1567 unsigned &LoadOpcode,
1568 unsigned &StoreOpcode)
const {
1569 if (RC == &SystemZ::GR32BitRegClass || RC == &SystemZ::ADDR32BitRegClass) {
1570 LoadOpcode = SystemZ::L;
1572 }
else if (RC == &SystemZ::GRH32BitRegClass) {
1573 LoadOpcode = SystemZ::LFH;
1574 StoreOpcode = SystemZ::STFH;
1575 }
else if (RC == &SystemZ::GRX32BitRegClass) {
1576 LoadOpcode = SystemZ::LMux;
1577 StoreOpcode = SystemZ::STMux;
1578 }
else if (RC == &SystemZ::GR64BitRegClass ||
1579 RC == &SystemZ::ADDR64BitRegClass) {
1580 LoadOpcode = SystemZ::LG;
1581 StoreOpcode = SystemZ::STG;
1582 }
else if (RC == &SystemZ::GR128BitRegClass ||
1583 RC == &SystemZ::ADDR128BitRegClass) {
1584 LoadOpcode = SystemZ::L128;
1585 StoreOpcode = SystemZ::ST128;
1586 }
else if (RC == &SystemZ::FP32BitRegClass) {
1588 StoreOpcode = SystemZ::STE;
1589 }
else if (RC == &SystemZ::FP64BitRegClass) {
1591 StoreOpcode = SystemZ::STD;
1592 }
else if (RC == &SystemZ::FP128BitRegClass) {
1593 LoadOpcode = SystemZ::LX;
1594 StoreOpcode = SystemZ::STX;
1595 }
else if (RC == &SystemZ::VR32BitRegClass) {
1596 LoadOpcode = SystemZ::VL32;
1597 StoreOpcode = SystemZ::VST32;
1598 }
else if (RC == &SystemZ::VR64BitRegClass) {
1599 LoadOpcode = SystemZ::VL64;
1600 StoreOpcode = SystemZ::VST64;
1601 }
else if (RC == &SystemZ::VF128BitRegClass ||
1602 RC == &SystemZ::VR128BitRegClass) {
1603 LoadOpcode = SystemZ::VL;
1604 StoreOpcode = SystemZ::VST;
1613 if (isUInt<12>(Offset) && isUInt<12>(Offset2)) {
1615 int Disp12Opcode = SystemZ::getDisp12Opcode(Opcode);
1616 if (Disp12Opcode >= 0)
1617 return Disp12Opcode;
1623 if (isInt<20>(Offset) && isInt<20>(Offset2)) {
1625 int Disp20Opcode = SystemZ::getDisp20Opcode(Opcode);
1626 if (Disp20Opcode >= 0)
1627 return Disp20Opcode;
1640 case SystemZ::LG:
return SystemZ::LTG;
1641 case SystemZ::LGF:
return SystemZ::LTGF;
1642 case SystemZ::LR:
return SystemZ::LTR;
1643 case SystemZ::LGFR:
return SystemZ::LTGFR;
1644 case SystemZ::LGR:
return SystemZ::LTGR;
1645 case SystemZ::LER:
return SystemZ::LTEBR;
1647 case SystemZ::LXR:
return SystemZ::LTXBR;
1648 case SystemZ::LCDFR:
return SystemZ::LCDBR;
1649 case SystemZ::LPDFR:
return SystemZ::LPDBR;
1650 case SystemZ::LNDFR:
return SystemZ::LNDBR;
1651 case SystemZ::LCDFR_32:
return SystemZ::LCEBR;
1652 case SystemZ::LPDFR_32:
return SystemZ::LPEBR;
1653 case SystemZ::LNDFR_32:
return SystemZ::LNEBR;
1658 case SystemZ::RISBGN:
return SystemZ::RISBG;
1668 uint64_t Top = (Mask >> First) + 1;
1669 if ((Top & -Top) == Top) {
1678 unsigned &Start,
unsigned &End)
const {
1686 unsigned LSB, Length;
1688 Start = 63 - (LSB + Length - 1);
1696 assert(LSB > 0 &&
"Bottom bit must be set");
1697 assert(LSB + Length < BitSize &&
"Top bit must be set");
1698 Start = 63 - (LSB - 1);
1699 End = 63 - (LSB + Length);
1716 case SystemZ::CLGFI:
1722 if (!STI.hasMiscellaneousExtensions())
1732 return SystemZ::CRJ;
1734 return SystemZ::CGRJ;
1736 return SystemZ::CIJ;
1738 return SystemZ::CGIJ;
1740 return SystemZ::CLRJ;
1742 return SystemZ::CLGRJ;
1744 return SystemZ::CLIJ;
1745 case SystemZ::CLGFI:
1746 return SystemZ::CLGIJ;
1753 return SystemZ::CRBReturn;
1755 return SystemZ::CGRBReturn;
1757 return SystemZ::CIBReturn;
1759 return SystemZ::CGIBReturn;
1761 return SystemZ::CLRBReturn;
1763 return SystemZ::CLGRBReturn;
1765 return SystemZ::CLIBReturn;
1766 case SystemZ::CLGFI:
1767 return SystemZ::CLGIBReturn;
1774 return SystemZ::CRBCall;
1776 return SystemZ::CGRBCall;
1778 return SystemZ::CIBCall;
1780 return SystemZ::CGIBCall;
1782 return SystemZ::CLRBCall;
1784 return SystemZ::CLGRBCall;
1786 return SystemZ::CLIBCall;
1787 case SystemZ::CLGFI:
1788 return SystemZ::CLGIBCall;
1795 return SystemZ::CRT;
1797 return SystemZ::CGRT;
1799 return SystemZ::CIT;
1801 return SystemZ::CGIT;
1803 return SystemZ::CLRT;
1805 return SystemZ::CLGRT;
1807 return SystemZ::CLFIT;
1808 case SystemZ::CLGFI:
1809 return SystemZ::CLGIT;
1811 return SystemZ::CLT;
1813 return SystemZ::CLGT;
1822 if (!STI.hasLoadAndTrap())
1827 return SystemZ::LAT;
1829 return SystemZ::LGAT;
1831 return SystemZ::LFHAT;
1833 return SystemZ::LLGFAT;
1835 return SystemZ::LLGTAT;
1842 unsigned Reg, uint64_t
Value)
const {
1846 Opcode = SystemZ::LGHI;
1848 Opcode = SystemZ::LLILL;
1850 Opcode = SystemZ::LLILH;
1854 Opcode = SystemZ::LGFI;
1874 bool SameVal = (VALa && VALb && (VALa == VALb));
1878 if (PSVa && PSVb && (PSVa == PSVb))
1884 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1885 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1886 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1887 if (LowOffset + LowWidth <= HighOffset)
void loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Reg, uint64_t Value) const
void push_back(const T &Elt)
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
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool use_nodbg_empty(unsigned RegNo) const
use_nodbg_empty - Return true if there are no non-Debug instructions using the specified register...
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
MachineBasicBlock * getMBB() const
const int64_t CallFrameSize
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
SystemZInstrInfo(SystemZSubtarget &STI)
Compute iterated dominance frontiers using a linear time algorithm.
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...
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
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
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 getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getSubReg() const
bool hasLoadStoreOnCond() const
static void eraseIfDead(MachineInstr *MI, const MachineRegisterInfo *MRI)
constexpr bool isInt< 8 >(int64_t x)
uint64_t getSize() const
Return the size in bytes of the memory reference.
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
constexpr bool isInt< 16 >(int64_t x)
STATISTIC(NumFunctions, "Total number of functions")
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
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
static bool removeIPMBasedCompare(MachineInstr &Compare, unsigned SrcReg, const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI)
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
A description of a memory reference used in the backend.
unsigned getNumOperands() const
Access to explicit operands of the instruction.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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
INLINEASM - Represents an inline asm block.
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int Mask, int Value, const MachineRegisterInfo *MRI) const override
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 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)
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...
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
bool registerDefIsDead(unsigned Reg, const TargetRegisterInfo *TRI=nullptr) const
Returns true if the register is dead in this machine instruction.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset) const
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
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)
self_iterator getIterator()
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.
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)
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
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...
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
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 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
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.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static MachineInstr * getDef(unsigned Reg, const MachineRegisterInfo *MRI)
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.
LLVM_NODISCARD bool empty() const
unsigned getFusedCompare(unsigned Opcode, SystemZII::FusedCompareType Type, const MachineInstr *MI=nullptr) const
void setReg(unsigned Reg)
Change the register this operand corresponds to.
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 MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
SlotIndexes * getSlotIndexes() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 isShift(MachineInstr *MI, unsigned Opcode, int64_t Imm)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
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
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...
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
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.
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
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.