From 74637fffbc276c259d9d93d022ea0b50a9179862 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 12 Dec 2024 11:19:24 +0900 Subject: [PATCH] [qfcc] Implement the actual return from inline It's just a jump to a label at the end of the block, but it's enough for now as it takes care of the assumption that the return is the last expression in the inlined function. --- tools/qfcc/source/expr_call.c | 4 ++-- tools/qfcc/source/target_spirv.c | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/qfcc/source/expr_call.c b/tools/qfcc/source/expr_call.c index 478c6c021..c9fdf8193 100644 --- a/tools/qfcc/source/expr_call.c +++ b/tools/qfcc/source/expr_call.c @@ -305,8 +305,8 @@ build_inline_call (symbol_t *fsym, const type_t *ftype, } append_expr (call, expr); - func->return_label = nullptr;//new_label_expr (); - //append_expr (call, func->return_label); + func->return_label = new_label_expr (); + append_expr (call, func->return_label); func->return_imp = inline_return_expr; diff --git a/tools/qfcc/source/target_spirv.c b/tools/qfcc/source/target_spirv.c index ef0808e8d..474f9ef3a 100644 --- a/tools/qfcc/source/target_spirv.c +++ b/tools/qfcc/source/target_spirv.c @@ -1067,6 +1067,14 @@ spirv_uexpr (const expr_t *e, spirvctx_t *ctx) return id; } +static unsigned +spirv_label (const expr_t *e, spirvctx_t *ctx) +{ + auto label = &e->label; + unsigned id = spirv_label_id (label, ctx); + return spirv_LabelId (id, ctx); +} + static unsigned spirv_block (const expr_t *e, spirvctx_t *ctx) { @@ -1722,6 +1730,7 @@ static unsigned spirv_emit_expr (const expr_t *e, spirvctx_t *ctx) { static spirv_expr_f funcs[ex_count] = { + [ex_label] = spirv_label, [ex_block] = spirv_block, [ex_expr] = spirv_expr, [ex_uexpr] = spirv_uexpr,