From be02c0868c763a6ed5384d689ee52d7ffb79c332 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 10 Feb 2021 11:46:01 -0500 Subject: [PATCH] pan/bi: Add bi_replace_index helper I keep open-coding this, incorrectly... Since bi_index contains both "position" and "modifier" data, it's common to want to swap the position while preserving modifiers. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/compiler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 049b0740bc4..35203838298 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -199,6 +199,17 @@ bi_neg(bi_index idx) return idx; } +/* Replaces an index, preserving any modifiers */ + +static inline bi_index +bi_replace_index(bi_index old, bi_index replacement) +{ + replacement.abs = old.abs; + replacement.neg = old.neg; + replacement.swizzle = old.swizzle; + return replacement; +} + /* For bitwise instructions */ #define bi_not(x) bi_neg(x)