From: Nick Lewycky Date: Sat, 9 Jul 2011 18:29:33 +0000 (+0000) Subject: Update OCaml bindings. Opaque types are gone, type holders are gone and the X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=7c72c927c5c26806651113d9ee1dfb7aa5cb62c2;p=oota-llvm.git Update OCaml bindings. Opaque types are gone, type holders are gone and the module operations that operate on type names are gone. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134839 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 462eb201694..a62ba377079 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -11,7 +11,6 @@ type llcontext type llmodule type lltype -type lltypehandle type llvalue type lluse type llbasicblock @@ -32,7 +31,6 @@ module TypeKind = struct | Struct | Array | Pointer - | Opaque | Vector | Metadata end @@ -162,12 +160,6 @@ external data_layout: llmodule -> string = "llvm_data_layout" external set_data_layout: string -> llmodule -> unit = "llvm_set_data_layout" -external define_type_name : string -> lltype -> llmodule -> bool - = "llvm_add_type_name" -external delete_type_name : string -> llmodule -> unit - = "llvm_delete_type_name" -external type_by_name : llmodule -> string -> lltype option - = "llvm_type_by_name" external dump_module : llmodule -> unit = "llvm_dump_module" external set_module_inline_asm : llmodule -> string -> unit = "llvm_set_module_inline_asm" @@ -222,16 +214,9 @@ external address_space : lltype -> int = "llvm_address_space" external vector_size : lltype -> int = "llvm_vector_size" (*--... Operations on other types ..........................................--*) -external opaque_type : llcontext -> lltype = "llvm_opaque_type" external void_type : llcontext -> lltype = "llvm_void_type" external label_type : llcontext -> lltype = "llvm_label_type" -(*--... Operations on type handles .........................................--*) -external handle_to_type : lltype -> lltypehandle = "llvm_handle_to_type" -external type_of_handle : lltypehandle -> lltype = "llvm_type_of_handle" -external refine_type : lltype -> lltype -> unit = "llvm_refine_type" - - (*===-- Values ------------------------------------------------------------===*) external type_of : llvalue -> lltype = "llvm_type_of" external value_name : llvalue -> string = "llvm_value_name" @@ -1049,7 +1034,6 @@ let rec string_of_lltype ty = " x " ^ (string_of_lltype (element_type ty)) ^ "]" | TypeKind.Vector -> "<" ^ (string_of_int (vector_size ty)) ^ " x " ^ (string_of_lltype (element_type ty)) ^ ">" - | TypeKind.Opaque -> "opaque" | TypeKind.Function -> string_of_lltype (return_type ty) ^ " (" ^ (concat2 ", " ( Array.map string_of_lltype (param_types ty) diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 9b037aae7a4..44f345f1b09 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -29,11 +29,6 @@ type llmodule [llvm::Type] class. *) type lltype -(** When building recursive types using {!refine_type}, [lltype] values may - become invalid; use [lltypehandle] to resolve this problem. See the - [llvm::AbstractTypeHolder] class. *) -type lltypehandle - (** Any value in the LLVM IR. Functions, instructions, global variables, constants, and much more are all [llvalues]. See the [llvm::Value] class. This type covers a wide range of subclasses. *) @@ -69,7 +64,6 @@ module TypeKind : sig | Struct | Array | Pointer - | Opaque | Vector | Metadata end @@ -261,24 +255,6 @@ val data_layout: llmodule -> string to the string [s]. See the method [llvm::Module::setDataLayout]. *) val set_data_layout: string -> llmodule -> unit - -(** [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] - method. *) -val define_type_name : string -> lltype -> llmodule -> bool - - -(** [delete_type_name name] removes a type name from the module's symbol - table. *) -val delete_type_name : string -> llmodule -> unit - - -(** [type_by_name m n] returns the type in the module [m] named [n], or [None] - if it does not exist. See the method [llvm::Module::getTypeByName]. *) -val type_by_name : llmodule -> string -> lltype option - - (** [dump_module m] prints the .ll representation of the module [m] to standard error. See the method [llvm::Module::dump]. *) val dump_module : llmodule -> unit @@ -447,11 +423,6 @@ val vector_size : lltype -> int (** {7 Operations on other types} *) -(** [opaque_type c] creates a new opaque type distinct from any other in the - context [c]. Opaque types are useful for building recursive types in - combination with {!refine_type}. See [llvm::OpaqueType::get]. *) -val opaque_type : llcontext -> lltype - (** [void_type c] creates a type of a function which does not return any value in the context [c]. See [llvm::Type::VoidTy]. *) val void_type : llcontext -> lltype @@ -460,25 +431,6 @@ val void_type : llcontext -> lltype [llvm::Type::LabelTy]. *) val label_type : llcontext -> lltype -(** {7 Operations on type handles} *) - -(** [handle_to_type ty] creates a handle to the type [ty]. If [ty] is later - refined as a result of a call to {!refine_type}, the handle will be updated; - any bare [lltype] references will become invalid. - See the class [llvm::PATypeHolder]. *) -val handle_to_type : lltype -> lltypehandle - -(** [type_of_handle tyh] resolves the type handle [tyh]. - See the method [llvm::PATypeHolder::get()]. *) -val type_of_handle : lltypehandle -> lltype - -(** [refine_type opaque_ty ty] replaces the abstract type [opaque_ty] with the - 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]. *) -val refine_type : lltype -> lltype -> unit - - (* {6 Values} *) (** [type_of v] returns the type of the value [v]. diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index ce6cf8ea79e..455e191d522 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -152,30 +152,6 @@ CAMLprim value llvm_set_data_layout(value Layout, LLVMModuleRef M) { return Val_unit; } -/* string -> lltype -> llmodule -> bool */ -CAMLprim value llvm_add_type_name(value Name, LLVMTypeRef Ty, LLVMModuleRef M) { - int res = LLVMAddTypeName(M, String_val(Name), Ty); - return Val_bool(res == 0); -} - -/* string -> llmodule -> unit */ -CAMLprim value llvm_delete_type_name(value Name, LLVMModuleRef M) { - LLVMDeleteTypeName(M, String_val(Name)); - return Val_unit; -} - -/* llmodule -> string -> lltype option */ -CAMLprim value llvm_type_by_name(LLVMModuleRef M, value Name) { - CAMLparam1(Name); - LLVMTypeRef T; - if ((T = LLVMGetTypeByName(M, String_val(Name)))) { - value Option = alloc(1, 0); - Field(Option, 0) = (value) T; - CAMLreturn(Option); - } - CAMLreturn(Val_int(0)); -} - /* llmodule -> unit */ CAMLprim value llvm_dump_module(LLVMModuleRef M) { LLVMDumpModule(M); @@ -373,44 +349,6 @@ CAMLprim LLVMTypeRef llvm_label_type(LLVMContextRef Context) { return LLVMLabelTypeInContext(Context); } -/* llcontext -> lltype */ -CAMLprim LLVMTypeRef llvm_opaque_type(LLVMContextRef Context) { - return LLVMOpaqueTypeInContext(Context); -} - -/*--... Operations on type handles .........................................--*/ - -#define Typehandle_val(v) (*(LLVMTypeHandleRef *)(Data_custom_val(v))) - -static void llvm_finalize_handle(value TH) { - LLVMDisposeTypeHandle(Typehandle_val(TH)); -} - -static struct custom_operations typehandle_ops = { - (char *) "LLVMTypeHandle", - llvm_finalize_handle, - custom_compare_default, - custom_hash_default, - custom_serialize_default, - custom_deserialize_default -}; - -CAMLprim value llvm_handle_to_type(LLVMTypeRef PATy) { - value TH = alloc_custom(&typehandle_ops, sizeof(LLVMBuilderRef), 0, 1); - Typehandle_val(TH) = LLVMCreateTypeHandle(PATy); - return TH; -} - -CAMLprim LLVMTypeRef llvm_type_of_handle(value TH) { - return LLVMResolveTypeHandle(Typehandle_val(TH)); -} - -CAMLprim value llvm_refine_type(LLVMTypeRef AbstractTy, LLVMTypeRef ConcreteTy){ - LLVMRefineType(AbstractTy, ConcreteTy); - return Val_unit; -} - - /*===-- VALUES ------------------------------------------------------------===*/ /* llvalue -> lltype */