pan/midgard: Factor out mir_get_alu_src
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Thu, 17 Oct 2019 20:37:48 +0000 (16:37 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sun, 20 Oct 2019 12:02:31 +0000 (12:02 +0000)
This helper is used in a bunch of places ... might as well make that
common.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/panfrost/midgard/mir.c

index f1eca73f7894b258db765961a8f1b54f7083ce49..68a13d437edc381848fd89a03bad2450f295dd27 100644 (file)
@@ -38,6 +38,13 @@ void mir_rewrite_index_dst_single(midgard_instruction *ins, unsigned old, unsign
                 ins->dest = new;
 }
 
+static midgard_vector_alu_src
+mir_get_alu_src(midgard_instruction *ins, unsigned idx)
+{
+        unsigned b = (idx == 0) ? ins->alu.src1 : ins->alu.src2;
+        return vector_alu_from_unsigned(b);
+}
+
 unsigned
 mir_get_swizzle(midgard_instruction *ins, unsigned idx)
 {
@@ -45,12 +52,7 @@ mir_get_swizzle(midgard_instruction *ins, unsigned idx)
                 if (idx == 2 || ins->compact_branch)
                         return ins->cond_swizzle;
 
-                unsigned b = (idx == 0) ? ins->alu.src1 : ins->alu.src2;
-
-                midgard_vector_alu_src s =
-                        vector_alu_from_unsigned(b);
-
-                return s.swizzle;
+                return (mir_get_alu_src(ins, idx)).swizzle;
         } else if (ins->type == TAG_LOAD_STORE_4) {
                 /* Main swizzle of a load is on the destination */
                 if (!OP_IS_STORE(ins->load_store.op))