This patch cleans up the OCaml bindings so that they format nicely with

ocamldoc. It does not yet hook into the build system, though.

Patch by Erick Tryzelaar!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48095 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gordon Henriksen 2008-03-09 07:17:38 +00:00
parent afb23f48a4
commit 3b646de036
6 changed files with 373 additions and 349 deletions

View File

@ -5,32 +5,31 @@
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===
*
* This interface provides an ocaml API for LLVM IR analyses, the classes in
* the Analysis library.
*
*===----------------------------------------------------------------------===*)
(** Intermediate representation analysis.
This interface provides an ocaml API for LLVM IR analyses, the classes in
the Analysis library. *)
(** [verify_module m] returns [None] if the module [m] is valid, and
[Some reason] if it is invalid. [reason] is a string containing a
human-readable validation report. See [llvm::verifyModule]. **)
human-readable validation report. See [llvm::verifyModule]. *)
external verify_module : Llvm.llmodule -> string option = "llvm_verify_module"
(** [verify_function f] returns [None] if the function [f] is valid, and
[Some reason] if it is invalid. [reason] is a string containing a
human-readable validation report. See [llvm::verifyFunction]. **)
human-readable validation report. See [llvm::verifyFunction]. *)
external verify_function : Llvm.llvalue -> bool = "llvm_verify_function"
(** [verify_module m] returns if the module [m] is valid, but prints a
validation report to [stderr] and aborts the program if it is invalid. See
[llvm::verifyModule]. **)
validation report to [stderr] and aborts the program if it is invalid. See
[llvm::verifyModule]. *)
external assert_valid_module : Llvm.llmodule -> unit
= "llvm_assert_valid_module"
(** [verify_function f] returns if the function [f] is valid, but prints a
validation report to [stderr] and aborts the program if it is invalid. See
[llvm::verifyFunction]. **)
validation report to [stderr] and aborts the program if it is invalid. See
[llvm::verifyFunction]. *)
external assert_valid_function : Llvm.llvalue -> unit
= "llvm_assert_valid_function"

View File

@ -5,26 +5,25 @@
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===
*
* This interface provides an ocaml API for the LLVM bitcode reader, the
* classes in the Bitreader library.
*
*===----------------------------------------------------------------------===*)
(** Bitcode reader.
This interface provides an ocaml API for the LLVM bitcode reader, the
classes in the Bitreader library. *)
exception Error of string
(** [read_bitcode_file path] reads the bitcode for a new module [m] from the
file at [path]. Returns [Success m] if successful, and [Failure msg]
otherwise, where [msg] is a description of the error encountered.
See the function [llvm::getBitcodeModuleProvider]. **)
See the function [llvm::getBitcodeModuleProvider]. *)
external get_module_provider : Llvm.llmemorybuffer -> Llvm.llmoduleprovider
= "llvm_get_module_provider"
(** [parse_bitcode mb] parses the bitcode for a new module [m] from the memory
buffer [mb]. Returns [Success m] if successful, and [Failure msg] otherwise,
where [msg] is a description of the error encountered.
See the function [llvm::ParseBitcodeFile]. **)
See the function [llvm::ParseBitcodeFile]. *)
external parse_bitcode : Llvm.llmemorybuffer -> Llvm.llmodule
= "llvm_parse_bitcode"

View File

@ -5,15 +5,14 @@
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===
*
* This interface provides an ocaml API for the LLVM bitcode writer, the
* classes in the Bitwriter library.
*
*===----------------------------------------------------------------------===*)
(** Bitcode writer.
This interface provides an ocaml API for the LLVM bitcode writer, the
classes in the Bitwriter library. *)
(** [write_bitcode_file m path] writes the bitcode for module [m] to the file at
[path]. Returns [true] if successful, [false] otherwise. **)
[path]. Returns [true] if successful, [false] otherwise. *)
external write_bitcode_file : Llvm.llmodule -> string -> bool
= "llvm_write_bitcode_file"

View File

@ -5,78 +5,76 @@
* This file is distributed under the University of Illinois Open Source
* License. See LICENSE.TXT for details.
*
*===----------------------------------------------------------------------===
*
* This interface provides an ocaml API for LLVM execution engine (JIT/
* interpreter), the classes in the ExecutionEngine library.
*
*===----------------------------------------------------------------------===*)
(** JIT Interpreter.
This interface provides an ocaml API for LLVM execution engine (JIT/
interpreter), the classes in the ExecutionEngine library. *)
exception Error of string
module GenericValue: sig
(** [GenericValue.t] is a boxed union type used to portably pass arguments to
and receive values from the execution engine. It supports only a limited
selection of types; for more complex argument types, it is necessary to
generate a stub function by hand or to pass parameters by reference.
See the struct [llvm::GenericValue]. **)
See the struct [llvm::GenericValue]. *)
type t
(** [of_float fpty n] boxes the float [n] in a float-valued generic value
according to the floating point type [fpty]. See the fields
[llvm::GenericValue::DoubleVal] and [llvm::GenericValue::FloatVal]. **)
according to the floating point type [fpty]. See the fields
[llvm::GenericValue::DoubleVal] and [llvm::GenericValue::FloatVal]. *)
val of_float: Llvm.lltype -> float -> t
(** [of_pointer v] boxes the pointer value [v] in a generic value. See the
field [llvm::GenericValue::PointerVal]. **)
field [llvm::GenericValue::PointerVal]. *)
val of_pointer: 'a -> t
(** [of_int32 n w] boxes the int32 [i] in a generic value with the bitwidth
[w]. See the field [llvm::GenericValue::IntVal]. **)
[w]. See the field [llvm::GenericValue::IntVal]. *)
val of_int32: Llvm.lltype -> int32 -> t
(** [of_int n w] boxes the int [i] in a generic value with the bitwidth
[w]. See the field [llvm::GenericValue::IntVal]. **)
[w]. See the field [llvm::GenericValue::IntVal]. *)
val of_int: Llvm.lltype -> int -> t
(** [of_natint n w] boxes the native int [i] in a generic value with the
bitwidth [w]. See the field [llvm::GenericValue::IntVal]. **)
bitwidth [w]. See the field [llvm::GenericValue::IntVal]. *)
val of_nativeint: Llvm.lltype -> nativeint -> t
(** [of_int64 n w] boxes the int64 [i] in a generic value with the bitwidth
[w]. See the field [llvm::GenericValue::IntVal]. **)
[w]. See the field [llvm::GenericValue::IntVal]. *)
val of_int64: Llvm.lltype -> int64 -> t
(** [as_float fpty gv] unboxes the floating point-valued generic value [gv] of
floating point type [fpty]. See the fields [llvm::GenericValue::DoubleVal]
and [llvm::GenericValue::FloatVal]. **)
and [llvm::GenericValue::FloatVal]. *)
val as_float: Llvm.lltype -> t -> float
(** [as_pointer gv] unboxes the pointer-valued generic value [gv]. See the
field [llvm::GenericValue::PointerVal]. **)
field [llvm::GenericValue::PointerVal]. *)
val as_pointer: t -> 'a
(** [as_int32 gv] unboxes the integer-valued generic value [gv] as an [int32].
Is invalid if [gv] has a bitwidth greater than 32 bits. See the field
[llvm::GenericValue::IntVal]. **)
[llvm::GenericValue::IntVal]. *)
val as_int32: t -> int32
(** [as_int gv] unboxes the integer-valued generic value [gv] as an [int].
Is invalid if [gv] has a bitwidth greater than the host bit width (but the
most significant bit may be lost). See the field
[llvm::GenericValue::IntVal]. **)
[llvm::GenericValue::IntVal]. *)
val as_int: t -> int
(** [as_natint gv] unboxes the integer-valued generic value [gv] as a
[nativeint]. Is invalid if [gv] has a bitwidth greater than
[nativeint]. See the field [llvm::GenericValue::IntVal]. **)
[nativeint]. See the field [llvm::GenericValue::IntVal]. *)
val as_nativeint: t -> nativeint
(** [as_int64 gv] returns the integer-valued generic value [gv] as an [int64].
Is invalid if [gv] has a bitwidth greater than [int64]. See the field
[llvm::GenericValue::IntVal]. **)
[llvm::GenericValue::IntVal]. *)
val as_int64: t -> int64
end
@ -84,69 +82,69 @@ end
module ExecutionEngine: sig
(** An execution engine is either a JIT compiler or an interpreter, capable of
directly loading an LLVM module and executing its functions without first
invoking a static compiler and generating a native executable. **)
invoking a static compiler and generating a native executable. *)
type t
(** [create mp] creates a new execution engine, taking ownership of the
module provider [mp] if successful. Creates a JIT if possible, else falls
back to an interpreter. Raises [Error msg] if an error occurrs. The
execution engine is not garbage collected and must be destroyed with
[dispose ee]. See the function [llvm::ExecutionEngine::create]. **)
[dispose ee]. See the function [llvm::ExecutionEngine::create]. *)
val create: Llvm.llmoduleprovider -> t
(** [create_interpreter mp] creates a new interpreter, taking ownership of the
module provider [mp] if successful. Raises [Error msg] if an error
occurrs. The execution engine is not garbage collected and must be
destroyed with [dispose ee].
See the function [llvm::ExecutionEngine::create]. **)
See the function [llvm::ExecutionEngine::create]. *)
val create_interpreter: Llvm.llmoduleprovider -> t
(** [create_jit mp] creates a new JIT (just-in-time compiler), taking
ownership of the module provider [mp] if successful. Raises [Error msg] if
an error occurrs. The execution engine is not garbage collected and must
be destroyed with [dispose ee].
See the function [llvm::ExecutionEngine::create]. **)
See the function [llvm::ExecutionEngine::create]. *)
val create_jit: Llvm.llmoduleprovider -> t
(** [dispose ee] releases the memory used by the execution engine and must be
invoked to avoid memory leaks. **)
invoked to avoid memory leaks. *)
val dispose: t -> unit
(** [add_module_provider mp ee] adds the module provider [mp] to the execution
engine [ee]. **)
engine [ee]. *)
val add_module_provider: Llvm.llmoduleprovider -> t -> unit
(** [remove_module_provider mp ee] removes the module provider [mp] from the
execution engine [ee], disposing of [mp] and the module referenced by
[mp]. Raises [Error msg] if an error occurs. **)
[mp]. Raises [Error msg] if an error occurs. *)
val remove_module_provider: Llvm.llmoduleprovider -> t -> Llvm.llmodule
(** [find_function n ee] finds the function named [n] defined in any of the
(** [find_function n ee] finds the function named [n] defined in any of the
modules owned by the execution engine [ee]. Returns [None] if the function
is not found and [Some f] otherwise. **)
is not found and [Some f] otherwise. *)
val find_function: string -> t -> Llvm.llvalue option
(** [run_function f args ee] synchronously executes the function [f] with the
arguments [args], which must be compatible with the parameter types. **)
arguments [args], which must be compatible with the parameter types. *)
val run_function: Llvm.llvalue -> GenericValue.t array -> t ->
GenericValue.t
(** [run_static_ctors ee] executes the static constructors of each module in
the execution engine [ee]. **)
the execution engine [ee]. *)
val run_static_ctors: t -> unit
(** [run_static_dtors ee] executes the static destructors of each module in
the execution engine [ee]. **)
the execution engine [ee]. *)
val run_static_dtors: t -> unit
(** [run_function_as_main f args env ee] executes the function [f] as a main
(** [run_function_as_main f args env ee] executes the function [f] as a main
function, passing it [argv] and [argc] according to the string array
[args], and [envp] as specified by the array [env]. Returns the integer
return value of the function. **)
[args], and [envp] as specified by the array [env]. Returns the integer
return value of the function. *)
val run_function_as_main: Llvm.llvalue -> string array ->
(string * string) array -> t -> int
(** [free_machine_code f ee] releases the memory in the execution engine [ee]
used to store the machine code for the function [f]. **)
used to store the machine code for the function [f]. *)
val free_machine_code: Llvm.llvalue -> t -> unit
end

View File

@ -120,7 +120,6 @@ external define_type_name : string -> lltype -> llmodule -> bool
external delete_type_name : string -> llmodule -> unit
= "llvm_delete_type_name"
(*===-- Types -------------------------------------------------------------===*)
external classify_type : lltype -> TypeKind.t = "llvm_classify_type"

File diff suppressed because it is too large Load Diff