pan/bi: Add bi_bytemask_of_read_components helpers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 11 Mar 2020 18:46:01 +0000 (14:46 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 11 Mar 2020 20:28:21 +0000 (20:28 +0000)
Same purpose as the Midgard version, but the implementation is
*dramatically* simpler thanks to our more regular IR.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4150>

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

index 5fe0ae484091ac86cf3dd887358e7f509d2ab8ce..48c06ab776e9d2a15cb10493ff172e0e5e93468f 100644 (file)
@@ -74,3 +74,24 @@ bi_has_arg(bi_instruction *ins, unsigned arg)
 
         return false;
 }
+
+uint16_t
+bi_bytemask_of_read_components(bi_instruction *ins, unsigned node)
+{
+        uint16_t mask = 0x0;
+
+        bi_foreach_src(ins, s) {
+                if (ins->src[s] != node) continue;
+                nir_alu_type T = ins->src_types[s];
+                unsigned size = nir_alu_type_get_type_size(T);
+                unsigned bytes = (MAX2(size, 8) / 8);
+                unsigned cmask = (1 << bytes) - 1;
+
+                for (unsigned i = 0; i < ARRAY_SIZE(ins->swizzle[s]); ++i) {
+                        unsigned c = ins->swizzle[s][i];
+                        mask |= (cmask << (c * bytes));
+                }
+        }
+
+        return mask;
+}
index cd0d4f565367e6646cf3efcc7df78e1005ca12af..467735bcf0ae1f4ff31bd09bdb203d07d1c58431 100644 (file)
@@ -475,6 +475,7 @@ bool bi_has_outmod(bi_instruction *ins);
 bool bi_has_source_mods(bi_instruction *ins);
 bool bi_is_src_swizzled(bi_instruction *ins, unsigned s);
 bool bi_has_arg(bi_instruction *ins, unsigned arg);
+uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node);
 
 /* BIR passes */