pub trait Inline {
// Required method
fn inline(
&mut self,
caller: &Function,
call_inst: Inst,
call_opcode: Opcode,
callee: FuncRef,
call_args: &[Value],
) -> InlineCommand<'_>;
}Expand description
A trait for directing Cranelift whether to inline a particular call or not.
Used in combination with the Context::inline
method.
Required Methods§
Sourcefn inline(
&mut self,
caller: &Function,
call_inst: Inst,
call_opcode: Opcode,
callee: FuncRef,
call_args: &[Value],
) -> InlineCommand<'_>
fn inline( &mut self, caller: &Function, call_inst: Inst, call_opcode: Opcode, callee: FuncRef, call_args: &[Value], ) -> InlineCommand<'_>
A hook invoked for each direct call instruction in a function, whose result determines whether Cranelift should inline a given call.
The Cranelift user is responsible for defining their own hueristics and deciding whether inlining the call is beneficial.
When returning a function and directing Cranelift to inline its body
into the call site, the Inline implementer must ensure the following:
-
The returned function’s signature exactly matches the
calleeFuncRef’s signature. -
The returned function must be legalized.
-
The returned function must be valid (i.e. it must pass the CLIF verifier).
-
The returned function is a correct and valid implementation of the
calleeaccording to your language’s semantics.
Failure to uphold these invariants may result in panics during compilation or incorrect runtime behavior in the generated code.