commit 97cfdc309e76fd931bcd923aa836a79d6591400b
parent 7922b259d995397fa97d10cd7b5fb63fe01e9ac5
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 18 Feb 2016 19:40:40 -0500
stop using OXxx1 and use new OLoad
Diffstat:
6 files changed, 34 insertions(+), 53 deletions(-)
diff --git 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
}
}