]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/Headers/opencl-c-header.cl
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / Headers / opencl-c-header.cl
1 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -cl-std=CL1.1| FileCheck %s
3
4 // CHECK: _Z16convert_char_rtec
5 // CHECK-NOT: _Z3ctzc
6 // CHECK20: _Z3ctzc
7 // CHECK20-NOT: _Z16convert_char_rtec
8 // CHECK-MOD: Reading modules
9
10 // Test including the default header as a module.
11 // The module should be compiled only once and loaded from cache afterwards.
12 // Change the directory mode to read only to make sure no new modules are created.
13 // Check time report to make sure module is used.
14
15 // ===
16 // Clear current directory.
17 // RUN: rm -rf %t
18 // RUN: mkdir -p %t
19
20 // ===
21 // Compile for OpenCL 1.0 for the first time. A module should be generated.
22 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
23 // RUN: chmod u-w %t/opencl_c.pcm
24
25 // ===
26 // Compile for OpenCL 1.0 for the second time. The module should not be re-created.
27 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
28 // RUN: chmod u+w %t/opencl_c.pcm
29 // RUN: mv %t/opencl_c.pcm %t/1_0.pcm
30
31 // ===
32 // Compile for OpenCL 2.0 for the first time. The module should change.
33 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
34 // RUN: not diff %t/1_0.pcm %t/opencl_c.pcm
35 // RUN: chmod u-w %t/opencl_c.pcm
36
37 // ===
38 // Compile for OpenCL 2.0 for the second time. The module should not change.
39 // RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fdisable-module-hash -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
40
41 // Check cached module works for different OpenCL versions.
42 // RUN: rm -rf %t
43 // RUN: mkdir -p %t
44 // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
45 // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
46 // RUN: chmod u-w %t 
47 // RUN: %clang_cc1 -triple spir64-unknown-unknown -emit-llvm -o - -cl-std=CL1.2 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MOD %s
48 // RUN: %clang_cc1 -triple amdgcn--amdhsa -emit-llvm -o - -cl-std=CL2.0 -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -ftime-report %s 2>&1 | FileCheck --check-prefix=CHECK20 --check-prefix=CHECK-MOD %s
49 // RUN: chmod u+w %t
50
51 char f(char x) {
52 #if __OPENCL_C_VERSION__ != CL_VERSION_2_0
53   return convert_char_rte(x);
54 #ifdef NO_HEADER
55   //expected-warning@-2{{implicit declaration of function 'convert_char_rte' is invalid in C99}}
56 #endif //NO_HEADER
57
58 #else //__OPENCL_C_VERSION__
59   return ctz(x);
60 #endif //__OPENCL_C_VERSION__
61 }