- int err = 0;
- int space = 0;
-
- if (inst->header.predicate_control) {
- string (file, "(");
- err |= control (file, "predicate inverse", pred_inv, inst->header.predicate_inverse, NULL);
- format (file, "f%d", brw->gen >= 7 ? inst->bits2.da1.flag_reg_nr : 0);
- if (inst->bits2.da1.flag_subreg_nr)
- format (file, ".%d", inst->bits2.da1.flag_subreg_nr);
- if (inst->header.access_mode == BRW_ALIGN_1)
- err |= control (file, "predicate control align1", pred_ctrl_align1,
- inst->header.predicate_control, NULL);
- else
- err |= control (file, "predicate control align16", pred_ctrl_align16,
- inst->header.predicate_control, NULL);
- string (file, ") ");
- }
-
- err |= print_opcode (file, inst->header.opcode);
- err |= control (file, "saturate", saturate, inst->header.saturate, NULL);
-
- err |= control (file, "debug control", debug_ctrl, inst->header.debug_control, NULL);
-
- if (inst->header.opcode == BRW_OPCODE_MATH) {
- string (file, " ");
- err |= control (file, "function", math_function,
- inst->header.destreg__conditionalmod, NULL);
- } else if (inst->header.opcode != BRW_OPCODE_SEND &&
- inst->header.opcode != BRW_OPCODE_SENDC) {
- err |= control (file, "conditional modifier", conditional_modifier,
- inst->header.destreg__conditionalmod, NULL);
-
- /* If we're using the conditional modifier, print which flags reg is
- * used for it. Note that on gen6+, the embedded-condition SEL and
- * control flow doesn't update flags.
- */
- if (inst->header.destreg__conditionalmod &&
- (brw->gen < 6 || (inst->header.opcode != BRW_OPCODE_SEL &&
- inst->header.opcode != BRW_OPCODE_IF &&
- inst->header.opcode != BRW_OPCODE_WHILE))) {
- format (file, ".f%d", brw->gen >= 7 ? inst->bits2.da1.flag_reg_nr : 0);
- if (inst->bits2.da1.flag_subreg_nr)
- format (file, ".%d", inst->bits2.da1.flag_subreg_nr);
- }
- }
-
- if (inst->header.opcode != BRW_OPCODE_NOP) {
- string (file, "(");
- err |= control (file, "execution size", exec_size, inst->header.execution_size, NULL);
- string (file, ")");
- }
-
- if (inst->header.opcode == BRW_OPCODE_SEND && brw->gen < 6)
- format (file, " %d", inst->header.destreg__conditionalmod);
-
- if (opcode[inst->header.opcode].nsrc == 3) {
- pad (file, 16);
- err |= dest_3src (file, inst);
-
- pad (file, 32);
- err |= src0_3src (file, inst);
-
- pad (file, 48);
- err |= src1_3src (file, inst);
-
- pad (file, 64);
- err |= src2_3src (file, inst);
- } else {
- if (opcode[inst->header.opcode].ndst > 0) {
- pad (file, 16);
- err |= dest (file, inst);
- } else if (brw->gen == 7 && (inst->header.opcode == BRW_OPCODE_ELSE ||
- inst->header.opcode == BRW_OPCODE_ENDIF ||
- inst->header.opcode == BRW_OPCODE_WHILE)) {
- format (file, " %d", inst->bits3.break_cont.jip);
- } else if (brw->gen == 6 && (inst->header.opcode == BRW_OPCODE_IF ||
- inst->header.opcode == BRW_OPCODE_ELSE ||
- inst->header.opcode == BRW_OPCODE_ENDIF ||
- inst->header.opcode == BRW_OPCODE_WHILE)) {
- format (file, " %d", inst->bits1.branch_gen6.jump_count);
- } else if ((brw->gen >= 6 && (inst->header.opcode == BRW_OPCODE_BREAK ||
- inst->header.opcode == BRW_OPCODE_CONTINUE ||
- inst->header.opcode == BRW_OPCODE_HALT)) ||
- (brw->gen == 7 && inst->header.opcode == BRW_OPCODE_IF)) {
- format (file, " %d %d", inst->bits3.break_cont.uip, inst->bits3.break_cont.jip);
- } else if (inst->header.opcode == BRW_OPCODE_JMPI) {
- format (file, " %d", inst->bits3.d);
- }
-
- if (opcode[inst->header.opcode].nsrc > 0) {
- pad (file, 32);
- err |= src0 (file, inst);
- }
- if (opcode[inst->header.opcode].nsrc > 1) {
- pad (file, 48);
- err |= src1 (file, inst);
- }
- }
-
- if (inst->header.opcode == BRW_OPCODE_SEND ||
- inst->header.opcode == BRW_OPCODE_SENDC) {
- enum brw_message_target target;
-
- if (brw->gen >= 6)
- target = inst->header.destreg__conditionalmod;
- else if (brw->gen == 5)
- target = inst->bits2.send_gen5.sfid;
- else
- target = inst->bits3.generic.msg_target;
-
- newline (file);
- pad (file, 16);
- space = 0;
-
- fprintf (file, " ");
- if (brw->gen >= 6) {
- err |= control (file, "target function", target_function_gen6,
- target, &space);
- } else {
- err |= control (file, "target function", target_function,
- target, &space);
- }
-
- switch (target) {
- case BRW_SFID_MATH:
- err |= control (file, "math function", math_function,
- inst->bits3.math.function, &space);
- err |= control (file, "math saturate", math_saturate,
- inst->bits3.math.saturate, &space);
- err |= control (file, "math signed", math_signed,
- inst->bits3.math.int_type, &space);
- err |= control (file, "math scalar", math_scalar,
- inst->bits3.math.data_type, &space);
- err |= control (file, "math precision", math_precision,
- inst->bits3.math.precision, &space);
- break;
- case BRW_SFID_SAMPLER:
- if (brw->gen >= 7) {
- format (file, " (%d, %d, %d, %d)",
- inst->bits3.sampler_gen7.binding_table_index,
- inst->bits3.sampler_gen7.sampler,
- inst->bits3.sampler_gen7.msg_type,
- inst->bits3.sampler_gen7.simd_mode);
- } else if (brw->gen >= 5) {
- format (file, " (%d, %d, %d, %d)",
- inst->bits3.sampler_gen5.binding_table_index,
- inst->bits3.sampler_gen5.sampler,
- inst->bits3.sampler_gen5.msg_type,
- inst->bits3.sampler_gen5.simd_mode);
- } else if (0 /* FINISHME: is_g4x */) {
- format (file, " (%d, %d)",
- inst->bits3.sampler_g4x.binding_table_index,
- inst->bits3.sampler_g4x.sampler);
- } else {
- format (file, " (%d, %d, ",
- inst->bits3.sampler.binding_table_index,
- inst->bits3.sampler.sampler);
- err |= control (file, "sampler target format",
- sampler_target_format,
- inst->bits3.sampler.return_format, NULL);
- string (file, ")");
- }
- break;
- case BRW_SFID_DATAPORT_READ:
- if (brw->gen >= 6) {
- format (file, " (%d, %d, %d, %d)",
- inst->bits3.gen6_dp.binding_table_index,
- inst->bits3.gen6_dp.msg_control,
- inst->bits3.gen6_dp.msg_type,
- inst->bits3.gen6_dp.send_commit_msg);
- } else if (brw->gen >= 5 /* FINISHME: || is_g4x */) {
- format (file, " (%d, %d, %d)",
- inst->bits3.dp_read_gen5.binding_table_index,
- inst->bits3.dp_read_gen5.msg_control,
- inst->bits3.dp_read_gen5.msg_type);
- } else {
- format (file, " (%d, %d, %d)",
- inst->bits3.dp_read.binding_table_index,
- inst->bits3.dp_read.msg_control,
- inst->bits3.dp_read.msg_type);
- }
- break;
-
- case BRW_SFID_DATAPORT_WRITE:
- if (brw->gen >= 7) {
- format (file, " (");
-
- err |= control (file, "DP rc message type",
- dp_rc_msg_type_gen6,
- inst->bits3.gen7_dp.msg_type, &space);
-
- format (file, ", %d, %d, %d)",
- inst->bits3.gen7_dp.binding_table_index,
- inst->bits3.gen7_dp.msg_control,
- inst->bits3.gen7_dp.msg_type);
- } else if (brw->gen == 6) {
- format (file, " (");
-
- err |= control (file, "DP rc message type",
- dp_rc_msg_type_gen6,
- inst->bits3.gen6_dp.msg_type, &space);
-
- format (file, ", %d, %d, %d, %d)",
- inst->bits3.gen6_dp.binding_table_index,
- inst->bits3.gen6_dp.msg_control,
- inst->bits3.gen6_dp.msg_type,
- inst->bits3.gen6_dp.send_commit_msg);
- } else {
- format (file, " (%d, %d, %d, %d)",
- inst->bits3.dp_write.binding_table_index,
- (inst->bits3.dp_write.last_render_target << 3) |
- inst->bits3.dp_write.msg_control,
- inst->bits3.dp_write.msg_type,
- inst->bits3.dp_write.send_commit_msg);
- }
- break;
-
- case BRW_SFID_URB:
- if (brw->gen >= 5) {
- format (file, " %d", inst->bits3.urb_gen5.offset);
- } else {
- format (file, " %d", inst->bits3.urb.offset);
- }
-
- space = 1;
- if (brw->gen >= 5) {
- err |= control (file, "urb opcode", urb_opcode,
- inst->bits3.urb_gen5.opcode, &space);
- }
- err |= control (file, "urb swizzle", urb_swizzle,
- inst->bits3.urb.swizzle_control, &space);
- err |= control (file, "urb allocate", urb_allocate,
- inst->bits3.urb.allocate, &space);
- err |= control (file, "urb used", urb_used,
- inst->bits3.urb.used, &space);
- err |= control (file, "urb complete", urb_complete,
- inst->bits3.urb.complete, &space);
- break;
- case BRW_SFID_THREAD_SPAWNER:
- break;
- case GEN7_SFID_DATAPORT_DATA_CACHE:
- if (brw->gen >= 7) {
- format (file, " (");
-
- err |= control (file, "DP DC0 message type",
+ int err = 0;
+ int space = 0;
+
+ const enum opcode opcode = brw_inst_opcode(brw, inst);
+
+ if (brw_inst_pred_control(brw, inst)) {
+ string(file, "(");
+ err |= control(file, "predicate inverse", pred_inv,
+ brw_inst_pred_inv(brw, inst), NULL);
+ format(file, "f%ld", brw->gen >= 7 ? brw_inst_flag_reg_nr(brw, inst) : 0);
+ if (brw_inst_flag_subreg_nr(brw, inst))
+ format(file, ".%ld", brw_inst_flag_subreg_nr(brw, inst));
+ if (brw_inst_access_mode(brw, inst) == BRW_ALIGN_1) {
+ err |= control(file, "predicate control align1", pred_ctrl_align1,
+ brw_inst_pred_control(brw, inst), NULL);
+ } else {
+ err |= control(file, "predicate control align16", pred_ctrl_align16,
+ brw_inst_pred_control(brw, inst), NULL);
+ }
+ string(file, ") ");
+ }
+
+ err |= print_opcode(file, opcode);
+ err |= control(file, "saturate", saturate, brw_inst_saturate(brw, inst),
+ NULL);
+
+ err |= control(file, "debug control", debug_ctrl,
+ brw_inst_debug_control(brw, inst), NULL);
+
+ if (opcode == BRW_OPCODE_MATH) {
+ string(file, " ");
+ err |= control(file, "function", math_function,
+ brw_inst_math_function(brw, inst), NULL);
+ } else if (opcode != BRW_OPCODE_SEND && opcode != BRW_OPCODE_SENDC) {
+ err |= control(file, "conditional modifier", conditional_modifier,
+ brw_inst_cond_modifier(brw, inst), NULL);
+
+ /* If we're using the conditional modifier, print which flags reg is
+ * used for it. Note that on gen6+, the embedded-condition SEL and
+ * control flow doesn't update flags.
+ */
+ if (brw_inst_cond_modifier(brw, inst) &&
+ (brw->gen < 6 || (opcode != BRW_OPCODE_SEL &&
+ opcode != BRW_OPCODE_IF &&
+ opcode != BRW_OPCODE_WHILE))) {
+ format(file, ".f%ld",
+ brw->gen >= 7 ? brw_inst_flag_reg_nr(brw, inst) : 0);
+ if (brw_inst_flag_subreg_nr(brw, inst))
+ format(file, ".%ld", brw_inst_flag_subreg_nr(brw, inst));
+ }
+ }
+
+ if (opcode != BRW_OPCODE_NOP && opcode != BRW_OPCODE_NENOP) {
+ string(file, "(");
+ err |= control(file, "execution size", exec_size,
+ brw_inst_exec_size(brw, inst), NULL);
+ string(file, ")");
+ }
+
+ if (opcode == BRW_OPCODE_SEND && brw->gen < 6)
+ format(file, " %ld", brw_inst_base_mrf(brw, inst));
+
+ if (has_uip(brw, opcode)) {
+ /* Instructions that have UIP also have JIP. */
+ pad(file, 16);
+ format(file, "JIP: %d", brw_inst_jip(brw, inst));
+ pad(file, 32);
+ format(file, "UIP: %d", brw_inst_uip(brw, inst));
+ } else if (has_jip(brw, opcode)) {
+ pad(file, 16);
+ if (brw->gen >= 7) {
+ format(file, "JIP: %d", brw_inst_jip(brw, inst));
+ } else {
+ format(file, "JIP: %d", brw_inst_gen6_jump_count(brw, inst));
+ }
+ } else if (brw->gen < 6 && (opcode == BRW_OPCODE_BREAK ||
+ opcode == BRW_OPCODE_CONTINUE ||
+ opcode == BRW_OPCODE_ELSE)) {
+ pad(file, 16);
+ format(file, "Jump: %d", brw_inst_gen4_jump_count(brw, inst));
+ pad(file, 32);
+ format(file, "Pop: %ld", brw_inst_gen4_pop_count(brw, inst));
+ } else if (brw->gen < 6 && (opcode == BRW_OPCODE_IF ||
+ opcode == BRW_OPCODE_IFF ||
+ opcode == BRW_OPCODE_HALT)) {
+ pad(file, 16);
+ format(file, "Jump: %d", brw_inst_gen4_jump_count(brw, inst));
+ } else if (brw->gen < 6 && opcode == BRW_OPCODE_ENDIF) {
+ pad(file, 16);
+ format(file, "Pop: %ld", brw_inst_gen4_pop_count(brw, inst));
+ } else if (opcode == BRW_OPCODE_JMPI) {
+ pad(file, 16);
+ err |= src1(file, brw, inst);
+ } else if (opcode_descs[opcode].nsrc == 3) {
+ pad(file, 16);
+ err |= dest_3src(file, brw, inst);
+
+ pad(file, 32);
+ err |= src0_3src(file, brw, inst);
+
+ pad(file, 48);
+ err |= src1_3src(file, brw, inst);
+
+ pad(file, 64);
+ err |= src2_3src(file, brw, inst);
+ } else {
+ if (opcode_descs[opcode].ndst > 0) {
+ pad(file, 16);
+ err |= dest(file, brw, inst);
+ }
+
+ if (opcode_descs[opcode].nsrc > 0) {
+ pad(file, 32);
+ err |= src0(file, brw, inst);
+ }
+
+ if (opcode_descs[opcode].nsrc > 1) {
+ pad(file, 48);
+ err |= src1(file, brw, inst);
+ }
+ }
+
+ if (opcode == BRW_OPCODE_SEND || opcode == BRW_OPCODE_SENDC) {
+ enum brw_message_target sfid = brw_inst_sfid(brw, inst);
+
+ if (brw_inst_src1_reg_file(brw, inst) != BRW_IMMEDIATE_VALUE) {
+ /* show the indirect descriptor source */
+ pad(file, 48);
+ err |= src1(file, brw, inst);
+ }
+
+ newline(file);
+ pad(file, 16);
+ space = 0;
+
+ fprintf(file, " ");
+ err |= control(file, "SFID", brw->gen >= 6 ? gen6_sfid : gen4_sfid,
+ sfid, &space);
+
+
+ if (brw_inst_src1_reg_file(brw, inst) != BRW_IMMEDIATE_VALUE) {
+ format(file, " indirect");
+ } else {
+ switch (sfid) {
+ case BRW_SFID_MATH:
+ err |= control(file, "math function", math_function,
+ brw_inst_math_msg_function(brw, inst), &space);
+ err |= control(file, "math saturate", math_saturate,
+ brw_inst_math_msg_saturate(brw, inst), &space);
+ err |= control(file, "math signed", math_signed,
+ brw_inst_math_msg_signed_int(brw, inst), &space);
+ err |= control(file, "math scalar", math_scalar,
+ brw_inst_math_msg_data_type(brw, inst), &space);
+ err |= control(file, "math precision", math_precision,
+ brw_inst_math_msg_precision(brw, inst), &space);
+ break;
+ case BRW_SFID_SAMPLER:
+ if (brw->gen >= 5) {
+ format(file, " (%ld, %ld, %ld, %ld)",
+ brw_inst_binding_table_index(brw, inst),
+ brw_inst_sampler(brw, inst),
+ brw_inst_sampler_msg_type(brw, inst),
+ brw_inst_sampler_simd_mode(brw, inst));
+ } else {
+ format(file, " (%ld, %ld, %ld, ",
+ brw_inst_binding_table_index(brw, inst),
+ brw_inst_sampler(brw, inst),
+ brw_inst_sampler_msg_type(brw, inst));
+ if (!brw->is_g4x) {
+ err |= control(file, "sampler target format",
+ sampler_target_format,
+ brw_inst_sampler_return_format(brw, inst), NULL);
+ }
+ string(file, ")");
+ }
+ break;
+ case GEN6_SFID_DATAPORT_SAMPLER_CACHE:
+ /* aka BRW_SFID_DATAPORT_READ on Gen4-5 */
+ if (brw->gen >= 6) {
+ format(file, " (%ld, %ld, %ld, %ld)",
+ brw_inst_binding_table_index(brw, inst),
+ brw_inst_dp_msg_control(brw, inst),
+ brw_inst_dp_msg_type(brw, inst),
+ brw->gen >= 7 ? 0 : brw_inst_dp_write_commit(brw, inst));
+ } else {
+ format(file, " (%ld, %ld, %ld)",
+ brw_inst_binding_table_index(brw, inst),
+ brw_inst_dp_read_msg_control(brw, inst),
+ brw_inst_dp_read_msg_type(brw, inst));
+ }
+ break;
+
+ case GEN6_SFID_DATAPORT_RENDER_CACHE: {
+ /* aka BRW_SFID_DATAPORT_WRITE on Gen4-5 */
+ unsigned msg_type = brw_inst_dp_write_msg_type(brw, inst);
+
+ err |= control(file, "DP rc message type",
+ brw->gen >= 6 ? dp_rc_msg_type_gen6
+ : dp_write_port_msg_type,
+ msg_type, &space);
+
+ bool is_rt_write = msg_type ==
+ (brw->gen >= 6 ? GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE
+ : BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE);
+
+ if (is_rt_write) {
+ err |= control(file, "RT message type", m_rt_write_subtype,
+ brw_inst_rt_message_type(brw, inst), &space);
+ if (brw->gen >= 6 && brw_inst_rt_slot_group(brw, inst))
+ string(file, " Hi");
+ if (brw_inst_rt_last(brw, inst))
+ string(file, " LastRT");
+ if (brw->gen < 7 && brw_inst_dp_write_commit(brw, inst))
+ string(file, " WriteCommit");
+ } else {
+ format(file, " MsgCtrl = 0x%lx",
+ brw_inst_dp_write_msg_control(brw, inst));
+ }
+
+ format(file, " Surface = %ld", brw_inst_binding_table_index(brw, inst));
+ break;
+ }
+
+ case BRW_SFID_URB:
+ format(file, " %ld", brw_inst_urb_global_offset(brw, inst));
+
+ space = 1;
+ if (brw->gen >= 7) {
+ err |= control(file, "urb opcode", gen7_urb_opcode,
+ brw_inst_urb_opcode(brw, inst), &space);
+ } else if (brw->gen >= 5) {
+ err |= control(file, "urb opcode", gen5_urb_opcode,
+ brw_inst_urb_opcode(brw, inst), &space);
+ }
+ err |= control(file, "urb swizzle", urb_swizzle,
+ brw_inst_urb_swizzle_control(brw, inst), &space);
+ if (brw->gen < 7) {
+ err |= control(file, "urb allocate", urb_allocate,
+ brw_inst_urb_allocate(brw, inst), &space);
+ err |= control(file, "urb used", urb_used,
+ brw_inst_urb_used(brw, inst), &space);
+ }
+ if (brw->gen < 8) {
+ err |= control(file, "urb complete", urb_complete,
+ brw_inst_urb_complete(brw, inst), &space);
+ }
+ break;
+ case BRW_SFID_THREAD_SPAWNER:
+ break;
+ case GEN7_SFID_DATAPORT_DATA_CACHE:
+ if (brw->gen >= 7) {
+ format(file, " (");
+
+ err |= control(file, "DP DC0 message type",