intel/compiler: Refactor dump_instruction(s)
Delete unnecessary virtual functions, we need just two. Refactor code so the 'default behavior' logic (stderr and/or creating file) is not duplicated. Rename the virtuals so overrides don't hide the common convenience functions. Finally, provide a variant of dump_instructions() with a `FILE *` parameter. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23457>
This commit is contained in:
@@ -5693,21 +5693,8 @@ fs_visitor::lower_find_live_channel()
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::dump_instructions() const
|
||||
fs_visitor::dump_instructions_to_file(FILE *file) const
|
||||
{
|
||||
dump_instructions(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::dump_instructions(const char *name) const
|
||||
{
|
||||
FILE *file = stderr;
|
||||
if (name && geteuid() != 0) {
|
||||
file = fopen(name, "w");
|
||||
if (!file)
|
||||
file = stderr;
|
||||
}
|
||||
|
||||
if (cfg) {
|
||||
const register_pressure &rp = regpressure_analysis.require();
|
||||
unsigned ip = 0, max_pressure = 0;
|
||||
@@ -5725,20 +5712,10 @@ fs_visitor::dump_instructions(const char *name) const
|
||||
dump_instruction(inst, file);
|
||||
}
|
||||
}
|
||||
|
||||
if (file != stderr) {
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::dump_instruction(const backend_instruction *be_inst) const
|
||||
{
|
||||
dump_instruction(be_inst, stderr);
|
||||
}
|
||||
|
||||
void
|
||||
fs_visitor::dump_instruction(const backend_instruction *be_inst, FILE *file) const
|
||||
fs_visitor::dump_instruction_to_file(const backend_instruction *be_inst, FILE *file) const
|
||||
{
|
||||
const fs_inst *inst = (const fs_inst *)be_inst;
|
||||
|
||||
|
@@ -439,10 +439,8 @@ public:
|
||||
fs_reg interp_reg(int location, int channel);
|
||||
fs_reg per_primitive_reg(int location);
|
||||
|
||||
virtual void dump_instructions() const;
|
||||
virtual void dump_instructions(const char *name) const;
|
||||
void dump_instruction(const backend_instruction *inst) const;
|
||||
void dump_instruction(const backend_instruction *inst, FILE *file) const;
|
||||
virtual void dump_instruction_to_file(const backend_instruction *inst, FILE *file) const;
|
||||
virtual void dump_instructions_to_file(FILE *file) const;
|
||||
|
||||
const brw_base_prog_key *const key;
|
||||
const struct brw_sampler_prog_key_data *key_tex;
|
||||
|
@@ -1235,12 +1235,6 @@ backend_instruction::remove(bblock_t *block, bool defer_later_block_ip_updates)
|
||||
exec_node::remove();
|
||||
}
|
||||
|
||||
void
|
||||
backend_shader::dump_instructions() const
|
||||
{
|
||||
dump_instructions(NULL);
|
||||
}
|
||||
|
||||
void
|
||||
backend_shader::dump_instructions(const char *name) const
|
||||
{
|
||||
@@ -1251,6 +1245,16 @@ backend_shader::dump_instructions(const char *name) const
|
||||
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) {
|
||||
@@ -1266,10 +1270,6 @@ backend_shader::dump_instructions(const char *name) const
|
||||
dump_instruction(inst, file);
|
||||
}
|
||||
}
|
||||
|
||||
if (file != stderr) {
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -82,10 +82,14 @@ public:
|
||||
|
||||
brw::simple_allocator alloc;
|
||||
|
||||
virtual void dump_instruction(const backend_instruction *inst) const = 0;
|
||||
virtual void dump_instruction(const backend_instruction *inst, FILE *file) const = 0;
|
||||
virtual void dump_instructions() const;
|
||||
virtual void dump_instructions(const char *name) const;
|
||||
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;
|
||||
|
||||
void calculate_cfg();
|
||||
|
||||
|
@@ -1309,13 +1309,7 @@ vec4_visitor::split_virtual_grfs()
|
||||
}
|
||||
|
||||
void
|
||||
vec4_visitor::dump_instruction(const backend_instruction *be_inst) const
|
||||
{
|
||||
dump_instruction(be_inst, stderr);
|
||||
}
|
||||
|
||||
void
|
||||
vec4_visitor::dump_instruction(const backend_instruction *be_inst, FILE *file) const
|
||||
vec4_visitor::dump_instruction_to_file(const backend_instruction *be_inst, FILE *file) const
|
||||
{
|
||||
const vec4_instruction *inst = (const vec4_instruction *)be_inst;
|
||||
|
||||
|
@@ -282,8 +282,7 @@ public:
|
||||
|
||||
src_reg get_timestamp();
|
||||
|
||||
void dump_instruction(const backend_instruction *inst) const;
|
||||
void dump_instruction(const backend_instruction *inst, FILE *file) const;
|
||||
virtual void dump_instruction_to_file(const backend_instruction *inst, FILE *file) const;
|
||||
|
||||
bool optimize_predicate(nir_alu_instr *instr, enum brw_predicate *predicate);
|
||||
|
||||
|
Reference in New Issue
Block a user