Skip to content

Commit 4785978

Browse files
lucasz93wenju-he
authored andcommitted
Add parsing of OpenCL C++ -cl-std flags (intel#510)
Hello! Support for OpenCL C++ was added into LLVM 14, but IGC doesn't support parsing of those flags just yet. I've opened PRs which adds support for parsing these flags to the following repositories: [intel-graphics-compiler](intel/intel-graphics-compiler#328), [compute-runtime](intel/compute-runtime#731) and [opencl-clang](intel#510). The options are passed down into LLVM which then happily compiles my C++ kernel. PRs should be merged in the following order: opencl-clang, intel-graphics-compiler, then finally compute-runtime. Kind regards, -Lucas Co-authored-by: Lucas Zadrozny <[email protected]> (cherry picked from commit 545a145)
1 parent e85b343 commit 4785978

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

opencl_clang_options.td

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ def cl_std_CL1_1: Flag<["-"], "cl-std=CL1.1">;
3333
def cl_std_CL1_2: Flag<["-"], "cl-std=CL1.2">;
3434
def cl_std_CL2_0: Flag<["-"], "cl-std=CL2.0">;
3535
def cl_std_CL3_0: Flag<["-"], "cl-std=CL3.0">;
36+
def cl_std_CLCxx: Flag<["-"], "cl-std=CLC++">;
37+
def cl_std_CLCxx1_0: Flag<["-"], "cl-std=CLC++1.0">;
38+
def cl_std_CLCxx2021: Flag<["-"], "cl-std=CLC++2021">;
3639
def cl_uniform_work_group_size: Flag<["-"], "cl-uniform-work-group-size">;
3740
def cl_no_subgroup_ifp: Flag<["-"], "cl-no-subgroup-ifp">;
3841
def triple : Separate<["-"], "triple">, HelpText<"Specify target triple (e.g. i686-apple-darwin9)">;

options_compile.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
7171
ArgsVector &effectiveArgs) {
7272
// Reset args
7373
int iCLStdSet = 0;
74+
bool isCpp = false;
7475
bool fp64Enabled = false;
7576
std::string szTriple;
7677
std::string sourceName(llvm::Twine(s_progID++).str());
@@ -139,6 +140,17 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
139140
iCLStdSet = 300;
140141
effectiveArgs.push_back((*it)->getAsString(args));
141142
break;
143+
case OPT_COMPILE_cl_std_CLCxx:
144+
case OPT_COMPILE_cl_std_CLCxx1_0:
145+
iCLStdSet = 200;
146+
isCpp = true;
147+
effectiveArgs.push_back((*it)->getAsString(args));
148+
break;
149+
case OPT_COMPILE_cl_std_CLCxx2021:
150+
iCLStdSet = 300;
151+
isCpp = true;
152+
effectiveArgs.push_back((*it)->getAsString(args));
153+
break;
142154
case OPT_COMPILE_triple:
143155
szTriple = (*it)->getValue();
144156
break;
@@ -220,7 +232,9 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
220232

221233
// Specifying the option makes clang emit function body for functions
222234
// marked with inline keyword.
223-
effectiveArgs.push_back("-fgnu89-inline");
235+
if (!isCpp) {
236+
effectiveArgs.push_back("-fgnu89-inline");
237+
}
224238

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

0 commit comments

Comments
 (0)