1 (*===-- llvm/llvm.mli - LLVM Ocaml Interface -------------------------------===*
3 * The LLVM Compiler Infrastructure
5 * This file is distributed under the University of Illinois Open Source
6 * License. See LICENSE.TXT for details.
8 *===----------------------------------------------------------------------===*)
12 This interface provides an ocaml API for the LLVM intermediate
13 representation, the classes in the VMCore library. *)
16 (** {6 Abstract types}
18 These abstract types correlate directly to the LLVM VMCore classes. *)
20 (** The top-level container for all LLVM global data. See the
21 [llvm::LLVMContext] class. *)
24 (** The top-level container for all other LLVM Intermediate Representation (IR)
25 objects. See the [llvm::Module] class. *)
28 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
29 [llvm::Type] class. *)
32 (** When building recursive types using {!refine_type}, [lltype] values may
33 become invalid; use [lltypehandle] to resolve this problem. See the
34 [llvm::AbstractTypeHolder] class. *)
37 (** Any value in the LLVM IR. Functions, instructions, global variables,
38 constants, and much more are all [llvalues]. See the [llvm::Value] class.
39 This type covers a wide range of subclasses. *)
42 (** Used to store users and usees of values. See the [llvm::Use] class. *)
45 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
48 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
52 (** Used to efficiently handle large buffers of read-only binary data.
53 See the [llvm::MemoryBuffer] class. *)
56 (** The kind of an [lltype], the result of [classify_type ty]. See the
57 [llvm::Type::TypeID] enumeration. *)
78 (** The linkage of a global value, accessed with {!linkage} and
79 {!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
83 | Available_externally
99 (** The linker visibility of a global value, accessed with {!visibility} and
100 {!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
101 module Visibility : sig
108 (** The following calling convention values may be accessed with
109 {!function_call_conv} and {!set_function_call_conv}. Calling
110 conventions are open-ended. *)
111 module CallConv : sig
112 val c : int (** [c] is the C calling convention. *)
113 val fast : int (** [fast] is the calling convention to allow LLVM
114 maximum optimization opportunities. Use only with
116 val cold : int (** [cold] is the calling convention for
118 val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
119 convention from C. *)
120 val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
121 convention from C. *)
124 module Attribute : sig
148 | Stackalignment of int
151 (** The predicate for an integer comparison ([icmp]) instruction.
152 See the [llvm::ICmpInst::Predicate] enumeration. *)
167 (** The predicate for a floating-point comparison ([fcmp]) instruction.
168 See the [llvm::FCmpInst::Predicate] enumeration. *)
192 (** [Before b] and [At_end a] specify positions from the start of the ['b] list
193 of [a]. [llpos] is used to specify positions in and for forward iteration
194 through the various value lists maintained by the LLVM IR. *)
195 type ('a, 'b) llpos =
199 (** [After b] and [At_start a] specify positions from the end of the ['b] list
200 of [a]. [llrev_pos] is used for reverse iteration through the various value
201 lists maintained by the LLVM IR. *)
202 type ('a, 'b) llrev_pos =
207 (** {6 Exceptions} *)
209 exception IoError of string
214 (** [create_context ()] creates a context for storing the "global" state in
215 LLVM. See the constructor [llvm::LLVMContext]. *)
216 external create_context : unit -> llcontext = "llvm_create_context"
218 (** [destroy_context ()] destroys a context. See the destructor
219 [llvm::LLVMContext::~LLVMContext]. *)
220 external dispose_context : llcontext -> unit = "llvm_dispose_context"
222 (** See the function [llvm::getGlobalContext]. *)
223 external global_context : unit -> llcontext = "llvm_global_context"
225 (** [mdkind_id context name] returns the MDKind ID that corresponds to the
226 name [name] in the context [context]. See the function
227 [llvm::LLVMContext::getMDKindID]. *)
228 external mdkind_id : llcontext -> string -> int = "llvm_mdkind_id"
233 (** [create_module context id] creates a module with the supplied module ID in
234 the context [context]. Modules are not garbage collected; it is mandatory
235 to call {!dispose_module} to free memory. See the constructor
236 [llvm::Module::Module]. *)
237 external create_module : llcontext -> string -> llmodule = "llvm_create_module"
239 (** [dispose_module m] destroys a module [m] and all of the IR objects it
240 contained. All references to subordinate objects are invalidated;
241 referencing them will invoke undefined behavior. See the destructor
242 [llvm::Module::~Module]. *)
243 external dispose_module : llmodule -> unit = "llvm_dispose_module"
245 (** [target_triple m] is the target specifier for the module [m], something like
246 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
247 external target_triple: llmodule -> string
248 = "llvm_target_triple"
250 (** [target_triple triple m] changes the target specifier for the module [m] to
251 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
252 external set_target_triple: string -> llmodule -> unit
253 = "llvm_set_target_triple"
255 (** [data_layout m] is the data layout specifier for the module [m], something
256 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
257 method [llvm::Module::getDataLayout]. *)
258 external data_layout: llmodule -> string
261 (** [set_data_layout s m] changes the data layout specifier for the module [m]
262 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
263 external set_data_layout: string -> llmodule -> unit
264 = "llvm_set_data_layout"
266 (** [define_type_name name ty m] adds a named type to the module's symbol table.
267 Returns [true] if successful. If such a name already exists, then no entry
268 is added and [false] is returned. See the [llvm::Module::addTypeName]
270 external define_type_name : string -> lltype -> llmodule -> bool
271 = "llvm_add_type_name"
273 (** [delete_type_name name] removes a type name from the module's symbol
275 external delete_type_name : string -> llmodule -> unit
276 = "llvm_delete_type_name"
278 (** [type_by_name m n] returns the type in the module [m] named [n], or [None]
279 if it does not exist. See the method [llvm::Module::getTypeByName]. *)
280 external type_by_name : llmodule -> string -> lltype option
281 = "llvm_type_by_name"
283 (** [dump_module m] prints the .ll representation of the module [m] to standard
284 error. See the method [llvm::Module::dump]. *)
285 external dump_module : llmodule -> unit = "llvm_dump_module"
287 (** [set_module_inline_asm m asm] sets the inline assembler for the module. See
288 the method [llvm::Module::setModuleInlineAsm]. *)
289 external set_module_inline_asm : llmodule -> string -> unit
290 = "llvm_set_module_inline_asm"
295 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
296 See the method [llvm::Type::getTypeID]. *)
297 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
299 (** [type_context ty] returns the {!llcontext} corresponding to the type [ty].
300 See the method [llvm::Type::getContext]. *)
301 external type_context : lltype -> llcontext = "llvm_type_context"
303 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
304 val string_of_lltype : lltype -> string
306 (** {7 Operations on integer types} *)
308 (** [i1_type c] returns an integer type of bitwidth 1 in the context [c]. See
309 [llvm::Type::Int1Ty]. *)
310 external i1_type : llcontext -> lltype = "llvm_i1_type"
312 (** [i8_type c] returns an integer type of bitwidth 8 in the context [c]. See
313 [llvm::Type::Int8Ty]. *)
314 external i8_type : llcontext -> lltype = "llvm_i8_type"
316 (** [i16_type c] returns an integer type of bitwidth 16 in the context [c]. See
317 [llvm::Type::Int16Ty]. *)
318 external i16_type : llcontext -> lltype = "llvm_i16_type"
320 (** [i32_type c] returns an integer type of bitwidth 32 in the context [c]. See
321 [llvm::Type::Int32Ty]. *)
322 external i32_type : llcontext -> lltype = "llvm_i32_type"
324 (** [i64_type c] returns an integer type of bitwidth 64 in the context [c]. See
325 [llvm::Type::Int64Ty]. *)
326 external i64_type : llcontext -> lltype = "llvm_i64_type"
328 (** [integer_type c n] returns an integer type of bitwidth [n] in the context
329 [c]. See the method [llvm::IntegerType::get]. *)
330 external integer_type : llcontext -> int -> lltype = "llvm_integer_type"
332 (** [integer_bitwidth c ty] returns the number of bits in the integer type [ty]
333 in the context [c]. See the method [llvm::IntegerType::getBitWidth]. *)
334 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
337 (** {7 Operations on real types} *)
339 (** [float_type c] returns the IEEE 32-bit floating point type in the context
340 [c]. See [llvm::Type::FloatTy]. *)
341 external float_type : llcontext -> lltype = "llvm_float_type"
343 (** [double_type c] returns the IEEE 64-bit floating point type in the context
344 [c]. See [llvm::Type::DoubleTy]. *)
345 external double_type : llcontext -> lltype = "llvm_double_type"
347 (** [x86fp80_type c] returns the x87 80-bit floating point type in the context
348 [c]. See [llvm::Type::X86_FP80Ty]. *)
349 external x86fp80_type : llcontext -> lltype = "llvm_x86fp80_type"
351 (** [fp128_type c] returns the IEEE 128-bit floating point type in the context
352 [c]. See [llvm::Type::FP128Ty]. *)
353 external fp128_type : llcontext -> lltype = "llvm_fp128_type"
355 (** [ppc_fp128_type c] returns the PowerPC 128-bit floating point type in the
356 context [c]. See [llvm::Type::PPC_FP128Ty]. *)
357 external ppc_fp128_type : llcontext -> lltype = "llvm_ppc_fp128_type"
360 (** {7 Operations on function types} *)
362 (** [function_type ret_ty param_tys] returns the function type returning
363 [ret_ty] and taking [param_tys] as parameters.
364 See the method [llvm::FunctionType::get]. *)
365 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
367 (** [va_arg_function_type ret_ty param_tys] is just like
368 [function_type ret_ty param_tys] except that it returns the function type
369 which also takes a variable number of arguments.
370 See the method [llvm::FunctionType::get]. *)
371 external var_arg_function_type : lltype -> lltype array -> lltype
372 = "llvm_var_arg_function_type"
374 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
375 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
376 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
378 (** [return_type fty] gets the return type of the function type [fty].
379 See the method [llvm::FunctionType::getReturnType]. *)
380 external return_type : lltype -> lltype = "LLVMGetReturnType"
382 (** [param_types fty] gets the parameter types of the function type [fty].
383 See the method [llvm::FunctionType::getParamType]. *)
384 external param_types : lltype -> lltype array = "llvm_param_types"
387 (** {7 Operations on struct types} *)
389 (** [struct_type context tys] returns the structure type in the context
390 [context] containing in the types in the array [tys]. See the method
391 [llvm::StructType::get]. *)
392 external struct_type : llcontext -> lltype array -> lltype
395 (** [packed_struct_type context ys] returns the packed structure type in the
396 context [context] containing in the types in the array [tys]. See the method
397 [llvm::StructType::get]. *)
398 external packed_struct_type : llcontext -> lltype array -> lltype
399 = "llvm_packed_struct_type"
401 (** [struct_element_types sty] returns the constituent types of the struct type
402 [sty]. See the method [llvm::StructType::getElementType]. *)
403 external struct_element_types : lltype -> lltype array
404 = "llvm_struct_element_types"
406 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
407 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
408 external is_packed : lltype -> bool = "llvm_is_packed"
411 (** {7 Operations on union types} *)
413 (** [union_type context tys] returns the union type in the context [context]
414 containing the types in the array [tys]. See the method
415 [llvm::UnionType::get] *)
416 external union_type : llcontext -> lltype array -> lltype = "llvm_union_type"
418 (** [union_element_types uty] returns the constituent types of the union type
419 [uty]. See the method [llvm::UnionType::getElementType]. *)
420 external union_element_types : lltype -> lltype array
421 = "llvm_union_element_types"
424 (** {7 Operations on pointer, vector, and array types} *)
426 (** [array_type ty n] returns the array type containing [n] elements of type
427 [ty]. See the method [llvm::ArrayType::get]. *)
428 external array_type : lltype -> int -> lltype = "llvm_array_type"
430 (** [pointer_type ty] returns the pointer type referencing objects of type
431 [ty] in the default address space (0).
432 See the method [llvm::PointerType::getUnqual]. *)
433 external pointer_type : lltype -> lltype = "llvm_pointer_type"
435 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
436 of type [ty] in address space [as].
437 See the method [llvm::PointerType::get]. *)
438 external qualified_pointer_type : lltype -> int -> lltype
439 = "llvm_qualified_pointer_type"
441 (** [vector_type ty n] returns the array type containing [n] elements of the
442 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
443 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
445 (** [element_type ty] returns the element type of the pointer, vector, or array
446 type [ty]. See the method [llvm::SequentialType::get]. *)
447 external element_type : lltype -> lltype = "LLVMGetElementType"
449 (** [element_type aty] returns the element count of the array type [aty].
450 See the method [llvm::ArrayType::getNumElements]. *)
451 external array_length : lltype -> int = "llvm_array_length"
453 (** [address_space pty] returns the address space qualifier of the pointer type
454 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
455 external address_space : lltype -> int = "llvm_address_space"
457 (** [element_type ty] returns the element count of the vector type [ty].
458 See the method [llvm::VectorType::getNumElements]. *)
459 external vector_size : lltype -> int = "llvm_vector_size"
462 (** {7 Operations on other types} *)
464 (** [opaque_type c] creates a new opaque type distinct from any other in the
465 context [c]. Opaque types are useful for building recursive types in
466 combination with {!refine_type}. See [llvm::OpaqueType::get]. *)
467 external opaque_type : llcontext -> lltype = "llvm_opaque_type"
469 (** [void_type c] creates a type of a function which does not return any
470 value in the context [c]. See [llvm::Type::VoidTy]. *)
471 external void_type : llcontext -> lltype = "llvm_void_type"
473 (** [label_type c] creates a type of a basic block in the context [c]. See
474 [llvm::Type::LabelTy]. *)
475 external label_type : llcontext -> lltype = "llvm_label_type"
477 (** {7 Operations on type handles} *)
479 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
480 refined as a result of a call to {!refine_type}, the handle will be updated;
481 any bare [lltype] references will become invalid.
482 See the class [llvm::PATypeHolder]. *)
483 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
485 (** [type_of_handle tyh] resolves the type handle [tyh].
486 See the method [llvm::PATypeHolder::get()]. *)
487 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
489 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
490 concrete type [ty] in all users. Warning: This may invalidate {!lltype}
491 values! Use {!lltypehandle} to manipulate potentially abstract types. See
492 the method [llvm::Type::refineAbstractType]. *)
493 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
498 (** [type_of v] returns the type of the value [v].
499 See the method [llvm::Value::getType]. *)
500 external type_of : llvalue -> lltype = "llvm_type_of"
502 (** [value_name v] returns the name of the value [v]. For global values, this is
503 the symbol name. For instructions and basic blocks, it is the SSA register
504 name. It is meaningless for constants.
505 See the method [llvm::Value::getName]. *)
506 external value_name : llvalue -> string = "llvm_value_name"
508 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
509 [llvm::Value::setName]. *)
510 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
512 (** [dump_value v] prints the .ll representation of the value [v] to standard
513 error. See the method [llvm::Value::dump]. *)
514 external dump_value : llvalue -> unit = "llvm_dump_value"
516 (** [replace_all_uses_with old new] replaces all uses of the value [old]
517 * with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
518 external replace_all_uses_with : llvalue -> llvalue -> unit
519 = "LLVMReplaceAllUsesWith"
524 (** [use_begin v] returns the first position in the use list for the value [v].
525 [use_begin] and [use_succ] can e used to iterate over the use list in order.
526 See the method [llvm::Value::use_begin]. *)
527 external use_begin : llvalue -> lluse option = "llvm_use_begin"
529 (** [use_succ u] returns the use list position succeeding [u].
530 See the method [llvm::use_value_iterator::operator++]. *)
531 external use_succ : lluse -> lluse option = "llvm_use_succ"
533 (** [user u] returns the user of the use [u].
534 See the method [llvm::Use::getUser]. *)
535 external user : lluse -> llvalue = "llvm_user"
537 (** [used_value u] returns the usee of the use [u].
538 See the method [llvm::Use::getUsedValue]. *)
539 external used_value : lluse -> llvalue = "llvm_used_value"
541 (** [iter_uses f v] applies function [f] to each of the users of the value [v]
542 in order. Tail recursive. *)
543 val iter_uses : (lluse -> unit) -> llvalue -> unit
545 (** [fold_left_uses f init v] is [f (... (f init u1) ...) uN] where
546 [u1,...,uN] are the users of the value [v]. Tail recursive. *)
547 val fold_left_uses : ('a -> lluse -> 'a) -> 'a -> llvalue -> 'a
549 (** [fold_right_uses f v init] is [f u1 (... (f uN init) ...)] where
550 [u1,...,uN] are the users of the value [v]. Not tail recursive. *)
551 val fold_right_uses : (lluse -> 'a -> 'a) -> llvalue -> 'a -> 'a
556 (** [operand v i] returns the operand at index [i] for the value [v]. See the
557 method [llvm::User::getOperand]. *)
558 external operand : llvalue -> int -> llvalue = "llvm_operand"
560 (** [set_operand v i o] sets the operand of the value [v] at the index [i] to
562 See the method [llvm::User::setOperand]. *)
563 external set_operand : llvalue -> int -> llvalue -> unit = "llvm_set_operand"
565 (** [num_operands v] returns the number of operands for the value [v].
566 See the method [llvm::User::getNumOperands]. *)
567 external num_operands : llvalue -> int = "llvm_num_operands"
569 (** {7 Operations on constants of (mostly) any type} *)
571 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
572 otherwise. Similar to [llvm::isa<Constant>]. *)
573 external is_constant : llvalue -> bool = "llvm_is_constant"
575 (** [const_null ty] returns the constant null (zero) of the type [ty].
576 See the method [llvm::Constant::getNullValue]. *)
577 external const_null : lltype -> llvalue = "LLVMConstNull"
579 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
580 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
581 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
583 (** [const_pointer_null ty] returns the constant null (zero) pointer of the type
584 [ty]. See the method [llvm::ConstantPointerNull::get]. *)
585 external const_pointer_null : lltype -> llvalue = "LLVMConstPointerNull"
587 (** [undef ty] returns the undefined value of the type [ty].
588 See the method [llvm::UndefValue::get]. *)
589 external undef : lltype -> llvalue = "LLVMGetUndef"
591 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
592 See the method [llvm::Constant::isNullValue]. *)
593 external is_null : llvalue -> bool = "llvm_is_null"
595 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
596 otherwise. Similar to [llvm::isa<UndefValue>]. *)
597 external is_undef : llvalue -> bool = "llvm_is_undef"
600 (** {7 Operations on instructions} *)
602 (** [has_metadata i] returns whether or not the instruction [i] has any
603 metadata attached to it. See the function
604 [llvm::Instruction::hasMetadata]. *)
605 external has_metadata : llvalue -> bool = "llvm_has_metadata"
607 (** [metadata i kind] optionally returns the metadata associated with the
608 kind [kind] in the instruction [i] See the function
609 [llvm::Instruction::getMetadata]. *)
610 external metadata : llvalue -> int -> llvalue option = "llvm_metadata"
612 (** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
613 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
614 external set_metadata : llvalue -> int -> llvalue -> unit = "llvm_set_metadata"
616 (** [clear_metadata i kind] clears the metadata of kind [kind] in the
617 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
618 external clear_metadata : llvalue -> int -> unit = "llvm_clear_metadata"
621 (** {7 Operations on metadata} *)
623 (** [mdstring c s] returns the MDString of the string [s] in the context [c].
624 See the method [llvm::MDNode::get]. *)
625 external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"
627 (** [mdnode c elts] returns the MDNode containing the values [elts] in the
629 See the method [llvm::MDNode::get]. *)
630 external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
633 (** {7 Operations on scalar constants} *)
635 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
636 See the method [llvm::ConstantInt::get]. *)
637 external const_int : lltype -> int -> llvalue = "llvm_const_int"
639 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
640 [i]. See the method [llvm::ConstantInt::get]. *)
641 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
642 = "llvm_const_of_int64"
644 (** [const_int_of_string ty s r] returns the integer constant of type [ty] and
645 * value [s], with the radix [r]. See the method [llvm::ConstantInt::get]. *)
646 external const_int_of_string : lltype -> string -> int -> llvalue
647 = "llvm_const_int_of_string"
649 (** [const_float ty n] returns the floating point constant of type [ty] and
650 value [n]. See the method [llvm::ConstantFP::get]. *)
651 external const_float : lltype -> float -> llvalue = "llvm_const_float"
653 (** [const_float_of_string ty s] returns the floating point constant of type
654 [ty] and value [n]. See the method [llvm::ConstantFP::get]. *)
655 external const_float_of_string : lltype -> string -> llvalue
656 = "llvm_const_float_of_string"
659 (** {7 Operations on composite constants} *)
661 (** [const_string c s] returns the constant [i8] array with the values of the
662 characters in the string [s] in the context [c]. The array is not
663 null-terminated (but see {!const_stringz}). This value can in turn be used
664 as the initializer for a global variable. See the method
665 [llvm::ConstantArray::get]. *)
666 external const_string : llcontext -> string -> llvalue = "llvm_const_string"
668 (** [const_stringz c s] returns the constant [i8] array with the values of the
669 characters in the string [s] and a null terminator in the context [c]. This
670 value can in turn be used as the initializer for a global variable.
671 See the method [llvm::ConstantArray::get]. *)
672 external const_stringz : llcontext -> string -> llvalue = "llvm_const_stringz"
674 (** [const_array ty elts] returns the constant array of type
675 [array_type ty (Array.length elts)] and containing the values [elts].
676 This value can in turn be used as the initializer for a global variable.
677 See the method [llvm::ConstantArray::get]. *)
678 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
680 (** [const_struct context elts] returns the structured constant of type
681 [struct_type (Array.map type_of elts)] and containing the values [elts]
682 in the context [context]. This value can in turn be used as the initializer
683 for a global variable. See the method [llvm::ConstantStruct::get]. *)
684 external const_struct : llcontext -> llvalue array -> llvalue
685 = "llvm_const_struct"
687 (** [const_packed_struct context elts] returns the structured constant of
688 type {!packed_struct_type} [(Array.map type_of elts)] and containing the
689 values [elts] in the context [context]. This value can in turn be used as
690 the initializer for a global variable. See the method
691 [llvm::ConstantStruct::get]. *)
692 external const_packed_struct : llcontext -> llvalue array -> llvalue
693 = "llvm_const_packed_struct"
695 (** [const_vector elts] returns the vector constant of type
696 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
697 values [elts]. See the method [llvm::ConstantVector::get]. *)
698 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
700 (** [const_union ty v] returns the union constant of type [union_type tys] and
701 containing the value [v]. See the method [llvm::ConstantUnion::get]. *)
702 external const_union : lltype -> llvalue -> llvalue = "LLVMConstUnion"
705 (** {7 Constant expressions} *)
707 (** [align_of ty] returns the alignof constant for the type [ty]. This is
708 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type {i8,ty}))
709 (const_int i32_type 0) (const_int i32_type 1)) i32_type], but considerably
710 more readable. See the method [llvm::ConstantExpr::getAlignOf]. *)
711 external align_of : lltype -> llvalue = "LLVMAlignOf"
713 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
714 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
715 (const_int i32_type 1)) i64_type], but considerably more readable.
716 See the method [llvm::ConstantExpr::getSizeOf]. *)
717 external size_of : lltype -> llvalue = "LLVMSizeOf"
719 (** [const_neg c] returns the arithmetic negation of the constant [c].
720 See the method [llvm::ConstantExpr::getNeg]. *)
721 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
723 (** [const_nsw_neg c] returns the arithmetic negation of the constant [c] with
724 no signed wrapping. The result is undefined if the negation overflows.
725 See the method [llvm::ConstantExpr::getNSWNeg]. *)
726 external const_nsw_neg : llvalue -> llvalue = "LLVMConstNSWNeg"
728 (** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
729 no unsigned wrapping. The result is undefined if the negation overflows.
730 See the method [llvm::ConstantExpr::getNUWNeg]. *)
731 external const_nuw_neg : llvalue -> llvalue = "LLVMConstNUWNeg"
733 (** [const_fneg c] returns the arithmetic negation of the constant float [c].
734 See the method [llvm::ConstantExpr::getFNeg]. *)
735 external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
737 (** [const_not c] returns the bitwise inverse of the constant [c].
738 See the method [llvm::ConstantExpr::getNot]. *)
739 external const_not : llvalue -> llvalue = "LLVMConstNot"
741 (** [const_add c1 c2] returns the constant sum of two constants.
742 See the method [llvm::ConstantExpr::getAdd]. *)
743 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
745 (** [const_nsw_add c1 c2] returns the constant sum of two constants with no
746 signed wrapping. The result is undefined if the sum overflows.
747 See the method [llvm::ConstantExpr::getNSWAdd]. *)
748 external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
750 (** [const_nuw_add c1 c2] returns the constant sum of two constants with no
751 unsigned wrapping. The result is undefined if the sum overflows.
752 See the method [llvm::ConstantExpr::getNSWAdd]. *)
753 external const_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
755 (** [const_fadd c1 c2] returns the constant sum of two constant floats.
756 See the method [llvm::ConstantExpr::getFAdd]. *)
757 external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
759 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
760 constants. See the method [llvm::ConstantExpr::getSub]. *)
761 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
763 (** [const_nsw_sub c1 c2] returns the constant difference of two constants with
764 no signed wrapping. The result is undefined if the sum overflows.
765 See the method [llvm::ConstantExpr::getNSWSub]. *)
766 external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
768 (** [const_nuw_sub c1 c2] returns the constant difference of two constants with
769 no unsigned wrapping. The result is undefined if the sum overflows.
770 See the method [llvm::ConstantExpr::getNSWSub]. *)
771 external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
773 (** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
774 constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
775 external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
777 (** [const_mul c1 c2] returns the constant product of two constants.
778 See the method [llvm::ConstantExpr::getMul]. *)
779 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
781 (** [const_nsw_mul c1 c2] returns the constant product of two constants with
782 no signed wrapping. The result is undefined if the sum overflows.
783 See the method [llvm::ConstantExpr::getNSWMul]. *)
784 external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
786 (** [const_nuw_mul c1 c2] returns the constant product of two constants with
787 no unsigned wrapping. The result is undefined if the sum overflows.
788 See the method [llvm::ConstantExpr::getNSWMul]. *)
789 external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
791 (** [const_fmul c1 c2] returns the constant product of two constants floats.
792 See the method [llvm::ConstantExpr::getFMul]. *)
793 external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
795 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
797 See the method [llvm::ConstantExpr::getUDiv]. *)
798 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
800 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
802 See the method [llvm::ConstantExpr::getSDiv]. *)
803 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
805 (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
806 signed integer constants. The result is undefined if the result is rounded
807 or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
808 external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
810 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
812 See the method [llvm::ConstantExpr::getFDiv]. *)
813 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
815 (** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
816 unsigned integer constants.
817 See the method [llvm::ConstantExpr::getURem]. *)
818 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
820 (** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
821 signed integer constants.
822 See the method [llvm::ConstantExpr::getSRem]. *)
823 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
825 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
826 signed floating point constants.
827 See the method [llvm::ConstantExpr::getFRem]. *)
828 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
830 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
832 See the method [llvm::ConstantExpr::getAnd]. *)
833 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
835 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
837 See the method [llvm::ConstantExpr::getOr]. *)
838 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
840 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
842 See the method [llvm::ConstantExpr::getXor]. *)
843 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
845 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
846 constants, [c1 pred c2].
847 See the method [llvm::ConstantExpr::getICmp]. *)
848 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
851 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
852 point constants, [c1 pred c2].
853 See the method [llvm::ConstantExpr::getFCmp]. *)
854 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
857 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
858 constant integer [c2].
859 See the method [llvm::ConstantExpr::getShl]. *)
860 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
862 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
863 constant integer [c2] with zero extension.
864 See the method [llvm::ConstantExpr::getLShr]. *)
865 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
867 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
868 constant integer [c2] with sign extension.
869 See the method [llvm::ConstantExpr::getAShr]. *)
870 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
872 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
873 constant integers indices from the array [indices].
874 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
875 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
877 (** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
878 with the constant integers indices from the array [indices].
879 See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
880 external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
881 = "llvm_const_in_bounds_gep"
883 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
884 to the smaller integer type [ty].
885 See the method [llvm::ConstantExpr::getTrunc]. *)
886 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
888 (** [const_sext c ty] returns the constant sign extension of integer constant
889 [c] to the larger integer type [ty].
890 See the method [llvm::ConstantExpr::getSExt]. *)
891 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
893 (** [const_zext c ty] returns the constant zero extension of integer constant
894 [c] to the larger integer type [ty].
895 See the method [llvm::ConstantExpr::getZExt]. *)
896 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
898 (** [const_fptrunc c ty] returns the constant truncation of floating point
899 constant [c] to the smaller floating point type [ty].
900 See the method [llvm::ConstantExpr::getFPTrunc]. *)
901 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
903 (** [const_fpext c ty] returns the constant extension of floating point constant
904 [c] to the larger floating point type [ty].
905 See the method [llvm::ConstantExpr::getFPExt]. *)
906 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
908 (** [const_uitofp c ty] returns the constant floating point conversion of
909 unsigned integer constant [c] to the floating point type [ty].
910 See the method [llvm::ConstantExpr::getUIToFP]. *)
911 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
913 (** [const_sitofp c ty] returns the constant floating point conversion of
914 signed integer constant [c] to the floating point type [ty].
915 See the method [llvm::ConstantExpr::getSIToFP]. *)
916 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
918 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
919 floating point constant [c] to integer type [ty].
920 See the method [llvm::ConstantExpr::getFPToUI]. *)
921 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
923 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
924 floating point constant [c] to integer type [ty].
925 See the method [llvm::ConstantExpr::getFPToSI]. *)
926 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
928 (** [const_ptrtoint c ty] returns the constant integer conversion of
929 pointer constant [c] to integer type [ty].
930 See the method [llvm::ConstantExpr::getPtrToInt]. *)
931 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
933 (** [const_inttoptr c ty] returns the constant pointer conversion of
934 integer constant [c] to pointer type [ty].
935 See the method [llvm::ConstantExpr::getIntToPtr]. *)
936 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
938 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
939 to type [ty] of equal size.
940 See the method [llvm::ConstantExpr::getBitCast]. *)
941 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
943 (** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
944 conversion of constant [c] to type [ty].
945 See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
946 external const_zext_or_bitcast : llvalue -> lltype -> llvalue
947 = "LLVMConstZExtOrBitCast"
949 (** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
950 conversion of constant [c] to type [ty].
951 See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
952 external const_sext_or_bitcast : llvalue -> lltype -> llvalue
953 = "LLVMConstSExtOrBitCast"
955 (** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
956 conversion of constant [c] to type [ty].
957 See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
958 external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
959 = "LLVMConstTruncOrBitCast"
961 (** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
962 cast conversion of constant [c] to type [ty] of equal size.
963 See the method [llvm::ConstantExpr::getPointerCast]. *)
964 external const_pointercast : llvalue -> lltype -> llvalue
965 = "LLVMConstPointerCast"
967 (** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
968 -> integer casts of constant [c] to type [ty].
969 See the method [llvm::ConstantExpr::getIntCast]. *)
970 external const_intcast : llvalue -> lltype -> llvalue
973 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
974 fp casts of constant [c] to type [ty].
975 See the method [llvm::ConstantExpr::getFPCast]. *)
976 external const_fpcast : llvalue -> lltype -> llvalue
979 (** [const_select cond t f] returns the constant conditional which returns value
980 [t] if the boolean constant [cond] is true and the value [f] otherwise.
981 See the method [llvm::ConstantExpr::getSelect]. *)
982 external const_select : llvalue -> llvalue -> llvalue -> llvalue
985 (** [const_extractelement vec i] returns the constant [i]th element of
986 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
987 the size of the vector.
988 See the method [llvm::ConstantExpr::getExtractElement]. *)
989 external const_extractelement : llvalue -> llvalue -> llvalue
990 = "LLVMConstExtractElement"
992 (** [const_insertelement vec v i] returns the constant vector with the same
993 elements as constant vector [v] but the [i]th element replaced by the
994 constant [v]. [v] must be a constant value with the type of the vector
995 elements. [i] must be a constant [i32] value unsigned less than the size
997 See the method [llvm::ConstantExpr::getInsertElement]. *)
998 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
999 = "LLVMConstInsertElement"
1001 (** [const_shufflevector a b mask] returns a constant [shufflevector].
1002 See the LLVM Language Reference for details on the [shufflevector]
1004 See the method [llvm::ConstantExpr::getShuffleVector]. *)
1005 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
1006 = "LLVMConstShuffleVector"
1008 (** [const_extractvalue agg idxs] returns the constant [idxs]th value of
1009 constant aggregate [agg]. Each [idxs] must be less than the size of the
1010 aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
1011 external const_extractvalue : llvalue -> int array -> llvalue
1012 = "llvm_const_extractvalue"
1014 (** [const_insertvalue agg val idxs] inserts the value [val] in the specified
1015 indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
1016 of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
1017 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
1018 = "llvm_const_insertvalue"
1020 (** [const_inline_asm ty asm con side align] inserts a inline assembly string.
1021 See the method [llvm::InlineAsm::get]. *)
1022 external const_inline_asm : lltype -> string -> string -> bool -> bool ->
1024 = "llvm_const_inline_asm"
1026 (** [block_address f bb] returns the address of the basic block [bb] in the
1027 function [f]. See the method [llvm::BasicBlock::get]. *)
1028 external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
1031 (** {7 Operations on global variables, functions, and aliases (globals)} *)
1033 (** [global_parent g] is the enclosing module of the global value [g].
1034 See the method [llvm::GlobalValue::getParent]. *)
1035 external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
1037 (** [is_declaration g] returns [true] if the global value [g] is a declaration
1038 only. Returns [false] otherwise.
1039 See the method [llvm::GlobalValue::isDeclaration]. *)
1040 external is_declaration : llvalue -> bool = "llvm_is_declaration"
1042 (** [linkage g] returns the linkage of the global value [g].
1043 See the method [llvm::GlobalValue::getLinkage]. *)
1044 external linkage : llvalue -> Linkage.t = "llvm_linkage"
1046 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
1047 See the method [llvm::GlobalValue::setLinkage]. *)
1048 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
1050 (** [section g] returns the linker section of the global value [g].
1051 See the method [llvm::GlobalValue::getSection]. *)
1052 external section : llvalue -> string = "llvm_section"
1054 (** [set_section s g] sets the linker section of the global value [g] to [s].
1055 See the method [llvm::GlobalValue::setSection]. *)
1056 external set_section : string -> llvalue -> unit = "llvm_set_section"
1058 (** [visibility g] returns the linker visibility of the global value [g].
1059 See the method [llvm::GlobalValue::getVisibility]. *)
1060 external visibility : llvalue -> Visibility.t = "llvm_visibility"
1062 (** [set_visibility v g] sets the linker visibility of the global value [g] to
1063 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
1064 external set_visibility : Visibility.t -> llvalue -> unit
1065 = "llvm_set_visibility"
1067 (** [alignment g] returns the required alignment of the global value [g].
1068 See the method [llvm::GlobalValue::getAlignment]. *)
1069 external alignment : llvalue -> int = "llvm_alignment"
1071 (** [set_alignment n g] sets the required alignment of the global value [g] to
1072 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
1073 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
1076 (** {7 Operations on global variables} *)
1078 (** [declare_global ty name m] returns a new global variable of type [ty] and
1079 with name [name] in module [m] in the default address space (0). If such a
1080 global variable already exists, it is returned. If the type of the existing
1081 global differs, then a bitcast to [ty] is returned. *)
1082 external declare_global : lltype -> string -> llmodule -> llvalue
1083 = "llvm_declare_global"
1085 (** [declare_qualified_global ty name addrspace m] returns a new global variable
1086 of type [ty] and with name [name] in module [m] in the address space
1087 [addrspace]. If such a global variable already exists, it is returned. If
1088 the type of the existing global differs, then a bitcast to [ty] is
1090 external declare_qualified_global : lltype -> string -> int -> llmodule ->
1092 = "llvm_declare_qualified_global"
1094 (** [define_global name init m] returns a new global with name [name] and
1095 initializer [init] in module [m] in the default address space (0). If the
1096 named global already exists, it is renamed.
1097 See the constructor of [llvm::GlobalVariable]. *)
1098 external define_global : string -> llvalue -> llmodule -> llvalue
1099 = "llvm_define_global"
1101 (** [define_qualified_global name init addrspace m] returns a new global with
1102 name [name] and initializer [init] in module [m] in the address space
1103 [addrspace]. If the named global already exists, it is renamed.
1104 See the constructor of [llvm::GlobalVariable]. *)
1105 external define_qualified_global : string -> llvalue -> int -> llmodule ->
1107 = "llvm_define_qualified_global"
1109 (** [lookup_global name m] returns [Some g] if a global variable with name
1110 [name] exists in module [m]. If no such global exists, returns [None].
1111 See the [llvm::GlobalVariable] constructor. *)
1112 external lookup_global : string -> llmodule -> llvalue option
1113 = "llvm_lookup_global"
1115 (** [delete_global gv] destroys the global variable [gv].
1116 See the method [llvm::GlobalVariable::eraseFromParent]. *)
1117 external delete_global : llvalue -> unit = "llvm_delete_global"
1119 (** [global_begin m] returns the first position in the global variable list of
1120 the module [m]. [global_begin] and [global_succ] can be used to iterate
1121 over the global list in order.
1122 See the method [llvm::Module::global_begin]. *)
1123 external global_begin : llmodule -> (llmodule, llvalue) llpos
1124 = "llvm_global_begin"
1126 (** [global_succ gv] returns the global variable list position succeeding
1128 See the method [llvm::Module::global_iterator::operator++]. *)
1129 external global_succ : llvalue -> (llmodule, llvalue) llpos
1130 = "llvm_global_succ"
1132 (** [iter_globals f m] applies function [f] to each of the global variables of
1133 module [m] in order. Tail recursive. *)
1134 val iter_globals : (llvalue -> unit) -> llmodule -> unit
1136 (** [fold_left_globals f init m] is [f (... (f init g1) ...) gN] where
1137 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1138 val fold_left_globals : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
1140 (** [global_end m] returns the last position in the global variable list of the
1141 module [m]. [global_end] and [global_pred] can be used to iterate over the
1142 global list in reverse.
1143 See the method [llvm::Module::global_end]. *)
1144 external global_end : llmodule -> (llmodule, llvalue) llrev_pos
1147 (** [global_pred gv] returns the global variable list position preceding
1149 See the method [llvm::Module::global_iterator::operator--]. *)
1150 external global_pred : llvalue -> (llmodule, llvalue) llrev_pos
1151 = "llvm_global_pred"
1153 (** [rev_iter_globals f m] applies function [f] to each of the global variables
1154 of module [m] in reverse order. Tail recursive. *)
1155 val rev_iter_globals : (llvalue -> unit) -> llmodule -> unit
1157 (** [fold_right_globals f m init] is [f g1 (... (f gN init) ...)] where
1158 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1159 val fold_right_globals : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
1161 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
1162 constant. Returns [false] otherwise.
1163 See the method [llvm::GlobalVariable::isConstant]. *)
1164 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
1166 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
1167 [c] is [true] and not if [c] is [false].
1168 See the method [llvm::GlobalVariable::setConstant]. *)
1169 external set_global_constant : bool -> llvalue -> unit
1170 = "llvm_set_global_constant"
1172 (** [global_initializer gv] returns the initializer for the global variable
1173 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
1174 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
1176 (** [set_initializer c gv] sets the initializer for the global variable
1177 [gv] to the constant [c].
1178 See the method [llvm::GlobalVariable::setInitializer]. *)
1179 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
1181 (** [remove_initializer gv] unsets the initializer for the global variable
1183 See the method [llvm::GlobalVariable::setInitializer]. *)
1184 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
1186 (** [is_thread_local gv] returns [true] if the global variable [gv] is
1187 thread-local and [false] otherwise.
1188 See the method [llvm::GlobalVariable::isThreadLocal]. *)
1189 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
1191 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
1192 [c] is [true] and not otherwise.
1193 See the method [llvm::GlobalVariable::setThreadLocal]. *)
1194 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
1197 (** {7 Operations on aliases} *)
1199 (** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
1200 the aliasee [a] with the name [n].
1201 See the constructor for [llvm::GlobalAlias]. *)
1202 external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
1206 (** {7 Operations on functions} *)
1208 (** [declare_function name ty m] returns a new function of type [ty] and
1209 with name [name] in module [m]. If such a function already exists,
1210 it is returned. If the type of the existing function differs, then a bitcast
1211 to [ty] is returned. *)
1212 external declare_function : string -> lltype -> llmodule -> llvalue
1213 = "llvm_declare_function"
1215 (** [define_function name ty m] creates a new function with name [name] and
1216 type [ty] in module [m]. If the named function already exists, it is
1217 renamed. An entry basic block is created in the function.
1218 See the constructor of [llvm::GlobalVariable]. *)
1219 external define_function : string -> lltype -> llmodule -> llvalue
1220 = "llvm_define_function"
1222 (** [lookup_function name m] returns [Some f] if a function with name
1223 [name] exists in module [m]. If no such function exists, returns [None].
1224 See the method [llvm::Module] constructor. *)
1225 external lookup_function : string -> llmodule -> llvalue option
1226 = "llvm_lookup_function"
1228 (** [delete_function f] destroys the function [f].
1229 See the method [llvm::Function::eraseFromParent]. *)
1230 external delete_function : llvalue -> unit = "llvm_delete_function"
1232 (** [function_begin m] returns the first position in the function list of the
1233 module [m]. [function_begin] and [function_succ] can be used to iterate over
1234 the function list in order.
1235 See the method [llvm::Module::begin]. *)
1236 external function_begin : llmodule -> (llmodule, llvalue) llpos
1237 = "llvm_function_begin"
1239 (** [function_succ gv] returns the function list position succeeding
1241 See the method [llvm::Module::iterator::operator++]. *)
1242 external function_succ : llvalue -> (llmodule, llvalue) llpos
1243 = "llvm_function_succ"
1245 (** [iter_functions f m] applies function [f] to each of the functions of module
1246 [m] in order. Tail recursive. *)
1247 val iter_functions : (llvalue -> unit) -> llmodule -> unit
1249 (** [fold_left_function f init m] is [f (... (f init f1) ...) fN] where
1250 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1251 val fold_left_functions : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
1253 (** [function_end m] returns the last position in the function list of
1254 the module [m]. [function_end] and [function_pred] can be used to iterate
1255 over the function list in reverse.
1256 See the method [llvm::Module::end]. *)
1257 external function_end : llmodule -> (llmodule, llvalue) llrev_pos
1258 = "llvm_function_end"
1260 (** [function_pred gv] returns the function list position preceding [After gv].
1261 See the method [llvm::Module::iterator::operator--]. *)
1262 external function_pred : llvalue -> (llmodule, llvalue) llrev_pos
1263 = "llvm_function_pred"
1265 (** [rev_iter_functions f fn] applies function [f] to each of the functions of
1266 module [m] in reverse order. Tail recursive. *)
1267 val rev_iter_functions : (llvalue -> unit) -> llmodule -> unit
1269 (** [fold_right_functions f m init] is [f (... (f init fN) ...) f1] where
1270 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1271 val fold_right_functions : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
1273 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
1274 See the method [llvm::Function::isIntrinsic]. *)
1275 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
1277 (** [function_call_conv f] returns the calling convention of the function [f].
1278 See the method [llvm::Function::getCallingConv]. *)
1279 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
1281 (** [set_function_call_conv cc f] sets the calling convention of the function
1282 [f] to the calling convention numbered [cc].
1283 See the method [llvm::Function::setCallingConv]. *)
1284 external set_function_call_conv : int -> llvalue -> unit
1285 = "llvm_set_function_call_conv"
1287 (** [gc f] returns [Some name] if the function [f] has a garbage
1288 collection algorithm specified and [None] otherwise.
1289 See the method [llvm::Function::getGC]. *)
1290 external gc : llvalue -> string option = "llvm_gc"
1292 (** [set_gc gc f] sets the collection algorithm for the function [f] to
1293 [gc]. See the method [llvm::Function::setGC]. *)
1294 external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
1296 (** [add_function_attr f a] adds attribute [a] to the return type of function
1298 val add_function_attr : llvalue -> Attribute.t -> unit
1300 (** [remove_function_attr f a] removes attribute [a] from the return type of
1302 val remove_function_attr : llvalue -> Attribute.t -> unit
1304 (** {7 Operations on params} *)
1306 (** [params f] returns the parameters of function [f].
1307 See the method [llvm::Function::getArgumentList]. *)
1308 external params : llvalue -> llvalue array = "llvm_params"
1310 (** [param f n] returns the [n]th parameter of function [f].
1311 See the method [llvm::Function::getArgumentList]. *)
1312 external param : llvalue -> int -> llvalue = "llvm_param"
1314 (** [param_parent p] returns the parent function that owns the parameter.
1315 See the method [llvm::Argument::getParent]. *)
1316 external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
1318 (** [param_begin f] returns the first position in the parameter list of the
1319 function [f]. [param_begin] and [param_succ] can be used to iterate over
1320 the parameter list in order.
1321 See the method [llvm::Function::arg_begin]. *)
1322 external param_begin : llvalue -> (llvalue, llvalue) llpos = "llvm_param_begin"
1324 (** [param_succ bb] returns the parameter list position succeeding
1326 See the method [llvm::Function::arg_iterator::operator++]. *)
1327 external param_succ : llvalue -> (llvalue, llvalue) llpos = "llvm_param_succ"
1329 (** [iter_params f fn] applies function [f] to each of the parameters
1330 of function [fn] in order. Tail recursive. *)
1331 val iter_params : (llvalue -> unit) -> llvalue -> unit
1333 (** [fold_left_params f init fn] is [f (... (f init b1) ...) bN] where
1334 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1335 val fold_left_params : ('a -> llvalue -> 'a) -> 'a -> llvalue -> 'a
1337 (** [param_end f] returns the last position in the parameter list of
1338 the function [f]. [param_end] and [param_pred] can be used to iterate
1339 over the parameter list in reverse.
1340 See the method [llvm::Function::arg_end]. *)
1341 external param_end : llvalue -> (llvalue, llvalue) llrev_pos = "llvm_param_end"
1343 (** [param_pred gv] returns the function list position preceding [After gv].
1344 See the method [llvm::Function::arg_iterator::operator--]. *)
1345 external param_pred : llvalue -> (llvalue, llvalue) llrev_pos
1348 (** [rev_iter_params f fn] applies function [f] to each of the parameters
1349 of function [fn] in reverse order. Tail recursive. *)
1350 val rev_iter_params : (llvalue -> unit) -> llvalue -> unit
1352 (** [fold_right_params f fn init] is [f (... (f init bN) ...) b1] where
1353 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1354 val fold_right_params : (llvalue -> 'a -> 'a) -> llvalue -> 'a -> 'a
1356 (** [add_param p a] adds attribute [a] to parameter [p]. *)
1357 val add_param_attr : llvalue -> Attribute.t -> unit
1359 (** [remove_param_attr p a] removes attribute [a] from parameter [p]. *)
1360 val remove_param_attr : llvalue -> Attribute.t -> unit
1362 (** [set_param_alignment p a] set the alignment of parameter [p] to [a]. *)
1363 external set_param_alignment : llvalue -> int -> unit
1364 = "llvm_set_param_alignment"
1366 (** {7 Operations on basic blocks} *)
1368 (** [basic_blocks fn] returns the basic blocks of the function [f].
1369 See the method [llvm::Function::getBasicBlockList]. *)
1370 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
1372 (** [entry_block fn] returns the entry basic block of the function [f].
1373 See the method [llvm::Function::getEntryBlock]. *)
1374 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
1376 (** [delete_block bb] deletes the basic block [bb].
1377 See the method [llvm::BasicBlock::eraseFromParent]. *)
1378 external delete_block : llbasicblock -> unit = "llvm_delete_block"
1380 (** [append_block c name f] creates a new basic block named [name] at the end of
1381 function [f] in the context [c].
1382 See the constructor of [llvm::BasicBlock]. *)
1383 external append_block : llcontext -> string -> llvalue -> llbasicblock
1384 = "llvm_append_block"
1386 (** [insert_block c name bb] creates a new basic block named [name] before the
1387 basic block [bb] in the context [c].
1388 See the constructor of [llvm::BasicBlock]. *)
1389 external insert_block : llcontext -> string -> llbasicblock -> llbasicblock
1390 = "llvm_insert_block"
1392 (** [block_parent bb] returns the parent function that owns the basic block.
1393 See the method [llvm::BasicBlock::getParent]. *)
1394 external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
1396 (** [block_begin f] returns the first position in the basic block list of the
1397 function [f]. [block_begin] and [block_succ] can be used to iterate over
1398 the basic block list in order.
1399 See the method [llvm::Function::begin]. *)
1400 external block_begin : llvalue -> (llvalue, llbasicblock) llpos
1401 = "llvm_block_begin"
1403 (** [block_succ bb] returns the basic block list position succeeding
1405 See the method [llvm::Function::iterator::operator++]. *)
1406 external block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
1409 (** [iter_blocks f fn] applies function [f] to each of the basic blocks
1410 of function [fn] in order. Tail recursive. *)
1411 val iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1413 (** [fold_left_blocks f init fn] is [f (... (f init b1) ...) bN] where
1414 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1415 val fold_left_blocks : ('a -> llbasicblock -> 'a) -> 'a -> llvalue -> 'a
1417 (** [block_end f] returns the last position in the basic block list of
1418 the function [f]. [block_end] and [block_pred] can be used to iterate
1419 over the basic block list in reverse.
1420 See the method [llvm::Function::end]. *)
1421 external block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
1424 (** [block_pred gv] returns the function list position preceding [After gv].
1425 See the method [llvm::Function::iterator::operator--]. *)
1426 external block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
1429 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
1430 of function [fn] in reverse order. Tail recursive. *)
1431 val rev_iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1433 (** [fold_right_blocks f fn init] is [f (... (f init bN) ...) b1] where
1434 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1435 val fold_right_blocks : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
1437 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
1438 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
1440 (** [value_is_block v] returns [true] if the value [v] is a basic block and
1442 Similar to [llvm::isa<BasicBlock>]. *)
1443 external value_is_block : llvalue -> bool = "llvm_value_is_block"
1445 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
1446 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
1449 (** {7 Operations on instructions} *)
1451 (** [instr_parent i] is the enclosing basic block of the instruction [i].
1452 See the method [llvm::Instruction::getParent]. *)
1453 external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
1455 (** [instr_begin bb] returns the first position in the instruction list of the
1456 basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
1457 the instruction list in order.
1458 See the method [llvm::BasicBlock::begin]. *)
1459 external instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
1460 = "llvm_instr_begin"
1462 (** [instr_succ i] returns the instruction list position succeeding [Before i].
1463 See the method [llvm::BasicBlock::iterator::operator++]. *)
1464 external instr_succ : llvalue -> (llbasicblock, llvalue) llpos
1467 (** [iter_instrs f bb] applies function [f] to each of the instructions of basic
1468 block [bb] in order. Tail recursive. *)
1469 val iter_instrs: (llvalue -> unit) -> llbasicblock -> unit
1471 (** [fold_left_instrs f init bb] is [f (... (f init g1) ...) gN] where
1472 [g1,...,gN] are the instructions of basic block [bb]. Tail recursive. *)
1473 val fold_left_instrs: ('a -> llvalue -> 'a) -> 'a -> llbasicblock -> 'a
1475 (** [instr_end bb] returns the last position in the instruction list of the
1476 basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
1477 the instruction list in reverse.
1478 See the method [llvm::BasicBlock::end]. *)
1479 external instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
1482 (** [instr_pred i] returns the instruction list position preceding [After i].
1483 See the method [llvm::BasicBlock::iterator::operator--]. *)
1484 external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
1487 (** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
1488 [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
1489 val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a
1492 (** {7 Operations on call sites} *)
1494 (** [instruction_call_conv ci] is the calling convention for the call or invoke
1495 instruction [ci], which may be one of the values from the module
1496 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
1497 [llvm::InvokeInst::getCallingConv]. *)
1498 external instruction_call_conv: llvalue -> int
1499 = "llvm_instruction_call_conv"
1501 (** [set_instruction_call_conv cc ci] sets the calling convention for the call
1502 or invoke instruction [ci] to the integer [cc], which can be one of the
1503 values from the module {!CallConv}.
1504 See the method [llvm::CallInst::setCallingConv]
1505 and [llvm::InvokeInst::setCallingConv]. *)
1506 external set_instruction_call_conv: int -> llvalue -> unit
1507 = "llvm_set_instruction_call_conv"
1509 (** [add_instruction_param_attr ci i a] adds attribute [a] to the [i]th
1510 parameter of the call or invoke instruction [ci]. [i]=0 denotes the return
1512 val add_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1514 (** [remove_instruction_param_attr ci i a] removes attribute [a] from the
1515 [i]th parameter of the call or invoke instruction [ci]. [i]=0 denotes the
1517 val remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1519 (** {Operations on call instructions (only)} *)
1521 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
1522 eligible for tail call optimization, [false] otherwise.
1523 See the method [llvm::CallInst::isTailCall]. *)
1524 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
1526 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
1527 call optimization if [tc] is [true], clears otherwise.
1528 See the method [llvm::CallInst::setTailCall]. *)
1529 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
1531 (** {7 Operations on phi nodes} *)
1533 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
1534 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
1535 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
1536 = "llvm_add_incoming"
1538 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
1539 See the method [llvm::PHINode::getIncomingValue]. *)
1540 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
1544 (** {6 Instruction builders} *)
1546 (** [builder context] creates an instruction builder with no position in
1547 the context [context]. It is invalid to use this builder until its position
1548 is set with {!position_before} or {!position_at_end}. See the constructor
1549 for [llvm::LLVMBuilder]. *)
1550 external builder : llcontext -> llbuilder = "llvm_builder"
1552 (** [builder_at ip] creates an instruction builder positioned at [ip].
1553 See the constructor for [llvm::LLVMBuilder]. *)
1554 val builder_at : llcontext -> (llbasicblock, llvalue) llpos -> llbuilder
1556 (** [builder_before ins] creates an instruction builder positioned before the
1557 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
1558 val builder_before : llcontext -> llvalue -> llbuilder
1560 (** [builder_at_end bb] creates an instruction builder positioned at the end of
1561 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
1562 val builder_at_end : llcontext -> llbasicblock -> llbuilder
1564 (** [position_builder ip bb] moves the instruction builder [bb] to the position
1566 See the constructor for [llvm::LLVMBuilder]. *)
1567 external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
1568 = "llvm_position_builder"
1570 (** [position_before ins b] moves the instruction builder [b] to before the
1571 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1572 val position_before : llvalue -> llbuilder -> unit
1574 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
1575 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1576 val position_at_end : llbasicblock -> llbuilder -> unit
1578 (** [insertion_block b] returns the basic block that the builder [b] is
1579 positioned to insert into. Raises [Not_Found] if the instruction builder is
1581 See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
1582 external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
1584 (** [insert_into_builder i name b] inserts the specified instruction [i] at the
1585 position specified by the instruction builder [b].
1586 See the method [llvm::LLVMBuilder::Insert]. *)
1587 external insert_into_builder : llvalue -> string -> llbuilder -> unit
1588 = "llvm_insert_into_builder"
1592 (** [set_current_debug_location b md] sets the current debug location [md] in
1594 See the method [llvm::IRBuilder::SetDebugLocation]. *)
1595 external set_current_debug_location : llbuilder -> llvalue -> unit
1596 = "llvm_set_current_debug_location"
1598 (** [clear_current_debug_location b] clears the current debug location in the
1600 external clear_current_debug_location : llbuilder -> unit
1601 = "llvm_clear_current_debug_location"
1603 (** [current_debug_location b] returns the current debug location, or None
1604 if none is currently set.
1605 See the method [llvm::IRBuilder::GetDebugLocation]. *)
1606 external current_debug_location : llbuilder -> llvalue option
1607 = "llvm_current_debug_location"
1609 (** [set_inst_debug_location b i] sets the current debug location of the builder
1610 [b] to the instruction [i].
1611 See the method [llvm::IRBuilder::SetInstDebugLocation]. *)
1612 external set_inst_debug_location : llbuilder -> llvalue -> unit
1613 = "llvm_set_inst_debug_location"
1615 (** {7 Terminators} *)
1617 (** [build_ret_void b] creates a
1619 instruction at the position specified by the instruction builder [b].
1620 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
1621 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
1623 (** [build_ret v b] creates a
1625 instruction at the position specified by the instruction builder [b].
1626 See the method [llvm::LLVMBuilder::CreateRet]. *)
1627 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
1629 (** [build_aggregate_ret vs b] creates a
1630 [ret {...} { %v1, %v2, ... } ]
1631 instruction at the position specified by the instruction builder [b].
1632 See the method [llvm::LLVMBuilder::CreateAggregateRet]. *)
1633 external build_aggregate_ret : llvalue array -> llbuilder -> llvalue
1634 = "llvm_build_aggregate_ret"
1636 (** [build_br bb b] creates a
1638 instruction at the position specified by the instruction builder [b].
1639 See the method [llvm::LLVMBuilder::CreateBr]. *)
1640 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
1642 (** [build_cond_br cond tbb fbb b] creates a
1643 [br %cond, %tbb, %fbb]
1644 instruction at the position specified by the instruction builder [b].
1645 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
1646 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
1647 llvalue = "llvm_build_cond_br"
1649 (** [build_switch case elsebb count b] creates an empty
1650 [switch %case, %elsebb]
1651 instruction at the position specified by the instruction builder [b] with
1652 space reserved for [count] cases.
1653 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
1654 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
1655 = "llvm_build_switch"
1657 (** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
1658 when its input matches the constant [onval].
1659 See the method [llvm::SwitchInst::addCase]. **)
1660 external add_case : llvalue -> llvalue -> llbasicblock -> unit
1663 (** [build_indirect_br addr count b] creates a
1665 instruction at the position specified by the instruction builder [b] with
1666 space reserved for [count] destinations.
1667 See the method [llvm::LLVMBuilder::CreateIndirectBr]. *)
1668 external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
1669 = "llvm_build_indirect_br"
1671 (** [add_destination br bb] adds the basic block [bb] as a possible branch
1672 location for the indirectbr instruction [br].
1673 See the method [llvm::IndirectBrInst::addDestination]. **)
1674 external add_destination : llvalue -> llbasicblock -> unit
1675 = "llvm_add_destination"
1677 (** [build_invoke fn args tobb unwindbb name b] creates an
1678 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
1679 instruction at the position specified by the instruction builder [b].
1680 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
1681 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
1682 llbasicblock -> string -> llbuilder -> llvalue
1683 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
1685 (** [build_unwind b] creates an
1687 instruction at the position specified by the instruction builder [b].
1688 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1689 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
1691 (** [build_unreachable b] creates an
1693 instruction at the position specified by the instruction builder [b].
1694 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1695 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
1698 (** {7 Arithmetic} *)
1700 (** [build_add x y name b] creates a
1701 [%name = add %x, %y]
1702 instruction at the position specified by the instruction builder [b].
1703 See the method [llvm::LLVMBuilder::CreateAdd]. *)
1704 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1707 (** [build_nsw_add x y name b] creates a
1708 [%name = nsw add %x, %y]
1709 instruction at the position specified by the instruction builder [b].
1710 See the method [llvm::LLVMBuilder::CreateNSWAdd]. *)
1711 external build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1712 = "llvm_build_nsw_add"
1714 (** [build_nuw_add x y name b] creates a
1715 [%name = nuw add %x, %y]
1716 instruction at the position specified by the instruction builder [b].
1717 See the method [llvm::LLVMBuilder::CreateNUWAdd]. *)
1718 external build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1719 = "llvm_build_nuw_add"
1721 (** [build_fadd x y name b] creates a
1722 [%name = fadd %x, %y]
1723 instruction at the position specified by the instruction builder [b].
1724 See the method [llvm::LLVMBuilder::CreateFAdd]. *)
1725 external build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
1728 (** [build_sub x y name b] creates a
1729 [%name = sub %x, %y]
1730 instruction at the position specified by the instruction builder [b].
1731 See the method [llvm::LLVMBuilder::CreateSub]. *)
1732 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1735 (** [build_nsw_sub x y name b] creates a
1736 [%name = nsw sub %x, %y]
1737 instruction at the position specified by the instruction builder [b].
1738 See the method [llvm::LLVMBuilder::CreateNSWSub]. *)
1739 external build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1740 = "llvm_build_nsw_sub"
1742 (** [build_nuw_sub x y name b] creates a
1743 [%name = nuw sub %x, %y]
1744 instruction at the position specified by the instruction builder [b].
1745 See the method [llvm::LLVMBuilder::CreateNUWSub]. *)
1746 external build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1747 = "llvm_build_nuw_sub"
1749 (** [build_fsub x y name b] creates a
1750 [%name = fsub %x, %y]
1751 instruction at the position specified by the instruction builder [b].
1752 See the method [llvm::LLVMBuilder::CreateFSub]. *)
1753 external build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1756 (** [build_mul x y name b] creates a
1757 [%name = mul %x, %y]
1758 instruction at the position specified by the instruction builder [b].
1759 See the method [llvm::LLVMBuilder::CreateMul]. *)
1760 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1763 (** [build_nsw_mul x y name b] creates a
1764 [%name = nsw mul %x, %y]
1765 instruction at the position specified by the instruction builder [b].
1766 See the method [llvm::LLVMBuilder::CreateNSWMul]. *)
1767 external build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1768 = "llvm_build_nsw_mul"
1770 (** [build_nuw_mul x y name b] creates a
1771 [%name = nuw mul %x, %y]
1772 instruction at the position specified by the instruction builder [b].
1773 See the method [llvm::LLVMBuilder::CreateNUWMul]. *)
1774 external build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1775 = "llvm_build_nuw_mul"
1777 (** [build_fmul x y name b] creates a
1778 [%name = fmul %x, %y]
1779 instruction at the position specified by the instruction builder [b].
1780 See the method [llvm::LLVMBuilder::CreateFMul]. *)
1781 external build_fmul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1784 (** [build_udiv x y name b] creates a
1785 [%name = udiv %x, %y]
1786 instruction at the position specified by the instruction builder [b].
1787 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
1788 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1791 (** [build_sdiv x y name b] creates a
1792 [%name = sdiv %x, %y]
1793 instruction at the position specified by the instruction builder [b].
1794 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
1795 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1798 (** [build_exact_sdiv x y name b] creates a
1799 [%name = exact sdiv %x, %y]
1800 instruction at the position specified by the instruction builder [b].
1801 See the method [llvm::LLVMBuilder::CreateExactSDiv]. *)
1802 external build_exact_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1803 = "llvm_build_exact_sdiv"
1805 (** [build_fdiv x y name b] creates a
1806 [%name = fdiv %x, %y]
1807 instruction at the position specified by the instruction builder [b].
1808 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
1809 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1812 (** [build_urem x y name b] creates a
1813 [%name = urem %x, %y]
1814 instruction at the position specified by the instruction builder [b].
1815 See the method [llvm::LLVMBuilder::CreateURem]. *)
1816 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1819 (** [build_SRem x y name b] creates a
1820 [%name = srem %x, %y]
1821 instruction at the position specified by the instruction builder [b].
1822 See the method [llvm::LLVMBuilder::CreateSRem]. *)
1823 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1826 (** [build_frem x y name b] creates a
1827 [%name = frem %x, %y]
1828 instruction at the position specified by the instruction builder [b].
1829 See the method [llvm::LLVMBuilder::CreateFRem]. *)
1830 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1833 (** [build_shl x y name b] creates a
1834 [%name = shl %x, %y]
1835 instruction at the position specified by the instruction builder [b].
1836 See the method [llvm::LLVMBuilder::CreateShl]. *)
1837 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1840 (** [build_lshr x y name b] creates a
1841 [%name = lshr %x, %y]
1842 instruction at the position specified by the instruction builder [b].
1843 See the method [llvm::LLVMBuilder::CreateLShr]. *)
1844 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1847 (** [build_ashr x y name b] creates a
1848 [%name = ashr %x, %y]
1849 instruction at the position specified by the instruction builder [b].
1850 See the method [llvm::LLVMBuilder::CreateAShr]. *)
1851 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1854 (** [build_and x y name b] creates a
1855 [%name = and %x, %y]
1856 instruction at the position specified by the instruction builder [b].
1857 See the method [llvm::LLVMBuilder::CreateAnd]. *)
1858 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1861 (** [build_or x y name b] creates a
1863 instruction at the position specified by the instruction builder [b].
1864 See the method [llvm::LLVMBuilder::CreateOr]. *)
1865 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1868 (** [build_xor x y name b] creates a
1869 [%name = xor %x, %y]
1870 instruction at the position specified by the instruction builder [b].
1871 See the method [llvm::LLVMBuilder::CreateXor]. *)
1872 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1875 (** [build_neg x name b] creates a
1877 instruction at the position specified by the instruction builder [b].
1878 [-0.0] is used for floating point types to compute the correct sign.
1879 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1880 external build_neg : llvalue -> string -> llbuilder -> llvalue
1883 (** [build_nsw_neg x name b] creates a
1884 [%name = nsw sub 0, %x]
1885 instruction at the position specified by the instruction builder [b].
1886 [-0.0] is used for floating point types to compute the correct sign.
1887 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1888 external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
1889 = "llvm_build_nsw_neg"
1891 (** [build_nuw_neg x name b] creates a
1892 [%name = nuw sub 0, %x]
1893 instruction at the position specified by the instruction builder [b].
1894 [-0.0] is used for floating point types to compute the correct sign.
1895 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1896 external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
1897 = "llvm_build_nuw_neg"
1899 (** [build_fneg x name b] creates a
1900 [%name = fsub 0, %x]
1901 instruction at the position specified by the instruction builder [b].
1902 [-0.0] is used for floating point types to compute the correct sign.
1903 See the method [llvm::LLVMBuilder::CreateFNeg]. *)
1904 external build_fneg : llvalue -> string -> llbuilder -> llvalue
1907 (** [build_xor x name b] creates a
1908 [%name = xor %x, -1]
1909 instruction at the position specified by the instruction builder [b].
1910 [-1] is the correct "all ones" value for the type of [x].
1911 See the method [llvm::LLVMBuilder::CreateXor]. *)
1912 external build_not : llvalue -> string -> llbuilder -> llvalue
1918 (** [build_alloca ty name b] creates a
1919 [%name = alloca %ty]
1920 instruction at the position specified by the instruction builder [b].
1921 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1922 external build_alloca : lltype -> string -> llbuilder -> llvalue
1923 = "llvm_build_alloca"
1925 (** [build_array_alloca ty n name b] creates a
1926 [%name = alloca %ty, %n]
1927 instruction at the position specified by the instruction builder [b].
1928 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1929 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1930 llvalue = "llvm_build_array_alloca"
1932 (** [build_load v name b] creates a
1934 instruction at the position specified by the instruction builder [b].
1935 See the method [llvm::LLVMBuilder::CreateLoad]. *)
1936 external build_load : llvalue -> string -> llbuilder -> llvalue
1939 (** [build_store v p b] creates a
1941 instruction at the position specified by the instruction builder [b].
1942 See the method [llvm::LLVMBuilder::CreateStore]. *)
1943 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1944 = "llvm_build_store"
1946 (** [build_gep p indices name b] creates a
1947 [%name = getelementptr %p, indices...]
1948 instruction at the position specified by the instruction builder [b].
1949 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
1950 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1953 (** [build_in_bounds_gep p indices name b] creates a
1954 [%name = gelementptr inbounds %p, indices...]
1955 instruction at the position specified by the instruction builder [b].
1956 See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
1957 external build_in_bounds_gep : llvalue -> llvalue array -> string -> llbuilder ->
1958 llvalue = "llvm_build_in_bounds_gep"
1960 (** [build_struct_gep p idx name b] creates a
1961 [%name = getelementptr %p, 0, idx]
1962 instruction at the position specified by the instruction builder [b].
1963 See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
1964 external build_struct_gep : llvalue -> int -> string -> llbuilder ->
1965 llvalue = "llvm_build_struct_gep"
1967 (** [build_global_string str name b] creates a series of instructions that adds
1968 a global string at the position specified by the instruction builder [b].
1969 See the method [llvm::LLVMBuilder::CreateGlobalString]. *)
1970 external build_global_string : string -> string -> llbuilder -> llvalue
1971 = "llvm_build_global_string"
1973 (** [build_global_stringptr str name b] creates a series of instructions that
1974 adds a global string pointer at the position specified by the instruction
1976 See the method [llvm::LLVMBuilder::CreateGlobalStringPtr]. *)
1977 external build_global_stringptr : string -> string -> llbuilder -> llvalue
1978 = "llvm_build_global_stringptr"
1983 (** [build_trunc v ty name b] creates a
1984 [%name = trunc %p to %ty]
1985 instruction at the position specified by the instruction builder [b].
1986 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
1987 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1988 = "llvm_build_trunc"
1990 (** [build_zext v ty name b] creates a
1991 [%name = zext %p to %ty]
1992 instruction at the position specified by the instruction builder [b].
1993 See the method [llvm::LLVMBuilder::CreateZExt]. *)
1994 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1997 (** [build_sext v ty name b] creates a
1998 [%name = sext %p to %ty]
1999 instruction at the position specified by the instruction builder [b].
2000 See the method [llvm::LLVMBuilder::CreateSExt]. *)
2001 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
2004 (** [build_fptoui v ty name b] creates a
2005 [%name = fptoui %p to %ty]
2006 instruction at the position specified by the instruction builder [b].
2007 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
2008 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
2009 = "llvm_build_fptoui"
2011 (** [build_fptosi v ty name b] creates a
2012 [%name = fptosi %p to %ty]
2013 instruction at the position specified by the instruction builder [b].
2014 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
2015 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
2016 = "llvm_build_fptosi"
2018 (** [build_uitofp v ty name b] creates a
2019 [%name = uitofp %p to %ty]
2020 instruction at the position specified by the instruction builder [b].
2021 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
2022 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2023 = "llvm_build_uitofp"
2025 (** [build_sitofp v ty name b] creates a
2026 [%name = sitofp %p to %ty]
2027 instruction at the position specified by the instruction builder [b].
2028 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
2029 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
2030 = "llvm_build_sitofp"
2032 (** [build_fptrunc v ty name b] creates a
2033 [%name = fptrunc %p to %ty]
2034 instruction at the position specified by the instruction builder [b].
2035 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
2036 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
2037 = "llvm_build_fptrunc"
2039 (** [build_fpext v ty name b] creates a
2040 [%name = fpext %p to %ty]
2041 instruction at the position specified by the instruction builder [b].
2042 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
2043 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
2044 = "llvm_build_fpext"
2046 (** [build_ptrtoint v ty name b] creates a
2047 [%name = prtotint %p to %ty]
2048 instruction at the position specified by the instruction builder [b].
2049 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
2050 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
2051 = "llvm_build_prttoint"
2053 (** [build_inttoptr v ty name b] creates a
2054 [%name = inttoptr %p to %ty]
2055 instruction at the position specified by the instruction builder [b].
2056 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
2057 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
2058 = "llvm_build_inttoptr"
2060 (** [build_bitcast v ty name b] creates a
2061 [%name = bitcast %p to %ty]
2062 instruction at the position specified by the instruction builder [b].
2063 See the method [llvm::LLVMBuilder::CreateBitCast]. *)
2064 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2065 = "llvm_build_bitcast"
2067 (** [build_zext_or_bitcast v ty name b] creates a zext or bitcast
2068 instruction at the position specified by the instruction builder [b].
2069 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2070 external build_zext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2071 llvalue = "llvm_build_zext_or_bitcast"
2073 (** [build_sext_or_bitcast v ty name b] creates a sext or bitcast
2074 instruction at the position specified by the instruction builder [b].
2075 See the method [llvm::LLVMBuilder::CreateSExtOrBitCast]. *)
2076 external build_sext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2077 llvalue = "llvm_build_sext_or_bitcast"
2079 (** [build_trunc_or_bitcast v ty name b] creates a trunc or bitcast
2080 instruction at the position specified by the instruction builder [b].
2081 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2082 external build_trunc_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2083 llvalue = "llvm_build_trunc_or_bitcast"
2085 (** [build_pointercast v ty name b] creates a bitcast or pointer-to-int
2086 instruction at the position specified by the instruction builder [b].
2087 See the method [llvm::LLVMBuilder::CreatePointerCast]. *)
2088 external build_pointercast : llvalue -> lltype -> string -> llbuilder -> llvalue
2089 = "llvm_build_pointercast"
2091 (** [build_intcast v ty name b] creates a zext, bitcast, or trunc
2092 instruction at the position specified by the instruction builder [b].
2093 See the method [llvm::LLVMBuilder::CreateIntCast]. *)
2094 external build_intcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2095 = "llvm_build_intcast"
2097 (** [build_fpcast v ty name b] creates a fpext, bitcast, or fptrunc
2098 instruction at the position specified by the instruction builder [b].
2099 See the method [llvm::LLVMBuilder::CreateFPCast]. *)
2100 external build_fpcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2101 = "llvm_build_fpcast"
2104 (** {7 Comparisons} *)
2106 (** [build_icmp pred x y name b] creates a
2107 [%name = icmp %pred %x, %y]
2108 instruction at the position specified by the instruction builder [b].
2109 See the method [llvm::LLVMBuilder::CreateICmp]. *)
2110 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
2111 llbuilder -> llvalue = "llvm_build_icmp"
2113 (** [build_fcmp pred x y name b] creates a
2114 [%name = fcmp %pred %x, %y]
2115 instruction at the position specified by the instruction builder [b].
2116 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
2117 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
2118 llbuilder -> llvalue = "llvm_build_fcmp"
2121 (** {7 Miscellaneous instructions} *)
2123 (** [build_phi incoming name b] creates a
2124 [%name = phi %incoming]
2125 instruction at the position specified by the instruction builder [b].
2126 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
2127 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2128 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
2129 llvalue = "llvm_build_phi"
2131 (** [build_call fn args name b] creates a
2132 [%name = call %fn(args...)]
2133 instruction at the position specified by the instruction builder [b].
2134 See the method [llvm::LLVMBuilder::CreateCall]. *)
2135 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2138 (** [build_select cond thenv elsev name b] creates a
2139 [%name = select %cond, %thenv, %elsev]
2140 instruction at the position specified by the instruction builder [b].
2141 See the method [llvm::LLVMBuilder::CreateSelect]. *)
2142 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
2143 llvalue = "llvm_build_select"
2145 (** [build_va_arg valist argty name b] creates a
2146 [%name = va_arg %valist, %argty]
2147 instruction at the position specified by the instruction builder [b].
2148 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
2149 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
2150 = "llvm_build_va_arg"
2152 (** [build_extractelement vec i name b] creates a
2153 [%name = extractelement %vec, %i]
2154 instruction at the position specified by the instruction builder [b].
2155 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
2156 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
2157 llvalue = "llvm_build_extractelement"
2159 (** [build_insertelement vec elt i name b] creates a
2160 [%name = insertelement %vec, %elt, %i]
2161 instruction at the position specified by the instruction builder [b].
2162 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
2163 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
2164 llbuilder -> llvalue = "llvm_build_insertelement"
2166 (** [build_shufflevector veca vecb mask name b] creates a
2167 [%name = shufflevector %veca, %vecb, %mask]
2168 instruction at the position specified by the instruction builder [b].
2169 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
2170 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
2171 llbuilder -> llvalue = "llvm_build_shufflevector"
2173 (** [build_insertvalue agg idx name b] creates a
2174 [%name = extractvalue %agg, %idx]
2175 instruction at the position specified by the instruction builder [b].
2176 See the method [llvm::LLVMBuilder::CreateExtractValue]. *)
2177 external build_extractvalue : llvalue -> int -> string -> llbuilder -> llvalue
2178 = "llvm_build_extractvalue"
2180 (** [build_insertvalue agg val idx name b] creates a
2181 [%name = insertvalue %agg, %val, %idx]
2182 instruction at the position specified by the instruction builder [b].
2183 See the method [llvm::LLVMBuilder::CreateInsertValue]. *)
2184 external build_insertvalue : llvalue -> llvalue -> int -> string -> llbuilder ->
2185 llvalue = "llvm_build_insertvalue"
2187 (** [build_is_null val name b] creates a
2188 [%name = icmp eq %val, null]
2189 instruction at the position specified by the instruction builder [b].
2190 See the method [llvm::LLVMBuilder::CreateIsNull]. *)
2191 external build_is_null : llvalue -> string -> llbuilder -> llvalue
2192 = "llvm_build_is_null"
2194 (** [build_is_not_null val name b] creates a
2195 [%name = icmp ne %val, null]
2196 instruction at the position specified by the instruction builder [b].
2197 See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
2198 external build_is_not_null : llvalue -> string -> llbuilder -> llvalue
2199 = "llvm_build_is_not_null"
2201 (** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure
2202 the difference between two pointer values at the position specified by the
2203 instruction builder [b].
2204 See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2205 external build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
2206 = "llvm_build_ptrdiff"
2209 (** {6 Memory buffers} *)
2211 module MemoryBuffer : sig
2212 (** [of_file p] is the memory buffer containing the contents of the file at
2213 path [p]. If the file could not be read, then [IoError msg] is
2215 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
2217 (** [stdin ()] is the memory buffer containing the contents of standard input.
2218 If standard input is empty, then [IoError msg] is raised. *)
2219 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
2221 (** Disposes of a memory buffer. *)
2222 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
2226 (** {6 Pass Managers} *)
2228 module PassManager : sig
2231 type any = [ `Module | `Function ]
2233 (** [PassManager.create ()] constructs a new whole-module pass pipeline. This
2234 type of pipeline is suitable for link-time optimization and whole-module
2236 See the constructor of [llvm::PassManager]. *)
2237 external create : unit -> [ `Module ] t = "llvm_passmanager_create"
2239 (** [PassManager.create_function m] constructs a new function-by-function
2240 pass pipeline over the module [m]. It does not take ownership of [m].
2241 This type of pipeline is suitable for code generation and JIT compilation
2243 See the constructor of [llvm::FunctionPassManager]. *)
2244 external create_function : llmodule -> [ `Function ] t
2245 = "LLVMCreateFunctionPassManager"
2247 (** [run_module m pm] initializes, executes on the module [m], and finalizes
2248 all of the passes scheduled in the pass manager [pm]. Returns [true] if
2249 any of the passes modified the module, [false] otherwise.
2250 See the [llvm::PassManager::run] method. *)
2251 external run_module : llmodule -> [ `Module ] t -> bool
2252 = "llvm_passmanager_run_module"
2254 (** [initialize fpm] initializes all of the function passes scheduled in the
2255 function pass manager [fpm]. Returns [true] if any of the passes modified
2256 the module, [false] otherwise.
2257 See the [llvm::FunctionPassManager::doInitialization] method. *)
2258 external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize"
2260 (** [run_function f fpm] executes all of the function passes scheduled in the
2261 function pass manager [fpm] over the function [f]. Returns [true] if any
2262 of the passes modified [f], [false] otherwise.
2263 See the [llvm::FunctionPassManager::run] method. *)
2264 external run_function : llvalue -> [ `Function ] t -> bool
2265 = "llvm_passmanager_run_function"
2267 (** [finalize fpm] finalizes all of the function passes scheduled in in the
2268 function pass manager [fpm]. Returns [true] if any of the passes
2269 modified the module, [false] otherwise.
2270 See the [llvm::FunctionPassManager::doFinalization] method. *)
2271 external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize"
2273 (** Frees the memory of a pass pipeline. For function pipelines, does not free
2275 See the destructor of [llvm::BasePassManager]. *)
2276 external dispose : [< any ] t -> unit = "llvm_passmanager_dispose"