From: Rob Clark Date: Wed, 3 Jun 2020 19:12:54 +0000 (-0700) Subject: nir/builder: add bitsize conversion helpers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0f3255ef0aefaf7a7aca4f7ee8a334cf91bf2c99;p=mesa.git nir/builder: add bitsize conversion helpers Signed-off-by: Rob Clark Reviewed-by: Alyssa Rosenzweig Reviewed-by: Eric Anholt Reviewed-by: Kristian H. Kristensen Part-of: --- diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index de84bc85784..48b22888516 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -1399,4 +1399,28 @@ nir_convert_to_bit_size(nir_builder *b, return nir_build_alu(b, opcode, src, NULL, NULL, NULL); } +static inline nir_ssa_def * +nir_i2iN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) +{ + return nir_convert_to_bit_size(b, src, nir_type_int, bit_size); +} + +static inline nir_ssa_def * +nir_u2uN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) +{ + return nir_convert_to_bit_size(b, src, nir_type_uint, bit_size); +} + +static inline nir_ssa_def * +nir_b2bN(nir_builder *b, nir_ssa_def *src, unsigned bit_size) +{ + return nir_convert_to_bit_size(b, src, nir_type_bool, bit_size); +} + +static inline nir_ssa_def * +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); +} + #endif /* NIR_BUILDER_H */