pub struct ModuleRef(/* private fields */);
Expand description
LLVM Module wrapper
Implementations§
Source§impl ModuleRef
impl ModuleRef
Sourcepub fn create_module_with_name(module_name: &str) -> Self
pub fn create_module_with_name(module_name: &str) -> Self
§Panics
It panics if module creation is null
Sourcepub fn create_module_with_name_in_context(
module_name: &str,
context: &ContextRef,
) -> Self
pub fn create_module_with_name_in_context( module_name: &str, context: &ContextRef, ) -> Self
§Panics
It panics if module creation is null
Sourcepub fn clone_module(&self) -> Self
pub fn clone_module(&self) -> Self
Return an exact copy of the current module.
Sourcepub fn get_module_identifier(&self) -> Option<String>
pub fn get_module_identifier(&self) -> Option<String>
Obtain the identifier of a module.
Sourcepub fn set_module_identifier(&self, ident: &str)
pub fn set_module_identifier(&self, ident: &str)
Set the identifier of a module to a string Ident with length Len.
Sourcepub fn get_source_file_name(&self) -> Option<String>
pub fn get_source_file_name(&self) -> Option<String>
Obtain the module’s original source file name.
Sourcepub fn set_source_file_name(&self, name: &str)
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.
Sourcepub fn get_data_layout_str(&self) -> Option<String>
pub fn get_data_layout_str(&self) -> Option<String>
Get module data layout
Sourcepub fn set_data_layout(&self, data_layout_str: &str)
pub fn set_data_layout(&self, data_layout_str: &str)
Set the data layout for a module.
Sourcepub fn get_target(&self) -> Option<String>
pub fn get_target(&self) -> Option<String>
Obtain the target triple for a module.
Sourcepub fn set_target(&self, triple: &str)
pub fn set_target(&self, triple: &str)
Set the target triple for a module.
Sourcepub fn copy_module_flags_metadata(&self) -> Option<ModuleFlagEntry>
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
.
Sourcepub fn get_module_flag(&self, key: &str) -> MetadataRef
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.
pub fn add_module_flag( &self, behavior: &ModuleFlagBehavior, key: &str, val: &MetadataRef, )
Sourcepub fn dump_module(&self)
pub fn dump_module(&self)
Dump module to stdout
Sourcepub fn print_module_to_file(&self, filename: &str) -> Result<(), String>
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
Sourcepub fn print_module_to_string(&self) -> Option<String>
pub fn print_module_to_string(&self) -> Option<String>
Return a string representation of the module.
Sourcepub fn get_module_inline_asm(&self) -> Option<String>
pub fn get_module_inline_asm(&self) -> Option<String>
Get inline assembly for a module.
Sourcepub fn set_module_inline_asm(&self, asm: &str)
pub fn set_module_inline_asm(&self, asm: &str)
Set inline assembly for a module.
Sourcepub fn append_module_inline_asm(&self, asm: &str)
pub fn append_module_inline_asm(&self, asm: &str)
Append inline assembly to a module.
Sourcepub fn get_module_context(&self) -> ContextRef
pub fn get_module_context(&self) -> ContextRef
Obtain the context to which this module is associated.
Sourcepub fn get_first_named_metadata(&self) -> Option<NamedMetadataNodeRef>
pub fn get_first_named_metadata(&self) -> Option<NamedMetadataNodeRef>
Obtain an iterator to the first NamedMDNode
in a Module
.
Sourcepub fn get_last_named_metadata(&self) -> Option<NamedMetadataNodeRef>
pub fn get_last_named_metadata(&self) -> Option<NamedMetadataNodeRef>
Obtain an iterator to the last NamedMDNode
in a Module.
Sourcepub fn get_named_metadata(&self, name: &str) -> Option<NamedMetadataNodeRef>
pub fn get_named_metadata(&self, name: &str) -> Option<NamedMetadataNodeRef>
Retrieve a NamedMetadataNode
with the given name, returning None
if no such node exists.
Sourcepub fn get_or_insert_named_metadata(&self, name: &str) -> NamedMetadataNodeRef
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.
Sourcepub fn get_named_metadata_num_operands(&self, name: &str) -> u32
pub fn get_named_metadata_num_operands(&self, name: &str) -> u32
Obtain the number of operands for named metadata in a module.
Sourcepub fn get_named_metadata_operands(&self, name: &str) -> Vec<ValueRef>
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.
Sourcepub fn add_named_metadata_operand(&self, name: &str, val: &ValueRef)
pub fn add_named_metadata_operand(&self, name: &str, val: &ValueRef)
Add an operand to named metadata.
Sourcepub fn add_function(&self, fn_name: &str, fn_type: &TypeRef) -> ValueRef
pub fn add_function(&self, fn_name: &str, fn_type: &TypeRef) -> ValueRef
Set add function value based on Function type
Sourcepub fn get_named_function(&self, name: &str) -> ValueRef
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.
Sourcepub fn get_first_function(&self) -> ValueRef
pub fn get_first_function(&self) -> ValueRef
Obtain an iterator to the first Function in a Module.
Sourcepub fn get_last_function(&self) -> ValueRef
pub fn get_last_function(&self) -> ValueRef
Obtain an iterator to the last Function in a Module.