agx: Introduce worklist infrastructure

Using the common NIR stuff.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
This commit is contained in:
Alyssa Rosenzweig 2022-05-01 15:53:35 -04:00
parent e414a8c16f
commit 590df764d6
3 changed files with 18 additions and 8 deletions

View File

@ -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);

View File

@ -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 {

View File

@ -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");