--- src/mesa/drivers/dri/i965/brw_fs.cpp | 129 +++++++++++++--------- src/mesa/drivers/dri/i965/brw_fs.h | 2 + src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 2 +- src/mesa/drivers/dri/i965/brw_shader.cpp | 20 +++- src/mesa/drivers/dri/i965/brw_shader.h | 2 + src/mesa/drivers/dri/i965/brw_vec4.cpp | 104 +++++++++-------- src/mesa/drivers/dri/i965/brw_vec4.h | 1 + 7 files changed, 154 insertions(+), 106 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index 85a5463..c1d79e1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2810,197 +2810,218 @@ fs_visitor::lower_uniform_pull_constant_loads() void fs_visitor::dump_instructions() { + dump_instructions(NULL); +} + +void +fs_visitor::dump_instructions(const char *name) +{ + invalidate_live_intervals(); calculate_register_pressure(); + FILE *file = stderr; + if (name) { + file = fopen(name, "w"); + } int ip = 0, max_pressure = 0; foreach_list(node, &this->instructions) { backend_instruction *inst = (backend_instruction *)node; max_pressure = MAX2(max_pressure, regs_live_at_ip[ip]); - fprintf(stderr, "{%3d} %4d: ", regs_live_at_ip[ip], ip); - dump_instruction(inst); + fprintf(file, "{%3d} %4d: ", regs_live_at_ip[ip], ip); + dump_instruction(inst, file); ++ip; } - fprintf(stderr, "Maximum %3d registers live at once.\n", max_pressure); + fprintf(file, "Maximum %3d registers live at once.\n", max_pressure); + + if (name) { + fclose(file); + } } void fs_visitor::dump_instruction(backend_instruction *be_inst) { + dump_instruction(be_inst, stderr); +} + +void +fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) +{ fs_inst *inst = (fs_inst *)be_inst; if (inst->predicate) { - fprintf(stderr, "(%cf0.%d) ", + fprintf(file, "(%cf0.%d) ", inst->predicate_inverse ? '-' : '+', inst->flag_subreg); } - fprintf(stderr, "%s", brw_instruction_name(inst->opcode)); + fprintf(file, "%s", brw_instruction_name(inst->opcode)); if (inst->saturate) - fprintf(stderr, ".sat"); + fprintf(file, ".sat"); if (inst->conditional_mod) { - fprintf(stderr, "%s", conditional_modifier[inst->conditional_mod]); + fprintf(file, "%s", conditional_modifier[inst->conditional_mod]); if (!inst->predicate && (brw->gen < 5 || (inst->opcode != BRW_OPCODE_SEL && inst->opcode != BRW_OPCODE_IF && inst->opcode != BRW_OPCODE_WHILE))) { - fprintf(stderr, ".f0.%d", inst->flag_subreg); + fprintf(file, ".f0.%d", inst->flag_subreg); } } - fprintf(stderr, " "); + fprintf(file, " "); switch (inst->dst.file) { case GRF: - fprintf(stderr, "vgrf%d", inst->dst.reg); + fprintf(file, "vgrf%d", inst->dst.reg); if (virtual_grf_sizes[inst->dst.reg] != 1 || inst->dst.subreg_offset) - fprintf(stderr, "+%d.%d", + fprintf(file, "+%d.%d", inst->dst.reg_offset, inst->dst.subreg_offset); break; case MRF: - fprintf(stderr, "m%d", inst->dst.reg); + fprintf(file, "m%d", inst->dst.reg); break; case BAD_FILE: - fprintf(stderr, "(null)"); + fprintf(file, "(null)"); break; case UNIFORM: - fprintf(stderr, "***u%d***", inst->dst.reg + inst->dst.reg_offset); + fprintf(file, "***u%d***", inst->dst.reg + inst->dst.reg_offset); break; case HW_REG: if (inst->dst.fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) { switch (inst->dst.fixed_hw_reg.nr) { case BRW_ARF_NULL: - fprintf(stderr, "null"); + fprintf(file, "null"); break; case BRW_ARF_ADDRESS: - fprintf(stderr, "a0.%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "a0.%d", inst->dst.fixed_hw_reg.subnr); break; case BRW_ARF_ACCUMULATOR: - fprintf(stderr, "acc%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "acc%d", inst->dst.fixed_hw_reg.subnr); break; case BRW_ARF_FLAG: - fprintf(stderr, "f%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, + fprintf(file, "f%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, inst->dst.fixed_hw_reg.subnr); break; default: - fprintf(stderr, "arf%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, + fprintf(file, "arf%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, inst->dst.fixed_hw_reg.subnr); break; } } else { - fprintf(stderr, "hw_reg%d", inst->dst.fixed_hw_reg.nr); + fprintf(file, "hw_reg%d", inst->dst.fixed_hw_reg.nr); } if (inst->dst.fixed_hw_reg.subnr) - fprintf(stderr, "+%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "+%d", inst->dst.fixed_hw_reg.subnr); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } - fprintf(stderr, ":%s, ", brw_reg_type_letters(inst->dst.type)); + fprintf(file, ":%s, ", brw_reg_type_letters(inst->dst.type)); for (int i = 0; i < 3 && inst->src[i].file != BAD_FILE; i++) { if (inst->src[i].negate) - fprintf(stderr, "-"); + fprintf(file, "-"); if (inst->src[i].abs) - fprintf(stderr, "|"); + fprintf(file, "|"); switch (inst->src[i].file) { case GRF: - fprintf(stderr, "vgrf%d", inst->src[i].reg); + fprintf(file, "vgrf%d", inst->src[i].reg); if (virtual_grf_sizes[inst->src[i].reg] != 1 || inst->src[i].subreg_offset) - fprintf(stderr, "+%d.%d", inst->src[i].reg_offset, + fprintf(file, "+%d.%d", inst->src[i].reg_offset, inst->src[i].subreg_offset); break; case MRF: - fprintf(stderr, "***m%d***", inst->src[i].reg); + fprintf(file, "***m%d***", inst->src[i].reg); break; case UNIFORM: - fprintf(stderr, "u%d", inst->src[i].reg + inst->src[i].reg_offset); + fprintf(file, "u%d", inst->src[i].reg + inst->src[i].reg_offset); if (inst->src[i].reladdr) { - fprintf(stderr, "+reladdr"); + fprintf(file, "+reladdr"); } else if (virtual_grf_sizes[inst->src[i].reg] != 1 || inst->src[i].subreg_offset) { - fprintf(stderr, "+%d.%d", inst->src[i].reg_offset, + fprintf(file, "+%d.%d", inst->src[i].reg_offset, inst->src[i].subreg_offset); } break; case BAD_FILE: - fprintf(stderr, "(null)"); + fprintf(file, "(null)"); break; case IMM: switch (inst->src[i].type) { case BRW_REGISTER_TYPE_F: - fprintf(stderr, "%ff", inst->src[i].imm.f); + fprintf(file, "%ff", inst->src[i].imm.f); break; case BRW_REGISTER_TYPE_D: - fprintf(stderr, "%dd", inst->src[i].imm.i); + fprintf(file, "%dd", inst->src[i].imm.i); break; case BRW_REGISTER_TYPE_UD: - fprintf(stderr, "%uu", inst->src[i].imm.u); + fprintf(file, "%uu", inst->src[i].imm.u); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } break; case HW_REG: if (inst->src[i].fixed_hw_reg.negate) - fprintf(stderr, "-"); + fprintf(file, "-"); if (inst->src[i].fixed_hw_reg.abs) - fprintf(stderr, "|"); + fprintf(file, "|"); if (inst->src[i].fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) { switch (inst->src[i].fixed_hw_reg.nr) { case BRW_ARF_NULL: - fprintf(stderr, "null"); + fprintf(file, "null"); break; case BRW_ARF_ADDRESS: - fprintf(stderr, "a0.%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "a0.%d", inst->src[i].fixed_hw_reg.subnr); break; case BRW_ARF_ACCUMULATOR: - fprintf(stderr, "acc%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "acc%d", inst->src[i].fixed_hw_reg.subnr); break; case BRW_ARF_FLAG: - fprintf(stderr, "f%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, + fprintf(file, "f%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, inst->src[i].fixed_hw_reg.subnr); break; default: - fprintf(stderr, "arf%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, + fprintf(file, "arf%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, inst->src[i].fixed_hw_reg.subnr); break; } } else { - fprintf(stderr, "hw_reg%d", inst->src[i].fixed_hw_reg.nr); + fprintf(file, "hw_reg%d", inst->src[i].fixed_hw_reg.nr); } if (inst->src[i].fixed_hw_reg.subnr) - fprintf(stderr, "+%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "+%d", inst->src[i].fixed_hw_reg.subnr); if (inst->src[i].fixed_hw_reg.abs) - fprintf(stderr, "|"); + fprintf(file, "|"); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } if (inst->src[i].abs) - fprintf(stderr, "|"); + fprintf(file, "|"); if (inst->src[i].file != IMM) { - fprintf(stderr, ":%s", brw_reg_type_letters(inst->src[i].type)); + fprintf(file, ":%s", brw_reg_type_letters(inst->src[i].type)); } if (i < 2 && inst->src[i + 1].file != BAD_FILE) - fprintf(stderr, ", "); + fprintf(file, ", "); } - fprintf(stderr, " "); + fprintf(file, " "); if (inst->force_uncompressed) - fprintf(stderr, "1sthalf "); + fprintf(file, "1sthalf "); if (inst->force_sechalf) - fprintf(stderr, "2ndhalf "); + fprintf(file, "2ndhalf "); - fprintf(stderr, "\n"); + fprintf(file, "\n"); } /** diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 3d21ee5..c14d7c1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -489,7 +489,9 @@ public: int implied_mrf_writes(fs_inst *inst); virtual void dump_instructions(); + virtual void dump_instructions(const char *name); void dump_instruction(backend_instruction *inst); + void dump_instruction(backend_instruction *inst, FILE *file); void visit_atomic_counter_intrinsic(ir_call *ir); diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp index f2f158e..4190c38 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp @@ -498,7 +498,7 @@ fs_visitor::assign_regs(bool allow_spilling) if (reg == -1) { fail("no register to spill:\n"); - dump_instructions(); + dump_instructions(NULL); } else if (allow_spilling) { spill_reg(reg); } diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index c32e66c..d17489d 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -676,11 +676,27 @@ backend_instruction::has_side_effects() const void backend_visitor::dump_instructions() { + dump_instructions(NULL); +} + +void +backend_visitor::dump_instructions(const char *name) +{ + FILE *file = stderr; + if (name) { + file = fopen(name, "w"); + } + int ip = 0; foreach_list(node, &this->instructions) { backend_instruction *inst = (backend_instruction *)node; - fprintf(stderr, "%d: ", ip++); - dump_instruction(inst); + if (!name) + fprintf(stderr, "%d: ", ip++); + dump_instruction(inst, file); + } + + if (name) { + fclose(file); } } diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index 6bd7dc8..6b12795 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -96,7 +96,9 @@ public: exec_list instructions; virtual void dump_instruction(backend_instruction *inst) = 0; + virtual void dump_instruction(backend_instruction *inst, FILE *file) = 0; virtual void dump_instructions(); + virtual void dump_instructions(const char *name); void assign_common_binding_table_offsets(uint32_t next_binding_table_offset); diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp index 740d9ff..75b5690 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp @@ -1243,168 +1243,174 @@ vec4_visitor::split_virtual_grfs() void vec4_visitor::dump_instruction(backend_instruction *be_inst) { + dump_instruction(be_inst, stderr); +} + +void +vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file) +{ vec4_instruction *inst = (vec4_instruction *)be_inst; if (inst->predicate) { - fprintf(stderr, "(%cf0) ", + fprintf(file, "(%cf0) ", inst->predicate_inverse ? '-' : '+'); } - fprintf(stderr, "%s", brw_instruction_name(inst->opcode)); + fprintf(file, "%s", brw_instruction_name(inst->opcode)); if (inst->conditional_mod) { - fprintf(stderr, "%s", conditional_modifier[inst->conditional_mod]); + fprintf(file, "%s", conditional_modifier[inst->conditional_mod]); } - fprintf(stderr, " "); + fprintf(file, " "); switch (inst->dst.file) { case GRF: - fprintf(stderr, "vgrf%d.%d", inst->dst.reg, inst->dst.reg_offset); + fprintf(file, "vgrf%d.%d", inst->dst.reg, inst->dst.reg_offset); break; case MRF: - fprintf(stderr, "m%d", inst->dst.reg); + fprintf(file, "m%d", inst->dst.reg); break; case HW_REG: if (inst->dst.fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) { switch (inst->dst.fixed_hw_reg.nr) { case BRW_ARF_NULL: - fprintf(stderr, "null"); + fprintf(file, "null"); break; case BRW_ARF_ADDRESS: - fprintf(stderr, "a0.%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "a0.%d", inst->dst.fixed_hw_reg.subnr); break; case BRW_ARF_ACCUMULATOR: - fprintf(stderr, "acc%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "acc%d", inst->dst.fixed_hw_reg.subnr); break; case BRW_ARF_FLAG: - fprintf(stderr, "f%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, + fprintf(file, "f%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, inst->dst.fixed_hw_reg.subnr); break; default: - fprintf(stderr, "arf%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, + fprintf(file, "arf%d.%d", inst->dst.fixed_hw_reg.nr & 0xf, inst->dst.fixed_hw_reg.subnr); break; } } else { - fprintf(stderr, "hw_reg%d", inst->dst.fixed_hw_reg.nr); + fprintf(file, "hw_reg%d", inst->dst.fixed_hw_reg.nr); } if (inst->dst.fixed_hw_reg.subnr) - fprintf(stderr, "+%d", inst->dst.fixed_hw_reg.subnr); + fprintf(file, "+%d", inst->dst.fixed_hw_reg.subnr); break; case BAD_FILE: - fprintf(stderr, "(null)"); + fprintf(file, "(null)"); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } if (inst->dst.writemask != WRITEMASK_XYZW) { - fprintf(stderr, "."); + fprintf(file, "."); if (inst->dst.writemask & 1) - fprintf(stderr, "x"); + fprintf(file, "x"); if (inst->dst.writemask & 2) - fprintf(stderr, "y"); + fprintf(file, "y"); if (inst->dst.writemask & 4) - fprintf(stderr, "z"); + fprintf(file, "z"); if (inst->dst.writemask & 8) - fprintf(stderr, "w"); + fprintf(file, "w"); } - fprintf(stderr, ":%s, ", brw_reg_type_letters(inst->dst.type)); + fprintf(file, ":%s, ", brw_reg_type_letters(inst->dst.type)); for (int i = 0; i < 3 && inst->src[i].file != BAD_FILE; i++) { if (inst->src[i].negate) - fprintf(stderr, "-"); + fprintf(file, "-"); if (inst->src[i].abs) - fprintf(stderr, "|"); + fprintf(file, "|"); switch (inst->src[i].file) { case GRF: - fprintf(stderr, "vgrf%d", inst->src[i].reg); + fprintf(file, "vgrf%d", inst->src[i].reg); break; case ATTR: - fprintf(stderr, "attr%d", inst->src[i].reg); + fprintf(file, "attr%d", inst->src[i].reg); break; case UNIFORM: - fprintf(stderr, "u%d", inst->src[i].reg); + fprintf(file, "u%d", inst->src[i].reg); break; case IMM: switch (inst->src[i].type) { case BRW_REGISTER_TYPE_F: - fprintf(stderr, "%fF", inst->src[i].imm.f); + fprintf(file, "%fF", inst->src[i].imm.f); break; case BRW_REGISTER_TYPE_D: - fprintf(stderr, "%dD", inst->src[i].imm.i); + fprintf(file, "%dD", inst->src[i].imm.i); break; case BRW_REGISTER_TYPE_UD: - fprintf(stderr, "%uU", inst->src[i].imm.u); + fprintf(file, "%uU", inst->src[i].imm.u); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } break; case HW_REG: if (inst->src[i].fixed_hw_reg.negate) - fprintf(stderr, "-"); + fprintf(file, "-"); if (inst->src[i].fixed_hw_reg.abs) - fprintf(stderr, "|"); + fprintf(file, "|"); if (inst->src[i].fixed_hw_reg.file == BRW_ARCHITECTURE_REGISTER_FILE) { switch (inst->src[i].fixed_hw_reg.nr) { case BRW_ARF_NULL: - fprintf(stderr, "null"); + fprintf(file, "null"); break; case BRW_ARF_ADDRESS: - fprintf(stderr, "a0.%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "a0.%d", inst->src[i].fixed_hw_reg.subnr); break; case BRW_ARF_ACCUMULATOR: - fprintf(stderr, "acc%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "acc%d", inst->src[i].fixed_hw_reg.subnr); break; case BRW_ARF_FLAG: - fprintf(stderr, "f%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, + fprintf(file, "f%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, inst->src[i].fixed_hw_reg.subnr); break; default: - fprintf(stderr, "arf%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, + fprintf(file, "arf%d.%d", inst->src[i].fixed_hw_reg.nr & 0xf, inst->src[i].fixed_hw_reg.subnr); break; } } else { - fprintf(stderr, "hw_reg%d", inst->src[i].fixed_hw_reg.nr); + fprintf(file, "hw_reg%d", inst->src[i].fixed_hw_reg.nr); } if (inst->src[i].fixed_hw_reg.subnr) - fprintf(stderr, "+%d", inst->src[i].fixed_hw_reg.subnr); + fprintf(file, "+%d", inst->src[i].fixed_hw_reg.subnr); if (inst->src[i].fixed_hw_reg.abs) - fprintf(stderr, "|"); + fprintf(file, "|"); break; case BAD_FILE: - fprintf(stderr, "(null)"); + fprintf(file, "(null)"); break; default: - fprintf(stderr, "???"); + fprintf(file, "???"); break; } if (virtual_grf_sizes[inst->src[i].reg] != 1) - fprintf(stderr, ".%d", inst->src[i].reg_offset); + fprintf(file, ".%d", inst->src[i].reg_offset); if (inst->src[i].file != IMM) { static const char *chans[4] = {"x", "y", "z", "w"}; - fprintf(stderr, "."); + fprintf(file, "."); for (int c = 0; c < 4; c++) { - fprintf(stderr, "%s", chans[BRW_GET_SWZ(inst->src[i].swizzle, c)]); + fprintf(file, "%s", chans[BRW_GET_SWZ(inst->src[i].swizzle, c)]); } } if (inst->src[i].abs) - fprintf(stderr, "|"); + fprintf(file, "|"); if (inst->src[i].file != IMM) { - fprintf(stderr, ":%s", brw_reg_type_letters(inst->src[i].type)); + fprintf(file, ":%s", brw_reg_type_letters(inst->src[i].type)); } if (i < 2 && inst->src[i + 1].file != BAD_FILE) - fprintf(stderr, ", "); + fprintf(file, ", "); } - fprintf(stderr, "\n"); + fprintf(file, "\n"); } diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h index 159a5bd..43c3f64 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4.h +++ b/src/mesa/drivers/dri/i965/brw_vec4.h @@ -597,6 +597,7 @@ public: bool process_move_condition(ir_rvalue *ir); void dump_instruction(backend_instruction *inst); + void dump_instruction(backend_instruction *inst, FILE *file); void visit_atomic_counter_intrinsic(ir_call *ir); -- 1.8.3.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev