From 3a63b5d7cf39dca2dfec4367fd579dde3774e67f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 11 Dec 2020 20:01:38 -0500 Subject: [PATCH] pan/bi: Add nullity/equality helpers for bi_index We can no longer use the builtin equals, since they're structs now, but these helpers are almost as convenient. 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 6f2cbe21e41..0d952eb45e4 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -471,6 +471,24 @@ bi_passthrough(enum bifrost_packed_src value) }; } +static inline bool +bi_is_null(bi_index idx) +{ + return idx.type == BI_INDEX_NULL; +} + +/* Compares equivalence as references. Does not compare offsets, swizzles, or + * modifiers. In other words, this forms bi_index equivalence classes by + * partitioning memory. E.g. -abs(foo[1].yx) == foo.xy but foo != bar */ + +static inline bool +bi_is_equiv(bi_index left, bi_index right) +{ + return (left.type == right.type) && + (left.reg == right.reg) && + (left.value == right.value); +} + /* Represents the assignment of slots for a given bi_bundle */ typedef struct {