pub struct Module { /* private fields */ }
Expand description

Wrapper for a LLVM Module with its own LLVM Context.

Implementations§

source§

impl<'llvm> Module

source

pub fn new() -> Self

Create a new Module instance.

Panics

Panics if creating the context or the module fails.

source

pub fn dump(&self)

Dump LLVM IR emitted into the Module to stdout.

source

pub fn type_f64(&self) -> Type<'llvm>

Get a type reference representing a f64 float.

Panics

Panics if LLVM API returns a null pointer.

source

pub fn type_fn( &'llvm self, args: &mut [Type<'llvm>], ret: Type<'llvm> ) -> Type<'llvm>

Get a type reference representing a fn(args) -> ret function.

Panics

Panics if LLVM API returns a null pointer.

source

pub fn add_fn(&'llvm self, name: &str, fn_type: Type<'llvm>) -> FnValue<'llvm>

Add a function with the given name and fn_type to the module and return a value reference representing the function.

Panics

Panics if LLVM API returns a null pointer or name could not be converted to a SmallCStr.

source

pub fn get_fn(&'llvm self, name: &str) -> Option<FnValue<'llvm>>

Get a function value reference to the function with the given name if it was previously added to the module with add_fn.

Panics

Panics if name could not be converted to a SmallCStr.

source

pub fn append_basic_block( &'llvm self, fn_value: FnValue<'llvm> ) -> BasicBlock<'llvm>

Append a Basic Block to the end of the function referenced by the value reference fn_value.

Panics

Panics if LLVM API returns a null pointer.

source

pub fn create_basic_block(&self) -> BasicBlock<'llvm>

Create a free-standing Basic Block without adding it to a function. This can be added to a function at a later point in time with FnValue::append_basic_block.

Panics

Panics if LLVM API returns a null pointer.

Trait Implementations§

source§

impl Drop for Module

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Module

§

impl !Send for Module

§

impl !Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.