pub struct Module<'a>(/* private fields */);Expand description
Wraps LLVMModule
Implementations§
Source§impl<'a> Module<'a>
impl<'a> Module<'a>
Sourcepub fn new(
ctx: &Context<'a>,
name: impl AsRef<str>,
) -> Result<Module<'a>, Error>
pub fn new( ctx: &Context<'a>, name: impl AsRef<str>, ) -> Result<Module<'a>, Error>
Create a new module
Sourcepub fn identifier(&self) -> Result<&str, Error>
pub fn identifier(&self) -> Result<&str, Error>
Get the module identifier
Sourcepub fn set_source_file(&mut self, name: impl AsRef<str>)
pub fn set_source_file(&mut self, name: impl AsRef<str>)
Set the module source file name
Sourcepub fn source_file(&self) -> Result<&str, Error>
pub fn source_file(&self) -> Result<&str, Error>
Get the source file name
Sourcepub fn set_target(&mut self, target: impl AsRef<str>)
pub fn set_target(&mut self, target: impl AsRef<str>)
Set the module target string
Sourcepub fn set_data_layout(&mut self, layout: impl AsRef<str>)
pub fn set_data_layout(&mut self, layout: impl AsRef<str>)
Set the module data layout string
Sourcepub fn data_layout(&self) -> Result<&str, Error>
pub fn data_layout(&self) -> Result<&str, Error>
Get data layout string
Sourcepub fn set_inline_asm(&mut self, asm: impl AsRef<str>)
pub fn set_inline_asm(&mut self, asm: impl AsRef<str>)
Set module inline assembly
Sourcepub fn append_inline_asm(&mut self, asm: impl AsRef<str>)
pub fn append_inline_asm(&mut self, asm: impl AsRef<str>)
Append module inline assembly
Sourcepub fn inline_asm(&self) -> Result<&str, Error>
pub fn inline_asm(&self) -> Result<&str, Error>
Get module inline assembly
Sourcepub fn define_function(
&self,
name: impl AsRef<str>,
t: FuncType<'_>,
) -> Result<Func<'a>, Error>
pub fn define_function( &self, name: impl AsRef<str>, t: FuncType<'_>, ) -> Result<Func<'a>, Error>
Define a new function without declaring a function body
Sourcepub fn declare_function<T: Into<Value<'a>>, F: FnOnce(Func<'a>) -> Result<T, Error>>(
&self,
builder: &Builder<'a>,
name: impl AsRef<str>,
ft: FuncType<'_>,
def: F,
) -> Result<Func<'a>, Error>
pub fn declare_function<T: Into<Value<'a>>, F: FnOnce(Func<'a>) -> Result<T, Error>>( &self, builder: &Builder<'a>, name: impl AsRef<str>, ft: FuncType<'_>, def: F, ) -> Result<Func<'a>, Error>
Declare a new function with function body
Sourcepub fn define_global(
&self,
name: impl AsRef<str>,
ty: impl AsRef<Type<'a>>,
) -> Result<Value<'a>, Error>
pub fn define_global( &self, name: impl AsRef<str>, ty: impl AsRef<Type<'a>>, ) -> Result<Value<'a>, Error>
Create a new global with an empty initializer
Sourcepub fn define_global_in_address_space(
&self,
name: impl AsRef<str>,
ty: impl AsRef<Type<'a>>,
addr: usize,
) -> Result<Value<'a>, Error>
pub fn define_global_in_address_space( &self, name: impl AsRef<str>, ty: impl AsRef<Type<'a>>, addr: usize, ) -> Result<Value<'a>, Error>
Define a new global in the given address space with an empty initializer
Sourcepub fn declare_global(
&self,
name: impl AsRef<str>,
t: impl AsRef<Value<'a>>,
) -> Result<Value<'a>, Error>
pub fn declare_global( &self, name: impl AsRef<str>, t: impl AsRef<Value<'a>>, ) -> Result<Value<'a>, Error>
Create a new global with the specified initializer
Sourcepub fn declare_global_in_address_space(
&self,
name: impl AsRef<str>,
t: impl AsRef<Value<'a>>,
addr: usize,
) -> Result<Value<'a>, Error>
pub fn declare_global_in_address_space( &self, name: impl AsRef<str>, t: impl AsRef<Value<'a>>, addr: usize, ) -> Result<Value<'a>, Error>
Create a new global in the given address space with the specified initializer
Sourcepub fn function(&self, name: impl AsRef<str>) -> Result<Func<'a>, Error>
pub fn function(&self, name: impl AsRef<str>) -> Result<Func<'a>, Error>
Get a function by name
Sourcepub fn global(&self, name: impl AsRef<str>) -> Result<Value<'a>, Error>
pub fn global(&self, name: impl AsRef<str>) -> Result<Value<'a>, Error>
Get a global value by name
Sourcepub fn first_global(&self) -> Result<Value<'a>, Error>
pub fn first_global(&self) -> Result<Value<'a>, Error>
Get the first global
Sourcepub fn last_global(&self) -> Result<Value<'a>, Error>
pub fn last_global(&self) -> Result<Value<'a>, Error>
Get the last global
Sourcepub fn next_global(
&self,
global: impl AsRef<Value<'a>>,
) -> Result<Value<'a>, Error>
pub fn next_global( &self, global: impl AsRef<Value<'a>>, ) -> Result<Value<'a>, Error>
Get the next global
Sourcepub fn first_function(&self) -> Result<Func<'a>, Error>
pub fn first_function(&self) -> Result<Func<'a>, Error>
Get the first function
Sourcepub fn last_function(&self) -> Result<Func<'a>, Error>
pub fn last_function(&self) -> Result<Func<'a>, Error>
Get the last function
Sourcepub fn parse_ir(
ctx: &Context<'_>,
mem_buf: &MemoryBuffer,
) -> Result<Module<'a>, Error>
pub fn parse_ir( ctx: &Context<'_>, mem_buf: &MemoryBuffer, ) -> Result<Module<'a>, Error>
Create a new module from existing IR
Sourcepub fn parse_bitcode(
ctx: &Context<'_>,
mem_buf: &MemoryBuffer,
) -> Option<Module<'a>>
pub fn parse_bitcode( ctx: &Context<'_>, mem_buf: &MemoryBuffer, ) -> Option<Module<'a>>
Create a new module from existing bitcode
Sourcepub fn write_bitcode_to_file(
&self,
path: impl AsRef<Path>,
) -> Result<bool, Error>
pub fn write_bitcode_to_file( &self, path: impl AsRef<Path>, ) -> Result<bool, Error>
Write module bitcode to file
Sourcepub fn write_bitcode_to_memory_buffer(&self) -> Result<MemoryBuffer, Error>
pub fn write_bitcode_to_memory_buffer(&self) -> Result<MemoryBuffer, Error>
Write module bitcode to in-memory buffer
Sourcepub fn set_wasm32(&mut self)
pub fn set_wasm32(&mut self)
Set WASM32 target/data layout
Sourcepub fn set_target_data(&mut self, target: &TargetData<'_>)
pub fn set_target_data(&mut self, target: &TargetData<'_>)
Set target data
Sourcepub fn target_data(&self) -> Result<TargetData<'_>, Error>
pub fn target_data(&self) -> Result<TargetData<'_>, Error>
Get target data