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