OpenCLOptions.h revision 303233
1163953Srrs//===--- OpenCLOptions.h ----------------------------------------*- C++ -*-===// 2185694Srrs// 3218269Srrs// The LLVM Compiler Infrastructure 4218269Srrs// 5163953Srrs// This file is distributed under the University of Illinois Open Source 6163953Srrs// License. See LICENSE.TXT for details. 7163953Srrs// 8163953Srrs//===----------------------------------------------------------------------===// 9163953Srrs/// 10163953Srrs/// \file 11163953Srrs/// \brief Defines the clang::OpenCLOptions class. 12163953Srrs/// 13163953Srrs//===----------------------------------------------------------------------===// 14163953Srrs 15163953Srrs#ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H 16163953Srrs#define LLVM_CLANG_BASIC_OPENCLOPTIONS_H 17163953Srrs 18163953Srrs#include <string> 19163953Srrs#include <vector> 20163953Srrs 21163953Srrsnamespace clang { 22163953Srrs 23163953Srrs/// \brief OpenCL supported extensions and optional core features 24163953Srrsclass OpenCLOptions { 25163953Srrspublic: 26163953Srrs#define OPENCLEXT(nm) unsigned nm : 1; 27163953Srrs#include "clang/Basic/OpenCLExtensions.def" 28163953Srrs 29163953Srrs OpenCLOptions() { 30163953Srrs#define OPENCLEXT(nm) nm = 0; 31163953Srrs#include "clang/Basic/OpenCLExtensions.def" 32163953Srrs } 33163953Srrs 34163953Srrs // Enable all options. 35163953Srrs void setAll() { 36163953Srrs#define OPENCLEXT(nm) nm = 1; 37163953Srrs#include "clang/Basic/OpenCLExtensions.def" 38163953Srrs } 39163953Srrs 40167598Srrs // Is supported with OpenCL version \p OCLVer. 41163953Srrs#define OPENCLEXT_INTERNAL(Ext, Avail, ...) \ 42163953Srrs bool is_##Ext##_supported(unsigned OCLVer) const { \ 43163953Srrs return Ext && OCLVer >= Avail; \ 44163953Srrs } 45163953Srrs#include "clang/Basic/OpenCLExtensions.def" 46163953Srrs 47163953Srrs 48163953Srrs // Is supported OpenCL extension with OpenCL version \p OCLVer. 49170091Srrs // For supported optional core feature, return false. 50172091Srrs#define OPENCLEXT_INTERNAL(Ext, Avail, Core) \ 51188067Srrs bool is_##Ext##_supported_extension(unsigned CLVer) const { \ 52179157Srrs return is_##Ext##_supported(CLVer) && (Core == ~0U || CLVer < Core); \ 53218211Srrs } 54163953Srrs#include "clang/Basic/OpenCLExtensions.def" 55163953Srrs 56163953Srrs // Is supported OpenCL core features with OpenCL version \p OCLVer. 57163953Srrs // For supported extension, return false. 58163953Srrs#define OPENCLEXT_INTERNAL(Ext, Avail, Core) \ 59163953Srrs bool is_##Ext##_supported_core(unsigned CLVer) const { \ 60163953Srrs return is_##Ext##_supported(CLVer) && Core != ~0U && CLVer >= Core; \ 61163953Srrs } 62165220Srrs#include "clang/Basic/OpenCLExtensions.def" 63165220Srrs 64165220Srrs}; 65165220Srrs 66165220Srrs} // end namespace clang 67163953Srrs 68163953Srrs#endif 69165220Srrs