wcc_ww/cgen: collapse cgenutil.ww's plain TY_NAMED chase loops into tichase — byte-id neutral

Mechanical sweep, F2a batch 2 commit 1 (alias arc #5, rob batch-2 spec
c1; same conversion rule as batch-1 ef93b16). Every loop matching the
exact plain shape

    for (X != nil && X.kind == tykind.TY_NAMED) { X = X.under; };

(modulo variable name and one-line vs three-line layout, body exactly
the peel, guard exactly nil+NAMED) becomes `X = tichase(X);`. Census
of cgenutil.ww at 486f7f8: 63 raw `.under` lines, eyes-classified;
38 plain-shape loops converted.

Survivor enumeration (raw `.under` lines left, by post-sweep line):
- 1297 comment text only — not a read.
- 1301 tichase's own body — the accessor itself.
- 1531/1553 elemsizeofc internals — c3/B3 behavior scope (task #83),
  excluded from c1 per spec.
- 2073/2075/2078 exprprimresolved N_DOT single-peel ifs — c3/B1.
- 2719 nullableptrtag variant-scan single-peel if — c3/B2.
- 2868 flatvariantidxt structural-fallback guard (`pu.under != nil &&
  typeeq(pu.under, want)`) — one-level BY DESIGN pending task #17;
  not the plain shape.
- 2895/2904/2923-2924/2934-2935 tyassignableuntyped one-level
  unwraps — c4 acceptance scope.
- 3415/3471/3526/3674/3731/3783/3796/3861/4083/4089 inside
  cgwidentaggedstore(bp) — c2 L2-twin scope, excluded wholesale.

Byte-id evidence: post-sweep w6c_ww vs pre-sweep (486f7f8 build) on
the five HEAD main.combined.ww — byte-identical .s on every input;
cs w6c vs new w6c_ww on the regenerated combined.ww — byte-identical
all five; make test-unit green (288). combined.ww regens ride along
(cgenutil.ww embeds in w6c + wwdump).
This commit is contained in:
2026-06-05 21:40:27 +09:00
parent 486f7f87f9
commit f19d0cb14d
3 changed files with 114 additions and 180 deletions

View File

@@ -16217,13 +16217,9 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
if (memptype != nil) {
let pt: *tinfo = memptype.type_: *tinfo;
let pu: *tinfo = pt;
for (pu != nil && pu.kind == tykind.TY_NAMED) {
pu = pu.under;
};
pu = tichase(pu);
let au: *tinfo = at;
for (au != nil && au.kind == tykind.TY_NAMED) {
au = au.under;
};
au = tichase(au);
if (pu != nil && pu == au) { same = true; };
if (!same && pt != nil && at != nil) {
if (typeeq(pt, at)) { same = true; };
@@ -16429,9 +16425,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// literal/cast forms and loud-stops the rest (#72). Mirrors
// cstage cg_widen_tagged_push src_is_tuple.
let argtup: *tinfo = arg.type_: *tinfo;
for (argtup != nil && argtup.kind == tykind.TY_NAMED) {
argtup = argtup.under;
};
argtup = tichase(argtup);
let argistuple: bool = false;
if (argtup != nil) {
if (argtup.kind == tykind.TY_TUPLE) {
@@ -16538,9 +16532,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let dotbu: *tinfo = nil;
if (base != nil) { if (base.kind == nkind.N_DOT) {
dotbu = base.type_: *tinfo;
for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) {
dotbu = dotbu.under;
};
dotbu = tichase(dotbu);
};};
// #60 (alias arc #5): alias-NAMED N_IDENT base — the tnode
// reads below see only the N_TNAME leaf (esz 1-sentinel,
@@ -16798,9 +16790,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let structident: bool = false;
if (arg.kind == nkind.N_IDENT) {
let st: *tinfo = arg.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) {
st = st.under;
};
st = tichase(st);
if (st != nil) { if (st.kind == tykind.TY_STRUCT) {
if (st.size: i32 <= 16) { structident = true; };
}; };
@@ -16914,9 +16904,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// nodes and literal value exprs. Mirrors the cstage
// restage guard.
let eti: *tinfo = et.type_: *tinfo;
for (eti != nil && eti.kind == tykind.TY_NAMED) {
eti = eti.under;
};
eti = tichase(eti);
if (eti != nil) {
if (eti.kind == tykind.TY_TUPLE
|| eti.kind == tykind.TY_STRUCT
@@ -16983,9 +16971,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// register. Mirrors the cstage cgcall guard.
{
let ati: *tinfo = arg.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) {
ati = ati.under;
};
ati = tichase(ati);
if (ati != nil) {
if (ati.kind == tykind.TY_TUPLE) {
let m32: str = "#32: tuple arg from unsupported source shape (call/ident/literal/unwrap only; rule 7)\n";
@@ -17395,7 +17381,7 @@ fn tichase(t0: *tinfo) *tinfo = {
// avoid widening the frontend surface for one #156 read-half check.
fn tinfoisarray(t: *tinfo) bool = {
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
return u.kind == tykind.TY_ARRAY;
};
@@ -17501,10 +17487,10 @@ export fn localloadop(c: *cgen, tnode: *node) str = {
// through here. Mirrors cstage idx_eff (cmd/w6c/cgen.c:1163).
fn idxeffti(t0: *tinfo) *tinfo = {
let t: *tinfo = t0;
for (t != nil && t.kind == tykind.TY_NAMED) { t = t.under; };
t = tichase(t);
if (t != nil && t.kind == tykind.TY_PTR) {
let p: *tinfo = t.sub;
for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; };
p = tichase(p);
if (p != nil && p.kind == tykind.TY_ARRAY) { return p; };
};
return t;
@@ -17790,9 +17776,7 @@ fn structabisize(si: *structinfo) i32 = {
if (end > n) { n = end; };
if (fi.tnode != nil) {
let ti: *tinfo = fi.tnode.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) {
ti = ti.under;
};
ti = tichase(ti);
if (ti != nil) {
let aln: i32 = ti.align: i32;
if (aln > maxaln) { maxaln = aln; };
@@ -17895,7 +17879,7 @@ export fn sretretsize(c: *cgen, t: *node) i32 = {
// no float-array-return consumer (structfloatclass stays struct-only).
if (r.kind == nkind.N_TARRAY) {
let ati: *tinfo = r.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) { ati = ati.under; };
ati = tichase(ati);
if (ati == nil) { return 0; };
let asz: i32 = ati.size: i32;
if (asz <= 24) { return 0; };
@@ -18308,7 +18292,7 @@ fn slotsize(c: *cgen, typn: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let kk: tykind = ti.kind;
if (kk == tykind.TY_VOID) { return 0; };
@@ -18346,7 +18330,7 @@ fn fieldsize(c: *cgen, tnode: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let k: tykind = ti.kind;
if (k == tykind.TY_STRUCT) { return ti.slotsize: i32; };
@@ -18603,7 +18587,7 @@ fn structparamsize(c: *cgen, t: *node) i32 = {
fn aggargsizetn(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind == tykind.TY_STRUCT || u.kind == tykind.TY_ARRAY) {
return u.size: i32;
@@ -18621,7 +18605,7 @@ fn aggargsizetn(t: *tinfo) i32 = {
fn taggedmemargsize(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind != tykind.TY_TAGGED) { return 0; };
if (u.nullable != 0) { return 0; };
@@ -18644,7 +18628,7 @@ fn nodeisaggarg(n: *node) bool = {
fn aggargfloatstop(n: *node) bool = {
if (n == nil) { return false; };
let st: *tinfo = n.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return false; };
if (st.kind != tykind.TY_STRUCT) { return false; };
if (st.size: i32 > 16) { return false; };
@@ -18750,7 +18734,7 @@ fn istaggedtype(c: *cgen, t: *node) bool = {
fn tnodeisagg(t: *node) bool = {
if (t == nil) { return false; };
let u: *tinfo = t.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind == tykind.TY_STRUCT) { return true; };
if (u.kind == tykind.TY_ARRAY) { return true; };
@@ -18796,7 +18780,7 @@ export fn nullableptrtag(t: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 0; };
if (ti.kind != tykind.TY_TAGGED) { return 0; };
let p: *tparam = ti.params;
@@ -18858,7 +18842,7 @@ fn taggedvariantindext(c: *cgen, du: *tinfo, rhs: *node) i32 = {
if (du == nil) { return -1; };
if (rhs == nil) { return -1; };
let ti: *tinfo = du;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let r: i32 = flatvariantidxt(ti, rhs.type_: *tinfo);
@@ -18918,7 +18902,7 @@ fn flatvariantidx(c: *cgen, tagged: *node, pat: *node) i32 = {
fn flatvariantidxt(tagged: *tinfo, want: *tinfo) i32 = {
if (want == nil) { return -1; };
let ti: *tinfo = tagged;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
// Pass 1: exact match (NAMED-vs-NAMED typeeq, tagged-vs-tagged, bare
@@ -19060,9 +19044,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
};
if (vt.kind == tykind.TY_NAMED || want.kind == tykind.TY_NAMED) {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu != nil && wu != nil
&& vu.kind == tykind.TY_TAGGED
&& wu.kind == tykind.TY_TAGGED) {
@@ -19080,9 +19064,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
// cstage cg_variant_struct_match (cmd/w6c/cgen.c).
fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu == nil) { return false; };
if (wu == nil) { return false; };
return typeeq(vu, wu);
@@ -19102,7 +19086,7 @@ fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (tagged == nil) { return -1; };
let ti: *tinfo = tagged.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let want: *tinfo = nil;
@@ -19117,7 +19101,7 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (fallback < 0) { fallback = idx; };
if (want != nil) {
let su: *tinfo = vt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
if (su != nil) {
if (typeeq(su.sub, want)) { return idx; };
};
@@ -19140,11 +19124,11 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
// (cmd/w6c/cgen.c:1177) over su->params + cg_tag_for_variant (:503).
fn cgwidentagremap(c: *cgen, du: *tinfo, su: *tinfo, slot_off: i32) void = {
let dt: *tinfo = du;
for (dt != nil && dt.kind == tykind.TY_NAMED) { dt = dt.under; };
dt = tichase(dt);
if (dt == nil) { return; };
if (dt.kind != tykind.TY_TAGGED) { return; };
let st: *tinfo = su;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return; };
if (st.kind != tykind.TY_TAGGED) { return; };
let identity: bool = true;
@@ -19316,7 +19300,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
if (e == nil) { return false; };
if (e.kind == nkind.N_UN && e.op == tkind.TK_STAR) {
let du: *tinfo = e.type_: *tinfo;
for (du != nil && du.kind == tykind.TY_NAMED) { du = du.under; };
du = tichase(du);
if (du == nil) { return false; };
if (du.kind != tykind.TY_TAGGED) { return false; };
if (du.nullable != 0) { return false; };
@@ -19324,7 +19308,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
};
if (e.kind != nkind.N_INDEX && e.kind != nkind.N_DOT) { return false; };
let u: *tinfo = e.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind != tykind.TY_TAGGED) { return false; };
return u.size: i32 > TUPLE_GPCAP * 8;
@@ -19341,12 +19325,12 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
fn taggedcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
if (cu.nullable != 0) { return e; };
let iu: *tinfo = e.lhs.type_: *tinfo;
for (iu != nil && iu.kind == tykind.TY_NAMED) { iu = iu.under; };
iu = tichase(iu);
if (iu == nil) { return e; };
if (iu.kind != tykind.TY_TAGGED) { return e; };
if (iu.nullable != 0) { return e; };
@@ -19365,7 +19349,7 @@ fn taggedidcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
if (!typeeq(e.type_: *tinfo, e.lhs.type_: *tinfo)) { return e; };
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
e = e.lhs;
@@ -20315,16 +20299,12 @@ export fn dotchainresolve(c: *cgen, n: *node,
// (plus one TY_PTR hop for a `*struct` root). tfield.type_ then
// supplies each nested struct directly, so no name re-lookup.
let curstruct: *tinfo = cur.type_: *tinfo;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
if (*outptrroot) {
if (curstruct == nil) { return false; };
if (curstruct.kind != tykind.TY_PTR) { return false; };
curstruct = curstruct.sub;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
};
let i: i32 = nsteps - 1;
for (i >= 0) {
@@ -20346,7 +20326,7 @@ export fn dotchainresolve(c: *cgen, n: *node,
return true;
};
let ft: *tinfo = found.type_;
for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; };
ft = tichase(ft);
if (ft == nil) { return false; };
if (ft.kind == tykind.TY_STR) {
// str IS []u8: .cap is the third header word, same as
@@ -20891,9 +20871,7 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node,
let agsz49: i32 = 0;
if (fi.tnode != nil) {
let agti49: *tinfo = fi.tnode.type_: *tinfo;
for (agti49 != nil && agti49.kind == tykind.TY_NAMED) {
agti49 = agti49.under;
};
agti49 = tichase(agti49);
if (agti49 != nil) { agsz49 = agti49.size: i32; };
};
aggcopy(c, agsz49);

View File

@@ -145,13 +145,9 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
if (memptype != nil) {
let pt: *tinfo = memptype.type_: *tinfo;
let pu: *tinfo = pt;
for (pu != nil && pu.kind == tykind.TY_NAMED) {
pu = pu.under;
};
pu = tichase(pu);
let au: *tinfo = at;
for (au != nil && au.kind == tykind.TY_NAMED) {
au = au.under;
};
au = tichase(au);
if (pu != nil && pu == au) { same = true; };
if (!same && pt != nil && at != nil) {
if (typeeq(pt, at)) { same = true; };
@@ -357,9 +353,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// literal/cast forms and loud-stops the rest (#72). Mirrors
// cstage cg_widen_tagged_push src_is_tuple.
let argtup: *tinfo = arg.type_: *tinfo;
for (argtup != nil && argtup.kind == tykind.TY_NAMED) {
argtup = argtup.under;
};
argtup = tichase(argtup);
let argistuple: bool = false;
if (argtup != nil) {
if (argtup.kind == tykind.TY_TUPLE) {
@@ -466,9 +460,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let dotbu: *tinfo = nil;
if (base != nil) { if (base.kind == nkind.N_DOT) {
dotbu = base.type_: *tinfo;
for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) {
dotbu = dotbu.under;
};
dotbu = tichase(dotbu);
};};
// #60 (alias arc #5): alias-NAMED N_IDENT base — the tnode
// reads below see only the N_TNAME leaf (esz 1-sentinel,
@@ -726,9 +718,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let structident: bool = false;
if (arg.kind == nkind.N_IDENT) {
let st: *tinfo = arg.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) {
st = st.under;
};
st = tichase(st);
if (st != nil) { if (st.kind == tykind.TY_STRUCT) {
if (st.size: i32 <= 16) { structident = true; };
}; };
@@ -842,9 +832,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// nodes and literal value exprs. Mirrors the cstage
// restage guard.
let eti: *tinfo = et.type_: *tinfo;
for (eti != nil && eti.kind == tykind.TY_NAMED) {
eti = eti.under;
};
eti = tichase(eti);
if (eti != nil) {
if (eti.kind == tykind.TY_TUPLE
|| eti.kind == tykind.TY_STRUCT
@@ -911,9 +899,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// register. Mirrors the cstage cgcall guard.
{
let ati: *tinfo = arg.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) {
ati = ati.under;
};
ati = tichase(ati);
if (ati != nil) {
if (ati.kind == tykind.TY_TUPLE) {
let m32: str = "#32: tuple arg from unsupported source shape (call/ident/literal/unwrap only; rule 7)\n";
@@ -1323,7 +1309,7 @@ fn tichase(t0: *tinfo) *tinfo = {
// avoid widening the frontend surface for one #156 read-half check.
fn tinfoisarray(t: *tinfo) bool = {
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
return u.kind == tykind.TY_ARRAY;
};
@@ -1429,10 +1415,10 @@ export fn localloadop(c: *cgen, tnode: *node) str = {
// through here. Mirrors cstage idx_eff (cmd/w6c/cgen.c:1163).
fn idxeffti(t0: *tinfo) *tinfo = {
let t: *tinfo = t0;
for (t != nil && t.kind == tykind.TY_NAMED) { t = t.under; };
t = tichase(t);
if (t != nil && t.kind == tykind.TY_PTR) {
let p: *tinfo = t.sub;
for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; };
p = tichase(p);
if (p != nil && p.kind == tykind.TY_ARRAY) { return p; };
};
return t;
@@ -1718,9 +1704,7 @@ fn structabisize(si: *structinfo) i32 = {
if (end > n) { n = end; };
if (fi.tnode != nil) {
let ti: *tinfo = fi.tnode.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) {
ti = ti.under;
};
ti = tichase(ti);
if (ti != nil) {
let aln: i32 = ti.align: i32;
if (aln > maxaln) { maxaln = aln; };
@@ -1823,7 +1807,7 @@ export fn sretretsize(c: *cgen, t: *node) i32 = {
// no float-array-return consumer (structfloatclass stays struct-only).
if (r.kind == nkind.N_TARRAY) {
let ati: *tinfo = r.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) { ati = ati.under; };
ati = tichase(ati);
if (ati == nil) { return 0; };
let asz: i32 = ati.size: i32;
if (asz <= 24) { return 0; };
@@ -2236,7 +2220,7 @@ fn slotsize(c: *cgen, typn: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let kk: tykind = ti.kind;
if (kk == tykind.TY_VOID) { return 0; };
@@ -2274,7 +2258,7 @@ fn fieldsize(c: *cgen, tnode: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let k: tykind = ti.kind;
if (k == tykind.TY_STRUCT) { return ti.slotsize: i32; };
@@ -2531,7 +2515,7 @@ fn structparamsize(c: *cgen, t: *node) i32 = {
fn aggargsizetn(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind == tykind.TY_STRUCT || u.kind == tykind.TY_ARRAY) {
return u.size: i32;
@@ -2549,7 +2533,7 @@ fn aggargsizetn(t: *tinfo) i32 = {
fn taggedmemargsize(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind != tykind.TY_TAGGED) { return 0; };
if (u.nullable != 0) { return 0; };
@@ -2572,7 +2556,7 @@ fn nodeisaggarg(n: *node) bool = {
fn aggargfloatstop(n: *node) bool = {
if (n == nil) { return false; };
let st: *tinfo = n.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return false; };
if (st.kind != tykind.TY_STRUCT) { return false; };
if (st.size: i32 > 16) { return false; };
@@ -2678,7 +2662,7 @@ fn istaggedtype(c: *cgen, t: *node) bool = {
fn tnodeisagg(t: *node) bool = {
if (t == nil) { return false; };
let u: *tinfo = t.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind == tykind.TY_STRUCT) { return true; };
if (u.kind == tykind.TY_ARRAY) { return true; };
@@ -2724,7 +2708,7 @@ export fn nullableptrtag(t: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 0; };
if (ti.kind != tykind.TY_TAGGED) { return 0; };
let p: *tparam = ti.params;
@@ -2786,7 +2770,7 @@ fn taggedvariantindext(c: *cgen, du: *tinfo, rhs: *node) i32 = {
if (du == nil) { return -1; };
if (rhs == nil) { return -1; };
let ti: *tinfo = du;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let r: i32 = flatvariantidxt(ti, rhs.type_: *tinfo);
@@ -2846,7 +2830,7 @@ fn flatvariantidx(c: *cgen, tagged: *node, pat: *node) i32 = {
fn flatvariantidxt(tagged: *tinfo, want: *tinfo) i32 = {
if (want == nil) { return -1; };
let ti: *tinfo = tagged;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
// Pass 1: exact match (NAMED-vs-NAMED typeeq, tagged-vs-tagged, bare
@@ -2988,9 +2972,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
};
if (vt.kind == tykind.TY_NAMED || want.kind == tykind.TY_NAMED) {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu != nil && wu != nil
&& vu.kind == tykind.TY_TAGGED
&& wu.kind == tykind.TY_TAGGED) {
@@ -3008,9 +2992,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
// cstage cg_variant_struct_match (cmd/w6c/cgen.c).
fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu == nil) { return false; };
if (wu == nil) { return false; };
return typeeq(vu, wu);
@@ -3030,7 +3014,7 @@ fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (tagged == nil) { return -1; };
let ti: *tinfo = tagged.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let want: *tinfo = nil;
@@ -3045,7 +3029,7 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (fallback < 0) { fallback = idx; };
if (want != nil) {
let su: *tinfo = vt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
if (su != nil) {
if (typeeq(su.sub, want)) { return idx; };
};
@@ -3068,11 +3052,11 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
// (cmd/w6c/cgen.c:1177) over su->params + cg_tag_for_variant (:503).
fn cgwidentagremap(c: *cgen, du: *tinfo, su: *tinfo, slot_off: i32) void = {
let dt: *tinfo = du;
for (dt != nil && dt.kind == tykind.TY_NAMED) { dt = dt.under; };
dt = tichase(dt);
if (dt == nil) { return; };
if (dt.kind != tykind.TY_TAGGED) { return; };
let st: *tinfo = su;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return; };
if (st.kind != tykind.TY_TAGGED) { return; };
let identity: bool = true;
@@ -3244,7 +3228,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
if (e == nil) { return false; };
if (e.kind == nkind.N_UN && e.op == tkind.TK_STAR) {
let du: *tinfo = e.type_: *tinfo;
for (du != nil && du.kind == tykind.TY_NAMED) { du = du.under; };
du = tichase(du);
if (du == nil) { return false; };
if (du.kind != tykind.TY_TAGGED) { return false; };
if (du.nullable != 0) { return false; };
@@ -3252,7 +3236,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
};
if (e.kind != nkind.N_INDEX && e.kind != nkind.N_DOT) { return false; };
let u: *tinfo = e.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind != tykind.TY_TAGGED) { return false; };
return u.size: i32 > TUPLE_GPCAP * 8;
@@ -3269,12 +3253,12 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
fn taggedcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
if (cu.nullable != 0) { return e; };
let iu: *tinfo = e.lhs.type_: *tinfo;
for (iu != nil && iu.kind == tykind.TY_NAMED) { iu = iu.under; };
iu = tichase(iu);
if (iu == nil) { return e; };
if (iu.kind != tykind.TY_TAGGED) { return e; };
if (iu.nullable != 0) { return e; };
@@ -3293,7 +3277,7 @@ fn taggedidcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
if (!typeeq(e.type_: *tinfo, e.lhs.type_: *tinfo)) { return e; };
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
e = e.lhs;
@@ -4243,16 +4227,12 @@ export fn dotchainresolve(c: *cgen, n: *node,
// (plus one TY_PTR hop for a `*struct` root). tfield.type_ then
// supplies each nested struct directly, so no name re-lookup.
let curstruct: *tinfo = cur.type_: *tinfo;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
if (*outptrroot) {
if (curstruct == nil) { return false; };
if (curstruct.kind != tykind.TY_PTR) { return false; };
curstruct = curstruct.sub;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
};
let i: i32 = nsteps - 1;
for (i >= 0) {
@@ -4274,7 +4254,7 @@ export fn dotchainresolve(c: *cgen, n: *node,
return true;
};
let ft: *tinfo = found.type_;
for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; };
ft = tichase(ft);
if (ft == nil) { return false; };
if (ft.kind == tykind.TY_STR) {
// str IS []u8: .cap is the third header word, same as
@@ -4819,9 +4799,7 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node,
let agsz49: i32 = 0;
if (fi.tnode != nil) {
let agti49: *tinfo = fi.tnode.type_: *tinfo;
for (agti49 != nil && agti49.kind == tykind.TY_NAMED) {
agti49 = agti49.under;
};
agti49 = tichase(agti49);
if (agti49 != nil) { agsz49 = agti49.size: i32; };
};
aggcopy(c, agsz49);

View File

@@ -16217,13 +16217,9 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
if (memptype != nil) {
let pt: *tinfo = memptype.type_: *tinfo;
let pu: *tinfo = pt;
for (pu != nil && pu.kind == tykind.TY_NAMED) {
pu = pu.under;
};
pu = tichase(pu);
let au: *tinfo = at;
for (au != nil && au.kind == tykind.TY_NAMED) {
au = au.under;
};
au = tichase(au);
if (pu != nil && pu == au) { same = true; };
if (!same && pt != nil && at != nil) {
if (typeeq(pt, at)) { same = true; };
@@ -16429,9 +16425,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// literal/cast forms and loud-stops the rest (#72). Mirrors
// cstage cg_widen_tagged_push src_is_tuple.
let argtup: *tinfo = arg.type_: *tinfo;
for (argtup != nil && argtup.kind == tykind.TY_NAMED) {
argtup = argtup.under;
};
argtup = tichase(argtup);
let argistuple: bool = false;
if (argtup != nil) {
if (argtup.kind == tykind.TY_TUPLE) {
@@ -16538,9 +16532,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let dotbu: *tinfo = nil;
if (base != nil) { if (base.kind == nkind.N_DOT) {
dotbu = base.type_: *tinfo;
for (dotbu != nil && dotbu.kind == tykind.TY_NAMED) {
dotbu = dotbu.under;
};
dotbu = tichase(dotbu);
};};
// #60 (alias arc #5): alias-NAMED N_IDENT base — the tnode
// reads below see only the N_TNAME leaf (esz 1-sentinel,
@@ -16798,9 +16790,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
let structident: bool = false;
if (arg.kind == nkind.N_IDENT) {
let st: *tinfo = arg.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) {
st = st.under;
};
st = tichase(st);
if (st != nil) { if (st.kind == tykind.TY_STRUCT) {
if (st.size: i32 <= 16) { structident = true; };
}; };
@@ -16914,9 +16904,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// nodes and literal value exprs. Mirrors the cstage
// restage guard.
let eti: *tinfo = et.type_: *tinfo;
for (eti != nil && eti.kind == tykind.TY_NAMED) {
eti = eti.under;
};
eti = tichase(eti);
if (eti != nil) {
if (eti.kind == tykind.TY_TUPLE
|| eti.kind == tykind.TY_STRUCT
@@ -16983,9 +16971,7 @@ fn pushargsrev(c: *cgen, arg: *node, param: *node, memphase: bool) i32 = {
// register. Mirrors the cstage cgcall guard.
{
let ati: *tinfo = arg.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) {
ati = ati.under;
};
ati = tichase(ati);
if (ati != nil) {
if (ati.kind == tykind.TY_TUPLE) {
let m32: str = "#32: tuple arg from unsupported source shape (call/ident/literal/unwrap only; rule 7)\n";
@@ -17395,7 +17381,7 @@ fn tichase(t0: *tinfo) *tinfo = {
// avoid widening the frontend surface for one #156 read-half check.
fn tinfoisarray(t: *tinfo) bool = {
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
return u.kind == tykind.TY_ARRAY;
};
@@ -17501,10 +17487,10 @@ export fn localloadop(c: *cgen, tnode: *node) str = {
// through here. Mirrors cstage idx_eff (cmd/w6c/cgen.c:1163).
fn idxeffti(t0: *tinfo) *tinfo = {
let t: *tinfo = t0;
for (t != nil && t.kind == tykind.TY_NAMED) { t = t.under; };
t = tichase(t);
if (t != nil && t.kind == tykind.TY_PTR) {
let p: *tinfo = t.sub;
for (p != nil && p.kind == tykind.TY_NAMED) { p = p.under; };
p = tichase(p);
if (p != nil && p.kind == tykind.TY_ARRAY) { return p; };
};
return t;
@@ -17790,9 +17776,7 @@ fn structabisize(si: *structinfo) i32 = {
if (end > n) { n = end; };
if (fi.tnode != nil) {
let ti: *tinfo = fi.tnode.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) {
ti = ti.under;
};
ti = tichase(ti);
if (ti != nil) {
let aln: i32 = ti.align: i32;
if (aln > maxaln) { maxaln = aln; };
@@ -17895,7 +17879,7 @@ export fn sretretsize(c: *cgen, t: *node) i32 = {
// no float-array-return consumer (structfloatclass stays struct-only).
if (r.kind == nkind.N_TARRAY) {
let ati: *tinfo = r.type_: *tinfo;
for (ati != nil && ati.kind == tykind.TY_NAMED) { ati = ati.under; };
ati = tichase(ati);
if (ati == nil) { return 0; };
let asz: i32 = ati.size: i32;
if (asz <= 24) { return 0; };
@@ -18308,7 +18292,7 @@ fn slotsize(c: *cgen, typn: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let kk: tykind = ti.kind;
if (kk == tykind.TY_VOID) { return 0; };
@@ -18346,7 +18330,7 @@ fn fieldsize(c: *cgen, tnode: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 8; };
let k: tykind = ti.kind;
if (k == tykind.TY_STRUCT) { return ti.slotsize: i32; };
@@ -18603,7 +18587,7 @@ fn structparamsize(c: *cgen, t: *node) i32 = {
fn aggargsizetn(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind == tykind.TY_STRUCT || u.kind == tykind.TY_ARRAY) {
return u.size: i32;
@@ -18621,7 +18605,7 @@ fn aggargsizetn(t: *tinfo) i32 = {
fn taggedmemargsize(t: *tinfo) i32 = {
if (t == nil) { return 0; };
let u: *tinfo = t;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return 0; };
if (u.kind != tykind.TY_TAGGED) { return 0; };
if (u.nullable != 0) { return 0; };
@@ -18644,7 +18628,7 @@ fn nodeisaggarg(n: *node) bool = {
fn aggargfloatstop(n: *node) bool = {
if (n == nil) { return false; };
let st: *tinfo = n.type_: *tinfo;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return false; };
if (st.kind != tykind.TY_STRUCT) { return false; };
if (st.size: i32 > 16) { return false; };
@@ -18750,7 +18734,7 @@ fn istaggedtype(c: *cgen, t: *node) bool = {
fn tnodeisagg(t: *node) bool = {
if (t == nil) { return false; };
let u: *tinfo = t.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind == tykind.TY_STRUCT) { return true; };
if (u.kind == tykind.TY_ARRAY) { return true; };
@@ -18796,7 +18780,7 @@ export fn nullableptrtag(t: *node) i32 = {
// #64 builds per-decl NAMED wrappers (tinfofornode), so the peel
// now fires on aliased operands; byte-id holds because it collapses
// NAMED to the alias-invariant underlying this read consumes.
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return 0; };
if (ti.kind != tykind.TY_TAGGED) { return 0; };
let p: *tparam = ti.params;
@@ -18858,7 +18842,7 @@ fn taggedvariantindext(c: *cgen, du: *tinfo, rhs: *node) i32 = {
if (du == nil) { return -1; };
if (rhs == nil) { return -1; };
let ti: *tinfo = du;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let r: i32 = flatvariantidxt(ti, rhs.type_: *tinfo);
@@ -18918,7 +18902,7 @@ fn flatvariantidx(c: *cgen, tagged: *node, pat: *node) i32 = {
fn flatvariantidxt(tagged: *tinfo, want: *tinfo) i32 = {
if (want == nil) { return -1; };
let ti: *tinfo = tagged;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
// Pass 1: exact match (NAMED-vs-NAMED typeeq, tagged-vs-tagged, bare
@@ -19060,9 +19044,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
};
if (vt.kind == tykind.TY_NAMED || want.kind == tykind.TY_NAMED) {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu != nil && wu != nil
&& vu.kind == tykind.TY_TAGGED
&& wu.kind == tykind.TY_TAGGED) {
@@ -19080,9 +19064,9 @@ fn cgvariantmatch(vt: *tinfo, want: *tinfo) bool = {
// cstage cg_variant_struct_match (cmd/w6c/cgen.c).
fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
let vu: *tinfo = vt;
for (vu != nil && vu.kind == tykind.TY_NAMED) { vu = vu.under; };
vu = tichase(vu);
let wu: *tinfo = want;
for (wu != nil && wu.kind == tykind.TY_NAMED) { wu = wu.under; };
wu = tichase(wu);
if (vu == nil) { return false; };
if (wu == nil) { return false; };
return typeeq(vu, wu);
@@ -19102,7 +19086,7 @@ fn cgvariantstructmatch(vt: *tinfo, want: *tinfo) bool = {
fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (tagged == nil) { return -1; };
let ti: *tinfo = tagged.type_: *tinfo;
for (ti != nil && ti.kind == tykind.TY_NAMED) { ti = ti.under; };
ti = tichase(ti);
if (ti == nil) { return -1; };
if (ti.kind != tykind.TY_TAGGED) { return -1; };
let want: *tinfo = nil;
@@ -19117,7 +19101,7 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
if (fallback < 0) { fallback = idx; };
if (want != nil) {
let su: *tinfo = vt;
for (su != nil && su.kind == tykind.TY_NAMED) { su = su.under; };
su = tichase(su);
if (su != nil) {
if (typeeq(su.sub, want)) { return idx; };
};
@@ -19140,11 +19124,11 @@ fn flatslicevariantidx(c: *cgen, tagged: *node, elem: *node) i32 = {
// (cmd/w6c/cgen.c:1177) over su->params + cg_tag_for_variant (:503).
fn cgwidentagremap(c: *cgen, du: *tinfo, su: *tinfo, slot_off: i32) void = {
let dt: *tinfo = du;
for (dt != nil && dt.kind == tykind.TY_NAMED) { dt = dt.under; };
dt = tichase(dt);
if (dt == nil) { return; };
if (dt.kind != tykind.TY_TAGGED) { return; };
let st: *tinfo = su;
for (st != nil && st.kind == tykind.TY_NAMED) { st = st.under; };
st = tichase(st);
if (st == nil) { return; };
if (st.kind != tykind.TY_TAGGED) { return; };
let identity: bool = true;
@@ -19316,7 +19300,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
if (e == nil) { return false; };
if (e.kind == nkind.N_UN && e.op == tkind.TK_STAR) {
let du: *tinfo = e.type_: *tinfo;
for (du != nil && du.kind == tykind.TY_NAMED) { du = du.under; };
du = tichase(du);
if (du == nil) { return false; };
if (du.kind != tykind.TY_TAGGED) { return false; };
if (du.nullable != 0) { return false; };
@@ -19324,7 +19308,7 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
};
if (e.kind != nkind.N_INDEX && e.kind != nkind.N_DOT) { return false; };
let u: *tinfo = e.type_: *tinfo;
for (u != nil && u.kind == tykind.TY_NAMED) { u = u.under; };
u = tichase(u);
if (u == nil) { return false; };
if (u.kind != tykind.TY_TAGGED) { return false; };
return u.size: i32 > TUPLE_GPCAP * 8;
@@ -19341,12 +19325,12 @@ fn taggedmemread(c: *cgen, e: *node) bool = {
fn taggedcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
if (cu.nullable != 0) { return e; };
let iu: *tinfo = e.lhs.type_: *tinfo;
for (iu != nil && iu.kind == tykind.TY_NAMED) { iu = iu.under; };
iu = tichase(iu);
if (iu == nil) { return e; };
if (iu.kind != tykind.TY_TAGGED) { return e; };
if (iu.nullable != 0) { return e; };
@@ -19365,7 +19349,7 @@ fn taggedidcastpeel(c: *cgen, e: *node) *node = {
for (e != nil && e.kind == nkind.N_CAST && e.lhs != nil) {
if (!typeeq(e.type_: *tinfo, e.lhs.type_: *tinfo)) { return e; };
let cu: *tinfo = e.type_: *tinfo;
for (cu != nil && cu.kind == tykind.TY_NAMED) { cu = cu.under; };
cu = tichase(cu);
if (cu == nil) { return e; };
if (cu.kind != tykind.TY_TAGGED) { return e; };
e = e.lhs;
@@ -20315,16 +20299,12 @@ export fn dotchainresolve(c: *cgen, n: *node,
// (plus one TY_PTR hop for a `*struct` root). tfield.type_ then
// supplies each nested struct directly, so no name re-lookup.
let curstruct: *tinfo = cur.type_: *tinfo;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
if (*outptrroot) {
if (curstruct == nil) { return false; };
if (curstruct.kind != tykind.TY_PTR) { return false; };
curstruct = curstruct.sub;
for (curstruct != nil && curstruct.kind == tykind.TY_NAMED) {
curstruct = curstruct.under;
};
curstruct = tichase(curstruct);
};
let i: i32 = nsteps - 1;
for (i >= 0) {
@@ -20346,7 +20326,7 @@ export fn dotchainresolve(c: *cgen, n: *node,
return true;
};
let ft: *tinfo = found.type_;
for (ft != nil && ft.kind == tykind.TY_NAMED) { ft = ft.under; };
ft = tichase(ft);
if (ft == nil) { return false; };
if (ft.kind == tykind.TY_STR) {
// str IS []u8: .cap is the third header word, same as
@@ -20891,9 +20871,7 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *node,
let agsz49: i32 = 0;
if (fi.tnode != nil) {
let agti49: *tinfo = fi.tnode.type_: *tinfo;
for (agti49 != nil && agti49.kind == tykind.TY_NAMED) {
agti49 = agti49.under;
};
agti49 = tichase(agti49);
if (agti49 != nil) { agsz49 = agti49.size: i32; };
};
aggcopy(c, agsz49);