summary refs log tree commit diff
path: root/lisc/spill.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-18 19:11:48 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:32 -0400
commit6f09869ea139782fd97e80182a0645891bf548d5 (patch)
tree1de16ac33bbcbefaf64f572ead798cd5e4e3f023 /lisc/spill.c
parent627e45e330d44c55a8dcd8dfe8ebe1b3b091ef9e (diff)
downloadroux-6f09869ea139782fd97e80182a0645891bf548d5.tar.gz
move spill and emit to the new slot system
In emit, I worked a little to make sure that framesz works
when we change the size of the svec array (if we need more
alignments).
Diffstat (limited to 'lisc/spill.c')
-rw-r--r--lisc/spill.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lisc/spill.c b/lisc/spill.c
index a407047..5fa54ca 100644
--- a/lisc/spill.c
+++ b/lisc/spill.c
@@ -141,10 +141,10 @@ bcnt(Bits *b) /* glad I can pull it :) */
 }
 
 extern Ins insb[NIns], *curi; /* shared work buffer */
-static Bits *f;  /* temps to prioritize in registers (for tcmp1) */
-static Tmp *tmp; /* current temporaries (for tcmpX) */
-static int ntmp; /* current # of temps (for limit) */
-static uint ns;  /* current # of spill slots */
+static Bits *f;   /* temps to prioritize in registers (for tcmp1) */
+static Tmp *tmp;  /* current temporaries (for tcmpX) */
+static int ntmp;  /* current # of temps (for limit) */
+static int *svec; /* free slots vector */
 
 static int
 tcmp0(const void *pa, const void *pb)
@@ -170,7 +170,12 @@ slot(int t)
 		diag("spill: cannot spill register");
 	s = tmp[t].spill;
 	if (!s) {
-		s = ++ns;
+		if (tmp[t].type == TWord)
+			s = slota(1, 1, svec);
+		else if (tmp[t].type == TLong)
+			s = slota(2, 2, svec);
+		else
+			diag("spill: unknown type (1)");
 		tmp[t].spill = s;
 	}
 	return SLOT(s);
@@ -189,8 +194,10 @@ store(Ref r, int s)
 {
 	if (tmp[r.val].type == TLong)
 		emit(OStorel, R, r, SLOT(s));
-	else
+	else if (tmp[r.val].type == TWord)
 		emit(OStorew, R, r, SLOT(s));
+	else
+		diag("spill: unknown type (2)");
 }
 
 static int
@@ -293,7 +300,7 @@ spill(Fn *fn)
 	int j, s;
 	Phi *p;
 
-	ns = 0;
+	svec = fn->svec;
 	tmp = fn->tmp;
 	ntmp = fn->ntmp;
 	assert(ntmp < NBit*BITS);