selfhost+cstage+test: graduate *[]T indexing to slice-element type (#20)
Cstage and wwstage share the latent: check.c's N_INDEX bespoke TY_PTR-over-TY_SLICE clause peeled the slice in `*[]T[i]` and returned the element of the element, while wwstage's elemsizeof had no N_TSLICE arm for the post-N_TPTR-peel elem and fell to the 8B catch-all. Splitting leaves one stage broken on the exact `*[]T[i]` shape the new 754 sentinel asserts byte-identical between stages (rule 11). The companion 24B per-element copy emit is a separate codegen wedge already pinned inline at cmd/w6c/cgen.c:6518; out-of-scope here and noted in the fixture header.
This commit is contained in:
@@ -8787,6 +8787,10 @@ fn elemsizeof(t: *node) i32 = {
|
||||
if (elem.kind == nkind.N_TARRAY) {
|
||||
if (elem.lhs != nil) { elem = elem.lhs; };
|
||||
};
|
||||
// `*[]T`: stride is the slice header (24B). Hare-faithful — a
|
||||
// pointer-to-slice is a 1D array of slices, not of T. Mirrors the
|
||||
// cstage check.c default `*U → U` path for U=[]T (slice element).
|
||||
if (elem.kind == nkind.N_TSLICE) { return 24; };
|
||||
if (elem.kind == nkind.N_TNAME) {
|
||||
let nm: str = elem.str;
|
||||
// str element is 16B (ptr+len). primsize returns 0 for it.
|
||||
|
||||
@@ -1288,6 +1288,10 @@ fn elemsizeof(t: *node) i32 = {
|
||||
if (elem.kind == nkind.N_TARRAY) {
|
||||
if (elem.lhs != nil) { elem = elem.lhs; };
|
||||
};
|
||||
// `*[]T`: stride is the slice header (24B). Hare-faithful — a
|
||||
// pointer-to-slice is a 1D array of slices, not of T. Mirrors the
|
||||
// cstage check.c default `*U → U` path for U=[]T (slice element).
|
||||
if (elem.kind == nkind.N_TSLICE) { return 24; };
|
||||
if (elem.kind == nkind.N_TNAME) {
|
||||
let nm: str = elem.str;
|
||||
// str element is 16B (ptr+len). primsize returns 0 for it.
|
||||
|
||||
@@ -8787,6 +8787,10 @@ fn elemsizeof(t: *node) i32 = {
|
||||
if (elem.kind == nkind.N_TARRAY) {
|
||||
if (elem.lhs != nil) { elem = elem.lhs; };
|
||||
};
|
||||
// `*[]T`: stride is the slice header (24B). Hare-faithful — a
|
||||
// pointer-to-slice is a 1D array of slices, not of T. Mirrors the
|
||||
// cstage check.c default `*U → U` path for U=[]T (slice element).
|
||||
if (elem.kind == nkind.N_TSLICE) { return 24; };
|
||||
if (elem.kind == nkind.N_TNAME) {
|
||||
let nm: str = elem.str;
|
||||
// str element is 16B (ptr+len). primsize returns 0 for it.
|
||||
|
||||
Reference in New Issue
Block a user