llvm.org GIT mirror llvm / a156efd
Fix OCaml bindings crash, PR8847. See http://caml.inria.fr/mantis/view.php?id=4166 If we call only external functions from a module, then its 'let _' bindings don't get executed, which means that the exceptions don't get registered for use in the C code. This in turn causes llvm_raise to call raise_with_arg() with a NULL pointer and cause a segmentation fault. The workaround is to declare all 'external' functions as 'val' in these .mli files. Also added a separate testcase (the testcase must call only external functions for the bug to occur). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122497 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 9 years ago
4 changed file(s) with 535 addition(s) and 519 deletion(s). Raw diff Collapse all Expand all
1717 memory buffer [mb] in the context [context]. Returns [m] if successful, or
1818 raises [Error msg] otherwise, where [msg] is a description of the error
1919 encountered. See the function [llvm::getBitcodeModule]. *)
20 external get_module : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
21 = "llvm_get_module"
20 val get_module : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
21
2222
2323 (** [parse_bitcode context mb] parses the bitcode for a new module [m] from the
2424 memory buffer [mb] in the context [context]. Returns [m] if successful, or
2525 raises [Error msg] otherwise, where [msg] is a description of the error
2626 encountered. See the function [llvm::ParseBitcodeFile]. *)
27 external parse_bitcode : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
28 = "llvm_parse_bitcode"
27 val parse_bitcode : Llvm.llcontext -> Llvm.llmemorybuffer -> Llvm.llmodule
28
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 external of_float : Llvm.lltype -> float -> t = "llvm_genericvalue_of_float"
27 val of_float : Llvm.lltype -> float -> t
2828
2929 (** [of_pointer v] boxes the pointer value [v] in a generic value. See the
3030 field [llvm::GenericValue::PointerVal]. *)
31 external of_pointer : 'a -> t = "llvm_genericvalue_of_pointer"
31 val of_pointer : 'a -> t
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 external of_int32 : Llvm.lltype -> int32 -> t = "llvm_genericvalue_of_int32"
35 val of_int32 : Llvm.lltype -> int32 -> t
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 external of_int : Llvm.lltype -> int -> t = "llvm_genericvalue_of_int"
39 val of_int : Llvm.lltype -> int -> t
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 external of_nativeint : Llvm.lltype -> nativeint -> t
44 = "llvm_genericvalue_of_nativeint"
43 val of_nativeint : Llvm.lltype -> nativeint -> t
44
4545
4646 (** [of_int64 n w] boxes the int64 [i] in a generic value with the bitwidth
4747 [w]. See the field [llvm::GenericValue::IntVal]. *)
48 external of_int64 : Llvm.lltype -> int64 -> t = "llvm_genericvalue_of_int64"
48 val of_int64 : Llvm.lltype -> int64 -> t
4949
5050 (** [as_float fpty gv] unboxes the floating point-valued generic value [gv] of
5151 floating point type [fpty]. See the fields [llvm::GenericValue::DoubleVal]
5252 and [llvm::GenericValue::FloatVal]. *)
53 external as_float : Llvm.lltype -> t -> float = "llvm_genericvalue_as_float"
53 val as_float : Llvm.lltype -> t -> float
5454
5555 (** [as_pointer gv] unboxes the pointer-valued generic value [gv]. See the
5656 field [llvm::GenericValue::PointerVal]. *)
57 external as_pointer : t -> 'a = "llvm_genericvalue_as_pointer"
57 val as_pointer : t -> 'a
5858
5959 (** [as_int32 gv] unboxes the integer-valued generic value [gv] as an [int32].
6060 Is invalid if [gv] has a bitwidth greater than 32 bits. See the field
6161 [llvm::GenericValue::IntVal]. *)
62 external as_int32 : t -> int32 = "llvm_genericvalue_as_int32"
62 val as_int32 : t -> int32
6363
6464 (** [as_int gv] unboxes the integer-valued generic value [gv] as an [int].
6565 Is invalid if [gv] has a bitwidth greater than the host bit width (but the
6666 most significant bit may be lost). See the field
6767 [llvm::GenericValue::IntVal]. *)
68 external as_int : t -> int = "llvm_genericvalue_as_int"
68 val as_int : t -> int
6969
7070 (** [as_natint gv] unboxes the integer-valued generic value [gv] as a
7171 [nativeint]. Is invalid if [gv] has a bitwidth greater than
7272 [nativeint]. See the field [llvm::GenericValue::IntVal]. *)
73 external as_nativeint : t -> nativeint = "llvm_genericvalue_as_nativeint"
73 val as_nativeint : t -> nativeint
7474
7575 (** [as_int64 gv] returns the integer-valued generic value [gv] as an [int64].
7676 Is invalid if [gv] has a bitwidth greater than [int64]. See the field
7777 [llvm::GenericValue::IntVal]. *)
78 external as_int64 : t -> int64 = "llvm_genericvalue_as_int64"
78 val as_int64 : t -> int64
7979 end
8080
8181
9090 interpreter. Raises [Error msg] if an error occurrs. The execution engine
9191 is not garbage collected and must be destroyed with [dispose ee].
9292 See the function [llvm::EngineBuilder::create]. *)
93 external create : Llvm.llmodule -> t = "llvm_ee_create"
93 val create : Llvm.llmodule -> t
9494
9595 (** [create_interpreter m] creates a new interpreter, taking ownership of the
9696 module [m] if successful. Raises [Error msg] if an error occurrs. The
9797 execution engine is not garbage collected and must be destroyed with
9898 [dispose ee].
9999 See the function [llvm::EngineBuilder::create]. *)
100 external create_interpreter : Llvm.llmodule -> t = "llvm_ee_create_interpreter"
100 val create_interpreter : Llvm.llmodule -> t
101101
102102 (** [create_jit m optlevel] creates a new JIT (just-in-time compiler), taking
103103 ownership of the module [m] if successful with the desired optimization
104104 level [optlevel]. Raises [Error msg] if an error occurrs. The execution
105105 engine is not garbage collected and must be destroyed with [dispose ee].
106106 See the function [llvm::EngineBuilder::create]. *)
107 external create_jit : Llvm.llmodule -> int -> t = "llvm_ee_create_jit"
107 val create_jit : Llvm.llmodule -> int -> t
108108
109109 (** [dispose ee] releases the memory used by the execution engine and must be
110110 invoked to avoid memory leaks. *)
111 external dispose : t -> unit = "llvm_ee_dispose"
111 val dispose : t -> unit
112112
113113 (** [add_module m ee] adds the module [m] to the execution engine [ee]. *)
114 external add_module : Llvm.llmodule -> t -> unit = "llvm_ee_add_module"
114 val add_module : Llvm.llmodule -> t -> unit
115115
116116 (** [remove_module m ee] removes the module [m] from the execution engine
117117 [ee], disposing of [m] and the module referenced by [mp]. Raises
118118 [Error msg] if an error occurs. *)
119 external remove_module : Llvm.llmodule -> t -> Llvm.llmodule
120 = "llvm_ee_remove_module"
119 val remove_module : Llvm.llmodule -> t -> Llvm.llmodule
120
121121
122122 (** [find_function n ee] finds the function named [n] defined in any of the
123123 modules owned by the execution engine [ee]. Returns [None] if the function
124124 is not found and [Some f] otherwise. *)
125 external find_function : string -> t -> Llvm.llvalue option
126 = "llvm_ee_find_function"
125 val find_function : string -> t -> Llvm.llvalue option
126
127127
128128 (** [run_function f args ee] synchronously executes the function [f] with the
129129 arguments [args], which must be compatible with the parameter types. *)
130 external run_function : Llvm.llvalue -> GenericValue.t array -> t ->
130 val run_function : Llvm.llvalue -> GenericValue.t array -> t ->
131131 GenericValue.t
132 = "llvm_ee_run_function"
132
133133
134134 (** [run_static_ctors ee] executes the static constructors of each module in
135135 the execution engine [ee]. *)
136 external run_static_ctors : t -> unit = "llvm_ee_run_static_ctors"
136 val run_static_ctors : t -> unit
137137
138138 (** [run_static_dtors ee] executes the static destructors of each module in
139139 the execution engine [ee]. *)
140 external run_static_dtors : t -> unit = "llvm_ee_run_static_dtors"
140 val run_static_dtors : t -> unit
141141
142142 (** [run_function_as_main f args env ee] executes the function [f] as a main
143143 function, passing it [argv] and [argc] according to the string array
144144 [args], and [envp] as specified by the array [env]. Returns the integer
145145 return value of the function. *)
146 external run_function_as_main : Llvm.llvalue -> string array ->
146 val run_function_as_main : Llvm.llvalue -> string array ->
147147 (string * string) array -> t -> int
148 = "llvm_ee_run_function_as_main"
148
149149
150150 (** [free_machine_code f ee] releases the memory in the execution engine [ee]
151151 used to store the machine code for the function [f]. *)
152 external free_machine_code : Llvm.llvalue -> t -> unit
153 = "llvm_ee_free_machine_code"
152 val free_machine_code : Llvm.llvalue -> t -> unit
153
154154
155155 (** [target_data ee] is the target data owned by the execution engine
156156 [ee]. *)
157 external target_data : t -> Llvm_target.TargetData.t
158 = "LLVMGetExecutionEngineTargetData"
157 val target_data : t -> Llvm_target.TargetData.t
158
159159 end
160160
161 external initialize_native_target : unit -> bool
162 = "llvm_initialize_native_target"
161 val initialize_native_target : unit -> bool
162
211211
212212 (** [create_context ()] creates a context for storing the "global" state in
213213 LLVM. See the constructor [llvm::LLVMContext]. *)
214 external create_context : unit -> llcontext = "llvm_create_context"
214 val create_context : unit -> llcontext
215215
216216 (** [destroy_context ()] destroys a context. See the destructor
217217 [llvm::LLVMContext::~LLVMContext]. *)
218 external dispose_context : llcontext -> unit = "llvm_dispose_context"
218 val dispose_context : llcontext -> unit
219219
220220 (** See the function [llvm::getGlobalContext]. *)
221 external global_context : unit -> llcontext = "llvm_global_context"
221 val global_context : unit -> llcontext
222222
223223 (** [mdkind_id context name] returns the MDKind ID that corresponds to the
224224 name [name] in the context [context]. See the function
225225 [llvm::LLVMContext::getMDKindID]. *)
226 external mdkind_id : llcontext -> string -> int = "llvm_mdkind_id"
226 val mdkind_id : llcontext -> string -> int
227227
228228
229229 (** {6 Modules} *)
232232 the context [context]. Modules are not garbage collected; it is mandatory
233233 to call {!dispose_module} to free memory. See the constructor
234234 [llvm::Module::Module]. *)
235 external create_module : llcontext -> string -> llmodule = "llvm_create_module"
235 val create_module : llcontext -> string -> llmodule
236236
237237 (** [dispose_module m] destroys a module [m] and all of the IR objects it
238238 contained. All references to subordinate objects are invalidated;
239239 referencing them will invoke undefined behavior. See the destructor
240240 [llvm::Module::~Module]. *)
241 external dispose_module : llmodule -> unit = "llvm_dispose_module"
241 val dispose_module : llmodule -> unit
242242
243243 (** [target_triple m] is the target specifier for the module [m], something like
244244 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
245 external target_triple: llmodule -> string
246 = "llvm_target_triple"
245 val target_triple: llmodule -> string
246
247247
248248 (** [target_triple triple m] changes the target specifier for the module [m] to
249249 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
250 external set_target_triple: string -> llmodule -> unit
251 = "llvm_set_target_triple"
250 val set_target_triple: string -> llmodule -> unit
251
252252
253253 (** [data_layout m] is the data layout specifier for the module [m], something
254254 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
255255 method [llvm::Module::getDataLayout]. *)
256 external data_layout: llmodule -> string
257 = "llvm_data_layout"
256 val data_layout: llmodule -> string
257
258258
259259 (** [set_data_layout s m] changes the data layout specifier for the module [m]
260260 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
261 external set_data_layout: string -> llmodule -> unit
262 = "llvm_set_data_layout"
261 val set_data_layout: string -> llmodule -> unit
262
263263
264264 (** [define_type_name name ty m] adds a named type to the module's symbol table.
265265 Returns [true] if successful. If such a name already exists, then no entry
266266 is added and [false] is returned. See the [llvm::Module::addTypeName]
267267 method. *)
268 external define_type_name : string -> lltype -> llmodule -> bool
269 = "llvm_add_type_name"
268 val define_type_name : string -> lltype -> llmodule -> bool
269
270270
271271 (** [delete_type_name name] removes a type name from the module's symbol
272272 table. *)
273 external delete_type_name : string -> llmodule -> unit
274 = "llvm_delete_type_name"
273 val delete_type_name : string -> llmodule -> unit
274
275275
276276 (** [type_by_name m n] returns the type in the module [m] named [n], or [None]
277277 if it does not exist. See the method [llvm::Module::getTypeByName]. *)
278 external type_by_name : llmodule -> string -> lltype option
279 = "llvm_type_by_name"
278 val type_by_name : llmodule -> string -> lltype option
279
280280
281281 (** [dump_module m] prints the .ll representation of the module [m] to standard
282282 error. See the method [llvm::Module::dump]. *)
283 external dump_module : llmodule -> unit = "llvm_dump_module"
283 val dump_module : llmodule -> unit
284284
285285 (** [set_module_inline_asm m asm] sets the inline assembler for the module. See
286286 the method [llvm::Module::setModuleInlineAsm]. *)
287 external set_module_inline_asm : llmodule -> string -> unit
288 = "llvm_set_module_inline_asm"
287 val set_module_inline_asm : llmodule -> string -> unit
288
289289
290290
291291 (** {6 Types} *)
292292
293293 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
294294 See the method [llvm::Type::getTypeID]. *)
295 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
295 val classify_type : lltype -> TypeKind.t
296296
297297 (** [type_context ty] returns the {!llcontext} corresponding to the type [ty].
298298 See the method [llvm::Type::getContext]. *)
299 external type_context : lltype -> llcontext = "llvm_type_context"
299 val type_context : lltype -> llcontext
300300
301301 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
302302 val string_of_lltype : lltype -> string
305305
306306 (** [i1_type c] returns an integer type of bitwidth 1 in the context [c]. See
307307 [llvm::Type::Int1Ty]. *)
308 external i1_type : llcontext -> lltype = "llvm_i1_type"
308 val i1_type : llcontext -> lltype
309309
310310 (** [i8_type c] returns an integer type of bitwidth 8 in the context [c]. See
311311 [llvm::Type::Int8Ty]. *)
312 external i8_type : llcontext -> lltype = "llvm_i8_type"
312 val i8_type : llcontext -> lltype
313313
314314 (** [i16_type c] returns an integer type of bitwidth 16 in the context [c]. See
315315 [llvm::Type::Int16Ty]. *)
316 external i16_type : llcontext -> lltype = "llvm_i16_type"
316 val i16_type : llcontext -> lltype
317317
318318 (** [i32_type c] returns an integer type of bitwidth 32 in the context [c]. See
319319 [llvm::Type::Int32Ty]. *)
320 external i32_type : llcontext -> lltype = "llvm_i32_type"
320 val i32_type : llcontext -> lltype
321321
322322 (** [i64_type c] returns an integer type of bitwidth 64 in the context [c]. See
323323 [llvm::Type::Int64Ty]. *)
324 external i64_type : llcontext -> lltype = "llvm_i64_type"
324 val i64_type : llcontext -> lltype
325325
326326 (** [integer_type c n] returns an integer type of bitwidth [n] in the context
327327 [c]. See the method [llvm::IntegerType::get]. *)
328 external integer_type : llcontext -> int -> lltype = "llvm_integer_type"
328 val integer_type : llcontext -> int -> lltype
329329
330330 (** [integer_bitwidth c ty] returns the number of bits in the integer type [ty]
331331 in the context [c]. See the method [llvm::IntegerType::getBitWidth]. *)
332 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
332 val integer_bitwidth : lltype -> int
333333
334334
335335 (** {7 Operations on real types} *)
336336
337337 (** [float_type c] returns the IEEE 32-bit floating point type in the context
338338 [c]. See [llvm::Type::FloatTy]. *)
339 external float_type : llcontext -> lltype = "llvm_float_type"
339 val float_type : llcontext -> lltype
340340
341341 (** [double_type c] returns the IEEE 64-bit floating point type in the context
342342 [c]. See [llvm::Type::DoubleTy]. *)
343 external double_type : llcontext -> lltype = "llvm_double_type"
343 val double_type : llcontext -> lltype
344344
345345 (** [x86fp80_type c] returns the x87 80-bit floating point type in the context
346346 [c]. See [llvm::Type::X86_FP80Ty]. *)
347 external x86fp80_type : llcontext -> lltype = "llvm_x86fp80_type"
347 val x86fp80_type : llcontext -> lltype
348348
349349 (** [fp128_type c] returns the IEEE 128-bit floating point type in the context
350350 [c]. See [llvm::Type::FP128Ty]. *)
351 external fp128_type : llcontext -> lltype = "llvm_fp128_type"
351 val fp128_type : llcontext -> lltype
352352
353353 (** [ppc_fp128_type c] returns the PowerPC 128-bit floating point type in the
354354 context [c]. See [llvm::Type::PPC_FP128Ty]. *)
355 external ppc_fp128_type : llcontext -> lltype = "llvm_ppc_fp128_type"
355 val ppc_fp128_type : llcontext -> lltype
356356
357357
358358 (** {7 Operations on function types} *)
360360 (** [function_type ret_ty param_tys] returns the function type returning
361361 [ret_ty] and taking [param_tys] as parameters.
362362 See the method [llvm::FunctionType::get]. *)
363 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
363 val function_type : lltype -> lltype array -> lltype
364364
365365 (** [va_arg_function_type ret_ty param_tys] is just like
366366 [function_type ret_ty param_tys] except that it returns the function type
367367 which also takes a variable number of arguments.
368368 See the method [llvm::FunctionType::get]. *)
369 external var_arg_function_type : lltype -> lltype array -> lltype
370 = "llvm_var_arg_function_type"
369 val var_arg_function_type : lltype -> lltype array -> lltype
370
371371
372372 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
373373 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
374 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
374 val is_var_arg : lltype -> bool
375375
376376 (** [return_type fty] gets the return type of the function type [fty].
377377 See the method [llvm::FunctionType::getReturnType]. *)
378 external return_type : lltype -> lltype = "LLVMGetReturnType"
378 val return_type : lltype -> lltype
379379
380380 (** [param_types fty] gets the parameter types of the function type [fty].
381381 See the method [llvm::FunctionType::getParamType]. *)
382 external param_types : lltype -> lltype array = "llvm_param_types"
382 val param_types : lltype -> lltype array
383383
384384
385385 (** {7 Operations on struct types} *)
387387 (** [struct_type context tys] returns the structure type in the context
388388 [context] containing in the types in the array [tys]. See the method
389389 [llvm::StructType::get]. *)
390 external struct_type : llcontext -> lltype array -> lltype
391 = "llvm_struct_type"
390 val struct_type : llcontext -> lltype array -> lltype
391
392392
393393 (** [packed_struct_type context ys] returns the packed structure type in the
394394 context [context] containing in the types in the array [tys]. See the method
395395 [llvm::StructType::get]. *)
396 external packed_struct_type : llcontext -> lltype array -> lltype
397 = "llvm_packed_struct_type"
396 val packed_struct_type : llcontext -> lltype array -> lltype
397
398398
399399 (** [struct_element_types sty] returns the constituent types of the struct type
400400 [sty]. See the method [llvm::StructType::getElementType]. *)
401 external struct_element_types : lltype -> lltype array
402 = "llvm_struct_element_types"
401 val struct_element_types : lltype -> lltype array
402
403403
404404 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
405405 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
406 external is_packed : lltype -> bool = "llvm_is_packed"
406 val is_packed : lltype -> bool
407407
408408
409409 (** {7 Operations on pointer, vector, and array types} *)
410410
411411 (** [array_type ty n] returns the array type containing [n] elements of type
412412 [ty]. See the method [llvm::ArrayType::get]. *)
413 external array_type : lltype -> int -> lltype = "llvm_array_type"
413 val array_type : lltype -> int -> lltype
414414
415415 (** [pointer_type ty] returns the pointer type referencing objects of type
416416 [ty] in the default address space (0).
417417 See the method [llvm::PointerType::getUnqual]. *)
418 external pointer_type : lltype -> lltype = "llvm_pointer_type"
418 val pointer_type : lltype -> lltype
419419
420420 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
421421 of type [ty] in address space [as].
422422 See the method [llvm::PointerType::get]. *)
423 external qualified_pointer_type : lltype -> int -> lltype
424 = "llvm_qualified_pointer_type"
423 val qualified_pointer_type : lltype -> int -> lltype
424
425425
426426 (** [vector_type ty n] returns the array type containing [n] elements of the
427427 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
428 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
428 val vector_type : lltype -> int -> lltype
429429
430430 (** [element_type ty] returns the element type of the pointer, vector, or array
431431 type [ty]. See the method [llvm::SequentialType::get]. *)
432 external element_type : lltype -> lltype = "LLVMGetElementType"
432 val element_type : lltype -> lltype
433433
434434 (** [element_type aty] returns the element count of the array type [aty].
435435 See the method [llvm::ArrayType::getNumElements]. *)
436 external array_length : lltype -> int = "llvm_array_length"
436 val array_length : lltype -> int
437437
438438 (** [address_space pty] returns the address space qualifier of the pointer type
439439 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
440 external address_space : lltype -> int = "llvm_address_space"
440 val address_space : lltype -> int
441441
442442 (** [element_type ty] returns the element count of the vector type [ty].
443443 See the method [llvm::VectorType::getNumElements]. *)
444 external vector_size : lltype -> int = "llvm_vector_size"
444 val vector_size : lltype -> int
445445
446446
447447 (** {7 Operations on other types} *)
449449 (** [opaque_type c] creates a new opaque type distinct from any other in the
450450 context [c]. Opaque types are useful for building recursive types in
451451 combination with {!refine_type}. See [llvm::OpaqueType::get]. *)
452 external opaque_type : llcontext -> lltype = "llvm_opaque_type"
452 val opaque_type : llcontext -> lltype
453453
454454 (** [void_type c] creates a type of a function which does not return any
455455 value in the context [c]. See [llvm::Type::VoidTy]. *)
456 external void_type : llcontext -> lltype = "llvm_void_type"
456 val void_type : llcontext -> lltype
457457
458458 (** [label_type c] creates a type of a basic block in the context [c]. See
459459 [llvm::Type::LabelTy]. *)
460 external label_type : llcontext -> lltype = "llvm_label_type"
460 val label_type : llcontext -> lltype
461461
462462 (** {7 Operations on type handles} *)
463463
465465 refined as a result of a call to {!refine_type}, the handle will be updated;
466466 any bare [lltype] references will become invalid.
467467 See the class [llvm::PATypeHolder]. *)
468 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
468 val handle_to_type : lltype -> lltypehandle
469469
470470 (** [type_of_handle tyh] resolves the type handle [tyh].
471471 See the method [llvm::PATypeHolder::get()]. *)
472 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
472 val type_of_handle : lltypehandle -> lltype
473473
474474 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
475475 concrete type [ty] in all users. Warning: This may invalidate {!lltype}
476476 values! Use {!lltypehandle} to manipulate potentially abstract types. See
477477 the method [llvm::Type::refineAbstractType]. *)
478 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
478 val refine_type : lltype -> lltype -> unit
479479
480480
481481 (* {6 Values} *)
482482
483483 (** [type_of v] returns the type of the value [v].
484484 See the method [llvm::Value::getType]. *)
485 external type_of : llvalue -> lltype = "llvm_type_of"
485 val type_of : llvalue -> lltype
486486
487487 (** [value_name v] returns the name of the value [v]. For global values, this is
488488 the symbol name. For instructions and basic blocks, it is the SSA register
489489 name. It is meaningless for constants.
490490 See the method [llvm::Value::getName]. *)
491 external value_name : llvalue -> string = "llvm_value_name"
491 val value_name : llvalue -> string
492492
493493 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
494494 [llvm::Value::setName]. *)
495 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
495 val set_value_name : string -> llvalue -> unit
496496
497497 (** [dump_value v] prints the .ll representation of the value [v] to standard
498498 error. See the method [llvm::Value::dump]. *)
499 external dump_value : llvalue -> unit = "llvm_dump_value"
499 val dump_value : llvalue -> unit
500500
501501 (** [replace_all_uses_with old new] replaces all uses of the value [old]
502502 * with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
503 external replace_all_uses_with : llvalue -> llvalue -> unit
504 = "LLVMReplaceAllUsesWith"
503 val replace_all_uses_with : llvalue -> llvalue -> unit
504
505505
506506
507507 (* {6 Uses} *)
509509 (** [use_begin v] returns the first position in the use list for the value [v].
510510 [use_begin] and [use_succ] can e used to iterate over the use list in order.
511511 See the method [llvm::Value::use_begin]. *)
512 external use_begin : llvalue -> lluse option = "llvm_use_begin"
512 val use_begin : llvalue -> lluse option
513513
514514 (** [use_succ u] returns the use list position succeeding [u].
515515 See the method [llvm::use_value_iterator::operator++]. *)
516 external use_succ : lluse -> lluse option = "llvm_use_succ"
516 val use_succ : lluse -> lluse option
517517
518518 (** [user u] returns the user of the use [u].
519519 See the method [llvm::Use::getUser]. *)
520 external user : lluse -> llvalue = "llvm_user"
520 val user : lluse -> llvalue
521521
522522 (** [used_value u] returns the usee of the use [u].
523523 See the method [llvm::Use::getUsedValue]. *)
524 external used_value : lluse -> llvalue = "llvm_used_value"
524 val used_value : lluse -> llvalue
525525
526526 (** [iter_uses f v] applies function [f] to each of the users of the value [v]
527527 in order. Tail recursive. *)
540540
541541 (** [operand v i] returns the operand at index [i] for the value [v]. See the
542542 method [llvm::User::getOperand]. *)
543 external operand : llvalue -> int -> llvalue = "llvm_operand"
543 val operand : llvalue -> int -> llvalue
544544
545545 (** [set_operand v i o] sets the operand of the value [v] at the index [i] to
546546 the value [o].
547547 See the method [llvm::User::setOperand]. *)
548 external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
548 val set_operand : llvalue -> int -> llvalue -> unit
549549
550550 (** [num_operands v] returns the number of operands for the value [v].
551551 See the method [llvm::User::getNumOperands]. *)
552 external num_operands : llvalue -> int = "llvm_num_operands"
552 val num_operands : llvalue -> int
553553
554554 (** {7 Operations on constants of (mostly) any type} *)
555555
556556 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
557557 otherwise. Similar to [llvm::isa]. *)
558 external is_constant : llvalue -> bool = "llvm_is_constant"
558 val is_constant : llvalue -> bool
559559
560560 (** [const_null ty] returns the constant null (zero) of the type [ty].
561561 See the method [llvm::Constant::getNullValue]. *)
562 external const_null : lltype -> llvalue = "LLVMConstNull"
562 val const_null : lltype -> llvalue
563563
564564 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
565565 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
566 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
566 val const_all_ones : (*int|vec*)lltype -> llvalue
567567
568568 (** [const_pointer_null ty] returns the constant null (zero) pointer of the type
569569 [ty]. See the method [llvm::ConstantPointerNull::get]. *)
570 external const_pointer_null : lltype -> llvalue = "LLVMConstPointerNull"
570 val const_pointer_null : lltype -> llvalue
571571
572572 (** [undef ty] returns the undefined value of the type [ty].
573573 See the method [llvm::UndefValue::get]. *)
574 external undef : lltype -> llvalue = "LLVMGetUndef"
574 val undef : lltype -> llvalue
575575
576576 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
577577 See the method [llvm::Constant::isNullValue]. *)
578 external is_null : llvalue -> bool = "llvm_is_null"
578 val is_null : llvalue -> bool
579579
580580 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
581581 otherwise. Similar to [llvm::isa]. *)
582 external is_undef : llvalue -> bool = "llvm_is_undef"
582 val is_undef : llvalue -> bool
583583
584584
585585 (** {7 Operations on instructions} *)
587587 (** [has_metadata i] returns whether or not the instruction [i] has any
588588 metadata attached to it. See the function
589589 [llvm::Instruction::hasMetadata]. *)
590 external has_metadata : llvalue -> bool = "llvm_has_metadata"
590 val has_metadata : llvalue -> bool
591591
592592 (** [metadata i kind] optionally returns the metadata associated with the
593593 kind [kind] in the instruction [i] See the function
594594 [llvm::Instruction::getMetadata]. *)
595 external metadata : llvalue -> int -> llvalue option = "llvm_metadata"
595 val metadata : llvalue -> int -> llvalue option
596596
597597 (** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
598598 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
599 external set_metadata : llvalue -> int -> llvalue -> unit = "llvm_set_metadata"
599 val set_metadata : llvalue -> int -> llvalue -> unit
600600
601601 (** [clear_metadata i kind] clears the metadata of kind [kind] in the
602602 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
603 external clear_metadata : llvalue -> int -> unit = "llvm_clear_metadata"
603 val clear_metadata : llvalue -> int -> unit
604604
605605
606606 (** {7 Operations on metadata} *)
607607
608608 (** [mdstring c s] returns the MDString of the string [s] in the context [c].
609609 See the method [llvm::MDNode::get]. *)
610 external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"
610 val mdstring : llcontext -> string -> llvalue
611611
612612 (** [mdnode c elts] returns the MDNode containing the values [elts] in the
613613 context [c].
614614 See the method [llvm::MDNode::get]. *)
615 external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
615 val mdnode : llcontext -> llvalue array -> llvalue
616616
617617
618618 (** {7 Operations on scalar constants} *)
619619
620620 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
621621 See the method [llvm::ConstantInt::get]. *)
622 external const_int : lltype -> int -> llvalue = "llvm_const_int"
622 val const_int : lltype -> int -> llvalue
623623
624624 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
625625 [i]. See the method [llvm::ConstantInt::get]. *)
626 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
627 = "llvm_const_of_int64"
626 val const_of_int64 : lltype -> Int64.t -> bool -> llvalue
627
628628
629629 (** [const_int_of_string ty s r] returns the integer constant of type [ty] and
630630 * value [s], with the radix [r]. See the method [llvm::ConstantInt::get]. *)
631 external const_int_of_string : lltype -> string -> int -> llvalue
632 = "llvm_const_int_of_string"
631 val const_int_of_string : lltype -> string -> int -> llvalue
632
633633
634634 (** [const_float ty n] returns the floating point constant of type [ty] and
635635 value [n]. See the method [llvm::ConstantFP::get]. *)
636 external const_float : lltype -> float -> llvalue = "llvm_const_float"
636 val const_float : lltype -> float -> llvalue
637637
638638 (** [const_float_of_string ty s] returns the floating point constant of type
639639 [ty] and value [n]. See the method [llvm::ConstantFP::get]. *)
640 external const_float_of_string : lltype -> string -> llvalue
641 = "llvm_const_float_of_string"
640 val const_float_of_string : lltype -> string -> llvalue
641
642642
643643
644644 (** {7 Operations on composite constants} *)
648648 null-terminated (but see {!const_stringz}). This value can in turn be used
649649 as the initializer for a global variable. See the method
650650 [llvm::ConstantArray::get]. *)
651 external const_string : llcontext -> string -> llvalue = "llvm_const_string"
651 val const_string : llcontext -> string -> llvalue
652652
653653 (** [const_stringz c s] returns the constant [i8] array with the values of the
654654 characters in the string [s] and a null terminator in the context [c]. This
655655 value can in turn be used as the initializer for a global variable.
656656 See the method [llvm::ConstantArray::get]. *)
657 external const_stringz : llcontext -> string -> llvalue = "llvm_const_stringz"
657 val const_stringz : llcontext -> string -> llvalue
658658
659659 (** [const_array ty elts] returns the constant array of type
660660 [array_type ty (Array.length elts)] and containing the values [elts].
661661 This value can in turn be used as the initializer for a global variable.
662662 See the method [llvm::ConstantArray::get]. *)
663 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
663 val const_array : lltype -> llvalue array -> llvalue
664664
665665 (** [const_struct context elts] returns the structured constant of type
666666 [struct_type (Array.map type_of elts)] and containing the values [elts]
667667 in the context [context]. This value can in turn be used as the initializer
668668 for a global variable. See the method [llvm::ConstantStruct::get]. *)
669 external const_struct : llcontext -> llvalue array -> llvalue
670 = "llvm_const_struct"
669 val const_struct : llcontext -> llvalue array -> llvalue
670
671671
672672 (** [const_packed_struct context elts] returns the structured constant of
673673 type {!packed_struct_type} [(Array.map type_of elts)] and containing the
674674 values [elts] in the context [context]. This value can in turn be used as
675675 the initializer for a global variable. See the method
676676 [llvm::ConstantStruct::get]. *)
677 external const_packed_struct : llcontext -> llvalue array -> llvalue
678 = "llvm_const_packed_struct"
677 val const_packed_struct : llcontext -> llvalue array -> llvalue
678
679679
680680 (** [const_vector elts] returns the vector constant of type
681681 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
682682 values [elts]. See the method [llvm::ConstantVector::get]. *)
683 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
683 val const_vector : llvalue array -> llvalue
684684
685685
686686 (** {7 Constant expressions} *)
689689 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type {i8,ty}))
690690 (const_int i32_type 0) (const_int i32_type 1)) i32_type], but considerably
691691 more readable. See the method [llvm::ConstantExpr::getAlignOf]. *)
692 external align_of : lltype -> llvalue = "LLVMAlignOf"
692 val align_of : lltype -> llvalue
693693
694694 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
695695 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
696696 (const_int i32_type 1)) i64_type], but considerably more readable.
697697 See the method [llvm::ConstantExpr::getSizeOf]. *)
698 external size_of : lltype -> llvalue = "LLVMSizeOf"
698 val size_of : lltype -> llvalue
699699
700700 (** [const_neg c] returns the arithmetic negation of the constant [c].
701701 See the method [llvm::ConstantExpr::getNeg]. *)
702 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
702 val const_neg : llvalue -> llvalue
703703
704704 (** [const_nsw_neg c] returns the arithmetic negation of the constant [c] with
705705 no signed wrapping. The result is undefined if the negation overflows.
706706 See the method [llvm::ConstantExpr::getNSWNeg]. *)
707 external const_nsw_neg : llvalue -> llvalue = "LLVMConstNSWNeg"
707 val const_nsw_neg : llvalue -> llvalue
708708
709709 (** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
710710 no unsigned wrapping. The result is undefined if the negation overflows.
711711 See the method [llvm::ConstantExpr::getNUWNeg]. *)
712 external const_nuw_neg : llvalue -> llvalue = "LLVMConstNUWNeg"
712 val const_nuw_neg : llvalue -> llvalue
713713
714714 (** [const_fneg c] returns the arithmetic negation of the constant float [c].
715715 See the method [llvm::ConstantExpr::getFNeg]. *)
716 external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
716 val const_fneg : llvalue -> llvalue
717717
718718 (** [const_not c] returns the bitwise inverse of the constant [c].
719719 See the method [llvm::ConstantExpr::getNot]. *)
720 external const_not : llvalue -> llvalue = "LLVMConstNot"
720 val const_not : llvalue -> llvalue
721721
722722 (** [const_add c1 c2] returns the constant sum of two constants.
723723 See the method [llvm::ConstantExpr::getAdd]. *)
724 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
724 val const_add : llvalue -> llvalue -> llvalue
725725
726726 (** [const_nsw_add c1 c2] returns the constant sum of two constants with no
727727 signed wrapping. The result is undefined if the sum overflows.
728728 See the method [llvm::ConstantExpr::getNSWAdd]. *)
729 external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
729 val const_nsw_add : llvalue -> llvalue -> llvalue
730730
731731 (** [const_nuw_add c1 c2] returns the constant sum of two constants with no
732732 unsigned wrapping. The result is undefined if the sum overflows.
733733 See the method [llvm::ConstantExpr::getNSWAdd]. *)
734 external const_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
734 val const_nuw_add : llvalue -> llvalue -> llvalue
735735
736736 (** [const_fadd c1 c2] returns the constant sum of two constant floats.
737737 See the method [llvm::ConstantExpr::getFAdd]. *)
738 external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
738 val const_fadd : llvalue -> llvalue -> llvalue
739739
740740 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
741741 constants. See the method [llvm::ConstantExpr::getSub]. *)
742 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
742 val const_sub : llvalue -> llvalue -> llvalue
743743
744744 (** [const_nsw_sub c1 c2] returns the constant difference of two constants with
745745 no signed wrapping. The result is undefined if the sum overflows.
746746 See the method [llvm::ConstantExpr::getNSWSub]. *)
747 external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
747 val const_nsw_sub : llvalue -> llvalue -> llvalue
748748
749749 (** [const_nuw_sub c1 c2] returns the constant difference of two constants with
750750 no unsigned wrapping. The result is undefined if the sum overflows.
751751 See the method [llvm::ConstantExpr::getNSWSub]. *)
752 external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
752 val const_nuw_sub : llvalue -> llvalue -> llvalue
753753
754754 (** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
755755 constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
756 external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
756 val const_fsub : llvalue -> llvalue -> llvalue
757757
758758 (** [const_mul c1 c2] returns the constant product of two constants.
759759 See the method [llvm::ConstantExpr::getMul]. *)
760 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
760 val const_mul : llvalue -> llvalue -> llvalue
761761
762762 (** [const_nsw_mul c1 c2] returns the constant product of two constants with
763763 no signed wrapping. The result is undefined if the sum overflows.
764764 See the method [llvm::ConstantExpr::getNSWMul]. *)
765 external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
765 val const_nsw_mul : llvalue -> llvalue -> llvalue
766766
767767 (** [const_nuw_mul c1 c2] returns the constant product of two constants with
768768 no unsigned wrapping. The result is undefined if the sum overflows.
769769 See the method [llvm::ConstantExpr::getNSWMul]. *)
770 external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
770 val const_nuw_mul : llvalue -> llvalue -> llvalue
771771
772772 (** [const_fmul c1 c2] returns the constant product of two constants floats.
773773 See the method [llvm::ConstantExpr::getFMul]. *)
774 external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
774 val const_fmul : llvalue -> llvalue -> llvalue
775775
776776 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
777777 integer constants.
778778 See the method [llvm::ConstantExpr::getUDiv]. *)
779 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
779 val const_udiv : llvalue -> llvalue -> llvalue
780780
781781 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
782782 integer constants.
783783 See the method [llvm::ConstantExpr::getSDiv]. *)
784 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
784 val const_sdiv : llvalue -> llvalue -> llvalue
785785
786786 (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
787787 signed integer constants. The result is undefined if the result is rounded
788788 or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
789 external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
789 val const_exact_sdiv : llvalue -> llvalue -> llvalue
790790
791791 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
792792 point constants.
793793 See the method [llvm::ConstantExpr::getFDiv]. *)
794 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
794 val const_fdiv : llvalue -> llvalue -> llvalue
795795
796796 (** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
797797 unsigned integer constants.
798798 See the method [llvm::ConstantExpr::getURem]. *)
799 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
799 val const_urem : llvalue -> llvalue -> llvalue
800800
801801 (** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
802802 signed integer constants.
803803 See the method [llvm::ConstantExpr::getSRem]. *)
804 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
804 val const_srem : llvalue -> llvalue -> llvalue
805805
806806 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
807807 signed floating point constants.
808808 See the method [llvm::ConstantExpr::getFRem]. *)
809 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
809 val const_frem : llvalue -> llvalue -> llvalue
810810
811811 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
812812 constants.
813813 See the method [llvm::ConstantExpr::getAnd]. *)
814 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
814 val const_and : llvalue -> llvalue -> llvalue
815815
816816 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
817817 constants.
818818 See the method [llvm::ConstantExpr::getOr]. *)
819 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
819 val const_or : llvalue -> llvalue -> llvalue
820820
821821 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
822822 constants.
823823 See the method [llvm::ConstantExpr::getXor]. *)
824 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
824 val const_xor : llvalue -> llvalue -> llvalue
825825
826826 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
827827 constants, [c1 pred c2].
828828 See the method [llvm::ConstantExpr::getICmp]. *)
829 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
830 = "llvm_const_icmp"
829 val const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
830
831831
832832 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
833833 point constants, [c1 pred c2].
834834 See the method [llvm::ConstantExpr::getFCmp]. *)
835 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
836 = "llvm_const_fcmp"
835 val const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
836
837837
838838 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
839839 constant integer [c2].
840840 See the method [llvm::ConstantExpr::getShl]. *)
841 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
841 val const_shl : llvalue -> llvalue -> llvalue
842842
843843 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
844844 constant integer [c2] with zero extension.
845845 See the method [llvm::ConstantExpr::getLShr]. *)
846 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
846 val const_lshr : llvalue -> llvalue -> llvalue
847847
848848 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
849849 constant integer [c2] with sign extension.
850850 See the method [llvm::ConstantExpr::getAShr]. *)
851 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
851 val const_ashr : llvalue -> llvalue -> llvalue
852852
853853 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
854854 constant integers indices from the array [indices].
855855 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
856 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
856 val const_gep : llvalue -> llvalue array -> llvalue
857857
858858 (** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
859859 with the constant integers indices from the array [indices].
860860 See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
861 external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
862 = "llvm_const_in_bounds_gep"
861 val const_in_bounds_gep : llvalue -> llvalue array -> llvalue
862
863863
864864 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
865865 to the smaller integer type [ty].
866866 See the method [llvm::ConstantExpr::getTrunc]. *)
867 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
867 val const_trunc : llvalue -> lltype -> llvalue
868868
869869 (** [const_sext c ty] returns the constant sign extension of integer constant
870870 [c] to the larger integer type [ty].
871871 See the method [llvm::ConstantExpr::getSExt]. *)
872 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
872 val const_sext : llvalue -> lltype -> llvalue
873873
874874 (** [const_zext c ty] returns the constant zero extension of integer constant
875875 [c] to the larger integer type [ty].
876876 See the method [llvm::ConstantExpr::getZExt]. *)
877 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
877 val const_zext : llvalue -> lltype -> llvalue
878878
879879 (** [const_fptrunc c ty] returns the constant truncation of floating point
880880 constant [c] to the smaller floating point type [ty].
881881 See the method [llvm::ConstantExpr::getFPTrunc]. *)
882 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
882 val const_fptrunc : llvalue -> lltype -> llvalue
883883
884884 (** [const_fpext c ty] returns the constant extension of floating point constant
885885 [c] to the larger floating point type [ty].
886886 See the method [llvm::ConstantExpr::getFPExt]. *)
887 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
887 val const_fpext : llvalue -> lltype -> llvalue
888888
889889 (** [const_uitofp c ty] returns the constant floating point conversion of
890890 unsigned integer constant [c] to the floating point type [ty].
891891 See the method [llvm::ConstantExpr::getUIToFP]. *)
892 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
892 val const_uitofp : llvalue -> lltype -> llvalue
893893
894894 (** [const_sitofp c ty] returns the constant floating point conversion of
895895 signed integer constant [c] to the floating point type [ty].
896896 See the method [llvm::ConstantExpr::getSIToFP]. *)
897 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
897 val const_sitofp : llvalue -> lltype -> llvalue
898898
899899 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
900900 floating point constant [c] to integer type [ty].
901901 See the method [llvm::ConstantExpr::getFPToUI]. *)
902 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
902 val const_fptoui : llvalue -> lltype -> llvalue
903903
904904 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
905905 floating point constant [c] to integer type [ty].
906906 See the method [llvm::ConstantExpr::getFPToSI]. *)
907 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
907 val const_fptosi : llvalue -> lltype -> llvalue
908908
909909 (** [const_ptrtoint c ty] returns the constant integer conversion of
910910 pointer constant [c] to integer type [ty].
911911 See the method [llvm::ConstantExpr::getPtrToInt]. *)
912 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
912 val const_ptrtoint : llvalue -> lltype -> llvalue
913913
914914 (** [const_inttoptr c ty] returns the constant pointer conversion of
915915 integer constant [c] to pointer type [ty].
916916 See the method [llvm::ConstantExpr::getIntToPtr]. *)
917 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
917 val const_inttoptr : llvalue -> lltype -> llvalue
918918
919919 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
920920 to type [ty] of equal size.
921921 See the method [llvm::ConstantExpr::getBitCast]. *)
922 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
922 val const_bitcast : llvalue -> lltype -> llvalue
923923
924924 (** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
925925 conversion of constant [c] to type [ty].
926926 See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
927 external const_zext_or_bitcast : llvalue -> lltype -> llvalue
928 = "LLVMConstZExtOrBitCast"
927 val const_zext_or_bitcast : llvalue -> lltype -> llvalue
928
929929
930930 (** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
931931 conversion of constant [c] to type [ty].
932932 See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
933 external const_sext_or_bitcast : llvalue -> lltype -> llvalue
934 = "LLVMConstSExtOrBitCast"
933 val const_sext_or_bitcast : llvalue -> lltype -> llvalue
934
935935
936936 (** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
937937 conversion of constant [c] to type [ty].
938938 See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
939 external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
940 = "LLVMConstTruncOrBitCast"
939 val const_trunc_or_bitcast : llvalue -> lltype -> llvalue
940
941941
942942 (** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
943943 cast conversion of constant [c] to type [ty] of equal size.
944944 See the method [llvm::ConstantExpr::getPointerCast]. *)
945 external const_pointercast : llvalue -> lltype -> llvalue
946 = "LLVMConstPointerCast"
945 val const_pointercast : llvalue -> lltype -> llvalue
946
947947
948948 (** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
949949 -> integer casts of constant [c] to type [ty].
950950 See the method [llvm::ConstantExpr::getIntCast]. *)
951 external const_intcast : llvalue -> lltype -> llvalue
952 = "LLVMConstIntCast"
951 val const_intcast : llvalue -> lltype -> llvalue
952
953953
954954 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
955955 fp casts of constant [c] to type [ty].
956956 See the method [llvm::ConstantExpr::getFPCast]. *)
957 external const_fpcast : llvalue -> lltype -> llvalue
958 = "LLVMConstFPCast"
957 val const_fpcast : llvalue -> lltype -> llvalue
958
959959
960960 (** [const_select cond t f] returns the constant conditional which returns value
961961 [t] if the boolean constant [cond] is true and the value [f] otherwise.
962962 See the method [llvm::ConstantExpr::getSelect]. *)
963 external const_select : llvalue -> llvalue -> llvalue -> llvalue
964 = "LLVMConstSelect"
963 val const_select : llvalue -> llvalue -> llvalue -> llvalue
964
965965
966966 (** [const_extractelement vec i] returns the constant [i]th element of
967967 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
968968 the size of the vector.
969969 See the method [llvm::ConstantExpr::getExtractElement]. *)
970 external const_extractelement : llvalue -> llvalue -> llvalue
971 = "LLVMConstExtractElement"
970 val const_extractelement : llvalue -> llvalue -> llvalue
971
972972
973973 (** [const_insertelement vec v i] returns the constant vector with the same
974974 elements as constant vector [v] but the [i]th element replaced by the
976976 elements. [i] must be a constant [i32] value unsigned less than the size
977977 of the vector.
978978 See the method [llvm::ConstantExpr::getInsertElement]. *)
979 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
980 = "LLVMConstInsertElement"
979 val const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
980
981981
982982 (** [const_shufflevector a b mask] returns a constant [shufflevector].
983983 See the LLVM Language Reference for details on the [shufflevector]
984984 instruction.
985985 See the method [llvm::ConstantExpr::getShuffleVector]. *)
986 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
987 = "LLVMConstShuffleVector"
986 val const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
987
988988
989989 (** [const_extractvalue agg idxs] returns the constant [idxs]th value of
990990 constant aggregate [agg]. Each [idxs] must be less than the size of the
991991 aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
992 external const_extractvalue : llvalue -> int array -> llvalue
993 = "llvm_const_extractvalue"
992 val const_extractvalue : llvalue -> int array -> llvalue
993
994994
995995 (** [const_insertvalue agg val idxs] inserts the value [val] in the specified
996996 indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
997997 of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
998 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
999 = "llvm_const_insertvalue"
998 val const_insertvalue : llvalue -> llvalue -> int array -> llvalue
999
10001000
10011001 (** [const_inline_asm ty asm con side align] inserts a inline assembly string.
10021002 See the method [llvm::InlineAsm::get]. *)
1003 external const_inline_asm : lltype -> string -> string -> bool -> bool ->
1003 val const_inline_asm : lltype -> string -> string -> bool -> bool ->
10041004 llvalue
1005 = "llvm_const_inline_asm"
1005
10061006
10071007 (** [block_address f bb] returns the address of the basic block [bb] in the
10081008 function [f]. See the method [llvm::BasicBlock::get]. *)
1009 external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
1009 val block_address : llvalue -> llbasicblock -> llvalue
10101010
10111011
10121012 (** {7 Operations on global variables, functions, and aliases (globals)} *)
10131013
10141014 (** [global_parent g] is the enclosing module of the global value [g].
10151015 See the method [llvm::GlobalValue::getParent]. *)
1016 external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
1016 val global_parent : llvalue -> llmodule
10171017
10181018 (** [is_declaration g] returns [true] if the global value [g] is a declaration
10191019 only. Returns [false] otherwise.
10201020 See the method [llvm::GlobalValue::isDeclaration]. *)
1021 external is_declaration : llvalue -> bool = "llvm_is_declaration"
1021 val is_declaration : llvalue -> bool
10221022
10231023 (** [linkage g] returns the linkage of the global value [g].
10241024 See the method [llvm::GlobalValue::getLinkage]. *)
1025 external linkage : llvalue -> Linkage.t = "llvm_linkage"
1025 val linkage : llvalue -> Linkage.t
10261026
10271027 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
10281028 See the method [llvm::GlobalValue::setLinkage]. *)
1029 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
1029 val set_linkage : Linkage.t -> llvalue -> unit
10301030
10311031 (** [section g] returns the linker section of the global value [g].
10321032 See the method [llvm::GlobalValue::getSection]. *)
1033 external section : llvalue -> string = "llvm_section"
1033 val section : llvalue -> string
10341034
10351035 (** [set_section s g] sets the linker section of the global value [g] to [s].
10361036 See the method [llvm::GlobalValue::setSection]. *)
1037 external set_section : string -> llvalue -> unit = "llvm_set_section"
1037 val set_section : string -> llvalue -> unit
10381038
10391039 (** [visibility g] returns the linker visibility of the global value [g].
10401040 See the method [llvm::GlobalValue::getVisibility]. *)
1041 external visibility : llvalue -> Visibility.t = "llvm_visibility"
1041 val visibility : llvalue -> Visibility.t
10421042
10431043 (** [set_visibility v g] sets the linker visibility of the global value [g] to
10441044 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
1045 external set_visibility : Visibility.t -> llvalue -> unit
1046 = "llvm_set_visibility"
1045 val set_visibility : Visibility.t -> llvalue -> unit
1046
10471047
10481048 (** [alignment g] returns the required alignment of the global value [g].
10491049 See the method [llvm::GlobalValue::getAlignment]. *)
1050 external alignment : llvalue -> int = "llvm_alignment"
1050 val alignment : llvalue -> int
10511051
10521052 (** [set_alignment n g] sets the required alignment of the global value [g] to
10531053 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
1054 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
1054 val set_alignment : int -> llvalue -> unit
10551055
10561056
10571057 (** {7 Operations on global variables} *)
10601060 with name [name] in module [m] in the default address space (0). If such a
10611061 global variable already exists, it is returned. If the type of the existing
10621062 global differs, then a bitcast to [ty] is returned. *)
1063 external declare_global : lltype -> string -> llmodule -> llvalue
1064 = "llvm_declare_global"
1063 val declare_global : lltype -> string -> llmodule -> llvalue
1064
10651065
10661066 (** [declare_qualified_global ty name addrspace m] returns a new global variable
10671067 of type [ty] and with name [name] in module [m] in the address space
10681068 [addrspace]. If such a global variable already exists, it is returned. If
10691069 the type of the existing global differs, then a bitcast to [ty] is
10701070 returned. *)
1071 external declare_qualified_global : lltype -> string -> int -> llmodule ->
1071 val declare_qualified_global : lltype -> string -> int -> llmodule ->
10721072 llvalue
1073 = "llvm_declare_qualified_global"
1073
10741074
10751075 (** [define_global name init m] returns a new global with name [name] and
10761076 initializer [init] in module [m] in the default address space (0). If the
10771077 named global already exists, it is renamed.
10781078 See the constructor of [llvm::GlobalVariable]. *)
1079 external define_global : string -> llvalue -> llmodule -> llvalue
1080 = "llvm_define_global"
1079 val define_global : string -> llvalue -> llmodule -> llvalue
1080
10811081
10821082 (** [define_qualified_global name init addrspace m] returns a new global with
10831083 name [name] and initializer [init] in module [m] in the address space
10841084 [addrspace]. If the named global already exists, it is renamed.
10851085 See the constructor of [llvm::GlobalVariable]. *)
1086 external define_qualified_global : string -> llvalue -> int -> llmodule ->
1086 val define_qualified_global : string -> llvalue -> int -> llmodule ->
10871087 llvalue
1088 = "llvm_define_qualified_global"
1088
10891089
10901090 (** [lookup_global name m] returns [Some g] if a global variable with name
10911091 [name] exists in module [m]. If no such global exists, returns [None].
10921092 See the [llvm::GlobalVariable] constructor. *)
1093 external lookup_global : string -> llmodule -> llvalue option
1094 = "llvm_lookup_global"
1093 val lookup_global : string -> llmodule -> llvalue option
1094
10951095
10961096 (** [delete_global gv] destroys the global variable [gv].
10971097 See the method [llvm::GlobalVariable::eraseFromParent]. *)
1098 external delete_global : llvalue -> unit = "llvm_delete_global"
1098 val delete_global : llvalue -> unit
10991099
11001100 (** [global_begin m] returns the first position in the global variable list of
11011101 the module [m]. [global_begin] and [global_succ] can be used to iterate
11021102 over the global list in order.
11031103 See the method [llvm::Module::global_begin]. *)
1104 external global_begin : llmodule -> (llmodule, llvalue) llpos
1105 = "llvm_global_begin"
1104 val global_begin : llmodule -> (llmodule, llvalue) llpos
1105
11061106
11071107 (** [global_succ gv] returns the global variable list position succeeding
11081108 [Before gv].
11091109 See the method [llvm::Module::global_iterator::operator++]. *)
1110 external global_succ : llvalue -> (llmodule, llvalue) llpos
1111 = "llvm_global_succ"
1110 val global_succ : llvalue -> (llmodule, llvalue) llpos
1111
11121112
11131113 (** [iter_globals f m] applies function [f] to each of the global variables of
11141114 module [m] in order. Tail recursive. *)
11221122 module [m]. [global_end] and [global_pred] can be used to iterate over the
11231123 global list in reverse.
11241124 See the method [llvm::Module::global_end]. *)
1125 external global_end : llmodule -> (llmodule, llvalue) llrev_pos
1126 = "llvm_global_end"
1125 val global_end : llmodule -> (llmodule, llvalue) llrev_pos
1126
11271127
11281128 (** [global_pred gv] returns the global variable list position preceding
11291129 [After gv].
11301130 See the method [llvm::Module::global_iterator::operator--]. *)
1131 external global_pred : llvalue -> (llmodule, llvalue) llrev_pos
1132 = "llvm_global_pred"
1131 val global_pred : llvalue -> (llmodule, llvalue) llrev_pos
1132
11331133
11341134 (** [rev_iter_globals f m] applies function [f] to each of the global variables
11351135 of module [m] in reverse order. Tail recursive. *)
11421142 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
11431143 constant. Returns [false] otherwise.
11441144 See the method [llvm::GlobalVariable::isConstant]. *)
1145 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
1145 val is_global_constant : llvalue -> bool
11461146
11471147 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
11481148 [c] is [true] and not if [c] is [false].
11491149 See the method [llvm::GlobalVariable::setConstant]. *)
1150 external set_global_constant : bool -> llvalue -> unit
1151 = "llvm_set_global_constant"
1150 val set_global_constant : bool -> llvalue -> unit
1151
11521152
11531153 (** [global_initializer gv] returns the initializer for the global variable
11541154 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
1155 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
1155 val global_initializer : llvalue -> llvalue
11561156
11571157 (** [set_initializer c gv] sets the initializer for the global variable
11581158 [gv] to the constant [c].
11591159 See the method [llvm::GlobalVariable::setInitializer]. *)
1160 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
1160 val set_initializer : llvalue -> llvalue -> unit
11611161
11621162 (** [remove_initializer gv] unsets the initializer for the global variable
11631163 [gv].
11641164 See the method [llvm::GlobalVariable::setInitializer]. *)
1165 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
1165 val remove_initializer : llvalue -> unit
11661166
11671167 (** [is_thread_local gv] returns [true] if the global variable [gv] is
11681168 thread-local and [false] otherwise.
11691169 See the method [llvm::GlobalVariable::isThreadLocal]. *)
1170 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
1170 val is_thread_local : llvalue -> bool
11711171
11721172 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
11731173 [c] is [true] and not otherwise.
11741174 See the method [llvm::GlobalVariable::setThreadLocal]. *)
1175 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
1175 val set_thread_local : bool -> llvalue -> unit
11761176
11771177
11781178 (** {7 Operations on aliases} *)
11801180 (** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
11811181 the aliasee [a] with the name [n].
11821182 See the constructor for [llvm::GlobalAlias]. *)
1183 external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
1184 = "llvm_add_alias"
1183 val add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
1184
11851185
11861186
11871187 (** {7 Operations on functions} *)
11901190 with name [name] in module [m]. If such a function already exists,
11911191 it is returned. If the type of the existing function differs, then a bitcast
11921192 to [ty] is returned. *)
1193 external declare_function : string -> lltype -> llmodule -> llvalue
1194 = "llvm_declare_function"
1193 val declare_function : string -> lltype -> llmodule -> llvalue
1194
11951195
11961196 (** [define_function name ty m] creates a new function with name [name] and
11971197 type [ty] in module [m]. If the named function already exists, it is
11981198 renamed. An entry basic block is created in the function.
11991199 See the constructor of [llvm::GlobalVariable]. *)
1200 external define_function : string -> lltype -> llmodule -> llvalue
1201 = "llvm_define_function"
1200 val define_function : string -> lltype -> llmodule -> llvalue
1201
12021202
12031203 (** [lookup_function name m] returns [Some f] if a function with name
12041204 [name] exists in module [m]. If no such function exists, returns [None].
12051205 See the method [llvm::Module] constructor. *)
1206 external lookup_function : string -> llmodule -> llvalue option
1207 = "llvm_lookup_function"
1206 val lookup_function : string -> llmodule -> llvalue option
1207
12081208
12091209 (** [delete_function f] destroys the function [f].
12101210 See the method [llvm::Function::eraseFromParent]. *)
1211 external delete_function : llvalue -> unit = "llvm_delete_function"
1211 val delete_function : llvalue -> unit
12121212
12131213 (** [function_begin m] returns the first position in the function list of the
12141214 module [m]. [function_begin] and [function_succ] can be used to iterate over
12151215 the function list in order.
12161216 See the method [llvm::Module::begin]. *)
1217 external function_begin : llmodule -> (llmodule, llvalue) llpos
1218 = "llvm_function_begin"
1217 val function_begin : llmodule -> (llmodule, llvalue) llpos
1218
12191219
12201220 (** [function_succ gv] returns the function list position succeeding
12211221 [Before gv].
12221222 See the method [llvm::Module::iterator::operator++]. *)
1223 external function_succ : llvalue -> (llmodule, llvalue) llpos
1224 = "llvm_function_succ"
1223 val function_succ : llvalue -> (llmodule, llvalue) llpos
1224
12251225
12261226 (** [iter_functions f m] applies function [f] to each of the functions of module
12271227 [m] in order. Tail recursive. *)
12351235 the module [m]. [function_end] and [function_pred] can be used to iterate
12361236 over the function list in reverse.
12371237 See the method [llvm::Module::end]. *)
1238 external function_end : llmodule -> (llmodule, llvalue) llrev_pos
1239 = "llvm_function_end"
1238 val function_end : llmodule -> (llmodule, llvalue) llrev_pos
1239
12401240
12411241 (** [function_pred gv] returns the function list position preceding [After gv].
12421242 See the method [llvm::Module::iterator::operator--]. *)
1243 external function_pred : llvalue -> (llmodule, llvalue) llrev_pos
1244 = "llvm_function_pred"
1243 val function_pred : llvalue -> (llmodule, llvalue) llrev_pos
1244
12451245
12461246 (** [rev_iter_functions f fn] applies function [f] to each of the functions of
12471247 module [m] in reverse order. Tail recursive. *)
12531253
12541254 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
12551255 See the method [llvm::Function::isIntrinsic]. *)
1256 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
1256 val is_intrinsic : llvalue -> bool
12571257
12581258 (** [function_call_conv f] returns the calling convention of the function [f].
12591259 See the method [llvm::Function::getCallingConv]. *)
1260 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
1260 val function_call_conv : llvalue -> int
12611261
12621262 (** [set_function_call_conv cc f] sets the calling convention of the function
12631263 [f] to the calling convention numbered [cc].
12641264 See the method [llvm::Function::setCallingConv]. *)
1265 external set_function_call_conv : int -> llvalue -> unit
1266 = "llvm_set_function_call_conv"
1265 val set_function_call_conv : int -> llvalue -> unit
1266
12671267
12681268 (** [gc f] returns [Some name] if the function [f] has a garbage
12691269 collection algorithm specified and [None] otherwise.
12701270 See the method [llvm::Function::getGC]. *)
1271 external gc : llvalue -> string option = "llvm_gc"
1271 val gc : llvalue -> string option
12721272
12731273 (** [set_gc gc f] sets the collection algorithm for the function [f] to
12741274 [gc]. See the method [llvm::Function::setGC]. *)
1275 external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
1275 val set_gc : string option -> llvalue -> unit
12761276
12771277 (** [add_function_attr f a] adds attribute [a] to the return type of function
12781278 [f]. *)
12861286
12871287 (** [params f] returns the parameters of function [f].
12881288 See the method [llvm::Function::getArgumentList]. *)
1289 external params : llvalue -> llvalue array = "llvm_params"
1289 val params : llvalue -> llvalue array
12901290
12911291 (** [param f n] returns the [n]th parameter of function [f].
12921292 See the method [llvm::Function::getArgumentList]. *)
1293 external param : llvalue -> int -> llvalue = "llvm_param"
1293 val param : llvalue -> int -> llvalue
12941294
12951295 (** [param_parent p] returns the parent function that owns the parameter.
12961296 See the method [llvm::Argument::getParent]. *)
1297 external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
1297 val param_parent : llvalue -> llvalue
12981298
12991299 (** [param_begin f] returns the first position in the parameter list of the
13001300 function [f]. [param_begin] and [param_succ] can be used to iterate over
13011301 the parameter list in order.
13021302 See the method [llvm::Function::arg_begin]. *)
1303 external param_begin : llvalue -> (llvalue, llvalue) llpos = "llvm_param_begin"
1303 val param_begin : llvalue -> (llvalue, llvalue) llpos
13041304
13051305 (** [param_succ bb] returns the parameter list position succeeding
13061306 [Before bb].
13071307 See the method [llvm::Function::arg_iterator::operator++]. *)
1308 external param_succ : llvalue -> (llvalue, llvalue) llpos = "llvm_param_succ"
1308 val param_succ : llvalue -> (llvalue, llvalue) llpos
13091309
13101310 (** [iter_params f fn] applies function [f] to each of the parameters
13111311 of function [fn] in order. Tail recursive. *)
13191319 the function [f]. [param_end] and [param_pred] can be used to iterate
13201320 over the parameter list in reverse.
13211321 See the method [llvm::Function::arg_end]. *)
1322 external param_end : llvalue -> (llvalue, llvalue) llrev_pos = "llvm_param_end"
1322 val param_end : llvalue -> (llvalue, llvalue) llrev_pos
13231323
13241324 (** [param_pred gv] returns the function list position preceding [After gv].
13251325 See the method [llvm::Function::arg_iterator::operator--]. *)
1326 external param_pred : llvalue -> (llvalue, llvalue) llrev_pos
1327 = "llvm_param_pred"
1326 val param_pred : llvalue -> (llvalue, llvalue) llrev_pos
1327
13281328
13291329 (** [rev_iter_params f fn] applies function [f] to each of the parameters
13301330 of function [fn] in reverse order. Tail recursive. *)
13411341 val remove_param_attr : llvalue -> Attribute.t -> unit
13421342
13431343 (** [set_param_alignment p a] set the alignment of parameter [p] to [a]. *)
1344 external set_param_alignment : llvalue -> int -> unit
1345 = "llvm_set_param_alignment"
1344 val set_param_alignment : llvalue -> int -> unit
1345
13461346
13471347 (** {7 Operations on basic blocks} *)
13481348
13491349 (** [basic_blocks fn] returns the basic blocks of the function [f].
13501350 See the method [llvm::Function::getBasicBlockList]. *)
1351 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
1351 val basic_blocks : llvalue -> llbasicblock array
13521352
13531353 (** [entry_block fn] returns the entry basic block of the function [f].
13541354 See the method [llvm::Function::getEntryBlock]. *)
1355 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
1355 val entry_block : llvalue -> llbasicblock
13561356
13571357 (** [delete_block bb] deletes the basic block [bb].
13581358 See the method [llvm::BasicBlock::eraseFromParent]. *)
1359 external delete_block : llbasicblock -> unit = "llvm_delete_block"
1359 val delete_block : llbasicblock -> unit
13601360
13611361 (** [append_block c name f] creates a new basic block named [name] at the end of
13621362 function [f] in the context [c].
13631363 See the constructor of [llvm::BasicBlock]. *)
1364 external append_block : llcontext -> string -> llvalue -> llbasicblock
1365 = "llvm_append_block"
1364 val append_block : llcontext -> string -> llvalue -> llbasicblock
1365
13661366
13671367 (** [insert_block c name bb] creates a new basic block named [name] before the
13681368 basic block [bb] in the context [c].
13691369 See the constructor of [llvm::BasicBlock]. *)
1370 external insert_block : llcontext -> string -> llbasicblock -> llbasicblock
1371 = "llvm_insert_block"
1370 val insert_block : llcontext -> string -> llbasicblock -> llbasicblock
1371
13721372
13731373 (** [block_parent bb] returns the parent function that owns the basic block.
13741374 See the method [llvm::BasicBlock::getParent]. *)
1375 external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
1375 val block_parent : llbasicblock -> llvalue
13761376
13771377 (** [block_begin f] returns the first position in the basic block list of the
13781378 function [f]. [block_begin] and [block_succ] can be used to iterate over
13791379 the basic block list in order.
13801380 See the method [llvm::Function::begin]. *)
1381 external block_begin : llvalue -> (llvalue, llbasicblock) llpos
1382 = "llvm_block_begin"
1381 val block_begin : llvalue -> (llvalue, llbasicblock) llpos
1382
13831383
13841384 (** [block_succ bb] returns the basic block list position succeeding
13851385 [Before bb].
13861386 See the method [llvm::Function::iterator::operator++]. *)
1387 external block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
1388 = "llvm_block_succ"
1387 val block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
1388
13891389
13901390 (** [iter_blocks f fn] applies function [f] to each of the basic blocks
13911391 of function [fn] in order. Tail recursive. *)
13991399 the function [f]. [block_end] and [block_pred] can be used to iterate
14001400 over the basic block list in reverse.
14011401 See the method [llvm::Function::end]. *)
1402 external block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
1403 = "llvm_block_end"
1402 val block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
1403
14041404
14051405 (** [block_pred gv] returns the function list position preceding [After gv].
14061406 See the method [llvm::Function::iterator::operator--]. *)
1407 external block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
1408 = "llvm_block_pred"
1407 val block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
1408
14091409
14101410 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
14111411 of function [fn] in reverse order. Tail recursive. *)
14161416 val fold_right_blocks : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
14171417
14181418 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
1419 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
1419 val value_of_block : llbasicblock -> llvalue
14201420
14211421 (** [value_is_block v] returns [true] if the value [v] is a basic block and
14221422 [false] otherwise.
14231423 Similar to [llvm::isa]. *)
1424 external value_is_block : llvalue -> bool = "llvm_value_is_block"
1424 val value_is_block : llvalue -> bool
14251425
14261426 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
1427 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
1427 val block_of_value : llvalue -> llbasicblock
14281428
14291429
14301430 (** {7 Operations on instructions} *)
14311431
14321432 (** [instr_parent i] is the enclosing basic block of the instruction [i].
14331433 See the method [llvm::Instruction::getParent]. *)
1434 external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
1434 val instr_parent : llvalue -> llbasicblock
14351435
14361436 (** [instr_begin bb] returns the first position in the instruction list of the
14371437 basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
14381438 the instruction list in order.
14391439 See the method [llvm::BasicBlock::begin]. *)
1440 external instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
1441 = "llvm_instr_begin"
1440 val instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
1441
14421442
14431443 (** [instr_succ i] returns the instruction list position succeeding [Before i].
14441444 See the method [llvm::BasicBlock::iterator::operator++]. *)
1445 external instr_succ : llvalue -> (llbasicblock, llvalue) llpos
1446 = "llvm_instr_succ"
1445 val instr_succ : llvalue -> (llbasicblock, llvalue) llpos
1446
14471447
14481448 (** [iter_instrs f bb] applies function [f] to each of the instructions of basic
14491449 block [bb] in order. Tail recursive. *)
14571457 basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
14581458 the instruction list in reverse.
14591459 See the method [llvm::BasicBlock::end]. *)
1460 external instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
1461 = "llvm_instr_end"
1460 val instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
1461
14621462
14631463 (** [instr_pred i] returns the instruction list position preceding [After i].
14641464 See the method [llvm::BasicBlock::iterator::operator--]. *)
1465 external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
1466 = "llvm_instr_pred"
1465 val instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
1466
14671467
14681468 (** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
14691469 [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
14761476 instruction [ci], which may be one of the values from the module
14771477 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
14781478 [llvm::InvokeInst::getCallingConv]. *)
1479 external instruction_call_conv: llvalue -> int
1480 = "llvm_instruction_call_conv"
1479 val instruction_call_conv: llvalue -> int
1480
14811481
14821482 (** [set_instruction_call_conv cc ci] sets the calling convention for the call
14831483 or invoke instruction [ci] to the integer [cc], which can be one of the
14841484 values from the module {!CallConv}.
14851485 See the method [llvm::CallInst::setCallingConv]
14861486 and [llvm::InvokeInst::setCallingConv]. *)
1487 external set_instruction_call_conv: int -> llvalue -> unit
1488 = "llvm_set_instruction_call_conv"
1487 val set_instruction_call_conv: int -> llvalue -> unit
1488
14891489
14901490 (** [add_instruction_param_attr ci i a] adds attribute [a] to the [i]th
14911491 parameter of the call or invoke instruction [ci]. [i]=0 denotes the return
15021502 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
15031503 eligible for tail call optimization, [false] otherwise.
15041504 See the method [llvm::CallInst::isTailCall]. *)
1505 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
1505 val is_tail_call : llvalue -> bool
15061506
15071507 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
15081508 call optimization if [tc] is [true], clears otherwise.
15091509 See the method [llvm::CallInst::setTailCall]. *)
1510 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
1510 val set_tail_call : bool -> llvalue -> unit
15111511
15121512 (** {7 Operations on phi nodes} *)
15131513
15141514 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
15151515 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
1516 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
1517 = "llvm_add_incoming"
1516 val add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
1517
15181518
15191519 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
15201520 See the method [llvm::PHINode::getIncomingValue]. *)
1521 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
1521 val incoming : llvalue -> (llvalue * llbasicblock) list
15221522
15231523
15241524
15281528 the context [context]. It is invalid to use this builder until its position
15291529 is set with {!position_before} or {!position_at_end}. See the constructor
15301530 for [llvm::LLVMBuilder]. *)
1531 external builder : llcontext -> llbuilder = "llvm_builder"
1531 val builder : llcontext -> llbuilder
15321532
15331533 (** [builder_at ip] creates an instruction builder positioned at [ip].
15341534 See the constructor for [llvm::LLVMBuilder]. *)
15451545 (** [position_builder ip bb] moves the instruction builder [bb] to the position
15461546 [ip].
15471547 See the constructor for [llvm::LLVMBuilder]. *)
1548 external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
1549 = "llvm_position_builder"
1548 val position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
1549
15501550
15511551 (** [position_before ins b] moves the instruction builder [b] to before the
15521552 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
15601560 positioned to insert into. Raises [Not_Found] if the instruction builder is
15611561 uninitialized.
15621562 See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
1563 external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
1563 val insertion_block : llbuilder -> llbasicblock
15641564
15651565 (** [insert_into_builder i name b] inserts the specified instruction [i] at the
15661566 position specified by the instruction builder [b].
15671567 See the method [llvm::LLVMBuilder::Insert]. *)
1568 external insert_into_builder : llvalue -> string -> llbuilder -> unit
1569 = "llvm_insert_into_builder"
1568 val insert_into_builder : llvalue -> string -> llbuilder -> unit
1569
15701570
15711571 (** {7 Metadata} *)
15721572
15731573 (** [set_current_debug_location b md] sets the current debug location [md] in
15741574 the builder [b].
15751575 See the method [llvm::IRBuilder::SetDebugLocation]. *)
1576 external set_current_debug_location : llbuilder -> llvalue -> unit
1577 = "llvm_set_current_debug_location"
1576 val set_current_debug_location : llbuilder -> llvalue -> unit
1577
15781578
15791579 (** [clear_current_debug_location b] clears the current debug location in the
15801580 builder [b]. *)
1581 external clear_current_debug_location : llbuilder -> unit
1582 = "llvm_clear_current_debug_location"
1581 val clear_current_debug_location : llbuilder -> unit
1582
15831583
15841584 (** [current_debug_location b] returns the current debug location, or None
15851585 if none is currently set.
15861586 See the method [llvm::IRBuilder::GetDebugLocation]. *)
1587 external current_debug_location : llbuilder -> llvalue option
1588 = "llvm_current_debug_location"
1587 val current_debug_location : llbuilder -> llvalue option
1588
15891589
15901590 (** [set_inst_debug_location b i] sets the current debug location of the builder
15911591 [b] to the instruction [i].
15921592 See the method [llvm::IRBuilder::SetInstDebugLocation]. *)
1593 external set_inst_debug_location : llbuilder -> llvalue -> unit
1594 = "llvm_set_inst_debug_location"
1593 val set_inst_debug_location : llbuilder -> llvalue -> unit
1594
15951595
15961596 (** {7 Terminators} *)
15971597
15991599 [ret void]
16001600 instruction at the position specified by the instruction builder [b].
16011601 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
1602 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
1602 val build_ret_void : llbuilder -> llvalue
16031603
16041604 (** [build_ret v b] creates a
16051605 [ret %v]
16061606 instruction at the position specified by the instruction builder [b].
16071607 See the method [llvm::LLVMBuilder::CreateRet]. *)
1608 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
1608 val build_ret : llvalue -> llbuilder -> llvalue
16091609
16101610 (** [build_aggregate_ret vs b] creates a
16111611 [ret {...} { %v1, %v2, ... } ]
16121612 instruction at the position specified by the instruction builder [b].
16131613 See the method [llvm::LLVMBuilder::CreateAggregateRet]. *)
1614 external build_aggregate_ret : llvalue array -> llbuilder -> llvalue
1615 = "llvm_build_aggregate_ret"
1614 val build_aggregate_ret : llvalue array -> llbuilder -> llvalue
1615
16161616
16171617 (** [build_br bb b] creates a
16181618 [br %bb]
16191619 instruction at the position specified by the instruction builder [b].
16201620 See the method [llvm::LLVMBuilder::CreateBr]. *)
1621 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
1621 val build_br : llbasicblock -> llbuilder -> llvalue
16221622
16231623 (** [build_cond_br cond tbb fbb b] creates a
16241624 [br %cond, %tbb, %fbb]
16251625 instruction at the position specified by the instruction builder [b].
16261626 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
1627 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
1628 llvalue = "llvm_build_cond_br"
1627 val build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
1628 llvalue
16291629
16301630 (** [build_switch case elsebb count b] creates an empty
16311631 [switch %case, %elsebb]
16321632 instruction at the position specified by the instruction builder [b] with
16331633 space reserved for [count] cases.
16341634 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
1635 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
1636 = "llvm_build_switch"
1635 val build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
1636
16371637
16381638 (** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
16391639 when its input matches the constant [onval].
16401640 See the method [llvm::SwitchInst::addCase]. **)
1641 external add_case : llvalue -> llvalue -> llbasicblock -> unit
1642 = "llvm_add_case"
1641 val add_case : llvalue -> llvalue -> llbasicblock -> unit
1642
16431643
16441644 (** [build_indirect_br addr count b] creates a
16451645 [indirectbr %addr]
16461646 instruction at the position specified by the instruction builder [b] with
16471647 space reserved for [count] destinations.
16481648 See the method [llvm::LLVMBuilder::CreateIndirectBr]. *)
1649 external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
1650 = "llvm_build_indirect_br"
1649 val build_indirect_br : llvalue -> int -> llbuilder -> llvalue
1650
16511651
16521652 (** [add_destination br bb] adds the basic block [bb] as a possible branch
16531653 location for the indirectbr instruction [br].
16541654 See the method [llvm::IndirectBrInst::addDestination]. **)
1655 external add_destination : llvalue -> llbasicblock -> unit
1656 = "llvm_add_destination"
1655 val add_destination : llvalue -> llbasicblock -> unit
1656
16571657
16581658 (** [build_invoke fn args tobb unwindbb name b] creates an
16591659 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
16601660 instruction at the position specified by the instruction builder [b].
16611661 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
1662 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
1662 val build_invoke : llvalue -> llvalue array -> llbasicblock ->
16631663 llbasicblock -> string -> llbuilder -> llvalue
1664 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
1664
16651665
16661666 (** [build_unwind b] creates an
16671667 [unwind]
16681668 instruction at the position specified by the instruction builder [b].
16691669 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1670 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
1670 val build_unwind : llbuilder -> llvalue
16711671
16721672 (** [build_unreachable b] creates an
16731673 [unreachable]
16741674 instruction at the position specified by the instruction builder [b].
16751675 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1676 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
1676 val build_unreachable : llbuilder -> llvalue
16771677
16781678
16791679 (** {7 Arithmetic} *)
16821682 [%name = add %x, %y]
16831683 instruction at the position specified by the instruction builder [b].
16841684 See the method [llvm::LLVMBuilder::CreateAdd]. *)
1685 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1686 = "llvm_build_add"
1685 val build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1686
16871687
16881688 (** [build_nsw_add x y name b] creates a
16891689 [%name = nsw add %x, %y]
16901690 instruction at the position specified by the instruction builder [b].
16911691 See the method [llvm::LLVMBuilder::CreateNSWAdd]. *)
1692 external build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1693 = "llvm_build_nsw_add"
1692 val build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1693
16941694
16951695 (** [build_nuw_add x y name b] creates a
16961696 [%name = nuw add %x, %y]
16971697 instruction at the position specified by the instruction builder [b].
16981698 See the method [llvm::LLVMBuilder::CreateNUWAdd]. *)
1699 external build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1700 = "llvm_build_nuw_add"
1699 val build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1700
17011701
17021702 (** [build_fadd x y name b] creates a
17031703 [%name = fadd %x, %y]
17041704 instruction at the position specified by the instruction builder [b].
17051705 See the method [llvm::LLVMBuilder::CreateFAdd]. *)
1706 external build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
1707 = "llvm_build_fadd"
1706 val build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
1707
17081708
17091709 (** [build_sub x y name b] creates a
17101710 [%name = sub %x, %y]
17111711 instruction at the position specified by the instruction builder [b].
17121712 See the method [llvm::LLVMBuilder::CreateSub]. *)
1713 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1714 = "llvm_build_sub"
1713 val build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1714
17151715
17161716 (** [build_nsw_sub x y name b] creates a
17171717 [%name = nsw sub %x, %y]
17181718 instruction at the position specified by the instruction builder [b].
17191719 See the method [llvm::LLVMBuilder::CreateNSWSub]. *)
1720 external build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1721 = "llvm_build_nsw_sub"
1720 val build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1721
17221722
17231723 (** [build_nuw_sub x y name b] creates a
17241724 [%name = nuw sub %x, %y]
17251725 instruction at the position specified by the instruction builder [b].
17261726 See the method [llvm::LLVMBuilder::CreateNUWSub]. *)
1727 external build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1728 = "llvm_build_nuw_sub"
1727 val build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1728
17291729
17301730 (** [build_fsub x y name b] creates a
17311731 [%name = fsub %x, %y]
17321732 instruction at the position specified by the instruction builder [b].
17331733 See the method [llvm::LLVMBuilder::CreateFSub]. *)
1734 external build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1735 = "llvm_build_fsub"
1734 val build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1735
17361736
17371737 (** [build_mul x y name b] creates a
17381738 [%name = mul %x, %y]
17391739 instruction at the position specified by the instruction builder [b].
17401740 See the method [llvm::LLVMBuilder::CreateMul]. *)
1741 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1742 = "llvm_build_mul"
1741 val build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1742
17431743
17441744 (** [build_nsw_mul x y name b] creates a
17451745 [%name = nsw mul %x, %y]
17461746 instruction at the position specified by the instruction builder [b].
17471747 See the method [llvm::LLVMBuilder::CreateNSWMul]. *)
1748 external build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1749 = "llvm_build_nsw_mul"
1748 val build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1749
17501750
17511751 (** [build_nuw_mul x y name b] creates a
17521752 [%name = nuw mul %x, %y]
17531753 instruction at the position specified by the instruction builder [b].
17541754 See the method [llvm::LLVMBuilder::CreateNUWMul]. *)
1755 external build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1756 = "llvm_build_nuw_mul"
1755 val build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1756
17571757
17581758 (** [build_fmul x y name b] creates a
17591759 [%name = fmul %x, %y]
17601760 instruction at the position specified by the instruction builder [b].
17611761 See the method [llvm::LLVMBuilder::CreateFMul]. *)
1762 external build_fmul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1763 = "llvm_build_fmul"
1762 val build_fmul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1763
17641764
17651765 (** [build_udiv x y name b] creates a
17661766 [%name = udiv %x, %y]
17671767 instruction at the position specified by the instruction builder [b].
17681768 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
1769 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1770 = "llvm_build_udiv"
1769 val build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1770
17711771
17721772 (** [build_sdiv x y name b] creates a
17731773 [%name = sdiv %x, %y]
17741774 instruction at the position specified by the instruction builder [b].
17751775 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
1776 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1777 = "llvm_build_sdiv"
1776 val build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1777
17781778
17791779 (** [build_exact_sdiv x y name b] creates a
17801780 [%name = exact sdiv %x, %y]
17811781 instruction at the position specified by the instruction builder [b].
17821782 See the method [llvm::LLVMBuilder::CreateExactSDiv]. *)
1783 external build_exact_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1784 = "llvm_build_exact_sdiv"
1783 val build_exact_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1784
17851785
17861786 (** [build_fdiv x y name b] creates a
17871787 [%name = fdiv %x, %y]
17881788 instruction at the position specified by the instruction builder [b].
17891789 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
1790 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1791 = "llvm_build_fdiv"
1790 val build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1791
17921792
17931793 (** [build_urem x y name b] creates a
17941794 [%name = urem %x, %y]
17951795 instruction at the position specified by the instruction builder [b].
17961796 See the method [llvm::LLVMBuilder::CreateURem]. *)
1797 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1798 = "llvm_build_urem"
1797 val build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1798
17991799
18001800 (** [build_SRem x y name b] creates a
18011801 [%name = srem %x, %y]
18021802 instruction at the position specified by the instruction builder [b].
18031803 See the method [llvm::LLVMBuilder::CreateSRem]. *)
1804 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1805 = "llvm_build_srem"
1804 val build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1805
18061806
18071807 (** [build_frem x y name b] creates a
18081808 [%name = frem %x, %y]
18091809 instruction at the position specified by the instruction builder [b].
18101810 See the method [llvm::LLVMBuilder::CreateFRem]. *)
1811 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1812 = "llvm_build_frem"
1811 val build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1812
18131813
18141814 (** [build_shl x y name b] creates a
18151815 [%name = shl %x, %y]
18161816 instruction at the position specified by the instruction builder [b].
18171817 See the method [llvm::LLVMBuilder::CreateShl]. *)
1818 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1819 = "llvm_build_shl"
1818 val build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1819
18201820
18211821 (** [build_lshr x y name b] creates a
18221822 [%name = lshr %x, %y]
18231823 instruction at the position specified by the instruction builder [b].
18241824 See the method [llvm::LLVMBuilder::CreateLShr]. *)
1825 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1826 = "llvm_build_lshr"
1825 val build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1826
18271827
18281828 (** [build_ashr x y name b] creates a
18291829 [%name = ashr %x, %y]
18301830 instruction at the position specified by the instruction builder [b].
18311831 See the method [llvm::LLVMBuilder::CreateAShr]. *)
1832 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1833 = "llvm_build_ashr"
1832 val build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1833
18341834
18351835 (** [build_and x y name b] creates a
18361836 [%name = and %x, %y]
18371837 instruction at the position specified by the instruction builder [b].
18381838 See the method [llvm::LLVMBuilder::CreateAnd]. *)
1839 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1840 = "llvm_build_and"
1839 val build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1840
18411841
18421842 (** [build_or x y name b] creates a
18431843 [%name = or %x, %y]
18441844 instruction at the position specified by the instruction builder [b].
18451845 See the method [llvm::LLVMBuilder::CreateOr]. *)
1846 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1847 = "llvm_build_or"
1846 val build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1847
18481848
18491849 (** [build_xor x y name b] creates a
18501850 [%name = xor %x, %y]
18511851 instruction at the position specified by the instruction builder [b].
18521852 See the method [llvm::LLVMBuilder::CreateXor]. *)
1853 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1854 = "llvm_build_xor"
1853 val build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1854
18551855
18561856 (** [build_neg x name b] creates a
18571857 [%name = sub 0, %x]
18581858 instruction at the position specified by the instruction builder [b].
18591859 [-0.0] is used for floating point types to compute the correct sign.
18601860 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1861 external build_neg : llvalue -> string -> llbuilder -> llvalue
1862 = "llvm_build_neg"
1861 val build_neg : llvalue -> string -> llbuilder -> llvalue
1862
18631863
18641864 (** [build_nsw_neg x name b] creates a
18651865 [%name = nsw sub 0, %x]
18661866 instruction at the position specified by the instruction builder [b].
18671867 [-0.0] is used for floating point types to compute the correct sign.
18681868 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1869 external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
1870 = "llvm_build_nsw_neg"
1869 val build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
1870
18711871
18721872 (** [build_nuw_neg x name b] creates a
18731873 [%name = nuw sub 0, %x]
18741874 instruction at the position specified by the instruction builder [b].
18751875 [-0.0] is used for floating point types to compute the correct sign.
18761876 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1877 external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
1878 = "llvm_build_nuw_neg"
1877 val build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
1878
18791879
18801880 (** [build_fneg x name b] creates a
18811881 [%name = fsub 0, %x]
18821882 instruction at the position specified by the instruction builder [b].
18831883 [-0.0] is used for floating point types to compute the correct sign.
18841884 See the method [llvm::LLVMBuilder::CreateFNeg]. *)
1885 external build_fneg : llvalue -> string -> llbuilder -> llvalue
1886 = "llvm_build_fneg"
1885 val build_fneg : llvalue -> string -> llbuilder -> llvalue
1886
18871887
18881888 (** [build_xor x name b] creates a
18891889 [%name = xor %x, -1]
18901890 instruction at the position specified by the instruction builder [b].
18911891 [-1] is the correct "all ones" value for the type of [x].
18921892 See the method [llvm::LLVMBuilder::CreateXor]. *)
1893 external build_not : llvalue -> string -> llbuilder -> llvalue
1894 = "llvm_build_not"
1893 val build_not : llvalue -> string -> llbuilder -> llvalue
1894
18951895
18961896
18971897 (** {7 Memory} *)
19001900 [%name = alloca %ty]
19011901 instruction at the position specified by the instruction builder [b].
19021902 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1903 external build_alloca : lltype -> string -> llbuilder -> llvalue
1904 = "llvm_build_alloca"
1903 val build_alloca : lltype -> string -> llbuilder -> llvalue
1904
19051905
19061906 (** [build_array_alloca ty n name b] creates a
19071907 [%name = alloca %ty, %n]
19081908 instruction at the position specified by the instruction builder [b].
19091909 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1910 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1911 llvalue = "llvm_build_array_alloca"
1910 val build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1911 llvalue
19121912
19131913 (** [build_load v name b] creates a
19141914 [%name = load %v]
19151915 instruction at the position specified by the instruction builder [b].
19161916 See the method [llvm::LLVMBuilder::CreateLoad]. *)
1917 external build_load : llvalue -> string -> llbuilder -> llvalue
1918 = "llvm_build_load"
1917 val build_load : llvalue -> string -> llbuilder -> llvalue
1918
19191919
19201920 (** [build_store v p b] creates a
19211921 [store %v, %p]
19221922 instruction at the position specified by the instruction builder [b].
19231923 See the method [llvm::LLVMBuilder::CreateStore]. *)
1924 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1925 = "llvm_build_store"
1924 val build_store : llvalue -> llvalue -> llbuilder -> llvalue
1925
19261926
19271927 (** [build_gep p indices name b] creates a
19281928 [%name = getelementptr %p, indices...]
19291929 instruction at the position specified by the instruction builder [b].
19301930 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
1931 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1932 = "llvm_build_gep"
1931 val build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1932
19331933
19341934 (** [build_in_bounds_gep p indices name b] creates a
19351935 [%name = gelementptr inbounds %p, indices...]
19361936 instruction at the position specified by the instruction builder [b].
19371937 See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
1938 external build_in_bounds_gep : llvalue -> llvalue array -> string -> llbuilder ->
1939 llvalue = "llvm_build_in_bounds_gep"
1938 val build_in_bounds_gep : llvalue -> llvalue array -> string -> llbuilder ->
1939 llvalue
19401940
19411941 (** [build_struct_gep p idx name b] creates a
19421942 [%name = getelementptr %p, 0, idx]
19431943 instruction at the position specified by the instruction builder [b].
19441944 See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
1945 external build_struct_gep : llvalue -> int -> string -> llbuilder ->
1946 llvalue = "llvm_build_struct_gep"
1945 val build_struct_gep : llvalue -> int -> string -> llbuilder ->
1946 llvalue
19471947
19481948 (** [build_global_string str name b] creates a series of instructions that adds
19491949 a global string at the position specified by the instruction builder [b].
19501950 See the method [llvm::LLVMBuilder::CreateGlobalString]. *)
1951 external build_global_string : string -> string -> llbuilder -> llvalue
1952 = "llvm_build_global_string"
1951 val build_global_string : string -> string -> llbuilder -> llvalue
1952
19531953
19541954 (** [build_global_stringptr str name b] creates a series of instructions that
19551955 adds a global string pointer at the position specified by the instruction
19561956 builder [b].
19571957 See the method [llvm::LLVMBuilder::CreateGlobalStringPtr]. *)
1958 external build_global_stringptr : string -> string -> llbuilder -> llvalue
1959 = "llvm_build_global_stringptr"
1958 val build_global_stringptr : string -> string -> llbuilder -> llvalue
1959
19601960
19611961
19621962 (** {7 Casts} *)
19651965 [%name = trunc %p to %ty]
19661966 instruction at the position specified by the instruction builder [b].
19671967 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
1968 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1969 = "llvm_build_trunc"
1968 val build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1969
19701970
19711971 (** [build_zext v ty name b] creates a
19721972 [%name = zext %p to %ty]
19731973 instruction at the position specified by the instruction builder [b].
19741974 See the method [llvm::LLVMBuilder::CreateZExt]. *)
1975 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1976 = "llvm_build_zext"
1975 val build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1976
19771977
19781978 (** [build_sext v ty name b] creates a
19791979 [%name = sext %p to %ty]
19801980 instruction at the position specified by the instruction builder [b].
19811981 See the method [llvm::LLVMBuilder::CreateSExt]. *)
1982 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1983 = "llvm_build_sext"
1982 val build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1983
19841984
19851985 (** [build_fptoui v ty name b] creates a
19861986 [%name = fptoui %p to %ty]
19871987 instruction at the position specified by the instruction builder [b].
19881988 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
1989 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1990 = "llvm_build_fptoui"
1989 val build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1990
19911991
19921992 (** [build_fptosi v ty name b] creates a
19931993 [%name = fptosi %p to %ty]
19941994 instruction at the position specified by the instruction builder [b].
19951995 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
1996 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1997 = "llvm_build_fptosi"
1996 val build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1997
19981998
19991999 (** [build_uitofp v ty name b] creates a
20002000 [%name = uitofp %p to %ty]
20012001 instruction at the position specified by the instruction builder [b].
20022002 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
2003 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2004 = "llvm_build_uitofp"
2003 val build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2004
20052005
20062006 (** [build_sitofp v ty name b] creates a
20072007 [%name = sitofp %p to %ty]
20082008 instruction at the position specified by the instruction builder [b].
20092009 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
2010 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2011 = "llvm_build_sitofp"
2010 val build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2011
20122012
20132013 (** [build_fptrunc v ty name b] creates a
20142014 [%name = fptrunc %p to %ty]
20152015 instruction at the position specified by the instruction builder [b].
20162016 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
2017 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
2018 = "llvm_build_fptrunc"
2017 val build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
2018
20192019
20202020 (** [build_fpext v ty name b] creates a
20212021 [%name = fpext %p to %ty]
20222022 instruction at the position specified by the instruction builder [b].
20232023 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
2024 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
2025 = "llvm_build_fpext"
2024 val build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
2025
20262026
20272027 (** [build_ptrtoint v ty name b] creates a
20282028 [%name = prtotint %p to %ty]
20292029 instruction at the position specified by the instruction builder [b].
20302030 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
2031 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
2032 = "llvm_build_prttoint"
2031 val build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
2032
20332033
20342034 (** [build_inttoptr v ty name b] creates a
20352035 [%name = inttoptr %p to %ty]
20362036 instruction at the position specified by the instruction builder [b].
20372037 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
2038 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
2039 = "llvm_build_inttoptr"
2038 val build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
2039
20402040
20412041 (** [build_bitcast v ty name b] creates a
20422042 [%name = bitcast %p to %ty]
20432043 instruction at the position specified by the instruction builder [b].
20442044 See the method [llvm::LLVMBuilder::CreateBitCast]. *)
2045 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2046 = "llvm_build_bitcast"
2045 val build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2046
20472047
20482048 (** [build_zext_or_bitcast v ty name b] creates a zext or bitcast
20492049 instruction at the position specified by the instruction builder [b].
20502050 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2051 external build_zext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2052 llvalue = "llvm_build_zext_or_bitcast"
2051 val build_zext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2052 llvalue
20532053
20542054 (** [build_sext_or_bitcast v ty name b] creates a sext or bitcast
20552055 instruction at the position specified by the instruction builder [b].
20562056 See the method [llvm::LLVMBuilder::CreateSExtOrBitCast]. *)
2057 external build_sext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2058 llvalue = "llvm_build_sext_or_bitcast"
2057 val build_sext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2058 llvalue
20592059
20602060 (** [build_trunc_or_bitcast v ty name b] creates a trunc or bitcast
20612061 instruction at the position specified by the instruction builder [b].
20622062 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2063 external build_trunc_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2064 llvalue = "llvm_build_trunc_or_bitcast"
2063 val build_trunc_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2064 llvalue
20652065
20662066 (** [build_pointercast v ty name b] creates a bitcast or pointer-to-int
20672067 instruction at the position specified by the instruction builder [b].
20682068 See the method [llvm::LLVMBuilder::CreatePointerCast]. *)
2069 external build_pointercast : llvalue -> lltype -> string -> llbuilder -> llvalue
2070 = "llvm_build_pointercast"
2069 val build_pointercast : llvalue -> lltype -> string -> llbuilder -> llvalue
2070
20712071
20722072 (** [build_intcast v ty name b] creates a zext, bitcast, or trunc
20732073 instruction at the position specified by the instruction builder [b].
20742074 See the method [llvm::LLVMBuilder::CreateIntCast]. *)
2075 external build_intcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2076 = "llvm_build_intcast"
2075 val build_intcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2076
20772077
20782078 (** [build_fpcast v ty name b] creates a fpext, bitcast, or fptrunc
20792079 instruction at the position specified by the instruction builder [b].
20802080 See the method [llvm::LLVMBuilder::CreateFPCast]. *)
2081 external build_fpcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2082 = "llvm_build_fpcast"
2081 val build_fpcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2082
20832083
20842084
20852085 (** {7 Comparisons} *)
20882088 [%name = icmp %pred %x, %y]
20892089 instruction at the position specified by the instruction builder [b].
20902090 See the method [llvm::LLVMBuilder::CreateICmp]. *)
2091 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
2092 llbuilder -> llvalue = "llvm_build_icmp"
2091 val build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
2092 llbuilder -> llvalue
20932093
20942094 (** [build_fcmp pred x y name b] creates a
20952095 [%name = fcmp %pred %x, %y]
20962096 instruction at the position specified by the instruction builder [b].
20972097 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
2098 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
2099 llbuilder -> llvalue = "llvm_build_fcmp"
2098 val build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
2099 llbuilder -> llvalue
21002100
21012101
21022102 (** {7 Miscellaneous instructions} *)
21062106 instruction at the position specified by the instruction builder [b].
21072107 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
21082108 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2109 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
2110 llvalue = "llvm_build_phi"
2109 val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
2110 llvalue
21112111
21122112 (** [build_call fn args name b] creates a
21132113 [%name = call %fn(args...)]
21142114 instruction at the position specified by the instruction builder [b].
21152115 See the method [llvm::LLVMBuilder::CreateCall]. *)
2116 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2117 = "llvm_build_call"
2116 val build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2117
21182118
21192119 (** [build_select cond thenv elsev name b] creates a
21202120 [%name = select %cond, %thenv, %elsev]
21212121 instruction at the position specified by the instruction builder [b].
21222122 See the method [llvm::LLVMBuilder::CreateSelect]. *)
2123 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
2124 llvalue = "llvm_build_select"
2123 val build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
2124 llvalue
21252125
21262126 (** [build_va_arg valist argty name b] creates a
21272127 [%name = va_arg %valist, %argty]
21282128 instruction at the position specified by the instruction builder [b].
21292129 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
2130 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
2131 = "llvm_build_va_arg"
2130 val build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
2131
21322132
21332133 (** [build_extractelement vec i name b] creates a
21342134 [%name = extractelement %vec, %i]
21352135 instruction at the position specified by the instruction builder [b].
21362136 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
2137 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
2138 llvalue = "llvm_build_extractelement"
2137 val build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
2138 llvalue
21392139
21402140 (** [build_insertelement vec elt i name b] creates a
21412141 [%name = insertelement %vec, %elt, %i]
21422142 instruction at the position specified by the instruction builder [b].
21432143 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
2144 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
2145 llbuilder -> llvalue = "llvm_build_insertelement"
2144 val build_insertelement : llvalue -> llvalue -> llvalue -> string ->
2145 llbuilder -> llvalue
21462146
21472147 (** [build_shufflevector veca vecb mask name b] creates a
21482148 [%name = shufflevector %veca, %vecb, %mask]
21492149 instruction at the position specified by the instruction builder [b].
21502150 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
2151 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
2152 llbuilder -> llvalue = "llvm_build_shufflevector"
2151 val build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
2152 llbuilder -> llvalue
21532153
21542154 (** [build_insertvalue agg idx name b] creates a
21552155 [%name = extractvalue %agg, %idx]
21562156 instruction at the position specified by the instruction builder [b].
21572157 See the method [llvm::LLVMBuilder::CreateExtractValue]. *)
2158 external build_extractvalue : llvalue -> int -> string -> llbuilder -> llvalue
2159 = "llvm_build_extractvalue"
2158 val build_extractvalue : llvalue -> int -> string -> llbuilder -> llvalue
2159
21602160
21612161 (** [build_insertvalue agg val idx name b] creates a
21622162 [%name = insertvalue %agg, %val, %idx]
21632163 instruction at the position specified by the instruction builder [b].
21642164 See the method [llvm::LLVMBuilder::CreateInsertValue]. *)
2165 external build_insertvalue : llvalue -> llvalue -> int -> string -> llbuilder ->
2166 llvalue = "llvm_build_insertvalue"
2165 val build_insertvalue : llvalue -> llvalue -> int -> string -> llbuilder ->
2166 llvalue
21672167
21682168 (** [build_is_null val name b] creates a
21692169 [%name = icmp eq %val, null]
21702170 instruction at the position specified by the instruction builder [b].
21712171 See the method [llvm::LLVMBuilder::CreateIsNull]. *)
2172 external build_is_null : llvalue -> string -> llbuilder -> llvalue
2173 = "llvm_build_is_null"
2172 val build_is_null : llvalue -> string -> llbuilder -> llvalue
2173
21742174
21752175 (** [build_is_not_null val name b] creates a
21762176 [%name = icmp ne %val, null]
21772177 instruction at the position specified by the instruction builder [b].
21782178 See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
2179 external build_is_not_null : llvalue -> string -> llbuilder -> llvalue
2180 = "llvm_build_is_not_null"
2179 val build_is_not_null : llvalue -> string -> llbuilder -> llvalue
2180
21812181
21822182 (** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure
21832183 the difference between two pointer values at the position specified by the
21842184 instruction builder [b].
21852185 See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2186 external build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
2187 = "llvm_build_ptrdiff"
2186 val build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
2187
21882188
21892189
21902190 (** {6 Memory buffers} *)
21932193 (** [of_file p] is the memory buffer containing the contents of the file at
21942194 path [p]. If the file could not be read, then [IoError msg] is
21952195 raised. *)
2196 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
2196 val of_file : string -> llmemorybuffer
21972197
21982198 (** [stdin ()] is the memory buffer containing the contents of standard input.
21992199 If standard input is empty, then [IoError msg] is raised. *)
2200 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
2200 val of_stdin : unit -> llmemorybuffer
22012201
22022202 (** Disposes of a memory buffer. *)
2203 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
2203 val dispose : llmemorybuffer -> unit
22042204 end
22052205
22062206
22152215 type of pipeline is suitable for link-time optimization and whole-module
22162216 transformations.
22172217 See the constructor of [llvm::PassManager]. *)
2218 external create : unit -> [ `Module ] t = "llvm_passmanager_create"
2218 val create : unit -> [ `Module ] t
22192219
22202220 (** [PassManager.create_function m] constructs a new function-by-function
22212221 pass pipeline over the module [m]. It does not take ownership of [m].
22222222 This type of pipeline is suitable for code generation and JIT compilation
22232223 tasks.
22242224 See the constructor of [llvm::FunctionPassManager]. *)
2225 external create_function : llmodule -> [ `Function ] t
2226 = "LLVMCreateFunctionPassManager"
2225 val create_function : llmodule -> [ `Function ] t
2226
22272227
22282228 (** [run_module m pm] initializes, executes on the module [m], and finalizes
22292229 all of the passes scheduled in the pass manager [pm]. Returns [true] if
22302230 any of the passes modified the module, [false] otherwise.
22312231 See the [llvm::PassManager::run] method. *)
2232 external run_module : llmodule -> [ `Module ] t -> bool
2233 = "llvm_passmanager_run_module"
2232 val run_module : llmodule -> [ `Module ] t -> bool
2233
22342234
22352235 (** [initialize fpm] initializes all of the function passes scheduled in the
22362236 function pass manager [fpm]. Returns [true] if any of the passes modified
22372237 the module, [false] otherwise.
22382238 See the [llvm::FunctionPassManager::doInitialization] method. *)
2239 external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize"
2239 val initialize : [ `Function ] t -> bool
22402240
22412241 (** [run_function f fpm] executes all of the function passes scheduled in the
22422242 function pass manager [fpm] over the function [f]. Returns [true] if any
22432243 of the passes modified [f], [false] otherwise.
22442244 See the [llvm::FunctionPassManager::run] method. *)
2245 external run_function : llvalue -> [ `Function ] t -> bool
2246 = "llvm_passmanager_run_function"
2245 val run_function : llvalue -> [ `Function ] t -> bool
2246
22472247
22482248 (** [finalize fpm] finalizes all of the function passes scheduled in in the
22492249 function pass manager [fpm]. Returns [true] if any of the passes
22502250 modified the module, [false] otherwise.
22512251 See the [llvm::FunctionPassManager::doFinalization] method. *)
2252 external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize"
2252 val finalize : [ `Function ] t -> bool
22532253
22542254 (** Frees the memory of a pass pipeline. For function pipelines, does not free
22552255 the module.
22562256 See the destructor of [llvm::BasePassManager]. *)
2257 external dispose : [< any ] t -> unit = "llvm_passmanager_dispose"
2257 val dispose : [< any ] t -> unit
22582258 end
0 (* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_bitreader.cmxa llvm_executionengine.cmxa %s -o %t
1 * RUN: %t
2 *)
3 let context = Llvm.global_context ()
4 (* this used to crash, we must not use 'external' in .mli files, but 'val' if we
5 * want the let _ bindings executed, see http://caml.inria.fr/mantis/view.php?id=4166 *)
6 let _ =
7 try
8 ignore (Llvm_bitreader.get_module context (Llvm.MemoryBuffer.of_stdin ()))
9 with
10 Llvm_bitreader.Error _ -> ();;
11 let _ =
12 try
13 ignore (Llvm.MemoryBuffer.of_file "/path/to/nonexistent/file")
14 with
15 Llvm.IoError _ -> ();;