forked from OSchip/llvm-project
Serialization/deserialization support for floating point #pragma
options, enabled OpenCL extensions and default FP_CONTRACT setting. llvm-svn: 125589
This commit is contained in:
parent
e87167b7d8
commit
5df20e02af
|
@ -356,7 +356,13 @@ namespace clang {
|
||||||
HEADER_SEARCH_TABLE = 40,
|
HEADER_SEARCH_TABLE = 40,
|
||||||
|
|
||||||
/// \brief The directory that the PCH was originally created in.
|
/// \brief The directory that the PCH was originally created in.
|
||||||
ORIGINAL_PCH_DIR = 41
|
ORIGINAL_PCH_DIR = 41,
|
||||||
|
|
||||||
|
/// \brief Record code for floating point #pragma options.
|
||||||
|
FP_PRAGMA_OPTIONS = 42,
|
||||||
|
|
||||||
|
/// \brief Record code for enabled OpenCL extensions.
|
||||||
|
OPENCL_EXTENSIONS = 43
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Record types used within a source manager block.
|
/// \brief Record types used within a source manager block.
|
||||||
|
|
|
@ -600,6 +600,12 @@ private:
|
||||||
/// directly.
|
/// directly.
|
||||||
llvm::SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
|
llvm::SmallVector<uint64_t, 2> CUDASpecialDeclRefs;
|
||||||
|
|
||||||
|
/// \brief The floating point pragma option settings.
|
||||||
|
llvm::SmallVector<uint64_t, 1> FPPragmaOptions;
|
||||||
|
|
||||||
|
/// \brief The OpenCL extension settings.
|
||||||
|
llvm::SmallVector<uint64_t, 1> OpenCLExtensions;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \brief Diagnostic IDs and their mappings that the user changed.
|
/// \brief Diagnostic IDs and their mappings that the user changed.
|
||||||
|
|
|
@ -42,10 +42,12 @@ class ASTSerializationListener;
|
||||||
class NestedNameSpecifier;
|
class NestedNameSpecifier;
|
||||||
class CXXBaseSpecifier;
|
class CXXBaseSpecifier;
|
||||||
class CXXCtorInitializer;
|
class CXXCtorInitializer;
|
||||||
|
class FPOptions;
|
||||||
class HeaderSearch;
|
class HeaderSearch;
|
||||||
class LabelStmt;
|
class LabelStmt;
|
||||||
class MacroDefinition;
|
class MacroDefinition;
|
||||||
class MemorizeStatCalls;
|
class MemorizeStatCalls;
|
||||||
|
class OpenCLOptions;
|
||||||
class ASTReader;
|
class ASTReader;
|
||||||
class PreprocessedEntity;
|
class PreprocessedEntity;
|
||||||
class PreprocessingRecord;
|
class PreprocessingRecord;
|
||||||
|
@ -331,6 +333,8 @@ private:
|
||||||
void WriteDeclUpdatesBlocks();
|
void WriteDeclUpdatesBlocks();
|
||||||
void WriteDeclReplacementsBlock();
|
void WriteDeclReplacementsBlock();
|
||||||
void WriteDeclContextVisibleUpdate(const DeclContext *DC);
|
void WriteDeclContextVisibleUpdate(const DeclContext *DC);
|
||||||
|
void WriteFPPragmaOptions(const FPOptions &Opts);
|
||||||
|
void WriteOpenCLExtensions(Sema &SemaRef);
|
||||||
|
|
||||||
unsigned ParmVarDeclAbbrev;
|
unsigned ParmVarDeclAbbrev;
|
||||||
unsigned DeclContextLexicalAbbrev;
|
unsigned DeclContextLexicalAbbrev;
|
||||||
|
|
|
@ -142,6 +142,7 @@ PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts) {
|
||||||
PARSE_LANGOPT_BENIGN(CatchUndefined);
|
PARSE_LANGOPT_BENIGN(CatchUndefined);
|
||||||
PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_pch_elide_constructors);
|
PARSE_LANGOPT_IMPORTANT(ElideConstructors, diag::warn_pch_elide_constructors);
|
||||||
PARSE_LANGOPT_BENIGN(SpellChecking);
|
PARSE_LANGOPT_BENIGN(SpellChecking);
|
||||||
|
PARSE_LANGOPT_BENIGN(DefaultFPContract);
|
||||||
#undef PARSE_LANGOPT_IMPORTANT
|
#undef PARSE_LANGOPT_IMPORTANT
|
||||||
#undef PARSE_LANGOPT_BENIGN
|
#undef PARSE_LANGOPT_BENIGN
|
||||||
|
|
||||||
|
@ -2304,6 +2305,16 @@ ASTReader::ReadASTBlock(PerFileData &F) {
|
||||||
PP->getHeaderSearchInfo().SetExternalSource(this);
|
PP->getHeaderSearchInfo().SetExternalSource(this);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case FP_PRAGMA_OPTIONS:
|
||||||
|
// Later tables overwrite earlier ones.
|
||||||
|
FPPragmaOptions.swap(Record);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPENCL_EXTENSIONS:
|
||||||
|
// Later tables overwrite earlier ones.
|
||||||
|
OpenCLExtensions.swap(Record);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
First = false;
|
First = false;
|
||||||
}
|
}
|
||||||
|
@ -2818,6 +2829,7 @@ bool ASTReader::ParseLanguageOptions(
|
||||||
PARSE_LANGOPT(OpenCL);
|
PARSE_LANGOPT(OpenCL);
|
||||||
PARSE_LANGOPT(CUDA);
|
PARSE_LANGOPT(CUDA);
|
||||||
PARSE_LANGOPT(CatchUndefined);
|
PARSE_LANGOPT(CatchUndefined);
|
||||||
|
PARSE_LANGOPT(DefaultFPContract);
|
||||||
// FIXME: Missing ElideConstructors?!
|
// FIXME: Missing ElideConstructors?!
|
||||||
#undef PARSE_LANGOPT
|
#undef PARSE_LANGOPT
|
||||||
|
|
||||||
|
@ -4106,6 +4118,19 @@ void ASTReader::InitializeSema(Sema &S) {
|
||||||
SemaObj->VTablesUsed[Class] = DefinitionRequired;
|
SemaObj->VTablesUsed[Class] = DefinitionRequired;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!FPPragmaOptions.empty()) {
|
||||||
|
assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS");
|
||||||
|
SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!OpenCLExtensions.empty()) {
|
||||||
|
unsigned I = 0;
|
||||||
|
#define OPENCLEXT(nm) SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++];
|
||||||
|
#include "clang/Basic/OpenCLExtensions.def"
|
||||||
|
|
||||||
|
assert(OpenCLExtensions.size() == I && "Wrong number of OPENCL_EXTENSIONS");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifierInfo* ASTReader::get(const char *NameStart, const char *NameEnd) {
|
IdentifierInfo* ASTReader::get(const char *NameStart, const char *NameEnd) {
|
||||||
|
|
|
@ -740,7 +740,10 @@ void ASTWriter::WriteBlockInfoBlock() {
|
||||||
RECORD(DECL_UPDATES);
|
RECORD(DECL_UPDATES);
|
||||||
RECORD(CXX_BASE_SPECIFIER_OFFSETS);
|
RECORD(CXX_BASE_SPECIFIER_OFFSETS);
|
||||||
RECORD(DIAG_PRAGMA_MAPPINGS);
|
RECORD(DIAG_PRAGMA_MAPPINGS);
|
||||||
|
RECORD(CUDA_SPECIAL_DECL_REFS);
|
||||||
RECORD(HEADER_SEARCH_TABLE);
|
RECORD(HEADER_SEARCH_TABLE);
|
||||||
|
RECORD(FP_PRAGMA_OPTIONS);
|
||||||
|
RECORD(OPENCL_EXTENSIONS);
|
||||||
|
|
||||||
// SourceManager Block.
|
// SourceManager Block.
|
||||||
BLOCK(SOURCE_MANAGER_BLOCK);
|
BLOCK(SOURCE_MANAGER_BLOCK);
|
||||||
|
@ -1056,6 +1059,7 @@ void ASTWriter::WriteLanguageOptions(const LangOptions &LangOpts) {
|
||||||
Record.push_back(LangOpts.OpenCL);
|
Record.push_back(LangOpts.OpenCL);
|
||||||
Record.push_back(LangOpts.CUDA);
|
Record.push_back(LangOpts.CUDA);
|
||||||
Record.push_back(LangOpts.CatchUndefined);
|
Record.push_back(LangOpts.CatchUndefined);
|
||||||
|
Record.push_back(LangOpts.DefaultFPContract);
|
||||||
Record.push_back(LangOpts.ElideConstructors);
|
Record.push_back(LangOpts.ElideConstructors);
|
||||||
Record.push_back(LangOpts.SpellChecking);
|
Record.push_back(LangOpts.SpellChecking);
|
||||||
Stream.EmitRecord(LANGUAGE_OPTIONS, Record);
|
Stream.EmitRecord(LANGUAGE_OPTIONS, Record);
|
||||||
|
@ -2528,6 +2532,25 @@ void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) {
|
||||||
Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable.str());
|
Stream.EmitRecordWithBlob(UpdateVisibleAbbrev, Record, LookupTable.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Write an FP_PRAGMA_OPTIONS block for the given FPOptions.
|
||||||
|
void ASTWriter::WriteFPPragmaOptions(const FPOptions &Opts) {
|
||||||
|
RecordData Record;
|
||||||
|
Record.push_back(Opts.fp_contract);
|
||||||
|
Stream.EmitRecord(FP_PRAGMA_OPTIONS, Record);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Write an OPENCL_EXTENSIONS block for the given OpenCLOptions.
|
||||||
|
void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
|
||||||
|
if (!SemaRef.Context.getLangOptions().OpenCL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const OpenCLOptions &Opts = SemaRef.getOpenCLOptions();
|
||||||
|
RecordData Record;
|
||||||
|
#define OPENCLEXT(nm) Record.push_back(Opts.nm);
|
||||||
|
#include "clang/Basic/OpenCLExtensions.def"
|
||||||
|
Stream.EmitRecord(OPENCL_EXTENSIONS, Record);
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// General Serialization Routines
|
// General Serialization Routines
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -2758,6 +2781,8 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||||
WriteSelectors(SemaRef);
|
WriteSelectors(SemaRef);
|
||||||
WriteReferencedSelectorsPool(SemaRef);
|
WriteReferencedSelectorsPool(SemaRef);
|
||||||
WriteIdentifierTable(PP);
|
WriteIdentifierTable(PP);
|
||||||
|
WriteFPPragmaOptions(SemaRef.getFPOptions());
|
||||||
|
WriteOpenCLExtensions(SemaRef);
|
||||||
|
|
||||||
WriteTypeDeclOffsets();
|
WriteTypeDeclOffsets();
|
||||||
WritePragmaDiagnosticMappings(Context.getDiagnostics());
|
WritePragmaDiagnosticMappings(Context.getDiagnostics());
|
||||||
|
@ -2997,6 +3022,9 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
|
||||||
WriteSelectors(SemaRef);
|
WriteSelectors(SemaRef);
|
||||||
WriteReferencedSelectorsPool(SemaRef);
|
WriteReferencedSelectorsPool(SemaRef);
|
||||||
WriteIdentifierTable(PP);
|
WriteIdentifierTable(PP);
|
||||||
|
WriteFPPragmaOptions(SemaRef.getFPOptions());
|
||||||
|
WriteOpenCLExtensions(SemaRef);
|
||||||
|
|
||||||
WriteTypeDeclOffsets();
|
WriteTypeDeclOffsets();
|
||||||
// FIXME: For chained PCH only write the new mappings (we currently
|
// FIXME: For chained PCH only write the new mappings (we currently
|
||||||
// write all of them again).
|
// write all of them again).
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// RUN: %clang_cc1 -emit-pch -o %t %s
|
||||||
|
// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s
|
||||||
|
|
||||||
|
#ifndef HEADER
|
||||||
|
#define HEADER
|
||||||
|
// Header.
|
||||||
|
|
||||||
|
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||||
|
|
||||||
|
#else
|
||||||
|
// Using the header.
|
||||||
|
|
||||||
|
void test(void) {
|
||||||
|
double d;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue