[qfcc] Support multivector expression to/from functions

The multivector is first assigned to a temporary then passed or returned
as usual.
This commit is contained in:
Bill Currie 2024-02-20 01:51:56 +09:00
parent 389571cbbe
commit 277feaeb03
2 changed files with 22 additions and 11 deletions

View file

@ -2234,7 +2234,7 @@ build_function_call (const expr_t *fexpr, const type_t *ftype, const expr_t *par
}
auto e = arguments[i];
if (e->type == ex_compound) {
if (e->type == ex_compound || e->type == ex_multivec) {
scoped_src_loc (e);
e = initialized_temp_expr (arg_types[i], e);
}
@ -2407,7 +2407,7 @@ return_expr (function_t *f, const expr_t *e)
}
}
if (e->type == ex_compound) {
if (e->type == ex_compound || e->type == ex_multivec) {
scoped_src_loc (e);
e = initialized_temp_expr (ret_type, e);
} else {

View file

@ -358,18 +358,29 @@ assign_elements (expr_t *local_expr, const expr_t *init,
}
expr_t *
initialized_temp_expr (const type_t *type, const expr_t *compound)
initialized_temp_expr (const type_t *type, const expr_t *expr)
{
type = unalias_type (type);
element_chain_t element_chain;
expr_t *temp = new_temp_def_expr (type);
expr_t *block = new_block_expr (0);
//type = unalias_type (type);
expr_t *temp = new_temp_def_expr (type);
block->block.result = temp;
if (expr->type == ex_compound) {
element_chain_t element_chain;
element_chain.head = 0;
element_chain.tail = &element_chain.head;
build_element_chain (&element_chain, type, compound, 0);
build_element_chain (&element_chain, type, expr, 0);
assign_elements (block, temp, &element_chain);
block->block.result = temp;
free_element_chain (&element_chain);
} else if (expr->type == ex_multivec) {
expr = algebra_assign_expr (temp, expr);
append_expr (block, algebra_optimize (expr));
} else {
internal_error (expr, "unexpected expression type: %s",
expr_names[expr->type]);
}
return block;
}