LLVM 22.0.0git
AMDGPUBaseInfo.h
Go to the documentation of this file.
1//===- AMDGPUBaseInfo.h - Top level definitions for AMDGPU ------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
10#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
11
12#include "AMDGPUSubtarget.h"
13#include "SIDefines.h"
14#include "llvm/IR/CallingConv.h"
15#include "llvm/IR/InstrTypes.h"
16#include "llvm/IR/Module.h"
18#include <array>
19#include <functional>
20#include <utility>
21
22// Pull in OpName enum definition and getNamedOperandIdx() declaration.
23#define GET_INSTRINFO_OPERAND_ENUM
24#include "AMDGPUGenInstrInfo.inc"
25
27
28namespace llvm {
29
30struct Align;
31class Argument;
32class Function;
33class GlobalValue;
34class MCInstrInfo;
35class MCRegisterClass;
36class MCRegisterInfo;
37class MCSubtargetInfo;
38class MDNode;
39class StringRef;
40class Triple;
41class raw_ostream;
42
43namespace AMDGPU {
44
45struct AMDGPUMCKernelCodeT;
46struct IsaVersion;
47
48/// Generic target versions emitted by this version of LLVM.
49///
50/// These numbers are incremented every time a codegen breaking change occurs
51/// within a generic family.
52namespace GenericVersion {
53static constexpr unsigned GFX9 = 1;
54static constexpr unsigned GFX9_4 = 1;
55static constexpr unsigned GFX10_1 = 1;
56static constexpr unsigned GFX10_3 = 1;
57static constexpr unsigned GFX11 = 1;
58static constexpr unsigned GFX12 = 1;
59} // namespace GenericVersion
60
61enum { AMDHSA_COV4 = 4, AMDHSA_COV5 = 5, AMDHSA_COV6 = 6 };
62
63enum class FPType { None, FP4, FP8 };
64
65/// \returns True if \p STI is AMDHSA.
66bool isHsaAbi(const MCSubtargetInfo &STI);
67
68/// \returns Code object version from the IR module flag.
69unsigned getAMDHSACodeObjectVersion(const Module &M);
70
71/// \returns Code object version from ELF's e_ident[EI_ABIVERSION].
72unsigned getAMDHSACodeObjectVersion(unsigned ABIVersion);
73
74/// \returns The default HSA code object version. This should only be used when
75/// we lack a more accurate CodeObjectVersion value (e.g. from the IR module
76/// flag or a .amdhsa_code_object_version directive)
78
79/// \returns ABIVersion suitable for use in ELF's e_ident[EI_ABIVERSION]. \param
80/// CodeObjectVersion is a value returned by getAMDHSACodeObjectVersion().
81uint8_t getELFABIVersion(const Triple &OS, unsigned CodeObjectVersion);
82
83/// \returns The offset of the multigrid_sync_arg argument from implicitarg_ptr
84unsigned getMultigridSyncArgImplicitArgPosition(unsigned COV);
85
86/// \returns The offset of the hostcall pointer argument from implicitarg_ptr
87unsigned getHostcallImplicitArgPosition(unsigned COV);
88
89unsigned getDefaultQueueImplicitArgPosition(unsigned COV);
90unsigned getCompletionActionImplicitArgPosition(unsigned COV);
91
93 unsigned Format;
94 unsigned BitsPerComp;
95 unsigned NumComponents;
96 unsigned NumFormat;
97 unsigned DataFormat;
98};
99
105
112
116
118 unsigned T16Op;
119 unsigned HiOp;
120 unsigned LoOp;
121};
122
127
128#define GET_MIMGBaseOpcode_DECL
129#define GET_MIMGDim_DECL
130#define GET_MIMGEncoding_DECL
131#define GET_MIMGLZMapping_DECL
132#define GET_MIMGMIPMapping_DECL
133#define GET_MIMGBiASMapping_DECL
134#define GET_MAIInstInfoTable_DECL
135#define GET_isMFMA_F8F6F4Table_DECL
136#define GET_isCvtScaleF32_F32F16ToF8F4Table_DECL
137#define GET_True16D16Table_DECL
138#define GET_WMMAInstInfoTable_DECL
139#include "AMDGPUGenSearchableTables.inc"
140
141namespace IsaInfo {
142
143enum {
144 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
145 // doesn't spill SGPRs as much as when 80 is set.
148};
149
151
153private:
154 const MCSubtargetInfo &STI;
155 TargetIDSetting XnackSetting;
156 TargetIDSetting SramEccSetting;
157
158public:
159 explicit AMDGPUTargetID(const MCSubtargetInfo &STI);
160 ~AMDGPUTargetID() = default;
161
162 /// \return True if the current xnack setting is not "Unsupported".
163 bool isXnackSupported() const {
164 return XnackSetting != TargetIDSetting::Unsupported;
165 }
166
167 /// \returns True if the current xnack setting is "On" or "Any".
168 bool isXnackOnOrAny() const {
169 return XnackSetting == TargetIDSetting::On ||
170 XnackSetting == TargetIDSetting::Any;
171 }
172
173 /// \returns True if current xnack setting is "On" or "Off",
174 /// false otherwise.
179
180 /// \returns The current xnack TargetIDSetting, possible options are
181 /// "Unsupported", "Any", "Off", and "On".
182 TargetIDSetting getXnackSetting() const { return XnackSetting; }
183
184 /// Sets xnack setting to \p NewXnackSetting.
185 void setXnackSetting(TargetIDSetting NewXnackSetting) {
186 XnackSetting = NewXnackSetting;
187 }
188
189 /// \return True if the current sramecc setting is not "Unsupported".
190 bool isSramEccSupported() const {
191 return SramEccSetting != TargetIDSetting::Unsupported;
192 }
193
194 /// \returns True if the current sramecc setting is "On" or "Any".
195 bool isSramEccOnOrAny() const {
196 return SramEccSetting == TargetIDSetting::On ||
197 SramEccSetting == TargetIDSetting::Any;
198 }
199
200 /// \returns True if current sramecc setting is "On" or "Off",
201 /// false otherwise.
206
207 /// \returns The current sramecc TargetIDSetting, possible options are
208 /// "Unsupported", "Any", "Off", and "On".
209 TargetIDSetting getSramEccSetting() const { return SramEccSetting; }
210
211 /// Sets sramecc setting to \p NewSramEccSetting.
212 void setSramEccSetting(TargetIDSetting NewSramEccSetting) {
213 SramEccSetting = NewSramEccSetting;
214 }
215
218
219 /// \returns String representation of an object.
220 std::string toString() const;
221};
222
223/// \returns Wavefront size for given subtarget \p STI.
224unsigned getWavefrontSize(const MCSubtargetInfo *STI);
225
226/// \returns Local memory size in bytes for given subtarget \p STI.
227unsigned getLocalMemorySize(const MCSubtargetInfo *STI);
228
229/// \returns Maximum addressable local memory size in bytes for given subtarget
230/// \p STI.
232
233/// \returns Number of execution units per compute unit for given subtarget \p
234/// STI.
235unsigned getEUsPerCU(const MCSubtargetInfo *STI);
236
237/// \returns Maximum number of work groups per compute unit for given subtarget
238/// \p STI and limited by given \p FlatWorkGroupSize.
239unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI,
240 unsigned FlatWorkGroupSize);
241
242/// \returns Minimum number of waves per execution unit for given subtarget \p
243/// STI.
244unsigned getMinWavesPerEU(const MCSubtargetInfo *STI);
245
246/// \returns Maximum number of waves per execution unit for given subtarget \p
247/// STI without any kind of limitation.
248unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI);
249
250/// \returns Number of waves per execution unit required to support the given \p
251/// FlatWorkGroupSize.
253 unsigned FlatWorkGroupSize);
254
255/// \returns Minimum flat work group size for given subtarget \p STI.
256unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI);
257
258/// \returns Maximum flat work group size for given subtarget \p STI.
259unsigned getMaxFlatWorkGroupSize(const MCSubtargetInfo *STI);
260
261/// \returns Number of waves per work group for given subtarget \p STI and
262/// \p FlatWorkGroupSize.
263unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI,
264 unsigned FlatWorkGroupSize);
265
266/// \returns SGPR allocation granularity for given subtarget \p STI.
267unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI);
268
269/// \returns SGPR encoding granularity for given subtarget \p STI.
270unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI);
271
272/// \returns Total number of SGPRs for given subtarget \p STI.
273unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI);
274
275/// \returns Addressable number of SGPRs for given subtarget \p STI.
276unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI);
277
278/// \returns Minimum number of SGPRs that meets the given number of waves per
279/// execution unit requirement for given subtarget \p STI.
280unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
281
282/// \returns Maximum number of SGPRs that meets the given number of waves per
283/// execution unit requirement for given subtarget \p STI.
284unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
285 bool Addressable);
286
287/// \returns Number of extra SGPRs implicitly required by given subtarget \p
288/// STI when the given special registers are used.
289unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
290 bool FlatScrUsed, bool XNACKUsed);
291
292/// \returns Number of extra SGPRs implicitly required by given subtarget \p
293/// STI when the given special registers are used. XNACK is inferred from
294/// \p STI.
295unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
296 bool FlatScrUsed);
297
298/// \returns Number of SGPR blocks needed for given subtarget \p STI when
299/// \p NumSGPRs are used. \p NumSGPRs should already include any special
300/// register counts.
301unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs);
302
303/// \returns VGPR allocation granularity for given subtarget \p STI.
304///
305/// For subtargets which support it, \p EnableWavefrontSize32 should match
306/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
307unsigned
308getVGPRAllocGranule(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize,
309 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
310
311/// \returns VGPR encoding granularity for given subtarget \p STI.
312///
313/// For subtargets which support it, \p EnableWavefrontSize32 should match
314/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
316 const MCSubtargetInfo *STI,
317 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
318
319/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
320/// returns the allocation granule for ArchVGPRs.
321unsigned getArchVGPRAllocGranule();
322
323/// \returns Total number of VGPRs for given subtarget \p STI.
324unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI);
325
326/// \returns Addressable number of architectural VGPRs for a given subtarget \p
327/// STI.
329
330/// \returns Addressable number of VGPRs for given subtarget \p STI.
331unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI,
332 unsigned DynamicVGPRBlockSize);
333
334/// \returns Minimum number of VGPRs that meets given number of waves per
335/// execution unit requirement for given subtarget \p STI.
336unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
337 unsigned DynamicVGPRBlockSize);
338
339/// \returns Maximum number of VGPRs that meets given number of waves per
340/// execution unit requirement for given subtarget \p STI.
341unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
342 unsigned DynamicVGPRBlockSize);
343
344/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
345/// subtarget \p STI.
347 unsigned NumVGPRs,
348 unsigned DynamicVGPRBlockSize);
349
350/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
351/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
352unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
353 unsigned MaxWaves,
354 unsigned TotalNumVGPRs);
355
356/// \returns Occupancy for a given \p SGPRs usage, \p MaxWaves possible, and \p
357/// Gen.
358unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
360
361/// \returns Number of VGPR blocks needed for given subtarget \p STI when
362/// \p NumVGPRs are used. We actually return the number of blocks -1, since
363/// that's what we encode.
364///
365/// For subtargets which support it, \p EnableWavefrontSize32 should match the
366/// ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
368 const MCSubtargetInfo *STI, unsigned NumVGPRs,
369 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
370
371/// \returns Number of VGPR blocks that need to be allocated for the given
372/// subtarget \p STI when \p NumVGPRs are used.
374 const MCSubtargetInfo *STI, unsigned NumVGPRs,
375 unsigned DynamicVGPRBlockSize,
376 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
377
378} // end namespace IsaInfo
379
380// Represents a field in an encoded value.
381template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
383 static_assert(HighBit >= LowBit, "Invalid bit range!");
384 static constexpr unsigned Offset = LowBit;
385 static constexpr unsigned Width = HighBit - LowBit + 1;
386
388 static constexpr ValueType Default = D;
389
392
393 constexpr uint64_t encode() const { return Value; }
394 static ValueType decode(uint64_t Encoded) { return Encoded; }
395};
396
397// Represents a single bit in an encoded value.
398template <unsigned Bit, unsigned D = 0>
400
401// A helper for encoding and decoding multiple fields.
402template <typename... Fields> struct EncodingFields {
403 static constexpr uint64_t encode(Fields... Values) {
404 return ((Values.encode() << Values.Offset) | ...);
405 }
406
407 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
408 return {Fields::decode((Encoded >> Fields::Offset) &
409 maxUIntN(Fields::Width))...};
410 }
411};
412
414inline bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx) {
415 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
416}
417
420
441
444
446const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
447
457
459const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
460
463
466
468 MIMGBaseOpcode L;
469 MIMGBaseOpcode LZ;
470};
471
473 MIMGBaseOpcode MIP;
474 MIMGBaseOpcode NONMIP;
475};
476
478 MIMGBaseOpcode Bias;
479 MIMGBaseOpcode NoBias;
480};
481
483 MIMGBaseOpcode Offset;
484 MIMGBaseOpcode NoOffset;
485};
486
488 MIMGBaseOpcode G;
489 MIMGBaseOpcode G16;
490};
491
494
496 unsigned Opcode2Addr;
497 unsigned Opcode3Addr;
498};
499
502
505
508
511
513int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
514 unsigned VDataDwords, unsigned VAddrDwords);
515
517int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
518
520unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
521 const MIMGDimInfo *Dim, bool IsA16,
522 bool IsG16Supported);
523
532
534const MIMGInfo *getMIMGInfo(unsigned Opc);
535
537int getMTBUFBaseOpcode(unsigned Opc);
538
540int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
541
543int getMTBUFElements(unsigned Opc);
544
546bool getMTBUFHasVAddr(unsigned Opc);
547
549bool getMTBUFHasSrsrc(unsigned Opc);
550
552bool getMTBUFHasSoffset(unsigned Opc);
553
555int getMUBUFBaseOpcode(unsigned Opc);
556
558int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
559
561int getMUBUFElements(unsigned Opc);
562
564bool getMUBUFHasVAddr(unsigned Opc);
565
567bool getMUBUFHasSrsrc(unsigned Opc);
568
570bool getMUBUFHasSoffset(unsigned Opc);
571
573bool getMUBUFIsBufferInv(unsigned Opc);
574
576bool getMUBUFTfe(unsigned Opc);
577
579bool getSMEMIsBuffer(unsigned Opc);
580
582bool getVOP1IsSingle(unsigned Opc);
583
585bool getVOP2IsSingle(unsigned Opc);
586
588bool getVOP3IsSingle(unsigned Opc);
589
591bool isVOPC64DPP(unsigned Opc);
592
594bool isVOPCAsmOnly(unsigned Opc);
595
596/// Returns true if MAI operation is a double precision GEMM.
598bool getMAIIsDGEMM(unsigned Opc);
599
601bool getMAIIsGFX940XDL(unsigned Opc);
602
604bool getWMMAIsXDL(unsigned Opc);
605
606// Get an equivalent BitOp3 for a binary logical \p Opc.
607// \returns BitOp3 modifier for the logical operation or zero.
608// Used in VOPD3 conversion.
609unsigned getBitOp2(unsigned Opc);
610
611struct CanBeVOPD {
612 bool X;
613 bool Y;
614};
615
616/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
618unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
619
621CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3);
622
624uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
625
628 unsigned BLGP,
629 unsigned F8F8Opcode);
630
633
636 unsigned FmtB,
637 unsigned F8F8Opcode);
638
641 uint8_t NumComponents,
642 uint8_t NumFormat,
643 const MCSubtargetInfo &STI);
646 const MCSubtargetInfo &STI);
647
649int getMCOpcode(uint16_t Opcode, unsigned Gen);
650
652unsigned getVOPDOpcode(unsigned Opc, bool VOPD3);
653
655int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily,
656 bool VOPD3);
657
659bool isVOPD(unsigned Opc);
660
662bool isMAC(unsigned Opc);
663
665bool isPermlane16(unsigned Opc);
666
668bool isGenericAtomic(unsigned Opc);
669
671bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
672
673namespace VOPD {
674
685
686// LSB mask for VGPR banks per VOPD component operand.
687// 4 banks result in a mask 3, setting 2 lower bits.
688constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
689constexpr unsigned VOPD3_VGPR_BANK_MASKS[] = {1, 3, 3, 3};
690
691enum ComponentIndex : unsigned { X = 0, Y = 1 };
693constexpr unsigned COMPONENTS_NUM = 2;
694
695// Properties of VOPD components.
697private:
698 unsigned SrcOperandsNum = 0;
699 unsigned MandatoryLiteralIdx = ~0u;
700 bool HasSrc2Acc = false;
701 unsigned NumVOPD3Mods = 0;
702 unsigned Opcode = 0;
703 bool IsVOP3 = false;
704
705public:
706 ComponentProps() = default;
707 ComponentProps(const MCInstrDesc &OpDesc, bool VOP3Layout = false);
708
709 // Return the total number of src operands this component has.
710 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
711
712 // Return the number of src operands of this component visible to the parser.
714 return SrcOperandsNum - HasSrc2Acc;
715 }
716
717 // Return true iif this component has a mandatory literal.
718 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
719
720 // If this component has a mandatory literal, return component operand
721 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
724 return MandatoryLiteralIdx;
725 }
726
727 // Return true iif this component has operand
728 // with component index CompSrcIdx and this operand may be a register.
729 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
730 assert(CompSrcIdx < Component::MAX_SRC_NUM);
731 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
732 }
733
734 // Return true iif this component has tied src2.
735 bool hasSrc2Acc() const { return HasSrc2Acc; }
736
737 // Return a number of source modifiers if instruction is used in VOPD3.
738 unsigned getCompVOPD3ModsNum() const { return NumVOPD3Mods; }
739
740 // Return opcode of the component.
741 unsigned getOpcode() const { return Opcode; }
742
743 // Returns if component opcode is in VOP3 encoding.
744 unsigned isVOP3() const { return IsVOP3; }
745
746 // Return index of BitOp3 operand or -1.
747 int getBitOp3OperandIdx() const;
748
749private:
750 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
751 assert(CompSrcIdx < Component::MAX_SRC_NUM);
752 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
753 }
754};
755
756enum ComponentKind : unsigned {
757 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
758 COMPONENT_X, // A VOPD instruction, X component.
759 COMPONENT_Y, // A VOPD instruction, Y component.
761};
762
763// Interface functions of this class map VOPD component operand indices
764// to indices of operands in MachineInstr/MCInst or parsed operands array.
765//
766// Note that this class operates with 3 kinds of indices:
767// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
768// - MC operand indices (they refer operands in a MachineInstr/MCInst);
769// - parsed operand indices (they refer operands in parsed operands array).
770//
771// For SINGLE components mapping between these indices is trivial.
772// But things get more complicated for COMPONENT_X and
773// COMPONENT_Y because these components share the same
774// MachineInstr/MCInst and the same parsed operands array.
775// Below is an example of component operand to parsed operand
776// mapping for the following instruction:
777//
778// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
779//
780// PARSED COMPONENT PARSED
781// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
782// -------------------------------------------------------------------
783// "v_dual_add_f32" 0
784// v_dual_add_f32 v255 0 (DST) --> 1
785// v4 1 (SRC0) --> 2
786// v5 2 (SRC1) --> 3
787// "::" 4
788// "v_dual_mov_b32" 5
789// v_dual_mov_b32 v6 0 (DST) --> 6
790// v1 1 (SRC0) --> 7
791// -------------------------------------------------------------------
792//
794private:
795 // Regular MachineInstr/MCInst operands are ordered as follows:
796 // dst, src0 [, other src operands]
797 // VOPD MachineInstr/MCInst operands are ordered as follows:
798 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
799 // Each ComponentKind has operand indices defined below.
800 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
801
802 // VOPD3 instructions may have 2 or 3 source modifiers, src2 modifier is not
803 // used if there is tied accumulator. Indexing of this array:
804 // MC_SRC_IDX[VOPD3ModsNum][SrcNo]. This returns an index for a SINGLE
805 // instruction layout, add 1 for COMPONENT_X or COMPONENT_Y. For the second
806 // component add OpX.MCSrcNum + OpX.VOPD3ModsNum.
807 // For VOPD1/VOPD2 use column with zero modifiers.
808 static constexpr unsigned SINGLE_MC_SRC_IDX[4][3] = {
809 {1, 2, 3}, {2, 3, 4}, {2, 4, 5}, {2, 4, 6}};
810
811 // Parsed operands of regular instructions are ordered as follows:
812 // Mnemo dst src0 [vsrc1 ...]
813 // Parsed VOPD operands are ordered as follows:
814 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
815 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
816 // Each ComponentKind has operand indices defined below.
817 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
818 4 /* + OpX.ParsedSrcNum */};
819 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
820 2, 2, 5 /* + OpX.ParsedSrcNum */};
821
822private:
823 const ComponentKind Kind;
824 const ComponentProps PrevComp;
825 const unsigned VOPD3ModsNum;
826 const int BitOp3Idx; // Index of bitop3 operand or -1
827
828public:
829 // Create layout for COMPONENT_X or SINGLE component.
830 ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
831 : Kind(Kind), VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {
833 }
834
835 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
836 ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum,
837 int BitOp3Idx)
838 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps),
839 VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {}
840
841public:
842 // Return the index of dst operand in MCInst operands.
843 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
844
845 // Return the index of the specified src operand in MCInst operands.
846 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const {
847 assert(CompSrcIdx < Component::MAX_SRC_NUM);
848
849 if (Kind == SINGLE && CompSrcIdx == 2 && BitOp3Idx != -1)
850 return BitOp3Idx;
851
852 if (VOPD3) {
853 return SINGLE_MC_SRC_IDX[VOPD3ModsNum][CompSrcIdx] + getPrevCompSrcNum() +
854 getPrevCompVOPD3ModsNum() + (Kind != SINGLE ? 1 : 0);
855 }
856
857 return SINGLE_MC_SRC_IDX[0][CompSrcIdx] + getPrevCompSrcNum() +
858 (Kind != SINGLE ? 1 : 0);
859 }
860
861 // Return the index of dst operand in the parsed operands array.
863 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
864 }
865
866 // Return the index of the specified src operand in the parsed operands array.
867 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
868 assert(CompSrcIdx < Component::MAX_SRC_NUM);
869 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
870 }
871
872private:
873 unsigned getPrevCompSrcNum() const {
874 return PrevComp.getCompSrcOperandsNum();
875 }
876 unsigned getPrevCompParsedSrcNum() const {
877 return PrevComp.getCompParsedSrcOperandsNum();
878 }
879 unsigned getPrevCompVOPD3ModsNum() const {
880 return PrevComp.getCompVOPD3ModsNum();
881 }
882};
883
884// Layout and properties of VOPD components.
886public:
887 // Create ComponentInfo for COMPONENT_X or SINGLE component.
890 bool VOP3Layout = false)
891 : ComponentProps(OpDesc, VOP3Layout),
893
894 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
895 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps,
896 bool VOP3Layout = false)
897 : ComponentProps(OpDesc, VOP3Layout),
900
901 // Map component operand index to parsed operand index.
902 // Return 0 if the specified operand does not exist.
903 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
904};
905
906// Properties of VOPD instructions.
907class InstInfo {
908private:
909 const ComponentInfo CompInfo[COMPONENTS_NUM];
910
911public:
912 using RegIndices = std::array<unsigned, Component::MAX_OPR_NUM>;
913
914 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
915 : CompInfo{OpX, OpY} {}
916
917 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
918 : CompInfo{OprInfoX, OprInfoY} {}
919
920 const ComponentInfo &operator[](size_t ComponentIdx) const {
921 assert(ComponentIdx < COMPONENTS_NUM);
922 return CompInfo[ComponentIdx];
923 }
924
925 // Check VOPD operands constraints.
926 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
927 // for the specified component and MC operand. The callback must return 0
928 // if the operand is not a register or not a VGPR.
929 // If \p SkipSrc is set to true then constraints for source operands are not
930 // checked.
931 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
932 // even though it violates requirement to be from different banks.
933 // If \p VOPD3 is set to true both dst registers allowed to be either odd
934 // or even and instruction may have real src2 as opposed to tied accumulator.
935 bool hasInvalidOperand(std::function<unsigned(unsigned, unsigned)> GetRegIdx,
936 const MCRegisterInfo &MRI, bool SkipSrc = false,
937 bool AllowSameVGPR = false, bool VOPD3 = false) const {
938 return getInvalidCompOperandIndex(GetRegIdx, MRI, SkipSrc, AllowSameVGPR,
939 VOPD3)
940 .has_value();
941 }
942
943 // Check VOPD operands constraints.
944 // Return the index of an invalid component operand, if any.
945 // If \p SkipSrc is set to true then constraints for source operands are not
946 // checked except for being from the same halves of VGPR file on gfx1250.
947 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
948 // even though it violates requirement to be from different banks.
949 // If \p VOPD3 is set to true both dst registers allowed to be either odd
950 // or even and instruction may have real src2 as opposed to tied accumulator.
951 std::optional<unsigned> getInvalidCompOperandIndex(
952 std::function<unsigned(unsigned, unsigned)> GetRegIdx,
953 const MCRegisterInfo &MRI, bool SkipSrc = false,
954 bool AllowSameVGPR = false, bool VOPD3 = false) const;
955
956private:
958 getRegIndices(unsigned ComponentIdx,
959 std::function<unsigned(unsigned, unsigned)> GetRegIdx,
960 bool VOPD3) const;
961};
962
963} // namespace VOPD
964
966std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
967
969// Get properties of 2 single VOP1/VOP2 instructions
970// used as components to create a VOPD instruction.
971VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
972
974// Get properties of VOPD X and Y components.
975VOPD::InstInfo getVOPDInstInfo(unsigned VOPDOpcode,
976 const MCInstrInfo *InstrInfo);
977
979bool isAsyncStore(unsigned Opc);
981bool isTensorStore(unsigned Opc);
983unsigned getTemporalHintType(const MCInstrDesc TID);
984
986bool isTrue16Inst(unsigned Opc);
987
989FPType getFPDstSelType(unsigned Opc);
990
993
996
998
1000unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
1001
1003unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
1004
1006 const MCSubtargetInfo *STI);
1007
1008bool isGroupSegment(const GlobalValue *GV);
1009bool isGlobalSegment(const GlobalValue *GV);
1010bool isReadOnlySegment(const GlobalValue *GV);
1011
1012/// \returns True if constants should be emitted to .text section for given
1013/// target triple \p TT, false otherwise.
1015
1016/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1017/// register name. Followed by the start register number, and the register
1018/// width. Does not validate the number of registers exists in the class. Unlike
1019/// parseAsmConstraintPhysReg, this does not expect the name to be wrapped in
1020/// "{}".
1021std::tuple<char, unsigned, unsigned> parseAsmPhysRegName(StringRef TupleString);
1022
1023/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1024/// register constraint. Followed by the start register number, and the register
1025/// width. Does not validate the number of registers exists in the class.
1026std::tuple<char, unsigned, unsigned>
1028
1029/// \returns Integer value requested using \p F's \p Name attribute.
1030///
1031/// \returns \p Default if attribute is not present.
1032///
1033/// \returns \p Default and emits error if requested value cannot be converted
1034/// to integer.
1036
1037/// \returns A pair of integer values requested using \p F's \p Name attribute
1038/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1039/// is false).
1040///
1041/// \returns \p Default if attribute is not present.
1042///
1043/// \returns \p Default and emits error if one of the requested values cannot be
1044/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
1045/// not present.
1046std::pair<unsigned, unsigned>
1048 std::pair<unsigned, unsigned> Default,
1049 bool OnlyFirstRequired = false);
1050
1051/// \returns A pair of integer values requested using \p F's \p Name attribute
1052/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1053/// is false).
1054///
1055/// \returns \p std::nullopt if attribute is not present.
1056///
1057/// \returns \p std::nullopt and emits error if one of the requested values
1058/// cannot be converted to integer, or \p OnlyFirstRequired is false and
1059/// "second" value is not present.
1060std::optional<std::pair<unsigned, std::optional<unsigned>>>
1062 bool OnlyFirstRequired = false);
1063
1064/// \returns Generate a vector of integer values requested using \p F's \p Name
1065/// attribute.
1066/// \returns A vector of size \p Size, with all elements set to \p DefaultVal,
1067/// if any error occurs. The corresponding error will also be emitted.
1069 unsigned Size,
1070 unsigned DefaultVal);
1071/// Similar to the function above, but returns std::nullopt if any error occurs.
1072std::optional<SmallVector<unsigned>>
1073getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size);
1074
1075/// Checks if \p Val is inside \p MD, a !range-like metadata.
1076bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val);
1077
1078/// Represents the counter values to wait for in an s_waitcnt instruction.
1079///
1080/// Large values (including the maximum possible integer) can be used to
1081/// represent "don't care" waits.
1082struct Waitcnt {
1083 unsigned LoadCnt = ~0u; // Corresponds to Vmcnt prior to gfx12.
1084 unsigned ExpCnt = ~0u;
1085 unsigned DsCnt = ~0u; // Corresponds to LGKMcnt prior to gfx12.
1086 unsigned StoreCnt = ~0u; // Corresponds to VScnt on gfx10/gfx11.
1087 unsigned SampleCnt = ~0u; // gfx12+ only.
1088 unsigned BvhCnt = ~0u; // gfx12+ only.
1089 unsigned KmCnt = ~0u; // gfx12+ only.
1090 unsigned XCnt = ~0u; // gfx1250.
1091
1092 Waitcnt() = default;
1093 // Pre-gfx12 constructor.
1094 Waitcnt(unsigned VmCnt, unsigned ExpCnt, unsigned LgkmCnt, unsigned VsCnt)
1095 : LoadCnt(VmCnt), ExpCnt(ExpCnt), DsCnt(LgkmCnt), StoreCnt(VsCnt) {}
1096
1097 // gfx12+ constructor.
1098 Waitcnt(unsigned LoadCnt, unsigned ExpCnt, unsigned DsCnt, unsigned StoreCnt,
1099 unsigned SampleCnt, unsigned BvhCnt, unsigned KmCnt, unsigned XCnt)
1102
1103 bool hasWait() const { return StoreCnt != ~0u || hasWaitExceptStoreCnt(); }
1104
1106 return LoadCnt != ~0u || ExpCnt != ~0u || DsCnt != ~0u ||
1107 SampleCnt != ~0u || BvhCnt != ~0u || KmCnt != ~0u || XCnt != ~0u;
1108 }
1109
1110 bool hasWaitStoreCnt() const { return StoreCnt != ~0u; }
1111
1113 // Does the right thing provided self and Other are either both pre-gfx12
1114 // or both gfx12+.
1115 return Waitcnt(
1116 std::min(LoadCnt, Other.LoadCnt), std::min(ExpCnt, Other.ExpCnt),
1117 std::min(DsCnt, Other.DsCnt), std::min(StoreCnt, Other.StoreCnt),
1118 std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
1119 std::min(KmCnt, Other.KmCnt), std::min(XCnt, Other.XCnt));
1120 }
1121};
1122
1123// The following methods are only meaningful on targets that support
1124// S_WAITCNT.
1125
1126/// \returns Vmcnt bit mask for given isa \p Version.
1127unsigned getVmcntBitMask(const IsaVersion &Version);
1128
1129/// \returns Expcnt bit mask for given isa \p Version.
1130unsigned getExpcntBitMask(const IsaVersion &Version);
1131
1132/// \returns Lgkmcnt bit mask for given isa \p Version.
1133unsigned getLgkmcntBitMask(const IsaVersion &Version);
1134
1135/// \returns Waitcnt bit mask for given isa \p Version.
1136unsigned getWaitcntBitMask(const IsaVersion &Version);
1137
1138/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1139unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1140
1141/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1142unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1143
1144/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1145unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1146
1147/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1148/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1149/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1150/// which needs it is deprecated
1151///
1152/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1153/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1154/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1155/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1156/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1157/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1158/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1159/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1160/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1161///
1162void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt,
1163 unsigned &Expcnt, unsigned &Lgkmcnt);
1164
1165Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded);
1166
1167/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1168unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1169 unsigned Vmcnt);
1170
1171/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1172unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1173 unsigned Expcnt);
1174
1175/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1176unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1177 unsigned Lgkmcnt);
1178
1179/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1180/// \p Version. Should not be used on gfx12+, the instruction which needs
1181/// it is deprecated
1182///
1183/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1184/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1185/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1186/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1187/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1188/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1189/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1190/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1191/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1192/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1193///
1194/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1195/// isa \p Version.
1196///
1197unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt,
1198 unsigned Expcnt, unsigned Lgkmcnt);
1199
1200unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded);
1201
1202// The following methods are only meaningful on targets that support
1203// S_WAIT_*CNT, introduced with gfx12.
1204
1205/// \returns Loadcnt bit mask for given isa \p Version.
1206/// Returns 0 for versions that do not support LOADcnt
1207unsigned getLoadcntBitMask(const IsaVersion &Version);
1208
1209/// \returns Samplecnt bit mask for given isa \p Version.
1210/// Returns 0 for versions that do not support SAMPLEcnt
1211unsigned getSamplecntBitMask(const IsaVersion &Version);
1212
1213/// \returns Bvhcnt bit mask for given isa \p Version.
1214/// Returns 0 for versions that do not support BVHcnt
1215unsigned getBvhcntBitMask(const IsaVersion &Version);
1216
1217/// \returns Dscnt bit mask for given isa \p Version.
1218/// Returns 0 for versions that do not support DScnt
1219unsigned getDscntBitMask(const IsaVersion &Version);
1220
1221/// \returns Dscnt bit mask for given isa \p Version.
1222/// Returns 0 for versions that do not support KMcnt
1223unsigned getKmcntBitMask(const IsaVersion &Version);
1224
1225/// \returns Xcnt bit mask for given isa \p Version.
1226/// Returns 0 for versions that do not support Xcnt.
1227unsigned getXcntBitMask(const IsaVersion &Version);
1228
1229/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1230/// returns 0 for versions that do not support STOREcnt or VScnt.
1231/// STOREcnt and VScnt are the same counter, the name used
1232/// depends on the ISA version.
1233unsigned getStorecntBitMask(const IsaVersion &Version);
1234
1235// The following are only meaningful on targets that support
1236// S_WAIT_LOADCNT_DSCNT and S_WAIT_STORECNT_DSCNT.
1237
1238/// \returns Decoded Waitcnt structure from given \p LoadcntDscnt for given
1239/// isa \p Version.
1240Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt);
1241
1242/// \returns Decoded Waitcnt structure from given \p StorecntDscnt for given
1243/// isa \p Version.
1244Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt);
1245
1246/// \returns \p Loadcnt and \p Dscnt components of \p Decoded encoded as an
1247/// immediate that can be used with S_WAIT_LOADCNT_DSCNT for given isa
1248/// \p Version.
1249unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded);
1250
1251/// \returns \p Storecnt and \p Dscnt components of \p Decoded encoded as an
1252/// immediate that can be used with S_WAIT_STORECNT_DSCNT for given isa
1253/// \p Version.
1254unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded);
1255
1256namespace Hwreg {
1257
1260
1261struct HwregSize : EncodingField<15, 11, 32> {
1263 constexpr uint64_t encode() const { return Value - 1; }
1264 static ValueType decode(uint64_t Encoded) { return Encoded + 1; }
1265};
1266
1268
1269} // namespace Hwreg
1270
1271namespace DepCtr {
1272
1274int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1275 const MCSubtargetInfo &STI);
1276bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1277 const MCSubtargetInfo &STI);
1278bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1279 bool &IsDefault, const MCSubtargetInfo &STI);
1280
1281/// \returns Decoded VaVdst from given immediate \p Encoded.
1282unsigned decodeFieldVaVdst(unsigned Encoded);
1283
1284/// \returns Decoded VmVsrc from given immediate \p Encoded.
1285unsigned decodeFieldVmVsrc(unsigned Encoded);
1286
1287/// \returns Decoded SaSdst from given immediate \p Encoded.
1288unsigned decodeFieldSaSdst(unsigned Encoded);
1289
1290/// \returns Decoded VaSdst from given immediate \p Encoded.
1291unsigned decodeFieldVaSdst(unsigned Encoded);
1292
1293/// \returns Decoded VaVcc from given immediate \p Encoded.
1294unsigned decodeFieldVaVcc(unsigned Encoded);
1295
1296/// \returns Decoded SaSrc from given immediate \p Encoded.
1297unsigned decodeFieldVaSsrc(unsigned Encoded);
1298
1299/// \returns Decoded HoldCnt from given immediate \p Encoded.
1300unsigned decodeFieldHoldCnt(unsigned Encoded);
1301
1302/// \returns \p VmVsrc as an encoded Depctr immediate.
1303unsigned encodeFieldVmVsrc(unsigned VmVsrc);
1304
1305/// \returns \p Encoded combined with encoded \p VmVsrc.
1306unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1307
1308/// \returns \p VaVdst as an encoded Depctr immediate.
1309unsigned encodeFieldVaVdst(unsigned VaVdst);
1310
1311/// \returns \p Encoded combined with encoded \p VaVdst.
1312unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1313
1314/// \returns \p SaSdst as an encoded Depctr immediate.
1315unsigned encodeFieldSaSdst(unsigned SaSdst);
1316
1317/// \returns \p Encoded combined with encoded \p SaSdst.
1318unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1319
1320/// \returns \p VaSdst as an encoded Depctr immediate.
1321unsigned encodeFieldVaSdst(unsigned VaSdst);
1322
1323/// \returns \p Encoded combined with encoded \p VaSdst.
1324unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1325
1326/// \returns \p VaVcc as an encoded Depctr immediate.
1327unsigned encodeFieldVaVcc(unsigned VaVcc);
1328
1329/// \returns \p Encoded combined with encoded \p VaVcc.
1330unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1331
1332/// \returns \p HoldCnt as an encoded Depctr immediate.
1333unsigned encodeFieldHoldCnt(unsigned HoldCnt);
1334
1335/// \returns \p Encoded combined with encoded \p HoldCnt.
1336unsigned encodeFieldHoldCnt(unsigned HoldCnt, unsigned Encoded);
1337
1338/// \returns \p VaSsrc as an encoded Depctr immediate.
1339unsigned encodeFieldVaSsrc(unsigned VaSsrc);
1340
1341/// \returns \p Encoded combined with encoded \p VaSsrc.
1342unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc);
1343
1344} // namespace DepCtr
1345
1346namespace Exp {
1347
1348bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1349
1351unsigned getTgtId(const StringRef Name);
1352
1354bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1355
1356} // namespace Exp
1357
1358namespace MTBUFFormat {
1359
1361int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1362
1363void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1364
1365int64_t getDfmt(const StringRef Name);
1366
1367StringRef getDfmtName(unsigned Id);
1368
1369int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1370
1371StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1372
1373bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1374
1375bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1376
1377int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1378
1379StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1380
1381bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1382
1383int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1384 const MCSubtargetInfo &STI);
1385
1386bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1387
1388unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1389
1390} // namespace MTBUFFormat
1391
1392namespace SendMsg {
1393
1395bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1396
1398bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1399 bool Strict = true);
1400
1402bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1403 const MCSubtargetInfo &STI, bool Strict = true);
1404
1406bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1407
1409bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1410
1411void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1412 uint16_t &StreamId, const MCSubtargetInfo &STI);
1413
1415uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId);
1416
1417} // namespace SendMsg
1418
1419unsigned getInitialPSInputAddr(const Function &F);
1420
1421bool getHasColorExport(const Function &F);
1422
1423bool getHasDepthExport(const Function &F);
1424
1426
1427// Returns the value of the "amdgpu-dynamic-vgpr-block-size" attribute, or 0 if
1428// the attribute is missing or its value is invalid.
1429unsigned getDynamicVGPRBlockSize(const Function &F);
1430
1432constexpr bool isShader(CallingConv::ID CC) {
1433 switch (CC) {
1443 return true;
1444 default:
1445 return false;
1446 }
1447}
1448
1450constexpr bool isGraphics(CallingConv::ID CC) {
1451 return isShader(CC) || CC == CallingConv::AMDGPU_Gfx ||
1453}
1454
1456constexpr bool isCompute(CallingConv::ID CC) {
1457 return !isGraphics(CC) || CC == CallingConv::AMDGPU_CS;
1458}
1459
1462 switch (CC) {
1472 return true;
1473 default:
1474 return false;
1475 }
1476}
1477
1479constexpr bool isChainCC(CallingConv::ID CC) {
1480 switch (CC) {
1483 return true;
1484 default:
1485 return false;
1486 }
1487}
1488
1489// These functions are considered entrypoints into the current module, i.e. they
1490// are allowed to be called from outside the current module. This is different
1491// from isEntryFunctionCC, which is only true for functions that are entered by
1492// the hardware. Module entry points include all entry functions but also
1493// include functions that can be called from other functions inside or outside
1494// the current module. Module entry functions are allowed to allocate LDS.
1497 switch (CC) {
1499 return true;
1500 default:
1501 return isEntryFunctionCC(CC) || isChainCC(CC);
1502 }
1503}
1504
1506constexpr inline bool isKernel(CallingConv::ID CC) {
1507 switch (CC) {
1510 return true;
1511 default:
1512 return false;
1513 }
1514}
1515
1518 return CC == CallingConv::Fast;
1519}
1520
1521/// Return true if we might ever do TCO for calls with this calling convention.
1524 switch (CC) {
1525 case CallingConv::C:
1528 return true;
1529 default:
1530 return canGuaranteeTCO(CC);
1531 }
1532}
1533
1534bool hasXNACK(const MCSubtargetInfo &STI);
1535bool hasSRAMECC(const MCSubtargetInfo &STI);
1536bool hasMIMG_R128(const MCSubtargetInfo &STI);
1537bool hasA16(const MCSubtargetInfo &STI);
1538bool hasG16(const MCSubtargetInfo &STI);
1539bool hasPackedD16(const MCSubtargetInfo &STI);
1540bool hasGDS(const MCSubtargetInfo &STI);
1541unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1542unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1543
1544bool isSI(const MCSubtargetInfo &STI);
1545bool isCI(const MCSubtargetInfo &STI);
1546bool isVI(const MCSubtargetInfo &STI);
1547bool isGFX9(const MCSubtargetInfo &STI);
1548bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1549bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1550bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1551bool isGFX8Plus(const MCSubtargetInfo &STI);
1552bool isGFX9Plus(const MCSubtargetInfo &STI);
1553bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1554bool isGFX10(const MCSubtargetInfo &STI);
1555bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1556bool isGFX10Plus(const MCSubtargetInfo &STI);
1557bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1558bool isGFX10Before1030(const MCSubtargetInfo &STI);
1559bool isGFX11(const MCSubtargetInfo &STI);
1560bool isGFX11Plus(const MCSubtargetInfo &STI);
1561bool isGFX12(const MCSubtargetInfo &STI);
1562bool isGFX12Plus(const MCSubtargetInfo &STI);
1563bool isGFX1250(const MCSubtargetInfo &STI);
1564bool supportsWGP(const MCSubtargetInfo &STI);
1565bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1566bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1567bool isGCN3Encoding(const MCSubtargetInfo &STI);
1568bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
1569bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1570bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1571bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1572bool isGFX90A(const MCSubtargetInfo &STI);
1573bool isGFX940(const MCSubtargetInfo &STI);
1575bool hasMAIInsts(const MCSubtargetInfo &STI);
1576bool hasVOPD(const MCSubtargetInfo &STI);
1577bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1578
1579inline bool supportsWave32(const MCSubtargetInfo &STI) {
1580 return AMDGPU::isGFX10Plus(STI) && !AMDGPU::isGFX1250(STI);
1581}
1582
1583int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
1584unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1586
1587/// Is Reg - scalar register
1588bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1589
1590/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1592
1593/// If \p Reg is a pseudo reg, return the correct hardware register given
1594/// \p STI otherwise return \p Reg.
1596
1597/// Convert hardware register \p Reg to a pseudo register
1600
1602bool isInlineValue(unsigned Reg);
1603
1604/// Is this an AMDGPU specific source operand? These include registers,
1605/// inline constants, literals and mandatory literals (KImm).
1606constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo) {
1607 return OpInfo.OperandType >= AMDGPU::OPERAND_SRC_FIRST &&
1608 OpInfo.OperandType <= AMDGPU::OPERAND_SRC_LAST;
1609}
1610
1611inline bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo) {
1612 return isSISrcOperand(Desc.operands()[OpNo]);
1613}
1614
1615/// Is this a KImm operand?
1616bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1617
1618/// Is this floating-point operand?
1619bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1620
1621/// Does this operand support only inlinable literals?
1622bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
1623
1624/// Get the size in bits of a register from the register class \p RC.
1625unsigned getRegBitWidth(unsigned RCID);
1626
1627/// Get the size in bits of a register from the register class \p RC.
1628unsigned getRegBitWidth(const MCRegisterClass &RC);
1629
1631inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1632 switch (OpInfo.OperandType) {
1642 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1644 return 4;
1645
1652 return 8;
1653
1667 return 2;
1668
1669 default:
1670 llvm_unreachable("unhandled operand type");
1671 }
1672}
1673
1675inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
1676 return getOperandSize(Desc.operands()[OpNo]);
1677}
1678
1679/// Is this literal inlinable, and not one of the values intended for floating
1680/// point values.
1682inline bool isInlinableIntLiteral(int64_t Literal) {
1683 return Literal >= -16 && Literal <= 64;
1684}
1685
1686/// Is this literal inlinable
1688bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
1689
1691bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
1692
1694bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1695
1697bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi);
1698
1700bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1701
1703bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi);
1704
1706std::optional<unsigned> getInlineEncodingV2I16(uint32_t Literal);
1707
1709std::optional<unsigned> getInlineEncodingV2BF16(uint32_t Literal);
1710
1712std::optional<unsigned> getInlineEncodingV2F16(uint32_t Literal);
1713
1716
1719
1722
1725
1727bool isValid32BitLiteral(uint64_t Val, bool IsFP64);
1728
1730int64_t encode32BitLiteral(int64_t Imm, OperandType Type);
1731
1732bool isArgPassedInSGPR(const Argument *Arg);
1733
1734bool isArgPassedInSGPR(const CallBase *CB, unsigned ArgNo);
1735
1736LLVM_READONLY bool isPackedFP32Inst(unsigned Opc);
1737
1740 int64_t EncodedOffset);
1741
1744 int64_t EncodedOffset, bool IsBuffer);
1745
1746/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1747/// offsets.
1749
1750/// \returns The encoding that will be used for \p ByteOffset in the
1751/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1752/// S_LOAD instructions have a signed offset, on other subtargets it is
1753/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1754std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1755 int64_t ByteOffset, bool IsBuffer,
1756 bool HasSOffset = false);
1757
1758/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1759/// instruction. This is only useful on CI.s
1760std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1761 int64_t ByteOffset);
1762
1763/// For pre-GFX12 FLAT instructions the offset must be positive;
1764/// MSB is ignored and forced to zero.
1765///
1766/// \return The number of bits available for the signed offset field in flat
1767/// instructions. Note that some forms of the instruction disallow negative
1768/// offsets.
1769unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1770
1771/// \returns true if this offset is small enough to fit in the SMRD
1772/// offset field. \p ByteOffset should be the offset in bytes and
1773/// not the encoded offset.
1774bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
1775
1777inline bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC) {
1778 if (isGFX12(ST))
1779 return DC >= DPP::ROW_SHARE_FIRST && DC <= DPP::ROW_SHARE_LAST;
1780 if (isGFX90A(ST))
1781 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1782 return false;
1783}
1784
1785/// \returns true if an instruction may have a 64-bit VGPR operand.
1787 const MCSubtargetInfo &ST);
1788
1789/// \returns true if an instruction is a DP ALU DPP without any 64-bit operands.
1790bool isDPALU_DPP32BitOpc(unsigned Opc);
1791
1792/// \returns true if an instruction is a DP ALU DPP.
1793bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII,
1794 const MCSubtargetInfo &ST);
1795
1796/// \returns true if the intrinsic is divergent
1797bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1798
1799/// \returns true if the intrinsic is uniform
1800bool isIntrinsicAlwaysUniform(unsigned IntrID);
1801
1802/// \returns a register class for the physical register \p Reg if it is a VGPR
1803/// or nullptr otherwise.
1805 const MCRegisterInfo &MRI);
1806
1807/// \returns the MODE bits which have to be set by the S_SET_VGPR_MSB for the
1808/// physical register \p Reg.
1810
1811/// If \p Reg is a low VGPR return a corresponding high VGPR with \p MSBs set.
1812MCPhysReg getVGPRWithMSBs(MCPhysReg Reg, unsigned MSBs,
1813 const MCRegisterInfo &MRI);
1814
1815// Returns a table for the opcode with a given \p Desc to map the VGPR MSB
1816// set by the S_SET_VGPR_MSB to one of 4 sources. In case of VOPD returns 2
1817// maps, one for X and one for Y component.
1818std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
1820
1821/// \returns true if a memory instruction supports scale_offset modifier.
1822bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode);
1823
1824/// \returns lds block size in terms of dwords. \p
1825/// This is used to calculate the lds size encoded for PAL metadata 3.0+ which
1826/// must be defined in terms of bytes.
1827unsigned getLdsDwGranularity(const MCSubtargetInfo &ST);
1828
1830public:
1832
1833 ClusterDimsAttr() = default;
1834
1835 Kind getKind() const { return AttrKind; }
1836
1837 bool isUnknown() const { return getKind() == Kind::Unknown; }
1838
1839 bool isNoCluster() const { return getKind() == Kind::NoCluster; }
1840
1841 bool isFixedDims() const { return getKind() == Kind::FixedDims; }
1842
1843 bool isVariableDims() const { return getKind() == Kind::VariableDims; }
1844
1846
1848
1850
1851 /// \returns the dims stored. Note that this function can only be called if
1852 /// the kind is \p Fixed.
1853 const std::array<unsigned, 3> &getDims() const;
1854
1855 bool operator==(const ClusterDimsAttr &RHS) const {
1856 return AttrKind == RHS.AttrKind && Dims == RHS.Dims;
1857 }
1858
1859 std::string to_string() const;
1860
1861 static ClusterDimsAttr get(const Function &F);
1862
1863private:
1864 enum Encoding { EncoNoCluster = 0, EncoVariableDims = 1024 };
1865
1866 ClusterDimsAttr(Kind AttrKind) : AttrKind(AttrKind) {}
1867
1868 std::array<unsigned, 3> Dims = {0, 0, 0};
1869
1870 Kind AttrKind = Kind::Unknown;
1871};
1872
1873} // end namespace AMDGPU
1874
1877
1878} // end namespace llvm
1879
1880#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Base class for AMDGPU specific classes of TargetSubtarget.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_READNONE
Definition Compiler.h:315
#define LLVM_READONLY
Definition Compiler.h:322
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:55
#define G(x, y, z)
Definition MD5.cpp:56
Register Reg
Register const TargetRegisterInfo * TRI
unsigned unsigned DefaultVal
Value * RHS
static ClusterDimsAttr get(const Function &F)
bool operator==(const ClusterDimsAttr &RHS) const
const std::array< unsigned, 3 > & getDims() const
void setXnackSetting(TargetIDSetting NewXnackSetting)
Sets xnack setting to NewXnackSetting.
TargetIDSetting getXnackSetting() const
AMDGPUTargetID(const MCSubtargetInfo &STI)
void setTargetIDFromTargetIDStream(StringRef TargetID)
void setSramEccSetting(TargetIDSetting NewSramEccSetting)
Sets sramecc setting to NewSramEccSetting.
TargetIDSetting getSramEccSetting() const
unsigned getIndexInParsedOperands(unsigned CompOprIdx) const
ComponentInfo(const MCInstrDesc &OpDesc, ComponentKind Kind=ComponentKind::SINGLE, bool VOP3Layout=false)
ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps, bool VOP3Layout=false)
unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const
ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum, int BitOp3Idx)
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
bool hasRegSrcOperand(unsigned CompSrcIdx) const
unsigned getMandatoryLiteralCompOperandIndex() const
InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
std::optional< unsigned > getInvalidCompOperandIndex(std::function< unsigned(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false) const
const ComponentInfo & operator[](size_t ComponentIdx) const
InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
std::array< unsigned, Component::MAX_OPR_NUM > RegIndices
bool hasInvalidOperand(std::function< unsigned(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false) const
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:87
MCRegisterClass - Base class of TargetRegisterClass.
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.
Definition MCRegister.h:33
Generic base class for all target subtargets.
Metadata node.
Definition Metadata.h:1078
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned decodeFieldVaVcc(unsigned Encoded)
unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc)
unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt)
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc)
unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst)
unsigned decodeFieldSaSdst(unsigned Encoded)
unsigned decodeFieldVaSdst(unsigned Encoded)
unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc)
unsigned decodeFieldVaSsrc(unsigned Encoded)
int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask, const MCSubtargetInfo &STI)
unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst)
bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
unsigned decodeFieldVaVdst(unsigned Encoded)
unsigned decodeFieldHoldCnt(unsigned Encoded)
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI)
unsigned decodeFieldVmVsrc(unsigned Encoded)
unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst)
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI)
bool getTgtName(unsigned Id, StringRef &Name, int &Index)
unsigned getTgtId(const StringRef Name)
Generic target versions emitted by this version of LLVM.
static constexpr unsigned GFX9_4
static constexpr unsigned GFX10_1
static constexpr unsigned GFX10_3
static constexpr unsigned GFX11
static constexpr unsigned GFX9
static constexpr unsigned GFX12
EncodingField< 10, 6 > HwregOffset
EncodingField< 5, 0 > HwregId
EncodingFields< HwregId, HwregOffset, HwregSize > HwregEncoding
unsigned getVGPREncodingGranule(const MCSubtargetInfo *STI, std::optional< bool > EnableWavefrontSize32)
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI)
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getWavefrontSize(const MCSubtargetInfo *STI)
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo *STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize)
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 getEUsPerCU(const MCSubtargetInfo *STI)
unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI)
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI)
unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, bool Addressable)
unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs)
unsigned getMinWavesPerEU(const MCSubtargetInfo *STI)
unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getEncodedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, AMDGPUSubtarget::Generation Gen)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo *STI)
unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize)
bool isValidUnifiedFormat(unsigned Id, const MCSubtargetInfo &STI)
unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI)
StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI)
bool isValidNfmt(unsigned Id, const MCSubtargetInfo &STI)
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)
int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI)
int64_t getDfmt(const StringRef Name)
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)
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 COMPONENTS[]
bool isPackedFP32Inst(unsigned Opc)
bool isGCN3Encoding(const MCSubtargetInfo &STI)
bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi)
bool isGFX10_BEncoding(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGG16MappingInfo * getMIMGG16MappingInfo(unsigned G)
bool isGFX10_GFX11(const MCSubtargetInfo &STI)
bool isInlinableLiteralV216(uint32_t Literal, uint8_t OpType)
EncodingField< Bit, Bit, D > EncodingBit
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
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.
MCRegister getMCReg(MCRegister Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg.
LLVM_READONLY const MIMGOffsetMappingInfo * getMIMGOffsetMappingInfo(unsigned Offset)
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)
bool getWMMAIsXDL(unsigned Opc)
uint8_t wmmaScaleF8F6F4FormatToNumRegs(unsigned Fmt)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isShader(CallingConv::ID CC)
bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo)
Does this operand support only inlinable literals?
unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc)
bool shouldEmitConstantsToTextSection(const Triple &TT)
bool isInlinableLiteralV2I16(uint32_t Literal)
bool isDPMACCInstruction(unsigned Opc)
int getMTBUFElements(unsigned Opc)
bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI)
unsigned getTemporalHintType(const MCInstrDesc TID)
int32_t getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR)
bool isGFX10(const MCSubtargetInfo &STI)
const MCRegisterClass * getVGPRPhysRegClass(MCPhysReg Reg, const MCRegisterInfo &MRI)
bool isInlinableLiteralV2BF16(uint32_t Literal)
unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI)
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)
LLVM_READNONE constexpr bool isModuleEntryFunctionCC(CallingConv::ID CC)
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
bool hasPackedD16(const MCSubtargetInfo &STI)
unsigned getStorecntBitMask(const IsaVersion &Version)
unsigned getLdsDwGranularity(const MCSubtargetInfo &ST)
bool isGFX940(const MCSubtargetInfo &STI)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
unsigned getVGPREncodingMSBs(MCPhysReg Reg, const MCRegisterInfo &MRI)
bool getSMEMIsBuffer(unsigned Opc)
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val)
Checks if Val is inside MD, a !range-like metadata.
LLVM_READONLY bool isInvalidSingleUseProducerInst(unsigned Opc)
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
LLVM_READONLY bool isInvalidSingleUseConsumerInst(unsigned Opc)
unsigned getVOPDOpcode(unsigned Opc, bool VOPD3)
bool isGroupSegment(const GlobalValue *GV)
LLVM_READONLY const MIMGMIPMappingInfo * getMIMGMIPMappingInfo(unsigned MIP)
bool getMTBUFHasSoffset(unsigned Opc)
bool hasXNACK(const MCSubtargetInfo &STI)
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3)
unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt)
Encodes Vmcnt, Expcnt and Lgkmcnt into Waitcnt for given isa Version.
LLVM_READNONE bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC)
bool isVOPC64DPP(unsigned Opc)
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool getMAIIsGFX940XDL(unsigned Opc)
bool isSI(const MCSubtargetInfo &STI)
unsigned getDefaultAMDHSACodeObjectVersion()
bool isReadOnlySegment(const GlobalValue *GV)
bool isArgPassedInSGPR(const Argument *A)
LLVM_READNONE constexpr bool mayTailCallThisCC(CallingConv::ID CC)
Return true if we might ever do TCO for calls with this calling convention.
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)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx)
bool getVOP3IsSingle(unsigned Opc)
bool isGFX9(const MCSubtargetInfo &STI)
bool isDPALU_DPP32BitOpc(unsigned Opc)
bool getVOP1IsSingle(unsigned Opc)
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 isGFX90A(const MCSubtargetInfo &STI)
unsigned getSamplecntBitMask(const IsaVersion &Version)
unsigned getDefaultQueueImplicitArgPosition(unsigned CodeObjectVersion)
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 hasSRAMECC(const MCSubtargetInfo &STI)
bool getHasDepthExport(const Function &F)
bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isKernel(CallingConv::ID CC)
bool getMUBUFHasVAddr(unsigned Opc)
bool isTrue16Inst(unsigned Opc)
LLVM_READNONE constexpr bool isEntryFunctionCC(CallingConv::ID CC)
std::pair< unsigned, unsigned > getVOPDComponents(unsigned VOPDOpcode)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
LLVM_READNONE constexpr bool isCompute(CallingConv::ID CC)
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)
bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
unsigned getKmcntBitMask(const IsaVersion &Version)
unsigned getVmcntBitMask(const IsaVersion &Version)
bool isNotGFX10Plus(const MCSubtargetInfo &STI)
bool hasMAIInsts(const MCSubtargetInfo &STI)
unsigned getBitOp2(unsigned Opc)
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo)
Is this an AMDGPU specific source operand?
unsigned getXcntBitMask(const IsaVersion &Version)
bool isGenericAtomic(unsigned Opc)
const MFMA_F8F6F4_Info * getWMMA_F8F6F4_WithFormatArgs(unsigned FmtA, unsigned FmtB, unsigned F8F8Opcode)
Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt)
bool isGFX8Plus(const MCSubtargetInfo &STI)
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)
LLVM_READONLY const MIMGBiasMappingInfo * getMIMGBiasMappingInfo(unsigned Bias)
unsigned getBvhcntBitMask(const IsaVersion &Version)
bool hasSMRDSignedImmOffset(const MCSubtargetInfo &ST)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByAsmSuffix(StringRef AsmSuffix)
bool hasMIMG_R128(const MCSubtargetInfo &STI)
bool hasGFX10_3Insts(const MCSubtargetInfo &STI)
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)
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?
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)
bool isGFX10Plus(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.
Definition SIDefines.h:231
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:202
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:209
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:222
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:219
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:224
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:210
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:206
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:201
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:208
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:207
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:218
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:216
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:211
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:205
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:225
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:236
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:237
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:212
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:204
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:221
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:217
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:223
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:213
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:238
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:220
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:203
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:228
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo *STI)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
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)
MCPhysReg getVGPRWithMSBs(MCPhysReg Reg, unsigned MSBs, const MCRegisterInfo &MRI)
If Reg is a low VGPR return a corresponding high VGPR with MSBs set.
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)
bool isGFX1250(const MCSubtargetInfo &STI)
bool supportsWave32(const MCSubtargetInfo &STI)
int getMCOpcode(uint16_t Opcode, unsigned Gen)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
int64_t encode32BitLiteral(int64_t Imm, OperandType Type)
bool isTensorStore(unsigned Opc)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfo(unsigned DimEnum)
bool getMUBUFIsBufferInv(unsigned Opc)
bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode)
MCRegister mc2PseudoReg(MCRegister Reg)
Convert hardware register Reg to a pseudo register.
std::optional< unsigned > getInlineEncodingV2BF16(uint32_t Literal)
unsigned hasKernargPreload(const MCSubtargetInfo &STI)
bool supportsWGP(const MCSubtargetInfo &STI)
bool hasDynamicVGPR(const Function &F)
bool isMAC(unsigned Opc)
LLVM_READNONE unsigned getOperandSize(const MCOperandInfo &OpInfo)
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)
LLVM_READNONE constexpr bool isChainCC(CallingConv::ID CC)
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels)
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)
LLVM_READNONE constexpr bool canGuaranteeTCO(CallingConv::ID CC)
LLVM_READNONE constexpr bool isGraphics(CallingConv::ID CC)
int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily, bool VOPD3)
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)
unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc)
bool isPermlane16(unsigned Opc)
LLVM_READONLY int getSOPPWithRelaxation(uint16_t Opcode)
bool getMUBUFHasSrsrc(unsigned Opc)
unsigned getDscntBitMask(const IsaVersion &Version)
bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ 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.
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition CallingConv.h:41
@ 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.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Definition MathExtras.h:216
Op::Description Desc
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302
@ Other
Any other memory.
Definition ModRef.h:68
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition MCRegister.h:21
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
@ Default
The result values are uniform if and only if all operands are uniform.
Definition Uniformity.h:20
AMD Kernel Code Object (amd_kernel_code_t).
constexpr EncodingField(ValueType Value)
static ValueType decode(uint64_t Encoded)
constexpr uint64_t encode() const
static constexpr uint64_t encode(Fields... Values)
static std::tuple< typename Fields::ValueType... > decode(uint64_t Encoded)
constexpr EncodingField(ValueType Value)
constexpr uint64_t encode() const
static ValueType decode(uint64_t Encoded)
Waitcnt(unsigned LoadCnt, unsigned ExpCnt, unsigned DsCnt, unsigned StoreCnt, unsigned SampleCnt, unsigned BvhCnt, unsigned KmCnt, unsigned XCnt)
bool hasWaitExceptStoreCnt() const
Waitcnt(unsigned VmCnt, unsigned ExpCnt, unsigned LgkmCnt, unsigned VsCnt)
Waitcnt combined(const Waitcnt &Other) const