commit ecebb6f48e276336d386125f3471b1c20db97119
parent 31f23dd5925196b5c0eb81cdf9537913b9a3ae4c
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Mon, 30 Nov 2015 12:53:30 -0500
update liveness to work with fp
Diffstat:
3 files changed, 50 insertions(+), 33 deletions(-)
diff --git a/lisc/Makefile b/lisc/Makefile
@@ -1,6 +1,6 @@
BIN = lisc
# OBJ = main.o util.o parse.o mem.o ssa.o copy.o live.o isel.o spill.o rega.o emit.o
-OBJ = main.o util.o parse.o ssa.o
+OBJ = main.o util.o parse.o ssa.o live.o
CFLAGS = -Wall -Wextra -std=c99 -g -pedantic
diff --git a/lisc/lisc.h b/lisc/lisc.h
@@ -65,7 +65,9 @@ enum Reg {
NReg = RBX - RAX + 1,
NFReg = XMM15 - XMM0 + 1,
- NRSave = 9,
+ NISave = 9,
+ NFSave = 15,
+ NRSave = NISave + NFSave,
NRClob = 5,
};
@@ -164,6 +166,9 @@ enum Class {
Kd
};
+#define KWIDE(k) ((k)&1)
+#define KBASE(k) ((k)>>1)
+
enum Op {
OXXX,
@@ -270,7 +275,7 @@ struct Blk {
Blk **pred;
uint npred;
Bits in, out, gen;
- int nlive;
+ int nlive[2];
int loop;
char name[NString];
};
@@ -295,7 +300,7 @@ struct Tmp {
uint ndef, nuse;
uint cost;
short slot;
- short wide;
+ short cls;
struct {
int r;
ulong m;
@@ -421,9 +426,8 @@ void filllive(Fn *);
/* isel.c */
extern int rsave[NRSave];
extern int rclob[NRClob];
-ulong calldef(Ins, int *);
-ulong calluse(Ins, int *);
-ulong callclb(Ins, int *);
+ulong calldef(Ins, int[2]);
+ulong calluse(Ins, int[2]);
void isel(Fn *);
/* spill.c */
diff --git a/lisc/live.c b/lisc/live.c
@@ -59,7 +59,7 @@ bset(Ref r, Blk *b, int *nlv, short *phi, Tmp *tmp)
BSET(b->gen, r.val);
phifix(r.val, phi, tmp);
if (!BGET(b->in, r.val)) {
- ++*nlv;
+ nlv[KBASE(tmp[r.val].cls)]++;
BSET(b->in, r.val);
}
}
@@ -72,7 +72,7 @@ filllive(Fn *f)
{
Blk *b;
Ins *i;
- int t, z, m, n, chg, nlv;
+ int k, t, z, m[2], n, chg, nlv[2];
short *phi;
Bits u, v;
Mem *ma;
@@ -104,43 +104,55 @@ Again:
memset(phi, 0, f->ntmp * sizeof phi[0]);
b->in = b->out;
- nlv = bcnt(&b->in);
+ nlv[0] = 0;
+ nlv[1] = 0;
for (t=0; t<f->ntmp; t++)
- if (BGET(b->in, t))
+ if (BGET(b->in, t)) {
phifix(t, phi, f->tmp);
- bset(b->jmp.arg, b, &nlv, phi, f->tmp);
- b->nlive = nlv;
+ nlv[KBASE(f->tmp[t].cls)]++;
+ }
+ bset(b->jmp.arg, b, nlv, phi, f->tmp);
+ for (k=0; k<2; k++)
+ b->nlive[k] = nlv[k];
for (i=&b->ins[b->nins]; i!=b->ins;) {
+#if 0
if ((--i)->op == OCall)
if (rtype(i->arg[1]) == RACall) {
- b->in.t[0] &= ~calldef(*i, &m);
- nlv -= m;
- if (nlv + NRSave > b->nlive)
- b->nlive = nlv + NRSave;
- b->in.t[0] |= calluse(*i, &m);
- nlv += m;
+ b->in.t[0] &= ~calldef(*i, m);
+ for (k=0; k<2; k++)
+ nlv[k] -= m[k];
+ if (nlv[0] + NISave > b->nlive[0])
+ b->nlive[0] = nlv[0] + NISave;
+ if (nlv[1] + NFSave > b->nlive[1])
+ b->nlive[1] = nlv[1] + NFSave;
+ b->in.t[0] |= calluse(*i, m);
+ for (k=0; k<2; k++)
+ nlv[k] += m[k];
}
+#endif
if (!req(i->to, R)) {
assert(rtype(i->to) == RTmp);
- nlv -= BGET(b->in, i->to.val);
- BSET(b->gen, i->to.val);
- BCLR(b->in, i->to.val);
- t = phitmp(i->to.val, f->tmp);
- phi[t] = 0;
+ t = i->to.val;
+ if (BGET(b->in, i->to.val))
+ nlv[KBASE(f->tmp[t].cls)]--;
+ BSET(b->gen, t);
+ BCLR(b->in, t);
+ phi[phitmp(t, f->tmp)] = 0;
}
- for (m=0; m<2; m++)
- switch (rtype(i->arg[m])) {
+ for (k=0; k<2; k++)
+ switch (rtype(i->arg[k])) {
case RAMem:
- ma = &f->mem[i->arg[m].val & AMask];
- bset(ma->base, b, &nlv, phi, f->tmp);
- bset(ma->index, b, &nlv, phi, f->tmp);
+ ma = &f->mem[i->arg[k].val & AMask];
+ bset(ma->base, b, nlv, phi, f->tmp);
+ bset(ma->index, b, nlv, phi, f->tmp);
break;
default:
- bset(i->arg[m], b, &nlv, phi, f->tmp);
+ bset(i->arg[k], b, nlv, phi, f->tmp);
break;
}
- if (nlv > b->nlive)
- b->nlive = nlv;
+ for (k=0; k<2; k++)
+ if (nlv[k] > b->nlive[k])
+ b->nlive[k] = nlv[k];
}
}
if (chg) {
@@ -158,7 +170,8 @@ Again:
dumpts(&b->out, f->tmp, stderr);
fprintf(stderr, "\t gen: ");
dumpts(&b->gen, f->tmp, stderr);
- fprintf(stderr, "\t live: %d\n", b->nlive);
+ fprintf(stderr, "\t live int: %d\n", b->nlive[0]);
+ fprintf(stderr, "\t live flt: %d\n", b->nlive[1]);
}
}
}