freedreno: slurp in decode tools
[mesa.git] / src / freedreno / decode / instr-a2xx.h
1 /*
2 * Copyright (c) 2012 Rob Clark <robdclark@gmail.com>
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 #ifndef INSTR_A2XX_H_
25 #define INSTR_A2XX_H_
26
27 #define PACKED __attribute__((__packed__))
28
29
30 /*
31 * ALU instructions:
32 */
33
34 typedef enum {
35 ADDs = 0,
36 ADD_PREVs = 1,
37 MULs = 2,
38 MUL_PREVs = 3,
39 MUL_PREV2s = 4,
40 MAXs = 5,
41 MINs = 6,
42 SETEs = 7,
43 SETGTs = 8,
44 SETGTEs = 9,
45 SETNEs = 10,
46 FRACs = 11,
47 TRUNCs = 12,
48 FLOORs = 13,
49 EXP_IEEE = 14,
50 LOG_CLAMP = 15,
51 LOG_IEEE = 16,
52 RECIP_CLAMP = 17,
53 RECIP_FF = 18,
54 RECIP_IEEE = 19,
55 RECIPSQ_CLAMP = 20,
56 RECIPSQ_FF = 21,
57 RECIPSQ_IEEE = 22,
58 MOVAs = 23,
59 MOVA_FLOORs = 24,
60 SUBs = 25,
61 SUB_PREVs = 26,
62 PRED_SETEs = 27,
63 PRED_SETNEs = 28,
64 PRED_SETGTs = 29,
65 PRED_SETGTEs = 30,
66 PRED_SET_INVs = 31,
67 PRED_SET_POPs = 32,
68 PRED_SET_CLRs = 33,
69 PRED_SET_RESTOREs = 34,
70 KILLEs = 35,
71 KILLGTs = 36,
72 KILLGTEs = 37,
73 KILLNEs = 38,
74 KILLONEs = 39,
75 SQRT_IEEE = 40,
76 MUL_CONST_0 = 42,
77 MUL_CONST_1 = 43,
78 ADD_CONST_0 = 44,
79 ADD_CONST_1 = 45,
80 SUB_CONST_0 = 46,
81 SUB_CONST_1 = 47,
82 SIN = 48,
83 COS = 49,
84 RETAIN_PREV = 50,
85 } instr_scalar_opc_t;
86
87 typedef enum {
88 ADDv = 0,
89 MULv = 1,
90 MAXv = 2,
91 MINv = 3,
92 SETEv = 4,
93 SETGTv = 5,
94 SETGTEv = 6,
95 SETNEv = 7,
96 FRACv = 8,
97 TRUNCv = 9,
98 FLOORv = 10,
99 MULADDv = 11,
100 CNDEv = 12,
101 CNDGTEv = 13,
102 CNDGTv = 14,
103 DOT4v = 15,
104 DOT3v = 16,
105 DOT2ADDv = 17,
106 CUBEv = 18,
107 MAX4v = 19,
108 PRED_SETE_PUSHv = 20,
109 PRED_SETNE_PUSHv = 21,
110 PRED_SETGT_PUSHv = 22,
111 PRED_SETGTE_PUSHv = 23,
112 KILLEv = 24,
113 KILLGTv = 25,
114 KILLGTEv = 26,
115 KILLNEv = 27,
116 DSTv = 28,
117 MOVAv = 29,
118 } instr_vector_opc_t;
119
120 typedef struct PACKED {
121 /* dword0: */
122 uint8_t vector_dest : 6;
123 uint8_t vector_dest_rel : 1;
124 uint8_t low_precision_16b_fp : 1;
125 uint8_t scalar_dest : 6;
126 uint8_t scalar_dest_rel : 1;
127 uint8_t export_data : 1;
128 uint8_t vector_write_mask : 4;
129 uint8_t scalar_write_mask : 4;
130 uint8_t vector_clamp : 1;
131 uint8_t scalar_clamp : 1;
132 instr_scalar_opc_t scalar_opc : 6;
133 /* dword1: */
134 uint8_t src3_swiz : 8;
135 uint8_t src2_swiz : 8;
136 uint8_t src1_swiz : 8;
137 uint8_t src3_reg_negate : 1;
138 uint8_t src2_reg_negate : 1;
139 uint8_t src1_reg_negate : 1;
140 uint8_t pred_select : 2;
141 uint8_t relative_addr : 1;
142 uint8_t const_1_rel_abs : 1;
143 uint8_t const_0_rel_abs : 1;
144 /* dword2: */
145 uint8_t src3_reg : 6;
146 uint8_t src3_reg_select : 1;
147 uint8_t src3_reg_abs : 1;
148 uint8_t src2_reg : 6;
149 uint8_t src2_reg_select : 1;
150 uint8_t src2_reg_abs : 1;
151 uint8_t src1_reg : 6;
152 uint8_t src1_reg_select : 1;
153 uint8_t src1_reg_abs : 1;
154 instr_vector_opc_t vector_opc : 5;
155 uint8_t src3_sel : 1;
156 uint8_t src2_sel : 1;
157 uint8_t src1_sel : 1;
158 } instr_alu_t;
159
160
161
162 /*
163 * CF instructions:
164 */
165
166 typedef enum {
167 NOP = 0,
168 EXEC = 1,
169 EXEC_END = 2,
170 COND_EXEC = 3,
171 COND_EXEC_END = 4,
172 COND_PRED_EXEC = 5,
173 COND_PRED_EXEC_END = 6,
174 LOOP_START = 7,
175 LOOP_END = 8,
176 COND_CALL = 9,
177 RETURN = 10,
178 COND_JMP = 11,
179 ALLOC = 12,
180 COND_EXEC_PRED_CLEAN = 13,
181 COND_EXEC_PRED_CLEAN_END = 14,
182 MARK_VS_FETCH_DONE = 15,
183 } instr_cf_opc_t;
184
185 typedef enum {
186 RELATIVE_ADDR = 0,
187 ABSOLUTE_ADDR = 1,
188 } instr_addr_mode_t;
189
190 typedef enum {
191 SQ_NO_ALLOC = 0,
192 SQ_POSITION = 1,
193 SQ_PARAMETER_PIXEL = 2,
194 SQ_MEMORY = 3,
195 } instr_alloc_type_t;
196
197 typedef struct PACKED {
198 uint16_t address : 9;
199 uint8_t reserved0 : 3;
200 uint8_t count : 3;
201 uint8_t yeild : 1;
202 uint16_t serialize : 12;
203 uint8_t vc : 6; /* vertex cache? */
204 uint8_t bool_addr : 8;
205 uint8_t condition : 1;
206 instr_addr_mode_t address_mode : 1;
207 instr_cf_opc_t opc : 4;
208 } instr_cf_exec_t;
209
210 typedef struct PACKED {
211 uint16_t address : 10;
212 uint8_t reserved0 : 6;
213 uint8_t loop_id : 5;
214 uint32_t reserved1 : 22;
215 instr_addr_mode_t address_mode : 1;
216 instr_cf_opc_t opc : 4;
217 } instr_cf_loop_t;
218
219 typedef struct PACKED {
220 uint16_t address : 10;
221 uint8_t reserved0 : 3;
222 uint8_t force_call : 1;
223 uint8_t predicated_jmp : 1;
224 uint32_t reserved1 : 18;
225 uint8_t direction : 1;
226 uint8_t bool_addr : 8;
227 uint8_t condition : 1;
228 instr_addr_mode_t address_mode : 1;
229 instr_cf_opc_t opc : 4;
230 } instr_cf_jmp_call_t;
231
232 typedef struct PACKED {
233 uint8_t size : 4;
234 uint64_t reserved0 : 36;
235 uint8_t no_serial : 1;
236 instr_alloc_type_t buffer_select : 2;
237 uint8_t alloc_mode : 1;
238 instr_cf_opc_t opc : 4;
239 } instr_cf_alloc_t;
240
241 typedef union PACKED {
242 instr_cf_exec_t exec;
243 instr_cf_loop_t loop;
244 instr_cf_jmp_call_t jmp_call;
245 instr_cf_alloc_t alloc;
246 struct PACKED {
247 uint64_t dummy : 44;
248 instr_cf_opc_t opc : 4;
249 };
250 } instr_cf_t;
251
252
253
254 /*
255 * FETCH instructions:
256 */
257
258 typedef enum {
259 VTX_FETCH = 0,
260 TEX_FETCH = 1,
261 TEX_GET_BORDER_COLOR_FRAC = 16,
262 TEX_GET_COMP_TEX_LOD = 17,
263 TEX_GET_GRADIENTS = 18,
264 TEX_GET_WEIGHTS = 19,
265 TEX_SET_TEX_LOD = 24,
266 TEX_SET_GRADIENTS_H = 25,
267 TEX_SET_GRADIENTS_V = 26,
268 TEX_RESERVED_4 = 27,
269 } instr_fetch_opc_t;
270
271 typedef enum {
272 TEX_FILTER_POINT = 0,
273 TEX_FILTER_LINEAR = 1,
274 TEX_FILTER_BASEMAP = 2, /* only applicable for mip-filter */
275 TEX_FILTER_USE_FETCH_CONST = 3,
276 } instr_tex_filter_t;
277
278 typedef enum {
279 ANISO_FILTER_DISABLED = 0,
280 ANISO_FILTER_MAX_1_1 = 1,
281 ANISO_FILTER_MAX_2_1 = 2,
282 ANISO_FILTER_MAX_4_1 = 3,
283 ANISO_FILTER_MAX_8_1 = 4,
284 ANISO_FILTER_MAX_16_1 = 5,
285 ANISO_FILTER_USE_FETCH_CONST = 7,
286 } instr_aniso_filter_t;
287
288 typedef enum {
289 ARBITRARY_FILTER_2X4_SYM = 0,
290 ARBITRARY_FILTER_2X4_ASYM = 1,
291 ARBITRARY_FILTER_4X2_SYM = 2,
292 ARBITRARY_FILTER_4X2_ASYM = 3,
293 ARBITRARY_FILTER_4X4_SYM = 4,
294 ARBITRARY_FILTER_4X4_ASYM = 5,
295 ARBITRARY_FILTER_USE_FETCH_CONST = 7,
296 } instr_arbitrary_filter_t;
297
298 typedef enum {
299 SAMPLE_CENTROID = 0,
300 SAMPLE_CENTER = 1,
301 } instr_sample_loc_t;
302
303 typedef unsigned instr_surf_fmt_t;
304
305 typedef struct PACKED {
306 /* dword0: */
307 instr_fetch_opc_t opc : 5;
308 uint8_t src_reg : 6;
309 uint8_t src_reg_am : 1;
310 uint8_t dst_reg : 6;
311 uint8_t dst_reg_am : 1;
312 uint8_t fetch_valid_only : 1;
313 uint8_t const_idx : 5;
314 uint8_t tx_coord_denorm : 1;
315 uint8_t src_swiz : 6;
316 /* dword1: */
317 uint16_t dst_swiz : 12;
318 instr_tex_filter_t mag_filter : 2;
319 instr_tex_filter_t min_filter : 2;
320 instr_tex_filter_t mip_filter : 2;
321 instr_aniso_filter_t aniso_filter : 3;
322 instr_arbitrary_filter_t arbitrary_filter : 3;
323 instr_tex_filter_t vol_mag_filter : 2;
324 instr_tex_filter_t vol_min_filter : 2;
325 uint8_t use_comp_lod : 1;
326 uint8_t use_reg_lod : 2;
327 uint8_t pred_select : 1;
328 /* dword2: */
329 uint8_t use_reg_gradients : 1;
330 instr_sample_loc_t sample_location : 1;
331 uint8_t lod_bias : 7;
332 uint8_t unused : 7;
333 uint8_t offset_x : 5;
334 uint8_t offset_y : 5;
335 uint8_t offset_z : 5;
336 uint8_t pred_condition : 1;
337 } instr_fetch_tex_t;
338
339 typedef struct PACKED {
340 /* dword0: */
341 instr_fetch_opc_t opc : 5;
342 uint8_t src_reg : 6;
343 uint8_t src_reg_am : 1;
344 uint8_t dst_reg : 6;
345 uint8_t dst_reg_am : 1;
346 uint8_t must_be_one : 1;
347 uint8_t const_index : 5;
348 uint8_t const_index_sel : 2;
349 uint8_t reserved0 : 3;
350 uint8_t src_swiz : 2;
351 /* dword1: */
352 uint16_t dst_swiz : 12;
353 uint8_t format_comp_all : 1; /* '1' for signed, '0' for unsigned? */
354 uint8_t num_format_all : 1; /* '0' for normalized, '1' for unnormalized */
355 uint8_t signed_rf_mode_all : 1;
356 uint8_t reserved1 : 1;
357 instr_surf_fmt_t format : 6;
358 uint8_t reserved2 : 1;
359 uint8_t exp_adjust_all : 7;
360 uint8_t reserved3 : 1;
361 uint8_t pred_select : 1;
362 /* dword2: */
363 uint8_t stride : 8;
364 /* possibly offset and reserved4 are swapped on a200? */
365 uint8_t offset : 8;
366 uint8_t reserved4 : 8;
367 uint8_t reserved5 : 7;
368 uint8_t pred_condition : 1;
369 } instr_fetch_vtx_t;
370
371 typedef union PACKED {
372 instr_fetch_tex_t tex;
373 instr_fetch_vtx_t vtx;
374 struct PACKED {
375 /* dword0: */
376 instr_fetch_opc_t opc : 5;
377 uint32_t dummy0 : 27;
378 /* dword1: */
379 uint32_t dummy1 : 32;
380 /* dword2: */
381 uint32_t dummy2 : 32;
382 };
383 } instr_fetch_t;
384
385 #endif /* INSTR_H_ */