Files
ww/test/lang/idx_dot_aggret_recv_test.ww
Hojun-Cho a0e330b283 cgen: store all eightbytes when an in-cap aggregate call returns into a field of an indexed element (#11)
The arr[i].f=mk() assign arm had no aggregate-field sub-arm, so a by-value aggregate field receive fell to the scalar default (one MOVQ, dropping DX/CX) — silent on BOTH stages (byte-id blind). Add a dual-site symmetric in-cap N_CALL arm mirroring C2c (c83a340): scratch-first materialise AX/DX/CX, then word-copy to (fi.foff+k*8) within &arr[i], sizing from the natural field size fi.fsz (not slotsize). Rule-7 LOUD-STOP for the three cases the in-cap GP path cannot transport: over-cap sret (#11c/#234), a float-bearing field whose eightbyte classifies SSE (#11/#165), and a 3/5/6/7-byte sub-8 tail the single narrow tail MOV cannot express (the general cascade tail is the shared C2c/#11 follow-up, task #10). Value-asserting pins (poison-seeded, redden under each stage's independent revert) plus cfail pins for the three loud-stops.

Contained to the indexed base + in-cap call rhs; arr[i].f=src (#11b) and over-cap (#11c) are separate.
2026-06-27 18:49:03 +09:00

84 lines
3.3 KiB
Plaintext

// idx_dot_aggret_recv_test — #11: an in-cap aggregate-returning CALL received
// into an AGGREGATE field of an INDEXED element `arr[i].f = mk()`. Pre-fix the
// N_DOT(N_INDEX) assign arm had no case for a struct/array/tuple field filled
// from an in-cap (<=24B, AX/DX/CX-return) call rhs: it fell to the 1-word
// scalar default — only AX (eb0) stored, DX/CX dropped. BOTH stages emitted
// byte-IDENTICAL wrong asm (gate-blind, the #263 both-wrong form). The field-
// of-indexed twin of C2c (idx_aggret_recv_test) — a DIFFERENT cgassign arm.
// Each @test POISON-seeds the field + its neighbour with sentinel 9 (distinct
// from 0 AND every expected value) and asserts EVERY member: a dropped word
// then reads 9 and fails. Covers full=2, full=3 (CX word), the sub-8-tail MOVL
// row (anti-clobber: the 12B field's tail MUST stay MOVL — a widened MOVQ would
// smash the adjacent g at +12), foff!=0, and bases [N]S / *[N]S / []S with
// const + runtime index. The sub-8-tail rows use a GLOBAL-backed base: a LOCAL
// [N]<sub-8-tail-struct> array trips a SEPARATE PRE-EXISTING let-array slotsize
// cs!=ww frame divergence (see the _runonly twin), independent of #11. T2 keeps
// the cs==ww net.
package idx_dot_aggret_recv_test;
type t16 = struct { a: i64, b: i64 };
type t24 = struct { a: i64, b: i64, c: i64 };
type t12 = struct { a: i32, b: i32, c: i32 };
type s16 = struct { f: t16, g: i64 };
type s24 = struct { f: t24, g: i64 };
type sfnf = struct { g: i64, f: t16 };
type s12 = struct { f: t12, g: i32 };
let g12p: [2]s12 = [s12{f=t12{a=9i32,b=9i32,c=9i32},g=9i32}, s12{f=t12{a=9i32,b=9i32,c=9i32},g=9i32}];
let g12s: [2]s12 = [s12{f=t12{a=9i32,b=9i32,c=9i32},g=9i32}, s12{f=t12{a=9i32,b=9i32,c=9i32},g=9i32}];
fn mk16() t16 = { return t16{a=40i64, b=20i64}; };
fn mk24() t24 = { return t24{a=100i64, b=20i64, c=3i64}; };
fn mk12() t12 = { return t12{a=10i32, b=20i32, c=30i32}; };
fn one() i64 = { return 1i64; };
// full=2, [N]S value-array local, const index, foff=0
@test fn struct16_local_const() void = {
let a: [2]s16 = [s16{f=t16{a=9i64,b=9i64},g=9i64}, s16{f=t16{a=9i64,b=9i64},g=9i64}];
a[1].f = mk16();
assert(a[1].f.a == 40i64);
assert(a[1].f.b == 20i64);
assert(a[1].g == 9i64);
assert(a[0].f.a == 9i64);
};
// full=3 (CX word), [N]S value-array local, runtime index, foff=0
@test fn struct24_local_runtime() void = {
let a: [2]s24 = [s24{f=t24{a=9i64,b=9i64,c=9i64},g=9i64}, s24{f=t24{a=9i64,b=9i64,c=9i64},g=9i64}];
a[one()].f = mk24();
assert(a[1].f.a == 100i64);
assert(a[1].f.b == 20i64);
assert(a[1].f.c == 3i64);
assert(a[1].g == 9i64);
};
// foff != 0 (f at offset 8), [N]S local, const index
@test fn fnotfirst_local() void = {
let a: [2]sfnf = [sfnf{g=9i64,f=t16{a=9i64,b=9i64}}, sfnf{g=9i64,f=t16{a=9i64,b=9i64}}];
a[1].f = mk16();
assert(a[1].f.a == 40i64);
assert(a[1].f.b == 20i64);
assert(a[1].g == 9i64);
};
// sub-8-tail (12B, MOVL tail), *[N]S -> global, const index
@test fn subtail_ptr_const() void = {
let p: *[2]s12 = &g12p;
p[1].f = mk12();
assert(g12p[1].f.a == 10i32);
assert(g12p[1].f.b == 20i32);
assert(g12p[1].f.c == 30i32);
assert(g12p[1].g == 9i32);
};
// sub-8-tail (12B, MOVL tail), []S -> global, runtime index
@test fn subtail_slice_runtime() void = {
let sl: []s12 = g12s[0:2];
sl[one()].f = mk12();
assert(g12s[1].f.a == 10i32);
assert(g12s[1].f.b == 20i32);
assert(g12s[1].f.c == 30i32);
assert(g12s[1].g == 9i32);
};