spirv: Refactor vtn_push_ssa
We rename it to vtn_push_ssa_value, move it to spirv_to_nir, and remove the unnecessary type parameter. Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5278>
This commit is contained in:
@@ -302,6 +302,23 @@ 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)
|
||||||
|
{
|
||||||
|
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 *
|
nir_ssa_def *
|
||||||
vtn_get_nir_ssa(struct vtn_builder *b, uint32_t value_id)
|
vtn_get_nir_ssa(struct vtn_builder *b, uint32_t value_id)
|
||||||
{
|
{
|
||||||
@@ -323,7 +340,7 @@ vtn_push_nir_ssa(struct vtn_builder *b, uint32_t value_id, nir_ssa_def *def)
|
|||||||
"Mismatch between NIR and SPIR-V type.");
|
"Mismatch between NIR and SPIR-V type.");
|
||||||
struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, type->type);
|
struct vtn_ssa_value *ssa = vtn_create_ssa_value(b, type->type);
|
||||||
ssa->def = def;
|
ssa->def = def;
|
||||||
return vtn_push_ssa(b, value_id, type, ssa);
|
return vtn_push_ssa_value(b, value_id, ssa);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@@ -3606,7 +3623,7 @@ vtn_handle_composite(struct vtn_builder *b, SpvOp opcode,
|
|||||||
vtn_fail_with_opcode("unknown composite operation", opcode);
|
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
|
static void
|
||||||
@@ -4733,11 +4750,10 @@ vtn_handle_select(struct vtn_builder *b, SpvOp opcode,
|
|||||||
vtn_fail("Result type of OpSelect must be a scalar, composite, or pointer");
|
vtn_fail("Result type of OpSelect must be a scalar, composite, or pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vtn_type *res_type = vtn_get_type(b, w[1]);
|
vtn_push_ssa_value(b, w[2],
|
||||||
struct vtn_ssa_value *ssa = vtn_nir_select(b,
|
vtn_nir_select(b, vtn_ssa_value(b, w[3]),
|
||||||
vtn_ssa_value(b, w[3]), vtn_ssa_value(b, w[4]), vtn_ssa_value(b, w[5]));
|
vtn_ssa_value(b, w[4]),
|
||||||
|
vtn_ssa_value(b, w[5])));
|
||||||
vtn_push_ssa(b, w[2], res_type, ssa);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -185,7 +185,6 @@ void
|
|||||||
vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
|
vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
|
||||||
const uint32_t *w, unsigned count)
|
const uint32_t *w, unsigned count)
|
||||||
{
|
{
|
||||||
struct vtn_type *res_type = vtn_get_type(b, w[1]);
|
|
||||||
struct vtn_function *vtn_callee =
|
struct vtn_function *vtn_callee =
|
||||||
vtn_value(b, w[3], vtn_value_type_function)->func;
|
vtn_value(b, w[3], vtn_value_type_function)->func;
|
||||||
struct nir_function *callee = vtn_callee->impl->function;
|
struct nir_function *callee = vtn_callee->impl->function;
|
||||||
@@ -238,7 +237,7 @@ vtn_handle_function_call(struct vtn_builder *b, SpvOp opcode,
|
|||||||
if (ret_type->base_type == vtn_base_type_void) {
|
if (ret_type->base_type == vtn_base_type_void) {
|
||||||
vtn_push_value(b, w[2], vtn_value_type_undef);
|
vtn_push_value(b, w[2], vtn_value_type_undef);
|
||||||
} else {
|
} 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +350,7 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||||||
/* We're a regular SSA value. */
|
/* We're a regular SSA value. */
|
||||||
struct vtn_ssa_value *value = vtn_create_ssa_value(b, type->type);
|
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_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;
|
break;
|
||||||
}
|
}
|
||||||
@@ -988,7 +987,7 @@ vtn_handle_phis_first_pass(struct vtn_builder *b, SpvOp opcode,
|
|||||||
nir_local_variable_create(b->nb.impl, type->type, "phi");
|
nir_local_variable_create(b->nb.impl, type->type, "phi");
|
||||||
_mesa_hash_table_insert(b->phi_table, w, phi_var);
|
_mesa_hash_table_insert(b->phi_table, w, phi_var);
|
||||||
|
|
||||||
vtn_push_ssa(b, w[2], type,
|
vtn_push_ssa_value(b, w[2],
|
||||||
vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0));
|
vtn_local_load(b, nir_build_deref_var(&b->nb, phi_var), 0));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -784,6 +784,8 @@ vtn_get_type(struct vtn_builder *b, uint32_t value_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
|
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);
|
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,
|
struct vtn_value *vtn_push_nir_ssa(struct vtn_builder *b, uint32_t value_id,
|
||||||
@@ -793,9 +795,6 @@ struct vtn_value *vtn_push_pointer(struct vtn_builder *b,
|
|||||||
uint32_t value_id,
|
uint32_t value_id,
|
||||||
struct vtn_pointer *ptr);
|
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
|
void
|
||||||
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
|
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
|
||||||
uint32_t dst_value_id);
|
uint32_t dst_value_id);
|
||||||
|
@@ -76,20 +76,6 @@ vtn_push_pointer(struct vtn_builder *b, uint32_t value_id,
|
|||||||
return val;
|
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
|
void
|
||||||
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
|
vtn_copy_value(struct vtn_builder *b, uint32_t src_value_id,
|
||||||
uint32_t dst_value_id)
|
uint32_t dst_value_id)
|
||||||
@@ -2621,7 +2607,7 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user