LLVM  9.0.0svn
SIDefines.h
Go to the documentation of this file.
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 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/MC/MCInstrDesc.h"
11 
12 #ifndef LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
13 #define LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
14 
15 namespace llvm {
16 
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,
23 
24  // SALU instruction formats.
25  SOP1 = 1 << 2,
26  SOP2 = 1 << 3,
27  SOPC = 1 << 4,
28  SOPK = 1 << 5,
29  SOPP = 1 << 6,
30 
31  // VALU instruction formats.
32  VOP1 = 1 << 7,
33  VOP2 = 1 << 8,
34  VOPC = 1 << 9,
35 
36  // TODO: Should this be spilt into VOP3 a and b?
37  VOP3 = 1 << 10,
38  VOP3P = 1 << 12,
39 
40  VINTRP = 1 << 13,
41  SDWA = 1 << 14,
42  DPP = 1 << 15,
43 
44  // Memory instruction formats.
45  MUBUF = 1 << 16,
46  MTBUF = 1 << 17,
47  SMRD = 1 << 18,
48  MIMG = 1 << 19,
49  EXP = 1 << 20,
50  FLAT = 1 << 21,
51  DS = 1 << 22,
52 
53  // Pseudo instruction formats.
54  VGPRSpill = 1 << 23,
55  SGPRSpill = 1 << 24,
56 
57  // High bits - other information.
58  VM_CNT = UINT64_C(1) << 32,
59  EXP_CNT = UINT64_C(1) << 33,
60  LGKM_CNT = UINT64_C(1) << 34,
61 
62  WQM = UINT64_C(1) << 35,
63  DisableWQM = UINT64_C(1) << 36,
64  Gather4 = UINT64_C(1) << 37,
65  SOPK_ZEXT = UINT64_C(1) << 38,
66  SCALAR_STORE = UINT64_C(1) << 39,
67  FIXED_SIZE = UINT64_C(1) << 40,
68  VOPAsmPrefer32Bit = UINT64_C(1) << 41,
69  VOP3_OPSEL = UINT64_C(1) << 42,
70  maybeAtomic = UINT64_C(1) << 43,
71  renamedInGFX9 = UINT64_C(1) << 44,
72 
73  // Is a clamp on FP type.
74  FPClamp = UINT64_C(1) << 45,
75 
76  // Is an integer clamp
77  IntClamp = UINT64_C(1) << 46,
78 
79  // Clamps lo component of register.
80  ClampLo = UINT64_C(1) << 47,
81 
82  // Clamps hi component of register.
83  // ClampLo and ClampHi set for packed clamp.
84  ClampHi = UINT64_C(1) << 48,
85 
86  // Is a packed VOP3P instruction.
87  IsPacked = UINT64_C(1) << 49,
88 
89  // Is a D16 buffer instruction.
90  D16Buf = UINT64_C(1) << 50,
91 
92  // FLAT instruction accesses FLAT_GLBL or FLAT_SCRATCH segment.
93  IsNonFlatSeg = UINT64_C(1) << 51,
94 
95  // Uses floating point double precision rounding mode
96  FPDPRounding = UINT64_C(1) << 52
97 };
98 
99 // v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
100 // The result is true if any of these tests are true.
101 enum ClassFlags : unsigned {
102  S_NAN = 1 << 0, // Signaling NaN
103  Q_NAN = 1 << 1, // Quiet NaN
104  N_INFINITY = 1 << 2, // Negative infinity
105  N_NORMAL = 1 << 3, // Negative normal
106  N_SUBNORMAL = 1 << 4, // Negative subnormal
107  N_ZERO = 1 << 5, // Negative zero
108  P_ZERO = 1 << 6, // Positive zero
109  P_SUBNORMAL = 1 << 7, // Positive subnormal
110  P_NORMAL = 1 << 8, // Positive normal
111  P_INFINITY = 1 << 9 // Positive infinity
112 };
113 }
114 
115 namespace AMDGPU {
116  enum OperandType : unsigned {
117  /// Operands with register or 32-bit immediate
126 
127  /// Operands with register or inline constant
136 
139 
142 
145 
146  // Operand for source modifiers for VOP instructions
148 
149  // Operand for SDWA instructions
151 
152  /// Operand with 32-bit immediate that uses the constant bus.
155  };
156 }
157 
158 namespace SIStackID {
159 enum StackTypes : uint8_t {
160  SCRATCH = 0,
162 };
163 }
164 
165 // Input operand modifiers bit-masks
166 // NEG and SEXT share same bit-mask because they can't be set simultaneously.
167 namespace SISrcMods {
168  enum : unsigned {
169  NEG = 1 << 0, // Floating-point negate modifier
170  ABS = 1 << 1, // Floating-point absolute modifier
171  SEXT = 1 << 0, // Integer sign-extend modifier
172  NEG_HI = ABS, // Floating-point negate high packed component modifier.
173  OP_SEL_0 = 1 << 2,
174  OP_SEL_1 = 1 << 3,
175  DST_OP_SEL = 1 << 3 // VOP3 dst op_sel (share mask with OP_SEL_1)
176  };
177 }
178 
179 namespace SIOutMods {
180  enum : unsigned {
181  NONE = 0,
182  MUL2 = 1,
183  MUL4 = 2,
184  DIV2 = 3
185  };
186 }
187 
188 namespace AMDGPU {
189 namespace VGPRIndexMode {
190 
191 enum Id : unsigned { // id of symbolic names
192  ID_SRC0 = 0,
196 
199 };
200 
201 enum EncBits : unsigned {
202  OFF = 0,
208 };
209 
210 } // namespace VGPRIndexMode
211 } // namespace AMDGPU
212 
213 namespace AMDGPUAsmVariants {
214  enum : unsigned {
215  DEFAULT = 0,
216  VOP3 = 1,
217  SDWA = 2,
218  SDWA9 = 3,
219  DPP = 4
220  };
221 }
222 
223 namespace AMDGPU {
224 namespace EncValues { // Encoding values of enum9/8/7 operands
225 
226 enum : unsigned {
227  SGPR_MIN = 0,
228  SGPR_MAX_SI = 101,
230  TTMP_VI_MIN = 112,
231  TTMP_VI_MAX = 123,
240  VGPR_MIN = 256,
241  VGPR_MAX = 511
242 };
243 
244 } // namespace EncValues
245 } // namespace AMDGPU
246 
247 namespace AMDGPU {
248 namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
249 
250 enum Id { // Message ID, width(4) [3:0].
256  ID_SYSMSG = 15,
257  ID_GAPS_LAST_, // Indicate that sequence has gaps.
261  ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
262 };
263 
264 enum Op { // Both GS and SYS operation IDs.
267  // width(2) [5:4]
275  OP_GS_MASK_ = (((1 << OP_GS_WIDTH_) - 1) << OP_SHIFT_),
276  // width(3) [6:4]
285 };
286 
287 enum StreamId : unsigned { // Stream ID, (2) [9:8].
294 };
295 
296 } // namespace SendMsg
297 
298 namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
299 
300 enum Id { // HwRegCode, (6) [5:0]
302  ID_SYMBOLIC_FIRST_ = 1, // There are corresponding symbolic names defined.
303  ID_MODE = 1,
306  ID_HW_ID = 4,
312  ID_TBA_LO = 16,
314  ID_TBA_HI = 17,
315  ID_TMA_LO = 18,
316  ID_TMA_HI = 19,
324  ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
325 };
326 
327 enum Offset : unsigned { // Offset, (5) [10:6]
332 
335 };
336 
337 enum WidthMinusOne : unsigned { // WidthMinusOne, (5) [15:11]
342 
345 };
346 
347 } // namespace Hwreg
348 
349 namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
350 
351 enum Id : unsigned { // id of symbolic names
357 };
358 
359 enum EncBits : unsigned {
360 
361  // swizzle mode encodings
362 
363  QUAD_PERM_ENC = 0x8000,
365 
368 
369  // QUAD_PERM encodings
370 
371  LANE_MASK = 0x3,
374  LANE_NUM = 4,
375 
376  // BITMASK_PERM encodings
377 
378  BITMASK_MASK = 0x1F,
381 
385 };
386 
387 } // namespace Swizzle
388 
389 namespace SDWA {
390 
391 enum SdwaSel : unsigned {
392  BYTE_0 = 0,
393  BYTE_1 = 1,
394  BYTE_2 = 2,
395  BYTE_3 = 3,
396  WORD_0 = 4,
397  WORD_1 = 5,
398  DWORD = 6,
399 };
400 
401 enum DstUnused : unsigned {
405 };
406 
407 enum SDWA9EncValues : unsigned {
408  SRC_SGPR_MASK = 0x100,
412 
420 };
421 
422 } // namespace SDWA
423 
424 namespace DPP {
425 
426 enum DppCtrl : unsigned {
429  DPP_UNUSED1 = 0x100,
430  ROW_SHL0 = 0x100,
431  ROW_SHL_FIRST = 0x101,
432  ROW_SHL_LAST = 0x10F,
433  DPP_UNUSED2 = 0x110,
434  ROW_SHR0 = 0x110,
435  ROW_SHR_FIRST = 0x111,
436  ROW_SHR_LAST = 0x11F,
437  DPP_UNUSED3 = 0x120,
438  ROW_ROR0 = 0x120,
439  ROW_ROR_FIRST = 0x121,
440  ROW_ROR_LAST = 0x12F,
441  WAVE_SHL1 = 0x130,
444  WAVE_ROL1 = 0x134,
447  WAVE_SHR1 = 0x138,
450  WAVE_ROR1 = 0x13C,
453  ROW_MIRROR = 0x140,
455  BCAST15 = 0x142,
456  BCAST31 = 0x143,
458 };
459 
460 } // namespace DPP
461 } // namespace AMDGPU
462 
463 #define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
464 #define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
465 #define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
466 #define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
467 #define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
468 #define R_00B328_SPI_SHADER_PGM_RSRC1_ES 0x00B328
469 #define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
470 #define R_00B528_SPI_SHADER_PGM_RSRC1_LS 0x00B528
471 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
472 #define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
473 #define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
474 
475 #define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
476 #define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
477 #define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
478 #define C_00B84C_SCRATCH_EN 0xFFFFFFFE
479 #define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
480 #define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
481 #define C_00B84C_USER_SGPR 0xFFFFFFC1
482 #define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
483 #define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
484 #define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
485 #define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
486 #define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
487 #define C_00B84C_TGID_X_EN 0xFFFFFF7F
488 #define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
489 #define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
490 #define C_00B84C_TGID_Y_EN 0xFFFFFEFF
491 #define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
492 #define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
493 #define C_00B84C_TGID_Z_EN 0xFFFFFDFF
494 #define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
495 #define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
496 #define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
497 #define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
498 #define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
499 #define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
500 /* CIK */
501 #define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
502 #define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
503 #define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
504 /* */
505 #define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
506 #define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
507 #define C_00B84C_LDS_SIZE 0xFF007FFF
508 #define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
509 #define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
510 #define C_00B84C_EXCP_EN
511 
512 #define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
513 #define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
514 
515 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
516 #define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
517 #define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
518 #define C_00B848_VGPRS 0xFFFFFFC0
519 #define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
520 #define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
521 #define C_00B848_SGPRS 0xFFFFFC3F
522 #define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
523 #define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
524 #define C_00B848_PRIORITY 0xFFFFF3FF
525 #define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
526 #define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
527 #define C_00B848_FLOAT_MODE 0xFFF00FFF
528 #define S_00B848_PRIV(x) (((x) & 0x1) << 20)
529 #define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
530 #define C_00B848_PRIV 0xFFEFFFFF
531 #define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
532 #define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
533 #define C_00B848_DX10_CLAMP 0xFFDFFFFF
534 #define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
535 #define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
536 #define C_00B848_DEBUG_MODE 0xFFBFFFFF
537 #define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
538 #define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
539 #define C_00B848_IEEE_MODE 0xFF7FFFFF
540 #define S_00B848_WGP_MODE(x) (((x) & 0x1) << 29)
541 #define G_00B848_WGP_MODE(x) (((x) >> 29) & 0x1)
542 #define C_00B848_WGP_MODE 0xDFFFFFFF
543 #define S_00B848_MEM_ORDERED(x) (((x) & 0x1) << 30)
544 #define G_00B848_MEM_ORDERED(x) (((x) >> 30) & 0x1)
545 #define C_00B848_MEM_ORDERED 0xBFFFFFFF
546 #define S_00B848_FWD_PROGRESS(x) (((x) & 0x1) << 31)
547 #define G_00B848_FWD_PROGRESS(x) (((x) >> 31) & 0x1)
548 #define C_00B848_FWD_PROGRESS 0x7FFFFFFF
549 
550 
551 // Helpers for setting FLOAT_MODE
552 #define FP_ROUND_ROUND_TO_NEAREST 0
553 #define FP_ROUND_ROUND_TO_INF 1
554 #define FP_ROUND_ROUND_TO_NEGINF 2
555 #define FP_ROUND_ROUND_TO_ZERO 3
556 
557 // Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
558 // precision.
559 #define FP_ROUND_MODE_SP(x) ((x) & 0x3)
560 #define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
561 
562 #define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
563 #define FP_DENORM_FLUSH_OUT 1
564 #define FP_DENORM_FLUSH_IN 2
565 #define FP_DENORM_FLUSH_NONE 3
566 
567 
568 // Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
569 // precision.
570 #define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
571 #define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
572 
573 #define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
574 #define S_00B860_WAVESIZE(x) (((x) & 0x1FFF) << 12)
575 
576 #define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
577 #define S_0286E8_WAVESIZE(x) (((x) & 0x1FFF) << 12)
578 
579 #define R_028B54_VGT_SHADER_STAGES_EN 0x028B54
580 #define S_028B54_HS_W32_EN(x) (((x) & 0x1) << 21)
581 #define S_028B54_GS_W32_EN(x) (((x) & 0x1) << 22)
582 #define S_028B54_VS_W32_EN(x) (((x) & 0x1) << 23)
583 #define R_0286D8_SPI_PS_IN_CONTROL 0x0286D8
584 #define S_0286D8_PS_W32_EN(x) (((x) & 0x1) << 15)
585 #define R_00B800_COMPUTE_DISPATCH_INITIATOR 0x00B800
586 #define S_00B800_CS_W32_EN(x) (((x) & 0x1) << 15)
587 
588 #define R_SPILLED_SGPRS 0x4
589 #define R_SPILLED_VGPRS 0x8
590 } // End namespace llvm
591 
592 #endif
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Operand with 32-bit immediate that uses the constant bus.
Definition: SIDefines.h:153
static std::vector< std::pair< int, unsigned > > Swizzle(std::vector< std::pair< int, unsigned >> Src, R600InstrInfo::BankSwizzle Swz)
Operands with register or 32-bit immediate.
Definition: SIDefines.h:118
Operands with register or inline constant.
Definition: SIDefines.h:128