[OpenCL patch] support for __builtin_astype, __builtin_convert, __builtin_vec_step

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.

Hi Chris,

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)

Yes, as I mentioned, I view as/convert_<dst_type>(<src_type>) as a family of
built-in functions overloaded on the <src_type> [by declaring them with
__attribute__((overloadable))].

or 2) as a specific new Expr subclass to represent this.

I'm not in favour of this approach because then one would argue that all
OpenCL built-ins should be represented as Expr subclasses. I don't think
there's need for this.

Defining these in terms of a macro that expands out to a bunch of
builtins seems to obfuscate a lot of semantic information.

Agree.

Cheers,
Anton.