Skip to content

Commit 0a2b098

Browse files
wenju-helucasz93
andauthored
Add parsing of OpenCL C++ -cl-std flags (#510) (#511)
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](#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) Co-authored-by: lucasz93 <[email protected]>
1 parent 980f169 commit 0a2b098

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
@@ -67,6 +67,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
6767
ArgsVector &effectiveArgs) {
6868
// Reset args
6969
int iCLStdSet = 0;
70+
bool isCpp = false;
7071
bool fp64Enabled = false;
7172
std::string szTriple;
7273
std::string sourceName(llvm::Twine(s_progID++).str());
@@ -135,6 +136,17 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
135136
iCLStdSet = 300;
136137
effectiveArgs.push_back((*it)->getAsString(args));
137138
break;
139+
case OPT_COMPILE_cl_std_CLCxx:
140+
case OPT_COMPILE_cl_std_CLCxx1_0:
141+
iCLStdSet = 200;
142+
isCpp = true;
143+
effectiveArgs.push_back((*it)->getAsString(args));
144+
break;
145+
case OPT_COMPILE_cl_std_CLCxx2021:
146+
iCLStdSet = 300;
147+
isCpp = true;
148+
effectiveArgs.push_back((*it)->getAsString(args));
149+
break;
138150
case OPT_COMPILE_triple:
139151
szTriple = (*it)->getValue();
140152
break;
@@ -212,7 +224,9 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
212224

213225
// Specifying the option makes clang emit function body for functions
214226
// marked with inline keyword.
215-
effectiveArgs.push_back("-fgnu89-inline");
227+
if (!isCpp) {
228+
effectiveArgs.push_back("-fgnu89-inline");
229+
}
216230

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

0 commit comments

Comments
 (0)