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