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 <ian.d.romanick@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4093>
This commit is contained in:
@@ -154,8 +154,10 @@ bblock_t::combine_with(bblock_t *that)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
bblock_t::dump(backend_shader *s) const
|
bblock_t::dump() const
|
||||||
{
|
{
|
||||||
|
const backend_shader *s = this->cfg->s;
|
||||||
|
|
||||||
int ip = this->start_ip;
|
int ip = this->start_ip;
|
||||||
foreach_inst_in_block(backend_instruction, inst, this) {
|
foreach_inst_in_block(backend_instruction, inst, this) {
|
||||||
fprintf(stderr, "%5d: ", ip);
|
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);
|
mem_ctx = ralloc_context(NULL);
|
||||||
block_list.make_empty();
|
block_list.make_empty();
|
||||||
@@ -499,7 +502,7 @@ cfg_t::make_block_array()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cfg_t::dump(backend_shader *s)
|
cfg_t::dump()
|
||||||
{
|
{
|
||||||
const idom_tree *idom = (s ? &s->idom_analysis.require() : NULL);
|
const idom_tree *idom = (s ? &s->idom_analysis.require() : NULL);
|
||||||
|
|
||||||
@@ -517,7 +520,7 @@ cfg_t::dump(backend_shader *s)
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
if (s != NULL)
|
if (s != NULL)
|
||||||
block->dump(s);
|
block->dump();
|
||||||
fprintf(stderr, "END B%d", block->num);
|
fprintf(stderr, "END B%d", block->num);
|
||||||
foreach_list_typed(bblock_link, link, link, &block->children) {
|
foreach_list_typed(bblock_link, link, link, &block->children) {
|
||||||
fprintf(stderr, " %c>B%d",
|
fprintf(stderr, " %c>B%d",
|
||||||
|
@@ -90,7 +90,7 @@ struct bblock_t {
|
|||||||
enum bblock_link_kind kind) const;
|
enum bblock_link_kind kind) const;
|
||||||
bool can_combine_with(const bblock_t *that) const;
|
bool can_combine_with(const bblock_t *that) const;
|
||||||
void combine_with(bblock_t *that);
|
void combine_with(bblock_t *that);
|
||||||
void dump(backend_shader *s) const;
|
void dump() const;
|
||||||
|
|
||||||
backend_instruction *start();
|
backend_instruction *start();
|
||||||
const backend_instruction *start() const;
|
const backend_instruction *start() const;
|
||||||
@@ -305,7 +305,7 @@ struct cfg_t {
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
DECLARE_RALLOC_CXX_OPERATORS(cfg_t)
|
DECLARE_RALLOC_CXX_OPERATORS(cfg_t)
|
||||||
|
|
||||||
cfg_t(exec_list *instructions);
|
cfg_t(const backend_shader *s, exec_list *instructions);
|
||||||
~cfg_t();
|
~cfg_t();
|
||||||
|
|
||||||
void remove_block(bblock_t *block);
|
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 set_next_block(bblock_t **cur, bblock_t *block, int ip);
|
||||||
void make_block_array();
|
void make_block_array();
|
||||||
|
|
||||||
void dump(backend_shader *s);
|
void dump();
|
||||||
void dump_cfg();
|
void dump_cfg();
|
||||||
#endif
|
#endif
|
||||||
|
const struct backend_shader *s;
|
||||||
void *mem_ctx;
|
void *mem_ctx;
|
||||||
|
|
||||||
/** Ordered list (by ip) of basic blocks */
|
/** Ordered list (by ip) of basic blocks */
|
||||||
|
@@ -1242,7 +1242,7 @@ backend_shader::calculate_cfg()
|
|||||||
{
|
{
|
||||||
if (this->cfg)
|
if (this->cfg)
|
||||||
return;
|
return;
|
||||||
cfg = new(mem_ctx) cfg_t(&this->instructions);
|
cfg = new(mem_ctx) cfg_t(this, &this->instructions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -94,14 +94,14 @@ cmod_propagation(fs_visitor *v)
|
|||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "= Before =\n");
|
fprintf(stderr, "= Before =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = v->opt_cmod_propagation();
|
bool ret = v->opt_cmod_propagation();
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "\n= After =\n");
|
fprintf(stderr, "\n= After =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -84,14 +84,14 @@ copy_propagation(fs_visitor *v)
|
|||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "= Before =\n");
|
fprintf(stderr, "= Before =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = v->opt_copy_propagation();
|
bool ret = v->opt_copy_propagation();
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "\n= After =\n");
|
fprintf(stderr, "\n= After =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -84,14 +84,14 @@ saturate_propagation(fs_visitor *v)
|
|||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "= Before =\n");
|
fprintf(stderr, "= Before =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ret = v->opt_saturate_propagation();
|
bool ret = v->opt_saturate_propagation();
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "\n= After =\n");
|
fprintf(stderr, "\n= After =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -73,14 +73,14 @@ lower_scoreboard(fs_visitor *v)
|
|||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "= Before =\n");
|
fprintf(stderr, "= Before =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
|
|
||||||
v->lower_scoreboard();
|
v->lower_scoreboard();
|
||||||
|
|
||||||
if (print) {
|
if (print) {
|
||||||
fprintf(stderr, "\n= After =\n");
|
fprintf(stderr, "\n= After =\n");
|
||||||
v->cfg->dump(v);
|
v->cfg->dump();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user