Module: Mesa Branch: main Commit: 47c5656f0eac5e12443cd1e73ef3f6a9ab207186 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=47c5656f0eac5e12443cd1e73ef3f6a9ab207186
Author: Caio Oliveira <caio.olive...@intel.com> Date: Fri Nov 3 22:40:45 2023 -0700 intel/compiler: Allow dumping CFG to a specific FILE* Add optional argument for both cfg and block dump() function to pass a FILE*. Default behavior remains dumping to stderr. v2 (idr): Don't add the new test framework in this commit. Reviewed-by: Ian Romanick <ian.d.roman...@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25216> --- src/intel/compiler/brw_cfg.cpp | 24 ++++++++++++------------ src/intel/compiler/brw_cfg.h | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/intel/compiler/brw_cfg.cpp b/src/intel/compiler/brw_cfg.cpp index c6a384cafb7..138111dcc4d 100644 --- a/src/intel/compiler/brw_cfg.cpp +++ b/src/intel/compiler/brw_cfg.cpp @@ -154,14 +154,14 @@ bblock_t::combine_with(bblock_t *that) } void -bblock_t::dump() const +bblock_t::dump(FILE *file) 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); - s->dump_instruction(inst); + fprintf(file, "%5d: ", ip); + s->dump_instruction(inst, file); ip++; } } @@ -578,32 +578,32 @@ cfg_t::make_block_array() } void -cfg_t::dump() +cfg_t::dump(FILE *file) { const idom_tree *idom = (s ? &s->idom_analysis.require() : NULL); foreach_block (block, this) { if (idom && idom->parent(block)) - fprintf(stderr, "START B%d IDOM(B%d)", block->num, + fprintf(file, "START B%d IDOM(B%d)", block->num, idom->parent(block)->num); else - fprintf(stderr, "START B%d IDOM(none)", block->num); + fprintf(file, "START B%d IDOM(none)", block->num); foreach_list_typed(bblock_link, link, link, &block->parents) { - fprintf(stderr, " <%cB%d", + fprintf(file, " <%cB%d", link->kind == bblock_link_logical ? '-' : '~', link->block->num); } - fprintf(stderr, "\n"); + fprintf(file, "\n"); if (s != NULL) - block->dump(); - fprintf(stderr, "END B%d", block->num); + block->dump(file); + fprintf(file, "END B%d", block->num); foreach_list_typed(bblock_link, link, link, &block->children) { - fprintf(stderr, " %c>B%d", + fprintf(file, " %c>B%d", link->kind == bblock_link_logical ? '-' : '~', link->block->num); } - fprintf(stderr, "\n"); + fprintf(file, "\n"); } } diff --git a/src/intel/compiler/brw_cfg.h b/src/intel/compiler/brw_cfg.h index 20ed2d2988d..7784ab43784 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() const; + void dump(FILE *file = stderr) const; backend_instruction *start(); const backend_instruction *start() const; @@ -339,7 +339,7 @@ struct cfg_t { void set_next_block(bblock_t **cur, bblock_t *block, int ip); void make_block_array(); - void dump(); + void dump(FILE *file = stderr); void dump_cfg(); #ifdef NDEBUG