1 //===-- SIDefines.h - SI Helper Macros ----------------------*- C++ -*-===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
11 #define LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
13 #include "llvm/MC/MCInstrDesc.h"
17 // This needs to be kept in sync with the field bits in SIRegisterClass.
18 enum SIRCFlags
: uint8_t {
19 RegTupleAlignUnitsWidth
= 2,
20 HasVGPRBit
= RegTupleAlignUnitsWidth
,
24 HasVGPR
= 1 << HasVGPRBit
,
25 HasAGPR
= 1 << HasAGPRBit
,
26 HasSGPR
= 1 << HasSGPRbit
,
28 RegTupleAlignUnitsMask
= (1 << RegTupleAlignUnitsWidth
) - 1,
29 RegKindMask
= (HasVGPR
| HasAGPR
| HasSGPR
)
32 namespace SIEncodingFamily
{
33 // This must be kept in sync with the SIEncodingFamily class in SIInstrInfo.td
34 // and the columns of the getMCOpcodeGen table.
51 namespace SIInstrFlags
{
52 // This needs to be kept in sync with the field bits in InstSI.
54 // Low bits - basic encoding information.
58 // SALU instruction formats.
65 // VALU instruction formats.
70 // TODO: Should this be spilt into VOP3 a and b?
79 // Memory instruction formats.
90 // Pseudo instruction formats.
94 // LDSDIR instruction format.
97 // VINTERP instruction format.
100 // High bits - other information.
101 VM_CNT
= UINT64_C(1) << 32,
102 EXP_CNT
= UINT64_C(1) << 33,
103 LGKM_CNT
= UINT64_C(1) << 34,
105 WQM
= UINT64_C(1) << 35,
106 DisableWQM
= UINT64_C(1) << 36,
107 Gather4
= UINT64_C(1) << 37,
108 SOPK_ZEXT
= UINT64_C(1) << 38,
109 SCALAR_STORE
= UINT64_C(1) << 39,
110 FIXED_SIZE
= UINT64_C(1) << 40,
111 VOPAsmPrefer32Bit
= UINT64_C(1) << 41,
112 VOP3_OPSEL
= UINT64_C(1) << 42,
113 maybeAtomic
= UINT64_C(1) << 43,
114 renamedInGFX9
= UINT64_C(1) << 44,
116 // Is a clamp on FP type.
117 FPClamp
= UINT64_C(1) << 45,
119 // Is an integer clamp
120 IntClamp
= UINT64_C(1) << 46,
122 // Clamps lo component of register.
123 ClampLo
= UINT64_C(1) << 47,
125 // Clamps hi component of register.
126 // ClampLo and ClampHi set for packed clamp.
127 ClampHi
= UINT64_C(1) << 48,
129 // Is a packed VOP3P instruction.
130 IsPacked
= UINT64_C(1) << 49,
132 // Is a D16 buffer instruction.
133 D16Buf
= UINT64_C(1) << 50,
135 // FLAT instruction accesses FLAT_GLBL segment.
136 FlatGlobal
= UINT64_C(1) << 51,
138 // Uses floating point double precision rounding mode
139 FPDPRounding
= UINT64_C(1) << 52,
141 // Instruction is FP atomic.
142 FPAtomic
= UINT64_C(1) << 53,
144 // Is a MFMA instruction.
145 IsMAI
= UINT64_C(1) << 54,
147 // Is a DOT instruction.
148 IsDOT
= UINT64_C(1) << 55,
150 // FLAT instruction accesses FLAT_SCRATCH segment.
151 FlatScratch
= UINT64_C(1) << 56,
153 // Atomic without return.
154 IsAtomicNoRet
= UINT64_C(1) << 57,
156 // Atomic with return.
157 IsAtomicRet
= UINT64_C(1) << 58,
159 // Is a WMMA instruction.
160 IsWMMA
= UINT64_C(1) << 59,
162 // Whether tied sources will be read.
163 TiedSourceNotRead
= UINT64_C(1) << 60,
166 IsNeverUniform
= UINT64_C(1) << 61,
168 // ds_gws_* instructions.
169 GWS
= UINT64_C(1) << 62,
172 // v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
173 // The result is true if any of these tests are true.
174 enum ClassFlags
: unsigned {
175 S_NAN
= 1 << 0, // Signaling NaN
176 Q_NAN
= 1 << 1, // Quiet NaN
177 N_INFINITY
= 1 << 2, // Negative infinity
178 N_NORMAL
= 1 << 3, // Negative normal
179 N_SUBNORMAL
= 1 << 4, // Negative subnormal
180 N_ZERO
= 1 << 5, // Negative zero
181 P_ZERO
= 1 << 6, // Positive zero
182 P_SUBNORMAL
= 1 << 7, // Positive subnormal
183 P_NORMAL
= 1 << 8, // Positive normal
184 P_INFINITY
= 1 << 9 // Positive infinity
189 enum OperandType
: unsigned {
190 /// Operands with register or 32-bit immediate
191 OPERAND_REG_IMM_INT32
= MCOI::OPERAND_FIRST_TARGET
,
192 OPERAND_REG_IMM_INT64
,
193 OPERAND_REG_IMM_INT16
,
194 OPERAND_REG_IMM_FP32
,
195 OPERAND_REG_IMM_FP64
,
196 OPERAND_REG_IMM_FP16
,
197 OPERAND_REG_IMM_FP16_DEFERRED
,
198 OPERAND_REG_IMM_FP32_DEFERRED
,
199 OPERAND_REG_IMM_V2FP16
,
200 OPERAND_REG_IMM_V2INT16
,
201 OPERAND_REG_IMM_V2INT32
,
202 OPERAND_REG_IMM_V2FP32
,
204 /// Operands with register or inline constant
205 OPERAND_REG_INLINE_C_INT16
,
206 OPERAND_REG_INLINE_C_INT32
,
207 OPERAND_REG_INLINE_C_INT64
,
208 OPERAND_REG_INLINE_C_FP16
,
209 OPERAND_REG_INLINE_C_FP32
,
210 OPERAND_REG_INLINE_C_FP64
,
211 OPERAND_REG_INLINE_C_V2INT16
,
212 OPERAND_REG_INLINE_C_V2FP16
,
213 OPERAND_REG_INLINE_C_V2INT32
,
214 OPERAND_REG_INLINE_C_V2FP32
,
216 /// Operand with 32-bit immediate that uses the constant bus.
220 /// Operands with an AccVGPR register or inline constant
221 OPERAND_REG_INLINE_AC_INT16
,
222 OPERAND_REG_INLINE_AC_INT32
,
223 OPERAND_REG_INLINE_AC_FP16
,
224 OPERAND_REG_INLINE_AC_FP32
,
225 OPERAND_REG_INLINE_AC_FP64
,
226 OPERAND_REG_INLINE_AC_V2INT16
,
227 OPERAND_REG_INLINE_AC_V2FP16
,
228 OPERAND_REG_INLINE_AC_V2INT32
,
229 OPERAND_REG_INLINE_AC_V2FP32
,
231 // Operand for source modifiers for VOP instructions
234 // Operand for SDWA instructions
235 OPERAND_SDWA_VOPC_DST
,
237 OPERAND_REG_IMM_FIRST
= OPERAND_REG_IMM_INT32
,
238 OPERAND_REG_IMM_LAST
= OPERAND_REG_IMM_V2FP32
,
240 OPERAND_REG_INLINE_C_FIRST
= OPERAND_REG_INLINE_C_INT16
,
241 OPERAND_REG_INLINE_C_LAST
= OPERAND_REG_INLINE_AC_V2FP32
,
243 OPERAND_REG_INLINE_AC_FIRST
= OPERAND_REG_INLINE_AC_INT16
,
244 OPERAND_REG_INLINE_AC_LAST
= OPERAND_REG_INLINE_AC_V2FP32
,
246 OPERAND_SRC_FIRST
= OPERAND_REG_IMM_INT32
,
247 OPERAND_SRC_LAST
= OPERAND_REG_INLINE_C_LAST
,
249 OPERAND_KIMM_FIRST
= OPERAND_KIMM32
,
250 OPERAND_KIMM_LAST
= OPERAND_KIMM16
255 // Input operand modifiers bit-masks
256 // NEG and SEXT share same bit-mask because they can't be set simultaneously.
257 namespace SISrcMods
{
260 NEG
= 1 << 0, // Floating-point negate modifier
261 ABS
= 1 << 1, // Floating-point absolute modifier
262 SEXT
= 1 << 0, // Integer sign-extend modifier
263 NEG_HI
= ABS
, // Floating-point negate high packed component modifier.
266 DST_OP_SEL
= 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
270 namespace SIOutMods
{
280 namespace VGPRIndexMode
{
282 enum Id
: unsigned { // id of symbolic names
292 enum EncBits
: unsigned {
294 SRC0_ENABLE
= 1 << ID_SRC0
,
295 SRC1_ENABLE
= 1 << ID_SRC1
,
296 SRC2_ENABLE
= 1 << ID_SRC2
,
297 DST_ENABLE
= 1 << ID_DST
,
298 ENABLE_MASK
= SRC0_ENABLE
| SRC1_ENABLE
| SRC2_ENABLE
| DST_ENABLE
,
302 } // namespace VGPRIndexMode
303 } // namespace AMDGPU
305 namespace AMDGPUAsmVariants
{
314 } // namespace AMDGPUAsmVariants
317 namespace EncValues
{ // Encoding values of enum9/8/7 operands
322 SGPR_MAX_GFX10
= 105,
325 TTMP_GFX9PLUS_MIN
= 108,
326 TTMP_GFX9PLUS_MAX
= 123,
327 INLINE_INTEGER_C_MIN
= 128,
328 INLINE_INTEGER_C_POSITIVE_MAX
= 192, // 64
329 INLINE_INTEGER_C_MAX
= 208,
330 INLINE_FLOATING_C_MIN
= 240,
331 INLINE_FLOATING_C_MAX
= 248,
335 IS_VGPR
= 256, // Indicates VGPR or AGPR
338 } // namespace EncValues
340 // Register codes as defined in the TableGen's HWEncoding field.
341 namespace HWEncoding
{
344 IS_VGPR_OR_AGPR
= 1 << 8,
345 IS_HI
= 1 << 9, // High 16-bit register.
347 } // namespace HWEncoding
359 ALL_pregfx12
= GLC
| SLC
| DLC
| SCC
,
362 // Below are GFX12+ cache policy bits
365 TH
= 0x7, // All TH bits
366 TH_RT
= 0, // regular
367 TH_NT
= 1, // non-temporal
368 TH_HT
= 2, // high-temporal
369 TH_LU
= 3, // last use
370 TH_RT_WB
= 3, // regular (CU, SE), high-temporal with write-back (MALL)
371 TH_NT_RT
= 4, // non-temporal (CU, SE), regular (MALL)
372 TH_RT_NT
= 5, // regular (CU, SE), non-temporal (MALL)
373 TH_NT_HT
= 6, // non-temporal (CU, SE), high-temporal (MALL)
374 TH_NT_WB
= 7, // non-temporal (CU, SE), high-temporal with write-back (MALL)
375 TH_BYPASS
= 3, // only to be used with scope = 3
377 TH_RESERVED
= 7, // unused value for load insts
379 // Bits of TH for atomics
380 TH_ATOMIC_RETURN
= GLC
, // Returning vs non-returning
381 TH_ATOMIC_NT
= SLC
, // Non-temporal vs regular
382 TH_ATOMIC_CASCADE
= 4, // Cascading vs regular
385 SCOPE
= 0x3 << 3, // All Scope bits
391 SWZ
= 1 << 6, // Swizzle bit
396 TH_TYPE_LOAD
= 1 << 7, // TH_LOAD policy
397 TH_TYPE_STORE
= 1 << 8, // TH_STORE policy
398 TH_TYPE_ATOMIC
= 1 << 9, // TH_ATOMIC policy
399 TH_REAL_BYPASS
= 1 << 10, // is TH=3 bypass policy or not
404 namespace SendMsg
{ // Encoding of SIMM16 used in s_sendmsg* insns.
406 enum Id
{ // Message ID, width(4) [3:0].
409 ID_GS_PreGFX11
= 2, // replaced in GFX11
410 ID_GS_DONE_PreGFX11
= 3, // replaced in GFX11
412 ID_HS_TESSFACTOR_GFX11Plus
= 2, // reused in GFX11
413 ID_DEALLOC_VGPRS_GFX11Plus
= 3, // reused in GFX11
415 ID_SAVEWAVE
= 4, // added in GFX8, removed in GFX11
416 ID_STALL_WAVE_GEN
= 5, // added in GFX9, removed in GFX12
417 ID_HALT_WAVES
= 6, // added in GFX9, removed in GFX12
418 ID_ORDERED_PS_DONE
= 7, // added in GFX9, removed in GFX11
419 ID_EARLY_PRIM_DEALLOC
= 8, // added in GFX9, removed in GFX10
420 ID_GS_ALLOC_REQ
= 9, // added in GFX9
421 ID_GET_DOORBELL
= 10, // added in GFX9, removed in GFX11
422 ID_GET_DDID
= 11, // added in GFX10, removed in GFX11
425 ID_RTN_GET_DOORBELL
= 128,
426 ID_RTN_GET_DDID
= 129,
427 ID_RTN_GET_TMA
= 130,
428 ID_RTN_GET_REALTIME
= 131,
429 ID_RTN_SAVE_WAVE
= 132,
430 ID_RTN_GET_TBA
= 133,
431 ID_RTN_GET_SE_AID_ID
= 134,
433 ID_MASK_PreGFX11_
= 0xF,
434 ID_MASK_GFX11Plus_
= 0xFF
437 enum Op
{ // Both GS and SYS operation IDs.
441 // Bits used for operation encoding
443 OP_MASK_
= (((1 << OP_WIDTH_
) - 1) << OP_SHIFT_
),
444 // GS operations are encoded in bits 5:4
450 OP_GS_FIRST_
= OP_GS_NOP
,
451 // SYS operations are encoded in bits 6:4
452 OP_SYS_ECC_ERR_INTERRUPT
= 1,
454 OP_SYS_HOST_TRAP_ACK
= 3,
455 OP_SYS_TTRACE_PC
= 4,
457 OP_SYS_FIRST_
= OP_SYS_ECC_ERR_INTERRUPT
,
460 enum StreamId
: unsigned { // Stream ID, (2) [9:8].
462 STREAM_ID_DEFAULT_
= 0,
464 STREAM_ID_FIRST_
= STREAM_ID_DEFAULT_
,
465 STREAM_ID_SHIFT_
= 8,
467 STREAM_ID_MASK_
= (((1 << STREAM_ID_WIDTH_
) - 1) << STREAM_ID_SHIFT_
)
470 } // namespace SendMsg
472 namespace Hwreg
{ // Encoding of SIMM16 used in s_setreg/getreg* insns.
474 enum Id
{ // HwRegCode, (6) [5:0]
482 ID_PERF_SNAPSHOT_DATA_gfx12
= 10,
483 ID_PERF_SNAPSHOT_PC_LO_gfx12
= 11,
484 ID_PERF_SNAPSHOT_PC_HI_gfx12
= 12,
496 ID_PERF_SNAPSHOT_DATA_gfx11
= 27,
497 ID_SHADER_CYCLES
= 29,
498 ID_SHADER_CYCLES_HI
= 30,
499 ID_DVGPR_ALLOC_LO
= 31,
500 ID_DVGPR_ALLOC_HI
= 32,
502 // Register numbers reused in GFX11
503 ID_PERF_SNAPSHOT_PC_LO_gfx11
= 18,
504 ID_PERF_SNAPSHOT_PC_HI_gfx11
= 19,
506 // Register numbers reused in GFX12+
508 ID_PERF_SNAPSHOT_DATA1
= 15,
509 ID_PERF_SNAPSHOT_DATA2
= 16,
510 ID_EXCP_FLAG_PRIV
= 17,
511 ID_EXCP_FLAG_USER
= 18,
514 // GFX940 specific registers
516 ID_SQ_PERF_SNAPSHOT_DATA
= 21,
517 ID_SQ_PERF_SNAPSHOT_DATA1
= 22,
518 ID_SQ_PERF_SNAPSHOT_PC_LO
= 23,
519 ID_SQ_PERF_SNAPSHOT_PC_HI
= 24,
523 ID_MASK_
= (((1 << ID_WIDTH_
) - 1) << ID_SHIFT_
)
526 enum Offset
: unsigned { // Offset, (5) [10:6]
530 OFFSET_MASK_
= (((1 << OFFSET_WIDTH_
) - 1) << OFFSET_SHIFT_
),
535 enum WidthMinusOne
: unsigned { // WidthMinusOne, (5) [15:11]
536 WIDTH_M1_DEFAULT_
= 31,
537 WIDTH_M1_SHIFT_
= 11,
539 WIDTH_M1_MASK_
= (((1 << WIDTH_M1_WIDTH_
) - 1) << WIDTH_M1_SHIFT_
),
542 // Some values from WidthMinusOne mapped into Width domain.
543 enum Width
: unsigned {
544 WIDTH_DEFAULT_
= WIDTH_M1_DEFAULT_
+ 1,
547 enum ModeRegisterMasks
: uint32_t {
548 FP_ROUND_MASK
= 0xf << 0, // Bits 0..3
549 FP_DENORM_MASK
= 0xf << 4, // Bits 4..7
550 DX10_CLAMP_MASK
= 1 << 8,
551 IEEE_MODE_MASK
= 1 << 9,
552 LOD_CLAMP_MASK
= 1 << 10,
553 DEBUG_MASK
= 1 << 11,
556 EXCP_EN_INVALID_MASK
= 1 << 12,
557 EXCP_EN_INPUT_DENORMAL_MASK
= 1 << 13,
558 EXCP_EN_FLOAT_DIV0_MASK
= 1 << 14,
559 EXCP_EN_OVERFLOW_MASK
= 1 << 15,
560 EXCP_EN_UNDERFLOW_MASK
= 1 << 16,
561 EXCP_EN_INEXACT_MASK
= 1 << 17,
562 EXCP_EN_INT_DIV0_MASK
= 1 << 18,
564 GPR_IDX_EN_MASK
= 1 << 27,
565 VSKIP_MASK
= 1 << 28,
566 CSP_MASK
= 0x7u
<< 29 // Bits 29..31
571 namespace MTBUFFormat
{
573 enum DataFormat
: int64_t {
591 DFMT_MIN
= DFMT_INVALID
,
592 DFMT_MAX
= DFMT_RESERVED_15
,
595 DFMT_DEFAULT
= DFMT_8
,
601 enum NumFormat
: int64_t {
608 NFMT_RESERVED_6
, // VI and GFX9
609 NFMT_SNORM_OGL
= NFMT_RESERVED_6
, // SI and CI only
612 NFMT_MIN
= NFMT_UNORM
,
613 NFMT_MAX
= NFMT_FLOAT
,
616 NFMT_DEFAULT
= NFMT_UNORM
,
622 enum MergedFormat
: int64_t {
623 DFMT_NFMT_UNDEF
= -1,
624 DFMT_NFMT_DEFAULT
= ((DFMT_DEFAULT
& DFMT_MASK
) << DFMT_SHIFT
) |
625 ((NFMT_DEFAULT
& NFMT_MASK
) << NFMT_SHIFT
),
628 DFMT_NFMT_MASK
= (DFMT_MASK
<< DFMT_SHIFT
) | (NFMT_MASK
<< NFMT_SHIFT
),
630 DFMT_NFMT_MAX
= DFMT_NFMT_MASK
633 enum UnifiedFormatCommon
: int64_t {
639 } // namespace MTBUFFormat
641 namespace UfmtGFX10
{
642 enum UnifiedFormat
: int64_t {
681 UFMT_10_11_11_USCALED
,
682 UFMT_10_11_11_SSCALED
,
689 UFMT_11_11_10_USCALED
,
690 UFMT_11_11_10_SSCALED
,
695 UFMT_10_10_10_2_UNORM
,
696 UFMT_10_10_10_2_SNORM
,
697 UFMT_10_10_10_2_USCALED
,
698 UFMT_10_10_10_2_SSCALED
,
699 UFMT_10_10_10_2_UINT
,
700 UFMT_10_10_10_2_SINT
,
702 UFMT_2_10_10_10_UNORM
,
703 UFMT_2_10_10_10_SNORM
,
704 UFMT_2_10_10_10_USCALED
,
705 UFMT_2_10_10_10_SSCALED
,
706 UFMT_2_10_10_10_UINT
,
707 UFMT_2_10_10_10_SINT
,
711 UFMT_8_8_8_8_USCALED
,
712 UFMT_8_8_8_8_SSCALED
,
720 UFMT_16_16_16_16_UNORM
,
721 UFMT_16_16_16_16_SNORM
,
722 UFMT_16_16_16_16_USCALED
,
723 UFMT_16_16_16_16_SSCALED
,
724 UFMT_16_16_16_16_UINT
,
725 UFMT_16_16_16_16_SINT
,
726 UFMT_16_16_16_16_FLOAT
,
731 UFMT_32_32_32_32_UINT
,
732 UFMT_32_32_32_32_SINT
,
733 UFMT_32_32_32_32_FLOAT
,
735 UFMT_FIRST
= UFMT_INVALID
,
736 UFMT_LAST
= UFMT_32_32_32_32_FLOAT
,
739 } // namespace UfmtGFX10
741 namespace UfmtGFX11
{
742 enum UnifiedFormat
: int64_t {
783 UFMT_10_10_10_2_UNORM
,
784 UFMT_10_10_10_2_SNORM
,
785 UFMT_10_10_10_2_UINT
,
786 UFMT_10_10_10_2_SINT
,
788 UFMT_2_10_10_10_UNORM
,
789 UFMT_2_10_10_10_SNORM
,
790 UFMT_2_10_10_10_USCALED
,
791 UFMT_2_10_10_10_SSCALED
,
792 UFMT_2_10_10_10_UINT
,
793 UFMT_2_10_10_10_SINT
,
797 UFMT_8_8_8_8_USCALED
,
798 UFMT_8_8_8_8_SSCALED
,
806 UFMT_16_16_16_16_UNORM
,
807 UFMT_16_16_16_16_SNORM
,
808 UFMT_16_16_16_16_USCALED
,
809 UFMT_16_16_16_16_SSCALED
,
810 UFMT_16_16_16_16_UINT
,
811 UFMT_16_16_16_16_SINT
,
812 UFMT_16_16_16_16_FLOAT
,
817 UFMT_32_32_32_32_UINT
,
818 UFMT_32_32_32_32_SINT
,
819 UFMT_32_32_32_32_FLOAT
,
821 UFMT_FIRST
= UFMT_INVALID
,
822 UFMT_LAST
= UFMT_32_32_32_32_FLOAT
,
825 } // namespace UfmtGFX11
827 namespace Swizzle
{ // Encoding of swizzle macro used in ds_swizzle_b32.
829 enum Id
: unsigned { // id of symbolic names
837 enum EncBits
: unsigned {
839 // swizzle mode encodings
841 QUAD_PERM_ENC
= 0x8000,
842 QUAD_PERM_ENC_MASK
= 0xFF00,
844 BITMASK_PERM_ENC
= 0x0000,
845 BITMASK_PERM_ENC_MASK
= 0x8000,
847 // QUAD_PERM encodings
850 LANE_MAX
= LANE_MASK
,
854 // BITMASK_PERM encodings
857 BITMASK_MAX
= BITMASK_MASK
,
860 BITMASK_AND_SHIFT
= 0,
861 BITMASK_OR_SHIFT
= 5,
862 BITMASK_XOR_SHIFT
= 10
865 } // namespace Swizzle
869 enum SdwaSel
: unsigned {
879 enum DstUnused
: unsigned {
885 enum SDWA9EncValues
: unsigned {
886 SRC_SGPR_MASK
= 0x100,
887 SRC_VGPR_MASK
= 0xFF,
888 VOPC_DST_VCC_MASK
= 0x80,
889 VOPC_DST_SGPR_MASK
= 0x7F,
894 SRC_SGPR_MAX_SI
= 357,
895 SRC_SGPR_MAX_GFX10
= 361,
905 enum DppCtrl
: unsigned {
907 QUAD_PERM_ID
= 0xE4, // identity permutation
908 QUAD_PERM_LAST
= 0xFF,
911 ROW_SHL_FIRST
= 0x101,
912 ROW_SHL_LAST
= 0x10F,
915 ROW_SHR_FIRST
= 0x111,
916 ROW_SHR_LAST
= 0x11F,
919 ROW_ROR_FIRST
= 0x121,
920 ROW_ROR_LAST
= 0x12F,
922 DPP_UNUSED4_FIRST
= 0x131,
923 DPP_UNUSED4_LAST
= 0x133,
925 DPP_UNUSED5_FIRST
= 0x135,
926 DPP_UNUSED5_LAST
= 0x137,
928 DPP_UNUSED6_FIRST
= 0x139,
929 DPP_UNUSED6_LAST
= 0x13B,
931 DPP_UNUSED7_FIRST
= 0x13D,
932 DPP_UNUSED7_LAST
= 0x13F,
934 ROW_HALF_MIRROR
= 0x141,
937 DPP_UNUSED8_FIRST
= 0x144,
938 DPP_UNUSED8_LAST
= 0x14F,
939 ROW_NEWBCAST_FIRST
= 0x150,
940 ROW_NEWBCAST_LAST
= 0x15F,
942 ROW_SHARE_FIRST
= 0x150,
943 ROW_SHARE_LAST
= 0x15F,
945 ROW_XMASK_FIRST
= 0x160,
946 ROW_XMASK_LAST
= 0x16F,
947 DPP_LAST
= ROW_XMASK_LAST
962 enum Target
: unsigned {
966 ET_NULL
= 9, // Pre-GFX11
969 ET_POS4
= 16, // GFX10+
970 ET_POS_LAST
= ET_POS4
, // Highest pos used on any subtarget
971 ET_PRIM
= 20, // GFX10+
972 ET_DUAL_SRC_BLEND0
= 21, // GFX11+
973 ET_DUAL_SRC_BLEND1
= 22, // GFX11+
974 ET_PARAM0
= 32, // Pre-GFX11
975 ET_PARAM31
= 63, // Pre-GFX11
982 ET_DUAL_SRC_BLEND_MAX_IDX
= 1,
983 ET_PARAM_MAX_IDX
= 31,
990 namespace VOP3PEncoding
{
992 enum OpSel
: uint64_t {
993 OP_SEL_HI_0
= UINT64_C(1) << 59,
994 OP_SEL_HI_1
= UINT64_C(1) << 60,
995 OP_SEL_HI_2
= UINT64_C(1) << 14,
998 } // namespace VOP3PEncoding
1000 namespace ImplicitArg
{
1001 // Implicit kernel argument offset for code object version 5.
1002 enum Offset_COV5
: unsigned {
1003 HOSTCALL_PTR_OFFSET
= 80,
1004 MULTIGRID_SYNC_ARG_OFFSET
= 88,
1005 HEAP_PTR_OFFSET
= 96,
1007 DEFAULT_QUEUE_OFFSET
= 104,
1008 COMPLETION_ACTION_OFFSET
= 112,
1010 PRIVATE_BASE_OFFSET
= 192,
1011 SHARED_BASE_OFFSET
= 196,
1012 QUEUE_PTR_OFFSET
= 200,
1015 } // namespace ImplicitArg
1017 namespace VirtRegFlag
{
1018 // Virtual register flags used for various target specific handlings during
1020 enum Register_Flag
: uint8_t {
1021 // Register operand in a whole-wave mode operation.
1025 } // namespace VirtRegFlag
1027 } // namespace AMDGPU
1029 #define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
1030 #define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
1031 #define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
1032 #define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
1033 #define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1034 #define C_00B028_MEM_ORDERED 0xFDFFFFFF
1036 #define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
1037 #define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
1038 #define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
1039 #define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
1040 #define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
1041 #define C_00B128_MEM_ORDERED 0xF7FFFFFF
1043 #define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
1044 #define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
1045 #define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
1046 #define C_00B228_WGP_MODE 0xF7FFFFFF
1047 #define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
1048 #define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
1049 #define C_00B228_MEM_ORDERED 0xFDFFFFFF
1051 #define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
1052 #define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
1053 #define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
1054 #define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
1055 #define C_00B428_WGP_MODE 0xFBFFFFFF
1056 #define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
1057 #define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
1058 #define C_00B428_MEM_ORDERED 0xFEFFFFFF
1060 #define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
1062 #define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
1063 #define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
1064 #define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
1065 #define C_00B84C_SCRATCH_EN 0xFFFFFFFE
1066 #define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
1067 #define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
1068 #define C_00B84C_USER_SGPR 0xFFFFFFC1
1069 #define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
1070 #define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
1071 #define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
1072 #define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
1073 #define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
1074 #define C_00B84C_TGID_X_EN 0xFFFFFF7F
1075 #define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
1076 #define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
1077 #define C_00B84C_TGID_Y_EN 0xFFFFFEFF
1078 #define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
1079 #define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
1080 #define C_00B84C_TGID_Z_EN 0xFFFFFDFF
1081 #define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
1082 #define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
1083 #define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
1084 #define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
1085 #define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
1086 #define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
1088 #define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
1089 #define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
1090 #define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
1092 #define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
1093 #define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
1094 #define C_00B84C_LDS_SIZE 0xFF007FFF
1095 #define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
1096 #define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
1097 #define C_00B84C_EXCP_EN
1099 #define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
1100 #define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
1102 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
1103 #define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
1104 #define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
1105 #define C_00B848_VGPRS 0xFFFFFFC0
1106 #define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
1107 #define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
1108 #define C_00B848_SGPRS 0xFFFFFC3F
1109 #define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
1110 #define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
1111 #define C_00B848_PRIORITY 0xFFFFF3FF
1112 #define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
1113 #define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
1114 #define C_00B848_FLOAT_MODE 0xFFF00FFF
1115 #define S_00B848_PRIV(x) (((x) & 0x1) << 20)
1116 #define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
1117 #define C_00B848_PRIV 0xFFEFFFFF
1118 #define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
1119 #define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
1120 #define C_00B848_DX10_CLAMP 0xFFDFFFFF
1121 #define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
1122 #define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
1123 #define C_00B848_DEBUG_MODE 0xFFBFFFFF
1124 #define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
1125 #define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
1126 #define C_00B848_IEEE_MODE 0xFF7FFFFF
1127 #define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
1128 #define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
1129 #define C_00B848_WGP_MODE 0xDFFFFFFF
1130 #define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
1131 #define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
1132 #define C_00B848_MEM_ORDERED 0xBFFFFFFF
1133 #define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
1134 #define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
1135 #define C_00B848_FWD_PROGRESS 0x7FFFFFFF
1138 // Helpers for setting FLOAT_MODE
1139 #define FP_ROUND_ROUND_TO_NEAREST 0
1140 #define FP_ROUND_ROUND_TO_INF 1
1141 #define FP_ROUND_ROUND_TO_NEGINF 2
1142 #define FP_ROUND_ROUND_TO_ZERO 3
1144 // Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
1146 #define FP_ROUND_MODE_SP(x) ((x) & 0x3)
1147 #define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
1149 #define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
1150 #define FP_DENORM_FLUSH_OUT 1
1151 #define FP_DENORM_FLUSH_IN 2
1152 #define FP_DENORM_FLUSH_NONE 3
1155 // Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
1157 #define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
1158 #define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
1160 #define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
1161 #define S_00B860_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1162 #define S_00B860_WAVESIZE_GFX11Plus(x) (((x) & 0x7FFF) << 12)
1164 #define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
1165 #define S_0286E8_WAVESIZE_PreGFX11(x) (((x) & 0x1FFF) << 12)
1166 #define S_0286E8_WAVESIZE_GFX11Plus(x) (((x) & 0x7FFF) << 12)
1168 #define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
1169 #define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
1170 #define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
1171 #define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
1172 #define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
1173 #define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
1174 #define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
1175 #define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
1177 #define R_SPILLED_SGPRS 0x4
1178 #define R_SPILLED_VGPRS 0x8
1179 } // End namespace llvm