nir/builder: add bitsize conversion helpers
authorRob Clark <robdclark@chromium.org>
Wed, 3 Jun 2020 19:12:54 +0000 (12:12 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Jun 2020 21:24:13 +0000 (21:24 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5318>

src/compiler/nir/nir_builder.h

index de84bc85784cf83e696b96416ab32eae7f0c7a60..48b22888516abe91fdeb1d80663d5e59aacbab0f 100644 (file)
@@ -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 */