From edf284215dc013fdeb3d0b0891f0ff223298666f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 27 Jul 2021 13:24:22 -0400 Subject: [PATCH] pan/va: Add helpers for swapping bitwise sources Annoyingly different from Bifrost. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/valhall/valhall.h | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/panfrost/bifrost/valhall/valhall.h b/src/panfrost/bifrost/valhall/valhall.h index debf1f7..36bc606 100644 --- a/src/panfrost/bifrost/valhall/valhall.h +++ b/src/panfrost/bifrost/valhall/valhall.h @@ -105,6 +105,46 @@ struct va_opcode_info { extern const struct va_opcode_info valhall_opcodes[BI_NUM_OPCODES]; +/* Bifrost specifies the source of bitwise operations as (A, B, shift), but + * Valhall specifies (A, shift, B). We follow Bifrost conventions in the + * compiler, so normalize. + */ + +static inline bool +va_swap_12(enum bi_opcode op) +{ + switch (op) { + case BI_OPCODE_LSHIFT_AND_I32: + case BI_OPCODE_LSHIFT_AND_V2I16: + case BI_OPCODE_LSHIFT_AND_V4I8: + case BI_OPCODE_LSHIFT_OR_I32: + case BI_OPCODE_LSHIFT_OR_V2I16: + case BI_OPCODE_LSHIFT_OR_V4I8: + case BI_OPCODE_LSHIFT_XOR_I32: + case BI_OPCODE_LSHIFT_XOR_V2I16: + case BI_OPCODE_LSHIFT_XOR_V4I8: + case BI_OPCODE_RSHIFT_AND_I32: + case BI_OPCODE_RSHIFT_AND_V2I16: + case BI_OPCODE_RSHIFT_AND_V4I8: + case BI_OPCODE_RSHIFT_OR_I32: + case BI_OPCODE_RSHIFT_OR_V2I16: + case BI_OPCODE_RSHIFT_OR_V4I8: + case BI_OPCODE_RSHIFT_XOR_I32: + case BI_OPCODE_RSHIFT_XOR_V2I16: + case BI_OPCODE_RSHIFT_XOR_V4I8: + return true; + default: + return false; + } +} + +static inline struct va_src_info +va_src_info(enum bi_opcode op, unsigned src) +{ + unsigned idx = (va_swap_12(op) && (src == 1 || src == 2)) ? (3 - src) : src; + return valhall_opcodes[op].srcs[idx]; +} + #ifdef __cplusplus } /* extern C */ #endif -- 2.7.4