blob: fa48ad28f767f45d308fcaa57a132f23d4759863 [file] [log] [blame]
Alexey Bader3e0b8172016-09-06 10:10:28 +00001// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s
2// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO
Tanya Lattner7445ada2012-07-11 23:02:10 +00003
Egor Churaev53f9a302017-07-18 06:04:01 +00004kernel void foo(global int * globalintp, global int * restrict globalintrestrictp,
5 global const int * globalconstintp,
6 global const int * restrict globalconstintrestrictp,
7 constant int * constantintp, constant int * restrict constantintrestrictp,
8 global const volatile int * globalconstvolatileintp,
9 global const volatile int * restrict globalconstvolatileintrestrictp,
10 global volatile int * globalvolatileintp,
11 global volatile int * restrict globalvolatileintrestrictp,
12 local int * localintp, local int * restrict localintrestrictp,
13 local const int * localconstintp,
14 local const int * restrict localconstintrestrictp,
15 local const volatile int * localconstvolatileintp,
16 local const volatile int * restrict localconstvolatileintrestrictp,
17 local volatile int * localvolatileintp,
18 local volatile int * restrict localvolatileintrestrictp,
19 int X, const int constint, const volatile int constvolatileint,
20 volatile int volatileint) {
21 *globalintrestrictp = constint + volatileint;
Tanya Lattner7445ada2012-07-11 23:02:10 +000022}
Yaxun Liuba28cba2016-06-22 14:56:35 +000023// CHECK: define spir_kernel void @foo{{[^!]+}}
24// CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]]
25// CHECK: !kernel_arg_access_qual ![[MD12:[0-9]+]]
26// CHECK: !kernel_arg_type ![[MD13:[0-9]+]]
27// CHECK: !kernel_arg_base_type ![[MD13]]
28// CHECK: !kernel_arg_type_qual ![[MD14:[0-9]+]]
29// CHECK-NOT: !kernel_arg_name
30// ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]]
Guy Benyeifb36ede2013-03-24 13:58:12 +000031
Alexey Bader3e0b8172016-09-06 10:10:28 +000032kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3, read_write image1d_t img4) {
Guy Benyeifb36ede2013-03-24 13:58:12 +000033}
Yaxun Liuba28cba2016-06-22 14:56:35 +000034// CHECK: define spir_kernel void @foo2{{[^!]+}}
35// CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]]
36// CHECK: !kernel_arg_access_qual ![[MD22:[0-9]+]]
37// CHECK: !kernel_arg_type ![[MD23:[0-9]+]]
38// CHECK: !kernel_arg_base_type ![[MD23]]
39// CHECK: !kernel_arg_type_qual ![[MD24:[0-9]+]]
40// CHECK-NOT: !kernel_arg_name
41// ARGINFO: !kernel_arg_name ![[MD25:[0-9]+]]
Joey Gouly92a47442014-04-04 13:43:57 +000042
43kernel void foo3(__global half * X) {
44}
Yaxun Liuba28cba2016-06-22 14:56:35 +000045// CHECK: define spir_kernel void @foo3{{[^!]+}}
46// CHECK: !kernel_arg_addr_space ![[MD31:[0-9]+]]
47// CHECK: !kernel_arg_access_qual ![[MD32:[0-9]+]]
48// CHECK: !kernel_arg_type ![[MD33:[0-9]+]]
49// CHECK: !kernel_arg_base_type ![[MD33]]
50// CHECK: !kernel_arg_type_qual ![[MD34:[0-9]+]]
51// CHECK-NOT: !kernel_arg_name
52// ARGINFO: !kernel_arg_name ![[MD35:[0-9]+]]
Fraser Cormack152493b2014-07-30 13:41:12 +000053
54typedef unsigned int myunsignedint;
55kernel void foo4(__global unsigned int * X, __global myunsignedint * Y) {
56}
Yaxun Liuba28cba2016-06-22 14:56:35 +000057// CHECK: define spir_kernel void @foo4{{[^!]+}}
58// CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
59// CHECK: !kernel_arg_access_qual ![[MD42:[0-9]+]]
60// CHECK: !kernel_arg_type ![[MD43:[0-9]+]]
61// CHECK: !kernel_arg_base_type ![[MD44:[0-9]+]]
62// CHECK: !kernel_arg_type_qual ![[MD45:[0-9]+]]
63// CHECK-NOT: !kernel_arg_name
64// ARGINFO: !kernel_arg_name ![[MD46:[0-9]+]]
Fraser Cormackdadc3712014-07-30 14:39:53 +000065
66typedef image1d_t myImage;
Alexey Baderc813c812016-07-08 15:34:59 +000067kernel void foo5(myImage img1, write_only image1d_t img2) {
Fraser Cormackdadc3712014-07-30 14:39:53 +000068}
Yaxun Liuba28cba2016-06-22 14:56:35 +000069// CHECK: define spir_kernel void @foo5{{[^!]+}}
70// CHECK: !kernel_arg_addr_space ![[MD41:[0-9]+]]
71// CHECK: !kernel_arg_access_qual ![[MD51:[0-9]+]]
72// CHECK: !kernel_arg_type ![[MD52:[0-9]+]]
73// CHECK: !kernel_arg_base_type ![[MD53:[0-9]+]]
74// CHECK: !kernel_arg_type_qual ![[MD45]]
75// CHECK-NOT: !kernel_arg_name
76// ARGINFO: !kernel_arg_name ![[MD54:[0-9]+]]
77
Egor Churaev53f9a302017-07-18 06:04:01 +000078typedef char char16 __attribute__((ext_vector_type(16)));
79__kernel void foo6(__global char16 arg[]) {}
80// CHECK: !kernel_arg_type ![[MD61:[0-9]+]]
Alexey Sotkin7d7f0dc2017-07-26 18:49:54 +000081// ARGINFO: !kernel_arg_name ![[MD62:[0-9]+]]
82
83typedef read_only image1d_t ROImage;
84typedef write_only image1d_t WOImage;
85typedef read_write image1d_t RWImage;
86kernel void foo7(ROImage ro, WOImage wo, RWImage rw) {
87}
88// CHECK: define spir_kernel void @foo7{{[^!]+}}
89// CHECK: !kernel_arg_addr_space ![[MD71:[0-9]+]]
90// CHECK: !kernel_arg_access_qual ![[MD72:[0-9]+]]
91// CHECK: !kernel_arg_type ![[MD73:[0-9]+]]
92// CHECK: !kernel_arg_base_type ![[MD74:[0-9]+]]
93// CHECK: !kernel_arg_type_qual ![[MD75:[0-9]+]]
94// CHECK-NOT: !kernel_arg_name
95// ARGINFO: !kernel_arg_name ![[MD76:[0-9]+]]
Egor Churaev53f9a302017-07-18 06:04:01 +000096
97// CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0}
98// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"}
99// CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"}
100// CHECK: ![[MD14]] = !{!"", !"restrict", !"const", !"restrict const", !"const", !"restrict const", !"const volatile", !"restrict const volatile", !"volatile", !"restrict volatile", !"", !"restrict", !"const", !"restrict const", !"const volatile", !"restrict const volatile", !"volatile", !"restrict volatile", !"", !"", !"", !""}
101// ARGINFO: ![[MD15]] = !{!"globalintp", !"globalintrestrictp", !"globalconstintp", !"globalconstintrestrictp", !"constantintp", !"constantintrestrictp", !"globalconstvolatileintp", !"globalconstvolatileintrestrictp", !"globalvolatileintp", !"globalvolatileintrestrictp", !"localintp", !"localintrestrictp", !"localconstintp", !"localconstintrestrictp", !"localconstvolatileintp", !"localconstvolatileintrestrictp", !"localvolatileintp", !"localvolatileintrestrictp", !"X", !"constint", !"constvolatileint", !"volatileint"}
Alexey Bader3e0b8172016-09-06 10:10:28 +0000102// CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1, i32 1}
103// CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only", !"read_write"}
104// CHECK: ![[MD23]] = !{!"image1d_t", !"image2d_t", !"image2d_array_t", !"image1d_t"}
105// CHECK: ![[MD24]] = !{!"", !"", !"", !""}
106// ARGINFO: ![[MD25]] = !{!"img1", !"img2", !"img3", !"img4"}
Yaxun Liuba28cba2016-06-22 14:56:35 +0000107// CHECK: ![[MD31]] = !{i32 1}
108// CHECK: ![[MD32]] = !{!"none"}
109// CHECK: ![[MD33]] = !{!"half*"}
110// CHECK: ![[MD34]] = !{!""}
111// ARGINFO: ![[MD35]] = !{!"X"}
112// CHECK: ![[MD41]] = !{i32 1, i32 1}
113// CHECK: ![[MD42]] = !{!"none", !"none"}
114// CHECK: ![[MD43]] = !{!"uint*", !"myunsignedint*"}
115// CHECK: ![[MD44]] = !{!"uint*", !"uint*"}
116// CHECK: ![[MD45]] = !{!"", !""}
117// ARGINFO: ![[MD46]] = !{!"X", !"Y"}
118// CHECK: ![[MD51]] = !{!"read_only", !"write_only"}
Alexey Bader3e0b8172016-09-06 10:10:28 +0000119// CHECK: ![[MD52]] = !{!"myImage", !"image1d_t"}
120// CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"}
Yaxun Liuba28cba2016-06-22 14:56:35 +0000121// ARGINFO: ![[MD54]] = !{!"img1", !"img2"}
Egor Churaev53f9a302017-07-18 06:04:01 +0000122// CHECK: ![[MD61]] = !{!"char16*"}
Alexey Sotkin7d7f0dc2017-07-26 18:49:54 +0000123// ARGINFO: ![[MD62]] = !{!"arg"}
124// CHECK: ![[MD71]] = !{i32 1, i32 1, i32 1}
125// CHECK: ![[MD72]] = !{!"read_only", !"write_only", !"read_write"}
126// CHECK: ![[MD73]] = !{!"ROImage", !"WOImage", !"RWImage"}
127// CHECK: ![[MD74]] = !{!"image1d_t", !"image1d_t", !"image1d_t"}
128// CHECK: ![[MD75]] = !{!"", !"", !""}
129// ARGINFO: ![[MD76]] = !{!"ro", !"wo", !"rw"}
Yaxun Liuba28cba2016-06-22 14:56:35 +0000130