| 1 | // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify | FileCheck %s |
| 2 | // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.1 | FileCheck %s |
| 3 | // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=CL1.2 | FileCheck %s |
| 4 | // RUN: %clang_cc1 -O0 -triple spir-unknown-unknown -internal-isystem ../../lib/Headers -include opencl-c.h -emit-llvm -o - %s -verify -cl-std=c++ | FileCheck %s --check-prefix=CHECK20 |
| 5 | |
| 6 | // Test including the default header as a module. |
| 7 | // The module should be compiled only once and loaded from cache afterwards. |
| 8 | // Change the directory mode to read only to make sure no new modules are created. |
| 9 | // Check time report to make sure module is used. |
| 10 | // Check that some builtins occur in the generated IR when called. |
| 11 | |
| 12 | // === |
| 13 | // Clear current directory. |
| 14 | // RUN: rm -rf %t |
| 15 | // RUN: mkdir -p %t |
| 16 | |
| 17 | // === |
| 18 | // Compile for OpenCL 1.0 for the first time. A module should be generated. |
| 19 | // 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 |
| 20 | // RUN: chmod u-w %t/opencl_c.pcm |
| 21 | |
| 22 | // === |
| 23 | // Compile for OpenCL 1.0 for the second time. The module should not be re-created. |
| 24 | // 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 |
| 25 | // RUN: chmod u+w %t/opencl_c.pcm |
| 26 | // RUN: mv %t/opencl_c.pcm %t/1_0.pcm |
| 27 | |
| 28 | // === |
| 29 | // Compile for OpenCL 2.0 for the first time. The module should change. |
| 30 | // RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -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 |
| 31 | // RUN: not diff %t/1_0.pcm %t/opencl_c.pcm |
| 32 | // RUN: chmod u-w %t/opencl_c.pcm |
| 33 | |
| 34 | // === |
| 35 | // Compile for OpenCL 2.0 for the second time. The module should not change. |
| 36 | // RUN: %clang_cc1 -triple spir-unknown-unknown -O0 -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 |
| 37 | |
| 38 | // Check cached module works for different OpenCL versions. |
| 39 | // RUN: rm -rf %t |
| 40 | // RUN: mkdir -p %t |
| 41 | // 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 |
| 42 | // RUN: %clang_cc1 -triple amdgcn--amdhsa -O0 -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 |
| 43 | // RUN: chmod u-w %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 -O0 -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 | |
| 48 | // Verify that called builtins occur in the generated IR. |
| 49 | |
| 50 | // CHECK-NOT: intel_sub_group_avc_mce_get_default_inter_base_multi_reference_penalty |
| 51 | // CHECK-NOT: ndrange_t |
| 52 | // CHECK20: ndrange_t |
| 53 | // CHECK: _Z16convert_char_rtec |
| 54 | // CHECK-NOT: _Z3ctzc |
| 55 | // CHECK20: _Z3ctzc |
| 56 | // CHECK20: _Z16convert_char_rtec |
| 57 | char f(char x) { |
| 58 | // Check functionality from OpenCL 2.0 onwards |
| 59 | #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == CL_VERSION_2_0) |
| 60 | ndrange_t t; |
| 61 | x = ctz(x); |
| 62 | #endif //__OPENCL_C_VERSION__ |
| 63 | return convert_char_rte(x); |
| 64 | } |
| 65 | |
| 66 | // Verify that a builtin using a write_only image3d_t type is available |
| 67 | // from OpenCL 2.0 onwards. |
| 68 | |
| 69 | // CHECK20: _Z12write_imagef14ocl_image3d_wo |
| 70 | #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0) |
| 71 | void test_image3dwo(write_only image3d_t img) { |
| 72 | write_imagef(img, (0), (0.0f)); |
| 73 | } |
| 74 | #endif //__OPENCL_C_VERSION__ |
| 75 | |
| 76 | // Verify that non-builtin cl_intel_planar_yuv extension is defined from |
| 77 | // OpenCL 1.2 onwards. |
| 78 | #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) |
| 79 | // expected-no-diagnostics |
| 80 | #ifndef cl_intel_planar_yuv |
| 81 | #error "Missing cl_intel_planar_yuv define" |
| 82 | #endif |
| 83 | #else //__OPENCL_C_VERSION__ |
| 84 | // expected-warning@+2{{unknown OpenCL extension 'cl_intel_planar_yuv' - ignoring}} |
| 85 | #endif //__OPENCL_C_VERSION__ |
| 86 | #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable |
| 87 | |
| 88 | // CHECK-MOD: Reading modules |
| 89 | |