This is kind of a hack, but it makes vtn_ssa_value insert a load if the
value requested is actually a deref. This shouldn't happen normally but,
thanks to the impedence mismatch of the NIR function parameter model vs.
the SPIR-V model, this can happen for function arguments.
return val;
}
+static struct vtn_ssa_value *
+vtn_variable_load(struct vtn_builder *b, nir_deref_var *src,
+ struct vtn_type *src_type);
+
struct vtn_ssa_value *
vtn_ssa_value(struct vtn_builder *b, uint32_t value_id)
{
case vtn_value_type_ssa:
return val->ssa;
+
+ case vtn_value_type_deref:
+ /* This is needed for function parameters */
+ return vtn_variable_load(b, val->deref, val->deref_type);
+
default:
unreachable("Invalid type for an SSA value");
}