aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-11-23 17:10:30 +0100
committerlemon <lsof@mailbox.org>2025-11-23 17:10:30 +0100
commitbd3307a3e98e75b7cce5aa130719022a00323e0f (patch)
tree55baab714b5b5e2fd65698ffa08a70b0770f5197
parent9c06b225a3f385ad107de7238a4654598b8a4ddf (diff)
amd64: va_arg for small aggregates
-rw-r--r--amd64/sysv.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/amd64/sysv.c b/amd64/sysv.c
index 9d356a1..712652a 100644
--- a/amd64/sysv.c
+++ b/amd64/sysv.c
@@ -205,7 +205,7 @@ vastart(struct function *fn, struct block *blk, int *curi)
/* set ap->fp_offset */
dst = insertinstr(blk, i++, mkinstr(Oadd, KPTR, ap, mkref(RICON, 4)));
insertinstr(blk, i++, mkinstr(Ostore32, 0, dst, mkref(RICON, 6*8 + fpr0*16)));
- *curi = i;
+ *curi = i-1;
}
static void
@@ -270,7 +270,13 @@ vaarg(struct function *fn, struct block *blk, int *curi)
merge->ins.p[0] = var;
phi = insertphi(merge, KPTR);
memcpy(phitab.p[instrtab[phi.i].l.i], phiargs, sizeof phiargs);
- instrtab[var] = mkinstr(cls[0] == KI32 ? Oloads32 : Oloadi64, cls[0], phi);
+ if (!ty.isagg) {
+ instrtab[var] = mkinstr(cls[0] == KI32 ? Oloads32 : Oloadi64, cls[0], phi);
+ } else {
+ instrtab[var] = mkalloca(8, 8);
+ tmp = insertinstr(merge, 1, mkinstr(Oloadi64, KI64, phi));
+ insertinstr(merge, 2, mkinstr(Ostore64, 0, mkref(RTMP, var), tmp));
+ }
fn->prop &= ~FNUSE;
} else {
assert(!"nyi");