[PATCH] C API: implement LLVMIntPtrType{,ForAS}InContext

Peter Zotov whitequark at whitequark.org
Sat Oct 12 09:10:57 PDT 2013


All of the Core API functions have versions which accept explicit context, in addition to ones which work on global context. This commit adds functions which accept explicit context to the Target API for consistency.

http://llvm-reviews.chandlerc.com/D1912

Files:
  include/llvm-c/Target.h
  lib/Target/Target.cpp

Index: include/llvm-c/Target.h
===================================================================
--- include/llvm-c/Target.h
+++ include/llvm-c/Target.h
@@ -186,6 +186,15 @@
     See the method llvm::DataLayout::getIntPtrType. */
 LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef, unsigned AS);
 
+/** Returns the integer type that is the same size as a pointer on a target.
+    See the method llvm::DataLayout::getIntPtrType. */
+LLVMTypeRef LLVMIntPtrTypeInContext(LLVMTargetDataRef, LLVMContextRef);
+
+/** Returns the integer type that is the same size as a pointer on a target.
+    This version allows the address space to be specified.
+    See the method llvm::DataLayout::getIntPtrType. */
+LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMTargetDataRef, LLVMContextRef, unsigned AS);
+
 /** Computes the size of a type in bytes for a target.
     See the method llvm::DataLayout::getTypeSizeInBits. */
 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef);
Index: lib/Target/Target.cpp
===================================================================
--- lib/Target/Target.cpp
+++ lib/Target/Target.cpp
@@ -88,6 +88,14 @@
   return wrap(unwrap(TD)->getIntPtrType(getGlobalContext(), AS));
 }
 
+LLVMTypeRef LLVMIntPtrTypeInContext(LLVMTargetDataRef TD, LLVMContextRef C) {
+  return wrap(unwrap(TD)->getIntPtrType(*unwrap(C)));
+}
+
+LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMTargetDataRef TD, LLVMContextRef C, unsigned AS) {
+  return wrap(unwrap(TD)->getIntPtrType(*unwrap(C), AS));
+}
+
 unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
   return unwrap(TD)->getTypeSizeInBits(unwrap(Ty));
 }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1912.1.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131012/39be0e93/attachment.bin>


More information about the llvm-commits mailing list