37 cl::desc(
"Restrict range of branch instructions (DEBUG)"));
68 if (Op0Idx == -1 && Op1Idx == -1)
72 if ((Op0Idx == -1 && Op1Idx != -1) ||
73 (Op1Idx == -1 && Op0Idx != -1))
92 case AMDGPU::V_MOV_B32_e32:
93 case AMDGPU::V_MOV_B32_e64:
94 case AMDGPU::V_MOV_B64_PSEUDO:
103 int64_t &Offset1)
const {
111 if (!
get(Opc0).mayLoad() || !
get(Opc1).mayLoad())
135 Offset0 = cast<ConstantSDNode>(Load0->
getOperand(2))->getZExtValue();
136 Offset1 = cast<ConstantSDNode>(Load1->
getOperand(2))->getZExtValue();
157 if (!Load0Offset || !Load1Offset)
165 Offset1 = Load1Offset->getZExtValue();
182 if (OffIdx0 == -1 || OffIdx1 == -1)
195 if (!isa<ConstantSDNode>(Off0) || !isa<ConstantSDNode>(Off1))
198 Offset0 = cast<ConstantSDNode>(Off0)->getZExtValue();
199 Offset1 = cast<ConstantSDNode>(Off1)->getZExtValue();
208 case AMDGPU::DS_READ2ST64_B32:
209 case AMDGPU::DS_READ2ST64_B64:
210 case AMDGPU::DS_WRITE2ST64_B32:
211 case AMDGPU::DS_WRITE2ST64_B64:
231 BaseReg = AddrReg->
getReg();
232 Offset = OffsetImm->
getImm();
244 uint8_t Offset0 = Offset0Imm->
getImm();
245 uint8_t Offset1 = Offset1Imm->
getImm();
247 if (Offset1 > Offset0 && Offset1 - Offset0 == 1) {
265 BaseReg = AddrReg->
getReg();
266 Offset = EltSize * Offset0;
275 if (SOffset && SOffset->
isReg())
285 BaseReg = AddrReg->
getReg();
286 Offset = OffsetImm->
getImm();
289 Offset += SOffset->
getImm();
302 BaseReg = SBaseReg->
getReg();
303 Offset = OffsetImm->
getImm();
309 BaseReg = AddrReg->
getReg();
319 unsigned NumLoads)
const {
331 }
else if (
isDS(FirstLdSt) &&
isDS(SecondLdSt)) {
336 if (!FirstDst || !SecondDst)
347 unsigned LoadClusterThreshold = 16;
353 return (NumLoads * (RI.getRegSizeInBits(*DstRC) / 8)) <= LoadClusterThreshold;
359 unsigned SrcReg,
bool KillSrc) {
362 "illegal SGPR to VGPR copy",
367 BuildMI(MBB, MI, DL, TII->get(AMDGPU::SI_ILLEGAL_COPY), DestReg)
374 unsigned SrcReg,
bool KillSrc)
const {
377 if (RC == &AMDGPU::VGPR_32RegClass) {
379 AMDGPU::SReg_32RegClass.
contains(SrcReg));
380 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DestReg)
385 if (RC == &AMDGPU::SReg_32_XM0RegClass ||
386 RC == &AMDGPU::SReg_32RegClass) {
387 if (SrcReg == AMDGPU::SCC) {
388 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CSELECT_B32), DestReg)
394 if (!AMDGPU::SReg_32RegClass.
contains(SrcReg)) {
399 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
404 if (RC == &AMDGPU::SReg_64RegClass) {
405 if (DestReg == AMDGPU::VCC) {
406 if (AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
407 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), AMDGPU::VCC)
412 BuildMI(MBB, MI, DL,
get(AMDGPU::V_CMP_NE_U32_e32))
420 if (!AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
425 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
430 if (DestReg == AMDGPU::SCC) {
432 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CMP_LG_U32))
438 unsigned EltSize = 4;
439 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
441 if (RI.getRegSizeInBits(*RC) > 32) {
442 Opcode = AMDGPU::S_MOV_B64;
445 Opcode = AMDGPU::S_MOV_B32;
459 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
462 SubIdx = SubIndices[Idx];
464 SubIdx = SubIndices[SubIndices.
size() - Idx - 1];
467 get(Opcode), RI.getSubReg(DestReg, SubIdx));
469 Builder.
addReg(RI.getSubReg(SrcReg, SubIdx));
474 bool UseKill = KillSrc && Idx == SubIndices.
size() - 1;
500 int64_t
Value)
const {
503 if (RegClass == &AMDGPU::SReg_32RegClass ||
504 RegClass == &AMDGPU::SGPR_32RegClass ||
505 RegClass == &AMDGPU::SReg_32_XM0RegClass ||
506 RegClass == &AMDGPU::SReg_32_XM0_XEXECRegClass) {
507 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
512 if (RegClass == &AMDGPU::SReg_64RegClass ||
513 RegClass == &AMDGPU::SGPR_64RegClass ||
514 RegClass == &AMDGPU::SReg_64_XEXECRegClass) {
515 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
520 if (RegClass == &AMDGPU::VGPR_32RegClass) {
521 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DestReg)
525 if (RegClass == &AMDGPU::VReg_64RegClass) {
526 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B64_PSEUDO), DestReg)
531 unsigned EltSize = 4;
532 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
534 if (RI.getRegSizeInBits(*RegClass) > 32) {
535 Opcode = AMDGPU::S_MOV_B64;
538 Opcode = AMDGPU::S_MOV_B32;
544 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
545 int64_t IdxValue = Idx == 0 ? Value : 0;
548 get(Opcode), RI.getSubReg(DestReg, Idx));
555 return &AMDGPU::VGPR_32RegClass;
563 unsigned FalseReg)
const {
568 if (Cond.
size() == 1) {
569 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
573 }
else if (Cond.
size() == 2) {
574 assert(Cond[0].isImm() &&
"Cond[0] is not an immediate");
575 switch (Cond[0].getImm()) {
576 case SIInstrInfo::SCC_TRUE: {
578 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
581 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
587 case SIInstrInfo::SCC_FALSE: {
589 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
592 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
598 case SIInstrInfo::VCCNZ: {
601 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
607 case SIInstrInfo::VCCZ: {
610 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
616 case SIInstrInfo::EXECNZ: {
619 BuildMI(MBB, I, DL,
get(AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
621 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
624 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
630 case SIInstrInfo::EXECZ: {
633 BuildMI(MBB, I, DL,
get(AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
635 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), SReg)
638 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
656 unsigned SrcReg,
int Value)
const {
659 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_EQ_I32_e64), Reg)
669 unsigned SrcReg,
int Value)
const {
672 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_NE_I32_e64), Reg)
681 if (RI.getRegSizeInBits(*DstRC) == 32) {
682 return RI.
isSGPRClass(DstRC) ? AMDGPU::S_MOV_B32 : AMDGPU::V_MOV_B32_e32;
683 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && RI.
isSGPRClass(DstRC)) {
684 return AMDGPU::S_MOV_B64;
685 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && !RI.
isSGPRClass(DstRC)) {
686 return AMDGPU::V_MOV_B64_PSEUDO;
694 return AMDGPU::SI_SPILL_S32_SAVE;
696 return AMDGPU::SI_SPILL_S64_SAVE;
698 return AMDGPU::SI_SPILL_S128_SAVE;
700 return AMDGPU::SI_SPILL_S256_SAVE;
702 return AMDGPU::SI_SPILL_S512_SAVE;
711 return AMDGPU::SI_SPILL_V32_SAVE;
713 return AMDGPU::SI_SPILL_V64_SAVE;
715 return AMDGPU::SI_SPILL_V96_SAVE;
717 return AMDGPU::SI_SPILL_V128_SAVE;
719 return AMDGPU::SI_SPILL_V256_SAVE;
721 return AMDGPU::SI_SPILL_V512_SAVE;
729 unsigned SrcReg,
bool isKill,
738 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
739 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
781 Ctx.
emitError(
"SIInstrInfo::storeRegToStackSlot - Do not know how to"
793 BuildMI(MBB, MI, DL,
get(Opcode))
805 return AMDGPU::SI_SPILL_S32_RESTORE;
807 return AMDGPU::SI_SPILL_S64_RESTORE;
809 return AMDGPU::SI_SPILL_S128_RESTORE;
811 return AMDGPU::SI_SPILL_S256_RESTORE;
813 return AMDGPU::SI_SPILL_S512_RESTORE;
822 return AMDGPU::SI_SPILL_V32_RESTORE;
824 return AMDGPU::SI_SPILL_V64_RESTORE;
826 return AMDGPU::SI_SPILL_V96_RESTORE;
828 return AMDGPU::SI_SPILL_V128_RESTORE;
830 return AMDGPU::SI_SPILL_V256_RESTORE;
832 return AMDGPU::SI_SPILL_V512_RESTORE;
847 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
848 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
882 Ctx.
emitError(
"SIInstrInfo::loadRegFromStackSlot - Do not know how to"
883 " restore register");
884 BuildMI(MBB, MI, DL,
get(AMDGPU::IMPLICIT_DEF), DestReg);
892 BuildMI(MBB, MI, DL,
get(Opcode), DestReg)
903 unsigned FrameOffset,
unsigned Size)
const {
916 DebugLoc DL = Insert->getDebugLoc();
920 if (TIDReg == AMDGPU::NoRegister)
924 WorkGroupSize > WavefrontSize) {
932 unsigned InputPtrReg =
934 for (
unsigned Reg : {TIDIGXReg, TIDIGYReg, TIDIGZReg}) {
943 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp0)
946 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp1)
951 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_MUL_I32), STmp1)
955 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MUL_U32_U24_e32), TIDReg)
959 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MAD_U32_U24), TIDReg)
964 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_ADD_I32_e32), TIDReg)
969 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_LO_U32_B32_e64),
974 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_HI_U32_B32_e64),
980 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_LSHLREV_B32_e32),
988 unsigned LDSOffset = MFI->
getLDSSize() + (FrameOffset * WorkGroupSize);
989 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADD_I32_e32), TmpReg)
1007 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOP))
1025 if (HasNoTerminator)
1027 get(Info->
returnsVoid() ? AMDGPU::S_ENDPGM : AMDGPU::SI_RETURN_TO_EPILOG));
1044 default:
return AMDGPUInstrInfo::expandPostRAPseudo(MI);
1045 case AMDGPU::S_MOV_B64_term: {
1048 MI.
setDesc(
get(AMDGPU::S_MOV_B64));
1051 case AMDGPU::S_XOR_B64_term: {
1054 MI.
setDesc(
get(AMDGPU::S_XOR_B64));
1057 case AMDGPU::S_ANDN2_B64_term: {
1060 MI.
setDesc(
get(AMDGPU::S_ANDN2_B64));
1063 case AMDGPU::V_MOV_B64_PSEUDO: {
1065 unsigned DstLo = RI.getSubReg(Dst, AMDGPU::sub0);
1066 unsigned DstHi = RI.getSubReg(Dst, AMDGPU::sub1);
1071 if (SrcOp.
isImm()) {
1073 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1074 .
addImm(Imm.getLoBits(32).getZExtValue())
1076 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1077 .
addImm(Imm.getHiBits(32).getZExtValue())
1081 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1084 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1091 case AMDGPU::V_MOVRELD_B32_V1:
1092 case AMDGPU::V_MOVRELD_B32_V2:
1093 case AMDGPU::V_MOVRELD_B32_V4:
1094 case AMDGPU::V_MOVRELD_B32_V8:
1095 case AMDGPU::V_MOVRELD_B32_V16: {
1096 const MCInstrDesc &MovRelDesc =
get(AMDGPU::V_MOVRELD_B32_e32);
1103 BuildMI(MBB, MI, DL, MovRelDesc)
1110 const int ImpDefIdx =
1112 const int ImpUseIdx = ImpDefIdx + 1;
1113 MovRel->tieOperands(ImpDefIdx, ImpUseIdx);
1118 case AMDGPU::SI_PC_ADD_REL_OFFSET: {
1121 unsigned RegLo = RI.getSubReg(Reg, AMDGPU::sub0);
1122 unsigned RegHi = RI.getSubReg(Reg, AMDGPU::sub1);
1127 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_GETPC_B64), Reg));
1131 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_ADD_U32), RegLo)
1154 unsigned Src0OpName,
1156 unsigned Src1OpName)
const {
1163 "All commutable instructions have both src0 and src1 modifiers");
1165 int Src0ModsVal = Src0Mods->
getImm();
1166 int Src1ModsVal = Src1Mods->
getImm();
1168 Src1Mods->
setImm(Src0ModsVal);
1169 Src0Mods->
setImm(Src1ModsVal);
1178 bool IsKill = RegOp.
isKill();
1179 bool IsDead = RegOp.
isDead();
1180 bool IsUndef = RegOp.
isUndef();
1181 bool IsDebug = RegOp.
isDebug();
1183 if (NonRegOp.
isImm())
1185 else if (NonRegOp.
isFI())
1190 NonRegOp.
ChangeToRegister(Reg,
false,
false, IsKill, IsDead, IsUndef, IsDebug);
1198 unsigned Src1Idx)
const {
1199 assert(!NewMI &&
"this should never be used");
1203 if (CommutedOpcode == -1)
1207 static_cast<int>(Src0Idx) &&
1209 static_cast<int>(Src1Idx) &&
1210 "inconsistency with findCommutedOpIndices");
1238 Src1, AMDGPU::OpName::src1_modifiers);
1240 CommutedMI->
setDesc(
get(CommutedOpcode));
1250 unsigned &SrcOpIdx1)
const {
1263 return fixCommutedOpIndices(SrcOpIdx0, SrcOpIdx1, Src0Idx, Src1Idx);
1267 int64_t BrOffset)
const {
1270 assert(BranchOp != AMDGPU::S_SETPC_B64);
1284 if (MI.
getOpcode() == AMDGPU::S_SETPC_B64) {
1298 assert(RS &&
"RegScavenger required for long branching");
1300 "new block should be inserted for expanding unconditional branch");
1317 if (BrOffset >= 0) {
1318 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADD_U32))
1320 .
addReg(PCReg, 0, AMDGPU::sub0)
1322 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADDC_U32))
1324 .
addReg(PCReg, 0, AMDGPU::sub1)
1328 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUB_U32))
1330 .
addReg(PCReg, 0, AMDGPU::sub0)
1332 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUBB_U32))
1334 .
addReg(PCReg, 0, AMDGPU::sub1)
1339 BuildMI(&MBB, DL,
get(AMDGPU::S_SETPC_B64))
1385 return 4 + 8 + 4 + 4;
1388 unsigned SIInstrInfo::getBranchOpcode(SIInstrInfo::BranchPredicate Cond) {
1390 case SIInstrInfo::SCC_TRUE:
1391 return AMDGPU::S_CBRANCH_SCC1;
1392 case SIInstrInfo::SCC_FALSE:
1393 return AMDGPU::S_CBRANCH_SCC0;
1394 case SIInstrInfo::VCCNZ:
1395 return AMDGPU::S_CBRANCH_VCCNZ;
1396 case SIInstrInfo::VCCZ:
1397 return AMDGPU::S_CBRANCH_VCCZ;
1398 case SIInstrInfo::EXECNZ:
1399 return AMDGPU::S_CBRANCH_EXECNZ;
1400 case SIInstrInfo::EXECZ:
1401 return AMDGPU::S_CBRANCH_EXECZ;
1407 SIInstrInfo::BranchPredicate SIInstrInfo::getBranchPredicate(
unsigned Opcode) {
1409 case AMDGPU::S_CBRANCH_SCC0:
1411 case AMDGPU::S_CBRANCH_SCC1:
1413 case AMDGPU::S_CBRANCH_VCCNZ:
1415 case AMDGPU::S_CBRANCH_VCCZ:
1417 case AMDGPU::S_CBRANCH_EXECNZ:
1419 case AMDGPU::S_CBRANCH_EXECZ:
1431 bool AllowModify)
const {
1432 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1434 TBB = I->getOperand(0).getMBB();
1440 if (I->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
1441 CondBB = I->getOperand(1).getMBB();
1444 BranchPredicate Pred = getBranchPredicate(I->getOpcode());
1445 if (Pred == INVALID_BR)
1448 CondBB = I->getOperand(0).getMBB();
1454 if (I == MBB.
end()) {
1460 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1462 FBB = I->getOperand(0).getMBB();
1472 bool AllowModify)
const {
1477 if (I->getOpcode() != AMDGPU::SI_MASK_BRANCH)
1500 if (TBB != MaskBrDest || Cond.
empty())
1503 auto Pred = Cond[0].getImm();
1504 return (Pred != EXECZ && Pred != EXECNZ);
1508 int *BytesRemoved)
const {
1512 unsigned RemovedSize = 0;
1513 while (I != MBB.
end()) {
1515 if (I->getOpcode() == AMDGPU::SI_MASK_BRANCH) {
1521 I->eraseFromParent();
1527 *BytesRemoved = RemovedSize;
1544 int *BytesAdded)
const {
1546 if (!FBB && Cond.
empty()) {
1547 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
1554 if(Cond.
size() == 1 && Cond[0].isReg()) {
1555 BuildMI(&MBB, DL,
get(AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO))
1561 assert(TBB && Cond[0].isImm());
1564 = getBranchOpcode(static_cast<BranchPredicate>(Cond[0].getImm()));
1569 BuildMI(&MBB, DL,
get(Opcode))
1583 BuildMI(&MBB, DL,
get(Opcode))
1585 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
1600 if (Cond.
size() != 2) {
1604 if (Cond[0].isImm()) {
1605 Cond[0].setImm(-Cond[0].getImm());
1614 unsigned TrueReg,
unsigned FalseReg,
1616 int &TrueCycles,
int &FalseCycles)
const {
1617 switch (Cond[0].getImm()) {
1625 CondCycles = TrueCycles = FalseCycles = NumInsts;
1641 if (NumInsts % 2 == 0)
1644 CondCycles = TrueCycles = FalseCycles = NumInsts;
1655 unsigned TrueReg,
unsigned FalseReg)
const {
1656 BranchPredicate Pred =
static_cast<BranchPredicate
>(Cond[0].getImm());
1657 if (Pred == VCCZ || Pred == SCC_FALSE) {
1658 Pred =
static_cast<BranchPredicate
>(-Pred);
1664 unsigned DstSize = RI.getRegSizeInBits(*DstRC);
1666 if (DstSize == 32) {
1667 unsigned SelOp = Pred == SCC_TRUE ?
1668 AMDGPU::S_CSELECT_B32 : AMDGPU::V_CNDMASK_B32_e32;
1672 BuildMI(MBB, I, DL,
get(SelOp), DstReg)
1680 if (DstSize == 64 && Pred == SCC_TRUE) {
1682 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), DstReg)
1690 static const int16_t Sub0_15[] = {
1691 AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3,
1692 AMDGPU::sub4, AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7,
1693 AMDGPU::sub8, AMDGPU::sub9, AMDGPU::sub10, AMDGPU::sub11,
1694 AMDGPU::sub12, AMDGPU::sub13, AMDGPU::sub14, AMDGPU::sub15,
1697 static const int16_t Sub0_15_64[] = {
1698 AMDGPU::sub0_sub1, AMDGPU::sub2_sub3,
1699 AMDGPU::sub4_sub5, AMDGPU::sub6_sub7,
1700 AMDGPU::sub8_sub9, AMDGPU::sub10_sub11,
1701 AMDGPU::sub12_sub13, AMDGPU::sub14_sub15,
1704 unsigned SelOp = AMDGPU::V_CNDMASK_B32_e32;
1706 const int16_t *SubIndices = Sub0_15;
1707 int NElts = DstSize / 32;
1710 if (Pred == SCC_TRUE) {
1711 SelOp = AMDGPU::S_CSELECT_B64;
1712 EltRC = &AMDGPU::SGPR_64RegClass;
1713 SubIndices = Sub0_15_64;
1720 MBB, I, DL,
get(AMDGPU::REG_SEQUENCE), DstReg);
1725 for (
int Idx = 0; Idx != NElts; ++Idx) {
1729 unsigned SubIdx = SubIndices[Idx];
1732 BuildMI(MBB, I, DL,
get(SelOp), DstElt)
1733 .
addReg(FalseReg, 0, SubIdx)
1734 .
addReg(TrueReg, 0, SubIdx);
1744 case AMDGPU::V_MOV_B32_e32:
1745 case AMDGPU::V_MOV_B32_e64:
1746 case AMDGPU::V_MOV_B64_PSEUDO: {
1754 case AMDGPU::S_MOV_B32:
1755 case AMDGPU::S_MOV_B64:
1766 AMDGPU::OpName::src0_modifiers);
1768 AMDGPU::OpName::src1_modifiers);
1770 AMDGPU::OpName::src2_modifiers);
1783 if (Opc == AMDGPU::COPY) {
1788 case AMDGPU::S_MOV_B64:
1793 case AMDGPU::V_MOV_B32_e32:
1794 case AMDGPU::S_MOV_B32:
1797 unsigned NewOpc = isVGPRCopy ? AMDGPU::V_MOV_B32_e32 : AMDGPU::S_MOV_B32;
1801 if (!ImmOp->
isImm()) {
1810 if (Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64 ||
1811 Opc == AMDGPU::V_MAD_F16 || Opc == AMDGPU::V_MAC_F16_e64) {
1828 bool IsF32 = Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64;
1854 unsigned Src1Reg = Src1->
getReg();
1855 unsigned Src1SubReg = Src1->
getSubReg();
1860 if (Opc == AMDGPU::V_MAC_F32_e64 ||
1861 Opc == AMDGPU::V_MAC_F16_e64)
1868 UseMI.
setDesc(
get(IsF32 ? AMDGPU::V_MADMK_F32 : AMDGPU::V_MADMK_F16));
1881 if (!Src0->
isImm() &&
1899 if (Opc == AMDGPU::V_MAC_F32_e64 ||
1900 Opc == AMDGPU::V_MAC_F16_e64)
1909 UseMI.
setDesc(
get(IsF32 ? AMDGPU::V_MADAK_F32 : AMDGPU::V_MADAK_F16));
1923 int WidthB,
int OffsetB) {
1924 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
1925 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
1926 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
1927 return LowOffset + LowWidth <= HighOffset;
1930 bool SIInstrInfo::checkInstOffsetsDoNotOverlap(
MachineInstr &MIa,
1932 unsigned BaseReg0, BaseReg1;
1933 int64_t Offset0, Offset1;
1944 if (BaseReg0 == BaseReg1 &&
1957 "MIa must load from or modify a memory location");
1959 "MIb must load from or modify a memory location");
1974 if (!AA->
alias(LocA, LocB))
1986 return checkInstOffsetsDoNotOverlap(MIa, MIb);
1993 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2000 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2007 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2023 case AMDGPU::V_MAC_F16_e64:
2026 case AMDGPU::V_MAC_F32_e64:
2028 case AMDGPU::V_MAC_F16_e32:
2031 case AMDGPU::V_MAC_F32_e32: {
2033 AMDGPU::OpName::src0);
2053 get(IsF16 ? AMDGPU::V_MAD_F16 : AMDGPU::V_MAD_F32))
2057 .addImm(Src1Mods ? Src1Mods->
getImm() : 0)
2061 .addImm(Clamp ? Clamp->
getImm() : 0)
2062 .addImm(Omod ? Omod->
getImm() : 0);
2070 case AMDGPU::S_SET_GPR_IDX_ON:
2071 case AMDGPU::S_SET_GPR_IDX_MODE:
2072 case AMDGPU::S_SET_GPR_IDX_OFF:
2089 MI.
getOpcode() == AMDGPU::S_SETREG_IMM32_B32 ||
2090 MI.
getOpcode() == AMDGPU::S_SETREG_B32 ||
2123 int64_t Imm = MO.
getImm();
2124 switch (OperandType) {
2129 int32_t Trunc =
static_cast<int32_t
>(Imm);
2130 return Trunc == Imm &&
2149 int16_t Trunc =
static_cast<int16_t
>(Imm);
2230 AMDGPU::OpName::src0_modifiers) != -1;
2234 unsigned OpName)
const {
2236 return Mods && Mods->
getImm();
2274 return (MO.
getReg() == AMDGPU::VCC || MO.
getReg() == AMDGPU::M0 ||
2276 (AMDGPU::SGPR_32RegClass.contains(MO.
getReg()) ||
2286 switch (MO.getReg()) {
2289 case AMDGPU::FLAT_SCR:
2297 return AMDGPU::NoRegister;
2303 case AMDGPU::V_READLANE_B32:
2304 case AMDGPU::V_READLANE_B32_si:
2305 case AMDGPU::V_READLANE_B32_vi:
2306 case AMDGPU::V_WRITELANE_B32:
2307 case AMDGPU::V_WRITELANE_B32_si:
2308 case AMDGPU::V_WRITELANE_B32_vi:
2315 if (SIInstrInfo::isGenericOpcode(MI.
getOpcode()) ||
2327 return TRI.isSubRegister(SuperVec.
getReg(), SubReg.
getReg());
2329 return SubReg.
getSubReg() != AMDGPU::NoSubRegister &&
2336 if (SIInstrInfo::isGenericOpcode(MI.
getOpcode()))
2350 ErrInfo =
"Instruction has wrong number of operands.";
2368 ErrInfo =
"inlineasm operand has incorrect register class.";
2379 ErrInfo =
"FPImm Machine Operands are not supported. ISel should bitcast "
2380 "all fp values to integers.";
2389 ErrInfo =
"Illegal immediate value for operand.";
2404 ErrInfo =
"Illegal immediate value for operand.";
2415 ErrInfo =
"Expected immediate, but got non-immediate";
2426 if (RegClass != -1) {
2428 if (Reg == AMDGPU::NoRegister ||
2434 ErrInfo =
"Operand has incorrect register class.";
2444 ErrInfo =
"SDWA is not supported on this target";
2450 const int OpIndicies[] = { DstIdx, Src0Idx, Src1Idx, Src2Idx };
2452 for (
int OpIdx: OpIndicies) {
2460 ErrInfo =
"Only VGPRs allowed as operands in SDWA instructions on VI";
2466 ErrInfo =
"Only reg allowed as operands in SDWA instructions on GFX9";
2475 if (OMod !=
nullptr &&
2477 ErrInfo =
"OMod not allowed in SDWA instructions on VI";
2483 if (
isVOPC(BasicOpcode)) {
2487 if (!Dst.
isReg() || Dst.
getReg() != AMDGPU::VCC) {
2488 ErrInfo =
"Only VCC allowed as dst in SDWA instructions on VI";
2494 if (Clamp && (!Clamp->
isImm() || Clamp->
getImm() != 0)) {
2495 ErrInfo =
"Clamp not allowed in VOPC SDWA instructions on VI";
2501 if (OMod && (!OMod->
isImm() || OMod->
getImm() != 0)) {
2502 ErrInfo =
"OMod not allowed in VOPC SDWA instructions on VI";
2514 const int OpIndices[] = { Src0Idx, Src1Idx, Src2Idx };
2516 unsigned ConstantBusCount = 0;
2522 if (SGPRUsed != AMDGPU::NoRegister)
2525 for (
int OpIdx : OpIndices) {
2531 if (MO.
getReg() != SGPRUsed)
2539 if (ConstantBusCount > 1) {
2540 ErrInfo =
"VOP* instruction uses the constant bus more than once";
2546 if (Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F32 ||
2547 Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F64) {
2554 ErrInfo =
"v_div_scale_{f32|f64} require src0 = src1 or src2";
2564 ErrInfo =
"invalid immediate for SOPK instruction";
2569 ErrInfo =
"invalid immediate for SOPK instruction";
2575 if (Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e32 ||
2576 Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e64 ||
2577 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
2578 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64) {
2579 const bool IsDst = Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
2580 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64;
2584 const unsigned NumImplicitOps = IsDst ? 2 : 1;
2590 ErrInfo =
"missing implicit register operands";
2596 if (!Dst->
isUse()) {
2597 ErrInfo =
"v_movreld_b32 vdst should be a use operand";
2603 UseOpIdx != StaticNumOps + 1) {
2604 ErrInfo =
"movrel implicit operands should be tied";
2611 = MI.
getOperand(StaticNumOps + NumImplicitOps - 1);
2613 !
isSubRegOf(RI, ImpUse, IsDst ? *Dst : Src0)) {
2614 ErrInfo =
"src0 should be subreg of implicit vector use";
2623 ErrInfo =
"VALU instruction does not implicitly read exec mask";
2633 if (Soff && Soff->
getReg() != AMDGPU::M0) {
2634 ErrInfo =
"scalar stores must use m0 as offset register";
2642 if (Offset->
getImm() != 0) {
2643 ErrInfo =
"subtarget does not support offsets in flat instructions";
2653 default:
return AMDGPU::INSTRUCTION_LIST_END;
2654 case AMDGPU::REG_SEQUENCE:
return AMDGPU::REG_SEQUENCE;
2655 case AMDGPU::COPY:
return AMDGPU::COPY;
2656 case AMDGPU::PHI:
return AMDGPU::PHI;
2657 case AMDGPU::INSERT_SUBREG:
return AMDGPU::INSERT_SUBREG;
2658 case AMDGPU::S_MOV_B32:
2660 AMDGPU::COPY : AMDGPU::V_MOV_B32_e32;
2661 case AMDGPU::S_ADD_I32:
2662 case AMDGPU::S_ADD_U32:
return AMDGPU::V_ADD_I32_e32;
2663 case AMDGPU::S_ADDC_U32:
return AMDGPU::V_ADDC_U32_e32;
2664 case AMDGPU::S_SUB_I32:
2665 case AMDGPU::S_SUB_U32:
return AMDGPU::V_SUB_I32_e32;
2666 case AMDGPU::S_SUBB_U32:
return AMDGPU::V_SUBB_U32_e32;
2667 case AMDGPU::S_MUL_I32:
return AMDGPU::V_MUL_LO_I32;
2668 case AMDGPU::S_AND_B32:
return AMDGPU::V_AND_B32_e64;
2669 case AMDGPU::S_OR_B32:
return AMDGPU::V_OR_B32_e64;
2670 case AMDGPU::S_XOR_B32:
return AMDGPU::V_XOR_B32_e64;
2671 case AMDGPU::S_MIN_I32:
return AMDGPU::V_MIN_I32_e64;
2672 case AMDGPU::S_MIN_U32:
return AMDGPU::V_MIN_U32_e64;
2673 case AMDGPU::S_MAX_I32:
return AMDGPU::V_MAX_I32_e64;
2674 case AMDGPU::S_MAX_U32:
return AMDGPU::V_MAX_U32_e64;
2675 case AMDGPU::S_ASHR_I32:
return AMDGPU::V_ASHR_I32_e32;
2676 case AMDGPU::S_ASHR_I64:
return AMDGPU::V_ASHR_I64;
2677 case AMDGPU::S_LSHL_B32:
return AMDGPU::V_LSHL_B32_e32;
2678 case AMDGPU::S_LSHL_B64:
return AMDGPU::V_LSHL_B64;
2679 case AMDGPU::S_LSHR_B32:
return AMDGPU::V_LSHR_B32_e32;
2680 case AMDGPU::S_LSHR_B64:
return AMDGPU::V_LSHR_B64;
2681 case AMDGPU::S_SEXT_I32_I8:
return AMDGPU::V_BFE_I32;
2682 case AMDGPU::S_SEXT_I32_I16:
return AMDGPU::V_BFE_I32;
2683 case AMDGPU::S_BFE_U32:
return AMDGPU::V_BFE_U32;
2684 case AMDGPU::S_BFE_I32:
return AMDGPU::V_BFE_I32;
2685 case AMDGPU::S_BFM_B32:
return AMDGPU::V_BFM_B32_e64;
2686 case AMDGPU::S_BREV_B32:
return AMDGPU::V_BFREV_B32_e32;
2687 case AMDGPU::S_NOT_B32:
return AMDGPU::V_NOT_B32_e32;
2688 case AMDGPU::S_NOT_B64:
return AMDGPU::V_NOT_B32_e32;
2689 case AMDGPU::S_CMP_EQ_I32:
return AMDGPU::V_CMP_EQ_I32_e32;
2690 case AMDGPU::S_CMP_LG_I32:
return AMDGPU::V_CMP_NE_I32_e32;
2691 case AMDGPU::S_CMP_GT_I32:
return AMDGPU::V_CMP_GT_I32_e32;
2692 case AMDGPU::S_CMP_GE_I32:
return AMDGPU::V_CMP_GE_I32_e32;
2693 case AMDGPU::S_CMP_LT_I32:
return AMDGPU::V_CMP_LT_I32_e32;
2694 case AMDGPU::S_CMP_LE_I32:
return AMDGPU::V_CMP_LE_I32_e32;
2695 case AMDGPU::S_CMP_EQ_U32:
return AMDGPU::V_CMP_EQ_U32_e32;
2696 case AMDGPU::S_CMP_LG_U32:
return AMDGPU::V_CMP_NE_U32_e32;
2697 case AMDGPU::S_CMP_GT_U32:
return AMDGPU::V_CMP_GT_U32_e32;
2698 case AMDGPU::S_CMP_GE_U32:
return AMDGPU::V_CMP_GE_U32_e32;
2699 case AMDGPU::S_CMP_LT_U32:
return AMDGPU::V_CMP_LT_U32_e32;
2700 case AMDGPU::S_CMP_LE_U32:
return AMDGPU::V_CMP_LE_U32_e32;
2701 case AMDGPU::S_CMP_EQ_U64:
return AMDGPU::V_CMP_EQ_U64_e32;
2702 case AMDGPU::S_CMP_LG_U64:
return AMDGPU::V_CMP_NE_U64_e32;
2703 case AMDGPU::S_BCNT1_I32_B32:
return AMDGPU::V_BCNT_U32_B32_e64;
2704 case AMDGPU::S_FF1_I32_B32:
return AMDGPU::V_FFBL_B32_e32;
2705 case AMDGPU::S_FLBIT_I32_B32:
return AMDGPU::V_FFBH_U32_e32;
2706 case AMDGPU::S_FLBIT_I32:
return AMDGPU::V_FFBH_I32_e64;
2707 case AMDGPU::S_CBRANCH_SCC0:
return AMDGPU::S_CBRANCH_VCCZ;
2708 case AMDGPU::S_CBRANCH_SCC1:
return AMDGPU::S_CBRANCH_VCCNZ;
2713 return getVALUOp(MI) != AMDGPU::INSTRUCTION_LIST_END;
2717 unsigned OpNo)
const {
2730 return RI.getRegClass(RCID);
2736 case AMDGPU::REG_SEQUENCE:
2738 case AMDGPU::INSERT_SUBREG:
2750 unsigned RCID =
get(MI.
getOpcode()).OpInfo[OpIdx].RegClass;
2752 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
2754 Opcode = AMDGPU::COPY;
2756 Opcode = AMDGPU::S_MOV_B32;
2759 if (RI.getCommonSubClass(&AMDGPU::VReg_64RegClass, VRC))
2760 VRC = &AMDGPU::VReg_64RegClass;
2762 VRC = &AMDGPU::VGPR_32RegClass;
2781 if (SuperReg.
getSubReg() == AMDGPU::NoSubRegister) {
2782 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
2793 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), NewSuperReg)
2796 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
2797 .
addReg(NewSuperReg, 0, SubIdx);
2810 if (SubIdx == AMDGPU::sub0)
2812 if (SubIdx == AMDGPU::sub1)
2818 unsigned SubReg = buildExtractSubReg(MII, MRI, Op, SuperRC,
2824 void SIInstrInfo::swapOperands(
MachineInstr &Inst)
const {
2856 return RI.getCommonSubClass(RC, RI.getRegClass(OpInfo.
RegClass)) == RC;
2882 RegSubRegPair SGPRUsed;
2891 if ((Op.
getReg() != SGPRUsed.Reg || Op.
getSubReg() != SGPRUsed.SubReg) &&
2932 if (HasImplicitSGPR) {
2948 if (Opc == AMDGPU::V_READLANE_B32 && Src1.
isReg() &&
2982 if (CommutedOpc == -1) {
2989 unsigned Src0Reg = Src0.
getReg();
2991 bool Src0Kill = Src0.
isKill();
2995 else if (Src1.
isReg()) {
3020 unsigned SGPRReg = findUsedSGPR(MI, VOP3Idx);
3022 for (
unsigned i = 0; i < 3; ++i) {
3023 int Idx = VOP3Idx[i];
3035 if (SGPRReg == AMDGPU::NoRegister || SGPRReg == MO.
getReg()) {
3052 unsigned SubRegs = RI.getRegSizeInBits(*VRC) / 32;
3055 for (
unsigned i = 0; i < SubRegs; ++i) {
3058 get(AMDGPU::V_READFIRSTLANE_B32), SGPR)
3065 get(AMDGPU::REG_SEQUENCE), DstReg);
3066 for (
unsigned i = 0; i < SubRegs; ++i) {
3094 unsigned OpReg = Op.
getReg();
3106 BuildMI(InsertMBB, I, DL,
get(AMDGPU::COPY), DstReg).
add(Op);
3192 if (MI.
getOpcode() == AMDGPU::REG_SEQUENCE) {
3219 if (MI.
getOpcode() == AMDGPU::INSERT_SUBREG) {
3224 if (DstRC != Src0RC) {
3260 if (SRsrcIdx != -1) {
3263 unsigned SRsrcRC =
get(MI.
getOpcode()).OpInfo[SRsrcIdx].RegClass;
3265 RI.getRegClass(SRsrcRC))) {
3274 unsigned SRsrcPtr = buildExtractSubReg(MI, MRI, *SRsrc,
3275 &AMDGPU::VReg_128RegClass, AMDGPU::sub0_sub1, &AMDGPU::VReg_64RegClass);
3290 .
addImm(RsrcDataFormat & 0xFFFFFFFF);
3294 .
addImm(RsrcDataFormat >> 32);
3299 .
addImm(AMDGPU::sub0_sub1)
3315 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADD_I32_e32), NewVAddrLo)
3316 .
addReg(SRsrcPtr, 0, AMDGPU::sub0)
3320 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADDC_U32_e32), NewVAddrHi)
3321 .
addReg(SRsrcPtr, 0, AMDGPU::sub1)
3335 "FIXME: Need to emit flat atomics here");
3352 .
addReg(AMDGPU::NoRegister)
3362 MIB.
addImm(GLC->getImm());
3369 MIB.
addImm(TFE->getImm());
3379 .
addReg(AMDGPU::NoRegister)
3394 .
addReg(SRsrcPtr, 0, AMDGPU::sub0)
3396 .
addReg(SRsrcPtr, 0, AMDGPU::sub1)
3412 Worklist.
insert(&TopInst);
3414 while (!Worklist.
empty()) {
3426 case AMDGPU::S_AND_B64:
3427 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_AND_B32_e64);
3431 case AMDGPU::S_OR_B64:
3432 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_OR_B32_e64);
3436 case AMDGPU::S_XOR_B64:
3437 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::V_XOR_B32_e64);
3441 case AMDGPU::S_NOT_B64:
3442 splitScalar64BitUnaryOp(Worklist, Inst, AMDGPU::V_NOT_B32_e32);
3446 case AMDGPU::S_BCNT1_I32_B64:
3447 splitScalar64BitBCNT(Worklist, Inst);
3451 case AMDGPU::S_BFE_I64: {
3452 splitScalar64BitBFE(Worklist, Inst);
3457 case AMDGPU::S_LSHL_B32:
3459 NewOpcode = AMDGPU::V_LSHLREV_B32_e64;
3463 case AMDGPU::S_ASHR_I32:
3465 NewOpcode = AMDGPU::V_ASHRREV_I32_e64;
3469 case AMDGPU::S_LSHR_B32:
3471 NewOpcode = AMDGPU::V_LSHRREV_B32_e64;
3475 case AMDGPU::S_LSHL_B64:
3477 NewOpcode = AMDGPU::V_LSHLREV_B64;
3481 case AMDGPU::S_ASHR_I64:
3483 NewOpcode = AMDGPU::V_ASHRREV_I64;
3487 case AMDGPU::S_LSHR_B64:
3489 NewOpcode = AMDGPU::V_LSHRREV_B64;
3494 case AMDGPU::S_ABS_I32:
3495 lowerScalarAbs(Worklist, Inst);
3499 case AMDGPU::S_CBRANCH_SCC0:
3500 case AMDGPU::S_CBRANCH_SCC1:
3508 case AMDGPU::S_BFE_U64:
3509 case AMDGPU::S_BFM_B64:
3512 case AMDGPU::S_PACK_LL_B32_B16:
3513 case AMDGPU::S_PACK_LH_B32_B16:
3514 case AMDGPU::S_PACK_HH_B32_B16: {
3515 movePackToVALU(Worklist, MRI, Inst);
3521 if (NewOpcode == AMDGPU::INSTRUCTION_LIST_END) {
3539 addSCCDefUsersToVALUWorklist(Inst, Worklist);
3543 if (Opcode == AMDGPU::S_SEXT_I32_I8 || Opcode == AMDGPU::S_SEXT_I32_I16) {
3546 unsigned Size = (Opcode == AMDGPU::S_SEXT_I32_I8) ? 8 : 16;
3550 }
else if (Opcode == AMDGPU::S_BCNT1_I32_B32) {
3558 if (Opcode == AMDGPU::S_BFE_I32 || Opcode == AMDGPU::S_BFE_U32) {
3563 "Scalar BFE is only implemented for constant width and offset");
3567 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
3574 unsigned NewDstReg = AMDGPU::NoRegister;
3594 addUsersToMoveToVALUWorklist(DstReg, MRI, Worklist);
3609 addUsersToMoveToVALUWorklist(NewDstReg, MRI, Worklist);
3613 void SIInstrInfo::lowerScalarAbs(SetVectorType &Worklist,
3625 BuildMI(MBB, MII, DL,
get(AMDGPU::V_SUB_I32_e32), TmpReg)
3629 BuildMI(MBB, MII, DL,
get(AMDGPU::V_MAX_I32_e64), ResultReg)
3634 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
3637 void SIInstrInfo::splitScalar64BitUnaryOp(
3639 unsigned Opcode)
const {
3652 &AMDGPU::SGPR_32RegClass;
3656 MachineOperand SrcReg0Sub0 = buildExtractSubRegOrImm(MII, MRI, Src0, Src0RC,
3657 AMDGPU::sub0, Src0SubRC);
3664 BuildMI(MBB, MII, DL, InstDesc, DestSub0).
add(SrcReg0Sub0);
3666 MachineOperand SrcReg0Sub1 = buildExtractSubRegOrImm(MII, MRI, Src0, Src0RC,
3667 AMDGPU::sub1, Src0SubRC);
3670 BuildMI(MBB, MII, DL, InstDesc, DestSub1).
add(SrcReg0Sub1);
3673 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
3685 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
3688 void SIInstrInfo::splitScalar64BitBinaryOp(
3690 unsigned Opcode)
const {
3704 &AMDGPU::SGPR_32RegClass;
3709 &AMDGPU::SGPR_32RegClass;
3713 MachineOperand SrcReg0Sub0 = buildExtractSubRegOrImm(MII, MRI, Src0, Src0RC,
3714 AMDGPU::sub0, Src0SubRC);
3715 MachineOperand SrcReg1Sub0 = buildExtractSubRegOrImm(MII, MRI, Src1, Src1RC,
3716 AMDGPU::sub0, Src1SubRC);
3727 MachineOperand SrcReg0Sub1 = buildExtractSubRegOrImm(MII, MRI, Src0, Src0RC,
3728 AMDGPU::sub1, Src0SubRC);
3729 MachineOperand SrcReg1Sub1 = buildExtractSubRegOrImm(MII, MRI, Src1, Src1RC,
3730 AMDGPU::sub1, Src1SubRC);
3738 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
3752 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
3755 void SIInstrInfo::splitScalar64BitBCNT(
3766 const MCInstrDesc &InstDesc =
get(AMDGPU::V_BCNT_U32_B32_e64);
3769 &AMDGPU::SGPR_32RegClass;
3776 MachineOperand SrcRegSub0 = buildExtractSubRegOrImm(MII, MRI, Src, SrcRC,
3777 AMDGPU::sub0, SrcSubRC);
3778 MachineOperand SrcRegSub1 = buildExtractSubRegOrImm(MII, MRI, Src, SrcRC,
3779 AMDGPU::sub1, SrcSubRC);
3789 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
3792 void SIInstrInfo::splitScalar64BitBFE(SetVectorType &Worklist,
3802 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
3808 Offset == 0 &&
"Not implemented");
3810 if (BitWidth < 32) {
3815 BuildMI(MBB, MII, DL,
get(AMDGPU::V_BFE_I32), MidRegLo)
3820 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e32), MidRegHi)
3824 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
3831 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
3839 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e64), TmpReg)
3843 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
3845 .addImm(AMDGPU::sub0)
3850 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
3853 void SIInstrInfo::addUsersToMoveToVALUWorklist(
3856 SetVectorType &Worklist)
const {
3861 Worklist.insert(&UseMI);
3865 }
while (
I !=
E &&
I->getParent() == &
UseMI);
3872 void SIInstrInfo::movePackToVALU(SetVectorType &Worklist,
3882 case AMDGPU::S_PACK_LL_B32_B16: {
3888 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
3891 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_B32_e64), TmpReg)
3895 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHL_OR_B32), ResultReg)
3901 case AMDGPU::S_PACK_LH_B32_B16: {
3903 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
3905 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_BFI_B32), ResultReg)
3911 case AMDGPU::S_PACK_HH_B32_B16: {
3914 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHRREV_B32_e64), TmpReg)
3917 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
3919 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_OR_B32), ResultReg)
3931 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
3934 void SIInstrInfo::addSCCDefUsersToVALUWorklist(
3935 MachineInstr &SCCDefInst, SetVectorType &Worklist)
const {
3942 if (MI.findRegisterDefOperandIdx(AMDGPU::SCC) != -1)
3945 if (MI.findRegisterUseOperandIdx(AMDGPU::SCC) != -1)
3946 Worklist.insert(&MI);
3960 case AMDGPU::REG_SEQUENCE:
3961 case AMDGPU::INSERT_SUBREG:
3975 unsigned SIInstrInfo::findUsedSGPR(
const MachineInstr &MI,
3976 int OpIndices[3])
const {
3989 if (SGPRReg != AMDGPU::NoRegister)
3992 unsigned UsedSGPRs[3] = { AMDGPU::NoRegister };
3995 for (
unsigned i = 0; i < 3; ++i) {
3996 int Idx = OpIndices[i];
4031 if (UsedSGPRs[0] != AMDGPU::NoRegister) {
4032 if (UsedSGPRs[0] == UsedSGPRs[1] || UsedSGPRs[0] == UsedSGPRs[2])
4033 SGPRReg = UsedSGPRs[0];
4036 if (SGPRReg == AMDGPU::NoRegister && UsedSGPRs[1] != AMDGPU::NoRegister) {
4037 if (UsedSGPRs[1] == UsedSGPRs[2])
4038 SGPRReg = UsedSGPRs[1];
4045 unsigned OperandName)
const {
4058 RsrcDataFormat |= (1ULL << 56);
4063 RsrcDataFormat |= (2ULL << 59);
4066 return RsrcDataFormat;
4106 if (!Addr || !Addr->
isFI())
4107 return AMDGPU::NoRegister;
4128 return AMDGPU::NoRegister;
4136 return AMDGPU::NoRegister;
4142 return AMDGPU::NoRegister;
4150 return AMDGPU::NoRegister;
4156 unsigned DescSize = Desc.
getSize();
4163 if (DescSize != 0 && DescSize != 4)
4193 case TargetOpcode::IMPLICIT_DEF:
4195 case TargetOpcode::DBG_VALUE:
4196 case TargetOpcode::BUNDLE:
4224 return Branch.
getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO;
4236 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
4239 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_IF), DstReg)
4240 .
add(Branch->getOperand(0))
4241 .
add(Branch->getOperand(1));
4243 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_END_CF))
4262 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
4267 BuildMI(*(MF), Branch->getDebugLoc(),
get(TargetOpcode::PHI), DstReg);
4271 if (*PI == LoopEnd) {
4272 HeaderPHIBuilder.
addReg(BackEdgeReg);
4278 HeaderPHIBuilder.
addReg(ZeroReg);
4280 HeaderPHIBuilder.
addMBB(*PI);
4284 get(AMDGPU::SI_IF_BREAK), BackEdgeReg)
4286 .
add(Branch->getOperand(0));
4288 BuildMI(*(MF), Branch->getDebugLoc(),
get(AMDGPU::SI_LOOP))
4294 LoopEnd->
insert(LoopEnd->
end(), SIIFBREAK);
4295 LoopEnd->
insert(LoopEnd->
end(), SILOOP);
4301 static const std::pair<int, const char *> TargetIndices[] = {
4325 std::pair<unsigned, unsigned>
4327 return std::make_pair(TF &
MO_MASK, TF & ~MO_MASK);
4332 static const std::pair<unsigned, const char *>
TargetFlags[] = {
4352 unsigned DestReg)
const {
4357 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_I32_e64), DestReg)
void legalizeOpWithMove(MachineInstr &MI, unsigned OpIdx) const
Legalize the OpIndex operand of this instruction by inserting a MOV.
MachineBasicBlock::instr_iterator begin() const
Return an iterator to the first bundled instruction.
void push_back(const T &Elt)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static unsigned getVGPRSpillSaveOpcode(unsigned Size)
static bool isSGPRSpill(const MachineInstr &MI)
unsigned getNumImplicitUses() const
Return the number of implicit uses this instruction has.
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
ArrayRef< int16_t > getRegSplitParts(const TargetRegisterClass *RC, unsigned EltSize) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Diagnostic information for unsupported feature in backend.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool opCanUseInlineConstant(unsigned OpType) const
LLVM_NODISCARD T pop_back_val()
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
bool isVGPRSpillingEnabled(const Function &F) const
static bool sopkIsZext(const MachineInstr &MI)
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...
unsigned calculateLDSSpillAddress(MachineBasicBlock &MBB, MachineInstr &MI, RegScavenger *RS, unsigned TmpReg, unsigned Offset, unsigned Size) const
MachineBasicBlock * getMBB() const
bool isTargetIndex() const
isTargetIndex - Tests if this is a MO_TargetIndex operand.
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
unsigned createVirtualRegister(const TargetRegisterClass *RegClass)
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
static bool isStride64(unsigned Opc)
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry, MachineBasicBlock *IfEnd) const
void legalizeOperandsVOP3(MachineRegisterInfo &MRI, MachineInstr &MI) const
Fix operands in MI to satisfy constant bus requirements.
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.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
void setIsUndef(bool Val=true)
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
bool hasRegisterImplicitUseOperand(unsigned Reg) const
Returns true if the MachineInstr has an implicit-use operand of exactly the given register (not consi...
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
const MachineInstrBuilder & add(const MachineOperand &MO) const
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void moveToVALU(MachineInstr &MI) const
Replace this instruction's opcode with the equivalent VALU opcode.
static bool isSOPK(const MachineInstr &MI)
const TargetRegisterClass * getRegClassForReg(const MachineRegisterInfo &MRI, unsigned Reg) const
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
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 getID() const
Return the register class ID number.
bool isNonUniformBranchInstr(MachineInstr &Instr) const
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
unsigned getNumOperands() const
Return the number of values used by this operation.
MachineBasicBlock reference.
const char * getSymbolName() const
const TargetRegisterClass * getPreferredSelectRegClass(unsigned Size) const
constexpr bool isInt< 16 >(int64_t x)
const SDValue & getOperand(unsigned Num) const
bool isSGPRClass(const TargetRegisterClass *RC) const
unsigned getMovOpcode(const TargetRegisterClass *DstRC) const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
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 hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
bool hasSDWAScalar() const
static bool isSMRD(const MachineInstr &MI)
void clearVirtRegs()
clearVirtRegs - Remove all virtual registers (after physreg assignment).
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
return AArch64::GPR64RegClass contains(Reg)
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static MachineInstr * swapRegAndNonRegOperand(MachineInstr &MI, MachineOperand &RegOp, MachineOperand &NonRegOp)
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
const TargetRegisterClass * getSubRegClass(const TargetRegisterClass *RC, unsigned SubIdx) const
unsigned getHWRegIndex(unsigned Reg) const
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi)
bool mayAccessFlatAddressSpace(const MachineInstr &MI) const
static bool isFixedSize(const MachineInstr &MI)
MachineFunction & MF
Machine function.
unsigned getMaxFlatWorkGroupSize() const
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)
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
A description of a memory reference used in the backend.
static use_iterator use_end()
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
static bool isFLAT(const MachineInstr &MI)
void insertWaitStates(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, int Count) const
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const HexagonInstrInfo * TII
const TargetRegisterInfo * getTargetRegisterInfo() const
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
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)
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static bool isMIMG(const MachineInstr &MI)
unsigned isSGPRStackAccess(const MachineInstr &MI, int &FrameIndex) const
unsigned getLDSSize() const
bool hasSDWAOutModsVOPC() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void setImplicit(bool Val=true)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
bool hasAnyModifiersSet(const MachineInstr &MI) const
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
void setHasSpilledVGPRs(bool Spill=true)
void setTIDReg(unsigned Reg)
Name of external global symbol.
const MCInstrDesc & getMCOpcodeFromPseudo(unsigned Opcode) const
Return the descriptor of the target-specific machine instruction that corresponds to the specified ps...
Reg
All possible values of the reg field in the ModR/M byte.
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...
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.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
INLINEASM - Represents an inline asm block.
bool opCanUseLiteralConstant(unsigned OpType) const
static bool isSubRegOf(const SIRegisterInfo &TRI, const MachineOperand &SuperVec, const MachineOperand &SubReg)
LLVM_NODISCARD bool empty() const
unsigned getNumOperands() const
Access to explicit operands of the instruction.
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.
void RemoveOperand(unsigned i)
Erase an operand from an instruction, leaving it with one fewer operand than it started with...
const MachineBasicBlock & front() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
LLVM_READONLY int commuteOpcode(unsigned Opc) const
static bool isMUBUF(const MachineInstr &MI)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool canReadVGPR(const MachineInstr &MI, unsigned OpNo) const
static bool shouldReadExec(const MachineInstr &MI)
uint64_t getScratchRsrcWords23() const
const uint64_t RSRC_DATA_FORMAT
bool empty() const
Determine if the SetVector is empty or not.
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 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 isStackAccess(const MachineInstr &MI, int &FrameIndex) 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
Generation getGeneration() const
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
size_t size() const
size - Get the array size.
const TargetRegisterClass * constrainRegClass(unsigned Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
unsigned getKillRegState(bool B)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
const MachineBasicBlock * getParent() const
mmo_iterator memoperands_end() const
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.
Address of a global value.
bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) const final
initializer< Ty > init(const Ty &Val)
unsigned getTargetFlags() const
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
const MachineInstrBuilder & setMemRefs(MachineInstr::mmo_iterator b, MachineInstr::mmo_iterator e) const
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 TargetRegisterClass * getEquivalentVGPRClass(const TargetRegisterClass *SRC) const
unsigned const MachineRegisterInfo * MRI
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
bool hasVGPRs(const TargetRegisterClass *RC) const
This is an important class for using LLVM in a threaded context.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AliasAnalysis *AA) const override
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE instructions.
int64_t getSExtValue() const
Get sign extended value.
const MachineOperand & getOperand(unsigned i) const
static unsigned getSGPRSpillRestoreOpcode(unsigned Size)
const TargetRegisterClass * getEquivalentSGPRClass(const TargetRegisterClass *VRC) const
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
unsigned getSubRegFromChannel(unsigned Channel) const
void convertNonUniformLoopRegion(MachineBasicBlock *LoopEntry, MachineBasicBlock *LoopEnd) const
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
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...
bool expandPostRAPseudo(MachineInstr &MI) const override
static unsigned getNumOperandsNoGlue(SDNode *Node)
static void removeModOperands(MachineInstr &MI)
bool swapSourceModifiers(MachineInstr &MI, MachineOperand &Src0, unsigned Src0OpName, MachineOperand &Src1, unsigned Src1OpName) const
unsigned getNumExplicitOperands() const
Returns the number of non-implicit operands.
void legalizeGenericOperand(MachineBasicBlock &InsertMBB, MachineBasicBlock::iterator I, const TargetRegisterClass *DstRC, MachineOperand &Op, MachineRegisterInfo &MRI, const DebugLoc &DL) const
bool isVariadic(QueryType Type=IgnoreBundle) const
Return true if this instruction can have a variable number of operands.
bool hasScalarStores() const
unsigned getBitWidth() const
Return the number of bits in the APInt.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
void setImm(int64_t immVal)
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
void insertVectorSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const
uint64_t getDefaultRsrcDataFormat() const
self_iterator getIterator()
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
bool empty() const
empty - Check if the array is empty.
The AMDGPU TargetMachine interface definition for hw codgen targets.
virtual bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
Test if the given instruction should be considered a scheduling boundary.
bool has16BitInsts() const
std::vector< MachineBasicBlock * >::iterator pred_iterator
static unsigned getVGPRSpillRestoreOpcode(unsigned Size)
static bool isVOP2(const MachineInstr &MI)
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
unsigned getSubReg() const
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
void setHasSpilledSGPRs(bool Spill=true)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
bool isHighLatencyInstruction(const MachineInstr &MI) const
pred_iterator pred_begin()
LLVM_READONLY int getBasicFromSDWAOp(uint16_t Opcode)
unsigned insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
bool hasInv2PiInlineImm() const
This class contains a discriminated union of information about pointers in memory operands...
Operands with register or inline constant.
SIInstrInfo(const SISubtarget &)
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
unsigned getOpcode() const
Return the opcode number for this descriptor.
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const final
The memory access writes data.
bool isInlineConstant(const APInt &Imm) const
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg) const
Return a partially built integer add instruction without carry.
Representation for a specific memory location.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool memoperands_empty() const
Return true if we don't have any memory operands which described the the memory access done by this i...
A SetVector that performs no allocations if smaller than a certain size.
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...
bool analyzeBranchImpl(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
LLVM_READONLY int getVOPe32(uint16_t Opcode)
bool hasVALU32BitEncoding(unsigned Opcode) const
Return true if this 64-bit VALU instruction has a 32-bit encoding.
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 readlaneVGPRToSGPR(unsigned SrcReg, MachineInstr &UseMI, MachineRegisterInfo &MRI) const
Copy a value from a VGPR (SrcReg) to SGPR.
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo, const MachineOperand &MO) const
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
const uint64_t RSRC_INDEX_STRIDE_SHIFT
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
Represents one node in the SelectionDAG.
bool usesConstantBus(const MachineRegisterInfo &MRI, const MachineOperand &MO, const MCOperandInfo &OpInfo) const
Returns true if this operand uses the constant bus.
const MachineInstrBuilder & addFrameIndex(int Idx) const
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const override
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 isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
Class for arbitrary precision integers.
const Value * getValue() const
Return the base address of the memory access.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
const TargetRegisterClass * getRegClassConstraint(unsigned OpIdx, const TargetInstrInfo *TII, const TargetRegisterInfo *TRI) const
Compute the static register class constraint for operand OpIdx.
bool isShader(CallingConv::ID cc)
iterator_range< mop_iterator > implicit_operands()
void addImplicitDefUseOperands(MachineFunction &MF)
Add all implicit def and use operands to this instruction.
const TargetRegisterClass * getPhysRegClass(unsigned Reg) const
Return the 'base' register class for this register.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
bool isEntryFunction() const
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
static bool isVOP3(const MachineInstr &MI)
llvm_unreachable("Unknown RegBank!")
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.
bool shouldClusterMemOps(MachineInstr &FirstLdSt, MachineInstr &SecondLdSt, unsigned NumLoads) const final
void legalizeOperandsVOP2(MachineRegisterInfo &MRI, MachineInstr &MI) const
Legalize operands in MI by either commuting it or inserting a copy of src1.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
bool isFoldableCopy(const MachineInstr &MI) const
static bool compareMachineOp(const MachineOperand &Op0, const MachineOperand &Op1)
Representation of each machine instruction.
void insertReturn(MachineBasicBlock &MBB) const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
Interface definition for SIInstrInfo.
bool isVGPRCopy(const MachineInstr &MI) const
void enterBasicBlock(MachineBasicBlock &MBB)
Start tracking liveness from the begin of basic block MBB.
static bool isMTBUF(const MachineInstr &MI)
OperandType
Types of operands to CF instructions.
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
unsigned getMaxPrivateElementSize() const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const
Get required immediate operand.
static bool isVOPC(const MachineInstr &MI)
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
use_iterator use_begin(unsigned RegNo) const
unsigned getNumWaitStates(const MachineInstr &MI) const
Return the number of wait states that result from executing this instruction.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug instruction using the specified regis...
unsigned FLAT_ADDRESS
Address space for flat memory.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
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)
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
void setSubReg(unsigned subReg)
void clearKillFlags(unsigned Reg) const
clearKillFlags - Iterate over all the uses of the given register and clear the kill flag from the Mac...
bool isLowLatencyInstruction(const MachineInstr &MI) const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
constexpr char WavefrontSize[]
Key for Kernel::CodeProps::Metadata::mWavefrontSize.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Abstract Stack Frame Index.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
constexpr bool isUInt< 16 >(uint64_t x)
ArrayRef< std::pair< int, const char * > > getSerializableTargetIndices() const override
MachineInstr * removeFromParent()
Unlink 'this' from the containing basic block, and return it without deleting it. ...
bool isLiveIn(MCPhysReg Reg, LaneBitmask LaneMask=LaneBitmask::getAll()) const
Return true if the specified register is in the live in set.
EVT getValueType() const
Return the ValueType of the referenced return value.
static unsigned getVALUOp(const MachineInstr &MI)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
Operands with register or 32-bit immediate.
static void preserveCondRegFlags(MachineOperand &CondReg, const MachineOperand &OrigCond)
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isSALUOpSupportedOnVALU(const MachineInstr &MI) const
unsigned getReg() const
getReg - Returns the register number.
MIBundleBuilder & append(MachineInstr *MI)
Insert MI into MBB by appending it to the instructions in the bundle.
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.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
void setRegUsed(unsigned Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
const uint64_t RSRC_ELEMENT_SIZE_SHIFT
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
LLVM Value Representation.
bool hasModifiersSet(const MachineInstr &MI, unsigned OpName) const
static bool isSDWA(const MachineInstr &MI)
MachineInstr * convertToThreeAddress(MachineFunction::iterator &MBB, MachineInstr &MI, LiveVariables *LV) const override
unsigned getFrameOffsetReg() const
void materializeImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DestReg, int64_t Value) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
static bool isVGPRSpill(const MachineInstr &MI)
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Operand with 32-bit immediate that uses the constant bus.
const MCOperandInfo * OpInfo
void ChangeToFrameIndex(int Idx)
Replace this operand with a frame index.
uint64_t getSize() const
Return the size in bytes of the memory reference.
unsigned insertEQ(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const override
void legalizeOperands(MachineInstr &MI) const
Legalize all operands in this instruction.
const TargetRegisterClass * getOpRegClass(const MachineInstr &MI, unsigned OpNo) const
Return the correct register class for OpNo.
StringRef - Represent a constant reference to a string, i.e.
bool hasCalculatedTID() 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 ...
bool isLiteralConstantLike(const MachineOperand &MO, const MCOperandInfo &OpInfo) const
LLVM_READONLY int getAddr64Inst(uint16_t Opcode)
This holds information about one operand of a machine instruction, indicating the register class for ...
bool isMoveImmediate(QueryType Type=IgnoreBundle) const
Return true if this instruction is a move immediate (including conditional moves) instruction...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getTIDReg() const
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)
unsigned pred_size() const
bool modifiesRegister(unsigned Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
bool findCommutedOpIndices(MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
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.
LLVM_READONLY int getCommuteRev(uint16_t Opcode)
Helper class for constructing bundles of MachineInstrs.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode...
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
uint64_t getZExtValue() const
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned scavengeRegister(const TargetRegisterClass *RegClass, MachineBasicBlock::iterator I, int SPAdj)
Make a register of the specific register class available and do the appropriate bookkeeping.
bool contains(unsigned Reg) const
Return true if the specified register is included in this register class.