LLVM 21.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 StringRef;
39class Triple;
40class raw_ostream;
41
42namespace AMDGPU {
43
44struct AMDGPUMCKernelCodeT;
45struct IsaVersion;
46
47/// Generic target versions emitted by this version of LLVM.
48///
49/// These numbers are incremented every time a codegen breaking change occurs
50/// within a generic family.
51namespace GenericVersion {
52static constexpr unsigned GFX9 = 1;
53static constexpr unsigned GFX9_4 = 1;
54static constexpr unsigned GFX10_1 = 1;
55static constexpr unsigned GFX10_3 = 1;
56static constexpr unsigned GFX11 = 1;
57static constexpr unsigned GFX12 = 1;
58} // namespace GenericVersion
59
60enum { AMDHSA_COV4 = 4, AMDHSA_COV5 = 5, AMDHSA_COV6 = 6 };
61
62enum class FPType { None, FP4, FP8 };
63
64/// \returns True if \p STI is AMDHSA.
65bool isHsaAbi(const MCSubtargetInfo &STI);
66
67/// \returns Code object version from the IR module flag.
68unsigned getAMDHSACodeObjectVersion(const Module &M);
69
70/// \returns Code object version from ELF's e_ident[EI_ABIVERSION].
71unsigned getAMDHSACodeObjectVersion(unsigned ABIVersion);
72
73/// \returns The default HSA code object version. This should only be used when
74/// we lack a more accurate CodeObjectVersion value (e.g. from the IR module
75/// flag or a .amdhsa_code_object_version directive)
77
78/// \returns ABIVersion suitable for use in ELF's e_ident[EI_ABIVERSION]. \param
79/// CodeObjectVersion is a value returned by getAMDHSACodeObjectVersion().
80uint8_t getELFABIVersion(const Triple &OS, unsigned CodeObjectVersion);
81
82/// \returns The offset of the multigrid_sync_arg argument from implicitarg_ptr
83unsigned getMultigridSyncArgImplicitArgPosition(unsigned COV);
84
85/// \returns The offset of the hostcall pointer argument from implicitarg_ptr
86unsigned getHostcallImplicitArgPosition(unsigned COV);
87
88unsigned getDefaultQueueImplicitArgPosition(unsigned COV);
89unsigned getCompletionActionImplicitArgPosition(unsigned COV);
90
92 unsigned Format;
93 unsigned BitsPerComp;
94 unsigned NumComponents;
95 unsigned NumFormat;
96 unsigned DataFormat;
97};
98
103};
104
106 unsigned Opcode;
107 unsigned F8F8Opcode;
110};
111
113 unsigned Opcode;
114};
115
116#define GET_MIMGBaseOpcode_DECL
117#define GET_MIMGDim_DECL
118#define GET_MIMGEncoding_DECL
119#define GET_MIMGLZMapping_DECL
120#define GET_MIMGMIPMapping_DECL
121#define GET_MIMGBiASMapping_DECL
122#define GET_MAIInstInfoTable_DECL
123#define GET_MAIInstInfoTable_DECL
124#define GET_isMFMA_F8F6F4Table_DECL
125#define GET_isCvtScaleF32_F32F16ToF8F4Table_DECL
126#include "AMDGPUGenSearchableTables.inc"
127
128namespace IsaInfo {
129
130enum {
131 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
132 // doesn't spill SGPRs as much as when 80 is set.
134 TRAP_NUM_SGPRS = 16
136
137enum class TargetIDSetting {
139 Any,
140 Off,
141 On
142};
143
145private:
146 const MCSubtargetInfo &STI;
147 TargetIDSetting XnackSetting;
148 TargetIDSetting SramEccSetting;
149
150public:
151 explicit AMDGPUTargetID(const MCSubtargetInfo &STI);
152 ~AMDGPUTargetID() = default;
153
154 /// \return True if the current xnack setting is not "Unsupported".
155 bool isXnackSupported() const {
156 return XnackSetting != TargetIDSetting::Unsupported;
157 }
158
159 /// \returns True if the current xnack setting is "On" or "Any".
160 bool isXnackOnOrAny() const {
161 return XnackSetting == TargetIDSetting::On ||
162 XnackSetting == TargetIDSetting::Any;
163 }
164
165 /// \returns True if current xnack setting is "On" or "Off",
166 /// false otherwise.
167 bool isXnackOnOrOff() const {
170 }
171
172 /// \returns The current xnack TargetIDSetting, possible options are
173 /// "Unsupported", "Any", "Off", and "On".
175 return XnackSetting;
176 }
177
178 /// Sets xnack setting to \p NewXnackSetting.
179 void setXnackSetting(TargetIDSetting NewXnackSetting) {
180 XnackSetting = NewXnackSetting;
181 }
182
183 /// \return True if the current sramecc setting is not "Unsupported".
184 bool isSramEccSupported() const {
185 return SramEccSetting != TargetIDSetting::Unsupported;
186 }
187
188 /// \returns True if the current sramecc setting is "On" or "Any".
189 bool isSramEccOnOrAny() const {
190 return SramEccSetting == TargetIDSetting::On ||
191 SramEccSetting == TargetIDSetting::Any;
192 }
193
194 /// \returns True if current sramecc setting is "On" or "Off",
195 /// false otherwise.
196 bool isSramEccOnOrOff() const {
199 }
200
201 /// \returns The current sramecc TargetIDSetting, possible options are
202 /// "Unsupported", "Any", "Off", and "On".
204 return SramEccSetting;
205 }
206
207 /// Sets sramecc setting to \p NewSramEccSetting.
208 void setSramEccSetting(TargetIDSetting NewSramEccSetting) {
209 SramEccSetting = NewSramEccSetting;
210 }
211
214
215 /// \returns String representation of an object.
216 std::string toString() const;
217};
218
219/// \returns Wavefront size for given subtarget \p STI.
220unsigned getWavefrontSize(const MCSubtargetInfo *STI);
221
222/// \returns Local memory size in bytes for given subtarget \p STI.
223unsigned getLocalMemorySize(const MCSubtargetInfo *STI);
224
225/// \returns Maximum addressable local memory size in bytes for given subtarget
226/// \p STI.
228
229/// \returns Number of execution units per compute unit for given subtarget \p
230/// STI.
231unsigned getEUsPerCU(const MCSubtargetInfo *STI);
232
233/// \returns Maximum number of work groups per compute unit for given subtarget
234/// \p STI and limited by given \p FlatWorkGroupSize.
235unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI,
236 unsigned FlatWorkGroupSize);
237
238/// \returns Minimum number of waves per execution unit for given subtarget \p
239/// STI.
240unsigned getMinWavesPerEU(const MCSubtargetInfo *STI);
241
242/// \returns Maximum number of waves per execution unit for given subtarget \p
243/// STI without any kind of limitation.
244unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI);
245
246/// \returns Number of waves per execution unit required to support the given \p
247/// FlatWorkGroupSize.
249 unsigned FlatWorkGroupSize);
250
251/// \returns Minimum flat work group size for given subtarget \p STI.
252unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI);
253
254/// \returns Maximum flat work group size for given subtarget \p STI.
255unsigned getMaxFlatWorkGroupSize(const MCSubtargetInfo *STI);
256
257/// \returns Number of waves per work group for given subtarget \p STI and
258/// \p FlatWorkGroupSize.
259unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI,
260 unsigned FlatWorkGroupSize);
261
262/// \returns SGPR allocation granularity for given subtarget \p STI.
263unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI);
264
265/// \returns SGPR encoding granularity for given subtarget \p STI.
266unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI);
267
268/// \returns Total number of SGPRs for given subtarget \p STI.
269unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI);
270
271/// \returns Addressable number of SGPRs for given subtarget \p STI.
272unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI);
273
274/// \returns Minimum number of SGPRs that meets the given number of waves per
275/// execution unit requirement for given subtarget \p STI.
276unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
277
278/// \returns Maximum number of SGPRs that meets the given number of waves per
279/// execution unit requirement for given subtarget \p STI.
280unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
281 bool Addressable);
282
283/// \returns Number of extra SGPRs implicitly required by given subtarget \p
284/// STI when the given special registers are used.
285unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
286 bool FlatScrUsed, bool XNACKUsed);
287
288/// \returns Number of extra SGPRs implicitly required by given subtarget \p
289/// STI when the given special registers are used. XNACK is inferred from
290/// \p STI.
291unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
292 bool FlatScrUsed);
293
294/// \returns Number of SGPR blocks needed for given subtarget \p STI when
295/// \p NumSGPRs are used. \p NumSGPRs should already include any special
296/// register counts.
297unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs);
298
299/// \returns VGPR allocation granularity for given subtarget \p STI.
300///
301/// For subtargets which support it, \p EnableWavefrontSize32 should match
302/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
303unsigned
305 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
306
307/// \returns VGPR encoding granularity for given subtarget \p STI.
308///
309/// For subtargets which support it, \p EnableWavefrontSize32 should match
310/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
312 const MCSubtargetInfo *STI,
313 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
314
315/// \returns Total number of VGPRs for given subtarget \p STI.
316unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI);
317
318/// \returns Addressable number of architectural VGPRs for a given subtarget \p
319/// STI.
321
322/// \returns Addressable number of VGPRs for given subtarget \p STI.
323unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI);
324
325/// \returns Minimum number of VGPRs that meets given number of waves per
326/// execution unit requirement for given subtarget \p STI.
327unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
328
329/// \returns Maximum number of VGPRs that meets given number of waves per
330/// execution unit requirement for given subtarget \p STI.
331unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
332
333/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
334/// subtarget \p STI.
336 unsigned NumVGPRs);
337
338/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
339/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
340unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
341 unsigned MaxWaves,
342 unsigned TotalNumVGPRs);
343
344/// \returns Occupancy for a given \p SGPRs usage, \p MaxWaves possible, and \p
345/// Gen.
346unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
348
349/// \returns Number of VGPR blocks needed for given subtarget \p STI when
350/// \p NumVGPRs are used. We actually return the number of blocks -1, since
351/// that's what we encode.
352///
353/// For subtargets which support it, \p EnableWavefrontSize32 should match the
354/// ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
356 const MCSubtargetInfo *STI, unsigned NumVGPRs,
357 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
358
359/// \returns Number of VGPR blocks that need to be allocated for the given
360/// subtarget \p STI when \p NumVGPRs are used.
362 const MCSubtargetInfo *STI, unsigned NumVGPRs,
363 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
364
365} // end namespace IsaInfo
366
367// Represents a field in an encoded value.
368template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
370 static_assert(HighBit >= LowBit, "Invalid bit range!");
371 static constexpr unsigned Offset = LowBit;
372 static constexpr unsigned Width = HighBit - LowBit + 1;
373
375 static constexpr ValueType Default = D;
376
379
380 constexpr uint64_t encode() const { return Value; }
381 static ValueType decode(uint64_t Encoded) { return Encoded; }
382};
383
384// Represents a single bit in an encoded value.
385template <unsigned Bit, unsigned D = 0>
387
388// A helper for encoding and decoding multiple fields.
389template <typename... Fields> struct EncodingFields {
390 static constexpr uint64_t encode(Fields... Values) {
391 return ((Values.encode() << Values.Offset) | ...);
392 }
393
394 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
395 return {Fields::decode((Encoded >> Fields::Offset) &
396 maxUIntN(Fields::Width))...};
397 }
398};
399
401inline bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx) {
402 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
403}
404
407
409 MIMGBaseOpcode BaseOpcode;
410 bool Store;
411 bool Atomic;
415
418 bool G16;
421 bool HasD16;
422 bool MSAA;
423 bool BVH;
424 bool A16;
426};
427
429const MIMGBaseOpcodeInfo *getMIMGBaseOpcode(unsigned Opc);
430
432const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
433
435 MIMGDim Dim;
438 bool MSAA;
439 bool DA;
441 const char *AsmSuffix;
442};
443
445const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
446
449
452
454 MIMGBaseOpcode L;
455 MIMGBaseOpcode LZ;
456};
457
459 MIMGBaseOpcode MIP;
460 MIMGBaseOpcode NONMIP;
461};
462
464 MIMGBaseOpcode Bias;
465 MIMGBaseOpcode NoBias;
466};
467
469 MIMGBaseOpcode Offset;
470 MIMGBaseOpcode NoOffset;
471};
472
474 MIMGBaseOpcode G;
475 MIMGBaseOpcode G16;
476};
477
480
482 unsigned Opcode2Addr;
483 unsigned Opcode3Addr;
484};
485
488
491
494
497
499int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
500 unsigned VDataDwords, unsigned VAddrDwords);
501
503int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
504
506unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
507 const MIMGDimInfo *Dim, bool IsA16,
508 bool IsG16Supported);
509
510struct MIMGInfo {
517};
518
520const MIMGInfo *getMIMGInfo(unsigned Opc);
521
523int getMTBUFBaseOpcode(unsigned Opc);
524
526int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
527
529int getMTBUFElements(unsigned Opc);
530
532bool getMTBUFHasVAddr(unsigned Opc);
533
535bool getMTBUFHasSrsrc(unsigned Opc);
536
538bool getMTBUFHasSoffset(unsigned Opc);
539
541int getMUBUFBaseOpcode(unsigned Opc);
542
544int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
545
547int getMUBUFElements(unsigned Opc);
548
550bool getMUBUFHasVAddr(unsigned Opc);
551
553bool getMUBUFHasSrsrc(unsigned Opc);
554
556bool getMUBUFHasSoffset(unsigned Opc);
557
559bool getMUBUFIsBufferInv(unsigned Opc);
560
562bool getMUBUFTfe(unsigned Opc);
563
565bool getSMEMIsBuffer(unsigned Opc);
566
568bool getVOP1IsSingle(unsigned Opc);
569
571bool getVOP2IsSingle(unsigned Opc);
572
574bool getVOP3IsSingle(unsigned Opc);
575
577bool isVOPC64DPP(unsigned Opc);
578
580bool isVOPCAsmOnly(unsigned Opc);
581
582/// Returns true if MAI operation is a double precision GEMM.
584bool getMAIIsDGEMM(unsigned Opc);
585
587bool getMAIIsGFX940XDL(unsigned Opc);
588
589struct CanBeVOPD {
590 bool X;
591 bool Y;
592};
593
594/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
596unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
597
599CanBeVOPD getCanBeVOPD(unsigned Opc);
600
602uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
603
606 unsigned BLGP,
607 unsigned F8F8Opcode);
608
611 uint8_t NumComponents,
612 uint8_t NumFormat,
613 const MCSubtargetInfo &STI);
616 const MCSubtargetInfo &STI);
617
619int getMCOpcode(uint16_t Opcode, unsigned Gen);
620
622unsigned getVOPDOpcode(unsigned Opc);
623
625int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily);
626
628bool isVOPD(unsigned Opc);
629
631bool isMAC(unsigned Opc);
632
634bool isPermlane16(unsigned Opc);
635
637bool isGenericAtomic(unsigned Opc);
638
640bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
641
642namespace VOPD {
643
644enum Component : unsigned {
645 DST = 0,
649
654
655// LSB mask for VGPR banks per VOPD component operand.
656// 4 banks result in a mask 3, setting 2 lower bits.
657constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
658
659enum ComponentIndex : unsigned { X = 0, Y = 1 };
661constexpr unsigned COMPONENTS_NUM = 2;
662
663// Properties of VOPD components.
665private:
666 unsigned SrcOperandsNum = 0;
667 unsigned MandatoryLiteralIdx = ~0u;
668 bool HasSrc2Acc = false;
669
670public:
671 ComponentProps() = default;
672 ComponentProps(const MCInstrDesc &OpDesc);
673
674 // Return the total number of src operands this component has.
675 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
676
677 // Return the number of src operands of this component visible to the parser.
679 return SrcOperandsNum - HasSrc2Acc;
680 }
681
682 // Return true iif this component has a mandatory literal.
683 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
684
685 // If this component has a mandatory literal, return component operand
686 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
689 return MandatoryLiteralIdx;
690 }
691
692 // Return true iif this component has operand
693 // with component index CompSrcIdx and this operand may be a register.
694 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
695 assert(CompSrcIdx < Component::MAX_SRC_NUM);
696 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
697 }
698
699 // Return true iif this component has tied src2.
700 bool hasSrc2Acc() const { return HasSrc2Acc; }
701
702private:
703 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
704 assert(CompSrcIdx < Component::MAX_SRC_NUM);
705 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
706 }
707};
708
709enum ComponentKind : unsigned {
710 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
711 COMPONENT_X, // A VOPD instruction, X component.
712 COMPONENT_Y, // A VOPD instruction, Y component.
715
716// Interface functions of this class map VOPD component operand indices
717// to indices of operands in MachineInstr/MCInst or parsed operands array.
718//
719// Note that this class operates with 3 kinds of indices:
720// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
721// - MC operand indices (they refer operands in a MachineInstr/MCInst);
722// - parsed operand indices (they refer operands in parsed operands array).
723//
724// For SINGLE components mapping between these indices is trivial.
725// But things get more complicated for COMPONENT_X and
726// COMPONENT_Y because these components share the same
727// MachineInstr/MCInst and the same parsed operands array.
728// Below is an example of component operand to parsed operand
729// mapping for the following instruction:
730//
731// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
732//
733// PARSED COMPONENT PARSED
734// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
735// -------------------------------------------------------------------
736// "v_dual_add_f32" 0
737// v_dual_add_f32 v255 0 (DST) --> 1
738// v4 1 (SRC0) --> 2
739// v5 2 (SRC1) --> 3
740// "::" 4
741// "v_dual_mov_b32" 5
742// v_dual_mov_b32 v6 0 (DST) --> 6
743// v1 1 (SRC0) --> 7
744// -------------------------------------------------------------------
745//
747private:
748 // Regular MachineInstr/MCInst operands are ordered as follows:
749 // dst, src0 [, other src operands]
750 // VOPD MachineInstr/MCInst operands are ordered as follows:
751 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
752 // Each ComponentKind has operand indices defined below.
753 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
754 static constexpr unsigned FIRST_MC_SRC_IDX[] = {1, 2, 2 /* + OpX.MCSrcNum */};
755
756 // Parsed operands of regular instructions are ordered as follows:
757 // Mnemo dst src0 [vsrc1 ...]
758 // Parsed VOPD operands are ordered as follows:
759 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
760 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
761 // Each ComponentKind has operand indices defined below.
762 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
763 4 /* + OpX.ParsedSrcNum */};
764 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
765 2, 2, 5 /* + OpX.ParsedSrcNum */};
766
767private:
768 const ComponentKind Kind;
769 const ComponentProps PrevComp;
770
771public:
772 // Create layout for COMPONENT_X or SINGLE component.
773 ComponentLayout(ComponentKind Kind) : Kind(Kind) {
775 }
776
777 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
779 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps) {}
780
781public:
782 // Return the index of dst operand in MCInst operands.
783 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
784
785 // Return the index of the specified src operand in MCInst operands.
786 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx) const {
787 assert(CompSrcIdx < Component::MAX_SRC_NUM);
788 return FIRST_MC_SRC_IDX[Kind] + getPrevCompSrcNum() + CompSrcIdx;
789 }
790
791 // Return the index of dst operand in the parsed operands array.
793 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
794 }
795
796 // Return the index of the specified src operand in the parsed operands array.
797 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
798 assert(CompSrcIdx < Component::MAX_SRC_NUM);
799 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
800 }
801
802private:
803 unsigned getPrevCompSrcNum() const {
804 return PrevComp.getCompSrcOperandsNum();
805 }
806 unsigned getPrevCompParsedSrcNum() const {
807 return PrevComp.getCompParsedSrcOperandsNum();
808 }
809};
810
811// Layout and properties of VOPD components.
813public:
814 // Create ComponentInfo for COMPONENT_X or SINGLE component.
817 : ComponentLayout(Kind), ComponentProps(OpDesc) {}
818
819 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
820 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps)
821 : ComponentLayout(OpXProps), ComponentProps(OpDesc) {}
822
823 // Map component operand index to parsed operand index.
824 // Return 0 if the specified operand does not exist.
825 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
826};
827
828// Properties of VOPD instructions.
829class InstInfo {
830private:
831 const ComponentInfo CompInfo[COMPONENTS_NUM];
832
833public:
834 using RegIndices = std::array<unsigned, Component::MAX_OPR_NUM>;
835
836 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
837 : CompInfo{OpX, OpY} {}
838
839 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
840 : CompInfo{OprInfoX, OprInfoY} {}
841
842 const ComponentInfo &operator[](size_t ComponentIdx) const {
843 assert(ComponentIdx < COMPONENTS_NUM);
844 return CompInfo[ComponentIdx];
845 }
846
847 // Check VOPD operands constraints.
848 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
849 // for the specified component and MC operand. The callback must return 0
850 // if the operand is not a register or not a VGPR.
851 // If \p SkipSrc is set to true then constraints for source operands are not
852 // checked.
853 bool hasInvalidOperand(std::function<unsigned(unsigned, unsigned)> GetRegIdx,
854 bool SkipSrc = false) const {
855 return getInvalidCompOperandIndex(GetRegIdx, SkipSrc).has_value();
856 }
857
858 // Check VOPD operands constraints.
859 // Return the index of an invalid component operand, if any.
860 // If \p SkipSrc is set to true then constraints for source operands are not
861 // checked.
862 std::optional<unsigned> getInvalidCompOperandIndex(
863 std::function<unsigned(unsigned, unsigned)> GetRegIdx,
864 bool SkipSrc = false) const;
865
866private:
868 getRegIndices(unsigned ComponentIdx,
869 std::function<unsigned(unsigned, unsigned)> GetRegIdx) const;
870};
871
872} // namespace VOPD
873
875std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
876
878// Get properties of 2 single VOP1/VOP2 instructions
879// used as components to create a VOPD instruction.
880VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
881
883// Get properties of VOPD X and Y components.
884VOPD::InstInfo
885getVOPDInstInfo(unsigned VOPDOpcode, const MCInstrInfo *InstrInfo);
886
888bool isTrue16Inst(unsigned Opc);
889
891FPType getFPDstSelType(unsigned Opc);
892
895
898
899bool isDPMACCInstruction(unsigned Opc);
900
902unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
903
905unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
906
908 const MCSubtargetInfo *STI);
909
910bool isGroupSegment(const GlobalValue *GV);
911bool isGlobalSegment(const GlobalValue *GV);
912bool isReadOnlySegment(const GlobalValue *GV);
913
914/// \returns True if constants should be emitted to .text section for given
915/// target triple \p TT, false otherwise.
917
918/// \returns Integer value requested using \p F's \p Name attribute.
919///
920/// \returns \p Default if attribute is not present.
921///
922/// \returns \p Default and emits error if requested value cannot be converted
923/// to integer.
925
926/// \returns A pair of integer values requested using \p F's \p Name attribute
927/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
928/// is false).
929///
930/// \returns \p Default if attribute is not present.
931///
932/// \returns \p Default and emits error if one of the requested values cannot be
933/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
934/// not present.
935std::pair<unsigned, unsigned>
937 std::pair<unsigned, unsigned> Default,
938 bool OnlyFirstRequired = false);
939
940/// \returns A pair of integer values requested using \p F's \p Name attribute
941/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
942/// is false).
943///
944/// \returns \p std::nullopt if attribute is not present.
945///
946/// \returns \p std::nullopt and emits error if one of the requested values
947/// cannot be converted to integer, or \p OnlyFirstRequired is false and
948/// "second" value is not present.
949std::optional<std::pair<unsigned, std::optional<unsigned>>>
951 bool OnlyFirstRequired = false);
952
953/// \returns Generate a vector of integer values requested using \p F's \p Name
954/// attribute.
955///
956/// \returns true if exactly Size (>2) number of integers are found in the
957/// attribute.
958///
959/// \returns false if any error occurs.
961 unsigned Size,
962 unsigned DefaultVal = 0);
963
964/// Represents the counter values to wait for in an s_waitcnt instruction.
965///
966/// Large values (including the maximum possible integer) can be used to
967/// represent "don't care" waits.
968struct Waitcnt {
969 unsigned LoadCnt = ~0u; // Corresponds to Vmcnt prior to gfx12.
970 unsigned ExpCnt = ~0u;
971 unsigned DsCnt = ~0u; // Corresponds to LGKMcnt prior to gfx12.
972 unsigned StoreCnt = ~0u; // Corresponds to VScnt on gfx10/gfx11.
973 unsigned SampleCnt = ~0u; // gfx12+ only.
974 unsigned BvhCnt = ~0u; // gfx12+ only.
975 unsigned KmCnt = ~0u; // gfx12+ only.
976
977 Waitcnt() = default;
978 // Pre-gfx12 constructor.
979 Waitcnt(unsigned VmCnt, unsigned ExpCnt, unsigned LgkmCnt, unsigned VsCnt)
980 : LoadCnt(VmCnt), ExpCnt(ExpCnt), DsCnt(LgkmCnt), StoreCnt(VsCnt) {}
981
982 // gfx12+ constructor.
983 Waitcnt(unsigned LoadCnt, unsigned ExpCnt, unsigned DsCnt, unsigned StoreCnt,
984 unsigned SampleCnt, unsigned BvhCnt, unsigned KmCnt)
987
988 bool hasWait() const { return StoreCnt != ~0u || hasWaitExceptStoreCnt(); }
989
991 return LoadCnt != ~0u || ExpCnt != ~0u || DsCnt != ~0u ||
992 SampleCnt != ~0u || BvhCnt != ~0u || KmCnt != ~0u;
993 }
994
995 bool hasWaitStoreCnt() const { return StoreCnt != ~0u; }
996
998 // Does the right thing provided self and Other are either both pre-gfx12
999 // or both gfx12+.
1000 return Waitcnt(
1001 std::min(LoadCnt, Other.LoadCnt), std::min(ExpCnt, Other.ExpCnt),
1002 std::min(DsCnt, Other.DsCnt), std::min(StoreCnt, Other.StoreCnt),
1003 std::min(SampleCnt, Other.SampleCnt), std::min(BvhCnt, Other.BvhCnt),
1004 std::min(KmCnt, Other.KmCnt));
1005 }
1006};
1007
1008// The following methods are only meaningful on targets that support
1009// S_WAITCNT.
1010
1011/// \returns Vmcnt bit mask for given isa \p Version.
1012unsigned getVmcntBitMask(const IsaVersion &Version);
1013
1014/// \returns Expcnt bit mask for given isa \p Version.
1015unsigned getExpcntBitMask(const IsaVersion &Version);
1016
1017/// \returns Lgkmcnt bit mask for given isa \p Version.
1018unsigned getLgkmcntBitMask(const IsaVersion &Version);
1019
1020/// \returns Waitcnt bit mask for given isa \p Version.
1021unsigned getWaitcntBitMask(const IsaVersion &Version);
1022
1023/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1024unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1025
1026/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1027unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1028
1029/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1030unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1031
1032/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1033/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1034/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1035/// which needs it is deprecated
1036///
1037/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1038/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1039/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1040/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1041/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1042/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1043/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1044/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1045/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1046///
1047void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt,
1048 unsigned &Vmcnt, unsigned &Expcnt, unsigned &Lgkmcnt);
1049
1050Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded);
1051
1052/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1053unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1054 unsigned Vmcnt);
1055
1056/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1057unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1058 unsigned Expcnt);
1059
1060/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1061unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1062 unsigned Lgkmcnt);
1063
1064/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1065/// \p Version. Should not be used on gfx12+, the instruction which needs
1066/// it is deprecated
1067///
1068/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1069/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1070/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1071/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1072/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1073/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1074/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1075/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1076/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1077/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1078///
1079/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1080/// isa \p Version.
1081///
1082unsigned encodeWaitcnt(const IsaVersion &Version,
1083 unsigned Vmcnt, unsigned Expcnt, unsigned Lgkmcnt);
1084
1085unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded);
1086
1087// The following methods are only meaningful on targets that support
1088// S_WAIT_*CNT, introduced with gfx12.
1089
1090/// \returns Loadcnt bit mask for given isa \p Version.
1091/// Returns 0 for versions that do not support LOADcnt
1092unsigned getLoadcntBitMask(const IsaVersion &Version);
1093
1094/// \returns Samplecnt bit mask for given isa \p Version.
1095/// Returns 0 for versions that do not support SAMPLEcnt
1096unsigned getSamplecntBitMask(const IsaVersion &Version);
1097
1098/// \returns Bvhcnt bit mask for given isa \p Version.
1099/// Returns 0 for versions that do not support BVHcnt
1100unsigned getBvhcntBitMask(const IsaVersion &Version);
1101
1102/// \returns Dscnt bit mask for given isa \p Version.
1103/// Returns 0 for versions that do not support DScnt
1104unsigned getDscntBitMask(const IsaVersion &Version);
1105
1106/// \returns Dscnt bit mask for given isa \p Version.
1107/// Returns 0 for versions that do not support KMcnt
1108unsigned getKmcntBitMask(const IsaVersion &Version);
1109
1110/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1111/// returns 0 for versions that do not support STOREcnt or VScnt.
1112/// STOREcnt and VScnt are the same counter, the name used
1113/// depends on the ISA version.
1114unsigned getStorecntBitMask(const IsaVersion &Version);
1115
1116// The following are only meaningful on targets that support
1117// S_WAIT_LOADCNT_DSCNT and S_WAIT_STORECNT_DSCNT.
1118
1119/// \returns Decoded Waitcnt structure from given \p LoadcntDscnt for given
1120/// isa \p Version.
1121Waitcnt decodeLoadcntDscnt(const IsaVersion &Version, unsigned LoadcntDscnt);
1122
1123/// \returns Decoded Waitcnt structure from given \p StorecntDscnt for given
1124/// isa \p Version.
1125Waitcnt decodeStorecntDscnt(const IsaVersion &Version, unsigned StorecntDscnt);
1126
1127/// \returns \p Loadcnt and \p Dscnt components of \p Decoded encoded as an
1128/// immediate that can be used with S_WAIT_LOADCNT_DSCNT for given isa
1129/// \p Version.
1130unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded);
1131
1132/// \returns \p Storecnt and \p Dscnt components of \p Decoded encoded as an
1133/// immediate that can be used with S_WAIT_STORECNT_DSCNT for given isa
1134/// \p Version.
1135unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded);
1136
1137namespace Hwreg {
1138
1141
1142struct HwregSize : EncodingField<15, 11, 32> {
1144 constexpr uint64_t encode() const { return Value - 1; }
1145 static ValueType decode(uint64_t Encoded) { return Encoded + 1; }
1146};
1147
1149
1150} // namespace Hwreg
1151
1152namespace DepCtr {
1153
1155int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1156 const MCSubtargetInfo &STI);
1157bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1158 const MCSubtargetInfo &STI);
1159bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1160 bool &IsDefault, const MCSubtargetInfo &STI);
1161
1162/// \returns Decoded VaVdst from given immediate \p Encoded.
1163unsigned decodeFieldVaVdst(unsigned Encoded);
1164
1165/// \returns Decoded VmVsrc from given immediate \p Encoded.
1166unsigned decodeFieldVmVsrc(unsigned Encoded);
1167
1168/// \returns Decoded SaSdst from given immediate \p Encoded.
1169unsigned decodeFieldSaSdst(unsigned Encoded);
1170
1171/// \returns Decoded VaSdst from given immediate \p Encoded.
1172unsigned decodeFieldVaSdst(unsigned Encoded);
1173
1174/// \returns Decoded VaVcc from given immediate \p Encoded.
1175unsigned decodeFieldVaVcc(unsigned Encoded);
1176
1177/// \returns \p VmVsrc as an encoded Depctr immediate.
1178unsigned encodeFieldVmVsrc(unsigned VmVsrc);
1179
1180/// \returns \p Encoded combined with encoded \p VmVsrc.
1181unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1182
1183/// \returns \p VaVdst as an encoded Depctr immediate.
1184unsigned encodeFieldVaVdst(unsigned VaVdst);
1185
1186/// \returns \p Encoded combined with encoded \p VaVdst.
1187unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1188
1189/// \returns \p SaSdst as an encoded Depctr immediate.
1190unsigned encodeFieldSaSdst(unsigned SaSdst);
1191
1192/// \returns \p Encoded combined with encoded \p SaSdst.
1193unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1194
1195/// \returns \p VaSdst as an encoded Depctr immediate.
1196unsigned encodeFieldVaSdst(unsigned VaSdst);
1197
1198/// \returns \p Encoded combined with encoded \p VaSdst.
1199unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1200
1201/// \returns \p VaVcc as an encoded Depctr immediate.
1202unsigned encodeFieldVaVcc(unsigned VaVcc);
1203
1204/// \returns \p Encoded combined with encoded \p VaVcc.
1205unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1206
1207} // namespace DepCtr
1208
1209namespace Exp {
1210
1211bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1212
1214unsigned getTgtId(const StringRef Name);
1215
1217bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1218
1219} // namespace Exp
1220
1221namespace MTBUFFormat {
1222
1224int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1225
1226void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1227
1228int64_t getDfmt(const StringRef Name);
1229
1230StringRef getDfmtName(unsigned Id);
1231
1232int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1233
1234StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1235
1236bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1237
1238bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1239
1240int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1241
1242StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1243
1244bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1245
1246int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1247 const MCSubtargetInfo &STI);
1248
1249bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1250
1251unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1252
1253} // namespace MTBUFFormat
1254
1255namespace SendMsg {
1256
1258bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1259
1261bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1262 bool Strict = true);
1263
1265bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1266 const MCSubtargetInfo &STI, bool Strict = true);
1267
1269bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1270
1272bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1273
1274void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1275 uint16_t &StreamId, const MCSubtargetInfo &STI);
1276
1279 uint64_t OpId,
1281
1282} // namespace SendMsg
1283
1284
1285unsigned getInitialPSInputAddr(const Function &F);
1286
1287bool getHasColorExport(const Function &F);
1288
1289bool getHasDepthExport(const Function &F);
1290
1293
1296
1299
1302
1303// These functions are considered entrypoints into the current module, i.e. they
1304// are allowed to be called from outside the current module. This is different
1305// from isEntryFunctionCC, which is only true for functions that are entered by
1306// the hardware. Module entry points include all entry functions but also
1307// include functions that can be called from other functions inside or outside
1308// the current module. Module entry functions are allowed to allocate LDS.
1311
1314
1315bool isKernelCC(const Function *Func);
1316
1317// FIXME: Remove this when calling conventions cleaned up
1320 switch (CC) {
1323 return true;
1324 default:
1325 return false;
1326 }
1327}
1328
1329bool hasXNACK(const MCSubtargetInfo &STI);
1330bool hasSRAMECC(const MCSubtargetInfo &STI);
1331bool hasMIMG_R128(const MCSubtargetInfo &STI);
1332bool hasA16(const MCSubtargetInfo &STI);
1333bool hasG16(const MCSubtargetInfo &STI);
1334bool hasPackedD16(const MCSubtargetInfo &STI);
1335bool hasGDS(const MCSubtargetInfo &STI);
1336unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1337unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1338
1339bool isSI(const MCSubtargetInfo &STI);
1340bool isCI(const MCSubtargetInfo &STI);
1341bool isVI(const MCSubtargetInfo &STI);
1342bool isGFX9(const MCSubtargetInfo &STI);
1343bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1344bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1345bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1346bool isGFX8Plus(const MCSubtargetInfo &STI);
1347bool isGFX9Plus(const MCSubtargetInfo &STI);
1348bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1349bool isGFX10(const MCSubtargetInfo &STI);
1350bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1351bool isGFX10Plus(const MCSubtargetInfo &STI);
1352bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1353bool isGFX10Before1030(const MCSubtargetInfo &STI);
1354bool isGFX11(const MCSubtargetInfo &STI);
1355bool isGFX11Plus(const MCSubtargetInfo &STI);
1356bool isGFX12(const MCSubtargetInfo &STI);
1357bool isGFX12Plus(const MCSubtargetInfo &STI);
1358bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1359bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1360bool isGCN3Encoding(const MCSubtargetInfo &STI);
1361bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
1362bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1363bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1364bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1365bool isGFX90A(const MCSubtargetInfo &STI);
1366bool isGFX940(const MCSubtargetInfo &STI);
1368bool hasMAIInsts(const MCSubtargetInfo &STI);
1369bool hasVOPD(const MCSubtargetInfo &STI);
1370bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1371int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
1372unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1374
1375/// Is Reg - scalar register
1376bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1377
1378/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1380
1381/// If \p Reg is a pseudo reg, return the correct hardware register given
1382/// \p STI otherwise return \p Reg.
1384
1385/// Convert hardware register \p Reg to a pseudo register
1388
1390bool isInlineValue(unsigned Reg);
1391
1392/// Is this an AMDGPU specific source operand? These include registers,
1393/// inline constants, literals and mandatory literals (KImm).
1394bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo);
1395
1396/// Is this a KImm operand?
1397bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1398
1399/// Is this floating-point operand?
1400bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1401
1402/// Does this operand support only inlinable literals?
1403bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
1404
1405/// Get the size in bits of a register from the register class \p RC.
1406unsigned getRegBitWidth(unsigned RCID);
1407
1408/// Get the size in bits of a register from the register class \p RC.
1409unsigned getRegBitWidth(const MCRegisterClass &RC);
1410
1411/// Get size of register operand
1412unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc,
1413 unsigned OpNo);
1414
1416inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1417 switch (OpInfo.OperandType) {
1430 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1432 return 4;
1433
1439 return 8;
1440
1461 return 2;
1462
1463 default:
1464 llvm_unreachable("unhandled operand type");
1465 }
1466}
1467
1469inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
1470 return getOperandSize(Desc.operands()[OpNo]);
1471}
1472
1473/// Is this literal inlinable, and not one of the values intended for floating
1474/// point values.
1476inline bool isInlinableIntLiteral(int64_t Literal) {
1477 return Literal >= -16 && Literal <= 64;
1478}
1479
1480/// Is this literal inlinable
1482bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
1483
1485bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
1486
1488bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1489
1491bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi);
1492
1494bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1495
1497bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi);
1498
1500std::optional<unsigned> getInlineEncodingV2I16(uint32_t Literal);
1501
1503std::optional<unsigned> getInlineEncodingV2BF16(uint32_t Literal);
1504
1506std::optional<unsigned> getInlineEncodingV2F16(uint32_t Literal);
1507
1510
1513
1516
1519
1521bool isValid32BitLiteral(uint64_t Val, bool IsFP64);
1522
1523bool isArgPassedInSGPR(const Argument *Arg);
1524
1525bool isArgPassedInSGPR(const CallBase *CB, unsigned ArgNo);
1526
1529 int64_t EncodedOffset);
1530
1533 int64_t EncodedOffset,
1534 bool IsBuffer);
1535
1536/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1537/// offsets.
1539
1540/// \returns The encoding that will be used for \p ByteOffset in the
1541/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1542/// S_LOAD instructions have a signed offset, on other subtargets it is
1543/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1544std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1545 int64_t ByteOffset, bool IsBuffer,
1546 bool HasSOffset = false);
1547
1548/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1549/// instruction. This is only useful on CI.s
1550std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1551 int64_t ByteOffset);
1552
1553/// For pre-GFX12 FLAT instructions the offset must be positive;
1554/// MSB is ignored and forced to zero.
1555///
1556/// \return The number of bits available for the signed offset field in flat
1557/// instructions. Note that some forms of the instruction disallow negative
1558/// offsets.
1559unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1560
1561/// \returns true if this offset is small enough to fit in the SMRD
1562/// offset field. \p ByteOffset should be the offset in bytes and
1563/// not the encoded offset.
1564bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
1565
1567inline bool isLegalDPALU_DPPControl(unsigned DC) {
1568 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1569}
1570
1571/// \returns true if an instruction may have a 64-bit VGPR operand.
1572bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc);
1573
1574/// \returns true if an instruction is a DP ALU DPP.
1575bool isDPALU_DPP(const MCInstrDesc &OpDesc);
1576
1577/// \returns true if the intrinsic is divergent
1578bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1579
1580/// \returns true if the intrinsic is uniform
1581bool isIntrinsicAlwaysUniform(unsigned IntrID);
1582
1583/// \returns lds block size in terms of dwords. \p
1584/// This is used to calculate the lds size encoded for PAL metadata 3.0+ which
1585/// must be defined in terms of bytes.
1586unsigned getLdsDwGranularity(const MCSubtargetInfo &ST);
1587
1588} // end namespace AMDGPU
1589
1590raw_ostream &operator<<(raw_ostream &OS,
1592
1593} // end namespace llvm
1594
1595#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
unsigned const MachineRegisterInfo * MRI
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:299
#define LLVM_READONLY
Definition: Compiler.h:306
uint64_t Align
std::string Name
uint32_t Index
uint64_t Size
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
unsigned const TargetRegisterInfo * TRI
unsigned Reg
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned unsigned DefaultVal
raw_pwrite_stream & OS
void setTargetIDFromFeaturesString(StringRef FS)
void setXnackSetting(TargetIDSetting NewXnackSetting)
Sets xnack setting to NewXnackSetting.
TargetIDSetting getXnackSetting() const
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)
ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps)
unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx) const
unsigned getIndexOfDstInParsedOperands() const
ComponentLayout(const ComponentProps &OpXProps)
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
bool hasRegSrcOperand(unsigned CompSrcIdx) const
unsigned getMandatoryLiteralCompOperandIndex() const
unsigned getCompParsedSrcOperandsNum() const
InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
bool hasInvalidOperand(std::function< unsigned(unsigned, unsigned)> GetRegIdx, bool SkipSrc=false) const
const ComponentInfo & operator[](size_t ComponentIdx) const
InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
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.
Definition: Argument.h:31
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1112
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:198
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition: MCInstrDesc.h:85
uint8_t OperandType
Information about the type of the operand.
Definition: MCInstrDesc.h:97
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.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVM Value Representation.
Definition: Value.h:74
#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)
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 decodeFieldVaSdst(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)
bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
unsigned decodeFieldVaVdst(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)
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
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)
unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI)
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
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)
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)
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 COMPONENTS[]
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)
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.
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)
LLVM_READNONE bool isLegalDPALU_DPPControl(unsigned DC)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
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)
int32_t getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR)
bool isGFX10(const MCSubtargetInfo &STI)
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)
CanBeVOPD getCanBeVOPD(unsigned Opc)
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 isEntryFunctionCC(CallingConv::ID CC)
LLVM_READNONE bool isKernel(CallingConv::ID CC)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
bool getSMEMIsBuffer(unsigned Opc)
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
LLVM_READONLY bool isInvalidSingleUseProducerInst(unsigned Opc)
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
LLVM_READONLY bool isInvalidSingleUseConsumerInst(unsigned Opc)
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)
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)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx)
bool getVOP3IsSingle(unsigned Opc)
bool isGFX9(const MCSubtargetInfo &STI)
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 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)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
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,...
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)
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_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)
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)
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:234
@ OPERAND_REG_IMM_INT64
Definition: SIDefines.h:201
@ OPERAND_REG_IMM_V2FP16
Definition: SIDefines.h:211
@ OPERAND_REG_INLINE_C_V2INT32
Definition: SIDefines.h:227
@ OPERAND_REG_INLINE_C_FP64
Definition: SIDefines.h:223
@ OPERAND_REG_INLINE_C_BF16
Definition: SIDefines.h:220
@ OPERAND_REG_INLINE_C_V2BF16
Definition: SIDefines.h:225
@ OPERAND_REG_IMM_V2INT16
Definition: SIDefines.h:212
@ OPERAND_REG_IMM_BF16
Definition: SIDefines.h:205
@ OPERAND_REG_INLINE_AC_V2FP16
Definition: SIDefines.h:246
@ OPERAND_REG_IMM_INT32
Operands with register or 32-bit immediate.
Definition: SIDefines.h:200
@ OPERAND_REG_IMM_V2BF16
Definition: SIDefines.h:210
@ OPERAND_REG_IMM_BF16_DEFERRED
Definition: SIDefines.h:207
@ OPERAND_REG_IMM_FP16
Definition: SIDefines.h:206
@ OPERAND_REG_INLINE_C_INT64
Definition: SIDefines.h:219
@ OPERAND_REG_INLINE_AC_BF16
Definition: SIDefines.h:240
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition: SIDefines.h:217
@ OPERAND_REG_INLINE_AC_INT16
Operands with an AccVGPR register or inline constant.
Definition: SIDefines.h:238
@ OPERAND_REG_IMM_FP64
Definition: SIDefines.h:204
@ OPERAND_REG_INLINE_C_V2FP16
Definition: SIDefines.h:226
@ OPERAND_REG_INLINE_AC_V2INT16
Definition: SIDefines.h:244
@ OPERAND_REG_INLINE_AC_FP16
Definition: SIDefines.h:241
@ OPERAND_REG_INLINE_AC_INT32
Definition: SIDefines.h:239
@ OPERAND_REG_INLINE_AC_FP32
Definition: SIDefines.h:242
@ OPERAND_REG_INLINE_AC_V2BF16
Definition: SIDefines.h:245
@ OPERAND_REG_IMM_V2INT32
Definition: SIDefines.h:213
@ OPERAND_REG_IMM_FP32
Definition: SIDefines.h:203
@ OPERAND_REG_INLINE_C_FP32
Definition: SIDefines.h:222
@ OPERAND_REG_INLINE_C_INT32
Definition: SIDefines.h:218
@ OPERAND_REG_INLINE_C_V2INT16
Definition: SIDefines.h:224
@ OPERAND_REG_IMM_V2FP32
Definition: SIDefines.h:214
@ OPERAND_REG_INLINE_AC_FP64
Definition: SIDefines.h:243
@ OPERAND_REG_INLINE_C_FP16
Definition: SIDefines.h:221
@ OPERAND_REG_IMM_INT16
Definition: SIDefines.h:202
@ OPERAND_REG_INLINE_C_V2FP32
Definition: SIDefines.h:228
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition: SIDefines.h:231
@ OPERAND_REG_IMM_FP32_DEFERRED
Definition: SIDefines.h:209
@ OPERAND_REG_IMM_FP16_DEFERRED
Definition: SIDefines.h:208
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo *STI)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
bool hasGDS(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedUnsignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset)
bool isGFX9Plus(const MCSubtargetInfo &STI)
bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI)
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)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfo(unsigned DimEnum)
bool getMUBUFIsBufferInv(unsigned Opc)
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 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)
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)
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)
LLVM_READONLY int getSOPPWithRelaxation(uint16_t Opcode)
bool getMUBUFHasSrsrc(unsigned Opc)
unsigned getDscntBitMask(const IsaVersion &Version)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
Definition: CallingConv.h:200
@ SPIR_KERNEL
Used for SPIR kernel functions.
Definition: CallingConv.h:144
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Other
Any other memory.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:303
@ Default
The result values are uniform if and only if all operands are uniform.
uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Definition: MathExtras.h:220
AMD Kernel Code Object (amd_kernel_code_t).
static constexpr unsigned Width
constexpr EncodingField(ValueType Value)
static constexpr unsigned Offset
static constexpr ValueType Default
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 uint64_t encode() const
static ValueType decode(uint64_t Encoded)
Represents the counter values to wait for in an s_waitcnt instruction.
Waitcnt(unsigned LoadCnt, unsigned ExpCnt, unsigned DsCnt, unsigned StoreCnt, unsigned SampleCnt, unsigned BvhCnt, unsigned KmCnt)
bool hasWaitExceptStoreCnt() const
bool hasWaitStoreCnt() const
Waitcnt(unsigned VmCnt, unsigned ExpCnt, unsigned LgkmCnt, unsigned VsCnt)
Waitcnt combined(const Waitcnt &Other) const
Description of the encoding of one expression Op.