[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenOpenCL / builtins.cl
blobae6033fa70d15add384c52f38faa5b8f896f6bce
1 // RUN: %clang_cc1 -no-opaque-pointers %s -finclude-default-header -fdeclare-opencl-builtins -cl-std=clc++ -fblocks -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s
3 void testBranchingOnEnqueueKernel(queue_t default_queue, unsigned flags, ndrange_t ndrange) {
4 // Ensure `enqueue_kernel` can be branched upon.
6 if (enqueue_kernel(default_queue, flags, ndrange, ^(void) {}))
7 (void)0;
8 // CHECK: [[P:%[0-9]+]] = call spir_func i32 @__enqueue_kernel
9 // CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
10 // CHECK-NEXT: br i1 [[Q]]
12 if (get_kernel_work_group_size(^(void) {}))
13 (void)0;
14 // CHECK: [[P:%[0-9]+]] = call spir_func i32 @__get_kernel_work_group_size
15 // CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
16 // CHECK-NEXT: br i1 [[Q]]
18 if (get_kernel_preferred_work_group_size_multiple(^(void) {}))
19 (void)0;
20 // CHECK: [[P:%[0-9]+]] = call spir_func i32 @__get_kernel_preferred_work_group_size_multiple_impl
21 // CHECK-NEXT: [[Q:%[a-z0-9]+]] = icmp ne i32 [[P]], 0
22 // CHECK-NEXT: br i1 [[Q]]
25 void testBranchinOnPipeOperations(read_only pipe int r, write_only pipe int w, global int* ptr) {
26 // Verify that return type is correctly casted to i1 value.
28 if (read_pipe(r, ptr))
29 (void)0;
30 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__read_pipe_2
31 // CHECK-NEXT: icmp ne i32 [[R]], 0
33 if (write_pipe(w, ptr))
34 (void)0;
35 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__write_pipe_2
36 // CHECK-NEXT: icmp ne i32 [[R]], 0
38 if (get_pipe_num_packets(r))
39 (void)0;
40 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_num_packets_ro
41 // CHECK-NEXT: icmp ne i32 [[R]], 0
43 if (get_pipe_num_packets(w))
44 (void)0;
45 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_num_packets_wo
46 // CHECK-NEXT: icmp ne i32 [[R]], 0
48 if (get_pipe_max_packets(r))
49 (void)0;
50 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_max_packets_ro
51 // CHECK-NEXT: icmp ne i32 [[R]], 0
53 if (get_pipe_max_packets(w))
54 (void)0;
55 // CHECK: [[R:%[0-9]+]] = call spir_func i32 @__get_pipe_max_packets_wo
56 // CHECK-NEXT: icmp ne i32 [[R]], 0
59 void testBranchingOnAddressSpaceCast(generic long* ptr) {
60 // Verify that pointer types are properly casted, respecting address spaces.
62 if (to_global(ptr))
63 (void)0;
64 // CHECK: [[P:%[0-9]+]] = call spir_func [[GLOBAL_VOID:i8 addrspace\(1\)\*]] @__to_global([[GENERIC_VOID:i8 addrspace\(4\)\*]] {{%[0-9]+}})
65 // CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[GLOBAL_VOID]] [[P]] to [[GLOBAL_i64:i64 addrspace\(1\)\*]]
66 // CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[GLOBAL_i64]] [[Q]], null
67 // CHECK-NEXT: br i1 [[BOOL]]
69 if (to_local(ptr))
70 (void)0;
71 // CHECK: [[P:%[0-9]+]] = call spir_func [[LOCAL_VOID:i8 addrspace\(3\)\*]] @__to_local([[GENERIC_VOID]] {{%[0-9]+}})
72 // CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[LOCAL_VOID]] [[P]] to [[LOCAL_i64:i64 addrspace\(3\)\*]]
73 // CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[LOCAL_i64]] [[Q]], null
74 // CHECK-NEXT: br i1 [[BOOL]]
76 if (to_private(ptr))
77 (void)0;
78 // CHECK: [[P:%[0-9]+]] = call spir_func [[PRIVATE_VOID:i8\*]] @__to_private([[GENERIC_VOID]] {{%[0-9]+}})
79 // CHECK-NEXT: [[Q:%[0-9]+]] = bitcast [[PRIVATE_VOID]] [[P]] to [[PRIVATE_i64:i64\*]]
80 // CHECK-NEXT: [[BOOL:%[a-z0-9]+]] = icmp ne [[PRIVATE_i64]] [[Q]], null
81 // CHECK-NEXT: br i1 [[BOOL]]