add rpo information to functions
This commit is contained in:
parent
11db0b61d9
commit
851e79f959
3 changed files with 53 additions and 0 deletions
44
lisc/ssa.c
44
lisc/ssa.c
|
@ -38,3 +38,47 @@ fillpreds(Fn *f)
|
|||
addpred(b, b->s2);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
rporec(Blk *b, int x)
|
||||
{
|
||||
if (b->rpo >= 0)
|
||||
return x;
|
||||
if (b->s1)
|
||||
x = rporec(b->s1, x);
|
||||
if (b->s2)
|
||||
x = rporec(b->s2, x);
|
||||
b->rpo = x;
|
||||
return x - 1;
|
||||
}
|
||||
|
||||
void
|
||||
fillrpo(Fn *f)
|
||||
{
|
||||
int n;
|
||||
Blk *b, **p;
|
||||
|
||||
for (b=f->start; b; b=b->link)
|
||||
b->rpo = -1;
|
||||
n = rporec(f->start, f->nblk-1);
|
||||
f->rpo = alloc(n * sizeof(Blk*));
|
||||
for (p=&f->start; *p;) {
|
||||
b = *p;
|
||||
if (b->rpo == -1) {
|
||||
*p = b->link;
|
||||
/* todo, free block */
|
||||
} else {
|
||||
b->rpo -= n;
|
||||
f->rpo[b->rpo] = b;
|
||||
p=&(*p)->link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ssafix(Fn *f, Ref v)
|
||||
{
|
||||
(void)f;
|
||||
(void)v;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue