selfhost/cmd/wcc/cgenutil: tagged-store machinery reads tinfo.params (#68)

cgwidentaggedstore/storebp/cgwidentagremap took a type *node and re-derived
the tagged shape via resolvetagged + N_TTAGGED.list walks. Migrate them onto
the stamped tinfo (the store-side parallel of #66's match-side flip): dst is
now the tagged *tinfo (peel TY_NAMED->du, gate TY_TAGGED), variant lookup +
tag-remap read tinfo.params by typeeq, mirroring cstage cg_widen_tagged_store
/ cg_widen_tag_remap / cg_tag_for_variant (cmd/w6c/cgen.c:1273/1177/503). The
N_CAST widening test flips from surface-name streq to `castu==dt || (castu
tagged && typeeq(castt,dst))` (cgen.c:1295).

Node-form flatvariantidx/taggedvariantindex become thin shims over new tinfo
cores (flatvariantidxt/taggedvariantindext) so node-side callers (cgreturn
cgenstmt:269, pushargs cgenutil:192) are untouched. The 9 cgwidentaggedstore
callers pass node.type_ (each already istaggedtype/slotsize-gated). resolvetagged
is retained for its 7 match-side callers.

Incidentally retires two latent ww-vs-cstage divergences, both byte-id-neutral
on the corpus: the old N_CAST test set castisdst for ANY N_TTAGGED regardless
of type equality (cstage guards on type_eq), and the old remap walked the
UNflattened src.list (cstage walks the flattened params). Unblocks cgassign's
indexvaluetnode drop (#69/#61d). make test 134/134, byte-id 990-997 hold.
This commit is contained in:
2026-05-23 22:57:13 +09:00
parent aec48e8c13
commit 901ddf20b9
5 changed files with 354 additions and 288 deletions

View File

@@ -225,7 +225,7 @@ fn cgreturn(c: *cgen, n: *node) void = {
emitline("(BP)\n");
zz += 8;
};
cgwidentaggedstore(c, c.fnret, rhs, "BP",
cgwidentaggedstore(c, c.fnret.type_: *tinfo, rhs, "BP",
scroff, rsz);
emitline("\tMOVQ\t");
emitoff(scroff: i64);
@@ -715,7 +715,7 @@ fn cglet(c: *cgen, n: *node) void = {
// ABI call), struct payload (literal/ident), str payload,
// scalar payload — with tag remap for tagged-subset widening.
if (istaggedtype(c, tn)) {
cgwidentaggedstore(c, tn, rhs, "BP", off, sz);
cgwidentaggedstore(c, tn.type_: *tinfo, rhs, "BP", off, sz);
c.lastwasreturn = 0;
return;
};