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 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
45 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
49 (** Used to provide a module to JIT or interpreter.
50 See the [llvm::ModuleProvider] class. *)
53 (** Used to efficiently handle large buffers of read-only binary data.
54 See the [llvm::MemoryBuffer] class. *)
57 (** The kind of an [lltype], the result of [classify_type ty]. See the
58 [llvm::Type::TypeID] enumeration. *)
79 (** The linkage of a global value, accessed with {!linkage} and
80 {!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
84 | Available_externally
100 (** The linker visibility of a global value, accessed with {!visibility} and
101 {!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
102 module Visibility : sig
109 (** The following calling convention values may be accessed with
110 {!function_call_conv} and {!set_function_call_conv}. Calling
111 conventions are open-ended. *)
112 module CallConv : sig
113 val c : int (** [c] is the C calling convention. *)
114 val fast : int (** [fast] is the calling convention to allow LLVM
115 maximum optimization opportunities. Use only with
117 val cold : int (** [cold] is the calling convention for
119 val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
120 convention from C. *)
121 val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
122 convention from C. *)
125 module Attribute : sig
150 (** The predicate for an integer comparison ([icmp]) instruction.
151 See the [llvm::ICmpInst::Predicate] enumeration. *)
166 (** The predicate for a floating-point comparison ([fcmp]) instruction.
167 See the [llvm::FCmpInst::Predicate] enumeration. *)
191 (** [Before b] and [At_end a] specify positions from the start of the ['b] list
192 of [a]. [llpos] is used to specify positions in and for forward iteration
193 through the various value lists maintained by the LLVM IR. *)
194 type ('a, 'b) llpos =
198 (** [After b] and [At_start a] specify positions from the end of the ['b] list
199 of [a]. [llrev_pos] is used for reverse iteration through the various value
200 lists maintained by the LLVM IR. *)
201 type ('a, 'b) llrev_pos =
206 (** {6 Exceptions} *)
208 exception IoError of string
213 (** [create_context ()] creates a context for storing the "global" state in
214 LLVM. See the constructor [llvm::LLVMContext]. *)
215 external create_context : unit -> llcontext = "llvm_create_context"
217 (** [destroy_context ()] destroys a context. See the destructor
218 [llvm::LLVMContext::~LLVMContext]. *)
219 external dispose_context : llcontext -> unit = "llvm_dispose_context"
221 (** See the function [llvm::getGlobalContext]. *)
222 external global_context : unit -> llcontext = "llvm_global_context"
224 (** [mdkind_id context name] returns the MDKind ID that corresponds to the
225 name [name] in the context [context]. See the function
226 [llvm::LLVMContext::getMDKindID]. *)
227 external mdkind_id : llcontext -> string -> int = "llvm_mdkind_id"
232 (** [create_module context id] creates a module with the supplied module ID in
233 the context [context]. Modules are not garbage collected; it is mandatory
234 to call {!dispose_module} to free memory. See the constructor
235 [llvm::Module::Module]. *)
236 external create_module : llcontext -> string -> llmodule = "llvm_create_module"
238 (** [dispose_module m] destroys a module [m] and all of the IR objects it
239 contained. All references to subordinate objects are invalidated;
240 referencing them will invoke undefined behavior. See the destructor
241 [llvm::Module::~Module]. *)
242 external dispose_module : llmodule -> unit = "llvm_dispose_module"
244 (** [target_triple m] is the target specifier for the module [m], something like
245 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
246 external target_triple: llmodule -> string
247 = "llvm_target_triple"
249 (** [target_triple triple m] changes the target specifier for the module [m] to
250 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
251 external set_target_triple: string -> llmodule -> unit
252 = "llvm_set_target_triple"
254 (** [data_layout m] is the data layout specifier for the module [m], something
255 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
256 method [llvm::Module::getDataLayout]. *)
257 external data_layout: llmodule -> string
260 (** [set_data_layout s m] changes the data layout specifier for the module [m]
261 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
262 external set_data_layout: string -> llmodule -> unit
263 = "llvm_set_data_layout"
265 (** [define_type_name name ty m] adds a named type to the module's symbol table.
266 Returns [true] if successful. If such a name already exists, then no entry
267 is added and [false] is returned. See the [llvm::Module::addTypeName]
269 external define_type_name : string -> lltype -> llmodule -> bool
270 = "llvm_add_type_name"
272 (** [delete_type_name name] removes a type name from the module's symbol
274 external delete_type_name : string -> llmodule -> unit
275 = "llvm_delete_type_name"
277 (** [type_by_name m n] returns the type in the module [m] named [n], or [None]
278 if it does not exist. See the method [llvm::Module::getTypeByName]. *)
279 external type_by_name : llmodule -> string -> lltype option
280 = "llvm_type_by_name"
282 (** [dump_module m] prints the .ll representation of the module [m] to standard
283 error. See the method [llvm::Module::dump]. *)
284 external dump_module : llmodule -> unit = "llvm_dump_module"
289 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
290 See the method [llvm::Type::getTypeID]. *)
291 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
293 (** [type_context ty] returns the {!llcontext} corresponding to the type [ty].
294 See the method [llvm::Type::getContext]. *)
295 external type_context : lltype -> llcontext = "llvm_type_context"
297 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
298 val string_of_lltype : lltype -> string
300 (** {7 Operations on integer types} *)
302 (** [i1_type c] returns an integer type of bitwidth 1 in the context [c]. See
303 [llvm::Type::Int1Ty]. *)
304 external i1_type : llcontext -> lltype = "llvm_i1_type"
306 (** [i8_type c] returns an integer type of bitwidth 8 in the context [c]. See
307 [llvm::Type::Int8Ty]. *)
308 external i8_type : llcontext -> lltype = "llvm_i8_type"
310 (** [i16_type c] returns an integer type of bitwidth 16 in the context [c]. See
311 [llvm::Type::Int16Ty]. *)
312 external i16_type : llcontext -> lltype = "llvm_i16_type"
314 (** [i32_type c] returns an integer type of bitwidth 32 in the context [c]. See
315 [llvm::Type::Int32Ty]. *)
316 external i32_type : llcontext -> lltype = "llvm_i32_type"
318 (** [i64_type c] returns an integer type of bitwidth 64 in the context [c]. See
319 [llvm::Type::Int64Ty]. *)
320 external i64_type : llcontext -> lltype = "llvm_i64_type"
322 (** [integer_type c n] returns an integer type of bitwidth [n] in the context
323 [c]. See the method [llvm::IntegerType::get]. *)
324 external integer_type : llcontext -> int -> lltype = "llvm_integer_type"
326 (** [integer_bitwidth c ty] returns the number of bits in the integer type [ty]
327 in the context [c]. See the method [llvm::IntegerType::getBitWidth]. *)
328 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
331 (** {7 Operations on real types} *)
333 (** [float_type c] returns the IEEE 32-bit floating point type in the context
334 [c]. See [llvm::Type::FloatTy]. *)
335 external float_type : llcontext -> lltype = "llvm_float_type"
337 (** [double_type c] returns the IEEE 64-bit floating point type in the context
338 [c]. See [llvm::Type::DoubleTy]. *)
339 external double_type : llcontext -> lltype = "llvm_double_type"
341 (** [x86fp80_type c] returns the x87 80-bit floating point type in the context
342 [c]. See [llvm::Type::X86_FP80Ty]. *)
343 external x86fp80_type : llcontext -> lltype = "llvm_x86fp80_type"
345 (** [fp128_type c] returns the IEEE 128-bit floating point type in the context
346 [c]. See [llvm::Type::FP128Ty]. *)
347 external fp128_type : llcontext -> lltype = "llvm_fp128_type"
349 (** [ppc_fp128_type c] returns the PowerPC 128-bit floating point type in the
350 context [c]. See [llvm::Type::PPC_FP128Ty]. *)
351 external ppc_fp128_type : llcontext -> lltype = "llvm_ppc_fp128_type"
354 (** {7 Operations on function types} *)
356 (** [function_type ret_ty param_tys] returns the function type returning
357 [ret_ty] and taking [param_tys] as parameters.
358 See the method [llvm::FunctionType::get]. *)
359 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
361 (** [va_arg_function_type ret_ty param_tys] is just like
362 [function_type ret_ty param_tys] except that it returns the function type
363 which also takes a variable number of arguments.
364 See the method [llvm::FunctionType::get]. *)
365 external var_arg_function_type : lltype -> lltype array -> lltype
366 = "llvm_var_arg_function_type"
368 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
369 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
370 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
372 (** [return_type fty] gets the return type of the function type [fty].
373 See the method [llvm::FunctionType::getReturnType]. *)
374 external return_type : lltype -> lltype = "LLVMGetReturnType"
376 (** [param_types fty] gets the parameter types of the function type [fty].
377 See the method [llvm::FunctionType::getParamType]. *)
378 external param_types : lltype -> lltype array = "llvm_param_types"
381 (** {7 Operations on struct types} *)
383 (** [struct_type context tys] returns the structure type in the context
384 [context] containing in the types in the array [tys]. See the method
385 [llvm::StructType::get]. *)
386 external struct_type : llcontext -> lltype array -> lltype
389 (** [packed_struct_type context ys] returns the packed structure type in the
390 context [context] containing in the types in the array [tys]. See the method
391 [llvm::StructType::get]. *)
392 external packed_struct_type : llcontext -> lltype array -> lltype
393 = "llvm_packed_struct_type"
395 (** [struct_element_types sty] returns the constituent types of the struct type
396 [sty]. See the method [llvm::StructType::getElementType]. *)
397 external struct_element_types : lltype -> lltype array
398 = "llvm_struct_element_types"
400 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
401 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
402 external is_packed : lltype -> bool = "llvm_is_packed"
405 (** {7 Operations on union types} *)
407 (** [union_type context tys] returns the union type in the context [context]
408 containing the types in the array [tys]. See the method
409 [llvm::UnionType::get] *)
410 external union_type : llcontext -> lltype array -> lltype = "llvm_union_type"
412 (** [union_element_types uty] returns the constituent types of the union type
413 [uty]. See the method [llvm::UnionType::getElementType]. *)
414 external union_element_types : lltype -> lltype array
415 = "llvm_union_element_types"
418 (** {7 Operations on pointer, vector, and array types} *)
420 (** [array_type ty n] returns the array type containing [n] elements of type
421 [ty]. See the method [llvm::ArrayType::get]. *)
422 external array_type : lltype -> int -> lltype = "llvm_array_type"
424 (** [pointer_type ty] returns the pointer type referencing objects of type
425 [ty] in the default address space (0).
426 See the method [llvm::PointerType::getUnqual]. *)
427 external pointer_type : lltype -> lltype = "llvm_pointer_type"
429 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
430 of type [ty] in address space [as].
431 See the method [llvm::PointerType::get]. *)
432 external qualified_pointer_type : lltype -> int -> lltype
433 = "llvm_qualified_pointer_type"
435 (** [vector_type ty n] returns the array type containing [n] elements of the
436 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
437 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
439 (** [element_type ty] returns the element type of the pointer, vector, or array
440 type [ty]. See the method [llvm::SequentialType::get]. *)
441 external element_type : lltype -> lltype = "LLVMGetElementType"
443 (** [element_type aty] returns the element count of the array type [aty].
444 See the method [llvm::ArrayType::getNumElements]. *)
445 external array_length : lltype -> int = "llvm_array_length"
447 (** [address_space pty] returns the address space qualifier of the pointer type
448 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
449 external address_space : lltype -> int = "llvm_address_space"
451 (** [element_type ty] returns the element count of the vector type [ty].
452 See the method [llvm::VectorType::getNumElements]. *)
453 external vector_size : lltype -> int = "llvm_vector_size"
456 (** {7 Operations on other types} *)
458 (** [opaque_type c] creates a new opaque type distinct from any other in the
459 context [c]. Opaque types are useful for building recursive types in
460 combination with {!refine_type}. See [llvm::OpaqueType::get]. *)
461 external opaque_type : llcontext -> lltype = "llvm_opaque_type"
463 (** [void_type c] creates a type of a function which does not return any
464 value in the context [c]. See [llvm::Type::VoidTy]. *)
465 external void_type : llcontext -> lltype = "llvm_void_type"
467 (** [label_type c] creates a type of a basic block in the context [c]. See
468 [llvm::Type::LabelTy]. *)
469 external label_type : llcontext -> lltype = "llvm_label_type"
471 (** {7 Operations on type handles} *)
473 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
474 refined as a result of a call to {!refine_type}, the handle will be updated;
475 any bare [lltype] references will become invalid.
476 See the class [llvm::PATypeHolder]. *)
477 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
479 (** [type_of_handle tyh] resolves the type handle [tyh].
480 See the method [llvm::PATypeHolder::get()]. *)
481 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
483 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
484 concrete type [ty] in all users. Warning: This may invalidate {!lltype}
485 values! Use {!lltypehandle} to manipulate potentially abstract types. See
486 the method [llvm::Type::refineAbstractType]. *)
487 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
492 (** [type_of v] returns the type of the value [v].
493 See the method [llvm::Value::getType]. *)
494 external type_of : llvalue -> lltype = "llvm_type_of"
496 (** [value_name v] returns the name of the value [v]. For global values, this is
497 the symbol name. For instructions and basic blocks, it is the SSA register
498 name. It is meaningless for constants.
499 See the method [llvm::Value::getName]. *)
500 external value_name : llvalue -> string = "llvm_value_name"
502 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
503 [llvm::Value::setName]. *)
504 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
506 (** [dump_value v] prints the .ll representation of the value [v] to standard
507 error. See the method [llvm::Value::dump]. *)
508 external dump_value : llvalue -> unit = "llvm_dump_value"
510 (** [replace_all_uses_with old new] replaces all uses of the value [old]
511 * with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
512 external replace_all_uses_with : llvalue -> llvalue -> unit
513 = "LLVMReplaceAllUsesWith"
516 (** {7 Operations on constants of (mostly) any type} *)
518 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
519 otherwise. Similar to [llvm::isa<Constant>]. *)
520 external is_constant : llvalue -> bool = "llvm_is_constant"
522 (** [const_null ty] returns the constant null (zero) of the type [ty].
523 See the method [llvm::Constant::getNullValue]. *)
524 external const_null : lltype -> llvalue = "LLVMConstNull"
526 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
527 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
528 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
530 (** [undef ty] returns the undefined value of the type [ty].
531 See the method [llvm::UndefValue::get]. *)
532 external undef : lltype -> llvalue = "LLVMGetUndef"
534 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
535 See the method [llvm::Constant::isNullValue]. *)
536 external is_null : llvalue -> bool = "llvm_is_null"
538 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
539 otherwise. Similar to [llvm::isa<UndefValue>]. *)
540 external is_undef : llvalue -> bool = "llvm_is_undef"
543 (** {7 Operations on instructions} *)
545 (** [has_metadata i] returns whether or not the instruction [i] has any
546 metadata attached to it. See the function
547 [llvm::Instruction::hasMetadata]. *)
548 external has_metadata : llvalue -> bool = "llvm_has_metadata"
550 (** [metadata i kind] optionally returns the metadata associated with the
551 kind [kind] in the instruction [i] See the function
552 [llvm::Instruction::getMetadata]. *)
553 external metadata : llvalue -> int -> llvalue option = "llvm_metadata"
555 (** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
556 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
557 external set_metadata : llvalue -> int -> llvalue -> unit = "llvm_set_metadata"
559 (** [clear_metadata i kind] clears the metadata of kind [kind] in the
560 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
561 external clear_metadata : llvalue -> int -> unit = "llvm_clear_metadata"
564 (** {7 Operations on metadata} *)
566 (** [mdstring c s] returns the MDString of the string [s] in the context [c].
567 See the method [llvm::MDNode::get]. *)
568 external mdstring : llcontext -> string -> llvalue = "llvm_mdstring"
570 (** [mdnode c elts] returns the MDNode containing the values [elts] in the
572 See the method [llvm::MDNode::get]. *)
573 external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode"
576 (** {7 Operations on scalar constants} *)
578 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
579 See the method [llvm::ConstantInt::get]. *)
580 external const_int : lltype -> int -> llvalue = "llvm_const_int"
582 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
583 [i]. See the method [llvm::ConstantInt::get]. *)
584 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
585 = "llvm_const_of_int64"
587 (** [const_int_of_string ty s r] returns the integer constant of type [ty] and
588 * value [s], with the radix [r]. See the method [llvm::ConstantInt::get]. *)
589 external const_int_of_string : lltype -> string -> int -> llvalue
590 = "llvm_const_int_of_string"
592 (** [const_float ty n] returns the floating point constant of type [ty] and
593 value [n]. See the method [llvm::ConstantFP::get]. *)
594 external const_float : lltype -> float -> llvalue = "llvm_const_float"
596 (** [const_float_of_string ty s] returns the floating point constant of type
597 [ty] and value [n]. See the method [llvm::ConstantFP::get]. *)
598 external const_float_of_string : lltype -> string -> llvalue
599 = "llvm_const_float_of_string"
602 (** {7 Operations on composite constants} *)
604 (** [const_string c s] returns the constant [i8] array with the values of the
605 characters in the string [s] in the context [c]. The array is not
606 null-terminated (but see {!const_stringz}). This value can in turn be used
607 as the initializer for a global variable. See the method
608 [llvm::ConstantArray::get]. *)
609 external const_string : llcontext -> string -> llvalue = "llvm_const_string"
611 (** [const_stringz c s] returns the constant [i8] array with the values of the
612 characters in the string [s] and a null terminator in the context [c]. This
613 value can in turn be used as the initializer for a global variable.
614 See the method [llvm::ConstantArray::get]. *)
615 external const_stringz : llcontext -> string -> llvalue = "llvm_const_stringz"
617 (** [const_array ty elts] returns the constant array of type
618 [array_type ty (Array.length elts)] and containing the values [elts].
619 This value can in turn be used as the initializer for a global variable.
620 See the method [llvm::ConstantArray::get]. *)
621 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
623 (** [const_struct context elts] returns the structured constant of type
624 [struct_type (Array.map type_of elts)] and containing the values [elts]
625 in the context [context]. This value can in turn be used as the initializer
626 for a global variable. See the method [llvm::ConstantStruct::get]. *)
627 external const_struct : llcontext -> llvalue array -> llvalue
628 = "llvm_const_struct"
630 (** [const_packed_struct context elts] returns the structured constant of
631 type {!packed_struct_type} [(Array.map type_of elts)] and containing the
632 values [elts] in the context [context]. This value can in turn be used as
633 the initializer for a global variable. See the method
634 [llvm::ConstantStruct::get]. *)
635 external const_packed_struct : llcontext -> llvalue array -> llvalue
636 = "llvm_const_packed_struct"
638 (** [const_vector elts] returns the vector constant of type
639 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
640 values [elts]. See the method [llvm::ConstantVector::get]. *)
641 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
643 (** [const_union ty v] returns the union constant of type [union_type tys] and
644 containing the value [v]. See the method [llvm::ConstantUnion::get]. *)
645 external const_union : lltype -> llvalue -> llvalue = "LLVMConstUnion"
648 (** {7 Constant expressions} *)
650 (** [align_of ty] returns the alignof constant for the type [ty]. This is
651 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type {i8,ty}))
652 (const_int i32_type 0) (const_int i32_type 1)) i32_type], but considerably
653 more readable. See the method [llvm::ConstantExpr::getAlignOf]. *)
654 external align_of : lltype -> llvalue = "LLVMAlignOf"
656 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
657 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
658 (const_int i32_type 1)) i64_type], but considerably more readable.
659 See the method [llvm::ConstantExpr::getSizeOf]. *)
660 external size_of : lltype -> llvalue = "LLVMSizeOf"
662 (** [const_neg c] returns the arithmetic negation of the constant [c].
663 See the method [llvm::ConstantExpr::getNeg]. *)
664 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
666 (** [const_nsw_neg c] returns the arithmetic negation of the constant [c] with
667 no signed wrapping. The result is undefined if the negation overflows.
668 See the method [llvm::ConstantExpr::getNSWNeg]. *)
669 external const_nsw_neg : llvalue -> llvalue = "LLVMConstNSWNeg"
671 (** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
672 no unsigned wrapping. The result is undefined if the negation overflows.
673 See the method [llvm::ConstantExpr::getNUWNeg]. *)
674 external const_nuw_neg : llvalue -> llvalue = "LLVMConstNUWNeg"
676 (** [const_fneg c] returns the arithmetic negation of the constant float [c].
677 See the method [llvm::ConstantExpr::getFNeg]. *)
678 external const_fneg : llvalue -> llvalue = "LLVMConstFNeg"
680 (** [const_not c] returns the bitwise inverse of the constant [c].
681 See the method [llvm::ConstantExpr::getNot]. *)
682 external const_not : llvalue -> llvalue = "LLVMConstNot"
684 (** [const_add c1 c2] returns the constant sum of two constants.
685 See the method [llvm::ConstantExpr::getAdd]. *)
686 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
688 (** [const_nsw_add c1 c2] returns the constant sum of two constants with no
689 signed wrapping. The result is undefined if the sum overflows.
690 See the method [llvm::ConstantExpr::getNSWAdd]. *)
691 external const_nsw_add : llvalue -> llvalue -> llvalue = "LLVMConstNSWAdd"
693 (** [const_nuw_add c1 c2] returns the constant sum of two constants with no
694 unsigned wrapping. The result is undefined if the sum overflows.
695 See the method [llvm::ConstantExpr::getNSWAdd]. *)
696 external const_nuw_add : llvalue -> llvalue -> llvalue = "LLVMConstNUWAdd"
698 (** [const_fadd c1 c2] returns the constant sum of two constant floats.
699 See the method [llvm::ConstantExpr::getFAdd]. *)
700 external const_fadd : llvalue -> llvalue -> llvalue = "LLVMConstFAdd"
702 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
703 constants. See the method [llvm::ConstantExpr::getSub]. *)
704 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
706 (** [const_nsw_sub c1 c2] returns the constant difference of two constants with
707 no signed wrapping. The result is undefined if the sum overflows.
708 See the method [llvm::ConstantExpr::getNSWSub]. *)
709 external const_nsw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNSWSub"
711 (** [const_nuw_sub c1 c2] returns the constant difference of two constants with
712 no unsigned wrapping. The result is undefined if the sum overflows.
713 See the method [llvm::ConstantExpr::getNSWSub]. *)
714 external const_nuw_sub : llvalue -> llvalue -> llvalue = "LLVMConstNUWSub"
716 (** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
717 constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
718 external const_fsub : llvalue -> llvalue -> llvalue = "LLVMConstFSub"
720 (** [const_mul c1 c2] returns the constant product of two constants.
721 See the method [llvm::ConstantExpr::getMul]. *)
722 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
724 (** [const_nsw_mul c1 c2] returns the constant product of two constants with
725 no signed wrapping. The result is undefined if the sum overflows.
726 See the method [llvm::ConstantExpr::getNSWMul]. *)
727 external const_nsw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNSWMul"
729 (** [const_nuw_mul c1 c2] returns the constant product of two constants with
730 no unsigned wrapping. The result is undefined if the sum overflows.
731 See the method [llvm::ConstantExpr::getNSWMul]. *)
732 external const_nuw_mul : llvalue -> llvalue -> llvalue = "LLVMConstNUWMul"
734 (** [const_fmul c1 c2] returns the constant product of two constants floats.
735 See the method [llvm::ConstantExpr::getFMul]. *)
736 external const_fmul : llvalue -> llvalue -> llvalue = "LLVMConstFMul"
738 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
740 See the method [llvm::ConstantExpr::getUDiv]. *)
741 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
743 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
745 See the method [llvm::ConstantExpr::getSDiv]. *)
746 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
748 (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
749 signed integer constants. The result is undefined if the result is rounded
750 or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
751 external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv"
753 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
755 See the method [llvm::ConstantExpr::getFDiv]. *)
756 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
758 (** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
759 unsigned integer constants.
760 See the method [llvm::ConstantExpr::getURem]. *)
761 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
763 (** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
764 signed integer constants.
765 See the method [llvm::ConstantExpr::getSRem]. *)
766 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
768 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
769 signed floating point constants.
770 See the method [llvm::ConstantExpr::getFRem]. *)
771 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
773 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
775 See the method [llvm::ConstantExpr::getAnd]. *)
776 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
778 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
780 See the method [llvm::ConstantExpr::getOr]. *)
781 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
783 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
785 See the method [llvm::ConstantExpr::getXor]. *)
786 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
788 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
789 constants, [c1 pred c2].
790 See the method [llvm::ConstantExpr::getICmp]. *)
791 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
794 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
795 point constants, [c1 pred c2].
796 See the method [llvm::ConstantExpr::getFCmp]. *)
797 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
800 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
801 constant integer [c2].
802 See the method [llvm::ConstantExpr::getShl]. *)
803 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
805 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
806 constant integer [c2] with zero extension.
807 See the method [llvm::ConstantExpr::getLShr]. *)
808 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
810 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
811 constant integer [c2] with sign extension.
812 See the method [llvm::ConstantExpr::getAShr]. *)
813 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
815 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
816 constant integers indices from the array [indices].
817 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
818 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
820 (** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
821 with the constant integers indices from the array [indices].
822 See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
823 external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
824 = "llvm_const_in_bounds_gep"
826 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
827 to the smaller integer type [ty].
828 See the method [llvm::ConstantExpr::getTrunc]. *)
829 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
831 (** [const_sext c ty] returns the constant sign extension of integer constant
832 [c] to the larger integer type [ty].
833 See the method [llvm::ConstantExpr::getSExt]. *)
834 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
836 (** [const_zext c ty] returns the constant zero extension of integer constant
837 [c] to the larger integer type [ty].
838 See the method [llvm::ConstantExpr::getZExt]. *)
839 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
841 (** [const_fptrunc c ty] returns the constant truncation of floating point
842 constant [c] to the smaller floating point type [ty].
843 See the method [llvm::ConstantExpr::getFPTrunc]. *)
844 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
846 (** [const_fpext c ty] returns the constant extension of floating point constant
847 [c] to the larger floating point type [ty].
848 See the method [llvm::ConstantExpr::getFPExt]. *)
849 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
851 (** [const_uitofp c ty] returns the constant floating point conversion of
852 unsigned integer constant [c] to the floating point type [ty].
853 See the method [llvm::ConstantExpr::getUIToFP]. *)
854 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
856 (** [const_sitofp c ty] returns the constant floating point conversion of
857 signed integer constant [c] to the floating point type [ty].
858 See the method [llvm::ConstantExpr::getSIToFP]. *)
859 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
861 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
862 floating point constant [c] to integer type [ty].
863 See the method [llvm::ConstantExpr::getFPToUI]. *)
864 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
866 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
867 floating point constant [c] to integer type [ty].
868 See the method [llvm::ConstantExpr::getFPToSI]. *)
869 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
871 (** [const_ptrtoint c ty] returns the constant integer conversion of
872 pointer constant [c] to integer type [ty].
873 See the method [llvm::ConstantExpr::getPtrToInt]. *)
874 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
876 (** [const_inttoptr c ty] returns the constant pointer conversion of
877 integer constant [c] to pointer type [ty].
878 See the method [llvm::ConstantExpr::getIntToPtr]. *)
879 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
881 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
882 to type [ty] of equal size.
883 See the method [llvm::ConstantExpr::getBitCast]. *)
884 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
886 (** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
887 conversion of constant [c] to type [ty].
888 See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
889 external const_zext_or_bitcast : llvalue -> lltype -> llvalue
890 = "LLVMConstZExtOrBitCast"
892 (** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
893 conversion of constant [c] to type [ty].
894 See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
895 external const_sext_or_bitcast : llvalue -> lltype -> llvalue
896 = "LLVMConstSExtOrBitCast"
898 (** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
899 conversion of constant [c] to type [ty].
900 See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
901 external const_trunc_or_bitcast : llvalue -> lltype -> llvalue
902 = "LLVMConstTruncOrBitCast"
904 (** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
905 cast conversion of constant [c] to type [ty] of equal size.
906 See the method [llvm::ConstantExpr::getPointerCast]. *)
907 external const_pointercast : llvalue -> lltype -> llvalue
908 = "LLVMConstPointerCast"
910 (** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
911 -> integer casts of constant [c] to type [ty].
912 See the method [llvm::ConstantExpr::getIntCast]. *)
913 external const_intcast : llvalue -> lltype -> llvalue
916 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
917 fp casts of constant [c] to type [ty].
918 See the method [llvm::ConstantExpr::getFPCast]. *)
919 external const_fpcast : llvalue -> lltype -> llvalue
922 (** [const_select cond t f] returns the constant conditional which returns value
923 [t] if the boolean constant [cond] is true and the value [f] otherwise.
924 See the method [llvm::ConstantExpr::getSelect]. *)
925 external const_select : llvalue -> llvalue -> llvalue -> llvalue
928 (** [const_extractelement vec i] returns the constant [i]th element of
929 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
930 the size of the vector.
931 See the method [llvm::ConstantExpr::getExtractElement]. *)
932 external const_extractelement : llvalue -> llvalue -> llvalue
933 = "LLVMConstExtractElement"
935 (** [const_insertelement vec v i] returns the constant vector with the same
936 elements as constant vector [v] but the [i]th element replaced by the
937 constant [v]. [v] must be a constant value with the type of the vector
938 elements. [i] must be a constant [i32] value unsigned less than the size
940 See the method [llvm::ConstantExpr::getInsertElement]. *)
941 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
942 = "LLVMConstInsertElement"
944 (** [const_shufflevector a b mask] returns a constant [shufflevector].
945 See the LLVM Language Reference for details on the [sufflevector]
947 See the method [llvm::ConstantExpr::getShuffleVector]. *)
948 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
949 = "LLVMConstShuffleVector"
951 (** [const_extractvalue agg idxs] returns the constant [idxs]th value of
952 constant aggregate [agg]. Each [idxs] must be less than the size of the
953 aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
954 external const_extractvalue : llvalue -> int array -> llvalue
955 = "llvm_const_extractvalue"
957 (** [const_insertvalue agg val idxs] inserts the value [val] in the specified
958 indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
959 of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
960 external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
961 = "llvm_const_insertvalue"
963 (** [block_address f bb] returns the address of the basic block [bb] in the
964 function [f]. See the method [llvm::BasicBlock::get]. *)
965 external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
968 (** {7 Operations on global variables, functions, and aliases (globals)} *)
970 (** [global_parent g] is the enclosing module of the global value [g].
971 See the method [llvm::GlobalValue::getParent]. *)
972 external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
974 (** [is_declaration g] returns [true] if the global value [g] is a declaration
975 only. Returns [false] otherwise.
976 See the method [llvm::GlobalValue::isDeclaration]. *)
977 external is_declaration : llvalue -> bool = "llvm_is_declaration"
979 (** [linkage g] returns the linkage of the global value [g].
980 See the method [llvm::GlobalValue::getLinkage]. *)
981 external linkage : llvalue -> Linkage.t = "llvm_linkage"
983 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
984 See the method [llvm::GlobalValue::setLinkage]. *)
985 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
987 (** [section g] returns the linker section of the global value [g].
988 See the method [llvm::GlobalValue::getSection]. *)
989 external section : llvalue -> string = "llvm_section"
991 (** [set_section s g] sets the linker section of the global value [g] to [s].
992 See the method [llvm::GlobalValue::setSection]. *)
993 external set_section : string -> llvalue -> unit = "llvm_set_section"
995 (** [visibility g] returns the linker visibility of the global value [g].
996 See the method [llvm::GlobalValue::getVisibility]. *)
997 external visibility : llvalue -> Visibility.t = "llvm_visibility"
999 (** [set_visibility v g] sets the linker visibility of the global value [g] to
1000 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
1001 external set_visibility : Visibility.t -> llvalue -> unit
1002 = "llvm_set_visibility"
1004 (** [alignment g] returns the required alignment of the global value [g].
1005 See the method [llvm::GlobalValue::getAlignment]. *)
1006 external alignment : llvalue -> int = "llvm_alignment"
1008 (** [set_alignment n g] sets the required alignment of the global value [g] to
1009 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
1010 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
1013 (** {7 Operations on global variables} *)
1015 (** [declare_global ty name m] returns a new global variable of type [ty] and
1016 with name [name] in module [m] in the default address space (0). If such a
1017 global variable already exists, it is returned. If the type of the existing
1018 global differs, then a bitcast to [ty] is returned. *)
1019 external declare_global : lltype -> string -> llmodule -> llvalue
1020 = "llvm_declare_global"
1022 (** [declare_qualified_global ty name as m] returns a new global variable of
1023 type [ty] and with name [name] in module [m] in the address space [as]. If
1024 such a global variable already exists, it is returned. If the type of the
1025 existing global differs, then a bitcast to [ty] is returned. *)
1026 external declare_qualified_global : lltype -> string -> int -> llmodule ->
1028 = "llvm_declare_qualified_global"
1030 (** [define_global name init m] returns a new global with name [name] and
1031 initializer [init] in module [m] in the default address space (0). If the
1032 named global already exists, it is renamed.
1033 See the constructor of [llvm::GlobalVariable]. *)
1034 external define_global : string -> llvalue -> llmodule -> llvalue
1035 = "llvm_define_global"
1037 (** [define_qualified_global name init as m] returns a new global with name
1038 [name] and initializer [init] in module [m] in the address space [as]. If
1039 the named global already exists, it is renamed.
1040 See the constructor of [llvm::GlobalVariable]. *)
1041 external define_qualified_global : string -> llvalue -> int -> llmodule ->
1043 = "llvm_define_qualified_global"
1045 (** [lookup_global name m] returns [Some g] if a global variable with name
1046 [name] exists in module [m]. If no such global exists, returns [None].
1047 See the [llvm::GlobalVariable] constructor. *)
1048 external lookup_global : string -> llmodule -> llvalue option
1049 = "llvm_lookup_global"
1051 (** [delete_global gv] destroys the global variable [gv].
1052 See the method [llvm::GlobalVariable::eraseFromParent]. *)
1053 external delete_global : llvalue -> unit = "llvm_delete_global"
1055 (** [global_begin m] returns the first position in the global variable list of
1056 the module [m]. [global_begin] and [global_succ] can be used to iterate
1057 over the global list in order.
1058 See the method [llvm::Module::global_begin]. *)
1059 external global_begin : llmodule -> (llmodule, llvalue) llpos
1060 = "llvm_global_begin"
1062 (** [global_succ gv] returns the global variable list position succeeding
1064 See the method [llvm::Module::global_iterator::operator++]. *)
1065 external global_succ : llvalue -> (llmodule, llvalue) llpos
1066 = "llvm_global_succ"
1068 (** [iter_globals f m] applies function [f] to each of the global variables of
1069 module [m] in order. Tail recursive. *)
1070 val iter_globals : (llvalue -> unit) -> llmodule -> unit
1072 (** [fold_left_globals f init m] is [f (... (f init g1) ...) gN] where
1073 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1074 val fold_left_globals : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
1076 (** [global_end m] returns the last position in the global variable list of the
1077 module [m]. [global_end] and [global_pred] can be used to iterate over the
1078 global list in reverse.
1079 See the method [llvm::Module::global_end]. *)
1080 external global_end : llmodule -> (llmodule, llvalue) llrev_pos
1083 (** [global_pred gv] returns the global variable list position preceding
1085 See the method [llvm::Module::global_iterator::operator--]. *)
1086 external global_pred : llvalue -> (llmodule, llvalue) llrev_pos
1087 = "llvm_global_pred"
1089 (** [rev_iter_globals f m] applies function [f] to each of the global variables
1090 of module [m] in reverse order. Tail recursive. *)
1091 val rev_iter_globals : (llvalue -> unit) -> llmodule -> unit
1093 (** [fold_right_globals f m init] is [f g1 (... (f gN init) ...)] where
1094 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1095 val fold_right_globals : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
1097 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
1098 constant. Returns [false] otherwise.
1099 See the method [llvm::GlobalVariable::isConstant]. *)
1100 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
1102 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
1103 [c] is [true] and not if [c] is [false].
1104 See the method [llvm::GlobalVariable::setConstant]. *)
1105 external set_global_constant : bool -> llvalue -> unit
1106 = "llvm_set_global_constant"
1108 (** [global_initializer gv] returns the initializer for the global variable
1109 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
1110 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
1112 (** [set_initializer c gv] sets the initializer for the global variable
1113 [gv] to the constant [c].
1114 See the method [llvm::GlobalVariable::setInitializer]. *)
1115 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
1117 (** [remove_initializer gv] unsets the initializer for the global variable
1119 See the method [llvm::GlobalVariable::setInitializer]. *)
1120 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
1122 (** [is_thread_local gv] returns [true] if the global variable [gv] is
1123 thread-local and [false] otherwise.
1124 See the method [llvm::GlobalVariable::isThreadLocal]. *)
1125 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
1127 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
1128 [c] is [true] and not otherwise.
1129 See the method [llvm::GlobalVariable::setThreadLocal]. *)
1130 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
1133 (** {7 Operations on functions} *)
1135 (** [declare_function name ty m] returns a new function of type [ty] and
1136 with name [name] in module [m]. If such a function already exists,
1137 it is returned. If the type of the existing function differs, then a bitcast
1138 to [ty] is returned. *)
1139 external declare_function : string -> lltype -> llmodule -> llvalue
1140 = "llvm_declare_function"
1142 (** [define_function name ty m] creates a new function with name [name] and
1143 type [ty] in module [m]. If the named function already exists, it is
1144 renamed. An entry basic block is created in the function.
1145 See the constructor of [llvm::GlobalVariable]. *)
1146 external define_function : string -> lltype -> llmodule -> llvalue
1147 = "llvm_define_function"
1149 (** [lookup_function name m] returns [Some f] if a function with name
1150 [name] exists in module [m]. If no such function exists, returns [None].
1151 See the method [llvm::Module] constructor. *)
1152 external lookup_function : string -> llmodule -> llvalue option
1153 = "llvm_lookup_function"
1155 (** [delete_function f] destroys the function [f].
1156 See the method [llvm::Function::eraseFromParent]. *)
1157 external delete_function : llvalue -> unit = "llvm_delete_function"
1159 (** [function_begin m] returns the first position in the function list of the
1160 module [m]. [function_begin] and [function_succ] can be used to iterate over
1161 the function list in order.
1162 See the method [llvm::Module::begin]. *)
1163 external function_begin : llmodule -> (llmodule, llvalue) llpos
1164 = "llvm_function_begin"
1166 (** [function_succ gv] returns the function list position succeeding
1168 See the method [llvm::Module::iterator::operator++]. *)
1169 external function_succ : llvalue -> (llmodule, llvalue) llpos
1170 = "llvm_function_succ"
1172 (** [iter_functions f m] applies function [f] to each of the functions of module
1173 [m] in order. Tail recursive. *)
1174 val iter_functions : (llvalue -> unit) -> llmodule -> unit
1176 (** [fold_left_function f init m] is [f (... (f init f1) ...) fN] where
1177 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1178 val fold_left_functions : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
1180 (** [function_end m] returns the last position in the function list of
1181 the module [m]. [function_end] and [function_pred] can be used to iterate
1182 over the function list in reverse.
1183 See the method [llvm::Module::end]. *)
1184 external function_end : llmodule -> (llmodule, llvalue) llrev_pos
1185 = "llvm_function_end"
1187 (** [function_pred gv] returns the function list position preceding [After gv].
1188 See the method [llvm::Module::iterator::operator--]. *)
1189 external function_pred : llvalue -> (llmodule, llvalue) llrev_pos
1190 = "llvm_function_pred"
1192 (** [rev_iter_functions f fn] applies function [f] to each of the functions of
1193 module [m] in reverse order. Tail recursive. *)
1194 val rev_iter_functions : (llvalue -> unit) -> llmodule -> unit
1196 (** [fold_right_functions f m init] is [f (... (f init fN) ...) f1] where
1197 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1198 val fold_right_functions : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
1200 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
1201 See the method [llvm::Function::isIntrinsic]. *)
1202 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
1204 (** [function_call_conv f] returns the calling convention of the function [f].
1205 See the method [llvm::Function::getCallingConv]. *)
1206 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
1208 (** [set_function_call_conv cc f] sets the calling convention of the function
1209 [f] to the calling convention numbered [cc].
1210 See the method [llvm::Function::setCallingConv]. *)
1211 external set_function_call_conv : int -> llvalue -> unit
1212 = "llvm_set_function_call_conv"
1214 (** [gc f] returns [Some name] if the function [f] has a garbage
1215 collection algorithm specified and [None] otherwise.
1216 See the method [llvm::Function::getGC]. *)
1217 external gc : llvalue -> string option = "llvm_gc"
1219 (** [set_gc gc f] sets the collection algorithm for the function [f] to
1220 [gc]. See the method [llvm::Function::setGC]. *)
1221 external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
1223 (** [add_function_attr f a] adds attribute [a] to the return type of function
1225 external add_function_attr : llvalue -> Attribute.t -> unit
1226 = "llvm_add_function_attr"
1228 (** [remove_function_attr f a] removes attribute [a] from the return type of
1230 external remove_function_attr : llvalue -> Attribute.t -> unit
1231 = "llvm_remove_function_attr"
1233 (** {7 Operations on params} *)
1235 (** [params f] returns the parameters of function [f].
1236 See the method [llvm::Function::getArgumentList]. *)
1237 external params : llvalue -> llvalue array = "llvm_params"
1239 (** [param f n] returns the [n]th parameter of function [f].
1240 See the method [llvm::Function::getArgumentList]. *)
1241 external param : llvalue -> int -> llvalue = "llvm_param"
1243 (** [param_parent p] returns the parent function that owns the parameter.
1244 See the method [llvm::Argument::getParent]. *)
1245 external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
1247 (** [param_begin f] returns the first position in the parameter list of the
1248 function [f]. [param_begin] and [param_succ] can be used to iterate over
1249 the parameter list in order.
1250 See the method [llvm::Function::arg_begin]. *)
1251 external param_begin : llvalue -> (llvalue, llvalue) llpos = "llvm_param_begin"
1253 (** [param_succ bb] returns the parameter list position succeeding
1255 See the method [llvm::Function::arg_iterator::operator++]. *)
1256 external param_succ : llvalue -> (llvalue, llvalue) llpos = "llvm_param_succ"
1258 (** [iter_params f fn] applies function [f] to each of the parameters
1259 of function [fn] in order. Tail recursive. *)
1260 val iter_params : (llvalue -> unit) -> llvalue -> unit
1262 (** [fold_left_params f init fn] is [f (... (f init b1) ...) bN] where
1263 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1264 val fold_left_params : ('a -> llvalue -> 'a) -> 'a -> llvalue -> 'a
1266 (** [param_end f] returns the last position in the parameter list of
1267 the function [f]. [param_end] and [param_pred] can be used to iterate
1268 over the parameter list in reverse.
1269 See the method [llvm::Function::arg_end]. *)
1270 external param_end : llvalue -> (llvalue, llvalue) llrev_pos = "llvm_param_end"
1272 (** [param_pred gv] returns the function list position preceding [After gv].
1273 See the method [llvm::Function::arg_iterator::operator--]. *)
1274 external param_pred : llvalue -> (llvalue, llvalue) llrev_pos
1277 (** [rev_iter_params f fn] applies function [f] to each of the parameters
1278 of function [fn] in reverse order. Tail recursive. *)
1279 val rev_iter_params : (llvalue -> unit) -> llvalue -> unit
1281 (** [fold_right_params f fn init] is [f (... (f init bN) ...) b1] where
1282 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1283 val fold_right_params : (llvalue -> 'a -> 'a) -> llvalue -> 'a -> 'a
1285 (** [add_param p a] adds attribute [a] to parameter [p]. *)
1286 external add_param_attr : llvalue -> Attribute.t -> unit = "llvm_add_param_attr"
1288 (** [remove_param_attr p a] removes attribute [a] from parameter [p]. *)
1289 external remove_param_attr : llvalue -> Attribute.t -> unit
1290 = "llvm_remove_param_attr"
1292 (** [set_param_alignment p a] set the alignment of parameter [p] to [a]. *)
1293 external set_param_alignment : llvalue -> int -> unit
1294 = "llvm_set_param_alignment"
1296 (** {7 Operations on basic blocks} *)
1298 (** [basic_blocks fn] returns the basic blocks of the function [f].
1299 See the method [llvm::Function::getBasicBlockList]. *)
1300 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
1302 (** [entry_block fn] returns the entry basic block of the function [f].
1303 See the method [llvm::Function::getEntryBlock]. *)
1304 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
1306 (** [delete_block bb] deletes the basic block [bb].
1307 See the method [llvm::BasicBlock::eraseFromParent]. *)
1308 external delete_block : llbasicblock -> unit = "llvm_delete_block"
1310 (** [append_block c name f] creates a new basic block named [name] at the end of
1311 function [f] in the context [c].
1312 See the constructor of [llvm::BasicBlock]. *)
1313 external append_block : llcontext -> string -> llvalue -> llbasicblock
1314 = "llvm_append_block"
1316 (** [insert_block c name bb] creates a new basic block named [name] before the
1317 basic block [bb] in the context [c].
1318 See the constructor of [llvm::BasicBlock]. *)
1319 external insert_block : llcontext -> string -> llbasicblock -> llbasicblock
1320 = "llvm_insert_block"
1322 (** [block_parent bb] returns the parent function that owns the basic block.
1323 See the method [llvm::BasicBlock::getParent]. *)
1324 external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
1326 (** [block_begin f] returns the first position in the basic block list of the
1327 function [f]. [block_begin] and [block_succ] can be used to iterate over
1328 the basic block list in order.
1329 See the method [llvm::Function::begin]. *)
1330 external block_begin : llvalue -> (llvalue, llbasicblock) llpos
1331 = "llvm_block_begin"
1333 (** [block_succ bb] returns the basic block list position succeeding
1335 See the method [llvm::Function::iterator::operator++]. *)
1336 external block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
1339 (** [iter_blocks f fn] applies function [f] to each of the basic blocks
1340 of function [fn] in order. Tail recursive. *)
1341 val iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1343 (** [fold_left_blocks f init fn] is [f (... (f init b1) ...) bN] where
1344 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1345 val fold_left_blocks : ('a -> llbasicblock -> 'a) -> 'a -> llvalue -> 'a
1347 (** [block_end f] returns the last position in the basic block list of
1348 the function [f]. [block_end] and [block_pred] can be used to iterate
1349 over the basic block list in reverse.
1350 See the method [llvm::Function::end]. *)
1351 external block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
1354 (** [block_pred gv] returns the function list position preceding [After gv].
1355 See the method [llvm::Function::iterator::operator--]. *)
1356 external block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
1359 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
1360 of function [fn] in reverse order. Tail recursive. *)
1361 val rev_iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1363 (** [fold_right_blocks f fn init] is [f (... (f init bN) ...) b1] where
1364 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1365 val fold_right_blocks : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
1367 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
1368 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
1370 (** [value_is_block v] returns [true] if the value [v] is a basic block and
1372 Similar to [llvm::isa<BasicBlock>]. *)
1373 external value_is_block : llvalue -> bool = "llvm_value_is_block"
1375 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
1376 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
1379 (** {7 Operations on instructions} *)
1381 (** [instr_parent i] is the enclosing basic block of the instruction [i].
1382 See the method [llvm::Instruction::getParent]. *)
1383 external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
1385 (** [instr_begin bb] returns the first position in the instruction list of the
1386 basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
1387 the instruction list in order.
1388 See the method [llvm::BasicBlock::begin]. *)
1389 external instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
1390 = "llvm_instr_begin"
1392 (** [instr_succ i] returns the instruction list position succeeding [Before i].
1393 See the method [llvm::BasicBlock::iterator::operator++]. *)
1394 external instr_succ : llvalue -> (llbasicblock, llvalue) llpos
1397 (** [iter_instrs f bb] applies function [f] to each of the instructions of basic
1398 block [bb] in order. Tail recursive. *)
1399 val iter_instrs: (llvalue -> unit) -> llbasicblock -> unit
1401 (** [fold_left_instrs f init bb] is [f (... (f init g1) ...) gN] where
1402 [g1,...,gN] are the instructions of basic block [bb]. Tail recursive. *)
1403 val fold_left_instrs: ('a -> llvalue -> 'a) -> 'a -> llbasicblock -> 'a
1405 (** [instr_end bb] returns the last position in the instruction list of the
1406 basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
1407 the instruction list in reverse.
1408 See the method [llvm::BasicBlock::end]. *)
1409 external instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
1412 (** [instr_pred i] returns the instruction list position preceding [After i].
1413 See the method [llvm::BasicBlock::iterator::operator--]. *)
1414 external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
1417 (** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
1418 [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
1419 val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a
1422 (** {7 Operations on call sites} *)
1424 (** [instruction_call_conv ci] is the calling convention for the call or invoke
1425 instruction [ci], which may be one of the values from the module
1426 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
1427 [llvm::InvokeInst::getCallingConv]. *)
1428 external instruction_call_conv: llvalue -> int
1429 = "llvm_instruction_call_conv"
1431 (** [set_instruction_call_conv cc ci] sets the calling convention for the call
1432 or invoke instruction [ci] to the integer [cc], which can be one of the
1433 values from the module {!CallConv}.
1434 See the method [llvm::CallInst::setCallingConv]
1435 and [llvm::InvokeInst::setCallingConv]. *)
1436 external set_instruction_call_conv: int -> llvalue -> unit
1437 = "llvm_set_instruction_call_conv"
1439 (** [add_instruction_param_attr ci i a] adds attribute [a] to the [i]th
1440 parameter of the call or invoke instruction [ci]. [i]=0 denotes the return
1442 external add_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1443 = "llvm_add_instruction_param_attr"
1445 (** [remove_instruction_param_attr ci i a] removes attribute [a] from the
1446 [i]th parameter of the call or invoke instruction [ci]. [i]=0 denotes the
1448 external remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1449 = "llvm_remove_instruction_param_attr"
1451 (** {Operations on call instructions (only)} *)
1453 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
1454 eligible for tail call optimization, [false] otherwise.
1455 See the method [llvm::CallInst::isTailCall]. *)
1456 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
1458 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
1459 call optimization if [tc] is [true], clears otherwise.
1460 See the method [llvm::CallInst::setTailCall]. *)
1461 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
1463 (** {7 Operations on phi nodes} *)
1465 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
1466 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
1467 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
1468 = "llvm_add_incoming"
1470 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
1471 See the method [llvm::PHINode::getIncomingValue]. *)
1472 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
1476 (** {6 Instruction builders} *)
1478 (** [builder context] creates an instruction builder with no position in
1479 the context [context]. It is invalid to use this builder until its position
1480 is set with {!position_before} or {!position_at_end}. See the constructor
1481 for [llvm::LLVMBuilder]. *)
1482 external builder : llcontext -> llbuilder = "llvm_builder"
1484 (** [builder_at ip] creates an instruction builder positioned at [ip].
1485 See the constructor for [llvm::LLVMBuilder]. *)
1486 val builder_at : llcontext -> (llbasicblock, llvalue) llpos -> llbuilder
1488 (** [builder_before ins] creates an instruction builder positioned before the
1489 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
1490 val builder_before : llcontext -> llvalue -> llbuilder
1492 (** [builder_at_end bb] creates an instruction builder positioned at the end of
1493 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
1494 val builder_at_end : llcontext -> llbasicblock -> llbuilder
1496 (** [position_builder ip bb] moves the instruction builder [bb] to the position
1498 See the constructor for [llvm::LLVMBuilder]. *)
1499 external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
1500 = "llvm_position_builder"
1502 (** [position_before ins b] moves the instruction builder [b] to before the
1503 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1504 val position_before : llvalue -> llbuilder -> unit
1506 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
1507 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1508 val position_at_end : llbasicblock -> llbuilder -> unit
1510 (** [insertion_block b] returns the basic block that the builder [b] is
1511 positioned to insert into. Raises [Not_Found] if the instruction builder is
1513 See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
1514 external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
1516 (** [insert_into_builder i name b] inserts the specified instruction [i] at the
1517 position specified by the instruction builder [b].
1518 See the method [llvm::LLVMBuilder::Insert]. *)
1519 external insert_into_builder : llvalue -> string -> llbuilder -> unit
1520 = "llvm_insert_into_builder"
1524 (** [set_current_debug_location b md] sets the current debug location [md] in
1526 See the method [llvm::IRBuilder::SetDebugLocation]. *)
1527 external set_current_debug_location : llbuilder -> llvalue -> unit
1528 = "llvm_set_current_debug_location"
1530 (** [clear_current_debug_location b] clears the current debug location in the
1532 external clear_current_debug_location : llbuilder -> unit
1533 = "llvm_clear_current_debug_location"
1535 (** [current_debug_location b] returns the current debug location, or None
1536 if none is currently set.
1537 See the method [llvm::IRBuilder::GetDebugLocation]. *)
1538 external current_debug_location : llbuilder -> llvalue option
1539 = "llvm_current_debug_location"
1541 (** [set_inst_debug_location b i] sets the current debug location of the builder
1542 [b] to the instruction [i].
1543 See the method [llvm::IRBuilder::SetInstDebugLocation]. *)
1544 external set_inst_debug_location : llbuilder -> llvalue -> unit
1545 = "llvm_set_inst_debug_location"
1547 (** {7 Terminators} *)
1549 (** [build_ret_void b] creates a
1551 instruction at the position specified by the instruction builder [b].
1552 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
1553 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
1555 (** [build_ret v b] creates a
1557 instruction at the position specified by the instruction builder [b].
1558 See the method [llvm::LLVMBuilder::CreateRet]. *)
1559 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
1561 (** [build_aggregate_ret vs b] creates a
1562 [ret {...} { %v1, %v2, ... } ]
1563 instruction at the position specified by the instruction builder [b].
1564 See the method [llvm::LLVMBuilder::CreateAggregateRet]. *)
1565 external build_aggregate_ret : llvalue array -> llbuilder -> llvalue
1566 = "llvm_build_aggregate_ret"
1568 (** [build_br bb b] creates a
1570 instruction at the position specified by the instruction builder [b].
1571 See the method [llvm::LLVMBuilder::CreateBr]. *)
1572 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
1574 (** [build_cond_br cond tbb fbb b] creates a
1575 [br %cond, %tbb, %fbb]
1576 instruction at the position specified by the instruction builder [b].
1577 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
1578 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
1579 llvalue = "llvm_build_cond_br"
1581 (** [build_switch case elsebb count b] creates an empty
1582 [switch %case, %elsebb]
1583 instruction at the position specified by the instruction builder [b] with
1584 space reserved for [count] cases.
1585 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
1586 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
1587 = "llvm_build_switch"
1589 (** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
1590 when its input matches the constant [onval].
1591 See the method [llvm::SwitchInst::addCase]. **)
1592 external add_case : llvalue -> llvalue -> llbasicblock -> unit
1595 (** [build_indirect_br addr count b] creates a
1597 instruction at the position specified by the instruction builder [b] with
1598 space reserved for [count] destinations.
1599 See the method [llvm::LLVMBuilder::CreateIndirectBr]. *)
1600 external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
1601 = "llvm_build_indirect_br"
1603 (** [add_destination br bb] adds the basic block [bb] as a possible branch
1604 location for the indirectbr instruction [br].
1605 See the method [llvm::IndirectBrInst::addDestination]. **)
1606 external add_destination : llvalue -> llbasicblock -> unit
1607 = "llvm_add_destination"
1609 (** [build_invoke fn args tobb unwindbb name b] creates an
1610 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
1611 instruction at the position specified by the instruction builder [b].
1612 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
1613 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
1614 llbasicblock -> string -> llbuilder -> llvalue
1615 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
1617 (** [build_unwind b] creates an
1619 instruction at the position specified by the instruction builder [b].
1620 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1621 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
1623 (** [build_unreachable b] creates an
1625 instruction at the position specified by the instruction builder [b].
1626 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1627 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
1630 (** {7 Arithmetic} *)
1632 (** [build_add x y name b] creates a
1633 [%name = add %x, %y]
1634 instruction at the position specified by the instruction builder [b].
1635 See the method [llvm::LLVMBuilder::CreateAdd]. *)
1636 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1639 (** [build_nsw_add x y name b] creates a
1640 [%name = nsw add %x, %y]
1641 instruction at the position specified by the instruction builder [b].
1642 See the method [llvm::LLVMBuilder::CreateNSWAdd]. *)
1643 external build_nsw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1644 = "llvm_build_nsw_add"
1646 (** [build_nuw_add x y name b] creates a
1647 [%name = nuw add %x, %y]
1648 instruction at the position specified by the instruction builder [b].
1649 See the method [llvm::LLVMBuilder::CreateNUWAdd]. *)
1650 external build_nuw_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1651 = "llvm_build_nuw_add"
1653 (** [build_fadd x y name b] creates a
1654 [%name = fadd %x, %y]
1655 instruction at the position specified by the instruction builder [b].
1656 See the method [llvm::LLVMBuilder::CreateFAdd]. *)
1657 external build_fadd : llvalue -> llvalue -> string -> llbuilder -> llvalue
1660 (** [build_sub x y name b] creates a
1661 [%name = sub %x, %y]
1662 instruction at the position specified by the instruction builder [b].
1663 See the method [llvm::LLVMBuilder::CreateSub]. *)
1664 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1667 (** [build_nsw_sub x y name b] creates a
1668 [%name = nsw sub %x, %y]
1669 instruction at the position specified by the instruction builder [b].
1670 See the method [llvm::LLVMBuilder::CreateNSWSub]. *)
1671 external build_nsw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1672 = "llvm_build_nsw_sub"
1674 (** [build_nuw_sub x y name b] creates a
1675 [%name = nuw sub %x, %y]
1676 instruction at the position specified by the instruction builder [b].
1677 See the method [llvm::LLVMBuilder::CreateNUWSub]. *)
1678 external build_nuw_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1679 = "llvm_build_nuw_sub"
1681 (** [build_fsub x y name b] creates a
1682 [%name = fsub %x, %y]
1683 instruction at the position specified by the instruction builder [b].
1684 See the method [llvm::LLVMBuilder::CreateFSub]. *)
1685 external build_fsub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1688 (** [build_mul x y name b] creates a
1689 [%name = mul %x, %y]
1690 instruction at the position specified by the instruction builder [b].
1691 See the method [llvm::LLVMBuilder::CreateMul]. *)
1692 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1695 (** [build_nsw_mul x y name b] creates a
1696 [%name = nsw mul %x, %y]
1697 instruction at the position specified by the instruction builder [b].
1698 See the method [llvm::LLVMBuilder::CreateNSWMul]. *)
1699 external build_nsw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1700 = "llvm_build_nsw_mul"
1702 (** [build_nuw_mul x y name b] creates a
1703 [%name = nuw mul %x, %y]
1704 instruction at the position specified by the instruction builder [b].
1705 See the method [llvm::LLVMBuilder::CreateNUWMul]. *)
1706 external build_nuw_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1707 = "llvm_build_nuw_mul"
1709 (** [build_fmul x y name b] creates a
1710 [%name = fmul %x, %y]
1711 instruction at the position specified by the instruction builder [b].
1712 See the method [llvm::LLVMBuilder::CreateFMul]. *)
1713 external build_fmul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1716 (** [build_udiv x y name b] creates a
1717 [%name = udiv %x, %y]
1718 instruction at the position specified by the instruction builder [b].
1719 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
1720 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1723 (** [build_sdiv x y name b] creates a
1724 [%name = sdiv %x, %y]
1725 instruction at the position specified by the instruction builder [b].
1726 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
1727 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1730 (** [build_exact_sdiv x y name b] creates a
1731 [%name = exact sdiv %x, %y]
1732 instruction at the position specified by the instruction builder [b].
1733 See the method [llvm::LLVMBuilder::CreateExactSDiv]. *)
1734 external build_exact_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1735 = "llvm_build_exact_sdiv"
1737 (** [build_fdiv x y name b] creates a
1738 [%name = fdiv %x, %y]
1739 instruction at the position specified by the instruction builder [b].
1740 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
1741 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1744 (** [build_urem x y name b] creates a
1745 [%name = urem %x, %y]
1746 instruction at the position specified by the instruction builder [b].
1747 See the method [llvm::LLVMBuilder::CreateURem]. *)
1748 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1751 (** [build_SRem x y name b] creates a
1752 [%name = srem %x, %y]
1753 instruction at the position specified by the instruction builder [b].
1754 See the method [llvm::LLVMBuilder::CreateSRem]. *)
1755 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1758 (** [build_frem x y name b] creates a
1759 [%name = frem %x, %y]
1760 instruction at the position specified by the instruction builder [b].
1761 See the method [llvm::LLVMBuilder::CreateFRem]. *)
1762 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1765 (** [build_shl x y name b] creates a
1766 [%name = shl %x, %y]
1767 instruction at the position specified by the instruction builder [b].
1768 See the method [llvm::LLVMBuilder::CreateShl]. *)
1769 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1772 (** [build_lshr x y name b] creates a
1773 [%name = lshr %x, %y]
1774 instruction at the position specified by the instruction builder [b].
1775 See the method [llvm::LLVMBuilder::CreateLShr]. *)
1776 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1779 (** [build_ashr x y name b] creates a
1780 [%name = ashr %x, %y]
1781 instruction at the position specified by the instruction builder [b].
1782 See the method [llvm::LLVMBuilder::CreateAShr]. *)
1783 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1786 (** [build_and x y name b] creates a
1787 [%name = and %x, %y]
1788 instruction at the position specified by the instruction builder [b].
1789 See the method [llvm::LLVMBuilder::CreateAnd]. *)
1790 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1793 (** [build_or x y name b] creates a
1795 instruction at the position specified by the instruction builder [b].
1796 See the method [llvm::LLVMBuilder::CreateOr]. *)
1797 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1800 (** [build_xor x y name b] creates a
1801 [%name = xor %x, %y]
1802 instruction at the position specified by the instruction builder [b].
1803 See the method [llvm::LLVMBuilder::CreateXor]. *)
1804 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1807 (** [build_neg x name b] creates a
1809 instruction at the position specified by the instruction builder [b].
1810 [-0.0] is used for floating point types to compute the correct sign.
1811 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1812 external build_neg : llvalue -> string -> llbuilder -> llvalue
1815 (** [build_nsw_neg x name b] creates a
1816 [%name = nsw sub 0, %x]
1817 instruction at the position specified by the instruction builder [b].
1818 [-0.0] is used for floating point types to compute the correct sign.
1819 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1820 external build_nsw_neg : llvalue -> string -> llbuilder -> llvalue
1821 = "llvm_build_nsw_neg"
1823 (** [build_nuw_neg x name b] creates a
1824 [%name = nuw sub 0, %x]
1825 instruction at the position specified by the instruction builder [b].
1826 [-0.0] is used for floating point types to compute the correct sign.
1827 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1828 external build_nuw_neg : llvalue -> string -> llbuilder -> llvalue
1829 = "llvm_build_nuw_neg"
1831 (** [build_fneg x name b] creates a
1832 [%name = fsub 0, %x]
1833 instruction at the position specified by the instruction builder [b].
1834 [-0.0] is used for floating point types to compute the correct sign.
1835 See the method [llvm::LLVMBuilder::CreateFNeg]. *)
1836 external build_fneg : llvalue -> string -> llbuilder -> llvalue
1839 (** [build_xor x name b] creates a
1840 [%name = xor %x, -1]
1841 instruction at the position specified by the instruction builder [b].
1842 [-1] is the correct "all ones" value for the type of [x].
1843 See the method [llvm::LLVMBuilder::CreateXor]. *)
1844 external build_not : llvalue -> string -> llbuilder -> llvalue
1850 (** [build_alloca ty name b] creates a
1851 [%name = alloca %ty]
1852 instruction at the position specified by the instruction builder [b].
1853 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1854 external build_alloca : lltype -> string -> llbuilder -> llvalue
1855 = "llvm_build_alloca"
1857 (** [build_array_alloca ty n name b] creates a
1858 [%name = alloca %ty, %n]
1859 instruction at the position specified by the instruction builder [b].
1860 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1861 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1862 llvalue = "llvm_build_array_alloca"
1864 (** [build_load v name b] creates a
1866 instruction at the position specified by the instruction builder [b].
1867 See the method [llvm::LLVMBuilder::CreateLoad]. *)
1868 external build_load : llvalue -> string -> llbuilder -> llvalue
1871 (** [build_store v p b] creates a
1873 instruction at the position specified by the instruction builder [b].
1874 See the method [llvm::LLVMBuilder::CreateStore]. *)
1875 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1876 = "llvm_build_store"
1878 (** [build_gep p indices name b] creates a
1879 [%name = getelementptr %p, indices...]
1880 instruction at the position specified by the instruction builder [b].
1881 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
1882 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1885 (** [build_in_bounds_gep p indices name b] creates a
1886 [%name = gelementptr inbounds %p, indices...]
1887 instruction at the position specified by the instruction builder [b].
1888 See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
1889 external build_in_bounds_gep : llvalue -> llvalue array -> string -> llbuilder ->
1890 llvalue = "llvm_build_in_bounds_gep"
1892 (** [build_struct_gep p idx name b] creates a
1893 [%name = getelementptr %p, 0, idx]
1894 instruction at the position specified by the instruction builder [b].
1895 See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
1896 external build_struct_gep : llvalue -> int -> string -> llbuilder ->
1897 llvalue = "llvm_build_struct_gep"
1899 (** [build_global_string str name b] creates a series of instructions that adds
1900 a global string at the position specified by the instruction builder [b].
1901 See the method [llvm::LLVMBuilder::CreateGlobalString]. *)
1902 external build_global_string : string -> string -> llbuilder -> llvalue
1903 = "llvm_build_global_string"
1905 (** [build_global_stringptr str name b] creates a series of instructions that
1906 adds a global string pointer at the position specified by the instruction
1908 See the method [llvm::LLVMBuilder::CreateGlobalStringPtr]. *)
1909 external build_global_stringptr : string -> string -> llbuilder -> llvalue
1910 = "llvm_build_global_stringptr"
1915 (** [build_trunc v ty name b] creates a
1916 [%name = trunc %p to %ty]
1917 instruction at the position specified by the instruction builder [b].
1918 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
1919 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1920 = "llvm_build_trunc"
1922 (** [build_zext v ty name b] creates a
1923 [%name = zext %p to %ty]
1924 instruction at the position specified by the instruction builder [b].
1925 See the method [llvm::LLVMBuilder::CreateZExt]. *)
1926 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1929 (** [build_sext v ty name b] creates a
1930 [%name = sext %p to %ty]
1931 instruction at the position specified by the instruction builder [b].
1932 See the method [llvm::LLVMBuilder::CreateSExt]. *)
1933 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1936 (** [build_fptoui v ty name b] creates a
1937 [%name = fptoui %p to %ty]
1938 instruction at the position specified by the instruction builder [b].
1939 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
1940 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1941 = "llvm_build_fptoui"
1943 (** [build_fptosi v ty name b] creates a
1944 [%name = fptosi %p to %ty]
1945 instruction at the position specified by the instruction builder [b].
1946 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
1947 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1948 = "llvm_build_fptosi"
1950 (** [build_uitofp v ty name b] creates a
1951 [%name = uitofp %p to %ty]
1952 instruction at the position specified by the instruction builder [b].
1953 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
1954 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1955 = "llvm_build_uitofp"
1957 (** [build_sitofp v ty name b] creates a
1958 [%name = sitofp %p to %ty]
1959 instruction at the position specified by the instruction builder [b].
1960 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
1961 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1962 = "llvm_build_sitofp"
1964 (** [build_fptrunc v ty name b] creates a
1965 [%name = fptrunc %p to %ty]
1966 instruction at the position specified by the instruction builder [b].
1967 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
1968 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1969 = "llvm_build_fptrunc"
1971 (** [build_fpext v ty name b] creates a
1972 [%name = fpext %p to %ty]
1973 instruction at the position specified by the instruction builder [b].
1974 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
1975 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1976 = "llvm_build_fpext"
1978 (** [build_ptrtoint v ty name b] creates a
1979 [%name = prtotint %p to %ty]
1980 instruction at the position specified by the instruction builder [b].
1981 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
1982 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1983 = "llvm_build_prttoint"
1985 (** [build_inttoptr v ty name b] creates a
1986 [%name = inttoptr %p to %ty]
1987 instruction at the position specified by the instruction builder [b].
1988 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
1989 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1990 = "llvm_build_inttoptr"
1992 (** [build_bitcast v ty name b] creates a
1993 [%name = bitcast %p to %ty]
1994 instruction at the position specified by the instruction builder [b].
1995 See the method [llvm::LLVMBuilder::CreateBitCast]. *)
1996 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1997 = "llvm_build_bitcast"
1999 (** [build_zext_or_bitcast v ty name b] creates a zext or bitcast
2000 instruction at the position specified by the instruction builder [b].
2001 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2002 external build_zext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2003 llvalue = "llvm_build_zext_or_bitcast"
2005 (** [build_sext_or_bitcast v ty name b] creates a sext or bitcast
2006 instruction at the position specified by the instruction builder [b].
2007 See the method [llvm::LLVMBuilder::CreateSExtOrBitCast]. *)
2008 external build_sext_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2009 llvalue = "llvm_build_sext_or_bitcast"
2011 (** [build_trunc_or_bitcast v ty name b] creates a trunc or bitcast
2012 instruction at the position specified by the instruction builder [b].
2013 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2014 external build_trunc_or_bitcast : llvalue -> lltype -> string -> llbuilder ->
2015 llvalue = "llvm_build_trunc_or_bitcast"
2017 (** [build_pointercast v ty name b] creates a bitcast or pointer-to-int
2018 instruction at the position specified by the instruction builder [b].
2019 See the method [llvm::LLVMBuilder::CreatePointerCast]. *)
2020 external build_pointercast : llvalue -> lltype -> string -> llbuilder -> llvalue
2021 = "llvm_build_pointercast"
2023 (** [build_intcast v ty name b] creates a zext, bitcast, or trunc
2024 instruction at the position specified by the instruction builder [b].
2025 See the method [llvm::LLVMBuilder::CreateIntCast]. *)
2026 external build_intcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2027 = "llvm_build_intcast"
2029 (** [build_fpcast v ty name b] creates a fpext, bitcast, or fptrunc
2030 instruction at the position specified by the instruction builder [b].
2031 See the method [llvm::LLVMBuilder::CreateFPCast]. *)
2032 external build_fpcast : llvalue -> lltype -> string -> llbuilder -> llvalue
2033 = "llvm_build_fpcast"
2036 (** {7 Comparisons} *)
2038 (** [build_icmp pred x y name b] creates a
2039 [%name = icmp %pred %x, %y]
2040 instruction at the position specified by the instruction builder [b].
2041 See the method [llvm::LLVMBuilder::CreateICmp]. *)
2042 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
2043 llbuilder -> llvalue = "llvm_build_icmp"
2045 (** [build_fcmp pred x y name b] creates a
2046 [%name = fcmp %pred %x, %y]
2047 instruction at the position specified by the instruction builder [b].
2048 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
2049 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
2050 llbuilder -> llvalue = "llvm_build_fcmp"
2053 (** {7 Miscellaneous instructions} *)
2055 (** [build_phi incoming name b] creates a
2056 [%name = phi %incoming]
2057 instruction at the position specified by the instruction builder [b].
2058 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
2059 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2060 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
2061 llvalue = "llvm_build_phi"
2063 (** [build_call fn args name b] creates a
2064 [%name = call %fn(args...)]
2065 instruction at the position specified by the instruction builder [b].
2066 See the method [llvm::LLVMBuilder::CreateCall]. *)
2067 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2070 (** [build_select cond thenv elsev name b] creates a
2071 [%name = select %cond, %thenv, %elsev]
2072 instruction at the position specified by the instruction builder [b].
2073 See the method [llvm::LLVMBuilder::CreateSelect]. *)
2074 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
2075 llvalue = "llvm_build_select"
2077 (** [build_va_arg valist argty name b] creates a
2078 [%name = va_arg %valist, %argty]
2079 instruction at the position specified by the instruction builder [b].
2080 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
2081 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
2082 = "llvm_build_va_arg"
2084 (** [build_extractelement vec i name b] creates a
2085 [%name = extractelement %vec, %i]
2086 instruction at the position specified by the instruction builder [b].
2087 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
2088 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
2089 llvalue = "llvm_build_extractelement"
2091 (** [build_insertelement vec elt i name b] creates a
2092 [%name = insertelement %vec, %elt, %i]
2093 instruction at the position specified by the instruction builder [b].
2094 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
2095 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
2096 llbuilder -> llvalue = "llvm_build_insertelement"
2098 (** [build_shufflevector veca vecb mask name b] creates a
2099 [%name = shufflevector %veca, %vecb, %mask]
2100 instruction at the position specified by the instruction builder [b].
2101 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
2102 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
2103 llbuilder -> llvalue = "llvm_build_shufflevector"
2105 (** [build_insertvalue agg idx name b] creates a
2106 [%name = extractvalue %agg, %idx]
2107 instruction at the position specified by the instruction builder [b].
2108 See the method [llvm::LLVMBuilder::CreateExtractValue]. *)
2109 external build_extractvalue : llvalue -> int -> string -> llbuilder -> llvalue
2110 = "llvm_build_extractvalue"
2112 (** [build_insertvalue agg val idx name b] creates a
2113 [%name = insertvalue %agg, %val, %idx]
2114 instruction at the position specified by the instruction builder [b].
2115 See the method [llvm::LLVMBuilder::CreateInsertValue]. *)
2116 external build_insertvalue : llvalue -> llvalue -> int -> string -> llbuilder ->
2117 llvalue = "llvm_build_insertvalue"
2119 (** [build_is_null val name b] creates a
2120 [%name = icmp eq %val, null]
2121 instruction at the position specified by the instruction builder [b].
2122 See the method [llvm::LLVMBuilder::CreateIsNull]. *)
2123 external build_is_null : llvalue -> string -> llbuilder -> llvalue
2124 = "llvm_build_is_null"
2126 (** [build_is_not_null val name b] creates a
2127 [%name = icmp ne %val, null]
2128 instruction at the position specified by the instruction builder [b].
2129 See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
2130 external build_is_not_null : llvalue -> string -> llbuilder -> llvalue
2131 = "llvm_build_is_not_null"
2133 (** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure
2134 the difference between two pointer values at the position specified by the
2135 instruction builder [b].
2136 See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2137 external build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
2138 = "llvm_build_ptrdiff"
2140 (** {6 Module providers} *)
2142 module ModuleProvider : sig
2143 (** [create_module_provider m] encapsulates [m] in a module provider and takes
2144 ownership of the module. See the constructor
2145 [llvm::ExistingModuleProvider::ExistingModuleProvider]. *)
2146 external create : llmodule -> llmoduleprovider
2147 = "LLVMCreateModuleProviderForExistingModule"
2149 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
2150 the contained module. *)
2151 external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider"
2155 (** {6 Memory buffers} *)
2157 module MemoryBuffer : sig
2158 (** [of_file p] is the memory buffer containing the contents of the file at
2159 path [p]. If the file could not be read, then [IoError msg] is
2161 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
2163 (** [stdin ()] is the memory buffer containing the contents of standard input.
2164 If standard input is empty, then [IoError msg] is raised. *)
2165 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
2167 (** Disposes of a memory buffer. *)
2168 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
2172 (** {6 Pass Managers} *)
2174 module PassManager : sig
2177 type any = [ `Module | `Function ]
2179 (** [PassManager.create ()] constructs a new whole-module pass pipeline. This
2180 type of pipeline is suitable for link-time optimization and whole-module
2182 See the constructor of [llvm::PassManager]. *)
2183 external create : unit -> [ `Module ] t = "llvm_passmanager_create"
2185 (** [PassManager.create_function mp] constructs a new function-by-function
2186 pass pipeline over the module provider [mp]. It does not take ownership of
2187 [mp]. This type of pipeline is suitable for code generation and JIT
2189 See the constructor of [llvm::FunctionPassManager]. *)
2190 external create_function : llmoduleprovider -> [ `Function ] t
2191 = "LLVMCreateFunctionPassManager"
2193 (** [run_module m pm] initializes, executes on the module [m], and finalizes
2194 all of the passes scheduled in the pass manager [pm]. Returns [true] if
2195 any of the passes modified the module, [false] otherwise.
2196 See the [llvm::PassManager::run] method. *)
2197 external run_module : llmodule -> [ `Module ] t -> bool
2198 = "llvm_passmanager_run_module"
2200 (** [initialize fpm] initializes all of the function passes scheduled in the
2201 function pass manager [fpm]. Returns [true] if any of the passes modified
2202 the module, [false] otherwise.
2203 See the [llvm::FunctionPassManager::doInitialization] method. *)
2204 external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize"
2206 (** [run_function f fpm] executes all of the function passes scheduled in the
2207 function pass manager [fpm] over the function [f]. Returns [true] if any
2208 of the passes modified [f], [false] otherwise.
2209 See the [llvm::FunctionPassManager::run] method. *)
2210 external run_function : llvalue -> [ `Function ] t -> bool
2211 = "llvm_passmanager_run_function"
2213 (** [finalize fpm] finalizes all of the function passes scheduled in in the
2214 function pass manager [fpm]. Returns [true] if any of the passes
2215 modified the module, [false] otherwise.
2216 See the [llvm::FunctionPassManager::doFinalization] method. *)
2217 external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize"
2219 (** Frees the memory of a pass pipeline. For function pipelines, does not free
2220 the module provider.
2221 See the destructor of [llvm::BasePassManager]. *)
2222 external dispose : [< any ] t -> unit = "llvm_passmanager_dispose"