This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Added -std/-cl-std=CL2.2/CLC++
ClosedPublic

Authored by Anastasia on Apr 6 2018, 4:40 AM.

Details

Summary

Added std option for OpenCL C++, see cfe-dev thread for more details:
http://lists.llvm.org/pipermail/cfe-dev/2018-April/057535.html

Examples:
clang -std=c++ test.cl

I am not sure if we need a separate language mode. Right now I am reusing OpenCL. We can discuss.

Diff Detail

Event Timeline

Anastasia created this revision.Apr 6 2018, 4:40 AM
yaxunl added a comment.Apr 6 2018, 7:28 AM

LGTM. Thank!

bader added inline comments.Apr 6 2018, 8:28 AM
include/clang/Frontend/LangStandards.def
167

OpenCL C++ 1.0 specification defines only 'c++' value for -cl-std option.
Assuming that OpenCL C++ 1.0 might be supported by multiple OpenCL version, wouldn't 'CL2.2' confuse people?
As we have separate kernel language specification with independent version numbering, I think we should avoid using OpenCL API numbering for language version.

What is the naming scheme for next versions of OpenCL C++ specification? 'clc++N.M'?

lib/Frontend/InitPreprocessor.cpp
428

I think we should not skip this section for OpenCL C++, but define OPENCL_CPP_VERSION macro.

Anastasia updated this revision to Diff 141975.Apr 11 2018, 5:04 AM
Anastasia edited the summary of this revision. (Show Details)

Changed to -cl-std=c++ since it's explicitly defined in spec. We could reuse OpenCLVersion in LangOpts but I think it might be cleaner to add separate OpenCLCPlusPlusVersion.

Anastasia added inline comments.Apr 11 2018, 5:06 AM
lib/Frontend/InitPreprocessor.cpp
434

There is no such macro in the spec it seems, but I am adding it because it's probably useful. Also endian and fast math macros (bfrom below) are not in the spec it seems. Not sure it was on purpose.

bader accepted this revision.Apr 11 2018, 5:44 AM

LGTM. Thanks!

This revision is now accepted and ready to land.Apr 11 2018, 5:44 AM
This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.