summaryrefslogtreecommitdiff
path: root/lisc
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-26 16:33:29 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-26 16:33:29 -0400
commitaa9dc343995ef2eafcb3ef630e2ab8e3ec61ac4f (patch)
tree846867688d43bd926e7bc74dfcc88726a743486c /lisc
parente80b84ebdb6c0623442a26ac10fc763cc6d9e6e9 (diff)
downloadroux-aa9dc343995ef2eafcb3ef630e2ab8e3ec61ac4f.tar.gz
move the liveon() function in live.c
Diffstat (limited to 'lisc')
-rw-r--r--lisc/lisc.h1
-rw-r--r--lisc/live.c46
-rw-r--r--lisc/spill.c20
3 files changed, 32 insertions, 35 deletions
diff --git a/lisc/lisc.h b/lisc/lisc.h
index 83994e5..127aa78 100644
--- a/lisc/lisc.h
+++ b/lisc/lisc.h
@@ -287,6 +287,7 @@ void fillphi(Fn *);
void ssafix(Fn *, int);
/* live.c */
+Bits liveon(Blk *, Blk *);
void filllive(Fn *);
/* isel.c */
diff --git a/lisc/live.c b/lisc/live.c
index c3aae86..80bdd75 100644
--- a/lisc/live.c
+++ b/lisc/live.c
@@ -1,5 +1,23 @@
#include "lisc.h"
+Bits
+liveon(Blk *b, Blk *s)
+{
+ Bits v;
+ Phi *p;
+ uint a;
+
+ v = s->in;
+ for (p=s->phi; p; p=p->link) {
+ BCLR(v, p->to.val);
+ for (a=0; a<p->narg; a++)
+ if (p->blk[a] == b)
+ if (rtype(p->arg[a]) == RTmp)
+ BSET(v, p->arg[a].val);
+ }
+ return v;
+}
+
static void
bset(Ref r, Blk *b, int *nlv)
{
@@ -20,10 +38,8 @@ filllive(Fn *f)
{
Blk *b;
Ins *i;
- Phi *p;
int z, m, n, chg, nlv;
- uint a;
- Bits tb;
+ Bits u, v;
assert(f->ntmp <= NBit*BITS);
for (b=f->start; b; b=b->link) {
@@ -36,14 +52,18 @@ Again:
for (n=f->nblk-1; n>=0; n--) {
b = f->rpo[n];
- tb = b->out;
- if (b->s1)
+ u = b->out;
+ if (b->s1) {
+ v = liveon(b, b->s1);
for (z=0; z<BITS; z++)
- b->out.t[z] |= b->s1->in.t[z];
- if (b->s2)
+ b->out.t[z] |= v.t[z];
+ }
+ if (b->s2) {
+ v = liveon(b, b->s2);
for (z=0; z<BITS; z++)
- b->out.t[z] |= b->s2->in.t[z];
- chg |= memcmp(&b->out, &tb, sizeof(Bits));
+ b->out.t[z] |= v.t[z];
+ }
+ chg |= memcmp(&b->out, &u, sizeof(Bits));
b->in = b->out;
nlv = bcnt(&b->in);
@@ -57,7 +77,6 @@ Again:
b->nlive = nlv + NRSave;
b->in.t[0] |= calluse(*i, &m);
nlv += m;
- bset(i->arg[0], b, &nlv);
}
if (!req(i->to, R)) {
assert(rtype(i->to) == RTmp);
@@ -69,13 +88,6 @@ Again:
if (nlv > b->nlive)
b->nlive = nlv;
}
-
- for (p=b->phi; p; p=p->link) {
- BCLR(b->in, p->to.val);
- for (a=0; a<p->narg; a++)
- if (rtype(p->arg[a]) == RTmp)
- BSET(p->blk[a]->out, p->arg[a].val);
- }
}
if (chg) {
chg = 0;
diff --git a/lisc/spill.c b/lisc/spill.c
index 115b6fc..36b08cd 100644
--- a/lisc/spill.c
+++ b/lisc/spill.c
@@ -258,22 +258,6 @@ setloc(Ref *pr, Bits *v, Bits *w)
}
}
-static Bits
-inregs(Blk *b, Blk *s) /* todo, move to live.c */
-{
- Bits v;
- Phi *p;
- uint a;
-
- v = s->in;
- for (p=s->phi; p; p=p->link)
- for (a=0; a<p->narg; a++)
- if (p->blk[a] == b)
- if (rtype(p->arg[a]) == RTmp)
- BSET(v, p->arg[a].val);
- return v;
-}
-
static Ins *
dopm(Blk *b, Ins *i, Bits *v)
{
@@ -374,10 +358,10 @@ spill(Fn *fn)
} else if (j > NReg)
limit(&v, NReg, 0);
} else if (s1) {
- v = inregs(b, s1);
+ v = liveon(b, s1);
w = v;
if (s2) {
- u = inregs(b, s2);
+ u = liveon(b, s2);
for (z=0; z<BITS; z++) {
v.t[z] |= u.t[z];
w.t[z] &= u.t[z];