aboutsummaryrefslogtreecommitdiffhomepage
path: root/abi0.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-21 23:52:23 +0200
committerlemon <lsof@mailbox.org>2023-06-21 23:52:23 +0200
commit3f2221dfb9ab33b7ac44bbf822a78753a0357d25 (patch)
tree5828192184328e405da0489d72d1c71a4be70316 /abi0.c
parent995fd23ecd5de710a6f587d29af2874b1fb4756d (diff)
mem2reg: implement ssa construction; this breaks regalloc right now
Diffstat (limited to 'abi0.c')
-rw-r--r--abi0.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/abi0.c b/abi0.c
index 8523c99..2024424 100644
--- a/abi0.c
+++ b/abi0.c
@@ -198,11 +198,19 @@ abi0_call(struct function *fn, struct instr *ins, struct block *blk, int *curi)
union irtype retty = call->ret;
struct instr alloca = { .cls = KPTR };
struct typedata *td = &typedata[retty.dat];
+ int ialloca ;
sretarghidden = ni == 0;
alloca.op = Oalloca8 + (td->align == 16);
alloca.l = mkref(RICON, td->align == 16 ? 1 : td->siz / 8);
- retmem = insertinstr(blk, (*curi)++ - call->narg, alloca);
+ /* swap alloca and call temps so users of original call point to alloca */
+ retmem = insertinstr(blk, ialloca = (*curi)++ - call->narg, *ins);
+ *ins = alloca;
+ blk->ins.p[ialloca] = ins - instrtab;
+ blk->ins.p[*curi] = retmem.i;
+ ins = &instrtab[retmem.i];
+ retmem.i = blk->ins.p[ialloca];
+
if (!nret) /* hidden pointer argument */
insertinstr(blk, (*curi)++ - call->narg,
mkinstr(Oarg, 0, mktyperef((union irtype){.cls=KPTR}), retmem));
@@ -219,7 +227,6 @@ abi0_call(struct function *fn, struct instr *ins, struct block *blk, int *curi)
}
/* adjust return */
if (call->ret.isagg) {
- replref(fn, blk, (*curi), mkref(RTMP, ins - instrtab), retmem);
ins->cls = 0;
if (!nret) { /* hidden pointer argument */
ins->cls = 0;