diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-07-10 11:41:11 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:27 -0400 |
commit | 935ab611f0fd841f4f7e54c95ea2e57bba44f8ab (patch) | |
tree | 36e5e22c05a1c4f13bb313435d5e2101e9a6c726 /lisc/ssa.c | |
parent | 1d62b4bf478a17d7b825bb0064a50dba570dfe01 (diff) | |
download | roux-935ab611f0fd841f4f7e54c95ea2e57bba44f8ab.tar.gz |
add predecessor computation
Diffstat (limited to 'lisc/ssa.c')
-rw-r--r-- | lisc/ssa.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lisc/ssa.c b/lisc/ssa.c new file mode 100644 index 0000000..6f28634 --- /dev/null +++ b/lisc/ssa.c @@ -0,0 +1,39 @@ +#include "lisc.h" + +static void +addpred(Blk *bp, Blk *bc) +{ + int i; + + if (!bc->preds) { + bc->preds = alloc(bc->npreds * sizeof(Blk*)); + for (i=0; i<bc->npreds; i++) + bc->preds[i] = 0; + } + for (i=0; bc->preds[i]; i++) + ; + bc->preds[i] = bp; +} + +void +fillpreds(Fn *f) +{ + Blk *b; + + for (b=f->start; b; b=b->link) { + b->npreds = 0; + free(b->preds); + } + for (b=f->start; b; b=b->link) { + if (b->s1) + b->s1->npreds++; + if (b->s2) + b->s2->npreds++; + } + for (b=f->start; b; b=b->link) { + if (b->s1) + addpred(b, b->s1); + if (b->s2) + addpred(b, b->s2); + } +} |