Mesa (master): nir/opcodes: Clear variable names confusion

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Sep 18 20:59:56 UTC 2019


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

Author: Andres Gomez <agomez at igalia.com>
Date:   Wed Sep 18 15:48:36 2019 +0300

nir/opcodes: Clear variable names confusion

Having Python and C variables sharing name in the same block of code
makes its understanding a bit confusing. Make it explicit that the
Python bit_size variable refers to the destination bit size.

Suggested-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Signed-off-by: Andres Gomez <agomez at igalia.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>

---

 src/compiler/nir/nir_opcodes.py | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index 7818d9fec60..5d589ee20bf 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -217,8 +217,8 @@ for src_t in [tint, tuint, tfloat, tbool]:
       dst_types = [tint, tuint, tfloat, tbool]
 
    for dst_t in dst_types:
-      for bit_size in type_sizes(dst_t):
-          if bit_size == 16 and dst_t == tfloat and src_t == tfloat:
+      for dst_bit_size in type_sizes(dst_t):
+          if dst_bit_size == 16 and dst_t == tfloat and src_t == tfloat:
               rnd_modes = ['_rtne', '_rtz', '']
               for rnd_mode in rnd_modes:
                   if rnd_mode == '_rtne':
@@ -240,10 +240,13 @@ for src_t in [tint, tuint, tfloat, tbool]:
                   else:
                       conv_expr = "src0"
 
-                  unop_numeric_convert("{0}2{1}{2}{3}".format(src_t[0], dst_t[0],
-                                                              bit_size, rnd_mode),
-                                       dst_t + str(bit_size), src_t, conv_expr)
-          elif bit_size == 32 and dst_t == tfloat and src_t == tfloat:
+                  unop_numeric_convert("{0}2{1}{2}{3}".format(src_t[0],
+                                                              dst_t[0],
+                                                              dst_bit_size,
+                                                              rnd_mode),
+                                       dst_t + str(dst_bit_size),
+                                       src_t, conv_expr)
+          elif dst_bit_size == 32 and dst_t == tfloat and src_t == tfloat:
               conv_expr = """
               if (bit_size > 32 && nir_is_rounding_mode_rtz(execution_mode, 32)) {
                  dst = _mesa_double_to_float_rtz(src0);
@@ -251,12 +254,14 @@ for src_t in [tint, tuint, tfloat, tbool]:
                  dst = src0;
               }
               """
-              unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0], bit_size),
-                                   dst_t + str(bit_size), src_t, conv_expr)
+              unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0],
+                                                       dst_bit_size),
+                                   dst_t + str(dst_bit_size), src_t, conv_expr)
           else:
               conv_expr = "src0 != 0" if dst_t == tbool else "src0"
-              unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0], bit_size),
-                                   dst_t + str(bit_size), src_t, conv_expr)
+              unop_numeric_convert("{0}2{1}{2}".format(src_t[0], dst_t[0],
+                                                       dst_bit_size),
+                                   dst_t + str(dst_bit_size), src_t, conv_expr)
 
 
 # Unary floating-point rounding operations.




More information about the mesa-commit mailing list