[OpenCL] Turn global vector into static array. NFCI.

This commit is contained in:
Benjamin Kramer 2022-03-05 19:16:01 +01:00
parent 28bb040ded
commit 14af99d375
2 changed files with 7 additions and 14 deletions

View File

@ -212,15 +212,6 @@ private:
bool isEnabled(llvm::StringRef Ext) const; bool isEnabled(llvm::StringRef Ext) const;
OpenCLOptionInfoMap OptMap; OpenCLOptionInfoMap OptMap;
// First feature in a pair requires the second one to be supported.
using FeatureDepEntry = std::pair<llvm::StringRef, llvm::StringRef>;
using FeatureDepList = llvm::SmallVector<FeatureDepEntry, 8>;
static const FeatureDepList DependentFeaturesList;
// Extensions and equivalent feature pairs.
static const llvm::StringMap<llvm::StringRef> FeatureExtensionMap;
}; };
} // end namespace clang } // end namespace clang

View File

@ -12,14 +12,16 @@
namespace clang { namespace clang {
const OpenCLOptions::FeatureDepList OpenCLOptions::DependentFeaturesList = { // 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_read_write_images", "__opencl_c_images"},
{"__opencl_c_3d_image_writes", "__opencl_c_images"}, {"__opencl_c_3d_image_writes", "__opencl_c_images"},
{"__opencl_c_pipes", "__opencl_c_generic_address_space"}, {"__opencl_c_pipes", "__opencl_c_generic_address_space"},
{"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"}, {"__opencl_c_device_enqueue", "__opencl_c_generic_address_space"},
{"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}}; {"__opencl_c_device_enqueue", "__opencl_c_program_scope_global_variables"}};
const llvm::StringMap<llvm::StringRef> OpenCLOptions::FeatureExtensionMap = { // Extensions and equivalent feature pairs.
static const std::pair<StringRef, StringRef> FeatureExtensionMap[] = {
{"cl_khr_fp64", "__opencl_c_fp64"}, {"cl_khr_fp64", "__opencl_c_fp64"},
{"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}}; {"cl_khr_3d_image_writes", "__opencl_c_3d_image_writes"}};
@ -140,11 +142,11 @@ bool OpenCLOptions::diagnoseFeatureExtensionDifferences(
bool IsValid = true; bool IsValid = true;
for (auto &ExtAndFeat : FeatureExtensionMap) for (auto &ExtAndFeat : FeatureExtensionMap)
if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getKey()) != if (TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.first) !=
TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.getValue())) { TI.hasFeatureEnabled(OpenCLFeaturesMap, ExtAndFeat.second)) {
IsValid = false; IsValid = false;
Diags.Report(diag::err_opencl_extension_and_feature_differs) Diags.Report(diag::err_opencl_extension_and_feature_differs)
<< ExtAndFeat.getKey() << ExtAndFeat.getValue(); << ExtAndFeat.first << ExtAndFeat.second;
} }
return IsValid; return IsValid;
} }