summary refs log tree commit diff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-23 11:28:45 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-30 13:20:42 -0400
commitb33febc25cce5c836bad952da472f6a54e777ed8 (patch)
tree342f67f6109a6513991297ab61fdaa4b26b12d1b /lisc
parent82d79017ffff082f2237453ebf8d9f640fa10710 (diff)
downloadroux-b33febc25cce5c836bad952da472f6a54e777ed8.tar.gz
prepare for using memory refs
Diffstat (limited to 'lisc')
-rw-r--r--lisc/isel.c18
-rw-r--r--lisc/lisc.h20
-rw-r--r--lisc/parse.c7
3 files changed, 20 insertions, 25 deletions
diff --git a/lisc/isel.c b/lisc/isel.c
index 9235c83..5bbbab1 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -14,7 +14,6 @@
  */
 
 typedef struct ANum ANum;
-typedef struct Addr Addr;
 typedef struct AClass AClass;
 
 struct ANum {
@@ -22,13 +21,6 @@ struct ANum {
 	Ins *i;
 };
 
-struct Addr {
-	Con offset;
-	Ref base;
-	Ref index;
-	int scale;
-};
-
 static void amatch(Addr *, Ref, ANum *, Fn *, int);
 
 static int
@@ -83,7 +75,7 @@ rslot(Ref r, Fn *fn)
 static void
 sel(Ins i, ANum *an, Fn *fn)
 {
-	static char logS[] = {[1] = 0, [2] = 1, [4] = 2, [8] = 3};
+	static char logS[] = {[2] = 1, [4] = 2, [8] = 3};
 	Ins *i0;
 	Ref r0, r1;
 	int n, x, s, w;
@@ -145,7 +137,7 @@ sel(Ins i, ANum *an, Fn *fn)
 			i.arg[0] = SLOT(cpy[0].s);
 			cpy[0].s = -1;
 		}
-		goto Emit;
+		break;
 	case OXPush:
 	case OCall:
 	case OSAlloc:
@@ -158,6 +150,7 @@ sel(Ins i, ANum *an, Fn *fn)
 	case_OExt:
 Emit:
 		emiti(i);
+#if 0
 		for (n=0; n<2; n++) {
 			/* fuse memory loads into arithmetic
 			 * operations when the sizes match
@@ -183,6 +176,7 @@ Emit:
 				emit(x, 0, R, r1, a.index);
 			}
 		}
+#endif
 		for (n=0; n<2; n++) {
 			/* load constants that do not fit in
 			 * a 32bit signed integer into a
@@ -674,8 +668,8 @@ anumber(ANum *ai, Blk *b, Con *con)
 			continue;
 		a1 = aref(i->arg[0], ai);
 		a2 = aref(i->arg[1], ai);
-		t1 = a1 != 1 & a1 != 2;
-		t2 = a2 != 1 & a2 != 2;
+		t1 = a1 != 1 && a1 != 2;
+		t2 = a2 != 1 && a2 != 2;
 		if (i->op == OAdd) {
 			a = add[n1 = a1][n2 = a2];
 			if (t1 && a < add[0][a2])
diff --git a/lisc/lisc.h b/lisc/lisc.h
index f5283a8..166c18c 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -16,6 +16,7 @@ typedef struct Phi Phi;
 typedef struct Blk Blk;
 typedef struct Tmp Tmp;
 typedef struct Con Con;
+typedef struct Addr Mem;
 typedef struct Fn Fn;
 typedef struct Typ Typ;
 typedef struct Dat Dat;
@@ -178,14 +179,6 @@ enum Op {
 	OXSet,
 	OXSet1 = OXSet + NCmp-1,
 	OXTest,
-	OXScale01, /* memory addressing */
-	OXScale02,
-	OXScale04,
-	OXScale08,
-	OXScale11,
-	OXScale12,
-	OXScale14,
-	OXScale18,
 	NOp
 };
 
@@ -265,12 +258,23 @@ struct Con {
 	int64_t val;
 };
 
+typedef struct Addr Addr;
+
+struct Addr { /* x64 addressing */
+	Con offset;
+	Ref base;
+	Ref index;
+	int scale;
+};
+
 struct Fn {
 	Blk *start;
 	Tmp *tmp;
 	Con *con;
+	Mem *mem;
 	int ntmp;
 	int ncon;
+	int nmem;
 	int nblk;
 	int retty;
 	Blk **rpo;
diff --git a/lisc/parse.c b/lisc/parse.c
index c09f6e3..d0ac325 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -32,11 +32,6 @@ OpDesc opdesc[NOp] = {
 	[OAlloc+1] = { "alloc8",  1 },
 	[OAlloc+2] = { "alloc16", 1 },
 
-#define X(n) [OXScale##n] = { "ofid" #n, 0 }
-	X(01), X(02), X(04), X(08),
-	X(11), X(12), X(14), X(18),
-#undef X
-
 #define X(t) \
 	[OLoad+T##t] = { "load" #t, 0 }, \
 	[OExt+T##t]  = { "ext"  #t, 1 },
@@ -624,8 +619,10 @@ parsefn()
 		err("last block misses jump");
 	fn->tmp = tmp;
 	fn->con = con;
+	fn->mem = vnew(0, sizeof fn->mem[0]);
 	fn->ntmp = ntmp;
 	fn->ncon = ncon;
+	fn->nmem = 0;
 	fn->nblk = nblk;
 	fn->rpo = 0;
 	return fn;