1//===- AMDGPUBaseInfo.cpp - AMDGPU Base encoding information --------------===// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7//===----------------------------------------------------------------------===// 21#include "llvm/IR/IntrinsicsAMDGPU.h" 22#include "llvm/IR/IntrinsicsR600.h" 31#define GET_INSTRINFO_NAMED_OPS 32#define GET_INSTRMAP_INFO 33#include "AMDGPUGenInstrInfo.inc" 38llvm::cl::desc(
"Set default AMDHSA Code Object Version (module flag " 39"or asm directive still take priority if present)"));
43/// \returns Bit mask for given bit \p Shift and bit \p Width. 44unsigned getBitMask(
unsigned Shift,
unsigned Width) {
45return ((1 << Width) - 1) << Shift;
48/// Packs \p Src into \p Dst for given bit \p Shift and bit \p Width. 50/// \returns Packed \p Dst. 51unsigned packBits(
unsigned Src,
unsigned Dst,
unsigned Shift,
unsigned Width) {
52unsignedMask = getBitMask(Shift, Width);
53return ((Src << Shift) & Mask) | (Dst & ~Mask);
56/// Unpacks bits from \p Src for given bit \p Shift and bit \p Width. 58/// \returns Unpacked bits. 59unsigned unpackBits(
unsigned Src,
unsigned Shift,
unsigned Width) {
60return (Src & getBitMask(Shift, Width)) >> Shift;
63/// \returns Vmcnt bit shift (lower bits). 64unsigned getVmcntBitShiftLo(
unsigned VersionMajor) {
68/// \returns Vmcnt bit width (lower bits). 69unsigned getVmcntBitWidthLo(
unsigned VersionMajor) {
73/// \returns Expcnt bit shift. 74unsigned getExpcntBitShift(
unsigned VersionMajor) {
78/// \returns Expcnt bit width. 79unsigned getExpcntBitWidth(
unsigned VersionMajor) {
return 3; }
81/// \returns Lgkmcnt bit shift. 82unsigned getLgkmcntBitShift(
unsigned VersionMajor) {
86/// \returns Lgkmcnt bit width. 87unsigned getLgkmcntBitWidth(
unsigned VersionMajor) {
91/// \returns Vmcnt bit shift (higher bits). 92unsigned getVmcntBitShiftHi(
unsigned VersionMajor) {
return 14; }
94/// \returns Vmcnt bit width (higher bits). 95unsigned getVmcntBitWidthHi(
unsigned VersionMajor) {
96return (VersionMajor == 9 || VersionMajor == 10) ? 2 : 0;
99/// \returns Loadcnt bit width 100unsigned getLoadcntBitWidth(
unsigned VersionMajor) {
104/// \returns Samplecnt bit width. 105unsigned getSamplecntBitWidth(
unsigned VersionMajor) {
109/// \returns Bvhcnt bit width. 110unsigned getBvhcntBitWidth(
unsigned VersionMajor) {
114/// \returns Dscnt bit width. 115unsigned getDscntBitWidth(
unsigned VersionMajor) {
119/// \returns Dscnt bit shift in combined S_WAIT instructions. 120unsigned getDscntBitShift(
unsigned VersionMajor) {
return 0; }
122/// \returns Storecnt or Vscnt bit width, depending on VersionMajor. 123unsigned getStorecntBitWidth(
unsigned VersionMajor) {
127/// \returns Kmcnt bit width. 128unsigned getKmcntBitWidth(
unsigned VersionMajor) {
132/// \returns shift for Loadcnt/Storecnt in combined S_WAIT instructions. 133unsigned getLoadcntStorecntBitShift(
unsigned VersionMajor) {
137/// \returns VmVsrc bit width 138inlineunsigned getVmVsrcBitWidth() {
return 3; }
140/// \returns VmVsrc bit shift 141inlineunsigned getVmVsrcBitShift() {
return 2; }
143/// \returns VaVdst bit width 144inlineunsigned getVaVdstBitWidth() {
return 4; }
146/// \returns VaVdst bit shift 147inlineunsigned getVaVdstBitShift() {
return 12; }
149/// \returns SaSdst bit width 150inlineunsigned getSaSdstBitWidth() {
return 1; }
152/// \returns SaSdst bit shift 153inlineunsigned getSaSdstBitShift() {
return 0; }
155}
// end anonymous namespace 161/// \returns true if the target supports signed immediate offset for SMRD 167/// \returns True if \p STI is AMDHSA. 173if (
auto *Ver = mdconst::extract_or_null<ConstantInt>(
174 M.getModuleFlag(
"amdhsa_code_object_version"))) {
175return (
unsigned)Ver->getZExtValue() / 100;
202switch (CodeObjectVersion) {
211Twine(CodeObjectVersion));
216switch (CodeObjectVersion) {
227// FIXME: All such magic numbers about the ABI should be in a 230switch (CodeObjectVersion) {
241switch (CodeObjectVersion) {
252switch (CodeObjectVersion) {
262#define GET_MIMGBaseOpcodesTable_IMPL 263#define GET_MIMGDimInfoTable_IMPL 264#define GET_MIMGInfoTable_IMPL 265#define GET_MIMGLZMappingTable_IMPL 266#define GET_MIMGMIPMappingTable_IMPL 267#define GET_MIMGBiasMappingTable_IMPL 268#define GET_MIMGOffsetMappingTable_IMPL 269#define GET_MIMGG16MappingTable_IMPL 270#define GET_MAIInstInfoTable_IMPL 271#include "AMDGPUGenSearchableTables.inc" 274unsigned VDataDwords,
unsigned VAddrDwords) {
275constMIMGInfo *
Info = getMIMGOpcodeHelper(BaseOpcode, MIMGEncoding,
276 VDataDwords, VAddrDwords);
290return NewInfo ? NewInfo->
Opcode : -1;
295bool IsG16Supported) {
302 AddrWords += AddrComponents;
304// Note: For subtargets that support A16 but not G16, enabling A16 also 305// enables 16 bit gradients. 306// For subtargets that support A16 (operand) and G16 (done with a different 307// instruction encoding), they are independent. 310if ((IsA16 && !IsG16Supported) || BaseOpcode->
G16)
311// There are two gradients per coordinate, we pack them separately. 313// we get (dy/du, dx/du) (-, dz/du) (dy/dv, dx/dv) (-, dz/dv) 381#define GET_FP4FP8DstByteSelTable_DECL 382#define GET_FP4FP8DstByteSelTable_IMPL 395#define GET_MTBUFInfoTable_DECL 396#define GET_MTBUFInfoTable_IMPL 397#define GET_MUBUFInfoTable_DECL 398#define GET_MUBUFInfoTable_IMPL 399#define GET_SMInfoTable_DECL 400#define GET_SMInfoTable_IMPL 401#define GET_VOP1InfoTable_DECL 402#define GET_VOP1InfoTable_IMPL 403#define GET_VOP2InfoTable_DECL 404#define GET_VOP2InfoTable_IMPL 405#define GET_VOP3InfoTable_DECL 406#define GET_VOP3InfoTable_IMPL 407#define GET_VOPC64DPPTable_DECL 408#define GET_VOPC64DPPTable_IMPL 409#define GET_VOPC64DPP8Table_DECL 410#define GET_VOPC64DPP8Table_IMPL 411#define GET_VOPCAsmOnlyInfoTable_DECL 412#define GET_VOPCAsmOnlyInfoTable_IMPL 413#define GET_VOP3CAsmOnlyInfoTable_DECL 414#define GET_VOP3CAsmOnlyInfoTable_IMPL 415#define GET_VOPDComponentTable_DECL 416#define GET_VOPDComponentTable_IMPL 417#define GET_VOPDPairs_DECL 418#define GET_VOPDPairs_IMPL 419#define GET_VOPTrue16Table_DECL 420#define GET_VOPTrue16Table_IMPL 421#define GET_WMMAOpcode2AddrMappingTable_DECL 422#define GET_WMMAOpcode2AddrMappingTable_IMPL 423#define GET_WMMAOpcode3AddrMappingTable_DECL 424#define GET_WMMAOpcode3AddrMappingTable_IMPL 425#define GET_getMFMA_F8F6F4_WithSize_DECL 426#define GET_getMFMA_F8F6F4_WithSize_IMPL 427#define GET_isMFMA_F8F6F4Table_IMPL 428#define GET_isCvtScaleF32_F32F16ToF8F4Table_IMPL 430#include "AMDGPUGenSearchableTables.inc" 438constMTBUFInfo *
Info = getMTBUFInfoFromBaseOpcodeAndElements(BaseOpc, Elements);
459returnInfo ?
Info->has_soffset :
false;
468constMUBUFInfo *
Info = getMUBUFInfoFromBaseOpcodeAndElements(BaseOpc, Elements);
489returnInfo ?
Info->has_soffset :
false;
494returnInfo ?
Info->IsBufferInv :
false;
523return isVOPC64DPPOpcodeHelper(Opc) || isVOPC64DPP8OpcodeHelper(Opc);
535returnInfo ?
Info->is_gfx940_xdl :
false;
539switch (EncodingVal) {
556unsigned F8F8Opcode) {
559return getMFMA_F8F6F4_InstWithNumRegs(SrcANumRegs, SrcBNumRegs, F8F8Opcode);
563if (ST.hasFeature(AMDGPU::FeatureGFX12Insts))
565if (ST.hasFeature(AMDGPU::FeatureGFX11Insts))
573return {
Info->CanBeVOPDX,
true};
587return Opc == AMDGPU::V_MAC_F32_e64_gfx6_gfx7 ||
588 Opc == AMDGPU::V_MAC_F32_e64_gfx10 ||
589 Opc == AMDGPU::V_MAC_F32_e64_vi ||
590 Opc == AMDGPU::V_MAC_LEGACY_F32_e64_gfx6_gfx7 ||
591 Opc == AMDGPU::V_MAC_LEGACY_F32_e64_gfx10 ||
592 Opc == AMDGPU::V_MAC_F16_e64_vi ||
593 Opc == AMDGPU::V_FMAC_F64_e64_gfx90a ||
594 Opc == AMDGPU::V_FMAC_F32_e64_gfx10 ||
595 Opc == AMDGPU::V_FMAC_F32_e64_gfx11 ||
596 Opc == AMDGPU::V_FMAC_F32_e64_gfx12 ||
597 Opc == AMDGPU::V_FMAC_F32_e64_vi ||
598 Opc == AMDGPU::V_FMAC_LEGACY_F32_e64_gfx10 ||
599 Opc == AMDGPU::V_FMAC_DX9_ZERO_F32_e64_gfx11 ||
600 Opc == AMDGPU::V_FMAC_F16_e64_gfx10 ||
601 Opc == AMDGPU::V_FMAC_F16_fake16_e64_gfx11 ||
602 Opc == AMDGPU::V_FMAC_F16_fake16_e64_gfx12 ||
603 Opc == AMDGPU::V_DOT2C_F32_F16_e64_vi ||
604 Opc == AMDGPU::V_DOT2C_F32_BF16_e64_vi ||
605 Opc == AMDGPU::V_DOT2C_I32_I16_e64_vi ||
606 Opc == AMDGPU::V_DOT4C_I32_I8_e64_vi ||
607 Opc == AMDGPU::V_DOT8C_I32_I4_e64_vi;
611return Opc == AMDGPU::V_PERMLANE16_B32_gfx10 ||
612 Opc == AMDGPU::V_PERMLANEX16_B32_gfx10 ||
613 Opc == AMDGPU::V_PERMLANE16_B32_e64_gfx11 ||
614 Opc == AMDGPU::V_PERMLANEX16_B32_e64_gfx11 ||
615 Opc == AMDGPU::V_PERMLANE16_B32_e64_gfx12 ||
616 Opc == AMDGPU::V_PERMLANEX16_B32_e64_gfx12 ||
617 Opc == AMDGPU::V_PERMLANE16_VAR_B32_e64_gfx12 ||
618 Opc == AMDGPU::V_PERMLANEX16_VAR_B32_e64_gfx12;
622return Opc == AMDGPU::V_CVT_F32_BF8_e64_gfx12 ||
623 Opc == AMDGPU::V_CVT_F32_FP8_e64_gfx12 ||
624 Opc == AMDGPU::V_CVT_F32_BF8_e64_dpp_gfx12 ||
625 Opc == AMDGPU::V_CVT_F32_FP8_e64_dpp_gfx12 ||
626 Opc == AMDGPU::V_CVT_F32_BF8_e64_dpp8_gfx12 ||
627 Opc == AMDGPU::V_CVT_F32_FP8_e64_dpp8_gfx12 ||
628 Opc == AMDGPU::V_CVT_PK_F32_BF8_fake16_e64_gfx12 ||
629 Opc == AMDGPU::V_CVT_PK_F32_FP8_fake16_e64_gfx12 ||
630 Opc == AMDGPU::V_CVT_PK_F32_BF8_t16_e64_gfx12 ||
631 Opc == AMDGPU::V_CVT_PK_F32_FP8_t16_e64_gfx12;
635return Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SWAP ||
636 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_ADD ||
637 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SUB ||
638 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SMIN ||
639 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_UMIN ||
640 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_SMAX ||
641 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_UMAX ||
642 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_AND ||
643 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_OR ||
644 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_XOR ||
645 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_INC ||
646 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_DEC ||
647 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FADD ||
648 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FMIN ||
649 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_FMAX ||
650 Opc == AMDGPU::G_AMDGPU_BUFFER_ATOMIC_CMPSWAP ||
651 Opc == AMDGPU::G_AMDGPU_ATOMIC_CMPXCHG;
663if (
Info->HasFP8DstByteSel)
665if (
Info->HasFP4DstByteSel)
681// Wrapper for Tablegen'd function. enum Subtarget is not defined in any 682// header files, so we need to wrap it in a function that takes unsigned 685return getMCOpcodeGen(Opcode,
static_cast<Subtarget
>(Gen));
688intgetVOPDFull(
unsigned OpX,
unsigned OpY,
unsigned EncodingFamily) {
690 getVOPDInfoFromComponentOpcodes(OpX, OpY, EncodingFamily);
697constauto *OpX = getVOPDBaseFromComponent(
Info->OpX);
698constauto *OpY = getVOPDBaseFromComponent(
Info->OpY);
700return {OpX->BaseVOP, OpY->BaseVOP};
712 HasSrc2Acc = TiedIdx != -1;
719for (CompOprIdx =
Component::SRC1; CompOprIdx < OperandsNum; ++CompOprIdx) {
721 MandatoryLiteralIdx = CompOprIdx;
737// The specified operand does not exist. 742 std::function<
unsigned(
unsigned,
unsigned)> GetRegIdx,
bool SkipSrc)
const{
747constunsigned CompOprNum =
750for (CompOprIdx = 0; CompOprIdx < CompOprNum; ++CompOprIdx) {
752if (OpXRegs[CompOprIdx] && OpYRegs[CompOprIdx] &&
753 ((OpXRegs[CompOprIdx] & BanksMasks) ==
754 (OpYRegs[CompOprIdx] & BanksMasks)))
761// Return an array of VGPR registers [DST,SRC0,SRC1,SRC2] used 762// by the specified component. If an operand is unused 763// or is not a VGPR, the corresponding value is 0. 765// GetRegIdx(Component, MCOperandIdx) must return a VGPR register index 766// for the specified component and MC operand. The callback must return 0 767// if the operand is not a register or not a VGPR. 770 std::function<
unsigned(
unsigned,
unsigned)> GetRegIdx)
const{
773constauto &Comp = CompInfo[CompIdx];
776RegIndices[
DST] = GetRegIdx(CompIdx, Comp.getIndexOfDstInMCOperands());
779unsigned CompSrcIdx = CompOprIdx -
DST_NUM;
781 Comp.hasRegSrcOperand(CompSrcIdx)
782 ? GetRegIdx(CompIdx, Comp.getIndexOfSrcInMCOperands(CompSrcIdx))
797constauto &OpXDesc = InstrInfo->
get(OpX);
798constauto &OpYDesc = InstrInfo->
get(OpY);
816// Check if xnack or sramecc is explicitly enabled or disabled. In the 817// absence of the target features we assume we must generate code that can run 818// in any environment. 820 std::optional<bool> XnackRequested;
821 std::optional<bool> SramEccRequested;
823for (
const std::string &Feature : Features.
getFeatures()) {
824if (Feature ==
"+xnack")
825 XnackRequested =
true;
826elseif (Feature ==
"-xnack")
827 XnackRequested =
false;
828elseif (Feature ==
"+sramecc")
829 SramEccRequested =
true;
830elseif (Feature ==
"-sramecc")
831 SramEccRequested =
false;
842// If a specific xnack setting was requested and this GPU does not support 843// xnack emit a warning. Setting will remain set to "Unsupported". 844if (*XnackRequested) {
845errs() <<
"warning: xnack 'On' was requested for a processor that does " 848errs() <<
"warning: xnack 'Off' was requested for a processor that " 849"does not support it!\n";
854if (SramEccRequested) {
855if (SramEccSupported) {
859// If a specific sramecc setting was requested and this GPU does not 860// support sramecc emit a warning. Setting will remain set to 862if (*SramEccRequested) {
863errs() <<
"warning: sramecc 'On' was requested for a processor that " 864"does not support it!\n";
866errs() <<
"warning: sramecc 'Off' was requested for a processor that " 867"does not support it!\n";
885 TargetID.
split(TargetIDSplit,
':');
887for (
constauto &FeatureString : TargetIDSplit) {
888if (FeatureString.starts_with(
"xnack"))
890if (FeatureString.starts_with(
"sramecc"))
896 std::string StringRep;
902 StreamRep << TargetTriple.getArchName() <<
'-' 903 << TargetTriple.getVendorName() <<
'-' 904 << TargetTriple.getOSName() <<
'-' 905 << TargetTriple.getEnvironmentName() <<
'-';
907 std::string Processor;
908// TODO: Following else statement is present here because we used various 909// alias names for GPUs up until GFX9 (e.g. 'fiji' is same as 'gfx803'). 910// Remove once all aliases are removed from GCNProcessors.td. 918 std::string Features;
922 Features +=
":sramecc-";
924 Features +=
":sramecc+";
927 Features +=
":xnack-";
929 Features +=
":xnack+";
932 StreamRep << Processor << Features;
949// "Per CU" really means "per whatever functional block the waves of a 950// workgroup must share". So the effective local memory size is doubled in 969// "Per CU" really means "per whatever functional block the waves of a 970// workgroup must share". For gfx10 in CU mode this is the CU, which contains 974// Pre-gfx10 a CU contains four SIMDs. For gfx10 in WGP mode the WGP contains 975// two CUs, so a total of four SIMDs. 980unsigned FlatWorkGroupSize) {
981assert(FlatWorkGroupSize != 0);
987// Single-wave workgroups don't consume barrier resources. 991unsigned MaxBarriers = 16;
995return std::min(MaxWaves /
N, MaxBarriers);
1003// FIXME: Need to take scratch memory into account. 1012unsigned FlatWorkGroupSize) {
1022// Some subtargets allow encoding 2048, but this isn't tested or supported. 1027unsigned FlatWorkGroupSize) {
1087return Addressable ? AddressableNumSGPRs : 108;
1088if (
Version.Major >= 8 && !Addressable)
1089 AddressableNumSGPRs = 112;
1094return std::min(MaxNumSGPRs, AddressableNumSGPRs);
1098bool FlatScrUsed,
bool XNACKUsed) {
1099unsigned ExtraSGPRs = 0;
1130returndivideCeil(std::max(1u, NumRegs), Granule);
1134// SGPRBlocks is actual number of SGPR blocks minus 1. 1140 std::optional<bool> EnableWavefrontSize32) {
1144bool IsWave32 = EnableWavefrontSize32 ?
1145 *EnableWavefrontSize32 :
1149return IsWave32 ? 24 : 12;
1152return IsWave32 ? 16 : 8;
1154return IsWave32 ? 8 : 4;
1158 std::optional<bool> EnableWavefrontSize32) {
1162bool IsWave32 = EnableWavefrontSize32 ?
1163 *EnableWavefrontSize32 :
1166return IsWave32 ? 8 : 4;
1176return IsWave32 ? 1536 : 768;
1177return IsWave32 ? 1024 : 512;
1197unsigned TotalNumVGPRs) {
1198if (NumVGPRs < Granule)
1200unsigned RoundedRegs =
alignTo(NumVGPRs, Granule);
1201return std::min(std::max(TotalNumVGPRs / RoundedRegs, 1u), MaxWaves);
1235if (WavesPerEU >= MaxWavesPerEU)
1241unsigned MaxNumVGPRs =
alignDown(TotNumVGPRs / WavesPerEU, Granule);
1243if (MaxNumVGPRs ==
alignDown(TotNumVGPRs / MaxWavesPerEU, Granule))
1247if (WavesPerEU < MinWavesPerEU)
1250unsigned MaxNumVGPRsNext =
alignDown(TotNumVGPRs / (WavesPerEU + 1), Granule);
1251unsigned MinNumVGPRs = 1 + std::min(MaxNumVGPRs - Granule, MaxNumVGPRsNext);
1252return std::min(MinNumVGPRs, AddrsableNumVGPRs);
1261return std::min(MaxNumVGPRs, AddressableNumVGPRs);
1265 std::optional<bool> EnableWavefrontSize32) {
1273 std::optional<bool> EnableWavefrontSize32) {
1277}
// end namespace IsaInfo 1296// If the code object does not support indirect functions, then the value must 1300// These alignment values are specified in powers of two, so alignment = 1301// 2^n. The minimum alignment is 2^4 = 16. 1331std::pair<unsigned, unsigned>
1333 std::pair<unsigned, unsigned>
Default,
1334bool OnlyFirstRequired) {
1336return {Attr->first, Attr->second ? *(Attr->second) :
Default.second};
1340std::optional<std::pair<unsigned, std::optional<unsigned>>>
1342bool OnlyFirstRequired) {
1344if (!
A.isStringAttribute())
1348 std::pair<unsigned, std::optional<unsigned>> Ints;
1349 std::pair<StringRef, StringRef> Strs =
A.getValueAsString().split(
',');
1350if (Strs.first.trim().getAsInteger(0, Ints.first)) {
1351 Ctx.
emitError(
"can't parse first integer attribute " +
Name);
1355if (Strs.second.trim().getAsInteger(0, Second)) {
1356if (!OnlyFirstRequired || !Strs.second.trim().empty()) {
1357 Ctx.
emitError(
"can't parse second integer attribute " +
Name);
1361 Ints.second = Second;
1374if (!
A.isStringAttribute())
1384 std::pair<StringRef, StringRef> Strs = S.
split(
',');
1386if (Strs.first.trim().getAsInteger(0, IntVal)) {
1387 Ctx.
emitError(
"can't parse integer attribute " + Strs.first +
" in " +
1397" has incorrect number of integers; expected " +
1398 llvm::utostr(
Size));
1405return (1 << (getVmcntBitWidthLo(
Version.Major) +
1406 getVmcntBitWidthHi(
Version.Major))) -
1411return (1 << getLoadcntBitWidth(
Version.Major)) - 1;
1415return (1 << getSamplecntBitWidth(
Version.Major)) - 1;
1419return (1 << getBvhcntBitWidth(
Version.Major)) - 1;
1423return (1 << getExpcntBitWidth(
Version.Major)) - 1;
1427return (1 << getLgkmcntBitWidth(
Version.Major)) - 1;
1431return (1 << getDscntBitWidth(
Version.Major)) - 1;
1435return (1 << getKmcntBitWidth(
Version.Major)) - 1;
1439return (1 << getStorecntBitWidth(
Version.Major)) - 1;
1443unsigned VmcntLo = getBitMask(getVmcntBitShiftLo(
Version.Major),
1444 getVmcntBitWidthLo(
Version.Major));
1445unsigned Expcnt = getBitMask(getExpcntBitShift(
Version.Major),
1446 getExpcntBitWidth(
Version.Major));
1447unsigned Lgkmcnt = getBitMask(getLgkmcntBitShift(
Version.Major),
1448 getLgkmcntBitWidth(
Version.Major));
1449unsigned VmcntHi = getBitMask(getVmcntBitShiftHi(
Version.Major),
1450 getVmcntBitWidthHi(
Version.Major));
1451return VmcntLo | Expcnt | Lgkmcnt | VmcntHi;
1455unsigned VmcntLo = unpackBits(
Waitcnt, getVmcntBitShiftLo(
Version.Major),
1456 getVmcntBitWidthLo(
Version.Major));
1457unsigned VmcntHi = unpackBits(
Waitcnt, getVmcntBitShiftHi(
Version.Major),
1458 getVmcntBitWidthHi(
Version.Major));
1459return VmcntLo | VmcntHi << getVmcntBitWidthLo(
Version.Major);
1464 getExpcntBitWidth(
Version.Major));
1469 getLgkmcntBitWidth(
Version.Major));
1473unsigned &Vmcnt,
unsigned &Expcnt,
unsigned &Lgkmcnt) {
1490 getVmcntBitWidthLo(
Version.Major));
1491return packBits(Vmcnt >> getVmcntBitWidthLo(
Version.Major),
Waitcnt,
1492 getVmcntBitShiftHi(
Version.Major),
1493 getVmcntBitWidthHi(
Version.Major));
1499 getExpcntBitWidth(
Version.Major));
1504return packBits(Lgkmcnt,
Waitcnt, getLgkmcntBitShift(
Version.Major),
1505 getLgkmcntBitWidth(
Version.Major));
1509unsigned Vmcnt,
unsigned Expcnt,
unsigned Lgkmcnt) {
1523unsigned Dscnt = getBitMask(getDscntBitShift(
Version.Major),
1524 getDscntBitWidth(
Version.Major));
1526unsigned Storecnt = getBitMask(getLoadcntStorecntBitShift(
Version.Major),
1527 getStorecntBitWidth(
Version.Major));
1528return Dscnt | Storecnt;
1530unsigned Loadcnt = getBitMask(getLoadcntStorecntBitShift(
Version.Major),
1531 getLoadcntBitWidth(
Version.Major));
1532return Dscnt | Loadcnt;
1538 unpackBits(LoadcntDscnt, getLoadcntStorecntBitShift(
Version.Major),
1539 getLoadcntBitWidth(
Version.Major));
1540 Decoded.
DsCnt = unpackBits(LoadcntDscnt, getDscntBitShift(
Version.Major),
1541 getDscntBitWidth(
Version.Major));
1548 unpackBits(StorecntDscnt, getLoadcntStorecntBitShift(
Version.Major),
1549 getStorecntBitWidth(
Version.Major));
1550 Decoded.
DsCnt = unpackBits(StorecntDscnt, getDscntBitShift(
Version.Major),
1551 getDscntBitWidth(
Version.Major));
1557return packBits(Loadcnt,
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1558 getLoadcntBitWidth(
Version.Major));
1563return packBits(Storecnt,
Waitcnt, getLoadcntStorecntBitShift(
Version.Major),
1564 getStorecntBitWidth(
Version.Major));
1570 getDscntBitWidth(
Version.Major));
1586unsigned Storecnt,
unsigned Dscnt) {
1598//===----------------------------------------------------------------------===// 1599// Custom Operand Values 1600//===----------------------------------------------------------------------===// 1607constauto &
Op = Opr[
Idx];
1608if (
Op.isSupported(STI))
1609 Enc |=
Op.encode(
Op.Default);
1615intSize,
unsigned Code,
1616bool &HasNonDefaultVal,
1618unsigned UsedOprMask = 0;
1619 HasNonDefaultVal =
false;
1621constauto &
Op = Opr[
Idx];
1622if (!
Op.isSupported(STI))
1624 UsedOprMask |=
Op.getMask();
1625unsigned Val =
Op.decode(Code);
1626if (!
Op.isValid(Val))
1628 HasNonDefaultVal |= (Val !=
Op.Default);
1630return (Code & ~UsedOprMask) == 0;
1635unsigned &Val,
bool &IsDefault,
1638constauto &
Op = Opr[
Idx++];
1639if (
Op.isSupported(STI)) {
1641 Val =
Op.decode(Code);
1642 IsDefault = (Val ==
Op.Default);
1652if (InputVal < 0 || InputVal >
Op.Max)
1654returnOp.encode(InputVal);
1659unsigned &UsedOprMask,
1663constauto &
Op = Opr[
Idx];
1665if (!
Op.isSupported(STI)) {
1669auto OprMask =
Op.getMask();
1670if (OprMask & UsedOprMask)
1672 UsedOprMask |= OprMask;
1679//===----------------------------------------------------------------------===// 1681//===----------------------------------------------------------------------===// 1695 HasNonDefaultVal, STI);
1711return unpackBits(Encoded, getVmVsrcBitShift(), getVmVsrcBitWidth());
1715return unpackBits(Encoded, getVaVdstBitShift(), getVaVdstBitWidth());
1719return unpackBits(Encoded, getSaSdstBitShift(), getSaSdstBitWidth());
1723return packBits(VmVsrc, Encoded, getVmVsrcBitShift(), getVmVsrcBitWidth());
1731return packBits(VaVdst, Encoded, getVaVdstBitShift(), getVaVdstBitWidth());
1739return packBits(SaSdst, Encoded, getSaSdstBitShift(), getSaSdstBitWidth());
1748//===----------------------------------------------------------------------===// 1750//===----------------------------------------------------------------------===// 1772if (Val.Tgt <= Id && Id <= Val.Tgt + Val.MaxIndex) {
1773Index = (Val.MaxIndex == 0) ? -1 : (Id - Val.Tgt);
1784if (Val.MaxIndex == 0 &&
Name == Val.Name)
1787if (Val.MaxIndex > 0 &&
Name.starts_with(Val.Name)) {
1794// Disable leading zeroes 1795if (Suffix.
size() > 1 && Suffix[0] ==
'0')
1823//===----------------------------------------------------------------------===// 1825//===----------------------------------------------------------------------===// 1827namespaceMTBUFFormat {
1853if (
Name == lookupTable[Id])
1936}
// namespace MTBUFFormat 1938//===----------------------------------------------------------------------===// 1940//===----------------------------------------------------------------------===// 1957return 0 <= OpId && isUInt<OP_WIDTH_>(OpId);
2020}
// namespace SendMsg 2022//===----------------------------------------------------------------------===// 2024//===----------------------------------------------------------------------===// 2027returnF.getFnAttributeAsParsedInteger(
"InitialPSInputAddr", 0);
2031// As a safe default always respond as if PS has color exports. 2032returnF.getFnAttributeAsParsedInteger(
2033"amdgpu-color-export",
2038returnF.getFnAttributeAsParsedInteger(
"amdgpu-depth-export", 0) != 0;
2111return STI.
hasFeature(AMDGPU::FeatureSRAMECC);
2127return !STI.
hasFeature(AMDGPU::FeatureUnpackedD16VMem) && !
isCI(STI) &&
2138returnVersion.Minor >= 3 ? 13 : 5;
2142return HasSampler ? 4 : 5;
2149return STI.
hasFeature(AMDGPU::FeatureSouthernIslands);
2153return STI.
hasFeature(AMDGPU::FeatureSeaIslands);
2157return STI.
hasFeature(AMDGPU::FeatureVolcanicIslands);
2227return STI.
hasFeature(AMDGPU::FeatureGCN3Encoding);
2231return STI.
hasFeature(AMDGPU::FeatureGFX10_AEncoding);
2235return STI.
hasFeature(AMDGPU::FeatureGFX10_BEncoding);
2239return STI.
hasFeature(AMDGPU::FeatureGFX10_3Insts);
2247return STI.
hasFeature(AMDGPU::FeatureGFX90AInsts);
2251return STI.
hasFeature(AMDGPU::FeatureGFX940Insts);
2255return STI.
hasFeature(AMDGPU::FeatureArchitectedFlatScratch);
2259return STI.
hasFeature(AMDGPU::FeatureMAIInsts);
2267return STI.
hasFeature(AMDGPU::FeatureDPPSrc1SGPR);
2271return STI.
hasFeature(AMDGPU::FeatureKernargPreload);
2275 int32_t ArgNumVGPR) {
2276if (has90AInsts && ArgNumAGPR)
2277returnalignTo(ArgNumVGPR, 4) + ArgNumAGPR;
2278return std::max(ArgNumVGPR, ArgNumAGPR);
2284return SGPRClass.
contains(FirstSubReg != 0 ? FirstSubReg :
Reg) ||
2292#define MAP_REG2REG \ 2293 using namespace AMDGPU; \ 2294 switch(Reg.id()) { \ 2295 default: return Reg; \ 2296 CASE_CI_VI(FLAT_SCR) \ 2297 CASE_CI_VI(FLAT_SCR_LO) \ 2298 CASE_CI_VI(FLAT_SCR_HI) \ 2299 CASE_VI_GFX9PLUS(TTMP0) \ 2300 CASE_VI_GFX9PLUS(TTMP1) \ 2301 CASE_VI_GFX9PLUS(TTMP2) \ 2302 CASE_VI_GFX9PLUS(TTMP3) \ 2303 CASE_VI_GFX9PLUS(TTMP4) \ 2304 CASE_VI_GFX9PLUS(TTMP5) \ 2305 CASE_VI_GFX9PLUS(TTMP6) \ 2306 CASE_VI_GFX9PLUS(TTMP7) \ 2307 CASE_VI_GFX9PLUS(TTMP8) \ 2308 CASE_VI_GFX9PLUS(TTMP9) \ 2309 CASE_VI_GFX9PLUS(TTMP10) \ 2310 CASE_VI_GFX9PLUS(TTMP11) \ 2311 CASE_VI_GFX9PLUS(TTMP12) \ 2312 CASE_VI_GFX9PLUS(TTMP13) \ 2313 CASE_VI_GFX9PLUS(TTMP14) \ 2314 CASE_VI_GFX9PLUS(TTMP15) \ 2315 CASE_VI_GFX9PLUS(TTMP0_TTMP1) \ 2316 CASE_VI_GFX9PLUS(TTMP2_TTMP3) \ 2317 CASE_VI_GFX9PLUS(TTMP4_TTMP5) \ 2318 CASE_VI_GFX9PLUS(TTMP6_TTMP7) \ 2319 CASE_VI_GFX9PLUS(TTMP8_TTMP9) \ 2320 CASE_VI_GFX9PLUS(TTMP10_TTMP11) \ 2321 CASE_VI_GFX9PLUS(TTMP12_TTMP13) \ 2322 CASE_VI_GFX9PLUS(TTMP14_TTMP15) \ 2323 CASE_VI_GFX9PLUS(TTMP0_TTMP1_TTMP2_TTMP3) \ 2324 CASE_VI_GFX9PLUS(TTMP4_TTMP5_TTMP6_TTMP7) \ 2325 CASE_VI_GFX9PLUS(TTMP8_TTMP9_TTMP10_TTMP11) \ 2326 CASE_VI_GFX9PLUS(TTMP12_TTMP13_TTMP14_TTMP15) \ 2327 CASE_VI_GFX9PLUS(TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7) \ 2328 CASE_VI_GFX9PLUS(TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11) \ 2329 CASE_VI_GFX9PLUS(TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15) \ 2330 CASE_VI_GFX9PLUS(TTMP0_TTMP1_TTMP2_TTMP3_TTMP4_TTMP5_TTMP6_TTMP7_TTMP8_TTMP9_TTMP10_TTMP11_TTMP12_TTMP13_TTMP14_TTMP15) \ 2331 CASE_GFXPRE11_GFX11PLUS(M0) \ 2332 CASE_GFXPRE11_GFX11PLUS(SGPR_NULL) \ 2333 CASE_GFXPRE11_GFX11PLUS_TO(SGPR_NULL64, SGPR_NULL) \ 2336#define CASE_CI_VI(node) \ 2337 assert(!isSI(STI)); \ 2338 case node: return isCI(STI) ? node##_ci : node##_vi; 2340#define CASE_VI_GFX9PLUS(node) \ 2341 case node: return isGFX9Plus(STI) ? node##_gfx9plus : node##_vi; 2343#define CASE_GFXPRE11_GFX11PLUS(node) \ 2344 case node: return isGFX11Plus(STI) ? node##_gfx11plus : node##_gfxpre11; 2346#define CASE_GFXPRE11_GFX11PLUS_TO(node, result) \ 2347 case node: return isGFX11Plus(STI) ? result##_gfx11plus : result##_gfxpre11; 2356#undef CASE_VI_GFX9PLUS 2357#undef CASE_GFXPRE11_GFX11PLUS 2358#undef CASE_GFXPRE11_GFX11PLUS_TO 2360#define CASE_CI_VI(node) case node##_ci: case node##_vi: return node; 2361#define CASE_VI_GFX9PLUS(node) case node##_vi: case node##_gfx9plus: return node; 2362#define CASE_GFXPRE11_GFX11PLUS(node) case node##_gfx11plus: case node##_gfxpre11: return node; 2363#define CASE_GFXPRE11_GFX11PLUS_TO(node, result) 2369case AMDGPU::SRC_SHARED_BASE_LO:
2370case AMDGPU::SRC_SHARED_BASE:
2371case AMDGPU::SRC_SHARED_LIMIT_LO:
2372case AMDGPU::SRC_SHARED_LIMIT:
2373case AMDGPU::SRC_PRIVATE_BASE_LO:
2374case AMDGPU::SRC_PRIVATE_BASE:
2375case AMDGPU::SRC_PRIVATE_LIMIT_LO:
2376case AMDGPU::SRC_PRIVATE_LIMIT:
2377case AMDGPU::SRC_POPS_EXITING_WAVE_ID:
2379case AMDGPU::SRC_VCCZ:
2380case AMDGPU::SRC_EXECZ:
2381case AMDGPU::SRC_SCC:
2383case AMDGPU::SGPR_NULL:
2391#undef CASE_VI_GFX9PLUS 2392#undef CASE_GFXPRE11_GFX11PLUS 2393#undef CASE_GFXPRE11_GFX11PLUS_TO 2398unsigned OpType =
Desc.operands()[OpNo].OperandType;
2405unsigned OpType =
Desc.operands()[OpNo].OperandType;
2412unsigned OpType =
Desc.operands()[OpNo].OperandType;
2438unsigned OpType =
Desc.operands()[OpNo].OperandType;
2445// Avoid using MCRegisterClass::getSize, since that function will go away 2446// (move from MC* level to Target* level). Return size in bits. 2449case AMDGPU::SGPR_LO16RegClassID:
2450case AMDGPU::AGPR_LO16RegClassID:
2452case AMDGPU::SGPR_32RegClassID:
2453case AMDGPU::VGPR_32RegClassID:
2454case AMDGPU::VRegOrLds_32RegClassID:
2455case AMDGPU::AGPR_32RegClassID:
2456case AMDGPU::VS_32RegClassID:
2457case AMDGPU::AV_32RegClassID:
2458case AMDGPU::SReg_32RegClassID:
2459case AMDGPU::SReg_32_XM0RegClassID:
2460case AMDGPU::SRegOrLds_32RegClassID:
2462case AMDGPU::SGPR_64RegClassID:
2463case AMDGPU::VS_64RegClassID:
2464case AMDGPU::SReg_64RegClassID:
2465case AMDGPU::VReg_64RegClassID:
2466case AMDGPU::AReg_64RegClassID:
2467case AMDGPU::SReg_64_XEXECRegClassID:
2468case AMDGPU::VReg_64_Align2RegClassID:
2469case AMDGPU::AReg_64_Align2RegClassID:
2470case AMDGPU::AV_64RegClassID:
2471case AMDGPU::AV_64_Align2RegClassID:
2473case AMDGPU::SGPR_96RegClassID:
2474case AMDGPU::SReg_96RegClassID:
2475case AMDGPU::VReg_96RegClassID:
2476case AMDGPU::AReg_96RegClassID:
2477case AMDGPU::VReg_96_Align2RegClassID:
2478case AMDGPU::AReg_96_Align2RegClassID:
2479case AMDGPU::AV_96RegClassID:
2480case AMDGPU::AV_96_Align2RegClassID:
2482case AMDGPU::SGPR_128RegClassID:
2483case AMDGPU::SReg_128RegClassID:
2484case AMDGPU::VReg_128RegClassID:
2485case AMDGPU::AReg_128RegClassID:
2486case AMDGPU::VReg_128_Align2RegClassID:
2487case AMDGPU::AReg_128_Align2RegClassID:
2488case AMDGPU::AV_128RegClassID:
2489case AMDGPU::AV_128_Align2RegClassID:
2490case AMDGPU::SReg_128_XNULLRegClassID:
2492case AMDGPU::SGPR_160RegClassID:
2493case AMDGPU::SReg_160RegClassID:
2494case AMDGPU::VReg_160RegClassID:
2495case AMDGPU::AReg_160RegClassID:
2496case AMDGPU::VReg_160_Align2RegClassID:
2497case AMDGPU::AReg_160_Align2RegClassID:
2498case AMDGPU::AV_160RegClassID:
2499case AMDGPU::AV_160_Align2RegClassID:
2501case AMDGPU::SGPR_192RegClassID:
2502case AMDGPU::SReg_192RegClassID:
2503case AMDGPU::VReg_192RegClassID:
2504case AMDGPU::AReg_192RegClassID:
2505case AMDGPU::VReg_192_Align2RegClassID:
2506case AMDGPU::AReg_192_Align2RegClassID:
2507case AMDGPU::AV_192RegClassID:
2508case AMDGPU::AV_192_Align2RegClassID:
2510case AMDGPU::SGPR_224RegClassID:
2511case AMDGPU::SReg_224RegClassID:
2512case AMDGPU::VReg_224RegClassID:
2513case AMDGPU::AReg_224RegClassID:
2514case AMDGPU::VReg_224_Align2RegClassID:
2515case AMDGPU::AReg_224_Align2RegClassID:
2516case AMDGPU::AV_224RegClassID:
2517case AMDGPU::AV_224_Align2RegClassID:
2519case AMDGPU::SGPR_256RegClassID:
2520case AMDGPU::SReg_256RegClassID:
2521case AMDGPU::VReg_256RegClassID:
2522case AMDGPU::AReg_256RegClassID:
2523case AMDGPU::VReg_256_Align2RegClassID:
2524case AMDGPU::AReg_256_Align2RegClassID:
2525case AMDGPU::AV_256RegClassID:
2526case AMDGPU::AV_256_Align2RegClassID:
2527case AMDGPU::SReg_256_XNULLRegClassID:
2529case AMDGPU::SGPR_288RegClassID:
2530case AMDGPU::SReg_288RegClassID:
2531case AMDGPU::VReg_288RegClassID:
2532case AMDGPU::AReg_288RegClassID:
2533case AMDGPU::VReg_288_Align2RegClassID:
2534case AMDGPU::AReg_288_Align2RegClassID:
2535case AMDGPU::AV_288RegClassID:
2536case AMDGPU::AV_288_Align2RegClassID:
2538case AMDGPU::SGPR_320RegClassID:
2539case AMDGPU::SReg_320RegClassID:
2540case AMDGPU::VReg_320RegClassID:
2541case AMDGPU::AReg_320RegClassID:
2542case AMDGPU::VReg_320_Align2RegClassID:
2543case AMDGPU::AReg_320_Align2RegClassID:
2544case AMDGPU::AV_320RegClassID:
2545case AMDGPU::AV_320_Align2RegClassID:
2547case AMDGPU::SGPR_352RegClassID:
2548case AMDGPU::SReg_352RegClassID:
2549case AMDGPU::VReg_352RegClassID:
2550case AMDGPU::AReg_352RegClassID:
2551case AMDGPU::VReg_352_Align2RegClassID:
2552case AMDGPU::AReg_352_Align2RegClassID:
2553case AMDGPU::AV_352RegClassID:
2554case AMDGPU::AV_352_Align2RegClassID:
2556case AMDGPU::SGPR_384RegClassID:
2557case AMDGPU::SReg_384RegClassID:
2558case AMDGPU::VReg_384RegClassID:
2559case AMDGPU::AReg_384RegClassID:
2560case AMDGPU::VReg_384_Align2RegClassID:
2561case AMDGPU::AReg_384_Align2RegClassID:
2562case AMDGPU::AV_384RegClassID:
2563case AMDGPU::AV_384_Align2RegClassID:
2565case AMDGPU::SGPR_512RegClassID:
2566case AMDGPU::SReg_512RegClassID:
2567case AMDGPU::VReg_512RegClassID:
2568case AMDGPU::AReg_512RegClassID:
2569case AMDGPU::VReg_512_Align2RegClassID:
2570case AMDGPU::AReg_512_Align2RegClassID:
2571case AMDGPU::AV_512RegClassID:
2572case AMDGPU::AV_512_Align2RegClassID:
2574case AMDGPU::SGPR_1024RegClassID:
2575case AMDGPU::SReg_1024RegClassID:
2576case AMDGPU::VReg_1024RegClassID:
2577case AMDGPU::AReg_1024RegClassID:
2578case AMDGPU::VReg_1024_Align2RegClassID:
2579case AMDGPU::AReg_1024_Align2RegClassID:
2580case AMDGPU::AV_1024RegClassID:
2581case AMDGPU::AV_1024_Align2RegClassID:
2595unsigned RCID =
Desc.operands()[OpNo].RegClass;
2604return (Val == llvm::bit_cast<uint64_t>(0.0)) ||
2605 (Val == llvm::bit_cast<uint64_t>(1.0)) ||
2606 (Val == llvm::bit_cast<uint64_t>(-1.0)) ||
2607 (Val == llvm::bit_cast<uint64_t>(0.5)) ||
2608 (Val == llvm::bit_cast<uint64_t>(-0.5)) ||
2609 (Val == llvm::bit_cast<uint64_t>(2.0)) ||
2610 (Val == llvm::bit_cast<uint64_t>(-2.0)) ||
2611 (Val == llvm::bit_cast<uint64_t>(4.0)) ||
2612 (Val == llvm::bit_cast<uint64_t>(-4.0)) ||
2613 (Val == 0x3fc45f306dc9c882 && HasInv2Pi);
2620// The actual type of the operand does not seem to matter as long 2621// as the bits match one of the inline immediate values. For example: 2623// -nan has the hexadecimal encoding of 0xfffffffe which is -2 in decimal, 2624// so it is a legal inline immediate. 2626// 1065353216 has the hexadecimal encoding 0x3f800000 which is 1.0f in 2627// floating-point, so it is a legal inline immediate. 2630return (Val == llvm::bit_cast<uint32_t>(0.0f)) ||
2631 (Val == llvm::bit_cast<uint32_t>(1.0f)) ||
2632 (Val == llvm::bit_cast<uint32_t>(-1.0f)) ||
2633 (Val == llvm::bit_cast<uint32_t>(0.5f)) ||
2634 (Val == llvm::bit_cast<uint32_t>(-0.5f)) ||
2635 (Val == llvm::bit_cast<uint32_t>(2.0f)) ||
2636 (Val == llvm::bit_cast<uint32_t>(-2.0f)) ||
2637 (Val == llvm::bit_cast<uint32_t>(4.0f)) ||
2638 (Val == llvm::bit_cast<uint32_t>(-4.0f)) ||
2639 (Val == 0x3e22f983 && HasInv2Pi);
2648return Val == 0x3F00 ||
// 0.5 2649 Val == 0xBF00 ||
// -0.5 2650 Val == 0x3F80 ||
// 1.0 2651 Val == 0xBF80 ||
// -1.0 2652 Val == 0x4000 ||
// 2.0 2653 Val == 0xC000 ||
// -2.0 2654 Val == 0x4080 ||
// 4.0 2655 Val == 0xC080 ||
// -4.0 2656 Val == 0x3E22;
// 1.0 / (2.0 * pi) 2669return Val == 0x3C00 ||
// 1.0 2670 Val == 0xBC00 ||
// -1.0 2671 Val == 0x3800 ||
// 0.5 2672 Val == 0xB800 ||
// -0.5 2673 Val == 0x4000 ||
// 2.0 2674 Val == 0xC000 ||
// -2.0 2675 Val == 0x4400 ||
// 4.0 2676 Val == 0xC400 ||
// -4.0 2677 Val == 0x3118;
// 1/2pi 2681// Unfortunately, the Instruction Set Architecture Reference Guide is 2682// misleading about how the inline operands work for (packed) 16-bit 2683// instructions. In a nutshell, the actual HW behavior is: 2685// - integer encodings (-16 .. 64) are always produced as sign-extended 2687// - float encodings are produced as: 2688// - for F16 instructions: corresponding half-precision float values in 2689// the LSBs, 0 in the MSBs 2690// - for UI16 instructions: corresponding single-precision float value 2696return 192 + std::abs(
Signed);
2701case 0x3800:
return 240;
// 0.5 2702case 0xB800:
return 241;
// -0.5 2703case 0x3C00:
return 242;
// 1.0 2704case 0xBC00:
return 243;
// -1.0 2705case 0x4000:
return 244;
// 2.0 2706case 0xC000:
return 245;
// -2.0 2707case 0x4400:
return 246;
// 4.0 2708case 0xC400:
return 247;
// -4.0 2709case 0x3118:
return 248;
// 1.0 / (2.0 * pi) 2716case 0x3F000000:
return 240;
// 0.5 2717case 0xBF000000:
return 241;
// -0.5 2718case 0x3F800000:
return 242;
// 1.0 2719case 0xBF800000:
return 243;
// -1.0 2720case 0x40000000:
return 244;
// 2.0 2721case 0xC0000000:
return 245;
// -2.0 2722case 0x40800000:
return 246;
// 4.0 2723case 0xC0800000:
return 247;
// -4.0 2724case 0x3E22F983:
return 248;
// 1.0 / (2.0 * pi) 2733// Encoding of the literal as an inline constant for a V_PK_*_IU16 instruction 2739// Encoding of the literal as an inline constant for a V_PK_*_BF16 instruction 2747return 192 + std::abs(
Signed);
2751case 0x3F00:
return 240;
// 0.5 2752case 0xBF00:
return 241;
// -0.5 2753case 0x3F80:
return 242;
// 1.0 2754case 0xBF80:
return 243;
// -1.0 2755case 0x4000:
return 244;
// 2.0 2756case 0xC000:
return 245;
// -2.0 2757case 0x4080:
return 246;
// 4.0 2758case 0xC080:
return 247;
// -4.0 2759case 0x3E22:
return 248;
// 1.0 / (2.0 * pi) 2767// Encoding of the literal as an inline constant for a V_PK_*_F16 instruction 2773// Whether the given literal can be inlined for a V_PK_* instruction. 2793// Whether the given literal can be inlined for a V_PK_*_IU16 instruction. 2798// Whether the given literal can be inlined for a V_PK_*_BF16 instruction. 2803// Whether the given literal can be inlined for a V_PK_*_F16 instruction. 2810return !(Val & 0xffffffffu);
2812return isUInt<32>(Val) || isInt<32>(Val);
2818// Arguments to compute shaders are never a source of divergence. 2834// For non-compute shaders, SGPR inputs are marked with either inreg or 2835// byval. Everything else is in VGPRs. 2836returnA->hasAttribute(Attribute::InReg) ||
2837A->hasAttribute(Attribute::ByVal);
2839// TODO: treat i1 as divergent? 2840returnA->hasAttribute(Attribute::InReg);
2845// Arguments to compute shaders are never a source of divergence. 2861// For non-compute shaders, SGPR inputs are marked with either inreg or 2862// byval. Everything else is in VGPRs. 2875 int64_t EncodedOffset) {
2877return isUInt<23>(EncodedOffset);
2880 : isUInt<8>(EncodedOffset);
2884 int64_t EncodedOffset,
2887return isInt<24>(EncodedOffset);
2891 isInt<21>(EncodedOffset);
2895return (ByteOffset & 3) == 0;
2904return ByteOffset >> 2;
2908 int64_t ByteOffset,
bool IsBuffer,
2910// For unbuffered smem loads, it is illegal for the Immediate Offset to be 2911// negative if the resulting (Offset + (M0 or SOffset or zero) is negative. 2912// Handle case where SOffset is not present. 2917return isInt<24>(ByteOffset) ? std::optional<int64_t>(ByteOffset)
2920// The signed version is always a byte offset. 2923return isInt<20>(ByteOffset) ? std::optional<int64_t>(ByteOffset)
2932 ? std::optional<int64_t>(EncodedOffset)
2937 int64_t ByteOffset) {
2942return isUInt<32>(EncodedOffset) ? std::optional<int64_t>(EncodedOffset)
2957structSourceOfDivergence {
2960const SourceOfDivergence *lookupSourceOfDivergence(
unsignedIntr);
2967#define GET_SourcesOfDivergence_IMPL 2968#define GET_UniformIntrinsics_IMPL 2969#define GET_Gfx9BufferFormat_IMPL 2970#define GET_Gfx10BufferFormat_IMPL 2971#define GET_Gfx11PlusBufferFormat_IMPL 2973#include "AMDGPUGenSearchableTables.inc" 2975}
// end anonymous namespace 2978return lookupSourceOfDivergence(IntrID);
2982return lookupAlwaysUniform(IntrID);
2990 ? getGfx11PlusBufferFormatInfo(BitsPerComp, NumComponents,
2992 :
isGFX10(STI) ? getGfx10BufferFormatInfo(BitsPerComp,
2993 NumComponents, NumFormat)
2994 : getGfx9BufferFormatInfo(BitsPerComp,
2995 NumComponents, NumFormat);
3002 : getGfx9BufferFormatInfo(
Format);
3006for (
autoOpName : { OpName::vdst, OpName::src0, OpName::src1,
3012if (OpDesc.
operands()[
Idx].RegClass == AMDGPU::VReg_64RegClassID ||
3013 OpDesc.
operands()[
Idx].RegClass == AMDGPU::VReg_64_Align2RegClassID)
3025// Currently this is 128 for all subtargets unsigned const MachineRegisterInfo * MRI
static llvm::cl::opt< unsigned > DefaultAMDHSACodeObjectVersion("amdhsa-code-object-version", llvm::cl::Hidden, llvm::cl::init(llvm::AMDGPU::AMDHSA_COV5), 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< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
unsigned const TargetRegisterInfo * TRI
#define S_00B848_MEM_ORDERED(x)
#define S_00B848_WGP_MODE(x)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned unsigned DefaultVal
This file contains some functions that are useful when dealing with strings.
bool isSramEccSupported() const
void setTargetIDFromFeaturesString(StringRef FS)
TargetIDSetting getXnackSetting() const
AMDGPUTargetID(const MCSubtargetInfo &STI)
bool isXnackSupported() const
void setTargetIDFromTargetIDStream(StringRef TargetID)
std::string toString() const
TargetIDSetting getSramEccSetting() const
unsigned getIndexInParsedOperands(unsigned CompOprIdx) const
unsigned getIndexOfDstInParsedOperands() const
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
unsigned getCompParsedSrcOperandsNum() const
std::optional< unsigned > getInvalidCompOperandIndex(std::function< unsigned(unsigned, unsigned)> GetRegIdx, bool SkipSrc=false) const
std::array< unsigned, Component::MAX_OPR_NUM > RegIndices
This class represents an incoming formal argument to a Function.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
CallingConv::ID getCallingConv() const
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
This class represents an Operation in the Expression.
constexpr bool test(unsigned I) const
unsigned getAddressSpace() const
This is an important class for using LLVM in a threaded context.
void emitError(const Instruction *I, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
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
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.
MCRegisterClass - Base class of TargetRegisterClass.
unsigned getID() const
getID() - Return the register class ID number.
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.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
const FeatureBitset & getFeatureBits() const
A Module instance is used to store all the information related to an LLVM module.
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...
StringRef - 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.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
constexpr size_t size() const
size - Get the string size.
bool ends_with(StringRef Suffix) const
Check if this string ends with the given Suffix.
Manages the enabling and disabling of subtarget specific features.
const std::vector< std::string > & getFeatures() const
Returns the vector of individual subtarget features.
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#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.
@ LOCAL_ADDRESS
Address space for local memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst)
unsigned decodeFieldSaSdst(unsigned Encoded)
unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc)
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)
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI)
unsigned decodeFieldVmVsrc(unsigned Encoded)
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 VersionMajor
HSA metadata major version.
@ COMPLETION_ACTION_OFFSET
@ MULTIGRID_SYNC_ARG_OFFSET
unsigned getVGPREncodingGranule(const MCSubtargetInfo *STI, std::optional< bool > EnableWavefrontSize32)
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI)
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getWavefrontSize(const MCSubtargetInfo *STI)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getMaxFlatWorkGroupSize(const MCSubtargetInfo *STI)
unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI)
unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI)
unsigned getLocalMemorySize(const MCSubtargetInfo *STI)
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo *STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
unsigned getEUsPerCU(const MCSubtargetInfo *STI)
@ FIXED_NUM_SGPRS_FOR_INIT_BUG
unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI)
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
static TargetIDSetting getTargetIDSettingFromFeatureString(StringRef FeatureString)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI)
unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, bool Addressable)
unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs)
unsigned getMinWavesPerEU(const MCSubtargetInfo *STI)
unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI)
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo *STI, unsigned NumVGPRs)
unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
unsigned getEncodedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, AMDGPUSubtarget::Generation Gen)
static unsigned getGranulatedNumRegisterBlocks(unsigned NumRegs, unsigned Granule)
unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI, std::optional< bool > EnableWavefrontSize32)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo *STI)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI)
StringLiteral const UfmtSymbolicGFX11[]
bool isValidUnifiedFormat(unsigned Id, const MCSubtargetInfo &STI)
unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI)
StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI)
unsigned const DfmtNfmt2UFmtGFX10[]
StringLiteral const DfmtSymbolic[]
static StringLiteral const * getNfmtLookupTable(const MCSubtargetInfo &STI)
bool isValidNfmt(unsigned Id, const MCSubtargetInfo &STI)
StringLiteral const NfmtSymbolicGFX10[]
bool isValidDfmtNfmt(unsigned Id, const MCSubtargetInfo &STI)
int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt, const MCSubtargetInfo &STI)
StringRef getDfmtName(unsigned Id)
int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt)
int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI)
bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI)
StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI)
unsigned const DfmtNfmt2UFmtGFX11[]
StringLiteral const NfmtSymbolicVI[]
StringLiteral const NfmtSymbolicSICI[]
int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI)
int64_t getDfmt(const StringRef Name)
StringLiteral const UfmtSymbolicGFX10[]
void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt)
uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId)
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)
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
bool isGCN3Encoding(const MCSubtargetInfo &STI)
bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi)
bool isGFX10_BEncoding(const MCSubtargetInfo &STI)
bool isGFX10_GFX11(const MCSubtargetInfo &STI)
bool isInlinableLiteralV216(uint32_t Literal, uint8_t OpType)
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc, unsigned OpNo)
Get size of register operand.
void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt)
Decodes Vmcnt, Expcnt and Lgkmcnt from given Waitcnt for given isa Version, and writes decoded values...
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)
bool isVOPCAsmOnly(unsigned Opc)
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding, unsigned VDataDwords, unsigned VAddrDwords)
bool getMTBUFHasSrsrc(unsigned Opc)
std::optional< int64_t > getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST, int64_t ByteOffset)
static bool isSymbolicCustomOperandEncoding(const CustomOperandVal *Opr, int Size, unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo)
Does this operand support only inlinable literals?
unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc)
const int OPR_ID_UNSUPPORTED
bool shouldEmitConstantsToTextSection(const Triple &TT)
bool isInlinableLiteralV2I16(uint32_t Literal)
int getMTBUFElements(unsigned Opc)
bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI)
static int encodeCustomOperandVal(const CustomOperandVal &Op, int64_t InputVal)
int32_t getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR)
bool isGFX10(const MCSubtargetInfo &STI)
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
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)
CanBeVOPD getCanBeVOPD(unsigned Opc)
bool hasPackedD16(const MCSubtargetInfo &STI)
unsigned getStorecntBitMask(const IsaVersion &Version)
unsigned getLdsDwGranularity(const MCSubtargetInfo &ST)
bool isGFX940(const MCSubtargetInfo &STI)
bool isEntryFunctionCC(CallingConv::ID CC)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
const int OPR_VAL_INVALID
bool getSMEMIsBuffer(unsigned Opc)
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
bool isGroupSegment(const GlobalValue *GV)
IsaVersion getIsaVersion(StringRef GPU)
bool getMTBUFHasSoffset(unsigned Opc)
bool hasXNACK(const MCSubtargetInfo &STI)
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
static unsigned getCombinedCountBitMask(const IsaVersion &Version, bool IsStore)
unsigned getVOPDOpcode(unsigned Opc)
bool isDPALU_DPP(const MCInstrDesc &OpDesc)
unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt)
Encodes Vmcnt, Expcnt and Lgkmcnt into Waitcnt for given isa Version.
bool isVOPC64DPP(unsigned Opc)
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool isCompute(CallingConv::ID cc)
bool getMAIIsGFX940XDL(unsigned Opc)
bool isSI(const MCSubtargetInfo &STI)
unsigned getDefaultAMDHSACodeObjectVersion()
bool isReadOnlySegment(const GlobalValue *GV)
bool isArgPassedInSGPR(const Argument *A)
bool isIntrinsicAlwaysUniform(unsigned IntrID)
int getMUBUFBaseOpcode(unsigned Opc)
unsigned getAMDHSACodeObjectVersion(const Module &M)
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getWaitcntBitMask(const IsaVersion &Version)
bool getVOP3IsSingle(unsigned Opc)
bool isGFX9(const MCSubtargetInfo &STI)
bool getVOP1IsSingle(unsigned Opc)
static bool isDwordAligned(uint64_t ByteOffset)
unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST)
bool isGFX10_AEncoding(const MCSubtargetInfo &STI)
bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this a KImm operand?
bool getHasColorExport(const Function &F)
int getMTBUFBaseOpcode(unsigned Opc)
bool isChainCC(CallingConv::ID CC)
bool isGFX90A(const MCSubtargetInfo &STI)
unsigned getSamplecntBitMask(const IsaVersion &Version)
unsigned getDefaultQueueImplicitArgPosition(unsigned CodeObjectVersion)
bool hasSRAMECC(const MCSubtargetInfo &STI)
bool getHasDepthExport(const Function &F)
bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI)
bool getMUBUFHasVAddr(unsigned Opc)
int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily)
bool isTrue16Inst(unsigned Opc)
bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc)
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 isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this an AMDGPU specific source operand? These include registers, inline constants,...
unsigned getKmcntBitMask(const IsaVersion &Version)
unsigned getVmcntBitMask(const IsaVersion &Version)
bool isNotGFX10Plus(const MCSubtargetInfo &STI)
bool hasMAIInsts(const MCSubtargetInfo &STI)
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
bool isKernelCC(const Function *Func)
bool isGenericAtomic(unsigned Opc)
Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt)
bool isGFX8Plus(const MCSubtargetInfo &STI)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, uint64_t NamedIdx)
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 hasSMRDSignedImmOffset(const MCSubtargetInfo &ST)
bool hasMIMG_R128(const MCSubtargetInfo &STI)
bool hasGFX10_3Insts(const MCSubtargetInfo &STI)
bool hasG16(const MCSubtargetInfo &STI)
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode, const MIMGDimInfo *Dim, bool IsA16, bool IsG16Supported)
int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements)
unsigned getExpcntBitMask(const IsaVersion &Version)
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI)
bool getMUBUFHasSoffset(unsigned Opc)
bool isNotGFX11Plus(const MCSubtargetInfo &STI)
bool isGFX11Plus(const MCSubtargetInfo &STI)
std::optional< unsigned > getInlineEncodingV2F16(uint32_t Literal)
bool isInlineValue(unsigned Reg)
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
bool isShader(CallingConv::ID cc)
unsigned getHostcallImplicitArgPosition(unsigned CodeObjectVersion)
static unsigned getDefaultCustomOperandEncoding(const CustomOperandVal *Opr, int Size, const MCSubtargetInfo &STI)
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)
std::optional< int64_t > getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset, bool IsBuffer, bool HasSOffset)
bool isGlobalSegment(const GlobalValue *GV)
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
@ OPERAND_REG_INLINE_C_LAST
@ OPERAND_REG_INLINE_C_FP64
@ OPERAND_REG_INLINE_C_V2BF16
@ OPERAND_REG_IMM_V2INT16
@ OPERAND_REG_INLINE_AC_V2FP16
@ OPERAND_REG_INLINE_AC_FIRST
@ OPERAND_REG_INLINE_C_V2FP16
@ OPERAND_REG_INLINE_AC_V2INT16
@ OPERAND_REG_INLINE_AC_FP16
@ OPERAND_REG_INLINE_AC_FP32
@ OPERAND_REG_INLINE_AC_V2BF16
@ OPERAND_REG_INLINE_C_FIRST
@ OPERAND_REG_INLINE_C_FP32
@ OPERAND_REG_INLINE_AC_LAST
@ OPERAND_REG_INLINE_C_V2INT16
@ OPERAND_REG_INLINE_AC_FP64
@ OPERAND_REG_INLINE_C_FP16
@ OPERAND_REG_INLINE_C_V2FP32
@ OPERAND_REG_IMM_FP32_DEFERRED
@ OPERAND_REG_IMM_FP16_DEFERRED
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo *STI)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
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 isCvt_F32_Fp8_Bf8_e64(unsigned Opc)
Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt)
std::optional< unsigned > getInlineEncodingV2I16(uint32_t Literal)
unsigned getRegBitWidth(const TargetRegisterClass &RC)
Get the size in bits of a register from the register class RC.
static unsigned encodeStorecntDscnt(const IsaVersion &Version, unsigned Storecnt, unsigned Dscnt)
int getMCOpcode(uint16_t Opcode, unsigned Gen)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
bool getMUBUFIsBufferInv(unsigned Opc)
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 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)
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels)
bool isModuleEntryFunctionCC(CallingConv::ID CC)
bool isNotGFX12Plus(const MCSubtargetInfo &STI)
bool getMTBUFHasVAddr(unsigned Opc)
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)
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 getMultigridSyncArgImplicitArgPosition(unsigned CodeObjectVersion)
bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI)
bool isGFX9_GFX10(const MCSubtargetInfo &STI)
int getMUBUFElements(unsigned Opc)
static unsigned encodeLoadcntDscnt(const IsaVersion &Version, unsigned Loadcnt, unsigned Dscnt)
const GcnBufferFormatInfo * getGcnBufferFormatInfo(uint8_t BitsPerComp, uint8_t NumComponents, uint8_t NumFormat, const MCSubtargetInfo &STI)
bool isGraphics(CallingConv::ID cc)
unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc)
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.
@ 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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ ELFABIVERSION_AMDGPU_HSA_V4
@ ELFABIVERSION_AMDGPU_HSA_V5
@ ELFABIVERSION_AMDGPU_HSA_V6
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
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.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
@ AlwaysUniform
The result values are always uniform.
@ Default
The result values are uniform if and only if all operands are 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
Instruction set architecture version.
Represents the counter values to wait for in an s_waitcnt instruction.
Description of the encoding of one expression Op.