1 //===--- OpenCLOptions.h ----------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// 10 /// \file 11 /// \brief Defines the clang::OpenCLOptions class. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H 16 #define LLVM_CLANG_BASIC_OPENCLOPTIONS_H 17 18 #include <string> 19 #include <vector> 20 21 namespace clang { 22 23 /// \brief OpenCL supported extensions and optional core features 24 class OpenCLOptions { 25 public: 26 #define OPENCLEXT(nm) unsigned nm : 1; 27 #include "clang/Basic/OpenCLExtensions.def" 28 OpenCLOptions()29 OpenCLOptions() { 30 #define OPENCLEXT(nm) nm = 0; 31 #include "clang/Basic/OpenCLExtensions.def" 32 } 33 34 // Enable all options. setAll()35 void setAll() { 36 #define OPENCLEXT(nm) nm = 1; 37 #include "clang/Basic/OpenCLExtensions.def" 38 } 39 40 // Is supported with OpenCL version \p OCLVer. 41 #define OPENCLEXT_INTERNAL(Ext, Avail, ...) \ 42 bool is_##Ext##_supported(unsigned OCLVer) const { \ 43 return Ext && OCLVer >= Avail; \ 44 } 45 #include "clang/Basic/OpenCLExtensions.def" 46 47 48 // Is supported OpenCL extension with OpenCL version \p OCLVer. 49 // For supported optional core feature, return false. 50 #define OPENCLEXT_INTERNAL(Ext, Avail, Core) \ 51 bool is_##Ext##_supported_extension(unsigned CLVer) const { \ 52 return is_##Ext##_supported(CLVer) && (Core == ~0U || CLVer < Core); \ 53 } 54 #include "clang/Basic/OpenCLExtensions.def" 55 56 // Is supported OpenCL core features with OpenCL version \p OCLVer. 57 // For supported extension, return false. 58 #define OPENCLEXT_INTERNAL(Ext, Avail, Core) \ 59 bool is_##Ext##_supported_core(unsigned CLVer) const { \ 60 return is_##Ext##_supported(CLVer) && Core != ~0U && CLVer >= Core; \ 61 } 62 #include "clang/Basic/OpenCLExtensions.def" 63 64 }; 65 66 } // end namespace clang 67 68 #endif 69