feat: LLVM native compilation backend#29
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
llvm-backend/— LLVM 18 native compilation for DOL programsdol-nativeCLI tool withbuild,emit-ir, andtargetssubcommandshir_lowering.rs) wired to the DOL parserdocs/native-compilation.mdWhat compiles end-to-end
What needs stdlib / library work
+)dol_string_concatin stdlib.to_string()Vec<T>,Map<K,V>for/whileloopsmatchexpressionsmutvariables+=, path syntax (::)Test results
Test plan
cargo test --allin univrs-dol (2,074 pass)cargo test --allin llvm-backend (10 pass)dol-native emit-iron all 11 native examplesdol-native buildproduces valid ELF x86-64 object filesdol-native targetslists all 5 architectures