Topotuna created this revision. Topotuna added a reviewer: Anastasia. Herald added subscribers: ldrumm, yaxunl. Topotuna requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Modifies OpenCL 3.0 optional core feature macro definitions so that they are set analogously in C++ for OpenCL 2021. This change aims to achieve compatibility between C++ for OpenCL 2021 and OpenCL 3.0. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D108704 Files: clang/lib/Headers/opencl-c-base.h clang/test/Headers/opencl-c-header.cl clang/test/SemaOpenCL/features.cl Index: clang/test/SemaOpenCL/features.cl =================================================================== --- clang/test/SemaOpenCL/features.cl +++ clang/test/SemaOpenCL/features.cl @@ -6,6 +6,14 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \ // RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=-all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES // For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL // versions don't define feature macros accidentally and CL2.0 don't define them without header @@ -15,7 +23,7 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES -// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CLC++ \ +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // Note that __opencl_c_int64 is always defined assuming Index: clang/test/Headers/opencl-c-header.cl =================================================================== --- clang/test/Headers/opencl-c-header.cl +++ clang/test/Headers/opencl-c-header.cl @@ -175,13 +175,13 @@ #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // OpenCL C features. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #if __opencl_c_atomic_scope_all_devices != 1 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices" #endif -#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #ifndef __opencl_c_pipes #error "Feature macro __opencl_c_pipes should be defined" @@ -262,6 +262,6 @@ #error "Incorrect feature macro __opencl_c_subgroups define" #endif -#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #endif // defined(__SPIR__) Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -30,7 +30,7 @@ #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // Define feature macros for OpenCL C 2.0 -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #define __opencl_c_pipes 1 #define __opencl_c_generic_address_space 1 #define __opencl_c_work_group_collective_functions 1 @@ -45,12 +45,12 @@ #endif // Define header-only feature macros for OpenCL C 3.0. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // For the SPIR target all features are supported. #if defined(__SPIR__) #define __opencl_c_atomic_scope_all_devices 1 #endif // defined(__SPIR__) -#endif // (__OPENCL_C_VERSION__ == 300) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // built-in scalar data types:
Index: clang/test/SemaOpenCL/features.cl =================================================================== --- clang/test/SemaOpenCL/features.cl +++ clang/test/SemaOpenCL/features.cl @@ -6,6 +6,14 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=+all \ // RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=-all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES +// RUN: %clang_cc1 -triple r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++2021 -cl-ext=+all \ +// RUN: | FileCheck -match-full-lines %s --check-prefix=FEATURES // For OpenCL C 2.0 feature macros are defined only in header, so test that earlier OpenCL // versions don't define feature macros accidentally and CL2.0 don't define them without header @@ -15,7 +23,7 @@ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL2.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES -// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CLC++ \ +// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=clc++1.0 \ // RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES // Note that __opencl_c_int64 is always defined assuming Index: clang/test/Headers/opencl-c-header.cl =================================================================== --- clang/test/Headers/opencl-c-header.cl +++ clang/test/Headers/opencl-c-header.cl @@ -175,13 +175,13 @@ #endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // OpenCL C features. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #if __opencl_c_atomic_scope_all_devices != 1 #error "Incorrectly defined feature macro __opencl_c_atomic_scope_all_devices" #endif -#elif (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#elif (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #ifndef __opencl_c_pipes #error "Feature macro __opencl_c_pipes should be defined" @@ -262,6 +262,6 @@ #error "Incorrect feature macro __opencl_c_subgroups define" #endif -#endif //(defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) #endif // defined(__SPIR__) Index: clang/lib/Headers/opencl-c-base.h =================================================================== --- clang/lib/Headers/opencl-c-base.h +++ clang/lib/Headers/opencl-c-base.h @@ -30,7 +30,7 @@ #endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) // Define feature macros for OpenCL C 2.0 -#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ == 200) +#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200) #define __opencl_c_pipes 1 #define __opencl_c_generic_address_space 1 #define __opencl_c_work_group_collective_functions 1 @@ -45,12 +45,12 @@ #endif // Define header-only feature macros for OpenCL C 3.0. -#if (__OPENCL_C_VERSION__ == 300) +#if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // For the SPIR target all features are supported. #if defined(__SPIR__) #define __opencl_c_atomic_scope_all_devices 1 #endif // defined(__SPIR__) -#endif // (__OPENCL_C_VERSION__ == 300) +#endif // (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300) // built-in scalar data types:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits