}
}
+struct vtn_value *
+vtn_push_ssa_value(struct vtn_builder *b, uint32_t value_id,
+ struct vtn_ssa_value *ssa)
+{
+ struct vtn_type *type = vtn_get_value_type(b, value_id);
+
+ struct vtn_value *val;
+ if (type->base_type == vtn_base_type_pointer) {
+ val = vtn_push_pointer(b, value_id, vtn_pointer_from_ssa(b, ssa->def, type));
+ } else {
+ val = vtn_push_value(b, value_id, vtn_value_type_ssa);
+ val->ssa = ssa;
+ }
+
+ return val;
+}
+
nir_ssa_def *
vtn_get_nir_ssa(struct vtn_builder *b, uint32_t value_id)
{
"Mismatch between NIR and SPIR-V type.");
struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, type->type);
ssa->def = def;
- return vtn_push_ssa(b, value_id, type, ssa);
+ return vtn_push_ssa_value(b, value_id, ssa);
}
static char *
vtn_fail_with_opcode("unknown composite operation", opcode);
}
- vtn_push_ssa(b, w[2], type, ssa);
+ vtn_push_ssa_value(b, w[2], ssa);
}
static void
vtn_fail("Result type of OpSelect must be a scalar, composite, or pointer");
}
- struct vtn_type *res_type = vtn_get_type(b, w[1]);
- struct vtn_ssa_value *ssa = vtn_nir_select(b,
- vtn_ssa_value(b, w[3]), vtn_ssa_value(b, w[4]), vtn_ssa_value(b, w[5]));
-
- vtn_push_ssa(b, w[2], res_type, ssa);
+ vtn_push_ssa_value(b, w[2],
+ vtn_nir_select(b, vtn_ssa_value(b, w[3]),
+ vtn_ssa_value(b, w[4]),
+ vtn_ssa_value(b, w[5])));
}
static void
vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count)
{
- struct vtn_type *res_type = vtn_get_type(b, w[1]);
struct vtn_function *vtn_callee =
vtn_value(b, w[3], vtn_value_type_function)->func;
struct nir_function *callee = vtn_callee->impl->function;
if (ret_type->base_type == vtn_base_type_void) {
vtn_push_value(b, w[2], vtn_value_type_undef);
} else {
- vtn_push_ssa(b, w[2], res_type, vtn_local_load(b, ret_deref, 0));
+ vtn_push_ssa_value(b, w[2], vtn_local_load(b, ret_deref, 0));
}
}
/* We're a regular SSA value. */
struct vtn_ssa_value *value = vtn_create_ssa_value(b, type->type);
vtn_ssa_value_load_function_param(b, value, type, &b->func_param_idx);
- vtn_push_ssa(b, w[2], type, value);
+ vtn_push_ssa_value(b, w[2], value);
}
break;
}
nir_local_variable_create(b->nb.impl, type->type, "phi");
_mesa_hash_table_insert(b->phi_table, w, phi_var);
- vtn_push_ssa(b, w[2], type,
- vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0));
+ vtn_push_ssa_value(b, w[2],
+ vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0));
return true;
}
}
struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
+struct vtn_value *vtn_push_ssa_value(struct vtn_builder *b, uint32_t value_id,
+ struct vtn_ssa_value *ssa);
nir_ssa_def *vtn_get_nir_ssa(struct vtn_builder *b, uint32_t value_id);
struct vtn_value *vtn_push_nir_ssa(struct vtn_builder *b, uint32_t value_id,
uint32_t value_id,
struct vtn_pointer *ptr);
-struct vtn_value *vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
- struct vtn_type *type, struct vtn_ssa_value *ssa);
-
void
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
uint32_t dst_value_id);
return val;
}
-struct vtn_value *
-vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
- struct vtn_type *type, struct vtn_ssa_value *ssa)
-{
- struct vtn_value *val;
- if (type->base_type == vtn_base_type_pointer) {
- val = vtn_push_pointer(b, value_id, vtn_pointer_from_ssa(b, ssa->def, type));
- } else {
- val = vtn_push_value(b, value_id, vtn_value_type_ssa);
- val->ssa = ssa;
- }
- return val;
-}
-
void
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
uint32_t dst_value_id)
}
}
- vtn_push_ssa(b, w[2], res_type, vtn_variable_load(b, src));
+ vtn_push_ssa_value(b, w[2], vtn_variable_load(b, src));
break;
}