+
+(** [build_is_not_null val name b] creates a
+ [%name = icmp ne %val, null]
+ instruction at the position specified by the instruction builder [b].
+ See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
+val 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].
+ See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
+val build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
+
+
+
+(** {6 Memory buffers} *)
+
+module MemoryBuffer : sig
+ (** [of_file p] is the memory buffer containing the contents of the file at
+ path [p]. If the file could not be read, then [IoError msg] is
+ raised. *)
+ val of_file : string -> llmemorybuffer
+
+ (** [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
+
+ (** Disposes of a memory buffer. *)
+ val dispose : llmemorybuffer -> unit
+end
+
+
+(** {6 Pass Managers} *)
+
+module PassManager : sig
+ (** *)
+ 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
+ tasks.
+ See the constructor of [llvm::FunctionPassManager]. *)
+ val create_function : llmodule -> [ `Function ] t
+
+
+ (** [run_module m pm] initializes, executes on the module [m], and finalizes
+ all of the passes scheduled in the pass manager [pm]. Returns [true] if
+ any of the passes modified the module, [false] otherwise.
+ See the [llvm::PassManager::run] method. *)
+ val run_module : llmodule -> [ `Module ] t -> bool
+
+
+ (** [initialize fpm] initializes all of the function passes scheduled in the
+ function pass manager [fpm]. Returns [true] if any of the passes modified
+ 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]. *)
+ val dispose : [< any ] t -> unit
+end