flan/spike/backend/probe.flan
Joseph Ferano 0fbca40446 One function goes from Tast to machine code and answers correctly
x86.ml is an instruction selector for the part of Tast that fits in one
integer register: literals, slots, let, if, arithmetic, comparison, and a
call. Everything else raises with the node that defeated it, because an
honest refusal is the measurement and a silently wrong answer would waste
the exercise.

The frontend is the real one -- Reader, Parse, Load, Check -- so what is
lowered is the same Tast.fn the LLVM backend gets. Seven arithmetic results
are compared against what the language says they should be; the disassembly
proves nothing and is not the evidence.

Nothing is wired into the build. No dune file under spike/, driven by hand
with ocamlfind and clang as spike/embed already does.
2026-09-13 09:12:55 +07:00

25 lines
613 B
Plaintext

;; The spike's input. Ordinary Flan, run through the ordinary frontend --
;; Reader, Parse, Load, Check -- so that what the emitter below lowers is the
;; same Tast.fn the LLVM backend gets and not a literal someone typed to make
;; the exercise come out.
(defn spike-add [a i64 b i64] i64
(+ a b))
(defn spike-arith [a i64 b i64] i64
(- (* a 3) (+ b 7)))
(defn spike-let [a i64] i64
(let [x (* a a)
y (+ x 1)]
(* x y)))
(defn spike-if [a i64 b i64] i64
(if (< a b) (- b a) (- a b)))
(defn spike-calls [a i64] i64
(spike-add (spike-arith a 2) (spike-let a)))
(defn main [] i32
0)