pan/bi: Use a dynarray for predecessors
This is deterministic, unlike a set. Note we need the extra dereferencing to keep the macro safe, simple, and standards compliant: 1. Nesting two for-loops would cause break/continue to fail. 2. Declaring variables outside the loop would pollute the namespace. 3. Declaring an anonymous struct is not conformant and doesn't compile in clang. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16279>
This commit is contained in:
parent
37f60a66e8
commit
80f8e9da16
|
@ -143,8 +143,8 @@ bi_propagate_pass_flag(bi_block *block)
|
|||
block->pass_flags = 1;
|
||||
|
||||
bi_foreach_predecessor(block, pred) {
|
||||
if (pred->pass_flags == 0)
|
||||
bi_propagate_pass_flag(pred);
|
||||
if ((*pred)->pass_flags == 0)
|
||||
bi_propagate_pass_flag(*pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +243,7 @@ bi_analyze_helper_requirements(bi_context *ctx)
|
|||
|
||||
if (bi_helper_block_update(deps, blk)) {
|
||||
bi_foreach_predecessor(blk, pred)
|
||||
bi_worklist_push_head(&worklist, pred);
|
||||
bi_worklist_push_head(&worklist, *pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ bi_compute_liveness(bi_context *ctx)
|
|||
*/
|
||||
if (liveness_block_update(blk, temp_count)) {
|
||||
bi_foreach_predecessor(blk, pred)
|
||||
bi_worklist_push_head(&worklist, pred);
|
||||
bi_worklist_push_head(&worklist, *pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ bi_postra_liveness(bi_context *ctx)
|
|||
*/
|
||||
if (bi_postra_liveness_block(blk)) {
|
||||
bi_foreach_predecessor(blk, pred)
|
||||
bi_worklist_push_head(&worklist, pred);
|
||||
bi_worklist_push_head(&worklist, *pred);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -177,11 +177,11 @@ bi_print_block(bi_block *block, FILE *fp)
|
|||
fprintf(fp, "block%u ", succ->index);
|
||||
}
|
||||
|
||||
if (block->predecessors->entries) {
|
||||
if (bi_num_predecessors(block)) {
|
||||
fprintf(fp, " from");
|
||||
|
||||
bi_foreach_predecessor(block, pred)
|
||||
fprintf(fp, " block%u", pred->index);
|
||||
fprintf(fp, " block%u", (*pred)->index);
|
||||
}
|
||||
|
||||
if (block->scheduled) {
|
||||
|
|
|
@ -252,8 +252,8 @@ scoreboard_block_update(bi_block *blk)
|
|||
/* pending_in[s] = sum { p in pred[s] } ( pending_out[p] ) */
|
||||
bi_foreach_predecessor(blk, pred) {
|
||||
for (unsigned i = 0; i < BI_NUM_SLOTS; ++i) {
|
||||
blk->scoreboard_in.read[i] |= pred->scoreboard_out.read[i];
|
||||
blk->scoreboard_in.write[i] |= pred->scoreboard_out.write[i];
|
||||
blk->scoreboard_in.read[i] |= (*pred)->scoreboard_out.read[i];
|
||||
blk->scoreboard_in.write[i] |= (*pred)->scoreboard_out.write[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,7 @@ bit_builder(void *memctx)
|
|||
|
||||
bi_block *blk = rzalloc(ctx, bi_block);
|
||||
|
||||
blk->predecessors = _mesa_set_create(blk,
|
||||
_mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
|
||||
util_dynarray_init(&blk->predecessors, blk);
|
||||
list_addtail(&blk->link, &ctx->blocks);
|
||||
list_inithead(&blk->instructions);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ bi_block_add_successor(bi_block *block, bi_block *successor)
|
|||
}
|
||||
|
||||
block->successors[i] = successor;
|
||||
_mesa_set_add(successor->predecessors, block);
|
||||
util_dynarray_append(&successor->predecessors, bi_block *, block);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3539,9 +3539,7 @@ create_empty_block(bi_context *ctx)
|
|||
{
|
||||
bi_block *blk = rzalloc(ctx, bi_block);
|
||||
|
||||
blk->predecessors = _mesa_set_create(blk,
|
||||
_mesa_hash_pointer,
|
||||
_mesa_key_pointer_equal);
|
||||
util_dynarray_init(&blk->predecessors, blk);
|
||||
|
||||
return blk;
|
||||
}
|
||||
|
|
|
@ -222,8 +222,7 @@ bi_reconverge_branches(bi_block *block)
|
|||
|
||||
/* Must have at least one successor */
|
||||
struct bi_block *succ = block->successors[0];
|
||||
assert(succ->predecessors);
|
||||
|
||||
/* Reconverge if the successor has multiple predecessors */
|
||||
return (succ->predecessors->entries > 1);
|
||||
return bi_num_predecessors(succ) > 1;
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ typedef struct bi_block {
|
|||
|
||||
/* Control flow graph */
|
||||
struct bi_block *successors[2];
|
||||
struct set *predecessors;
|
||||
struct util_dynarray predecessors;
|
||||
bool unconditional_jumps;
|
||||
|
||||
/* Per 32-bit word live masks for the block indexed by node */
|
||||
|
@ -684,11 +684,17 @@ typedef struct bi_block {
|
|||
uint8_t pass_flags;
|
||||
} bi_block;
|
||||
|
||||
static inline unsigned
|
||||
bi_num_predecessors(bi_block *block)
|
||||
{
|
||||
return util_dynarray_num_elements(&block->predecessors, bi_block *);
|
||||
}
|
||||
|
||||
static inline bi_block *
|
||||
bi_start_block(struct list_head *blocks)
|
||||
{
|
||||
bi_block *first = list_first_entry(blocks, bi_block, link);
|
||||
assert(first->predecessors->entries == 0);
|
||||
assert(bi_num_predecessors(first) == 0);
|
||||
return first;
|
||||
}
|
||||
|
||||
|
@ -969,16 +975,8 @@ bi_node_to_index(unsigned node, unsigned node_count)
|
|||
v != NULL && _v < &blk->successors[2]; \
|
||||
_v++, v = *_v) \
|
||||
|
||||
/* Based on set_foreach, expanded with automatic type casts */
|
||||
|
||||
#define bi_foreach_predecessor(blk, v) \
|
||||
struct set_entry *_entry_##v; \
|
||||
bi_block *v; \
|
||||
for (_entry_##v = _mesa_set_next_entry(blk->predecessors, NULL), \
|
||||
v = (bi_block *) (_entry_##v ? _entry_##v->key : NULL); \
|
||||
_entry_##v != NULL; \
|
||||
_entry_##v = _mesa_set_next_entry(blk->predecessors, _entry_##v), \
|
||||
v = (bi_block *) (_entry_##v ? _entry_##v->key : NULL))
|
||||
util_dynarray_foreach(&(blk)->predecessors, bi_block *, v)
|
||||
|
||||
#define bi_foreach_src(ins, v) \
|
||||
for (unsigned v = 0; v < ARRAY_SIZE(ins->src); ++v)
|
||||
|
|
Loading…
Reference in New Issue