[PATCH] D19071: [OpenCL] Add predefined macros.

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 09:48:38 PDT 2016


Anastasia added inline comments.

================
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:
> 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
> 
Where do you plan to add this code?

My point is that the code is a bit complicated and messy with this checks and on the other hand it's kind of logical that compiler supporting all CL version would also accept all CL_VERSION_X_Y macros irrespectively from the passed -cl-std flag... I don't think spec is being that explicit on how CL2.0 compliant compiler should enable those macros when earlier versions of -cl-std are being passed.


http://reviews.llvm.org/D19071





More information about the cfe-commits mailing list