test: migrate Fam10 alias value tests to @test, carve divergences to pins (#5-C3)
fold-2 chunk C3 (drew's Fam8-13 plan): 8 alias value-row C drivers, 205 rows
re-homed with zero loss -- 177 value -> 8 test/lang/alias_*_test.ww @test
row-tables; 16 reject -> runww //ww:error carriers (both stages reject);
3 cs!=ww value rows -> 2 *_runonly_test.ww (T1, byte-id-excluded, #60/#81);
9 irreducible asymmetric rows -> slim C pins, each ticket-cited and
mutation-proven non-vacuous:
- accept amplen1/2,ampcap2: cs runs / ww rejects 'unsupported address-of
shape' (#96)
- cgen_b5 g73_heapfill: cs!=ww .s + ww link-fails on self-contained alloc;
compile-smoke pin (#24)
- cgen_b6 fsarg2_bound: both reject, different msgs, each vs the correct
stage (#271/#165 cs vs #272/#276/#277 ww)
- emit_b7 slc/slcstr/slctag _2lvl + slc_plain_ctl: slice-literal static-init
divergence (#120/#29-kin, ken-d2-oracle)
4 fully-migrated drivers deleted, 4 slimmed-in-place to hold only the
irreducible pins. LANGBYTEID floor 74->82 (8 new byte-id @test files); test
count 388->384 (4 deleted; 4 slimmed kept). do-not-auto-batch files not in
Fam10.
This commit is contained in:
@@ -1,133 +1,16 @@
|
||||
/*
|
||||
* 944_alias_cgen_b6_run — #5 alias arc F2b (B6 train): the cgen.c
|
||||
* cgexpr/cgstmt INLINE single-peel sweep through type_chase_named, by
|
||||
* consumer family — c1 assign/reassign (9 lines), c2 call-arg (8),
|
||||
* c3 addr-of/field-walk/index spine (14), c4 cast/is/try (10),
|
||||
* c5 reads/len/globals (8). All cs-only: every graduation is a
|
||||
* DIVERGE→byte-id flip (cs aligns UP to ww's already-chasing asm);
|
||||
* zero selfhost/lib bytes move across the train, so the _ww binaries
|
||||
* stay bit-identical (the crossing detector).
|
||||
* 944_alias_cgen_b6_run — SLIM CARRIER (#5-C3 alias fold-2). The 23 K_RUN value
|
||||
* rows migrated to test/lang/alias_cgen_b6_test.ww (@test, cs==ww byte-id); the
|
||||
* symmetric K_BUILDERR rejects (fsarg0_loud_ctl, try_loud_38b) to
|
||||
* test/wcc/data/alias_{fsarg0_loud,try_loud_38b}/case.ww runww.
|
||||
*
|
||||
* Row sources are ken's B6 first-position oracle probes
|
||||
* (/tmp/ken_b5/src/kb6_*, .ai/ken-b6-oracle.md, matrix at 4cac1cb).
|
||||
*
|
||||
* row | shape (oracle row) | cs/ww
|
||||
* --------------------+-------------------------------------+------
|
||||
* ---- c1 (assign/reassign: :6359 :6403/:6405 :6460/:6462 -------
|
||||
* :6518 + cgstmt :11696 :12047 :13625) -------------------
|
||||
* streassign_2lvl | kb6_streassign: 2-lvl alias str |
|
||||
* | reassign `b = a` — cs copied WORD0 |
|
||||
* | (ptr) ONLY, len/cap stale (silent |
|
||||
* | exit 1); the :6518 lu gate fell to |
|
||||
* | the scalar default. LIVE graduation | 0/0
|
||||
* wstore_a (B5 file) | kb5_wstore_a graduates K_RUN_NOID → |
|
||||
* | K_RUN in 944_alias_cgen_b5_run.c — |
|
||||
* | the ident-lhs N_ASSIGN tagged gate |
|
||||
* | (:6359) was the divergence (ken |
|
||||
* | C1-CORR-2, he owns the flip) | 0/0
|
||||
* sreassign_2lvl | kb6_sreassign: whole-struct alias |
|
||||
* | reassign — latent control | 0/0
|
||||
* dassign_2lvl | kb6_dassign: (*p).f= over alias ptr |
|
||||
* | — latent control | 0/0
|
||||
* ---- c2 (call-arg: :8402 :8435 :8561/:8563/:8577/:8579 --------
|
||||
* + LOUD-PRESERVING :8829 :8934) ------------------------
|
||||
* fsarg0_loud_ctl | kb6_fsarg0: PLAIN float-struct from |
|
||||
* | a non-ident source — #271/#165 loud |
|
||||
* | BOTH stages (control, twin texts) | err/err
|
||||
* fsarg2_bound | kb6_fsarg2: 1-alias-level respell — |
|
||||
* | pre-c2 the :8829 single-peel let |
|
||||
* | the alias DODGE the fatal; cs GP- |
|
||||
* | passed by self-consistent luck. |
|
||||
* | DESIGNED NARROWING: cs now louds |
|
||||
* | with the pinned #271/#165 text |
|
||||
* | ("widen what the gate SEES, never |
|
||||
* | what it ACCEPTS"). ww's loud is its |
|
||||
* | own alias-return bound (#272/#277 |
|
||||
* | class, experr_ww) — per-stage texts | err/err
|
||||
* fsarg_ident_ctl | kb6_fsarg: IDENT-source alias twin |
|
||||
* | — ident domain out of the :8829 |
|
||||
* | gate, latent control | 0/0
|
||||
* sarg_2lvl | kb6_sarg: >16B alias struct arg — |
|
||||
* | latent (B5 helper chases carry the |
|
||||
* | type layer) | 0/0
|
||||
* strarg_2lvl | kb6_strarg: alias str arg — latent | 0/0
|
||||
* (:8934 tuple loud is WATCH-ONLY: alias spellings are |
|
||||
* checker-blocked upstream (#86/#99) — the pin is the b5 |
|
||||
* suite's tuparg_cast_bound99 two-key cells, which must |
|
||||
* not move.) |
|
||||
* ---- c3 (addr-of/field-walk/index spine: :3949 :4006 ---------
|
||||
* :4124/:4128 :5029/:5035/:5052 :5937 :10953/:10956 -----
|
||||
* :11046/:11052/:11067 :11285, numbering at 4cac1cb) ----
|
||||
* idxf_2lvl / | kb6_idxf (indexed-elem struct field |
|
||||
* ampf_2lvl | write+read) / kb6_ampf (&p.b over |
|
||||
* | alias ptr): the c3 chase moved cs |
|
||||
* | onto the PLAIN-canonical dedicated |
|
||||
* | shape (cs_alias == ww_PLAIN, bit- |
|
||||
* | proven, ken c3-STOP addendum) — and |
|
||||
* | WWSTAGE was the alias-blind side at |
|
||||
* | these two sites (generic-but-correct |
|
||||
* | routes). GRADUATED to full byte-id |
|
||||
* | by the W2 ww fold, task #102 (the |
|
||||
* | two gates now chase the alias chain |
|
||||
* | via structlookupchain). ampf's |
|
||||
* | pre-c3 byte-id was both-on-generic |
|
||||
* | identity, not latency (oracle |
|
||||
* | self-correction) | 0/0
|
||||
* idxf_plain_ctl / | plain no-alias twins — pin the |
|
||||
* ampf_plain_ctl | canonical dedicated shape byte-id |
|
||||
* | BOTH stages (the convergence target |
|
||||
* | the NOID rows graduate onto) | 0/0
|
||||
* ampv_2lvl / | W2-review-found #102 sibling: &x.f |
|
||||
* ampv_plain_ctl | over an alias-NAMED VALUE struct — |
|
||||
* | the leg one below the &p.f gate had |
|
||||
* | the same alias-blind bare lookup |
|
||||
* | (ww_alias != ww_plain; cs_alias == |
|
||||
* | ww_plain, same bit-proven mechanism).|
|
||||
* | Chased in the W2 review amendment | 0/0
|
||||
* chdot_2lvl | kb6_chdot: chained dot over alias |
|
||||
* | hops — latent control | 0/0
|
||||
* esub_2lvl | kb6_esub: [3]my32b narrow-elem index |
|
||||
* | (#61/#101-kin at the INDEX sites) — |
|
||||
* | latent control | 0/0
|
||||
* ---- c4 (cast/is/try: :9422 :9598 :9674 :9718 :9819 ----------
|
||||
* :9986/:9991 :10103/:10105 :10131, numbering at 4cac1cb) -
|
||||
* strcast_2lvl | kb6_strcast: str→[]u8 over 2-lvl |
|
||||
* | alias — was both-correct divergent; |
|
||||
* | the :10103/:10105 tu/fu chase FLIPS |
|
||||
* | it (cs → ww's unchanged asm, #263 |
|
||||
* | polarity; alias == plain shape) | 0/0
|
||||
* idcast_2lvl | kb6_idcast: identity cast over alias |
|
||||
* | union (Family-C peel) — latent | 0/0
|
||||
* is_2lvl | kb6_is: `is` over alias union — |
|
||||
* | latent control | 0/0
|
||||
* try_loud_38b | kb6_try: `?` on a >48B sret-class |
|
||||
* | call result — the #38b loud is |
|
||||
* | ALIAS-INDEPENDENT (documented bound);|
|
||||
* | :9819's chase is loud-preserving |
|
||||
* | ONLY — twin texts, shared experr | err/err
|
||||
* ---- c5 (reads/len/globals: :3820 :7201 :7807 :7900 :9944 ----
|
||||
* :10224 :10750 :10873, numbering at 4cac1cb) ------------
|
||||
* tfread_2lvl | kb6_tfread: tagged-union field load |
|
||||
* | direct + through-ptr over alias |
|
||||
* | struct — was both-correct divergent; |
|
||||
* | the :10750/:10873 tag_fu chases FLIP |
|
||||
* | it (cs → ww's unchanged asm, #263 |
|
||||
* | polarity; alias == plain shape) | 0/0
|
||||
* len_2lvl | kb6_len: str+array len over 2-lvl |
|
||||
* | alias — latent control | 0/0
|
||||
* gref_2lvl | kb6_gref: alias scalar global value- |
|
||||
* | ref — latent control | 0/0
|
||||
* memread_40b | kb6_memread: 40B union, the :9944 |
|
||||
* | #37 cap-watch row — the `is` chase |
|
||||
* | keys the cap test on the CHASED size |
|
||||
* | (mirrors ww taggedmemread); byte- |
|
||||
* | NEUTRALITY here is the regression net| 0/0
|
||||
*
|
||||
* K_RUN rows build+run BOTH drivers (cs exit==cswant, ww exit==wwwant)
|
||||
* and assert cstage/wwstage asm byte-id. K_BUILDERR rows must FAIL
|
||||
* with experr on BOTH drivers; experr_ww overrides the ww-side text
|
||||
* when the two stages loud at DIFFERENT sites (per-stage texts).
|
||||
* NNN<950, self-contained /tmp sources, no imports (944 precedent).
|
||||
* What survives here is the one IRREDUCIBLE Group-B row: BOTH stages reject the
|
||||
* same input but with DIFFERENT diagnostics — a held cs!=ww divergence (a
|
||||
* rule-10 smell, tracked not silently merged). A single-substring runww
|
||||
* //ww:error would erase the distinction; this carrier asserts EACH stage's own
|
||||
* substring. cstage rejects with the #271/#165 SSE-eightbyte-transport reason;
|
||||
* wwstage rejects with the #272/#276/#277 aggregate-return scalar-default
|
||||
* reason (the float-bearing alias struct arg from a non-ident source).
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -145,35 +28,6 @@ runwait(const char *cmd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
slurp_eq(const char *a, const char *b)
|
||||
{
|
||||
FILE *fa = fopen(a, "rb");
|
||||
FILE *fb = fopen(b, "rb");
|
||||
if (!fa || !fb) { if (fa) fclose(fa); if (fb) fclose(fb); return -1; }
|
||||
int rc = 0;
|
||||
for (;;) {
|
||||
int ca = fgetc(fa), cb = fgetc(fb);
|
||||
if (ca != cb) { rc = -1; break; }
|
||||
if (ca == EOF) break;
|
||||
}
|
||||
fclose(fa); fclose(fb);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#define K_RUN 0 /* build+run BOTH, exits==wants, + byte-id */
|
||||
#define K_BUILDERR 1 /* build FAILS with experr on BOTH drivers;
|
||||
* experr_ww overrides the ww-side text */
|
||||
#define K_RUN_NOID 2 /* build+run BOTH, exits==wants, byte-id
|
||||
* SKIPPED — cite the blocking task */
|
||||
|
||||
struct row { const char *label; const char *src;
|
||||
int cswant; int wwwant; int kind;
|
||||
const char *experr; const char *experr_ww; };
|
||||
|
||||
/* errlog_has — a builderr cell must fail WITH its diagnostic; any other
|
||||
* failure (parse error, crash, hang-kill) is a vacuous reject (940
|
||||
* precedent). */
|
||||
static int
|
||||
errlog_has(const char *path, const char *needle)
|
||||
{
|
||||
@@ -186,69 +40,48 @@ errlog_has(const char *path, const char *needle)
|
||||
return strstr(buf, needle) != NULL;
|
||||
}
|
||||
|
||||
/* cstage (w6c) rejects with cserr; wwstage (w6c_ww) rejects with wwerr. */
|
||||
static int
|
||||
run_row(const char *bin, const char *label, const char *src,
|
||||
const char *cserr, const char *wwerr, int i)
|
||||
{
|
||||
char dir[96], srcf[160], cse[160], wwe[160], ss[160], rm[200], cmd[2048];
|
||||
snprintf(dir, sizeof dir, "/tmp/ab6_%d_%d", getpid(), i);
|
||||
mkdir(dir, 0755);
|
||||
snprintf(srcf, sizeof srcf, "%s/c.ww", dir);
|
||||
snprintf(cse, sizeof cse, "%s/cs.err", dir);
|
||||
snprintf(wwe, sizeof wwe, "%s/ww.err", dir);
|
||||
snprintf(ss, sizeof ss, "%s/o.s", dir);
|
||||
snprintf(rm, sizeof rm, "rm -rf %s", dir);
|
||||
|
||||
FILE *f = fopen(srcf, "wb");
|
||||
if (!f) { runwait(rm); return -1; }
|
||||
fputs(src, f);
|
||||
fclose(f);
|
||||
|
||||
int ok = 1;
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>%s", bin, ss, srcf, cse);
|
||||
int crc = runwait(cmd);
|
||||
if (!(crc != 0 && errlog_has(cse, cserr))) {
|
||||
fprintf(stderr, "row[%s]: cstage expected reject \"%s\" (rc=%d)\n",
|
||||
label, cserr, crc);
|
||||
ok = 0;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>%s", bin, ss, srcf, wwe);
|
||||
int wrc = runwait(cmd);
|
||||
if (!(wrc != 0 && errlog_has(wwe, wwerr))) {
|
||||
fprintf(stderr, "row[%s]: wwstage expected reject \"%s\" (rc=%d)\n",
|
||||
label, wwerr, wrc);
|
||||
ok = 0;
|
||||
}
|
||||
runwait(rm);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
struct row { const char *label; const char *src; const char *cserr;
|
||||
const char *wwerr; };
|
||||
|
||||
static const struct row rows[] = {
|
||||
/* ---- c1: assign/reassign family */
|
||||
/* LIVE c1 graduation: the :6518 reassign gate single-peeled the
|
||||
* 2-level alias str lhs, missed the TY_STR kind test, and fell
|
||||
* to the scalar default — ONE MOVQ stored the ptr word, len/cap
|
||||
* kept the dead value's header (cs silent exit 1, ww correct:
|
||||
* full 3-word {ptr,len,cap} store, Hare value semantics). */
|
||||
{ "streassign_2lvl",
|
||||
"package main;\n"
|
||||
"type ms0 = str;\n"
|
||||
"type ms = ms0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: ms = \"hello\";\n"
|
||||
" let b: ms = \"x\";\n"
|
||||
" b = a;\n"
|
||||
" if (len(b) != 5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "sreassign_2lvl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64, c: i64 };\n"
|
||||
"type st = st0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st; x.a = 1; x.b = 2; x.c = 3;\n"
|
||||
" let y: st; y.a = 0; y.b = 0; y.c = 0;\n"
|
||||
" y = x;\n"
|
||||
" if (y.c != 3 || y.b != 2) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "dassign_2lvl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64 };\n"
|
||||
"type st = st0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st; x.a = 1; x.b = 2;\n"
|
||||
" let p: *st = &x;\n"
|
||||
" (*p).b = 9;\n"
|
||||
" if (x.b != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* ---- c2: call-arg family */
|
||||
{ "fsarg0_loud_ctl",
|
||||
"package main;\n"
|
||||
"type fs0 = struct { x: f64 };\n"
|
||||
"fn mk() fs0 = {\n"
|
||||
" let s: fs0; s.x = 2.5;\n"
|
||||
" return s;\n"
|
||||
"};\n"
|
||||
"fn g(p: fs0) f64 = { return p.x; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (g(mk()) != 2.5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"#271/#165: float-bearing struct arg from a non-ident source",
|
||||
NULL },
|
||||
/* DESIGNED ACCEPTANCE NARROWING (B6-c2): pre-c2 cs accepted and
|
||||
* GP-passed this float struct correct-by-self-consistent-luck
|
||||
* (caller+callee agreed on the wrong transport) — the :8829
|
||||
* single peel let a 1-level alias dodge the rule-7 fatal. The
|
||||
* chase widens what the gate SEES; the loud stays loud for the
|
||||
* shapes it guards. ww's cell was ALREADY loud at its own
|
||||
* alias-return bound (#272/#276/#277 class) — different site,
|
||||
* per-stage experr. */
|
||||
{ "fsarg2_bound",
|
||||
"package main;\n"
|
||||
"type fs0 = struct { x: f64 };\n"
|
||||
@@ -261,381 +94,11 @@ static const struct row rows[] = {
|
||||
"export fn main() i32 = {\n"
|
||||
" if (g(mk()) != 2.5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"};\n",
|
||||
"#271/#165: float-bearing struct arg from a non-ident source",
|
||||
"#272/#276/#277: aggregate return reaches scalar default" },
|
||||
{ "fsarg_ident_ctl",
|
||||
"package main;\n"
|
||||
"type fs0 = struct { x: f64 };\n"
|
||||
"type fs = fs0;\n"
|
||||
"fn mk() fs0 = {\n"
|
||||
" let s: fs0; s.x = 2.5;\n"
|
||||
" return s;\n"
|
||||
"};\n"
|
||||
"fn g(p: fs) f64 = { return p.x; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: fs = mk();\n"
|
||||
" if (g(v) != 2.5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "sarg_2lvl",
|
||||
"package main;\n"
|
||||
"type big0 = struct { a: i64, b: i64, c: i64 };\n"
|
||||
"type big = big0;\n"
|
||||
"fn g(p: big) i64 = { return p.a + p.c; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: big; s.a = 4; s.b = 5; s.c = 9;\n"
|
||||
" if (g(s) != 13) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "strarg_2lvl",
|
||||
"package main;\n"
|
||||
"type ms0 = str;\n"
|
||||
"type ms = ms0;\n"
|
||||
"fn g(s: ms) i64 = { return len(s): i64; };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: ms = \"hello\";\n"
|
||||
" if (g(a) != 5) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* ---- c3: addr-of/field-walk/index spine */
|
||||
/* The c3 chase put cs on the PLAIN-canonical dedicated shape
|
||||
* (cs_alias == ww_PLAIN, bit-proven — ken c3-STOP addendum);
|
||||
* WWSTAGE was the alias-blind side here: its indexed-elem
|
||||
* struct-field store gate fell to a generic-but-correct route
|
||||
* on alias bases. GRADUATED: the W2 ww fold (task #102) chases
|
||||
* the alias chain (structlookupchain), restoring full byte-id —
|
||||
* idxf_plain_ctl pins the canonical shape both rows now share. */
|
||||
{ "idxf_2lvl",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64, b: i64 };\n"
|
||||
"type el = el0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: [2]el;\n"
|
||||
" xs[0].a = 1; xs[0].b = 2;\n"
|
||||
" xs[1].a = 3; xs[1].b = 4;\n"
|
||||
" if (xs[1].b != 4 || xs[0].b != 2) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL }, /* graduated: #102 (W2) */
|
||||
{ "idxf_plain_ctl",
|
||||
"package main;\n"
|
||||
"type el0 = struct { a: i64, b: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: [2]el0;\n"
|
||||
" xs[0].a = 1; xs[0].b = 2;\n"
|
||||
" xs[1].a = 3; xs[1].b = 4;\n"
|
||||
" if (xs[1].b != 4 || xs[0].b != 2) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* &p.b ptr-field fallback twin of the same re-attribution: the
|
||||
* pre-c3 byte-id here was BOTH stages on the generic spine
|
||||
* (gate-blind identity, not M5 latency — oracle self-correction
|
||||
* banked in ken's c3-STOP addendum). GRADUATED with #102 (W2). */
|
||||
{ "ampf_2lvl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64 };\n"
|
||||
"type st = st0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st; x.a = 1; x.b = 2;\n"
|
||||
" let p: *st = &x;\n"
|
||||
" let q: *i64 = &p.b;\n"
|
||||
" *q = 9;\n"
|
||||
" if (x.b != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL }, /* graduated: #102 (W2) */
|
||||
{ "ampf_plain_ctl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st0; x.a = 1; x.b = 2;\n"
|
||||
" let p: *st0 = &x;\n"
|
||||
" let q: *i64 = &p.b;\n"
|
||||
" *q = 9;\n"
|
||||
" if (x.b != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* W2-review-found #102 sibling: the value-struct &x.f leg sits
|
||||
* one leg below the &p.f gate in the same cgun single-DOT arm
|
||||
* and had the same alias-blind bare structlookup (ww_alias !=
|
||||
* ww_plain, cs_alias == ww_plain — the c3-STOP bit-test
|
||||
* mechanism verbatim). Chased in the W2 review amendment. */
|
||||
{ "ampv_2lvl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64 };\n"
|
||||
"type st = st0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st; x.a = 1; x.b = 2;\n"
|
||||
" let q: *i64 = &x.b;\n"
|
||||
" *q = 9;\n"
|
||||
" if (x.b != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL }, /* amendment: #102 (W2) */
|
||||
{ "ampv_plain_ctl",
|
||||
"package main;\n"
|
||||
"type st0 = struct { a: i64, b: i64 };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let x: st0; x.a = 1; x.b = 2;\n"
|
||||
" let q: *i64 = &x.b;\n"
|
||||
" *q = 9;\n"
|
||||
" if (x.b != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "chdot_2lvl",
|
||||
"package main;\n"
|
||||
"type in0 = struct { v: i64 };\n"
|
||||
"type in1 = in0;\n"
|
||||
"type out0 = struct { inner: in1, n: i64 };\n"
|
||||
"type out1 = out0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: out1; s.inner.v = 7; s.n = 3;\n"
|
||||
" let p: *out1 = &s;\n"
|
||||
" if (p.inner.v != 7) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "esub_2lvl",
|
||||
"package main;\n"
|
||||
"type my32 = u32;\n"
|
||||
"type my32b = my32;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let xs: [3]my32b;\n"
|
||||
" xs[0] = 5; xs[1] = 6; xs[2] = 7;\n"
|
||||
" if (xs[0]: i64 + xs[1]: i64 + xs[2]: i64 != 18) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* #101: NARROW-alias struct-FILL stride (the cgstructlitfill
|
||||
* :4791 leg, twin of esub_2lvl's INDEX leg). Pre-fold ww sized
|
||||
* the [3]my32 element off primsize("my32")=0 → 8B-default stride,
|
||||
* so the fill stored at -24/-16/-8 and field n collided with
|
||||
* arr[2] (run exit 1); cs chased my32→u32→4 (MOVL stride-4). The
|
||||
* aliasprimsize route aligns ww UP — kw1_101 was the SOLE corpus
|
||||
* mover (cs0/ww1 byteid-NO → byteid-YES + run 0). */
|
||||
{ "kw1_101",
|
||||
"package main;\n"
|
||||
"type my32 = u32;\n"
|
||||
"type S = struct { arr: [3]my32, n: int };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S { arr = [10u32, 20u32, 30u32], n = 4 };\n"
|
||||
" if (s.arr[0] + s.arr[1] + s.arr[2] != 60u32) { return 1; };\n"
|
||||
" if (s.n != 4) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* #101 control: a DIFFERENT narrow width (u16, stride-2 MOVW)
|
||||
* proves the routed esz is width-general, not a 4-only patch.
|
||||
* fld n must survive the fill untouched. */
|
||||
{ "kw1_ctl16",
|
||||
"package main;\n"
|
||||
"type my16 = u16;\n"
|
||||
"type S2 = struct { arr: [4]my16, n: int };\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s = S2 { arr = [1u16, 2u16, 3u16, 4u16], n = 9 };\n"
|
||||
" if (s.arr[0] + s.arr[1] + s.arr[2] + s.arr[3] != 10u16) { return 1; };\n"
|
||||
" if (s.n != 9) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* ---- c4: cast/is/try family */
|
||||
{ "strcast_2lvl",
|
||||
"package main;\n"
|
||||
"type ms0 = str;\n"
|
||||
"type ms = ms0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: ms = \"hey\";\n"
|
||||
" let b: []u8 = a: []u8;\n"
|
||||
" if (len(b) != 3) { return 1; };\n"
|
||||
" if (b[0] != 'h') { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "idcast_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" let w: u = (v: u);\n"
|
||||
" match (w) {\n"
|
||||
" case let n: i64 => { if (n != 42) { return 1; }; };\n"
|
||||
" case void => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "is_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let v: u = 42i64;\n"
|
||||
" if (!(v is i64)) { return 1; };\n"
|
||||
" if (v is void) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* ALIAS-INDEPENDENT #38b bound (ken's row is >48B sret-class):
|
||||
* the :9819 chase must stay loud-preserving — this pins the
|
||||
* fatal so a future chase can't silently green it. */
|
||||
{ "try_loud_38b",
|
||||
"package main;\n"
|
||||
"type e0 = !i64;\n"
|
||||
"type big = struct { a: i64, b: i64, c: i64, d: i64, e: i64, f: i64, g: i64 };\n"
|
||||
"type r0 = (big | e0);\n"
|
||||
"type r = r0;\n"
|
||||
"fn w() r = {\n"
|
||||
" let s: big;\n"
|
||||
" s.a = 1; s.b = 2; s.c = 3; s.d = 4; s.e = 5; s.f = 6; s.g = 77;\n"
|
||||
" return s;\n"
|
||||
"};\n"
|
||||
"fn outer() (i64 | e0) = {\n"
|
||||
" let v = w()?;\n"
|
||||
" return v.g;\n"
|
||||
"};\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" match (outer()) {\n"
|
||||
" case let n: i64 => { if (n != 77) { return 1; }; };\n"
|
||||
" case e0 => { return 2; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_BUILDERR,
|
||||
"#38b: `?`/`!` on an sret-class call result unwired", NULL },
|
||||
/* ---- c5: reads/len/globals family */
|
||||
{ "tfread_2lvl",
|
||||
"package main;\n"
|
||||
"type u0 = (void | i64);\n"
|
||||
"type u = u0;\n"
|
||||
"type st0 = struct { f: u, n: i64 };\n"
|
||||
"type st = st0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: st;\n"
|
||||
" s.f = 42i64;\n"
|
||||
" s.n = 3;\n"
|
||||
" if (!(s.f is i64)) { return 1; };\n"
|
||||
" let p: *st = &s;\n"
|
||||
" if (!(p.f is i64)) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "len_2lvl",
|
||||
"package main;\n"
|
||||
"type ms0 = str;\n"
|
||||
"type ms = ms0;\n"
|
||||
"type ar0 = [4]i64;\n"
|
||||
"type ar = ar0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let a: ms = \"hello\";\n"
|
||||
" if (len(a) != 5) { return 1; };\n"
|
||||
" let xs: ar = [1, 2, 3, 4];\n"
|
||||
" if (len(xs) != 4) { return 2; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
{ "gref_2lvl",
|
||||
"package main;\n"
|
||||
"type my64 = i64;\n"
|
||||
"type my64b = my64;\n"
|
||||
"let G: my64b = 7;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" if (G != 7) { return 1; };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
/* :9944 #37 cap-watch: the `is` site's >32B mem-read predicate
|
||||
* must key the CHASED size — byte-neutrality of this 40B-union
|
||||
* row across the c5 chase is the regression net. */
|
||||
{ "memread_40b",
|
||||
"package main;\n"
|
||||
"type big = struct { a: i64, b: i64, c: i64, d: i64, e: i64 };\n"
|
||||
"type m0 = (void | big);\n"
|
||||
"type m = m0;\n"
|
||||
"export fn main() i32 = {\n"
|
||||
" let s: big;\n"
|
||||
" s.a = 1; s.b = 2; s.c = 3; s.d = 4; s.e = 55;\n"
|
||||
" let v: m = s;\n"
|
||||
" if (!(v is big)) { return 1; };\n"
|
||||
" match (v) {\n"
|
||||
" case let w: big => { if (w.e != 55) { return 2; }; };\n"
|
||||
" case void => { return 3; };\n"
|
||||
" };\n"
|
||||
" return 0;\n"
|
||||
"};\n", 0, 0, K_RUN, NULL, NULL },
|
||||
};
|
||||
|
||||
static int
|
||||
run_driver(const char *driver, const struct row *r, int i, int expect_err,
|
||||
int want, const char *experr)
|
||||
{
|
||||
char tmpdir[96], src[128], outbin[128], errf[128], rmcmd[160];
|
||||
char cmd[1024];
|
||||
snprintf(tmpdir, sizeof tmpdir, "/tmp/ab6_%d_d_%d", getpid(), i);
|
||||
mkdir(tmpdir, 0755);
|
||||
snprintf(src, sizeof src, "%s/ab6_%d_%d.ww", tmpdir, getpid(), i);
|
||||
snprintf(outbin, sizeof outbin, "%s/ab6_%d_%d", tmpdir, getpid(), i);
|
||||
snprintf(errf, sizeof errf, "%s/err", tmpdir);
|
||||
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) { runwait(rmcmd); return -1; }
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd,
|
||||
"timeout 20 %s build -o %s %s >/dev/null 2>%s",
|
||||
driver, outbin, src, errf);
|
||||
int brc = runwait(cmd);
|
||||
if (expect_err) {
|
||||
int ok = (brc != 0)
|
||||
&& (experr == NULL || errlog_has(errf, experr));
|
||||
if (!ok)
|
||||
fprintf(stderr, "row[%s]: %s expected loud builderr "
|
||||
"\"%s\" (brc=%d)\n", r->label, driver,
|
||||
experr ? experr : "", brc);
|
||||
runwait(rmcmd);
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
if (brc != 0) {
|
||||
fprintf(stderr, "row[%s]: build via %s failed\n",
|
||||
r->label, driver);
|
||||
runwait(rmcmd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int got = runwait(outbin);
|
||||
|
||||
runwait(rmcmd);
|
||||
if (got != want) {
|
||||
fprintf(stderr, "row[%s]: %s exit %d, want %d\n",
|
||||
r->label, driver, got, want);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
asm_byte_identical(const char *bin, const struct row *r, int i)
|
||||
{
|
||||
char src[96], cs[96], ws[96], cmd[1024];
|
||||
snprintf(src, sizeof src, "/tmp/ab6_asm_%d_%d.ww", getpid(), i);
|
||||
snprintf(cs, sizeof cs, "/tmp/ab6_asm_%d_%d_c.s", getpid(), i);
|
||||
snprintf(ws, sizeof ws, "/tmp/ab6_asm_%d_%d_w.s", getpid(), i);
|
||||
|
||||
FILE *f = fopen(src, "wb");
|
||||
if (!f) return -1;
|
||||
fputs(r->src, f);
|
||||
fclose(f);
|
||||
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>/dev/null", bin, cs, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c errored\n", r->label);
|
||||
unlink(src);
|
||||
return -1;
|
||||
}
|
||||
snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>/dev/null",
|
||||
bin, ws, src);
|
||||
if (runwait(cmd) != 0) {
|
||||
fprintf(stderr, "row[%s]: w6c_ww errored\n", r->label);
|
||||
unlink(src); unlink(cs);
|
||||
return -1;
|
||||
}
|
||||
int rc = slurp_eq(cs, ws);
|
||||
if (rc != 0)
|
||||
fprintf(stderr, "row[%s]: cstage vs wwstage asm differs\n",
|
||||
r->label);
|
||||
unlink(src); unlink(cs); unlink(ws);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
@@ -649,41 +112,17 @@ main(void)
|
||||
bin = absbin;
|
||||
}
|
||||
|
||||
char cdrv[2120], wdrv[2120];
|
||||
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
|
||||
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
|
||||
|
||||
int n = (int)(sizeof rows / sizeof rows[0]);
|
||||
int total = 0, fail = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
int cs_err = rows[i].kind == K_BUILDERR;
|
||||
if (run_driver(cdrv, &rows[i], i, cs_err,
|
||||
rows[i].cswant, rows[i].experr) != 0) fail++;
|
||||
}
|
||||
if (access(wdrv, X_OK) == 0) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
total++;
|
||||
int ww_err = rows[i].kind == K_BUILDERR;
|
||||
const char *we = rows[i].experr_ww
|
||||
? rows[i].experr_ww : rows[i].experr;
|
||||
if (run_driver(wdrv, &rows[i], i, ww_err,
|
||||
rows[i].wwwant, we) != 0) fail++;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (rows[i].kind != K_RUN)
|
||||
continue;
|
||||
total++;
|
||||
if (asm_byte_identical(bin, &rows[i], i) != 0) fail++;
|
||||
}
|
||||
}
|
||||
int fail = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
if (run_row(bin, rows[i].label, rows[i].src, rows[i].cserr,
|
||||
rows[i].wwerr, i) != 0)
|
||||
fail++;
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "alias_cgen_b6: %d/%d checks failed\n",
|
||||
fail, total);
|
||||
fprintf(stderr, "alias_cgen_b6 (slim): %d/%d rows failed\n", fail, n);
|
||||
return 1;
|
||||
}
|
||||
printf("alias_cgen_b6: %d/%d ok\n", total, total);
|
||||
printf("alias_cgen_b6 (slim): %d/%d ok\n", n, n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user