66 #define GET_INSTRINFO_CTOR_DTOR 67 #include "AMDGPUGenInstrInfo.inc" 71 #define GET_D16ImageDimIntrinsics_IMPL 72 #define GET_ImageDimIntrinsicTable_IMPL 73 #define GET_RsrcIntrinsics_IMPL 74 #include "AMDGPUGenSearchableTables.inc" 84 cl::desc(
"Restrict range of branch instructions (DEBUG)"));
112 if (Op0Idx == -1 && Op1Idx == -1)
116 if ((Op0Idx == -1 && Op1Idx != -1) ||
117 (Op1Idx == -1 && Op0Idx != -1))
136 case AMDGPU::V_MOV_B32_e32:
137 case AMDGPU::V_MOV_B32_e64:
138 case AMDGPU::V_MOV_B64_PSEUDO:
148 int64_t &Offset1)
const {
156 if (!
get(Opc0).mayLoad() || !
get(Opc1).mayLoad())
174 if (Offset0Idx == -1 || Offset1Idx == -1)
181 Offset0Idx -=
get(Opc0).NumDefs;
182 Offset1Idx -=
get(Opc1).NumDefs;
183 Offset0 = cast<ConstantSDNode>(Load0->
getOperand(Offset0Idx))->getZExtValue();
184 Offset1 = cast<ConstantSDNode>(Load1->
getOperand(Offset1Idx))->getZExtValue();
205 if (!Load0Offset || !Load1Offset)
209 Offset1 = Load1Offset->getZExtValue();
225 if (OffIdx0 == -1 || OffIdx1 == -1)
231 OffIdx0 -=
get(Opc0).NumDefs;
232 OffIdx1 -=
get(Opc1).NumDefs;
238 if (!isa<ConstantSDNode>(Off0) || !isa<ConstantSDNode>(Off1))
241 Offset0 = cast<ConstantSDNode>(Off0)->getZExtValue();
242 Offset1 = cast<ConstantSDNode>(Off1)->getZExtValue();
251 case AMDGPU::DS_READ2ST64_B32:
252 case AMDGPU::DS_READ2ST64_B64:
253 case AMDGPU::DS_WRITE2ST64_B32:
254 case AMDGPU::DS_WRITE2ST64_B64:
278 if (!BaseOp || !BaseOp->
isReg())
281 Offset = OffsetImm->
getImm();
294 uint8_t Offset0 = Offset0Imm->
getImm();
295 uint8_t Offset1 = Offset1Imm->
getImm();
297 if (Offset1 > Offset0 && Offset1 - Offset0 == 1) {
314 if (!BaseOp->
isReg())
317 Offset = EltSize * Offset0;
327 if (SOffset && SOffset->
isReg()) {
331 if (AddrReg && !AddrReg->
isFI())
343 Offset = OffsetImm->
getImm();
354 Offset = OffsetImm->
getImm();
356 Offset += SOffset->
getImm();
358 if (!BaseOp->
isReg())
372 Offset = OffsetImm->
getImm();
373 if (!BaseOp->
isReg())
393 if (!BaseOp->
isReg())
418 if (MO1->getAddrSpace() != MO2->getAddrSpace())
421 auto Base1 = MO1->getValue();
422 auto Base2 = MO2->getValue();
423 if (!Base1 || !Base2)
430 if (isa<UndefValue>(Base1) || isa<UndefValue>(Base2))
433 return Base1 == Base2;
438 unsigned NumLoads)
const {
451 const unsigned MaxGlobalLoadCluster = 6;
452 if (NumLoads > MaxGlobalLoadCluster)
464 }
else if (
isDS(FirstLdSt) &&
isDS(SecondLdSt)) {
469 if (!FirstDst || !SecondDst)
480 unsigned LoadClusterThreshold = 16;
491 return (NumLoads * (RI.getRegSizeInBits(*DstRC) / 8)) <= LoadClusterThreshold;
505 int64_t Offset0, int64_t Offset1,
506 unsigned NumLoads)
const {
507 assert(Offset1 > Offset0 &&
508 "Second offset should be larger than first offset!");
513 return (NumLoads <= 16 && (Offset1 - Offset0) < 64);
522 "illegal SGPR to VGPR copy",
527 BuildMI(MBB, MI, DL, TII->get(AMDGPU::SI_ILLEGAL_COPY), DestReg)
537 if (RC == &AMDGPU::VGPR_32RegClass) {
539 AMDGPU::SReg_32RegClass.
contains(SrcReg) ||
540 AMDGPU::AGPR_32RegClass.
contains(SrcReg));
541 unsigned Opc = AMDGPU::AGPR_32RegClass.contains(SrcReg) ?
542 AMDGPU::V_ACCVGPR_READ_B32 : AMDGPU::V_MOV_B32_e32;
543 BuildMI(MBB, MI, DL,
get(Opc), DestReg)
548 if (RC == &AMDGPU::SReg_32_XM0RegClass ||
549 RC == &AMDGPU::SReg_32RegClass) {
550 if (SrcReg == AMDGPU::SCC) {
551 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CSELECT_B32), DestReg)
557 if (DestReg == AMDGPU::VCC_LO) {
558 if (AMDGPU::SReg_32RegClass.
contains(SrcReg)) {
559 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), AMDGPU::VCC_LO)
564 BuildMI(MBB, MI, DL,
get(AMDGPU::V_CMP_NE_U32_e32))
572 if (!AMDGPU::SReg_32RegClass.
contains(SrcReg)) {
577 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
582 if (RC == &AMDGPU::SReg_64RegClass) {
583 if (DestReg == AMDGPU::VCC) {
584 if (AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
585 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), AMDGPU::VCC)
590 BuildMI(MBB, MI, DL,
get(AMDGPU::V_CMP_NE_U32_e32))
598 if (!AMDGPU::SReg_64RegClass.
contains(SrcReg)) {
603 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
608 if (DestReg == AMDGPU::SCC) {
610 BuildMI(MBB, MI, DL,
get(AMDGPU::S_CMP_LG_U32))
616 if (RC == &AMDGPU::AGPR_32RegClass) {
618 AMDGPU::SReg_32RegClass.
contains(SrcReg) ||
619 AMDGPU::AGPR_32RegClass.
contains(SrcReg));
620 if (!AMDGPU::VGPR_32RegClass.
contains(SrcReg)) {
624 if (!
Def->definesRegister(SrcReg, &RI))
626 if (
Def->getOpcode() != AMDGPU::V_ACCVGPR_WRITE_B32)
635 bool SafeToPropagate =
true;
636 for (
auto I =
Def;
I != MI && SafeToPropagate; ++
I)
637 if (
I->modifiesRegister(DefOp.
getReg(), &RI))
638 SafeToPropagate =
false;
640 if (!SafeToPropagate)
646 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ACCVGPR_WRITE_B32), DestReg)
662 unsigned RegNo = DestReg % 3;
670 while (RegNo-- && RS.
FindUnusedReg(&AMDGPU::VGPR_32RegClass)) {
678 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ACCVGPR_WRITE_B32), DestReg)
683 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ACCVGPR_WRITE_B32), DestReg)
688 unsigned EltSize = 4;
689 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
692 if (!(RI.getRegSizeInBits(*RC) % 64)) {
693 Opcode = AMDGPU::S_MOV_B64;
696 Opcode = AMDGPU::S_MOV_B32;
706 AMDGPU::V_ACCVGPR_WRITE_B32 : AMDGPU::COPY;
708 Opcode = AMDGPU::V_ACCVGPR_READ_B32;
714 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
717 SubIdx = SubIndices[Idx];
719 SubIdx = SubIndices[SubIndices.
size() - Idx - 1];
721 if (Opcode == TargetOpcode::COPY) {
722 copyPhysReg(MBB, MI, DL, RI.getSubReg(DestReg, SubIdx),
723 RI.getSubReg(SrcReg, SubIdx), KillSrc);
728 get(Opcode), RI.getSubReg(DestReg, SubIdx));
730 Builder.
addReg(RI.getSubReg(SrcReg, SubIdx));
735 bool UseKill = KillSrc && Idx == SubIndices.
size() - 1;
760 const DebugLoc &DL,
unsigned DestReg,
761 int64_t
Value)
const {
764 if (RegClass == &AMDGPU::SReg_32RegClass ||
765 RegClass == &AMDGPU::SGPR_32RegClass ||
766 RegClass == &AMDGPU::SReg_32_XM0RegClass ||
767 RegClass == &AMDGPU::SReg_32_XM0_XEXECRegClass) {
768 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B32), DestReg)
773 if (RegClass == &AMDGPU::SReg_64RegClass ||
774 RegClass == &AMDGPU::SGPR_64RegClass ||
775 RegClass == &AMDGPU::SReg_64_XEXECRegClass) {
776 BuildMI(MBB, MI, DL,
get(AMDGPU::S_MOV_B64), DestReg)
781 if (RegClass == &AMDGPU::VGPR_32RegClass) {
782 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DestReg)
786 if (RegClass == &AMDGPU::VReg_64RegClass) {
787 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B64_PSEUDO), DestReg)
792 unsigned EltSize = 4;
793 unsigned Opcode = AMDGPU::V_MOV_B32_e32;
795 if (RI.getRegSizeInBits(*RegClass) > 32) {
796 Opcode = AMDGPU::S_MOV_B64;
799 Opcode = AMDGPU::S_MOV_B32;
805 for (
unsigned Idx = 0; Idx < SubIndices.
size(); ++Idx) {
806 int64_t IdxValue = Idx == 0 ?
Value : 0;
809 get(Opcode), RI.getSubReg(DestReg, Idx));
816 return &AMDGPU::VGPR_32RegClass;
821 const DebugLoc &DL,
unsigned DstReg,
824 unsigned FalseReg)
const {
833 if (Cond.
size() == 1) {
835 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
837 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
843 }
else if (Cond.
size() == 2) {
844 assert(Cond[0].isImm() &&
"Cond[0] is not an immediate");
845 switch (Cond[0].getImm()) {
846 case SIInstrInfo::SCC_TRUE: {
849 : AMDGPU::S_CSELECT_B64), SReg)
852 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
860 case SIInstrInfo::SCC_FALSE: {
863 : AMDGPU::S_CSELECT_B64), SReg)
866 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
874 case SIInstrInfo::VCCNZ: {
878 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
880 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
888 case SIInstrInfo::VCCZ: {
892 BuildMI(MBB, I, DL,
get(AMDGPU::COPY), SReg)
894 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
902 case SIInstrInfo::EXECNZ: {
906 : AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
909 : AMDGPU::S_CSELECT_B64), SReg)
912 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
920 case SIInstrInfo::EXECZ: {
924 : AMDGPU::S_OR_SAVEEXEC_B64), SReg2)
927 : AMDGPU::S_CSELECT_B64), SReg)
930 BuildMI(MBB, I, DL,
get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
950 unsigned SrcReg,
int Value)
const {
953 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_EQ_I32_e64), Reg)
963 unsigned SrcReg,
int Value)
const {
966 BuildMI(*MBB, I, DL,
get(AMDGPU::V_CMP_NE_I32_e64), Reg)
977 if (RI.getRegSizeInBits(*DstRC) == 32) {
978 return RI.
isSGPRClass(DstRC) ? AMDGPU::S_MOV_B32 : AMDGPU::V_MOV_B32_e32;
979 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && RI.
isSGPRClass(DstRC)) {
980 return AMDGPU::S_MOV_B64;
981 }
else if (RI.getRegSizeInBits(*DstRC) == 64 && !RI.
isSGPRClass(DstRC)) {
982 return AMDGPU::V_MOV_B64_PSEUDO;
990 return AMDGPU::SI_SPILL_S32_SAVE;
992 return AMDGPU::SI_SPILL_S64_SAVE;
994 return AMDGPU::SI_SPILL_S96_SAVE;
996 return AMDGPU::SI_SPILL_S128_SAVE;
998 return AMDGPU::SI_SPILL_S160_SAVE;
1000 return AMDGPU::SI_SPILL_S256_SAVE;
1002 return AMDGPU::SI_SPILL_S512_SAVE;
1004 return AMDGPU::SI_SPILL_S1024_SAVE;
1013 return AMDGPU::SI_SPILL_V32_SAVE;
1015 return AMDGPU::SI_SPILL_V64_SAVE;
1017 return AMDGPU::SI_SPILL_V96_SAVE;
1019 return AMDGPU::SI_SPILL_V128_SAVE;
1021 return AMDGPU::SI_SPILL_V160_SAVE;
1023 return AMDGPU::SI_SPILL_V256_SAVE;
1025 return AMDGPU::SI_SPILL_V512_SAVE;
1027 return AMDGPU::SI_SPILL_V1024_SAVE;
1036 return AMDGPU::SI_SPILL_A32_SAVE;
1038 return AMDGPU::SI_SPILL_A64_SAVE;
1040 return AMDGPU::SI_SPILL_A128_SAVE;
1042 return AMDGPU::SI_SPILL_A512_SAVE;
1044 return AMDGPU::SI_SPILL_A1024_SAVE;
1052 unsigned SrcReg,
bool isKill,
1061 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
1062 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
1072 assert(SrcReg != AMDGPU::M0 &&
"m0 should not be spilled");
1103 auto MIB =
BuildMI(MBB, MI, DL,
get(Opcode));
1110 .addFrameIndex(FrameIndex)
1114 .addMemOperand(MMO);
1120 return AMDGPU::SI_SPILL_S32_RESTORE;
1122 return AMDGPU::SI_SPILL_S64_RESTORE;
1124 return AMDGPU::SI_SPILL_S96_RESTORE;
1126 return AMDGPU::SI_SPILL_S128_RESTORE;
1128 return AMDGPU::SI_SPILL_S160_RESTORE;
1130 return AMDGPU::SI_SPILL_S256_RESTORE;
1132 return AMDGPU::SI_SPILL_S512_RESTORE;
1134 return AMDGPU::SI_SPILL_S1024_RESTORE;
1143 return AMDGPU::SI_SPILL_V32_RESTORE;
1145 return AMDGPU::SI_SPILL_V64_RESTORE;
1147 return AMDGPU::SI_SPILL_V96_RESTORE;
1149 return AMDGPU::SI_SPILL_V128_RESTORE;
1151 return AMDGPU::SI_SPILL_V160_RESTORE;
1153 return AMDGPU::SI_SPILL_V256_RESTORE;
1155 return AMDGPU::SI_SPILL_V512_RESTORE;
1157 return AMDGPU::SI_SPILL_V1024_RESTORE;
1166 return AMDGPU::SI_SPILL_A32_RESTORE;
1168 return AMDGPU::SI_SPILL_A64_RESTORE;
1170 return AMDGPU::SI_SPILL_A128_RESTORE;
1172 return AMDGPU::SI_SPILL_A512_RESTORE;
1174 return AMDGPU::SI_SPILL_A1024_RESTORE;
1189 unsigned Align = FrameInfo.getObjectAlignment(FrameIndex);
1190 unsigned Size = FrameInfo.getObjectSize(FrameIndex);
1201 assert(DestReg != AMDGPU::M0 &&
"m0 should not be reloaded into");
1213 BuildMI(MBB, MI, DL, OpDesc, DestReg)
1223 auto MIB =
BuildMI(MBB, MI, DL,
get(Opcode), DestReg);
1229 MIB.addFrameIndex(FrameIndex)
1233 .addMemOperand(MMO);
1239 unsigned FrameOffset,
unsigned Size)
const {
1251 const DebugLoc &DL = Insert->getDebugLoc();
1255 if (TIDReg == AMDGPU::NoRegister)
1259 WorkGroupSize > WavefrontSize) {
1268 for (
unsigned Reg : {TIDIGXReg, TIDIGYReg, TIDIGZReg}) {
1277 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp0)
1280 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_LOAD_DWORD_IMM), STmp1)
1285 BuildMI(Entry, Insert, DL,
get(AMDGPU::S_MUL_I32), STmp1)
1289 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MUL_U32_U24_e32), TIDReg)
1293 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MAD_U32_U24), TIDReg)
1304 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_LO_U32_B32_e64),
1309 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_MBCNT_HI_U32_B32_e64),
1315 BuildMI(Entry, Insert, DL,
get(AMDGPU::V_LSHLREV_B32_e32),
1323 unsigned LDSOffset = MFI->
getLDSSize() + (FrameOffset * WorkGroupSize);
1343 BuildMI(MBB, MI, DL,
get(AMDGPU::S_NOP))
1361 if (HasNoTerminator) {
1385 case AMDGPU::S_MOV_B64_term:
1388 MI.
setDesc(
get(AMDGPU::S_MOV_B64));
1391 case AMDGPU::S_MOV_B32_term:
1394 MI.
setDesc(
get(AMDGPU::S_MOV_B32));
1397 case AMDGPU::S_XOR_B64_term:
1400 MI.
setDesc(
get(AMDGPU::S_XOR_B64));
1403 case AMDGPU::S_XOR_B32_term:
1406 MI.
setDesc(
get(AMDGPU::S_XOR_B32));
1409 case AMDGPU::S_OR_B32_term:
1412 MI.
setDesc(
get(AMDGPU::S_OR_B32));
1415 case AMDGPU::S_ANDN2_B64_term:
1418 MI.
setDesc(
get(AMDGPU::S_ANDN2_B64));
1421 case AMDGPU::S_ANDN2_B32_term:
1424 MI.
setDesc(
get(AMDGPU::S_ANDN2_B32));
1427 case AMDGPU::V_MOV_B64_PSEUDO: {
1429 Register DstLo = RI.getSubReg(Dst, AMDGPU::sub0);
1430 Register DstHi = RI.getSubReg(Dst, AMDGPU::sub1);
1435 if (SrcOp.
isImm()) {
1437 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1438 .
addImm(Imm.getLoBits(32).getZExtValue())
1440 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1441 .
addImm(Imm.getHiBits(32).getZExtValue())
1445 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstLo)
1448 BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_e32), DstHi)
1455 case AMDGPU::V_MOV_B64_DPP_PSEUDO: {
1459 case AMDGPU::V_SET_INACTIVE_B32: {
1460 unsigned NotOpc = ST.
isWave32() ? AMDGPU::S_NOT_B32 : AMDGPU::S_NOT_B64;
1461 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
1462 BuildMI(MBB, MI, DL,
get(NotOpc), Exec)
1466 BuildMI(MBB, MI, DL,
get(NotOpc), Exec)
1471 case AMDGPU::V_SET_INACTIVE_B64: {
1472 unsigned NotOpc = ST.
isWave32() ? AMDGPU::S_NOT_B32 : AMDGPU::S_NOT_B64;
1473 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
1474 BuildMI(MBB, MI, DL,
get(NotOpc), Exec)
1480 BuildMI(MBB, MI, DL,
get(NotOpc), Exec)
1485 case AMDGPU::V_MOVRELD_B32_V1:
1486 case AMDGPU::V_MOVRELD_B32_V2:
1487 case AMDGPU::V_MOVRELD_B32_V4:
1488 case AMDGPU::V_MOVRELD_B32_V8:
1489 case AMDGPU::V_MOVRELD_B32_V16: {
1490 const MCInstrDesc &MovRelDesc =
get(AMDGPU::V_MOVRELD_B32_e32);
1497 BuildMI(MBB, MI, DL, MovRelDesc)
1504 const int ImpDefIdx =
1506 const int ImpUseIdx = ImpDefIdx + 1;
1507 MovRel->tieOperands(ImpDefIdx, ImpUseIdx);
1512 case AMDGPU::SI_PC_ADD_REL_OFFSET: {
1515 Register RegLo = RI.getSubReg(Reg, AMDGPU::sub0);
1516 Register RegHi = RI.getSubReg(Reg, AMDGPU::sub1);
1521 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_GETPC_B64), Reg));
1525 Bundler.
append(
BuildMI(MF, DL,
get(AMDGPU::S_ADD_U32), RegLo)
1539 case AMDGPU::ENTER_WWM: {
1543 : AMDGPU::S_OR_SAVEEXEC_B64));
1546 case AMDGPU::EXIT_WWM: {
1549 MI.
setDesc(
get(ST.
isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64));
1552 case TargetOpcode::BUNDLE: {
1558 I->isBundledWithSucc(); ++
I) {
1559 I->unbundleFromSucc();
1562 MO.setIsInternalRead(
false);
1572 std::pair<MachineInstr*, MachineInstr*>
1577 DebugLoc DL = MBB.findDebugLoc(MI);
1585 for (
auto Sub : { AMDGPU::sub0, AMDGPU::sub1 }) {
1586 auto MovDPP =
BuildMI(MBB, MI, DL,
get(AMDGPU::V_MOV_B32_dpp));
1588 MovDPP.addDef(RI.getSubReg(Dst, Sub));
1595 for (
unsigned I = 1;
I <= 2; ++
I) {
1598 if (SrcOp.
isImm()) {
1601 MovDPP.addImm(Imm.getLoBits(32).getZExtValue());
1605 if (Src.isPhysical())
1606 MovDPP.addReg(RI.getSubReg(Src, Sub));
1615 Split[Part] = MovDPP;
1620 BuildMI(MBB, MI, DL,
get(AMDGPU::REG_SEQUENCE), Dst)
1621 .addReg(Split[0]->getOperand(0).getReg())
1622 .addImm(AMDGPU::sub0)
1627 return std::make_pair(Split[0], Split[1]);
1632 unsigned Src0OpName,
1634 unsigned Src1OpName)
const {
1641 "All commutable instructions have both src0 and src1 modifiers");
1643 int Src0ModsVal = Src0Mods->
getImm();
1644 int Src1ModsVal = Src1Mods->
getImm();
1646 Src1Mods->
setImm(Src0ModsVal);
1647 Src0Mods->
setImm(Src1ModsVal);
1656 bool IsKill = RegOp.
isKill();
1658 bool IsUndef = RegOp.
isUndef();
1659 bool IsDebug = RegOp.
isDebug();
1661 if (NonRegOp.
isImm())
1663 else if (NonRegOp.
isFI())
1668 NonRegOp.
ChangeToRegister(Reg,
false,
false, IsKill, IsDead, IsUndef, IsDebug);
1676 unsigned Src1Idx)
const {
1677 assert(!NewMI &&
"this should never be used");
1681 if (CommutedOpcode == -1)
1685 static_cast<int>(Src0Idx) &&
1687 static_cast<int>(Src1Idx) &&
1688 "inconsistency with findCommutedOpIndices");
1715 Src1, AMDGPU::OpName::src1_modifiers);
1717 CommutedMI->
setDesc(
get(CommutedOpcode));
1727 unsigned &SrcOpIdx0,
1728 unsigned &SrcOpIdx1)
const {
1733 unsigned &SrcOpIdx1)
const {
1746 return fixCommutedOpIndices(SrcOpIdx0, SrcOpIdx1, Src0Idx, Src1Idx);
1750 int64_t BrOffset)
const {
1753 assert(BranchOp != AMDGPU::S_SETPC_B64);
1767 if (MI.
getOpcode() == AMDGPU::S_SETPC_B64) {
1781 assert(RS &&
"RegScavenger required for long branching");
1783 "new block should be inserted for expanding unconditional branch");
1800 if (BrOffset >= 0) {
1801 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADD_U32))
1803 .
addReg(PCReg, 0, AMDGPU::sub0)
1805 BuildMI(MBB,
I, DL,
get(AMDGPU::S_ADDC_U32))
1807 .
addReg(PCReg, 0, AMDGPU::sub1)
1811 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUB_U32))
1813 .
addReg(PCReg, 0, AMDGPU::sub0)
1815 BuildMI(MBB,
I, DL,
get(AMDGPU::S_SUBB_U32))
1817 .
addReg(PCReg, 0, AMDGPU::sub1)
1822 BuildMI(&MBB, DL,
get(AMDGPU::S_SETPC_B64))
1863 AMDGPU::SReg_64RegClass,
1869 return 4 + 8 + 4 + 4;
1872 unsigned SIInstrInfo::getBranchOpcode(SIInstrInfo::BranchPredicate Cond) {
1874 case SIInstrInfo::SCC_TRUE:
1875 return AMDGPU::S_CBRANCH_SCC1;
1876 case SIInstrInfo::SCC_FALSE:
1877 return AMDGPU::S_CBRANCH_SCC0;
1878 case SIInstrInfo::VCCNZ:
1879 return AMDGPU::S_CBRANCH_VCCNZ;
1880 case SIInstrInfo::VCCZ:
1881 return AMDGPU::S_CBRANCH_VCCZ;
1882 case SIInstrInfo::EXECNZ:
1883 return AMDGPU::S_CBRANCH_EXECNZ;
1884 case SIInstrInfo::EXECZ:
1885 return AMDGPU::S_CBRANCH_EXECZ;
1891 SIInstrInfo::BranchPredicate SIInstrInfo::getBranchPredicate(
unsigned Opcode) {
1893 case AMDGPU::S_CBRANCH_SCC0:
1895 case AMDGPU::S_CBRANCH_SCC1:
1897 case AMDGPU::S_CBRANCH_VCCNZ:
1899 case AMDGPU::S_CBRANCH_VCCZ:
1901 case AMDGPU::S_CBRANCH_EXECNZ:
1903 case AMDGPU::S_CBRANCH_EXECZ:
1915 bool AllowModify)
const {
1916 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1918 TBB = I->getOperand(0).getMBB();
1924 if (I->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
1925 CondBB = I->getOperand(1).getMBB();
1928 BranchPredicate Pred = getBranchPredicate(I->getOpcode());
1929 if (Pred == INVALID_BR)
1932 CondBB = I->getOperand(0).getMBB();
1938 if (I == MBB.
end()) {
1944 if (I->getOpcode() == AMDGPU::S_BRANCH) {
1946 FBB = I->getOperand(0).getMBB();
1956 bool AllowModify)
const {
1964 while (I !=
E && !I->isBranch() && !I->isReturn() &&
1965 I->getOpcode() != AMDGPU::SI_MASK_BRANCH) {
1966 switch (I->getOpcode()) {
1967 case AMDGPU::SI_MASK_BRANCH:
1968 case AMDGPU::S_MOV_B64_term:
1969 case AMDGPU::S_XOR_B64_term:
1970 case AMDGPU::S_ANDN2_B64_term:
1971 case AMDGPU::S_MOV_B32_term:
1972 case AMDGPU::S_XOR_B32_term:
1973 case AMDGPU::S_OR_B32_term:
1974 case AMDGPU::S_ANDN2_B32_term:
1977 case AMDGPU::SI_ELSE:
1978 case AMDGPU::SI_KILL_I1_TERMINATOR:
1979 case AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR:
1992 if (I->getOpcode() != AMDGPU::SI_MASK_BRANCH)
2015 if (TBB != MaskBrDest || Cond.
empty())
2018 auto Pred = Cond[0].getImm();
2019 return (Pred != EXECZ && Pred != EXECNZ);
2023 int *BytesRemoved)
const {
2027 unsigned RemovedSize = 0;
2028 while (I != MBB.
end()) {
2030 if (I->getOpcode() == AMDGPU::SI_MASK_BRANCH) {
2036 I->eraseFromParent();
2042 *BytesRemoved = RemovedSize;
2059 int *BytesAdded)
const {
2060 if (!FBB && Cond.
empty()) {
2061 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
2068 if(Cond.
size() == 1 && Cond[0].isReg()) {
2069 BuildMI(&MBB, DL,
get(AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO))
2075 assert(TBB && Cond[0].isImm());
2078 = getBranchOpcode(static_cast<BranchPredicate>(Cond[0].getImm()));
2083 BuildMI(&MBB, DL,
get(Opcode))
2097 BuildMI(&MBB, DL,
get(Opcode))
2099 BuildMI(&MBB, DL,
get(AMDGPU::S_BRANCH))
2114 if (Cond.
size() != 2) {
2118 if (Cond[0].isImm()) {
2119 Cond[0].setImm(-Cond[0].getImm());
2128 unsigned TrueReg,
unsigned FalseReg,
2130 int &TrueCycles,
int &FalseCycles)
const {
2131 switch (Cond[0].getImm()) {
2139 CondCycles = TrueCycles = FalseCycles = NumInsts;
2142 return RI.
hasVGPRs(RC) && NumInsts <= 6;
2155 if (NumInsts % 2 == 0)
2158 CondCycles = TrueCycles = FalseCycles = NumInsts;
2169 unsigned TrueReg,
unsigned FalseReg)
const {
2170 BranchPredicate Pred =
static_cast<BranchPredicate
>(Cond[0].getImm());
2171 if (Pred == VCCZ || Pred == SCC_FALSE) {
2172 Pred =
static_cast<BranchPredicate
>(-Pred);
2178 unsigned DstSize = RI.getRegSizeInBits(*DstRC);
2180 if (DstSize == 32) {
2181 unsigned SelOp = Pred == SCC_TRUE ?
2182 AMDGPU::S_CSELECT_B32 : AMDGPU::V_CNDMASK_B32_e32;
2186 BuildMI(MBB, I, DL,
get(SelOp), DstReg)
2194 if (DstSize == 64 && Pred == SCC_TRUE) {
2196 BuildMI(MBB, I, DL,
get(AMDGPU::S_CSELECT_B64), DstReg)
2204 static const int16_t Sub0_15[] = {
2205 AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3,
2206 AMDGPU::sub4, AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7,
2207 AMDGPU::sub8, AMDGPU::sub9, AMDGPU::sub10, AMDGPU::sub11,
2208 AMDGPU::sub12, AMDGPU::sub13, AMDGPU::sub14, AMDGPU::sub15,
2211 static const int16_t Sub0_15_64[] = {
2212 AMDGPU::sub0_sub1, AMDGPU::sub2_sub3,
2213 AMDGPU::sub4_sub5, AMDGPU::sub6_sub7,
2214 AMDGPU::sub8_sub9, AMDGPU::sub10_sub11,
2215 AMDGPU::sub12_sub13, AMDGPU::sub14_sub15,
2218 unsigned SelOp = AMDGPU::V_CNDMASK_B32_e32;
2220 const int16_t *SubIndices = Sub0_15;
2221 int NElts = DstSize / 32;
2225 if (Pred == SCC_TRUE) {
2227 SelOp = AMDGPU::S_CSELECT_B32;
2228 EltRC = &AMDGPU::SGPR_32RegClass;
2230 SelOp = AMDGPU::S_CSELECT_B64;
2231 EltRC = &AMDGPU::SGPR_64RegClass;
2232 SubIndices = Sub0_15_64;
2238 MBB, I, DL,
get(AMDGPU::REG_SEQUENCE), DstReg);
2243 for (
int Idx = 0; Idx != NElts; ++Idx) {
2247 unsigned SubIdx = SubIndices[Idx];
2250 BuildMI(MBB, I, DL,
get(SelOp), DstElt)
2251 .
addReg(FalseReg, 0, SubIdx)
2252 .
addReg(TrueReg, 0, SubIdx);
2263 case AMDGPU::V_MOV_B32_e32:
2264 case AMDGPU::V_MOV_B32_e64:
2265 case AMDGPU::V_MOV_B64_PSEUDO: {
2273 case AMDGPU::S_MOV_B32:
2274 case AMDGPU::S_MOV_B64:
2276 case AMDGPU::V_ACCVGPR_WRITE_B32:
2277 case AMDGPU::V_ACCVGPR_READ_B32:
2285 unsigned Kind)
const {
2304 AMDGPU::OpName::src0_modifiers);
2306 AMDGPU::OpName::src1_modifiers);
2308 AMDGPU::OpName::src2_modifiers);
2323 case AMDGPU::S_MOV_B64:
2328 case AMDGPU::V_MOV_B32_e32:
2329 case AMDGPU::S_MOV_B32:
2330 case AMDGPU::V_ACCVGPR_WRITE_B32:
2337 if (!ImmOp->
isImm())
2341 if (Opc == AMDGPU::COPY) {
2343 unsigned NewOpc = isVGPRCopy ? AMDGPU::V_MOV_B32_e32 : AMDGPU::S_MOV_B32;
2347 NewOpc = AMDGPU::V_ACCVGPR_WRITE_B32;
2355 if (Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64 ||
2356 Opc == AMDGPU::V_MAD_F16 || Opc == AMDGPU::V_MAC_F16_e64 ||
2357 Opc == AMDGPU::V_FMA_F32 || Opc == AMDGPU::V_FMAC_F32_e64 ||
2358 Opc == AMDGPU::V_FMA_F16 || Opc == AMDGPU::V_FMAC_F16_e64) {
2373 bool IsF32 = Opc == AMDGPU::V_MAD_F32 || Opc == AMDGPU::V_MAC_F32_e64 ||
2374 Opc == AMDGPU::V_FMA_F32 || Opc == AMDGPU::V_FMAC_F32_e64;
2375 bool IsFMA = Opc == AMDGPU::V_FMA_F32 || Opc == AMDGPU::V_FMAC_F32_e64 ||
2376 Opc == AMDGPU::V_FMA_F16 || Opc == AMDGPU::V_FMAC_F16_e64;
2390 IsFMA ? (IsF32 ? AMDGPU::V_FMAMK_F32 : AMDGPU::V_FMAMK_F16)
2391 : (IsF32 ? AMDGPU::V_MADMK_F32 : AMDGPU::V_MADMK_F16);
2397 const int64_t Imm = ImmOp->
getImm();
2409 unsigned Src1SubReg = Src1->
getSubReg();
2414 if (Opc == AMDGPU::V_MAC_F32_e64 ||
2415 Opc == AMDGPU::V_MAC_F16_e64 ||
2416 Opc == AMDGPU::V_FMAC_F32_e64 ||
2417 Opc == AMDGPU::V_FMAC_F16_e64)
2437 bool Src0Inlined =
false;
2438 if (Src0->
isReg()) {
2458 if (Src1->
isReg() && !Src0Inlined ) {
2464 commuteInstruction(UseMI)) {
2475 IsFMA ? (IsF32 ? AMDGPU::V_FMAAK_F32 : AMDGPU::V_FMAAK_F16)
2476 : (IsF32 ? AMDGPU::V_MADAK_F32 : AMDGPU::V_MADAK_F16);
2480 const int64_t Imm = ImmOp->
getImm();
2491 if (Opc == AMDGPU::V_MAC_F32_e64 ||
2492 Opc == AMDGPU::V_MAC_F16_e64 ||
2493 Opc == AMDGPU::V_FMAC_F32_e64 ||
2494 Opc == AMDGPU::V_FMAC_F16_e64)
2521 int WidthB,
int OffsetB) {
2522 int LowOffset = OffsetA < OffsetB ? OffsetA : OffsetB;
2523 int HighOffset = OffsetA < OffsetB ? OffsetB : OffsetA;
2524 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
2525 return LowOffset + LowWidth <= HighOffset;
2528 bool SIInstrInfo::checkInstOffsetsDoNotOverlap(
const MachineInstr &MIa,
2531 int64_t Offset0, Offset1;
2555 "MIa must load from or modify a memory location");
2557 "MIb must load from or modify a memory location");
2573 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2580 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2587 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2594 return checkInstOffsetsDoNotOverlap(MIa, MIb);
2608 if (
Def &&
Def->getOpcode() == AMDGPU::V_MOV_B32_e32 &&
2609 Def->getOperand(1).isImm())
2610 return Def->getOperand(1).getImm();
2611 return AMDGPU::NoRegister;
2619 bool IsFMA = Opc == AMDGPU::V_FMAC_F32_e32 || Opc == AMDGPU::V_FMAC_F32_e64 ||
2620 Opc == AMDGPU::V_FMAC_F16_e32 || Opc == AMDGPU::V_FMAC_F16_e64;
2625 case AMDGPU::V_MAC_F16_e64:
2626 case AMDGPU::V_FMAC_F16_e64:
2629 case AMDGPU::V_MAC_F32_e64:
2630 case AMDGPU::V_FMAC_F32_e64:
2632 case AMDGPU::V_MAC_F16_e32:
2633 case AMDGPU::V_FMAC_F16_e32:
2636 case AMDGPU::V_MAC_F32_e32:
2637 case AMDGPU::V_FMAC_F32_e32: {
2639 AMDGPU::OpName::src0);
2641 if (!Src0->isReg() && !Src0->isImm())
2662 if (!Src0Mods && !Src1Mods && !Clamp && !Omod &&
2669 IsFMA ? (IsF16 ? AMDGPU::V_FMAAK_F16 : AMDGPU::V_FMAAK_F32)
2670 : (IsF16 ? AMDGPU::V_MADAK_F16 : AMDGPU::V_MADAK_F32);
2679 IsFMA ? (IsF16 ? AMDGPU::V_FMAMK_F16 : AMDGPU::V_FMAMK_F32)
2680 : (IsF16 ? AMDGPU::V_MADMK_F16 : AMDGPU::V_MADMK_F32);
2692 AMDGPU::OpName::src0), Src1))
2701 unsigned NewOpc = IsFMA ? (IsF16 ? AMDGPU::V_FMA_F16 : AMDGPU::V_FMA_F32)
2702 : (IsF16 ? AMDGPU::V_MAD_F16 : AMDGPU::V_MAD_F32);
2710 .addImm(Src1Mods ? Src1Mods->
getImm() : 0)
2714 .addImm(Clamp ? Clamp->
getImm() : 0)
2715 .addImm(Omod ? Omod->
getImm() : 0);
2723 case AMDGPU::S_SET_GPR_IDX_ON:
2724 case AMDGPU::S_SET_GPR_IDX_MODE:
2725 case AMDGPU::S_SET_GPR_IDX_OFF:
2742 MI.
getOpcode() == AMDGPU::S_SETREG_IMM32_B32 ||
2743 MI.
getOpcode() == AMDGPU::S_SETREG_B32 ||
2744 MI.
getOpcode() == AMDGPU::S_DENORM_MODE ||
2750 Opcode == AMDGPU::DS_GWS_INIT ||
2751 Opcode == AMDGPU::DS_GWS_SEMA_V ||
2752 Opcode == AMDGPU::DS_GWS_SEMA_BR ||
2753 Opcode == AMDGPU::DS_GWS_SEMA_P ||
2754 Opcode == AMDGPU::DS_GWS_SEMA_RELEASE_ALL ||
2755 Opcode == AMDGPU::DS_GWS_BARRIER;
2774 if (Opcode == AMDGPU::S_SENDMSG || Opcode == AMDGPU::S_SENDMSGHALT ||
2775 Opcode ==
AMDGPU::EXP || Opcode == AMDGPU::EXP_DONE ||
2777 Opcode == AMDGPU::DS_GWS_INIT || Opcode == AMDGPU::DS_GWS_BARRIER)
2788 if (Opcode == AMDGPU::V_READFIRSTLANE_B32 || Opcode == AMDGPU::V_READLANE_B32)
2851 int64_t Imm = MO.
getImm();
2852 switch (OperandType) {
2859 int32_t Trunc =
static_cast<int32_t
>(Imm);
2879 int16_t Trunc =
static_cast<int16_t
>(Imm);
2952 AMDGPU::OpName::src2))
2979 AMDGPU::OpName::src0_modifiers) != -1;
2985 return Mods && Mods->
getImm();
3008 default:
return false;
3010 case AMDGPU::V_ADDC_U32_e64:
3011 case AMDGPU::V_SUBB_U32_e64:
3012 case AMDGPU::V_SUBBREV_U32_e64: {
3020 case AMDGPU::V_MAC_F32_e64:
3021 case AMDGPU::V_MAC_F16_e64:
3022 case AMDGPU::V_FMAC_F32_e64:
3023 case AMDGPU::V_FMAC_F16_e64:
3029 case AMDGPU::V_CNDMASK_B32_e64:
3059 if (
Use.isUse() &&
Use.getReg() == AMDGPU::VCC) {
3068 unsigned Op32)
const {
3076 if (Op32DstIdx != -1) {
3095 if (Op32Src2Idx != -1) {
3127 if (MO.
getReg() == AMDGPU::SGPR_NULL)
3132 return MO.
getReg() == AMDGPU::M0 ||
3133 MO.
getReg() == AMDGPU::VCC ||
3134 MO.
getReg() == AMDGPU::VCC_LO;
3136 return AMDGPU::SReg_32RegClass.contains(MO.
getReg()) ||
3147 switch (MO.getReg()) {
3149 case AMDGPU::VCC_LO:
3150 case AMDGPU::VCC_HI:
3152 case AMDGPU::FLAT_SCR:
3160 return AMDGPU::NoRegister;
3166 case AMDGPU::V_READLANE_B32:
3167 case AMDGPU::V_READLANE_B32_gfx6_gfx7:
3168 case AMDGPU::V_READLANE_B32_gfx10:
3169 case AMDGPU::V_READLANE_B32_vi:
3170 case AMDGPU::V_WRITELANE_B32:
3171 case AMDGPU::V_WRITELANE_B32_gfx6_gfx7:
3172 case AMDGPU::V_WRITELANE_B32_gfx10:
3173 case AMDGPU::V_WRITELANE_B32_vi:
3181 SIInstrInfo::isGenericOpcode(MI.
getOpcode()) ||
3193 return TRI.isSubRegister(SuperVec.
getReg(), SubReg.
getReg());
3195 return SubReg.
getSubReg() != AMDGPU::NoSubRegister &&
3202 if (SIInstrInfo::isGenericOpcode(MI.
getOpcode()))
3216 ErrInfo =
"Instruction has wrong number of operands.";
3234 ErrInfo =
"inlineasm operand has incorrect register class.";
3245 ErrInfo =
"FPImm Machine Operands are not supported. ISel should bitcast " 3246 "all fp values to integers.";
3255 ErrInfo =
"Illegal immediate value for operand.";
3274 ErrInfo =
"Illegal immediate value for operand.";
3285 ErrInfo =
"Expected immediate, but got non-immediate";
3296 if (RegClass != -1) {
3303 ErrInfo =
"Operand has incorrect register class.";
3312 ErrInfo =
"SDWA is not supported on this target";
3318 const int OpIndicies[] = { DstIdx, Src0Idx, Src1Idx, Src2Idx };
3320 for (
int OpIdx: OpIndicies) {
3328 ErrInfo =
"Only VGPRs allowed as operands in SDWA instructions on VI";
3334 ErrInfo =
"Only reg allowed as operands in SDWA instructions on GFX9";
3343 if (OMod !=
nullptr &&
3345 ErrInfo =
"OMod not allowed in SDWA instructions on VI";
3351 if (
isVOPC(BasicOpcode)) {
3355 if (!Dst.
isReg() || Dst.
getReg() != AMDGPU::VCC) {
3356 ErrInfo =
"Only VCC allowed as dst in SDWA instructions on VI";
3362 if (Clamp && (!Clamp->
isImm() || Clamp->
getImm() != 0)) {
3363 ErrInfo =
"Clamp not allowed in VOPC SDWA instructions on VI";
3369 if (OMod && (!OMod->
isImm() || OMod->
getImm() != 0)) {
3370 ErrInfo =
"OMod not allowed in VOPC SDWA instructions on VI";
3377 if (DstUnused && DstUnused->
isImm() &&
3381 ErrInfo =
"Dst register should have tied register";
3389 "Dst register should be tied to implicit use of preserved register";
3393 ErrInfo =
"Dst register should use same physical register as preserved";
3405 uint64_t DMaskImm = DMask->
getImm();
3425 uint32_t DstSize = RI.getRegSizeInBits(*DstRC) / 32;
3426 if (RegCount > DstSize) {
3427 ErrInfo =
"MIMG instruction returns too many registers for dst " 3436 if (Desc.
getOpcode() != AMDGPU::V_WRITELANE_B32
3441 const int OpIndices[] = { Src0Idx, Src1Idx, Src2Idx };
3443 unsigned ConstantBusCount = 0;
3444 unsigned LiteralCount = 0;
3451 if (SGPRUsed != AMDGPU::NoRegister) {
3456 for (
int OpIdx : OpIndices) {
3463 if (
llvm::all_of(SGPRsUsed, [
this, SGPRUsed](
unsigned SGPR) {
3464 return !RI.regsOverlap(SGPRUsed, SGPR);
3479 Opcode != AMDGPU::V_WRITELANE_B32) {
3480 ErrInfo =
"VOP* instruction violates constant bus restriction";
3484 if (
isVOP3(MI) && LiteralCount) {
3486 ErrInfo =
"VOP3 instruction uses literal";
3489 if (LiteralCount > 1) {
3490 ErrInfo =
"VOP3 instruction uses more than one literal";
3498 if (Desc.
getOpcode() == AMDGPU::V_WRITELANE_B32) {
3499 unsigned SGPRCount = 0;
3500 Register SGPRUsed = AMDGPU::NoRegister;
3502 for (
int OpIdx : {Src0Idx, Src1Idx, Src2Idx}) {
3510 if (MO.
getReg() != SGPRUsed)
3516 ErrInfo =
"WRITELANE instruction violates constant bus restriction";
3523 if (Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F32 ||
3524 Desc.
getOpcode() == AMDGPU::V_DIV_SCALE_F64) {
3531 ErrInfo =
"v_div_scale_{f32|f64} require src0 = src1 or src2";
3540 unsigned Immediates = 0;
3542 if (!Src0.
isReg() &&
3545 if (!Src1.
isReg() &&
3549 if (Immediates > 1) {
3550 ErrInfo =
"SOP2/SOPC instruction requires too many immediate constants";
3559 ErrInfo =
"invalid branch target for SOPK instruction";
3563 uint64_t Imm =
Op->getImm();
3566 ErrInfo =
"invalid immediate for SOPK instruction";
3571 ErrInfo =
"invalid immediate for SOPK instruction";
3578 if (Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e32 ||
3579 Desc.
getOpcode() == AMDGPU::V_MOVRELS_B32_e64 ||
3580 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
3581 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64) {
3582 const bool IsDst = Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e32 ||
3583 Desc.
getOpcode() == AMDGPU::V_MOVRELD_B32_e64;
3587 const unsigned NumImplicitOps = IsDst ? 2 : 1;
3593 ErrInfo =
"missing implicit register operands";
3599 if (!Dst->
isUse()) {
3600 ErrInfo =
"v_movreld_b32 vdst should be a use operand";
3606 UseOpIdx != StaticNumOps + 1) {
3607 ErrInfo =
"movrel implicit operands should be tied";
3614 = MI.
getOperand(StaticNumOps + NumImplicitOps - 1);
3616 !
isSubRegOf(RI, ImpUse, IsDst ? *Dst : Src0)) {
3617 ErrInfo =
"src0 should be subreg of implicit vector use";
3626 ErrInfo =
"VALU instruction does not implicitly read exec mask";
3636 if (Soff && Soff->
getReg() != AMDGPU::M0) {
3637 ErrInfo =
"scalar stores must use m0 as offset register";
3645 if (Offset->
getImm() != 0) {
3646 ErrInfo =
"subtarget does not support offsets in flat instructions";
3655 AMDGPU::OpName::vaddr0);
3664 ErrInfo =
"dim is out of range";
3668 bool IsNSA = SRsrcIdx - VAddr0Idx > 1;
3674 unsigned VAddrWords;
3676 VAddrWords = SRsrcIdx - VAddr0Idx;
3682 else if (AddrWords > 4)
3684 else if (AddrWords == 3 && VAddrWords == 4) {
3691 if (VAddrWords != AddrWords) {
3692 ErrInfo =
"bad vaddr size";
3710 ErrInfo =
"Invalid dpp_ctrl value";
3715 ErrInfo =
"Invalid dpp_ctrl value: " 3716 "wavefront shifts are not supported on GFX10+";
3721 ErrInfo =
"Invalid dpp_ctrl value: " 3722 "broadcasts are not supported on GFX10+";
3727 ErrInfo =
"Invalid dpp_ctrl value: " 3728 "row_share and row_xmask are not supported before GFX10";
3738 default:
return AMDGPU::INSTRUCTION_LIST_END;
3739 case AMDGPU::REG_SEQUENCE:
return AMDGPU::REG_SEQUENCE;
3740 case AMDGPU::COPY:
return AMDGPU::COPY;
3741 case AMDGPU::PHI:
return AMDGPU::PHI;
3742 case AMDGPU::INSERT_SUBREG:
return AMDGPU::INSERT_SUBREG;
3744 case AMDGPU::SOFT_WQM:
return AMDGPU::SOFT_WQM;
3745 case AMDGPU::WWM:
return AMDGPU::WWM;
3746 case AMDGPU::S_MOV_B32: {
3750 AMDGPU::COPY : AMDGPU::V_MOV_B32_e32;
3752 case AMDGPU::S_ADD_I32:
3753 return ST.hasAddNoCarry() ? AMDGPU::V_ADD_U32_e64 : AMDGPU::V_ADD_I32_e32;
3754 case AMDGPU::S_ADDC_U32:
3755 return AMDGPU::V_ADDC_U32_e32;
3756 case AMDGPU::S_SUB_I32:
3757 return ST.hasAddNoCarry() ? AMDGPU::V_SUB_U32_e64 : AMDGPU::V_SUB_I32_e32;
3760 case AMDGPU::S_ADD_U32:
3761 return AMDGPU::V_ADD_I32_e32;
3762 case AMDGPU::S_SUB_U32:
3763 return AMDGPU::V_SUB_I32_e32;
3764 case AMDGPU::S_SUBB_U32:
return AMDGPU::V_SUBB_U32_e32;
3765 case AMDGPU::S_MUL_I32:
return AMDGPU::V_MUL_LO_U32;
3766 case AMDGPU::S_MUL_HI_U32:
return AMDGPU::V_MUL_HI_U32;
3767 case AMDGPU::S_MUL_HI_I32:
return AMDGPU::V_MUL_HI_I32;
3768 case AMDGPU::S_AND_B32:
return AMDGPU::V_AND_B32_e64;
3769 case AMDGPU::S_OR_B32:
return AMDGPU::V_OR_B32_e64;
3770 case AMDGPU::S_XOR_B32:
return AMDGPU::V_XOR_B32_e64;
3771 case AMDGPU::S_XNOR_B32:
3772 return ST.hasDLInsts() ? AMDGPU::V_XNOR_B32_e64 : AMDGPU::INSTRUCTION_LIST_END;
3773 case AMDGPU::S_MIN_I32:
return AMDGPU::V_MIN_I32_e64;
3774 case AMDGPU::S_MIN_U32:
return AMDGPU::V_MIN_U32_e64;
3775 case AMDGPU::S_MAX_I32:
return AMDGPU::V_MAX_I32_e64;
3776 case AMDGPU::S_MAX_U32:
return AMDGPU::V_MAX_U32_e64;
3777 case AMDGPU::S_ASHR_I32:
return AMDGPU::V_ASHR_I32_e32;
3778 case AMDGPU::S_ASHR_I64:
return AMDGPU::V_ASHR_I64;
3779 case AMDGPU::S_LSHL_B32:
return AMDGPU::V_LSHL_B32_e32;
3780 case AMDGPU::S_LSHL_B64:
return AMDGPU::V_LSHL_B64;
3781 case AMDGPU::S_LSHR_B32:
return AMDGPU::V_LSHR_B32_e32;
3782 case AMDGPU::S_LSHR_B64:
return AMDGPU::V_LSHR_B64;
3783 case AMDGPU::S_SEXT_I32_I8:
return AMDGPU::V_BFE_I32;
3784 case AMDGPU::S_SEXT_I32_I16:
return AMDGPU::V_BFE_I32;
3785 case AMDGPU::S_BFE_U32:
return AMDGPU::V_BFE_U32;
3786 case AMDGPU::S_BFE_I32:
return AMDGPU::V_BFE_I32;
3787 case AMDGPU::S_BFM_B32:
return AMDGPU::V_BFM_B32_e64;
3788 case AMDGPU::S_BREV_B32:
return AMDGPU::V_BFREV_B32_e32;
3789 case AMDGPU::S_NOT_B32:
return AMDGPU::V_NOT_B32_e32;
3790 case AMDGPU::S_NOT_B64:
return AMDGPU::V_NOT_B32_e32;
3791 case AMDGPU::S_CMP_EQ_I32:
return AMDGPU::V_CMP_EQ_I32_e32;
3792 case AMDGPU::S_CMP_LG_I32:
return AMDGPU::V_CMP_NE_I32_e32;
3793 case AMDGPU::S_CMP_GT_I32:
return AMDGPU::V_CMP_GT_I32_e32;
3794 case AMDGPU::S_CMP_GE_I32:
return AMDGPU::V_CMP_GE_I32_e32;
3795 case AMDGPU::S_CMP_LT_I32:
return AMDGPU::V_CMP_LT_I32_e32;
3796 case AMDGPU::S_CMP_LE_I32:
return AMDGPU::V_CMP_LE_I32_e32;
3797 case AMDGPU::S_CMP_EQ_U32:
return AMDGPU::V_CMP_EQ_U32_e32;
3798 case AMDGPU::S_CMP_LG_U32:
return AMDGPU::V_CMP_NE_U32_e32;
3799 case AMDGPU::S_CMP_GT_U32:
return AMDGPU::V_CMP_GT_U32_e32;
3800 case AMDGPU::S_CMP_GE_U32:
return AMDGPU::V_CMP_GE_U32_e32;
3801 case AMDGPU::S_CMP_LT_U32:
return AMDGPU::V_CMP_LT_U32_e32;
3802 case AMDGPU::S_CMP_LE_U32:
return AMDGPU::V_CMP_LE_U32_e32;
3803 case AMDGPU::S_CMP_EQ_U64:
return AMDGPU::V_CMP_EQ_U64_e32;
3804 case AMDGPU::S_CMP_LG_U64:
return AMDGPU::V_CMP_NE_U64_e32;
3805 case AMDGPU::S_BCNT1_I32_B32:
return AMDGPU::V_BCNT_U32_B32_e64;
3806 case AMDGPU::S_FF1_I32_B32:
return AMDGPU::V_FFBL_B32_e32;
3807 case AMDGPU::S_FLBIT_I32_B32:
return AMDGPU::V_FFBH_U32_e32;
3808 case AMDGPU::S_FLBIT_I32:
return AMDGPU::V_FFBH_I32_e64;
3809 case AMDGPU::S_CBRANCH_SCC0:
return AMDGPU::S_CBRANCH_VCCZ;
3810 case AMDGPU::S_CBRANCH_SCC1:
return AMDGPU::S_CBRANCH_VCCNZ;
3813 "Unexpected scalar opcode without corresponding vector one!");
3817 unsigned OpNo)
const {
3826 return RI.getPhysRegClass(Reg);
3830 return RI.getRegClass(RCID);
3840 unsigned RCID =
get(MI.
getOpcode()).OpInfo[OpIdx].RegClass;
3842 unsigned Size = TRI->getRegSizeInBits(*RC);
3843 unsigned Opcode = (Size == 64) ? AMDGPU::V_MOV_B64_PSEUDO : AMDGPU::V_MOV_B32_e32;
3845 Opcode = AMDGPU::COPY;
3846 else if (RI.isSGPRClass(RC))
3847 Opcode = (Size == 64) ? AMDGPU::S_MOV_B64 : AMDGPU::S_MOV_B32;
3850 if (RI.getCommonSubClass(&AMDGPU::VReg_64RegClass, VRC))
3851 VRC = &AMDGPU::VReg_64RegClass;
3853 VRC = &AMDGPU::VGPR_32RegClass;
3872 if (SuperReg.
getSubReg() == AMDGPU::NoSubRegister) {
3873 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
3884 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), NewSuperReg)
3887 BuildMI(*MBB, MI, DL,
get(TargetOpcode::COPY), SubReg)
3888 .
addReg(NewSuperReg, 0, SubIdx);
3901 if (SubIdx == AMDGPU::sub0)
3903 if (SubIdx == AMDGPU::sub1)
3915 void SIInstrInfo::swapOperands(
MachineInstr &Inst)
const {
3931 : RI.getPhysRegClass(Reg);
3940 DRC = RI.getMatchingSuperRegClass(SuperRC, DRC, MO.
getSubReg());
3986 if (!SGPRsUsed.
count(SGPR) &&
3988 if (--ConstantBusLimit <= 0)
3993 if (--ConstantBusLimit <= 0)
3997 if (!VOP3LiteralLimit--)
3999 if (--ConstantBusLimit <= 0)
4035 if (HasImplicitSGPR && ST.getConstantBusLimit(Opc) <= 1 &&
4036 Src0.
isReg() && (RI.isSGPRReg(MRI, Src0.
getReg()) ||
4043 if (Opc == AMDGPU::V_WRITELANE_B32) {
4045 if (Src0.
isReg() && RI.isVGPR(MRI, Src0.
getReg())) {
4051 if (Src1.
isReg() && RI.isVGPR(MRI, Src1.
getReg())) {
4062 if (Src0.
isReg() && RI.isAGPR(MRI, Src0.
getReg()))
4065 if (Src1.
isReg() && RI.isAGPR(MRI, Src1.
getReg()))
4076 if (Opc == AMDGPU::V_READLANE_B32 && Src1.
isReg() &&
4077 RI.isVGPR(MRI, Src1.
getReg())) {
4107 if (CommutedOpc == -1) {
4116 bool Src0Kill = Src0.
isKill();
4120 else if (Src1.
isReg()) {
4143 if (Opc == AMDGPU::V_PERMLANE16_B32 ||
4144 Opc == AMDGPU::V_PERMLANEX16_B32) {
4164 int ConstantBusLimit = ST.getConstantBusLimit(Opc);
4165 int LiteralLimit = ST.hasVOP3Literal() ? 1 : 0;
4167 unsigned SGPRReg = findUsedSGPR(MI, VOP3Idx);
4168 if (SGPRReg != AMDGPU::NoRegister) {
4169 SGPRsUsed.
insert(SGPRReg);
4173 for (
unsigned i = 0; i < 3; ++i) {
4174 int Idx = VOP3Idx[i];
4183 if (LiteralLimit > 0 && ConstantBusLimit > 0) {
4208 if (ConstantBusLimit > 0) {
4225 unsigned SubRegs = RI.getRegSizeInBits(*VRC) / 32;
4227 if (RI.hasAGPRs(VRC)) {
4228 VRC = RI.getEquivalentVGPRClass(VRC);
4231 get(TargetOpcode::COPY), NewSrcReg)
4238 get(AMDGPU::V_READFIRSTLANE_B32), DstReg)
4244 for (
unsigned i = 0; i < SubRegs; ++i) {
4247 get(AMDGPU::V_READFIRSTLANE_B32), SGPR)
4248 .
addReg(SrcReg, 0, RI.getSubRegFromChannel(i));
4254 get(AMDGPU::REG_SEQUENCE), DstReg);
4255 for (
unsigned i = 0; i < SubRegs; ++i) {
4257 MIB.
addImm(RI.getSubRegFromChannel(i));
4291 RI.getRegClassForReg(MRI, OpReg), OpSubReg);
4299 BuildMI(InsertMBB, I, DL,
get(AMDGPU::COPY), DstReg).
add(Op);
4313 while (!ImpDef && Def && Def->
isCopy()) {
4319 if (!RI.isSGPRClass(DstRC) && !Copy->
readsRegister(AMDGPU::EXEC, &RI) &&
4334 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
4335 unsigned SaveExecOpc =
4336 ST.
isWave32() ? AMDGPU::S_AND_SAVEEXEC_B32 : AMDGPU::S_AND_SAVEEXEC_B64;
4337 unsigned XorTermOpc =
4338 ST.
isWave32() ? AMDGPU::S_XOR_B32_term : AMDGPU::S_XOR_B64_term;
4340 ST.
isWave32() ? AMDGPU::S_AND_B32 : AMDGPU::S_AND_B64;
4341 const auto *BoolXExecRC = TRI->getRegClass(AMDGPU::SReg_1_XEXECRegClassID);
4359 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_READFIRSTLANE_B32), SRsrcSub0)
4360 .addReg(VRsrc, VRsrcUndef, AMDGPU::sub0);
4361 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_READFIRSTLANE_B32), SRsrcSub1)
4362 .addReg(VRsrc, VRsrcUndef, AMDGPU::sub1);
4363 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_READFIRSTLANE_B32), SRsrcSub2)
4364 .addReg(VRsrc, VRsrcUndef, AMDGPU::sub2);
4365 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_READFIRSTLANE_B32), SRsrcSub3)
4366 .addReg(VRsrc, VRsrcUndef, AMDGPU::sub3);
4368 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::REG_SEQUENCE), SRsrc)
4383 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_CMP_EQ_U64_e64), CondReg0)
4384 .addReg(SRsrc, 0, AMDGPU::sub0_sub1)
4385 .
addReg(VRsrc, 0, AMDGPU::sub0_sub1);
4386 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::V_CMP_EQ_U64_e64), CondReg1)
4387 .addReg(SRsrc, 0, AMDGPU::sub2_sub3)
4388 .
addReg(VRsrc, 0, AMDGPU::sub2_sub3);
4389 BuildMI(LoopBB, I, DL, TII.get(AndOpc), AndCond)
4396 BuildMI(LoopBB, I, DL, TII.get(SaveExecOpc), SaveExec)
4403 BuildMI(LoopBB, I, DL, TII.get(XorTermOpc), Exec)
4406 BuildMI(LoopBB, I, DL, TII.get(AMDGPU::S_CBRANCH_EXECNZ)).addMBB(&LoopBB);
4420 unsigned Exec = ST.
isWave32() ? AMDGPU::EXEC_LO : AMDGPU::EXEC;
4421 unsigned MovExecOpc = ST.
isWave32() ? AMDGPU::S_MOV_B32 : AMDGPU::S_MOV_B64;
4422 const auto *BoolXExecRC = TRI->getRegClass(AMDGPU::SReg_1_XEXECRegClassID);
4427 BuildMI(MBB, I, DL, TII.get(MovExecOpc), SaveExec).addReg(Exec);
4431 for (
auto &MO : MI.
uses()) {
4432 if (MO.isReg() && MO.isUse()) {
4445 MF.
insert(MBBI, RemainderBB);
4465 for (
auto &Succ : RemainderBB->
successors()) {
4476 BuildMI(*RemainderBB, First, DL, TII.get(MovExecOpc), Exec).addReg(SaveExec);
4480 static std::tuple<unsigned, unsigned>
4489 AMDGPU::sub0_sub1, &AMDGPU::VReg_64RegClass);
4504 .addImm(RsrcDataFormat & 0xFFFFFFFF);
4508 .addImm(RsrcDataFormat >> 32);
4513 .
addImm(AMDGPU::sub0_sub1)
4519 return std::make_tuple(RsrcPtr, NewSRsrc);
4556 if (RI.hasVectorRegisters(OpRC)) {
4570 VRC = &AMDGPU::VReg_1RegClass;
4573 ? RI.getEquivalentAGPRClass(SRC)
4574 : RI.getEquivalentVGPRClass(SRC);
4577 ? RI.getEquivalentAGPRClass(VRC)
4578 : RI.getEquivalentVGPRClass(VRC);
4604 if (MI.
getOpcode() == AMDGPU::REG_SEQUENCE) {
4607 if (RI.hasVGPRs(DstRC)) {
4631 if (MI.
getOpcode() == AMDGPU::INSERT_SUBREG) {
4636 if (DstRC != Src0RC) {
4645 if (MI.
getOpcode() == AMDGPU::SI_INIT_M0) {
4677 if (RsrcIdx != -1) {
4680 unsigned RsrcRC =
get(MI.
getOpcode()).OpInfo[RsrcIdx].RegClass;
4682 RI.getRegClass(RsrcRC))) {
4711 const auto *BoolXExecRC = RI.getRegClass(AMDGPU::SReg_1_XEXECRegClassID);
4715 unsigned RsrcPtr, NewSRsrc;
4720 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADD_I32_e64), NewVAddrLo)
4722 .
addReg(RsrcPtr, 0, AMDGPU::sub0)
4727 BuildMI(MBB, MI, DL,
get(AMDGPU::V_ADDC_U32_e64), NewVAddrHi)
4729 .
addReg(RsrcPtr, 0, AMDGPU::sub1)
4743 }
else if (!VAddr && ST.hasAddr64()) {
4748 "FIXME: Need to emit flat atomics here");
4750 unsigned RsrcPtr, NewSRsrc;
4777 MIB.
addImm(GLC->getImm());
4781 MIB.
addImm(DLC->getImm());
4788 MIB.
addImm(TFE->getImm());
4813 .
addReg(RsrcPtr, 0, AMDGPU::sub0)
4815 .
addReg(RsrcPtr, 0, AMDGPU::sub1)
4828 Worklist.
insert(&TopInst);
4830 while (!Worklist.
empty()) {
4842 case AMDGPU::S_ADD_U64_PSEUDO:
4843 case AMDGPU::S_SUB_U64_PSEUDO:
4844 splitScalar64BitAddSub(Worklist, Inst, MDT);
4847 case AMDGPU::S_ADD_I32:
4848 case AMDGPU::S_SUB_I32:
4850 if (moveScalarAddSub(Worklist, Inst, MDT))
4855 case AMDGPU::S_AND_B64:
4856 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_AND_B32, MDT);
4860 case AMDGPU::S_OR_B64:
4861 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_OR_B32, MDT);
4865 case AMDGPU::S_XOR_B64:
4866 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_XOR_B32, MDT);
4870 case AMDGPU::S_NAND_B64:
4871 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_NAND_B32, MDT);
4875 case AMDGPU::S_NOR_B64:
4876 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_NOR_B32, MDT);
4880 case AMDGPU::S_XNOR_B64:
4881 if (ST.hasDLInsts())
4882 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_XNOR_B32, MDT);
4884 splitScalar64BitXnor(Worklist, Inst, MDT);
4888 case AMDGPU::S_ANDN2_B64:
4889 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_ANDN2_B32, MDT);
4893 case AMDGPU::S_ORN2_B64:
4894 splitScalar64BitBinaryOp(Worklist, Inst, AMDGPU::S_ORN2_B32, MDT);
4898 case AMDGPU::S_NOT_B64:
4899 splitScalar64BitUnaryOp(Worklist, Inst, AMDGPU::S_NOT_B32);
4903 case AMDGPU::S_BCNT1_I32_B64:
4904 splitScalar64BitBCNT(Worklist, Inst);
4908 case AMDGPU::S_BFE_I64:
4909 splitScalar64BitBFE(Worklist, Inst);
4913 case AMDGPU::S_LSHL_B32:
4914 if (ST.hasOnlyRevVALUShifts()) {
4915 NewOpcode = AMDGPU::V_LSHLREV_B32_e64;
4919 case AMDGPU::S_ASHR_I32:
4920 if (ST.hasOnlyRevVALUShifts()) {
4921 NewOpcode = AMDGPU::V_ASHRREV_I32_e64;
4925 case AMDGPU::S_LSHR_B32:
4926 if (ST.hasOnlyRevVALUShifts()) {
4927 NewOpcode = AMDGPU::V_LSHRREV_B32_e64;
4931 case AMDGPU::S_LSHL_B64:
4932 if (ST.hasOnlyRevVALUShifts()) {
4933 NewOpcode = AMDGPU::V_LSHLREV_B64;
4937 case AMDGPU::S_ASHR_I64:
4938 if (ST.hasOnlyRevVALUShifts()) {
4939 NewOpcode = AMDGPU::V_ASHRREV_I64;
4943 case AMDGPU::S_LSHR_B64:
4944 if (ST.hasOnlyRevVALUShifts()) {
4945 NewOpcode = AMDGPU::V_LSHRREV_B64;
4950 case AMDGPU::S_ABS_I32:
4951 lowerScalarAbs(Worklist, Inst);
4955 case AMDGPU::S_CBRANCH_SCC0:
4956 case AMDGPU::S_CBRANCH_SCC1:
4970 case AMDGPU::S_BFE_U64:
4971 case AMDGPU::S_BFM_B64:
4974 case AMDGPU::S_PACK_LL_B32_B16:
4975 case AMDGPU::S_PACK_LH_B32_B16:
4976 case AMDGPU::S_PACK_HH_B32_B16:
4977 movePackToVALU(Worklist, MRI, Inst);
4981 case AMDGPU::S_XNOR_B32:
4982 lowerScalarXnor(Worklist, Inst);
4986 case AMDGPU::S_NAND_B32:
4987 splitScalarNotBinop(Worklist, Inst, AMDGPU::S_AND_B32);
4991 case AMDGPU::S_NOR_B32:
4992 splitScalarNotBinop(Worklist, Inst, AMDGPU::S_OR_B32);
4996 case AMDGPU::S_ANDN2_B32:
4997 splitScalarBinOpN2(Worklist, Inst, AMDGPU::S_AND_B32);
5001 case AMDGPU::S_ORN2_B32:
5002 splitScalarBinOpN2(Worklist, Inst, AMDGPU::S_OR_B32);
5007 if (NewOpcode == AMDGPU::INSTRUCTION_LIST_END) {
5026 addSCCDefUsersToVALUWorklist(Op, Inst, Worklist);
5031 if (Opcode == AMDGPU::S_SEXT_I32_I8 || Opcode == AMDGPU::S_SEXT_I32_I16) {
5034 unsigned Size = (Opcode == AMDGPU::S_SEXT_I32_I8) ? 8 : 16;
5038 }
else if (Opcode == AMDGPU::S_BCNT1_I32_B32) {
5047 if (Opcode == AMDGPU::S_BFE_I32 || Opcode == AMDGPU::S_BFE_U32) {
5052 "Scalar BFE is only implemented for constant width and offset");
5056 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
5063 unsigned NewDstReg = AMDGPU::NoRegister;
5083 addUsersToMoveToVALUWorklist(DstReg, MRI, Worklist);
5093 Inst.
setDesc(
get(AMDGPU::IMPLICIT_DEF));
5105 addUsersToMoveToVALUWorklist(NewDstReg, MRI, Worklist);
5112 if (ST.hasAddNoCarry()) {
5124 assert(Opc == AMDGPU::S_ADD_I32 || Opc == AMDGPU::S_SUB_I32);
5126 unsigned NewOpc = Opc == AMDGPU::S_ADD_I32 ?
5127 AMDGPU::V_ADD_U32_e64 : AMDGPU::V_SUB_U32_e64;
5138 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5157 unsigned SubOp = ST.hasAddNoCarry() ?
5158 AMDGPU::V_SUB_U32_e32 : AMDGPU::V_SUB_I32_e32;
5160 BuildMI(MBB, MII, DL,
get(SubOp), TmpReg)
5164 BuildMI(MBB, MII, DL,
get(AMDGPU::V_MAX_I32_e64), ResultReg)
5169 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5183 if (ST.hasDLInsts()) {
5188 BuildMI(MBB, MII, DL,
get(AMDGPU::V_XNOR_B32_e64), NewDest)
5193 addUsersToMoveToVALUWorklist(NewDest, MRI, Worklist);
5199 bool Src0IsSGPR = Src0.
isReg() &&
5201 bool Src1IsSGPR = Src1.
isReg() &&
5211 BuildMI(MBB, MII, DL,
get(AMDGPU::S_NOT_B32), Temp).
add(Src0);
5212 Xor =
BuildMI(MBB, MII, DL,
get(AMDGPU::S_XOR_B32), NewDest)
5215 }
else if (Src1IsSGPR) {
5216 BuildMI(MBB, MII, DL,
get(AMDGPU::S_NOT_B32), Temp).
add(Src1);
5217 Xor =
BuildMI(MBB, MII, DL,
get(AMDGPU::S_XOR_B32), NewDest)
5221 Xor =
BuildMI(MBB, MII, DL,
get(AMDGPU::S_XOR_B32), Temp)
5225 BuildMI(MBB, MII, DL,
get(AMDGPU::S_NOT_B32), NewDest).
addReg(Temp);
5233 addUsersToMoveToVALUWorklist(NewDest, MRI, Worklist);
5237 void SIInstrInfo::splitScalarNotBinop(
SetVectorType &Worklist,
5239 unsigned Opcode)
const {
5263 addUsersToMoveToVALUWorklist(NewDest, MRI, Worklist);
5266 void SIInstrInfo::splitScalarBinOpN2(
SetVectorType& Worklist,
5268 unsigned Opcode)
const {
5292 addUsersToMoveToVALUWorklist(NewDest, MRI, Worklist);
5295 void SIInstrInfo::splitScalar64BitUnaryOp(
5297 unsigned Opcode)
const {
5310 &AMDGPU::SGPR_32RegClass;
5315 AMDGPU::sub0, Src0SubRC);
5325 AMDGPU::sub1, Src0SubRC);
5331 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
5339 Worklist.
insert(&LoHalf);
5340 Worklist.
insert(&HiHalf);
5346 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
5349 void SIInstrInfo::splitScalar64BitAddSub(
SetVectorType &Worklist,
5352 bool IsAdd = (Inst.
getOpcode() == AMDGPU::S_ADD_U64_PSEUDO);
5356 const auto *CarryRC = RI.
getRegClass(AMDGPU::SReg_1_XEXECRegClassID);
5377 AMDGPU::sub0, Src0SubRC);
5379 AMDGPU::sub0, Src1SubRC);
5383 AMDGPU::sub1, Src0SubRC);
5385 AMDGPU::sub1, Src1SubRC);
5387 unsigned LoOpc = IsAdd ? AMDGPU::V_ADD_I32_e64 : AMDGPU::V_SUB_I32_e64;
5389 BuildMI(MBB, MII, DL,
get(LoOpc), DestSub0)
5395 unsigned HiOpc = IsAdd ? AMDGPU::V_ADDC_U32_e64 : AMDGPU::V_SUBB_U32_e64;
5397 BuildMI(MBB, MII, DL,
get(HiOpc), DestSub1)
5404 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
5418 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
5421 void SIInstrInfo::splitScalar64BitBinaryOp(
SetVectorType &Worklist,
5437 &AMDGPU::SGPR_32RegClass;
5442 &AMDGPU::SGPR_32RegClass;
5447 AMDGPU::sub0, Src0SubRC);
5449 AMDGPU::sub0, Src1SubRC);
5451 AMDGPU::sub1, Src0SubRC);
5453 AMDGPU::sub1, Src1SubRC);
5470 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), FullDestReg)
5478 Worklist.
insert(&LoHalf);
5479 Worklist.
insert(&HiHalf);
5482 addUsersToMoveToVALUWorklist(FullDestReg, MRI, Worklist);
5485 void SIInstrInfo::splitScalar64BitXnor(
SetVectorType &Worklist,
5505 if (Src0.
isReg() && RI.isSGPRReg(MRI, Src0.
getReg())) {
5513 BuildMI(MBB, MII, DL,
get(AMDGPU::S_NOT_B64), Interm)
5527 void SIInstrInfo::splitScalar64BitBCNT(
5538 const MCInstrDesc &InstDesc =
get(AMDGPU::V_BCNT_U32_B32_e64);
5541 &AMDGPU::SGPR_32RegClass;
5549 AMDGPU::sub0, SrcSubRC);
5551 AMDGPU::sub1, SrcSubRC);
5561 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5564 void SIInstrInfo::splitScalar64BitBFE(
SetVectorType &Worklist,
5574 uint32_t BitWidth = (Imm & 0x7f0000) >> 16;
5580 Offset == 0 &&
"Not implemented");
5582 if (BitWidth < 32) {
5587 BuildMI(MBB, MII, DL,
get(AMDGPU::V_BFE_I32), MidRegLo)
5592 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e32), MidRegHi)
5596 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
5603 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5611 BuildMI(MBB, MII, DL,
get(AMDGPU::V_ASHRREV_I32_e64), TmpReg)
5615 BuildMI(MBB, MII, DL,
get(TargetOpcode::REG_SEQUENCE), ResultReg)
5617 .addImm(AMDGPU::sub0)
5622 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5625 void SIInstrInfo::addUsersToMoveToVALUWorklist(
5638 case AMDGPU::SOFT_WQM:
5640 case AMDGPU::REG_SEQUENCE:
5642 case AMDGPU::INSERT_SUBREG:
5645 OpNo =
I.getOperandNo();
5654 }
while (
I !=
E &&
I->getParent() == &
UseMI);
5671 case AMDGPU::S_PACK_LL_B32_B16: {
5677 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
5680 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_B32_e64), TmpReg)
5684 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHL_OR_B32), ResultReg)
5690 case AMDGPU::S_PACK_LH_B32_B16: {
5692 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
5694 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_BFI_B32), ResultReg)
5700 case AMDGPU::S_PACK_HH_B32_B16: {
5703 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_LSHRREV_B32_e64), TmpReg)
5706 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_MOV_B32_e32), ImmReg)
5708 BuildMI(*MBB, Inst, DL,
get(AMDGPU::V_AND_OR_B32), ResultReg)
5720 addUsersToMoveToVALUWorklist(ResultReg, MRI, Worklist);
5735 if (
MI.findRegisterUseOperandIdx(AMDGPU::SCC,
false, &RI) != -1)
5738 if (
MI.findRegisterDefOperandIdx(AMDGPU::SCC,
false,
false, &RI) != -1)
5753 case AMDGPU::REG_SEQUENCE:
5754 case AMDGPU::INSERT_SUBREG:
5756 case AMDGPU::SOFT_WQM:
5759 if (RI.hasAGPRs(SrcRC)) {
5760 if (RI.hasAGPRs(NewDstRC))
5765 case AMDGPU::REG_SEQUENCE:
5766 case AMDGPU::INSERT_SUBREG:
5767 NewDstRC = RI.getEquivalentAGPRClass(NewDstRC);
5770 NewDstRC = RI.getEquivalentVGPRClass(NewDstRC);
5776 if (RI.hasVGPRs(NewDstRC) || NewDstRC == &AMDGPU::VReg_1RegClass)
5779 NewDstRC = RI.getEquivalentVGPRClass(NewDstRC);
5793 int OpIndices[3])
const {
5806 if (SGPRReg != AMDGPU::NoRegister)
5809 unsigned UsedSGPRs[3] = { AMDGPU::NoRegister };
5812 for (
unsigned i = 0; i < 3; ++i) {
5813 int Idx = OpIndices[i];
5824 bool IsRequiredSGPR = RI.isSGPRClass(OpRC);
5831 if (RI.isSGPRClass(RegRC))
5848 if (UsedSGPRs[0] != AMDGPU::NoRegister) {
5849 if (UsedSGPRs[0] == UsedSGPRs[1] || UsedSGPRs[0] == UsedSGPRs[2])
5850 SGPRReg = UsedSGPRs[0];
5853 if (SGPRReg == AMDGPU::NoRegister && UsedSGPRs[1] != AMDGPU::NoRegister) {
5854 if (UsedSGPRs[1] == UsedSGPRs[2])
5855 SGPRReg = UsedSGPRs[1];
5862 unsigned OperandName)
const {
5872 return (22ULL << 44) |
5878 if (ST.isAmdHsaOS()) {
5881 RsrcDataFormat |= (1ULL << 56);
5886 RsrcDataFormat |= (2ULL << 59);
5889 return RsrcDataFormat;
5899 uint64_t EltSizeValue =
Log2_32(ST.getMaxPrivateElementSize()) - 1;
5904 uint64_t IndexStride = ST.getWavefrontSize() == 64 ? 3 : 2;
5931 if (!Addr || !Addr->
isFI())
5932 return AMDGPU::NoRegister;
5952 return AMDGPU::NoRegister;
5960 return AMDGPU::NoRegister;
5966 return AMDGPU::NoRegister;
5974 return AMDGPU::NoRegister;
5981 while (++I != E && I->isInsideBundle()) {
5982 assert(!I->isBundle() &&
"No nested bundle!");
5992 unsigned DescSize = Desc.
getSize();
6007 return isVOP3(MI) ? 12 : (DescSize + 4);
6014 return isVOP3(MI) ? 12 : (DescSize + 4);
6021 return isVOP3(MI) ? 12 : (DescSize + 4);
6033 return 8 + 4 * ((RSrcIdx - VAddr0Idx + 2) / 4);
6037 case TargetOpcode::IMPLICIT_DEF:
6039 case TargetOpcode::DBG_VALUE:
6042 case TargetOpcode::BUNDLE:
6071 return Branch.
getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO;
6083 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
6086 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_IF), DstReg)
6087 .
add(Branch->getOperand(0))
6088 .
add(Branch->getOperand(1));
6090 BuildMI(*MF, Branch->getDebugLoc(),
get(AMDGPU::SI_END_CF))
6109 if (Branch->getOpcode() == AMDGPU::SI_NON_UNIFORM_BRCOND_PSEUDO) {
6114 BuildMI(*(MF), Branch->getDebugLoc(),
get(TargetOpcode::PHI), DstReg);
6118 if (*PI == LoopEnd) {
6119 HeaderPHIBuilder.
addReg(BackEdgeReg);
6125 HeaderPHIBuilder.
addReg(ZeroReg);
6127 HeaderPHIBuilder.
addMBB(*PI);
6131 get(AMDGPU::SI_IF_BREAK), BackEdgeReg)
6133 .
add(Branch->getOperand(0));
6135 BuildMI(*(MF), Branch->getDebugLoc(),
get(AMDGPU::SI_LOOP))
6141 LoopEnd->
insert(LoopEnd->
end(), SIIFBREAK);
6142 LoopEnd->
insert(LoopEnd->
end(), SILOOP);
6148 static const std::pair<int, const char *> TargetIndices[] = {
6172 std::pair<unsigned, unsigned>
6174 return std::make_pair(TF &
MO_MASK, TF & ~MO_MASK);
6179 static const std::pair<unsigned, const char *> TargetFlags[] = {
6201 unsigned DestReg)
const {
6202 if (ST.hasAddNoCarry())
6203 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_U32_e64), DestReg);
6209 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_I32_e64), DestReg)
6218 if (ST.hasAddNoCarry())
6219 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_U32_e32), DestReg);
6230 return BuildMI(MBB, I, DL,
get(AMDGPU::V_ADD_I32_e64), DestReg)
6236 case AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR:
6237 case AMDGPU::SI_KILL_I1_TERMINATOR:
6246 case AMDGPU::SI_KILL_F32_COND_IMM_PSEUDO:
6247 return get(AMDGPU::SI_KILL_F32_COND_IMM_TERMINATOR);
6248 case AMDGPU::SI_KILL_I1_PSEUDO:
6249 return get(AMDGPU::SI_KILL_I1_TERMINATOR);
6265 Op.
setReg(AMDGPU::VCC_LO);
6279 return RI.getRegClass(RCID)->hasSubClassEq(&AMDGPU::SGPR_128RegClass);
6284 if (!ST.hasFlatInstOffsets())
6291 return Signed ? 12 : 11;
6293 return Signed ? 13 : 12;
6299 if (!ST.hasFlatInstOffsets())
6306 return (Signed && isInt<12>(Offset)) ||
6307 (!Signed && isUInt<11>(Offset));
6310 return (Signed && isInt<13>(Offset)) ||
6311 (!Signed && isUInt<12>(Offset));
6349 case AMDGPU::V_MOVRELS_B32_dpp_gfx10:
6350 case AMDGPU::V_MOVRELS_B32_sdwa_gfx10:
6351 case AMDGPU::V_MOVRELD_B32_dpp_gfx10:
6352 case AMDGPU::V_MOVRELD_B32_sdwa_gfx10:
6353 case AMDGPU::V_MOVRELSD_B32_dpp_gfx10:
6354 case AMDGPU::V_MOVRELSD_B32_sdwa_gfx10:
6355 case AMDGPU::V_MOVRELSD_2_B32_dpp_gfx10:
6356 case AMDGPU::V_MOVRELSD_2_B32_sdwa_gfx10:
6377 switch (ST.getGeneration()) {
6433 case AMDGPU::REG_SEQUENCE:
6437 case AMDGPU::INSERT_SUBREG:
6460 while (
auto *MI = DefInst) {
6464 case AMDGPU::V_MOV_B32_e32: {
6501 const int MaxInstScan = 20;
6507 if (
I->isDebugInstr())
6510 if (++NumInst > MaxInstScan)
6513 if (
I->modifiesRegister(AMDGPU::EXEC, TRI))
6528 const int MaxUseInstScan = 10;
6534 if (UseInst.getParent() != DefBB)
6537 if (++NumUseInst > MaxUseInstScan)
6541 const int MaxInstScan = 20;
6546 if (
I->isDebugInstr())
6549 if (++NumInst > MaxInstScan)
6552 if (
I->readsRegister(VReg))
6553 if (--NumUseInst == 0)
6556 if (
I->modifiesRegister(AMDGPU::EXEC, TRI))
6564 auto Cur = MBB.
begin();
6565 if (Cur != MBB.
end())
6567 if (!Cur->isPHI() && Cur->readsRegister(Dst))
6568 return BuildMI(MBB, Cur, DL,
get(TargetOpcode::COPY), Dst).addReg(Src);
6570 }
while (Cur != MBB.
end() && Cur != LastPHIIt);
6579 if (InsPt != MBB.
end() &&
6580 (InsPt->getOpcode() == AMDGPU::SI_IF ||
6581 InsPt->getOpcode() == AMDGPU::SI_ELSE ||
6582 InsPt->getOpcode() == AMDGPU::SI_IF_BREAK) &&
6583 InsPt->definesRegister(Src)) {
6585 return BuildMI(MBB, InsPt, DL,
6586 get(ST.isWave32() ? AMDGPU::S_MOV_B32_term
6587 : AMDGPU::S_MOV_B64_term),
6589 .
addReg(Src, 0, SrcSubReg)
6617 if (DstReg == AMDGPU::M0 && SrcReg.
isVirtual()) {
6622 if (SrcReg == AMDGPU::M0 && DstReg.
isVirtual()) {
6633 unsigned *PredCost)
const {
6637 unsigned Lat = 0, Count = 0;
6638 for (++
I;
I !=
E &&
I->isBundledWithPred(); ++
I) {
6640 Lat =
std::max(Lat, SchedModel.computeInstrLatency(&*
I));
6642 return Lat + Count - 1;
6645 return SchedModel.computeInstrLatency(&MI);
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
TargetInstrInfo::RegSubRegPair getRegSequenceSubReg(MachineInstr &MI, unsigned SubReg)
Return the SubReg component from REG_SEQUENCE.
static unsigned getAGPRSpillRestoreOpcode(unsigned Size)
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool hasVOP3Literal() const
A parsed version of the target data layout string in and methods for querying it. ...
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.
static void copyFlagsToImplicitVCC(MachineInstr &MI, const MachineOperand &Orig)
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 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 isCall(QueryType Type=AnyInBundle) const
Wrapper class representing physical registers. Should be passed by value.
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
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
LLVM_NODISCARD T pop_back_val()
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
MachineInstr * getVRegSubRegDef(const TargetInstrInfo::RegSubRegPair &P, MachineRegisterInfo &MRI)
Return the defining instruction for a given reg:subreg pair skipping copy like instructions and subre...
static bool sopkIsZext(const MachineInstr &MI)
uint64_t getDefaultRsrcDataFormat() const
MachineInstr * createPHISourceCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, unsigned SrcSubReg, Register Dst) const override
unsigned getStackPtrOffsetReg() const
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.
bool isCommutable() 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 getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const override
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getMaxFlatWorkGroupSize() const
bool canInsertSelect(const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const override
Operand with 32-bit immediate that uses the constant bus.
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
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool hasModifiersSet(const MachineInstr &MI, unsigned OpName) const
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
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.
void setIsUndef(bool Val=true)
unsigned insertNE(MachineBasicBlock *MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned SrcReg, int Value) const
unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const override
void transferSuccessorsAndUpdatePHIs(MachineBasicBlock *FromMBB)
Transfers all the successors, as in transferSuccessors, and update PHI operands in the successor bloc...
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
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
bool isRegSequence() const
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
static std::tuple< unsigned, unsigned > extractRsrcPtr(const SIInstrInfo &TII, MachineInstr &MI, MachineOperand &Rsrc)
int64_t getNamedImmOperand(const MachineInstr &MI, unsigned OpName) const
Get required immediate operand.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
MachineBasicBlock reference.
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
bool isAGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
bool isInlinableLiteralV216(int32_t Literal, bool HasInv2Pi)
bool isMetaInstruction() const
Return true if this instruction doesn't produce any output in the form of executable instructions...
bool isCopyLike() const
Return true if the instruction behaves like a copy.
bool isInlineConstant(const APInt &Imm) const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static bool isSOPC(const MachineInstr &MI)
bool hasAnyModifiersSet(const MachineInstr &MI) const
Address space for flat memory.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) 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).
void legalizeOperands(MachineInstr &MI, MachineDominatorTree *MDT=nullptr) const
Legalize all operands in this instruction.
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...
bool isBranch() const
Returns true if this is a conditional, unconditional, or indirect branch.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< succ_iterator > successors()
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
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()
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.
bool isAlwaysGDS(uint16_t Opcode) const
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
Retuns the total number of operands.
static bool isGather4(const MachineInstr &MI)
bool isEntryFunction() const
static bool isMIMG(const MachineInstr &MI)
A Use represents the edge between a Value definition and its users.
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
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...
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
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 getID() const
Return the register class ID number.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
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 setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
void forward()
Move the internal MBB iterator and update register states.
uint8_t OperandType
Information about the type of the operand.
void ashrInPlace(unsigned ShiftAmt)
Arithmetic right-shift this APInt by ShiftAmt in place.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr &MI, unsigned *PredCost=nullptr) const override
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 opCanUseInlineConstant(unsigned OpType) const
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...
static bool followSubRegDef(MachineInstr &MI, TargetInstrInfo::RegSubRegPair &RSR)
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
bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
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.
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
void untieRegOperand(unsigned OpIdx)
Break any tie involving OpIdx.
static unsigned findImplicitSGPRRead(const MachineInstr &MI)
bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
void setReg(Register Reg)
Change the register this operand corresponds to.
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.
unsigned getUndefRegState(bool B)
MachineBasicBlock * CreateMachineBasicBlock(const BasicBlock *bb=nullptr)
CreateMachineBasicBlock - Allocate a new MachineBasicBlock.
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...
Analysis containing CSE Info
BasicBlockListType::iterator iterator
unsigned getKillRegState(bool B)
bool execMayBeModifiedBeforeUse(const MachineRegisterInfo &MRI, Register VReg, const MachineInstr &DefMI, const MachineInstr &UseMI)
Return false if EXEC is not changed between the def of VReg at DefMI and the use at UseMI...
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
bool isReturn(QueryType Type=AnyInBundle) const
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
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.
virtual MachineInstr * createPHIDestinationCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, Register Dst) const
During PHI eleimination lets target to make necessary checks and insert the copy to the PHI destinati...
initializer< Ty > init(const Ty &Val)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
This file declares the machine register scavenger class.
const TargetRegisterInfo * getTargetRegisterInfo() const
unsigned const MachineRegisterInfo * MRI
const MCInstrDesc & getKillTerminatorFromPseudo(unsigned Opcode) const
bool isFoldableCopy(const MachineInstr &MI) const
bool isPreISelOpcode(QueryType Type=IgnoreBundle) const
Return true if this is an instruction that should go through the usual legalization steps...
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 hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
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.
virtual MachineInstr * createPHISourceCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, unsigned SrcSubReg, Register Dst) const
During PHI eleimination lets target to make necessary checks and insert the copy to the PHI destinati...
bool isVariadic() const
Return true if this instruction can have a variable number of operands.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineInstrBuilder & UseMI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static TargetInstrInfo::RegSubRegPair getRegOrUndef(const MachineOperand &RegOpnd)
void fixImplicitOperands(MachineInstr &MI) const
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...
bool isRegUsed(Register Reg, bool includeReserved=true) const
Return if a specific register is currently used.
static unsigned getSGPRSpillRestoreOpcode(unsigned Size)
bool isSchedulingBoundary(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
std::pair< iterator, bool > insert(const ValueT &V)
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 canShrink(const MachineInstr &MI, const MachineRegisterInfo &MRI) const
bool expandPostRAPseudo(MachineInstr &MI) const override
bool hasVGPRs(const TargetRegisterClass *RC) const
static unsigned getNumOperandsNoGlue(SDNode *Node)
static void removeModOperands(MachineInstr &MI)
void insertReturn(MachineBasicBlock &MBB) const
LLVM_READONLY int getIfAddr64Inst(uint16_t Opcode)
Check if Opcode is an Addr64 opcode.
LLVM_READONLY int commuteOpcode(unsigned Opc) const
bool hasRegisterImplicitUseOperand(Register Reg) const
Returns true if the MachineInstr has an implicit-use operand of exactly the given register (not consi...
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)
bool isTargetSpecificOpcode(unsigned Opcode)
Check whether the given Opcode is a target-specific opcode.
std::pair< MachineInstr *, MachineInstr * > expandMovDPP64(MachineInstr &MI) const
static bool isSOP2(const MachineInstr &MI)
Generation getGeneration() const
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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).
static void reportIllegalCopy(const SIInstrInfo *TII, MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc)
unsigned insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &NewDestBB, const DebugLoc &DL, int64_t BrOffset, RegScavenger *RS=nullptr) const override
std::vector< MachineBasicBlock * >::iterator pred_iterator
const MachineInstrBuilder & addFrameIndex(int Idx) const
static unsigned getVGPRSpillRestoreOpcode(unsigned Size)
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static bool isVOP2(const MachineInstr &MI)
static MachineOperand CreateReg(Register 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)
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
bool isImplicitDef() const
static unsigned getNumWaitStates(const MachineInstr &MI)
Return the number of wait states that result from executing this instruction.
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()
bool getMemOperandWithOffset(const MachineInstr &LdSt, const MachineOperand *&BaseOp, int64_t &Offset, const TargetRegisterInfo *TRI) const final
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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 hasUnpackedD16VMem() const
bool mayReadEXEC(const MachineRegisterInfo &MRI, const MachineInstr &MI) const
Returns true if the instruction could potentially depend on the value of exec.
bool FoldImmediate(MachineInstr &UseMI, MachineInstr &DefMI, unsigned Reg, MachineRegisterInfo *MRI) const final
The memory access writes data.
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, AAResults *AA) const override
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static bool isUndef(ArrayRef< int > Mask)
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
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.
unsigned countPopulation(T Value)
Count the number of set bits in a value.
void addSuccessor(MachineBasicBlock *Succ, BranchProbability Prob=BranchProbability::getUnknown())
Add Succ as a successor of this MachineBasicBlock.
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.
MachineInstr * createPHIDestinationCopy(MachineBasicBlock &MBB, MachineBasicBlock::iterator InsPt, const DebugLoc &DL, Register Src, Register Dst) const override
Align max(MaybeAlign Lhs, Align Rhs)
LLVM_READONLY int getVOPe32(uint16_t Opcode)
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
TargetInstrInfo::RegSubRegPair getRegSubRegPair(const MachineOperand &O)
Create RegSubRegPair from a register MachineOperand.
bool hasAGPRs(const TargetRegisterClass *RC) const
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 uint64_t add(uint64_t LeftOp, uint64_t RightOp)
static bool isSALU(const MachineInstr &MI)
MachineOperand class - Representation of each machine instruction operand.
Operands with register or 32-bit immediate.
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 hasMFMAInlineLiteralBug() const
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
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
Promote Memory to Register
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...
bool properlyDominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
bool shouldClusterMemOps(const MachineOperand &BaseOp1, const MachineOperand &BaseOp2, unsigned NumLoads) const override
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
Implements a dense probed hash-table based set with some number of buckets stored inline...
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 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)
bool hasModifiers(unsigned Opcode) const
Return true if this instruction has any modifiers.
static bool memOpsHaveSameBasePtr(const MachineInstr &MI1, const MachineOperand &BaseOp1, const MachineInstr &MI2, const MachineOperand &BaseOp2)
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)
Register scavengeRegisterBackwards(const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available from the current position backwards to the p...
bool execMayBeModifiedBeforeAnyUse(const MachineRegisterInfo &MRI, Register VReg, const MachineInstr &DefMI)
Return false if EXEC is not changed between the def of VReg at DefMI and all its uses.
static bool isVOP3(const MachineInstr &MI)
bool isAsmOnlyOpcode(int MCOp) const
Check if this instruction should only be used by assembler.
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.
unsigned getNumFlatOffsetBits(unsigned AddrSpace, bool Signed) const
Provides AMDGPU specific target descriptions.
static bool compareMachineOp(const MachineOperand &Op0, const MachineOperand &Op1)
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
bool hasInv2PiInlineImm() const
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.
const TargetRegisterClass * getBoolRC() 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)
Register scavengeRegister(const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available and do the appropriate bookkeeping.
void moveToVALU(MachineInstr &MI, MachineDominatorTree *MDT=nullptr) const
Replace this instruction's opcode with the equivalent VALU opcode.
bool hasOneUse(unsigned RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
bool 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.
Register FindUnusedReg(const TargetRegisterClass *RC) const
Find an unused register of the specified register class.
This file provides utility analysis objects describing memory locations.
static bool isMAI(const MachineInstr &MI)
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.
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
void ChangeToRegister(Register 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...
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.
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
static void emitLoadSRsrcFromVGPRLoop(const SIInstrInfo &TII, MachineRegisterInfo &MRI, MachineBasicBlock &OrigBB, MachineBasicBlock &LoopBB, const DebugLoc &DL, MachineOperand &Rsrc)
Operands with register or inline constant.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Abstract Stack Frame Index.
Address space for private memory.
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
constexpr bool isUInt< 16 >(uint64_t x)
void setSimpleHint(unsigned VReg, unsigned PrefReg)
Specify the preferred (target independent) register allocation hint for the specified virtual registe...
bool spillSGPRToVGPR() const
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. ...
void changeImmediateDominator(MachineBasicBlock *N, MachineBasicBlock *NewIDom)
changeImmediateDominator - This method is used to update the dominator tree information when a node's...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
SIInstrInfo(const GCNSubtarget &ST)
bool hasSDWAScalar() const
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr, VirtRegMap *VRM=nullptr) const override
static void preserveCondRegFlags(MachineOperand &CondReg, const MachineOperand &OrigCond)
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo)
Can this operand also contain immediate values?
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 insert(iterator MBBI, MachineBasicBlock *MBB)
void legalizeOperandsSMRD(MachineRegisterInfo &MRI, MachineInstr &MI) const
INLINEASM_BR - Terminator version of inline asm. Used by asm-goto.
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)
const TargetRegisterClass * getRegClass(unsigned RCID) const
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.
static bool isVGPRSpill(const MachineInstr &MI)
const TargetRegisterClass * getPhysRegClass(unsigned Reg) const
Return the 'base' register class for this register.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
const MCOperandInfo * OpInfo
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 findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
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
bool isLegalFLATOffset(int64_t Offset, unsigned AddrSpace, bool Signed) const
Returns if Offset is legal for the subtarget as the offset to a FLAT encoded instruction.
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.
unsigned getConstantBusLimit(unsigned Opcode) const
static void loadSRsrcFromVGPR(const SIInstrInfo &TII, MachineInstr &MI, MachineOperand &Rsrc, MachineDominatorTree *MDT)
void legalizeGenericOperand(MachineBasicBlock &InsertMBB, MachineBasicBlock::iterator I, const TargetRegisterClass *DstRC, MachineOperand &Op, MachineRegisterInfo &MRI, const DebugLoc &DL) const
Register getReg() const
getReg - Returns the register number.
Operands with an AccVGPR register or inline constant.
static bool isKillTerminator(unsigned Opcode)
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
MachineDomTreeNode * addNewBlock(MachineBasicBlock *BB, MachineBasicBlock *DomBB)
addNewBlock - Add a new node to the dominator tree information.
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(unsigned Reg) const
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
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 unsigned getAGPRSpillSaveOpcode(unsigned Size)
static bool isVOP1(const MachineInstr &MI)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
MachineInstr * buildShrunkInst(MachineInstr &MI, unsigned NewOpcode) const
void convertNonUniformIfRegion(MachineBasicBlock *IfEntry, MachineBasicBlock *IfEnd) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
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.
Address space for constant memory (VTX2).
static cl::opt< unsigned > BranchOffsetBits("amdgpu-s-branch-bits", cl::ReallyHidden, cl::init(16), cl::desc("Restrict range of branch instructions (DEBUG)"))
Wrapper class representing virtual and physical registers.
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...
Register getPreloadedReg(AMDGPUFunctionArgInfo::PreloadedValue Value) const
const SIRegisterInfo * getRegisterInfo() const override