|
5 | 5 | * This file was developed by Gordon Henriksen and is distributed under the
|
6 | 6 | * University of Illinois Open Source License. See LICENSE.TXT for details.
|
7 | 7 | *
|
8 |
| - *===----------------------------------------------------------------------=== |
9 |
| - * |
10 |
| - * This interface provides an ocaml API for the LLVM intermediate |
11 |
| - * representation, the classes in the VMCore library. |
12 |
| - * |
13 | 8 | *===----------------------------------------------------------------------===*)
|
14 | 9 |
|
15 | 10 |
|
16 |
| -(* These abstract types correlate directly to the LLVM VMCore classes. *) |
17 | 11 | type llmodule
|
18 | 12 | type lltype
|
19 | 13 | type lltypehandle
|
20 | 14 | type llvalue
|
21 |
| -type llbasicblock (* These are actually values, but |
22 |
| - benefit from type checking. *) |
| 15 | +type llbasicblock |
23 | 16 | type llbuilder
|
24 | 17 |
|
25 | 18 | type type_kind =
|
@@ -93,28 +86,17 @@ type real_predicate =
|
93 | 86 |
|
94 | 87 | (*===-- Modules -----------------------------------------------------------===*)
|
95 | 88 |
|
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. *) |
98 | 89 | 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. *) |
102 | 90 | 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. *) |
106 | 91 | external define_type_name : string -> lltype -> llmodule -> bool
|
107 | 92 | = "llvm_add_type_name"
|
108 |
| - |
109 | 93 | external delete_type_name : string -> llmodule -> unit
|
110 | 94 | = "llvm_delete_type_name"
|
111 | 95 |
|
112 | 96 |
|
113 | 97 | (*===-- Types -------------------------------------------------------------===*)
|
114 | 98 |
|
115 | 99 | external classify_type : lltype -> type_kind = "llvm_classify_type"
|
116 |
| -external refine_abstract_type : lltype -> lltype -> unit |
117 |
| - = "llvm_refine_abstract_type" |
118 | 100 |
|
119 | 101 | (*--... Operations on integer types ........................................--*)
|
120 | 102 | external _i1_type : unit -> lltype = "llvm_i1_type"
|
@@ -146,7 +128,6 @@ let fp128_type = _fp128_type ()
|
146 | 128 | let ppc_fp128_type = _ppc_fp128_type ()
|
147 | 129 |
|
148 | 130 | (*--... Operations on function types .......................................--*)
|
149 |
| -(* FIXME: handle parameter attributes *) |
150 | 131 | external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
|
151 | 132 | external var_arg_function_type : lltype -> lltype array -> lltype
|
152 | 133 | = "llvm_var_arg_function_type"
|
@@ -280,6 +261,7 @@ external define_global : string -> llvalue -> llmodule -> llvalue
|
280 | 261 | external lookup_global : string -> llmodule -> llvalue option
|
281 | 262 | = "llvm_lookup_global"
|
282 | 263 | external delete_global : llvalue -> unit = "llvm_delete_global"
|
| 264 | +external has_initializer : llvalue -> bool = "llvm_has_initializer" |
283 | 265 | external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
|
284 | 266 | external set_initializer : llvalue -> llvalue -> unit = "llvm_set_initializer"
|
285 | 267 | external remove_initializer : llvalue -> unit = "llvm_remove_initializer"
|
@@ -457,6 +439,7 @@ let concat2 sep arr =
|
457 | 439 | !s
|
458 | 440 |
|
459 | 441 | let rec string_of_lltype ty =
|
| 442 | + (* FIXME: stop infinite recursion! :) *) |
460 | 443 | match classify_type ty with
|
461 | 444 | Integer_type -> "i" ^ string_of_int (integer_bitwidth ty)
|
462 | 445 | | Pointer_type -> (string_of_lltype (element_type ty)) ^ "*"
|
|
0 commit comments