[PATCH] D125168: Add opaque ptr to the llvm-c

Christoffer Lerno via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 7 08:25:46 PDT 2022


lerno created this revision.
lerno added a project: LLVM.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
Herald added a project: All.
lerno requested review of this revision.
Herald added a subscriber: llvm-commits.

Add wrappers to allow use of opaque pointers from the C API


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125168

Files:
  llvm/include/llvm-c/Core.h
  llvm/lib/IR/Core.cpp


Index: llvm/lib/IR/Core.cpp
===================================================================
--- llvm/lib/IR/Core.cpp
+++ llvm/lib/IR/Core.cpp
@@ -824,6 +824,10 @@
 
 /*--.. Operations on other types ...........................................--*/
 
+LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace)  {
+  return wrap(PointerType::get(*unwrap(C), AddressSpace));
+}
+
 LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C)  {
   return wrap(Type::getVoidTy(*unwrap(C)));
 }
@@ -837,6 +841,10 @@
   return wrap(Type::getMetadataTy(*unwrap(C)));
 }
 
+LLVMTypeRef LLVMPointerType2(unsigned AddressSpace)  {
+  return LLVMPointerTypeInContext(LLVMGetGlobalContext(), AddressSpace);
+}
+
 LLVMTypeRef LLVMVoidType(void)  {
   return LLVMVoidTypeInContext(LLVMGetGlobalContext());
 }
Index: llvm/include/llvm-c/Core.h
===================================================================
--- llvm/include/llvm-c/Core.h
+++ llvm/include/llvm-c/Core.h
@@ -1442,6 +1442,13 @@
  */
 LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace);
 
+/**
+ * Create an opaque pointer type in a context
+ *
+ * @see llvm::PointerType::get()
+ */
+LLVMTypeRef LLVMPointerTypeInContext(LLVMContextRef C, unsigned AddressSpace);
+
 /**
  * Obtain the address space of a pointer type.
  *
@@ -1531,6 +1538,7 @@
 LLVMTypeRef LLVMLabelType(void);
 LLVMTypeRef LLVMX86MMXType(void);
 LLVMTypeRef LLVMX86AMXType(void);
+LLVMTypeRef LLVMPointerType2(unsigned AddressSpace);
 
 /**
  * @}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125168.427867.patch
Type: text/x-patch
Size: 1509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220507/443d8948/attachment.bin>


More information about the llvm-commits mailing list