[cfe-dev] OpenCL vec_step feature implementation

Peter Collingbourne peter at pcc.me.uk
Tue Feb 15 09:42:20 PST 2011


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.

I don't think we need to mention in the type name that the operator can
take an expression argument as it is common knowledge that sizeof and
alignof can take an expression argument (at least if you are writing
a compiler you should know this!)

Thanks,
-- 
Peter



More information about the cfe-dev mailing list