From 6af7ff28679be12f97516283b2009ecf9e603e25 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 3 Jan 2025 02:29:37 +0900 Subject: [PATCH] [qfcc] Ensure processed expressions are dagged GA expressions need to be optimized so things that should cancel out do, and this requires everything to be dagged. Doing so in expr_process gets most of the expressions, and then a few stragglers in proc_field. There might still be some more, but my test scene compiles again. --- tools/qfcc/include/expr.h | 3 ++- tools/qfcc/source/expr_algebra.c | 2 ++ tools/qfcc/source/expr_process.c | 12 ++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index ad7680499..39ab1e1f9 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -124,7 +124,8 @@ typedef struct { ex_list_t list; symtab_t *scope; const expr_t *result; ///< the result of this block if non-void - int is_call; ///< this block exprssion forms a function call + bool is_call; ///< this block exprssion forms a function call + bool no_flush; ///< don't flush edags void *return_addr; ///< who allocated this } ex_block_t; diff --git a/tools/qfcc/source/expr_algebra.c b/tools/qfcc/source/expr_algebra.c index 9ee555fd4..7c61f3530 100644 --- a/tools/qfcc/source/expr_algebra.c +++ b/tools/qfcc/source/expr_algebra.c @@ -2987,6 +2987,7 @@ algebra_assign_expr (const expr_t *dst, const expr_t *src) if (srcType == dstType) { if (summed_extend (src)) { auto block = new_block_expr (0); + block->block.no_flush = true; assign_extend (block, dst, src); return block; } @@ -3005,6 +3006,7 @@ algebra_assign_expr (const expr_t *dst, const expr_t *src) auto sym = get_mvec_sym (dstType); auto block = new_block_expr (0); + block->block.no_flush = true; int memset_base = 0; for (int i = 0; i < layout->count; i++) { if (!c[i]) { diff --git a/tools/qfcc/source/expr_process.c b/tools/qfcc/source/expr_process.c index b63d86146..2a145b614 100644 --- a/tools/qfcc/source/expr_process.c +++ b/tools/qfcc/source/expr_process.c @@ -158,6 +158,7 @@ proc_field (const expr_t *expr, rua_ctx_t *ctx) } if (field) { member = new_deffield_expr (0, field->type, field->def); + member = edag_add_expr (member); return typed_binary_expr (field->type, '.', object, member); } else { member = expr_process (member, ctx); @@ -199,6 +200,7 @@ proc_field (const expr_t *expr, rua_ctx_t *ctx) } member = new_symbol_expr (ivar); } + member = edag_add_expr (member); auto e = new_field_expr (object, member); e->field.type = member->symbol->type; return e; @@ -246,13 +248,16 @@ proc_block (const expr_t *expr, rua_ctx_t *ctx) current_symtab = expr->block.scope; int count = list_count (&expr->block.list); int num_out = 0; + bool flush = !expr->block.no_flush; const expr_t *result = nullptr; const expr_t *in[count + 1]; const expr_t *out[count + 1]; const expr_t *err = nullptr; list_scatter (&expr->block.list, in); for (int i = 0; i < count; i++) { - edag_flush (); + if (flush) { + edag_flush (); + } auto e = expr_process (in[i], ctx); if (is_error (e)) { err = e; @@ -265,7 +270,9 @@ proc_block (const expr_t *expr, rua_ctx_t *ctx) } } } - edag_flush (); + if (flush) { + edag_flush (); + } if (err) { current_symtab = old_scope; return err; @@ -758,6 +765,7 @@ expr_process (const expr_t *expr, rua_ctx_t *ctx) } auto proc = funcs[expr->type] (expr, ctx); + proc = edag_add_expr (proc); if (proc && proc->type == ex_process) { auto func = current_func; if (proc->process.function) {