clang: lib/Basic/OpenCLOptions.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
12
14
15
17 {"__opencl_c_read_write_images", "__opencl_c_images"},
18 {"__opencl_c_3d_image_writes", "__opencl_c_images"},
19 {"__opencl_c_pipes", "__opencl_c_generic_address_space"},
20 {"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
21 {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
22
23
25 {"cl_khr_fp64", "__opencl_c_fp64"},
26 {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
27
29 return OptMap.contains(Ext);
30}
31
35 return false;
36
37 auto &OptInfo = OptMap.find(Ext)->getValue();
38 if (OptInfo.isCoreIn(LO) || OptInfo.isOptionalCoreIn(LO))
40
41 return isEnabled(Ext);
42}
43
44bool OpenCLOptions::isEnabled(llvm::StringRef Ext) const {
45 auto I = OptMap.find(Ext);
46 return I != OptMap.end() && I->getValue().Enabled;
47}
48
50 auto E = OptMap.find(Ext);
51 return E != OptMap.end() && E->second.WithPragma;
52}
53
56 auto I = OptMap.find(Ext);
57 return I != OptMap.end() && I->getValue().Supported &&
58 I->getValue().isAvailableIn(LO);
59}
60
63 auto I = OptMap.find(Ext);
64 return I != OptMap.end() && I->getValue().Supported &&
65 I->getValue().isCoreIn(LO);
66}
67
70 auto I = OptMap.find(Ext);
71 return I != OptMap.end() && I->getValue().Supported &&
72 I->getValue().isOptionalCoreIn(LO);
73}
74
78}
79
82 auto I = OptMap.find(Ext);
83 return I != OptMap.end() && I->getValue().Supported &&
84 I->getValue().isAvailableIn(LO) &&
86}
87
89 OptMap[Ext].Enabled = V;
90}
91
93 OptMap[Ext].WithPragma = V;
94}
95
97 assert(!Ext.empty() && "Extension is empty.");
98 assert(Ext[0] != '+' && Ext[0] != '-');
99 OptMap[Ext].Supported = V;
100}
101
103#define OPENCL_GENERIC_EXTENSION(Ext, ...) \
104 OptMap.insert_or_assign(#Ext, OpenCLOptionInfo{__VA_ARGS__});
105#include "clang/Basic/OpenCLExtensions.def"
106}
107
110 for (const auto &F : FeaturesMap) {
111 const auto &Name = F.getKey();
112 if (F.getValue() && isKnown(Name) && OptMap[Name].isAvailableIn(Opts))
114 }
115}
116
118 for (auto &Opt : OptMap)
119 Opt.getValue().Enabled = false;
120}
121
125
126 bool IsValid = true;
128 auto Feature = FeaturePair.first;
129 auto Dep = FeaturePair.second;
132 IsValid = false;
133 Diags.Report(diag::err_opencl_feature_requires) << Feature << Dep;
134 }
135 }
136 return IsValid;
137}
138
142
143 bool IsValid = true;
147 IsValid = false;
148 Diags.Report(diag::err_opencl_extension_and_feature_differs)
149 << ExtAndFeat.first << ExtAndFeat.second;
150 }
151 return IsValid;
152}
153
154}
Defines the Diagnostic-related interfaces.
Defines the clang::OpenCLOptions class.
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isAvailableOption(llvm::StringRef Ext, const LangOptions &LO) const
static bool diagnoseUnsupportedFeatureDependencies(const TargetInfo &TI, DiagnosticsEngine &Diags)
bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const
void enable(llvm::StringRef Ext, bool V=true)
bool isWithPragma(llvm::StringRef Ext) const
bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const
static bool diagnoseFeatureExtensionDifferences(const TargetInfo &TI, DiagnosticsEngine &Diags)
bool isSupportedCoreOrOptionalCore(llvm::StringRef Ext, const LangOptions &LO) const
bool isSupportedOptionalCore(llvm::StringRef Ext, const LangOptions &LO) const
void addSupport(const llvm::StringMap< bool > &FeaturesMap, const LangOptions &Opts)
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
void acceptsPragma(llvm::StringRef Ext, bool V=true)
void support(llvm::StringRef Ext, bool V=true)
Enable or disable support for OpenCL extensions.
bool isKnown(llvm::StringRef Ext) const
Exposes information about the current target.
virtual bool hasFeatureEnabled(const llvm::StringMap< bool > &Features, StringRef Name) const
Check if target has a given feature enabled.
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
static const std::pair< StringRef, StringRef > FeatureExtensionMap[]
static const std::pair< StringRef, StringRef > DependentFeaturesList[]