diff options
-rw-r--r-- | lisc/emit.c | 11 | ||||
-rw-r--r-- | lisc/isel.c | 8 | ||||
-rw-r--r-- | lisc/lisc.h | 2 | ||||
-rw-r--r-- | lisc/parse.c | 4 |
4 files changed, 10 insertions, 15 deletions
diff --git a/lisc/emit.c b/lisc/emit.c index 3e03a81..22e9073 100644 --- a/lisc/emit.c +++ b/lisc/emit.c @@ -81,7 +81,6 @@ eref(Ref r, Fn *fn, FILE *f) assert(r.val < Tmp0); fprintf(f, "%%%s", rtoa(r.val)); break; - case RMem: case RSlot: fprintf(f, "-%d(%%rbp)", 4 * r.val); break; @@ -106,7 +105,6 @@ emem(Ref r, Fn *fn, FILE *f) switch (rtype(r)) { default: diag("emit: invalid memory reference"); - case RMem: case RSlot: eref(r, fn, f); break; @@ -186,10 +184,6 @@ eins(Ins i, Fn *fn, FILE *f) val, rsub[i.to.val][SWord]); break; } - } - if (rtype(i.arg[0]) == RMem) { - assert(rtype(i.to)==RTmp && i.to.val<EAX); - eop("lea", i.arg[0], i.to, fn, f); } else if (!req(i.arg[0], i.to)) eop("mov", i.arg[0], i.to, fn, f); break; @@ -228,6 +222,11 @@ eins(Ins i, Fn *fn, FILE *f) if (!req(i.to, R)) eop("mov", TMP(RSP), i.to, fn ,f); break; + case OAddr: + if (rtype(i.arg[0]) != RSlot) + diag("emit: invalid addr instruction"); + eop("lea", i.arg[0], i.to, fn, f); + break; case OSwap: eop("xchg", i.arg[0], i.arg[1], fn, f); break; diff --git a/lisc/isel.c b/lisc/isel.c index 41ff9f2..4f6b054 100644 --- a/lisc/isel.c +++ b/lisc/isel.c @@ -191,7 +191,7 @@ sel(Ins i, Fn *fn) case OStoreb: case OStores: if (cpy[1].s) { - i.arg[1] = MEM(cpy[1].s); + i.arg[1] = SLOT(cpy[1].s); cpy[1].s = 0; } n = i.op == OStorel; @@ -202,7 +202,7 @@ sel(Ins i, Fn *fn) case OLoadsb: case OLoadub: if (cpy[0].s) { - i.arg[0] = MEM(cpy[0].s); + i.arg[0] = SLOT(cpy[0].s); cpy[0].s = 0; } n = 0; @@ -261,7 +261,7 @@ Emit: for (n=0; n<2; n++) if (cpy[n].s) - emit(OCopy, cpy[n].r, MEM(cpy[n].s), R); + emit(OAddr, cpy[n].r, SLOT(cpy[n].s), R); } static Ins * @@ -441,7 +441,7 @@ isel(Fn *fn) s = rslot(p->arg[a], fn); if (s) { p->arg[a] = newtmp(TLong, fn); - emit(OCopy, p->arg[a], MEM(s), R); + emit(OAddr, p->arg[a], SLOT(s), R); } } curi = &insb[NIns]; diff --git a/lisc/lisc.h b/lisc/lisc.h index 76290dc..6e9ce6c 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -90,7 +90,6 @@ struct Ref { enum { RTmp, RCon, - RMem, RSlot, NRef = (1<<14) - 1 }; @@ -99,7 +98,6 @@ enum { #define TMP(x) (Ref){RTmp, x} #define CON(x) (Ref){RCon, x} #define CON_Z CON(0) /* reserved zero constant */ -#define MEM(x) (Ref){RMem, x} #define SLOT(x) (Ref){RSlot, x} static inline int req(Ref a, Ref b) diff --git a/lisc/parse.c b/lisc/parse.c index 4856d5c..07e1ad9 100644 --- a/lisc/parse.c +++ b/lisc/parse.c @@ -35,6 +35,7 @@ OpDesc opdesc[NOp] = { [OXCmpl] = { "xcmpl", 2, 1 }, [OXTestw] = { "xtestw", 2, 1 }, [OXTestl] = { "xtestl", 2, 1 }, + [OAddr] = { "addr", 1, 0 }, [OAlloc] = { "alloc4", 1, 1 }, [OAlloc+1] = { "alloc8", 1, 1 }, [OAlloc+2] = { "alloc16", 1, 1 }, @@ -565,9 +566,6 @@ printref(Ref r, Fn *fn, FILE *f) case RSlot: fprintf(f, "S%d", r.val); break; - case RMem: - fprintf(f, "M%d", r.val); - break; } return ""; } |