summaryrefslogtreecommitdiff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-16 11:18:28 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-03-16 11:18:28 -0400
commitdb6f7ad72dda70f5dd3b34a3faea1e08537e77be (patch)
treed3bbfd3bc9b0a1e4bf88e4a463d559b2f459fc51 /lisc
parent567c18398f7c35ec3527a6a1245a95774dcbf0a2 (diff)
downloadroux-db6f7ad72dda70f5dd3b34a3faea1e08537e77be.tar.gz
add shift instructions
Diffstat (limited to 'lisc')
-rw-r--r--lisc/emit.c3
-rw-r--r--lisc/isel.c11
-rw-r--r--lisc/lisc.h3
-rw-r--r--lisc/parse.c3
4 files changed, 20 insertions, 0 deletions
diff --git a/lisc/emit.c b/lisc/emit.c
index 9b2af4e..4eeee8d 100644
--- a/lisc/emit.c
+++ b/lisc/emit.c
@@ -46,6 +46,9 @@ static struct {
{ OAnd, Ki, "+and%k %1, %=" },
{ OOr, Ki, "+or%k %1, %=" },
{ OXor, Ki, "+xor%k %1, %=" },
+ { OSar, Ki, "-sar%k %B1, %=" },
+ { OShr, Ki, "-shr%k %B1, %=" },
+ { OShl, Ki, "-shl%k %B1, %=" },
{ OMul, Ki, "+imul%k %1, %=" },
{ OMul, Ks, "+mulss %1, %=" }, /* fixme */
{ OMul, Kd, "+mulsd %1, %=" },
diff --git a/lisc/isel.c b/lisc/isel.c
index 6dfc06f..da7e946 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -240,6 +240,17 @@ sel(Ins i, ANum *an, Fn *fn)
if (rtype(i.arg[1]) == RCon)
emit(OCopy, k, r0, i.arg[1], R);
break;
+ case OSar:
+ case OShr:
+ case OShl:
+ if (rtype(i.arg[1]) == RCon)
+ goto Emit;
+ r0 = i.arg[1];
+ i.arg[1] = TMP(RCX);
+ emit(OCopy, Kw, R, TMP(RCX), R);
+ emiti(i);
+ emit(OCopy, Kw, TMP(RCX), r0, R);
+ break;
case ONop:
break;
case OStored:
diff --git a/lisc/lisc.h b/lisc/lisc.h
index 9a627a8..354c8c7 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -217,6 +217,9 @@ enum Op {
OAnd,
OOr,
OXor,
+ OSar,
+ OShr,
+ OShl,
OCmpw,
OCmpw1 = OCmpw + NICmp-1,
OCmpl,
diff --git a/lisc/parse.c b/lisc/parse.c
index 1fbd406..45b1b96 100644
--- a/lisc/parse.c
+++ b/lisc/parse.c
@@ -19,6 +19,9 @@ OpDesc opdesc[NOp] = {
[OAnd] = { "and", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0 },
[OOr] = { "or", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0 },
[OXor] = { "xor", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0 },
+ [OSar] = { "sar", 1, {A(w,l,x,x), A(w,w,x,x)}, 1, 0 },
+ [OShr] = { "shr", 1, {A(w,l,x,x), A(w,w,x,x)}, 1, 0 },
+ [OShl] = { "shl", 1, {A(w,l,x,x), A(w,w,x,x)}, 1, 0 },
[OStored] = { "stored", 0, {A(d,d,d,d), A(m,m,m,m)}, 0, 1 },
[OStores] = { "stores", 0, {A(s,s,s,s), A(m,m,m,m)}, 0, 1 },
[OStorel] = { "storel", 0, {A(l,l,l,l), A(m,m,m,m)}, 0, 1 },