aboutsummaryrefslogtreecommitdiffhomepage
path: root/amd64/isel.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-14 15:05:43 +0200
committerlemon <lsof@mailbox.org>2023-06-14 15:05:43 +0200
commit782d4e9df0363ca9f64d8b92a3d6952d552f13a5 (patch)
tree8c71e107a8c0b54f53c2c94d053ad4cc1b7a441d /amd64/isel.c
parent8d8cf6584bf4081b54cd91fcaa42578cbd794440 (diff)
add spilling for function calls, misc fixes
Diffstat (limited to 'amd64/isel.c')
-rw-r--r--amd64/isel.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/amd64/isel.c b/amd64/isel.c
index 6d4c87e..ff0968c 100644
--- a/amd64/isel.c
+++ b/amd64/isel.c
@@ -71,21 +71,21 @@ ascale(struct addr *addr, union ref a, union ref b)
}
static bool
-aadd(struct addr *addr, union ref r, bool rec)
+aadd(struct addr *addr, union ref r)
{
if (r.t == RTMP) {
struct instr *ins = &instrtab[r.i];
if (ins->op == Oadd) {
- if (!aadd(addr, ins->l, rec)) return 0;
- if (!aadd(addr, ins->r, rec)) return 0;
+ if (!aadd(addr, ins->l)) goto Ref;
+ if (!aadd(addr, ins->r)) goto Ref;
ins->skip = 1;
} else if (ins->op == Oshl) {
- if (!ascale(addr, ins->l, ins->r)) return 0;
+ if (!ascale(addr, ins->l, ins->r)) goto Ref;
ins->skip = 1;
- } else if (!rec && ins->op == Ocopy && ins->l.t == RMORE) {
+ } else if (ins->op == Ocopy && ins->l.t == RMORE) {
struct addr save = *addr, *addr2 = &addrht[ins->l.i];
- if ((!addr2->base.t || aadd(addr, addr2->base, 1))
+ if ((!addr2->base.t || aadd(addr, addr2->base))
&& acon(addr, mkintcon(KI4, addr2->disp))
&& (!addr2->index.t || ascale(addr, addr2->index, mkref(RICON, addr2->shift))))
{
@@ -94,6 +94,9 @@ aadd(struct addr *addr, union ref r, bool rec)
*addr = save;
goto Ref;
}
+ } else if (ins->op == Ocopy) {
+ if (!aadd(addr, ins->l)) goto Ref;
+ ins->skip = 1;
} else goto Ref;
} else if (iscon(r)) {
return acon(addr, r);
@@ -117,7 +120,7 @@ fuseaddr(struct function *fn, union ref *r)
if (r->t == RMORE) return 1;
if (r->t != RTMP) return 0;
- if (!aadd(&addr, *r, 0)) return 0;
+ if (!aadd(&addr, *r)) return 0;
*r = mkaddr(addr);
return 1;
@@ -272,7 +275,6 @@ amd64_isel(struct function *fn)
sel(fn, &instrtab[blk->ins.p[i]], blk, &i);
}
} while ((blk = blk->lnext) != fn->entry);
- fn->stksiz = alignup(fn->stksiz, 16);
if (ccopt.dbg.i) {
efmt("<< After isel >>\n");