Struct MirFuncBuilder

Source
pub struct MirFuncBuilder<'module, 'ctx> { /* private fields */ }
Expand description

The currently building MIR function.

There can only be at most one unfinished function for each MirContext inside one unfinished module. It is strongly advised to explicitly call MirFuncBuilder::finish to finish the current function for clarity and observe any error outside drop impl. MirFuncBuilder will automatically finish it on drop.

Implementations§

Source§

impl<'module, 'ctx> MirFuncBuilder<'module, 'ctx>

Source

pub fn finish(self) -> FuncItemRef<'ctx>

Explicitly finish the function and return the function reference.

§Panics

Panic from C if the function content is malformed.

Source

pub fn get_reg(&self, name: &CStr) -> Reg

Get the virtual register or given name.

Function parameters are represented as pre-defined virtual registers of same names.

Source

pub fn new_local_reg(&self, name: &CStr, ty: Ty) -> Reg

Create a new virtual register.

Source

pub fn new_label(&self) -> Label<'module>

Create a new unbound label.

The label must be inserted later via InsnBuilder::label.

Source

pub fn ins<'func>( &'func self, ) -> impl InsnBuilder<'module> + use<'func, 'module, 'ctx>

Append a new instruction to the function.

See InsnBuilder for all instructions available.

Trait Implementations§

Source§

impl<'module, 'ctx> Debug for MirFuncBuilder<'module, 'ctx>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for MirFuncBuilder<'_, '_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'module, 'ctx> Freeze for MirFuncBuilder<'module, 'ctx>

§

impl<'module, 'ctx> !RefUnwindSafe for MirFuncBuilder<'module, 'ctx>

§

impl<'module, 'ctx> !Send for MirFuncBuilder<'module, 'ctx>

§

impl<'module, 'ctx> !Sync for MirFuncBuilder<'module, 'ctx>

§

impl<'module, 'ctx> Unpin for MirFuncBuilder<'module, 'ctx>

§

impl<'module, 'ctx> !UnwindSafe for MirFuncBuilder<'module, 'ctx>

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.