Mesa (master): nir: Add {i2f, u2f, f2i, f2u} helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 7 16:11:43 UTC 2021


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Jan  5 14:43:14 2021 -0500

nir: Add {i2f, u2f, f2i, f2u} helpers

Convenient for bitsize independent lowerings, will be used in the idiv
lowering.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8339>

---

 src/compiler/nir/nir_builder.h | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 13439a8b646..37711abe68c 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -1713,4 +1713,32 @@ nir_f2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
    return nir_convert_to_bit_size(b, src, nir_type_float, bit_size);
 }
 
+static inline nir_ssa_def *
+nir_i2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
+{
+   return nir_type_convert(b, src, nir_type_int,
+         (nir_alu_type) (nir_type_float | bit_size));
+}
+
+static inline nir_ssa_def *
+nir_u2fN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
+{
+   return nir_type_convert(b, src, nir_type_uint,
+         (nir_alu_type) (nir_type_float | bit_size));
+}
+
+static inline nir_ssa_def *
+nir_f2uN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
+{
+   return nir_type_convert(b, src, nir_type_float,
+         (nir_alu_type) (nir_type_uint | bit_size));
+}
+
+static inline nir_ssa_def *
+nir_f2iN(nir_builder *b, nir_ssa_def *src, unsigned bit_size)
+{
+   return nir_type_convert(b, src, nir_type_float,
+         (nir_alu_type) (nir_type_int | bit_size));
+}
+
 #endif /* NIR_BUILDER_H */



More information about the mesa-commit mailing list