Mesa (master): pan/mdg: eliminate references to ins->alu.outmod

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 30 23:13:18 UTC 2020


Module: Mesa
Branch: master
Commit: 5011373e2b48320abfa5aafbcd9c876f1815060a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5011373e2b48320abfa5aafbcd9c876f1815060a

Author: Italo Nicola <italonicola at collabora.com>
Date:   Wed Jul 15 18:43:18 2020 +0000

pan/mdg: eliminate references to ins->alu.outmod

In an effort to simplify MIR by not prepacking instructions, this commit
removes references to `ins->alu.outmod` so that we can later remove the
`ins->alu` field from midgard_instruction.
Every place that was using `ins->alu.outmod` was changed to now use the
generic `ins->outmod` field instead.
We then reconstruct the outmod field right before emission.

Signed-off-by: Italo Nicola <italonicola at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5933>

---

 src/panfrost/midgard/compiler.h        | 10 +++++++---
 src/panfrost/midgard/midgard_compile.c |  7 +------
 src/panfrost/midgard/midgard_emit.c    |  2 ++
 src/panfrost/midgard/mir.c             |  2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 8d7af77a324..86465d9b7e2 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -178,6 +178,12 @@ typedef struct midgard_instruction {
         /* Use this in conjunction with `type` */
         unsigned op;
 
+        /* This refers to midgard_outmod_float or midgard_outmod_int.
+         * In case of a ALU op, use midgard_is_integer_out_op() to know which
+         * one is used.
+         * If it's a texture op, it's always midgard_outmod_float. */
+        unsigned outmod;
+
         union {
                 midgard_load_store_word load_store;
                 midgard_vector_alu alu;
@@ -556,9 +562,7 @@ v_mov(unsigned src, unsigned dest)
                 .dest = dest,
                 .dest_type = nir_type_uint32,
                 .op = midgard_alu_op_imov,
-                .alu = {
-                        .outmod = midgard_outmod_int_wrap
-                },
+                .outmod = midgard_outmod_int_wrap
         };
 
         return ins;
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 71191083794..db3b6bb0a6c 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1161,10 +1161,6 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
 
         ins.mask = mask_of(nr_components);
 
-        midgard_vector_alu alu = {
-                .outmod = outmod,
-        };
-
         /* Apply writemask if non-SSA, keeping in mind that we can't write to
          * components that don't exist. Note modifier => SSA => !reg => no
          * writemask, so we don't have to worry about writemasks here.*/
@@ -1172,9 +1168,8 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
         if (!is_ssa)
                 ins.mask &= instr->dest.write_mask;
 
-        ins.alu = alu;
-
         ins.op = op;
+        ins.outmod = outmod;
 
         /* Late fixup for emulated instructions */
 
diff --git a/src/panfrost/midgard/midgard_emit.c b/src/panfrost/midgard/midgard_emit.c
index 92a962db5e9..99a26c8618b 100644
--- a/src/panfrost/midgard/midgard_emit.c
+++ b/src/panfrost/midgard/midgard_emit.c
@@ -492,6 +492,7 @@ vector_alu_from_instr(midgard_instruction *ins)
 {
         midgard_vector_alu alu = ins->alu;
         alu.op = ins->op;
+        alu.outmod = ins->outmod;
         alu.reg_mode = reg_mode_for_bitsize(max_bitsize_for_alu(ins));
         return alu;
 }
@@ -699,6 +700,7 @@ emit_binary_bundle(compiler_context *ctx,
                 ins->texture.out_upper = override > 0;
                 ins->texture.in_reg_full = (isz == 32);
                 ins->texture.sampler_type = midgard_sampler_type(ins->dest_type);
+                ins->texture.outmod = ins->outmod;
 
                 if (mir_op_computes_derivatives(ctx->stage, ins->texture.op)) {
                         ins->texture.cont = !ins->helper_terminate;
diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c
index 806dffd8de1..40669edb0f8 100644
--- a/src/panfrost/midgard/mir.c
+++ b/src/panfrost/midgard/mir.c
@@ -141,7 +141,7 @@ bool
 mir_nontrivial_outmod(midgard_instruction *ins)
 {
         bool is_int = midgard_is_integer_op(ins->op);
-        unsigned mod = ins->alu.outmod;
+        unsigned mod = ins->outmod;
 
         if (ins->dest_type != ins->src_types[1])
                 return true;



More information about the mesa-commit mailing list