diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-07 13:46:44 -0500 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-07 13:46:44 -0500 |
commit | cebec4dd4739712530111c6211129ef2ee948c5c (patch) | |
tree | 496284040d586d37df41d21873d46e1deb575654 | |
parent | 9de2a588da1d4879984992dcd03b75bd0bac8035 (diff) | |
download | roux-cebec4dd4739712530111c6211129ef2ee948c5c.tar.gz |
add new cast instruction
-rw-r--r-- | lisc/emit.c | 2 | ||||
-rw-r--r-- | lisc/isel.c | 11 | ||||
-rw-r--r-- | lisc/lisc.h | 1 | ||||
-rw-r--r-- | lisc/parse.c | 1 |
4 files changed, 15 insertions, 0 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index e055758..240bfc6 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -77,6 +77,8 @@ static struct { { OFtosi, Kl, "cvttsd2si %0, %=" }, { OSitof, Ks, "cvtsi2ss %W0, %=" }, { OSitof, Kd, "cvtsi2sd %L0, %=" }, + { OCast, Ki, "movq %D0, %L=" }, + { OCast, Ka, "movq %L0, %D=" }, { OAddr, Ki, "lea%k %M0, %=" }, { OSwap, Ki, "xchg%k %0, %1" }, diff --git a/lisc/isel.c b/lisc/isel.c index 6834d17..2c05b22 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -129,6 +129,13 @@ argcls(Ins *i, int n) return KWIDE(i->cls) ? Kl : Kw; case OSitof: return KWIDE(i->cls) ? Kd : Ks; + case OCast: + switch (i->cls) { + case Kw: return Ks; + case Kl: return Kd; + case Ks: return Kw; + case Kd: return Kl; + } default: if (OCmpw <= i->op && i->op <= OCmpd1) diag("isel: invalid call to argcls"); @@ -295,6 +302,9 @@ sel(Ins i, ANum *an, Fn *fn) case OOr: case OXor: case OXTest: + case OFtosi: + case OSitof: + case OCast: case_OExt: Emit: emiti(i); @@ -373,6 +383,7 @@ flagi(Ins *i0, Ins *i) case OTruncd: case OFtosi: case OSitof: + case OCast: ; } return 0; diff --git a/lisc/lisc.h b/lisc/lisc.h index 12ea1ea..17ebc9c 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -253,6 +253,7 @@ enum Op { OTruncd, OFtosi, OSitof, + OCast, OAlloc, OAlloc1 = OAlloc + NAlign-1, diff --git a/lisc/parse.c b/lisc/parse.c index d3ce1e4..3cc983a 100644 --- a/lisc/parse.c +++ b/lisc/parse.c @@ -35,6 +35,7 @@ OpDesc opdesc[NOp] = { [OTruncd] = { "truncd", 0 }, [OFtosi] = { "ftosi", 0 }, [OSitof] = { "sitof", 0 }, + [OCast] = { "cast", 0 }, [OCopy] = { "copy", 1 }, [ONop] = { "nop", 0 }, [OSwap] = { "swap", 2 }, |