summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2016-12-16 19:22:08 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2016-12-16 19:22:08 +0000
commit2e8331cab61615d3831f4eb497a38171eaccc9e7 (patch)
tree9d77b116da67230781caacc4fd5d82c9260b17d8 /clang/lib/Serialization/ASTWriter.cpp
parenta4e7dfbc16e6e9c786f01a325a3663e8028b4cc0 (diff)
downloadbcm5719-llvm-2e8331cab61615d3831f4eb497a38171eaccc9e7.tar.gz
bcm5719-llvm-2e8331cab61615d3831f4eb497a38171eaccc9e7.zip
[OpenCL] Allow disabling types and declarations associated with extensions
Added a map to associate types and declarations with extensions. Refactored existing diagnostic for disabled types associated with extensions and extended it to declarations for generic situation. Fixed some bugs for types associated with extensions. Allow users to use pragma to declare types and functions for supported extensions, e.g. #pragma OPENCL EXTENSION the_new_extension_name : begin // declare types and functions associated with the extension here #pragma OPENCL EXTENSION the_new_extension_name : end Differential Revision: https://reviews.llvm.org/D21698 llvm-svn: 289979
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 8b863bcecde..493941a3eff 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1053,6 +1053,8 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(HEADER_SEARCH_TABLE);
RECORD(FP_PRAGMA_OPTIONS);
RECORD(OPENCL_EXTENSIONS);
+ RECORD(OPENCL_EXTENSION_TYPES);
+ RECORD(OPENCL_EXTENSION_DECLS);
RECORD(DELEGATING_CTORS);
RECORD(KNOWN_NAMESPACES);
RECORD(MODULE_OFFSET_MAP);
@@ -3939,11 +3941,46 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
const OpenCLOptions &Opts = SemaRef.getOpenCLOptions();
RecordData Record;
-#define OPENCLEXT(nm) Record.push_back(Opts.nm);
-#include "clang/Basic/OpenCLExtensions.def"
+ for (const auto &I:Opts.OptMap) {
+ AddString(I.getKey(), Record);
+ auto V = I.getValue();
+ Record.push_back(V.Supported);
+ Record.push_back(V.Enabled);
+ Record.push_back(V.Avail);
+ Record.push_back(V.Core);
+ }
Stream.EmitRecord(OPENCL_EXTENSIONS, Record);
}
+void ASTWriter::WriteOpenCLExtensionTypes(Sema &SemaRef) {
+ if (!SemaRef.Context.getLangOpts().OpenCL)
+ return;
+
+ RecordData Record;
+ for (const auto &I : SemaRef.OpenCLTypeExtMap) {
+ Record.push_back(
+ static_cast<unsigned>(getTypeID(I.first->getCanonicalTypeInternal())));
+ Record.push_back(I.second.size());
+ for (auto Ext : I.second)
+ AddString(Ext, Record);
+ }
+ Stream.EmitRecord(OPENCL_EXTENSION_TYPES, Record);
+}
+
+void ASTWriter::WriteOpenCLExtensionDecls(Sema &SemaRef) {
+ if (!SemaRef.Context.getLangOpts().OpenCL)
+ return;
+
+ RecordData Record;
+ for (const auto &I : SemaRef.OpenCLDeclExtMap) {
+ Record.push_back(getDeclID(I.first));
+ Record.push_back(static_cast<unsigned>(I.second.size()));
+ for (auto Ext : I.second)
+ AddString(Ext, Record);
+ }
+ Stream.EmitRecord(OPENCL_EXTENSION_DECLS, Record);
+}
+
void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
@@ -4628,6 +4665,8 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
WriteIdentifierTable(PP, SemaRef.IdResolver, isModule);
WriteFPPragmaOptions(SemaRef.getFPOptions());
WriteOpenCLExtensions(SemaRef);
+ WriteOpenCLExtensionTypes(SemaRef);
+ WriteOpenCLExtensionDecls(SemaRef);
WriteCUDAPragmas(SemaRef);
WritePragmaDiagnosticMappings(Context.getDiagnostics(), isModule);
OpenPOWER on IntegriCloud