LLVM 24.0.0git
AMDGPUBaseInfo.h
Go to the documentation of this file.
1//===- AMDGPUBaseInfo.h - Top level definitions for AMDGPU ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
10#define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
11
12#include "AMDGPUSubtarget.h"
13#include "SIDefines.h"
14#include "llvm/ADT/APFloat.h"
17#include "llvm/IR/CallingConv.h"
18#include "llvm/IR/InstrTypes.h"
19#include "llvm/IR/Module.h"
22#include <array>
23#include <functional>
24#include <optional>
25#include <utility>
26
27// Pull in OpName enum definition and getNamedOperandIdx() declaration.
28#define GET_INSTRINFO_OPERAND_ENUM
29#include "AMDGPUGenInstrInfo.inc"
30
31namespace llvm {
32
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 GFX11_7 = 1;
62static constexpr unsigned GFX12 = 1;
63static constexpr unsigned GFX12_5 = 1;
64static constexpr unsigned GFX13 = 1;
65} // namespace GenericVersion
66
67enum { AMDHSA_COV4 = 4, AMDHSA_COV5 = 5, AMDHSA_COV6 = 6 };
68
69enum class FPType { None, FP4, FP8 };
70
71/// \returns True if \p STI is AMDHSA.
72bool isHsaAbi(const MCSubtargetInfo &STI);
73
74/// \returns Code object version from the IR module flag.
75unsigned getAMDHSACodeObjectVersion(const Module &M);
76
77/// \returns Code object version from ELF's e_ident[EI_ABIVERSION].
78unsigned getAMDHSACodeObjectVersion(unsigned ABIVersion);
79
80/// \returns The default HSA code object version. This should only be used when
81/// we lack a more accurate CodeObjectVersion value (e.g. from the IR module
82/// flag or a .amdhsa_code_object_version directive)
84
85/// \returns ABIVersion suitable for use in ELF's e_ident[EI_ABIVERSION]. \param
86/// CodeObjectVersion is a value returned by getAMDHSACodeObjectVersion().
87uint8_t getELFABIVersion(const Triple &OS, unsigned CodeObjectVersion);
88
89/// \returns The offset of the multigrid_sync_arg argument from implicitarg_ptr
90unsigned getMultigridSyncArgImplicitArgPosition(unsigned COV);
91
92/// \returns The offset of the hostcall pointer argument from implicitarg_ptr
93unsigned getHostcallImplicitArgPosition(unsigned COV);
94
95unsigned getDefaultQueueImplicitArgPosition(unsigned COV);
96unsigned getCompletionActionImplicitArgPosition(unsigned COV);
97
99 unsigned Format;
100 unsigned BitsPerComp;
102 unsigned NumFormat;
103 unsigned DataFormat;
104};
105
106/// Normalized MFMA or SMFMAC family, selects co-execution rules.
127
132
139
140/// Normalized WMMA or SWMMAC family used to select co-execution rules.
151
153 unsigned T16Op;
154 unsigned HiOp;
155 unsigned LoOp;
156};
157
164
165#define GET_MIMGBaseOpcode_DECL
166#define GET_MIMGDim_DECL
167#define GET_MIMGEncoding_DECL
168#define GET_MIMGLZMapping_DECL
169#define GET_MIMGMIPMapping_DECL
170#define GET_MIMGBiASMapping_DECL
171#define GET_MAIInstInfoTable_DECL
172#define GET_isMFMA_F8F6F4Table_DECL
173#define GET_isCvtScaleF32_F32F16ToF8F4Table_DECL
174#define GET_True16D16Table_DECL
175#define GET_WMMAInstInfoTable_DECL
176#include "AMDGPUGenSearchableTables.inc"
177
180
181/// Construct TargetID from MCSubtargetInfo. \p FeatureString is used to
182/// determine explicitly requested xnack/sramecc settings.
184 StringRef FeatureString);
185
186namespace IsaInfo {
187
188enum {
191};
192
193/// Returns true if \p Lhs and \p Rhs are incompatible (both specific but
194/// different).
196 return Lhs != TargetIDSetting::Any && Rhs != TargetIDSetting::Any &&
197 Lhs != Rhs;
198}
199
200/// \returns Instruction cache line size in bytes for given subtarget \p STI.
201unsigned getInstCacheLineSize(const MCSubtargetInfo &STI);
202
203/// \returns Wavefront size for given subtarget \p STI.
204unsigned getWavefrontSize(const MCSubtargetInfo &STI);
205
206/// \returns Local memory size in bytes for given subtarget \p STI.
207unsigned getLocalMemorySize(const MCSubtargetInfo &STI);
208
209/// \returns Maximum addressable local memory size in bytes for given subtarget
210/// \p STI.
212
213/// \returns Maximum number of work groups per compute unit for given subtarget
214/// \p STI and limited by given \p FlatWorkGroupSize.
215unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI,
216 unsigned FlatWorkGroupSize);
217
218/// \returns Number of waves per execution unit required to support the given \p
219/// FlatWorkGroupSize.
221 unsigned FlatWorkGroupSize);
222
223/// \returns Number of waves per work group for given subtarget \p STI and
224/// \p FlatWorkGroupSize.
225unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI,
226 unsigned FlatWorkGroupSize);
227
228/// \returns SGPR encoding granularity for given subtarget \p STI.
229unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI);
230
231/// \returns Minimum number of SGPRs that meets the given number of waves per
232/// execution unit requirement for given subtarget \p STI.
233unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU);
234
235/// \returns Maximum number of SGPRs that meets the given number of waves per
236/// execution unit requirement for given subtarget \p STI.
237unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
238 bool Addressable);
239
240/// \returns Number of extra SGPRs implicitly required by given subtarget \p
241/// STI when the given special registers are used.
242unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed,
243 bool FlatScrUsed, bool XNACKUsed);
244
245/// \returns Number of SGPR blocks needed for given subtarget \p STI when
246/// \p NumSGPRs are used. \p NumSGPRs should already include any special
247/// register counts.
248unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs);
249
250/// \returns VGPR allocation granularity for given subtarget \p STI.
251///
252/// For subtargets which support it, \p EnableWavefrontSize32 should match
253/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
254unsigned
255getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize,
256 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
257
258/// \returns VGPR encoding granularity for given subtarget \p STI.
259///
260/// For subtargets which support it, \p EnableWavefrontSize32 should match
261/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
263 const MCSubtargetInfo &STI,
264 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
265
266/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
267/// returns the allocation granule for ArchVGPRs.
268unsigned getArchVGPRAllocGranule();
269
270/// Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
271static constexpr unsigned MaxDynamicVGPRBlocks = 8;
272
273/// \returns Addressable number of architectural VGPRs for a given subtarget \p
274/// STI.
276
277/// \returns Addressable number of VGPRs for given subtarget \p STI.
278unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI,
279 unsigned DynamicVGPRBlockSize);
280
281/// \returns Minimum number of VGPRs that meets given number of waves per
282/// execution unit requirement for given subtarget \p STI.
283unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
284 unsigned DynamicVGPRBlockSize);
285
286/// \returns Maximum number of VGPRs that meets given number of waves per
287/// execution unit requirement for given subtarget \p STI.
288unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
289 unsigned DynamicVGPRBlockSize);
290
291/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
292/// subtarget \p STI.
294 unsigned NumVGPRs,
295 unsigned DynamicVGPRBlockSize);
296
297/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
298/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
299unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
300 unsigned MaxWaves,
301 unsigned TotalNumVGPRs);
302
303/// \returns Whether allocated SGPRs can reduce occupancy on subtarget \p STI
304/// (true pre-GFX10). One named capability so callers don't test the version.
306
307/// \returns SGPR-limited occupancy (waves per EU) for subtarget \p STI: the
308/// inverse of getMaxNumSGPRs(). Unlike getMaxNumSGPRs() the budget is not
309/// clamped to the addressable count, since the allocated count callers pass in
310/// can exceed it.
311unsigned getOccupancyWithNumSGPRs(const MCSubtargetInfo &STI, unsigned SGPRs);
312
313/// \returns SGPR-limited occupancy computed from explicit budget parameters
314/// (\p MaxWaves, \p TotalNumSGPRs, \p Granule, \p TrapReserve). Subtarget-free
315/// core shared by the overload above and the occupancy MCExpr. Callers must
316/// check isSGPROccupancyLimited() first.
317unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
318 unsigned TotalNumSGPRs, unsigned Granule,
319 unsigned TrapReserve);
320
321/// \returns Number of VGPR blocks that need to be allocated for the given
322/// subtarget \p STI when \p NumVGPRs are used.
324 const MCSubtargetInfo &STI, unsigned NumVGPRs,
325 unsigned DynamicVGPRBlockSize,
326 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
327
328} // end namespace IsaInfo
329
330// Represents a field in an encoded value.
331template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
333 static_assert(HighBit >= LowBit, "Invalid bit range!");
334 static constexpr unsigned Offset = LowBit;
335 static constexpr unsigned Width = HighBit - LowBit + 1;
336
338 static_assert(Width <= sizeof(ValueType) * 8);
339 static constexpr ValueType Default = D;
340
343
344 constexpr uint64_t encode() const { return Value; }
345 static ValueType decode(uint64_t Encoded) {
346 return static_cast<ValueType>(Encoded);
347 }
348};
349
350// Represents a single bit in an encoded value.
351template <unsigned Bit, unsigned D = 0>
353
354// A helper for encoding and decoding multiple fields.
355template <typename... Fields> struct EncodingFields {
356 static constexpr uint64_t encode(Fields... Values) {
357 return ((Values.encode() << Values.Offset) | ...);
358 }
359
360 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
361 return {Fields::decode((Encoded >> Fields::Offset) &
362 maxUIntN(Fields::Width))...};
363 }
364};
365
367inline bool hasNamedOperand(uint32_t Opcode, OpName NamedIdx) {
368 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
369}
370
373
394
397
399const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
400
411
413const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
414
416
419
422
424 MIMGBaseOpcode L;
425 MIMGBaseOpcode LZ;
426};
427
429 MIMGBaseOpcode MIP;
430 MIMGBaseOpcode NONMIP;
431};
432
434 MIMGBaseOpcode Bias;
435 MIMGBaseOpcode NoBias;
436};
437
439 MIMGBaseOpcode Offset;
440 MIMGBaseOpcode NoOffset;
441};
442
444 MIMGBaseOpcode G;
445 MIMGBaseOpcode G16;
446};
447
450
452 unsigned Opcode2Addr;
453 unsigned Opcode3Addr;
454};
455
458
461
464
467
469int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
470 unsigned VDataDwords, unsigned VAddrDwords,
471 bool IndexedRsrc = false, bool IndexedSamp = false);
472
474int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
475
477unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
478 const MIMGDimInfo *Dim, bool IsA16,
479 bool IsG16Supported);
480
491
493const MIMGInfo *getMIMGInfo(unsigned Opc);
494
501
504
506const VLdStIdxOpcodeInfo *
507getVLdStIdxOpcodeInfoByKey(unsigned BitWidth, bool IsStore, bool IsGPRIdx);
508
510int getMTBUFBaseOpcode(unsigned Opc);
511
513int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
514
516int getMTBUFElements(unsigned Opc);
517
519bool getMTBUFHasVAddr(unsigned Opc);
520
522bool getMTBUFHasSrsrc(unsigned Opc);
523
525bool getMTBUFHasSoffset(unsigned Opc);
526
528int getMUBUFBaseOpcode(unsigned Opc);
529
531int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
532
534int getMUBUFElements(unsigned Opc);
535
537bool getMUBUFHasVAddr(unsigned Opc);
538
540bool getMUBUFHasSrsrc(unsigned Opc);
541
543bool getMUBUFHasSoffset(unsigned Opc);
544
546bool getMUBUFIsBufferInv(unsigned Opc);
547
549bool getMUBUFTfe(unsigned Opc);
550
552bool getSMEMIsBuffer(unsigned Opc);
553
555bool getVOP1IsSingle(unsigned Opc);
556
558bool getVOP2IsSingle(unsigned Opc);
559
561bool getVOP3IsSingle(unsigned Opc);
562
564bool isVOPC64DPP(unsigned Opc);
565
567bool isVOPCAsmOnly(unsigned Opc);
568
569/// Returns true if this VOP3P opcode has no op_sel_hi field, in which case
570/// those bits are encoded as zero instead of defaulting to one.
572bool hasNoOpSelHi(unsigned Opc);
573
574/// Returns true if MAI operation is a double precision GEMM.
576bool getMAIIsDGEMM(unsigned Opc);
577
579bool getMAIIsGFX940XDL(unsigned Opc);
580
582bool getWMMAIsXDL(unsigned Opc);
583
585bool getHasMatrixScale(unsigned Opc);
586
587// Get an equivalent BitOp3 for a binary logical \p Opc.
588// \returns BitOp3 modifier for the logical operation or zero.
589// Used in VOPD3 conversion.
590unsigned getBitOp2(unsigned Opc);
591
592struct CanBeVOPD {
593 bool X;
594 bool Y;
595};
596
597/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
599unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
600
602CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3);
603
605uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
606
609 unsigned BLGP,
610 unsigned F8F8Opcode);
611
614
617 unsigned FmtB,
618 unsigned F8F8Opcode);
619
620/// \return true if this combination is listed as valid.
622bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale,
623 unsigned BFmt, unsigned BScale);
624
625/// \returns the matrix_a_fmt and matrix_b_fmt operands of an f8f6f4 WMMA.
626/// Works on both MCInst and MachineInstr.
627template <typename InstT>
628std::pair<unsigned, unsigned> getWMMAMatrixFmts(const InstT &MI) {
629 unsigned Opc = MI.getOpcode();
630 int AIdx = getNamedOperandIdx(Opc, OpName::matrix_a_fmt);
631 int BIdx = getNamedOperandIdx(Opc, OpName::matrix_b_fmt);
632 assert(AIdx != -1 && BIdx != -1 && "expected an f8f6f4 WMMA");
633 return {static_cast<unsigned>(MI.getOperand(AIdx).getImm()),
634 static_cast<unsigned>(MI.getOperand(BIdx).getImm())};
635}
636
637/// \returns true if either matrix input of an f8f6f4 WMMA is f8.
638template <typename InstT> bool isWMMAAnyF8(const InstT &MI) {
639 auto [AFmt, BFmt] = getWMMAMatrixFmts(MI);
640 return AFmt <= WMMA::MATRIX_FMT_BF8 || BFmt <= WMMA::MATRIX_FMT_BF8;
641}
642
643/// \returns true if both matrix inputs of an f8f6f4 WMMA are f4.
644template <typename InstT> bool isWMMABothF4(const InstT &MI) {
645 auto [AFmt, BFmt] = getWMMAMatrixFmts(MI);
646 return AFmt == WMMA::MATRIX_FMT_FP4 && BFmt == WMMA::MATRIX_FMT_FP4;
647}
648
650const GcnBufferFormatInfo *getGcnBufferFormatInfo(uint8_t BitsPerComp,
651 uint8_t NumComponents,
652 uint8_t NumFormat,
653 const MCSubtargetInfo &STI);
655const GcnBufferFormatInfo *getGcnBufferFormatInfo(uint8_t Format,
656 const MCSubtargetInfo &STI);
657
659int32_t getMCOpcode(uint32_t Opcode, unsigned Gen);
660
662unsigned getVOPDOpcode(unsigned Opc, bool VOPD3);
663
665int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily,
666 bool VOPD3);
667
669bool isVOPD(unsigned Opc);
670
672bool isMAC(unsigned Opc);
673
675bool isPermlane16(unsigned Opc);
676
678bool isGenericAtomic(unsigned Opc);
679
681bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
682
683namespace VOPD {
684
695
696// LSB mask for VGPR banks per VOPD component operand.
697// 4 banks result in a mask 3, setting 2 lower bits.
698constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
699constexpr unsigned VOPD3_VGPR_BANK_MASKS[] = {1, 3, 3, 3};
700// GFX11 VOPD interlock hazard requires SRC0/SRC1 to have
701// different parities, not just on different banks. Else,
702// non-deterministic forwarding error may occur.
703constexpr unsigned VOPD_GFX11_VGPR_BANK_MASKS[] = {1, 1, 1, 1};
704
705enum ComponentIndex : unsigned { X = 0, Y = 1 };
707constexpr unsigned COMPONENTS_NUM = 2;
708
709// Properties of VOPD components.
711private:
712 unsigned SrcOperandsNum = 0;
713 unsigned MandatoryLiteralIdx = ~0u;
714 bool HasSrc2Acc = false;
715 unsigned NumVOPD3Mods = 0;
716 unsigned Opcode = 0;
717 bool IsVOP3 = false;
718
719public:
720 ComponentProps() = default;
721 ComponentProps(const MCInstrDesc &OpDesc, bool VOP3Layout = false);
722
723 // Return the total number of src operands this component has.
724 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
725
726 // Return the number of src operands of this component visible to the parser.
728 return SrcOperandsNum - HasSrc2Acc;
729 }
730
731 // Return true iif this component has a mandatory literal.
732 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
733
734 // If this component has a mandatory literal, return component operand
735 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
738 return MandatoryLiteralIdx;
739 }
740
741 // Return true iif this component has operand
742 // with component index CompSrcIdx and this operand may be a register.
743 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
744 assert(CompSrcIdx < Component::MAX_SRC_NUM);
745 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
746 }
747
748 // Return true iif this component has tied src2.
749 bool hasSrc2Acc() const { return HasSrc2Acc; }
750
751 // Return a number of source modifiers if instruction is used in VOPD3.
752 unsigned getCompVOPD3ModsNum() const { return NumVOPD3Mods; }
753
754 // Return opcode of the component.
755 unsigned getOpcode() const { return Opcode; }
756
757 // Returns if component opcode is in VOP3 encoding.
758 unsigned isVOP3() const { return IsVOP3; }
759
760 // Return index of BitOp3 operand or -1.
761 int getBitOp3OperandIdx() const;
762
763private:
764 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
765 assert(CompSrcIdx < Component::MAX_SRC_NUM);
766 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
767 }
768};
769
770enum ComponentKind : unsigned {
771 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
772 COMPONENT_X, // A VOPD instruction, X component.
773 COMPONENT_Y, // A VOPD instruction, Y component.
775};
776
777// Interface functions of this class map VOPD component operand indices
778// to indices of operands in MachineInstr/MCInst or parsed operands array.
779//
780// Note that this class operates with 3 kinds of indices:
781// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
782// - MC operand indices (they refer operands in a MachineInstr/MCInst);
783// - parsed operand indices (they refer operands in parsed operands array).
784//
785// For SINGLE components mapping between these indices is trivial.
786// But things get more complicated for COMPONENT_X and
787// COMPONENT_Y because these components share the same
788// MachineInstr/MCInst and the same parsed operands array.
789// Below is an example of component operand to parsed operand
790// mapping for the following instruction:
791//
792// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
793//
794// PARSED COMPONENT PARSED
795// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
796// -------------------------------------------------------------------
797// "v_dual_add_f32" 0
798// v_dual_add_f32 v255 0 (DST) --> 1
799// v4 1 (SRC0) --> 2
800// v5 2 (SRC1) --> 3
801// "::" 4
802// "v_dual_mov_b32" 5
803// v_dual_mov_b32 v6 0 (DST) --> 6
804// v1 1 (SRC0) --> 7
805// -------------------------------------------------------------------
806//
808private:
809 // Regular MachineInstr/MCInst operands are ordered as follows:
810 // dst, src0 [, other src operands]
811 // VOPD MachineInstr/MCInst operands are ordered as follows:
812 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
813 // Each ComponentKind has operand indices defined below.
814 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
815
816 // VOPD3 instructions may have 2 or 3 source modifiers, src2 modifier is not
817 // used if there is tied accumulator. Indexing of this array:
818 // MC_SRC_IDX[VOPD3ModsNum][SrcNo]. This returns an index for a SINGLE
819 // instruction layout, add 1 for COMPONENT_X or COMPONENT_Y. For the second
820 // component add OpX.MCSrcNum + OpX.VOPD3ModsNum.
821 // For VOPD1/VOPD2 use column with zero modifiers.
822 static constexpr unsigned SINGLE_MC_SRC_IDX[4][3] = {
823 {1, 2, 3}, {2, 3, 4}, {2, 4, 5}, {2, 4, 6}};
824
825 // Parsed operands of regular instructions are ordered as follows:
826 // Mnemo dst src0 [vsrc1 ...]
827 // Parsed VOPD operands are ordered as follows:
828 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
829 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
830 // Each ComponentKind has operand indices defined below.
831 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
832 4 /* + OpX.ParsedSrcNum */};
833 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
834 2, 2, 5 /* + OpX.ParsedSrcNum */};
835
836private:
837 const ComponentKind Kind;
838 const ComponentProps PrevComp;
839 const unsigned VOPD3ModsNum;
840 const int BitOp3Idx; // Index of bitop3 operand or -1
841
842public:
843 // Create layout for COMPONENT_X or SINGLE component.
844 ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
845 : Kind(Kind), VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {
847 }
848
849 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
850 ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum,
851 int BitOp3Idx)
852 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps),
853 VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {}
854
855public:
856 // Return the index of dst operand in MCInst operands.
857 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
858
859 // Return the index of the specified src operand in MCInst operands.
860 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const {
861 assert(CompSrcIdx < Component::MAX_SRC_NUM);
862
863 if (Kind == SINGLE && CompSrcIdx == 2 && BitOp3Idx != -1)
864 return BitOp3Idx;
865
866 if (VOPD3) {
867 return SINGLE_MC_SRC_IDX[VOPD3ModsNum][CompSrcIdx] + getPrevCompSrcNum() +
868 getPrevCompVOPD3ModsNum() + (Kind != SINGLE ? 1 : 0);
869 }
870
871 return SINGLE_MC_SRC_IDX[0][CompSrcIdx] + getPrevCompSrcNum() +
872 (Kind != SINGLE ? 1 : 0);
873 }
874
875 // Return the index of dst operand in the parsed operands array.
877 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
878 }
879
880 // Return the index of the specified src operand in the parsed operands array.
881 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
882 assert(CompSrcIdx < Component::MAX_SRC_NUM);
883 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
884 }
885
886private:
887 unsigned getPrevCompSrcNum() const {
888 return PrevComp.getCompSrcOperandsNum();
889 }
890 unsigned getPrevCompParsedSrcNum() const {
891 return PrevComp.getCompParsedSrcOperandsNum();
892 }
893 unsigned getPrevCompVOPD3ModsNum() const {
894 return PrevComp.getCompVOPD3ModsNum();
895 }
896};
897
898// Layout and properties of VOPD components.
900public:
901 // Create ComponentInfo for COMPONENT_X or SINGLE component.
904 bool VOP3Layout = false)
905 : ComponentProps(OpDesc, VOP3Layout),
907
908 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
909 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps,
910 bool VOP3Layout = false)
911 : ComponentProps(OpDesc, VOP3Layout),
914
915 // Map component operand index to parsed operand index.
916 // Return 0 if the specified operand does not exist.
917 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
918};
919
920// Properties of VOPD instructions.
921class InstInfo {
922private:
923 const ComponentInfo CompInfo[COMPONENTS_NUM];
924
925public:
926 using RegIndices = std::array<MCRegister, Component::MAX_OPR_NUM>;
927
928 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
929 : CompInfo{OpX, OpY} {}
930
931 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
932 : CompInfo{OprInfoX, OprInfoY} {}
933
934 const ComponentInfo &operator[](size_t ComponentIdx) const {
935 assert(ComponentIdx < COMPONENTS_NUM);
936 return CompInfo[ComponentIdx];
937 }
938
939 // Check VOPD operands constraints.
940 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
941 // for the specified component and MC operand. The callback must return 0
942 // if the operand is not a register or not a VGPR.
943 // If \p SkipSrc is set to true then constraints for source operands are not
944 // checked.
945 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
946 // even though it violates requirement to be from different banks.
947 // If \p VOPD3 is set to true both dst registers allowed to be either odd
948 // or even and instruction may have real src2 as opposed to tied accumulator.
949 // If \p HasGFX11InterlockHazard is set then X/Y SRC0 and SRC1 VGPRs
950 // must have different register-number parity.
951 bool
952 hasInvalidOperand(std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
953 const MCRegisterInfo &MRI, bool SkipSrc = false,
954 bool AllowSameVGPR = false, bool VOPD3 = false,
955 bool HasGFX11InterlockHazard = false) const {
956 return getInvalidCompOperandIndex(GetRegIdx, MRI, SkipSrc, AllowSameVGPR,
957 VOPD3, HasGFX11InterlockHazard)
958 .has_value();
959 }
960
961 // Check VOPD operands constraints.
962 // Return the index of an invalid component operand, if any.
963 // If \p SkipSrc is set to true then constraints for source operands are not
964 // checked except for being from the same halves of VGPR file on gfx1250.
965 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
966 // even though it violates requirement to be from different banks.
967 // If \p VOPD3 is set to true both dst registers allowed to be either odd
968 // or even and instruction may have real src2 as opposed to tied accumulator.
969 // If \p HasGFX11InterlockHazard is set then X/Y SRC0 and SRC1 VGPRs
970 // must have different register-number parity.
971 std::optional<unsigned> getInvalidCompOperandIndex(
972 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
973 const MCRegisterInfo &MRI, bool SkipSrc = false,
974 bool AllowSameVGPR = false, bool VOPD3 = false,
975 bool HasGFX11InterlockHazard = false) const;
976
977private:
979 getRegIndices(unsigned ComponentIdx,
980 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
981 bool VOPD3) const;
982};
983
984} // namespace VOPD
985
987std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
988
990// Get properties of 2 single VOP1/VOP2 instructions
991// used as components to create a VOPD instruction.
992VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
993
995// Get properties of VOPD X and Y components.
996VOPD::InstInfo getVOPDInstInfo(unsigned VOPDOpcode,
997 const MCInstrInfo *InstrInfo);
998
1000bool isAsyncStore(unsigned Opc);
1002bool isTensorStore(unsigned Opc);
1004unsigned getTemporalHintType(const MCInstrDesc TID);
1005
1007bool isTrue16Inst(unsigned Opc);
1008
1010FPType getFPDstSelType(unsigned Opc);
1011
1012bool isDPMACCInstruction(unsigned Opc);
1013
1015unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
1016
1017void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &Header,
1018 const MCSubtargetInfo &STI);
1019
1020bool isReadOnlySegment(const GlobalValue *GV);
1021
1022/// \returns True if constants should be emitted to .text section for given
1023/// target triple \p TT, false otherwise.
1025
1026/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1027/// register name. Followed by the start register number, and the register
1028/// width. Does not validate the number of registers exists in the class. Unlike
1029/// parseAsmConstraintPhysReg, this does not expect the name to be wrapped in
1030/// "{}".
1031std::tuple<char, unsigned, unsigned> parseAsmPhysRegName(StringRef TupleString);
1032
1033/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1034/// register constraint. Followed by the start register number, and the register
1035/// width. Does not validate the number of registers exists in the class.
1036std::tuple<char, unsigned, unsigned>
1038
1039/// \returns A pair of integer values requested using \p F's \p Name attribute
1040/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1041/// is false).
1042///
1043/// \returns \p Default if attribute is not present.
1044///
1045/// \returns \p Default and emits error if one of the requested values cannot be
1046/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
1047/// not present.
1048std::pair<unsigned, unsigned>
1050 std::pair<unsigned, unsigned> Default,
1051 bool OnlyFirstRequired = false);
1052
1053/// \returns A pair of integer values requested using \p F's \p Name attribute
1054/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1055/// is false).
1056///
1057/// \returns \p std::nullopt if attribute is not present.
1058///
1059/// \returns \p std::nullopt and emits error if one of the requested values
1060/// cannot be converted to integer, or \p OnlyFirstRequired is false and
1061/// "second" value is not present.
1062std::optional<std::pair<unsigned, std::optional<unsigned>>>
1064 bool OnlyFirstRequired = false);
1065
1066/// \returns Generate a vector of integer values requested using \p F's \p Name
1067/// attribute.
1068/// \returns A vector of size \p Size, with all elements set to \p DefaultVal,
1069/// if any error occurs. The corresponding error will also be emitted.
1071 unsigned Size,
1072 unsigned DefaultVal);
1073/// Similar to the function above, but returns std::nullopt if any error occurs.
1074std::optional<SmallVector<unsigned>>
1075getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size);
1076
1077/// \returns The maximum number of workgroups for the function.
1079
1080inline bool isTgSplitEnabled(const Function &F) {
1081 return F.hasFnAttribute("amdgpu-tg-split");
1082}
1083
1084/// Checks if \p Val is inside \p MD, a !range-like metadata.
1085bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val);
1086
1087// The following methods are only meaningful on targets that support
1088// S_WAITCNT.
1089
1090/// \returns Vmcnt bit mask for given isa \p Version.
1091unsigned getVmcntBitMask(const IsaVersion &Version);
1092
1093/// \returns Expcnt bit mask for given isa \p Version.
1094unsigned getExpcntBitMask(const IsaVersion &Version);
1095
1096/// \returns Lgkmcnt bit mask for given isa \p Version.
1097unsigned getLgkmcntBitMask(const IsaVersion &Version);
1098
1099/// \returns Waitcnt bit mask for given isa \p Version.
1100unsigned getWaitcntBitMask(const IsaVersion &Version);
1101
1102/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1103unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1104
1105/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1106unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1107
1108/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1109unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1110
1111/// \returns Decoded Loadcnt from given \p Waitcnt for given isa \p Version.
1112unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt);
1113
1114/// \returns Decoded Storecnt from given \p Waitcnt for given isa \p Version.
1115unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt);
1116
1117/// \returns Decoded Dscnt from given \p Waitcnt for given isa \p Version.
1118unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt);
1119
1120/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1121/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1122/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1123/// which needs it is deprecated
1124///
1125/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1126/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1127/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1128/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1129/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1130/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1131/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1132/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1133/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1134///
1135void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt,
1136 unsigned &Expcnt, unsigned &Lgkmcnt);
1137
1138/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1139unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1140 unsigned Vmcnt);
1141
1142/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1143unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1144 unsigned Expcnt);
1145
1146/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1147unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1148 unsigned Lgkmcnt);
1149
1150/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1151/// \p Version. Should not be used on gfx12+, the instruction which needs
1152/// it is deprecated
1153///
1154/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1155/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1156/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1157/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1158/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1159/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1160/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1161/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1162/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1163/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1164///
1165/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1166/// isa \p Version.
1167///
1168unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt,
1169 unsigned Expcnt, unsigned Lgkmcnt);
1170
1171/// \returns Waitcnt with encoded \p Loadcnt and \p Dscnt for given isa \p
1172/// Version.
1173unsigned encodeLoadcntDscnt(const IsaVersion &Version, unsigned Loadcnt,
1174 unsigned Dscnt);
1175
1176/// \returns Waitcnt with encoded \p Storecnt and \p Dscnt for given isa \p
1177/// Version.
1178unsigned encodeStorecntDscnt(const IsaVersion &Version, unsigned Storecnt,
1179 unsigned Dscnt);
1180
1181// The following methods are only meaningful on targets that support
1182// S_WAIT_*CNT, introduced with gfx12.
1183
1184/// \returns Loadcnt bit mask for given isa \p Version.
1185/// Returns 0 for versions that do not support LOADcnt
1186unsigned getLoadcntBitMask(const IsaVersion &Version);
1187
1188/// \returns Samplecnt bit mask for given isa \p Version.
1189/// Returns 0 for versions that do not support SAMPLEcnt
1190unsigned getSamplecntBitMask(const IsaVersion &Version);
1191
1192/// \returns Bvhcnt bit mask for given isa \p Version.
1193/// Returns 0 for versions that do not support BVHcnt
1194unsigned getBvhcntBitMask(const IsaVersion &Version);
1195
1196/// \returns Asynccnt bit mask for given isa \p Version.
1197/// Returns 0 for versions that do not support Asynccnt
1198unsigned getAsynccntBitMask(const IsaVersion &Version);
1199
1200/// \returns Dscnt bit mask for given isa \p Version.
1201/// Returns 0 for versions that do not support DScnt
1202unsigned getDscntBitMask(const IsaVersion &Version);
1203
1204/// \returns Dscnt bit mask for given isa \p Version.
1205/// Returns 0 for versions that do not support KMcnt
1206unsigned getKmcntBitMask(const IsaVersion &Version);
1207
1208/// \returns Xcnt bit mask for given isa \p Version.
1209/// Returns 0 for versions that do not support Xcnt.
1210unsigned getXcntBitMask(const IsaVersion &Version);
1211
1212/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1213/// returns 0 for versions that do not support STOREcnt or VScnt.
1214/// STOREcnt and VScnt are the same counter, the name used
1215/// depends on the ISA version.
1216unsigned getStorecntBitMask(const IsaVersion &Version);
1217
1218/// \returns barrier member count bit mask in M0 for given isa \p Version.
1219unsigned getBarrierMemberCountBitMask(const IsaVersion &Version);
1220
1221namespace Hwreg {
1222
1225
1226struct HwregSize : EncodingField<15, 11, 32> {
1228 constexpr uint64_t encode() const { return Value - 1; }
1229 static ValueType decode(uint64_t Encoded) {
1230 return static_cast<ValueType>(Encoded + 1);
1231 }
1232};
1233
1235
1236} // namespace Hwreg
1237
1238namespace DepCtr {
1239
1241int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1242 const MCSubtargetInfo &STI);
1243bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1244 const MCSubtargetInfo &STI);
1245bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1246 bool &IsDefault, const MCSubtargetInfo &STI);
1247
1248/// \returns Maximum VaVdst value that can be encoded.
1249unsigned getVaVdstBitMask();
1250
1251/// \returns Maximum VaSdst value that can be encoded.
1252unsigned getVaSdstBitMask();
1253
1254/// \returns Maximum VaSsrc value that can be encoded.
1255unsigned getVaSsrcBitMask();
1256
1257/// \returns Maximum HoldCnt value that can be encoded.
1258unsigned getHoldCntBitMask(const IsaVersion &Version);
1259
1260/// \returns Maximum VmVsrc value that can be encoded.
1261unsigned getVmVsrcBitMask();
1262
1263/// \returns Maximum VaVcc value that can be encoded.
1264unsigned getVaVccBitMask();
1265
1266/// \returns Maximum SaSdst value that can be encoded.
1267unsigned getSaSdstBitMask();
1268
1269/// \returns Decoded VaVdst from given immediate \p Encoded.
1270unsigned decodeFieldVaVdst(unsigned Encoded);
1271
1272/// \returns Decoded VmVsrc from given immediate \p Encoded.
1273unsigned decodeFieldVmVsrc(unsigned Encoded);
1274
1275/// \returns Decoded SaSdst from given immediate \p Encoded.
1276unsigned decodeFieldSaSdst(unsigned Encoded);
1277
1278/// \returns Decoded VaSdst from given immediate \p Encoded.
1279unsigned decodeFieldVaSdst(unsigned Encoded);
1280
1281/// \returns Decoded VaVcc from given immediate \p Encoded.
1282unsigned decodeFieldVaVcc(unsigned Encoded);
1283
1284/// \returns Decoded SaSrc from given immediate \p Encoded.
1285unsigned decodeFieldVaSsrc(unsigned Encoded);
1286
1287/// \returns Decoded HoldCnt from given immediate \p Encoded.
1288unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version);
1289
1290/// \returns \p VmVsrc as an encoded Depctr immediate.
1291unsigned encodeFieldVmVsrc(unsigned VmVsrc, const MCSubtargetInfo &STI);
1292
1293/// \returns \p Encoded combined with encoded \p VmVsrc.
1294unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1295
1296/// \returns \p VaVdst as an encoded Depctr immediate.
1297unsigned encodeFieldVaVdst(unsigned VaVdst, const MCSubtargetInfo &STI);
1298
1299/// \returns \p Encoded combined with encoded \p VaVdst.
1300unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1301
1302/// \returns \p SaSdst as an encoded Depctr immediate.
1303unsigned encodeFieldSaSdst(unsigned SaSdst, const MCSubtargetInfo &STI);
1304
1305/// \returns \p Encoded combined with encoded \p SaSdst.
1306unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1307
1308/// \returns \p VaSdst as an encoded Depctr immediate.
1309unsigned encodeFieldVaSdst(unsigned VaSdst, const MCSubtargetInfo &STI);
1310
1311/// \returns \p Encoded combined with encoded \p VaSdst.
1312unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1313
1314/// \returns \p VaVcc as an encoded Depctr immediate.
1315unsigned encodeFieldVaVcc(unsigned VaVcc, const MCSubtargetInfo &STI);
1316
1317/// \returns \p Encoded combined with encoded \p VaVcc.
1318unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1319
1320/// \returns \p HoldCnt as an encoded Depctr immediate.
1321unsigned encodeFieldHoldCnt(unsigned HoldCnt, const MCSubtargetInfo &STI);
1322
1323/// \returns \p Encoded combined with encoded \p HoldCnt.
1324unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt,
1325 const IsaVersion &Version);
1326
1327/// \returns \p VaSsrc as an encoded Depctr immediate.
1328unsigned encodeFieldVaSsrc(unsigned VaSsrc, const MCSubtargetInfo &STI);
1329
1330/// \returns \p Encoded combined with encoded \p VaSsrc.
1331unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc);
1332
1333} // namespace DepCtr
1334
1335namespace Exp {
1336
1337bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1338
1340unsigned getTgtId(const StringRef Name);
1341
1343bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1344
1345} // namespace Exp
1346
1347namespace MTBUFFormat {
1348
1350int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1351
1352void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1353
1354int64_t getDfmt(const StringRef Name);
1355
1356StringRef getDfmtName(unsigned Id);
1357
1358int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1359
1360StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1361
1362bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1363
1364bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1365
1366int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1367
1368StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1369
1370bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1371
1372int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1373 const MCSubtargetInfo &STI);
1374
1375bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1376
1377unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1378
1379} // namespace MTBUFFormat
1380
1381namespace SendMsg {
1382
1384bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1385
1387bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1388 bool Strict = true);
1389
1391bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1392 const MCSubtargetInfo &STI, bool Strict = true);
1393
1395bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1396
1398bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1399
1400void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1401 uint16_t &StreamId, const MCSubtargetInfo &STI);
1402
1405
1406/// Returns true if the message does not use the m0 operand.
1407bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI);
1408
1409} // namespace SendMsg
1410
1411unsigned getInitialPSInputAddr(const Function &F);
1412
1413bool getHasColorExport(const Function &F);
1414
1415bool getHasDepthExport(const Function &F);
1416
1417// Returns the value of the "amdgpu-dynamic-vgpr-block-size" attribute, or 0 if
1418// the attribute is missing or its value is invalid.
1419unsigned getDynamicVGPRBlockSize(const Function &F);
1420
1422constexpr bool isShader(CallingConv::ID CC) {
1423 switch (CC) {
1433 return true;
1434 default:
1435 return false;
1436 }
1437}
1438
1444
1447 return !isGraphics(CC) || CC == CallingConv::AMDGPU_CS;
1448}
1449
1452 switch (CC) {
1462 return true;
1463 default:
1464 return false;
1465 }
1466}
1467
1470 switch (CC) {
1473 return true;
1474 default:
1475 return false;
1476 }
1477}
1478
1479// These functions are considered entrypoints into the current module, i.e. they
1480// are allowed to be called from outside the current module. This is different
1481// from isEntryFunctionCC, which is only true for functions that are entered by
1482// the hardware. Module entry points include all entry functions but also
1483// include functions that can be called from other functions inside or outside
1484// the current module. Module entry functions are allowed to allocate LDS.
1485//
1486// AMDGPU_CS_Chain is intended for externally callable chain functions, so it is
1487// treated as a module entrypoint. AMDGPU_CS_ChainPreserve is used for internal
1488// helper functions (e.g. retry helpers), so it is not a module entrypoint.
1491 switch (CC) {
1494 return true;
1495 default:
1496 return isEntryFunctionCC(CC);
1497 }
1498}
1499
1501constexpr inline bool isKernel(CallingConv::ID CC) {
1502 switch (CC) {
1505 return true;
1506 default:
1507 return false;
1508 }
1509}
1510
1511inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
1512
1515 return CC == CallingConv::Fast;
1516}
1517
1518/// Return true if we might ever do TCO for calls with this calling convention.
1521 switch (CC) {
1522 case CallingConv::C:
1525 return true;
1526 default:
1527 return canGuaranteeTCO(CC);
1528 }
1529}
1530
1531bool hasMIMG_R128(const MCSubtargetInfo &STI);
1532bool hasA16(const MCSubtargetInfo &STI);
1533bool hasG16(const MCSubtargetInfo &STI);
1534bool hasPackedD16(const MCSubtargetInfo &STI);
1535bool hasGDS(const MCSubtargetInfo &STI);
1536unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1537unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1538
1539bool isSI(const MCSubtargetInfo &STI);
1540bool isCI(const MCSubtargetInfo &STI);
1541bool isVI(const MCSubtargetInfo &STI);
1542bool isGFX9(const MCSubtargetInfo &STI);
1543bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1544bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1545bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1546bool isGFX8Plus(const MCSubtargetInfo &STI);
1547bool isGFX9Plus(const MCSubtargetInfo &STI);
1548bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1549bool isGFX10(const MCSubtargetInfo &STI);
1550bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1551bool isGFX10Plus(const MCSubtargetInfo &STI);
1552bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1553bool isGFX10Before1030(const MCSubtargetInfo &STI);
1554bool isGFX11(const MCSubtargetInfo &STI);
1555bool isGFX11Plus(const MCSubtargetInfo &STI);
1556bool isGFX12(const MCSubtargetInfo &STI);
1557bool isGFX12Plus(const MCSubtargetInfo &STI);
1558bool isGFX1250(const MCSubtargetInfo &STI);
1559bool isGFX1250Plus(const MCSubtargetInfo &STI);
1560bool isGFX13(const MCSubtargetInfo &STI);
1561bool isGFX13Plus(const MCSubtargetInfo &STI);
1562
1563/// \returns true if a work-group's waves run on all four SIMD32s (one
1564/// contiguous LDS) and not just on two.
1565bool isFullSIMDMode(const MCSubtargetInfo &STI);
1566
1567bool supportsWGP(const MCSubtargetInfo &STI);
1568bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1569bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1570bool isGCN3Encoding(const MCSubtargetInfo &STI);
1571bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1572bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1573bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1574bool isGFX90A(const MCSubtargetInfo &STI);
1575bool isGFX940(const MCSubtargetInfo &STI);
1577bool hasMAIInsts(const MCSubtargetInfo &STI);
1578bool hasPopsExitingWaveID(const MCSubtargetInfo &STI);
1579
1580/// \returns true if the src_private_base and src_private_limit aperture
1581/// registers are available on \p STI. Targets with globally addressable
1582/// scratch have no private aperture and expose src_flat_scratch_base instead.
1584
1585bool hasVOPD(const MCSubtargetInfo &STI);
1586bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1587
1588uint32_t getTotalNumVGPRs(bool has90AInsts, uint32_t ArgNumAGPR,
1589 uint32_t ArgNumVGPR);
1590unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1592
1593/// Is Reg - scalar register
1594bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1595
1596/// \returns true if \p Reg is an indexed-resource index register, i.e. either a
1597/// 32-bit SGPR (uniform-indexed form) or a Lo256 VGPR (per-lane indexed form).
1599
1600/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1602
1603/// If \p Reg is a pseudo reg, return the correct hardware register given
1604/// \p STI otherwise return \p Reg.
1606
1607/// Convert hardware register \p Reg to a pseudo register
1610
1613
1614/// Is this an AMDGPU specific source operand? These include registers,
1615/// inline constants, literals and mandatory literals (KImm).
1616constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo) {
1617 return OpInfo.OperandType >= AMDGPU::OPERAND_SRC_FIRST &&
1618 OpInfo.OperandType <= AMDGPU::OPERAND_SRC_LAST;
1619}
1620
1621inline bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo) {
1622 return isSISrcOperand(Desc.operands()[OpNo]);
1623}
1624
1625/// Is this a scalar (i.e. not packed) bf16 source operand?
1626constexpr bool isBF16SrcOperand(const MCOperandInfo &OpInfo) {
1627 return OpInfo.OperandType == AMDGPU::OPERAND_REG_IMM_BF16 ||
1628 OpInfo.OperandType == AMDGPU::OPERAND_REG_INLINE_C_BF16;
1629}
1630
1631/// Is this a KImm operand?
1632bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1633
1634/// Is this floating-point operand?
1635bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1636
1637/// Get the size in bits of a register from the register class \p RC.
1638unsigned getRegBitWidth(unsigned RCID);
1639
1640/// Get the size in bits of a register from the register class \p RC.
1641unsigned getRegBitWidth(const MCRegisterClass &RC);
1642
1644inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1645 switch (OpInfo.OperandType) {
1655 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1657 return 4;
1658
1667 return 8;
1668
1684 return 2;
1685
1686 default:
1687 llvm_unreachable("unhandled operand type");
1688 }
1689}
1690
1692inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
1693 return getOperandSize(Desc.operands()[OpNo]);
1694}
1695
1696/// Is this literal inlinable, and not one of the values intended for floating
1697/// point values.
1699inline bool isInlinableIntLiteral(int64_t Literal) {
1700 return Literal >= -16 && Literal <= 64;
1701}
1702
1703/// Is this literal inlinable
1705bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
1706
1708bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
1709
1710bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi,
1711 bool *IsBF16 = nullptr);
1712
1714bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi);
1715
1717bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi);
1718
1720std::optional<unsigned> getInlineEncodingV2I16(uint32_t Literal);
1721
1723std::optional<unsigned> getInlineEncodingV2BF16(uint32_t Literal);
1724
1726std::optional<unsigned> getInlineEncodingV2F16(uint32_t Literal);
1727
1729std::optional<unsigned> getPKFMACF16InlineEncoding(uint32_t Literal,
1730 bool IsGFX11Plus);
1731
1734
1737
1740
1743
1745bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus);
1746
1748bool isValid32BitLiteral(uint64_t Val, bool IsFP64);
1749
1751int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit);
1752
1753bool isArgPassedInSGPR(const Argument *Arg);
1754
1755bool isArgPassedInSGPR(const CallBase *CB, unsigned ArgNo);
1756
1757/// The opcode is a packed fp32 instruction which only reads low 32 bits of
1758/// a scalar operand and propagates it to high channel.
1760
1761/// The opcode is a packed 64-bit instruction which only reads low 64 bits of
1762/// a scalar operand and propagates it to high channel.
1764
1765/// Packed instructions that read a single SGPR for SGPR operands, except for
1766/// 64-bit elements which read two SGPRs.
1768
1771 int64_t EncodedOffset);
1772
1775 int64_t EncodedOffset, bool IsBuffer);
1776
1777/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1778/// offsets.
1780
1781/// \returns The encoding that will be used for \p ByteOffset in the
1782/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1783/// S_LOAD instructions have a signed offset, on other subtargets it is
1784/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1785std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1786 int64_t ByteOffset, bool IsBuffer,
1787 bool HasSOffset = false);
1788
1789/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1790/// instruction. This is only useful on CI.s
1791std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1792 int64_t ByteOffset);
1793
1794/// For pre-GFX12 FLAT instructions the offset must be positive;
1795/// MSB is ignored and forced to zero.
1796///
1797/// \return The number of bits available for the signed offset field in flat
1798/// instructions. Note that some forms of the instruction disallow negative
1799/// offsets.
1800unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1801
1803inline bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC) {
1804 if (isGFX12(ST))
1805 return DC >= DPP::ROW_SHARE_FIRST && DC <= DPP::ROW_SHARE_LAST;
1806 if (isGFX90A(ST))
1807 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1808 return false;
1809}
1810
1811/// \returns true if an instruction is a DP ALU DPP without any 64-bit operands.
1812bool isDPALU_DPP32BitOpc(unsigned Opc);
1813
1814/// \returns true if an instruction is a DP ALU DPP.
1815bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII,
1816 const MCSubtargetInfo &ST);
1817
1818/// \returns true if an instruction is a VOP3 DPP REV-type where DPP applies to
1819/// src1, so it must be a VGPR even on targets with FeatureDPPSrc1SGPR.
1820bool isVOP3DPPSrc1RevOpc(const MCSubtargetInfo &STI, unsigned Opc);
1821
1822/// \returns true if the intrinsic is divergent
1823bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1824
1825/// \returns true if the intrinsic is uniform
1826bool isIntrinsicAlwaysUniform(unsigned IntrID);
1827
1828/// Return true if we can easily prove that \p V is uniform at \p CtxI.
1829bool isTriviallyUniform(const Value *V, const Instruction *CtxI);
1830
1831/// Return true if we can easily prove that use \p U is uniform.
1832bool isTriviallyUniform(const Use &U);
1833
1834/// \returns true if the intrinsic executes an LDSDMA operation
1835bool isLDSDMAIntrinsic(unsigned IntrID);
1836
1837/// \returns the index of the f32 scale argument of a V_CVT_SCALEF32_*
1838/// conversion to a narrow format, or std::nullopt for any other intrinsic.
1839/// These instructions only read the bits of the scale given by
1840/// getExponentOnlyScaleDemandedBits().
1841std::optional<unsigned> getExponentOnlyScaleArgIdx(unsigned IntrID);
1842
1843/// \returns the bits of an exponent-only scale argument that are read: the
1844/// exponent field of the f32 value.
1846 return APInt::getBitsSet(32, 23, 31);
1847}
1848
1849/// \returns a register class for the physical register \p Reg if it is a VGPR
1850/// or nullptr otherwise.
1852 const MCRegisterInfo &MRI);
1853
1854/// \returns the MODE bits which have to be set by the S_SET_VGPR_MSB for the
1855/// physical register \p Reg.
1857
1858/// If \p Reg is a low VGPR return a corresponding high VGPR with \p MSBs set.
1860 const MCRegisterInfo &MRI);
1861
1862/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1863/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1864/// ignored.
1865std::optional<unsigned> convertSetRegImmToVgprMSBs(const MachineInstr &MI,
1866 bool HasSetregVGPRMSBFixup);
1867
1868/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1869/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1870/// ignored.
1871std::optional<unsigned> convertSetRegImmToVgprMSBs(const MCInst &MI,
1872 bool HasSetregVGPRMSBFixup);
1873
1874// Returns a table for the opcode with a given \p Desc to map the VGPR MSB
1875// set by the S_SET_VGPR_MSB to one of 4 sources. In case of VOPD returns 2
1876// maps, one for X and one for Y component.
1877std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
1879
1880/// \returns true if a memory instruction supports scale_offset modifier.
1881bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode);
1882
1884public:
1886
1887 ClusterDimsAttr() = default;
1888
1889 Kind getKind() const { return AttrKind; }
1890
1891 bool isUnknown() const { return getKind() == Kind::Unknown; }
1892
1893 bool isNoCluster() const { return getKind() == Kind::NoCluster; }
1894
1895 bool isFixedDims() const { return getKind() == Kind::FixedDims; }
1896
1897 bool isVariableDims() const { return getKind() == Kind::VariableDims; }
1898
1900
1902
1903 /// \returns the dims stored. Note that this function can only be called if
1904 /// the kind is \p Fixed.
1905 const std::array<unsigned, 3> &getDims() const;
1906
1907 bool operator==(const ClusterDimsAttr &RHS) const {
1908 return AttrKind == RHS.AttrKind && Dims == RHS.Dims;
1909 }
1910
1911 std::string to_string() const;
1912
1913 static ClusterDimsAttr get(const Function &F);
1914
1915private:
1916 enum Encoding { EncoNoCluster = 0, EncoVariableDims = 1024 };
1917
1918 ClusterDimsAttr(Kind AttrKind) : AttrKind(AttrKind) {}
1919
1920 std::array<unsigned, 3> Dims = {0, 0, 0};
1921
1922 Kind AttrKind = Kind::Unknown;
1923};
1924
1925/// Evaluate the constant-folded result of v_rcp for \p Val, accounting for
1926/// the hardware's denormal flushing on f32/f64 and its approximate rounding.
1927/// Returns std::nullopt if the hardware result is not guaranteed to match the
1928/// exact reciprocal.
1929std::optional<APFloat> evaluateRcp(const APFloat &Val);
1930
1931} // namespace AMDGPU
1932
1934
1935} // end namespace llvm
1936
1937#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
uint64_t Imm
Base class for AMDGPU specific classes of TargetSubtarget.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_READNONE
Definition Compiler.h:327
#define LLVM_READONLY
Definition Compiler.h:334
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
unsigned Opc
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
Register Reg
Register const TargetRegisterInfo * TRI
RISCVCC::CondCode CC
MachineRegisterInfo & MRI
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
InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
std::optional< unsigned > getInvalidCompOperandIndex(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false, bool HasGFX11InterlockHazard=false) const
const ComponentInfo & operator[](size_t ComponentIdx) const
bool hasInvalidOperand(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false, bool HasGFX11InterlockHazard=false) const
InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
std::array< MCRegister, Component::MAX_OPR_NUM > RegIndices
Class for arbitrary precision integers.
Definition APInt.h:78
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
Definition APInt.h:254
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:187
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:88
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 and target specific virtual registers.
Definition MCRegister.h:42
Generic base class for all target subtargets.
Metadata node.
Definition Metadata.h:1087
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
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:48
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM Value Representation.
Definition Value.h:75
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 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 getAddressableLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, 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)
static constexpr unsigned MaxDynamicVGPRBlocks
Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
unsigned getSGPREncodingGranule(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 getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
bool targetIDSettingsConflict(TargetIDSetting Lhs, TargetIDSetting Rhs)
Returns true if Lhs and Rhs are incompatible (both specific but different).
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)
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 VOPD_GFX11_VGPR_BANK_MASKS[]
constexpr unsigned COMPONENTS[]
bool isGCN3Encoding(const MCSubtargetInfo &STI)
APInt getExponentOnlyScaleDemandedBits()
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)
bool getMTBUFHasSrsrc(unsigned Opc)
std::optional< int64_t > getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool getWMMAIsXDL(unsigned Opc)
uint8_t wmmaScaleF8F6F4FormatToNumRegs(unsigned Fmt)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isShader(CallingConv::ID CC)
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)
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)
bool isFullSIMDMode(const MCSubtargetInfo &STI)
bool isGFX940(const MCSubtargetInfo &STI)
std::optional< unsigned > getExponentOnlyScaleArgIdx(unsigned IntrID)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
static std::optional< unsigned > convertSetRegImmToVgprMSBs(uint64_t Imm, uint64_t Simm16, bool HasSetregVGPRMSBFixup)
bool getSMEMIsBuffer(unsigned Opc)
bool isPackedSingleSGPRFP32Inst(unsigned Opc)
The opcode is a packed fp32 instruction which only reads low 32 bits of a scalar operand and propagat...
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)
LLVM_READONLY const MIMGMIPMappingInfo * getMIMGMIPMappingInfo(unsigned MIP)
bool getMTBUFHasSoffset(unsigned Opc)
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
LLVM_ABI unsigned getTotalNumVGPRs(GPUKind AK, bool IsWave32)
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 isVOP3DPPSrc1RevOpc(const MCSubtargetInfo &STI, unsigned Opc)
bool isSI(const MCSubtargetInfo &STI)
unsigned getDefaultAMDHSACodeObjectVersion()
LLVM_READONLY const VLdStIdxOpcodeInfo * getVLdStIdxOpcodeInfoByOpcode(unsigned Opc)
bool hasPrivateApertureRegs(const MCSubtargetInfo &STI)
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)
bool isTgSplitEnabled(const Function &F)
bool getVOP3IsSingle(unsigned Opc)
bool isPackedSingleSGPR64BitInst(unsigned Opc)
The opcode is a packed 64-bit instruction which only reads low 64 bits of a scalar operand and propag...
bool isGFX9(const MCSubtargetInfo &STI)
bool isDPALU_DPP32BitOpc(unsigned Opc)
bool getVOP1IsSingle(unsigned Opc)
unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST)
LLVM_READONLY bool hasNamedOperand(uint32_t Opcode, OpName NamedIdx)
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)
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding, unsigned VDataDwords, unsigned VAddrDwords, bool IndexedRsrc, bool IndexedSamp)
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 isLDSDMAIntrinsic(unsigned IntrID)
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 hasNoOpSelHi(unsigned Opc)
Returns true if this VOP3P opcode has no op_sel_hi field, in which case those bits are encoded as zer...
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)
bool isTriviallyUniform(const Value *V, const Instruction *CtxI)
Return true if we can easily prove that V is uniform at CtxI.
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)
const VLdStIdxOpcodeInfo * getVLdStIdxOpcodeInfoByKey(unsigned BitWidth, bool IsStore, bool IsGPRIdx)
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 isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi, bool *IsBF16)
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 isWMMABothF4(const InstT &MI)
bool isNotGFX11Plus(const MCSubtargetInfo &STI)
WMMAVariant
Normalized WMMA or SWMMAC family used to select co-execution rules.
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::optional< APFloat > evaluateRcp(const APFloat &Val)
Evaluate the constant-folded result of v_rcp for Val, accounting for the hardware's denormal flushing...
std::tuple< char, unsigned, unsigned > parseAsmConstraintPhysReg(StringRef Constraint)
Returns a valid charcode or 0 in the first entry if this is a valid physical register constraint.
unsigned getHostcallImplicitArgPosition(unsigned CodeObjectVersion)
bool isGFX10Plus(const MCSubtargetInfo &STI)
std::optional< int64_t > getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset, bool IsBuffer, bool HasSOffset)
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)
MFMAVariant
Normalized MFMA or SMFMAC family, selects co-execution rules.
@ OPERAND_REG_IMM_V2FP64
Definition SIDefines.h:447
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:465
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:432
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:440
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:456
@ OPERAND_REG_IMM_NOINLINE_FP16
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:453
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:458
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:443
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:442
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:436
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:431
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:439
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:437
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:441
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:452
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:450
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:444
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:435
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:459
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:470
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:471
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:445
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:434
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:455
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:451
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:457
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:446
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:472
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:454
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:433
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:462
std::optional< unsigned > getPKFMACF16InlineEncoding(uint32_t Literal, bool IsGFX11Plus)
std::pair< unsigned, unsigned > getWMMAMatrixFmts(const InstT &MI)
constexpr bool isBF16SrcOperand(const MCOperandInfo &OpInfo)
Is this a scalar (i.e. not packed) bf16 source operand?
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)
bool isWMMAAnyF8(const InstT &MI)
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 isRsrcIndexReg(MCRegister Reg, const MCRegisterInfo &MRI)
bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc)
std::optional< unsigned > getInlineEncodingV2I16(uint32_t Literal)
unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool isGFX1250(const MCSubtargetInfo &STI)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
bool isSingleSGPRReadInst(unsigned Opc)
Packed instructions that read a single SGPR for SGPR operands, except for 64-bit elements which read ...
bool isTensorStore(unsigned Opc)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfo(unsigned DimEnum)
bool getMUBUFIsBufferInv(unsigned Opc)
bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode)
unsigned getBarrierMemberCountBitMask(const IsaVersion &Version)
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)
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)
bool hasPopsExitingWaveID(const MCSubtargetInfo &STI)
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)
bool isPermlane16(unsigned Opc)
bool getMUBUFHasSrsrc(unsigned Opc)
unsigned getDscntBitMask(const IsaVersion &Version)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ AMDGPU_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:577
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Definition MathExtras.h:208
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
Op::Description Desc
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
constexpr unsigned BitWidth
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