summary refs log tree commit diff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-12 20:42:20 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:33 -0400
commitf8d922b27cf83162f2d84b9b6743a201f01c6237 (patch)
tree596da3bcf6f938253554be5078f45f91fd19b11a /lisc
parentb5a009347e75df5ccb48736e22dff06ab9194658 (diff)
downloadroux-f8d922b27cf83162f2d84b9b6743a201f01c6237.tar.gz
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 (limited to 'lisc')
-rw-r--r--lisc/emit.c2
-rw-r--r--lisc/isel.c12
2 files changed, 7 insertions, 7 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 691dc25..935b2e6 100644
--- 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
index e3c3591..9295d49 100644
--- 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");