commit f8d922b27cf83162f2d84b9b6743a201f01c6237
parent b5a009347e75df5ccb48736e22dff06ab9194658
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Sat, 12 Sep 2015 20:42:20 -0400
hack to enable proper regalloc on calls
I add the dual to dummy uses: dummy defs. They
are compiled to nothing, but help preserving the
invariants I had when writing the register
allocator.
Clearly, there should be a better way.
Diffstat:
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lisc/emit.c b/lisc/emit.c
@@ -192,7 +192,7 @@ eins(Ins i, Fn *fn, FILE *f)
i.arg[0], i.wide, i.to);
break;
case OCopy:
- if (req(i.to, R))
+ if (req(i.to, R) || req(i.arg[0], R))
break;
if (isreg(i.to)
&& i.wide
diff --git a/lisc/isel.c b/lisc/isel.c
@@ -445,7 +445,7 @@ classify(AInfo *a, Typ *t)
static void
selcall(Fn *fn, Ins *i0, Ins *i1)
{
- static int ireg[6] = {RDI, RSI, RDX, RCX, R8, R9};
+ static int ireg[8] = {RDI, RSI, RDX, RCX, R8, R9, R10, R11};
Ins *i;
AInfo *ai, *a;
int nint, nsse, ni, ns, n;
@@ -501,11 +501,9 @@ selcall(Fn *fn, Ins *i0, Ins *i1)
diag("struct-returning function not implemented");
emit(OCopy, i1->wide, i1->to, TMP(RAX), R);
-#if 1
- for (n=0; n<6; n++) {
+ for (n=0; n<8; n++) {
emit(OCopy, 0, R, TMP(ireg[n]), R);
}
-#endif
r = newcon(-(int64_t)stk, fn);
emit(OSAlloc, 0, R, r, R);
emit(OCall, 0, TMP(RAX), i->arg[0], R);
@@ -532,13 +530,15 @@ selcall(Fn *fn, Ins *i0, Ins *i1)
emit(OCopy, i->wide, r, i->arg[0], R);
}
}
+ for (; ni < 8; ni++)
+ emit(OCopy, 1, TMP(ireg[ni]), R, R);
for (i=i0, a=ai; i<i1; i++, a++) {
if (!a->inmem)
continue;
sz = a->size;
- if (a->align == 4 && (stk-sz) % 16)
- sz += 8;
+ if (a->align == 4)
+ sz += (stk-sz) & 15;
stk -= sz;
if (i->op == OArgc) {
assert(!"argc todo 2");