llvm.org GIT mirror llvm / 3b646de
This patch cleans up the OCaml bindings so that they format nicely with ocamldoc. It does not yet hook into the build system, though. Patch by Erick Tryzelaar! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48095 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 12 years ago
6 changed file(s) with 382 addition(s) and 358 deletion(s). Raw diff Collapse all Expand all
44 * This file is distributed under the University of Illinois Open Source
55 * License. See LICENSE.TXT for details.
66 *
7 *===----------------------------------------------------------------------===
8 *
9 * This interface provides an ocaml API for LLVM IR analyses, the classes in
10 * the Analysis library.
11 *
127 *===----------------------------------------------------------------------===*)
138
9 (** Intermediate representation analysis.
10
11 This interface provides an ocaml API for LLVM IR analyses, the classes in
12 the Analysis library. *)
1413
1514 (** [verify_module m] returns [None] if the module [m] is valid, and
1615 [Some reason] if it is invalid. [reason] is a string containing a
17 human-readable validation report. See [llvm::verifyModule]. **)
16 human-readable validation report. See [llvm::verifyModule]. *)
1817 external verify_module : Llvm.llmodule -> string option = "llvm_verify_module"
1918
2019 (** [verify_function f] returns [None] if the function [f] is valid, and
2120 [Some reason] if it is invalid. [reason] is a string containing a
22 human-readable validation report. See [llvm::verifyFunction]. **)
21 human-readable validation report. See [llvm::verifyFunction]. *)
2322 external verify_function : Llvm.llvalue -> bool = "llvm_verify_function"
2423
2524 (** [verify_module m] returns if the module [m] is valid, but prints a
26 validation report to [stderr] and aborts the program if it is invalid. See
27 [llvm::verifyModule]. **)
25 validation report to [stderr] and aborts the program if it is invalid. See
26 [llvm::verifyModule]. *)
2827 external assert_valid_module : Llvm.llmodule -> unit
2928 = "llvm_assert_valid_module"
3029
3130 (** [verify_function f] returns if the function [f] is valid, but prints a
32 validation report to [stderr] and aborts the program if it is invalid. See
33 [llvm::verifyFunction]. **)
31 validation report to [stderr] and aborts the program if it is invalid. See
32 [llvm::verifyFunction]. *)
3433 external assert_valid_function : Llvm.llvalue -> unit
3534 = "llvm_assert_valid_function"
44 * This file is distributed under the University of Illinois Open Source
55 * License. See LICENSE.TXT for details.
66 *
7 *===----------------------------------------------------------------------===
8 *
9 * This interface provides an ocaml API for the LLVM bitcode reader, the
10 * classes in the Bitreader library.
11 *
127 *===----------------------------------------------------------------------===*)
138
9 (** Bitcode reader.
10
11 This interface provides an ocaml API for the LLVM bitcode reader, the
12 classes in the Bitreader library. *)
1413
1514 exception Error of string
1615
1716 (** [read_bitcode_file path] reads the bitcode for a new module [m] from the
1817 file at [path]. Returns [Success m] if successful, and [Failure msg]
1918 otherwise, where [msg] is a description of the error encountered.
20 See the function [llvm::getBitcodeModuleProvider]. **)
19 See the function [llvm::getBitcodeModuleProvider]. *)
2120 external get_module_provider : Llvm.llmemorybuffer -> Llvm.llmoduleprovider
2221 = "llvm_get_module_provider"
2322
2423 (** [parse_bitcode mb] parses the bitcode for a new module [m] from the memory
2524 buffer [mb]. Returns [Success m] if successful, and [Failure msg] otherwise,
2625 where [msg] is a description of the error encountered.
27 See the function [llvm::ParseBitcodeFile]. **)
26 See the function [llvm::ParseBitcodeFile]. *)
2827 external parse_bitcode : Llvm.llmemorybuffer -> Llvm.llmodule
2928 = "llvm_parse_bitcode"
44 * This file is distributed under the University of Illinois Open Source
55 * License. See LICENSE.TXT for details.
66 *
7 *===----------------------------------------------------------------------===
8 *
9 * This interface provides an ocaml API for the LLVM bitcode writer, the
10 * classes in the Bitwriter library.
11 *
127 *===----------------------------------------------------------------------===*)
138
9 (** Bitcode writer.
10
11 This interface provides an ocaml API for the LLVM bitcode writer, the
12 classes in the Bitwriter library. *)
1413
1514 (** [write_bitcode_file m path] writes the bitcode for module [m] to the file at
16 [path]. Returns [true] if successful, [false] otherwise. **)
15 [path]. Returns [true] if successful, [false] otherwise. *)
1716 external write_bitcode_file : Llvm.llmodule -> string -> bool
1817 = "llvm_write_bitcode_file"
44 * This file is distributed under the University of Illinois Open Source
55 * License. See LICENSE.TXT for details.
66 *
7 *===----------------------------------------------------------------------===
8 *
9 * This interface provides an ocaml API for LLVM execution engine (JIT/
10 * interpreter), the classes in the ExecutionEngine library.
11 *
127 *===----------------------------------------------------------------------===*)
138
9 (** JIT Interpreter.
10
11 This interface provides an ocaml API for LLVM execution engine (JIT/
12 interpreter), the classes in the ExecutionEngine library. *)
1413
1514 exception Error of string
16
1715
1816 module GenericValue: sig
1917 (** [GenericValue.t] is a boxed union type used to portably pass arguments to
2018 and receive values from the execution engine. It supports only a limited
2119 selection of types; for more complex argument types, it is necessary to
2220 generate a stub function by hand or to pass parameters by reference.
23 See the struct [llvm::GenericValue]. **)
21 See the struct [llvm::GenericValue]. *)
2422 type t
2523
2624 (** [of_float fpty n] boxes the float [n] in a float-valued generic value
27 according to the floating point type [fpty]. See the fields
28 [llvm::GenericValue::DoubleVal] and [llvm::GenericValue::FloatVal]. **)
25 according to the floating point type [fpty]. See the fields
26 [llvm::GenericValue::DoubleVal] and [llvm::GenericValue::FloatVal]. *)
2927 val of_float: Llvm.lltype -> float -> t
3028
3129 (** [of_pointer v] boxes the pointer value [v] in a generic value. See the
32 field [llvm::GenericValue::PointerVal]. **)
30 field [llvm::GenericValue::PointerVal]. *)
3331 val of_pointer: 'a -> t
3432
3533 (** [of_int32 n w] boxes the int32 [i] in a generic value with the bitwidth
36 [w]. See the field [llvm::GenericValue::IntVal]. **)
34 [w]. See the field [llvm::GenericValue::IntVal]. *)
3735 val of_int32: Llvm.lltype -> int32 -> t
3836
3937 (** [of_int n w] boxes the int [i] in a generic value with the bitwidth
40 [w]. See the field [llvm::GenericValue::IntVal]. **)
38 [w]. See the field [llvm::GenericValue::IntVal]. *)
4139 val of_int: Llvm.lltype -> int -> t
4240
4341 (** [of_natint n w] boxes the native int [i] in a generic value with the
44 bitwidth [w]. See the field [llvm::GenericValue::IntVal]. **)
42 bitwidth [w]. See the field [llvm::GenericValue::IntVal]. *)
4543 val of_nativeint: Llvm.lltype -> nativeint -> t
4644
4745 (** [of_int64 n w] boxes the int64 [i] in a generic value with the bitwidth
48 [w]. See the field [llvm::GenericValue::IntVal]. **)
46 [w]. See the field [llvm::GenericValue::IntVal]. *)
4947 val of_int64: Llvm.lltype -> int64 -> t
5048
5149 (** [as_float fpty gv] unboxes the floating point-valued generic value [gv] of
5250 floating point type [fpty]. See the fields [llvm::GenericValue::DoubleVal]
53 and [llvm::GenericValue::FloatVal]. **)
51 and [llvm::GenericValue::FloatVal]. *)
5452 val as_float: Llvm.lltype -> t -> float
5553
5654 (** [as_pointer gv] unboxes the pointer-valued generic value [gv]. See the
57 field [llvm::GenericValue::PointerVal]. **)
55 field [llvm::GenericValue::PointerVal]. *)
5856 val as_pointer: t -> 'a
5957
6058 (** [as_int32 gv] unboxes the integer-valued generic value [gv] as an [int32].
6159 Is invalid if [gv] has a bitwidth greater than 32 bits. See the field
62 [llvm::GenericValue::IntVal]. **)
60 [llvm::GenericValue::IntVal]. *)
6361 val as_int32: t -> int32
6462
6563 (** [as_int gv] unboxes the integer-valued generic value [gv] as an [int].
6664 Is invalid if [gv] has a bitwidth greater than the host bit width (but the
6765 most significant bit may be lost). See the field
68 [llvm::GenericValue::IntVal]. **)
66 [llvm::GenericValue::IntVal]. *)
6967 val as_int: t -> int
7068
7169 (** [as_natint gv] unboxes the integer-valued generic value [gv] as a
7270 [nativeint]. Is invalid if [gv] has a bitwidth greater than
73 [nativeint]. See the field [llvm::GenericValue::IntVal]. **)
71 [nativeint]. See the field [llvm::GenericValue::IntVal]. *)
7472 val as_nativeint: t -> nativeint
7573
7674 (** [as_int64 gv] returns the integer-valued generic value [gv] as an [int64].
7775 Is invalid if [gv] has a bitwidth greater than [int64]. See the field
78 [llvm::GenericValue::IntVal]. **)
76 [llvm::GenericValue::IntVal]. *)
7977 val as_int64: t -> int64
8078 end
8179
8381 module ExecutionEngine: sig
8482 (** An execution engine is either a JIT compiler or an interpreter, capable of
8583 directly loading an LLVM module and executing its functions without first
86 invoking a static compiler and generating a native executable. **)
84 invoking a static compiler and generating a native executable. *)
8785 type t
8886
8987 (** [create mp] creates a new execution engine, taking ownership of the
9088 module provider [mp] if successful. Creates a JIT if possible, else falls
9189 back to an interpreter. Raises [Error msg] if an error occurrs. The
9290 execution engine is not garbage collected and must be destroyed with
93 [dispose ee]. See the function [llvm::ExecutionEngine::create]. **)
91 [dispose ee]. See the function [llvm::ExecutionEngine::create]. *)
9492 val create: Llvm.llmoduleprovider -> t
9593
9694 (** [create_interpreter mp] creates a new interpreter, taking ownership of the
9795 module provider [mp] if successful. Raises [Error msg] if an error
9896 occurrs. The execution engine is not garbage collected and must be
9997 destroyed with [dispose ee].
100 See the function [llvm::ExecutionEngine::create]. **)
98 See the function [llvm::ExecutionEngine::create]. *)
10199 val create_interpreter: Llvm.llmoduleprovider -> t
102100
103101 (** [create_jit mp] creates a new JIT (just-in-time compiler), taking
104102 ownership of the module provider [mp] if successful. Raises [Error msg] if
105103 an error occurrs. The execution engine is not garbage collected and must
106104 be destroyed with [dispose ee].
107 See the function [llvm::ExecutionEngine::create]. **)
105 See the function [llvm::ExecutionEngine::create]. *)
108106 val create_jit: Llvm.llmoduleprovider -> t
109107
110108 (** [dispose ee] releases the memory used by the execution engine and must be
111 invoked to avoid memory leaks. **)
109 invoked to avoid memory leaks. *)
112110 val dispose: t -> unit
113111
114112 (** [add_module_provider mp ee] adds the module provider [mp] to the execution
115 engine [ee]. **)
113 engine [ee]. *)
116114 val add_module_provider: Llvm.llmoduleprovider -> t -> unit
117115
118116 (** [remove_module_provider mp ee] removes the module provider [mp] from the
119117 execution engine [ee], disposing of [mp] and the module referenced by
120 [mp]. Raises [Error msg] if an error occurs. **)
118 [mp]. Raises [Error msg] if an error occurs. *)
121119 val remove_module_provider: Llvm.llmoduleprovider -> t -> Llvm.llmodule
122120
123 (** [find_function n ee] finds the function named [n] defined in any of the
121 (** [find_function n ee] finds the function named [n] defined in any of the
124122 modules owned by the execution engine [ee]. Returns [None] if the function
125 is not found and [Some f] otherwise. **)
123 is not found and [Some f] otherwise. *)
126124 val find_function: string -> t -> Llvm.llvalue option
127125
128126 (** [run_function f args ee] synchronously executes the function [f] with the
129 arguments [args], which must be compatible with the parameter types. **)
127 arguments [args], which must be compatible with the parameter types. *)
130128 val run_function: Llvm.llvalue -> GenericValue.t array -> t ->
131129 GenericValue.t
132130
133131 (** [run_static_ctors ee] executes the static constructors of each module in
134 the execution engine [ee]. **)
132 the execution engine [ee]. *)
135133 val run_static_ctors: t -> unit
136134
137135 (** [run_static_dtors ee] executes the static destructors of each module in
138 the execution engine [ee]. **)
136 the execution engine [ee]. *)
139137 val run_static_dtors: t -> unit
140138
141 (** [run_function_as_main f args env ee] executes the function [f] as a main
139 (** [run_function_as_main f args env ee] executes the function [f] as a main
142140 function, passing it [argv] and [argc] according to the string array
143 [args], and [envp] as specified by the array [env]. Returns the integer
144 return value of the function. **)
141 [args], and [envp] as specified by the array [env]. Returns the integer
142 return value of the function. *)
145143 val run_function_as_main: Llvm.llvalue -> string array ->
146144 (string * string) array -> t -> int
147145
148146 (** [free_machine_code f ee] releases the memory in the execution engine [ee]
149 used to store the machine code for the function [f]. **)
147 used to store the machine code for the function [f]. *)
150148 val free_machine_code: Llvm.llvalue -> t -> unit
151149 end
118118 = "llvm_add_type_name"
119119 external delete_type_name : string -> llmodule -> unit
120120 = "llvm_delete_type_name"
121
122121
123122 (*===-- Types -------------------------------------------------------------===*)
124123
44 * This file is distributed under the University of Illinois Open Source
55 * License. See LICENSE.TXT for details.
66 *
7 *===----------------------------------------------------------------------===
8 *
9 * This interface provides an ocaml API for the LLVM intermediate
10 * representation, the classes in the VMCore library.
11 *
127 *===----------------------------------------------------------------------===*)
138
14
15 (* These abstract types correlate directly to the LLVM VMCore classes. *)
9 (** Core API.
10
11 This interface provides an ocaml API for the LLVM intermediate
12 representation, the classes in the VMCore library. *)
13
14
15 (** {6 Abstract types}
16
17 These abstract types correlate directly to the LLVM VMCore classes. *)
1618
1719 (** The top-level container for all other LLVM Intermediate Representation (IR)
18 objects. See the [llvm::Module] class. **)
20 objects. See the [llvm::Module] class. *)
1921 type llmodule
2022
2123 (** Each value in the LLVM IR has a type, an instance of [lltype]. See the
22 [llvm::Type] class. **)
23 type lltype
24
25 (** When building recursive types using [refine_type], [lltype] values may
24 [llvm::Type] class. *)
25 type lltype
26
27 (** When building recursive types using {!refine_type}, [lltype] values may
2628 become invalid; use [lltypehandle] to resolve this problem. See the
27 [llvm::AbstractTypeHolder] class. **)
29 [llvm::AbstractTypeHolder] class. *)
2830 type lltypehandle
2931
3032 (** Any value in the LLVM IR. Functions, instructions, global variables,
3133 constants, and much more are all [llvalues]. See the [llvm::Value] class.
32 This type covers a wide range of subclasses. **)
34 This type covers a wide range of subclasses. *)
3335 type llvalue
3436
35 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. **)
37 (** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
3638 type llbasicblock
3739
3840 (** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
39 class. **)
41 class. *)
4042 type llbuilder
4143
4244 (** Used to provide a module to JIT or interpreter.
43 See the [llvm::ModuleProvider] class. **)
45 See the [llvm::ModuleProvider] class. *)
4446 type llmoduleprovider
4547
4648 (** Used to efficiently handle large buffers of read-only binary data.
47 See the [llvm::MemoryBuffer] class. **)
49 See the [llvm::MemoryBuffer] class. *)
4850 type llmemorybuffer
4951
50 (** The kind of an [lltype], the result of [classify_type ty]. See the
51 [llvm::Type::TypeID] enumeration. **)
52 (** The kind of an [lltype], the result of [classify_type ty]. See the
53 [llvm::Type::TypeID] enumeration. *)
5254 module TypeKind : sig
5355 type t =
5456 Void
6769 | Vector
6870 end
6971
70 (** The linkage of a global value, accessed with [linkage gv] and
71 [set_linkage l gv]. See [llvm::GlobalValue::LinkageTypes]. **)
72 (** The linkage of a global value, accessed with {!linkage} and
73 {!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
7274 module Linkage : sig
7375 type t =
7476 External
8284 | Ghost
8385 end
8486
85 (** The linker visibility of a global value, accessed with [visibility gv] and
86 [set_visibility v gv]. See [llvm::GlobalValue::VisibilityTypes]. **)
87 (** The linker visibility of a global value, accessed with {!visibility} and
88 {!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
8789 module Visibility : sig
8890 type t =
8991 Default
9193 | Protected
9294 end
9395
94 (* The following calling convention values may be accessed with
95 [function_call_conv f] and [set_function_call_conv conv f]. Calling
96 conventions are open-ended. *)
96 (** The following calling convention values may be accessed with
97 {!function_call_conv} and {!set_function_call_conv}. Calling
98 conventions are open-ended. *)
9799 module CallConv : sig
98 val c : int (** [c] is the C calling convention. **)
100 val c : int (** [c] is the C calling convention. *)
99101 val fast : int (** [fast] is the calling convention to allow LLVM
100102 maximum optimization opportunities. Use only with
101 internal linkage. **)
103 internal linkage. *)
102104 val cold : int (** [cold] is the calling convention for
103 callee-save. **)
105 callee-save. *)
104106 val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
105 convention from C. **)
107 convention from C. *)
106108 val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
107 convention from C. **)
109 convention from C. *)
108110 end
109111
110112 (** The predicate for an integer comparison ([icmp]) instruction.
111 See the [llvm::ICmpInst::Predicate] enumeration. **)
113 See the [llvm::ICmpInst::Predicate] enumeration. *)
112114 module Icmp : sig
113115 type t =
114116 | Eq
124126 end
125127
126128 (** The predicate for a floating-point comparison ([fcmp]) instruction.
127 See the [llvm::FCmpInst::Predicate] enumeration. **)
129 See the [llvm::FCmpInst::Predicate] enumeration. *)
128130 module Fcmp : sig
129131 type t =
130132 | False
145147 | True
146148 end
147149
150
151 (** {6 Exceptions} *)
152
148153 exception IoError of string
149154
150155
151 (*===-- Modules -----------------------------------------------------------===*)
156 (** {6 Modules} *)
152157
153158 (** [create_module id] creates a module with the supplied module ID. Modules are
154 not garbage collected; it is mandatory to call [dispose_module m] to free
159 not garbage collected; it is mandatory to call {!dispose_module} to free
155160 memory. See the constructor [llvm::Module::Module]. *)
156161 external create_module : string -> llmodule = "llvm_create_module"
157162
158163 (** [dispose_module m] destroys a module [m] and all of the IR objects it
159164 contained. All references to subordinate objects are invalidated;
160165 referencing them will invoke undefined behavior. See the destructor
161 [llvm::Module::~Module]. **)
166 [llvm::Module::~Module]. *)
162167 external dispose_module : llmodule -> unit = "llvm_dispose_module"
163168
164169 (** [target_triple m] is the target specifier for the module [m], something like
165 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. **)
170 [i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
166171 external target_triple: llmodule -> string
167172 = "llvm_target_triple"
168173
169174 (** [target_triple triple m] changes the target specifier for the module [m] to
170 the string [triple]. See the method [llvm::Module::setTargetTriple]. **)
175 the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
171176 external set_target_triple: string -> llmodule -> unit
172177 = "llvm_set_target_triple"
173178
174179 (** [data_layout m] is the data layout specifier for the module [m], something
175180 like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
176 method [llvm::Module::getDataLayout]. **)
181 method [llvm::Module::getDataLayout]. *)
177182 external data_layout: llmodule -> string
178183 = "llvm_data_layout"
179184
180185 (** [set_data_layout s m] changes the data layout specifier for the module [m]
181 to the string [s]. See the method [llvm::Module::setDataLayout]. **)
186 to the string [s]. See the method [llvm::Module::setDataLayout]. *)
182187 external set_data_layout: string -> llmodule -> unit
183188 = "llvm_set_data_layout"
184189
185190 (** [define_type_name name ty m] adds a named type to the module's symbol table.
186191 Returns [true] if successful. If such a name already exists, then no entry
187192 is added and [false] is returned. See the [llvm::Module::addTypeName]
188 method. **)
193 method. *)
189194 external define_type_name : string -> lltype -> llmodule -> bool
190195 = "llvm_add_type_name"
191196
195200 = "llvm_delete_type_name"
196201
197202
198 (*===-- Types -------------------------------------------------------------===*)
199
200 (** [classify_type ty] returns the [type_kind] corresponding to the type [ty].
201 See the method [llvm::Type::getTypeID]. **)
203 (** {6 Types} *)
204
205 (** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
206 See the method [llvm::Type::getTypeID]. *)
202207 external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
203208
204 (** [string_of_lltype ty] returns a string describing the type [ty]. **)
209 (** [string_of_lltype ty] returns a string describing the type [ty]. *)
205210 val string_of_lltype : lltype -> string
206211
207 (*--... Operations on integer types ........................................--*)
208
209 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. **)
210 val i1_type : lltype
211
212 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. **)
213 val i8_type : lltype
214
215 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. **)
212 (** {7 Operations on integer types} *)
213
214 (** The 1-bit integer type. See [llvm::Type::Int1Ty]. *)
215 val i1_type : lltype
216
217 (** The 8-bit integer type. See [llvm::Type::Int8Ty]. *)
218 val i8_type : lltype
219
220 (** The 16-bit integer type. See [llvm::Type::Int16Ty]. *)
216221 val i16_type : lltype
217222
218 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. **)
223 (** The 32-bit integer type. See [llvm::Type::Int32Ty]. *)
219224 val i32_type : lltype
220225
221 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. **)
226 (** The 64-bit integer type. See [llvm::Type::Int64Ty]. *)
222227 val i64_type : lltype
223228
224229 (** [integer_type n] returns an integer type of bitwidth [n].
225 See the method [llvm::IntegerType::get]. **)
230 See the method [llvm::IntegerType::get]. *)
226231 external integer_type : int -> lltype = "llvm_integer_type"
227232
228 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty]..
229 See the method [llvm::IntegerType::getBitWidth]. **)
233 (** [integer_bitwidth ty] returns the number of bits in the integer type [ty].
234 See the method [llvm::IntegerType::getBitWidth]. *)
230235 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
231236
232 (*--... Operations on real types ...........................................--*)
233
234 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. **)
237
238 (** {7 Operations on real types} *)
239
240 (** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. *)
235241 val float_type : lltype
236242
237 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. **)
243 (** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. *)
238244 val double_type : lltype
239245
240 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. **)
246 (** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. *)
241247 val x86fp80_type : lltype
242248
243 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. **)
249 (** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. *)
244250 val fp128_type : lltype
245251
246 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. **)
252 (** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. *)
247253 val ppc_fp128_type : lltype
248254
249 (*--... Operations on function types .......................................--*)
255
256 (** {7 Operations on function types} *)
250257
251258 (** [function_type ret_ty param_tys] returns the function type returning
252259 [ret_ty] and taking [param_tys] as parameters.
253 See the method [llvm::FunctionType::get]. **)
260 See the method [llvm::FunctionType::get]. *)
254261 external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
255262
256263 (** [va_arg_function_type ret_ty param_tys] is just like
257264 [function_type ret_ty param_tys] except that it returns the function type
258265 which also takes a variable number of arguments.
259 See the method [llvm::FunctionType::get]. **)
266 See the method [llvm::FunctionType::get]. *)
260267 external var_arg_function_type : lltype -> lltype array -> lltype
261268 = "llvm_var_arg_function_type"
262269
263270 (** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
264 otherwise. See the method [llvm::FunctionType::isVarArg]. **)
271 otherwise. See the method [llvm::FunctionType::isVarArg]. *)
265272 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
266273
267274 (** [return_type fty] gets the return type of the function type [fty].
268 See the method [llvm::FunctionType::getReturnType]. **)
275 See the method [llvm::FunctionType::getReturnType]. *)
269276 external return_type : lltype -> lltype = "LLVMGetReturnType"
270277
271278 (** [param_types fty] gets the parameter types of the function type [fty].
272 See the method [llvm::FunctionType::getParamType]. **)
279 See the method [llvm::FunctionType::getParamType]. *)
273280 external param_types : lltype -> lltype array = "llvm_param_types"
274281
275 (*--... Operations on struct types .........................................--*)
282
283 (** {7 Operations on struct types} *)
276284
277285 (** [struct_type tys] returns the structure type containing in the types in the
278 array [tys]. See the method [llvm::StructType::get]. **)
286 array [tys]. See the method [llvm::StructType::get]. *)
279287 external struct_type : lltype array -> lltype = "llvm_struct_type"
280288
281289 (** [struct_type tys] returns the packed structure type containing in the types
282 in the array [tys]. See the method [llvm::StructType::get]. **)
290 in the array [tys]. See the method [llvm::StructType::get]. *)
283291 external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
284292
285293 (** [element_types sty] returns the constituent types of the struct type [sty].
286 See the method [llvm::StructType::getElementType]. **)
294 See the method [llvm::StructType::getElementType]. *)
287295 external element_types : lltype -> lltype array = "llvm_element_types"
288296
289297 (** [is_packed sty] returns [true] if the structure type [sty] is packed,
290 [false] otherwise. See the method [llvm::StructType::isPacked]. **)
298 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
291299 external is_packed : lltype -> bool = "llvm_is_packed"
292300
293 (*--... Operations on pointer, vector, and array types .....................--*)
301
302 (** {7 Operations on pointer, vector, and array types} *)
294303
295304 (** [array_type ty n] returns the array type containing [n] elements of type
296 [ty]. See the method [llvm::ArrayType::get]. **)
305 [ty]. See the method [llvm::ArrayType::get]. *)
297306 external array_type : lltype -> int -> lltype = "llvm_array_type"
298307
299308 (** [pointer_type ty] returns the pointer type referencing objects of type
300309 [ty] in the default address space (0).
301 See the method [llvm::PointerType::getUnqual]. **)
310 See the method [llvm::PointerType::getUnqual]. *)
302311 external pointer_type : lltype -> lltype = "llvm_pointer_type"
303312
304313 (** [qualified_pointer_type ty as] returns the pointer type referencing objects
305314 of type [ty] in address space [as].
306 See the method [llvm::PointerType::get]. **)
315 See the method [llvm::PointerType::get]. *)
307316 external qualified_pointer_type : lltype -> int -> lltype
308317 = "llvm_qualified_pointer_type"
309318
310319 (** [vector_type ty n] returns the array type containing [n] elements of the
311 primitive type [ty]. See the method [llvm::ArrayType::get]. **)
320 primitive type [ty]. See the method [llvm::ArrayType::get]. *)
312321 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
313322
314323 (** [element_type ty] returns the element type of the pointer, vector, or array
315 type [ty]. See the method [llvm::SequentialType::get]. **)
324 type [ty]. See the method [llvm::SequentialType::get]. *)
316325 external element_type : lltype -> lltype = "LLVMGetElementType"
317326
318327 (** [element_type aty] returns the element count of the array type [aty].
319 See the method [llvm::ArrayType::getNumElements]. **)
328 See the method [llvm::ArrayType::getNumElements]. *)
320329 external array_length : lltype -> int = "llvm_array_length"
321330
322331 (** [address_space pty] returns the address space qualifier of the pointer type
323 [pty]. See the method [llvm::PointerType::getAddressSpace]. **)
332 [pty]. See the method [llvm::PointerType::getAddressSpace]. *)
324333 external address_space : lltype -> int = "llvm_address_space"
325334
326335 (** [element_type ty] returns the element count of the vector type [ty].
327 See the method [llvm::VectorType::getNumElements]. **)
336 See the method [llvm::VectorType::getNumElements]. *)
328337 external vector_size : lltype -> int = "llvm_vector_size"
329338
330 (*--... Operations on other types ..........................................--*)
339
340 (** {7 Operations on other types} *)
331341
332342 (** [opaque_type ()] creates a new opaque type distinct from any other.
333343 Opaque types are useful for building recursive types in combination with
334 [refine_type opaque_ty ty].
335 See [llvm::OpaqueType::get]. **)
344 {!refine_type} [opaque_ty ty].
345 See [llvm::OpaqueType::get]. *)
336346 external opaque_type : unit -> lltype = "llvm_opaque_type"
337347
338348 (** [void_type] is the type of a function which does not return any value.
339 See [llvm::Type::VoidTy]. **)
349 See [llvm::Type::VoidTy]. *)
340350 val void_type : lltype
341351
342 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. **)
352 (** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. *)
343353 val label_type : lltype
344354
345 (*--... Operations on type handles .........................................--*)
355 (** {7 Operations on type handles} *)
346356
347357 (** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
348 refined as a result of a call to [refine_type], the handle will be updated;
358 refined as a result of a call to {!refine_type}, the handle will be updated;
349359 any bare [lltype] references will become invalid.
350 See the class [llvm::PATypeHolder]. **)
360 See the class [llvm::PATypeHolder]. *)
351361 external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
352362
353363 (** [type_of_handle tyh] resolves the type handle [tyh].
354 See the method [llvm::PATypeHolder::get()]. **)
364 See the method [llvm::PATypeHolder::get()]. *)
355365 external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
356366
357367 (** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
358 concrete type [ty] in all users. Warning: This may invalidate [lltype]
359 values! Use [lltypehandle] to manipulate potentially abstract types. See the
360 method [llvm::Type::refineAbstractType]. **)
368 concrete type [ty] in all users. Warning: This may invalidate {!lltype}
369 values! Use {!lltypehandle} to manipulate potentially abstract types. See
370 the method [llvm::Type::refineAbstractType]. *)
361371 external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
362372
363373
364 (*===-- Values ------------------------------------------------------------===*)
374 (* {6 Values} *)
365375
366376 (** [type_of v] returns the type of the value [v].
367 See the method [llvm::Value::getType]. **)
377 See the method [llvm::Value::getType]. *)
368378 external type_of : llvalue -> lltype = "llvm_type_of"
369379
370380 (** [value_name v] returns the name of the value [v]. For global values, this is
371381 the symbol name. For instructions and basic blocks, it is the SSA register
372382 name. It is meaningless for constants.
373 See the method [llvm::Value::getName]. **)
383 See the method [llvm::Value::getName]. *)
374384 external value_name : llvalue -> string = "llvm_value_name"
375385
376 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
377 [llvm::Value::setName]. **)
386 (** [set_value_name n v] sets the name of the value [v] to [n]. See the method
387 [llvm::Value::setName]. *)
378388 external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
379389
380390 (** [dump_value v] prints the .ll representation of the value [v] to standard
381 error. See the method [llvm::Value::dump]. **)
391 error. See the method [llvm::Value::dump]. *)
382392 external dump_value : llvalue -> unit = "llvm_dump_value"
383393
384 (*--... Operations on constants of (mostly) any type .......................--*)
394
395 (** {7 Operations on constants of (mostly) any type} *)
385396
386397 (** [is_constant v] returns [true] if the value [v] is a constant, [false]
387 otherwise. Similar to [llvm::isa]. **)
398 otherwise. Similar to [llvm::isa]. *)
388399 external is_constant : llvalue -> bool = "llvm_is_constant"
389400
390401 (** [const_null ty] returns the constant null (zero) of the type [ty].
391 See the method [llvm::Constant::getNullValue]. **)
402 See the method [llvm::Constant::getNullValue]. *)
392403 external const_null : lltype -> llvalue = "LLVMConstNull"
393404
394405 (** [const_all_ones ty] returns the constant '-1' of the integer or vector type
395 [ty]. See the method [llvm::Constant::getAllOnesValue]. **)
406 [ty]. See the method [llvm::Constant::getAllOnesValue]. *)
396407 external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
397408
398409 (** [undef ty] returns the undefined value of the type [ty].
399 See the method [llvm::UndefValue::get]. **)
410 See the method [llvm::UndefValue::get]. *)
400411 external undef : lltype -> llvalue = "LLVMGetUndef"
401412
402413 (** [is_null v] returns [true] if the value [v] is the null (zero) value.
403 See the method [llvm::Constant::isNullValue]. **)
414 See the method [llvm::Constant::isNullValue]. *)
404415 external is_null : llvalue -> bool = "llvm_is_null"
405416
406417 (** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
407 otherwise. Similar to [llvm::isa]. **)
418 otherwise. Similar to [llvm::isa]. *)
408419 external is_undef : llvalue -> bool = "llvm_is_undef"
409420
410 (*--... Operations on scalar constants .....................................--*)
421
422 (** {7 Operations on scalar constants} *)
411423
412424 (** [const_int ty i] returns the integer constant of type [ty] and value [i].
413 See the method [llvm::ConstantInt::get]. **)
425 See the method [llvm::ConstantInt::get]. *)
414426 external const_int : lltype -> int -> llvalue = "llvm_const_int"
415427
416428 (** [const_of_int64 ty i] returns the integer constant of type [ty] and value
417 [i]. See the method [llvm::ConstantInt::get]. **)
429 [i]. See the method [llvm::ConstantInt::get]. *)
418430 external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
419431 = "llvm_const_of_int64"
420432
421433 (** [const_float ty n] returns the floating point constant of type [ty] and
422 value [n]. See the method [llvm::ConstantInt::get]. **)
434 value [n]. See the method [llvm::ConstantInt::get]. *)
423435 external const_float : lltype -> float -> llvalue = "llvm_const_float"
424436
425 (*--... Operations on composite constants ..................................--*)
437
438 (** {7 Operations on composite constants} *)
426439
427440 (** [const_string s] returns the constant [i8] array with the values of the
428441 characters in the string [s]. The array is not null-terminated (but see
429 [const_stringz]). This value can in turn be used as the initializer for a
430 global variable. See the method [llvm::ConstantArray::get]. **)
442 {!const_stringz}). This value can in turn be used as the initializer for a
443 global variable. See the method [llvm::ConstantArray::get]. *)
431444 external const_string : string -> llvalue = "llvm_const_string"
432445
433446 (** [const_stringz s] returns the constant [i8] array with the values of the
434447 characters in the string [s] and a null terminator. This value can in turn
435448 be used as the initializer for a global variable.
436 See the method [llvm::ConstantArray::get]. **)
449 See the method [llvm::ConstantArray::get]. *)
437450 external const_stringz : string -> llvalue = "llvm_const_stringz"
438451
439452 (** [const_array ty elts] returns the constant array of type
440453 [array_type ty (Array.length elts)] and containing the values [elts].
441454 This value can in turn be used as the initializer for a global variable.
442 See the method [llvm::ConstantArray::get]. **)
455 See the method [llvm::ConstantArray::get]. *)
443456 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
444457
445458 (** [const_struct elts] returns the structured constant of type
446459 [struct_type (Array.map type_of elts)] and containing the values [elts].
447460 This value can in turn be used as the initializer for a global variable.
448 See the method [llvm::ConstantStruct::get]. **)
461 See the method [llvm::ConstantStruct::get]. *)
449462 external const_struct : llvalue array -> llvalue = "llvm_const_struct"
450463
451464 (** [const_packed_struct elts] returns the structured constant of type
452 [packed_struct_type (Array.map type_of elts)] and containing the values
465 {!packed_struct_type} [(Array.map type_of elts)] and containing the values
453466 [elts]. This value can in turn be used as the initializer for a global
454 variable. See the method [llvm::ConstantStruct::get]. **)
467 variable. See the method [llvm::ConstantStruct::get]. *)
455468 external const_packed_struct : llvalue array -> llvalue
456469 = "llvm_const_packed_struct"
457470
458471 (** [const_vector elts] returns the vector constant of type
459472 [vector_type (type_of elts.(0)) (Array.length elts)] and containing the
460 values [elts]. See the method [llvm::ConstantVector::get]. **)
473 values [elts]. See the method [llvm::ConstantVector::get]. *)
461474 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
462475
463 (*--... Constant expressions ...............................................--*)
476
477 (** {7 Constant expressions} *)
464478
465479 (** [size_of ty] returns the sizeof constant for the type [ty]. This is
466480 equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
467481 (const_int i64_type 1)) i64_type], but considerably more readable.
468 See the method [llvm::ConstantExpr::getSizeOf]. **)
482 See the method [llvm::ConstantExpr::getSizeOf]. *)
469483 external size_of : lltype -> llvalue = "LLVMSizeOf"
470484
471485 (** [const_neg c] returns the arithmetic negation of the constant [c].
472 See the method [llvm::ConstantExpr::getNeg]. **)
486 See the method [llvm::ConstantExpr::getNeg]. *)
473487 external const_neg : llvalue -> llvalue = "LLVMConstNeg"
474488
475489 (** [const_not c] returns the bitwise inverse of the constant [c].
476 See the method [llvm::ConstantExpr::getNot]. **)
490 See the method [llvm::ConstantExpr::getNot]. *)
477491 external const_not : llvalue -> llvalue = "LLVMConstNot"
478492
479493 (** [const_add c1 c2] returns the constant sum of two constants.
480 See the method [llvm::ConstantExpr::getAdd]. **)
494 See the method [llvm::ConstantExpr::getAdd]. *)
481495 external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
482496
483497 (** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
484 constants. See the method [llvm::ConstantExpr::getSub]. **)
498 constants. See the method [llvm::ConstantExpr::getSub]. *)
485499 external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
486500
487501 (** [const_mul c1 c2] returns the constant product of two constants.
488 See the method [llvm::ConstantExpr::getMul]. **)
502 See the method [llvm::ConstantExpr::getMul]. *)
489503 external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
490504
491505 (** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
492506 integer constants.
493 See the method [llvm::ConstantExpr::getUDiv]. **)
507 See the method [llvm::ConstantExpr::getUDiv]. *)
494508 external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
495509
496510 (** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
497511 integer constants.
498 See the method [llvm::ConstantExpr::]. **)
512 See the method [llvm::ConstantExpr::]. *)
499513 external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
500514
501515 (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
502516 point constants.
503 See the method [llvm::ConstantExpr::getFDiv]. **)
517 See the method [llvm::ConstantExpr::getFDiv]. *)
504518 external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
505519
506520 (** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
507521 unsigned integer constants.
508 See the method [llvm::ConstantExpr::getURem]. **)
522 See the method [llvm::ConstantExpr::getURem]. *)
509523 external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
510524
511525 (** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
512526 signed integer constants.
513 See the method [llvm::ConstantExpr::getSRem]. **)
527 See the method [llvm::ConstantExpr::getSRem]. *)
514528 external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
515529
516530 (** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
517531 signed floating point constants.
518 See the method [llvm::ConstantExpr::getFRem]. **)
532 See the method [llvm::ConstantExpr::getFRem]. *)
519533 external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
520534
521535 (** [const_and c1 c2] returns the constant bitwise [AND] of two integer
522536 constants.
523 See the method [llvm::ConstantExpr::getAnd]. **)
537 See the method [llvm::ConstantExpr::getAnd]. *)
524538 external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
525539
526540 (** [const_or c1 c2] returns the constant bitwise [OR] of two integer
527541 constants.
528 See the method [llvm::ConstantExpr::getOr]. **)
542 See the method [llvm::ConstantExpr::getOr]. *)
529543 external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
530544
531545 (** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
532546 constants.
533 See the method [llvm::ConstantExpr::getXor]. **)
547 See the method [llvm::ConstantExpr::getXor]. *)
534548 external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
535549
536550 (** [const_icmp pred c1 c2] returns the constant comparison of two integer
537551 constants, [c1 pred c2].
538 See the method [llvm::ConstantExpr::getICmp]. **)
552 See the method [llvm::ConstantExpr::getICmp]. *)
539553 external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
540554 = "llvm_const_icmp"
541555
542556 (** [const_fcmp pred c1 c2] returns the constant comparison of two floating
543557 point constants, [c1 pred c2].
544 See the method [llvm::ConstantExpr::getFCmp]. **)
558 See the method [llvm::ConstantExpr::getFCmp]. *)
545559 external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
546560 = "llvm_const_fcmp"
547561
548562 (** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
549563 constant integer [c2].
550 See the method [llvm::ConstantExpr::getShl]. **)
564 See the method [llvm::ConstantExpr::getShl]. *)
551565 external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
552566
553567 (** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
554568 constant integer [c2] with zero extension.
555 See the method [llvm::ConstantExpr::getLShr]. **)
569 See the method [llvm::ConstantExpr::getLShr]. *)
556570 external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
557571
558572 (** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
559573 constant integer [c2] with sign extension.
560 See the method [llvm::ConstantExpr::getAShr]. **)
574 See the method [llvm::ConstantExpr::getAShr]. *)
561575 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
562576
563577 (** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
564578 constant integers indices from the array [indices].
565 See the method [llvm::ConstantExpr::getGetElementPtr]. **)
579 See the method [llvm::ConstantExpr::getGetElementPtr]. *)
566580 external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
567581
568582 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
569583 to the smaller integer type [ty].
570 See the method [llvm::ConstantExpr::getTrunc]. **)
584 See the method [llvm::ConstantExpr::getTrunc]. *)
571585 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
572586
573587 (** [const_sext c ty] returns the constant sign extension of integer constant
574588 [c] to the larger integer type [ty].
575 See the method [llvm::ConstantExpr::getSExt]. **)
589 See the method [llvm::ConstantExpr::getSExt]. *)
576590 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
577591
578592 (** [const_zext c ty] returns the constant zero extension of integer constant
579593 [c] to the larger integer type [ty].
580 See the method [llvm::ConstantExpr::getZExt]. **)
594 See the method [llvm::ConstantExpr::getZExt]. *)
581595 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
582596
583597 (** [const_fptrunc c ty] returns the constant truncation of floating point
584598 constant [c] to the smaller floating point type [ty].
585 See the method [llvm::ConstantExpr::getFPTrunc]. **)
599 See the method [llvm::ConstantExpr::getFPTrunc]. *)
586600 external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
587601
588602 (** [const_fpext c ty] returns the constant extension of floating point constant
589603 [c] to the larger floating point type [ty].
590 See the method [llvm::ConstantExpr::getFPExt]. **)
604 See the method [llvm::ConstantExpr::getFPExt]. *)
591605 external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
592606
593607 (** [const_uitofp c ty] returns the constant floating point conversion of
594608 unsigned integer constant [c] to the floating point type [ty].
595 See the method [llvm::ConstantExpr::getUIToFP]. **)
609 See the method [llvm::ConstantExpr::getUIToFP]. *)
596610 external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
597611
598612 (** [const_sitofp c ty] returns the constant floating point conversion of
599613 signed integer constant [c] to the floating point type [ty].
600 See the method [llvm::ConstantExpr::getSIToFP]. **)
614 See the method [llvm::ConstantExpr::getSIToFP]. *)
601615 external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
602616
603617 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
604618 floating point constant [c] to integer type [ty].
605 See the method [llvm::ConstantExpr::getFPToUI]. **)
619 See the method [llvm::ConstantExpr::getFPToUI]. *)
606620 external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
607621
608622 (** [const_fptoui c ty] returns the constant unsigned integer conversion of
609623 floating point constant [c] to integer type [ty].
610 See the method [llvm::ConstantExpr::getFPToSI]. **)
624 See the method [llvm::ConstantExpr::getFPToSI]. *)
611625 external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
612626
613627 (** [const_ptrtoint c ty] returns the constant integer conversion of
614628 pointer constant [c] to integer type [ty].
615 See the method [llvm::ConstantExpr::getPtrToInt]. **)
629 See the method [llvm::ConstantExpr::getPtrToInt]. *)
616630 external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
617631
618632 (** [const_inttoptr c ty] returns the constant pointer conversion of
619633 integer constant [c] to pointer type [ty].
620 See the method [llvm::ConstantExpr::getIntToPtr]. **)
634 See the method [llvm::ConstantExpr::getIntToPtr]. *)
621635 external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
622636
623637 (** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
624638 to type [ty] of equal size.
625 See the method [llvm::ConstantExpr::getBitCast]. **)
639 See the method [llvm::ConstantExpr::getBitCast]. *)
626640 external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
627641
628642 (** [const_select cond t f] returns the constant conditional which returns value
629643 [t] if the boolean constant [cond] is true and the value [f] otherwise.
630 See the method [llvm::ConstantExpr::getSelect]. **)
644 See the method [llvm::ConstantExpr::getSelect]. *)
631645 external const_select : llvalue -> llvalue -> llvalue -> llvalue
632646 = "LLVMConstSelect"
633647
634648 (** [const_extractelement vec i] returns the constant [i]th element of
635649 constant vector [vec]. [i] must be a constant [i32] value unsigned less than
636650 the size of the vector.
637 See the method [llvm::ConstantExpr::getExtractElement]. **)
651 See the method [llvm::ConstantExpr::getExtractElement]. *)
638652 external const_extractelement : llvalue -> llvalue -> llvalue
639653 = "LLVMConstExtractElement"
640654
643657 constant [v]. [v] must be a constant value with the type of the vector
644658 elements. [i] must be a constant [i32] value unsigned less than the size
645659 of the vector.
646 See the method [llvm::ConstantExpr::getInsertElement]. **)
660 See the method [llvm::ConstantExpr::getInsertElement]. *)
647661 external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
648662 = "LLVMConstInsertElement"
649663
650664 (** [const_shufflevector a b mask] returns a constant [shufflevector].
651665 See the LLVM Language Reference for details on the [sufflevector]
652666 instruction.
653 See the method [llvm::ConstantExpr::getShuffleVector]. **)
667 See the method [llvm::ConstantExpr::getShuffleVector]. *)
654668 external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
655669 = "LLVMConstShuffleVector"
656670
657 (*--... Operations on global variables, functions, and aliases (globals) ...--*)
671
672 (** {7 Operations on global variables, functions, and aliases (globals)} *)
658673
659674 (** [is_declaration g] returns [true] if the global value [g] is a declaration
660675 only. Returns [false] otherwise.
661 See the method [llvm::GlobalValue::isDeclaration]. **)
676 See the method [llvm::GlobalValue::isDeclaration]. *)
662677 external is_declaration : llvalue -> bool = "llvm_is_declaration"
663678
664679 (** [linkage g] returns the linkage of the global value [g].
665 See the method [llvm::GlobalValue::getLinkage]. **)
680 See the method [llvm::GlobalValue::getLinkage]. *)
666681 external linkage : llvalue -> Linkage.t = "llvm_linkage"
667682
668683 (** [set_linkage l g] sets the linkage of the global value [g] to [l].
669 See the method [llvm::GlobalValue::setLinkage]. **)
684 See the method [llvm::GlobalValue::setLinkage]. *)
670685 external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
671686
672687 (** [section g] returns the linker section of the global value [g].
673 See the method [llvm::GlobalValue::getSection]. **)
688 See the method [llvm::GlobalValue::getSection]. *)
674689 external section : llvalue -> string = "llvm_section"
675690
676691 (** [set_section s g] sets the linker section of the global value [g] to [s].
677 See the method [llvm::GlobalValue::setSection]. **)
692 See the method [llvm::GlobalValue::setSection]. *)
678693 external set_section : string -> llvalue -> unit = "llvm_set_section"
679694
680695 (** [visibility g] returns the linker visibility of the global value [g].
681 See the method [llvm::GlobalValue::getVisibility]. **)
696 See the method [llvm::GlobalValue::getVisibility]. *)
682697 external visibility : llvalue -> Visibility.t = "llvm_visibility"
683698
684699 (** [set_visibility v g] sets the linker visibility of the global value [g] to
685 [v]. See the method [llvm::GlobalValue::setVisibility]. **)
700 [v]. See the method [llvm::GlobalValue::setVisibility]. *)
686701 external set_visibility : Visibility.t -> llvalue -> unit
687702 = "llvm_set_visibility"
688703
689704 (** [alignment g] returns the required alignment of the global value [g].
690 See the method [llvm::GlobalValue::getAlignment]. **)
705 See the method [llvm::GlobalValue::getAlignment]. *)
691706 external alignment : llvalue -> int = "llvm_alignment"
692707
693708 (** [set_alignment n g] sets the required alignment of the global value [g] to
694 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. **)
709 [n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
695710 external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
696711
697 (*--... Operations on global variables .....................................--*)
712
713 (** {7 Operations on global variables} *)
698714
699715 (** [declare_global ty name m] returns a new global variable of type [ty] and
700716 with name [name] in module [m]. If such a global variable already exists,
701717 it is returned. If the type of the existing global differs, then a bitcast
702 to [ty] is returned. **)
718 to [ty] is returned. *)
703719 external declare_global : lltype -> string -> llmodule -> llvalue
704720 = "llvm_declare_global"
705721
706722 (** [define_global name init m] returns a new global with name [name] and
707723 initializer [init] in module [m]. If the named global already exists, it is
708724 renamed.
709 See the constructor of [llvm::GlobalVariable]. **)
725 See the constructor of [llvm::GlobalVariable]. *)
710726 external define_global : string -> llvalue -> llmodule -> llvalue
711727 = "llvm_define_global"
712728
713729 (** [lookup_global name m] returns [Some g] if a global variable with name
714730 [name] exists in module [m]. If no such global exists, returns [None].
715 See the [llvm::GlobalVariable] constructor. **)
731 See the [llvm::GlobalVariable] constructor. *)
716732 external lookup_global : string -> llmodule -> llvalue option
717733 = "llvm_lookup_global"
718734
719735 (** [delete_global gv] destroys the global variable [gv].
720 See the method [llvm::GlobalVariable::eraseFromParent]. **)
736 See the method [llvm::GlobalVariable::eraseFromParent]. *)
721737 external delete_global : llvalue -> unit = "llvm_delete_global"
722738
723739 (** [is_global_constant gv] returns [true] if the global variabile [gv] is a
724740 constant. Returns [false] otherwise.
725 See the method [llvm::GlobalVariable::isConstant]. **)
741 See the method [llvm::GlobalVariable::isConstant]. *)
726742 external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
727743
728744 (** [set_global_constant c gv] sets the global variable [gv] to be a constant if
729745 [c] is [true] and not if [c] is [false].
730 See the method [llvm::GlobalVariable::setConstant]. **)
746 See the method [llvm::GlobalVariable::setConstant]. *)
731747 external set_global_constant : bool -> llvalue -> unit
732748 = "llvm_set_global_constant"
733749
734750 (** [has_initializer gv] returns [true] if the global variable [gv] has an
735751 initializer and [false] otherwise.
736 See the method [llvm::GlobalVariable::hasInitializer]. **)
752 See the method [llvm::GlobalVariable::hasInitializer]. *)
737753 external has_initializer : llvalue -> bool = "llvm_has_initializer"
738754
739755 (** [global_initializer gv] returns the initializer for the global variable
740 [gv]. See the method [llvm::GlobalVariable::getInitializer]. **)
756 [gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
741757 external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
742758
743759 (** [set_initializer c gv] sets the initializer for the global variable
744760 [gv] to the constant [c].
745 See the method [llvm::GlobalVariable::setInitializer]. **)
761 See the method [llvm::GlobalVariable::setInitializer]. *)
746762 external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
747763
748764 (** [remove_initializer gv] unsets the initializer for the global variable
749765 [gv].
750 See the method [llvm::GlobalVariable::setInitializer]. **)
766 See the method [llvm::GlobalVariable::setInitializer]. *)
751767 external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
752768
753769 (** [is_thread_local gv] returns [true] if the global variable [gv] is
754770 thread-local and [false] otherwise.
755 See the method [llvm::GlobalVariable::isThreadLocal]. **)
771 See the method [llvm::GlobalVariable::isThreadLocal]. *)
756772 external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
757773
758774 (** [set_thread_local c gv] sets the global variable [gv] to be thread local if
759775 [c] is [true] and not otherwise.
760 See the method [llvm::GlobalVariable::setThreadLocal]. **)
776 See the method [llvm::GlobalVariable::setThreadLocal]. *)
761777 external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
762778
763 (*--... Operations on functions ............................................--*)
779
780 (** {7 Operations on functions} *)
764781
765782 (** [declare_function name ty m] returns a new function of type [ty] and
766783 with name [name] in module [m]. If such a function already exists,
767784 it is returned. If the type of the existing function differs, then a bitcast
768 to [ty] is returned. **)
785 to [ty] is returned. *)
769786 external declare_function : string -> lltype -> llmodule -> llvalue
770787 = "llvm_declare_function"
771788
772789 (** [define_function name ty m] creates a new function with name [name] and
773790 type [ty] in module [m]. If the named function already exists, it is
774791 renamed. An entry basic block is created in the function.
775 See the constructor of [llvm::GlobalVariable]. **)
792 See the constructor of [llvm::GlobalVariable]. *)
776793 external define_function : string -> lltype -> llmodule -> llvalue
777794 = "llvm_define_function"
778795
779796 (** [lookup_function name m] returns [Some f] if a function with name
780797 [name] exists in module [m]. If no such function exists, returns [None].
781 See the method [llvm::Module] constructor. **)
798 See the method [llvm::Module] constructor. *)
782799 external lookup_function : string -> llmodule -> llvalue option
783800 = "llvm_lookup_function"
784801
785802 (** [delete_function f] destroys the function [f].
786 See the method [llvm::Function::eraseFromParent]. **)
803 See the method [llvm::Function::eraseFromParent]. *)
787804 external delete_function : llvalue -> unit = "llvm_delete_function"
788805
789806 (** [params f] returns the parameters of function [f].
790 See the method [llvm::Function::getArgumentList]. **)
807 See the method [llvm::Function::getArgumentList]. *)
791808 external params : llvalue -> llvalue array = "llvm_params"
792809
793810 (** [param f n] returns the [n]th parameter of function [f].
794 See the method [llvm::Function::getArgumentList]. **)
811 See the method [llvm::Function::getArgumentList]. *)
795812 external param : llvalue -> int -> llvalue = "llvm_param"
796813
797814 (** [is_intrinsic f] returns true if the function [f] is an intrinsic.
798 See the method [llvm::Function::isIntrinsic]. **)
815 See the method [llvm::Function::isIntrinsic]. *)
799816 external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
800817
801818 (** [function_call_conv f] returns the calling convention of the function [f].
802 See the method [llvm::Function::getCallingConv]. **)
819 See the method [llvm::Function::getCallingConv]. *)
803820 external function_call_conv : llvalue -> int = "llvm_function_call_conv"
804821
805822 (** [set_function_call_conv cc f] sets the calling convention of the function
806823 [f] to the calling convention numbered [cc].
807 See the method [llvm::Function::setCallingConv]. **)
824 See the method [llvm::Function::setCallingConv]. *)
808825 external set_function_call_conv : int -> llvalue -> unit
809826 = "llvm_set_function_call_conv"
810827
811828 (** [collector f] returns [Some name] if the function [f] has a garbage
812829 collection algorithm specified and [None] otherwise.
813 See the method [llvm::Function::getCollector]. **)
830 See the method [llvm::Function::getCollector]. *)
814831 external collector : llvalue -> string option = "llvm_collector"
815832
816833 (** [set_collector gc f] sets the collection algorithm for the function [f] to
817 [gc]. See the method [llvm::Function::setCollector]. **)
834 [gc]. See the method [llvm::Function::setCollector]. *)
818835 external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
819836
820 (*--... Operations on basic blocks .........................................--*)
837
838 (** {7 Operations on basic blocks} *)
821839
822840 (** [basic_blocks fn] returns the basic blocks of the function [f].
823 See the method [llvm::Function::getBasicBlockList]. **)
841 See the method [llvm::Function::getBasicBlockList]. *)
824842 external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
825843
826844 (** [entry_block fn] returns the entry basic block of the function [f].
827 See the method [llvm::Function::getEntryBlock]. **)
845 See the method [llvm::Function::getEntryBlock]. *)
828846 external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
829847
830848 (** [delete_block bb] deletes the basic block [bb].
831 See the method [llvm::BasicBlock::eraseFromParent]. **)
849 See the method [llvm::BasicBlock::eraseFromParent]. *)
832850 external delete_block : llbasicblock -> unit = "llvm_delete_block"
833851
834852 (** [append_block name f] creates a new basic block named [name] at the end of
835853 function [f].
836 See the constructor of [llvm::BasicBlock]. **)
854 See the constructor of [llvm::BasicBlock]. *)
837855 external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
838856
839857 (** [insert_block name bb] creates a new basic block named [name] before the
840858 basic block [bb].
841 See the constructor of [llvm::BasicBlock]. **)
859 See the constructor of [llvm::BasicBlock]. *)
842860 external insert_block : string -> llbasicblock -> llbasicblock
843861 = "llvm_insert_block"
844862
845 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. **)
863 (** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
846864 external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
847865
848866 (** [value_is_block v] returns [true] if the value [v] is a basic block and
849867 [false] otherwise.
850 Similar to [llvm::isa]. **)
868 Similar to [llvm::isa]. *)
851869 external value_is_block : llvalue -> bool = "llvm_value_is_block"
852870
853 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. **)
871 (** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
854872 external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
855873
856 (*--... Operations on call sites ...........................................--*)
857
858 (** [inst_call_conv ci] is the calling convention for the call or invoke
859 instruction [ci], which may be one of the values from the module [CallConv].
860 See the method [CallSite:: **)
874
875 (** {7 Operations on call sites} *)
876
877 (** [instruction_call_conv ci] is the calling convention for the call or invoke
878 instruction [ci], which may be one of the values from the module
879 {!CallConv}. See the method [llvm::CallInst::getCallingConv] and
880 [llvm::InvokeInst::getCallingConv]. *)
861881 external instruction_call_conv: llvalue -> int
862882 = "llvm_instruction_call_conv"
863883
864884 (** [set_inst_call_conv cc ci] sets the calling convention for the call or
865885 invoke instruction [ci] to the integer [cc], which can be one of the values
866 from the module [CallConv]. See the method [CallSite::]. **)
886 from the module {!CallConv}. See the method [llvm::CallInst::setCallingConv]
887 and [llvm::InvokeInst::setCallingConv]. *)
867888 external set_instruction_call_conv: int -> llvalue -> unit
868889 = "llvm_set_instruction_call_conv"
869890
870 (*--... Operations on phi nodes ............................................--*)
891
892 (** {7 Operations on phi nodes} *)
871893
872894 (** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
873 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. **)
895 with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
874896 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
875897 = "llvm_add_incoming"
876898
877899 (** [incoming pn] returns the list of value-block pairs for phi node [pn].
878 See the method [llvm::PHINode::getIncomingValue]. **)
900 See the method [llvm::PHINode::getIncomingValue]. *)
879901 external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
880902
881903
882 (*===-- Instruction builders ----------------------------------------------===*)
904
905 (** {6 Instruction builders} *)
883906
884907 (** [builder] creates an instruction builder with no position. It is invalid to
885 use this builder until its position is set with [position_before] or
886 [position_at_end]. See the constructor for [llvm::LLVMBuilder]. **)
908 use this builder until its position is set with {!position_before} or
909 {!position_at_end}. See the constructor for [llvm::LLVMBuilder]. *)
887910 external builder: unit-> llbuilder
888911 = "llvm_builder"
889912
890913 (** [builder_before ins] creates an instruction builder positioned before the
891 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
914 instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
892915 external builder_before : llvalue -> llbuilder = "llvm_builder_before"
893916
894917 (** [builder_at_end bb] creates an instruction builder positioned at the end of
895 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. **)
918 the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
896919 external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
897920
898921 (** [position_before ins b] moves the instruction builder [b] to before the
899 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
922 instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
900923 external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
901924
902925 (** [position_at_end bb b] moves the instruction builder [b] to the end of the
903 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. **)
926 basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
904927 external position_at_end : llbasicblock -> llbuilder -> unit
905928 = "llvm_position_at_end"
906929
907 (*--... Terminators ........................................................--*)
930
931 (** {7 Terminators} *)
908932
909933 (** [build_ret_void b] creates a
910934 [ret void]
911935 instruction at the position specified by the instruction builder [b].
912 See the method [llvm::LLVMBuilder::CreateRetVoid]. **)
936 See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
913937 external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
914938
915939 (** [build_ret v b] creates a
916940 [ret %v]
917941 instruction at the position specified by the instruction builder [b].
918 See the method [llvm::LLVMBuilder::CreateRet]. **)
942 See the method [llvm::LLVMBuilder::CreateRet]. *)
919943 external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
920944
921945 (** [build_br bb b] creates a
922946 [b %bb]
923947 instruction at the position specified by the instruction builder [b].
924 See the method [llvm::LLVMBuilder::CreateBr]. **)
948 See the method [llvm::LLVMBuilder::CreateBr]. *)
925949 external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
926950
927951 (** [build_cond_br cond tbb fbb b] creates a
928952 [b %cond, %tbb, %fbb]
929953 instruction at the position specified by the instruction builder [b].
930 See the method [llvm::LLVMBuilder::CreateCondBr]. **)
954 See the method [llvm::LLVMBuilder::CreateCondBr]. *)
931955 external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
932956 llvalue = "llvm_build_cond_br"
933957
934958 (** [build_switch case elsebb b] creates an empty
935959 [switch %case, %elsebb]
936960 instruction at the position specified by the instruction builder [b].
937 See the method [llvm::LLVMBuilder::CreateSwitch]. **)
961 See the method [llvm::LLVMBuilder::CreateSwitch]. *)
938962 external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
939963 = "llvm_build_switch"
940964
941965 (** [build_invoke fn args tobb unwindbb name b] creates an
942966 [%name = invoke %fn(args) to %tobb unwind %unwindbb]
943967 instruction at the position specified by the instruction builder [b].
944 See the method [llvm::LLVMBuilder::CreateInvoke]. **)
968 See the method [llvm::LLVMBuilder::CreateInvoke]. *)
945969 external build_invoke : llvalue -> llvalue array -> llbasicblock ->
946970 llbasicblock -> string -> llbuilder -> llvalue
947971 = "llvm_build_invoke_bc" "llvm_build_invoke_nat"
949973 (** [build_unwind b] creates an
950974 [unwind]
951975 instruction at the position specified by the instruction builder [b].
952 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
976 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
953977 external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
954978
955979 (** [build_unreachable b] creates an
956980 [unreachable]
957981 instruction at the position specified by the instruction builder [b].
958 See the method [llvm::LLVMBuilder::CreateUnwind]. **)
982 See the method [llvm::LLVMBuilder::CreateUnwind]. *)
959983 external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
960984
961 (*--... Arithmetic .........................................................--*)
985
986 (** {7 Arithmetic} *)
962987
963988 (** [build_add x y name b] creates a
964989 [%name = add %x, %y]
965990 instruction at the position specified by the instruction builder [b].
966 See the method [llvm::LLVMBuilder::CreateAdd]. **)
991 See the method [llvm::LLVMBuilder::CreateAdd]. *)
967992 external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
968993 = "llvm_build_add"
969994
970995 (** [build_sub x y name b] creates a
971996 [%name = sub %x, %y]
972997 instruction at the position specified by the instruction builder [b].
973 See the method [llvm::LLVMBuilder::CreateSub]. **)
998 See the method [llvm::LLVMBuilder::CreateSub]. *)
974999 external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
9751000 = "llvm_build_sub"
9761001
9771002 (** [build_mul x y name b] creates a
9781003 [%name = mul %x, %y]
9791004 instruction at the position specified by the instruction builder [b].
980 See the method [llvm::LLVMBuilder::CreateMul]. **)
1005 See the method [llvm::LLVMBuilder::CreateMul]. *)
9811006 external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
9821007 = "llvm_build_mul"
9831008
9841009 (** [build_udiv x y name b] creates a
9851010 [%name = udiv %x, %y]
9861011 instruction at the position specified by the instruction builder [b].
987 See the method [llvm::LLVMBuilder::CreateUDiv]. **)
1012 See the method [llvm::LLVMBuilder::CreateUDiv]. *)
9881013 external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
9891014 = "llvm_build_udiv"
9901015
9911016 (** [build_sdiv x y name b] creates a
9921017 [%name = sdiv %x, %y]
9931018 instruction at the position specified by the instruction builder [b].
994 See the method [llvm::LLVMBuilder::CreateSDiv]. **)
1019 See the method [llvm::LLVMBuilder::CreateSDiv]. *)
9951020 external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
9961021 = "llvm_build_sdiv"
9971022
9981023 (** [build_fdiv x y name b] creates a
9991024 [%name = fdiv %x, %y]
10001025 instruction at the position specified by the instruction builder [b].
1001 See the method [llvm::LLVMBuilder::CreateFDiv]. **)
1026 See the method [llvm::LLVMBuilder::CreateFDiv]. *)
10021027 external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
10031028 = "llvm_build_fdiv"
10041029
10051030 (** [build_urem x y name b] creates a
10061031 [%name = urem %x, %y]
10071032 instruction at the position specified by the instruction builder [b].
1008 See the method [llvm::LLVMBuilder::CreateURem]. **)
1033 See the method [llvm::LLVMBuilder::CreateURem]. *)
10091034 external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
10101035 = "llvm_build_urem"
10111036
10121037 (** [build_SRem x y name b] creates a
10131038 [%name = srem %x, %y]
10141039 instruction at the position specified by the instruction builder [b].
1015 See the method [llvm::LLVMBuilder::CreateSRem]. **)
1040 See the method [llvm::LLVMBuilder::CreateSRem]. *)
10161041 external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
10171042 = "llvm_build_srem"
10181043
10191044 (** [build_frem x y name b] creates a
10201045 [%name = frem %x, %y]
10211046 instruction at the position specified by the instruction builder [b].
1022 See the method [llvm::LLVMBuilder::CreateFRem]. **)
1047 See the method [llvm::LLVMBuilder::CreateFRem]. *)
10231048 external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
10241049 = "llvm_build_frem"
10251050
10261051 (** [build_shl x y name b] creates a
10271052 [%name = shl %x, %y]
10281053 instruction at the position specified by the instruction builder [b].
1029 See the method [llvm::LLVMBuilder::CreateShl]. **)
1054 See the method [llvm::LLVMBuilder::CreateShl]. *)
10301055 external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
10311056 = "llvm_build_shl"
10321057
10331058 (** [build_lshr x y name b] creates a
10341059 [%name = lshr %x, %y]
10351060 instruction at the position specified by the instruction builder [b].
1036 See the method [llvm::LLVMBuilder::CreateLShr]. **)
1061 See the method [llvm::LLVMBuilder::CreateLShr]. *)
10371062 external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
10381063 = "llvm_build_lshr"
10391064
10401065 (** [build_ashr x y name b] creates a
10411066 [%name = ashr %x, %y]
10421067 instruction at the position specified by the instruction builder [b].
1043 See the method [llvm::LLVMBuilder::CreateAShr]. **)
1068 See the method [llvm::LLVMBuilder::CreateAShr]. *)
10441069 external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
10451070 = "llvm_build_ashr"
10461071
10471072 (** [build_and x y name b] creates a
10481073 [%name = and %x, %y]
10491074 instruction at the position specified by the instruction builder [b].
1050 See the method [llvm::LLVMBuilder::CreateAnd]. **)
1075 See the method [llvm::LLVMBuilder::CreateAnd]. *)
10511076 external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
10521077 = "llvm_build_and"
10531078
10541079 (** [build_or x y name b] creates a
10551080 [%name = or %x, %y]
10561081 instruction at the position specified by the instruction builder [b].
1057 See the method [llvm::LLVMBuilder::CreateOr]. **)
1082 See the method [llvm::LLVMBuilder::CreateOr]. *)
10581083 external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
10591084 = "llvm_build_or"
10601085
10611086 (** [build_xor x y name b] creates a
10621087 [%name = xor %x, %y]
10631088 instruction at the position specified by the instruction builder [b].
1064 See the method [llvm::LLVMBuilder::CreateXor]. **)
1089 See the method [llvm::LLVMBuilder::CreateXor]. *)
10651090 external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
10661091 = "llvm_build_xor"
10671092
10691094 [%name = sub 0, %x]
10701095 instruction at the position specified by the instruction builder [b].
10711096 [-0.0] is used for floating point types to compute the correct sign.
1072 See the method [llvm::LLVMBuilder::CreateNeg]. **)
1097 See the method [llvm::LLVMBuilder::CreateNeg]. *)
10731098 external build_neg : llvalue -> string -> llbuilder -> llvalue
10741099 = "llvm_build_neg"
10751100
10771102 [%name = xor %x, -1]
10781103 instruction at the position specified by the instruction builder [b].
10791104 [-1] is the correct "all ones" value for the type of [x].
1080 See the method [llvm::LLVMBuilder::CreateXor]. **)
1105 See the method [llvm::LLVMBuilder::CreateXor]. *)
10811106 external build_not : llvalue -> string -> llbuilder -> llvalue
10821107 = "llvm_build_not"
10831108
1084 (*--... Memory .............................................................--*)
1109
1110 (** {7 Memory} *)
10851111
10861112 (** [build_malloc ty name b] creates a
10871113 [%name = malloc %ty]
10881114 instruction at the position specified by the instruction builder [b].
1089 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1115 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
10901116 external build_malloc : lltype -> string -> llbuilder -> llvalue
10911117 = "llvm_build_malloc"
10921118
10931119 (** [build_array_malloc ty n name b] creates a
10941120 [%name = malloc %ty, %n]
10951121 instruction at the position specified by the instruction builder [b].
1096 See the method [llvm::LLVMBuilder::CreateMalloc]. **)
1122 See the method [llvm::LLVMBuilder::CreateMalloc]. *)
10971123 external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
10981124 llvalue = "llvm_build_array_malloc"
10991125
11001126 (** [build_alloca ty name b] creates a
11011127 [%name = alloca %ty]
11021128 instruction at the position specified by the instruction builder [b].
1103 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1129 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
11041130 external build_alloca : lltype -> string -> llbuilder -> llvalue
11051131 = "llvm_build_alloca"
11061132
11071133 (** [build_array_alloca ty n name b] creates a
11081134 [%name = alloca %ty, %n]
11091135 instruction at the position specified by the instruction builder [b].
1110 See the method [llvm::LLVMBuilder::CreateAlloca]. **)
1136 See the method [llvm::LLVMBuilder::CreateAlloca]. *)
11111137 external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
11121138 llvalue = "llvm_build_array_alloca"
11131139
11141140 (** [build_free v b] creates a
11151141 [free %v]
11161142 instruction at the position specified by the instruction builder [b].
1117 See the method [llvm::LLVMBuilder::CreateFree]. **)
1143 See the method [llvm::LLVMBuilder::CreateFree]. *)
11181144 external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
11191145
11201146 (** [build_load v name b] creates a
11211147 [%name = load %v]
11221148 instruction at the position specified by the instruction builder [b].
1123 See the method [llvm::LLVMBuilder::CreateLoad]. **)
1149 See the method [llvm::LLVMBuilder::CreateLoad]. *)
11241150 external build_load : llvalue -> string -> llbuilder -> llvalue
11251151 = "llvm_build_load"
11261152
11271153 (** [build_store v p b] creates a
11281154 [store %v, %p]
11291155 instruction at the position specified by the instruction builder [b].
1130 See the method [llvm::LLVMBuilder::CreateStore]. **)
1156 See the method [llvm::LLVMBuilder::CreateStore]. *)
11311157 external build_store : llvalue -> llvalue -> llbuilder -> llvalue
11321158 = "llvm_build_store"
11331159
11341160 (** [build_gep p indices name b] creates a
11351161 [%name = gep %p, indices...]
11361162 instruction at the position specified by the instruction builder [b].
1137 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. **)
1163 See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
11381164 external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
11391165 = "llvm_build_gep"
11401166
1141 (*--... Casts ..............................................................--*)
1167
1168 (** {7 Casts} *)
11421169
11431170 (** [build_trunc v ty name b] creates a
11441171 [%name = trunc %p to %ty]
11451172 instruction at the position specified by the instruction builder [b].
1146 See the method [llvm::LLVMBuilder::CreateTrunc]. **)
1173 See the method [llvm::LLVMBuilder::CreateTrunc]. *)
11471174 external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
11481175 = "llvm_build_trunc"
11491176
11501177 (** [build_zext v ty name b] creates a
11511178 [%name = zext %p to %ty]
11521179 instruction at the position specified by the instruction builder [b].
1153 See the method [llvm::LLVMBuilder::CreateZExt]. **)
1180 See the method [llvm::LLVMBuilder::CreateZExt]. *)
11541181 external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
11551182 = "llvm_build_zext"
11561183
11571184 (** [build_sext v ty name b] creates a
11581185 [%name = sext %p to %ty]
11591186 instruction at the position specified by the instruction builder [b].
1160 See the method [llvm::LLVMBuilder::CreateSExt]. **)
1187 See the method [llvm::LLVMBuilder::CreateSExt]. *)
11611188 external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
11621189 = "llvm_build_sext"
11631190
11641191 (** [build_fptoui v ty name b] creates a
11651192 [%name = fptoui %p to %ty]
11661193 instruction at the position specified by the instruction builder [b].
1167 See the method [llvm::LLVMBuilder::CreateFPToUI]. **)
1194 See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
11681195 external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
11691196 = "llvm_build_fptoui"
11701197
11711198 (** [build_fptosi v ty name b] creates a
11721199 [%name = fptosi %p to %ty]
11731200 instruction at the position specified by the instruction builder [b].
1174 See the method [llvm::LLVMBuilder::CreateFPToSI]. **)
1201 See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
11751202 external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
11761203 = "llvm_build_fptosi"
11771204
11781205 (** [build_uitofp v ty name b] creates a
11791206 [%name = uitofp %p to %ty]
11801207 instruction at the position specified by the instruction builder [b].
1181 See the method [llvm::LLVMBuilder::CreateUIToFP]. **)
1208 See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
11821209 external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
11831210 = "llvm_build_uitofp"
11841211
11851212 (** [build_sitofp v ty name b] creates a
11861213 [%name = sitofp %p to %ty]
11871214 instruction at the position specified by the instruction builder [b].
1188 See the method [llvm::LLVMBuilder::CreateSIToFP]. **)
1215 See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
11891216 external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
11901217 = "llvm_build_sitofp"
11911218
11921219 (** [build_fptrunc v ty name b] creates a
11931220 [%name = fptrunc %p to %ty]
11941221 instruction at the position specified by the instruction builder [b].
1195 See the method [llvm::LLVMBuilder::CreateFPTrunc]. **)
1222 See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
11961223 external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
11971224 = "llvm_build_fptrunc"
11981225
11991226 (** [build_fpext v ty name b] creates a
12001227 [%name = fpext %p to %ty]
12011228 instruction at the position specified by the instruction builder [b].
1202 See the method [llvm::LLVMBuilder::CreateFPExt]. **)
1229 See the method [llvm::LLVMBuilder::CreateFPExt]. *)
12031230 external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
12041231 = "llvm_build_fpext"
12051232
12061233 (** [build_ptrtoint v ty name b] creates a
12071234 [%name = prtotint %p to %ty]
12081235 instruction at the position specified by the instruction builder [b].
1209 See the method [llvm::LLVMBuilder::CreatePtrToInt]. **)
1236 See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
12101237 external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
12111238 = "llvm_build_prttoint"
12121239
12131240 (** [build_inttoptr v ty name b] creates a
12141241 [%name = inttoptr %p to %ty]
12151242 instruction at the position specified by the instruction builder [b].
1216 See the method [llvm::LLVMBuilder::CreateIntToPtr]. **)
1243 See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
12171244 external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
12181245 = "llvm_build_inttoptr"
12191246
12201247 (** [build_bitcast v ty name b] creates a
12211248 [%name = bitcast %p to %ty]
12221249 instruction at the position specified by the instruction builder [b].
1223 See the method [llvm::LLVMBuilder::CreateBitcast]. **)
1250 See the method [llvm::LLVMBuilder::CreateBitcast]. *)
12241251 external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
12251252 = "llvm_build_bitcast"
12261253
1227 (*--... Comparisons ........................................................--*)
1254
1255 (** {7 Comparisons} *)
12281256
12291257 (** [build_icmp pred x y name b] creates a
12301258 [%name = icmp %pred %x, %y]
12311259 instruction at the position specified by the instruction builder [b].
1232 See the method [llvm::LLVMBuilder::CreateICmp]. **)
1260 See the method [llvm::LLVMBuilder::CreateICmp]. *)
12331261 external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
12341262 llbuilder -> llvalue = "llvm_build_icmp"
12351263
12361264 (** [build_fcmp pred x y name b] creates a
12371265 [%name = fcmp %pred %x, %y]
12381266 instruction at the position specified by the instruction builder [b].
1239 See the method [llvm::LLVMBuilder::CreateFCmp]. **)
1267 See the method [llvm::LLVMBuilder::CreateFCmp]. *)
12401268 external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
12411269 llbuilder -> llvalue = "llvm_build_fcmp"
12421270
1243 (*--... Miscellaneous instructions .........................................--*)
1271
1272 (** {7 Miscellaneous instructions} *)
12441273
12451274 (** [build_phi incoming name b] creates a
12461275 [%name = phi %incoming]
12471276 instruction at the position specified by the instruction builder [b].
1248 [incoming] is a list of [(llvalue, llbasicblock)] tuples.
1249 See the method [llvm::LLVMBuilder::CreatePHI]. **)
1277 [incoming] is a list of [({!llvalue}, {!llbasicblock})] tuples.
1278 See the method [llvm::LLVMBuilder::CreatePHI]. *)
12501279 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
12511280 llvalue = "llvm_build_phi"
12521281
12531282 (** [build_call fn args name b] creates a
12541283 [%name = call %fn(args...)]
12551284 instruction at the position specified by the instruction builder [b].
1256 See the method [llvm::LLVMBuilder::CreateCall]. **)
1285 See the method [llvm::LLVMBuilder::CreateCall]. *)
12571286 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
12581287 = "llvm_build_call"
12591288
12601289 (** [build_select cond thenv elsev name b] creates a
12611290 [%name = select %cond, %thenv, %elsev]
12621291 instruction at the position specified by the instruction builder [b].
1263 See the method [llvm::LLVMBuilder::CreateSelect]. **)
1292 See the method [llvm::LLVMBuilder::CreateSelect]. *)
12641293 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
12651294 llvalue = "llvm_build_select"
12661295
12671296 (** [build_va_arg valist argty name b] creates a
12681297 [%name = va_arg %valist, %argty]
12691298 instruction at the position specified by the instruction builder [b].
1270 See the method [llvm::LLVMBuilder::CreateVAArg]. **)
1299 See the method [llvm::LLVMBuilder::CreateVAArg]. *)
12711300 external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
12721301 = "llvm_build_va_arg"
12731302
12741303 (** [build_extractelement vec i name b] creates a
12751304 [%name = extractelement %vec, %i]
12761305 instruction at the position specified by the instruction builder [b].
1277 See the method [llvm::LLVMBuilder::CreateExtractElement]. **)
1306 See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
12781307 external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
12791308 llvalue = "llvm_build_extractelement"
12801309
12811310 (** [build_insertelement vec elt i name b] creates a
12821311 [%name = insertelement %vec, %elt, %i]
12831312 instruction at the position specified by the instruction builder [b].
1284 See the method [llvm::LLVMBuilder::CreateInsertElement]. **)
1313 See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
12851314 external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
12861315 llbuilder -> llvalue = "llvm_build_insertelement"
12871316
12881317 (** [build_shufflevector veca vecb mask name b] creates a
12891318 [%name = shufflevector %veca, %vecb, %mask]
12901319 instruction at the position specified by the instruction builder [b].
1291 See the method [llvm::LLVMBuilder::CreateShuffleVector]. **)
1320 See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
12921321 external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
12931322 llbuilder -> llvalue = "llvm_build_shufflevector"
12941323
12951324
1296 (*===-- Module providers --------------------------------------------------===*)
1325 (** {6 Module providers} *)
12971326
12981327 module ModuleProvider : sig
12991328 (** [create_module_provider m] encapsulates [m] in a module provider and takes
1300 ownership of the module. See the constructor
1301 [llvm::ExistingModuleProvider::ExistingModuleProvider]. **)
1329 ownership of the module. See the constructor
1330 [llvm::ExistingModuleProvider::ExistingModuleProvider]. *)
13021331 external create : llmodule -> llmoduleprovider
13031332 = "LLVMCreateModuleProviderForExistingModule"
1304
1333
13051334 (** [dispose_module_provider mp] destroys the module provider [mp] as well as
1306 the contained module. **)
1335 the contained module. *)
13071336 external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider"
13081337 end
1309
1310
1311 (*===-- Memory buffers ----------------------------------------------------===*)
1338
1339
1340 (** {6 Memory buffers} *)
13121341
13131342 module MemoryBuffer : sig
1314 (** [of_file p] is the memory buffer containing the contents of the file at
1315 path [p]. If the file could not be read, then [IoError msg] is raised. **)
1343 (** [of_file p] is the memory buffer containing the contents of the file at
1344 path [p]. If the file could not be read, then [IoError msg] is
1345 raised. *)
13161346 external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
13171347
13181348 (** [stdin ()] is the memory buffer containing the contents of standard input.
1319 If standard input is empty, then [IoError msg] is raised. **)
1349 If standard input is empty, then [IoError msg] is raised. *)
13201350 external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
13211351
1322 (** Disposes of a memory buffer. **)
1352 (** Disposes of a memory buffer. *)
13231353 external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
13241354 end