[llvm-branch-commits] [clang] 95dd9c5 - [OpenCL] Add support of language builtins for OpenCL C 3.0
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 14 14:15:51 PST 2022
Author: Anton Zabaznov
Date: 2022-02-14T14:13:04-08:00
New Revision: 95dd9c5f2a0642260c5351d860757c4b8abe4537
URL: https://github.com/llvm/llvm-project/commit/95dd9c5f2a0642260c5351d860757c4b8abe4537
DIFF: https://github.com/llvm/llvm-project/commit/95dd9c5f2a0642260c5351d860757c4b8abe4537.diff
LOG: [OpenCL] Add support of language builtins for OpenCL C 3.0
OpenCL C 3.0 introduces optionality to some builtins, in particularly
to those which are conditionally supported with pipe, device enqueue
and generic address space features.
The idea is to conditionally support such builtins depending on the language options
being set for a certain feature. This allows users to define functions with names
of those optional builtins in OpenCL (as such names are not reserved).
Reviewed By: Anastasia
Differential Revision: https://reviews.llvm.org/D118605
(cherry picked from commit bee4bd70f76952b2c6296feb46a087b497322376)
Added:
Modified:
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/lib/Basic/Builtins.cpp
clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/to_addr_builtin.cl
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
clang/test/SemaOpenCL/clang-builtin-version.cl
clang/test/SemaOpenCL/to_addr_builtin.cl
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index d2cb14d2fd8cc..a17d2e59f5d8b 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1625,50 +1625,50 @@ LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", COR_LANG)
// OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
// We need the generic prototype, since the packet type could be anything.
-LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(write_pipe, "i.", "tn", OCL_PIPE)
-LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCL_PIPE)
-LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(commit_write_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(commit_read_pipe, "v.", "tn", OCL_PIPE)
-LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCL_PIPE)
-LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCL_PIPE)
-LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCL_PIPE)
-LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCL_PIPE)
-LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG)
+LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCL_PIPE)
+LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCL_PIPE)
// OpenCL v2.0 s6.13.17 - Enqueue kernel functions.
// Custom builtin check allows to perform special check of passed block arguments.
-LANGBUILTIN(enqueue_kernel, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC20_LANG)
+LANGBUILTIN(enqueue_kernel, "i.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCL_DSE)
// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
// FIXME: Pointer parameters of OpenCL builtins should have their address space
// requirement defined.
-LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
-LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
-LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)
+LANGBUILTIN(to_global, "v*v*", "tn", OCL_GAS)
+LANGBUILTIN(to_local, "v*v*", "tn", OCL_GAS)
+LANGBUILTIN(to_private, "v*v*", "tn", OCL_GAS)
// OpenCL half load/store builtin
-LANGBUILTIN(__builtin_store_half, "vdh*", "n", ALL_OCLC_LANGUAGES)
-LANGBUILTIN(__builtin_store_halff, "vfh*", "n", ALL_OCLC_LANGUAGES)
-LANGBUILTIN(__builtin_load_half, "dhC*", "nc", ALL_OCLC_LANGUAGES)
-LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES)
+LANGBUILTIN(__builtin_store_half, "vdh*", "n", ALL_OCL_LANGUAGES)
+LANGBUILTIN(__builtin_store_halff, "vfh*", "n", ALL_OCL_LANGUAGES)
+LANGBUILTIN(__builtin_load_half, "dhC*", "nc", ALL_OCL_LANGUAGES)
+LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCL_LANGUAGES)
// Builtins for os_log/os_trace
BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h
index cdaaee48c32d8..1dabafce54f39 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -28,20 +28,21 @@ class IdentifierTable;
class LangOptions;
enum LanguageID {
- GNU_LANG = 0x1, // builtin requires GNU mode.
- C_LANG = 0x2, // builtin for c only.
- CXX_LANG = 0x4, // builtin for cplusplus only.
- OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
- MS_LANG = 0x10, // builtin requires MS mode.
- OCLC20_LANG = 0x20, // builtin for OpenCL C 2.0 only.
- OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only.
- OMP_LANG = 0x80, // builtin requires OpenMP.
- CUDA_LANG = 0x100, // builtin requires CUDA.
- COR_LANG = 0x200, // builtin requires use of 'fcoroutine-ts' option.
+ GNU_LANG = 0x1, // builtin requires GNU mode.
+ C_LANG = 0x2, // builtin for c only.
+ CXX_LANG = 0x4, // builtin for cplusplus only.
+ OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
+ MS_LANG = 0x10, // builtin requires MS mode.
+ OMP_LANG = 0x20, // builtin requires OpenMP.
+ CUDA_LANG = 0x40, // builtin requires CUDA.
+ COR_LANG = 0x80, // builtin requires use of 'fcoroutine-ts' option.
+ OCL_GAS = 0x100, // builtin requires OpenCL generic address space.
+ OCL_PIPE = 0x200, // builtin requires OpenCL pipe.
+ OCL_DSE = 0x400, // builtin requires OpenCL device side enqueue.
+ ALL_OCL_LANGUAGES = 0x800, // builtin for OCL languages.
ALL_LANGUAGES = C_LANG | CXX_LANG | OBJC_LANG, // builtin for all languages.
ALL_GNU_LANGUAGES = ALL_LANGUAGES | GNU_LANG, // builtin requires GNU mode.
- ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG, // builtin requires MS mode.
- ALL_OCLC_LANGUAGES = OCLC1X_LANG | OCLC20_LANG // builtin for OCLC languages.
+ ALL_MS_LANGUAGES = ALL_LANGUAGES | MS_LANG // builtin requires MS mode.
};
namespace Builtin {
diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp
index 2b0f4071662c0..6d278e9c4a229 100644
--- a/clang/lib/Basic/Builtins.cpp
+++ b/clang/lib/Basic/Builtins.cpp
@@ -69,22 +69,26 @@ bool Builtin::Context::builtinIsSupported(const Builtin::Info &BuiltinInfo,
bool MSModeUnsupported =
!LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG);
bool ObjCUnsupported = !LangOpts.ObjC && BuiltinInfo.Langs == OBJC_LANG;
- bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
- (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES ) == OCLC1X_LANG;
- bool OclC2Unsupported =
- (LangOpts.getOpenCLCompatibleVersion() != 200) &&
- (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC20_LANG;
- bool OclCUnsupported = !LangOpts.OpenCL &&
- (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES);
+ bool OclCUnsupported =
+ !LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCL_LANGUAGES);
+ bool OclGASUnsupported =
+ !LangOpts.OpenCLGenericAddressSpace && (BuiltinInfo.Langs & OCL_GAS);
+ bool OclPipeUnsupported =
+ !LangOpts.OpenCLPipes && (BuiltinInfo.Langs & OCL_PIPE);
+ // Device side enqueue is not supported until OpenCL 2.0. In 2.0 and higher
+ // support is indicated with language option for blocks.
+ bool OclDSEUnsupported =
+ (LangOpts.getOpenCLCompatibleVersion() < 200 || !LangOpts.Blocks) &&
+ (BuiltinInfo.Langs & OCL_DSE);
bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG;
bool CUDAUnsupported = !LangOpts.CUDA && BuiltinInfo.Langs == CUDA_LANG;
bool CPlusPlusUnsupported =
!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG;
return !BuiltinsUnsupported && !CorBuiltinsUnsupported &&
- !MathBuiltinsUnsupported && !OclCUnsupported && !OclC1Unsupported &&
- !OclC2Unsupported && !OpenMPUnsupported && !GnuModeUnsupported &&
- !MSModeUnsupported && !ObjCUnsupported && !CPlusPlusUnsupported &&
- !CUDAUnsupported;
+ !MathBuiltinsUnsupported && !OclCUnsupported && !OclGASUnsupported &&
+ !OclPipeUnsupported && !OclDSEUnsupported && !OpenMPUnsupported &&
+ !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
+ !CPlusPlusUnsupported && !CUDAUnsupported;
}
/// initializeBuiltins - Mark the identifiers for all the builtins with their
diff --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
index fdbc0aaa6e263..01750804884b3 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -1,6 +1,9 @@
// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B32
// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B64
// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL2.0 -ffake-address-space-map -O1 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=CHECK-LIFETIMES
+// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL3.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B32
+// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL3.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B64
+// RUN: %clang_cc1 -disable-noundef-analysis %s -cl-std=CL3.0 -ffake-address-space-map -O1 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=CHECK-LIFETIMES
#pragma OPENCL EXTENSION cl_khr_subgroups : enable
diff --git a/clang/test/CodeGenOpenCL/pipe_types.cl b/clang/test/CodeGenOpenCL/pipe_types.cl
index 57da95fec0d70..9644aff1a6248 100644
--- a/clang/test/CodeGenOpenCL/pipe_types.cl
+++ b/clang/test/CodeGenOpenCL/pipe_types.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -DTEST_STRUCT -o - %s | FileCheck --check-prefixes=CHECK,CHECK-STRUCT %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck --check-prefixes=CHECK,CHECK-STRUCT %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -o - %s | FileCheck --check-prefixes=CHECK %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_pipes,+__opencl_c_generic_address_space -o - %s | FileCheck --check-prefixes=CHECK %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -o - %s | FileCheck --check-prefixes=CHECK %s
@@ -36,8 +36,6 @@ kernel void test6(MyPipe p) {
// CHECK: define{{.*}} spir_kernel void @test6(%opencl.pipe_ro_t* %p)
}
-#ifdef TEST_STRUCT
-// FIXME: not supported for OpenCL C 3.0 as language built-ins not supported yet
struct Person {
const char *Name;
bool isFemale;
@@ -52,4 +50,3 @@ void test_reserved_read_pipe(global struct Person *SDst,
read_pipe (SPipe, SDst);
// CHECK-STRUCT: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8)
}
-#endif // TEST_STRUCT
diff --git a/clang/test/CodeGenOpenCL/to_addr_builtin.cl b/clang/test/CodeGenOpenCL/to_addr_builtin.cl
index b5b197079b74b..03097f60f7931 100644
--- a/clang/test/CodeGenOpenCL/to_addr_builtin.cl
+++ b/clang/test/CodeGenOpenCL/to_addr_builtin.cl
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=clc++ -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=cl2.0 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=cl3.0 -o - %s | FileCheck %s
// CHECK: %[[A:.*]] = type { float, float, float }
typedef struct {
diff --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
index 5cfdfb3cdc5ca..9c375b2603ac1 100644
--- a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify -pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify -pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
typedef struct {int a;} ndrange_t;
// Diagnostic tests for
diff erent overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
diff --git a/clang/test/SemaOpenCL/clang-builtin-version.cl b/clang/test/SemaOpenCL/clang-builtin-version.cl
index 3e270e64c69d1..7111db1784c60 100644
--- a/clang/test/SemaOpenCL/clang-builtin-version.cl
+++ b/clang/test/SemaOpenCL/clang-builtin-version.cl
@@ -1,6 +1,8 @@
// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100 -cl-std=CL1.2
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100 -cl-std=CL3.0 -cl-ext=-__opencl_c_device_enqueue,-__opencl_c_generic_address_space,-__opencl_c_pipes
-// Confirm CL2.0 Clang builtins are not available in earlier versions
+// Confirm CL2.0 Clang builtins are not available in earlier versions and in OpenCL C 3.0 without required features.
kernel void dse_builtins() {
int tmp;
@@ -13,6 +15,11 @@ kernel void dse_builtins() {
size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-error{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in OpenCL}}
return;
});
+#if (__OPENCL_C_VERSION__ >= CL_VERSION_3_0) && !defined(__opencl_c_device_enqueue)
+// expected-error at -10{{support disabled - compile with -fblocks or for OpenCL C 2.0 or OpenCL C 3.0 with __opencl_c_device_enqueue feature}}
+// expected-error at -8{{support disabled - compile with -fblocks or for OpenCL C 2.0 or OpenCL C 3.0 with __opencl_c_device_enqueue feature}}
+// expected-error at -6{{support disabled - compile with -fblocks or for OpenCL C 2.0 or OpenCL C 3.0 with __opencl_c_device_enqueue feature}}
+#endif
}
void pipe_builtins() {
diff --git a/clang/test/SemaOpenCL/to_addr_builtin.cl b/clang/test/SemaOpenCL/to_addr_builtin.cl
index 8f4a20ac7662a..f5df7abc3b4f2 100644
--- a/clang/test/SemaOpenCL/to_addr_builtin.cl
+++ b/clang/test/SemaOpenCL/to_addr_builtin.cl
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -verify -fsyntax-only %s
// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL2.0 %s
+// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL3.0 -cl-ext=-all %s
+// RUN: %clang_cc1 -Wconversion -verify -fsyntax-only -cl-std=CL3.0 %s
void test(void) {
global int *glob;
@@ -11,7 +13,7 @@ void test(void) {
const_int_ty *con_typedef;
glob = to_global(glob, loc);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-error at -2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
// expected-warning at -3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
@@ -20,28 +22,28 @@ void test(void) {
int x;
glob = to_global(x);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-error at -4{{invalid argument x to function: 'to_global', expecting a generic pointer argument}}
#endif
glob = to_global(con);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-error at -4{{invalid argument con to function: 'to_global', expecting a generic pointer argument}}
#endif
glob = to_global(con_typedef);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-error at -4{{invalid argument con_typedef to function: 'to_global', expecting a generic pointer argument}}
#endif
loc = to_global(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}}
#else
// expected-error at -4{{assigning '__global int *' to '__local int *__private' changes address space of pointer}}
@@ -49,7 +51,7 @@ void test(void) {
#endif
loc = to_private(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-error at -2{{implicit declaration of function 'to_private' is invalid in OpenCL}}
// expected-warning at -3{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}}
#else
@@ -58,17 +60,17 @@ void test(void) {
#endif
loc = to_local(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-error at -2{{implicit declaration of function 'to_local' is invalid in OpenCL}}
// expected-warning at -3{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}}
// expected-note at -4{{did you mean 'to_global'}}
- // expected-note at 13{{'to_global' declared here}}
+ // expected-note at 15{{'to_global' declared here}}
#else
// expected-warning at -7{{passing non-generic address space pointer to to_local may cause dynamic conversion affecting performance}}
#endif
priv = to_global(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}}
#else
// expected-error at -4{{assigning '__global int *' to '__private int *__private' changes address space of pointer}}
@@ -76,7 +78,7 @@ void test(void) {
#endif
priv = to_private(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}}
#else
// expected-warning at -4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}}
@@ -84,7 +86,7 @@ void test(void) {
priv = to_local(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}}
#else
// expected-error at -4{{assigning '__local int *' to '__private int *__private' changes address space of pointer}}
@@ -92,14 +94,14 @@ void test(void) {
#endif
glob = to_global(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-warning at -4{{passing non-generic address space pointer to to_global may cause dynamic conversion affecting performance}}
#endif
glob = to_private(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-error at -4{{assigning '__private int *' to '__global int *__private' changes address space of pointer}}
@@ -107,7 +109,7 @@ void test(void) {
#endif
glob = to_local(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}}
#else
// expected-error at -4{{assigning '__local int *' to '__global int *__private' changes address space of pointer}}
@@ -115,7 +117,7 @@ void test(void) {
#endif
global char *glob_c = to_global(loc);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion initializing '__global char *__private' with an expression of type 'int'}}
#else
// expected-warning at -4{{incompatible pointer types initializing '__global char *__private' with an expression of type '__global int *'}}
@@ -123,7 +125,7 @@ void test(void) {
#endif
glob_wrong_ty = to_global(glob);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if (__OPENCL_C_VERSION__ < CL_VERSION_2_0) || (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && !defined(__opencl_c_generic_address_space))
// expected-warning at -2{{incompatible integer to pointer conversion assigning to '__global float *__private' from 'int'}}
#else
// expected-warning at -4{{incompatible pointer types assigning to '__global float *__private' from '__global int *'}}
More information about the llvm-branch-commits
mailing list