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);
}
}
if (bi_helper_block_update(deps, blk)) {
bi_foreach_predecessor(blk, pred)
- bi_worklist_push_head(&worklist, pred);
+ bi_worklist_push_head(&worklist, *pred);
}
}
*/
if (liveness_block_update(blk, temp_count)) {
bi_foreach_predecessor(blk, pred)
- bi_worklist_push_head(&worklist, pred);
+ bi_worklist_push_head(&worklist, *pred);
}
}
*/
if (bi_postra_liveness_block(blk)) {
bi_foreach_predecessor(blk, pred)
- bi_worklist_push_head(&worklist, pred);
+ bi_worklist_push_head(&worklist, *pred);
}
}
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) {
/* 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];
}
}
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);
}
block->successors[i] = successor;
- _mesa_set_add(successor->predecessors, block);
+ util_dynarray_append(&successor->predecessors, bi_block *, block);
return;
}
{
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;
}
/* 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;
}
/* 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 */
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;
}
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)