diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-03 17:40:48 -0500 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-03 17:40:48 -0500 |
commit | 169411a220f4cb10c973d5bb613b4a6b9915efb7 (patch) | |
tree | 8508c45534028810bd4ac8c2defb5e123f0068d0 | |
parent | cf8da3a6142e847e014306876742ab24189a6a94 (diff) | |
download | roux-169411a220f4cb10c973d5bb613b4a6b9915efb7.tar.gz |
add some (easy) instructions
-rw-r--r-- | lisc/emit.c | 10 | ||||
-rw-r--r-- | lisc/isel.c | 19 | ||||
-rw-r--r-- | lisc/lisc.h | 7 | ||||
-rw-r--r-- | lisc/parse.c | 8 |
4 files changed, 43 insertions, 1 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index 0ed3296..e055758 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -44,6 +44,8 @@ static struct { { OAdd, Ka, "+add%k %1, %=" }, { OSub, Ka, "-sub%k %1, %=" }, { OAnd, Ki, "+and%k %1, %=" }, + { OOr, Ki, "+or%k %1, %=" }, + { OXor, Ki, "+xor%k %1, %=" }, { OMul, Ki, "+imul%k %1, %=" }, { OMul, Ks, "+mulss %1, %=" }, /* fixme */ { OMul, Kd, "+mulsd %1, %=" }, @@ -68,6 +70,14 @@ static struct { { OExtuh, Ki, "movzw%k %H0, %=" }, { OExtsb, Ki, "movsb%k %B0, %=" }, { OExtub, Ki, "movzb%k %B0, %=" }, + + { OExts, Kd, "cvtss2sd %0, %=" }, /* see if factorization is possible */ + { OTruncd, Ks, "cvttsd2ss %0, %=" }, + { OFtosi, Kw, "cvttss2si %0, %=" }, + { OFtosi, Kl, "cvttsd2si %0, %=" }, + { OSitof, Ks, "cvtsi2ss %W0, %=" }, + { OSitof, Kd, "cvtsi2sd %L0, %=" }, + { OAddr, Ki, "lea%k %M0, %=" }, { OSwap, Ki, "xchg%k %0, %1" }, { OSign, Kl, "cqto" }, diff --git a/lisc/isel.c b/lisc/isel.c index 64a3da9..73d4c21 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -120,6 +120,14 @@ argcls(Ins *i, int n) return n == 0 ? Kw : Kl; case OStorel: return Kl; + case OExts: + return Ks; + case OTruncd: + return Kd; + case OFtosi: + return KWIDE(i->cls) ? Kl : Kw; + case OSitof: + return KWIDE(i->cls) ? Kd : Ks; default: if (OCmpw <= i->op && i->op <= OCmpd1) diag("isel: invalid call to argcls"); @@ -283,6 +291,8 @@ sel(Ins i, ANum *an, Fn *fn) case OSub: case OMul: case OAnd: + case OOr: + case OXor: case OXTest: case_OExt: Emit: @@ -348,6 +358,8 @@ flagi(Ins *i0, Ins *i) case OAdd: /* flag-setting */ case OSub: case OAnd: + case OOr: + case OXor: return i; case OCopy: /* flag-transparent */ case OStored: @@ -355,7 +367,12 @@ flagi(Ins *i0, Ins *i) case OStorel: case OStorew: case OStoreh: - case OStoreb:; + case OStoreb: + case OExts: + case OTruncd: + case OFtosi: + case OSitof: + ; } return 0; } diff --git a/lisc/lisc.h b/lisc/lisc.h index edac623..5702182 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -216,6 +216,8 @@ enum Op { ORem, OMul, OAnd, + OOr, + OXor, OCmpw, OCmpw1 = OCmpw + NICmp-1, OCmpl, @@ -248,6 +250,11 @@ enum Op { OExtub, #define isext(o) (OExtsw <= o && o <= OExtub) + OExts, + OTruncd, + OFtosi, + OSitof, + OAlloc, OAlloc1 = OAlloc + NAlign-1, diff --git a/lisc/parse.c b/lisc/parse.c index 69ed66a..7798dcd 100644 --- a/lisc/parse.c +++ b/lisc/parse.c @@ -10,6 +10,8 @@ OpDesc opdesc[NOp] = { [ORem] = { "rem", 2 }, [OMul] = { "mul", 2 }, [OAnd] = { "and", 2 }, + [OOr] = { "or", 2 }, + [OXor] = { "xor", 2 }, [OStored] = { "stored", 0 }, [OStores] = { "stores", 0 }, [OStorel] = { "storel", 0 }, @@ -29,6 +31,10 @@ OpDesc opdesc[NOp] = { [OExtuh] = { "extuh", 0 }, [OExtsb] = { "extsb", 0 }, [OExtub] = { "extub", 0 }, + [OExts] = { "exts", 0 }, + [OTruncd] = { "truncd", 0 }, + [OFtosi] = { "ftosi", 0 }, + [OSitof] = { "sitof", 0 }, [OCopy] = { "copy", 1 }, [ONop] = { "nop", 0 }, [OSwap] = { "swap", 2 }, @@ -179,6 +185,8 @@ lex() { "loadl", OLoad }, { "loads", OLoad }, { "loadd", OLoad }, + { "alloc1", OAlloc }, + { "alloc2", OAlloc }, { 0, TXXX } }; static char tok[NString]; |