summary refs log tree commit diff
path: root/lisc
diff options
context:
space:
mode:
Diffstat (limited to 'lisc')
-rw-r--r--lisc/emit.c7
-rw-r--r--lisc/isel.c29
-rw-r--r--lisc/lisc.h16
-rw-r--r--lisc/mem.c23
-rw-r--r--lisc/parse.c5
-rw-r--r--lisc/spill.c7
6 files changed, 34 insertions, 53 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index e081565..0485b65 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -54,7 +54,10 @@ static struct {
 	{ OStoreb, Ka, "movb %B0, %M1" },
 	{ OStores, Ka, "movss %S0, %M1" },
 	{ OStored, Ka, "movsd %D0, %M1" },
-	{ OLoadl,  Kl, "movq %M0, %=" },
+	{ OLoad,   Kl, "movq %M0, %=" },
+	{ OLoad,   Kw, "movl %M0, %W=" },
+	{ OLoad,   Ks, "movss %M0, %S=" },
+	{ OLoad,   Kd, "movsd %M0, %D=" },
 	{ OLoadsw, Kl, "movslq %M0, %L=" },
 	{ OLoadsw, Kw, "movl %M0, %W=" },
 	{ OLoaduw, Ki, "movl %M0, %W=" },
@@ -62,8 +65,6 @@ static struct {
 	{ OLoaduh, Ki, "movzw%k %M0, %=" },
 	{ OLoadsb, Ki, "movsb%k %M0, %=" },
 	{ OLoadub, Ki, "movzb%k %M0, %=" },
-	{ OLoads,  Ks, "movss %M0, %S=" },
-	{ OLoadd,  Kd, "movsd %M0, %D=" },
 	{ OExtsw,  Kl, "movslq %W0, %L=" },
 	{ OExtuw,  Kl, "movl %W0, %W=" },
 	{ OExtsh,  Ki, "movsw%k %H0, %=" },
diff --git a/lisc/isel.c b/lisc/isel.c
index b59fe55..c2d92d1 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -117,15 +117,12 @@ argcls(Ins *i, int n)
 	case OStorel:
 		return Kl;
 	default:
-		if ((OCmpw <= i->op && i->op <= OCmpw1)
-		|| (OCmpl <= i->op && i->op <= OCmpl1)
-		|| (OCmps <= i->op && i->op <= OCmps1)
-		|| (OCmpd <= i->op && i->op <= OCmpd1))
+		if (OCmpw <= i->op && i->op <= OCmpd1)
 			goto Invalid;
-		if (OLoad <= i->op && i->op <= OLoad1)
+		if (isload(i->op))
 			return Kl;
-		if (OExt <= i->op && i->op <= OExt1)
-			return i->op == OExtl ? Kl : Kw;
+		if (isext(i->op))
+			return Kw;
 		return i->cls;
 	}
 }
@@ -313,9 +310,9 @@ Emit:
 		}
 		break;
 	default:
-		if (OExt <= i.op && i.op <= OExt1)
+		if (isext(i.op))
 			goto case_OExt;
-		if (OLoad <= i.op && i.op <= OLoad1)
+		if (isload(i.op))
 			goto case_OLoad;
 		if (iscmp(i.op, &kc, &x)) {
 			if (rtype(i.arg[0]) == RCon)
@@ -344,9 +341,7 @@ flagi(Ins *i0, Ins *i)
 			||  (OCmps <= i->op && i->op <= OCmps1)
 			||  (OCmpd <= i->op && i->op <= OCmpd1))
 				return i;
-			if (OExt <= i->op && i->op <= OExt1)
-				continue;
-			if (OLoad <= i->op && i->op <= OLoad1)
+			if (isext(i->op) || isload(i->op))
 				continue;
 			return 0;
 		case OAdd:  /* flag-setting */
@@ -626,16 +621,10 @@ selcall(Fn *fn, Ins *i0, Ins *i1)
 			if (a->size > 8) {
 				r2 = rarg(a->cls[1], &ni, &ns);
 				r = newtmp("isel", fn);
-				if (a->cls[1] == Kl)              /* fixme, add OLoad? */
-					emit(OLoadl, Kl, r2, r, R);
-				else
-					emit(OLoadd, Kd, r2, r, R);
+				emit(OLoad, a->cls[1], r2, r, R);
 				emit(OAdd, Kl, r, i->arg[1], getcon(8, fn));
 			}
-			if (a->cls[0] == Kl)                      /* fixme! */
-				emit(OLoadl, Kl, r1, i->arg[1], R);
-			else
-				emit(OLoadd, Kd, r1, i->arg[1], R);
+			emit(OLoad, a->cls[0], r1, i->arg[1], R);
 		} else
 			emit(OCopy, i->cls, r1, i->arg[0], R);
 	}
diff --git a/lisc/lisc.h b/lisc/lisc.h
index 2762eb7..9eb541a 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -230,28 +230,22 @@ enum Op {
 	OStorew,
 	OStoreh,
 	OStoreb,
-#define OStore  OStored
-#define OStore1 OStoreb
-	OLoadl,  /* needs to match OExt (mem.c) */
-	OLoadsw,
+#define isstore(o) (OStored <= o && o <= OStoreb)
+	OLoadsw,  /* needs to match OExt (mem.c) */
 	OLoaduw,
 	OLoadsh,
 	OLoaduh,
 	OLoadsb,
 	OLoadub,
-	OLoadd,
-	OLoads,
-#define OLoad  OLoadl
-#define OLoad1 OLoads
-	OExtl,
+	OLoad,
+#define isload(o) (OLoadsw <= o && o <= OLoad)
 	OExtsw,
 	OExtuw,
 	OExtsh,
 	OExtuh,
 	OExtsb,
 	OExtub,
-#define OExt  OExtl
-#define OExt1 OExtub
+#define isext(o) (OExtsw <= o && o <= OExtub)
 
 	OAlloc,
 	OAlloc1 = OAlloc + NAlign-1,
diff --git a/lisc/mem.c b/lisc/mem.c
index 75eacb8..914f181 100644
--- a/lisc/mem.c
+++ b/lisc/mem.c
@@ -29,9 +29,8 @@ memopt(Fn *fn)
 			if (u->type != UIns)
 				goto NextIns;
 			l = u->u.ins;
-			if (l->op < OLoadl || l->op > OLoadub)
-			if (l->op < OStorel || l->op > OStoreb
-			|| req(i->to, l->arg[0]))
+			if (!isload(l->op)
+			&& (!isstore(l->op) || req(i->to, l->arg[0])))
 				goto NextIns;
 		}
 		/* get rid of the alloc and replace uses */
@@ -40,8 +39,15 @@ memopt(Fn *fn)
 		ue = &t->use[t->nuse];
 		for (u=t->use; u!=ue; u++) {
 			l = u->u.ins;
-			if (OStorel <= l->op && l->op <= OStoreb) {
-				l->cls = l->op == OStorel ? Kl : Kw;
+			if (isstore(l->op)) {
+				if (l->op == OStores)
+					l->cls = Kd;
+				else if (l->op == OStored)
+					l->cls = Kd;
+				else if (l->op == OStorel)
+					l->cls = Kl;
+				else
+					l->cls = Kw;
 				l->op = OCopy;
 				l->to = l->arg[1];
 				l->arg[1] = R;
@@ -51,8 +57,7 @@ memopt(Fn *fn)
 				/* try to turn loads into copies so we
 				 * can eliminate them later */
 				switch(l->op) {
-				case OLoadl:
-					l->cls = Kl;
+				case OLoad:
 					l->op = OCopy;
 					break;
 				case OLoadsw:
@@ -62,8 +67,8 @@ memopt(Fn *fn)
 					break;
 				default:
 					/* keep l->cls */
-					a = l->op - OLoad;
-					l->op = OExt + a;
+					a = l->op - OLoadsw;
+					l->op = OExtsw + a;
 					break;
 				}
 		}
diff --git a/lisc/parse.c b/lisc/parse.c
index 3de8e5e..da82d0a 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -15,16 +15,13 @@ OpDesc opdesc[NOp] = {
 	[OStorew] = { "storew", 0 },
 	[OStoreh] = { "storeh", 0 },
 	[OStoreb] = { "storeb", 0 },
-	[OLoadl]  = { "loadl",  0 },
+	[OLoad]   = { "load",   0 },
 	[OLoadsw] = { "loadsw", 0 },
 	[OLoaduw] = { "loaduw", 0 },
 	[OLoadsh] = { "loadsh", 0 },
 	[OLoaduh] = { "loaduh", 0 },
 	[OLoadsb] = { "loadsb", 0 },
 	[OLoadub] = { "loadub", 0 },
-	[OLoadd]  = { "loadd",  0 },
-	[OLoads]  = { "loads",  0 },
-	[OExtl]   = { "extl",   0 }, /* buu... fix mem.c */
 	[OExtsw]  = { "extsw",  0 },
 	[OExtuw]  = { "extuw",  0 },
 	[OExtsh]  = { "extsh",  0 },
diff --git a/lisc/spill.c b/lisc/spill.c
index b12522b..06c748d 100644
--- a/lisc/spill.c
+++ b/lisc/spill.c
@@ -242,17 +242,12 @@ sethint(Bits *u, ulong r)
 static void
 reloads(Bits *u, Bits *v)
 {
-	/* fixme, oooh really... */
-	static int kload[] = {
-		[Kw] = OLoadsw, [Kl] = OLoadl,
-		[Ks] = OLoads, [Kd] = OLoadd
-	};
 	int t, k;
 
 	for (t=Tmp0; t<ntmp; t++)
 		if (BGET(*u, t) && !BGET(*v, t)) {
 			k = tmp[t].cls;
-			emit(kload[k], k, TMP(t), slot(t), R);
+			emit(OLoad, k, TMP(t), slot(t), R);
 		}
 }