From 9496689f57757d981d43954327d0780978e56619 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 29 Dec 2020 07:51:29 -0500 Subject: [PATCH] pan/bi: Add clause encodings as a table We would rather not type out all of the packs by hand (that's error prone), so declaratively specify the encodings as a table corresponding to the bit patterns. This is all formats, except for format 12 which just encodes constants. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bifrost.h | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index c59692e..daa0e69 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -272,6 +272,91 @@ struct bifrost_fmt_constant { uint64_t imm_2 : 60; } __attribute__((packed)); +/* Clause formats, encoded in a table */ + +enum bi_clause_subword { + /* Literal 3-bit values */ + BI_CLAUSE_SUBWORD_LITERAL_0 = 0, + /* etc */ + BI_CLAUSE_SUBWORD_LITERAL_7 = 7, + + /* The value of the corresponding tuple in the corresponding bits */ + BI_CLAUSE_SUBWORD_TUPLE_0 = 8, + /* etc */ + BI_CLAUSE_SUBWORD_TUPLE_7 = 15, + + /* Clause header */ + BI_CLAUSE_SUBWORD_HEADER = 16, + + /* Leave zero, but semantically distinct from literal 0 */ + BI_CLAUSE_SUBWORD_RESERVED = 17, + + /* Embedded constant 0 */ + BI_CLAUSE_SUBWORD_CONSTANT = 18, + + /* M bits controlling modifier for the constant */ + BI_CLAUSE_SUBWORD_M = 19, + + /* Z bit: 1 to begin encoding constants, 0 to terminate the clause */ + BI_CLAUSE_SUBWORD_Z = 20, + + /* Upper 3-bits of a given tuple and zero extended */ + BI_CLAUSE_SUBWORD_UPPER_0 = 32, + /* etc */ + BI_CLAUSE_SUBWORD_UPPER_7 = BI_CLAUSE_SUBWORD_UPPER_0 + 7, + + /* Upper 3-bits of two tuples, concatenated and zero-extended */ + BI_CLAUSE_SUBWORD_UPPER_23 = BI_CLAUSE_SUBWORD_UPPER_0 + 23, + BI_CLAUSE_SUBWORD_UPPER_56 = BI_CLAUSE_SUBWORD_UPPER_0 + 56, +}; + +#define L(x) (BI_CLAUSE_SUBWORD_LITERAL_0 + x) +#define U(x) (BI_CLAUSE_SUBWORD_UPPER_0 + x) +#define T(x) (BI_CLAUSE_SUBWORD_TUPLE_0 + x) +#define EC BI_CLAUSE_SUBWORD_CONSTANT +#define M BI_CLAUSE_SUBWORD_M +#define Z BI_CLAUSE_SUBWORD_Z +#define H BI_CLAUSE_SUBWORD_HEADER +#define R BI_CLAUSE_SUBWORD_RESERVED + +struct bi_clause_format { + unsigned format; /* format number */ + unsigned pos; /* index in the clause */ + enum bi_clause_subword tag_1; /* 2-bits */ + enum bi_clause_subword tag_2; /* 3-bits */ + enum bi_clause_subword tag_3; /* 3-bits */ + enum bi_clause_subword s0_s3; /* 60 bits */ + enum bi_clause_subword s4; /* 15 bits */ + enum bi_clause_subword s5_s6; /* 30 bits */ + enum bi_clause_subword s7; /* 15 bits */ +}; + +static const struct bi_clause_format bi_clause_formats[] = { + { 0, 0, L(0), L(5), U(0), T(0), T(0), H, H }, + { 0, 0, Z, L(1), U(0), T(0), T(0), H, H }, + { 1, 1, Z, L(0), L(3), T(1), T(1), R, U(1) }, + { 2, 1, L(0), L(4), U(1), T(1), T(1), T(2), T(2) }, + { 3, 2, Z, L(0), L(4), EC, M, T(2), U(2) }, + { 4, 2, L(0), L(0), L(1), T(3), T(3), T(2), U(23) }, + { 4, 2, Z, L(0), L(5), T(3), T(3), T(2), U(23) }, + { 5, 2, L(2), U(3), U(2), T(3), T(3), T(2), EC }, + { 6, 3, Z, L(2), U(4), T(4), T(4), EC, EC }, + { 7, 3, L(1), L(4), U(4), T(4), T(4), T(5), T(5) }, + { 8, 4, Z, L(0), L(6), EC, M, T(5), U(5) }, + { 9, 4, Z, L(0), L(7), T(6), T(6), T(5), U(56) }, + { 10, 4, L(3), U(6), U(5), T(6), T(6), T(5), EC }, + { 11, 5, Z, L(3), U(7), T(7), T(7), EC, EC }, +}; + +#undef L +#undef U +#undef T +#undef EC +#undef M +#undef Z +#undef H +#undef R + /* 32-bit modes for slots 2/3, as encoded in the register block. Other values * are reserved. First part specifies behaviour of slot 2 (Idle, Read, Write * Full, Write Low, Write High), second part behaviour of slot 3, and the last -- 2.7.4