diff options
author | Anton Zabaznov <anton.zabaznov@intel.com> | 2021-12-13 18:43:37 +0300 |
---|---|---|
committer | Anton Zabaznov <anton.zabaznov@intel.com> | 2022-01-27 14:25:59 +0300 |
commit | a5de66c4c50b5dec085ffbcd2afefd47f3f18d7f (patch) | |
tree | 0e62627e3c005179835a1759d69f6621a894d59b /clang/lib/Basic/OpenCLOptions.cpp | |
parent | 0d5b35934e010d4207b0b111e2e2905ba36fa77b (diff) | |
download | llvm-a5de66c4c50b5dec085ffbcd2afefd47f3f18d7f.zip llvm-a5de66c4c50b5dec085ffbcd2afefd47f3f18d7f.tar.gz llvm-a5de66c4c50b5dec085ffbcd2afefd47f3f18d7f.tar.bz2 |
[OpenCL] Add support of __opencl_c_device_enqueue feature macro.
This feature requires support of __opencl_c_generic_address_space and
__opencl_c_program_scope_global_variables so diagnostics for that is provided as well.
Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D115640
Diffstat (limited to 'clang/lib/Basic/OpenCLOptions.cpp')
-rw-r--r-- | clang/lib/Basic/OpenCLOptions.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/clang/lib/Basic/OpenCLOptions.cpp b/clang/lib/Basic/OpenCLOptions.cpp index b7408f3..7e89b3f 100644 --- a/clang/lib/Basic/OpenCLOptions.cpp +++ b/clang/lib/Basic/OpenCLOptions.cpp @@ -12,6 +12,17 @@ namespace clang { +const OpenCLOptions::FeatureDepList OpenCLOptions::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"}}; + +const llvm::StringMap<llvm::StringRef> OpenCLOptions::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(); } @@ -108,33 +119,23 @@ 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; |