r303844 - [OpenCL] Added regression test on invalid vector initialization.
Author: echuraev Date: Thu May 25 01:55:02 2017 New Revision: 303844 URL: http://llvm.org/viewvc/llvm-project?rev=303844&view=rev Log: [OpenCL] Added regression test on invalid vector initialization. Summary: This patch increases code coverage. Reviewers: Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, bader, yaxunl Differential Revision: https://reviews.llvm.org/D33489 Modified: cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl Modified: cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl?rev=303844&r1=303843&r2=303844&view=diff == --- cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl (original) +++ cfe/trunk/test/SemaOpenCL/vector_literals_invalid.cl Thu May 25 01:55:02 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify %s typedef __attribute__(( ext_vector_type(4) )) float float4; typedef __attribute__(( ext_vector_type(4) )) int int4; @@ -10,4 +10,5 @@ void vector_literals_invalid() int4 b = (int4)(1,2,3,4,5); // expected-error{{excess elements in vector}} ((float4)(1.0f))++; // expected-error{{cannot increment value of type 'float4'}} int8 d = (int8)(a,(float4)(1)); // expected-error{{initializing 'int' with an expression of incompatible type 'float4'}} + ((int4)(0)).x = 8; // expected-error{{expression is not assignable}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r303846 - [OpenCL] reserve_id_t cannot be used as argument to kernel function
Author: echuraev Date: Thu May 25 02:18:37 2017 New Revision: 303846 URL: http://llvm.org/viewvc/llvm-project?rev=303846&view=rev Log: [OpenCL] reserve_id_t cannot be used as argument to kernel function Reviewers: Anastasia Reviewed By: Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D33483 Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=303846&r1=303845&r2=303846&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu May 25 02:18:37 2017 @@ -7920,10 +7920,7 @@ static OpenCLParamType getOpenCLKernelPa if (PT->isImageType()) return PtrKernelParam; - if (PT->isBooleanType()) -return InvalidKernelParam; - - if (PT->isEventT()) + if (PT->isBooleanType() || PT->isEventT() || PT->isReserveIDT()) return InvalidKernelParam; // OpenCL extension spec v1.2 s9.5: Modified: cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl?rev=303846&r1=303845&r2=303846&view=diff == --- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original) +++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Thu May 25 02:18:37 2017 @@ -3,6 +3,11 @@ global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}} global reserve_id_t rid; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}} +extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}} + +kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}} +} + void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of reference type}} } void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r303986 - [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element
Author: echuraev Date: Fri May 26 08:30:26 2017 New Revision: 303986 URL: http://llvm.org/viewvc/llvm-project?rev=303986&view=rev Log: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element Reviewers: Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, bader, yaxunl Differential Revision: https://reviews.llvm.org/D33353 Added: cfe/trunk/test/SemaOpenCL/arithmetic-conversions.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaOpenCL/cond.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=303986&r1=303985&r2=303986&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri May 26 08:30:26 2017 @@ -8314,6 +8314,9 @@ def err_opencl_bitfields : Error< "bit-fields are not supported in OpenCL">; def err_opencl_vla : Error< "variable length arrays are not supported in OpenCL">; +def err_opencl_scalar_type_rank_greater_than_vector_type : Error< +"scalar operand type has greater rank than the type of the vector " +"element. (%0 and %1)">; def err_bad_kernel_param_type : Error< "%0 cannot be used as the type of a kernel parameter">; def err_record_with_pointers_kernel_param : Error< Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=303986&r1=303985&r2=303986&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May 26 08:30:26 2017 @@ -8074,28 +8074,38 @@ QualType Sema::InvalidLogicalVectorOpera /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except /// for float->int. /// +/// OpenCL V2.0 6.2.6.p2: +/// An error shall occur if any scalar operand type has greater rank +/// than the type of the vector element. +/// /// \param scalar - if non-null, actually perform the conversions /// \return true if the operation fails (but without diagnosing the failure) static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, - QualType vectorTy) { + QualType vectorTy, + unsigned &DiagID) { // The conversion to apply to the scalar before splatting it, // if necessary. CastKind scalarCast = CK_Invalid; if (vectorEltTy->isIntegralType(S.Context)) { -if (!scalarTy->isIntegralType(S.Context)) +if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() || +(scalarTy->isIntegerType() && + S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) { + DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type; return true; -if (S.getLangOpts().OpenCL && -S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0) +} +if (!scalarTy->isIntegralType(S.Context)) return true; scalarCast = CK_IntegralCast; } else if (vectorEltTy->isRealFloatingType()) { if (scalarTy->isRealFloatingType()) { if (S.getLangOpts().OpenCL && - S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) + S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) { +DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type; return true; + } scalarCast = CK_FloatingCast; } else if (scalarTy->isIntegralType(S.Context)) @@ -8341,10 +8351,12 @@ QualType Sema::CheckVectorOperands(ExprR // If there's a vector type and a scalar, try to convert the scalar to // the vector element type and splat. + unsigned DiagID = diag::err_typecheck_vector_not_convertable; if (!RHSVecType) { if (isa(LHSVecType)) { if (!tryVectorConvertAndSplat(*this, &RHS, RHSType, -LHSVecType->getElementType(), LHSType)) +LHSVecType->getElementType(), LHSType, +DiagID)) return LHSType; } else { if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS)) @@ -8355,7 +8367,7 @@ QualType Sema::CheckVectorOperands(ExprR if (isa(RHSVecType)) { if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS), LHSType, RHSVecType->getElementType(), -RHSType)) +RHSType, DiagID)) return RHSType; } else { if (LHS.get()->getValueKind() == VK_LValue || @@ -8431,7 +8443,7 @@ QualType
r304134 - [OpenCL] Test on half immediate support.
Author: echuraev Date: Mon May 29 02:44:22 2017 New Revision: 304134 URL: http://llvm.org/viewvc/llvm-project?rev=304134&view=rev Log: [OpenCL] Test on half immediate support. Reviewers: Anastasia Reviewed By: Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D33592 Modified: cfe/trunk/test/CodeGenOpenCL/half.cl Modified: cfe/trunk/test/CodeGenOpenCL/half.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/half.cl?rev=304134&r1=304133&r2=304134&view=diff == --- cfe/trunk/test/CodeGenOpenCL/half.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/half.cl Mon May 29 02:44:22 2017 @@ -21,3 +21,20 @@ half test_inc(half x) { return ++x; } + +__attribute__((overloadable)) int min(int, int); +__attribute__((overloadable)) half min(half, half); +__attribute__((overloadable)) float min(float, float); + +__kernel void foo( __global half* buf, __global float* buf2 ) +{ +buf[0] = min( buf[0], 1.5h ); +// CHECK: half 0xH3E00 +buf[0] = min( buf2[0], 1.5f ); +// CHECK: float 1.50e+00 + +const half one = 1.; +buf[1] = min( buf[1], one ); +// CHECK: half 0xH3EAB +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304191 - [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element
Author: echuraev Date: Tue May 30 00:32:03 2017 New Revision: 304191 URL: http://llvm.org/viewvc/llvm-project?rev=304191&view=rev Log: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element Summary: This is the fix for patch https://reviews.llvm.org/D33353 @uweigand, could you please verify that everything will be good on SystemZ? I added triple spir-unknown-unknown. Thank you in advance! Reviewers: uweigand Reviewed By: uweigand Subscribers: yaxunl, cfe-commits, bader, Anastasia, uweigand Differential Revision: https://reviews.llvm.org/D33648 Added: cfe/trunk/test/SemaOpenCL/arithmetic-conversions.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/test/SemaOpenCL/cond.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304191&r1=304190&r2=304191&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 30 00:32:03 2017 @@ -8312,6 +8312,9 @@ def err_opencl_bitfields : Error< "bit-fields are not supported in OpenCL">; def err_opencl_vla : Error< "variable length arrays are not supported in OpenCL">; +def err_opencl_scalar_type_rank_greater_than_vector_type : Error< +"scalar operand type has greater rank than the type of the vector " +"element. (%0 and %1)">; def err_bad_kernel_param_type : Error< "%0 cannot be used as the type of a kernel parameter">; def err_record_with_pointers_kernel_param : Error< Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=304191&r1=304190&r2=304191&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue May 30 00:32:03 2017 @@ -8074,28 +8074,38 @@ QualType Sema::InvalidLogicalVectorOpera /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except /// for float->int. /// +/// OpenCL V2.0 6.2.6.p2: +/// An error shall occur if any scalar operand type has greater rank +/// than the type of the vector element. +/// /// \param scalar - if non-null, actually perform the conversions /// \return true if the operation fails (but without diagnosing the failure) static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, - QualType vectorTy) { + QualType vectorTy, + unsigned &DiagID) { // The conversion to apply to the scalar before splatting it, // if necessary. CastKind scalarCast = CK_Invalid; if (vectorEltTy->isIntegralType(S.Context)) { -if (!scalarTy->isIntegralType(S.Context)) +if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() || +(scalarTy->isIntegerType() && + S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) { + DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type; return true; -if (S.getLangOpts().OpenCL && -S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0) +} +if (!scalarTy->isIntegralType(S.Context)) return true; scalarCast = CK_IntegralCast; } else if (vectorEltTy->isRealFloatingType()) { if (scalarTy->isRealFloatingType()) { if (S.getLangOpts().OpenCL && - S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) + S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) { +DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type; return true; + } scalarCast = CK_FloatingCast; } else if (scalarTy->isIntegralType(S.Context)) @@ -8341,10 +8351,12 @@ QualType Sema::CheckVectorOperands(ExprR // If there's a vector type and a scalar, try to convert the scalar to // the vector element type and splat. + unsigned DiagID = diag::err_typecheck_vector_not_convertable; if (!RHSVecType) { if (isa(LHSVecType)) { if (!tryVectorConvertAndSplat(*this, &RHS, RHSType, -LHSVecType->getElementType(), LHSType)) +LHSVecType->getElementType(), LHSType, +DiagID)) return LHSType; } else { if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS)) @@ -8355,7 +8367,7 @@ QualType Sema::CheckVectorOperands(ExprR if (isa(RHSVecType)) { if (!tryVectorConvertAndSplat(*this, (IsCompAssign ? nullptr : &LHS), LHSType, RHSVecType->getElementType(), -
r304193 - [OpenCL] Added diagnostic for implicit declaration of function in OpenCL
Author: echuraev Date: Tue May 30 00:57:52 2017 New Revision: 304193 URL: http://llvm.org/viewvc/llvm-project?rev=304193&view=rev Log: [OpenCL] Added diagnostic for implicit declaration of function in OpenCL Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D31745 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304193&r1=304192&r2=304193&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 30 00:57:52 2017 @@ -8317,6 +8317,8 @@ def err_opencl_scalar_type_rank_greater_ "element. (%0 and %1)">; def err_bad_kernel_param_type : Error< "%0 cannot be used as the type of a kernel parameter">; +def err_opencl_implicit_function_decl : Error< + "implicit declaration of function %0 is invalid in OpenCL">; def err_record_with_pointers_kernel_param : Error< "%select{struct|union}0 kernel parameters may not contain pointers">; def note_within_field_of_type : Note< Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304193&r1=304192&r2=304193&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 30 00:57:52 2017 @@ -12509,6 +12509,9 @@ NamedDecl *Sema::ImplicitlyDefineFunctio unsigned diag_id; if (II.getName().startswith("__builtin_")) diag_id = diag::warn_builtin_unknown; + // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported. + else if (getLangOpts().OpenCL) +diag_id = diag::err_opencl_implicit_function_decl; else if (getLangOpts().C99) diag_id = diag::ext_implicit_function_decl; else Modified: cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl?rev=304193&r1=304192&r2=304193&view=diff == --- cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl (original) +++ cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl Tue May 30 00:57:52 2017 @@ -4,13 +4,13 @@ kernel void dse_builtins() { int tmp; - enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-warning{{implicit declaration of function 'enqueue_kernel' is invalid in C99}} + enqueue_kernel(tmp, tmp, tmp, ^(void) { // expected-error{{implicit declaration of function 'enqueue_kernel' is invalid in OpenCL}} return; }); - unsigned size = get_kernel_work_group_size(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_work_group_size' is invalid in C99}} + unsigned size = get_kernel_work_group_size(^(void) { // expected-error{{implicit declaration of function 'get_kernel_work_group_size' is invalid in OpenCL}} return; }); - size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-warning{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in C99}} + size = get_kernel_preferred_work_group_size_multiple(^(void) { // expected-error{{implicit declaration of function 'get_kernel_preferred_work_group_size_multiple' is invalid in OpenCL}} return; }); } @@ -18,27 +18,48 @@ kernel void dse_builtins() { void pipe_builtins() { int tmp; - read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'read_pipe' is invalid in C99}} - write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'write_pipe' is invalid in C99}} - - reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_read_pipe' is invalid in C99}} - reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'reserve_write_pipe' is invalid in C99}} - - work_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_read_pipe' is invalid in C99}} - work_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'work_group_reserve_write_pipe' is invalid in C99}} - - sub_group_reserve_write_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_write_pipe' is invalid in C99}} - sub_group_reserve_read_pipe(tmp, tmp); // expected-warning{{implicit declaration of function 'sub_group_reserve_read_pipe' is invalid in C99}} - - commit_read_pipe(tmp, tmp); // expected-warning{{implicit declaratio
r290171 - [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.
Author: echuraev Date: Tue Dec 20 03:15:21 2016 New Revision: 290171 URL: http://llvm.org/viewvc/llvm-project?rev=290171&view=rev Log: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand. Summary: Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t. Reviewers: Anastasia Subscribers: cfe-commits, yaxunl, bader Differential Revision: https://reviews.llvm.org/D27569 Added: cfe/trunk/test/CodeGenOpenCL/null_queue.cl cfe/trunk/test/SemaOpenCL/null_queue.cl cfe/trunk/test/SemaOpenCL/queue_t_overload.cl Modified: cfe/trunk/include/clang/AST/OperationKinds.def cfe/trunk/include/clang/Sema/Initialization.h cfe/trunk/include/clang/Sema/Overload.h cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/include/clang/AST/OperationKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=290171&r1=290170&r2=290171&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.def (original) +++ cfe/trunk/include/clang/AST/OperationKinds.def Tue Dec 20 03:15:21 2016 @@ -321,6 +321,9 @@ CAST_OPERATION(BuiltinFnToFnPtr) // Convert a zero value for OpenCL event_t initialization. CAST_OPERATION(ZeroToOCLEvent) +// Convert a zero value for OpenCL queue_t initialization. +CAST_OPERATION(ZeroToOCLQueue) + // Convert a pointer to a different address space. CAST_OPERATION(AddressSpaceConversion) Modified: cfe/trunk/include/clang/Sema/Initialization.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=290171&r1=290170&r2=290171&view=diff == --- cfe/trunk/include/clang/Sema/Initialization.h (original) +++ cfe/trunk/include/clang/Sema/Initialization.h Tue Dec 20 03:15:21 2016 @@ -751,6 +751,8 @@ public: SK_StdInitializerListConstructorCall, /// \brief Initialize an OpenCL sampler from an integer. SK_OCLSamplerInit, +/// \brief Initialize queue_t from 0. +SK_OCLZeroQueue, /// \brief Passing zero to a function where OpenCL event_t is expected. SK_OCLZeroEvent }; @@ -1148,6 +1150,9 @@ public: /// constant. void AddOCLZeroEventStep(QualType T); + /// \brief Add a step to initialize an OpenCL queue_t from 0. + void AddOCLZeroQueueStep(QualType T); + /// \brief Add steps to unwrap a initializer list for a reference around a /// single element and rewrap it at the end. void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic); Modified: cfe/trunk/include/clang/Sema/Overload.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290171&r1=290170&r2=290171&view=diff == --- cfe/trunk/include/clang/Sema/Overload.h (original) +++ cfe/trunk/include/clang/Sema/Overload.h Tue Dec 20 03:15:21 2016 @@ -83,6 +83,7 @@ namespace clang { ICK_TransparentUnionConversion, ///< Transparent Union Conversions ICK_Writeback_Conversion, ///< Objective-C ARC writeback conversion ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10) +ICK_Zero_Queue_Conversion, ///< Zero constant to queue ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++ ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between pointers /// with incompatible types Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=290171&r1=290170&r2=290171&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Dec 20 03:15:21 2016 @@ -8340,6 +8340,7 @@ bool IntExprEvaluator::VisitCastExpr(con case CK_IntegralComplexToFloatingComplex: case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: + case CK_ZeroToOCLQueue: case CK_NonAtomicToAtomic: case CK_AddressSpaceConversion: case CK_IntToOCLSampler: @@ -8837,6 +8838,7 @@ bool ComplexExprEvaluator::VisitCastExpr case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: case CK_ZeroToOCLEvent: + case CK_ZeroToOCLQueue: case CK_NonAtomicToAtomic: case CK_AddressSpaceConversion: case CK_IntToOCLSampler: Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=290171&r1=290170&r2=290171&view=diff == --- cfe/trunk/lib/C
r290431 - Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand."
Author: echuraev Date: Fri Dec 23 08:55:49 2016 New Revision: 290431 URL: http://llvm.org/viewvc/llvm-project?rev=290431&view=rev Log: Fix problems in "[OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand." Summary: Fixed warnings in commit: https://reviews.llvm.org/rL290171 Reviewers: djasper, Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D27981 Added: cfe/trunk/test/CodeGenOpenCL/null_queue.cl cfe/trunk/test/SemaOpenCL/null_queue.cl cfe/trunk/test/SemaOpenCL/queue_t_overload.cl Modified: cfe/trunk/include/clang/AST/OperationKinds.def cfe/trunk/include/clang/Sema/Initialization.h cfe/trunk/include/clang/Sema/Overload.h cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/lib/CodeGen/CGExprAgg.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGExprConstant.cpp cfe/trunk/lib/CodeGen/CGExprScalar.cpp cfe/trunk/lib/Edit/RewriteObjCFoundationAPI.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Modified: cfe/trunk/include/clang/AST/OperationKinds.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OperationKinds.def?rev=290431&r1=290430&r2=290431&view=diff == --- cfe/trunk/include/clang/AST/OperationKinds.def (original) +++ cfe/trunk/include/clang/AST/OperationKinds.def Fri Dec 23 08:55:49 2016 @@ -321,6 +321,9 @@ CAST_OPERATION(BuiltinFnToFnPtr) // Convert a zero value for OpenCL event_t initialization. CAST_OPERATION(ZeroToOCLEvent) +// Convert a zero value for OpenCL queue_t initialization. +CAST_OPERATION(ZeroToOCLQueue) + // Convert a pointer to a different address space. CAST_OPERATION(AddressSpaceConversion) Modified: cfe/trunk/include/clang/Sema/Initialization.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Initialization.h?rev=290431&r1=290430&r2=290431&view=diff == --- cfe/trunk/include/clang/Sema/Initialization.h (original) +++ cfe/trunk/include/clang/Sema/Initialization.h Fri Dec 23 08:55:49 2016 @@ -751,6 +751,8 @@ public: SK_StdInitializerListConstructorCall, /// \brief Initialize an OpenCL sampler from an integer. SK_OCLSamplerInit, +/// \brief Initialize queue_t from 0. +SK_OCLZeroQueue, /// \brief Passing zero to a function where OpenCL event_t is expected. SK_OCLZeroEvent }; @@ -1148,6 +1150,9 @@ public: /// constant. void AddOCLZeroEventStep(QualType T); + /// \brief Add a step to initialize an OpenCL queue_t from 0. + void AddOCLZeroQueueStep(QualType T); + /// \brief Add steps to unwrap a initializer list for a reference around a /// single element and rewrap it at the end. void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic); Modified: cfe/trunk/include/clang/Sema/Overload.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=290431&r1=290430&r2=290431&view=diff == --- cfe/trunk/include/clang/Sema/Overload.h (original) +++ cfe/trunk/include/clang/Sema/Overload.h Fri Dec 23 08:55:49 2016 @@ -83,6 +83,7 @@ namespace clang { ICK_TransparentUnionConversion, ///< Transparent Union Conversions ICK_Writeback_Conversion, ///< Objective-C ARC writeback conversion ICK_Zero_Event_Conversion, ///< Zero constant to event (OpenCL1.2 6.12.10) +ICK_Zero_Queue_Conversion, ///< Zero constant to queue ICK_C_Only_Conversion, ///< Conversions allowed in C, but not C++ ICK_Incompatible_Pointer_Conversion, ///< C-only conversion between pointers /// with incompatible types Modified: cfe/trunk/lib/AST/Expr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=290431&r1=290430&r2=290431&view=diff == --- cfe/trunk/lib/AST/Expr.cpp (original) +++ cfe/trunk/lib/AST/Expr.cpp Fri Dec 23 08:55:49 2016 @@ -1603,6 +1603,7 @@ bool CastExpr::CastConsistency() const { case CK_ARCReclaimReturnedObject: case CK_ARCExtendBlockObject: case CK_ZeroToOCLEvent: + case CK_ZeroToOCLQueue: case CK_IntToOCLSampler: assert(!getType()->isBooleanType() && "unheralded conversion to bool"); goto CheckNoBasePath; Modified: cfe/trunk/lib/AST/ExprConstant.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=290431&r1=290430&r2=290431&view=diff == --- cfe/trunk/lib/AST/ExprConstant.cpp (original) +++ cfe/trunk/
r290436 - [OpenCL] Align fake address space map with the SPIR target maps.
Author: echuraev Date: Fri Dec 23 10:11:25 2016 New Revision: 290436 URL: http://llvm.org/viewvc/llvm-project?rev=290436&view=rev Log: [OpenCL] Align fake address space map with the SPIR target maps. Summary: We compile user opencl kernel code with spir triple. But built-ins are written in OpenCL and we compile it with triple x86_64 to be able to use x86 intrinsics. And we need address spaces to match in both cases. So, we change fake address space map in OpenCL for matching with spir. On CPU address spaces are not really important but we'd like to preserve address space information in order to perform optimizations relying on this info like enhanced alias analysis. Reviewers: pekka.jaaskelainen, Anastasia Subscribers: pekka.jaaskelainen, yaxunl, bader, cfe-commits Differential Revision: https://reviews.llvm.org/D28048 Modified: cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/test/CodeGen/blocks-opencl.cl cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl cfe/trunk/test/CodeGenOpenCL/address-spaces.cl cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl cfe/trunk/test/CodeGenOpenCL/const-str-array-decay.cl cfe/trunk/test/CodeGenOpenCL/constant-addr-space-globals.cl cfe/trunk/test/CodeGenOpenCL/local-initializer-undef.cl cfe/trunk/test/CodeGenOpenCL/local.cl cfe/trunk/test/CodeGenOpenCL/memcpy.cl cfe/trunk/test/CodeGenOpenCL/str_literals.cl cfe/trunk/test/SemaOpenCL/extern.cl Modified: cfe/trunk/lib/AST/ASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=290436&r1=290435&r2=290436&view=diff == --- cfe/trunk/lib/AST/ASTContext.cpp (original) +++ cfe/trunk/lib/AST/ASTContext.cpp Fri Dec 23 10:11:25 2016 @@ -704,8 +704,8 @@ static const LangAS::Map *getAddressSpac // language-specific address space. static const unsigned FakeAddrSpaceMap[] = { 1, // opencl_global - 2, // opencl_local - 3, // opencl_constant + 3, // opencl_local + 2, // opencl_constant 4, // opencl_generic 5, // cuda_device 6, // cuda_constant Modified: cfe/trunk/test/CodeGen/blocks-opencl.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/blocks-opencl.cl?rev=290436&r1=290435&r2=290436&view=diff == --- cfe/trunk/test/CodeGen/blocks-opencl.cl (original) +++ cfe/trunk/test/CodeGen/blocks-opencl.cl Fri Dec 23 10:11:25 2016 @@ -5,7 +5,7 @@ void dummy(float (^const op)(float)) { } -// CHECK: i8 addrspace(3)* getelementptr inbounds ([9 x i8], [9 x i8] addrspace(3)* @.str, i32 0, i32 0) +// CHECK: i8 addrspace(2)* getelementptr inbounds ([9 x i8], [9 x i8] addrspace(2)* @.str, i32 0, i32 0) kernel void test_block() { Modified: cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl?rev=290436&r1=290435&r2=290436&view=diff == --- cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/address-space-constant-initializers.cl Fri Dec 23 10:11:25 2016 @@ -11,8 +11,8 @@ typedef struct { __constant float* constant_float_ptr; } ConstantArrayPointerStruct; -// CHECK: %struct.ConstantArrayPointerStruct = type { float addrspace(3)* } -// CHECK: addrspace(3) constant %struct.ConstantArrayPointerStruct { float addrspace(3)* bitcast (i8 addrspace(3)* getelementptr (i8, i8 addrspace(3)* bitcast (%struct.ArrayStruct addrspace(3)* @constant_array_struct to i8 addrspace(3)*), i64 4) to float addrspace(3)*) } +// CHECK: %struct.ConstantArrayPointerStruct = type { float addrspace(2)* } +// CHECK: addrspace(2) constant %struct.ConstantArrayPointerStruct { float addrspace(2)* bitcast (i8 addrspace(2)* getelementptr (i8, i8 addrspace(2)* bitcast (%struct.ArrayStruct addrspace(2)* @constant_array_struct to i8 addrspace(2)*), i64 4) to float addrspace(2)*) } // Bug 18567 __constant ConstantArrayPointerStruct constant_array_pointer_struct = { &constant_array_struct.f Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl?rev=290436&r1=290435&r2=290436&view=diff == --- cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl Fri Dec 23 10:11:25 2016 @@ -31,14 +31,14 @@ void f(global int *arg) { } __attribute__((overloadable)) void f(local int *arg) { } -// ASMANG: @_Z1fPU3AS2i +// ASMANG: @_Z1fPU3AS3i // NOASMANG: @_Z1fPU7CLlocali -// OC
r297947 - [OpenCL] Implement as_type operator as alias of __builtin_astype.
Author: echuraev Date: Thu Mar 16 07:15:10 2017 New Revision: 297947 URL: http://llvm.org/viewvc/llvm-project?rev=297947&view=rev Log: [OpenCL] Implement as_type operator as alias of __builtin_astype. Reviewers: Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, yaxunl, bader Differential Revision: https://reviews.llvm.org/D28136 Modified: cfe/trunk/lib/Headers/opencl-c.h cfe/trunk/test/SemaOpenCL/as_type.cl Modified: cfe/trunk/lib/Headers/opencl-c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=297947&r1=297946&r2=297947&view=diff == --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Thu Mar 16 07:15:10 2017 @@ -6584,777 +6584,85 @@ half16 __ovld __cnfn convert_half16_rtz( * OpenCL v1.1/1.2/2.0 s6.2.4.2 - as_type operators * Reinterprets a data type as another data type of the same size */ -char __ovld __cnfn as_char(char); -char __ovld __cnfn as_char(uchar); - -char2 __ovld __cnfn as_char2(char2); -char2 __ovld __cnfn as_char2(uchar2); -char2 __ovld __cnfn as_char2(short); -char2 __ovld __cnfn as_char2(ushort); - -char3 __ovld __cnfn as_char3(char3); -char3 __ovld __cnfn as_char3(char4); -char3 __ovld __cnfn as_char3(uchar3); -char3 __ovld __cnfn as_char3(uchar4); -char3 __ovld __cnfn as_char3(short2); -char3 __ovld __cnfn as_char3(ushort2); -char3 __ovld __cnfn as_char3(int); -char3 __ovld __cnfn as_char3(uint); -char3 __ovld __cnfn as_char3(float); - -char4 __ovld __cnfn as_char4(char3); -char4 __ovld __cnfn as_char4(char4); -char4 __ovld __cnfn as_char4(uchar3); -char4 __ovld __cnfn as_char4(uchar4); -char4 __ovld __cnfn as_char4(short2); -char4 __ovld __cnfn as_char4(ushort2); -char4 __ovld __cnfn as_char4(int); -char4 __ovld __cnfn as_char4(uint); -char4 __ovld __cnfn as_char4(float); - -char8 __ovld __cnfn as_char8(char8); -char8 __ovld __cnfn as_char8(uchar8); -char8 __ovld __cnfn as_char8(short3); -char8 __ovld __cnfn as_char8(short4); -char8 __ovld __cnfn as_char8(ushort3); -char8 __ovld __cnfn as_char8(ushort4); -char8 __ovld __cnfn as_char8(int2); -char8 __ovld __cnfn as_char8(uint2); -char8 __ovld __cnfn as_char8(long); -char8 __ovld __cnfn as_char8(ulong); -char8 __ovld __cnfn as_char8(float2); - -char16 __ovld __cnfn as_char16(char16); -char16 __ovld __cnfn as_char16(uchar16); -char16 __ovld __cnfn as_char16(short8); -char16 __ovld __cnfn as_char16(ushort8); -char16 __ovld __cnfn as_char16(int3); -char16 __ovld __cnfn as_char16(int4); -char16 __ovld __cnfn as_char16(uint3); -char16 __ovld __cnfn as_char16(uint4); -char16 __ovld __cnfn as_char16(long2); -char16 __ovld __cnfn as_char16(ulong2); -char16 __ovld __cnfn as_char16(float3); -char16 __ovld __cnfn as_char16(float4); - -uchar __ovld __cnfn as_uchar(char); -uchar __ovld __cnfn as_uchar(uchar); - -uchar2 __ovld __cnfn as_uchar2(char2); -uchar2 __ovld __cnfn as_uchar2(uchar2); -uchar2 __ovld __cnfn as_uchar2(short); -uchar2 __ovld __cnfn as_uchar2(ushort); - -uchar3 __ovld __cnfn as_uchar3(char3); -uchar3 __ovld __cnfn as_uchar3(char4); -uchar3 __ovld __cnfn as_uchar3(uchar3); -uchar3 __ovld __cnfn as_uchar3(uchar4); -uchar3 __ovld __cnfn as_uchar3(short2); -uchar3 __ovld __cnfn as_uchar3(ushort2); -uchar3 __ovld __cnfn as_uchar3(int); -uchar3 __ovld __cnfn as_uchar3(uint); -uchar3 __ovld __cnfn as_uchar3(float); - -uchar4 __ovld __cnfn as_uchar4(char3); -uchar4 __ovld __cnfn as_uchar4(char4); -uchar4 __ovld __cnfn as_uchar4(uchar3); -uchar4 __ovld __cnfn as_uchar4(uchar4); -uchar4 __ovld __cnfn as_uchar4(short2); -uchar4 __ovld __cnfn as_uchar4(ushort2); -uchar4 __ovld __cnfn as_uchar4(int); -uchar4 __ovld __cnfn as_uchar4(uint); -uchar4 __ovld __cnfn as_uchar4(float); - -uchar8 __ovld __cnfn as_uchar8(char8); -uchar8 __ovld __cnfn as_uchar8(uchar8); -uchar8 __ovld __cnfn as_uchar8(short3); -uchar8 __ovld __cnfn as_uchar8(short4); -uchar8 __ovld __cnfn as_uchar8(ushort3); -uchar8 __ovld __cnfn as_uchar8(ushort4); -uchar8 __ovld __cnfn as_uchar8(int2); -uchar8 __ovld __cnfn as_uchar8(uint2); -uchar8 __ovld __cnfn as_uchar8(long); -uchar8 __ovld __cnfn as_uchar8(ulong); -uchar8 __ovld __cnfn as_uchar8(float2); - -uchar16 __ovld __cnfn as_uchar16(char16); -uchar16 __ovld __cnfn as_uchar16(uchar16); -uchar16 __ovld __cnfn as_uchar16(short8); -uchar16 __ovld __cnfn as_uchar16(ushort8); -uchar16 __ovld __cnfn as_uchar16(int3); -uchar16 __ovld __cnfn as_uchar16(int4); -uchar16 __ovld __cnfn as_uchar16(uint3); -uchar16 __ovld __cnfn as_uchar16(uint4); -uchar16 __ovld __cnfn as_uchar16(long2); -uchar16 __ovld __cnfn as_uchar16(ulong2); -uchar16 __ovld __cnfn as_uchar16(float3); -uchar16 __ovld __cnfn as_uchar16(float4); - -short __ovld __cnfn as_short(char2); -short __ovld __cnfn as_short(uchar2); -short __ovld __cnfn as_short(short); -short __ovld __cnfn as_short(ushort); - -short2 __ovld __cnfn as_short2(char3); -short2 __ovld __cnfn as_short2(char4); -short2 __ovld __cnfn a
r298366 - [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL
Author: echuraev Date: Tue Mar 21 07:55:55 2017 New Revision: 298366 URL: http://llvm.org/viewvc/llvm-project?rev=298366&view=rev Log: [OpenCL] Added implicit conversion rank for overloading functions with vector data type in OpenCL Summary: I added a new rank to ImplicitConversionRank enum to resolve the function overload ambiguity with vector types. Rank of scalar types conversion is lower than vector splat. So, we can choose which function should we call. See test for more details. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30816 Added: cfe/trunk/test/CodeGenOpenCL/overload.cl Removed: cfe/trunk/test/SemaOpenCL/overload_addrspace_resolution.cl Modified: cfe/trunk/include/clang/Sema/Overload.h cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/include/clang/Sema/Overload.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Overload.h?rev=298366&r1=298365&r2=298366&view=diff == --- cfe/trunk/include/clang/Sema/Overload.h (original) +++ cfe/trunk/include/clang/Sema/Overload.h Tue Mar 21 07:55:55 2017 @@ -98,6 +98,7 @@ namespace clang { ICR_Exact_Match = 0, ///< Exact Match ICR_Promotion, ///< Promotion ICR_Conversion, ///< Conversion +ICR_OCL_Scalar_Widening, ///< OpenCL Scalar Widening ICR_Complex_Real_Conversion, ///< Complex <-> Real conversion ICR_Writeback_Conversion,///< ObjC ARC writeback conversion ICR_C_Conversion,///< Conversion only allowed in the C standard. Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=298366&r1=298365&r2=298366&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Mar 21 07:55:55 2017 @@ -131,7 +131,7 @@ ImplicitConversionRank clang::GetConvers ICR_Conversion, ICR_Conversion, ICR_Conversion, -ICR_Conversion, +ICR_OCL_Scalar_Widening, ICR_Complex_Real_Conversion, ICR_Conversion, ICR_Conversion, Added: cfe/trunk/test/CodeGenOpenCL/overload.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/overload.cl?rev=298366&view=auto == --- cfe/trunk/test/CodeGenOpenCL/overload.cl (added) +++ cfe/trunk/test/CodeGenOpenCL/overload.cl Tue Mar 21 07:55:55 2017 @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown %s | FileCheck %s + +typedef short short4 __attribute__((ext_vector_type(4))); + +// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16>, <4 x i16>, <4 x i16>) +short4 __attribute__ ((overloadable)) clamp(short4 x, short4 minval, short4 maxval); +// CHECK-DAG: declare spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16>, i16 signext, i16 signext) +short4 __attribute__ ((overloadable)) clamp(short4 x, short minval, short maxval); +void __attribute__((overloadable)) foo(global int *a, global int *b); +void __attribute__((overloadable)) foo(generic int *a, generic int *b); +void __attribute__((overloadable)) bar(generic int *global *a, generic int *global *b); +void __attribute__((overloadable)) bar(generic int *generic *a, generic int *generic *b); + +// Checking address space resolution +void kernel test1() { + global int *a; + global int *b; + generic int *c; + local int *d; + generic int *generic *gengen; + generic int *local *genloc; + generic int *global *genglob; + // CHECK-DAG: call spir_func void @_Z3fooPU3AS1iS0_(i32 addrspace(1)* undef, i32 addrspace(1)* undef) + foo(a, b); + // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* undef, i32 addrspace(4)* undef) + foo(b, c); + // CHECK-DAG: call spir_func void @_Z3fooPU3AS4iS0_(i32 addrspace(4)* undef, i32 addrspace(4)* undef) + foo(a, d); + + // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* addrspace(4)* undef, i32 addrspace(4)* addrspace(4)* undef) + bar(gengen, genloc); + // CHECK-DAG: call spir_func void @_Z3barPU3AS4PU3AS4iS2_(i32 addrspace(4)* addrspace(4)* undef, i32 addrspace(4)* addrspace(4)* undef) + bar(gengen, genglob); + // CHECK-DAG: call spir_func void @_Z3barPU3AS1PU3AS4iS2_(i32 addrspace(4)* addrspace(1)* undef, i32 addrspace(4)* addrspace(1)* undef) + bar(genglob, genglob); +} + +// Checking vector vs scalar resolution +void kernel test2() { + short4 e0=0; + + // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sss(<4 x i16> zeroinitializer, i16 signext 0, i16 signext 255) + clamp(e0, 0, 255); + // CHECK-DAG: call spir_func <4 x i16> @_Z5clampDv4_sS_S_(<4 x i16> zeroinitializer, <4 x i16> zeroinitializer, <4 x i16> zeroinitializer)
r298369 - [OpenCL] Added diagnostic for checking length of vector
Author: echuraev Date: Tue Mar 21 08:20:57 2017 New Revision: 298369 URL: http://llvm.org/viewvc/llvm-project?rev=298369&view=rev Log: [OpenCL] Added diagnostic for checking length of vector Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30937 Added: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExprMember.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298369&r1=298368&r2=298369&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 21 08:20:57 2017 @@ -8236,6 +8236,8 @@ def err_opencl_ptrptr_kernel_param : Err def err_kernel_arg_address_space : Error< "pointer arguments to kernel functions must reside in '__global', " "'__constant' or '__local' address space">; +def err_opencl_ext_vector_component_invalid_length : Error< + "vector component access has invalid length %0. Supported: 1,2,3,4,8,16.">; def err_opencl_function_variable : Error< "%select{non-kernel function|function scope}0 variable cannot be declared in %1 address space">; def err_static_function_scope : Error< Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=298369&r1=298368&r2=298369&view=diff == --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original) +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 21 08:20:57 2017 @@ -284,6 +284,14 @@ IsRGBA(char c) { } } +// OpenCL v1.1, s6.1.7 +// The component swizzle length must be in accordance with the acceptable +// vector sizes. +static bool IsValidOpenCLComponentSwizzleLength(unsigned len) +{ + return (len >= 1 && len <= 4) || len == 8 || len == 16; +} + /// Check an ext-vector component access expression. /// /// VK should be set in advance to the value kind of the base @@ -376,6 +384,19 @@ CheckExtVectorComponent(Sema &S, QualTyp } } + if (!HalvingSwizzle) { +unsigned SwizzleLength = CompName->getLength(); + +if (HexSwizzle) + SwizzleLength--; + +if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) { + S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length) +<< SwizzleLength << SourceRange(CompLoc); + return QualType(); +} + } + // The component accessor looks fine - now we need to compute the actual type. // The vector type is implied by the component accessor. For example, // vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc. Added: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=298369&view=auto == --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (added) +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Mar 21 08:20:57 2017 @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +typedef float float8 __attribute__((ext_vector_type(8))); + +void foo() { +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0); + +f2.s01234; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +f2.xyzxy; // expected-error {{vector component access has invalid length 5. Supported: 1,2,3,4,8,16}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r298838 - [OpenCL] Extended mapping of parcing CodeGen arguments
Author: echuraev Date: Mon Mar 27 05:38:01 2017 New Revision: 298838 URL: http://llvm.org/viewvc/llvm-project?rev=298838&view=rev Log: [OpenCL] Extended mapping of parcing CodeGen arguments Summary: Enable cl_mad_enamle and cl_no_signed_zeros options when user turns on cl_unsafe_math_optimizations or cl_fast_relaxed_math options. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D31324 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=298838&r1=298837&r2=298838&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Mar 27 05:38:01 2017 @@ -573,7 +573,9 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.DiscardValueNames = Args.hasArg(OPT_discard_value_names); Opts.DisableTailCalls = Args.hasArg(OPT_mdisable_tail_calls); Opts.FloatABI = Args.getLastArgValue(OPT_mfloat_abi); - Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable); + Opts.LessPreciseFPMAD = Args.hasArg(OPT_cl_mad_enable) || + Args.hasArg(OPT_cl_unsafe_math_optimizations) || + Args.hasArg(OPT_cl_fast_relaxed_math); Opts.LimitFloatPrecision = Args.getLastArgValue(OPT_mlimit_float_precision); Opts.NoInfsFPMath = (Args.hasArg(OPT_menable_no_infinities) || Args.hasArg(OPT_cl_finite_math_only) || @@ -583,7 +585,9 @@ static bool ParseCodeGenArgs(CodeGenOpti Args.hasArg(OPT_cl_finite_math_only) || Args.hasArg(OPT_cl_fast_relaxed_math)); Opts.NoSignedZeros = (Args.hasArg(OPT_fno_signed_zeros) || -Args.hasArg(OPT_cl_no_signed_zeros)); +Args.hasArg(OPT_cl_no_signed_zeros) || +Args.hasArg(OPT_cl_unsafe_math_optimizations) || +Args.hasArg(OPT_cl_fast_relaxed_math)); Opts.FlushDenorm = Args.hasArg(OPT_cl_denorms_are_zero); Opts.CorrectlyRoundedDivSqrt = Args.hasArg(OPT_cl_fp32_correctly_rounded_divide_sqrt); Modified: cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl?rev=298838&r1=298837&r2=298838&view=diff == --- cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/relaxed-fpmath.cl Mon Mar 27 05:38:01 2017 @@ -2,33 +2,54 @@ // RUN: %clang_cc1 %s -emit-llvm -cl-fast-relaxed-math -o - | FileCheck %s -check-prefix=FAST // RUN: %clang_cc1 %s -emit-llvm -cl-finite-math-only -o - | FileCheck %s -check-prefix=FINITE // RUN: %clang_cc1 %s -emit-llvm -cl-unsafe-math-optimizations -o - | FileCheck %s -check-prefix=UNSAFE - -typedef __attribute__(( ext_vector_type(4) )) float float4; +// RUN: %clang_cc1 %s -emit-llvm -cl-mad-enable -o - | FileCheck %s -check-prefix=MAD +// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s -check-prefix=NOSIGNED float spscalardiv(float a, float b) { // CHECK: @spscalardiv( - // NORMAL: fdiv float + // NORMAL: fdiv float // FAST: fdiv fast float // FINITE: fdiv nnan ninf float - // UNSAFE: fdiv nnan float + // UNSAFE: fdiv nnan nsz float + // MAD: fdiv float + // NOSIGNED: fdiv nsz float return a / b; } // CHECK: attributes +// NORMAL: "less-precise-fpmad"="false" // NORMAL: "no-infs-fp-math"="false" // NORMAL: "no-nans-fp-math"="false" +// NORMAL: "no-signed-zeros-fp-math"="false" // NORMAL: "unsafe-fp-math"="false" +// FAST: "less-precise-fpmad"="true" // FAST: "no-infs-fp-math"="true" // FAST: "no-nans-fp-math"="true" +// FAST: "no-signed-zeros-fp-math"="true" // FAST: "unsafe-fp-math"="true" +// FINITE: "less-precise-fpmad"="false" // FINITE: "no-infs-fp-math"="true" // FINITE: "no-nans-fp-math"="true" +// FINITE: "no-signed-zeros-fp-math"="false" // FINITE: "unsafe-fp-math"="false" +// UNSAFE: "less-precise-fpmad"="true" // UNSAFE: "no-infs-fp-math"="false" // UNSAFE: "no-nans-fp-math"="true" +// UNSAFE: "no-signed-zeros-fp-math"="true" // UNSAFE: "unsafe-fp-math"="true" +// MAD: "less-precise-fpmad"="true" +// MAD: "no-infs-fp-math"="false" +// MAD: "no-nans-fp-math"="false" +// MAD: "no-signed-zeros-fp-math"="false" +// MAD: "unsafe-fp-math"="false" + +// NOSIGNED: "less-precise-fpmad"="false" +// NOSIGNED: "no-infs-fp-math"="false" +// NOSIGNED: "no-nans-fp-math"="false" +// NOSIGNED: "no-signed-zeros-fp-math"="true" +// NOSIGNED: "unsafe-fp-math"="false" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lis
r298976 - [OpenCL] Added parsing for OpenCL vector types.
Author: echuraev Date: Wed Mar 29 00:08:18 2017 New Revision: 298976 URL: http://llvm.org/viewvc/llvm-project?rev=298976&view=rev Log: [OpenCL] Added parsing for OpenCL vector types. Reviewers: cfe-commits, Anastasia Reviewed By: Anastasia Subscribers: yaxunl, bader Differential Revision: https://reviews.llvm.org/D31183 Added: cfe/trunk/test/Parser/vector-cast-define.cl Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseExpr.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298976&r1=298975&r2=298976&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017 @@ -1449,10 +1449,12 @@ private: ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast); + TypeCastState isTypeCast, + bool isVectorLiteral = false); ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand = false, - TypeCastState isTypeCast = NotTypeCast); + TypeCastState isTypeCast = NotTypeCast, + bool isVectorLiteral = false); /// Returns true if the next token cannot start an expression. bool isNotExpressionStart(); Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298976&r1=298975&r2=298976&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017 @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { bool NotCastExpr; ExprResult Res = ParseCastExpression(isUnaryExpression, isAddressOfOperand, NotCastExpr, - isTypeCast); + isTypeCast, + isVectorLiteral); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); return Res; @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); NotCastExpr = false; @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, isTypeCast == IsTypeCast, CastTy, RParenLoc); +if (isVectorLiteral) +return Res; + switch (ParenExprType) { case SimpleExpr: break;// Nothing else to do. case CompoundStmt: break; // Nothing else to do. @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc); } + if (Tok.is(tok::l_paren)) { +// This could be OpenCL vector Literals +if (getLangOpts().OpenCL) +{ + TypeResult Ty; + { +InMessageExpressionRAIIObject InMessage(*this, false); +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); + } + if(Ty.isInvalid()) + { + return ExprError(); + } + QualType QT = Ty.get().get().getCanonicalType(); + if (QT->isVectorType()) + { +// We parsed '(' vector-type-name ')' followed by '(' + +// Parse the cast-expression that follows it next. +// isVectorLiteral = true will make sure we don't parse any +// Postfix expression yet +Result = ParseCastExpression(/*isUnaryExpression=*/false, + /*isAddressOfOperand=*/false, + /*isTypeCast=*/IsTypeCast, + /*isVectorLiteral=*/true); +
Re: r298976 - [OpenCL] Added parsing for OpenCL vector types.
I see it. I'm reverting this patch and I'll investigate why it has happend. 2017-03-29 8:43 GMT+03:00 Dean Michael Berris : > This seems to have broken multiple builds. > > On Wed, Mar 29, 2017 at 4:20 PM Egor Churaev via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: echuraev >> Date: Wed Mar 29 00:08:18 2017 >> New Revision: 298976 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=298976&view=rev >> Log: >> [OpenCL] Added parsing for OpenCL vector types. >> >> Reviewers: cfe-commits, Anastasia >> >> Reviewed By: Anastasia >> >> Subscribers: yaxunl, bader >> >> Differential Revision: https://reviews.llvm.org/D31183 >> >> Added: >> cfe/trunk/test/Parser/vector-cast-define.cl >> Modified: >> cfe/trunk/include/clang/Parse/Parser.h >> cfe/trunk/lib/Parse/ParseExpr.cpp >> >> Modified: cfe/trunk/include/clang/Parse/Parser.h >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/ >> clang/Parse/Parser.h?rev=298976&r1=298975&r2=298976&view=diff >> >> == >> --- cfe/trunk/include/clang/Parse/Parser.h (original) >> +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:08:18 2017 >> @@ -1449,10 +1449,12 @@ private: >>ExprResult ParseCastExpression(bool isUnaryExpression, >> bool isAddressOfOperand, >> bool &NotCastExpr, >> - TypeCastState isTypeCast); >> + TypeCastState isTypeCast, >> + bool isVectorLiteral = false); >>ExprResult ParseCastExpression(bool isUnaryExpression, >> bool isAddressOfOperand = false, >> - TypeCastState isTypeCast = NotTypeCast); >> + TypeCastState isTypeCast = NotTypeCast, >> + bool isVectorLiteral = false); >> >>/// Returns true if the next token cannot start an expression. >>bool isNotExpressionStart(); >> >> Modified: cfe/trunk/lib/Parse/ParseExpr.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ >> ParseExpr.cpp?rev=298976&r1=298975&r2=298976&view=diff >> >> == >> --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) >> +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:08:18 2017 >> @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR >> /// >> ExprResult Parser::ParseCastExpression(bool isUnaryExpression, >> bool isAddressOfOperand, >> - TypeCastState isTypeCast) { >> + TypeCastState isTypeCast, >> + bool isVectorLiteral) { >>bool NotCastExpr; >>ExprResult Res = ParseCastExpression(isUnaryExpression, >> isAddressOfOperand, >> NotCastExpr, >> - isTypeCast); >> + isTypeCast, >> + isVectorLiteral); >>if (NotCastExpr) >> Diag(Tok, diag::err_expected_expression); >>return Res; >> @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public >> ExprResult Parser::ParseCastExpression(bool isUnaryExpression, >> bool isAddressOfOperand, >> bool &NotCastExpr, >> - TypeCastState isTypeCast) { >> + TypeCastState isTypeCast, >> + bool isVectorLiteral) { >>ExprResult Res; >>tok::TokenKind SavedKind = Tok.getKind(); >>NotCastExpr = false; >> @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b >> Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, >> isTypeCast == IsTypeCast, CastTy, >> RParenLoc); >> >> +if (isVectorLiteral) >> +return Res; >> + >> switch (ParenExprType) { >> case SimpleExpr: break;// Nothing else to do. >> case CompoundStmt: break; // Nothing else to do. >> @@ -2350,6 +2356,48 @@ Parser::ParseParen
r298978 - Reverted r298976 [OpenCL] Added parsing for OpenCL vector types.
Author: echuraev Date: Wed Mar 29 00:40:45 2017 New Revision: 298978 URL: http://llvm.org/viewvc/llvm-project?rev=298978&view=rev Log: Reverted r298976 [OpenCL] Added parsing for OpenCL vector types. Removed: cfe/trunk/test/Parser/vector-cast-define.cl Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseExpr.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298978&r1=298977&r2=298978&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 00:40:45 2017 @@ -1449,12 +1449,10 @@ private: ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast, - bool isVectorLiteral = false); + TypeCastState isTypeCast); ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand = false, - TypeCastState isTypeCast = NotTypeCast, - bool isVectorLiteral = false); + TypeCastState isTypeCast = NotTypeCast); /// Returns true if the next token cannot start an expression. bool isNotExpressionStart(); Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298978&r1=298977&r2=298978&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 00:40:45 2017 @@ -473,14 +473,12 @@ Parser::ParseRHSOfBinaryExpression(ExprR /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, - TypeCastState isTypeCast, - bool isVectorLiteral) { + TypeCastState isTypeCast) { bool NotCastExpr; ExprResult Res = ParseCastExpression(isUnaryExpression, isAddressOfOperand, NotCastExpr, - isTypeCast, - isVectorLiteral); + isTypeCast); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); return Res; @@ -696,8 +694,7 @@ class CastExpressionIdValidator : public ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast, - bool isVectorLiteral) { + TypeCastState isTypeCast) { ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); NotCastExpr = false; @@ -725,9 +722,6 @@ ExprResult Parser::ParseCastExpression(b Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, isTypeCast == IsTypeCast, CastTy, RParenLoc); -if (isVectorLiteral) -return Res; - switch (ParenExprType) { case SimpleExpr: break;// Nothing else to do. case CompoundStmt: break; // Nothing else to do. @@ -2356,48 +2350,6 @@ Parser::ParseParenExpression(ParenParseO return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc); } - if (Tok.is(tok::l_paren)) { -// This could be OpenCL vector Literals -if (getLangOpts().OpenCL) -{ - TypeResult Ty; - { -InMessageExpressionRAIIObject InMessage(*this, false); -Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); - } - if(Ty.isInvalid()) - { - return ExprError(); - } - QualType QT = Ty.get().get().getCanonicalType(); - if (QT->isVectorType()) - { -// We parsed '(' vector-type-name ')' followed by '(' - -// Parse the cast-expression that follows it next. -// isVectorLiteral = true will make sure we don't parse any -// Postfix expression yet -Result = ParseCastExpression(/*isUnaryExpression=*/false, - /*isAddressOfOperand=*/false, - /*isTypeCast=*/IsTypeCast, - /*isVectorLiteral=*/true); - -if (!Result.isInvalid()) { - Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, -
r298992 - Reapplied r298976 [OpenCL] Added parsing for OpenCL vector types.
Author: echuraev Date: Wed Mar 29 07:09:39 2017 New Revision: 298992 URL: http://llvm.org/viewvc/llvm-project?rev=298992&view=rev Log: Reapplied r298976 [OpenCL] Added parsing for OpenCL vector types. Added: cfe/trunk/test/Parser/vector-cast-define.cl Modified: cfe/trunk/include/clang/Parse/Parser.h cfe/trunk/lib/Parse/ParseExpr.cpp Modified: cfe/trunk/include/clang/Parse/Parser.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=298992&r1=298991&r2=298992&view=diff == --- cfe/trunk/include/clang/Parse/Parser.h (original) +++ cfe/trunk/include/clang/Parse/Parser.h Wed Mar 29 07:09:39 2017 @@ -1449,10 +1449,12 @@ private: ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast); + TypeCastState isTypeCast, + bool isVectorLiteral = false); ExprResult ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand = false, - TypeCastState isTypeCast = NotTypeCast); + TypeCastState isTypeCast = NotTypeCast, + bool isVectorLiteral = false); /// Returns true if the next token cannot start an expression. bool isNotExpressionStart(); Modified: cfe/trunk/lib/Parse/ParseExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=298992&r1=298991&r2=298992&view=diff == --- cfe/trunk/lib/Parse/ParseExpr.cpp (original) +++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed Mar 29 07:09:39 2017 @@ -473,12 +473,14 @@ Parser::ParseRHSOfBinaryExpression(ExprR /// ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { bool NotCastExpr; ExprResult Res = ParseCastExpression(isUnaryExpression, isAddressOfOperand, NotCastExpr, - isTypeCast); + isTypeCast, + isVectorLiteral); if (NotCastExpr) Diag(Tok, diag::err_expected_expression); return Res; @@ -694,7 +696,8 @@ class CastExpressionIdValidator : public ExprResult Parser::ParseCastExpression(bool isUnaryExpression, bool isAddressOfOperand, bool &NotCastExpr, - TypeCastState isTypeCast) { + TypeCastState isTypeCast, + bool isVectorLiteral) { ExprResult Res; tok::TokenKind SavedKind = Tok.getKind(); NotCastExpr = false; @@ -722,6 +725,9 @@ ExprResult Parser::ParseCastExpression(b Res = ParseParenExpression(ParenExprType, false/*stopIfCastExr*/, isTypeCast == IsTypeCast, CastTy, RParenLoc); +if (isVectorLiteral) +return Res; + switch (ParenExprType) { case SimpleExpr: break;// Nothing else to do. case CompoundStmt: break; // Nothing else to do. @@ -2350,6 +2356,48 @@ Parser::ParseParenExpression(ParenParseO return ParseCompoundLiteralExpression(Ty.get(), OpenLoc, RParenLoc); } + if (Tok.is(tok::l_paren)) { +// This could be OpenCL vector Literals +if (getLangOpts().OpenCL) +{ + TypeResult Ty; + { +InMessageExpressionRAIIObject InMessage(*this, false); +Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); + } + if(Ty.isInvalid()) + { + return ExprError(); + } + QualType QT = Ty.get().get().getCanonicalType(); + if (QT->isVectorType()) + { +// We parsed '(' vector-type-name ')' followed by '(' + +// Parse the cast-expression that follows it next. +// isVectorLiteral = true will make sure we don't parse any +// Postfix expression yet +Result = ParseCastExpression(/*isUnaryExpression=*/false, + /*isAddressOfOperand=*/false, + /*isTypeCast=*/IsTypeCast, + /*isVectorLiteral=*/true); + +if (!Result.isInvalid()) { + Result = Actions.ActOnCastExpr(getCurScope(), OpenLoc, +
r299192 - [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args
Author: echuraev Date: Fri Mar 31 05:14:52 2017 New Revision: 299192 URL: http://llvm.org/viewvc/llvm-project?rev=299192&view=rev Log: [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args Summary: "kernel_arg_type_qual" metadata should contain const/volatile/restrict tags only for pointer types to match the corresponding requirement of the OpenCL specification. OpenCL 2.0 spec 5.9.3 Kernel Object Queries: CL_KERNEL_ARG_TYPE_VOLATILE is returned if the argument is a pointer and the referenced type is declared with the volatile qualifier. [...] Similarly, CL_KERNEL_ARG_TYPE_CONST is returned if the argument is a pointer and the referenced type is declared with the restrict or const qualifier. [...] CL_KERNEL_ARG_TYPE_RESTRICT will be returned if the pointer type is marked restrict. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D31321 Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=299192&r1=299191&r2=299192&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar 31 05:14:52 2017 @@ -610,11 +610,6 @@ static void GenOpenCLArgMetadata(const F argBaseTypeNames.push_back(llvm::MDString::get(Context, baseTypeName)); - // Get argument type qualifiers: - if (ty.isConstQualified()) -typeQuals = "const"; - if (ty.isVolatileQualified()) -typeQuals += typeQuals.empty() ? "volatile" : " volatile"; if (isPipe) typeQuals = "pipe"; } Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl?rev=299192&r1=299191&r2=299192&view=diff == --- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Fri Mar 31 05:14:52 2017 @@ -2,7 +2,8 @@ // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO kernel void foo(__global int * restrict X, const int Y, -volatile int anotherArg, __constant float * restrict Z) { +volatile int anotherArg, __constant float * restrict Z, +__global volatile int * V, __global const int * C) { *X = Y + anotherArg; } // CHECK: define spir_kernel void @foo{{[^!]+}} @@ -60,11 +61,11 @@ kernel void foo5(myImage img1, write_onl // CHECK-NOT: !kernel_arg_name // ARGINFO: !kernel_arg_name ![[MD54:[0-9]+]] -// CHECK: ![[MD11]] = !{i32 1, i32 0, i32 0, i32 2} -// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none"} -// CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"} -// CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"} -// ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"} +// CHECK: ![[MD11]] = !{i32 1, i32 0, i32 0, i32 2, i32 1, i32 1} +// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none"} +// CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*", !"int*", !"int*"} +// CHECK: ![[MD14]] = !{!"restrict", !"", !"", !"restrict const", !"volatile", !"const"} +// ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z", !"V", !"C"} // CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1, i32 1} // CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only", !"read_write"} // CHECK: ![[MD23]] = !{!"image1d_t", !"image2d_t", !"image2d_array_t", !"image1d_t"} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299524 - [OpenCL] Enables passing sampler initializer to function argument
Author: echuraev Date: Wed Apr 5 04:02:56 2017 New Revision: 299524 URL: http://llvm.org/viewvc/llvm-project?rev=299524&view=rev Log: [OpenCL] Enables passing sampler initializer to function argument Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: yaxunl, bader Differential Revision: https://reviews.llvm.org/D31594 Modified: cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/CodeGenOpenCL/sampler.cl cfe/trunk/test/SemaOpenCL/sampler_t.cl Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=299524&r1=299523&r2=299524&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Apr 5 04:02:56 2017 @@ -7174,7 +7174,7 @@ InitializationSequence::Perform(Sema &S, QualType SourceType = Init->getType(); // Case 1 if (Entity.isParameterKind()) { -if (!SourceType->isSamplerT()) { +if (!SourceType->isSamplerT() && !SourceType->isIntegerType()) { S.Diag(Kind.getLocation(), diag::err_sampler_argument_required) << SourceType; break; Modified: cfe/trunk/test/CodeGenOpenCL/sampler.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/sampler.cl?rev=299524&r1=299523&r2=299524&view=diff == --- cfe/trunk/test/CodeGenOpenCL/sampler.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/sampler.cl Wed Apr 5 04:02:56 2017 @@ -54,4 +54,8 @@ kernel void foo(sampler_t smp_par) { fnc4smp(smp_par); // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_par_ptr]] // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + fnc4smp(5); + // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 5) + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) } Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=299524&r1=299523&r2=299524&view=diff == --- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original) +++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Wed Apr 5 04:02:56 2017 @@ -30,7 +30,7 @@ constant sampler_t glb_smp8 = 1.0f; // e constant sampler_t glb_smp9 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}} -void foo(sampler_t); +void foo(sampler_t); // expected-note{{passing argument to parameter here}} constant struct sampler_s { sampler_t smp; // expected-error{{the 'sampler_t' type cannot be used to declare a structure or union field}} @@ -65,7 +65,8 @@ void kernel ker(sampler_t argsmp) { foo(const_smp5); foo(const_smp6); foo(argsmp); - foo(5); // expected-error{{sampler_t variable required - got 'int'}} + foo(5); + foo(5.0f); // expected-error {{passing 'float' to parameter of incompatible type 'sampler_t'}} sampler_t sa[] = {argsmp, const_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}} foo(sa[0]); foo(bad()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299537 - [OpenCL] Extended diagnostics for atomic initialization
Author: echuraev Date: Wed Apr 5 07:47:10 2017 New Revision: 299537 URL: http://llvm.org/viewvc/llvm-project?rev=299537&view=rev Log: [OpenCL] Extended diagnostics for atomic initialization Summary: I saw the same changes in the following review: https://reviews.llvm.org/D17438 I don't know in that way I could determine that atomic variable was initialized by macro ATOMIC_VAR_INIT. Anyway I added check that atomic variables can be initialize only in global scope. I think that we can discuss this change. Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30643 Added: cfe/trunk/test/SemaOpenCL/atomic-init.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaInit.cpp cfe/trunk/test/Parser/opencl-atomics-cl20.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=299537&r1=299536&r2=299537&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 5 07:47:10 2017 @@ -8286,9 +8286,9 @@ def err_opencl_return_value_with_address "return value cannot be qualified with address space">; def err_opencl_constant_no_init : Error< "variable in constant address space must be initialized">; -def err_atomic_init_constant : Error< - "atomic variable can only be assigned to a compile time constant" - " in the declaration statement in the program scope">; +def err_opencl_atomic_init: Error< + "atomic variable can be %select{assigned|initialized}0 to a variable only " + "in global address space">; def err_opencl_implicit_vector_conversion : Error< "implicit conversions between vector types (%0 and %1) are not permitted">; def err_opencl_invalid_type_array : Error< Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=299537&r1=299536&r2=299537&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Apr 5 07:47:10 2017 @@ -11121,7 +11121,7 @@ ExprResult Sema::CreateBuiltinBinOp(Sour if (LHSTy->isAtomicType() || RHSTy->isAtomicType()) { SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd()); if (BO_Assign == Opc) -Diag(OpLoc, diag::err_atomic_init_constant) << SR; +Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR; else ResultTy = InvalidOperands(OpLoc, LHS, RHS); return ExprError(); Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=299537&r1=299536&r2=299537&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Wed Apr 5 07:47:10 2017 @@ -6502,6 +6502,20 @@ InitializationSequence::Perform(Sema &S, << Init->getSourceRange(); } + // OpenCL v2.0 s6.13.11.1. atomic variables can be initialized in global scope + QualType ETy = Entity.getType(); + Qualifiers TyQualifiers = ETy.getQualifiers(); + bool HasGlobalAS = TyQualifiers.hasAddressSpace() && + TyQualifiers.getAddressSpace() == LangAS::opencl_global; + + if (S.getLangOpts().OpenCLVersion >= 200 && + ETy->isAtomicType() && !HasGlobalAS && + Entity.getKind() == InitializedEntity::EK_Variable && Args.size() > 0) { +S.Diag(Args[0]->getLocStart(), diag::err_opencl_atomic_init) << 1 << +SourceRange(Entity.getDecl()->getLocStart(), Args[0]->getLocEnd()); +return ExprError(); + } + // Diagnose cases where we initialize a pointer to an array temporary, and the // pointer obviously outlives the temporary. if (Args.size() == 1 && Args[0]->getType()->isArrayType() && Modified: cfe/trunk/test/Parser/opencl-atomics-cl20.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-atomics-cl20.cl?rev=299537&r1=299536&r2=299537&view=diff == --- cfe/trunk/test/Parser/opencl-atomics-cl20.cl (original) +++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl Wed Apr 5 07:47:10 2017 @@ -67,7 +67,7 @@ void atomic_ops_test() { foo(&i); // OpenCL v2.0 s6.13.11.8, arithemtic operations are not permitted on atomic types. i++; // expected-error {{invalid argument type 'atomic_int' (aka '_Atomic(int)') to unary expression}} - i = 1; // expected-error {{atomic variable can only be assigned to a compile time constant in the declaration statement in the program scope}} + i = 1; // expected-error {{atomic variable can be assigned to a variable on
r307238 - [OpenCL] Test on image access modifiers and image type can only be a type of a function argument.
Author: echuraev Date: Thu Jul 6 00:06:11 2017 New Revision: 307238 URL: http://llvm.org/viewvc/llvm-project?rev=307238&view=rev Log: [OpenCL] Test on image access modifiers and image type can only be a type of a function argument. Reviewers: Anastasia Reviewed By: Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D34980 Modified: cfe/trunk/test/SemaOpenCL/images.cl Modified: cfe/trunk/test/SemaOpenCL/images.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/images.cl?rev=307238&r1=307237&r2=307238&view=diff == --- cfe/trunk/test/SemaOpenCL/images.cl (original) +++ cfe/trunk/test/SemaOpenCL/images.cl Thu Jul 6 00:06:11 2017 @@ -1,9 +1,32 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -void img2d_ro(__read_only image2d_t img) {} // expected-note{{passing argument to parameter 'img' here}} expected-note{{passing argument to parameter 'img' here}} +void img2d_ro(read_only image2d_t); // expected-note 3{{passing argument to parameter here}} +void img2d_wo(write_only image2d_t); // expected-note 2{{passing argument to parameter here}} +void img2d_rw(read_write image2d_t); // expected-note 2{{passing argument to parameter here}} +void img2d_default(image2d_t); // expected-note 2{{passing argument to parameter here}} -void imgage_access_test(image2d_t img2dro, write_only image2d_t img2dwo, image3d_t img3dro) { - img2d_ro(img2dro); - img2d_ro(img2dwo); // expected-error{{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}} +void imgage_access_test(image2d_t img2dro, image3d_t img3dro) { + img2d_ro(img2dro); // read_only = read_only img2d_ro(img3dro); // expected-error{{passing '__read_only image3d_t' to parameter of incompatible type '__read_only image2d_t'}} } + +kernel void read_only_access_test(read_only image2d_t img) { + img2d_ro(img); // read_only = read_only + img2d_wo(img); // expected-error {{passing '__read_only image2d_t' to parameter of incompatible type '__write_only image2d_t'}} + img2d_rw(img); // expected-error {{passing '__read_only image2d_t' to parameter of incompatible type '__read_write image2d_t'}} + img2d_default(img); // read_only = read_only +} + +kernel void write_only_access_test(write_only image2d_t img) { + img2d_ro(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}} + img2d_wo(img); // write_only = write_only + img2d_rw(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_write image2d_t'}} + img2d_default(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}} +} + +kernel void read_write_access_test(read_write image2d_t img) { + img2d_ro(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}} + img2d_wo(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__write_only image2d_t'}} + img2d_rw(img); //read_write = read_write + img2d_default(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}} +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308266 - [OpenCL] Added extended tests on metadata generation for half data type and arrays.
Author: echuraev Date: Mon Jul 17 23:04:01 2017 New Revision: 308266 URL: http://llvm.org/viewvc/llvm-project?rev=308266&view=rev Log: [OpenCL] Added extended tests on metadata generation for half data type and arrays. Reviewers: Anastasia Reviewed By: Anastasia Subscribers: bader, cfe-commits, yaxunl Differential Revision: https://reviews.llvm.org/D35000 Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Modified: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl?rev=308266&r1=308265&r2=308266&view=diff == --- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Mon Jul 17 23:04:01 2017 @@ -1,10 +1,24 @@ // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s // RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO -kernel void foo(__global int * restrict X, const int Y, -volatile int anotherArg, __constant float * restrict Z, -__global volatile int * V, __global const int * C) { - *X = Y + anotherArg; +kernel void foo(global int * globalintp, global int * restrict globalintrestrictp, +global const int * globalconstintp, +global const int * restrict globalconstintrestrictp, +constant int * constantintp, constant int * restrict constantintrestrictp, +global const volatile int * globalconstvolatileintp, +global const volatile int * restrict globalconstvolatileintrestrictp, +global volatile int * globalvolatileintp, +global volatile int * restrict globalvolatileintrestrictp, +local int * localintp, local int * restrict localintrestrictp, +local const int * localconstintp, +local const int * restrict localconstintrestrictp, +local const volatile int * localconstvolatileintp, +local const volatile int * restrict localconstvolatileintrestrictp, +local volatile int * localvolatileintp, +local volatile int * restrict localvolatileintrestrictp, +int X, const int constint, const volatile int constvolatileint, +volatile int volatileint) { + *globalintrestrictp = constint + volatileint; } // CHECK: define spir_kernel void @foo{{[^!]+}} // CHECK: !kernel_arg_addr_space ![[MD11:[0-9]+]] @@ -61,11 +75,15 @@ kernel void foo5(myImage img1, write_onl // CHECK-NOT: !kernel_arg_name // ARGINFO: !kernel_arg_name ![[MD54:[0-9]+]] -// CHECK: ![[MD11]] = !{i32 1, i32 0, i32 0, i32 2, i32 1, i32 1} -// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none"} -// CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*", !"int*", !"int*"} -// CHECK: ![[MD14]] = !{!"restrict", !"", !"", !"restrict const", !"volatile", !"const"} -// ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z", !"V", !"C"} +typedef char char16 __attribute__((ext_vector_type(16))); +__kernel void foo6(__global char16 arg[]) {} +// CHECK: !kernel_arg_type ![[MD61:[0-9]+]] + +// CHECK: ![[MD11]] = !{i32 1, i32 1, i32 1, i32 1, i32 2, i32 2, i32 1, i32 1, i32 1, i32 1, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 0, i32 0, i32 0, i32 0} +// CHECK: ![[MD12]] = !{!"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none", !"none"} +// CHECK: ![[MD13]] = !{!"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int*", !"int", !"int", !"int", !"int"} +// CHECK: ![[MD14]] = !{!"", !"restrict", !"const", !"restrict const", !"const", !"restrict const", !"const volatile", !"restrict const volatile", !"volatile", !"restrict volatile", !"", !"restrict", !"const", !"restrict const", !"const volatile", !"restrict const volatile", !"volatile", !"restrict volatile", !"", !"", !"", !""} +// ARGINFO: ![[MD15]] = !{!"globalintp", !"globalintrestrictp", !"globalconstintp", !"globalconstintrestrictp", !"constantintp", !"constantintrestrictp", !"globalconstvolatileintp", !"globalconstvolatileintrestrictp", !"globalvolatileintp", !"globalvolatileintrestrictp", !"localintp", !"localintrestrictp", !"localconstintp", !"localconstintrestrictp", !"localconstvolatileintp", !"localconstvolatileintrestrictp", !"localvolatileintp", !"localvolatileintrestrictp", !"X", !"constint", !"constvolatileint", !"volatileint"} // CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1, i32 1} // CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only", !"read_write"} // CHECK
[PATCH] D26735: [OpenCL] Disable && (address of label) GNU extension for OpenCL
echuraev created this revision. echuraev added a reviewer: cfe-commits. Herald added a subscriber: yaxunl. Patch by Guy Benyei https://reviews.llvm.org/D26735 Files: include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseExpr.cpp test/SemaOpenCL/ampamp-gnu.cl Index: test/SemaOpenCL/ampamp-gnu.cl === --- /dev/null +++ test/SemaOpenCL/ampamp-gnu.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +kernel void foo(global int *in) { + int a; + void *p = &&a; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} + + void *hlbl_tbl[] = { &&label1 }; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} +label1: + a = 0; +} Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1104,6 +1104,9 @@ if (Tok.isNot(tok::identifier)) return ExprError(Diag(Tok, diag::err_expected) << tok::identifier); +if (getLangOpts().OpenCL) + return ExprError(Diag(Tok, diag::err_opencl_address_of_label)); + if (getCurScope()->getFnParent() == nullptr) return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn)); Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -972,6 +972,8 @@ "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup>, DefaultIgnore; // OpenCL errors. +def err_opencl_address_of_label : Error< + "OpenCL does not support address of label ('&&') GNU extension">; def err_opencl_taking_function_address_parser : Error< "taking address of function is not allowed">; def err_opencl_logical_exclusive_or : Error< Index: test/SemaOpenCL/ampamp-gnu.cl === --- /dev/null +++ test/SemaOpenCL/ampamp-gnu.cl @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only + +kernel void foo(global int *in) { + int a; + void *p = &&a; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} + + void *hlbl_tbl[] = { &&label1 }; // expected-error {{OpenCL does not support address of label ('&&') GNU extension}} +label1: + a = 0; +} Index: lib/Parse/ParseExpr.cpp === --- lib/Parse/ParseExpr.cpp +++ lib/Parse/ParseExpr.cpp @@ -1104,6 +1104,9 @@ if (Tok.isNot(tok::identifier)) return ExprError(Diag(Tok, diag::err_expected) << tok::identifier); +if (getLangOpts().OpenCL) + return ExprError(Diag(Tok, diag::err_opencl_address_of_label)); + if (getCurScope()->getFnParent() == nullptr) return ExprError(Diag(Tok, diag::err_address_of_label_outside_fn)); Index: include/clang/Basic/DiagnosticParseKinds.td === --- include/clang/Basic/DiagnosticParseKinds.td +++ include/clang/Basic/DiagnosticParseKinds.td @@ -972,6 +972,8 @@ "OpenCL extension %0 is core feature or supported optional core feature - ignoring">, InGroup>, DefaultIgnore; // OpenCL errors. +def err_opencl_address_of_label : Error< + "OpenCL does not support address of label ('&&') GNU extension">; def err_opencl_taking_function_address_parser : Error< "taking address of function is not allowed">; def err_opencl_logical_exclusive_or : Error< ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26794: [OpenCL] Blocks are allowed to capture arrays in OpenCL 2.0 and higher.
echuraev created this revision. echuraev added a reviewer: Anastasia. echuraev added subscribers: cfe-commits, yaxunl, bader. https://reviews.llvm.org/D26794 Files: lib/Sema/SemaExpr.cpp test/SemaOpenCL/blocks_with_arrays.cl Index: test/SemaOpenCL/blocks_with_arrays.cl === --- /dev/null +++ test/SemaOpenCL/blocks_with_arrays.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm %s -o -| FileCheck %s + +typedef int (^block_t)(); + +int block_typedef_kernel(global int* res) { + int a[3] = {1, 2, 3}; + block_t b = ^() { +// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32]* %{{.*}}, i64 0, i64 0 +return a[0]; + }; + return b(); +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -13477,13 +13477,16 @@ bool ByRef = false; // Blocks are not allowed to capture arrays. - if (CaptureType->isArrayType()) { -if (BuildAndDiagnose) { - S.Diag(Loc, diag::err_ref_array_type); - S.Diag(Var->getLocation(), diag::note_previous_decl) - << Var->getDeclName(); + // Only if it's not OpenCL 2.0. + if (!(S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200)) { +if (CaptureType->isArrayType()) { + if (BuildAndDiagnose) { +S.Diag(Loc, diag::err_ref_array_type); +S.Diag(Var->getLocation(), diag::note_previous_decl) +<< Var->getDeclName(); + } + return false; } -return false; } // Forbid the block-capture of autoreleasing variables. Index: test/SemaOpenCL/blocks_with_arrays.cl === --- /dev/null +++ test/SemaOpenCL/blocks_with_arrays.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -O0 -cl-std=CL2.0 -triple spir64-unkown-unkown -emit-llvm %s -o -| FileCheck %s + +typedef int (^block_t)(); + +int block_typedef_kernel(global int* res) { + int a[3] = {1, 2, 3}; + block_t b = ^() { +// CHECK: %{{.*}} = getelementptr inbounds [3 x i32], [3 x i32]* %{{.*}}, i64 0, i64 0 +return a[0]; + }; + return b(); +} Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -13477,13 +13477,16 @@ bool ByRef = false; // Blocks are not allowed to capture arrays. - if (CaptureType->isArrayType()) { -if (BuildAndDiagnose) { - S.Diag(Loc, diag::err_ref_array_type); - S.Diag(Var->getLocation(), diag::note_previous_decl) - << Var->getDeclName(); + // Only if it's not OpenCL 2.0. + if (!(S.getLangOpts().OpenCL && S.getLangOpts().OpenCLVersion >= 200)) { +if (CaptureType->isArrayType()) { + if (BuildAndDiagnose) { +S.Diag(Loc, diag::err_ref_array_type); +S.Diag(Var->getLocation(), diag::note_previous_decl) +<< Var->getDeclName(); + } + return false; } -return false; } // Forbid the block-capture of autoreleasing variables. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D27099: [OpenCL] Prohibit using reserve_id_t in program scope.
echuraev created this revision. echuraev added a reviewer: Anastasia. echuraev added subscribers: bader, yaxunl, cfe-commits. https://reviews.llvm.org/D27099 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaDecl.cpp test/SemaOpenCL/event_t.cl test/SemaOpenCL/invalid-pipes-cl2.0.cl Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl === --- test/SemaOpenCL/invalid-pipes-cl2.0.cl +++ test/SemaOpenCL/invalid-pipes-cl2.0.cl @@ -1,5 +1,8 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +global pipe int GlobalPipe;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}} +global reserve_id_t GlobalID; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}} + void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of reference type}} } void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}} @@ -20,3 +23,11 @@ typedef pipe int pipe_int_t; pipe_int_t test6() {} // expected-error{{declaring function return value of type 'pipe_int_t' (aka 'read_only pipe int') is not allowed}} + +void test7(read_write pipe int p) {// expected-error {{access qualifier 'read_write' can not be used for 'read_only pipe int'}} +} + +bool test_id_comprision(void) { + reserve_id_t id1, id2; + return (id1 == id2); // expected-error {{invalid operands to binary expression ('reserve_id_t' and 'reserve_id_t')}} +} Index: test/SemaOpenCL/event_t.cl === --- test/SemaOpenCL/event_t.cl +++ test/SemaOpenCL/event_t.cl @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -event_t glb_evt; // expected-error {{the event_t type cannot be used to declare a program scope variable}} +event_t glb_evt; // expected-error {{the 'event_t' type cannot be used to declare a program scope variable}} constant struct evt_s { event_t evt; // expected-error {{the 'event_t' type cannot be used to declare a structure or union field}} Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -5920,6 +5920,14 @@ return nullptr; } + if (getLangOpts().OpenCL && (NULL == S->getParent())) { +if (R->isReserveIDT()) { + Diag(D.getIdentifierLoc(), + diag::err_invalid_type_for_program_scope_var) << R; + D.setInvalidType(); +} + } + DeclSpec::SCS SCSpec = D.getDeclSpec().getStorageClassSpec(); StorageClass SC = StorageClassSpecToVarDeclStorageClass(D.getDeclSpec()); @@ -6003,7 +6011,8 @@ // address space qualifiers. if (R->isEventT()) { if (S->getParent() == nullptr) { -Diag(D.getLocStart(), diag::err_event_t_global_var); +Diag(D.getLocStart(), + diag::err_invalid_type_for_program_scope_var) << R; D.setInvalidType(); } Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -8073,8 +8073,6 @@ "within field of type %0 declared here">; def note_illegal_field_declared_here : Note< "field of illegal %select{type|pointer type}0 %1 declared here">; -def err_event_t_global_var : Error< - "the event_t type cannot be used to declare a program scope variable">; def err_opencl_type_struct_or_union_field : Error< "the %0 type cannot be used to declare a structure or union field">; def err_event_t_addr_space_qual : Error< @@ -8587,6 +8585,8 @@ def note_related_result_type_explicit : Note< "%select{overridden|current}0 method is explicitly declared 'instancetype'" "%select{| and is expected to return an instance of its class type}0">; +def err_invalid_type_for_program_scope_var : Error< + "the %0 type cannot be used to declare a program scope variable">; } Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl === --- test/SemaOpenCL/invalid-pipes-cl2.0.cl +++ test/SemaOpenCL/invalid-pipes-cl2.0.cl @@ -1,5 +1,8 @@ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +global pipe int GlobalPipe;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}} +global reserve_id_t GlobalID; // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}} + void test1(pipe int *p) {// expected-error {{pipes packet types cannot be of reference type}} } void test2(pipe p) {// expected-error {{missing actual type specifier for pipe}} @@ -20,3 +23,11 @@ typedef pipe int pipe_int_t; pipe_int_t test6() {} // expected-error{{declaring function return value
r289535 - [OpenCL] Enable unroll hint for OpenCL 1.x.
Author: echuraev Date: Tue Dec 13 08:02:35 2016 New Revision: 289535 URL: http://llvm.org/viewvc/llvm-project?rev=289535&view=rev Log: [OpenCL] Enable unroll hint for OpenCL 1.x. Summary: Although the feature was introduced only in OpenCL C v2.0 spec., it's useful for OpenCL 1.x too and doesn't require HW support. Reviewers: Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D27453 Modified: cfe/trunk/lib/Sema/SemaStmtAttr.cpp cfe/trunk/test/CodeGenOpenCL/unroll-hint.cl cfe/trunk/test/SemaOpenCL/unroll-hint.cl Modified: cfe/trunk/lib/Sema/SemaStmtAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAttr.cpp?rev=289535&r1=289534&r2=289535&view=diff == --- cfe/trunk/lib/Sema/SemaStmtAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp Tue Dec 13 08:02:35 2016 @@ -225,16 +225,12 @@ CheckForIncompatibleAttributes(Sema &S, static Attr *handleOpenCLUnrollHint(Sema &S, Stmt *St, const AttributeList &A, SourceRange Range) { - // OpenCL v2.0 s6.11.5 - opencl_unroll_hint can have 0 arguments (compiler + // Although the feature was introduced only in OpenCL C v2.0 s6.11.5, it's + // useful for OpenCL 1.x too and doesn't require HW support. + // opencl_unroll_hint can have 0 arguments (compiler // determines unrolling factor) or 1 argument (the unroll factor provided // by the user). - if (S.getLangOpts().OpenCLVersion < 200) { -S.Diag(A.getLoc(), diag::err_attribute_requires_opencl_version) -<< A.getName() << "2.0" << 1; -return nullptr; - } - unsigned NumArgs = A.getNumArgs(); if (NumArgs > 1) { Modified: cfe/trunk/test/CodeGenOpenCL/unroll-hint.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/unroll-hint.cl?rev=289535&r1=289534&r2=289535&view=diff == --- cfe/trunk/test/CodeGenOpenCL/unroll-hint.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/unroll-hint.cl Tue Dec 13 08:02:35 2016 @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -O0 -cl-std=CL1.2 -o - %s | FileCheck %s /*** for ***/ void for_count() Modified: cfe/trunk/test/SemaOpenCL/unroll-hint.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/unroll-hint.cl?rev=289535&r1=289534&r2=289535&view=diff == --- cfe/trunk/test/SemaOpenCL/unroll-hint.cl (original) +++ cfe/trunk/test/SemaOpenCL/unroll-hint.cl Tue Dec 13 08:02:35 2016 @@ -1,17 +1,5 @@ -//RUN: %clang_cc1 -O0 -fsyntax-only -verify %s -//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify -DCL20 %s +//RUN: %clang_cc1 -O0 -cl-std=CL2.0 -fsyntax-only -verify %s -kernel void D (global int *x) { - int i = 10; -#ifndef CL20 - // expected-error@+2 {{'opencl_unroll_hint' attribute requires OpenCL version 2.0 or above}} -#endif - __attribute__((opencl_unroll_hint)) - do { - } while(i--); -} - -#ifdef CL20 kernel void C (global int *x) { int I = 3; __attribute__((opencl_unroll_hint(I))) // expected-error {{'opencl_unroll_hint' attribute requires an integer constant}} @@ -27,4 +15,3 @@ kernel void F() { __attribute__((opencl_unroll_hint(-1))) // expected-error {{'opencl_unroll_hint' attribute requires a positive integral compile time constant expression}} for(int i=0; i<100; i++); } -#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r289536 - [OpenCL] Improve address space diagnostics.
Author: echuraev Date: Tue Dec 13 08:07:23 2016 New Revision: 289536 URL: http://llvm.org/viewvc/llvm-project?rev=289536&view=rev Log: [OpenCL] Improve address space diagnostics. Reviewers: Anastasia Subscribers: bader, yaxunl, cfe-commits Differential Revision: https://reviews.llvm.org/D27671 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaOpenCL/invalid-kernel.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=289536&r1=289535&r2=289536&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Dec 13 08:07:23 2016 @@ -8076,8 +8076,9 @@ def err_static_kernel : Error< "kernel functions cannot be declared static">; def err_opencl_ptrptr_kernel_param : Error< "kernel parameter cannot be declared as a pointer to a pointer">; -def err_opencl_private_ptr_kernel_param : Error< - "kernel parameter cannot be declared as a pointer to the __private address space">; +def err_kernel_arg_address_space : Error< + "pointer arguments to kernel functions must reside in '__global', " + "'__constant' or '__local' address space">; def err_opencl_function_variable : Error< "%select{non-kernel function|function scope}0 variable cannot be declared in %1 address space">; def err_static_function_scope : Error< Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=289536&r1=289535&r2=289536&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Dec 13 08:07:23 2016 @@ -7586,7 +7586,7 @@ enum OpenCLParamType { ValidKernelParam, PtrPtrKernelParam, PtrKernelParam, - PrivatePtrKernelParam, + InvalidAddrSpacePtrKernelParam, InvalidKernelParam, RecordKernelParam }; @@ -7596,8 +7596,10 @@ static OpenCLParamType getOpenCLKernelPa QualType PointeeType = PT->getPointeeType(); if (PointeeType->isPointerType()) return PtrPtrKernelParam; -return PointeeType.getAddressSpace() == 0 ? PrivatePtrKernelParam - : PtrKernelParam; +if (PointeeType.getAddressSpace() == LangAS::opencl_generic || +PointeeType.getAddressSpace() == 0) + return InvalidAddrSpacePtrKernelParam; +return PtrKernelParam; } // TODO: Forbid the other integer types (size_t, ptrdiff_t...) when they can @@ -7645,11 +7647,12 @@ static void checkIsValidOpenCLKernelPara D.setInvalidType(); return; - case PrivatePtrKernelParam: -// OpenCL v1.2 s6.9.a: -// A kernel function argument cannot be declared as a -// pointer to the private address space. -S.Diag(Param->getLocation(), diag::err_opencl_private_ptr_kernel_param); + case InvalidAddrSpacePtrKernelParam: +// OpenCL v1.0 s6.5: +// __kernel function arguments declared to be a pointer of a type can point +// to one of the following address spaces only : __global, __local or +// __constant. +S.Diag(Param->getLocation(), diag::err_kernel_arg_address_space); D.setInvalidType(); return; @@ -7736,7 +7739,7 @@ static void checkIsValidOpenCLKernelPara // do not allow OpenCL objects to be passed as elements of the struct or // union. if (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam || - ParamType == PrivatePtrKernelParam) { + ParamType == InvalidAddrSpacePtrKernelParam) { S.Diag(Param->getLocation(), diag::err_record_with_pointers_kernel_param) << PT->isUnionType() Modified: cfe/trunk/test/SemaOpenCL/invalid-kernel.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-kernel.cl?rev=289536&r1=289535&r2=289536&view=diff == --- cfe/trunk/test/SemaOpenCL/invalid-kernel.cl (original) +++ cfe/trunk/test/SemaOpenCL/invalid-kernel.cl Tue Dec 13 08:07:23 2016 @@ -1,10 +1,11 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -cl-std=CL2.0 -verify %s -kernel void no_ptrptr(global int **i) { } // expected-error{{kernel parameter cannot be declared as a pointer to a pointer}} +kernel void no_ptrptr(global int * global *i) { } // expected-error{{kernel parameter cannot be declared as a pointer to a pointer}} -__kernel void no_privateptr(__private int *i) { } // expected-error {{kernel parameter cannot be declared as a pointer to the __private address space}} +__kernel void no_privateptr(__private int *i) { } // expected-error {{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
r302630 - [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins
Author: echuraev Date: Wed May 10 03:23:01 2017 New Revision: 302630 URL: http://llvm.org/viewvc/llvm-project?rev=302630&view=rev Log: [OpenCL] Added checking OpenCL version for cl_khr_mipmap_image built-ins Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D32897 Modified: cfe/trunk/lib/Headers/opencl-c.h Modified: cfe/trunk/lib/Headers/opencl-c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/opencl-c.h?rev=302630&r1=302629&r2=302630&view=diff == --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Wed May 10 03:23:01 2017 @@ -14962,6 +14962,7 @@ float __purefn __ovld read_imagef(read_o #endif //cl_khr_gl_msaa_sharing // OpenCL Extension v2.0 s9.18 - Mipmaps +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #ifdef cl_khr_mipmap_image float4 __purefn __ovld read_imagef(read_only image1d_t image, sampler_t sampler, float coord, float lod); @@ -15037,6 +15038,7 @@ int4 __purefn __ovld read_imagei(read_on uint4 __purefn __ovld read_imageui(read_only image3d_t image, sampler_t sampler, float4 coord, float lod); #endif //cl_khr_mipmap_image +#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 /** * Sampler-less Image Access @@ -15135,6 +15137,7 @@ float __purefn __ovld read_imagef(read_w float __purefn __ovld read_imagef(read_write image2d_array_msaa_depth_t image, int4 coord, int sample); #endif //cl_khr_gl_msaa_sharing +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #ifdef cl_khr_mipmap_image float4 __purefn __ovld read_imagef(read_write image1d_t image, sampler_t sampler, float coord, float lod); int4 __purefn __ovld read_imagei(read_write image1d_t image, sampler_t sampler, float coord, float lod); @@ -15208,6 +15211,7 @@ float4 __purefn __ovld read_imagef(read_ int4 __purefn __ovld read_imagei(read_write image3d_t image, sampler_t sampler, float4 coord, float lod); uint4 __purefn __ovld read_imageui(read_write image3d_t image, sampler_t sampler, float4 coord, float lod); #endif //cl_khr_mipmap_image +#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 // Image read functions returning half4 type #ifdef cl_khr_fp16 @@ -15319,6 +15323,7 @@ void __ovld write_imagef(write_only imag #endif //cl_khr_depth_images // OpenCL Extension v2.0 s9.18 - Mipmaps +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #ifdef cl_khr_mipmap_image void __ovld write_imagef(write_only image1d_t image, int coord, int lod, float4 color); void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 color); @@ -15345,6 +15350,7 @@ void __ovld write_imagei(write_only imag void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color); #endif #endif //cl_khr_mipmap_image +#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 // Image write functions for half4 type #ifdef cl_khr_fp16 @@ -15391,6 +15397,7 @@ void __ovld write_imagef(read_write imag void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, float color); #endif //cl_khr_depth_images +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #ifdef cl_khr_mipmap_image void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color); void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color); @@ -15417,6 +15424,7 @@ void __ovld write_imagei(read_write imag void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 color); #endif #endif //cl_khr_mipmap_image +#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 // Image write functions for half4 type #ifdef cl_khr_fp16 @@ -15559,6 +15567,7 @@ int __ovld __cnfn get_image_depth(read_w #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 // OpenCL Extension v2.0 s9.18 - Mipmaps +#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 #ifdef cl_khr_mipmap_image /** * Return the image miplevels. @@ -15574,11 +15583,9 @@ int __ovld get_image_num_mip_levels(writ int __ovld get_image_num_mip_levels(write_only image3d_t image); #endif -#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 int __ovld get_image_num_mip_levels(read_write image1d_t image); int __ovld get_image_num_mip_levels(read_write image2d_t image); int __ovld get_image_num_mip_levels(read_write image3d_t image); -#endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 int __ovld get_image_num_mip_levels(read_only image1d_array_t image); int __ovld get_image_num_mip_levels(read_only image2d_array_t image); @@ -15590,14 +15597,13 @@ int __ovld get_image_num_mip_levels(writ int __ovld get_image_num_mip_levels(write_only image2d_array_depth_t image); int __ovld get_image_num_mip_levels(write_only image2d_depth_t image); -#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 int __ovld get_image_num_mip_levels(read_write image1d_array_t image); int __ovld get_image_num_mip_levels(read_write image2d_array_t image); int __ovld get_ima
r302633 - [OpenCL] Handle OpenCL specific subelement types
Author: echuraev Date: Wed May 10 05:28:34 2017 New Revision: 302633 URL: http://llvm.org/viewvc/llvm-project?rev=302633&view=rev Log: [OpenCL] Handle OpenCL specific subelement types Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D32898 Added: cfe/trunk/test/SemaOpenCL/array-init.cl Modified: cfe/trunk/lib/Sema/SemaInit.cpp Modified: cfe/trunk/lib/Sema/SemaInit.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=302633&r1=302632&r2=302633&view=diff == --- cfe/trunk/lib/Sema/SemaInit.cpp (original) +++ cfe/trunk/lib/Sema/SemaInit.cpp Wed May 10 05:28:34 2017 @@ -1209,7 +1209,7 @@ void InitListChecker::CheckSubElementTyp } else { assert((ElemType->isRecordType() || ElemType->isVectorType() || -ElemType->isClkEventT()) && "Unexpected type"); +ElemType->isOpenCLSpecificType()) && "Unexpected type"); // C99 6.7.8p13: // Added: cfe/trunk/test/SemaOpenCL/array-init.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/array-init.cl?rev=302633&view=auto == --- cfe/trunk/test/SemaOpenCL/array-init.cl (added) +++ cfe/trunk/test/SemaOpenCL/array-init.cl Wed May 10 05:28:34 2017 @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0 +// expected-no-diagnostics + +__kernel void k1(queue_t q1, queue_t q2) { + queue_t q[] = {q1, q2}; +} + +__kernel void k2(read_only pipe int p) { + reserve_id_t i1 = reserve_read_pipe(p, 1); + reserve_id_t i2 = reserve_read_pipe(p, 1); + reserve_id_t i[] = {i1, i2}; +} + +event_t create_event(); +__kernel void k3() { + event_t e1 = create_event(); + event_t e2 = create_event(); + event_t e[] = {e1, e2}; +} + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits