[clang] [clang][SYCL] Implement address space attributes for SYCL (PR #200849)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 10:48:16 PDT 2026


================
@@ -576,21 +576,38 @@ class ParsedAttr final
     }
   }
 
-  /// If this is an OpenCL address space attribute, returns its SYCL
-  /// representation in LangAS, otherwise returns default address space.
+  /// If this is a SYCL address space attribute, returns its SYCL
+  /// representation in LangAS.
   LangAS asSYCLLangAS() const {
-    switch (getKind()) {
-    case ParsedAttr::AT_OpenCLGlobalAddressSpace:
+    switch (getParsedKind()) {
+    case ParsedAttr::AT_SYCLGlobalAddressSpace:
       return LangAS::sycl_global;
+    // TODO: OpenCLGlobalDeviceAddressSpace, OpenCLGlobalHostAddressSpace,
+    // sycl_global_device, and sycl_global_host will be removed after
+    // deprecation.
+    // https://discourse.llvm.org/t/rfc-remove-opencl-global-device-and-opencl-global-host-address-space-attributes/90677
     case ParsedAttr::AT_OpenCLGlobalDeviceAddressSpace:
       return LangAS::sycl_global_device;
     case ParsedAttr::AT_OpenCLGlobalHostAddressSpace:
       return LangAS::sycl_global_host;
-    case ParsedAttr::AT_OpenCLLocalAddressSpace:
+    case ParsedAttr::AT_SYCLLocalAddressSpace:
       return LangAS::sycl_local;
-    case ParsedAttr::AT_OpenCLPrivateAddressSpace:
+    case ParsedAttr::AT_SYCLPrivateAddressSpace:
       return LangAS::sycl_private;
+    case ParsedAttr::AT_SYCLGenericAddressSpace:
+      return LangAS::sycl_generic;
+    case ParsedAttr::AT_SYCLConstantAddressSpace:
+      return LangAS::sycl_constant;
+    // The OpenCL address space attributes are available to enable
+    // implicit conversions between OpenCL address space attributes and
+    // SYCL address space attributes when targeting the OpenCL execution
+    // environments.
+    case ParsedAttr::AT_OpenCLGlobalAddressSpace:
+    case ParsedAttr::AT_OpenCLLocalAddressSpace:
+    case ParsedAttr::AT_OpenCLPrivateAddressSpace:
     case ParsedAttr::AT_OpenCLGenericAddressSpace:
+    case ParsedAttr::AT_OpenCLConstantAddressSpace:
+      return asOpenCLLangAS();
----------------
elizabethandrews wrote:

>>The names DO change though? SYglobal vs CLglobal, see ItaniumManglel.cpp in this patch.  

The mangling scheme selected depends on what is returned by [`addressSpaceMapManglingFor` ](https://clang.llvm.org/doxygen/ASTContext_8h_source.html#l03371). When set, `AddrSpaceMapMangling` mangles language address spaces by their mapped number. This is target dependent. SPIR-V, NVPTX etc sets this to true. While host targets like x86 do not. The mangling test in this PR illustrates this. 

So yes for host compilation, the mangled names do change. For device targets, it does not

https://github.com/llvm/llvm-project/pull/200849


More information about the cfe-commits mailing list