pan/midgard: Add helper to pack load/store registers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 1 Aug 2019 21:14:43 +0000 (14:14 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 2 Aug 2019 21:20:03 +0000 (14:20 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/helpers.h

index 9d04b0571260ae41b8dc4fe14476c002b90b5e5d..c44783e3d68180904b623dd3ccc73629acda30ce 100644 (file)
@@ -340,4 +340,22 @@ mir_is_simple_swizzle(unsigned swizzle, unsigned mask)
         return true;
 }
 
+/* Packs a load/store argument */
+
+static inline uint8_t
+midgard_ldst_reg(unsigned reg, unsigned component)
+{
+        assert(reg == REGISTER_LDST_BASE || (reg == REGISTER_LDST_BASE + 1));
+
+        midgard_ldst_register_select sel = {
+                .component = component,
+                .select = reg - 26
+        };
+
+        uint8_t packed;
+        memcpy(&packed, &sel, sizeof(packed));
+
+        return packed;
+}
+
 #endif