[PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 13:54:36 PDT 2016


yaxunl marked 8 inline comments as done.

================
Comment at: lib/Headers/opencl.h:11-13
@@ +10,5 @@
+
+#if !defined(__SPIR32__) && !defined(__SPIR64__)
+#error "This header file should be used with SPIR target only."
+#endif
+
----------------
tstellarAMD wrote:
> This should be removed so they can be used with any target.
Agree.

================
Comment at: lib/Headers/opencl.h:53-57
@@ +52,7 @@
+ */
+#if defined(__SPIR32__)
+typedef uint size_t;
+#elif defined(__SPIR64__)
+typedef ulong size_t;
+#endif
+
----------------
tstellarAMD wrote:
> This needs to be removed too.
clang does not define size_t for OpenCL but defines `__SIZE_TYPE__`, so I can use

  #define size_t __SIZE_TYPE__

since `__SIZE_TYPE__` is defined based on pointer width of the architecture, we will get a size_t definition consistent with target pointer width.

================
Comment at: lib/Headers/opencl.h:65-69
@@ +64,7 @@
+ */
+#if defined(__SPIR32__)
+typedef int ptrdiff_t;
+#elif defined(__SPIR64__ )
+typedef long ptrdiff_t;
+#endif
+
----------------
tstellarAMD wrote:
> And this.
Clang does not define ptrdiff_t for OpenCL but I can define it as `__PTRDIFF_TYPE__` which is defined by Clang.

================
Comment at: lib/Headers/opencl.h:70-84
@@ +69,17 @@
+#endif
+
+/**
+* A signed integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef ptrdiff_t intptr_t;
+
+/**
+* An unsigned integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef size_t uintptr_t;
+
+// built-in vector data types:
----------------
tstellarAMD wrote:
> Do we actually need these typdefs?  I thought clang automatically set these for OpenCL.
Clang does not define intptr_t nor uintptr_t, but it defines `__INTPTR_TYPE__` and `__UINTPTR_TYPE__`. I can use them.


http://reviews.llvm.org/D18369





More information about the cfe-commits mailing list