pan/bi: Add nullity/equality helpers for bi_index
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 12 Dec 2020 01:01:38 +0000 (20:01 -0500)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 23 Dec 2020 18:29:36 +0000 (13:29 -0500)
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 <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8215>

src/panfrost/bifrost/compiler.h

index 6f2cbe2..0d952eb 100644 (file)
@@ -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 {