panfrost: Move Bifrost IR indexing to common
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 27 Apr 2020 20:00:38 +0000 (16:00 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Apr 2020 15:18:38 +0000 (15:18 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4792>

src/panfrost/util/pan_ir.h

index 2d416ffeb21b7ba0ec84e8746834e38759eace15..7eb51fa5df1ab840b204369483a6bc3be78b0323 100644 (file)
@@ -178,4 +178,36 @@ pan_to_bytemask(unsigned bytes, unsigned mask);
 
 void pan_block_add_successor(pan_block *block, pan_block *successor);
 
+/* IR indexing */
+#define PAN_IS_REG (1)
+
+static inline unsigned
+pan_ssa_index(nir_ssa_def *ssa)
+{
+        /* Off-by-one ensures BIR_NO_ARG is skipped */
+        return ((ssa->index + 1) << 1) | 0;
+}
+
+static inline unsigned
+pan_src_index(nir_src *src)
+{
+        if (src->is_ssa)
+                return pan_ssa_index(src->ssa);
+        else {
+                assert(!src->reg.indirect);
+                return (src->reg.reg->index << 1) | BIR_IS_REG;
+        }
+}
+
+static inline unsigned
+pan_dest_index(nir_dest *dst)
+{
+        if (dst->is_ssa)
+                return pan_ssa_index(&dst->ssa);
+        else {
+                assert(!dst->reg.indirect);
+                return (dst->reg.reg->index << 1) | BIR_IS_REG;
+        }
+}
+
 #endif