[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / CodeGenOpenCL / pipe_builtin.cl
blob05cdcd1de30a71b464b00c7c9f07359eac8229bc
1 // RUN: %clang_cc1 -no-opaque-pointers -triple %itanium_abi_triple -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=clc++ -o - %s | FileCheck %s
2 // FIXME: Add MS ABI manglings of OpenCL things and remove %itanium_abi_triple
3 // above to support OpenCL in the MS C++ ABI.
5 // CHECK-DAG: %opencl.pipe_ro_t = type opaque
6 // CHECK-DAG: %opencl.pipe_wo_t = type opaque
7 // CHECK-DAG: %opencl.reserve_id_t = type opaque
9 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
11 void test1(read_only pipe int p, global int *ptr) {
12 // CHECK: call i32 @__read_pipe_2(%opencl.pipe_ro_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
13 read_pipe(p, ptr);
14 // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
15 reserve_id_t rid = reserve_read_pipe(p, 2);
16 // CHECK: call i32 @__read_pipe_4(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
17 read_pipe(p, rid, 2, ptr);
18 // CHECK: call void @__commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
19 commit_read_pipe(p, rid);
22 void test2(write_only pipe int p, global int *ptr) {
23 // CHECK: call i32 @__write_pipe_2(%opencl.pipe_wo_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4)
24 write_pipe(p, ptr);
25 // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
26 reserve_id_t rid = reserve_write_pipe(p, 2);
27 // CHECK: call i32 @__write_pipe_4(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4)
28 write_pipe(p, rid, 2, ptr);
29 // CHECK: call void @__commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
30 commit_write_pipe(p, rid);
33 void test3(read_only pipe int p, global int *ptr) {
34 // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
35 reserve_id_t rid = work_group_reserve_read_pipe(p, 2);
36 // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
37 work_group_commit_read_pipe(p, rid);
40 void test4(write_only pipe int p, global int *ptr) {
41 // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
42 reserve_id_t rid = work_group_reserve_write_pipe(p, 2);
43 // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
44 work_group_commit_write_pipe(p, rid);
47 void test5(read_only pipe int p, global int *ptr) {
48 // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_ro_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
49 reserve_id_t rid = sub_group_reserve_read_pipe(p, 2);
50 // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_ro_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
51 sub_group_commit_read_pipe(p, rid);
54 void test6(write_only pipe int p, global int *ptr) {
55 // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_write_pipe(%opencl.pipe_wo_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4)
56 reserve_id_t rid = sub_group_reserve_write_pipe(p, 2);
57 // CHECK: call void @__sub_group_commit_write_pipe(%opencl.pipe_wo_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4)
58 sub_group_commit_write_pipe(p, rid);
61 void test7(read_only pipe int p, global int *ptr) {
62 // CHECK: call i32 @__get_pipe_num_packets_ro(%opencl.pipe_ro_t* %{{.*}}, i32 4, i32 4)
63 *ptr = get_pipe_num_packets(p);
64 // CHECK: call i32 @__get_pipe_max_packets_ro(%opencl.pipe_ro_t* %{{.*}}, i32 4, i32 4)
65 *ptr = get_pipe_max_packets(p);
68 void test8(write_only pipe int p, global int *ptr) {
69 // CHECK: call i32 @__get_pipe_num_packets_wo(%opencl.pipe_wo_t* %{{.*}}, i32 4, i32 4)
70 *ptr = get_pipe_num_packets(p);
71 // CHECK: call i32 @__get_pipe_max_packets_wo(%opencl.pipe_wo_t* %{{.*}}, i32 4, i32 4)
72 *ptr = get_pipe_max_packets(p);