From 8b79b61ae78c91c069447331ed64d400187bdd77 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 8 Apr 2026 10:26:18 +0200 Subject: Implement basic aarch64 struct arg passing ABI - Missing: vaargs, >2 member HFAs - Reworked the way stack allocation references are lowered. Now RSTACK persists throughout all passes until emit. This allows deferring stack frame layouting until the end in a less messy way than before, which was emiting frame-pointer relative addresses @ isel time and patching them up later in emit to account for actual stack frame layout. --- src/t_aarch64_aapcs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/t_aarch64_aapcs.c') diff --git a/src/t_aarch64_aapcs.c b/src/t_aarch64_aapcs.c index a321f5b..1cf3a61 100644 --- a/src/t_aarch64_aapcs.c +++ b/src/t_aarch64_aapcs.c @@ -93,7 +93,7 @@ abiarg(short r[2], uchar cls[2], uchar *r2off, int *ni, int *nf, int *ns, IRType if (n <= NFLT - *nf) { for (int i = 0; i < n; ++i) { r[i] = V(0) + *nf + i; - cls[i] = type2cls[k]; + cls[i] = k; } *nf += n; } else { /* stack */ @@ -121,17 +121,17 @@ abiarg(short r[2], uchar cls[2], uchar *r2off, int *ni, int *nf, int *ns, IRType } static int -abiret(short r[2], uchar cls[2], uchar *r2off, int *ni, IRType typ) +abiret(short r[2], uchar cls[2], uchar *r2off, int *_ni, IRType typ) { if (!typ.isagg) { r[0] = kisflt(cls[0] = typ.cls) ? V(0) : R0; return 1; } - int nf = 0, ns = 0; - int ret = abiarg(r, cls, r2off, ni, &nf, &ns, typ); - if (ret) return ret; + int ni = 0, nf = 0, ns = 0; + int ret = abiarg(r, cls, r2off, &ni, &nf, &ns, typ); + if (ret && cls[0] != KPTR) /* in regs */ + return ret; /* caller-allocated result address in x8 */ - assert(*ni == 0); r[0] = -1; r[1] = R(8); return 0; -- cgit v1.2.3