diff options
author | Michael Forney <mforney@mforney.org> | 2024-04-27 13:49:52 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-27 13:50:19 -0700 |
commit | 52c17530f2e2dbc61a3bf1d4950c8b9eaeab86de (patch) | |
tree | f14ce75d56736d3bab952b08ffbd418da66baa8d | |
parent | 186b7095eeb84bec527d6d7ac9320776a8b78734 (diff) |
qbe: Temporarily set func->end = func->start in funcalloc
This way way can just use funcinst.
-rw-r--r-- | qbe.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -266,12 +266,15 @@ static void funcalloc(struct func *f, struct decl *d) { enum instkind op; - struct inst *inst; + struct block *end; + struct value *v; unsigned long long size; int align; assert(!d->type->incomplete); assert(d->type->size > 0); + end = f->end; + f->end = f->start; size = d->type->size; align = d->u.obj.align; switch (align) { @@ -282,16 +285,14 @@ funcalloc(struct func *f, struct decl *d) default: size += align - 16; /* fallthrough */ case 16: op = IALLOC16; break; } - inst = mkinst(f, op, ptrclass, mkintconst(size), NULL); - arrayaddptr(&f->start->insts, inst); + v = funcinst(f, op, ptrclass, mkintconst(size), NULL); if (align > 16) { /* TODO: implement alloc32 in QBE and use that instead */ - inst = mkinst(f, IADD, ptrclass, &inst->res, mkintconst(align - 16)); - arrayaddptr(&f->start->insts, inst); - inst = mkinst(f, IAND, ptrclass, &inst->res, mkintconst(-align)); - arrayaddptr(&f->start->insts, inst); + v = funcinst(f, IADD, ptrclass, v, mkintconst(align - 16)); + v = funcinst(f, IAND, ptrclass, v, mkintconst(-align)); } - d->value = &inst->res; + d->value = v; + f->end = end; } static struct value * |