summaryrefslogtreecommitdiff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-06 16:35:17 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:30 -0400
commit7dc3e5dcf60d1995857c85773cd15c9904ec9abd (patch)
tree80fdc629c43569d868705622b8139f1628efd03f /lisc
parent27f32f26b32d9dd4138f30a23baaea237984c58c (diff)
downloadroux-7dc3e5dcf60d1995857c85773cd15c9904ec9abd.tar.gz
split cmp in two sizes
Diffstat (limited to 'lisc')
-rw-r--r--lisc/emit.c7
-rw-r--r--lisc/isel.c11
-rw-r--r--lisc/lisc.h3
-rw-r--r--lisc/parse.c3
-rw-r--r--lisc/test/cup.ssa4
5 files changed, 20 insertions, 8 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 665a418..c1fd49a 100644
--- 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
index 8fe7535..31de291 100644
--- 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
index 2fe2614..8f77a54 100644
--- 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
index 0a03abb..6b7767e 100644
--- 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
index 4ffcf29..bd6501e 100644
--- 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