summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-30 11:26:59 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-30 11:26:59 -0400
commit94597f72d9ae6f2ebf308714110e6aab38151481 (patch)
tree58fd079f08ebb4d75a3cf830a9a7790235f028f6
parentfa298cc9e14e1a6a54bf3403a177c34c6b2ca488 (diff)
downloadroux-94597f72d9ae6f2ebf308714110e6aab38151481.tar.gz
finalize the new slot system
There is still the issue that spill is set to
-1 to mark the absence of slot, it does not
play well with zero-initialization at all.
-rw-r--r--lisc/slot.txt42
-rw-r--r--lisc/tools/slot.c141
2 files changed, 0 insertions, 183 deletions
diff --git a/lisc/slot.txt b/lisc/slot.txt
deleted file mode 100644
index 9212cde..0000000
--- a/lisc/slot.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-Plan for new slot computations:
-
-- reverse the allocation of all stack slots
-  so that isel slots go below spill locations
-- the fast allocs must be allocated by decreasing
-  alignment constraints
-- instead of the svec vector, we simply need two
-  numbers that contain the size of both the locals
-  and spills (stk0, stk1)
-- maybe it's time to include small alignments
-- use Tmp.spill == -1 to mark unallocated slots
-- issue: how do we reach for the arguments?
-  1. an answer to that could be proper support
-     for memory references accesses
-  2. a more hackish solution is to keep using
-     negative numbers (but not -1) for argument
-     slots and add a special case in emit.c
-- could be time to clean the tests on the size
-  of allocs (there are two and they are non-
-  uniform)
-
-Layout:
-
-  ---------- rbp = 0 [16]
-  | << padding 1 >>
-  | .. spills   ..
-  |                <- enforce align 16
-  | .. align 16 ..
-  | .. align  8 ..
-  | .. align  4 ..
-  | << padding 0 >>
-  ---------- rsp = 0 [16]
-
-  padding 0: inserted at last minute by the code
-             emitter to respect the ABI
-  padding 1: inserted at the end of spill it can
-             be 4 or 0
-
-Examples:
-
-  if the first local is aligned 4 of size 4, its slot
-  number will be set 0, to emit the proper offset to
diff --git a/lisc/tools/slot.c b/lisc/tools/slot.c
deleted file mode 100644
index caee851..0000000
--- a/lisc/tools/slot.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/*% clang -g -Wall -o # %
- *
- * This is a test program for the slota
- * routine in isel.c, it's a tricky beast
- * so when you modify it you can use this
- * test program to debug your changes.
- *
- * Please make sure it stays in sync.
- */
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-
-#define VARL 1
-
-enum { NAlign = 3 };
-
-static int
-slota(int sz, int al, int *sa)
-{
-	int j, k, s, l, a, ret;
-
-	a = 1 << al;
-	l = sz;
-
-	if (l > a) {
-		/* for large slots, we just
-		 * tack them on the next max
-		 * alignment slot available
-		 * todo, could sophisticate
-		 */
-		l = (l + a-1) & ~(a-1);
-		s = sa[NAlign-1] + l;
-		ret = s;
-		for (j=0, k=1; j<NAlign; j++, k*=2) {
-			l = (l + k-1) & ~(k-1);
-			sa[j] = sa[NAlign-1] + l;
-		}
-	} else {
-		j = al;
-		s = sa[j] + a;
-		ret = s;
-	Shift:
-		if (j < NAlign-1 && s < sa[j+1])
-			/* ........-----------...
-			 * ^       ^          ^
-			 * sa[j]  sa[j]+a    sa[j+1]
-			 *
-			 * we have to skip to the
-			 * next large whole
-			 */
-			s = sa[j+1];
-
-		for (k=0; k<=j; k++)
-			/* move all smaller holes
-			 * that we contain with us
-			 */
-			if (sa[k] == sa[j])
-				sa[k] = s;
-
-		if (j < NAlign-1 && s > sa[j+1]) {
-			/* we were in a bigger hole,
-			 * it needs to shift further
-			 */
-			s = sa[++j] + (a *= 2);
-			goto Shift;
-		}
-	}
-	return ret;
-}
-
-enum { S = 300 };
-
-int
-main(int ac, char *av[])
-{
-	int sa[NAlign] = {0, 0, 2};
-	char stk[S] = {0}, buf[4] = {0};
-	unsigned seed;
-	int i, a, l, s, itr;
-	int ret;
-	FILE *rnd;
-
-	if (ac < 2) {
-		rnd = fopen("/dev/urandom", "r");
-		fread(buf, 4, 1, rnd);
-		seed = *(unsigned *)buf;
-		printf("seed: %u", seed);
-		fclose(rnd);
-	} else
-		seed = atol(av[1]);
-	srand(seed);
-
-	for (itr=1;;itr++) {
-		if ((itr-1) % 4 == 0)
-			printf("\n");
-		do
-			a = rand() % 4;
-		while (a >= NAlign);
-		if ((float)rand()/RAND_MAX < 0.1 && VARL) {
-			l = rand() % (S/20);
-			printf("[(%02d) %02d %d] ", itr, l, a);
-		} else {
-			l = 1 << a;
-			printf("[(%02d) xx %d] ", itr, a);
-		}
-		s = slota(l, a, sa);
-		if (s > S)
-			break;
-		if ((s+2) % (1 << a) != 0) {
-			printf("... FAIL (%d align)\n", s);
-			ret = 1;
-			goto end;
-		}
-		for (i=0; i<l; i++) {
-			s--;
-			assert(s >= 0);
-			if (stk[s]) {
-				printf("... FAIL (%d)\n", s);
-				ret = 1;
-				goto end;
-			}
-			stk[s] = itr;
-		}
-	}
-
-	for (s=0, i=0; i<S; i++)
-		if (!stk[i])
-			s++;
-	printf("... OK (%d)\n", s);
-	ret = 0;
-end:
-	printf("\n");
-	for (i=0; i<S; i++)
-		printf("%02d ", stk[i]);
-	printf("\n\n");
-	for (i=0; i<NAlign; i++)
-		printf("sa[%d] = %d\n", i, sa[i]);
-	exit(ret);
-}