yaxunl marked 6 inline comments as done. ================ Comment at: lib/Frontend/InitPreprocessor.cpp:426 @@ +425,3 @@ + case 110: + Builder.defineMacro("__CLANG_OPENCL_C_VERSION__", "110"); + break; ---------------- Anastasia wrote: > So why we can't use unified __OPENCL_C_VERSION__? `__OPENCL_C_VERSION__` is not defined in OpenCL spec v1.0 and 1.1.
================ Comment at: lib/Frontend/InitPreprocessor.cpp:438 @@ +437,3 @@ + Builder.defineMacro("CL_VERSION_1_0", "100"); + if (LangOpts.OpenCLVersion >= 110) + Builder.defineMacro("CL_VERSION_1_1", "110"); ---------------- Anastasia wrote: > I am not sure we should add this conditionally though. If you want to compile > CL code like this (forcing pointer to point to private AS for all CL versions > the code is compiled for): > > #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 > private void* priv_ptr; > #else > void* priv_ptr; > #endif > > This code would fail with -cl-sdt=CL1.1 (because CL_VERSION_2_0 is no longer > defined), but the purpose of having version macros is to be able to condition > on the passed CL version in the particular compilation run to avoid the > compiler failure/miscompilation. This way we provide a way to select the > right CL code for all versions the code is being compiled (if such selection > is needed) to allow portability of CL code among OpenCL version. CL_VERSION_x_y is only defined in OpenCL spec version equal or above x.y. We can use macros like #if defined(__OPENCL_C_VERSION__) && defined(CL_VERSION_2_0) && __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #define _CL20_AND_ABOVE 1 #endif ================ Comment at: lib/Frontend/InitPreprocessor.cpp:439 @@ +438,3 @@ + if (LangOpts.OpenCLVersion >= 110) + Builder.defineMacro("CL_VERSION_1_1", "110"); + if (LangOpts.OpenCLVersion >= 120) ---------------- yaxunl wrote: > pxli168 wrote: > > These macros maybe need for all cl version, and in the header we should > > compare __OPENCL_C_VERSION__ with CL_VERSION_2_0 instead of the integer > > 200 in the header of http://reviews.llvm.org/D18369? > Each OpenCL version only defines some of these macros by spec. > > In the header file `__OPENCL_C_VERSION__` can compare with 200 since the spec > defines the integer value for `__OPENCL_C_VERSION__`. Comparing with > CL_VERSION_2_0 requires checking CL_VERSION_2_0 is available first. I think > probably I can define a macro > > #define _OPENCL20_AND_ABOVE defined(__OPENCL_C_VERSION__) and > defined(CL_VERSION_2_0) and __OPENCL_C_VERSION__ >= 200 > > and then use this macro for conditioning 2.0 specific functions. should be #if defined(__OPENCL_C_VERSION__) && defined(CL_VERSION_2_0) && __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #define _CL20_AND_ABOVE 1 #endif http://reviews.llvm.org/D19071 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits