[PATCH] D135499: [llvm-ocaml] Revise OCaml opaque pointer bindings to match rest of API

Alan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 16:18:40 PDT 2022


alan created this revision.
Herald added a project: All.
alan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135499

Files:
  llvm/bindings/ocaml/llvm/llvm.ml
  llvm/bindings/ocaml/llvm/llvm.mli
  llvm/bindings/ocaml/llvm/llvm_ocaml.c
  llvm/test/Bindings/OCaml/core.ml


Index: llvm/test/Bindings/OCaml/core.ml
===================================================================
--- llvm/test/Bindings/OCaml/core.ml
+++ llvm/test/Bindings/OCaml/core.ml
@@ -43,8 +43,9 @@
 
 (*===-- Pointer types  ----------------------------------------------------===*)
 let test_pointer_types () =
-  insist (address_space (pointer_type_in_context context 0) = 0);
-  insist (address_space (pointer_type_in_context context 1) = 1)
+  insist (address_space (pointer_type2 context) = 0);
+  insist (address_space (qualified_pointer_type2 context 0) = 0);
+  insist (address_space (qualified_pointer_type2 context 1) = 1)
 
 (*===-- Conversion --------------------------------------------------------===*)
 
Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -581,8 +581,13 @@
   return LLVMPointerType(ElementTy, Int_val(AddressSpace));
 }
 
+/* llcontext -> lltype */
+LLVMTypeRef llvm_pointer_type2(LLVMContextRef C, value AddressSpace) {
+  return LLVMPointerTypeInContext(C, 0);
+}
+
 /* llcontext -> int -> lltype */
-LLVMTypeRef llvm_pointer_type_in_context(LLVMContextRef C, value AddressSpace) {
+LLVMTypeRef llvm_qualified_pointer_type2(LLVMContextRef C, value AddressSpace) {
   return LLVMPointerTypeInContext(C, Int_val(AddressSpace));
 }
 
Index: llvm/bindings/ocaml/llvm/llvm.mli
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.mli
+++ llvm/bindings/ocaml/llvm/llvm.mli
@@ -721,15 +721,20 @@
     See the method [llvm::PointerType::getUnqual]. *)
 val pointer_type : lltype -> lltype
 
-(** [qualified_pointer_type ty as] returns the pointer type referencing objects
-    of type [ty] in address space [as].
+(** [qualified_pointer_type ty a] returns the pointer type referencing objects
+    of type [ty] in address space [a].
     See the method [llvm::PointerType::get]. *)
 val qualified_pointer_type : lltype -> int -> lltype
 
-(** [pointer_type_in_context context as] returns the opaque pointer type
-    referencing objects in address space [as].
+(** [pointer_type2 context] returns the pointer type in the default
+    address space (0).
     See the method [llvm::PointerType::get]. *)
-val pointer_type_in_context : llcontext -> int -> lltype
+val pointer_type2 : llcontext -> lltype
+
+(** [qualified_pointer_type2 context a] returns the pointer type referencing
+    objects in address space [a].
+    See the method [llvm::PointerType::get]. *)
+val qualified_pointer_type2 : llcontext -> int -> lltype
 
 (** [vector_type ty n] returns the array type containing [n] elements of the
     primitive type [ty]. See the method [llvm::ArrayType::get]. *)
Index: llvm/bindings/ocaml/llvm/llvm.ml
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.ml
+++ llvm/bindings/ocaml/llvm/llvm.ml
@@ -508,8 +508,9 @@
 external pointer_type : lltype -> lltype = "llvm_pointer_type"
 external qualified_pointer_type : lltype -> int -> lltype
                                 = "llvm_qualified_pointer_type"
-external pointer_type_in_context : llcontext -> int -> lltype
-                                 = "llvm_pointer_type_in_context"
+external pointer_type2 : llcontext -> lltype = "llvm_pointer_type2"
+external qualified_pointer_type2 : llcontext -> int -> lltype
+                                 = "llvm_qualified_pointer_type2"
 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
 
 external element_type : lltype -> lltype = "LLVMGetElementType"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135499.466218.patch
Type: text/x-patch
Size: 3651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221007/fd1a4c09/attachment.bin>


More information about the llvm-commits mailing list