From 0337a7cd80d20c328732362d9ed9aa674b1791c2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 13 Dec 2024 15:02:22 +0900 Subject: [PATCH] [qfcc] Handle integral aliases in spir-v Needed for array indexing using unsigned indices. --- tools/qfcc/source/target_spirv.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index 474f9ef3a..d0b068800 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -1305,6 +1305,19 @@ spirv_compound (const expr_t *e, spirvctx_t *ctx) return id; } +static unsigned +spirv_alias (const expr_t *e, spirvctx_t *ctx) +{ + if (e->alias.offset) { + internal_error (e, "offset alias in spir-v"); + } + if (!is_integral (e->alias.type) + || !is_integral (get_type (e->alias.expr))) { + internal_error (e, "non-integral alias in spir-v"); + } + return spirv_emit_expr (e->alias.expr, ctx); +} + static unsigned spirv_vector (const expr_t *e, spirvctx_t *ctx) { @@ -1739,6 +1752,7 @@ spirv_emit_expr (const expr_t *e, spirvctx_t *ctx) [ex_value] = spirv_value, [ex_vector] = spirv_vector, [ex_compound] = spirv_compound, + [ex_alias] = spirv_alias, [ex_assign] = spirv_assign, [ex_branch] = spirv_branch, [ex_return] = spirv_return,