Anastasia updated this revision to Diff 60339.
Anastasia added a comment.
Fixed issue with block typedef.
http://reviews.llvm.org/D20249
Files:
include/clang/AST/Type.h
include/clang/Basic/Builtins.def
include/clang/Basic/Builtins.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/Basic/Builtins.cpp
lib/CodeGen/CGBuiltin.cpp
lib/Headers/opencl-c.h
lib/Sema/SemaChecking.cpp
lib/Sema/SemaInit.cpp
test/CodeGenOpenCL/cl20-device-side-enqueue.cl
test/SemaOpenCL/cl20-device-side-enqueue.cl
test/SemaOpenCL/clang-builtin-version.cl
test/SemaOpenCL/to_addr_builtin.cl
Index: test/SemaOpenCL/to_addr_builtin.cl
===================================================================
--- test/SemaOpenCL/to_addr_builtin.cl
+++ test/SemaOpenCL/to_addr_builtin.cl
@@ -10,43 +10,44 @@
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
Index: test/SemaOpenCL/clang-builtin-version.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/clang-builtin-version.cl
@@ -0,0 +1,44 @@
+// 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}}
+}
Index: test/SemaOpenCL/cl20-device-side-enqueue.cl
===================================================================
--- /dev/null
+++ test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -0,0 +1,148 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -fblocks -verify -pedantic -fsyntax-only
+
+// Diagnostic tests for different overloads of enqueue_kernel from Table 6.13.17.1 of OpenCL 2.0 Spec.
+kernel void enqueue_kernel_tests() {
+ queue_t default_queue;
+ unsigned flags = 0;
+ ndrange_t ndrange;
+ clk_event_t evt;
+ clk_event_t event_wait_list;
+ clk_event_t event_wait_list2[] = {evt, evt};
+ void *vptr;
+
+ // Testing the first overload type
+ enqueue_kernel(default_queue, flags, ndrange, ^(void) {
+ return 0;
+ });
+
+ enqueue_kernel(vptr, flags, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'queue_t' argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, vptr, ndrange, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'kernel_enqueue_flags_t' (i.e. uint) argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, vptr, ^(void) { // expected-error{{illegal call to enqueue_kernel, expected 'ndrange_t' argument type}}
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+
+ // Testing the second overload type
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, ^(void) {
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, vptr, &evt, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
+ {
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, vptr, ^(void) // expected-error{{illegal call to enqueue_kernel, expected 'clk_event_t *' argument type}}
+ {
+ return 0;
+ });
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, vptr); // expected-error{{illegal call to enqueue_kernel, expected block argument}}
+
+ // Testing the third overload type
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024);
+
+ typedef void (^bl_A_t)(local void *);
+
+ const bl_A_t block_A = (bl_A_t) ^ (local void *a) {};
+
+ enqueue_kernel(default_queue, flags, ndrange, block_A, 1024);
+
+ typedef void (^bl_B_t)(local void *, local int *);
+
+ const bl_B_t block_B = (bl_B_t) ^ (local void *a, local int *b) {};
+
+ enqueue_kernel(default_queue, flags, ndrange, block_B, 1024, 1024); // expected-error{{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+
+ enqueue_kernel(default_queue, flags, ndrange, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024);
+
+ float illegal_mem_size = (float)0.5f;
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ illegal_mem_size, illegal_mem_size); // expected-error{{local memory sizes need to be specified as uint}}
+
+ // Testing the forth overload type
+ enqueue_kernel(default_queue, flags, ndrange, 1, event_wait_list2, &evt,
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024);
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt, // expected-error{{mismatch in number of block parameters and local size arguments passed}}
+ ^(local void *a, local void *b) {
+ return 0;
+ },
+ 1024, 1024, 1024);
+
+ // More random misc cases that can't be deduced
+ enqueue_kernel(default_queue, flags, ndrange, 1, &event_wait_list, &evt); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
+
+ enqueue_kernel(default_queue, flags, ndrange, 1, 1); // expected-error{{illegal call to enqueue_kernel, incorrect argument types}}
+}
+
+// Diagnostic tests for get_kernel_work_group_size and allowed block parameter types in dynamic parallelism.
+kernel void work_group_size_tests() {
+ void (^const block_A)(void) = ^{
+ return;
+ };
+ void (^const block_B)(int) = ^(int a) {
+ return;
+ };
+ void (^const block_C)(local void *) = ^(local void *a) {
+ return;
+ };
+ void (^const block_D)(local int *) = ^(local int *a) {
+ return;
+ };
+
+ unsigned size = get_kernel_work_group_size(block_A);
+ size = get_kernel_work_group_size(block_C);
+ size = get_kernel_work_group_size(^(local void *a) {
+ return;
+ });
+ size = get_kernel_work_group_size(^(local int *a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ return;
+ });
+ size = get_kernel_work_group_size(block_B); // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ size = get_kernel_work_group_size(block_D); // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ size = get_kernel_work_group_size(^(int a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ return;
+ });
+ size = get_kernel_work_group_size(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+ size = get_kernel_work_group_size(1); // expected-error{{expected block argument}}
+ size = get_kernel_work_group_size(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
+
+ size = get_kernel_preferred_work_group_size_multiple(block_A);
+ size = get_kernel_preferred_work_group_size_multiple(block_C);
+ size = get_kernel_preferred_work_group_size_multiple(^(local void *a) {
+ return;
+ });
+ size = get_kernel_preferred_work_group_size_multiple(^(local int *a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ return;
+ });
+ size = get_kernel_preferred_work_group_size_multiple(^(int a) { // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ return;
+ });
+ size = get_kernel_preferred_work_group_size_multiple(block_B); // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ size = get_kernel_preferred_work_group_size_multiple(block_D); // expected-error {{blocks used in device side enqueue are expected to have parameters of type 'local void*'}}
+ size = get_kernel_preferred_work_group_size_multiple(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+ size = get_kernel_preferred_work_group_size_multiple(1); // expected-error{{expected block argument}}
+ size = get_kernel_preferred_work_group_size_multiple(block_A, 1); // expected-error{{too many arguments to function call, expected 1, have 2}}
+}
Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===================================================================
--- /dev/null
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -fblocks -ffake-address-space-map -O0 -emit-llvm -o - | FileCheck %s
+
+typedef void (^bl_t)(local void *);
+
+const bl_t block_G = (bl_t) ^ (local void *a) {};
+
+kernel void device_side_enqueue(global int *a, global int *b, int i) {
+ // CHECK: %default_queue = alloca %opencl.queue_t*
+ queue_t default_queue;
+ // CHECK: %flags = alloca i32
+ unsigned flags = 0;
+ // CHECK: %ndrange = alloca %opencl.ndrange_t*
+ ndrange_t ndrange;
+ // CHECK: %clk_event = alloca %opencl.clk_event_t*
+ clk_event_t clk_event;
+ // CHECK: %event_wait_list = alloca %opencl.clk_event_t*
+ clk_event_t event_wait_list;
+ // CHECK: %event_wait_list2 = alloca [1 x %opencl.clk_event_t*]
+ clk_event_t event_wait_list2[] = {clk_event};
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block to void ()*
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__enqueue_kernel_basic(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* [[BL_I8]])
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(void) {
+ a[i] = b[i];
+ });
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: [[BL:%[0-9]+]] = bitcast <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32{{.*}}, i32{{.*}}, i32{{.*}} }>* %block3 to void ()*
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__enqueue_kernel_basic_events(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** %event_wait_list, %opencl.clk_event_t** %clk_event, i8* [[BL_I8]])
+ enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
+ ^(void) {
+ a[i] = b[i];
+ });
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i8*, i32, ...) @__enqueue_kernel_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ enqueue_kernel(default_queue, flags, ndrange,
+ ^(local void *p) {
+ return;
+ },
+ 256);
+
+ // CHECK: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t*, %opencl.queue_t** %default_queue
+ // CHECK: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
+ // CHECK: [[NDR:%[0-9]+]] = load %opencl.ndrange_t*, %opencl.ndrange_t** %ndrange
+ // CHECK: %arraydecay = getelementptr inbounds [1 x %opencl.clk_event_t*], [1 x %opencl.clk_event_t*]* %event_wait_list2, i32 0, i32 0
+ // CHECK: call i32 (%opencl.queue_t*, i32, %opencl.ndrange_t*, i32, %opencl.clk_event_t**, %opencl.clk_event_t**, i8*, i32, ...) @__enqueue_kernel_events_vaargs(%opencl.queue_t* [[DEF_Q]], i32 [[FLAGS]], %opencl.ndrange_t* [[NDR]], i32 2, %opencl.clk_event_t** %arraydecay, %opencl.clk_event_t** %clk_event, i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{(.[0-9]+)?}} to i8*), i32 1, i32 256)
+ enqueue_kernel(default_queue, flags, ndrange, 2, event_wait_list2, &clk_event,
+ ^(local void *p) {
+ return;
+ },
+ 256);
+
+ void (^const block_A)(void) = ^{
+ return;
+ };
+ void (^const block_B)(local void *) = ^(local void *a) {
+ return;
+ };
+
+ // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+ unsigned size = get_kernel_work_group_size(block_A);
+ // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)** %block_B
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_work_group_size_impl(i8* [[BL_I8]])
+ size = get_kernel_work_group_size(block_B);
+ // CHECK: [[BL:%[0-9]+]] = load void ()*, void ()** %block_A
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void ()* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+ size = get_kernel_preferred_work_group_size_multiple(block_A);
+ // CHECK: [[BL:%[0-9]+]] = load void (i8 addrspace(2)*)*, void (i8 addrspace(2)*)* addrspace(1)* @block_G
+ // CHECK: [[BL_I8:%[0-9]+]] = bitcast void (i8 addrspace(2)*)* [[BL]] to i8*
+ // CHECK: call i32 @__get_kernel_preferred_work_group_multiple_impl(i8* [[BL_I8]])
+ size = get_kernel_preferred_work_group_size_multiple(block_G);
+}
Index: lib/Sema/SemaInit.cpp
===================================================================
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1193,8 +1193,8 @@
// Fall through for subaggregate initialization.
} else {
- assert((ElemType->isRecordType() || ElemType->isVectorType()) &&
- "Unexpected type");
+ assert((ElemType->isRecordType() || ElemType->isVectorType() ||
+ ElemType->isClkEventT()) && "Unexpected type");
// C99 6.7.8p13:
//
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -71,6 +71,240 @@
<< call->getArg(1)->getSourceRange();
}
+static inline bool isBlockPointer(Expr *Arg) {
+ return Arg->getType().getTypePtr()->isBlockPointerType();
+}
+
+/// OpenCL C v2.0, s6.13.17.2 - Checks that the block parameters are all local
+/// void*, which is a requirement of device side enqueue.
+static bool checkBlockArgs(Sema &S, Expr *BlockArg) {
+ const BlockPointerType *BPT =
+ cast<BlockPointerType>(BlockArg->getType().getCanonicalType());
+ ArrayRef<QualType> Params =
+ BPT->getPointeeType()->getAs<FunctionProtoType>()->getParamTypes();
+ bool IllegalParams = false;
+ unsigned ArgCounter = 0;
+
+ // Iterate through the block parameters until either one is found that is not
+ // a local void*, or the block is valid.
+ for (ArrayRef<QualType>::iterator I = Params.begin(), E = Params.end();
+ I != E; ++I, ++ArgCounter) {
+ const Type *ParamType = I->getTypePtr();
+ if (!ParamType->isPointerType()) {
+ IllegalParams = true;
+ break;
+ }
+ QualType PointeeType = cast<PointerType>(ParamType)->getPointeeType();
+ if (!PointeeType.getTypePtr()->isVoidType()) {
+ IllegalParams = true;
+ break;
+ }
+ Qualifiers ArgQual = PointeeType.getQualifiers();
+ if (ArgQual.getAddressSpace() != LangAS::opencl_local) {
+ IllegalParams = true;
+ break;
+ }
+ }
+ if (IllegalParams) {
+ // Get the location of the error. If a block literal has been passed
+ // (BlockExpr) then we can point straight to the offending argument,
+ // else we just point to the variable reference.
+ SourceLocation ErrorLoc;
+ if (isa<BlockExpr>(BlockArg)) {
+ BlockDecl *BD = cast<BlockExpr>(BlockArg)->getBlockDecl();
+ ErrorLoc = BD->getParamDecl(ArgCounter)->getLocStart();
+ } else if (isa<DeclRefExpr>(BlockArg)) {
+ ErrorLoc = cast<DeclRefExpr>(BlockArg)->getLocStart();
+ }
+ S.Diag(ErrorLoc,
+ diag::err_opencl_enqueue_kernel_blocks_non_local_void_args);
+ }
+
+ return IllegalParams;
+}
+
+/// OpenCL C v2.0, s6.13.17.6 - Check the argument to the
+/// get_kernel_work_group_size
+/// and get_kernel_preferred_work_group_size_multiple builtin functions.
+static bool SemaOpenCLBuiltinKernelWorkGroupSize(Sema &S, CallExpr *TheCall) {
+ if (checkArgCount(S, TheCall, 1))
+ return true;
+
+ Expr *BlockArg = TheCall->getArg(0);
+ if (!isBlockPointer(BlockArg)) {
+ S.Diag(BlockArg->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type) << "block";
+ return true;
+ } else
+ return checkBlockArgs(S, BlockArg);
+}
+
+static bool checkForLocalSizeArgs(Sema &S, CallExpr *TheCall, unsigned Start,
+ unsigned End) {
+ for (unsigned i = Start; i < End; ++i)
+ if (!TheCall->getArg(i)->getType().getTypePtr()->isIntegerType())
+ return false;
+ return true;
+}
+
+/// OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all
+/// 'local void*' parameter of passed block.
+static bool checkEnqueueVariadicArgs(Sema &S, CallExpr *TheCall, Expr *BlockArg,
+ unsigned NumNonVarArgs) {
+ const BlockPointerType *BPT =
+ cast<BlockPointerType>(BlockArg->getType().getCanonicalType());
+ unsigned NumBlockParams =
+ BPT->getPointeeType()->getAs<FunctionProtoType>()->getNumParams();
+ unsigned TotalNumArgs = TheCall->getNumArgs();
+
+ // For each argument passed to the block, a corresponding uint needs to
+ // be passed to describe the size of the local memory.
+ if (TotalNumArgs != NumBlockParams + NumNonVarArgs) {
+ S.Diag(TheCall->getLocStart(),
+ diag::err_opencl_enqueue_kernel_local_size_args);
+ return true;
+ }
+
+ // Check that the sizes of the local memory are specified by integers.
+ if (!checkForLocalSizeArgs(S, TheCall, NumNonVarArgs, TotalNumArgs - 1)) {
+ S.Diag(TheCall->getArg(NumNonVarArgs)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_invalid_local_size_type);
+ return true;
+ }
+ return false;
+}
+
+/// OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different
+/// overload formats specified in Table 6.13.17.1.
+/// int enqueue_kernel(queue_t queue,
+/// kernel_enqueue_flags_t flags,
+/// const ndrange_t ndrange,
+/// void (^block)(void))
+/// int enqueue_kernel(queue_t queue,
+/// kernel_enqueue_flags_t flags,
+/// const ndrange_t ndrange,
+/// uint num_events_in_wait_list,
+/// clk_event_t *event_wait_list,
+/// clk_event_t *event_ret,
+/// void (^block)(void))
+/// int enqueue_kernel(queue_t queue,
+/// kernel_enqueue_flags_t flags,
+/// const ndrange_t ndrange,
+/// void (^block)(local void*, ...),
+/// uint size0, ...)
+/// int enqueue_kernel(queue_t queue,
+/// kernel_enqueue_flags_t flags,
+/// const ndrange_t ndrange,
+/// uint num_events_in_wait_list,
+/// clk_event_t *event_wait_list,
+/// clk_event_t *event_ret,
+/// void (^block)(void*, ...),
+/// uint size0, ...)
+static bool SemaOpenCLBuiltinEnqueueKernel(Sema &S, CallExpr *TheCall) {
+ unsigned NumArgs = TheCall->getNumArgs();
+
+ if (NumArgs < 4) {
+ S.Diag(TheCall->getLocStart(), diag::err_typecheck_call_too_few_args);
+ return true;
+ }
+
+ Expr *Arg0 = TheCall->getArg(0);
+ Expr *Arg1 = TheCall->getArg(1);
+ Expr *Arg2 = TheCall->getArg(2);
+ Expr *Arg3 = TheCall->getArg(3);
+
+ // First argument always needs to be a queue_t type.
+ if (!Arg0->getType()->isQueueT()) {
+ S.Diag(TheCall->getArg(0)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << S.Context.OCLQueueTy;
+ return true;
+ }
+
+ // Second argument always needs to be a kernel_enqueue_flags_t enum value.
+ if (!Arg1->getType()->isIntegerType()) {
+ S.Diag(TheCall->getArg(1)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << "'kernel_enqueue_flags_t' (i.e. uint)";
+ return true;
+ }
+
+ // Third argument is always an ndrange_t type.
+ if (!Arg2->getType()->isNDRangeT()) {
+ S.Diag(TheCall->getArg(2)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << S.Context.OCLNDRangeTy;
+ return true;
+ }
+
+ // With four arguments, there is only one form that the function could be
+ // called in: no events and no variable arguments.
+ if (NumArgs == 4) {
+ // check that the last argument is the right block type.
+ if (!isBlockPointer(Arg3)) {
+ S.Diag(Arg3->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type) << "block";
+ return true;
+ } else
+ return checkBlockArgs(S, Arg3);
+ } else if (NumArgs >= 5) {
+ // we can have block + varargs.
+ if (isBlockPointer(Arg3))
+ return (checkBlockArgs(S, Arg3) ||
+ checkEnqueueVariadicArgs(S, TheCall, Arg3, 4));
+ // last two cases with either exactly 7 args or 7 args and varargs.
+ if (NumArgs >= 7) {
+ // check common block argument.
+ Expr *Arg6 = TheCall->getArg(6);
+ if (!isBlockPointer(Arg6)) {
+ S.Diag(Arg6->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type) << "block";
+ return true;
+ }
+ if (checkBlockArgs(S, Arg6))
+ return true;
+
+ // Forth argument has to be any integer type.
+ if (!Arg3->getType()->isIntegerType()) {
+ S.Diag(TheCall->getArg(3)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << "integer";
+ return true;
+ }
+ // check remaining common arguments.
+ Expr *Arg4 = TheCall->getArg(4);
+ Expr *Arg5 = TheCall->getArg(5);
+
+ // Fith argument is always passed as pointers to clk_event_t.
+ if (!Arg4->getType()->getPointeeOrArrayElementType()->isClkEventT()) {
+ S.Diag(TheCall->getArg(4)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << S.Context.getPointerType(S.Context.OCLClkEventTy);
+ return true;
+ }
+
+ // Sixth argument is always passed as pointers to clk_event_t.
+ if (!(Arg5->getType()->isPointerType() &&
+ Arg5->getType()->getPointeeType()->isClkEventT())) {
+ S.Diag(TheCall->getArg(5)->getLocStart(),
+ diag::err_opencl_enqueue_kernel_expected_type)
+ << S.Context.getPointerType(S.Context.OCLClkEventTy);
+ return true;
+ }
+
+ if (NumArgs == 7)
+ return false;
+ else if (NumArgs >= 7) // check if varargs are correct types.
+ return checkEnqueueVariadicArgs(S, TheCall, Arg6, 7);
+ }
+ }
+
+ // None of the specific case has been detected, give generic error
+ S.Diag(TheCall->getLocStart(),
+ diag::err_opencl_enqueue_kernel_incorrect_args);
+ return true;
+}
+
/// Check that the first argument to __builtin_annotation is an integer
/// and the second argument is a non-wide string literal.
static bool SemaBuiltinAnnotation(Sema &S, CallExpr *TheCall) {
@@ -454,21 +688,14 @@
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.
// \param Call A pointer to the builtin call.
// \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();
@@ -801,6 +1028,7 @@
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
@@ -841,6 +1069,15 @@
if (SemaOpenCLBuiltinToAddr(*this, BuiltinID, TheCall))
return ExprError();
break;
+ // OpenCL v2.0, s6.13.17 - Enqueue kernel functions.
+ case Builtin::BIenqueue_kernel:
+ if (SemaOpenCLBuiltinEnqueueKernel(*this, TheCall))
+ return ExprError();
+ break;
+ case Builtin::BIget_kernel_work_group_size:
+ case Builtin::BIget_kernel_preferred_work_group_size_multiple:
+ if (SemaOpenCLBuiltinKernelWorkGroupSize(*this, TheCall))
+ return ExprError();
}
// Since the target specific builtins for each arch overlap, only check those
@@ -9313,15 +9550,6 @@
<< TRange << Op->getSourceRange();
}
-static const Type* getElementType(const Expr *BaseExpr) {
- const Type* EltType = BaseExpr->getType().getTypePtr();
- if (EltType->isAnyPointerType())
- return EltType->getPointeeType().getTypePtr();
- else if (EltType->isArrayType())
- return EltType->getBaseElementTypeUnsafe();
- return EltType;
-}
-
/// \brief Check whether this array fits the idiom of a size-one tail padded
/// array member of a struct.
///
@@ -9376,7 +9604,8 @@
if (IndexExpr->isValueDependent())
return;
- const Type *EffectiveType = getElementType(BaseExpr);
+ const Type *EffectiveType =
+ BaseExpr->getType()->getPointeeOrArrayElementType();
BaseExpr = BaseExpr->IgnoreParenCasts();
const ConstantArrayType *ArrayTy =
Context.getAsConstantArrayType(BaseExpr->getType());
@@ -9400,7 +9629,7 @@
if (!size.isStrictlyPositive())
return;
- const Type* BaseType = getElementType(BaseExpr);
+ const Type *BaseType = BaseExpr->getType()->getPointeeOrArrayElementType();
if (BaseType != EffectiveType) {
// Make sure we're comparing apples to apples when comparing index to size
uint64_t ptrarith_typesize = Context.getTypeSize(EffectiveType);
Index: lib/Headers/opencl-c.h
===================================================================
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16834,12 +16834,6 @@
ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3]);
ndrange_t __ovld ndrange_3D(const size_t[3], const size_t[3], const size_t[3]);
-// ToDo: Add these functions as Clang builtins since they eed a special check of parameters to block.
-uint __ovld get_kernel_work_group_size(void (^block)(void));
-uint __ovld get_kernel_work_group_size(void (^block)(local void *, ...));
-uint __ovld get_kernel_preferred_work_group_size_multiple(void (^block)(void));
-uint __ovld get_kernel_preferred_work_group_size_multiple(void (^block)(local void *, ...));
-
int __ovld enqueue_marker(queue_t, uint, const __private clk_event_t*, __private clk_event_t*);
void __ovld retain_event(clk_event_t);
Index: lib/CodeGen/CGBuiltin.cpp
===================================================================
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2074,7 +2074,7 @@
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:
@@ -2150,6 +2150,137 @@
ConvertType(E->getType())));
}
+ // OpenCL v2.0, s6.13.17 - Enqueue kernel function.
+ // It contains four different overload formats specified in Table 6.13.17.1.
+ case Builtin::BIenqueue_kernel: {
+ StringRef Name; // Generated function call name
+ unsigned NumArgs = E->getNumArgs();
+
+ llvm::Type *QueueTy = ConvertType(getContext().OCLQueueTy);
+ llvm::Type *RangeTy = ConvertType(getContext().OCLNDRangeTy);
+
+ llvm::Value *Queue = EmitScalarExpr(E->getArg(0));
+ llvm::Value *Flags = EmitScalarExpr(E->getArg(1));
+ llvm::Value *Range = EmitScalarExpr(E->getArg(2));
+
+ if (NumArgs == 4) {
+ // The most basic form of the call with parameters:
+ // queue_t, kernel_enqueue_flags_t, ndrange_t, block(void)
+ Name = "__enqueue_kernel_basic";
+ llvm::Type *ArgTys[] = {QueueTy, Int32Ty, RangeTy, Int8PtrTy};
+ llvm::FunctionType *FTy = llvm::FunctionType::get(
+ Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys, 4), false);
+
+ llvm::Value *Block =
+ Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int8PtrTy);
+
+ return RValue::get(Builder.CreateCall(
+ CGM.CreateRuntimeFunction(FTy, Name), {Queue, Flags, Range, Block}));
+ }
+ // Could have events and/or vaargs.
+ if (NumArgs >= 5) {
+ if (E->getArg(3)->getType()->isBlockPointerType()) {
+ // No events passed, but has variadic arguments.
+ Name = "__enqueue_kernel_vaargs";
+ llvm::Value *Block =
+ Builder.CreateBitCast(EmitScalarExpr(E->getArg(3)), Int8PtrTy);
+ // Create a vector of the arguments, as well as a constant value to
+ // express to the runtime the number of variadic arguments.
+ std::vector<llvm::Value *> Args{Queue, Flags, Range, Block,
+ ConstantInt::get(IntTy, NumArgs - 4)};
+ std::vector<llvm::Type *> ArgTys = {QueueTy, IntTy, RangeTy, Int8PtrTy,
+ IntTy};
+
+ // Add the variadics.
+ for (unsigned i = 4; i < NumArgs; ++i) {
+ Args.push_back(EmitScalarExpr(E->getArg(i)));
+ }
+
+ llvm::FunctionType *FTy = llvm::FunctionType::get(
+ Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys), true);
+ return RValue::get(
+ Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef<llvm::Value *>(Args)));
+ }
+ // Any calls now have event arguments passed.
+ if (NumArgs >= 7) {
+ llvm::Type *EventTy = ConvertType(getContext().OCLClkEventTy);
+ unsigned AS4 =
+ E->getArg(4)->getType()->isArrayType()
+ ? E->getArg(4)->getType().getAddressSpace()
+ : E->getArg(4)->getType()->getPointeeType().getAddressSpace();
+ llvm::Type *EventPtrAS4Ty =
+ EventTy->getPointerTo(CGM.getContext().getTargetAddressSpace(AS4));
+ unsigned AS5 =
+ E->getArg(5)->getType()->getPointeeType().getAddressSpace();
+ llvm::Type *EventPtrAS5Ty =
+ EventTy->getPointerTo(CGM.getContext().getTargetAddressSpace(AS5));
+
+ llvm::Value *NumEvents = EmitScalarExpr(E->getArg(3));
+ llvm::Value *EventList =
+ E->getArg(4)->getType()->isArrayType()
+ ? EmitArrayToPointerDecay(E->getArg(4)).getPointer()
+ : EmitScalarExpr(E->getArg(4));
+ llvm::Value *ClkEvent = EmitScalarExpr(E->getArg(5));
+ llvm::Value *Block =
+ Builder.CreateBitCast(EmitScalarExpr(E->getArg(6)), Int8PtrTy);
+
+ std::vector<llvm::Type *> ArgTys = {
+ QueueTy, Int32Ty, RangeTy, Int32Ty,
+ EventPtrAS4Ty, EventPtrAS5Ty, Int8PtrTy};
+ std::vector<llvm::Value *> Args{Queue, Flags, Range, NumEvents,
+ EventList, ClkEvent, Block};
+
+ if (NumArgs == 7) {
+ // Has events but no variadics.
+ Name = "__enqueue_kernel_basic_events";
+ llvm::FunctionType *FTy = llvm::FunctionType::get(
+ Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys), false);
+ return RValue::get(
+ Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef<llvm::Value *>(Args)));
+ } else {
+ // Has event info and variadics
+
+ // Pass the number of variadics to the runtime function too.
+ Args.push_back(ConstantInt::get(Int32Ty, NumArgs - 7));
+ ArgTys.push_back(Int32Ty);
+ Name = "__enqueue_kernel_events_vaargs";
+
+ // Add the variadics.
+ for (unsigned i = 7; i < NumArgs; ++i) {
+ Args.push_back(EmitScalarExpr(E->getArg(i)));
+ }
+ llvm::FunctionType *FTy = llvm::FunctionType::get(
+ Int32Ty, llvm::ArrayRef<llvm::Type *>(ArgTys), true);
+ return RValue::get(
+ Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
+ llvm::ArrayRef<llvm::Value *>(Args)));
+ }
+ }
+ }
+ llvm_unreachable("Unhandled enqueue_kernel signature");
+ }
+ // OpenCL v2.0 s6.13.17.6 - Kernel query functions need bitcast of block
+ // parameter.
+ case Builtin::BIget_kernel_work_group_size: {
+ Value *Arg = EmitScalarExpr(E->getArg(0));
+ Arg = Builder.CreateBitCast(Arg, Int8PtrTy);
+ return RValue::get(
+ Builder.CreateCall(CGM.CreateRuntimeFunction(
+ llvm::FunctionType::get(IntTy, Int8PtrTy, false),
+ "__get_kernel_work_group_size_impl"),
+ Arg));
+ }
+ case Builtin::BIget_kernel_preferred_work_group_size_multiple: {
+ Value *Arg = EmitScalarExpr(E->getArg(0));
+ Arg = Builder.CreateBitCast(Arg, Int8PtrTy);
+ return RValue::get(Builder.CreateCall(
+ CGM.CreateRuntimeFunction(
+ llvm::FunctionType::get(IntTy, Int8PtrTy, false),
+ "__get_kernel_preferred_work_group_multiple_impl"),
+ Arg));
+ }
case Builtin::BIprintf:
if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
return EmitCUDADevicePrintfCallExpr(E, ReturnValue);
Index: lib/Basic/Builtins.cpp
===================================================================
--- lib/Basic/Builtins.cpp
+++ lib/Basic/Builtins.cpp
@@ -69,7 +69,8 @@
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;
}
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7861,8 +7861,6 @@
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<
@@ -7899,6 +7897,18 @@
"invalid number of arguments to function: %0">;
def err_opencl_builtin_to_addr_invalid_arg : Error<
"invalid argument %0 to function: %1, expecting a generic pointer argument">;
+
+// OpenCL v2.0 s6.13.17 Enqueue kernel restrictions.
+def err_opencl_enqueue_kernel_incorrect_args : Error<
+ "illegal call to enqueue_kernel, incorrect argument types">;
+def err_opencl_enqueue_kernel_expected_type : Error<
+ "illegal call to enqueue_kernel, expected %0 argument type">;
+def err_opencl_enqueue_kernel_local_size_args : Error<
+ "mismatch in number of block parameters and local size arguments passed">;
+def err_opencl_enqueue_kernel_invalid_local_size_type : Error<
+ "local memory sizes need to be specified as uint">;
+def err_opencl_enqueue_kernel_blocks_non_local_void_args : Error<
+ "blocks used in device side enqueue are expected to have parameters of type 'local void*'">;
} // end of sema category
let CategoryName = "OpenMP Issue" in {
Index: include/clang/Basic/Builtins.h
===================================================================
--- include/clang/Basic/Builtins.h
+++ include/clang/Basic/Builtins.h
@@ -36,7 +36,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.
- 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.
Index: include/clang/Basic/Builtins.def
===================================================================
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -1281,34 +1281,40 @@
// 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.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, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "i.", "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
Index: include/clang/AST/Type.h
===================================================================
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1898,6 +1898,11 @@
/// This should never be used when type qualifiers are meaningful.
const Type *getArrayElementTypeNoTypeQual() const;
+ /// If this is a pointer type, return the pointee type.
+ /// If this is an array type, return the array element type.
+ /// This should never be used when type qualifiers are meaningful.
+ const Type *getPointeeOrArrayElementType() const;
+
/// If this is a pointer, ObjC object pointer, or block
/// pointer, this returns the respective pointee.
QualType getPointeeType() const;
@@ -5771,6 +5776,15 @@
return type;
}
+inline const Type *Type::getPointeeOrArrayElementType() const {
+ const Type *type = this;
+ if (type->isAnyPointerType())
+ return type->getPointeeType().getTypePtr();
+ else if (type->isArrayType())
+ return type->getBaseElementTypeUnsafe();
+ return type;
+}
+
/// Insertion operator for diagnostics. This allows sending QualType's into a
/// diagnostic with <<.
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits