From 19bbdfa3c7ae05f4694ce5e434d9855c6f2c3682 Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 24 Jun 2023 18:47:05 +0200 Subject: backend: fix regalloc to work with more complex dataflow basically an allocation map at the beginning (in) and end (out) of each block is kept and after the first allocation pass another pass is ran to resolve allocation conflicts between each edge, plus another pass to finish lowering phi functions. also introduced `regset` and plenty of other miscellaneous fixes --- irdump.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'irdump.c') diff --git a/irdump.c b/irdump.c index 9eda415..3d95843 100644 --- a/irdump.c +++ b/irdump.c @@ -80,10 +80,9 @@ dumpref(enum op o, union ref ref) efmt("??"); break; case RTMP: + efmt("%%%d", ref.i); if (instrtab[ref.i].reg) - efmt("%s", mctarg->rnames[instrtab[ref.i].reg - 1]); - else - efmt("%%%d", ref.i); + efmt("(%s)", mctarg->rnames[instrtab[ref.i].reg-1]); break; case RREG: efmt("%s", mctarg->rnames[ref.i]); @@ -168,7 +167,7 @@ dumpinst(const struct instr *ins) if (ins->reg) { if (cls) efmt("%s ", clsname[cls]); - efmt("%s = ", mctarg->rnames[ins->reg - 1]); + efmt("(%%%d)%s = ", ins - instrtab, mctarg->rnames[ins->reg - 1]); } else if (cls) { efmt("%s %%%d", clsname[cls], ins - instrtab); efmt(" = "); @@ -198,7 +197,9 @@ dumpblk(struct function *fn, struct block *blk) struct instr *phi = &instrtab[blk->phi.p[i]]; union ref *refs = phitab.p[phi->l.i]; assert(phi->op == Ophi); - efmt(" %s %%%d = phi ", clsname[phi->cls], blk->phi.p[i]); + efmt(" %s ", clsname[phi->cls]); + if (!phi->reg) efmt("%%%d = phi ", blk->phi.p[i]); + else efmt("(%%%d)%s = phi ", phi - instrtab, mctarg->rnames[phi->reg-1]); for (int i = 0; i < blk->npred; ++i) { if (i) efmt(", "); efmt("@%d ", blkpred(blk, i)->id); -- cgit v1.2.3