22#include "llvm/IR/IntrinsicsAMDGPU.h"
23#include "llvm/IR/IntrinsicsR600.h"
33#define GET_INSTRINFO_NAMED_OPS
34#define GET_INSTRMAP_INFO
35#include "AMDGPUGenInstrInfo.inc"
40 llvm::cl::desc(
"Set default AMDHSA Code Object Version (module flag "
41 "or asm directive still take priority if present)"));
46unsigned getBitMask(
unsigned Shift,
unsigned Width) {
47 return ((1 << Width) - 1) << Shift;
53unsigned packBits(
unsigned Src,
unsigned Dst,
unsigned Shift,
unsigned Width) {
54 unsigned Mask = getBitMask(Shift, Width);
55 return ((Src << Shift) & Mask) | (Dst & ~Mask);
61unsigned unpackBits(
unsigned Src,
unsigned Shift,
unsigned Width) {
62 return (Src & getBitMask(Shift, Width)) >> Shift;
66unsigned getVmcntBitShiftLo(
unsigned VersionMajor) {
71unsigned getVmcntBitWidthLo(
unsigned VersionMajor) {
76unsigned getExpcntBitShift(
unsigned VersionMajor) {
81unsigned getExpcntBitWidth(
unsigned VersionMajor) {
return 3; }
84unsigned getLgkmcntBitShift(
unsigned VersionMajor) {
89unsigned getLgkmcntBitWidth(
unsigned VersionMajor) {
94unsigned getVmcntBitShiftHi(
unsigned VersionMajor) {
return 14; }
97unsigned getVmcntBitWidthHi(
unsigned VersionMajor) {
98 return (VersionMajor == 9 || VersionMajor == 10) ? 2 : 0;
102unsigned getLoadcntBitWidth(
unsigned VersionMajor) {
107unsigned getSamplecntBitWidth(
unsigned VersionMajor) {
112unsigned getBvhcntBitWidth(
unsigned VersionMajor) {
117unsigned getDscntBitWidth(
unsigned VersionMajor) {
122unsigned getDscntBitShift(
unsigned VersionMajor) {
return 0; }
125unsigned getStorecntBitWidth(
unsigned VersionMajor) {
130unsigned getKmcntBitWidth(
unsigned VersionMajor) {
135unsigned getXcntBitWidth(
unsigned VersionMajor,
unsigned VersionMinor) {
140unsigned getAsynccntBitWidth(
unsigned VersionMajor,
unsigned VersionMinor) {
145unsigned getLoadcntStorecntBitShift(
unsigned VersionMajor) {
150unsigned getBarrierMemberCountBitWidth(
unsigned VersionMajor) {
155inline unsigned getVaSdstBitWidth() {
return 3; }
158inline unsigned getVaSdstBitShift() {
return 9; }
161inline unsigned getVmVsrcBitWidth() {
return 3; }
164inline unsigned getVmVsrcBitShift() {
return 2; }
167inline unsigned getVaVdstBitWidth() {
return 4; }
170inline unsigned getVaVdstBitShift() {
return 12; }
173inline unsigned getVaVccBitWidth() {
return 1; }
176inline unsigned getVaVccBitShift() {
return 1; }
179inline unsigned getSaSdstBitWidth() {
return 1; }
182inline unsigned getSaSdstBitShift() {
return 0; }
185inline unsigned getVaSsrcBitWidth() {
return 1; }
188inline unsigned getVaSsrcBitShift() {
return 8; }
191inline unsigned getHoldCntWidth(
unsigned VersionMajor,
unsigned VersionMinor) {
192 static constexpr const unsigned MinMajor = 10;
193 static constexpr const unsigned MinMinor = 3;
194 return std::tie(VersionMajor, VersionMinor) >= std::tie(MinMajor, MinMinor)
200inline unsigned getHoldCntBitShift() {
return 7; }
221 M.getModuleFlag(
"amdhsa_code_object_version"))) {
222 return (
unsigned)Ver->getZExtValue() / 100;
233 switch (ABIVersion) {
249 switch (CodeObjectVersion) {
258 Twine(CodeObjectVersion));
263 switch (CodeObjectVersion) {
276 switch (CodeObjectVersion) {
287 switch (CodeObjectVersion) {
298 switch (CodeObjectVersion) {
308#define GET_MIMGBaseOpcodesTable_IMPL
309#define GET_MIMGDimInfoTable_IMPL
310#define GET_MIMGInfoTable_IMPL
311#define GET_MIMGLZMappingTable_IMPL
312#define GET_MIMGMIPMappingTable_IMPL
313#define GET_MIMGBiasMappingTable_IMPL
314#define GET_MIMGOffsetMappingTable_IMPL
315#define GET_MIMGG16MappingTable_IMPL
316#define GET_MAIInstInfoTable_IMPL
317#define GET_WMMAInstInfoTable_IMPL
318#include "AMDGPUGenSearchableTables.inc"
321 unsigned VDataDwords,
unsigned VAddrDwords,
bool IndexedRsrc,
324 getMIMGOpcodeHelper(BaseOpcode, MIMGEncoding, VDataDwords, VAddrDwords,
325 IndexedRsrc, IndexedSamp);
326 return Info ? Info->Opcode : -1;
336 const MIMGInfo *NewInfo = getMIMGOpcodeHelper(
339 return NewInfo ? NewInfo->
Opcode : -1;
344 bool IsG16Supported) {
351 AddrWords += AddrComponents;
359 if ((IsA16 && !IsG16Supported) || BaseOpcode->
G16)
429#define GET_FP4FP8DstByteSelTable_DECL
430#define GET_FP4FP8DstByteSelTable_IMPL
446#define GET_DPMACCInstructionTable_DECL
447#define GET_DPMACCInstructionTable_IMPL
448#define GET_MTBUFInfoTable_DECL
449#define GET_MTBUFInfoTable_IMPL
450#define GET_MUBUFInfoTable_DECL
451#define GET_MUBUFInfoTable_IMPL
452#define GET_SMInfoTable_DECL
453#define GET_SMInfoTable_IMPL
454#define GET_VOP1InfoTable_DECL
455#define GET_VOP1InfoTable_IMPL
456#define GET_VOP2InfoTable_DECL
457#define GET_VOP2InfoTable_IMPL
458#define GET_VOP3InfoTable_DECL
459#define GET_VOP3InfoTable_IMPL
460#define GET_VOPC64DPPTable_DECL
461#define GET_VOPC64DPPTable_IMPL
462#define GET_VOPC64DPP8Table_DECL
463#define GET_VOPC64DPP8Table_IMPL
464#define GET_VOPCAsmOnlyInfoTable_DECL
465#define GET_VOPCAsmOnlyInfoTable_IMPL
466#define GET_VOP3CAsmOnlyInfoTable_DECL
467#define GET_VOP3CAsmOnlyInfoTable_IMPL
468#define GET_VOPDComponentTable_DECL
469#define GET_VOPDComponentTable_IMPL
470#define GET_VOPDPairs_DECL
471#define GET_VOPDPairs_IMPL
472#define GET_VOPDXYTable_DECL
473#define GET_VOPDXYTable_IMPL
474#define GET_VOPTrue16Table_DECL
475#define GET_VOPTrue16Table_IMPL
476#define GET_VOP3PHasNoOpSelHiTable_DECL
477#define GET_VOP3PHasNoOpSelHiTable_IMPL
478#define GET_True16D16Table_IMPL
479#define GET_WMMAOpcode2AddrMappingTable_DECL
480#define GET_WMMAOpcode2AddrMappingTable_IMPL
481#define GET_WMMAOpcode3AddrMappingTable_DECL
482#define GET_WMMAOpcode3AddrMappingTable_IMPL
483#define GET_getMFMA_F8F6F4_WithSize_DECL
484#define GET_getMFMA_F8F6F4_WithSize_IMPL
485#define GET_isMFMA_F8F6F4Table_IMPL
486#define GET_isCvtScaleF32_F32F16ToF8F4Table_IMPL
487#define GET_VLdStIdxOpcodeInfoTable_IMPL
489#include "AMDGPUGenSearchableTables.inc"
491const VLdStIdxOpcodeInfo *
494 return getVLdStIdxOpcodeInfoByKeyImpl(
BitWidth, IsStore, IsGPRIdx);
499 return Info ? Info->BaseOpcode : -1;
504 getMTBUFInfoFromBaseOpcodeAndElements(BaseOpc, Elements);
505 return Info ? Info->Opcode : -1;
510 return Info ? Info->elements : 0;
515 return Info && Info->has_vaddr;
520 return Info && Info->has_srsrc;
525 return Info && Info->has_soffset;
530 return Info ? Info->BaseOpcode : -1;
535 getMUBUFInfoFromBaseOpcodeAndElements(BaseOpc, Elements);
536 return Info ? Info->Opcode : -1;
541 return Info ? Info->elements : 0;
546 return Info && Info->has_vaddr;
551 return Info && Info->has_srsrc;
556 return Info && Info->has_soffset;
561 return Info && Info->IsBufferInv;
566 return Info && Info->tfe;
570 return isSMEMOpcodeHelper(
Opc) !=
nullptr;
574 return isVOP1SingleOpcodeHelper(
Opc) !=
nullptr;
578 return isVOP2SingleOpcodeHelper(
Opc) !=
nullptr;
582 return isVOP3SingleOpcodeHelper(
Opc) !=
nullptr;
586 return isVOPC64DPPOpcodeHelper(
Opc) || isVOPC64DPP8OpcodeHelper(
Opc);
593 return Info && Info->is_dgemm;
598 return Info && Info->is_gfx940_xdl;
603 return Info ? Info->is_wmma_xdl :
false;
608 return Info && Info->HasMatrixScale;
612 switch (EncodingVal) {
629 unsigned F8F8Opcode) {
632 return getMFMA_F8F6F4_InstWithNumRegs(SrcANumRegs, SrcBNumRegs, F8F8Opcode);
652 unsigned F8F8Opcode) {
655 return getMFMA_F8F6F4_InstWithNumRegs(SrcANumRegs, SrcBNumRegs, F8F8Opcode);
659 unsigned BFmt,
unsigned BScale) {
660 auto isValid = [](
unsigned Fmt,
unsigned Scale) ->
bool {
690 if (ST.hasFeature(AMDGPU::FeatureGFX13Insts))
692 if (ST.hasFeature(AMDGPU::FeatureGFX1250Insts))
694 if (ST.hasFeature(AMDGPU::FeatureGFX12Insts))
696 if (ST.hasFeature(AMDGPU::FeatureGFX11_7Insts))
698 if (ST.hasFeature(AMDGPU::FeatureGFX11Insts))
705 Opc = IsConvertibleToBitOp ? (
unsigned)AMDGPU::V_BITOP3_B32_e64 :
Opc;
710 return {
false,
false};
712 (Info->VOPDOp << 5) | (EncodingFamily << 1) | (VOPD3 ? 1u : 0u);
715 return {
false,
false};
716 return {XYInfo->
IsX, XYInfo->
IsY};
721 Opc = IsConvertibleToBitOp ? (
unsigned)AMDGPU::V_BITOP3_B32_e64 :
Opc;
723 return Info ? Info->VOPDOp : ~0u;
731 return Opc == AMDGPU::V_MAC_F32_e64_gfx6_gfx7 ||
732 Opc == AMDGPU::V_MAC_F32_e64_gfx10 ||
733 Opc == AMDGPU::V_MAC_F32_e64_vi ||
734 Opc == AMDGPU::V_MAC_LEGACY_F32_e64_gfx6_gfx7 ||
735 Opc == AMDGPU::V_MAC_LEGACY_F32_e64_gfx10 ||
736 Opc == AMDGPU::V_MAC_F16_e64_vi ||
737 Opc == AMDGPU::V_FMAC_F64_e64_gfx90a ||
738 Opc == AMDGPU::V_FMAC_F64_e64_gfx12 ||
739 Opc == AMDGPU::V_FMAC_F64_e64_gfx13 ||
740 Opc == AMDGPU::V_FMAC_F32_e64_gfx10 ||
741 Opc == AMDGPU::V_FMAC_F32_e64_gfx11 ||
742 Opc == AMDGPU::V_FMAC_F32_e64_gfx12 ||
743 Opc == AMDGPU::V_FMAC_F32_e64_gfx13 ||
744 Opc == AMDGPU::V_FMAC_F32_e64_vi ||
745 Opc == AMDGPU::V_FMAC_LEGACY_F32_e64_gfx10 ||
746 Opc == AMDGPU::V_FMAC_DX9_ZERO_F32_e64_gfx11 ||
747 Opc == AMDGPU::V_FMAC_F16_e64_gfx10 ||
748 Opc == AMDGPU::V_FMAC_F16_t16_e64_gfx11 ||
749 Opc == AMDGPU::V_FMAC_F16_fake16_e64_gfx11 ||
750 Opc == AMDGPU::V_FMAC_F16_t16_e64_gfx12 ||
751 Opc == AMDGPU::V_FMAC_F16_fake16_e64_gfx12 ||
752 Opc == AMDGPU::V_FMAC_F16_t16_e64_gfx13 ||
753 Opc == AMDGPU::V_FMAC_F16_fake16_e64_gfx13 ||
754 Opc == AMDGPU::V_DOT2C_F32_F16_e64_vi ||
755 Opc == AMDGPU::V_DOT2C_F32_BF16_e64_vi ||
756 Opc == AMDGPU::V_DOT2C_I32_I16_e64_vi ||
757 Opc == AMDGPU::V_DOT4C_I32_I8_e64_vi ||
758 Opc == AMDGPU::V_DOT8C_I32_I4_e64_vi;
762 return Opc == AMDGPU::V_PERMLANE16_B32_gfx10 ||
763 Opc == AMDGPU::V_PERMLANEX16_B32_gfx10 ||
764 Opc == AMDGPU::V_PERMLANE16_B32_e64_gfx11 ||
765 Opc == AMDGPU::V_PERMLANEX16_B32_e64_gfx11 ||
766 Opc == AMDGPU::V_PERMLANE16_B32_e64_gfx12 ||
767 Opc == AMDGPU::V_PERMLANE16_B32_e64_gfx13 ||
768 Opc == AMDGPU::V_PERMLANEX16_B32_e64_gfx12 ||
769 Opc == AMDGPU::V_PERMLANEX16_B32_e64_gfx13 ||
770 Opc == AMDGPU::V_PERMLANE16_VAR_B32_e64_gfx12 ||
771 Opc == AMDGPU::V_PERMLANE16_VAR_B32_e64_gfx13 ||
772 Opc == AMDGPU::V_PERMLANEX16_VAR_B32_e64_gfx12 ||
773 Opc == AMDGPU::V_PERMLANEX16_VAR_B32_e64_gfx13;
777 return Opc == AMDGPU::V_CVT_F32_BF8_e64_gfx12 ||
778 Opc == AMDGPU::V_CVT_F32_FP8_e64_gfx12 ||
779 Opc == AMDGPU::V_CVT_F32_BF8_e64_dpp_gfx12 ||
780 Opc == AMDGPU::V_CVT_F32_FP8_e64_dpp_gfx12 ||
781 Opc == AMDGPU::V_CVT_F32_BF8_e64_dpp8_gfx12 ||
782 Opc == AMDGPU::V_CVT_F32_FP8_e64_dpp8_gfx12 ||
783 Opc == AMDGPU::V_CVT_PK_F32_BF8_fake16_e64_gfx12 ||
784 Opc == AMDGPU::V_CVT_PK_F32_FP8_fake16_e64_gfx12 ||
785 Opc == AMDGPU::V_CVT_PK_F32_BF8_t16_e64_gfx12 ||
786 Opc == AMDGPU::V_CVT_PK_F32_FP8_t16_e64_gfx12;
790 return Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SWAP ||
791 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_ADD ||
792 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SUB ||
793 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SMIN ||
794 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_UMIN ||
795 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SMAX ||
796 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_UMAX ||
797 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_AND ||
798 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_OR ||
799 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_XOR ||
800 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_INC ||
801 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_DEC ||
802 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FADD ||
803 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FMIN ||
804 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FMAX ||
805 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_CMPSWAP ||
806 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SUB_CLAMP_U32 ||
807 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_COND_SUB_U32 ||
808 Opc == AMDGPU::G_AMDGPU_ATOMIC_CMPXCHG;
812 return Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B8_gfx1250 ||
813 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B32_gfx1250 ||
814 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B64_gfx1250 ||
815 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B128_gfx1250 ||
816 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B8_SADDR_gfx1250 ||
817 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B32_SADDR_gfx1250 ||
818 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B64_SADDR_gfx1250 ||
819 Opc == GLOBAL_STORE_ASYNC_FROM_LDS_B128_SADDR_gfx1250;
823 return Opc == TENSOR_STORE_FROM_LDS_d2_gfx1250 ||
824 Opc == TENSOR_STORE_FROM_LDS_d4_gfx1250;
845 return getVOP3PHasNoOpSelHiHelper(
Opc) !=
nullptr;
852 if (Info->HasFP8DstByteSel)
854 if (Info->HasFP4DstByteSel)
861 return isDPMACCInstructionHelper(
Opc) !=
nullptr;
866 return Info ? Info->Opcode3Addr : ~0u;
873 return getMCOpcodeGen(Opcode,
static_cast<Subtarget>(Gen));
880 case AMDGPU::V_AND_B32_e32:
882 case AMDGPU::V_OR_B32_e32:
884 case AMDGPU::V_XOR_B32_e32:
886 case AMDGPU::V_XNOR_B32_e32:
891int getVOPDFull(
unsigned OpX,
unsigned OpY,
unsigned EncodingFamily,
893 bool IsConvertibleToBitOp = VOPD3 ?
getBitOp2(OpY) : 0;
894 OpY = IsConvertibleToBitOp ? (
unsigned)AMDGPU::V_BITOP3_B32_e64 : OpY;
895 const VOPDInfo *Info = getVOPDInfoFromComponentOpcodes(
897 static_cast<uint8_t>(EncodingFamily), VOPD3);
898 return Info ? Info->Opcode : -1;
902 const VOPDInfo *Info = getVOPDOpcodeHelper(VOPDOpcode);
904 const auto *OpX = getVOPDBaseFromComponent(Info->OpX);
905 const auto *OpY = getVOPDBaseFromComponent(Info->OpY);
907 return {OpX->BaseVOP, OpY->BaseVOP};
919 HasSrc2Acc = TiedIdx != -1;
929 if (Opcode == AMDGPU::V_CNDMASK_B32_e32 ||
930 Opcode == AMDGPU::V_CNDMASK_B32_e64) {
936 }
else if (Opcode == AMDGPU::V_DOT2_F32_F16 ||
937 Opcode == AMDGPU::V_DOT2_F32_BF16) {
941 NumVOPD3Mods = SrcOperandsNum;
943 getNamedOperandIdx(Opcode, OpName::src0))) {
946 NumVOPD3Mods = SrcOperandsNum;
956 for (CompOprIdx =
Component::SRC1; CompOprIdx < OperandsNum; ++CompOprIdx) {
958 MandatoryLiteralIdx = CompOprIdx;
965 return getNamedOperandIdx(Opcode, OpName::bitop3);
983 std::function<
MCRegister(
unsigned,
unsigned)> GetRegIdx,
985 bool HasGFX11InterlockHazard)
const {
993 unsigned BanksMask) ->
bool {
1000 if ((BaseX.
id() & BanksMask) == (BaseY.
id() & BanksMask))
1003 ((BaseX.
id() + 1) & BanksMask) == (BaseY.
id() & BanksMask))
1006 (BaseX.
id() & BanksMask) == ((BaseY.
id() + 1) & BanksMask))
1014 unsigned CompOprIdx;
1017 : HasGFX11InterlockHazard
1020 if (!OpXRegs[CompOprIdx] || !OpYRegs[CompOprIdx])
1033 if (
MRI.regsOverlap(OpXRegs[CompOprIdx], OpYRegs[CompOprIdx]))
1039 if (banksOverlap(OpXRegs[CompOprIdx], OpYRegs[CompOprIdx], BanksMasks) &&
1041 OpXRegs[CompOprIdx] != OpYRegs[CompOprIdx]))
1056InstInfo::getRegIndices(
unsigned CompIdx,
1057 std::function<
MCRegister(
unsigned,
unsigned)> GetRegIdx,
1061 const auto &Comp = CompInfo[CompIdx];
1064 RegIndices[
DST] = GetRegIdx(CompIdx, Comp.getIndexOfDstInMCOperands());
1067 unsigned CompSrcIdx = CompOprIdx -
DST_NUM;
1069 Comp.hasRegSrcOperand(CompSrcIdx)
1070 ? GetRegIdx(CompIdx,
1071 Comp.getIndexOfSrcInMCOperands(CompSrcIdx, VOPD3))
1086 const auto &OpXDesc = InstrInfo->get(OpX);
1087 const auto &OpYDesc = InstrInfo->get(OpY);
1100 STI.
getCPU(), FeatureString);
1146 return 2 * Addressable;
1174 unsigned FlatWorkGroupSize) {
1175 assert(FlatWorkGroupSize != 0);
1187 unsigned MaxBarriers = 16;
1191 return std::min(MaxWaves /
N, MaxBarriers);
1195 unsigned FlatWorkGroupSize) {
1201 unsigned FlatWorkGroupSize) {
1218 unsigned WavesPerEU,
unsigned TrapReserve,
1220 assert(WavesPerEU != 0 && Granule != 0);
1221 unsigned Budget = TotalNumSGPRs / WavesPerEU;
1222 Budget -= std::min(Budget, TrapReserve);
1237 unsigned MinNumSGPRs =
1253 return Addressable ? AddressableNumSGPRs : 108;
1254 if (
Version.Major >= 8 && !Addressable)
1255 AddressableNumSGPRs = 112;
1259 return std::min(MaxNumSGPRs, AddressableNumSGPRs);
1269 bool FlatScrUsed,
bool XNACKUsed) {
1270 unsigned ExtraSGPRs = 0;
1295 return divideCeil(std::max(1u, NumRegs), Granule);
1305 unsigned DynamicVGPRBlockSize,
1306 std::optional<bool> EnableWavefrontSize32) {
1310 if (DynamicVGPRBlockSize != 0)
1311 return DynamicVGPRBlockSize;
1313 bool IsWave32 = EnableWavefrontSize32
1314 ? *EnableWavefrontSize32
1318 return IsWave32 ? 24 : 12;
1321 return IsWave32 ? 16 : 8;
1323 return IsWave32 ? 8 : 4;
1327 std::optional<bool> EnableWavefrontSize32) {
1331 bool IsWave32 = EnableWavefrontSize32
1332 ? *EnableWavefrontSize32
1336 return IsWave32 ? 16 : 8;
1338 return IsWave32 ? 8 : 4;
1345 if (Features.test(FeatureVGPRMSBs))
1346 return Features.
test(FeatureWavefrontSize32) ? 1024 : 512;
1351 unsigned DynamicVGPRBlockSize) {
1353 if (Features.test(FeatureGFX90AInsts))
1356 if (DynamicVGPRBlockSize != 0) {
1366 unsigned DynamicVGPRBlockSize) {
1376 unsigned TotalNumVGPRs) {
1377 if (NumVGPRs < Granule)
1379 unsigned RoundedRegs =
alignTo(NumVGPRs, Granule);
1380 return std::min(std::max(TotalNumVGPRs / RoundedRegs, 1u), MaxWaves);
1384 unsigned TotalNumSGPRs,
unsigned Granule,
1385 unsigned TrapReserve) {
1389 unsigned PerWave =
alignTo(SGPRs, Granule) + TrapReserve;
1390 return PerWave ? std::clamp(TotalNumSGPRs / PerWave, 1u, MaxWaves) : MaxWaves;
1406 unsigned DynamicVGPRBlockSize) {
1413 bool DynamicVGPREnabled = (DynamicVGPRBlockSize != 0);
1414 if (DynamicVGPREnabled)
1419 if (WavesPerEU >= MaxWavesPerEU)
1424 unsigned AddrsableNumVGPRs =
1427 unsigned MaxNumVGPRs =
alignDown(TotNumVGPRs / WavesPerEU, Granule);
1429 if (MaxNumVGPRs ==
alignDown(TotNumVGPRs / MaxWavesPerEU, Granule))
1433 DynamicVGPRBlockSize);
1434 if (WavesPerEU < MinWavesPerEU)
1437 unsigned MaxNumVGPRsNext =
alignDown(TotNumVGPRs / (WavesPerEU + 1), Granule);
1438 unsigned MinNumVGPRs = 1 + std::min(MaxNumVGPRs - Granule, MaxNumVGPRsNext);
1439 return std::min(MinNumVGPRs, AddrsableNumVGPRs);
1443 unsigned DynamicVGPRBlockSize) {
1451 bool DynamicVGPREnabled = (DynamicVGPRBlockSize != 0);
1452 unsigned MaxNumVGPRs =
1457 unsigned AddressableNumVGPRs =
1459 return std::min(MaxNumVGPRs, AddressableNumVGPRs);
1464 unsigned DynamicVGPRBlockSize,
1465 std::optional<bool> EnableWavefrontSize32) {
1517 return C ==
'v' ||
C ==
's' ||
C ==
'a';
1529 if (
RegName.consume_front(
"[")) {
1536 unsigned NumRegs =
End -
Idx + 1;
1538 return {Kind,
Idx, NumRegs};
1544 return {Kind,
Idx, 1};
1550std::tuple<char, unsigned, unsigned>
1558std::pair<unsigned, unsigned>
1560 std::pair<unsigned, unsigned>
Default,
1561 bool OnlyFirstRequired) {
1563 return {Attr->first, Attr->second.value_or(
Default.second)};
1567std::optional<std::pair<unsigned, std::optional<unsigned>>>
1569 bool OnlyFirstRequired) {
1571 if (!
A.isStringAttribute())
1572 return std::nullopt;
1575 std::pair<unsigned, std::optional<unsigned>> Ints;
1576 std::pair<StringRef, StringRef> Strs =
A.getValueAsString().split(
',');
1577 if (Strs.first.trim().getAsInteger(0, Ints.first)) {
1578 Ctx.emitError(
"can't parse first integer attribute " + Name);
1579 return std::nullopt;
1581 unsigned Second = 0;
1582 if (Strs.second.trim().getAsInteger(0, Second)) {
1583 if (!OnlyFirstRequired || !Strs.second.trim().empty()) {
1584 Ctx.emitError(
"can't parse second integer attribute " + Name);
1585 return std::nullopt;
1588 Ints.second = Second;
1596 unsigned DefaultVal) {
1597 std::optional<SmallVector<unsigned>> R =
1602std::optional<SmallVector<unsigned>>
1609 return std::nullopt;
1610 if (!
A.isStringAttribute()) {
1611 Ctx.emitError(Name +
" is not a string attribute");
1612 return std::nullopt;
1620 std::pair<StringRef, StringRef> Strs = S.
split(
',');
1622 if (Strs.first.trim().getAsInteger(0, IntVal)) {
1623 Ctx.emitError(
"can't parse integer attribute " + Strs.first +
" in " +
1625 return std::nullopt;
1632 Ctx.emitError(
"attribute " + Name +
1633 " has incorrect number of integers; expected " +
1635 return std::nullopt;
1642 std::numeric_limits<uint32_t>::max());
1657 if (
Low.ule(Val) &&
High.ugt(Val))
1660 if (
Low.uge(Val) &&
High.ult(Val))
1669 return (1 << (getVmcntBitWidthLo(
Version.Major) +
1670 getVmcntBitWidthHi(
Version.Major))) -
1675 return (1 << getLoadcntBitWidth(
Version.Major)) - 1;
1679 return (1 << getSamplecntBitWidth(
Version.Major)) - 1;
1683 return (1 << getBvhcntBitWidth(
Version.Major)) - 1;
1687 return (1 << getExpcntBitWidth(
Version.Major)) - 1;
1691 return (1 << getLgkmcntBitWidth(
Version.Major)) - 1;
1695 return (1 << getDscntBitWidth(
Version.Major)) - 1;
1699 return (1 << getKmcntBitWidth(
Version.Major)) - 1;
1707 return (1 << getAsynccntBitWidth(
Version.Major,
Version.Minor)) - 1;
1711 return (1 << getStorecntBitWidth(
Version.Major)) - 1;
1715 return (1 << getBarrierMemberCountBitWidth(
Version.Major)) - 1;
1719 unsigned VmcntLo = getBitMask(getVmcntBitShiftLo(
Version.Major),
1720 getVmcntBitWidthLo(
Version.Major));
1721 unsigned Expcnt = getBitMask(getExpcntBitShift(
Version.Major),
1722 getExpcntBitWidth(
Version.Major));
1723 unsigned Lgkmcnt = getBitMask(getLgkmcntBitShift(
Version.Major),
1724 getLgkmcntBitWidth(
Version.Major));
1725 unsigned VmcntHi = getBitMask(getVmcntBitShiftHi(
Version.Major),
1726 getVmcntBitWidthHi(
Version.Major));
1727 return VmcntLo | Expcnt | Lgkmcnt | VmcntHi;
1731 unsigned VmcntLo = unpackBits(
Waitcnt, getVmcntBitShiftLo(
Version.Major),
1732 getVmcntBitWidthLo(
Version.Major));
1733 unsigned VmcntHi = unpackBits(
Waitcnt, getVmcntBitShiftHi(
Version.Major),
1734 getVmcntBitWidthHi(
Version.Major));
1735 return VmcntLo | VmcntHi << getVmcntBitWidthLo(
Version.Major);
1740 getExpcntBitWidth(
Version.Major));
1745 getLgkmcntBitWidth(
Version.Major));
1749 return unpackBits(
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1750 getLoadcntBitWidth(
Version.Major));
1754 return unpackBits(
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1755 getStorecntBitWidth(
Version.Major));
1760 getDscntBitWidth(
Version.Major));
1764 unsigned &Expcnt,
unsigned &Lgkmcnt) {
1773 getVmcntBitWidthLo(
Version.Major));
1774 return packBits(Vmcnt >> getVmcntBitWidthLo(
Version.Major),
Waitcnt,
1775 getVmcntBitShiftHi(
Version.Major),
1776 getVmcntBitWidthHi(
Version.Major));
1781 return packBits(Expcnt,
Waitcnt, getExpcntBitShift(
Version.Major),
1782 getExpcntBitWidth(
Version.Major));
1787 return packBits(Lgkmcnt,
Waitcnt, getLgkmcntBitShift(
Version.Major),
1788 getLgkmcntBitWidth(
Version.Major));
1792 unsigned Expcnt,
unsigned Lgkmcnt) {
1802 unsigned Dscnt = getBitMask(getDscntBitShift(
Version.Major),
1803 getDscntBitWidth(
Version.Major));
1805 unsigned Storecnt = getBitMask(getLoadcntStorecntBitShift(
Version.Major),
1806 getStorecntBitWidth(
Version.Major));
1807 return Dscnt | Storecnt;
1809 unsigned Loadcnt = getBitMask(getLoadcntStorecntBitShift(
Version.Major),
1810 getLoadcntBitWidth(
Version.Major));
1811 return Dscnt | Loadcnt;
1816 return packBits(Loadcnt,
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1817 getLoadcntBitWidth(
Version.Major));
1821 unsigned Storecnt) {
1822 return packBits(Storecnt,
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1823 getStorecntBitWidth(
Version.Major));
1829 getDscntBitWidth(
Version.Major));
1853 int Size,
unsigned Code,
1854 bool &HasNonDefaultVal,
1856 unsigned UsedOprMask = 0;
1857 HasNonDefaultVal =
false;
1859 const auto &
Op = Opr[
Idx];
1860 if (!
Op.isSupported(STI))
1862 UsedOprMask |=
Op.getMask();
1863 unsigned Val =
Op.decode(Code);
1864 if (!
Op.isValid(Val))
1866 HasNonDefaultVal |= (Val !=
Op.Default);
1868 return (Code & ~UsedOprMask) == 0;
1873 unsigned &Val,
bool &IsDefault,
1876 const auto &
Op = Opr[
Idx++];
1877 if (
Op.isSupported(STI)) {
1879 Val =
Op.decode(Code);
1880 IsDefault = (Val ==
Op.Default);
1890 if (InputVal < 0 || InputVal >
Op.Max)
1892 return Op.encode(
static_cast<unsigned>(InputVal));
1897 unsigned &UsedOprMask,
1901 const auto &
Op = Opr[
Idx];
1902 if (
Op.Name == Name) {
1903 if (!
Op.isSupported(STI)) {
1907 auto OprMask =
Op.getMask();
1908 if (OprMask & UsedOprMask)
1910 UsedOprMask |= OprMask;
1927 if (
Op.isSupported(STI))
1928 Enc |=
Op.encode(
Op.Default);
1936 HasNonDefaultVal, STI);
1968 return unpackBits(Encoded, getVmVsrcBitShift(), getVmVsrcBitWidth());
1972 return unpackBits(Encoded, getVaVdstBitShift(), getVaVdstBitWidth());
1976 return unpackBits(Encoded, getSaSdstBitShift(), getSaSdstBitWidth());
1980 return unpackBits(Encoded, getVaSdstBitShift(), getVaSdstBitWidth());
1984 return unpackBits(Encoded, getVaVccBitShift(), getVaVccBitWidth());
1988 return unpackBits(Encoded, getVaSsrcBitShift(), getVaSsrcBitWidth());
1992 return unpackBits(Encoded, getHoldCntBitShift(),
1997 return packBits(VmVsrc, Encoded, getVmVsrcBitShift(), getVmVsrcBitWidth());
2006 return packBits(VaVdst, Encoded, getVaVdstBitShift(), getVaVdstBitWidth());
2015 return packBits(SaSdst, Encoded, getSaSdstBitShift(), getSaSdstBitWidth());
2024 return packBits(VaSdst, Encoded, getVaSdstBitShift(), getVaSdstBitWidth());
2033 return packBits(VaVcc, Encoded, getVaVccBitShift(), getVaVccBitWidth());
2042 return packBits(VaSsrc, Encoded, getVaSsrcBitShift(), getVaSsrcBitWidth());
2052 return packBits(HoldCnt, Encoded, getHoldCntBitShift(),
2089 if (Val.Tgt <= Id && Id <= Val.Tgt + Val.MaxIndex) {
2090 Index = (Val.MaxIndex == 0) ? -1 : (Id - Val.Tgt);
2101 if (Val.MaxIndex == 0 && Name == Val.Name)
2104 if (Val.MaxIndex > 0 && Name.starts_with(Val.Name)) {
2105 StringRef Suffix = Name.drop_front(Val.Name.size());
2112 if (Suffix.
size() > 1 && Suffix[0] ==
'0')
2115 return Val.Tgt + Id;
2144namespace MTBUFFormat {
2170 if (Name == lookupTable[Id])
2369 return static_cast<unsigned>(
2370 F.getFnAttributeAsParsedInteger(
"InitialPSInputAddr", 0));
2375 return F.getFnAttributeAsParsedInteger(
2376 "amdgpu-color-export",
2381 return F.getFnAttributeAsParsedInteger(
"amdgpu-depth-export", 0) != 0;
2385 unsigned BlockSize =
static_cast<unsigned>(
2386 F.getFnAttributeAsParsedInteger(
"amdgpu-dynamic-vgpr-block-size", 0));
2395 return STI.
hasFeature(AMDGPU::FeatureMIMG_R128) &&
2408 return !STI.
hasFeature(AMDGPU::FeatureUnpackedD16VMem) && !
isCI(STI) &&
2419 return Version.Minor >= 3 ? 13 : 5;
2423 return HasSampler ? 4 : 5;
2434 return STI.
hasFeature(AMDGPU::FeatureSouthernIslands);
2438 return STI.
hasFeature(AMDGPU::FeatureSeaIslands);
2442 return STI.
hasFeature(AMDGPU::FeatureVolcanicIslands);
2472 return STI.
hasFeature(AMDGPU::FeaturePopsExitingWaveID);
2476 return STI.
hasFeature(AMDGPU::FeatureApertureRegs) &&
2477 !STI.
hasFeature(AMDGPU::FeatureGloballyAddressableScratch);
2545 return STI.
hasFeature(AMDGPU::FeatureGCN3Encoding);
2549 return STI.
hasFeature(AMDGPU::FeatureGFX10_BEncoding);
2553 return STI.
hasFeature(AMDGPU::FeatureGFX10_3Insts);
2561 return STI.
hasFeature(AMDGPU::FeatureGFX90AInsts);
2565 return STI.
hasFeature(AMDGPU::FeatureGFX940Insts);
2569 return STI.
hasFeature(AMDGPU::FeatureArchitectedFlatScratch);
2573 return STI.
hasFeature(AMDGPU::FeatureMAIInsts);
2577 return STI.
hasFeature(AMDGPU::FeatureVOPDInsts);
2581 return STI.
hasFeature(AMDGPU::FeatureDPPSrc1SGPR);
2585 return STI.
hasFeature(AMDGPU::FeatureKernargPreload);
2590 if (has90AInsts && ArgNumAGPR)
2591 return alignTo(ArgNumVGPR, 4) + ArgNumAGPR;
2592 return std::max(ArgNumVGPR, ArgNumAGPR);
2597 TRI->getRegClass(AMDGPU::SReg_32RegClassID);
2599 return SGPRClass.
contains(FirstSubReg != 0 ? FirstSubReg :
Reg) ||
2604 return MRI.getRegClass(AMDGPU::RsrcReg32RegClassID).contains(
Reg);
2611#define MAP_REG2REG \
2612 using namespace AMDGPU; \
2613 switch (Reg.id()) { \
2616 CASE_CI_VI(FLAT_SCR) \
2617 CASE_CI_VI(FLAT_SCR_LO) \
2618 CASE_CI_VI(FLAT_SCR_HI) \
2619 CASE_VI_GFX9PLUS(TTMP0) \
2620 CASE_VI_GFX9PLUS(TTMP1) \
2621 CASE_VI_GFX9PLUS(TTMP2) \
2622 CASE_VI_GFX9PLUS(TTMP3) \
2623 CASE_VI_GFX9PLUS(TTMP4) \
2624 CASE_VI_GFX9PLUS(TTMP5) \
2625 CASE_VI_GFX9PLUS(TTMP6) \
2626 CASE_VI_GFX9PLUS(TTMP7) \
2627 CASE_VI_GFX9PLUS(TTMP8) \
2628 CASE_VI_GFX9PLUS(TTMP9) \
2629 CASE_VI_GFX9PLUS(TTMP10) \
2630 CASE_VI_GFX9PLUS(TTMP11) \
2631 CASE_VI_GFX9PLUS(TTMP12) \
2632 CASE_VI_GFX9PLUS(TTMP13) \
2633 CASE_VI_GFX9PLUS(TTMP14) \
2634 CASE_VI_GFX9PLUS(TTMP15) \
2635 CASE_VI_GFX9PLUS(TTMP0_TTMP1) \
2636 CASE_VI_GFX9PLUS(TTMP2_TTMP3) \
2637 CASE_VI_GFX9PLUS(TTMP4_TTMP5) \
2638 CASE_VI_GFX9PLUS(TTMP6_TTMP7) \
2639 CASE_VI_GFX9PLUS(TTMP8_TTMP9) \
2640 CASE_VI_GFX9PLUS(TTMP10_TTMP11) \
2641 CASE_VI_GFX9PLUS(TTMP12_TTMP13) \
2642 CASE_VI_GFX9PLUS(TTMP14_TTMP15) \
2643 CASE_VI_GFX9PLUS(TTMP0_TTMP1_TTMP2_TTMP3) \
2644 CASE_VI_GFX9PLUS(TTMP4_TTMP5_TTMP6_TTMP7) \
2645 CASE_VI_GFX9PLUS(TTMP8_TTMP9_TTMP10_TTMP11) \
2646 CASE_VI_GFX9PLUS(TTMP12_TTMP13_TTMP14_TTMP15) \
2647 CASE_VI_GFX9PLUS(TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7) \
2648 CASE_VI_GFX9PLUS(TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11) \
2649 CASE_VI_GFX9PLUS(TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15) \
2651 TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15) \
2652 CASE_GFXPRE11_GFX11PLUS(M0) \
2653 CASE_GFXPRE11_GFX11PLUS(SGPR_NULL) \
2654 CASE_GFXPRE11_GFX11PLUS_TO(SGPR_NULL64, SGPR_NULL) \
2657#define CASE_CI_VI(node) \
2658 assert(!isSI(STI)); \
2660 return isCI(STI) ? node##_ci : node##_vi;
2662#define CASE_VI_GFX9PLUS(node) \
2664 return isGFX9Plus(STI) ? node##_gfx9plus : node##_vi;
2666#define CASE_GFXPRE11_GFX11PLUS(node) \
2668 return isGFX11Plus(STI) ? node##_gfx11plus : node##_gfxpre11;
2670#define CASE_GFXPRE11_GFX11PLUS_TO(node, result) \
2672 return isGFX11Plus(STI) ? result##_gfx11plus : result##_gfxpre11;
2681#undef CASE_VI_GFX9PLUS
2682#undef CASE_GFXPRE11_GFX11PLUS
2683#undef CASE_GFXPRE11_GFX11PLUS_TO
2685#define CASE_CI_VI(node) \
2689#define CASE_VI_GFX9PLUS(node) \
2691 case node##_gfx9plus: \
2693#define CASE_GFXPRE11_GFX11PLUS(node) \
2694 case node##_gfx11plus: \
2695 case node##_gfxpre11: \
2697#define CASE_GFXPRE11_GFX11PLUS_TO(node, result)
2703 case AMDGPU::SRC_SHARED_BASE_LO:
2704 case AMDGPU::SRC_SHARED_BASE:
2705 case AMDGPU::SRC_SHARED_LIMIT_LO:
2706 case AMDGPU::SRC_SHARED_LIMIT:
2707 case AMDGPU::SRC_PRIVATE_BASE_LO:
2708 case AMDGPU::SRC_PRIVATE_BASE:
2709 case AMDGPU::SRC_PRIVATE_LIMIT_LO:
2710 case AMDGPU::SRC_PRIVATE_LIMIT:
2711 case AMDGPU::SRC_FLAT_SCRATCH_BASE_LO:
2712 case AMDGPU::SRC_FLAT_SCRATCH_BASE_HI:
2713 case AMDGPU::SRC_POPS_EXITING_WAVE_ID:
2715 case AMDGPU::SRC_VCCZ:
2716 case AMDGPU::SRC_EXECZ:
2717 case AMDGPU::SRC_SCC:
2719 case AMDGPU::SGPR_NULL:
2727#undef CASE_VI_GFX9PLUS
2728#undef CASE_GFXPRE11_GFX11PLUS
2729#undef CASE_GFXPRE11_GFX11PLUS_TO
2734 unsigned OpType =
Desc.operands()[OpNo].OperandType;
2741 unsigned OpType =
Desc.operands()[OpNo].OperandType;
2768 case AMDGPU::VGPR_16RegClassID:
2769 case AMDGPU::VGPR_16_Lo128RegClassID:
2770 case AMDGPU::SGPR_LO16RegClassID:
2771 case AMDGPU::AGPR_LO16RegClassID:
2773 case AMDGPU::SGPR_32RegClassID:
2774 case AMDGPU::VGPR_32RegClassID:
2775 case AMDGPU::VGPR_32_Lo256RegClassID:
2776 case AMDGPU::VRegOrLds_32RegClassID:
2777 case AMDGPU::AGPR_32RegClassID:
2778 case AMDGPU::VS_32RegClassID:
2779 case AMDGPU::AV_32RegClassID:
2780 case AMDGPU::SReg_32RegClassID:
2781 case AMDGPU::SReg_32_XM0RegClassID:
2782 case AMDGPU::SRegOrLds_32RegClassID:
2784 case AMDGPU::SGPR_64RegClassID:
2785 case AMDGPU::VS_64RegClassID:
2786 case AMDGPU::SReg_64RegClassID:
2787 case AMDGPU::VReg_64RegClassID:
2788 case AMDGPU::AReg_64RegClassID:
2789 case AMDGPU::SReg_64_XEXECRegClassID:
2790 case AMDGPU::VReg_64_Align2RegClassID:
2791 case AMDGPU::AReg_64_Align2RegClassID:
2792 case AMDGPU::AV_64RegClassID:
2793 case AMDGPU::AV_64_Align2RegClassID:
2794 case AMDGPU::VReg_64_Lo256_Align2RegClassID:
2795 case AMDGPU::VS_64_Lo256RegClassID:
2797 case AMDGPU::SGPR_96RegClassID:
2798 case AMDGPU::SReg_96RegClassID:
2799 case AMDGPU::VReg_96RegClassID:
2800 case AMDGPU::AReg_96RegClassID:
2801 case AMDGPU::VReg_96_Align2RegClassID:
2802 case AMDGPU::AReg_96_Align2RegClassID:
2803 case AMDGPU::AV_96RegClassID:
2804 case AMDGPU::AV_96_Align2RegClassID:
2805 case AMDGPU::VReg_96_Lo256_Align2RegClassID:
2807 case AMDGPU::SGPR_128RegClassID:
2808 case AMDGPU::SReg_128RegClassID:
2809 case AMDGPU::VReg_128RegClassID:
2810 case AMDGPU::AReg_128RegClassID:
2811 case AMDGPU::VReg_128_Align2RegClassID:
2812 case AMDGPU::AReg_128_Align2RegClassID:
2813 case AMDGPU::AV_128RegClassID:
2814 case AMDGPU::AV_128_Align2RegClassID:
2815 case AMDGPU::SReg_128_XNULLRegClassID:
2816 case AMDGPU::VReg_128_Lo256_Align2RegClassID:
2818 case AMDGPU::SGPR_160RegClassID:
2819 case AMDGPU::SReg_160RegClassID:
2820 case AMDGPU::VReg_160RegClassID:
2821 case AMDGPU::AReg_160RegClassID:
2822 case AMDGPU::VReg_160_Align2RegClassID:
2823 case AMDGPU::AReg_160_Align2RegClassID:
2824 case AMDGPU::AV_160RegClassID:
2825 case AMDGPU::AV_160_Align2RegClassID:
2826 case AMDGPU::VReg_160_Lo256_Align2RegClassID:
2828 case AMDGPU::SGPR_192RegClassID:
2829 case AMDGPU::SReg_192RegClassID:
2830 case AMDGPU::VReg_192RegClassID:
2831 case AMDGPU::AReg_192RegClassID:
2832 case AMDGPU::VReg_192_Align2RegClassID:
2833 case AMDGPU::AReg_192_Align2RegClassID:
2834 case AMDGPU::AV_192RegClassID:
2835 case AMDGPU::AV_192_Align2RegClassID:
2836 case AMDGPU::VReg_192_Lo256_Align2RegClassID:
2838 case AMDGPU::SGPR_224RegClassID:
2839 case AMDGPU::SReg_224RegClassID:
2840 case AMDGPU::VReg_224RegClassID:
2841 case AMDGPU::AReg_224RegClassID:
2842 case AMDGPU::VReg_224_Align2RegClassID:
2843 case AMDGPU::AReg_224_Align2RegClassID:
2844 case AMDGPU::AV_224RegClassID:
2845 case AMDGPU::AV_224_Align2RegClassID:
2846 case AMDGPU::VReg_224_Lo256_Align2RegClassID:
2848 case AMDGPU::SGPR_256RegClassID:
2849 case AMDGPU::SReg_256RegClassID:
2850 case AMDGPU::VReg_256RegClassID:
2851 case AMDGPU::AReg_256RegClassID:
2852 case AMDGPU::VReg_256_Align2RegClassID:
2853 case AMDGPU::AReg_256_Align2RegClassID:
2854 case AMDGPU::AV_256RegClassID:
2855 case AMDGPU::AV_256_Align2RegClassID:
2856 case AMDGPU::SReg_256_XNULLRegClassID:
2857 case AMDGPU::VReg_256_Lo256_Align2RegClassID:
2859 case AMDGPU::SGPR_288RegClassID:
2860 case AMDGPU::SReg_288RegClassID:
2861 case AMDGPU::VReg_288RegClassID:
2862 case AMDGPU::AReg_288RegClassID:
2863 case AMDGPU::VReg_288_Align2RegClassID:
2864 case AMDGPU::AReg_288_Align2RegClassID:
2865 case AMDGPU::AV_288RegClassID:
2866 case AMDGPU::AV_288_Align2RegClassID:
2867 case AMDGPU::VReg_288_Lo256_Align2RegClassID:
2869 case AMDGPU::SGPR_320RegClassID:
2870 case AMDGPU::SReg_320RegClassID:
2871 case AMDGPU::VReg_320RegClassID:
2872 case AMDGPU::AReg_320RegClassID:
2873 case AMDGPU::VReg_320_Align2RegClassID:
2874 case AMDGPU::AReg_320_Align2RegClassID:
2875 case AMDGPU::AV_320RegClassID:
2876 case AMDGPU::AV_320_Align2RegClassID:
2877 case AMDGPU::VReg_320_Lo256_Align2RegClassID:
2879 case AMDGPU::SGPR_352RegClassID:
2880 case AMDGPU::SReg_352RegClassID:
2881 case AMDGPU::VReg_352RegClassID:
2882 case AMDGPU::AReg_352RegClassID:
2883 case AMDGPU::VReg_352_Align2RegClassID:
2884 case AMDGPU::AReg_352_Align2RegClassID:
2885 case AMDGPU::AV_352RegClassID:
2886 case AMDGPU::AV_352_Align2RegClassID:
2887 case AMDGPU::VReg_352_Lo256_Align2RegClassID:
2889 case AMDGPU::SGPR_384RegClassID:
2890 case AMDGPU::SReg_384RegClassID:
2891 case AMDGPU::VReg_384RegClassID:
2892 case AMDGPU::AReg_384RegClassID:
2893 case AMDGPU::VReg_384_Align2RegClassID:
2894 case AMDGPU::AReg_384_Align2RegClassID:
2895 case AMDGPU::AV_384RegClassID:
2896 case AMDGPU::AV_384_Align2RegClassID:
2897 case AMDGPU::VReg_384_Lo256_Align2RegClassID:
2899 case AMDGPU::SGPR_512RegClassID:
2900 case AMDGPU::SReg_512RegClassID:
2901 case AMDGPU::VReg_512RegClassID:
2902 case AMDGPU::AReg_512RegClassID:
2903 case AMDGPU::VReg_512_Align2RegClassID:
2904 case AMDGPU::AReg_512_Align2RegClassID:
2905 case AMDGPU::AV_512RegClassID:
2906 case AMDGPU::AV_512_Align2RegClassID:
2907 case AMDGPU::VReg_512_Lo256_Align2RegClassID:
2909 case AMDGPU::SGPR_1024RegClassID:
2910 case AMDGPU::SReg_1024RegClassID:
2911 case AMDGPU::VReg_1024RegClassID:
2912 case AMDGPU::AReg_1024RegClassID:
2913 case AMDGPU::VReg_1024_Align2RegClassID:
2914 case AMDGPU::AReg_1024_Align2RegClassID:
2915 case AMDGPU::AV_1024RegClassID:
2916 case AMDGPU::AV_1024_Align2RegClassID:
2917 case AMDGPU::VReg_1024_Lo256_Align2RegClassID:
2942 (Val == 0x3fc45f306dc9c882 && HasInv2Pi);
2968 (Val == 0x3e22f983 && HasInv2Pi);
2981 return Val == 0x3F00 ||
3002 return Val == 0x3C00 ||
3029 return 192 + std::abs(
Signed);
3034 case 0x3800:
return 240;
3035 case 0xB800:
return 241;
3036 case 0x3C00:
return 242;
3037 case 0xBC00:
return 243;
3038 case 0x4000:
return 244;
3039 case 0xC000:
return 245;
3040 case 0x4400:
return 246;
3041 case 0xC400:
return 247;
3042 case 0x3118:
return 248;
3049 case 0x3F000000:
return 240;
3050 case 0xBF000000:
return 241;
3051 case 0x3F800000:
return 242;
3052 case 0xBF800000:
return 243;
3053 case 0x40000000:
return 244;
3054 case 0xC0000000:
return 245;
3055 case 0x40800000:
return 246;
3056 case 0xC0800000:
return 247;
3057 case 0x3E22F983:
return 248;
3080 return 192 + std::abs(
Signed);
3084 case 0x3F00:
return 240;
3085 case 0xBF00:
return 241;
3086 case 0x3F80:
return 242;
3087 case 0xBF80:
return 243;
3088 case 0x4000:
return 244;
3089 case 0xC000:
return 245;
3090 case 0x4080:
return 246;
3091 case 0xC080:
return 247;
3092 case 0x3E22:
return 248;
3097 return std::nullopt;
3124 return 192 + std::abs(
Signed);
3130 return std::nullopt;
3191 return Imm & 0xffff;
3234 return A->hasAttribute(Attribute::InReg) ||
3235 A->hasAttribute(Attribute::ByVal);
3238 return A->hasAttribute(Attribute::InReg);
3273 int64_t EncodedOffset) {
3282 int64_t EncodedOffset,
bool IsBuffer) {
3284 if (IsBuffer && EncodedOffset < 0)
3293 return (ByteOffset & 3) == 0;
3302 return ByteOffset >> 2;
3306 int64_t ByteOffset,
bool IsBuffer,
3312 return std::nullopt;
3315 return isInt<24>(ByteOffset) ? std::optional<int64_t>(ByteOffset)
3321 return isInt<20>(ByteOffset) ? std::optional<int64_t>(ByteOffset)
3326 return std::nullopt;
3330 ? std::optional<int64_t>(EncodedOffset)
3335 int64_t ByteOffset) {
3337 return std::nullopt;
3340 return isUInt<32>(EncodedOffset) ? std::optional<int64_t>(EncodedOffset)
3345 if (ST.getFeatureBits().test(FeatureFlatOffsetBits12))
3347 if (ST.getFeatureBits().test(FeatureFlatOffsetBits24))
3354struct SourceOfDivergence {
3357const SourceOfDivergence *lookupSourceOfDivergence(
unsigned Intr);
3362const AlwaysUniform *lookupAlwaysUniform(
unsigned Intr);
3364struct LDSDMAIntrinsic {
3367const LDSDMAIntrinsic *lookupLDSDMAIntrinsic(
unsigned Intr);
3369struct ExponentOnlyScaleIntrinsic {
3373const ExponentOnlyScaleIntrinsic *
3374lookupExponentOnlyScaleIntrinsic(
unsigned Intr);
3376#define GET_SourcesOfDivergence_IMPL
3377#define GET_UniformIntrinsics_IMPL
3378#define GET_LDSDMAIntrinsicTable_IMPL
3379#define GET_ExponentOnlyScaleIntrinsics_IMPL
3380#define GET_Gfx9BufferFormat_IMPL
3381#define GET_Gfx10BufferFormat_IMPL
3382#define GET_Gfx11PlusBufferFormat_IMPL
3384#include "AMDGPUGenSearchableTables.inc"
3389 return lookupSourceOfDivergence(IntrID);
3393 return lookupAlwaysUniform(IntrID);
3416 return lookupLDSDMAIntrinsic(IntrID);
3420 if (
const ExponentOnlyScaleIntrinsic *Info =
3421 lookupExponentOnlyScaleIntrinsic(IntrID))
3422 return Info->ScaleArg;
3423 return std::nullopt;
3430 return isGFX11Plus(STI) ? getGfx11PlusBufferFormatInfo(
3431 BitsPerComp, NumComponents, NumFormat)
3433 ? getGfx10BufferFormatInfo(BitsPerComp, NumComponents, NumFormat)
3434 : getGfx9BufferFormatInfo(BitsPerComp, NumComponents, NumFormat);
3441 : getGfx9BufferFormatInfo(
Format);
3446 const unsigned VGPRClasses[] = {
3447 AMDGPU::VGPR_16RegClassID, AMDGPU::VGPR_32RegClassID,
3448 AMDGPU::VReg_64RegClassID, AMDGPU::VReg_96RegClassID,
3449 AMDGPU::VReg_128RegClassID, AMDGPU::VReg_160RegClassID,
3450 AMDGPU::VReg_192RegClassID, AMDGPU::VReg_224RegClassID,
3451 AMDGPU::VReg_256RegClassID, AMDGPU::VReg_288RegClassID,
3452 AMDGPU::VReg_320RegClassID, AMDGPU::VReg_352RegClassID,
3453 AMDGPU::VReg_384RegClassID, AMDGPU::VReg_512RegClassID,
3454 AMDGPU::VReg_1024RegClassID};
3456 for (
unsigned RCID : VGPRClasses) {
3466 unsigned Enc =
MRI.getEncodingValue(
Reg);
3473 unsigned Enc =
MRI.getEncodingValue(
Reg);
3483 if (RC->
getID() == AMDGPU::VGPR_16RegClassID) {
3493static std::optional<unsigned>
3495 bool HasSetregVGPRMSBFixup) {
3496 constexpr unsigned VGPRMSBShift =
3501 (!HasSetregVGPRMSBFixup && (
Offset +
Size) < VGPRMSBShift))
3504 if (!HasSetregVGPRMSBFixup)
3507 if (!HasSetregVGPRMSBFixup)
3513 bool HasSetregVGPRMSBFixup) {
3514 assert(
MI.getOpcode() == AMDGPU::S_SETREG_IMM32_B32);
3516 MI.getOperand(1).getImm(),
3517 HasSetregVGPRMSBFixup);
3521 bool HasSetregVGPRMSBFixup) {
3522 assert(
MI.getOpcode() == AMDGPU::S_SETREG_IMM32_B32_gfx12);
3524 MI.getOperand(1).getImm(),
3525 HasSetregVGPRMSBFixup);
3528std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
3530 static const AMDGPU::OpName VOPOps[4] = {
3531 AMDGPU::OpName::src0, AMDGPU::OpName::src1, AMDGPU::OpName::src2,
3532 AMDGPU::OpName::vdst};
3533 static const AMDGPU::OpName VDSOps[4] = {
3534 AMDGPU::OpName::addr, AMDGPU::OpName::data0, AMDGPU::OpName::data1,
3535 AMDGPU::OpName::vdst};
3536 static const AMDGPU::OpName FLATOps[4] = {
3537 AMDGPU::OpName::vaddr, AMDGPU::OpName::vdata,
3538 AMDGPU::OpName::NUM_OPERAND_NAMES, AMDGPU::OpName::vdst};
3539 static const AMDGPU::OpName BUFOps[4] = {
3540 AMDGPU::OpName::vaddr, AMDGPU::OpName::NUM_OPERAND_NAMES,
3541 AMDGPU::OpName::NUM_OPERAND_NAMES, AMDGPU::OpName::vdata};
3542 static const AMDGPU::OpName VIMGOps[4] = {
3543 AMDGPU::OpName::vaddr0, AMDGPU::OpName::vaddr1, AMDGPU::OpName::vaddr2,
3544 AMDGPU::OpName::vdata};
3549 static const AMDGPU::OpName VOPDOpsX[4] = {
3550 AMDGPU::OpName::src0X, AMDGPU::OpName::vsrc1X, AMDGPU::OpName::vsrc2X,
3551 AMDGPU::OpName::vdstX};
3552 static const AMDGPU::OpName VOPDOpsY[4] = {
3553 AMDGPU::OpName::src0Y, AMDGPU::OpName::vsrc1Y, AMDGPU::OpName::vsrc2Y,
3554 AMDGPU::OpName::vdstY};
3557 static const AMDGPU::OpName VOP2MADMKOps[4] = {
3558 AMDGPU::OpName::src0, AMDGPU::OpName::NUM_OPERAND_NAMES,
3559 AMDGPU::OpName::src1, AMDGPU::OpName::vdst};
3560 static const AMDGPU::OpName VOPDFMAMKOpsX[4] = {
3561 AMDGPU::OpName::src0X, AMDGPU::OpName::NUM_OPERAND_NAMES,
3562 AMDGPU::OpName::vsrc1X, AMDGPU::OpName::vdstX};
3563 static const AMDGPU::OpName VOPDFMAMKOpsY[4] = {
3564 AMDGPU::OpName::src0Y, AMDGPU::OpName::NUM_OPERAND_NAMES,
3565 AMDGPU::OpName::vsrc1Y, AMDGPU::OpName::vdstY};
3570 switch (
Desc.getOpcode()) {
3572 case AMDGPU::V_WMMA_LD_SCALE_PAIRED_B32:
3573 case AMDGPU::V_WMMA_LD_SCALE_PAIRED_B32_gfx1250:
3574 case AMDGPU::V_WMMA_LD_SCALE16_PAIRED_B64:
3575 case AMDGPU::V_WMMA_LD_SCALE16_PAIRED_B64_gfx1250:
3577 case AMDGPU::V_FMAMK_F16:
3578 case AMDGPU::V_FMAMK_F16_t16:
3579 case AMDGPU::V_FMAMK_F16_t16_gfx12:
3580 case AMDGPU::V_FMAMK_F16_fake16:
3581 case AMDGPU::V_FMAMK_F16_fake16_gfx12:
3582 case AMDGPU::V_FMAMK_F32:
3583 case AMDGPU::V_FMAMK_F32_gfx12:
3584 case AMDGPU::V_FMAMK_F64:
3585 case AMDGPU::V_FMAMK_F64_gfx1250:
3586 return {VOP2MADMKOps,
nullptr};
3590 return {VOPOps,
nullptr};
3594 return {VDSOps,
nullptr};
3597 return {FLATOps,
nullptr};
3600 return {BUFOps,
nullptr};
3603 return {VIMGOps,
nullptr};
3607 return {(OpX == AMDGPU::V_FMAMK_F32) ? VOPDFMAMKOpsX : VOPDOpsX,
3608 (OpY == AMDGPU::V_FMAMK_F32) ? VOPDFMAMKOpsY : VOPDOpsY};
3615 " these instructions are not expected on gfx1250");
3641 for (
auto OpName : {OpName::vdst, OpName::src0, OpName::src1, OpName::src2}) {
3649 if (RegClass == AMDGPU::VReg_64RegClassID ||
3650 RegClass == AMDGPU::VReg_64_Align2RegClassID)
3659 case AMDGPU::V_MUL_LO_U32_e64:
3660 case AMDGPU::V_MUL_LO_U32_e64_dpp:
3661 case AMDGPU::V_MUL_LO_U32_e64_dpp_gfx1250:
3662 case AMDGPU::V_MUL_HI_U32_e64:
3663 case AMDGPU::V_MUL_HI_U32_e64_dpp:
3664 case AMDGPU::V_MUL_HI_U32_e64_dpp_gfx1250:
3665 case AMDGPU::V_MUL_HI_I32_e64:
3666 case AMDGPU::V_MUL_HI_I32_e64_dpp:
3667 case AMDGPU::V_MUL_HI_I32_e64_dpp_gfx1250:
3668 case AMDGPU::V_MAD_U32_e64:
3669 case AMDGPU::V_MAD_U32_e64_dpp:
3670 case AMDGPU::V_MAD_U32_e64_dpp_gfx1250:
3687 case AMDGPU::V_PK_ADD_F32_gfx1250:
3688 case AMDGPU::V_PK_ADD_F32_gfx1250_gfx12:
3689 case AMDGPU::V_PK_MUL_F32_gfx1250:
3690 case AMDGPU::V_PK_MUL_F32_gfx1250_gfx12:
3691 case AMDGPU::V_PK_FMA_F32_gfx1250:
3692 case AMDGPU::V_PK_FMA_F32_gfx1250_gfx12:
3702 case AMDGPU::V_PK_ADD_F64:
3703 case AMDGPU::V_PK_MUL_F64:
3704 case AMDGPU::V_PK_FMA_F64:
3705 case AMDGPU::V_PK_MAX_NUM_F64:
3706 case AMDGPU::V_PK_MIN_NUM_F64:
3707 case AMDGPU::V_PK_ADD_NC_U64:
3708 case AMDGPU::V_PK_SUB_NC_U64:
3709 case AMDGPU::V_PK_LSHL_ADD_U64:
3733 OS << EncoNoCluster <<
',' << EncoNoCluster <<
',' << EncoNoCluster;
3734 return Buffer.
c_str();
3737 OS << EncoVariableDims <<
',' << EncoVariableDims <<
','
3738 << EncoVariableDims;
3739 return Buffer.
c_str();
3742 OS << Dims[0] <<
',' << Dims[1] <<
',' << Dims[2];
3743 return Buffer.
c_str();
3750 std::optional<SmallVector<unsigned>> Attr =
3754 if (!Attr.has_value())
3763 A.Dims = {(*Attr)[0], (*Attr)[1], (*Attr)[2]};
3784 if (Result.isDenormal())
3789 if (!Result.isZero() && !Result.isInfinity() && !Result.isNaN() &&
3790 !Result.isOne() && !Result.isMinusOne())
3791 return std::nullopt;
3800 case (AMDGPU::TargetIDSetting::Unsupported):
3801 OS <<
"Unsupported";
3803 case (AMDGPU::TargetIDSetting::Any):
3806 case (AMDGPU::TargetIDSetting::Off):
3809 case (AMDGPU::TargetIDSetting::On):
const AArch64Subtarget & Subtarget
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static llvm::cl::opt< unsigned > DefaultAMDHSACodeObjectVersion("amdhsa-code-object-version", llvm::cl::Hidden, llvm::cl::init(llvm::AMDGPU::AMDHSA_COV6), llvm::cl::desc("Set default AMDHSA Code Object Version (module flag " "or asm directive still take priority if present)"))
Provides AMDGPU specific target descriptions.
MC layer struct for AMDGPUMCKernelCodeT, provides MCExpr functionality where required.
@ AMD_CODE_PROPERTY_ENABLE_WAVEFRONT_SIZE32
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Register const TargetRegisterInfo * TRI
uint64_t IntrinsicInst * II
MachineRegisterInfo & MRI
static bool isValid(const char C)
Returns true if C is a valid mangled character: <0-9a-zA-Z_>.
#define S_00B848_MEM_ORDERED(x)
#define S_00B848_WGP_MODE(x)
#define S_00B848_FWD_PROGRESS(x)
static const int BlockSize
static ClusterDimsAttr get(const Function &F)
ClusterDimsAttr()=default
std::string to_string() const
const std::array< unsigned, 3 > & getDims() const
static TargetID createFromSubtargetFeatures(const Triple &TT, StringRef CPU, StringRef FeatureString)
Construct a TargetID for triple TT and processor CPU, taking the xnack/sramecc modes from the subtarg...
unsigned getIndexInParsedOperands(unsigned CompOprIdx) const
unsigned getIndexOfDstInParsedOperands() const
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
int getBitOp3OperandIdx() const
unsigned getCompParsedSrcOperandsNum() const
std::optional< unsigned > getInvalidCompOperandIndex(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false, bool HasGFX11InterlockHazard=false) const
std::array< MCRegister, Component::MAX_OPR_NUM > RegIndices
Represents the counter values to wait for in an s_waitcnt instruction.
static const fltSemantics & BFloat()
static const fltSemantics & IEEEhalf()
const fltSemantics & getSemantics() const
static APFloat getOne(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative One.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
This class represents an incoming formal argument to a Function.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
CallingConv::ID getCallingConv() const
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
bool isByValArgument(unsigned ArgNo) const
Determine whether this argument is passed by value.
constexpr bool test(unsigned I) const
unsigned getAddressSpace() const
This is an important class for using LLVM in a threaded context.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool mayLoad() const
Return true if this instruction could possibly read memory.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
int getOperandConstraint(unsigned OpNum, MCOI::OperandConstraint Constraint) const
Returns the value of the specified operand constraint if it is present.
unsigned getOpcode() const
Return the opcode number for this descriptor.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
int16_t getOpRegClassID(const MCOperandInfo &OpInfo, unsigned HwModeId) const
Return the ID of the register class to use for OpInfo, for the active HwMode HwModeId.
This holds information about one operand of a machine instruction, indicating the register class for ...
MCRegisterClass - Base class of TargetRegisterClass.
unsigned getID() const
getID() - Return the register class ID number.
MCRegister getRegister(unsigned i) const
getRegister - Return the specified register in the class.
bool contains(MCRegister Reg) const
contains - Return true if the specified register is included in this register class.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
constexpr unsigned id() const
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
const FeatureBitset & getFeatureBits() const
const MDOperand & getOperand(unsigned I) const
unsigned getNumOperands() const
Return number of MDNode operands.
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
constexpr bool empty() const
Check if the string is empty.
constexpr size_t size() const
Get the string size.
Triple - Helper class for working with autoconf configuration names.
OSType getOS() const
Get the parsed operating system type of this triple.
ArchType getArch() const
Get the parsed architecture type of this triple.
bool isAMDGCN() const
Tests whether the target is AMDGCN.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
const ParentTy * getParent() const
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ CONSTANT_ADDRESS_32BIT
Address space for 32-bit constant memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
unsigned decodeFieldVaVcc(unsigned Encoded)
unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc)
unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version)
unsigned getVaVccBitMask()
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt, const IsaVersion &Version)
unsigned getVmVsrcBitMask()
unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc)
unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst)
unsigned decodeFieldSaSdst(unsigned Encoded)
unsigned getHoldCntBitMask(const IsaVersion &Version)
unsigned decodeFieldVaSdst(unsigned Encoded)
unsigned getVaVdstBitMask()
unsigned getVaSsrcBitMask()
unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc)
unsigned getVaSdstBitMask()
unsigned decodeFieldVaSsrc(unsigned Encoded)
int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask, const MCSubtargetInfo &STI)
unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst)
const CustomOperandVal DepCtrInfo[]
bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
unsigned decodeFieldVaVdst(unsigned Encoded)
unsigned getSaSdstBitMask()
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI)
unsigned decodeFieldVmVsrc(unsigned Encoded)
unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst)
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI)
static constexpr ExpTgt ExpTgtInfo[]
bool getTgtName(unsigned Id, StringRef &Name, int &Index)
unsigned getTgtId(const StringRef Name)
@ ET_DUAL_SRC_BLEND_MAX_IDX
constexpr uint32_t VersionMinor
HSA metadata minor version.
constexpr uint32_t VersionMajor
HSA metadata major version.
@ COMPLETION_ACTION_OFFSET
@ MULTIGRID_SYNC_ARG_OFFSET
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize)
static unsigned getMaxHWAddressableLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo &STI)
bool isSGPROccupancyLimited(const MCSubtargetInfo &STI)
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
static unsigned getPhysicalLocalMemorySize(const MCSubtargetInfo &STI)
static unsigned getSGPRTrapHandlerReserve(const MCSubtargetInfo &STI)
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU)
unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, bool Addressable)
unsigned getWavefrontSize(const MCSubtargetInfo &STI)
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getInstCacheLineSize(const MCSubtargetInfo &STI)
static constexpr unsigned MaxDynamicVGPRBlocks
Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI)
static unsigned getSGPRBudgetPerWave(unsigned TotalNumSGPRs, unsigned WavesPerEU, unsigned TrapReserve, unsigned Granule)
unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize)
unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, unsigned TotalNumSGPRs, unsigned Granule, unsigned TrapReserve)
unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs)
unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
unsigned getLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
static unsigned getGranulatedNumRegisterBlocks(unsigned NumRegs, unsigned Granule)
unsigned getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId)
@ ID_DEALLOC_VGPRS_GFX11Plus
bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI)
void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId, uint16_t &StreamId, const MCSubtargetInfo &STI)
bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId, const MCSubtargetInfo &STI, bool Strict)
bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI)
Returns true if the message does not use the m0 operand.
StringRef getMsgOpName(int64_t MsgId, uint64_t Encoding, const MCSubtargetInfo &STI)
Map from an encoding to the symbolic name for a sendmsg operation.
static uint64_t getMsgIdMask(const MCSubtargetInfo &STI)
bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI, bool Strict)
constexpr unsigned VOPD_VGPR_BANK_MASKS[]
constexpr unsigned COMPONENTS_NUM
constexpr unsigned VOPD3_VGPR_BANK_MASKS[]
constexpr unsigned VOPD_GFX11_VGPR_BANK_MASKS[]
bool isGCN3Encoding(const MCSubtargetInfo &STI)
bool isGFX10_BEncoding(const MCSubtargetInfo &STI)
bool isInlineValue(MCRegister Reg)
bool isGFX10_GFX11(const MCSubtargetInfo &STI)
bool isInlinableLiteralV216(uint32_t Literal, uint8_t OpType)
bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus)
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi)
bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST, uint64_t ByteOffset)
Convert ByteOffset to dwords if the subtarget uses dword SMRD immediate offsets.
static unsigned encodeStorecnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Storecnt)
MCRegister getMCReg(MCRegister Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg.
static bool hasSMEMByteOffset(const MCSubtargetInfo &ST)
LLVM_ABI unsigned getMaxWavesPerEU(GPUKind AK)
bool isVOPCAsmOnly(unsigned Opc)
bool getMTBUFHasSrsrc(unsigned Opc)
std::optional< int64_t > getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool getWMMAIsXDL(unsigned Opc)
uint8_t wmmaScaleF8F6F4FormatToNumRegs(unsigned Fmt)
static bool isSymbolicCustomOperandEncoding(const CustomOperandVal *Opr, int Size, unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc)
const int OPR_ID_UNSUPPORTED
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo &STI)
bool shouldEmitConstantsToTextSection(const Triple &TT)
bool isInlinableLiteralV2I16(uint32_t Literal)
bool isDPMACCInstruction(unsigned Opc)
int getMTBUFElements(unsigned Opc)
constexpr unsigned getNumWorkGroupSIMDs(bool FullSIMDMode)
bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI)
static int encodeCustomOperandVal(const CustomOperandVal &Op, int64_t InputVal)
unsigned getTemporalHintType(const MCInstrDesc TID)
bool isGFX10(const MCSubtargetInfo &STI)
bool isInlinableLiteralV2BF16(uint32_t Literal)
unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI)
std::optional< unsigned > getInlineEncodingV216(bool IsFloat, uint32_t Literal)
FPType getFPDstSelType(unsigned Opc)
unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST)
For pre-GFX12 FLAT instructions the offset must be positive; MSB is ignored and forced to zero.
bool hasA16(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedSignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset, bool IsBuffer)
bool isGFX12Plus(const MCSubtargetInfo &STI)
unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler)
const MCRegisterClass * getVGPRPhysRegClass(MCRegister Reg, const MCRegisterInfo &MRI)
unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool getHasMatrixScale(unsigned Opc)
bool hasPackedD16(const MCSubtargetInfo &STI)
unsigned getStorecntBitMask(const IsaVersion &Version)
bool isFullSIMDMode(const MCSubtargetInfo &STI)
bool isGFX940(const MCSubtargetInfo &STI)
std::optional< unsigned > getExponentOnlyScaleArgIdx(unsigned IntrID)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
static std::optional< unsigned > convertSetRegImmToVgprMSBs(uint64_t Imm, uint64_t Simm16, bool HasSetregVGPRMSBFixup)
const int OPR_VAL_INVALID
bool getSMEMIsBuffer(unsigned Opc)
bool isPackedSingleSGPRFP32Inst(unsigned Opc)
The opcode is a packed fp32 instruction which only reads low 32 bits of a scalar operand and propagat...
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
bool isGFX13(const MCSubtargetInfo &STI)
unsigned getAsynccntBitMask(const IsaVersion &Version)
bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val)
Checks if Val is inside MD, a !range-like metadata.
LLVM_ABI unsigned getAddressableNumSGPRs(GPUKind AK)
TargetID createAMDGPUTargetID(const MCSubtargetInfo &STI, StringRef FeatureString)
Construct TargetID from MCSubtargetInfo.
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
unsigned getVOPDOpcode(unsigned Opc, bool VOPD3)
LLVM_ABI IsaVersion getIsaVersion(StringRef GPU)
bool getMTBUFHasSoffset(unsigned Opc)
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
static unsigned getCombinedCountBitMask(const IsaVersion &Version, bool IsStore)
LLVM_ABI unsigned getTotalNumVGPRs(GPUKind AK, bool IsWave32)
CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3)
bool isVOPC64DPP(unsigned Opc)
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool getMAIIsGFX940XDL(unsigned Opc)
bool isSI(const MCSubtargetInfo &STI)
unsigned getDefaultAMDHSACodeObjectVersion()
LLVM_ABI unsigned getTotalNumSGPRs(GPUKind AK)
bool hasPrivateApertureRegs(const MCSubtargetInfo &STI)
bool isReadOnlySegment(const GlobalValue *GV)
Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded)
bool isArgPassedInSGPR(const Argument *A)
bool isIntrinsicAlwaysUniform(unsigned IntrID)
int getMUBUFBaseOpcode(unsigned Opc)
unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded)
unsigned getAMDHSACodeObjectVersion(const Module &M)
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getWaitcntBitMask(const IsaVersion &Version)
bool getVOP3IsSingle(unsigned Opc)
bool isPackedSingleSGPR64BitInst(unsigned Opc)
The opcode is a packed 64-bit instruction which only reads low 64 bits of a scalar operand and propag...
bool isGFX9(const MCSubtargetInfo &STI)
bool isDPALU_DPP32BitOpc(unsigned Opc)
bool getVOP1IsSingle(unsigned Opc)
static bool isDwordAligned(uint64_t ByteOffset)
unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST)
LLVM_READONLY bool hasNamedOperand(uint32_t Opcode, OpName NamedIdx)
bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this a KImm operand?
bool getHasColorExport(const Function &F)
GPUKind
GPU kinds supported by the AMDGPU target.
int getMTBUFBaseOpcode(unsigned Opc)
bool isGFX90A(const MCSubtargetInfo &STI)
unsigned getSamplecntBitMask(const IsaVersion &Version)
unsigned getDefaultQueueImplicitArgPosition(unsigned CodeObjectVersion)
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding, unsigned VDataDwords, unsigned VAddrDwords, bool IndexedRsrc, bool IndexedSamp)
std::tuple< char, unsigned, unsigned > parseAsmPhysRegName(StringRef RegName)
Returns a valid charcode or 0 in the first entry if this is a valid physical register name.
bool isLDSDMAIntrinsic(unsigned IntrID)
bool getHasDepthExport(const Function &F)
bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI)
bool getMUBUFHasVAddr(unsigned Opc)
bool hasNoOpSelHi(unsigned Opc)
Returns true if this VOP3P opcode has no op_sel_hi field, in which case those bits are encoded as zer...
bool isTrue16Inst(unsigned Opc)
LLVM_ABI unsigned getSGPRAllocGranule(GPUKind AK)
unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI)
std::pair< unsigned, unsigned > getVOPDComponents(unsigned VOPDOpcode)
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
bool isGFX12(const MCSubtargetInfo &STI)
unsigned getInitialPSInputAddr(const Function &F)
unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Expcnt)
bool isAsyncStore(unsigned Opc)
unsigned getDynamicVGPRBlockSize(const Function &F)
unsigned getKmcntBitMask(const IsaVersion &Version)
bool isTriviallyUniform(const Value *V, const Instruction *CtxI)
Return true if we can easily prove that V is uniform at CtxI.
MCRegister getVGPRWithMSBs(MCRegister Reg, unsigned MSBs, const MCRegisterInfo &MRI)
If Reg is a low VGPR return a corresponding high VGPR with MSBs set.
unsigned getVmcntBitMask(const IsaVersion &Version)
bool isNotGFX10Plus(const MCSubtargetInfo &STI)
bool hasMAIInsts(const MCSubtargetInfo &STI)
unsigned getBitOp2(unsigned Opc)
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
unsigned getXcntBitMask(const IsaVersion &Version)
bool isGenericAtomic(unsigned Opc)
const MFMA_F8F6F4_Info * getWMMA_F8F6F4_WithFormatArgs(unsigned FmtA, unsigned FmtB, unsigned F8F8Opcode)
bool isGFX8Plus(const MCSubtargetInfo &STI)
const VLdStIdxOpcodeInfo * getVLdStIdxOpcodeInfoByKey(unsigned BitWidth, bool IsStore, bool IsGPRIdx)
LLVM_READNONE bool isInlinableIntLiteral(int64_t Literal)
Is this literal inlinable, and not one of the values intended for floating point values.
unsigned getLgkmcntBitMask(const IsaVersion &Version)
bool getMUBUFTfe(unsigned Opc)
unsigned getBvhcntBitMask(const IsaVersion &Version)
bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi, bool *IsBF16)
bool hasSMRDSignedImmOffset(const MCSubtargetInfo &ST)
bool hasMIMG_R128(const MCSubtargetInfo &STI)
LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU)
bool hasGFX10_3Insts(const MCSubtargetInfo &STI)
unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt)
std::pair< const AMDGPU::OpName *, const AMDGPU::OpName * > getVGPRLoweringOperandTables(const MCInstrDesc &Desc)
bool hasG16(const MCSubtargetInfo &STI)
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode, const MIMGDimInfo *Dim, bool IsA16, bool IsG16Supported)
int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool isGFX13Plus(const MCSubtargetInfo &STI)
unsigned getExpcntBitMask(const IsaVersion &Version)
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI)
int32_t getMCOpcode(uint32_t Opcode, unsigned Gen)
bool getMUBUFHasSoffset(unsigned Opc)
bool isNotGFX11Plus(const MCSubtargetInfo &STI)
bool isGFX11Plus(const MCSubtargetInfo &STI)
std::optional< unsigned > getInlineEncodingV2F16(uint32_t Literal)
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
static bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
std::optional< APFloat > evaluateRcp(const APFloat &Val)
Evaluate the constant-folded result of v_rcp for Val, accounting for the hardware's denormal flushing...
std::tuple< char, unsigned, unsigned > parseAsmConstraintPhysReg(StringRef Constraint)
Returns a valid charcode or 0 in the first entry if this is a valid physical register constraint.
unsigned getHostcallImplicitArgPosition(unsigned CodeObjectVersion)
static unsigned encodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Loadcnt)
bool isGFX10Plus(const MCSubtargetInfo &STI)
static bool decodeCustomOperand(const CustomOperandVal *Opr, int Size, unsigned Code, int &Idx, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
static bool isValidRegPrefix(char C)
std::optional< int64_t > getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset, bool IsBuffer, bool HasSOffset)
SmallVector< unsigned > getMaxNumWorkGroups(const Function &F)
int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit)
bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale, unsigned BFmt, unsigned BScale)
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
@ OPERAND_REG_INLINE_C_FP64
@ OPERAND_REG_IMM_NOINLINE_FP16
@ OPERAND_REG_INLINE_C_BF16
@ OPERAND_REG_INLINE_C_V2BF16
@ OPERAND_REG_IMM_V2INT16
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
@ OPERAND_REG_IMM_V2FP16_SPLAT
@ OPERAND_REG_IMM_NOINLINE_V2FP16
@ OPERAND_REG_INLINE_C_V2FP16
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
@ OPERAND_REG_INLINE_AC_FP32
@ OPERAND_REG_IMM_V2INT32
@ OPERAND_REG_INLINE_C_FP32
@ OPERAND_REG_INLINE_C_INT32
@ OPERAND_REG_INLINE_C_V2INT16
@ OPERAND_REG_INLINE_AC_FP64
@ OPERAND_REG_INLINE_C_FP16
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
std::optional< unsigned > getPKFMACF16InlineEncoding(uint32_t Literal, bool IsGFX11Plus)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
bool hasGDS(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedUnsignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset)
bool isGFX9Plus(const MCSubtargetInfo &STI)
bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI)
const int OPR_ID_DUPLICATE
bool isVOPD(unsigned Opc)
VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Vmcnt)
unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt)
bool isRsrcIndexReg(MCRegister Reg, const MCRegisterInfo &MRI)
bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc)
std::optional< unsigned > getInlineEncodingV2I16(uint32_t Literal)
unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool isGFX1250(const MCSubtargetInfo &STI)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
bool isSingleSGPRReadInst(unsigned Opc)
Packed instructions that read a single SGPR for SGPR operands, except for 64-bit elements which read ...
bool isTensorStore(unsigned Opc)
bool getMUBUFIsBufferInv(unsigned Opc)
bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode)
unsigned getBarrierMemberCountBitMask(const IsaVersion &Version)
MCRegister mc2PseudoReg(MCRegister Reg)
Convert hardware register Reg to a pseudo register.
std::optional< unsigned > getInlineEncodingV2BF16(uint32_t Literal)
static int encodeCustomOperand(const CustomOperandVal *Opr, int Size, const StringRef Name, int64_t InputVal, unsigned &UsedOprMask, const MCSubtargetInfo &STI)
unsigned hasKernargPreload(const MCSubtargetInfo &STI)
bool supportsWGP(const MCSubtargetInfo &STI)
bool isCI(const MCSubtargetInfo &STI)
unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Lgkmcnt)
bool getVOP2IsSingle(unsigned Opc)
bool getMAIIsDGEMM(unsigned Opc)
Returns true if MAI operation is a double precision GEMM.
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
unsigned getCompletionActionImplicitArgPosition(unsigned CodeObjectVersion)
SmallVector< unsigned > getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size, unsigned DefaultVal)
unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt)
bool isGFX1250Plus(const MCSubtargetInfo &STI)
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels)
bool isNotGFX12Plus(const MCSubtargetInfo &STI)
bool getMTBUFHasVAddr(unsigned Opc)
bool hasPopsExitingWaveID(const MCSubtargetInfo &STI)
unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt)
uint8_t getELFABIVersion(const Triple &T, unsigned CodeObjectVersion)
std::pair< unsigned, unsigned > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< unsigned, unsigned > Default, bool OnlyFirstRequired)
unsigned getLoadcntBitMask(const IsaVersion &Version)
bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi)
bool hasVOPD(const MCSubtargetInfo &STI)
int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily, bool VOPD3)
static unsigned encodeDscnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Dscnt)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
const MFMA_F8F6F4_Info * getMFMA_F8F6F4_WithFormatArgs(unsigned CBSZ, unsigned BLGP, unsigned F8F8Opcode)
unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getMultigridSyncArgImplicitArgPosition(unsigned CodeObjectVersion)
bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI)
bool isGFX9_GFX10(const MCSubtargetInfo &STI)
int getMUBUFElements(unsigned Opc)
const GcnBufferFormatInfo * getGcnBufferFormatInfo(uint8_t BitsPerComp, uint8_t NumComponents, uint8_t NumFormat, const MCSubtargetInfo &STI)
bool isPermlane16(unsigned Opc)
bool getMUBUFHasSrsrc(unsigned Opc)
unsigned getDscntBitMask(const IsaVersion &Version)
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_Gfx
Used for AMD graphics targets.
@ AMDGPU_CS_ChainPreserve
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AMDGPU_CS_Chain
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ SPIR_KERNEL
Used for SPIR kernel functions.
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
@ ELFABIVERSION_AMDGPU_HSA_V4
@ ELFABIVERSION_AMDGPU_HSA_V5
@ ELFABIVERSION_AMDGPU_HSA_V6
constexpr bool isVOPC(const T &...O)
constexpr bool isVOP3(const T &...O)
constexpr bool isVOP1(const T &...O)
constexpr bool isVOP2(const T &...O)
constexpr bool isFLAT(const T &...O)
constexpr bool isBuffer(const T &...O)
constexpr bool isVIMAGE(const T &...O)
constexpr bool isSMRD(const T &...O)
constexpr bool isVOP3Like(const T &...O)
constexpr bool isFlatScratch(const T &...O)
constexpr bool isMIMG(const T &...O)
constexpr bool isVOPD3(const T &...O)
constexpr bool isEXP(const T &...O)
constexpr bool isVSAMPLE(const T &...O)
constexpr bool isDS(const T &...O)
constexpr bool isAtomic(const T &...O)
constexpr bool isDPP(const T &...O)
initializer< Ty > init(const Ty &Val)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
constexpr T rotr(T V, int R)
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
testing::Matcher< const detail::ErrorHolder & > Failed()
constexpr T alignDown(U Value, V Align, W Skew=0)
Returns the largest unsigned integer less than or equal to Value and is Skew mod Align.
std::string utostr(uint64_t X, bool isNeg=false)
constexpr auto equal_to(T &&Arg)
Functor variant of std::equal_to that can be used as a UnaryPredicate in functional algorithms like a...
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
To bit_cast(const From &from) noexcept
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
constexpr unsigned BitWidth
constexpr int countr_zero_constexpr(T Val)
Count number of 0's from the least significant bit to the most stopping at the first 1.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr T maskTrailingOnes(unsigned N)
Create a bitmask with the N right-most bits set to 1, and all other bits set to 0.
@ End
Run the machine verifier once, at the end of the pipeline.
@ AlwaysUniform
The result value is always uniform.
AMD Kernel Code Object (amd_kernel_code_t).
uint16_t amd_machine_version_major
uint16_t amd_machine_kind
uint16_t amd_machine_version_stepping
uint8_t private_segment_alignment
int64_t kernel_code_entry_byte_offset
uint32_t amd_kernel_code_version_major
uint16_t amd_machine_version_minor
uint8_t group_segment_alignment
uint8_t kernarg_segment_alignment
uint32_t amd_kernel_code_version_minor
uint64_t compute_pgm_resource_registers
static std::tuple< typename Fields::ValueType... > decode(uint64_t Encoded)
Instruction set architecture version.