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