================
@@ -23,4 +23,20 @@
 #define _CLC_DEF __attribute__((always_inline))
 #endif
 
+#if __OPENCL_C_VERSION__ == CL_VERSION_2_0 ||                                  
\
+    (__OPENCL_C_VERSION__ >= CL_VERSION_3_0 &&                                 
\
+     defined(__opencl_c_generic_address_space))
+#define _CLC_GENERIC_AS_SUPPORTED 1
+// Note that we hard-code the assumption that a non-distinct address space 
means
+// that the target maps the generic address space to the private address space.
+#ifdef __CLC_DISTINCT_GENERIC_ADDRSPACE__
+#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1
+#else
+#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0
+#endif
+#else
----------------
frasercrmck wrote:

Yes, something like that. Thanks for clarifying, I was half wondering if you 
meant adding some new macro definition to clang itself.

I am a bit hesitant to encode actual address space values in libclc as it's 
ultimately up to clang (and may differ depending on the subtarget/CPU), but 
either way unless clang gives us more information we have to encode _some_ kind 
of assumption in libclc. Having some kind of introspection available about the 
address space mappings would be nice but overkill.

It looks like every target uses `private = 0` except for AMDGPU which has 
`private = 5`. For `generic` we have mostly `0` too, except for DirectX and 
SPIR (which I think influences SPIRV?) which use `4`. It's doable using some 
preprocessorr logic, or some defs passed in from CMake as build options, but 
I'd worry a bit about it getting out of sync with the actual compiler.

I think the macro could definitely be better worded to include the assumption 
of "private". Something along the lines of `GENERIC_IS_(NOT_)PRIVATE` or 
whatever. Ultimately this only applies to NVPTX so there's also the possibility 
of using the NVPTX target rather than trying to come up with something general. 
At least if anything goes wrong it would fail at build time.

https://github.com/llvm/llvm-project/pull/137183
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to