1// RUN: %clang_cc1 %s -cl-kernel-arg-info -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix ARGINFO
2// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -check-prefix NO-ARGINFO
3
4kernel void foo(__global int * restrict X, const int Y,
5                volatile int anotherArg, __constant float * restrict Z) {
6  *X = Y + anotherArg;
7}
8
9// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 0, i32 0, i32 2}
10// CHECK:  !{!"kernel_arg_access_qual", !"none", !"none", !"none", !"none"}
11// CHECK:  !{!"kernel_arg_type", !"int*", !"int", !"int", !"float*"}
12// CHECK:  !{!"kernel_arg_base_type", !"int*", !"int", !"int", !"float*"}
13// CHECK:  !{!"kernel_arg_type_qual", !"restrict", !"const", !"volatile", !"restrict const"}
14// ARGINFO: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
15// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"X", !"Y", !"anotherArg", !"Z"}
16
17kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) {
18}
19// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 1, i32 1}
20// CHECK:  !{!"kernel_arg_access_qual", !"read_only", !"read_only", !"write_only"}
21// CHECK:  !{!"kernel_arg_type", !"image1d_t", !"image2d_t", !"image2d_array_t"}
22// CHECK:  !{!"kernel_arg_base_type", !"image1d_t", !"image2d_t", !"image2d_array_t"}
23// CHECK:  !{!"kernel_arg_type_qual", !"", !"", !""}
24// ARGINFO: !{!"kernel_arg_name", !"img1", !"img2", !"img3"}
25// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"img1", !"img2", !"img3"}
26
27kernel void foo3(__global half * X) {
28}
29// CHECK:  !{!"kernel_arg_addr_space", i32 1}
30// CHECK:  !{!"kernel_arg_access_qual", !"none"}
31// CHECK:  !{!"kernel_arg_type", !"half*"}
32// CHECK:  !{!"kernel_arg_base_type", !"half*"}
33// CHECK:  !{!"kernel_arg_type_qual", !""}
34// ARGINFO: !{!"kernel_arg_name", !"X"}
35// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"X"}
36
37typedef unsigned int myunsignedint;
38kernel void foo4(__global unsigned int * X, __global myunsignedint * Y) {
39}
40// CHECK:  !{!"kernel_arg_addr_space", i32 1, i32 1}
41// CHECK:  !{!"kernel_arg_access_qual", !"none", !"none"}
42// CHECK:  !{!"kernel_arg_type", !"uint*", !"myunsignedint*"}
43// CHECK:  !{!"kernel_arg_base_type", !"uint*", !"uint*"}
44// CHECK:  !{!"kernel_arg_type_qual", !"", !""}
45// ARGINFO: !{!"kernel_arg_name", !"X", !"Y"}
46// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"X", !"Y"}
47
48typedef image1d_t myImage;
49kernel void foo5(read_only myImage img1, write_only image1d_t img2) {
50}
51// CHECK:  !{!"kernel_arg_access_qual", !"read_only", !"write_only"}
52// CHECK:  !{!"kernel_arg_type", !"myImage", !"image1d_t"}
53// CHECK:  !{!"kernel_arg_base_type", !"image1d_t", !"image1d_t"}
54// ARGINFO: !{!"kernel_arg_name", !"img1", !"img2"}
55// NO-ARGINFO-NOT: !{!"kernel_arg_name", !"img1", !"img2"}
56