aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-26 19:37:45 +0100
committerlemon <lsof@mailbox.org>2025-12-26 19:39:24 +0100
commit0378ccf92c3c1896af29900039339a077c8b5502 (patch)
treed30ad619ec6adaba62c4ef4a64d9ffb014b8e5cf
parentbf1a1c5aa83fe1e3d0a60e64199882efeb307116 (diff)
x86_64/emit move things around
-rw-r--r--x86_64/emit.c23
1 files changed, 11 insertions, 12 deletions
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))