pan/bi: Extract bit_block helper

Convenience for unit tests which need to create multiple blocks, to test global
passes.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16804>
This commit is contained in:
Alyssa Rosenzweig 2022-05-20 11:09:43 -04:00 committed by Marge Bot
parent b0edd92156
commit d7c6b7c9d2
1 changed files with 16 additions and 7 deletions

View File

@ -32,20 +32,29 @@
#include "compiler.h"
/* Helper to generate a bi_builder suitable for creating test instructions */
static inline bi_builder *
bit_builder(void *memctx)
static inline bi_block *
bit_block(bi_context *ctx)
{
bi_context *ctx = rzalloc(memctx, bi_context);
list_inithead(&ctx->blocks);
ctx->num_blocks = 1;
ctx->inputs = rzalloc(memctx, struct panfrost_compile_inputs);
bi_block *blk = rzalloc(ctx, bi_block);
util_dynarray_init(&blk->predecessors, blk);
list_addtail(&blk->link, &ctx->blocks);
list_inithead(&blk->instructions);
blk->index = ctx->num_blocks++;
return blk;
}
static inline bi_builder *
bit_builder(void *memctx)
{
bi_context *ctx = rzalloc(memctx, bi_context);
list_inithead(&ctx->blocks);
ctx->inputs = rzalloc(memctx, struct panfrost_compile_inputs);
bi_block *blk = bit_block(ctx);
bi_builder *b = rzalloc(memctx, bi_builder);
b->shader = ctx;
b->cursor = bi_after_block(blk);