etnaviv: extend etna_pass_flags with source modifiers
authorChristian Gmeiner <cgmeiner@igalia.com>
Wed, 19 Jul 2023 08:35:39 +0000 (10:35 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 24 Jul 2023 15:22:56 +0000 (15:22 +0000)
As nir_lower_to_source_mods(..) will be deleted and with it the modifier storage
in nir's core we need to find an other way store the information.

We have have 6 bits left in nir's pass_flags - so lets go that route.

This also adds some small helpers that will be used later.

Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24216>

src/gallium/drivers/etnaviv/etnaviv_compiler_nir.h

index 3cf0127..438de6d 100644 (file)
@@ -70,17 +70,63 @@ struct etna_compile {
 enum etna_pass_flags {
    BYPASS_DST = BITFIELD_BIT(0),
    BYPASS_SRC = BITFIELD_BIT(1),
+
+   /* source modifier */
+   SRC0_MOD_NEG = BITFIELD_BIT(2),
+   SRC1_MOD_NEG = BITFIELD_BIT(3),
+   SRC2_MOD_NEG = BITFIELD_BIT(4),
+   SRC0_MOD_ABS = BITFIELD_BIT(5),
+   SRC1_MOD_ABS = BITFIELD_BIT(6),
+   SRC2_MOD_ABS = BITFIELD_BIT(7),
 };
 
 #define PASS_FLAGS_IS_DEAD_MASK     BITFIELD_RANGE(0, 2)
+#define PASS_FLAGS_SRC_MOD_NEG_MASK BITFIELD_RANGE(2, 3)
+#define PASS_FLAGS_SRC_MOD_ABS_MASK BITFIELD_RANGE(5, 3)
 
-static_assert(PASS_FLAGS_IS_DEAD_MASK == (BYPASS_DST | BYPASS_SRC));
+static_assert(PASS_FLAGS_IS_DEAD_MASK == (BYPASS_DST | BYPASS_SRC), "is_dead_mask is wrong");
+static_assert(PASS_FLAGS_SRC_MOD_NEG_MASK == (SRC0_MOD_NEG | SRC1_MOD_NEG | SRC2_MOD_NEG), "src_mod_neg_mask is wrong");
+static_assert(PASS_FLAGS_SRC_MOD_ABS_MASK == (SRC0_MOD_ABS | SRC1_MOD_ABS | SRC2_MOD_ABS), "src_mod_abs_mask is wrong");
 
 static inline bool is_dead_instruction(nir_instr *instr)
 {
    return instr->pass_flags & PASS_FLAGS_IS_DEAD_MASK;
 }
 
+static inline void set_src_mod_abs(nir_instr *instr, unsigned idx)
+{
+   assert(idx < 3);
+   instr->pass_flags |= (SRC0_MOD_ABS << idx);
+}
+
+static inline void set_src_mod_neg(nir_instr *instr, unsigned idx)
+{
+   assert(idx < 3);
+   instr->pass_flags |= (SRC0_MOD_NEG << idx);
+}
+
+static inline void toggle_src_mod_neg(nir_instr *instr, unsigned idx)
+{
+   assert(idx < 3);
+   instr->pass_flags ^= (SRC0_MOD_NEG << idx);
+}
+
+static inline bool is_src_mod_abs(nir_instr *instr, unsigned idx)
+{
+   if (idx < 3)
+      return instr->pass_flags & (SRC0_MOD_ABS << idx);
+
+   return false;
+}
+
+static inline bool is_src_mod_neg(nir_instr *instr, unsigned idx)
+{
+   if (idx < 3)
+      return instr->pass_flags & (SRC0_MOD_NEG << idx);
+
+   return false;
+}
+
 static inline bool is_sysval(nir_instr *instr)
 {
    if (instr->type != nir_instr_type_intrinsic)