X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=bindings%2Focaml%2Fllvm%2Fllvm.mli;h=4f28ae687564eb41acf91d5390cc0b243850ae8d;hb=1430425539fd8004e47ab664c5e5fe5dc23c6d58;hp=3c58ce9b3ac49a2e7cd9fd16937058a51b61925e;hpb=1b42cfd1ca03e48835e8e4c91c5dbb598030257f;p=oota-llvm.git diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 3c58ce9b3ac..4f28ae68756 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -17,6 +17,10 @@ These abstract types correlate directly to the LLVM VMCore classes. *) +(** The top-level container for all LLVM global data. See the + [llvm::LLVMContext] class. *) +type llcontext + (** The top-level container for all other LLVM Intermediate Representation (IR) objects. See the [llvm::Module] class. *) type llmodule @@ -78,13 +82,18 @@ module Linkage : sig External | Available_externally | Link_once + | Link_once_odr | Weak + | Weak_odr | Appending | Internal + | Private | Dllimport | Dllexport | External_weak | Ghost + | Common + | Linker_private end (** The linker visibility of a global value, accessed with {!visibility} and @@ -125,6 +134,16 @@ module Attribute : sig | Nest | Readnone | Readonly + | Noinline + | Alwaysinline + | Optsize + | Ssp + | Sspreq + | Nocapture + | Noredzone + | Noimplicitfloat + | Naked + | Inlinehint end (** The predicate for an integer comparison ([icmp]) instruction. @@ -188,12 +207,27 @@ type ('a, 'b) llrev_pos = exception IoError of string +(** {6 Contexts} *) + +(** [create_context ()] creates a context for storing the "global" state in + LLVM. See the constructor [llvm::LLVMContext]. *) +external create_context : unit -> llcontext = "llvm_create_context" + +(** [destroy_context ()] destroys a context. See the destructor + [llvm::LLVMContext::~LLVMContext]. *) +external dispose_context : llcontext -> unit = "llvm_dispose_context" + +(** See the function [llvm::getGlobalContext]. *) +external global_context : unit -> llcontext = "llvm_global_context" + + (** {6 Modules} *) -(** [create_module id] creates a module with the supplied module ID. Modules are - not garbage collected; it is mandatory to call {!dispose_module} to free - memory. See the constructor [llvm::Module::Module]. *) -external create_module : string -> llmodule = "llvm_create_module" +(** [create_module context id] creates a module with the supplied module ID in + the context [context]. Modules are not garbage collected; it is mandatory + to call {!dispose_module} to free memory. See the constructor + [llvm::Module::Module]. *) +external create_module : llcontext -> string -> llmodule = "llvm_create_module" (** [dispose_module m] destroys a module [m] and all of the IR objects it contained. All references to subordinate objects are invalidated; @@ -245,51 +279,65 @@ external dump_module : llmodule -> unit = "llvm_dump_module" See the method [llvm::Type::getTypeID]. *) external classify_type : lltype -> TypeKind.t = "llvm_classify_type" +(** [type_context ty] returns the {!llcontext} corresponding to the type [ty]. + See the method [llvm::Type::getContext]. *) +external type_context : lltype -> llcontext = "llvm_type_context" + (** [string_of_lltype ty] returns a string describing the type [ty]. *) val string_of_lltype : lltype -> string (** {7 Operations on integer types} *) -(** The 1-bit integer type. See [llvm::Type::Int1Ty]. *) -val i1_type : lltype +(** [i1_type c] returns an integer type of bitwidth 1 in the context [c]. See + [llvm::Type::Int1Ty]. *) +external i1_type : llcontext -> lltype = "llvm_i1_type" -(** The 8-bit integer type. See [llvm::Type::Int8Ty]. *) -val i8_type : lltype +(** [i8_type c] returns an integer type of bitwidth 8 in the context [c]. See + [llvm::Type::Int8Ty]. *) +external i8_type : llcontext -> lltype = "llvm_i8_type" -(** The 16-bit integer type. See [llvm::Type::Int16Ty]. *) -val i16_type : lltype +(** [i16_type c] returns an integer type of bitwidth 16 in the context [c]. See + [llvm::Type::Int16Ty]. *) +external i16_type : llcontext -> lltype = "llvm_i16_type" -(** The 32-bit integer type. See [llvm::Type::Int32Ty]. *) -val i32_type : lltype +(** [i32_type c] returns an integer type of bitwidth 32 in the context [c]. See + [llvm::Type::Int32Ty]. *) +external i32_type : llcontext -> lltype = "llvm_i32_type" -(** The 64-bit integer type. See [llvm::Type::Int64Ty]. *) -val i64_type : lltype +(** [i64_type c] returns an integer type of bitwidth 64 in the context [c]. See + [llvm::Type::Int64Ty]. *) +external i64_type : llcontext -> lltype = "llvm_i64_type" -(** [integer_type n] returns an integer type of bitwidth [n]. - See the method [llvm::IntegerType::get]. *) -external integer_type : int -> lltype = "llvm_integer_type" +(** [integer_type c n] returns an integer type of bitwidth [n] in the context + [c]. See the method [llvm::IntegerType::get]. *) +external integer_type : llcontext -> int -> lltype = "llvm_integer_type" -(** [integer_bitwidth ty] returns the number of bits in the integer type [ty]. - See the method [llvm::IntegerType::getBitWidth]. *) +(** [integer_bitwidth c ty] returns the number of bits in the integer type [ty] + in the context [c]. See the method [llvm::IntegerType::getBitWidth]. *) external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth" (** {7 Operations on real types} *) -(** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. *) -val float_type : lltype +(** [float_type c] returns the IEEE 32-bit floating point type in the context + [c]. See [llvm::Type::FloatTy]. *) +external float_type : llcontext -> lltype = "llvm_float_type" -(** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. *) -val double_type : lltype +(** [double_type c] returns the IEEE 64-bit floating point type in the context + [c]. See [llvm::Type::DoubleTy]. *) +external double_type : llcontext -> lltype = "llvm_double_type" -(** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. *) -val x86fp80_type : lltype +(** [x86fp80_type c] returns the x87 80-bit floating point type in the context + [c]. See [llvm::Type::X86_FP80Ty]. *) +external x86fp80_type : llcontext -> lltype = "llvm_x86fp80_type" -(** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. *) -val fp128_type : lltype +(** [fp128_type c] returns the IEEE 128-bit floating point type in the context + [c]. See [llvm::Type::FP128Ty]. *) +external fp128_type : llcontext -> lltype = "llvm_fp128_type" -(** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. *) -val ppc_fp128_type : lltype +(** [ppc_fp128_type c] returns the PowerPC 128-bit floating point type in the + context [c]. See [llvm::Type::PPC_FP128Ty]. *) +external ppc_fp128_type : llcontext -> lltype = "llvm_ppc_fp128_type" (** {7 Operations on function types} *) @@ -321,13 +369,17 @@ external param_types : lltype -> lltype array = "llvm_param_types" (** {7 Operations on struct types} *) -(** [struct_type tys] returns the structure type containing in the types in the - array [tys]. See the method [llvm::StructType::get]. *) -external struct_type : lltype array -> lltype = "llvm_struct_type" +(** [struct_type context tys] returns the structure type in the context + [context] containing in the types in the array [tys]. See the method + [llvm::StructType::get]. *) +external struct_type : llcontext -> lltype array -> lltype + = "llvm_struct_type" -(** [packed_struct_type tys] returns the packed structure type containing in the - types in the array [tys]. See the method [llvm::StructType::get]. *) -external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type" +(** [packed_struct_type context ys] returns the packed structure type in the + context [context] containing in the types in the array [tys]. See the method + [llvm::StructType::get]. *) +external packed_struct_type : llcontext -> lltype array -> lltype + = "llvm_packed_struct_type" (** [element_types sty] returns the constituent types of the struct type [sty]. See the method [llvm::StructType::getElementType]. *) @@ -378,18 +430,18 @@ external vector_size : lltype -> int = "llvm_vector_size" (** {7 Operations on other types} *) -(** [opaque_type ()] creates a new opaque type distinct from any other. - Opaque types are useful for building recursive types in combination with - {!refine_type}. - See [llvm::OpaqueType::get]. *) -external opaque_type : unit -> lltype = "llvm_opaque_type" +(** [opaque_type c] creates a new opaque type distinct from any other in the + context [c]. Opaque types are useful for building recursive types in + combination with {!refine_type}. See [llvm::OpaqueType::get]. *) +external opaque_type : llcontext -> lltype = "llvm_opaque_type" -(** [void_type] is the type of a function which does not return any value. - See [llvm::Type::VoidTy]. *) -val void_type : lltype +(** [void_type c] creates a type of a function which does not return any + value in the context [c]. See [llvm::Type::VoidTy]. *) +external void_type : llcontext -> lltype = "llvm_void_type" -(** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. *) -val label_type : lltype +(** [label_type c] creates a type of a basic block in the context [c]. See + [llvm::Type::LabelTy]. *) +external label_type : llcontext -> lltype = "llvm_label_type" (** {7 Operations on type handles} *) @@ -469,24 +521,35 @@ external const_int : lltype -> int -> llvalue = "llvm_const_int" external const_of_int64 : lltype -> Int64.t -> bool -> llvalue = "llvm_const_of_int64" +(** [const_int_of_string ty s r] returns the integer constant of type [ty] and + * value [s], with the radix [r]. See the method [llvm::ConstantInt::get]. *) +external const_int_of_string : lltype -> string -> int -> llvalue + = "llvm_const_int_of_string" + (** [const_float ty n] returns the floating point constant of type [ty] and value [n]. See the method [llvm::ConstantFP::get]. *) external const_float : lltype -> float -> llvalue = "llvm_const_float" +(** [const_float_of_string ty s] returns the floating point constant of type + [ty] and value [n]. See the method [llvm::ConstantFP::get]. *) +external const_float_of_string : lltype -> string -> llvalue + = "llvm_const_float_of_string" + (** {7 Operations on composite constants} *) -(** [const_string s] returns the constant [i8] array with the values of the - characters in the string [s]. The array is not null-terminated (but see - {!const_stringz}). This value can in turn be used as the initializer for a - global variable. See the method [llvm::ConstantArray::get]. *) -external const_string : string -> llvalue = "llvm_const_string" +(** [const_string c s] returns the constant [i8] array with the values of the + characters in the string [s] in the context [c]. The array is not + null-terminated (but see {!const_stringz}). This value can in turn be used + as the initializer for a global variable. See the method + [llvm::ConstantArray::get]. *) +external const_string : llcontext -> string -> llvalue = "llvm_const_string" -(** [const_stringz s] returns the constant [i8] array with the values of the - characters in the string [s] and a null terminator. This value can in turn - be used as the initializer for a global variable. +(** [const_stringz c s] returns the constant [i8] array with the values of the + characters in the string [s] and a null terminator in the context [c]. This + value can in turn be used as the initializer for a global variable. See the method [llvm::ConstantArray::get]. *) -external const_stringz : string -> llvalue = "llvm_const_stringz" +external const_stringz : llcontext -> string -> llvalue = "llvm_const_stringz" (** [const_array ty elts] returns the constant array of type [array_type ty (Array.length elts)] and containing the values [elts]. @@ -494,17 +557,19 @@ external const_stringz : string -> llvalue = "llvm_const_stringz" See the method [llvm::ConstantArray::get]. *) external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array" -(** [const_struct elts] returns the structured constant of type - [struct_type (Array.map type_of elts)] and containing the values [elts]. - This value can in turn be used as the initializer for a global variable. - See the method [llvm::ConstantStruct::get]. *) -external const_struct : llvalue array -> llvalue = "llvm_const_struct" - -(** [const_packed_struct elts] returns the structured constant of type - {!packed_struct_type} [(Array.map type_of elts)] and containing the values - [elts]. This value can in turn be used as the initializer for a global - variable. See the method [llvm::ConstantStruct::get]. *) -external const_packed_struct : llvalue array -> llvalue +(** [const_struct context elts] returns the structured constant of type + [struct_type (Array.map type_of elts)] and containing the values [elts] + in the context [context]. This value can in turn be used as the initializer + for a global variable. See the method [llvm::ConstantStruct::get]. *) +external const_struct : llcontext -> llvalue array -> llvalue + = "llvm_const_struct" + +(** [const_packed_struct context elts] returns the structured constant of + type {!packed_struct_type} [(Array.map type_of elts)] and containing the + values [elts] in the context [context]. This value can in turn be used as + the initializer for a global variable. See the method + [llvm::ConstantStruct::get]. *) +external const_packed_struct : llcontext -> llvalue array -> llvalue = "llvm_const_packed_struct" (** [const_vector elts] returns the vector constant of type @@ -580,7 +645,7 @@ external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv" (** [const_exact_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed integer constants. The result is undefined if the result is rounded - or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *) + or overflows. See the method [llvm::ConstantExpr::getExactSDiv]. *) external const_exact_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstExactSDiv" (** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating @@ -747,7 +812,7 @@ external const_intcast : llvalue -> lltype -> llvalue = "LLVMConstIntCast" (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp -> - fp casts of constant [c] to type [ty]. + fp casts of constant [c] to type [ty]. See the method [llvm::ConstantExpr::getFPCast]. *) external const_fpcast : llvalue -> lltype -> llvalue = "LLVMConstFPCast" @@ -1120,15 +1185,16 @@ external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock" See the method [llvm::BasicBlock::eraseFromParent]. *) external delete_block : llbasicblock -> unit = "llvm_delete_block" -(** [append_block name f] creates a new basic block named [name] at the end of - function [f]. +(** [append_block c name f] creates a new basic block named [name] at the end of + function [f] in the context [c]. See the constructor of [llvm::BasicBlock]. *) -external append_block : string -> llvalue -> llbasicblock = "llvm_append_block" +external append_block : llcontext -> string -> llvalue -> llbasicblock + = "llvm_append_block" -(** [insert_block name bb] creates a new basic block named [name] before the - basic block [bb]. +(** [insert_block c name bb] creates a new basic block named [name] before the + basic block [bb] in the context [c]. See the constructor of [llvm::BasicBlock]. *) -external insert_block : string -> llbasicblock -> llbasicblock +external insert_block : llcontext -> string -> llbasicblock -> llbasicblock = "llvm_insert_block" (** [block_parent bb] returns the parent function that owns the basic block. @@ -1287,22 +1353,23 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming" (** {6 Instruction builders} *) -(** [builder ()] creates an instruction builder with no position. It is invalid - to use this builder until its position is set with {!position_before} or - {!position_at_end}. See the constructor for [llvm::LLVMBuilder]. *) -external builder : unit -> llbuilder = "llvm_builder" +(** [builder context] creates an instruction builder with no position in + the context [context]. It is invalid to use this builder until its position + is set with {!position_before} or {!position_at_end}. See the constructor + for [llvm::LLVMBuilder]. *) +external builder : llcontext -> llbuilder = "llvm_builder" (** [builder_at ip] creates an instruction builder positioned at [ip]. See the constructor for [llvm::LLVMBuilder]. *) -val builder_at : (llbasicblock, llvalue) llpos -> llbuilder +val builder_at : llcontext -> (llbasicblock, llvalue) llpos -> llbuilder (** [builder_before ins] creates an instruction builder positioned before the instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *) -val builder_before : llvalue -> llbuilder +val builder_before : llcontext -> llvalue -> llbuilder (** [builder_at_end bb] creates an instruction builder positioned at the end of the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *) -val builder_at_end : llbasicblock -> llbuilder +val builder_at_end : llcontext -> llbasicblock -> llbuilder (** [position_builder ip bb] moves the instruction builder [bb] to the position [ip]. @@ -1324,6 +1391,12 @@ val position_at_end : llbasicblock -> llbuilder -> unit See the method [llvm::LLVMBuilder::GetInsertBlock]. *) external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block" +(** [insert_into_builder i name b] inserts the specified instruction [i] at the + position specified by the instruction builder [b]. + See the method [llvm::LLVMBuilder::Insert]. *) +external insert_into_builder : llvalue -> string -> llbuilder -> unit + = "llvm_insert_into_builder" + (** {7 Terminators} *) @@ -1347,13 +1420,13 @@ external build_aggregate_ret : llvalue array -> llbuilder -> llvalue = "llvm_build_aggregate_ret" (** [build_br bb b] creates a - [b %bb] + [br %bb] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateBr]. *) external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br" (** [build_cond_br cond tbb fbb b] creates a - [b %cond, %tbb, %fbb] + [br %cond, %tbb, %fbb] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateCondBr]. *) external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder -> @@ -1403,7 +1476,7 @@ external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable" external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue = "llvm_build_add" -(** [build_nswadd x y name b] creates a +(** [build_nsw_add x y name b] creates a [%name = nsw add %x, %y] instruction at the position specified by the instruction builder [b]. See the method [llvm::LLVMBuilder::CreateNSWAdd]. *) @@ -1632,7 +1705,7 @@ external build_global_string : string -> string -> llbuilder -> llvalue (** [build_global_stringptr str name b] creates a series of instructions that adds a global string pointer at the position specified by the instruction - builder [b]. + builder [b]. See the method [llvm::LLVMBuilder::CreateGlobalStringPtr]. *) external build_global_stringptr : string -> string -> llbuilder -> llvalue = "llvm_build_global_stringptr" @@ -1860,7 +1933,7 @@ external build_is_not_null : llvalue -> string -> llbuilder -> llvalue (** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure the difference between two pointer values at the position specified by the - instruction builder [b]. + instruction builder [b]. See the method [llvm::LLVMBuilder::CreatePtrDiff]. *) external build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue = "llvm_build_ptrdiff"