summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorYaxun Liu <Yaxun.Liu@amd.com>2016-05-13 15:44:37 +0000
committerYaxun Liu <Yaxun.Liu@amd.com>2016-05-13 15:44:37 +0000
commit1ae52775b1ad7cad31ddfbd2cd2a60a61afb888c (patch)
treef787a72c7b1ac3caab61293ebcb385c5e6c75af1 /include
parent7948f6bcd9d329f8fc95625c6a5407c174e1c8e6 (diff)
[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. Differential Revision: http://reviews.llvm.org/D19484 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td4
-rw-r--r--include/clang/Basic/LangOptions.h12
-rw-r--r--include/clang/Basic/OpenCLExtensions.def76
-rw-r--r--include/clang/Basic/OpenCLOptions.h68
-rw-r--r--include/clang/Basic/TargetInfo.h13
-rw-r--r--include/clang/Basic/TargetOptions.h4
6 files changed, 148 insertions, 29 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index c3eea00e1b..f54e3f3eaa 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -926,6 +926,10 @@ def warn_pragma_expected_enable_disable : Warning<
"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<
diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h
index a069a8f8b8..4da7a56cb3 100644
--- a/include/clang/Basic/LangOptions.h
+++ b/include/clang/Basic/LangOptions.h
@@ -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.
diff --git a/include/clang/Basic/OpenCLExtensions.def b/include/clang/Basic/OpenCLExtensions.def
index 91fd9195b1..70c45bba30 100644
--- a/include/clang/Basic/OpenCLExtensions.def
+++ b/include/clang/Basic/OpenCLExtensions.def
@@ -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)
-
-// OpenCL 2.0
-OPENCLEXT(cl_khr_gl_msaa_sharing)
+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_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
diff --git a/include/clang/Basic/OpenCLOptions.h b/include/clang/Basic/OpenCLOptions.h
new file mode 100644
index 0000000000..4aaa3d74cc
--- /dev/null
+++ b/include/clang/Basic/OpenCLOptions.h
@@ -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
diff --git a/include/clang/Basic/TargetInfo.h b/include/clang/Basic/TargetInfo.h
index cf76daee71..950e8b9a4a 100644
--- a/include/clang/Basic/TargetInfo.h
+++ b/include/clang/Basic/TargetInfo.h
@@ -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;
diff --git a/include/clang/Basic/TargetOptions.h b/include/clang/Basic/TargetOptions.h
index 81fb7b2117..fde294c922 100644
--- a/include/clang/Basic/TargetOptions.h
+++ b/include/clang/Basic/TargetOptions.h
@@ -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