1 /*
2  * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *      Jerome Glisse
25  */
26 #ifndef EG_SQ_H
27 #define EG_SQ_H
28 
29 #define P_SQ_CF_WORD0
30 #define   S_SQ_CF_WORD0_ADDR(x)                                      (((unsigned)(x) & 0xFFFFFF) << 0)
31 #define   G_SQ_CF_WORD0_ADDR(x)                                      (((x) >> 0) & 0xFFFFFF)
32 #define   C_SQ_CF_WORD0_ADDR                                         0x00000000
33 #define   S_SQ_CF_WORD0_JUMPTABLE_SEL(x)                             (((unsigned)(x) & 0x7) << 24)
34 #define   G_SQ_CF_WORD0_JUMPTABLE_SEL(x)                             (((x) >> 24) & 0x7)
35 #define   C_SQ_CF_WORD0_JUMPTABLE_SEL                                0xF8FFFFFF
36 #define P_SQ_CF_WORD1
37 #define   S_SQ_CF_WORD1_POP_COUNT(x)                                 (((unsigned)(x) & 0x7) << 0)
38 #define   G_SQ_CF_WORD1_POP_COUNT(x)                                 (((x) >> 0) & 0x7)
39 #define   C_SQ_CF_WORD1_POP_COUNT                                    0xFFFFFFF8
40 #define   S_SQ_CF_WORD1_CF_CONST(x)                                  (((unsigned)(x) & 0x1F) << 3)
41 #define   G_SQ_CF_WORD1_CF_CONST(x)                                  (((x) >> 3) & 0x1F)
42 #define   C_SQ_CF_WORD1_CF_CONST                                     0xFFFFFF07
43 #define   S_SQ_CF_WORD1_COND(x)                                      (((unsigned)(x) & 0x3) << 8)
44 #define   G_SQ_CF_WORD1_COND(x)                                      (((x) >> 8) & 0x3)
45 #define   C_SQ_CF_WORD1_COND                                         0xFFFFFCFF
46 #define   S_SQ_CF_WORD1_COUNT(x)                                     (((unsigned)(x) & 0x3f) << 10)
47 #define   G_SQ_CF_WORD1_COUNT(x)                                     (((x) >> 10) & 0x3f)
48 #define   C_SQ_CF_WORD1_COUNT                                        0xFFFF03FF
49 #define   S_SQ_CF_WORD1_VALID_PIXEL_MODE(x)                          (((unsigned)(x) & 0x1) << 20)
50 #define   G_SQ_CF_WORD1_VALID_PIXEL_MODE(x)                          (((x) >> 20) & 0x1)
51 #define   C_SQ_CF_WORD1_VALID_PIXEL_MODE                             0xFFEFFFFF
52 #define   S_SQ_CF_WORD1_END_OF_PROGRAM(x)                            (((unsigned)(x) & 0x1) << 21)
53 #define   G_SQ_CF_WORD1_END_OF_PROGRAM(x)                            (((x) >> 21) & 0x1)
54 #define   C_SQ_CF_WORD1_END_OF_PROGRAM                               0xFFDFFFFF
55 
56 #define   S_SQ_CF_WORD1_CF_INST(x)                                   (((unsigned)(x) & 0xFF) << 22)
57 #define   G_SQ_CF_WORD1_CF_INST(x)                                   (((x) >> 22) & 0xFF)
58 #define   C_SQ_CF_WORD1_CF_INST                                      0xC03FFFFF
59 
60 #define   S_SQ_CF_WORD1_WHOLE_QUAD_MODE(x)                           (((unsigned)(x) & 0x1) << 30)
61 #define   G_SQ_CF_WORD1_WHOLE_QUAD_MODE(x)                           (((x) >> 30) & 0x1)
62 #define   C_SQ_CF_WORD1_WHOLE_QUAD_MODE                              0xBFFFFFFF
63 #define   S_SQ_CF_WORD1_BARRIER(x)                                   (((unsigned)(x) & 0x1) << 31)
64 #define   G_SQ_CF_WORD1_BARRIER(x)                                   (((x) >> 31) & 0x1)
65 #define   C_SQ_CF_WORD1_BARRIER                                      0x7FFFFFFF
66 
67 /* done */
68 #define P_SQ_CF_ALU_WORD0
69 #define   S_SQ_CF_ALU_WORD0_ADDR(x)                                  (((unsigned)(x) & 0x3FFFFF) << 0)
70 #define   G_SQ_CF_ALU_WORD0_ADDR(x)                                  (((x) >> 0) & 0x3FFFFF)
71 #define   C_SQ_CF_ALU_WORD0_ADDR                                     0xFFC00000
72 #define   S_SQ_CF_ALU_WORD0_KCACHE_BANK0(x)                          (((unsigned)(x) & 0xF) << 22)
73 #define   G_SQ_CF_ALU_WORD0_KCACHE_BANK0(x)                          (((x) >> 22) & 0xF)
74 #define   C_SQ_CF_ALU_WORD0_KCACHE_BANK0                             0xFC3FFFFF
75 #define   S_SQ_CF_ALU_WORD0_KCACHE_BANK1(x)                          (((unsigned)(x) & 0xF) << 26)
76 #define   G_SQ_CF_ALU_WORD0_KCACHE_BANK1(x)                          (((x) >> 26) & 0xF)
77 #define   C_SQ_CF_ALU_WORD0_KCACHE_BANK1                             0xC3FFFFFF
78 #define   S_SQ_CF_ALU_WORD0_KCACHE_MODE0(x)                          (((unsigned)(x) & 0x3) << 30)
79 #define   G_SQ_CF_ALU_WORD0_KCACHE_MODE0(x)                          (((x) >> 30) & 0x3)
80 #define   C_SQ_CF_ALU_WORD0_KCACHE_MODE0                             0x3FFFFFFF
81 #define     V_SQ_CF_KCACHE_NOP                                       0x00000000
82 #define     V_SQ_CF_KCACHE_LOCK_1                                    0x00000001
83 #define     V_SQ_CF_KCACHE_LOCK_2                                    0x00000002
84 #define     V_SQ_CF_KCACHE_LOCK_LOOP_INDEX                           0x00000003
85 #define P_SQ_CF_ALU_WORD1
86 #define   S_SQ_CF_ALU_WORD1_KCACHE_MODE1(x)                          (((unsigned)(x) & 0x3) << 0)
87 #define   G_SQ_CF_ALU_WORD1_KCACHE_MODE1(x)                          (((x) >> 0) & 0x3)
88 #define   C_SQ_CF_ALU_WORD1_KCACHE_MODE1                             0xFFFFFFFC
89 #define   S_SQ_CF_ALU_WORD1_KCACHE_ADDR0(x)                          (((unsigned)(x) & 0xFF) << 2)
90 #define   G_SQ_CF_ALU_WORD1_KCACHE_ADDR0(x)                          (((x) >> 2) & 0xFF)
91 #define   C_SQ_CF_ALU_WORD1_KCACHE_ADDR0                             0xFFFFFC03
92 #define   S_SQ_CF_ALU_WORD1_KCACHE_ADDR1(x)                          (((unsigned)(x) & 0xFF) << 10)
93 #define   G_SQ_CF_ALU_WORD1_KCACHE_ADDR1(x)                          (((x) >> 10) & 0xFF)
94 #define   C_SQ_CF_ALU_WORD1_KCACHE_ADDR1                             0xFFFC03FF
95 #define   S_SQ_CF_ALU_WORD1_COUNT(x)                                 (((unsigned)(x) & 0x7F) << 18)
96 #define   G_SQ_CF_ALU_WORD1_COUNT(x)                                 (((x) >> 18) & 0x7F)
97 #define   C_SQ_CF_ALU_WORD1_COUNT                                    0xFE03FFFF
98 #define   S_SQ_CF_ALU_WORD1_ALT_CONST(x)                             (((unsigned)(x) & 0x1) << 25)
99 #define   G_SQ_CF_ALU_WORD1_ALT_CONST(x)                             (((x) >> 25) & 0x1)
100 #define   C_SQ_CF_ALU_WORD1_ALT_CONST                                0xFDFFFFFF
101 #define   S_SQ_CF_ALU_WORD1_CF_INST(x)                               (((unsigned)(x) & 0xF) << 26)
102 #define   G_SQ_CF_ALU_WORD1_CF_INST(x)                               (((x) >> 26) & 0xF)
103 #define   C_SQ_CF_ALU_WORD1_CF_INST                                  0xC3FFFFFF
104 #define   S_SQ_CF_ALU_WORD1_WHOLE_QUAD_MODE(x)                       (((unsigned)(x) & 0x1) << 30)
105 #define   G_SQ_CF_ALU_WORD1_WHOLE_QUAD_MODE(x)                       (((x) >> 30) & 0x1)
106 #define   C_SQ_CF_ALU_WORD1_WHOLE_QUAD_MODE                          0xBFFFFFFF
107 #define   S_SQ_CF_ALU_WORD1_BARRIER(x)                               (((unsigned)(x) & 0x1) << 31)
108 #define   G_SQ_CF_ALU_WORD1_BARRIER(x)                               (((x) >> 31) & 0x1)
109 #define   C_SQ_CF_ALU_WORD1_BARRIER                                  0x7FFFFFFF
110 
111 #define P_SQ_CF_ALU_WORD0_EXT
112 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE0(x)           (((unsigned)(x) & 0x3) << 4)
113 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE0(x)           (((x) >> 4) & 0x3)
114 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE0              0xFFFFFFCF
115 #define	    V_SQ_CF_INDEX_NONE                                       0x00
116 #define	    V_SQ_CF_INDEX_0                                          0x01
117 #define	    V_SQ_CF_INDEX_1                                          0x02
118 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE1(x)           (((unsigned)(x) & 0x3) << 6)
119 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE1(x)           (((x) >> 6) & 0x3)
120 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE1              0xFFFFFF3F
121 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE2(x)           (((unsigned)(x) & 0x3) << 8)
122 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE2(x)           (((x) >> 8) & 0x3)
123 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE2              0xFFFFFCFF
124 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE3(x)           (((unsigned)(x) & 0x3) << 10)
125 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE3(x)           (((x) >> 10) & 0x3)
126 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK_INDEX_MODE3              0xFFFFF3FF
127 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK2(x)                      (((unsigned)(x) & 0xF) << 22)
128 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK2(x)                      (((x) >> 22) & 0xF)
129 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK2                         0xFC3FFFFF
130 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK3(x)                      (((unsigned)(x) & 0xF) << 26)
131 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK3(x)                      (((x) >> 26) & 0xF)
132 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_BANK3                         0xC3FFFFFF
133 #define   S_SQ_CF_ALU_WORD0_EXT_KCACHE_MODE2(x)                      (((unsigned)(x) & 0x3) << 30)
134 #define   G_SQ_CF_ALU_WORD0_EXT_KCACHE_MODE2(x)                      (((x) >> 30) & 0x3)
135 #define   C_SQ_CF_ALU_WORD0_EXT_KCACHE_MODE2                         0x3FFFFFFF
136 
137 #define P_SQ_CF_ALU_WORD1_EXT
138 #define   S_SQ_CF_ALU_WORD1_EXT_KCACHE_MODE3(x)                      (((unsigned)(x) & 0x3) << 0)
139 #define   G_SQ_CF_ALU_WORD1_EXT_KCACHE_MODE3(x)                      (((x) >> 0) & 0x3)
140 #define   C_SQ_CF_ALU_WORD1_EXT_KCACHE_MODE3                         0xFFFFFFFC
141 #define   S_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR2(x)                      (((unsigned)(x) & 0xFF) << 2)
142 #define   G_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR2(x)                      (((x) >> 2) & 0xFF)
143 #define   C_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR2                         0xFFFFFC03
144 #define   S_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR3(x)                      (((unsigned)(x) & 0xFF) << 10)
145 #define   G_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR3(x)                      (((x) >> 10) & 0xFF)
146 #define   C_SQ_CF_ALU_WORD1_EXT_KCACHE_ADDR3                         0xFFFC03FF
147 #define   S_SQ_CF_ALU_WORD1_EXT_CF_INST(x)                           (((unsigned)(x) & 0xF) << 26)
148 #define   G_SQ_CF_ALU_WORD1_EXT_CF_INST(x)                           (((x) >> 26) & 0xF)
149 #define   C_SQ_CF_ALU_WORD1_EXT_CF_INST                              0xC3FFFFFF
150 #define   S_SQ_CF_ALU_WORD1_EXT_BARRIER(x)                           (((unsigned)(x) & 0x1) << 31)
151 #define   G_SQ_CF_ALU_WORD1_EXT_BARRIER(x)                           (((x) >> 31) & 0x1)
152 #define   C_SQ_CF_ALU_WORD1_EXT_BARRIER                              0x7FFFFFFF
153 
154 /* done */
155 #define P_SQ_CF_ALLOC_EXPORT_WORD0
156 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(x)                   (((unsigned)(x) & 0x1FFF) << 0)
157 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE(x)                   (((x) >> 0) & 0x1FFF)
158 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_ARRAY_BASE                      0xFFFFE000
159 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(x)                         (((unsigned)(x) & 0x3) << 13)
160 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_TYPE(x)                         (((x) >> 13) & 0x3)
161 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_TYPE                            0xFFFF9FFF
162 #define     V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL               0x00000000
163 #define     V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS                 0x00000001
164 #define     V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM               0x00000002
165 #define     V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE_IND_ACK       0x00000003
166 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(x)                       (((unsigned)(x) & 0x7F) << 15)
167 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR(x)                       (((x) >> 15) & 0x7F)
168 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_RW_GPR                          0xFFC07FFF
169 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_RW_REL(x)                       (((unsigned)(x) & 0x1) << 22)
170 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_RW_REL(x)                       (((x) >> 22) & 0x1)
171 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_RW_REL                          0xFFBFFFFF
172 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_INDEX_GPR(x)                    (((unsigned)(x) & 0x7F) << 23)
173 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_INDEX_GPR(x)                    (((x) >> 23) & 0x7F)
174 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_INDEX_GPR                       0xC07FFFFF
175 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(x)                    (((unsigned)(x) & 0x3) << 30)
176 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE(x)                    (((x) >> 30) & 0x3)
177 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_ELEM_SIZE                       0x3FFFFFFF
178 /* done */
179 
180 #define P_SQ_CF_ALLOC_EXPORT_WORD0_RAT
181 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_ID(x)                   (((x) & 0xF) << 0)
182 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_ID(x)                   (((x) >> 0) & 0xF)
183 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_ID                      0xFFFFFFF0
184 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INST(x)                 (((x) & 0x3F) << 4)
185 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INST(x)                 (((x) >> 4) & 0x3F)
186 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INST                    0xFFFFFC0F
187 #define   S_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INDEX_MODE(x)           (((x) & 0x3) << 11)
188 #define   G_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INDEX_MODE(x)           (((x) >> 11) & 0x3)
189 #define   C_SQ_CF_ALLOC_EXPORT_WORD0_RAT_RAT_INDEX_MODE              0xFFFFE7FF
190 
191 #define P_SQ_CF_ALLOC_EXPORT_WORD1
192 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(x)                  (((unsigned)(x) & 0xF) << 16)
193 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT(x)                  (((x) >> 16) & 0xF)
194 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_BURST_COUNT                     0xFFF0FFFF
195 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_VALID_PIXEL_MODE(x)             (((unsigned)(x) & 0x1) << 20)
196 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_VALID_PIXEL_MODE(x)             (((x) >> 20) & 0x1)
197 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_VALID_PIXEL_MODE                0xFFEFFFFF
198 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(x)               (((unsigned)(x) & 0x1) << 21)
199 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM(x)               (((x) >> 21) & 0x1)
200 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_END_OF_PROGRAM                  0xFFDFFFFF
201 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(x)                      (((unsigned)(x) & 0xFF) << 22)
202 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST(x)                      (((x) >> 22) & 0xFF)
203 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_CF_INST                         0xC03FFFFF
204 
205 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_MARK(x)                         (((unsigned)(x) & 0x1) << 30)
206 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_MARK(x)                         (((x) >> 30) & 0x1)
207 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_WHOLE_QUAD_MODE                 0xBFFFFFFF
208 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(x)                      (((unsigned)(x) & 0x1) << 31)
209 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER(x)                      (((x) >> 31) & 0x1)
210 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_BARRIER                         0x7FFFFFFF
211 
212 /* done */
213 #define P_SQ_CF_ALLOC_EXPORT_WORD1_BUF
214 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE(x)               (((unsigned)(x) & 0xFFF) << 0)
215 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE(x)               (((x) >> 0) & 0xFFF)
216 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_BUF_ARRAY_SIZE                  0xFFFFF000
217 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(x)                (((unsigned)(x) & 0xF) << 12)
218 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK(x)                (((x) >> 12) & 0xF)
219 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_BUF_COMP_MASK                   0xFFFF0FFF
220 #define P_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ
221 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X(x)                   (((unsigned)(x) & 0x7) << 0)
222 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X(x)                   (((x) >> 0) & 0x7)
223 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_X                      0xFFFFFFF8
224 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y(x)                   (((unsigned)(x) & 0x7) << 3)
225 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y(x)                   (((x) >> 3) & 0x7)
226 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Y                      0xFFFFFFC7
227 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z(x)                   (((unsigned)(x) & 0x7) << 6)
228 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z(x)                   (((x) >> 6) & 0x7)
229 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_Z                      0xFFFFFE3F
230 #define   S_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(x)                   (((unsigned)(x) & 0x7) << 9)
231 #define   G_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W(x)                   (((x) >> 9) & 0x7)
232 #define   C_SQ_CF_ALLOC_EXPORT_WORD1_SWIZ_SEL_W                      0xFFFFF1FF
233 
234 /* done */
235 #define P_SQ_ALU_WORD0
236 #define   S_SQ_ALU_WORD0_SRC0_SEL(x)                                 (((unsigned)(x) & 0x1FF) << 0)
237 #define   G_SQ_ALU_WORD0_SRC0_SEL(x)                                 (((x) >> 0) & 0x1FF)
238 #define   C_SQ_ALU_WORD0_SRC0_SEL                                    0xFFFFFE00
239 
240 /*
241  * 244  ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
242  * 245  ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
243  * 246  ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
244  * 247  ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
245  * 248  SQ_ALU_SRC_0: special constant 0.0.
246  * 249  SQ_ALU_SRC_1: special constant 1.0 float.
247  * 250  SQ_ALU_SRC_1_INT: special constant 1 integer.
248  * 251  SQ_ALU_SRC_M_1_INT: special constant -1 integer.
249  * 252  SQ_ALU_SRC_0_5: special constant 0.5 float.
250  * 253  SQ_ALU_SRC_LITERAL: literal constant.
251  * 254  SQ_ALU_SRC_PV: previous vector result.
252  * 255  SQ_ALU_SRC_PS: previous scalar result.
253  */
254 #define     V_SQ_ALU_SRC_0                                           0x000000F8
255 #define     V_SQ_ALU_SRC_1                                           0x000000F9
256 #define     V_SQ_ALU_SRC_1_INT                                       0x000000FA
257 #define     V_SQ_ALU_SRC_M_1_INT                                     0x000000FB
258 #define     V_SQ_ALU_SRC_0_5                                         0x000000FC
259 #define     V_SQ_ALU_SRC_LITERAL                                     0x000000FD
260 #define   S_SQ_ALU_WORD0_SRC0_REL(x)                                 (((unsigned)(x) & 0x1) << 9)
261 #define   G_SQ_ALU_WORD0_SRC0_REL(x)                                 (((x) >> 9) & 0x1)
262 #define   C_SQ_ALU_WORD0_SRC0_REL                                    0xFFFFFDFF
263 #define   S_SQ_ALU_WORD0_SRC0_CHAN(x)                                (((unsigned)(x) & 0x3) << 10)
264 #define   G_SQ_ALU_WORD0_SRC0_CHAN(x)                                (((x) >> 10) & 0x3)
265 #define   C_SQ_ALU_WORD0_SRC0_CHAN                                   0xFFFFF3FF
266 #define   S_SQ_ALU_WORD0_SRC0_NEG(x)                                 (((unsigned)(x) & 0x1) << 12)
267 #define   G_SQ_ALU_WORD0_SRC0_NEG(x)                                 (((x) >> 12) & 0x1)
268 #define   C_SQ_ALU_WORD0_SRC0_NEG                                    0xFFFFEFFF
269 #define   S_SQ_ALU_WORD0_SRC1_SEL(x)                                 (((unsigned)(x) & 0x1FF) << 13)
270 #define   G_SQ_ALU_WORD0_SRC1_SEL(x)                                 (((x) >> 13) & 0x1FF)
271 #define   C_SQ_ALU_WORD0_SRC1_SEL                                    0xFFC01FFF
272 #define   S_SQ_ALU_WORD0_SRC1_REL(x)                                 (((unsigned)(x) & 0x1) << 22)
273 #define   G_SQ_ALU_WORD0_SRC1_REL(x)                                 (((x) >> 22) & 0x1)
274 #define   C_SQ_ALU_WORD0_SRC1_REL                                    0xFFBFFFFF
275 #define   S_SQ_ALU_WORD0_SRC1_CHAN(x)                                (((unsigned)(x) & 0x3) << 23)
276 #define   G_SQ_ALU_WORD0_SRC1_CHAN(x)                                (((x) >> 23) & 0x3)
277 #define   C_SQ_ALU_WORD0_SRC1_CHAN                                   0xFE7FFFFF
278 #define   S_SQ_ALU_WORD0_SRC1_NEG(x)                                 (((unsigned)(x) & 0x1) << 25)
279 #define   G_SQ_ALU_WORD0_SRC1_NEG(x)                                 (((x) >> 25) & 0x1)
280 #define   C_SQ_ALU_WORD0_SRC1_NEG                                    0xFDFFFFFF
281 #define   S_SQ_ALU_WORD0_INDEX_MODE(x)                               (((unsigned)(x) & 0x7) << 26)
282 #define   G_SQ_ALU_WORD0_INDEX_MODE(x)                               (((x) >> 26) & 0x7)
283 #define   C_SQ_ALU_WORD0_INDEX_MODE                                  0xE3FFFFFF
284 #define   S_SQ_ALU_WORD0_PRED_SEL(x)                                 (((unsigned)(x) & 0x3) << 29)
285 #define   G_SQ_ALU_WORD0_PRED_SEL(x)                                 (((x) >> 29) & 0x3)
286 #define   C_SQ_ALU_WORD0_PRED_SEL                                    0x9FFFFFFF
287 #define   S_SQ_ALU_WORD0_LAST(x)                                     (((unsigned)(x) & 0x1) << 31)
288 #define   G_SQ_ALU_WORD0_LAST(x)                                     (((x) >> 31) & 0x1)
289 #define   C_SQ_ALU_WORD0_LAST                                        0x7FFFFFFF
290 /* same */
291 #define P_SQ_ALU_WORD1
292 #define   S_SQ_ALU_WORD1_ENCODING(x)                                 (((unsigned)(x) & 0x7) << 15)
293 #define   G_SQ_ALU_WORD1_ENCODING(x)                                 (((x) >> 15) & 0x7)
294 #define   C_SQ_ALU_WORD1_ENCODING                                    0xFFFC7FFF
295 #define   S_SQ_ALU_WORD1_BANK_SWIZZLE(x)                             (((unsigned)(x) & 0x7) << 18)
296 #define   G_SQ_ALU_WORD1_BANK_SWIZZLE(x)                             (((x) >> 18) & 0x7)
297 #define   C_SQ_ALU_WORD1_BANK_SWIZZLE                                0xFFE3FFFF
298 #define   S_SQ_ALU_WORD1_DST_GPR(x)                                  (((unsigned)(x) & 0x7F) << 21)
299 #define   G_SQ_ALU_WORD1_DST_GPR(x)                                  (((x) >> 21) & 0x7F)
300 #define   C_SQ_ALU_WORD1_DST_GPR                                     0xF01FFFFF
301 #define   S_SQ_ALU_WORD1_DST_REL(x)                                  (((unsigned)(x) & 0x1) << 28)
302 #define   G_SQ_ALU_WORD1_DST_REL(x)                                  (((x) >> 28) & 0x1)
303 #define   C_SQ_ALU_WORD1_DST_REL                                     0xEFFFFFFF
304 #define   S_SQ_ALU_WORD1_DST_CHAN(x)                                 (((unsigned)(x) & 0x3) << 29)
305 #define   G_SQ_ALU_WORD1_DST_CHAN(x)                                 (((x) >> 29) & 0x3)
306 #define   C_SQ_ALU_WORD1_DST_CHAN                                    0x9FFFFFFF
307 #define   S_SQ_ALU_WORD1_CLAMP(x)                                    (((unsigned)(x) & 0x1) << 31)
308 #define   G_SQ_ALU_WORD1_CLAMP(x)                                    (((x) >> 31) & 0x1)
309 #define   C_SQ_ALU_WORD1_CLAMP                                       0x7FFFFFFF
310 /* same except maybe encoding */
311 #define P_SQ_ALU_WORD1_OP2
312 #define   S_SQ_ALU_WORD1_OP2_SRC0_ABS(x)                             (((unsigned)(x) & 0x1) << 0)
313 #define   G_SQ_ALU_WORD1_OP2_SRC0_ABS(x)                             (((x) >> 0) & 0x1)
314 #define   C_SQ_ALU_WORD1_OP2_SRC0_ABS                                0xFFFFFFFE
315 #define   S_SQ_ALU_WORD1_OP2_SRC1_ABS(x)                             (((unsigned)(x) & 0x1) << 1)
316 #define   G_SQ_ALU_WORD1_OP2_SRC1_ABS(x)                             (((x) >> 1) & 0x1)
317 #define   C_SQ_ALU_WORD1_OP2_SRC1_ABS                                0xFFFFFFFD
318 #define   S_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(x)                  (((unsigned)(x) & 0x1) << 2)
319 #define   G_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK(x)                  (((x) >> 2) & 0x1)
320 #define   C_SQ_ALU_WORD1_OP2_UPDATE_EXECUTE_MASK                     0xFFFFFFFB
321 #define   S_SQ_ALU_WORD1_OP2_UPDATE_PRED(x)                          (((unsigned)(x) & 0x1) << 3)
322 #define   G_SQ_ALU_WORD1_OP2_UPDATE_PRED(x)                          (((x) >> 3) & 0x1)
323 #define   C_SQ_ALU_WORD1_OP2_UPDATE_PRED                             0xFFFFFFF7
324 #define   S_SQ_ALU_WORD1_OP2_WRITE_MASK(x)                           (((unsigned)(x) & 0x1) << 4)
325 #define   G_SQ_ALU_WORD1_OP2_WRITE_MASK(x)                           (((x) >> 4) & 0x1)
326 #define   C_SQ_ALU_WORD1_OP2_WRITE_MASK                              0xFFFFFFEF
327 #define   S_SQ_ALU_WORD1_OP2_OMOD(x)                                 (((unsigned)(x) & 0x3) << 5)
328 #define   G_SQ_ALU_WORD1_OP2_OMOD(x)                                 (((x) >> 5) & 0x3)
329 #define   C_SQ_ALU_WORD1_OP2_OMOD                                    0xFFFFFF9F
330 #define   S_SQ_ALU_WORD1_OP2_ALU_INST(x)                             (((unsigned)(x) & 0x7FF) << 7)
331 #define   G_SQ_ALU_WORD1_OP2_ALU_INST(x)                             (((x) >> 7) & 0x7FF)
332 #define   C_SQ_ALU_WORD1_OP2_ALU_INST                                0xFFFC007F
333 
334 #define P_SQ_ALU_WORD1_OP3
335 #define   S_SQ_ALU_WORD1_OP3_SRC2_SEL(x)                             (((unsigned)(x) & 0x1FF) << 0)
336 #define   G_SQ_ALU_WORD1_OP3_SRC2_SEL(x)                             (((x) >> 0) & 0x1FF)
337 #define   C_SQ_ALU_WORD1_OP3_SRC2_SEL                                0xFFFFFE00
338 #define   S_SQ_ALU_WORD1_OP3_SRC2_REL(x)                             (((unsigned)(x) & 0x1) << 9)
339 #define   G_SQ_ALU_WORD1_OP3_SRC2_REL(x)                             (((x) >> 9) & 0x1)
340 #define   C_SQ_ALU_WORD1_OP3_SRC2_REL                                0xFFFFFDFF
341 #define   S_SQ_ALU_WORD1_OP3_SRC2_CHAN(x)                            (((unsigned)(x) & 0x3) << 10)
342 #define   G_SQ_ALU_WORD1_OP3_SRC2_CHAN(x)                            (((x) >> 10) & 0x3)
343 #define   C_SQ_ALU_WORD1_OP3_SRC2_CHAN                               0xFFFFF3FF
344 #define   S_SQ_ALU_WORD1_OP3_SRC2_NEG(x)                             (((unsigned)(x) & 0x1) << 12)
345 #define   G_SQ_ALU_WORD1_OP3_SRC2_NEG(x)                             (((x) >> 12) & 0x1)
346 #define   C_SQ_ALU_WORD1_OP3_SRC2_NEG                                0xFFFFEFFF
347 #define   S_SQ_ALU_WORD1_OP3_ALU_INST(x)                             (((unsigned)(x) & 0x1F) << 13)
348 #define   G_SQ_ALU_WORD1_OP3_ALU_INST(x)                             (((x) >> 13) & 0x1F)
349 #define   C_SQ_ALU_WORD1_OP3_ALU_INST                                0xFFFC1FFF
350 /* XXX ADD OTHER OP3 */
351 /* done */
352 #define P_SQ_VTX_WORD0
353 #define   S_SQ_VTX_WORD0_VTX_INST(x)                                 (((unsigned)(x) & 0x1F) << 0)
354 #define   G_SQ_VTX_WORD0_VTX_INST(x)                                 (((x) >> 0) & 0x1F)
355 #define   C_SQ_VTX_WORD0_VTX_INST                                    0xFFFFFFE0
356 #define   S_SQ_VTX_WORD0_FETCH_TYPE(x)                               (((unsigned)(x) & 0x3) << 5)
357 #define   G_SQ_VTX_WORD0_FETCH_TYPE(x)                               (((x) >> 5) & 0x3)
358 #define   C_SQ_VTX_WORD0_FETCH_TYPE                                  0xFFFFFF9F
359 #define   S_SQ_VTX_WORD0_FETCH_WHOLE_QUAD(x)                         (((unsigned)(x) & 0x1) << 7)
360 #define   G_SQ_VTX_WORD0_FETCH_WHOLE_QUAD(x)                         (((x) >> 7) & 0x1)
361 #define   C_SQ_VTX_WORD0_FETCH_WHOLE_QUAD                            0xFFFFFF7F
362 #define   S_SQ_VTX_WORD0_BUFFER_ID(x)                                (((unsigned)(x) & 0xFF) << 8)
363 #define   G_SQ_VTX_WORD0_BUFFER_ID(x)                                (((x) >> 8) & 0xFF)
364 #define   C_SQ_VTX_WORD0_BUFFER_ID                                   0xFFFF00FF
365 #define   S_SQ_VTX_WORD0_SRC_GPR(x)                                  (((unsigned)(x) & 0x7F) << 16)
366 #define   G_SQ_VTX_WORD0_SRC_GPR(x)                                  (((x) >> 16) & 0x7F)
367 #define   C_SQ_VTX_WORD0_SRC_GPR                                     0xFF80FFFF
368 #define   S_SQ_VTX_WORD0_SRC_REL(x)                                  (((unsigned)(x) & 0x1) << 23)
369 #define   G_SQ_VTX_WORD0_SRC_REL(x)                                  (((x) >> 23) & 0x1)
370 #define   C_SQ_VTX_WORD0_SRC_REL                                     0xFF7FFFFF
371 #define   S_SQ_VTX_WORD0_SRC_SEL_X(x)                                (((unsigned)(x) & 0x3) << 24)
372 #define   G_SQ_VTX_WORD0_SRC_SEL_X(x)                                (((x) >> 24) & 0x3)
373 #define   C_SQ_VTX_WORD0_SRC_SEL_X                                   0xFCFFFFFF
374 #define   S_SQ_VTX_WORD0_MEGA_FETCH_COUNT(x)                         (((unsigned)(x) & 0x3F) << 26)
375 #define   G_SQ_VTX_WORD0_MEGA_FETCH_COUNT(x)                         (((x) >> 26) & 0x3F)
376 #define   C_SQ_VTX_WORD0_MEGA_FETCH_COUNT                            0x03FFFFFF
377 /* same WORD 0 */
378 #define P_SQ_VTX_WORD1
379 #define   S_SQ_VTX_WORD1_DST_SEL_X(x)                                (((unsigned)(x) & 0x7) << 9)
380 #define   G_SQ_VTX_WORD1_DST_SEL_X(x)                                (((x) >> 9) & 0x7)
381 #define   C_SQ_VTX_WORD1_DST_SEL_X                                   0xFFFFF1FF
382 #define   S_SQ_VTX_WORD1_DST_SEL_Y(x)                                (((unsigned)(x) & 0x7) << 12)
383 #define   G_SQ_VTX_WORD1_DST_SEL_Y(x)                                (((x) >> 12) & 0x7)
384 #define   C_SQ_VTX_WORD1_DST_SEL_Y                                   0xFFFF8FFF
385 #define   S_SQ_VTX_WORD1_DST_SEL_Z(x)                                (((unsigned)(x) & 0x7) << 15)
386 #define   G_SQ_VTX_WORD1_DST_SEL_Z(x)                                (((x) >> 15) & 0x7)
387 #define   C_SQ_VTX_WORD1_DST_SEL_Z                                   0xFFFC7FFF
388 #define   S_SQ_VTX_WORD1_DST_SEL_W(x)                                (((unsigned)(x) & 0x7) << 18)
389 #define   G_SQ_VTX_WORD1_DST_SEL_W(x)                                (((x) >> 18) & 0x7)
390 #define   C_SQ_VTX_WORD1_DST_SEL_W                                   0xFFE3FFFF
391 #define   S_SQ_VTX_WORD1_USE_CONST_FIELDS(x)                         (((unsigned)(x) & 0x1) << 21)
392 #define   G_SQ_VTX_WORD1_USE_CONST_FIELDS(x)                         (((x) >> 21) & 0x1)
393 #define   C_SQ_VTX_WORD1_USE_CONST_FIELDS                            0xFFDFFFFF
394 #define   S_SQ_VTX_WORD1_DATA_FORMAT(x)                              (((unsigned)(x) & 0x3F) << 22)
395 #define   G_SQ_VTX_WORD1_DATA_FORMAT(x)                              (((x) >> 22) & 0x3F)
396 #define   C_SQ_VTX_WORD1_DATA_FORMAT                                 0xF03FFFFF
397 #define   S_SQ_VTX_WORD1_NUM_FORMAT_ALL(x)                           (((unsigned)(x) & 0x3) << 28)
398 #define   G_SQ_VTX_WORD1_NUM_FORMAT_ALL(x)                           (((x) >> 28) & 0x3)
399 #define   C_SQ_VTX_WORD1_NUM_FORMAT_ALL                              0xCFFFFFFF
400 #define   S_SQ_VTX_WORD1_FORMAT_COMP_ALL(x)                          (((unsigned)(x) & 0x1) << 30)
401 #define   G_SQ_VTX_WORD1_FORMAT_COMP_ALL(x)                          (((x) >> 30) & 0x1)
402 #define   C_SQ_VTX_WORD1_FORMAT_COMP_ALL                             0xBFFFFFFF
403 #define   S_SQ_VTX_WORD1_SRF_MODE_ALL(x)                             (((unsigned)(x) & 0x1) << 31)
404 #define   G_SQ_VTX_WORD1_SRF_MODE_ALL(x)                             (((x) >> 31) & 0x1)
405 #define   C_SQ_VTX_WORD1_SRF_MODE_ALL                                0x7FFFFFFF
406 /* same WORD1 generic */
407 #define P_SQ_VTX_WORD1_GPR
408 #define   S_SQ_VTX_WORD1_GPR_DST_GPR(x)                              (((unsigned)(x) & 0x7F) << 0)
409 #define   G_SQ_VTX_WORD1_GPR_DST_GPR(x)                              (((x) >> 0) & 0x7F)
410 #define   C_SQ_VTX_WORD1_GPR_DST_GPR                                 0xFFFFFF80
411 #define   S_SQ_VTX_WORD1_GPR_DST_REL(x)                              (((unsigned)(x) & 0x1) << 7)
412 #define   G_SQ_VTX_WORD1_GPR_DST_REL(x)                              (((x) >> 7) & 0x1)
413 #define   C_SQ_VTX_WORD1_GPR_DST_REL                                 0xFFFFFF7F
414 #define P_SQ_VTX_WORD1_SEM
415 #define   S_SQ_VTX_WORD1_SEM_SEMANTIC_ID(x)                          (((unsigned)(x) & 0xFF) << 0)
416 #define   G_SQ_VTX_WORD1_SEM_SEMANTIC_ID(x)                          (((x) >> 0) & 0xFF)
417 #define   C_SQ_VTX_WORD1_SEM_SEMANTIC_ID                             0xFFFFFF00
418 #define P_SQ_VTX_WORD2
419 #define   S_SQ_VTX_WORD2_OFFSET(x)                                   (((unsigned)(x) & 0xFFFF) << 0)
420 #define   G_SQ_VTX_WORD2_OFFSET(x)                                   (((x) >> 0) & 0xFFFF)
421 #define   C_SQ_VTX_WORD2_OFFSET                                      0xFFFF0000
422 #define   S_SQ_VTX_WORD2_ENDIAN_SWAP(x)                              (((unsigned)(x) & 0x3) << 16)
423 #define   G_SQ_VTX_WORD2_ENDIAN_SWAP(x)                              (((x) >> 16) & 0x3)
424 #define   C_SQ_VTX_WORD2_ENDIAN_SWAP                                 0xFFFCFFFF
425 #define   S_SQ_VTX_WORD2_CONST_BUF_NO_STRIDE(x)                      (((unsigned)(x) & 0x1) << 18)
426 #define   G_SQ_VTX_WORD2_CONST_BUF_NO_STRIDE(x)                      (((x) >> 18) & 0x1)
427 #define   C_SQ_VTX_WORD2_CONST_BUF_NO_STRIDE                         0xFFFBFFFF
428 #define   S_SQ_VTX_WORD2_MEGA_FETCH(x)                               (((unsigned)(x) & 0x1) << 19)
429 #define   G_SQ_VTX_WORD2_MEGA_FETCH(x)                               (((x) >> 19) & 0x1)
430 #define   C_SQ_VTX_WORD2_MEGA_FETCH                                  0xFFF7FFFF
431 #define   S_SQ_VTX_WORD2_ALT_CONST(x)                                (((unsigned)(x) & 0x1) << 20)
432 #define   G_SQ_VTX_WORD2_ALT_CONST(x)                                (((x) >> 20) & 0x1)
433 #define   C_SQ_VTX_WORD2_ALT_CONST                                   0xFFEFFFFF
434 #define   S_SQ_VTX_WORD2_BIM(x)                                      (((unsigned)(x) & 0x3) << 21)
435 #define   G_SQ_VTX_WORD2_BIM(x)                                      (((x) >> 21) & 0x3)
436 #define   C_SQ_VTX_WORD2_BIM                                         0xFF9FFFFF
437 /* done */
438 
439 #define P_SQ_TEX_WORD0
440 #define   S_SQ_TEX_WORD0_TEX_INST(x)                                 (((unsigned)(x) & 0x1F) << 0)
441 #define   G_SQ_TEX_WORD0_TEX_INST(x)                                 (((x) >> 0) & 0x1F)
442 #define   C_SQ_TEX_WORD0_TEX_INST                                    0xFFFFFFE0
443 #define   S_SQ_TEX_WORD0_INST_MOD(x)                                 (((unsigned)(x) & 0x3) << 5)
444 #define   G_SQ_TEX_WORD0_INST_MOD(x)                                 (((x) >> 5) & 0x3)
445 #define   C_SQ_TEX_WORD0_INST_MOD                                    0xFFFFFF9F
446 #define   S_SQ_TEX_WORD0_FETCH_WHOLE_QUAD(x)                         (((unsigned)(x) & 0x1) << 7)
447 #define   G_SQ_TEX_WORD0_FETCH_WHOLE_QUAD(x)                         (((x) >> 7) & 0x1)
448 #define   C_SQ_TEX_WORD0_FETCH_WHOLE_QUAD                            0xFFFFFF7F
449 #define   S_SQ_TEX_WORD0_RESOURCE_ID(x)                              (((unsigned)(x) & 0xFF) << 8)
450 #define   G_SQ_TEX_WORD0_RESOURCE_ID(x)                              (((x) >> 8) & 0xFF)
451 #define   C_SQ_TEX_WORD0_RESOURCE_ID                                 0xFFFF00FF
452 #define   S_SQ_TEX_WORD0_SRC_GPR(x)                                  (((unsigned)(x) & 0x7F) << 16)
453 #define   G_SQ_TEX_WORD0_SRC_GPR(x)                                  (((x) >> 16) & 0x7F)
454 #define   C_SQ_TEX_WORD0_SRC_GPR                                     0xFF80FFFF
455 #define   S_SQ_TEX_WORD0_SRC_REL(x)                                  (((unsigned)(x) & 0x1) << 23)
456 #define   G_SQ_TEX_WORD0_SRC_REL(x)                                  (((x) >> 23) & 0x1)
457 #define   C_SQ_TEX_WORD0_SRC_REL                                     0xFF7FFFFF
458 #define   S_SQ_TEX_WORD0_ALT_CONST(x)                                (((unsigned)(x) & 0x1) << 24)
459 #define   G_SQ_TEX_WORD0_ALT_CONST(x)                                (((x) >> 24) & 0x1)
460 #define   C_SQ_TEX_WORD0_ALT_CONST                                   0xFEFFFFFF
461 #define   S_SQ_TEX_WORD0_RIM(x)                                      (((unsigned)(x) & 0x3) << 25)
462 #define   G_SQ_TEX_WORD0_RIM(x)                                      (((x) >> 25) & 0x3)
463 #define   C_SQ_TEX_WORD0_RIM                                         0xF9FFFFFF
464 #define   S_SQ_TEX_WORD0_SIM(x)                                      (((unsigned)(x) & 0x3) << 27)
465 #define   G_SQ_TEX_WORD0_SIM(x)                                      (((x) >> 27) & 0x3)
466 #define   C_SQ_TEX_WORD0_SIM                                         0xE7FFFFFF
467 #define P_SQ_TEX_WORD1
468 #define   S_SQ_TEX_WORD1_DST_GPR(x)                                  (((unsigned)(x) & 0x7F) << 0)
469 #define   G_SQ_TEX_WORD1_DST_GPR(x)                                  (((x) >> 0) & 0x7F)
470 #define   C_SQ_TEX_WORD1_DST_GPR                                     0xFFFFFF80
471 #define   S_SQ_TEX_WORD1_DST_REL(x)                                  (((unsigned)(x) & 0x1) << 7)
472 #define   G_SQ_TEX_WORD1_DST_REL(x)                                  (((x) >> 7) & 0x1)
473 #define   C_SQ_TEX_WORD1_DST_REL                                     0xFFFFFF7F
474 #define   S_SQ_TEX_WORD1_DST_SEL_X(x)                                (((unsigned)(x) & 0x7) << 9)
475 #define   G_SQ_TEX_WORD1_DST_SEL_X(x)                                (((x) >> 9) & 0x7)
476 #define   C_SQ_TEX_WORD1_DST_SEL_X                                   0xFFFFF1FF
477 #define   S_SQ_TEX_WORD1_DST_SEL_Y(x)                                (((unsigned)(x) & 0x7) << 12)
478 #define   G_SQ_TEX_WORD1_DST_SEL_Y(x)                                (((x) >> 12) & 0x7)
479 #define   C_SQ_TEX_WORD1_DST_SEL_Y                                   0xFFFF8FFF
480 #define   S_SQ_TEX_WORD1_DST_SEL_Z(x)                                (((unsigned)(x) & 0x7) << 15)
481 #define   G_SQ_TEX_WORD1_DST_SEL_Z(x)                                (((x) >> 15) & 0x7)
482 #define   C_SQ_TEX_WORD1_DST_SEL_Z                                   0xFFFC7FFF
483 #define   S_SQ_TEX_WORD1_DST_SEL_W(x)                                (((unsigned)(x) & 0x7) << 18)
484 #define   G_SQ_TEX_WORD1_DST_SEL_W(x)                                (((x) >> 18) & 0x7)
485 #define   C_SQ_TEX_WORD1_DST_SEL_W                                   0xFFE3FFFF
486 #define   S_SQ_TEX_WORD1_LOD_BIAS(x)                                 (((unsigned)(x) & 0x7F) << 21)
487 #define   G_SQ_TEX_WORD1_LOD_BIAS(x)                                 (((x) >> 21) & 0x7F)
488 #define   C_SQ_TEX_WORD1_LOD_BIAS                                    0xF01FFFFF
489 #define   S_SQ_TEX_WORD1_COORD_TYPE_X(x)                             (((unsigned)(x) & 0x1) << 28)
490 #define   G_SQ_TEX_WORD1_COORD_TYPE_X(x)                             (((x) >> 28) & 0x1)
491 #define   C_SQ_TEX_WORD1_COORD_TYPE_X                                0xEFFFFFFF
492 #define     V_SQ_TEX_WORD1_COORD_UNNORMALIZED                        0x00000000
493 #define     V_SQ_TEX_WORD1_COORD_NORMALIZED                          0x00000001
494 #define   S_SQ_TEX_WORD1_COORD_TYPE_Y(x)                             (((unsigned)(x) & 0x1) << 29)
495 #define   G_SQ_TEX_WORD1_COORD_TYPE_Y(x)                             (((x) >> 29) & 0x1)
496 #define   C_SQ_TEX_WORD1_COORD_TYPE_Y                                0xDFFFFFFF
497 #define   S_SQ_TEX_WORD1_COORD_TYPE_Z(x)                             (((unsigned)(x) & 0x1) << 30)
498 #define   G_SQ_TEX_WORD1_COORD_TYPE_Z(x)                             (((x) >> 30) & 0x1)
499 #define   C_SQ_TEX_WORD1_COORD_TYPE_Z                                0xBFFFFFFF
500 #define   S_SQ_TEX_WORD1_COORD_TYPE_W(x)                             (((unsigned)(x) & 0x1) << 31)
501 #define   G_SQ_TEX_WORD1_COORD_TYPE_W(x)                             (((x) >> 31) & 0x1)
502 #define   C_SQ_TEX_WORD1_COORD_TYPE_W                                0x7FFFFFFF
503 #define P_SQ_TEX_WORD2
504 #define   S_SQ_TEX_WORD2_OFFSET_X(x)                                 (((unsigned)(x) & 0x1F) << 0)
505 #define   G_SQ_TEX_WORD2_OFFSET_X(x)                                 (((x) >> 0) & 0x1F)
506 #define   C_SQ_TEX_WORD2_OFFSET_X                                    0xFFFFFFE0
507 #define   S_SQ_TEX_WORD2_OFFSET_Y(x)                                 (((unsigned)(x) & 0x1F) << 5)
508 #define   G_SQ_TEX_WORD2_OFFSET_Y(x)                                 (((x) >> 5) & 0x1F)
509 #define   C_SQ_TEX_WORD2_OFFSET_Y                                    0xFFFFFC1F
510 #define   S_SQ_TEX_WORD2_OFFSET_Z(x)                                 (((unsigned)(x) & 0x1F) << 10)
511 #define   G_SQ_TEX_WORD2_OFFSET_Z(x)                                 (((x) >> 10) & 0x1F)
512 #define   C_SQ_TEX_WORD2_OFFSET_Z                                    0xFFFF83FF
513 #define   S_SQ_TEX_WORD2_SAMPLER_ID(x)                               (((unsigned)(x) & 0x1F) << 15)
514 #define   G_SQ_TEX_WORD2_SAMPLER_ID(x)                               (((x) >> 15) & 0x1F)
515 #define   C_SQ_TEX_WORD2_SAMPLER_ID                                  0xFFF07FFF
516 #define   S_SQ_TEX_WORD2_SRC_SEL_X(x)                                (((unsigned)(x) & 0x7) << 20)
517 #define   G_SQ_TEX_WORD2_SRC_SEL_X(x)                                (((x) >> 20) & 0x7)
518 #define   C_SQ_TEX_WORD2_SRC_SEL_X                                   0xFF8FFFFF
519 #define   S_SQ_TEX_WORD2_SRC_SEL_Y(x)                                (((unsigned)(x) & 0x7) << 23)
520 #define   G_SQ_TEX_WORD2_SRC_SEL_Y(x)                                (((x) >> 23) & 0x7)
521 #define   C_SQ_TEX_WORD2_SRC_SEL_Y                                   0xFC7FFFFF
522 #define   S_SQ_TEX_WORD2_SRC_SEL_Z(x)                                (((unsigned)(x) & 0x7) << 26)
523 #define   G_SQ_TEX_WORD2_SRC_SEL_Z(x)                                (((x) >> 26) & 0x7)
524 #define   C_SQ_TEX_WORD2_SRC_SEL_Z                                   0xE3FFFFFF
525 #define   S_SQ_TEX_WORD2_SRC_SEL_W(x)                                (((unsigned)(x) & 0x7) << 29)
526 #define   G_SQ_TEX_WORD2_SRC_SEL_W(x)                                (((x) >> 29) & 0x7)
527 #define   C_SQ_TEX_WORD2_SRC_SEL_W                                   0x1FFFFFFF
528 
529 #define P_SQ_MEM_GDS_WORD0
530 #define   S_SQ_MEM_GDS_WORD0_MEM_INST(x)                             (((unsigned)(x) & 0x1f) << 0)
531 #define   S_SQ_MEM_GDS_WORD0_MEM_OP(x)                               (((unsigned)(x) & 0x7) << 8)
532 #define   S_SQ_MEM_GDS_WORD0_SRC_GPR(x)                              (((unsigned)(x) & 0x7f) << 11)
533 #define   S_SQ_MEM_GDS_WORD0_SRC_REL(x)                              (((unsigned)(x) & 0x3) << 18)
534 #define   S_SQ_MEM_GDS_WORD0_SRC_SEL_X(x)                            (((unsigned)(x) & 0x7) << 20)
535 #define   S_SQ_MEM_GDS_WORD0_SRC_SEL_Y(x)                            (((unsigned)(x) & 0x7) << 23)
536 #define   S_SQ_MEM_GDS_WORD0_SRC_SEL_Z(x)                            (((unsigned)(x) & 0x7) << 26)
537 
538 #define P_SQ_MEM_GDS_WORD1
539 #define   S_SQ_MEM_GDS_WORD1_DST_GPR(x)                              (((unsigned)(x) & 0x7f) << 0)
540 #define   S_SQ_MEM_GDS_WORD1_DST_REL(x)                              (((unsigned)(x) & 0x3) << 7)
541 #define   S_SQ_MEM_GDS_WORD1_GDS_OP(x)                               (((unsigned)(x) & 0x3f) << 9)
542 #define   S_SQ_MEM_GDS_WORD1_SRC_GPR(x)                              (((unsigned)(x) & 0x7f) << 16)
543 #define   S_SQ_MEM_GDS_WORD1_UAV_INDEX_MODE(x)                       (((unsigned)(x) & 0x3) << 24)
544 #define   S_SQ_MEM_GDS_WORD1_UAV_ID(x)                               (((unsigned)(x) & 0xf) << 26)
545 #define   S_SQ_MEM_GDS_WORD1_ALLOC_CONSUME(x)                        (((unsigned)(x) & 0x1) << 30)
546 #define   S_SQ_MEM_GDS_WORD1_BCAST_FIRST_REQ(x)                      (((unsigned)(x) & 0x1) << 31)
547 
548 #define P_SQ_MEM_GDS_WORD2
549 #define   S_SQ_MEM_GDS_WORD2_DST_SEL_X(x)                            (((unsigned)(x) & 0x7) << 0)
550 #define   S_SQ_MEM_GDS_WORD2_DST_SEL_Y(x)                            (((unsigned)(x) & 0x7) << 3)
551 #define   S_SQ_MEM_GDS_WORD2_DST_SEL_Z(x)                            (((unsigned)(x) & 0x7) << 6)
552 #define   S_SQ_MEM_GDS_WORD2_DST_SEL_W(x)                            (((unsigned)(x) & 0x7) << 9)
553 
554 /* LDS IDX redefines the neg bits on op3 */
555 #define S_SQ_ALU_WORD0_LDS_IDX_OP_IDX_OFFSET_4(x)                    (((unsigned)(x) & 0x1) << 12)
556 #define S_SQ_ALU_WORD0_LDS_IDX_OP_IDX_OFFSET_5(x)                    (((unsigned)(x) & 0x1) << 25)
557 
558 /* src2 neg */
559 #define S_SQ_ALU_WORD1_LDS_IDX_OP_IDX_OFFSET_1(x)                    (((unsigned)(x) & 0x1) << 12)
560 
561 /* this was dst gpr */
562 #define S_SQ_ALU_WORD1_LDS_IDX_OP_LDS_OP(x)                    (((unsigned)(x) & 0x3f) << 21)
563 #define S_SQ_ALU_WORD1_LDS_IDX_OP_IDX_OFFSET_0(x)                    (((unsigned)(x) & 0x1) << 27)
564 
565 /* this was dst rel */
566 #define S_SQ_ALU_WORD1_LDS_IDX_OP_IDX_OFFSET_2(x)                    (((unsigned)(x) & 0x1) << 28)
567 /* this was clamp */
568 #define S_SQ_ALU_WORD1_LDS_IDX_OP_IDX_OFFSET_3(x)                    (((unsigned)(x) & 0x1) << 31)
569 
570 #define V_SQ_LDS_INST_ADD                               0x00
571 #define V_SQ_LDS_INST_SUB                               0x01
572 #define V_SQ_LDS_INST_RSUB                              0x02
573 
574 #define V_SQ_LDS_INST_INC                               0x03
575 #define V_SQ_LDS_INST_DEC                               0x04
576 #define V_SQ_LDS_INST_MIN_INT                           0x05
577 #define V_SQ_LDS_INST_MAX_INT                           0x06
578 #define V_SQ_LDS_INST_MIN_UINT                          0x07
579 #define V_SQ_LDS_INST_MAX_UINT                          0x08
580 #define V_SQ_LDS_INST_AND                               0x09
581 #define V_SQ_LDS_INST_OR                                0x0a
582 #define V_SQ_LDS_INST_XOR                               0x0b
583 #define V_SQ_LDS_INST_MSKOR                             0x0c
584 #define V_SQ_LDS_INST_WRITE                             0x0d
585 #define V_SQ_LDS_INST_WRITE_REL                         0x0e
586 #define V_SQ_LDS_INST_WRITE2                            0x0f
587 
588 #define V_SQ_LDS_INST_READ_RET                          0x32
589 #define V_SQ_LDS_INST_READ_REL_RET                      0x33
590 #define V_SQ_LDS_INST_READ2_RET                         0x34
591 #define V_SQ_LDS_INST_READWRITE_RET                     0x35
592 
593 #define V_SQ_CF_COND_ACTIVE                             0x00
594 #define V_SQ_CF_COND_FALSE                              0x01
595 #define V_SQ_CF_COND_BOOL                               0x02
596 #define V_SQ_CF_COND_NOT_BOOL                           0x03
597 
598 #define V_SQ_REL_ABSOLUTE 0
599 #define V_SQ_REL_RELATIVE 1
600 
601 /* CAYMAN has special encoding for MOVA_INT destination */
602 #define CM_V_SQ_MOVA_DST_AR_X 0
603 #define CM_V_SQ_MOVA_DST_CF_PC 1
604 #define CM_V_SQ_MOVA_DST_CF_IDX0 2
605 #define CM_V_SQ_MOVA_DST_CF_IDX1 3
606 
607 #endif
608