diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index efdc189d7..f4fe472de 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -2579,6 +2579,9 @@ address_expr (const expr_t *e1, const type_t *t) break; } return error (e1, "invalid type for unary &"); + case ex_field: + e = new_address_expr (e1->field.type, e1, nullptr); + break; case ex_expr: if (e1->expr.op == '.') { e = new_address_expr (e1->expr.type, diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index 337365d7f..354d424d3 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -1571,6 +1571,22 @@ spirv_access_chain (const expr_t *e, spirvctx_t *ctx, return id; } +static unsigned +spirv_address (const expr_t *e, spirvctx_t *ctx) +{ + auto lvalue = e->address.lvalue; + if (lvalue->type != ex_field && lvalue->type != ex_array) { + internal_error (e, "not field or array"); + } + if (e->address.offset) { + internal_error (e, "offset on address"); + } + const type_t *res_type; + const type_t *acc_type; + unsigned id = spirv_access_chain (lvalue, ctx, &res_type, &acc_type); + return id; +} + static unsigned spirv_assign (const expr_t *e, spirvctx_t *ctx) { @@ -1958,6 +1974,7 @@ spirv_emit_expr (const expr_t *e, spirvctx_t *ctx) [ex_vector] = spirv_vector, [ex_compound] = spirv_compound, [ex_alias] = spirv_alias, + [ex_address] = spirv_address, [ex_assign] = spirv_assign, [ex_branch] = spirv_branch, [ex_return] = spirv_return,