xref: /llvm-project/clang/test/SemaOpenCL/features.cl (revision a60b8f468119065f8a6cb4a16598263cb00de0b5)
1// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \
2// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
3// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \
4// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
5// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 \
6// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
7// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \
8// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
9// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=-all \
10// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
11// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \
12// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
13// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 \
14// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
15// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \
16// RUN:   | FileCheck -match-full-lines %s  --check-prefix=FEATURES
17
18// For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL
19// versions don't define feature macros accidentally and CL2.0 don't define them without header
20// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.1 \
21// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
22// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL1.2 \
23// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
24// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \
25// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
26// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \
27// RUN:   | FileCheck -match-full-lines %s  --check-prefix=NO-FEATURES
28
29// For OpenCL C 3.0, header-only features can be disabled using macros.
30// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header \
31// RUN:    -D__undef___opencl_c_work_group_collective_functions=1 \
32// RUN:    -D__undef___opencl_c_atomic_order_seq_cst=1 \
33// RUN:    -D__undef___opencl_c_atomic_scope_device=1 \
34// RUN:    -D__undef___opencl_c_atomic_scope_all_devices=1 \
35// RUN:    -D__undef___opencl_c_read_write_images=1 \
36// RUN:   | FileCheck %s --check-prefix=NO-HEADERONLY-FEATURES
37
38// Note that __opencl_c_int64 is always defined assuming
39// always compiling for FULL OpenCL profile
40
41// FEATURES: #define __opencl_c_3d_image_writes 1
42// FEATURES: #define __opencl_c_atomic_order_acq_rel 1
43// FEATURES: #define __opencl_c_atomic_order_seq_cst 1
44// FEATURES: #define __opencl_c_device_enqueue 1
45// FEATURES: #define __opencl_c_fp64 1
46// FEATURES: #define __opencl_c_generic_address_space 1
47// FEATURES: #define __opencl_c_images 1
48// FEATURES: #define __opencl_c_int64 1
49// FEATURES: #define __opencl_c_pipes 1
50// FEATURES: #define __opencl_c_program_scope_global_variables 1
51// FEATURES: #define __opencl_c_read_write_images 1
52// FEATURES: #define __opencl_c_subgroups 1
53
54// NO-FEATURES: #define __opencl_c_int64 1
55// NO-FEATURES-NOT: #define __opencl_c_3d_image_writes
56// NO-FEATURES-NOT: #define __opencl_c_atomic_order_acq_rel
57// NO-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
58// NO-FEATURES-NOT: #define __opencl_c_device_enqueue
59// NO-FEATURES-NOT: #define __opencl_c_fp64
60// NO-FEATURES-NOT: #define __opencl_c_generic_address_space
61// NO-FEATURES-NOT: #define __opencl_c_images
62// NO-FEATURES-NOT: #define __opencl_c_pipes
63// NO-FEATURES-NOT: #define __opencl_c_program_scope_global_variables
64// NO-FEATURES-NOT: #define __opencl_c_read_write_images
65// NO-FEATURES-NOT: #define __opencl_c_subgroups
66
67// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_work_group_collective_functions
68// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_order_seq_cst
69// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_device
70// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_atomic_scope_all_devices
71// NO-HEADERONLY-FEATURES-NOT: #define __opencl_c_read_write_images
72