pan/decode: Fix awkward syntax
[mesa.git] / src / panfrost / bifrost / bi_ra.c
index 6533d66b7df99cdc05d96d668fe4e65e6d007800..1936958c28f33dc76c48b298c41a0e7380686110 100644 (file)
@@ -25,6 +25,7 @@
  */
 
 #include "compiler.h"
+#include "bi_print.h"
 #include "panfrost/util/lcra.h"
 #include "util/u_memory.h"
 
@@ -44,7 +45,7 @@ bi_compute_interference(bi_context *ctx, struct lcra_state *l)
                         if (ins->dest && (ins->dest < l->node_count)) {
                                 for (unsigned i = 1; i < l->node_count; ++i) {
                                         if (live[i])
-                                                lcra_add_node_interference(l, ins->dest, ins->writemask, i, live[i]);
+                                                lcra_add_node_interference(l, ins->dest, bi_writemask(ins), i, live[i]);
                                 }
                         }
 
@@ -66,7 +67,7 @@ bi_allocate_registers(bi_context *ctx, bool *success)
         unsigned node_count = bi_max_temp(ctx);
 
         struct lcra_state *l =
-                lcra_alloc_equations(node_count, 1, 8, 16, 1);
+                lcra_alloc_equations(node_count, 1);
 
         l->class_start[BI_REG_CLASS_WORK] = 0;
         l->class_size[BI_REG_CLASS_WORK] = 64 * 4; /* R0 - R63, all 32-bit */
@@ -78,7 +79,7 @@ bi_allocate_registers(bi_context *ctx, bool *success)
                         continue;
 
                 l->class[dest] = BI_REG_CLASS_WORK;
-                lcra_set_alignment(l, dest, 2); /* 2^2 = 4 */
+                lcra_set_alignment(l, dest, 2, 16); /* 2^2 = 4 */
                 lcra_restrict_range(l, dest, 4);
         }
 
@@ -101,10 +102,10 @@ bi_reg_from_index(struct lcra_state *l, unsigned index, unsigned offset)
         if (solution < 0)
                 return index;
 
-        solution += offset;
-
         assert((solution & 0x3) == 0);
         unsigned reg = solution / 4;
+        reg += offset;
+
         return BIR_INDEX_REGISTER | reg;
 }
 
@@ -121,19 +122,16 @@ bi_adjust_src_ra(bi_instruction *ins, struct lcra_state *l, unsigned src)
                 /* TODO: Do we do anything here? */
         } else {
                 /* Use the swizzle as component select */
+                unsigned components = bi_get_component_count(ins, src);
+
                 nir_alu_type T = ins->src_types[src];
                 unsigned size = nir_alu_type_get_type_size(T);
-                assert(size <= 32); /* TODO: 64-bit */
-                unsigned comps_per_reg = 32 / size;
-                unsigned components = bi_get_component_count(ins, src);
+                /* TODO: 64-bit? */
+                unsigned components_per_word = MAX2(32 / size, 1);
 
                 for (unsigned i = 0; i < components; ++i) {
-                        /* If we're not writing the component, who cares? */
-                        if (!bi_writes_component(ins, i))
-                                continue;
-
-                        unsigned off = ins->swizzle[src][i] / comps_per_reg;
-                        off *= 4; /* 32-bit registers */
+                        unsigned off = ins->swizzle[src][i] / components_per_word;
 
                         /* We can't cross register boundaries in a swizzle */
                         if (i == 0)
@@ -141,7 +139,7 @@ bi_adjust_src_ra(bi_instruction *ins, struct lcra_state *l, unsigned src)
                         else
                                 assert(off == offset);
 
-                        ins->swizzle[src][i] %= comps_per_reg;
+                        ins->swizzle[src][i] %= components_per_word;
                 }
         }
 
@@ -154,25 +152,8 @@ bi_adjust_dest_ra(bi_instruction *ins, struct lcra_state *l)
         if (ins->dest >= l->node_count)
                 return;
 
-        bool vector = (bi_class_props[ins->type] & BI_VECTOR);
-        unsigned offset = 0;
-
-        if (!vector) {
-                /* Look at the writemask to get an offset, specifically the
-                 * trailing zeros */
-
-                unsigned tz = __builtin_ctz(ins->writemask);
-
-                /* Recall writemask is one bit per byte, so tz is in eytes */
-                unsigned regs = tz / 4;
-                offset = regs * 4;
-
-                /* Adjust writemask to compensate */
-                ins->writemask >>= offset;
-        }
-
-        ins->dest = bi_reg_from_index(l, ins->dest, offset);
-
+        ins->dest = bi_reg_from_index(l, ins->dest, ins->dest_offset);
+        ins->dest_offset = 0;
 }
 
 static void