From 7bd6ca934d0785a152b8fa2df4f87ebfa08b31cf Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 21 Dec 2020 15:45:51 -0500 Subject: pan/bi: Unit test bi_can_{fma, add} Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_schedule.c | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index ef5e6be0077..efd821019fc 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -25,6 +25,7 @@ */ #include "compiler.h" +#include "bi_builder.h" /* Determines messsage type by checking the table and a few special cases. Only * case missing is tilebuffer instructions that access depth/stencil, which @@ -292,8 +293,52 @@ bi_schedule(bi_context *ctx) } #ifndef NDEBUG + +static bi_builder * +bit_builder(void *memctx) +{ + bi_context *ctx = rzalloc(memctx, bi_context); + list_inithead(&ctx->blocks); + + bi_block *blk = rzalloc(ctx, bi_block); + + blk->base.predecessors = _mesa_set_create(blk, + _mesa_hash_pointer, + _mesa_key_pointer_equal); + + list_addtail(&blk->base.link, &ctx->blocks); + list_inithead(&blk->base.instructions); + + bi_builder *b = rzalloc(memctx, bi_builder); + b->shader = ctx; + b->cursor = bi_after_block(blk); + return b; +} + +#define TMP() bi_temp(b->shader) + +static void +bi_test_units(bi_builder *b) +{ + bi_instr *mov = bi_mov_i32_to(b, TMP(), TMP()); + assert(bi_can_fma(mov)); + assert(bi_can_add(mov)); + + bi_instr *fma = bi_fma_f32_to(b, TMP(), TMP(), TMP(), bi_zero(), BI_ROUND_NONE); + assert(bi_can_fma(fma)); + assert(!bi_can_add(fma)); + + bi_instr *load = bi_load_i128_to(b, TMP(), TMP(), TMP(), BI_SEG_UBO); + assert(!bi_can_fma(load)); + assert(bi_can_add(load)); +} + int bi_test_scheduler(void) { + void *memctx = NULL; + + bi_test_units(bit_builder(memctx)); + return 0; } #endif -- cgit v1.2.3