nir/builder: Add nir_b2i
authorConnor Abbott <cwabbott0@gmail.com>
Fri, 2 Aug 2019 12:56:20 +0000 (14:56 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 6 Aug 2019 22:03:10 +0000 (18:03 -0400)
Same as nir_b2f but for integers.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/compiler/nir/nir_builder.h

index 2fed76106eb4c2939131916a7213d65c4fb406b1..0f300aef15563b9a1a74b942b742a403acf45317 100644 (file)
@@ -1166,6 +1166,18 @@ nir_b2f(nir_builder *build, nir_ssa_def *b, uint32_t bit_size)
    };
 }
 
+static inline nir_ssa_def *
+nir_b2i(nir_builder *build, nir_ssa_def *b, uint32_t bit_size)
+{
+   switch (bit_size) {
+   case 64: return nir_b2i64(build, b);
+   case 32: return nir_b2i32(build, b);
+   case 16: return nir_b2i16(build, b);
+   case 8:  return nir_b2i8(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)