OpenCL parsing / type support

Hi,

I know many vendors use clang/llvm for their implementations of OpenCL.

I am wondering if OpenCL parser and types are supported in standard OpenCL distributions or they are strictly proprietary modules.

Thanks,

Marko

Hi Marko,

I'm not an expert, but clang mainline does a bunch of OpenCL features, such as the vector extensions:
http://clang.llvm.org/docs/LanguageExtensions.html#vectors

AFAIK, common opencl implementations have various hacks on top of mainline clang, so I doubt clang mainline will be a compliant implementation out of the box.

-Chris

AFAIK, common opencl implementations have various hacks on
top of mainline clang, so I doubt clang mainline will be a
compliant implementation out of the box.

That's how it appears. For parsing only, what's missing is:

1. address space qualifiers (eg., __global float*, __constant int,
__local char*)
2. function qualifiers (eg, __kernel void foo(...) ),
some builtin types (float4, float8, float16, image2d_t, etc.)
3. image access qualifiers (eg, __read_only, __write_only,
__read_write).

It also seems that clang-cc had some OpenCL support (at least it was listed in the command line parser as an acceptable language), but don't know what was supported.

Marko

AFAIK, common opencl implementations have various hacks on
top of mainline clang, so I doubt clang mainline will be a
compliant implementation out of the box.

That's how it appears. For parsing only, what's missing is:

1. address space qualifiers (eg., __global float*, __constant int,
__local char*)
2. function qualifiers (eg, __kernel void foo(...) ),
some builtin types (float4, float8, float16, image2d_t, etc.)

These are not magic parser features, in the opencl implementations I'm aware of, these are macros that come from an implicit #include. These are #defines for various attributes, __global typically turns into __attribute__((address_space. __kernel turns into attribute(annotate)

3. image access qualifiers (eg, __read_only, __write_only,
__read_write).

I don't know what these do, not familiar enough with OpenCL.

-Chris

1. address space qualifiers (eg., __global float*, __constant int,
__local char*)
2. function qualifiers (eg, __kernel void foo(...) ),
some builtin types (float4, float8, float16, image2d_t, etc.)

These are not magic parser features, in the opencl implementations I'm
aware of, these are macros that come from an implicit #include. These are > #defines for various attributes, __global typically turns into
__attribute__((address_space. __kernel turns into attribute(annotate)

Although not magic parser feature per se, in the case of the address_space attributes this requires modifying clang to accept them nicely in the function prototypes. I have a patch for this for llvm/clang-2.6, and I plan to provided a patch for clang-head soon.

To be more specific, this is about intrinsic prototypes with address spaces, not function prototypes.