67 #define GET_INSTRINFO_CTOR_DTOR 68 #include "AMDGPUGenInstrInfo.inc" 72 #define GET_D16ImageDimIntrinsics_IMPL 73 #define GET_ImageDimIntrinsicTable_IMPL 74 #define GET_RsrcIntrinsics_IMPL 75 #include "AMDGPUGenSearchableTables.inc" 85 cl::desc(
"Restrict range of branch instructions (DEBUG)"));
117 if (Op0Idx == -1 && Op1Idx == -1)
121 if ((Op0Idx == -1 && Op1Idx != -1) ||
122 (Op1Idx == -1 && Op0Idx != -1))
141 case AMDGPU::V_MOV_B32_e32:
142 case AMDGPU::V_MOV_B32_e64:
143 case AMDGPU::V_MOV_B64_PSEUDO:
152 int64_t &Offset1)
const {
160 if (!
get(Opc0).mayLoad() || !
get(Opc1).mayLoad())
184 Offset0 = cast<ConstantSDNode>(Load0->
getOperand(2))->getZExtValue();
185 Offset1 = cast<ConstantSDNode>(Load1->
getOperand(2))->getZExtValue();
206 if (!Load0Offset || !Load1Offset)
214 Offset1 = Load1Offset->getZExtValue();
231 if (OffIdx0 == -1 || OffIdx1 == -1)
244 if (!isa<ConstantSDNode>(Off0) || !isa<ConstantSDNode>(Off1))
247 Offset0 = cast<ConstantSDNode>(Off0)->getZExtValue();
248 Offset1 = cast<ConstantSDNode>(Off1)->getZExtValue();
257 case AMDGPU::DS_READ2ST64_B32:
258 case AMDGPU::DS_READ2ST64_B64:
259 case AMDGPU::DS_WRITE2ST64_B32:
260 case AMDGPU::DS_WRITE2ST64_B64:
280 BaseReg = AddrReg->
getReg();
281 Offset = OffsetImm->
getImm();
293 uint8_t Offset0 = Offset0Imm->
getImm();
294 uint8_t Offset1 = Offset1Imm->
getImm();
296 if (Offset1 > Offset0 && Offset1 - Offset0 == 1) {
314 BaseReg = AddrReg->
getReg();
315 Offset = EltSize * Offset0;
324 if (SOffset && SOffset->
isReg())
334 BaseReg = AddrReg->
getReg();
335 Offset = OffsetImm->
getImm();
338 Offset += SOffset->
getImm();
351 BaseReg = SBaseReg->
getReg();
352 Offset = OffsetImm->
getImm();
363 BaseReg = VAddr->
getReg();
378 if (BaseReg1 == BaseReg2)
386 if (MO1->getAddrSpace() != MO2->getAddrSpace())
390 auto Base2 = MO2->getValue();
391 if (!Base1 || !Base2)
398 if (isa<UndefValue>(Base1) || isa<UndefValue>(Base2))
401 return Base1 == Base2;
408 unsigned NumLoads)
const {
418 const unsigned MaxGlobalLoadCluster = 6;
419 if (NumLoads > MaxGlobalLoadCluster)
431 }
else if (
isDS(FirstLdSt) &&
isDS(SecondLdSt)) {
436 if (!FirstDst || !SecondDst)
447 unsigned LoadClusterThreshold = 16;
453 return (NumLoads * (RI.getRegSizeInBits(*DstRC) / 8)) <= LoadClusterThreshold;
467 int64_t Offset0, int64_t Offset1,
468 unsigned NumLoads)
const {
469 assert(Offset1 > Offset0 &&
470 "Second offset should be larger than first offset!");
475 return (NumLoads <= 16 && (Offset1 - Offset0) < 64);
480 const DebugLoc &DL,
unsigned DestReg,
481 unsigned SrcReg,
bool KillSrc) {
484 "illegal SGPR to VGPR copy",
489 BuildMI(MBB, MI, DL, TII->get(AMDGPU::SI_ILLEGAL_COPY), DestReg)
495 const DebugLoc &DL,
unsigned DestReg,
496 unsigned SrcReg,
bool KillSrc)
const {
499 if (RC == &AMDGPU::VGPR_32RegClass) {
501 AMDGPU::SReg_32RegClass.
contains(SrcReg));
502 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DestReg)
507 if (RC == &AMDGPU::SReg_32_XM0RegClass ||
508 RC == &AMDGPU::SReg_32RegClass) {
509 if (SrcReg == AMDGPU::SCC) {
510 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CSELECT_B32), DestReg)
516 if (!AMDGPU::SReg_32RegClass.
contains(SrcReg)) {
521 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
526 if (RC == &AMDGPU::SReg_64RegClass) {
527 if (DestReg == AMDGPU::VCC) {
528 if (AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
529 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), AMDGPU::VCC)
534 BuildMI(MBB, MI, DL,
get(AMDGPU::V_CMP_NE_U32_e32))
542 if (!AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
547 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
552 if (DestReg == AMDGPU::SCC) {
554 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CMP_LG_U32))
560 unsigned EltSize = 4;
561 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
563 if (RI.getRegSizeInBits(*RC) > 32) {
564 Opcode = AMDGPU::S_MOV_B64;
567 Opcode = AMDGPU::S_MOV_B32;
580 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
583 SubIdx = SubIndices[Idx];
585 SubIdx = SubIndices[SubIndices.
size() - Idx - 1];
588 get(Opcode), RI.getSubReg(DestReg, SubIdx));
590 Builder.
addReg(RI.getSubReg(SrcReg, SubIdx));
595 bool UseKill = KillSrc && Idx == SubIndices.
size() - 1;
620 const DebugLoc &DL,
unsigned DestReg,
621 int64_t
Value)
const {
624 if (RegClass == &AMDGPU::SReg_32RegClass ||
625 RegClass == &AMDGPU::SGPR_32RegClass ||
626 RegClass == &AMDGPU::SReg_32_XM0RegClass ||
627 RegClass == &AMDGPU::SReg_32_XM0_XEXECRegClass) {
628 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
633 if (RegClass == &AMDGPU::SReg_64RegClass ||
634 RegClass == &AMDGPU::SGPR_64RegClass ||
635 RegClass == &AMDGPU::SReg_64_XEXECRegClass) {
636 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
641 if (RegClass == &AMDGPU::VGPR_32RegClass) {
642 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DestReg)
646 if (RegClass == &AMDGPU::VReg_64RegClass) {
647 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B64_PSEUDO), DestReg)
652 unsigned EltSize = 4;
653 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
655 if (RI.getRegSizeInBits(*RegClass) > 32) {
656 Opcode = AMDGPU::S_MOV_B64;
659 Opcode = AMDGPU::S_MOV_B32;
665 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
666 int64_t IdxValue = Idx == 0 ? Value : 0;
669 get(Opcode), RI.getSubReg(DestReg, Idx));
676 return &AMDGPU::VGPR_32RegClass;
681 const DebugLoc &DL,
unsigned DstReg,
684 unsigned FalseReg)
const {
689 if (Cond.
size() == 1) {
691 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
693 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
697 }
else if (Cond.
size() == 2) {
698 assert(Cond[0].isImm() &&
"Cond[0] is not an immediate");
699 switch (Cond[0].getImm()) {
700 case SIInstrInfo::SCC_TRUE: {
702 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
705 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
711 case SIInstrInfo::SCC_FALSE: {
713 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
716 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
722 case SIInstrInfo::VCCNZ: {
726 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
728 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
734 case SIInstrInfo::VCCZ: {
738 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
740 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
746 case SIInstrInfo::EXECNZ: {
749 BuildMI(MBB, I, DL,
get(AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
751 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
754 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
760 case SIInstrInfo::EXECZ: {
763 BuildMI(MBB, I, DL,
get(AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
765 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
768 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
786 unsigned SrcReg,
int Value)
const {
789 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_EQ_I32_e64), Reg)
799 unsigned SrcReg,
int Value)
const {
802 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_NE_I32_e64), Reg)
811 if (RI.getRegSizeInBits(*DstRC) == 32) {
812 return RI.
isSGPRClass(DstRC) ? AMDGPU::S_MOV_B32 : AMDGPU::V_MOV_B32_e32;
813 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && RI.
isSGPRClass(DstRC)) {
814 return AMDGPU::S_MOV_B64;
815 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && !RI.
isSGPRClass(DstRC)) {
816 return AMDGPU::V_MOV_B64_PSEUDO;
824 return AMDGPU::SI_SPILL_S32_SAVE;
826 return AMDGPU::SI_SPILL_S64_SAVE;
828 return AMDGPU::SI_SPILL_S128_SAVE;
830 return AMDGPU::SI_SPILL_S256_SAVE;
832 return AMDGPU::SI_SPILL_S512_SAVE;
841 return AMDGPU::SI_SPILL_V32_SAVE;
843 return AMDGPU::SI_SPILL_V64_SAVE;
845 return AMDGPU::SI_SPILL_V96_SAVE;
847 return AMDGPU::SI_SPILL_V128_SAVE;
849 return AMDGPU::SI_SPILL_V256_SAVE;
851 return AMDGPU::SI_SPILL_V512_SAVE;
859 unsigned SrcReg,
bool isKill,
868 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
869 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
912 Ctx.
emitError(
"SIInstrInfo::storeRegToStackSlot - Do not know how to" 924 BuildMI(MBB, MI, DL,
get(Opcode))
936 return AMDGPU::SI_SPILL_S32_RESTORE;
938 return AMDGPU::SI_SPILL_S64_RESTORE;
940 return AMDGPU::SI_SPILL_S128_RESTORE;
942 return AMDGPU::SI_SPILL_S256_RESTORE;
944 return AMDGPU::SI_SPILL_S512_RESTORE;
953 return AMDGPU::SI_SPILL_V32_RESTORE;
955 return AMDGPU::SI_SPILL_V64_RESTORE;
957 return AMDGPU::SI_SPILL_V96_RESTORE;
959 return AMDGPU::SI_SPILL_V128_RESTORE;
961 return AMDGPU::SI_SPILL_V256_RESTORE;
963 return AMDGPU::SI_SPILL_V512_RESTORE;
978 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
979 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
1014 Ctx.
emitError(
"SIInstrInfo::loadRegFromStackSlot - Do not know how to" 1015 " restore register");
1016 BuildMI(MBB, MI, DL,
get(AMDGPU::IMPLICIT_DEF), DestReg);
1024 BuildMI(MBB, MI, DL,
get(Opcode), DestReg)
1035 unsigned FrameOffset,
unsigned Size)
const {
1047 DebugLoc DL = Insert->getDebugLoc();
1051 if (TIDReg == AMDGPU::NoRegister)
1055 WorkGroupSize > WavefrontSize) {
1062 unsigned InputPtrReg =
1064 for (
unsigned Reg : {TIDIGXReg, TIDIGYReg, TIDIGZReg}) {
1073 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp0)
1076 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp1)
1081 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_MUL_I32), STmp1)
1085 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MUL_U32_U24_e32), TIDReg)
1089 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MAD_U32_U24), TIDReg)
1099 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_LO_U32_B32_e64),
1104 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_HI_U32_B32_e64),
1110 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_LSHLREV_B32_e32),
1118 unsigned LDSOffset = MFI->
getLDSSize() + (FrameOffset * WorkGroupSize);
1137 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOP))
1155 if (HasNoTerminator)
1157 get(Info->
returnsVoid() ? AMDGPU::S_ENDPGM : AMDGPU::SI_RETURN_TO_EPILOG));
1175 case AMDGPU::S_MOV_B64_term:
1178 MI.
setDesc(
get(AMDGPU::S_MOV_B64));
1181 case AMDGPU::S_XOR_B64_term:
1184 MI.
setDesc(
get(AMDGPU::S_XOR_B64));
1187 case AMDGPU::S_ANDN2_B64_term:
1190 MI.
setDesc(
get(AMDGPU::S_ANDN2_B64));
1193 case AMDGPU::V_MOV_B64_PSEUDO: {
1195 unsigned DstLo = RI.getSubReg(Dst, AMDGPU::sub0);
1196 unsigned DstHi = RI.getSubReg(Dst, AMDGPU::sub1);
1201 if (SrcOp.
isImm()) {
1203 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1204 .
addImm(Imm.getLoBits(32).getZExtValue())
1206 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1207 .
addImm(Imm.getHiBits(32).getZExtValue())
1211 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1214 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1221 case AMDGPU::V_SET_INACTIVE_B32: {
1222 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOT_B64), AMDGPU::EXEC)
1226 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOT_B64), AMDGPU::EXEC)
1231 case AMDGPU::V_SET_INACTIVE_B64: {
1232 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOT_B64), AMDGPU::EXEC)
1238 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOT_B64), AMDGPU::EXEC)
1243 case AMDGPU::V_MOVRELD_B32_V1:
1244 case AMDGPU::V_MOVRELD_B32_V2:
1245 case AMDGPU::V_MOVRELD_B32_V4:
1246 case AMDGPU::V_MOVRELD_B32_V8:
1247 case AMDGPU::V_MOVRELD_B32_V16: {
1248 const MCInstrDesc &MovRelDesc =
get(AMDGPU::V_MOVRELD_B32_e32);
1255 BuildMI(MBB, MI, DL, MovRelDesc)
1262 const int ImpDefIdx =
1264 const int ImpUseIdx = ImpDefIdx + 1;
1265 MovRel->tieOperands(ImpDefIdx, ImpUseIdx);
1270 case AMDGPU::SI_PC_ADD_REL_OFFSET: {
1273 unsigned RegLo = RI.getSubReg(Reg, AMDGPU::sub0);
1274 unsigned RegHi = RI.getSubReg(Reg, AMDGPU::sub1);
1279 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_GETPC_B64), Reg));
1283 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_ADD_U32), RegLo)
1300 case AMDGPU::EXIT_WWM: {
1303 MI.
setDesc(
get(AMDGPU::S_MOV_B64));
1306 case TargetOpcode::BUNDLE: {
1312 I->isBundledWithSucc(); ++
I) {
1313 I->unbundleFromSucc();
1316 MO.setIsInternalRead(
false);
1328 unsigned Src0OpName,
1330 unsigned Src1OpName)
const {
1337 "All commutable instructions have both src0 and src1 modifiers");
1339 int Src0ModsVal = Src0Mods->
getImm();
1340 int Src1ModsVal = Src1Mods->
getImm();
1342 Src1Mods->
setImm(Src0ModsVal);
1343 Src0Mods->
setImm(Src1ModsVal);
1352 bool IsKill = RegOp.
isKill();
1354 bool IsUndef = RegOp.
isUndef();
1355 bool IsDebug = RegOp.
isDebug();
1357 if (NonRegOp.
isImm())
1359 else if (NonRegOp.
isFI())
1364 NonRegOp.
ChangeToRegister(Reg,
false,
false, IsKill, IsDead, IsUndef, IsDebug);
1372 unsigned Src1Idx)
const {
1373 assert(!NewMI &&
"this should never be used");
1377 if (CommutedOpcode == -1)
1381 static_cast<int>(Src0Idx) &&
1383 static_cast<int>(Src1Idx) &&
1384 "inconsistency with findCommutedOpIndices");
1411 Src1, AMDGPU::OpName::src1_modifiers);
1413 CommutedMI->
setDesc(
get(CommutedOpcode));
1423 unsigned &SrcOpIdx1)
const {
1436 return fixCommutedOpIndices(SrcOpIdx0, SrcOpIdx1, Src0Idx, Src1Idx);
1440 int64_t BrOffset)
const {
1443 assert(BranchOp != AMDGPU::S_SETPC_B64);
1457 if (MI.
getOpcode() == AMDGPU::S_SETPC_B64) {
1471 assert(RS &&
"RegScavenger required for long branching");
1473 "new block should be inserted for expanding unconditional branch");
1490 if (BrOffset >= 0) {
1491 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADD_U32))
1493 .
addReg(PCReg, 0, AMDGPU::sub0)
1495 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADDC_U32))
1497 .
addReg(PCReg, 0, AMDGPU::sub1)
1501 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUB_U32))
1503 .
addReg(PCReg, 0, AMDGPU::sub0)
1505 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUBB_U32))
1507 .
addReg(PCReg, 0, AMDGPU::sub1)
1512 BuildMI(&MBB, DL,
get(AMDGPU::S_SETPC_B64))
1558 return 4 + 8 + 4 + 4;
1561 unsigned SIInstrInfo::getBranchOpcode(SIInstrInfo::BranchPredicate Cond) {
1563 case SIInstrInfo::SCC_TRUE:
1564 return AMDGPU::S_CBRANCH_SCC1;
1565 case SIInstrInfo::SCC_FALSE:
1566 return AMDGPU::S_CBRANCH_SCC0;
1567 case SIInstrInfo::VCCNZ:
1568 return AMDGPU::S_CBRANCH_VCCNZ;
1569 case SIInstrInfo::VCCZ:
1570 return AMDGPU::S_CBRANCH_VCCZ;
1571 case SIInstrInfo::EXECNZ:
1572 return AMDGPU::S_CBRANCH_EXECNZ;
1573 case SIInstrInfo::EXECZ:
1574 return AMDGPU::S_CBRANCH_EXECZ;
1580 SIInstrInfo::BranchPredicate SIInstrInfo::getBranchPredicate(
unsigned Opcode) {
1582 case AMDGPU::S_CBRANCH_SCC0:
1584 case AMDGPU::S_CBRANCH_SCC1:
1586 case AMDGPU::S_CBRANCH_VCCNZ:
1588 case AMDGPU::S_CBRANCH_VCCZ:
1590 case AMDGPU::S_CBRANCH_EXECNZ:
1592 case AMDGPU::S_CBRANCH_EXECZ:
1604 bool AllowModify)
const {
1605 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1607 TBB = I->getOperand(0).getMBB();
1613 if (I->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
1614 CondBB = I->getOperand(1).getMBB();
1617 BranchPredicate Pred = getBranchPredicate(I->getOpcode());
1618 if (Pred == INVALID_BR)
1621 CondBB = I->getOperand(0).getMBB();
1627 if (I == MBB.
end()) {
1633 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1635 FBB = I->getOperand(0).getMBB();
1645 bool AllowModify)
const {
1650 if (I->getOpcode() != AMDGPU::SI_MASK_BRANCH)
1673 if (TBB != MaskBrDest || Cond.
empty())
1676 auto Pred = Cond[0].getImm();
1677 return (Pred != EXECZ && Pred != EXECNZ);
1681 int *BytesRemoved)
const {
1685 unsigned RemovedSize = 0;
1686 while (I != MBB.
end()) {
1688 if (I->getOpcode() == AMDGPU::SI_MASK_BRANCH) {
1694 I->eraseFromParent();
1700 *BytesRemoved = RemovedSize;
1717 int *BytesAdded)
const {
1718 if (!FBB && Cond.
empty()) {
1719 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
1726 if(Cond.
size() == 1 && Cond[0].isReg()) {
1727 BuildMI(&MBB, DL,
get(AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO))
1733 assert(TBB && Cond[0].isImm());
1736 = getBranchOpcode(static_cast<BranchPredicate>(Cond[0].getImm()));
1741 BuildMI(&MBB, DL,
get(Opcode))
1755 BuildMI(&MBB, DL,
get(Opcode))
1757 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
1772 if (Cond.
size() != 2) {
1776 if (Cond[0].isImm()) {
1777 Cond[0].setImm(-Cond[0].getImm());
1786 unsigned TrueReg,
unsigned FalseReg,
1788 int &TrueCycles,
int &FalseCycles)
const {
1789 switch (Cond[0].getImm()) {
1797 CondCycles = TrueCycles = FalseCycles = NumInsts;
1813 if (NumInsts % 2 == 0)
1816 CondCycles = TrueCycles = FalseCycles = NumInsts;
1827 unsigned TrueReg,
unsigned FalseReg)
const {
1828 BranchPredicate Pred =
static_cast<BranchPredicate
>(Cond[0].getImm());
1829 if (Pred == VCCZ || Pred == SCC_FALSE) {
1830 Pred =
static_cast<BranchPredicate
>(-Pred);
1836 unsigned DstSize = RI.getRegSizeInBits(*DstRC);
1838 if (DstSize == 32) {
1839 unsigned SelOp = Pred == SCC_TRUE ?
1840 AMDGPU::S_CSELECT_B32 : AMDGPU::V_CNDMASK_B32_e32;
1844 BuildMI(MBB, I, DL,
get(SelOp), DstReg)
1852 if (DstSize == 64 && Pred == SCC_TRUE) {
1854 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), DstReg)
1862 static const int16_t Sub0_15[] = {
1863 AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3,
1864 AMDGPU::sub4, AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7,
1865 AMDGPU::sub8, AMDGPU::sub9, AMDGPU::sub10, AMDGPU::sub11,
1866 AMDGPU::sub12, AMDGPU::sub13, AMDGPU::sub14, AMDGPU::sub15,
1869 static const int16_t Sub0_15_64[] = {
1870 AMDGPU::sub0_sub1, AMDGPU::sub2_sub3,
1871 AMDGPU::sub4_sub5, AMDGPU::sub6_sub7,
1872 AMDGPU::sub8_sub9, AMDGPU::sub10_sub11,
1873 AMDGPU::sub12_sub13, AMDGPU::sub14_sub15,
1876 unsigned SelOp = AMDGPU::V_CNDMASK_B32_e32;
1878 const int16_t *SubIndices = Sub0_15;
1879 int NElts = DstSize / 32;
1882 if (Pred == SCC_TRUE) {
1883 SelOp = AMDGPU::S_CSELECT_B64;
1884 EltRC = &AMDGPU::SGPR_64RegClass;
1885 SubIndices = Sub0_15_64;
1892 MBB, I, DL,
get(AMDGPU::REG_SEQUENCE), DstReg);
1897 for (
int Idx = 0; Idx != NElts; ++Idx) {
1901 unsigned SubIdx = SubIndices[Idx];
1904 BuildMI(MBB, I, DL,
get(SelOp), DstElt)
1905 .
addReg(FalseReg, 0, SubIdx)
1906 .
addReg(TrueReg, 0, SubIdx);
1916 case AMDGPU::V_MOV_B32_e32:
1917 case AMDGPU::V_MOV_B32_e64:
1918 case AMDGPU::V_MOV_B64_PSEUDO: {
1926 case AMDGPU::S_MOV_B32:
1927 case AMDGPU::S_MOV_B64:
1955 AMDGPU::OpName::src0_modifiers);
1957 AMDGPU::OpName::src1_modifiers);
1959 AMDGPU::OpName::src2_modifiers);
1974 case AMDGPU::S_MOV_B64:
1979 case AMDGPU::V_MOV_B32_e32:
1980 case AMDGPU::S_MOV_B32:
1987 if (!ImmOp->
isImm())
1991 if (Opc == AMDGPU::COPY) {
1993 unsigned NewOpc = isVGPRCopy ? AMDGPU::V_MOV_B32_e32 : AMDGPU::S_MOV_B32;
2000 if (Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64 ||
2001 Opc == AMDGPU::V_MAD_F16 || Opc == AMDGPU::V_MAC_F16_e64) {
2016 bool IsF32 = Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64;
2031 const int64_t Imm = ImmOp->
getImm();
2042 unsigned Src1Reg = Src1->
getReg();
2043 unsigned Src1SubReg = Src1->
getSubReg();
2048 if (Opc == AMDGPU::V_MAC_F32_e64 ||
2049 Opc == AMDGPU::V_MAC_F16_e64)
2056 UseMI.
setDesc(
get(IsF32 ? AMDGPU::V_MADMK_F32 : AMDGPU::V_MADMK_F16));
2069 if (!Src0->
isImm() &&
2076 const int64_t Imm = ImmOp->
getImm();
2087 if (Opc == AMDGPU::V_MAC_F32_e64 ||
2088 Opc == AMDGPU::V_MAC_F16_e64)
2097 UseMI.
setDesc(
get(IsF32 ? AMDGPU::V_MADAK_F32 : AMDGPU::V_MADAK_F16));
2111 int WidthB,
int OffsetB) {
2112 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
2113 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
2114 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
2115 return LowOffset + LowWidth <= HighOffset;
2118 bool SIInstrInfo::checkInstOffsetsDoNotOverlap(
MachineInstr &MIa,
2120 unsigned BaseReg0, BaseReg1;
2121 int64_t Offset0, Offset1;
2132 if (BaseReg0 == BaseReg1 &&
2145 "MIa must load from or modify a memory location");
2147 "MIb must load from or modify a memory location");
2162 if (!AA->
alias(LocA, LocB))
2174 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2181 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2188 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2195 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2209 if (
Def &&
Def->getOpcode() == AMDGPU::V_MOV_B32_e32 &&
2210 Def->getOperand(1).isImm())
2211 return Def->getOperand(1).getImm();
2212 return AMDGPU::NoRegister;
2220 bool IsFMA = Opc == AMDGPU::V_FMAC_F32_e32 || Opc == AMDGPU::V_FMAC_F32_e64;
2225 case AMDGPU::V_MAC_F16_e64:
2228 case AMDGPU::V_MAC_F32_e64:
2229 case AMDGPU::V_FMAC_F32_e64:
2231 case AMDGPU::V_MAC_F16_e32:
2234 case AMDGPU::V_MAC_F32_e32:
2235 case AMDGPU::V_FMAC_F32_e32: {
2237 AMDGPU::OpName::src0);
2239 if (!Src0->isReg() && !Src0->isImm())
2260 if (!IsFMA && !Src0Mods && !Src1Mods && !Clamp && !Omod &&
2265 get(IsF16 ? AMDGPU::V_MADAK_F16 : AMDGPU::V_MADAK_F32))
2273 get(IsF16 ? AMDGPU::V_MADMK_F16 : AMDGPU::V_MADMK_F32))
2281 AMDGPU::OpName::src0), Src1))
2283 get(IsF16 ? AMDGPU::V_MADMK_F16 : AMDGPU::V_MADMK_F32))
2291 assert((!IsFMA || !IsF16) &&
"fmac only expected with f32");
2292 unsigned NewOpc = IsFMA ? AMDGPU::V_FMA_F32 :
2293 (IsF16 ? AMDGPU::V_MAD_F16 : AMDGPU::V_MAD_F32);
2298 .addImm(Src1Mods ? Src1Mods->
getImm() : 0)
2302 .addImm(Clamp ? Clamp->
getImm() : 0)
2303 .addImm(Omod ? Omod->
getImm() : 0);
2311 case AMDGPU::S_SET_GPR_IDX_ON:
2312 case AMDGPU::S_SET_GPR_IDX_MODE:
2313 case AMDGPU::S_SET_GPR_IDX_OFF:
2330 MI.
getOpcode() == AMDGPU::S_SETREG_IMM32_B32 ||
2331 MI.
getOpcode() == AMDGPU::S_SETREG_B32 ||
2347 if (Opcode == AMDGPU::S_SENDMSG || Opcode == AMDGPU::S_SENDMSGHALT ||
2348 Opcode ==
AMDGPU::EXP || Opcode == AMDGPU::EXP_DONE)
2359 if (Opcode == AMDGPU::V_READFIRSTLANE_B32 || Opcode == AMDGPU::V_READLANE_B32)
2394 int64_t Imm = MO.
getImm();
2395 switch (OperandType) {
2400 int32_t Trunc =
static_cast<int32_t
>(Imm);
2401 return Trunc == Imm &&
2419 int16_t Trunc =
static_cast<int16_t
>(Imm);
2429 int16_t Trunc =
static_cast<int16_t
>(Imm);
2433 if (!(Imm & 0xffff)) {
2509 AMDGPU::OpName::src0_modifiers) != -1;
2515 return Mods && Mods->
getImm();
2553 return (MO.
getReg() == AMDGPU::VCC || MO.
getReg() == AMDGPU::M0 ||
2555 (AMDGPU::SGPR_32RegClass.contains(MO.
getReg()) ||
2565 switch (MO.getReg()) {
2568 case AMDGPU::FLAT_SCR:
2576 return AMDGPU::NoRegister;
2582 case AMDGPU::V_READLANE_B32:
2583 case AMDGPU::V_READLANE_B32_si:
2584 case AMDGPU::V_READLANE_B32_vi:
2585 case AMDGPU::V_WRITELANE_B32:
2586 case AMDGPU::V_WRITELANE_B32_si:
2587 case AMDGPU::V_WRITELANE_B32_vi:
2594 if (SIInstrInfo::isGenericOpcode(MI.
getOpcode()) ||
2606 return TRI.isSubRegister(SuperVec.
getReg(), SubReg.
getReg());
2608 return SubReg.
getSubReg() != AMDGPU::NoSubRegister &&
2615 if (SIInstrInfo::isGenericOpcode(MI.
getOpcode()))
2629 ErrInfo =
"Instruction has wrong number of operands.";
2647 ErrInfo =
"inlineasm operand has incorrect register class.";
2658 ErrInfo =
"FPImm Machine Operands are not supported. ISel should bitcast " 2659 "all fp values to integers.";
2668 ErrInfo =
"Illegal immediate value for operand.";
2683 ErrInfo =
"Illegal immediate value for operand.";
2694 ErrInfo =
"Expected immediate, but got non-immediate";
2705 if (RegClass != -1) {
2707 if (Reg == AMDGPU::NoRegister ||
2713 ErrInfo =
"Operand has incorrect register class.";
2722 ErrInfo =
"SDWA is not supported on this target";
2728 const int OpIndicies[] = { DstIdx, Src0Idx, Src1Idx, Src2Idx };
2730 for (
int OpIdx: OpIndicies) {
2738 ErrInfo =
"Only VGPRs allowed as operands in SDWA instructions on VI";
2744 ErrInfo =
"Only reg allowed as operands in SDWA instructions on GFX9";
2753 if (OMod !=
nullptr &&
2755 ErrInfo =
"OMod not allowed in SDWA instructions on VI";
2761 if (
isVOPC(BasicOpcode)) {
2765 if (!Dst.
isReg() || Dst.
getReg() != AMDGPU::VCC) {
2766 ErrInfo =
"Only VCC allowed as dst in SDWA instructions on VI";
2772 if (Clamp && (!Clamp->
isImm() || Clamp->
getImm() != 0)) {
2773 ErrInfo =
"Clamp not allowed in VOPC SDWA instructions on VI";
2779 if (OMod && (!OMod->
isImm() || OMod->
getImm() != 0)) {
2780 ErrInfo =
"OMod not allowed in VOPC SDWA instructions on VI";
2787 if (DstUnused && DstUnused->
isImm() &&
2791 ErrInfo =
"Dst register should have tied register";
2799 "Dst register should be tied to implicit use of preserved register";
2803 ErrInfo =
"Dst register should use same physical register as preserved";
2810 if (Desc.
getOpcode() != AMDGPU::V_WRITELANE_B32
2815 const int OpIndices[] = { Src0Idx, Src1Idx, Src2Idx };
2817 unsigned ConstantBusCount = 0;
2818 unsigned LiteralCount = 0;
2824 if (SGPRUsed != AMDGPU::NoRegister)
2827 for (
int OpIdx : OpIndices) {
2833 if (MO.
getReg() != SGPRUsed)
2842 if (ConstantBusCount > 1) {
2843 ErrInfo =
"VOP* instruction uses the constant bus more than once";
2847 if (
isVOP3(MI) && LiteralCount) {
2848 ErrInfo =
"VOP3 instruction uses literal";
2854 if (Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F32 ||
2855 Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F64) {
2862 ErrInfo =
"v_div_scale_{f32|f64} require src0 = src1 or src2";
2872 ErrInfo =
"invalid immediate for SOPK instruction";
2877 ErrInfo =
"invalid immediate for SOPK instruction";
2883 if (Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e32 ||
2884 Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e64 ||
2885 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
2886 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64) {
2887 const bool IsDst = Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
2888 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64;
2892 const unsigned NumImplicitOps = IsDst ? 2 : 1;
2898 ErrInfo =
"missing implicit register operands";
2904 if (!Dst->
isUse()) {
2905 ErrInfo =
"v_movreld_b32 vdst should be a use operand";
2911 UseOpIdx != StaticNumOps + 1) {
2912 ErrInfo =
"movrel implicit operands should be tied";
2919 = MI.
getOperand(StaticNumOps + NumImplicitOps - 1);
2921 !
isSubRegOf(RI, ImpUse, IsDst ? *Dst : Src0)) {
2922 ErrInfo =
"src0 should be subreg of implicit vector use";
2931 ErrInfo =
"VALU instruction does not implicitly read exec mask";
2941 if (Soff && Soff->
getReg() != AMDGPU::M0) {
2942 ErrInfo =
"scalar stores must use m0 as offset register";
2950 if (Offset->
getImm() != 0) {
2951 ErrInfo =
"subtarget does not support offsets in flat instructions";
2967 ErrInfo =
"Invalid dpp_ctrl value";
2977 default:
return AMDGPU::INSTRUCTION_LIST_END;
2978 case AMDGPU::REG_SEQUENCE:
return AMDGPU::REG_SEQUENCE;
2979 case AMDGPU::COPY:
return AMDGPU::COPY;
2980 case AMDGPU::PHI:
return AMDGPU::PHI;
2981 case AMDGPU::INSERT_SUBREG:
return AMDGPU::INSERT_SUBREG;
2983 case AMDGPU::WWM:
return AMDGPU::WWM;
2984 case AMDGPU::S_MOV_B32:
2986 AMDGPU::COPY : AMDGPU::V_MOV_B32_e32;
2987 case AMDGPU::S_ADD_I32:
2988 return ST.hasAddNoCarry() ? AMDGPU::V_ADD_U32_e64 : AMDGPU::V_ADD_I32_e32;
2989 case AMDGPU::S_ADDC_U32:
2990 return AMDGPU::V_ADDC_U32_e32;
2991 case AMDGPU::S_SUB_I32:
2992 return ST.hasAddNoCarry() ? AMDGPU::V_SUB_U32_e64 : AMDGPU::V_SUB_I32_e32;
2995 case AMDGPU::S_ADD_U32:
2996 return AMDGPU::V_ADD_I32_e32;
2997 case AMDGPU::S_SUB_U32:
2998 return AMDGPU::V_SUB_I32_e32;
2999 case AMDGPU::S_SUBB_U32:
return AMDGPU::V_SUBB_U32_e32;
3000 case AMDGPU::S_MUL_I32:
return AMDGPU::V_MUL_LO_I32;
3001 case AMDGPU::S_AND_B32:
return AMDGPU::V_AND_B32_e64;
3002 case AMDGPU::S_OR_B32:
return AMDGPU::V_OR_B32_e64;
3003 case AMDGPU::S_XOR_B32:
return AMDGPU::V_XOR_B32_e64;
3004 case AMDGPU::S_MIN_I32:
return AMDGPU::V_MIN_I32_e64;
3005 case AMDGPU::S_MIN_U32:
return AMDGPU::V_MIN_U32_e64;
3006 case AMDGPU::S_MAX_I32:
return AMDGPU::V_MAX_I32_e64;
3007 case AMDGPU::S_MAX_U32:
return AMDGPU::V_MAX_U32_e64;
3008 case AMDGPU::S_ASHR_I32:
return AMDGPU::V_ASHR_I32_e32;
3009 case AMDGPU::S_ASHR_I64:
return AMDGPU::V_ASHR_I64;
3010 case AMDGPU::S_LSHL_B32:
return AMDGPU::V_LSHL_B32_e32;
3011 case AMDGPU::S_LSHL_B64:
return AMDGPU::V_LSHL_B64;
3012 case AMDGPU::S_LSHR_B32:
return AMDGPU::V_LSHR_B32_e32;
3013 case AMDGPU::S_LSHR_B64:
return AMDGPU::V_LSHR_B64;
3014 case AMDGPU::S_SEXT_I32_I8:
return AMDGPU::V_BFE_I32;
3015 case AMDGPU::S_SEXT_I32_I16:
return AMDGPU::V_BFE_I32;
3016 case AMDGPU::S_BFE_U32:
return AMDGPU::V_BFE_U32;
3017 case AMDGPU::S_BFE_I32:
return AMDGPU::V_BFE_I32;
3018 case AMDGPU::S_BFM_B32:
return AMDGPU::V_BFM_B32_e64;
3019 case AMDGPU::S_BREV_B32:
return AMDGPU::V_BFREV_B32_e32;
3020 case AMDGPU::S_NOT_B32:
return AMDGPU::V_NOT_B32_e32;
3021 case AMDGPU::S_NOT_B64:
return AMDGPU::V_NOT_B32_e32;
3022 case AMDGPU::S_CMP_EQ_I32:
return AMDGPU::V_CMP_EQ_I32_e32;
3023 case AMDGPU::S_CMP_LG_I32:
return AMDGPU::V_CMP_NE_I32_e32;
3024 case AMDGPU::S_CMP_GT_I32:
return AMDGPU::V_CMP_GT_I32_e32;
3025 case AMDGPU::S_CMP_GE_I32:
return AMDGPU::V_CMP_GE_I32_e32;
3026 case AMDGPU::S_CMP_LT_I32:
return AMDGPU::V_CMP_LT_I32_e32;
3027 case AMDGPU::S_CMP_LE_I32:
return AMDGPU::V_CMP_LE_I32_e32;
3028 case AMDGPU::S_CMP_EQ_U32:
return AMDGPU::V_CMP_EQ_U32_e32;
3029 case AMDGPU::S_CMP_LG_U32:
return AMDGPU::V_CMP_NE_U32_e32;
3030 case AMDGPU::S_CMP_GT_U32:
return AMDGPU::V_CMP_GT_U32_e32;
3031 case AMDGPU::S_CMP_GE_U32:
return AMDGPU::V_CMP_GE_U32_e32;
3032 case AMDGPU::S_CMP_LT_U32:
return AMDGPU::V_CMP_LT_U32_e32;
3033 case AMDGPU::S_CMP_LE_U32:
return AMDGPU::V_CMP_LE_U32_e32;
3034 case AMDGPU::S_CMP_EQ_U64:
return AMDGPU::V_CMP_EQ_U64_e32;
3035 case AMDGPU::S_CMP_LG_U64:
return AMDGPU::V_CMP_NE_U64_e32;
3036 case AMDGPU::S_BCNT1_I32_B32:
return AMDGPU::V_BCNT_U32_B32_e64;
3037 case AMDGPU::S_FF1_I32_B32:
return AMDGPU::V_FFBL_B32_e32;
3038 case AMDGPU::S_FLBIT_I32_B32:
return AMDGPU::V_FFBH_U32_e32;
3039 case AMDGPU::S_FLBIT_I32:
return AMDGPU::V_FFBH_I32_e64;
3040 case AMDGPU::S_CBRANCH_SCC0:
return AMDGPU::S_CBRANCH_VCCZ;
3041 case AMDGPU::S_CBRANCH_SCC1:
return AMDGPU::S_CBRANCH_VCCNZ;
3046 unsigned OpNo)
const {
3055 return RI.getPhysRegClass(Reg);
3059 return RI.getRegClass(RCID);
3065 case AMDGPU::REG_SEQUENCE:
3067 case AMDGPU::INSERT_SUBREG:
3079 unsigned RCID =
get(MI.
getOpcode()).OpInfo[OpIdx].RegClass;
3081 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
3083 Opcode = AMDGPU::COPY;
3084 else if (RI.isSGPRClass(RC))
3085 Opcode = AMDGPU::S_MOV_B32;
3088 if (RI.getCommonSubClass(&AMDGPU::VReg_64RegClass, VRC))
3089 VRC = &AMDGPU::VReg_64RegClass;
3091 VRC = &AMDGPU::VGPR_32RegClass;
3110 if (SuperReg.
getSubReg() == AMDGPU::NoSubRegister) {
3111 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
3122 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), NewSuperReg)
3125 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
3126 .
addReg(NewSuperReg, 0, SubIdx);
3139 if (SubIdx == AMDGPU::sub0)
3141 if (SubIdx == AMDGPU::sub1)
3153 void SIInstrInfo::swapOperands(
MachineInstr &Inst)
const {
3170 RI.getPhysRegClass(Reg);
3185 return RI.getCommonSubClass(RC, RI.getRegClass(OpInfo.
RegClass)) == RC;
3261 if (HasImplicitSGPR) {
3265 if (Src0.
isReg() && RI.isSGPRReg(MRI, Src0.
getReg()))
3272 if (Opc == AMDGPU::V_WRITELANE_B32) {
3276 if (Src0.
isReg() && RI.isVGPR(MRI, Src0.
getReg())) {
3282 if (Src1.
isReg() && RI.isVGPR(MRI, Src1.
getReg())) {
3300 if (Opc == AMDGPU::V_READLANE_B32 && Src1.
isReg() &&
3301 RI.isVGPR(MRI, Src1.
getReg())) {
3334 if (CommutedOpc == -1) {
3341 unsigned Src0Reg = Src0.
getReg();
3343 bool Src0Kill = Src0.
isKill();
3347 else if (Src1.
isReg()) {
3372 unsigned SGPRReg = findUsedSGPR(MI, VOP3Idx);
3374 for (
unsigned i = 0; i < 3; ++i) {
3375 int Idx = VOP3Idx[i];
3387 if (SGPRReg == AMDGPU::NoRegister || SGPRReg == MO.
getReg()) {
3404 unsigned SubRegs = RI.getRegSizeInBits(*VRC) / 32;
3408 get(AMDGPU::V_READFIRSTLANE_B32), DstReg)
3414 for (
unsigned i = 0; i < SubRegs; ++i) {
3417 get(AMDGPU::V_READFIRSTLANE_B32), SGPR)
3418 .
addReg(SrcReg, 0, RI.getSubRegFromChannel(i));
3424 get(AMDGPU::REG_SEQUENCE), DstReg);
3425 for (
unsigned i = 0; i < SubRegs; ++i) {
3427 MIB.
addImm(RI.getSubRegFromChannel(i));
3452 unsigned OpReg = Op.
getReg();
3456 RI.getRegClassForReg(MRI, OpReg), OpSubReg);
3464 BuildMI(InsertMBB, I, DL,
get(AMDGPU::COPY), DstReg).
add(Op);
3511 if (RI.hasVGPRs(OpRC)) {
3524 VRC = RI.getEquivalentVGPRClass(SRC);
3550 if (MI.
getOpcode() == AMDGPU::REG_SEQUENCE) {
3553 if (RI.hasVGPRs(DstRC)) {
3577 if (MI.
getOpcode() == AMDGPU::INSERT_SUBREG) {
3582 if (DstRC != Src0RC) {
3591 if (MI.
getOpcode() == AMDGPU::SI_INIT_M0) {
3626 if (SRsrcIdx != -1) {
3629 unsigned SRsrcRC =
get(MI.
getOpcode()).OpInfo[SRsrcIdx].RegClass;
3631 RI.getRegClass(SRsrcRC))) {
3641 &AMDGPU::VReg_128RegClass, AMDGPU::sub0_sub1, &AMDGPU::VReg_64RegClass);
3656 .
addImm(RsrcDataFormat & 0xFFFFFFFF);
3660 .
addImm(RsrcDataFormat >> 32);
3665 .
addImm(AMDGPU::sub0_sub1)
3681 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADD_I32_e32), NewVAddrLo)
3682 .
addReg(SRsrcPtr, 0, AMDGPU::sub0)
3686 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADDC_U32_e32), NewVAddrHi)
3687 .
addReg(SRsrcPtr, 0, AMDGPU::sub1)
3701 "FIXME: Need to emit flat atomics here");
3718 .
addReg(AMDGPU::NoRegister)
3728 MIB.
addImm(GLC->getImm());
3735 MIB.
addImm(TFE->getImm());
3745 .
addReg(AMDGPU::NoRegister)
3760 .
addReg(SRsrcPtr, 0, AMDGPU::sub0)
3762 .
addReg(SRsrcPtr, 0, AMDGPU::sub1)
3778 Worklist.
insert(&TopInst);
3780 while (!Worklist.
empty()) {
3792 case AMDGPU::S_ADD_U64_PSEUDO:
3793 case AMDGPU::S_SUB_U64_PSEUDO:
3794 splitScalar64BitAddSub(Worklist, Inst);
3797 case AMDGPU::S_ADD_I32:
3798 case AMDGPU::S_SUB_I32:
3800 if (moveScalarAddSub(Worklist, Inst))
3805 case AMDGPU::S_AND_B64:
3806 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_AND_B32_e64);
3810 case AMDGPU::S_OR_B64:
3811 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_OR_B32_e64);
3815 case AMDGPU::S_XOR_B64:
3816 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_XOR_B32_e64);
3820 case AMDGPU::S_NOT_B64:
3821 splitScalar64BitUnaryOp(Worklist, Inst, AMDGPU::V_NOT_B32_e32);
3825 case AMDGPU::S_BCNT1_I32_B64:
3826 splitScalar64BitBCNT(Worklist, Inst);
3830 case AMDGPU::S_BFE_I64:
3831 splitScalar64BitBFE(Worklist, Inst);
3835 case AMDGPU::S_LSHL_B32:
3837 NewOpcode = AMDGPU::V_LSHLREV_B32_e64;
3841 case AMDGPU::S_ASHR_I32:
3843 NewOpcode = AMDGPU::V_ASHRREV_I32_e64;
3847 case AMDGPU::S_LSHR_B32:
3849 NewOpcode = AMDGPU::V_LSHRREV_B32_e64;
3853 case AMDGPU::S_LSHL_B64:
3855 NewOpcode = AMDGPU::V_LSHLREV_B64;
3859 case AMDGPU::S_ASHR_I64:
3861 NewOpcode = AMDGPU::V_ASHRREV_I64;
3865 case AMDGPU::S_LSHR_B64:
3867 NewOpcode = AMDGPU::V_LSHRREV_B64;
3872 case AMDGPU::S_ABS_I32:
3873 lowerScalarAbs(Worklist, Inst);
3877 case AMDGPU::S_CBRANCH_SCC0:
3878 case AMDGPU::S_CBRANCH_SCC1:
3886 case AMDGPU::S_BFE_U64:
3887 case AMDGPU::S_BFM_B64:
3890 case AMDGPU::S_PACK_LL_B32_B16:
3891 case AMDGPU::S_PACK_LH_B32_B16:
3892 case AMDGPU::S_PACK_HH_B32_B16:
3893 movePackToVALU(Worklist, MRI, Inst);
3897 case AMDGPU::S_XNOR_B32:
3898 lowerScalarXnor(Worklist, Inst);
3902 case AMDGPU::S_XNOR_B64:
3903 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_XNOR_B32);
3907 case AMDGPU::S_BUFFER_LOAD_DWORD_SGPR: {
3923 (
Add->getOpcode() == AMDGPU::V_ADD_I32_e32 ||
3924 Add->getOpcode() == AMDGPU::V_ADD_U32_e64)) {
3925 static const unsigned SrcNames[2] = {
3926 AMDGPU::OpName::src0,
3927 AMDGPU::OpName::src1,
3931 for (
int i = 0; i < 2; i++) {
3937 if (Mov && Mov->getOpcode() == AMDGPU::S_MOV_B32)
3938 Src = &Mov->getOperand(1);
3959 get(AMDGPU::BUFFER_LOAD_DWORD_OFFEN), VDst)
3972 addUsersToMoveToVALUWorklist(VDst, MRI, Worklist);
3982 if (NewOpcode == AMDGPU::INSTRUCTION_LIST_END) {
4000 addSCCDefUsersToVALUWorklist(Inst, Worklist);
4004 if (Opcode == AMDGPU::S_SEXT_I32_I8 || Opcode == AMDGPU::S_SEXT_I32_I16) {
4007 unsigned Size = (Opcode == AMDGPU::S_SEXT_I32_I8) ? 8 : 16;
4011 }
else if (Opcode == AMDGPU::S_BCNT1_I32_B32) {
4019 if (Opcode == AMDGPU::S_BFE_I32 || Opcode == AMDGPU::S_BFE_U32) {
4024 "Scalar BFE is only implemented for constant width and offset");
4028 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
4035 unsigned NewDstReg = AMDGPU::NoRegister;
4055 addUsersToMoveToVALUWorklist(DstReg, MRI, Worklist);
4065 Inst.
setDesc(
get(AMDGPU::IMPLICIT_DEF));
4077 addUsersToMoveToVALUWorklist(NewDstReg, MRI, Worklist);
4084 if (ST.hasAddNoCarry()) {
4096 assert(Opc == AMDGPU::S_ADD_I32 || Opc == AMDGPU::S_SUB_I32);
4098 unsigned NewOpc = Opc == AMDGPU::S_ADD_I32 ?
4099 AMDGPU::V_ADD_U32_e64 : AMDGPU::V_SUB_U32_e64;
4109 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4128 unsigned SubOp = ST.hasAddNoCarry() ?
4129 AMDGPU::V_SUB_U32_e32 : AMDGPU::V_SUB_I32_e32;
4131 BuildMI(MBB, MII, DL,
get(SubOp), TmpReg)
4135 BuildMI(MBB, MII, DL,
get(AMDGPU::V_MAX_I32_e64), ResultReg)
4140 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4158 if (ST.hasDLInsts()) {
4159 BuildMI(MBB, MII, DL,
get(AMDGPU::V_XNOR_B32_e64), NewDest)
4164 BuildMI(MBB, MII, DL,
get(AMDGPU::V_XOR_B32_e64), Xor)
4168 BuildMI(MBB, MII, DL,
get(AMDGPU::V_NOT_B32_e64), NewDest)
4173 addUsersToMoveToVALUWorklist(NewDest, MRI, Worklist);
4176 void SIInstrInfo::splitScalar64BitUnaryOp(
4178 unsigned Opcode)
const {
4191 &AMDGPU::SGPR_32RegClass;
4196 AMDGPU::sub0, Src0SubRC);
4203 BuildMI(MBB, MII, DL, InstDesc, DestSub0).
add(SrcReg0Sub0);
4206 AMDGPU::sub1, Src0SubRC);
4209 BuildMI(MBB, MII, DL, InstDesc, DestSub1).
add(SrcReg0Sub1);
4212 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
4224 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
4227 void SIInstrInfo::splitScalar64BitAddSub(
4229 bool IsAdd = (Inst.
getOpcode() == AMDGPU::S_ADD_U64_PSEUDO);
4253 AMDGPU::sub0, Src0SubRC);
4255 AMDGPU::sub0, Src1SubRC);
4259 AMDGPU::sub1, Src0SubRC);
4261 AMDGPU::sub1, Src1SubRC);
4263 unsigned LoOpc = IsAdd ? AMDGPU::V_ADD_I32_e64 : AMDGPU::V_SUB_I32_e64;
4265 BuildMI(MBB, MII, DL,
get(LoOpc), DestSub0)
4270 unsigned HiOpc = IsAdd ? AMDGPU::V_ADDC_U32_e64 : AMDGPU::V_SUBB_U32_e64;
4272 BuildMI(MBB, MII, DL,
get(HiOpc), DestSub1)
4278 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
4292 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
4295 void SIInstrInfo::splitScalar64BitBinaryOp(
4297 unsigned Opcode)
const {
4311 &AMDGPU::SGPR_32RegClass;
4316 &AMDGPU::SGPR_32RegClass;
4321 AMDGPU::sub0, Src0SubRC);
4323 AMDGPU::sub0, Src1SubRC);
4335 AMDGPU::sub1, Src0SubRC);
4337 AMDGPU::sub1, Src1SubRC);
4345 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
4359 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
4362 void SIInstrInfo::splitScalar64BitBCNT(
4373 const MCInstrDesc &InstDesc =
get(AMDGPU::V_BCNT_U32_B32_e64);
4376 &AMDGPU::SGPR_32RegClass;
4384 AMDGPU::sub0, SrcSubRC);
4386 AMDGPU::sub1, SrcSubRC);
4396 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4399 void SIInstrInfo::splitScalar64BitBFE(
SetVectorType &Worklist,
4409 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
4415 Offset == 0 &&
"Not implemented");
4417 if (BitWidth < 32) {
4422 BuildMI(MBB, MII, DL,
get(AMDGPU::V_BFE_I32), MidRegLo)
4427 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e32), MidRegHi)
4431 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
4438 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4446 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e64), TmpReg)
4450 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
4452 .addImm(AMDGPU::sub0)
4457 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4460 void SIInstrInfo::addUsersToMoveToVALUWorklist(
4472 }
while (
I !=
E &&
I->getParent() == &
UseMI);
4489 case AMDGPU::S_PACK_LL_B32_B16: {
4495 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
4498 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_B32_e64), TmpReg)
4502 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHL_OR_B32), ResultReg)
4508 case AMDGPU::S_PACK_LH_B32_B16: {
4510 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
4512 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_BFI_B32), ResultReg)
4518 case AMDGPU::S_PACK_HH_B32_B16: {
4521 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHRREV_B32_e64), TmpReg)
4524 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
4526 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_OR_B32), ResultReg)
4538 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
4541 void SIInstrInfo::addSCCDefUsersToVALUWorklist(
4549 if (
MI.findRegisterDefOperandIdx(AMDGPU::SCC) != -1)
4552 if (
MI.findRegisterUseOperandIdx(AMDGPU::SCC) != -1)
4567 case AMDGPU::REG_SEQUENCE:
4568 case AMDGPU::INSERT_SUBREG:
4571 if (RI.hasVGPRs(NewDstRC))
4574 NewDstRC = RI.getEquivalentVGPRClass(NewDstRC);
4585 int OpIndices[3])
const {
4598 if (SGPRReg != AMDGPU::NoRegister)
4601 unsigned UsedSGPRs[3] = { AMDGPU::NoRegister };
4604 for (
unsigned i = 0; i < 3; ++i) {
4605 int Idx = OpIndices[i];
4616 bool IsRequiredSGPR = RI.isSGPRClass(OpRC);
4623 if (RI.isSGPRClass(RegRC))
4640 if (UsedSGPRs[0] != AMDGPU::NoRegister) {
4641 if (UsedSGPRs[0] == UsedSGPRs[1] || UsedSGPRs[0] == UsedSGPRs[2])
4642 SGPRReg = UsedSGPRs[0];
4645 if (SGPRReg == AMDGPU::NoRegister && UsedSGPRs[1] != AMDGPU::NoRegister) {
4646 if (UsedSGPRs[1] == UsedSGPRs[2])
4647 SGPRReg = UsedSGPRs[1];
4654 unsigned OperandName)
const {
4664 if (ST.isAmdHsaOS()) {
4667 RsrcDataFormat |= (1ULL << 56);
4672 RsrcDataFormat |= (2ULL << 59);
4675 return RsrcDataFormat;
4685 uint64_t EltSizeValue =
Log2_32(ST.getMaxPrivateElementSize()) - 1;
4715 if (!Addr || !Addr->
isFI())
4716 return AMDGPU::NoRegister;
4736 return AMDGPU::NoRegister;
4744 return AMDGPU::NoRegister;
4750 return AMDGPU::NoRegister;
4758 return AMDGPU::NoRegister;
4765 while (++I != E && I->isInsideBundle()) {
4766 assert(!I->isBundle() &&
"No nested bundle!");
4776 unsigned DescSize = Desc.
getSize();
4783 if (DescSize != 0 && DescSize != 4)
4813 case TargetOpcode::IMPLICIT_DEF:
4815 case TargetOpcode::DBG_VALUE:
4818 case TargetOpcode::BUNDLE:
4838 if (MMO->getAddrSpace() == ST.getAMDGPUAS().FLAT_ADDRESS)
4845 return Branch.
getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO;
4857 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
4860 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_IF), DstReg)
4861 .
add(Branch->getOperand(0))
4862 .
add(Branch->getOperand(1));
4864 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_END_CF))
4883 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
4888 BuildMI(*(MF), Branch->getDebugLoc(),
get(TargetOpcode::PHI), DstReg);
4892 if (*PI == LoopEnd) {
4893 HeaderPHIBuilder.
addReg(BackEdgeReg);
4899 HeaderPHIBuilder.
addReg(ZeroReg);
4901 HeaderPHIBuilder.
addMBB(*PI);
4905 get(AMDGPU::SI_IF_BREAK), BackEdgeReg)
4907 .
add(Branch->getOperand(0));
4909 BuildMI(*(MF), Branch->getDebugLoc(),
get(AMDGPU::SI_LOOP))
4915 LoopEnd->
insert(LoopEnd->
end(), SIIFBREAK);
4916 LoopEnd->
insert(LoopEnd->
end(), SILOOP);
4922 static const std::pair<int, const char *> TargetIndices[] = {
4946 std::pair<unsigned, unsigned>
4948 return std::make_pair(TF &
MO_MASK, TF & ~MO_MASK);
4953 static const std::pair<unsigned, const char *>
TargetFlags[] = {
4973 unsigned DestReg)
const {
4974 if (ST.hasAddNoCarry())
4975 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_U32_e64), DestReg);
4981 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_I32_e64), DestReg)
4987 case AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR:
4988 case AMDGPU::SI_KILL_I1_TERMINATOR:
4997 case AMDGPU::SI_KILL_F32_COND_IMM_PSEUDO:
4998 return get(AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR);
4999 case AMDGPU::SI_KILL_I1_PSEUDO:
5000 return get(AMDGPU::SI_KILL_I1_TERMINATOR);
5016 return RCID == AMDGPU::SReg_128RegClassID;
5067 if (MCOp == (uint16_t)-1)
unsigned getTargetFlags() const
unsigned getFrameOffsetReg() const
bool isLegalRegOperand(const MachineRegisterInfo &MRI, const MCOperandInfo &OpInfo, const MachineOperand &MO) const
Check if MO (a register operand) is a legal register for the given operand description.
unsigned buildExtractSubReg(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
unsigned getNumImplicitUses() const
Return the number of implicit uses this instruction has.
unsigned getVALUOp(const MachineInstr &MI) const
void push_back(const T &Elt)
const MachineInstrBuilder & add(const MachineOperand &MO) const
void legalizeOperands(MachineInstr &MI) const
Legalize all operands in this instruction.
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static unsigned getVGPRSpillSaveOpcode(unsigned Size)
EVT getValueType() const
Return the ValueType of the referenced return value.
static bool isSGPRSpill(const MachineInstr &MI)
Interface definition for SIRegisterInfo.
bool hasRegisterImplicitUseOperand(unsigned Reg) const
Returns true if the MachineInstr has an implicit-use operand of exactly the given register (not consi...
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
virtual bool expandPostRAPseudo(MachineInstr &MI) const
This function is called for all pseudo instructions that remain after register allocation.
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.
Diagnostic information for unsupported feature in backend.
AMDGPU specific subclass of TargetSubtarget.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
instr_iterator instr_end()
bool isVGPRCopy(const MachineInstr &MI) const
MachineBasicBlock * getMBB() const
bool hasScalarStores() const
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
LLVM_NODISCARD T pop_back_val()
Compute iterated dominance frontiers using a linear time algorithm.
static bool sopkIsZext(const MachineInstr &MI)
uint64_t getDefaultRsrcDataFormat() const
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
ChangeToRegister - Replace this operand with a new register operand of the specified value...
bool isOperandLegal(const MachineInstr &MI, unsigned OpIdx, const MachineOperand *MO=nullptr) const
Check if MO is a legal operand if it was the OpIdx Operand for MI.
unsigned getMaxFlatWorkGroupSize() const
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Returns true if this operand uses the constant bus.
static bool isStride64(unsigned Opc)
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
bool mayAccessFlatAddressSpace(const MachineInstr &MI) const
unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB, MachineInstr &MI, RegScavenger *RS, unsigned TmpReg, unsigned Offset, unsigned Size) const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool hasModifiersSet(const MachineInstr &MI, unsigned OpName) const
const TargetRegisterClass * getOpRegClass(const MachineInstr &MI, unsigned OpNo) const
Return the correct register class for OpNo.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
void setIsUndef(bool Val=true)
unsigned insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool hasInv2PiInlineImm() const
unsigned getSubReg() const
static bool isSOPK(const MachineInstr &MI)
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const
Legalize operands in MI by either commuting it or inserting a copy of src1.
unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const
uint64_t getSize() const
Return the size in bytes of the memory reference.
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const
Get required immediate operand.
MachineBasicBlock reference.
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi)
iterator_range< mmo_iterator > memoperands()
static void reportIllegalCopy(const SIInstrInfo *TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc)
static SDValue findChainOperand(SDNode *Load)
bool isInlineConstant(const APInt &Imm) const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
bool hasAnyModifiersSet(const MachineInstr &MI) const
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
static bool isSMRD(const MachineInstr &MI)
void clearVirtRegs()
clearVirtRegs - Remove all virtual registers (after physreg assignment).
unsigned getBitWidth() const
Return the number of bits in the APInt.
return AArch64::GPR64RegClass contains(Reg)
bool isMoveImmediate(QueryType Type=IgnoreBundle) const
Return true if this instruction is a move immediate (including conditional moves) instruction...
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
static MachineInstr * swapRegAndNonRegOperand(MachineInstr &MI, MachineOperand &RegOp, MachineOperand &NonRegOp)
static unsigned getAddrSpace(StringRef R)
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi)
static bool isFixedSize(const MachineInstr &MI)
MachineFunction & MF
Machine function.
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
The main low level interface to the alias analysis implementation.
static bool isDS(const MachineInstr &MI)
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
Address space for constant memory (VTX2)
A description of a memory reference used in the backend.
static use_iterator use_end()
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
static bool isFLAT(const MachineInstr &MI)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static ManagedStatic< DebugCounter > DC
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const HexagonInstrInfo * TII
uint64_t getScratchRsrcWords23() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
bool isEntryFunction() const
static bool isMIMG(const MachineInstr &MI)
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
static SIEncodingFamily subtargetEncodingFamily(const GCNSubtarget &ST)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void setImplicit(bool Val=true)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOperand buildExtractSubRegOrImm(MachineBasicBlock::iterator MI, MachineRegisterInfo &MRI, MachineOperand &SuperReg, const TargetRegisterClass *SuperRC, unsigned SubIdx, const TargetRegisterClass *SubRC) const
bool opCanUseInlineConstant(unsigned OpType) const
void setHasSpilledVGPRs(bool Spill=true)
void setTIDReg(unsigned Reg)
Name of external global symbol.
bool hasSDWAOutModsVOPC() const
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
void insertWaitStates(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, int Count) const
LLVM_READONLY int getCommuteOrig(uint16_t Opcode)
static bool changesVGPRIndexingMode(const MachineInstr &MI)
static unsigned getSGPRSpillSaveOpcode(unsigned Size)
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool opCanUseLiteralConstant(unsigned OpType) const
const MCInstrDesc & getMCOpcodeFromPseudo(unsigned Opcode) const
Return the descriptor of the target-specific machine instruction that corresponds to the specified ps...
const char * getSymbolName() const
static bool isVALU(const MachineInstr &MI)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
unsigned getAddressSpaceForPseudoSourceKind(PseudoSourceValue::PSVKind Kind) const override
unsigned getID() const
Return the register class ID number.
bool isSGPRClass(const TargetRegisterClass *RC) const
This file implements a class to represent arbitrary precision integral constant values and operations...
INLINEASM - Represents an inline asm block.
static bool isSubRegOf(const SIRegisterInfo &TRI, const MachineOperand &SuperVec, const MachineOperand &SubReg)
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
int getMCOpcode(uint16_t Opcode, unsigned Gen)
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
uint8_t OperandType
Information about the type of the operand.
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
int64_t getSExtValue() const
Get sign extended value.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool insert(const value_type &X)
Insert a new element into the SetVector.
unsigned getInstBundleSize(const MachineInstr &MI) const
static bool isMUBUF(const MachineInstr &MI)
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
static bool shouldReadExec(const MachineInstr &MI)
void convertNonUniformLoopRegion(MachineBasicBlock *LoopEntry, MachineBasicBlock *LoopEnd) const
const uint64_t RSRC_DATA_FORMAT
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx0, unsigned OpIdx1) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
ArrayRef< int16_t > getRegSplitParts(const TargetRegisterClass *RC, unsigned EltSize) const
Itinerary data supplied by a subtarget to be used by a target.
void untieRegOperand(unsigned OpIdx)
Break any tie involving OpIdx.
static unsigned findImplicitSGPRRead(const MachineInstr &MI)
bool isBasicBlockPrologue(const MachineInstr &MI) const override
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
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...
const Value * getValue() const
Return the base address of the memory access.
TargetInstrInfo::RegSubRegPair RegSubRegPair
static int64_t getFoldableImm(const MachineOperand *MO)
static bool nodesHaveSameOperandValue(SDNode *N0, SDNode *N1, unsigned OpName)
Returns true if both nodes have the same value for the given operand Op, or if both nodes do not have...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Address of a global value.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) const final
initializer< Ty > init(const Ty &Val)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
This file declares the machine register scavenger class.
const TargetRegisterInfo * getTargetRegisterInfo() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
unsigned const MachineRegisterInfo * MRI
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
bool isFoldableCopy(const MachineInstr &MI) const
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
const TargetRegisterClass * getPreferredSelectRegClass(unsigned Size) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AliasAnalysis *AA) const override
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
constexpr char WavefrontSize[]
Key for Kernel::CodeProps::Metadata::mWavefrontSize.
const SDValue & getOperand(unsigned Num) const
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
static unsigned getSGPRSpillRestoreOpcode(unsigned Size)
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool has16BitInsts() const
void insertVectorSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const
bool expandPostRAPseudo(MachineInstr &MI) const override
bool hasVGPRs(const TargetRegisterClass *RC) const
static unsigned getNumOperandsNoGlue(SDNode *Node)
static void removeModOperands(MachineInstr &MI)
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
void insertReturn(MachineBasicBlock &MBB) const
LLVM_READONLY int commuteOpcode(unsigned Opc) const
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
unsigned insertEQ(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, const MachineOperand &MO) const
MachineBasicBlock::instr_iterator begin() const
Return an iterator to the first bundled instruction.
bool hasVALU32BitEncoding(unsigned Opcode) const
Return true if this 64-bit VALU instruction has a 32-bit encoding.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
Generation getGeneration() const
self_iterator getIterator()
void materializeImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, int64_t Value) const
ScheduleHazardRecognizer * CreateTargetPostRAHazardRecognizer(const InstrItineraryData *II, const ScheduleDAG *DAG) const override
This is used by the post-RA scheduler (SchedulePostRAList.cpp).
unsigned insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS=nullptr) const override
const TargetRegisterClass * getSubRegClass(const TargetRegisterClass *RC, unsigned SubIdx) const
std::vector< MachineBasicBlock * >::iterator pred_iterator
const MachineInstrBuilder & addFrameIndex(int Idx) const
static unsigned getVGPRSpillRestoreOpcode(unsigned Size)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static bool isVOP2(const MachineInstr &MI)
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
unsigned isStackAccess(const MachineInstr &MI, int &FrameIndex) const
void setHasSpilledSGPRs(bool Spill=true)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
pred_iterator pred_begin()
LLVM_READONLY int getBasicFromSDWAOp(uint16_t Opcode)
This class contains a discriminated union of information about pointers in memory operands...
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, unsigned Src0OpName, MachineOperand &Src1, unsigned Src1OpName) const
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
Value * GetUnderlyingObject(Value *V, const DataLayout &DL, unsigned MaxLookup=6)
This method strips off any GEP address adjustments and pointer casts from the specified value...
unsigned getNumOperands() const
Return the number of values used by this operation.
#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.
Operands with register or inline constant.
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
void setIsKill(bool Val=true)
const uint64_t RSRC_TID_ENABLE
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const final
The memory access writes data.
static bool memOpsHaveSameBasePtr(const MachineInstr &MI1, unsigned BaseReg1, const MachineInstr &MI2, unsigned BaseReg2)
Representation for a specific memory location.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
unsigned getNumWaitStates(const MachineInstr &MI) const
Return the number of wait states that result from executing this instruction.
static bool isUndef(ArrayRef< int > Mask)
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
A SetVector that performs no allocations if smaller than a certain size.
unsigned findTiedOperandIdx(unsigned OpIdx) const
Given the index of a tied register operand, find the operand it is tied to.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
Iterator for intrusive lists based on ilist_node.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
LLVM_READONLY int getVOPe32(uint16_t Opcode)
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned getLDSSize() const
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static bool offsetsDoNotOverlap(int WidthA, int OffsetA, int WidthB, int OffsetB)
static bool isSALU(const MachineInstr &MI)
MachineOperand class - Representation of each machine instruction operand.
unsigned findUnusedRegister(const MachineRegisterInfo &MRI, const TargetRegisterClass *RC, const MachineFunction &MF) const
Returns a register that is not used at any point in the function.
void setRegAllocationHint(unsigned VReg, unsigned Type, unsigned PrefReg)
setRegAllocationHint - Specify a register allocation hint for the specified virtual register...
bool isLiteralConstantLike(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
A pair composed of a register and a sub-register index.
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
MachineInstrBuilder MachineInstrBuilder & DefMI
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg) const
Return a partially built integer add instruction without carry.
bool isLegalVSrcOperand(const MachineRegisterInfo &MRI, const MCOperandInfo &OpInfo, const MachineOperand &MO) const
Check if MO would be a valid operand for the given operand definition OpInfo.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
const uint64_t RSRC_INDEX_STRIDE_SHIFT
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
AMDGPUAS getAMDGPUAS() const
Represents one node in the SelectionDAG.
bool isVariadic(QueryType Type=IgnoreBundle) const
Return true if this instruction can have a variable number of operands.
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
unsigned pred_size() const
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const override
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
const TargetRegisterClass * getRegClassForReg(const MachineRegisterInfo &MRI, unsigned Reg) const
MCSymbol reference (for debug/eh info)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isVGPRSpillingEnabled(const Function &F) const
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
Class for arbitrary precision integers.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
bool isShader(CallingConv::ID cc)
Interface for the AMDGPU Implementation of the Intrinsic Info class.
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
iterator_range< mop_iterator > implicit_operands()
void addImplicitDefUseOperands(MachineFunction &MF)
Add all implicit def and use operands to this instruction.
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
static bool isSegmentSpecificFLAT(const MachineInstr &MI)
static bool isVOP3(const MachineInstr &MI)
amdgpu Simplify well known AMD library false Value Value * Arg
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Provides AMDGPU specific target descriptions.
static bool compareMachineOp(const MachineOperand &Op0, const MachineOperand &Op1)
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.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
OperandType
Operands are tagged with one of the values of this enum.
unsigned getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
void enterBasicBlock(MachineBasicBlock &MBB)
Start tracking liveness from the begin of basic block MBB.
static bool isMTBUF(const MachineInstr &MI)
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
use_iterator use_begin(unsigned RegNo) const
LLVM_NODISCARD bool empty() const
static bool isVOPC(const MachineInstr &MI)
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
This file provides utility analysis objects describing memory locations.
unsigned FLAT_ADDRESS
Address space for flat memory.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
static MachineOperand CreateImm(int64_t Val)
bool empty() const
Determine if the SetVector is empty or not.
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
void setSubReg(unsigned subReg)
bool hasUnwantedEffectsWhenEXECEmpty(const MachineInstr &MI) const
Whether we must prevent this instruction from executing with EXEC = 0.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
unsigned scavengeRegister(const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj)
Make a register of the specific register class available and do the appropriate bookkeeping.
bool isHighLatencyInstruction(const MachineInstr &MI) const
bool hasCalculatedTID() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isLowLatencyInstruction(const MachineInstr &MI) const
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Abstract Stack Frame Index.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
constexpr bool isUInt< 16 >(uint64_t x)
bool isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx=nullptr) const
Given the index of a register def operand, check if the register def is tied to a source operand...
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const
MachineInstr * removeFromParent()
Unlink 'this' from the containing basic block, and return it without deleting it. ...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Operands with register or 32-bit immediate.
SIInstrInfo(const GCNSubtarget &ST)
bool hasSDWAScalar() const
static void preserveCondRegFlags(MachineOperand &CondReg, const MachineOperand &OrigCond)
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void moveToVALU(MachineInstr &MI) const
Replace this instruction's opcode with the equivalent VALU opcode.
bool isNonUniformBranchInstr(MachineInstr &Instr) const
MIBundleBuilder & append(MachineInstr *MI)
Insert MI into MBB by appending it to the instructions in the bundle.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the memory access done by this instr...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
static bool isLegalMUBUFImmOffset(unsigned Imm)
void setRegUsed(unsigned Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
unsigned readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI, MachineRegisterInfo &MRI) const
Copy a value from a VGPR (SrcReg) to SGPR.
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static bool isSDWA(const MachineInstr &MI)
void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const
Legalize the OpIndex operand of this instruction by inserting a MOV.
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MBB, MachineInstr &MI, LiveVariables *LV) const override
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static bool isVGPRSpill(const MachineInstr &MI)
const TargetRegisterClass * getPhysRegClass(unsigned Reg) const
Return the 'base' register class for this register.
Operand with 32-bit immediate that uses the constant bus.
const MCOperandInfo * OpInfo
unsigned getHWRegIndex(unsigned Reg) const
void ChangeToFrameIndex(int Idx)
Replace this operand with a frame index.
unsigned getOpcode() const
Return the opcode number for this descriptor.
bool shouldScheduleLoadsNear(SDNode *Load0, SDNode *Load1, int64_t Offset0, int64_t Offset1, unsigned NumLoads) const override
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
unsigned getTIDReg() const
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
void legalizeGenericOperand(MachineBasicBlock &InsertMBB, MachineBasicBlock::iterator I, const TargetRegisterClass *DstRC, MachineOperand &Op, MachineRegisterInfo &MRI, const DebugLoc &DL) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
static bool isKillTerminator(unsigned Opcode)
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
LLVM_READONLY int getAddr64Inst(uint16_t Opcode)
uint64_t getZExtValue() const
This holds information about one operand of a machine instruction, indicating the register class for ...
const MachineOperand & getOperand(unsigned i) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const ConstantInt * getCImm() const
bool shouldClusterMemOps(MachineInstr &FirstLdSt, unsigned BaseReg1, MachineInstr &SecondLdSt, unsigned BaseReg2, unsigned NumLoads) const override
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
static bool isVOP1(const MachineInstr &MI)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry, MachineBasicBlock *IfEnd) const
bool isBufferSMRD(const MachineInstr &MI) const
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.
bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
unsigned createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static cl::opt< unsigned > BranchOffsetBits("amdgpu-s-branch-bits", cl::ReallyHidden, cl::init(16), cl::desc("Restrict range of branch instructions (DEBUG)"))
unsigned PRIVATE_ADDRESS
Address space for private memory.
bool empty() const
empty - Check if the array is empty.
LLVM_READONLY int getCommuteRev(uint16_t Opcode)
Helper class for constructing bundles of MachineInstrs.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
mmo_iterator memoperands_end() const