https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/137940

As best as I can see, all NVPTX architectures support the generic address space.

I note there's a FIXME in the target's address space map about 'generic' still 
having to be added to the target but we haven't observed any issues with it 
downstream. The generic address space is mapped to the same target address 
space as default/private (0), but this isn't necessarily a problem for users.

>From fada7821b0eeb3836ddef143fbff4c78abe4a35b Mon Sep 17 00:00:00 2001
From: Fraser Cormack <fra...@codeplay.com>
Date: Wed, 30 Apr 2025 10:13:37 +0100
Subject: [PATCH] [NVPTX] Support the OpenCL generic addrspace feature by
 default

As best as I can see, all NVPTX architectures support the generic
address space.

I note there's a FIXME in the target's address space map about 'generic'
still having to be added to the target but we haven't observed any
issues with it downstream. The generic address space is mapped to the
same target address space as default/private (0), but this isn't
necessarily a problem for users.
---
 clang/lib/Basic/Targets/NVPTX.h             | 2 ++
 clang/test/Misc/nvptx.languageOptsOpenCL.cl | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h
index dc1ecc30980b7..fbb46001b0f90 100644
--- a/clang/lib/Basic/Targets/NVPTX.h
+++ b/clang/lib/Basic/Targets/NVPTX.h
@@ -170,6 +170,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public 
TargetInfo {
     Opts["cl_khr_global_int32_extended_atomics"] = true;
     Opts["cl_khr_local_int32_base_atomics"] = true;
     Opts["cl_khr_local_int32_extended_atomics"] = true;
+
+    Opts["__opencl_c_generic_address_space"] = true;
   }
 
   const llvm::omp::GV &getGridValue() const override {
diff --git a/clang/test/Misc/nvptx.languageOptsOpenCL.cl 
b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
index f479dddffb3ab..2610cfafc257b 100644
--- a/clang/test/Misc/nvptx.languageOptsOpenCL.cl
+++ b/clang/test/Misc/nvptx.languageOptsOpenCL.cl
@@ -132,3 +132,11 @@
 #pragma OPENCL EXTENSION cl_khr_subgroups: enable
 // expected-warning@-1{{unsupported OpenCL extension 'cl_khr_subgroups' - 
ignoring}}
 
+#if (__OPENCL_C_VERSION__ >= 300)
+#ifndef __opencl_c_generic_address_space
+#error "Missing __opencl_c_generic_address_space define"
+#else
+#error "Incorrect __opencl_c_generic_address_space define"
+#endif
+#pragma OPENCL EXTENSION __opencl_c_generic_address_space: enable
+#endif

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to