bc44e403f1019f6269f1b225906eaeb25d9893a7
[oota-llvm.git] / lib / Target / R600 / SIDefines.h
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 #ifndef LLVM_LIB_TARGET_R600_SIDEFINES_H
12 #define LLVM_LIB_TARGET_R600_SIDEFINES_H
13
14 namespace SIInstrFlags {
15 // This needs to be kept in sync with the field bits in InstSI.
16 enum {
17   SALU = 1 << 3,
18   VALU = 1 << 4,
19
20   SOP1 = 1 << 5,
21   SOP2 = 1 << 6,
22   SOPC = 1 << 7,
23   SOPK = 1 << 8,
24   SOPP = 1 << 9,
25
26   VOP1 = 1 << 10,
27   VOP2 = 1 << 11,
28   VOP3 = 1 << 12,
29   VOPC = 1 << 13,
30
31   MUBUF = 1 << 14,
32   MTBUF = 1 << 15,
33   SMRD = 1 << 16,
34   DS = 1 << 17,
35   MIMG = 1 << 18,
36   FLAT = 1 << 19
37 };
38 }
39
40 namespace SIInstrFlags {
41   enum Flags {
42     // First 4 bits are the instruction encoding
43     VM_CNT = 1 << 0,
44     EXP_CNT = 1 << 1,
45     LGKM_CNT = 1 << 2
46   };
47 }
48
49 namespace SISrcMods {
50   enum {
51    NEG = 1 << 0,
52    ABS = 1 << 1
53   };
54 }
55
56 namespace SIOutMods {
57   enum {
58     NONE = 0,
59     MUL2 = 1,
60     MUL4 = 2,
61     DIV2 = 3
62   };
63 }
64
65 #define R_00B028_SPI_SHADER_PGM_RSRC1_PS                                0x00B028
66 #define R_00B02C_SPI_SHADER_PGM_RSRC2_PS                                0x00B02C
67 #define   S_00B02C_EXTRA_LDS_SIZE(x)                                  (((x) & 0xFF) << 8)
68 #define R_00B128_SPI_SHADER_PGM_RSRC1_VS                                0x00B128
69 #define R_00B228_SPI_SHADER_PGM_RSRC1_GS                                0x00B228
70 #define R_00B848_COMPUTE_PGM_RSRC1                                      0x00B848
71 #define   S_00B028_VGPRS(x)                                           (((x) & 0x3F) << 0)
72 #define   S_00B028_SGPRS(x)                                           (((x) & 0x0F) << 6)
73 #define R_00B84C_COMPUTE_PGM_RSRC2                                      0x00B84C
74 #define   S_00B02C_SCRATCH_EN(x)                                      (((x) & 0x1) << 0)
75 #define   S_00B84C_LDS_SIZE(x)                                        (((x) & 0x1FF) << 15)
76 #define R_0286CC_SPI_PS_INPUT_ENA                                       0x0286CC
77
78
79 #define R_00B848_COMPUTE_PGM_RSRC1                                      0x00B848
80 #define   S_00B848_VGPRS(x)                                           (((x) & 0x3F) << 0)
81 #define   G_00B848_VGPRS(x)                                           (((x) >> 0) & 0x3F)
82 #define   C_00B848_VGPRS                                              0xFFFFFFC0
83 #define   S_00B848_SGPRS(x)                                           (((x) & 0x0F) << 6)
84 #define   G_00B848_SGPRS(x)                                           (((x) >> 6) & 0x0F)
85 #define   C_00B848_SGPRS                                              0xFFFFFC3F
86 #define   S_00B848_PRIORITY(x)                                        (((x) & 0x03) << 10)
87 #define   G_00B848_PRIORITY(x)                                        (((x) >> 10) & 0x03)
88 #define   C_00B848_PRIORITY                                           0xFFFFF3FF
89 #define   S_00B848_FLOAT_MODE(x)                                      (((x) & 0xFF) << 12)
90 #define   G_00B848_FLOAT_MODE(x)                                      (((x) >> 12) & 0xFF)
91 #define   C_00B848_FLOAT_MODE                                         0xFFF00FFF
92 #define   S_00B848_PRIV(x)                                            (((x) & 0x1) << 20)
93 #define   G_00B848_PRIV(x)                                            (((x) >> 20) & 0x1)
94 #define   C_00B848_PRIV                                               0xFFEFFFFF
95 #define   S_00B848_DX10_CLAMP(x)                                      (((x) & 0x1) << 21)
96 #define   G_00B848_DX10_CLAMP(x)                                      (((x) >> 21) & 0x1)
97 #define   C_00B848_DX10_CLAMP                                         0xFFDFFFFF
98 #define   S_00B848_DEBUG_MODE(x)                                      (((x) & 0x1) << 22)
99 #define   G_00B848_DEBUG_MODE(x)                                      (((x) >> 22) & 0x1)
100 #define   C_00B848_DEBUG_MODE                                         0xFFBFFFFF
101 #define   S_00B848_IEEE_MODE(x)                                       (((x) & 0x1) << 23)
102 #define   G_00B848_IEEE_MODE(x)                                       (((x) >> 23) & 0x1)
103 #define   C_00B848_IEEE_MODE                                          0xFF7FFFFF
104
105
106 // Helpers for setting FLOAT_MODE
107 #define FP_ROUND_ROUND_TO_NEAREST 0
108 #define FP_ROUND_ROUND_TO_INF 1
109 #define FP_ROUND_ROUND_TO_NEGINF 2
110 #define FP_ROUND_ROUND_TO_ZERO 3
111
112 // Bits 3:0 control rounding mode. 1:0 control single precision, 3:2 double
113 // precision.
114 #define FP_ROUND_MODE_SP(x) ((x) & 0x3)
115 #define FP_ROUND_MODE_DP(x) (((x) & 0x3) << 2)
116
117 #define FP_DENORM_FLUSH_IN_FLUSH_OUT 0
118 #define FP_DENORM_FLUSH_OUT 1
119 #define FP_DENORM_FLUSH_IN 2
120 #define FP_DENORM_FLUSH_NONE 3
121
122
123 // Bits 7:4 control denormal handling. 5:4 control single precision, 6:7 double
124 // precision.
125 #define FP_DENORM_MODE_SP(x) (((x) & 0x3) << 4)
126 #define FP_DENORM_MODE_DP(x) (((x) & 0x3) << 6)
127
128 #define R_00B860_COMPUTE_TMPRING_SIZE                                   0x00B860
129 #define   S_00B860_WAVESIZE(x)                                        (((x) & 0x1FFF) << 12)
130
131 #endif