[cfe-dev] [RFC] Re-use OpenCL address space attributes for SYCL

John McCall via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 11 12:56:03 PDT 2020


On 11 Aug 2020, at 8:15, Anastasia Stulova wrote:
> > Alexey is correct that C and C++ require that if a variable x has type
>> T, the expression &x must have type T *. Anything else is not
>> strictly conformant, whether it compiles or not.
>
> Btw OpenCL doesn't violate these rules.

It does.  C requires the type of a variable to be exactly the type
that it was written with, notwithstanding a handful of exceptions
around e.g. parameters of array type or `int x[] = {1,2,3};`).
In OpenCL, a local variable `int x;` has type `__private int`,
and that is not conformant.  And there’s nothing wrong with that,
because OpenCL is its own language and its programs do not need
to conform to the C standard.

> Moreover, it uses conventional
> embedded C address space qualifier logic. It only defines a concrete
> memory hierarchy and adds an inference logic for address spaces that is
> not present in an embedded C extension.

Inferring non-generic address spaces for variables is not conformant
to the Embedded C specification.  The mechanics of address spaces in
OpenCL otherwise conform to the Embedded C specification, but
Embedded C does not change the rules for how unqualified types work.
Unlike OpenCL, Embedded C is a pure language extension: programs
that do not use the extension’s features behave exactly as specified
by the C standard.  Only when an address space is actually uttered
do those rules have any effect.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200811/4adec671/attachment.html>


More information about the cfe-dev mailing list