2008-03-07 19:13:06 +00:00
|
|
|
(*===-- llvm/llvm.mli - LLVM Ocaml Interface -------------------------------===*
|
2007-09-18 12:49:39 +00:00
|
|
|
*
|
|
|
|
* The LLVM Compiler Infrastructure
|
|
|
|
*
|
2007-12-29 22:59:10 +00:00
|
|
|
* This file is distributed under the University of Illinois Open Source
|
|
|
|
* License. See LICENSE.TXT for details.
|
2007-09-18 12:49:39 +00:00
|
|
|
*
|
|
|
|
*===----------------------------------------------------------------------===*)
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** Core API.
|
|
|
|
|
|
|
|
This interface provides an ocaml API for the LLVM intermediate
|
|
|
|
representation, the classes in the VMCore library. *)
|
|
|
|
|
|
|
|
|
|
|
|
(** {6 Abstract types}
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
These abstract types correlate directly to the LLVM VMCore classes. *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** The top-level container for all other LLVM Intermediate Representation (IR)
|
2008-03-09 07:17:38 +00:00
|
|
|
objects. See the [llvm::Module] class. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
type llmodule
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** Each value in the LLVM IR has a type, an instance of [lltype]. See the
|
2008-03-09 07:17:38 +00:00
|
|
|
[llvm::Type] class. *)
|
|
|
|
type lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** When building recursive types using {!refine_type}, [lltype] values may
|
2007-12-01 21:01:15 +00:00
|
|
|
become invalid; use [lltypehandle] to resolve this problem. See the
|
2008-03-09 07:17:38 +00:00
|
|
|
[llvm::AbstractTypeHolder] class. *)
|
2007-10-07 00:13:35 +00:00
|
|
|
type lltypehandle
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** Any value in the LLVM IR. Functions, instructions, global variables,
|
|
|
|
constants, and much more are all [llvalues]. See the [llvm::Value] class.
|
2008-03-09 07:17:38 +00:00
|
|
|
This type covers a wide range of subclasses. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
type llvalue
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** A basic block in LLVM IR. See the [llvm::BasicBlock] class. *)
|
2007-12-01 21:01:15 +00:00
|
|
|
type llbasicblock
|
|
|
|
|
|
|
|
(** Used to generate instructions in the LLVM IR. See the [llvm::LLVMBuilder]
|
2008-03-09 07:17:38 +00:00
|
|
|
class. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
type llbuilder
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2007-12-19 22:30:40 +00:00
|
|
|
(** Used to provide a module to JIT or interpreter.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the [llvm::ModuleProvider] class. *)
|
2007-12-12 01:04:30 +00:00
|
|
|
type llmoduleprovider
|
|
|
|
|
2007-12-19 22:30:40 +00:00
|
|
|
(** Used to efficiently handle large buffers of read-only binary data.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the [llvm::MemoryBuffer] class. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
type llmemorybuffer
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The kind of an [lltype], the result of [classify_type ty]. See the
|
|
|
|
[llvm::Type::TypeID] enumeration. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
module TypeKind : sig
|
|
|
|
type t =
|
|
|
|
Void
|
|
|
|
| Float
|
|
|
|
| Double
|
|
|
|
| X86fp80
|
|
|
|
| Fp128
|
|
|
|
| Ppc_fp128
|
|
|
|
| Label
|
|
|
|
| Integer
|
|
|
|
| Function
|
|
|
|
| Struct
|
|
|
|
| Array
|
|
|
|
| Pointer
|
|
|
|
| Opaque
|
|
|
|
| Vector
|
|
|
|
end
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The linkage of a global value, accessed with {!linkage} and
|
|
|
|
{!set_linkage}. See [llvm::GlobalValue::LinkageTypes]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
module Linkage : sig
|
|
|
|
type t =
|
|
|
|
External
|
|
|
|
| Link_once
|
|
|
|
| Weak
|
|
|
|
| Appending
|
|
|
|
| Internal
|
|
|
|
| Dllimport
|
|
|
|
| Dllexport
|
|
|
|
| External_weak
|
|
|
|
| Ghost
|
|
|
|
end
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The linker visibility of a global value, accessed with {!visibility} and
|
|
|
|
{!set_visibility}. See [llvm::GlobalValue::VisibilityTypes]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
module Visibility : sig
|
|
|
|
type t =
|
|
|
|
Default
|
|
|
|
| Hidden
|
|
|
|
| Protected
|
|
|
|
end
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The following calling convention values may be accessed with
|
|
|
|
{!function_call_conv} and {!set_function_call_conv}. Calling
|
|
|
|
conventions are open-ended. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
module CallConv : sig
|
2008-03-09 07:17:38 +00:00
|
|
|
val c : int (** [c] is the C calling convention. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
val fast : int (** [fast] is the calling convention to allow LLVM
|
2007-12-01 21:01:15 +00:00
|
|
|
maximum optimization opportunities. Use only with
|
2008-03-09 07:17:38 +00:00
|
|
|
internal linkage. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
val cold : int (** [cold] is the calling convention for
|
2008-03-09 07:17:38 +00:00
|
|
|
callee-save. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
val x86_stdcall : int (** [x86_stdcall] is the familiar stdcall calling
|
2008-03-09 07:17:38 +00:00
|
|
|
convention from C. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
val x86_fastcall : int (** [x86_fastcall] is the familiar fastcall calling
|
2008-03-09 07:17:38 +00:00
|
|
|
convention from C. *)
|
2007-12-20 00:13:26 +00:00
|
|
|
end
|
2007-09-26 20:56:12 +00:00
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** The predicate for an integer comparison ([icmp]) instruction.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the [llvm::ICmpInst::Predicate] enumeration. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
module Icmp : sig
|
|
|
|
type t =
|
|
|
|
| Eq
|
|
|
|
| Ne
|
|
|
|
| Ugt
|
|
|
|
| Uge
|
|
|
|
| Ult
|
|
|
|
| Ule
|
|
|
|
| Sgt
|
|
|
|
| Sge
|
|
|
|
| Slt
|
|
|
|
| Sle
|
|
|
|
end
|
2007-09-26 20:56:12 +00:00
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** The predicate for a floating-point comparison ([fcmp]) instruction.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the [llvm::FCmpInst::Predicate] enumeration. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
module Fcmp : sig
|
|
|
|
type t =
|
|
|
|
| False
|
|
|
|
| Oeq
|
|
|
|
| Ogt
|
|
|
|
| Oge
|
|
|
|
| Olt
|
|
|
|
| Ole
|
|
|
|
| One
|
|
|
|
| Ord
|
|
|
|
| Uno
|
|
|
|
| Ueq
|
|
|
|
| Ugt
|
|
|
|
| Uge
|
|
|
|
| Ult
|
|
|
|
| Ule
|
|
|
|
| Une
|
|
|
|
| True
|
|
|
|
end
|
2007-09-26 20:56:12 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
2008-03-23 22:21:29 +00:00
|
|
|
(** {6 Iteration} *)
|
|
|
|
|
|
|
|
(** [Before b] and [At_end a] specify positions from the start of the ['b] list
|
2008-03-23 22:37:22 +00:00
|
|
|
of [a]. [llpos] is used to specify positions in and for forward iteration
|
2008-03-23 22:21:29 +00:00
|
|
|
through the various value lists maintained by the LLVM IR. *)
|
|
|
|
type ('a, 'b) llpos =
|
|
|
|
| At_end of 'a
|
|
|
|
| Before of 'b
|
|
|
|
|
|
|
|
(** [After b] and [At_start a] specify positions from the end of the ['b] list
|
|
|
|
of [a]. [llrev_pos] is used for reverse iteration through the various value
|
|
|
|
lists maintained by the LLVM IR. *)
|
|
|
|
type ('a, 'b) llrev_pos =
|
|
|
|
| At_start of 'a
|
|
|
|
| After of 'b
|
|
|
|
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {6 Exceptions} *)
|
|
|
|
|
2007-12-19 22:30:40 +00:00
|
|
|
exception IoError of string
|
|
|
|
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {6 Modules} *)
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [create_module id] creates a module with the supplied module ID. Modules are
|
2008-03-09 07:17:38 +00:00
|
|
|
not garbage collected; it is mandatory to call {!dispose_module} to free
|
2007-12-01 21:01:15 +00:00
|
|
|
memory. See the constructor [llvm::Module::Module]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external create_module : string -> llmodule = "llvm_create_module"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [dispose_module m] destroys a module [m] and all of the IR objects it
|
|
|
|
contained. All references to subordinate objects are invalidated;
|
|
|
|
referencing them will invoke undefined behavior. See the destructor
|
2008-03-09 07:17:38 +00:00
|
|
|
[llvm::Module::~Module]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external dispose_module : llmodule -> unit = "llvm_dispose_module"
|
|
|
|
|
2007-12-27 20:13:47 +00:00
|
|
|
(** [target_triple m] is the target specifier for the module [m], something like
|
2008-03-09 07:17:38 +00:00
|
|
|
[i686-apple-darwin8]. See the method [llvm::Module::getTargetTriple]. *)
|
2007-12-27 20:13:47 +00:00
|
|
|
external target_triple: llmodule -> string
|
|
|
|
= "llvm_target_triple"
|
|
|
|
|
|
|
|
(** [target_triple triple m] changes the target specifier for the module [m] to
|
2008-03-09 07:17:38 +00:00
|
|
|
the string [triple]. See the method [llvm::Module::setTargetTriple]. *)
|
2007-12-27 20:13:47 +00:00
|
|
|
external set_target_triple: string -> llmodule -> unit
|
|
|
|
= "llvm_set_target_triple"
|
|
|
|
|
|
|
|
(** [data_layout m] is the data layout specifier for the module [m], something
|
|
|
|
like [e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-...-a0:0:64-f80:128:128]. See the
|
2008-03-09 07:17:38 +00:00
|
|
|
method [llvm::Module::getDataLayout]. *)
|
2007-12-27 20:13:47 +00:00
|
|
|
external data_layout: llmodule -> string
|
|
|
|
= "llvm_data_layout"
|
|
|
|
|
|
|
|
(** [set_data_layout s m] changes the data layout specifier for the module [m]
|
2008-03-09 07:17:38 +00:00
|
|
|
to the string [s]. See the method [llvm::Module::setDataLayout]. *)
|
2007-12-27 20:13:47 +00:00
|
|
|
external set_data_layout: string -> llmodule -> unit
|
|
|
|
= "llvm_set_data_layout"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [define_type_name name ty m] adds a named type to the module's symbol table.
|
|
|
|
Returns [true] if successful. If such a name already exists, then no entry
|
|
|
|
is added and [false] is returned. See the [llvm::Module::addTypeName]
|
2008-03-09 07:17:38 +00:00
|
|
|
method. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external define_type_name : string -> lltype -> llmodule -> bool
|
|
|
|
= "llvm_add_type_name"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [delete_type_name name] removes a type name from the module's symbol
|
|
|
|
table. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external delete_type_name : string -> llmodule -> unit
|
|
|
|
= "llvm_delete_type_name"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-14 23:52:53 +00:00
|
|
|
(** [dump_module m] prints the .ll representation of the module [m] to standard
|
|
|
|
error. See the method [llvm::Module::dump]. *)
|
|
|
|
external dump_module : llmodule -> unit = "llvm_dump_module"
|
|
|
|
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {6 Types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [classify_type ty] returns the {!TypeKind.t} corresponding to the type [ty].
|
|
|
|
See the method [llvm::Type::getTypeID]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external classify_type : lltype -> TypeKind.t = "llvm_classify_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [string_of_lltype ty] returns a string describing the type [ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val string_of_lltype : lltype -> string
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {7 Operations on integer types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The 1-bit integer type. See [llvm::Type::Int1Ty]. *)
|
|
|
|
val i1_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The 8-bit integer type. See [llvm::Type::Int8Ty]. *)
|
|
|
|
val i8_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The 16-bit integer type. See [llvm::Type::Int16Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val i16_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The 32-bit integer type. See [llvm::Type::Int32Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val i32_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The 64-bit integer type. See [llvm::Type::Int64Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val i64_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [integer_type n] returns an integer type of bitwidth [n].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::IntegerType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external integer_type : int -> lltype = "llvm_integer_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [integer_bitwidth ty] returns the number of bits in the integer type [ty].
|
|
|
|
See the method [llvm::IntegerType::getBitWidth]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {7 Operations on real types} *)
|
|
|
|
|
|
|
|
(** The IEEE 32-bit floating point type. See [llvm::Type::FloatTy]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val float_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The IEEE 64-bit floating point type. See [llvm::Type::DoubleTy]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val double_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The x87 80-bit floating point type. See [llvm::Type::X86_FP80Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val x86fp80_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The IEEE 128-bit floating point type. See [llvm::Type::FP128Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val fp128_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** The PowerPC 128-bit floating point type. See [llvm::Type::PPC_FP128Ty]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val ppc_fp128_type : lltype
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on function types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [function_type ret_ty param_tys] returns the function type returning
|
|
|
|
[ret_ty] and taking [param_tys] as parameters.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::FunctionType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [va_arg_function_type ret_ty param_tys] is just like
|
|
|
|
[function_type ret_ty param_tys] except that it returns the function type
|
|
|
|
which also takes a variable number of arguments.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::FunctionType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external var_arg_function_type : lltype -> lltype array -> lltype
|
|
|
|
= "llvm_var_arg_function_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_var_arg fty] returns [true] if [fty] is a varargs function type, [false]
|
2008-03-09 07:17:38 +00:00
|
|
|
otherwise. See the method [llvm::FunctionType::isVarArg]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external is_var_arg : lltype -> bool = "llvm_is_var_arg"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [return_type fty] gets the return type of the function type [fty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::FunctionType::getReturnType]. *)
|
2007-10-06 17:10:44 +00:00
|
|
|
external return_type : lltype -> lltype = "LLVMGetReturnType"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [param_types fty] gets the parameter types of the function type [fty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::FunctionType::getParamType]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external param_types : lltype -> lltype array = "llvm_param_types"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on struct types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [struct_type tys] returns the structure type containing in the types in the
|
2008-03-09 07:17:38 +00:00
|
|
|
array [tys]. See the method [llvm::StructType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external struct_type : lltype array -> lltype = "llvm_struct_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [struct_type tys] returns the packed structure type containing in the types
|
2008-03-09 07:17:38 +00:00
|
|
|
in the array [tys]. See the method [llvm::StructType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [element_types sty] returns the constituent types of the struct type [sty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::StructType::getElementType]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external element_types : lltype -> lltype array = "llvm_element_types"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_packed sty] returns [true] if the structure type [sty] is packed,
|
2008-03-09 07:17:38 +00:00
|
|
|
[false] otherwise. See the method [llvm::StructType::isPacked]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external is_packed : lltype -> bool = "llvm_is_packed"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on pointer, vector, and array types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [array_type ty n] returns the array type containing [n] elements of type
|
2008-03-09 07:17:38 +00:00
|
|
|
[ty]. See the method [llvm::ArrayType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external array_type : lltype -> int -> lltype = "llvm_array_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [pointer_type ty] returns the pointer type referencing objects of type
|
2007-12-17 16:08:32 +00:00
|
|
|
[ty] in the default address space (0).
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::PointerType::getUnqual]. *)
|
2007-12-17 16:08:32 +00:00
|
|
|
external pointer_type : lltype -> lltype = "llvm_pointer_type"
|
|
|
|
|
|
|
|
(** [qualified_pointer_type ty as] returns the pointer type referencing objects
|
|
|
|
of type [ty] in address space [as].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::PointerType::get]. *)
|
2007-12-17 16:08:32 +00:00
|
|
|
external qualified_pointer_type : lltype -> int -> lltype
|
|
|
|
= "llvm_qualified_pointer_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [vector_type ty n] returns the array type containing [n] elements of the
|
2008-03-09 07:17:38 +00:00
|
|
|
primitive type [ty]. See the method [llvm::ArrayType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external vector_type : lltype -> int -> lltype = "llvm_vector_type"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [element_type ty] returns the element type of the pointer, vector, or array
|
2008-03-09 07:17:38 +00:00
|
|
|
type [ty]. See the method [llvm::SequentialType::get]. *)
|
2007-10-06 17:10:44 +00:00
|
|
|
external element_type : lltype -> lltype = "LLVMGetElementType"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [element_type aty] returns the element count of the array type [aty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ArrayType::getNumElements]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external array_length : lltype -> int = "llvm_array_length"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2007-12-17 16:08:32 +00:00
|
|
|
(** [address_space pty] returns the address space qualifier of the pointer type
|
2008-03-09 07:17:38 +00:00
|
|
|
[pty]. See the method [llvm::PointerType::getAddressSpace]. *)
|
2007-12-17 16:08:32 +00:00
|
|
|
external address_space : lltype -> int = "llvm_address_space"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [element_type ty] returns the element count of the vector type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::VectorType::getNumElements]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external vector_size : lltype -> int = "llvm_vector_size"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on other types} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [opaque_type ()] creates a new opaque type distinct from any other.
|
|
|
|
Opaque types are useful for building recursive types in combination with
|
2008-03-10 15:47:03 +00:00
|
|
|
{!refine_type}.
|
2008-03-09 07:17:38 +00:00
|
|
|
See [llvm::OpaqueType::get]. *)
|
2007-10-06 16:56:09 +00:00
|
|
|
external opaque_type : unit -> lltype = "llvm_opaque_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [void_type] is the type of a function which does not return any value.
|
2008-03-09 07:17:38 +00:00
|
|
|
See [llvm::Type::VoidTy]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val void_type : lltype
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [label_type] is the type of a basic block. See [llvm::Type::LabelTy]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
val label_type : lltype
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {7 Operations on type handles} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later
|
2008-03-09 07:17:38 +00:00
|
|
|
refined as a result of a call to {!refine_type}, the handle will be updated;
|
2007-12-01 21:01:15 +00:00
|
|
|
any bare [lltype] references will become invalid.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the class [llvm::PATypeHolder]. *)
|
2007-10-07 00:13:35 +00:00
|
|
|
external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [type_of_handle tyh] resolves the type handle [tyh].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::PATypeHolder::get()]. *)
|
2007-10-07 00:13:35 +00:00
|
|
|
external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the
|
2008-03-09 07:17:38 +00:00
|
|
|
concrete type [ty] in all users. Warning: This may invalidate {!lltype}
|
|
|
|
values! Use {!lltypehandle} to manipulate potentially abstract types. See
|
|
|
|
the method [llvm::Type::refineAbstractType]. *)
|
2007-10-07 00:13:35 +00:00
|
|
|
external refine_type : lltype -> lltype -> unit = "llvm_refine_type"
|
|
|
|
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(* {6 Values} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [type_of v] returns the type of the value [v].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Value::getType]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external type_of : llvalue -> lltype = "llvm_type_of"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [value_name v] returns the name of the value [v]. For global values, this is
|
|
|
|
the symbol name. For instructions and basic blocks, it is the SSA register
|
|
|
|
name. It is meaningless for constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Value::getName]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external value_name : llvalue -> string = "llvm_value_name"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [set_value_name n v] sets the name of the value [v] to [n]. See the method
|
|
|
|
[llvm::Value::setName]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external set_value_name : string -> llvalue -> unit = "llvm_set_value_name"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [dump_value v] prints the .ll representation of the value [v] to standard
|
2008-03-09 07:17:38 +00:00
|
|
|
error. See the method [llvm::Value::dump]. *)
|
2007-10-06 00:08:49 +00:00
|
|
|
external dump_value : llvalue -> unit = "llvm_dump_value"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on constants of (mostly) any type} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_constant v] returns [true] if the value [v] is a constant, [false]
|
2008-03-09 07:17:38 +00:00
|
|
|
otherwise. Similar to [llvm::isa<Constant>]. *)
|
2007-09-18 18:07:51 +00:00
|
|
|
external is_constant : llvalue -> bool = "llvm_is_constant"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_null ty] returns the constant null (zero) of the type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Constant::getNullValue]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_null : lltype -> llvalue = "LLVMConstNull"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_all_ones ty] returns the constant '-1' of the integer or vector type
|
2008-03-09 07:17:38 +00:00
|
|
|
[ty]. See the method [llvm::Constant::getAllOnesValue]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_all_ones : (*int|vec*)lltype -> llvalue = "LLVMConstAllOnes"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [undef ty] returns the undefined value of the type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::UndefValue::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external undef : lltype -> llvalue = "LLVMGetUndef"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_null v] returns [true] if the value [v] is the null (zero) value.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Constant::isNullValue]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external is_null : llvalue -> bool = "llvm_is_null"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_undef v] returns [true] if the value [v] is an undefined value, [false]
|
2008-03-09 07:17:38 +00:00
|
|
|
otherwise. Similar to [llvm::isa<UndefValue>]. *)
|
2007-09-18 18:07:51 +00:00
|
|
|
external is_undef : llvalue -> bool = "llvm_is_undef"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on scalar constants} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_int ty i] returns the integer constant of type [ty] and value [i].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantInt::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_int : lltype -> int -> llvalue = "llvm_const_int"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_of_int64 ty i] returns the integer constant of type [ty] and value
|
2008-03-09 07:17:38 +00:00
|
|
|
[i]. See the method [llvm::ConstantInt::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_of_int64 : lltype -> Int64.t -> bool -> llvalue
|
|
|
|
= "llvm_const_of_int64"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_float ty n] returns the floating point constant of type [ty] and
|
2008-03-09 07:17:38 +00:00
|
|
|
value [n]. See the method [llvm::ConstantInt::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_float : lltype -> float -> llvalue = "llvm_const_float"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on composite constants} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [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
|
2008-03-09 07:17:38 +00:00
|
|
|
{!const_stringz}). This value can in turn be used as the initializer for a
|
|
|
|
global variable. See the method [llvm::ConstantArray::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_string : string -> llvalue = "llvm_const_string"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [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.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantArray::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_stringz : string -> llvalue = "llvm_const_stringz"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_array ty elts] returns the constant array of type
|
|
|
|
[array_type ty (Array.length elts)] and containing the values [elts].
|
|
|
|
This value can in turn be used as the initializer for a global variable.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantArray::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [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.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantStruct::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_struct : llvalue array -> llvalue = "llvm_const_struct"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_packed_struct elts] returns the structured constant of type
|
2008-03-09 07:17:38 +00:00
|
|
|
{!packed_struct_type} [(Array.map type_of elts)] and containing the values
|
2007-12-01 21:01:15 +00:00
|
|
|
[elts]. This value can in turn be used as the initializer for a global
|
2008-03-09 07:17:38 +00:00
|
|
|
variable. See the method [llvm::ConstantStruct::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_packed_struct : llvalue array -> llvalue
|
|
|
|
= "llvm_const_packed_struct"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_vector elts] returns the vector constant of type
|
|
|
|
[vector_type (type_of elts.(0)) (Array.length elts)] and containing the
|
2008-03-09 07:17:38 +00:00
|
|
|
values [elts]. See the method [llvm::ConstantVector::get]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external const_vector : llvalue array -> llvalue = "llvm_const_vector"
|
2007-09-18 12:49:39 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Constant expressions} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [size_of ty] returns the sizeof constant for the type [ty]. This is
|
|
|
|
equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
|
|
|
|
(const_int i64_type 1)) i64_type], but considerably more readable.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getSizeOf]. *)
|
2007-10-06 15:11:06 +00:00
|
|
|
external size_of : lltype -> llvalue = "LLVMSizeOf"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_neg c] returns the arithmetic negation of the constant [c].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getNeg]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_neg : llvalue -> llvalue = "LLVMConstNeg"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_not c] returns the bitwise inverse of the constant [c].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getNot]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_not : llvalue -> llvalue = "LLVMConstNot"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_add c1 c2] returns the constant sum of two constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getAdd]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_add : llvalue -> llvalue -> llvalue = "LLVMConstAdd"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_sub c1 c2] returns the constant difference, [c1 - c2], of two
|
2008-03-09 07:17:38 +00:00
|
|
|
constants. See the method [llvm::ConstantExpr::getSub]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_sub : llvalue -> llvalue -> llvalue = "LLVMConstSub"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_mul c1 c2] returns the constant product of two constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getMul]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_mul : llvalue -> llvalue -> llvalue = "LLVMConstMul"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_udiv c1 c2] returns the constant quotient [c1 / c2] of two unsigned
|
|
|
|
integer constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getUDiv]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_udiv : llvalue -> llvalue -> llvalue = "LLVMConstUDiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_sdiv c1 c2] returns the constant quotient [c1 / c2] of two signed
|
|
|
|
integer constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_sdiv : llvalue -> llvalue -> llvalue = "LLVMConstSDiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fdiv c1 c2] returns the constant quotient [c1 / c2] of two floating
|
|
|
|
point constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFDiv]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_fdiv : llvalue -> llvalue -> llvalue = "LLVMConstFDiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_udiv c1 c2] returns the constant remainder [c1 MOD c2] of two
|
|
|
|
unsigned integer constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getURem]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_urem : llvalue -> llvalue -> llvalue = "LLVMConstURem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_sdiv c1 c2] returns the constant remainder [c1 MOD c2] of two
|
|
|
|
signed integer constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getSRem]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_srem : llvalue -> llvalue -> llvalue = "LLVMConstSRem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_frem c1 c2] returns the constant remainder [c1 MOD c2] of two
|
|
|
|
signed floating point constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFRem]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_frem : llvalue -> llvalue -> llvalue = "LLVMConstFRem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_and c1 c2] returns the constant bitwise [AND] of two integer
|
|
|
|
constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getAnd]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_and : llvalue -> llvalue -> llvalue = "LLVMConstAnd"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_or c1 c2] returns the constant bitwise [OR] of two integer
|
|
|
|
constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getOr]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_or : llvalue -> llvalue -> llvalue = "LLVMConstOr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_xor c1 c2] returns the constant bitwise [XOR] of two integer
|
|
|
|
constants.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getXor]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_xor : llvalue -> llvalue -> llvalue = "LLVMConstXor"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_icmp pred c1 c2] returns the constant comparison of two integer
|
|
|
|
constants, [c1 pred c2].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getICmp]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
|
2007-10-06 14:29:36 +00:00
|
|
|
= "llvm_const_icmp"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fcmp pred c1 c2] returns the constant comparison of two floating
|
|
|
|
point constants, [c1 pred c2].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFCmp]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
|
2007-10-06 14:29:36 +00:00
|
|
|
= "llvm_const_fcmp"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_shl c1 c2] returns the constant integer [c1] left-shifted by the
|
|
|
|
constant integer [c2].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getShl]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
|
|
|
|
constant integer [c2] with zero extension.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getLShr]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
|
|
|
|
constant integer [c2] with sign extension.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getAShr]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_gep pc indices] returns the constant [getElementPtr] of [p1] with the
|
|
|
|
constant integers indices from the array [indices].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_trunc c ty] returns the constant truncation of integer constant [c]
|
|
|
|
to the smaller integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getTrunc]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_sext c ty] returns the constant sign extension of integer constant
|
|
|
|
[c] to the larger integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getSExt]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_zext c ty] returns the constant zero extension of integer constant
|
|
|
|
[c] to the larger integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getZExt]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fptrunc c ty] returns the constant truncation of floating point
|
|
|
|
constant [c] to the smaller floating point type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFPTrunc]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_fptrunc : llvalue -> lltype -> llvalue = "LLVMConstFPTrunc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fpext c ty] returns the constant extension of floating point constant
|
|
|
|
[c] to the larger floating point type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFPExt]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_fpext : llvalue -> lltype -> llvalue = "LLVMConstFPExt"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_uitofp c ty] returns the constant floating point conversion of
|
|
|
|
unsigned integer constant [c] to the floating point type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getUIToFP]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_uitofp : llvalue -> lltype -> llvalue = "LLVMConstUIToFP"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_sitofp c ty] returns the constant floating point conversion of
|
|
|
|
signed integer constant [c] to the floating point type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getSIToFP]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_sitofp : llvalue -> lltype -> llvalue = "LLVMConstSIToFP"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fptoui c ty] returns the constant unsigned integer conversion of
|
|
|
|
floating point constant [c] to integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFPToUI]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_fptoui : llvalue -> lltype -> llvalue = "LLVMConstFPToUI"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_fptoui c ty] returns the constant unsigned integer conversion of
|
|
|
|
floating point constant [c] to integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getFPToSI]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_fptosi : llvalue -> lltype -> llvalue = "LLVMConstFPToSI"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_ptrtoint c ty] returns the constant integer conversion of
|
|
|
|
pointer constant [c] to integer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getPtrToInt]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_ptrtoint : llvalue -> lltype -> llvalue = "LLVMConstPtrToInt"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_inttoptr c ty] returns the constant pointer conversion of
|
|
|
|
integer constant [c] to pointer type [ty].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getIntToPtr]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_inttoptr : llvalue -> lltype -> llvalue = "LLVMConstIntToPtr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_bitcast c ty] returns the constant bitwise conversion of constant [c]
|
|
|
|
to type [ty] of equal size.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getBitCast]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_bitcast : llvalue -> lltype -> llvalue = "LLVMConstBitCast"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_select cond t f] returns the constant conditional which returns value
|
|
|
|
[t] if the boolean constant [cond] is true and the value [f] otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getSelect]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_select : llvalue -> llvalue -> llvalue -> llvalue
|
|
|
|
= "LLVMConstSelect"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_extractelement vec i] returns the constant [i]th element of
|
|
|
|
constant vector [vec]. [i] must be a constant [i32] value unsigned less than
|
|
|
|
the size of the vector.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getExtractElement]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_extractelement : llvalue -> llvalue -> llvalue
|
|
|
|
= "LLVMConstExtractElement"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_insertelement vec v i] returns the constant vector with the same
|
|
|
|
elements as constant vector [v] but the [i]th element replaced by the
|
|
|
|
constant [v]. [v] must be a constant value with the type of the vector
|
|
|
|
elements. [i] must be a constant [i32] value unsigned less than the size
|
|
|
|
of the vector.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getInsertElement]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_insertelement : llvalue -> llvalue -> llvalue -> llvalue
|
|
|
|
= "LLVMConstInsertElement"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [const_shufflevector a b mask] returns a constant [shufflevector].
|
|
|
|
See the LLVM Language Reference for details on the [sufflevector]
|
|
|
|
instruction.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::ConstantExpr::getShuffleVector]. *)
|
2007-10-06 14:29:36 +00:00
|
|
|
external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
|
|
|
|
= "LLVMConstShuffleVector"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on global variables, functions, and aliases (globals)} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** [global_parent g] is the enclosing module of the global value [g].
|
|
|
|
See the method [llvm::GlobalValue::getParent]. *)
|
|
|
|
external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [is_declaration g] returns [true] if the global value [g] is a declaration
|
|
|
|
only. Returns [false] otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::isDeclaration]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external is_declaration : llvalue -> bool = "llvm_is_declaration"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [linkage g] returns the linkage of the global value [g].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::getLinkage]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external linkage : llvalue -> Linkage.t = "llvm_linkage"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_linkage l g] sets the linkage of the global value [g] to [l].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::setLinkage]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [section g] returns the linker section of the global value [g].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::getSection]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external section : llvalue -> string = "llvm_section"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_section s g] sets the linker section of the global value [g] to [s].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::setSection]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external set_section : string -> llvalue -> unit = "llvm_set_section"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [visibility g] returns the linker visibility of the global value [g].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::getVisibility]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external visibility : llvalue -> Visibility.t = "llvm_visibility"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_visibility v g] sets the linker visibility of the global value [g] to
|
2008-03-09 07:17:38 +00:00
|
|
|
[v]. See the method [llvm::GlobalValue::setVisibility]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external set_visibility : Visibility.t -> llvalue -> unit
|
|
|
|
= "llvm_set_visibility"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [alignment g] returns the required alignment of the global value [g].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalValue::getAlignment]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external alignment : llvalue -> int = "llvm_alignment"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_alignment n g] sets the required alignment of the global value [g] to
|
2008-03-09 07:17:38 +00:00
|
|
|
[n] bytes. See the method [llvm::GlobalValue::setAlignment]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external set_alignment : int -> llvalue -> unit = "llvm_set_alignment"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on global variables} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [declare_global ty name m] returns a new global variable of type [ty] and
|
|
|
|
with name [name] in module [m]. If such a global variable already exists,
|
|
|
|
it is returned. If the type of the existing global differs, then a bitcast
|
2008-03-09 07:17:38 +00:00
|
|
|
to [ty] is returned. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external declare_global : lltype -> string -> llmodule -> llvalue
|
|
|
|
= "llvm_declare_global"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [define_global name init m] returns a new global with name [name] and
|
|
|
|
initializer [init] in module [m]. If the named global already exists, it is
|
|
|
|
renamed.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the constructor of [llvm::GlobalVariable]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external define_global : string -> llvalue -> llmodule -> llvalue
|
|
|
|
= "llvm_define_global"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [lookup_global name m] returns [Some g] if a global variable with name
|
|
|
|
[name] exists in module [m]. If no such global exists, returns [None].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the [llvm::GlobalVariable] constructor. *)
|
2007-10-08 03:45:09 +00:00
|
|
|
external lookup_global : string -> llmodule -> llvalue option
|
|
|
|
= "llvm_lookup_global"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [delete_global gv] destroys the global variable [gv].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::eraseFromParent]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external delete_global : llvalue -> unit = "llvm_delete_global"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-23 22:21:29 +00:00
|
|
|
(** [global_begin m] returns the first position in the global variable list of
|
|
|
|
the module [m]. [global_begin] and [global_succ] can be used to iterate
|
|
|
|
over the global list in order.
|
|
|
|
See the method [llvm::Module::global_begin]. *)
|
|
|
|
external global_begin : llmodule -> (llmodule, llvalue) llpos
|
|
|
|
= "llvm_global_begin"
|
|
|
|
|
|
|
|
(** [global_succ gv] returns the global variable list position succeeding
|
|
|
|
[Before gv].
|
|
|
|
See the method [llvm::Module::global_iterator::operator++]. *)
|
|
|
|
external global_succ : llvalue -> (llmodule, llvalue) llpos
|
|
|
|
= "llvm_global_succ"
|
|
|
|
|
|
|
|
(** [iter_globals f m] applies function [f] to each of the global variables of
|
|
|
|
module [m] in order. Tail recursive. *)
|
|
|
|
val iter_globals : (llvalue -> unit) -> llmodule -> unit
|
|
|
|
|
|
|
|
(** [fold_left_globals f init m] is [f (... (f init g1) ...) gN] where
|
|
|
|
[g1,...,gN] are the global variables of module [m]. Tail recursive. *)
|
|
|
|
val fold_left_globals : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
|
|
|
|
|
|
|
|
(** [global_end m] returns the last position in the global variable list of the
|
|
|
|
module [m]. [global_end] and [global_pred] can be used to iterate over the
|
|
|
|
global list in reverse.
|
|
|
|
See the method [llvm::Module::global_end]. *)
|
|
|
|
external global_end : llmodule -> (llmodule, llvalue) llrev_pos
|
|
|
|
= "llvm_global_end"
|
|
|
|
|
|
|
|
(** [global_pred gv] returns the global variable list position preceding
|
|
|
|
[After gv].
|
|
|
|
See the method [llvm::Module::global_iterator::operator--]. *)
|
|
|
|
external global_pred : llvalue -> (llmodule, llvalue) llrev_pos
|
|
|
|
= "llvm_global_pred"
|
|
|
|
|
|
|
|
(** [rev_iter_globals f m] applies function [f] to each of the global variables
|
|
|
|
of module [m] in reverse order. Tail recursive. *)
|
|
|
|
val rev_iter_globals : (llvalue -> unit) -> llmodule -> unit
|
|
|
|
|
|
|
|
(** [fold_right_globals f m init] is [f g1 (... (f gN init) ...)] where
|
|
|
|
[g1,...,gN] are the global variables of module [m]. Tail recursive. *)
|
|
|
|
val fold_right_globals : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [is_global_constant gv] returns [true] if the global variabile [gv] is a
|
|
|
|
constant. Returns [false] otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::isConstant]. *)
|
2007-12-01 21:01:15 +00:00
|
|
|
external is_global_constant : llvalue -> bool = "llvm_is_global_constant"
|
|
|
|
|
|
|
|
(** [set_global_constant c gv] sets the global variable [gv] to be a constant if
|
|
|
|
[c] is [true] and not if [c] is [false].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::setConstant]. *)
|
2007-12-01 21:01:15 +00:00
|
|
|
external set_global_constant : bool -> llvalue -> unit
|
|
|
|
= "llvm_set_global_constant"
|
|
|
|
|
|
|
|
(** [global_initializer gv] returns the initializer for the global variable
|
2008-03-09 07:17:38 +00:00
|
|
|
[gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_initializer c gv] sets the initializer for the global variable
|
|
|
|
[gv] to the constant [c].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::setInitializer]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [remove_initializer gv] unsets the initializer for the global variable
|
|
|
|
[gv].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::setInitializer]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [is_thread_local gv] returns [true] if the global variable [gv] is
|
|
|
|
thread-local and [false] otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::isThreadLocal]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external is_thread_local : llvalue -> bool = "llvm_is_thread_local"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_thread_local c gv] sets the global variable [gv] to be thread local if
|
|
|
|
[c] is [true] and not otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::GlobalVariable::setThreadLocal]. *)
|
2007-09-18 12:49:39 +00:00
|
|
|
external set_thread_local : bool -> llvalue -> unit = "llvm_set_thread_local"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on functions} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [declare_function name ty m] returns a new function of type [ty] and
|
|
|
|
with name [name] in module [m]. If such a function already exists,
|
|
|
|
it is returned. If the type of the existing function differs, then a bitcast
|
2008-03-09 07:17:38 +00:00
|
|
|
to [ty] is returned. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external declare_function : string -> lltype -> llmodule -> llvalue
|
|
|
|
= "llvm_declare_function"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [define_function name ty m] creates a new function with name [name] and
|
|
|
|
type [ty] in module [m]. If the named function already exists, it is
|
|
|
|
renamed. An entry basic block is created in the function.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the constructor of [llvm::GlobalVariable]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external define_function : string -> lltype -> llmodule -> llvalue
|
|
|
|
= "llvm_define_function"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [lookup_function name m] returns [Some f] if a function with name
|
|
|
|
[name] exists in module [m]. If no such function exists, returns [None].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Module] constructor. *)
|
2007-10-08 03:45:09 +00:00
|
|
|
external lookup_function : string -> llmodule -> llvalue option
|
|
|
|
= "llvm_lookup_function"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [delete_function f] destroys the function [f].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::eraseFromParent]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external delete_function : llvalue -> unit = "llvm_delete_function"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-23 22:21:29 +00:00
|
|
|
(** [function_begin m] returns the first position in the function list of the
|
|
|
|
module [m]. [function_begin] and [function_succ] can be used to iterate over
|
|
|
|
the function list in order.
|
|
|
|
See the method [llvm::Module::begin]. *)
|
|
|
|
external function_begin : llmodule -> (llmodule, llvalue) llpos
|
|
|
|
= "llvm_function_begin"
|
|
|
|
|
|
|
|
(** [function_succ gv] returns the function list position succeeding
|
|
|
|
[Before gv].
|
|
|
|
See the method [llvm::Module::iterator::operator++]. *)
|
|
|
|
external function_succ : llvalue -> (llmodule, llvalue) llpos
|
|
|
|
= "llvm_function_succ"
|
|
|
|
|
|
|
|
(** [iter_functions f m] applies function [f] to each of the functions of module
|
|
|
|
[m] in order. Tail recursive. *)
|
|
|
|
val iter_functions : (llvalue -> unit) -> llmodule -> unit
|
|
|
|
|
|
|
|
(** [fold_left_function f init m] is [f (... (f init f1) ...) fN] where
|
|
|
|
[f1,...,fN] are the functions of module [m]. Tail recursive. *)
|
|
|
|
val fold_left_functions : ('a -> llvalue -> 'a) -> 'a -> llmodule -> 'a
|
|
|
|
|
|
|
|
(** [function_end m] returns the last position in the function list of
|
|
|
|
the module [m]. [function_end] and [function_pred] can be used to iterate
|
|
|
|
over the function list in reverse.
|
|
|
|
See the method [llvm::Module::end]. *)
|
|
|
|
external function_end : llmodule -> (llmodule, llvalue) llrev_pos
|
|
|
|
= "llvm_function_end"
|
|
|
|
|
|
|
|
(** [function_pred gv] returns the function list position preceding [After gv].
|
|
|
|
See the method [llvm::Module::iterator::operator--]. *)
|
|
|
|
external function_pred : llvalue -> (llmodule, llvalue) llrev_pos
|
|
|
|
= "llvm_function_pred"
|
|
|
|
|
|
|
|
(** [rev_iter_functions f fn] applies function [f] to each of the functions of
|
|
|
|
module [m] in reverse order. Tail recursive. *)
|
|
|
|
val rev_iter_functions : (llvalue -> unit) -> llmodule -> unit
|
|
|
|
|
|
|
|
(** [fold_right_functions f m init] is [f (... (f init fN) ...) f1] where
|
|
|
|
[f1,...,fN] are the functions of module [m]. Tail recursive. *)
|
|
|
|
val fold_right_functions : (llvalue -> 'a -> 'a) -> llmodule -> 'a -> 'a
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [is_intrinsic f] returns true if the function [f] is an intrinsic.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::isIntrinsic]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [function_call_conv f] returns the calling convention of the function [f].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::getCallingConv]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external function_call_conv : llvalue -> int = "llvm_function_call_conv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [set_function_call_conv cc f] sets the calling convention of the function
|
|
|
|
[f] to the calling convention numbered [cc].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::setCallingConv]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external set_function_call_conv : int -> llvalue -> unit
|
|
|
|
= "llvm_set_function_call_conv"
|
|
|
|
|
2008-08-17 18:44:35 +00:00
|
|
|
(** [gc f] returns [Some name] if the function [f] has a garbage
|
2007-12-10 03:18:06 +00:00
|
|
|
collection algorithm specified and [None] otherwise.
|
2008-08-17 18:44:35 +00:00
|
|
|
See the method [llvm::Function::getGC]. *)
|
|
|
|
external gc : llvalue -> string option = "llvm_gc"
|
2007-12-10 03:18:06 +00:00
|
|
|
|
2008-08-17 18:44:35 +00:00
|
|
|
(** [set_gc gc f] sets the collection algorithm for the function [f] to
|
|
|
|
[gc]. See the method [llvm::Function::setGC]. *)
|
|
|
|
external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
|
2007-12-10 03:18:06 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** {7 Operations on params} *)
|
|
|
|
|
|
|
|
(** [params f] returns the parameters of function [f].
|
|
|
|
See the method [llvm::Function::getArgumentList]. *)
|
|
|
|
external params : llvalue -> llvalue array = "llvm_params"
|
|
|
|
|
|
|
|
(** [param f n] returns the [n]th parameter of function [f].
|
|
|
|
See the method [llvm::Function::getArgumentList]. *)
|
|
|
|
external param : llvalue -> int -> llvalue = "llvm_param"
|
|
|
|
|
|
|
|
(** [param_parent p] returns the parent function that owns the parameter.
|
|
|
|
See the method [llvm::Argument::getParent]. *)
|
|
|
|
external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
|
|
|
|
|
2008-03-23 22:21:29 +00:00
|
|
|
(** [param_begin f] returns the first position in the parameter list of the
|
|
|
|
function [f]. [param_begin] and [param_succ] can be used to iterate over
|
|
|
|
the parameter list in order.
|
|
|
|
See the method [llvm::Function::arg_begin]. *)
|
|
|
|
external param_begin : llvalue -> (llvalue, llvalue) llpos = "llvm_param_begin"
|
|
|
|
|
|
|
|
(** [param_succ bb] returns the parameter list position succeeding
|
|
|
|
[Before bb].
|
|
|
|
See the method [llvm::Function::arg_iterator::operator++]. *)
|
|
|
|
external param_succ : llvalue -> (llvalue, llvalue) llpos = "llvm_param_succ"
|
|
|
|
|
|
|
|
(** [iter_params f fn] applies function [f] to each of the parameters
|
|
|
|
of function [fn] in order. Tail recursive. *)
|
|
|
|
val iter_params : (llvalue -> unit) -> llvalue -> unit
|
|
|
|
|
|
|
|
(** [fold_left_params f init fn] is [f (... (f init b1) ...) bN] where
|
|
|
|
[b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
|
|
|
|
val fold_left_params : ('a -> llvalue -> 'a) -> 'a -> llvalue -> 'a
|
|
|
|
|
|
|
|
(** [param_end f] returns the last position in the parameter list of
|
|
|
|
the function [f]. [param_end] and [param_pred] can be used to iterate
|
|
|
|
over the parameter list in reverse.
|
|
|
|
See the method [llvm::Function::arg_end]. *)
|
|
|
|
external param_end : llvalue -> (llvalue, llvalue) llrev_pos = "llvm_param_end"
|
|
|
|
|
|
|
|
(** [param_pred gv] returns the function list position preceding [After gv].
|
|
|
|
See the method [llvm::Function::arg_iterator::operator--]. *)
|
|
|
|
external param_pred : llvalue -> (llvalue, llvalue) llrev_pos
|
|
|
|
= "llvm_param_pred"
|
|
|
|
|
|
|
|
(** [rev_iter_params f fn] applies function [f] to each of the parameters
|
|
|
|
of function [fn] in reverse order. Tail recursive. *)
|
|
|
|
val rev_iter_params : (llvalue -> unit) -> llvalue -> unit
|
|
|
|
|
|
|
|
(** [fold_right_params f fn init] is [f (... (f init bN) ...) b1] where
|
|
|
|
[b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
|
|
|
|
val fold_right_params : (llvalue -> 'a -> 'a) -> llvalue -> 'a -> 'a
|
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {7 Operations on basic blocks} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [basic_blocks fn] returns the basic blocks of the function [f].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::getBasicBlockList]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [entry_block fn] returns the entry basic block of the function [f].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::Function::getEntryBlock]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [delete_block bb] deletes the basic block [bb].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::BasicBlock::eraseFromParent]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external delete_block : llbasicblock -> unit = "llvm_delete_block"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [append_block name f] creates a new basic block named [name] at the end of
|
|
|
|
function [f].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the constructor of [llvm::BasicBlock]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [insert_block name bb] creates a new basic block named [name] before the
|
|
|
|
basic block [bb].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the constructor of [llvm::BasicBlock]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external insert_block : string -> llbasicblock -> llbasicblock
|
|
|
|
= "llvm_insert_block"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** [block_parent bb] returns the parent function that owns the basic block.
|
|
|
|
See the method [llvm::BasicBlock::getParent]. *)
|
|
|
|
external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
|
|
|
|
|
2008-03-23 22:21:29 +00:00
|
|
|
(** [block_begin f] returns the first position in the basic block list of the
|
|
|
|
function [f]. [block_begin] and [block_succ] can be used to iterate over
|
|
|
|
the basic block list in order.
|
|
|
|
See the method [llvm::Function::begin]. *)
|
|
|
|
external block_begin : llvalue -> (llvalue, llbasicblock) llpos
|
|
|
|
= "llvm_block_begin"
|
|
|
|
|
|
|
|
(** [block_succ bb] returns the basic block list position succeeding
|
|
|
|
[Before bb].
|
|
|
|
See the method [llvm::Function::iterator::operator++]. *)
|
|
|
|
external block_succ : llbasicblock -> (llvalue, llbasicblock) llpos
|
|
|
|
= "llvm_block_succ"
|
|
|
|
|
|
|
|
(** [iter_blocks f fn] applies function [f] to each of the basic blocks
|
|
|
|
of function [fn] in order. Tail recursive. *)
|
|
|
|
val iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
|
|
|
|
|
|
|
|
(** [fold_left_blocks f init fn] is [f (... (f init b1) ...) bN] where
|
|
|
|
[b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
|
|
|
|
val fold_left_blocks : ('a -> llbasicblock -> 'a) -> 'a -> llvalue -> 'a
|
|
|
|
|
|
|
|
(** [block_end f] returns the last position in the basic block list of
|
|
|
|
the function [f]. [block_end] and [block_pred] can be used to iterate
|
|
|
|
over the basic block list in reverse.
|
|
|
|
See the method [llvm::Function::end]. *)
|
|
|
|
external block_end : llvalue -> (llvalue, llbasicblock) llrev_pos
|
|
|
|
= "llvm_block_end"
|
|
|
|
|
|
|
|
(** [block_pred gv] returns the function list position preceding [After gv].
|
|
|
|
See the method [llvm::Function::iterator::operator--]. *)
|
|
|
|
external block_pred : llbasicblock -> (llvalue, llbasicblock) llrev_pos
|
|
|
|
= "llvm_block_pred"
|
|
|
|
|
|
|
|
(** [rev_iter_blocks f fn] applies function [f] to each of the basic blocks
|
|
|
|
of function [fn] in reverse order. Tail recursive. *)
|
|
|
|
val rev_iter_blocks : (llbasicblock -> unit) -> llvalue -> unit
|
|
|
|
|
|
|
|
(** [fold_right_blocks f fn init] is [f (... (f init bN) ...) b1] where
|
|
|
|
[b1,...,bN] are the basic blocks of function [fn]. Tail recursive. *)
|
|
|
|
val fold_right_blocks : (llbasicblock -> 'a -> 'a) -> llvalue -> 'a -> 'a
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [value_is_block v] returns [true] if the value [v] is a basic block and
|
|
|
|
[false] otherwise.
|
2008-03-09 07:17:38 +00:00
|
|
|
Similar to [llvm::isa<BasicBlock>]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external value_is_block : llvalue -> bool = "llvm_value_is_block"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [block_of_value v] losslessly casts [v] to an [llbasicblock]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
|
|
|
|
|
2007-12-29 20:45:00 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** {7 Operations on instructions} *)
|
|
|
|
|
|
|
|
(** [instr_parent i] is the enclosing basic block of the instruction [i].
|
|
|
|
See the method [llvm::Instruction::getParent]. *)
|
|
|
|
external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
|
|
|
|
|
2008-03-25 16:26:51 +00:00
|
|
|
(** [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.
|
|
|
|
See the method [llvm::BasicBlock::begin]. *)
|
|
|
|
external instr_begin : llbasicblock -> (llbasicblock, llvalue) llpos
|
|
|
|
= "llvm_instr_begin"
|
|
|
|
|
|
|
|
(** [instr_succ i] returns the instruction list position succeeding [Before i].
|
|
|
|
See the method [llvm::BasicBlock::iterator::operator++]. *)
|
|
|
|
external instr_succ : llvalue -> (llbasicblock, llvalue) llpos
|
|
|
|
= "llvm_instr_succ"
|
|
|
|
|
|
|
|
(** [iter_instrs f bb] applies function [f] to each of the instructions of basic
|
|
|
|
block [bb] in order. Tail recursive. *)
|
|
|
|
val iter_instrs: (llvalue -> unit) -> llbasicblock -> unit
|
|
|
|
|
|
|
|
(** [fold_left_instrs f init bb] is [f (... (f init g1) ...) gN] where
|
|
|
|
[g1,...,gN] are the instructions of basic block [bb]. Tail recursive. *)
|
|
|
|
val fold_left_instrs: ('a -> llvalue -> 'a) -> 'a -> llbasicblock -> 'a
|
|
|
|
|
|
|
|
(** [instr_end bb] returns the last position in the instruction list of the
|
|
|
|
basic block [bb]. [instr_end] and [instr_pred] can be used to iterate over
|
|
|
|
the instruction list in reverse.
|
|
|
|
See the method [llvm::BasicBlock::end]. *)
|
|
|
|
external instr_end : llbasicblock -> (llbasicblock, llvalue) llrev_pos
|
|
|
|
= "llvm_instr_end"
|
|
|
|
|
|
|
|
(** [instr_pred i] returns the instruction list position preceding [After i].
|
|
|
|
See the method [llvm::BasicBlock::iterator::operator--]. *)
|
|
|
|
external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos
|
|
|
|
= "llvm_instr_pred"
|
|
|
|
|
|
|
|
(** [fold_right_instrs f bb init] is [f (... (f init fN) ...) f1] where
|
|
|
|
[f1,...,fN] are the instructions of basic block [bb]. Tail recursive. *)
|
|
|
|
val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a
|
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {7 Operations on call sites} *)
|
|
|
|
|
|
|
|
(** [instruction_call_conv ci] is the calling convention for the call or invoke
|
|
|
|
instruction [ci], which may be one of the values from the module
|
|
|
|
{!CallConv}. See the method [llvm::CallInst::getCallingConv] and
|
|
|
|
[llvm::InvokeInst::getCallingConv]. *)
|
2007-12-29 20:45:00 +00:00
|
|
|
external instruction_call_conv: llvalue -> int
|
|
|
|
= "llvm_instruction_call_conv"
|
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** [set_instruction_call_conv cc ci] sets the calling convention for the call
|
|
|
|
or invoke instruction [ci] to the integer [cc], which can be one of the
|
|
|
|
values from the module {!CallConv}.
|
|
|
|
See the method [llvm::CallInst::setCallingConv]
|
2008-03-09 07:17:38 +00:00
|
|
|
and [llvm::InvokeInst::setCallingConv]. *)
|
2007-12-29 20:45:00 +00:00
|
|
|
external set_instruction_call_conv: int -> llvalue -> unit
|
|
|
|
= "llvm_set_instruction_call_conv"
|
|
|
|
|
2008-08-30 16:34:54 +00:00
|
|
|
(** {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.
|
|
|
|
See the method [llvm::CallInst::isTailCall]. *)
|
|
|
|
external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
|
|
|
|
|
|
|
|
(** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
|
|
|
|
call optimization if [tc] is [true], clears otherwise.
|
|
|
|
See the method [llvm::CallInst::setTailCall]. *)
|
|
|
|
external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Operations on phi nodes} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
|
2008-03-09 07:17:38 +00:00
|
|
|
with branches from [bb]. See the method [llvm::PHINode::addIncoming]. *)
|
2007-10-08 18:14:39 +00:00
|
|
|
external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
|
|
|
|
= "llvm_add_incoming"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [incoming pn] returns the list of value-block pairs for phi node [pn].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::PHINode::getIncomingValue]. *)
|
2007-10-08 18:14:39 +00:00
|
|
|
external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
|
|
|
|
|
2007-09-26 20:56:12 +00:00
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {6 Instruction builders} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** [builder ()] creates an instruction builder with no position. It is invalid
|
|
|
|
to use this builder until its position is set with {!position_before} or
|
2008-03-09 07:17:38 +00:00
|
|
|
{!position_at_end}. See the constructor for [llvm::LLVMBuilder]. *)
|
2008-03-25 16:26:51 +00:00
|
|
|
external builder : unit -> 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
|
2007-12-26 21:21:51 +00:00
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [builder_before ins] creates an instruction builder positioned before the
|
2008-03-09 07:17:38 +00:00
|
|
|
instruction [isn]. See the constructor for [llvm::LLVMBuilder]. *)
|
2008-03-25 16:26:51 +00:00
|
|
|
val builder_before : llvalue -> llbuilder
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [builder_at_end bb] creates an instruction builder positioned at the end of
|
2008-03-09 07:17:38 +00:00
|
|
|
the basic block [bb]. See the constructor for [llvm::LLVMBuilder]. *)
|
2008-03-25 16:26:51 +00:00
|
|
|
val builder_at_end : llbasicblock -> llbuilder
|
|
|
|
|
|
|
|
(** [position_builder ip bb] moves the instruction builder [bb] to the position
|
|
|
|
[ip].
|
|
|
|
See the constructor for [llvm::LLVMBuilder]. *)
|
|
|
|
external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit
|
|
|
|
= "llvm_position_builder"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [position_before ins b] moves the instruction builder [b] to before the
|
2008-03-09 07:17:38 +00:00
|
|
|
instruction [isn]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
|
2008-03-25 16:26:51 +00:00
|
|
|
val position_before : llvalue -> llbuilder -> unit
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [position_at_end bb b] moves the instruction builder [b] to the end of the
|
2008-03-09 07:17:38 +00:00
|
|
|
basic block [bb]. See the method [llvm::LLVMBuilder::SetInsertPoint]. *)
|
2008-03-25 16:26:51 +00:00
|
|
|
val position_at_end : llbasicblock -> llbuilder -> unit
|
2007-09-26 20:56:12 +00:00
|
|
|
|
2008-03-19 01:11:35 +00:00
|
|
|
(** [insertion_block b] returns the basic block that the builder [b] is
|
|
|
|
positioned to insert into. Raises [Not_Found] if the instruction builder is
|
|
|
|
uninitialized.
|
|
|
|
See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
|
|
|
|
external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Terminators} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_ret_void b] creates a
|
|
|
|
[ret void]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateRetVoid]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_ret v b] creates a
|
|
|
|
[ret %v]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateRet]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_ret : llvalue -> llbuilder -> llvalue = "llvm_build_ret"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_br bb b] creates a
|
|
|
|
[b %bb]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateBr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_cond_br cond tbb fbb b] creates a
|
|
|
|
[b %cond, %tbb, %fbb]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateCondBr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_cond_br"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-08-09 01:55:52 +00:00
|
|
|
(** [build_switch case elsebb count b] creates an empty
|
2007-12-01 21:01:15 +00:00
|
|
|
[switch %case, %elsebb]
|
2008-08-09 01:55:52 +00:00
|
|
|
instruction at the position specified by the instruction builder [b] with
|
|
|
|
space reserved for [count] cases.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSwitch]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_switch"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-08-09 01:55:52 +00:00
|
|
|
(** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
|
|
|
|
when its input matches the constant [onval].
|
|
|
|
See the method [llvm::SwitchInst::addCase]. **)
|
|
|
|
external add_case : llvalue -> llvalue -> llbasicblock -> unit
|
|
|
|
= "llvm_add_case"
|
|
|
|
|
2007-12-01 21:01:15 +00:00
|
|
|
(** [build_invoke fn args tobb unwindbb name b] creates an
|
|
|
|
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateInvoke]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_invoke : llvalue -> llvalue array -> llbasicblock ->
|
|
|
|
llbasicblock -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_invoke_bc" "llvm_build_invoke_nat"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_unwind b] creates an
|
|
|
|
[unwind]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateUnwind]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_unwind : llbuilder -> llvalue = "llvm_build_unwind"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_unreachable b] creates an
|
|
|
|
[unreachable]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateUnwind]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Arithmetic} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_add x y name b] creates a
|
|
|
|
[%name = add %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAdd]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_add : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_add"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_sub x y name b] creates a
|
|
|
|
[%name = sub %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSub]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_sub : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_sub"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_mul x y name b] creates a
|
|
|
|
[%name = mul %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateMul]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_mul : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_mul"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_udiv x y name b] creates a
|
|
|
|
[%name = udiv %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateUDiv]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_udiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_udiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_sdiv x y name b] creates a
|
|
|
|
[%name = sdiv %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSDiv]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_sdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_sdiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fdiv x y name b] creates a
|
|
|
|
[%name = fdiv %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFDiv]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_fdiv : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_fdiv"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_urem x y name b] creates a
|
|
|
|
[%name = urem %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateURem]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_urem : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_urem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_SRem x y name b] creates a
|
|
|
|
[%name = srem %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSRem]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_srem : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_srem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_frem x y name b] creates a
|
|
|
|
[%name = frem %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFRem]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_frem : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_frem"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_shl x y name b] creates a
|
|
|
|
[%name = shl %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateShl]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_shl : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_shl"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_lshr x y name b] creates a
|
|
|
|
[%name = lshr %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateLShr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_lshr : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_lshr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_ashr x y name b] creates a
|
|
|
|
[%name = ashr %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAShr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_ashr : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_ashr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_and x y name b] creates a
|
|
|
|
[%name = and %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAnd]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_and : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_and"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_or x y name b] creates a
|
|
|
|
[%name = or %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateOr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_or : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_or"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_xor x y name b] creates a
|
|
|
|
[%name = xor %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateXor]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_xor : llvalue -> llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_xor"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_neg x name b] creates a
|
|
|
|
[%name = sub 0, %x]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
|
|
|
[-0.0] is used for floating point types to compute the correct sign.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateNeg]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_neg : llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_neg"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_xor x name b] creates a
|
|
|
|
[%name = xor %x, -1]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
|
|
|
[-1] is the correct "all ones" value for the type of [x].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateXor]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_not : llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_not"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Memory} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_malloc ty name b] creates a
|
|
|
|
[%name = malloc %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAlloca]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_malloc : lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_malloc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_array_malloc ty n name b] creates a
|
|
|
|
[%name = malloc %ty, %n]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateMalloc]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_array_malloc : lltype -> llvalue -> string -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_array_malloc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_alloca ty name b] creates a
|
|
|
|
[%name = alloca %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAlloca]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_alloca : lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_alloca"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_array_alloca ty n name b] creates a
|
|
|
|
[%name = alloca %ty, %n]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateAlloca]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_array_alloca"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_free v b] creates a
|
|
|
|
[free %v]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFree]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_free : llvalue -> llbuilder -> llvalue = "llvm_build_free"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_load v name b] creates a
|
|
|
|
[%name = load %v]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateLoad]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_load : llvalue -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_load"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_store v p b] creates a
|
|
|
|
[store %v, %p]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateStore]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_store : llvalue -> llvalue -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_store"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
2008-01-04 13:21:02 +00:00
|
|
|
(** [build_gep p indices name b] creates a
|
2007-12-01 21:01:15 +00:00
|
|
|
[%name = gep %p, indices...]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_gep"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Casts} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_trunc v ty name b] creates a
|
|
|
|
[%name = trunc %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateTrunc]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_trunc : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_trunc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_zext v ty name b] creates a
|
|
|
|
[%name = zext %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateZExt]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_zext : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_zext"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_sext v ty name b] creates a
|
|
|
|
[%name = sext %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSExt]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_sext : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_sext"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fptoui v ty name b] creates a
|
|
|
|
[%name = fptoui %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFPToUI]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_fptoui : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_fptoui"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fptosi v ty name b] creates a
|
|
|
|
[%name = fptosi %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFPToSI]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_fptosi : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_fptosi"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_uitofp v ty name b] creates a
|
|
|
|
[%name = uitofp %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateUIToFP]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_uitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_uitofp"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_sitofp v ty name b] creates a
|
|
|
|
[%name = sitofp %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSIToFP]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_sitofp : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_sitofp"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fptrunc v ty name b] creates a
|
|
|
|
[%name = fptrunc %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFPTrunc]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_fptrunc : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_fptrunc"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fpext v ty name b] creates a
|
|
|
|
[%name = fpext %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFPExt]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_fpext : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_fpext"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_ptrtoint v ty name b] creates a
|
|
|
|
[%name = prtotint %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreatePtrToInt]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_ptrtoint : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_prttoint"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_inttoptr v ty name b] creates a
|
|
|
|
[%name = inttoptr %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateIntToPtr]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_inttoptr : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_inttoptr"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_bitcast v ty name b] creates a
|
|
|
|
[%name = bitcast %p to %ty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateBitcast]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_bitcast : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_bitcast"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Comparisons} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_icmp pred x y name b] creates a
|
|
|
|
[%name = icmp %pred %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateICmp]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external build_icmp : Icmp.t -> llvalue -> llvalue -> string ->
|
2007-09-26 20:56:12 +00:00
|
|
|
llbuilder -> llvalue = "llvm_build_icmp"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_fcmp pred x y name b] creates a
|
|
|
|
[%name = fcmp %pred %x, %y]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateFCmp]. *)
|
2007-12-19 22:54:12 +00:00
|
|
|
external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
|
2007-09-26 20:56:12 +00:00
|
|
|
llbuilder -> llvalue = "llvm_build_fcmp"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {7 Miscellaneous instructions} *)
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_phi incoming name b] creates a
|
|
|
|
[%name = phi %incoming]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-10 15:47:03 +00:00
|
|
|
[incoming] is a list of [(llvalue, llbasicblock)] tuples.
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreatePHI]. *)
|
2007-10-08 18:14:39 +00:00
|
|
|
external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_phi"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_call fn args name b] creates a
|
|
|
|
[%name = call %fn(args...)]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateCall]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_call"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_select cond thenv elsev name b] creates a
|
|
|
|
[%name = select %cond, %thenv, %elsev]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateSelect]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_select"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_va_arg valist argty name b] creates a
|
|
|
|
[%name = va_arg %valist, %argty]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateVAArg]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
|
|
|
|
= "llvm_build_va_arg"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_extractelement vec i name b] creates a
|
|
|
|
[%name = extractelement %vec, %i]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateExtractElement]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_extractelement : llvalue -> llvalue -> string -> llbuilder ->
|
|
|
|
llvalue = "llvm_build_extractelement"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_insertelement vec elt i name b] creates a
|
|
|
|
[%name = insertelement %vec, %elt, %i]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateInsertElement]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_insertelement : llvalue -> llvalue -> llvalue -> string ->
|
|
|
|
llbuilder -> llvalue = "llvm_build_insertelement"
|
2007-12-01 21:01:15 +00:00
|
|
|
|
|
|
|
(** [build_shufflevector veca vecb mask name b] creates a
|
|
|
|
[%name = shufflevector %veca, %vecb, %mask]
|
|
|
|
instruction at the position specified by the instruction builder [b].
|
2008-03-09 07:17:38 +00:00
|
|
|
See the method [llvm::LLVMBuilder::CreateShuffleVector]. *)
|
2007-09-26 20:56:12 +00:00
|
|
|
external build_shufflevector : llvalue -> llvalue -> llvalue -> string ->
|
|
|
|
llbuilder -> llvalue = "llvm_build_shufflevector"
|
2007-12-12 01:04:30 +00:00
|
|
|
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** {6 Module providers} *)
|
2007-12-12 01:04:30 +00:00
|
|
|
|
2007-12-19 22:30:40 +00:00
|
|
|
module ModuleProvider : sig
|
|
|
|
(** [create_module_provider m] encapsulates [m] in a module provider and takes
|
2008-03-09 07:17:38 +00:00
|
|
|
ownership of the module. See the constructor
|
|
|
|
[llvm::ExistingModuleProvider::ExistingModuleProvider]. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
external create : llmodule -> llmoduleprovider
|
|
|
|
= "LLVMCreateModuleProviderForExistingModule"
|
2008-03-09 07:17:38 +00:00
|
|
|
|
2007-12-19 22:30:40 +00:00
|
|
|
(** [dispose_module_provider mp] destroys the module provider [mp] as well as
|
2008-03-09 07:17:38 +00:00
|
|
|
the contained module. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
external dispose : llmoduleprovider -> unit = "llvm_dispose_module_provider"
|
|
|
|
end
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
|
|
|
|
(** {6 Memory buffers} *)
|
2007-12-19 22:30:40 +00:00
|
|
|
|
|
|
|
module MemoryBuffer : sig
|
2008-03-09 07:17:38 +00:00
|
|
|
(** [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. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
external of_file : string -> llmemorybuffer = "llvm_memorybuffer_of_file"
|
|
|
|
|
|
|
|
(** [stdin ()] is the memory buffer containing the contents of standard input.
|
2008-03-09 07:17:38 +00:00
|
|
|
If standard input is empty, then [IoError msg] is raised. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
external of_stdin : unit -> llmemorybuffer = "llvm_memorybuffer_of_stdin"
|
|
|
|
|
2008-03-09 07:17:38 +00:00
|
|
|
(** Disposes of a memory buffer. *)
|
2007-12-19 22:30:40 +00:00
|
|
|
external dispose : llmemorybuffer -> unit = "llvm_memorybuffer_dispose"
|
|
|
|
end
|
2008-03-16 04:20:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
(** {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]. *)
|
|
|
|
external create : unit -> [ `Module ] t = "llvm_passmanager_create"
|
|
|
|
|
|
|
|
(** [PassManager.create_function mp] constructs a new function-by-function
|
|
|
|
pass pipeline over the module provider [mp]. It does not take ownership of
|
|
|
|
[mp]. This type of pipeline is suitable for code generation and JIT
|
|
|
|
compilation tasks.
|
|
|
|
See the constructor of [llvm::FunctionPassManager]. *)
|
|
|
|
external create_function : llmoduleprovider -> [ `Function ] t
|
|
|
|
= "LLVMCreateFunctionPassManager"
|
|
|
|
|
|
|
|
(** [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. *)
|
|
|
|
external run_module : llmodule -> [ `Module ] t -> bool
|
|
|
|
= "llvm_passmanager_run_module"
|
|
|
|
|
|
|
|
(** [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. *)
|
|
|
|
external initialize : [ `Function ] t -> bool = "llvm_passmanager_initialize"
|
|
|
|
|
|
|
|
(** [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. *)
|
|
|
|
external run_function : llvalue -> [ `Function ] t -> bool
|
|
|
|
= "llvm_passmanager_run_function"
|
|
|
|
|
|
|
|
(** [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. *)
|
|
|
|
external finalize : [ `Function ] t -> bool = "llvm_passmanager_finalize"
|
|
|
|
|
|
|
|
(** Frees the memory of a pass pipeline. For function pipelines, does not free
|
|
|
|
the module provider.
|
|
|
|
See the destructor of [llvm::BasePassManager]. *)
|
|
|
|
external dispose : [< any ] t -> unit = "llvm_passmanager_dispose"
|
|
|
|
end
|