An Elixir-to-native compiler built on Beaver
and the Slang-defined ex dialect.
The frontend boundary lowers an expanded module snapshot to ex IR, then
ex to func/arith/scf/cf and finally to LLVM via
Beaver.MLIR.Conversion.Plan. Both JIT (execute/2) and AOT (build/3)
execution are supported.
Summary
Functions
Compiles Elixir source to a static library and a C driver.
Parses and lowers Elixir source into a verified builtin.module of ex
operations.
Parses Elixir source, lowers it to LLVM and executes main through the
MLIR JIT, returning its value.
Parses Elixir source and lowers it all the way to LLVM dialect IR.
Functions
@spec build(String.t(), Path.t(), Beaver.MLIR.Context.t()) :: %{ archive: Path.t(), driver: Path.t(), object: Path.t() }
Compiles Elixir source to a static library and a C driver.
The entry function main is renamed to batata_main in the generated
object so the driver can call it without colliding with the C entry point.
Returns a map with the archive, driver and object paths.
Link the driver against the archive and run it:
cc driver.c libMath.a -o run_math
@spec compile(String.t(), Beaver.MLIR.Context.t()) :: Beaver.MLIR.Module.t()
Parses and lowers Elixir source into a verified builtin.module of ex
operations.
@spec execute(String.t(), Beaver.MLIR.Context.t()) :: term()
Parses Elixir source, lowers it to LLVM and executes main through the
MLIR JIT, returning its value.
The JIT engine and module are destroyed before returning.
@spec to_llvm(String.t(), Beaver.MLIR.Context.t()) :: Beaver.MLIR.Module.t()
Parses Elixir source and lowers it all the way to LLVM dialect IR.