2 * Copyright © 2008 Keith Packard
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
30 #include "brw_context.h"
31 #include "brw_defines.h"
35 const struct opcode_desc opcode_descs
[128] = {
36 [BRW_OPCODE_MOV
] = { .name
= "mov", .nsrc
= 1, .ndst
= 1 },
37 [BRW_OPCODE_FRC
] = { .name
= "frc", .nsrc
= 1, .ndst
= 1 },
38 [BRW_OPCODE_RNDU
] = { .name
= "rndu", .nsrc
= 1, .ndst
= 1 },
39 [BRW_OPCODE_RNDD
] = { .name
= "rndd", .nsrc
= 1, .ndst
= 1 },
40 [BRW_OPCODE_RNDE
] = { .name
= "rnde", .nsrc
= 1, .ndst
= 1 },
41 [BRW_OPCODE_RNDZ
] = { .name
= "rndz", .nsrc
= 1, .ndst
= 1 },
42 [BRW_OPCODE_NOT
] = { .name
= "not", .nsrc
= 1, .ndst
= 1 },
43 [BRW_OPCODE_LZD
] = { .name
= "lzd", .nsrc
= 1, .ndst
= 1 },
44 [BRW_OPCODE_F32TO16
] = { .name
= "f32to16", .nsrc
= 1, .ndst
= 1 },
45 [BRW_OPCODE_F16TO32
] = { .name
= "f16to32", .nsrc
= 1, .ndst
= 1 },
46 [BRW_OPCODE_BFREV
] = { .name
= "bfrev", .nsrc
= 1, .ndst
= 1 },
47 [BRW_OPCODE_FBH
] = { .name
= "fbh", .nsrc
= 1, .ndst
= 1 },
48 [BRW_OPCODE_FBL
] = { .name
= "fbl", .nsrc
= 1, .ndst
= 1 },
49 [BRW_OPCODE_CBIT
] = { .name
= "cbit", .nsrc
= 1, .ndst
= 1 },
51 [BRW_OPCODE_MUL
] = { .name
= "mul", .nsrc
= 2, .ndst
= 1 },
52 [BRW_OPCODE_MAC
] = { .name
= "mac", .nsrc
= 2, .ndst
= 1 },
53 [BRW_OPCODE_MACH
] = { .name
= "mach", .nsrc
= 2, .ndst
= 1 },
54 [BRW_OPCODE_LINE
] = { .name
= "line", .nsrc
= 2, .ndst
= 1 },
55 [BRW_OPCODE_PLN
] = { .name
= "pln", .nsrc
= 2, .ndst
= 1 },
56 [BRW_OPCODE_MAD
] = { .name
= "mad", .nsrc
= 3, .ndst
= 1 },
57 [BRW_OPCODE_LRP
] = { .name
= "lrp", .nsrc
= 3, .ndst
= 1 },
58 [BRW_OPCODE_SAD2
] = { .name
= "sad2", .nsrc
= 2, .ndst
= 1 },
59 [BRW_OPCODE_SADA2
] = { .name
= "sada2", .nsrc
= 2, .ndst
= 1 },
60 [BRW_OPCODE_DP4
] = { .name
= "dp4", .nsrc
= 2, .ndst
= 1 },
61 [BRW_OPCODE_DPH
] = { .name
= "dph", .nsrc
= 2, .ndst
= 1 },
62 [BRW_OPCODE_DP3
] = { .name
= "dp3", .nsrc
= 2, .ndst
= 1 },
63 [BRW_OPCODE_DP2
] = { .name
= "dp2", .nsrc
= 2, .ndst
= 1 },
64 [BRW_OPCODE_MATH
] = { .name
= "math", .nsrc
= 2, .ndst
= 1 },
66 [BRW_OPCODE_AVG
] = { .name
= "avg", .nsrc
= 2, .ndst
= 1 },
67 [BRW_OPCODE_ADD
] = { .name
= "add", .nsrc
= 2, .ndst
= 1 },
68 [BRW_OPCODE_SEL
] = { .name
= "sel", .nsrc
= 2, .ndst
= 1 },
69 [BRW_OPCODE_AND
] = { .name
= "and", .nsrc
= 2, .ndst
= 1 },
70 [BRW_OPCODE_OR
] = { .name
= "or", .nsrc
= 2, .ndst
= 1 },
71 [BRW_OPCODE_XOR
] = { .name
= "xor", .nsrc
= 2, .ndst
= 1 },
72 [BRW_OPCODE_SHR
] = { .name
= "shr", .nsrc
= 2, .ndst
= 1 },
73 [BRW_OPCODE_SHL
] = { .name
= "shl", .nsrc
= 2, .ndst
= 1 },
74 [BRW_OPCODE_ASR
] = { .name
= "asr", .nsrc
= 2, .ndst
= 1 },
75 [BRW_OPCODE_CMP
] = { .name
= "cmp", .nsrc
= 2, .ndst
= 1 },
76 [BRW_OPCODE_CMPN
] = { .name
= "cmpn", .nsrc
= 2, .ndst
= 1 },
77 [BRW_OPCODE_BFE
] = { .name
= "bfe", .nsrc
= 3, .ndst
= 1 },
78 [BRW_OPCODE_BFI1
] = { .name
= "bfi1", .nsrc
= 2, .ndst
= 1 },
79 [BRW_OPCODE_BFI2
] = { .name
= "bfi2", .nsrc
= 3, .ndst
= 1 },
80 [BRW_OPCODE_ADDC
] = { .name
= "addc", .nsrc
= 2, .ndst
= 1 },
81 [BRW_OPCODE_SUBB
] = { .name
= "subb", .nsrc
= 2, .ndst
= 1 },
83 [BRW_OPCODE_SEND
] = { .name
= "send", .nsrc
= 1, .ndst
= 1 },
84 [BRW_OPCODE_SENDC
] = { .name
= "sendc", .nsrc
= 1, .ndst
= 1 },
85 [BRW_OPCODE_NOP
] = { .name
= "nop", .nsrc
= 0, .ndst
= 0 },
86 [BRW_OPCODE_JMPI
] = { .name
= "jmpi", .nsrc
= 0, .ndst
= 0 },
87 [BRW_OPCODE_IF
] = { .name
= "if", .nsrc
= 2, .ndst
= 0 },
88 [BRW_OPCODE_IFF
] = { .name
= "iff", .nsrc
= 2, .ndst
= 1 },
89 [BRW_OPCODE_WHILE
] = { .name
= "while", .nsrc
= 2, .ndst
= 0 },
90 [BRW_OPCODE_ELSE
] = { .name
= "else", .nsrc
= 2, .ndst
= 0 },
91 [BRW_OPCODE_BREAK
] = { .name
= "break", .nsrc
= 2, .ndst
= 0 },
92 [BRW_OPCODE_CONTINUE
] = { .name
= "cont", .nsrc
= 1, .ndst
= 0 },
93 [BRW_OPCODE_HALT
] = { .name
= "halt", .nsrc
= 1, .ndst
= 0 },
94 [BRW_OPCODE_MSAVE
] = { .name
= "msave", .nsrc
= 1, .ndst
= 1 },
95 [BRW_OPCODE_PUSH
] = { .name
= "push", .nsrc
= 1, .ndst
= 1 },
96 [BRW_OPCODE_MRESTORE
] = { .name
= "mrest", .nsrc
= 1, .ndst
= 1 },
97 [BRW_OPCODE_POP
] = { .name
= "pop", .nsrc
= 2, .ndst
= 0 },
98 [BRW_OPCODE_WAIT
] = { .name
= "wait", .nsrc
= 1, .ndst
= 0 },
99 [BRW_OPCODE_DO
] = { .name
= "do", .nsrc
= 0, .ndst
= 0 },
100 [BRW_OPCODE_ENDIF
] = { .name
= "endif", .nsrc
= 2, .ndst
= 0 },
104 has_jip(struct brw_context
*brw
, enum opcode opcode
)
109 return opcode
== BRW_OPCODE_IF
||
110 opcode
== BRW_OPCODE_ELSE
||
111 opcode
== BRW_OPCODE_ENDIF
||
112 opcode
== BRW_OPCODE_WHILE
;
116 has_uip(struct brw_context
*brw
, enum opcode opcode
)
121 return (brw
->gen
>= 7 && opcode
== BRW_OPCODE_IF
) ||
122 (brw
->gen
>= 8 && opcode
== BRW_OPCODE_ELSE
) ||
123 opcode
== BRW_OPCODE_BREAK
||
124 opcode
== BRW_OPCODE_CONTINUE
||
125 opcode
== BRW_OPCODE_HALT
;
129 is_logic_instruction(unsigned opcode
)
131 return opcode
== BRW_OPCODE_AND
||
132 opcode
== BRW_OPCODE_NOT
||
133 opcode
== BRW_OPCODE_OR
||
134 opcode
== BRW_OPCODE_XOR
;
137 const char *const conditional_modifier
[16] = {
138 [BRW_CONDITIONAL_NONE
] = "",
139 [BRW_CONDITIONAL_Z
] = ".e",
140 [BRW_CONDITIONAL_NZ
] = ".ne",
141 [BRW_CONDITIONAL_G
] = ".g",
142 [BRW_CONDITIONAL_GE
] = ".ge",
143 [BRW_CONDITIONAL_L
] = ".l",
144 [BRW_CONDITIONAL_LE
] = ".le",
145 [BRW_CONDITIONAL_R
] = ".r",
146 [BRW_CONDITIONAL_O
] = ".o",
147 [BRW_CONDITIONAL_U
] = ".u",
150 static const char *const m_negate
[2] = {
155 static const char *const _abs
[2] = {
160 static const char *const m_bitnot
[2] = { "", "~" };
162 static const char *const vert_stride
[16] = {
173 static const char *const width
[8] = {
181 static const char *const horiz_stride
[4] = {
188 static const char *const chan_sel
[4] = {
195 static const char *const debug_ctrl
[2] = {
200 static const char *const saturate
[2] = {
205 static const char *const cmpt_ctrl
[2] = {
210 static const char *const accwr
[2] = {
215 static const char *const wectrl
[2] = {
220 static const char *const exec_size
[8] = {
229 static const char *const pred_inv
[2] = {
234 static const char *const pred_ctrl_align16
[16] = {
244 static const char *const pred_ctrl_align1
[16] = {
245 [BRW_PREDICATE_NORMAL
] = "",
246 [BRW_PREDICATE_ALIGN1_ANYV
] = ".anyv",
247 [BRW_PREDICATE_ALIGN1_ALLV
] = ".allv",
248 [BRW_PREDICATE_ALIGN1_ANY2H
] = ".any2h",
249 [BRW_PREDICATE_ALIGN1_ALL2H
] = ".all2h",
250 [BRW_PREDICATE_ALIGN1_ANY4H
] = ".any4h",
251 [BRW_PREDICATE_ALIGN1_ALL4H
] = ".all4h",
252 [BRW_PREDICATE_ALIGN1_ANY8H
] = ".any8h",
253 [BRW_PREDICATE_ALIGN1_ALL8H
] = ".all8h",
254 [BRW_PREDICATE_ALIGN1_ANY16H
] = ".any16h",
255 [BRW_PREDICATE_ALIGN1_ANY16H
] = ".all16h",
256 [BRW_PREDICATE_ALIGN1_ANY32H
] = ".any32h",
257 [BRW_PREDICATE_ALIGN1_ANY32H
] = ".all32h",
260 static const char *const thread_ctrl
[4] = {
261 [BRW_THREAD_NORMAL
] = "",
262 [BRW_THREAD_ATOMIC
] = "atomic",
263 [BRW_THREAD_SWITCH
] = "switch",
266 static const char *const compr_ctrl
[4] = {
273 static const char *const dep_ctrl
[4] = {
277 [3] = "NoDDClr,NoDDChk",
280 static const char *const mask_ctrl
[4] = {
285 static const char *const access_mode
[2] = {
290 static const char * const reg_encoding
[] = {
291 [BRW_HW_REG_TYPE_UD
] = "UD",
292 [BRW_HW_REG_TYPE_D
] = "D",
293 [BRW_HW_REG_TYPE_UW
] = "UW",
294 [BRW_HW_REG_TYPE_W
] = "W",
295 [BRW_HW_REG_NON_IMM_TYPE_UB
] = "UB",
296 [BRW_HW_REG_NON_IMM_TYPE_B
] = "B",
297 [GEN7_HW_REG_NON_IMM_TYPE_DF
] = "DF",
298 [BRW_HW_REG_TYPE_F
] = "F",
299 [GEN8_HW_REG_TYPE_UQ
] = "UQ",
300 [GEN8_HW_REG_TYPE_Q
] = "Q",
301 [GEN8_HW_REG_NON_IMM_TYPE_HF
] = "HF",
304 static const char *const three_source_reg_encoding
[] = {
305 [BRW_3SRC_TYPE_F
] = "F",
306 [BRW_3SRC_TYPE_D
] = "D",
307 [BRW_3SRC_TYPE_UD
] = "UD",
310 const int reg_type_size
[] = {
311 [BRW_HW_REG_TYPE_UD
] = 4,
312 [BRW_HW_REG_TYPE_D
] = 4,
313 [BRW_HW_REG_TYPE_UW
] = 2,
314 [BRW_HW_REG_TYPE_W
] = 2,
315 [BRW_HW_REG_NON_IMM_TYPE_UB
] = 1,
316 [BRW_HW_REG_NON_IMM_TYPE_B
] = 1,
317 [GEN7_HW_REG_NON_IMM_TYPE_DF
] = 8,
318 [BRW_HW_REG_TYPE_F
] = 4,
319 [GEN8_HW_REG_TYPE_UQ
] = 8,
320 [GEN8_HW_REG_TYPE_Q
] = 8,
321 [GEN8_HW_REG_NON_IMM_TYPE_HF
] = 2,
324 static const char *const reg_file
[4] = {
331 static const char *const writemask
[16] = {
350 static const char *const end_of_thread
[2] = {
355 /* SFIDs on Gen4-5 */
356 static const char *const gen4_sfid
[16] = {
357 [BRW_SFID_NULL
] = "null",
358 [BRW_SFID_MATH
] = "math",
359 [BRW_SFID_SAMPLER
] = "sampler",
360 [BRW_SFID_MESSAGE_GATEWAY
] = "gateway",
361 [BRW_SFID_DATAPORT_READ
] = "read",
362 [BRW_SFID_DATAPORT_WRITE
] = "write",
363 [BRW_SFID_URB
] = "urb",
364 [BRW_SFID_THREAD_SPAWNER
] = "thread_spawner",
365 [BRW_SFID_VME
] = "vme",
368 static const char *const gen6_sfid
[16] = {
369 [BRW_SFID_NULL
] = "null",
370 [BRW_SFID_MATH
] = "math",
371 [BRW_SFID_SAMPLER
] = "sampler",
372 [BRW_SFID_MESSAGE_GATEWAY
] = "gateway",
373 [BRW_SFID_URB
] = "urb",
374 [BRW_SFID_THREAD_SPAWNER
] = "thread_spawner",
375 [GEN6_SFID_DATAPORT_SAMPLER_CACHE
] = "sampler",
376 [GEN6_SFID_DATAPORT_RENDER_CACHE
] = "render",
377 [GEN6_SFID_DATAPORT_CONSTANT_CACHE
] = "const",
378 [GEN7_SFID_DATAPORT_DATA_CACHE
] = "data",
379 [GEN7_SFID_PIXEL_INTERPOLATOR
] = "pixel interp",
380 [HSW_SFID_DATAPORT_DATA_CACHE_1
] = "dp data 1",
381 [HSW_SFID_CRE
] = "cre",
384 static const char *const dp_write_port_msg_type
[8] = {
385 [0b000] = "OWord block write",
386 [0b001] = "OWord dual block write",
387 [0b010] = "media block write",
388 [0b011] = "DWord scattered write",
389 [0b100] = "RT write",
390 [0b101] = "streamed VB write",
391 [0b110] = "RT UNORM write", /* G45+ */
392 [0b111] = "flush render cache",
395 static const char *const dp_rc_msg_type_gen6
[16] = {
396 [BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ
] = "OWORD block read",
397 [GEN6_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ
] = "RT UNORM read",
398 [GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ
] = "OWORD dual block read",
399 [GEN6_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ
] = "media block read",
400 [GEN6_DATAPORT_READ_MESSAGE_OWORD_UNALIGN_BLOCK_READ
] =
401 "OWORD unaligned block read",
402 [GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ
] = "DWORD scattered read",
403 [GEN6_DATAPORT_WRITE_MESSAGE_DWORD_ATOMIC_WRITE
] = "DWORD atomic write",
404 [GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE
] = "OWORD block write",
405 [GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE
] =
406 "OWORD dual block write",
407 [GEN6_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE
] = "media block write",
408 [GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE
] =
409 "DWORD scattered write",
410 [GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE
] = "RT write",
411 [GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE
] = "streamed VB write",
412 [GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE
] = "RT UNORM write",
415 static const char *const m_rt_write_subtype
[] = {
417 [0b001] = "SIMD16/RepData",
418 [0b010] = "SIMD8/DualSrcLow",
419 [0b011] = "SIMD8/DualSrcHigh",
421 [0b101] = "SIMD8/ImageWrite", /* Gen6+ */
422 [0b111] = "SIMD16/RepData-111", /* no idea how this is different than 1 */
425 static const char *const dp_dc0_msg_type_gen7
[16] = {
426 [GEN7_DATAPORT_DC_OWORD_BLOCK_READ
] = "DC OWORD block read",
427 [GEN7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ
] =
428 "DC unaligned OWORD block read",
429 [GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_READ
] = "DC OWORD dual block read",
430 [GEN7_DATAPORT_DC_DWORD_SCATTERED_READ
] = "DC DWORD scattered read",
431 [GEN7_DATAPORT_DC_BYTE_SCATTERED_READ
] = "DC byte scattered read",
432 [GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP
] = "DC untyped atomic",
433 [GEN7_DATAPORT_DC_MEMORY_FENCE
] = "DC mfence",
434 [GEN7_DATAPORT_DC_OWORD_BLOCK_WRITE
] = "DC OWORD block write",
435 [GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_WRITE
] = "DC OWORD dual block write",
436 [GEN7_DATAPORT_DC_DWORD_SCATTERED_WRITE
] = "DC DWORD scatterd write",
437 [GEN7_DATAPORT_DC_BYTE_SCATTERED_WRITE
] = "DC byte scattered write",
438 [GEN7_DATAPORT_DC_UNTYPED_SURFACE_WRITE
] = "DC untyped surface write",
441 static const char *const dp_dc1_msg_type_hsw
[16] = {
442 [HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ
] = "untyped surface read",
443 [HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP
] = "DC untyped atomic op",
444 [HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2
] =
445 "DC untyped 4x2 atomic op",
446 [HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_READ
] = "DC media block read",
447 [HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ
] = "DC typed surface read",
448 [HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP
] = "DC typed atomic",
449 [HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2
] = "DC typed 4x2 atomic op",
450 [HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE
] = "DC untyped surface write",
451 [HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_WRITE
] = "DC media block write",
452 [HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP
] = "DC atomic counter op",
453 [HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP_SIMD4X2
] =
454 "DC 4x2 atomic counter op",
455 [HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE
] = "DC typed surface write",
458 static const char *const aop
[16] = {
459 [BRW_AOP_AND
] = "and",
461 [BRW_AOP_XOR
] = "xor",
462 [BRW_AOP_MOV
] = "mov",
463 [BRW_AOP_INC
] = "inc",
464 [BRW_AOP_DEC
] = "dec",
465 [BRW_AOP_ADD
] = "add",
466 [BRW_AOP_SUB
] = "sub",
467 [BRW_AOP_REVSUB
] = "revsub",
468 [BRW_AOP_IMAX
] = "imax",
469 [BRW_AOP_IMIN
] = "imin",
470 [BRW_AOP_UMAX
] = "umax",
471 [BRW_AOP_UMIN
] = "umin",
472 [BRW_AOP_CMPWR
] = "cmpwr",
473 [BRW_AOP_PREDEC
] = "predec",
476 static const char *const math_function
[16] = {
477 [BRW_MATH_FUNCTION_INV
] = "inv",
478 [BRW_MATH_FUNCTION_LOG
] = "log",
479 [BRW_MATH_FUNCTION_EXP
] = "exp",
480 [BRW_MATH_FUNCTION_SQRT
] = "sqrt",
481 [BRW_MATH_FUNCTION_RSQ
] = "rsq",
482 [BRW_MATH_FUNCTION_SIN
] = "sin",
483 [BRW_MATH_FUNCTION_COS
] = "cos",
484 [BRW_MATH_FUNCTION_SINCOS
] = "sincos",
485 [BRW_MATH_FUNCTION_FDIV
] = "fdiv",
486 [BRW_MATH_FUNCTION_POW
] = "pow",
487 [BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER
] = "intdivmod",
488 [BRW_MATH_FUNCTION_INT_DIV_QUOTIENT
] = "intdiv",
489 [BRW_MATH_FUNCTION_INT_DIV_REMAINDER
] = "intmod",
490 [GEN8_MATH_FUNCTION_INVM
] = "invm",
491 [GEN8_MATH_FUNCTION_RSQRTM
] = "rsqrtm",
494 static const char *const math_saturate
[2] = {
499 static const char *const math_signed
[2] = {
504 static const char *const math_scalar
[2] = {
509 static const char *const math_precision
[2] = {
511 [1] = "partial_precision"
514 static const char *const gen5_urb_opcode
[] = {
519 static const char *const gen7_urb_opcode
[] = {
524 [4] = "atomic mov", /* Gen7+ */
525 [5] = "atomic inc", /* Gen7+ */
526 [6] = "atomic add", /* Gen8+ */
527 [7] = "SIMD8 write", /* Gen8+ */
528 [8] = "SIMD8 read", /* Gen8+ */
529 /* [9-15] - reserved */
532 static const char *const urb_swizzle
[4] = {
533 [BRW_URB_SWIZZLE_NONE
] = "",
534 [BRW_URB_SWIZZLE_INTERLEAVE
] = "interleave",
535 [BRW_URB_SWIZZLE_TRANSPOSE
] = "transpose",
538 static const char *const urb_allocate
[2] = {
543 static const char *const urb_used
[2] = {
548 static const char *const urb_complete
[2] = {
553 static const char *const sampler_target_format
[4] = {
563 string(FILE *file
, const char *string
)
566 column
+= strlen(string
);
571 format(FILE *f
, const char *format
, ...)
575 va_start(args
, format
);
577 vsnprintf(buf
, sizeof(buf
) - 1, format
, args
);
601 control(FILE *file
, const char *name
, const char *const ctrl
[],
602 unsigned id
, int *space
)
605 fprintf(file
, "*** invalid %s value %d ", name
, id
);
611 string(file
, ctrl
[id
]);
619 print_opcode(FILE *file
, int id
)
621 if (!opcode_descs
[id
].name
) {
622 format(file
, "*** invalid opcode value %d ", id
);
625 string(file
, opcode_descs
[id
].name
);
630 reg(FILE *file
, unsigned _reg_file
, unsigned _reg_nr
)
634 /* Clear the Compr4 instruction compression bit. */
635 if (_reg_file
== BRW_MESSAGE_REGISTER_FILE
)
636 _reg_nr
&= ~(1 << 7);
638 if (_reg_file
== BRW_ARCHITECTURE_REGISTER_FILE
) {
639 switch (_reg_nr
& 0xf0) {
641 string(file
, "null");
643 case BRW_ARF_ADDRESS
:
644 format(file
, "a%d", _reg_nr
& 0x0f);
646 case BRW_ARF_ACCUMULATOR
:
647 format(file
, "acc%d", _reg_nr
& 0x0f);
650 format(file
, "f%d", _reg_nr
& 0x0f);
653 format(file
, "mask%d", _reg_nr
& 0x0f);
655 case BRW_ARF_MASK_STACK
:
656 format(file
, "msd%d", _reg_nr
& 0x0f);
659 format(file
, "sr%d", _reg_nr
& 0x0f);
661 case BRW_ARF_CONTROL
:
662 format(file
, "cr%d", _reg_nr
& 0x0f);
664 case BRW_ARF_NOTIFICATION_COUNT
:
665 format(file
, "n%d", _reg_nr
& 0x0f);
672 format(file
, "ARF%d", _reg_nr
);
676 err
|= control(file
, "src reg file", reg_file
, _reg_file
, NULL
);
677 format(file
, "%d", _reg_nr
);
683 dest(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
687 if (brw_inst_access_mode(brw
, inst
) == BRW_ALIGN_1
) {
688 if (brw_inst_dst_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
689 err
|= reg(file
, brw_inst_dst_reg_file(brw
, inst
),
690 brw_inst_dst_da_reg_nr(brw
, inst
));
693 if (brw_inst_dst_da1_subreg_nr(brw
, inst
))
694 format(file
, ".%d", brw_inst_dst_da1_subreg_nr(brw
, inst
) /
695 reg_type_size
[brw_inst_dst_reg_type(brw
, inst
)]);
697 err
|= control(file
, "horiz stride", horiz_stride
,
698 brw_inst_dst_hstride(brw
, inst
), NULL
);
700 err
|= control(file
, "dest reg encoding", reg_encoding
,
701 brw_inst_dst_reg_type(brw
, inst
), NULL
);
703 string(file
, "g[a0");
704 if (brw_inst_dst_ia_subreg_nr(brw
, inst
))
705 format(file
, ".%d", brw_inst_dst_ia_subreg_nr(brw
, inst
) /
706 reg_type_size
[brw_inst_dst_reg_type(brw
, inst
)]);
707 if (brw_inst_dst_ia1_addr_imm(brw
, inst
))
708 format(file
, " %d", brw_inst_dst_ia1_addr_imm(brw
, inst
));
710 err
|= control(file
, "horiz stride", horiz_stride
,
711 brw_inst_dst_hstride(brw
, inst
), NULL
);
713 err
|= control(file
, "dest reg encoding", reg_encoding
,
714 brw_inst_dst_reg_type(brw
, inst
), NULL
);
717 if (brw_inst_dst_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
718 err
|= reg(file
, brw_inst_dst_reg_file(brw
, inst
),
719 brw_inst_dst_da_reg_nr(brw
, inst
));
722 if (brw_inst_dst_da16_subreg_nr(brw
, inst
))
723 format(file
, ".%d", brw_inst_dst_da16_subreg_nr(brw
, inst
) /
724 reg_type_size
[brw_inst_dst_reg_type(brw
, inst
)]);
726 err
|= control(file
, "writemask", writemask
,
727 brw_inst_da16_writemask(brw
, inst
), NULL
);
728 err
|= control(file
, "dest reg encoding", reg_encoding
,
729 brw_inst_dst_reg_type(brw
, inst
), NULL
);
732 string(file
, "Indirect align16 address mode not supported");
740 dest_3src(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
745 if (brw
->gen
== 6 && brw_inst_3src_dst_reg_file(brw
, inst
))
746 reg_file
= BRW_MESSAGE_REGISTER_FILE
;
748 reg_file
= BRW_GENERAL_REGISTER_FILE
;
750 err
|= reg(file
, reg_file
, brw_inst_3src_dst_reg_nr(brw
, inst
));
753 if (brw_inst_3src_dst_subreg_nr(brw
, inst
))
754 format(file
, ".%d", brw_inst_3src_dst_subreg_nr(brw
, inst
));
756 err
|= control(file
, "writemask", writemask
,
757 brw_inst_3src_dst_writemask(brw
, inst
), NULL
);
758 err
|= control(file
, "dest reg encoding", three_source_reg_encoding
,
759 brw_inst_3src_dst_type(brw
, inst
), NULL
);
765 src_align1_region(FILE *file
,
766 unsigned _vert_stride
, unsigned _width
,
767 unsigned _horiz_stride
)
771 err
|= control(file
, "vert stride", vert_stride
, _vert_stride
, NULL
);
773 err
|= control(file
, "width", width
, _width
, NULL
);
775 err
|= control(file
, "horiz_stride", horiz_stride
, _horiz_stride
, NULL
);
782 const struct brw_context
*brw
,
784 unsigned type
, unsigned _reg_file
,
785 unsigned _vert_stride
, unsigned _width
, unsigned _horiz_stride
,
786 unsigned reg_num
, unsigned sub_reg_num
, unsigned __abs
,
791 if (brw
->gen
>= 8 && is_logic_instruction(opcode
))
792 err
|= control(file
, "bitnot", m_bitnot
, _negate
, NULL
);
794 err
|= control(file
, "negate", m_negate
, _negate
, NULL
);
796 err
|= control(file
, "abs", _abs
, __abs
, NULL
);
798 err
|= reg(file
, _reg_file
, reg_num
);
802 format(file
, ".%d", sub_reg_num
/ reg_type_size
[type
]); /* use formal style like spec */
803 src_align1_region(file
, _vert_stride
, _width
, _horiz_stride
);
804 err
|= control(file
, "src reg encoding", reg_encoding
, type
, NULL
);
810 const struct brw_context
*brw
,
815 unsigned _addr_subreg_nr
,
819 unsigned _horiz_stride
, unsigned _width
, unsigned _vert_stride
)
823 if (brw
->gen
>= 8 && is_logic_instruction(opcode
))
824 err
|= control(file
, "bitnot", m_bitnot
, _negate
, NULL
);
826 err
|= control(file
, "negate", m_negate
, _negate
, NULL
);
828 err
|= control(file
, "abs", _abs
, __abs
, NULL
);
830 string(file
, "g[a0");
832 format(file
, ".%d", _addr_subreg_nr
);
834 format(file
, " %d", _addr_imm
);
836 src_align1_region(file
, _vert_stride
, _width
, _horiz_stride
);
837 err
|= control(file
, "src reg encoding", reg_encoding
, type
, NULL
);
842 src_swizzle(FILE *file
, unsigned swiz
)
844 unsigned x
= BRW_GET_SWZ(swiz
, BRW_CHANNEL_X
);
845 unsigned y
= BRW_GET_SWZ(swiz
, BRW_CHANNEL_Y
);
846 unsigned z
= BRW_GET_SWZ(swiz
, BRW_CHANNEL_Z
);
847 unsigned w
= BRW_GET_SWZ(swiz
, BRW_CHANNEL_W
);
850 if (x
== y
&& x
== z
&& x
== w
) {
852 err
|= control(file
, "channel select", chan_sel
, x
, NULL
);
853 } else if (swiz
!= BRW_SWIZZLE_XYZW
) {
855 err
|= control(file
, "channel select", chan_sel
, x
, NULL
);
856 err
|= control(file
, "channel select", chan_sel
, y
, NULL
);
857 err
|= control(file
, "channel select", chan_sel
, z
, NULL
);
858 err
|= control(file
, "channel select", chan_sel
, w
, NULL
);
865 const struct brw_context
*brw
,
869 unsigned _vert_stride
,
874 unsigned swz_x
, unsigned swz_y
, unsigned swz_z
, unsigned swz_w
)
878 if (brw
->gen
>= 8 && is_logic_instruction(opcode
))
879 err
|= control(file
, "bitnot", m_bitnot
, _negate
, NULL
);
881 err
|= control(file
, "negate", m_negate
, _negate
, NULL
);
883 err
|= control(file
, "abs", _abs
, __abs
, NULL
);
885 err
|= reg(file
, _reg_file
, _reg_nr
);
889 /* bit4 for subreg number byte addressing. Make this same meaning as
890 in da1 case, so output looks consistent. */
891 format(file
, ".%d", 16 / reg_type_size
[_reg_type
]);
893 err
|= control(file
, "vert stride", vert_stride
, _vert_stride
, NULL
);
894 string(file
, ",4,1>");
895 err
|= src_swizzle(file
, BRW_SWIZZLE4(swz_x
, swz_y
, swz_z
, swz_w
));
896 err
|= control(file
, "src da16 reg type", reg_encoding
, _reg_type
, NULL
);
901 src0_3src(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
904 unsigned src0_subreg_nr
= brw_inst_3src_src0_subreg_nr(brw
, inst
);
906 err
|= control(file
, "negate", m_negate
,
907 brw_inst_3src_src0_negate(brw
, inst
), NULL
);
908 err
|= control(file
, "abs", _abs
, brw_inst_3src_src0_abs(brw
, inst
), NULL
);
910 err
|= reg(file
, BRW_GENERAL_REGISTER_FILE
,
911 brw_inst_3src_src0_reg_nr(brw
, inst
));
915 format(file
, ".%d", src0_subreg_nr
);
916 if (brw_inst_3src_src0_rep_ctrl(brw
, inst
))
917 string(file
, "<0,1,0>");
919 string(file
, "<4,4,1>");
920 err
|= control(file
, "src da16 reg type", three_source_reg_encoding
,
921 brw_inst_3src_src_type(brw
, inst
), NULL
);
922 err
|= src_swizzle(file
, brw_inst_3src_src0_swizzle(brw
, inst
));
927 src1_3src(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
930 unsigned src1_subreg_nr
= brw_inst_3src_src1_subreg_nr(brw
, inst
);
932 err
|= control(file
, "negate", m_negate
,
933 brw_inst_3src_src1_negate(brw
, inst
), NULL
);
934 err
|= control(file
, "abs", _abs
, brw_inst_3src_src1_abs(brw
, inst
), NULL
);
936 err
|= reg(file
, BRW_GENERAL_REGISTER_FILE
,
937 brw_inst_3src_src1_reg_nr(brw
, inst
));
941 format(file
, ".%d", src1_subreg_nr
);
942 if (brw_inst_3src_src1_rep_ctrl(brw
, inst
))
943 string(file
, "<0,1,0>");
945 string(file
, "<4,4,1>");
946 err
|= control(file
, "src da16 reg type", three_source_reg_encoding
,
947 brw_inst_3src_src_type(brw
, inst
), NULL
);
948 err
|= src_swizzle(file
, brw_inst_3src_src1_swizzle(brw
, inst
));
954 src2_3src(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
957 unsigned src2_subreg_nr
= brw_inst_3src_src2_subreg_nr(brw
, inst
);
959 err
|= control(file
, "negate", m_negate
,
960 brw_inst_3src_src2_negate(brw
, inst
), NULL
);
961 err
|= control(file
, "abs", _abs
, brw_inst_3src_src2_abs(brw
, inst
), NULL
);
963 err
|= reg(file
, BRW_GENERAL_REGISTER_FILE
,
964 brw_inst_3src_src2_reg_nr(brw
, inst
));
968 format(file
, ".%d", src2_subreg_nr
);
969 if (brw_inst_3src_src2_rep_ctrl(brw
, inst
))
970 string(file
, "<0,1,0>");
972 string(file
, "<4,4,1>");
973 err
|= control(file
, "src da16 reg type", three_source_reg_encoding
,
974 brw_inst_3src_src_type(brw
, inst
), NULL
);
975 err
|= src_swizzle(file
, brw_inst_3src_src2_swizzle(brw
, inst
));
980 imm(FILE *file
, struct brw_context
*brw
, unsigned type
, brw_inst
*inst
)
983 case BRW_HW_REG_TYPE_UD
:
984 format(file
, "0x%08xUD", brw_inst_imm_ud(brw
, inst
));
986 case BRW_HW_REG_TYPE_D
:
987 format(file
, "%dD", brw_inst_imm_d(brw
, inst
));
989 case BRW_HW_REG_TYPE_UW
:
990 format(file
, "0x%04xUW", (uint16_t) brw_inst_imm_ud(brw
, inst
));
992 case BRW_HW_REG_TYPE_W
:
993 format(file
, "%dW", (int16_t) brw_inst_imm_d(brw
, inst
));
995 case BRW_HW_REG_IMM_TYPE_UV
:
996 format(file
, "0x%08xUV", brw_inst_imm_ud(brw
, inst
));
998 case BRW_HW_REG_IMM_TYPE_VF
:
999 format(file
, "Vector Float");
1001 case BRW_HW_REG_IMM_TYPE_V
:
1002 format(file
, "0x%08xV", brw_inst_imm_ud(brw
, inst
));
1004 case BRW_HW_REG_TYPE_F
:
1005 format(file
, "%-gF", brw_inst_imm_f(brw
, inst
));
1007 case GEN8_HW_REG_IMM_TYPE_DF
:
1008 string(file
, "Double IMM");
1010 case GEN8_HW_REG_IMM_TYPE_HF
:
1011 string(file
, "Half Float IMM");
1018 src0(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
1020 if (brw_inst_src0_reg_file(brw
, inst
) == BRW_IMMEDIATE_VALUE
) {
1021 return imm(file
, brw
, brw_inst_src0_reg_type(brw
, inst
), inst
);
1022 } else if (brw_inst_access_mode(brw
, inst
) == BRW_ALIGN_1
) {
1023 if (brw_inst_src0_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
1024 return src_da1(file
,
1026 brw_inst_opcode(brw
, inst
),
1027 brw_inst_src0_reg_type(brw
, inst
),
1028 brw_inst_src0_reg_file(brw
, inst
),
1029 brw_inst_src0_vstride(brw
, inst
),
1030 brw_inst_src0_width(brw
, inst
),
1031 brw_inst_src0_hstride(brw
, inst
),
1032 brw_inst_src0_da_reg_nr(brw
, inst
),
1033 brw_inst_src0_da1_subreg_nr(brw
, inst
),
1034 brw_inst_src0_abs(brw
, inst
),
1035 brw_inst_src0_negate(brw
, inst
));
1037 return src_ia1(file
,
1039 brw_inst_opcode(brw
, inst
),
1040 brw_inst_src0_reg_type(brw
, inst
),
1041 brw_inst_src0_reg_file(brw
, inst
),
1042 brw_inst_src0_ia1_addr_imm(brw
, inst
),
1043 brw_inst_src0_ia_subreg_nr(brw
, inst
),
1044 brw_inst_src0_negate(brw
, inst
),
1045 brw_inst_src0_abs(brw
, inst
),
1046 brw_inst_src0_address_mode(brw
, inst
),
1047 brw_inst_src0_hstride(brw
, inst
),
1048 brw_inst_src0_width(brw
, inst
),
1049 brw_inst_src0_vstride(brw
, inst
));
1052 if (brw_inst_src0_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
1053 return src_da16(file
,
1055 brw_inst_opcode(brw
, inst
),
1056 brw_inst_src0_reg_type(brw
, inst
),
1057 brw_inst_src0_reg_file(brw
, inst
),
1058 brw_inst_src0_vstride(brw
, inst
),
1059 brw_inst_src0_da_reg_nr(brw
, inst
),
1060 brw_inst_src0_da16_subreg_nr(brw
, inst
),
1061 brw_inst_src0_abs(brw
, inst
),
1062 brw_inst_src0_negate(brw
, inst
),
1063 brw_inst_src0_da16_swiz_x(brw
, inst
),
1064 brw_inst_src0_da16_swiz_y(brw
, inst
),
1065 brw_inst_src0_da16_swiz_z(brw
, inst
),
1066 brw_inst_src0_da16_swiz_w(brw
, inst
));
1068 string(file
, "Indirect align16 address mode not supported");
1075 src1(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
1077 if (brw_inst_src1_reg_file(brw
, inst
) == BRW_IMMEDIATE_VALUE
) {
1078 return imm(file
, brw
, brw_inst_src1_reg_type(brw
, inst
), inst
);
1079 } else if (brw_inst_access_mode(brw
, inst
) == BRW_ALIGN_1
) {
1080 if (brw_inst_src1_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
1081 return src_da1(file
,
1083 brw_inst_opcode(brw
, inst
),
1084 brw_inst_src1_reg_type(brw
, inst
),
1085 brw_inst_src1_reg_file(brw
, inst
),
1086 brw_inst_src1_vstride(brw
, inst
),
1087 brw_inst_src1_width(brw
, inst
),
1088 brw_inst_src1_hstride(brw
, inst
),
1089 brw_inst_src1_da_reg_nr(brw
, inst
),
1090 brw_inst_src1_da1_subreg_nr(brw
, inst
),
1091 brw_inst_src1_abs(brw
, inst
),
1092 brw_inst_src1_negate(brw
, inst
));
1094 return src_ia1(file
,
1096 brw_inst_opcode(brw
, inst
),
1097 brw_inst_src1_reg_type(brw
, inst
),
1098 brw_inst_src1_reg_file(brw
, inst
),
1099 brw_inst_src1_ia1_addr_imm(brw
, inst
),
1100 brw_inst_src1_ia_subreg_nr(brw
, inst
),
1101 brw_inst_src1_negate(brw
, inst
),
1102 brw_inst_src1_abs(brw
, inst
),
1103 brw_inst_src1_address_mode(brw
, inst
),
1104 brw_inst_src1_hstride(brw
, inst
),
1105 brw_inst_src1_width(brw
, inst
),
1106 brw_inst_src1_vstride(brw
, inst
));
1109 if (brw_inst_src1_address_mode(brw
, inst
) == BRW_ADDRESS_DIRECT
) {
1110 return src_da16(file
,
1112 brw_inst_opcode(brw
, inst
),
1113 brw_inst_src1_reg_type(brw
, inst
),
1114 brw_inst_src1_reg_file(brw
, inst
),
1115 brw_inst_src1_vstride(brw
, inst
),
1116 brw_inst_src1_da_reg_nr(brw
, inst
),
1117 brw_inst_src1_da16_subreg_nr(brw
, inst
),
1118 brw_inst_src1_abs(brw
, inst
),
1119 brw_inst_src1_negate(brw
, inst
),
1120 brw_inst_src1_da16_swiz_x(brw
, inst
),
1121 brw_inst_src1_da16_swiz_y(brw
, inst
),
1122 brw_inst_src1_da16_swiz_z(brw
, inst
),
1123 brw_inst_src1_da16_swiz_w(brw
, inst
));
1125 string(file
, "Indirect align16 address mode not supported");
1132 qtr_ctrl(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
)
1134 int qtr_ctl
= brw_inst_qtr_control(brw
, inst
);
1135 int exec_size
= 1 << brw_inst_exec_size(brw
, inst
);
1137 if (exec_size
== 8) {
1140 string(file
, " 1Q");
1143 string(file
, " 2Q");
1146 string(file
, " 3Q");
1149 string(file
, " 4Q");
1152 } else if (exec_size
== 16) {
1154 string(file
, " 1H");
1156 string(file
, " 2H");
1162 brw_disassemble_inst(FILE *file
, struct brw_context
*brw
, brw_inst
*inst
,
1168 const enum opcode opcode
= brw_inst_opcode(brw
, inst
);
1170 if (brw_inst_pred_control(brw
, inst
)) {
1172 err
|= control(file
, "predicate inverse", pred_inv
,
1173 brw_inst_pred_inv(brw
, inst
), NULL
);
1174 format(file
, "f%d", brw
->gen
>= 7 ? brw_inst_flag_reg_nr(brw
, inst
) : 0);
1175 if (brw_inst_flag_subreg_nr(brw
, inst
))
1176 format(file
, ".%d", brw_inst_flag_subreg_nr(brw
, inst
));
1177 if (brw_inst_access_mode(brw
, inst
) == BRW_ALIGN_1
) {
1178 err
|= control(file
, "predicate control align1", pred_ctrl_align1
,
1179 brw_inst_pred_control(brw
, inst
), NULL
);
1181 err
|= control(file
, "predicate control align16", pred_ctrl_align16
,
1182 brw_inst_pred_control(brw
, inst
), NULL
);
1187 err
|= print_opcode(file
, opcode
);
1188 err
|= control(file
, "saturate", saturate
, brw_inst_saturate(brw
, inst
),
1191 err
|= control(file
, "debug control", debug_ctrl
,
1192 brw_inst_debug_control(brw
, inst
), NULL
);
1194 if (opcode
== BRW_OPCODE_MATH
) {
1196 err
|= control(file
, "function", math_function
,
1197 brw_inst_math_function(brw
, inst
), NULL
);
1198 } else if (opcode
!= BRW_OPCODE_SEND
&& opcode
!= BRW_OPCODE_SENDC
) {
1199 err
|= control(file
, "conditional modifier", conditional_modifier
,
1200 brw_inst_cond_modifier(brw
, inst
), NULL
);
1202 /* If we're using the conditional modifier, print which flags reg is
1203 * used for it. Note that on gen6+, the embedded-condition SEL and
1204 * control flow doesn't update flags.
1206 if (brw_inst_cond_modifier(brw
, inst
) &&
1207 (brw
->gen
< 6 || (opcode
!= BRW_OPCODE_SEL
&&
1208 opcode
!= BRW_OPCODE_IF
&&
1209 opcode
!= BRW_OPCODE_WHILE
))) {
1210 format(file
, ".f%d",
1211 brw
->gen
>= 7 ? brw_inst_flag_reg_nr(brw
, inst
) : 0);
1212 if (brw_inst_flag_subreg_nr(brw
, inst
))
1213 format(file
, ".%d", brw_inst_flag_subreg_nr(brw
, inst
));
1217 if (opcode
!= BRW_OPCODE_NOP
) {
1219 err
|= control(file
, "execution size", exec_size
,
1220 brw_inst_exec_size(brw
, inst
), NULL
);
1224 if (opcode
== BRW_OPCODE_SEND
&& brw
->gen
< 6)
1225 format(file
, " %d", brw_inst_base_mrf(brw
, inst
));
1227 if (has_uip(brw
, opcode
)) {
1228 /* Instructions that have UIP also have JIP. */
1230 format(file
, "JIP: %d", brw_inst_jip(brw
, inst
));
1232 format(file
, "UIP: %d", brw_inst_uip(brw
, inst
));
1233 } else if (has_jip(brw
, opcode
)) {
1235 if (brw
->gen
>= 7) {
1236 format(file
, "JIP: %d", brw_inst_jip(brw
, inst
));
1238 format(file
, "JIP: %d", brw_inst_gen6_jump_count(brw
, inst
));
1240 } else if (brw
->gen
< 6 && (opcode
== BRW_OPCODE_BREAK
||
1241 opcode
== BRW_OPCODE_CONTINUE
||
1242 opcode
== BRW_OPCODE_ELSE
)) {
1244 format(file
, "Jump: %d", brw_inst_gen4_jump_count(brw
, inst
));
1246 format(file
, "Pop: %d", brw_inst_gen4_pop_count(brw
, inst
));
1247 } else if (brw
->gen
< 6 && (opcode
== BRW_OPCODE_IF
||
1248 opcode
== BRW_OPCODE_IFF
||
1249 opcode
== BRW_OPCODE_HALT
)) {
1251 format(file
, "Jump: %d", brw_inst_gen4_pop_count(brw
, inst
));
1252 } else if (brw
->gen
< 6 && opcode
== BRW_OPCODE_ENDIF
) {
1254 format(file
, "Pop: %d", brw_inst_gen4_pop_count(brw
, inst
));
1255 } else if (opcode
== BRW_OPCODE_JMPI
) {
1256 format(file
, " %d", brw_inst_imm_d(brw
, inst
));
1257 } else if (opcode_descs
[opcode
].nsrc
== 3) {
1259 err
|= dest_3src(file
, brw
, inst
);
1262 err
|= src0_3src(file
, brw
, inst
);
1265 err
|= src1_3src(file
, brw
, inst
);
1268 err
|= src2_3src(file
, brw
, inst
);
1270 if (opcode_descs
[opcode
].ndst
> 0) {
1272 err
|= dest(file
, brw
, inst
);
1275 if (opcode_descs
[opcode
].nsrc
> 0) {
1277 err
|= src0(file
, brw
, inst
);
1280 if (opcode_descs
[opcode
].nsrc
> 1) {
1282 err
|= src1(file
, brw
, inst
);
1286 if (opcode
== BRW_OPCODE_SEND
|| opcode
== BRW_OPCODE_SENDC
) {
1287 enum brw_message_target sfid
= brw_inst_sfid(brw
, inst
);
1294 err
|= control(file
, "SFID", brw
->gen
>= 6 ? gen6_sfid
: gen4_sfid
,
1299 err
|= control(file
, "math function", math_function
,
1300 brw_inst_math_msg_function(brw
, inst
), &space
);
1301 err
|= control(file
, "math saturate", math_saturate
,
1302 brw_inst_math_msg_saturate(brw
, inst
), &space
);
1303 err
|= control(file
, "math signed", math_signed
,
1304 brw_inst_math_msg_signed_int(brw
, inst
), &space
);
1305 err
|= control(file
, "math scalar", math_scalar
,
1306 brw_inst_math_msg_data_type(brw
, inst
), &space
);
1307 err
|= control(file
, "math precision", math_precision
,
1308 brw_inst_math_msg_precision(brw
, inst
), &space
);
1310 case BRW_SFID_SAMPLER
:
1311 if (brw
->gen
>= 5) {
1312 format(file
, " (%d, %d, %d, %d)",
1313 brw_inst_binding_table_index(brw
, inst
),
1314 brw_inst_sampler(brw
, inst
),
1315 brw_inst_sampler_msg_type(brw
, inst
),
1316 brw_inst_sampler_simd_mode(brw
, inst
));
1318 format(file
, " (%d, %d, %d, ",
1319 brw_inst_binding_table_index(brw
, inst
),
1320 brw_inst_sampler(brw
, inst
),
1321 brw_inst_sampler_msg_type(brw
, inst
));
1323 err
|= control(file
, "sampler target format",
1324 sampler_target_format
,
1325 brw_inst_sampler_return_format(brw
, inst
), NULL
);
1330 case GEN6_SFID_DATAPORT_SAMPLER_CACHE
:
1331 /* aka BRW_SFID_DATAPORT_READ on Gen4-5 */
1332 if (brw
->gen
>= 6) {
1333 format(file
, " (%d, %d, %d, %d)",
1334 brw_inst_binding_table_index(brw
, inst
),
1335 brw_inst_dp_msg_control(brw
, inst
),
1336 brw_inst_dp_msg_type(brw
, inst
),
1337 brw
->gen
>= 7 ? 0 : brw_inst_dp_write_commit(brw
, inst
));
1339 format(file
, " (%d, %d, %d)",
1340 brw_inst_binding_table_index(brw
, inst
),
1341 brw_inst_dp_read_msg_control(brw
, inst
),
1342 brw_inst_dp_read_msg_type(brw
, inst
));
1346 case GEN6_SFID_DATAPORT_RENDER_CACHE
: {
1347 /* aka BRW_SFID_DATAPORT_WRITE on Gen4-5 */
1348 unsigned msg_type
= brw_inst_dp_write_msg_type(brw
, inst
);
1350 err
|= control(file
, "DP rc message type",
1351 brw
->gen
>= 6 ? dp_rc_msg_type_gen6
1352 : dp_write_port_msg_type
,
1355 bool is_rt_write
= msg_type
==
1356 (brw
->gen
>= 6 ? GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE
1357 : BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE
);
1360 err
|= control(file
, "RT message type", m_rt_write_subtype
,
1361 brw_inst_rt_message_type(brw
, inst
), &space
);
1362 if (brw
->gen
>= 6 && brw_inst_rt_slot_group(brw
, inst
))
1363 string(file
, " Hi");
1364 if (brw_inst_rt_last(brw
, inst
))
1365 string(file
, " LastRT");
1366 if (brw
->gen
< 7 && brw_inst_dp_write_commit(brw
, inst
))
1367 string(file
, " WriteCommit");
1369 format(file
, " MsgCtrl = 0x%x",
1370 brw_inst_dp_write_msg_control(brw
, inst
));
1373 format(file
, " Surface = %d", brw_inst_binding_table_index(brw
, inst
));
1378 format(file
, " %d", brw_inst_urb_global_offset(brw
, inst
));
1381 if (brw
->gen
>= 7) {
1382 err
|= control(file
, "urb opcode", gen7_urb_opcode
,
1383 brw_inst_urb_opcode(brw
, inst
), &space
);
1384 } else if (brw
->gen
>= 5) {
1385 err
|= control(file
, "urb opcode", gen5_urb_opcode
,
1386 brw_inst_urb_opcode(brw
, inst
), &space
);
1388 err
|= control(file
, "urb swizzle", urb_swizzle
,
1389 brw_inst_urb_swizzle_control(brw
, inst
), &space
);
1391 err
|= control(file
, "urb allocate", urb_allocate
,
1392 brw_inst_urb_allocate(brw
, inst
), &space
);
1393 err
|= control(file
, "urb used", urb_used
,
1394 brw_inst_urb_used(brw
, inst
), &space
);
1396 err
|= control(file
, "urb complete", urb_complete
,
1397 brw_inst_urb_complete(brw
, inst
), &space
);
1399 case BRW_SFID_THREAD_SPAWNER
:
1401 case GEN7_SFID_DATAPORT_DATA_CACHE
:
1402 if (brw
->gen
>= 7) {
1405 err
|= control(file
, "DP DC0 message type",
1406 dp_dc0_msg_type_gen7
,
1407 brw_inst_dp_msg_type(brw
, inst
), &space
);
1409 format(file
, ", %d, ", brw_inst_binding_table_index(brw
, inst
));
1411 switch (brw_inst_dp_msg_type(brw
, inst
)) {
1412 case GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP
:
1413 control(file
, "atomic op", aop
,
1414 brw_inst_imm_ud(brw
, inst
) >> 8 & 0xf, &space
);
1417 format(file
, "%d", brw_inst_dp_msg_control(brw
, inst
));
1424 case HSW_SFID_DATAPORT_DATA_CACHE_1
: {
1425 if (brw
->gen
>= 7) {
1428 unsigned msg_ctrl
= brw_inst_dp_msg_control(brw
, inst
);
1430 err
|= control(file
, "DP DC1 message type",
1431 dp_dc1_msg_type_hsw
,
1432 brw_inst_dp_msg_type(brw
, inst
), &space
);
1434 format(file
, ", Surface = %d, ",
1435 brw_inst_binding_table_index(brw
, inst
));
1437 switch (brw_inst_dp_msg_type(brw
, inst
)) {
1438 case HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP
:
1439 case HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP
:
1440 case HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP
:
1441 format(file
, "SIMD%d,", (msg_ctrl
& (1 << 4)) ? 8 : 16);
1443 case HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2
:
1444 case HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2
:
1445 case HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP_SIMD4X2
:
1446 control(file
, "atomic op", aop
, msg_ctrl
& 0xf, &space
);
1448 case HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ
:
1449 case HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE
:
1450 case HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ
:
1451 case HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE
: {
1452 static const char *simd_modes
[] = { "4x2", "16", "8" };
1453 format(file
, "SIMD%s, Mask = 0x%x",
1454 simd_modes
[msg_ctrl
>> 4], msg_ctrl
& 0xf);
1458 format(file
, "0x%x", msg_ctrl
);
1467 format(file
, "unsupported shared function ID %d", sfid
);
1472 format(file
, "mlen %d", brw_inst_mlen(brw
, inst
));
1473 format(file
, " rlen %d", brw_inst_rlen(brw
, inst
));
1476 if (opcode
!= BRW_OPCODE_NOP
) {
1479 err
|= control(file
, "access mode", access_mode
,
1480 brw_inst_access_mode(brw
, inst
), &space
);
1481 if (brw
->gen
>= 6) {
1482 err
|= control(file
, "write enable control", wectrl
,
1483 brw_inst_mask_control(brw
, inst
), &space
);
1485 err
|= control(file
, "mask control", mask_ctrl
,
1486 brw_inst_mask_control(brw
, inst
), &space
);
1488 err
|= control(file
, "dependency control", dep_ctrl
,
1489 ((brw_inst_no_dd_check(brw
, inst
) << 1) |
1490 brw_inst_no_dd_clear(brw
, inst
)), &space
);
1493 err
|= qtr_ctrl(file
, brw
, inst
);
1495 if (brw_inst_qtr_control(brw
, inst
) == BRW_COMPRESSION_COMPRESSED
&&
1496 opcode_descs
[opcode
].ndst
> 0 &&
1497 brw_inst_dst_reg_file(brw
, inst
) == BRW_MESSAGE_REGISTER_FILE
&&
1498 brw_inst_dst_da_reg_nr(brw
, inst
) & (1 << 7)) {
1499 format(file
, " compr4");
1501 err
|= control(file
, "compression control", compr_ctrl
,
1502 brw_inst_qtr_control(brw
, inst
), &space
);
1506 err
|= control(file
, "compaction", cmpt_ctrl
, is_compacted
, &space
);
1507 err
|= control(file
, "thread control", thread_ctrl
,
1508 brw_inst_thread_control(brw
, inst
), &space
);
1510 err
|= control(file
, "acc write control", accwr
,
1511 brw_inst_acc_wr_control(brw
, inst
), &space
);
1512 if (opcode
== BRW_OPCODE_SEND
|| opcode
== BRW_OPCODE_SENDC
)
1513 err
|= control(file
, "end of thread", end_of_thread
,
1514 brw_inst_eot(brw
, inst
), &space
);