From 662b866e1bfc5fc244a6531cca2e47f2df9eea9b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 21 Jul 2022 11:53:23 -0400 Subject: [PATCH] pan/bi: Add validation for nr_srcs/nr_dests Now that we set nr_srcs/nr_dests accurately, assert as much in the validator. This pass will be deleted later in the series, but having it here is expected to be useful for bisection, in case there are cases missed. Certainly running the CTS at this point in the series is helpful to prove completeness of the beginning of this series. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_validate.c | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/panfrost/bifrost/bi_validate.c b/src/panfrost/bifrost/bi_validate.c index 778689799fe..8e7c077ada7 100644 --- a/src/panfrost/bifrost/bi_validate.c +++ b/src/panfrost/bifrost/bi_validate.c @@ -149,6 +149,43 @@ bi_validate_width(bi_context *ctx) return succ; } +/* + * Temporary stopgap to check that source/destination counts are correct. This + * validation pass will go away later this series when we dynamically allocate + * sources and destinations. + */ +static bool +bi_validate_src_dest_count(bi_context *ctx) +{ + bool succ = true; + + bi_foreach_instr_global(ctx, I) { + for (unsigned s = I->nr_srcs; s < ARRAY_SIZE(I->src); ++s) { + if (!bi_is_null(I->src[s])) { + succ = false; + fprintf(stderr, + "unexpected source %u, expected %u sources\n", + s, I->nr_srcs); + bi_print_instr(I, stderr); + fprintf(stderr, "\n"); + } + } + + for (unsigned d = I->nr_dests; d < ARRAY_SIZE(I->dest); ++d) { + if (!bi_is_null(I->dest[d])) { + succ = false; + fprintf(stderr, + "unexpected dest %u, expected %u sources\n", + d, I->nr_dests); + bi_print_instr(I, stderr); + fprintf(stderr, "\n"); + } + } + } + + return succ; +} + void bi_validate(bi_context *ctx, const char *after) { @@ -172,6 +209,11 @@ bi_validate(bi_context *ctx, const char *after) fail = true; } + if (!bi_validate_src_dest_count(ctx)) { + fprintf(stderr, "Unexpected source/dest count after %s\n", after); + fail = true; + } + if (fail) { bi_print_shader(ctx, stderr); exit(1);