Adding a collector name attribute to Function in the IR. These
[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 (** [collector f] returns [Some name] if the function [f] has a garbage
758     collection algorithm specified and [None] otherwise.
759     See the method [llvm::Function::getCollector]. **)
760 external collector : llvalue -> string option = "llvm_collector"
761
762 (** [set_collector gc f] sets the collection algorithm for the function [f] to
763     [gc]. See the method [llvm::Function::setCollector]. **)
764 external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
765
766 (*--... Operations on basic blocks .........................................--*)
767
768 (** [basic_blocks fn] returns the basic blocks of the function [f].
769     See the method [llvm::Function::getBasicBlockList]. **)
770 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
771
772 (** [entry_block fn] returns the entry basic block of the function [f].
773     See the method [llvm::Function::getEntryBlock]. **)
774 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
775
776 (** [delete_block bb] deletes the basic block [bb].
777     See the method [llvm::BasicBlock::eraseFromParent]. **)
778 external delete_block : llbasicblock -> unit = "llvm_delete_block"
779
780 (** [append_block name f] creates a new basic block named [name] at the end of
781     function [f].
782     See the constructor of [llvm::BasicBlock]. **)
783 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
784
785 (** [insert_block name bb] creates a new basic block named [name] before the
786     basic block [bb].
787     See the constructor of [llvm::BasicBlock]. **)
788 external insert_block : string -> llbasicblock -> llbasicblock
789                       = "llvm_insert_block"
790
791 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
792 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
793
794 (** [value_is_block v] returns [true] if the value [v] is a basic block and
795     [false] otherwise.
796     Similar to [llvm::isa<BasicBlock>]. **)
797 external value_is_block : llvalue -> bool = "llvm_value_is_block"
798
799 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
800 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
801
802 (*--... Operations on phi nodes ............................................--*)
803
804 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
805     with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
806 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
807                       = "llvm_add_incoming"
808
809 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
810     See the method [llvm::PHINode::getIncomingValue]. **)
811 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
812
813
814 (*===-- Instruction builders ----------------------------------------------===*)
815
816 (** [builder_before ins] creates an instruction builder positioned before the
817     instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
818 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
819
820 (** [builder_at_end bb] creates an instruction builder positioned at the end of
821     the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
822 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
823
824 (** [position_before ins b] moves the instruction builder [b] to before the
825     instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
826 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
827
828 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
829     basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
830 external position_at_end : llbasicblock -> llbuilder -> unit
831                          = "llvm_position_at_end"
832
833 (*--... Terminators ........................................................--*)
834
835 (** [build_ret_void b] creates a
836     [ret void]
837     instruction at the position specified by the instruction builder [b].
838     See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
839 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
840
841 (** [build_ret v b] creates a
842     [ret %v]
843     instruction at the position specified by the instruction builder [b].
844     See the method [llvm::LLVMBuilder::CreateRet]. **)
845 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
846
847 (** [build_br bb b] creates a
848     [b %bb]
849     instruction at the position specified by the instruction builder [b].
850     See the method [llvm::LLVMBuilder::CreateBr]. **)
851 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
852
853 (** [build_cond_br cond tbb fbb b] creates a
854     [b %cond, %tbb, %fbb]
855     instruction at the position specified by the instruction builder [b].
856     See the method [llvm::LLVMBuilder::CreateCondBr]. **)
857 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
858                          llvalue = "llvm_build_cond_br"
859
860 (** [build_switch case elsebb b] creates an empty
861     [switch %case, %elsebb]
862     instruction at the position specified by the instruction builder [b].
863     See the method [llvm::LLVMBuilder::CreateSwitch]. **)
864 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
865                       = "llvm_build_switch"
866
867 (** [build_invoke fn args tobb unwindbb name b] creates an
868     [%name = invoke %fn(args) to %tobb unwind %unwindbb]
869     instruction at the position specified by the instruction builder [b].
870     See the method [llvm::LLVMBuilder::CreateInvoke]. **)
871 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
872                         llbasicblock -> string -> llbuilder -> llvalue
873                       = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
874
875 (** [build_unwind b] creates an
876     [unwind]
877     instruction at the position specified by the instruction builder [b].
878     See the method [llvm::LLVMBuilder::CreateUnwind]. **)
879 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
880
881 (** [build_unreachable b] creates an
882     [unreachable]
883     instruction at the position specified by the instruction builder [b].
884     See the method [llvm::LLVMBuilder::CreateUnwind]. **)
885 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
886
887 (*--... Arithmetic .........................................................--*)
888
889 (** [build_add x y name b] creates a
890     [%name = add %x, %y]
891     instruction at the position specified by the instruction builder [b].
892     See the method [llvm::LLVMBuilder::CreateAdd]. **)
893 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
894                    = "llvm_build_add"
895
896 (** [build_sub x y name b] creates a
897     [%name = sub %x, %y]
898     instruction at the position specified by the instruction builder [b].
899     See the method [llvm::LLVMBuilder::CreateSub]. **)
900 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
901                    = "llvm_build_sub"
902
903 (** [build_mul x y name b] creates a
904     [%name = mul %x, %y]
905     instruction at the position specified by the instruction builder [b].
906     See the method [llvm::LLVMBuilder::CreateMul]. **)
907 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
908                    = "llvm_build_mul"
909
910 (** [build_udiv x y name b] creates a
911     [%name = udiv %x, %y]
912     instruction at the position specified by the instruction builder [b].
913     See the method [llvm::LLVMBuilder::CreateUDiv]. **)
914 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
915                     = "llvm_build_udiv"
916
917 (** [build_sdiv x y name b] creates a
918     [%name = sdiv %x, %y]
919     instruction at the position specified by the instruction builder [b].
920     See the method [llvm::LLVMBuilder::CreateSDiv]. **)
921 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
922                     = "llvm_build_sdiv"
923
924 (** [build_fdiv x y name b] creates a
925     [%name = fdiv %x, %y]
926     instruction at the position specified by the instruction builder [b].
927     See the method [llvm::LLVMBuilder::CreateFDiv]. **)
928 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
929                     = "llvm_build_fdiv"
930
931 (** [build_urem x y name b] creates a
932     [%name = urem %x, %y]
933     instruction at the position specified by the instruction builder [b].
934     See the method [llvm::LLVMBuilder::CreateURem]. **)
935 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
936                     = "llvm_build_urem"
937
938 (** [build_SRem x y name b] creates a
939     [%name = srem %x, %y]
940     instruction at the position specified by the instruction builder [b].
941     See the method [llvm::LLVMBuilder::CreateSRem]. **)
942 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
943                     = "llvm_build_srem"
944
945 (** [build_frem x y name b] creates a
946     [%name = frem %x, %y]
947     instruction at the position specified by the instruction builder [b].
948     See the method [llvm::LLVMBuilder::CreateFRem]. **)
949 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
950                     = "llvm_build_frem"
951
952 (** [build_shl x y name b] creates a
953     [%name = shl %x, %y]
954     instruction at the position specified by the instruction builder [b].
955     See the method [llvm::LLVMBuilder::CreateShl]. **)
956 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
957                    = "llvm_build_shl"
958
959 (** [build_lshr x y name b] creates a
960     [%name = lshr %x, %y]
961     instruction at the position specified by the instruction builder [b].
962     See the method [llvm::LLVMBuilder::CreateLShr]. **)
963 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
964                     = "llvm_build_lshr"
965
966 (** [build_ashr x y name b] creates a
967     [%name = ashr %x, %y]
968     instruction at the position specified by the instruction builder [b].
969     See the method [llvm::LLVMBuilder::CreateAShr]. **)
970 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
971                     = "llvm_build_ashr"
972
973 (** [build_and x y name b] creates a
974     [%name = and %x, %y]
975     instruction at the position specified by the instruction builder [b].
976     See the method [llvm::LLVMBuilder::CreateAnd]. **)
977 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
978                    = "llvm_build_and"
979
980 (** [build_or x y name b] creates a
981     [%name = or %x, %y]
982     instruction at the position specified by the instruction builder [b].
983     See the method [llvm::LLVMBuilder::CreateOr]. **)
984 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
985                   = "llvm_build_or"
986
987 (** [build_xor x y name b] creates a
988     [%name = xor %x, %y]
989     instruction at the position specified by the instruction builder [b].
990     See the method [llvm::LLVMBuilder::CreateXor]. **)
991 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
992                    = "llvm_build_xor"
993
994 (** [build_neg x name b] creates a
995     [%name = sub 0, %x]
996     instruction at the position specified by the instruction builder [b].
997     [-0.0] is used for floating point types to compute the correct sign.
998     See the method [llvm::LLVMBuilder::CreateNeg]. **)
999 external build_neg : llvalue -> string -> llbuilder -> llvalue
1000                    = "llvm_build_neg"
1001
1002 (** [build_xor x name b] creates a
1003     [%name = xor %x, -1]
1004     instruction at the position specified by the instruction builder [b].
1005     [-1] is the correct "all ones" value for the type of [x].
1006     See the method [llvm::LLVMBuilder::CreateXor]. **)
1007 external build_not : llvalue -> string -> llbuilder -> llvalue
1008                    = "llvm_build_not"
1009
1010 (*--... Memory .............................................................--*)
1011
1012 (** [build_malloc ty name b] creates a
1013     [%name = malloc %ty]
1014     instruction at the position specified by the instruction builder [b].
1015     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1016 external build_malloc : lltype -> string -> llbuilder -> llvalue
1017                       = "llvm_build_malloc"
1018
1019 (** [build_array_malloc ty n name b] creates a
1020     [%name = malloc %ty, %n]
1021     instruction at the position specified by the instruction builder [b].
1022     See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1023 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
1024                               llvalue = "llvm_build_array_malloc"
1025
1026 (** [build_alloca ty name b] creates a
1027     [%name = alloca %ty]
1028     instruction at the position specified by the instruction builder [b].
1029     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1030 external build_alloca : lltype -> string -> llbuilder -> llvalue
1031                       = "llvm_build_alloca"
1032
1033 (** [build_array_alloca ty n name b] creates a
1034     [%name = alloca %ty, %n]
1035     instruction at the position specified by the instruction builder [b].
1036     See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1037 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
1038                               llvalue = "llvm_build_array_alloca"
1039
1040 (** [build_free v b] creates a
1041     [free %v]
1042     instruction at the position specified by the instruction builder [b].
1043     See the method [llvm::LLVMBuilder::CreateFree]. **)
1044 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
1045
1046 (** [build_load v name b] creates a
1047     [%name = load %v]
1048     instruction at the position specified by the instruction builder [b].
1049     See the method [llvm::LLVMBuilder::CreateLoad]. **)
1050 external build_load : llvalue -> string -> llbuilder -> llvalue
1051                     = "llvm_build_load"
1052
1053 (** [build_store v p b] creates a
1054     [store %v, %p]
1055     instruction at the position specified by the instruction builder [b].
1056     See the method [llvm::LLVMBuilder::CreateStore]. **)
1057 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
1058                      = "llvm_build_store"
1059
1060 (** [build_store p indices name b] creates a
1061     [%name = gep %p, indices...]
1062     instruction at the position specified by the instruction builder [b].
1063     See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1064 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1065                    = "llvm_build_gep"
1066
1067 (*--... Casts ..............................................................--*)
1068
1069 (** [build_trunc v ty name b] creates a
1070     [%name = trunc %p to %ty]
1071     instruction at the position specified by the instruction builder [b].
1072     See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1073 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1074                      = "llvm_build_trunc"
1075
1076 (** [build_zext v ty name b] creates a
1077     [%name = zext %p to %ty]
1078     instruction at the position specified by the instruction builder [b].
1079     See the method [llvm::LLVMBuilder::CreateZExt]. **)
1080 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
1081                     = "llvm_build_zext"
1082
1083 (** [build_sext v ty name b] creates a
1084     [%name = sext %p to %ty]
1085     instruction at the position specified by the instruction builder [b].
1086     See the method [llvm::LLVMBuilder::CreateSExt]. **)
1087 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
1088                     = "llvm_build_sext"
1089
1090 (** [build_fptoui v ty name b] creates a
1091     [%name = fptoui %p to %ty]
1092     instruction at the position specified by the instruction builder [b].
1093     See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1094 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
1095                       = "llvm_build_fptoui"
1096
1097 (** [build_fptosi v ty name b] creates a
1098     [%name = fptosi %p to %ty]
1099     instruction at the position specified by the instruction builder [b].
1100     See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1101 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
1102                       = "llvm_build_fptosi"
1103
1104 (** [build_uitofp v ty name b] creates a
1105     [%name = uitofp %p to %ty]
1106     instruction at the position specified by the instruction builder [b].
1107     See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1108 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1109                       = "llvm_build_uitofp"
1110
1111 (** [build_sitofp v ty name b] creates a
1112     [%name = sitofp %p to %ty]
1113     instruction at the position specified by the instruction builder [b].
1114     See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1115 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
1116                       = "llvm_build_sitofp"
1117
1118 (** [build_fptrunc v ty name b] creates a
1119     [%name = fptrunc %p to %ty]
1120     instruction at the position specified by the instruction builder [b].
1121     See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1122 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
1123                        = "llvm_build_fptrunc"
1124
1125 (** [build_fpext v ty name b] creates a
1126     [%name = fpext %p to %ty]
1127     instruction at the position specified by the instruction builder [b].
1128     See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1129 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
1130                      = "llvm_build_fpext"
1131
1132 (** [build_ptrtoint v ty name b] creates a
1133     [%name = prtotint %p to %ty]
1134     instruction at the position specified by the instruction builder [b].
1135     See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1136 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
1137                         = "llvm_build_prttoint"
1138
1139 (** [build_inttoptr v ty name b] creates a
1140     [%name = inttoptr %p to %ty]
1141     instruction at the position specified by the instruction builder [b].
1142     See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1143 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
1144                         = "llvm_build_inttoptr"
1145
1146 (** [build_bitcast v ty name b] creates a
1147     [%name = bitcast %p to %ty]
1148     instruction at the position specified by the instruction builder [b].
1149     See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1150 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
1151                        = "llvm_build_bitcast"
1152
1153 (*--... Comparisons ........................................................--*)
1154
1155 (** [build_icmp pred x y name b] creates a
1156     [%name = icmp %pred %x, %y]
1157     instruction at the position specified by the instruction builder [b].
1158     See the method [llvm::LLVMBuilder::CreateICmp]. **)
1159 external build_icmp : int_predicate -> llvalue -> llvalue -> string ->
1160                       llbuilder -> llvalue = "llvm_build_icmp"
1161
1162 (** [build_fcmp pred x y name b] creates a
1163     [%name = fcmp %pred %x, %y]
1164     instruction at the position specified by the instruction builder [b].
1165     See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1166 external build_fcmp : real_predicate -> llvalue -> llvalue -> string ->
1167                       llbuilder -> llvalue = "llvm_build_fcmp"
1168
1169 (*--... Miscellaneous instructions .........................................--*)
1170
1171 (** [build_phi incoming name b] creates a
1172     [%name = phi %incoming]
1173     instruction at the position specified by the instruction builder [b].
1174     [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1175     See the method [llvm::LLVMBuilder::CreatePHI]. **)
1176 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
1177                      llvalue = "llvm_build_phi"
1178
1179 (** [build_call fn args name b] creates a
1180     [%name = call %fn(args...)]
1181     instruction at the position specified by the instruction builder [b].
1182     See the method [llvm::LLVMBuilder::CreateCall]. **)
1183 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1184                     = "llvm_build_call"
1185
1186 (** [build_select cond thenv elsev name b] creates a
1187     [%name = select %cond, %thenv, %elsev]
1188     instruction at the position specified by the instruction builder [b].
1189     See the method [llvm::LLVMBuilder::CreateSelect]. **)
1190 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
1191                         llvalue = "llvm_build_select"
1192
1193 (** [build_va_arg valist argty name b] creates a
1194     [%name = va_arg %valist, %argty]
1195     instruction at the position specified by the instruction builder [b].
1196     See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1197 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
1198                       = "llvm_build_va_arg"
1199
1200 (** [build_extractelement vec i name b] creates a
1201     [%name = extractelement %vec, %i]
1202     instruction at the position specified by the instruction builder [b].
1203     See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1204 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
1205                                 llvalue = "llvm_build_extractelement"
1206
1207 (** [build_insertelement vec elt i name b] creates a
1208     [%name = insertelement %vec, %elt, %i]
1209     instruction at the position specified by the instruction builder [b].
1210     See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1211 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
1212                                llbuilder -> llvalue = "llvm_build_insertelement"
1213
1214 (** [build_shufflevector veca vecb mask name b] creates a
1215     [%name = shufflevector %veca, %vecb, %mask]
1216     instruction at the position specified by the instruction builder [b].
1217     See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1218 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
1219                                llbuilder -> llvalue = "llvm_build_shufflevector"