Skip to content

Commit 016c46d

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 b1e3219 commit 016c46d

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
@@ -34,6 +34,9 @@ def cl_std_CL1_1: Flag<["-"], "cl-std=CL1.1">;
3434
def cl_std_CL1_2: Flag<["-"], "cl-std=CL1.2">;
3535
def cl_std_CL2_0: Flag<["-"], "cl-std=CL2.0">;
3636
def cl_std_CL3_0: Flag<["-"], "cl-std=CL3.0">;
37+
def cl_std_CLCxx: Flag<["-"], "cl-std=CLC++">;
38+
def cl_std_CLCxx1_0: Flag<["-"], "cl-std=CLC++1.0">;
39+
def cl_std_CLCxx2021: Flag<["-"], "cl-std=CLC++2021">;
3740
def cl_uniform_work_group_size: Flag<["-"], "cl-uniform-work-group-size">;
3841
def cl_no_subgroup_ifp: Flag<["-"], "cl-no-subgroup-ifp">;
3942
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());
@@ -140,6 +141,17 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
140141
iCLStdSet = 300;
141142
effectiveArgs.push_back((*it)->getAsString(args));
142143
break;
144+
case OPT_COMPILE_cl_std_CLCxx:
145+
case OPT_COMPILE_cl_std_CLCxx1_0:
146+
iCLStdSet = 200;
147+
isCpp = true;
148+
effectiveArgs.push_back((*it)->getAsString(args));
149+
break;
150+
case OPT_COMPILE_cl_std_CLCxx2021:
151+
iCLStdSet = 300;
152+
isCpp = true;
153+
effectiveArgs.push_back((*it)->getAsString(args));
154+
break;
143155
case OPT_COMPILE_triple:
144156
szTriple = (*it)->getValue();
145157
break;
@@ -221,7 +233,9 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
221233

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

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

0 commit comments

Comments
 (0)