Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parsing of OpenCL C++ -cl-std flags (#510) #515

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions opencl_clang_options.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def cl_std_CL1_1: Flag<["-"], "cl-std=CL1.1">;
def cl_std_CL1_2: Flag<["-"], "cl-std=CL1.2">;
def cl_std_CL2_0: Flag<["-"], "cl-std=CL2.0">;
def cl_std_CL3_0: Flag<["-"], "cl-std=CL3.0">;
def cl_std_CLCxx: Flag<["-"], "cl-std=CLC++">;
def cl_std_CLCxx1_0: Flag<["-"], "cl-std=CLC++1.0">;
def cl_std_CLCxx2021: Flag<["-"], "cl-std=CLC++2021">;
def cl_uniform_work_group_size: Flag<["-"], "cl-uniform-work-group-size">;
def cl_no_subgroup_ifp: Flag<["-"], "cl-no-subgroup-ifp">;
def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">;
Expand Down
16 changes: 15 additions & 1 deletion options_compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
ArgsVector &effectiveArgs) {
// Reset args
int iCLStdSet = 0;
bool isCpp = false;
bool fp64Enabled = false;
std::string szTriple;
std::string sourceName(llvm::Twine(s_progID++).str());
Expand Down Expand Up @@ -140,6 +141,17 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
iCLStdSet = 300;
effectiveArgs.push_back((*it)->getAsString(args));
break;
case OPT_COMPILE_cl_std_CLCxx:
case OPT_COMPILE_cl_std_CLCxx1_0:
iCLStdSet = 200;
isCpp = true;
effectiveArgs.push_back((*it)->getAsString(args));
break;
case OPT_COMPILE_cl_std_CLCxx2021:
iCLStdSet = 300;
isCpp = true;
effectiveArgs.push_back((*it)->getAsString(args));
break;
case OPT_COMPILE_triple:
szTriple = (*it)->getValue();
break;
Expand Down Expand Up @@ -221,7 +233,9 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,

// Specifying the option makes clang emit function body for functions
// marked with inline keyword.
effectiveArgs.push_back("-fgnu89-inline");
if (!isCpp) {
effectiveArgs.push_back("-fgnu89-inline");
}

// Do not support all extensions by default. Support for a particular
// extension should be enabled by passing a '-cl-ext' option in pszOptionsEx.
Expand Down
Loading