module ExecutionEngine: sig
.. end
type
t
An execution engine is either a JIT compiler or an interpreter, capable of
directly loading an LLVM module and executing its functions without first
invoking a static compiler and generating a native executable.
val create : Llvm.llmoduleprovider -> t
create mp
creates a new execution engine, taking ownership of the
module provider mp
if successful. Creates a JIT if possible, else falls
back to an interpreter. Raises Error msg
if an error occurrs. The
execution engine is not garbage collected and must be destroyed with
dispose ee
. See the function llvm::ExecutionEngine::create
.
val create_interpreter : Llvm.llmoduleprovider -> t
create_interpreter mp
creates a new interpreter, taking ownership of the
module provider mp
if successful. Raises Error msg
if an error
occurrs. The execution engine is not garbage collected and must be
destroyed with dispose ee
.
See the function llvm::ExecutionEngine::create
.
val create_jit : Llvm.llmoduleprovider -> t
create_jit mp
creates a new JIT (just-in-time compiler), taking
ownership of the module provider mp
if successful. Raises Error msg
if
an error occurrs. The execution engine is not garbage collected and must
be destroyed with dispose ee
.
See the function llvm::ExecutionEngine::create
.
val dispose : t -> unit
dispose ee
releases the memory used by the execution engine and must be
invoked to avoid memory leaks.
val add_module_provider : Llvm.llmoduleprovider -> t -> unit
add_module_provider mp ee
adds the module provider mp
to the execution
engine ee
.
val remove_module_provider : Llvm.llmoduleprovider ->
t -> Llvm.llmodule
remove_module_provider mp ee
removes the module provider mp
from the
execution engine ee
, disposing of mp
and the module referenced by
mp
. Raises Error msg
if an error occurs.
val find_function : string -> t -> Llvm.llvalue option
find_function n ee
finds the function named n
defined in any of the
modules owned by the execution engine ee
. Returns None
if the function
is not found and Some f
otherwise.
val run_function : Llvm.llvalue ->
Llvm_executionengine.GenericValue.t array ->
t -> Llvm_executionengine.GenericValue.t
run_function f args ee
synchronously executes the function f
with the
arguments args
, which must be compatible with the parameter types.
val run_static_ctors : t -> unit
run_static_ctors ee
executes the static constructors of each module in
the execution engine ee
.
val run_static_dtors : t -> unit
run_static_dtors ee
executes the static destructors of each module in
the execution engine ee
.
val run_function_as_main : Llvm.llvalue ->
string array ->
(string * string) array -> t -> int
run_function_as_main f args env ee
executes the function f
as a main
function, passing it argv
and argc
according to the string array
args
, and envp
as specified by the array env
. Returns the integer
return value of the function.
val free_machine_code : Llvm.llvalue -> t -> unit
free_machine_code f ee
releases the memory in the execution engine ee
used to store the machine code for the function f
.
val target_data : t -> Llvm_target.TargetData.t
target_data ee
is the target data owned by the execution engine
ee
.