cstage+selfhost+test: extend structlit-fill helper to N_ASSIGN N_DOT lhs (4 flavors)
Sister fix to #17. The BP-rel helper from #17 covered N_LET / N_ASSIGN N_IDENT-lhs / N_RETURN; the four N_ASSIGN N_DOT-lhs structlit walks still went through the inline `cgexpr(field.lhs); store-AX-sized` shape and silently dropped trailing bytes when a struct-typed field's value was itself an N_STRUCTLIT. Affected dot flavors: single-dot via_ptr / global / BP-rel and the chained-dot walker (depth >= 2, all three root flavors). Extend `cg_structlit_fill_bp` / `cgstructlitfillbp` into `cg_structlit_fill` / `cgstructlitfill` taking a destination mode (DST_BP / DST_PTR_LOCAL / DST_GLOBAL = 0/1/2), srcoff (PTR_LOCAL), srcname (GLOBAL), and disp accumulator. `disp` grows by foff on descent; srcoff/srcname stay constant across the call tree. The pre-#17 wrappers are preserved byte-identically by delegating with mode=DST_BP — 995_self_rebuild byte-identity holds for the no- nested-STRUCTLIT case that selfhost source actually uses. The non-BP modes reload BX before the ELLIPSIS zero-fill loop AND before every field store (tagged, scalar, and the cgexpr leaf). This is correctness-by-construction — cgexpr clobbers BX between fields, and the redundant reload only fires on shapes that didn't compile before. The four dot-flavor sites in each stage now compute their dst mode + disp and call the shared helper (reducing each from ~80-130 inline lines to ~5-12 lines of dispatch). Stage signature asymmetry: cstage threads Local** for cgexpr; ww- stage takes explicit totsize because #15 (split totsize into naturalsize + slotsize) is still pending and the dot sites need structnaturalsize while the BP-rel sites need si.totsize. Both asymmetries are documented in the helper docstrings. 704 covers 8 rows (24 checks: 8 cstage exits, 8 wwstage exits, 8 cstage-vs-wwstage .s byte-identity diffs): 6 dst-flavors (single- dot local/ptr/global, chained-dot local/ptr/global) plus single- local 3-deep and single-ptr 3-deep to pin disp threading through the helper's recursion and through DST_PTR_LOCAL BX reloads. The nested struct-typed CALL rhs in field-walks has the same shape as the STRUCTLIT bug fixed here but the helper only handles STRUCTLIT — tracked as task #20.
This commit is contained in:
7
Makefile
7
Makefile
@@ -230,6 +230,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_cgassign_struct \
|
||||
$(BIN)/test_dot_explicit_deref \
|
||||
$(BIN)/test_nested_structlit \
|
||||
$(BIN)/test_dot_structlit \
|
||||
$(BIN)/test_use_promote_alias \
|
||||
$(BIN)/test_field_signed $(BIN)/test_frame_argcount \
|
||||
$(BIN)/test_selfhost $(BIN)/test_w6a_ww $(BIN)/test_w6l_ww \
|
||||
@@ -395,6 +396,12 @@ $(BIN)/test_nested_structlit: test/wcc/703_nested_structlit.c \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_dot_structlit: test/wcc/704_dot_structlit.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_use_promote_alias: test/wcc/699_use_promote_alias.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
|
||||
Reference in New Issue
Block a user