[PATCH] D102853: [OpenCL] Align definition of __IMAGE_SUPPORT__ feature macro with OpenCL version and __opencl_c_images feature macro definition
Anton Zabaznov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 20 10:05:37 PDT 2021
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: ldrumm, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102853
Files:
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Preprocessor/predefined-macros.c
clang/test/SemaOpenCL/features.cl
Index: clang/test/SemaOpenCL/features.cl
===================================================================
--- clang/test/SemaOpenCL/features.cl
+++ clang/test/SemaOpenCL/features.cl
@@ -1,9 +1,9 @@
// RUN: %clang_cc1 -triple spir-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \
-// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
+// RUN: | FileCheck -match-full-lines %s --check-prefixes=NO-FEATURES,NO-FEATURES-CL30
// RUN: %clang_cc1 -triple spir-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 r600-unknown-unknown %s -E -dM -o - -x cl -cl-std=CL3.0 \
-// RUN: | FileCheck -match-full-lines %s --check-prefix=NO-FEATURES
+// RUN: | FileCheck -match-full-lines %s --check-prefixes=NO-FEATURES,NO-FEATURES-CL30
// 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
@@ -21,6 +21,7 @@
// Note that __opencl_c_int64 is always defined assuming
// always compiling for FULL OpenCL profile
+// FEATURES: #define __IMAGE_SUPPORT__ 1
// FEATURES: #define __opencl_c_3d_image_writes 1
// FEATURES: #define __opencl_c_atomic_order_acq_rel 1
// FEATURES: #define __opencl_c_atomic_order_seq_cst 1
@@ -46,3 +47,4 @@
// NO-FEATURES-NOT: __opencl_c_program_scope_global_variables
// NO-FEATURES-NOT: __opencl_c_read_write_images
// NO-FEATURES-NOT: __opencl_c_subgroups
+// NO-FEATURES-CL30-NOT: __IMAGE_SUPPORT__
Index: clang/test/Preprocessor/predefined-macros.c
===================================================================
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -188,14 +188,12 @@
// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir-unknown-unknown \
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR
-// CHECK-SPIR-DAG: #define __IMAGE_SUPPORT__ 1
// CHECK-SPIR-DAG: #define __SPIR__ 1
// CHECK-SPIR-DAG: #define __SPIR32__ 1
// CHECK-SPIR-NOT: #define __SPIR64__ 1
// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple spir64-unknown-unknown \
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-SPIR64
-// CHECK-SPIR64-DAG: #define __IMAGE_SUPPORT__ 1
// CHECK-SPIR64-DAG: #define __SPIR__ 1
// CHECK-SPIR64-DAG: #define __SPIR64__ 1
// CHECK-SPIR64-NOT: #define __SPIR32__ 1
Index: clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -603,9 +603,9 @@
/// InitializeOpenCLFeatureTestMacros - Define OpenCL macros based on target
/// settings and language version
-void InitializeOpenCLFeatureTestMacros(const TargetInfo &TI,
- const LangOptions &Opts,
- MacroBuilder &Builder) {
+static void InitializeOpenCLFeatureTestMacros(const TargetInfo &TI,
+ const LangOptions &Opts,
+ MacroBuilder &Builder) {
const llvm::StringMap<bool> &OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
// FIXME: OpenCL options which affect language semantics/syntax
// should be moved into LangOptions.
@@ -622,6 +622,10 @@
// Assume compiling for FULL profile
Builder.defineMacro("__opencl_c_int64");
+
+ if (Opts.OpenCLCPlusPlus || Opts.OpenCLVersion < 300 ||
+ TI.hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_images"))
+ Builder.defineMacro("__IMAGE_SUPPORT__");
}
static void InitializePredefinedMacros(const TargetInfo &TI,
@@ -1159,13 +1163,9 @@
}
// OpenCL definitions.
- if (LangOpts.OpenCL) {
+ if (LangOpts.OpenCL)
InitializeOpenCLFeatureTestMacros(TI, LangOpts, Builder);
- if (TI.getTriple().isSPIR())
- Builder.defineMacro("__IMAGE_SUPPORT__");
- }
-
if (TI.hasInt128Type() && LangOpts.CPlusPlus && LangOpts.GNUMode) {
// For each extended integer type, g++ defines a macro mapping the
// index of the type (0 in this case) in some list of extended types
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102853.346775.patch
Type: text/x-patch
Size: 4230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210520/5470358f/attachment.bin>
More information about the cfe-commits
mailing list