@@ -20,6 +20,7 @@ Copyright (c) Intel Corporation (2009-2017).
2020#include " options.h"
2121
2222#include " clang/Driver/Options.h"
23+ #include " llvm/ADT/StringExtras.h"
2324#include " llvm/Option/Arg.h"
2425#include " llvm/Option/ArgList.h"
2526#include " llvm/Support/ManagedStatic.h"
@@ -237,10 +238,30 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
237238
238239 for (auto it = effectiveArgs.begin (), end = effectiveArgs.end (); it != end;
239240 ++it) {
240- if (it->compare (" -Dcl_khr_fp64" ) == 0 )
241+ if (it->compare (" -Dcl_khr_fp64" ) == 0 || it-> compare ( " -D cl_khr_fp64=1 " ) == 0 )
241242 fp64Enabled = true ;
243+ else if (it->compare (" -U cl_khr_fp64" ) == 0 )
244+ fp64Enabled = false ;
245+ // Find last position that enables or disables cl_khr_fp64
246+ else if (it->find (" cl_khr_fp64" ) != std::string::npos) {
247+ auto NegFp64 = it->rfind (" -cl_khr_fp64" );
248+ auto PosFp64 = it->rfind (" +cl_khr_fp64" );
249+ if (NegFp64 != std::string::npos && PosFp64 != std::string::npos)
250+ fp64Enabled = PosFp64 > NegFp64;
251+ else if (NegFp64 != std::string::npos)
252+ fp64Enabled = false ;
253+ else
254+ fp64Enabled = true ;
255+ }
242256 }
243257
258+ #ifdef PCH_EXTENSION
259+ std::map<std::string, bool > extMap;
260+ llvm::SmallVector<llvm::StringRef> extVec;
261+ llvm::SplitString (PCH_EXTENSION, extVec, " ," );
262+ for (auto ext : extVec)
263+ extMap.insert ({ext.str (), true });
264+ #else
244265 std::map<std::string, bool > extMap{
245266 {" cl_khr_3d_image_writes" , true },
246267 {" cl_khr_depth_images" , true },
@@ -262,6 +283,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
262283 {" cl_intel_planar_yuv" , true },
263284 {" cl_intel_subgroups" , true },
264285 {" cl_intel_subgroups_short" , true }};
286+ #endif
265287
266288 auto parseClExt = [&](const std::string &clExtStr) {
267289 llvm::StringRef clExtRef (clExtStr);
0 commit comments