r364174 - [OpenCL] Restore ATOMIC_VAR_INIT

Sven van Haastregt via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 24 03:06:41 PDT 2019


Author: svenvh
Date: Mon Jun 24 03:06:40 2019
New Revision: 364174

URL: http://llvm.org/viewvc/llvm-project?rev=364174&view=rev
Log:
[OpenCL] Restore ATOMIC_VAR_INIT

We accidentally lost the ATOMIC_VAR_INIT and ATOMIC_FLAG_INIT macros
in r363794.

Also put the `memory_order` typedef back inside a `>= CL2.0` guard.

Modified:
    cfe/trunk/lib/Headers/opencl-c-base.h
    cfe/trunk/test/Headers/opencl-c-header.cl

Modified: cfe/trunk/lib/Headers/opencl-c-base.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c-base.h?rev=364174&r1=364173&r2=364174&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/opencl-c-base.h (original)
+++ cfe/trunk/lib/Headers/opencl-c-base.h Mon Jun 24 03:06:40 2019
@@ -297,8 +297,11 @@ typedef enum memory_scope {
  * image memory.
  */
 #define CLK_IMAGE_MEM_FENCE  0x04
-#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
+#ifndef ATOMIC_VAR_INIT
+#define ATOMIC_VAR_INIT(x) (x)
+#endif //ATOMIC_VAR_INIT
+#define ATOMIC_FLAG_INIT 0
 
 // enum values aligned with what clang uses in EmitAtomicExpr()
 typedef enum memory_order
@@ -310,6 +313,8 @@ typedef enum memory_order
   memory_order_seq_cst = __ATOMIC_SEQ_CST
 } memory_order;
 
+#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
+
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions
 
 // These values need to match the runtime equivalent

Modified: cfe/trunk/test/Headers/opencl-c-header.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/opencl-c-header.cl?rev=364174&r1=364173&r2=364174&view=diff
==============================================================================
--- cfe/trunk/test/Headers/opencl-c-header.cl (original)
+++ cfe/trunk/test/Headers/opencl-c-header.cl Mon Jun 24 03:06:40 2019
@@ -80,6 +80,10 @@ void test_atomics(__generic volatile uns
 }
 #endif
 
+// Verify that ATOMIC_VAR_INIT is defined.
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
+global atomic_int z = ATOMIC_VAR_INIT(99);
+#endif //__OPENCL_C_VERSION__
 
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.




More information about the cfe-commits mailing list