diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-04-09 14:21:56 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-04-09 14:21:56 -0400 |
commit | 1e0f18e9086b825d6fc941bf37306ae2823f0341 (patch) | |
tree | 71b5ebe09b04fa44465fd98a559a6a3541acd8c9 /util.c | |
parent | 081360df6a06979852de977a4d4e56f3c4481a81 (diff) | |
download | roux-1e0f18e9086b825d6fc941bf37306ae2823f0341.tar.gz |
add a proper block deletion routine
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/util.c b/util.c index 51d7e58..15f9dea 100644 --- a/util.c +++ b/util.c @@ -98,6 +98,30 @@ blknew() } void +blkdel(Blk *b) +{ + Blk *s, **ps; + Phi *p; + uint a; + + for (ps=(Blk*[]){b->s1, b->s2, 0}; (s=*ps); ps++) { + for (p=s->phi; p; p=p->link) { + for (a=0; p->blk[a]!=b; a++) + assert(a+1<p->narg); + p->narg--; + memcpy(&p->blk[a], &p->blk[a+1], p->narg-a); + memcpy(&p->arg[a], &p->arg[a+1], p->narg-a); + } + if (s->npred != 0) { + for (a=0; s->pred[a]!=b; a++) + assert(a+1<s->npred); + s->npred--; + memcpy(&s->pred[a], &s->pred[a+1], s->npred-a); + } + } +} + +void emit(int op, int k, Ref to, Ref arg0, Ref arg1) { if (curi == insb) |