[Mesa-dev] [PATCH v2 09/29] nir: create new conversion opcodes with floating point rounding modes

Samuel Iglesias Gonsálvez siglesias at igalia.com
Tue Dec 18 10:34:04 UTC 2018


It adds round-towards-zero and round-to-nearest-even opcodes for
floating point conversions.

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
 src/compiler/nir/nir_opcodes.py   | 2 +-
 src/compiler/nir/nir_opcodes_c.py | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py
index d32005846a6..1274d29a04e 100644
--- a/src/compiler/nir/nir_opcodes.py
+++ b/src/compiler/nir/nir_opcodes.py
@@ -212,7 +212,7 @@ for src_t in [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:
+          if src_t == tfloat and dst_t == tfloat:
               rnd_modes = ['_rtne', '_rtz', '']
               for rnd_mode in rnd_modes:
                   unop_convert("{0}2{1}{2}{3}".format(src_t[0], dst_t[0],
diff --git a/src/compiler/nir/nir_opcodes_c.py b/src/compiler/nir/nir_opcodes_c.py
index 017c8b7ea9a..e3548bd6e21 100644
--- a/src/compiler/nir/nir_opcodes_c.py
+++ b/src/compiler/nir/nir_opcodes_c.py
@@ -76,7 +76,7 @@ nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd
                switch (dst_bit_size) {
 %                 for dst_bits in type_sizes(dst_t):
                   case ${dst_bits}:
-%                    if src_t == 'float' and dst_t == 'float' and dst_bits == 16:
+%                    if src_t == 'float' and dst_t == 'float':
                      switch(rnd) {
 %                       for rnd_t in [('rtne', '_rtne'), ('rtz', '_rtz'), ('undef', '')]:
                         case nir_rounding_mode_${rnd_t[0]}:
@@ -84,7 +84,7 @@ nir_type_conversion_op(nir_alu_type src, nir_alu_type dst, nir_rounding_mode rnd
                                                                    dst_bits, rnd_t[1])};
 %                       endfor
                         default:
-                           unreachable("Invalid 16-bit nir rounding mode");
+                           unreachable("Invalid ${dst_bits}-bit nir rounding mode");
                      }
 %                    else:
                      assert(rnd == nir_rounding_mode_undef);
-- 
2.19.1



More information about the mesa-dev mailing list