xref: /llvm-project/clang/test/CodeGenOpenCL/pipe_types_mangling.cl (revision a5de66c4c50b5dec085ffbcd2afefd47f3f18d7f)
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++1.0 -o - %s | FileCheck %s --check-prefixes=LINUX
2// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=clc++1.0 -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=LINUX
4// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=OCLWINDOWS
5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space -o - %s | FileCheck %s --check-prefixes=LINUX
6// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++2021 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -o - %s | FileCheck %s --check-prefixes=LINUX
7// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space -o - %s | FileCheck %s --check-prefixes=LINUX
8// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space -o - %s -DWIN | FileCheck %s --check-prefixes=OCLWINDOWS
9// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables -o - %s | FileCheck %s --check-prefixes=LINUX
10// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables,-__opencl_c_device_enqueue -o - %s -DWIN | FileCheck %s --check-prefixes=OCLWINDOWS
11
12typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
13typedef int __attribute__((ext_vector_type(4))) int4;
14
15__attribute__((overloadable))
16void test1(read_only pipe int p) {
17// LINUX: define{{.*}} void @_Z5test18ocl_pipe
18// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
19// OCLWINDOWS: define dso_local void @"?test1@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
20}
21
22__attribute__((overloadable))
23void test2(write_only pipe float p) {
24// LINUX: define{{.*}} void @_Z5test28ocl_pipe
25// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
26// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
27}
28
29#ifdef WIN
30// It isn't possible to overload on pipe types in Linux mode
31// because the OCL specification on the Itanium ABI has a specified mangling
32// for the entire class of types, and thus doesn't take element type or read/write
33// into account. Thus, both would result in the same mangling, which is an IR-CodeGen
34// error. Our windows implementation of this mangling doesn't have that problem,
35// so we can test it here.
36__attribute__((overloadable))
37void test2(read_only pipe int p) {
38// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
39// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
40}
41#endif
42
43__attribute__((overloadable))
44void test3(read_only pipe const int p) {
45// LINUX: define{{.*}} void @_Z5test38ocl_pipe
46// WINDOWS: define dso_local void @"?test3@@YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
47// OCLWINDOWS: define dso_local void @"?test3@@$$J0YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
48}
49
50__attribute__((overloadable))
51void test4(read_only pipe uchar3 p) {
52// LINUX: define{{.*}} void @_Z5test48ocl_pipe
53// WINDOWS: define dso_local void @"?test4@@YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
54// OCLWINDOWS: define dso_local void @"?test4@@$$J0YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
55}
56
57__attribute__((overloadable))
58void test5(read_only pipe int4 p) {
59// LINUX: define{{.*}} void @_Z5test58ocl_pipe
60// WINDOWS: define dso_local void @"?test5@@YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
61// OCLWINDOWS: define dso_local void @"?test5@@$$J0YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
62}
63
64typedef read_only pipe int MyPipe;
65kernel void test6(MyPipe p) {
66// LINUX: define{{.*}} spir_kernel void @test6
67// WINDOWS: define dso_local spir_kernel void @test6
68// OCLWINDOWS: define dso_local spir_kernel void @test6
69}
70
71struct Person {
72  const char *Name;
73  bool isFemale;
74  int ID;
75};
76
77__attribute__((overloadable))
78void test_reserved_read_pipe(global struct Person *SDst,
79                             read_only pipe struct Person SPipe) {
80// LINUX: define{{.*}} void @_Z23test_reserved_read_pipePU8CLglobal6Person8ocl_pipe
81// WINDOWS: define dso_local void @"?test_reserved_read_pipe@@YAXPEAU?$_ASCLglobal@$$CAUPerson@@@__clang@@U?$ocl_pipe@UPerson@@$00@2@@Z"
82// OCLWINDOWS: define dso_local void @"?test_reserved_read_pipe@@$$J0YAXPEAU?$_ASCLglobal@$$CAUPerson@@@__clang@@U?$ocl_pipe@UPerson@@$00@2@@Z"
83}
84