wcc: float-typed def/let DATA emit via SSoT helper (#129 A.1)
Extract emit_floatlit_data helper for def/let with float-typed top-level initializer; replaces inline emit_lets float arm and adds previously- absent emit_defs float arm. Helper peels N_CAST then N_UN(±, N_FLOATLIT), bit-casts magnitude (f32 via union narrow), emits in little-endian byte order, applies sign-XOR to top byte inside the loop (bit 31 for f32, bit 63 for f64). The byte-loop XOR avoids materialising 2^63, sidestepping the strconv.i64tos INT64_MIN bug (#144 / task #37) on the wwstage self- build path. Mirrored cstage (cgen.c) and wwstage (cgen.ww). Both stages' float-typed def materialisation (cgexpr N_IDENT / cgident def-branch) widened to route through the same LEAQ+MOVSS/MOVSD shape as float-typed let. Closes 3 latent bugs (all bootstrap-NEUTRAL, no current consumer): - def: f64 = literal silently emitted undefined ref - let: f64 = -literal silently emitted undefined ref (N_UN peel absent) - wwstage let: f32 = literal silently truncated to low 4 of f64 bits Test 917 (7 rows: f64_def_pos / f64_def_neg / f32_def_pos / f32_def_neg matrix-closure / f64_let_neg / f64_let_pos / f32_let_pos) registered. Make test: 180/180 incl. 990-997 byte-id + combined_ww_fresh + 995_self_ rebuild. #144 (strconv.i64tos INT64_MIN two's-complement-overflow root) filed separately as task #37 for its own fold.
This commit is contained in:
@@ -642,6 +642,22 @@ fn cgident(c: *cgen, n: *node) void = {
|
||||
return;
|
||||
};
|
||||
};
|
||||
// Float def: load via LEAQ + MOVSS/MOVSD into X0, same shape
|
||||
// as the let-float arm below — MOVSS/MOVSD have no D_EXTERN
|
||||
// operand form. Pre-#129 fell through to the MOVQ-AX
|
||||
// integer-convention fallback, leaving X0 untouched (#129
|
||||
// LOAD-side twin of the emitfloatlitdata DATA-side SSoT).
|
||||
if (isfloattype(c, n)) {
|
||||
let mov: str = "MOVSD";
|
||||
if (isf32type(c, n)) { mov = "MOVSS"; };
|
||||
emitline("\tLEAQ\t");
|
||||
emitsymname(c, nm);
|
||||
emitline("(SB), CX\n");
|
||||
emitline("\t");
|
||||
emitline(mov);
|
||||
emitline("\t(CX), X0\n");
|
||||
return;
|
||||
};
|
||||
emitline("\tMOVQ\t");
|
||||
emitsymname(c, nm);
|
||||
emitline("(SB), AX\n");
|
||||
|
||||
Reference in New Issue
Block a user