[OCaml] Commit missing parts of r210395
[oota-llvm.git] / bindings / ocaml / llvm / llvm.mli
index 6f0832cb13506012be05a469c49de07a03f3b06f..59a89db5f489bb40b0908958338c53b0d286b068 100644 (file)
@@ -48,6 +48,9 @@ type llbuilder
     See the [llvm::MemoryBuffer] class. *)
 type llmemorybuffer
 
+(** The kind id of metadata attached to an instruction. *)
+type llmdkind
+
 (** The kind of an [lltype], the result of [classify_type ty]. See the
     [llvm::Type::TypeID] enumeration. *)
 module TypeKind : sig
@@ -118,6 +121,8 @@ module CallConv : sig
                               convention from C. *)
 end
 
+(** The attribute kind of a function parameter, result or the function itself.
+    See [llvm::Attribute::AttrKind]. *)
 module Attribute : sig
   type t =
   | Zext
@@ -321,6 +326,8 @@ module ValueKind : sig
   | BlockAddress
   | ConstantAggregateZero
   | ConstantArray
+  | ConstantDataArray
+  | ConstantDataVector
   | ConstantExpr
   | ConstantFP
   | ConstantInt
@@ -357,6 +364,21 @@ type ('a, 'b) llrev_pos =
 exception IoError of string
 
 
+(** {6 Global configuration} *)
+
+(** [enable_pretty_stacktraces ()] enables LLVM's built-in stack trace code.
+    This intercepts the OS's crash signals and prints which component of LLVM
+    you were in at the time of the crash. *)
+val enable_pretty_stacktrace : unit -> unit
+
+(** [install_fatal_error_handler f] installs [f] as LLVM's fatal error handler.
+    The handler will receive the reason for termination as a string. After
+    the handler has been executed, LLVM calls [exit(1)]. *)
+val install_fatal_error_handler : (string -> unit) -> unit
+
+(** [reset_fatal_error_handler ()] resets LLVM's fatal error handler. *)
+val reset_fatal_error_handler : unit -> unit
+
 (** {6 Contexts} *)
 
 (** [create_context ()] creates a context for storing the "global" state in
@@ -373,7 +395,7 @@ val global_context : unit -> llcontext
 (** [mdkind_id context name] returns the MDKind ID that corresponds to the
     name [name] in the context [context].  See the function
     [llvm::LLVMContext::getMDKindID]. *)
-val mdkind_id : llcontext -> string -> int
+val mdkind_id : llcontext -> string -> llmdkind
 
 
 (** {6 Modules} *)
@@ -633,6 +655,7 @@ val type_by_name : llmodule -> string -> lltype option
     See the method [llvm::Value::getType]. *)
 val type_of : llvalue -> lltype
 
+(** [classify_value v] returns the kind of the value [v]. *)
 val classify_value : llvalue -> ValueKind.t
 
 (** [value_name v] returns the name of the value [v]. For global values, this is
@@ -649,6 +672,9 @@ val set_value_name : string -> llvalue -> unit
     error. See the method [llvm::Value::dump]. *)
 val dump_value : llvalue -> unit
 
+(** [string_of_llvalue v] returns a string describing the value [v]. *)
+val string_of_llvalue : llvalue -> string
+
 (** [replace_all_uses_with old new] replaces all uses of the value [old]
     with the value [new]. See the method [llvm::Value::replaceAllUsesWith]. *)
 val replace_all_uses_with : llvalue -> llvalue -> unit
@@ -732,6 +758,8 @@ val is_null : llvalue -> bool
     otherwise. Similar to [llvm::isa<UndefValue>]. *)
 val is_undef : llvalue -> bool
 
+(** [constexpr_opcode v] returns an [Opcode.t] corresponding to constexpr
+    value [v], or [Opcode.Invalid] if [v] is not a constexpr. *)
 val constexpr_opcode : llvalue -> Opcode.t
 
 
@@ -745,15 +773,15 @@ val has_metadata : llvalue -> bool
 (** [metadata i kind] optionally returns the metadata associated with the
     kind [kind] in the instruction [i] See the function
     [llvm::Instruction::getMetadata]. *)
-val metadata : llvalue -> int -> llvalue option
+val metadata : llvalue -> llmdkind -> llvalue option
 
 (** [set_metadata i kind md] sets the metadata [md] of kind [kind] in the
     instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
-val set_metadata : llvalue -> int -> llvalue -> unit
+val set_metadata : llvalue -> llmdkind -> llvalue -> unit
 
 (** [clear_metadata i kind] clears the metadata of kind [kind] in the
     instruction [i]. See the function [llvm::Instruction::setMetadata]. *)
-val clear_metadata : llvalue -> int -> unit
+val clear_metadata : llvalue -> llmdkind -> unit
 
 
 (** {7 Operations on metadata} *)
@@ -771,7 +799,7 @@ val mdnode : llcontext -> llvalue array -> llvalue
     See the method [llvm::MDString::getString] *)
 val get_mdstring : llvalue -> string option
 
-(** [get_named_metadata m name] return all the MDNodes belonging to the named
+(** [get_named_metadata m name] returns all the MDNodes belonging to the named
     metadata (if any).
     See the method [llvm::NamedMDNode::getOperand]. *)
 val get_named_metadata : llmodule -> string -> llvalue array
@@ -1113,10 +1141,12 @@ val const_trunc_or_bitcast : llvalue -> lltype -> llvalue
     See the method [llvm::ConstantExpr::getPointerCast]. *)
 val const_pointercast : llvalue -> lltype -> llvalue
 
-(** [const_intcast c ty] returns a constant zext, bitcast, or trunc for integer
-    -> integer casts of constant [c] to type [ty].
-    See the method [llvm::ConstantExpr::getIntCast]. *)
-val const_intcast : llvalue -> lltype -> llvalue
+(** [const_intcast c ty ~is_signed] returns a constant sext/zext, bitcast,
+    or trunc for integer -> integer casts of constant [c] to type [ty].
+    When converting a narrower value to a wider one, whether sext or zext
+    will be used is controlled by [is_signed].
+    See the method [llvm::ConstantExpr::getIntegerCast]. *)
+val const_intcast : llvalue -> lltype -> is_signed:bool -> llvalue
 
 (** [const_fpcast c ty] returns a constant fpext, bitcast, or fptrunc for fp ->
     fp casts of constant [c] to type [ty].
@@ -1578,10 +1608,11 @@ val fold_left_blocks : ('a -> llbasicblock -> 'a) -> 'a -> llvalue -> 'a
     See the method [llvm::Function::end]. *)
 val block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
 
-(** [block_pred gv] returns the function list position preceding [After gv].
+(** [block_pred bb] returns the basic block list position preceding [After bb].
     See the method [llvm::Function::iterator::operator--]. *)
 val block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
 
+(** [block_terminator bb] returns the terminator of the basic block [bb]. *)
 val block_terminator : llbasicblock -> llvalue option
 
 (** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
@@ -1610,6 +1641,10 @@ val block_of_value : llvalue -> llbasicblock
     See the method [llvm::Instruction::getParent]. *)
 val instr_parent : llvalue -> llbasicblock
 
+(** [delete_instruction i] deletes the instruction [i].
+ * See the method [llvm::Instruction::eraseFromParent]. *)
+val delete_instruction : llvalue -> unit
+
 (** [instr_begin bb] returns the first position in the instruction list of the
     basic block [bb]. [instr_begin] and [instr_succ] can be used to iterate over
     the instruction list in order.
@@ -1642,8 +1677,12 @@ val instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
     [f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
 val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a
 
+(** [inst_opcode i] returns the [Opcode.t] corresponding to instruction [i],
+    or [Opcode.Invalid] if [i] is not an instruction. *)
 val instr_opcode : llvalue -> Opcode.t
 
+(** [icmp_predicate i] returns the [Icmp.t] corresponding to an [icmp]
+    instruction [i]. *)
 val icmp_predicate : llvalue -> Icmp.t option
 
 
@@ -1673,7 +1712,7 @@ val add_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
 val remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
 
 
-(** {Operations on call instructions (only)} *)
+(** {Operations on call instructions (only)} *)
 
 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
     eligible for tail call optimization, [false] otherwise.
@@ -1711,9 +1750,6 @@ val add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
     See the method [llvm::PHINode::getIncomingValue]. *)
 val incoming : llvalue -> (llvalue * llbasicblock) list
 
-(** [delete_instruction i] deletes the instruction [i].
- * See the method [llvm::Instruction::eraseFromParent]. *)
-val delete_instruction : llvalue -> unit
 
 
 (** {6 Instruction builders} *)