aboutsummaryrefslogtreecommitdiffhomepage
path: root/ir.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-17 14:31:54 +0200
committerlemon <lsof@mailbox.org>2023-06-17 14:31:54 +0200
commitec28e9057e84b92acabb7ebf9122af59738917ad (patch)
treefe532fac21015cde652ee0472efc86569e30a9aa /ir.c
parent78b7a3a6874abad6d2326093287554f3e565a382 (diff)
misc
Diffstat (limited to 'ir.c')
-rw-r--r--ir.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/ir.c b/ir.c
index 7ccb926..d8772ad 100644
--- a/ir.c
+++ b/ir.c
@@ -367,22 +367,28 @@ putreturn(struct function *fn, union ref r0, union ref r1)
#undef putjump
void
-replref(struct function *fn, struct block *blk, int i0, union ref from, union ref to)
+blkreplref(struct block *blk, int i0, union ref from, union ref to)
{
- do {
- if (!i0) for (int i = 0; i < blk->phi.n; ++i) {
- struct phi *phi = &phitab.p[instrtab[blk->phi.p[i]].l.i];
- for (int i = 0; i < phi->n; ++i)
- if (phi->ref[i].bits == to.bits) phi->ref[i] = from;
- }
+ if (i0 == 0) for (int i = 0; i < blk->phi.n; ++i) {
+ struct phi *phi = &phitab.p[instrtab[blk->phi.p[i]].l.i];
+ for (int i = 0; i < phi->n; ++i)
+ if (phi->ref[i].bits == to.bits) phi->ref[i] = from;
+ }
- for (int i = i0; i < blk->ins.n; ++i) {
- struct instr *ins = &instrtab[blk->ins.p[i]];
- for (int i = 0; i < 2; ++i) {
- union ref *r = &(&ins->l)[i];
- if (r->bits == from.bits) *r = to;
- }
+ for (int i = i0; i < blk->ins.n; ++i) {
+ struct instr *ins = &instrtab[blk->ins.p[i]];
+ for (int i = 0; i < 2; ++i) {
+ union ref *r = &(&ins->l)[i];
+ if (r->bits == from.bits) *r = to;
}
+ }
+}
+
+void
+replref(struct function *fn, struct block *blk, int i0, union ref from, union ref to)
+{
+ do {
+ blkreplref(blk, i0, from, to);
i0 = 0;
} while ((blk = blk->lnext) != fn->entry);
}