Module: Mesa Branch: master Commit: e4da24bd24f0af8842d21ef633923bd03447d516 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4da24bd24f0af8842d21ef633923bd03447d516
Author: Alyssa Rosenzweig <[email protected]> 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 <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> 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 */ _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
