[PATCH] D19071: [OpenCL] Add predefined macros.
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 19 10:16:57 PDT 2016
yaxunl marked 7 inline comments as done.
================
Comment at: lib/Frontend/InitPreprocessor.cpp:421
@@ +420,3 @@
+ switch (LangOpts.OpenCLVersion) {
+ case 0:
+ case 100:
----------------
yaxunl wrote:
> pxli168 wrote:
> > What is 0 stand for as OpenCLVersion, it seems the default OpenCLVersion if we did not pass any -cl-std=CLXX is 100.
> > So maybe we did not need this case 0:
> There is a test test/Frontend/stdlang.c:
>
> // RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s
>
> With this test, LangOpts.OpenCL is 1 but LangOpts.OpenCLVersion is 0.
>
> If we all agree that this test is invalid and -x cl can only be compiled with OpenCL language standard and the default one is OpenCL 1.0, I can fix that test first and then remove case 0 in this switch.
Anastasia,
What's your opinion on this? Should we limit the allowed language standard for cl to OpenCL standard only? Should I diagnose invalid language standard and also add a lit test for that?
Thanks.
================
Comment at: lib/Frontend/InitPreprocessor.cpp:439
@@ +438,3 @@
+ if (LangOpts.OpenCLVersion >= 110)
+ Builder.defineMacro("CL_VERSION_1_1", "110");
+ if (LangOpts.OpenCLVersion >= 120)
----------------
Anastasia wrote:
> 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.
OK I will add these macros.
http://reviews.llvm.org/D19071
More information about the cfe-commits
mailing list