selfhost/cmd/wcc: inline N_INDEX elem tinfo at 3 tagged push/index sites (#60)
pushargsrev and cgindex re-derived an index element's type via
indexvaluetnode (a base->TPTR/SLICE/ARRAY .lhs AST walk). The checker
stamps the element type on the N_INDEX node itself (indexresult,
check.ww:1710; N_INDEX is in the asserttyped gate), so read n.type_
directly at the 3 sites that only need tagged-ness + element size/sign:
cgenutil pushargsrev L178/490: pass the N_INDEX arg to istaggedtype/
slotsize (arg.type_ is the element tinfo).
cgenexpr cgindex L726: esz = n.type_.size, signed = typeissigned(n.type_).
Polarity DOWN per rule 10: cstage has no indexvaluetnode -- it reads
base->type->sub->size directly (cmd/w6c/cgen.c:2070-2071, :3518). The new
path reads element natural size (tinfo.size == primsize: rune=4, u8=1,
str=16, slice=24), matching cstage; it also retires two latent elemsizeofc
divergences (elemsizeofc returned slotsize N*8 for *[N]i64 / 2D-array
elements where cstage uses sub->size=8) -- those shapes are absent from
self-compile, so byte-id stays green.
indexvaluetnode is NOT deleted: its remaining callers at cgenexpr
L3720/3729 feed cgwidentaggedstore -> resolvetagged -> resolvetype, still
node-keyed (nil for non-N_TNAME). Deleting it waits on the resolvetagged
-> tinfo migration (#11).
make test 133/133 (byte-id 990-997 green, independently re-confirmed on
quiescent tree).
This commit is contained in:
@@ -723,10 +723,15 @@ fn cgindex(c: *cgen, n: *node) void = {
|
||||
} else { if (base.kind == nkind.N_DOT) {
|
||||
esz = indexbaseesz(c, base);
|
||||
} else { if (base.kind == nkind.N_INDEX) {
|
||||
let bt: *node = indexvaluetnode(c, base);
|
||||
if (bt != nil) {
|
||||
esz = elemsizeofc(c, bt);
|
||||
signed_elem = elemissignedc(c, bt);
|
||||
// #60: chained `names[i][k]` — n.type_ is the checker-
|
||||
// stamped outer element tinfo (indexresult over the inner
|
||||
// index's value type). cstage reads base->type->sub->size
|
||||
// for esz (cmd/w6c/cgen.c:2070-2071). Drops the
|
||||
// indexvaluetnode walk.
|
||||
let et: *tinfo = n.type_: *tinfo;
|
||||
if (et != nil) {
|
||||
esz = et.size: i32;
|
||||
signed_elem = typeissigned(et);
|
||||
};
|
||||
};};};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user