Adding ocamldoc-style comments for the Ocaml bindings.
[oota-llvm.git] / bindings / ocaml / llvm / llvm.mli
1 (*===-- tools/ml/llvm.ml - LLVM Ocaml Interface ---------------------------===*
2  *
3  *                     The LLVM Compiler Infrastructure
4  *
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.
7  *
8  *===----------------------------------------------------------------------===
9  *
10  * This interface provides an ocaml API for the LLVM intermediate
11  * representation, the classes in the VMCore library.
12  *
13  *===----------------------------------------------------------------------===*)
14
15
16 (* These abstract types correlate directly to the LLVM VMCore classes. *)
17
18 (** The top-level container for all other LLVM Intermediate Representation (IR)
19     objects. See the [llvm::Module] class. **)
20 type llmodule
21
22 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
23     [llvm::Type] class. **)
24 type lltype 
25
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. **)
29 type lltypehandle
30
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. **)
34 type llvalue
35
36 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. **)
37 type llbasicblock
38
39 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
40     class. **)
41 type llbuilder
42
43 (** The kind of an [lltype], the result of [classify_type ty]. See the 
44     [llvm::Type::TypeID] enumeration. **)
45 type type_kind =
46   Void_type
47 | Float_type
48 | Double_type
49 | X86fp80_type
50 | Fp128_type
51 | Ppc_fp128_type
52 | Label_type
53 | Integer_type
54 | Function_type
55 | Struct_type
56 | Array_type
57 | Pointer_type
58 | Opaque_type
59 | Vector_type
60
61 (** The linkage of a global value, accessed with [linkage gv] and
62     [set_linkage l gv]. See [llvm::GlobalValue::LinkageTypes]. **)
63 type linkage =
64   External_linkage
65 | Link_once_linkage
66 | Weak_linkage
67 | Appending_linkage
68 | Internal_linkage
69 | Dllimport_linkage
70 | Dllexport_linkage
71 | External_weak_linkage
72 | Ghost_linkage
73
74 (** The linker visibility of a global value, accessed with [visibility gv] and
75     [set_visibility v gv]. See [llvm::GlobalValue::VisibilityTypes]. **)
76 type visibility =
77   Default_visibility
78 | Hidden_visibility
79 | Protected_visibility
80
81 (* The following calling convention values may be accessed with
82    [function_call_conv f] and [set_function_call_conv conv f]. Calling
83    conventions are open-ended. *)
84 val ccc : int             (** [ccc] is the C calling convention. **)
85 val fastcc : int          (** [fastcc] is the calling convention to allow LLVM
86                               maximum optimization opportunities. Use only with
87                               internal linkage. **)
88 val coldcc : int          (** [coldcc] is the calling convention for
89                               callee-save. **)
90 val x86_stdcallcc : int   (** [x86_stdcallcc] is the familiar stdcall calling
91                               convention from C. **)
92 val x86_fastcallcc : int  (** [x86_fastcallcc] is the familiar fastcall calling
93                               convention from C. **)
94
95 (** The predicate for an integer comparison ([icmp]) instruction.
96     See the [llvm::ICmpInst::Predicate] enumeration. **)
97 type int_predicate =
98   Icmp_eq
99 | Icmp_ne
100 | Icmp_ugt
101 | Icmp_uge
102 | Icmp_ult
103 | Icmp_ule
104 | Icmp_sgt
105 | Icmp_sge
106 | Icmp_slt
107 | Icmp_sle
108
109 (** The predicate for a floating-point comparison ([fcmp]) instruction.
110     See the [llvm::FCmpInst::Predicate] enumeration. **)
111 type real_predicate =
112   Fcmp_false
113 | Fcmp_oeq
114 | Fcmp_ogt
115 | Fcmp_oge
116 | Fcmp_olt
117 | Fcmp_ole
118 | Fcmp_one
119 | Fcmp_ord
120 | Fcmp_uno
121 | Fcmp_ueq
122 | Fcmp_ugt
123 | Fcmp_uge
124 | Fcmp_ult
125 | Fcmp_ule
126 | Fcmp_une
127 | Fcmp_true
128
129
130 (*===-- Modules -----------------------------------------------------------===*)
131
132 (** [create_module id] creates a module with the supplied module ID. Modules are
133     not garbage collected; it is mandatory to call [dispose_module m] to free
134     memory. See the constructor [llvm::Module::Module]. *)
135 external create_module : string -> llmodule = "llvm_create_module"
136
137 (** [dispose_module m] destroys a module [m] and all of the IR objects it
138     contained. All references to subordinate objects are invalidated;
139     referencing them will invoke undefined behavior. See the destructor
140     [llvm::Module::~Module]. **)
141 external dispose_module : llmodule -> unit = "llvm_dispose_module"
142
143 (** [define_type_name name ty m] adds a named type to the module's symbol table.
144     Returns [true] if successful. If such a name already exists, then no entry
145     is added and [false] is returned. See the [llvm::Module::addTypeName]
146     method. **)
147 external define_type_name : string -> lltype -> llmodule -> bool
148                           = "llvm_add_type_name"
149
150 (** [delete_type_name name] removes a type name from the module's symbol
151     table. *)
152 external delete_type_name : string -> llmodule -> unit
153                           = "llvm_delete_type_name"
154
155
156 (*===-- Types -------------------------------------------------------------===*)
157
158 (** [classify_type ty] returns the [type_kind] corresponding to the type [ty].
159     See the method [llvm::Type::getTypeID]. **)
160 external classify_type : lltype -> type_kind = "llvm_classify_type"
161
162 (** [string_of_lltype ty] returns a string describing the type [ty]. **)
163 val string_of_lltype : lltype -> string
164
165 (*--... Operations on integer types ........................................--*)
166
167 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. **)
168 val i1_type : lltype 
169
170 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. **)
171 val i8_type : lltype 
172
173 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. **)
174 val i16_type : lltype
175
176 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. **)
177 val i32_type : lltype
178
179 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. **)
180 val i64_type : lltype
181
182 (** [integer_type n] returns an integer type of bitwidth [n].
183     See the method [llvm::IntegerType::get]. **)
184 external integer_type : int -> lltype = "llvm_integer_type"
185
186 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty]..
187     See the method [llvm::IntegerType::getBitWidth]. **)
188 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
189
190 (*--... Operations on real types ...........................................--*)
191
192 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. **)
193 val float_type : lltype
194
195 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. **)
196 val double_type : lltype
197
198 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. **)
199 val x86fp80_type : lltype
200
201 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. **)
202 val fp128_type : lltype
203
204 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. **)
205 val ppc_fp128_type : lltype
206
207 (*--... Operations on function types .......................................--*)
208
209 (** [function_type ret_ty param_tys] returns the function type returning
210     [ret_ty] and taking [param_tys] as parameters.
211     See the method [llvm::FunctionType::get]. **)
212 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
213
214 (** [va_arg_function_type ret_ty param_tys] is just like
215     [function_type ret_ty param_tys] except that it returns the function type
216     which also takes a variable number of arguments.
217     See the method [llvm::FunctionType::get]. **)
218 external var_arg_function_type : lltype -> lltype array -> lltype
219                                = "llvm_var_arg_function_type"
220
221 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
222     otherwise. See the method [llvm::FunctionType::isVarArg]. **)
223 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
224
225 (** [return_type fty] gets the return type of the function type [fty].
226     See the method [llvm::FunctionType::getReturnType]. **)
227 external return_type : lltype -> lltype = "LLVMGetReturnType"
228
229 (** [param_types fty] gets the parameter types of the function type [fty].
230     See the method [llvm::FunctionType::getParamType]. **)
231 external param_types : lltype -> lltype array = "llvm_param_types"
232
233 (*--... Operations on struct types .........................................--*)
234
235 (** [struct_type tys] returns the structure type containing in the types in the
236     array [tys]. See the method [llvm::StructType::get]. **)
237 external struct_type : lltype array -> lltype = "llvm_struct_type"
238
239 (** [struct_type tys] returns the packed structure type containing in the types
240     in the array [tys]. See the method [llvm::StructType::get]. **)
241 external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
242
243 (** [element_types sty] returns the constituent types of the struct type [sty].
244     See the method [llvm::StructType::getElementType]. **)
245 external element_types : lltype -> lltype array = "llvm_element_types"
246
247 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
248     [false] otherwise. See the method [llvm::StructType::isPacked]. **)
249 external is_packed : lltype -> bool = "llvm_is_packed"
250
251 (*--... Operations on pointer, vector, and array types .....................--*)
252
253 (** [array_type ty n] returns the array type containing [n] elements of type
254     [ty]. See the method [llvm::ArrayType::get]. **)
255 external array_type : lltype -> int -> lltype = "llvm_array_type"
256
257 (** [pointer_type ty] returns the pointer type referencing objects of type
258     [ty]. See the method [llvm::PointerType::get]. **)
259 external pointer_type : lltype -> lltype = "LLVMPointerType"
260
261 (** [vector_type ty n] returns the array type containing [n] elements of the
262     primitive type [ty]. See the method [llvm::ArrayType::get]. **)
263 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
264
265 (** [element_type ty] returns the element type of the pointer, vector, or array
266     type [ty]. See the method [llvm::SequentialType::get]. **)
267 external element_type : lltype -> lltype = "LLVMGetElementType"
268
269 (** [element_type aty] returns the element count of the array type [aty].
270     See the method [llvm::ArrayType::getNumElements]. **)
271 external array_length : lltype -> int = "llvm_array_length"
272
273 (** [element_type ty] returns the element count of the vector type [ty].
274     See the method [llvm::VectorType::getNumElements]. **)
275 external vector_size : lltype -> int = "llvm_vector_size"
276
277 (*--... Operations on other types ..........................................--*)
278
279 (** [opaque_type ()] creates a new opaque type distinct from any other.
280     Opaque types are useful for building recursive types in combination with
281     [refine_type opaque_ty ty].
282     See [llvm::OpaqueType::get]. **)
283 external opaque_type : unit -> lltype = "llvm_opaque_type"
284
285 (** [void_type] is the type of a function which does not return any value.
286     See [llvm::Type::VoidTy]. **)
287 val void_type : lltype
288
289 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. **)
290 val label_type : lltype
291
292 (*--... Operations on type handles .........................................--*)
293
294 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
295     refined as a result of a call to [refine_type], the handle will be updated;
296     any bare [lltype] references will become invalid.
297     See the class [llvm::PATypeHolder]. **)
298 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
299
300 (** [type_of_handle tyh] resolves the type handle [tyh].
301     See the method [llvm::PATypeHolder::get()]. **)
302 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
303
304 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
305     concrete type [ty] in all users. Warning: This may invalidate [lltype]
306     values! Use [lltypehandle] to manipulate potentially abstract types. See the
307     method [llvm::Type::refineAbstractType]. **)
308 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
309
310
311 (*===-- Values ------------------------------------------------------------===*)
312
313 (** [type_of v] returns the type of the value [v].
314     See the method [llvm::Value::getType]. **)
315 external type_of : llvalue -> lltype = "llvm_type_of"
316
317 (** [value_name v] returns the name of the value [v]. For global values, this is
318     the symbol name. For instructions and basic blocks, it is the SSA register
319     name. It is meaningless for constants.
320     See the method [llvm::Value::getName]. **)
321 external value_name : llvalue -> string = "llvm_value_name"
322
323 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method 
324     [llvm::Value::setName]. **)
325 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
326
327 (** [dump_value v] prints the .ll representation of the value [v] to standard
328     error. See the method [llvm::Value::dump]. **)
329 external dump_value : llvalue -> unit = "llvm_dump_value"
330
331 (*--... Operations on constants of (mostly) any type .......................--*)
332
333 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
334     otherwise. Similar to [llvm::isa<Constant>]. **)
335 external is_constant : llvalue -> bool = "llvm_is_constant"
336
337 (** [const_null ty] returns the constant null (zero) of the type [ty].
338     See the method [llvm::Constant::getNullValue]. **)
339 external const_null : lltype -> llvalue = "LLVMConstNull"
340
341 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
342     [ty]. See the method [llvm::Constant::getAllOnesValue]. **)
343 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
344
345 (** [undef ty] returns the undefined value of the type [ty].
346     See the method [llvm::UndefValue::get]. **)
347 external undef : lltype -> llvalue = "LLVMGetUndef"
348
349 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
350     See the method [llvm::Constant::isNullValue]. **)
351 external is_null : llvalue -> bool = "llvm_is_null"
352
353 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
354     otherwise. Similar to [llvm::isa<UndefValue>]. **)
355 external is_undef : llvalue -> bool = "llvm_is_undef"
356
357 (*--... Operations on scalar constants .....................................--*)
358
359 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
360     See the method [llvm::ConstantInt::get]. **)
361 external const_int : lltype -> int -> llvalue = "llvm_const_int"
362
363 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
364     [i]. See the method [llvm::ConstantInt::get]. **)
365 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
366                         = "llvm_const_of_int64"
367
368 (** [const_float ty n] returns the floating point constant of type [ty] and
369     value [n]. See the method [llvm::ConstantInt::get]. **)
370 external const_float : lltype -> float -> llvalue = "llvm_const_float"
371
372 (*--... Operations on composite constants ..................................--*)
373
374 (** [const_string s] returns the constant [i8] array with the values of the
375     characters in the string [s]. The array is not null-terminated (but see
376     [const_stringz]). This value can in turn be used as the initializer for a
377     global variable. See the method [llvm::ConstantArray::get]. **)
378 external const_string : string -> llvalue = "llvm_const_string"
379
380 (** [const_stringz s] returns the constant [i8] array with the values of the
381     characters in the string [s] and a null terminator. This value can in turn
382     be used as the initializer for a global variable.
383     See the method [llvm::ConstantArray::get]. **)
384 external const_stringz : string -> llvalue = "llvm_const_stringz"
385
386 (** [const_array ty elts] returns the constant array of type
387     [array_type ty (Array.length elts)] and containing the values [elts].
388     This value can in turn be used as the initializer for a global variable.
389     See the method [llvm::ConstantArray::get]. **)
390 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
391
392 (** [const_struct elts] returns the structured constant of type
393     [struct_type (Array.map type_of elts)] and containing the values [elts].
394     This value can in turn be used as the initializer for a global variable.
395     See the method [llvm::ConstantStruct::get]. **)
396 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
397
398 (** [const_packed_struct elts] returns the structured constant of type
399     [packed_struct_type (Array.map type_of elts)] and containing the values
400     [elts]. This value can in turn be used as the initializer for a global
401     variable. See the method [llvm::ConstantStruct::get]. **)
402 external const_packed_struct : llvalue array -> llvalue
403                              = "llvm_const_packed_struct"
404
405 (** [const_vector elts] returns the vector constant of type
406     [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
407     values [elts]. See the method [llvm::ConstantVector::get]. **)
408 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
409
410 (*--... Constant expressions ...............................................--*)
411
412 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
413     equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
414     (const_int i64_type 1)) i64_type], but considerably more readable.
415     See the method [llvm::ConstantExpr::getSizeOf]. **)
416 external size_of : lltype -> llvalue = "LLVMSizeOf"
417
418 (** [const_neg c] returns the arithmetic negation of the constant [c].
419     See the method [llvm::ConstantExpr::getNeg]. **)
420 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
421
422 (** [const_not c] returns the bitwise inverse of the constant [c].
423     See the method [llvm::ConstantExpr::getNot]. **)
424 external const_not : llvalue -> llvalue = "LLVMConstNot"
425
426 (** [const_add c1 c2] returns the constant sum of two constants.
427     See the method [llvm::ConstantExpr::getAdd]. **)
428 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
429
430 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
431     constants. See the method [llvm::ConstantExpr::getSub]. **)
432 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
433
434 (** [const_mul c1 c2] returns the constant product of two constants.
435     See the method [llvm::ConstantExpr::getMul]. **)
436 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
437
438 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
439     integer constants.
440     See the method [llvm::ConstantExpr::getUDiv]. **)
441 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
442
443 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
444     integer constants.
445     See the method [llvm::ConstantExpr::]. **)
446 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
447
448 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
449     point constants.
450     See the method [llvm::ConstantExpr::getFDiv]. **)
451 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
452
453 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
454     unsigned integer constants.
455     See the method [llvm::ConstantExpr::getURem]. **)
456 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
457
458 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
459     signed integer constants.
460     See the method [llvm::ConstantExpr::getSRem]. **)
461 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
462
463 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
464     signed floating point constants.
465     See the method [llvm::ConstantExpr::getFRem]. **)
466 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
467
468 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
469     constants.
470     See the method [llvm::ConstantExpr::getAnd]. **)
471 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
472
473 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
474     constants.
475     See the method [llvm::ConstantExpr::getOr]. **)
476 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
477
478 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
479     constants.
480     See the method [llvm::ConstantExpr::getXor]. **)
481 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
482
483 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
484     constants, [c1 pred c2].
485     See the method [llvm::ConstantExpr::getICmp]. **)
486 external const_icmp : int_predicate -> llvalue -> llvalue -> llvalue
487                     = "llvm_const_icmp"
488
489 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
490     point constants, [c1 pred c2].
491     See the method [llvm::ConstantExpr::getFCmp]. **)
492 external const_fcmp : real_predicate -> llvalue -> llvalue -> llvalue
493                     = "llvm_const_fcmp"
494
495 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
496     constant integer [c2].
497     See the method [llvm::ConstantExpr::getShl]. **)
498 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
499
500 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
501     constant integer [c2] with zero extension.
502     See the method [llvm::ConstantExpr::getLShr]. **)
503 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
504
505 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
506     constant integer [c2] with sign extension.
507     See the method [llvm::ConstantExpr::getAShr]. **)
508 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
509
510 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
511     constant integers indices from the array [indices].
512     See the method [llvm::ConstantExpr::getGetElementPtr]. **)
513 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
514
515 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
516     to the smaller integer type [ty].
517     See the method [llvm::ConstantExpr::getTrunc]. **)
518 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
519
520 (** [const_sext c ty] returns the constant sign extension of integer constant
521     [c] to the larger integer type [ty].
522     See the method [llvm::ConstantExpr::getSExt]. **)
523 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
524
525 (** [const_zext c ty] returns the constant zero extension of integer constant
526     [c] to the larger integer type [ty].
527     See the method [llvm::ConstantExpr::getZExt]. **)
528 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
529
530 (** [const_fptrunc c ty] returns the constant truncation of floating point
531     constant [c] to the smaller floating point type [ty].
532     See the method [llvm::ConstantExpr::getFPTrunc]. **)
533 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
534
535 (** [const_fpext c ty] returns the constant extension of floating point constant
536     [c] to the larger floating point type [ty].
537     See the method [llvm::ConstantExpr::getFPExt]. **)
538 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
539
540 (** [const_uitofp c ty] returns the constant floating point conversion of
541     unsigned integer constant [c] to the floating point type [ty].
542     See the method [llvm::ConstantExpr::getUIToFP]. **)
543 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
544
545 (** [const_sitofp c ty] returns the constant floating point conversion of
546     signed integer constant [c] to the floating point type [ty].
547     See the method [llvm::ConstantExpr::getSIToFP]. **)
548 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
549
550 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
551     floating point constant [c] to integer type [ty].
552     See the method [llvm::ConstantExpr::getFPToUI]. **)
553 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
554
555 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
556     floating point constant [c] to integer type [ty].
557     See the method [llvm::ConstantExpr::getFPToSI]. **)
558 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
559
560 (** [const_ptrtoint c ty] returns the constant integer conversion of
561     pointer constant [c] to integer type [ty].
562     See the method [llvm::ConstantExpr::getPtrToInt]. **)
563 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
564
565 (** [const_inttoptr c ty] returns the constant pointer conversion of
566     integer constant [c] to pointer type [ty].
567     See the method [llvm::ConstantExpr::getIntToPtr]. **)
568 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
569
570 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
571     to type [ty] of equal size.
572     See the method [llvm::ConstantExpr::getBitCast]. **)
573 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
574
575 (** [const_select cond t f] returns the constant conditional which returns value
576     [t] if the boolean constant [cond] is true and the value [f] otherwise.
577     See the method [llvm::ConstantExpr::getSelect]. **)
578 external const_select : llvalue -> llvalue -> llvalue -> llvalue
579                       = "LLVMConstSelect"
580
581 (** [const_extractelement vec i] returns the constant [i]th element of
582     constant vector [vec]. [i] must be a constant [i32] value unsigned less than
583     the size of the vector.
584     See the method [llvm::ConstantExpr::getExtractElement]. **)
585 external const_extractelement : llvalue -> llvalue -> llvalue
586                               = "LLVMConstExtractElement"
587
588 (** [const_insertelement vec v i] returns the constant vector with the same
589     elements as constant vector [v] but the [i]th element replaced by the
590     constant [v]. [v] must be a constant value with the type of the vector
591     elements. [i] must be a constant [i32] value unsigned less than the size
592     of the vector.
593     See the method [llvm::ConstantExpr::getInsertElement]. **)
594 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
595                              = "LLVMConstInsertElement"
596
597 (** [const_shufflevector a b mask] returns a constant [shufflevector].
598     See the LLVM Language Reference for details on the [sufflevector]
599     instruction.
600     See the method [llvm::ConstantExpr::getShuffleVector]. **)
601 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
602                              = "LLVMConstShuffleVector"
603
604 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
605
606 (** [is_declaration g] returns [true] if the global value [g] is a declaration
607     only. Returns [false] otherwise.
608     See the method [llvm::GlobalValue::isDeclaration]. **)
609 external is_declaration : llvalue -> bool = "llvm_is_declaration"
610
611 (** [linkage g] returns the linkage of the global value [g].
612     See the method [llvm::GlobalValue::getLinkage]. **)
613 external linkage : llvalue -> linkage = "llvm_linkage"
614
615 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
616     See the method [llvm::GlobalValue::setLinkage]. **)
617 external set_linkage : linkage -> llvalue -> unit = "llvm_set_linkage"
618
619 (** [section g] returns the linker section of the global value [g].
620     See the method [llvm::GlobalValue::getSection]. **)
621 external section : llvalue -> string = "llvm_section"
622
623 (** [set_section s g] sets the linker section of the global value [g] to [s].
624     See the method [llvm::GlobalValue::setSection]. **)
625 external set_section : string -> llvalue -> unit = "llvm_set_section"
626
627 (** [visibility g] returns the linker visibility of the global value [g].
628     See the method [llvm::GlobalValue::getVisibility]. **)
629 external visibility : llvalue -> visibility = "llvm_visibility"
630
631 (** [set_visibility v g] sets the linker visibility of the global value [g] to
632     [v]. See the method [llvm::GlobalValue::setVisibility]. **)
633 external set_visibility : visibility -> llvalue -> unit = "llvm_set_visibility"
634
635 (** [alignment g] returns the required alignment of the global value [g].
636     See the method [llvm::GlobalValue::getAlignment]. **)
637 external alignment : llvalue -> int = "llvm_alignment"
638
639 (** [set_alignment n g] sets the required alignment of the global value [g] to
640     [n] bytes. See the method [llvm::GlobalValue::setAlignment]. **)
641 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
642
643 (*--... Operations on global variables .....................................--*)
644
645 (** [declare_global ty name m] returns a new global variable of type [ty] and
646     with name [name] in module [m]. If such a global variable already exists,
647     it is returned. If the type of the existing global differs, then a bitcast
648     to [ty] is returned. **)
649 external declare_global : lltype -> string -> llmodule -> llvalue
650                         = "llvm_declare_global"
651
652 (** [define_global name init m] returns a new global with name [name] and
653     initializer [init] in module [m]. If the named global already exists, it is
654     renamed.
655     See the constructor of [llvm::GlobalVariable]. **)
656 external define_global : string -> llvalue -> llmodule -> llvalue
657                        = "llvm_define_global"
658
659 (** [lookup_global name m] returns [Some g] if a global variable with name
660     [name] exists in module [m]. If no such global exists, returns [None].
661     See the [llvm::GlobalVariable] constructor. **)
662 external lookup_global : string -> llmodule -> llvalue option
663                        = "llvm_lookup_global"
664
665 (** [delete_global gv] destroys the global variable [gv].
666     See the method [llvm::GlobalVariable::eraseFromParent]. **)
667 external delete_global : llvalue -> unit = "llvm_delete_global"
668
669 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
670     constant. Returns [false] otherwise.
671     See the method [llvm::GlobalVariable::isConstant]. **)
672 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
673
674 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
675     [c] is [true] and not if [c] is [false].
676     See the method [llvm::GlobalVariable::setConstant]. **)
677 external set_global_constant : bool -> llvalue -> unit
678                              = "llvm_set_global_constant"
679
680 (** [has_initializer gv] returns [true] if the global variable [gv] has an
681     initializer and [false] otherwise.
682     See the method [llvm::GlobalVariable::hasInitializer]. **)
683 external has_initializer : llvalue -> bool = "llvm_has_initializer"
684
685 (** [global_initializer gv] returns the initializer for the global variable
686     [gv]. See the method [llvm::GlobalVariable::getInitializer]. **)
687 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
688
689 (** [set_initializer c gv] sets the initializer for the global variable
690     [gv] to the constant [c].
691     See the method [llvm::GlobalVariable::setInitializer]. **)
692 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
693
694 (** [remove_initializer gv] unsets the initializer for the global variable
695     [gv].
696     See the method [llvm::GlobalVariable::setInitializer]. **)
697 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
698
699 (** [is_thread_local gv] returns [true] if the global variable [gv] is
700     thread-local and [false] otherwise.
701     See the method [llvm::GlobalVariable::isThreadLocal]. **)
702 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
703
704 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
705     [c] is [true] and not otherwise.
706     See the method [llvm::GlobalVariable::setThreadLocal]. **)
707 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
708
709 (*--... Operations on functions ............................................--*)
710
711 (** [declare_function name ty m] returns a new function of type [ty] and
712     with name [name] in module [m]. If such a function already exists,
713     it is returned. If the type of the existing function differs, then a bitcast
714     to [ty] is returned. **)
715 external declare_function : string -> lltype -> llmodule -> llvalue
716                           = "llvm_declare_function"
717
718 (** [define_function name ty m] creates a new function with name [name] and
719     type [ty] in module [m]. If the named function already exists, it is
720     renamed. An entry basic block is created in the function.
721     See the constructor of [llvm::GlobalVariable]. **)
722 external define_function : string -> lltype -> llmodule -> llvalue
723                          = "llvm_define_function"
724
725 (** [lookup_function name m] returns [Some f] if a function with name
726     [name] exists in module [m]. If no such function exists, returns [None].
727     See the method [llvm::Module] constructor. **)
728 external lookup_function : string -> llmodule -> llvalue option
729                          = "llvm_lookup_function"
730
731 (** [delete_function f] destroys the function [f].
732     See the method [llvm::Function::eraseFromParent]. **)
733 external delete_function : llvalue -> unit = "llvm_delete_function"
734
735 (** [params f] returns the parameters of function [f].
736     See the method [llvm::Function::getArgumentList]. **)
737 external params : llvalue -> llvalue array = "llvm_params"
738
739 (** [param f n] returns the [n]th parameter of function [f].
740     See the method [llvm::Function::getArgumentList]. **)
741 external param : llvalue -> int -> llvalue = "llvm_param"
742
743 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
744     See the method [llvm::Function::isIntrinsic]. **)
745 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
746
747 (** [function_call_conv f] returns the calling convention of the function [f].
748     See the method [llvm::Function::getCallingConv]. **)
749 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
750
751 (** [set_function_call_conv cc f] sets the calling convention of the function
752     [f] to the calling convention numbered [cc].
753     See the method [llvm::Function::setCallingConv]. **)
754 external set_function_call_conv : int -> llvalue -> unit
755                                 = "llvm_set_function_call_conv"
756
757 (*--... Operations on basic blocks .........................................--*)
758
759 (** [basic_blocks fn] returns the basic blocks of the function [f].
760     See the method [llvm::Function::getBasicBlockList]. **)
761 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
762
763 (** [entry_block fn] returns the entry basic block of the function [f].
764     See the method [llvm::Function::getEntryBlock]. **)
765 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
766
767 (** [delete_block bb] deletes the basic block [bb].
768     See the method [llvm::BasicBlock::eraseFromParent]. **)
769 external delete_block : llbasicblock -> unit = "llvm_delete_block"
770
771 (** [append_block name f] creates a new basic block named [name] at the end of
772     function [f].
773     See the constructor of [llvm::BasicBlock]. **)
774 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
775
776 (** [insert_block name bb] creates a new basic block named [name] before the
777     basic block [bb].
778     See the constructor of [llvm::BasicBlock]. **)
779 external insert_block : string -> llbasicblock -> llbasicblock
780                       = "llvm_insert_block"
781
782 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
783 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
784
785 (** [value_is_block v] returns [true] if the value [v] is a basic block and
786     [false] otherwise.
787     Similar to [llvm::isa<BasicBlock>]. **)
788 external value_is_block : llvalue -> bool = "llvm_value_is_block"
789
790 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
791 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
792
793 (*--... Operations on phi nodes ............................................--*)
794
795 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
796     with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
797 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
798                       = "llvm_add_incoming"
799
800 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
801     See the method [llvm::PHINode::getIncomingValue]. **)
802 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
803
804
805 (*===-- Instruction builders ----------------------------------------------===*)
806
807 (** [builder_before ins] creates an instruction builder positioned before the
808     instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
809 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
810
811 (** [builder_at_end bb] creates an instruction builder positioned at the end of
812     the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
813 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
814
815 (** [position_before ins b] moves the instruction builder [b] to before the
816     instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
817 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
818
819 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
820     basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
821 external position_at_end : llbasicblock -> llbuilder -> unit
822                          = "llvm_position_at_end"
823
824 (*--... Terminators ........................................................--*)
825
826 (** [build_ret_void b] creates a
827     [ret void]
828     instruction at the position specified by the instruction builder [b].
829     See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
830 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
831
832 (** [build_ret v b] creates a
833     [ret %v]
834     instruction at the position specified by the instruction builder [b].
835     See the method [llvm::LLVMBuilder::CreateRet]. **)
836 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
837
838 (** [build_br bb b] creates a
839     [b %bb]
840     instruction at the position specified by the instruction builder [b].
841     See the method [llvm::LLVMBuilder::CreateBr]. **)
842 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
843
844 (** [build_cond_br cond tbb fbb b] creates a
845     [b %cond, %tbb, %fbb]
846     instruction at the position specified by the instruction builder [b].
847     See the method [llvm::LLVMBuilder::CreateCondBr]. **)
848 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
849                          llvalue = "llvm_build_cond_br"
850
851 (** [build_switch case elsebb b] creates an empty
852     [switch %case, %elsebb]
853     instruction at the position specified by the instruction builder [b].
854     See the method [llvm::LLVMBuilder::CreateSwitch]. **)
855 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
856                       = "llvm_build_switch"
857
858 (** [build_invoke fn args tobb unwindbb name b] creates an
859     [%name = invoke %fn(args) to %tobb unwind %unwindbb]
860     instruction at the position specified by the instruction builder [b].
861     See the method [llvm::LLVMBuilder::CreateInvoke]. **)
862 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
863                         llbasicblock -> string -> llbuilder -> llvalue
864                       = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
865
866 (** [build_unwind b] creates an
867     [unwind]
868     instruction at the position specified by the instruction builder [b].
869     See the method [llvm::LLVMBuilder::CreateUnwind]. **)
870 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
871
872 (** [build_unreachable b] creates an
873     [unreachable]
874     instruction at the position specified by the instruction builder [b].
875     See the method [llvm::LLVMBuilder::CreateUnwind]. **)
876 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
877
878 (*--... Arithmetic .........................................................--*)
879
880 (** [build_add x y name b] creates a
881     [%name = add %x, %y]
882     instruction at the position specified by the instruction builder [b].
883     See the method [llvm::LLVMBuilder::CreateAdd]. **)
884 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
885                    = "llvm_build_add"
886
887 (** [build_sub x y name b] creates a
888     [%name = sub %x, %y]
889     instruction at the position specified by the instruction builder [b].
890     See the method [llvm::LLVMBuilder::CreateSub]. **)
891 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
892                    = "llvm_build_sub"
893
894 (** [build_mul x y name b] creates a
895     [%name = mul %x, %y]
896     instruction at the position specified by the instruction builder [b].
897     See the method [llvm::LLVMBuilder::CreateMul]. **)
898 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
899                    = "llvm_build_mul"
900
901 (** [build_udiv x y name b] creates a
902     [%name = udiv %x, %y]
903     instruction at the position specified by the instruction builder [b].
904     See the method [llvm::LLVMBuilder::CreateUDiv]. **)
905 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
906                     = "llvm_build_udiv"
907
908 (** [build_sdiv x y name b] creates a
909     [%name = sdiv %x, %y]
910     instruction at the position specified by the instruction builder [b].
911     See the method [llvm::LLVMBuilder::CreateSDiv]. **)
912 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
913                     = "llvm_build_sdiv"
914
915 (** [build_fdiv x y name b] creates a
916     [%name = fdiv %x, %y]
917     instruction at the position specified by the instruction builder [b].
918     See the method [llvm::LLVMBuilder::CreateFDiv]. **)
919 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
920                     = "llvm_build_fdiv"
921
922 (** [build_urem x y name b] creates a
923     [%name = urem %x, %y]
924     instruction at the position specified by the instruction builder [b].
925     See the method [llvm::LLVMBuilder::CreateURem]. **)
926 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
927                     = "llvm_build_urem"
928
929 (** [build_SRem x y name b] creates a
930     [%name = srem %x, %y]
931     instruction at the position specified by the instruction builder [b].
932     See the method [llvm::LLVMBuilder::CreateSRem]. **)
933 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
934                     = "llvm_build_srem"
935
936 (** [build_frem x y name b] creates a
937     [%name = frem %x, %y]
938     instruction at the position specified by the instruction builder [b].
939     See the method [llvm::LLVMBuilder::CreateFRem]. **)
940 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
941                     = "llvm_build_frem"
942
943 (** [build_shl x y name b] creates a
944     [%name = shl %x, %y]
945     instruction at the position specified by the instruction builder [b].
946     See the method [llvm::LLVMBuilder::CreateShl]. **)
947 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
948                    = "llvm_build_shl"
949
950 (** [build_lshr x y name b] creates a
951     [%name = lshr %x, %y]
952     instruction at the position specified by the instruction builder [b].
953     See the method [llvm::LLVMBuilder::CreateLShr]. **)
954 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
955                     = "llvm_build_lshr"
956
957 (** [build_ashr x y name b] creates a
958     [%name = ashr %x, %y]
959     instruction at the position specified by the instruction builder [b].
960     See the method [llvm::LLVMBuilder::CreateAShr]. **)
961 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
962                     = "llvm_build_ashr"
963
964 (** [build_and x y name b] creates a
965     [%name = and %x, %y]
966     instruction at the position specified by the instruction builder [b].
967     See the method [llvm::LLVMBuilder::CreateAnd]. **)
968 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
969                    = "llvm_build_and"
970
971 (** [build_or x y name b] creates a
972     [%name = or %x, %y]
973     instruction at the position specified by the instruction builder [b].
974     See the method [llvm::LLVMBuilder::CreateOr]. **)
975 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
976                   = "llvm_build_or"
977
978 (** [build_xor x y name b] creates a
979     [%name = xor %x, %y]
980     instruction at the position specified by the instruction builder [b].
981     See the method [llvm::LLVMBuilder::CreateXor]. **)
982 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
983                    = "llvm_build_xor"
984
985 (** [build_neg x name b] creates a
986     [%name = sub 0, %x]
987     instruction at the position specified by the instruction builder [b].
988     [-0.0] is used for floating point types to compute the correct sign.
989     See the method [llvm::LLVMBuilder::CreateNeg]. **)
990 external build_neg : llvalue -> string -> llbuilder -> llvalue
991                    = "llvm_build_neg"
992
993 (** [build_xor x name b] creates a
994     [%name = xor %x, -1]
995     instruction at the position specified by the instruction builder [b].
996     [-1] is the correct "all ones" value for the type of [x].
997     See the method [llvm::LLVMBuilder::CreateXor]. **)
998 external build_not : llvalue -> string -> llbuilder -> llvalue
999                    = "llvm_build_not"
1000
1001 (*--... Memory .............................................................--*)
1002
1003 (** [build_malloc ty name b] creates a
1004     [%name = malloc %ty]
1005     instruction at the position specified by the instruction builder [b].
1006     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1007 external build_malloc : lltype -> string -> llbuilder -> llvalue
1008                       = "llvm_build_malloc"
1009
1010 (** [build_array_malloc ty n name b] creates a
1011     [%name = malloc %ty, %n]
1012     instruction at the position specified by the instruction builder [b].
1013     See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1014 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1015                               llvalue = "llvm_build_array_malloc"
1016
1017 (** [build_alloca ty name b] creates a
1018     [%name = alloca %ty]
1019     instruction at the position specified by the instruction builder [b].
1020     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1021 external build_alloca : lltype -> string -> llbuilder -> llvalue
1022                       = "llvm_build_alloca"
1023
1024 (** [build_array_alloca ty n name b] creates a
1025     [%name = alloca %ty, %n]
1026     instruction at the position specified by the instruction builder [b].
1027     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1028 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1029                               llvalue = "llvm_build_array_alloca"
1030
1031 (** [build_free v b] creates a
1032     [free %v]
1033     instruction at the position specified by the instruction builder [b].
1034     See the method [llvm::LLVMBuilder::CreateFree]. **)
1035 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1036
1037 (** [build_load v name b] creates a
1038     [%name = load %v]
1039     instruction at the position specified by the instruction builder [b].
1040     See the method [llvm::LLVMBuilder::CreateLoad]. **)
1041 external build_load : llvalue -> string -> llbuilder -> llvalue
1042                     = "llvm_build_load"
1043
1044 (** [build_store v p b] creates a
1045     [store %v, %p]
1046     instruction at the position specified by the instruction builder [b].
1047     See the method [llvm::LLVMBuilder::CreateStore]. **)
1048 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1049                      = "llvm_build_store"
1050
1051 (** [build_store p indices name b] creates a
1052     [%name = gep %p, indices...]
1053     instruction at the position specified by the instruction builder [b].
1054     See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1055 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1056                    = "llvm_build_gep"
1057
1058 (*--... Casts ..............................................................--*)
1059
1060 (** [build_trunc v ty name b] creates a
1061     [%name = trunc %p to %ty]
1062     instruction at the position specified by the instruction builder [b].
1063     See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1064 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1065                      = "llvm_build_trunc"
1066
1067 (** [build_zext v ty name b] creates a
1068     [%name = zext %p to %ty]
1069     instruction at the position specified by the instruction builder [b].
1070     See the method [llvm::LLVMBuilder::CreateZExt]. **)
1071 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1072                     = "llvm_build_zext"
1073
1074 (** [build_sext v ty name b] creates a
1075     [%name = sext %p to %ty]
1076     instruction at the position specified by the instruction builder [b].
1077     See the method [llvm::LLVMBuilder::CreateSExt]. **)
1078 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1079                     = "llvm_build_sext"
1080
1081 (** [build_fptoui v ty name b] creates a
1082     [%name = fptoui %p to %ty]
1083     instruction at the position specified by the instruction builder [b].
1084     See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1085 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1086                       = "llvm_build_fptoui"
1087
1088 (** [build_fptosi v ty name b] creates a
1089     [%name = fptosi %p to %ty]
1090     instruction at the position specified by the instruction builder [b].
1091     See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1092 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1093                       = "llvm_build_fptosi"
1094
1095 (** [build_uitofp v ty name b] creates a
1096     [%name = uitofp %p to %ty]
1097     instruction at the position specified by the instruction builder [b].
1098     See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1099 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1100                       = "llvm_build_uitofp"
1101
1102 (** [build_sitofp v ty name b] creates a
1103     [%name = sitofp %p to %ty]
1104     instruction at the position specified by the instruction builder [b].
1105     See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1106 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1107                       = "llvm_build_sitofp"
1108
1109 (** [build_fptrunc v ty name b] creates a
1110     [%name = fptrunc %p to %ty]
1111     instruction at the position specified by the instruction builder [b].
1112     See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1113 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1114                        = "llvm_build_fptrunc"
1115
1116 (** [build_fpext v ty name b] creates a
1117     [%name = fpext %p to %ty]
1118     instruction at the position specified by the instruction builder [b].
1119     See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1120 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1121                      = "llvm_build_fpext"
1122
1123 (** [build_ptrtoint v ty name b] creates a
1124     [%name = prtotint %p to %ty]
1125     instruction at the position specified by the instruction builder [b].
1126     See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1127 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1128                         = "llvm_build_prttoint"
1129
1130 (** [build_inttoptr v ty name b] creates a
1131     [%name = inttoptr %p to %ty]
1132     instruction at the position specified by the instruction builder [b].
1133     See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1134 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1135                         = "llvm_build_inttoptr"
1136
1137 (** [build_bitcast v ty name b] creates a
1138     [%name = bitcast %p to %ty]
1139     instruction at the position specified by the instruction builder [b].
1140     See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1141 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1142                        = "llvm_build_bitcast"
1143
1144 (*--... Comparisons ........................................................--*)
1145
1146 (** [build_icmp pred x y name b] creates a
1147     [%name = icmp %pred %x, %y]
1148     instruction at the position specified by the instruction builder [b].
1149     See the method [llvm::LLVMBuilder::CreateICmp]. **)
1150 external build_icmp : int_predicate -> llvalue -> llvalue -> string ->
1151                       llbuilder -> llvalue = "llvm_build_icmp"
1152
1153 (** [build_fcmp pred x y name b] creates a
1154     [%name = fcmp %pred %x, %y]
1155     instruction at the position specified by the instruction builder [b].
1156     See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1157 external build_fcmp : real_predicate -> llvalue -> llvalue -> string ->
1158                       llbuilder -> llvalue = "llvm_build_fcmp"
1159
1160 (*--... Miscellaneous instructions .........................................--*)
1161
1162 (** [build_phi incoming name b] creates a
1163     [%name = phi %incoming]
1164     instruction at the position specified by the instruction builder [b].
1165     [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1166     See the method [llvm::LLVMBuilder::CreatePHI]. **)
1167 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1168                      llvalue = "llvm_build_phi"
1169
1170 (** [build_call fn args name b] creates a
1171     [%name = call %fn(args...)]
1172     instruction at the position specified by the instruction builder [b].
1173     See the method [llvm::LLVMBuilder::CreateCall]. **)
1174 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1175                     = "llvm_build_call"
1176
1177 (** [build_select cond thenv elsev name b] creates a
1178     [%name = select %cond, %thenv, %elsev]
1179     instruction at the position specified by the instruction builder [b].
1180     See the method [llvm::LLVMBuilder::CreateSelect]. **)
1181 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1182                         llvalue = "llvm_build_select"
1183
1184 (** [build_va_arg valist argty name b] creates a
1185     [%name = va_arg %valist, %argty]
1186     instruction at the position specified by the instruction builder [b].
1187     See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1188 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1189                       = "llvm_build_va_arg"
1190
1191 (** [build_extractelement vec i name b] creates a
1192     [%name = extractelement %vec, %i]
1193     instruction at the position specified by the instruction builder [b].
1194     See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1195 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1196                                 llvalue = "llvm_build_extractelement"
1197
1198 (** [build_insertelement vec elt i name b] creates a
1199     [%name = insertelement %vec, %elt, %i]
1200     instruction at the position specified by the instruction builder [b].
1201     See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1202 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1203                                llbuilder -> llvalue = "llvm_build_insertelement"
1204
1205 (** [build_shufflevector veca vecb mask name b] creates a
1206     [%name = shufflevector %veca, %vecb, %mask]
1207     instruction at the position specified by the instruction builder [b].
1208     See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1209 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1210                                llbuilder -> llvalue = "llvm_build_shufflevector"