diff options
author | Alyssa Rosenzweig <[email protected]> | 2020-03-03 14:32:28 -0500 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-03-05 14:35:38 +0000 |
commit | 8ec671801a8decdd5c733f2fec53726d34666a0b (patch) | |
tree | 6835139c266d3b6f5ecffd44bdd171f2b056c2c5 /src/panfrost/bifrost | |
parent | 0b26cb194cc433a9910247051024bd6468d9b05c (diff) |
pan/bi: Add IR iteration macros
Copypaste from Midgard, for the most part.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4061>
Diffstat (limited to 'src/panfrost/bifrost')
-rw-r--r-- | src/panfrost/bifrost/compiler.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 04a0c39ab97..79e45c9dff7 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -373,4 +373,63 @@ bir_dest_index(nir_dest *dst) } } +/* Iterators for Bifrost IR */ + +#define bi_foreach_block(ctx, v) \ + list_for_each_entry(bi_block, v, &ctx->blocks, link) + +#define bi_foreach_block_from(ctx, from, v) \ + list_for_each_entry_from(bi_block, v, from, &ctx->blocks, link) + +#define bi_foreach_instr_in_block(block, v) \ + list_for_each_entry(bi_instruction, v, &block->instructions, link) + +#define bi_foreach_instr_in_block_rev(block, v) \ + list_for_each_entry_rev(bi_instruction, v, &block->instructions, link) + +#define bi_foreach_instr_in_block_safe(block, v) \ + list_for_each_entry_safe(bi_instruction, v, &block->instructions, link) + +#define bi_foreach_instr_in_block_safe_rev(block, v) \ + list_for_each_entry_safe_rev(bi_instruction, v, &block->instructions, link) + +#define bi_foreach_instr_in_block_from(block, v, from) \ + list_for_each_entry_from(bi_instruction, v, from, &block->instructions, link) + +#define bi_foreach_instr_in_block_from_rev(block, v, from) \ + list_for_each_entry_from_rev(bi_instruction, v, from, &block->instructions, link) + +#define bi_foreach_clause_in_block(block, v) \ + list_for_each_entry(bi_clause, v, &block->clauses, link) + +#define bi_foreach_instr_global(ctx, v) \ + bi_foreach_block(ctx, v_block) \ + bi_foreach_instr_in_block(v_block, v) + +#define bi_foreach_instr_global_safe(ctx, v) \ + bi_foreach_block(ctx, v_block) \ + bi_foreach_instr_in_block_safe(v_block, v) + +#define bi_foreach_successor(blk, v) \ + bi_block *v; \ + bi_block **_v; \ + for (_v = &blk->successors[0], \ + v = *_v; \ + 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)) + +#define bi_foreach_src(ins, v) \ + for (unsigned v = 0; v < ARRAY_SIZE(ins->src); ++v) + #endif |