llvm.org GIT mirror llvm / 7b3afb4
Expose the external functions for ocaml's execution engine as an optimization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97683 91177308-0d34-0410-b5e6-96231b3b80d8 Erick Tryzelaar 10 years ago
1 changed file(s) with 36 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
2424 (** [of_float fpty n] boxes the float [n] in a float-valued generic value
2525 according to the floating point type [fpty]. See the fields
2626 [llvm::GenericValue::DoubleVal] and [llvm::GenericValue::FloatVal]. *)
27 val of_float: Llvm.lltype -> float -> t
27 external of_float : Llvm.lltype -> float -> t = "llvm_genericvalue_of_float"
2828
2929 (** [of_pointer v] boxes the pointer value [v] in a generic value. See the
3030 field [llvm::GenericValue::PointerVal]. *)
31 val of_pointer: 'a -> t
31 external of_pointer : 'a -> t = "llvm_genericvalue_of_value"
3232
3333 (** [of_int32 n w] boxes the int32 [i] in a generic value with the bitwidth
3434 [w]. See the field [llvm::GenericValue::IntVal]. *)
35 val of_int32: Llvm.lltype -> int32 -> t
35 external of_int32 : Llvm.lltype -> int32 -> t = "llvm_genericvalue_of_int32"
3636
3737 (** [of_int n w] boxes the int [i] in a generic value with the bitwidth
3838 [w]. See the field [llvm::GenericValue::IntVal]. *)
39 val of_int: Llvm.lltype -> int -> t
39 external of_int : Llvm.lltype -> int -> t = "llvm_genericvalue_of_int"
4040
4141 (** [of_natint n w] boxes the native int [i] in a generic value with the
4242 bitwidth [w]. See the field [llvm::GenericValue::IntVal]. *)
43 val of_nativeint: Llvm.lltype -> nativeint -> t
44
43 external of_nativeint : Llvm.lltype -> nativeint -> t
44 = "llvm_genericvalue_of_nativeint"
45
4546 (** [of_int64 n w] boxes the int64 [i] in a generic value with the bitwidth
4647 [w]. See the field [llvm::GenericValue::IntVal]. *)
47 val of_int64: Llvm.lltype -> int64 -> t
48
48 external of_int64 : Llvm.lltype -> int64 -> t = "llvm_genericvalue_of_int64"
49
4950 (** [as_float fpty gv] unboxes the floating point-valued generic value [gv] of
5051 floating point type [fpty]. See the fields [llvm::GenericValue::DoubleVal]
5152 and [llvm::GenericValue::FloatVal]. *)
52 val as_float: Llvm.lltype -> t -> float
53 external as_float : Llvm.lltype -> t -> float = "llvm_genericvalue_as_float"
5354
5455 (** [as_pointer gv] unboxes the pointer-valued generic value [gv]. See the
5556 field [llvm::GenericValue::PointerVal]. *)
56 val as_pointer: t -> 'a
57 external as_pointer : t -> 'a = "llvm_genericvalue_as_value"
5758
5859 (** [as_int32 gv] unboxes the integer-valued generic value [gv] as an [int32].
5960 Is invalid if [gv] has a bitwidth greater than 32 bits. See the field
6061 [llvm::GenericValue::IntVal]. *)
61 val as_int32: t -> int32
62 external as_int32 : t -> int32 = "llvm_genericvalue_as_int32"
6263
6364 (** [as_int gv] unboxes the integer-valued generic value [gv] as an [int].
6465 Is invalid if [gv] has a bitwidth greater than the host bit width (but the
6566 most significant bit may be lost). See the field
6667 [llvm::GenericValue::IntVal]. *)
67 val as_int: t -> int
68 external as_int : t -> int = "llvm_genericvalue_as_int"
6869
6970 (** [as_natint gv] unboxes the integer-valued generic value [gv] as a
7071 [nativeint]. Is invalid if [gv] has a bitwidth greater than
7172 [nativeint]. See the field [llvm::GenericValue::IntVal]. *)
72 val as_nativeint: t -> nativeint
73 external as_nativeint : t -> nativeint = "llvm_genericvalue_as_int"
7374
7475 (** [as_int64 gv] returns the integer-valued generic value [gv] as an [int64].
7576 Is invalid if [gv] has a bitwidth greater than [int64]. See the field
7677 [llvm::GenericValue::IntVal]. *)
77 val as_int64: t -> int64
78 external as_int64 : t -> int64 = "llvm_genericvalue_as_int64"
7879 end
7980
8081
8990 interpreter. Raises [Error msg] if an error occurrs. The execution engine
9091 is not garbage collected and must be destroyed with [dispose ee].
9192 See the function [llvm::EngineBuilder::create]. *)
92 val create: Llvm.llmodule -> t
93 external create : Llvm.llmodule -> t = "llvm_ee_create"
9394
9495 (** [create_interpreter m] creates a new interpreter, taking ownership of the
9596 module [m] if successful. Raises [Error msg] if an error occurrs. The
9697 execution engine is not garbage collected and must be destroyed with
9798 [dispose ee].
9899 See the function [llvm::EngineBuilder::create]. *)
99 val create_interpreter: Llvm.llmodule -> t
100 external create_interpreter : Llvm.llmodule -> t = "llvm_ee_create_interpreter"
100101
101102 (** [create_jit m optlevel] creates a new JIT (just-in-time compiler), taking
102103 ownership of the module [m] if successful with the desired optimization
103104 level [optlevel]. Raises [Error msg] if an error occurrs. The execution
104105 engine is not garbage collected and must be destroyed with [dispose ee].
105106 See the function [llvm::EngineBuilder::create]. *)
106 val create_jit : Llvm.llmodule -> int -> t
107 external create_jit : Llvm.llmodule -> int -> t = "llvm_ee_create_jit"
107108
108109 (** [dispose ee] releases the memory used by the execution engine and must be
109110 invoked to avoid memory leaks. *)
110 val dispose: t -> unit
111 external dispose : t -> unit = "llvm_ee_dispose"
111112
112113 (** [add_module m ee] adds the module [m] to the execution engine [ee]. *)
113 val add_module: Llvm.llmodule -> t -> unit
114 external add_module : Llvm.llmodule -> t -> unit = "llvm_ee_add_mp"
114115
115116 (** [remove_module m ee] removes the module [m] from the execution engine
116117 [ee], disposing of [m] and the module referenced by [mp]. Raises
117118 [Error msg] if an error occurs. *)
118 val remove_module: Llvm.llmodule -> t -> Llvm.llmodule
119 external remove_module : Llvm.llmodule -> t -> Llvm.llmodule
120 = "llvm_ee_remove_module"
119121
120122 (** [find_function n ee] finds the function named [n] defined in any of the
121123 modules owned by the execution engine [ee]. Returns [None] if the function
122124 is not found and [Some f] otherwise. *)
123 val find_function: string -> t -> Llvm.llvalue option
125 external find_function : string -> t -> Llvm.llvalue option
126 = "llvm_ee_find_function"
124127
125128 (** [run_function f args ee] synchronously executes the function [f] with the
126129 arguments [args], which must be compatible with the parameter types. *)
127 val run_function: Llvm.llvalue -> GenericValue.t array -> t ->
128 GenericValue.t
130 external run_function : Llvm.llvalue -> GenericValue.t array -> t ->
131 GenericValue.t
132 = "llvm_ee_run_function"
129133
130134 (** [run_static_ctors ee] executes the static constructors of each module in
131135 the execution engine [ee]. *)
132 val run_static_ctors: t -> unit
136 external run_static_ctors : t -> unit = "llvm_ee_run_static_ctors"
133137
134138 (** [run_static_dtors ee] executes the static destructors of each module in
135139 the execution engine [ee]. *)
136 val run_static_dtors: t -> unit
140 external run_static_dtors : t -> unit = "llvm_ee_run_static_dtors"
137141
138142 (** [run_function_as_main f args env ee] executes the function [f] as a main
139143 function, passing it [argv] and [argc] according to the string array
140144 [args], and [envp] as specified by the array [env]. Returns the integer
141145 return value of the function. *)
142 val run_function_as_main: Llvm.llvalue -> string array ->
143 (string * string) array -> t -> int
146 external run_function_as_main : Llvm.llvalue -> string array ->
147 (string * string) array -> t -> int
148 = "llvm_ee_run_function_as_main"
144149
145150 (** [free_machine_code f ee] releases the memory in the execution engine [ee]
146151 used to store the machine code for the function [f]. *)
147 val free_machine_code: Llvm.llvalue -> t -> unit
152 external free_machine_code : Llvm.llvalue -> t -> unit
153 = "llvm_ee_free_machine_code"
148154
149155 (** [target_data ee] is the target data owned by the execution engine
150156 [ee]. *)
151 val target_data: t -> Llvm_target.TargetData.t
157 external target_data : t -> Llvm_target.TargetData.t
158 = "LLVMGetExecutionEngineTargetData"
152159 end
153160
154161 external initialize_native_target : unit -> bool