Mesa (master): nir: Expose double and int64 op_to_options_mask helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 6 17:25:14 UTC 2019


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

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Fri Mar  1 17:39:54 2019 -0600

nir: Expose double and int64 op_to_options_mask helpers

We already have one internally for int64 but we don't have a similar one
for doubles so we'll have to make one.

Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/compiler/nir/nir.h                  |  2 +
 src/compiler/nir/nir_lower_double_ops.c | 66 +++++++++------------------------
 src/compiler/nir/nir_lower_int64.c      |  6 +--
 3 files changed, 23 insertions(+), 51 deletions(-)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 0d5b70b1c34..3e1714ec5d2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3271,8 +3271,10 @@ bool nir_lower_bit_size(nir_shader *shader,
                         nir_lower_bit_size_callback callback,
                         void *callback_data);
 
+nir_lower_int64_options nir_lower_int64_op_to_options_mask(nir_op opcode);
 bool nir_lower_int64(nir_shader *shader, nir_lower_int64_options options);
 
+nir_lower_doubles_options nir_lower_doubles_op_to_options_mask(nir_op opcode);
 bool nir_lower_doubles(nir_shader *shader, nir_lower_doubles_options options);
 bool nir_lower_pack(nir_shader *shader);
 
diff --git a/src/compiler/nir/nir_lower_double_ops.c b/src/compiler/nir/nir_lower_double_ops.c
index 054fce9c168..69f4b3a78db 100644
--- a/src/compiler/nir/nir_lower_double_ops.c
+++ b/src/compiler/nir/nir_lower_double_ops.c
@@ -589,6 +589,23 @@ lower_doubles_instr_to_soft(nir_builder *b, nir_alu_instr *instr,
    return true;
 }
 
+nir_lower_doubles_options
+nir_lower_doubles_op_to_options_mask(nir_op opcode)
+{
+   switch (opcode) {
+   case nir_op_frcp:          return nir_lower_drcp;
+   case nir_op_fsqrt:         return nir_lower_dsqrt;
+   case nir_op_frsq:          return nir_lower_drsq;
+   case nir_op_ftrunc:        return nir_lower_dtrunc;
+   case nir_op_ffloor:        return nir_lower_dfloor;
+   case nir_op_fceil:         return nir_lower_dceil;
+   case nir_op_ffract:        return nir_lower_dfract;
+   case nir_op_fround_even:   return nir_lower_dround_even;
+   case nir_op_fmod:          return nir_lower_dmod;
+   default:                   return 0;
+   }
+}
+
 static bool
 lower_doubles_instr(nir_builder *b, nir_alu_instr *instr,
                     nir_lower_doubles_options options)
@@ -607,55 +624,8 @@ lower_doubles_instr(nir_builder *b, nir_alu_instr *instr,
    if (lower_doubles_instr_to_soft(b, instr, options))
       return true;
 
-   switch (instr->op) {
-   case nir_op_frcp:
-      if (!(options & nir_lower_drcp))
-         return false;
-      break;
-
-   case nir_op_fsqrt:
-      if (!(options & nir_lower_dsqrt))
-         return false;
-      break;
-
-   case nir_op_frsq:
-      if (!(options & nir_lower_drsq))
-         return false;
-      break;
-
-   case nir_op_ftrunc:
-      if (!(options & nir_lower_dtrunc))
-         return false;
-      break;
-
-   case nir_op_ffloor:
-      if (!(options & nir_lower_dfloor))
-         return false;
-      break;
-
-   case nir_op_fceil:
-      if (!(options & nir_lower_dceil))
-         return false;
-      break;
-
-   case nir_op_ffract:
-      if (!(options & nir_lower_dfract))
-         return false;
-      break;
-
-   case nir_op_fround_even:
-      if (!(options & nir_lower_dround_even))
-         return false;
-      break;
-
-   case nir_op_fmod:
-      if (!(options & nir_lower_dmod))
-         return false;
-      break;
-
-   default:
+   if (!(options & nir_lower_doubles_op_to_options_mask(instr->op)))
       return false;
-   }
 
    b->cursor = nir_before_instr(&instr->instr);
 
diff --git a/src/compiler/nir/nir_lower_int64.c b/src/compiler/nir/nir_lower_int64.c
index 6aae1816bd2..e7d361da6da 100644
--- a/src/compiler/nir/nir_lower_int64.c
+++ b/src/compiler/nir/nir_lower_int64.c
@@ -630,8 +630,8 @@ lower_irem64(nir_builder *b, nir_ssa_def *n, nir_ssa_def *d)
    return nir_bcsel(b, n_is_neg, nir_ineg(b, r), r);
 }
 
-static nir_lower_int64_options
-opcode_to_options_mask(nir_op opcode)
+nir_lower_int64_options
+nir_lower_int64_op_to_options_mask(nir_op opcode)
 {
    switch (opcode) {
    case nir_op_imul:
@@ -834,7 +834,7 @@ lower_int64_impl(nir_function_impl *impl, nir_lower_int64_options options)
             break;
          }
 
-         if (!(options & opcode_to_options_mask(alu->op)))
+         if (!(options & nir_lower_int64_op_to_options_mask(alu->op)))
             continue;
 
          b.cursor = nir_before_instr(instr);




More information about the mesa-commit mailing list