From db6f7ad72dda70f5dd3b34a3faea1e08537e77be Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Wed, 16 Mar 2016 11:18:28 -0400 Subject: add shift instructions --- lisc/emit.c | 3 +++ lisc/isel.c | 11 +++++++++++ lisc/lisc.h | 3 +++ lisc/parse.c | 3 +++ 4 files changed, 20 insertions(+) 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 }, -- cgit 1.4.1