From c2ce1375eb0d9b03861bb345fb10c393197174c5 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Thu, 4 Feb 2016 14:00:50 -0500 Subject: cheaply integrate fp in mem.c --- lisc/mem.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'lisc/mem.c') diff --git a/lisc/mem.c b/lisc/mem.c index bfc8218..ea4bd82 100644 --- a/lisc/mem.c +++ b/lisc/mem.c @@ -4,6 +4,8 @@ * * - replace alloced slots used only in * load/store operations + * Assumption: all the accesses have the + * same size (this could be wrong...) */ /* require use, maintains use counts */ @@ -28,35 +30,37 @@ memopt(Fn *fn) goto NextIns; l = u->u.ins; if (l->op < OStorel || l->op > OStoreb) - if (l->op < OLoad || l->op > OLoad1) + if (l->op < OLoadl || l->op > OLoadub) goto NextIns; } /* get rid of the alloc and replace uses */ *i = (Ins){.op = ONop}; t->ndef--; ue = &t->use[t->nuse]; - for (u=t->use; u != ue; u++) { + for (u=t->use; u!=ue; u++) { l = u->u.ins; if (OStorel <= l->op && l->op <= OStoreb) { - l->wide = (l->op == OStorel); + l->cls = l->op == OStorel ? Kl : Kw; l->op = OCopy; l->to = l->arg[1]; l->arg[1] = R; t->nuse--; t->ndef++; } else + /* try to turn loads into copies so we + * can eliminate them later */ switch(l->op) { - case OLoad+Tl: - l->wide = 1; + case OLoadl: + l->cls = Kl; l->op = OCopy; break; - case OLoad+Tsw: - case OLoad+Tuw: - l->wide = 0; + case OLoadsw: + case OLoaduw: + l->cls = Kw; l->op = OCopy; break; default: - /* keep l->wide */ + /* keep l->cls */ a = l->op - OLoad; l->op = OExt + a; break; -- cgit 1.4.1