diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-05-01 15:21:25 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-05-01 15:21:25 +0300 |
commit | 1fadcec6d7b26d34edf3b5b3a293deea0edb4139 (patch) | |
tree | 35772b6a024d175558b9c3a0ac76af77781c7bcb /src/lower.c | |
parent | 957da9056c36a5eea15c6058701f7465b31f64a8 (diff) | |
download | fwd-1fadcec6d7b26d34edf3b5b3a293deea0edb4139.tar.gz fwd-1fadcec6d7b26d34edf3b5b3a293deea0edb4139.zip |
+ Still not quite as robust as I'd like (and the autovectorization
problem persists) but at least there shouldn't be a risk of
overwriting a field following the parameters
Diffstat (limited to 'src/lower.c')
-rw-r--r-- | src/lower.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lower.c b/src/lower.c index a31564f..e29365d 100644 --- a/src/lower.c +++ b/src/lower.c @@ -682,6 +682,12 @@ static int lower_param_copy(struct state *state, struct ast *param, FILE *f, siz char *type = lower_type_str(param->t); fprintf(f, " %s a%zu;\n", type, idx); free(type); + + indent(state); + + char *p = mangle2(param); + fprintf(state->code, "ctx->%s = params->a%zu;\n", p, idx); + free(p); return 0; } @@ -707,11 +713,6 @@ static int lower_param_copies(struct state *state, struct ast *params) assert(param_buf); add_type(state, param_buf); - - indent(state); - fprintf(state->code, "*((struct %s_params *)&ctx->%s_start) =" - " *((struct %s_params *)args);\n", - state->prefix, state->prefix, state->prefix); return 0; } @@ -766,6 +767,12 @@ static int lower_proc(struct state *state, struct ast *proc) fprintf(new_state.code, "struct %s_ctx *ctx = &ctx_buf;\n", name); } + if (proc_params(proc)) { + indent(&new_state); + fprintf(new_state.code, "struct %s_params *params = (struct %s_params *)args;\n", + name, name); + } + /* allocates parameter slots */ int ret = lower_params(&new_state, proc_params(proc)); assert(ret == 0); |