+
+void
+vtn_handle_bitcast(struct vtn_builder *b, const uint32_t *w, unsigned count)
+{
+ vtn_assert(count == 4);
+ /* From the definition of OpBitcast in the SPIR-V 1.2 spec:
+ *
+ * "If Result Type has the same number of components as Operand, they
+ * must also have the same component width, and results are computed per
+ * component.
+ *
+ * If Result Type has a different number of components than Operand, the
+ * total number of bits in Result Type must equal the total number of
+ * bits in Operand. Let L be the type, either Result Type or Operand’s
+ * type, that has the larger number of components. Let S be the other
+ * type, with the smaller number of components. The number of components
+ * in L must be an integer multiple of the number of components in S.
+ * The first component (that is, the only or lowest-numbered component)
+ * of S maps to the first components of L, and so on, up to the last
+ * component of S mapping to the last components of L. Within this
+ * mapping, any single component of S (mapping to multiple components of
+ * L) maps its lower-ordered bits to the lower-numbered components of L."
+ */
+
+ struct vtn_type *type = vtn_get_type(b, w[1]);
+ struct nir_ssa_def *src = vtn_get_nir_ssa(b, w[3]);
+
+ vtn_fail_if(src->num_components * src->bit_size !=
+ glsl_get_vector_elements(type->type) * glsl_get_bit_size(type->type),
+ "Source and destination of OpBitcast must have the same "
+ "total number of bits");
+ nir_ssa_def *val =
+ nir_bitcast_vector(&b->nb, src, glsl_get_bit_size(type->type));
+ vtn_push_nir_ssa(b, w[2], val);
+}