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]. See the method [llvm::PointerType::get]. **)
262 external pointer_type : lltype -> lltype = "LLVMPointerType"
264 (** [vector_type ty n] returns the array type containing [n] elements of the
265 primitive type [ty]. See the method [llvm::ArrayType::get]. **)
266 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
268 (** [element_type ty] returns the element type of the pointer, vector, or array
269 type [ty]. See the method [llvm::SequentialType::get]. **)
270 external element_type : lltype -> lltype = "LLVMGetElementType"
272 (** [element_type aty] returns the element count of the array type [aty].
273 See the method [llvm::ArrayType::getNumElements]. **)
274 external array_length : lltype -> int = "llvm_array_length"
276 (** [element_type ty] returns the element count of the vector type [ty].
277 See the method [llvm::VectorType::getNumElements]. **)
278 external vector_size : lltype -> int = "llvm_vector_size"
280 (*--... Operations on other types ..........................................--*)
282 (** [opaque_type ()] creates a new opaque type distinct from any other.
283 Opaque types are useful for building recursive types in combination with
284 [refine_type opaque_ty ty].
285 See [llvm::OpaqueType::get]. **)
286 external opaque_type : unit -> lltype = "llvm_opaque_type"
288 (** [void_type] is the type of a function which does not return any value.
289 See [llvm::Type::VoidTy]. **)
290 val void_type : lltype
292 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. **)
293 val label_type : lltype
295 (*--... Operations on type handles .........................................--*)
297 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
298 refined as a result of a call to [refine_type], the handle will be updated;
299 any bare [lltype] references will become invalid.
300 See the class [llvm::PATypeHolder]. **)
301 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
303 (** [type_of_handle tyh] resolves the type handle [tyh].
304 See the method [llvm::PATypeHolder::get()]. **)
305 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
307 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
308 concrete type [ty] in all users. Warning: This may invalidate [lltype]
309 values! Use [lltypehandle] to manipulate potentially abstract types. See the
310 method [llvm::Type::refineAbstractType]. **)
311 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
314 (*===-- Values ------------------------------------------------------------===*)
316 (** [type_of v] returns the type of the value [v].
317 See the method [llvm::Value::getType]. **)
318 external type_of : llvalue -> lltype = "llvm_type_of"
320 (** [value_name v] returns the name of the value [v]. For global values, this is
321 the symbol name. For instructions and basic blocks, it is the SSA register
322 name. It is meaningless for constants.
323 See the method [llvm::Value::getName]. **)
324 external value_name : llvalue -> string = "llvm_value_name"
326 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
327 [llvm::Value::setName]. **)
328 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
330 (** [dump_value v] prints the .ll representation of the value [v] to standard
331 error. See the method [llvm::Value::dump]. **)
332 external dump_value : llvalue -> unit = "llvm_dump_value"
334 (*--... Operations on constants of (mostly) any type .......................--*)
336 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
337 otherwise. Similar to [llvm::isa<Constant>]. **)
338 external is_constant : llvalue -> bool = "llvm_is_constant"
340 (** [const_null ty] returns the constant null (zero) of the type [ty].
341 See the method [llvm::Constant::getNullValue]. **)
342 external const_null : lltype -> llvalue = "LLVMConstNull"
344 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
345 [ty]. See the method [llvm::Constant::getAllOnesValue]. **)
346 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
348 (** [undef ty] returns the undefined value of the type [ty].
349 See the method [llvm::UndefValue::get]. **)
350 external undef : lltype -> llvalue = "LLVMGetUndef"
352 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
353 See the method [llvm::Constant::isNullValue]. **)
354 external is_null : llvalue -> bool = "llvm_is_null"
356 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
357 otherwise. Similar to [llvm::isa<UndefValue>]. **)
358 external is_undef : llvalue -> bool = "llvm_is_undef"
360 (*--... Operations on scalar constants .....................................--*)
362 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
363 See the method [llvm::ConstantInt::get]. **)
364 external const_int : lltype -> int -> llvalue = "llvm_const_int"
366 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
367 [i]. See the method [llvm::ConstantInt::get]. **)
368 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
369 = "llvm_const_of_int64"
371 (** [const_float ty n] returns the floating point constant of type [ty] and
372 value [n]. See the method [llvm::ConstantInt::get]. **)
373 external const_float : lltype -> float -> llvalue = "llvm_const_float"
375 (*--... Operations on composite constants ..................................--*)
377 (** [const_string s] returns the constant [i8] array with the values of the
378 characters in the string [s]. The array is not null-terminated (but see
379 [const_stringz]). This value can in turn be used as the initializer for a
380 global variable. See the method [llvm::ConstantArray::get]. **)
381 external const_string : string -> llvalue = "llvm_const_string"
383 (** [const_stringz s] returns the constant [i8] array with the values of the
384 characters in the string [s] and a null terminator. This value can in turn
385 be used as the initializer for a global variable.
386 See the method [llvm::ConstantArray::get]. **)
387 external const_stringz : string -> llvalue = "llvm_const_stringz"
389 (** [const_array ty elts] returns the constant array of type
390 [array_type ty (Array.length elts)] and containing the values [elts].
391 This value can in turn be used as the initializer for a global variable.
392 See the method [llvm::ConstantArray::get]. **)
393 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
395 (** [const_struct elts] returns the structured constant of type
396 [struct_type (Array.map type_of elts)] and containing the values [elts].
397 This value can in turn be used as the initializer for a global variable.
398 See the method [llvm::ConstantStruct::get]. **)
399 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
401 (** [const_packed_struct elts] returns the structured constant of type
402 [packed_struct_type (Array.map type_of elts)] and containing the values
403 [elts]. This value can in turn be used as the initializer for a global
404 variable. See the method [llvm::ConstantStruct::get]. **)
405 external const_packed_struct : llvalue array -> llvalue
406 = "llvm_const_packed_struct"
408 (** [const_vector elts] returns the vector constant of type
409 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
410 values [elts]. See the method [llvm::ConstantVector::get]. **)
411 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
413 (*--... Constant expressions ...............................................--*)
415 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
416 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
417 (const_int i64_type 1)) i64_type], but considerably more readable.
418 See the method [llvm::ConstantExpr::getSizeOf]. **)
419 external size_of : lltype -> llvalue = "LLVMSizeOf"
421 (** [const_neg c] returns the arithmetic negation of the constant [c].
422 See the method [llvm::ConstantExpr::getNeg]. **)
423 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
425 (** [const_not c] returns the bitwise inverse of the constant [c].
426 See the method [llvm::ConstantExpr::getNot]. **)
427 external const_not : llvalue -> llvalue = "LLVMConstNot"
429 (** [const_add c1 c2] returns the constant sum of two constants.
430 See the method [llvm::ConstantExpr::getAdd]. **)
431 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
433 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
434 constants. See the method [llvm::ConstantExpr::getSub]. **)
435 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
437 (** [const_mul c1 c2] returns the constant product of two constants.
438 See the method [llvm::ConstantExpr::getMul]. **)
439 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
441 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
443 See the method [llvm::ConstantExpr::getUDiv]. **)
444 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
446 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
448 See the method [llvm::ConstantExpr::]. **)
449 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
451 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
453 See the method [llvm::ConstantExpr::getFDiv]. **)
454 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
456 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
457 unsigned integer constants.
458 See the method [llvm::ConstantExpr::getURem]. **)
459 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
461 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
462 signed integer constants.
463 See the method [llvm::ConstantExpr::getSRem]. **)
464 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
466 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
467 signed floating point constants.
468 See the method [llvm::ConstantExpr::getFRem]. **)
469 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
471 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
473 See the method [llvm::ConstantExpr::getAnd]. **)
474 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
476 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
478 See the method [llvm::ConstantExpr::getOr]. **)
479 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
481 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
483 See the method [llvm::ConstantExpr::getXor]. **)
484 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
486 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
487 constants, [c1 pred c2].
488 See the method [llvm::ConstantExpr::getICmp]. **)
489 external const_icmp : int_predicate -> llvalue -> llvalue -> llvalue
492 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
493 point constants, [c1 pred c2].
494 See the method [llvm::ConstantExpr::getFCmp]. **)
495 external const_fcmp : real_predicate -> llvalue -> llvalue -> llvalue
498 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
499 constant integer [c2].
500 See the method [llvm::ConstantExpr::getShl]. **)
501 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
503 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
504 constant integer [c2] with zero extension.
505 See the method [llvm::ConstantExpr::getLShr]. **)
506 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
508 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
509 constant integer [c2] with sign extension.
510 See the method [llvm::ConstantExpr::getAShr]. **)
511 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
513 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
514 constant integers indices from the array [indices].
515 See the method [llvm::ConstantExpr::getGetElementPtr]. **)
516 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
518 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
519 to the smaller integer type [ty].
520 See the method [llvm::ConstantExpr::getTrunc]. **)
521 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
523 (** [const_sext c ty] returns the constant sign extension of integer constant
524 [c] to the larger integer type [ty].
525 See the method [llvm::ConstantExpr::getSExt]. **)
526 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
528 (** [const_zext c ty] returns the constant zero extension of integer constant
529 [c] to the larger integer type [ty].
530 See the method [llvm::ConstantExpr::getZExt]. **)
531 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
533 (** [const_fptrunc c ty] returns the constant truncation of floating point
534 constant [c] to the smaller floating point type [ty].
535 See the method [llvm::ConstantExpr::getFPTrunc]. **)
536 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
538 (** [const_fpext c ty] returns the constant extension of floating point constant
539 [c] to the larger floating point type [ty].
540 See the method [llvm::ConstantExpr::getFPExt]. **)
541 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
543 (** [const_uitofp c ty] returns the constant floating point conversion of
544 unsigned integer constant [c] to the floating point type [ty].
545 See the method [llvm::ConstantExpr::getUIToFP]. **)
546 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
548 (** [const_sitofp c ty] returns the constant floating point conversion of
549 signed integer constant [c] to the floating point type [ty].
550 See the method [llvm::ConstantExpr::getSIToFP]. **)
551 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
553 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
554 floating point constant [c] to integer type [ty].
555 See the method [llvm::ConstantExpr::getFPToUI]. **)
556 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
558 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
559 floating point constant [c] to integer type [ty].
560 See the method [llvm::ConstantExpr::getFPToSI]. **)
561 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
563 (** [const_ptrtoint c ty] returns the constant integer conversion of
564 pointer constant [c] to integer type [ty].
565 See the method [llvm::ConstantExpr::getPtrToInt]. **)
566 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
568 (** [const_inttoptr c ty] returns the constant pointer conversion of
569 integer constant [c] to pointer type [ty].
570 See the method [llvm::ConstantExpr::getIntToPtr]. **)
571 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
573 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
574 to type [ty] of equal size.
575 See the method [llvm::ConstantExpr::getBitCast]. **)
576 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
578 (** [const_select cond t f] returns the constant conditional which returns value
579 [t] if the boolean constant [cond] is true and the value [f] otherwise.
580 See the method [llvm::ConstantExpr::getSelect]. **)
581 external const_select : llvalue -> llvalue -> llvalue -> llvalue
584 (** [const_extractelement vec i] returns the constant [i]th element of
585 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
586 the size of the vector.
587 See the method [llvm::ConstantExpr::getExtractElement]. **)
588 external const_extractelement : llvalue -> llvalue -> llvalue
589 = "LLVMConstExtractElement"
591 (** [const_insertelement vec v i] returns the constant vector with the same
592 elements as constant vector [v] but the [i]th element replaced by the
593 constant [v]. [v] must be a constant value with the type of the vector
594 elements. [i] must be a constant [i32] value unsigned less than the size
596 See the method [llvm::ConstantExpr::getInsertElement]. **)
597 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
598 = "LLVMConstInsertElement"
600 (** [const_shufflevector a b mask] returns a constant [shufflevector].
601 See the LLVM Language Reference for details on the [sufflevector]
603 See the method [llvm::ConstantExpr::getShuffleVector]. **)
604 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
605 = "LLVMConstShuffleVector"
607 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
609 (** [is_declaration g] returns [true] if the global value [g] is a declaration
610 only. Returns [false] otherwise.
611 See the method [llvm::GlobalValue::isDeclaration]. **)
612 external is_declaration : llvalue -> bool = "llvm_is_declaration"
614 (** [linkage g] returns the linkage of the global value [g].
615 See the method [llvm::GlobalValue::getLinkage]. **)
616 external linkage : llvalue -> linkage = "llvm_linkage"
618 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
619 See the method [llvm::GlobalValue::setLinkage]. **)
620 external set_linkage : linkage -> llvalue -> unit = "llvm_set_linkage"
622 (** [section g] returns the linker section of the global value [g].
623 See the method [llvm::GlobalValue::getSection]. **)
624 external section : llvalue -> string = "llvm_section"
626 (** [set_section s g] sets the linker section of the global value [g] to [s].
627 See the method [llvm::GlobalValue::setSection]. **)
628 external set_section : string -> llvalue -> unit = "llvm_set_section"
630 (** [visibility g] returns the linker visibility of the global value [g].
631 See the method [llvm::GlobalValue::getVisibility]. **)
632 external visibility : llvalue -> visibility = "llvm_visibility"
634 (** [set_visibility v g] sets the linker visibility of the global value [g] to
635 [v]. See the method [llvm::GlobalValue::setVisibility]. **)
636 external set_visibility : visibility -> llvalue -> unit = "llvm_set_visibility"
638 (** [alignment g] returns the required alignment of the global value [g].
639 See the method [llvm::GlobalValue::getAlignment]. **)
640 external alignment : llvalue -> int = "llvm_alignment"
642 (** [set_alignment n g] sets the required alignment of the global value [g] to
643 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. **)
644 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
646 (*--... Operations on global variables .....................................--*)
648 (** [declare_global ty name m] returns a new global variable of type [ty] and
649 with name [name] in module [m]. If such a global variable already exists,
650 it is returned. If the type of the existing global differs, then a bitcast
651 to [ty] is returned. **)
652 external declare_global : lltype -> string -> llmodule -> llvalue
653 = "llvm_declare_global"
655 (** [define_global name init m] returns a new global with name [name] and
656 initializer [init] in module [m]. If the named global already exists, it is
658 See the constructor of [llvm::GlobalVariable]. **)
659 external define_global : string -> llvalue -> llmodule -> llvalue
660 = "llvm_define_global"
662 (** [lookup_global name m] returns [Some g] if a global variable with name
663 [name] exists in module [m]. If no such global exists, returns [None].
664 See the [llvm::GlobalVariable] constructor. **)
665 external lookup_global : string -> llmodule -> llvalue option
666 = "llvm_lookup_global"
668 (** [delete_global gv] destroys the global variable [gv].
669 See the method [llvm::GlobalVariable::eraseFromParent]. **)
670 external delete_global : llvalue -> unit = "llvm_delete_global"
672 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
673 constant. Returns [false] otherwise.
674 See the method [llvm::GlobalVariable::isConstant]. **)
675 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
677 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
678 [c] is [true] and not if [c] is [false].
679 See the method [llvm::GlobalVariable::setConstant]. **)
680 external set_global_constant : bool -> llvalue -> unit
681 = "llvm_set_global_constant"
683 (** [has_initializer gv] returns [true] if the global variable [gv] has an
684 initializer and [false] otherwise.
685 See the method [llvm::GlobalVariable::hasInitializer]. **)
686 external has_initializer : llvalue -> bool = "llvm_has_initializer"
688 (** [global_initializer gv] returns the initializer for the global variable
689 [gv]. See the method [llvm::GlobalVariable::getInitializer]. **)
690 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
692 (** [set_initializer c gv] sets the initializer for the global variable
693 [gv] to the constant [c].
694 See the method [llvm::GlobalVariable::setInitializer]. **)
695 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
697 (** [remove_initializer gv] unsets the initializer for the global variable
699 See the method [llvm::GlobalVariable::setInitializer]. **)
700 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
702 (** [is_thread_local gv] returns [true] if the global variable [gv] is
703 thread-local and [false] otherwise.
704 See the method [llvm::GlobalVariable::isThreadLocal]. **)
705 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
707 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
708 [c] is [true] and not otherwise.
709 See the method [llvm::GlobalVariable::setThreadLocal]. **)
710 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
712 (*--... Operations on functions ............................................--*)
714 (** [declare_function name ty m] returns a new function of type [ty] and
715 with name [name] in module [m]. If such a function already exists,
716 it is returned. If the type of the existing function differs, then a bitcast
717 to [ty] is returned. **)
718 external declare_function : string -> lltype -> llmodule -> llvalue
719 = "llvm_declare_function"
721 (** [define_function name ty m] creates a new function with name [name] and
722 type [ty] in module [m]. If the named function already exists, it is
723 renamed. An entry basic block is created in the function.
724 See the constructor of [llvm::GlobalVariable]. **)
725 external define_function : string -> lltype -> llmodule -> llvalue
726 = "llvm_define_function"
728 (** [lookup_function name m] returns [Some f] if a function with name
729 [name] exists in module [m]. If no such function exists, returns [None].
730 See the method [llvm::Module] constructor. **)
731 external lookup_function : string -> llmodule -> llvalue option
732 = "llvm_lookup_function"
734 (** [delete_function f] destroys the function [f].
735 See the method [llvm::Function::eraseFromParent]. **)
736 external delete_function : llvalue -> unit = "llvm_delete_function"
738 (** [params f] returns the parameters of function [f].
739 See the method [llvm::Function::getArgumentList]. **)
740 external params : llvalue -> llvalue array = "llvm_params"
742 (** [param f n] returns the [n]th parameter of function [f].
743 See the method [llvm::Function::getArgumentList]. **)
744 external param : llvalue -> int -> llvalue = "llvm_param"
746 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
747 See the method [llvm::Function::isIntrinsic]. **)
748 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
750 (** [function_call_conv f] returns the calling convention of the function [f].
751 See the method [llvm::Function::getCallingConv]. **)
752 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
754 (** [set_function_call_conv cc f] sets the calling convention of the function
755 [f] to the calling convention numbered [cc].
756 See the method [llvm::Function::setCallingConv]. **)
757 external set_function_call_conv : int -> llvalue -> unit
758 = "llvm_set_function_call_conv"
760 (** [collector f] returns [Some name] if the function [f] has a garbage
761 collection algorithm specified and [None] otherwise.
762 See the method [llvm::Function::getCollector]. **)
763 external collector : llvalue -> string option = "llvm_collector"
765 (** [set_collector gc f] sets the collection algorithm for the function [f] to
766 [gc]. See the method [llvm::Function::setCollector]. **)
767 external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
769 (*--... Operations on basic blocks .........................................--*)
771 (** [basic_blocks fn] returns the basic blocks of the function [f].
772 See the method [llvm::Function::getBasicBlockList]. **)
773 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
775 (** [entry_block fn] returns the entry basic block of the function [f].
776 See the method [llvm::Function::getEntryBlock]. **)
777 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
779 (** [delete_block bb] deletes the basic block [bb].
780 See the method [llvm::BasicBlock::eraseFromParent]. **)
781 external delete_block : llbasicblock -> unit = "llvm_delete_block"
783 (** [append_block name f] creates a new basic block named [name] at the end of
785 See the constructor of [llvm::BasicBlock]. **)
786 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
788 (** [insert_block name bb] creates a new basic block named [name] before the
790 See the constructor of [llvm::BasicBlock]. **)
791 external insert_block : string -> llbasicblock -> llbasicblock
792 = "llvm_insert_block"
794 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
795 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
797 (** [value_is_block v] returns [true] if the value [v] is a basic block and
799 Similar to [llvm::isa<BasicBlock>]. **)
800 external value_is_block : llvalue -> bool = "llvm_value_is_block"
802 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
803 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
805 (*--... Operations on phi nodes ............................................--*)
807 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
808 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
809 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
810 = "llvm_add_incoming"
812 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
813 See the method [llvm::PHINode::getIncomingValue]. **)
814 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
817 (*===-- Instruction builders ----------------------------------------------===*)
819 (** [builder_before ins] creates an instruction builder positioned before the
820 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
821 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
823 (** [builder_at_end bb] creates an instruction builder positioned at the end of
824 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
825 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
827 (** [position_before ins b] moves the instruction builder [b] to before the
828 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
829 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
831 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
832 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
833 external position_at_end : llbasicblock -> llbuilder -> unit
834 = "llvm_position_at_end"
836 (*--... Terminators ........................................................--*)
838 (** [build_ret_void b] creates a
840 instruction at the position specified by the instruction builder [b].
841 See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
842 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
844 (** [build_ret v b] creates a
846 instruction at the position specified by the instruction builder [b].
847 See the method [llvm::LLVMBuilder::CreateRet]. **)
848 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
850 (** [build_br bb b] creates a
852 instruction at the position specified by the instruction builder [b].
853 See the method [llvm::LLVMBuilder::CreateBr]. **)
854 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
856 (** [build_cond_br cond tbb fbb b] creates a
857 [b %cond, %tbb, %fbb]
858 instruction at the position specified by the instruction builder [b].
859 See the method [llvm::LLVMBuilder::CreateCondBr]. **)
860 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
861 llvalue = "llvm_build_cond_br"
863 (** [build_switch case elsebb b] creates an empty
864 [switch %case, %elsebb]
865 instruction at the position specified by the instruction builder [b].
866 See the method [llvm::LLVMBuilder::CreateSwitch]. **)
867 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
868 = "llvm_build_switch"
870 (** [build_invoke fn args tobb unwindbb name b] creates an
871 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
872 instruction at the position specified by the instruction builder [b].
873 See the method [llvm::LLVMBuilder::CreateInvoke]. **)
874 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
875 llbasicblock -> string -> llbuilder -> llvalue
876 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
878 (** [build_unwind b] creates an
880 instruction at the position specified by the instruction builder [b].
881 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
882 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
884 (** [build_unreachable b] creates an
886 instruction at the position specified by the instruction builder [b].
887 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
888 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
890 (*--... Arithmetic .........................................................--*)
892 (** [build_add x y name b] creates a
894 instruction at the position specified by the instruction builder [b].
895 See the method [llvm::LLVMBuilder::CreateAdd]. **)
896 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
899 (** [build_sub x y name b] creates a
901 instruction at the position specified by the instruction builder [b].
902 See the method [llvm::LLVMBuilder::CreateSub]. **)
903 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
906 (** [build_mul x y name b] creates a
908 instruction at the position specified by the instruction builder [b].
909 See the method [llvm::LLVMBuilder::CreateMul]. **)
910 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
913 (** [build_udiv x y name b] creates a
914 [%name = udiv %x, %y]
915 instruction at the position specified by the instruction builder [b].
916 See the method [llvm::LLVMBuilder::CreateUDiv]. **)
917 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
920 (** [build_sdiv x y name b] creates a
921 [%name = sdiv %x, %y]
922 instruction at the position specified by the instruction builder [b].
923 See the method [llvm::LLVMBuilder::CreateSDiv]. **)
924 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
927 (** [build_fdiv x y name b] creates a
928 [%name = fdiv %x, %y]
929 instruction at the position specified by the instruction builder [b].
930 See the method [llvm::LLVMBuilder::CreateFDiv]. **)
931 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
934 (** [build_urem x y name b] creates a
935 [%name = urem %x, %y]
936 instruction at the position specified by the instruction builder [b].
937 See the method [llvm::LLVMBuilder::CreateURem]. **)
938 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
941 (** [build_SRem x y name b] creates a
942 [%name = srem %x, %y]
943 instruction at the position specified by the instruction builder [b].
944 See the method [llvm::LLVMBuilder::CreateSRem]. **)
945 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
948 (** [build_frem x y name b] creates a
949 [%name = frem %x, %y]
950 instruction at the position specified by the instruction builder [b].
951 See the method [llvm::LLVMBuilder::CreateFRem]. **)
952 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
955 (** [build_shl x y name b] creates a
957 instruction at the position specified by the instruction builder [b].
958 See the method [llvm::LLVMBuilder::CreateShl]. **)
959 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
962 (** [build_lshr x y name b] creates a
963 [%name = lshr %x, %y]
964 instruction at the position specified by the instruction builder [b].
965 See the method [llvm::LLVMBuilder::CreateLShr]. **)
966 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
969 (** [build_ashr x y name b] creates a
970 [%name = ashr %x, %y]
971 instruction at the position specified by the instruction builder [b].
972 See the method [llvm::LLVMBuilder::CreateAShr]. **)
973 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
976 (** [build_and x y name b] creates a
978 instruction at the position specified by the instruction builder [b].
979 See the method [llvm::LLVMBuilder::CreateAnd]. **)
980 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
983 (** [build_or x y name b] creates a
985 instruction at the position specified by the instruction builder [b].
986 See the method [llvm::LLVMBuilder::CreateOr]. **)
987 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
990 (** [build_xor x y name b] creates a
992 instruction at the position specified by the instruction builder [b].
993 See the method [llvm::LLVMBuilder::CreateXor]. **)
994 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
997 (** [build_neg x name b] creates a
999 instruction at the position specified by the instruction builder [b].
1000 [-0.0] is used for floating point types to compute the correct sign.
1001 See the method [llvm::LLVMBuilder::CreateNeg]. **)
1002 external build_neg : llvalue -> string -> llbuilder -> llvalue
1005 (** [build_xor x name b] creates a
1006 [%name = xor %x, -1]
1007 instruction at the position specified by the instruction builder [b].
1008 [-1] is the correct "all ones" value for the type of [x].
1009 See the method [llvm::LLVMBuilder::CreateXor]. **)
1010 external build_not : llvalue -> string -> llbuilder -> llvalue
1013 (*--... Memory .............................................................--*)
1015 (** [build_malloc ty name b] creates a
1016 [%name = malloc %ty]
1017 instruction at the position specified by the instruction builder [b].
1018 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1019 external build_malloc : lltype -> string -> llbuilder -> llvalue
1020 = "llvm_build_malloc"
1022 (** [build_array_malloc ty n name b] creates a
1023 [%name = malloc %ty, %n]
1024 instruction at the position specified by the instruction builder [b].
1025 See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1026 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1027 llvalue = "llvm_build_array_malloc"
1029 (** [build_alloca ty name b] creates a
1030 [%name = alloca %ty]
1031 instruction at the position specified by the instruction builder [b].
1032 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1033 external build_alloca : lltype -> string -> llbuilder -> llvalue
1034 = "llvm_build_alloca"
1036 (** [build_array_alloca ty n name b] creates a
1037 [%name = alloca %ty, %n]
1038 instruction at the position specified by the instruction builder [b].
1039 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1040 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1041 llvalue = "llvm_build_array_alloca"
1043 (** [build_free v b] creates a
1045 instruction at the position specified by the instruction builder [b].
1046 See the method [llvm::LLVMBuilder::CreateFree]. **)
1047 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1049 (** [build_load v name b] creates a
1051 instruction at the position specified by the instruction builder [b].
1052 See the method [llvm::LLVMBuilder::CreateLoad]. **)
1053 external build_load : llvalue -> string -> llbuilder -> llvalue
1056 (** [build_store v p b] creates a
1058 instruction at the position specified by the instruction builder [b].
1059 See the method [llvm::LLVMBuilder::CreateStore]. **)
1060 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1061 = "llvm_build_store"
1063 (** [build_store p indices name b] creates a
1064 [%name = gep %p, indices...]
1065 instruction at the position specified by the instruction builder [b].
1066 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1067 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1070 (*--... Casts ..............................................................--*)
1072 (** [build_trunc v ty name b] creates a
1073 [%name = trunc %p to %ty]
1074 instruction at the position specified by the instruction builder [b].
1075 See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1076 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1077 = "llvm_build_trunc"
1079 (** [build_zext v ty name b] creates a
1080 [%name = zext %p to %ty]
1081 instruction at the position specified by the instruction builder [b].
1082 See the method [llvm::LLVMBuilder::CreateZExt]. **)
1083 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1086 (** [build_sext v ty name b] creates a
1087 [%name = sext %p to %ty]
1088 instruction at the position specified by the instruction builder [b].
1089 See the method [llvm::LLVMBuilder::CreateSExt]. **)
1090 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1093 (** [build_fptoui v ty name b] creates a
1094 [%name = fptoui %p to %ty]
1095 instruction at the position specified by the instruction builder [b].
1096 See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1097 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1098 = "llvm_build_fptoui"
1100 (** [build_fptosi v ty name b] creates a
1101 [%name = fptosi %p to %ty]
1102 instruction at the position specified by the instruction builder [b].
1103 See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1104 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1105 = "llvm_build_fptosi"
1107 (** [build_uitofp v ty name b] creates a
1108 [%name = uitofp %p to %ty]
1109 instruction at the position specified by the instruction builder [b].
1110 See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1111 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1112 = "llvm_build_uitofp"
1114 (** [build_sitofp v ty name b] creates a
1115 [%name = sitofp %p to %ty]
1116 instruction at the position specified by the instruction builder [b].
1117 See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1118 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1119 = "llvm_build_sitofp"
1121 (** [build_fptrunc v ty name b] creates a
1122 [%name = fptrunc %p to %ty]
1123 instruction at the position specified by the instruction builder [b].
1124 See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1125 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1126 = "llvm_build_fptrunc"
1128 (** [build_fpext v ty name b] creates a
1129 [%name = fpext %p to %ty]
1130 instruction at the position specified by the instruction builder [b].
1131 See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1132 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1133 = "llvm_build_fpext"
1135 (** [build_ptrtoint v ty name b] creates a
1136 [%name = prtotint %p to %ty]
1137 instruction at the position specified by the instruction builder [b].
1138 See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1139 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1140 = "llvm_build_prttoint"
1142 (** [build_inttoptr v ty name b] creates a
1143 [%name = inttoptr %p to %ty]
1144 instruction at the position specified by the instruction builder [b].
1145 See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1146 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1147 = "llvm_build_inttoptr"
1149 (** [build_bitcast v ty name b] creates a
1150 [%name = bitcast %p to %ty]
1151 instruction at the position specified by the instruction builder [b].
1152 See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1153 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1154 = "llvm_build_bitcast"
1156 (*--... Comparisons ........................................................--*)
1158 (** [build_icmp pred x y name b] creates a
1159 [%name = icmp %pred %x, %y]
1160 instruction at the position specified by the instruction builder [b].
1161 See the method [llvm::LLVMBuilder::CreateICmp]. **)
1162 external build_icmp : int_predicate -> llvalue -> llvalue -> string ->
1163 llbuilder -> llvalue = "llvm_build_icmp"
1165 (** [build_fcmp pred x y name b] creates a
1166 [%name = fcmp %pred %x, %y]
1167 instruction at the position specified by the instruction builder [b].
1168 See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1169 external build_fcmp : real_predicate -> llvalue -> llvalue -> string ->
1170 llbuilder -> llvalue = "llvm_build_fcmp"
1172 (*--... Miscellaneous instructions .........................................--*)
1174 (** [build_phi incoming name b] creates a
1175 [%name = phi %incoming]
1176 instruction at the position specified by the instruction builder [b].
1177 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1178 See the method [llvm::LLVMBuilder::CreatePHI]. **)
1179 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1180 llvalue = "llvm_build_phi"
1182 (** [build_call fn args name b] creates a
1183 [%name = call %fn(args...)]
1184 instruction at the position specified by the instruction builder [b].
1185 See the method [llvm::LLVMBuilder::CreateCall]. **)
1186 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1189 (** [build_select cond thenv elsev name b] creates a
1190 [%name = select %cond, %thenv, %elsev]
1191 instruction at the position specified by the instruction builder [b].
1192 See the method [llvm::LLVMBuilder::CreateSelect]. **)
1193 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1194 llvalue = "llvm_build_select"
1196 (** [build_va_arg valist argty name b] creates a
1197 [%name = va_arg %valist, %argty]
1198 instruction at the position specified by the instruction builder [b].
1199 See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1200 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1201 = "llvm_build_va_arg"
1203 (** [build_extractelement vec i name b] creates a
1204 [%name = extractelement %vec, %i]
1205 instruction at the position specified by the instruction builder [b].
1206 See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1207 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1208 llvalue = "llvm_build_extractelement"
1210 (** [build_insertelement vec elt i name b] creates a
1211 [%name = insertelement %vec, %elt, %i]
1212 instruction at the position specified by the instruction builder [b].
1213 See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1214 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1215 llbuilder -> llvalue = "llvm_build_insertelement"
1217 (** [build_shufflevector veca vecb mask name b] creates a
1218 [%name = shufflevector %veca, %vecb, %mask]
1219 instruction at the position specified by the instruction builder [b].
1220 See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1221 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1222 llbuilder -> llvalue = "llvm_build_shufflevector"
1225 (*===-- Module providers --------------------------------------------------===*)
1227 (** [create_module_provider m] encapsulates [m] in a module provider and takes
1228 ownership of the module. See the constructor
1229 [llvm::ExistingModuleProvider::ExistingModuleProvider]. **)
1230 external create_module_provider : llmodule -> llmoduleprovider
1231 = "LLVMCreateModuleProviderForExistingModule"
1233 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
1234 the contained module. **)
1235 external dispose_module_provider : llmoduleprovider -> unit
1236 = "llvm_dispose_module_provider"