aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp b/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
index b7408f39bdab..d39686ea688e 100644
--- a/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/OpenCLOptions.cpp
@@ -12,8 +12,21 @@
namespace clang {
+// First feature in a pair requires the second one to be supported.
+static const std::pair<StringRef, StringRef> DependentFeaturesList[] = {
+ {"__opencl_c_read_write_images", "__opencl_c_images"},
+ {"__opencl_c_3d_image_writes", "__opencl_c_images"},
+ {"__opencl_c_pipes", "__opencl_c_generic_address_space"},
+ {"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
+ {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
+
+// Extensions and equivalent feature pairs.
+static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
+ {"cl_khr_fp64", "__opencl_c_fp64"},
+ {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
+
bool OpenCLOptions::isKnown(llvm::StringRef Ext) const {
- return OptMap.find(Ext) != OptMap.end();
+ return OptMap.contains(Ext);
}
bool OpenCLOptions::isAvailableOption(llvm::StringRef Ext,
@@ -108,42 +121,32 @@ void OpenCLOptions::disableAll() {
bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies(
const TargetInfo &TI, DiagnosticsEngine &Diags) {
- // Feature pairs. First feature in a pair requires the second one to be
- // supported.
- static const llvm::StringMap<llvm::StringRef> DependentFeaturesMap = {
- {"__opencl_c_read_write_images", "__opencl_c_images"},
- {"__opencl_c_3d_image_writes", "__opencl_c_images"},
- {"__opencl_c_pipes", "__opencl_c_generic_address_space"}};
-
auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
bool IsValid = true;
- for (auto &FeaturePair : DependentFeaturesMap)
- if (TI.hasFeatureEnabled(OpenCLFeaturesMap, FeaturePair.getKey()) &&
- !TI.hasFeatureEnabled(OpenCLFeaturesMap, FeaturePair.getValue())) {
+ for (auto &FeaturePair : DependentFeaturesList) {
+ auto Feature = FeaturePair.first;
+ auto Dep = FeaturePair.second;
+ if (TI.hasFeatureEnabled(OpenCLFeaturesMap, Feature) &&
+ !TI.hasFeatureEnabled(OpenCLFeaturesMap, Dep)) {
IsValid = false;
- Diags.Report(diag::err_opencl_feature_requires)
- << FeaturePair.getKey() << FeaturePair.getValue();
+ Diags.Report(diag::err_opencl_feature_requires) << Feature << Dep;
}
+ }
return IsValid;
}
bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
const TargetInfo &TI, DiagnosticsEngine &Diags) {
- // Extensions and equivalent feature pairs.
- static const llvm::StringMap<llvm::StringRef> FeatureExtensionMap = {
- {"cl_khr_fp64", "__opencl_c_fp64"},
- {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
-
auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
bool IsValid = true;
for (auto &ExtAndFeat : FeatureExtensionMap)
- if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) !=
- TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) {
+ if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.first) !=
+ TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.second)) {
IsValid = false;
Diags.Report(diag::err_opencl_extension_and_feature_differs)
- << ExtAndFeat.getKey() << ExtAndFeat.getValue();
+ << ExtAndFeat.first << ExtAndFeat.second;
}
return IsValid;
}