flan/spike/x86/p5-core.flan
Joseph Ferano 786656dfee (at a i) on the left of a set has to reach the array
The corpus sweep found it, and it found it the way item 15 said this work
fails: array-ctor.flan crashed, and the assembly around the crash read
correctly. (set (.x (at pts 0)) 1.5) went through lvalue, lvalue had no
case for At, and the fallback evaluates — so the store landed in a copy of
the element and the array kept its zeros.

emit.ml has this as addr's own At case. One line here, and the program
matches the LLVM build.

Two more programs beside the fizz: one for the internal calling
convention the fizz does not touch at all — a struct argument, a struct
return through the hidden pointer, f32 in the SSE half, eight integer
arguments so two go on the stack, and a slice by pointer — and one for
the rest of the core: a global with an initialiser, recursion, break,
continue, the bitwise family, unsigned shifts and the conversions both
ways. Both agree with LLVM.

al is now zero at every call this backend makes, including the three in
main that were reaching flan_rt_init, flan_argv and flan_exit without it.
Inert on a fixed callee; the point is that there is no exception to the
rule to remember.
2026-09-13 15:03:41 +07:00

47 lines
1.2 KiB
Plaintext

;; The rest of the core: a global with an initialiser, recursion, break and
;; continue, the bitwise family, unsigned arithmetic and shifts, and the
;; conversions in both directions.
(defvar counter i64 0)
(defconst limit i32 6)
(defn fib [n i64] i64
(if (< n 2) n (+ (fib (- n 1)) (fib (- n 2)))))
(defn main [] i32
(print (fib 20)) (println "")
(let [i 0]
(while (< i 100)
(set i (+ i 1))
(when (= i 7) (break)))
(print i) (println ""))
(let [j 0 seen 0]
(while (< j 10)
(set j (+ j 1))
(when (= (% j 2) 0) (continue))
(set seen (+ seen j)))
(print seen) (println ""))
(dotimes [k limit]
(set counter (+ counter (i64 k))))
(print counter) (println "")
(let [a (bit-xor (u32 0x0F0F0F0F) (u32 0xFFFFFFF))
b (u32 0x0F0F0F0F)]
(print (bit-or a b)) (println "")
(print (bit-and a b)) (println "")
(print (bit-xor a (u32 65535))) (println "")
(print (>> a 4)) (println "")
(print (<< b 4)) (println ""))
(let [x (i32 -9)]
(print (/ x 2)) (println "")
(print (% x 2)) (println "")
(print (f64 x)) (println "")
(print (i32 (f64 3.9))) (println "")
(print (f32 1.5)) (println ""))
0)