38 #define DEBUG_TYPE "amdgpu-isel" 41 using namespace MIPatternMatch;
43 #define GET_GLOBALISEL_IMPL 44 #define AMDGPUSubtarget GCNSubtarget 45 #include "AMDGPUGenGlobalISel.inc" 46 #undef GET_GLOBALISEL_IMPL 47 #undef AMDGPUSubtarget 53 TRI(*STI.getRegisterInfo()), RBI(RBI), TM(TM),
57 #include
"AMDGPUGenGlobalISel.inc" 60 #include
"AMDGPUGenGlobalISel.inc" 76 return Reg == TRI.
getVCC();
88 return RB->
getID() == AMDGPU::VCCRegBankID;
91 bool AMDGPUInstructionSelector::selectCOPY(
MachineInstr &
I)
const {
94 I.
setDesc(TII.get(TargetOpcode::COPY));
101 if (isVCC(DstReg, *MRI)) {
102 if (SrcReg == AMDGPU::SCC) {
110 if (!isVCC(SrcReg, *MRI)) {
125 AMDGPU::S_AND_B32 : AMDGPU::V_AND_B32_e32;
126 BuildMI(*BB, &I, DL, TII.get(AndOpc), MaskedReg)
129 BuildMI(*BB, &I, DL, TII.get(AMDGPU::V_CMP_NE_U32_e64), DstReg)
173 bool AMDGPUInstructionSelector::selectPHI(
MachineInstr &I)
const {
199 I.
setDesc(TII.get(TargetOpcode::PHI));
206 unsigned SubIdx)
const {
213 unsigned ComposedSubIdx = TRI.composeSubRegIndices(MO.
getSubReg(), SubIdx);
216 .addReg(Reg, 0, ComposedSubIdx);
241 return Is64 ? AMDGPU::S_AND_B64 : AMDGPU::S_AND_B32;
243 return Is64 ? AMDGPU::S_OR_B64 : AMDGPU::S_OR_B32;
245 return Is64 ? AMDGPU::S_XOR_B64 : AMDGPU::S_XOR_B32;
251 bool AMDGPUInstructionSelector::selectG_AND_OR_XOR(
MachineInstr &I)
const {
256 unsigned Size = RBI.getSizeInBits(DstReg, *MRI, TRI);
259 if (DstRB->
getID() == AMDGPU::VCCRegBankID) {
262 RC == &AMDGPU::SReg_64RegClass);
279 if (DstRB->
getID() == AMDGPU::SGPRRegBankID) {
293 bool AMDGPUInstructionSelector::selectG_ADD_SUB(
MachineInstr &I)
const {
298 unsigned Size = RBI.getSizeInBits(DstReg, *MRI, TRI);
300 const bool IsSALU = DstRB->
getID() == AMDGPU::SGPRRegBankID;
301 const bool Sub = I.
getOpcode() == TargetOpcode::G_SUB;
305 const unsigned Opc = Sub ? AMDGPU::S_SUB_U32 : AMDGPU::S_ADD_U32;
307 BuildMI(*BB, &I, DL, TII.get(Opc), DstReg)
315 const unsigned Opc = Sub ? AMDGPU::V_SUB_U32_e64 : AMDGPU::V_ADD_U32_e64;
322 const unsigned Opc = Sub ? AMDGPU::V_SUB_I32_e64 : AMDGPU::V_ADD_I32_e64;
326 =
BuildMI(*BB, &I, DL, TII.get(Opc), DstReg)
335 assert(!Sub &&
"illegal sub should not reach here");
338 = IsSALU ? AMDGPU::SReg_64_XEXECRegClass : AMDGPU::VReg_64RegClass;
340 = IsSALU ? AMDGPU::SReg_32RegClass : AMDGPU::VGPR_32RegClass;
351 BuildMI(*BB, &I, DL, TII.get(AMDGPU::S_ADD_U32), DstLo)
354 BuildMI(*BB, &I, DL, TII.get(AMDGPU::S_ADDC_U32), DstHi)
360 BuildMI(*BB, &I, DL, TII.get(AMDGPU::V_ADD_I32_e64), DstLo)
376 BuildMI(*BB, &I, DL, TII.get(AMDGPU::REG_SEQUENCE), DstReg)
390 bool AMDGPUInstructionSelector::selectG_UADDO_USUBO_UADDE_USUBE(
397 const bool IsAdd = I.
getOpcode() == AMDGPU::G_UADDO ||
399 const bool HasCarryIn = I.
getOpcode() == AMDGPU::G_UADDE ||
402 if (isVCC(Dst1Reg, *MRI)) {
406 unsigned NoCarryOpc = IsAdd ? AMDGPU::V_ADD_I32_e64 : AMDGPU::V_SUB_I32_e64;
407 unsigned CarryOpc = IsAdd ? AMDGPU::V_ADDC_U32_e64 : AMDGPU::V_SUBB_U32_e64;
408 I.
setDesc(TII.get(HasCarryIn ? CarryOpc : NoCarryOpc));
418 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), AMDGPU::SCC)
422 unsigned NoCarryOpc = IsAdd ? AMDGPU::S_ADD_U32 : AMDGPU::S_SUB_U32;
423 unsigned CarryOpc = IsAdd ? AMDGPU::S_ADDC_U32 : AMDGPU::S_SUBB_U32;
425 BuildMI(*BB, &I, DL, TII.get(HasCarryIn ? CarryOpc : NoCarryOpc), Dst0Reg)
428 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), Dst1Reg)
429 .addReg(AMDGPU::SCC);
432 MRI->
setRegClass(Dst1Reg, &AMDGPU::SReg_32RegClass);
441 AMDGPU::SReg_32RegClass, *MRI))
448 bool AMDGPUInstructionSelector::selectG_EXTRACT(
MachineInstr &I)
const {
459 if (Offset % DstSize != 0)
472 .addReg(SrcReg, 0, SubRegs[Offset / DstSize]);
485 bool AMDGPUInstructionSelector::selectG_MERGE_VALUES(
MachineInstr &
MI)
const {
505 BuildMI(*BB, &MI, DL, TII.get(TargetOpcode::REG_SEQUENCE), DstReg);
524 bool AMDGPUInstructionSelector::selectG_UNMERGE_VALUES(
MachineInstr &MI)
const {
551 for (
int I = 0,
E = NumDst; I !=
E; ++
I) {
553 BuildMI(*BB, &MI, DL, TII.get(TargetOpcode::COPY), Dst.
getReg())
554 .addReg(SrcReg, SrcFlags, SubRegs[I]);
566 bool AMDGPUInstructionSelector::selectG_PTR_ADD(
MachineInstr &I)
const {
567 return selectG_ADD_SUB(I);
570 bool AMDGPUInstructionSelector::selectG_IMPLICIT_DEF(
MachineInstr &I)
const {
578 I.
setDesc(TII.get(TargetOpcode::IMPLICIT_DEF));
585 bool AMDGPUInstructionSelector::selectG_INSERT(
MachineInstr &I)
const {
597 if (Offset % 32 != 0)
601 if (SubReg == AMDGPU::NoSubRegister)
619 Src0RC = TRI.getSubClassWithSubReg(Src0RC, SubReg);
629 BuildMI(*BB, &I, DL, TII.get(TargetOpcode::INSERT_SUBREG), DstReg)
638 bool AMDGPUInstructionSelector::selectG_INTRINSIC(
MachineInstr &I)
const {
640 switch (IntrinsicID) {
641 case Intrinsic::amdgcn_if_break: {
657 for (
Register Reg : { DstReg, Src0Reg, Src1Reg })
668 if (Size != 32 && Size != 64)
674 return Size == 32 ? AMDGPU::V_CMP_NE_U32_e64 : AMDGPU::V_CMP_NE_U64_e64;
676 return Size == 32 ? AMDGPU::V_CMP_EQ_U32_e64 : AMDGPU::V_CMP_EQ_U64_e64;
678 return Size == 32 ? AMDGPU::V_CMP_GT_I32_e64 : AMDGPU::V_CMP_GT_I64_e64;
680 return Size == 32 ? AMDGPU::V_CMP_GE_I32_e64 : AMDGPU::V_CMP_GE_I64_e64;
682 return Size == 32 ? AMDGPU::V_CMP_LT_I32_e64 : AMDGPU::V_CMP_LT_I64_e64;
684 return Size == 32 ? AMDGPU::V_CMP_LE_I32_e64 : AMDGPU::V_CMP_LE_I64_e64;
686 return Size == 32 ? AMDGPU::V_CMP_GT_U32_e64 : AMDGPU::V_CMP_GT_U64_e64;
688 return Size == 32 ? AMDGPU::V_CMP_GE_U32_e64 : AMDGPU::V_CMP_GE_U64_e64;
690 return Size == 32 ? AMDGPU::V_CMP_LT_U32_e64 : AMDGPU::V_CMP_LT_U64_e64;
692 return Size == 32 ? AMDGPU::V_CMP_LE_U32_e64 : AMDGPU::V_CMP_LE_U64_e64;
697 unsigned Size)
const {
704 return AMDGPU::S_CMP_LG_U64;
706 return AMDGPU::S_CMP_EQ_U64;
717 return AMDGPU::S_CMP_LG_U32;
719 return AMDGPU::S_CMP_EQ_U32;
721 return AMDGPU::S_CMP_GT_I32;
723 return AMDGPU::S_CMP_GE_I32;
725 return AMDGPU::S_CMP_LT_I32;
727 return AMDGPU::S_CMP_LE_I32;
729 return AMDGPU::S_CMP_GT_U32;
731 return AMDGPU::S_CMP_GE_U32;
733 return AMDGPU::S_CMP_LT_U32;
735 return AMDGPU::S_CMP_LE_U32;
741 bool AMDGPUInstructionSelector::selectG_ICMP(
MachineInstr &I)
const {
746 unsigned Size = RBI.getSizeInBits(SrcReg, *MRI, TRI);
751 if (!isVCC(CCReg, *MRI)) {
752 int Opcode = getS_CMPOpcode(Pred, Size);
758 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), CCReg)
759 .addReg(AMDGPU::SCC);
784 unsigned Reg0,
unsigned Reg1,
unsigned Reg2,
unsigned Reg3,
785 unsigned VM,
bool Compr,
unsigned Enabled,
bool Done) {
788 unsigned Opcode = Done ? AMDGPU::EXP_DONE :
AMDGPU::EXP;
789 return BuildMI(BB, Insert, DL, TII.
get(Opcode))
810 return AuxiliaryData & 1;
814 return (AuxiliaryData >> 1) & 1;
818 return (AuxiliaryData >> 2) & 1;
822 return (AuxiliaryData >> 3) & 1;
826 const unsigned MemSize,
829 switch (8 * MemSize) {
831 return Offen ? AMDGPU::BUFFER_STORE_BYTE_OFFEN_exact :
832 AMDGPU::BUFFER_STORE_BYTE_OFFSET_exact;
834 return Offen ? AMDGPU::BUFFER_STORE_SHORT_OFFEN_exact :
835 AMDGPU::BUFFER_STORE_SHORT_OFFSET_exact;
837 unsigned Opc = Offen ? AMDGPU::BUFFER_STORE_DWORD_OFFEN_exact :
838 AMDGPU::BUFFER_STORE_DWORD_OFFSET_exact;
846 const unsigned MemSize,
855 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_X_OFFEN_exact :
856 AMDGPU::BUFFER_STORE_FORMAT_D16_X_OFFSET_exact;
858 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XY_OFFEN_exact :
859 AMDGPU::BUFFER_STORE_FORMAT_D16_XY_OFFSET_exact;
861 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XYZ_OFFEN_exact :
862 AMDGPU::BUFFER_STORE_FORMAT_D16_XYZ_OFFSET_exact;
864 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XYZW_OFFEN_exact :
865 AMDGPU::BUFFER_STORE_FORMAT_D16_XYZW_OFFSET_exact;
874 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_X_OFFEN_exact :
875 AMDGPU::BUFFER_STORE_FORMAT_D16_X_OFFSET_exact;
877 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XY_gfx80_OFFEN_exact :
878 AMDGPU::BUFFER_STORE_FORMAT_D16_XY_gfx80_OFFSET_exact;
880 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XYZ_gfx80_OFFEN_exact :
881 AMDGPU::BUFFER_STORE_FORMAT_D16_XYZ_gfx80_OFFSET_exact;
883 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_D16_XYZW_gfx80_OFFEN_exact :
884 AMDGPU::BUFFER_STORE_FORMAT_D16_XYZW_gfx80_OFFSET_exact;
892 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_X_OFFEN_exact :
893 AMDGPU::BUFFER_STORE_FORMAT_X_OFFSET_exact;
895 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_XY_OFFEN_exact :
896 AMDGPU::BUFFER_STORE_FORMAT_XY_OFFSET_exact;
898 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_XYZ_OFFEN_exact :
899 AMDGPU::BUFFER_STORE_FORMAT_XYZ_OFFSET_exact;
901 return Offen ? AMDGPU::BUFFER_STORE_FORMAT_XYZW_OFFEN_exact :
902 AMDGPU::BUFFER_STORE_FORMAT_XYZW_OFFSET_exact;
912 std::tuple<Register, unsigned, unsigned>
915 const unsigned MaxImm = 4095;
917 unsigned TotalConstOffset;
920 std::tie(BaseReg, TotalConstOffset, OffsetDef)
923 unsigned ImmOffset = TotalConstOffset;
932 unsigned Overflow = ImmOffset & ~MaxImm;
933 ImmOffset -= Overflow;
934 if ((int32_t)Overflow < 0) {
935 Overflow += ImmOffset;
962 BaseReg = NewBaseReg;
968 return std::make_tuple(BaseReg, ImmOffset, TotalConstOffset);
971 bool AMDGPUInstructionSelector::selectStoreIntrinsic(
MachineInstr &MI,
972 bool IsFormat)
const {
984 const int MemSize = MMO->
getSize();
991 unsigned TotalOffset;
993 std::tie(VOffset, ImmOffset, TotalOffset) = splitBufferOffsets(B, VOffset);
994 if (TotalOffset != 0)
997 const bool Offen = !
isZero(VOffset, *MRI);
1047 bool AMDGPUInstructionSelector::selectDSOrderedIntrinsic(
1057 if (WaveDone && !WaveRelease)
1060 unsigned OrderedCountIndex = IndexOperand & 0x3f;
1061 IndexOperand &= ~0x3f;
1062 unsigned CountDw = 0;
1065 CountDw = (IndexOperand >> 24) & 0xf;
1066 IndexOperand &= ~(0xf << 24);
1068 if (CountDw < 1 || CountDw > 4) {
1070 "ds_ordered_count: dword count must be between 1 and 4");
1077 unsigned Instruction = IntrID == Intrinsic::amdgcn_ds_ordered_add ? 0 : 1;
1080 unsigned Offset0 = OrderedCountIndex << 2;
1081 unsigned Offset1 = WaveRelease | (WaveDone << 1) | (ShaderType << 2) |
1085 Offset1 |= (CountDw - 1) << 6;
1087 unsigned Offset = Offset0 | (Offset1 << 8);
1090 BuildMI(*MBB, &MI, DL, TII.get(AMDGPU::COPY), AMDGPU::M0)
1109 bool AMDGPUInstructionSelector::selectG_INTRINSIC_W_SIDE_EFFECTS(
1113 switch (IntrinsicID) {
1114 case Intrinsic::amdgcn_exp: {
1129 case Intrinsic::amdgcn_exp_compr: {
1139 BuildMI(*BB, &I, DL, TII.get(AMDGPU::IMPLICIT_DEF),
Undef);
1141 true, Enabled, Done);
1146 case Intrinsic::amdgcn_end_cf: {
1150 TII.get(AMDGPU::SI_END_CF))
1160 case Intrinsic::amdgcn_raw_buffer_store:
1161 return selectStoreIntrinsic(I,
false);
1162 case Intrinsic::amdgcn_raw_buffer_store_format:
1163 return selectStoreIntrinsic(I,
true);
1164 case Intrinsic::amdgcn_ds_ordered_add:
1165 case Intrinsic::amdgcn_ds_ordered_swap:
1166 return selectDSOrderedIntrinsic(I, IntrinsicID);
1172 bool AMDGPUInstructionSelector::selectG_SELECT(
MachineInstr &I)
const {
1177 unsigned Size = RBI.getSizeInBits(DstReg, *MRI, TRI);
1178 assert(Size <= 32 || Size == 64);
1181 if (!isVCC(CCReg, *MRI)) {
1182 unsigned SelectOpcode = Size == 64 ? AMDGPU::S_CSELECT_B64 :
1183 AMDGPU::S_CSELECT_B32;
1207 BuildMI(*BB, &I, DL, TII.get(AMDGPU::V_CNDMASK_B32_e64), DstReg)
1219 bool AMDGPUInstructionSelector::selectG_STORE(
MachineInstr &I)
const {
1227 return AMDGPU::sub0;
1229 return AMDGPU::sub0_sub1;
1231 return AMDGPU::sub0_sub1_sub2;
1233 return AMDGPU::sub0_sub1_sub2_sub3;
1235 return AMDGPU::sub0_sub1_sub2_sub3_sub4_sub5_sub6_sub7;
1238 return AMDGPU::sub0;
1245 bool AMDGPUInstructionSelector::selectG_TRUNC(
MachineInstr &I)
const {
1277 if (SubRegIdx == -1)
1282 SrcRC = TRI.getSubClassWithSubReg(SrcRC, SubRegIdx);
1295 I.
setDesc(TII.get(TargetOpcode::COPY));
1301 Mask = maskTrailingOnes<unsigned>(
Size);
1302 int SignedMask =
static_cast<int>(
Mask);
1303 return SignedMask >= -16 && SignedMask <= 64;
1307 const RegisterBank *AMDGPUInstructionSelector::getArtifactRegBank(
1320 bool AMDGPUInstructionSelector::selectG_SZA_EXT(
MachineInstr &I)
const {
1335 return selectCOPY(I);
1338 const RegisterBank *SrcBank = getArtifactRegBank(SrcReg, *MRI, TRI);
1340 if (SrcBank->
getID() == AMDGPU::VGPRRegBankID && DstSize <= 32) {
1347 BuildMI(MBB, I, DL, TII.get(AMDGPU::V_AND_B32_e32), DstReg)
1354 const unsigned BFE = Signed ? AMDGPU::V_BFE_I32 : AMDGPU::V_BFE_U32;
1356 BuildMI(MBB, I, DL, TII.get(BFE), DstReg)
1364 if (SrcBank->
getID() == AMDGPU::SGPRRegBankID && DstSize <= 64) {
1368 if (Signed && DstSize == 32 && (SrcSize == 8 || SrcSize == 16)) {
1369 const unsigned SextOpc = SrcSize == 8 ?
1370 AMDGPU::S_SEXT_I32_I8 : AMDGPU::S_SEXT_I32_I16;
1371 BuildMI(MBB, I, DL, TII.get(SextOpc), DstReg)
1377 const unsigned BFE64 = Signed ? AMDGPU::S_BFE_I64 : AMDGPU::S_BFE_U64;
1378 const unsigned BFE32 = Signed ? AMDGPU::S_BFE_I32 : AMDGPU::S_BFE_U32;
1381 if (DstSize > 32 && SrcSize <= 32) {
1385 BuildMI(MBB, I, DL, TII.get(AMDGPU::IMPLICIT_DEF), UndefReg);
1386 BuildMI(MBB, I, DL, TII.get(AMDGPU::REG_SEQUENCE), ExtReg)
1392 BuildMI(MBB, I, DL, TII.get(BFE64), DstReg)
1402 BuildMI(MBB, I, DL, TII.get(AMDGPU::S_AND_B32), DstReg)
1406 BuildMI(MBB, I, DL, TII.get(BFE32), DstReg)
1418 bool AMDGPUInstructionSelector::selectG_CONSTANT(
MachineInstr &I)
const {
1426 }
else if (ImmOp.
isCImm()) {
1435 IsSgpr = RB->
getID() == AMDGPU::SGPRRegBankID;
1439 IsSgpr = TRI.isSGPRClass(RC);
1443 if (Size != 32 && Size != 64)
1446 unsigned Opcode = IsSgpr ? AMDGPU::S_MOV_B32 : AMDGPU::V_MOV_B32_e32;
1459 ResInst =
BuildMI(*BB, &I, DL, TII.get(AMDGPU::S_MOV_B64), DstReg)
1463 &AMDGPU::SReg_32RegClass : &AMDGPU::VGPR_32RegClass;
1467 BuildMI(*BB, &I, DL, TII.get(Opcode), LoReg)
1468 .addImm(Imm.trunc(32).getZExtValue());
1470 BuildMI(*BB, &I, DL, TII.get(Opcode), HiReg)
1471 .addImm(Imm.ashr(32).getZExtValue());
1473 ResInst =
BuildMI(*BB, &I, DL, TII.get(AMDGPU::REG_SEQUENCE), DstReg)
1491 return MI.
getOpcode() == TargetOpcode::G_CONSTANT;
1501 if (PtrMI->
getOpcode() != TargetOpcode::G_PTR_ADD)
1504 GEPInfo GEPInfo(*PtrMI);
1506 for (
unsigned i = 1; i != 3; ++i) {
1513 assert(GEPInfo.Imm == 0);
1518 if (OpBank->
getID() == AMDGPU::SGPRRegBankID)
1519 GEPInfo.SgprParts.push_back(GEPOp.
getReg());
1521 GEPInfo.VgprParts.push_back(GEPOp.
getReg());
1525 getAddrModeInfo(*PtrMI, MRI, AddrInfo);
1528 bool AMDGPUInstructionSelector::isInstrUniform(
const MachineInstr &MI)
const {
1539 if (!Ptr || isa<UndefValue>(Ptr) || isa<Argument>(Ptr) ||
1540 isa<Constant>(Ptr) || isa<GlobalValue>(Ptr))
1550 bool AMDGPUInstructionSelector::hasVgprParts(
ArrayRef<GEPInfo> AddrInfo)
const {
1551 for (
const GEPInfo &GEPInfo : AddrInfo) {
1552 if (!GEPInfo.VgprParts.empty())
1558 void AMDGPUInstructionSelector::initM0(
MachineInstr &I)
const {
1571 bool AMDGPUInstructionSelector::selectG_LOAD_ATOMICRMW(
MachineInstr &I)
const {
1576 bool AMDGPUInstructionSelector::selectG_BRCOND(
MachineInstr &I)
const {
1591 if (!isVCC(CondReg, *MRI)) {
1595 CondPhysReg = AMDGPU::SCC;
1596 BrOpcode = AMDGPU::S_CBRANCH_SCC1;
1598 ConstrainRC = &AMDGPU::SGPR_32RegClass;
1605 CondPhysReg = TRI.getVCC();
1606 BrOpcode = AMDGPU::S_CBRANCH_VCCNZ;
1607 ConstrainRC = TRI.getBoolRC();
1613 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), CondPhysReg)
1615 BuildMI(*BB, &I, DL, TII.get(BrOpcode))
1622 bool AMDGPUInstructionSelector::selectG_FRAME_INDEX(
MachineInstr &I)
const {
1625 const bool IsVGPR = DstRB->
getID() == AMDGPU::VGPRRegBankID;
1626 I.
setDesc(TII.get(IsVGPR ? AMDGPU::V_MOV_B32_e32 : AMDGPU::S_MOV_B32));
1631 DstReg, IsVGPR ? AMDGPU::VGPR_32RegClass : AMDGPU::SReg_32RegClass, *MRI);
1634 bool AMDGPUInstructionSelector::selectG_PTR_MASK(
MachineInstr &I)
const {
1636 const uint64_t
Mask = ~((UINT64_C(1) <<
Align) - 1);
1645 const bool IsVGPR = DstRB->
getID() == AMDGPU::VGPRRegBankID;
1646 unsigned NewOpc = IsVGPR ? AMDGPU::V_AND_B32_e64 : AMDGPU::S_AND_B32;
1647 unsigned MovOpc = IsVGPR ? AMDGPU::V_MOV_B32_e32 : AMDGPU::S_MOV_B32;
1649 = IsVGPR ? AMDGPU::VGPR_32RegClass : AMDGPU::SReg_32RegClass;
1663 BuildMI(*BB, &I, DL, TII.get(MovOpc), ImmReg)
1667 BuildMI(*BB, &I, DL, TII.get(NewOpc), DstReg)
1678 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), LoReg)
1679 .addReg(SrcReg, 0, AMDGPU::sub0);
1680 BuildMI(*BB, &I, DL, TII.get(AMDGPU::COPY), HiReg)
1681 .addReg(SrcReg, 0, AMDGPU::sub1);
1683 BuildMI(*BB, &I, DL, TII.get(NewOpc), MaskLo)
1686 BuildMI(*BB, &I, DL, TII.get(AMDGPU::REG_SEQUENCE), DstReg)
1695 bool AMDGPUInstructionSelector::selectG_EXTRACT_VECTOR_ELT(
1710 if (IdxRB->
getID() != AMDGPU::SGPRRegBankID)
1726 unsigned SubReg = Is64 ? AMDGPU::sub0_sub1 : AMDGPU::sub0;
1728 if (SrcRB->
getID() == AMDGPU::SGPRRegBankID) {
1732 BuildMI(*BB, &MI, DL, TII.get(AMDGPU::COPY), AMDGPU::M0)
1735 unsigned Opc = Is64 ? AMDGPU::S_MOVRELS_B64 : AMDGPU::S_MOVRELS_B32;
1736 BuildMI(*BB, &MI, DL, TII.get(Opc), DstReg)
1737 .addReg(SrcReg, 0, SubReg)
1747 BuildMI(*BB, &MI, DL, TII.get(AMDGPU::COPY), AMDGPU::M0)
1749 BuildMI(*BB, &MI, DL, TII.get(AMDGPU::V_MOVRELS_B32_e32), DstReg)
1756 BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_ON))
1759 BuildMI(*BB, MI, DL, TII.get(AMDGPU::V_MOV_B32_e32), DstReg)
1763 BuildMI(*BB, MI, DL, TII.get(AMDGPU::S_SET_GPR_IDX_OFF));
1771 return selectPHI(I);
1775 return selectCOPY(I);
1780 case TargetOpcode::G_AND:
1781 case TargetOpcode::G_OR:
1782 case TargetOpcode::G_XOR:
1783 if (selectG_AND_OR_XOR(I))
1786 case TargetOpcode::G_ADD:
1787 case TargetOpcode::G_SUB:
1790 return selectG_ADD_SUB(I);
1791 case TargetOpcode::G_UADDO:
1792 case TargetOpcode::G_USUBO:
1793 case TargetOpcode::G_UADDE:
1794 case TargetOpcode::G_USUBE:
1795 return selectG_UADDO_USUBO_UADDE_USUBE(I);
1796 case TargetOpcode::G_INTTOPTR:
1797 case TargetOpcode::G_BITCAST:
1798 case TargetOpcode::G_PTRTOINT:
1799 return selectCOPY(I);
1800 case TargetOpcode::G_CONSTANT:
1801 case TargetOpcode::G_FCONSTANT:
1802 return selectG_CONSTANT(I);
1803 case TargetOpcode::G_EXTRACT:
1804 return selectG_EXTRACT(I);
1805 case TargetOpcode::G_MERGE_VALUES:
1806 case TargetOpcode::G_BUILD_VECTOR:
1807 case TargetOpcode::G_CONCAT_VECTORS:
1808 return selectG_MERGE_VALUES(I);
1809 case TargetOpcode::G_UNMERGE_VALUES:
1810 return selectG_UNMERGE_VALUES(I);
1811 case TargetOpcode::G_PTR_ADD:
1812 return selectG_PTR_ADD(I);
1813 case TargetOpcode::G_IMPLICIT_DEF:
1814 return selectG_IMPLICIT_DEF(I);
1815 case TargetOpcode::G_INSERT:
1816 return selectG_INSERT(I);
1817 case TargetOpcode::G_INTRINSIC:
1818 return selectG_INTRINSIC(I);
1819 case TargetOpcode::G_INTRINSIC_W_SIDE_EFFECTS:
1820 return selectG_INTRINSIC_W_SIDE_EFFECTS(I);
1821 case TargetOpcode::G_ICMP:
1822 if (selectG_ICMP(I))
1825 case TargetOpcode::G_LOAD:
1826 case TargetOpcode::G_ATOMIC_CMPXCHG:
1827 case TargetOpcode::G_ATOMICRMW_XCHG:
1828 case TargetOpcode::G_ATOMICRMW_ADD:
1829 case TargetOpcode::G_ATOMICRMW_SUB:
1830 case TargetOpcode::G_ATOMICRMW_AND:
1831 case TargetOpcode::G_ATOMICRMW_OR:
1832 case TargetOpcode::G_ATOMICRMW_XOR:
1833 case TargetOpcode::G_ATOMICRMW_MIN:
1834 case TargetOpcode::G_ATOMICRMW_MAX:
1835 case TargetOpcode::G_ATOMICRMW_UMIN:
1836 case TargetOpcode::G_ATOMICRMW_UMAX:
1837 case TargetOpcode::G_ATOMICRMW_FADD:
1838 return selectG_LOAD_ATOMICRMW(I);
1839 case TargetOpcode::G_SELECT:
1840 return selectG_SELECT(I);
1841 case TargetOpcode::G_STORE:
1842 return selectG_STORE(I);
1843 case TargetOpcode::G_TRUNC:
1844 return selectG_TRUNC(I);
1845 case TargetOpcode::G_SEXT:
1846 case TargetOpcode::G_ZEXT:
1847 case TargetOpcode::G_ANYEXT:
1850 return selectG_SZA_EXT(I);
1851 case TargetOpcode::G_BRCOND:
1852 return selectG_BRCOND(I);
1853 case TargetOpcode::G_FRAME_INDEX:
1854 return selectG_FRAME_INDEX(I);
1855 case TargetOpcode::G_PTR_MASK:
1856 return selectG_PTR_MASK(I);
1857 case TargetOpcode::G_EXTRACT_VECTOR_ELT:
1858 return selectG_EXTRACT_VECTOR_ELT(I);
1866 AMDGPUInstructionSelector::selectVCSRC(
MachineOperand &Root)
const {
1873 std::pair<Register, unsigned>
1874 AMDGPUInstructionSelector::selectVOP3ModsImpl(
1879 if (MI && MI->
getOpcode() == AMDGPU::G_FNEG) {
1885 if (MI && MI->
getOpcode() == AMDGPU::G_FABS) {
1890 return std::make_pair(Src, Mods);
1897 AMDGPUInstructionSelector::selectVSRC0(
MachineOperand &Root)
const {
1904 AMDGPUInstructionSelector::selectVOP3Mods0(
MachineOperand &Root)
const {
1907 std::tie(Src, Mods) = selectVOP3ModsImpl(Root.
getReg());
1918 AMDGPUInstructionSelector::selectVOP3OMods(
MachineOperand &Root)
const {
1927 AMDGPUInstructionSelector::selectVOP3Mods(
MachineOperand &Root)
const {
1930 std::tie(Src, Mods) = selectVOP3ModsImpl(Root.
getReg());
1939 AMDGPUInstructionSelector::selectVOP3Mods_nnan(
MachineOperand &Root)
const {
1942 std::tie(Src, Mods) = selectVOP3ModsImpl(Root.
getReg());
1953 AMDGPUInstructionSelector::selectVOP3OpSelMods0(
MachineOperand &Root)
const {
1963 AMDGPUInstructionSelector::selectVOP3OpSelMods(
MachineOperand &Root)
const {
1972 AMDGPUInstructionSelector::selectSmrdImm(
MachineOperand &Root)
const {
1974 getAddrModeInfo(*Root.
getParent(), *MRI, AddrInfo);
1976 if (AddrInfo.
empty() || AddrInfo[0].SgprParts.
size() != 1)
1979 const GEPInfo &GEPInfo = AddrInfo[0];
1984 unsigned PtrReg = GEPInfo.SgprParts[0];
1993 AMDGPUInstructionSelector::selectSmrdImm32(
MachineOperand &Root)
const {
1995 getAddrModeInfo(*Root.
getParent(), *MRI, AddrInfo);
1997 if (AddrInfo.
empty() || AddrInfo[0].SgprParts.
size() != 1)
2000 const GEPInfo &GEPInfo = AddrInfo[0];
2001 unsigned PtrReg = GEPInfo.SgprParts[0];
2013 AMDGPUInstructionSelector::selectSmrdSgpr(
MachineOperand &Root)
const {
2018 getAddrModeInfo(*MI, *MRI, AddrInfo);
2022 if (AddrInfo.
empty() || AddrInfo[0].SgprParts.
size() != 1)
2025 const GEPInfo &GEPInfo = AddrInfo[0];
2026 if (!GEPInfo.Imm || !
isUInt<32>(GEPInfo.Imm))
2033 unsigned PtrReg = GEPInfo.SgprParts[0];
2036 .addImm(GEPInfo.Imm);
2043 template <
bool Signed>
2045 AMDGPUInstructionSelector::selectFlatOffsetImpl(
MachineOperand &Root)
const {
2058 if (!OpDef || OpDef->
getOpcode() != AMDGPU::G_PTR_ADD)
2080 AMDGPUInstructionSelector::selectFlatOffset(
MachineOperand &Root)
const {
2081 return selectFlatOffsetImpl<false>(Root);
2085 AMDGPUInstructionSelector::selectFlatOffsetSigned(
MachineOperand &Root)
const {
2086 return selectFlatOffsetImpl<true>(Root);
2095 AMDGPUInstructionSelector::selectMUBUFScratchOffen(
MachineOperand &Root)
const {
2109 .addImm(Offset & ~4095);
2115 MIB.addReg(HighBits);
2124 MIB.addReg(SOffsetReg);
2127 MIB.addImm(Offset & 4095);
2143 if (LHSDef && RHSDef) {
2144 int64_t PossibleOffset =
2149 if (LHSDef->
getOpcode() == AMDGPU::G_FRAME_INDEX)
2153 Offset = PossibleOffset;
2156 }
else if (RootDef->getOpcode() == AMDGPU::G_FRAME_INDEX) {
2157 FI = RootDef->getOperand(1).getIndex();
2178 MIB.addReg(SOffset);
2188 unsigned OffsetBits)
const {
2202 AMDGPUInstructionSelector::selectMUBUFScratchOffset(
2230 AMDGPUInstructionSelector::selectDS1Addr1Offset(
MachineOperand &Root)
const {
2239 int64_t ConstAddr = 0;
2245 if (LHSDef && RHSDef) {
2246 int64_t PossibleOffset =
2248 if (isDSOffsetLegal(*MRI, LHS, PossibleOffset, 16)) {
2256 }
else if (RootDef->
getOpcode() == AMDGPU::G_SUB) {
2275 "Expected G_CONSTANT");
2277 assert(CstVal &&
"Expected constant value");
2278 MIB.
addImm(CstVal.getValue());
2285 "Expected G_CONSTANT");
2295 if (MI.
getOpcode() == TargetOpcode::G_FCONSTANT)
2298 assert(MI.
getOpcode() == TargetOpcode::G_CONSTANT &&
"Expected G_CONSTANT");
2307 "Expected G_CONSTANT");
2319 bool AMDGPUInstructionSelector::isInlineImmediate16(int64_t Imm)
const {
2323 bool AMDGPUInstructionSelector::isInlineImmediate32(int64_t Imm)
const {
2327 bool AMDGPUInstructionSelector::isInlineImmediate64(int64_t Imm)
const {
2331 bool AMDGPUInstructionSelector::isInlineImmediate(
const APFloat &Imm)
const {
unsigned getScratchWaveOffsetReg() const
static MachineInstr * buildEXP(const TargetInstrInfo &TII, MachineInstr *Insert, unsigned Tgt, unsigned Reg0, unsigned Reg1, unsigned Reg2, unsigned Reg3, unsigned VM, bool Compr, unsigned Enabled, bool Done)
constexpr bool isUInt< 32 >(uint64_t x)
const MachineInstrBuilder & add(const MachineOperand &MO) const
bool hasUsableDSOffset() const
True if the offset field of DS instructions works as expected.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
bool privateMemoryResourceIsRangeChecked() const
static bool isConstant(const MachineInstr &MI)
static unsigned getDSShaderTypeValue(const MachineFunction &MF)
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
uint64_t getZExtValue() const
Get zero extended value.
This file declares the targeting of the RegisterBankInfo class for AMDGPU.
unsigned getAddrSpace() const
AMDGPU specific subclass of TargetSubtarget.
MachineBasicBlock * getMBB() const
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.
bool select(MachineInstr &I) override
Select the (possibly generic) instruction I to only use target-specific opcodes.
unsigned getStackPtrOffsetReg() const
virtual void setupMF(MachineFunction &mf, GISelKnownBits &KB, CodeGenCoverage &covinfo)
Setup per-MF selector state.
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
unsigned getScalarSizeInBits() const
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
bool useVGPRIndexMode() const
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
unsigned getSubReg() const
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
uint64_t getSize() const
Return the size in bytes of the memory reference.
bool mi_match(Reg R, const MachineRegisterInfo &MRI, Pattern &&P)
const TargetRegisterClass * getConstrainedRegClassForOperand(const MachineOperand &MO, const MachineRegisterInfo &MRI) const override
C - The default llvm calling convention, compatible with C.
unsigned const TargetRegisterInfo * TRI
Calling convention used for AMDPAL vertex shader if tessellation is in use.
static unsigned getBufferStoreOpcode(LLT Ty, const unsigned MemSize, const bool Offen)
static int getV_CMPOpcode(CmpInst::Predicate P, unsigned Size)
static const char * getName()
iterator_range< mop_iterator > operands()
bool isInlineConstant(const APInt &Imm) const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
T get() const
Returns the value of the specified pointer type.
static unsigned extractGLC(unsigned AuxiliaryData)
bool isInternalRead() const
Calling convention used for Mesa/AMDPAL geometry shaders.
static unsigned getAddrSpace(StringRef R)
AMDGPUInstructionSelector(const GCNSubtarget &STI, const AMDGPURegisterBankInfo &RBI, const AMDGPUTargetMachine &TM)
bool isInlinableLiteral16(int16_t Literal, bool HasInv2Pi)
bool isEarlyClobber() const
const TargetRegisterClass * getRegClassForSizeOnBank(unsigned Size, const RegisterBank &Bank, const MachineRegisterInfo &MRI) const
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwises returns null...
A description of a memory reference used in the backend.
void setInsertPt(MachineBasicBlock &MBB, MachineBasicBlock::iterator II)
Set the insertion point before the specified position.
static bool shouldUseAndMask(unsigned Size, unsigned &Mask)
This file declares the targeting of the InstructionSelector class for AMDGPU.
bool isBaseWithConstantOffset(const MachineOperand &Root, const MachineRegisterInfo &MRI) const
Return true if the specified operand is a G_PTR_ADD with a G_CONSTANT on the right-hand side...
const HexagonInstrInfo * TII
const ConstantFP * getFPImm() const
unsigned getNumOperands() const
Retuns the total number of operands.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
static unsigned getBufferStoreFormatOpcode(LLT Ty, const unsigned MemSize, const bool Offen)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Address space for 32-bit constant memory.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
bool isSGPRClass(const TargetRegisterClass *RC) const
#define GET_GLOBALISEL_PREDICATES_INIT
TargetRegisterInfo interface that is implemented by all hw codegen targets.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
Address space for region memory. (GDS)
unsigned NoNaNsFPMath
NoNaNsFPMath - This flag is enabled when the -enable-no-nans-fp-math flag is specified on the command...
UnaryOp_match< SrcTy, TargetOpcode::COPY > m_Copy(SrcTy &&Src)
const RegisterBank & getRegBankFromRegClass(const TargetRegisterClass &RC, LLT) const override
Get a register bank that covers RC.
const TargetRegisterClass * getRegClassForTypeOnBank(LLT Ty, const RegisterBank &Bank, const MachineRegisterInfo &MRI) const
const RegClassOrRegBank & getRegClassOrRegBank(unsigned Reg) const
Return the register bank or register class of Reg.
const T & getValue() const LLVM_LVALUE_FUNCTION
MachineFunction & getMF()
Getter for the function we currently build.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
void setupMF(MachineFunction &MF, GISelKnownBits &KB, CodeGenCoverage &CoverageInfo) override
Setup per-MF selector state.
const APInt & getValue() const
Return the constant as an APInt value reference.
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
ArrayRef< int16_t > getRegSplitParts(const TargetRegisterClass *RC, unsigned EltSize) const
bool hasAddNoCarry() const
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
static unsigned getSubRegFromChannel(unsigned Channel, unsigned NumRegs=1)
unsigned getUndefRegState(bool B)
Analysis containing CSE Info
CodeGenCoverage * CoverageInfo
void ChangeToImmediate(int64_t ImmVal)
ChangeToImmediate - Replace this operand with a new immediate operand of the specified value...
TargetInstrInfo - Interface to description of machine instruction set.
const Value * getValue() const
Return the base address of the memory access.
Calling convention used for Mesa/AMDPAL compute shaders.
MachineBasicBlock::iterator getInsertPt()
Current insertion point for new instructions.
static unsigned extractDLC(unsigned AuxiliaryData)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
bool hasScalarCompareEq64() const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
int64_t getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
constexpr bool isUInt< 8 >(uint64_t x)
bool isPreISelOpcode(QueryType Type=IgnoreBundle) const
Return true if this is an instruction that should go through the usual legalization steps...
unsigned countPopulation() const
Count the number of bits set.
bool hasSuperClassEq(const TargetRegisterClass *RC) const
Returns true if RC is a super-class of or equal to this class.
MachineInstrBuilder buildInstr(unsigned Opcode)
Build and insert <empty> = Opcode <empty>.
PointerUnion< const Value *, const PseudoSourceValue * > V
This is the IR pointer value for the access, or it is null if unknown.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Helper class to build MachineInstr.
bool isCImm() const
isCImm - Test if this is a MO_CImmediate operand.
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool hasOneMemOperand() const
Return true if this instruction has exactly one MachineMemOperand.
void setInstr(MachineInstr &MI)
Set the insertion point to before MI.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Generation getGeneration() const
const RegisterBank * getRegBankOrNull(unsigned Reg) const
Return the register bank of Reg, or null if Reg has not been assigned a register bank or has been ass...
static unsigned extractSWZ(unsigned AuxiliaryData)
unsigned getAddressSpace() const
The AMDGPU TargetMachine interface definition for hw codgen targets.
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 isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This class contains a discriminated union of information about pointers in memory operands...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This struct is a compact representation of a valid (non-zero power of two) alignment.
const APFloat & getValueAPF() const
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.
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
RegisterBank & getRegBank(unsigned ID)
Get the register bank identified by ID.
Address space for local memory.
MachineOperand class - Representation of each machine instruction operand.
Calling convention used for Mesa/AMDPAL pixel shaders.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned getScratchRSrcReg() const
Returns the physical register reserved for use as the resource descriptor for scratch accesses...
MachineInstrBuilder getAddNoCarry(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg) const
Return a partially built integer add instruction without carry.
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
bool constrainSelectedInstRegOperands(MachineInstr &I, const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
Mutate the newly-selected instruction I to constrain its (possibly generic) virtual register operands...
std::tuple< Register, unsigned, MachineInstr * > getBaseWithConstantOffset(MachineRegisterInfo &MRI, Register Reg)
Returns Base register, constant offset, and offset def point.
DebugLoc getDebugLoc()
Get the current instruction's debug location.
This class implements the register bank concept.
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.
This file declares the MachineIRBuilder class.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static int sizeToSubRegIndex(unsigned Size)
Class for arbitrary precision integers.
Special value supplied for machine level alias analysis.
static unsigned extractSLC(unsigned AuxiliaryData)
void addImplicitDefUseOperands(MachineFunction &MF)
Add all implicit def and use operands to this instruction.
Optional< int64_t > getConstantVRegVal(unsigned VReg, const MachineRegisterInfo &MRI)
If VReg is defined by a G_CONSTANT fits in int64_t returns it.
#define GET_GLOBALISEL_TEMPORARIES_INIT
const MachineBasicBlock * getParent() const
Contains the definition of a TargetInstrInfo class that is common to all AMD GPUs.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Provides the logic to select generic machine instructions.
Provides AMDGPU specific target descriptions.
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...
const MachinePointerInfo & getPointerInfo() const
const TargetRegisterClass * getBoolRC() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
ConstantMatch m_ICst(int64_t &Cst)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
unsigned greater or equal
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
static unsigned getLogicalBitOpcode(unsigned Opc, bool Is64)
const MachineBasicBlock & getMBB() const
Getter for the basic block we currently build.
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
static MachineOperand CreateImm(int64_t Val)
const MachineInstrBuilder & cloneMemRefs(const MachineInstr &OtherMI) const
void setSubReg(unsigned subReg)
bool hasFlatInstOffsets() 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)
constexpr bool isUInt< 16 >(uint64_t x)
bool isKnownNeverNaN(const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
Return true if the floating-point scalar value is not a NaN or if the floating-point vector value has...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const TargetRegisterClass * getWaveMaskRegClass() const
bool ldsRequiresM0Init() const
Return if most LDS instructions have an m0 use that require m0 to be iniitalized. ...
const TargetRegisterClass * getRegClassOrNull(unsigned Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isLegalMUBUFImmOffset(unsigned Imm)
unsigned getIntrinsicID() const
Returns the Intrinsic::ID for this instruction.
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
LLVM Value Representation.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
uint16_t getNumElements() const
Returns the number of elements in a vector LLT.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
static bool isStackPtrRelative(const MachinePointerInfo &PtrInfo)
virtual const TargetRegisterClass * getConstrainedRegClassForOperand(const MachineOperand &MO, const MachineRegisterInfo &MRI) 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.
void setRegClass(unsigned Reg, const TargetRegisterClass *RC)
setRegClass - Set the register class of the specified virtual register.
APInt bitcastToAPInt() const
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
bool unsafeDSOffsetFoldingEnabled() const
Register getReg() const
getReg - Returns the register number.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
const MachineOperand & getOperand(unsigned i) const
const ConstantInt * getCImm() const
Calling convention for AMDGPU code object kernels.
static const TargetRegisterClass * constrainGenericRegister(Register Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)
Constrain the (possibly generic) virtual register Reg to RC.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
static bool isZero(Register Reg, MachineRegisterInfo &MRI)
Wrapper class representing virtual and physical registers.
Calling convention used for AMDPAL shader stage before geometry shader if geometry is in use...
unsigned getID() const
Get the identifier of this register bank.
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
unsigned getPredicate() const