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 other LLVM Intermediate Representation (IR)
21 objects. See the [llvm::Module] class. *)
24 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
25 [llvm::Type] class. *)
28 (** When building recursive types using {!refine_type}, [lltype] values may
29 become invalid; use [lltypehandle] to resolve this problem. See the
30 [llvm::AbstractTypeHolder] class. *)
33 (** Any value in the LLVM IR. Functions, instructions, global variables,
34 constants, and much more are all [llvalues]. See the [llvm::Value] class.
35 This type covers a wide range of subclasses. *)
38 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
41 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
45 (** Used to provide a module to JIT or interpreter.
46 See the [llvm::ModuleProvider] class. *)
49 (** Used to efficiently handle large buffers of read-only binary data.
50 See the [llvm::MemoryBuffer] class. *)
53 (** The kind of an [lltype], the result of [classify_type ty]. See the
54 [llvm::Type::TypeID] enumeration. *)
73 (** The linkage of a global value, accessed with {!linkage} and
74 {!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
78 | Available_externally
89 (** The linker visibility of a global value, accessed with {!visibility} and
90 {!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
91 module Visibility : sig
98 (** The following calling convention values may be accessed with
99 {!function_call_conv} and {!set_function_call_conv}. Calling
100 conventions are open-ended. *)
101 module CallConv : sig
102 val c : int (** [c] is the C calling convention. *)
103 val fast : int (** [fast] is the calling convention to allow LLVM
104 maximum optimization opportunities. Use only with
106 val cold : int (** [cold] is the calling convention for
108 val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
109 convention from C. *)
110 val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
111 convention from C. *)
114 module Attribute : sig
129 (** The predicate for an integer comparison ([icmp]) instruction.
130 See the [llvm::ICmpInst::Predicate] enumeration. *)
145 (** The predicate for a floating-point comparison ([fcmp]) instruction.
146 See the [llvm::FCmpInst::Predicate] enumeration. *)
170 (** [Before b] and [At_end a] specify positions from the start of the ['b] list
171 of [a]. [llpos] is used to specify positions in and for forward iteration
172 through the various value lists maintained by the LLVM IR. *)
173 type ('a, 'b) llpos =
177 (** [After b] and [At_start a] specify positions from the end of the ['b] list
178 of [a]. [llrev_pos] is used for reverse iteration through the various value
179 lists maintained by the LLVM IR. *)
180 type ('a, 'b) llrev_pos =
185 (** {6 Exceptions} *)
187 exception IoError of string
192 (** [create_module id] creates a module with the supplied module ID. Modules are
193 not garbage collected; it is mandatory to call {!dispose_module} to free
194 memory. See the constructor [llvm::Module::Module]. *)
195 external create_module : string -> llmodule = "llvm_create_module"
197 (** [dispose_module m] destroys a module [m] and all of the IR objects it
198 contained. All references to subordinate objects are invalidated;
199 referencing them will invoke undefined behavior. See the destructor
200 [llvm::Module::~Module]. *)
201 external dispose_module : llmodule -> unit = "llvm_dispose_module"
203 (** [target_triple m] is the target specifier for the module [m], something like
204 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
205 external target_triple: llmodule -> string
206 = "llvm_target_triple"
208 (** [target_triple triple m] changes the target specifier for the module [m] to
209 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
210 external set_target_triple: string -> llmodule -> unit
211 = "llvm_set_target_triple"
213 (** [data_layout m] is the data layout specifier for the module [m], something
214 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
215 method [llvm::Module::getDataLayout]. *)
216 external data_layout: llmodule -> string
219 (** [set_data_layout s m] changes the data layout specifier for the module [m]
220 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
221 external set_data_layout: string -> llmodule -> unit
222 = "llvm_set_data_layout"
224 (** [define_type_name name ty m] adds a named type to the module's symbol table.
225 Returns [true] if successful. If such a name already exists, then no entry
226 is added and [false] is returned. See the [llvm::Module::addTypeName]
228 external define_type_name : string -> lltype -> llmodule -> bool
229 = "llvm_add_type_name"
231 (** [delete_type_name name] removes a type name from the module's symbol
233 external delete_type_name : string -> llmodule -> unit
234 = "llvm_delete_type_name"
236 (** [dump_module m] prints the .ll representation of the module [m] to standard
237 error. See the method [llvm::Module::dump]. *)
238 external dump_module : llmodule -> unit = "llvm_dump_module"
243 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
244 See the method [llvm::Type::getTypeID]. *)
245 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
247 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
248 val string_of_lltype : lltype -> string
250 (** {7 Operations on integer types} *)
252 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. *)
255 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. *)
258 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. *)
259 val i16_type : lltype
261 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. *)
262 val i32_type : lltype
264 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. *)
265 val i64_type : lltype
267 (** [integer_type n] returns an integer type of bitwidth [n].
268 See the method [llvm::IntegerType::get]. *)
269 external integer_type : int -> lltype = "llvm_integer_type"
271 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty].
272 See the method [llvm::IntegerType::getBitWidth]. *)
273 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
276 (** {7 Operations on real types} *)
278 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. *)
279 val float_type : lltype
281 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. *)
282 val double_type : lltype
284 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. *)
285 val x86fp80_type : lltype
287 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. *)
288 val fp128_type : lltype
290 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. *)
291 val ppc_fp128_type : lltype
294 (** {7 Operations on function types} *)
296 (** [function_type ret_ty param_tys] returns the function type returning
297 [ret_ty] and taking [param_tys] as parameters.
298 See the method [llvm::FunctionType::get]. *)
299 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
301 (** [va_arg_function_type ret_ty param_tys] is just like
302 [function_type ret_ty param_tys] except that it returns the function type
303 which also takes a variable number of arguments.
304 See the method [llvm::FunctionType::get]. *)
305 external var_arg_function_type : lltype -> lltype array -> lltype
306 = "llvm_var_arg_function_type"
308 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
309 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
310 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
312 (** [return_type fty] gets the return type of the function type [fty].
313 See the method [llvm::FunctionType::getReturnType]. *)
314 external return_type : lltype -> lltype = "LLVMGetReturnType"
316 (** [param_types fty] gets the parameter types of the function type [fty].
317 See the method [llvm::FunctionType::getParamType]. *)
318 external param_types : lltype -> lltype array = "llvm_param_types"
321 (** {7 Operations on struct types} *)
323 (** [struct_type tys] returns the structure type containing in the types in the
324 array [tys]. See the method [llvm::StructType::get]. *)
325 external struct_type : lltype array -> lltype = "llvm_struct_type"
327 (** [struct_type tys] returns the packed structure type containing in the types
328 in the array [tys]. See the method [llvm::StructType::get]. *)
329 external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
331 (** [element_types sty] returns the constituent types of the struct type [sty].
332 See the method [llvm::StructType::getElementType]. *)
333 external element_types : lltype -> lltype array = "llvm_element_types"
335 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
336 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
337 external is_packed : lltype -> bool = "llvm_is_packed"
340 (** {7 Operations on pointer, vector, and array types} *)
342 (** [array_type ty n] returns the array type containing [n] elements of type
343 [ty]. See the method [llvm::ArrayType::get]. *)
344 external array_type : lltype -> int -> lltype = "llvm_array_type"
346 (** [pointer_type ty] returns the pointer type referencing objects of type
347 [ty] in the default address space (0).
348 See the method [llvm::PointerType::getUnqual]. *)
349 external pointer_type : lltype -> lltype = "llvm_pointer_type"
351 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
352 of type [ty] in address space [as].
353 See the method [llvm::PointerType::get]. *)
354 external qualified_pointer_type : lltype -> int -> lltype
355 = "llvm_qualified_pointer_type"
357 (** [vector_type ty n] returns the array type containing [n] elements of the
358 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
359 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
361 (** [element_type ty] returns the element type of the pointer, vector, or array
362 type [ty]. See the method [llvm::SequentialType::get]. *)
363 external element_type : lltype -> lltype = "LLVMGetElementType"
365 (** [element_type aty] returns the element count of the array type [aty].
366 See the method [llvm::ArrayType::getNumElements]. *)
367 external array_length : lltype -> int = "llvm_array_length"
369 (** [address_space pty] returns the address space qualifier of the pointer type
370 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
371 external address_space : lltype -> int = "llvm_address_space"
373 (** [element_type ty] returns the element count of the vector type [ty].
374 See the method [llvm::VectorType::getNumElements]. *)
375 external vector_size : lltype -> int = "llvm_vector_size"
378 (** {7 Operations on other types} *)
380 (** [opaque_type ()] creates a new opaque type distinct from any other.
381 Opaque types are useful for building recursive types in combination with
383 See [llvm::OpaqueType::get]. *)
384 external opaque_type : unit -> lltype = "llvm_opaque_type"
386 (** [void_type] is the type of a function which does not return any value.
387 See [llvm::Type::VoidTy]. *)
388 val void_type : lltype
390 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. *)
391 val label_type : lltype
393 (** {7 Operations on type handles} *)
395 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
396 refined as a result of a call to {!refine_type}, the handle will be updated;
397 any bare [lltype] references will become invalid.
398 See the class [llvm::PATypeHolder]. *)
399 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
401 (** [type_of_handle tyh] resolves the type handle [tyh].
402 See the method [llvm::PATypeHolder::get()]. *)
403 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
405 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
406 concrete type [ty] in all users. Warning: This may invalidate {!lltype}
407 values! Use {!lltypehandle} to manipulate potentially abstract types. See
408 the method [llvm::Type::refineAbstractType]. *)
409 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
414 (** [type_of v] returns the type of the value [v].
415 See the method [llvm::Value::getType]. *)
416 external type_of : llvalue -> lltype = "llvm_type_of"
418 (** [value_name v] returns the name of the value [v]. For global values, this is
419 the symbol name. For instructions and basic blocks, it is the SSA register
420 name. It is meaningless for constants.
421 See the method [llvm::Value::getName]. *)
422 external value_name : llvalue -> string = "llvm_value_name"
424 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
425 [llvm::Value::setName]. *)
426 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
428 (** [dump_value v] prints the .ll representation of the value [v] to standard
429 error. See the method [llvm::Value::dump]. *)
430 external dump_value : llvalue -> unit = "llvm_dump_value"
433 (** {7 Operations on constants of (mostly) any type} *)
435 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
436 otherwise. Similar to [llvm::isa<Constant>]. *)
437 external is_constant : llvalue -> bool = "llvm_is_constant"
439 (** [const_null ty] returns the constant null (zero) of the type [ty].
440 See the method [llvm::Constant::getNullValue]. *)
441 external const_null : lltype -> llvalue = "LLVMConstNull"
443 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
444 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
445 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
447 (** [undef ty] returns the undefined value of the type [ty].
448 See the method [llvm::UndefValue::get]. *)
449 external undef : lltype -> llvalue = "LLVMGetUndef"
451 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
452 See the method [llvm::Constant::isNullValue]. *)
453 external is_null : llvalue -> bool = "llvm_is_null"
455 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
456 otherwise. Similar to [llvm::isa<UndefValue>]. *)
457 external is_undef : llvalue -> bool = "llvm_is_undef"
460 (** {7 Operations on scalar constants} *)
462 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
463 See the method [llvm::ConstantInt::get]. *)
464 external const_int : lltype -> int -> llvalue = "llvm_const_int"
466 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
467 [i]. See the method [llvm::ConstantInt::get]. *)
468 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
469 = "llvm_const_of_int64"
471 (** [const_float ty n] returns the floating point constant of type [ty] and
472 value [n]. See the method [llvm::ConstantInt::get]. *)
473 external const_float : lltype -> float -> llvalue = "llvm_const_float"
476 (** {7 Operations on composite constants} *)
478 (** [const_string s] returns the constant [i8] array with the values of the
479 characters in the string [s]. The array is not null-terminated (but see
480 {!const_stringz}). This value can in turn be used as the initializer for a
481 global variable. See the method [llvm::ConstantArray::get]. *)
482 external const_string : string -> llvalue = "llvm_const_string"
484 (** [const_stringz s] returns the constant [i8] array with the values of the
485 characters in the string [s] and a null terminator. This value can in turn
486 be used as the initializer for a global variable.
487 See the method [llvm::ConstantArray::get]. *)
488 external const_stringz : string -> llvalue = "llvm_const_stringz"
490 (** [const_array ty elts] returns the constant array of type
491 [array_type ty (Array.length elts)] and containing the values [elts].
492 This value can in turn be used as the initializer for a global variable.
493 See the method [llvm::ConstantArray::get]. *)
494 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
496 (** [const_struct elts] returns the structured constant of type
497 [struct_type (Array.map type_of elts)] and containing the values [elts].
498 This value can in turn be used as the initializer for a global variable.
499 See the method [llvm::ConstantStruct::get]. *)
500 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
502 (** [const_packed_struct elts] returns the structured constant of type
503 {!packed_struct_type} [(Array.map type_of elts)] and containing the values
504 [elts]. This value can in turn be used as the initializer for a global
505 variable. See the method [llvm::ConstantStruct::get]. *)
506 external const_packed_struct : llvalue array -> llvalue
507 = "llvm_const_packed_struct"
509 (** [const_vector elts] returns the vector constant of type
510 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
511 values [elts]. See the method [llvm::ConstantVector::get]. *)
512 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
515 (** {7 Constant expressions} *)
517 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
518 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
519 (const_int i64_type 1)) i64_type], but considerably more readable.
520 See the method [llvm::ConstantExpr::getSizeOf]. *)
521 external size_of : lltype -> llvalue = "LLVMSizeOf"
523 (** [const_neg c] returns the arithmetic negation of the constant [c].
524 See the method [llvm::ConstantExpr::getNeg]. *)
525 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
527 (** [const_not c] returns the bitwise inverse of the constant [c].
528 See the method [llvm::ConstantExpr::getNot]. *)
529 external const_not : llvalue -> llvalue = "LLVMConstNot"
531 (** [const_add c1 c2] returns the constant sum of two constants.
532 See the method [llvm::ConstantExpr::getAdd]. *)
533 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
535 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
536 constants. See the method [llvm::ConstantExpr::getSub]. *)
537 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
539 (** [const_mul c1 c2] returns the constant product of two constants.
540 See the method [llvm::ConstantExpr::getMul]. *)
541 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
543 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
545 See the method [llvm::ConstantExpr::getUDiv]. *)
546 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
548 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
550 See the method [llvm::ConstantExpr::]. *)
551 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
553 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
555 See the method [llvm::ConstantExpr::getFDiv]. *)
556 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
558 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
559 unsigned integer constants.
560 See the method [llvm::ConstantExpr::getURem]. *)
561 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
563 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
564 signed integer constants.
565 See the method [llvm::ConstantExpr::getSRem]. *)
566 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
568 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
569 signed floating point constants.
570 See the method [llvm::ConstantExpr::getFRem]. *)
571 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
573 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
575 See the method [llvm::ConstantExpr::getAnd]. *)
576 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
578 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
580 See the method [llvm::ConstantExpr::getOr]. *)
581 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
583 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
585 See the method [llvm::ConstantExpr::getXor]. *)
586 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
588 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
589 constants, [c1 pred c2].
590 See the method [llvm::ConstantExpr::getICmp]. *)
591 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
594 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
595 point constants, [c1 pred c2].
596 See the method [llvm::ConstantExpr::getFCmp]. *)
597 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
600 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
601 constant integer [c2].
602 See the method [llvm::ConstantExpr::getShl]. *)
603 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
605 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
606 constant integer [c2] with zero extension.
607 See the method [llvm::ConstantExpr::getLShr]. *)
608 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
610 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
611 constant integer [c2] with sign extension.
612 See the method [llvm::ConstantExpr::getAShr]. *)
613 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
615 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
616 constant integers indices from the array [indices].
617 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
618 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
620 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
621 to the smaller integer type [ty].
622 See the method [llvm::ConstantExpr::getTrunc]. *)
623 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
625 (** [const_sext c ty] returns the constant sign extension of integer constant
626 [c] to the larger integer type [ty].
627 See the method [llvm::ConstantExpr::getSExt]. *)
628 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
630 (** [const_zext c ty] returns the constant zero extension of integer constant
631 [c] to the larger integer type [ty].
632 See the method [llvm::ConstantExpr::getZExt]. *)
633 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
635 (** [const_fptrunc c ty] returns the constant truncation of floating point
636 constant [c] to the smaller floating point type [ty].
637 See the method [llvm::ConstantExpr::getFPTrunc]. *)
638 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
640 (** [const_fpext c ty] returns the constant extension of floating point constant
641 [c] to the larger floating point type [ty].
642 See the method [llvm::ConstantExpr::getFPExt]. *)
643 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
645 (** [const_uitofp c ty] returns the constant floating point conversion of
646 unsigned integer constant [c] to the floating point type [ty].
647 See the method [llvm::ConstantExpr::getUIToFP]. *)
648 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
650 (** [const_sitofp c ty] returns the constant floating point conversion of
651 signed integer constant [c] to the floating point type [ty].
652 See the method [llvm::ConstantExpr::getSIToFP]. *)
653 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
655 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
656 floating point constant [c] to integer type [ty].
657 See the method [llvm::ConstantExpr::getFPToUI]. *)
658 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
660 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
661 floating point constant [c] to integer type [ty].
662 See the method [llvm::ConstantExpr::getFPToSI]. *)
663 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
665 (** [const_ptrtoint c ty] returns the constant integer conversion of
666 pointer constant [c] to integer type [ty].
667 See the method [llvm::ConstantExpr::getPtrToInt]. *)
668 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
670 (** [const_inttoptr c ty] returns the constant pointer conversion of
671 integer constant [c] to pointer type [ty].
672 See the method [llvm::ConstantExpr::getIntToPtr]. *)
673 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
675 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
676 to type [ty] of equal size.
677 See the method [llvm::ConstantExpr::getBitCast]. *)
678 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
680 (** [const_select cond t f] returns the constant conditional which returns value
681 [t] if the boolean constant [cond] is true and the value [f] otherwise.
682 See the method [llvm::ConstantExpr::getSelect]. *)
683 external const_select : llvalue -> llvalue -> llvalue -> llvalue
686 (** [const_extractelement vec i] returns the constant [i]th element of
687 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
688 the size of the vector.
689 See the method [llvm::ConstantExpr::getExtractElement]. *)
690 external const_extractelement : llvalue -> llvalue -> llvalue
691 = "LLVMConstExtractElement"
693 (** [const_insertelement vec v i] returns the constant vector with the same
694 elements as constant vector [v] but the [i]th element replaced by the
695 constant [v]. [v] must be a constant value with the type of the vector
696 elements. [i] must be a constant [i32] value unsigned less than the size
698 See the method [llvm::ConstantExpr::getInsertElement]. *)
699 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
700 = "LLVMConstInsertElement"
702 (** [const_shufflevector a b mask] returns a constant [shufflevector].
703 See the LLVM Language Reference for details on the [sufflevector]
705 See the method [llvm::ConstantExpr::getShuffleVector]. *)
706 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
707 = "LLVMConstShuffleVector"
710 (** {7 Operations on global variables, functions, and aliases (globals)} *)
712 (** [global_parent g] is the enclosing module of the global value [g].
713 See the method [llvm::GlobalValue::getParent]. *)
714 external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
716 (** [is_declaration g] returns [true] if the global value [g] is a declaration
717 only. Returns [false] otherwise.
718 See the method [llvm::GlobalValue::isDeclaration]. *)
719 external is_declaration : llvalue -> bool = "llvm_is_declaration"
721 (** [linkage g] returns the linkage of the global value [g].
722 See the method [llvm::GlobalValue::getLinkage]. *)
723 external linkage : llvalue -> Linkage.t = "llvm_linkage"
725 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
726 See the method [llvm::GlobalValue::setLinkage]. *)
727 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
729 (** [section g] returns the linker section of the global value [g].
730 See the method [llvm::GlobalValue::getSection]. *)
731 external section : llvalue -> string = "llvm_section"
733 (** [set_section s g] sets the linker section of the global value [g] to [s].
734 See the method [llvm::GlobalValue::setSection]. *)
735 external set_section : string -> llvalue -> unit = "llvm_set_section"
737 (** [visibility g] returns the linker visibility of the global value [g].
738 See the method [llvm::GlobalValue::getVisibility]. *)
739 external visibility : llvalue -> Visibility.t = "llvm_visibility"
741 (** [set_visibility v g] sets the linker visibility of the global value [g] to
742 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
743 external set_visibility : Visibility.t -> llvalue -> unit
744 = "llvm_set_visibility"
746 (** [alignment g] returns the required alignment of the global value [g].
747 See the method [llvm::GlobalValue::getAlignment]. *)
748 external alignment : llvalue -> int = "llvm_alignment"
750 (** [set_alignment n g] sets the required alignment of the global value [g] to
751 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
752 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
755 (** {7 Operations on global variables} *)
757 (** [declare_global ty name m] returns a new global variable of type [ty] and
758 with name [name] in module [m]. If such a global variable already exists,
759 it is returned. If the type of the existing global differs, then a bitcast
760 to [ty] is returned. *)
761 external declare_global : lltype -> string -> llmodule -> llvalue
762 = "llvm_declare_global"
764 (** [define_global name init m] returns a new global with name [name] and
765 initializer [init] in module [m]. If the named global already exists, it is
767 See the constructor of [llvm::GlobalVariable]. *)
768 external define_global : string -> llvalue -> llmodule -> llvalue
769 = "llvm_define_global"
771 (** [lookup_global name m] returns [Some g] if a global variable with name
772 [name] exists in module [m]. If no such global exists, returns [None].
773 See the [llvm::GlobalVariable] constructor. *)
774 external lookup_global : string -> llmodule -> llvalue option
775 = "llvm_lookup_global"
777 (** [delete_global gv] destroys the global variable [gv].
778 See the method [llvm::GlobalVariable::eraseFromParent]. *)
779 external delete_global : llvalue -> unit = "llvm_delete_global"
781 (** [global_begin m] returns the first position in the global variable list of
782 the module [m]. [global_begin] and [global_succ] can be used to iterate
783 over the global list in order.
784 See the method [llvm::Module::global_begin]. *)
785 external global_begin : llmodule -> (llmodule, llvalue) llpos
786 = "llvm_global_begin"
788 (** [global_succ gv] returns the global variable list position succeeding
790 See the method [llvm::Module::global_iterator::operator++]. *)
791 external global_succ : llvalue -> (llmodule, llvalue) llpos
794 (** [iter_globals f m] applies function [f] to each of the global variables of
795 module [m] in order. Tail recursive. *)
796 val iter_globals : (llvalue -> unit) -> llmodule -> unit
798 (** [fold_left_globals f init m] is [f (... (f init g1) ...) gN] where
799 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
800 val fold_left_globals : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
802 (** [global_end m] returns the last position in the global variable list of the
803 module [m]. [global_end] and [global_pred] can be used to iterate over the
804 global list in reverse.
805 See the method [llvm::Module::global_end]. *)
806 external global_end : llmodule -> (llmodule, llvalue) llrev_pos
809 (** [global_pred gv] returns the global variable list position preceding
811 See the method [llvm::Module::global_iterator::operator--]. *)
812 external global_pred : llvalue -> (llmodule, llvalue) llrev_pos
815 (** [rev_iter_globals f m] applies function [f] to each of the global variables
816 of module [m] in reverse order. Tail recursive. *)
817 val rev_iter_globals : (llvalue -> unit) -> llmodule -> unit
819 (** [fold_right_globals f m init] is [f g1 (... (f gN init) ...)] where
820 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
821 val fold_right_globals : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
823 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
824 constant. Returns [false] otherwise.
825 See the method [llvm::GlobalVariable::isConstant]. *)
826 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
828 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
829 [c] is [true] and not if [c] is [false].
830 See the method [llvm::GlobalVariable::setConstant]. *)
831 external set_global_constant : bool -> llvalue -> unit
832 = "llvm_set_global_constant"
834 (** [global_initializer gv] returns the initializer for the global variable
835 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
836 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
838 (** [set_initializer c gv] sets the initializer for the global variable
839 [gv] to the constant [c].
840 See the method [llvm::GlobalVariable::setInitializer]. *)
841 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
843 (** [remove_initializer gv] unsets the initializer for the global variable
845 See the method [llvm::GlobalVariable::setInitializer]. *)
846 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
848 (** [is_thread_local gv] returns [true] if the global variable [gv] is
849 thread-local and [false] otherwise.
850 See the method [llvm::GlobalVariable::isThreadLocal]. *)
851 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
853 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
854 [c] is [true] and not otherwise.
855 See the method [llvm::GlobalVariable::setThreadLocal]. *)
856 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
859 (** {7 Operations on functions} *)
861 (** [declare_function name ty m] returns a new function of type [ty] and
862 with name [name] in module [m]. If such a function already exists,
863 it is returned. If the type of the existing function differs, then a bitcast
864 to [ty] is returned. *)
865 external declare_function : string -> lltype -> llmodule -> llvalue
866 = "llvm_declare_function"
868 (** [define_function name ty m] creates a new function with name [name] and
869 type [ty] in module [m]. If the named function already exists, it is
870 renamed. An entry basic block is created in the function.
871 See the constructor of [llvm::GlobalVariable]. *)
872 external define_function : string -> lltype -> llmodule -> llvalue
873 = "llvm_define_function"
875 (** [lookup_function name m] returns [Some f] if a function with name
876 [name] exists in module [m]. If no such function exists, returns [None].
877 See the method [llvm::Module] constructor. *)
878 external lookup_function : string -> llmodule -> llvalue option
879 = "llvm_lookup_function"
881 (** [delete_function f] destroys the function [f].
882 See the method [llvm::Function::eraseFromParent]. *)
883 external delete_function : llvalue -> unit = "llvm_delete_function"
885 (** [function_begin m] returns the first position in the function list of the
886 module [m]. [function_begin] and [function_succ] can be used to iterate over
887 the function list in order.
888 See the method [llvm::Module::begin]. *)
889 external function_begin : llmodule -> (llmodule, llvalue) llpos
890 = "llvm_function_begin"
892 (** [function_succ gv] returns the function list position succeeding
894 See the method [llvm::Module::iterator::operator++]. *)
895 external function_succ : llvalue -> (llmodule, llvalue) llpos
896 = "llvm_function_succ"
898 (** [iter_functions f m] applies function [f] to each of the functions of module
899 [m] in order. Tail recursive. *)
900 val iter_functions : (llvalue -> unit) -> llmodule -> unit
902 (** [fold_left_function f init m] is [f (... (f init f1) ...) fN] where
903 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
904 val fold_left_functions : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
906 (** [function_end m] returns the last position in the function list of
907 the module [m]. [function_end] and [function_pred] can be used to iterate
908 over the function list in reverse.
909 See the method [llvm::Module::end]. *)
910 external function_end : llmodule -> (llmodule, llvalue) llrev_pos
911 = "llvm_function_end"
913 (** [function_pred gv] returns the function list position preceding [After gv].
914 See the method [llvm::Module::iterator::operator--]. *)
915 external function_pred : llvalue -> (llmodule, llvalue) llrev_pos
916 = "llvm_function_pred"
918 (** [rev_iter_functions f fn] applies function [f] to each of the functions of
919 module [m] in reverse order. Tail recursive. *)
920 val rev_iter_functions : (llvalue -> unit) -> llmodule -> unit
922 (** [fold_right_functions f m init] is [f (... (f init fN) ...) f1] where
923 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
924 val fold_right_functions : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
926 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
927 See the method [llvm::Function::isIntrinsic]. *)
928 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
930 (** [function_call_conv f] returns the calling convention of the function [f].
931 See the method [llvm::Function::getCallingConv]. *)
932 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
934 (** [set_function_call_conv cc f] sets the calling convention of the function
935 [f] to the calling convention numbered [cc].
936 See the method [llvm::Function::setCallingConv]. *)
937 external set_function_call_conv : int -> llvalue -> unit
938 = "llvm_set_function_call_conv"
940 (** [gc f] returns [Some name] if the function [f] has a garbage
941 collection algorithm specified and [None] otherwise.
942 See the method [llvm::Function::getGC]. *)
943 external gc : llvalue -> string option = "llvm_gc"
945 (** [set_gc gc f] sets the collection algorithm for the function [f] to
946 [gc]. See the method [llvm::Function::setGC]. *)
947 external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
949 (** [add_function_attr f a] adds attribute [a] to the return type of function
951 external add_function_attr : llvalue -> Attribute.t -> unit
952 = "llvm_add_function_attr"
954 (** [remove_function_attr f a] removes attribute [a] from the return type of
956 external remove_function_attr : llvalue -> Attribute.t -> unit
957 = "llvm_remove_function_attr"
959 (** {7 Operations on params} *)
961 (** [params f] returns the parameters of function [f].
962 See the method [llvm::Function::getArgumentList]. *)
963 external params : llvalue -> llvalue array = "llvm_params"
965 (** [param f n] returns the [n]th parameter of function [f].
966 See the method [llvm::Function::getArgumentList]. *)
967 external param : llvalue -> int -> llvalue = "llvm_param"
969 (** [param_parent p] returns the parent function that owns the parameter.
970 See the method [llvm::Argument::getParent]. *)
971 external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
973 (** [param_begin f] returns the first position in the parameter list of the
974 function [f]. [param_begin] and [param_succ] can be used to iterate over
975 the parameter list in order.
976 See the method [llvm::Function::arg_begin]. *)
977 external param_begin : llvalue -> (llvalue, llvalue) llpos = "llvm_param_begin"
979 (** [param_succ bb] returns the parameter list position succeeding
981 See the method [llvm::Function::arg_iterator::operator++]. *)
982 external param_succ : llvalue -> (llvalue, llvalue) llpos = "llvm_param_succ"
984 (** [iter_params f fn] applies function [f] to each of the parameters
985 of function [fn] in order. Tail recursive. *)
986 val iter_params : (llvalue -> unit) -> llvalue -> unit
988 (** [fold_left_params f init fn] is [f (... (f init b1) ...) bN] where
989 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
990 val fold_left_params : ('a -> llvalue -> 'a) -> 'a -> llvalue -> 'a
992 (** [param_end f] returns the last position in the parameter list of
993 the function [f]. [param_end] and [param_pred] can be used to iterate
994 over the parameter list in reverse.
995 See the method [llvm::Function::arg_end]. *)
996 external param_end : llvalue -> (llvalue, llvalue) llrev_pos = "llvm_param_end"
998 (** [param_pred gv] returns the function list position preceding [After gv].
999 See the method [llvm::Function::arg_iterator::operator--]. *)
1000 external param_pred : llvalue -> (llvalue, llvalue) llrev_pos
1003 (** [rev_iter_params f fn] applies function [f] to each of the parameters
1004 of function [fn] in reverse order. Tail recursive. *)
1005 val rev_iter_params : (llvalue -> unit) -> llvalue -> unit
1007 (** [fold_right_params f fn init] is [f (... (f init bN) ...) b1] where
1008 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1009 val fold_right_params : (llvalue -> 'a -> 'a) -> llvalue -> 'a -> 'a
1011 (** [add_param p a] adds attribute [a] to parameter [p]. *)
1012 external add_param_attr : llvalue -> Attribute.t -> unit = "llvm_add_param_attr"
1014 (** [remove_param_attr p a] removes attribute [a] from parameter [p]. *)
1015 external remove_param_attr : llvalue -> Attribute.t -> unit
1016 = "llvm_remove_param_attr"
1018 (** [set_param_alignment p a] set the alignment of parameter [p] to [a]. *)
1019 external set_param_alignment : llvalue -> int -> unit
1020 = "llvm_set_param_alignment"
1022 (** {7 Operations on basic blocks} *)
1024 (** [basic_blocks fn] returns the basic blocks of the function [f].
1025 See the method [llvm::Function::getBasicBlockList]. *)
1026 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
1028 (** [entry_block fn] returns the entry basic block of the function [f].
1029 See the method [llvm::Function::getEntryBlock]. *)
1030 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
1032 (** [delete_block bb] deletes the basic block [bb].
1033 See the method [llvm::BasicBlock::eraseFromParent]. *)
1034 external delete_block : llbasicblock -> unit = "llvm_delete_block"
1036 (** [append_block name f] creates a new basic block named [name] at the end of
1038 See the constructor of [llvm::BasicBlock]. *)
1039 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
1041 (** [insert_block name bb] creates a new basic block named [name] before the
1043 See the constructor of [llvm::BasicBlock]. *)
1044 external insert_block : string -> llbasicblock -> llbasicblock
1045 = "llvm_insert_block"
1047 (** [block_parent bb] returns the parent function that owns the basic block.
1048 See the method [llvm::BasicBlock::getParent]. *)
1049 external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
1051 (** [block_begin f] returns the first position in the basic block list of the
1052 function [f]. [block_begin] and [block_succ] can be used to iterate over
1053 the basic block list in order.
1054 See the method [llvm::Function::begin]. *)
1055 external block_begin : llvalue -> (llvalue, llbasicblock) llpos
1056 = "llvm_block_begin"
1058 (** [block_succ bb] returns the basic block list position succeeding
1060 See the method [llvm::Function::iterator::operator++]. *)
1061 external block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
1064 (** [iter_blocks f fn] applies function [f] to each of the basic blocks
1065 of function [fn] in order. Tail recursive. *)
1066 val iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1068 (** [fold_left_blocks f init fn] is [f (... (f init b1) ...) bN] where
1069 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1070 val fold_left_blocks : ('a -> llbasicblock -> 'a) -> 'a -> llvalue -> 'a
1072 (** [block_end f] returns the last position in the basic block list of
1073 the function [f]. [block_end] and [block_pred] can be used to iterate
1074 over the basic block list in reverse.
1075 See the method [llvm::Function::end]. *)
1076 external block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
1079 (** [block_pred gv] returns the function list position preceding [After gv].
1080 See the method [llvm::Function::iterator::operator--]. *)
1081 external block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
1084 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
1085 of function [fn] in reverse order. Tail recursive. *)
1086 val rev_iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
1088 (** [fold_right_blocks f fn init] is [f (... (f init bN) ...) b1] where
1089 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1090 val fold_right_blocks : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
1092 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
1093 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
1095 (** [value_is_block v] returns [true] if the value [v] is a basic block and
1097 Similar to [llvm::isa<BasicBlock>]. *)
1098 external value_is_block : llvalue -> bool = "llvm_value_is_block"
1100 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
1101 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
1104 (** {7 Operations on instructions} *)
1106 (** [instr_parent i] is the enclosing basic block of the instruction [i].
1107 See the method [llvm::Instruction::getParent]. *)
1108 external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
1110 (** [instr_begin bb] returns the first position in the instruction list of the
1111 basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
1112 the instruction list in order.
1113 See the method [llvm::BasicBlock::begin]. *)
1114 external instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
1115 = "llvm_instr_begin"
1117 (** [instr_succ i] returns the instruction list position succeeding [Before i].
1118 See the method [llvm::BasicBlock::iterator::operator++]. *)
1119 external instr_succ : llvalue -> (llbasicblock, llvalue) llpos
1122 (** [iter_instrs f bb] applies function [f] to each of the instructions of basic
1123 block [bb] in order. Tail recursive. *)
1124 val iter_instrs: (llvalue -> unit) -> llbasicblock -> unit
1126 (** [fold_left_instrs f init bb] is [f (... (f init g1) ...) gN] where
1127 [g1,...,gN] are the instructions of basic block [bb]. Tail recursive. *)
1128 val fold_left_instrs: ('a -> llvalue -> 'a) -> 'a -> llbasicblock -> 'a
1130 (** [instr_end bb] returns the last position in the instruction list of the
1131 basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
1132 the instruction list in reverse.
1133 See the method [llvm::BasicBlock::end]. *)
1134 external instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
1137 (** [instr_pred i] returns the instruction list position preceding [After i].
1138 See the method [llvm::BasicBlock::iterator::operator--]. *)
1139 external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
1142 (** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
1143 [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
1144 val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a
1147 (** {7 Operations on call sites} *)
1149 (** [instruction_call_conv ci] is the calling convention for the call or invoke
1150 instruction [ci], which may be one of the values from the module
1151 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
1152 [llvm::InvokeInst::getCallingConv]. *)
1153 external instruction_call_conv: llvalue -> int
1154 = "llvm_instruction_call_conv"
1156 (** [set_instruction_call_conv cc ci] sets the calling convention for the call
1157 or invoke instruction [ci] to the integer [cc], which can be one of the
1158 values from the module {!CallConv}.
1159 See the method [llvm::CallInst::setCallingConv]
1160 and [llvm::InvokeInst::setCallingConv]. *)
1161 external set_instruction_call_conv: int -> llvalue -> unit
1162 = "llvm_set_instruction_call_conv"
1164 (** [add_instruction_param_attr ci i a] adds attribute [a] to the [i]th
1165 parameter of the call or invoke instruction [ci]. [i]=0 denotes the return
1167 external add_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1168 = "llvm_add_instruction_param_attr"
1170 (** [remove_instruction_param_attr ci i a] removes attribute [a] from the
1171 [i]th parameter of the call or invoke instruction [ci]. [i]=0 denotes the
1173 external remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
1174 = "llvm_remove_instruction_param_attr"
1176 (** {Operations on call instructions (only)} *)
1178 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
1179 eligible for tail call optimization, [false] otherwise.
1180 See the method [llvm::CallInst::isTailCall]. *)
1181 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
1183 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
1184 call optimization if [tc] is [true], clears otherwise.
1185 See the method [llvm::CallInst::setTailCall]. *)
1186 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
1188 (** {7 Operations on phi nodes} *)
1190 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
1191 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
1192 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
1193 = "llvm_add_incoming"
1195 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
1196 See the method [llvm::PHINode::getIncomingValue]. *)
1197 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
1201 (** {6 Instruction builders} *)
1203 (** [builder ()] creates an instruction builder with no position. It is invalid
1204 to use this builder until its position is set with {!position_before} or
1205 {!position_at_end}. See the constructor for [llvm::LLVMBuilder]. *)
1206 external builder : unit -> llbuilder = "llvm_builder"
1208 (** [builder_at ip] creates an instruction builder positioned at [ip].
1209 See the constructor for [llvm::LLVMBuilder]. *)
1210 val builder_at : (llbasicblock, llvalue) llpos -> llbuilder
1212 (** [builder_before ins] creates an instruction builder positioned before the
1213 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
1214 val builder_before : llvalue -> llbuilder
1216 (** [builder_at_end bb] creates an instruction builder positioned at the end of
1217 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
1218 val builder_at_end : llbasicblock -> llbuilder
1220 (** [position_builder ip bb] moves the instruction builder [bb] to the position
1222 See the constructor for [llvm::LLVMBuilder]. *)
1223 external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
1224 = "llvm_position_builder"
1226 (** [position_before ins b] moves the instruction builder [b] to before the
1227 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1228 val position_before : llvalue -> llbuilder -> unit
1230 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
1231 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1232 val position_at_end : llbasicblock -> llbuilder -> unit
1234 (** [insertion_block b] returns the basic block that the builder [b] is
1235 positioned to insert into. Raises [Not_Found] if the instruction builder is
1237 See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
1238 external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
1241 (** {7 Terminators} *)
1243 (** [build_ret_void b] creates a
1245 instruction at the position specified by the instruction builder [b].
1246 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
1247 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
1249 (** [build_ret v b] creates a
1251 instruction at the position specified by the instruction builder [b].
1252 See the method [llvm::LLVMBuilder::CreateRet]. *)
1253 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
1255 (** [build_br bb b] creates a
1257 instruction at the position specified by the instruction builder [b].
1258 See the method [llvm::LLVMBuilder::CreateBr]. *)
1259 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
1261 (** [build_cond_br cond tbb fbb b] creates a
1262 [b %cond, %tbb, %fbb]
1263 instruction at the position specified by the instruction builder [b].
1264 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
1265 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
1266 llvalue = "llvm_build_cond_br"
1268 (** [build_switch case elsebb count b] creates an empty
1269 [switch %case, %elsebb]
1270 instruction at the position specified by the instruction builder [b] with
1271 space reserved for [count] cases.
1272 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
1273 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
1274 = "llvm_build_switch"
1276 (** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
1277 when its input matches the constant [onval].
1278 See the method [llvm::SwitchInst::addCase]. **)
1279 external add_case : llvalue -> llvalue -> llbasicblock -> unit
1282 (** [build_invoke fn args tobb unwindbb name b] creates an
1283 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
1284 instruction at the position specified by the instruction builder [b].
1285 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
1286 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
1287 llbasicblock -> string -> llbuilder -> llvalue
1288 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
1290 (** [build_unwind b] creates an
1292 instruction at the position specified by the instruction builder [b].
1293 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1294 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
1296 (** [build_unreachable b] creates an
1298 instruction at the position specified by the instruction builder [b].
1299 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
1300 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
1303 (** {7 Arithmetic} *)
1305 (** [build_add x y name b] creates a
1306 [%name = add %x, %y]
1307 instruction at the position specified by the instruction builder [b].
1308 See the method [llvm::LLVMBuilder::CreateAdd]. *)
1309 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
1312 (** [build_sub x y name b] creates a
1313 [%name = sub %x, %y]
1314 instruction at the position specified by the instruction builder [b].
1315 See the method [llvm::LLVMBuilder::CreateSub]. *)
1316 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
1319 (** [build_mul x y name b] creates a
1320 [%name = mul %x, %y]
1321 instruction at the position specified by the instruction builder [b].
1322 See the method [llvm::LLVMBuilder::CreateMul]. *)
1323 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
1326 (** [build_udiv x y name b] creates a
1327 [%name = udiv %x, %y]
1328 instruction at the position specified by the instruction builder [b].
1329 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
1330 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1333 (** [build_sdiv x y name b] creates a
1334 [%name = sdiv %x, %y]
1335 instruction at the position specified by the instruction builder [b].
1336 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
1337 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1340 (** [build_fdiv x y name b] creates a
1341 [%name = fdiv %x, %y]
1342 instruction at the position specified by the instruction builder [b].
1343 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
1344 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
1347 (** [build_urem x y name b] creates a
1348 [%name = urem %x, %y]
1349 instruction at the position specified by the instruction builder [b].
1350 See the method [llvm::LLVMBuilder::CreateURem]. *)
1351 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1354 (** [build_SRem x y name b] creates a
1355 [%name = srem %x, %y]
1356 instruction at the position specified by the instruction builder [b].
1357 See the method [llvm::LLVMBuilder::CreateSRem]. *)
1358 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1361 (** [build_frem x y name b] creates a
1362 [%name = frem %x, %y]
1363 instruction at the position specified by the instruction builder [b].
1364 See the method [llvm::LLVMBuilder::CreateFRem]. *)
1365 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1368 (** [build_shl x y name b] creates a
1369 [%name = shl %x, %y]
1370 instruction at the position specified by the instruction builder [b].
1371 See the method [llvm::LLVMBuilder::CreateShl]. *)
1372 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1375 (** [build_lshr x y name b] creates a
1376 [%name = lshr %x, %y]
1377 instruction at the position specified by the instruction builder [b].
1378 See the method [llvm::LLVMBuilder::CreateLShr]. *)
1379 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1382 (** [build_ashr x y name b] creates a
1383 [%name = ashr %x, %y]
1384 instruction at the position specified by the instruction builder [b].
1385 See the method [llvm::LLVMBuilder::CreateAShr]. *)
1386 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1389 (** [build_and x y name b] creates a
1390 [%name = and %x, %y]
1391 instruction at the position specified by the instruction builder [b].
1392 See the method [llvm::LLVMBuilder::CreateAnd]. *)
1393 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1396 (** [build_or x y name b] creates a
1398 instruction at the position specified by the instruction builder [b].
1399 See the method [llvm::LLVMBuilder::CreateOr]. *)
1400 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1403 (** [build_xor x y name b] creates a
1404 [%name = xor %x, %y]
1405 instruction at the position specified by the instruction builder [b].
1406 See the method [llvm::LLVMBuilder::CreateXor]. *)
1407 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1410 (** [build_neg x name b] creates a
1412 instruction at the position specified by the instruction builder [b].
1413 [-0.0] is used for floating point types to compute the correct sign.
1414 See the method [llvm::LLVMBuilder::CreateNeg]. *)
1415 external build_neg : llvalue -> string -> llbuilder -> llvalue
1418 (** [build_xor x name b] creates a
1419 [%name = xor %x, -1]
1420 instruction at the position specified by the instruction builder [b].
1421 [-1] is the correct "all ones" value for the type of [x].
1422 See the method [llvm::LLVMBuilder::CreateXor]. *)
1423 external build_not : llvalue -> string -> llbuilder -> llvalue
1429 (** [build_malloc ty name b] creates a
1430 [%name = malloc %ty]
1431 instruction at the position specified by the instruction builder [b].
1432 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1433 external build_malloc : lltype -> string -> llbuilder -> llvalue
1434 = "llvm_build_malloc"
1436 (** [build_array_malloc ty n name b] creates a
1437 [%name = malloc %ty, %n]
1438 instruction at the position specified by the instruction builder [b].
1439 See the method [llvm::LLVMBuilder::CreateMalloc]. *)
1440 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1441 llvalue = "llvm_build_array_malloc"
1443 (** [build_alloca ty name b] creates a
1444 [%name = alloca %ty]
1445 instruction at the position specified by the instruction builder [b].
1446 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1447 external build_alloca : lltype -> string -> llbuilder -> llvalue
1448 = "llvm_build_alloca"
1450 (** [build_array_alloca ty n name b] creates a
1451 [%name = alloca %ty, %n]
1452 instruction at the position specified by the instruction builder [b].
1453 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
1454 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1455 llvalue = "llvm_build_array_alloca"
1457 (** [build_free v b] creates a
1459 instruction at the position specified by the instruction builder [b].
1460 See the method [llvm::LLVMBuilder::CreateFree]. *)
1461 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1463 (** [build_load v name b] creates a
1465 instruction at the position specified by the instruction builder [b].
1466 See the method [llvm::LLVMBuilder::CreateLoad]. *)
1467 external build_load : llvalue -> string -> llbuilder -> llvalue
1470 (** [build_store v p b] creates a
1472 instruction at the position specified by the instruction builder [b].
1473 See the method [llvm::LLVMBuilder::CreateStore]. *)
1474 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1475 = "llvm_build_store"
1477 (** [build_gep p indices name b] creates a
1478 [%name = gep %p, indices...]
1479 instruction at the position specified by the instruction builder [b].
1480 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
1481 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1487 (** [build_trunc v ty name b] creates a
1488 [%name = trunc %p to %ty]
1489 instruction at the position specified by the instruction builder [b].
1490 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
1491 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1492 = "llvm_build_trunc"
1494 (** [build_zext v ty name b] creates a
1495 [%name = zext %p to %ty]
1496 instruction at the position specified by the instruction builder [b].
1497 See the method [llvm::LLVMBuilder::CreateZExt]. *)
1498 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1501 (** [build_sext v ty name b] creates a
1502 [%name = sext %p to %ty]
1503 instruction at the position specified by the instruction builder [b].
1504 See the method [llvm::LLVMBuilder::CreateSExt]. *)
1505 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1508 (** [build_fptoui v ty name b] creates a
1509 [%name = fptoui %p to %ty]
1510 instruction at the position specified by the instruction builder [b].
1511 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
1512 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1513 = "llvm_build_fptoui"
1515 (** [build_fptosi v ty name b] creates a
1516 [%name = fptosi %p to %ty]
1517 instruction at the position specified by the instruction builder [b].
1518 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
1519 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1520 = "llvm_build_fptosi"
1522 (** [build_uitofp v ty name b] creates a
1523 [%name = uitofp %p to %ty]
1524 instruction at the position specified by the instruction builder [b].
1525 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
1526 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1527 = "llvm_build_uitofp"
1529 (** [build_sitofp v ty name b] creates a
1530 [%name = sitofp %p to %ty]
1531 instruction at the position specified by the instruction builder [b].
1532 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
1533 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1534 = "llvm_build_sitofp"
1536 (** [build_fptrunc v ty name b] creates a
1537 [%name = fptrunc %p to %ty]
1538 instruction at the position specified by the instruction builder [b].
1539 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
1540 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1541 = "llvm_build_fptrunc"
1543 (** [build_fpext v ty name b] creates a
1544 [%name = fpext %p to %ty]
1545 instruction at the position specified by the instruction builder [b].
1546 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
1547 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1548 = "llvm_build_fpext"
1550 (** [build_ptrtoint v ty name b] creates a
1551 [%name = prtotint %p to %ty]
1552 instruction at the position specified by the instruction builder [b].
1553 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
1554 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1555 = "llvm_build_prttoint"
1557 (** [build_inttoptr v ty name b] creates a
1558 [%name = inttoptr %p to %ty]
1559 instruction at the position specified by the instruction builder [b].
1560 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
1561 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1562 = "llvm_build_inttoptr"
1564 (** [build_bitcast v ty name b] creates a
1565 [%name = bitcast %p to %ty]
1566 instruction at the position specified by the instruction builder [b].
1567 See the method [llvm::LLVMBuilder::CreateBitcast]. *)
1568 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1569 = "llvm_build_bitcast"
1572 (** {7 Comparisons} *)
1574 (** [build_icmp pred x y name b] creates a
1575 [%name = icmp %pred %x, %y]
1576 instruction at the position specified by the instruction builder [b].
1577 See the method [llvm::LLVMBuilder::CreateICmp]. *)
1578 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
1579 llbuilder -> llvalue = "llvm_build_icmp"
1581 (** [build_fcmp pred x y name b] creates a
1582 [%name = fcmp %pred %x, %y]
1583 instruction at the position specified by the instruction builder [b].
1584 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
1585 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
1586 llbuilder -> llvalue = "llvm_build_fcmp"
1589 (** {7 Miscellaneous instructions} *)
1591 (** [build_phi incoming name b] creates a
1592 [%name = phi %incoming]
1593 instruction at the position specified by the instruction builder [b].
1594 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1595 See the method [llvm::LLVMBuilder::CreatePHI]. *)
1596 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1597 llvalue = "llvm_build_phi"
1599 (** [build_call fn args name b] creates a
1600 [%name = call %fn(args...)]
1601 instruction at the position specified by the instruction builder [b].
1602 See the method [llvm::LLVMBuilder::CreateCall]. *)
1603 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1606 (** [build_select cond thenv elsev name b] creates a
1607 [%name = select %cond, %thenv, %elsev]
1608 instruction at the position specified by the instruction builder [b].
1609 See the method [llvm::LLVMBuilder::CreateSelect]. *)
1610 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1611 llvalue = "llvm_build_select"
1613 (** [build_va_arg valist argty name b] creates a
1614 [%name = va_arg %valist, %argty]
1615 instruction at the position specified by the instruction builder [b].
1616 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
1617 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1618 = "llvm_build_va_arg"
1620 (** [build_extractelement vec i name b] creates a
1621 [%name = extractelement %vec, %i]
1622 instruction at the position specified by the instruction builder [b].
1623 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
1624 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1625 llvalue = "llvm_build_extractelement"
1627 (** [build_insertelement vec elt i name b] creates a
1628 [%name = insertelement %vec, %elt, %i]
1629 instruction at the position specified by the instruction builder [b].
1630 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
1631 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1632 llbuilder -> llvalue = "llvm_build_insertelement"
1634 (** [build_shufflevector veca vecb mask name b] creates a
1635 [%name = shufflevector %veca, %vecb, %mask]
1636 instruction at the position specified by the instruction builder [b].
1637 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
1638 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1639 llbuilder -> llvalue = "llvm_build_shufflevector"
1642 (** {6 Module providers} *)
1644 module ModuleProvider : sig
1645 (** [create_module_provider m] encapsulates [m] in a module provider and takes
1646 ownership of the module. See the constructor
1647 [llvm::ExistingModuleProvider::ExistingModuleProvider]. *)
1648 external create : llmodule -> llmoduleprovider
1649 = "LLVMCreateModuleProviderForExistingModule"
1651 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
1652 the contained module. *)
1653 external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider"
1657 (** {6 Memory buffers} *)
1659 module MemoryBuffer : sig
1660 (** [of_file p] is the memory buffer containing the contents of the file at
1661 path [p]. If the file could not be read, then [IoError msg] is
1663 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
1665 (** [stdin ()] is the memory buffer containing the contents of standard input.
1666 If standard input is empty, then [IoError msg] is raised. *)
1667 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
1669 (** Disposes of a memory buffer. *)
1670 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
1674 (** {6 Pass Managers} *)
1676 module PassManager : sig
1679 type any = [ `Module | `Function ]
1681 (** [PassManager.create ()] constructs a new whole-module pass pipeline. This
1682 type of pipeline is suitable for link-time optimization and whole-module
1684 See the constructor of [llvm::PassManager]. *)
1685 external create : unit -> [ `Module ] t = "llvm_passmanager_create"
1687 (** [PassManager.create_function mp] constructs a new function-by-function
1688 pass pipeline over the module provider [mp]. It does not take ownership of
1689 [mp]. This type of pipeline is suitable for code generation and JIT
1691 See the constructor of [llvm::FunctionPassManager]. *)
1692 external create_function : llmoduleprovider -> [ `Function ] t
1693 = "LLVMCreateFunctionPassManager"
1695 (** [run_module m pm] initializes, executes on the module [m], and finalizes
1696 all of the passes scheduled in the pass manager [pm]. Returns [true] if
1697 any of the passes modified the module, [false] otherwise.
1698 See the [llvm::PassManager::run] method. *)
1699 external run_module : llmodule -> [ `Module ] t -> bool
1700 = "llvm_passmanager_run_module"
1702 (** [initialize fpm] initializes all of the function passes scheduled in the
1703 function pass manager [fpm]. Returns [true] if any of the passes modified
1704 the module, [false] otherwise.
1705 See the [llvm::FunctionPassManager::doInitialization] method. *)
1706 external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize"
1708 (** [run_function f fpm] executes all of the function passes scheduled in the
1709 function pass manager [fpm] over the function [f]. Returns [true] if any
1710 of the passes modified [f], [false] otherwise.
1711 See the [llvm::FunctionPassManager::run] method. *)
1712 external run_function : llvalue -> [ `Function ] t -> bool
1713 = "llvm_passmanager_run_function"
1715 (** [finalize fpm] finalizes all of the function passes scheduled in in the
1716 function pass manager [fpm]. Returns [true] if any of the passes
1717 modified the module, [false] otherwise.
1718 See the [llvm::FunctionPassManager::doFinalization] method. *)
1719 external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize"
1721 (** Frees the memory of a pass pipeline. For function pipelines, does not free
1722 the module provider.
1723 See the destructor of [llvm::BasePassManager]. *)
1724 external dispose : [< any ] t -> unit = "llvm_passmanager_dispose"