panfrost/midgard: Implement fneg/fabs/fsat
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 26 May 2019 03:16:37 +0000 (03:16 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 26 May 2019 03:16:37 +0000 (03:16 +0000)
Fix a regression I inadvertently caused by acking typeless movs before
implementing/pushing this *whistles*

Nothing to see here, move along folks.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/midgard/midgard_compile.c

index d8d3751..048389d 100644 (file)
@@ -864,6 +864,11 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
                 ALU_CASE(b32any_inequal3, ibany_neq);
                 ALU_CASE(b32any_inequal4, ibany_neq);
 
+                /* Source mods will be shoved in later */
+                ALU_CASE(fabs, fmov);
+                ALU_CASE(fneg, fmov);
+                ALU_CASE(fsat, fmov);
+
         /* For greater-or-equal, we lower to less-or-equal and flip the
          * arguments */
 
@@ -928,6 +933,9 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
                 midgard_is_integer_out_op(op) ? midgard_outmod_int :
                 instr->dest.saturate ? midgard_outmod_sat : midgard_outmod_none;
 
+        if (instr->op == nir_op_fsat)
+                outmod = midgard_outmod_sat;
+
         /* fmax(a, 0.0) can turn into a .pos modifier as an optimization */
 
         if (instr->op == nir_op_fmax) {
@@ -977,6 +985,18 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
                 assert(0);
         }
 
+        /* These were lowered to a move, so apply the corresponding mod */
+
+        if (instr->op == nir_op_fneg || instr->op == nir_op_fabs) {
+                nir_alu_src *s = nirmods[quirk_flipped_r24];
+
+                if (instr->op == nir_op_fneg)
+                        s->negate = !s->negate;
+
+                if (instr->op == nir_op_fabs)
+                        s->abs = !s->abs;
+        }
+
         bool is_int = midgard_is_integer_op(op);
 
         midgard_vector_alu alu = {