From 372787020d48da14976fcc56387c73110c7f838b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 21 Dec 2020 17:11:36 -0500 Subject: [PATCH] pan/bi: Add bi_half and bi_byte selectors Useful for extracting out part of an index, internally implemented via a subword swizzle. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/compiler.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index aa980c49707..341ad2d8ae5 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -479,6 +479,24 @@ bi_word(bi_index idx, unsigned component) return idx; } +/* Helps construct swizzles */ +static inline bi_index +bi_half(bi_index idx, bool upper) +{ + assert(idx.swizzle == BI_SWIZZLE_H01); + idx.swizzle = upper ? BI_SWIZZLE_H11 : BI_SWIZZLE_H00; + return idx; +} + +static inline bi_index +bi_byte(bi_index idx, unsigned lane) +{ + assert(idx.swizzle == BI_SWIZZLE_H01); + assert(lane < 4); + idx.swizzle = BI_SWIZZLE_B0000 + lane; + return idx; +} + static inline bool bi_is_null(bi_index idx) {