From e7d0460d585d6df7f2776e7c1c9b0109aed7dbe2 Mon Sep 17 00:00:00 2001 From: Matt Turner Date: Fri, 6 Mar 2020 13:34:13 -0800 Subject: [PATCH] intel/compiler: Pass backend_shader * to cfg_t() As you can see, not having a pointer to the backend_shader from within the class makes for some weird looking code. Reviewed-by: Ian Romanick Part-of: --- src/intel/compiler/brw_cfg.cpp | 11 +++++++---- src/intel/compiler/brw_cfg.h | 7 ++++--- src/intel/compiler/brw_shader.cpp | 2 +- src/intel/compiler/test_fs_cmod_propagation.cpp | 4 ++-- src/intel/compiler/test_fs_copy_propagation.cpp | 4 ++-- src/intel/compiler/test_fs_saturate_propagation.cpp | 4 ++-- src/intel/compiler/test_fs_scoreboard.cpp | 4 ++-- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/intel/compiler/brw_cfg.cpp b/src/intel/compiler/brw_cfg.cpp index e476ea36217..0fd411b1b94 100644 --- a/src/intel/compiler/brw_cfg.cpp +++ b/src/intel/compiler/brw_cfg.cpp @@ -154,8 +154,10 @@ bblock_t::combine_with(bblock_t *that) } void -bblock_t::dump(backend_shader *s) const +bblock_t::dump() const { + const backend_shader *s = this->cfg->s; + int ip = this->start_ip; foreach_inst_in_block(backend_instruction, inst, this) { fprintf(stderr, "%5d: ", ip); @@ -164,7 +166,8 @@ bblock_t::dump(backend_shader *s) const } } -cfg_t::cfg_t(exec_list *instructions) +cfg_t::cfg_t(const backend_shader *s, exec_list *instructions) : + s(s) { mem_ctx = ralloc_context(NULL); block_list.make_empty(); @@ -499,7 +502,7 @@ cfg_t::make_block_array() } void -cfg_t::dump(backend_shader *s) +cfg_t::dump() { const idom_tree *idom = (s ? &s->idom_analysis.require() : NULL); @@ -517,7 +520,7 @@ cfg_t::dump(backend_shader *s) } fprintf(stderr, "\n"); if (s != NULL) - block->dump(s); + block->dump(); fprintf(stderr, "END B%d", block->num); foreach_list_typed(bblock_link, link, link, &block->children) { fprintf(stderr, " %c>B%d", diff --git a/src/intel/compiler/brw_cfg.h b/src/intel/compiler/brw_cfg.h index 404a49c28b7..c747805817d 100644 --- a/src/intel/compiler/brw_cfg.h +++ b/src/intel/compiler/brw_cfg.h @@ -90,7 +90,7 @@ struct bblock_t { enum bblock_link_kind kind) const; bool can_combine_with(const bblock_t *that) const; void combine_with(bblock_t *that); - void dump(backend_shader *s) const; + void dump() const; backend_instruction *start(); const backend_instruction *start() const; @@ -305,7 +305,7 @@ struct cfg_t { #ifdef __cplusplus DECLARE_RALLOC_CXX_OPERATORS(cfg_t) - cfg_t(exec_list *instructions); + cfg_t(const backend_shader *s, exec_list *instructions); ~cfg_t(); void remove_block(bblock_t *block); @@ -314,9 +314,10 @@ struct cfg_t { void set_next_block(bblock_t **cur, bblock_t *block, int ip); void make_block_array(); - void dump(backend_shader *s); + void dump(); void dump_cfg(); #endif + const struct backend_shader *s; void *mem_ctx; /** Ordered list (by ip) of basic blocks */ diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index 475f9f04f8d..3ce680cec6f 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -1242,7 +1242,7 @@ backend_shader::calculate_cfg() { if (this->cfg) return; - cfg = new(mem_ctx) cfg_t(&this->instructions); + cfg = new(mem_ctx) cfg_t(this, &this->instructions); } void diff --git a/src/intel/compiler/test_fs_cmod_propagation.cpp b/src/intel/compiler/test_fs_cmod_propagation.cpp index d05c6897196..1fa2da2b619 100644 --- a/src/intel/compiler/test_fs_cmod_propagation.cpp +++ b/src/intel/compiler/test_fs_cmod_propagation.cpp @@ -94,14 +94,14 @@ cmod_propagation(fs_visitor *v) if (print) { fprintf(stderr, "= Before =\n"); - v->cfg->dump(v); + v->cfg->dump(); } bool ret = v->opt_cmod_propagation(); if (print) { fprintf(stderr, "\n= After =\n"); - v->cfg->dump(v); + v->cfg->dump(); } return ret; diff --git a/src/intel/compiler/test_fs_copy_propagation.cpp b/src/intel/compiler/test_fs_copy_propagation.cpp index fff85c2933b..db08a3482dc 100644 --- a/src/intel/compiler/test_fs_copy_propagation.cpp +++ b/src/intel/compiler/test_fs_copy_propagation.cpp @@ -84,14 +84,14 @@ copy_propagation(fs_visitor *v) if (print) { fprintf(stderr, "= Before =\n"); - v->cfg->dump(v); + v->cfg->dump(); } bool ret = v->opt_copy_propagation(); if (print) { fprintf(stderr, "\n= After =\n"); - v->cfg->dump(v); + v->cfg->dump(); } return ret; diff --git a/src/intel/compiler/test_fs_saturate_propagation.cpp b/src/intel/compiler/test_fs_saturate_propagation.cpp index e0f96abb10d..df8f5cc1eb6 100644 --- a/src/intel/compiler/test_fs_saturate_propagation.cpp +++ b/src/intel/compiler/test_fs_saturate_propagation.cpp @@ -84,14 +84,14 @@ saturate_propagation(fs_visitor *v) if (print) { fprintf(stderr, "= Before =\n"); - v->cfg->dump(v); + v->cfg->dump(); } bool ret = v->opt_saturate_propagation(); if (print) { fprintf(stderr, "\n= After =\n"); - v->cfg->dump(v); + v->cfg->dump(); } return ret; diff --git a/src/intel/compiler/test_fs_scoreboard.cpp b/src/intel/compiler/test_fs_scoreboard.cpp index 4c6acfaf201..71733c8d295 100644 --- a/src/intel/compiler/test_fs_scoreboard.cpp +++ b/src/intel/compiler/test_fs_scoreboard.cpp @@ -73,14 +73,14 @@ lower_scoreboard(fs_visitor *v) if (print) { fprintf(stderr, "= Before =\n"); - v->cfg->dump(v); + v->cfg->dump(); } v->lower_scoreboard(); if (print) { fprintf(stderr, "\n= After =\n"); - v->cfg->dump(v); + v->cfg->dump(); } } -- 2.30.2