LLVM 23.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"
16#include "llvm/IR/CallingConv.h"
17#include "llvm/IR/InstrTypes.h"
18#include "llvm/IR/Module.h"
21#include <array>
22#include <functional>
23#include <utility>
24
25// Pull in OpName enum definition and getNamedOperandIdx() declaration.
26#define GET_INSTRINFO_OPERAND_ENUM
27#include "AMDGPUGenInstrInfo.inc"
28
30
31namespace llvm {
32
33struct Align;
34class Argument;
35class Function;
36class GlobalValue;
37class MachineInstr;
38class MCInstrInfo;
39class MCRegisterClass;
40class MCRegisterInfo;
41class MCSubtargetInfo;
42class MDNode;
43class StringRef;
44class Triple;
45class raw_ostream;
46
47namespace AMDGPU {
48
49struct AMDGPUMCKernelCodeT;
50struct IsaVersion;
51
52/// Generic target versions emitted by this version of LLVM.
53///
54/// These numbers are incremented every time a codegen breaking change occurs
55/// within a generic family.
56namespace GenericVersion {
57static constexpr unsigned GFX9 = 1;
58static constexpr unsigned GFX9_4 = 1;
59static constexpr unsigned GFX10_1 = 1;
60static constexpr unsigned GFX10_3 = 1;
61static constexpr unsigned GFX11 = 1;
62static constexpr unsigned GFX11_7 = 1;
63static constexpr unsigned GFX12 = 1;
64static constexpr unsigned GFX12_5 = 1;
65static constexpr unsigned GFX13 = 1;
66} // namespace GenericVersion
67
68enum { AMDHSA_COV4 = 4, AMDHSA_COV5 = 5, AMDHSA_COV6 = 6 };
69
70enum class FPType { None, FP4, FP8 };
71
72/// \returns True if \p STI is AMDHSA.
73bool isHsaAbi(const MCSubtargetInfo &STI);
74
75/// \returns Code object version from the IR module flag.
76unsigned getAMDHSACodeObjectVersion(const Module &M);
77
78/// \returns Code object version from ELF's e_ident[EI_ABIVERSION].
79unsigned getAMDHSACodeObjectVersion(unsigned ABIVersion);
80
81/// \returns The default HSA code object version. This should only be used when
82/// we lack a more accurate CodeObjectVersion value (e.g. from the IR module
83/// flag or a .amdhsa_code_object_version directive)
85
86/// \returns ABIVersion suitable for use in ELF's e_ident[EI_ABIVERSION]. \param
87/// CodeObjectVersion is a value returned by getAMDHSACodeObjectVersion().
88uint8_t getELFABIVersion(const Triple &OS, unsigned CodeObjectVersion);
89
90/// \returns The offset of the multigrid_sync_arg argument from implicitarg_ptr
91unsigned getMultigridSyncArgImplicitArgPosition(unsigned COV);
92
93/// \returns The offset of the hostcall pointer argument from implicitarg_ptr
94unsigned getHostcallImplicitArgPosition(unsigned COV);
95
96unsigned getDefaultQueueImplicitArgPosition(unsigned COV);
97unsigned getCompletionActionImplicitArgPosition(unsigned COV);
98
100 unsigned Format;
101 unsigned BitsPerComp;
103 unsigned NumFormat;
104 unsigned DataFormat;
105};
106
112
119
123
125 unsigned T16Op;
126 unsigned HiOp;
127 unsigned LoOp;
128};
129
135
136#define GET_MIMGBaseOpcode_DECL
137#define GET_MIMGDim_DECL
138#define GET_MIMGEncoding_DECL
139#define GET_MIMGLZMapping_DECL
140#define GET_MIMGMIPMapping_DECL
141#define GET_MIMGBiASMapping_DECL
142#define GET_MAIInstInfoTable_DECL
143#define GET_isMFMA_F8F6F4Table_DECL
144#define GET_isCvtScaleF32_F32F16ToF8F4Table_DECL
145#define GET_True16D16Table_DECL
146#define GET_WMMAInstInfoTable_DECL
147#include "AMDGPUGenSearchableTables.inc"
148
151
152/// Construct TargetID from MCSubtargetInfo. \p FeatureString is used to
153/// determine explicitly requested xnack/sramecc settings.
155 StringRef FeatureString);
156
157namespace IsaInfo {
158
159enum {
160 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
161 // doesn't spill SGPRs as much as when 80 is set.
164};
165
166/// \returns Instruction cache line size in bytes for given subtarget \p STI.
167unsigned getInstCacheLineSize(const MCSubtargetInfo &STI);
168
169/// \returns Wavefront size for given subtarget \p STI.
170unsigned getWavefrontSize(const MCSubtargetInfo &STI);
171
172/// \returns Local memory size in bytes for given subtarget \p STI.
173unsigned getLocalMemorySize(const MCSubtargetInfo &STI);
174
175/// \returns Maximum addressable local memory size in bytes for given subtarget
176/// \p STI.
178
179/// \returns Number of execution units per compute unit for given subtarget \p
180/// STI.
181unsigned getEUsPerCU(const MCSubtargetInfo &STI);
182
183/// \returns Maximum number of work groups per compute unit for given subtarget
184/// \p STI and limited by given \p FlatWorkGroupSize.
185unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI,
186 unsigned FlatWorkGroupSize);
187
188/// \returns Minimum number of waves per execution unit for given subtarget \p
189/// STI.
190unsigned getMinWavesPerEU(const MCSubtargetInfo &STI);
191
192/// \returns Maximum number of waves per execution unit for given subtarget \p
193/// STI without any kind of limitation.
194unsigned getMaxWavesPerEU(const MCSubtargetInfo &STI);
195
196/// \returns Number of waves per execution unit required to support the given \p
197/// FlatWorkGroupSize.
199 unsigned FlatWorkGroupSize);
200
201/// \returns Minimum flat work group size for given subtarget \p STI.
202unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo &STI);
203
204/// \returns Maximum flat work group size
205constexpr unsigned getMaxFlatWorkGroupSize() {
206 // Some subtargets allow encoding 2048, but this isn't tested or supported.
207 return 1024;
208}
209
210/// \returns Number of waves per work group for given subtarget \p STI and
211/// \p FlatWorkGroupSize.
212unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI,
213 unsigned FlatWorkGroupSize);
214
215/// \returns SGPR allocation granularity for given subtarget \p STI.
216unsigned getSGPRAllocGranule(const MCSubtargetInfo &STI);
217
218/// \returns SGPR encoding granularity for given subtarget \p STI.
219unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI);
220
221/// \returns Total number of SGPRs for given subtarget \p STI.
222unsigned getTotalNumSGPRs(const MCSubtargetInfo &STI);
223
224/// \returns Addressable number of SGPRs for given subtarget \p STI.
225unsigned getAddressableNumSGPRs(const MCSubtargetInfo &STI);
226
227/// \returns Minimum number of SGPRs that meets the given number of waves per
228/// execution unit requirement for given subtarget \p STI.
229unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU);
230
231/// \returns Maximum number of SGPRs that meets the given number of waves per
232/// execution unit requirement for given subtarget \p STI.
233unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
234 bool Addressable);
235
236/// \returns Number of extra SGPRs implicitly required by given subtarget \p
237/// STI when the given special registers are used.
238unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed,
239 bool FlatScrUsed, bool XNACKUsed);
240
241/// \returns Number of extra SGPRs implicitly required by given subtarget \p
242/// STI when the given special registers are used. XNACK is inferred from
243/// \p STI.
244unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed,
245 bool FlatScrUsed);
246
247/// \returns Number of SGPR blocks needed for given subtarget \p STI when
248/// \p NumSGPRs are used. \p NumSGPRs should already include any special
249/// register counts.
250unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs);
251
252/// \returns VGPR allocation granularity for given subtarget \p STI.
253///
254/// For subtargets which support it, \p EnableWavefrontSize32 should match
255/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
256unsigned
257getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize,
258 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
259
260/// \returns VGPR encoding granularity for given subtarget \p STI.
261///
262/// For subtargets which support it, \p EnableWavefrontSize32 should match
263/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
265 const MCSubtargetInfo &STI,
266 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
267
268/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
269/// returns the allocation granule for ArchVGPRs.
270unsigned getArchVGPRAllocGranule();
271
272/// \returns Total number of VGPRs for given subtarget \p STI.
273unsigned getTotalNumVGPRs(const MCSubtargetInfo &STI);
274
275/// Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
276static constexpr unsigned MaxDynamicVGPRBlocks = 8;
277
278/// \returns Addressable number of architectural VGPRs for a given subtarget \p
279/// STI.
281
282/// \returns Addressable number of VGPRs for given subtarget \p STI.
283unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI,
284 unsigned DynamicVGPRBlockSize);
285
286/// \returns Minimum number of VGPRs that meets given number of waves per
287/// execution unit requirement for given subtarget \p STI.
288unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
289 unsigned DynamicVGPRBlockSize);
290
291/// \returns Maximum number of VGPRs that meets given number of waves per
292/// execution unit requirement for given subtarget \p STI.
293unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
294 unsigned DynamicVGPRBlockSize);
295
296/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
297/// subtarget \p STI.
299 unsigned NumVGPRs,
300 unsigned DynamicVGPRBlockSize);
301
302/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
303/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
304unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
305 unsigned MaxWaves,
306 unsigned TotalNumVGPRs);
307
308/// \returns Whether allocated SGPRs can reduce occupancy on subtarget \p STI
309/// (true pre-GFX10). One named capability so callers don't test the version.
311
312/// \returns SGPR-limited occupancy (waves per EU) for subtarget \p STI: the
313/// inverse of getMaxNumSGPRs(). Unlike getMaxNumSGPRs() the budget is not
314/// clamped to the addressable count, since the allocated count callers pass in
315/// can exceed it.
316unsigned getOccupancyWithNumSGPRs(const MCSubtargetInfo &STI, unsigned SGPRs);
317
318/// \returns SGPR-limited occupancy computed from explicit budget parameters
319/// (\p MaxWaves, \p TotalNumSGPRs, \p Granule, \p TrapReserve). Subtarget-free
320/// core shared by the overload above and the occupancy MCExpr. Callers must
321/// check isSGPROccupancyLimited() first.
322unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
323 unsigned TotalNumSGPRs, unsigned Granule,
324 unsigned TrapReserve);
325
326/// \returns Number of VGPR blocks needed for given subtarget \p STI when
327/// \p NumVGPRs are used. We actually return the number of blocks -1, since
328/// that's what we encode.
329///
330/// For subtargets which support it, \p EnableWavefrontSize32 should match the
331/// ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
333 const MCSubtargetInfo &STI, unsigned NumVGPRs,
334 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
335
336/// \returns Number of VGPR blocks that need to be allocated for the given
337/// subtarget \p STI when \p NumVGPRs are used.
339 const MCSubtargetInfo &STI, unsigned NumVGPRs,
340 unsigned DynamicVGPRBlockSize,
341 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
342
343} // end namespace IsaInfo
344
345// Represents a field in an encoded value.
346template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
348 static_assert(HighBit >= LowBit, "Invalid bit range!");
349 static constexpr unsigned Offset = LowBit;
350 static constexpr unsigned Width = HighBit - LowBit + 1;
351
353 static constexpr ValueType Default = D;
354
357
358 constexpr uint64_t encode() const { return Value; }
359 static ValueType decode(uint64_t Encoded) { return Encoded; }
360};
361
362// Represents a single bit in an encoded value.
363template <unsigned Bit, unsigned D = 0>
365
366// A helper for encoding and decoding multiple fields.
367template <typename... Fields> struct EncodingFields {
368 static constexpr uint64_t encode(Fields... Values) {
369 return ((Values.encode() << Values.Offset) | ...);
370 }
371
372 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
373 return {Fields::decode((Encoded >> Fields::Offset) &
374 maxUIntN(Fields::Width))...};
375 }
376};
377
379inline bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx) {
380 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
381}
382
385
406
409
411const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
412
422
424const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
425
427
430
433
435 MIMGBaseOpcode L;
436 MIMGBaseOpcode LZ;
437};
438
440 MIMGBaseOpcode MIP;
441 MIMGBaseOpcode NONMIP;
442};
443
445 MIMGBaseOpcode Bias;
446 MIMGBaseOpcode NoBias;
447};
448
450 MIMGBaseOpcode Offset;
451 MIMGBaseOpcode NoOffset;
452};
453
455 MIMGBaseOpcode G;
456 MIMGBaseOpcode G16;
457};
458
461
463 unsigned Opcode2Addr;
464 unsigned Opcode3Addr;
465};
466
469
472
475
478
480int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
481 unsigned VDataDwords, unsigned VAddrDwords);
482
484int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
485
487unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
488 const MIMGDimInfo *Dim, bool IsA16,
489 bool IsG16Supported);
490
499
501const MIMGInfo *getMIMGInfo(unsigned Opc);
502
504int getMTBUFBaseOpcode(unsigned Opc);
505
507int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
508
510int getMTBUFElements(unsigned Opc);
511
513bool getMTBUFHasVAddr(unsigned Opc);
514
516bool getMTBUFHasSrsrc(unsigned Opc);
517
519bool getMTBUFHasSoffset(unsigned Opc);
520
522int getMUBUFBaseOpcode(unsigned Opc);
523
525int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
526
528int getMUBUFElements(unsigned Opc);
529
531bool getMUBUFHasVAddr(unsigned Opc);
532
534bool getMUBUFHasSrsrc(unsigned Opc);
535
537bool getMUBUFHasSoffset(unsigned Opc);
538
540bool getMUBUFIsBufferInv(unsigned Opc);
541
543bool getMUBUFTfe(unsigned Opc);
544
546bool getSMEMIsBuffer(unsigned Opc);
547
549bool getVOP1IsSingle(unsigned Opc);
550
552bool getVOP2IsSingle(unsigned Opc);
553
555bool getVOP3IsSingle(unsigned Opc);
556
558bool isVOPC64DPP(unsigned Opc);
559
561bool isVOPCAsmOnly(unsigned Opc);
562
563/// Returns true if MAI operation is a double precision GEMM.
565bool getMAIIsDGEMM(unsigned Opc);
566
568bool getMAIIsGFX940XDL(unsigned Opc);
569
571bool getWMMAIsXDL(unsigned Opc);
572
574bool getHasMatrixScale(unsigned Opc);
575
576// Get an equivalent BitOp3 for a binary logical \p Opc.
577// \returns BitOp3 modifier for the logical operation or zero.
578// Used in VOPD3 conversion.
579unsigned getBitOp2(unsigned Opc);
580
581struct CanBeVOPD {
582 bool X;
583 bool Y;
584};
585
586/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
588unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
589
591CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3);
592
594uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
595
598 unsigned BLGP,
599 unsigned F8F8Opcode);
600
603
606 unsigned FmtB,
607 unsigned F8F8Opcode);
608
609/// \return true if this combination is listed as valid.
611bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale,
612 unsigned BFmt, unsigned BScale);
613
616 uint8_t NumComponents,
617 uint8_t NumFormat,
618 const MCSubtargetInfo &STI);
621 const MCSubtargetInfo &STI);
622
624int32_t getMCOpcode(uint32_t Opcode, unsigned Gen);
625
627unsigned getVOPDOpcode(unsigned Opc, bool VOPD3);
628
630int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily,
631 bool VOPD3);
632
634bool isVOPD(unsigned Opc);
635
637bool isMAC(unsigned Opc);
638
640bool isPermlane16(unsigned Opc);
641
643bool isGenericAtomic(unsigned Opc);
644
646bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
647
648namespace VOPD {
649
660
661// LSB mask for VGPR banks per VOPD component operand.
662// 4 banks result in a mask 3, setting 2 lower bits.
663constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
664constexpr unsigned VOPD3_VGPR_BANK_MASKS[] = {1, 3, 3, 3};
665
666enum ComponentIndex : unsigned { X = 0, Y = 1 };
668constexpr unsigned COMPONENTS_NUM = 2;
669
670// Properties of VOPD components.
672private:
673 unsigned SrcOperandsNum = 0;
674 unsigned MandatoryLiteralIdx = ~0u;
675 bool HasSrc2Acc = false;
676 unsigned NumVOPD3Mods = 0;
677 unsigned Opcode = 0;
678 bool IsVOP3 = false;
679
680public:
681 ComponentProps() = default;
682 ComponentProps(const MCInstrDesc &OpDesc, bool VOP3Layout = false);
683
684 // Return the total number of src operands this component has.
685 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
686
687 // Return the number of src operands of this component visible to the parser.
689 return SrcOperandsNum - HasSrc2Acc;
690 }
691
692 // Return true iif this component has a mandatory literal.
693 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
694
695 // If this component has a mandatory literal, return component operand
696 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
699 return MandatoryLiteralIdx;
700 }
701
702 // Return true iif this component has operand
703 // with component index CompSrcIdx and this operand may be a register.
704 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
705 assert(CompSrcIdx < Component::MAX_SRC_NUM);
706 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
707 }
708
709 // Return true iif this component has tied src2.
710 bool hasSrc2Acc() const { return HasSrc2Acc; }
711
712 // Return a number of source modifiers if instruction is used in VOPD3.
713 unsigned getCompVOPD3ModsNum() const { return NumVOPD3Mods; }
714
715 // Return opcode of the component.
716 unsigned getOpcode() const { return Opcode; }
717
718 // Returns if component opcode is in VOP3 encoding.
719 unsigned isVOP3() const { return IsVOP3; }
720
721 // Return index of BitOp3 operand or -1.
722 int getBitOp3OperandIdx() const;
723
724private:
725 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
726 assert(CompSrcIdx < Component::MAX_SRC_NUM);
727 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
728 }
729};
730
731enum ComponentKind : unsigned {
732 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
733 COMPONENT_X, // A VOPD instruction, X component.
734 COMPONENT_Y, // A VOPD instruction, Y component.
736};
737
738// Interface functions of this class map VOPD component operand indices
739// to indices of operands in MachineInstr/MCInst or parsed operands array.
740//
741// Note that this class operates with 3 kinds of indices:
742// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
743// - MC operand indices (they refer operands in a MachineInstr/MCInst);
744// - parsed operand indices (they refer operands in parsed operands array).
745//
746// For SINGLE components mapping between these indices is trivial.
747// But things get more complicated for COMPONENT_X and
748// COMPONENT_Y because these components share the same
749// MachineInstr/MCInst and the same parsed operands array.
750// Below is an example of component operand to parsed operand
751// mapping for the following instruction:
752//
753// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
754//
755// PARSED COMPONENT PARSED
756// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
757// -------------------------------------------------------------------
758// "v_dual_add_f32" 0
759// v_dual_add_f32 v255 0 (DST) --> 1
760// v4 1 (SRC0) --> 2
761// v5 2 (SRC1) --> 3
762// "::" 4
763// "v_dual_mov_b32" 5
764// v_dual_mov_b32 v6 0 (DST) --> 6
765// v1 1 (SRC0) --> 7
766// -------------------------------------------------------------------
767//
769private:
770 // Regular MachineInstr/MCInst operands are ordered as follows:
771 // dst, src0 [, other src operands]
772 // VOPD MachineInstr/MCInst operands are ordered as follows:
773 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
774 // Each ComponentKind has operand indices defined below.
775 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
776
777 // VOPD3 instructions may have 2 or 3 source modifiers, src2 modifier is not
778 // used if there is tied accumulator. Indexing of this array:
779 // MC_SRC_IDX[VOPD3ModsNum][SrcNo]. This returns an index for a SINGLE
780 // instruction layout, add 1 for COMPONENT_X or COMPONENT_Y. For the second
781 // component add OpX.MCSrcNum + OpX.VOPD3ModsNum.
782 // For VOPD1/VOPD2 use column with zero modifiers.
783 static constexpr unsigned SINGLE_MC_SRC_IDX[4][3] = {
784 {1, 2, 3}, {2, 3, 4}, {2, 4, 5}, {2, 4, 6}};
785
786 // Parsed operands of regular instructions are ordered as follows:
787 // Mnemo dst src0 [vsrc1 ...]
788 // Parsed VOPD operands are ordered as follows:
789 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
790 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
791 // Each ComponentKind has operand indices defined below.
792 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
793 4 /* + OpX.ParsedSrcNum */};
794 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
795 2, 2, 5 /* + OpX.ParsedSrcNum */};
796
797private:
798 const ComponentKind Kind;
799 const ComponentProps PrevComp;
800 const unsigned VOPD3ModsNum;
801 const int BitOp3Idx; // Index of bitop3 operand or -1
802
803public:
804 // Create layout for COMPONENT_X or SINGLE component.
805 ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
806 : Kind(Kind), VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {
808 }
809
810 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
811 ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum,
812 int BitOp3Idx)
813 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps),
814 VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {}
815
816public:
817 // Return the index of dst operand in MCInst operands.
818 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
819
820 // Return the index of the specified src operand in MCInst operands.
821 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const {
822 assert(CompSrcIdx < Component::MAX_SRC_NUM);
823
824 if (Kind == SINGLE && CompSrcIdx == 2 && BitOp3Idx != -1)
825 return BitOp3Idx;
826
827 if (VOPD3) {
828 return SINGLE_MC_SRC_IDX[VOPD3ModsNum][CompSrcIdx] + getPrevCompSrcNum() +
829 getPrevCompVOPD3ModsNum() + (Kind != SINGLE ? 1 : 0);
830 }
831
832 return SINGLE_MC_SRC_IDX[0][CompSrcIdx] + getPrevCompSrcNum() +
833 (Kind != SINGLE ? 1 : 0);
834 }
835
836 // Return the index of dst operand in the parsed operands array.
838 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
839 }
840
841 // Return the index of the specified src operand in the parsed operands array.
842 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
843 assert(CompSrcIdx < Component::MAX_SRC_NUM);
844 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
845 }
846
847private:
848 unsigned getPrevCompSrcNum() const {
849 return PrevComp.getCompSrcOperandsNum();
850 }
851 unsigned getPrevCompParsedSrcNum() const {
852 return PrevComp.getCompParsedSrcOperandsNum();
853 }
854 unsigned getPrevCompVOPD3ModsNum() const {
855 return PrevComp.getCompVOPD3ModsNum();
856 }
857};
858
859// Layout and properties of VOPD components.
861public:
862 // Create ComponentInfo for COMPONENT_X or SINGLE component.
865 bool VOP3Layout = false)
866 : ComponentProps(OpDesc, VOP3Layout),
868
869 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
870 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps,
871 bool VOP3Layout = false)
872 : ComponentProps(OpDesc, VOP3Layout),
875
876 // Map component operand index to parsed operand index.
877 // Return 0 if the specified operand does not exist.
878 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
879};
880
881// Properties of VOPD instructions.
882class InstInfo {
883private:
884 const ComponentInfo CompInfo[COMPONENTS_NUM];
885
886public:
887 using RegIndices = std::array<MCRegister, Component::MAX_OPR_NUM>;
888
889 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
890 : CompInfo{OpX, OpY} {}
891
892 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
893 : CompInfo{OprInfoX, OprInfoY} {}
894
895 const ComponentInfo &operator[](size_t ComponentIdx) const {
896 assert(ComponentIdx < COMPONENTS_NUM);
897 return CompInfo[ComponentIdx];
898 }
899
900 // Check VOPD operands constraints.
901 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
902 // for the specified component and MC operand. The callback must return 0
903 // if the operand is not a register or not a VGPR.
904 // If \p SkipSrc is set to true then constraints for source operands are not
905 // checked.
906 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
907 // even though it violates requirement to be from different banks.
908 // If \p VOPD3 is set to true both dst registers allowed to be either odd
909 // or even and instruction may have real src2 as opposed to tied accumulator.
910 bool
911 hasInvalidOperand(std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
912 const MCRegisterInfo &MRI, bool SkipSrc = false,
913 bool AllowSameVGPR = false, bool VOPD3 = false) const {
914 return getInvalidCompOperandIndex(GetRegIdx, MRI, SkipSrc, AllowSameVGPR,
915 VOPD3)
916 .has_value();
917 }
918
919 // Check VOPD operands constraints.
920 // Return the index of an invalid component operand, if any.
921 // If \p SkipSrc is set to true then constraints for source operands are not
922 // checked except for being from the same halves of VGPR file on gfx1250.
923 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
924 // even though it violates requirement to be from different banks.
925 // If \p VOPD3 is set to true both dst registers allowed to be either odd
926 // or even and instruction may have real src2 as opposed to tied accumulator.
927 std::optional<unsigned> getInvalidCompOperandIndex(
928 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
929 const MCRegisterInfo &MRI, bool SkipSrc = false,
930 bool AllowSameVGPR = false, bool VOPD3 = false) const;
931
932private:
934 getRegIndices(unsigned ComponentIdx,
935 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
936 bool VOPD3) const;
937};
938
939} // namespace VOPD
940
942std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
943
945// Get properties of 2 single VOP1/VOP2 instructions
946// used as components to create a VOPD instruction.
947VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
948
950// Get properties of VOPD X and Y components.
951VOPD::InstInfo getVOPDInstInfo(unsigned VOPDOpcode,
952 const MCInstrInfo *InstrInfo);
953
955bool isAsyncStore(unsigned Opc);
957bool isTensorStore(unsigned Opc);
959unsigned getTemporalHintType(const MCInstrDesc TID);
960
962bool isTrue16Inst(unsigned Opc);
963
965FPType getFPDstSelType(unsigned Opc);
966
967bool isDPMACCInstruction(unsigned Opc);
968
970unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
971
973unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
974
975void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &Header,
976 const MCSubtargetInfo &STI);
977
978bool isGroupSegment(const GlobalValue *GV);
979bool isGlobalSegment(const GlobalValue *GV);
980bool isReadOnlySegment(const GlobalValue *GV);
981
982/// \returns True if constants should be emitted to .text section for given
983/// target triple \p TT, false otherwise.
985
986/// Returns a valid charcode or 0 in the first entry if this is a valid physical
987/// register name. Followed by the start register number, and the register
988/// width. Does not validate the number of registers exists in the class. Unlike
989/// parseAsmConstraintPhysReg, this does not expect the name to be wrapped in
990/// "{}".
991std::tuple<char, unsigned, unsigned> parseAsmPhysRegName(StringRef TupleString);
992
993/// Returns a valid charcode or 0 in the first entry if this is a valid physical
994/// register constraint. Followed by the start register number, and the register
995/// width. Does not validate the number of registers exists in the class.
996std::tuple<char, unsigned, unsigned>
998
999/// \returns A pair of integer values requested using \p F's \p Name attribute
1000/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1001/// is false).
1002///
1003/// \returns \p Default if attribute is not present.
1004///
1005/// \returns \p Default and emits error if one of the requested values cannot be
1006/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
1007/// not present.
1008std::pair<unsigned, unsigned>
1010 std::pair<unsigned, unsigned> Default,
1011 bool OnlyFirstRequired = false);
1012
1013/// \returns A pair of integer values requested using \p F's \p Name attribute
1014/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1015/// is false).
1016///
1017/// \returns \p std::nullopt if attribute is not present.
1018///
1019/// \returns \p std::nullopt and emits error if one of the requested values
1020/// cannot be converted to integer, or \p OnlyFirstRequired is false and
1021/// "second" value is not present.
1022std::optional<std::pair<unsigned, std::optional<unsigned>>>
1024 bool OnlyFirstRequired = false);
1025
1026/// \returns Generate a vector of integer values requested using \p F's \p Name
1027/// attribute.
1028/// \returns A vector of size \p Size, with all elements set to \p DefaultVal,
1029/// if any error occurs. The corresponding error will also be emitted.
1031 unsigned Size,
1032 unsigned DefaultVal);
1033/// Similar to the function above, but returns std::nullopt if any error occurs.
1034std::optional<SmallVector<unsigned>>
1035getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size);
1036
1037/// \returns The maximum number of workgroups for the function.
1039
1040/// Checks if \p Val is inside \p MD, a !range-like metadata.
1041bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val);
1042
1043// The following methods are only meaningful on targets that support
1044// S_WAITCNT.
1045
1046/// \returns Vmcnt bit mask for given isa \p Version.
1047unsigned getVmcntBitMask(const IsaVersion &Version);
1048
1049/// \returns Expcnt bit mask for given isa \p Version.
1050unsigned getExpcntBitMask(const IsaVersion &Version);
1051
1052/// \returns Lgkmcnt bit mask for given isa \p Version.
1053unsigned getLgkmcntBitMask(const IsaVersion &Version);
1054
1055/// \returns Waitcnt bit mask for given isa \p Version.
1056unsigned getWaitcntBitMask(const IsaVersion &Version);
1057
1058/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1059unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1060
1061/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1062unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1063
1064/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1065unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1066
1067/// \returns Decoded Loadcnt from given \p Waitcnt for given isa \p Version.
1068unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt);
1069
1070/// \returns Decoded Storecnt from given \p Waitcnt for given isa \p Version.
1071unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt);
1072
1073/// \returns Decoded Dscnt from given \p Waitcnt for given isa \p Version.
1074unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt);
1075
1076/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1077/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1078/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1079/// which needs it is deprecated
1080///
1081/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1082/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1083/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1084/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1085/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1086/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1087/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1088/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1089/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1090///
1091void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt,
1092 unsigned &Expcnt, unsigned &Lgkmcnt);
1093
1094/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1095unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1096 unsigned Vmcnt);
1097
1098/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1099unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1100 unsigned Expcnt);
1101
1102/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1103unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1104 unsigned Lgkmcnt);
1105
1106/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1107/// \p Version. Should not be used on gfx12+, the instruction which needs
1108/// it is deprecated
1109///
1110/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1111/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1112/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1113/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1114/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1115/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1116/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1117/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1118/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1119/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1120///
1121/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1122/// isa \p Version.
1123///
1124unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt,
1125 unsigned Expcnt, unsigned Lgkmcnt);
1126
1127/// \returns Waitcnt with encoded \p Loadcnt and \p Dscnt for given isa \p
1128/// Version.
1129unsigned encodeLoadcntDscnt(const IsaVersion &Version, unsigned Loadcnt,
1130 unsigned Dscnt);
1131
1132/// \returns Waitcnt with encoded \p Storecnt and \p Dscnt for given isa \p
1133/// Version.
1134unsigned encodeStorecntDscnt(const IsaVersion &Version, unsigned Storecnt,
1135 unsigned Dscnt);
1136
1137// The following methods are only meaningful on targets that support
1138// S_WAIT_*CNT, introduced with gfx12.
1139
1140/// \returns Loadcnt bit mask for given isa \p Version.
1141/// Returns 0 for versions that do not support LOADcnt
1142unsigned getLoadcntBitMask(const IsaVersion &Version);
1143
1144/// \returns Samplecnt bit mask for given isa \p Version.
1145/// Returns 0 for versions that do not support SAMPLEcnt
1146unsigned getSamplecntBitMask(const IsaVersion &Version);
1147
1148/// \returns Bvhcnt bit mask for given isa \p Version.
1149/// Returns 0 for versions that do not support BVHcnt
1150unsigned getBvhcntBitMask(const IsaVersion &Version);
1151
1152/// \returns Asynccnt bit mask for given isa \p Version.
1153/// Returns 0 for versions that do not support Asynccnt
1154unsigned getAsynccntBitMask(const IsaVersion &Version);
1155
1156/// \returns Dscnt bit mask for given isa \p Version.
1157/// Returns 0 for versions that do not support DScnt
1158unsigned getDscntBitMask(const IsaVersion &Version);
1159
1160/// \returns Dscnt bit mask for given isa \p Version.
1161/// Returns 0 for versions that do not support KMcnt
1162unsigned getKmcntBitMask(const IsaVersion &Version);
1163
1164/// \returns Xcnt bit mask for given isa \p Version.
1165/// Returns 0 for versions that do not support Xcnt.
1166unsigned getXcntBitMask(const IsaVersion &Version);
1167
1168/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1169/// returns 0 for versions that do not support STOREcnt or VScnt.
1170/// STOREcnt and VScnt are the same counter, the name used
1171/// depends on the ISA version.
1172unsigned getStorecntBitMask(const IsaVersion &Version);
1173
1174namespace Hwreg {
1175
1178
1179struct HwregSize : EncodingField<15, 11, 32> {
1181 constexpr uint64_t encode() const { return Value - 1; }
1182 static ValueType decode(uint64_t Encoded) { return Encoded + 1; }
1183};
1184
1186
1187} // namespace Hwreg
1188
1189namespace DepCtr {
1190
1192int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1193 const MCSubtargetInfo &STI);
1194bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1195 const MCSubtargetInfo &STI);
1196bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1197 bool &IsDefault, const MCSubtargetInfo &STI);
1198
1199/// \returns Maximum VaVdst value that can be encoded.
1200unsigned getVaVdstBitMask();
1201
1202/// \returns Maximum VaSdst value that can be encoded.
1203unsigned getVaSdstBitMask();
1204
1205/// \returns Maximum VaSsrc value that can be encoded.
1206unsigned getVaSsrcBitMask();
1207
1208/// \returns Maximum HoldCnt value that can be encoded.
1209unsigned getHoldCntBitMask(const IsaVersion &Version);
1210
1211/// \returns Maximum VmVsrc value that can be encoded.
1212unsigned getVmVsrcBitMask();
1213
1214/// \returns Maximum VaVcc value that can be encoded.
1215unsigned getVaVccBitMask();
1216
1217/// \returns Maximum SaSdst value that can be encoded.
1218unsigned getSaSdstBitMask();
1219
1220/// \returns Decoded VaVdst from given immediate \p Encoded.
1221unsigned decodeFieldVaVdst(unsigned Encoded);
1222
1223/// \returns Decoded VmVsrc from given immediate \p Encoded.
1224unsigned decodeFieldVmVsrc(unsigned Encoded);
1225
1226/// \returns Decoded SaSdst from given immediate \p Encoded.
1227unsigned decodeFieldSaSdst(unsigned Encoded);
1228
1229/// \returns Decoded VaSdst from given immediate \p Encoded.
1230unsigned decodeFieldVaSdst(unsigned Encoded);
1231
1232/// \returns Decoded VaVcc from given immediate \p Encoded.
1233unsigned decodeFieldVaVcc(unsigned Encoded);
1234
1235/// \returns Decoded SaSrc from given immediate \p Encoded.
1236unsigned decodeFieldVaSsrc(unsigned Encoded);
1237
1238/// \returns Decoded HoldCnt from given immediate \p Encoded.
1239unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version);
1240
1241/// \returns \p VmVsrc as an encoded Depctr immediate.
1242unsigned encodeFieldVmVsrc(unsigned VmVsrc, const MCSubtargetInfo &STI);
1243
1244/// \returns \p Encoded combined with encoded \p VmVsrc.
1245unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1246
1247/// \returns \p VaVdst as an encoded Depctr immediate.
1248unsigned encodeFieldVaVdst(unsigned VaVdst, const MCSubtargetInfo &STI);
1249
1250/// \returns \p Encoded combined with encoded \p VaVdst.
1251unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1252
1253/// \returns \p SaSdst as an encoded Depctr immediate.
1254unsigned encodeFieldSaSdst(unsigned SaSdst, const MCSubtargetInfo &STI);
1255
1256/// \returns \p Encoded combined with encoded \p SaSdst.
1257unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1258
1259/// \returns \p VaSdst as an encoded Depctr immediate.
1260unsigned encodeFieldVaSdst(unsigned VaSdst, const MCSubtargetInfo &STI);
1261
1262/// \returns \p Encoded combined with encoded \p VaSdst.
1263unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1264
1265/// \returns \p VaVcc as an encoded Depctr immediate.
1266unsigned encodeFieldVaVcc(unsigned VaVcc, const MCSubtargetInfo &STI);
1267
1268/// \returns \p Encoded combined with encoded \p VaVcc.
1269unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1270
1271/// \returns \p HoldCnt as an encoded Depctr immediate.
1272unsigned encodeFieldHoldCnt(unsigned HoldCnt, const MCSubtargetInfo &STI);
1273
1274/// \returns \p Encoded combined with encoded \p HoldCnt.
1275unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt,
1276 const IsaVersion &Version);
1277
1278/// \returns \p VaSsrc as an encoded Depctr immediate.
1279unsigned encodeFieldVaSsrc(unsigned VaSsrc, const MCSubtargetInfo &STI);
1280
1281/// \returns \p Encoded combined with encoded \p VaSsrc.
1282unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc);
1283
1284} // namespace DepCtr
1285
1286namespace Exp {
1287
1288bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1289
1291unsigned getTgtId(const StringRef Name);
1292
1294bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1295
1296} // namespace Exp
1297
1298namespace MTBUFFormat {
1299
1301int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1302
1303void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1304
1305int64_t getDfmt(const StringRef Name);
1306
1307StringRef getDfmtName(unsigned Id);
1308
1309int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1310
1311StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1312
1313bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1314
1315bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1316
1317int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1318
1319StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1320
1321bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1322
1323int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1324 const MCSubtargetInfo &STI);
1325
1326bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1327
1328unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1329
1330} // namespace MTBUFFormat
1331
1332namespace SendMsg {
1333
1335bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1336
1338bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1339 bool Strict = true);
1340
1342bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1343 const MCSubtargetInfo &STI, bool Strict = true);
1344
1346bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1347
1349bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1350
1351void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1352 uint16_t &StreamId, const MCSubtargetInfo &STI);
1353
1355uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId);
1356
1357/// Returns true if the message does not use the m0 operand.
1358bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI);
1359
1360} // namespace SendMsg
1361
1362unsigned getInitialPSInputAddr(const Function &F);
1363
1364bool getHasColorExport(const Function &F);
1365
1366bool getHasDepthExport(const Function &F);
1367
1368// Returns the value of the "amdgpu-dynamic-vgpr-block-size" attribute, or 0 if
1369// the attribute is missing or its value is invalid.
1370unsigned getDynamicVGPRBlockSize(const Function &F);
1371
1373constexpr bool isShader(CallingConv::ID CC) {
1374 switch (CC) {
1384 return true;
1385 default:
1386 return false;
1387 }
1388}
1389
1391constexpr bool isGraphics(CallingConv::ID CC) {
1392 return isShader(CC) || CC == CallingConv::AMDGPU_Gfx ||
1394}
1395
1397constexpr bool isCompute(CallingConv::ID CC) {
1398 return !isGraphics(CC) || CC == CallingConv::AMDGPU_CS;
1399}
1400
1403 switch (CC) {
1413 return true;
1414 default:
1415 return false;
1416 }
1417}
1418
1420constexpr bool isChainCC(CallingConv::ID CC) {
1421 switch (CC) {
1424 return true;
1425 default:
1426 return false;
1427 }
1428}
1429
1430// These functions are considered entrypoints into the current module, i.e. they
1431// are allowed to be called from outside the current module. This is different
1432// from isEntryFunctionCC, which is only true for functions that are entered by
1433// the hardware. Module entry points include all entry functions but also
1434// include functions that can be called from other functions inside or outside
1435// the current module. Module entry functions are allowed to allocate LDS.
1436//
1437// AMDGPU_CS_Chain is intended for externally callable chain functions, so it is
1438// treated as a module entrypoint. AMDGPU_CS_ChainPreserve is used for internal
1439// helper functions (e.g. retry helpers), so it is not a module entrypoint.
1442 switch (CC) {
1445 return true;
1446 default:
1447 return isEntryFunctionCC(CC);
1448 }
1449}
1450
1452constexpr inline bool isKernel(CallingConv::ID CC) {
1453 switch (CC) {
1456 return true;
1457 default:
1458 return false;
1459 }
1460}
1461
1462inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
1463
1466 return CC == CallingConv::Fast;
1467}
1468
1469/// Return true if we might ever do TCO for calls with this calling convention.
1472 switch (CC) {
1473 case CallingConv::C:
1476 return true;
1477 default:
1478 return canGuaranteeTCO(CC);
1479 }
1480}
1481
1482bool hasXNACK(const MCSubtargetInfo &STI);
1483bool hasMIMG_R128(const MCSubtargetInfo &STI);
1484bool hasA16(const MCSubtargetInfo &STI);
1485bool hasG16(const MCSubtargetInfo &STI);
1486bool hasPackedD16(const MCSubtargetInfo &STI);
1487bool hasGDS(const MCSubtargetInfo &STI);
1488unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1489unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1490
1491bool isSI(const MCSubtargetInfo &STI);
1492bool isCI(const MCSubtargetInfo &STI);
1493bool isVI(const MCSubtargetInfo &STI);
1494bool isGFX9(const MCSubtargetInfo &STI);
1495bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1496bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1497bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1498bool isGFX8Plus(const MCSubtargetInfo &STI);
1499bool isGFX9Plus(const MCSubtargetInfo &STI);
1500bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1501bool isGFX10(const MCSubtargetInfo &STI);
1502bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1503bool isGFX10Plus(const MCSubtargetInfo &STI);
1504bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1505bool isGFX10Before1030(const MCSubtargetInfo &STI);
1506bool isGFX11(const MCSubtargetInfo &STI);
1507bool isGFX11Plus(const MCSubtargetInfo &STI);
1508bool isGFX12(const MCSubtargetInfo &STI);
1509bool isGFX12Plus(const MCSubtargetInfo &STI);
1510bool isGFX1250(const MCSubtargetInfo &STI);
1511bool isGFX1250Plus(const MCSubtargetInfo &STI);
1512bool isGFX13(const MCSubtargetInfo &STI);
1513bool isGFX13Plus(const MCSubtargetInfo &STI);
1514bool supportsWGP(const MCSubtargetInfo &STI);
1515bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1516bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1517bool isGCN3Encoding(const MCSubtargetInfo &STI);
1518bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
1519bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1520bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1521bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1522bool isGFX90A(const MCSubtargetInfo &STI);
1523bool isGFX940(const MCSubtargetInfo &STI);
1525bool hasMAIInsts(const MCSubtargetInfo &STI);
1526bool hasVOPD(const MCSubtargetInfo &STI);
1527bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1528
1529inline bool supportsWave32(const MCSubtargetInfo &STI) {
1530 return AMDGPU::isGFX10Plus(STI) && !AMDGPU::isGFX1250(STI);
1531}
1532
1533int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
1534unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1536
1537/// Is Reg - scalar register
1538bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1539
1540/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1541bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI);
1542
1543/// If \p Reg is a pseudo reg, return the correct hardware register given
1544/// \p STI otherwise return \p Reg.
1546
1547/// Convert hardware register \p Reg to a pseudo register
1550
1553
1554/// Is this an AMDGPU specific source operand? These include registers,
1555/// inline constants, literals and mandatory literals (KImm).
1556constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo) {
1557 return OpInfo.OperandType >= AMDGPU::OPERAND_SRC_FIRST &&
1558 OpInfo.OperandType <= AMDGPU::OPERAND_SRC_LAST;
1559}
1560
1561inline bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo) {
1562 return isSISrcOperand(Desc.operands()[OpNo]);
1563}
1564
1565/// Is this a KImm operand?
1566bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1567
1568/// Is this floating-point operand?
1569bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1570
1571/// Does this operand support only inlinable literals?
1572bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
1573
1574/// Get the size in bits of a register from the register class \p RC.
1575unsigned getRegBitWidth(unsigned RCID);
1576
1577/// Get the size in bits of a register from the register class \p RC.
1578unsigned getRegBitWidth(const MCRegisterClass &RC);
1579
1581inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1582 switch (OpInfo.OperandType) {
1592 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1594 return 4;
1595
1604 return 8;
1605
1620 return 2;
1621
1622 default:
1623 llvm_unreachable("unhandled operand type");
1624 }
1625}
1626
1628inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
1629 return getOperandSize(Desc.operands()[OpNo]);
1630}
1631
1632/// Is this literal inlinable, and not one of the values intended for floating
1633/// point values.
1635inline bool isInlinableIntLiteral(int64_t Literal) {
1636 return Literal >= -16 && Literal <= 64;
1637}
1638
1639/// Is this literal inlinable
1641bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
1642
1644bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
1645
1647bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1648
1650bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi);
1651
1653bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi);
1654
1656std::optional<unsigned> getInlineEncodingV2I16(uint32_t Literal);
1657
1659std::optional<unsigned> getInlineEncodingV2BF16(uint32_t Literal);
1660
1662std::optional<unsigned> getInlineEncodingV2F16(uint32_t Literal);
1663
1665std::optional<unsigned> getPKFMACF16InlineEncoding(uint32_t Literal,
1666 bool IsGFX11Plus);
1667
1670
1673
1676
1679
1681bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus);
1682
1684bool isValid32BitLiteral(uint64_t Val, bool IsFP64);
1685
1687int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit);
1688
1689bool isArgPassedInSGPR(const Argument *Arg);
1690
1691bool isArgPassedInSGPR(const CallBase *CB, unsigned ArgNo);
1692
1693LLVM_READONLY bool isPackedFP32Inst(unsigned Opc);
1694
1695LLVM_READONLY bool isPacked64BitInst(unsigned Opc);
1696
1698
1701 int64_t EncodedOffset);
1702
1705 int64_t EncodedOffset, bool IsBuffer);
1706
1707/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1708/// offsets.
1710
1711/// \returns The encoding that will be used for \p ByteOffset in the
1712/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1713/// S_LOAD instructions have a signed offset, on other subtargets it is
1714/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1715std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1716 int64_t ByteOffset, bool IsBuffer,
1717 bool HasSOffset = false);
1718
1719/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1720/// instruction. This is only useful on CI.s
1721std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1722 int64_t ByteOffset);
1723
1724/// For pre-GFX12 FLAT instructions the offset must be positive;
1725/// MSB is ignored and forced to zero.
1726///
1727/// \return The number of bits available for the signed offset field in flat
1728/// instructions. Note that some forms of the instruction disallow negative
1729/// offsets.
1730unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1731
1733inline bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC) {
1734 if (isGFX12(ST))
1735 return DC >= DPP::ROW_SHARE_FIRST && DC <= DPP::ROW_SHARE_LAST;
1736 if (isGFX90A(ST))
1737 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1738 return false;
1739}
1740
1741/// \returns true if an instruction may have a 64-bit VGPR operand.
1743 const MCSubtargetInfo &ST);
1744
1745/// \returns true if an instruction is a DP ALU DPP without any 64-bit operands.
1746bool isDPALU_DPP32BitOpc(unsigned Opc);
1747
1748/// \returns true if an instruction is a DP ALU DPP.
1749bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII,
1750 const MCSubtargetInfo &ST);
1751
1752/// \returns true if the intrinsic is divergent
1753bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1754
1755/// \returns true if the intrinsic is uniform
1756bool isIntrinsicAlwaysUniform(unsigned IntrID);
1757
1758/// \returns a register class for the physical register \p Reg if it is a VGPR
1759/// or nullptr otherwise.
1761 const MCRegisterInfo &MRI);
1762
1763/// \returns the MODE bits which have to be set by the S_SET_VGPR_MSB for the
1764/// physical register \p Reg.
1765unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI);
1766
1767/// If \p Reg is a low VGPR return a corresponding high VGPR with \p MSBs set.
1769 const MCRegisterInfo &MRI);
1770
1771/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1772/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1773/// ignored.
1774std::optional<unsigned> convertSetRegImmToVgprMSBs(const MachineInstr &MI,
1775 bool HasSetregVGPRMSBFixup);
1776
1777/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1778/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1779/// ignored.
1780std::optional<unsigned> convertSetRegImmToVgprMSBs(const MCInst &MI,
1781 bool HasSetregVGPRMSBFixup);
1782
1783// Returns a table for the opcode with a given \p Desc to map the VGPR MSB
1784// set by the S_SET_VGPR_MSB to one of 4 sources. In case of VOPD returns 2
1785// maps, one for X and one for Y component.
1786std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
1788
1789/// \returns true if a memory instruction supports scale_offset modifier.
1790bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode);
1791
1792/// \returns lds block size in terms of dwords. \p
1793/// This is used to calculate the lds size encoded for PAL metadata 3.0+ which
1794/// must be defined in terms of bytes.
1795unsigned getLdsDwGranularity(const MCSubtargetInfo &ST);
1796
1798public:
1800
1801 ClusterDimsAttr() = default;
1802
1803 Kind getKind() const { return AttrKind; }
1804
1805 bool isUnknown() const { return getKind() == Kind::Unknown; }
1806
1807 bool isNoCluster() const { return getKind() == Kind::NoCluster; }
1808
1809 bool isFixedDims() const { return getKind() == Kind::FixedDims; }
1810
1811 bool isVariableDims() const { return getKind() == Kind::VariableDims; }
1812
1814
1816
1818
1819 /// \returns the dims stored. Note that this function can only be called if
1820 /// the kind is \p Fixed.
1821 const std::array<unsigned, 3> &getDims() const;
1822
1823 bool operator==(const ClusterDimsAttr &RHS) const {
1824 return AttrKind == RHS.AttrKind && Dims == RHS.Dims;
1825 }
1826
1827 std::string to_string() const;
1828
1829 static ClusterDimsAttr get(const Function &F);
1830
1831private:
1832 enum Encoding { EncoNoCluster = 0, EncoVariableDims = 1024 };
1833
1834 ClusterDimsAttr(Kind AttrKind) : AttrKind(AttrKind) {}
1835
1836 std::array<unsigned, 3> Dims = {0, 0, 0};
1837
1838 Kind AttrKind = Kind::Unknown;
1839};
1840
1841} // namespace AMDGPU
1842
1844
1845} // end namespace llvm
1846
1847#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
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:317
#define LLVM_READONLY
Definition Compiler.h:324
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
Register Reg
Register const TargetRegisterInfo * TRI
This file contains some functions that are useful when dealing with strings.
Value * RHS
static ClusterDimsAttr get(const Function &F)
bool operator==(const ClusterDimsAttr &RHS) const
const std::array< unsigned, 3 > & getDims() 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
std::optional< unsigned > getInvalidCompOperandIndex(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false) const
InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
bool hasInvalidOperand(std::function< MCRegister(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< MCRegister, Component::MAX_OPR_NUM > RegIndices
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...
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
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:86
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:41
Generic base class for all target subtargets.
Metadata node.
Definition Metadata.h:1069
Representation of each machine instruction.
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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:46
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 decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version)
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt, const IsaVersion &Version)
unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc)
unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst)
unsigned decodeFieldSaSdst(unsigned Encoded)
unsigned getHoldCntBitMask(const IsaVersion &Version)
unsigned decodeFieldVaSdst(unsigned Encoded)
unsigned 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)
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 GFX12_5
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
static constexpr unsigned GFX13
static constexpr unsigned GFX11_7
EncodingField< 10, 6 > HwregOffset
EncodingField< 5, 0 > HwregId
EncodingFields< HwregId, HwregOffset, HwregSize > HwregEncoding
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize)
unsigned getSGPRAllocGranule(const MCSubtargetInfo &STI)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo &STI)
bool isSGPROccupancyLimited(const MCSubtargetInfo &STI)
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
unsigned getEUsPerCU(const MCSubtargetInfo &STI)
unsigned getTotalNumSGPRs(const MCSubtargetInfo &STI)
unsigned getAddressableNumSGPRs(const MCSubtargetInfo &STI)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo &STI)
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, std::optional< bool > EnableWavefrontSize32)
unsigned getEncodedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU)
unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, bool Addressable)
unsigned getWavefrontSize(const MCSubtargetInfo &STI)
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getInstCacheLineSize(const MCSubtargetInfo &STI)
constexpr unsigned getMaxFlatWorkGroupSize()
static constexpr unsigned MaxDynamicVGPRBlocks
Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI)
unsigned getTotalNumVGPRs(const MCSubtargetInfo &STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize)
unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, unsigned TotalNumSGPRs, unsigned Granule, unsigned TrapReserve)
unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs)
unsigned getMaxWavesPerEU(const MCSubtargetInfo &STI)
unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
unsigned getLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getMinWavesPerEU(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 msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI)
Returns true if the message does not use the m0 operand.
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 isInlineValue(MCRegister Reg)
bool isGFX10_GFX11(const MCSubtargetInfo &STI)
bool isInlinableLiteralV216(uint32_t Literal, uint8_t OpType)
EncodingField< Bit, Bit, D > EncodingBit
bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus)
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi)
bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST, uint64_t ByteOffset)
Convert ByteOffset to dwords if the subtarget uses dword SMRD immediate offsets.
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)
static std::optional< unsigned > convertSetRegImmToVgprMSBs(unsigned Imm, unsigned Simm16, bool HasSetregVGPRMSBFixup)
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)
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo &STI)
bool shouldEmitConstantsToTextSection(const Triple &TT)
bool isInlinableLiteralV2I16(uint32_t Literal)
bool isDPMACCInstruction(unsigned Opc)
int getMTBUFElements(unsigned Opc)
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)
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)
const MCRegisterClass * getVGPRPhysRegClass(MCRegister Reg, const MCRegisterInfo &MRI)
LLVM_READNONE constexpr bool isModuleEntryFunctionCC(CallingConv::ID CC)
unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool getHasMatrixScale(unsigned Opc)
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)
bool getSMEMIsBuffer(unsigned Opc)
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
bool isGFX13(const MCSubtargetInfo &STI)
unsigned getAsynccntBitMask(const IsaVersion &Version)
bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val)
Checks if Val is inside MD, a !range-like metadata.
TargetID createAMDGPUTargetID(const MCSubtargetInfo &STI, StringRef FeatureString)
Construct TargetID from MCSubtargetInfo.
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
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)
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)
Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded)
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 encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded)
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 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)
unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI)
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)
unsigned getKmcntBitMask(const IsaVersion &Version)
MCRegister getVGPRWithMSBs(MCRegister Reg, unsigned MSBs, const MCRegisterInfo &MRI)
If Reg is a low VGPR return a corresponding high VGPR with MSBs set.
unsigned getVmcntBitMask(const IsaVersion &Version)
bool isNotGFX10Plus(const MCSubtargetInfo &STI)
bool hasMAIInsts(const MCSubtargetInfo &STI)
unsigned getBitOp2(unsigned Opc)
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
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)
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)
unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt)
std::pair< const AMDGPU::OpName *, const AMDGPU::OpName * > getVGPRLoweringOperandTables(const MCInstrDesc &Desc)
bool hasG16(const MCSubtargetInfo &STI)
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode, const MIMGDimInfo *Dim, bool IsA16, bool IsG16Supported)
int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool isGFX13Plus(const MCSubtargetInfo &STI)
unsigned getExpcntBitMask(const IsaVersion &Version)
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI)
int32_t getMCOpcode(uint32_t Opcode, unsigned Gen)
bool getMUBUFHasSoffset(unsigned Opc)
bool isNotGFX11Plus(const MCSubtargetInfo &STI)
bool isGFX11Plus(const MCSubtargetInfo &STI)
std::optional< unsigned > getInlineEncodingV2F16(uint32_t Literal)
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
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 isPackedFP32or64BitInst(unsigned Opc)
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)
SmallVector< unsigned > getMaxNumWorkGroups(const Function &F)
int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit)
bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale, unsigned BFmt, unsigned BScale)
@ OPERAND_REG_IMM_V2FP64
Definition SIDefines.h:433
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:451
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:419
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:426
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:442
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:439
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:444
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:429
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:428
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:423
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:418
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:425
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:424
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:427
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:436
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:430
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:422
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:445
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:456
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:457
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:431
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:421
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:441
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:437
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:443
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:432
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:458
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:440
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:420
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:448
std::optional< unsigned > getPKFMACF16InlineEncoding(uint32_t Literal, bool IsGFX11Plus)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
LLVM_READONLY int32_t getSOPPWithRelaxation(uint32_t Opcode)
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)
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.
unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool isGFX1250(const MCSubtargetInfo &STI)
bool supportsWave32(const MCSubtargetInfo &STI)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
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 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)
bool isPacked64BitInst(unsigned Opc)
LLVM_READNONE constexpr bool isChainCC(CallingConv::ID CC)
unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt)
bool isGFX1250Plus(const MCSubtargetInfo &STI)
LLVM_READONLY StringRef getMIMGDimInfoStr(StringTable::Offset)
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 decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getMultigridSyncArgImplicitArgPosition(unsigned CodeObjectVersion)
bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI)
bool isGFX9_GFX10(const MCSubtargetInfo &STI)
int getMUBUFElements(unsigned Opc)
const GcnBufferFormatInfo * getGcnBufferFormatInfo(uint8_t BitsPerComp, uint8_t NumComponents, uint8_t NumFormat, const MCSubtargetInfo &STI)
unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc)
bool isPermlane16(unsigned Opc)
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:573
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Definition MathExtras.h:207
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
Op::Description Desc
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
@ Default
The result value is 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)
Instruction set architecture version.
StringTable::Offset AsmSuffix