From f3e9a5c719b091f511c8352cd1d284cc5e73277f Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Mon, 19 Feb 2024 22:37:47 -0800 Subject: [PATCH] intel/brw: Move dump_* functions into fs_visitor Make them non-virtual and update the parameter to use fs_inst. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw_cfg.cpp | 4 ++-- src/intel/compiler/brw_fs.cpp | 23 +++++++++++++++---- src/intel/compiler/brw_fs.h | 11 +++++++-- src/intel/compiler/brw_shader.cpp | 37 ------------------------------- src/intel/compiler/brw_shader.h | 9 -------- 5 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/intel/compiler/brw_cfg.cpp b/src/intel/compiler/brw_cfg.cpp index e66b6e56d37..7657609de47 100644 --- a/src/intel/compiler/brw_cfg.cpp +++ b/src/intel/compiler/brw_cfg.cpp @@ -157,10 +157,10 @@ bblock_t::combine_with(bblock_t *that) void bblock_t::dump(FILE *file) const { - const backend_shader *s = this->cfg->s; + const fs_visitor *s = static_cast(this->cfg->s); int ip = this->start_ip; - foreach_inst_in_block(backend_instruction, inst, this) { + foreach_inst_in_block(fs_inst, inst, this) { fprintf(file, "%5d: ", ip); s->dump_instruction(inst, file); ip++; diff --git a/src/intel/compiler/brw_fs.cpp b/src/intel/compiler/brw_fs.cpp index 097600f3c5a..c3d7edb6e2f 100644 --- a/src/intel/compiler/brw_fs.cpp +++ b/src/intel/compiler/brw_fs.cpp @@ -2144,7 +2144,7 @@ fs_visitor::dump_instructions_to_file(FILE *file) const const register_pressure &rp = regpressure_analysis.require(); unsigned ip = 0, max_pressure = 0; unsigned cf_count = 0; - foreach_block_and_inst(block, backend_instruction, inst, cfg) { + foreach_block_and_inst(block, fs_inst, inst, cfg) { if (inst->is_control_flow_end()) cf_count -= 1; @@ -2161,7 +2161,7 @@ fs_visitor::dump_instructions_to_file(FILE *file) const fprintf(file, "Maximum %3d registers live at once.\n", max_pressure); } else { int ip = 0; - foreach_in_list(backend_instruction, inst, &instructions) { + foreach_in_list(fs_inst, inst, &instructions) { fprintf(file, "%4d: ", ip++); dump_instruction(inst, file); } @@ -2169,10 +2169,25 @@ fs_visitor::dump_instructions_to_file(FILE *file) const } void -fs_visitor::dump_instruction_to_file(const backend_instruction *be_inst, FILE *file) const +fs_visitor::dump_instructions(const char *name) const { - const fs_inst *inst = (const fs_inst *)be_inst; + FILE *file = stderr; + if (name && __normal_user()) { + file = fopen(name, "w"); + if (!file) + file = stderr; + } + dump_instructions_to_file(file); + + if (file != stderr) { + fclose(file); + } +} + +void +fs_visitor::dump_instruction_to_file(const fs_inst *inst, FILE *file) const +{ if (inst->predicate) { fprintf(file, "(%cf%d.%d) ", inst->predicate_inverse ? '-' : '+', diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h index 295faee99a5..3ea5f3f3a73 100644 --- a/src/intel/compiler/brw_fs.h +++ b/src/intel/compiler/brw_fs.h @@ -288,8 +288,15 @@ public: fs_reg per_primitive_reg(const brw::fs_builder &bld, int location, unsigned comp); - virtual void dump_instruction_to_file(const backend_instruction *inst, FILE *file) const; - virtual void dump_instructions_to_file(FILE *file) const; + void dump_instruction_to_file(const fs_inst *inst, FILE *file) const; + void dump_instructions_to_file(FILE *file) const; + + /* Convenience functions based on the above. */ + void dump_instruction(const fs_inst *inst, FILE *file = stderr) const { + dump_instruction_to_file(inst, file); + } + void dump_instructions(const char *name = nullptr) const; + void calculate_cfg(); const brw_base_prog_key *const key; diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index eed30ea362c..547cb10d7ea 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -1108,43 +1108,6 @@ backend_instruction::remove(bblock_t *block, bool defer_later_block_ip_updates) exec_node::remove(); } -void -backend_shader::dump_instructions(const char *name) const -{ - FILE *file = stderr; - if (name && __normal_user()) { - file = fopen(name, "w"); - if (!file) - file = stderr; - } - - dump_instructions_to_file(file); - - if (file != stderr) { - fclose(file); - } -} - -void -backend_shader::dump_instructions_to_file(FILE *file) const -{ - if (cfg) { - int ip = 0; - foreach_block_and_inst(block, backend_instruction, inst, cfg) { - if (!INTEL_DEBUG(DEBUG_OPTIMIZER)) - fprintf(file, "%4d: ", ip++); - dump_instruction(inst, file); - } - } else { - int ip = 0; - foreach_in_list(backend_instruction, inst, &instructions) { - if (!INTEL_DEBUG(DEBUG_OPTIMIZER)) - fprintf(file, "%4d: ", ip++); - dump_instruction(inst, file); - } - } -} - void backend_shader::invalidate_analysis(brw::analysis_dependency_class c) { diff --git a/src/intel/compiler/brw_shader.h b/src/intel/compiler/brw_shader.h index caaee2cd7c6..9676c4a7f99 100644 --- a/src/intel/compiler/brw_shader.h +++ b/src/intel/compiler/brw_shader.h @@ -78,15 +78,6 @@ public: brw::simple_allocator alloc; - virtual void dump_instruction_to_file(const backend_instruction *inst, FILE *file) const = 0; - virtual void dump_instructions_to_file(FILE *file) const; - - /* Convenience functions based on the above. */ - void dump_instruction(const backend_instruction *inst, FILE *file = stderr) const { - dump_instruction_to_file(inst, file); - } - void dump_instructions(const char *name = nullptr) const; - virtual void invalidate_analysis(brw::analysis_dependency_class c); };