pan/bi: Add bi_load32_components helper
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 20 Mar 2020 15:52:33 +0000 (11:52 -0400)
committerMarge Bot <eric+marge@anholt.net>
Sun, 22 Mar 2020 03:32:35 +0000 (03:32 +0000)
Pattern seems to crop up a lot.

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

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

index 496a394acfa9243003ed2f930c27e0105c5da052..5de9d30fe30fa91e22078ba75ed56a0384afa5aa 100644 (file)
@@ -105,6 +105,16 @@ bi_get_component_count(bi_instruction *ins)
         }
 }
 
+unsigned
+bi_load32_components(bi_instruction *ins)
+{
+        unsigned mask = bi_from_bytemask(ins->writemask, 4);
+        unsigned count = util_bitcount(mask);
+        assert(mask == ((1 << count) - 1));
+        assert(count >= 1 && count <= 4);
+        return count;
+}
+
 uint16_t
 bi_bytemask_of_read_components(bi_instruction *ins, unsigned node)
 {
index 178346146729e0d8a967b37f0abdbdc5fa25e1a3..1a777feaaac1337b1895fc1d09110d12c0948a76 100644 (file)
@@ -531,6 +531,7 @@ bool bi_is_src_swizzled(bi_instruction *ins, unsigned s);
 bool bi_has_arg(bi_instruction *ins, unsigned arg);
 uint16_t bi_from_bytemask(uint16_t bytemask, unsigned bytes);
 unsigned bi_get_component_count(bi_instruction *ins);
+unsigned bi_load32_components(bi_instruction *ins);
 uint16_t bi_bytemask_of_read_components(bi_instruction *ins, unsigned node);
 
 /* BIR passes */