summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-07-22 07:09:12 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:29 -0400
commit4f4d4cce6f513a7fd3fdd2e0f6e2a795cfb9bb71 (patch)
treeef820a5e28dca38d48de66b413472fbdfd18953e
parent0d1595c770d896074f59a07aff8340902c1d8a12 (diff)
downloadroux-4f4d4cce6f513a7fd3fdd2e0f6e2a795cfb9bb71.tar.gz
rework spilling code for jump arguments
-rw-r--r--lisc/lisc.h3
-rw-r--r--lisc/spill.c20
2 files changed, 13 insertions, 10 deletions
diff --git a/lisc/lisc.h b/lisc/lisc.h
index e7e0cc8..941751d 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -32,7 +32,8 @@ enum {
 	R13,
 	R14,
 	R15,
-	NReg = R15 - RAX + 1
+	// NReg = R15 - RAX + 1
+	NReg = 4 /* for test purposes */
 };
 
 enum {
diff --git a/lisc/spill.c b/lisc/spill.c
index 109bc2f..ad105e1 100644
--- a/lisc/spill.c
+++ b/lisc/spill.c
@@ -217,7 +217,7 @@ void
 spill(Fn *fn)
 {
 	Blk *b, *s1, *s2, *hd;
-	int n, z, k, pl;
+	int n, z, pl;
 	Bits v, w;
 	Ins *i;
 	int j;
@@ -234,8 +234,6 @@ spill(Fn *fn)
 		 * the end of the block (put them in v) */
 		s1 = b->s1;
 		s2 = b->s2;
-		// k = NReg - !req(b->jmp.arg, R);
-		k = 4 - !req(b->jmp.arg, R);
 		v = (Bits){{0}};
 		hd = 0;
 		if (s1 && s1->id <= n)
@@ -249,16 +247,16 @@ spill(Fn *fn)
 			for (z=0; z<BITS; z++)
 				v.t[z] = hd->gen.t[z] & b->out.t[z];
 			j = bcnt(&v);
-			if (j < k) {
+			if (j < NReg) {
 				w = b->out;
 				for (z=0; z<BITS; z++)
 					w.t[z] &= ~v.t[z];
 				j = bcnt(&w);   /* live through */
-				w = limit(&w, k - (pl - j), 0);
+				w = limit(&w, NReg - (pl - j), 0);
 				for (z=0; z<BITS; z++)
 					v.t[z] |= w.t[z];
-			} else if (j > k)
-				v = limit(&v, k, 0);
+			} else if (j > NReg)
+				v = limit(&v, NReg, 0);
 		} else if (s1) {
 			v = s1->in;
 			w = s1->in;
@@ -273,9 +271,13 @@ spill(Fn *fn)
 			}
 			assert(bcnt(&w) <= NReg);
 			assert(bcnt(&w) <= bcnt(&v));
-			v = limit(&v, k, &w);
+			v = limit(&v, NReg, &w);
 		}
-		assert(bcnt(&v) <= k);
+		assert(bcnt(&v) <= NReg);
+		if (rtype(b->jmp.arg) == RSym
+		&& !BGET(v, b->jmp.arg.val)
+		&& bcnt(&v) == NReg)
+			v = limit(&v, NReg-1, 0);
 		b->out = v;
 
 		/* 2. process the block instructions */