Hi Sam,

Fair enough. However, if I read your quote correctly, then there is absolutely 
no need to define a cl_khr_icd, pragma, as ICD in no way affects the language. 
Why do you define one anyway?

The following also hasn’t been cleared up yet:

<quote>
* If I understand the patch correctly, it allows me to enable extensions for 
targets that do not support it. There does not seem a check against the 
initially enabled extensions, just a check for what is or isn't supported in a 
particular version of OpenCL. This means I can now, e.g., enable sharing with 
Direct3D 11 for the nvptx target even though this target does not support this 
functionality.
</quote>

Could you please clarify?

Thanks,

 Jeroen

> On 31 May 2016, at 21:29, Liu, Yaxun (Sam) <yaxun....@amd.com> wrote:
> 
> Hi Jeroen,
> 
> OpenCL spec v1.1 s9.1 says
> 
> Every extension which affects the OpenCL language semantics, syntax or adds 
> built-in functions
> to the language must create a preprocessor #define that matches the extension 
> name string.
> This #define would be available in the language if and only if the extension 
> is supported on a
> given implementation.
> 
> The spec does not say pragma enabling/disabling an extension will 
> define/undefined the macro.
> 
> Also before this commit, Clang did not define/undefine the macro based on 
> pragma either.
> 
> You could define/undefined your own macro to indicate an extension is 
> enabled/disabled then use it to condition your code.
> 
> Thanks.
> 
> Sam
> 
> -----Original Message-----
> From: Jeroen Ketema [mailto:j.ket...@imperial.ac.uk] 
> Sent: Monday, May 30, 2016 10:08 AM
> To: Anastasia Stulova <anastasia.stul...@arm.com>
> Cc: Liu, Yaxun (Sam) <yaxun....@amd.com>; Clang Commits 
> <cfe-commits@lists.llvm.org>; nd <n...@arm.com>
> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
> info.
> 
> 
> Hi Anastasia,
> 
> My apologies for my slow reply. My main issue was that the defaults have 
> changed, which is somewhat annoying. However, digging deeper into this I'm 
> noticing two serious problems:
> 
> * When I do:
> 
> #pragma OPENCL EXTENSION cl_khr_fp16 : disable
> 
> the cl_khr_fp16 macro stays defined in code I compile down to the SPIR 
> target, which means I cannot do conditional compilation based on which 
> extensions are enabled/disabled. This means I now need to start pulling 
> additional manual tricks to do conditional compilation of half precision code.
> 
> [Sam] Before this change, clang did not define/undefine cl_khr_fp16 based on 
> pragma. How could your code work?
> 
> * If I understand the patch correctly, it allows me to enable extensions for 
> targets that do not support it. There does not seem a check against the 
> initially enabled extensions, just a check for what is or isn't supported in 
> a particular version of OpenCL. This means I can now, e.g., enable sharing 
> with Direct3D 11 for the nvptx target even though this target does not 
> support this functionality.
> 
> On top of the above, I do not understand why this patch introduces code for 
> extensions like ICD, which is an OpenCL API concept and not a OpenCL C 
> concept.
> [Sam] The spec requires 
> 
> Jeroen
> 
>> On 20 May 2016, at 21:01, Anastasia Stulova <anastasia.stul...@arm.com> 
>> wrote:
>> 
>> Thanks Sam!
>> 
>> @Jeroen, could you give us more details about your problem.
>> 
>> Anastasia
>> 
>> -----Original Message-----
>> From: Liu, Yaxun (Sam) [mailto:yaxun....@amd.com]
>> Sent: 20 May 2016 20:52
>> To: Anastasia Stulova; Jeroen Ketema
>> Cc: Clang Commits; nd
>> Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target 
>> info.
>> 
>> I think this feature can be implemented by keeping a record of enabled 
>> OpenCL extensions by user's program.
>> 
>> For optional core feature cl_khr_fp64, we just need to detect if double type 
>> is used by user's program.
>> 
>> Sam
>> 
>> -----Original Message-----
>> From: Liu, Yaxun (Sam)
>> Sent: Friday, May 20, 2016 3:45 PM
>> To: 'Anastasia Stulova' <anastasia.stul...@arm.com>; Jeroen Ketema 
>> <j.ket...@imperial.ac.uk>
>> Cc: Clang Commits <cfe-commits@lists.llvm.org>; nd <n...@arm.com>
>> Subject: RE: r269670 - [OpenCL] Add supported OpenCL extensions to target 
>> info.
>> 
>> Currently Clang does not emit opencl.used.extensions metadata, so the issue 
>> mentioned does not exist.
>> 
>> Also extensions supported by a target and extensions used by an OpenCL 
>> program is different concept.
>> 
>> I'd say Clang currently miss a feature to detect used extensions and emit 
>> the metadata.
>> 
>> Sam
>> 
>> -----Original Message-----
>> From: Anastasia Stulova [mailto:anastasia.stul...@arm.com]
>> Sent: Friday, May 20, 2016 3:23 PM
>> To: Liu, Yaxun (Sam) <yaxun....@amd.com>; Jeroen Ketema 
>> <j.ket...@imperial.ac.uk>
>> Cc: Clang Commits <cfe-commits@lists.llvm.org>; nd <n...@arm.com>
>> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
>> info.
>> 
>> Hi Sam,
>> 
>> Has this been addressed?
>> 
>> @Jeroen, as far as I am aware adding supported extensions is completely new 
>> to Clang and shouldn't be braking any existing functionality that are 
>> related to that. Could you elaborate on the problem. Would creating new 
>> Clang target help? Otherwise, do you have any other proposal for the 
>> solution?
>> 
>> Thanks,
>> Anastasia
>> 
>> 
>> ________________________________________
>> From: cfe-commits <cfe-commits-boun...@lists.llvm.org> on behalf of 
>> Jeroen Ketema via cfe-commits <cfe-commits@lists.llvm.org>
>> Sent: 17 May 2016 12:49
>> To: Yaxun Liu via cfe-commits
>> Subject: Re: r269670 - [OpenCL] Add supported OpenCL extensions to target 
>> info.
>> 
>> Hi,
>> 
>> The below commit enables all OpenCL extensions for the SPIR target by 
>> default. This incorrect, as SPIR allows you to specify which extensions are 
>> enabled/disabled its metadata. This means that any SPIR generated by Clang 
>> may now be rejected by specific OpenCL platforms, because they might not 
>> support all extensions.
>> 
>> If possible I would like to see this commit reverted until that problem has 
>> been addressed.
>> 
>> Regards,
>> 
>> Jeroen
>> 
>>> On 16 May 2016, at 18:06, Yaxun Liu via cfe-commits <cfe-commits at 
>>> lists.llvm.org> wrote:
>>> 
>>> Author: yaxunl
>>> Date: Mon May 16 12:06:34 2016
>>> New Revision: 269670
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=269670&view=rev
>>> Log:
>>> [OpenCL] Add supported OpenCL extensions to target info.
>>> 
>>> Add supported OpenCL extensions to target info. It serves as default values 
>>> to save the users of the burden setting each supported extensions and 
>>> optional core features in command line.
>>> 
>>> Re-commit after fixing build error due to missing override attribute.
>>> 
>>> Differential Revision: http://reviews.llvm.org/D19484
>>> 
>>> Added:
>>> cfe/trunk/include/clang/Basic/OpenCLOptions.h
>>> cfe/trunk/test/SemaOpenCL/extensions.cl
>>> Removed:
>>> cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>>> cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>>> cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>>> cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
>>> Modified:
>>> cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>>> cfe/trunk/include/clang/Basic/LangOptions.h
>>> cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>>> cfe/trunk/include/clang/Basic/TargetInfo.h
>>> cfe/trunk/include/clang/Basic/TargetOptions.h
>>> cfe/trunk/lib/Basic/Targets.cpp
>>> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>>> cfe/trunk/lib/Parse/ParsePragma.cpp
>>> cfe/trunk/lib/Sema/Sema.cpp
>>> cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>>> cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>>> cfe/trunk/test/CodeGenOpenCL/half.cl
>>> cfe/trunk/test/Lexer/opencl-half-literal.cl
>>> cfe/trunk/test/Misc/languageOptsOpenCL.cl
>>> cfe/trunk/test/PCH/opencl-extensions.cl
>>> cfe/trunk/test/Parser/opencl-astype.cl
>>> cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>>> cfe/trunk/test/Parser/opencl-pragma.cl
>>> cfe/trunk/test/Parser/opencl-storage-class.cl
>>> cfe/trunk/test/SemaOpenCL/half.cl
>>> cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>>> cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Dia
>>> g nosticParseKinds.td?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
>>> +++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Mon May 16
>>> +++ 12:06:34 2016
>>> @@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable
>>> "expected 'enable' or 'disable' - ignoring">, 
>>> InGroup<IgnoredPragmas>; def warn_pragma_unknown_extension : Warning< 
>>> "unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>;
>>> +def warn_pragma_unsupported_extension : Warning<
>>> +  "unsupported OpenCL extension %0 - ignoring">, 
>>> +InGroup<IgnoredPragmas>; def warn_pragma_extension_is_core : 
>>> +Warning<
>>> +  "OpenCL extension %0 is core feature or supported optional core 
>>> +feature - ignoring">, InGroup<IgnoredPragmas>;
>>> 
>>> // OpenCL errors.
>>> def err_opencl_taking_function_address_parser : Error<
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Lan
>>> g Options.h?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
>>> +++ cfe/trunk/include/clang/Basic/LangOptions.h Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -160,18 +160,6 @@ public:
>>>  fp_contract(LangOpts.DefaultFPContract) {} };
>>> 
>>> -/// \brief OpenCL volatile options
>>> -class OpenCLOptions {
>>> -public:
>>> -#define OPENCLEXT(nm)  unsigned nm : 1; -#include 
>>> "clang/Basic/OpenCLExtensions.def"
>>> -
>>> -  OpenCLOptions() {
>>> -#define OPENCLEXT(nm)   nm = 0;
>>> -#include "clang/Basic/OpenCLExtensions.def"
>>> -  }
>>> -};
>>> -
>>> /// \brief Describes the kind of translation unit being processed.
>>> enum TranslationUnitKind {
>>> /// \brief The translation unit is a complete translation unit.
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Ope
>>> n CLExtensions.def?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original)
>>> +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Mon May 16
>>> +++ 12:06:34 2016
>>> @@ -11,25 +11,67 @@
>>> //
>>> //===----------------------------------------------------------------
>>> -
>>> -----===//
>>> 
>>> +// Macro OPENCLEXT or OPENCLEXT_INTERNAL can be defined to enumerate 
>>> +the // OpenCL extensions listed in this file.
>>> +//
>>> +// If the extensions are to be enumerated without the supported 
>>> +OpenCL version, // define OPENCLEXT(ext) where ext is the name of the 
>>> extension.
>>> +//
>>> +// If the extensions are to be enumerated with supported OpenCL 
>>> +version, // define OPENCLEXT_INTERNAL(ext, avail, core) where
>>> +//   ext - name of the extension or optional core feature.
>>> +//   avail - minimum OpenCL version supporting it.
>>> +//   core - minimum OpenCL version when the extension becomes optional core
>>> +//          feature or core feature. ~0U indicates not a core feature or an
>>> +//          optional core feature.
>>> +
>>> +#ifndef OPENCLEXT_INTERNAL
>>> +#ifndef OPENCLEXT
>>> +#pragma error "macro OPENCLEXT or OPENCLEXT_INTERNAL is required"
>>> +#else
>>> +#define OPENCLEXT_INTERNAL(ext, ...) OPENCLEXT(ext) #endif // 
>>> +OPENCLEXT #endif // OPENCLEXT_INTERNAL
>>> +
>>> +// OpenCL 1.0.
>>> +OPENCLEXT_INTERNAL(cl_khr_3d_image_writes, 100, 120) 
>>> +OPENCLEXT_INTERNAL(cl_khr_byte_addressable_store, 100, 110) 
>>> +OPENCLEXT_INTERNAL(cl_khr_fp16, 100, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_fp64, 100, 120) 
>>> +OPENCLEXT_INTERNAL(cl_khr_global_int32_base_atomics, 100, 110) 
>>> +OPENCLEXT_INTERNAL(cl_khr_global_int32_extended_atomics, 100, 110) 
>>> +OPENCLEXT_INTERNAL(cl_khr_gl_sharing, 100, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_local_int32_base_atomics, 100, 110) 
>>> +OPENCLEXT_INTERNAL(cl_khr_local_int32_extended_atomics, 100, 110)
>>> +
>>> // OpenCL 1.1.
>>> -OPENCLEXT(cl_khr_fp64)
>>> -OPENCLEXT(cl_khr_int64_base_atomics)
>>> -OPENCLEXT(cl_khr_int64_extended_atomics)
>>> -OPENCLEXT(cl_khr_fp16)
>>> -OPENCLEXT(cl_khr_gl_sharing)
>>> -OPENCLEXT(cl_khr_gl_event)
>>> -OPENCLEXT(cl_khr_d3d10_sharing)
>>> -OPENCLEXT(cl_khr_global_int32_base_atomics)
>>> -OPENCLEXT(cl_khr_global_int32_extended_atomics)
>>> -OPENCLEXT(cl_khr_local_int32_base_atomics)
>>> -OPENCLEXT(cl_khr_local_int32_extended_atomics)
>>> -OPENCLEXT(cl_khr_byte_addressable_store)
>>> -OPENCLEXT(cl_khr_3d_image_writes)
>>> +OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_int64_base_atomics, 110, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_int64_extended_atomics, 110, ~0U)
>>> +
>>> +// OpenCL 1.2.
>>> +OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_depth_images, 120, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_dx9_media_sharing, 120, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_gl_depth_images, 120, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
>>> 
>>> -// OpenCL 2.0
>>> -OPENCLEXT(cl_khr_gl_msaa_sharing)
>>> +// OpenCL 2.0.
>>> +OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_gl_msaa_sharing, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U) 
>>> +OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
>>> 
>>> // Clang Extensions.
>>> -OPENCLEXT(cl_clang_storage_class_specifiers)
>>> +OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)
>>> +
>>> +#undef OPENCLEXT_INTERNAL
>>> 
>>> +#ifdef OPENCLEXT
>>> #undef OPENCLEXT
>>> +#endif
>>> 
>>> Added: cfe/trunk/include/clang/Basic/OpenCLOptions.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Ope
>>> n
>>> CLOptions.h?rev=269670&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/OpenCLOptions.h (added)
>>> +++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -0,0 +1,68 @@
>>> +//===--- OpenCLOptions.h ----------------------------------------*-
>>> +C++ -*-===// //
>>> +//                     The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open 
>>> +Source // License. See LICENSE.TXT for details.
>>> +//
>>> +//===---------------------------------------------------------------
>>> +-
>>> +------===//
>>> +///
>>> +/// \file
>>> +/// \brief Defines the clang::OpenCLOptions class.
>>> +///
>>> +//===---------------------------------------------------------------
>>> +-
>>> +------===//
>>> +
>>> +#ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H #define 
>>> +LLVM_CLANG_BASIC_OPENCLOPTIONS_H
>>> +
>>> +#include <string>
>>> +#include <vector>
>>> +
>>> +namespace clang {
>>> +
>>> +/// \brief OpenCL supported extensions and optional core features 
>>> +class OpenCLOptions {
>>> +public:
>>> +#define OPENCLEXT(nm) unsigned nm : 1; #include 
>>> +"clang/Basic/OpenCLExtensions.def"
>>> +
>>> +  OpenCLOptions() {
>>> +#define OPENCLEXT(nm)   nm = 0;
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +  }
>>> +
>>> +  // Enable all options.
>>> +  void setAll() {
>>> +#define OPENCLEXT(nm)   nm = 1;
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +  }
>>> +
>>> +  // Is supported with OpenCL version \p OCLVer.
>>> +#define OPENCLEXT_INTERNAL(Ext, Avail, ...) \
>>> +  bool is_##Ext##_supported(unsigned OCLVer) const { \
>>> +    return Ext && OCLVer >= Avail; \
>>> +  }
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +
>>> +
>>> +  // Is supported OpenCL extension with OpenCL version \p OCLVer.
>>> +  // For supported optional core feature, return false.
>>> +#define OPENCLEXT_INTERNAL(Ext, Avail, Core) \
>>> +  bool is_##Ext##_supported_extension(unsigned CLVer) const { \
>>> +    return is_##Ext##_supported(CLVer) && (Core == ~0U || CLVer < 
>>> +Core); \
>>> +  }
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +
>>> +  // Is supported OpenCL core features with OpenCL version \p OCLVer.
>>> +  // For supported extension, return false.
>>> +#define OPENCLEXT_INTERNAL(Ext, Avail, Core) \
>>> +  bool is_##Ext##_supported_core(unsigned CLVer) const { \
>>> +    return is_##Ext##_supported(CLVer) && Core != ~0U && CLVer >= 
>>> +Core; \
>>> +  }
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +
>>> +};
>>> +
>>> +}  // end namespace clang
>>> +
>>> +#endif
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Tar
>>> g etInfo.h?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
>>> +++ cfe/trunk/include/clang/Basic/TargetInfo.h Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -969,6 +969,19 @@ public:
>>> /// \brief Whether target allows to overalign ABI-specified prefered 
>>> alignment  virtual bool allowsLargerPreferedTypeAlignment() const { 
>>> return true; }
>>> 
>>> +  /// \brief Set supported OpenCL extensions and optional core features.
>>> +  virtual void setSupportedOpenCLOpts() {}
>>> +
>>> +  /// \brief Get supported OpenCL extensions and optional core features.
>>> +  OpenCLOptions &getSupportedOpenCLOpts() {
>>> +    return getTargetOpts().SupportedOpenCLOptions;
>>> +  }
>>> +
>>> +  /// \brief Get const supported OpenCL extensions and optional core 
>>> features.
>>> +  const OpenCLOptions &getSupportedOpenCLOpts() const {
>>> +      return getTargetOpts().SupportedOpenCLOptions;
>>> +  }
>>> +
>>> protected:
>>> virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
>>>  return PointerWidth;
>>> 
>>> Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Tar
>>> g etOptions.h?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
>>> +++ cfe/trunk/include/clang/Basic/TargetOptions.h Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -17,6 +17,7 @@
>>> 
>>> #include <string>
>>> #include <vector>
>>> +#include "clang/Basic/OpenCLOptions.h"
>>> 
>>> namespace clang {
>>> 
>>> @@ -54,6 +55,9 @@ public:
>>> std::vector<std::string> Features;
>>> 
>>> std::vector<std::string> Reciprocals;
>>> +
>>> +  /// Supported OpenCL extensions and optional core features.
>>> +  OpenCLOptions SupportedOpenCLOptions;
>>> };
>>> 
>>> }  // end namespace clang
>>> 
>>> Modified: cfe/trunk/lib/Basic/Targets.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?r
>>> e v=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/lib/Basic/Targets.cpp (original)
>>> +++ cfe/trunk/lib/Basic/Targets.cpp Mon May 16 12:06:34 2016
>>> @@ -1999,17 +1999,6 @@ public:
>>>    Builder.defineMacro("__HAS_FMAF__");
>>>  if (hasLDEXPF)
>>>    Builder.defineMacro("__HAS_LDEXPF__");
>>> -    if (hasFP64 && Opts.OpenCL)
>>> -      Builder.defineMacro("cl_khr_fp64");
>>> -    if (Opts.OpenCL) {
>>> -      if (GPU >= GK_NORTHERN_ISLANDS) {
>>> -        Builder.defineMacro("cl_khr_byte_addressable_store");
>>> -        Builder.defineMacro("cl_khr_global_int32_base_atomics");
>>> -        Builder.defineMacro("cl_khr_global_int32_extended_atomics");
>>> -        Builder.defineMacro("cl_khr_local_int32_base_atomics");
>>> -        Builder.defineMacro("cl_khr_local_int32_extended_atomics");
>>> -      }
>>> -    }
>>> }
>>> 
>>> BuiltinVaListKind getBuiltinVaListKind() const override { @@ -2097,6
>>> +2086,31 @@ public:
>>> 
>>>  return true;
>>> }
>>> +
>>> +   void setSupportedOpenCLOpts() override {
>>> +     auto &Opts = getSupportedOpenCLOpts();
>>> +     Opts.cl_clang_storage_class_specifiers = 1;
>>> +     Opts.cl_khr_gl_sharing = 1;
>>> +     Opts.cl_khr_gl_event = 1;
>>> +     Opts.cl_khr_d3d10_sharing = 1;
>>> +     Opts.cl_khr_subgroups = 1;
>>> +
>>> +     if (hasFP64)
>>> +       Opts.cl_khr_fp64 = 1;
>>> +     if (GPU >= GK_NORTHERN_ISLANDS) {
>>> +       Opts.cl_khr_byte_addressable_store = 1;
>>> +       Opts.cl_khr_global_int32_base_atomics = 1;
>>> +       Opts.cl_khr_global_int32_extended_atomics = 1;
>>> +       Opts.cl_khr_local_int32_base_atomics = 1;
>>> +       Opts.cl_khr_local_int32_extended_atomics = 1;
>>> +     }
>>> +     if (GPU >= GK_SOUTHERN_ISLANDS)
>>> +       Opts.cl_khr_fp16 = 1;
>>> +       Opts.cl_khr_int64_base_atomics = 1;
>>> +       Opts.cl_khr_int64_extended_atomics = 1;
>>> +       Opts.cl_khr_3d_image_writes = 1;
>>> +       Opts.cl_khr_gl_msaa_sharing = 1;  }
>>> };
>>> 
>>> const Builtin::Info AMDGPUTargetInfo::BuiltinInfo[] = { @@ -2716,6
>>> +2730,10 @@ public:
>>> bool hasSjLjLowering() const override {
>>>  return true;
>>> }
>>> +
>>> +  void setSupportedOpenCLOpts() override {
>>> +    getSupportedOpenCLOpts().setAll();
>>> +  }
>>> };
>>> 
>>> bool X86TargetInfo::setFPMath(StringRef Name) { @@ -7858,6 +7876,12 
>>> @@
>>> public:
>>> CallingConv getDefaultCallingConv(CallingConvMethodType MT) const override {
>>>  return CC_SpirFunction;
>>> }
>>> +
>>> +  void setSupportedOpenCLOpts() override {
>>> +    // Assume all OpenCL extensions and optional core features are 
>>> supported
>>> +    // for SPIR since it is a generic target.
>>> +    getSupportedOpenCLOpts().setAll();
>>> +  }
>>> };
>>> 
>>> class SPIR32TargetInfo : public SPIRTargetInfo { @@ -8458,5 +8482,7 
>>> @@ TargetInfo::CreateTargetInfo(Diagnostics
>>> if (!Target->handleTargetFeatures(Opts->Features, Diags))
>>>  return nullptr;
>>> 
>>> +  Target->setSupportedOpenCLOpts();
>>> +
>>> return Target.release();
>>> }
>>> 
>>> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPrepro
>>> c essor.cpp?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
>>> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -938,6 +938,15 @@ static void InitializePredefinedMacros(c
>>>  Builder.defineMacro("__CUDA_ARCH__");
>>> }
>>> 
>>> +  // OpenCL definitions.
>>> +  if (LangOpts.OpenCL) {
>>> +#define OPENCLEXT(Ext) \
>>> +    if (TI.getSupportedOpenCLOpts().is_##Ext##_supported( \
>>> +        LangOpts.OpenCLVersion)) \
>>> +      Builder.defineMacro(#Ext);
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +  }
>>> +
>>> // Get other target #defines.
>>> TI.getTargetDefines(LangOpts, Builder); }
>>> 
>>> Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.c
>>> p p?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
>>> +++ cfe/trunk/lib/Parse/ParsePragma.cpp Mon May 16 12:06:34 2016
>>> @@ -468,14 +468,24 @@ void Parser::HandlePragmaOpenCLExtension
>>> ConsumeToken(); // The annotation token.
>>> 
>>> OpenCLOptions &f = Actions.getOpenCLOptions();
>>> +  auto CLVer = getLangOpts().OpenCLVersion;  auto &Supp = 
>>> + getTargetInfo().getSupportedOpenCLOpts();
>>> // OpenCL 1.1 9.1: "The all variant sets the behavior for all 
>>> extensions,  // overriding all previously issued extension 
>>> directives, but only if the  // behavior is set to disable."
>>> if (state == 0 && ename->isStr("all")) {
>>> -#define OPENCLEXT(nm)   f.nm = 0;
>>> +#define OPENCLEXT(nm) \
>>> +    if (Supp.is_##nm##_supported_extension(CLVer)) \
>>> +      f.nm = 0;
>>> #include "clang/Basic/OpenCLExtensions.def"
>>> }
>>> -#define OPENCLEXT(nm) else if (ename->isStr(#nm)) { f.nm = state; }
>>> +#define OPENCLEXT(nm) else if (ename->isStr(#nm)) \
>>> +   if (Supp.is_##nm##_supported_extension(CLVer)) \
>>> +     f.nm = state; \
>>> +   else if (Supp.is_##nm##_supported_core(CLVer)) \
>>> +     PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << ename; \
>>> +   else \
>>> +     PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << 
>>> +ename;
>>> #include "clang/Basic/OpenCLExtensions.def"
>>> else {
>>>  PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << ename;
>>> 
>>> Modified: cfe/trunk/lib/Sema/Sema.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=2
>>> 6
>>> 9670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/lib/Sema/Sema.cpp (original)
>>> +++ cfe/trunk/lib/Sema/Sema.cpp Mon May 16 12:06:34 2016
>>> @@ -207,8 +207,14 @@ void Sema::Initialize() {
>>>  addImplicitTypedef("size_t", Context.getSizeType());  }
>>> 
>>> -  // Initialize predefined OpenCL types.
>>> +  // Initialize predefined OpenCL types and supported optional core 
>>> features.
>>> if (getLangOpts().OpenCL) {
>>> +#define OPENCLEXT(Ext) \
>>> +     if 
>>> (Context.getTargetInfo().getSupportedOpenCLOpts().is_##Ext##_supported_core(
>>>  \
>>> +         getLangOpts().OpenCLVersion)) \
>>> +       getOpenCLOptions().Ext = 1;
>>> +#include "clang/Basic/OpenCLExtensions.def"
>>> +
>>>  addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
>>>  addImplicitTypedef("event_t", Context.OCLEventTy);
>>>  if (getLangOpts().OpenCLVersion >= 200) {
>>> 
>>> Modified: cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/buil
>>> t ins-r600.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl (original)
>>> +++ cfe/trunk/test/CodeGenOpenCL/builtins-r600.cl Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -1,5 +1,5 @@
>>> // REQUIRES: amdgpu-registered-target -// RUN: %clang_cc1 -triple 
>>> r600-unknown-unknown -S -emit-llvm -o - %s
>>> | FileCheck %s
>>> +// RUN: %clang_cc1 -triple r600-unknown-unknown -target-cpu rv670 -S 
>>> +-emit-llvm -o - %s | FileCheck %s
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> 
>>> 
>>> Modified: cfe/trunk/test/CodeGenOpenCL/fpmath.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/fpma
>>> t h.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/CodeGenOpenCL/fpmath.cl (original)
>>> +++ cfe/trunk/test/CodeGenOpenCL/fpmath.cl Mon May 16 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
>>> +// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | 
>>> +FileCheck %s
>>> 
>>> typedef __attribute__(( ext_vector_type(4) )) float float4;
>>> 
>>> 
>>> Modified: cfe/trunk/test/CodeGenOpenCL/half.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/half.
>>> cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/CodeGenOpenCL/half.cl (original)
>>> +++ cfe/trunk/test/CodeGenOpenCL/half.cl Mon May 16 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
>>> +// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | 
>>> +FileCheck %s
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp16 : enable
>>> 
>>> 
>>> Modified: cfe/trunk/test/Lexer/opencl-half-literal.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/opencl-half-
>>> l iteral.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Lexer/opencl-half-literal.cl (original)
>>> +++ cfe/trunk/test/Lexer/opencl-half-literal.cl Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -fsyntax-only -verify
>>> +// RUN: %clang_cc1 %s -fsyntax-only -verify -triple 
>>> +spir-unknown-unknown
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp16 : enable
>>> 
>>> 
>>> Modified: cfe/trunk/test/Misc/languageOptsOpenCL.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/languageOptsO
>>> p enCL.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Misc/languageOptsOpenCL.cl (original)
>>> +++ cfe/trunk/test/Misc/languageOptsOpenCL.cl Mon May 16 12:06:34 
>>> +++ 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 -x cl %s -verify
>>> +// RUN: %clang_cc1 -x cl %s -verify -triple spir-unknown-unknown
>>> // expected-no-diagnostics
>>> 
>>> // Test the forced language options for OpenCL are set correctly.
>>> 
>>> Modified: cfe/trunk/test/PCH/opencl-extensions.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/opencl-extensi
>>> o ns.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/PCH/opencl-extensions.cl (original)
>>> +++ cfe/trunk/test/PCH/opencl-extensions.cl Mon May 16 12:06:34 2016
>>> @@ -1,5 +1,5 @@
>>> -// RUN: %clang_cc1 -emit-pch -o %t %s -// RUN: %clang_cc1 
>>> -include-pch %t -fsyntax-only %s
>>> +// RUN: %clang_cc1 -emit-pch -o %t %s -triple spir-unknown-unknown 
>>> +//
>>> +RUN: %clang_cc1 -include-pch %t -fsyntax-only %s  -triple 
>>> +spir-unknown-unknown
>>> 
>>> #ifndef HEADER
>>> #define HEADER
>>> 
>>> Modified: cfe/trunk/test/Parser/opencl-astype.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-asty
>>> p e.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Parser/opencl-astype.cl (original)
>>> +++ cfe/trunk/test/Parser/opencl-astype.cl Mon May 16 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 -fsyntax-only -verify %s
>>> +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple 
>>> +spir-unknown-unknown
>>> #pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> 
>>> void test_astype() {
>>> 
>>> Modified: cfe/trunk/test/Parser/opencl-atomics-cl20.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-atom
>>> i cs-cl20.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Parser/opencl-atomics-cl20.cl (original)
>>> +++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -1,11 +1,14 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -// RUN: 
>>> %clang_cc1 %s -verify  -fsyntax-only -cl-std=CL2.0 -DCL20 -// RUN: 
>>> %clang_cc1 %s -verify  -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
>>> +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
>>> +-fsyntax-only // RUN: %clang_cc1 %s -triple spir-unknown-unknown 
>>> +-verify -fsyntax-only -cl-std=CL2.0 -DCL20 // RUN: %clang_cc1 %s 
>>> +-triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0
>>> +-DCL20 -DEXT
>>> 
>>> #ifdef EXT
>>> #pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable #pragma 
>>> OPENCL EXTENSION cl_khr_int64_extended_atomics:enable
>>> #pragma OPENCL EXTENSION cl_khr_fp64:enable
>>> +#if __OPENCL_C_VERSION__ >= CL_VERSION_1_2 // expected-warning at 
>>> +-2{{OpenCL extension 'cl_khr_fp64' is core feature or supported 
>>> +optional core feature - ignoring}} #endif
>>> #endif
>>> 
>>> void atomic_types_test() {
>>> @@ -44,15 +47,14 @@ void atomic_types_test() { // expected-error at
>>> -28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') 
>>> requires cl_khr_int64_extended_atomics extension to be enabled}} // 
>>> expected-error at -27 {{use of type 'atomic_double' (aka
>>> '_Atomic(double)') requires cl_khr_int64_base_atomics extension to be 
>>> enabled}} // expected-error at -28 {{use of type 'atomic_double' (aka
>>> '_Atomic(double)') requires cl_khr_int64_extended_atomics extension 
>>> to be enabled}} -// expected-error at -29 {{use of type 'atomic_double'
>>> (aka '_Atomic(double)') requires cl_khr_fp64 extension to be 
>>> enabled}} -// expected-error-re at -28 {{use of type 
>>> 'atomic_intptr_t' (aka
>>> '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be 
>>> enabled}} -// expected-error-re at -29 {{use of type 'atomic_intptr_t'
>>> (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics 
>>> extension to be enabled}} -// expected-error-re at -29 {{use of type 
>>> 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires 
>>> cl_khr_int64_base_atomics extension to be enabled}} -// 
>>> expected-error-re at -30 {{use of type 'atomic_uintptr_t' (aka
>>> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> to be enabled}} -// expected-error-re at -30 {{use of type 
>>> 'atomic_size_t' (aka '_Atomic({{.+}})') requires 
>>> cl_khr_int64_base_atomics extension to be enabled}} -// 
>>> expected-error-re at -31 {{use of type 'atomic_size_t' (aka
>>> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> to be enabled}} -// expected-error-re at -31 {{use of type 
>>> 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires 
>>> cl_khr_int64_base_atomics extension to be enabled}} -// 
>>> expected-error-re at -32 {{use of type 'atomic_ptrdiff_t' (aka
>>> '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> to be enabled}}
>>> +// expected-error-re at -27 {{use of type 'atomic_intptr_t' (aka
>>> +'_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to 
>>> +be enabled}} // expected-error-re at -28 {{use of type 'atomic_intptr_t'
>>> +(aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics 
>>> +extension to be enabled}} // expected-error-re at -28 {{use of type 
>>> +'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires 
>>> +cl_khr_int64_base_atomics extension to be enabled}} // 
>>> +expected-error-re at -29 {{use of type 'atomic_uintptr_t' (aka
>>> +'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> +to be enabled}} // expected-error-re at -29 {{use of type 
>>> +'atomic_size_t' (aka '_Atomic({{.+}})') requires 
>>> +cl_khr_int64_base_atomics extension to be enabled}} // 
>>> +expected-error-re at -30 {{use of type 'atomic_size_t' (aka
>>> +'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> +to be enabled}} // expected-error-re at -30 {{use of type 
>>> +'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires 
>>> +cl_khr_int64_base_atomics extension to be enabled}} // 
>>> +expected-error-re at -31 {{use of type 'atomic_ptrdiff_t' (aka
>>> +'_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension 
>>> +to be enabled}}
>>> #endif
>>> 
>>> #ifdef CL20
>>> 
>>> Modified: cfe/trunk/test/Parser/opencl-pragma.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-prag
>>> m a.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Parser/opencl-pragma.cl (original)
>>> +++ cfe/trunk/test/Parser/opencl-pragma.cl Mon May 16 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -Wno-empty-translation-unit 
>>> -fsyntax-only
>>> +// RUN: %clang_cc1 %s -verify -pedantic -Wno-empty-translation-unit 
>>> +-fsyntax-only -triple spir-unknown-unknown
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp16 : enable
>>> 
>>> 
>>> Modified: cfe/trunk/test/Parser/opencl-storage-class.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-stor
>>> a ge-class.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/Parser/opencl-storage-class.cl (original)
>>> +++ cfe/trunk/test/Parser/opencl-storage-class.cl Mon May 16 12:06:34
>>> +++ 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -verify -fsyntax-only
>>> +// RUN: %clang_cc1 %s -verify -fsyntax-only -triple 
>>> +spir-unknown-unknown
>>> 
>>> void test_storage_class_specs()
>>> {
>>> 
>>> Removed: cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extensi
>>> o
>>> n-fp64-cl1.1.cl?rev=269669&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/extension-fp64-cl1.1.cl (removed)
>>> @@ -1,19 +0,0 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
>>> -
>>> -void f1(double da) { // expected-error {{type 'double' requires
>>> cl_khr_fp64 extension}}
>>> -  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> extension}}
>>> -  (void) 1.0; // expected-warning {{double precision constant 
>>> requires cl_khr_fp64}} -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> -
>>> -void f2(void) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : disable
>>> -
>>> -void f3(void) {
>>> -  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> extension}} -}
>>> 
>>> Removed: cfe/trunk/test/SemaOpenCL/extension-fp64.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extensi
>>> o
>>> n-fp64.cl?rev=269669&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/extension-fp64.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/extension-fp64.cl (removed)
>>> @@ -1,19 +0,0 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
>>> -
>>> -void f1(double da) { // expected-error {{type 'double' requires
>>> cl_khr_fp64 extension}}
>>> -  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> extension}}
>>> -  (void) 1.0; // expected-warning {{double precision constant 
>>> requires cl_khr_fp64}} -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> -
>>> -void f2(void) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : disable
>>> -
>>> -void f3(void) {
>>> -  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> extension}} -}
>>> 
>>> Added: cfe/trunk/test/SemaOpenCL/extensions.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extensi
>>> o
>>> ns.cl?rev=269670&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/extensions.cl (added)
>>> +++ cfe/trunk/test/SemaOpenCL/extensions.cl Mon May 16 12:06:34 2016
>>> @@ -0,0 +1,36 @@
>>> +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic 
>>> +-fsyntax-only // RUN: %clang_cc1 %s -triple spir-unknown-unknown 
>>> +-verify -pedantic -fsyntax-only -cl-std=CL1.1
>>> +
>>> +// Test with a target not supporting fp64.
>>> +// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 
>>> +-verify -pedantic -fsyntax-only -DNOFP64
>>> +
>>> +void f1(double da) { // expected-error {{type 'double' requires
>>> +cl_khr_fp64 extension}}
>>> +  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> +extension}}
>>> +  (void) 1.0; // expected-warning {{double precision constant 
>>> +requires cl_khr_fp64}} }
>>> +
>>> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable #ifdef NOFP64 // 
>>> +expected-warning at -2{{unsupported OpenCL extension 'cl_khr_fp64' - 
>>> +ignoring}} #endif
>>> +
>>> +void f2(void) {
>>> +  double d;
>>> +#ifdef NOFP64
>>> +// expected-error at -2{{use of type 'double' requires cl_khr_fp64 
>>> +extension to be enabled}} #endif
>>> +
>>> +  (void) 1.0;
>>> +#ifdef NOFP64
>>> +// expected-warning at -2{{double precision constant requires 
>>> +cl_khr_fp64, casting to single precision}} #endif }
>>> +
>>> +#pragma OPENCL EXTENSION cl_khr_fp64 : disable #ifdef NOFP64 // 
>>> +expected-warning at -2{{unsupported OpenCL extension 'cl_khr_fp64' - 
>>> +ignoring}} #endif
>>> +
>>> +void f3(void) {
>>> +  double d; // expected-error {{type 'double' requires cl_khr_fp64 
>>> +extension}} }
>>> 
>>> Modified: cfe/trunk/test/SemaOpenCL/half.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/half.cl?
>>> rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/half.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/half.cl Mon May 16 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only 
>>> -Wno-unused-value
>>> +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only 
>>> +-Wno-unused-value -triple spir-unknown-unknown
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp16 : disable constant float f = 
>>> 1.0h; // expected-error{{half precision constant requires 
>>> cl_khr_fp16}}
>>> 
>>> Modified: cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid
>>> - kernel-parameters.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl Mon May 16
>>> +++ 12:06:34 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 -fsyntax-only -verify %s
>>> +// RUN: %clang_cc1 -fsyntax-only -verify %s -triple 
>>> +spir-unknown-unknown
>>> 
>>> #pragma OPENCL EXTENSION cl_khr_fp16 : enable
>>> 
>>> 
>>> Modified: cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid
>>> - logical-ops-1.2.cl?rev=269670&r1=269669&r2=269670&view=diff
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/invalid-logical-ops-1.2.cl Mon May 16
>>> +++ 12:06:34 2016
>>> @@ -1,6 +1,7 @@
>>> // RUN: %clang_cc1 %s -verify -cl-std=CL1.2 -triple 
>>> x86_64-unknown-linux-gnu
>>> 
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> +#pragma OPENCL EXTENSION cl_khr_fp64 : enable // 
>>> +expected-warning{{OpenCL extension 'cl_khr_fp64' is core feature or 
>>> +supported optional core feature - ignoring}}
>>> +
>>> typedef __attribute__((ext_vector_type(4))) float float4; typedef
>>> __attribute__((ext_vector_type(4))) double double4; typedef
>>> __attribute__((ext_vector_type(4))) int int4;
>>> 
>>> Removed: cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/optiona
>>> l -core-fp64-cl1.2.cl?rev=269669&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl1.2.cl (removed)
>>> @@ -1,20 +0,0 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 
>>> -// expected-no-diagnostics
>>> -
>>> -void f1(double da) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> -
>>> -void f2(void) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : disable
>>> -
>>> -void f3(void) {
>>> -  double d;
>>> -}
>>> 
>>> Removed: cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/optiona
>>> l -core-fp64-cl2.0.cl?rev=269669&view=auto
>>> =====================================================================
>>> =
>>> ========
>>> --- cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl (original)
>>> +++ cfe/trunk/test/SemaOpenCL/optional-core-fp64-cl2.0.cl (removed)
>>> @@ -1,20 +0,0 @@
>>> -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 
>>> -// expected-no-diagnostics
>>> -
>>> -void f1(double da) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : enable
>>> -
>>> -void f2(void) {
>>> -  double d;
>>> -  (void) 1.0;
>>> -}
>>> -
>>> -#pragma OPENCL EXTENSION cl_khr_fp64 : disable
>>> -
>>> -void f3(void) {
>>> -  double d;
>>> -}
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> 
> 

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to