[PATCH] R600: Add macro defs for all supported OpenCL extensions

Tom Stellard thomas.stellard at amd.com
Tue Mar 24 12:45:50 PDT 2015


---
 lib/Basic/Targets.cpp    | 13 +++++++++++--
 test/Preprocessor/init.c |  9 ++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index d5602b6..6e8bf2e 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -1701,8 +1701,17 @@ public:
   void getTargetDefines(const LangOptions &Opts,
                         MacroBuilder &Builder) const override {
     Builder.defineMacro("__R600__");
-    if (GPU >= GK_SOUTHERN_ISLANDS && Opts.OpenCL)
-      Builder.defineMacro("cl_khr_fp64");
+    if (Opts.OpenCL) {
+      if (GPU >= GK_SOUTHERN_ISLANDS)
+        Builder.defineMacro("cl_khr_fp64");
+      if (GPU >= GK_NORTHERN_ISLANDS) {
+        Builder.defineMacro("cl_khr_byte_addressable_store");
+        Builder.defineMacro("cl_khr_global_int32_base_atomics");
+        Builder.defineMacro("cl_khr_global_int32_extended_atomics");
+        Builder.defineMacro("cl_khr_local_int32_base_atomics");
+        Builder.defineMacro("cl_khr_local_int32_extended_atomics");
+      }
+    }
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c
index ad63d01..d3ebacb 100644
--- a/test/Preprocessor/init.c
+++ b/test/Preprocessor/init.c
@@ -6592,8 +6592,15 @@
 // PPC-DARWIN:#define __powerpc__ 1
 // PPC-DARWIN:#define __ppc__ 1
 //
-// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=amdgcn < /dev/null | FileCheck -check-prefix AMDGCN %s
+// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=amdgcn < /dev/null | FileCheck -check-prefix AMDGCN --check-prefix AMDGPU %s
+// RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=r600 -target-cpu caicos < /dev/null | FileCheck --check-prefix AMDGPU %s
+//
+// AMDGPU:#define cl_khr_byte_addressable_store 1
 // AMDGCN:#define cl_khr_fp64 1
+// AMDGPU:#define cl_khr_global_int32_base_atomics 1
+// AMDGPU:#define cl_khr_global_int32_extended_atomics 1
+// AMDGPU:#define cl_khr_local_int32_base_atomics 1
+// AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix S390X %s
 //
-- 
2.0.4




More information about the cfe-commits mailing list