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>
impl<'module, 'ctx> MirFuncBuilder<'module, 'ctx>
Sourcepub fn finish(self) -> FuncItemRef<'ctx>
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.
Sourcepub fn get_reg(&self, name: &CStr) -> Reg
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.
Sourcepub fn new_local_reg(&self, name: &CStr, ty: Ty) -> Reg
pub fn new_local_reg(&self, name: &CStr, ty: Ty) -> Reg
Create a new virtual register.
Sourcepub fn new_label(&self) -> Label<'module>
pub fn new_label(&self) -> Label<'module>
Create a new unbound label.
The label must be inserted later via InsnBuilder::label
.
Sourcepub fn ins<'func>(
&'func self,
) -> impl InsnBuilder<'module> + use<'func, 'module, 'ctx>
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.