From 0378ccf92c3c1896af29900039339a077c8b5502 Mon Sep 17 00:00:00 2001 From: lemon Date: Fri, 26 Dec 2025 19:37:45 +0100 Subject: x86_64/emit move things around --- x86_64/emit.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'x86_64/emit.c') diff --git a/x86_64/emit.c b/x86_64/emit.c index 6e48965..b0b4f58 100644 --- a/x86_64/emit.c +++ b/x86_64/emit.c @@ -971,6 +971,14 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc default: fatal(NULL, "x86_64: in %y; unimplemented instr '%s'", fn->name, opnames[ins->op]); case Onop: break; + case Omove: + dst = ref2oper(ins->l); + gencopy(pcode, cls, blk, curi, dst, ins->r); + break; + case Ocopy: + dst = reg2oper(ins->reg-1); + gencopy(pcode, cls, blk, curi, dst, ins->l); + break; case Ostore8: cls = KI32, X = Xmovb; goto Store; case Ostore16: cls = KI32, X = Xmovw; goto Store; case Ostore32: cls = KI32, X = Xmov; goto Store; @@ -1154,14 +1162,6 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc Xmovzxb(pcode, KI32, dst, dst); } break; - case Omove: - dst = ref2oper(ins->l); - gencopy(pcode, cls, blk, curi, dst, ins->r); - break; - case Ocopy: - dst = reg2oper(ins->reg-1); - gencopy(pcode, cls, blk, curi, dst, ins->l); - break; case Oswap: if (kisint(cls)) Xxchg(pcode, cls, ref2oper(ins->l), mkregoper(ins->r)); @@ -1360,18 +1360,17 @@ emitbin(struct function *fn) assert(!bb->resolved); while (bb->relreloc) { uint next; - int disp = bbaddr - bb->relreloc - 4; - memcpy(&next, objout.textbegin + bb->relreloc, 4); + int disp = bbaddr - bb->relreloc - 4; wr32le(objout.textbegin + bb->relreloc, disp); bb->relreloc = next; } bb->resolved = 1; bb->addr = bbaddr; - for (int i = 0; i < blk->ins.n; ++i) { + for (int i = 0; i < blk->ins.n; ++i) emitinstr(pcode, fn, blk, i, &instrtab[blk->ins.p[i]]); - } + if (blk->jmp.t == Jret) { /* epilogue */ if (fn->stksiz && (saverestore || !usebp)) -- cgit v1.2.3