w6c: emit length for string-literal .len (fix #14, align cstage to wwstage)
A string literal is TY_UNTYPED_STR, not TY_STR, so `"abc".len` missed the typed slice/str pseudo-field gate in cgen.c's N_DOT and fell to the final base-eval fallback, which left AX=.ptr — `.len` returned the pointer instead of the length. wwstage's cgdot catch-all already did the BX->AX shuffle, so the two stages diverged (rule-10). Align cstage UP: the N_DOT fallback emits MOVQ BX,AX for `.len`. `.ptr` is unchanged (already returned AX); `.cap` deliberately not added (wwstage catch-all is ptr/len only — mirror exactly). byte-id was blind here: no bootstrap source uses literal `.len` (lengths are hardcoded around literals), so the gate never exercised it. New test 801 pins both dimensions (cstage run + cs==ww byte-id) over len/empty/multibyte/ptr-deref/arg-passthrough rows.
This commit is contained in:
10
Makefile
10
Makefile
@@ -369,6 +369,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_xmod_valglobal_run \
|
||||
$(BIN)/test_xmod_valglobal_dot_run \
|
||||
$(BIN)/test_len_strglobal_run \
|
||||
$(BIN)/test_litstr_pseudo_run \
|
||||
$(BIN)/test_tuple_sret_callee \
|
||||
$(BIN)/test_tuple_sret_receive_run \
|
||||
$(BIN)/test_struct_tuple_field_slot \
|
||||
@@ -875,6 +876,15 @@ $(BIN)/test_len_strglobal_run: test/wcc/797_len_strglobal_run.c \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #14: a string LITERAL `.len` is TY_UNTYPED_STR, so it misses the typed
|
||||
# slice/str pseudo-field gate and fell to the N_DOT base-eval fallback —
|
||||
# cstage returned AX=.ptr instead of shuffling BX=.len into AX (wwstage
|
||||
# already did). Runtime + cs==ww byte-id; `.ptr` unchanged (control row).
|
||||
$(BIN)/test_litstr_pseudo_run: test/wcc/801_litstr_pseudo_run.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# #10 Fold A (wide tuple-return / sret, CALLEE side): an over-cap tuple
|
||||
# return (> 4 GP or > 2 SSE eightbytes) now compiles via sret instead of
|
||||
# loud-stopping at the SEND. Compile + cs==ww byte-id only — the receive
|
||||
|
||||
Reference in New Issue
Block a user