2 * Copyright (c) 2013 Rob Clark <robdclark@gmail.com>
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:
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
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
27 #define PACKED __attribute__((__packed__))
48 /* no opc.. all category 1 are variants of mov */
107 OPC_MADSH_M16 = 3, /* should this be .s16? */
162 OPC_LDG = 0, /* load-global */
165 OPC_STG = 3, /* store-global */
176 OPC_ATOMIC_ADD_L = 16,
177 OPC_ATOMIC_SUB_L = 17,
178 OPC_ATOMIC_XCHG_L = 18,
179 OPC_ATOMIC_INC_L = 19,
180 OPC_ATOMIC_DEC_L = 20,
181 OPC_ATOMIC_CMPXCHG_L = 21,
182 OPC_ATOMIC_MIN_L = 22,
183 OPC_ATOMIC_MAX_L = 23,
184 OPC_ATOMIC_AND_L = 24,
185 OPC_ATOMIC_OR_L = 25,
186 OPC_ATOMIC_XOR_L = 26,
187 OPC_LDGB_TYPED_4D = 27,
203 TYPE_S8 = 7, // XXX I assume?
206 static inline uint32_t type_size(type_t type)
221 assert(0); /* invalid type */
226 static inline int type_float(type_t type)
228 return (type == TYPE_F32) || (type == TYPE_F16);
231 typedef union PACKED {
232 /* normal gpr or const src register: */
237 /* for immediate val: */
238 int32_t iim_val : 11;
239 /* to make compiler happy: */
241 uint32_t dummy11 : 11;
245 /* special registers: */
246 #define REG_A0 61 /* address register */
247 #define REG_P0 62 /* predicate register */
249 static inline int reg_special(reg_t reg)
251 return (reg.num == REG_A0) || (reg.num == REG_P0);
254 typedef struct PACKED {
257 uint32_t dummy1 : 16;
268 uint32_t jmp_tgt : 1;
270 uint32_t opc_cat : 3;
273 typedef struct PACKED {
276 /* for normal src register: */
281 /* for address relative: */
284 uint32_t must_be_3 : 2;
285 uint32_t unknown : 20;
297 uint32_t src_rel : 1;
298 uint32_t dst_type : 3;
299 uint32_t dst_rel : 1;
300 uint32_t src_type : 3;
304 uint32_t pos_inf : 1;
305 uint32_t must_be_0 : 2;
306 uint32_t jmp_tgt : 1;
308 uint32_t opc_cat : 3;
311 typedef struct PACKED {
314 uint32_t src1_rel : 1; /* relative address */
315 uint32_t src1_c : 1; /* const */
316 uint32_t src1_im : 1; /* immediate */
317 uint32_t src1_neg : 1; /* negate */
318 uint32_t src1_abs : 1; /* absolute value */
321 uint32_t src2_rel : 1; /* relative address */
322 uint32_t src2_c : 1; /* const */
323 uint32_t src2_im : 1; /* immediate */
324 uint32_t src2_neg : 1; /* negate */
325 uint32_t src2_abs : 1; /* absolute value */
332 uint32_t ul : 1; /* dunno */
333 uint32_t dst_half : 1; /* or widen/narrow.. ie. dst hrN <-> rN */
337 uint32_t full : 1; /* not half */
339 uint32_t jmp_tgt : 1;
341 uint32_t opc_cat : 3;
344 typedef struct PACKED {
347 uint32_t src1_rel : 1;
350 uint32_t src1_neg : 1;
353 uint32_t src3_rel : 1;
356 uint32_t src2_neg : 1;
357 uint32_t src3_neg : 1;
365 uint32_t dst_half : 1; /* or widen/narrow.. ie. dst hrN <-> rN */
368 uint32_t jmp_tgt : 1;
370 uint32_t opc_cat : 3;
373 typedef struct PACKED {
376 uint32_t src_rel : 1;
379 uint32_t src_neg : 1;
380 uint32_t src_abs : 1;
381 uint32_t dummy1 : 16; /* seem to be ignored */
389 uint32_t dst_half : 1; /* or widen/narrow.. ie. dst hrN <-> rN */
390 uint32_t dummy2 : 5; /* seem to be ignored */
391 uint32_t full : 1; /* not half */
393 uint32_t jmp_tgt : 1;
395 uint32_t opc_cat : 3;
398 typedef struct PACKED {
403 uint32_t full : 1; /* not half */
406 uint32_t dummy1 : 4; /* seem to be ignored */
412 uint32_t full : 1; /* not half */
419 /* same in either case: */
420 // XXX I think, confirm this
422 uint32_t full : 1; /* not half */
430 uint32_t wrmask : 4; /* write-mask */
432 uint32_t dummy2 : 1; /* seems to be ignored */
437 uint32_t is_s2en : 1;
442 uint32_t jmp_tgt : 1;
444 uint32_t opc_cat : 3;
447 /* used for load instructions: */
448 typedef struct PACKED {
450 uint32_t must_be_one1 : 1;
454 uint32_t must_be_one2 : 1;
463 uint32_t jmp_tgt : 1;
465 uint32_t opc_cat : 3;
468 /* used for store instructions: */
469 typedef struct PACKED {
471 uint32_t must_be_zero1 : 1;
473 uint32_t off_hi : 5; /* high bits of 'off'... ugly! */
475 uint32_t must_be_one1 : 1;
480 uint32_t must_be_one2 : 1;
485 uint32_t jmp_tgt : 1;
487 uint32_t opc_cat : 3;
490 typedef union PACKED {
503 uint32_t jmp_tgt : 1;
505 uint32_t opc_cat : 3;
509 typedef union PACKED {
520 uint32_t repeat : 3; /* cat0-cat4 */
522 uint32_t ss : 1; /* cat1-cat4 (cat0??) */
523 uint32_t ul : 1; /* cat2-cat4 (and cat1 in blob.. which may be bug??) */
525 uint32_t jmp_tgt : 1;
527 uint32_t opc_cat : 3;
532 #endif /* INSTR_A3XX_H_ */