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
| Pointer
| Vector
| Metadata
+ | X86_mmx
end
(** The linkage of a global value, accessed with {!linkage} and
| Available_externally
| Link_once
| Link_once_odr
+ | Link_once_odr_auto_hide
| Weak
| Weak_odr
| Appending
| Ghost
| Common
| Linker_private
+ | Linker_private_weak
end
(** The linker visibility of a global value, accessed with {!visibility} and
| Protected
end
+(** The DLL storage class of a global value, accessed with {!dll_storage_class} and
+ {!set_dll_storage_class}. See [llvm::GlobalValue::DLLStorageClassTypes]. *)
+module DLLStorageClass : sig
+ type t =
+ | Default
+ | DLLImport
+ | DLLExport
+end
+
(** The following calling convention values may be accessed with
{!function_call_conv} and {!set_function_call_conv}. Calling
conventions are open-ended. *)
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
See the [llvm::ICmpInst::Predicate] enumeration. *)
module Icmp : sig
type t =
- | Eq
- | Ne
- | Ugt
- | Uge
- | Ult
- | Ule
- | Sgt
- | Sge
- | Slt
- | Sle
+ | Eq (** Equal *)
+ | Ne (** Not equal *)
+ | Ugt (** Unsigned greater than *)
+ | Uge (** Unsigned greater or equal *)
+ | Ult (** Unsigned less than *)
+ | Ule (** Unsigned less or equal *)
+ | Sgt (** Signed greater than *)
+ | Sge (** Signed greater or equal *)
+ | Slt (** Signed less than *)
+ | Sle (** Signed less or equal *)
end
(** The predicate for a floating-point comparison ([fcmp]) instruction.
+ Ordered means that neither operand is a QNAN while unordered means
+ that either operand may be a QNAN.
See the [llvm::FCmpInst::Predicate] enumeration. *)
module Fcmp : sig
type t =
- | False
- | Oeq
- | Ogt
- | Oge
- | Olt
- | Ole
- | One
- | Ord
- | Uno
- | Ueq
- | Ugt
- | Uge
- | Ult
- | Ule
- | Une
- | True
+ | False (** Always false *)
+ | Oeq (** Ordered and equal *)
+ | Ogt (** Ordered and greater than *)
+ | Oge (** Ordered and greater or equal *)
+ | Olt (** Ordered and less than *)
+ | Ole (** Ordered and less or equal *)
+ | One (** Ordered and not equal *)
+ | Ord (** Ordered (no operand is NaN) *)
+ | Uno (** Unordered (one operand at least is NaN) *)
+ | Ueq (** Unordered and equal *)
+ | Ugt (** Unordered and greater than *)
+ | Uge (** Unordered and greater or equal *)
+ | Ult (** Unordered and less than *)
+ | Ule (** Unordered and less or equal *)
+ | Une (** Unordered and not equal *)
+ | True (** Always true *)
end
(** The opcodes for LLVM instructions and constant expressions. *)
module Opcode : sig
type t =
- | Invalid (* not an instruction *)
- (* Terminator Instructions *)
- | Ret
+ | Invalid (** Not an instruction *)
+
+ | Ret (** Terminator Instructions *)
| Br
| Switch
| IndirectBr
| Invoke
| Invalid2
| Unreachable
- (* Standard Binary Operators *)
- | Add
+
+ | Add (** Standard Binary Operators *)
| FAdd
| Sub
| FSub
| URem
| SRem
| FRem
- (* Logical Operators *)
- | Shl
+
+ | Shl (** Logical Operators *)
| LShr
| AShr
| And
| Or
| Xor
- (* Memory Operators *)
- | Alloca
+
+ | Alloca (** Memory Operators *)
| Load
| Store
| GetElementPtr
- (* Cast Operators *)
- | Trunc
+
+ | Trunc (** Cast Operators *)
| ZExt
| SExt
| FPToUI
| PtrToInt
| IntToPtr
| BitCast
- (* Other Operators *)
- | ICmp
+
+ | ICmp (** Other Operators *)
| FCmp
| PHI
| Call
| AtomicRMW
| Resume
| LandingPad
- | Unwind
+end
+
+(** The type of a clause of a [landingpad] instruction.
+ See [llvm::LandingPadInst::ClauseType]. *)
+module LandingPadClauseTy : sig
+ type t =
+ | Catch
+ | Filter
+end
+
+(** The thread local mode of a global value, accessed with {!thread_local_mode}
+ and {!set_thread_local_mode}.
+ See [llvm::GlobalVariable::ThreadLocalMode]. *)
+module ThreadLocalMode : sig
+ type t =
+ | None
+ | GeneralDynamic
+ | LocalDynamic
+ | InitialExec
+ | LocalExec
+end
+
+(** The ordering of an atomic [load], [store], [cmpxchg], [atomicrmw] or
+ [fence] instruction. See [llvm::AtomicOrdering]. *)
+module AtomicOrdering : sig
+ type t =
+ | NotAtomic
+ | Unordered
+ | Monotonic
+ | Invalid (** removed due to API changes *)
+ | Acquire
+ | Release
+ | AcqiureRelease
+ | SequentiallyConsistent
+end
+
+(** The opcode of an [atomicrmw] instruction.
+ See [llvm::AtomicRMWInst::BinOp]. *)
+module AtomicRMWBinOp : sig
+ type t =
+ | Xchg
+ | Add
+ | Sub
+ | And
+ | Nand
+ | Or
+ | Xor
+ | Max
+ | Min
+ | UMax
+ | UMin
end
(** The kind of an [llvalue], the result of [classify_value v].
| BlockAddress
| ConstantAggregateZero
| ConstantArray
+ | ConstantDataArray
+ | ConstantDataVector
| ConstantExpr
| ConstantFP
| ConstantInt
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
+
+(** [parse_command_line_options ?overview args] parses [args] using
+ the LLVM command line parser. Note that the only stable thing about this
+ function is its signature; you cannot rely on any particular set of command
+ line arguments being interpreted the same way across LLVM versions.
+
+ See the function [llvm::cl::ParseCommandLineOptions()]. *)
+val parse_command_line_options : ?overview:string -> string array -> unit
+
(** {6 Contexts} *)
(** [create_context ()] creates a context for storing the "global" state in
(** [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} *)
error. See the method [llvm::Module::dump]. *)
val dump_module : llmodule -> unit
+(** [print_module f m] prints the .ll representation of the module [m]
+ to file [f]. See the method [llvm::Module::print]. *)
+val print_module : string -> llmodule -> unit
+
+(** [string_of_llmodule m] returns the .ll representation of the module [m]
+ as a string. See the method [llvm::Module::print]. *)
+val string_of_llmodule : llmodule -> string
+
(** [set_module_inline_asm m asm] sets the inline assembler for the module. See
the method [llvm::Module::setModuleInlineAsm]. *)
val set_module_inline_asm : llmodule -> string -> unit
See the method [llvm::Type::getContext]. *)
val type_context : lltype -> llcontext
+(** [dump_type ty] prints the .ll representation of the type [ty] to standard
+ error. See the method [llvm::Type::dump]. *)
+val dump_type : lltype -> unit
+
(** [string_of_lltype ty] returns a string describing the type [ty]. *)
val string_of_lltype : lltype -> string
[llvm::Type::LabelTy]. *)
val label_type : llcontext -> lltype
+(** [x86_mmx_type c] returns the x86 64-bit MMX register type in the
+ context [c]. See [llvm::Type::X86_MMXTy]. *)
+val x86_mmx_type : llcontext -> lltype
+
(** [type_by_name m name] returns the specified type from the current module
if it exists.
See the method [llvm::Module::getTypeByName] *)
val type_by_name : llmodule -> string -> lltype option
-(* {6 Values} *)
+(** {6 Values} *)
(** [type_of v] returns the type of the value [v].
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
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
-(* {6 Uses} *)
+(** {6 Uses} *)
(** [use_begin v] returns the first position in the use list for the value [v].
[use_begin] and [use_succ] can e used to iterate over the use list in order.
val fold_right_uses : (lluse -> 'a -> 'a) -> llvalue -> 'a -> 'a
-(* {6 Users} *)
+(** {6 Users} *)
(** [operand v i] returns the operand at index [i] for the value [v]. See the
method [llvm::User::getOperand]. *)
val operand : llvalue -> int -> llvalue
+(** [operand_use v i] returns the use of the operand at index [i] for the value [v]. See the
+ method [llvm::User::getOperandUse]. *)
+val operand_use : llvalue -> int -> lluse
+
+
(** [set_operand v i o] sets the operand of the value [v] at the index [i] to
the value [o].
See the method [llvm::User::setOperand]. *)
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
(** [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} *)
See the method [llvm::MDNode::get]. *)
val mdnode : llcontext -> llvalue array -> llvalue
+(** [mdnull c ] returns a null MDNode in context [c]. *)
+val mdnull : llcontext -> llvalue
+
(** [get_mdstring v] returns the MDString.
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
+(** [add_named_metadata_operand m name v] adds [v] as the last operand of
+ metadata named [name] in module [m]. If the metadata does not exist,
+ it is created.
+ See the methods [llvm::Module::getNamedMetadata()] and
+ [llvm::MDNode::addOperand()]. *)
+val add_named_metadata_operand : llmodule -> string -> llvalue -> unit
+
(** {7 Operations on scalar constants} *)
value [n]. See the method [llvm::ConstantFP::get]. *)
val const_float : lltype -> float -> llvalue
+(** [float_of_const c] returns the float value of the [c] constant float.
+ None is returned if this is not an float constant.
+ See the method [llvm::ConstantFP::getDoubleValue].*)
+val float_of_const : llvalue -> float option
+
(** [const_float_of_string ty s] returns the floating point constant of type
[ty] and value [n]. See the method [llvm::ConstantFP::get]. *)
val const_float_of_string : lltype -> string -> llvalue
-
(** {7 Operations on composite constants} *)
(** [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
+ 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]. *)
values [elts]. See the method [llvm::ConstantVector::get]. *)
val const_vector : llvalue array -> llvalue
+(** [string_of_const c] returns [Some str] if [c] is a string constant,
+ or [None] if this is not a string constant. *)
+val string_of_const : llvalue -> string option
+
+(** [const_element c] returns a constant for a specified index's element.
+ See the method ConstantDataSequential::getElementAsConstant. *)
+val const_element : llvalue -> int -> llvalue
+
(** {7 Constant expressions} *)
See the method [llvm::ConstantExpr::getAShr]. *)
val const_ashr : llvalue -> llvalue -> llvalue
-(** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
+(** [const_gep pc indices] returns the constant [getElementPtr] of [pc] with the
constant integers indices from the array [indices].
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
val const_gep : llvalue -> llvalue array -> llvalue
-(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [p1]
+(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [pc]
with the constant integers indices from the array [indices].
See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
val const_in_bounds_gep : llvalue -> llvalue array -> 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].
[v]. See the method [llvm::GlobalValue::setVisibility]. *)
val set_visibility : Visibility.t -> llvalue -> unit
+(** [dll_storage_class g] returns the DLL storage class of the global value [g].
+ See the method [llvm::GlobalValue::getDLLStorageClass]. *)
+val dll_storage_class : llvalue -> DLLStorageClass.t
+
+(** [set_dll_storage_class v g] sets the DLL storage class of the global value [g] to
+ [v]. See the method [llvm::GlobalValue::setDLLStorageClass]. *)
+val set_dll_storage_class : DLLStorageClass.t -> llvalue -> unit
+
(** [alignment g] returns the required alignment of the global value [g].
See the method [llvm::GlobalValue::getAlignment]. *)
val alignment : llvalue -> int
See the method [llvm::GlobalVariable::setThreadLocal]. *)
val set_thread_local : bool -> llvalue -> unit
+(** [is_thread_local gv] returns the thread local mode of the global
+ variable [gv].
+ See the method [llvm::GlobalVariable::getThreadLocalMode]. *)
+val thread_local_mode : llvalue -> ThreadLocalMode.t
+
+(** [set_thread_local c gv] sets the thread local mode of the global
+ variable [gv].
+ See the method [llvm::GlobalVariable::setThreadLocalMode]. *)
+val set_thread_local_mode : ThreadLocalMode.t -> llvalue -> unit
+
+(** [is_externally_initialized gv] returns [true] if the global
+ variable [gv] is externally initialized and [false] otherwise.
+ See the method [llvm::GlobalVariable::isExternallyInitialized]. *)
+val is_externally_initialized : llvalue -> bool
+
+(** [set_externally_initialized c gv] sets the global variable [gv] to be
+ externally initialized if [c] is [true] and not otherwise.
+ See the method [llvm::GlobalVariable::setExternallyInitialized]. *)
+val set_externally_initialized : bool -> llvalue -> unit
+
(** {7 Operations on aliases} *)
[f]. *)
val add_function_attr : llvalue -> Attribute.t -> unit
+(** [add_target_dependent_function_attr f a] adds target-dependent attribute
+ [a] to function [f]. *)
+val add_target_dependent_function_attr : llvalue -> string -> string -> unit
+
(** [function_attr f] returns the function attribute for the function [f].
See the method [llvm::Function::getAttributes] *)
val function_attr : llvalue -> Attribute.t list
See the method [llvm::BasicBlock::eraseFromParent]. *)
val delete_block : llbasicblock -> unit
+(** [remove_block bb] removes the basic block [bb] from its parent function.
+ See the method [llvm::BasicBlock::removeFromParent]. *)
+val remove_block : llbasicblock -> unit
+
+(** [move_block_before pos bb] moves the basic block [bb] before [pos].
+ See the method [llvm::BasicBlock::moveBefore]. *)
+val move_block_before : llbasicblock -> llbasicblock -> unit
+
+(** [move_block_after pos bb] moves the basic block [bb] after [pos].
+ See the method [llvm::BasicBlock::moveAfter]. *)
+val move_block_after : llbasicblock -> llbasicblock -> unit
+
(** [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]. *)
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
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.
[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
+(** [fcmp_predicate i] returns the [fcmp.t] corresponding to an [fcmp]
+ instruction [i]. *)
+val fcmp_predicate : llvalue -> Fcmp.t option
+
+(** [inst_clone i] returns a copy of instruction [i],
+ The instruction has no parent, and no name.
+ See the method [llvm::Instruction::clone]. *)
+val instr_clone : llvalue -> llvalue
+
(** {7 Operations on call sites} *)
val remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
-(** {Operations on call instructions (only)} *)
+(** {7 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.
val set_tail_call : bool -> llvalue -> unit
+(** {7 Operations on load/store instructions (only)} *)
+
+(** [is_volatile i] is [true] if the load or store instruction [i] is marked
+ as volatile.
+ See the methods [llvm::LoadInst::isVolatile] and
+ [llvm::StoreInst::isVolatile]. *)
+val is_volatile : llvalue -> bool
+
+(** [set_volatile v i] marks the load or store instruction [i] as volatile
+ if [v] is [true], unmarks otherwise.
+ See the methods [llvm::LoadInst::setVolatile] and
+ [llvm::StoreInst::setVolatile]. *)
+val set_volatile : bool -> llvalue -> unit
+
+(** {7 Operations on terminators} *)
+
+(** [is_terminator v] returns true if the instruction [v] is a terminator. *)
+val is_terminator : llvalue -> bool
+
+(** [successor v i] returns the successor at index [i] for the value [v].
+ See the method [llvm::TerminatorInst::getSuccessor]. *)
+val successor : llvalue -> int -> llbasicblock
+
+(** [set_successor v i o] sets the successor of the value [v] at the index [i] to
+ the value [o].
+ See the method [llvm::TerminatorInst::setSuccessor]. *)
+val set_successor : llvalue -> int -> llbasicblock -> unit
+
+(** [num_successors v] returns the number of successors for the value [v].
+ See the method [llvm::TerminatorInst::getNumSuccessors]. *)
+val num_successors : llvalue -> int
+
+(** [successors v] returns the successors of [v]. *)
+val successors : llvalue -> llbasicblock array
+
+(** [iter_successors f v] applies function f to each successor [v] in order. Tail recursive. *)
+val iter_successors : (llbasicblock -> unit) -> llvalue -> unit
+
+(** [fold_successors f v init] is [f (... (f init vN) ...) v1] where [v1,...,vN] are the successors of [v]. Tail recursive. *)
+val fold_successors : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
+
+(** {7 Operations on branches} *)
+
+(** [is_conditional v] returns true if the branch instruction [v] is conditional.
+ See the method [llvm::BranchInst::isConditional]. *)
+val is_conditional : llvalue -> bool
+
+(** [condition v] return the condition of the branch instruction [v].
+ See the method [llvm::BranchInst::getCondition]. *)
+val condition : llvalue -> llvalue
+
+(** [set_condition v c] sets the condition of the branch instruction [v] to the value [c].
+ See the method [llvm::BranchInst::setCondition]. *)
+val set_condition : llvalue -> llvalue -> unit
+
+(** [get_branch c] returns a description of the branch instruction [c]. *)
+val get_branch : llvalue ->
+ [ `Conditional of llvalue * llbasicblock * llbasicblock
+ | `Unconditional of llbasicblock ]
+ option
+
(** {7 Operations on phi nodes} *)
(** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
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} *)
See the method [llvm::LLVMBuilder::CreateStore]. *)
val build_store : llvalue -> llvalue -> llbuilder -> llvalue
+(** [build_atomicrmw op ptr val o st b] creates an [atomicrmw] instruction with
+ operation [op] performed on pointer [ptr] and value [val] with ordering [o]
+ and singlethread flag set to [st] at the position specified by
+ the instruction builder [b].
+ See the method [llvm::IRBuilder::CreateAtomicRMW]. *)
+val build_atomicrmw : AtomicRMWBinOp.t -> llvalue -> llvalue ->
+ AtomicOrdering.t -> bool -> string -> llbuilder -> llvalue
+
(** [build_gep p indices name b] creates a
[%name = getelementptr %p, indices...]
instruction at the position specified by the instruction builder [b].
val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
llvalue
+(** [build_empty_phi ty name b] creates a
+ [%name = phi %ty] instruction at the position specified by
+ the instruction builder [b]. [ty] is the type of the instruction.
+ See the method [llvm::LLVMBuilder::CreatePHI]. *)
+val build_empty_phi : lltype -> string -> llbuilder -> llvalue
+
(** [build_call fn args name b] creates a
[%name = call %fn(args...)]
instruction at the position specified by the instruction builder [b].
val build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
llbuilder -> llvalue
-(** [build_insertvalue agg idx name b] creates a
+(** [build_extractvalue agg idx name b] creates a
[%name = extractvalue %agg, %idx]
instruction at the position specified by the instruction builder [b].
See the method [llvm::LLVMBuilder::CreateExtractValue]. *)
path [p]. If the file could not be read, then [IoError msg] is
raised. *)
val of_file : string -> llmemorybuffer
-
+
(** [of_stdin ()] is the memory buffer containing the contents of standard input.
If standard input is empty, then [IoError msg] is raised. *)
val of_stdin : unit -> llmemorybuffer
(** [as_string mb] is the string containing the contents of memory buffer [mb]. *)
val as_string : llmemorybuffer -> string
-
+
(** Disposes of a memory buffer. *)
val dispose : llmemorybuffer -> unit
end
(** *)
type 'a t
type any = [ `Module | `Function ]
-
+
(** [PassManager.create ()] constructs a new whole-module pass pipeline. This
type of pipeline is suitable for link-time optimization and whole-module
transformations.
See the constructor of [llvm::PassManager]. *)
val create : unit -> [ `Module ] t
-
+
(** [PassManager.create_function m] constructs a new function-by-function
pass pipeline over the module [m]. It does not take ownership of [m].
This type of pipeline is suitable for code generation and JIT compilation
the module, [false] otherwise.
See the [llvm::FunctionPassManager::doInitialization] method. *)
val initialize : [ `Function ] t -> bool
-
+
(** [run_function f fpm] executes all of the function passes scheduled in the
function pass manager [fpm] over the function [f]. Returns [true] if any
of the passes modified [f], [false] otherwise.
See the [llvm::FunctionPassManager::run] method. *)
val run_function : llvalue -> [ `Function ] t -> bool
-
+
(** [finalize fpm] finalizes all of the function passes scheduled in in the
function pass manager [fpm]. Returns [true] if any of the passes
modified the module, [false] otherwise.
See the [llvm::FunctionPassManager::doFinalization] method. *)
val finalize : [ `Function ] t -> bool
-
+
(** Frees the memory of a pass pipeline. For function pipelines, does not free
the module.
See the destructor of [llvm::BasePassManager]. *)