[qfcc] Implement spir-v assignment to vars

Since actual variables are always references, they need to written via
OpStore.
This commit is contained in:
Bill Currie 2024-11-04 12:53:21 +09:00
parent 6e5b13c6f6
commit 5bf9d3c57c
3 changed files with 14 additions and 1 deletions

View file

@ -862,6 +862,8 @@ bool is_math_op (int op) __attribute__((const));
*/
bool is_logic (int op) __attribute__((const));
bool is_deref (const expr_t *e) __attribute__((pure));
bool has_function_call (const expr_t *e) __attribute__((pure));
bool is_function_call (const expr_t *e) __attribute__((pure));

View file

@ -1874,6 +1874,12 @@ is_logic (int op)
return false;
}
bool
is_deref (const expr_t *e)
{
return e->type == ex_uexpr && e->expr.op == '.';
}
bool
has_function_call (const expr_t *e)
{

View file

@ -796,7 +796,12 @@ static unsigned
spirv_assign (const expr_t *e, spirvctx_t *ctx)
{
unsigned src = spirv_emit_expr (e->assign.src, ctx);
unsigned dst = spirv_emit_expr (e->assign.dst, ctx);
unsigned dst = 0;
if (is_deref (e->assign.dst)) {
auto ptr = e->assign.dst->expr.e1;
dst = spirv_emit_expr (ptr, ctx);
}
if (!dst) return src;//FIXME workaround for temp