Heterogeneous AOT compiler middle-end for my-lisp
Українська · English · Deutsch
cml — це heterogeneous middle-end і Ahead-of-Time (AOT) компілятор для my-lisp. Він знижує єдиний semantic IR до CPU/C, GPU compute backends, виконання fpga-lisp і вузького freestanding x86_64 assembly target для wsm-os, залишаючи можливості backend'ів явними й fail-closed.
Цей підхід відділяє семантику мови від фізичного виконання. Поточний graph має live CPU, CUDA і FPGA шляхи, включно з host-staged typed-buffer→FPGA-register edge; прямий GPU→FPGA transfer не заявляється.
Компілятор підтримує:
- Змінні (через ін'єкцію пошуку в середовищі на етапі компіляції)
cond(логіка розгалуження, скомпільована вJF/RET)lambda(замикання, які самостійно прив'язують аргументи до середовища)let, знижений до негайно викликаноїlambdaбез нової FPGA-примітиви- Стандартні примітиви (
cons,car,cdr,eq,atom) - Явні форми quote (
(quote ...)) - Стек викликів (програмний стек
R11для збереження середовища та адреси повернення)
- Generic calls зв'язують щонайбільше 8 аргументів; зайві аргументи ще не відхиляються явно.
- Conformance runner канонічно декодує atoms, fixnums, proper lists і dotted lists із FPGA heap; непідтримувані мовні форми досі пропускаються явно.
- Tier-1 error fixtures теж спостережувані: компілятор класифікує статичні помилки арності/невідомого символу, а FPGA повертає runtime-помилки типу через машинозчитуваний канал результату.
- Сирцеві strings знижуються до
Ir::String(окремий IR-варіант); fpga-lisp ще не має окремого runtime string tag. - Inexact numbers і точні rationals не підтримуються цільовим представленням.
Freestanding x86_64 backend залежить від wsm-os-target, зафіксованого на
нейтральному репозиторії
wsm-target-contract. CML і
wsm-os-lisp є рівноправними споживачами цього ABI: CML емітує код за його
правилами, а wsm-os-lisp надає рантайм і платформові докази. Це прибирає
старий циклічний зв'язок репозиторіїв і не є заявою, що поточний рантайм чи
boot-шлях wsm-os уже покритий.
compatibility.my фіксує точний language contract my-lisp, ISA contract fpga-lisp, перевірені SHA, підтриману поверхню й відомі прогалини цієї ревізії компілятора.
Freestanding x86_64 зріз окремо описаний у
docs/x86-freestanding-backend.md. Наразі
він підтримує literals, явний (quote ...), cons/car/cdr/eq/atom, cond, арифметику з перевіркою (+/-), та loop-optimized self-tail-calls, без заяви про повну
мовну або boot parity.
Переглянути результати тестів · Тестування
- my-lisp: Мова Lisp та еталонний семантичний контракт.
- cml: Цей гетерогенний middle-end компілятор.
- fpga-lisp: Апаратна Lisp-машина та асемблер.
(Примітка: фундаментальні проєкти на кшталт
wsm(() -> математика) є окремими незалежними напрямами дослідження і не є споживачами CML IR).
cargo build
cargo run -- path/to/source.mycml is an Ahead-of-Time (AOT) compiler middle-end for my-lisp. It lowers one semantic IR toward CPU/C, GPU compute backends, fpga-lisp execution, and a bounded freestanding x86_64 assembly target for wsm-os. Backend capabilities remain explicit and fail-closed.
This approach separates language semantics from physical execution. The current graph has live CPU, CUDA, and FPGA paths, including a host-staged typed-buffer-to-FPGA-register edge; direct GPU-to-FPGA transfer is not claimed.
The compiler handles:
- Variables (via compile-time environment lookup injection)
cond(branching logic compiled toJF/RET)lambda(closures that self-bind arguments to an environment)letlowered as an immediately invokedlambda, without a new FPGA primitive- Standard primitives (
cons,car,cdr,eq,atom) - Explicit quote forms (
(quote ...)) - Call Stack (
R11software stack for environment and link preservation)
- Generic calls bind at most 8 arguments; additional arguments are not yet rejected explicitly.
- The conformance runner canonically decodes atoms, fixnums, proper lists, and dotted lists from the FPGA heap; unsupported language forms are still skipped explicitly.
- Tier-1 error fixtures are observable too: the compiler classifies static arity/unknown-symbol failures, while FPGA execution reports runtime type failures through a machine-readable result channel.
- Source strings lower to
Ir::String(separate IR variant); fpga-lisp still has no distinct runtime string tag. - Inexact numbers and exact rationals are not supported by the target representation.
The x86_64 freestanding backend depends on wsm-os-target, pinned to the
neutral wsm-target-contract
repository. CML and wsm-os-lisp are equal consumers of this target ABI:
CML emits code against it; wsm-os-lisp supplies its runtime and platform
evidence. This replaces the legacy repository cycle and does not claim that
the current wsm-os runtime or boot path is already covered.
compatibility.my records the exact my-lisp language contract, fpga-lisp ISA contract, tested SHAs, supported surface, and known gaps for this compiler revision.
The freestanding x86_64 slice is documented separately in
docs/x86-freestanding-backend.md. It
currently supports literals, explicit (quote ...), cons/car/cdr/eq/atom, cond, checked fixnum arithmetic (+/-), and loop-optimized self-tail-calls;
this is not a claim of full language or boot parity.
- my-lisp: The Lisp dialect and reference semantic contract.
- cml: This heterogeneous compiler middle-end.
- fpga-lisp: The hardware Lisp machine and assembler.
(Note: independent foundational research projects like
wsm(() -> mathematics) are separate research tracks and do not consume CML IR).
cargo build
cargo run -- path/to/source.mycml ist ein heterogenes AOT-Compiler-Middle-End für my-lisp. Es senkt eine gemeinsame semantische IR zu CPU/C-, GPU-Compute-Backends und fpga-lisp ab; Backend-Fähigkeiten bleiben explizit und fail-closed.
Dieser Ansatz trennt Sprachsemantik von physischer Ausführung. Der aktuelle Graph hat live CPU-, CUDA- und FPGA-Pfade einschließlich eines host-gestagten Typed-Buffer→FPGA-Register-Pfads; direkter GPU→FPGA-Transfer wird nicht behauptet.
Der Compiler verarbeitet:
- Variablen (über beim Kompilieren injiziertes Umgebungs-Lookup)
cond(Verzweigungslogik, kompiliert zuJF/RET)lambda(Closures, die ihre Argumente selbst an eine Umgebung binden)let, abgesenkt zu einer sofort aufgerufenenlambdaohne neue FPGA-Primitive- Standardprimitiven (
cons,car,cdr,eq,atom) - Explizite Quote-Formen (
(quote ...)) - Aufrufstapel (
R11Software-Stack für Umgebungs- und Rücksprungadressenspeicherung)
- Generische Aufrufe binden höchstens 8 Argumente; zusätzliche Argumente werden noch nicht explizit abgelehnt.
- Der Konformitätsrunner dekodiert Atome, Fixnums, echte Listen und Dotted Lists aus dem FPGA-Heap kanonisch; nicht unterstützte Sprachformen werden weiterhin explizit übersprungen.
- Auch Tier-1-Fehler-Fixtures sind beobachtbar: Der Compiler klassifiziert statische Stelligkeits- und Unbekanntes-Symbol-Fehler, während das FPGA Laufzeit-Typfehler über einen maschinenlesbaren Ergebniskanal meldet.
- Quell-Strings werden zu
Ir::String(separater IR-Variant) abgesenkt; fpga-lisp besitzt noch kein eigenes Laufzeit-String-Tag. - Inexakte Zahlen und exakte rationale Zahlen werden von der Zieldarstellung nicht unterstützt.
compatibility.my hält den genauen my-lisp-Sprachvertrag, fpga-lisp-ISA-Vertrag, geprüfte SHAs, die unterstützte Oberfläche und bekannte Lücken dieser Compilerrevision fest.
Der freistehende x86_64-Slice ist separat dokumentiert in
docs/x86-freestanding-backend.md. Er
unterstützt derzeit Literale, explizites (quote ...), cons/car/cdr/eq/atom, cond, überprüfte Fixnum-Arithmetik (+/-) und loop-optimierte Self-Tail-Calls;
dies ist kein Anspruch auf vollständige Sprach-oder Boot-Parität.
Testergebnisse anzeigen · Testen
cargo build
cargo run -- path/to/source.myЦей твір поширюється під ВОЛЬНІСТЮ — простим словом про свободу творити, пам'ятаючи про волю іншого.