w6c+wwstage: aggregate arg from any non-ident source via the closed addr machinery (#271) — close aggregate-arg family
Passing an aggregate BY VALUE as a call argument worked ONLY for a ≤16B struct from an IDENT source; every non-ident source — CALL mk(), N_DOT o.f, N_INDEX a[i], DEREF *p — and every array / >24B-struct (even as an ident) fell to the scalar default: one PUSHQ for a multi-word aggregate, stack-imbalancing against the type-based multi-word drain. cs!=ww, both garbage (f(mk()) cs4/ww236, f(o.f) cs8/ww108, f(a[i]) cs4/ww28, f(*p) cs4/ww140; arrays + 32B sret struct same). The arg-pass twin of the #265/#268 let-init copy. A new aggregate-arg push arm materialises the source into the arg convention: the source ADDRESS in SI (ident LEAQ / deref operand / dotchainaddr #253 / &base[i] spine #252-270) then its ceil(sz/8) words pushed high→low; a CALL receives first — ≤24B in AX/DX/CX pushed straight, >24B sret'd into a per-fn @aggargscr then pushed from there. The pop-forward drain gained a matching array / >16B-struct arm and the callee prologue an is_bigagg receive (ceil(sz/8) GP eightbytes), so caller and callee agree on the multi-word layout. The ≤16B-struct-IDENT fast path is untouched (byte-id preserved). The new-arm exclusion is TYPE-keyed (the stamped tinfo, mirroring cstage node_isstructarg over args[i]->type), not the name-keyed structparamsize — a name-keyed gate re-opened the #211/#13 cross-module same-leaf collision (784 symmetric: an 8B `sa.s` struct whose name-resolution collides with `sb.s = *vtable` would miss the struct fast path and wrongly enter the new arm, diverging from cstage's 1-word push). A float-bearing ≤16B struct from a non-ident source loud-stops in both stages (the #165 SSE eightbyte transport the GP push/drain can't model; out of scope). A const array/struct `def` global as an aggregate arg is aligned DOWN to the leaner wwstage (both loud-stop) per rule-10. #110: cgen is compiler-imported by w6c + wwdump — main.combined.ww regen'd for both. 949 rows: arg_{struct16,arr16,struct32}_{call,dot,idx,deref,ident}, full member readback (struct 16B reg-class + 32B sret-class + array [4]u32, each non-ident source + ident control); byteid=1 throughout (master both-broken-and-divergent → converge on the correct full push, #263). All 111 dotbaseaddr + 3/3 784 pass; test-unit 241 green; sizelint + smoke OK; the full w6c compiler source (214705 asm lines) self-compiles cs==ww byte-id.
This commit is contained in:
@@ -424,18 +424,66 @@ fn cgfnparams(c: *cgen, params: *node) void = {
|
||||
localaddstack(c, nm, p.lhs, 16 + stkcursor*8);
|
||||
stkcursor += nw;
|
||||
};};
|
||||
} else {
|
||||
if (idx < 6) {
|
||||
let off: i32 = localadd(c, nm, 8, p.lhs);
|
||||
emitline("\tMOVQ\t");
|
||||
emitline(argregname(idx));
|
||||
emitline(", ");
|
||||
emitoff(off: i64);
|
||||
emitline("(BP)\n");
|
||||
idx += 1;
|
||||
} else { let aggsz2: i32 = aggargsizetn(p.lhs.type_: *tinfo);
|
||||
if (aggsz2 > 0) {
|
||||
// #271: array / >16B-struct by-value param —
|
||||
// received as ceil(sz/8) GP eightbytes, the
|
||||
// callee twin of the generalised aggregate-arg
|
||||
// push. Mirror of the cstage is_bigagg arm
|
||||
// (regs-fit / partial-stitch / stack-spill).
|
||||
let nw2: i32 = (aggsz2 + 7) / 8;
|
||||
if (idx + nw2 <= 6) {
|
||||
let off: i32 = localadd(c, nm, aggsz2, p.lhs);
|
||||
let w: i32 = 0;
|
||||
for (w < nw2) {
|
||||
emitline("\tMOVQ\t");
|
||||
emitline(argregname(idx));
|
||||
emitline(", ");
|
||||
emitoff((off + w*8): i64);
|
||||
emitline("(BP)\n");
|
||||
idx += 1;
|
||||
w += 1;
|
||||
};
|
||||
} else { if (idx < 6) {
|
||||
let off: i32 = localadd(c, nm, aggsz2, p.lhs);
|
||||
let regs_left: i32 = 6 - idx;
|
||||
let w: i32 = 0;
|
||||
for (w < regs_left) {
|
||||
emitline("\tMOVQ\t");
|
||||
emitline(argregname(idx));
|
||||
emitline(", ");
|
||||
emitoff((off + w*8): i64);
|
||||
emitline("(BP)\n");
|
||||
idx += 1;
|
||||
w += 1;
|
||||
};
|
||||
for (w < nw2) {
|
||||
emitline("\tMOVQ\t");
|
||||
emitoff((16 + stkcursor*8): i64);
|
||||
emitline("(BP), AX\n");
|
||||
emitline("\tMOVQ\tAX, ");
|
||||
emitoff((off + w*8): i64);
|
||||
emitline("(BP)\n");
|
||||
stkcursor += 1;
|
||||
w += 1;
|
||||
};
|
||||
} else {
|
||||
localaddstack(c, nm, p.lhs, 16 + stkcursor*8);
|
||||
stkcursor += nw2;
|
||||
};};
|
||||
} else {
|
||||
localaddstack(c, nm, p.lhs, 16 + stkcursor*8);
|
||||
stkcursor += 1;
|
||||
if (idx < 6) {
|
||||
let off: i32 = localadd(c, nm, 8, p.lhs);
|
||||
emitline("\tMOVQ\t");
|
||||
emitline(argregname(idx));
|
||||
emitline(", ");
|
||||
emitoff(off: i64);
|
||||
emitline("(BP)\n");
|
||||
idx += 1;
|
||||
} else {
|
||||
localaddstack(c, nm, p.lhs, 16 + stkcursor*8);
|
||||
stkcursor += 1;
|
||||
};
|
||||
};
|
||||
};
|
||||
};};};
|
||||
|
||||
Reference in New Issue
Block a user