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. **)
46 (** The kind of an [lltype], the result of [classify_type ty]. See the
47 [llvm::Type::TypeID] enumeration. **)
64 (** The linkage of a global value, accessed with [linkage gv] and
65 [set_linkage l gv]. See [llvm::GlobalValue::LinkageTypes]. **)
74 | External_weak_linkage
77 (** The linker visibility of a global value, accessed with [visibility gv] and
78 [set_visibility v gv]. See [llvm::GlobalValue::VisibilityTypes]. **)
82 | Protected_visibility
84 (* The following calling convention values may be accessed with
85 [function_call_conv f] and [set_function_call_conv conv f]. Calling
86 conventions are open-ended. *)
87 val ccc : int (** [ccc] is the C calling convention. **)
88 val fastcc : int (** [fastcc] is the calling convention to allow LLVM
89 maximum optimization opportunities. Use only with
91 val coldcc : int (** [coldcc] is the calling convention for
93 val x86_stdcallcc : int (** [x86_stdcallcc] is the familiar stdcall calling
94 convention from C. **)
95 val x86_fastcallcc : int (** [x86_fastcallcc] is the familiar fastcall calling
96 convention from C. **)
98 (** The predicate for an integer comparison ([icmp]) instruction.
99 See the [llvm::ICmpInst::Predicate] enumeration. **)
112 (** The predicate for a floating-point comparison ([fcmp]) instruction.
113 See the [llvm::FCmpInst::Predicate] enumeration. **)
114 type real_predicate =
133 (*===-- Modules -----------------------------------------------------------===*)
135 (** [create_module id] creates a module with the supplied module ID. Modules are
136 not garbage collected; it is mandatory to call [dispose_module m] to free
137 memory. See the constructor [llvm::Module::Module]. *)
138 external create_module : string -> llmodule = "llvm_create_module"
140 (** [dispose_module m] destroys a module [m] and all of the IR objects it
141 contained. All references to subordinate objects are invalidated;
142 referencing them will invoke undefined behavior. See the destructor
143 [llvm::Module::~Module]. **)
144 external dispose_module : llmodule -> unit = "llvm_dispose_module"
146 (** [define_type_name name ty m] adds a named type to the module's symbol table.
147 Returns [true] if successful. If such a name already exists, then no entry
148 is added and [false] is returned. See the [llvm::Module::addTypeName]
150 external define_type_name : string -> lltype -> llmodule -> bool
151 = "llvm_add_type_name"
153 (** [delete_type_name name] removes a type name from the module's symbol
155 external delete_type_name : string -> llmodule -> unit
156 = "llvm_delete_type_name"
159 (*===-- Types -------------------------------------------------------------===*)
161 (** [classify_type ty] returns the [type_kind] corresponding to the type [ty].
162 See the method [llvm::Type::getTypeID]. **)
163 external classify_type : lltype -> type_kind = "llvm_classify_type"
165 (** [string_of_lltype ty] returns a string describing the type [ty]. **)
166 val string_of_lltype : lltype -> string
168 (*--... Operations on integer types ........................................--*)
170 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. **)
173 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. **)
176 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. **)
177 val i16_type : lltype
179 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. **)
180 val i32_type : lltype
182 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. **)
183 val i64_type : lltype
185 (** [integer_type n] returns an integer type of bitwidth [n].
186 See the method [llvm::IntegerType::get]. **)
187 external integer_type : int -> lltype = "llvm_integer_type"
189 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty]..
190 See the method [llvm::IntegerType::getBitWidth]. **)
191 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
193 (*--... Operations on real types ...........................................--*)
195 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. **)
196 val float_type : lltype
198 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. **)
199 val double_type : lltype
201 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. **)
202 val x86fp80_type : lltype
204 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. **)
205 val fp128_type : lltype
207 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. **)
208 val ppc_fp128_type : lltype
210 (*--... Operations on function types .......................................--*)
212 (** [function_type ret_ty param_tys] returns the function type returning
213 [ret_ty] and taking [param_tys] as parameters.
214 See the method [llvm::FunctionType::get]. **)
215 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
217 (** [va_arg_function_type ret_ty param_tys] is just like
218 [function_type ret_ty param_tys] except that it returns the function type
219 which also takes a variable number of arguments.
220 See the method [llvm::FunctionType::get]. **)
221 external var_arg_function_type : lltype -> lltype array -> lltype
222 = "llvm_var_arg_function_type"
224 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
225 otherwise. See the method [llvm::FunctionType::isVarArg]. **)
226 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
228 (** [return_type fty] gets the return type of the function type [fty].
229 See the method [llvm::FunctionType::getReturnType]. **)
230 external return_type : lltype -> lltype = "LLVMGetReturnType"
232 (** [param_types fty] gets the parameter types of the function type [fty].
233 See the method [llvm::FunctionType::getParamType]. **)
234 external param_types : lltype -> lltype array = "llvm_param_types"
236 (*--... Operations on struct types .........................................--*)
238 (** [struct_type tys] returns the structure type containing in the types in the
239 array [tys]. See the method [llvm::StructType::get]. **)
240 external struct_type : lltype array -> lltype = "llvm_struct_type"
242 (** [struct_type tys] returns the packed structure type containing in the types
243 in the array [tys]. See the method [llvm::StructType::get]. **)
244 external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
246 (** [element_types sty] returns the constituent types of the struct type [sty].
247 See the method [llvm::StructType::getElementType]. **)
248 external element_types : lltype -> lltype array = "llvm_element_types"
250 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
251 [false] otherwise. See the method [llvm::StructType::isPacked]. **)
252 external is_packed : lltype -> bool = "llvm_is_packed"
254 (*--... Operations on pointer, vector, and array types .....................--*)
256 (** [array_type ty n] returns the array type containing [n] elements of type
257 [ty]. See the method [llvm::ArrayType::get]. **)
258 external array_type : lltype -> int -> lltype = "llvm_array_type"
260 (** [pointer_type ty] returns the pointer type referencing objects of type
261 [ty] in the default address space (0).
262 See the method [llvm::PointerType::getUnqual]. **)
263 external pointer_type : lltype -> lltype = "llvm_pointer_type"
265 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
266 of type [ty] in address space [as].
267 See the method [llvm::PointerType::get]. **)
268 external qualified_pointer_type : lltype -> int -> lltype
269 = "llvm_qualified_pointer_type"
271 (** [vector_type ty n] returns the array type containing [n] elements of the
272 primitive type [ty]. See the method [llvm::ArrayType::get]. **)
273 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
275 (** [element_type ty] returns the element type of the pointer, vector, or array
276 type [ty]. See the method [llvm::SequentialType::get]. **)
277 external element_type : lltype -> lltype = "LLVMGetElementType"
279 (** [element_type aty] returns the element count of the array type [aty].
280 See the method [llvm::ArrayType::getNumElements]. **)
281 external array_length : lltype -> int = "llvm_array_length"
283 (** [address_space pty] returns the address space qualifier of the pointer type
284 [pty]. See the method [llvm::PointerType::getAddressSpace]. **)
285 external address_space : lltype -> int = "llvm_address_space"
287 (** [element_type ty] returns the element count of the vector type [ty].
288 See the method [llvm::VectorType::getNumElements]. **)
289 external vector_size : lltype -> int = "llvm_vector_size"
291 (*--... Operations on other types ..........................................--*)
293 (** [opaque_type ()] creates a new opaque type distinct from any other.
294 Opaque types are useful for building recursive types in combination with
295 [refine_type opaque_ty ty].
296 See [llvm::OpaqueType::get]. **)
297 external opaque_type : unit -> lltype = "llvm_opaque_type"
299 (** [void_type] is the type of a function which does not return any value.
300 See [llvm::Type::VoidTy]. **)
301 val void_type : lltype
303 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. **)
304 val label_type : lltype
306 (*--... Operations on type handles .........................................--*)
308 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
309 refined as a result of a call to [refine_type], the handle will be updated;
310 any bare [lltype] references will become invalid.
311 See the class [llvm::PATypeHolder]. **)
312 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
314 (** [type_of_handle tyh] resolves the type handle [tyh].
315 See the method [llvm::PATypeHolder::get()]. **)
316 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
318 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
319 concrete type [ty] in all users. Warning: This may invalidate [lltype]
320 values! Use [lltypehandle] to manipulate potentially abstract types. See the
321 method [llvm::Type::refineAbstractType]. **)
322 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
325 (*===-- Values ------------------------------------------------------------===*)
327 (** [type_of v] returns the type of the value [v].
328 See the method [llvm::Value::getType]. **)
329 external type_of : llvalue -> lltype = "llvm_type_of"
331 (** [value_name v] returns the name of the value [v]. For global values, this is
332 the symbol name. For instructions and basic blocks, it is the SSA register
333 name. It is meaningless for constants.
334 See the method [llvm::Value::getName]. **)
335 external value_name : llvalue -> string = "llvm_value_name"
337 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
338 [llvm::Value::setName]. **)
339 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
341 (** [dump_value v] prints the .ll representation of the value [v] to standard
342 error. See the method [llvm::Value::dump]. **)
343 external dump_value : llvalue -> unit = "llvm_dump_value"
345 (*--... Operations on constants of (mostly) any type .......................--*)
347 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
348 otherwise. Similar to [llvm::isa<Constant>]. **)
349 external is_constant : llvalue -> bool = "llvm_is_constant"
351 (** [const_null ty] returns the constant null (zero) of the type [ty].
352 See the method [llvm::Constant::getNullValue]. **)
353 external const_null : lltype -> llvalue = "LLVMConstNull"
355 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
356 [ty]. See the method [llvm::Constant::getAllOnesValue]. **)
357 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
359 (** [undef ty] returns the undefined value of the type [ty].
360 See the method [llvm::UndefValue::get]. **)
361 external undef : lltype -> llvalue = "LLVMGetUndef"
363 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
364 See the method [llvm::Constant::isNullValue]. **)
365 external is_null : llvalue -> bool = "llvm_is_null"
367 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
368 otherwise. Similar to [llvm::isa<UndefValue>]. **)
369 external is_undef : llvalue -> bool = "llvm_is_undef"
371 (*--... Operations on scalar constants .....................................--*)
373 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
374 See the method [llvm::ConstantInt::get]. **)
375 external const_int : lltype -> int -> llvalue = "llvm_const_int"
377 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
378 [i]. See the method [llvm::ConstantInt::get]. **)
379 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
380 = "llvm_const_of_int64"
382 (** [const_float ty n] returns the floating point constant of type [ty] and
383 value [n]. See the method [llvm::ConstantInt::get]. **)
384 external const_float : lltype -> float -> llvalue = "llvm_const_float"
386 (*--... Operations on composite constants ..................................--*)
388 (** [const_string s] returns the constant [i8] array with the values of the
389 characters in the string [s]. The array is not null-terminated (but see
390 [const_stringz]). This value can in turn be used as the initializer for a
391 global variable. See the method [llvm::ConstantArray::get]. **)
392 external const_string : string -> llvalue = "llvm_const_string"
394 (** [const_stringz s] returns the constant [i8] array with the values of the
395 characters in the string [s] and a null terminator. This value can in turn
396 be used as the initializer for a global variable.
397 See the method [llvm::ConstantArray::get]. **)
398 external const_stringz : string -> llvalue = "llvm_const_stringz"
400 (** [const_array ty elts] returns the constant array of type
401 [array_type ty (Array.length elts)] and containing the values [elts].
402 This value can in turn be used as the initializer for a global variable.
403 See the method [llvm::ConstantArray::get]. **)
404 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
406 (** [const_struct elts] returns the structured constant of type
407 [struct_type (Array.map type_of elts)] and containing the values [elts].
408 This value can in turn be used as the initializer for a global variable.
409 See the method [llvm::ConstantStruct::get]. **)
410 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
412 (** [const_packed_struct elts] returns the structured constant of type
413 [packed_struct_type (Array.map type_of elts)] and containing the values
414 [elts]. This value can in turn be used as the initializer for a global
415 variable. See the method [llvm::ConstantStruct::get]. **)
416 external const_packed_struct : llvalue array -> llvalue
417 = "llvm_const_packed_struct"
419 (** [const_vector elts] returns the vector constant of type
420 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
421 values [elts]. See the method [llvm::ConstantVector::get]. **)
422 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
424 (*--... Constant expressions ...............................................--*)
426 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
427 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
428 (const_int i64_type 1)) i64_type], but considerably more readable.
429 See the method [llvm::ConstantExpr::getSizeOf]. **)
430 external size_of : lltype -> llvalue = "LLVMSizeOf"
432 (** [const_neg c] returns the arithmetic negation of the constant [c].
433 See the method [llvm::ConstantExpr::getNeg]. **)
434 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
436 (** [const_not c] returns the bitwise inverse of the constant [c].
437 See the method [llvm::ConstantExpr::getNot]. **)
438 external const_not : llvalue -> llvalue = "LLVMConstNot"
440 (** [const_add c1 c2] returns the constant sum of two constants.
441 See the method [llvm::ConstantExpr::getAdd]. **)
442 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
444 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
445 constants. See the method [llvm::ConstantExpr::getSub]. **)
446 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
448 (** [const_mul c1 c2] returns the constant product of two constants.
449 See the method [llvm::ConstantExpr::getMul]. **)
450 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
452 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
454 See the method [llvm::ConstantExpr::getUDiv]. **)
455 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
457 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
459 See the method [llvm::ConstantExpr::]. **)
460 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
462 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
464 See the method [llvm::ConstantExpr::getFDiv]. **)
465 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
467 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
468 unsigned integer constants.
469 See the method [llvm::ConstantExpr::getURem]. **)
470 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
472 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
473 signed integer constants.
474 See the method [llvm::ConstantExpr::getSRem]. **)
475 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
477 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
478 signed floating point constants.
479 See the method [llvm::ConstantExpr::getFRem]. **)
480 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
482 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
484 See the method [llvm::ConstantExpr::getAnd]. **)
485 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
487 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
489 See the method [llvm::ConstantExpr::getOr]. **)
490 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
492 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
494 See the method [llvm::ConstantExpr::getXor]. **)
495 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
497 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
498 constants, [c1 pred c2].
499 See the method [llvm::ConstantExpr::getICmp]. **)
500 external const_icmp : int_predicate -> llvalue -> llvalue -> llvalue
503 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
504 point constants, [c1 pred c2].
505 See the method [llvm::ConstantExpr::getFCmp]. **)
506 external const_fcmp : real_predicate -> llvalue -> llvalue -> llvalue
509 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
510 constant integer [c2].
511 See the method [llvm::ConstantExpr::getShl]. **)
512 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
514 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
515 constant integer [c2] with zero extension.
516 See the method [llvm::ConstantExpr::getLShr]. **)
517 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
519 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
520 constant integer [c2] with sign extension.
521 See the method [llvm::ConstantExpr::getAShr]. **)
522 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
524 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
525 constant integers indices from the array [indices].
526 See the method [llvm::ConstantExpr::getGetElementPtr]. **)
527 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
529 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
530 to the smaller integer type [ty].
531 See the method [llvm::ConstantExpr::getTrunc]. **)
532 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
534 (** [const_sext c ty] returns the constant sign extension of integer constant
535 [c] to the larger integer type [ty].
536 See the method [llvm::ConstantExpr::getSExt]. **)
537 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
539 (** [const_zext c ty] returns the constant zero extension of integer constant
540 [c] to the larger integer type [ty].
541 See the method [llvm::ConstantExpr::getZExt]. **)
542 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
544 (** [const_fptrunc c ty] returns the constant truncation of floating point
545 constant [c] to the smaller floating point type [ty].
546 See the method [llvm::ConstantExpr::getFPTrunc]. **)
547 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
549 (** [const_fpext c ty] returns the constant extension of floating point constant
550 [c] to the larger floating point type [ty].
551 See the method [llvm::ConstantExpr::getFPExt]. **)
552 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
554 (** [const_uitofp c ty] returns the constant floating point conversion of
555 unsigned integer constant [c] to the floating point type [ty].
556 See the method [llvm::ConstantExpr::getUIToFP]. **)
557 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
559 (** [const_sitofp c ty] returns the constant floating point conversion of
560 signed integer constant [c] to the floating point type [ty].
561 See the method [llvm::ConstantExpr::getSIToFP]. **)
562 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
564 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
565 floating point constant [c] to integer type [ty].
566 See the method [llvm::ConstantExpr::getFPToUI]. **)
567 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
569 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
570 floating point constant [c] to integer type [ty].
571 See the method [llvm::ConstantExpr::getFPToSI]. **)
572 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
574 (** [const_ptrtoint c ty] returns the constant integer conversion of
575 pointer constant [c] to integer type [ty].
576 See the method [llvm::ConstantExpr::getPtrToInt]. **)
577 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
579 (** [const_inttoptr c ty] returns the constant pointer conversion of
580 integer constant [c] to pointer type [ty].
581 See the method [llvm::ConstantExpr::getIntToPtr]. **)
582 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
584 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
585 to type [ty] of equal size.
586 See the method [llvm::ConstantExpr::getBitCast]. **)
587 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
589 (** [const_select cond t f] returns the constant conditional which returns value
590 [t] if the boolean constant [cond] is true and the value [f] otherwise.
591 See the method [llvm::ConstantExpr::getSelect]. **)
592 external const_select : llvalue -> llvalue -> llvalue -> llvalue
595 (** [const_extractelement vec i] returns the constant [i]th element of
596 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
597 the size of the vector.
598 See the method [llvm::ConstantExpr::getExtractElement]. **)
599 external const_extractelement : llvalue -> llvalue -> llvalue
600 = "LLVMConstExtractElement"
602 (** [const_insertelement vec v i] returns the constant vector with the same
603 elements as constant vector [v] but the [i]th element replaced by the
604 constant [v]. [v] must be a constant value with the type of the vector
605 elements. [i] must be a constant [i32] value unsigned less than the size
607 See the method [llvm::ConstantExpr::getInsertElement]. **)
608 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
609 = "LLVMConstInsertElement"
611 (** [const_shufflevector a b mask] returns a constant [shufflevector].
612 See the LLVM Language Reference for details on the [sufflevector]
614 See the method [llvm::ConstantExpr::getShuffleVector]. **)
615 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
616 = "LLVMConstShuffleVector"
618 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
620 (** [is_declaration g] returns [true] if the global value [g] is a declaration
621 only. Returns [false] otherwise.
622 See the method [llvm::GlobalValue::isDeclaration]. **)
623 external is_declaration : llvalue -> bool = "llvm_is_declaration"
625 (** [linkage g] returns the linkage of the global value [g].
626 See the method [llvm::GlobalValue::getLinkage]. **)
627 external linkage : llvalue -> linkage = "llvm_linkage"
629 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
630 See the method [llvm::GlobalValue::setLinkage]. **)
631 external set_linkage : linkage -> llvalue -> unit = "llvm_set_linkage"
633 (** [section g] returns the linker section of the global value [g].
634 See the method [llvm::GlobalValue::getSection]. **)
635 external section : llvalue -> string = "llvm_section"
637 (** [set_section s g] sets the linker section of the global value [g] to [s].
638 See the method [llvm::GlobalValue::setSection]. **)
639 external set_section : string -> llvalue -> unit = "llvm_set_section"
641 (** [visibility g] returns the linker visibility of the global value [g].
642 See the method [llvm::GlobalValue::getVisibility]. **)
643 external visibility : llvalue -> visibility = "llvm_visibility"
645 (** [set_visibility v g] sets the linker visibility of the global value [g] to
646 [v]. See the method [llvm::GlobalValue::setVisibility]. **)
647 external set_visibility : visibility -> llvalue -> unit = "llvm_set_visibility"
649 (** [alignment g] returns the required alignment of the global value [g].
650 See the method [llvm::GlobalValue::getAlignment]. **)
651 external alignment : llvalue -> int = "llvm_alignment"
653 (** [set_alignment n g] sets the required alignment of the global value [g] to
654 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. **)
655 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
657 (*--... Operations on global variables .....................................--*)
659 (** [declare_global ty name m] returns a new global variable of type [ty] and
660 with name [name] in module [m]. If such a global variable already exists,
661 it is returned. If the type of the existing global differs, then a bitcast
662 to [ty] is returned. **)
663 external declare_global : lltype -> string -> llmodule -> llvalue
664 = "llvm_declare_global"
666 (** [define_global name init m] returns a new global with name [name] and
667 initializer [init] in module [m]. If the named global already exists, it is
669 See the constructor of [llvm::GlobalVariable]. **)
670 external define_global : string -> llvalue -> llmodule -> llvalue
671 = "llvm_define_global"
673 (** [lookup_global name m] returns [Some g] if a global variable with name
674 [name] exists in module [m]. If no such global exists, returns [None].
675 See the [llvm::GlobalVariable] constructor. **)
676 external lookup_global : string -> llmodule -> llvalue option
677 = "llvm_lookup_global"
679 (** [delete_global gv] destroys the global variable [gv].
680 See the method [llvm::GlobalVariable::eraseFromParent]. **)
681 external delete_global : llvalue -> unit = "llvm_delete_global"
683 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
684 constant. Returns [false] otherwise.
685 See the method [llvm::GlobalVariable::isConstant]. **)
686 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
688 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
689 [c] is [true] and not if [c] is [false].
690 See the method [llvm::GlobalVariable::setConstant]. **)
691 external set_global_constant : bool -> llvalue -> unit
692 = "llvm_set_global_constant"
694 (** [has_initializer gv] returns [true] if the global variable [gv] has an
695 initializer and [false] otherwise.
696 See the method [llvm::GlobalVariable::hasInitializer]. **)
697 external has_initializer : llvalue -> bool = "llvm_has_initializer"
699 (** [global_initializer gv] returns the initializer for the global variable
700 [gv]. See the method [llvm::GlobalVariable::getInitializer]. **)
701 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
703 (** [set_initializer c gv] sets the initializer for the global variable
704 [gv] to the constant [c].
705 See the method [llvm::GlobalVariable::setInitializer]. **)
706 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
708 (** [remove_initializer gv] unsets the initializer for the global variable
710 See the method [llvm::GlobalVariable::setInitializer]. **)
711 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
713 (** [is_thread_local gv] returns [true] if the global variable [gv] is
714 thread-local and [false] otherwise.
715 See the method [llvm::GlobalVariable::isThreadLocal]. **)
716 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
718 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
719 [c] is [true] and not otherwise.
720 See the method [llvm::GlobalVariable::setThreadLocal]. **)
721 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
723 (*--... Operations on functions ............................................--*)
725 (** [declare_function name ty m] returns a new function of type [ty] and
726 with name [name] in module [m]. If such a function already exists,
727 it is returned. If the type of the existing function differs, then a bitcast
728 to [ty] is returned. **)
729 external declare_function : string -> lltype -> llmodule -> llvalue
730 = "llvm_declare_function"
732 (** [define_function name ty m] creates a new function with name [name] and
733 type [ty] in module [m]. If the named function already exists, it is
734 renamed. An entry basic block is created in the function.
735 See the constructor of [llvm::GlobalVariable]. **)
736 external define_function : string -> lltype -> llmodule -> llvalue
737 = "llvm_define_function"
739 (** [lookup_function name m] returns [Some f] if a function with name
740 [name] exists in module [m]. If no such function exists, returns [None].
741 See the method [llvm::Module] constructor. **)
742 external lookup_function : string -> llmodule -> llvalue option
743 = "llvm_lookup_function"
745 (** [delete_function f] destroys the function [f].
746 See the method [llvm::Function::eraseFromParent]. **)
747 external delete_function : llvalue -> unit = "llvm_delete_function"
749 (** [params f] returns the parameters of function [f].
750 See the method [llvm::Function::getArgumentList]. **)
751 external params : llvalue -> llvalue array = "llvm_params"
753 (** [param f n] returns the [n]th parameter of function [f].
754 See the method [llvm::Function::getArgumentList]. **)
755 external param : llvalue -> int -> llvalue = "llvm_param"
757 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
758 See the method [llvm::Function::isIntrinsic]. **)
759 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
761 (** [function_call_conv f] returns the calling convention of the function [f].
762 See the method [llvm::Function::getCallingConv]. **)
763 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
765 (** [set_function_call_conv cc f] sets the calling convention of the function
766 [f] to the calling convention numbered [cc].
767 See the method [llvm::Function::setCallingConv]. **)
768 external set_function_call_conv : int -> llvalue -> unit
769 = "llvm_set_function_call_conv"
771 (** [collector f] returns [Some name] if the function [f] has a garbage
772 collection algorithm specified and [None] otherwise.
773 See the method [llvm::Function::getCollector]. **)
774 external collector : llvalue -> string option = "llvm_collector"
776 (** [set_collector gc f] sets the collection algorithm for the function [f] to
777 [gc]. See the method [llvm::Function::setCollector]. **)
778 external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
780 (*--... Operations on basic blocks .........................................--*)
782 (** [basic_blocks fn] returns the basic blocks of the function [f].
783 See the method [llvm::Function::getBasicBlockList]. **)
784 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
786 (** [entry_block fn] returns the entry basic block of the function [f].
787 See the method [llvm::Function::getEntryBlock]. **)
788 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
790 (** [delete_block bb] deletes the basic block [bb].
791 See the method [llvm::BasicBlock::eraseFromParent]. **)
792 external delete_block : llbasicblock -> unit = "llvm_delete_block"
794 (** [append_block name f] creates a new basic block named [name] at the end of
796 See the constructor of [llvm::BasicBlock]. **)
797 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
799 (** [insert_block name bb] creates a new basic block named [name] before the
801 See the constructor of [llvm::BasicBlock]. **)
802 external insert_block : string -> llbasicblock -> llbasicblock
803 = "llvm_insert_block"
805 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
806 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
808 (** [value_is_block v] returns [true] if the value [v] is a basic block and
810 Similar to [llvm::isa<BasicBlock>]. **)
811 external value_is_block : llvalue -> bool = "llvm_value_is_block"
813 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
814 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
816 (*--... Operations on phi nodes ............................................--*)
818 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
819 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
820 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
821 = "llvm_add_incoming"
823 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
824 See the method [llvm::PHINode::getIncomingValue]. **)
825 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
828 (*===-- Instruction builders ----------------------------------------------===*)
830 (** [builder_before ins] creates an instruction builder positioned before the
831 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
832 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
834 (** [builder_at_end bb] creates an instruction builder positioned at the end of
835 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
836 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
838 (** [position_before ins b] moves the instruction builder [b] to before the
839 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
840 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
842 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
843 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
844 external position_at_end : llbasicblock -> llbuilder -> unit
845 = "llvm_position_at_end"
847 (*--... Terminators ........................................................--*)
849 (** [build_ret_void b] creates a
851 instruction at the position specified by the instruction builder [b].
852 See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
853 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
855 (** [build_ret v b] creates a
857 instruction at the position specified by the instruction builder [b].
858 See the method [llvm::LLVMBuilder::CreateRet]. **)
859 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
861 (** [build_br bb b] creates a
863 instruction at the position specified by the instruction builder [b].
864 See the method [llvm::LLVMBuilder::CreateBr]. **)
865 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
867 (** [build_cond_br cond tbb fbb b] creates a
868 [b %cond, %tbb, %fbb]
869 instruction at the position specified by the instruction builder [b].
870 See the method [llvm::LLVMBuilder::CreateCondBr]. **)
871 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
872 llvalue = "llvm_build_cond_br"
874 (** [build_switch case elsebb b] creates an empty
875 [switch %case, %elsebb]
876 instruction at the position specified by the instruction builder [b].
877 See the method [llvm::LLVMBuilder::CreateSwitch]. **)
878 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
879 = "llvm_build_switch"
881 (** [build_invoke fn args tobb unwindbb name b] creates an
882 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
883 instruction at the position specified by the instruction builder [b].
884 See the method [llvm::LLVMBuilder::CreateInvoke]. **)
885 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
886 llbasicblock -> string -> llbuilder -> llvalue
887 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
889 (** [build_unwind b] creates an
891 instruction at the position specified by the instruction builder [b].
892 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
893 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
895 (** [build_unreachable b] creates an
897 instruction at the position specified by the instruction builder [b].
898 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
899 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
901 (*--... Arithmetic .........................................................--*)
903 (** [build_add x y name b] creates a
905 instruction at the position specified by the instruction builder [b].
906 See the method [llvm::LLVMBuilder::CreateAdd]. **)
907 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
910 (** [build_sub x y name b] creates a
912 instruction at the position specified by the instruction builder [b].
913 See the method [llvm::LLVMBuilder::CreateSub]. **)
914 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
917 (** [build_mul x y name b] creates a
919 instruction at the position specified by the instruction builder [b].
920 See the method [llvm::LLVMBuilder::CreateMul]. **)
921 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
924 (** [build_udiv x y name b] creates a
925 [%name = udiv %x, %y]
926 instruction at the position specified by the instruction builder [b].
927 See the method [llvm::LLVMBuilder::CreateUDiv]. **)
928 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
931 (** [build_sdiv x y name b] creates a
932 [%name = sdiv %x, %y]
933 instruction at the position specified by the instruction builder [b].
934 See the method [llvm::LLVMBuilder::CreateSDiv]. **)
935 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
938 (** [build_fdiv x y name b] creates a
939 [%name = fdiv %x, %y]
940 instruction at the position specified by the instruction builder [b].
941 See the method [llvm::LLVMBuilder::CreateFDiv]. **)
942 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
945 (** [build_urem x y name b] creates a
946 [%name = urem %x, %y]
947 instruction at the position specified by the instruction builder [b].
948 See the method [llvm::LLVMBuilder::CreateURem]. **)
949 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
952 (** [build_SRem x y name b] creates a
953 [%name = srem %x, %y]
954 instruction at the position specified by the instruction builder [b].
955 See the method [llvm::LLVMBuilder::CreateSRem]. **)
956 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
959 (** [build_frem x y name b] creates a
960 [%name = frem %x, %y]
961 instruction at the position specified by the instruction builder [b].
962 See the method [llvm::LLVMBuilder::CreateFRem]. **)
963 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
966 (** [build_shl x y name b] creates a
968 instruction at the position specified by the instruction builder [b].
969 See the method [llvm::LLVMBuilder::CreateShl]. **)
970 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
973 (** [build_lshr x y name b] creates a
974 [%name = lshr %x, %y]
975 instruction at the position specified by the instruction builder [b].
976 See the method [llvm::LLVMBuilder::CreateLShr]. **)
977 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
980 (** [build_ashr x y name b] creates a
981 [%name = ashr %x, %y]
982 instruction at the position specified by the instruction builder [b].
983 See the method [llvm::LLVMBuilder::CreateAShr]. **)
984 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
987 (** [build_and x y name b] creates a
989 instruction at the position specified by the instruction builder [b].
990 See the method [llvm::LLVMBuilder::CreateAnd]. **)
991 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
994 (** [build_or x y name b] creates a
996 instruction at the position specified by the instruction builder [b].
997 See the method [llvm::LLVMBuilder::CreateOr]. **)
998 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
1001 (** [build_xor x y name b] creates a
1002 [%name = xor %x, %y]
1003 instruction at the position specified by the instruction builder [b].
1004 See the method [llvm::LLVMBuilder::CreateXor]. **)
1005 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
1008 (** [build_neg x name b] creates a
1010 instruction at the position specified by the instruction builder [b].
1011 [-0.0] is used for floating point types to compute the correct sign.
1012 See the method [llvm::LLVMBuilder::CreateNeg]. **)
1013 external build_neg : llvalue -> string -> llbuilder -> llvalue
1016 (** [build_xor x name b] creates a
1017 [%name = xor %x, -1]
1018 instruction at the position specified by the instruction builder [b].
1019 [-1] is the correct "all ones" value for the type of [x].
1020 See the method [llvm::LLVMBuilder::CreateXor]. **)
1021 external build_not : llvalue -> string -> llbuilder -> llvalue
1024 (*--... Memory .............................................................--*)
1026 (** [build_malloc ty name b] creates a
1027 [%name = malloc %ty]
1028 instruction at the position specified by the instruction builder [b].
1029 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1030 external build_malloc : lltype -> string -> llbuilder -> llvalue
1031 = "llvm_build_malloc"
1033 (** [build_array_malloc ty n name b] creates a
1034 [%name = malloc %ty, %n]
1035 instruction at the position specified by the instruction builder [b].
1036 See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1037 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1038 llvalue = "llvm_build_array_malloc"
1040 (** [build_alloca ty name b] creates a
1041 [%name = alloca %ty]
1042 instruction at the position specified by the instruction builder [b].
1043 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1044 external build_alloca : lltype -> string -> llbuilder -> llvalue
1045 = "llvm_build_alloca"
1047 (** [build_array_alloca ty n name b] creates a
1048 [%name = alloca %ty, %n]
1049 instruction at the position specified by the instruction builder [b].
1050 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1051 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1052 llvalue = "llvm_build_array_alloca"
1054 (** [build_free v b] creates a
1056 instruction at the position specified by the instruction builder [b].
1057 See the method [llvm::LLVMBuilder::CreateFree]. **)
1058 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1060 (** [build_load v name b] creates a
1062 instruction at the position specified by the instruction builder [b].
1063 See the method [llvm::LLVMBuilder::CreateLoad]. **)
1064 external build_load : llvalue -> string -> llbuilder -> llvalue
1067 (** [build_store v p b] creates a
1069 instruction at the position specified by the instruction builder [b].
1070 See the method [llvm::LLVMBuilder::CreateStore]. **)
1071 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1072 = "llvm_build_store"
1074 (** [build_store p indices name b] creates a
1075 [%name = gep %p, indices...]
1076 instruction at the position specified by the instruction builder [b].
1077 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1078 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1081 (*--... Casts ..............................................................--*)
1083 (** [build_trunc v ty name b] creates a
1084 [%name = trunc %p to %ty]
1085 instruction at the position specified by the instruction builder [b].
1086 See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1087 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1088 = "llvm_build_trunc"
1090 (** [build_zext v ty name b] creates a
1091 [%name = zext %p to %ty]
1092 instruction at the position specified by the instruction builder [b].
1093 See the method [llvm::LLVMBuilder::CreateZExt]. **)
1094 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1097 (** [build_sext v ty name b] creates a
1098 [%name = sext %p to %ty]
1099 instruction at the position specified by the instruction builder [b].
1100 See the method [llvm::LLVMBuilder::CreateSExt]. **)
1101 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1104 (** [build_fptoui v ty name b] creates a
1105 [%name = fptoui %p to %ty]
1106 instruction at the position specified by the instruction builder [b].
1107 See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1108 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1109 = "llvm_build_fptoui"
1111 (** [build_fptosi v ty name b] creates a
1112 [%name = fptosi %p to %ty]
1113 instruction at the position specified by the instruction builder [b].
1114 See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1115 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1116 = "llvm_build_fptosi"
1118 (** [build_uitofp v ty name b] creates a
1119 [%name = uitofp %p to %ty]
1120 instruction at the position specified by the instruction builder [b].
1121 See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1122 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1123 = "llvm_build_uitofp"
1125 (** [build_sitofp v ty name b] creates a
1126 [%name = sitofp %p to %ty]
1127 instruction at the position specified by the instruction builder [b].
1128 See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1129 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1130 = "llvm_build_sitofp"
1132 (** [build_fptrunc v ty name b] creates a
1133 [%name = fptrunc %p to %ty]
1134 instruction at the position specified by the instruction builder [b].
1135 See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1136 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1137 = "llvm_build_fptrunc"
1139 (** [build_fpext v ty name b] creates a
1140 [%name = fpext %p to %ty]
1141 instruction at the position specified by the instruction builder [b].
1142 See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1143 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1144 = "llvm_build_fpext"
1146 (** [build_ptrtoint v ty name b] creates a
1147 [%name = prtotint %p to %ty]
1148 instruction at the position specified by the instruction builder [b].
1149 See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1150 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1151 = "llvm_build_prttoint"
1153 (** [build_inttoptr v ty name b] creates a
1154 [%name = inttoptr %p to %ty]
1155 instruction at the position specified by the instruction builder [b].
1156 See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1157 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1158 = "llvm_build_inttoptr"
1160 (** [build_bitcast v ty name b] creates a
1161 [%name = bitcast %p to %ty]
1162 instruction at the position specified by the instruction builder [b].
1163 See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1164 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1165 = "llvm_build_bitcast"
1167 (*--... Comparisons ........................................................--*)
1169 (** [build_icmp pred x y name b] creates a
1170 [%name = icmp %pred %x, %y]
1171 instruction at the position specified by the instruction builder [b].
1172 See the method [llvm::LLVMBuilder::CreateICmp]. **)
1173 external build_icmp : int_predicate -> llvalue -> llvalue -> string ->
1174 llbuilder -> llvalue = "llvm_build_icmp"
1176 (** [build_fcmp pred x y name b] creates a
1177 [%name = fcmp %pred %x, %y]
1178 instruction at the position specified by the instruction builder [b].
1179 See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1180 external build_fcmp : real_predicate -> llvalue -> llvalue -> string ->
1181 llbuilder -> llvalue = "llvm_build_fcmp"
1183 (*--... Miscellaneous instructions .........................................--*)
1185 (** [build_phi incoming name b] creates a
1186 [%name = phi %incoming]
1187 instruction at the position specified by the instruction builder [b].
1188 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1189 See the method [llvm::LLVMBuilder::CreatePHI]. **)
1190 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1191 llvalue = "llvm_build_phi"
1193 (** [build_call fn args name b] creates a
1194 [%name = call %fn(args...)]
1195 instruction at the position specified by the instruction builder [b].
1196 See the method [llvm::LLVMBuilder::CreateCall]. **)
1197 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1200 (** [build_select cond thenv elsev name b] creates a
1201 [%name = select %cond, %thenv, %elsev]
1202 instruction at the position specified by the instruction builder [b].
1203 See the method [llvm::LLVMBuilder::CreateSelect]. **)
1204 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1205 llvalue = "llvm_build_select"
1207 (** [build_va_arg valist argty name b] creates a
1208 [%name = va_arg %valist, %argty]
1209 instruction at the position specified by the instruction builder [b].
1210 See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1211 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1212 = "llvm_build_va_arg"
1214 (** [build_extractelement vec i name b] creates a
1215 [%name = extractelement %vec, %i]
1216 instruction at the position specified by the instruction builder [b].
1217 See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1218 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1219 llvalue = "llvm_build_extractelement"
1221 (** [build_insertelement vec elt i name b] creates a
1222 [%name = insertelement %vec, %elt, %i]
1223 instruction at the position specified by the instruction builder [b].
1224 See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1225 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1226 llbuilder -> llvalue = "llvm_build_insertelement"
1228 (** [build_shufflevector veca vecb mask name b] creates a
1229 [%name = shufflevector %veca, %vecb, %mask]
1230 instruction at the position specified by the instruction builder [b].
1231 See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1232 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1233 llbuilder -> llvalue = "llvm_build_shufflevector"
1236 (*===-- Module providers --------------------------------------------------===*)
1238 (** [create_module_provider m] encapsulates [m] in a module provider and takes
1239 ownership of the module. See the constructor
1240 [llvm::ExistingModuleProvider::ExistingModuleProvider]. **)
1241 external create_module_provider : llmodule -> llmoduleprovider
1242 = "LLVMCreateModuleProviderForExistingModule"
1244 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
1245 the contained module. **)
1246 external dispose_module_provider : llmoduleprovider -> unit
1247 = "llvm_dispose_module_provider"