X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=bindings%2Focaml%2Fexecutionengine%2Fllvm_executionengine.ml;h=2165533c13796899147a1fe860fd012d9ac92e8b;hp=921d424ad51a01bc76a30c121a9248ee9268cc33;hb=0947d0e38ba18b32e8eb2b76009d558bc4b2346e;hpb=16609f3c5c26ba34603ae0d7ebab86fb11a72722 diff --git a/bindings/ocaml/executionengine/llvm_executionengine.ml b/bindings/ocaml/executionengine/llvm_executionengine.ml index 921d424ad51..2165533c137 100644 --- a/bindings/ocaml/executionengine/llvm_executionengine.ml +++ b/bindings/ocaml/executionengine/llvm_executionengine.ml @@ -1,4 +1,4 @@ -(*===-- llvm_executionengine.ml - LLVM Ocaml Interface ----------*- C++ -*-===* +(*===-- llvm_executionengine.ml - LLVM OCaml Interface ----------*- C++ -*-===* * * The LLVM Compiler Infrastructure * @@ -14,13 +14,23 @@ external register_exns: exn -> unit = "llvm_register_ee_exns" +module CodeModel = struct + type t = + | Default + | JIT_default + | Small + | Kernel + | Medium + | Large +end + module GenericValue = struct type t - + external of_float: Llvm.lltype -> float -> t = "llvm_genericvalue_of_float" external of_pointer: 'a -> t - = "llvm_genericvalue_of_value" + = "llvm_genericvalue_of_pointer" external of_int32: Llvm.lltype -> int32 -> t = "llvm_genericvalue_of_int32" external of_int: Llvm.lltype -> int -> t @@ -29,11 +39,11 @@ module GenericValue = struct = "llvm_genericvalue_of_nativeint" external of_int64: Llvm.lltype -> int64 -> t = "llvm_genericvalue_of_int64" - + external as_float: Llvm.lltype -> t -> float = "llvm_genericvalue_as_float" external as_pointer: t -> 'a - = "llvm_genericvalue_as_value" + = "llvm_genericvalue_as_pointer" external as_int32: t -> int32 = "llvm_genericvalue_as_int32" external as_int: t -> int @@ -47,29 +57,42 @@ end module ExecutionEngine = struct type t - + + type compileroptions = { + opt_level: int; + code_model: CodeModel.t; + no_framepointer_elim: bool; + enable_fast_isel: bool; + } + + let default_compiler_options = { + opt_level = 0; + code_model = CodeModel.JIT_default; + no_framepointer_elim = false; + enable_fast_isel = false } + (* FIXME: Ocaml is not running this setup code unless we use 'val' in the interface, which causes the emission of a stub for each function; - using 'external' in the module allows direct calls into + using 'external' in the module allows direct calls into ocaml_executionengine.c. This is hardly fatal, but it is unnecessary - overhead on top of the two stubs that are already invoked for each + overhead on top of the two stubs that are already invoked for each call into LLVM. *) let _ = register_exns (Error "") - + external create: Llvm.llmodule -> t = "llvm_ee_create" external create_interpreter: Llvm.llmodule -> t = "llvm_ee_create_interpreter" - external create_jit: Llvm.llmodule -> t + external create_jit: Llvm.llmodule -> int -> t = "llvm_ee_create_jit" - external create_fast_jit: Llvm.llmodule -> t - = "llvm_ee_create_fast_jit" + external create_mcjit: Llvm.llmodule -> compileroptions -> t + = "llvm_ee_create_mcjit" external dispose: t -> unit = "llvm_ee_dispose" external add_module: Llvm.llmodule -> t -> unit - = "llvm_ee_add_mp" + = "llvm_ee_add_module" external remove_module: Llvm.llmodule -> t -> Llvm.llmodule - = "llvm_ee_remove_mp" + = "llvm_ee_remove_module" external find_function: string -> t -> Llvm.llvalue option = "llvm_ee_find_function" external run_function: Llvm.llvalue -> GenericValue.t array -> t -> @@ -85,12 +108,11 @@ module ExecutionEngine = struct external free_machine_code: Llvm.llvalue -> t -> unit = "llvm_ee_free_machine_code" - external target_data: t -> Llvm_target.TargetData.t - = "LLVMGetExecutionEngineTargetData" - + external data_layout : t -> Llvm_target.DataLayout.t + = "llvm_ee_get_data_layout" + (* The following are not bound. Patches are welcome. - - get_target_data: t -> lltargetdata + add_global_mapping: llvalue -> llgenericvalue -> t -> unit clear_all_global_mappings: t -> unit update_global_mapping: llvalue -> llgenericvalue -> t -> unit @@ -106,7 +128,7 @@ module ExecutionEngine = struct disable_lazy_compilation: t -> unit lazy_compilation_enabled: t -> bool install_lazy_function_creator: (string -> llgenericvalue) -> t -> unit - + *) end