compiler/nir: add a nir_b2f() helper
authorIago Toral Quiroga <itoral@igalia.com>
Fri, 14 Dec 2018 07:54:36 +0000 (08:54 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Wed, 2 Jan 2019 06:54:05 +0000 (07:54 +0100)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_builder.h

index 826e549019a5ae4503f0f2a1725428e25db4bf7b..74ecde798d55b5d37cbb92c4914d49bc6791c229 100644 (file)
@@ -985,6 +985,18 @@ nir_i2b(nir_builder *build, nir_ssa_def *i)
    return nir_i2b1(build, i);
 }
 
+static inline nir_ssa_def *
+nir_b2f(nir_builder *build, nir_ssa_def *b, uint32_t bit_size)
+{
+   switch (bit_size) {
+   case 64: return nir_b2f64(build, b);
+   case 32: return nir_b2f32(build, b);
+   case 16: return nir_b2f16(build, b);
+   default:
+      unreachable("Invalid bit-size");
+   };
+}
+
 static inline nir_ssa_def *
 nir_load_barycentric(nir_builder *build, nir_intrinsic_op op,
                      unsigned interp_mode)