From a69fe2c6c53ecad229c4477d541721084bba02df Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Sun, 9 Aug 2015 12:13:19 -0400 Subject: ugly support for store/load --- lisc/emit.c | 29 ++++++++++++++++++++++++----- lisc/isel.c | 27 +++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) (limited to 'lisc') diff --git a/lisc/emit.c b/lisc/emit.c index 7d62363..2e76209 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -170,16 +170,35 @@ eins(Ins i, Fn *fn, FILE *f) eop("mov", i.arg[0], i.to, fn, f); break; case OStore: - s = rtoa[i.arg[0].val]; + if (rtype(i.arg[0]) == RCon) { + fprintf(f, "\tmovl "); + eref(i.arg[0], fn, f); + fprintf(f, ", "); + } else { + assert(rtype(i.arg[0]) == RReg); + fprintf(f, "\tmov %%%s, ", rtoa[i.arg[0].val]); + } goto Store; case OStores: - s = rsub[BASE(i.arg[0].val)].s; + if (rtype(i.arg[0]) == RCon) { + fprintf(f, "\tmovw "); + eref(i.arg[0], fn, f); + fprintf(f, ", "); + } else { + assert(rtype(i.arg[0]) == RReg); + fprintf(f, "\tmovw %%%s, ", rsub[BASE(i.arg[0].val)].s); + } goto Store; case OStoreb: - s = rsub[BASE(i.arg[0].val)].b; + if (rtype(i.arg[0]) == RCon) { + fprintf(f, "\tmovb "); + eref(i.arg[0], fn, f); + fprintf(f, ", "); + } else { + assert(rtype(i.arg[0]) == RReg); + fprintf(f, "\tmovb %%%s, ", rsub[BASE(i.arg[0].val)].b); + } Store: - assert(rtype(i.arg[0]) == RReg); - fprintf(f, "\tmov %s, ", s); emem(i.arg[1], fn, f); fprintf(f, "\n"); break; diff --git a/lisc/isel.c b/lisc/isel.c index 36466ee..30c9b1f 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -117,6 +117,33 @@ sel(Ins i, Fn *fn) case OCopy: emit(i.op, i.to, i.arg[0], i.arg[1]); break; + case OStore: + case OStoreb: + case OStores: + r0 = i.arg[0]; + goto Load; + case OLoad: + case OLoadss: + case OLoadus: + case OLoadsb: + case OLoadub: + r0 = i.arg[0]; + if (rtype(r0) == RCon) { + t = newtmp(TLong, fn); + r0 = TMP(t); + } + Load: + r1 = i.arg[1]; + if (rtype(r1) == RCon) { + t = newtmp(TLong, fn); + r1 = TMP(t); + } + emit(i.op, i.to, r0, r1); + if (!req(r0, i.arg[0])) + emit(OCopy, r0, i.arg[0], R); + if (!req(r1, i.arg[1])) + emit(OCopy, r1, i.arg[1], R); + break; case ONop: break; default: -- cgit 1.4.1