1 (*===-- llvm/llvm.mli - LLVM OCaml Interface ------------------------------===*
3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 * See https://llvm.org/LICENSE.txt for license information.
5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 *===----------------------------------------------------------------------===*)
11 This interface provides an OCaml API for the LLVM intermediate
12 representation, the classes in the VMCore library. *)
15 (** {6 Abstract types}
17 These abstract types correlate directly to the LLVMCore classes. *)
19 (** The top-level container for all LLVM global data. See the
20 [llvm::LLVMContext] class. *)
23 (** The top-level container for all other LLVM Intermediate Representation (IR)
24 objects. See the [llvm::Module] class. *)
27 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
28 [llvm::Type] class. *)
31 (** Any value in the LLVM IR. Functions, instructions, global variables,
32 constants, and much more are all [llvalues]. See the [llvm::Value] class.
33 This type covers a wide range of subclasses. *)
36 (** Used to store users and usees of values. See the [llvm::Use] class. *)
39 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
42 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
46 (** Used to represent attribute kinds. *)
49 (** An attribute in LLVM IR. See the [llvm::Attribute] class. *)
52 (** Used to efficiently handle large buffers of read-only binary data.
53 See the [llvm::MemoryBuffer] class. *)
56 (** The kind id of metadata attached to an instruction. *)
59 (** The kind of an [lltype], the result of [classify_type ty]. See the
60 [llvm::Type::TypeID] enumeration. *)
82 (** The linkage of a global value, accessed with {!linkage} and
83 {!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
87 | Available_externally
90 | Link_once_odr_auto_hide
102 | Linker_private_weak
105 (** The linker visibility of a global value, accessed with {!visibility} and
106 {!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
107 module Visibility
: sig
114 (** The DLL storage class of a global value, accessed with {!dll_storage_class} and
115 {!set_dll_storage_class}. See [llvm::GlobalValue::DLLStorageClassTypes]. *)
116 module DLLStorageClass
: sig
123 (** The following calling convention values may be accessed with
124 {!function_call_conv} and {!set_function_call_conv}. Calling
125 conventions are open-ended. *)
126 module CallConv
: sig
127 val c
: int (** [c] is the C calling convention. *)
128 val fast
: int (** [fast] is the calling convention to allow LLVM
129 maximum optimization opportunities. Use only with
131 val cold
: int (** [cold] is the calling convention for
133 val x86_stdcall
: int (** [x86_stdcall] is the familiar stdcall calling
134 convention from C. *)
135 val x86_fastcall
: int (** [x86_fastcall] is the familiar fastcall calling
136 convention from C. *)
139 (** The logical representation of an attribute. *)
140 module AttrRepr
: sig
142 | Enum
of llattrkind
* int64
143 | String
of string * string
146 (** The position of an attribute. See [LLVMAttributeIndex]. *)
147 module AttrIndex
: sig
154 (** The predicate for an integer comparison ([icmp]) instruction.
155 See the [llvm::ICmpInst::Predicate] enumeration. *)
159 | Ne
(** Not equal *)
160 | Ugt
(** Unsigned greater than *)
161 | Uge
(** Unsigned greater or equal *)
162 | Ult
(** Unsigned less than *)
163 | Ule
(** Unsigned less or equal *)
164 | Sgt
(** Signed greater than *)
165 | Sge
(** Signed greater or equal *)
166 | Slt
(** Signed less than *)
167 | Sle
(** Signed less or equal *)
170 (** The predicate for a floating-point comparison ([fcmp]) instruction.
171 Ordered means that neither operand is a QNAN while unordered means
172 that either operand may be a QNAN.
173 See the [llvm::FCmpInst::Predicate] enumeration. *)
176 | False
(** Always false *)
177 | Oeq
(** Ordered and equal *)
178 | Ogt
(** Ordered and greater than *)
179 | Oge
(** Ordered and greater or equal *)
180 | Olt
(** Ordered and less than *)
181 | Ole
(** Ordered and less or equal *)
182 | One
(** Ordered and not equal *)
183 | Ord
(** Ordered (no operand is NaN) *)
184 | Uno
(** Unordered (one operand at least is NaN) *)
185 | Ueq
(** Unordered and equal *)
186 | Ugt
(** Unordered and greater than *)
187 | Uge
(** Unordered and greater or equal *)
188 | Ult
(** Unordered and less than *)
189 | Ule
(** Unordered and less or equal *)
190 | Une
(** Unordered and not equal *)
191 | True
(** Always true *)
194 (** The opcodes for LLVM instructions and constant expressions. *)
197 | Invalid
(** Not an instruction *)
199 | Ret
(** Terminator Instructions *)
207 | Add
(** Standard Binary Operators *)
220 | Shl
(** Logical Operators *)
227 | Alloca
(** Memory Operators *)
232 | Trunc
(** Cast Operators *)
245 | ICmp
(** Other Operators *)
271 (** The type of a clause of a [landingpad] instruction.
272 See [llvm::LandingPadInst::ClauseType]. *)
273 module LandingPadClauseTy
: sig
279 (** The thread local mode of a global value, accessed with {!thread_local_mode}
280 and {!set_thread_local_mode}.
281 See [llvm::GlobalVariable::ThreadLocalMode]. *)
282 module ThreadLocalMode
: sig
291 (** The ordering of an atomic [load], [store], [cmpxchg], [atomicrmw] or
292 [fence] instruction. See [llvm::AtomicOrdering]. *)
293 module AtomicOrdering
: sig
298 | Invalid
(** removed due to API changes *)
302 | SequentiallyConsistent
305 (** The opcode of an [atomicrmw] instruction.
306 See [llvm::AtomicRMWInst::BinOp]. *)
307 module AtomicRMWBinOp
: sig
322 (** The kind of an [llvalue], the result of [classify_value v].
323 See the various [LLVMIsA*] functions. *)
324 module ValueKind
: sig
333 | ConstantAggregateZero
340 | ConstantPointerNull
348 | Instruction
of Opcode.t
351 (** The kind of [Diagnostic], the result of [Diagnostic.severity d].
352 See [llvm::DiagnosticSeverity]. *)
353 module DiagnosticSeverity
: sig
364 (** [Before b] and [At_end a] specify positions from the start of the ['b] list
365 of [a]. [llpos] is used to specify positions in and for forward iteration
366 through the various value lists maintained by the LLVM IR. *)
367 type ('a
, 'b
) llpos
=
371 (** [After b] and [At_start a] specify positions from the end of the ['b] list
372 of [a]. [llrev_pos] is used for reverse iteration through the various value
373 lists maintained by the LLVM IR. *)
374 type ('a
, 'b
) llrev_pos
=
379 (** {6 Exceptions} *)
381 exception FeatureDisabled
of string
383 exception IoError
of string
386 (** {6 Global configuration} *)
388 (** [enable_pretty_stacktraces ()] enables LLVM's built-in stack trace code.
389 This intercepts the OS's crash signals and prints which component of LLVM
390 you were in at the time of the crash. *)
391 val enable_pretty_stacktrace
: unit -> unit
393 (** [install_fatal_error_handler f] installs [f] as LLVM's fatal error handler.
394 The handler will receive the reason for termination as a string. After
395 the handler has been executed, LLVM calls [exit(1)]. *)
396 val install_fatal_error_handler
: (string -> unit) -> unit
398 (** [reset_fatal_error_handler ()] resets LLVM's fatal error handler. *)
399 val reset_fatal_error_handler
: unit -> unit
401 (** [parse_command_line_options ?overview args] parses [args] using
402 the LLVM command line parser. Note that the only stable thing about this
403 function is its signature; you cannot rely on any particular set of command
404 line arguments being interpreted the same way across LLVM versions.
406 See the function [llvm::cl::ParseCommandLineOptions()]. *)
407 val parse_command_line_options
: ?overview
:string -> string array
-> unit
409 (** {6 Context error handling} *)
411 module Diagnostic
: sig
414 (** [description d] returns a textual description of [d]. *)
415 val description
: t
-> string
417 (** [severity d] returns the severity of [d]. *)
418 val severity
: t
-> DiagnosticSeverity.t
421 (** [set_diagnostic_handler c h] set the diagnostic handler of [c] to [h].
422 See the method [llvm::LLVMContext::setDiagnosticHandler]. *)
423 val set_diagnostic_handler
: llcontext
-> (Diagnostic.t
-> unit) option -> unit
427 (** [create_context ()] creates a context for storing the "global" state in
428 LLVM. See the constructor [llvm::LLVMContext]. *)
429 val create_context
: unit -> llcontext
431 (** [destroy_context ()] destroys a context. See the destructor
432 [llvm::LLVMContext::~LLVMContext]. *)
433 val dispose_context
: llcontext
-> unit
435 (** See the function [LLVMGetGlobalContext]. *)
436 val global_context
: unit -> llcontext
438 (** [mdkind_id context name] returns the MDKind ID that corresponds to the
439 name [name] in the context [context]. See the function
440 [llvm::LLVMContext::getMDKindID]. *)
441 val mdkind_id
: llcontext
-> string -> llmdkind
444 (** {6 Attributes} *)
446 (** [UnknownAttribute attr] is raised when a enum attribute name [name]
447 is not recognized by LLVM. *)
448 exception UnknownAttribute
of string
450 (** [enum_attr_kind name] returns the kind of enum attributes named [name].
451 May raise [UnknownAttribute]. *)
452 val enum_attr_kind
: string -> llattrkind
454 (** [create_enum_attr context value kind] creates an enum attribute
455 with the supplied [kind] and [value] in [context]; if the value
456 is not required (as for the majority of attributes), use [0L].
457 May raise [UnknownAttribute].
458 See the constructor [llvm::Attribute::get]. *)
459 val create_enum_attr
: llcontext
-> string -> int64
-> llattribute
461 (** [create_string_attr context kind value] creates a string attribute
462 with the supplied [kind] and [value] in [context].
463 See the constructor [llvm::Attribute::get]. *)
464 val create_string_attr
: llcontext
-> string -> string -> llattribute
466 (** [attr_of_repr context repr] creates an attribute with the supplied
467 representation [repr] in [context]. *)
468 val attr_of_repr
: llcontext
-> AttrRepr.t
-> llattribute
470 (** [repr_of_attr attr] describes the representation of attribute [attr]. *)
471 val repr_of_attr
: llattribute
-> AttrRepr.t
476 (** [create_module context id] creates a module with the supplied module ID in
477 the context [context]. Modules are not garbage collected; it is mandatory
478 to call {!dispose_module} to free memory. See the constructor
479 [llvm::Module::Module]. *)
480 val create_module
: llcontext
-> string -> llmodule
482 (** [dispose_module m] destroys a module [m] and all of the IR objects it
483 contained. All references to subordinate objects are invalidated;
484 referencing them will invoke undefined behavior. See the destructor
485 [llvm::Module::~Module]. *)
486 val dispose_module
: llmodule
-> unit
488 (** [target_triple m] is the target specifier for the module [m], something like
489 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
490 val target_triple
: llmodule
-> string
492 (** [target_triple triple m] changes the target specifier for the module [m] to
493 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
494 val set_target_triple
: string -> llmodule
-> unit
496 (** [data_layout m] is the data layout specifier for the module [m], something
497 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
498 method [llvm::Module::getDataLayout]. *)
499 val data_layout
: llmodule
-> string
501 (** [set_data_layout s m] changes the data layout specifier for the module [m]
502 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
503 val set_data_layout
: string -> llmodule
-> unit
505 (** [dump_module m] prints the .ll representation of the module [m] to standard
506 error. See the method [llvm::Module::dump]. *)
507 val dump_module
: llmodule
-> unit
509 (** [print_module f m] prints the .ll representation of the module [m]
510 to file [f]. See the method [llvm::Module::print]. *)
511 val print_module
: string -> llmodule
-> unit
513 (** [string_of_llmodule m] returns the .ll representation of the module [m]
514 as a string. See the method [llvm::Module::print]. *)
515 val string_of_llmodule
: llmodule
-> string
517 (** [set_module_inline_asm m asm] sets the inline assembler for the module. See
518 the method [llvm::Module::setModuleInlineAsm]. *)
519 val set_module_inline_asm
: llmodule
-> string -> unit
521 (** [module_context m] returns the context of the specified module.
522 See the method [llvm::Module::getContext] *)
523 val module_context
: llmodule
-> llcontext
528 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
529 See the method [llvm::Type::getTypeID]. *)
530 val classify_type
: lltype
-> TypeKind.t
532 (** [type_is_sized ty] returns whether the type has a size or not.
533 If it doesn't then it is not safe to call the [DataLayout::] methods on it.
535 val type_is_sized
: lltype
-> bool
537 (** [type_context ty] returns the {!llcontext} corresponding to the type [ty].
538 See the method [llvm::Type::getContext]. *)
539 val type_context
: lltype
-> llcontext
541 (** [dump_type ty] prints the .ll representation of the type [ty] to standard
542 error. See the method [llvm::Type::dump]. *)
543 val dump_type
: lltype
-> unit
545 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
546 val string_of_lltype
: lltype
-> string
549 (** {7 Operations on integer types} *)
551 (** [i1_type c] returns an integer type of bitwidth 1 in the context [c]. See
552 [llvm::Type::Int1Ty]. *)
553 val i1_type
: llcontext
-> lltype
555 (** [i8_type c] returns an integer type of bitwidth 8 in the context [c]. See
556 [llvm::Type::Int8Ty]. *)
557 val i8_type
: llcontext
-> lltype
559 (** [i16_type c] returns an integer type of bitwidth 16 in the context [c]. See
560 [llvm::Type::Int16Ty]. *)
561 val i16_type
: llcontext
-> lltype
563 (** [i32_type c] returns an integer type of bitwidth 32 in the context [c]. See
564 [llvm::Type::Int32Ty]. *)
565 val i32_type
: llcontext
-> lltype
567 (** [i64_type c] returns an integer type of bitwidth 64 in the context [c]. See
568 [llvm::Type::Int64Ty]. *)
569 val i64_type
: llcontext
-> lltype
571 (** [integer_type c n] returns an integer type of bitwidth [n] in the context
572 [c]. See the method [llvm::IntegerType::get]. *)
573 val integer_type
: llcontext
-> int -> lltype
575 (** [integer_bitwidth c ty] returns the number of bits in the integer type [ty]
576 in the context [c]. See the method [llvm::IntegerType::getBitWidth]. *)
577 val integer_bitwidth
: lltype
-> int
580 (** {7 Operations on real types} *)
582 (** [float_type c] returns the IEEE 32-bit floating point type in the context
583 [c]. See [llvm::Type::FloatTy]. *)
584 val float_type
: llcontext
-> lltype
586 (** [double_type c] returns the IEEE 64-bit floating point type in the context
587 [c]. See [llvm::Type::DoubleTy]. *)
588 val double_type
: llcontext
-> lltype
590 (** [x86fp80_type c] returns the x87 80-bit floating point type in the context
591 [c]. See [llvm::Type::X86_FP80Ty]. *)
592 val x86fp80_type
: llcontext
-> lltype
594 (** [fp128_type c] returns the IEEE 128-bit floating point type in the context
595 [c]. See [llvm::Type::FP128Ty]. *)
596 val fp128_type
: llcontext
-> lltype
598 (** [ppc_fp128_type c] returns the PowerPC 128-bit floating point type in the
599 context [c]. See [llvm::Type::PPC_FP128Ty]. *)
600 val ppc_fp128_type
: llcontext
-> lltype
603 (** {7 Operations on function types} *)
605 (** [function_type ret_ty param_tys] returns the function type returning
606 [ret_ty] and taking [param_tys] as parameters.
607 See the method [llvm::FunctionType::get]. *)
608 val function_type
: lltype
-> lltype array
-> lltype
610 (** [var_arg_function_type ret_ty param_tys] is just like
611 [function_type ret_ty param_tys] except that it returns the function type
612 which also takes a variable number of arguments.
613 See the method [llvm::FunctionType::get]. *)
614 val var_arg_function_type
: lltype
-> lltype array
-> lltype
616 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
617 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
618 val is_var_arg
: lltype
-> bool
620 (** [return_type fty] gets the return type of the function type [fty].
621 See the method [llvm::FunctionType::getReturnType]. *)
622 val return_type
: lltype
-> lltype
624 (** [param_types fty] gets the parameter types of the function type [fty].
625 See the method [llvm::FunctionType::getParamType]. *)
626 val param_types
: lltype
-> lltype array
629 (** {7 Operations on struct types} *)
631 (** [struct_type context tys] returns the structure type in the context
632 [context] containing in the types in the array [tys]. See the method
633 [llvm::StructType::get]. *)
634 val struct_type
: llcontext
-> lltype array
-> lltype
636 (** [packed_struct_type context ys] returns the packed structure type in the
637 context [context] containing in the types in the array [tys]. See the method
638 [llvm::StructType::get]. *)
639 val packed_struct_type
: llcontext
-> lltype array
-> lltype
641 (** [struct_name ty] returns the name of the named structure type [ty],
642 or None if the structure type is not named *)
643 val struct_name
: lltype
-> string option
645 (** [named_struct_type context name] returns the named structure type [name]
646 in the context [context].
647 See the method [llvm::StructType::get]. *)
648 val named_struct_type
: llcontext
-> string -> lltype
650 (** [struct_set_body ty elts ispacked] sets the body of the named struct [ty]
651 to the [elts] elements.
652 See the moethd [llvm::StructType::setBody]. *)
653 val struct_set_body
: lltype
-> lltype array
-> bool -> unit
655 (** [struct_element_types sty] returns the constituent types of the struct type
656 [sty]. See the method [llvm::StructType::getElementType]. *)
657 val struct_element_types
: lltype
-> lltype array
659 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
660 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
661 val is_packed
: lltype
-> bool
663 (** [is_opaque sty] returns [true] if the structure type [sty] is opaque.
664 [false] otherwise. See the method [llvm::StructType::isOpaque]. *)
665 val is_opaque
: lltype
-> bool
667 (** [is_literal sty] returns [true] if the structure type [sty] is literal.
668 [false] otherwise. See the method [llvm::StructType::isLiteral]. *)
669 val is_literal
: lltype
-> bool
672 (** {7 Operations on pointer, vector, and array types} *)
674 (** [subtypes ty] returns [ty]'s subtypes *)
675 val subtypes
: lltype
-> lltype array
677 (** [array_type ty n] returns the array type containing [n] elements of type
678 [ty]. See the method [llvm::ArrayType::get]. *)
679 val array_type
: lltype
-> int -> lltype
681 (** [pointer_type ty] returns the pointer type referencing objects of type
682 [ty] in the default address space (0).
683 See the method [llvm::PointerType::getUnqual]. *)
684 val pointer_type
: lltype
-> lltype
686 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
687 of type [ty] in address space [as].
688 See the method [llvm::PointerType::get]. *)
689 val qualified_pointer_type
: lltype
-> int -> lltype
691 (** [vector_type ty n] returns the array type containing [n] elements of the
692 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
693 val vector_type
: lltype
-> int -> lltype
695 (** [element_type ty] returns the element type of the pointer, vector, or array
696 type [ty]. See the method [llvm::SequentialType::get]. *)
697 val element_type
: lltype
-> lltype
699 (** [element_type aty] returns the element count of the array type [aty].
700 See the method [llvm::ArrayType::getNumElements]. *)
701 val array_length
: lltype
-> int
703 (** [address_space pty] returns the address space qualifier of the pointer type
704 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
705 val address_space
: lltype
-> int
707 (** [element_type ty] returns the element count of the vector type [ty].
708 See the method [llvm::VectorType::getNumElements]. *)
709 val vector_size
: lltype
-> int
712 (** {7 Operations on other types} *)
714 (** [void_type c] creates a type of a function which does not return any
715 value in the context [c]. See [llvm::Type::VoidTy]. *)
716 val void_type
: llcontext
-> lltype
718 (** [label_type c] creates a type of a basic block in the context [c]. See
719 [llvm::Type::LabelTy]. *)
720 val label_type
: llcontext
-> lltype
722 (** [x86_mmx_type c] returns the x86 64-bit MMX register type in the
723 context [c]. See [llvm::Type::X86_MMXTy]. *)
724 val x86_mmx_type
: llcontext
-> lltype
726 (** [type_by_name m name] returns the specified type from the current module
728 See the method [llvm::Module::getTypeByName] *)
729 val type_by_name
: llmodule
-> string -> lltype
option
734 (** [type_of v] returns the type of the value [v].
735 See the method [llvm::Value::getType]. *)
736 val type_of
: llvalue
-> lltype
738 (** [classify_value v] returns the kind of the value [v]. *)
739 val classify_value
: llvalue
-> ValueKind.t
741 (** [value_name v] returns the name of the value [v]. For global values, this is
742 the symbol name. For instructions and basic blocks, it is the SSA register
743 name. It is meaningless for constants.
744 See the method [llvm::Value::getName]. *)
745 val value_name
: llvalue
-> string
747 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
748 [llvm::Value::setName]. *)
749 val set_value_name
: string -> llvalue
-> unit
751 (** [dump_value v] prints the .ll representation of the value [v] to standard
752 error. See the method [llvm::Value::dump]. *)
753 val dump_value
: llvalue
-> unit
755 (** [string_of_llvalue v] returns a string describing the value [v]. *)
756 val string_of_llvalue
: llvalue
-> string
758 (** [replace_all_uses_with old new] replaces all uses of the value [old]
759 with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
760 val replace_all_uses_with
: llvalue
-> llvalue
-> unit
765 (** [use_begin v] returns the first position in the use list for the value [v].
766 [use_begin] and [use_succ] can e used to iterate over the use list in order.
767 See the method [llvm::Value::use_begin]. *)
768 val use_begin
: llvalue
-> lluse
option
770 (** [use_succ u] returns the use list position succeeding [u].
771 See the method [llvm::use_value_iterator::operator++]. *)
772 val use_succ
: lluse
-> lluse
option
774 (** [user u] returns the user of the use [u].
775 See the method [llvm::Use::getUser]. *)
776 val user
: lluse
-> llvalue
778 (** [used_value u] returns the usee of the use [u].
779 See the method [llvm::Use::getUsedValue]. *)
780 val used_value
: lluse
-> llvalue
782 (** [iter_uses f v] applies function [f] to each of the users of the value [v]
783 in order. Tail recursive. *)
784 val iter_uses
: (lluse
-> unit) -> llvalue
-> unit
786 (** [fold_left_uses f init v] is [f (... (f init u1) ...) uN] where
787 [u1,...,uN] are the users of the value [v]. Tail recursive. *)
788 val fold_left_uses
: ('a
-> lluse
-> 'a
) -> 'a
-> llvalue
-> 'a
790 (** [fold_right_uses f v init] is [f u1 (... (f uN init) ...)] where
791 [u1,...,uN] are the users of the value [v]. Not tail recursive. *)
792 val fold_right_uses
: (lluse
-> 'a
-> 'a
) -> llvalue
-> 'a
-> 'a
797 (** [operand v i] returns the operand at index [i] for the value [v]. See the
798 method [llvm::User::getOperand]. *)
799 val operand
: llvalue
-> int -> llvalue
801 (** [operand_use v i] returns the use of the operand at index [i] for the value [v]. See the
802 method [llvm::User::getOperandUse]. *)
803 val operand_use
: llvalue
-> int -> lluse
806 (** [set_operand v i o] sets the operand of the value [v] at the index [i] to
808 See the method [llvm::User::setOperand]. *)
809 val set_operand
: llvalue
-> int -> llvalue
-> unit
811 (** [num_operands v] returns the number of operands for the value [v].
812 See the method [llvm::User::getNumOperands]. *)
813 val num_operands
: llvalue
-> int
816 (** [indices i] returns the indices for the ExtractValue or InsertValue
818 See the [llvm::getIndices] methods. *)
819 val indices
: llvalue
-> int array
821 (** {7 Operations on constants of (mostly) any type} *)
823 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
824 otherwise. Similar to [llvm::isa<Constant>]. *)
825 val is_constant
: llvalue
-> bool
827 (** [const_null ty] returns the constant null (zero) of the type [ty].
828 See the method [llvm::Constant::getNullValue]. *)
829 val const_null
: lltype
-> llvalue
831 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
832 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
833 val const_all_ones
: (*int|vec*)lltype
-> llvalue
835 (** [const_pointer_null ty] returns the constant null (zero) pointer of the type
836 [ty]. See the method [llvm::ConstantPointerNull::get]. *)
837 val const_pointer_null
: lltype
-> llvalue
839 (** [undef ty] returns the undefined value of the type [ty].
840 See the method [llvm::UndefValue::get]. *)
841 val undef
: lltype
-> llvalue
843 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
844 See the method [llvm::Constant::isNullValue]. *)
845 val is_null
: llvalue
-> bool
847 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
848 otherwise. Similar to [llvm::isa<UndefValue>]. *)
849 val is_undef
: llvalue
-> bool
851 (** [constexpr_opcode v] returns an [Opcode.t] corresponding to constexpr
852 value [v], or [Opcode.Invalid] if [v] is not a constexpr. *)
853 val constexpr_opcode
: llvalue
-> Opcode.t
856 (** {7 Operations on instructions} *)
858 (** [has_metadata i] returns whether or not the instruction [i] has any
859 metadata attached to it. See the function
860 [llvm::Instruction::hasMetadata]. *)
861 val has_metadata
: llvalue
-> bool
863 (** [metadata i kind] optionally returns the metadata associated with the
864 kind [kind] in the instruction [i] See the function
865 [llvm::Instruction::getMetadata]. *)
866 val metadata
: llvalue
-> llmdkind
-> llvalue
option
868 (** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
869 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
870 val set_metadata
: llvalue
-> llmdkind
-> llvalue
-> unit
872 (** [clear_metadata i kind] clears the metadata of kind [kind] in the
873 instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
874 val clear_metadata
: llvalue
-> llmdkind
-> unit
877 (** {7 Operations on metadata} *)
879 (** [mdstring c s] returns the MDString of the string [s] in the context [c].
880 See the method [llvm::MDNode::get]. *)
881 val mdstring
: llcontext
-> string -> llvalue
883 (** [mdnode c elts] returns the MDNode containing the values [elts] in the
885 See the method [llvm::MDNode::get]. *)
886 val mdnode
: llcontext
-> llvalue array
-> llvalue
888 (** [mdnull c ] returns a null MDNode in context [c]. *)
889 val mdnull
: llcontext
-> llvalue
891 (** [get_mdstring v] returns the MDString.
892 See the method [llvm::MDString::getString] *)
893 val get_mdstring
: llvalue
-> string option
895 (** [get_mdnode_operands v] returns the operands in the MDNode. *)
896 (* See the method [llvm::MDNode::getOperand] *)
897 val get_mdnode_operands
: llvalue
-> llvalue array
899 (** [get_named_metadata m name] returns all the MDNodes belonging to the named
901 See the method [llvm::NamedMDNode::getOperand]. *)
902 val get_named_metadata
: llmodule
-> string -> llvalue array
904 (** [add_named_metadata_operand m name v] adds [v] as the last operand of
905 metadata named [name] in module [m]. If the metadata does not exist,
907 See the methods [llvm::Module::getNamedMetadata()] and
908 [llvm::MDNode::addOperand()]. *)
909 val add_named_metadata_operand
: llmodule
-> string -> llvalue
-> unit
912 (** {7 Operations on scalar constants} *)
914 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
915 See the method [llvm::ConstantInt::get]. *)
916 val const_int
: lltype
-> int -> llvalue
918 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
919 [i]. See the method [llvm::ConstantInt::get]. *)
920 val const_of_int64
: lltype
-> Int64.t
-> bool -> llvalue
922 (** [int64_of_const c] returns the int64 value of the [c] constant integer.
923 None is returned if this is not an integer constant, or bitwidth exceeds 64.
924 See the method [llvm::ConstantInt::getSExtValue].*)
925 val int64_of_const
: llvalue
-> Int64.t
option
927 (** [const_int_of_string ty s r] returns the integer constant of type [ty] and
928 value [s], with the radix [r]. See the method [llvm::ConstantInt::get]. *)
929 val const_int_of_string
: lltype
-> string -> int -> llvalue
931 (** [const_float ty n] returns the floating point constant of type [ty] and
932 value [n]. See the method [llvm::ConstantFP::get]. *)
933 val const_float
: lltype
-> float -> llvalue
935 (** [float_of_const c] returns the float value of the [c] constant float.
936 None is returned if this is not an float constant.
937 See the method [llvm::ConstantFP::getDoubleValue].*)
938 val float_of_const
: llvalue
-> float option
940 (** [const_float_of_string ty s] returns the floating point constant of type
941 [ty] and value [n]. See the method [llvm::ConstantFP::get]. *)
942 val const_float_of_string
: lltype
-> string -> llvalue
944 (** {7 Operations on composite constants} *)
946 (** [const_string c s] returns the constant [i8] array with the values of the
947 characters in the string [s] in the context [c]. The array is not
948 null-terminated (but see {!const_stringz}). This value can in turn be used
949 as the initializer for a global variable. See the method
950 [llvm::ConstantArray::get]. *)
951 val const_string
: llcontext
-> string -> llvalue
953 (** [const_stringz c s] returns the constant [i8] array with the values of the
954 characters in the string [s] and a null terminator in the context [c]. This
955 value can in turn be used as the initializer for a global variable.
956 See the method [llvm::ConstantArray::get]. *)
957 val const_stringz
: llcontext
-> string -> llvalue
959 (** [const_array ty elts] returns the constant array of type
960 [array_type ty (Array.length elts)] and containing the values [elts].
961 This value can in turn be used as the initializer for a global variable.
962 See the method [llvm::ConstantArray::get]. *)
963 val const_array
: lltype
-> llvalue array
-> llvalue
965 (** [const_struct context elts] returns the structured constant of type
966 [struct_type (Array.map type_of elts)] and containing the values [elts]
967 in the context [context]. This value can in turn be used as the initializer
968 for a global variable. See the method [llvm::ConstantStruct::getAnon]. *)
969 val const_struct
: llcontext
-> llvalue array
-> llvalue
971 (** [const_named_struct namedty elts] returns the structured constant of type
972 [namedty] (which must be a named structure type) and containing the values [elts].
973 This value can in turn be used as the initializer
974 for a global variable. See the method [llvm::ConstantStruct::get]. *)
975 val const_named_struct
: lltype
-> llvalue array
-> llvalue
977 (** [const_packed_struct context elts] returns the structured constant of
978 type {!packed_struct_type} [(Array.map type_of elts)] and containing the
979 values [elts] in the context [context]. This value can in turn be used as
980 the initializer for a global variable. See the method
981 [llvm::ConstantStruct::get]. *)
982 val const_packed_struct
: llcontext
-> llvalue array
-> llvalue
984 (** [const_vector elts] returns the vector constant of type
985 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
986 values [elts]. See the method [llvm::ConstantVector::get]. *)
987 val const_vector
: llvalue array
-> llvalue
989 (** [string_of_const c] returns [Some str] if [c] is a string constant,
990 or [None] if this is not a string constant. *)
991 val string_of_const
: llvalue
-> string option
993 (** [const_element c] returns a constant for a specified index's element.
994 See the method ConstantDataSequential::getElementAsConstant. *)
995 val const_element
: llvalue
-> int -> llvalue
998 (** {7 Constant expressions} *)
1000 (** [align_of ty] returns the alignof constant for the type [ty]. This is
1001 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type {i8,ty}))
1002 (const_int i32_type 0) (const_int i32_type 1)) i32_type], but considerably
1003 more readable. See the method [llvm::ConstantExpr::getAlignOf]. *)
1004 val align_of
: lltype
-> llvalue
1006 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
1007 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
1008 (const_int i32_type 1)) i64_type], but considerably more readable.
1009 See the method [llvm::ConstantExpr::getSizeOf]. *)
1010 val size_of
: lltype
-> llvalue
1012 (** [const_neg c] returns the arithmetic negation of the constant [c].
1013 See the method [llvm::ConstantExpr::getNeg]. *)
1014 val const_neg
: llvalue
-> llvalue
1016 (** [const_nsw_neg c] returns the arithmetic negation of the constant [c] with
1017 no signed wrapping. The result is undefined if the negation overflows.
1018 See the method [llvm::ConstantExpr::getNSWNeg]. *)
1019 val const_nsw_neg
: llvalue
-> llvalue
1021 (** [const_nuw_neg c] returns the arithmetic negation of the constant [c] with
1022 no unsigned wrapping. The result is undefined if the negation overflows.
1023 See the method [llvm::ConstantExpr::getNUWNeg]. *)
1024 val const_nuw_neg
: llvalue
-> llvalue
1026 (** [const_fneg c] returns the arithmetic negation of the constant float [c].
1027 See the method [llvm::ConstantExpr::getFNeg]. *)
1028 val const_fneg
: llvalue
-> llvalue
1030 (** [const_not c] returns the bitwise inverse of the constant [c].
1031 See the method [llvm::ConstantExpr::getNot]. *)
1032 val const_not
: llvalue
-> llvalue
1034 (** [const_add c1 c2] returns the constant sum of two constants.
1035 See the method [llvm::ConstantExpr::getAdd]. *)
1036 val const_add
: llvalue
-> llvalue
-> llvalue
1038 (** [const_nsw_add c1 c2] returns the constant sum of two constants with no
1039 signed wrapping. The result is undefined if the sum overflows.
1040 See the method [llvm::ConstantExpr::getNSWAdd]. *)
1041 val const_nsw_add
: llvalue
-> llvalue
-> llvalue
1043 (** [const_nuw_add c1 c2] returns the constant sum of two constants with no
1044 unsigned wrapping. The result is undefined if the sum overflows.
1045 See the method [llvm::ConstantExpr::getNSWAdd]. *)
1046 val const_nuw_add
: llvalue
-> llvalue
-> llvalue
1048 (** [const_fadd c1 c2] returns the constant sum of two constant floats.
1049 See the method [llvm::ConstantExpr::getFAdd]. *)
1050 val const_fadd
: llvalue
-> llvalue
-> llvalue
1052 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
1053 constants. See the method [llvm::ConstantExpr::getSub]. *)
1054 val const_sub
: llvalue
-> llvalue
-> llvalue
1056 (** [const_nsw_sub c1 c2] returns the constant difference of two constants with
1057 no signed wrapping. The result is undefined if the sum overflows.
1058 See the method [llvm::ConstantExpr::getNSWSub]. *)
1059 val const_nsw_sub
: llvalue
-> llvalue
-> llvalue
1061 (** [const_nuw_sub c1 c2] returns the constant difference of two constants with
1062 no unsigned wrapping. The result is undefined if the sum overflows.
1063 See the method [llvm::ConstantExpr::getNSWSub]. *)
1064 val const_nuw_sub
: llvalue
-> llvalue
-> llvalue
1066 (** [const_fsub c1 c2] returns the constant difference, [c1 - c2], of two
1067 constant floats. See the method [llvm::ConstantExpr::getFSub]. *)
1068 val const_fsub
: llvalue
-> llvalue
-> llvalue
1070 (** [const_mul c1 c2] returns the constant product of two constants.
1071 See the method [llvm::ConstantExpr::getMul]. *)
1072 val const_mul
: llvalue
-> llvalue
-> llvalue
1074 (** [const_nsw_mul c1 c2] returns the constant product of two constants with
1075 no signed wrapping. The result is undefined if the sum overflows.
1076 See the method [llvm::ConstantExpr::getNSWMul]. *)
1077 val const_nsw_mul
: llvalue
-> llvalue
-> llvalue
1079 (** [const_nuw_mul c1 c2] returns the constant product of two constants with
1080 no unsigned wrapping. The result is undefined if the sum overflows.
1081 See the method [llvm::ConstantExpr::getNSWMul]. *)
1082 val const_nuw_mul
: llvalue
-> llvalue
-> llvalue
1084 (** [const_fmul c1 c2] returns the constant product of two constants floats.
1085 See the method [llvm::ConstantExpr::getFMul]. *)
1086 val const_fmul
: llvalue
-> llvalue
-> llvalue
1088 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
1090 See the method [llvm::ConstantExpr::getUDiv]. *)
1091 val const_udiv
: llvalue
-> llvalue
-> llvalue
1093 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
1095 See the method [llvm::ConstantExpr::getSDiv]. *)
1096 val const_sdiv
: llvalue
-> llvalue
-> llvalue
1098 (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two
1099 signed integer constants. The result is undefined if the result is rounded
1100 or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *)
1101 val const_exact_sdiv
: llvalue
-> llvalue
-> llvalue
1103 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
1105 See the method [llvm::ConstantExpr::getFDiv]. *)
1106 val const_fdiv
: llvalue
-> llvalue
-> llvalue
1108 (** [const_urem c1 c2] returns the constant remainder [c1 MOD c2] of two
1109 unsigned integer constants.
1110 See the method [llvm::ConstantExpr::getURem]. *)
1111 val const_urem
: llvalue
-> llvalue
-> llvalue
1113 (** [const_srem c1 c2] returns the constant remainder [c1 MOD c2] of two
1114 signed integer constants.
1115 See the method [llvm::ConstantExpr::getSRem]. *)
1116 val const_srem
: llvalue
-> llvalue
-> llvalue
1118 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
1119 signed floating point constants.
1120 See the method [llvm::ConstantExpr::getFRem]. *)
1121 val const_frem
: llvalue
-> llvalue
-> llvalue
1123 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
1125 See the method [llvm::ConstantExpr::getAnd]. *)
1126 val const_and
: llvalue
-> llvalue
-> llvalue
1128 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
1130 See the method [llvm::ConstantExpr::getOr]. *)
1131 val const_or
: llvalue
-> llvalue
-> llvalue
1133 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
1135 See the method [llvm::ConstantExpr::getXor]. *)
1136 val const_xor
: llvalue
-> llvalue
-> llvalue
1138 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
1139 constants, [c1 pred c2].
1140 See the method [llvm::ConstantExpr::getICmp]. *)
1141 val const_icmp
: Icmp.t
-> llvalue
-> llvalue
-> llvalue
1143 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
1144 point constants, [c1 pred c2].
1145 See the method [llvm::ConstantExpr::getFCmp]. *)
1146 val const_fcmp
: Fcmp.t
-> llvalue
-> llvalue
-> llvalue
1148 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
1149 constant integer [c2].
1150 See the method [llvm::ConstantExpr::getShl]. *)
1151 val const_shl
: llvalue
-> llvalue
-> llvalue
1153 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
1154 constant integer [c2] with zero extension.
1155 See the method [llvm::ConstantExpr::getLShr]. *)
1156 val const_lshr
: llvalue
-> llvalue
-> llvalue
1158 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
1159 constant integer [c2] with sign extension.
1160 See the method [llvm::ConstantExpr::getAShr]. *)
1161 val const_ashr
: llvalue
-> llvalue
-> llvalue
1163 (** [const_gep pc indices] returns the constant [getElementPtr] of [pc] with the
1164 constant integers indices from the array [indices].
1165 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
1166 val const_gep
: llvalue
-> llvalue array
-> llvalue
1168 (** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [pc]
1169 with the constant integers indices from the array [indices].
1170 See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
1171 val const_in_bounds_gep
: llvalue
-> llvalue array
-> llvalue
1173 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
1174 to the smaller integer type [ty].
1175 See the method [llvm::ConstantExpr::getTrunc]. *)
1176 val const_trunc
: llvalue
-> lltype
-> llvalue
1178 (** [const_sext c ty] returns the constant sign extension of integer constant
1179 [c] to the larger integer type [ty].
1180 See the method [llvm::ConstantExpr::getSExt]. *)
1181 val const_sext
: llvalue
-> lltype
-> llvalue
1183 (** [const_zext c ty] returns the constant zero extension of integer constant
1184 [c] to the larger integer type [ty].
1185 See the method [llvm::ConstantExpr::getZExt]. *)
1186 val const_zext
: llvalue
-> lltype
-> llvalue
1188 (** [const_fptrunc c ty] returns the constant truncation of floating point
1189 constant [c] to the smaller floating point type [ty].
1190 See the method [llvm::ConstantExpr::getFPTrunc]. *)
1191 val const_fptrunc
: llvalue
-> lltype
-> llvalue
1193 (** [const_fpext c ty] returns the constant extension of floating point constant
1194 [c] to the larger floating point type [ty].
1195 See the method [llvm::ConstantExpr::getFPExt]. *)
1196 val const_fpext
: llvalue
-> lltype
-> llvalue
1198 (** [const_uitofp c ty] returns the constant floating point conversion of
1199 unsigned integer constant [c] to the floating point type [ty].
1200 See the method [llvm::ConstantExpr::getUIToFP]. *)
1201 val const_uitofp
: llvalue
-> lltype
-> llvalue
1203 (** [const_sitofp c ty] returns the constant floating point conversion of
1204 signed integer constant [c] to the floating point type [ty].
1205 See the method [llvm::ConstantExpr::getSIToFP]. *)
1206 val const_sitofp
: llvalue
-> lltype
-> llvalue
1208 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
1209 floating point constant [c] to integer type [ty].
1210 See the method [llvm::ConstantExpr::getFPToUI]. *)
1211 val const_fptoui
: llvalue
-> lltype
-> llvalue
1213 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
1214 floating point constant [c] to integer type [ty].
1215 See the method [llvm::ConstantExpr::getFPToSI]. *)
1216 val const_fptosi
: llvalue
-> lltype
-> llvalue
1218 (** [const_ptrtoint c ty] returns the constant integer conversion of
1219 pointer constant [c] to integer type [ty].
1220 See the method [llvm::ConstantExpr::getPtrToInt]. *)
1221 val const_ptrtoint
: llvalue
-> lltype
-> llvalue
1223 (** [const_inttoptr c ty] returns the constant pointer conversion of
1224 integer constant [c] to pointer type [ty].
1225 See the method [llvm::ConstantExpr::getIntToPtr]. *)
1226 val const_inttoptr
: llvalue
-> lltype
-> llvalue
1228 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
1229 to type [ty] of equal size.
1230 See the method [llvm::ConstantExpr::getBitCast]. *)
1231 val const_bitcast
: llvalue
-> lltype
-> llvalue
1233 (** [const_zext_or_bitcast c ty] returns a constant zext or bitwise cast
1234 conversion of constant [c] to type [ty].
1235 See the method [llvm::ConstantExpr::getZExtOrBitCast]. *)
1236 val const_zext_or_bitcast
: llvalue
-> lltype
-> llvalue
1238 (** [const_sext_or_bitcast c ty] returns a constant sext or bitwise cast
1239 conversion of constant [c] to type [ty].
1240 See the method [llvm::ConstantExpr::getSExtOrBitCast]. *)
1241 val const_sext_or_bitcast
: llvalue
-> lltype
-> llvalue
1243 (** [const_trunc_or_bitcast c ty] returns a constant trunc or bitwise cast
1244 conversion of constant [c] to type [ty].
1245 See the method [llvm::ConstantExpr::getTruncOrBitCast]. *)
1246 val const_trunc_or_bitcast
: llvalue
-> lltype
-> llvalue
1248 (** [const_pointercast c ty] returns a constant bitcast or a pointer-to-int
1249 cast conversion of constant [c] to type [ty] of equal size.
1250 See the method [llvm::ConstantExpr::getPointerCast]. *)
1251 val const_pointercast
: llvalue
-> lltype
-> llvalue
1253 (** [const_intcast c ty ~is_signed] returns a constant sext/zext, bitcast,
1254 or trunc for integer -> integer casts of constant [c] to type [ty].
1255 When converting a narrower value to a wider one, whether sext or zext
1256 will be used is controlled by [is_signed].
1257 See the method [llvm::ConstantExpr::getIntegerCast]. *)
1258 val const_intcast
: llvalue
-> lltype
-> is_signed
:bool -> llvalue
1260 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
1261 fp casts of constant [c] to type [ty].
1262 See the method [llvm::ConstantExpr::getFPCast]. *)
1263 val const_fpcast
: llvalue
-> lltype
-> llvalue
1265 (** [const_select cond t f] returns the constant conditional which returns value
1266 [t] if the boolean constant [cond] is true and the value [f] otherwise.
1267 See the method [llvm::ConstantExpr::getSelect]. *)
1268 val const_select
: llvalue
-> llvalue
-> llvalue
-> llvalue
1270 (** [const_extractelement vec i] returns the constant [i]th element of
1271 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
1272 the size of the vector.
1273 See the method [llvm::ConstantExpr::getExtractElement]. *)
1274 val const_extractelement
: llvalue
-> llvalue
-> llvalue
1276 (** [const_insertelement vec v i] returns the constant vector with the same
1277 elements as constant vector [v] but the [i]th element replaced by the
1278 constant [v]. [v] must be a constant value with the type of the vector
1279 elements. [i] must be a constant [i32] value unsigned less than the size
1281 See the method [llvm::ConstantExpr::getInsertElement]. *)
1282 val const_insertelement
: llvalue
-> llvalue
-> llvalue
-> llvalue
1284 (** [const_shufflevector a b mask] returns a constant [shufflevector].
1285 See the LLVM Language Reference for details on the [shufflevector]
1287 See the method [llvm::ConstantExpr::getShuffleVector]. *)
1288 val const_shufflevector
: llvalue
-> llvalue
-> llvalue
-> llvalue
1290 (** [const_extractvalue agg idxs] returns the constant [idxs]th value of
1291 constant aggregate [agg]. Each [idxs] must be less than the size of the
1292 aggregate. See the method [llvm::ConstantExpr::getExtractValue]. *)
1293 val const_extractvalue
: llvalue
-> int array
-> llvalue
1295 (** [const_insertvalue agg val idxs] inserts the value [val] in the specified
1296 indexs [idxs] in the aggegate [agg]. Each [idxs] must be less than the size
1297 of the aggregate. See the method [llvm::ConstantExpr::getInsertValue]. *)
1298 val const_insertvalue
: llvalue
-> llvalue
-> int array
-> llvalue
1300 (** [const_inline_asm ty asm con side align] inserts a inline assembly string.
1301 See the method [llvm::InlineAsm::get]. *)
1302 val const_inline_asm
: lltype
-> string -> string -> bool -> bool -> llvalue
1304 (** [block_address f bb] returns the address of the basic block [bb] in the
1305 function [f]. See the method [llvm::BasicBlock::get]. *)
1306 val block_address
: llvalue
-> llbasicblock
-> llvalue
1309 (** {7 Operations on global variables, functions, and aliases (globals)} *)
1311 (** [global_parent g] is the enclosing module of the global value [g].
1312 See the method [llvm::GlobalValue::getParent]. *)
1313 val global_parent
: llvalue
-> llmodule
1315 (** [is_declaration g] returns [true] if the global value [g] is a declaration
1316 only. Returns [false] otherwise.
1317 See the method [llvm::GlobalValue::isDeclaration]. *)
1318 val is_declaration
: llvalue
-> bool
1320 (** [linkage g] returns the linkage of the global value [g].
1321 See the method [llvm::GlobalValue::getLinkage]. *)
1322 val linkage
: llvalue
-> Linkage.t
1324 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
1325 See the method [llvm::GlobalValue::setLinkage]. *)
1326 val set_linkage
: Linkage.t
-> llvalue
-> unit
1328 (** [unnamed_addr g] returns [true] if the global value [g] has the unnamed_addr
1329 attribute. Returns [false] otherwise.
1330 See the method [llvm::GlobalValue::getUnnamedAddr]. *)
1331 val unnamed_addr
: llvalue
-> bool
1333 (** [set_unnamed_addr b g] if [b] is [true], sets the unnamed_addr attribute of
1334 the global value [g]. Unset it otherwise.
1335 See the method [llvm::GlobalValue::setUnnamedAddr]. *)
1336 val set_unnamed_addr
: bool -> llvalue
-> unit
1338 (** [section g] returns the linker section of the global value [g].
1339 See the method [llvm::GlobalValue::getSection]. *)
1340 val section
: llvalue
-> string
1342 (** [set_section s g] sets the linker section of the global value [g] to [s].
1343 See the method [llvm::GlobalValue::setSection]. *)
1344 val set_section
: string -> llvalue
-> unit
1346 (** [visibility g] returns the linker visibility of the global value [g].
1347 See the method [llvm::GlobalValue::getVisibility]. *)
1348 val visibility
: llvalue
-> Visibility.t
1350 (** [set_visibility v g] sets the linker visibility of the global value [g] to
1351 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
1352 val set_visibility
: Visibility.t
-> llvalue
-> unit
1354 (** [dll_storage_class g] returns the DLL storage class of the global value [g].
1355 See the method [llvm::GlobalValue::getDLLStorageClass]. *)
1356 val dll_storage_class
: llvalue
-> DLLStorageClass.t
1358 (** [set_dll_storage_class v g] sets the DLL storage class of the global value [g] to
1359 [v]. See the method [llvm::GlobalValue::setDLLStorageClass]. *)
1360 val set_dll_storage_class
: DLLStorageClass.t
-> llvalue
-> unit
1362 (** [alignment g] returns the required alignment of the global value [g].
1363 See the method [llvm::GlobalValue::getAlignment]. *)
1364 val alignment
: llvalue
-> int
1366 (** [set_alignment n g] sets the required alignment of the global value [g] to
1367 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
1368 val set_alignment
: int -> llvalue
-> unit
1371 (** {7 Operations on global variables} *)
1373 (** [declare_global ty name m] returns a new global variable of type [ty] and
1374 with name [name] in module [m] in the default address space (0). If such a
1375 global variable already exists, it is returned. If the type of the existing
1376 global differs, then a bitcast to [ty] is returned. *)
1377 val declare_global
: lltype
-> string -> llmodule
-> llvalue
1379 (** [declare_qualified_global ty name addrspace m] returns a new global variable
1380 of type [ty] and with name [name] in module [m] in the address space
1381 [addrspace]. If such a global variable already exists, it is returned. If
1382 the type of the existing global differs, then a bitcast to [ty] is
1384 val declare_qualified_global
: lltype
-> string -> int -> llmodule
-> llvalue
1386 (** [define_global name init m] returns a new global with name [name] and
1387 initializer [init] in module [m] in the default address space (0). If the
1388 named global already exists, it is renamed.
1389 See the constructor of [llvm::GlobalVariable]. *)
1390 val define_global
: string -> llvalue
-> llmodule
-> llvalue
1392 (** [define_qualified_global name init addrspace m] returns a new global with
1393 name [name] and initializer [init] in module [m] in the address space
1394 [addrspace]. If the named global already exists, it is renamed.
1395 See the constructor of [llvm::GlobalVariable]. *)
1396 val define_qualified_global
: string -> llvalue
-> int -> llmodule
-> llvalue
1398 (** [lookup_global name m] returns [Some g] if a global variable with name
1399 [name] exists in module [m]. If no such global exists, returns [None].
1400 See the [llvm::GlobalVariable] constructor. *)
1401 val lookup_global
: string -> llmodule
-> llvalue
option
1403 (** [delete_global gv] destroys the global variable [gv].
1404 See the method [llvm::GlobalVariable::eraseFromParent]. *)
1405 val delete_global
: llvalue
-> unit
1407 (** [global_begin m] returns the first position in the global variable list of
1408 the module [m]. [global_begin] and [global_succ] can be used to iterate
1409 over the global list in order.
1410 See the method [llvm::Module::global_begin]. *)
1411 val global_begin
: llmodule
-> (llmodule
, llvalue
) llpos
1413 (** [global_succ gv] returns the global variable list position succeeding
1415 See the method [llvm::Module::global_iterator::operator++]. *)
1416 val global_succ
: llvalue
-> (llmodule
, llvalue
) llpos
1418 (** [iter_globals f m] applies function [f] to each of the global variables of
1419 module [m] in order. Tail recursive. *)
1420 val iter_globals
: (llvalue
-> unit) -> llmodule
-> unit
1422 (** [fold_left_globals f init m] is [f (... (f init g1) ...) gN] where
1423 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1424 val fold_left_globals
: ('a
-> llvalue
-> 'a
) -> 'a
-> llmodule
-> 'a
1426 (** [global_end m] returns the last position in the global variable list of the
1427 module [m]. [global_end] and [global_pred] can be used to iterate over the
1428 global list in reverse.
1429 See the method [llvm::Module::global_end]. *)
1430 val global_end
: llmodule
-> (llmodule
, llvalue
) llrev_pos
1432 (** [global_pred gv] returns the global variable list position preceding
1434 See the method [llvm::Module::global_iterator::operator--]. *)
1435 val global_pred
: llvalue
-> (llmodule
, llvalue
) llrev_pos
1437 (** [rev_iter_globals f m] applies function [f] to each of the global variables
1438 of module [m] in reverse order. Tail recursive. *)
1439 val rev_iter_globals
: (llvalue
-> unit) -> llmodule
-> unit
1441 (** [fold_right_globals f m init] is [f g1 (... (f gN init) ...)] where
1442 [g1,...,gN] are the global variables of module [m]. Tail recursive. *)
1443 val fold_right_globals
: (llvalue
-> 'a
-> 'a
) -> llmodule
-> 'a
-> 'a
1445 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
1446 constant. Returns [false] otherwise.
1447 See the method [llvm::GlobalVariable::isConstant]. *)
1448 val is_global_constant
: llvalue
-> bool
1450 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
1451 [c] is [true] and not if [c] is [false].
1452 See the method [llvm::GlobalVariable::setConstant]. *)
1453 val set_global_constant
: bool -> llvalue
-> unit
1455 (** [global_initializer gv] returns the initializer for the global variable
1456 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
1457 val global_initializer
: llvalue
-> llvalue
1459 (** [set_initializer c gv] sets the initializer for the global variable
1460 [gv] to the constant [c].
1461 See the method [llvm::GlobalVariable::setInitializer]. *)
1462 val set_initializer
: llvalue
-> llvalue
-> unit
1464 (** [remove_initializer gv] unsets the initializer for the global variable
1466 See the method [llvm::GlobalVariable::setInitializer]. *)
1467 val remove_initializer
: llvalue
-> unit
1469 (** [is_thread_local gv] returns [true] if the global variable [gv] is
1470 thread-local and [false] otherwise.
1471 See the method [llvm::GlobalVariable::isThreadLocal]. *)
1472 val is_thread_local
: llvalue
-> bool
1474 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
1475 [c] is [true] and not otherwise.
1476 See the method [llvm::GlobalVariable::setThreadLocal]. *)
1477 val set_thread_local
: bool -> llvalue
-> unit
1479 (** [is_thread_local gv] returns the thread local mode of the global
1481 See the method [llvm::GlobalVariable::getThreadLocalMode]. *)
1482 val thread_local_mode
: llvalue
-> ThreadLocalMode.t
1484 (** [set_thread_local c gv] sets the thread local mode of the global
1486 See the method [llvm::GlobalVariable::setThreadLocalMode]. *)
1487 val set_thread_local_mode
: ThreadLocalMode.t
-> llvalue
-> unit
1489 (** [is_externally_initialized gv] returns [true] if the global
1490 variable [gv] is externally initialized and [false] otherwise.
1491 See the method [llvm::GlobalVariable::isExternallyInitialized]. *)
1492 val is_externally_initialized
: llvalue
-> bool
1494 (** [set_externally_initialized c gv] sets the global variable [gv] to be
1495 externally initialized if [c] is [true] and not otherwise.
1496 See the method [llvm::GlobalVariable::setExternallyInitialized]. *)
1497 val set_externally_initialized
: bool -> llvalue
-> unit
1500 (** {7 Operations on aliases} *)
1502 (** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
1503 the aliasee [a] with the name [n].
1504 See the constructor for [llvm::GlobalAlias]. *)
1505 val add_alias
: llmodule
-> lltype
-> llvalue
-> string -> llvalue
1508 (** {7 Operations on functions} *)
1510 (** [declare_function name ty m] returns a new function of type [ty] and
1511 with name [name] in module [m]. If such a function already exists,
1512 it is returned. If the type of the existing function differs, then a bitcast
1513 to [ty] is returned. *)
1514 val declare_function
: string -> lltype
-> llmodule
-> llvalue
1516 (** [define_function name ty m] creates a new function with name [name] and
1517 type [ty] in module [m]. If the named function already exists, it is
1518 renamed. An entry basic block is created in the function.
1519 See the constructor of [llvm::GlobalVariable]. *)
1520 val define_function
: string -> lltype
-> llmodule
-> llvalue
1522 (** [lookup_function name m] returns [Some f] if a function with name
1523 [name] exists in module [m]. If no such function exists, returns [None].
1524 See the method [llvm::Module] constructor. *)
1525 val lookup_function
: string -> llmodule
-> llvalue
option
1527 (** [delete_function f] destroys the function [f].
1528 See the method [llvm::Function::eraseFromParent]. *)
1529 val delete_function
: llvalue
-> unit
1531 (** [function_begin m] returns the first position in the function list of the
1532 module [m]. [function_begin] and [function_succ] can be used to iterate over
1533 the function list in order.
1534 See the method [llvm::Module::begin]. *)
1535 val function_begin
: llmodule
-> (llmodule
, llvalue
) llpos
1537 (** [function_succ gv] returns the function list position succeeding
1539 See the method [llvm::Module::iterator::operator++]. *)
1540 val function_succ
: llvalue
-> (llmodule
, llvalue
) llpos
1542 (** [iter_functions f m] applies function [f] to each of the functions of module
1543 [m] in order. Tail recursive. *)
1544 val iter_functions
: (llvalue
-> unit) -> llmodule
-> unit
1546 (** [fold_left_function f init m] is [f (... (f init f1) ...) fN] where
1547 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1548 val fold_left_functions
: ('a
-> llvalue
-> 'a
) -> 'a
-> llmodule
-> 'a
1550 (** [function_end m] returns the last position in the function list of
1551 the module [m]. [function_end] and [function_pred] can be used to iterate
1552 over the function list in reverse.
1553 See the method [llvm::Module::end]. *)
1554 val function_end
: llmodule
-> (llmodule
, llvalue
) llrev_pos
1556 (** [function_pred gv] returns the function list position preceding [After gv].
1557 See the method [llvm::Module::iterator::operator--]. *)
1558 val function_pred
: llvalue
-> (llmodule
, llvalue
) llrev_pos
1560 (** [rev_iter_functions f fn] applies function [f] to each of the functions of
1561 module [m] in reverse order. Tail recursive. *)
1562 val rev_iter_functions
: (llvalue
-> unit) -> llmodule
-> unit
1564 (** [fold_right_functions f m init] is [f (... (f init fN) ...) f1] where
1565 [f1,...,fN] are the functions of module [m]. Tail recursive. *)
1566 val fold_right_functions
: (llvalue
-> 'a
-> 'a
) -> llmodule
-> 'a
-> 'a
1568 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
1569 See the method [llvm::Function::isIntrinsic]. *)
1570 val is_intrinsic
: llvalue
-> bool
1572 (** [function_call_conv f] returns the calling convention of the function [f].
1573 See the method [llvm::Function::getCallingConv]. *)
1574 val function_call_conv
: llvalue
-> int
1576 (** [set_function_call_conv cc f] sets the calling convention of the function
1577 [f] to the calling convention numbered [cc].
1578 See the method [llvm::Function::setCallingConv]. *)
1579 val set_function_call_conv
: int -> llvalue
-> unit
1581 (** [gc f] returns [Some name] if the function [f] has a garbage
1582 collection algorithm specified and [None] otherwise.
1583 See the method [llvm::Function::getGC]. *)
1584 val gc
: llvalue
-> string option
1586 (** [set_gc gc f] sets the collection algorithm for the function [f] to
1587 [gc]. See the method [llvm::Function::setGC]. *)
1588 val set_gc
: string option -> llvalue
-> unit
1590 (** [add_function_attr f a i] adds attribute [a] to the function [f]
1592 val add_function_attr
: llvalue
-> llattribute
-> AttrIndex.t
-> unit
1594 (** [function_attrs f i] returns the attributes for the function [f]
1596 val function_attrs
: llvalue
-> AttrIndex.t
-> llattribute array
1598 (** [remove_enum_function_attr f k i] removes enum attribute with kind [k]
1599 from the function [f] at position [i]. *)
1600 val remove_enum_function_attr
: llvalue
-> llattrkind
-> AttrIndex.t
-> unit
1602 (** [remove_string_function_attr f k i] removes string attribute with kind [k]
1603 from the function [f] at position [i]. *)
1604 val remove_string_function_attr
: llvalue
-> string -> AttrIndex.t
-> unit
1607 (** {7 Operations on params} *)
1609 (** [params f] returns the parameters of function [f].
1610 See the method [llvm::Function::getArgumentList]. *)
1611 val params
: llvalue
-> llvalue array
1613 (** [param f n] returns the [n]th parameter of function [f].
1614 See the method [llvm::Function::getArgumentList]. *)
1615 val param
: llvalue
-> int -> llvalue
1617 (** [param_parent p] returns the parent function that owns the parameter.
1618 See the method [llvm::Argument::getParent]. *)
1619 val param_parent
: llvalue
-> llvalue
1621 (** [param_begin f] returns the first position in the parameter list of the
1622 function [f]. [param_begin] and [param_succ] can be used to iterate over
1623 the parameter list in order.
1624 See the method [llvm::Function::arg_begin]. *)
1625 val param_begin
: llvalue
-> (llvalue
, llvalue
) llpos
1627 (** [param_succ bb] returns the parameter list position succeeding
1629 See the method [llvm::Function::arg_iterator::operator++]. *)
1630 val param_succ
: llvalue
-> (llvalue
, llvalue
) llpos
1632 (** [iter_params f fn] applies function [f] to each of the parameters
1633 of function [fn] in order. Tail recursive. *)
1634 val iter_params
: (llvalue
-> unit) -> llvalue
-> unit
1636 (** [fold_left_params f init fn] is [f (... (f init b1) ...) bN] where
1637 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1638 val fold_left_params
: ('a
-> llvalue
-> 'a
) -> 'a
-> llvalue
-> 'a
1640 (** [param_end f] returns the last position in the parameter list of
1641 the function [f]. [param_end] and [param_pred] can be used to iterate
1642 over the parameter list in reverse.
1643 See the method [llvm::Function::arg_end]. *)
1644 val param_end
: llvalue
-> (llvalue
, llvalue
) llrev_pos
1646 (** [param_pred gv] returns the function list position preceding [After gv].
1647 See the method [llvm::Function::arg_iterator::operator--]. *)
1648 val param_pred
: llvalue
-> (llvalue
, llvalue
) llrev_pos
1650 (** [rev_iter_params f fn] applies function [f] to each of the parameters
1651 of function [fn] in reverse order. Tail recursive. *)
1652 val rev_iter_params
: (llvalue
-> unit) -> llvalue
-> unit
1654 (** [fold_right_params f fn init] is [f (... (f init bN) ...) b1] where
1655 [b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
1656 val fold_right_params
: (llvalue
-> 'a
-> 'a
) -> llvalue
-> 'a
-> 'a
1659 (** {7 Operations on basic blocks} *)
1661 (** [basic_blocks fn] returns the basic blocks of the function [f].
1662 See the method [llvm::Function::getBasicBlockList]. *)
1663 val basic_blocks
: llvalue
-> llbasicblock array
1665 (** [entry_block fn] returns the entry basic block of the function [f].
1666 See the method [llvm::Function::getEntryBlock]. *)
1667 val entry_block
: llvalue
-> llbasicblock
1669 (** [delete_block bb] deletes the basic block [bb].
1670 See the method [llvm::BasicBlock::eraseFromParent]. *)
1671 val delete_block
: llbasicblock
-> unit
1673 (** [remove_block bb] removes the basic block [bb] from its parent function.
1674 See the method [llvm::BasicBlock::removeFromParent]. *)
1675 val remove_block
: llbasicblock
-> unit
1677 (** [move_block_before pos bb] moves the basic block [bb] before [pos].
1678 See the method [llvm::BasicBlock::moveBefore]. *)
1679 val move_block_before
: llbasicblock
-> llbasicblock
-> unit
1681 (** [move_block_after pos bb] moves the basic block [bb] after [pos].
1682 See the method [llvm::BasicBlock::moveAfter]. *)
1683 val move_block_after
: llbasicblock
-> llbasicblock
-> unit
1685 (** [append_block c name f] creates a new basic block named [name] at the end of
1686 function [f] in the context [c].
1687 See the constructor of [llvm::BasicBlock]. *)
1688 val append_block
: llcontext
-> string -> llvalue
-> llbasicblock
1690 (** [insert_block c name bb] creates a new basic block named [name] before the
1691 basic block [bb] in the context [c].
1692 See the constructor of [llvm::BasicBlock]. *)
1693 val insert_block
: llcontext
-> string -> llbasicblock
-> llbasicblock
1695 (** [block_parent bb] returns the parent function that owns the basic block.
1696 See the method [llvm::BasicBlock::getParent]. *)
1697 val block_parent
: llbasicblock
-> llvalue
1699 (** [block_begin f] returns the first position in the basic block list of the
1700 function [f]. [block_begin] and [block_succ] can be used to iterate over
1701 the basic block list in order.
1702 See the method [llvm::Function::begin]. *)
1703 val block_begin
: llvalue
-> (llvalue
, llbasicblock
) llpos
1705 (** [block_succ bb] returns the basic block list position succeeding
1707 See the method [llvm::Function::iterator::operator++]. *)
1708 val block_succ
: llbasicblock
-> (llvalue
, llbasicblock
) llpos
1710 (** [iter_blocks f fn] applies function [f] to each of the basic blocks
1711 of function [fn] in order. Tail recursive. *)
1712 val iter_blocks
: (llbasicblock
-> unit) -> llvalue
-> unit
1714 (** [fold_left_blocks f init fn] is [f (... (f init b1) ...) bN] where
1715 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1716 val fold_left_blocks
: ('a
-> llbasicblock
-> 'a
) -> 'a
-> llvalue
-> 'a
1718 (** [block_end f] returns the last position in the basic block list of
1719 the function [f]. [block_end] and [block_pred] can be used to iterate
1720 over the basic block list in reverse.
1721 See the method [llvm::Function::end]. *)
1722 val block_end
: llvalue
-> (llvalue
, llbasicblock
) llrev_pos
1724 (** [block_pred bb] returns the basic block list position preceding [After bb].
1725 See the method [llvm::Function::iterator::operator--]. *)
1726 val block_pred
: llbasicblock
-> (llvalue
, llbasicblock
) llrev_pos
1728 (** [block_terminator bb] returns the terminator of the basic block [bb]. *)
1729 val block_terminator
: llbasicblock
-> llvalue
option
1731 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
1732 of function [fn] in reverse order. Tail recursive. *)
1733 val rev_iter_blocks
: (llbasicblock
-> unit) -> llvalue
-> unit
1735 (** [fold_right_blocks f fn init] is [f (... (f init bN) ...) b1] where
1736 [b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
1737 val fold_right_blocks
: (llbasicblock
-> 'a
-> 'a
) -> llvalue
-> 'a
-> 'a
1739 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
1740 val value_of_block
: llbasicblock
-> llvalue
1742 (** [value_is_block v] returns [true] if the value [v] is a basic block and
1744 Similar to [llvm::isa<BasicBlock>]. *)
1745 val value_is_block
: llvalue
-> bool
1747 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
1748 val block_of_value
: llvalue
-> llbasicblock
1751 (** {7 Operations on instructions} *)
1753 (** [instr_parent i] is the enclosing basic block of the instruction [i].
1754 See the method [llvm::Instruction::getParent]. *)
1755 val instr_parent
: llvalue
-> llbasicblock
1757 (** [delete_instruction i] deletes the instruction [i].
1758 * See the method [llvm::Instruction::eraseFromParent]. *)
1759 val delete_instruction
: llvalue
-> unit
1761 (** [instr_begin bb] returns the first position in the instruction list of the
1762 basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
1763 the instruction list in order.
1764 See the method [llvm::BasicBlock::begin]. *)
1765 val instr_begin
: llbasicblock
-> (llbasicblock
, llvalue
) llpos
1767 (** [instr_succ i] returns the instruction list position succeeding [Before i].
1768 See the method [llvm::BasicBlock::iterator::operator++]. *)
1769 val instr_succ
: llvalue
-> (llbasicblock
, llvalue
) llpos
1771 (** [iter_instrs f bb] applies function [f] to each of the instructions of basic
1772 block [bb] in order. Tail recursive. *)
1773 val iter_instrs
: (llvalue
-> unit) -> llbasicblock
-> unit
1775 (** [fold_left_instrs f init bb] is [f (... (f init g1) ...) gN] where
1776 [g1,...,gN] are the instructions of basic block [bb]. Tail recursive. *)
1777 val fold_left_instrs
: ('a
-> llvalue
-> 'a
) -> 'a
-> llbasicblock
-> 'a
1779 (** [instr_end bb] returns the last position in the instruction list of the
1780 basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
1781 the instruction list in reverse.
1782 See the method [llvm::BasicBlock::end]. *)
1783 val instr_end
: llbasicblock
-> (llbasicblock
, llvalue
) llrev_pos
1785 (** [instr_pred i] returns the instruction list position preceding [After i].
1786 See the method [llvm::BasicBlock::iterator::operator--]. *)
1787 val instr_pred
: llvalue
-> (llbasicblock
, llvalue
) llrev_pos
1789 (** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
1790 [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
1791 val fold_right_instrs
: (llvalue
-> 'a
-> 'a
) -> llbasicblock
-> 'a
-> 'a
1793 (** [inst_opcode i] returns the [Opcode.t] corresponding to instruction [i],
1794 or [Opcode.Invalid] if [i] is not an instruction. *)
1795 val instr_opcode
: llvalue
-> Opcode.t
1797 (** [icmp_predicate i] returns the [Icmp.t] corresponding to an [icmp]
1799 val icmp_predicate
: llvalue
-> Icmp.t
option
1801 (** [fcmp_predicate i] returns the [fcmp.t] corresponding to an [fcmp]
1803 val fcmp_predicate
: llvalue
-> Fcmp.t
option
1805 (** [inst_clone i] returns a copy of instruction [i],
1806 The instruction has no parent, and no name.
1807 See the method [llvm::Instruction::clone]. *)
1808 val instr_clone
: llvalue
-> llvalue
1811 (** {7 Operations on call sites} *)
1813 (** [instruction_call_conv ci] is the calling convention for the call or invoke
1814 instruction [ci], which may be one of the values from the module
1815 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
1816 [llvm::InvokeInst::getCallingConv]. *)
1817 val instruction_call_conv
: llvalue
-> int
1819 (** [set_instruction_call_conv cc ci] sets the calling convention for the call
1820 or invoke instruction [ci] to the integer [cc], which can be one of the
1821 values from the module {!CallConv}.
1822 See the method [llvm::CallInst::setCallingConv]
1823 and [llvm::InvokeInst::setCallingConv]. *)
1824 val set_instruction_call_conv
: int -> llvalue
-> unit
1826 (** [add_call_site_attr f a i] adds attribute [a] to the call instruction [ci]
1828 val add_call_site_attr
: llvalue
-> llattribute
-> AttrIndex.t
-> unit
1830 (** [call_site_attr f i] returns the attributes for the call instruction [ci]
1832 val call_site_attrs
: llvalue
-> AttrIndex.t
-> llattribute array
1834 (** [remove_enum_call_site_attr f k i] removes enum attribute with kind [k]
1835 from the call instruction [ci] at position [i]. *)
1836 val remove_enum_call_site_attr
: llvalue
-> llattrkind
-> AttrIndex.t
-> unit
1838 (** [remove_string_call_site_attr f k i] removes string attribute with kind [k]
1839 from the call instruction [ci] at position [i]. *)
1840 val remove_string_call_site_attr
: llvalue
-> string -> AttrIndex.t
-> unit
1843 (** {7 Operations on call and invoke instructions (only)} *)
1845 (** [num_arg_operands ci] returns the number of arguments for the call or
1846 invoke instruction [ci]. See the method
1847 [llvm::CallInst::getNumArgOperands]. *)
1848 val num_arg_operands
: llvalue
-> int
1850 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
1851 eligible for tail call optimization, [false] otherwise.
1852 See the method [llvm::CallInst::isTailCall]. *)
1853 val is_tail_call
: llvalue
-> bool
1855 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
1856 call optimization if [tc] is [true], clears otherwise.
1857 See the method [llvm::CallInst::setTailCall]. *)
1858 val set_tail_call
: bool -> llvalue
-> unit
1860 (** [get_normal_dest ii] is the normal destination basic block of an invoke
1861 instruction. See the method [llvm::InvokeInst::getNormalDest()]. *)
1862 val get_normal_dest
: llvalue
-> llbasicblock
1864 (** [get_unwind_dest ii] is the unwind destination basic block of an invoke
1865 instruction. See the method [llvm::InvokeInst::getUnwindDest()]. *)
1866 val get_unwind_dest
: llvalue
-> llbasicblock
1869 (** {7 Operations on load/store instructions (only)} *)
1871 (** [is_volatile i] is [true] if the load or store instruction [i] is marked
1873 See the methods [llvm::LoadInst::isVolatile] and
1874 [llvm::StoreInst::isVolatile]. *)
1875 val is_volatile
: llvalue
-> bool
1877 (** [set_volatile v i] marks the load or store instruction [i] as volatile
1878 if [v] is [true], unmarks otherwise.
1879 See the methods [llvm::LoadInst::setVolatile] and
1880 [llvm::StoreInst::setVolatile]. *)
1881 val set_volatile
: bool -> llvalue
-> unit
1883 (** {7 Operations on terminators} *)
1885 (** [is_terminator v] returns true if the instruction [v] is a terminator. *)
1886 val is_terminator
: llvalue
-> bool
1888 (** [successor v i] returns the successor at index [i] for the value [v].
1889 See the method [llvm::Instruction::getSuccessor]. *)
1890 val successor
: llvalue
-> int -> llbasicblock
1892 (** [set_successor v i o] sets the successor of the value [v] at the index [i] to
1894 See the method [llvm::Instruction::setSuccessor]. *)
1895 val set_successor
: llvalue
-> int -> llbasicblock
-> unit
1897 (** [num_successors v] returns the number of successors for the value [v].
1898 See the method [llvm::Instruction::getNumSuccessors]. *)
1899 val num_successors
: llvalue
-> int
1901 (** [successors v] returns the successors of [v]. *)
1902 val successors
: llvalue
-> llbasicblock array
1904 (** [iter_successors f v] applies function f to each successor [v] in order. Tail recursive. *)
1905 val iter_successors
: (llbasicblock
-> unit) -> llvalue
-> unit
1907 (** [fold_successors f v init] is [f (... (f init vN) ...) v1] where [v1,...,vN] are the successors of [v]. Tail recursive. *)
1908 val fold_successors
: (llbasicblock
-> 'a
-> 'a
) -> llvalue
-> 'a
-> 'a
1910 (** {7 Operations on branches} *)
1912 (** [is_conditional v] returns true if the branch instruction [v] is conditional.
1913 See the method [llvm::BranchInst::isConditional]. *)
1914 val is_conditional
: llvalue
-> bool
1916 (** [condition v] return the condition of the branch instruction [v].
1917 See the method [llvm::BranchInst::getCondition]. *)
1918 val condition
: llvalue
-> llvalue
1920 (** [set_condition v c] sets the condition of the branch instruction [v] to the value [c].
1921 See the method [llvm::BranchInst::setCondition]. *)
1922 val set_condition
: llvalue
-> llvalue
-> unit
1924 (** [get_branch c] returns a description of the branch instruction [c]. *)
1925 val get_branch
: llvalue
->
1926 [ `Conditional
of llvalue
* llbasicblock
* llbasicblock
1927 | `Unconditional
of llbasicblock
]
1930 (** {7 Operations on phi nodes} *)
1932 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
1933 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
1934 val add_incoming
: (llvalue
* llbasicblock
) -> llvalue
-> unit
1936 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
1937 See the method [llvm::PHINode::getIncomingValue]. *)
1938 val incoming
: llvalue
-> (llvalue
* llbasicblock
) list
1942 (** {6 Instruction builders} *)
1944 (** [builder context] creates an instruction builder with no position in
1945 the context [context]. It is invalid to use this builder until its position
1946 is set with {!position_before} or {!position_at_end}. See the constructor
1947 for [llvm::LLVMBuilder]. *)
1948 val builder
: llcontext
-> llbuilder
1950 (** [builder_at ip] creates an instruction builder positioned at [ip].
1951 See the constructor for [llvm::LLVMBuilder]. *)
1952 val builder_at
: llcontext
-> (llbasicblock
, llvalue
) llpos
-> llbuilder
1954 (** [builder_before ins] creates an instruction builder positioned before the
1955 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
1956 val builder_before
: llcontext
-> llvalue
-> llbuilder
1958 (** [builder_at_end bb] creates an instruction builder positioned at the end of
1959 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
1960 val builder_at_end
: llcontext
-> llbasicblock
-> llbuilder
1962 (** [position_builder ip bb] moves the instruction builder [bb] to the position
1964 See the constructor for [llvm::LLVMBuilder]. *)
1965 val position_builder
: (llbasicblock
, llvalue
) llpos
-> llbuilder
-> unit
1967 (** [position_before ins b] moves the instruction builder [b] to before the
1968 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1969 val position_before
: llvalue
-> llbuilder
-> unit
1971 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
1972 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
1973 val position_at_end
: llbasicblock
-> llbuilder
-> unit
1975 (** [insertion_block b] returns the basic block that the builder [b] is
1976 positioned to insert into. Raises [Not_Found] if the instruction builder is
1978 See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
1979 val insertion_block
: llbuilder
-> llbasicblock
1981 (** [insert_into_builder i name b] inserts the specified instruction [i] at the
1982 position specified by the instruction builder [b].
1983 See the method [llvm::LLVMBuilder::Insert]. *)
1984 val insert_into_builder
: llvalue
-> string -> llbuilder
-> unit
1989 (** [set_current_debug_location b md] sets the current debug location [md] in
1991 See the method [llvm::IRBuilder::SetDebugLocation]. *)
1992 val set_current_debug_location
: llbuilder
-> llvalue
-> unit
1994 (** [clear_current_debug_location b] clears the current debug location in the
1996 val clear_current_debug_location
: llbuilder
-> unit
1998 (** [current_debug_location b] returns the current debug location, or None
1999 if none is currently set.
2000 See the method [llvm::IRBuilder::GetDebugLocation]. *)
2001 val current_debug_location
: llbuilder
-> llvalue
option
2003 (** [set_inst_debug_location b i] sets the current debug location of the builder
2004 [b] to the instruction [i].
2005 See the method [llvm::IRBuilder::SetInstDebugLocation]. *)
2006 val set_inst_debug_location
: llbuilder
-> llvalue
-> unit
2009 (** {7 Terminators} *)
2011 (** [build_ret_void b] creates a
2013 instruction at the position specified by the instruction builder [b].
2014 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
2015 val build_ret_void
: llbuilder
-> llvalue
2017 (** [build_ret v b] creates a
2019 instruction at the position specified by the instruction builder [b].
2020 See the method [llvm::LLVMBuilder::CreateRet]. *)
2021 val build_ret
: llvalue
-> llbuilder
-> llvalue
2023 (** [build_aggregate_ret vs b] creates a
2024 [ret {...} { %v1, %v2, ... } ]
2025 instruction at the position specified by the instruction builder [b].
2026 See the method [llvm::LLVMBuilder::CreateAggregateRet]. *)
2027 val build_aggregate_ret
: llvalue array
-> llbuilder
-> llvalue
2029 (** [build_br bb b] creates a
2031 instruction at the position specified by the instruction builder [b].
2032 See the method [llvm::LLVMBuilder::CreateBr]. *)
2033 val build_br
: llbasicblock
-> llbuilder
-> llvalue
2035 (** [build_cond_br cond tbb fbb b] creates a
2036 [br %cond, %tbb, %fbb]
2037 instruction at the position specified by the instruction builder [b].
2038 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
2039 val build_cond_br
: llvalue
-> llbasicblock
-> llbasicblock
-> llbuilder
->
2042 (** [build_switch case elsebb count b] creates an empty
2043 [switch %case, %elsebb]
2044 instruction at the position specified by the instruction builder [b] with
2045 space reserved for [count] cases.
2046 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
2047 val build_switch
: llvalue
-> llbasicblock
-> int -> llbuilder
-> llvalue
2049 (** [build_malloc ty name b] creates an [malloc]
2050 instruction at the position specified by the instruction builder [b].
2051 See the method [llvm::CallInst::CreateMalloc]. *)
2052 val build_malloc
: lltype
-> string -> llbuilder
-> llvalue
2054 (** [build_array_malloc ty val name b] creates an [array malloc]
2055 instruction at the position specified by the instruction builder [b].
2056 See the method [llvm::CallInst::CreateArrayMalloc]. *)
2057 val build_array_malloc
: lltype
-> llvalue
-> string -> llbuilder
-> llvalue
2059 (** [build_free p b] creates a [free]
2060 instruction at the position specified by the instruction builder [b].
2061 See the method [llvm::LLVMBuilder::CreateFree]. *)
2062 val build_free
: llvalue
-> llbuilder
-> llvalue
2064 (** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
2065 when its input matches the constant [onval].
2066 See the method [llvm::SwitchInst::addCase]. **)
2067 val add_case
: llvalue
-> llvalue
-> llbasicblock
-> unit
2069 (** [switch_default_dest sw] returns the default destination of the [switch]
2071 See the method [llvm:;SwitchInst::getDefaultDest]. **)
2072 val switch_default_dest
: llvalue
-> llbasicblock
2074 (** [build_indirect_br addr count b] creates a
2076 instruction at the position specified by the instruction builder [b] with
2077 space reserved for [count] destinations.
2078 See the method [llvm::LLVMBuilder::CreateIndirectBr]. *)
2079 val build_indirect_br
: llvalue
-> int -> llbuilder
-> llvalue
2081 (** [add_destination br bb] adds the basic block [bb] as a possible branch
2082 location for the indirectbr instruction [br].
2083 See the method [llvm::IndirectBrInst::addDestination]. **)
2084 val add_destination
: llvalue
-> llbasicblock
-> unit
2086 (** [build_invoke fn args tobb unwindbb name b] creates an
2087 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
2088 instruction at the position specified by the instruction builder [b].
2089 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
2090 val build_invoke
: llvalue
-> llvalue array
-> llbasicblock
->
2091 llbasicblock
-> string -> llbuilder
-> llvalue
2093 (** [build_landingpad ty persfn numclauses name b] creates an
2095 instruction at the position specified by the instruction builder [b].
2096 See the method [llvm::LLVMBuilder::CreateLandingPad]. *)
2097 val build_landingpad
: lltype
-> llvalue
-> int -> string -> llbuilder
->
2100 (** [is_cleanup lp] returns [true] if [landingpad] instruction lp is a cleanup.
2101 See the method [llvm::LandingPadInst::isCleanup]. *)
2102 val is_cleanup
: llvalue
-> bool
2104 (** [set_cleanup lp] sets the cleanup flag in the [landingpad]instruction.
2105 See the method [llvm::LandingPadInst::setCleanup]. *)
2106 val set_cleanup
: llvalue
-> bool -> unit
2108 (** [add_clause lp clause] adds the clause to the [landingpad]instruction.
2109 See the method [llvm::LandingPadInst::addClause]. *)
2110 val add_clause
: llvalue
-> llvalue
-> unit
2112 (** [build_resume exn b] builds a [resume exn] instruction
2113 at the position specified by the instruction builder [b].
2114 See the method [llvm::LLVMBuilder::CreateResume] *)
2115 val build_resume
: llvalue
-> llbuilder
-> llvalue
2117 (** [build_unreachable b] creates an
2119 instruction at the position specified by the instruction builder [b].
2120 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
2121 val build_unreachable
: llbuilder
-> llvalue
2124 (** {7 Arithmetic} *)
2126 (** [build_add x y name b] creates a
2127 [%name = add %x, %y]
2128 instruction at the position specified by the instruction builder [b].
2129 See the method [llvm::LLVMBuilder::CreateAdd]. *)
2130 val build_add
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2132 (** [build_nsw_add x y name b] creates a
2133 [%name = nsw add %x, %y]
2134 instruction at the position specified by the instruction builder [b].
2135 See the method [llvm::LLVMBuilder::CreateNSWAdd]. *)
2136 val build_nsw_add
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2138 (** [build_nuw_add x y name b] creates a
2139 [%name = nuw add %x, %y]
2140 instruction at the position specified by the instruction builder [b].
2141 See the method [llvm::LLVMBuilder::CreateNUWAdd]. *)
2142 val build_nuw_add
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2144 (** [build_fadd x y name b] creates a
2145 [%name = fadd %x, %y]
2146 instruction at the position specified by the instruction builder [b].
2147 See the method [llvm::LLVMBuilder::CreateFAdd]. *)
2148 val build_fadd
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2150 (** [build_sub x y name b] creates a
2151 [%name = sub %x, %y]
2152 instruction at the position specified by the instruction builder [b].
2153 See the method [llvm::LLVMBuilder::CreateSub]. *)
2154 val build_sub
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2156 (** [build_nsw_sub x y name b] creates a
2157 [%name = nsw sub %x, %y]
2158 instruction at the position specified by the instruction builder [b].
2159 See the method [llvm::LLVMBuilder::CreateNSWSub]. *)
2160 val build_nsw_sub
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2162 (** [build_nuw_sub x y name b] creates a
2163 [%name = nuw sub %x, %y]
2164 instruction at the position specified by the instruction builder [b].
2165 See the method [llvm::LLVMBuilder::CreateNUWSub]. *)
2166 val build_nuw_sub
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2168 (** [build_fsub x y name b] creates a
2169 [%name = fsub %x, %y]
2170 instruction at the position specified by the instruction builder [b].
2171 See the method [llvm::LLVMBuilder::CreateFSub]. *)
2172 val build_fsub
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2174 (** [build_mul x y name b] creates a
2175 [%name = mul %x, %y]
2176 instruction at the position specified by the instruction builder [b].
2177 See the method [llvm::LLVMBuilder::CreateMul]. *)
2178 val build_mul
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2180 (** [build_nsw_mul x y name b] creates a
2181 [%name = nsw mul %x, %y]
2182 instruction at the position specified by the instruction builder [b].
2183 See the method [llvm::LLVMBuilder::CreateNSWMul]. *)
2184 val build_nsw_mul
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2186 (** [build_nuw_mul x y name b] creates a
2187 [%name = nuw mul %x, %y]
2188 instruction at the position specified by the instruction builder [b].
2189 See the method [llvm::LLVMBuilder::CreateNUWMul]. *)
2190 val build_nuw_mul
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2192 (** [build_fmul x y name b] creates a
2193 [%name = fmul %x, %y]
2194 instruction at the position specified by the instruction builder [b].
2195 See the method [llvm::LLVMBuilder::CreateFMul]. *)
2196 val build_fmul
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2198 (** [build_udiv x y name b] creates a
2199 [%name = udiv %x, %y]
2200 instruction at the position specified by the instruction builder [b].
2201 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
2202 val build_udiv
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2204 (** [build_sdiv x y name b] creates a
2205 [%name = sdiv %x, %y]
2206 instruction at the position specified by the instruction builder [b].
2207 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
2208 val build_sdiv
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2210 (** [build_exact_sdiv x y name b] creates a
2211 [%name = exact sdiv %x, %y]
2212 instruction at the position specified by the instruction builder [b].
2213 See the method [llvm::LLVMBuilder::CreateExactSDiv]. *)
2214 val build_exact_sdiv
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2216 (** [build_fdiv x y name b] creates a
2217 [%name = fdiv %x, %y]
2218 instruction at the position specified by the instruction builder [b].
2219 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
2220 val build_fdiv
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2222 (** [build_urem x y name b] creates a
2223 [%name = urem %x, %y]
2224 instruction at the position specified by the instruction builder [b].
2225 See the method [llvm::LLVMBuilder::CreateURem]. *)
2226 val build_urem
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2228 (** [build_SRem x y name b] creates a
2229 [%name = srem %x, %y]
2230 instruction at the position specified by the instruction builder [b].
2231 See the method [llvm::LLVMBuilder::CreateSRem]. *)
2232 val build_srem
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2234 (** [build_frem x y name b] creates a
2235 [%name = frem %x, %y]
2236 instruction at the position specified by the instruction builder [b].
2237 See the method [llvm::LLVMBuilder::CreateFRem]. *)
2238 val build_frem
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2240 (** [build_shl x y name b] creates a
2241 [%name = shl %x, %y]
2242 instruction at the position specified by the instruction builder [b].
2243 See the method [llvm::LLVMBuilder::CreateShl]. *)
2244 val build_shl
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2246 (** [build_lshr x y name b] creates a
2247 [%name = lshr %x, %y]
2248 instruction at the position specified by the instruction builder [b].
2249 See the method [llvm::LLVMBuilder::CreateLShr]. *)
2250 val build_lshr
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2252 (** [build_ashr x y name b] creates a
2253 [%name = ashr %x, %y]
2254 instruction at the position specified by the instruction builder [b].
2255 See the method [llvm::LLVMBuilder::CreateAShr]. *)
2256 val build_ashr
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2258 (** [build_and x y name b] creates a
2259 [%name = and %x, %y]
2260 instruction at the position specified by the instruction builder [b].
2261 See the method [llvm::LLVMBuilder::CreateAnd]. *)
2262 val build_and
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2264 (** [build_or x y name b] creates a
2266 instruction at the position specified by the instruction builder [b].
2267 See the method [llvm::LLVMBuilder::CreateOr]. *)
2268 val build_or
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2270 (** [build_xor x y name b] creates a
2271 [%name = xor %x, %y]
2272 instruction at the position specified by the instruction builder [b].
2273 See the method [llvm::LLVMBuilder::CreateXor]. *)
2274 val build_xor
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2276 (** [build_neg x name b] creates a
2278 instruction at the position specified by the instruction builder [b].
2279 [-0.0] is used for floating point types to compute the correct sign.
2280 See the method [llvm::LLVMBuilder::CreateNeg]. *)
2281 val build_neg
: llvalue
-> string -> llbuilder
-> llvalue
2283 (** [build_nsw_neg x name b] creates a
2284 [%name = nsw sub 0, %x]
2285 instruction at the position specified by the instruction builder [b].
2286 [-0.0] is used for floating point types to compute the correct sign.
2287 See the method [llvm::LLVMBuilder::CreateNeg]. *)
2288 val build_nsw_neg
: llvalue
-> string -> llbuilder
-> llvalue
2290 (** [build_nuw_neg x name b] creates a
2291 [%name = nuw sub 0, %x]
2292 instruction at the position specified by the instruction builder [b].
2293 [-0.0] is used for floating point types to compute the correct sign.
2294 See the method [llvm::LLVMBuilder::CreateNeg]. *)
2295 val build_nuw_neg
: llvalue
-> string -> llbuilder
-> llvalue
2297 (** [build_fneg x name b] creates a
2298 [%name = fsub 0, %x]
2299 instruction at the position specified by the instruction builder [b].
2300 [-0.0] is used for floating point types to compute the correct sign.
2301 See the method [llvm::LLVMBuilder::CreateFNeg]. *)
2302 val build_fneg
: llvalue
-> string -> llbuilder
-> llvalue
2304 (** [build_xor x name b] creates a
2305 [%name = xor %x, -1]
2306 instruction at the position specified by the instruction builder [b].
2307 [-1] is the correct "all ones" value for the type of [x].
2308 See the method [llvm::LLVMBuilder::CreateXor]. *)
2309 val build_not
: llvalue
-> string -> llbuilder
-> llvalue
2314 (** [build_alloca ty name b] creates a
2315 [%name = alloca %ty]
2316 instruction at the position specified by the instruction builder [b].
2317 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
2318 val build_alloca
: lltype
-> string -> llbuilder
-> llvalue
2320 (** [build_array_alloca ty n name b] creates a
2321 [%name = alloca %ty, %n]
2322 instruction at the position specified by the instruction builder [b].
2323 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
2324 val build_array_alloca
: lltype
-> llvalue
-> string -> llbuilder
->
2327 (** [build_load v name b] creates a
2329 instruction at the position specified by the instruction builder [b].
2330 See the method [llvm::LLVMBuilder::CreateLoad]. *)
2331 val build_load
: llvalue
-> string -> llbuilder
-> llvalue
2333 (** [build_store v p b] creates a
2335 instruction at the position specified by the instruction builder [b].
2336 See the method [llvm::LLVMBuilder::CreateStore]. *)
2337 val build_store
: llvalue
-> llvalue
-> llbuilder
-> llvalue
2339 (** [build_atomicrmw op ptr val o st b] creates an [atomicrmw] instruction with
2340 operation [op] performed on pointer [ptr] and value [val] with ordering [o]
2341 and singlethread flag set to [st] at the position specified by
2342 the instruction builder [b].
2343 See the method [llvm::IRBuilder::CreateAtomicRMW]. *)
2344 val build_atomicrmw
: AtomicRMWBinOp.t
-> llvalue
-> llvalue
->
2345 AtomicOrdering.t
-> bool -> string -> llbuilder
-> llvalue
2347 (** [build_gep p indices name b] creates a
2348 [%name = getelementptr %p, indices...]
2349 instruction at the position specified by the instruction builder [b].
2350 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
2351 val build_gep
: llvalue
-> llvalue array
-> string -> llbuilder
-> llvalue
2353 (** [build_in_bounds_gep p indices name b] creates a
2354 [%name = gelementptr inbounds %p, indices...]
2355 instruction at the position specified by the instruction builder [b].
2356 See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
2357 val build_in_bounds_gep
: llvalue
-> llvalue array
-> string -> llbuilder
->
2360 (** [build_struct_gep p idx name b] creates a
2361 [%name = getelementptr %p, 0, idx]
2362 instruction at the position specified by the instruction builder [b].
2363 See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
2364 val build_struct_gep
: llvalue
-> int -> string -> llbuilder
->
2367 (** [build_global_string str name b] creates a series of instructions that adds
2368 a global string at the position specified by the instruction builder [b].
2369 See the method [llvm::LLVMBuilder::CreateGlobalString]. *)
2370 val build_global_string
: string -> string -> llbuilder
-> llvalue
2372 (** [build_global_stringptr str name b] creates a series of instructions that
2373 adds a global string pointer at the position specified by the instruction
2375 See the method [llvm::LLVMBuilder::CreateGlobalStringPtr]. *)
2376 val build_global_stringptr
: string -> string -> llbuilder
-> llvalue
2381 (** [build_trunc v ty name b] creates a
2382 [%name = trunc %p to %ty]
2383 instruction at the position specified by the instruction builder [b].
2384 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
2385 val build_trunc
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2387 (** [build_zext v ty name b] creates a
2388 [%name = zext %p to %ty]
2389 instruction at the position specified by the instruction builder [b].
2390 See the method [llvm::LLVMBuilder::CreateZExt]. *)
2391 val build_zext
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2393 (** [build_sext v ty name b] creates a
2394 [%name = sext %p to %ty]
2395 instruction at the position specified by the instruction builder [b].
2396 See the method [llvm::LLVMBuilder::CreateSExt]. *)
2397 val build_sext
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2399 (** [build_fptoui v ty name b] creates a
2400 [%name = fptoui %p to %ty]
2401 instruction at the position specified by the instruction builder [b].
2402 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
2403 val build_fptoui
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2405 (** [build_fptosi v ty name b] creates a
2406 [%name = fptosi %p to %ty]
2407 instruction at the position specified by the instruction builder [b].
2408 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
2409 val build_fptosi
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2411 (** [build_uitofp v ty name b] creates a
2412 [%name = uitofp %p to %ty]
2413 instruction at the position specified by the instruction builder [b].
2414 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
2415 val build_uitofp
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2417 (** [build_sitofp v ty name b] creates a
2418 [%name = sitofp %p to %ty]
2419 instruction at the position specified by the instruction builder [b].
2420 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
2421 val build_sitofp
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2423 (** [build_fptrunc v ty name b] creates a
2424 [%name = fptrunc %p to %ty]
2425 instruction at the position specified by the instruction builder [b].
2426 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
2427 val build_fptrunc
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2429 (** [build_fpext v ty name b] creates a
2430 [%name = fpext %p to %ty]
2431 instruction at the position specified by the instruction builder [b].
2432 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
2433 val build_fpext
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2435 (** [build_ptrtoint v ty name b] creates a
2436 [%name = prtotint %p to %ty]
2437 instruction at the position specified by the instruction builder [b].
2438 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
2439 val build_ptrtoint
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2441 (** [build_inttoptr v ty name b] creates a
2442 [%name = inttoptr %p to %ty]
2443 instruction at the position specified by the instruction builder [b].
2444 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
2445 val build_inttoptr
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2447 (** [build_bitcast v ty name b] creates a
2448 [%name = bitcast %p to %ty]
2449 instruction at the position specified by the instruction builder [b].
2450 See the method [llvm::LLVMBuilder::CreateBitCast]. *)
2451 val build_bitcast
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2453 (** [build_zext_or_bitcast v ty name b] creates a zext or bitcast
2454 instruction at the position specified by the instruction builder [b].
2455 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2456 val build_zext_or_bitcast
: llvalue
-> lltype
-> string -> llbuilder
->
2459 (** [build_sext_or_bitcast v ty name b] creates a sext or bitcast
2460 instruction at the position specified by the instruction builder [b].
2461 See the method [llvm::LLVMBuilder::CreateSExtOrBitCast]. *)
2462 val build_sext_or_bitcast
: llvalue
-> lltype
-> string -> llbuilder
->
2465 (** [build_trunc_or_bitcast v ty name b] creates a trunc or bitcast
2466 instruction at the position specified by the instruction builder [b].
2467 See the method [llvm::LLVMBuilder::CreateZExtOrBitCast]. *)
2468 val build_trunc_or_bitcast
: llvalue
-> lltype
-> string -> llbuilder
->
2471 (** [build_pointercast v ty name b] creates a bitcast or pointer-to-int
2472 instruction at the position specified by the instruction builder [b].
2473 See the method [llvm::LLVMBuilder::CreatePointerCast]. *)
2474 val build_pointercast
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2476 (** [build_intcast v ty name b] creates a zext, bitcast, or trunc
2477 instruction at the position specified by the instruction builder [b].
2478 See the method [llvm::LLVMBuilder::CreateIntCast]. *)
2479 val build_intcast
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2481 (** [build_fpcast v ty name b] creates a fpext, bitcast, or fptrunc
2482 instruction at the position specified by the instruction builder [b].
2483 See the method [llvm::LLVMBuilder::CreateFPCast]. *)
2484 val build_fpcast
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2487 (** {7 Comparisons} *)
2489 (** [build_icmp pred x y name b] creates a
2490 [%name = icmp %pred %x, %y]
2491 instruction at the position specified by the instruction builder [b].
2492 See the method [llvm::LLVMBuilder::CreateICmp]. *)
2493 val build_icmp
: Icmp.t
-> llvalue
-> llvalue
-> string ->
2494 llbuilder
-> llvalue
2496 (** [build_fcmp pred x y name b] creates a
2497 [%name = fcmp %pred %x, %y]
2498 instruction at the position specified by the instruction builder [b].
2499 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
2500 val build_fcmp
: Fcmp.t
-> llvalue
-> llvalue
-> string ->
2501 llbuilder
-> llvalue
2504 (** {7 Miscellaneous instructions} *)
2506 (** [build_phi incoming name b] creates a
2507 [%name = phi %incoming]
2508 instruction at the position specified by the instruction builder [b].
2509 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
2510 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2511 val build_phi
: (llvalue
* llbasicblock
) list
-> string -> llbuilder
->
2514 (** [build_empty_phi ty name b] creates a
2515 [%name = phi %ty] instruction at the position specified by
2516 the instruction builder [b]. [ty] is the type of the instruction.
2517 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2518 val build_empty_phi
: lltype
-> string -> llbuilder
-> llvalue
2520 (** [build_call fn args name b] creates a
2521 [%name = call %fn(args...)]
2522 instruction at the position specified by the instruction builder [b].
2523 See the method [llvm::LLVMBuilder::CreateCall]. *)
2524 val build_call
: llvalue
-> llvalue array
-> string -> llbuilder
-> llvalue
2526 (** [build_select cond thenv elsev name b] creates a
2527 [%name = select %cond, %thenv, %elsev]
2528 instruction at the position specified by the instruction builder [b].
2529 See the method [llvm::LLVMBuilder::CreateSelect]. *)
2530 val build_select
: llvalue
-> llvalue
-> llvalue
-> string -> llbuilder
->
2533 (** [build_va_arg valist argty name b] creates a
2534 [%name = va_arg %valist, %argty]
2535 instruction at the position specified by the instruction builder [b].
2536 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
2537 val build_va_arg
: llvalue
-> lltype
-> string -> llbuilder
-> llvalue
2539 (** [build_extractelement vec i name b] creates a
2540 [%name = extractelement %vec, %i]
2541 instruction at the position specified by the instruction builder [b].
2542 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
2543 val build_extractelement
: llvalue
-> llvalue
-> string -> llbuilder
->
2546 (** [build_insertelement vec elt i name b] creates a
2547 [%name = insertelement %vec, %elt, %i]
2548 instruction at the position specified by the instruction builder [b].
2549 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
2550 val build_insertelement
: llvalue
-> llvalue
-> llvalue
-> string ->
2551 llbuilder
-> llvalue
2553 (** [build_shufflevector veca vecb mask name b] creates a
2554 [%name = shufflevector %veca, %vecb, %mask]
2555 instruction at the position specified by the instruction builder [b].
2556 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
2557 val build_shufflevector
: llvalue
-> llvalue
-> llvalue
-> string ->
2558 llbuilder
-> llvalue
2560 (** [build_extractvalue agg idx name b] creates a
2561 [%name = extractvalue %agg, %idx]
2562 instruction at the position specified by the instruction builder [b].
2563 See the method [llvm::LLVMBuilder::CreateExtractValue]. *)
2564 val build_extractvalue
: llvalue
-> int -> string -> llbuilder
-> llvalue
2567 (** [build_insertvalue agg val idx name b] creates a
2568 [%name = insertvalue %agg, %val, %idx]
2569 instruction at the position specified by the instruction builder [b].
2570 See the method [llvm::LLVMBuilder::CreateInsertValue]. *)
2571 val build_insertvalue
: llvalue
-> llvalue
-> int -> string -> llbuilder
->
2574 (** [build_is_null val name b] creates a
2575 [%name = icmp eq %val, null]
2576 instruction at the position specified by the instruction builder [b].
2577 See the method [llvm::LLVMBuilder::CreateIsNull]. *)
2578 val build_is_null
: llvalue
-> string -> llbuilder
-> llvalue
2580 (** [build_is_not_null val name b] creates a
2581 [%name = icmp ne %val, null]
2582 instruction at the position specified by the instruction builder [b].
2583 See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
2584 val build_is_not_null
: llvalue
-> string -> llbuilder
-> llvalue
2586 (** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure
2587 the difference between two pointer values at the position specified by the
2588 instruction builder [b].
2589 See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2590 val build_ptrdiff
: llvalue
-> llvalue
-> string -> llbuilder
-> llvalue
2593 (** {6 Memory buffers} *)
2595 module MemoryBuffer
: sig
2596 (** [of_file p] is the memory buffer containing the contents of the file at
2597 path [p]. If the file could not be read, then [IoError msg] is
2599 val of_file
: string -> llmemorybuffer
2601 (** [of_stdin ()] is the memory buffer containing the contents of standard input.
2602 If standard input is empty, then [IoError msg] is raised. *)
2603 val of_stdin
: unit -> llmemorybuffer
2605 (** [of_string ~name s] is the memory buffer containing the contents of string [s].
2606 The name of memory buffer is set to [name] if it is provided. *)
2607 val of_string
: ?name
:string -> string -> llmemorybuffer
2609 (** [as_string mb] is the string containing the contents of memory buffer [mb]. *)
2610 val as_string
: llmemorybuffer
-> string
2612 (** Disposes of a memory buffer. *)
2613 val dispose
: llmemorybuffer
-> unit
2617 (** {6 Pass Managers} *)
2619 module PassManager
: sig
2622 type any
= [ `Module
| `Function
]
2624 (** [PassManager.create ()] constructs a new whole-module pass pipeline. This
2625 type of pipeline is suitable for link-time optimization and whole-module
2627 See the constructor of [llvm::PassManager]. *)
2628 val create
: unit -> [ `Module
] t
2630 (** [PassManager.create_function m] constructs a new function-by-function
2631 pass pipeline over the module [m]. It does not take ownership of [m].
2632 This type of pipeline is suitable for code generation and JIT compilation
2634 See the constructor of [llvm::FunctionPassManager]. *)
2635 val create_function
: llmodule
-> [ `Function
] t
2637 (** [run_module m pm] initializes, executes on the module [m], and finalizes
2638 all of the passes scheduled in the pass manager [pm]. Returns [true] if
2639 any of the passes modified the module, [false] otherwise.
2640 See the [llvm::PassManager::run] method. *)
2641 val run_module
: llmodule
-> [ `Module
] t
-> bool
2643 (** [initialize fpm] initializes all of the function passes scheduled in the
2644 function pass manager [fpm]. Returns [true] if any of the passes modified
2645 the module, [false] otherwise.
2646 See the [llvm::FunctionPassManager::doInitialization] method. *)
2647 val initialize
: [ `Function
] t
-> bool
2649 (** [run_function f fpm] executes all of the function passes scheduled in the
2650 function pass manager [fpm] over the function [f]. Returns [true] if any
2651 of the passes modified [f], [false] otherwise.
2652 See the [llvm::FunctionPassManager::run] method. *)
2653 val run_function
: llvalue
-> [ `Function
] t
-> bool
2655 (** [finalize fpm] finalizes all of the function passes scheduled in the
2656 function pass manager [fpm]. Returns [true] if any of the passes
2657 modified the module, [false] otherwise.
2658 See the [llvm::FunctionPassManager::doFinalization] method. *)
2659 val finalize
: [ `Function
] t
-> bool
2661 (** Frees the memory of a pass pipeline. For function pipelines, does not free
2663 See the destructor of [llvm::BasePassManager]. *)
2664 val dispose
: [< any
] t
-> unit