[cfe-dev] OpenCL vec_step feature implementation

Sebastian Redl sebastian.redl at getdesigned.at
Wed Feb 16 04:04:13 PST 2011


On 15.02.2011, at 18:42, Peter Collingbourne wrote:

> On Tue, Feb 15, 2011 at 05:20:16PM +0200, Benyei, Guy wrote:
>> Hello,
>> 
>> Attached our implementation for the OpenCL vec_step built in function (OpenCL 1.1 specs, 6.11.12), and a test for validating it.
>> We'd like to get your feedback, and eventually we'd like to contribute this code to the open source development trunk.
>> 
>> The vec_step function takes an expression or a type as argument, and returns 1 for scalar types, or the number of vector elements for vector types.
>> Since vec_step might take types as argument, it cannot be implemented as a standard function, it is rather similar to sizeof and alignof expressions. In this implementation, we take advantage of the existing SizeOfAlignOfExpr class and the functions manipulating it, and we add vec_step to this expression class.
>> 
>> I know that the SizeOfAlignOf name is not exactly right after this change; however I still think that this name covers the main feature handled by this class. Calling it SizeOfAlignOfVecStep would be quite long, and might get longer over time. We might change the name to something like UnaryOperatorWithExprOrType - still long and ugly, but generic. I'll be happy to get your ideas about the name.
> 
> TypePropertyExpr (or perhaps UnaryTypePropertyExpr) may be a good
> name, as it reflects the fact that the operator's result reflects some
> property of the (type of the) operand (size, alignment, vector size)
> which I think is the most important characteristic of this family
> of operators.

While this reasoning is correct, there's high potential for confusion with UnaryTypeTraitExpr, which does the same, but has the important difference that type traits cannot be applied to expressions.

Sebastian



More information about the cfe-dev mailing list