pub trait ExtensionOpFn<'a, H>: for<'c> Fn(&mut EmitFuncContext<'c, 'a, H>, EmitOpArgs<'c, '_, ExtensionOp, H>) -> Result<()> + 'a { }
Expand description
A helper trait for describing the callback used for emitting ExtensionOps,
and for hanging documentation. We have the appropriate Fn
as a supertrait,
and there is a blanket impl for that Fn
. We do not intend users to impl
this trait.
ExtensionOpFn
callbacks are registered against a fully qualified OpName,
i.e. including it’s ExtensionId. Callbacks can assume that the provided
EmitOpArgs::node holds an op matching that fully qualified name, and that
the signature of that op determinies the length and types of
EmitOpArgs::inputs, and EmitOpArgs::outputs via
EmitFuncContext::llvm_type.
Callbacks should use the supplied EmitFuncContext to emit LLVM to match the desired semantics of the op. If a callback returns success then the callback must:
- ensure that crate::emit::func::RowPromise::finish has been called on the outputs.
- ensure that the contexts inkwell::builder::Builder is positioned at the end of a basic block, logically after the execution of the just-emitted op.
Callbacks may hold references with lifetimes older than 'a
.