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, StringRef FeatureString);
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
221
222 /// Write string representation to \p OS
223 void print(raw_ostream &OS) const;
224
225 /// \returns String representation of an object.
226 std::string toString() const;
227};
228
230 const AMDGPUTargetID &TargetID) {
231 TargetID.print(OS);
232 return OS;
233}
234
235/// \returns Instruction cache line size in bytes for given subtarget \p STI.
236unsigned getInstCacheLineSize(const MCSubtargetInfo &STI);
237
238/// \returns Wavefront size for given subtarget \p STI.
239unsigned getWavefrontSize(const MCSubtargetInfo &STI);
240
241/// \returns Local memory size in bytes for given subtarget \p STI.
242unsigned getLocalMemorySize(const MCSubtargetInfo &STI);
243
244/// \returns Maximum addressable local memory size in bytes for given subtarget
245/// \p STI.
247
248/// \returns Number of execution units per compute unit for given subtarget \p
249/// STI.
250unsigned getEUsPerCU(const MCSubtargetInfo &STI);
251
252/// \returns Maximum number of work groups per compute unit for given subtarget
253/// \p STI and limited by given \p FlatWorkGroupSize.
254unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI,
255 unsigned FlatWorkGroupSize);
256
257/// \returns Minimum number of waves per execution unit for given subtarget \p
258/// STI.
259unsigned getMinWavesPerEU(const MCSubtargetInfo &STI);
260
261/// \returns Maximum number of waves per execution unit for given subtarget \p
262/// STI without any kind of limitation.
263unsigned getMaxWavesPerEU(const MCSubtargetInfo &STI);
264
265/// \returns Number of waves per execution unit required to support the given \p
266/// FlatWorkGroupSize.
268 unsigned FlatWorkGroupSize);
269
270/// \returns Minimum flat work group size for given subtarget \p STI.
271unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo &STI);
272
273/// \returns Maximum flat work group size
274constexpr unsigned getMaxFlatWorkGroupSize() {
275 // Some subtargets allow encoding 2048, but this isn't tested or supported.
276 return 1024;
277}
278
279/// \returns Number of waves per work group for given subtarget \p STI and
280/// \p FlatWorkGroupSize.
281unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI,
282 unsigned FlatWorkGroupSize);
283
284/// \returns SGPR allocation granularity for given subtarget \p STI.
285unsigned getSGPRAllocGranule(const MCSubtargetInfo &STI);
286
287/// \returns SGPR encoding granularity for given subtarget \p STI.
288unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI);
289
290/// \returns Total number of SGPRs for given subtarget \p STI.
291unsigned getTotalNumSGPRs(const MCSubtargetInfo &STI);
292
293/// \returns Addressable number of SGPRs for given subtarget \p STI.
294unsigned getAddressableNumSGPRs(const MCSubtargetInfo &STI);
295
296/// \returns Minimum number of SGPRs that meets the given number of waves per
297/// execution unit requirement for given subtarget \p STI.
298unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU);
299
300/// \returns Maximum number of SGPRs that meets the given number of waves per
301/// execution unit requirement for given subtarget \p STI.
302unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
303 bool Addressable);
304
305/// \returns Number of extra SGPRs implicitly required by given subtarget \p
306/// STI when the given special registers are used.
307unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed,
308 bool FlatScrUsed, bool XNACKUsed);
309
310/// \returns Number of extra SGPRs implicitly required by given subtarget \p
311/// STI when the given special registers are used. XNACK is inferred from
312/// \p STI.
313unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed,
314 bool FlatScrUsed);
315
316/// \returns Number of SGPR blocks needed for given subtarget \p STI when
317/// \p NumSGPRs are used. \p NumSGPRs should already include any special
318/// register counts.
319unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs);
320
321/// \returns VGPR allocation granularity for given subtarget \p STI.
322///
323/// For subtargets which support it, \p EnableWavefrontSize32 should match
324/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
325unsigned
326getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize,
327 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
328
329/// \returns VGPR encoding granularity for given subtarget \p STI.
330///
331/// For subtargets which support it, \p EnableWavefrontSize32 should match
332/// the ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
334 const MCSubtargetInfo &STI,
335 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
336
337/// For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage,
338/// returns the allocation granule for ArchVGPRs.
339unsigned getArchVGPRAllocGranule();
340
341/// \returns Total number of VGPRs for given subtarget \p STI.
342unsigned getTotalNumVGPRs(const MCSubtargetInfo &STI);
343
344/// Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
345static constexpr unsigned MaxDynamicVGPRBlocks = 8;
346
347/// \returns Addressable number of architectural VGPRs for a given subtarget \p
348/// STI.
350
351/// \returns Addressable number of VGPRs for given subtarget \p STI.
352unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI,
353 unsigned DynamicVGPRBlockSize);
354
355/// \returns Minimum number of VGPRs that meets given number of waves per
356/// execution unit requirement for given subtarget \p STI.
357unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
358 unsigned DynamicVGPRBlockSize);
359
360/// \returns Maximum number of VGPRs that meets given number of waves per
361/// execution unit requirement for given subtarget \p STI.
362unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU,
363 unsigned DynamicVGPRBlockSize);
364
365/// \returns Number of waves reachable for a given \p NumVGPRs usage for given
366/// subtarget \p STI.
368 unsigned NumVGPRs,
369 unsigned DynamicVGPRBlockSize);
370
371/// \returns Number of waves reachable for a given \p NumVGPRs usage, \p Granule
372/// size, \p MaxWaves possible, and \p TotalNumVGPRs available.
373unsigned getNumWavesPerEUWithNumVGPRs(unsigned NumVGPRs, unsigned Granule,
374 unsigned MaxWaves,
375 unsigned TotalNumVGPRs);
376
377/// \returns Whether allocated SGPRs can reduce occupancy on subtarget \p STI
378/// (true pre-GFX10). One named capability so callers don't test the version.
380
381/// \returns SGPR-limited occupancy (waves per EU) for subtarget \p STI: the
382/// inverse of getMaxNumSGPRs(). Unlike getMaxNumSGPRs() the budget is not
383/// clamped to the addressable count, since the allocated count callers pass in
384/// can exceed it.
385unsigned getOccupancyWithNumSGPRs(const MCSubtargetInfo &STI, unsigned SGPRs);
386
387/// \returns SGPR-limited occupancy computed from explicit budget parameters
388/// (\p MaxWaves, \p TotalNumSGPRs, \p Granule, \p TrapReserve). Subtarget-free
389/// core shared by the overload above and the occupancy MCExpr. Callers must
390/// check isSGPROccupancyLimited() first.
391unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves,
392 unsigned TotalNumSGPRs, unsigned Granule,
393 unsigned TrapReserve);
394
395/// \returns Number of VGPR blocks needed for given subtarget \p STI when
396/// \p NumVGPRs are used. We actually return the number of blocks -1, since
397/// that's what we encode.
398///
399/// For subtargets which support it, \p EnableWavefrontSize32 should match the
400/// ENABLE_WAVEFRONT_SIZE32 kernel descriptor field.
402 const MCSubtargetInfo &STI, unsigned NumVGPRs,
403 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
404
405/// \returns Number of VGPR blocks that need to be allocated for the given
406/// subtarget \p STI when \p NumVGPRs are used.
408 const MCSubtargetInfo &STI, unsigned NumVGPRs,
409 unsigned DynamicVGPRBlockSize,
410 std::optional<bool> EnableWavefrontSize32 = std::nullopt);
411
412} // end namespace IsaInfo
413
414// Represents a field in an encoded value.
415template <unsigned HighBit, unsigned LowBit, unsigned D = 0>
417 static_assert(HighBit >= LowBit, "Invalid bit range!");
418 static constexpr unsigned Offset = LowBit;
419 static constexpr unsigned Width = HighBit - LowBit + 1;
420
422 static constexpr ValueType Default = D;
423
426
427 constexpr uint64_t encode() const { return Value; }
428 static ValueType decode(uint64_t Encoded) { return Encoded; }
429};
430
431// Represents a single bit in an encoded value.
432template <unsigned Bit, unsigned D = 0>
434
435// A helper for encoding and decoding multiple fields.
436template <typename... Fields> struct EncodingFields {
437 static constexpr uint64_t encode(Fields... Values) {
438 return ((Values.encode() << Values.Offset) | ...);
439 }
440
441 static std::tuple<typename Fields::ValueType...> decode(uint64_t Encoded) {
442 return {Fields::decode((Encoded >> Fields::Offset) &
443 maxUIntN(Fields::Width))...};
444 }
445};
446
448inline bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx) {
449 return getNamedOperandIdx(Opcode, NamedIdx) != -1;
450}
451
454
475
478
480const MIMGBaseOpcodeInfo *getMIMGBaseOpcodeInfo(unsigned BaseOpcode);
481
491
493const MIMGDimInfo *getMIMGDimInfo(unsigned DimEnum);
494
497
500
502 MIMGBaseOpcode L;
503 MIMGBaseOpcode LZ;
504};
505
507 MIMGBaseOpcode MIP;
508 MIMGBaseOpcode NONMIP;
509};
510
512 MIMGBaseOpcode Bias;
513 MIMGBaseOpcode NoBias;
514};
515
517 MIMGBaseOpcode Offset;
518 MIMGBaseOpcode NoOffset;
519};
520
522 MIMGBaseOpcode G;
523 MIMGBaseOpcode G16;
524};
525
528
530 unsigned Opcode2Addr;
531 unsigned Opcode3Addr;
532};
533
536
539
542
545
547int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding,
548 unsigned VDataDwords, unsigned VAddrDwords);
549
551int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels);
552
554unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode,
555 const MIMGDimInfo *Dim, bool IsA16,
556 bool IsG16Supported);
557
566
568const MIMGInfo *getMIMGInfo(unsigned Opc);
569
571int getMTBUFBaseOpcode(unsigned Opc);
572
574int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements);
575
577int getMTBUFElements(unsigned Opc);
578
580bool getMTBUFHasVAddr(unsigned Opc);
581
583bool getMTBUFHasSrsrc(unsigned Opc);
584
586bool getMTBUFHasSoffset(unsigned Opc);
587
589int getMUBUFBaseOpcode(unsigned Opc);
590
592int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements);
593
595int getMUBUFElements(unsigned Opc);
596
598bool getMUBUFHasVAddr(unsigned Opc);
599
601bool getMUBUFHasSrsrc(unsigned Opc);
602
604bool getMUBUFHasSoffset(unsigned Opc);
605
607bool getMUBUFIsBufferInv(unsigned Opc);
608
610bool getMUBUFTfe(unsigned Opc);
611
613bool getSMEMIsBuffer(unsigned Opc);
614
616bool getVOP1IsSingle(unsigned Opc);
617
619bool getVOP2IsSingle(unsigned Opc);
620
622bool getVOP3IsSingle(unsigned Opc);
623
625bool isVOPC64DPP(unsigned Opc);
626
628bool isVOPCAsmOnly(unsigned Opc);
629
630/// Returns true if MAI operation is a double precision GEMM.
632bool getMAIIsDGEMM(unsigned Opc);
633
635bool getMAIIsGFX940XDL(unsigned Opc);
636
638bool getWMMAIsXDL(unsigned Opc);
639
641bool getHasMatrixScale(unsigned Opc);
642
643// Get an equivalent BitOp3 for a binary logical \p Opc.
644// \returns BitOp3 modifier for the logical operation or zero.
645// Used in VOPD3 conversion.
646unsigned getBitOp2(unsigned Opc);
647
648struct CanBeVOPD {
649 bool X;
650 bool Y;
651};
652
653/// \returns SIEncodingFamily used for VOPD encoding on a \p ST.
655unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST);
656
658CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3);
659
661uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal);
662
665 unsigned BLGP,
666 unsigned F8F8Opcode);
667
670
673 unsigned FmtB,
674 unsigned F8F8Opcode);
675
676/// \return true if this combination is listed as valid.
678bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale,
679 unsigned BFmt, unsigned BScale);
680
683 uint8_t NumComponents,
684 uint8_t NumFormat,
685 const MCSubtargetInfo &STI);
688 const MCSubtargetInfo &STI);
689
691int32_t getMCOpcode(uint32_t Opcode, unsigned Gen);
692
694unsigned getVOPDOpcode(unsigned Opc, bool VOPD3);
695
697int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily,
698 bool VOPD3);
699
701bool isVOPD(unsigned Opc);
702
704bool isMAC(unsigned Opc);
705
707bool isPermlane16(unsigned Opc);
708
710bool isGenericAtomic(unsigned Opc);
711
713bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc);
714
715namespace VOPD {
716
727
728// LSB mask for VGPR banks per VOPD component operand.
729// 4 banks result in a mask 3, setting 2 lower bits.
730constexpr unsigned VOPD_VGPR_BANK_MASKS[] = {1, 3, 3, 1};
731constexpr unsigned VOPD3_VGPR_BANK_MASKS[] = {1, 3, 3, 3};
732
733enum ComponentIndex : unsigned { X = 0, Y = 1 };
735constexpr unsigned COMPONENTS_NUM = 2;
736
737// Properties of VOPD components.
739private:
740 unsigned SrcOperandsNum = 0;
741 unsigned MandatoryLiteralIdx = ~0u;
742 bool HasSrc2Acc = false;
743 unsigned NumVOPD3Mods = 0;
744 unsigned Opcode = 0;
745 bool IsVOP3 = false;
746
747public:
748 ComponentProps() = default;
749 ComponentProps(const MCInstrDesc &OpDesc, bool VOP3Layout = false);
750
751 // Return the total number of src operands this component has.
752 unsigned getCompSrcOperandsNum() const { return SrcOperandsNum; }
753
754 // Return the number of src operands of this component visible to the parser.
756 return SrcOperandsNum - HasSrc2Acc;
757 }
758
759 // Return true iif this component has a mandatory literal.
760 bool hasMandatoryLiteral() const { return MandatoryLiteralIdx != ~0u; }
761
762 // If this component has a mandatory literal, return component operand
763 // index of this literal (i.e. either Component::SRC1 or Component::SRC2).
766 return MandatoryLiteralIdx;
767 }
768
769 // Return true iif this component has operand
770 // with component index CompSrcIdx and this operand may be a register.
771 bool hasRegSrcOperand(unsigned CompSrcIdx) const {
772 assert(CompSrcIdx < Component::MAX_SRC_NUM);
773 return SrcOperandsNum > CompSrcIdx && !hasMandatoryLiteralAt(CompSrcIdx);
774 }
775
776 // Return true iif this component has tied src2.
777 bool hasSrc2Acc() const { return HasSrc2Acc; }
778
779 // Return a number of source modifiers if instruction is used in VOPD3.
780 unsigned getCompVOPD3ModsNum() const { return NumVOPD3Mods; }
781
782 // Return opcode of the component.
783 unsigned getOpcode() const { return Opcode; }
784
785 // Returns if component opcode is in VOP3 encoding.
786 unsigned isVOP3() const { return IsVOP3; }
787
788 // Return index of BitOp3 operand or -1.
789 int getBitOp3OperandIdx() const;
790
791private:
792 bool hasMandatoryLiteralAt(unsigned CompSrcIdx) const {
793 assert(CompSrcIdx < Component::MAX_SRC_NUM);
794 return MandatoryLiteralIdx == Component::DST_NUM + CompSrcIdx;
795 }
796};
797
798enum ComponentKind : unsigned {
799 SINGLE = 0, // A single VOP1 or VOP2 instruction which may be used in VOPD.
800 COMPONENT_X, // A VOPD instruction, X component.
801 COMPONENT_Y, // A VOPD instruction, Y component.
803};
804
805// Interface functions of this class map VOPD component operand indices
806// to indices of operands in MachineInstr/MCInst or parsed operands array.
807//
808// Note that this class operates with 3 kinds of indices:
809// - VOPD component operand indices (Component::DST, Component::SRC0, etc.);
810// - MC operand indices (they refer operands in a MachineInstr/MCInst);
811// - parsed operand indices (they refer operands in parsed operands array).
812//
813// For SINGLE components mapping between these indices is trivial.
814// But things get more complicated for COMPONENT_X and
815// COMPONENT_Y because these components share the same
816// MachineInstr/MCInst and the same parsed operands array.
817// Below is an example of component operand to parsed operand
818// mapping for the following instruction:
819//
820// v_dual_add_f32 v255, v4, v5 :: v_dual_mov_b32 v6, v1
821//
822// PARSED COMPONENT PARSED
823// COMPONENT OPERANDS OPERAND INDEX OPERAND INDEX
824// -------------------------------------------------------------------
825// "v_dual_add_f32" 0
826// v_dual_add_f32 v255 0 (DST) --> 1
827// v4 1 (SRC0) --> 2
828// v5 2 (SRC1) --> 3
829// "::" 4
830// "v_dual_mov_b32" 5
831// v_dual_mov_b32 v6 0 (DST) --> 6
832// v1 1 (SRC0) --> 7
833// -------------------------------------------------------------------
834//
836private:
837 // Regular MachineInstr/MCInst operands are ordered as follows:
838 // dst, src0 [, other src operands]
839 // VOPD MachineInstr/MCInst operands are ordered as follows:
840 // dstX, dstY, src0X [, other OpX operands], src0Y [, other OpY operands]
841 // Each ComponentKind has operand indices defined below.
842 static constexpr unsigned MC_DST_IDX[] = {0, 0, 1};
843
844 // VOPD3 instructions may have 2 or 3 source modifiers, src2 modifier is not
845 // used if there is tied accumulator. Indexing of this array:
846 // MC_SRC_IDX[VOPD3ModsNum][SrcNo]. This returns an index for a SINGLE
847 // instruction layout, add 1 for COMPONENT_X or COMPONENT_Y. For the second
848 // component add OpX.MCSrcNum + OpX.VOPD3ModsNum.
849 // For VOPD1/VOPD2 use column with zero modifiers.
850 static constexpr unsigned SINGLE_MC_SRC_IDX[4][3] = {
851 {1, 2, 3}, {2, 3, 4}, {2, 4, 5}, {2, 4, 6}};
852
853 // Parsed operands of regular instructions are ordered as follows:
854 // Mnemo dst src0 [vsrc1 ...]
855 // Parsed VOPD operands are ordered as follows:
856 // OpXMnemo dstX src0X [vsrc1X|imm vsrc1X|vsrc1X imm] '::'
857 // OpYMnemo dstY src0Y [vsrc1Y|imm vsrc1Y|vsrc1Y imm]
858 // Each ComponentKind has operand indices defined below.
859 static constexpr unsigned PARSED_DST_IDX[] = {1, 1,
860 4 /* + OpX.ParsedSrcNum */};
861 static constexpr unsigned FIRST_PARSED_SRC_IDX[] = {
862 2, 2, 5 /* + OpX.ParsedSrcNum */};
863
864private:
865 const ComponentKind Kind;
866 const ComponentProps PrevComp;
867 const unsigned VOPD3ModsNum;
868 const int BitOp3Idx; // Index of bitop3 operand or -1
869
870public:
871 // Create layout for COMPONENT_X or SINGLE component.
872 ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
873 : Kind(Kind), VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {
875 }
876
877 // Create layout for COMPONENT_Y which depends on COMPONENT_X layout.
878 ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum,
879 int BitOp3Idx)
880 : Kind(ComponentKind::COMPONENT_Y), PrevComp(OpXProps),
881 VOPD3ModsNum(VOPD3ModsNum), BitOp3Idx(BitOp3Idx) {}
882
883public:
884 // Return the index of dst operand in MCInst operands.
885 unsigned getIndexOfDstInMCOperands() const { return MC_DST_IDX[Kind]; }
886
887 // Return the index of the specified src operand in MCInst operands.
888 unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const {
889 assert(CompSrcIdx < Component::MAX_SRC_NUM);
890
891 if (Kind == SINGLE && CompSrcIdx == 2 && BitOp3Idx != -1)
892 return BitOp3Idx;
893
894 if (VOPD3) {
895 return SINGLE_MC_SRC_IDX[VOPD3ModsNum][CompSrcIdx] + getPrevCompSrcNum() +
896 getPrevCompVOPD3ModsNum() + (Kind != SINGLE ? 1 : 0);
897 }
898
899 return SINGLE_MC_SRC_IDX[0][CompSrcIdx] + getPrevCompSrcNum() +
900 (Kind != SINGLE ? 1 : 0);
901 }
902
903 // Return the index of dst operand in the parsed operands array.
905 return PARSED_DST_IDX[Kind] + getPrevCompParsedSrcNum();
906 }
907
908 // Return the index of the specified src operand in the parsed operands array.
909 unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const {
910 assert(CompSrcIdx < Component::MAX_SRC_NUM);
911 return FIRST_PARSED_SRC_IDX[Kind] + getPrevCompParsedSrcNum() + CompSrcIdx;
912 }
913
914private:
915 unsigned getPrevCompSrcNum() const {
916 return PrevComp.getCompSrcOperandsNum();
917 }
918 unsigned getPrevCompParsedSrcNum() const {
919 return PrevComp.getCompParsedSrcOperandsNum();
920 }
921 unsigned getPrevCompVOPD3ModsNum() const {
922 return PrevComp.getCompVOPD3ModsNum();
923 }
924};
925
926// Layout and properties of VOPD components.
928public:
929 // Create ComponentInfo for COMPONENT_X or SINGLE component.
932 bool VOP3Layout = false)
933 : ComponentProps(OpDesc, VOP3Layout),
935
936 // Create ComponentInfo for COMPONENT_Y which depends on COMPONENT_X layout.
937 ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps,
938 bool VOP3Layout = false)
939 : ComponentProps(OpDesc, VOP3Layout),
942
943 // Map component operand index to parsed operand index.
944 // Return 0 if the specified operand does not exist.
945 unsigned getIndexInParsedOperands(unsigned CompOprIdx) const;
946};
947
948// Properties of VOPD instructions.
949class InstInfo {
950private:
951 const ComponentInfo CompInfo[COMPONENTS_NUM];
952
953public:
954 using RegIndices = std::array<MCRegister, Component::MAX_OPR_NUM>;
955
956 InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
957 : CompInfo{OpX, OpY} {}
958
959 InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
960 : CompInfo{OprInfoX, OprInfoY} {}
961
962 const ComponentInfo &operator[](size_t ComponentIdx) const {
963 assert(ComponentIdx < COMPONENTS_NUM);
964 return CompInfo[ComponentIdx];
965 }
966
967 // Check VOPD operands constraints.
968 // GetRegIdx(Component, MCOperandIdx) must return a VGPR register index
969 // for the specified component and MC operand. The callback must return 0
970 // if the operand is not a register or not a VGPR.
971 // If \p SkipSrc is set to true then constraints for source operands are not
972 // checked.
973 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
974 // even though it violates requirement to be from different banks.
975 // If \p VOPD3 is set to true both dst registers allowed to be either odd
976 // or even and instruction may have real src2 as opposed to tied accumulator.
977 bool
978 hasInvalidOperand(std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
979 const MCRegisterInfo &MRI, bool SkipSrc = false,
980 bool AllowSameVGPR = false, bool VOPD3 = false) const {
981 return getInvalidCompOperandIndex(GetRegIdx, MRI, SkipSrc, AllowSameVGPR,
982 VOPD3)
983 .has_value();
984 }
985
986 // Check VOPD operands constraints.
987 // Return the index of an invalid component operand, if any.
988 // If \p SkipSrc is set to true then constraints for source operands are not
989 // checked except for being from the same halves of VGPR file on gfx1250.
990 // If \p AllowSameVGPR is set then same VGPRs are allowed for X and Y sources
991 // even though it violates requirement to be from different banks.
992 // If \p VOPD3 is set to true both dst registers allowed to be either odd
993 // or even and instruction may have real src2 as opposed to tied accumulator.
994 std::optional<unsigned> getInvalidCompOperandIndex(
995 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
996 const MCRegisterInfo &MRI, bool SkipSrc = false,
997 bool AllowSameVGPR = false, bool VOPD3 = false) const;
998
999private:
1001 getRegIndices(unsigned ComponentIdx,
1002 std::function<MCRegister(unsigned, unsigned)> GetRegIdx,
1003 bool VOPD3) const;
1004};
1005
1006} // namespace VOPD
1007
1009std::pair<unsigned, unsigned> getVOPDComponents(unsigned VOPDOpcode);
1010
1012// Get properties of 2 single VOP1/VOP2 instructions
1013// used as components to create a VOPD instruction.
1014VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY);
1015
1017// Get properties of VOPD X and Y components.
1018VOPD::InstInfo getVOPDInstInfo(unsigned VOPDOpcode,
1019 const MCInstrInfo *InstrInfo);
1020
1022bool isAsyncStore(unsigned Opc);
1024bool isTensorStore(unsigned Opc);
1026unsigned getTemporalHintType(const MCInstrDesc TID);
1027
1029bool isTrue16Inst(unsigned Opc);
1030
1032FPType getFPDstSelType(unsigned Opc);
1033
1034bool isDPMACCInstruction(unsigned Opc);
1035
1037unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc);
1038
1040unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc);
1041
1042void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &Header,
1043 const MCSubtargetInfo &STI);
1044
1045bool isGroupSegment(const GlobalValue *GV);
1046bool isGlobalSegment(const GlobalValue *GV);
1047bool isReadOnlySegment(const GlobalValue *GV);
1048
1049/// \returns True if constants should be emitted to .text section for given
1050/// target triple \p TT, false otherwise.
1052
1053/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1054/// register name. Followed by the start register number, and the register
1055/// width. Does not validate the number of registers exists in the class. Unlike
1056/// parseAsmConstraintPhysReg, this does not expect the name to be wrapped in
1057/// "{}".
1058std::tuple<char, unsigned, unsigned> parseAsmPhysRegName(StringRef TupleString);
1059
1060/// Returns a valid charcode or 0 in the first entry if this is a valid physical
1061/// register constraint. Followed by the start register number, and the register
1062/// width. Does not validate the number of registers exists in the class.
1063std::tuple<char, unsigned, unsigned>
1065
1066/// \returns A pair of integer values requested using \p F's \p Name attribute
1067/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1068/// is false).
1069///
1070/// \returns \p Default if attribute is not present.
1071///
1072/// \returns \p Default and emits error if one of the requested values cannot be
1073/// converted to integer, or \p OnlyFirstRequired is false and "second" value is
1074/// not present.
1075std::pair<unsigned, unsigned>
1077 std::pair<unsigned, unsigned> Default,
1078 bool OnlyFirstRequired = false);
1079
1080/// \returns A pair of integer values requested using \p F's \p Name attribute
1081/// in "first[,second]" format ("second" is optional unless \p OnlyFirstRequired
1082/// is false).
1083///
1084/// \returns \p std::nullopt if attribute is not present.
1085///
1086/// \returns \p std::nullopt and emits error if one of the requested values
1087/// cannot be converted to integer, or \p OnlyFirstRequired is false and
1088/// "second" value is not present.
1089std::optional<std::pair<unsigned, std::optional<unsigned>>>
1091 bool OnlyFirstRequired = false);
1092
1093/// \returns Generate a vector of integer values requested using \p F's \p Name
1094/// attribute.
1095/// \returns A vector of size \p Size, with all elements set to \p DefaultVal,
1096/// if any error occurs. The corresponding error will also be emitted.
1098 unsigned Size,
1099 unsigned DefaultVal);
1100/// Similar to the function above, but returns std::nullopt if any error occurs.
1101std::optional<SmallVector<unsigned>>
1102getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size);
1103
1104/// Checks if \p Val is inside \p MD, a !range-like metadata.
1105bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val);
1106
1107// The following methods are only meaningful on targets that support
1108// S_WAITCNT.
1109
1110/// \returns Vmcnt bit mask for given isa \p Version.
1111unsigned getVmcntBitMask(const IsaVersion &Version);
1112
1113/// \returns Expcnt bit mask for given isa \p Version.
1114unsigned getExpcntBitMask(const IsaVersion &Version);
1115
1116/// \returns Lgkmcnt bit mask for given isa \p Version.
1117unsigned getLgkmcntBitMask(const IsaVersion &Version);
1118
1119/// \returns Waitcnt bit mask for given isa \p Version.
1120unsigned getWaitcntBitMask(const IsaVersion &Version);
1121
1122/// \returns Decoded Vmcnt from given \p Waitcnt for given isa \p Version.
1123unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt);
1124
1125/// \returns Decoded Expcnt from given \p Waitcnt for given isa \p Version.
1126unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt);
1127
1128/// \returns Decoded Lgkmcnt from given \p Waitcnt for given isa \p Version.
1129unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt);
1130
1131/// \returns Decoded Loadcnt from given \p Waitcnt for given isa \p Version.
1132unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt);
1133
1134/// \returns Decoded Storecnt from given \p Waitcnt for given isa \p Version.
1135unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt);
1136
1137/// \returns Decoded Dscnt from given \p Waitcnt for given isa \p Version.
1138unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt);
1139
1140/// Decodes Vmcnt, Expcnt and Lgkmcnt from given \p Waitcnt for given isa
1141/// \p Version, and writes decoded values into \p Vmcnt, \p Expcnt and
1142/// \p Lgkmcnt respectively. Should not be used on gfx12+, the instruction
1143/// which needs it is deprecated
1144///
1145/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are decoded as follows:
1146/// \p Vmcnt = \p Waitcnt[3:0] (pre-gfx9)
1147/// \p Vmcnt = \p Waitcnt[15:14,3:0] (gfx9,10)
1148/// \p Vmcnt = \p Waitcnt[15:10] (gfx11)
1149/// \p Expcnt = \p Waitcnt[6:4] (pre-gfx11)
1150/// \p Expcnt = \p Waitcnt[2:0] (gfx11)
1151/// \p Lgkmcnt = \p Waitcnt[11:8] (pre-gfx10)
1152/// \p Lgkmcnt = \p Waitcnt[13:8] (gfx10)
1153/// \p Lgkmcnt = \p Waitcnt[9:4] (gfx11)
1154///
1155void decodeWaitcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned &Vmcnt,
1156 unsigned &Expcnt, unsigned &Lgkmcnt);
1157
1158/// \returns \p Waitcnt with encoded \p Vmcnt for given isa \p Version.
1159unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt,
1160 unsigned Vmcnt);
1161
1162/// \returns \p Waitcnt with encoded \p Expcnt for given isa \p Version.
1163unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt,
1164 unsigned Expcnt);
1165
1166/// \returns \p Waitcnt with encoded \p Lgkmcnt for given isa \p Version.
1167unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt,
1168 unsigned Lgkmcnt);
1169
1170/// Encodes \p Vmcnt, \p Expcnt and \p Lgkmcnt into Waitcnt for given isa
1171/// \p Version. Should not be used on gfx12+, the instruction which needs
1172/// it is deprecated
1173///
1174/// \details \p Vmcnt, \p Expcnt and \p Lgkmcnt are encoded as follows:
1175/// Waitcnt[2:0] = \p Expcnt (gfx11+)
1176/// Waitcnt[3:0] = \p Vmcnt (pre-gfx9)
1177/// Waitcnt[3:0] = \p Vmcnt[3:0] (gfx9,10)
1178/// Waitcnt[6:4] = \p Expcnt (pre-gfx11)
1179/// Waitcnt[9:4] = \p Lgkmcnt (gfx11)
1180/// Waitcnt[11:8] = \p Lgkmcnt (pre-gfx10)
1181/// Waitcnt[13:8] = \p Lgkmcnt (gfx10)
1182/// Waitcnt[15:10] = \p Vmcnt (gfx11)
1183/// Waitcnt[15:14] = \p Vmcnt[5:4] (gfx9,10)
1184///
1185/// \returns Waitcnt with encoded \p Vmcnt, \p Expcnt and \p Lgkmcnt for given
1186/// isa \p Version.
1187///
1188unsigned encodeWaitcnt(const IsaVersion &Version, unsigned Vmcnt,
1189 unsigned Expcnt, unsigned Lgkmcnt);
1190
1191/// \returns Waitcnt with encoded \p Loadcnt and \p Dscnt for given isa \p
1192/// Version.
1193unsigned encodeLoadcntDscnt(const IsaVersion &Version, unsigned Loadcnt,
1194 unsigned Dscnt);
1195
1196/// \returns Waitcnt with encoded \p Storecnt and \p Dscnt for given isa \p
1197/// Version.
1198unsigned encodeStorecntDscnt(const IsaVersion &Version, unsigned Storecnt,
1199 unsigned Dscnt);
1200
1201// The following methods are only meaningful on targets that support
1202// S_WAIT_*CNT, introduced with gfx12.
1203
1204/// \returns Loadcnt bit mask for given isa \p Version.
1205/// Returns 0 for versions that do not support LOADcnt
1206unsigned getLoadcntBitMask(const IsaVersion &Version);
1207
1208/// \returns Samplecnt bit mask for given isa \p Version.
1209/// Returns 0 for versions that do not support SAMPLEcnt
1210unsigned getSamplecntBitMask(const IsaVersion &Version);
1211
1212/// \returns Bvhcnt bit mask for given isa \p Version.
1213/// Returns 0 for versions that do not support BVHcnt
1214unsigned getBvhcntBitMask(const IsaVersion &Version);
1215
1216/// \returns Asynccnt bit mask for given isa \p Version.
1217/// Returns 0 for versions that do not support Asynccnt
1218unsigned getAsynccntBitMask(const IsaVersion &Version);
1219
1220/// \returns Dscnt bit mask for given isa \p Version.
1221/// Returns 0 for versions that do not support DScnt
1222unsigned getDscntBitMask(const IsaVersion &Version);
1223
1224/// \returns Dscnt bit mask for given isa \p Version.
1225/// Returns 0 for versions that do not support KMcnt
1226unsigned getKmcntBitMask(const IsaVersion &Version);
1227
1228/// \returns Xcnt bit mask for given isa \p Version.
1229/// Returns 0 for versions that do not support Xcnt.
1230unsigned getXcntBitMask(const IsaVersion &Version);
1231
1232/// \return STOREcnt or VScnt bit mask for given isa \p Version.
1233/// returns 0 for versions that do not support STOREcnt or VScnt.
1234/// STOREcnt and VScnt are the same counter, the name used
1235/// depends on the ISA version.
1236unsigned getStorecntBitMask(const IsaVersion &Version);
1237
1238namespace Hwreg {
1239
1242
1243struct HwregSize : EncodingField<15, 11, 32> {
1245 constexpr uint64_t encode() const { return Value - 1; }
1246 static ValueType decode(uint64_t Encoded) { return Encoded + 1; }
1247};
1248
1250
1251} // namespace Hwreg
1252
1253namespace DepCtr {
1254
1256int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask,
1257 const MCSubtargetInfo &STI);
1258bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal,
1259 const MCSubtargetInfo &STI);
1260bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val,
1261 bool &IsDefault, const MCSubtargetInfo &STI);
1262
1263/// \returns Maximum VaVdst value that can be encoded.
1264unsigned getVaVdstBitMask();
1265
1266/// \returns Maximum VaSdst value that can be encoded.
1267unsigned getVaSdstBitMask();
1268
1269/// \returns Maximum VaSsrc value that can be encoded.
1270unsigned getVaSsrcBitMask();
1271
1272/// \returns Maximum HoldCnt value that can be encoded.
1273unsigned getHoldCntBitMask(const IsaVersion &Version);
1274
1275/// \returns Maximum VmVsrc value that can be encoded.
1276unsigned getVmVsrcBitMask();
1277
1278/// \returns Maximum VaVcc value that can be encoded.
1279unsigned getVaVccBitMask();
1280
1281/// \returns Maximum SaSdst value that can be encoded.
1282unsigned getSaSdstBitMask();
1283
1284/// \returns Decoded VaVdst from given immediate \p Encoded.
1285unsigned decodeFieldVaVdst(unsigned Encoded);
1286
1287/// \returns Decoded VmVsrc from given immediate \p Encoded.
1288unsigned decodeFieldVmVsrc(unsigned Encoded);
1289
1290/// \returns Decoded SaSdst from given immediate \p Encoded.
1291unsigned decodeFieldSaSdst(unsigned Encoded);
1292
1293/// \returns Decoded VaSdst from given immediate \p Encoded.
1294unsigned decodeFieldVaSdst(unsigned Encoded);
1295
1296/// \returns Decoded VaVcc from given immediate \p Encoded.
1297unsigned decodeFieldVaVcc(unsigned Encoded);
1298
1299/// \returns Decoded SaSrc from given immediate \p Encoded.
1300unsigned decodeFieldVaSsrc(unsigned Encoded);
1301
1302/// \returns Decoded HoldCnt from given immediate \p Encoded.
1303unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version);
1304
1305/// \returns \p VmVsrc as an encoded Depctr immediate.
1306unsigned encodeFieldVmVsrc(unsigned VmVsrc, const MCSubtargetInfo &STI);
1307
1308/// \returns \p Encoded combined with encoded \p VmVsrc.
1309unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc);
1310
1311/// \returns \p VaVdst as an encoded Depctr immediate.
1312unsigned encodeFieldVaVdst(unsigned VaVdst, const MCSubtargetInfo &STI);
1313
1314/// \returns \p Encoded combined with encoded \p VaVdst.
1315unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst);
1316
1317/// \returns \p SaSdst as an encoded Depctr immediate.
1318unsigned encodeFieldSaSdst(unsigned SaSdst, const MCSubtargetInfo &STI);
1319
1320/// \returns \p Encoded combined with encoded \p SaSdst.
1321unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst);
1322
1323/// \returns \p VaSdst as an encoded Depctr immediate.
1324unsigned encodeFieldVaSdst(unsigned VaSdst, const MCSubtargetInfo &STI);
1325
1326/// \returns \p Encoded combined with encoded \p VaSdst.
1327unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst);
1328
1329/// \returns \p VaVcc as an encoded Depctr immediate.
1330unsigned encodeFieldVaVcc(unsigned VaVcc, const MCSubtargetInfo &STI);
1331
1332/// \returns \p Encoded combined with encoded \p VaVcc.
1333unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc);
1334
1335/// \returns \p HoldCnt as an encoded Depctr immediate.
1336unsigned encodeFieldHoldCnt(unsigned HoldCnt, const MCSubtargetInfo &STI);
1337
1338/// \returns \p Encoded combined with encoded \p HoldCnt.
1339unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt,
1340 const IsaVersion &Version);
1341
1342/// \returns \p VaSsrc as an encoded Depctr immediate.
1343unsigned encodeFieldVaSsrc(unsigned VaSsrc, const MCSubtargetInfo &STI);
1344
1345/// \returns \p Encoded combined with encoded \p VaSsrc.
1346unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc);
1347
1348} // namespace DepCtr
1349
1350namespace Exp {
1351
1352bool getTgtName(unsigned Id, StringRef &Name, int &Index);
1353
1355unsigned getTgtId(const StringRef Name);
1356
1358bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI);
1359
1360} // namespace Exp
1361
1362namespace MTBUFFormat {
1363
1365int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt);
1366
1367void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt);
1368
1369int64_t getDfmt(const StringRef Name);
1370
1371StringRef getDfmtName(unsigned Id);
1372
1373int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI);
1374
1375StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI);
1376
1377bool isValidDfmtNfmt(unsigned Val, const MCSubtargetInfo &STI);
1378
1379bool isValidNfmt(unsigned Val, const MCSubtargetInfo &STI);
1380
1381int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI);
1382
1383StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI);
1384
1385bool isValidUnifiedFormat(unsigned Val, const MCSubtargetInfo &STI);
1386
1387int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt,
1388 const MCSubtargetInfo &STI);
1389
1390bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI);
1391
1392unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI);
1393
1394} // namespace MTBUFFormat
1395
1396namespace SendMsg {
1397
1399bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI);
1400
1402bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI,
1403 bool Strict = true);
1404
1406bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId,
1407 const MCSubtargetInfo &STI, bool Strict = true);
1408
1410bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI);
1411
1413bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI);
1414
1415void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId,
1416 uint16_t &StreamId, const MCSubtargetInfo &STI);
1417
1419uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId);
1420
1421/// Returns true if the message does not use the m0 operand.
1422bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI);
1423
1424} // namespace SendMsg
1425
1426unsigned getInitialPSInputAddr(const Function &F);
1427
1428bool getHasColorExport(const Function &F);
1429
1430bool getHasDepthExport(const Function &F);
1431
1432// Returns the value of the "amdgpu-dynamic-vgpr-block-size" attribute, or 0 if
1433// the attribute is missing or its value is invalid.
1434unsigned getDynamicVGPRBlockSize(const Function &F);
1435
1437constexpr bool isShader(CallingConv::ID CC) {
1438 switch (CC) {
1448 return true;
1449 default:
1450 return false;
1451 }
1452}
1453
1455constexpr bool isGraphics(CallingConv::ID CC) {
1456 return isShader(CC) || CC == CallingConv::AMDGPU_Gfx ||
1458}
1459
1461constexpr bool isCompute(CallingConv::ID CC) {
1462 return !isGraphics(CC) || CC == CallingConv::AMDGPU_CS;
1463}
1464
1467 switch (CC) {
1477 return true;
1478 default:
1479 return false;
1480 }
1481}
1482
1484constexpr bool isChainCC(CallingConv::ID CC) {
1485 switch (CC) {
1488 return true;
1489 default:
1490 return false;
1491 }
1492}
1493
1494// These functions are considered entrypoints into the current module, i.e. they
1495// are allowed to be called from outside the current module. This is different
1496// from isEntryFunctionCC, which is only true for functions that are entered by
1497// the hardware. Module entry points include all entry functions but also
1498// include functions that can be called from other functions inside or outside
1499// the current module. Module entry functions are allowed to allocate LDS.
1500//
1501// AMDGPU_CS_Chain is intended for externally callable chain functions, so it is
1502// treated as a module entrypoint. AMDGPU_CS_ChainPreserve is used for internal
1503// helper functions (e.g. retry helpers), so it is not a module entrypoint.
1506 switch (CC) {
1509 return true;
1510 default:
1511 return isEntryFunctionCC(CC);
1512 }
1513}
1514
1516constexpr inline bool isKernel(CallingConv::ID CC) {
1517 switch (CC) {
1520 return true;
1521 default:
1522 return false;
1523 }
1524}
1525
1526inline bool isKernel(const Function &F) { return isKernel(F.getCallingConv()); }
1527
1530 return CC == CallingConv::Fast;
1531}
1532
1533/// Return true if we might ever do TCO for calls with this calling convention.
1536 switch (CC) {
1537 case CallingConv::C:
1540 return true;
1541 default:
1542 return canGuaranteeTCO(CC);
1543 }
1544}
1545
1546bool hasXNACK(const MCSubtargetInfo &STI);
1547bool hasMIMG_R128(const MCSubtargetInfo &STI);
1548bool hasA16(const MCSubtargetInfo &STI);
1549bool hasG16(const MCSubtargetInfo &STI);
1550bool hasPackedD16(const MCSubtargetInfo &STI);
1551bool hasGDS(const MCSubtargetInfo &STI);
1552unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler = false);
1553unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI);
1554
1555bool isSI(const MCSubtargetInfo &STI);
1556bool isCI(const MCSubtargetInfo &STI);
1557bool isVI(const MCSubtargetInfo &STI);
1558bool isGFX9(const MCSubtargetInfo &STI);
1559bool isGFX9_GFX10(const MCSubtargetInfo &STI);
1560bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI);
1561bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI);
1562bool isGFX8Plus(const MCSubtargetInfo &STI);
1563bool isGFX9Plus(const MCSubtargetInfo &STI);
1564bool isNotGFX9Plus(const MCSubtargetInfo &STI);
1565bool isGFX10(const MCSubtargetInfo &STI);
1566bool isGFX10_GFX11(const MCSubtargetInfo &STI);
1567bool isGFX10Plus(const MCSubtargetInfo &STI);
1568bool isNotGFX10Plus(const MCSubtargetInfo &STI);
1569bool isGFX10Before1030(const MCSubtargetInfo &STI);
1570bool isGFX11(const MCSubtargetInfo &STI);
1571bool isGFX11Plus(const MCSubtargetInfo &STI);
1572bool isGFX12(const MCSubtargetInfo &STI);
1573bool isGFX12Plus(const MCSubtargetInfo &STI);
1574bool isGFX1250(const MCSubtargetInfo &STI);
1575bool isGFX1250Plus(const MCSubtargetInfo &STI);
1576bool isGFX13(const MCSubtargetInfo &STI);
1577bool isGFX13Plus(const MCSubtargetInfo &STI);
1578bool supportsWGP(const MCSubtargetInfo &STI);
1579bool isNotGFX12Plus(const MCSubtargetInfo &STI);
1580bool isNotGFX11Plus(const MCSubtargetInfo &STI);
1581bool isGCN3Encoding(const MCSubtargetInfo &STI);
1582bool isGFX10_AEncoding(const MCSubtargetInfo &STI);
1583bool isGFX10_BEncoding(const MCSubtargetInfo &STI);
1584bool hasGFX10_3Insts(const MCSubtargetInfo &STI);
1585bool isGFX10_3_GFX11(const MCSubtargetInfo &STI);
1586bool isGFX90A(const MCSubtargetInfo &STI);
1587bool isGFX940(const MCSubtargetInfo &STI);
1589bool hasMAIInsts(const MCSubtargetInfo &STI);
1590bool hasVOPD(const MCSubtargetInfo &STI);
1591bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI);
1592
1593inline bool supportsWave32(const MCSubtargetInfo &STI) {
1594 return AMDGPU::isGFX10Plus(STI) && !AMDGPU::isGFX1250(STI);
1595}
1596
1597int getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR);
1598unsigned hasKernargPreload(const MCSubtargetInfo &STI);
1600
1601/// Is Reg - scalar register
1602bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI);
1603
1604/// \returns if \p Reg occupies the high 16-bits of a 32-bit register.
1605bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI);
1606
1607/// If \p Reg is a pseudo reg, return the correct hardware register given
1608/// \p STI otherwise return \p Reg.
1610
1611/// Convert hardware register \p Reg to a pseudo register
1614
1617
1618/// Is this an AMDGPU specific source operand? These include registers,
1619/// inline constants, literals and mandatory literals (KImm).
1620constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo) {
1621 return OpInfo.OperandType >= AMDGPU::OPERAND_SRC_FIRST &&
1622 OpInfo.OperandType <= AMDGPU::OPERAND_SRC_LAST;
1623}
1624
1625inline bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo) {
1626 return isSISrcOperand(Desc.operands()[OpNo]);
1627}
1628
1629/// Is this a KImm operand?
1630bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo);
1631
1632/// Is this floating-point operand?
1633bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo);
1634
1635/// Does this operand support only inlinable literals?
1636bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo);
1637
1638/// Get the size in bits of a register from the register class \p RC.
1639unsigned getRegBitWidth(unsigned RCID);
1640
1641/// Get the size in bits of a register from the register class \p RC.
1642unsigned getRegBitWidth(const MCRegisterClass &RC);
1643
1645inline unsigned getOperandSize(const MCOperandInfo &OpInfo) {
1646 switch (OpInfo.OperandType) {
1656 case AMDGPU::OPERAND_KIMM16: // mandatory literal is always size 4
1658 return 4;
1659
1668 return 8;
1669
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
1711bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi);
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
1757LLVM_READONLY bool isPackedFP32Inst(unsigned Opc);
1758
1759LLVM_READONLY bool isPacked64BitInst(unsigned Opc);
1760
1762
1765 int64_t EncodedOffset);
1766
1769 int64_t EncodedOffset, bool IsBuffer);
1770
1771/// Convert \p ByteOffset to dwords if the subtarget uses dword SMRD immediate
1772/// offsets.
1774
1775/// \returns The encoding that will be used for \p ByteOffset in the
1776/// SMRD offset field, or std::nullopt if it won't fit. On GFX9 and GFX10
1777/// S_LOAD instructions have a signed offset, on other subtargets it is
1778/// unsigned. S_BUFFER has an unsigned offset for all subtargets.
1779std::optional<int64_t> getSMRDEncodedOffset(const MCSubtargetInfo &ST,
1780 int64_t ByteOffset, bool IsBuffer,
1781 bool HasSOffset = false);
1782
1783/// \return The encoding that can be used for a 32-bit literal offset in an SMRD
1784/// instruction. This is only useful on CI.s
1785std::optional<int64_t> getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST,
1786 int64_t ByteOffset);
1787
1788/// For pre-GFX12 FLAT instructions the offset must be positive;
1789/// MSB is ignored and forced to zero.
1790///
1791/// \return The number of bits available for the signed offset field in flat
1792/// instructions. Note that some forms of the instruction disallow negative
1793/// offsets.
1794unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST);
1795
1797inline bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC) {
1798 if (isGFX12(ST))
1799 return DC >= DPP::ROW_SHARE_FIRST && DC <= DPP::ROW_SHARE_LAST;
1800 if (isGFX90A(ST))
1801 return DC >= DPP::ROW_NEWBCAST_FIRST && DC <= DPP::ROW_NEWBCAST_LAST;
1802 return false;
1803}
1804
1805/// \returns true if an instruction may have a 64-bit VGPR operand.
1807 const MCSubtargetInfo &ST);
1808
1809/// \returns true if an instruction is a DP ALU DPP without any 64-bit operands.
1810bool isDPALU_DPP32BitOpc(unsigned Opc);
1811
1812/// \returns true if an instruction is a DP ALU DPP.
1813bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII,
1814 const MCSubtargetInfo &ST);
1815
1816/// \returns true if the intrinsic is divergent
1817bool isIntrinsicSourceOfDivergence(unsigned IntrID);
1818
1819/// \returns true if the intrinsic is uniform
1820bool isIntrinsicAlwaysUniform(unsigned IntrID);
1821
1822/// \returns a register class for the physical register \p Reg if it is a VGPR
1823/// or nullptr otherwise.
1825 const MCRegisterInfo &MRI);
1826
1827/// \returns the MODE bits which have to be set by the S_SET_VGPR_MSB for the
1828/// physical register \p Reg.
1829unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI);
1830
1831/// If \p Reg is a low VGPR return a corresponding high VGPR with \p MSBs set.
1833 const MCRegisterInfo &MRI);
1834
1835/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1836/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1837/// ignored.
1838std::optional<unsigned> convertSetRegImmToVgprMSBs(const MachineInstr &MI,
1839 bool HasSetregVGPRMSBFixup);
1840
1841/// \returns VGPR MSBs encoded in a S_SETREG_IMM32_B32 \p MI if it sets
1842/// it. If \p HasSetregVGPRMSBFixup is true then size of the ID_MODE mask is
1843/// ignored.
1844std::optional<unsigned> convertSetRegImmToVgprMSBs(const MCInst &MI,
1845 bool HasSetregVGPRMSBFixup);
1846
1847// Returns a table for the opcode with a given \p Desc to map the VGPR MSB
1848// set by the S_SET_VGPR_MSB to one of 4 sources. In case of VOPD returns 2
1849// maps, one for X and one for Y component.
1850std::pair<const AMDGPU::OpName *, const AMDGPU::OpName *>
1852
1853/// \returns true if a memory instruction supports scale_offset modifier.
1854bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode);
1855
1856/// \returns lds block size in terms of dwords. \p
1857/// This is used to calculate the lds size encoded for PAL metadata 3.0+ which
1858/// must be defined in terms of bytes.
1859unsigned getLdsDwGranularity(const MCSubtargetInfo &ST);
1860
1862public:
1864
1865 ClusterDimsAttr() = default;
1866
1867 Kind getKind() const { return AttrKind; }
1868
1869 bool isUnknown() const { return getKind() == Kind::Unknown; }
1870
1871 bool isNoCluster() const { return getKind() == Kind::NoCluster; }
1872
1873 bool isFixedDims() const { return getKind() == Kind::FixedDims; }
1874
1875 bool isVariableDims() const { return getKind() == Kind::VariableDims; }
1876
1878
1880
1882
1883 /// \returns the dims stored. Note that this function can only be called if
1884 /// the kind is \p Fixed.
1885 const std::array<unsigned, 3> &getDims() const;
1886
1887 bool operator==(const ClusterDimsAttr &RHS) const {
1888 return AttrKind == RHS.AttrKind && Dims == RHS.Dims;
1889 }
1890
1891 std::string to_string() const;
1892
1893 static ClusterDimsAttr get(const Function &F);
1894
1895private:
1896 enum Encoding { EncoNoCluster = 0, EncoVariableDims = 1024 };
1897
1898 ClusterDimsAttr(Kind AttrKind) : AttrKind(AttrKind) {}
1899
1900 std::array<unsigned, 3> Dims = {0, 0, 0};
1901
1902 Kind AttrKind = Kind::Unknown;
1903};
1904
1905} // namespace AMDGPU
1906
1909
1910} // end namespace llvm
1911
1912#endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUBASEINFO_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Base class for AMDGPU specific classes of TargetSubtarget.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_READNONE
Definition Compiler.h:317
#define LLVM_READONLY
Definition Compiler.h:324
IRTranslator LLVM IR MI
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
Register Reg
Register const TargetRegisterInfo * TRI
This file contains some functions that are useful when dealing with strings.
Value * RHS
static ClusterDimsAttr get(const Function &F)
bool operator==(const ClusterDimsAttr &RHS) const
const std::array< unsigned, 3 > & getDims() const
void setXnackSetting(TargetIDSetting NewXnackSetting)
Sets xnack setting to NewXnackSetting.
TargetIDSetting getXnackSetting() const
void print(raw_ostream &OS) const
Write string representation to OS.
void setTargetIDFromTargetIDStream(StringRef TargetID)
void setSramEccSetting(TargetIDSetting NewSramEccSetting)
Sets sramecc setting to NewSramEccSetting.
TargetIDSetting getSramEccSetting() const
AMDGPUTargetID(const MCSubtargetInfo &STI, StringRef FeatureString)
unsigned getIndexInParsedOperands(unsigned CompOprIdx) const
ComponentInfo(const MCInstrDesc &OpDesc, ComponentKind Kind=ComponentKind::SINGLE, bool VOP3Layout=false)
ComponentInfo(const MCInstrDesc &OpDesc, const ComponentProps &OpXProps, bool VOP3Layout=false)
unsigned getIndexOfSrcInMCOperands(unsigned CompSrcIdx, bool VOPD3) const
ComponentLayout(const ComponentProps &OpXProps, unsigned VOPD3ModsNum, int BitOp3Idx)
unsigned getIndexOfSrcInParsedOperands(unsigned CompSrcIdx) const
ComponentLayout(ComponentKind Kind, unsigned VOPD3ModsNum, int BitOp3Idx)
bool hasRegSrcOperand(unsigned CompSrcIdx) const
unsigned getMandatoryLiteralCompOperandIndex() const
std::optional< unsigned > getInvalidCompOperandIndex(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false) const
InstInfo(const ComponentInfo &OprInfoX, const ComponentInfo &OprInfoY)
bool hasInvalidOperand(std::function< MCRegister(unsigned, unsigned)> GetRegIdx, const MCRegisterInfo &MRI, bool SkipSrc=false, bool AllowSameVGPR=false, bool VOPD3=false) const
const ComponentInfo & operator[](size_t ComponentIdx) const
InstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
std::array< MCRegister, Component::MAX_OPR_NUM > RegIndices
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
This holds information about one operand of a machine instruction, indicating the register class for ...
Definition MCInstrDesc.h:86
MCRegisterClass - Base class of TargetRegisterClass.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Generic base class for all target subtargets.
Metadata node.
Definition Metadata.h:1069
Representation of each machine instruction.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned decodeFieldVaVcc(unsigned Encoded)
unsigned encodeFieldVaVcc(unsigned Encoded, unsigned VaVcc)
unsigned decodeFieldHoldCnt(unsigned Encoded, const IsaVersion &Version)
bool decodeDepCtr(unsigned Code, int &Id, StringRef &Name, unsigned &Val, bool &IsDefault, const MCSubtargetInfo &STI)
unsigned encodeFieldHoldCnt(unsigned Encoded, unsigned HoldCnt, const IsaVersion &Version)
unsigned encodeFieldVaSsrc(unsigned Encoded, unsigned VaSsrc)
unsigned encodeFieldVaVdst(unsigned Encoded, unsigned VaVdst)
unsigned decodeFieldSaSdst(unsigned Encoded)
unsigned getHoldCntBitMask(const IsaVersion &Version)
unsigned decodeFieldVaSdst(unsigned Encoded)
unsigned encodeFieldVmVsrc(unsigned Encoded, unsigned VmVsrc)
unsigned decodeFieldVaSsrc(unsigned Encoded)
int encodeDepCtr(const StringRef Name, int64_t Val, unsigned &UsedOprMask, const MCSubtargetInfo &STI)
unsigned encodeFieldSaSdst(unsigned Encoded, unsigned SaSdst)
bool isSymbolicDepCtrEncoding(unsigned Code, bool &HasNonDefaultVal, const MCSubtargetInfo &STI)
unsigned decodeFieldVaVdst(unsigned Encoded)
int getDefaultDepCtrEncoding(const MCSubtargetInfo &STI)
unsigned decodeFieldVmVsrc(unsigned Encoded)
unsigned encodeFieldVaSdst(unsigned Encoded, unsigned VaSdst)
bool isSupportedTgtId(unsigned Id, const MCSubtargetInfo &STI)
bool getTgtName(unsigned Id, StringRef &Name, int &Index)
unsigned getTgtId(const StringRef Name)
Generic target versions emitted by this version of LLVM.
static constexpr unsigned GFX12_5
static constexpr unsigned GFX9_4
static constexpr unsigned GFX10_1
static constexpr unsigned GFX10_3
static constexpr unsigned GFX11
static constexpr unsigned GFX9
static constexpr unsigned GFX12
EncodingField< 10, 6 > HwregOffset
EncodingField< 5, 0 > HwregId
EncodingFields< HwregId, HwregOffset, HwregSize > HwregEncoding
unsigned getNumWavesPerEUWithNumVGPRs(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize)
unsigned getSGPRAllocGranule(const MCSubtargetInfo &STI)
unsigned getAddressableNumArchVGPRs(const MCSubtargetInfo &STI)
bool isSGPROccupancyLimited(const MCSubtargetInfo &STI)
unsigned getArchVGPRAllocGranule()
For subtargets with a unified VGPR file and mixed ArchVGPR/AGPR usage, returns the allocation granule...
unsigned getEUsPerCU(const MCSubtargetInfo &STI)
unsigned getTotalNumSGPRs(const MCSubtargetInfo &STI)
unsigned getAddressableNumSGPRs(const MCSubtargetInfo &STI)
unsigned getMinFlatWorkGroupSize(const MCSubtargetInfo &STI)
unsigned getAddressableLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getVGPREncodingGranule(const MCSubtargetInfo &STI, std::optional< bool > EnableWavefrontSize32)
unsigned getEncodedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, std::optional< bool > EnableWavefrontSize32)
unsigned getMaxWorkGroupsPerCU(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getMinNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU)
unsigned getMaxNumSGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, bool Addressable)
unsigned getWavefrontSize(const MCSubtargetInfo &STI)
unsigned getWavesPerEUForWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getInstCacheLineSize(const MCSubtargetInfo &STI)
constexpr unsigned getMaxFlatWorkGroupSize()
static constexpr unsigned MaxDynamicVGPRBlocks
Maximum number of VGPR blocks that can be allocated in dynamic VGPR mode.
unsigned getSGPREncodingGranule(const MCSubtargetInfo &STI)
unsigned getTotalNumVGPRs(const MCSubtargetInfo &STI)
unsigned getMinNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getAddressableNumVGPRs(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize)
unsigned getWavesPerWorkGroup(const MCSubtargetInfo &STI, unsigned FlatWorkGroupSize)
unsigned getAllocatedNumVGPRBlocks(const MCSubtargetInfo &STI, unsigned NumVGPRs, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs, unsigned MaxWaves, unsigned TotalNumSGPRs, unsigned Granule, unsigned TrapReserve)
unsigned getNumSGPRBlocks(const MCSubtargetInfo &STI, unsigned NumSGPRs)
unsigned getMaxWavesPerEU(const MCSubtargetInfo &STI)
unsigned getNumExtraSGPRs(const MCSubtargetInfo &STI, bool VCCUsed, bool FlatScrUsed, bool XNACKUsed)
raw_ostream & operator<<(raw_ostream &OS, const AMDGPUTargetID &TargetID)
unsigned getLocalMemorySize(const MCSubtargetInfo &STI)
unsigned getMaxNumVGPRs(const MCSubtargetInfo &STI, unsigned WavesPerEU, unsigned DynamicVGPRBlockSize)
unsigned getVGPRAllocGranule(const MCSubtargetInfo &STI, unsigned DynamicVGPRBlockSize, std::optional< bool > EnableWavefrontSize32)
unsigned getMinWavesPerEU(const MCSubtargetInfo &STI)
bool isValidUnifiedFormat(unsigned Id, const MCSubtargetInfo &STI)
unsigned getDefaultFormatEncoding(const MCSubtargetInfo &STI)
StringRef getUnifiedFormatName(unsigned Id, const MCSubtargetInfo &STI)
bool isValidNfmt(unsigned Id, const MCSubtargetInfo &STI)
bool isValidDfmtNfmt(unsigned Id, const MCSubtargetInfo &STI)
int64_t convertDfmtNfmt2Ufmt(unsigned Dfmt, unsigned Nfmt, const MCSubtargetInfo &STI)
StringRef getDfmtName(unsigned Id)
int64_t encodeDfmtNfmt(unsigned Dfmt, unsigned Nfmt)
int64_t getUnifiedFormat(const StringRef Name, const MCSubtargetInfo &STI)
bool isValidFormatEncoding(unsigned Val, const MCSubtargetInfo &STI)
StringRef getNfmtName(unsigned Id, const MCSubtargetInfo &STI)
int64_t getNfmt(const StringRef Name, const MCSubtargetInfo &STI)
int64_t getDfmt(const StringRef Name)
void decodeDfmtNfmt(unsigned Format, unsigned &Dfmt, unsigned &Nfmt)
uint64_t encodeMsg(uint64_t MsgId, uint64_t OpId, uint64_t StreamId)
bool msgSupportsStream(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI)
void decodeMsg(unsigned Val, uint16_t &MsgId, uint16_t &OpId, uint16_t &StreamId, const MCSubtargetInfo &STI)
bool isValidMsgId(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgStream(int64_t MsgId, int64_t OpId, int64_t StreamId, const MCSubtargetInfo &STI, bool Strict)
bool msgDoesNotUseM0(int64_t MsgId, const MCSubtargetInfo &STI)
Returns true if the message does not use the m0 operand.
bool msgRequiresOp(int64_t MsgId, const MCSubtargetInfo &STI)
bool isValidMsgOp(int64_t MsgId, int64_t OpId, const MCSubtargetInfo &STI, bool Strict)
constexpr unsigned VOPD_VGPR_BANK_MASKS[]
constexpr unsigned COMPONENTS_NUM
constexpr unsigned VOPD3_VGPR_BANK_MASKS[]
constexpr unsigned COMPONENTS[]
bool isPackedFP32Inst(unsigned Opc)
bool isGCN3Encoding(const MCSubtargetInfo &STI)
bool isInlinableLiteralBF16(int16_t Literal, bool HasInv2Pi)
bool isGFX10_BEncoding(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGG16MappingInfo * getMIMGG16MappingInfo(unsigned G)
bool isInlineValue(MCRegister Reg)
bool isGFX10_GFX11(const MCSubtargetInfo &STI)
bool isInlinableLiteralV216(uint32_t Literal, uint8_t OpType)
EncodingField< Bit, Bit, D > EncodingBit
bool isPKFMACF16InlineConstant(uint32_t Literal, bool IsGFX11Plus)
LLVM_READONLY const MIMGInfo * getMIMGInfo(unsigned Opc)
bool isInlinableLiteralFP16(int16_t Literal, bool HasInv2Pi)
bool isSGPR(MCRegister Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
uint64_t convertSMRDOffsetUnits(const MCSubtargetInfo &ST, uint64_t ByteOffset)
Convert ByteOffset to dwords if the subtarget uses dword SMRD immediate offsets.
MCRegister getMCReg(MCRegister Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg.
LLVM_READONLY const MIMGOffsetMappingInfo * getMIMGOffsetMappingInfo(unsigned Offset)
bool isVOPCAsmOnly(unsigned Opc)
int getMIMGOpcode(unsigned BaseOpcode, unsigned MIMGEncoding, unsigned VDataDwords, unsigned VAddrDwords)
bool getMTBUFHasSrsrc(unsigned Opc)
std::optional< int64_t > getSMRDEncodedLiteralOffset32(const MCSubtargetInfo &ST, int64_t ByteOffset)
bool getWMMAIsXDL(unsigned Opc)
static std::optional< unsigned > convertSetRegImmToVgprMSBs(unsigned Imm, unsigned Simm16, bool HasSetregVGPRMSBFixup)
uint8_t wmmaScaleF8F6F4FormatToNumRegs(unsigned Fmt)
bool isGFX10Before1030(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isShader(CallingConv::ID CC)
bool isSISrcInlinableOperand(const MCInstrDesc &Desc, unsigned OpNo)
Does this operand support only inlinable literals?
unsigned mapWMMA2AddrTo3AddrOpcode(unsigned Opc)
void initDefaultAMDKernelCodeT(AMDGPUMCKernelCodeT &KernelCode, const MCSubtargetInfo &STI)
bool shouldEmitConstantsToTextSection(const Triple &TT)
bool isInlinableLiteralV2I16(uint32_t Literal)
bool isDPMACCInstruction(unsigned Opc)
int getMTBUFElements(unsigned Opc)
bool isHi16Reg(MCRegister Reg, const MCRegisterInfo &MRI)
unsigned getTemporalHintType(const MCInstrDesc TID)
int32_t getTotalNumVGPRs(bool has90AInsts, int32_t ArgNumAGPR, int32_t ArgNumVGPR)
bool isGFX10(const MCSubtargetInfo &STI)
bool isInlinableLiteralV2BF16(uint32_t Literal)
unsigned getMaxNumUserSGPRs(const MCSubtargetInfo &STI)
FPType getFPDstSelType(unsigned Opc)
unsigned getNumFlatOffsetBits(const MCSubtargetInfo &ST)
For pre-GFX12 FLAT instructions the offset must be positive; MSB is ignored and forced to zero.
bool hasA16(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedSignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset, bool IsBuffer)
bool isGFX12Plus(const MCSubtargetInfo &STI)
unsigned getNSAMaxSize(const MCSubtargetInfo &STI, bool HasSampler)
const MCRegisterClass * getVGPRPhysRegClass(MCRegister Reg, const MCRegisterInfo &MRI)
LLVM_READNONE constexpr bool isModuleEntryFunctionCC(CallingConv::ID CC)
unsigned encodeLoadcntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool getHasMatrixScale(unsigned Opc)
bool hasPackedD16(const MCSubtargetInfo &STI)
unsigned getStorecntBitMask(const IsaVersion &Version)
unsigned getLdsDwGranularity(const MCSubtargetInfo &ST)
bool isGFX940(const MCSubtargetInfo &STI)
bool isInlinableLiteralV2F16(uint32_t Literal)
bool isHsaAbi(const MCSubtargetInfo &STI)
bool isGFX11(const MCSubtargetInfo &STI)
bool getSMEMIsBuffer(unsigned Opc)
bool isGFX10_3_GFX11(const MCSubtargetInfo &STI)
bool isGFX13(const MCSubtargetInfo &STI)
unsigned getAsynccntBitMask(const IsaVersion &Version)
bool hasValueInRangeLikeMetadata(const MDNode &MD, int64_t Val)
Checks if Val is inside MD, a !range-like metadata.
uint8_t mfmaScaleF8F6F4FormatToNumRegs(unsigned EncodingVal)
unsigned getVOPDOpcode(unsigned Opc, bool VOPD3)
bool isGroupSegment(const GlobalValue *GV)
LLVM_READONLY const MIMGMIPMappingInfo * getMIMGMIPMappingInfo(unsigned MIP)
bool getMTBUFHasSoffset(unsigned Opc)
bool hasXNACK(const MCSubtargetInfo &STI)
bool isValid32BitLiteral(uint64_t Val, bool IsFP64)
CanBeVOPD getCanBeVOPD(unsigned Opc, unsigned EncodingFamily, bool VOPD3)
LLVM_READNONE bool isLegalDPALU_DPPControl(const MCSubtargetInfo &ST, unsigned DC)
bool isVOPC64DPP(unsigned Opc)
int getMUBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool getMAIIsGFX940XDL(unsigned Opc)
bool isSI(const MCSubtargetInfo &STI)
unsigned getDefaultAMDHSACodeObjectVersion()
bool isReadOnlySegment(const GlobalValue *GV)
Waitcnt decodeWaitcnt(const IsaVersion &Version, unsigned Encoded)
bool isArgPassedInSGPR(const Argument *A)
LLVM_READNONE constexpr bool mayTailCallThisCC(CallingConv::ID CC)
Return true if we might ever do TCO for calls with this calling convention.
bool isIntrinsicAlwaysUniform(unsigned IntrID)
int getMUBUFBaseOpcode(unsigned Opc)
unsigned encodeWaitcnt(const IsaVersion &Version, const Waitcnt &Decoded)
unsigned getAMDHSACodeObjectVersion(const Module &M)
unsigned decodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getWaitcntBitMask(const IsaVersion &Version)
LLVM_READONLY bool hasNamedOperand(uint64_t Opcode, OpName NamedIdx)
bool getVOP3IsSingle(unsigned Opc)
bool isGFX9(const MCSubtargetInfo &STI)
bool isDPALU_DPP32BitOpc(unsigned Opc)
bool getVOP1IsSingle(unsigned Opc)
unsigned getVOPDEncodingFamily(const MCSubtargetInfo &ST)
bool isGFX10_AEncoding(const MCSubtargetInfo &STI)
bool isKImmOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this a KImm operand?
bool getHasColorExport(const Function &F)
int getMTBUFBaseOpcode(unsigned Opc)
bool isGFX90A(const MCSubtargetInfo &STI)
unsigned getSamplecntBitMask(const IsaVersion &Version)
unsigned getDefaultQueueImplicitArgPosition(unsigned CodeObjectVersion)
std::tuple< char, unsigned, unsigned > parseAsmPhysRegName(StringRef RegName)
Returns a valid charcode or 0 in the first entry if this is a valid physical register name.
bool getHasDepthExport(const Function &F)
bool isGFX8_GFX9_GFX10(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool isKernel(CallingConv::ID CC)
bool getMUBUFHasVAddr(unsigned Opc)
bool isTrue16Inst(unsigned Opc)
LLVM_READNONE constexpr bool isEntryFunctionCC(CallingConv::ID CC)
unsigned getVGPREncodingMSBs(MCRegister Reg, const MCRegisterInfo &MRI)
std::pair< unsigned, unsigned > getVOPDComponents(unsigned VOPDOpcode)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByEncoding(uint8_t DimEnc)
bool isInlinableLiteral32(int32_t Literal, bool HasInv2Pi)
LLVM_READNONE constexpr bool isCompute(CallingConv::ID CC)
bool isGFX12(const MCSubtargetInfo &STI)
unsigned getInitialPSInputAddr(const Function &F)
unsigned encodeExpcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Expcnt)
bool isAsyncStore(unsigned Opc)
unsigned getDynamicVGPRBlockSize(const Function &F)
unsigned getKmcntBitMask(const IsaVersion &Version)
MCRegister getVGPRWithMSBs(MCRegister Reg, unsigned MSBs, const MCRegisterInfo &MRI)
If Reg is a low VGPR return a corresponding high VGPR with MSBs set.
unsigned getVmcntBitMask(const IsaVersion &Version)
bool isNotGFX10Plus(const MCSubtargetInfo &STI)
bool hasMAIInsts(const MCSubtargetInfo &STI)
unsigned getBitOp2(unsigned Opc)
bool isIntrinsicSourceOfDivergence(unsigned IntrID)
constexpr bool isSISrcOperand(const MCOperandInfo &OpInfo)
Is this an AMDGPU specific source operand?
unsigned getXcntBitMask(const IsaVersion &Version)
bool isGenericAtomic(unsigned Opc)
const MFMA_F8F6F4_Info * getWMMA_F8F6F4_WithFormatArgs(unsigned FmtA, unsigned FmtB, unsigned F8F8Opcode)
bool isGFX8Plus(const MCSubtargetInfo &STI)
LLVM_READNONE bool isInlinableIntLiteral(int64_t Literal)
Is this literal inlinable, and not one of the values intended for floating point values.
unsigned getLgkmcntBitMask(const IsaVersion &Version)
bool getMUBUFTfe(unsigned Opc)
LLVM_READONLY const MIMGBiasMappingInfo * getMIMGBiasMappingInfo(unsigned Bias)
unsigned getBvhcntBitMask(const IsaVersion &Version)
bool hasSMRDSignedImmOffset(const MCSubtargetInfo &ST)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfoByAsmSuffix(StringRef AsmSuffix)
bool hasMIMG_R128(const MCSubtargetInfo &STI)
bool hasGFX10_3Insts(const MCSubtargetInfo &STI)
unsigned decodeDscnt(const IsaVersion &Version, unsigned Waitcnt)
std::pair< const AMDGPU::OpName *, const AMDGPU::OpName * > getVGPRLoweringOperandTables(const MCInstrDesc &Desc)
bool hasG16(const MCSubtargetInfo &STI)
unsigned getAddrSizeMIMGOp(const MIMGBaseOpcodeInfo *BaseOpcode, const MIMGDimInfo *Dim, bool IsA16, bool IsG16Supported)
int getMTBUFOpcode(unsigned BaseOpc, unsigned Elements)
bool isGFX13Plus(const MCSubtargetInfo &STI)
unsigned getExpcntBitMask(const IsaVersion &Version)
bool hasArchitectedFlatScratch(const MCSubtargetInfo &STI)
int32_t getMCOpcode(uint32_t Opcode, unsigned Gen)
bool getMUBUFHasSoffset(unsigned Opc)
bool isNotGFX11Plus(const MCSubtargetInfo &STI)
bool isGFX11Plus(const MCSubtargetInfo &STI)
std::optional< unsigned > getInlineEncodingV2F16(uint32_t Literal)
bool isSISrcFPOperand(const MCInstrDesc &Desc, unsigned OpNo)
Is this floating-point operand?
std::tuple< char, unsigned, unsigned > parseAsmConstraintPhysReg(StringRef Constraint)
Returns a valid charcode or 0 in the first entry if this is a valid physical register constraint.
unsigned getHostcallImplicitArgPosition(unsigned CodeObjectVersion)
bool isPackedFP32or64BitInst(unsigned Opc)
bool isGFX10Plus(const MCSubtargetInfo &STI)
std::optional< int64_t > getSMRDEncodedOffset(const MCSubtargetInfo &ST, int64_t ByteOffset, bool IsBuffer, bool HasSOffset)
bool isGlobalSegment(const GlobalValue *GV)
int64_t encode32BitLiteral(int64_t Imm, OperandType Type, bool IsLit)
bool isValidWMMAScaleFmtCombination(unsigned AFmt, unsigned AScale, unsigned BFmt, unsigned BScale)
@ OPERAND_REG_IMM_V2FP64
Definition SIDefines.h:430
@ OPERAND_KIMM32
Operand with 32-bit immediate that uses the constant bus.
Definition SIDefines.h:448
@ OPERAND_REG_IMM_INT64
Definition SIDefines.h:416
@ OPERAND_REG_IMM_V2FP16
Definition SIDefines.h:423
@ OPERAND_REG_INLINE_C_FP64
Definition SIDefines.h:439
@ OPERAND_REG_INLINE_C_BF16
Definition SIDefines.h:436
@ OPERAND_REG_INLINE_C_V2BF16
Definition SIDefines.h:441
@ OPERAND_REG_IMM_V2INT64
Definition SIDefines.h:426
@ OPERAND_REG_IMM_V2INT16
Definition SIDefines.h:425
@ OPERAND_REG_IMM_BF16
Definition SIDefines.h:420
@ OPERAND_REG_IMM_INT32
Operands with register, 32-bit, or 64-bit immediate.
Definition SIDefines.h:415
@ OPERAND_REG_IMM_V2BF16
Definition SIDefines.h:422
@ OPERAND_REG_IMM_FP16
Definition SIDefines.h:421
@ OPERAND_REG_IMM_V2FP16_SPLAT
Definition SIDefines.h:424
@ OPERAND_REG_INLINE_C_INT64
Definition SIDefines.h:435
@ OPERAND_REG_INLINE_C_INT16
Operands with register or inline constant.
Definition SIDefines.h:433
@ OPERAND_REG_IMM_NOINLINE_V2FP16
Definition SIDefines.h:427
@ OPERAND_REG_IMM_FP64
Definition SIDefines.h:419
@ OPERAND_REG_INLINE_C_V2FP16
Definition SIDefines.h:442
@ OPERAND_REG_INLINE_AC_INT32
Operands with an AccVGPR register or inline constant.
Definition SIDefines.h:453
@ OPERAND_REG_INLINE_AC_FP32
Definition SIDefines.h:454
@ OPERAND_REG_IMM_V2INT32
Definition SIDefines.h:428
@ OPERAND_REG_IMM_FP32
Definition SIDefines.h:418
@ OPERAND_REG_INLINE_C_FP32
Definition SIDefines.h:438
@ OPERAND_REG_INLINE_C_INT32
Definition SIDefines.h:434
@ OPERAND_REG_INLINE_C_V2INT16
Definition SIDefines.h:440
@ OPERAND_REG_IMM_V2FP32
Definition SIDefines.h:429
@ OPERAND_REG_INLINE_AC_FP64
Definition SIDefines.h:455
@ OPERAND_REG_INLINE_C_FP16
Definition SIDefines.h:437
@ OPERAND_REG_IMM_INT16
Definition SIDefines.h:417
@ OPERAND_INLINE_SPLIT_BARRIER_INT32
Definition SIDefines.h:445
std::optional< unsigned > getPKFMACF16InlineEncoding(uint32_t Literal, bool IsGFX11Plus)
bool isNotGFX9Plus(const MCSubtargetInfo &STI)
LLVM_READONLY const MIMGLZMappingInfo * getMIMGLZMappingInfo(unsigned L)
bool isDPALU_DPP(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
LLVM_READONLY int32_t getSOPPWithRelaxation(uint32_t Opcode)
bool hasGDS(const MCSubtargetInfo &STI)
bool isLegalSMRDEncodedUnsignedOffset(const MCSubtargetInfo &ST, int64_t EncodedOffset)
bool isGFX9Plus(const MCSubtargetInfo &STI)
bool hasDPPSrc1SGPR(const MCSubtargetInfo &STI)
bool isVOPD(unsigned Opc)
VOPD::InstInfo getVOPDInstInfo(const MCInstrDesc &OpX, const MCInstrDesc &OpY)
unsigned encodeVmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Vmcnt)
unsigned decodeExpcnt(const IsaVersion &Version, unsigned Waitcnt)
bool isCvt_F32_Fp8_Bf8_e64(unsigned Opc)
std::optional< unsigned > getInlineEncodingV2I16(uint32_t Literal)
unsigned getRegBitWidth(const TargetRegisterClass &RC)
Get the size in bits of a register from the register class RC.
unsigned encodeStorecntDscnt(const IsaVersion &Version, const Waitcnt &Decoded)
bool isGFX1250(const MCSubtargetInfo &STI)
bool supportsWave32(const MCSubtargetInfo &STI)
const MIMGBaseOpcodeInfo * getMIMGBaseOpcode(unsigned Opc)
bool isVI(const MCSubtargetInfo &STI)
bool isTensorStore(unsigned Opc)
LLVM_READONLY const MIMGDimInfo * getMIMGDimInfo(unsigned DimEnum)
bool getMUBUFIsBufferInv(unsigned Opc)
bool supportsScaleOffset(const MCInstrInfo &MII, unsigned Opcode)
MCRegister mc2PseudoReg(MCRegister Reg)
Convert hardware register Reg to a pseudo register.
std::optional< unsigned > getInlineEncodingV2BF16(uint32_t Literal)
unsigned hasKernargPreload(const MCSubtargetInfo &STI)
bool supportsWGP(const MCSubtargetInfo &STI)
bool isMAC(unsigned Opc)
LLVM_READNONE unsigned getOperandSize(const MCOperandInfo &OpInfo)
bool isCI(const MCSubtargetInfo &STI)
unsigned encodeLgkmcnt(const IsaVersion &Version, unsigned Waitcnt, unsigned Lgkmcnt)
bool getVOP2IsSingle(unsigned Opc)
bool getMAIIsDGEMM(unsigned Opc)
Returns true if MAI operation is a double precision GEMM.
LLVM_READONLY const MIMGBaseOpcodeInfo * getMIMGBaseOpcodeInfo(unsigned BaseOpcode)
unsigned getCompletionActionImplicitArgPosition(unsigned CodeObjectVersion)
SmallVector< unsigned > getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size, unsigned DefaultVal)
bool isPacked64BitInst(unsigned Opc)
LLVM_READNONE constexpr bool isChainCC(CallingConv::ID CC)
unsigned decodeStorecnt(const IsaVersion &Version, unsigned Waitcnt)
bool isGFX1250Plus(const MCSubtargetInfo &STI)
int getMaskedMIMGOp(unsigned Opc, unsigned NewChannels)
bool isNotGFX12Plus(const MCSubtargetInfo &STI)
bool getMTBUFHasVAddr(unsigned Opc)
unsigned decodeVmcnt(const IsaVersion &Version, unsigned Waitcnt)
uint8_t getELFABIVersion(const Triple &T, unsigned CodeObjectVersion)
std::pair< unsigned, unsigned > getIntegerPairAttribute(const Function &F, StringRef Name, std::pair< unsigned, unsigned > Default, bool OnlyFirstRequired)
unsigned getLoadcntBitMask(const IsaVersion &Version)
bool isInlinableLiteralI16(int32_t Literal, bool HasInv2Pi)
bool hasVOPD(const MCSubtargetInfo &STI)
LLVM_READNONE constexpr bool canGuaranteeTCO(CallingConv::ID CC)
LLVM_READNONE constexpr bool isGraphics(CallingConv::ID CC)
int getVOPDFull(unsigned OpX, unsigned OpY, unsigned EncodingFamily, bool VOPD3)
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi)
Is this literal inlinable.
const MFMA_F8F6F4_Info * getMFMA_F8F6F4_WithFormatArgs(unsigned CBSZ, unsigned BLGP, unsigned F8F8Opcode)
unsigned decodeLoadcnt(const IsaVersion &Version, unsigned Waitcnt)
unsigned getMultigridSyncArgImplicitArgPosition(unsigned CodeObjectVersion)
bool isGFX9_GFX10_GFX11(const MCSubtargetInfo &STI)
bool isGFX9_GFX10(const MCSubtargetInfo &STI)
int getMUBUFElements(unsigned Opc)
const GcnBufferFormatInfo * getGcnBufferFormatInfo(uint8_t BitsPerComp, uint8_t NumComponents, uint8_t NumFormat, const MCSubtargetInfo &STI)
unsigned mapWMMA3AddrTo2AddrOpcode(unsigned Opc)
bool isPermlane16(unsigned Opc)
bool getMUBUFHasSrsrc(unsigned Opc)
unsigned getDscntBitMask(const IsaVersion &Version)
bool hasAny64BitVGPROperands(const MCInstrDesc &OpDesc, const MCInstrInfo &MII, const MCSubtargetInfo &ST)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ AMDGPU_CS
Used for Mesa/AMDPAL compute shaders.
@ AMDGPU_VS
Used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (vertex shader if tess...
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
@ AMDGPU_Gfx
Used for AMD graphics targets.
@ AMDGPU_CS_ChainPreserve
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_HS
Used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
@ AMDGPU_GS
Used for Mesa/AMDPAL geometry shaders.
@ AMDGPU_CS_Chain
Used on AMDGPUs to give the middle-end more control over argument placement.
@ AMDGPU_PS
Used for Mesa/AMDPAL pixel shaders.
@ SPIR_KERNEL
Used for SPIR kernel functions.
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition CallingConv.h:41
@ AMDGPU_ES
Used for AMDPAL shader stage before geometry shader if geometry is in use.
@ AMDGPU_LS
Used for AMDPAL vertex shader if tessellation is in use.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:558
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
Definition MathExtras.h:207
Op::Description Desc
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:334
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
@ Default
The result value is uniform if and only if all operands are uniform.
Definition Uniformity.h:20
AMD Kernel Code Object (amd_kernel_code_t).
constexpr EncodingField(ValueType Value)
static ValueType decode(uint64_t Encoded)
constexpr uint64_t encode() const
static constexpr uint64_t encode(Fields... Values)
static std::tuple< typename Fields::ValueType... > decode(uint64_t Encoded)
constexpr EncodingField(ValueType Value)
constexpr uint64_t encode() const
static ValueType decode(uint64_t Encoded)
Instruction set architecture version.