agx: Use a dynarray for predecessors
This imposes a fixed ordering, allowing phi sources to be implicitly ordered. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16268>
This commit is contained in:
@@ -130,7 +130,7 @@ agx_block_add_successor(agx_block *block, agx_block *successor)
|
||||
}
|
||||
|
||||
block->successors[i] = successor;
|
||||
_mesa_set_add(successor->predecessors, block);
|
||||
util_dynarray_append(&successor->predecessors, agx_block *, block);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1053,8 +1053,7 @@ agx_create_block(agx_context *ctx)
|
||||
{
|
||||
agx_block *blk = rzalloc(ctx, agx_block);
|
||||
|
||||
blk->predecessors = _mesa_set_create(blk,
|
||||
_mesa_hash_pointer, _mesa_key_pointer_equal);
|
||||
util_dynarray_init(&blk->predecessors, blk);
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
@@ -351,7 +351,7 @@ typedef struct agx_block {
|
||||
|
||||
/* Control flow graph */
|
||||
struct agx_block *successors[2];
|
||||
struct set *predecessors;
|
||||
struct util_dynarray predecessors;
|
||||
bool unconditional_jumps;
|
||||
|
||||
/* Liveness analysis results */
|
||||
@@ -540,13 +540,7 @@ agx_vec_for_intr(agx_context *ctx, nir_intrinsic_instr *instr)
|
||||
_v++, v = *_v) \
|
||||
|
||||
#define agx_foreach_predecessor(blk, v) \
|
||||
struct set_entry *_entry_##v; \
|
||||
agx_block *v; \
|
||||
for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \
|
||||
v = (agx_block *) (_entry_##v ? _entry_##v->key : NULL); \
|
||||
_entry_##v != NULL; \
|
||||
_entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \
|
||||
v = (agx_block *) (_entry_##v ? _entry_##v->key : NULL))
|
||||
util_dynarray_foreach(&blk->predecessors, agx_block *, v)
|
||||
|
||||
#define agx_foreach_src(ins, v) \
|
||||
for (unsigned v = 0; v < ins->nr_srcs; ++v)
|
||||
|
@@ -123,10 +123,9 @@ agx_compute_liveness(agx_context *ctx)
|
||||
bool progress = liveness_block_update(blk, words);
|
||||
|
||||
/* If we made progress, we need to process the predecessors */
|
||||
|
||||
if (progress || !blk->pass_flags) {
|
||||
if (progress) {
|
||||
agx_foreach_predecessor(blk, pred)
|
||||
_mesa_set_add(work_list, pred);
|
||||
_mesa_set_add(work_list, *pred);
|
||||
}
|
||||
|
||||
/* Use pass flags to communicate that we've visited this block */
|
||||
|
@@ -208,11 +208,11 @@ agx_print_block(agx_block *block, FILE *fp)
|
||||
fprintf(fp, "block%u ", succ->name);
|
||||
}
|
||||
|
||||
if (block->predecessors->entries) {
|
||||
if (block->predecessors.size) {
|
||||
fprintf(fp, " from");
|
||||
|
||||
agx_foreach_predecessor(block, pred)
|
||||
fprintf(fp, " block%u", pred->name);
|
||||
fprintf(fp, " block%u", (*pred)->name);
|
||||
}
|
||||
|
||||
fprintf(fp, "\n\n");
|
||||
|
@@ -102,7 +102,7 @@ agx_ra_assign_local(agx_block *block, uint8_t *ssa_to_reg, uint8_t *ncomps, unsi
|
||||
|
||||
agx_foreach_predecessor(block, pred) {
|
||||
for (unsigned i = 0; i < BITSET_WORDS(AGX_NUM_REGS); ++i)
|
||||
used_regs[i] |= pred->regs_out[i];
|
||||
used_regs[i] |= (*pred)->regs_out[i];
|
||||
}
|
||||
|
||||
BITSET_SET(used_regs, 0); // control flow writes r0l
|
||||
|
@@ -40,10 +40,7 @@ agx_test_builder(void *memctx)
|
||||
list_inithead(&ctx->blocks);
|
||||
|
||||
agx_block *blk = rzalloc(ctx, agx_block);
|
||||
|
||||
blk->predecessors = _mesa_set_create(blk,
|
||||
_mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
util_dynarray_init(&blk->predecessors, NULL);
|
||||
|
||||
list_addtail(&blk->link, &ctx->blocks);
|
||||
list_inithead(&blk->instructions);
|
||||
|
Reference in New Issue
Block a user