pan/bi: Pull out bi_count_read_registers helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 20 Jan 2021 21:40:52 +0000 (16:40 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 16:55:43 +0000 (16:55 +0000)
I want to transition away from the ad hoc masks anyway.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8723>

src/panfrost/bifrost/bir.c
src/panfrost/bifrost/compiler.h

index 370a359..97126ac 100644 (file)
@@ -83,24 +83,25 @@ bi_count_staging_registers(bi_instr *ins)
         unreachable("Invalid sr_count");
 }
 
+unsigned
+bi_count_read_registers(bi_instr *ins, unsigned s)
+{
+        if (s == 0 && bi_opcode_props[ins->op].sr_read)
+                return bi_count_staging_registers(ins);
+        else
+                return 1;
+}
+
 uint16_t
 bi_bytemask_of_read_components(bi_instr *ins, bi_index node)
 {
         uint16_t mask = 0x0;
-        bool reads_sr = bi_opcode_props[ins->op].sr_read;
 
         bi_foreach_src(ins, s) {
                 if (!bi_is_equiv(ins->src[s], node)) continue;
 
-                /* assume we read a scalar */
-                unsigned rmask = 0xF;
-
-                if (s == 0 && reads_sr) {
-                        /* Override for a staging register */
-                        unsigned count = bi_count_staging_registers(ins);
-                        rmask = (1 << (count * 4)) - 1;
-                }
-
+                unsigned count = bi_count_read_registers(ins, s);
+                unsigned rmask = (1 << (4 * count)) - 1;
                 mask |= (rmask << (4 * node.offset));
         }
 
index d985377..853a7ba 100644 (file)
@@ -689,6 +689,7 @@ pan_next_block(pan_block *block)
 /* BIR manipulation */
 
 bool bi_has_arg(bi_instr *ins, bi_index arg);
+unsigned bi_count_read_registers(bi_instr *ins, unsigned src);
 uint16_t bi_bytemask_of_read_components(bi_instr *ins, bi_index node);
 unsigned bi_writemask(bi_instr *ins);