[PATCH] D90766: [OpenCL] Support vec_step in C++ for OpenCL mode

Sven van Haastregt via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 4 07:52:53 PST 2020


svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: dexonsmith, yaxunl.
svenvh requested review of this revision.

For compatibility with OpenCL C, enable the `vec_step` builtin in C++ for OpenCL mode.


https://reviews.llvm.org/D90766

Files:
  clang/include/clang/Basic/TokenKinds.def
  clang/test/CodeGenOpenCLCXX/constexpr.cl


Index: clang/test/CodeGenOpenCLCXX/constexpr.cl
===================================================================
--- clang/test/CodeGenOpenCLCXX/constexpr.cl
+++ clang/test/CodeGenOpenCLCXX/constexpr.cl
@@ -52,3 +52,13 @@
 kernel void vecEval2(global int2 *x) {
   *x = fromConstexprFunc;
 }
+
+// Test evaluation of vec_step
+// CHECK-LABEL: define spir_kernel void @vec_step_test
+// CHECK: store i32 6
+constexpr int vsize1 = vec_step(fromConstexprFunc);
+constexpr int vsize2 = vec_step(int4);
+
+kernel void vec_step_test(global int *x) {
+  *x = vsize1 + vsize2;
+}
Index: clang/include/clang/Basic/TokenKinds.def
===================================================================
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -586,7 +586,7 @@
 ALIAS("read_write", __read_write    , KEYOPENCLC | KEYOPENCLCXX)
 // OpenCL builtins
 KEYWORD(__builtin_astype            , KEYOPENCLC | KEYOPENCLCXX)
-UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYALTIVEC | KEYZVECTOR)
+UNARY_EXPR_OR_TYPE_TRAIT(vec_step, VecStep, KEYOPENCLC | KEYOPENCLCXX | KEYALTIVEC | KEYZVECTOR)
 #define GENERIC_IMAGE_TYPE(ImgType, Id) KEYWORD(ImgType##_t, KEYOPENCLC | KEYOPENCLCXX)
 #include "clang/Basic/OpenCLImageTypes.def"
 KEYWORD(pipe                        , KEYOPENCLC | KEYOPENCLCXX)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90766.302846.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201104/c7024c07/attachment.bin>


More information about the cfe-commits mailing list