diff options
| author | 2023-06-19 22:33:35 +0200 | |
|---|---|---|
| committer | 2023-06-19 22:33:35 +0200 | |
| commit | 61367525aea8f3f11c29e628fe49768dda959cef (patch) | |
| tree | 7f3f428b40086c20ebc2e7aa54f49b4394b6e820 /regalloc.c | |
| parent | 88bf0602d09bebbf18213fbf02821e9f63b964a8 (diff) | |
backend: compile comparison instrs and branches
Diffstat (limited to 'regalloc.c')
| -rw-r--r-- | regalloc.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -242,7 +242,9 @@ use(struct rega *ra, struct block *blk, int curi, enum op op, int hint, union re vpush(&ra->freestk, s); } } - *ref = mkref(RREG, ins->reg-1); + /* do not patch ref if it's cond branch arg, emit() wants to know what instr it is */ + if (ref != blk->jmp.arg || blk->jmp.t != Jb) + *ref = mkref(RREG, ins->reg-1); } void @@ -273,6 +275,9 @@ regalloc(struct function *fn) do { for (int i = 0; i < 2; ++i) { if (!blk->jmp.arg[i].t) break; + /* do not allocate a reg for a cmp op used a branch argument, since it's a pseudo op */ + if (blk->jmp.t == Jb && blk->jmp.arg[i].t == RTMP && oiscmp(instrtab[blk->jmp.arg[i].i].op)) + break; use(&ra, blk, blk->ins.n-1, (blk->jmp.t != Jb) - 1, blk->jmp.t == Jret ? fn->abiret[i].reg : -1, &blk->jmp.arg[i], blk->jmp.arg[!i]); |