get_or_make_function

Function get_or_make_function 

Source
pub fn get_or_make_function<'c, H: HugrView<Node = Node>, const N: usize>(
    ctx: &mut EmitFuncContext<'c, '_, H>,
    func_name: &str,
    args: [BasicValueEnum<'c>; N],
    ret_type: Option<BasicTypeEnum<'c>>,
    go: impl FnOnce(&mut EmitFuncContext<'c, '_, H>, [BasicValueEnum<'c>; N]) -> Result<Option<BasicValueEnum<'c>>>,
) -> Result<Option<BasicValueEnum<'c>>>
Expand description

Helper to outline LLVM IR into a function call instead of inlining it every time.

The first time this helper is called with a given function name, a function is built using the provided closure. Future invocations with the same name will just emit calls to this function.

The return type is specified by ret_type, and if Some then the closure must return a value of that type, which will be returned from the function. Otherwise, the function will return void.