[cfe-dev] [OpenCL patch] support for __builtin_astype, __builtin_convert, __builtin_vec_step
Chris Lattner
clattner at apple.com
Fri Mar 18 11:01:13 PDT 2011
On Mar 17, 2011, at 10:09 AM, Anton Lokhmotov wrote:
> Similar to Guy, I'm wondering what's the benefit of representing
> as/convert_type() as nodes in the AST. To me, they are just like other
> built-in functions. [Indeed, convert_type() implementations, especially for
> different rounding and saturation modes, can be quite involved and
> target-specific.]
>
> If we add special support for as/convert_type() to Clang, don't we need to
> add special support for all the other built-in functions as well? (I hope
> not, as we are very sensitive to the size of Clang.)
Hi Anton,
One of the major design goals of clang is for the AST to accurately represent the source code, to enable source analysis tools, static analysis, IDE integration, refactoring etc. As such, as_type shouldn't be represented as a simple C function since it is overloaded.
I'm not familiar with any of the OpenCL implementations that exist, but it seems that the best way to represent this is as either: 1) a function call to a properly overloaded set of functions (with attribute(overload), or 2) as a specific new Expr subclass to represent this.
Defining these in terms of a macro that expands out to a bunch of builtins seems to obfuscate a lot of semantic information.
-Chris
Disclaimer: I'm not an OpenCL expert by any stretch of the imagination.
More information about the cfe-dev
mailing list