OpenCL vec_step feature implementation

Hi Guy,

We'd like to get your feedback, and eventually we'd like to contribute
this code to the open source development trunk.

It's great to see more companies/people contributing to OpenCL support in
Clang!

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.

Agree. In fact, your implementation is very similar to ours :).

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.

Perhaps UnaryOperatorOnExprOrType?

Couple of minor comments inline.

Cheers,
Anton.

Hi,

thanks for the patch!

===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td (revision 125563)
+++ include/clang/Basic/DiagnosticSemaKinds.td (working copy)
...
+def err_vecstep_not_in_opencl : Error<
+ "usage of vec_step operator is allowed in OpenCL only">;

In fact, vec_step is also used in AltiVec (see PIM 2.5.3, where it is
properly called an operator).

Exactly! vec_step for AltiVec can be simply implemented in the header via overloaded functions but the suggested implementation is more correct.
I'll take care of working it with AltiVec also.

- still long and ugly, but generic. I'll be happy to get your ideas about
the name.

Perhaps UnaryOperatorOnExprOrType?

Or UnaryOpOnExprOrType? :slight_smile:

Comment on the patch:

===================================================================
--- include/clang/Sema/Sema.h (revision 125563)
+++ include/clang/Sema/Sema.h (working copy)
@@ -23,6 +23,7 @@
  #include "clang/AST/Expr.h"
  #include "clang/AST/DeclarationName.h"
  #include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/Expr.h"

What about Expr.h included two lines above?