commit 7dc3e5dcf60d1995857c85773cd15c9904ec9abd
parent 27f32f26b32d9dd4138f30a23baaea237984c58c
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Thu, 6 Aug 2015 16:35:17 -0400
split cmp in two sizes
Diffstat:
5 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/lisc/emit.c b/lisc/emit.c
@@ -43,7 +43,6 @@ static char *rtoa[] = {
static char *rbtoa[] = {
[RXX] = "OH GOD!",
-
[RAX] = "al",
[RCX] = "cl",
[RDX] = "dl",
@@ -166,8 +165,10 @@ eins(Ins i, Fn *fn, FILE *f)
case OXDiv:
eop("idiv", i.arg[0], R, fn, f);
break;
- case OXCmp:
- eop("cmp", i.arg[0], i.arg[1], fn, f);
+ case OXCmpw:
+ case OXCmpl:
+ eop(i.op == OXCmpw ? "cmpl" : "cmpq",
+ i.arg[0], i.arg[1], fn, f);
break;
case ONop:
break;
diff --git a/lisc/isel.c b/lisc/isel.c
@@ -39,6 +39,12 @@ newtmp(int type, Fn *fn)
return t;
}
+static int
+islong(Ref r, Fn *fn)
+{
+ return rtype(r) == RTmp && fn->tmp[r.val].type == TLong;
+}
+
static void
sel(Ins i, Fn *fn)
{
@@ -103,7 +109,10 @@ sel(Ins i, Fn *fn)
}
}
emit(OXSet+c, i.to, R, R);
- emit(OXCmp, R, i.arg[1], r0);
+ if (islong(r0, fn) || islong(i.arg[1], fn))
+ emit(OXCmpl, R, i.arg[1], r0);
+ else
+ emit(OXCmpw, R, i.arg[1], r0);
if (t != -1)
emit(OCopy, r0, i.arg[0], R);
break;
diff --git a/lisc/lisc.h b/lisc/lisc.h
@@ -134,7 +134,8 @@ enum {
OSwap,
OSign,
OXDiv,
- OXCmp,
+ OXCmpw,
+ OXCmpl,
OXSet,
OXSet1 = OXSet + NCmp-1,
OLast
diff --git a/lisc/parse.c b/lisc/parse.c
@@ -23,7 +23,8 @@ OpDesc opdesc[OLast] = {
[OSwap] = { "swap", 2, T },
[OSign] = { "sign", 1, U },
[OXDiv] = { "xdiv", 1, U },
- [OXCmp] = { "xcmp", 2, U },
+ [OXCmpw] = { "xcmpw", 2, U },
+ [OXCmpl] = { "xcmpl", 2, U },
#define X(c) \
[OCmp+C##c] = { "c" #c, 2, U }, \
diff --git a/lisc/test/cup.ssa b/lisc/test/cup.ssa
@@ -2,8 +2,8 @@
@start
@loop
- %n0 =w phi @start -1988, @loop %n1
- %n1 =w add 1, %n0
+ %n0 =l phi @start -1988, @loop %n1
+ %n1 =l add 1, %n0
%cmp =w csle 1991, %n1
jez %cmp, @loop, @end
@end