From a8fce919d22c1389e3511dc9970d62245bf53146 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 8 Jan 2021 17:49:25 -0500 Subject: [PATCH] pan/bi: Extract bi_ec0_packed helper Useful for scheduling decisions as well as packing. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_layout.c | 11 +++++++++++ src/panfrost/bifrost/bi_pack.c | 6 +----- src/panfrost/bifrost/compiler.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/panfrost/bifrost/bi_layout.c b/src/panfrost/bifrost/bi_layout.c index 9eb84af5c4f..db66ed04f77 100644 --- a/src/panfrost/bifrost/bi_layout.c +++ b/src/panfrost/bifrost/bi_layout.c @@ -50,6 +50,17 @@ bi_can_insert_tuple(bi_clause *clause, bool constant) return (constant_count + tuple_count) <= 13; } +/* Is embedded constant 0 packed for free in a clause with this many tuples? */ + +bool +bi_ec0_packed(unsigned tuple_count) +{ + return (tuple_count == 3) || + (tuple_count == 5) || + (tuple_count == 6) || + (tuple_count == 8); +} + /* Helper to calculate the number of quadwords in a clause. This is a function * of the number of instructions and constants; it doesn't require actually * packing, which is useful for branch offsets. diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 2b1739e2921..c988f16fc4d 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -822,11 +822,7 @@ bi_pack_clause(bi_context *ctx, bi_clause *clause, &clause->tuples[prev], i == 0, stage); } - bool ec0_packed = - (clause->tuple_count == 3) || - (clause->tuple_count == 5) || - (clause->tuple_count == 6) || - (clause->tuple_count == 8); + bool ec0_packed = bi_ec0_packed(clause->tuple_count); if (ec0_packed) clause->constant_count = MAX2(clause->constant_count, 1); diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 260b8d3c764..d358e79a113 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -749,6 +749,7 @@ void bi_invalidate_liveness(bi_context *ctx); bool bi_can_insert_tuple(bi_clause *clause, bool constant); unsigned bi_clause_quadwords(bi_clause *clause); signed bi_block_offset(bi_context *ctx, bi_clause *start, bi_block *target); +bool bi_ec0_packed(unsigned tuple_count); static inline bool bi_is_terminal_block(bi_block *block)