test: port the asm-pattern observers to ww; byteid carrier partition empty
Four ww tests carry the last eight native byteid carriers' assertions: asmwindow (753 convwrap beta/main/alpha order + window polarity, 754 slice stride + negative scale scan, 755 amp-dot-idx four rows, 758 first-CALL-line extraction + tab-framed disp literals, direct w6c/w6c_ww never ww build), freenoop (930 byte-id strengthened to per-stream compare + negative 'free' grep), structabi (946 param/ret MOVSD windows with polarity tables and SEND/RECV agreement), mangle (989_m1mangle needles + concat byte-id, glob order strengthened to byte-lexicographic). Dead want/stage_mask row fields documented, not invented into runtime legs; the w6c_ww-absent skip gates drop because the Make target declares the tools. BYTEID_WRAPPER_SOURCES, its bins, and test-native-byteid are deleted — the native byte/artifact partition is EMPTY (11 -> 0 this session); docs counts move to 123 carriers.
This commit is contained in:
240
test/byteid/structabi_test.ww
Normal file
240
test/byteid/structabi_test.ww
Normal file
@@ -0,0 +1,240 @@
|
||||
package structabi_test;
|
||||
|
||||
// Float-bearing struct-ABI byte-id + register-class gate. Port of the
|
||||
// retired native carriers test/wcc/946_structparam_run.c (#165, the
|
||||
// struct-PARAM SysV net) and test/wcc/946_structret_run.c (#171a, the
|
||||
// struct-RETURN twin); every assertion preserved.
|
||||
//
|
||||
// For a pure internal ww call both ends ride the same (possibly
|
||||
// wrong) registers, so runtime values AND cs==ww byte-id are
|
||||
// necessary-not-sufficient: the genuine defect is SysV register-CLASS
|
||||
// conformance, observable only in the emitted asm. Each row therefore
|
||||
// compiles its inline source directly through w6c and w6c_ww
|
||||
// (`-o out.s src.ww`), byte-ids the two .s (rule 10), and scans the
|
||||
// cstage .s (byte-id makes the wwstage scan redundant, as in the C)
|
||||
// for the SSE markers, PRESENT or ABSENT per row:
|
||||
//
|
||||
// param rows — callee receive marker "MOVSD\tX0, -" scoped to the
|
||||
// TEXT main.use block. Scoping is load-bearing: main's own
|
||||
// float-literal init also emits MOVSD X0, -off(BP), so a
|
||||
// whole-file grep would not discriminate.
|
||||
// ret rows — producer marker "(BP), X0" scoped to TEXT main.mk
|
||||
// (its literal fills load via (SP), X0, never (BP)) plus consumer
|
||||
// marker "MOVSD\tX0, -" scoped to TEXT main,; SEND and RECV
|
||||
// presence must AGREE before comparing against the row polarity.
|
||||
//
|
||||
// The ABSENT rows prove the classification gate: pure-INT structs
|
||||
// stay on the GP transport, and struct{f32,f32} (two f32 packing into
|
||||
// ONE SSE eightbyte — deferred #165b/#171b) falls back to GP instead
|
||||
// of wrongly riding two SSE regs.
|
||||
//
|
||||
// No runtime leg existed in the carriers (the sources embed value
|
||||
// checks but were only ever compiled to .s; end-to-end values live in
|
||||
// the r946_structparam_* / r946_structret_* fixtures) and none is
|
||||
// invented here. Dropped machinery, not assertions: the hard
|
||||
// w6c_ww-missing precondition (the Make target declares both tools; a
|
||||
// missing driver still fails loudly in runcommand), getpid tmpdirs +
|
||||
// rm/mkdir accounting (testenv.fresh/clean), and the 256KiB scan-
|
||||
// buffer refusal (testenv.readfile is unbounded).
|
||||
|
||||
import os;
|
||||
import os.exec;
|
||||
import strings;
|
||||
import testenv;
|
||||
import time;
|
||||
|
||||
fn fail(label: str, why: str) void = {
|
||||
let m: str = strings.concat("structabi FAIL: ", label, " -- ", why,
|
||||
"\n");
|
||||
os.write(2, m.ptr, m.len: u64);
|
||||
assert(false);
|
||||
};
|
||||
|
||||
fn tmo() time.duration = {
|
||||
return (180i64 * (time.second: i64)): time.duration;
|
||||
};
|
||||
|
||||
fn emitstage(td: str, label: str, stage: str, drv: str,
|
||||
outname: str) void = {
|
||||
let av: []str = [];
|
||||
append(av, drv);
|
||||
append(av, "-o");
|
||||
append(av, outname);
|
||||
append(av, "src.ww");
|
||||
let co: testenv.commandout;
|
||||
testenv.runcommand(td, td, stage, av, tmo(), &co);
|
||||
let ok: bool = co.termination == exec.termination.EXIT && co.code == 0;
|
||||
if (!ok) { fail(label, strings.concat(stage, " compile failed")); };
|
||||
};
|
||||
|
||||
// One function's TEXT block: [first `head` .. next "\nTEXT " after
|
||||
// it), to EOF when it is the last block. A missing head is a scan
|
||||
// error, never a silent ABSENT verdict.
|
||||
fn textblock(label: str, s: str, head: str) str = {
|
||||
let hp: i32 = testenv.pos(s, head);
|
||||
if (hp < 0) {
|
||||
fail(label, strings.concat("cannot scan .s: no ", head));
|
||||
};
|
||||
let tail: str = strings.sub(s, hp, s.len);
|
||||
let rest: str = strings.sub(tail, 1, tail.len);
|
||||
let ep: i32 = testenv.pos(rest, "\nTEXT ");
|
||||
if (ep < 0) { return tail; };
|
||||
return strings.sub(tail, 0, ep + 1);
|
||||
};
|
||||
|
||||
// Compile both stages and gate rule-10 byte identity; returns the
|
||||
// cstage .s body for the marker scan.
|
||||
fn buildpair(label: str, src: str, td: str) str = {
|
||||
testenv.writefile(strings.concat(td, "/src.ww"), src);
|
||||
emitstage(td, label, "cstage", testenv.driver("w6c"), "cs.s");
|
||||
emitstage(td, label, "wwstage", testenv.driver("w6c_ww"), "ws.s");
|
||||
let cs: str = testenv.readfile(strings.concat(td, "/cs.s"));
|
||||
let ws: str = testenv.readfile(strings.concat(td, "/ws.s"));
|
||||
if (!testenv.same(cs, ws)) {
|
||||
fail(label, "cstage/wwstage .s DIFFER (rule-10 byte-id violation)");
|
||||
};
|
||||
return cs;
|
||||
};
|
||||
|
||||
fn paramrow(label: str, src: str, wantsse: i32) void = {
|
||||
let td: str = testenv.fresh();
|
||||
let cs: str = buildpair(label, src, td);
|
||||
let callee: str = textblock(label, cs, "TEXT main.use");
|
||||
let sse: i32 = 0;
|
||||
if (testenv.has(callee, "MOVSD\tX0, -")) { sse = 1; };
|
||||
if (sse != wantsse) {
|
||||
fail(label,
|
||||
"callee SSE receive polarity wrong (register-class discriminator)");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
fn retrow(label: str, src: str, wantsse: i32) void = {
|
||||
let td: str = testenv.fresh();
|
||||
let cs: str = buildpair(label, src, td);
|
||||
let mk: str = textblock(label, cs, "TEXT main.mk");
|
||||
let mn: str = textblock(label, cs, "TEXT main,");
|
||||
let send: i32 = 0;
|
||||
if (testenv.has(mk, "(BP), X0")) { send = 1; };
|
||||
let recv: i32 = 0;
|
||||
if (testenv.has(mn, "MOVSD\tX0, -")) { recv = 1; };
|
||||
if (send != recv) {
|
||||
fail(label, "SEND and RECV SSE markers disagree");
|
||||
};
|
||||
if (send != wantsse) {
|
||||
fail(label,
|
||||
"struct return SSE polarity wrong (register-class discriminator)");
|
||||
};
|
||||
testenv.clean(td);
|
||||
};
|
||||
|
||||
// #165 param rows: lone-f64 eightbytes ride X0/X1 on independent
|
||||
// cursors; pure-INT and the f32f32 fallback stay GP-routed.
|
||||
@test fn structparam() void = {
|
||||
paramrow("f64f64_arg", strings.concat(
|
||||
"package main;\n",
|
||||
"type pff = struct { a: f64, b: f64 };\n",
|
||||
"fn use(s: pff) f64 = { return s.a + s.b; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pff = pff { a = 3.0, b = 5.0 };\n",
|
||||
"\tif (use(s) != 8.0) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
paramrow("f64i64_arg", strings.concat(
|
||||
"package main;\n",
|
||||
"type pfi = struct { a: f64, b: i64 };\n",
|
||||
"fn use(s: pfi) i64 = { return (s.a: i64) + s.b; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pfi = pfi { a = 3.0, b = 5 };\n",
|
||||
"\tif (use(s) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
paramrow("i64f64_arg", strings.concat(
|
||||
"package main;\n",
|
||||
"type pif = struct { a: i64, b: f64 };\n",
|
||||
"fn use(s: pif) i64 = { return s.a + (s.b: i64); };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pif = pif { a = 3, b = 5.0 };\n",
|
||||
"\tif (use(s) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
paramrow("i64i64_arg", strings.concat(
|
||||
"package main;\n",
|
||||
"type pii = struct { a: i64, b: i64 };\n",
|
||||
"fn use(s: pii) i64 = { return s.a + s.b; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pii = pii { a = 3, b = 5 };\n",
|
||||
"\tif (use(s) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 0);
|
||||
paramrow("f32f32_arg_fallback", strings.concat(
|
||||
"package main;\n",
|
||||
"type pf32 = struct { a: f32, b: f32 };\n",
|
||||
"fn use(s: pf32) i64 = { return (s.a: i64) + (s.b: i64); };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pf32 = pf32 { a = 3.0f32, b = 5.0f32 };\n",
|
||||
"\tif (use(s) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 0);
|
||||
paramrow("scalar_plus_f64f64", strings.concat(
|
||||
"package main;\n",
|
||||
"type pff = struct { a: f64, b: f64 };\n",
|
||||
"fn use(n: i64, s: pff) i64 = {\n",
|
||||
"\treturn n + (s.a: i64) + (s.b: i64);\n",
|
||||
"};\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pff = pff { a = 3.0, b = 5.0 };\n",
|
||||
"\tif (use(2, s) != 10) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
};
|
||||
|
||||
// #171a return rows: the return twin — lone-f64 eightbytes ride the
|
||||
// SSE return cursor, GP cursor independent (f64i32's i32 rides AX).
|
||||
@test fn structret() void = {
|
||||
retrow("f64f64_ret", strings.concat(
|
||||
"package main;\n",
|
||||
"type pff = struct { a: f64, b: f64 };\n",
|
||||
"fn mk() pff = { return pff { a = 3.0, b = 5.0 }; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pff = mk();\n",
|
||||
"\tif ((s.a: i64) + (s.b: i64) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
retrow("f64i32_ret", strings.concat(
|
||||
"package main;\n",
|
||||
"type pfi = struct { a: f64, b: i32 };\n",
|
||||
"fn mk() pfi = { return pfi { a = 3.0, b = 5 }; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pfi = mk();\n",
|
||||
"\tif ((s.a: i64) + (s.b: i64) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
retrow("i64f64_ret", strings.concat(
|
||||
"package main;\n",
|
||||
"type pif = struct { a: i64, b: f64 };\n",
|
||||
"fn mk() pif = { return pif { a = 3, b = 5.0 }; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pif = mk();\n",
|
||||
"\tif (s.a + (s.b: i64) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 1);
|
||||
retrow("i64i64_ret", strings.concat(
|
||||
"package main;\n",
|
||||
"type pii = struct { a: i64, b: i64 };\n",
|
||||
"fn mk() pii = { return pii { a = 3, b = 5 }; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pii = mk();\n",
|
||||
"\tif (s.a + s.b != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 0);
|
||||
retrow("f32f32_ret_fallback", strings.concat(
|
||||
"package main;\n",
|
||||
"type pf32 = struct { a: f32, b: f32 };\n",
|
||||
"fn mk() pf32 = { return pf32 { a = 3.0f32, b = 5.0f32 }; };\n",
|
||||
"export fn main() i32 = {\n",
|
||||
"\tlet s: pf32 = mk();\n",
|
||||
"\tif ((s.a: i64) + (s.b: i64) != 8) { return 1; };\n",
|
||||
"\treturn 0;\n",
|
||||
"};\n"), 0);
|
||||
};
|
||||
Reference in New Issue
Block a user