[cfe-dev] OpenCL parsing / type support

Chris Lattner clattner at apple.com
Sun Mar 14 10:30:33 PDT 2010


On Mar 12, 2010, at 2:59 AM, Anton Lokhmotov wrote:
>> From: Chris Lattner
>> Sent: 11 March 2010 18:05
>> 
>> I'm fine with improving infrastructure to support this, but there is no
>> reason to add first class language support for things like __kernel.
>> It just makes the compiler more complex for no reason.  If you're
>> interested in driving this, a better thing to focus on would be to
>> provide an implementation of the *implicit include* which provides the
>> #defines etc.
> Yes, I'm interested in driving this.  I didn't mean to suggest that an implicit header is necessarily a bad idea.  I agree that the things that can be supported this way, such as vector types and address (and hopefully function) qualifiers, should be supported this way.  Where do you think such a header should live (e.g. which subdirectory of Clang)?

clang/lib/Headers would make sense to me.

> It appears, however, that certain things cannot be supported only with headers.  For example, the OpenCL standard restricts usage of the half type (16-bit floating point) to declaring a pointer to a buffer that contains half values; such pointers cannot be dereferenced.  In other words, half behaves similar to void.  However, sizeof(half) must be 2.  (Obviously, if someone knows an ingenious quirk to solve this conundrum, I'd be interested to hear.) 

You're right, 'half float' is something that clang will need to support directly.  I think that Anton has some patches coming to add at least backend support for half float.
> 
> The standard also specifies many restrictions which the compiler should check as semantic analyses, possibly in a few separate passes.  Also, there are some alignment restrictions which perhaps call for a special OpenCL triple (since the target should be OpenCL-compliant)?

Yep, sounds right.  These checks should be based on the existing LangOptions.OpenCL bit, and that bit should be set when using an OpenCL target triple.  I'm not sure how much of that is wired up.

-Chris



More information about the cfe-dev mailing list