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