diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h --- a/clang/include/clang/Basic/Builtins.h +++ b/clang/include/clang/Basic/Builtins.h @@ -33,7 +33,7 @@ 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. + OCLC2P_LANG = 0x20, // builtin for OpenCL C 2.0+ versions. OCLC1X_LANG = 0x40, // builtin for OpenCL C 1.x only. OMP_LANG = 0x80, // builtin requires OpenMP. CUDA_LANG = 0x100, // builtin requires CUDA. @@ -41,7 +41,7 @@ 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_OCLC_LANGUAGES = OCLC1X_LANG | OCLC2P_LANG // builtin for OCLC languages. }; namespace Builtin { @@ -240,6 +240,26 @@ bool builtinIsSupported(const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts); + /// Check if OpenCL builtin supported. Required as feature set + /// affects language capabilities. + bool OclBuiltinIsSupported(const Builtin::Info &BuiltinInfo, + const LangOptions &LangOpts) const; + + /// Check if builtin uses OpenCL pipes. + bool usesOpenCLPipes(const Builtin::Info &BuiltinInfo) const { + return strchr(BuiltinInfo.Attributes, 'P') != nullptr; + } + + /// Check if builtin required by OpenCL device enqueue feature. + bool usesOpenCLDeviceEnqueue(const Builtin::Info &BuiltinInfo) const { + return strchr(BuiltinInfo.Attributes, 'Q') != nullptr; + } + + // Check if builtin uses OpenCL generic address space. + bool usesOpenCLGenericAddressSpace(const Builtin::Info &BuiltinInfo) const { + return strchr(BuiltinInfo.Attributes, 'G') != nullptr; + } + /// Helper function for isPrintfLike and isScanfLike. bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg, const char *Fmt) const; diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def --- a/clang/include/clang/Basic/Builtins.def +++ b/clang/include/clang/Basic/Builtins.def @@ -85,6 +85,9 @@ // h -> this function requires a specific header or an explicit declaration. // i -> this is a runtime library implemented function without the // '__builtin_' prefix. It will be implemented in compiler-rt or libgcc. +// G -> this function uses generic address space (OpenCL). +// P -> this function uses pipes (OpenCL). +// Q -> this function uses device enqueue (OpenCL). // p:N: -> this is a printf-like function whose Nth argument is the format // string. // P:N: -> similar to the p:N: attribute, but the function is like vprintf @@ -1625,44 +1628,44 @@ // 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.", "tnP", OCLC2P_LANG) +LANGBUILTIN(write_pipe, "i.", "tnP", OCLC2P_LANG) -LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG) -LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG) +LANGBUILTIN(reserve_read_pipe, "i.", "tnP", OCLC2P_LANG) +LANGBUILTIN(reserve_write_pipe, "i.", "tnP", OCLC2P_LANG) -LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG) -LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG) +LANGBUILTIN(commit_write_pipe, "v.", "tnP", OCLC2P_LANG) +LANGBUILTIN(commit_read_pipe, "v.", "tnP", OCLC2P_LANG) -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.", "tnP", OCLC2P_LANG) +LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tnP", OCLC2P_LANG) -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.", "tnP", OCLC2P_LANG) +LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tnP", OCLC2P_LANG) -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.", "tnP", OCLC2P_LANG) +LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tnP", OCLC2P_LANG) -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.", "tnP", OCLC2P_LANG) +LANGBUILTIN(work_group_commit_write_pipe, "v.", "tnP", OCLC2P_LANG) -LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG) -LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG) +LANGBUILTIN(get_pipe_num_packets, "Ui.", "tnP", OCLC2P_LANG) +LANGBUILTIN(get_pipe_max_packets, "Ui.", "tnP", OCLC2P_LANG) // 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.", "tnQ", OCLC2P_LANG) +LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tnQ", OCLC2P_LANG) +LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tnQ", OCLC2P_LANG) +LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tnQ", OCLC2P_LANG) +LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tnQ", OCLC2P_LANG) // 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*", "tnG", OCLC2P_LANG) +LANGBUILTIN(to_local, "v*v*", "tnG", OCLC2P_LANG) +LANGBUILTIN(to_private, "v*v*", "tnG", OCLC2P_LANG) // OpenCL half load/store builtin LANGBUILTIN(__builtin_store_half, "vdh*", "n", ALL_OCLC_LANGUAGES) diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp --- a/clang/lib/Basic/Builtins.cpp +++ b/clang/lib/Basic/Builtins.cpp @@ -71,9 +71,10 @@ 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 OclC2PUnsupported = + (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES) == OCLC2P_LANG && + ((LangOpts.getOpenCLCompatibleVersion() < 200) || + !OclBuiltinIsSupported(BuiltinInfo, LangOpts)); bool OclCUnsupported = !LangOpts.OpenCL && (BuiltinInfo.Langs & ALL_OCLC_LANGUAGES); bool OpenMPUnsupported = !LangOpts.OpenMP && BuiltinInfo.Langs == OMP_LANG; @@ -82,7 +83,7 @@ !LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG; return !BuiltinsUnsupported && !CorBuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported && !OclC1Unsupported && - !OclC2Unsupported && !OpenMPUnsupported && !GnuModeUnsupported && + !OclC2PUnsupported && !OpenMPUnsupported && !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported && !CPlusPlusUnsupported && !CUDAUnsupported; } @@ -191,3 +192,13 @@ (!hasReferenceArgsOrResult(ID) && !hasCustomTypechecking(ID)); } + +bool Builtin::Context::OclBuiltinIsSupported( + const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts) const { + if ((usesOpenCLGenericAddressSpace(BuiltinInfo) && + !LangOpts.OpenCLGenericAddressSpace) || + (usesOpenCLPipes(BuiltinInfo) && !LangOpts.OpenCLPipes) || + (usesOpenCLDeviceEnqueue(BuiltinInfo) && !LangOpts.Blocks)) + return false; + return true; +} diff --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl --- 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 --- 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 @@ // 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 @@ 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 --- 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 --- 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 different 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 --- 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 @@ 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@-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@-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@-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 --- 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 @@ 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@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}} // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else @@ -20,28 +22,28 @@ 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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-error@-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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-error@-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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-error@-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@-2{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}} #else // expected-error@-4{{assigning '__global int *' to '__local int *__private' changes address space of pointer}} @@ -49,7 +51,7 @@ #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@-2{{implicit declaration of function 'to_private' is invalid in OpenCL}} // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}} #else @@ -58,17 +60,17 @@ #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@-2{{implicit declaration of function 'to_local' is invalid in OpenCL}} // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__local int *__private' from 'int'}} // expected-note@-4{{did you mean 'to_global'}} - // expected-note@13{{'to_global' declared here}} + // expected-note@15{{'to_global' declared here}} #else // expected-warning@-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@-2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}} #else // expected-error@-4{{assigning '__global int *' to '__private int *__private' changes address space of pointer}} @@ -76,7 +78,7 @@ #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@-2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}} #else // expected-warning@-4{{passing non-generic address space pointer to to_private may cause dynamic conversion affecting performance}} @@ -84,7 +86,7 @@ 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@-2{{incompatible integer to pointer conversion assigning to '__private int *__private' from 'int'}} #else // expected-error@-4{{assigning '__local int *' to '__private int *__private' changes address space of pointer}} @@ -92,14 +94,14 @@ #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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-warning@-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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-error@-4{{assigning '__private int *' to '__global int *__private' changes address space of pointer}} @@ -107,7 +109,7 @@ #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@-2{{incompatible integer to pointer conversion assigning to '__global int *__private' from 'int'}} #else // expected-error@-4{{assigning '__local int *' to '__global int *__private' changes address space of pointer}} @@ -115,7 +117,7 @@ #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@-2{{incompatible integer to pointer conversion initializing '__global char *__private' with an expression of type 'int'}} #else // expected-warning@-4{{incompatible pointer types initializing '__global char *__private' with an expression of type '__global int *'}} @@ -123,7 +125,7 @@ #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@-2{{incompatible integer to pointer conversion assigning to '__global float *__private' from 'int'}} #else // expected-warning@-4{{incompatible pointer types assigning to '__global float *__private' from '__global int *'}}