From 0dbf1b48d12347ca5e8d30eda827d91d1654de4e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 22 Feb 2024 08:42:39 -0400 Subject: [PATCH] agx: add helpers for multiblock unit tests Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/test/agx_test.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/asahi/compiler/test/agx_test.h b/src/asahi/compiler/test/agx_test.h index 3ac0cd913b9..bed608853c9 100644 --- a/src/asahi/compiler/test/agx_test.h +++ b/src/asahi/compiler/test/agx_test.h @@ -20,6 +20,7 @@ agx_test_builder(void *memctx) agx_block *blk = rzalloc(ctx, agx_block); util_dynarray_init(&blk->predecessors, NULL); + ctx->num_blocks = 1; list_addtail(&blk->link, &ctx->blocks); list_inithead(&blk->instructions); @@ -31,6 +32,20 @@ agx_test_builder(void *memctx) return b; } +static inline agx_block * +agx_test_block(agx_context *ctx) +{ + agx_block *blk = rzalloc(ctx, agx_block); + + util_dynarray_init(&blk->predecessors, blk); + list_addtail(&blk->link, &ctx->blocks); + list_inithead(&blk->instructions); + + blk->index = ctx->num_blocks++; + + return blk; +} + /* Helper to compare for logical equality of instructions. Need to compare the * pointers, then compare raw data. */