Skip to main content

Module

Struct Module 

Source
pub struct Module {
    pub name: String,
    pub source_filename: Option<String>,
    pub target_triple: Option<String>,
    pub data_layout: Option<String>,
    pub globals: Vec<GlobalVariable>,
    pub functions: Vec<Function>,
    pub function_names: HashMap<String, FunctionId>,
    pub global_names: HashMap<String, GlobalId>,
    pub named_types: Vec<(String, TypeId)>,
    pub debug_locations: HashMap<u32, DebugLocation>,
    pub metadata_nodes: HashMap<u32, String>,
    pub named_metadata: Vec<(String, String)>,
}
Expand description

Top-level IR module.

Fields§

§name: String

Public API for name.

§source_filename: Option<String>

Public API for source_filename.

§target_triple: Option<String>

Public API for target_triple.

§data_layout: Option<String>

Public API for data_layout.

§globals: Vec<GlobalVariable>

Public API for globals.

§functions: Vec<Function>

Public API for functions.

§function_names: HashMap<String, FunctionId>

Public API for function_names.

§global_names: HashMap<String, GlobalId>

Public API for global_names.

§named_types: Vec<(String, TypeId)>

Named type definitions in declaration order (for printing).

§debug_locations: HashMap<u32, DebugLocation>

!N = !DILocation(...) records keyed by metadata id N.

§metadata_nodes: HashMap<u32, String>

Raw metadata node definitions keyed by numeric id, e.g. !12 = !DIFile(...).

§named_metadata: Vec<(String, String)>

Named metadata definitions in insertion order, e.g. !llvm.dbg.cu = !{!0}.

Implementations§

Source§

impl Module

Source

pub fn new(name: impl Into<String>) -> Self

Public API for new.

Source

pub fn add_function(&mut self, f: Function) -> FunctionId

Public API for add_function.

Source

pub fn function(&self, id: FunctionId) -> &Function

Public API for function.

Source

pub fn function_mut(&mut self, id: FunctionId) -> &mut Function

Public API for function_mut.

Source

pub fn get_function(&self, name: &str) -> Option<(FunctionId, &Function)>

Public API for get_function.

Source

pub fn get_function_id(&self, name: &str) -> Option<FunctionId>

Public API for get_function_id.

Source

pub fn num_functions(&self) -> usize

Public API for num_functions.

Source

pub fn add_global(&mut self, gv: GlobalVariable) -> GlobalId

Public API for add_global.

Source

pub fn global(&self, id: GlobalId) -> &GlobalVariable

Public API for global.

Source

pub fn global_mut(&mut self, id: GlobalId) -> &mut GlobalVariable

Public API for global_mut.

Source

pub fn get_global(&self, name: &str) -> Option<(GlobalId, &GlobalVariable)>

Public API for get_global.

Source

pub fn get_global_id(&self, name: &str) -> Option<GlobalId>

Public API for get_global_id.

Source

pub fn num_globals(&self) -> usize

Public API for num_globals.

Source

pub fn register_named_type(&mut self, name: impl Into<String>, ty: TypeId)

Register a named struct type for emission in the module header. Duplicate names are silently ignored.

Source

pub fn set_debug_location(&mut self, id: u32, loc: DebugLocation)

Public API for set_debug_location.

Source

pub fn debug_location(&self, id: u32) -> Option<DebugLocation>

Public API for debug_location.

Source

pub fn set_metadata_node(&mut self, id: u32, value: impl Into<String>)

Public API for set_metadata_node.

Source

pub fn metadata_node(&self, id: u32) -> Option<&str>

Public API for metadata_node.

Source

pub fn set_named_metadata( &mut self, name: impl Into<String>, value: impl Into<String>, )

Public API for set_named_metadata.

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<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.