ling_codegen/lib.rs
1//! Code generation backends for Ling.
2//!
3//! The default build compiles to Ling bytecode only.
4//! Enable the `llvm` feature for native code generation via LLVM 18.
5
6pub mod bytecode;
7pub mod wasm;
8
9#[cfg(feature = "llvm")]
10pub mod llvm;
11
12/// Opaque MIR program handle passed to backends.
13pub struct MirProgram {
14 pub name: String,
15}
16
17/// All backends implement this trait.
18pub trait CodegenBackend {
19 fn emit(&mut self, mir: &MirProgram, out: &std::path::Path) -> anyhow::Result<()>;
20}
21
22pub use bytecode::BytecodeBackend;
23pub use wasm::WasmBackend;