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

@@ -3144,7 +3144,7 @@ fn cgcall(c: *cgen, n: *node) void = {
// dst is the per-element tagged type;
// pass velem (cstage cgen.c:4382 passes
// velem, not the slice wrap vsu).
cgwidentaggedstore(c, velem,
cgwidentaggedstore(c, velem.type_: *tinfo,
aa2, "BP", slot, esz);
} else { if (velemstr) {
cgexpr(c, aa2);
@@ -3479,7 +3479,7 @@ fn cgassign(c: *cgen, n: *node) void = {
if (lc != nil) {
if (istaggedtype(c, lc.tnode)) {
let lsz: i32 = slotsize(c, lc.tnode);
cgwidentaggedstore(c, lc.tnode,
cgwidentaggedstore(c, lc.tnode.type_: *tinfo,
n.rhs, "BP", lc.off, lsz);
return;
};
@@ -3759,7 +3759,7 @@ fn cgassign(c: *cgen, n: *node) void = {
emitline("(BP)\n");
zz += 8;
};
cgwidentaggedstore(c, elemtn, n.rhs,
cgwidentaggedstore(c, elemtn.type_: *tinfo, n.rhs,
"BP", scroff, slot_sz);
cgexpr(c, idx);
if (slot_sz > 1) {
@@ -4137,7 +4137,7 @@ fn cgassign(c: *cgen, n: *node) void = {
emitline("\tMOVQ\t");
emitoff(lc.off: i64);
emitline("(BP), BX\n");
cgwidentaggedstore(c, fi.tnode,
cgwidentaggedstore(c, fi.tnode.type_: *tinfo,
n.rhs, "BX", fi.foff, fsz);
return;
};
@@ -4374,7 +4374,7 @@ fn cgassign(c: *cgen, n: *node) void = {
if (n.op == tkind.TK_ASSIGN
&& istaggedtype(c, fi.tnode)) {
let fsz: i32 = slotsize(c, fi.tnode);
cgwidentaggedstore(c, fi.tnode,
cgwidentaggedstore(c, fi.tnode.type_: *tinfo,
n.rhs, "BP", lc.off + fi.foff, fsz);
return;
};