w6c+selfhost: float globals — DATAW + LEAQ-indirect MOVSS/MOVSD
f32 → 4B slot, f64 → 8B. C cgen bakes the FLOATLIT bit pattern into DATAW directly; selfhost emits zero-init only (its parser doesn't lex N_FLOATLIT yet). Read/write goes LEAQ name(SB),CX + MOVSS/MOVSD since w6a has no D_EXTERN operand form for SSE moves.
This commit is contained in:
@@ -188,6 +188,50 @@ static const struct fixture fixtures[] = {
|
||||
"};\n",
|
||||
42,
|
||||
},
|
||||
{
|
||||
"f64-literal-init",
|
||||
/* `let pi: f64 = 3.14;` — DATAW bakes the 8 LE bytes of
|
||||
* the double directly. Read goes LEAQ name(SB),CX +
|
||||
* MOVSD (CX),X0; cast truncates to i32. */
|
||||
"let pi: f64 = 7.5;\n"
|
||||
"fn main() i32 = { return pi: i32; };\n",
|
||||
7,
|
||||
},
|
||||
{
|
||||
"f32-literal-init",
|
||||
/* f32 globals are 4-byte slots; literal init bakes the
|
||||
* single-precision bit pattern. */
|
||||
"let half: f32 = 4.25;\n"
|
||||
"fn main() i32 = { return half: i32; };\n",
|
||||
4,
|
||||
},
|
||||
{
|
||||
"f64-zero-init",
|
||||
"let z: f64;\n"
|
||||
"fn main() i32 = { return z: i32; };\n",
|
||||
0,
|
||||
},
|
||||
{
|
||||
"f64-reassign",
|
||||
/* Reassigning an f64 global goes LEAQ name(SB),CX +
|
||||
* MOVSD X0,(CX); read-back through the same shape. */
|
||||
"let pi: f64 = 1.0;\n"
|
||||
"fn main() i32 = {\n"
|
||||
"\tpi = 7.5;\n"
|
||||
"\treturn pi: i32;\n"
|
||||
"};\n",
|
||||
7,
|
||||
},
|
||||
{
|
||||
"f64-arith",
|
||||
"let a: f64 = 7.5;\n"
|
||||
"let b: f64 = 4.25;\n"
|
||||
"fn main() i32 = {\n"
|
||||
"\tlet s: f64 = a + b;\n"
|
||||
"\treturn s: i32;\n"
|
||||
"};\n",
|
||||
11,
|
||||
},
|
||||
{
|
||||
"struct-narrow-field",
|
||||
/* u8 field on a struct global. Read uses MOVZBQ, store
|
||||
|
||||
Reference in New Issue
Block a user