Expand description
§LLVM IR lowering
Lower irvm IR to LLVM IR.
The main functions to use are lower_module_to_llvmir
which gives you a CompileResult
.
With this result you can either write it to a file (.ll), compile it to an object file or create a JIT Engine to execute methods (a bit limited currently, useful for testing).
ⓘ
// Lower the module.
let result = lower_module_to_llvmir(&mymodule, &my_type_storage)?;
// Output to a file as a .ll
output_to_file(&result, Path::new("out.ll"))?;
// Compile to an object file.
compile_object(&result, &mymodule.target_triple, CompileOptions::default(), Path::new("out.o"), false)?;
// Or create a JIT engine.
let engine = create_jit_engine(result, 3)?;
let res = unsafe { engine.execute("main", &[JitValue::U32(4)], JitValue::U32(0))? };
Structs§
- Compile
Options - Compile options to generate the object file.
- Compile
Result - A compile result from lowering a given Module.
- JitEngine
- A prepared JIT engine.
Enums§
- Code
Model - The code model supported by LLVM.
- Error
- A possible Error.
- JitValue
- Possible value/types to pass to the JIT engine execute method.
- OptLevel
- The optimization level to use.
- Output
Compilation - Reloc
Model - The relocation model types supported by LLVM
- Target
Cpu - The target LLVM cpu.
- Target
CpuFeatures - The target LLVM cpu features.
Functions§
- compile_
object - Compiles the given llvm compile result to an object or assembly file.
- create_
jit_ engine - Creates a jit engine for the given compile result.
- lower_
module_ to_ llvmir - Lowers the given module to llvm ir.
- output_
to_ file - Outputs the given compile result to a llvm ir file.