Skip to main content

Module writer

Module writer 

Source
Expand description

Public API for writer. Bitcode writer: serializes an IR Module to the LRIR binary format.

§Format

The LRIR (“LLVM-in-Rust IR”) binary format is a custom format designed for compact, faithful round-trip serialization of a (Context, Module) pair.

Layout:

[4B]  magic  = 0x4C 0x52 0x49 0x52  ("LRIR")
[4B]  version (u32 LE) = 1
[4B]  type_count (u32 LE)
[...]  type_count × TypeRecord
[4B]  const_count (u32 LE)
[...]  const_count × ConstRecord
[str]  module_name (u32 len + bytes)
[4B]  func_count (u32 LE)
[...]  func_count × FunctionRecord

Each string is encoded as u32 length + UTF-8 bytes (no null terminator). Optional strings use a 0 length to mean “absent”.

Re-exports§

pub use write_bitcode as write;

Functions§

write_bitcode
Serialize (ctx, module) into the LRIR binary format.