[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.
This commit is contained in:
Bill Currie 2025-01-03 02:29:37 +09:00
parent 34fe4efc9d
commit 6af7ff2867
3 changed files with 14 additions and 3 deletions

View file

@ -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;

View file

@ -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]) {

View file

@ -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) {