Skip to content

Commit 0465fb5

Browse files
author
Gordon Henriksen
committed
Adding ocamldoc-style comments for the Ocaml bindings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44494 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c8d7194 commit 0465fb5

File tree

6 files changed

+826
-56
lines changed

6 files changed

+826
-56
lines changed

bindings/ocaml/analysis/llvm_analysis.ml

-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
* This file was developed by Gordon Henriksen and is distributed under the
66
* University of Illinois Open Source License. See LICENSE.TXT for details.
77
*
8-
*===----------------------------------------------------------------------===
9-
*
10-
* This interface provides an ocaml API for LLVM IR analyses, the classes in
11-
* the Analysis library.
12-
*
138
*===----------------------------------------------------------------------===*)
149

1510

bindings/ocaml/analysis/llvm_analysis.mli

+12
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,24 @@
1313
*===----------------------------------------------------------------------===*)
1414

1515

16+
(** [verify_module m] returns [None] if the module [m] is valid, and
17+
[Some reason] if it is invalid. [reason] is a string containing a
18+
human-readable validation report. See [llvm::verifyModule]. **)
1619
external verify_module : Llvm.llmodule -> string option = "llvm_verify_module"
1720

21+
(** [verify_function f] returns [None] if the function [f] is valid, and
22+
[Some reason] if it is invalid. [reason] is a string containing a
23+
human-readable validation report. See [llvm::verifyFunction]. **)
1824
external verify_function : Llvm.llvalue -> bool = "llvm_verify_function"
1925

26+
(** [verify_module m] returns if the module [m] is valid, but prints a
27+
validation report to [stderr] and aborts the program if it is invalid. See
28+
[llvm::verifyModule]. **)
2029
external assert_valid_module : Llvm.llmodule -> unit
2130
= "llvm_assert_valid_module"
2231

32+
(** [verify_function f] returns if the function [f] is valid, but prints a
33+
validation report to [stderr] and aborts the program if it is invalid. See
34+
[llvm::verifyFunction]. **)
2335
external assert_valid_function : Llvm.llvalue -> unit
2436
= "llvm_assert_valid_function"

bindings/ocaml/bitwriter/llvm_bitwriter.mli

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*===----------------------------------------------------------------------===*)
1414

1515

16-
(* Writes the bitcode for module the given path. Returns true if successful. *)
16+
(** [write_bitcode_file m path] writes the bitcode for module [m] to the file at
17+
[path]. Returns [true] if successful, [false] otherwise. **)
1718
external write_bitcode_file : Llvm.llmodule -> string -> bool
1819
= "llvm_write_bitcode_file"

bindings/ocaml/llvm/llvm.ml

+3-20
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
* This file was developed by Gordon Henriksen and is distributed under the
66
* University of Illinois Open Source License. See LICENSE.TXT for details.
77
*
8-
*===----------------------------------------------------------------------===
9-
*
10-
* This interface provides an ocaml API for the LLVM intermediate
11-
* representation, the classes in the VMCore library.
12-
*
138
*===----------------------------------------------------------------------===*)
149

1510

16-
(* These abstract types correlate directly to the LLVM VMCore classes. *)
1711
type llmodule
1812
type lltype
1913
type lltypehandle
2014
type llvalue
21-
type llbasicblock (* These are actually values, but
22-
benefit from type checking. *)
15+
type llbasicblock
2316
type llbuilder
2417

2518
type type_kind =
@@ -93,28 +86,17 @@ type real_predicate =
9386

9487
(*===-- Modules -----------------------------------------------------------===*)
9588

96-
(* Creates a module with the supplied module ID. Modules are not garbage
97-
collected; it is mandatory to call dispose_module to free memory. *)
9889
external create_module : string -> llmodule = "llvm_create_module"
99-
100-
(* Disposes a module. All references to subordinate objects are invalidated;
101-
referencing them will invoke undefined behavior. *)
10290
external dispose_module : llmodule -> unit = "llvm_dispose_module"
103-
104-
(* Adds a named type to the module's symbol table. Returns true if successful.
105-
If such a name already exists, then no entry is added and returns false. *)
10691
external define_type_name : string -> lltype -> llmodule -> bool
10792
= "llvm_add_type_name"
108-
10993
external delete_type_name : string -> llmodule -> unit
11094
= "llvm_delete_type_name"
11195

11296

11397
(*===-- Types -------------------------------------------------------------===*)
11498

11599
external classify_type : lltype -> type_kind = "llvm_classify_type"
116-
external refine_abstract_type : lltype -> lltype -> unit
117-
= "llvm_refine_abstract_type"
118100

119101
(*--... Operations on integer types ........................................--*)
120102
external _i1_type : unit -> lltype = "llvm_i1_type"
@@ -146,7 +128,6 @@ let fp128_type = _fp128_type ()
146128
let ppc_fp128_type = _ppc_fp128_type ()
147129

148130
(*--... Operations on function types .......................................--*)
149-
(* FIXME: handle parameter attributes *)
150131
external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
151132
external var_arg_function_type : lltype -> lltype array -> lltype
152133
= "llvm_var_arg_function_type"
@@ -280,6 +261,7 @@ external define_global : string -> llvalue -> llmodule -> llvalue
280261
external lookup_global : string -> llmodule -> llvalue option
281262
= "llvm_lookup_global"
282263
external delete_global : llvalue -> unit = "llvm_delete_global"
264+
external has_initializer : llvalue -> bool = "llvm_has_initializer"
283265
external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
284266
external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
285267
external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
@@ -457,6 +439,7 @@ let concat2 sep arr =
457439
!s
458440

459441
let rec string_of_lltype ty =
442+
(* FIXME: stop infinite recursion! :) *)
460443
match classify_type ty with
461444
Integer_type -> "i" ^ string_of_int (integer_bitwidth ty)
462445
| Pointer_type -> (string_of_lltype (element_type ty)) ^ "*"

0 commit comments

Comments
 (0)