[PATCH] Add __builtin_convertvector

Hal

__builtin_astype is not a builtin that is recognized by the front-end -- at least Builtins.def does not define it. Is this because one expects to be able to use type cases for this? Note that this does not work in OpenCL, where type casts between vector types are illegal. To implement OpenCL's astype functions, an explicit __builtin_astype (similar to __builtin_convervector) would be handy.

-erik

Hal

__builtin_astype is not a builtin that is recognized by the front-end
-- at least Builtins.def does not define it. Is this because one
expects to be able to use type cases for this?

There are two separate issues here.

1. Like __builtin_astype, __builtin_convertvector needs to be defined as its own token because it needs special parser support (it takes a type name as a parameter).

2. In the patch I actually do add __builtin_convertvector to Builtins.def; the only reason being that it allows __has_builtin to work as expected. If this approach flies, then I was planning to propose a patch to do the same with the other token builtins.

Note that this does
not work in OpenCL, where type casts between vector types are
illegal. To implement OpenCL's astype functions, an explicit
__builtin_astype (similar to __builtin_convervector) would be handy.

OpenCL has a bunch of convert_<type> functions for doing conversions. Some of them could be implemented in terms of __builtin_convertvector :wink: -- nevertheless, __builtin_astype *is* an OpenCL feature, and I don't understand what you're trying to say.

Thanks again,
Hal