qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit cebec4dd4739712530111c6211129ef2ee948c5c
parent 9de2a588da1d4879984992dcd03b75bd0bac8035
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date:   Mon,  7 Mar 2016 13:46:44 -0500

add new cast instruction

Diffstat:
Mlisc/emit.c | 2++
Mlisc/isel.c | 11+++++++++++
Mlisc/lisc.h | 1+
Mlisc/parse.c | 1+
4 files changed, 15 insertions(+), 0 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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 },