Skip to content

feat: LLVM native compilation backend#29

Merged
ardeshir merged 5 commits into
mainfrom
feature/support-native
Feb 16, 2026
Merged

feat: LLVM native compilation backend#29
ardeshir merged 5 commits into
mainfrom
feature/support-native

Conversation

@ardeshir

@ardeshir ardeshir commented Feb 9, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds llvm-backend/ — LLVM 18 native compilation for DOL programs
  • New dol-native CLI tool with build, emit-ir, and targets subcommands
  • HIR-to-LLVM-IR lowering engine (hir_lowering.rs) wired to the DOL parser
  • 5 target architectures: ARM64 Linux, ARM64 macOS, RISC-V 64, x86-64 Linux, x86-64 Windows
  • 22 VUDO ABI host function declarations (I/O, Memory, Time, Messaging, Random, Effects, Debug)
  • 11 native examples demonstrating what compiles today
  • User manual at docs/native-compilation.md

What compiles end-to-end

  • Functions with parameters, return types, recursion
  • Integer/boolean arithmetic (14 binary ops, 2 unary ops)
  • if/else control flow
  • Genes → LLVM struct types (typed fields + heuristic inference)
  • Traits, rules, systems (compile-time validation, no runtime code)
  • String literals and print/println via VUDO ABI
  • Val bindings and local variables
  • Cross-compilation to all 5 targets from a single source

What needs stdlib / library work

Gap What's Needed
String concatenation (+) dol_string_concat in stdlib
.to_string() Type-specific formatters
Vec<T>, Map<K,V> Collection implementations
for / while loops Loop codegen in hir_lowering
match expressions Branch/jump table codegen
mut variables Parser support
Method dispatch Vtable or monomorphized calls
Field/index access Struct GEP codegen
CRDT implementations Library crate for peritext, rga, etc.
Spirit manifests Parser + package manager
+=, path syntax (::) Parser extensions

Test results

  • univrs-dol: 2,074 tests pass, 0 failures
  • llvm-backend: 10 tests pass (abi, functions, structs, types, targets, hir_lowering, codegen)
  • Native examples: 11/11 emit valid LLVM IR
  • Existing .dol files: 93/155 compile through native pipeline (62 use features needing parser/stdlib work)

Test plan

  • cargo test --all in univrs-dol (2,074 pass)
  • cargo test --all in llvm-backend (10 pass)
  • dol-native emit-ir on all 11 native examples
  • dol-native build produces valid ELF x86-64 object files
  • dol-native targets lists all 5 architectures
  • CI: llvm-backend tests require LLVM 18 (separate CI job needed)

DOL programs can now compile to native machine code for ARM64,
RISC-V, and x86-64 via LLVM 18. Adds dol-native CLI with build,
emit-ir, and targets subcommands. Includes HIR-to-LLVM-IR lowering
engine, VUDO ABI declarations (22 host functions), 5 target
architectures, 11 native examples, and user manual.
Corrects all references from LLVM 17 to LLVM 18, documents actual
system libraries required by llvm-sys 181, adds workarounds for
missing libPolly/libzstd, inkwell lifetime patterns, and a full
gap analysis covering codegen, parser, and stdlib needs.
- Add string support: fat string {ptr, i64} representation, vudo_string_concat,
  vudo_i64_to_string runtime functions, and string concatenation codegen
- Fix terminator safety: check current_block_terminated() before emitting
  ret/br to prevent dead code after return statements
- Fix main() ABI: return i32 (not void) for proper C exit codes
- Fix if/else codegen: handle terminated branches without dead merge blocks
- Track variable types in named_values for proper load/store operations
- Add builtin-to-vudo name mapping for println/print host function calls
- Implement FromStr for Target, fix clippy lints across all crates
- Update native examples with main() entry points and print_i64 helpers
- Add program.dol comprehensive showcase of all working native features
- Add examples/native/README.md developer documentation

All 12 native examples compile, link, and execute correctly.
15 llvm-backend tests pass, 0 main DOL test regressions.
- Add benchmarks/src/lib.rs so Cargo can parse the benchmark manifest
- Fix doc test step: use explicit features instead of --all-features
  to avoid pulling in melior/tblgen-alt which requires LLVM headers
- Move bench files to benches/ where Cargo expects them
- Move regression_tests.rs to tests/ (uses #[test], not criterion)
- Remove [[bench]] entry for regression_tests (it's an integration test)
@ardeshir
ardeshir merged commit 1f24903 into main Feb 16, 2026
32 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant