From 5dd756afedee0d45663c00976624c9c2493c2884 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 11 Dec 2020 20:00:28 -0500 Subject: [PATCH] pan/bi: Add bi_index constructors These add succinct helpers to generate well-formed references. Note for semantic that bi_zero represents the immediate value #0, while bi_null represents a value that does not exist ("undefined"). Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/compiler.h | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 19216bc887a..6f2cbe21e41 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -415,6 +415,62 @@ typedef struct { enum bi_index_type type : 3; } bi_index; +static inline bi_index +bi_get_index(unsigned value, bool is_reg, unsigned offset) +{ + return (bi_index) { + .type = BI_INDEX_NORMAL, + .value = value, + .swizzle = BI_SWIZZLE_H01, + .offset = offset, + .reg = is_reg, + }; +} + +static inline bi_index +bi_register(unsigned reg) +{ + assert(reg < 64); + + return (bi_index) { + .type = BI_INDEX_REGISTER, + .swizzle = BI_SWIZZLE_H01, + .value = reg + }; +} + +static inline bi_index +bi_imm_u32(uint32_t imm) +{ + return (bi_index) { + .type = BI_INDEX_CONSTANT, + .swizzle = BI_SWIZZLE_H01, + .value = imm + }; +} + +static inline bi_index +bi_null() +{ + return (bi_index) { .type = BI_INDEX_NULL }; +} + +static inline bi_index +bi_zero() +{ + return bi_imm_u32(0); +} + +static inline bi_index +bi_passthrough(enum bifrost_packed_src value) +{ + return (bi_index) { + .type = BI_INDEX_PASS, + .swizzle = BI_SWIZZLE_H01, + .value = value + }; +} + /* Represents the assignment of slots for a given bi_bundle */ typedef struct { @@ -610,6 +666,17 @@ enum bir_fau { BIR_FAU_HI = (1 << 8), }; +static inline bi_index +bi_fau(enum bir_fau value, bool hi) +{ + return (bi_index) { + .type = BI_INDEX_FAU, + .value = value, + .swizzle = BI_SWIZZLE_H01, + .offset = hi ? 1 : 0 + }; +} + /* Keep me synced please so we can check src & BIR_SPECIAL */ #define BIR_SPECIAL (BIR_INDEX_REGISTER | BIR_INDEX_CONSTANT | \