// 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", OCLC_LANG)
-LANGBUILTIN(write_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(write_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC_LANG)
-LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC_LANG)
-LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC_LANG)
+LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
-LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
-LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
+LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC_LANG)
-LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC_LANG)
+LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC_LANG)
-LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC_LANG)
+LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC_LANG)
-LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC_LANG)
+LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG)
+LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG)
// OpenCL v2.0 s6.13.9 - Address space qualifier functions.
-LANGBUILTIN(to_global, "v*v*", "tn", OCLC_LANG)
-LANGBUILTIN(to_local, "v*v*", "tn", OCLC_LANG)
-LANGBUILTIN(to_private, "v*v*", "tn", OCLC_LANG)
+LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
+LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
+LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)
#undef BUILTIN
#undef LIBBUILTIN
CXX_LANG = 0x4, // builtin for cplusplus only.
OBJC_LANG = 0x8, // builtin for objective-c and objective-c++
MS_LANG = 0x10, // builtin requires MS mode.
- OCLC_LANG = 0x20, // builtin for OpenCL C only.
+ OCLC20_LANG = 0x20, // builtin for OpenCL C only.
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.
def warn_opencl_attr_deprecated_ignored : Warning <
"%0 attribute is deprecated and ignored in OpenCL version %1">,
InGroup<IgnoredAttributes>;
-def err_opencl_builtin_requires_version : Error<
- "%0 requires OpenCL version %1%select{| or above}2">;
// OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
def err_opencl_builtin_pipe_first_arg : Error<
bool MSModeUnsupported =
!LangOpts.MicrosoftExt && (BuiltinInfo.Langs & MS_LANG);
bool ObjCUnsupported = !LangOpts.ObjC1 && BuiltinInfo.Langs == OBJC_LANG;
- bool OclCUnsupported = !LangOpts.OpenCL && BuiltinInfo.Langs == OCLC_LANG;
+ bool OclCUnsupported = LangOpts.OpenCLVersion != 200 &&
+ BuiltinInfo.Langs == OCLC20_LANG;
return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
!GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported;
}
return RValue::get(
Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), {Arg0, Arg1}));
}
- // OpenCL v2.0 s6.13.16 ,s9.17.3.5 - Built-in pipe commit read and write
+ // OpenCL v2.0 s6.13.16, s9.17.3.5 - Built-in pipe commit read and write
// functions
case Builtin::BIcommit_read_pipe:
case Builtin::BIcommit_write_pipe:
return false;
}
-
+// \brief OpenCL v2.0 s6.13.9 - Address space qualifier functions.
// \brief Performs semantic analysis for the to_global/local/private call.
// \param S Reference to the semantic analyzer.
// \param BuiltinID ID of the builtin function.
// \return True if a semantic error has been found, false otherwise.
static bool SemaOpenCLBuiltinToAddr(Sema &S, unsigned BuiltinID,
CallExpr *Call) {
- // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
- if (S.getLangOpts().OpenCLVersion < 200) {
- S.Diag(Call->getLocStart(), diag::err_opencl_builtin_requires_version)
- << Call->getDirectCallee() << "2.0" << 1 << Call->getSourceRange();
- return true;
- }
-
if (Call->getNumArgs() != 1) {
S.Diag(Call->getLocStart(), diag::err_opencl_builtin_to_addr_arg_num)
<< Call->getDirectCallee() << Call->getSourceRange();
TheCall->setType(Context.VoidPtrTy);
break;
+ // OpenCL v2.0, s6.13.16 - Pipe functions
case Builtin::BIread_pipe:
case Builtin::BIwrite_pipe:
// Since those two functions are declared with var args, we need a semantic
--- /dev/null
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100
+
+// Confirm CL2.0 Clang builtins are not available in earlier versions
+
+kernel void dse_builtins() {
+ int tmp;
+ enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}}
+ return;
+ });
+ unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}}
+ return;
+ });
+ size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}}
+ return;
+ });
+}
+
+void pipe_builtins() {
+ int tmp;
+
+ read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}}
+ write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}}
+
+ reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}}
+ reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}}
+
+ work_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_read_pipe' is invalid in C99}}
+ work_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in C99}}
+
+ sub_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_write_pipe' is invalid in C99}}
+ sub_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_read_pipe' is invalid in C99}}
+
+ commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_read_pipe' is invalid in C99}}
+ commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'commit_write_pipe' is invalid in C99}}
+
+ work_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_read_pipe' is invalid in C99}}
+ work_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_commit_write_pipe' is invalid in C99}}
+
+ sub_group_commit_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_write_pipe' is invalid in C99}}
+ sub_group_commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_commit_read_pipe' is invalid in C99}}
+
+ get_pipe_num_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_num_packets' is invalid in C99}}
+ get_pipe_max_packets(tmp); // expected-warning{{implicit declaration of function 'get_pipe_max_packets' is invalid in C99}}
+}
glob = to_global(glob, loc);
#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in C99}}
+ // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
#else
- // expected-error@-4{{invalid number of arguments to function: 'to_global'}}
+ // expected-error@-5{{invalid number of arguments to function: 'to_global'}}
#endif
int x;
glob = to_global(x);
#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' 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
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' 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
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__global int *' 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
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{incompatible integer to pointer conversion assigning to '__local int *' from 'int'}}
#else
// expected-error@-4{{assigning '__global int *' to '__local int *' changes address space of pointer}}
#endif
global char *glob_c = to_global(loc);
#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
- // expected-error@-2{{'to_global' requires OpenCL version 2.0 or above}}
+ // expected-warning@-2{{incompatible integer to pointer conversion initializing '__global char *' with an expression of type 'int'}}
#else
// expected-warning@-4{{incompatible pointer types initializing '__global char *' with an expression of type '__global int *'}}
#endif