1 (*===-- tools/ml/llvm.ml - LLVM Ocaml Interface ---------------------------===*
3 * The LLVM Compiler Infrastructure
5 * This file was developed by Gordon Henriksen and is distributed under the
6 * University of Illinois Open Source License. See LICENSE.TXT for details.
8 *===----------------------------------------------------------------------===
10 * This interface provides an ocaml API for the LLVM intermediate
11 * representation, the classes in the VMCore library.
13 *===----------------------------------------------------------------------===*)
16 (* These abstract types correlate directly to the LLVM VMCore classes. *)
18 (** The top-level container for all other LLVM Intermediate Representation (IR)
19 objects. See the [llvm::Module] class. **)
22 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
23 [llvm::Type] class. **)
26 (** When building recursive types using [refine_type], [lltype] values may
27 become invalid; use [lltypehandle] to resolve this problem. See the
28 [llvm::AbstractTypeHolder] 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 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. **)
39 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
43 (** Used to provide a module to JIT or interpreter.
44 See the [llvm::ModuleProvider] class. **)
47 (** Used to efficiently handle large buffers of read-only binary data.
48 See the [llvm::MemoryBuffer] class. **)
51 (** The kind of an [lltype], the result of [classify_type ty]. See the
52 [llvm::Type::TypeID] enumeration. **)
71 (** The linkage of a global value, accessed with [linkage gv] and
72 [set_linkage l gv]. See [llvm::GlobalValue::LinkageTypes]. **)
86 (** The linker visibility of a global value, accessed with [visibility gv] and
87 [set_visibility v gv]. See [llvm::GlobalValue::VisibilityTypes]. **)
88 module Visibility : sig
95 (* The following calling convention values may be accessed with
96 [function_call_conv f] and [set_function_call_conv conv f]. Calling
97 conventions are open-ended. *)
99 val c : int (** [c] is the C calling convention. **)
100 val fast : int (** [fast] is the calling convention to allow LLVM
101 maximum optimization opportunities. Use only with
102 internal linkage. **)
103 val cold : int (** [cold] is the calling convention for
105 val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
106 convention from C. **)
107 val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
108 convention from C. **)
111 (** The predicate for an integer comparison ([icmp]) instruction.
112 See the [llvm::ICmpInst::Predicate] enumeration. **)
127 (** The predicate for a floating-point comparison ([fcmp]) instruction.
128 See the [llvm::FCmpInst::Predicate] enumeration. **)
149 exception IoError of string
152 (*===-- Modules -----------------------------------------------------------===*)
154 (** [create_module id] creates a module with the supplied module ID. Modules are
155 not garbage collected; it is mandatory to call [dispose_module m] to free
156 memory. See the constructor [llvm::Module::Module]. *)
157 external create_module : string -> llmodule = "llvm_create_module"
159 (** [dispose_module m] destroys a module [m] and all of the IR objects it
160 contained. All references to subordinate objects are invalidated;
161 referencing them will invoke undefined behavior. See the destructor
162 [llvm::Module::~Module]. **)
163 external dispose_module : llmodule -> unit = "llvm_dispose_module"
165 (** [target_triple m] is the target specifier for the module [m], something like
166 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. **)
167 external target_triple: llmodule -> string
168 = "llvm_target_triple"
170 (** [target_triple triple m] changes the target specifier for the module [m] to
171 the string [triple]. See the method [llvm::Module::setTargetTriple]. **)
172 external set_target_triple: string -> llmodule -> unit
173 = "llvm_set_target_triple"
175 (** [data_layout m] is the data layout specifier for the module [m], something
176 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
177 method [llvm::Module::getDataLayout]. **)
178 external data_layout: llmodule -> string
181 (** [set_data_layout s m] changes the data layout specifier for the module [m]
182 to the string [s]. See the method [llvm::Module::setDataLayout]. **)
183 external set_data_layout: string -> llmodule -> unit
184 = "llvm_set_data_layout"
186 (** [define_type_name name ty m] adds a named type to the module's symbol table.
187 Returns [true] if successful. If such a name already exists, then no entry
188 is added and [false] is returned. See the [llvm::Module::addTypeName]
190 external define_type_name : string -> lltype -> llmodule -> bool
191 = "llvm_add_type_name"
193 (** [delete_type_name name] removes a type name from the module's symbol
195 external delete_type_name : string -> llmodule -> unit
196 = "llvm_delete_type_name"
199 (*===-- Types -------------------------------------------------------------===*)
201 (** [classify_type ty] returns the [type_kind] corresponding to the type [ty].
202 See the method [llvm::Type::getTypeID]. **)
203 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
205 (** [string_of_lltype ty] returns a string describing the type [ty]. **)
206 val string_of_lltype : lltype -> string
208 (*--... Operations on integer types ........................................--*)
210 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. **)
213 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. **)
216 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. **)
217 val i16_type : lltype
219 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. **)
220 val i32_type : lltype
222 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. **)
223 val i64_type : lltype
225 (** [integer_type n] returns an integer type of bitwidth [n].
226 See the method [llvm::IntegerType::get]. **)
227 external integer_type : int -> lltype = "llvm_integer_type"
229 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty]..
230 See the method [llvm::IntegerType::getBitWidth]. **)
231 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
233 (*--... Operations on real types ...........................................--*)
235 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. **)
236 val float_type : lltype
238 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. **)
239 val double_type : lltype
241 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. **)
242 val x86fp80_type : lltype
244 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. **)
245 val fp128_type : lltype
247 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. **)
248 val ppc_fp128_type : lltype
250 (*--... Operations on function types .......................................--*)
252 (** [function_type ret_ty param_tys] returns the function type returning
253 [ret_ty] and taking [param_tys] as parameters.
254 See the method [llvm::FunctionType::get]. **)
255 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
257 (** [va_arg_function_type ret_ty param_tys] is just like
258 [function_type ret_ty param_tys] except that it returns the function type
259 which also takes a variable number of arguments.
260 See the method [llvm::FunctionType::get]. **)
261 external var_arg_function_type : lltype -> lltype array -> lltype
262 = "llvm_var_arg_function_type"
264 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
265 otherwise. See the method [llvm::FunctionType::isVarArg]. **)
266 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
268 (** [return_type fty] gets the return type of the function type [fty].
269 See the method [llvm::FunctionType::getReturnType]. **)
270 external return_type : lltype -> lltype = "LLVMGetReturnType"
272 (** [param_types fty] gets the parameter types of the function type [fty].
273 See the method [llvm::FunctionType::getParamType]. **)
274 external param_types : lltype -> lltype array = "llvm_param_types"
276 (*--... Operations on struct types .........................................--*)
278 (** [struct_type tys] returns the structure type containing in the types in the
279 array [tys]. See the method [llvm::StructType::get]. **)
280 external struct_type : lltype array -> lltype = "llvm_struct_type"
282 (** [struct_type tys] returns the packed structure type containing in the types
283 in the array [tys]. See the method [llvm::StructType::get]. **)
284 external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
286 (** [element_types sty] returns the constituent types of the struct type [sty].
287 See the method [llvm::StructType::getElementType]. **)
288 external element_types : lltype -> lltype array = "llvm_element_types"
290 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
291 [false] otherwise. See the method [llvm::StructType::isPacked]. **)
292 external is_packed : lltype -> bool = "llvm_is_packed"
294 (*--... Operations on pointer, vector, and array types .....................--*)
296 (** [array_type ty n] returns the array type containing [n] elements of type
297 [ty]. See the method [llvm::ArrayType::get]. **)
298 external array_type : lltype -> int -> lltype = "llvm_array_type"
300 (** [pointer_type ty] returns the pointer type referencing objects of type
301 [ty] in the default address space (0).
302 See the method [llvm::PointerType::getUnqual]. **)
303 external pointer_type : lltype -> lltype = "llvm_pointer_type"
305 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
306 of type [ty] in address space [as].
307 See the method [llvm::PointerType::get]. **)
308 external qualified_pointer_type : lltype -> int -> lltype
309 = "llvm_qualified_pointer_type"
311 (** [vector_type ty n] returns the array type containing [n] elements of the
312 primitive type [ty]. See the method [llvm::ArrayType::get]. **)
313 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
315 (** [element_type ty] returns the element type of the pointer, vector, or array
316 type [ty]. See the method [llvm::SequentialType::get]. **)
317 external element_type : lltype -> lltype = "LLVMGetElementType"
319 (** [element_type aty] returns the element count of the array type [aty].
320 See the method [llvm::ArrayType::getNumElements]. **)
321 external array_length : lltype -> int = "llvm_array_length"
323 (** [address_space pty] returns the address space qualifier of the pointer type
324 [pty]. See the method [llvm::PointerType::getAddressSpace]. **)
325 external address_space : lltype -> int = "llvm_address_space"
327 (** [element_type ty] returns the element count of the vector type [ty].
328 See the method [llvm::VectorType::getNumElements]. **)
329 external vector_size : lltype -> int = "llvm_vector_size"
331 (*--... Operations on other types ..........................................--*)
333 (** [opaque_type ()] creates a new opaque type distinct from any other.
334 Opaque types are useful for building recursive types in combination with
335 [refine_type opaque_ty ty].
336 See [llvm::OpaqueType::get]. **)
337 external opaque_type : unit -> lltype = "llvm_opaque_type"
339 (** [void_type] is the type of a function which does not return any value.
340 See [llvm::Type::VoidTy]. **)
341 val void_type : lltype
343 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. **)
344 val label_type : lltype
346 (*--... Operations on type handles .........................................--*)
348 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
349 refined as a result of a call to [refine_type], the handle will be updated;
350 any bare [lltype] references will become invalid.
351 See the class [llvm::PATypeHolder]. **)
352 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
354 (** [type_of_handle tyh] resolves the type handle [tyh].
355 See the method [llvm::PATypeHolder::get()]. **)
356 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
358 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
359 concrete type [ty] in all users. Warning: This may invalidate [lltype]
360 values! Use [lltypehandle] to manipulate potentially abstract types. See the
361 method [llvm::Type::refineAbstractType]. **)
362 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
365 (*===-- Values ------------------------------------------------------------===*)
367 (** [type_of v] returns the type of the value [v].
368 See the method [llvm::Value::getType]. **)
369 external type_of : llvalue -> lltype = "llvm_type_of"
371 (** [value_name v] returns the name of the value [v]. For global values, this is
372 the symbol name. For instructions and basic blocks, it is the SSA register
373 name. It is meaningless for constants.
374 See the method [llvm::Value::getName]. **)
375 external value_name : llvalue -> string = "llvm_value_name"
377 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
378 [llvm::Value::setName]. **)
379 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
381 (** [dump_value v] prints the .ll representation of the value [v] to standard
382 error. See the method [llvm::Value::dump]. **)
383 external dump_value : llvalue -> unit = "llvm_dump_value"
385 (*--... Operations on constants of (mostly) any type .......................--*)
387 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
388 otherwise. Similar to [llvm::isa<Constant>]. **)
389 external is_constant : llvalue -> bool = "llvm_is_constant"
391 (** [const_null ty] returns the constant null (zero) of the type [ty].
392 See the method [llvm::Constant::getNullValue]. **)
393 external const_null : lltype -> llvalue = "LLVMConstNull"
395 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
396 [ty]. See the method [llvm::Constant::getAllOnesValue]. **)
397 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
399 (** [undef ty] returns the undefined value of the type [ty].
400 See the method [llvm::UndefValue::get]. **)
401 external undef : lltype -> llvalue = "LLVMGetUndef"
403 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
404 See the method [llvm::Constant::isNullValue]. **)
405 external is_null : llvalue -> bool = "llvm_is_null"
407 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
408 otherwise. Similar to [llvm::isa<UndefValue>]. **)
409 external is_undef : llvalue -> bool = "llvm_is_undef"
411 (*--... Operations on scalar constants .....................................--*)
413 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
414 See the method [llvm::ConstantInt::get]. **)
415 external const_int : lltype -> int -> llvalue = "llvm_const_int"
417 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
418 [i]. See the method [llvm::ConstantInt::get]. **)
419 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
420 = "llvm_const_of_int64"
422 (** [const_float ty n] returns the floating point constant of type [ty] and
423 value [n]. See the method [llvm::ConstantInt::get]. **)
424 external const_float : lltype -> float -> llvalue = "llvm_const_float"
426 (*--... Operations on composite constants ..................................--*)
428 (** [const_string s] returns the constant [i8] array with the values of the
429 characters in the string [s]. The array is not null-terminated (but see
430 [const_stringz]). This value can in turn be used as the initializer for a
431 global variable. See the method [llvm::ConstantArray::get]. **)
432 external const_string : string -> llvalue = "llvm_const_string"
434 (** [const_stringz s] returns the constant [i8] array with the values of the
435 characters in the string [s] and a null terminator. This value can in turn
436 be used as the initializer for a global variable.
437 See the method [llvm::ConstantArray::get]. **)
438 external const_stringz : string -> llvalue = "llvm_const_stringz"
440 (** [const_array ty elts] returns the constant array of type
441 [array_type ty (Array.length elts)] and containing the values [elts].
442 This value can in turn be used as the initializer for a global variable.
443 See the method [llvm::ConstantArray::get]. **)
444 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
446 (** [const_struct elts] returns the structured constant of type
447 [struct_type (Array.map type_of elts)] and containing the values [elts].
448 This value can in turn be used as the initializer for a global variable.
449 See the method [llvm::ConstantStruct::get]. **)
450 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
452 (** [const_packed_struct elts] returns the structured constant of type
453 [packed_struct_type (Array.map type_of elts)] and containing the values
454 [elts]. This value can in turn be used as the initializer for a global
455 variable. See the method [llvm::ConstantStruct::get]. **)
456 external const_packed_struct : llvalue array -> llvalue
457 = "llvm_const_packed_struct"
459 (** [const_vector elts] returns the vector constant of type
460 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
461 values [elts]. See the method [llvm::ConstantVector::get]. **)
462 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
464 (*--... Constant expressions ...............................................--*)
466 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
467 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
468 (const_int i64_type 1)) i64_type], but considerably more readable.
469 See the method [llvm::ConstantExpr::getSizeOf]. **)
470 external size_of : lltype -> llvalue = "LLVMSizeOf"
472 (** [const_neg c] returns the arithmetic negation of the constant [c].
473 See the method [llvm::ConstantExpr::getNeg]. **)
474 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
476 (** [const_not c] returns the bitwise inverse of the constant [c].
477 See the method [llvm::ConstantExpr::getNot]. **)
478 external const_not : llvalue -> llvalue = "LLVMConstNot"
480 (** [const_add c1 c2] returns the constant sum of two constants.
481 See the method [llvm::ConstantExpr::getAdd]. **)
482 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
484 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
485 constants. See the method [llvm::ConstantExpr::getSub]. **)
486 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
488 (** [const_mul c1 c2] returns the constant product of two constants.
489 See the method [llvm::ConstantExpr::getMul]. **)
490 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
492 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
494 See the method [llvm::ConstantExpr::getUDiv]. **)
495 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
497 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
499 See the method [llvm::ConstantExpr::]. **)
500 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
502 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
504 See the method [llvm::ConstantExpr::getFDiv]. **)
505 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
507 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
508 unsigned integer constants.
509 See the method [llvm::ConstantExpr::getURem]. **)
510 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
512 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
513 signed integer constants.
514 See the method [llvm::ConstantExpr::getSRem]. **)
515 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
517 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
518 signed floating point constants.
519 See the method [llvm::ConstantExpr::getFRem]. **)
520 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
522 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
524 See the method [llvm::ConstantExpr::getAnd]. **)
525 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
527 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
529 See the method [llvm::ConstantExpr::getOr]. **)
530 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
532 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
534 See the method [llvm::ConstantExpr::getXor]. **)
535 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
537 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
538 constants, [c1 pred c2].
539 See the method [llvm::ConstantExpr::getICmp]. **)
540 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
543 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
544 point constants, [c1 pred c2].
545 See the method [llvm::ConstantExpr::getFCmp]. **)
546 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
549 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
550 constant integer [c2].
551 See the method [llvm::ConstantExpr::getShl]. **)
552 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
554 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
555 constant integer [c2] with zero extension.
556 See the method [llvm::ConstantExpr::getLShr]. **)
557 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
559 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
560 constant integer [c2] with sign extension.
561 See the method [llvm::ConstantExpr::getAShr]. **)
562 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
564 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
565 constant integers indices from the array [indices].
566 See the method [llvm::ConstantExpr::getGetElementPtr]. **)
567 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
569 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
570 to the smaller integer type [ty].
571 See the method [llvm::ConstantExpr::getTrunc]. **)
572 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
574 (** [const_sext c ty] returns the constant sign extension of integer constant
575 [c] to the larger integer type [ty].
576 See the method [llvm::ConstantExpr::getSExt]. **)
577 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
579 (** [const_zext c ty] returns the constant zero extension of integer constant
580 [c] to the larger integer type [ty].
581 See the method [llvm::ConstantExpr::getZExt]. **)
582 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
584 (** [const_fptrunc c ty] returns the constant truncation of floating point
585 constant [c] to the smaller floating point type [ty].
586 See the method [llvm::ConstantExpr::getFPTrunc]. **)
587 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
589 (** [const_fpext c ty] returns the constant extension of floating point constant
590 [c] to the larger floating point type [ty].
591 See the method [llvm::ConstantExpr::getFPExt]. **)
592 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
594 (** [const_uitofp c ty] returns the constant floating point conversion of
595 unsigned integer constant [c] to the floating point type [ty].
596 See the method [llvm::ConstantExpr::getUIToFP]. **)
597 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
599 (** [const_sitofp c ty] returns the constant floating point conversion of
600 signed integer constant [c] to the floating point type [ty].
601 See the method [llvm::ConstantExpr::getSIToFP]. **)
602 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
604 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
605 floating point constant [c] to integer type [ty].
606 See the method [llvm::ConstantExpr::getFPToUI]. **)
607 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
609 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
610 floating point constant [c] to integer type [ty].
611 See the method [llvm::ConstantExpr::getFPToSI]. **)
612 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
614 (** [const_ptrtoint c ty] returns the constant integer conversion of
615 pointer constant [c] to integer type [ty].
616 See the method [llvm::ConstantExpr::getPtrToInt]. **)
617 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
619 (** [const_inttoptr c ty] returns the constant pointer conversion of
620 integer constant [c] to pointer type [ty].
621 See the method [llvm::ConstantExpr::getIntToPtr]. **)
622 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
624 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
625 to type [ty] of equal size.
626 See the method [llvm::ConstantExpr::getBitCast]. **)
627 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
629 (** [const_select cond t f] returns the constant conditional which returns value
630 [t] if the boolean constant [cond] is true and the value [f] otherwise.
631 See the method [llvm::ConstantExpr::getSelect]. **)
632 external const_select : llvalue -> llvalue -> llvalue -> llvalue
635 (** [const_extractelement vec i] returns the constant [i]th element of
636 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
637 the size of the vector.
638 See the method [llvm::ConstantExpr::getExtractElement]. **)
639 external const_extractelement : llvalue -> llvalue -> llvalue
640 = "LLVMConstExtractElement"
642 (** [const_insertelement vec v i] returns the constant vector with the same
643 elements as constant vector [v] but the [i]th element replaced by the
644 constant [v]. [v] must be a constant value with the type of the vector
645 elements. [i] must be a constant [i32] value unsigned less than the size
647 See the method [llvm::ConstantExpr::getInsertElement]. **)
648 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
649 = "LLVMConstInsertElement"
651 (** [const_shufflevector a b mask] returns a constant [shufflevector].
652 See the LLVM Language Reference for details on the [sufflevector]
654 See the method [llvm::ConstantExpr::getShuffleVector]. **)
655 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
656 = "LLVMConstShuffleVector"
658 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
660 (** [is_declaration g] returns [true] if the global value [g] is a declaration
661 only. Returns [false] otherwise.
662 See the method [llvm::GlobalValue::isDeclaration]. **)
663 external is_declaration : llvalue -> bool = "llvm_is_declaration"
665 (** [linkage g] returns the linkage of the global value [g].
666 See the method [llvm::GlobalValue::getLinkage]. **)
667 external linkage : llvalue -> Linkage.t = "llvm_linkage"
669 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
670 See the method [llvm::GlobalValue::setLinkage]. **)
671 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
673 (** [section g] returns the linker section of the global value [g].
674 See the method [llvm::GlobalValue::getSection]. **)
675 external section : llvalue -> string = "llvm_section"
677 (** [set_section s g] sets the linker section of the global value [g] to [s].
678 See the method [llvm::GlobalValue::setSection]. **)
679 external set_section : string -> llvalue -> unit = "llvm_set_section"
681 (** [visibility g] returns the linker visibility of the global value [g].
682 See the method [llvm::GlobalValue::getVisibility]. **)
683 external visibility : llvalue -> Visibility.t = "llvm_visibility"
685 (** [set_visibility v g] sets the linker visibility of the global value [g] to
686 [v]. See the method [llvm::GlobalValue::setVisibility]. **)
687 external set_visibility : Visibility.t -> llvalue -> unit
688 = "llvm_set_visibility"
690 (** [alignment g] returns the required alignment of the global value [g].
691 See the method [llvm::GlobalValue::getAlignment]. **)
692 external alignment : llvalue -> int = "llvm_alignment"
694 (** [set_alignment n g] sets the required alignment of the global value [g] to
695 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. **)
696 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
698 (*--... Operations on global variables .....................................--*)
700 (** [declare_global ty name m] returns a new global variable of type [ty] and
701 with name [name] in module [m]. If such a global variable already exists,
702 it is returned. If the type of the existing global differs, then a bitcast
703 to [ty] is returned. **)
704 external declare_global : lltype -> string -> llmodule -> llvalue
705 = "llvm_declare_global"
707 (** [define_global name init m] returns a new global with name [name] and
708 initializer [init] in module [m]. If the named global already exists, it is
710 See the constructor of [llvm::GlobalVariable]. **)
711 external define_global : string -> llvalue -> llmodule -> llvalue
712 = "llvm_define_global"
714 (** [lookup_global name m] returns [Some g] if a global variable with name
715 [name] exists in module [m]. If no such global exists, returns [None].
716 See the [llvm::GlobalVariable] constructor. **)
717 external lookup_global : string -> llmodule -> llvalue option
718 = "llvm_lookup_global"
720 (** [delete_global gv] destroys the global variable [gv].
721 See the method [llvm::GlobalVariable::eraseFromParent]. **)
722 external delete_global : llvalue -> unit = "llvm_delete_global"
724 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
725 constant. Returns [false] otherwise.
726 See the method [llvm::GlobalVariable::isConstant]. **)
727 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
729 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
730 [c] is [true] and not if [c] is [false].
731 See the method [llvm::GlobalVariable::setConstant]. **)
732 external set_global_constant : bool -> llvalue -> unit
733 = "llvm_set_global_constant"
735 (** [has_initializer gv] returns [true] if the global variable [gv] has an
736 initializer and [false] otherwise.
737 See the method [llvm::GlobalVariable::hasInitializer]. **)
738 external has_initializer : llvalue -> bool = "llvm_has_initializer"
740 (** [global_initializer gv] returns the initializer for the global variable
741 [gv]. See the method [llvm::GlobalVariable::getInitializer]. **)
742 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
744 (** [set_initializer c gv] sets the initializer for the global variable
745 [gv] to the constant [c].
746 See the method [llvm::GlobalVariable::setInitializer]. **)
747 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
749 (** [remove_initializer gv] unsets the initializer for the global variable
751 See the method [llvm::GlobalVariable::setInitializer]. **)
752 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
754 (** [is_thread_local gv] returns [true] if the global variable [gv] is
755 thread-local and [false] otherwise.
756 See the method [llvm::GlobalVariable::isThreadLocal]. **)
757 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
759 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
760 [c] is [true] and not otherwise.
761 See the method [llvm::GlobalVariable::setThreadLocal]. **)
762 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
764 (*--... Operations on functions ............................................--*)
766 (** [declare_function name ty m] returns a new function of type [ty] and
767 with name [name] in module [m]. If such a function already exists,
768 it is returned. If the type of the existing function differs, then a bitcast
769 to [ty] is returned. **)
770 external declare_function : string -> lltype -> llmodule -> llvalue
771 = "llvm_declare_function"
773 (** [define_function name ty m] creates a new function with name [name] and
774 type [ty] in module [m]. If the named function already exists, it is
775 renamed. An entry basic block is created in the function.
776 See the constructor of [llvm::GlobalVariable]. **)
777 external define_function : string -> lltype -> llmodule -> llvalue
778 = "llvm_define_function"
780 (** [lookup_function name m] returns [Some f] if a function with name
781 [name] exists in module [m]. If no such function exists, returns [None].
782 See the method [llvm::Module] constructor. **)
783 external lookup_function : string -> llmodule -> llvalue option
784 = "llvm_lookup_function"
786 (** [delete_function f] destroys the function [f].
787 See the method [llvm::Function::eraseFromParent]. **)
788 external delete_function : llvalue -> unit = "llvm_delete_function"
790 (** [params f] returns the parameters of function [f].
791 See the method [llvm::Function::getArgumentList]. **)
792 external params : llvalue -> llvalue array = "llvm_params"
794 (** [param f n] returns the [n]th parameter of function [f].
795 See the method [llvm::Function::getArgumentList]. **)
796 external param : llvalue -> int -> llvalue = "llvm_param"
798 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
799 See the method [llvm::Function::isIntrinsic]. **)
800 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
802 (** [function_call_conv f] returns the calling convention of the function [f].
803 See the method [llvm::Function::getCallingConv]. **)
804 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
806 (** [set_function_call_conv cc f] sets the calling convention of the function
807 [f] to the calling convention numbered [cc].
808 See the method [llvm::Function::setCallingConv]. **)
809 external set_function_call_conv : int -> llvalue -> unit
810 = "llvm_set_function_call_conv"
812 (** [collector f] returns [Some name] if the function [f] has a garbage
813 collection algorithm specified and [None] otherwise.
814 See the method [llvm::Function::getCollector]. **)
815 external collector : llvalue -> string option = "llvm_collector"
817 (** [set_collector gc f] sets the collection algorithm for the function [f] to
818 [gc]. See the method [llvm::Function::setCollector]. **)
819 external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
821 (*--... Operations on basic blocks .........................................--*)
823 (** [basic_blocks fn] returns the basic blocks of the function [f].
824 See the method [llvm::Function::getBasicBlockList]. **)
825 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
827 (** [entry_block fn] returns the entry basic block of the function [f].
828 See the method [llvm::Function::getEntryBlock]. **)
829 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
831 (** [delete_block bb] deletes the basic block [bb].
832 See the method [llvm::BasicBlock::eraseFromParent]. **)
833 external delete_block : llbasicblock -> unit = "llvm_delete_block"
835 (** [append_block name f] creates a new basic block named [name] at the end of
837 See the constructor of [llvm::BasicBlock]. **)
838 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
840 (** [insert_block name bb] creates a new basic block named [name] before the
842 See the constructor of [llvm::BasicBlock]. **)
843 external insert_block : string -> llbasicblock -> llbasicblock
844 = "llvm_insert_block"
846 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
847 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
849 (** [value_is_block v] returns [true] if the value [v] is a basic block and
851 Similar to [llvm::isa<BasicBlock>]. **)
852 external value_is_block : llvalue -> bool = "llvm_value_is_block"
854 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
855 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
857 (*--... Operations on phi nodes ............................................--*)
859 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
860 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
861 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
862 = "llvm_add_incoming"
864 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
865 See the method [llvm::PHINode::getIncomingValue]. **)
866 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
869 (*===-- Instruction builders ----------------------------------------------===*)
871 (** [builder] creates an instruction builder with no position. It is invalid to
872 use this builder until its position is set with [position_before] or
873 [position_at_end]. See the constructor for [llvm::LLVMBuilder]. **)
874 external builder: unit-> llbuilder
877 (** [builder_before ins] creates an instruction builder positioned before the
878 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
879 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
881 (** [builder_at_end bb] creates an instruction builder positioned at the end of
882 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
883 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
885 (** [position_before ins b] moves the instruction builder [b] to before the
886 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
887 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
889 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
890 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
891 external position_at_end : llbasicblock -> llbuilder -> unit
892 = "llvm_position_at_end"
894 (*--... Terminators ........................................................--*)
896 (** [build_ret_void b] creates a
898 instruction at the position specified by the instruction builder [b].
899 See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
900 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
902 (** [build_ret v b] creates a
904 instruction at the position specified by the instruction builder [b].
905 See the method [llvm::LLVMBuilder::CreateRet]. **)
906 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
908 (** [build_br bb b] creates a
910 instruction at the position specified by the instruction builder [b].
911 See the method [llvm::LLVMBuilder::CreateBr]. **)
912 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
914 (** [build_cond_br cond tbb fbb b] creates a
915 [b %cond, %tbb, %fbb]
916 instruction at the position specified by the instruction builder [b].
917 See the method [llvm::LLVMBuilder::CreateCondBr]. **)
918 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
919 llvalue = "llvm_build_cond_br"
921 (** [build_switch case elsebb b] creates an empty
922 [switch %case, %elsebb]
923 instruction at the position specified by the instruction builder [b].
924 See the method [llvm::LLVMBuilder::CreateSwitch]. **)
925 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
926 = "llvm_build_switch"
928 (** [build_invoke fn args tobb unwindbb name b] creates an
929 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
930 instruction at the position specified by the instruction builder [b].
931 See the method [llvm::LLVMBuilder::CreateInvoke]. **)
932 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
933 llbasicblock -> string -> llbuilder -> llvalue
934 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
936 (** [build_unwind b] creates an
938 instruction at the position specified by the instruction builder [b].
939 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
940 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
942 (** [build_unreachable b] creates an
944 instruction at the position specified by the instruction builder [b].
945 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
946 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
948 (*--... Arithmetic .........................................................--*)
950 (** [build_add x y name b] creates a
952 instruction at the position specified by the instruction builder [b].
953 See the method [llvm::LLVMBuilder::CreateAdd]. **)
954 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
957 (** [build_sub x y name b] creates a
959 instruction at the position specified by the instruction builder [b].
960 See the method [llvm::LLVMBuilder::CreateSub]. **)
961 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
964 (** [build_mul x y name b] creates a
966 instruction at the position specified by the instruction builder [b].
967 See the method [llvm::LLVMBuilder::CreateMul]. **)
968 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
971 (** [build_udiv x y name b] creates a
972 [%name = udiv %x, %y]
973 instruction at the position specified by the instruction builder [b].
974 See the method [llvm::LLVMBuilder::CreateUDiv]. **)
975 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
978 (** [build_sdiv x y name b] creates a
979 [%name = sdiv %x, %y]
980 instruction at the position specified by the instruction builder [b].
981 See the method [llvm::LLVMBuilder::CreateSDiv]. **)
982 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
985 (** [build_fdiv x y name b] creates a
986 [%name = fdiv %x, %y]
987 instruction at the position specified by the instruction builder [b].
988 See the method [llvm::LLVMBuilder::CreateFDiv]. **)
989 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
992 (** [build_urem x y name b] creates a
993 [%name = urem %x, %y]
994 instruction at the position specified by the instruction builder [b].
995 See the method [llvm::LLVMBuilder::CreateURem]. **)
996 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
999 (** [build_SRem x y name b] creates a
1000 [%name = srem %x, %y]
1001 instruction at the position specified by the instruction builder [b].
1002 See the method [llvm::LLVMBuilder::CreateSRem]. **)
1003 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1006 (** [build_frem x y name b] creates a
1007 [%name = frem %x, %y]
1008 instruction at the position specified by the instruction builder [b].
1009 See the method [llvm::LLVMBuilder::CreateFRem]. **)
1010 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
1013 (** [build_shl x y name b] creates a
1014 [%name = shl %x, %y]
1015 instruction at the position specified by the instruction builder [b].
1016 See the method [llvm::LLVMBuilder::CreateShl]. **)
1017 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
1020 (** [build_lshr x y name b] creates a
1021 [%name = lshr %x, %y]
1022 instruction at the position specified by the instruction builder [b].
1023 See the method [llvm::LLVMBuilder::CreateLShr]. **)
1024 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1027 (** [build_ashr x y name b] creates a
1028 [%name = ashr %x, %y]
1029 instruction at the position specified by the instruction builder [b].
1030 See the method [llvm::LLVMBuilder::CreateAShr]. **)
1031 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
1034 (** [build_and x y name b] creates a
1035 [%name = and %x, %y]
1036 instruction at the position specified by the instruction builder [b].
1037 See the method [llvm::LLVMBuilder::CreateAnd]. **)
1038 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
1041 (** [build_or x y name b] creates a
1043 instruction at the position specified by the instruction builder [b].
1044 See the method [llvm::LLVMBuilder::CreateOr]. **)
1045 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1048 (** [build_xor x y name b] creates a
1049 [%name = xor %x, %y]
1050 instruction at the position specified by the instruction builder [b].
1051 See the method [llvm::LLVMBuilder::CreateXor]. **)
1052 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1055 (** [build_neg x name b] creates a
1057 instruction at the position specified by the instruction builder [b].
1058 [-0.0] is used for floating point types to compute the correct sign.
1059 See the method [llvm::LLVMBuilder::CreateNeg]. **)
1060 external build_neg : llvalue -> string -> llbuilder -> llvalue
1063 (** [build_xor x name b] creates a
1064 [%name = xor %x, -1]
1065 instruction at the position specified by the instruction builder [b].
1066 [-1] is the correct "all ones" value for the type of [x].
1067 See the method [llvm::LLVMBuilder::CreateXor]. **)
1068 external build_not : llvalue -> string -> llbuilder -> llvalue
1071 (*--... Memory .............................................................--*)
1073 (** [build_malloc ty name b] creates a
1074 [%name = malloc %ty]
1075 instruction at the position specified by the instruction builder [b].
1076 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1077 external build_malloc : lltype -> string -> llbuilder -> llvalue
1078 = "llvm_build_malloc"
1080 (** [build_array_malloc ty n name b] creates a
1081 [%name = malloc %ty, %n]
1082 instruction at the position specified by the instruction builder [b].
1083 See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1084 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1085 llvalue = "llvm_build_array_malloc"
1087 (** [build_alloca ty name b] creates a
1088 [%name = alloca %ty]
1089 instruction at the position specified by the instruction builder [b].
1090 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1091 external build_alloca : lltype -> string -> llbuilder -> llvalue
1092 = "llvm_build_alloca"
1094 (** [build_array_alloca ty n name b] creates a
1095 [%name = alloca %ty, %n]
1096 instruction at the position specified by the instruction builder [b].
1097 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1098 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1099 llvalue = "llvm_build_array_alloca"
1101 (** [build_free v b] creates a
1103 instruction at the position specified by the instruction builder [b].
1104 See the method [llvm::LLVMBuilder::CreateFree]. **)
1105 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1107 (** [build_load v name b] creates a
1109 instruction at the position specified by the instruction builder [b].
1110 See the method [llvm::LLVMBuilder::CreateLoad]. **)
1111 external build_load : llvalue -> string -> llbuilder -> llvalue
1114 (** [build_store v p b] creates a
1116 instruction at the position specified by the instruction builder [b].
1117 See the method [llvm::LLVMBuilder::CreateStore]. **)
1118 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1119 = "llvm_build_store"
1121 (** [build_store p indices name b] creates a
1122 [%name = gep %p, indices...]
1123 instruction at the position specified by the instruction builder [b].
1124 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1125 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1128 (*--... Casts ..............................................................--*)
1130 (** [build_trunc v ty name b] creates a
1131 [%name = trunc %p to %ty]
1132 instruction at the position specified by the instruction builder [b].
1133 See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1134 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1135 = "llvm_build_trunc"
1137 (** [build_zext v ty name b] creates a
1138 [%name = zext %p to %ty]
1139 instruction at the position specified by the instruction builder [b].
1140 See the method [llvm::LLVMBuilder::CreateZExt]. **)
1141 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1144 (** [build_sext v ty name b] creates a
1145 [%name = sext %p to %ty]
1146 instruction at the position specified by the instruction builder [b].
1147 See the method [llvm::LLVMBuilder::CreateSExt]. **)
1148 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1151 (** [build_fptoui v ty name b] creates a
1152 [%name = fptoui %p to %ty]
1153 instruction at the position specified by the instruction builder [b].
1154 See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1155 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1156 = "llvm_build_fptoui"
1158 (** [build_fptosi v ty name b] creates a
1159 [%name = fptosi %p to %ty]
1160 instruction at the position specified by the instruction builder [b].
1161 See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1162 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1163 = "llvm_build_fptosi"
1165 (** [build_uitofp v ty name b] creates a
1166 [%name = uitofp %p to %ty]
1167 instruction at the position specified by the instruction builder [b].
1168 See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1169 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1170 = "llvm_build_uitofp"
1172 (** [build_sitofp v ty name b] creates a
1173 [%name = sitofp %p to %ty]
1174 instruction at the position specified by the instruction builder [b].
1175 See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1176 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1177 = "llvm_build_sitofp"
1179 (** [build_fptrunc v ty name b] creates a
1180 [%name = fptrunc %p to %ty]
1181 instruction at the position specified by the instruction builder [b].
1182 See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1183 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1184 = "llvm_build_fptrunc"
1186 (** [build_fpext v ty name b] creates a
1187 [%name = fpext %p to %ty]
1188 instruction at the position specified by the instruction builder [b].
1189 See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1190 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1191 = "llvm_build_fpext"
1193 (** [build_ptrtoint v ty name b] creates a
1194 [%name = prtotint %p to %ty]
1195 instruction at the position specified by the instruction builder [b].
1196 See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1197 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1198 = "llvm_build_prttoint"
1200 (** [build_inttoptr v ty name b] creates a
1201 [%name = inttoptr %p to %ty]
1202 instruction at the position specified by the instruction builder [b].
1203 See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1204 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1205 = "llvm_build_inttoptr"
1207 (** [build_bitcast v ty name b] creates a
1208 [%name = bitcast %p to %ty]
1209 instruction at the position specified by the instruction builder [b].
1210 See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1211 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1212 = "llvm_build_bitcast"
1214 (*--... Comparisons ........................................................--*)
1216 (** [build_icmp pred x y name b] creates a
1217 [%name = icmp %pred %x, %y]
1218 instruction at the position specified by the instruction builder [b].
1219 See the method [llvm::LLVMBuilder::CreateICmp]. **)
1220 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
1221 llbuilder -> llvalue = "llvm_build_icmp"
1223 (** [build_fcmp pred x y name b] creates a
1224 [%name = fcmp %pred %x, %y]
1225 instruction at the position specified by the instruction builder [b].
1226 See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1227 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
1228 llbuilder -> llvalue = "llvm_build_fcmp"
1230 (*--... Miscellaneous instructions .........................................--*)
1232 (** [build_phi incoming name b] creates a
1233 [%name = phi %incoming]
1234 instruction at the position specified by the instruction builder [b].
1235 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1236 See the method [llvm::LLVMBuilder::CreatePHI]. **)
1237 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1238 llvalue = "llvm_build_phi"
1240 (** [build_call fn args name b] creates a
1241 [%name = call %fn(args...)]
1242 instruction at the position specified by the instruction builder [b].
1243 See the method [llvm::LLVMBuilder::CreateCall]. **)
1244 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1247 (** [build_select cond thenv elsev name b] creates a
1248 [%name = select %cond, %thenv, %elsev]
1249 instruction at the position specified by the instruction builder [b].
1250 See the method [llvm::LLVMBuilder::CreateSelect]. **)
1251 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1252 llvalue = "llvm_build_select"
1254 (** [build_va_arg valist argty name b] creates a
1255 [%name = va_arg %valist, %argty]
1256 instruction at the position specified by the instruction builder [b].
1257 See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1258 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1259 = "llvm_build_va_arg"
1261 (** [build_extractelement vec i name b] creates a
1262 [%name = extractelement %vec, %i]
1263 instruction at the position specified by the instruction builder [b].
1264 See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1265 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1266 llvalue = "llvm_build_extractelement"
1268 (** [build_insertelement vec elt i name b] creates a
1269 [%name = insertelement %vec, %elt, %i]
1270 instruction at the position specified by the instruction builder [b].
1271 See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1272 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1273 llbuilder -> llvalue = "llvm_build_insertelement"
1275 (** [build_shufflevector veca vecb mask name b] creates a
1276 [%name = shufflevector %veca, %vecb, %mask]
1277 instruction at the position specified by the instruction builder [b].
1278 See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1279 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1280 llbuilder -> llvalue = "llvm_build_shufflevector"
1283 (*===-- Module providers --------------------------------------------------===*)
1285 module ModuleProvider : sig
1286 (** [create_module_provider m] encapsulates [m] in a module provider and takes
1287 ownership of the module. See the constructor
1288 [llvm::ExistingModuleProvider::ExistingModuleProvider]. **)
1289 external create : llmodule -> llmoduleprovider
1290 = "LLVMCreateModuleProviderForExistingModule"
1292 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
1293 the contained module. **)
1294 external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider"
1298 (*===-- Memory buffers ----------------------------------------------------===*)
1300 module MemoryBuffer : sig
1301 (** [of_file p] is the memory buffer containing the contents of the file at
1302 path [p]. If the file could not be read, then [IoError msg] is raised. **)
1303 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
1305 (** [stdin ()] is the memory buffer containing the contents of standard input.
1306 If standard input is empty, then [IoError msg] is raised. **)
1307 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
1309 (** Disposes of a memory buffer. **)
1310 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"