Struct ModuleRef

Source
pub struct ModuleRef(/* private fields */);
Expand description

LLVM Module wrapper

Implementations§

Source§

impl ModuleRef

Source

pub fn new(module_name: &str) -> Self

Create LLVM module with name

§Panics

It panics if module creation is null

Source

pub fn create_module_with_name(module_name: &str) -> Self

§Panics

It panics if module creation is null

Source

pub fn create_module_with_name_in_context( module_name: &str, context: &ContextRef, ) -> Self

§Panics

It panics if module creation is null

Source

pub fn clone_module(&self) -> Self

Return an exact copy of the current module.

Source

pub fn get_module_identifier(&self) -> Option<String>

Obtain the identifier of a module.

Source

pub fn set_module_identifier(&self, ident: &str)

Set the identifier of a module to a string Ident with length Len.

Source

pub fn get_source_file_name(&self) -> Option<String>

Obtain the module’s original source file name.

Source

pub fn set_source_file_name(&self, name: &str)

Set the original source file name of a module to a string Name with length Len.

Source

pub fn get_data_layout_str(&self) -> Option<String>

Get module data layout

Source

pub fn set_data_layout(&self, data_layout_str: &str)

Set the data layout for a module.

Source

pub fn get_target(&self) -> Option<String>

Obtain the target triple for a module.

Source

pub fn set_target(&self, triple: &str)

Set the target triple for a module.

Source

pub fn copy_module_flags_metadata(&self) -> Option<ModuleFlagEntry>

Returns the module flags as an array of flag-key-value triples. The caller is responsible for freeing this array by calling dispose_module_flags_metadata.

Source

pub fn get_module_flag(&self, key: &str) -> MetadataRef

Add a module-level flag to the module-level flags metadata if it doesn’t already exist.

Source

pub fn add_module_flag( &self, behavior: &ModuleFlagBehavior, key: &str, val: &MetadataRef, )

Source

pub fn dump_module(&self)

Dump module to stdout

Source

pub fn print_module_to_file(&self, filename: &str) -> Result<(), String>

Print a representation of a module to a file. The ErrorMessage needs to be disposed with core::dispose_message. Returns 0 on success, 1 otherwise.

§Errors

Return error as String if print module fails

Source

pub fn print_module_to_string(&self) -> Option<String>

Return a string representation of the module.

Source

pub fn get_module_inline_asm(&self) -> Option<String>

Get inline assembly for a module.

Source

pub fn set_module_inline_asm(&self, asm: &str)

Set inline assembly for a module.

Source

pub fn append_module_inline_asm(&self, asm: &str)

Append inline assembly to a module.

Source

pub fn get_module_context(&self) -> ContextRef

Obtain the context to which this module is associated.

Source

pub fn get_first_named_metadata(&self) -> Option<NamedMetadataNodeRef>

Obtain an iterator to the first NamedMDNode in a Module.

Source

pub fn get_last_named_metadata(&self) -> Option<NamedMetadataNodeRef>

Obtain an iterator to the last NamedMDNode in a Module.

Source

pub fn get_named_metadata(&self, name: &str) -> Option<NamedMetadataNodeRef>

Retrieve a NamedMetadataNode with the given name, returning None if no such node exists.

Source

pub fn get_or_insert_named_metadata(&self, name: &str) -> NamedMetadataNodeRef

Retrieve a NamedMetadataNode with the given name, creating a new node if no such node exists.

Source

pub fn get_named_metadata_num_operands(&self, name: &str) -> u32

Obtain the number of operands for named metadata in a module.

Source

pub fn get_named_metadata_operands(&self, name: &str) -> Vec<ValueRef>

Obtain the named metadata operands for a module.

The passed ValueRef pointer should refer to an array of ValueRef at least get_names_metadata_operands long. This array will be populated with the ValueRef instances. Each instance corresponds to a Metadata Node.

Source

pub fn add_named_metadata_operand(&self, name: &str, val: &ValueRef)

Add an operand to named metadata.

Source

pub fn add_function(&self, fn_name: &str, fn_type: &TypeRef) -> ValueRef

Set add function value based on Function type

Source

pub fn get_named_function(&self, name: &str) -> ValueRef

Obtain a Function value from a Module by its name.

The returned value corresponds to a Function value.

Source

pub fn get_first_function(&self) -> ValueRef

Obtain an iterator to the first Function in a Module.

Source

pub fn get_last_function(&self) -> ValueRef

Obtain an iterator to the last Function in a Module.

Trait Implementations§

Source§

impl Deref for ModuleRef

Source§

type Target = *mut LLVMModule

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for ModuleRef

Source§

fn drop(&mut self)

Dispose module

Source§

impl From<*mut LLVMModule> for ModuleRef

Source§

fn from(module: LLVMModuleRef) -> Self

Converts to this type from the input type.
Source§

impl GetRef for ModuleRef

Source§

type RawRef = *mut LLVMModule

Raw LLVM reference type
Source§

fn get_ref(&self) -> Self::RawRef

Get LLVM raw reference

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.