commit 854ecd40092a33184aaa20b0bfbc023c7df6a3d0
parent 8899449c39f66b8d7db24c33a56708e7678e70ad
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Mon, 27 Jul 2015 14:57:56 -0400
add crippled dce to the allocator
Diffstat:
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lisc/lisc.h b/lisc/lisc.h
@@ -88,6 +88,7 @@ enum {
OStore,
OLoad,
/* reserved instructions */
+ ONop,
OCopy,
OSwap,
OIACltd,
diff --git a/lisc/parse.c b/lisc/parse.c
@@ -18,6 +18,7 @@ OpDesc opdesc[OLast] = {
[ORem] = { 2, 0, "rem" },
[OStore] = { 2, 0, "store" },
[OLoad] = { 1, 0, "load" },
+ [ONop] = { 0, 0, "nop" },
[OCopy] = { 1, 0, "copy" },
[OSwap] = { 2, 1, "swap" },
[OIADiv] = { 1, 0, "iadiv" },
diff --git a/lisc/rega.c b/lisc/rega.c
@@ -256,7 +256,7 @@ rega(Fn *fn)
/* process instructions */
end[n] = cur;
if (debug['R']) {
- fprintf(stderr, "\tend %-10s ", b->name);
+ fprintf(stderr, "\t%-10s end", b->name);
mdump(&cur);
}
if (rtype(b->jmp.arg) == RSym)
@@ -270,8 +270,11 @@ rega(Fn *fn)
}
if (!req(i->to, R)) {
r = rfree(&cur, i->to.val);
- if (r)
- i->to = SYM(r);
+ if (!r) {
+ *i = (Ins){ONop, R, {R, R}};
+ continue;
+ }
+ i->to = SYM(r);
}
if (rtype(i->arg[0]) == RSym) {
/* <arch>
@@ -301,9 +304,13 @@ rega(Fn *fn)
}
}
if (debug['R']) {
- fprintf(stderr, "\tbeg %-10s ", b->name);
+ fprintf(stderr, "\t beg");
mdump(&cur);
}
+ b->in = cur.bt;
+ for (p=b->phi; p; p=p->link)
+ if (rtype(p->to) == RSym)
+ BCLR(b->in, p->to.val);
beg[n] = cur;
}
if (debug['R'])
@@ -318,14 +325,18 @@ rega(Fn *fn)
for (p=s->phi; p; p=p->link) {
assert(rtype(p->to) == RSlot
|| rtype(p->to) == RSym);
+ dst = p->to;
+ if (rtype(dst) == RSym) {
+ r = rfind(&beg[s->id], dst.val);
+ if (!r)
+ continue;
+ dst = SYM(r);
+ }
for (a=0; p->blk[a]!=b; a++)
assert(a+1 < p->narg);
- dst = p->to;
src = p->arg[a];
if (rtype(src) == RSym)
src = rref(&end[b->id], src.val);
- if (rtype(dst) == RSym)
- dst = rref(&beg[s->id], dst.val);
pmadd(src, dst);
}
for (t=Tmp0; t<fn->ntmp; t++)