From: Alyssa Rosenzweig Date: Sun, 1 May 2022 19:53:35 +0000 (-0400) Subject: agx: Introduce worklist infrastructure X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=590df764d620cdbff9451502e006919e424193e9;p=platform%2Fupstream%2Fmesa.git agx: Introduce worklist infrastructure Using the common NIR stuff. Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 779f39e..9a9d6ae 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1728,11 +1728,9 @@ agx_compile_shader_nir(nir_shader *nir, for (unsigned i = 0; i < 8; ++i) agx_trap(&_b); - unsigned block_source_count = 0; - - /* Name blocks now that we're done emitting so the order is consistent */ + /* Index blocks now that we're done emitting so the order is consistent */ agx_foreach_block(ctx, block) - block->name = block_source_count++; + block->index = ctx->num_blocks++; if (agx_debug & AGX_DBG_SHADERS && !skip_internal) agx_print_shader(ctx, stdout); diff --git a/src/asahi/compiler/agx_compiler.h b/src/asahi/compiler/agx_compiler.h index 4b1fe4b..6052535 100644 --- a/src/asahi/compiler/agx_compiler.h +++ b/src/asahi/compiler/agx_compiler.h @@ -29,6 +29,7 @@ #include "util/u_math.h" #include "util/half_float.h" #include "util/u_dynarray.h" +#include "util/u_worklist.h" #include "agx_compile.h" #include "agx_opcodes.h" #include "agx_minifloat.h" @@ -347,7 +348,7 @@ typedef struct agx_block { struct list_head instructions; /* Index of the block in source order */ - unsigned name; + unsigned index; /* Control flow graph */ struct agx_block *successors[2]; @@ -388,6 +389,9 @@ typedef struct { /* Place to start pushing new values */ unsigned push_base; + /* Maximum block index */ + unsigned num_blocks; + /* For creating temporaries */ unsigned alloc; @@ -591,6 +595,14 @@ agx_exit_block(agx_context *ctx) return last; } +#define agx_worklist_init(ctx, w) u_worklist_init(w, ctx->num_blocks, ctx) +#define agx_worklist_push_head(w, block) u_worklist_push_head(w, block, index) +#define agx_worklist_push_tail(w, block) u_worklist_push_tail(w, block, index) +#define agx_worklist_peek_head(w) u_worklist_peek_head(w, agx_block, index) +#define agx_worklist_pop_head(w) u_worklist_pop_head( w, agx_block, index) +#define agx_worklist_peek_tail(w) u_worklist_peek_tail(w, agx_block, index) +#define agx_worklist_pop_tail(w) u_worklist_pop_tail( w, agx_block, index) + /* Like in NIR, for use with the builder */ enum agx_cursor_option { diff --git a/src/asahi/compiler/agx_print.c b/src/asahi/compiler/agx_print.c index 6b53cc0..2191b6f 100644 --- a/src/asahi/compiler/agx_print.c +++ b/src/asahi/compiler/agx_print.c @@ -194,7 +194,7 @@ agx_print_instr(agx_instr *I, FILE *fp) void agx_print_block(agx_block *block, FILE *fp) { - fprintf(fp, "block%u {\n", block->name); + fprintf(fp, "block%u {\n", block->index); agx_foreach_instr_in_block(block, ins) agx_print_instr(ins, fp); @@ -205,14 +205,14 @@ agx_print_block(agx_block *block, FILE *fp) fprintf(fp, " -> "); agx_foreach_successor(block, succ) - fprintf(fp, "block%u ", succ->name); + fprintf(fp, "block%u ", succ->index); } if (block->predecessors.size) { fprintf(fp, " from"); agx_foreach_predecessor(block, pred) - fprintf(fp, " block%u", (*pred)->name); + fprintf(fp, " block%u", (*pred)->index); } fprintf(fp, "\n\n");