Author: Sven van Haastregt Date: 2020-11-05T12:02:59Z New Revision: 8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46
URL: https://github.com/llvm/llvm-project/commit/8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46 DIFF: https://github.com/llvm/llvm-project/commit/8ac9bcc746b9bb4b0ccdd71c6cbeda3b406e7b46.diff LOG: [OpenCL] Support vec_step in C++ for OpenCL mode Enable the vec_step builtin in C++ for OpenCL mode for compatibility with OpenCL C. Differential Revision: https://reviews.llvm.org/D90766 Added: Modified: clang/include/clang/Basic/TokenKinds.def clang/test/CodeGenOpenCLCXX/constexpr.cl Removed: ################################################################################ diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index 7664269fb8da..d8a2016e9caa 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -586,7 +586,7 @@ ALIAS("write_only", __write_only , KEYOPENCLC | KEYOPENCLCXX) 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) diff --git a/clang/test/CodeGenOpenCLCXX/constexpr.cl b/clang/test/CodeGenOpenCLCXX/constexpr.cl index 8c3fad08ea76..8eb9218c8f44 100644 --- a/clang/test/CodeGenOpenCLCXX/constexpr.cl +++ b/clang/test/CodeGenOpenCLCXX/constexpr.cl @@ -52,3 +52,13 @@ const int2 fromConstexprFunc = addOne(int2(2)); 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; +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits