================
@@ -70,43 +70,89 @@ bool Qualifiers::isStrictSupersetOf(Qualifiers Other) const
{
(hasObjCLifetime() && !Other.hasObjCLifetime()));
}
+// When targeting the OpenCL execution environment, corresponding SYCL and
+// OpenCL address spaces designate the same underlying address space and are
+// mutually convertible.
+static bool isConvertibleOpenCLSYCLAddressSpace(LangAS A, LangAS B) {
+ return (A == LangAS::sycl_global && B == LangAS::opencl_global) ||
+ (A == LangAS::opencl_global && B == LangAS::sycl_global) ||
+ (A == LangAS::sycl_global_device &&
+ B == LangAS::opencl_global_device) ||
+ (A == LangAS::opencl_global_device &&
+ B == LangAS::sycl_global_device) ||
+ (A == LangAS::sycl_global_host && B == LangAS::opencl_global_host) ||
+ (A == LangAS::opencl_global_host && B == LangAS::sycl_global_host) ||
+ (A == LangAS::sycl_local && B == LangAS::opencl_local) ||
+ (A == LangAS::opencl_local && B == LangAS::sycl_local) ||
+ (A == LangAS::sycl_private && B == LangAS::opencl_private) ||
+ (A == LangAS::opencl_private && B == LangAS::sycl_private) ||
+ (A == LangAS::sycl_generic && B == LangAS::opencl_generic) ||
+ (A == LangAS::opencl_generic && B == LangAS::sycl_generic) ||
+ (A == LangAS::sycl_constant && B == LangAS::opencl_constant) ||
+ (A == LangAS::opencl_constant && B == LangAS::sycl_constant);
----------------
tahonermann wrote:
I think this can be expressed in a way that is easier to understand by doing
something like this:
```
enum class MemoryRegion {
Global,
Local,
Private,
Generic,
Constant
};
MemoryRegion getMemoryRegion(LangAS AS) {
if (AS == LangAS::sycl_global || AS == LangAS::opencl_global)
return MemoryRegion::Global;
if (AS == LangAS::sycl_local || AS == LangAS::opencl_local)
return MemoryRegion::Local;
...
}
static bool isConvertibleOpenCLSYCLAddressSpace(LangAS A, LangAS B) {
return getMemoryRegion(A) == getMemoryRegion(B);
}
```
https://github.com/llvm/llvm-project/pull/200849
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits