[PATCH] D134916: [llvm-ocaml] Add binding for constructing opaque pointers

Alan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 29 22:49:07 PDT 2022


alan updated this revision to Diff 464143.
alan added a comment.

[llvm-ocaml] Add binding for llvm::PointerType::isOpaque


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134916/new/

https://reviews.llvm.org/D134916

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
@@ -41,6 +41,10 @@
   insist (i32_type = (Array.get (subtypes ar)) 0);
   insist (i8_type = (Array.get (subtypes ar)) 1)
 
+(*===-- Pointer types  ----------------------------------------------------===*)
+let test_pointer_types () =
+  insist (pointer_type_is_opaque (pointer_type_in_context context 0));
+  insist (not (pointer_type_is_opaque (pointer_type i8_type)))
 
 (*===-- Conversion --------------------------------------------------------===*)
 
Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -586,6 +586,11 @@
   return LLVMPointerTypeInContext(C, Int_val(AddressSpace));
 }
 
+/* lltype -> bool */
+value llvm_pointer_type_is_opaque(LLVMTypeRef PtrTy) {
+  return Val_bool(LLVMPointerTypeIsOpaque(PtrTy));
+}
+
 /* lltype -> int -> lltype */
 LLVMTypeRef llvm_vector_type(LLVMTypeRef ElementTy, value Count) {
   return LLVMVectorType(ElementTy, Int_val(Count));
Index: llvm/bindings/ocaml/llvm/llvm.mli
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.mli
+++ llvm/bindings/ocaml/llvm/llvm.mli
@@ -731,6 +731,10 @@
     See the method [llvm::PointerType::get]. *)
 val pointer_type_in_context : llcontext -> int -> lltype
 
+(** [pointer_type_is_opaque pty] returns whether the pointer type [pty]
+    is opaque. See the method [llvm::PointerType::isOpaque]. *)
+val pointer_type_is_opaque : lltype -> bool
+
 (** [vector_type ty n] returns the array type containing [n] elements of the
     primitive type [ty]. See the method [llvm::ArrayType::get]. *)
 val vector_type : lltype -> int -> lltype
Index: llvm/bindings/ocaml/llvm/llvm.ml
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.ml
+++ llvm/bindings/ocaml/llvm/llvm.ml
@@ -510,6 +510,8 @@
                                 = "llvm_qualified_pointer_type"
 external pointer_type_in_context : llcontext -> int -> lltype
                                  = "llvm_pointer_type_in_context"
+external pointer_type_is_opaque : lltype -> bool
+                                = "llvm_pointer_type_is_opaque"
 external vector_type : lltype -> int -> lltype = "llvm_vector_type"
 
 external element_type : lltype -> lltype = "LLVMGetElementType"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134916.464143.patch
Type: text/x-patch
Size: 2547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220930/0aacd832/attachment.bin>


More information about the llvm-commits mailing list