LLVM  5.0.0
SIDefines.h
Go to the documentation of this file.
1 //===-- SIDefines.h - SI Helper Macros ----------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 /// \file
9 //===----------------------------------------------------------------------===//
10 
11 #include "llvm/MC/MCInstrDesc.h"
12 
13 #ifndef LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
14 #define LLVM_LIB_TARGET_AMDGPU_SIDEFINES_H
15 
16 namespace llvm {
17 
18 namespace SIInstrFlags {
19 // This needs to be kept in sync with the field bits in InstSI.
20 enum : uint64_t {
21  // Low bits - basic encoding information.
22  SALU = 1 << 0,
23  VALU = 1 << 1,
24 
25  // SALU instruction formats.
26  SOP1 = 1 << 2,
27  SOP2 = 1 << 3,
28  SOPC = 1 << 4,
29  SOPK = 1 << 5,
30  SOPP = 1 << 6,
31 
32  // VALU instruction formats.
33  VOP1 = 1 << 7,
34  VOP2 = 1 << 8,
35  VOPC = 1 << 9,
36 
37  // TODO: Should this be spilt into VOP3 a and b?
38  VOP3 = 1 << 10,
39  VOP3P = 1 << 12,
40 
41  VINTRP = 1 << 13,
42  SDWA = 1 << 14,
43  DPP = 1 << 15,
44 
45  // Memory instruction formats.
46  MUBUF = 1 << 16,
47  MTBUF = 1 << 17,
48  SMRD = 1 << 18,
49  MIMG = 1 << 19,
50  EXP = 1 << 20,
51  FLAT = 1 << 21,
52  DS = 1 << 22,
53 
54  // Pseudo instruction formats.
55  VGPRSpill = 1 << 23,
56  SGPRSpill = 1 << 24,
57 
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,
62 
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  HasFPClamp = UINT64_C(1) << 42
71 };
72 
73 // v_cmp_class_* etc. use a 10-bit mask for what operation is checked.
74 // The result is true if any of these tests are true.
75 enum ClassFlags {
76  S_NAN = 1 << 0, // Signaling NaN
77  Q_NAN = 1 << 1, // Quiet NaN
78  N_INFINITY = 1 << 2, // Negative infinity
79  N_NORMAL = 1 << 3, // Negative normal
80  N_SUBNORMAL = 1 << 4, // Negative subnormal
81  N_ZERO = 1 << 5, // Negative zero
82  P_ZERO = 1 << 6, // Positive zero
83  P_SUBNORMAL = 1 << 7, // Positive subnormal
84  P_NORMAL = 1 << 8, // Positive normal
85  P_INFINITY = 1 << 9 // Positive infinity
86 };
87 }
88 
89 namespace AMDGPU {
90  enum OperandType {
91  /// Operands with register or 32-bit immediate
98 
99  /// Operands with register or inline constant
108 
111 
114 
117 
118  // Operand for source modifiers for VOP instructions
120 
121  // Operand for SDWA instructions
124 
125  /// Operand with 32-bit immediate that uses the constant bus.
128  };
129 }
130 
131 // Input operand modifiers bit-masks
132 // NEG and SEXT share same bit-mask because they can't be set simultaneously.
133 namespace SISrcMods {
134  enum {
135  NEG = 1 << 0, // Floating-point negate modifier
136  ABS = 1 << 1, // Floating-point absolute modifier
137  SEXT = 1 << 0, // Integer sign-extend modifier
138  NEG_HI = ABS, // Floating-point negate high packed component modifier.
139  OP_SEL_0 = 1 << 2,
140  OP_SEL_1 = 1 << 3
141  };
142 }
143 
144 namespace SIOutMods {
145  enum {
146  NONE = 0,
147  MUL2 = 1,
148  MUL4 = 2,
149  DIV2 = 3
150  };
151 }
152 
153 namespace VGPRIndexMode {
154  enum {
155  SRC0_ENABLE = 1 << 0,
156  SRC1_ENABLE = 1 << 1,
157  SRC2_ENABLE = 1 << 2,
158  DST_ENABLE = 1 << 3
159  };
160 }
161 
162 namespace AMDGPUAsmVariants {
163  enum {
164  DEFAULT = 0,
165  VOP3 = 1,
166  SDWA = 2,
167  SDWA9 = 3,
168  DPP = 4
169  };
170 }
171 
172 namespace AMDGPU {
173 namespace EncValues { // Encoding values of enum9/8/7 operands
174 
175 enum {
176  SGPR_MIN = 0,
177  SGPR_MAX = 101,
178  TTMP_MIN = 112,
179  TTMP_MAX = 123,
186  VGPR_MIN = 256,
187  VGPR_MAX = 511
188 };
189 
190 } // namespace EncValues
191 } // namespace AMDGPU
192 
193 namespace AMDGPU {
194 namespace SendMsg { // Encoding of SIMM16 used in s_sendmsg* insns.
195 
196 enum Id { // Message ID, width(4) [3:0].
201  ID_SYSMSG = 15,
202  ID_GAPS_LAST_, // Indicate that sequence has gaps.
206  ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
207 };
208 
209 enum Op { // Both GS and SYS operation IDs.
212  // width(2) [5:4]
220  OP_GS_MASK_ = (((1 << OP_GS_WIDTH_) - 1) << OP_SHIFT_),
221  // width(3) [6:4]
230 };
231 
232 enum StreamId { // Stream ID, (2) [9:8].
239 };
240 
241 } // namespace SendMsg
242 
243 namespace Hwreg { // Encoding of SIMM16 used in s_setreg/getreg* insns.
244 
245 enum Id { // HwRegCode, (6) [5:0]
247  ID_SYMBOLIC_FIRST_ = 1, // There are corresponding symbolic names defined.
248  ID_MODE = 1,
251  ID_HW_ID = 4,
259  ID_MASK_ = (((1 << ID_WIDTH_) - 1) << ID_SHIFT_)
260 };
261 
262 enum Offset { // Offset, (5) [10:6]
267 
270 };
271 
272 enum WidthMinusOne { // WidthMinusOne, (5) [15:11]
277 
280 };
281 
282 } // namespace Hwreg
283 
284 namespace Swizzle { // Encoding of swizzle macro used in ds_swizzle_b32.
285 
286 enum Id { // id of symbolic names
292 };
293 
294 enum EncBits {
295 
296  // swizzle mode encodings
297 
298  QUAD_PERM_ENC = 0x8000,
300 
303 
304  // QUAD_PERM encodings
305 
306  LANE_MASK = 0x3,
309  LANE_NUM = 4,
310 
311  // BITMASK_PERM encodings
312 
313  BITMASK_MASK = 0x1F,
316 
320 };
321 
322 } // namespace Swizzle
323 
324 namespace SDWA {
325 
326 enum SdwaSel {
327  BYTE_0 = 0,
328  BYTE_1 = 1,
329  BYTE_2 = 2,
330  BYTE_3 = 3,
331  WORD_0 = 4,
332  WORD_1 = 5,
333  DWORD = 6,
334 };
335 
336 enum DstUnused {
340 };
341 
343  SRC_SGPR_MASK = 0x100,
347 
352 };
353 
354 } // namespace SDWA
355 } // namespace AMDGPU
356 
357 #define R_00B028_SPI_SHADER_PGM_RSRC1_PS 0x00B028
358 #define R_00B02C_SPI_SHADER_PGM_RSRC2_PS 0x00B02C
359 #define S_00B02C_EXTRA_LDS_SIZE(x) (((x) & 0xFF) << 8)
360 #define R_00B128_SPI_SHADER_PGM_RSRC1_VS 0x00B128
361 #define R_00B228_SPI_SHADER_PGM_RSRC1_GS 0x00B228
362 #define R_00B428_SPI_SHADER_PGM_RSRC1_HS 0x00B428
363 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
364 #define S_00B028_VGPRS(x) (((x) & 0x3F) << 0)
365 #define S_00B028_SGPRS(x) (((x) & 0x0F) << 6)
366 
367 #define R_00B84C_COMPUTE_PGM_RSRC2 0x00B84C
368 #define S_00B84C_SCRATCH_EN(x) (((x) & 0x1) << 0)
369 #define G_00B84C_SCRATCH_EN(x) (((x) >> 0) & 0x1)
370 #define C_00B84C_SCRATCH_EN 0xFFFFFFFE
371 #define S_00B84C_USER_SGPR(x) (((x) & 0x1F) << 1)
372 #define G_00B84C_USER_SGPR(x) (((x) >> 1) & 0x1F)
373 #define C_00B84C_USER_SGPR 0xFFFFFFC1
374 #define S_00B84C_TRAP_HANDLER(x) (((x) & 0x1) << 6)
375 #define G_00B84C_TRAP_HANDLER(x) (((x) >> 6) & 0x1)
376 #define C_00B84C_TRAP_HANDLER 0xFFFFFFBF
377 #define S_00B84C_TGID_X_EN(x) (((x) & 0x1) << 7)
378 #define G_00B84C_TGID_X_EN(x) (((x) >> 7) & 0x1)
379 #define C_00B84C_TGID_X_EN 0xFFFFFF7F
380 #define S_00B84C_TGID_Y_EN(x) (((x) & 0x1) << 8)
381 #define G_00B84C_TGID_Y_EN(x) (((x) >> 8) & 0x1)
382 #define C_00B84C_TGID_Y_EN 0xFFFFFEFF
383 #define S_00B84C_TGID_Z_EN(x) (((x) & 0x1) << 9)
384 #define G_00B84C_TGID_Z_EN(x) (((x) >> 9) & 0x1)
385 #define C_00B84C_TGID_Z_EN 0xFFFFFDFF
386 #define S_00B84C_TG_SIZE_EN(x) (((x) & 0x1) << 10)
387 #define G_00B84C_TG_SIZE_EN(x) (((x) >> 10) & 0x1)
388 #define C_00B84C_TG_SIZE_EN 0xFFFFFBFF
389 #define S_00B84C_TIDIG_COMP_CNT(x) (((x) & 0x03) << 11)
390 #define G_00B84C_TIDIG_COMP_CNT(x) (((x) >> 11) & 0x03)
391 #define C_00B84C_TIDIG_COMP_CNT 0xFFFFE7FF
392 /* CIK */
393 #define S_00B84C_EXCP_EN_MSB(x) (((x) & 0x03) << 13)
394 #define G_00B84C_EXCP_EN_MSB(x) (((x) >> 13) & 0x03)
395 #define C_00B84C_EXCP_EN_MSB 0xFFFF9FFF
396 /* */
397 #define S_00B84C_LDS_SIZE(x) (((x) & 0x1FF) << 15)
398 #define G_00B84C_LDS_SIZE(x) (((x) >> 15) & 0x1FF)
399 #define C_00B84C_LDS_SIZE 0xFF007FFF
400 #define S_00B84C_EXCP_EN(x) (((x) & 0x7F) << 24)
401 #define G_00B84C_EXCP_EN(x) (((x) >> 24) & 0x7F)
402 #define C_00B84C_EXCP_EN
403 
404 #define R_0286CC_SPI_PS_INPUT_ENA 0x0286CC
405 #define R_0286D0_SPI_PS_INPUT_ADDR 0x0286D0
406 
407 #define R_00B848_COMPUTE_PGM_RSRC1 0x00B848
408 #define S_00B848_VGPRS(x) (((x) & 0x3F) << 0)
409 #define G_00B848_VGPRS(x) (((x) >> 0) & 0x3F)
410 #define C_00B848_VGPRS 0xFFFFFFC0
411 #define S_00B848_SGPRS(x) (((x) & 0x0F) << 6)
412 #define G_00B848_SGPRS(x) (((x) >> 6) & 0x0F)
413 #define C_00B848_SGPRS 0xFFFFFC3F
414 #define S_00B848_PRIORITY(x) (((x) & 0x03) << 10)
415 #define G_00B848_PRIORITY(x) (((x) >> 10) & 0x03)
416 #define C_00B848_PRIORITY 0xFFFFF3FF
417 #define S_00B848_FLOAT_MODE(x) (((x) & 0xFF) << 12)
418 #define G_00B848_FLOAT_MODE(x) (((x) >> 12) & 0xFF)
419 #define C_00B848_FLOAT_MODE 0xFFF00FFF
420 #define S_00B848_PRIV(x) (((x) & 0x1) << 20)
421 #define G_00B848_PRIV(x) (((x) >> 20) & 0x1)
422 #define C_00B848_PRIV 0xFFEFFFFF
423 #define S_00B848_DX10_CLAMP(x) (((x) & 0x1) << 21)
424 #define G_00B848_DX10_CLAMP(x) (((x) >> 21) & 0x1)
425 #define C_00B848_DX10_CLAMP 0xFFDFFFFF
426 #define S_00B848_DEBUG_MODE(x) (((x) & 0x1) << 22)
427 #define G_00B848_DEBUG_MODE(x) (((x) >> 22) & 0x1)
428 #define C_00B848_DEBUG_MODE 0xFFBFFFFF
429 #define S_00B848_IEEE_MODE(x) (((x) & 0x1) << 23)
430 #define G_00B848_IEEE_MODE(x) (((x) >> 23) & 0x1)
431 #define C_00B848_IEEE_MODE 0xFF7FFFFF
432 
433 
434 // Helpers for setting FLOAT_MODE
435 #define FP_ROUND_ROUND_TO_NEAREST 0
436 #define FP_ROUND_ROUND_TO_INF 1
437 #define FP_ROUND_ROUND_TO_NEGINF 2
438 #define FP_ROUND_ROUND_TO_ZERO 3
439 
440 // Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
441 // precision.
442 #define FP_ROUND_MODE_SP(x) ((x) & 0x3)
443 #define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
444 
445 #define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
446 #define FP_DENORM_FLUSH_OUT 1
447 #define FP_DENORM_FLUSH_IN 2
448 #define FP_DENORM_FLUSH_NONE 3
449 
450 
451 // Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
452 // precision.
453 #define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
454 #define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
455 
456 #define R_00B860_COMPUTE_TMPRING_SIZE 0x00B860
457 #define S_00B860_WAVESIZE(x) (((x) & 0x1FFF) << 12)
458 
459 #define R_0286E8_SPI_TMPRING_SIZE 0x0286E8
460 #define S_0286E8_WAVESIZE(x) (((x) & 0x1FFF) << 12)
461 
462 #define R_SPILLED_SGPRS 0x4
463 #define R_SPILLED_VGPRS 0x8
464 } // End namespace llvm
465 
466 #endif
static std::vector< std::pair< int, unsigned > > Swizzle(std::vector< std::pair< int, unsigned >> Src, R600InstrInfo::BankSwizzle Swz)
Operands with register or inline constant.
Definition: SIDefines.h:100
Operands with register or 32-bit immediate.
Definition: SIDefines.h:92
Operand with 32-bit immediate that uses the constant bus.
Definition: SIDefines.h:126