48#define GET_INSTRINFO_CTOR_DTOR
49#define GET_INSTRMAP_INFO
50#include "SystemZGenInstrInfo.inc"
52#define DEBUG_TYPE "systemz-II"
56 return Count == 0 ? 0 : (
uint64_t(1) << (Count - 1) << 1) - 1;
60void SystemZInstrInfo::anchor() {}
64 RI(sti.getSpecialRegisters()->getReturnFunctionAddressRegister()),
70 unsigned NewOpcode)
const {
86 HighRegOp.
setReg(RI.getSubReg(HighRegOp.
getReg(), SystemZ::subreg_h64));
87 LowRegOp.
setReg(RI.getSubReg(LowRegOp.
getReg(), SystemZ::subreg_l64));
98 assert(HighOpcode && LowOpcode &&
"Both offsets should be in range");
103 if (
MI->mayStore()) {
115 auto overlapsAddressReg = [&](
Register Reg) ->
bool {
116 return RI.regsOverlap(Reg,
MI->getOperand(1).getReg()) ||
117 RI.regsOverlap(Reg,
MI->getOperand(3).getReg());
119 if (overlapsAddressReg(HighRegOp.
getReg())) {
121 "Both loads clobber address!");
145 assert(NewOpcode &&
"No support for huge argument lists yet");
146 MI->setDesc(
get(NewOpcode));
156void SystemZInstrInfo::expandRIPseudo(
MachineInstr &
MI,
unsigned LowOpcode,
158 bool ConvertHigh)
const {
161 MI.setDesc(
get(IsHigh ? HighOpcode : LowOpcode));
162 if (IsHigh && ConvertHigh)
163 MI.getOperand(1).setImm(
uint32_t(
MI.getOperand(1).getImm()));
170void SystemZInstrInfo::expandRIEPseudo(
MachineInstr &
MI,
unsigned LowOpcode,
172 unsigned HighOpcode)
const {
177 if (!DestIsHigh && !SrcIsHigh)
178 MI.setDesc(
get(LowOpcodeK));
180 if (DestReg != SrcReg) {
181 emitGRX32Move(*
MI.getParent(),
MI,
MI.getDebugLoc(), DestReg, SrcReg,
182 SystemZ::LR, 32,
MI.getOperand(1).isKill(),
183 MI.getOperand(1).isUndef());
184 MI.getOperand(1).setReg(DestReg);
186 MI.setDesc(
get(DestIsHigh ? HighOpcode : LowOpcode));
187 MI.tieOperands(0, 1);
194void SystemZInstrInfo::expandRXYPseudo(
MachineInstr &
MI,
unsigned LowOpcode,
195 unsigned HighOpcode)
const {
199 MI.getOperand(2).getImm());
200 MI.setDesc(
get(Opcode));
206void SystemZInstrInfo::expandLOCPseudo(
MachineInstr &
MI,
unsigned LowOpcode,
207 unsigned HighOpcode)
const {
210 MI.setDesc(
get(Opcode));
216void SystemZInstrInfo::expandZExtPseudo(
MachineInstr &
MI,
unsigned LowOpcode,
217 unsigned Size)
const {
219 emitGRX32Move(*
MI.getParent(),
MI,
MI.getDebugLoc(),
220 MI.getOperand(0).getReg(),
MI.getOperand(1).getReg(), LowOpcode,
221 Size,
MI.getOperand(1).isKill(),
MI.getOperand(1).isUndef());
227 MI.eraseFromParent();
230void SystemZInstrInfo::expandLoadStackGuard(
MachineInstr *
MI)
const {
233 const Register Reg64 =
MI->getOperand(0).getReg();
234 const Register Reg32 = RI.getSubReg(Reg64, SystemZ::subreg_l32);
255 MI->setDesc(
get(SystemZ::LG));
268 unsigned SrcReg,
unsigned LowLowOpcode,
269 unsigned Size,
bool KillSrc,
270 bool UndefSrc)
const {
274 if (DestIsHigh && SrcIsHigh)
275 Opcode = SystemZ::RISBHH;
276 else if (DestIsHigh && !SrcIsHigh)
277 Opcode = SystemZ::RISBHL;
278 else if (!DestIsHigh && SrcIsHigh)
279 Opcode = SystemZ::RISBLH;
284 unsigned Rotate = (DestIsHigh != SrcIsHigh ? 32 : 0);
294 unsigned OpIdx2)
const {
297 return *
MI.getParent()->getParent()->CloneMachineInstr(&
MI);
301 switch (
MI.getOpcode()) {
302 case SystemZ::SELRMux:
303 case SystemZ::SELFHR:
306 case SystemZ::LOCRMux:
307 case SystemZ::LOCFHR:
309 case SystemZ::LOCGR: {
310 auto &WorkingMI = cloneIfNew(
MI);
312 unsigned CCValid = WorkingMI.getOperand(3).getImm();
313 unsigned CCMask = WorkingMI.getOperand(4).getImm();
314 WorkingMI.getOperand(4).setImm(CCMask ^ CCValid);
331 if ((MCID.
TSFlags & Flag) &&
MI.getOperand(1).isFI() &&
332 MI.getOperand(2).getImm() == 0 &&
MI.getOperand(3).getReg() == 0) {
333 FrameIndex =
MI.getOperand(1).getIndex();
334 return MI.getOperand(0).getReg();
340 int &FrameIndex)
const {
345 int &FrameIndex)
const {
351 int &SrcFrameIndex)
const {
354 if (
MI.getOpcode() != SystemZ::MVC || !
MI.getOperand(0).isFI() ||
355 MI.getOperand(1).getImm() != 0 || !
MI.getOperand(3).isFI() ||
356 MI.getOperand(4).getImm() != 0)
360 int64_t
Length =
MI.getOperand(2).getImm();
361 unsigned FI1 =
MI.getOperand(0).getIndex();
362 unsigned FI2 =
MI.getOperand(3).getIndex();
367 DestFrameIndex = FI1;
376 bool AllowModify)
const {
384 if (
I->isDebugInstr())
389 if (!isUnpredicatedTerminator(*
I))
399 if (!Branch.hasMBBTarget())
409 TBB = Branch.getMBBTarget();
422 I->eraseFromParent();
428 TBB = Branch.getMBBTarget();
436 TBB = Branch.getMBBTarget();
443 assert(
Cond.size() == 2 &&
TBB &&
"Should have seen a conditional branch");
447 if (
TBB != Branch.getMBBTarget())
451 unsigned OldCCValid =
Cond[0].getImm();
452 unsigned OldCCMask =
Cond[1].getImm();
453 if (OldCCValid == Branch.CCValid && OldCCMask == Branch.CCMask)
464 int *BytesRemoved)
const {
465 assert(!BytesRemoved &&
"code size not handled");
473 if (
I->isDebugInstr())
480 I->eraseFromParent();
490 assert(
Cond.size() == 2 &&
"Invalid condition");
500 int *BytesAdded)
const {
506 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
508 "SystemZ branch conditions have one component!");
509 assert(!BytesAdded &&
"code size not handled");
513 assert(!FBB &&
"Unconditional branch with multiple successors!");
520 unsigned CCValid =
Cond[0].getImm();
521 unsigned CCMask =
Cond[1].getImm();
536 int64_t &
Value)
const {
537 assert(
MI.isCompare() &&
"Caller should have checked for a comparison");
539 if (
MI.getNumExplicitOperands() == 2 &&
MI.getOperand(0).isReg() &&
540 MI.getOperand(1).isImm()) {
541 SrcReg =
MI.getOperand(0).getReg();
543 Value =
MI.getOperand(1).getImm();
556 int &FalseCycles)
const {
558 if (!STI.hasLoadStoreOnCond())
560 if (Pred.
size() != 2)
566 RI.getCommonSubClass(
MRI.getRegClass(TrueReg),
MRI.getRegClass(FalseReg));
571 if ((STI.hasLoadStoreOnCond2() &&
572 SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) ||
573 SystemZ::GR32BitRegClass.hasSubClassEq(RC) ||
574 SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
594 assert(Pred.
size() == 2 &&
"Invalid condition");
595 unsigned CCValid = Pred[0].getImm();
596 unsigned CCMask = Pred[1].getImm();
599 if (SystemZ::GRX32BitRegClass.hasSubClassEq(RC)) {
600 if (STI.hasMiscellaneousExtensions3())
601 Opc = SystemZ::SELRMux;
602 else if (STI.hasLoadStoreOnCond2())
603 Opc = SystemZ::LOCRMux;
606 MRI.constrainRegClass(DstReg, &SystemZ::GR32BitRegClass);
607 Register TReg =
MRI.createVirtualRegister(&SystemZ::GR32BitRegClass);
608 Register FReg =
MRI.createVirtualRegister(&SystemZ::GR32BitRegClass);
614 }
else if (SystemZ::GR64BitRegClass.hasSubClassEq(RC)) {
615 if (STI.hasMiscellaneousExtensions3())
616 Opc = SystemZ::SELGR;
618 Opc = SystemZ::LOCGR;
632 DefMI =
MRI->getVRegDef(FoldAsLoadDefReg);
634 bool SawStore =
false;
639 MI.findRegisterUseOperandIdx(FoldAsLoadDefReg,
nullptr);
640 assert(UseOpIdx != -1 &&
"Expected FoldAsLoadDefReg to be used by MI.");
645 FoldAsLoadDefReg = 0;
655 unsigned DefOpc =
DefMI.getOpcode();
657 if (DefOpc == SystemZ::VGBM) {
658 int64_t ImmVal =
DefMI.getOperand(1).getImm();
673 MRI->getRegClass(CopyDstReg) == &SystemZ::GR128BitRegClass &&
674 MRI->hasOneNonDBGUse(Reg)) {
678 Register TmpReg =
MRI->createVirtualRegister(&SystemZ::GR64BitRegClass);
683 UseMI.setDesc(
get(SystemZ::REG_SEQUENCE));
684 UseMI.getOperand(1).setReg(TmpReg);
686 .
addImm(SystemZ::subreg_h64)
688 .
addImm(SystemZ::subreg_l64);
690 if (
MRI->use_nodbg_empty(Reg))
691 DefMI.eraseFromParent();
698 if (DefOpc != SystemZ::LHIMux && DefOpc != SystemZ::LHI &&
699 DefOpc != SystemZ::LGHI)
703 int32_t ImmVal = (int32_t)
DefMI.getOperand(1).getImm();
705 unsigned UseOpc =
UseMI.getOpcode();
711 case SystemZ::SELRMux:
714 case SystemZ::LOCRMux:
715 if (!STI.hasLoadStoreOnCond2())
717 NewUseOpc = SystemZ::LOCHIMux;
721 UseIdx = 2, CommuteIdx = 1;
729 if (!STI.hasLoadStoreOnCond2())
731 NewUseOpc = SystemZ::LOCGHI;
735 UseIdx = 2, CommuteIdx = 1;
743 if (CommuteIdx != -1)
744 if (!commuteInstruction(
UseMI,
false, CommuteIdx, UseIdx))
747 bool DeleteDef =
MRI->hasOneNonDBGUse(Reg);
750 UseMI.tieOperands(0, 1);
751 UseMI.getOperand(UseIdx).ChangeToImmediate(ImmVal);
753 DefMI.eraseFromParent();
759 unsigned Opcode =
MI.getOpcode();
760 if (Opcode == SystemZ::Return ||
761 Opcode == SystemZ::Return_XPLINK ||
762 Opcode == SystemZ::Trap ||
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");
811 unsigned Opcode =
MI.getOpcode();
812 if (Opcode == SystemZ::Trap) {
813 MI.setDesc(
get(SystemZ::CondTrap));
819 if (Opcode == SystemZ::Return || Opcode == SystemZ::Return_XPLINK) {
820 MI.setDesc(
get(Opcode == SystemZ::Return ? SystemZ::CondReturn
821 : SystemZ::CondReturn_XPLINK));
828 if (Opcode == SystemZ::CallJG) {
830 const uint32_t *RegMask =
MI.getOperand(1).getRegMask();
833 MI.setDesc(
get(SystemZ::CallBRCL));
842 if (Opcode == SystemZ::CallBR) {
844 const uint32_t *RegMask =
MI.getOperand(1).getRegMask();
847 MI.setDesc(
get(SystemZ::CallBCR));
863 bool RenamableSrc)
const {
867 if (SystemZ::GR128BitRegClass.
contains(DestReg, SrcReg)) {
869 RI.getSubReg(SrcReg, SystemZ::subreg_h64), KillSrc);
873 RI.getSubReg(SrcReg, SystemZ::subreg_l64), KillSrc);
879 if (SystemZ::GRX32BitRegClass.
contains(DestReg, SrcReg)) {
880 emitGRX32Move(
MBB,
MBBI,
DL, DestReg, SrcReg, SystemZ::LR, 32, KillSrc,
886 if (SystemZ::VR128BitRegClass.
contains(DestReg) &&
887 SystemZ::FP128BitRegClass.
contains(SrcReg)) {
889 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_h64),
890 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
892 RI.getMatchingSuperReg(RI.getSubReg(SrcReg, SystemZ::subreg_l64),
893 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
900 if (SystemZ::FP128BitRegClass.
contains(DestReg) &&
901 SystemZ::VR128BitRegClass.
contains(SrcReg)) {
903 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_h64),
904 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
906 RI.getMatchingSuperReg(RI.getSubReg(DestReg, SystemZ::subreg_l64),
907 SystemZ::subreg_h64, &SystemZ::VR128BitRegClass);
909 if (DestRegHi != SrcReg)
916 if (SystemZ::FP128BitRegClass.
contains(DestReg) &&
917 SystemZ::GR128BitRegClass.
contains(SrcReg)) {
918 MCRegister DestRegHi = RI.getSubReg(DestReg, SystemZ::subreg_h64);
919 MCRegister DestRegLo = RI.getSubReg(DestReg, SystemZ::subreg_l64);
920 MCRegister SrcRegHi = RI.getSubReg(SrcReg, SystemZ::subreg_h64);
921 MCRegister SrcRegLo = RI.getSubReg(SrcReg, SystemZ::subreg_l64);
933 if (DestReg == SystemZ::CC) {
935 SystemZ::GR32BitRegClass.contains(SrcReg) ? SystemZ::TMLH : SystemZ::TMHH;
942 if (SystemZ::GR128BitRegClass.
contains(DestReg) &&
943 SystemZ::VR128BitRegClass.
contains(SrcReg)) {
944 MCRegister DestH64 = RI.getSubReg(DestReg, SystemZ::subreg_h64);
945 MCRegister DestL64 = RI.getSubReg(DestReg, SystemZ::subreg_l64);
949 .
addReg(SystemZ::NoRegister)
954 .
addReg(SystemZ::NoRegister)
959 if (SystemZ::VR128BitRegClass.
contains(DestReg) &&
960 SystemZ::GR128BitRegClass.
contains(SrcReg)) {
962 .
addReg(RI.getSubReg(SrcReg, SystemZ::subreg_h64))
963 .
addReg(RI.getSubReg(SrcReg, SystemZ::subreg_l64));
969 if (SystemZ::GR64BitRegClass.
contains(DestReg, SrcReg))
970 Opcode = SystemZ::LGR;
971 else if (SystemZ::FP32BitRegClass.
contains(DestReg, SrcReg))
973 Opcode = STI.hasVector() ? SystemZ::LDR32 : SystemZ::LER;
974 else if (SystemZ::FP64BitRegClass.
contains(DestReg, SrcReg))
975 Opcode = SystemZ::LDR;
976 else if (SystemZ::FP128BitRegClass.
contains(DestReg, SrcReg))
977 Opcode = SystemZ::LXR;
978 else if (SystemZ::VR32BitRegClass.
contains(DestReg, SrcReg))
979 Opcode = SystemZ::VLR32;
980 else if (SystemZ::VR64BitRegClass.
contains(DestReg, SrcReg))
981 Opcode = SystemZ::VLR64;
982 else if (SystemZ::VR128BitRegClass.
contains(DestReg, SrcReg))
983 Opcode = SystemZ::VLR;
984 else if (SystemZ::AR32BitRegClass.
contains(DestReg, SrcReg))
985 Opcode = SystemZ::CPYA;
1002 unsigned LoadOpcode, StoreOpcode;
1017 unsigned LoadOpcode, StoreOpcode;
1027 return ((MCID.
TSFlags & Flag) &&
1028 isUInt<12>(
MI->getOperand(2).getImm()) &&
1029 MI->getOperand(3).getReg() == 0);
1035 LogicOp() =
default;
1036 LogicOp(
unsigned regSize,
unsigned immLSB,
unsigned immSize)
1037 :
RegSize(regSize), ImmLSB(immLSB), ImmSize(immSize) {}
1039 explicit operator bool()
const {
return RegSize; }
1042 unsigned ImmLSB = 0;
1043 unsigned ImmSize = 0;
1050 case SystemZ::NILMux:
return LogicOp(32, 0, 16);
1051 case SystemZ::NIHMux:
return LogicOp(32, 16, 16);
1052 case SystemZ::NILL64:
return LogicOp(64, 0, 16);
1053 case SystemZ::NILH64:
return LogicOp(64, 16, 16);
1054 case SystemZ::NIHL64:
return LogicOp(64, 32, 16);
1055 case SystemZ::NIHH64:
return LogicOp(64, 48, 16);
1056 case SystemZ::NIFMux:
return LogicOp(32, 0, 32);
1057 case SystemZ::NILF64:
return LogicOp(64, 0, 32);
1058 case SystemZ::NIHF64:
return LogicOp(64, 32, 32);
1059 default:
return LogicOp();
1067 if (CCDef !=
nullptr)
1089 unsigned Start,
End;
1092 if (
And.RegSize == 64) {
1093 NewOpcode = SystemZ::RISBG;
1095 if (STI.hasMiscellaneousExtensions())
1096 NewOpcode = SystemZ::RISBGN;
1098 NewOpcode = SystemZ::RISBMux;
1114 unsigned NumOps =
MI.getNumOperands();
1115 for (
unsigned I = 1;
I < NumOps; ++
I) {
1117 if (
Op.isReg() &&
Op.isKill())
1131 bool Invert)
const {
1137 Opc = *InverseOpcode;
1144 case SystemZ::WFADB:
1145 case SystemZ::WFASB:
1146 case SystemZ::WFAXB:
1147 case SystemZ::VFADB:
1148 case SystemZ::VFASB:
1149 case SystemZ::WFMDB:
1150 case SystemZ::WFMSB:
1151 case SystemZ::WFMXB:
1152 case SystemZ::VFMDB:
1153 case SystemZ::VFMSB:
1161std::optional<unsigned>
1165 case SystemZ::WFADB:
1166 return SystemZ::WFSDB;
1167 case SystemZ::WFASB:
1168 return SystemZ::WFSSB;
1169 case SystemZ::WFAXB:
1170 return SystemZ::WFSXB;
1171 case SystemZ::VFADB:
1172 return SystemZ::VFSDB;
1173 case SystemZ::VFASB:
1174 return SystemZ::VFSSB;
1176 case SystemZ::WFSDB:
1177 return SystemZ::WFADB;
1178 case SystemZ::WFSSB:
1179 return SystemZ::WFASB;
1180 case SystemZ::WFSXB:
1181 return SystemZ::WFAXB;
1182 case SystemZ::VFSDB:
1183 return SystemZ::VFADB;
1184 case SystemZ::VFSSB:
1185 return SystemZ::VFASB;
1187 return std::nullopt;
1199 unsigned Opcode =
MI.getOpcode();
1204 bool CCLiveAtMI =
true;
1209 CCLiveRange = &LIS->
getRegUnit(*CCUnits.begin());
1210 CCLiveAtMI = CCLiveRange->
liveAt(MISlot);
1213 if (Ops.
size() == 2 && Ops[0] == 0 && Ops[1] == 1) {
1214 if (!CCLiveAtMI && (Opcode == SystemZ::LA || Opcode == SystemZ::LAY) &&
1215 isInt<8>(
MI.getOperand(2).getImm()) && !
MI.getOperand(3).getReg()) {
1218 MI.getDebugLoc(),
get(SystemZ::AGSI))
1221 .
addImm(
MI.getOperand(2).getImm());
1231 if (Ops.
size() != 1)
1234 unsigned OpNum = Ops[0];
1238 "Invalid size combination");
1240 if ((Opcode == SystemZ::AHI || Opcode == SystemZ::AGHI) && OpNum == 0 &&
1241 isInt<8>(
MI.getOperand(2).getImm())) {
1243 Opcode = (Opcode == SystemZ::AHI ? SystemZ::ASI : SystemZ::AGSI);
1245 BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
get(Opcode))
1248 .
addImm(
MI.getOperand(2).getImm());
1254 if ((Opcode == SystemZ::ALFI && OpNum == 0 &&
1255 isInt<8>((int32_t)
MI.getOperand(2).getImm())) ||
1256 (Opcode == SystemZ::ALGFI && OpNum == 0 &&
1257 isInt<8>((int64_t)
MI.getOperand(2).getImm()))) {
1259 Opcode = (Opcode == SystemZ::ALFI ? SystemZ::ALSI : SystemZ::ALGSI);
1261 BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
get(Opcode))
1264 .
addImm((int8_t)
MI.getOperand(2).getImm());
1269 if ((Opcode == SystemZ::SLFI && OpNum == 0 &&
1270 isInt<8>((int32_t)-
MI.getOperand(2).getImm())) ||
1271 (Opcode == SystemZ::SLGFI && OpNum == 0 &&
1272 isInt<8>((int64_t)-
MI.getOperand(2).getImm()))) {
1274 Opcode = (Opcode == SystemZ::SLFI ? SystemZ::ALSI : SystemZ::ALGSI);
1276 BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
get(Opcode))
1279 .
addImm((int8_t)-
MI.getOperand(2).getImm());
1284 unsigned MemImmOpc = 0;
1286 case SystemZ::LHIMux:
1287 case SystemZ::LHI: MemImmOpc = SystemZ::MVHI;
break;
1288 case SystemZ::LGHI: MemImmOpc = SystemZ::MVGHI;
break;
1289 case SystemZ::CHIMux:
1290 case SystemZ::CHI: MemImmOpc = SystemZ::CHSI;
break;
1291 case SystemZ::CGHI: MemImmOpc = SystemZ::CGHSI;
break;
1292 case SystemZ::CLFIMux:
1294 if (isUInt<16>(
MI.getOperand(1).getImm()))
1295 MemImmOpc = SystemZ::CLFHSI;
1297 case SystemZ::CLGFI:
1298 if (isUInt<16>(
MI.getOperand(1).getImm()))
1299 MemImmOpc = SystemZ::CLGHSI;
1304 return BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
1308 .
addImm(
MI.getOperand(1).getImm());
1310 if (Opcode == SystemZ::LGDR || Opcode == SystemZ::LDGR) {
1311 bool Op0IsGPR = (Opcode == SystemZ::LGDR);
1312 bool Op1IsGPR = (Opcode == SystemZ::LDGR);
1316 unsigned StoreOpcode = Op1IsGPR ? SystemZ::STG : SystemZ::STD;
1317 return BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
1319 .
add(
MI.getOperand(1))
1327 unsigned LoadOpcode = Op0IsGPR ? SystemZ::LG : SystemZ::LD;
1328 return BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
1330 .
add(
MI.getOperand(0))
1350 if (OpNum == 0 &&
MI.hasOneMemOperand()) {
1355 return BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
1360 .
add(
MI.getOperand(1))
1366 return BuildMI(*InsertPt->getParent(), InsertPt,
MI.getDebugLoc(),
1368 .
add(
MI.getOperand(1))
1381 unsigned NumOps =
MI.getNumExplicitOperands();
1382 int MemOpcode = SystemZ::getMemOpcode(Opcode);
1383 if (MemOpcode == -1 ||
1384 (CCLiveAtMI && !
MI.definesRegister(SystemZ::CC,
nullptr) &&
1385 get(MemOpcode).hasImplicitDefOfPhysReg(SystemZ::CC)))
1396 if (RC == &SystemZ::VR32BitRegClass || RC == &SystemZ::VR64BitRegClass) {
1402 !(SystemZ::FP32BitRegClass.
contains(PhysReg) ||
1403 SystemZ::FP64BitRegClass.
contains(PhysReg) ||
1404 SystemZ::VF128BitRegClass.
contains(PhysReg)))
1409 bool FusedFPOp = (Opcode == SystemZ::WFMADB || Opcode == SystemZ::WFMASB ||
1410 Opcode == SystemZ::WFMSDB || Opcode == SystemZ::WFMSSB);
1414 if (OpNum == 0 || OpNum == 3 || DstReg != AccReg)
1419 bool NeedsCommute =
false;
1420 if ((
MI.getOpcode() == SystemZ::CR ||
MI.getOpcode() == SystemZ::CGR ||
1421 MI.getOpcode() == SystemZ::CLR ||
MI.getOpcode() == SystemZ::CLGR ||
1422 MI.getOpcode() == SystemZ::WFCDB ||
MI.getOpcode() == SystemZ::WFCSB ||
1423 MI.getOpcode() == SystemZ::WFKDB ||
MI.getOpcode() == SystemZ::WFKSB) &&
1425 NeedsCommute =
true;
1427 bool CCOperands =
false;
1428 if (
MI.getOpcode() == SystemZ::LOCRMux ||
MI.getOpcode() == SystemZ::LOCGR ||
1429 MI.getOpcode() == SystemZ::SELRMux ||
MI.getOpcode() == SystemZ::SELGR) {
1430 assert(
MI.getNumOperands() == 6 && NumOps == 5 &&
1431 "LOCR/SELR instruction operands corrupt?");
1446 Register SrcReg = (OpNum == 2 ?
MI.getOperand(1).getReg()
1447 : ((OpNum == 1 &&
MI.isCommutable())
1448 ?
MI.getOperand(2).getReg()
1450 if (DstPhys && !SystemZ::GRH32BitRegClass.
contains(DstPhys) && SrcReg &&
1452 NeedsCommute = (OpNum == 1);
1458 if ((OpNum == NumOps - 1) || NeedsCommute || FusedFPOp) {
1461 assert(AccessBytes != 0 &&
"Size of access should be known");
1462 assert(AccessBytes <=
Size &&
"Access outside the frame index");
1465 MI.getDebugLoc(),
get(MemOpcode));
1466 if (
MI.isCompare()) {
1467 assert(NumOps == 2 &&
"Expected 2 register operands for a compare.");
1468 MIB.
add(
MI.getOperand(NeedsCommute ? 1 : 0));
1470 else if (FusedFPOp) {
1471 MIB.
add(
MI.getOperand(0));
1472 MIB.
add(
MI.getOperand(3));
1473 MIB.
add(
MI.getOperand(OpNum == 1 ? 2 : 1));
1476 MIB.
add(
MI.getOperand(0));
1478 MIB.
add(
MI.getOperand(2));
1480 for (
unsigned I = 1;
I < OpNum; ++
I)
1481 MIB.
add(
MI.getOperand(
I));
1487 unsigned CCValid =
MI.getOperand(NumOps).getImm();
1488 unsigned CCMask =
MI.getOperand(NumOps + 1).getImm();
1490 MIB.
addImm(NeedsCommute ? CCMask ^ CCValid : CCMask);
1493 (!
MI.definesRegister(SystemZ::CC,
nullptr) ||
1494 MI.registerDefIsDead(SystemZ::CC,
nullptr))) {
1502 if (MO.isReg() && MO.getReg().isVirtual()) {
1504 if (
MRI.getRegClass(Reg) == &SystemZ::VR32BitRegClass)
1505 MRI.setRegClass(Reg, &SystemZ::FP32BitRegClass);
1506 else if (
MRI.getRegClass(Reg) == &SystemZ::VR64BitRegClass)
1507 MRI.setRegClass(Reg, &SystemZ::FP64BitRegClass);
1508 else if (
MRI.getRegClass(Reg) == &SystemZ::VR128BitRegClass)
1509 MRI.setRegClass(Reg, &SystemZ::VF128BitRegClass);
1534 unsigned LoadOpc = 0;
1535 unsigned RegMemOpcode = 0;
1537 RegMemOpcode =
MI.getOpcode() == SystemZ::WFADB ? SystemZ::ADB
1538 :
MI.getOpcode() == SystemZ::WFSDB ? SystemZ::SDB
1539 :
MI.getOpcode() == SystemZ::WFMDB ? SystemZ::MDB
1542 LoadOpc = SystemZ::VL64;
1543 FPRC = &SystemZ::FP64BitRegClass;
1545 RegMemOpcode =
MI.getOpcode() == SystemZ::WFASB ? SystemZ::AEB
1546 :
MI.getOpcode() == SystemZ::WFSSB ? SystemZ::SEB
1547 :
MI.getOpcode() == SystemZ::WFMSB ? SystemZ::MEEB
1550 LoadOpc = SystemZ::VL32;
1551 FPRC = &SystemZ::FP32BitRegClass;
1554 if (!RegMemOpcode || LoadMI.
getOpcode() != LoadOpc)
1558 if (
get(RegMemOpcode).hasImplicitDefOfPhysReg(SystemZ::CC)) {
1560 assert(LoadMI != InsertPt &&
"Assuming InsertPt not to be first in MBB.");
1563 if (MII->definesRegister(SystemZ::CC,
nullptr)) {
1564 if (!MII->registerDefIsDead(SystemZ::CC,
nullptr))
1577 if (Ops.
size() != 1 || FoldAsLoadDefReg !=
MI.getOperand(Ops[0]).getReg())
1583 if ((RegMemOpcode == SystemZ::SDB || RegMemOpcode == SystemZ::SEB) &&
1584 FoldAsLoadDefReg !=
RHS.getReg())
1591 BuildMI(*
MI.getParent(), InsertPt,
MI.getDebugLoc(),
get(RegMemOpcode), DstReg)
1597 MRI->setRegClass(DstReg, FPRC);
1605 switch (
MI.getOpcode()) {
1607 splitMove(
MI, SystemZ::LG);
1610 case SystemZ::ST128:
1611 splitMove(
MI, SystemZ::STG);
1615 splitMove(
MI, SystemZ::LD);
1619 splitMove(
MI, SystemZ::STD);
1622 case SystemZ::LBMux:
1623 expandRXYPseudo(
MI, SystemZ::LB, SystemZ::LBH);
1626 case SystemZ::LHMux:
1627 expandRXYPseudo(
MI, SystemZ::LH, SystemZ::LHH);
1630 case SystemZ::LLCRMux:
1631 expandZExtPseudo(
MI, SystemZ::LLCR, 8);
1634 case SystemZ::LLHRMux:
1635 expandZExtPseudo(
MI, SystemZ::LLHR, 16);
1638 case SystemZ::LLCMux:
1639 expandRXYPseudo(
MI, SystemZ::LLC, SystemZ::LLCH);
1642 case SystemZ::LLHMux:
1643 expandRXYPseudo(
MI, SystemZ::LLH, SystemZ::LLHH);
1647 expandRXYPseudo(
MI, SystemZ::L, SystemZ::LFH);
1650 case SystemZ::LOCMux:
1651 expandLOCPseudo(
MI, SystemZ::LOC, SystemZ::LOCFH);
1654 case SystemZ::LOCHIMux:
1655 expandLOCPseudo(
MI, SystemZ::LOCHI, SystemZ::LOCHHI);
1658 case SystemZ::STCMux:
1659 expandRXYPseudo(
MI, SystemZ::STC, SystemZ::STCH);
1662 case SystemZ::STHMux:
1663 expandRXYPseudo(
MI, SystemZ::STH, SystemZ::STHH);
1666 case SystemZ::STMux:
1667 expandRXYPseudo(
MI, SystemZ::ST, SystemZ::STFH);
1670 case SystemZ::STOCMux:
1671 expandLOCPseudo(
MI, SystemZ::STOC, SystemZ::STOCFH);
1674 case SystemZ::LHIMux:
1675 expandRIPseudo(
MI, SystemZ::LHI, SystemZ::IIHF,
true);
1678 case SystemZ::IIFMux:
1679 expandRIPseudo(
MI, SystemZ::IILF, SystemZ::IIHF,
false);
1682 case SystemZ::IILMux:
1683 expandRIPseudo(
MI, SystemZ::IILL, SystemZ::IIHL,
false);
1686 case SystemZ::IIHMux:
1687 expandRIPseudo(
MI, SystemZ::IILH, SystemZ::IIHH,
false);
1690 case SystemZ::NIFMux:
1691 expandRIPseudo(
MI, SystemZ::NILF, SystemZ::NIHF,
false);
1694 case SystemZ::NILMux:
1695 expandRIPseudo(
MI, SystemZ::NILL, SystemZ::NIHL,
false);
1698 case SystemZ::NIHMux:
1699 expandRIPseudo(
MI, SystemZ::NILH, SystemZ::NIHH,
false);
1702 case SystemZ::OIFMux:
1703 expandRIPseudo(
MI, SystemZ::OILF, SystemZ::OIHF,
false);
1706 case SystemZ::OILMux:
1707 expandRIPseudo(
MI, SystemZ::OILL, SystemZ::OIHL,
false);
1710 case SystemZ::OIHMux:
1711 expandRIPseudo(
MI, SystemZ::OILH, SystemZ::OIHH,
false);
1714 case SystemZ::XIFMux:
1715 expandRIPseudo(
MI, SystemZ::XILF, SystemZ::XIHF,
false);
1718 case SystemZ::TMLMux:
1719 expandRIPseudo(
MI, SystemZ::TMLL, SystemZ::TMHL,
false);
1722 case SystemZ::TMHMux:
1723 expandRIPseudo(
MI, SystemZ::TMLH, SystemZ::TMHH,
false);
1726 case SystemZ::AHIMux:
1727 expandRIPseudo(
MI, SystemZ::AHI, SystemZ::AIH,
false);
1730 case SystemZ::AHIMuxK:
1731 expandRIEPseudo(
MI, SystemZ::AHI, SystemZ::AHIK, SystemZ::AIH);
1734 case SystemZ::AFIMux:
1735 expandRIPseudo(
MI, SystemZ::AFI, SystemZ::AIH,
false);
1738 case SystemZ::CHIMux:
1739 expandRIPseudo(
MI, SystemZ::CHI, SystemZ::CIH,
false);
1742 case SystemZ::CFIMux:
1743 expandRIPseudo(
MI, SystemZ::CFI, SystemZ::CIH,
false);
1746 case SystemZ::CLFIMux:
1747 expandRIPseudo(
MI, SystemZ::CLFI, SystemZ::CLIH,
false);
1751 expandRXYPseudo(
MI, SystemZ::C, SystemZ::CHF);
1754 case SystemZ::CLMux:
1755 expandRXYPseudo(
MI, SystemZ::CL, SystemZ::CLHF);
1758 case SystemZ::RISBMux: {
1761 if (SrcIsHigh == DestIsHigh)
1762 MI.setDesc(
get(DestIsHigh ? SystemZ::RISBHH : SystemZ::RISBLL));
1764 MI.setDesc(
get(DestIsHigh ? SystemZ::RISBHL : SystemZ::RISBLH));
1765 MI.getOperand(5).setImm(
MI.getOperand(5).getImm() ^ 32);
1770 case SystemZ::ADJDYNALLOC:
1771 splitAdjDynAlloc(
MI);
1774 case TargetOpcode::LOAD_STACK_GUARD:
1775 expandLoadStackGuard(&
MI);
1784 if (
MI.isInlineAsm()) {
1786 const char *AsmStr =
MI.getOperand(0).getSymbolName();
1789 else if (
MI.getOpcode() == SystemZ::PATCHPOINT)
1791 else if (
MI.getOpcode() == SystemZ::STACKMAP)
1792 return MI.getOperand(1).getImm();
1793 else if (
MI.getOpcode() == SystemZ::FENTRY_CALL)
1795 if (
MI.getOpcode() == TargetOpcode::PATCHABLE_FUNCTION_ENTER)
1797 if (
MI.getOpcode() == TargetOpcode::PATCHABLE_RET)
1798 return 18 + (
MI.getOperand(0).getImm() == SystemZ::CondReturn ? 4 : 0);
1800 return MI.getDesc().getSize();
1805 switch (
MI.getOpcode()) {
1816 MI.getOperand(1).getImm(), &
MI.getOperand(2));
1819 case SystemZ::BRCTH:
1823 case SystemZ::BRCTG:
1830 MI.getOperand(2).getImm(), &
MI.getOperand(3));
1835 MI.getOperand(2).getImm(), &
MI.getOperand(3));
1840 MI.getOperand(2).getImm(), &
MI.getOperand(3));
1842 case SystemZ::CLGIJ:
1843 case SystemZ::CLGRJ:
1845 MI.getOperand(2).getImm(), &
MI.getOperand(3));
1847 case SystemZ::INLINEASM_BR:
1857 unsigned &LoadOpcode,
1858 unsigned &StoreOpcode)
const {
1859 if (RC == &SystemZ::GR32BitRegClass || RC == &SystemZ::ADDR32BitRegClass) {
1860 LoadOpcode = SystemZ::L;
1861 StoreOpcode = SystemZ::ST;
1862 }
else if (RC == &SystemZ::GRH32BitRegClass) {
1863 LoadOpcode = SystemZ::LFH;
1864 StoreOpcode = SystemZ::STFH;
1865 }
else if (RC == &SystemZ::GRX32BitRegClass) {
1866 LoadOpcode = SystemZ::LMux;
1867 StoreOpcode = SystemZ::STMux;
1868 }
else if (RC == &SystemZ::GR64BitRegClass ||
1869 RC == &SystemZ::ADDR64BitRegClass) {
1870 LoadOpcode = SystemZ::LG;
1871 StoreOpcode = SystemZ::STG;
1872 }
else if (RC == &SystemZ::GR128BitRegClass ||
1873 RC == &SystemZ::ADDR128BitRegClass) {
1874 LoadOpcode = SystemZ::L128;
1875 StoreOpcode = SystemZ::ST128;
1876 }
else if (RC == &SystemZ::FP32BitRegClass) {
1877 LoadOpcode = SystemZ::LE;
1878 StoreOpcode = SystemZ::STE;
1879 }
else if (RC == &SystemZ::FP64BitRegClass) {
1880 LoadOpcode = SystemZ::LD;
1881 StoreOpcode = SystemZ::STD;
1882 }
else if (RC == &SystemZ::FP128BitRegClass) {
1883 LoadOpcode = SystemZ::LX;
1884 StoreOpcode = SystemZ::STX;
1885 }
else if (RC == &SystemZ::VR32BitRegClass) {
1886 LoadOpcode = SystemZ::VL32;
1887 StoreOpcode = SystemZ::VST32;
1888 }
else if (RC == &SystemZ::VR64BitRegClass) {
1889 LoadOpcode = SystemZ::VL64;
1890 StoreOpcode = SystemZ::VST64;
1891 }
else if (RC == &SystemZ::VF128BitRegClass ||
1892 RC == &SystemZ::VR128BitRegClass) {
1893 LoadOpcode = SystemZ::VL;
1894 StoreOpcode = SystemZ::VST;
1904 if (isUInt<12>(
Offset) && isUInt<12>(Offset2)) {
1906 int Disp12Opcode = SystemZ::getDisp12Opcode(Opcode);
1907 if (Disp12Opcode >= 0)
1908 return Disp12Opcode;
1914 if (isInt<20>(
Offset) && isInt<20>(Offset2)) {
1916 int Disp20Opcode = SystemZ::getDisp20Opcode(Opcode);
1917 if (Disp20Opcode >= 0)
1918 return Disp20Opcode;
1925 if (
MI &&
MI->getOperand(0).isReg()) {
1930 return SystemZ::LEY;
1931 case SystemZ::VST32:
1932 return SystemZ::STEY;
1934 return SystemZ::LDY;
1935 case SystemZ::VST64:
1936 return SystemZ::STDY;
1948 return SystemZ::getDisp12Opcode(Opcode) >= 0;
1949 return SystemZ::getDisp20Opcode(Opcode) >= 0;
1954 case SystemZ::L:
return SystemZ::LT;
1955 case SystemZ::LY:
return SystemZ::LT;
1956 case SystemZ::LG:
return SystemZ::LTG;
1957 case SystemZ::LGF:
return SystemZ::LTGF;
1958 case SystemZ::LR:
return SystemZ::LTR;
1959 case SystemZ::LGFR:
return SystemZ::LTGFR;
1960 case SystemZ::LGR:
return SystemZ::LTGR;
1961 case SystemZ::LCDFR:
return SystemZ::LCDBR;
1962 case SystemZ::LPDFR:
return SystemZ::LPDBR;
1963 case SystemZ::LNDFR:
return SystemZ::LNDBR;
1964 case SystemZ::LCDFR_32:
return SystemZ::LCEBR;
1965 case SystemZ::LPDFR_32:
return SystemZ::LPEBR;
1966 case SystemZ::LNDFR_32:
return SystemZ::LNEBR;
1971 case SystemZ::RISBGN:
return SystemZ::RISBG;
1977 unsigned &Start,
unsigned &
End)
const {
1987 Start = 63 - (LSB +
Length - 1);
1995 assert(LSB > 0 &&
"Bottom bit must be set");
1996 assert(LSB +
Length < BitSize &&
"Top bit must be set");
1997 Start = 63 - (LSB - 1);
2011 if (!(
MI && isInt<8>(
MI->getOperand(1).getImm())))
2015 case SystemZ::CLGFI:
2016 if (!(
MI && isUInt<8>(
MI->getOperand(1).getImm())))
2021 if (!STI.hasMiscellaneousExtensions())
2023 if (!(
MI &&
MI->getOperand(3).getReg() == 0))
2031 return SystemZ::CRJ;
2033 return SystemZ::CGRJ;
2035 return SystemZ::CIJ;
2037 return SystemZ::CGIJ;
2039 return SystemZ::CLRJ;
2041 return SystemZ::CLGRJ;
2043 return SystemZ::CLIJ;
2044 case SystemZ::CLGFI:
2045 return SystemZ::CLGIJ;
2052 return SystemZ::CRBReturn;
2054 return SystemZ::CGRBReturn;
2056 return SystemZ::CIBReturn;
2058 return SystemZ::CGIBReturn;
2060 return SystemZ::CLRBReturn;
2062 return SystemZ::CLGRBReturn;
2064 return SystemZ::CLIBReturn;
2065 case SystemZ::CLGFI:
2066 return SystemZ::CLGIBReturn;
2073 return SystemZ::CRBCall;
2075 return SystemZ::CGRBCall;
2077 return SystemZ::CIBCall;
2079 return SystemZ::CGIBCall;
2081 return SystemZ::CLRBCall;
2083 return SystemZ::CLGRBCall;
2085 return SystemZ::CLIBCall;
2086 case SystemZ::CLGFI:
2087 return SystemZ::CLGIBCall;
2094 return SystemZ::CRT;
2096 return SystemZ::CGRT;
2098 return SystemZ::CIT;
2100 return SystemZ::CGIT;
2102 return SystemZ::CLRT;
2104 return SystemZ::CLGRT;
2106 return SystemZ::CLFIT;
2107 case SystemZ::CLGFI:
2108 return SystemZ::CLGIT;
2110 return SystemZ::CLT;
2112 return SystemZ::CLGT;
2123 MBBI->getOperand(1).isReg() && !
MBBI->mayLoad() &&
2124 "Not a compare reg/reg.");
2130 if (
MI.readsRegister(SystemZ::CC,
nullptr)) {
2131 unsigned Flags =
MI.getDesc().TSFlags;
2137 if (
MI.definesRegister(SystemZ::CC,
nullptr)) {
2151 unsigned Flags = CCUsers[
Idx]->getDesc().TSFlags;
2153 0 : CCUsers[
Idx]->getNumExplicitOperands() - 2);
2156 CCMaskMO.
setImm(NewCCMask);
2194 if (!STI.hasLoadAndTrap())
2199 return SystemZ::LAT;
2201 return SystemZ::LGAT;
2203 return SystemZ::LFHAT;
2205 return SystemZ::LLGFAT;
2207 return SystemZ::LLGTAT;
2216 unsigned Opcode = 0;
2217 if (isInt<16>(
Value))
2218 Opcode = SystemZ::LGHI;
2220 Opcode = SystemZ::LLILL;
2222 Opcode = SystemZ::LLILH;
2225 else if (isInt<32>(
Value))
2226 Opcode = SystemZ::LGFI;
2233 assert (
MRI.isSSA() &&
"Huge values only handled before reg-alloc .");
2234 Register Reg0 =
MRI.createVirtualRegister(&SystemZ::GR64BitRegClass);
2235 Register Reg1 =
MRI.createVirtualRegister(&SystemZ::GR64BitRegClass);
2246 for (
unsigned I = 0, E =
MI.getNumOperands();
I != E; ++
I) {
2257 ErrInfo =
"Addressing mode operands corrupt!";
2280 bool SameVal = (VALa && VALb && (VALa == VALb));
2284 if (PSVa && PSVb && (PSVa == PSVb))
2290 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
2291 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
2292 LocationSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
2294 LowOffset + (int)LowWidth.
getValue() <= HighOffset)
2303 int64_t &ImmVal)
const {
2305 if (
MI.getOpcode() == SystemZ::VGBM && Reg ==
MI.getOperand(0).getReg()) {
2306 ImmVal =
MI.getOperand(1).getImm();
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
unsigned const TargetRegisterInfo * TRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
static bool isSimpleBD12Move(const MachineInstr *MI, unsigned Flag)
static void transferDeadCC(MachineInstr *OldMI, MachineInstr *NewMI)
static void transferMIFlag(MachineInstr *OldMI, MachineInstr *NewMI, MachineInstr::MIFlag Flag)
static int isSimpleMove(const MachineInstr &MI, int &FrameIndex, unsigned Flag)
static LogicOp interpretAndImmediate(unsigned Opcode)
static uint64_t allOnes(unsigned int Count)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This class represents an Operation in the Expression.
SlotIndexes * getSlotIndexes() const
VNInfo::Allocator & getVNInfoAllocator()
LiveRange & getRegUnit(unsigned Unit)
Return the live range for register unit Unit.
SlotIndex ReplaceMachineInstrInMaps(MachineInstr &MI, MachineInstr &NewMI)
This class represents the liveness of a register, stack slot, etc.
bool liveAt(SlotIndex index) const
VNInfo * createDeadDef(SlotIndex Def, VNInfo::Allocator &VNIAlloc)
createDeadDef - Make sure the range has a value defined at Def.
A set of register units used to track register liveness.
bool available(MCPhysReg Reg) const
Returns true if no part of physical register Reg is live.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds registers living out of block MBB.
void replaceKillInstruction(Register Reg, MachineInstr &OldMI, MachineInstr &NewMI)
replaceKillInstruction - Update register kill info by replacing a kill instruction with a new one.
TypeSize getValue() const
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
This holds information about one operand of a machine instruction, indicating the register class for ...
uint8_t OperandType
Information about the type of the operand.
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
Wrapper class representing physical registers. Should be passed by value.
static MCRegister from(unsigned Val)
Check the provided unsigned value is a valid MCRegister.
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const BasicBlock * getBasicBlock() const
Return the LLVM basic block that this instance corresponded to originally.
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
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 MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool isLiveIn(MCRegister Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
uint64_t getMaxCallFrameSize() const
Return the maximum size of a call frame that must be allocated for an outgoing function call.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *BB=nullptr, std::optional< UniqueBBID > BBID=std::nullopt)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
void insert(iterator MBBI, MachineBasicBlock *MBB)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Register getReg(unsigned Idx) const
Get the register for the operand index.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addRegMask(const uint32_t *Mask) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
bool getFlag(MIFlag Flag) const
Return whether an MI flag is set.
bool isSafeToMove(bool &SawStore) const
Return true if it is safe to move this instruction.
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI) const
Returns true if the register is dead in this machine instruction.
bool definesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr fully defines the specified register.
void setDesc(const MCInstrDesc &TID)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one.
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
iterator_range< mop_iterator > operands()
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
void setFlag(MIFlag Flag)
Set a MI flag.
const MachineOperand & getOperand(unsigned i) const
MachineOperand * findRegisterDefOperand(Register Reg, const TargetRegisterInfo *TRI, bool isDead=false, bool Overlap=false)
Wrapper for findRegisterDefOperandIdx, it returns a pointer to the MachineOperand rather than an inde...
bool addRegisterDead(Register Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI defined a register without a use.
A description of a memory reference used in the backend.
LocationSize getSize() const
Return the size in bytes of the memory reference.
const PseudoSourceValue * getPseudoValue() const
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher,...
const Value * getValue() const
Return the base address of the memory access.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
MachineOperand class - Representation of each machine instruction operand.
void setImm(int64_t immVal)
void setIsDead(bool Val=true)
void setReg(Register Reg)
Change the register this operand corresponds to.
void setIsKill(bool Val=true)
static MachineOperand CreateImm(int64_t Val)
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
MI-level patchpoint operands.
uint32_t getNumPatchBytes() const
Return the number of patchable bytes the given patchpoint should emit.
Special value supplied for machine level alias analysis.
Wrapper class representing virtual and physical registers.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
SlotIndex - An opaque wrapper around machine indexes.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def.
SlotIndex getInstructionIndex(const MachineInstr &MI, bool IgnoreBundle=false) const
Returns the base index for the given instruction.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
A SystemZ-specific class detailing special use registers particular for calling conventions.
virtual int getStackPointerBias()=0
virtual int getCallFrameSize()=0
unsigned getLoadAndTrap(unsigned Opcode) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, BranchProbability Probability) const override
unsigned getLoadAndTest(unsigned Opcode) const
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIdx, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool isPredicable(const MachineInstr &MI) const override
bool isStackSlotCopy(const MachineInstr &MI, int &DestFrameIndex, int &SrcFrameIndex) const override
MachineInstr * convertToThreeAddress(MachineInstr &MI, LiveVariables *LV, LiveIntervals *LIS) const override
unsigned getOpcodeForOffset(unsigned Opcode, int64_t Offset, const MachineInstr *MI=nullptr) const
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool getConstValDefinedInReg(const MachineInstr &MI, const Register Reg, int64_t &ImmVal) const override
bool isAssociativeAndCommutative(const MachineInstr &Inst, bool Invert) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
MachineInstr * optimizeLoadInstr(MachineInstr &MI, const MachineRegisterInfo *MRI, Register &FoldAsLoadDefReg, MachineInstr *&DefMI) const override
SystemZInstrInfo(SystemZSubtarget &STI)
bool hasDisplacementPairInsn(unsigned Opcode) 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...
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, Register DstReg, ArrayRef< MachineOperand > Cond, Register TrueReg, Register FalseReg) const override
std::optional< unsigned > getInverseOpcode(unsigned Opcode) const override
bool isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles, BranchProbability Probability) const override
SystemZII::Branch getBranchInfo(const MachineInstr &MI) const
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
unsigned getFusedCompare(unsigned Opcode, SystemZII::FusedCompareType Type, const MachineInstr *MI=nullptr) const
bool expandPostRAPseudo(MachineInstr &MBBI) const override
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &Mask, int64_t &Value) const override
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
void getLoadStoreOpcodes(const TargetRegisterClass *RC, unsigned &LoadOpcode, unsigned &StoreOpcode) const
bool isRxSBGMask(uint64_t Mask, unsigned BitSize, unsigned &Start, unsigned &End) const
bool foldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, Register Reg, MachineRegisterInfo *MRI) const override
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, Register, Register, Register, int &, int &, int &) const override
bool prepareCompareSwapOperands(MachineBasicBlock::iterator MBBI) const
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
void loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Reg, uint64_t Value) const
bool PredicateInstruction(MachineInstr &MI, ArrayRef< MachineOperand > Pred) const override
SystemZCallingConventionRegisters * getSpecialRegisters() const
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
Target - Wrapper for Target specific information.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
MCRegister getPhys(Register virtReg) const
returns the physical register mapped to the specified virtual register
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Implicit
Not emitted register (e.g. carry, or temporary result).
@ Undef
Value of the register doesn't matter.
static unsigned getAccessSize(unsigned int Flags)
unsigned getFirstReg(unsigned Reg)
MachineBasicBlock * splitBlockBefore(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
int getTargetMemOpcode(uint16_t Opcode)
const unsigned CCMASK_CMP_GT
const unsigned CCMASK_ANY
static bool isImmLL(uint64_t Val)
static bool isImmLH(uint64_t Val)
MachineBasicBlock * emitBlockAfter(MachineBasicBlock *MBB)
unsigned reverseCCMask(unsigned CCMask)
const unsigned CCMASK_CMP_EQ
const unsigned CCMASK_ICMP
MachineBasicBlock * splitBlockAfter(MachineBasicBlock::iterator MI, MachineBasicBlock *MBB)
const unsigned CCMASK_CMP_LT
const unsigned CCMASK_CMP_NE
bool isHighReg(unsigned int Reg)
const unsigned CCMASK_CMP_UO
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
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...
constexpr bool isShiftedMask_64(uint64_t Value)
Return true if the argument contains a non-empty sequence of ones with the remainder zero (64 bit ver...
constexpr size_t range_size(R &&Range)
Returns the size of the Range, i.e., the number of elements.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
unsigned getUndefRegState(bool B)
@ And
Bitwise or logical AND of integers.
unsigned getKillRegState(bool B)