1 /*
2 * Copyright © 2010 Intel Corporation
3 * SPDX-License-Identifier: MIT
4 */
5
6 #include "brw_cfg.h"
7 #include "brw_disasm.h"
8 #include "brw_fs.h"
9 #include "brw_private.h"
10 #include "dev/intel_debug.h"
11 #include "util/half_float.h"
12
13 using namespace brw;
14
15 void
brw_print_instructions(const fs_visitor & s,FILE * file)16 brw_print_instructions(const fs_visitor &s, FILE *file)
17 {
18 if (s.cfg && s.grf_used == 0) {
19 const brw::def_analysis &defs = s.def_analysis.require();
20 const register_pressure *rp =
21 INTEL_DEBUG(DEBUG_REG_PRESSURE) ? &s.regpressure_analysis.require() : NULL;
22
23 unsigned ip = 0, max_pressure = 0;
24 unsigned cf_count = 0;
25 foreach_block(block, s.cfg) {
26 fprintf(file, "START B%d", block->num);
27 foreach_list_typed(bblock_link, link, link, &block->parents) {
28 fprintf(file, " <%cB%d",
29 link->kind == bblock_link_logical ? '-' : '~',
30 link->block->num);
31 }
32 fprintf(file, "\n");
33
34 foreach_inst_in_block(fs_inst, inst, block) {
35 if (inst->is_control_flow_end())
36 cf_count -= 1;
37
38 if (rp) {
39 max_pressure = MAX2(max_pressure, rp->regs_live_at_ip[ip]);
40 fprintf(file, "{%3d} ", rp->regs_live_at_ip[ip]);
41 }
42
43 for (unsigned i = 0; i < cf_count; i++)
44 fprintf(file, " ");
45 brw_print_instruction(s, inst, file, &defs);
46 ip++;
47
48 if (inst->is_control_flow_begin())
49 cf_count += 1;
50 }
51
52 fprintf(file, "END B%d", block->num);
53 foreach_list_typed(bblock_link, link, link, &block->children) {
54 fprintf(file, " %c>B%d",
55 link->kind == bblock_link_logical ? '-' : '~',
56 link->block->num);
57 }
58 fprintf(file, "\n");
59 }
60 if (rp)
61 fprintf(file, "Maximum %3d registers live at once.\n", max_pressure);
62 } else if (s.cfg && exec_list_is_empty(&s.instructions)) {
63 foreach_block_and_inst(block, fs_inst, inst, s.cfg) {
64 brw_print_instruction(s, inst, file);
65 }
66 } else {
67 foreach_in_list(fs_inst, inst, &s.instructions) {
68 brw_print_instruction(s, inst, file);
69 }
70 }
71 }
72
73 static const char *
brw_instruction_name(const struct brw_isa_info * isa,enum opcode op)74 brw_instruction_name(const struct brw_isa_info *isa, enum opcode op)
75 {
76 const struct intel_device_info *devinfo = isa->devinfo;
77
78 switch (op) {
79 case 0 ... NUM_BRW_OPCODES - 1:
80 /* The DO instruction doesn't exist on Gfx9+, but we use it to mark the
81 * start of a loop in the IR.
82 */
83 if (op == BRW_OPCODE_DO)
84 return "do";
85
86 /* DPAS instructions may transiently exist on platforms that do not
87 * support DPAS. They will eventually be lowered, but in the meantime it
88 * must be possible to query the instruction name.
89 */
90 if (devinfo->verx10 < 125 && op == BRW_OPCODE_DPAS)
91 return "dpas";
92
93 assert(brw_opcode_desc(isa, op)->name);
94 return brw_opcode_desc(isa, op)->name;
95 case FS_OPCODE_FB_WRITE_LOGICAL:
96 return "fb_write_logical";
97 case FS_OPCODE_FB_READ_LOGICAL:
98 return "fb_read_logical";
99
100 case SHADER_OPCODE_RCP:
101 return "rcp";
102 case SHADER_OPCODE_RSQ:
103 return "rsq";
104 case SHADER_OPCODE_SQRT:
105 return "sqrt";
106 case SHADER_OPCODE_EXP2:
107 return "exp2";
108 case SHADER_OPCODE_LOG2:
109 return "log2";
110 case SHADER_OPCODE_POW:
111 return "pow";
112 case SHADER_OPCODE_INT_QUOTIENT:
113 return "int_quot";
114 case SHADER_OPCODE_INT_REMAINDER:
115 return "int_rem";
116 case SHADER_OPCODE_SIN:
117 return "sin";
118 case SHADER_OPCODE_COS:
119 return "cos";
120
121 case SHADER_OPCODE_SEND:
122 return "send";
123 case SHADER_OPCODE_SEND_GATHER:
124 return "send_gather";
125
126 case SHADER_OPCODE_UNDEF:
127 return "undef";
128
129 case SHADER_OPCODE_TEX_LOGICAL:
130 return "tex_logical";
131 case SHADER_OPCODE_TXD_LOGICAL:
132 return "txd_logical";
133 case SHADER_OPCODE_TXF_LOGICAL:
134 return "txf_logical";
135 case SHADER_OPCODE_TXL_LOGICAL:
136 return "txl_logical";
137 case SHADER_OPCODE_TXS_LOGICAL:
138 return "txs_logical";
139 case FS_OPCODE_TXB_LOGICAL:
140 return "txb_logical";
141 case SHADER_OPCODE_TXF_CMS_W_LOGICAL:
142 return "txf_cms_w_logical";
143 case SHADER_OPCODE_TXF_CMS_W_GFX12_LOGICAL:
144 return "txf_cms_w_gfx12_logical";
145 case SHADER_OPCODE_TXF_MCS_LOGICAL:
146 return "txf_mcs_logical";
147 case SHADER_OPCODE_LOD_LOGICAL:
148 return "lod_logical";
149 case SHADER_OPCODE_TG4_LOGICAL:
150 return "tg4_logical";
151 case SHADER_OPCODE_TG4_OFFSET_LOGICAL:
152 return "tg4_offset_logical";
153 case SHADER_OPCODE_TG4_OFFSET_LOD_LOGICAL:
154 return "tg4_offset_lod_logical";
155 case SHADER_OPCODE_TG4_OFFSET_BIAS_LOGICAL:
156 return "tg4_offset_bias_logical";
157 case SHADER_OPCODE_TG4_BIAS_LOGICAL:
158 return "tg4_b_logical";
159 case SHADER_OPCODE_TG4_EXPLICIT_LOD_LOGICAL:
160 return "tg4_l_logical";
161 case SHADER_OPCODE_TG4_IMPLICIT_LOD_LOGICAL:
162 return "tg4_i_logical";
163 case SHADER_OPCODE_SAMPLEINFO_LOGICAL:
164 return "sampleinfo_logical";
165
166 case SHADER_OPCODE_IMAGE_SIZE_LOGICAL:
167 return "image_size_logical";
168
169 case SHADER_OPCODE_MEMORY_FENCE:
170 return "memory_fence";
171 case FS_OPCODE_SCHEDULING_FENCE:
172 return "scheduling_fence";
173 case SHADER_OPCODE_INTERLOCK:
174 /* For an interlock we actually issue a memory fence via sendc. */
175 return "interlock";
176
177 case SHADER_OPCODE_LOAD_PAYLOAD:
178 return "load_payload";
179 case FS_OPCODE_PACK:
180 return "pack";
181
182 case SHADER_OPCODE_SCRATCH_HEADER:
183 return "scratch_header";
184
185 case SHADER_OPCODE_URB_WRITE_LOGICAL:
186 return "urb_write_logical";
187 case SHADER_OPCODE_URB_READ_LOGICAL:
188 return "urb_read_logical";
189
190 case SHADER_OPCODE_FIND_LIVE_CHANNEL:
191 return "find_live_channel";
192 case SHADER_OPCODE_FIND_LAST_LIVE_CHANNEL:
193 return "find_last_live_channel";
194 case SHADER_OPCODE_LOAD_LIVE_CHANNELS:
195 return "load_live_channels";
196 case FS_OPCODE_LOAD_LIVE_CHANNELS:
197 return "fs_load_live_channels";
198
199 case SHADER_OPCODE_BROADCAST:
200 return "broadcast";
201 case SHADER_OPCODE_SHUFFLE:
202 return "shuffle";
203 case SHADER_OPCODE_SEL_EXEC:
204 return "sel_exec";
205 case SHADER_OPCODE_QUAD_SWIZZLE:
206 return "quad_swizzle";
207 case SHADER_OPCODE_CLUSTER_BROADCAST:
208 return "cluster_broadcast";
209
210 case SHADER_OPCODE_GET_BUFFER_SIZE:
211 return "get_buffer_size";
212
213 case FS_OPCODE_DDX_COARSE:
214 return "ddx_coarse";
215 case FS_OPCODE_DDX_FINE:
216 return "ddx_fine";
217 case FS_OPCODE_DDY_COARSE:
218 return "ddy_coarse";
219 case FS_OPCODE_DDY_FINE:
220 return "ddy_fine";
221
222 case FS_OPCODE_PIXEL_X:
223 return "pixel_x";
224 case FS_OPCODE_PIXEL_Y:
225 return "pixel_y";
226
227 case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD:
228 return "uniform_pull_const";
229 case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_LOGICAL:
230 return "varying_pull_const_logical";
231
232 case FS_OPCODE_PACK_HALF_2x16_SPLIT:
233 return "pack_half_2x16_split";
234
235 case SHADER_OPCODE_HALT_TARGET:
236 return "halt_target";
237
238 case FS_OPCODE_INTERPOLATE_AT_SAMPLE:
239 return "interp_sample";
240 case FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET:
241 return "interp_shared_offset";
242 case FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET:
243 return "interp_per_slot_offset";
244
245 case SHADER_OPCODE_BARRIER:
246 return "barrier";
247 case SHADER_OPCODE_MULH:
248 return "mulh";
249 case SHADER_OPCODE_ISUB_SAT:
250 return "isub_sat";
251 case SHADER_OPCODE_USUB_SAT:
252 return "usub_sat";
253 case SHADER_OPCODE_MOV_INDIRECT:
254 return "mov_indirect";
255 case SHADER_OPCODE_MOV_RELOC_IMM:
256 return "mov_reloc_imm";
257
258 case RT_OPCODE_TRACE_RAY_LOGICAL:
259 return "rt_trace_ray_logical";
260
261 case SHADER_OPCODE_RND_MODE:
262 return "rnd_mode";
263 case SHADER_OPCODE_FLOAT_CONTROL_MODE:
264 return "float_control_mode";
265 case SHADER_OPCODE_BTD_SPAWN_LOGICAL:
266 return "btd_spawn_logical";
267 case SHADER_OPCODE_BTD_RETIRE_LOGICAL:
268 return "btd_retire_logical";
269 case SHADER_OPCODE_READ_ARCH_REG:
270 return "read_arch_reg";
271 case SHADER_OPCODE_LOAD_SUBGROUP_INVOCATION:
272 return "load_subgroup_invocation";
273 case SHADER_OPCODE_MEMORY_LOAD_LOGICAL:
274 return "memory_load";
275 case SHADER_OPCODE_MEMORY_STORE_LOGICAL:
276 return "memory_store";
277 case SHADER_OPCODE_MEMORY_ATOMIC_LOGICAL:
278 return "memory_atomic";
279 case SHADER_OPCODE_REDUCE:
280 return "reduce";
281 case SHADER_OPCODE_INCLUSIVE_SCAN:
282 return "inclusive_scan";
283 case SHADER_OPCODE_EXCLUSIVE_SCAN:
284 return "exclusive_scan";
285 case SHADER_OPCODE_VOTE_ANY:
286 return "vote_any";
287 case SHADER_OPCODE_VOTE_ALL:
288 return "vote_all";
289 case SHADER_OPCODE_VOTE_EQUAL:
290 return "vote_equal";
291 case SHADER_OPCODE_BALLOT:
292 return "ballot";
293 case SHADER_OPCODE_QUAD_SWAP:
294 return "quad_swap";
295 case SHADER_OPCODE_READ_FROM_LIVE_CHANNEL:
296 return "read_from_live_channel";
297 case SHADER_OPCODE_READ_FROM_CHANNEL:
298 return "read_from_channel";
299 }
300
301 unreachable("not reached");
302 }
303
304 /**
305 * Pretty-print a source for a SHADER_OPCODE_MEMORY_LOGICAL instruction.
306 *
307 * Returns true if the value is fully printed (i.e. an enum) and false if
308 * we only printed a label, and the actual source value still needs printing.
309 */
310 static bool
print_memory_logical_source(FILE * file,const fs_inst * inst,unsigned i)311 print_memory_logical_source(FILE *file, const fs_inst *inst, unsigned i)
312 {
313 if (inst->is_control_source(i)) {
314 assert(inst->src[i].file == IMM && inst->src[i].type == BRW_TYPE_UD);
315 assert(!inst->src[i].negate);
316 assert(!inst->src[i].abs);
317 }
318
319 switch (i) {
320 case MEMORY_LOGICAL_OPCODE:
321 fprintf(file, " %s", brw_lsc_op_to_string(inst->src[i].ud));
322 return true;
323 case MEMORY_LOGICAL_MODE: {
324 static const char *modes[] = {
325 [MEMORY_MODE_TYPED] = "typed",
326 [MEMORY_MODE_UNTYPED] = "untyped",
327 [MEMORY_MODE_SHARED_LOCAL] = "shared",
328 [MEMORY_MODE_SCRATCH] = "scratch",
329 [MEMORY_MODE_CONSTANT] = "const",
330 };
331 assert(inst->src[i].ud < ARRAY_SIZE(modes));
332 fprintf(file, " %s", modes[inst->src[i].ud]);
333 return true;
334 }
335 case MEMORY_LOGICAL_BINDING_TYPE:
336 fprintf(file, " %s", brw_lsc_addr_surftype_to_string(inst->src[i].ud));
337 if (inst->src[i].ud != LSC_ADDR_SURFTYPE_FLAT)
338 fprintf(file, ":");
339 return true;
340 case MEMORY_LOGICAL_BINDING:
341 return inst->src[i].file == BAD_FILE;
342 case MEMORY_LOGICAL_ADDRESS:
343 fprintf(file, " addr: ");
344 return false;
345 case MEMORY_LOGICAL_COORD_COMPONENTS:
346 fprintf(file, " coord_comps:");
347 return false;
348 case MEMORY_LOGICAL_ALIGNMENT:
349 fprintf(file, " align:");
350 return false;
351 case MEMORY_LOGICAL_DATA_SIZE:
352 fprintf(file, " %s", brw_lsc_data_size_to_string(inst->src[i].ud));
353 return true;
354 case MEMORY_LOGICAL_COMPONENTS:
355 fprintf(file, " comps:");
356 return false;
357 case MEMORY_LOGICAL_FLAGS:
358 if (inst->src[i].ud & MEMORY_FLAG_TRANSPOSE)
359 fprintf(file, " transpose");
360 if (inst->src[i].ud & MEMORY_FLAG_INCLUDE_HELPERS)
361 fprintf(file, " helpers");
362 return true;
363 case MEMORY_LOGICAL_DATA0:
364 fprintf(file, " data0: ");
365 return false;
366 case MEMORY_LOGICAL_DATA1:
367 if (inst->src[i].file == BAD_FILE)
368 return true;
369 fprintf(file, " data1: ");
370 return false;
371 default:
372 unreachable("invalid source");
373 }
374 }
375
376 void
brw_print_instruction(const fs_visitor & s,const fs_inst * inst,FILE * file,const brw::def_analysis * defs)377 brw_print_instruction(const fs_visitor &s, const fs_inst *inst, FILE *file, const brw::def_analysis *defs)
378 {
379 if (inst->predicate) {
380 fprintf(file, "(%cf%d.%d) ",
381 inst->predicate_inverse ? '-' : '+',
382 inst->flag_subreg / 2,
383 inst->flag_subreg % 2);
384 }
385
386 fprintf(file, "%s", brw_instruction_name(&s.compiler->isa, inst->opcode));
387 if (inst->saturate)
388 fprintf(file, ".sat");
389 if (inst->conditional_mod) {
390 fprintf(file, "%s", conditional_modifier[inst->conditional_mod]);
391 if (!inst->predicate &&
392 (inst->opcode != BRW_OPCODE_SEL &&
393 inst->opcode != BRW_OPCODE_CSEL &&
394 inst->opcode != BRW_OPCODE_IF &&
395 inst->opcode != BRW_OPCODE_WHILE)) {
396 fprintf(file, ".f%d.%d", inst->flag_subreg / 2,
397 inst->flag_subreg % 2);
398 }
399 }
400 fprintf(file, "(%d) ", inst->exec_size);
401
402 if (inst->mlen) {
403 fprintf(file, "(mlen: %d) ", inst->mlen);
404 }
405
406 if (inst->ex_mlen) {
407 fprintf(file, "(ex_mlen: %d) ", inst->ex_mlen);
408 }
409
410 if (inst->eot) {
411 fprintf(file, "(EOT) ");
412 }
413
414 const bool is_send = inst->opcode == BRW_OPCODE_SEND ||
415 inst->opcode == SHADER_OPCODE_SEND;
416
417 switch (inst->dst.file) {
418 case VGRF:
419 if (defs && defs->get(inst->dst))
420 fprintf(file, "%%%d", inst->dst.nr);
421 else
422 fprintf(file, "v%d", inst->dst.nr);
423 break;
424 case FIXED_GRF:
425 fprintf(file, "g%d", inst->dst.nr);
426 if (inst->dst.subnr != 0)
427 fprintf(file, ".%d", inst->dst.subnr / brw_type_size_bytes(inst->dst.type));
428 break;
429 case BAD_FILE:
430 fprintf(file, "(null)");
431 break;
432 case UNIFORM:
433 fprintf(file, "***u%d***", inst->dst.nr);
434 break;
435 case ATTR:
436 fprintf(file, "***attr%d***", inst->dst.nr);
437 break;
438 case ADDRESS:
439 if (inst->dst.nr == 0)
440 fprintf(file, "a0.%d", inst->dst.subnr);
441 else
442 fprintf(file, "va%u.%d", inst->dst.nr, inst->dst.subnr);
443 break;
444 case ARF:
445 switch (inst->dst.nr & 0xF0) {
446 case BRW_ARF_NULL:
447 fprintf(file, "null");
448 break;
449 case BRW_ARF_ACCUMULATOR:
450 if (inst->dst.subnr == 0)
451 fprintf(file, "acc%d", inst->dst.nr & 0x0F);
452 else
453 fprintf(file, "acc%d.%d", inst->dst.nr & 0x0F, inst->dst.subnr);
454 break;
455 case BRW_ARF_FLAG:
456 fprintf(file, "f%d.%d", inst->dst.nr & 0xf, inst->dst.subnr);
457 break;
458 case BRW_ARF_SCALAR:
459 fprintf(file, "s0.%d", inst->dst.subnr);
460 break;
461 default:
462 fprintf(file, "arf%d.%d", inst->dst.nr & 0xf, inst->dst.subnr);
463 break;
464 }
465 break;
466 case IMM:
467 unreachable("not reached");
468 }
469
470 if (inst->dst.offset ||
471 (!s.grf_used && inst->dst.file == VGRF &&
472 s.alloc.sizes[inst->dst.nr] * REG_SIZE != inst->size_written)) {
473 const unsigned reg_size = (inst->dst.file == UNIFORM ? 4 : REG_SIZE);
474 fprintf(file, "+%d.%d", inst->dst.offset / reg_size,
475 inst->dst.offset % reg_size);
476 }
477
478 if (!is_send) {
479 if (inst->dst.stride != 1)
480 fprintf(file, "<%u>", inst->dst.stride);
481 fprintf(file, ":%s", brw_reg_type_to_letters(inst->dst.type));
482 }
483
484 for (int i = 0; i < inst->sources; i++) {
485 if (inst->opcode == SHADER_OPCODE_MEMORY_LOAD_LOGICAL ||
486 inst->opcode == SHADER_OPCODE_MEMORY_STORE_LOGICAL ||
487 inst->opcode == SHADER_OPCODE_MEMORY_ATOMIC_LOGICAL) {
488 if (print_memory_logical_source(file, inst, i))
489 continue;
490 } else {
491 fprintf(file, ", ");
492 }
493
494 if (inst->src[i].negate)
495 fprintf(file, "-");
496 if (inst->src[i].abs)
497 fprintf(file, "|");
498 switch (inst->src[i].file) {
499 case VGRF:
500 if (defs && defs->get(inst->src[i]))
501 fprintf(file, "%%%d", inst->src[i].nr);
502 else
503 fprintf(file, "v%d", inst->src[i].nr);
504 break;
505 case FIXED_GRF:
506 fprintf(file, "g%d", inst->src[i].nr);
507 break;
508 case ADDRESS:
509 if (inst->src[i].nr == 0)
510 fprintf(file, "a0.%d", inst->src[i].subnr);
511 else
512 fprintf(file, "va%u.%d", inst->src[i].nr, inst->src[i].subnr);
513 break;
514 case ATTR:
515 fprintf(file, "attr%d", inst->src[i].nr);
516 break;
517 case UNIFORM:
518 fprintf(file, "u%d", inst->src[i].nr);
519 break;
520 case BAD_FILE:
521 fprintf(file, "(null)");
522 break;
523 case IMM:
524 switch (inst->src[i].type) {
525 case BRW_TYPE_HF:
526 fprintf(file, "%-ghf", _mesa_half_to_float(inst->src[i].ud & 0xffff));
527 break;
528 case BRW_TYPE_F:
529 fprintf(file, "%-gf", inst->src[i].f);
530 break;
531 case BRW_TYPE_DF:
532 fprintf(file, "%fdf", inst->src[i].df);
533 break;
534 case BRW_TYPE_W:
535 fprintf(file, "%dw", (int)(int16_t)inst->src[i].d);
536 break;
537 case BRW_TYPE_D:
538 fprintf(file, "%dd", inst->src[i].d);
539 break;
540 case BRW_TYPE_UW:
541 fprintf(file, "%duw", inst->src[i].ud & 0xffff);
542 break;
543 case BRW_TYPE_UD:
544 fprintf(file, "%uu", inst->src[i].ud);
545 break;
546 case BRW_TYPE_Q:
547 fprintf(file, "%" PRId64 "q", inst->src[i].d64);
548 break;
549 case BRW_TYPE_UQ:
550 fprintf(file, "%" PRIu64 "uq", inst->src[i].u64);
551 break;
552 case BRW_TYPE_VF:
553 fprintf(file, "[%-gF, %-gF, %-gF, %-gF]",
554 brw_vf_to_float((inst->src[i].ud >> 0) & 0xff),
555 brw_vf_to_float((inst->src[i].ud >> 8) & 0xff),
556 brw_vf_to_float((inst->src[i].ud >> 16) & 0xff),
557 brw_vf_to_float((inst->src[i].ud >> 24) & 0xff));
558 break;
559 case BRW_TYPE_V:
560 case BRW_TYPE_UV:
561 fprintf(file, "%08x%s", inst->src[i].ud,
562 inst->src[i].type == BRW_TYPE_V ? "V" : "UV");
563 break;
564 default:
565 fprintf(file, "???");
566 break;
567 }
568 break;
569 case ARF:
570 switch (inst->src[i].nr & 0xF0) {
571 case BRW_ARF_NULL:
572 fprintf(file, "null");
573 break;
574 case BRW_ARF_ACCUMULATOR:
575 if (inst->src[i].subnr == 0)
576 fprintf(file, "acc%d", inst->src[i].nr & 0x0F);
577 else
578 fprintf(file, "acc%d.%d", inst->src[i].nr & 0x0F, inst->src[i].subnr);
579
580 break;
581 case BRW_ARF_FLAG:
582 fprintf(file, "f%d.%d", inst->src[i].nr & 0xf, inst->src[i].subnr);
583 break;
584 case BRW_ARF_SCALAR:
585 fprintf(file, "s0.%d", inst->src[i].subnr);
586 break;
587 default:
588 fprintf(file, "arf%d.%d", inst->src[i].nr & 0xf, inst->src[i].subnr);
589 break;
590 }
591 break;
592 }
593
594 if (inst->src[i].file == FIXED_GRF && inst->src[i].subnr != 0) {
595 assert(inst->src[i].offset == 0);
596
597 fprintf(file, ".%d", inst->src[i].subnr / brw_type_size_bytes(inst->src[i].type));
598 } else if (inst->src[i].offset ||
599 (!s.grf_used && inst->src[i].file == VGRF &&
600 s.alloc.sizes[inst->src[i].nr] * REG_SIZE != inst->size_read(s.devinfo, i))) {
601 const unsigned reg_size = (inst->src[i].file == UNIFORM ? 4 : REG_SIZE);
602 fprintf(file, "+%d.%d", inst->src[i].offset / reg_size,
603 inst->src[i].offset % reg_size);
604 }
605
606 if (inst->src[i].abs)
607 fprintf(file, "|");
608
609 /* Just print register numbers for payload sources. */
610 const bool omit_src_type_and_region = is_send && i >= 2;
611
612 if (inst->src[i].file != IMM && !omit_src_type_and_region) {
613 unsigned stride;
614 if (inst->src[i].file == ARF || inst->src[i].file == FIXED_GRF) {
615 fprintf(file, "<%u,%u,%u>", inst->src[i].vstride == 0 ? 0 : (1 << (inst->src[i].vstride - 1)),
616 1 << inst->src[i].width,
617 inst->src[i].hstride == 0 ? 0 : (1 << (inst->src[i].hstride - 1)));
618 } else {
619 stride = inst->src[i].stride;
620 if (stride != 1)
621 fprintf(file, "<%u>", stride);
622 }
623
624 fprintf(file, ":%s", brw_reg_type_to_letters(inst->src[i].type));
625 }
626
627 if (inst->opcode == SHADER_OPCODE_QUAD_SWAP && i == 1) {
628 assert(inst->src[i].file == IMM);
629 const char *name = NULL;
630 switch (inst->src[i].ud) {
631 case BRW_SWAP_HORIZONTAL: name = "horizontal"; break;
632 case BRW_SWAP_VERTICAL: name = "vertical"; break;
633 case BRW_SWAP_DIAGONAL: name = "diagonal"; break;
634 default:
635 unreachable("invalid brw_swap_direction");
636 }
637 fprintf(file, " (%s)", name);
638 }
639 }
640
641 fprintf(file, " ");
642
643 if (inst->force_writemask_all)
644 fprintf(file, "NoMask ");
645
646 if (inst->exec_size != s.dispatch_width)
647 fprintf(file, "group%d ", inst->group);
648
649 if (inst->has_no_mask_send_params)
650 fprintf(file, "NoMaskParams ");
651
652 if (inst->sched.regdist || inst->sched.mode) {
653 fprintf(file, "{ ");
654 brw_print_swsb(file, s.devinfo, inst->sched);
655 fprintf(file, " } ");
656 }
657
658 fprintf(file, "\n");
659 }
660
661
662 void
brw_print_swsb(FILE * f,const struct intel_device_info * devinfo,const tgl_swsb swsb)663 brw_print_swsb(FILE *f, const struct intel_device_info *devinfo, const tgl_swsb swsb)
664 {
665 if (swsb.regdist) {
666 fprintf(f, "%s@%d",
667 (devinfo && devinfo->verx10 < 125 ? "" :
668 swsb.pipe == TGL_PIPE_FLOAT ? "F" :
669 swsb.pipe == TGL_PIPE_INT ? "I" :
670 swsb.pipe == TGL_PIPE_LONG ? "L" :
671 swsb.pipe == TGL_PIPE_ALL ? "A" :
672 swsb.pipe == TGL_PIPE_MATH ? "M" :
673 swsb.pipe == TGL_PIPE_SCALAR ? "S" : "" ),
674 swsb.regdist);
675 }
676
677 if (swsb.mode) {
678 if (swsb.regdist)
679 fprintf(f, " ");
680
681 fprintf(f, "$%d%s", swsb.sbid,
682 (swsb.mode & TGL_SBID_SET ? "" :
683 swsb.mode & TGL_SBID_DST ? ".dst" : ".src"));
684 }
685 }
686