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"
19#include <array>
20#include <functional>
21#include <utility>
22
23// Pull in OpName enum definition and getNamedOperandIdx() declaration.
24#define GET_INSTRINFO_OPERAND_ENUM
25#include "AMDGPUGenInstrInfo.inc"
26
28
29namespace llvm {
30
31struct Align;
32class Argument;
33class Function;
34class GlobalValue;
35class MachineInstr;
36class MCInstrInfo;
37class MCRegisterClass;
38class MCRegisterInfo;
39class MCSubtargetInfo;
40class MDNode;
41class StringRef;
42class Triple;
43class raw_ostream;
44
45namespace AMDGPU {
46
47struct AMDGPUMCKernelCodeT;
48struct IsaVersion;
49
50/// Generic target versions emitted by this version of LLVM.
51///
52/// These numbers are incremented every time a codegen breaking change occurs
53/// within a generic family.
54namespace GenericVersion {
55static constexpr unsigned GFX9 = 1;
56static constexpr unsigned GFX9_4 = 1;
57static constexpr unsigned GFX10_1 = 1;
58static constexpr unsigned GFX10_3 = 1;
59static constexpr unsigned GFX11 = 1;
60static constexpr unsigned GFX12 = 1;
61static constexpr unsigned GFX12_5 = 1;
62} // namespace GenericVersion
63
64enum { AMDHSA_COV4 = 4, AMDHSA_COV5 = 5, AMDHSA_COV6 = 6 };
65
66enum class FPType { None, FP4, FP8 };
67
68/// \returns True if \p STI is AMDHSA.
69bool isHsaAbi(const MCSubtargetInfo &STI);
70
71/// \returns Code object version from the IR module flag.
72unsigned getAMDHSACodeObjectVersion(const Module &M);
73
74/// \returns Code object version from ELF's e_ident[EI_ABIVERSION].
75unsigned getAMDHSACodeObjectVersion(unsigned ABIVersion);
76
77/// \returns The default HSA code object version. This should only be used when
78/// we lack a more accurate CodeObjectVersion value (e.g. from the IR module
79/// flag or a .amdhsa_code_object_version directive)
81
82/// \returns ABIVersion suitable for use in ELF's e_ident[EI_ABIVERSION]. \param
83/// CodeObjectVersion is a value returned by getAMDHSACodeObjectVersion().
84uint8_t getELFABIVersion(const Triple &OS, unsigned CodeObjectVersion);
85
86/// \returns The offset of the multigrid_sync_arg argument from implicitarg_ptr
87unsigned getMultigridSyncArgImplicitArgPosition(unsigned COV);
88
89/// \returns The offset of the hostcall pointer argument from implicitarg_ptr
90unsigned getHostcallImplicitArgPosition(unsigned COV);
91
92unsigned getDefaultQueueImplicitArgPosition(unsigned COV);
93unsigned getCompletionActionImplicitArgPosition(unsigned COV);
94
96 unsigned Format;
97 unsigned BitsPerComp;
98 unsigned NumComponents;
99 unsigned NumFormat;
100 unsigned DataFormat;
101};
102
108
115
119
121 unsigned T16Op;
122 unsigned HiOp;
123 unsigned LoOp;
124};
125
131
132#define GET_MIMGBaseOpcode_DECL
133#define GET_MIMGDim_DECL
134#define GET_MIMGEncoding_DECL
135#define GET_MIMGLZMapping_DECL
136#define GET_MIMGMIPMapping_DECL
137#define GET_MIMGBiASMapping_DECL
138#define GET_MAIInstInfoTable_DECL
139#define GET_isMFMA_F8F6F4Table_DECL
140#define GET_isCvtScaleF32_F32F16ToF8F4Table_DECL
141#define GET_True16D16Table_DECL
142#define GET_WMMAInstInfoTable_DECL
143#include "AMDGPUGenSearchableTables.inc"
144
145namespace IsaInfo {
146
147enum {
148 // The closed Vulkan driver sets 96, which limits the wave count to 8 but
149 // doesn't spill SGPRs as much as when 80 is set.
152};
153
155
157private:
158 const MCSubtargetInfo &STI;
159 TargetIDSetting XnackSetting;
160 TargetIDSetting SramEccSetting;
161
162public:
163 explicit AMDGPUTargetID(const MCSubtargetInfo &STI);
164 ~AMDGPUTargetID() = default;
165
166 /// \return True if the current xnack setting is not "Unsupported".
167 bool isXnackSupported() const {
168 return XnackSetting != TargetIDSetting::Unsupported;
169 }
170
171 /// \returns True if the current xnack setting is "On" or "Any".
172 bool isXnackOnOrAny() const {
173 return XnackSetting == TargetIDSetting::On ||
174 XnackSetting == TargetIDSetting::Any;
175 }
176
177 /// \returns True if current xnack setting is "On" or "Off",
178 /// false otherwise.
183
184 /// \returns The current xnack TargetIDSetting, possible options are
185 /// "Unsupported", "Any", "Off", and "On".
186 TargetIDSetting getXnackSetting() const { return XnackSetting; }
187
188 /// Sets xnack setting to \p NewXnackSetting.
189 void setXnackSetting(TargetIDSetting NewXnackSetting) {
190 XnackSetting = NewXnackSetting;
191 }
192
193 /// \return True if the current sramecc setting is not "Unsupported".
194 bool isSramEccSupported() const {
195 return SramEccSetting != TargetIDSetting::Unsupported;
196 }
197
198 /// \returns True if the current sramecc setting is "On" or "Any".
199 bool isSramEccOnOrAny() const {
200 return SramEccSetting == TargetIDSetting::On ||
201 SramEccSetting == TargetIDSetting::Any;
202 }
203
204 /// \returns True if current sramecc setting is "On" or "Off",
205 /// false otherwise.
210
211 /// \returns The current sramecc TargetIDSetting, possible options are
212 /// "Unsupported", "Any", "Off", and "On".
213 TargetIDSetting getSramEccSetting() const { return SramEccSetting; }
214
215 /// Sets sramecc setting to \p NewSramEccSetting.
216 void setSramEccSetting(TargetIDSetting NewSramEccSetting) {
217 SramEccSetting = NewSramEccSetting;
218 }
219
222
223 /// Write string representation to \p OS
224 void print(raw_ostream &OS) const;
225
226 /// \returns String representation of an object.
227 std::string toString() const;
228};
229
231 const AMDGPUTargetID &TargetID) {
232 TargetID.print(OS);
233 return OS;
234}
235
236/// \returns Instruction cache line size in bytes for given subtarget \p STI.
237unsigned getInstCacheLineSize(const MCSubtargetInfo *STI);
238
239/// \returns Wavefront size for given subtarget \p STI.
240unsigned getWavefrontSize(const MCSubtargetInfo *STI);
241
242/// \returns Local memory size in bytes for given subtarget \p STI.
243unsigned getLocalMemorySize(const MCSubtargetInfo *STI);
244
245/// \returns Maximum addressable local memory size in bytes for given subtarget
246/// \p STI.
248
249/// \returns Number of execution units per compute unit for given subtarget \p
250/// STI.
251unsigned getEUsPerCU(const MCSubtargetInfo *STI);
252
253/// \returns Maximum number of work groups per compute unit for given subtarget
254/// \p STI and limited by given \p FlatWorkGroupSize.
255unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI,
256 unsigned FlatWorkGroupSize);
257
258/// \returns Minimum number of waves per execution unit for given subtarget \p
259/// STI.
260unsigned getMinWavesPerEU(const MCSubtargetInfo *STI);
261
262/// \returns Maximum number of waves per execution unit for given subtarget \p
263/// STI without any kind of limitation.
264unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI);
265
266/// \returns Number of waves per execution unit required to support the given \p
267/// FlatWorkGroupSize.
269 unsigned FlatWorkGroupSize);
270
271/// \returns Minimum flat work group size for given subtarget \p STI.
272unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI);
273
274/// \returns Maximum flat work group size
275constexpr unsigned getMaxFlatWorkGroupSize() {
276 // Some subtargets allow encoding 2048, but this isn't tested or supported.
277 return 1024;
278}
279
280/// \returns Number of waves per work group for given subtarget \p STI and
281/// \p FlatWorkGroupSize.
282unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI,
283 unsigned FlatWorkGroupSize);
284
285/// \returns SGPR allocation granularity for given subtarget \p STI.
286unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI);
287
288/// \returns SGPR encoding granularity for given subtarget \p STI.
289unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI);
290
291/// \returns Total number of SGPRs for given subtarget \p STI.
292unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI);
293
294/// \returns Addressable number of SGPRs for given subtarget \p STI.
295unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI);
296
297/// \returns Minimum number of SGPRs that meets the given number of waves per
298/// execution unit requirement for given subtarget \p STI.
299unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU);
300
301/// \returns Maximum number of SGPRs that meets the given number of waves per
302/// execution unit requirement for given subtarget \p STI.
303unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
304 bool Addressable);
305
306/// \returns Number of extra SGPRs implicitly required by given subtarget \p
307/// STI when the given special registers are used.
308unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
309 bool FlatScrUsed, bool XNACKUsed);
310
311/// \returns Number of extra SGPRs implicitly required by given subtarget \p
312/// STI when the given special registers are used. XNACK is inferred from
313/// \p STI.
314unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed,
315 bool FlatScrUsed);
316
317/// \returns Number of SGPR blocks needed for given subtarget \p STI when
318/// \p NumSGPRs are used. \p NumSGPRs should already include any special
319/// register counts.
320unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs);
321
322/// \returns VGPR allocation granularity for given subtarget \p STI.
323///
324/// For subtargets which support it, \p EnableWavefrontSize32 should match
325/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
326unsigned
327getVGPRAllocGranule(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize,
328 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
329
330/// \returns VGPR encoding granularity for given subtarget \p STI.
331///
332/// For subtargets which support it, \p EnableWavefrontSize32 should match
333/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
335 const MCSubtargetInfo *STI,
336 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
337
338/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
339/// returns the allocation granule for ArchVGPRs.
340unsigned getArchVGPRAllocGranule();
341
342/// \returns Total number of VGPRs for given subtarget \p STI.
343unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI);
344
345/// \returns Addressable number of architectural VGPRs for a given subtarget \p
346/// STI.
348
349/// \returns Addressable number of VGPRs for given subtarget \p STI.
350unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI,
351 unsigned DynamicVGPRBlockSize);
352
353/// \returns Minimum number of VGPRs that meets given number of waves per
354/// execution unit requirement for given subtarget \p STI.
355unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
356 unsigned DynamicVGPRBlockSize);
357
358/// \returns Maximum number of VGPRs that meets given number of waves per
359/// execution unit requirement for given subtarget \p STI.
360unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU,
361 unsigned DynamicVGPRBlockSize);
362
363/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
364/// subtarget \p STI.
366 unsigned NumVGPRs,
367 unsigned DynamicVGPRBlockSize);
368
369/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
370/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
371unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
372 unsigned MaxWaves,
373 unsigned TotalNumVGPRs);
374
375/// \returns Occupancy for a given \p SGPRs usage, \p MaxWaves possible, and \p
376/// Gen.
377unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
379
380/// \returns Number of VGPR blocks needed for given subtarget \p STI when
381/// \p NumVGPRs are used. We actually return the number of blocks -1, since
382/// that's what we encode.
383///
384/// For subtargets which support it, \p EnableWavefrontSize32 should match the
385/// ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
387 const MCSubtargetInfo *STI, unsigned NumVGPRs,
388 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
389
390/// \returns Number of VGPR blocks that need to be allocated for the given
391/// subtarget \p STI when \p NumVGPRs are used.
393 const MCSubtargetInfo *STI, unsigned NumVGPRs,
394 unsigned DynamicVGPRBlockSize,
395 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
396
397} // end namespace IsaInfo
398
399// Represents a field in an encoded value.
400template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
402 static_assert(HighBit >= LowBit, "Invalid bit range!");
403 static constexpr unsigned Offset = LowBit;
404 static constexpr unsigned Width = HighBit - LowBit + 1;
405
407 static constexpr ValueType Default = D;
408
411
412 constexpr uint64_t encode() const { return Value; }
413 static ValueType decode(uint64_t Encoded) { return Encoded; }
414};
415
416// Represents a single bit in an encoded value.
417template <unsigned Bit, unsigned D = 0>
419
420// A helper for encoding and decoding multiple fields.
421template <typename... Fields> struct EncodingFields {
422 static constexpr uint64_t encode(Fields... Values) {
423 return ((Values.encode() << Values.Offset) | ...);
424 }
425
426 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
427 return {Fields::decode((Encoded >> Fields::Offset) &
428 maxUIntN(Fields::Width))...};
429 }
430};
431
433inline bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx) {
434 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
435}
436
439
460
463
465const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
466
476
478const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
479
482
485
487 MIMGBaseOpcode L;
488 MIMGBaseOpcode LZ;
489};
490
492 MIMGBaseOpcode MIP;
493 MIMGBaseOpcode NONMIP;
494};
495
497 MIMGBaseOpcode Bias;
498 MIMGBaseOpcode NoBias;
499};
500
502 MIMGBaseOpcode Offset;
503 MIMGBaseOpcode NoOffset;
504};
505
507 MIMGBaseOpcode G;
508 MIMGBaseOpcode G16;
509};
510
513
515 unsigned Opcode2Addr;
516 unsigned Opcode3Addr;
517};
518
521
524
527
530
532int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
533 unsigned VDataDwords, unsigned VAddrDwords);
534
536int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
537
539unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
540 const MIMGDimInfo *Dim, bool IsA16,
541 bool IsG16Supported);
542
551
553const MIMGInfo *getMIMGInfo(unsigned Opc);
554
556int getMTBUFBaseOpcode(unsigned Opc);
557
559int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
560
562int getMTBUFElements(unsigned Opc);
563
565bool getMTBUFHasVAddr(unsigned Opc);
566
568bool getMTBUFHasSrsrc(unsigned Opc);
569
571bool getMTBUFHasSoffset(unsigned Opc);
572
574int getMUBUFBaseOpcode(unsigned Opc);
575
577int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
578
580int getMUBUFElements(unsigned Opc);
581
583bool getMUBUFHasVAddr(unsigned Opc);
584
586bool getMUBUFHasSrsrc(unsigned Opc);
587
589bool getMUBUFHasSoffset(unsigned Opc);
590
592bool getMUBUFIsBufferInv(unsigned Opc);
593
595bool getMUBUFTfe(unsigned Opc);
596
598bool getSMEMIsBuffer(unsigned Opc);
599
601bool getVOP1IsSingle(unsigned Opc);
602
604bool getVOP2IsSingle(unsigned Opc);
605
607bool getVOP3IsSingle(unsigned Opc);
608
610bool isVOPC64DPP(unsigned Opc);
611
613bool isVOPCAsmOnly(unsigned Opc);
614
615/// Returns true if MAI operation is a double precision GEMM.
617bool getMAIIsDGEMM(unsigned Opc);
618
620bool getMAIIsGFX940XDL(unsigned Opc);
621
623bool getWMMAIsXDL(unsigned Opc);
624
626bool getHasMatrixScale(unsigned Opc);
627
628// Get an equivalent BitOp3 for a binary logical \p Opc.
629// \returns BitOp3 modifier for the logical operation or zero.
630// Used in VOPD3 conversion.
631unsigned getBitOp2(unsigned Opc);
632
633struct CanBeVOPD {
634 bool X;
635 bool Y;
636};
637
638/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
640unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
641
643CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3);
644
646uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
647
650 unsigned BLGP,
651 unsigned F8F8Opcode);
652
655
658 unsigned FmtB,
659 unsigned F8F8Opcode);
660
663 uint8_t NumComponents,
664 uint8_t NumFormat,
665 const MCSubtargetInfo &STI);
668 const MCSubtargetInfo &STI);
669
671int32_t getMCOpcode(uint32_t Opcode, unsigned Gen);
672
674unsigned getVOPDOpcode(unsigned Opc, bool VOPD3);
675
677int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily,
678 bool VOPD3);
679
681bool isVOPD(unsigned Opc);
682
684bool isMAC(unsigned Opc);
685
687bool isPermlane16(unsigned Opc);
688
690bool isGenericAtomic(unsigned Opc);
691
693bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
694
695namespace VOPD {
696
707
708// LSB mask for VGPR banks per VOPD component operand.
709// 4 banks result in a mask 3, setting 2 lower bits.
710constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
711constexpr unsigned VOPD3_VGPR_BANK_MASKS[] = {1, 3, 3, 3};
712
713enum ComponentIndex : unsigned { X = 0, Y = 1 };
715constexpr unsigned COMPONENTS_NUM = 2;
716
717// Properties of VOPD components.
719private:
720 unsigned SrcOperandsNum = 0;
721 unsigned MandatoryLiteralIdx = ~0u;
722 bool HasSrc2Acc = false;
723 unsigned NumVOPD3Mods = 0;
724 unsigned Opcode = 0;
725 bool IsVOP3 = false;
726
727public:
728 ComponentProps() = default;
729 ComponentProps(const MCInstrDesc &OpDesc, bool VOP3Layout = false);
730
731 // Return the total number of src operands this component has.
732 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
733
734 // Return the number of src operands of this component visible to the parser.
736 return SrcOperandsNum - HasSrc2Acc;
737 }
738
739 // Return true iif this component has a mandatory literal.
740 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
741
742 // If this component has a mandatory literal, return component operand
743 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
746 return MandatoryLiteralIdx;
747 }
748
749 // Return true iif this component has operand
750 // with component index CompSrcIdx and this operand may be a register.
751 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
752 assert(CompSrcIdx < Component::MAX_SRC_NUM);
753 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
754 }
755
756 // Return true iif this component has tied src2.
757 bool hasSrc2Acc() const { return HasSrc2Acc; }
758
759 // Return a number of source modifiers if instruction is used in VOPD3.
760 unsigned getCompVOPD3ModsNum() const { return NumVOPD3Mods; }
761
762 // Return opcode of the component.
763 unsigned getOpcode() const { return Opcode; }
764
765 // Returns if component opcode is in VOP3 encoding.
766 unsigned isVOP3() const { return IsVOP3; }
767
768 // Return index of BitOp3 operand or -1.
769 int getBitOp3OperandIdx() const;
770
771private:
772 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
773 assert(CompSrcIdx < Component::MAX_SRC_NUM);
774 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
775 }
776};
777
778enum ComponentKind : unsigned {
779 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
780 COMPONENT_X, // A VOPD instruction, X component.
781 COMPONENT_Y, // A VOPD instruction, Y component.
783};
784
785// Interface functions of this class map VOPD component operand indices
786// to indices of operands in MachineInstr/MCInst or parsed operands array.
787//
788// Note that this class operates with 3 kinds of indices:
789// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
790// - MC operand indices (they refer operands in a MachineInstr/MCInst);
791// - parsed operand indices (they refer operands in parsed operands array).
792//
793// For SINGLE components mapping between these indices is trivial.
794// But things get more complicated for COMPONENT_X and
795// COMPONENT_Y because these components share the same
796// MachineInstr/MCInst and the same parsed operands array.
797// Below is an example of component operand to parsed operand
798// mapping for the following instruction:
799//
800// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
801//
802// PARSED COMPONENT PARSED
803// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
804// -------------------------------------------------------------------
805// "v_dual_add_f32" 0
806// v_dual_add_f32 v255 0 (DST) --> 1
807// v4 1 (SRC0) --> 2
808// v5 2 (SRC1) --> 3
809// "::" 4
810// "v_dual_mov_b32" 5
811// v_dual_mov_b32 v6 0 (DST) --> 6
812// v1 1 (SRC0) --> 7
813// -------------------------------------------------------------------
814//
816private:
817 // Regular MachineInstr/MCInst operands are ordered as follows:
818 // dst, src0 [, other src operands]
819 // VOPD MachineInstr/MCInst operands are ordered as follows:
820 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
821 // Each ComponentKind has operand indices defined below.
822 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
823
824 // VOPD3 instructions may have 2 or 3 source modifiers, src2 modifier is not
825 // used if there is tied accumulator. Indexing of this array:
826 // MC_SRC_IDX[VOPD3ModsNum][SrcNo]. This returns an index for a SINGLE
827 // instruction layout, add 1 for COMPONENT_X or COMPONENT_Y. For the second
828 // component add OpX.MCSrcNum + OpX.VOPD3ModsNum.
829 // For VOPD1/VOPD2 use column with zero modifiers.
830 static constexpr unsigned SINGLE_MC_SRC_IDX[4][3] = {
831 {1, 2, 3}, {2, 3, 4}, {2, 4, 5}, {2, 4, 6}};
832
833 // Parsed operands of regular instructions are ordered as follows:
834 // Mnemo dst src0 [vsrc1 ...]
835 // Parsed VOPD operands are ordered as follows:
836 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
837 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
838 // Each ComponentKind has operand indices defined below.
839 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
840 4 /* + OpX.ParsedSrcNum */};
841 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
842 2, 2, 5 /* + OpX.ParsedSrcNum */};
843
844private:
845 const ComponentKind Kind;
846 const ComponentProps PrevComp;
847 const unsigned VOPD3ModsNum;
848 const int BitOp3Idx; // Index of bitop3 operand or -1
849
850public:
851 // Create layout for COMPONENT_X or SINGLE component.
852 ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
853 : Kind(Kind), VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {
855 }
856
857 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
858 ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum,
859 int BitOp3Idx)
860 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps),
861 VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {}
862
863public:
864 // Return the index of dst operand in MCInst operands.
865 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
866
867 // Return the index of the specified src operand in MCInst operands.
868 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const {
869 assert(CompSrcIdx < Component::MAX_SRC_NUM);
870
871 if (Kind == SINGLE && CompSrcIdx == 2 && BitOp3Idx != -1)
872 return BitOp3Idx;
873
874 if (VOPD3) {
875 return SINGLE_MC_SRC_IDX[VOPD3ModsNum][CompSrcIdx] + getPrevCompSrcNum() +
876 getPrevCompVOPD3ModsNum() + (Kind != SINGLE ? 1 : 0);
877 }
878
879 return SINGLE_MC_SRC_IDX[0][CompSrcIdx] + getPrevCompSrcNum() +
880 (Kind != SINGLE ? 1 : 0);
881 }
882
883 // Return the index of dst operand in the parsed operands array.
885 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
886 }
887
888 // Return the index of the specified src operand in the parsed operands array.
889 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
890 assert(CompSrcIdx < Component::MAX_SRC_NUM);
891 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
892 }
893
894private:
895 unsigned getPrevCompSrcNum() const {
896 return PrevComp.getCompSrcOperandsNum();
897 }
898 unsigned getPrevCompParsedSrcNum() const {
899 return PrevComp.getCompParsedSrcOperandsNum();
900 }
901 unsigned getPrevCompVOPD3ModsNum() const {
902 return PrevComp.getCompVOPD3ModsNum();
903 }
904};
905
906// Layout and properties of VOPD components.
908public:
909 // Create ComponentInfo for COMPONENT_X or SINGLE component.
912 bool VOP3Layout = false)
913 : ComponentProps(OpDesc, VOP3Layout),
915
916 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
917 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps,
918 bool VOP3Layout = false)
919 : ComponentProps(OpDesc, VOP3Layout),
922
923 // Map component operand index to parsed operand index.
924 // Return 0 if the specified operand does not exist.
925 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
926};
927
928// Properties of VOPD instructions.
929class InstInfo {
930private:
931 const ComponentInfo CompInfo[COMPONENTS_NUM];
932
933public:
934 using RegIndices = std::array<MCRegister, Component::MAX_OPR_NUM>;
935
936 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
937 : CompInfo{OpX, OpY} {}
938
939 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
940 : CompInfo{OprInfoX, OprInfoY} {}
941
942 const ComponentInfo &operator[](size_t ComponentIdx) const {
943 assert(ComponentIdx < COMPONENTS_NUM);
944 return CompInfo[ComponentIdx];
945 }
946
947 // Check VOPD operands constraints.
948 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
949 // for the specified component and MC operand. The callback must return 0
950 // if the operand is not a register or not a VGPR.
951 // If \p SkipSrc is set to true then constraints for source operands are not
952 // checked.
953 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
954 // even though it violates requirement to be from different banks.
955 // If \p VOPD3 is set to true both dst registers allowed to be either odd
956 // or even and instruction may have real src2 as opposed to tied accumulator.
957 bool
958 hasInvalidOperand(std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
959 const MCRegisterInfo &MRI, bool SkipSrc = false,
960 bool AllowSameVGPR = false, bool VOPD3 = false) const {
961 return getInvalidCompOperandIndex(GetRegIdx, MRI, SkipSrc, AllowSameVGPR,
962 VOPD3)
963 .has_value();
964 }
965
966 // Check VOPD operands constraints.
967 // Return the index of an invalid component operand, if any.
968 // If \p SkipSrc is set to true then constraints for source operands are not
969 // checked except for being from the same halves of VGPR file on gfx1250.
970 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
971 // even though it violates requirement to be from different banks.
972 // If \p VOPD3 is set to true both dst registers allowed to be either odd
973 // or even and instruction may have real src2 as opposed to tied accumulator.
974 std::optional<unsigned> getInvalidCompOperandIndex(
975 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
976 const MCRegisterInfo &MRI, bool SkipSrc = false,
977 bool AllowSameVGPR = false, bool VOPD3 = false) const;
978
979private:
981 getRegIndices(unsigned ComponentIdx,
982 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
983 bool VOPD3) const;
984};
985
986} // namespace VOPD
987
989std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
990
992// Get properties of 2 single VOP1/VOP2 instructions
993// used as components to create a VOPD instruction.
994VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
995
997// Get properties of VOPD X and Y components.
998VOPD::InstInfo getVOPDInstInfo(unsigned VOPDOpcode,
999 const MCInstrInfo *InstrInfo);
1000
1002bool isAsyncStore(unsigned Opc);
1004bool isTensorStore(unsigned Opc);
1006unsigned getTemporalHintType(const MCInstrDesc TID);
1007
1009bool isTrue16Inst(unsigned Opc);
1010
1012FPType getFPDstSelType(unsigned Opc);
1013
1016
1019
1020bool isDPMACCInstruction(unsigned Opc);
1021
1023unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
1024
1026unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
1027
1029 const MCSubtargetInfo *STI);
1030
1031bool isGroupSegment(const GlobalValue *GV);
1032bool isGlobalSegment(const GlobalValue *GV);
1033bool isReadOnlySegment(const GlobalValue *GV);
1034
1035/// \returns True if constants should be emitted to .text section for given
1036/// target triple \p TT, false otherwise.
1038
1039/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1040/// register name. Followed by the start register number, and the register
1041/// width. Does not validate the number of registers exists in the class. Unlike
1042/// parseAsmConstraintPhysReg, this does not expect the name to be wrapped in
1043/// "{}".
1044std::tuple<char, unsigned, unsigned> parseAsmPhysRegName(StringRef TupleString);
1045
1046/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1047/// register constraint. Followed by the start register number, and the register
1048/// width. Does not validate the number of registers exists in the class.
1049std::tuple<char, unsigned, unsigned>
1051
1052/// \returns Integer value requested using \p F's \p Name attribute.
1053///
1054/// \returns \p Default if attribute is not present.
1055///
1056/// \returns \p Default and emits error if requested value cannot be converted
1057/// to integer.
1059
1060/// \returns A pair of integer values requested using \p F's \p Name attribute
1061/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1062/// is false).
1063///
1064/// \returns \p Default if attribute is not present.
1065///
1066/// \returns \p Default and emits error if one of the requested values cannot be
1067/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
1068/// not present.
1069std::pair<unsigned, unsigned>
1071 std::pair<unsigned, unsigned> Default,
1072 bool OnlyFirstRequired = false);
1073
1074/// \returns A pair of integer values requested using \p F's \p Name attribute
1075/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1076/// is false).
1077///
1078/// \returns \p std::nullopt if attribute is not present.
1079///
1080/// \returns \p std::nullopt and emits error if one of the requested values
1081/// cannot be converted to integer, or \p OnlyFirstRequired is false and
1082/// "second" value is not present.
1083std::optional<std::pair<unsigned, std::optional<unsigned>>>
1085 bool OnlyFirstRequired = false);
1086
1087/// \returns Generate a vector of integer values requested using \p F's \p Name
1088/// attribute.
1089/// \returns A vector of size \p Size, with all elements set to \p DefaultVal,
1090/// if any error occurs. The corresponding error will also be emitted.
1092 unsigned Size,
1093 unsigned DefaultVal);
1094/// Similar to the function above, but returns std::nullopt if any error occurs.
1095std::optional<SmallVector<unsigned>>
1096getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size);
1097
1098/// Checks if \p Val is inside \p MD, a !range-like metadata.
1099bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val);
1100
1101/// Represents the hardware counter limits for different wait count types.
1103 unsigned LoadcntMax; // Corresponds to Vmcnt prior to gfx12.
1104 unsigned ExpcntMax;
1105 unsigned DscntMax; // Corresponds to LGKMcnt prior to gfx12.
1106 unsigned StorecntMax; // Corresponds to VScnt in gfx10/gfx11.
1107 unsigned SamplecntMax; // gfx12+ only.
1108 unsigned BvhcntMax; // gfx12+ only.
1109 unsigned KmcntMax; // gfx12+ only.
1110 unsigned XcntMax; // gfx1250.
1111 unsigned AsyncMax; // gfx1250.
1112 unsigned VaVdstMax; // gfx12+ expert mode only.
1113 unsigned VmVsrcMax; // gfx12+ expert mode only.
1114
1115 HardwareLimits() = default;
1116
1117 /// Initializes hardware limits from ISA version.
1119};
1120
1121// The following methods are only meaningful on targets that support
1122// S_WAITCNT.
1123
1124/// \returns Vmcnt bit mask for given isa \p Version.
1125unsigned getVmcntBitMask(const IsaVersion &Version);
1126
1127/// \returns Expcnt bit mask for given isa \p Version.
1128unsigned getExpcntBitMask(const IsaVersion &Version);
1129
1130/// \returns Lgkmcnt bit mask for given isa \p Version.
1131unsigned getLgkmcntBitMask(const IsaVersion &Version);
1132
1133/// \returns Waitcnt bit mask for given isa \p Version.
1134unsigned getWaitcntBitMask(const IsaVersion &Version);
1135
1136/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1137unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1138
1139/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1140unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1141
1142/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1143unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1144
1145/// \returns Decoded Loadcnt from given \p Waitcnt for given isa \p Version.
1146unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt);
1147
1148/// \returns Decoded Storecnt from given \p Waitcnt for given isa \p Version.
1149unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt);
1150
1151/// \returns Decoded Dscnt from given \p Waitcnt for given isa \p Version.
1152unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt);
1153
1154/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1155/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1156/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1157/// which needs it is deprecated
1158///
1159/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1160/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1161/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1162/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1163/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1164/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1165/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1166/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1167/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1168///
1169void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt,
1170 unsigned &Expcnt, unsigned &Lgkmcnt);
1171
1172/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1173unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1174 unsigned Vmcnt);
1175
1176/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1177unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1178 unsigned Expcnt);
1179
1180/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1181unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1182 unsigned Lgkmcnt);
1183
1184/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1185/// \p Version. Should not be used on gfx12+, the instruction which needs
1186/// it is deprecated
1187///
1188/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1189/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1190/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1191/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1192/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1193/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1194/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1195/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1196/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1197/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1198///
1199/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1200/// isa \p Version.
1201///
1202unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt,
1203 unsigned Expcnt, unsigned Lgkmcnt);
1204
1205/// \returns Waitcnt with encoded \p Loadcnt and \p Dscnt for given isa \p
1206/// Version.
1207unsigned encodeLoadcntDscnt(const IsaVersion &Version, unsigned Loadcnt,
1208 unsigned Dscnt);
1209
1210/// \returns Waitcnt with encoded \p Storecnt and \p Dscnt for given isa \p
1211/// Version.
1212unsigned encodeStorecntDscnt(const IsaVersion &Version, unsigned Storecnt,
1213 unsigned Dscnt);
1214
1215// The following methods are only meaningful on targets that support
1216// S_WAIT_*CNT, introduced with gfx12.
1217
1218/// \returns Loadcnt bit mask for given isa \p Version.
1219/// Returns 0 for versions that do not support LOADcnt
1220unsigned getLoadcntBitMask(const IsaVersion &Version);
1221
1222/// \returns Samplecnt bit mask for given isa \p Version.
1223/// Returns 0 for versions that do not support SAMPLEcnt
1224unsigned getSamplecntBitMask(const IsaVersion &Version);
1225
1226/// \returns Bvhcnt bit mask for given isa \p Version.
1227/// Returns 0 for versions that do not support BVHcnt
1228unsigned getBvhcntBitMask(const IsaVersion &Version);
1229
1230/// \returns Asynccnt bit mask for given isa \p Version.
1231/// Returns 0 for versions that do not support Asynccnt
1232unsigned getAsynccntBitMask(const IsaVersion &Version);
1233
1234/// \returns Dscnt bit mask for given isa \p Version.
1235/// Returns 0 for versions that do not support DScnt
1236unsigned getDscntBitMask(const IsaVersion &Version);
1237
1238/// \returns Dscnt bit mask for given isa \p Version.
1239/// Returns 0 for versions that do not support KMcnt
1240unsigned getKmcntBitMask(const IsaVersion &Version);
1241
1242/// \returns Xcnt bit mask for given isa \p Version.
1243/// Returns 0 for versions that do not support Xcnt.
1244unsigned getXcntBitMask(const IsaVersion &Version);
1245
1246/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1247/// returns 0 for versions that do not support STOREcnt or VScnt.
1248/// STOREcnt and VScnt are the same counter, the name used
1249/// depends on the ISA version.
1250unsigned getStorecntBitMask(const IsaVersion &Version);
1251
1252namespace Hwreg {
1253
1256
1257struct HwregSize : EncodingField<15, 11, 32> {
1259 constexpr uint64_t encode() const { return Value - 1; }
1260 static ValueType decode(uint64_t Encoded) { return Encoded + 1; }
1261};
1262
1264
1265} // namespace Hwreg
1266
1267namespace DepCtr {
1268
1270int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1271 const MCSubtargetInfo &STI);
1272bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1273 const MCSubtargetInfo &STI);
1274bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1275 bool &IsDefault, const MCSubtargetInfo &STI);
1276
1277/// \returns Maximum VaVdst value that can be encoded.
1278unsigned getVaVdstBitMask();
1279
1280/// \returns Maximum VaSdst value that can be encoded.
1281unsigned getVaSdstBitMask();
1282
1283/// \returns Maximum VaSsrc value that can be encoded.
1284unsigned getVaSsrcBitMask();
1285
1286/// \returns Maximum HoldCnt value that can be encoded.
1287unsigned getHoldCntBitMask(const IsaVersion &Version);
1288
1289/// \returns Maximum VmVsrc value that can be encoded.
1290unsigned getVmVsrcBitMask();
1291
1292/// \returns Maximum VaVcc value that can be encoded.
1293unsigned getVaVccBitMask();
1294
1295/// \returns Maximum SaSdst value that can be encoded.
1296unsigned getSaSdstBitMask();
1297
1298/// \returns Decoded VaVdst from given immediate \p Encoded.
1299unsigned decodeFieldVaVdst(unsigned Encoded);
1300
1301/// \returns Decoded VmVsrc from given immediate \p Encoded.
1302unsigned decodeFieldVmVsrc(unsigned Encoded);
1303
1304/// \returns Decoded SaSdst from given immediate \p Encoded.
1305unsigned decodeFieldSaSdst(unsigned Encoded);
1306
1307/// \returns Decoded VaSdst from given immediate \p Encoded.
1308unsigned decodeFieldVaSdst(unsigned Encoded);
1309
1310/// \returns Decoded VaVcc from given immediate \p Encoded.
1311unsigned decodeFieldVaVcc(unsigned Encoded);
1312
1313/// \returns Decoded SaSrc from given immediate \p Encoded.
1314unsigned decodeFieldVaSsrc(unsigned Encoded);
1315
1316/// \returns Decoded HoldCnt from given immediate \p Encoded.
1317unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version);
1318
1319/// \returns \p VmVsrc as an encoded Depctr immediate.
1320unsigned encodeFieldVmVsrc(unsigned VmVsrc, const MCSubtargetInfo &STI);
1321
1322/// \returns \p Encoded combined with encoded \p VmVsrc.
1323unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1324
1325/// \returns \p VaVdst as an encoded Depctr immediate.
1326unsigned encodeFieldVaVdst(unsigned VaVdst, const MCSubtargetInfo &STI);
1327
1328/// \returns \p Encoded combined with encoded \p VaVdst.
1329unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1330
1331/// \returns \p SaSdst as an encoded Depctr immediate.
1332unsigned encodeFieldSaSdst(unsigned SaSdst, const MCSubtargetInfo &STI);
1333
1334/// \returns \p Encoded combined with encoded \p SaSdst.
1335unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1336
1337/// \returns \p VaSdst as an encoded Depctr immediate.
1338unsigned encodeFieldVaSdst(unsigned VaSdst, const MCSubtargetInfo &STI);
1339
1340/// \returns \p Encoded combined with encoded \p VaSdst.
1341unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1342
1343/// \returns \p VaVcc as an encoded Depctr immediate.
1344unsigned encodeFieldVaVcc(unsigned VaVcc, const MCSubtargetInfo &STI);
1345
1346/// \returns \p Encoded combined with encoded \p VaVcc.
1347unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1348
1349/// \returns \p HoldCnt as an encoded Depctr immediate.
1350unsigned encodeFieldHoldCnt(unsigned HoldCnt, const MCSubtargetInfo &STI);
1351
1352/// \returns \p Encoded combined with encoded \p HoldCnt.
1353unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt,
1354 const IsaVersion &Version);
1355
1356/// \returns \p VaSsrc as an encoded Depctr immediate.
1357unsigned encodeFieldVaSsrc(unsigned VaSsrc, const MCSubtargetInfo &STI);
1358
1359/// \returns \p Encoded combined with encoded \p VaSsrc.
1360unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc);
1361
1362} // namespace DepCtr
1363
1364namespace Exp {
1365
1366bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1367
1369unsigned getTgtId(const StringRef Name);
1370
1372bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1373
1374} // namespace Exp
1375
1376namespace MTBUFFormat {
1377
1379int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1380
1381void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1382
1383int64_t getDfmt(const StringRef Name);
1384
1385StringRef getDfmtName(unsigned Id);
1386
1387int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1388
1389StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1390
1391bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1392
1393bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1394
1395int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1396
1397StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1398
1399bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1400
1401int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1402 const MCSubtargetInfo &STI);
1403
1404bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1405
1406unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1407
1408} // namespace MTBUFFormat
1409
1410namespace SendMsg {
1411
1413bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1414
1416bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1417 bool Strict = true);
1418
1420bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1421 const MCSubtargetInfo &STI, bool Strict = true);
1422
1424bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1425
1427bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1428
1429void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1430 uint16_t &StreamId, const MCSubtargetInfo &STI);
1431
1433uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId);
1434
1435/// Returns true if the message does not use the m0 operand.
1436bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI);
1437
1438} // namespace SendMsg
1439
1440unsigned getInitialPSInputAddr(const Function &F);
1441
1442bool getHasColorExport(const Function &F);
1443
1444bool getHasDepthExport(const Function &F);
1445
1447
1448// Returns the value of the "amdgpu-dynamic-vgpr-block-size" attribute, or 0 if
1449// the attribute is missing or its value is invalid.
1450unsigned getDynamicVGPRBlockSize(const Function &F);
1451
1453constexpr bool isShader(CallingConv::ID CC) {
1454 switch (CC) {
1464 return true;
1465 default:
1466 return false;
1467 }
1468}
1469
1471constexpr bool isGraphics(CallingConv::ID CC) {
1472 return isShader(CC) || CC == CallingConv::AMDGPU_Gfx ||
1474}
1475
1477constexpr bool isCompute(CallingConv::ID CC) {
1478 return !isGraphics(CC) || CC == CallingConv::AMDGPU_CS;
1479}
1480
1483 switch (CC) {
1493 return true;
1494 default:
1495 return false;
1496 }
1497}
1498
1500constexpr bool isChainCC(CallingConv::ID CC) {
1501 switch (CC) {
1504 return true;
1505 default:
1506 return false;
1507 }
1508}
1509
1510// These functions are considered entrypoints into the current module, i.e. they
1511// are allowed to be called from outside the current module. This is different
1512// from isEntryFunctionCC, which is only true for functions that are entered by
1513// the hardware. Module entry points include all entry functions but also
1514// include functions that can be called from other functions inside or outside
1515// the current module. Module entry functions are allowed to allocate LDS.
1516//
1517// AMDGPU_CS_Chain is intended for externally callable chain functions, so it is
1518// treated as a module entrypoint. AMDGPU_CS_ChainPreserve is used for internal
1519// helper functions (e.g. retry helpers), so it is not a module entrypoint.
1522 switch (CC) {
1525 return true;
1526 default:
1527 return isEntryFunctionCC(CC);
1528 }
1529}
1530
1532constexpr inline bool isKernel(CallingConv::ID CC) {
1533 switch (CC) {
1536 return true;
1537 default:
1538 return false;
1539 }
1540}
1541
1542inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
1543
1546 return CC == CallingConv::Fast;
1547}
1548
1549/// Return true if we might ever do TCO for calls with this calling convention.
1552 switch (CC) {
1553 case CallingConv::C:
1556 return true;
1557 default:
1558 return canGuaranteeTCO(CC);
1559 }
1560}
1561
1562bool hasXNACK(const MCSubtargetInfo &STI);
1563bool hasMIMG_R128(const MCSubtargetInfo &STI);
1564bool hasA16(const MCSubtargetInfo &STI);
1565bool hasG16(const MCSubtargetInfo &STI);
1566bool hasPackedD16(const MCSubtargetInfo &STI);
1567bool hasGDS(const MCSubtargetInfo &STI);
1568unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1569unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1570
1571bool isSI(const MCSubtargetInfo &STI);
1572bool isCI(const MCSubtargetInfo &STI);
1573bool isVI(const MCSubtargetInfo &STI);
1574bool isGFX9(const MCSubtargetInfo &STI);
1575bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1576bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1577bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1578bool isGFX8Plus(const MCSubtargetInfo &STI);
1579bool isGFX9Plus(const MCSubtargetInfo &STI);
1580bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1581bool isGFX10(const MCSubtargetInfo &STI);
1582bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1583bool isGFX10Plus(const MCSubtargetInfo &STI);
1584bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1585bool isGFX10Before1030(const MCSubtargetInfo &STI);
1586bool isGFX11(const MCSubtargetInfo &STI);
1587bool isGFX11Plus(const MCSubtargetInfo &STI);
1588bool isGFX12(const MCSubtargetInfo &STI);
1589bool isGFX12Plus(const MCSubtargetInfo &STI);
1590bool isGFX1250(const MCSubtargetInfo &STI);
1591bool isGFX1250Plus(const MCSubtargetInfo &STI);
1592bool isGFX13(const MCSubtargetInfo &STI);
1593bool isGFX13Plus(const MCSubtargetInfo &STI);
1594bool supportsWGP(const MCSubtargetInfo &STI);
1595bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1596bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1597bool isGCN3Encoding(const MCSubtargetInfo &STI);
1598bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
1599bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1600bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1601bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1602bool isGFX90A(const MCSubtargetInfo &STI);
1603bool isGFX940(const MCSubtargetInfo &STI);
1605bool hasMAIInsts(const MCSubtargetInfo &STI);
1606bool hasVOPD(const MCSubtargetInfo &STI);
1607bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1608
1609inline bool supportsWave32(const MCSubtargetInfo &STI) {
1610 return AMDGPU::isGFX10Plus(STI) && !AMDGPU::isGFX1250(STI);
1611}
1612
1613int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
1614unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1616
1617/// Is Reg - scalar register
1618bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1619
1620/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1621bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI);
1622
1623/// If \p Reg is a pseudo reg, return the correct hardware register given
1624/// \p STI otherwise return \p Reg.
1626
1627/// Convert hardware register \p Reg to a pseudo register
1630
1633
1634/// Is this an AMDGPU specific source operand? These include registers,
1635/// inline constants, literals and mandatory literals (KImm).
1636constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo) {
1637 return OpInfo.OperandType >= AMDGPU::OPERAND_SRC_FIRST &&
1638 OpInfo.OperandType <= AMDGPU::OPERAND_SRC_LAST;
1639}
1640
1641inline bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo) {
1642 return isSISrcOperand(Desc.operands()[OpNo]);
1643}
1644
1645/// Is this a KImm operand?
1646bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1647
1648/// Is this floating-point operand?
1649bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1650
1651/// Does this operand support only inlinable literals?
1652bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
1653
1654/// Get the size in bits of a register from the register class \p RC.
1655unsigned getRegBitWidth(unsigned RCID);
1656
1657/// Get the size in bits of a register from the register class \p RC.
1658unsigned getRegBitWidth(const MCRegisterClass &RC);
1659
1661inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1662 switch (OpInfo.OperandType) {
1672 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1674 return 4;
1675
1682 return 8;
1683
1698 return 2;
1699
1700 default:
1701 llvm_unreachable("unhandled operand type");
1702 }
1703}
1704
1706inline unsigned getOperandSize(const MCInstrDesc &Desc, unsigned OpNo) {
1707 return getOperandSize(Desc.operands()[OpNo]);
1708}
1709
1710/// Is this literal inlinable, and not one of the values intended for floating
1711/// point values.
1713inline bool isInlinableIntLiteral(int64_t Literal) {
1714 return Literal >= -16 && Literal <= 64;
1715}
1716
1717/// Is this literal inlinable
1719bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi);
1720
1722bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi);
1723
1725bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
1726
1728bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi);
1729
1731bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi);
1732
1734std::optional<unsigned> getInlineEncodingV2I16(uint32_t Literal);
1735
1737std::optional<unsigned> getInlineEncodingV2BF16(uint32_t Literal);
1738
1740std::optional<unsigned> getInlineEncodingV2F16(uint32_t Literal);
1741
1743std::optional<unsigned> getPKFMACF16InlineEncoding(uint32_t Literal,
1744 bool IsGFX11Plus);
1745
1748
1751
1754
1757
1759bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus);
1760
1762bool isValid32BitLiteral(uint64_t Val, bool IsFP64);
1763
1765int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit);
1766
1767bool isArgPassedInSGPR(const Argument *Arg);
1768
1769bool isArgPassedInSGPR(const CallBase *CB, unsigned ArgNo);
1770
1771LLVM_READONLY bool isPackedFP32Inst(unsigned Opc);
1772
1775 int64_t EncodedOffset);
1776
1779 int64_t EncodedOffset, bool IsBuffer);
1780
1781/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1782/// offsets.
1784
1785/// \returns The encoding that will be used for \p ByteOffset in the
1786/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1787/// S_LOAD instructions have a signed offset, on other subtargets it is
1788/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1789std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1790 int64_t ByteOffset, bool IsBuffer,
1791 bool HasSOffset = false);
1792
1793/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1794/// instruction. This is only useful on CI.s
1795std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1796 int64_t ByteOffset);
1797
1798/// For pre-GFX12 FLAT instructions the offset must be positive;
1799/// MSB is ignored and forced to zero.
1800///
1801/// \return The number of bits available for the signed offset field in flat
1802/// instructions. Note that some forms of the instruction disallow negative
1803/// offsets.
1804unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1805
1806/// \returns true if this offset is small enough to fit in the SMRD
1807/// offset field. \p ByteOffset should be the offset in bytes and
1808/// not the encoded offset.
1809bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset);
1810
1812inline bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC) {
1813 if (isGFX12(ST))
1814 return DC >= DPP::ROW_SHARE_FIRST && DC <= DPP::ROW_SHARE_LAST;
1815 if (isGFX90A(ST))
1816 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1817 return false;
1818}
1819
1820/// \returns true if an instruction may have a 64-bit VGPR operand.
1822 const MCSubtargetInfo &ST);
1823
1824/// \returns true if an instruction is a DP ALU DPP without any 64-bit operands.
1825bool isDPALU_DPP32BitOpc(unsigned Opc);
1826
1827/// \returns true if an instruction is a DP ALU DPP.
1828bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII,
1829 const MCSubtargetInfo &ST);
1830
1831/// \returns true if the intrinsic is divergent
1832bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1833
1834/// \returns true if the intrinsic is uniform
1835bool isIntrinsicAlwaysUniform(unsigned IntrID);
1836
1837/// \returns a register class for the physical register \p Reg if it is a VGPR
1838/// or nullptr otherwise.
1840 const MCRegisterInfo &MRI);
1841
1842/// \returns the MODE bits which have to be set by the S_SET_VGPR_MSB for the
1843/// physical register \p Reg.
1844unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI);
1845
1846/// If \p Reg is a low VGPR return a corresponding high VGPR with \p MSBs set.
1848 const MCRegisterInfo &MRI);
1849
1850/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1851/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1852/// ignored.
1853std::optional<unsigned> convertSetRegImmToVgprMSBs(const MachineInstr &MI,
1854 bool HasSetregVGPRMSBFixup);
1855
1856/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1857/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1858/// ignored.
1859std::optional<unsigned> convertSetRegImmToVgprMSBs(const MCInst &MI,
1860 bool HasSetregVGPRMSBFixup);
1861
1862// Returns a table for the opcode with a given \p Desc to map the VGPR MSB
1863// set by the S_SET_VGPR_MSB to one of 4 sources. In case of VOPD returns 2
1864// maps, one for X and one for Y component.
1865std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
1867
1868/// \returns true if a memory instruction supports scale_offset modifier.
1869bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode);
1870
1871/// \returns lds block size in terms of dwords. \p
1872/// This is used to calculate the lds size encoded for PAL metadata 3.0+ which
1873/// must be defined in terms of bytes.
1874unsigned getLdsDwGranularity(const MCSubtargetInfo &ST);
1875
1877public:
1879
1880 ClusterDimsAttr() = default;
1881
1882 Kind getKind() const { return AttrKind; }
1883
1884 bool isUnknown() const { return getKind() == Kind::Unknown; }
1885
1886 bool isNoCluster() const { return getKind() == Kind::NoCluster; }
1887
1888 bool isFixedDims() const { return getKind() == Kind::FixedDims; }
1889
1890 bool isVariableDims() const { return getKind() == Kind::VariableDims; }
1891
1893
1895
1897
1898 /// \returns the dims stored. Note that this function can only be called if
1899 /// the kind is \p Fixed.
1900 const std::array<unsigned, 3> &getDims() const;
1901
1902 bool operator==(const ClusterDimsAttr &RHS) const {
1903 return AttrKind == RHS.AttrKind && Dims == RHS.Dims;
1904 }
1905
1906 std::string to_string() const;
1907
1908 static ClusterDimsAttr get(const Function &F);
1909
1910private:
1911 enum Encoding { EncoNoCluster = 0, EncoVariableDims = 1024 };
1912
1913 ClusterDimsAttr(Kind AttrKind) : AttrKind(AttrKind) {}
1914
1915 std::array<unsigned, 3> Dims = {0, 0, 0};
1916
1917 Kind AttrKind = Kind::Unknown;
1918};
1919
1920} // namespace AMDGPU
1921
1924
1925} // end namespace llvm
1926
1927#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:315
#define LLVM_READONLY
Definition Compiler.h:322
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 const uint32_t IV[8]
Definition blake3_impl.h:83
static ClusterDimsAttr get(const Function &F)
bool operator==(const ClusterDimsAttr &RHS) const
const std::array< unsigned, 3 > & getDims() const
void setXnackSetting(TargetIDSetting NewXnackSetting)
Sets xnack setting to NewXnackSetting.
TargetIDSetting getXnackSetting() const
void print(raw_ostream &OS) const
Write string representation to OS.
AMDGPUTargetID(const MCSubtargetInfo &STI)
void setTargetIDFromTargetIDStream(StringRef TargetID)
void setSramEccSetting(TargetIDSetting NewSramEccSetting)
Sets sramecc setting to NewSramEccSetting.
TargetIDSetting getSramEccSetting() const
unsigned getIndexInParsedOperands(unsigned CompOprIdx) const
ComponentInfo(const MCInstrDesc &OpDesc, ComponentKind Kind=ComponentKind::SINGLE, bool VOP3Layout=false)
ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps, bool VOP3Layout=false)
unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const
ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum, int BitOp3Idx)
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
bool hasRegSrcOperand(unsigned CompSrcIdx) const
unsigned getMandatoryLiteralCompOperandIndex() const
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
Represents the counter values to wait for in an s_waitcnt instruction.
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:1080
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 getVGPREncodingGranule(const MCSubtargetInfo *STI, std::optional< bool > EnableWavefrontSize32)
unsigned getTotalNumVGPRs(const MCSubtargetInfo *STI)
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getWavefrontSize(const MCSubtargetInfo *STI)
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo *STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getMaxWavesPerEU(const MCSubtargetInfo *STI)
unsigned getWavesPerWorkGroup(const MCSubtargetInfo *STI, unsigned FlatWorkGroupSize)
unsigned getNumExtraSGPRs(const MCSubtargetInfo *STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
unsigned getSGPREncodingGranule(const MCSubtargetInfo *STI)
unsigned getLocalMemorySize(const MCSubtargetInfo *STI)
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo *STI)
unsigned getEUsPerCU(const MCSubtargetInfo *STI)
constexpr unsigned getMaxFlatWorkGroupSize()
unsigned getAddressableNumSGPRs(const MCSubtargetInfo *STI)
unsigned getMinNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo *STI)
unsigned getVGPRAllocGranule(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxNumSGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, bool Addressable)
unsigned getNumSGPRBlocks(const MCSubtargetInfo *STI, unsigned NumSGPRs)
unsigned getMinWavesPerEU(const MCSubtargetInfo *STI)
unsigned getMaxNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getSGPRAllocGranule(const MCSubtargetInfo *STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo *STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
raw_ostream & operator<<(raw_ostream &OS, const AMDGPUTargetID &TargetID)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getInstCacheLineSize(const MCSubtargetInfo *STI)
unsigned getEncodedNumVGPRBlocks(const MCSubtargetInfo *STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, AMDGPUSubtarget::Generation Gen)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo *STI)
unsigned getTotalNumSGPRs(const MCSubtargetInfo *STI)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo *STI, unsigned DynamicVGPRBlockSize)
bool isValidUnifiedFormat(unsigned Id, const MCSubtargetInfo &STI)
unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI)
StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI)
bool isValidNfmt(unsigned Id, const MCSubtargetInfo &STI)
bool isValidDfmtNfmt(unsigned Id, const MCSubtargetInfo &STI)
int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt, const MCSubtargetInfo &STI)
StringRef getDfmtName(unsigned Id)
int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt)
int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI)
bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI)
StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI)
int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI)
int64_t getDfmt(const StringRef Name)
void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt)
uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId)
bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI)
void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId, uint16_t &StreamId, const MCSubtargetInfo &STI)
bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId, const MCSubtargetInfo &STI, bool Strict)
bool 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)
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)
int getIntegerAttribute(const Function &F, StringRef Name, int Default)
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.
LLVM_READONLY bool isInvalidSingleUseProducerInst(unsigned Opc)
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
LLVM_READONLY bool isInvalidSingleUseConsumerInst(unsigned Opc)
unsigned getVOPDOpcode(unsigned Opc, bool VOPD3)
bool isGroupSegment(const GlobalValue *GV)
LLVM_READONLY const MIMGMIPMappingInfo * getMIMGMIPMappingInfo(unsigned MIP)
bool getMTBUFHasSoffset(unsigned Opc)
bool hasXNACK(const MCSubtargetInfo &STI)
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3)
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)
bool isLegalSMRDImmOffset(const MCSubtargetInfo &ST, int64_t ByteOffset)
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 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)
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:234
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:204
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:211
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:225
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:222
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:227
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:213
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:208
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:203
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:210
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:209
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:212
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:221
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:219
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:214
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:207
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:228
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:239
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:240
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:215
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:206
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:224
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:220
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:226
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:216
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:241
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:223
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:205
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:231
std::optional< unsigned > getPKFMACF16InlineEncoding(uint32_t Literal, bool IsGFX11Plus)
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo *STI)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
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 hasDynamicVGPR(const Function &F)
bool isMAC(unsigned Opc)
LLVM_READNONE unsigned getOperandSize(const MCOperandInfo &OpInfo)
bool isCI(const MCSubtargetInfo &STI)
unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Lgkmcnt)
bool getVOP2IsSingle(unsigned Opc)
bool getMAIIsDGEMM(unsigned Opc)
Returns true if MAI operation is a double precision GEMM.
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
unsigned getCompletionActionImplicitArgPosition(unsigned CodeObjectVersion)
SmallVector< unsigned > getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size, unsigned DefaultVal)
LLVM_READNONE constexpr bool isChainCC(CallingConv::ID CC)
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:557
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.