[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / Target / AMDGPU / SIDefines.h
blobd3c0d792804da37e47a267be1fa5b3c9375bc804
1 //===-- SIDefines.h - SI Helper Macros ----------------------*- 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 /// \file
8 //===----------------------------------------------------------------------===//
10 #include "llvm/MC/MCInstrDesc.h"
12 #ifndef LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
13 #define LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
15 namespace llvm {
17 namespace SIInstrFlags {
18 // This needs to be kept in sync with the field bits in InstSI.
19 enum : uint64_t {
20 // Low bits - basic encoding information.
21 SALU = 1 << 0,
22 VALU = 1 << 1,
24 // SALU instruction formats.
25 SOP1 = 1 << 2,
26 SOP2 = 1 << 3,
27 SOPC = 1 << 4,
28 SOPK = 1 << 5,
29 SOPP = 1 << 6,
31 // VALU instruction formats.
32 VOP1 = 1 << 7,
33 VOP2 = 1 << 8,
34 VOPC = 1 << 9,
36 // TODO: Should this be spilt into VOP3 a and b?
37 VOP3 = 1 << 10,
38 VOP3P = 1 << 12,
40 VINTRP = 1 << 13,
41 SDWA = 1 << 14,
42 DPP = 1 << 15,
43 TRANS = 1 << 16,
45 // Memory instruction formats.
46 MUBUF = 1 << 17,
47 MTBUF = 1 << 18,
48 SMRD = 1 << 19,
49 MIMG = 1 << 20,
50 EXP = 1 << 21,
51 FLAT = 1 << 22,
52 DS = 1 << 23,
54 // Pseudo instruction formats.
55 VGPRSpill = 1 << 24,
56 SGPRSpill = 1 << 25,
58 // High bits - other information.
59 VM_CNT = UINT64_C(1) << 32,
60 EXP_CNT = UINT64_C(1) << 33,
61 LGKM_CNT = UINT64_C(1) << 34,
63 WQM = UINT64_C(1) << 35,
64 DisableWQM = UINT64_C(1) << 36,
65 Gather4 = UINT64_C(1) << 37,
66 SOPK_ZEXT = UINT64_C(1) << 38,
67 SCALAR_STORE = UINT64_C(1) << 39,
68 FIXED_SIZE = UINT64_C(1) << 40,
69 VOPAsmPrefer32Bit = UINT64_C(1) << 41,
70 VOP3_OPSEL = UINT64_C(1) << 42,
71 maybeAtomic = UINT64_C(1) << 43,
72 renamedInGFX9 = UINT64_C(1) << 44,
74 // Is a clamp on FP type.
75 FPClamp = UINT64_C(1) << 45,
77 // Is an integer clamp
78 IntClamp = UINT64_C(1) << 46,
80 // Clamps lo component of register.
81 ClampLo = UINT64_C(1) << 47,
83 // Clamps hi component of register.
84 // ClampLo and ClampHi set for packed clamp.
85 ClampHi = UINT64_C(1) << 48,
87 // Is a packed VOP3P instruction.
88 IsPacked = UINT64_C(1) << 49,
90 // Is a D16 buffer instruction.
91 D16Buf = UINT64_C(1) << 50,
93 // FLAT instruction accesses FLAT_GLBL segment.
94 FlatGlobal = UINT64_C(1) << 51,
96 // Uses floating point double precision rounding mode
97 FPDPRounding = UINT64_C(1) << 52,
99 // Instruction is FP atomic.
100 FPAtomic = UINT64_C(1) << 53,
102 // Is a MFMA instruction.
103 IsMAI = UINT64_C(1) << 54,
105 // Is a DOT instruction.
106 IsDOT = UINT64_C(1) << 55,
108 // FLAT instruction accesses FLAT_SCRATCH segment.
109 FlatScratch = UINT64_C(1) << 56,
111 // Atomic without return.
112 IsAtomicNoRet = UINT64_C(1) << 57,
114 // Atomic with return.
115 IsAtomicRet = UINT64_C(1) << 58
118 // v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
119 // The result is true if any of these tests are true.
120 enum ClassFlags : unsigned {
121 S_NAN = 1 << 0, // Signaling NaN
122 Q_NAN = 1 << 1, // Quiet NaN
123 N_INFINITY = 1 << 2, // Negative infinity
124 N_NORMAL = 1 << 3, // Negative normal
125 N_SUBNORMAL = 1 << 4, // Negative subnormal
126 N_ZERO = 1 << 5, // Negative zero
127 P_ZERO = 1 << 6, // Positive zero
128 P_SUBNORMAL = 1 << 7, // Positive subnormal
129 P_NORMAL = 1 << 8, // Positive normal
130 P_INFINITY = 1 << 9 // Positive infinity
134 namespace AMDGPU {
135 enum OperandType : unsigned {
136 /// Operands with register or 32-bit immediate
137 OPERAND_REG_IMM_INT32 = MCOI::OPERAND_FIRST_TARGET,
138 OPERAND_REG_IMM_INT64,
139 OPERAND_REG_IMM_INT16,
140 OPERAND_REG_IMM_FP32,
141 OPERAND_REG_IMM_FP64,
142 OPERAND_REG_IMM_FP16,
143 OPERAND_REG_IMM_V2FP16,
144 OPERAND_REG_IMM_V2INT16,
145 OPERAND_REG_IMM_V2INT32,
146 OPERAND_REG_IMM_V2FP32,
148 /// Operands with register or inline constant
149 OPERAND_REG_INLINE_C_INT16,
150 OPERAND_REG_INLINE_C_INT32,
151 OPERAND_REG_INLINE_C_INT64,
152 OPERAND_REG_INLINE_C_FP16,
153 OPERAND_REG_INLINE_C_FP32,
154 OPERAND_REG_INLINE_C_FP64,
155 OPERAND_REG_INLINE_C_V2INT16,
156 OPERAND_REG_INLINE_C_V2FP16,
157 OPERAND_REG_INLINE_C_V2INT32,
158 OPERAND_REG_INLINE_C_V2FP32,
160 /// Operands with an AccVGPR register or inline constant
161 OPERAND_REG_INLINE_AC_INT16,
162 OPERAND_REG_INLINE_AC_INT32,
163 OPERAND_REG_INLINE_AC_FP16,
164 OPERAND_REG_INLINE_AC_FP32,
165 OPERAND_REG_INLINE_AC_FP64,
166 OPERAND_REG_INLINE_AC_V2INT16,
167 OPERAND_REG_INLINE_AC_V2FP16,
168 OPERAND_REG_INLINE_AC_V2INT32,
169 OPERAND_REG_INLINE_AC_V2FP32,
171 OPERAND_REG_IMM_FIRST = OPERAND_REG_IMM_INT32,
172 OPERAND_REG_IMM_LAST = OPERAND_REG_IMM_V2FP32,
174 OPERAND_REG_INLINE_C_FIRST = OPERAND_REG_INLINE_C_INT16,
175 OPERAND_REG_INLINE_C_LAST = OPERAND_REG_INLINE_AC_V2FP32,
177 OPERAND_REG_INLINE_AC_FIRST = OPERAND_REG_INLINE_AC_INT16,
178 OPERAND_REG_INLINE_AC_LAST = OPERAND_REG_INLINE_AC_V2FP32,
180 OPERAND_SRC_FIRST = OPERAND_REG_IMM_INT32,
181 OPERAND_SRC_LAST = OPERAND_REG_INLINE_C_LAST,
183 // Operand for source modifiers for VOP instructions
184 OPERAND_INPUT_MODS,
186 // Operand for SDWA instructions
187 OPERAND_SDWA_VOPC_DST,
189 /// Operand with 32-bit immediate that uses the constant bus.
190 OPERAND_KIMM32,
191 OPERAND_KIMM16
195 // Input operand modifiers bit-masks
196 // NEG and SEXT share same bit-mask because they can't be set simultaneously.
197 namespace SISrcMods {
198 enum : unsigned {
199 NEG = 1 << 0, // Floating-point negate modifier
200 ABS = 1 << 1, // Floating-point absolute modifier
201 SEXT = 1 << 0, // Integer sign-extend modifier
202 NEG_HI = ABS, // Floating-point negate high packed component modifier.
203 OP_SEL_0 = 1 << 2,
204 OP_SEL_1 = 1 << 3,
205 DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
209 namespace SIOutMods {
210 enum : unsigned {
211 NONE = 0,
212 MUL2 = 1,
213 MUL4 = 2,
214 DIV2 = 3
218 namespace AMDGPU {
219 namespace VGPRIndexMode {
221 enum Id : unsigned { // id of symbolic names
222 ID_SRC0 = 0,
223 ID_SRC1,
224 ID_SRC2,
225 ID_DST,
227 ID_MIN = ID_SRC0,
228 ID_MAX = ID_DST
231 enum EncBits : unsigned {
232 OFF = 0,
233 SRC0_ENABLE = 1 << ID_SRC0,
234 SRC1_ENABLE = 1 << ID_SRC1,
235 SRC2_ENABLE = 1 << ID_SRC2,
236 DST_ENABLE = 1 << ID_DST,
237 ENABLE_MASK = SRC0_ENABLE | SRC1_ENABLE | SRC2_ENABLE | DST_ENABLE,
238 UNDEF = 0xFFFF
241 } // namespace VGPRIndexMode
242 } // namespace AMDGPU
244 namespace AMDGPUAsmVariants {
245 enum : unsigned {
246 DEFAULT = 0,
247 VOP3 = 1,
248 SDWA = 2,
249 SDWA9 = 3,
250 DPP = 4
254 namespace AMDGPU {
255 namespace EncValues { // Encoding values of enum9/8/7 operands
257 enum : unsigned {
258 SGPR_MIN = 0,
259 SGPR_MAX_SI = 101,
260 SGPR_MAX_GFX10 = 105,
261 TTMP_VI_MIN = 112,
262 TTMP_VI_MAX = 123,
263 TTMP_GFX9PLUS_MIN = 108,
264 TTMP_GFX9PLUS_MAX = 123,
265 INLINE_INTEGER_C_MIN = 128,
266 INLINE_INTEGER_C_POSITIVE_MAX = 192, // 64
267 INLINE_INTEGER_C_MAX = 208,
268 INLINE_FLOATING_C_MIN = 240,
269 INLINE_FLOATING_C_MAX = 248,
270 LITERAL_CONST = 255,
271 VGPR_MIN = 256,
272 VGPR_MAX = 511
275 } // namespace EncValues
276 } // namespace AMDGPU
278 namespace AMDGPU {
279 namespace CPol {
281 enum CPol {
282 GLC = 1,
283 SLC = 2,
284 DLC = 4,
285 SCC = 16,
286 ALL = GLC | SLC | DLC | SCC
289 } // namespace CPol
291 namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
293 enum Id { // Message ID, width(4) [3:0].
294 ID_UNKNOWN_ = -1,
295 ID_INTERRUPT = 1,
296 ID_GS = 2,
297 ID_GS_DONE = 3,
298 ID_SAVEWAVE = 4, // added in GFX8
299 ID_STALL_WAVE_GEN = 5, // added in GFX9
300 ID_HALT_WAVES = 6, // added in GFX9
301 ID_ORDERED_PS_DONE = 7, // added in GFX9
302 ID_EARLY_PRIM_DEALLOC = 8, // added in GFX9, removed in GFX10
303 ID_GS_ALLOC_REQ = 9, // added in GFX9
304 ID_GET_DOORBELL = 10, // added in GFX9
305 ID_GET_DDID = 11, // added in GFX10
306 ID_SYSMSG = 15,
307 ID_GAPS_LAST_, // Indicate that sequence has gaps.
308 ID_GAPS_FIRST_ = ID_INTERRUPT,
309 ID_SHIFT_ = 0,
310 ID_WIDTH_ = 4,
311 ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
314 enum Op { // Both GS and SYS operation IDs.
315 OP_UNKNOWN_ = -1,
316 OP_SHIFT_ = 4,
317 OP_NONE_ = 0,
318 // Bits used for operation encoding
319 OP_WIDTH_ = 3,
320 OP_MASK_ = (((1 << OP_WIDTH_) - 1) << OP_SHIFT_),
321 // GS operations are encoded in bits 5:4
322 OP_GS_NOP = 0,
323 OP_GS_CUT = 1,
324 OP_GS_EMIT = 2,
325 OP_GS_EMIT_CUT = 3,
326 OP_GS_LAST_,
327 OP_GS_FIRST_ = OP_GS_NOP,
328 // SYS operations are encoded in bits 6:4
329 OP_SYS_ECC_ERR_INTERRUPT = 1,
330 OP_SYS_REG_RD = 2,
331 OP_SYS_HOST_TRAP_ACK = 3,
332 OP_SYS_TTRACE_PC = 4,
333 OP_SYS_LAST_,
334 OP_SYS_FIRST_ = OP_SYS_ECC_ERR_INTERRUPT,
337 enum StreamId : unsigned { // Stream ID, (2) [9:8].
338 STREAM_ID_NONE_ = 0,
339 STREAM_ID_DEFAULT_ = 0,
340 STREAM_ID_LAST_ = 4,
341 STREAM_ID_FIRST_ = STREAM_ID_DEFAULT_,
342 STREAM_ID_SHIFT_ = 8,
343 STREAM_ID_WIDTH_= 2,
344 STREAM_ID_MASK_ = (((1 << STREAM_ID_WIDTH_) - 1) << STREAM_ID_SHIFT_)
347 } // namespace SendMsg
349 namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
351 enum Id { // HwRegCode, (6) [5:0]
352 ID_UNKNOWN_ = -1,
353 ID_SYMBOLIC_FIRST_ = 1, // There are corresponding symbolic names defined.
354 ID_MODE = 1,
355 ID_STATUS = 2,
356 ID_TRAPSTS = 3,
357 ID_HW_ID = 4,
358 ID_GPR_ALLOC = 5,
359 ID_LDS_ALLOC = 6,
360 ID_IB_STS = 7,
361 ID_MEM_BASES = 15,
362 ID_SYMBOLIC_FIRST_GFX9_ = ID_MEM_BASES,
363 ID_TBA_LO = 16,
364 ID_SYMBOLIC_FIRST_GFX10_ = ID_TBA_LO,
365 ID_TBA_HI = 17,
366 ID_TMA_LO = 18,
367 ID_TMA_HI = 19,
368 ID_FLAT_SCR_LO = 20,
369 ID_FLAT_SCR_HI = 21,
370 ID_XNACK_MASK = 22,
371 ID_POPS_PACKER = 25,
372 ID_SHADER_CYCLES = 29,
373 ID_SYMBOLIC_FIRST_GFX1030_ = ID_SHADER_CYCLES,
374 ID_SYMBOLIC_LAST_ = 30,
375 ID_SHIFT_ = 0,
376 ID_WIDTH_ = 6,
377 ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
380 enum Offset : unsigned { // Offset, (5) [10:6]
381 OFFSET_DEFAULT_ = 0,
382 OFFSET_SHIFT_ = 6,
383 OFFSET_WIDTH_ = 5,
384 OFFSET_MASK_ = (((1 << OFFSET_WIDTH_) - 1) << OFFSET_SHIFT_),
386 OFFSET_MEM_VIOL = 8,
388 OFFSET_SRC_SHARED_BASE = 16,
389 OFFSET_SRC_PRIVATE_BASE = 0
392 enum WidthMinusOne : unsigned { // WidthMinusOne, (5) [15:11]
393 WIDTH_M1_DEFAULT_ = 31,
394 WIDTH_M1_SHIFT_ = 11,
395 WIDTH_M1_WIDTH_ = 5,
396 WIDTH_M1_MASK_ = (((1 << WIDTH_M1_WIDTH_) - 1) << WIDTH_M1_SHIFT_),
398 WIDTH_M1_SRC_SHARED_BASE = 15,
399 WIDTH_M1_SRC_PRIVATE_BASE = 15
402 // Some values from WidthMinusOne mapped into Width domain.
403 enum Width : unsigned {
404 WIDTH_DEFAULT_ = WIDTH_M1_DEFAULT_ + 1,
407 enum ModeRegisterMasks : uint32_t {
408 FP_ROUND_MASK = 0xf << 0, // Bits 0..3
409 FP_DENORM_MASK = 0xf << 4, // Bits 4..7
410 DX10_CLAMP_MASK = 1 << 8,
411 IEEE_MODE_MASK = 1 << 9,
412 LOD_CLAMP_MASK = 1 << 10,
413 DEBUG_MASK = 1 << 11,
415 // EXCP_EN fields.
416 EXCP_EN_INVALID_MASK = 1 << 12,
417 EXCP_EN_INPUT_DENORMAL_MASK = 1 << 13,
418 EXCP_EN_FLOAT_DIV0_MASK = 1 << 14,
419 EXCP_EN_OVERFLOW_MASK = 1 << 15,
420 EXCP_EN_UNDERFLOW_MASK = 1 << 16,
421 EXCP_EN_INEXACT_MASK = 1 << 17,
422 EXCP_EN_INT_DIV0_MASK = 1 << 18,
424 GPR_IDX_EN_MASK = 1 << 27,
425 VSKIP_MASK = 1 << 28,
426 CSP_MASK = 0x7u << 29 // Bits 29..31
429 } // namespace Hwreg
431 namespace MTBUFFormat {
433 enum DataFormat : int64_t {
434 DFMT_INVALID = 0,
435 DFMT_8,
436 DFMT_16,
437 DFMT_8_8,
438 DFMT_32,
439 DFMT_16_16,
440 DFMT_10_11_11,
441 DFMT_11_11_10,
442 DFMT_10_10_10_2,
443 DFMT_2_10_10_10,
444 DFMT_8_8_8_8,
445 DFMT_32_32,
446 DFMT_16_16_16_16,
447 DFMT_32_32_32,
448 DFMT_32_32_32_32,
449 DFMT_RESERVED_15,
451 DFMT_MIN = DFMT_INVALID,
452 DFMT_MAX = DFMT_RESERVED_15,
454 DFMT_UNDEF = -1,
455 DFMT_DEFAULT = DFMT_8,
457 DFMT_SHIFT = 0,
458 DFMT_MASK = 0xF
461 enum NumFormat : int64_t {
462 NFMT_UNORM = 0,
463 NFMT_SNORM,
464 NFMT_USCALED,
465 NFMT_SSCALED,
466 NFMT_UINT,
467 NFMT_SINT,
468 NFMT_RESERVED_6, // VI and GFX9
469 NFMT_SNORM_OGL = NFMT_RESERVED_6, // SI and CI only
470 NFMT_FLOAT,
472 NFMT_MIN = NFMT_UNORM,
473 NFMT_MAX = NFMT_FLOAT,
475 NFMT_UNDEF = -1,
476 NFMT_DEFAULT = NFMT_UNORM,
478 NFMT_SHIFT = 4,
479 NFMT_MASK = 7
482 enum MergedFormat : int64_t {
483 DFMT_NFMT_UNDEF = -1,
484 DFMT_NFMT_DEFAULT = ((DFMT_DEFAULT & DFMT_MASK) << DFMT_SHIFT) |
485 ((NFMT_DEFAULT & NFMT_MASK) << NFMT_SHIFT),
488 DFMT_NFMT_MASK = (DFMT_MASK << DFMT_SHIFT) | (NFMT_MASK << NFMT_SHIFT),
490 DFMT_NFMT_MAX = DFMT_NFMT_MASK
493 enum UnifiedFormat : int64_t {
494 UFMT_INVALID = 0,
496 UFMT_8_UNORM,
497 UFMT_8_SNORM,
498 UFMT_8_USCALED,
499 UFMT_8_SSCALED,
500 UFMT_8_UINT,
501 UFMT_8_SINT,
503 UFMT_16_UNORM,
504 UFMT_16_SNORM,
505 UFMT_16_USCALED,
506 UFMT_16_SSCALED,
507 UFMT_16_UINT,
508 UFMT_16_SINT,
509 UFMT_16_FLOAT,
511 UFMT_8_8_UNORM,
512 UFMT_8_8_SNORM,
513 UFMT_8_8_USCALED,
514 UFMT_8_8_SSCALED,
515 UFMT_8_8_UINT,
516 UFMT_8_8_SINT,
518 UFMT_32_UINT,
519 UFMT_32_SINT,
520 UFMT_32_FLOAT,
522 UFMT_16_16_UNORM,
523 UFMT_16_16_SNORM,
524 UFMT_16_16_USCALED,
525 UFMT_16_16_SSCALED,
526 UFMT_16_16_UINT,
527 UFMT_16_16_SINT,
528 UFMT_16_16_FLOAT,
530 UFMT_10_11_11_UNORM,
531 UFMT_10_11_11_SNORM,
532 UFMT_10_11_11_USCALED,
533 UFMT_10_11_11_SSCALED,
534 UFMT_10_11_11_UINT,
535 UFMT_10_11_11_SINT,
536 UFMT_10_11_11_FLOAT,
538 UFMT_11_11_10_UNORM,
539 UFMT_11_11_10_SNORM,
540 UFMT_11_11_10_USCALED,
541 UFMT_11_11_10_SSCALED,
542 UFMT_11_11_10_UINT,
543 UFMT_11_11_10_SINT,
544 UFMT_11_11_10_FLOAT,
546 UFMT_10_10_10_2_UNORM,
547 UFMT_10_10_10_2_SNORM,
548 UFMT_10_10_10_2_USCALED,
549 UFMT_10_10_10_2_SSCALED,
550 UFMT_10_10_10_2_UINT,
551 UFMT_10_10_10_2_SINT,
553 UFMT_2_10_10_10_UNORM,
554 UFMT_2_10_10_10_SNORM,
555 UFMT_2_10_10_10_USCALED,
556 UFMT_2_10_10_10_SSCALED,
557 UFMT_2_10_10_10_UINT,
558 UFMT_2_10_10_10_SINT,
560 UFMT_8_8_8_8_UNORM,
561 UFMT_8_8_8_8_SNORM,
562 UFMT_8_8_8_8_USCALED,
563 UFMT_8_8_8_8_SSCALED,
564 UFMT_8_8_8_8_UINT,
565 UFMT_8_8_8_8_SINT,
567 UFMT_32_32_UINT,
568 UFMT_32_32_SINT,
569 UFMT_32_32_FLOAT,
571 UFMT_16_16_16_16_UNORM,
572 UFMT_16_16_16_16_SNORM,
573 UFMT_16_16_16_16_USCALED,
574 UFMT_16_16_16_16_SSCALED,
575 UFMT_16_16_16_16_UINT,
576 UFMT_16_16_16_16_SINT,
577 UFMT_16_16_16_16_FLOAT,
579 UFMT_32_32_32_UINT,
580 UFMT_32_32_32_SINT,
581 UFMT_32_32_32_FLOAT,
582 UFMT_32_32_32_32_UINT,
583 UFMT_32_32_32_32_SINT,
584 UFMT_32_32_32_32_FLOAT,
586 UFMT_FIRST = UFMT_INVALID,
587 UFMT_LAST = UFMT_32_32_32_32_FLOAT,
589 UFMT_MAX = 127,
591 UFMT_UNDEF = -1,
592 UFMT_DEFAULT = UFMT_8_UNORM
595 } // namespace MTBUFFormat
597 namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
599 enum Id : unsigned { // id of symbolic names
600 ID_QUAD_PERM = 0,
601 ID_BITMASK_PERM,
602 ID_SWAP,
603 ID_REVERSE,
604 ID_BROADCAST
607 enum EncBits : unsigned {
609 // swizzle mode encodings
611 QUAD_PERM_ENC = 0x8000,
612 QUAD_PERM_ENC_MASK = 0xFF00,
614 BITMASK_PERM_ENC = 0x0000,
615 BITMASK_PERM_ENC_MASK = 0x8000,
617 // QUAD_PERM encodings
619 LANE_MASK = 0x3,
620 LANE_MAX = LANE_MASK,
621 LANE_SHIFT = 2,
622 LANE_NUM = 4,
624 // BITMASK_PERM encodings
626 BITMASK_MASK = 0x1F,
627 BITMASK_MAX = BITMASK_MASK,
628 BITMASK_WIDTH = 5,
630 BITMASK_AND_SHIFT = 0,
631 BITMASK_OR_SHIFT = 5,
632 BITMASK_XOR_SHIFT = 10
635 } // namespace Swizzle
637 namespace SDWA {
639 enum SdwaSel : unsigned {
640 BYTE_0 = 0,
641 BYTE_1 = 1,
642 BYTE_2 = 2,
643 BYTE_3 = 3,
644 WORD_0 = 4,
645 WORD_1 = 5,
646 DWORD = 6,
649 enum DstUnused : unsigned {
650 UNUSED_PAD = 0,
651 UNUSED_SEXT = 1,
652 UNUSED_PRESERVE = 2,
655 enum SDWA9EncValues : unsigned {
656 SRC_SGPR_MASK = 0x100,
657 SRC_VGPR_MASK = 0xFF,
658 VOPC_DST_VCC_MASK = 0x80,
659 VOPC_DST_SGPR_MASK = 0x7F,
661 SRC_VGPR_MIN = 0,
662 SRC_VGPR_MAX = 255,
663 SRC_SGPR_MIN = 256,
664 SRC_SGPR_MAX_SI = 357,
665 SRC_SGPR_MAX_GFX10 = 361,
666 SRC_TTMP_MIN = 364,
667 SRC_TTMP_MAX = 379,
670 } // namespace SDWA
672 namespace DPP {
674 // clang-format off
675 enum DppCtrl : unsigned {
676 QUAD_PERM_FIRST = 0,
677 QUAD_PERM_ID = 0xE4, // identity permutation
678 QUAD_PERM_LAST = 0xFF,
679 DPP_UNUSED1 = 0x100,
680 ROW_SHL0 = 0x100,
681 ROW_SHL_FIRST = 0x101,
682 ROW_SHL_LAST = 0x10F,
683 DPP_UNUSED2 = 0x110,
684 ROW_SHR0 = 0x110,
685 ROW_SHR_FIRST = 0x111,
686 ROW_SHR_LAST = 0x11F,
687 DPP_UNUSED3 = 0x120,
688 ROW_ROR0 = 0x120,
689 ROW_ROR_FIRST = 0x121,
690 ROW_ROR_LAST = 0x12F,
691 WAVE_SHL1 = 0x130,
692 DPP_UNUSED4_FIRST = 0x131,
693 DPP_UNUSED4_LAST = 0x133,
694 WAVE_ROL1 = 0x134,
695 DPP_UNUSED5_FIRST = 0x135,
696 DPP_UNUSED5_LAST = 0x137,
697 WAVE_SHR1 = 0x138,
698 DPP_UNUSED6_FIRST = 0x139,
699 DPP_UNUSED6_LAST = 0x13B,
700 WAVE_ROR1 = 0x13C,
701 DPP_UNUSED7_FIRST = 0x13D,
702 DPP_UNUSED7_LAST = 0x13F,
703 ROW_MIRROR = 0x140,
704 ROW_HALF_MIRROR = 0x141,
705 BCAST15 = 0x142,
706 BCAST31 = 0x143,
707 DPP_UNUSED8_FIRST = 0x144,
708 DPP_UNUSED8_LAST = 0x14F,
709 ROW_NEWBCAST_FIRST= 0x150,
710 ROW_NEWBCAST_LAST = 0x15F,
711 ROW_SHARE0 = 0x150,
712 ROW_SHARE_FIRST = 0x150,
713 ROW_SHARE_LAST = 0x15F,
714 ROW_XMASK0 = 0x160,
715 ROW_XMASK_FIRST = 0x160,
716 ROW_XMASK_LAST = 0x16F,
717 DPP_LAST = ROW_XMASK_LAST
719 // clang-format on
721 enum DppFiMode {
722 DPP_FI_0 = 0,
723 DPP_FI_1 = 1,
724 DPP8_FI_0 = 0xE9,
725 DPP8_FI_1 = 0xEA,
728 } // namespace DPP
730 namespace Exp {
732 enum Target : unsigned {
733 ET_MRT0 = 0,
734 ET_MRT7 = 7,
735 ET_MRTZ = 8,
736 ET_NULL = 9,
737 ET_POS0 = 12,
738 ET_POS3 = 15,
739 ET_POS4 = 16, // GFX10+
740 ET_POS_LAST = ET_POS4, // Highest pos used on any subtarget
741 ET_PRIM = 20, // GFX10+
742 ET_PARAM0 = 32,
743 ET_PARAM31 = 63,
745 ET_NULL_MAX_IDX = 0,
746 ET_MRTZ_MAX_IDX = 0,
747 ET_PRIM_MAX_IDX = 0,
748 ET_MRT_MAX_IDX = 7,
749 ET_POS_MAX_IDX = 4,
750 ET_PARAM_MAX_IDX = 31,
752 ET_INVALID = 255,
755 } // namespace Exp
757 namespace VOP3PEncoding {
759 enum OpSel : uint64_t {
760 OP_SEL_HI_0 = UINT64_C(1) << 59,
761 OP_SEL_HI_1 = UINT64_C(1) << 60,
762 OP_SEL_HI_2 = UINT64_C(1) << 14,
765 } // namespace VOP3PEncoding
767 } // namespace AMDGPU
769 #define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
770 #define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
771 #define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
772 #define S_00B028_MEM_ORDERED(x) (((x) & 0x1) << 25)
773 #define G_00B028_MEM_ORDERED(x) (((x) >> 25) & 0x1)
774 #define C_00B028_MEM_ORDERED 0xFDFFFFFF
776 #define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
777 #define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
778 #define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
779 #define S_00B128_MEM_ORDERED(x) (((x) & 0x1) << 27)
780 #define G_00B128_MEM_ORDERED(x) (((x) >> 27) & 0x1)
781 #define C_00B128_MEM_ORDERED 0xF7FFFFFF
783 #define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
784 #define S_00B228_WGP_MODE(x) (((x) & 0x1) << 27)
785 #define G_00B228_WGP_MODE(x) (((x) >> 27) & 0x1)
786 #define C_00B228_WGP_MODE 0xF7FFFFFF
787 #define S_00B228_MEM_ORDERED(x) (((x) & 0x1) << 25)
788 #define G_00B228_MEM_ORDERED(x) (((x) >> 25) & 0x1)
789 #define C_00B228_MEM_ORDERED 0xFDFFFFFF
791 #define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
792 #define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
793 #define S_00B428_WGP_MODE(x) (((x) & 0x1) << 26)
794 #define G_00B428_WGP_MODE(x) (((x) >> 26) & 0x1)
795 #define C_00B428_WGP_MODE 0xFBFFFFFF
796 #define S_00B428_MEM_ORDERED(x) (((x) & 0x1) << 24)
797 #define G_00B428_MEM_ORDERED(x) (((x) >> 24) & 0x1)
798 #define C_00B428_MEM_ORDERED 0xFEFFFFFF
800 #define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
802 #define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
803 #define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
804 #define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
805 #define C_00B84C_SCRATCH_EN 0xFFFFFFFE
806 #define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
807 #define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
808 #define C_00B84C_USER_SGPR 0xFFFFFFC1
809 #define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
810 #define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
811 #define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
812 #define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
813 #define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
814 #define C_00B84C_TGID_X_EN 0xFFFFFF7F
815 #define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
816 #define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
817 #define C_00B84C_TGID_Y_EN 0xFFFFFEFF
818 #define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
819 #define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
820 #define C_00B84C_TGID_Z_EN 0xFFFFFDFF
821 #define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
822 #define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
823 #define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
824 #define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
825 #define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
826 #define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
827 /* CIK */
828 #define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
829 #define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
830 #define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
831 /* */
832 #define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
833 #define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
834 #define C_00B84C_LDS_SIZE 0xFF007FFF
835 #define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
836 #define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
837 #define C_00B84C_EXCP_EN
839 #define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
840 #define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
842 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
843 #define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
844 #define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
845 #define C_00B848_VGPRS 0xFFFFFFC0
846 #define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
847 #define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
848 #define C_00B848_SGPRS 0xFFFFFC3F
849 #define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
850 #define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
851 #define C_00B848_PRIORITY 0xFFFFF3FF
852 #define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
853 #define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
854 #define C_00B848_FLOAT_MODE 0xFFF00FFF
855 #define S_00B848_PRIV(x) (((x) & 0x1) << 20)
856 #define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
857 #define C_00B848_PRIV 0xFFEFFFFF
858 #define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
859 #define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
860 #define C_00B848_DX10_CLAMP 0xFFDFFFFF
861 #define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
862 #define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
863 #define C_00B848_DEBUG_MODE 0xFFBFFFFF
864 #define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
865 #define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
866 #define C_00B848_IEEE_MODE 0xFF7FFFFF
867 #define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
868 #define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
869 #define C_00B848_WGP_MODE 0xDFFFFFFF
870 #define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
871 #define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
872 #define C_00B848_MEM_ORDERED 0xBFFFFFFF
873 #define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
874 #define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
875 #define C_00B848_FWD_PROGRESS 0x7FFFFFFF
878 // Helpers for setting FLOAT_MODE
879 #define FP_ROUND_ROUND_TO_NEAREST 0
880 #define FP_ROUND_ROUND_TO_INF 1
881 #define FP_ROUND_ROUND_TO_NEGINF 2
882 #define FP_ROUND_ROUND_TO_ZERO 3
884 // Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
885 // precision.
886 #define FP_ROUND_MODE_SP(x) ((x) & 0x3)
887 #define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
889 #define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
890 #define FP_DENORM_FLUSH_OUT 1
891 #define FP_DENORM_FLUSH_IN 2
892 #define FP_DENORM_FLUSH_NONE 3
895 // Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
896 // precision.
897 #define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
898 #define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
900 #define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
901 #define S_00B860_WAVESIZE(x) (((x) & 0x1FFF) << 12)
903 #define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
904 #define S_0286E8_WAVESIZE(x) (((x) & 0x1FFF) << 12)
906 #define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
907 #define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
908 #define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
909 #define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
910 #define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
911 #define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
912 #define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
913 #define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
915 #define R_SPILLED_SGPRS 0x4
916 #define R_SPILLED_VGPRS 0x8
917 } // End namespace llvm
919 #endif