pan/mdg: eliminate references to ins->alu.outmod
authorItalo Nicola <italonicola@collabora.com>
Wed, 15 Jul 2020 18:43:18 +0000 (18:43 +0000)
committerMarge Bot <eric+marge@anholt.net>
Thu, 30 Jul 2020 22:55:36 +0000 (22:55 +0000)
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@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5933>

src/panfrost/midgard/compiler.h
src/panfrost/midgard/midgard_compile.c
src/panfrost/midgard/midgard_emit.c
src/panfrost/midgard/mir.c

index 8d7af77a324671bc9253d153071036adb620166e..86465d9b7e2b2db10e8a1761399af9ca0a44eb1b 100644 (file)
@@ -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;
index 71191083794e58ca1383a0beb64404682f017cff..db3b6bb0a6cba019a81898ae130768c8d0f24abc 100644 (file)
@@ -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 */
 
index 92a962db5e9723b649ac8df81d87f7e4ac7c02ce..99a26c8618bde2753d2792e2fcde9bb8e5052b39 100644 (file)
@@ -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;
index 806dffd8de1437ebedc9a2e6d2259f14a9e29875..40669edb0f8f997350dfc44cf2b626aa221e6a3a 100644 (file)
@@ -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;