[PATCH] D60764: Add clang cc1 option to generate OpenCL builtin functions
Pierre via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 16 01:52:21 PDT 2019
Pierre created this revision.
Pierre added reviewers: svenvh, Anastasia.
Herald added subscribers: cfe-commits, kristina, yaxunl.
Herald added a project: clang.
Clang cc1 currently sets the -finclude-default-header flag by default, including the opencl-c.h header file. This patch adds a -fgenerate-opencl-builtin flag to generate OpenCL builtin functions with Tablegen. This flag overrides the -finclude-default-header flag.
This patch follows https://reviews.llvm.org/D60763
Repository:
rC Clang
https://reviews.llvm.org/D60764
Files:
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaLookup.cpp
Index: clang/lib/Sema/SemaLookup.cpp
===================================================================
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -820,7 +820,7 @@
}
// Check if this is an OpenCL Builtin, and if so, insert the declarations.
- if (S.getLangOpts().OpenCL) {
+ if (S.getLangOpts().OpenCL && S.getLangOpts().GenerateOpenCLBuiltin) {
auto Index = isOpenCLBuiltin(II->getName());
if (Index.first) {
InsertBuiltinDeclarations(S, R, II, Index.first, Index.second);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2152,7 +2152,7 @@
Opts.NativeHalfArgsAndReturns = 1;
Opts.OpenCLCPlusPlus = Opts.CPlusPlus;
// Include default header file for OpenCL.
- if (Opts.IncludeDefaultHeader) {
+ if (Opts.IncludeDefaultHeader && !Opts.GenerateOpenCLBuiltin) {
PPOpts.Includes.push_back("opencl-c.h");
}
}
@@ -2355,6 +2355,7 @@
}
Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header);
+ Opts.GenerateOpenCLBuiltin = Args.hasArg(OPT_fgenerate_opencl_builtin);
llvm::Triple T(TargetOpts.Triple);
CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
Index: clang/include/clang/Driver/CC1Options.td
===================================================================
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -752,6 +752,8 @@
HelpText<"Set default calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall,regcall">;
def finclude_default_header : Flag<["-"], "finclude-default-header">,
HelpText<"Include the default header file for OpenCL">;
+def fgenerate_opencl_builtin: Flag<["-"], "fgenerate-opencl-builtin">,
+ HelpText<"Generate OpenCL builtin functions using Tablegen">;
def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
HelpText<"Preserve 3-component vector type">;
def fwchar_type_EQ : Joined<["-"], "fwchar-type=">,
Index: clang/include/clang/Basic/LangOptions.def
===================================================================
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -255,6 +255,7 @@
LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, "OpenCL address space map mangling mode")
LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
+LANGOPT(GenerateOpenCLBuiltin, 1, 0, "Generate OpenCL Builtin functions using Tablegen")
BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
LANGOPT(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60764.195339.patch
Type: text/x-patch
Size: 2872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190416/9f054729/attachment.bin>
More information about the cfe-commits
mailing list