Skip to main content

ling_codegen/
lib.rs

1//! Code generation backends for Ling.
2
3pub mod bytecode;
4pub mod wasm;
5
6pub mod cranelift;
7
8pub struct MirProgram {
9    pub mir: ling_mir::MirProgram,
10    pub name: String,
11}
12
13impl MirProgram {
14    pub fn new(mir: ling_mir::MirProgram, name: impl Into<String>) -> Self {
15        Self { mir, name: name.into() }
16    }
17}
18
19pub trait CodegenBackend {
20    fn emit(&mut self, mir: &MirProgram, out: &std::path::Path) -> anyhow::Result<()>;
21}
22
23pub use bytecode::{compile_mir_program, BytecodeBackend, Vm, VmProgram};
24pub use cranelift::aot::CraneliftBackend;
25pub use cranelift::jit::JitBackend;
26pub use cranelift::runtime;
27pub use wasm::WasmBackend;