r315453 - [OpenCL] Allow function declaration with empty argument list.
Author: bader Date: Wed Oct 11 04:16:31 2017 New Revision: 315453 URL: http://llvm.org/viewvc/llvm-project?rev=315453&view=rev Log: [OpenCL] Allow function declaration with empty argument list. Treat 'f()' as 'f(void)' rather than a function w/o a prototype. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia, yaxunl Subscribers: cfe-commits, echuraev, chapuni Differential Revision: https://reviews.llvm.org/D33681 Re-apply revision 306653. Modified: cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaOpenCL/func.cl cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Modified: cfe/trunk/lib/Parse/ParseDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=315453&r1=315452&r2=315453&view=diff == --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) +++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed Oct 11 04:16:31 2017 @@ -5989,7 +5989,8 @@ void Parser::ParseFunctionDeclarator(Dec else if (RequiresArg) Diag(Tok, diag::err_argument_required_after_attribute); -HasProto = ParamInfo.size() || getLangOpts().CPlusPlus; +HasProto = ParamInfo.size() || getLangOpts().CPlusPlus +|| getLangOpts().OpenCL; // If we have the closing ')', eat it. Tracker.consumeClose(); Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=315453&r1=315452&r2=315453&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Oct 11 04:16:31 2017 @@ -4460,7 +4460,8 @@ static TypeSourceInfo *GetFullTypeForDec FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex)); - if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) { + if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus +&& !LangOpts.OpenCL) { // Simple void foo(), where the incoming T is the result type. T = Context.getFunctionNoProtoType(T, EI); } else { Modified: cfe/trunk/test/SemaOpenCL/func.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/func.cl?rev=315453&r1=315452&r2=315453&view=diff == --- cfe/trunk/test/SemaOpenCL/func.cl (original) +++ cfe/trunk/test/SemaOpenCL/func.cl Wed Oct 11 04:16:31 2017 @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown // Variadic functions void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} @@ -16,6 +16,9 @@ typedef struct s //Function pointer void foo(void*); +// Expect no diagnostics for an empty parameter list. +void bar(); + void bar() { // declaring a function pointer is an error 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=315453&r1=315452&r2=315453&view=diff == --- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original) +++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Wed Oct 11 04:16:31 2017 @@ -3,7 +3,7 @@ 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}} +extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' 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}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r304575 - [OpenCL] Harden function pointer diagnostics.
Author: bader Date: Fri Jun 2 13:08:58 2017 New Revision: 304575 URL: http://llvm.org/viewvc/llvm-project?rev=304575&view=rev Log: [OpenCL] Harden function pointer diagnostics. Summary: Improve OpenCL type checking by rejecting function pointer types. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33821 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaOpenCL/func.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=304575&r1=304574&r2=304575&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jun 2 13:08:58 2017 @@ -7268,7 +7268,7 @@ def err_invalid_conversion_between_vecto "invalid conversion between vector type %0 and integer type %1 " "of different size">; -def err_opencl_function_pointer_variable : Error< +def err_opencl_function_pointer : Error< "pointers to functions are not allowed">; def err_opencl_taking_function_address : Error< Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=304575&r1=304574&r2=304575&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Jun 2 13:08:58 2017 @@ -6160,7 +6160,7 @@ NamedDecl *Sema::ActOnVariableDeclarator QualType NR = R; while (NR->isPointerType()) { if (NR->isFunctionPointerType()) { -Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer_variable); +Diag(D.getIdentifierLoc(), diag::err_opencl_function_pointer); D.setInvalidType(); break; } Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=304575&r1=304574&r2=304575&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Fri Jun 2 13:08:58 2017 @@ -1881,6 +1881,11 @@ QualType Sema::BuildPointerType(QualType return QualType(); } + if (T->isFunctionType() && getLangOpts().OpenCL) { +Diag(Loc, diag::err_opencl_function_pointer); +return QualType(); + } + if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer)) return QualType(); Modified: cfe/trunk/test/SemaOpenCL/func.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/func.cl?rev=304575&r1=304574&r2=304575&view=diff == --- cfe/trunk/test/SemaOpenCL/func.cl (original) +++ cfe/trunk/test/SemaOpenCL/func.cl Fri Jun 2 13:08:58 2017 @@ -4,8 +4,15 @@ void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} void __vararg_f(int, ...); typedef void (*vararg_fptr_t)(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} +// expected-error@-1{{pointers to functions are not allowed}} int printf(__constant const char *st, ...); // expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}} +// Struct type with function pointer field +typedef struct s +{ + void (*f)(struct s *self, int *i); // expected-error{{pointers to functions are not allowed}} +} s_t; + //Function pointer void foo(void*); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305796 - [OpenCL] Fix OpenCL and SPIR version metadata generation.
Author: bader Date: Tue Jun 20 09:30:18 2017 New Revision: 305796 URL: http://llvm.org/viewvc/llvm-project?rev=305796&view=rev Log: [OpenCL] Fix OpenCL and SPIR version metadata generation. Summary: OpenCL and SPIR version metadata must be generated once per module instead of once per mangled global value. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: ahatanak, cfe-commits Differential Revision: https://reviews.llvm.org/D34235 Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/CodeGenModule.h cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenOpenCL/spir_version.cl Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=305796&r1=305795&r2=305796&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jun 20 09:30:18 2017 @@ -506,6 +506,26 @@ void CodeGenModule::Release() { LangOpts.CUDADeviceFlushDenormalsToZero ? 1 : 0); } + // Emit OpenCL specific module metadata: OpenCL/SPIR version. + if (LangOpts.OpenCL) { +EmitOpenCLMetadata(); +// Emit SPIR version. +if (getTriple().getArch() == llvm::Triple::spir || +getTriple().getArch() == llvm::Triple::spir64) { + // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the + // opencl.spir.version named metadata. + llvm::Metadata *SPIRVerElts[] = { + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, LangOpts.OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (LangOpts.OpenCLVersion / 100 > 1) ? 0 : 2))}; + llvm::NamedMDNode *SPIRVerMD = + TheModule.getOrInsertNamedMetadata("opencl.spir.version"); + llvm::LLVMContext &Ctx = TheModule.getContext(); + SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); +} + } + if (uint32_t PLevel = Context.getLangOpts().PICLevel) { assert(PLevel < 3 && "Invalid PIC Level"); getModule().setPICLevel(static_cast(PLevel)); @@ -529,6 +549,20 @@ void CodeGenModule::Release() { EmitTargetMetadata(); } +void CodeGenModule::EmitOpenCLMetadata() { + // SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the + // opencl.ocl.version named metadata node. + llvm::Metadata *OCLVerElts[] = { + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, LangOpts.OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (LangOpts.OpenCLVersion % 100) / 10))}; + llvm::NamedMDNode *OCLVerMD = + TheModule.getOrInsertNamedMetadata("opencl.ocl.version"); + llvm::LLVMContext &Ctx = TheModule.getContext(); + OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts)); +} + void CodeGenModule::UpdateCompletedType(const TagDecl *TD) { // Make sure that this type is translated. Types.UpdateCompletedType(TD); Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=305796&r1=305795&r2=305796&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenModule.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue Jun 20 09:30:18 2017 @@ -1321,6 +1321,9 @@ private: /// Emits target specific Metadata for global declarations. void EmitTargetMetadata(); + /// Emits OpenCL specific Metadata e.g. OpenCL version. + void EmitOpenCLMetadata(); + /// Emit the llvm.gcov metadata used to tell LLVM where to emit the .gcno and /// .gcda files in a way that persists in .bc files. void EmitCoverageFile(); Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=305796&r1=305795&r2=305796&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Jun 20 09:30:18 2017 @@ -7344,8 +7344,6 @@ public: }; } -static void appendOpenCLVersionMD (CodeGen::CodeGenModule &CGM); - void AMDGPUTargetCodeGenInfo::setTargetAttributes( const Decl *D, llvm::GlobalValue *GV, @@ -7402,8 +7400,6 @@ void AMDGPUTargetCodeGenInfo::setTargetA if (NumVGPR != 0) F->addFnAttr("amdgpu-num-vgpr", llvm::utostr(NumVGPR)); } - - appendOpenCLVersionMD(M); } unsigned AMDGPUTargetCodeGenInfo::getOpenCLKernelCallingConv() const { @@ -8074,8 +8070,6 @@ class SPIRTargetCodeGenInfo : public Tar public: SPIRTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT) : TargetCodeGenInfo(new DefaultABIInfo(CGT)) {} - void emitTargetMD(const Decl *D, llvm::GlobalValue *GV, -CodeGen::CodeGenModule &M)
r335103 - [Sema] Allow creating types with multiple of the same addrspace.
Author: bader Date: Wed Jun 20 01:31:24 2018 New Revision: 335103 URL: http://llvm.org/viewvc/llvm-project?rev=335103&view=rev Log: [Sema] Allow creating types with multiple of the same addrspace. Summary: The comment with the OpenCL clause about this clearly says: "No type shall be qualified by qualifiers for two or more different address spaces." This must mean that two or more qualifiers for the _same_ address space is allowed. However, it is likely unintended by the programmer, so emit a warning. For dependent address space types, reject them like before since we cannot know what the address space will be. Patch by Bevin Hansson (ebevhan). Reviewers: Anastasia Reviewed By: Anastasia Subscribers: bader, cfe-commits Differential Revision: https://reviews.llvm.org/D47630 Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/Sema/address_spaces.c cfe/trunk/test/SemaOpenCL/address-spaces.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=335103&r1=335102&r2=335103&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jun 20 01:31:24 2018 @@ -2576,6 +2576,9 @@ def err_attribute_address_space_too_high "address space is larger than the maximum supported (%0)">; def err_attribute_address_multiple_qualifiers : Error< "multiple address spaces specified for type">; +def warn_attribute_address_multiple_identical_qualifiers : Warning< + "multiple identical address spaces specified for type">, + InGroup; def err_attribute_address_function_type : Error< "function type may not be qualified with an address space">; def err_as_qualified_auto_decl : Error< Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=335103&r1=335102&r2=335103&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Wed Jun 20 01:31:24 2018 @@ -5758,14 +5758,6 @@ QualType Sema::BuildAddressSpaceAttr(Qua SourceLocation AttrLoc) { if (!AddrSpace->isValueDependent()) { -// If this type is already address space qualified, reject it. -// ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified -// by qualifiers for two or more different address spaces." -if (T.getAddressSpace() != LangAS::Default) { - Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers); - return QualType(); -} - llvm::APSInt addrSpace(32); if (!AddrSpace->isIntegerConstantExpr(addrSpace, Context)) { Diag(AttrLoc, diag::err_attribute_argument_type) @@ -5796,6 +5788,20 @@ QualType Sema::BuildAddressSpaceAttr(Qua LangAS ASIdx = getLangASFromTargetAS(static_cast(addrSpace.getZExtValue())); +// If this type is already address space qualified with a different +// address space, reject it. +// ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified +// by qualifiers for two or more different address spaces." +if (T.getAddressSpace() != LangAS::Default) { + if (T.getAddressSpace() != ASIdx) { +Diag(AttrLoc, diag::err_attribute_address_multiple_qualifiers); +return QualType(); + } else +// Emit a warning if they are identical; it's likely unintended. +Diag(AttrLoc, + diag::warn_attribute_address_multiple_identical_qualifiers); +} + return Context.getAddrSpaceQualType(T, ASIdx); } @@ -5817,15 +5823,6 @@ QualType Sema::BuildAddressSpaceAttr(Qua /// space for the type. static void HandleAddressSpaceTypeAttribute(QualType &Type, const AttributeList &Attr, Sema &S){ - // If this type is already address space qualified, reject it. - // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified by - // qualifiers for two or more different address spaces." - if (Type.getAddressSpace() != LangAS::Default) { -S.Diag(Attr.getLoc(), diag::err_attribute_address_multiple_qualifiers); -Attr.setInvalid(); -return; - } - // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be // qualified by an address-space qualifier." if (Type->isFunctionType()) { @@ -5888,6 +5885,21 @@ static void HandleAddressSpaceTypeAttrib llvm_unreachable("Invalid address space"); } +// If this type is already address space qualified with a different +// address space, reject it. +// ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "No type shall be qualified by +// qualifiers for two or more different address spaces." +i
r354337 - [OpenCL] Change type of block pointer for OpenCL
Author: bader Date: Tue Feb 19 07:19:06 2019 New Revision: 354337 URL: http://llvm.org/viewvc/llvm-project?rev=354337&view=rev Log: [OpenCL] Change type of block pointer for OpenCL Summary: For some reason OpenCL blocks in LLVM IR are represented as function pointers. These pointers do not point to any real function and never get called. Actually they point to some structure, which in turn contains pointer to the real block invoke function. This patch changes represntation of OpenCL blocks in LLVM IR from function pointers to pointers to `%struct.__block_literal_generic`. Such representation allows to avoid unnecessary bitcasts and simplifies further processing (e.g. translation to SPIR-V ) of the module for targets which do not support function pointers. Patch by: Alexey Sotkin. Reviewers: Anastasia, yaxunl, svenvh Reviewed By: Anastasia Subscribers: alexbatashev, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58277 Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/test/CodeGenOpenCL/blocks.cl cfe/trunk/test/CodeGenOpenCL/cl20-device-side-enqueue.cl Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=354337&r1=354336&r2=354337&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Tue Feb 19 07:19:06 2019 @@ -635,7 +635,9 @@ llvm::Type *CodeGenTypes::ConvertType(Qu case Type::BlockPointer: { const QualType FTy = cast(Ty)->getPointeeType(); -llvm::Type *PointeeType = ConvertTypeForMem(FTy); +llvm::Type *PointeeType = CGM.getLangOpts().OpenCL + ? CGM.getGenericBlockLiteralType() + : ConvertTypeForMem(FTy); unsigned AS = Context.getTargetAddressSpace(FTy); ResultType = llvm::PointerType::get(PointeeType, AS); break; Modified: cfe/trunk/test/CodeGenOpenCL/blocks.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/blocks.cl?rev=354337&r1=354336&r2=354337&view=diff == --- cfe/trunk/test/CodeGenOpenCL/blocks.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/blocks.cl Tue Feb 19 07:19:06 2019 @@ -35,11 +35,10 @@ void foo(){ // SPIR: %[[block_captured:.*]] = getelementptr inbounds <{ i32, i32, i8 addrspace(4)*, i32 }>, <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block]], i32 0, i32 3 // SPIR: %[[i_value:.*]] = load i32, i32* %i // SPIR: store i32 %[[i_value]], i32* %[[block_captured]], - // SPIR: %[[blk_ptr:.*]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block]] to i32 ()* - // SPIR: %[[blk_gen_ptr:.*]] = addrspacecast i32 ()* %[[blk_ptr]] to i32 () addrspace(4)* - // SPIR: store i32 () addrspace(4)* %[[blk_gen_ptr]], i32 () addrspace(4)** %[[block_B:.*]], - // SPIR: %[[blk_gen_ptr:.*]] = load i32 () addrspace(4)*, i32 () addrspace(4)** %[[block_B]] - // SPIR: %[[block_literal:.*]] = bitcast i32 () addrspace(4)* %[[blk_gen_ptr]] to %struct.__opencl_block_literal_generic addrspace(4)* + // SPIR: %[[blk_ptr:.*]] = bitcast <{ i32, i32, i8 addrspace(4)*, i32 }>* %[[block]] to %struct.__opencl_block_literal_generic* + // SPIR: %[[blk_gen_ptr:.*]] = addrspacecast %struct.__opencl_block_literal_generic* %[[blk_ptr]] to %struct.__opencl_block_literal_generic addrspace(4)* + // SPIR: store %struct.__opencl_block_literal_generic addrspace(4)* %[[blk_gen_ptr]], %struct.__opencl_block_literal_generic addrspace(4)** %[[block_B:.*]], + // SPIR: %[[block_literal:.*]] = load %struct.__opencl_block_literal_generic addrspace(4)*, %struct.__opencl_block_literal_generic addrspace(4)** %[[block_B]] // SPIR: %[[invoke_addr:.*]] = getelementptr inbounds %struct.__opencl_block_literal_generic, %struct.__opencl_block_literal_generic addrspace(4)* %[[block_literal]], i32 0, i32 2 // SPIR: %[[blk_gen_ptr:.*]] = bitcast %struct.__opencl_block_literal_generic addrspace(4)* %[[block_literal]] to i8 addrspace(4)* // SPIR: %[[invoke_func_ptr:.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* %[[invoke_addr]] @@ -50,11 +49,10 @@ void foo(){ // AMDGCN: %[[block_captured:.*]] = getelementptr inbounds <{ i32, i32, i8*, i32 }>, <{ i32, i32, i8*, i32 }> addrspace(5)* %[[block]], i32 0, i32 3 // AMDGCN: %[[i_value:.*]] = load i32, i32 addrspace(5)* %i // AMDGCN: store i32 %[[i_value]], i32 addrspace(5)* %[[block_captured]], - // AMDGCN: %[[blk_ptr:.*]] = bitcast <{ i32, i32, i8*, i32 }> addrspace(5)* %[[block]] to i32 () addrspace(5)* - // AMDGCN: %[[blk_gen_ptr:.*]] = addrspacecast i32 () addrspace(5)* %[[blk_ptr]] to i32 ()* - // AMDGCN: store i32 ()* %[[blk_gen_ptr]], i32 ()* addrspace(5)* %[[block_B:.*]], - // AMDGCN: %[[blk_gen_ptr:.*]] = load i32 ()*, i32 ()* addrspace(5)* %[[block_B]] - // AMDGCN: %[[block_
r354773 - [SYCL] Add clang front-end option to enable SYCL device compilation flow.
Author: bader Date: Mon Feb 25 03:48:48 2019 New Revision: 354773 URL: http://llvm.org/viewvc/llvm-project?rev=354773&view=rev Log: [SYCL] Add clang front-end option to enable SYCL device compilation flow. Patch by Mariya Podchishchaeva Added: cfe/trunk/test/Preprocessor/sycl-macro.cpp (with props) Modified: cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/lib/Frontend/InitPreprocessor.cpp Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=354773&r1=354772&r2=354773&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Feb 25 03:48:48 2019 @@ -217,6 +217,8 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, " LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate transcendental functions") LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code") +LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") + LANGOPT(SizedDeallocation , 1, 0, "sized deallocation") LANGOPT(AlignedAllocation , 1, 0, "aligned allocation") LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are unavailable") Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=354773&r1=354772&r2=354773&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Feb 25 03:48:48 2019 @@ -836,8 +836,14 @@ def fopenmp_is_device : Flag<["-"], "fop def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">, HelpText<"Path to the IR file produced by the frontend for the host.">; -} // let Flags = [CC1Option] +//===--===// +// SYCL Options +//===--===// +def fsycl_is_device : Flag<["-"], "fsycl-is-device">, + HelpText<"Generate code for SYCL device.">; + +} // let Flags = [CC1Option] //===--===// // cc1as-only Options Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=354773&r1=354772&r2=354773&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 25 03:48:48 2019 @@ -2879,6 +2879,8 @@ static void ParseLangArgs(LangOptions &O << Opts.OMPHostIRFile; } + Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device); + // Set CUDA mode for OpenMP target NVPTX if specified in options Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() && Args.hasArg(options::OPT_fopenmp_cuda_mode); Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=354773&r1=354772&r2=354773&view=diff == --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original) +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Feb 25 03:48:48 2019 @@ -1057,6 +1057,12 @@ static void InitializePredefinedMacros(c Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__"); } + // Define a macro indicating that the source file is being compiled with a + // SYCL device compiler which doesn't produce host binary. + if (LangOpts.SYCLIsDevice) { +Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1"); + } + // OpenCL definitions. if (LangOpts.OpenCL) { #define OPENCLEXT(Ext) \ Added: cfe/trunk/test/Preprocessor/sycl-macro.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sycl-macro.cpp?rev=354773&view=auto == --- cfe/trunk/test/Preprocessor/sycl-macro.cpp (added) +++ cfe/trunk/test/Preprocessor/sycl-macro.cpp Mon Feb 25 03:48:48 2019 @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 %s -E -dM | FileCheck %s +// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-SYCL %s + +// CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1 +// CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1 Propchange: cfe/trunk/test/Preprocessor/sycl-macro.cpp -- svn:eol-style = native Propchange: cfe/trunk/test/Preprocessor/sycl-macro.cpp
[clang] e95ee30 - [SYCL] Prohibit arithmetic operations for incompatible pointers
Author: Alexey Bader Date: 2020-05-22T13:43:24+03:00 New Revision: e95ee300c0530158d86430fd82ffabd36262e862 URL: https://github.com/llvm/llvm-project/commit/e95ee300c0530158d86430fd82ffabd36262e862 DIFF: https://github.com/llvm/llvm-project/commit/e95ee300c0530158d86430fd82ffabd36262e862.diff LOG: [SYCL] Prohibit arithmetic operations for incompatible pointers Summary: This change enables OpenCL diagnostics for the pointers annotated with address space attribute SYCL mode. Move `isAddressSpaceOverlapping` method from PointerType to QualType. Reviewers: Anastasia, rjmccall Reviewed By: rjmccall Subscribers: rjmccall, jeroen.dobbelaere, Fznamznon, yaxunl, ebevhan, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80317 Added: clang/test/SemaCXX/address-space-arithmetic.cpp Modified: clang/include/clang/AST/Type.h clang/lib/Sema/SemaCast.cpp clang/lib/Sema/SemaExpr.cpp clang/test/Sema/address_spaces.c Removed: diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 21b14de997cb..ed31dea925f3 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -1064,6 +1064,21 @@ class QualType { /// Return the address space of this type. inline LangAS getAddressSpace() const; + /// Returns true if address space qualifiers overlap with T address space + /// qualifiers. + /// OpenCL C defines conversion rules for pointers to diff erent address spaces + /// and notion of overlapping address spaces. + /// CL1.1 or CL1.2: + /// address spaces overlap iff they are they same. + /// OpenCL C v2.0 s6.5.5 adds: + /// __generic overlaps with any address space except for __constant. + bool isAddressSpaceOverlapping(QualType T) const { +Qualifiers Q = getQualifiers(); +Qualifiers TQ = T.getQualifiers(); +// Address spaces overlap if at least one of them is a superset of another +return Q.isAddressSpaceSupersetOf(TQ) || TQ.isAddressSpaceSupersetOf(Q); + } + /// Returns gc attribute of this type. inline Qualifiers::GC getObjCGCAttr() const; @@ -2631,22 +2646,6 @@ class PointerType : public Type, public llvm::FoldingSetNode { public: QualType getPointeeType() const { return PointeeType; } - /// Returns true if address spaces of pointers overlap. - /// OpenCL v2.0 defines conversion rules for pointers to diff erent - /// address spaces (OpenCLC v2.0 s6.5.5) and notion of overlapping - /// address spaces. - /// CL1.1 or CL1.2: - /// address spaces overlap iff they are they same. - /// CL2.0 adds: - /// __generic overlaps with any address space except for __constant. - bool isAddressSpaceOverlapping(const PointerType &other) const { -Qualifiers thisQuals = PointeeType.getQualifiers(); -Qualifiers otherQuals = other.getPointeeType().getQualifiers(); -// Address spaces overlap if at least one of them is a superset of another -return thisQuals.isAddressSpaceSupersetOf(otherQuals) || - otherQuals.isAddressSpaceSupersetOf(thisQuals); - } - bool isSugared() const { return false; } QualType desugar() const { return QualType(this, 0); } diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp index a4fe90f79eb9..fe4fcdd01301 100644 --- a/clang/lib/Sema/SemaCast.cpp +++ b/clang/lib/Sema/SemaCast.cpp @@ -2391,7 +2391,7 @@ static TryCastResult TryAddressSpaceCast(Sema &Self, ExprResult &SrcExpr, return TC_NotApplicable; auto SrcPointeeType = SrcPtrType->getPointeeType(); auto DestPointeeType = DestPtrType->getPointeeType(); - if (!DestPtrType->isAddressSpaceOverlapping(*SrcPtrType)) { + if (!DestPointeeType.isAddressSpaceOverlapping(SrcPointeeType)) { msg = diag::err_bad_cxx_cast_addr_space_mismatch; return TC_Failed; } @@ -2434,9 +2434,9 @@ void CastOperation::checkAddressSpaceCast(QualType SrcType, QualType DestType) { const PointerType *SrcPPtr = cast(SrcPtr); QualType DestPPointee = DestPPtr->getPointeeType(); QualType SrcPPointee = SrcPPtr->getPointeeType(); - if (Nested ? DestPPointee.getAddressSpace() != - SrcPPointee.getAddressSpace() - : !DestPPtr->isAddressSpaceOverlapping(*SrcPPtr)) { + if (Nested + ? DestPPointee.getAddressSpace() != SrcPPointee.getAddressSpace() + : !DestPPointee.isAddressSpaceOverlapping(SrcPPointee)) { Self.Diag(OpRange.getBegin(), DiagID) << SrcType << DestType << Sema::AA_Casting << SrcExpr.get()->getSourceRange(); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 93e67ad2940c..261e69b44052 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -10087,10 +10087,8 @@ static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, if (isRHSPointer) RHSPointeeTy = RHSExpr->getType()
[clang] cf6cc66 - [OpenMP][SYCL] Improve diagnosing of unsupported types usage
Author: Mariya Podchishchaeva Date: 2020-05-29T18:00:48+03:00 New Revision: cf6cc6622b1416430f517850be9032788e39 URL: https://github.com/llvm/llvm-project/commit/cf6cc6622b1416430f517850be9032788e39 DIFF: https://github.com/llvm/llvm-project/commit/cf6cc6622b1416430f517850be9032788e39.diff LOG: [OpenMP][SYCL] Improve diagnosing of unsupported types usage Summary: Diagnostic is emitted if some declaration of unsupported type declaration is used inside device code. Memcpy operations for structs containing member with unsupported type are allowed. Fixed crash on attempt to emit diagnostic outside of the functions. The approach is generalized between SYCL and OpenMP. CUDA/OMP deferred diagnostic interface is going to be used for SYCL device. Reviewers: rsmith, rjmccall, ABataev, erichkeane, bader, jdoerfert, aaron.ballman Reviewed By: jdoerfert Subscribers: guansong, sstefan1, yaxunl, mgorny, bader, ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74387 Added: clang/lib/Sema/SemaSYCL.cpp clang/test/SemaSYCL/float128.cpp Modified: clang/include/clang/Basic/DiagnosticSemaKinds.td clang/include/clang/Sema/Sema.h clang/lib/Sema/CMakeLists.txt clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaDeclCXX.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/SemaType.cpp clang/test/Headers/nvptx_device_math_sin.c clang/test/Headers/nvptx_device_math_sin.cpp clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp clang/test/OpenMP/nvptx_unsupported_type_messages.cpp Removed: diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 845e329033c3..63af9f42dfd3 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10204,8 +10204,8 @@ def err_omp_invariant_or_linear_dependency : Error< "expected loop invariant expression or ' * %0 + ' kind of expression">; def err_omp_wrong_dependency_iterator_type : Error< "expected an integer or a pointer type of the outer loop counter '%0' for non-rectangular nests">; -def err_omp_unsupported_type : Error < - "host requires %0 bit size %1 type support, but device '%2' does not support it">; +def err_device_unsupported_type : Error < + "%0 requires %1 bit size %2 type support, but device '%3' does not support it">; def err_omp_lambda_capture_in_declare_target_not_to : Error< "variable captured in declare target region must appear in a to clause">; def err_omp_device_type_mismatch : Error< diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index dc7ee2ddd0b8..594c6e03aa38 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -9868,10 +9868,6 @@ class Sema final { /// Pop OpenMP function region for non-capturing function. void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); - /// Check if the expression is allowed to be used in expressions for the - /// OpenMP devices. - void checkOpenMPDeviceExpr(const Expr *E); - /// Checks if a type or a declaration is disabled due to the owning extension /// being disabled, and emits diagnostic messages if it is disabled. /// \param D type or declaration to be checked. @@ -11654,6 +11650,10 @@ class Sema final { DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID); + /// Check if the expression is allowed to be used in expressions for the + /// offloading devices. + void checkDeviceDecl(const ValueDecl *D, SourceLocation Loc); + enum CUDAFunctionTarget { CFT_Device, CFT_Global, @@ -12396,6 +12396,40 @@ class Sema final { ConstructorDestructor, BuiltinFunction }; + /// Creates a DeviceDiagBuilder that emits the diagnostic if the current + /// context is "used as device code". + /// + /// - If CurLexicalContext is a kernel function or it is known that the + /// function will be emitted for the device, emits the diagnostics + /// immediately. + /// - If CurLexicalContext is a function and we are compiling + /// for the device, but we don't know that this function will be codegen'ed + /// for devive yet, creates a diagnostic which is emitted if and when we + /// realize that the function will be codegen'ed. + /// + /// Example usage: + /// + /// Diagnose __float128 type usage only from SYCL device code if the current + /// target doesn't support it + /// if (!S.Context.getTargetInfo().hasFloat128Type() && + /// S.getLangOpts().SYCLIsDevice) + /// SYCLDiagIfDeviceCode(Loc, diag::err_type_unsupported) << "__float128"; + DeviceDiagBuilder SYCLDiagIfDeviceCode(SourceLocation Loc, unsigned DiagID); + + /// Check whether we're allowed to call Callee from the current context. +
[clang] bd85b7d - [OpenMP][SYCL] Do not crash on attempt to diagnose unsupported type use
Author: Mariya Podchishchaeva Date: 2020-05-30T12:27:58+03:00 New Revision: bd85b7d6688725e854a694f9f3e8baa6a3077a4a URL: https://github.com/llvm/llvm-project/commit/bd85b7d6688725e854a694f9f3e8baa6a3077a4a DIFF: https://github.com/llvm/llvm-project/commit/bd85b7d6688725e854a694f9f3e8baa6a3077a4a.diff LOG: [OpenMP][SYCL] Do not crash on attempt to diagnose unsupported type use Summary: Do not ask size of type if it is dependent. ASTContext doesn't seem expecting this. Reviewers: jdoerfert, ABataev, bader Reviewed By: ABataev Subscribers: yaxunl, guansong, ebevhan, Anastasia, sstefan1, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D80829 Added: Modified: clang/lib/Sema/Sema.cpp clang/test/OpenMP/nvptx_unsupported_type_messages.cpp Removed: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 8c11a1a59e9c..ffe2e4d4d56a 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1725,6 +1725,9 @@ void Sema::checkDeviceDecl(const ValueDecl *D, SourceLocation Loc) { } auto CheckType = [&](QualType Ty) { +if (Ty->isDependentType()) + return; + if ((Ty->isFloat16Type() && !Context.getTargetInfo().hasFloat16Type()) || ((Ty->isFloat128Type() || (Ty->isRealFloatingType() && Context.getTypeSize(Ty) == 128)) && diff --git a/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp b/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp index 22ce8175fd05..e56105adeb83 100644 --- a/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ b/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -120,3 +120,14 @@ void hostFoo() { long double qa, qb; decltype(qa + qb) qc; double qd[sizeof(-(-(qc * 2)))]; + +struct A { }; + +template +struct A_type { typedef A type; }; + +template +struct B { + enum { value = bool(Sp::value) || bool(Tp::value) }; + typedef typename A_type::type type; +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8d27be8 - [OpenCL] Add global_device and global_host address spaces
Author: Alexey Bader Date: 2020-07-29T17:24:53+03:00 New Revision: 8d27be8dbaffce0519ac41173d51923fc2524b1b URL: https://github.com/llvm/llvm-project/commit/8d27be8dbaffce0519ac41173d51923fc2524b1b DIFF: https://github.com/llvm/llvm-project/commit/8d27be8dbaffce0519ac41173d51923fc2524b1b.diff LOG: [OpenCL] Add global_device and global_host address spaces This patch introduces 2 new address spaces in OpenCL: global_device and global_host which are a subset of a global address space, so the address space scheme will be looking like: ``` generic->global->host ->device ->private ->local constant ``` Justification: USM allocations may be associated with both host and device memory. We want to give users a way to tell the compiler the allocation type of a USM pointer for optimization purposes. (Link to the Unified Shared Memory extension: https://github.com/intel/llvm/blob/sycl/sycl/doc/extensions/USM/cl_intel_unified_shared_memory.asciidoc) Before this patch USM pointer could be only in opencl_global address space, hence a device backend can't tell if a particular pointer points to host or device memory. On FPGAs at least we can generate more efficient hardware code if the user tells us where the pointer can point - being able to distinguish between these types of pointers at compile time allows us to instantiate simpler load-store units to perform memory transactions. Patch by Dmitry Sidorov. Reviewed By: Anastasia Differential Revision: https://reviews.llvm.org/D82174 Added: clang/test/SemaOpenCL/usm-address-spaces-conversions.cl Modified: clang/include/clang/AST/Type.h clang/include/clang/Basic/AddressSpaces.h clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Sema/ParsedAttr.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/MicrosoftMangle.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Basic/Targets/AMDGPU.cpp clang/lib/Basic/Targets/NVPTX.h clang/lib/Basic/Targets/SPIR.h clang/lib/Basic/Targets/TCE.h clang/lib/Basic/Targets/X86.h clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Sema/SemaType.cpp clang/test/AST/language_address_space_attribute.cpp clang/test/CodeGenCXX/mangle-address-space.cpp clang/test/CodeGenOpenCL/address-spaces-conversions.cl clang/test/CodeGenOpenCL/address-spaces.cl clang/test/SemaTemplate/address_space-dependent.cpp Removed: diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 7fe652492b0e..7d943ebc78c0 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -480,6 +480,11 @@ class Qualifiers { // Otherwise in OpenCLC v2.0 s6.5.5: every address space except // for __constant can be used as __generic. (A == LangAS::opencl_generic && B != LangAS::opencl_constant) || + // We also define global_device and global_host address spaces, + // to distinguish global pointers allocated on host from pointers + // allocated on device, which are a subset of __global. + (A == LangAS::opencl_global && (B == LangAS::opencl_global_device || + B == LangAS::opencl_global_host)) || // Consider pointer size address spaces to be equivalent to default. ((isPtrSizeAddressSpace(A) || A == LangAS::Default) && (isPtrSizeAddressSpace(B) || B == LangAS::Default)); diff --git a/clang/include/clang/Basic/AddressSpaces.h b/clang/include/clang/Basic/AddressSpaces.h index faf7f303aa2d..a9db52dfcc9c 100644 --- a/clang/include/clang/Basic/AddressSpaces.h +++ b/clang/include/clang/Basic/AddressSpaces.h @@ -36,6 +36,8 @@ enum class LangAS : unsigned { opencl_constant, opencl_private, opencl_generic, + opencl_global_device, + opencl_global_host, // CUDA specific address spaces. cuda_device, diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 0ee3c5188563..f9bf3f0acd55 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1178,6 +1178,16 @@ def OpenCLGlobalAddressSpace : TypeAttr { let Documentation = [OpenCLAddressSpaceGlobalDocs]; } +def OpenCLGlobalDeviceAddressSpace : TypeAttr { + let Spellings = [Clang<"opencl_global_device">]; + let Documentation = [OpenCLAddressSpaceGlobalExtDocs]; +} + +def OpenCLGlobalHostAddressSpace : TypeAttr { + let Spellings = [Clang<"opencl_global_host">]; + let Documentation = [OpenCLAddressSpaceGlobalExtDocs]; +} + def OpenCLLocalAddressSpace : TypeAttr { let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">]; let Documentation = [OpenCLAddressSpaceLocalDocs]; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Ba
[clang] 93cd411 - [NFC] Run clang-format on clang/test/OpenMP/nvptx_target_codegen.cpp
Author: Alexey Bader Date: 2020-06-17T13:04:01+03:00 New Revision: 93cd4115799cefa698833ca7a2f1899243d94c77 URL: https://github.com/llvm/llvm-project/commit/93cd4115799cefa698833ca7a2f1899243d94c77 DIFF: https://github.com/llvm/llvm-project/commit/93cd4115799cefa698833ca7a2f1899243d94c77.diff LOG: [NFC] Run clang-format on clang/test/OpenMP/nvptx_target_codegen.cpp Added: Modified: clang/test/OpenMP/nvptx_target_codegen.cpp Removed: diff --git a/clang/test/OpenMP/nvptx_target_codegen.cpp b/clang/test/OpenMP/nvptx_target_codegen.cpp index 20415c0dc1b6..d615b8536c48 100644 --- a/clang/test/OpenMP/nvptx_target_codegen.cpp +++ b/clang/test/OpenMP/nvptx_target_codegen.cpp @@ -16,16 +16,16 @@ // CHECK-DAG: {{@__omp_offloading_.+l123}}_exec_mode = weak constant i8 1 // CHECK-DAG: {{@__omp_offloading_.+l200}}_exec_mode = weak constant i8 1 // CHECK-DAG: {{@__omp_offloading_.+l310}}_exec_mode = weak constant i8 1 -// CHECK-DAG: {{@__omp_offloading_.+l348}}_exec_mode = weak constant i8 1 -// CHECK-DAG: {{@__omp_offloading_.+l366}}_exec_mode = weak constant i8 1 +// CHECK-DAG: {{@__omp_offloading_.+l347}}_exec_mode = weak constant i8 1 +// CHECK-DAG: {{@__omp_offloading_.+l365}}_exec_mode = weak constant i8 1 // CHECK-DAG: {{@__omp_offloading_.+l331}}_exec_mode = weak constant i8 1 __thread int id; int baz(int f, double &a); -template -struct TT{ +template +struct TT { tx X; ty Y; tx &operator[](int i) { return X; } @@ -56,258 +56,258 @@ int foo(int n) { double cn[5][n]; TT d; - // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l123}}_worker() - // CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, - // CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, - // CHECK: store i8* null, i8** [[OMP_WORK_FN]], - // CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], - // CHECK: br label {{%?}}[[AWAIT_WORK:.+]] - // - // CHECK: [[AWAIT_WORK]] - // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) - // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]], - // CHECK: [[SHOULD_EXIT:%.+]] = icmp eq i8* [[WORK]], null - // CHECK: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]] - // - // CHECK: [[SEL_WORKERS]] - // CHECK: [[ST:%.+]] = load i8, i8* [[OMP_EXEC_STATUS]], - // CHECK: [[IS_ACTIVE:%.+]] = icmp ne i8 [[ST]], 0 - // CHECK: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]] - // - // CHECK: [[EXEC_PARALLEL]] - // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]] - // - // CHECK: [[TERM_PARALLEL]] - // CHECK: br label {{%?}}[[BAR_PARALLEL]] - // - // CHECK: [[BAR_PARALLEL]] - // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) - // CHECK: br label {{%?}}[[AWAIT_WORK]] - // - // CHECK: [[EXIT]] - // CHECK: ret void - - // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+l123]]() - // CHECK-DAG: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() - // CHECK-DAG: [[NTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() - // CHECK-DAG: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() - // CHECK-DAG: [[TH_LIMIT:%.+]] = sub nuw i32 [[NTH]], [[WS]] - // CHECK: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[TH_LIMIT]] - // CHECK: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[CHECK_MASTER:.+]] - // - // CHECK: [[WORKER]] - // CHECK: {{call|invoke}} void [[T1]]_worker() - // CHECK: br label {{%?}}[[EXIT:.+]] - // - // CHECK: [[CHECK_MASTER]] - // CHECK-DAG: [[CMTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() - // CHECK-DAG: [[CMNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() - // CHECK-DAG: [[CMWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() - // CHECK: [[IS_MASTER:%.+]] = icmp eq i32 [[CMTID]], - // CHECK: br i1 [[IS_MASTER]], label {{%?}}[[MASTER:.+]], label {{%?}}[[EXIT]] - // - // CHECK: [[MASTER]] - // CHECK-DAG: [[MNTH:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() - // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize() - // CHECK: [[MTMP1:%.+]] = sub nuw i32 [[MNTH]], [[MWS]] - // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]] - // CHECK: br label {{%?}}[[TERMINATE:.+]] - // - // CHECK: [[TERMINATE]] - // CHECK: call void @__kmpc_kernel_deinit( - // CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i32 0) - // CHECK: br label {{%?}}[[EXIT]] - // - // CHECK: [[EXIT]] - // CHECK: ret void - #pragma omp target +// CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+foo.+l123}}_worker() +// CHECK-DAG: [[OMP_EXEC_STATUS:%.+]] = alloca i8, +// CHECK-DAG: [[OMP_WORK_FN:%.+]] = alloca i8*, +// CHECK: store i8* null, i8** [[OMP_WORK_FN]], +// CHECK: store i8 0, i8* [[OMP_EXEC_STATUS]], +// CHECK: br label {{%?}}[[AWAIT_WORK:.+]] +// +// CHECK: [[AWAIT_WORK]] +// CHECK: call void @__kmpc_barrier_simple_spmd(%struct.ident_t* null, i3
[clang] 0bdcd95 - [SYCL][OpenMP] Implement thread-local storage restriction
Author: Mariya Podchishchaeva Date: 2020-06-17T14:36:00+03:00 New Revision: 0bdcd95bf20f159a2512aff1ef032bec52039bf6 URL: https://github.com/llvm/llvm-project/commit/0bdcd95bf20f159a2512aff1ef032bec52039bf6 DIFF: https://github.com/llvm/llvm-project/commit/0bdcd95bf20f159a2512aff1ef032bec52039bf6.diff LOG: [SYCL][OpenMP] Implement thread-local storage restriction Summary: SYCL and OpenMP prohibits thread local storage in device code, so this commit ensures that error is emitted for device code and not emitted for host code when host target supports it. Reviewers: jdoerfert, erichkeane, bader Reviewed By: jdoerfert, erichkeane Subscribers: guansong, riccibruno, ABataev, yaxunl, ebevhan, Anastasia, sstefan1, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81641 Added: clang/test/OpenMP/nvptx_prohibit_thread_local.cpp clang/test/SemaSYCL/prohibit-thread-local.cpp Modified: clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/test/OpenMP/nvptx_target_codegen.cpp Removed: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2bf16d138d5a..80469e3bedbe 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7077,7 +7077,8 @@ NamedDecl *Sema::ActOnVariableDeclarator( diag::err_thread_non_global) << DeclSpec::getSpecifierName(TSCS); else if (!Context.getTargetInfo().isTLSSupported()) { - if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) { + if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice || + getLangOpts().SYCLIsDevice) { // Postpone error emission until we've collected attributes required to // figure out whether it's a host or device variable and whether the // error should be ignored. @@ -7179,13 +7180,18 @@ NamedDecl *Sema::ActOnVariableDeclarator( // Handle attributes prior to checking for duplicates in MergeVarDecl ProcessDeclAttributes(S, NewVD, D); - if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) { + if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice || + getLangOpts().SYCLIsDevice) { if (EmitTLSUnsupportedError && ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) || (getLangOpts().OpenMPIsDevice && OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(), diag::err_thread_unsupported); + +if (EmitTLSUnsupportedError && +(LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice))) + targetDiag(D.getIdentifierLoc(), diag::err_thread_unsupported); // CUDA B.2.5: "__shared__ and __constant__ variables have implied static // storage [duration]." if (SC == SC_None && S->getFnParent() != nullptr && diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 66a2ec1fe9dc..ffc72140dcf4 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -355,10 +355,16 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef Locs, diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc); - if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) + if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) { if (const auto *VD = dyn_cast(D)) checkDeviceDecl(VD, Loc); +if (!Context.getTargetInfo().isTLSSupported()) + if (const auto *VD = dyn_cast(D)) +if (VD->getTLSKind() != VarDecl::TLS_None) + targetDiag(*Locs.begin(), diag::err_thread_unsupported); + } + if (isa(D) && isa(D->getDeclContext()) && !isUnevaluatedContext()) { // C++ [expr.prim.req.nested] p3 diff --git a/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp b/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp new file mode 100644 index ..b84918e528cb --- /dev/null +++ b/clang/test/OpenMP/nvptx_prohibit_thread_local.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc +// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -fsyntax-only + +thread_local const int prohobit_ns_scope = 0; +thread_local int prohobit_ns_scope2 = 0; +thread_local const int allow_ns_scope = 0; + +struct S { + static const thread_local int prohibit_static_member; + static thread_local int prohibit_static_member2; +}; + +struct T { + static const thread_local int allow_static_member; +}; + +void foo() { + // expected-error@+1{{thread-local storage is not supported for the current target}} + thread_local const int prohibit_local = 0; + // expected-error@+1{{thread-local storage is not supported for t
Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
bader added inline comments. Comment at: lib/Sema/SemaDecl.cpp:7599-7602 @@ -7595,3 +7598,6 @@ // of event_t type. -S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT; +// Do not diagnose half type since it is diagnosed as invalid argument +// type for any function eleswhere. +if (!PT->isHalfType()) + S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT; D.setInvalidType(); yaxunl wrote: > bader wrote: > > It looks strange to me. First we check if parameter type is half - we set > > InvalidKernelParam status, later we check again and do not report an error. > > I think it would be simpler just return ValidKernelParam for half data type > > from getOpenCLKernelParameterType, > > > > I think the whole patch should two deleted lines from > > getOpenCLKernelParameterType function + test case. > getOpenCLKernelParameterType should report half type as InvalidKernelParam > since it really is an invalid kernel argument type. We do not emit diagnostic > msg because the msg is redundant, not because half type is a valid kernel > argument type. > > getOpenCLKernelParameterType may be used for other purpose. Reporting half > type as a valid kernel argument violates the semantics of > getOpenCLKernelParameterType and can cause confusion and potential error. Maybe we should the other way. Leave half parameter check here only and remove duplicate check that reports "declaring function parameter of type 'half' is not allowed; did you forget * ?" message. https://reviews.llvm.org/D24666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r282252 - [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
Author: bader Date: Fri Sep 23 09:20:00 2016 New Revision: 282252 URL: http://llvm.org/viewvc/llvm-project?rev=282252&view=rev Log: [OpenCL] Augment pipe built-ins with pipe packet size and alignment. Reviewers: Anastasia, vpykhtin Subscribers: dmitry, cfe-commits Differential Revision: https://reviews.llvm.org/D23992 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=282252&r1=282251&r2=282252&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Sep 23 09:20:00 2016 @@ -14,6 +14,7 @@ #include "CodeGenFunction.h" #include "CGCXXABI.h" #include "CGObjCRuntime.h" +#include "CGOpenCLRuntime.h" #include "CodeGenModule.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" @@ -2139,6 +2140,9 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BIwrite_pipe: { Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); +CGOpenCLRuntime OpenCLRT(CGM); +Value *PacketSize = OpenCLRT.getPipeElemSize(E->getArg(0)); +Value *PacketAlign = OpenCLRT.getPipeElemAlign(E->getArg(0)); // Type of the generic packet parameter. unsigned GenericAS = @@ -2152,19 +2156,21 @@ RValue CodeGenFunction::EmitBuiltinExpr( : "__write_pipe_2"; // Creating a generic function type to be able to call with any builtin or // user defined type. - llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy}; + llvm::Type *ArgTys[] = {Arg0->getType(), I8PTy, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( Int32Ty, llvm::ArrayRef(ArgTys), false); Value *BCast = Builder.CreatePointerCast(Arg1, I8PTy); - return RValue::get(Builder.CreateCall( - CGM.CreateRuntimeFunction(FTy, Name), {Arg0, BCast})); + return RValue::get( + Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, BCast, PacketSize, PacketAlign})); } else { assert(4 == E->getNumArgs() && "Illegal number of parameters to pipe function"); const char *Name = (BuiltinID == Builtin::BIread_pipe) ? "__read_pipe_4" : "__write_pipe_4"; - llvm::Type *ArgTys[] = {Arg0->getType(), Arg1->getType(), Int32Ty, I8PTy}; + llvm::Type *ArgTys[] = {Arg0->getType(), Arg1->getType(), Int32Ty, I8PTy, + Int32Ty, Int32Ty}; Value *Arg2 = EmitScalarExpr(E->getArg(2)), *Arg3 = EmitScalarExpr(E->getArg(3)); llvm::FunctionType *FTy = llvm::FunctionType::get( @@ -2175,7 +2181,8 @@ RValue CodeGenFunction::EmitBuiltinExpr( if (Arg2->getType() != Int32Ty) Arg2 = Builder.CreateZExtOrTrunc(Arg2, Int32Ty); return RValue::get(Builder.CreateCall( - CGM.CreateRuntimeFunction(FTy, Name), {Arg0, Arg1, Arg2, BCast})); + CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, Arg1, Arg2, BCast, PacketSize, PacketAlign})); } } // OpenCL v2.0 s6.13.16 ,s9.17.3.5 - Built-in pipe reserve read and write @@ -2204,9 +2211,12 @@ RValue CodeGenFunction::EmitBuiltinExpr( Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); llvm::Type *ReservedIDTy = ConvertType(getContext().OCLReserveIDTy); +CGOpenCLRuntime OpenCLRT(CGM); +Value *PacketSize = OpenCLRT.getPipeElemSize(E->getArg(0)); +Value *PacketAlign = OpenCLRT.getPipeElemAlign(E->getArg(0)); // Building the generic function prototype. -llvm::Type *ArgTys[] = {Arg0->getType(), Int32Ty}; +llvm::Type *ArgTys[] = {Arg0->getType(), Int32Ty, Int32Ty, Int32Ty}; llvm::FunctionType *FTy = llvm::FunctionType::get( ReservedIDTy, llvm::ArrayRef(ArgTys), false); // We know the second argument is an integer type, but we may need to cast @@ -2214,7 +2224,8 @@ RValue CodeGenFunction::EmitBuiltinExpr( if (Arg1->getType() != Int32Ty) Arg1 = Builder.CreateZExtOrTrunc(Arg1, Int32Ty); return RValue::get( -Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), {Arg0, Arg1})); +Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), + {Arg0, Arg1, PacketSize, PacketAlign})); } // OpenCL v2.0 s6.13.16, s9.17.3.5 - Built-in pipe commit read and write // functions @@ -2240,15 +2251,19 @@ RValue CodeGenFunction::EmitBuiltinExpr( Value *Arg0 = EmitScalarExpr(E->getArg(0)), *Arg1 = EmitScalarExpr(E->getArg(1)); +
Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
This revision was automatically updated to reflect the committed changes. Closed by commit rL282252: [OpenCL] Augment pipe built-ins with pipe packet size and alignment. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23992?vs=70366&id=72276#toc Repository: rL LLVM https://reviews.llvm.org/D23992 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CGOpenCLRuntime.h cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl cfe/trunk/test/CodeGenOpenCL/pipe_types.cl Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -4,59 +4,59 @@ // CHECK: %opencl.reserve_id_t = type opaque void test1(read_only pipe int p, global int *ptr) { - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_read_pipe(p, 2); - // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_read_pipe(p, rid); } void test2(write_only pipe int p, global int *ptr) { - // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_write_pipe(p, 2); - // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_write_pipe(p, rid); } void test3(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_read_pipe(p, 2); - // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_read_pipe(p, rid); } void test4(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_write_pipe(p, 2); - // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_write_pipe(p, rid); } void test5(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = sub_group_reserve_read_pipe(p, 2); - // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__sub_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) sub_group_commit_read_pipe(p, rid); } void test6(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_write_pipe(%
[clang] 923b56e - [NFC] Add a TODO comment to apply nounwind attribute in all GPU modes.
Author: Alexey Bader Date: 2022-07-06T06:20:09-07:00 New Revision: 923b56e7ca96e03cedcb0e3a5df5c05e8e975a38 URL: https://github.com/llvm/llvm-project/commit/923b56e7ca96e03cedcb0e3a5df5c05e8e975a38 DIFF: https://github.com/llvm/llvm-project/commit/923b56e7ca96e03cedcb0e3a5df5c05e8e975a38.diff LOG: [NFC] Add a TODO comment to apply nounwind attribute in all GPU modes. Added: Modified: clang/lib/CodeGen/CGCall.cpp Removed: diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4e26c35c6342..104a30dd6b25 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1931,6 +1931,9 @@ void CodeGenModule::getDefaultFunctionAttributes(StringRef Name, FuncAttrs.addAttribute(llvm::Attribute::Convergent); } + // TODO: NoUnwind attribute should be added for other GPU modes OpenCL, HIP, + // SYCL, OpenMP offload. AFAIK, none of them support exceptions in device + // code. if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) { // Exceptions aren't supported in CUDA device code. FuncAttrs.addAttribute(llvm::Attribute::NoUnwind); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 87b28f5 - [clang][NFC] Extract the EmitAssemblyHelper::TargetTriple member
Author: Pavel Samolysov Date: 2022-04-04T12:16:39+03:00 New Revision: 87b28f5092f2f92fc380f18e8578746bdd2a54b2 URL: https://github.com/llvm/llvm-project/commit/87b28f5092f2f92fc380f18e8578746bdd2a54b2 DIFF: https://github.com/llvm/llvm-project/commit/87b28f5092f2f92fc380f18e8578746bdd2a54b2.diff LOG: [clang][NFC] Extract the EmitAssemblyHelper::TargetTriple member Few times in different methods of the EmitAssemblyHelper class the following code snippet is used to get the TargetTriple and then use it's single method to check some conditions: TargetTriple(TheModule->getTargetTriple()) The parsing of a target triple string is not a trivial operation and it takes time to repeat the parsing many times in different methods of the class and even numerous times in one method just to call a getter (llvm::Triple(TheModule->getTargetTriple()).getVendor()), for example. The patch extracts the TargetTriple member of the EmitAssemblyHelper class to parse the triple only once in the class' constructor. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D122587 Added: Modified: clang/lib/CodeGen/BackendUtil.cpp Removed: diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 61677d368029e..36776d39b952a 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -118,6 +118,8 @@ class EmitAssemblyHelper { std::unique_ptr OS; + Triple TargetTriple; + TargetIRAnalysis getTargetIRAnalysis() const { if (TM) return TM->getTargetIRAnalysis(); @@ -170,7 +172,8 @@ class EmitAssemblyHelper { const LangOptions &LOpts, Module *M) : Diags(_Diags), HSOpts(HeaderSearchOpts), CodeGenOpts(CGOpts), TargetOpts(TOpts), LangOpts(LOpts), TheModule(M), -CodeGenerationTime("codegen", "Code Generation Time") {} +CodeGenerationTime("codegen", "Code Generation Time"), +TargetTriple(TheModule->getTargetTriple()) {} ~EmitAssemblyHelper() { if (CodeGenOpts.DisableFree) @@ -695,7 +698,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM, // manually (and not via PMBuilder), since some passes (eg. InstrProfiling) // are inserted before PMBuilder ones - they'd get the default-constructed // TLI with an unknown target otherwise. - Triple TargetTriple(TheModule->getTargetTriple()); std::unique_ptr TLII( createTLII(TargetTriple, CodeGenOpts)); @@ -965,7 +967,6 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses, raw_pwrite_stream &OS, raw_pwrite_stream *DwoOS) { // Add LibraryInfo. - llvm::Triple TargetTriple(TheModule->getTargetTriple()); std::unique_ptr TLII( createTLII(TargetTriple, CodeGenOpts)); CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII)); @@ -1054,10 +1055,8 @@ void EmitAssemblyHelper::EmitAssemblyWithLegacyPassManager( // Emit a module summary by default for Regular LTO except for ld64 // targets bool EmitLTOSummary = - (CodeGenOpts.PrepareForLTO && - !CodeGenOpts.DisableLLVMPasses && - llvm::Triple(TheModule->getTargetTriple()).getVendor() != - llvm::Triple::Apple); + (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses && + TargetTriple.getVendor() != llvm::Triple::Apple); if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); @@ -1338,7 +1337,6 @@ void EmitAssemblyHelper::RunOptimizationPipeline( // Register the target library analysis directly and give it a customized // preset TLI. - Triple TargetTriple(TheModule->getTargetTriple()); std::unique_ptr TLII( createTLII(TargetTriple, CodeGenOpts)); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); @@ -1474,8 +1472,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline( // targets bool EmitLTOSummary = (CodeGenOpts.PrepareForLTO && !CodeGenOpts.DisableLLVMPasses && - llvm::Triple(TheModule->getTargetTriple()).getVendor() != - llvm::Triple::Apple); + TargetTriple.getVendor() != llvm::Triple::Apple); if (EmitLTOSummary) { if (!TheModule->getModuleFlag("ThinLTO")) TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0)); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AMDGPU] Adding the amdgpu-num-work-groups function attribute (PR #75647)
bader wrote: > How does this attribute relate to `reqd_work_group_size` and related existing > attributes? They seems to be different/"unrelated". Based on the description of the `amdgpu-num-work-groups` attribute it provides "number of work-groups", whereas `reqd_work_group_size` provides "number of work-items in a work-group". I think this attributed can be useful for other targets. The optimization ideas described in https://github.com/llvm/llvm-project/pull/75647#issuecomment-1863352459 seems to be generic. There is an RFC to unify some existing functionality exposing "grid" information: https://discourse.llvm.org/t/proposing-llvm-gpu-intrinsics/75374. This might fall into similar category. https://github.com/llvm/llvm-project/pull/75647 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 128f39d - Fix crash in getFullyQualifiedName for inline namespace
Author: Alexey Bader Date: 2019-12-28T16:35:51+03:00 New Revision: 128f39da932be50cb49646084820119e6e0d1e22 URL: https://github.com/llvm/llvm-project/commit/128f39da932be50cb49646084820119e6e0d1e22 DIFF: https://github.com/llvm/llvm-project/commit/128f39da932be50cb49646084820119e6e0d1e22.diff LOG: Fix crash in getFullyQualifiedName for inline namespace Summary: The ICE happens when the most outer namespace is an inline namespace. Reviewers: bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ebevhan, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71962 Added: Modified: clang/lib/AST/QualTypeNames.cpp clang/unittests/Tooling/QualTypeNamesTest.cpp Removed: diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index f28f00171cce..73a33a208233 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -192,7 +192,7 @@ static NestedNameSpecifier *createOuterNNS(const ASTContext &Ctx, const Decl *D, // Ignore inline namespace; NS = dyn_cast(NS->getDeclContext()); } -if (NS->getDeclName()) { +if (NS && NS->getDeclName()) { return createNestedNameSpecifier(Ctx, NS, WithGlobalNsPrefix); } return nullptr; // no starting '::', no anonymous diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index b6c302977876..ff6b78c2666d 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -223,6 +223,17 @@ TEST(QualTypeNameTest, getFullyQualifiedName) { "}\n" ); + TypeNameVisitor InlineNamespace; + InlineNamespace.ExpectedQualTypeNames["c"] = "B::C"; + InlineNamespace.runOver("inline namespace A {\n" + " namespace B {\n" + "class C {};\n" + " }\n" + "}\n" + "using namespace A::B;\n" + "C c;\n", + TypeNameVisitor::Lang_CXX11); + TypeNameVisitor AnonStrucs; AnonStrucs.ExpectedQualTypeNames["a"] = "short"; AnonStrucs.ExpectedQualTypeNames["un_in_st_1"] = ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a500a43 - [CodeGen][AMDGPU] Fix ICE for static initializer IR generation
Author: Alexey Bader Date: 2020-12-12T23:26:54+03:00 New Revision: a500a4358789d1794bc672421c55900ea2bbc938 URL: https://github.com/llvm/llvm-project/commit/a500a4358789d1794bc672421c55900ea2bbc938 DIFF: https://github.com/llvm/llvm-project/commit/a500a4358789d1794bc672421c55900ea2bbc938.diff LOG: [CodeGen][AMDGPU] Fix ICE for static initializer IR generation Differential Revision: https://reviews.llvm.org/D92782 Added: Modified: clang/lib/CodeGen/CGDecl.cpp clang/test/CodeGen/address-space.c Removed: diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 478821665e45..a01638f0b67b 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -353,12 +353,11 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D, if (GV->getValueType() != Init->getType()) { llvm::GlobalVariable *OldGV = GV; -GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), - OldGV->isConstant(), - OldGV->getLinkage(), Init, "", - /*InsertBefore*/ OldGV, - OldGV->getThreadLocalMode(), - CGM.getContext().getTargetAddressSpace(D.getType())); +GV = new llvm::GlobalVariable( +CGM.getModule(), Init->getType(), OldGV->isConstant(), +OldGV->getLinkage(), Init, "", +/*InsertBefore*/ OldGV, OldGV->getThreadLocalMode(), +OldGV->getType()->getPointerAddressSpace()); GV->setVisibility(OldGV->getVisibility()); GV->setDSOLocal(OldGV->isDSOLocal()); GV->setComdat(OldGV->getComdat()); diff --git a/clang/test/CodeGen/address-space.c b/clang/test/CodeGen/address-space.c index c66dfc87c0c0..baefb4b983fc 100644 --- a/clang/test/CodeGen/address-space.c +++ b/clang/test/CodeGen/address-space.c @@ -59,3 +59,14 @@ void __attribute__((address_space(1)))* void_ptr_arithmetic_test(void __attribute__((address_space(1))) *arg) { return arg + 4; } + +// CHECK-LABEL: define i32* @test5( +const unsigned *test5() { + // Intentionally leave a part of an array uninitialized. This triggers a + // diff erent code path contrary to a fully initialized array. + // CHECK: ret i32* getelementptr inbounds ([256 x i32] + static const unsigned bars[256] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}; + return &bars[0]; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 9263931 - [SYCL] Assume SYCL device functions are convergent
Author: Alexey Bader Date: 2020-09-29T15:23:50+03:00 New Revision: 9263931fcccdc99000c1de668bea330711333729 URL: https://github.com/llvm/llvm-project/commit/9263931fcccdc99000c1de668bea330711333729 DIFF: https://github.com/llvm/llvm-project/commit/9263931fcccdc99000c1de668bea330711333729.diff LOG: [SYCL] Assume SYCL device functions are convergent SYCL device compiler (similar to other SPMD compilers) assumes that functions are convergent by default to avoid invalid transformations. This attribute can be removed if compiler can prove that function does not have convergent operations. Reviewed By: Naghasan Differential Revision: https://reviews.llvm.org/D87282 Added: clang/test/CodeGenSYCL/convergent.cpp Modified: clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 2d008d8a3fbe..42224339250d 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2882,7 +2882,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.Coroutines = Opts.CPlusPlus20 || Args.hasArg(OPT_fcoroutines_ts); Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) || -Args.hasArg(OPT_fconvergent_functions); + Opts.SYCLIsDevice || + Args.hasArg(OPT_fconvergent_functions); Opts.DoubleSquareBracketAttributes = Args.hasFlag(OPT_fdouble_square_bracket_attributes, diff --git a/clang/test/CodeGenSYCL/convergent.cpp b/clang/test/CodeGenSYCL/convergent.cpp new file mode 100644 index ..784fb8976c27 --- /dev/null +++ b/clang/test/CodeGenSYCL/convergent.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsycl -fsycl-is-device -emit-llvm -disable-llvm-passes \ +// RUN: -triple spir64-unknown-unknown-sycldevice -emit-llvm %s -o - | \ +// RUN: FileCheck %s + +// CHECK-DAG: Function Attrs: +// CHECK-DAG-SAME: convergent +// CHECK-DAG-NEXT: define void @_Z3foov +void foo() { + int a = 1; +} + +template +__attribute__((sycl_kernel)) void kernel_single_task(const Func &kernelFunc) { + kernelFunc(); +} + +int main() { + kernel_single_task([] { foo(); }); + return 0; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2ab513c - [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL
Author: Alexey Bader Date: 2021-05-18T10:27:35+03:00 New Revision: 2ab513cd3e0648806db7ed1f8170ad4a3d4e7749 URL: https://github.com/llvm/llvm-project/commit/2ab513cd3e0648806db7ed1f8170ad4a3d4e7749 DIFF: https://github.com/llvm/llvm-project/commit/2ab513cd3e0648806db7ed1f8170ad4a3d4e7749.diff LOG: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL Differential Revision: https://reviews.llvm.org/D100396 Added: Modified: clang/docs/SYCLSupport.rst clang/include/clang/AST/Type.h clang/include/clang/Basic/AddressSpaces.h clang/include/clang/Sema/ParsedAttr.h clang/lib/AST/ASTContext.cpp clang/lib/AST/ItaniumMangle.cpp clang/lib/AST/TypePrinter.cpp clang/lib/Basic/Targets/AMDGPU.cpp clang/lib/Basic/Targets/NVPTX.h clang/lib/Basic/Targets/SPIR.h clang/lib/Basic/Targets/TCE.h clang/lib/Basic/Targets/X86.h clang/test/CodeGenSYCL/address-space-conversions.cpp clang/test/SemaSYCL/address-space-conversions.cpp clang/test/SemaTemplate/address_space-dependent.cpp Removed: diff --git a/clang/docs/SYCLSupport.rst b/clang/docs/SYCLSupport.rst index d45ecfbea53f8..6b529e3eb0127 100644 --- a/clang/docs/SYCLSupport.rst +++ b/clang/docs/SYCLSupport.rst @@ -34,10 +34,20 @@ the address space qualifier inference as detailed in The default address space is "generic-memory", which is a virtual address space that overlaps the global, local, and private address spaces. SYCL mode enables -explicit conversions to/from the default address space from/to the address -space-attributed type and implicit conversions from the address space-attributed -type to the default address space. All named address spaces are disjoint and -sub-sets of default address space. +following conversions: + +- explicit conversions to/from the default address space from/to the address + space-attributed type +- implicit conversions from the address space-attributed type to the default + address space +- explicit conversions to/from the global address space from/to the + ``__attribute__((opencl_global_device))`` or + ``__attribute__((opencl_global_host))`` address space-attributed type +- implicit conversions from the ``__attribute__((opencl_global_device))`` or + ``__attribute__((opencl_global_host))`` address space-attributed type to the + global address space + +All named address spaces are disjoint and sub-sets of default address space. The SPIR target allocates SYCL namespace scope variables in the global address space. @@ -93,6 +103,10 @@ space attributes for pointers: - SYCL address_space enumeration * - ``__attribute__((opencl_global))`` - global_space, constant_space + * - ``__attribute__((opencl_global_device))`` + - global_space + * - ``__attribute__((opencl_global_host))`` + - global_space * - ``__attribute__((opencl_local))`` - local_space * - ``__attribute__((opencl_private))`` diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index 84de51aba5b2d..9f46d53378976 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -486,13 +486,16 @@ class Qualifiers { // allocated on device, which are a subset of __global. (A == LangAS::opencl_global && (B == LangAS::opencl_global_device || B == LangAS::opencl_global_host)) || + (A == LangAS::sycl_global && (B == LangAS::sycl_global_device || + B == LangAS::sycl_global_host)) || // Consider pointer size address spaces to be equivalent to default. ((isPtrSizeAddressSpace(A) || A == LangAS::Default) && (isPtrSizeAddressSpace(B) || B == LangAS::Default)) || // Default is a superset of SYCL address spaces. (A == LangAS::Default && (B == LangAS::sycl_private || B == LangAS::sycl_local || - B == LangAS::sycl_global)); + B == LangAS::sycl_global || B == LangAS::sycl_global_device || + B == LangAS::sycl_global_host)); } /// Returns true if the address space in these qualifiers is equal to or diff --git a/clang/include/clang/Basic/AddressSpaces.h b/clang/include/clang/Basic/AddressSpaces.h index 5fa031250a629..99bb67fd26d19 100644 --- a/clang/include/clang/Basic/AddressSpaces.h +++ b/clang/include/clang/Basic/AddressSpaces.h @@ -46,6 +46,8 @@ enum class LangAS : unsigned { // SYCL specific address spaces. sycl_global, + sycl_global_device, + sycl_global_host, sycl_local, sycl_private, diff --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h index 347925873b30f..f47f557adeb10 100644 --- a/clang/include/clang/Sema/ParsedAttr.h +++ b/clang/include/clang/Sema/ParsedAttr.h @@ -657,6 +657,10 @@ class ParsedAttr final switch (getKind()) { case
[clang] 15feaaa - Add myself as a code owner for SYCL support
Author: Alexey Bader Date: 2021-09-20T09:32:25+03:00 New Revision: 15feaaa359c7245bb59ff0a2aa3b806682f44286 URL: https://github.com/llvm/llvm-project/commit/15feaaa359c7245bb59ff0a2aa3b806682f44286 DIFF: https://github.com/llvm/llvm-project/commit/15feaaa359c7245bb59ff0a2aa3b806682f44286.diff LOG: Add myself as a code owner for SYCL support Added: Modified: clang/CODE_OWNERS.TXT Removed: diff --git a/clang/CODE_OWNERS.TXT b/clang/CODE_OWNERS.TXT index faf9575a2898..740aeeb7125b 100644 --- a/clang/CODE_OWNERS.TXT +++ b/clang/CODE_OWNERS.TXT @@ -8,6 +8,10 @@ beautification by scripts. The fields are: name (N), email (E), web-address (W), PGP key ID and fingerprint (P), description (D), and snail-mail address (S). +N: Alexey Bader +E: alexey.ba...@intel.com +D: SYCL support + N: Aaron Ballman E: aa...@aaronballman.com D: Clang attributes ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c064ba3 - [NFC] Add commas in code comments.
Author: Alexey Bader Date: 2021-08-13T08:59:47+03:00 New Revision: c064ba34c7d867c1180279fe3dca8817d835cb28 URL: https://github.com/llvm/llvm-project/commit/c064ba34c7d867c1180279fe3dca8817d835cb28 DIFF: https://github.com/llvm/llvm-project/commit/c064ba34c7d867c1180279fe3dca8817d835cb28.diff LOG: [NFC] Add commas in code comments. Added: Modified: clang/include/clang/Sema/ParsedAttr.h Removed: diff --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h index 61a36ddcc1db..408032cec7e8 100644 --- a/clang/include/clang/Sema/ParsedAttr.h +++ b/clang/include/clang/Sema/ParsedAttr.h @@ -627,7 +627,7 @@ class ParsedAttr final /// a Spelling enumeration, the value UINT_MAX is returned. unsigned getSemanticSpelling() const; - /// If this is an OpenCL address space attribute returns its representation + /// If this is an OpenCL address space attribute, returns its representation /// in LangAS, otherwise returns default address space. LangAS asOpenCLLangAS() const { switch (getParsedKind()) { @@ -650,7 +650,7 @@ class ParsedAttr final } } - /// If this is an OpenCL address space attribute returns its SYCL + /// If this is an OpenCL address space attribute, returns its SYCL /// representation in LangAS, otherwise returns default address space. LangAS asSYCLLangAS() const { switch (getKind()) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d754b97 - [NFC] Drop idle compiler option from the test.
Author: Alexey Bader Date: 2021-08-13T13:20:11+03:00 New Revision: d754b970eddb83b1c68346a36b067391d93166b0 URL: https://github.com/llvm/llvm-project/commit/d754b970eddb83b1c68346a36b067391d93166b0 DIFF: https://github.com/llvm/llvm-project/commit/d754b970eddb83b1c68346a36b067391d93166b0.diff LOG: [NFC] Drop idle compiler option from the test. Differential Revision: https://reviews.llvm.org/D108020 Added: Modified: clang/test/AST/ast-print-sycl-unique-stable-name.cpp Removed: diff --git a/clang/test/AST/ast-print-sycl-unique-stable-name.cpp b/clang/test/AST/ast-print-sycl-unique-stable-name.cpp index 3f49ea9ee733c..b55d01aa1b6b6 100644 --- a/clang/test/AST/ast-print-sycl-unique-stable-name.cpp +++ b/clang/test/AST/ast-print-sycl-unique-stable-name.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -ast-print -fsycl-is-device %s -o - -triple spir64-sycldevice | FileCheck %s +// RUN: %clang_cc1 -ast-print -fsycl-is-device %s -o - | FileCheck %s template void WrappedInTemplate(T t) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 49682f1 - [SPIR-V] Add translator tool
Author: Henry Linjamäki Date: 2021-11-18T03:41:24+03:00 New Revision: 49682f14bf3fb8db5e2721d9896b27bb4c2bd635 URL: https://github.com/llvm/llvm-project/commit/49682f14bf3fb8db5e2721d9896b27bb4c2bd635 DIFF: https://github.com/llvm/llvm-project/commit/49682f14bf3fb8db5e2721d9896b27bb4c2bd635.diff LOG: [SPIR-V] Add translator tool Add a tool for constructing commands for translating LLVM IR to SPIR-V. Used by HIPSPV tool chain (D110618). Reviewed By: bader Differential Revision: https://reviews.llvm.org/D112404 Added: clang/lib/Driver/ToolChains/SPIRV.cpp clang/lib/Driver/ToolChains/SPIRV.h Modified: clang/lib/Driver/CMakeLists.txt Removed: diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt index 61a1cd04e088..31e357b67361 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -69,6 +69,7 @@ add_clang_library(clangDriver ToolChains/PS4CPU.cpp ToolChains/RISCVToolchain.cpp ToolChains/Solaris.cpp + ToolChains/SPIRV.cpp ToolChains/TCE.cpp ToolChains/VEToolchain.cpp ToolChains/WebAssembly.cpp diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp new file mode 100644 index ..3f942478e2ad --- /dev/null +++ b/clang/lib/Driver/ToolChains/SPIRV.cpp @@ -0,0 +1,48 @@ +//===--- SPIRV.cpp - SPIR-V Tool Implementations *- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// +#include "SPIRV.h" +#include "CommonArgs.h" +#include "clang/Driver/Compilation.h" +#include "clang/Driver/Driver.h" +#include "clang/Driver/InputInfo.h" +#include "clang/Driver/Options.h" + +using namespace clang::driver::tools; +using namespace llvm::opt; + +void SPIRV::constructTranslateCommand(Compilation &C, const Tool &T, + const JobAction &JA, + const InputInfo &Output, + const InputInfo &Input, + const llvm::opt::ArgStringList &Args) { + llvm::opt::ArgStringList CmdArgs(Args); + CmdArgs.push_back(Input.getFilename()); + + if (Input.getType() == types::TY_PP_Asm) +CmdArgs.push_back("-to-binary"); + if (Output.getType() == types::TY_PP_Asm) +CmdArgs.push_back("-spirv-text"); + + CmdArgs.append({"-o", Output.getFilename()}); + + const char *Exec = + C.getArgs().MakeArgString(T.getToolChain().GetProgramPath("llvm-spirv")); + C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(), + Exec, CmdArgs, Input, Output)); +} + +void SPIRV::Translator::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &Args, + const char *LinkingOutput) const { + claimNoWarnArgs(Args); + if (Inputs.size() != 1) +llvm_unreachable("Invalid number of input files."); + constructTranslateCommand(C, *this, JA, Output, Inputs[0], {}); +} diff --git a/clang/lib/Driver/ToolChains/SPIRV.h b/clang/lib/Driver/ToolChains/SPIRV.h new file mode 100644 index ..35d0446bd8b8 --- /dev/null +++ b/clang/lib/Driver/ToolChains/SPIRV.h @@ -0,0 +1,46 @@ +//===--- SPIRV.h - SPIR-V Tool Implementations --*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H +#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_SPIRV_H + +#include "clang/Driver/Tool.h" +#include "clang/Driver/ToolChain.h" + +namespace clang { +namespace driver { +namespace tools { +namespace SPIRV { + +void addTranslatorArgs(const llvm::opt::ArgList &InArgs, + llvm::opt::ArgStringList &OutArgs); + +void constructTranslateCommand(Compilation &C, const Tool &T, + const JobAction &JA, const InputInfo &Output, + const InputInfo &Input, + const llvm::opt::ArgStringList &Args); + +class LLVM_LIBRARY_VISIBILITY Translator : public Tool { +public: + Translator(const ToolChain &TC) + : Tool("SPIR-V::Translator", "llvm-spirv", TC) {} + + bool hasIntegratedCPP() const override { return false; } + bool hasIntegratedAssembler() const override { return true; } + +
[clang] 66bd607 - [Attr][Doc] Fix pragma unroll documentation.
Author: Alexey Bader Date: 2022-10-19T03:50:47-07:00 New Revision: 66bd6074c133402e45075b591c062c22f308ef26 URL: https://github.com/llvm/llvm-project/commit/66bd6074c133402e45075b591c062c22f308ef26 DIFF: https://github.com/llvm/llvm-project/commit/66bd6074c133402e45075b591c062c22f308ef26.diff LOG: [Attr][Doc] Fix pragma unroll documentation. There is a contradiction in the #pragma unroll behavior documentation. It says that specifying `#pragma unroll` without a parameter directs the loop unroller to attempt to partially unroll the loop if the trip count is not known at compile time. At the same time later it states that `#pragma unroll` has identical semantics to `#pragma clang loop unroll(full)`, which doesn't attempt to unroll partially if the trip count is not known at compile time. pragma clang loop unroll(enable): If unroll(enable) is specified the unroller will attempt to fully unroll the loop if the trip count is known at compile time. If the fully unrolled code size is greater than an internal limit the loop will be partially unrolled up to this limit. If the trip count is not known at compile time the loop will be partially unrolled with a heuristically chosen unroll factor. pragma clang loop unroll(full): If unroll(full) is specified the unroller will attempt to fully unroll the loop if the trip count is known at compile time identically to unroll(enable). However, with unroll(full) the loop will not be unrolled if the loop count is not known at compile time. Differential Revision: https://reviews.llvm.org/D136160 Added: Modified: clang/include/clang/Basic/AttrDocs.td Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 33a18ac033252..484052f4db8ad 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -3569,7 +3569,7 @@ Specifying ``#pragma nounroll`` indicates that the loop should not be unrolled: } ``#pragma unroll`` and ``#pragma unroll _value_`` have identical semantics to -``#pragma clang loop unroll(full)`` and +``#pragma clang loop unroll(enable)`` and ``#pragma clang loop unroll_count(_value_)`` respectively. ``#pragma nounroll`` is equivalent to ``#pragma clang loop unroll(disable)``. See `language extensions ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a2e2f47 - [Clang][Docs] Fix typo in clang-offload-packager documentation
Author: Alexey Bader Date: 2023-09-11T16:24:37-07:00 New Revision: a2e2f471c51f0aea836a4929dfdf50523dcff1eb URL: https://github.com/llvm/llvm-project/commit/a2e2f471c51f0aea836a4929dfdf50523dcff1eb DIFF: https://github.com/llvm/llvm-project/commit/a2e2f471c51f0aea836a4929dfdf50523dcff1eb.diff LOG: [Clang][Docs] Fix typo in clang-offload-packager documentation Fixed formatting of the section violating 80-char line limit. Added: Modified: clang/docs/ClangOffloadPackager.rst Removed: diff --git a/clang/docs/ClangOffloadPackager.rst b/clang/docs/ClangOffloadPackager.rst index 1d6ded952e8adfe..2b985e260e302de 100644 --- a/clang/docs/ClangOffloadPackager.rst +++ b/clang/docs/ClangOffloadPackager.rst @@ -124,7 +124,7 @@ array of the :ref:`string entry` format. +--+--+---+ | Type | Identifier | Description | +==+==+===+ -| uint64_t | key offset | Absolute byte offset of the key in th string table| +| uint64_t | key offset | Absolute byte offset of the key in the string table | +--+--+---+ | uint64_t | value offset | Absolute byte offset of the value in the string table | +--+--+---+ @@ -145,9 +145,9 @@ Usage = This tool can be used with the following arguments. Generally information is -passed as a key-value pair to the ``image=`` argument. The ``file`` and ``triple``, -arguments are considered mandatory to make a valid image. The ``arch`` argument -is suggested. +passed as a key-value pair to the ``image=`` argument. The ``file`` and +``triple``, arguments are considered mandatory to make a valid image. +The ``arch`` argument is suggested. .. code-block:: console ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bd97704 - [SYCL] Driver option to select SYCL version
Author: Ruyman Date: 2020-02-27T15:08:42+03:00 New Revision: bd97704eb5a95ecb048ce343c1a4be5d94e5 URL: https://github.com/llvm/llvm-project/commit/bd97704eb5a95ecb048ce343c1a4be5d94e5 DIFF: https://github.com/llvm/llvm-project/commit/bd97704eb5a95ecb048ce343c1a4be5d94e5.diff LOG: [SYCL] Driver option to select SYCL version Summary: User can select the version of SYCL the compiler will use via the flag -sycl-std, similar to -cl-std. The flag defines the LangOpts.SYCLVersion option to the version of SYCL. The default value is undefined. If driver is building SYCL code, flag is set to the default SYCL version (1.2.1) The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro, which should be defined according to SYCL 1.2.1 standard. Only valid value at this point for the flag is 1.2.1. Co-Authored-By: David Wood Signed-off-by: Ruyman Reyes Subscribers: ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72857 Signed-off-by: Alexey Bader Added: Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/test/Driver/sycl.c clang/test/Frontend/sycl-aux-triple.cpp clang/test/Preprocessor/sycl-macro.cpp clang/test/SemaSYCL/kernel-attribute.cpp Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 3cc7c384ac10..53b87b737568 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -230,7 +230,9 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code") LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP") LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP") +LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") +LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index f1801e3e89e7..36626342e364 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3420,10 +3420,12 @@ defm underscoring : BooleanFFlag<"underscoring">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; // C++ SYCL options -def fsycl : Flag<["-"], "fsycl">, Group, +def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Enable SYCL kernels compilation for device">; -def fno_sycl : Flag<["-"], "fno-sycl">, Group, +def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>, HelpText<"Disable SYCL kernels compilation for device">; +def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, + HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">; include "CC1Options.td" diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index d387a1dc2079..87596dd19c5a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4040,9 +4040,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); } - if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { +CmdArgs.push_back("-fsycl"); CmdArgs.push_back("-fsycl-is-device"); +if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) { + A->render(Args, CmdArgs); +} else { + // Ensure the default version in SYCL mode is 1.2.1 (aka 2017) + CmdArgs.push_back("-sycl-std=2017"); +} + } + if (IsOpenMPDevice) { // We have to pass the triple of the host if compiling for an OpenMP device. std::string NormalizedTriple = diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 9cc41c9d96f8..76f63d065017 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2535,6 +2535,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, LangStd = OpenCLLangStd; } + Opts.SYCL = Args.hasArg(options::OPT_fsycl); + Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); + if (Opts.SYCL) { +// -sycl-std applies to any SYCL source, not only those containing kernels, +// but also those using the SYCL API +if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) { +
[clang] 740ed61 - Revert "[SYCL] Driver option to select SYCL version"
Author: Alexey Bader Date: 2020-02-27T16:23:54+03:00 New Revision: 740ed617f7d4d16e7883636c5eff994f8be7eba4 URL: https://github.com/llvm/llvm-project/commit/740ed617f7d4d16e7883636c5eff994f8be7eba4 DIFF: https://github.com/llvm/llvm-project/commit/740ed617f7d4d16e7883636c5eff994f8be7eba4.diff LOG: Revert "[SYCL] Driver option to select SYCL version" This reverts commit bd97704eb5a95ecb048ce343c1a4be5d94e5. It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt Added: Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/test/Driver/sycl.c clang/test/Frontend/sycl-aux-triple.cpp clang/test/Preprocessor/sycl-macro.cpp clang/test/SemaSYCL/kernel-attribute.cpp Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 53b87b737568..3cc7c384ac10 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -230,9 +230,7 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code") LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP") LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP") -LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") -LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 36626342e364..f1801e3e89e7 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3420,12 +3420,10 @@ defm underscoring : BooleanFFlag<"underscoring">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; // C++ SYCL options -def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, CoreOption]>, +def fsycl : Flag<["-"], "fsycl">, Group, HelpText<"Enable SYCL kernels compilation for device">; -def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>, +def fno_sycl : Flag<["-"], "fno-sycl">, Group, HelpText<"Disable SYCL kernels compilation for device">; -def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, - HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">; include "CC1Options.td" diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 87596dd19c5a..d387a1dc2079 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4040,18 +4040,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); } - if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { -CmdArgs.push_back("-fsycl"); + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) CmdArgs.push_back("-fsycl-is-device"); -if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) { - A->render(Args, CmdArgs); -} else { - // Ensure the default version in SYCL mode is 1.2.1 (aka 2017) - CmdArgs.push_back("-sycl-std=2017"); -} - } - if (IsOpenMPDevice) { // We have to pass the triple of the host if compiling for an OpenMP device. std::string NormalizedTriple = diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 76f63d065017..9cc41c9d96f8 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2535,24 +2535,6 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, LangStd = OpenCLLangStd; } - Opts.SYCL = Args.hasArg(options::OPT_fsycl); - Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); - if (Opts.SYCL) { -// -sycl-std applies to any SYCL source, not only those containing kernels, -// but also those using the SYCL API -if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) { - Opts.SYCLVersion = llvm::StringSwitch(A->getValue()) - .Cases("2017", "1.2.1", "121", "sycl-1.2.1", 2017) - .Default(0U); - - if (Opts.SYCLVersion == 0U) { -// User has passed an invalid value to the flag, this is an error -Diags.Report(diag::err_drv_invalid_value) -<< A->getAsString(Args) << A->getValue(); - } -} - } - Opts.IncludeDefaultHeader = Args.hasArg(OPT_finclude_default_header); Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_ope
[clang] c094e7d - [SYCL] Add sycl_kernel attribute for accelerated code outlining
Author: Mariya Podchishchaeva Date: 2019-12-03T16:13:22+03:00 New Revision: c094e7dc4b3f9d1c1e590b008bb1cc46e3496abd URL: https://github.com/llvm/llvm-project/commit/c094e7dc4b3f9d1c1e590b008bb1cc46e3496abd DIFF: https://github.com/llvm/llvm-project/commit/c094e7dc4b3f9d1c1e590b008bb1cc46e3496abd.diff LOG: [SYCL] Add sycl_kernel attribute for accelerated code outlining SYCL is single source offload programming model relying on compiler to separate device code (i.e. offloaded to an accelerator) from the code executed on the host. Here is code example of the SYCL program to demonstrate compiler outlining work: ``` int foo(int x) { return ++x; } int bar(int x) { throw std::exception("CPU code only!"); } ... using namespace cl::sycl; queue Q; buffer a(range<1>{1024}); Q.submit([&](handler& cgh) { auto A = a.get_access(cgh); cgh.parallel_for(range<1>{1024}, [=](id<1> index) { A[index] = index[0] + foo(42); }); } ... ``` SYCL device compiler must compile lambda expression passed to cl::sycl::handler::parallel_for method and function foo called from this lambda expression for an "accelerator". SYCL device compiler also must ignore bar function as it's not required for offloaded code execution. This patch adds the sycl_kernel attribute, which is used to mark code passed to cl::sycl::handler::parallel_for as "accelerated code". Attribute must be applied to function templates which parameters include at least "kernel name" and "kernel function object". These parameters will be used to establish an ABI between the host application and offloaded part. Reviewers: jlebar, keryell, Naghasan, ABataev, Anastasia, bader, aaron.ballman, rjmccall, rsmith Reviewed By: keryell, bader Subscribers: mgorny, OlegM, ArturGainullin, agozillon, aaron.ballman, ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60455 Signed-off-by: Alexey Bader Added: clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp clang/test/SemaSYCL/kernel-attribute.cpp Modified: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/include/clang/Basic/DiagnosticSemaKinds.td clang/lib/Sema/SemaDeclAttr.cpp Removed: diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 21cf53f0a815..4ea1c9f58beb 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -121,6 +121,11 @@ def GlobalVar : SubsetSubjectisInlineSpecified()}], "inline functions">; +def FunctionTmpl +: SubsetSubjectgetTemplatedKind() == + FunctionDecl::TK_FunctionTemplate}], +"function templates">; + // FIXME: this hack is needed because DeclNodes.td defines the base Decl node // type to be a class, not a definition. This makes it impossible to create an // attribute subject which accepts a Decl. Normally, this is not a problem, @@ -296,6 +301,7 @@ def MicrosoftExt : LangOpt<"MicrosoftExt">; def Borland : LangOpt<"Borland">; def CUDA : LangOpt<"CUDA">; def HIP : LangOpt<"HIP">; +def SYCL : LangOpt<"SYCLIsDevice">; def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">; def CPlusPlus : LangOpt<"CPlusPlus">; def OpenCL : LangOpt<"OpenCL">; @@ -1056,6 +1062,13 @@ def CUDAShared : InheritableAttr { let Documentation = [Undocumented]; } +def SYCLKernel : InheritableAttr { + let Spellings = [Clang<"sycl_kernel">]; + let Subjects = SubjectList<[FunctionTmpl]>; + let LangOpts = [SYCL]; + let Documentation = [SYCLKernelDocs]; +} + def C11NoReturn : InheritableAttr { let Spellings = [Keyword<"_Noreturn">]; let Subjects = SubjectList<[Function], ErrorDiag>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index f35199f81c3e..d47315a3f518 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -253,6 +253,79 @@ any option of a multiversioned function is undefined. }]; } +def SYCLKernelDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``sycl_kernel`` attribute specifies that a function template will be used +to outline device code and to generate an OpenCL kernel. +Here is a code example of the SYCL program, which demonstrates the compiler's +outlining job: +.. code-block:: c++ + + int foo(int x) { return ++x; } + + using namespace cl::sycl; + queue Q; + buffer a(range<1>{1024}); + Q.submit([&](handler& cgh) { +auto A = a.get_access(cgh); +cgh.parallel_for(range<1>{1024}, [=](id<1> index) { + A[index] = index[0] + foo(42); +}); + } + +A C++ function object passed to the ``parallel_for`` is called a "SYCL kernel". +A SYCL kernel defines the entry point to the "device part" of the code. The +compiler will emit all symbols accessible from a "kernel". In this code +example, the compiler will emit "foo" function. More
[clang] 11a9bae - [AST] Enable expression of OpenCL language address spaces an attribute
Author: Victor Lomuller Date: 2019-12-05T12:24:06+03:00 New Revision: 11a9bae8f66986751078501988b4414f24dbe37e URL: https://github.com/llvm/llvm-project/commit/11a9bae8f66986751078501988b4414f24dbe37e DIFF: https://github.com/llvm/llvm-project/commit/11a9bae8f66986751078501988b4414f24dbe37e.diff LOG: [AST] Enable expression of OpenCL language address spaces an attribute Summary: Enable a way to set OpenCL language address space using attributes in addition to existing keywords. Signed-off-by: Victor Lomuller vic...@codeplay.com Reviewers: aaron.ballman, Anastasia Subscribers: yaxunl, ebevhan, cfe-commits, Naghasan Tags: #clang Differential Revision: https://reviews.llvm.org/D71005 Signed-off-by: Alexey Bader Added: clang/test/AST/language_address_space_attribute.cpp Modified: clang/include/clang/Basic/Attr.td clang/lib/Sema/SemaType.cpp clang/test/SemaOpenCL/address-spaces.cl Removed: diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 4ea1c9f58beb..9ca4be0e07c8 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1120,27 +1120,27 @@ def OpenCLAccess : Attr { } def OpenCLPrivateAddressSpace : TypeAttr { - let Spellings = [Keyword<"__private">, Keyword<"private">]; + let Spellings = [Keyword<"__private">, Keyword<"private">, Clang<"opencl_private">]; let Documentation = [OpenCLAddressSpacePrivateDocs]; } def OpenCLGlobalAddressSpace : TypeAttr { - let Spellings = [Keyword<"__global">, Keyword<"global">]; + let Spellings = [Keyword<"__global">, Keyword<"global">, Clang<"opencl_global">]; let Documentation = [OpenCLAddressSpaceGlobalDocs]; } def OpenCLLocalAddressSpace : TypeAttr { - let Spellings = [Keyword<"__local">, Keyword<"local">]; + let Spellings = [Keyword<"__local">, Keyword<"local">, Clang<"opencl_local">]; let Documentation = [OpenCLAddressSpaceLocalDocs]; } def OpenCLConstantAddressSpace : TypeAttr { - let Spellings = [Keyword<"__constant">, Keyword<"constant">]; + let Spellings = [Keyword<"__constant">, Keyword<"constant">, Clang<"opencl_constant">]; let Documentation = [OpenCLAddressSpaceConstantDocs]; } def OpenCLGenericAddressSpace : TypeAttr { - let Spellings = [Keyword<"__generic">, Keyword<"generic">]; + let Spellings = [Keyword<"__generic">, Keyword<"generic">, Clang<"opencl_generic">]; let Documentation = [OpenCLAddressSpaceGenericDocs]; } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 52a0581643bc..1375ccbabc50 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -7407,6 +7407,16 @@ static void HandleLifetimeBoundAttr(TypeProcessingState &State, } } +static bool isAddressSpaceKind(const ParsedAttr &attr) { + auto attrKind = attr.getKind(); + + return attrKind == ParsedAttr::AT_AddressSpace || + attrKind == ParsedAttr::AT_OpenCLPrivateAddressSpace || + attrKind == ParsedAttr::AT_OpenCLGlobalAddressSpace || + attrKind == ParsedAttr::AT_OpenCLLocalAddressSpace || + attrKind == ParsedAttr::AT_OpenCLConstantAddressSpace || + attrKind == ParsedAttr::AT_OpenCLGenericAddressSpace; +} static void processTypeAttrs(TypeProcessingState &state, QualType &type, TypeAttrLocation TAL, @@ -7445,11 +7455,11 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type, if (!IsTypeAttr) continue; } - } else if (TAL != TAL_DeclChunk && - attr.getKind() != ParsedAttr::AT_AddressSpace) { + } else if (TAL != TAL_DeclChunk && !isAddressSpaceKind(attr)) { // Otherwise, only consider type processing for a C++11 attribute if // it's actually been applied to a type. -// We also allow C++11 address_space attributes to pass through. +// We also allow C++11 address_space and +// OpenCL language address space attributes to pass through. continue; } } diff --git a/clang/test/AST/language_address_space_attribute.cpp b/clang/test/AST/language_address_space_attribute.cpp new file mode 100644 index ..7c6bdca06c06 --- /dev/null +++ b/clang/test/AST/language_address_space_attribute.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 %s -ast-dump | FileCheck %s + +// Verify that the language address space attribute is +// understood correctly by clang. + +void langas() { + // CHECK: VarDecl {{.*}} x_global '__global int *' + __attribute__((opencl_global)) int *x_global; + + // CHECK: VarDecl {{.*}} z_global '__global int *' + [[clang::opencl_global]] int *z_global; + + // CHECK: VarDecl {{.*}} x_local '__local int *' + __attribute__((opencl_local)) int *x_local; + + // CHECK: VarDecl {{.*}} z_local '__local int *' + [[clang::opencl_local]] int *z_local; + + // CHECK: VarDecl {{.*}} x_constant '_
[clang] cb30ad7 - [SYCL] Add support for auxiliary triple specification to Frontend
Author: Alexey Bader Date: 2019-12-11T12:40:43+03:00 New Revision: cb30ad728f0b791c72a6a1399f36ebc60ad5 URL: https://github.com/llvm/llvm-project/commit/cb30ad728f0b791c72a6a1399f36ebc60ad5 DIFF: https://github.com/llvm/llvm-project/commit/cb30ad728f0b791c72a6a1399f36ebc60ad5.diff LOG: [SYCL] Add support for auxiliary triple specification to Frontend Summary: Add host predefined macros to compilation for SYCL device, which is required for pre-processing host specific includes (e.g. system headers). Reviewers: ABataev, jdoerfert Subscribers: ebevhan, Anastasia, cfe-commits, keryell, Naghasan, Fznamznon Tags: #clang Differential Revision: https://reviews.llvm.org/D71286 Signed-off-by: Alexey Bader Added: clang/test/Frontend/sycl-aux-triple.cpp Modified: clang/lib/Frontend/CompilerInstance.cpp clang/lib/Frontend/InitPreprocessor.cpp Removed: diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index b69dc4f854ff..05ecc3f447cc 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -917,8 +917,9 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { if (!hasTarget()) return false; - // Create TargetInfo for the other side of CUDA and OpenMP compilation. - if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) && + // Create TargetInfo for the other side of CUDA/OpenMP/SYCL compilation. + if ((getLangOpts().CUDA || getLangOpts().OpenMPIsDevice || + getLangOpts().SYCLIsDevice) && !getFrontendOpts().AuxTriple.empty()) { auto TO = std::make_shared(); TO->Triple = llvm::Triple::normalize(getFrontendOpts().AuxTriple); diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index c27c33c530f6..b1c7aed0d44e 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -1124,7 +1124,8 @@ void clang::InitializePreprocessor( if (InitOpts.UsePredefines) { // FIXME: This will create multiple definitions for most of the predefined // macros. This is not the right way to handle this. -if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice) && PP.getAuxTargetInfo()) +if ((LangOpts.CUDA || LangOpts.OpenMPIsDevice || LangOpts.SYCLIsDevice) && +PP.getAuxTargetInfo()) InitializePredefinedMacros(*PP.getAuxTargetInfo(), LangOpts, FEOpts, PP.getPreprocessorOpts(), Builder); diff --git a/clang/test/Frontend/sycl-aux-triple.cpp b/clang/test/Frontend/sycl-aux-triple.cpp new file mode 100644 index ..38b6a24fb3ce --- /dev/null +++ b/clang/test/Frontend/sycl-aux-triple.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 %s -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s +// RUN: %clang_cc1 %s -fsycl-is-device -triple spir -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-SYCL %s + +// CHECK-NOT:#define __x86_64__ 1 +// CHECK-SYCL:#define __x86_64__ 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2d6a5e4 - [OpenMP][Test] Add check for aux-triple predefined macros
Author: Alexey Bader Date: 2019-12-12T14:36:11+03:00 New Revision: 2d6a5e4fe45d0a1f1c94df6b3422ffb0d676fb6d URL: https://github.com/llvm/llvm-project/commit/2d6a5e4fe45d0a1f1c94df6b3422ffb0d676fb6d DIFF: https://github.com/llvm/llvm-project/commit/2d6a5e4fe45d0a1f1c94df6b3422ffb0d676fb6d.diff LOG: [OpenMP][Test] Add check for aux-triple predefined macros Summary: Make sure that auxiliary target specific macros are defined in OpenMP mode. Reviewers: ABataev, jdoerfert Subscribers: guansong, ebevhan, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71413 Added: clang/test/OpenMP/aux-triple-macros.cpp Modified: Removed: diff --git a/clang/test/OpenMP/aux-triple-macros.cpp b/clang/test/OpenMP/aux-triple-macros.cpp new file mode 100644 index ..73b74bd92f6d --- /dev/null +++ b/clang/test/OpenMP/aux-triple-macros.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 %s -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck %s +// RUN: %clang_cc1 %s -fopenmp -fopenmp-is-device -triple nvptx64 -aux-triple x86_64-unknown-linux-gnu -E -dM | FileCheck --check-prefix=CHECK-OMP-DEVICE %s + +// CHECK-NOT:#define __x86_64__ 1 +// CHECK-OMP-DEVICE:#define __x86_64__ 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 118b057 - [SYCL] Driver option to select SYCL version
Author: Ruyman Date: 2020-03-07T18:28:54+03:00 New Revision: 118b057f1268d1789e40ffceb214e73772df04f4 URL: https://github.com/llvm/llvm-project/commit/118b057f1268d1789e40ffceb214e73772df04f4 DIFF: https://github.com/llvm/llvm-project/commit/118b057f1268d1789e40ffceb214e73772df04f4.diff LOG: [SYCL] Driver option to select SYCL version Summary: User can select the version of SYCL the compiler will use via the flag -sycl-std, similar to -cl-std. The flag defines the LangOpts.SYCLVersion option to the version of SYCL. The default value is undefined. If driver is building SYCL code, flag is set to the default SYCL version (1.2.1) The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro, which should be defined according to SYCL 1.2.1 standard. Only valid value at this point for the flag is 1.2.1. Co-Authored-By: David Wood Signed-off-by: Ruyman Reyes Subscribers: ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72857 Added: Modified: clang/include/clang/Basic/LangOptions.def clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Frontend/InitPreprocessor.cpp clang/test/Driver/sycl.c clang/test/Frontend/sycl-aux-triple.cpp clang/test/Preprocessor/sycl-macro.cpp clang/test/SemaSYCL/kernel-attribute.cpp Removed: diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 3cc7c384ac10..53b87b737568 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -230,7 +230,9 @@ LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code") LANGOPT(GPUAllowDeviceInit, 1, 0, "allowing device side global init functions for HIP") LANGOPT(GPUMaxThreadsPerBlock, 32, 256, "default max threads per block for kernel launch bounds for HIP") +LANGOPT(SYCL , 1, 0, "SYCL") LANGOPT(SYCLIsDevice , 1, 0, "Generate code for SYCL device") +LANGOPT(SYCLVersion , 32, 0, "Version of the SYCL standard used") LANGOPT(HIPUseNewLaunchAPI, 1, 0, "Use new kernel launching API for HIP") diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 2aaf85434214..0d5cba8d682a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3422,10 +3422,12 @@ defm underscoring : BooleanFFlag<"underscoring">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; // C++ SYCL options -def fsycl : Flag<["-"], "fsycl">, Group, +def fsycl : Flag<["-"], "fsycl">, Group, Flags<[CC1Option, CoreOption]>, HelpText<"Enable SYCL kernels compilation for device">; -def fno_sycl : Flag<["-"], "fno-sycl">, Group, +def fno_sycl : Flag<["-"], "fno-sycl">, Group, Flags<[CoreOption]>, HelpText<"Disable SYCL kernels compilation for device">; +def sycl_std_EQ : Joined<["-"], "sycl-std=">, Group, Flags<[CC1Option, NoArgumentUnused, CoreOption]>, + HelpText<"SYCL language standard to compile for.">, Values<"2017, 121, 1.2.1, sycl-1.2.1">; include "CC1Options.td" diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 3ca034e69b3b..99faae396be3 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4048,9 +4048,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); } - if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) { +CmdArgs.push_back("-fsycl"); CmdArgs.push_back("-fsycl-is-device"); +if (Arg *A = Args.getLastArg(options::OPT_sycl_std_EQ)) { + A->render(Args, CmdArgs); +} else { + // Ensure the default version in SYCL mode is 1.2.1 (aka 2017) + CmdArgs.push_back("-sycl-std=2017"); +} + } + if (IsOpenMPDevice) { // We have to pass the triple of the host if compiling for an OpenMP device. std::string NormalizedTriple = diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 48c65aded817..9f3522a3e654 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2544,6 +2544,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, LangStd = OpenCLLangStd; } + Opts.SYCL = Args.hasArg(options::OPT_fsycl); + Opts.SYCLIsDevice = Opts.SYCL && Args.hasArg(options::OPT_fsycl_is_device); + if (Opts.SYCL) { +// -sycl-std applies to any SYCL source, not only those containing kernels, +// but also those using the SYCL API +if (const Arg *A = Args.getLastArg(OPT_sycl_std_EQ)) { + Opts.SYCLVersion = llvm::Strin
[clang] 863d975 - [SYCL][Driver] Add clang driver option to enable SYCL compilation mode
Author: Alexey Bader Date: 2020-02-06T08:42:31+03:00 New Revision: 863d9752105f390b31b3d08d1980d2888c15b034 URL: https://github.com/llvm/llvm-project/commit/863d9752105f390b31b3d08d1980d2888c15b034 DIFF: https://github.com/llvm/llvm-project/commit/863d9752105f390b31b3d08d1980d2888c15b034.diff LOG: [SYCL][Driver] Add clang driver option to enable SYCL compilation mode Summary: As a first step this implementation enables compilation of the offload code. Reviewers: ABataev Subscribers: ebevhan, Anastasia, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D74048 Added: clang/test/Driver/sycl.c Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 2c925d018da7..2dea0ac2ba5c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -124,6 +124,9 @@ def pedantic_Group : OptionGroup<"">, Group, def opencl_Group : OptionGroup<"">, Group, DocName<"OpenCL flags">; +def sycl_Group : OptionGroup<"">, Group, + DocName<"SYCL flags">; + def m_Group : OptionGroup<"">, Group, DocName<"Target-dependent compilation options">; @@ -3407,6 +3410,11 @@ defm stack_arrays : BooleanFFlag<"stack-arrays">, Group; defm underscoring : BooleanFFlag<"underscoring">, Group; defm whole_file : BooleanFFlag<"whole-file">, Group; +// C++ SYCL options +def fsycl : Flag<["-"], "fsycl">, Group, + HelpText<"Enable SYCL kernels compilation for device">; +def fno_sycl : Flag<["-"], "fno-sycl">, Group, + HelpText<"Disable SYCL kernels compilation for device">; include "CC1Options.td" diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index ccdfbe8c604f..0bed933185f6 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4023,6 +4023,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Args.MakeArgString(NormalizedTriple)); } + if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false)) +CmdArgs.push_back("-fsycl-is-device"); + if (IsOpenMPDevice) { // We have to pass the triple of the host if compiling for an OpenMP device. std::string NormalizedTriple = diff --git a/clang/test/Driver/sycl.c b/clang/test/Driver/sycl.c new file mode 100644 index ..6c4b291f387b --- /dev/null +++ b/clang/test/Driver/sycl.c @@ -0,0 +1,10 @@ +// RUN: %clang -### -fsycl -c %s 2>&1 | FileCheck %s --check-prefix=ENABLED +// RUN: %clang -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED +// RUN: %clang -### -fno-sycl -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED +// RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=ENABLED +// RUN: %clangxx -### -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED +// RUN: %clangxx -### -fsycl -fno-sycl %s 2>&1 | FileCheck %s --check-prefix=DISABLED +// RUN: %clangxx -### %s 2>&1 | FileCheck %s --check-prefix=DISABLED + +// ENABLED: "-cc1"{{.*}} "-fsycl-is-device" +// DISABLED-NOT: "-fsycl-is-device" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] dd18729 - [Attr][Doc][NFC] Fix code snippet formatting for attribute documentation
Author: Alexey Bader Date: 2020-01-21T18:30:56+03:00 New Revision: dd18729b2a7a23b76b8d74fbf4f4bb4efbe8aa97 URL: https://github.com/llvm/llvm-project/commit/dd18729b2a7a23b76b8d74fbf4f4bb4efbe8aa97 DIFF: https://github.com/llvm/llvm-project/commit/dd18729b2a7a23b76b8d74fbf4f4bb4efbe8aa97.diff LOG: [Attr][Doc][NFC] Fix code snippet formatting for attribute documentation Reviewers: aaron.ballman, Fznamznon Subscribers: ebevhan, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73104 Added: Modified: clang/include/clang/Basic/AttrDocs.td Removed: diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 456edd1daafc..8fd59a0c9b38 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -260,6 +260,7 @@ The ``sycl_kernel`` attribute specifies that a function template will be used to outline device code and to generate an OpenCL kernel. Here is a code example of the SYCL program, which demonstrates the compiler's outlining job: + .. code-block:: c++ int foo(int x) { return ++x; } @@ -282,27 +283,29 @@ compilation of functions for the device part can be found in the SYCL 1.2.1 specification Section 6.4. To show to the compiler entry point to the "device part" of the code, the SYCL runtime can use the ``sycl_kernel`` attribute in the following way: + .. code-block:: c++ -namespace cl { -namespace sycl { -class handler { - template - __attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) { -// ... -KernelFuncObj(); - } - template - void parallel_for(range NumWorkItems, KernelType KernelFunc) { -#ifdef __SYCL_DEVICE_ONLY__ -sycl_kernel_function(KernelFunc); -#else -// Host implementation -#endif - } -}; -} // namespace sycl -} // namespace cl + namespace cl { + namespace sycl { + class handler { +template +__attribute__((sycl_kernel)) void sycl_kernel_function(KernelType KernelFuncObj) { + // ... + KernelFuncObj(); +} + +template +void parallel_for(range NumWorkItems, KernelType KernelFunc) { + #ifdef __SYCL_DEVICE_ONLY__ + sycl_kernel_function(KernelFunc); + #else + // Host implementation + #endif +} + }; + } // namespace sycl + } // namespace cl The compiler will also generate an OpenCL kernel using the function marked with the ``sycl_kernel`` attribute. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r318290 - [OpenCL] Fix code generation of function-scope constant samplers.
Author: bader Date: Wed Nov 15 03:38:17 2017 New Revision: 318290 URL: http://llvm.org/viewvc/llvm-project?rev=318290&view=rev Log: [OpenCL] Fix code generation of function-scope constant samplers. Summary: Constant samplers are handled as static variables and clang's code generation library, which leads to llvm::unreachable. We bypass emitting sampler variable as static since it's translated to a function call later. Reviewers: yaxunl, Anastasia Reviewed By: yaxunl, Anastasia Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34342 Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/test/CodeGenOpenCL/sampler.cl cfe/trunk/test/SemaOpenCL/sampler_t.cl Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=318290&r1=318289&r2=318290&view=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Nov 15 03:38:17 2017 @@ -162,6 +162,10 @@ void CodeGenFunction::EmitVarDecl(const // needs to be emitted like a static variable, e.g. a function-scope // variable in constant address space in OpenCL. if (D.getStorageDuration() != SD_Automatic) { +// Static sampler variables translated to function calls. +if (D.getType()->isSamplerT()) + return; + llvm::GlobalValue::LinkageTypes Linkage = CGM.getLLVMLinkageVarDefinition(&D, /*isConstant=*/false); Modified: cfe/trunk/test/CodeGenOpenCL/sampler.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/sampler.cl?rev=318290&r1=318289&r2=318290&view=diff == --- cfe/trunk/test/CodeGenOpenCL/sampler.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/sampler.cl Wed Nov 15 03:38:17 2017 @@ -20,6 +20,8 @@ constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; // CHECK-NOT: glb_smp +int get_sampler_initializer(void); + void fnc4smp(sampler_t s) {} // CHECK: define spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* % @@ -58,4 +60,20 @@ kernel void foo(sampler_t smp_par) { 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]]) + + const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(const_smp); + // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]] + fnc4smp(const_smp); + // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]] + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; + fnc4smp(constant_smp); + // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35) + // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]]) + + // TODO: enable sampler initialization with non-constant integer. + //const sampler_t const_smp_func_init = get_sampler_initializer(); } Modified: cfe/trunk/test/SemaOpenCL/sampler_t.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/sampler_t.cl?rev=318290&r1=318289&r2=318290&view=diff == --- cfe/trunk/test/SemaOpenCL/sampler_t.cl (original) +++ cfe/trunk/test/SemaOpenCL/sampler_t.cl Wed Nov 15 03:38:17 2017 @@ -46,36 +46,11 @@ const constant sampler_t glb_smp11 = CLK void kernel ker(sampler_t argsmp) { local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}} - const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR; - const sampler_t const_smp2; - const sampler_t const_smp3 = const_smp; - const sampler_t const_smp4 = f(); const sampler_t const_smp5 = 1.0f; // expected-error{{initializing 'const sampler_t' with an expression of incompatible type 'float'}} const sampler_t const_smp6 = 0x1LL; // expected-error{{sampler_t initialization requires 32-bit integer, not 'long long'}} - foo(glb_smp); - foo(glb_smp2); - foo(glb_smp3); - foo(glb_smp4); - foo(glb_smp5); - foo(glb_smp6); - foo(glb_smp7); - foo(glb_smp8); - foo(glb_smp9); - foo(smp); - foo(sampler_str.smp); - foo(const_smp); - foo(const_smp2); - foo(const_smp3); - foo(const_smp4); - foo(const_smp5); - foo(const_smp6); - foo(argsmp); - foo(5);
Re: [PATCH] D23914: [OpenCL] Make is_valid_event overloadable.
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D23914 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23915: [OpenCL] Remove access qualifiers on images in arg info metadata.
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D23915 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
bader created this revision. bader added reviewers: Anastasia, vpykhtin. bader added a subscriber: cfe-commits. Keep pipe packet size and alignment in LLVM IR layer to enable translation from LLVM IR to SPIR-V format. https://reviews.llvm.org/D23992 Files: lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CGOpenCLRuntime.h test/CodeGenOpenCL/pipe_builtin.cl test/CodeGenOpenCL/pipe_types.cl Index: test/CodeGenOpenCL/pipe_types.cl === --- test/CodeGenOpenCL/pipe_types.cl +++ test/CodeGenOpenCL/pipe_types.cl @@ -41,7 +41,7 @@ read_only pipe struct Person SPipe) { // CHECK: define void @test_reserved_read_pipe read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) } Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -4,58 +4,58 @@ // CHECK: %opencl.reserve_id_t = type opaque void test1(read_only pipe int p, global int *ptr) { - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_read_pipe(p, 2); - // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_read_pipe(p, rid); } void test2(write_only pipe int p, global int *ptr) { - // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_write_pipe(p, 2); - // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_write_pipe(p, rid); } void test3(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_read_pipe(p, 2); - // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_read_pipe(p, rid); } void test4(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_write_pipe(p, 2); - // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_write_pipe(p, rid); } void test5(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid =
Re: [PATCH] D23914: [OpenCL] Make is_valid_event, create_user_event overloadable.
This revision was automatically updated to reflect the committed changes. Closed by commit rL280097: [OpenCL] Make is_valid_event, create_user_event overloadable. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23914?vs=69650&id=69682#toc Repository: rL LLVM https://reviews.llvm.org/D23914 Files: cfe/trunk/lib/Headers/opencl-c.h Index: cfe/trunk/lib/Headers/opencl-c.h === --- cfe/trunk/lib/Headers/opencl-c.h +++ cfe/trunk/lib/Headers/opencl-c.h @@ -16729,11 +16729,11 @@ void __ovld release_event(clk_event_t); -clk_event_t create_user_event(void); +clk_event_t __ovld create_user_event(void); void __ovld set_user_event_status(clk_event_t e, int state); -bool is_valid_event (clk_event_t event); +bool __ovld is_valid_event (clk_event_t event); void __ovld capture_event_profiling_info(clk_event_t, clk_profiling_info, __global void* value); Index: cfe/trunk/lib/Headers/opencl-c.h === --- cfe/trunk/lib/Headers/opencl-c.h +++ cfe/trunk/lib/Headers/opencl-c.h @@ -16729,11 +16729,11 @@ void __ovld release_event(clk_event_t); -clk_event_t create_user_event(void); +clk_event_t __ovld create_user_event(void); void __ovld set_user_event_status(clk_event_t e, int state); -bool is_valid_event (clk_event_t event); +bool __ovld is_valid_event (clk_event_t event); void __ovld capture_event_profiling_info(clk_event_t, clk_profiling_info, __global void* value); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280097 - [OpenCL] Make is_valid_event, create_user_event overloadable.
Author: bader Date: Tue Aug 30 09:42:54 2016 New Revision: 280097 URL: http://llvm.org/viewvc/llvm-project?rev=280097&view=rev Log: [OpenCL] Make is_valid_event, create_user_event overloadable. Summary: Make is_valid_event and create_user_event overloadable like other built-ins. Patch by Evgeniy Tyurin. Reviewers: bader, yaxunl Subscribers: Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D23914 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=280097&r1=280096&r2=280097&view=diff == --- cfe/trunk/lib/Headers/opencl-c.h (original) +++ cfe/trunk/lib/Headers/opencl-c.h Tue Aug 30 09:42:54 2016 @@ -16729,11 +16729,11 @@ void __ovld retain_event(clk_event_t); void __ovld release_event(clk_event_t); -clk_event_t create_user_event(void); +clk_event_t __ovld create_user_event(void); void __ovld set_user_event_status(clk_event_t e, int state); -bool is_valid_event (clk_event_t event); +bool __ovld is_valid_event (clk_event_t event); void __ovld capture_event_profiling_info(clk_event_t, clk_profiling_info, __global void* value); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.
bader created this revision. bader added a reviewer: Anastasia. bader added subscribers: yaxunl, cfe-commits. By default return type of call expressions calling built-in functions is set to bool. Fixes https://llvm.org/bugs/show_bug.cgi?id=30219. https://reviews.llvm.org/D24136 Files: lib/Sema/SemaChecking.cpp test/CodeGenOpenCL/pipe_builtin.cl Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,13 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,13 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24054: Do not validate pch when -fno-validate-pch is set
bader added a comment. Could you a regression test, please? https://reviews.llvm.org/D24054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
bader updated this revision to Diff 70366. bader added a comment. Applied code review comment from Anastasia. Use getTypeSizeInChars instead of getTypeSize to get type size in bytes. Assume that char size is always one byte. https://reviews.llvm.org/D23992 Files: lib/CodeGen/CGBuiltin.cpp lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CGOpenCLRuntime.h test/CodeGenOpenCL/pipe_builtin.cl test/CodeGenOpenCL/pipe_types.cl Index: test/CodeGenOpenCL/pipe_types.cl === --- test/CodeGenOpenCL/pipe_types.cl +++ test/CodeGenOpenCL/pipe_types.cl @@ -41,7 +41,7 @@ read_only pipe struct Person SPipe) { // CHECK: define void @test_reserved_read_pipe read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) read_pipe (SPipe, SDst); - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 16, i32 8) } Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -4,58 +4,58 @@ // CHECK: %opencl.reserve_id_t = type opaque void test1(read_only pipe int p, global int *ptr) { - // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_read_pipe(p, 2); - // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__read_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) read_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_read_pipe(p, rid); } void test2(write_only pipe int p, global int *ptr) { - // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_2(%opencl.pipe_t* %{{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, ptr); - // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = reserve_write_pipe(p, 2); - // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}) + // CHECK: call i32 @__write_pipe_4(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 {{.*}}, i8* %{{.*}}, i32 4, i32 4) write_pipe(p, rid, 2, ptr); - // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) commit_write_pipe(p, rid); } void test3(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_read_pipe(p, 2); - // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_read_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_read_pipe(p, rid); } void test4(write_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__work_group_reserve_write_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_id_t rid = work_group_reserve_write_pipe(p, 2); - // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}) + // CHECK: call void @__work_group_commit_write_pipe(%opencl.pipe_t* %{{.*}}, %opencl.reserve_id_t* %{{.*}}, i32 4, i32 4) work_group_commit_write_pipe(p, rid); } void test5(read_only pipe int p, global int *ptr) { - // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}) + // CHECK: call %opencl.reserve_id_t* @__sub_group_reserve_read_pipe(%opencl.pipe_t* %{{.*}}, i32 {{.*}}, i32 4, i32 4) reserve_i
Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.
bader updated this revision to Diff 70368. bader added a comment. Added get_pipe_num_packets and get_pipe_max_packets test cases. https://reviews.llvm.org/D24136 Files: lib/Sema/SemaChecking.cpp test/CodeGenOpenCL/pipe_builtin.cl Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Index: test/CodeGenOpenCL/pipe_builtin.cl === --- test/CodeGenOpenCL/pipe_builtin.cl +++ test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: lib/Sema/SemaChecking.cpp === --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r280699 - [OpenCL] Remove access qualifiers on images in arg info metadata.
Author: bader Date: Tue Sep 6 05:10:28 2016 New Revision: 280699 URL: http://llvm.org/viewvc/llvm-project?rev=280699&view=rev Log: [OpenCL] Remove access qualifiers on images in arg info metadata. Summary: Remove access qualifiers on images in arg info metadata: * kernel_arg_type * kernel_arg_base_type Image access qualifiers are inseparable from type in clang implementation, but OpenCL spec provides a special query to get access qualifier via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER. Besides that OpenCL conformance test_api get_kernel_arg_info expects image types without access qualifier. Patch by Evgeniy Tyurin. Reviewers: bader, yaxunl, Anastasia Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23915 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=280699&r1=280698&r2=280699&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Sep 6 05:10:28 2016 @@ -428,6 +428,26 @@ void CodeGenFunction::EmitFunctionInstru EmitNounwindRuntimeCall(F, args); } +static void removeImageAccessQualifier(std::string& TyName) { + std::string ReadOnlyQual("__read_only"); + std::string::size_type ReadOnlyPos = TyName.find(ReadOnlyQual); + if (ReadOnlyPos != std::string::npos) +// "+ 1" for the space after access qualifier. +TyName.erase(ReadOnlyPos, ReadOnlyQual.size() + 1); + else { +std::string WriteOnlyQual("__write_only"); +std::string::size_type WriteOnlyPos = TyName.find(WriteOnlyQual); +if (WriteOnlyPos != std::string::npos) + TyName.erase(WriteOnlyPos, WriteOnlyQual.size() + 1); +else { + std::string ReadWriteQual("__read_write"); + std::string::size_type ReadWritePos = TyName.find(ReadWriteQual); + if (ReadWritePos != std::string::npos) +TyName.erase(ReadWritePos, ReadWriteQual.size() + 1); +} + } +} + // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument // information in the program executable. The argument information stored // includes the argument name, its type, the address and access qualifiers used. @@ -524,8 +544,6 @@ static void GenOpenCLArgMetadata(const F if (ty.isCanonical() && pos != std::string::npos) typeName.erase(pos+1, 8); - argTypeNames.push_back(llvm::MDString::get(Context, typeName)); - std::string baseTypeName; if (isPipe) baseTypeName = ty.getCanonicalType()->getAs() @@ -535,6 +553,17 @@ static void GenOpenCLArgMetadata(const F baseTypeName = ty.getUnqualifiedType().getCanonicalType().getAsString(Policy); + // Remove access qualifiers on images + // (as they are inseparable from type in clang implementation, + // but OpenCL spec provides a special query to get access qualifier + // via clGetKernelArgInfo with CL_KERNEL_ARG_ACCESS_QUALIFIER): + if (ty->isImageType()) { +removeImageAccessQualifier(typeName); +removeImageAccessQualifier(baseTypeName); + } + + argTypeNames.push_back(llvm::MDString::get(Context, typeName)); + // Turn "unsigned type" to "utype" pos = baseTypeName.find("unsigned"); if (pos != std::string::npos) 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=280699&r1=280698&r2=280699&view=diff == --- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Tue Sep 6 05:10:28 2016 @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO +// 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) { @@ -14,7 +14,7 @@ kernel void foo(__global int * restrict // CHECK-NOT: !kernel_arg_name // ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]] -kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) { +kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3, read_write image1d_t img4) { } // CHECK: define spir_kernel void @foo2{{[^!]+}} // CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]] @@ -65,11 +65,11 @@ kern
Re: [PATCH] D23915: [OpenCL] Remove access qualifiers on images in arg info metadata.
This revision was automatically updated to reflect the committed changes. Closed by commit rL280699: [OpenCL] Remove access qualifiers on images in arg info metadata. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23915?vs=69649&id=70372#toc Repository: rL LLVM https://reviews.llvm.org/D23915 Files: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl Index: cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl === --- cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl +++ cfe/trunk/test/CodeGenOpenCL/kernel-arg-info.cl @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple spir-unknown-unknown -cl-kernel-arg-info | FileCheck %s -check-prefix ARGINFO +// 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) { @@ -14,7 +14,7 @@ // CHECK-NOT: !kernel_arg_name // ARGINFO: !kernel_arg_name ![[MD15:[0-9]+]] -kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3) { +kernel void foo2(read_only image1d_t img1, image2d_t img2, write_only image2d_array_t img3, read_write image1d_t img4) { } // CHECK: define spir_kernel void @foo2{{[^!]+}} // CHECK: !kernel_arg_addr_space ![[MD21:[0-9]+]] @@ -65,11 +65,11 @@ // CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"} // CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"} // ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"} -// CHECK: ![[MD21]] = !{i32 1, i32 1, i32 1} -// CHECK: ![[MD22]] = !{!"read_only", !"read_only", !"write_only"} -// CHECK: ![[MD23]] = !{!"__read_only image1d_t", !"__read_only image2d_t", !"__write_only image2d_array_t"} -// CHECK: ![[MD24]] = !{!"", !"", !""} -// ARGINFO: ![[MD25]] = !{!"img1", !"img2", !"img3"} +// 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"} +// CHECK: ![[MD24]] = !{!"", !"", !"", !""} +// ARGINFO: ![[MD25]] = !{!"img1", !"img2", !"img3", !"img4"} // CHECK: ![[MD31]] = !{i32 1} // CHECK: ![[MD32]] = !{!"none"} // CHECK: ![[MD33]] = !{!"half*"} @@ -82,7 +82,7 @@ // CHECK: ![[MD45]] = !{!"", !""} // ARGINFO: ![[MD46]] = !{!"X", !"Y"} // CHECK: ![[MD51]] = !{!"read_only", !"write_only"} -// CHECK: ![[MD52]] = !{!"myImage", !"__write_only image1d_t"} -// CHECK: ![[MD53]] = !{!"__read_only image1d_t", !"__write_only image1d_t"} +// CHECK: ![[MD52]] = !{!"myImage", !"image1d_t"} +// CHECK: ![[MD53]] = !{!"image1d_t", !"image1d_t"} // ARGINFO: ![[MD54]] = !{!"img1", !"img2"} Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp === --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp @@ -428,6 +428,26 @@ EmitNounwindRuntimeCall(F, args); } +static void removeImageAccessQualifier(std::string& TyName) { + std::string ReadOnlyQual("__read_only"); + std::string::size_type ReadOnlyPos = TyName.find(ReadOnlyQual); + if (ReadOnlyPos != std::string::npos) +// "+ 1" for the space after access qualifier. +TyName.erase(ReadOnlyPos, ReadOnlyQual.size() + 1); + else { +std::string WriteOnlyQual("__write_only"); +std::string::size_type WriteOnlyPos = TyName.find(WriteOnlyQual); +if (WriteOnlyPos != std::string::npos) + TyName.erase(WriteOnlyPos, WriteOnlyQual.size() + 1); +else { + std::string ReadWriteQual("__read_write"); + std::string::size_type ReadWritePos = TyName.find(ReadWriteQual); + if (ReadWritePos != std::string::npos) +TyName.erase(ReadWritePos, ReadWriteQual.size() + 1); +} + } +} + // OpenCL v1.2 s5.6.4.6 allows the compiler to store kernel argument // information in the program executable. The argument information stored // includes the argument name, its type, the address and access qualifiers used. @@ -524,8 +544,6 @@ if (ty.isCanonical() && pos != std::string::npos) typeName.erase(pos+1, 8); - argTypeNames.push_back(llvm::MDString::get(Context, typeName)); - std::string baseTypeName; if (isPipe) baseTypeName = ty.getCanonicalType()->getAs() @@ -535,6 +553,17 @@ baseTypeName = ty.getUnqualifiedType().getCanonicalType().getAsString(Policy); + // Remove access qualifiers on images + // (as they are inseparable from type in clang implementation, + // but OpenCL spec provides a special query to get access qua
r280800 - [OpenCL] Fix pipe built-in functions return type.
Author: bader Date: Wed Sep 7 05:32:03 2016 New Revision: 280800 URL: http://llvm.org/viewvc/llvm-project?rev=280800&view=rev Log: [OpenCL] Fix pipe built-in functions return type. By default return type of call expressions calling built-in functions is set to bool. Fixes https://llvm.org/bugs/show_bug.cgi?id=30219. Reviewers: Anastasia Subscribers: dmitry, cfe-commits, yaxunl Differential Revision: https://reviews.llvm.org/D24136 Modified: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Modified: cfe/trunk/lib/Sema/SemaChecking.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=280800&r1=280799&r2=280800&view=diff == --- cfe/trunk/lib/Sema/SemaChecking.cpp (original) +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 7 05:32:03 2016 @@ -1020,6 +1020,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ Sema::CheckBuiltinFunctionCall(FunctionD case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Modified: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl?rev=280800&r1=280799&r2=280800&view=diff == --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Wed Sep 7 05:32:03 2016 @@ -59,3 +59,19 @@ void test7(write_only pipe int p, global // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24136: [OpenCL] Fix pipe built-in functions return type.
This revision was automatically updated to reflect the committed changes. Closed by commit rL280800: [OpenCL] Fix pipe built-in functions return type. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D24136?vs=70368&id=70516#toc Repository: rL LLVM https://reviews.llvm.org/D24136 Files: cfe/trunk/lib/Sema/SemaChecking.cpp cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: Index: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl @@ -59,3 +59,19 @@ // CHECK: call i32 @__get_pipe_max_packets(%opencl.pipe_t* %{{.*}}) *ptr = get_pipe_max_packets(p); } + +void test8(read_only pipe int r, write_only pipe int w, global int *ptr) { + // verify that return type is correctly casted to i1 value + // CHECK: %[[R:[0-9]+]] = call i32 @__read_pipe_2 + // CHECK: icmp ne i32 %[[R]], 0 + if (read_pipe(r, ptr)) *ptr = -1; + // CHECK: %[[W:[0-9]+]] = call i32 @__write_pipe_2 + // CHECK: icmp ne i32 %[[W]], 0 + if (write_pipe(w, ptr)) *ptr = -1; + // CHECK: %[[N:[0-9]+]] = call i32 @__get_pipe_num_packets + // CHECK: icmp ne i32 %[[N]], 0 + if (get_pipe_num_packets(r)) *ptr = -1; + // CHECK: %[[M:[0-9]+]] = call i32 @__get_pipe_max_packets + // CHECK: icmp ne i32 %[[M]], 0 + if (get_pipe_max_packets(w)) *ptr = -1; +} Index: cfe/trunk/lib/Sema/SemaChecking.cpp === --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -1020,6 +1020,7 @@ // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); +TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1047,6 +1048,7 @@ case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); +TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D23992: [OpenCL] Augment pipe built-ins with pipe packet size and alignment.
bader added a comment. Valery, do you have any additional comments/questions regarding this patch? https://reviews.llvm.org/D23992 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24626: [OpenCL] Diagnose assignment to dereference of half type pointer
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM. Thanks. https://reviews.llvm.org/D24626 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
bader added inline comments. Comment at: test/SemaOpenCL/half.cl:29 @@ +28,3 @@ +kernel void half_disabled_kernel(global half *p, + half h); // expected-error{{'half' cannot be used as the type of a kernel parameter}} // expected-error{{declaring function parameter of type 'half' is not allowed; did you forget * ?}} + It's not related to your change, but it looks like there are two checks that report the same error. Could you remove the duplication, please? https://reviews.llvm.org/D24666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24666: [OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
bader added inline comments. Comment at: lib/Sema/SemaDecl.cpp:7599-7602 @@ -7595,3 +7598,6 @@ // of event_t type. -S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT; +// Do not diagnose half type since it is diagnosed as invalid argument +// type for any function eleswhere. +if (!PT->isHalfType()) + S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT; D.setInvalidType(); It looks strange to me. First we check if parameter type is half - we set InvalidKernelParam status, later we check again and do not report an error. I think it would be simpler just return ValidKernelParam for half data type from getOpenCLKernelParameterType, I think the whole patch should two deleted lines from getOpenCLKernelParameterType function + test case. https://reviews.llvm.org/D24666 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306653 - [OpenCL] Allow function declaration with empty argument list.
Author: bader Date: Thu Jun 29 01:44:10 2017 New Revision: 306653 URL: http://llvm.org/viewvc/llvm-project?rev=306653&view=rev Log: [OpenCL] Allow function declaration with empty argument list. Summary: does it make sense to enable K&R function declaration style for OpenCL? clang throws following error message for the declaration w/o arguments: ``` int my_func(); error: function with no prototype cannot use the spir_function calling convention ``` Current way to fix this issue is to specify that parameter list is empty by using 'void': ``` int my_func(void); ``` Let me know what do you think about this patch. Reviewers: Anastasia, yaxunl Reviewed By: Anastasia Subscribers: cfe-commits, echuraev Differential Revision: https://reviews.llvm.org/D33681 Added: cfe/trunk/test/SemaOpenCL/function-no-args.cl Modified: cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Modified: cfe/trunk/lib/Sema/SemaType.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=306653&r1=306652&r2=306653&view=diff == --- cfe/trunk/lib/Sema/SemaType.cpp (original) +++ cfe/trunk/lib/Sema/SemaType.cpp Thu Jun 29 01:44:10 2017 @@ -4355,7 +4355,7 @@ static TypeSourceInfo *GetFullTypeForDec FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex)); - if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) { + if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus && !LangOpts.OpenCL) { // Simple void foo(), where the incoming T is the result type. T = Context.getFunctionNoProtoType(T, EI); } else { Added: cfe/trunk/test/SemaOpenCL/function-no-args.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/function-no-args.cl?rev=306653&view=auto == --- cfe/trunk/test/SemaOpenCL/function-no-args.cl (added) +++ cfe/trunk/test/SemaOpenCL/function-no-args.cl Thu Jun 29 01:44:10 2017 @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s +// expected-no-diagnostics + +global int gi; +int my_func(); +int my_func() { + gi = 2; + return gi; +} 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=306653&r1=306652&r2=306653&view=diff == --- cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl (original) +++ cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Thu Jun 29 01:44:10 2017 @@ -3,7 +3,7 @@ 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}} +extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' 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}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r323522 - [OpenCL] Add "cles_khr_int64" extension.
Author: bader Date: Fri Jan 26 03:48:46 2018 New Revision: 323522 URL: http://llvm.org/viewvc/llvm-project?rev=323522&view=rev Log: [OpenCL] Add "cles_khr_int64" extension. Summary: For OpenCL 1.1 embedded profile 64 bit integers i.e. long, ulong including the appropriate vector data types and operations on 64-bit integers are optional. The "cles_khr_int64" extension string will be reported if the embedded profile implementation supports 64-bit integers. Reviewers: Anastasia, bader Reviewed By: Anastasia, bader Subscribers: bader, yaxunl, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D42532 Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def cfe/trunk/test/SemaOpenCL/extension-version.cl Modified: cfe/trunk/include/clang/Basic/OpenCLExtensions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLExtensions.def?rev=323522&r1=323521&r2=323522&view=diff == --- cfe/trunk/include/clang/Basic/OpenCLExtensions.def (original) +++ cfe/trunk/include/clang/Basic/OpenCLExtensions.def Fri Jan 26 03:48:46 2018 @@ -53,6 +53,9 @@ OPENCLEXT_INTERNAL(cl_khr_icd, 100, ~0U) OPENCLEXT_INTERNAL(cl_khr_gl_event, 110, ~0U) OPENCLEXT_INTERNAL(cl_khr_d3d10_sharing, 110, ~0U) +// EMBEDDED_PROFILE +OPENCLEXT_INTERNAL(cles_khr_int64, 110, ~0U) + // OpenCL 1.2. OPENCLEXT_INTERNAL(cl_khr_context_abort, 120, ~0U) OPENCLEXT_INTERNAL(cl_khr_d3d11_sharing, 120, ~0U) Modified: cfe/trunk/test/SemaOpenCL/extension-version.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/extension-version.cl?rev=323522&r1=323521&r2=323522&view=diff == --- cfe/trunk/test/SemaOpenCL/extension-version.cl (original) +++ cfe/trunk/test/SemaOpenCL/extension-version.cl Fri Jan 26 03:48:46 2018 @@ -131,6 +131,15 @@ #endif #pragma OPENCL EXTENSION cl_khr_d3d10_sharing: enable +#if (__OPENCL_C_VERSION__ >= 110) +#ifndef cles_khr_int64 +#error "Missing cles_khr_int64 define" +#endif +#else +// expected-warning@+2{{unsupported OpenCL extension 'cles_khr_int64' - ignoring}} +#endif +#pragma OPENCL EXTENSION cles_khr_int64: enable + #if (__OPENCL_C_VERSION__ >= 120) #ifndef cl_khr_context_abort #error "Missing cl_context_abort define" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26746: [OpenCL] Split PipeType into ReadPipe/WritePipe
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM. Thanks! A few minor comments regarding outdated comments and style. Comment at: include/clang/AST/ASTContext.h:1124 /// \brief Return pipe type for the specified type. + QualType getReadPipeType(QualType T) const; Please, update the comment to specify that this function return pipe type with '__read_only' access qualifier. Comment at: lib/AST/ASTContext.cpp:3341 /// Return pipe type for the specified type. +QualType ASTContext::getReadPipeType(QualType T) const { Please, remove this comment. It's a copy of the comment from the header file. Comment at: lib/Serialization/ASTReader.cpp:5806-5807 +return Context.getReadPipeType(ElementType); + } + case TYPE_WRITE_PIPE: { +if (Record.size() != 1) { Please, separate case with an empty line. Repository: rL LLVM https://reviews.llvm.org/D26746 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288126 - [OpenCL] Prohibit using reserve_id_t in program scope.
Author: bader Date: Tue Nov 29 04:21:40 2016 New Revision: 288126 URL: http://llvm.org/viewvc/llvm-project?rev=288126&view=rev Log: [OpenCL] Prohibit using reserve_id_t in program scope. Patch by Egor Churaev (echuraev). Reviewers: Anastasia Subscribers: cfe-commits, yaxunl, bader Differential Revision: https://reviews.llvm.org/D27099 Added: cfe/trunk/test/SemaOpenCL/invalid-clk-events-cl2.0.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaOpenCL/event_t.cl cfe/trunk/test/SemaOpenCL/invalid-pipes-cl2.0.cl Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=288126&r1=288125&r2=288126&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Nov 29 04:21:40 2016 @@ -8075,8 +8075,6 @@ def note_within_field_of_type : Note< "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< @@ -8589,6 +8587,8 @@ def note_related_result_type_inferred : 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">; } Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=288126&r1=288125&r2=288126&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Nov 29 04:21:40 2016 @@ -5909,32 +5909,31 @@ NamedDecl *Sema::ActOnVariableDeclarator return nullptr; } - // OpenCL v2.0 s6.9.b - Image type can only be used as a function argument. - // OpenCL v2.0 s6.13.16.1 - Pipe type can only be used as a function - // argument. - if (getLangOpts().OpenCL && (R->isImageType() || R->isPipeType())) { -Diag(D.getIdentifierLoc(), - diag::err_opencl_type_can_only_be_used_as_function_parameter) -<< R; -D.setInvalidType(); -return nullptr; - } - - DeclSpec::SCS SCSpec = D.getDeclSpec().getStorageClassSpec(); - StorageClass SC = StorageClassSpecToVarDeclStorageClass(D.getDeclSpec()); - - // dllimport globals without explicit storage class are treated as extern. We - // have to change the storage class this early to get the right DeclContext. - if (SC == SC_None && !DC->isRecord() && - hasParsedAttr(S, D, AttributeList::AT_DLLImport) && - !hasParsedAttr(S, D, AttributeList::AT_DLLExport)) -SC = SC_Extern; + if (getLangOpts().OpenCL) { +// OpenCL v2.0 s6.9.b - Image type can only be used as a function argument. +// OpenCL v2.0 s6.13.16.1 - Pipe type can only be used as a function +// argument. +if (R->isImageType() || R->isPipeType()) { + Diag(D.getIdentifierLoc(), + diag::err_opencl_type_can_only_be_used_as_function_parameter) + << R; + D.setInvalidType(); + return nullptr; +} - DeclContext *OriginalDC = DC; - bool IsLocalExternDecl = SC == SC_Extern && - adjustContextForLocalExternDecl(DC); +// OpenCL v1.2 s6.9.r: +// The event type cannot be used to declare a program scope variable. +// OpenCL v2.0 s6.9.q: +// The clk_event_t and reserve_id_t types cannot be declared in program scope. +if (NULL == S->getParent()) { + if (R->isReserveIDT() || R->isClkEventT() || R->isEventT()) { +Diag(D.getIdentifierLoc(), + diag::err_invalid_type_for_program_scope_var) << R; +D.setInvalidType(); +return nullptr; + } +} - if (getLangOpts().OpenCL) { // OpenCL v1.0 s6.8.a.3: Pointers to functions are not allowed. QualType NR = R; while (NR->isPointerType()) { @@ -5954,8 +5953,40 @@ NamedDecl *Sema::ActOnVariableDeclarator D.setInvalidType(); } } + +// OpenCL v1.2 s6.9.b p4: +// The sampler type cannot be used with the __local and __global address +// space qualifiers. +if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local || + R.getAddressSpace() == LangAS::opencl_global)) { + Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace); +} + +// OpenCL v1.2 s6.9.r: +// The event
r288890 - [OpenCL] Fix SPIR version generation.
Author: bader Date: Wed Dec 7 02:38:24 2016 New Revision: 288890 URL: http://llvm.org/viewvc/llvm-project?rev=288890&view=rev Log: [OpenCL] Fix SPIR version generation. Patch by Egor Churaev (echuraev). Reviewers: Anastasia Subscribers: bader, yaxunl, cfe-commits Differential Revision: https://reviews.llvm.org/D27300 Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/test/CodeGenOpenCL/spir_version.cl Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=288890&r1=29&r2=288890&view=diff == --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Dec 7 02:38:24 2016 @@ -7801,8 +7801,10 @@ void SPIRTargetCodeGenInfo::emitTargetMD // SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the // opencl.spir.version named metadata. llvm::Metadata *SPIRVerElts[] = { - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 2)), - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(Int32Ty, 0))}; + llvm::ConstantAsMetadata::get( + llvm::ConstantInt::get(Int32Ty, CGM.getLangOpts().OpenCLVersion / 100)), + llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( + Int32Ty, (CGM.getLangOpts().OpenCLVersion / 100 > 1) ? 0 : 2))}; llvm::NamedMDNode *SPIRVerMD = M.getOrInsertNamedMetadata("opencl.spir.version"); SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts)); Modified: cfe/trunk/test/CodeGenOpenCL/spir_version.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/spir_version.cl?rev=288890&r1=29&r2=288890&view=diff == --- cfe/trunk/test/CodeGenOpenCL/spir_version.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/spir_version.cl Wed Dec 7 02:38:24 2016 @@ -13,19 +13,22 @@ kernel void foo() {} // CHECK-SPIR-CL10: !opencl.spir.version = !{[[SPIR:![0-9]+]]} // CHECK-SPIR-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL10: [[SPIR]] = !{i32 2, i32 0} +// CHECK-SPIR-CL10: [[SPIR]] = !{i32 1, i32 2} // CHECK-SPIR-CL10: [[OCL]] = !{i32 1, i32 0} -// CHECK-SPIR-CL12: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-SPIR-CL12: [[SPIR]] = !{i32 2, i32 0} -// CHECK-SPIR-CL12: [[OCL]] = !{i32 1, i32 2} -// CHECK-SPIR-CL20: !opencl.spir.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[SPIR:![0-9]+]]} -// CHECK-SPIR-CL20: [[SPIR]] = !{i32 2, i32 0} +// CHECK-SPIR-CL12: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL12: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL12: [[VER]] = !{i32 1, i32 2} +// CHECK-SPIR-CL20: !opencl.spir.version = !{[[VER:![0-9]+]]} +// CHECK-SPIR-CL20: !opencl.ocl.version = !{[[VER]]} +// CHECK-SPIR-CL20: [[VER]] = !{i32 2, i32 0} + +// CHECK-AMDGCN-CL10-NOT: !opencl.spir.version // CHECK-AMDGCN-CL10: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL10: [[OCL]] = !{i32 1, i32 0} +// CHECK-AMDGCN-CL12-NOT: !opencl.spir.version // CHECK-AMDGCN-CL12: !opencl.ocl.version = !{[[OCL:![0-9]+]]} // CHECK-AMDGCN-CL12: [[OCL]] = !{i32 1, i32 2} +// CHECK-AMDGCN-CL20-NOT: !opencl.spir.version // CHECK-AMDGCN-CL20: !opencl.ocl.version = !{[[OCL:![0-9]+]]} -// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} \ No newline at end of file +// CHECK-AMDGCN-CL20: [[OCL]] = !{i32 2, i32 0} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r288891 - [OpenCL] Added a LIT test for ensuring address space mangling is done the same both in OpenCL1.2 and OpenCL2.0.
Author: bader Date: Wed Dec 7 02:43:49 2016 New Revision: 288891 URL: http://llvm.org/viewvc/llvm-project?rev=288891&view=rev Log: [OpenCL] Added a LIT test for ensuring address space mangling is done the same both in OpenCL1.2 and OpenCL2.0. Patch by Egor Churaev (echuraev). Reviewers: Anastasia Subscribers: yaxunl, cfe-commits, bader Differential Revision: https://reviews.llvm.org/D27403 Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl 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=288891&r1=288890&r2=288891&view=diff == --- cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/address-spaces-mangling.cl Wed Dec 7 02:43:49 2016 @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=yes -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefix=ASMANG %s // RUN: %clang_cc1 %s -ffake-address-space-map -faddress-space-map-mangling=no -triple %itanium_abi_triple -emit-llvm -o - | FileCheck -check-prefix=NOASMANG %s +// We check that the address spaces are mangled the same in both version of OpenCL +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL2.0 -emit-llvm -o - | FileCheck -check-prefix=OCL-20 %s +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=CL1.2 -emit-llvm -o - | FileCheck -check-prefix=OCL-12 %s + // We can't name this f as private is equivalent to default // no specifier given address space so we get multiple definition // warnings, but we do want it for comparison purposes. @@ -8,23 +12,33 @@ __attribute__((overloadable)) void ff(int *arg) { } // ASMANG: @_Z2ffPi // NOASMANG: @_Z2ffPi +// OCL-20-DAG: @_Z2ffPU3AS4i +// OCL-12-DAG: @_Z2ffPi __attribute__((overloadable)) void f(private int *arg) { } // ASMANG: @_Z1fPi // NOASMANG: @_Z1fPi +// OCL-20-DAG: @_Z1fPi +// OCL-12-DAG: @_Z1fPi __attribute__((overloadable)) void f(global int *arg) { } // ASMANG: @_Z1fPU3AS1i // NOASMANG: @_Z1fPU8CLglobali +// OCL-20-DAG: @_Z1fPU3AS1i +// OCL-12-DAG: @_Z1fPU3AS1i __attribute__((overloadable)) void f(local int *arg) { } // ASMANG: @_Z1fPU3AS2i // NOASMANG: @_Z1fPU7CLlocali +// OCL-20-DAG: @_Z1fPU3AS2i +// OCL-12-DAG: @_Z1fPU3AS2i __attribute__((overloadable)) void f(constant int *arg) { } // ASMANG: @_Z1fPU3AS3i // NOASMANG: @_Z1fPU10CLconstanti +// OCL-20-DAG: @_Z1fPU3AS3i +// OCL-12-DAG: @_Z1fPU3AS3i ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
bader accepted this revision. bader added a comment. LGTM https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
bader added inline comments. Comment at: lib/CodeGen/CGDecl.cpp:1272 +if (getLangOpts().OpenCL) { + UA = llvm::GlobalValue::UnnamedAddr::None; + AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); AlexeySotkin wrote: > Anastasia wrote: > > Why this change? > Without this change, global variables with unnamed address space are > translated to SPIR-V as variables with "Function" storage class, which is > wrong. > This should fix this issue: > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50 There is inconsistency with how Clang maps initializers to OpenCL memory model. Consider example from the test case: ``` __private int arr[] = {1, 2, 3}; ``` This code allocates a global constant for initializer {1, 2, 3} and later copies values from this global constant to the private array using memcpy intrinsic. The global constant must be allocated in constant address space, but old code do assign any address space, which is considered to be a private memory region. This patch puts global constant objects to constant address space. https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
bader added inline comments. Comment at: lib/CodeGen/CGDecl.cpp:1272 +if (getLangOpts().OpenCL) { + UA = llvm::GlobalValue::UnnamedAddr::None; + AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); Anastasia wrote: > bader wrote: > > AlexeySotkin wrote: > > > Anastasia wrote: > > > > Why this change? > > > Without this change, global variables with unnamed address space are > > > translated to SPIR-V as variables with "Function" storage class, which is > > > wrong. > > > This should fix this issue: > > > https://github.com/KhronosGroup/SPIRV-LLVM/issues/50 > > There is inconsistency with how Clang maps initializers to OpenCL memory > > model. > > Consider example from the test case: > > ``` > > __private int arr[] = {1, 2, 3}; > > ``` > > This code allocates a global constant for initializer {1, 2, 3} and later > > copies values from this global constant to the private array using memcpy > > intrinsic. The global constant must be allocated in constant address space, > > but old code do assign any address space, which is considered to be a > > private memory region. > > This patch puts global constant objects to constant address space. > Yes, this is perfectly fine. I was specifically asking about setting > llvm::GlobalValue::UnnamedAddr::None attribute. I can't see why this has to > be done or is it because we now assign concrete address space and private was > treated as no address space at all? This attribute has nothing to do with address spaces. See http://llvm.org/docs/LangRef.html#global-variables for local_unnamed_addr and unnamed_addr attributes description. My understanding is that llvm::GlobalValue::UnnamedAddr::Global should be fine here. https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r285557 - [OpenCL] Setting constant address space for array initializers
Author: bader Date: Mon Oct 31 05:26:31 2016 New Revision: 285557 URL: http://llvm.org/viewvc/llvm-project?rev=285557&view=rev Log: [OpenCL] Setting constant address space for array initializers Summary: Setting constant address space for global constants used for memcpy-initialization of arrays. Patch by Alexey Sotkin. Reviewers: bader, yaxunl, Anastasia Subscribers: cfe-commits, AlexeySotkin Differential Revision: https://reviews.llvm.org/D25305 Added: cfe/trunk/test/CodeGenOpenCL/private-array-initialization.cl Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=285557&r1=285556&r2=285557&view=diff == --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Mon Oct 31 05:26:31 2016 @@ -1225,10 +1225,16 @@ void CodeGenFunction::EmitAutoVarInit(co // Otherwise, create a temporary global with the initializer then // memcpy from the global to the alloca. std::string Name = getStaticDeclName(CGM, D); +unsigned AS = 0; +if (getLangOpts().OpenCL) { + AS = CGM.getContext().getTargetAddressSpace(LangAS::opencl_constant); + BP = llvm::PointerType::getInt8PtrTy(getLLVMContext(), AS); +} llvm::GlobalVariable *GV = new llvm::GlobalVariable(CGM.getModule(), constant->getType(), true, llvm::GlobalValue::PrivateLinkage, - constant, Name); + constant, Name, nullptr, + llvm::GlobalValue::NotThreadLocal, AS); GV->setAlignment(Loc.getAlignment().getQuantity()); GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); Modified: cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl?rev=285557&r1=285556&r2=285557&view=diff == --- cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/partial_initializer.cl Mon Oct 31 05:26:31 2016 @@ -24,7 +24,7 @@ int4 GV1 = (int4)((int2)(1,2),3,4); // CHECK: @GV2 = addrspace(1) global <4 x i32> , align 16 int4 GV2 = (int4)(1); -// CHECK: @f.S = private unnamed_addr constant %struct.StrucTy { i32 1, i32 2, i32 0 }, align 4 +// CHECK: @f.S = private unnamed_addr addrspace(2) constant %struct.StrucTy { i32 1, i32 2, i32 0 }, align 4 // CHECK-LABEL: define spir_func void @f() void f(void) { @@ -46,7 +46,7 @@ void f(void) { float A[6][6] = {1.0f, 2.0f}; // CHECK: %[[v5:.*]] = bitcast %struct.StrucTy* %S to i8* - // CHECK: call void @llvm.memcpy.p0i8.p0i8.i32(i8* %[[v5]], i8* bitcast (%struct.StrucTy* @f.S to i8*), i32 12, i32 4, i1 false) + // CHECK: call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[v5]], i8 addrspace(2)* bitcast (%struct.StrucTy addrspace(2)* @f.S to i8 addrspace(2)*), i32 12, i32 4, i1 false) StrucTy S = {1, 2}; // CHECK: store <2 x i32> , <2 x i32>* %[[compoundliteral1]], align 8 Added: cfe/trunk/test/CodeGenOpenCL/private-array-initialization.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/private-array-initialization.cl?rev=285557&view=auto == --- cfe/trunk/test/CodeGenOpenCL/private-array-initialization.cl (added) +++ cfe/trunk/test/CodeGenOpenCL/private-array-initialization.cl Mon Oct 31 05:26:31 2016 @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | FileCheck %s + +// CHECK: @test.arr = private unnamed_addr addrspace(2) constant [3 x i32] [i32 1, i32 2, i32 3], align 4 + +void test() { + __private int arr[] = {1, 2, 3}; +// CHECK: %[[arr_i8_ptr:[0-9]+]] = bitcast [3 x i32]* %arr to i8* +// CHECK: call void @llvm.memcpy.p0i8.p2i8.i32(i8* %[[arr_i8_ptr]], i8 addrspace(2)* bitcast ([3 x i32] addrspace(2)* @test.arr to i8 addrspace(2)*), i32 12, i32 4, i1 false) +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25305: [OpenCL] Setting constant address space for array initializers
bader added a comment. Committed at 285557 with updated tests. https://reviews.llvm.org/D25305 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r285700 - [OpenCL] Override supported OpenCL extensions with -cl-ext option
Author: bader Date: Tue Nov 1 10:50:52 2016 New Revision: 285700 URL: http://llvm.org/viewvc/llvm-project?rev=285700&view=rev Log: [OpenCL] Override supported OpenCL extensions with -cl-ext option Summary: This patch adds a command line option '-cl-ext' to control a set of supported OpenCL extensions. Option accepts a comma-separated list of extensions prefixed with '+' or '-'. It can be used together with a target triple to override support for some extensions: // spir target supports all extensions, but we want to disable fp64 clang -cc1 -triple spir-unknown-unknown -cl-ext=-cl_khr_fp64 Special 'all' extension allows to enable or disable all possible extensions: // only fp64 will be supported clang -cc1 -triple spir-unknown-unknown -cl-ext=-all,+cl_khr_fp64 Patch by asavonic (Andrew Savonichev). Reviewers: joey, yaxunl Subscribers: yaxunl, bader, Anastasia, cfe-commits Differential Revision: https://reviews.llvm.org/D23712 Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TargetOptions.h cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/SemaOpenCL/extensions.cl Modified: cfe/trunk/include/clang/Basic/OpenCLOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenCLOptions.h?rev=285700&r1=285699&r2=285700&view=diff == --- cfe/trunk/include/clang/Basic/OpenCLOptions.h (original) +++ cfe/trunk/include/clang/Basic/OpenCLOptions.h Tue Nov 1 10:50:52 2016 @@ -15,6 +15,8 @@ #ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H #define LLVM_CLANG_BASIC_OPENCLOPTIONS_H +#include "llvm/ADT/StringRef.h" + namespace clang { /// \brief OpenCL supported extensions and optional core features @@ -28,9 +30,39 @@ public: #include "clang/Basic/OpenCLExtensions.def" } - // Enable all options. - void setAll() { -#define OPENCLEXT(nm) nm = 1; + // Enable or disable all options. + void setAll(bool Enable = true) { +#define OPENCLEXT(nm) nm = Enable; +#include "clang/Basic/OpenCLExtensions.def" + } + + /// \brief Enable or disable support for OpenCL extensions + /// \param Ext name of the extension optionally prefixed with + ///'+' or '-' + /// \param Enable used when \p Ext is not prefixed by '+' or '-' + void set(llvm::StringRef Ext, bool Enable = true) { +assert(!Ext.empty() && "Extension is empty."); + +switch (Ext[0]) { +case '+': + Enable = true; + Ext = Ext.drop_front(); + break; +case '-': + Enable = false; + Ext = Ext.drop_front(); + break; +} + +if (Ext.equals("all")) { + setAll(Enable); + return; +} + +#define OPENCLEXT(nm) \ +if (Ext.equals(#nm)) { \ + nm = Enable; \ +} #include "clang/Basic/OpenCLExtensions.def" } Modified: cfe/trunk/include/clang/Basic/TargetInfo.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=285700&r1=285699&r2=285700&view=diff == --- cfe/trunk/include/clang/Basic/TargetInfo.h (original) +++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Nov 1 10:50:52 2016 @@ -995,6 +995,13 @@ public: /// \brief Set supported OpenCL extensions and optional core features. virtual void setSupportedOpenCLOpts() {} + /// \brief Set supported OpenCL extensions as written on command line + virtual void setOpenCLExtensionOpts() { +for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { + getTargetOpts().SupportedOpenCLOptions.set(Ext); +} + } + /// \brief Get supported OpenCL extensions and optional core features. OpenCLOptions &getSupportedOpenCLOpts() { return getTargetOpts().SupportedOpenCLOptions; Modified: cfe/trunk/include/clang/Basic/TargetOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=285700&r1=285699&r2=285700&view=diff == --- cfe/trunk/include/clang/Basic/TargetOptions.h (original) +++ cfe/trunk/include/clang/Basic/TargetOptions.h Tue Nov 1 10:50:52 2016 @@ -58,6 +58,10 @@ public: /// Supported OpenCL extensions and optional core features. OpenCLOptions SupportedOpenCLOptions; + + /// \brief The list of OpenCL extensions to enable or disable, as written on + /// the command line. + std::vector OpenCLExtensionsAsWritten; }; } // end namespace clang Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=285700&r1=285699&r2=285700&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (o
[PATCH] D23712: [OpenCL] Override supported OpenCL extensions with -cl-ext option
This revision was automatically updated to reflect the committed changes. Closed by commit rL285700: [OpenCL] Override supported OpenCL extensions with -cl-ext option (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23712?vs=75568&id=76571#toc Repository: rL LLVM https://reviews.llvm.org/D23712 Files: cfe/trunk/include/clang/Basic/OpenCLOptions.h cfe/trunk/include/clang/Basic/TargetInfo.h cfe/trunk/include/clang/Basic/TargetOptions.h cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/SemaOpenCL/extensions.cl Index: cfe/trunk/include/clang/Driver/CC1Options.td === --- cfe/trunk/include/clang/Driver/CC1Options.td +++ cfe/trunk/include/clang/Driver/CC1Options.td @@ -688,6 +688,13 @@ HelpText<"include a detailed record of preprocessing actions">; //===--===// +// OpenCL Options +//===--===// + +def cl_ext_EQ : CommaJoined<["-"], "cl-ext=">, + HelpText<"OpenCL only. Enable or disable OpenCL extensions. The argument is a comma-separated sequence of one or more extension names, each prefixed by '+' or '-'.">; + +//===--===// // CUDA Options //===--===// Index: cfe/trunk/include/clang/Basic/TargetInfo.h === --- cfe/trunk/include/clang/Basic/TargetInfo.h +++ cfe/trunk/include/clang/Basic/TargetInfo.h @@ -995,6 +995,13 @@ /// \brief Set supported OpenCL extensions and optional core features. virtual void setSupportedOpenCLOpts() {} + /// \brief Set supported OpenCL extensions as written on command line + virtual void setOpenCLExtensionOpts() { +for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) { + getTargetOpts().SupportedOpenCLOptions.set(Ext); +} + } + /// \brief Get supported OpenCL extensions and optional core features. OpenCLOptions &getSupportedOpenCLOpts() { return getTargetOpts().SupportedOpenCLOptions; Index: cfe/trunk/include/clang/Basic/TargetOptions.h === --- cfe/trunk/include/clang/Basic/TargetOptions.h +++ cfe/trunk/include/clang/Basic/TargetOptions.h @@ -58,6 +58,10 @@ /// Supported OpenCL extensions and optional core features. OpenCLOptions SupportedOpenCLOptions; + + /// \brief The list of OpenCL extensions to enable or disable, as written on + /// the command line. + std::vector OpenCLExtensionsAsWritten; }; } // end namespace clang Index: cfe/trunk/include/clang/Basic/OpenCLOptions.h === --- cfe/trunk/include/clang/Basic/OpenCLOptions.h +++ cfe/trunk/include/clang/Basic/OpenCLOptions.h @@ -15,6 +15,8 @@ #ifndef LLVM_CLANG_BASIC_OPENCLOPTIONS_H #define LLVM_CLANG_BASIC_OPENCLOPTIONS_H +#include "llvm/ADT/StringRef.h" + namespace clang { /// \brief OpenCL supported extensions and optional core features @@ -28,9 +30,39 @@ #include "clang/Basic/OpenCLExtensions.def" } - // Enable all options. - void setAll() { -#define OPENCLEXT(nm) nm = 1; + // Enable or disable all options. + void setAll(bool Enable = true) { +#define OPENCLEXT(nm) nm = Enable; +#include "clang/Basic/OpenCLExtensions.def" + } + + /// \brief Enable or disable support for OpenCL extensions + /// \param Ext name of the extension optionally prefixed with + ///'+' or '-' + /// \param Enable used when \p Ext is not prefixed by '+' or '-' + void set(llvm::StringRef Ext, bool Enable = true) { +assert(!Ext.empty() && "Extension is empty."); + +switch (Ext[0]) { +case '+': + Enable = true; + Ext = Ext.drop_front(); + break; +case '-': + Enable = false; + Ext = Ext.drop_front(); + break; +} + +if (Ext.equals("all")) { + setAll(Enable); + return; +} + +#define OPENCLEXT(nm) \ +if (Ext.equals(#nm)) { \ + nm = Enable; \ +} #include "clang/Basic/OpenCLExtensions.def" } Index: cfe/trunk/test/SemaOpenCL/extensions.cl === --- cfe/trunk/test/SemaOpenCL/extensions.cl +++ cfe/trunk/test/SemaOpenCL/extensions.cl @@ -2,7 +2,26 @@ // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1 // Test with a target not supporting fp64. -// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 +// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16 + +// Test with some extensions ena
[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD
bader added a comment. @pekka.jaaskelainen, I have related question: what is the problem with retaining OpenCL address space information in LLVM IR? My understanding is that target CodeGen can ignore this information for the machines with 'flat' address space model. On the other hand I would expect this information be useful for the Optimizer to resolve pointer aliasing. Does it make any sense to keep OpenCL address space information in LLVM IR generated for the machines with 'flat' address space (e.g. CPU)? Repository: rL LLVM https://reviews.llvm.org/D26157 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.
bader created this revision. bader added a reviewer: pekka.jaaskelainen. bader added a subscriber: cfe-commits. Patch by Pedro Ferreira. This patch was reviewed here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20150629/thread.html#131992, but wasn't submitted into the tree. Rebased to rev. 247586. http://reviews.llvm.org/D12855 Files: include/clang/AST/ASTContext.h include/clang/AST/BuiltinTypes.def include/clang/AST/Type.h include/clang/Basic/OpenCLExtensions.def include/clang/Serialization/ASTBitCodes.h lib/AST/ASTContext.cpp lib/AST/ItaniumMangle.cpp lib/AST/MicrosoftMangle.cpp lib/AST/NSAPI.cpp lib/AST/Type.cpp lib/AST/TypeLoc.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CGOpenCLRuntime.cpp lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/Index/USRGeneration.cpp lib/Sema/Sema.cpp lib/Sema/SemaType.cpp lib/Serialization/ASTCommon.cpp lib/Serialization/ASTReader.cpp test/PCH/ocl_types.h tools/libclang/CIndex.cpp Index: tools/libclang/CIndex.cpp === --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -1460,9 +1460,19 @@ case BuiltinType::OCLImage1dBuffer: case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: + case BuiltinType::OCLImage2dDepth: + case BuiltinType::OCLImage2dArrayDepth: + case BuiltinType::OCLImage2dMSAA: + case BuiltinType::OCLImage2dArrayMSAA: + case BuiltinType::OCLImage2dMSAADepth: + case BuiltinType::OCLImage2dArrayMSAADepth: case BuiltinType::OCLImage3d: case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: + case BuiltinType::OCLClkEvent: + case BuiltinType::OCLQueue: + case BuiltinType::OCLNDRange: + case BuiltinType::OCLReserveID: #define BUILTIN_TYPE(Id, SingletonId) #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: Index: test/PCH/ocl_types.h === --- test/PCH/ocl_types.h +++ test/PCH/ocl_types.h @@ -23,3 +23,37 @@ // event_t typedef event_t evt_t; + +#if __OPENCL_VERSION__ >= 200 + +// clk_event_t +typedef clk_event_t clkevt_t; + +// queue_t +typedef queue_t q_t; + +// ndrange_t +typedef ndrange_t range_t; + +// reserve_id_t +typedef reserve_id_t reserveid_t; + +// image2d_depth_t +typedef image2d_depth_t img2ddep_t; + +// image2d_array_depth_t +typedef image2d_array_depth_t img2darr_dep_t; + +// image2d_msaa_t +typedef image2d_msaa_t img2dmsaa_t; + +// image2d_array_msaa_t +typedef image2d_array_msaa_t img2darrmsaa_t; + +// image2d_msaa_depth_t +typedef image2d_msaa_depth_t img2dmsaadep_t; + +// image2d_array_msaa_depth_t +typedef image2d_array_msaa_depth_t img2darrmsaadep_t; + +#endif Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -5824,9 +5824,39 @@ case PREDEF_TYPE_IMAGE1D_BUFF_ID: T = Context.OCLImage1dBufferTy; break; case PREDEF_TYPE_IMAGE2D_ID:T = Context.OCLImage2dTy; break; case PREDEF_TYPE_IMAGE2D_ARR_ID: T = Context.OCLImage2dArrayTy; break; +case PREDEF_TYPE_IMAGE2D_DEP_ID: + T = Context.OCLImage2dDepthTy; + break; +case PREDEF_TYPE_IMAGE2D_ARR_DEP_ID: + T = Context.OCLImage2dArrayDepthTy; + break; +case PREDEF_TYPE_IMAGE2D_MSAA_ID: + T = Context.OCLImage2dMSAATy; + break; +case PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID: + T = Context.OCLImage2dArrayMSAATy; + break; +case PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID: + T = Context.OCLImage2dMSAADepthTy; + break; +case PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID: + T = Context.OCLImage2dArrayMSAADepthTy; + break; case PREDEF_TYPE_IMAGE3D_ID:T = Context.OCLImage3dTy; break; case PREDEF_TYPE_SAMPLER_ID:T = Context.OCLSamplerTy; break; case PREDEF_TYPE_EVENT_ID: T = Context.OCLEventTy; break; +case PREDEF_TYPE_CLK_EVENT_ID: + T = Context.OCLClkEventTy; + break; +case PREDEF_TYPE_QUEUE_ID: + T = Context.OCLQueueTy; + break; +case PREDEF_TYPE_NDRANGE_ID: + T = Context.OCLNDRangeTy; + break; +case PREDEF_TYPE_RESERVE_ID_ID: + T = Context.OCLReserveIDTy; + break; case PREDEF_TYPE_AUTO_DEDUCT: T = Context.getAutoDeductType(); break; case PREDEF_TYPE_AUTO_RREF_DEDUCT: Index: lib/Serialization/ASTCommon.cpp === --- lib/Serialization/ASTCommon.cpp +++ lib/Serialization/ASTCommon.cpp @@ -67,9 +67,39 @@ case BuiltinType::OCLImage1dBuffer: ID = PREDEF_TYPE_IMAGE1D_BUFF_ID; break; case BuiltinType::OCLImage2d: ID = PREDEF_TYPE_IMAGE2D_ID; break; case BuiltinType::OCLImage2dArray: ID = PREDEF_TYPE_IMAGE2D_ARR_ID; break; + case BuiltinType::OCLImage2dDepth
Re: [PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.
bader added a comment. In http://reviews.llvm.org/D12855#246004, @pekka.jaaskelainen wrote: > The patch seems straightforward enough. BTW does someone know if anyone has > worked on the 'pipe' qualifier? I'm currently supporting Intel's implementation of 'pipe' qualifier and I'd like to contribute this implementation to the community if there is any interest. Comment at: lib/Serialization/ASTCommon.cpp:70 @@ -69,1 +69,3 @@ case BuiltinType::OCLImage2dArray: ID = PREDEF_TYPE_IMAGE2D_ARR_ID; break; + case BuiltinType::OCLImage2dDepth: +ID = PREDEF_TYPE_IMAGE2D_DEP_ID; pekka.jaaskelainen wrote: > A nitpick, but why deviate from the style where each case has been stuffed to > a single line? My guess it's effect of clang-format. Original patch sent by Pedro matched the style, but violated 80-character limit, so he was asked to run clang-format over the patch. Do you want me to run clang-format on surrounding code to unify the style? http://reviews.llvm.org/D12855 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r247676 - [OpenCL] Add new types for OpenCL 2.0.
Author: bader Date: Tue Sep 15 06:18:52 2015 New Revision: 247676 URL: http://llvm.org/viewvc/llvm-project?rev=247676&view=rev Log: [OpenCL] Add new types for OpenCL 2.0. Patch by Pedro Ferreira. Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12855 Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/OpenCLExtensions.def cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/PCH/ocl_types.h cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=247676&r1=247675&r2=247676&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Tue Sep 15 06:18:52 2015 @@ -839,9 +839,12 @@ public: CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy; CanQualType ObjCBuiltinBoolTy; CanQualType OCLImage1dTy, OCLImage1dArrayTy, OCLImage1dBufferTy; - CanQualType OCLImage2dTy, OCLImage2dArrayTy; + CanQualType OCLImage2dTy, OCLImage2dArrayTy, OCLImage2dDepthTy; + CanQualType OCLImage2dArrayDepthTy, OCLImage2dMSAATy, OCLImage2dArrayMSAATy; + CanQualType OCLImage2dMSAADepthTy, OCLImage2dArrayMSAADepthTy; CanQualType OCLImage3dTy; - CanQualType OCLSamplerTy, OCLEventTy; + CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; + CanQualType OCLQueueTy, OCLNDRangeTy, OCLReserveIDTy; CanQualType OMPArraySectionTy; // Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand. Modified: cfe/trunk/include/clang/AST/BuiltinTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BuiltinTypes.def?rev=247676&r1=247675&r2=247676&view=diff == --- cfe/trunk/include/clang/AST/BuiltinTypes.def (original) +++ cfe/trunk/include/clang/AST/BuiltinTypes.def Tue Sep 15 06:18:52 2015 @@ -160,6 +160,12 @@ BUILTIN_TYPE(OCLImage1dArray, OCLImage1d BUILTIN_TYPE(OCLImage1dBuffer, OCLImage1dBufferTy) BUILTIN_TYPE(OCLImage2d, OCLImage2dTy) BUILTIN_TYPE(OCLImage2dArray, OCLImage2dArrayTy) +BUILTIN_TYPE(OCLImage2dDepth, OCLImage2dDepthTy) +BUILTIN_TYPE(OCLImage2dArrayDepth, OCLImage2dArrayDepthTy) +BUILTIN_TYPE(OCLImage2dMSAA, OCLImage2dMSAATy) +BUILTIN_TYPE(OCLImage2dArrayMSAA, OCLImage2dArrayMSAATy) +BUILTIN_TYPE(OCLImage2dMSAADepth, OCLImage2dMSAADepthTy) +BUILTIN_TYPE(OCLImage2dArrayMSAADepth, OCLImage2dArrayMSAADepthTy) BUILTIN_TYPE(OCLImage3d, OCLImage3dTy) // OpenCL sampler_t. @@ -168,6 +174,18 @@ BUILTIN_TYPE(OCLSampler, OCLSamplerTy) // OpenCL event_t. BUILTIN_TYPE(OCLEvent, OCLEventTy) +// OpenCL clk_event_t. +BUILTIN_TYPE(OCLClkEvent, OCLClkEventTy) + +// OpenCL queue_t. +BUILTIN_TYPE(OCLQueue, OCLQueueTy) + +// OpenCL ndrange_t. +BUILTIN_TYPE(OCLNDRange, OCLNDRangeTy) + +// OpenCL reserve_id_t. +BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is Modified: cfe/trunk/include/clang/AST/Type.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=247676&r1=247675&r2=247676&view=diff == --- cfe/trunk/include/clang/AST/Type.h (original) +++ cfe/trunk/include/clang/AST/Type.h Tue Sep 15 06:18:52 2015 @@ -1683,17 +1683,27 @@ public: bool isNullPtrType() const; // C++0x nullptr_t bool isAtomicType() const;// C11 _Atomic() - bool isImage1dT() const; // OpenCL image1d_t - bool isImage1dArrayT() const; // OpenCL image1d_array_t - bool isImage1dBufferT() const;// OpenCL image1d_buffer_t - bool isImage2dT() const; // OpenCL image2d_t - bool isImage2dArrayT() const; // OpenCL image2d_array_t - bool isImage3dT() const; // OpenCL image3d_t + bool isImage1dT() const; // OpenCL image1d_t + bool isImage1dArr
Re: [PATCH] D12855: [OpenCL] Add new types for OpenCL 2.0.
This revision was automatically updated to reflect the committed changes. Closed by commit rL247676: [OpenCL] Add new types for OpenCL 2.0. (authored by bader). Changed prior to commit: http://reviews.llvm.org/D12855?vs=34709&id=34796#toc Repository: rL LLVM http://reviews.llvm.org/D12855 Files: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/OpenCLExtensions.def cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/PCH/ocl_types.h cfe/trunk/tools/libclang/CIndex.cpp Index: cfe/trunk/tools/libclang/CIndex.cpp === --- cfe/trunk/tools/libclang/CIndex.cpp +++ cfe/trunk/tools/libclang/CIndex.cpp @@ -1460,9 +1460,19 @@ case BuiltinType::OCLImage1dBuffer: case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: + case BuiltinType::OCLImage2dDepth: + case BuiltinType::OCLImage2dArrayDepth: + case BuiltinType::OCLImage2dMSAA: + case BuiltinType::OCLImage2dArrayMSAA: + case BuiltinType::OCLImage2dMSAADepth: + case BuiltinType::OCLImage2dArrayMSAADepth: case BuiltinType::OCLImage3d: case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: + case BuiltinType::OCLClkEvent: + case BuiltinType::OCLQueue: + case BuiltinType::OCLNDRange: + case BuiltinType::OCLReserveID: #define BUILTIN_TYPE(Id, SingletonId) #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id: Index: cfe/trunk/include/clang/AST/BuiltinTypes.def === --- cfe/trunk/include/clang/AST/BuiltinTypes.def +++ cfe/trunk/include/clang/AST/BuiltinTypes.def @@ -160,14 +160,32 @@ BUILTIN_TYPE(OCLImage1dBuffer, OCLImage1dBufferTy) BUILTIN_TYPE(OCLImage2d, OCLImage2dTy) BUILTIN_TYPE(OCLImage2dArray, OCLImage2dArrayTy) +BUILTIN_TYPE(OCLImage2dDepth, OCLImage2dDepthTy) +BUILTIN_TYPE(OCLImage2dArrayDepth, OCLImage2dArrayDepthTy) +BUILTIN_TYPE(OCLImage2dMSAA, OCLImage2dMSAATy) +BUILTIN_TYPE(OCLImage2dArrayMSAA, OCLImage2dArrayMSAATy) +BUILTIN_TYPE(OCLImage2dMSAADepth, OCLImage2dMSAADepthTy) +BUILTIN_TYPE(OCLImage2dArrayMSAADepth, OCLImage2dArrayMSAADepthTy) BUILTIN_TYPE(OCLImage3d, OCLImage3dTy) // OpenCL sampler_t. BUILTIN_TYPE(OCLSampler, OCLSamplerTy) // OpenCL event_t. BUILTIN_TYPE(OCLEvent, OCLEventTy) +// OpenCL clk_event_t. +BUILTIN_TYPE(OCLClkEvent, OCLClkEventTy) + +// OpenCL queue_t. +BUILTIN_TYPE(OCLQueue, OCLQueueTy) + +// OpenCL ndrange_t. +BUILTIN_TYPE(OCLNDRange, OCLNDRangeTy) + +// OpenCL reserve_id_t. +BUILTIN_TYPE(OCLReserveID, OCLReserveIDTy) + // This represents the type of an expression whose type is // totally unknown, e.g. 'T::foo'. It is permitted for this to // appear in situations where the structure of the type is Index: cfe/trunk/include/clang/AST/Type.h === --- cfe/trunk/include/clang/AST/Type.h +++ cfe/trunk/include/clang/AST/Type.h @@ -1683,17 +1683,27 @@ bool isNullPtrType() const; // C++0x nullptr_t bool isAtomicType() const;// C11 _Atomic() - bool isImage1dT() const; // OpenCL image1d_t - bool isImage1dArrayT() const; // OpenCL image1d_array_t - bool isImage1dBufferT() const;// OpenCL image1d_buffer_t - bool isImage2dT() const; // OpenCL image2d_t - bool isImage2dArrayT() const; // OpenCL image2d_array_t - bool isImage3dT() const; // OpenCL image3d_t + bool isImage1dT() const; // OpenCL image1d_t + bool isImage1dArrayT() const; // OpenCL image1d_array_t + bool isImage1dBufferT() const; // OpenCL image1d_buffer_t + bool isImage2dT() const; // OpenCL image2d_t + bool isImage2dArrayT() const; // OpenCL image2d_array_t + bool isImage2dDepthT() const; // OpenCL image_2d_depth_t + bool isImage2dArrayDepthT() const; // OpenCL image_2d_array_depth_t + bool isImage2dMSAAT() const; // OpenCL image_2d_msaa_t + bool isImage2dArrayMSAAT() const; // OpenCL image_2d_array_msaa_t + bool isImage2dMSAATDepth() const; // OpenCL image_2d_msaa_depth_t + bool isImage2dA
r247678 - Run clang-format to unify the switch statement style as suggest here: http://reviews.llvm.org/D12855#246073.
Author: bader Date: Tue Sep 15 07:18:29 2015 New Revision: 247678 URL: http://llvm.org/viewvc/llvm-project?rev=247678&view=rev Log: Run clang-format to unify the switch statement style as suggest here: http://reviews.llvm.org/D12855#246073. NFC. Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=247678&r1=247677&r2=247678&view=diff == --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original) +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Sep 15 07:18:29 2015 @@ -1985,34 +1985,79 @@ void CXXNameMangler::mangleType(const Bu // ::= Dn # std::nullptr_t (i.e., decltype(nullptr)) // ::= u # vendor extended type switch (T->getKind()) { - case BuiltinType::Void: Out << 'v'; break; - case BuiltinType::Bool: Out << 'b'; break; - case BuiltinType::Char_U: case BuiltinType::Char_S: Out << 'c'; break; - case BuiltinType::UChar: Out << 'h'; break; - case BuiltinType::UShort: Out << 't'; break; - case BuiltinType::UInt: Out << 'j'; break; - case BuiltinType::ULong: Out << 'm'; break; - case BuiltinType::ULongLong: Out << 'y'; break; - case BuiltinType::UInt128: Out << 'o'; break; - case BuiltinType::SChar: Out << 'a'; break; + case BuiltinType::Void: +Out << 'v'; +break; + case BuiltinType::Bool: +Out << 'b'; +break; + case BuiltinType::Char_U: + case BuiltinType::Char_S: +Out << 'c'; +break; + case BuiltinType::UChar: +Out << 'h'; +break; + case BuiltinType::UShort: +Out << 't'; +break; + case BuiltinType::UInt: +Out << 'j'; +break; + case BuiltinType::ULong: +Out << 'm'; +break; + case BuiltinType::ULongLong: +Out << 'y'; +break; + case BuiltinType::UInt128: +Out << 'o'; +break; + case BuiltinType::SChar: +Out << 'a'; +break; case BuiltinType::WChar_S: - case BuiltinType::WChar_U: Out << 'w'; break; - case BuiltinType::Char16: Out << "Ds"; break; - case BuiltinType::Char32: Out << "Di"; break; - case BuiltinType::Short: Out << 's'; break; - case BuiltinType::Int: Out << 'i'; break; - case BuiltinType::Long: Out << 'l'; break; - case BuiltinType::LongLong: Out << 'x'; break; - case BuiltinType::Int128: Out << 'n'; break; - case BuiltinType::Half: Out << "Dh"; break; - case BuiltinType::Float: Out << 'f'; break; - case BuiltinType::Double: Out << 'd'; break; + case BuiltinType::WChar_U: +Out << 'w'; +break; + case BuiltinType::Char16: +Out << "Ds"; +break; + case BuiltinType::Char32: +Out << "Di"; +break; + case BuiltinType::Short: +Out << 's'; +break; + case BuiltinType::Int: +Out << 'i'; +break; + case BuiltinType::Long: +Out << 'l'; +break; + case BuiltinType::LongLong: +Out << 'x'; +break; + case BuiltinType::Int128: +Out << 'n'; +break; + case BuiltinType::Half: +Out << "Dh"; +break; + case BuiltinType::Float: +Out << 'f'; +break; + case BuiltinType::Double: +Out << 'd'; +break; case BuiltinType::LongDouble: Out << (getASTContext().getTargetInfo().useFloat128ManglingForLongDouble() ? 'g' : 'e'); break; - case BuiltinType::NullPtr: Out << "Dn"; break; + case BuiltinType::NullPtr: +Out << "Dn"; +break; #define BUILTIN_TYPE(Id, SingletonId) #define PLACEHOLDER_TYPE(Id, SingletonId) \ @@ -2020,14 +2065,30 @@ void CXXNameMangler::mangleType(const Bu #include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: llvm_unreachable("mangling a placeholder type"); - case BuiltinType::ObjCId: Out << "11objc_object"; break; - case BuiltinType::ObjCClass: Out << "10objc_class"; break; - case BuiltinType::ObjCSel: Out << "13objc_selector"; break; - case BuiltinType::OCLImage1d: Out << "11ocl_image1d"; break; - case BuiltinType::OCLImage1dArray: Out << "16ocl_image1darray"; break; - case BuiltinType::OCLImage1dBuffer: Out << "17ocl_image1dbuffer"; break; - case BuiltinType::OCLImage2d: Out << "11ocl_image2d"; break; - case BuiltinType::OCLImage2dArray: Out << "16ocl_image2darray"; break; + case BuiltinType::ObjCId: +Out << "11objc_object"; +break; + case BuiltinType::ObjCClass: +Out << "10objc_class"; +break; + case BuiltinType::ObjCSel: +Out << "13objc_selector"; +break; + case BuiltinType::OCLImage1d: +Out << "11ocl_image1d"; +break; + case BuiltinType::OCLImage1dArray: +Out << "16ocl_image1darray"; +break; + case BuiltinType::OCLImage1dBuffer: +Out << "17ocl_image1dbuffer"; +break; + case BuiltinType::OCLImage2d: +Out << "11ocl_image2d"; +break; + case BuiltinType::OCLImage2
Re: [PATCH] D13105: [OpenCL] Enable program scope variables for OpenCL2.0
bader added a subscriber: bader. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7472-7473 @@ -7469,4 +7471,4 @@ "sampler type cannot be used with the __local and __global address space qualifiers">; def err_opencl_global_invalid_addr_space : Error< - "global variables must have a constant address space qualifier">; + "program scope variables has wrong address space qualifier">; def err_opencl_no_main : Error<"%select{function|kernel}0 cannot be called 'main'">; I think we can do better diagnostics. Original message hinted on way to fix that error - add 'constant' qualifier. In our implementation we have 4 kinds of diagnostics (probably we need only 2 of them): def err_opencl_global_invalid_addr_space : Error< "program scope variables must reside in constant address space">; def err_opencl20_global_invalid_addr_space : Error< "program scope variables must reside in global or constant address space">; def err_program_scope_variable_non_constant : Error< "program scope variables are required to be declared in constant address space">; def err_program_scope_variable_non_constant_or_global : Error< "program scope variables are required to be declared either in constant or global address space">; They used for OpenCL 1.2 and OpenCL 2.0 sources correspondingly. Comment at: test/SemaOpenCL/storageclass.cl:9-11 @@ +8,5 @@ +global int G2 = 0; +#ifndef CL20 +// expected-error@-2{{program scope variables has wrong address space qualifier}} +#endif + Don't you think it's better to put OpenCL 2.0 test into separate file? http://reviews.llvm.org/D13105 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D12378: [OpenCL] Improve diagnostics detecting implicit vector conversion.
bader created this revision. bader added a subscriber: cfe-commits. http://reviews.llvm.org/D12378 Files: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaOpenCL/cond.cl Index: test/SemaOpenCL/cond.cl === --- test/SemaOpenCL/cond.cl +++ test/SemaOpenCL/cond.cl @@ -84,7 +84,7 @@ float2 ntest04(int2 C, int2 X, float2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values)) are not permitted}} } float2 ntest05(int2 C, int2 X, float Y) @@ -115,7 +115,7 @@ char3 ntest10(char C, char3 X, char2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values)) are not permitted}} } char3 ntest11(char2 C, char3 X, char Y) Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -7534,6 +7534,19 @@ return QualType(); } + // OpenCL V1.1 6.2.6.p1: + // If the operands are of more than one vector type, then an error shall + // occur. Implicit conversions between vector types are not permitted, per + // section 6.2.1. + if (getLangOpts().OpenCL && + RHSVecType && isa(RHSVecType) && + LHSVecType && isa(LHSVecType)) { +assert(!Context.hasSameType(LHSType, RHSType)); +Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType + << RHSType; +return QualType(); + } + // Otherwise, use the generic diagnostic. Diag(Loc, diag::err_typecheck_vector_not_convertable) << LHSType << RHSType Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7445,6 +7445,8 @@ "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_opencl_implicit_vector_conversion : Error< + "implicit conversions between vector types (%0 and %1) are not permitted">; } // end of sema category let CategoryName = "OpenMP Issue" in { Index: test/SemaOpenCL/cond.cl === --- test/SemaOpenCL/cond.cl +++ test/SemaOpenCL/cond.cl @@ -84,7 +84,7 @@ float2 ntest04(int2 C, int2 X, float2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values)) are not permitted}} } float2 ntest05(int2 C, int2 X, float Y) @@ -115,7 +115,7 @@ char3 ntest10(char C, char3 X, char2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values)) are not permitted}} } char3 ntest11(char2 C, char3 X, char Y) Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -7534,6 +7534,19 @@ return QualType(); } + // OpenCL V1.1 6.2.6.p1: + // If the operands are of more than one vector type, then an error shall + // occur. Implicit conversions between vector types are not permitted, per + // section 6.2.1. + if (getLangOpts().OpenCL && + RHSVecType && isa(RHSVecType) && + LHSVecType && isa(LHSVecType)) { +assert(!Context.hasSameType(LHSType, RHSType)); +Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType + << RHSType; +return QualType(); + } + // Otherwise, use the generic diagnostic. Diag(Loc, diag::err_typecheck_vector_not_convertable) << LHSType << RHSType Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -7445,6 +7445,8 @@ "return value cannot
r246393 - [OpenCL] Improve diagnostics detecting implicit vector conversion.
Author: bader Date: Sun Aug 30 13:06:39 2015 New Revision: 246393 URL: http://llvm.org/viewvc/llvm-project?rev=246393&view=rev Log: [OpenCL] Improve diagnostics detecting implicit vector conversion. Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12470 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=246393&r1=246392&r2=246393&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sun Aug 30 13:06:39 2015 @@ -7445,6 +7445,8 @@ 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_opencl_implicit_vector_conversion : Error< + "implicit conversions between vector types (%0 and %1) are not permitted">; } // end of sema category let CategoryName = "OpenMP Issue" in { Modified: cfe/trunk/lib/Sema/SemaExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=246393&r1=246392&r2=246393&view=diff == --- cfe/trunk/lib/Sema/SemaExpr.cpp (original) +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Aug 30 13:06:39 2015 @@ -7534,6 +7534,18 @@ QualType Sema::CheckVectorOperands(ExprR return QualType(); } + // OpenCL V1.1 6.2.6.p1: + // If the operands are of more than one vector type, then an error shall + // occur. Implicit conversions between vector types are not permitted, per + // section 6.2.1. + if (getLangOpts().OpenCL && + RHSVecType && isa(RHSVecType) && + LHSVecType && isa(LHSVecType)) { +Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType + << RHSType; +return QualType(); + } + // Otherwise, use the generic diagnostic. Diag(Loc, diag::err_typecheck_vector_not_convertable) << LHSType << RHSType Modified: cfe/trunk/test/SemaOpenCL/cond.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/cond.cl?rev=246393&r1=246392&r2=246393&view=diff == --- cfe/trunk/test/SemaOpenCL/cond.cl (original) +++ cfe/trunk/test/SemaOpenCL/cond.cl Sun Aug 30 13:06:39 2015 @@ -84,7 +84,7 @@ uchar2 ntest03(int2 C, uchar X, uchar Y) float2 ntest04(int2 C, int2 X, float2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('int2' (vector of 2 'int' values) and 'float2' (vector of 2 'float' values)) are not permitted}} } float2 ntest05(int2 C, int2 X, float Y) @@ -115,7 +115,7 @@ int2 ntest09(int2 C, global int *X, glob char3 ntest10(char C, char3 X, char2 Y) { - return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values))}} + return C ? X : Y; // expected-error {{implicit conversions between vector types ('char3' (vector of 3 'char' values) and 'char2' (vector of 2 'char' values)) are not permitted}} } char3 ntest11(char2 C, char3 X, char Y) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12378: [OpenCL] Improve diagnostics detecting implicit vector conversion.
bader closed this revision. bader added a comment. Thanks! Committed at rev. 246393. http://reviews.llvm.org/D12378 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D14441: [OpenCL] Pipe types support.
bader created this revision. bader added reviewers: pekka.jaaskelainen, gbenyei. bader added a subscriber: cfe-commits. Initial support for OpenCL 2.0 feature: pipe types. http://reviews.llvm.org/D14441 Files: include/clang/AST/ASTContext.h include/clang/AST/DataRecursiveASTVisitor.h include/clang/AST/RecursiveASTVisitor.h include/clang/AST/Type.h include/clang/AST/TypeLoc.h include/clang/AST/TypeNodes.def include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/Specifiers.h include/clang/Basic/TokenKinds.def include/clang/Sema/DeclSpec.h include/clang/Sema/Sema.h include/clang/Serialization/ASTBitCodes.h lib/AST/ASTContext.cpp lib/AST/ASTImporter.cpp lib/AST/ItaniumMangle.cpp lib/AST/MicrosoftMangle.cpp lib/AST/Type.cpp lib/AST/TypePrinter.cpp lib/CodeGen/CGDebugInfo.cpp lib/CodeGen/CGDebugInfo.h lib/CodeGen/CodeGenFunction.cpp lib/CodeGen/CodeGenTypes.cpp lib/CodeGen/ItaniumCXXABI.cpp lib/Parse/ParseDecl.cpp lib/Sema/DeclSpec.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaTemplate.cpp lib/Sema/SemaTemplateDeduction.cpp lib/Sema/SemaTemplateVariadic.cpp lib/Sema/SemaType.cpp lib/Sema/TreeTransform.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp test/CodeGenOpenCL/pipe_types.cl test/PCH/ocl_types.cl test/PCH/ocl_types.h tools/libclang/CIndex.cpp Index: lib/Serialization/ASTWriter.cpp === --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -447,6 +447,12 @@ Code = TYPE_ATOMIC; } +void +ASTTypeWriter::VisitPipeType(const PipeType *T) { + Writer.AddTypeRef(T->getElementType(), Record); + Code = TYPE_PIPE; +} + namespace { class TypeLocWriter : public TypeLocVisitor { @@ -672,6 +678,9 @@ Writer.AddSourceLocation(TL.getKWLoc(), Record); Writer.AddSourceLocation(TL.getLParenLoc(), Record); Writer.AddSourceLocation(TL.getRParenLoc(), Record); +} +void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) { + Writer.AddSourceLocation(TL.getKWLoc(), Record); } void ASTWriter::WriteTypeAbbrevs() { Index: lib/Serialization/ASTReader.cpp === --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -5631,6 +5631,17 @@ QualType ValueType = readType(*Loc.F, Record, Idx); return Context.getAtomicType(ValueType); } + + case TYPE_PIPE: { +if (Record.size() != 1) { + Error("Incorrect encoding of pipe type"); + return QualType(); +} + +// Reading the pipe element type. +QualType ElementType = readType(*Loc.F, Record, Idx); +return Context.getPipeType(ElementType); + } } llvm_unreachable("Invalid TypeCode!"); } @@ -5901,6 +5912,9 @@ TL.setKWLoc(ReadSourceLocation(Record, Idx)); TL.setLParenLoc(ReadSourceLocation(Record, Idx)); TL.setRParenLoc(ReadSourceLocation(Record, Idx)); +} +void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) { + TL.setKWLoc(ReadSourceLocation(Record, Idx)); } TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F, Index: lib/Parse/ParseDecl.cpp === --- lib/Parse/ParseDecl.cpp +++ lib/Parse/ParseDecl.cpp @@ -3321,6 +3321,15 @@ case tok::kw___bool: isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy); break; +case tok::kw_pipe: + if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200)) { +// OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should +// support the "pipe" word as identifier. +Tok.getIdentifierInfo()->revertTokenIDToIdentifier(); +goto DoneWithDeclSpec; + } + isInvalid = DS.SetTypePipe(true, Loc, PrevSpec, DiagID, Policy); + break; case tok::kw___unknown_anytype: isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc, PrevSpec, DiagID, Policy); @@ -4396,6 +4405,9 @@ switch (Tok.getKind()) { default: return false; + case tok::kw_pipe: +return getLangOpts().OpenCL && (getLangOpts().OpenCLVersion >= 200); + case tok::identifier: // foo::bar // Unfortunate hack to support "Class.factoryMethod" notation. if (getLangOpts().ObjC1 && NextToken().is(tok::period)) @@ -4841,6 +4853,9 @@ if (Kind == tok::star || Kind == tok::caret) return true; + if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200)) +return true; + if (!Lang.CPlusPlus) return false; @@ -4935,6 +4950,16 @@ } tok::TokenKind Kind = Tok.getKind(); + + if ( D.getDeclSpec().isTypeSpecPipe() ) { +DeclSpec &DS = D.getMutableDeclSpec(); + + D.AddTypeInfo(DeclaratorChunk::getPipe(DS.getTypeQualifiers(), + DS.getPipeLoc()), + DS.getAttributes(), + SourceLocation());
Re: [PATCH] D23086: [OpenCL] Generate concrete struct type for ndrange_t
bader added inline comments. Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:12 @@ -11,3 +11,3 @@ unsigned flags = 0; - // CHECK: %ndrange = alloca %opencl.ndrange_t* + // CHECK: %ndrange = alloca %ndrange_t ndrange_t ndrange; Could you also add a regression test to validate that ndrange_t is defined in LLVM as struct type, please? Repository: rL LLVM https://reviews.llvm.org/D23086 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D23120: [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
bader created this revision. bader added reviewers: Anastasia, yaxunl. bader added a subscriber: cfe-commits. In order to re-define OpenCL built-in functions 'to_{private,local,global}' in OpenCL run-time library LLVM names must be different from the clang built-in function names. https://reviews.llvm.org/D23120 Files: lib/CodeGen/CGBuiltin.cpp test/CodeGenOpenCL/to_addr_builtin.cl Index: test/CodeGenOpenCL/to_addr_builtin.cl === --- test/CodeGenOpenCL/to_addr_builtin.cl +++ test/CodeGenOpenCL/to_addr_builtin.cl @@ -14,74 +14,74 @@ generic int *gen; //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(gen); //CHECK: %[[ARG:.*]] = addrspacecast %[[A]]* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[
r277743 - [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
Author: bader Date: Thu Aug 4 13:06:27 2016 New Revision: 277743 URL: http://llvm.org/viewvc/llvm-project?rev=277743&view=rev Log: [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins. Summary: In order to re-define OpenCL built-in functions 'to_{private,local,global}' in OpenCL run-time library LLVM names must be different from the clang built-in function names. Reviewers: yaxunl, Anastasia Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D23120 Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=277743&r1=277742&r2=277743&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Aug 4 13:06:27 2016 @@ -2209,8 +2209,9 @@ RValue CodeGenFunction::EmitBuiltinExpr( NewArg = Builder.CreateAddrSpaceCast(Arg0, NewArgT); else NewArg = Builder.CreateBitOrPointerCast(Arg0, NewArgT); -auto NewCall = Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, - E->getDirectCallee()->getName()), {NewArg}); +auto NewName = std::string("__") + E->getDirectCallee()->getName().str(); +auto NewCall = +Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, NewName), {NewArg}); return RValue::get(Builder.CreateBitOrPointerCast(NewCall, ConvertType(E->getType(; } Modified: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl?rev=277743&r1=277742&r2=277743&view=diff == --- cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl (original) +++ cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl Thu Aug 4 13:06:27 2016 @@ -14,74 +14,74 @@ void test(void) { generic int *gen; //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to
Re: [PATCH] D23120: [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins.
This revision was automatically updated to reflect the committed changes. Closed by commit rL277743: [OpenCL] Added underscores to the names of 'to_addr' OpenCL built-ins. (authored by bader). Changed prior to commit: https://reviews.llvm.org/D23120?vs=66653&id=66832#toc Repository: rL LLVM https://reviews.llvm.org/D23120 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl Index: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl === --- cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl +++ cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl @@ -14,74 +14,74 @@ generic int *gen; //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @__to_global(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(1)* %[[RET]] to i32 addrspace(1)* glob = to_global(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @to_local(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8 addrspace(3)* @__to_local(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8 addrspace(3)* %[[RET]] to i32 addrspace(3)* loc = to_local(gen); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(1)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(glob); //CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace(3)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(loc); //CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(priv); //CHECK: %[[ARG:.*]] = bitcast i32 addrspace(4)* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8* @to_private(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[RET:.*]] = call i8* @__to_private(i8 addrspace(4)* %[[ARG]]) //CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32* priv = to_private(gen); //CHECK: %[[ARG:.*]] = addrspacecast %[[A]]* %{{.*}} to i8 addrspace(4)* - //CHECK: %[[RET:.*]] = call i8 addrspace(1)* @to_global(i8 addrspace(4)* %[[ARG]]) + //CHECK: %[[
Re: [PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator
bader added a subscriber: bader. Comment at: test/SemaOpenCL/ternary-implicit-casts.cl:10-11 @@ +9,4 @@ +kernel void implicit_cast_generic(global int* gint, local int* lint, int cond) { + // will compile, ptr is generic and can accept global and local + int* ptr = cond ? gint : lint; // expected-warning {{pointer type mismatch ('__global int *' and '__local int *')}} +} Note that test doesn't specify OpenCL version. By default it's 1.0, so ptr points to private AS and it's illegal to cast pointers from different address spaces in OpenCL v1.x. http://reviews.llvm.org/D16682 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20090: [OPENCL] Fix wrongly vla error for OpenCL array.
bader accepted this revision. bader added a reviewer: bader. bader added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D20090 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20133: [OpenCL] Fix __builtin_astype for vec3 types.
bader accepted this revision. bader added a comment. This revision is now accepted and ready to land. LGTM. Comment at: test/CodeGenOpenCL/as_type.cl:6 @@ +5,3 @@ + +//CHECK: define spir_func <3 x i8> @f1(<4 x i8> %[[x:.*]]) +//CHECK: %[[astype:.*]] = shufflevector <4 x i8> %[[x]], <4 x i8> undef, <3 x i32> Could you also one test case that requires bitcast from vector type to 4-element vector type, please? E.g. short2 <-> char3 or char16 <-> int3. http://reviews.llvm.org/D20133 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.
bader added inline comments. Comment at: include/clang/Basic/OpenCLExtensions.def:64 @@ +63,3 @@ +OPENCLEXT_INTERNAL(cl_khr_initialize_memory, 200, ~0U) +OPENCLEXT_INTERNAL(cl_khr_spir, 200, ~0U) +OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U) Minimum required version should be 120. cl_khr_spir was available in OpenCL 1.2 as well as cl_khr_depth_images and cl_khr_gl_depth_images. https://www.khronos.org/registry/cl/specs/opencl-1.2-extensions.pdf http://reviews.llvm.org/D19484 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.
bader accepted this revision. bader added a comment. LGTM. Thanks! http://reviews.llvm.org/D19484 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17821: [OpenCL] Complete image types support
bader added inline comments. Comment at: include/clang/AST/ASTContext.h:903 @@ +902,3 @@ +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ + CanQualType SingletonId; +#include "clang/AST/OpenCLImageTypes.def" mgrang wrote: > remove extra spacing in front of the \ Sorry for delay... I used clang-format tool to format that code. I expect it to be in agreement with LLVM coding style guide. Did I miss something or it's clang-format bug? http://reviews.llvm.org/D17821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17821: [OpenCL] Complete image types support
bader added a comment. In http://reviews.llvm.org/D17821#393387, @Anastasia wrote: > Regarding, extending this approach for OpenCL pipe types too. I was thinking > we could change current implementation to have ReadPipeType and > WritePipeType. They can both be derived from PipeType that we already have > now (we can make it an abstract class to avoid its instantiation?). > > Similarly to images, since read and write pipes will be mapped to different > Clang types, we won't need any extra semantical checking but just need to add > extra code in CodeGen of pipe type and builtins to accept two separate types > for read only and write only cases. > > Would this make sense? Sure. Do you want me to add it here or it's okay if we fix pipes in a separate patch? Comment at: include/clang/AST/ASTContext.h:903 @@ +902,3 @@ +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ + CanQualType SingletonId; +#include "clang/AST/OpenCLImageTypes.def" Anastasia wrote: > bader wrote: > > mgrang wrote: > > > remove extra spacing in front of the \ > > Sorry for delay... > > I used clang-format tool to format that code. I expect it to be in > > agreement with LLVM coding style guide. > > Did I miss something or it's clang-format bug? > I would have thought clang-format should be fine. > > But it does look a bit weird here. There are other places in this patch that > have the same formatting. > > I can't find anything relevant in coding style description: > http://llvm.org/docs/CodingStandards.html#source-code-width > > I'll remove extra spacing. http://reviews.llvm.org/D17821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17821: [OpenCL] Complete image types support
bader added a comment. In http://reviews.llvm.org/D17821#394620, @Anastasia wrote: > Yes, I think it's better to go in a separate commit, not to complicate this > one too much. Also since there are not many comment here, I think we should > try to commit it ASAP otherwise rebasing would be an issue. I can commit it tomorrow if there are no other comments. http://reviews.llvm.org/D17821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r265783 - [OpenCL] Complete image types support.
Author: bader Date: Fri Apr 8 08:40:33 2016 New Revision: 265783 URL: http://llvm.org/viewvc/llvm-project?rev=265783&view=rev Log: [OpenCL] Complete image types support. I. Current implementation of images is not conformant to spec in the following points: 1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine: void write_image(write_only image2d_t img); kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code which is disallowed according to s6.13.14. 2. It discards access qualifier on generated code, which leads to generated code for the above example: call void @write_image(%opencl.image2d_t* %img); In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images. Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently. 3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names. 4. Default access qualifier read_only is to be added if not provided explicitly. II. This patch corrects the above points as follows: 1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type. 2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers). 3. Improves testing of images in Clang. Author: Anastasia Stulova Reviewers: bader, mgrang. Subscribers: pxli168, pekka.jaaskelainen, yaxunl. Differential Revision: http://reviews.llvm.org/D17821 Added: cfe/trunk/include/clang/AST/OpenCLImageTypes.def cfe/trunk/test/CodeGenOpenCL/images.cl cfe/trunk/test/SemaOpenCL/images.cl Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/CodeGenOpenCL/opencl_types.cl cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl cfe/trunk/test/SemaOpenCL/invalid-image.cl cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=265783&r1=265782&r2=265783&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Fri Apr 8 08:40:33 2016 @@ -902,11 +902,9 @@ public: CanQualType PseudoObjectTy, ARCUnbridgedCastTy; CanQualType ObjCBuiltinIdTy, ObjCBuiltinClassTy, ObjCBuiltinSelTy; CanQualType ObjCBuiltinBoolTy; - CanQualType OCLImage1dTy, OCLImage1dArrayTy, OCLImage1dBufferTy; - CanQualType OCLImage2dTy, OCLImage2dArrayTy, OCLImage2dDepthTy; - CanQualType OCLImage2dArrayDepthTy, OCLImage2dMSAATy, OCLImage2dArrayMSAATy; - CanQualType OCLImage2dMSAADepthTy, OCLImage2dArrayMSAADepthTy; - CanQualType OCLImage3dTy; +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ + CanQualType SingletonId; +#inclu
Re: [PATCH] D17821: [OpenCL] Complete image types support
bader added a comment. In http://reviews.llvm.org/D17821#394708, @bader wrote: > In http://reviews.llvm.org/D17821#394620, @Anastasia wrote: > > > Yes, I think it's better to go in a separate commit, not to complicate this > > one too much. Also since there are not many comment here, I think we should > > try to commit it ASAP otherwise rebasing would be an issue. > > > I can commit it tomorrow if there are no other comments. Committed @265783 Repository: rL LLVM http://reviews.llvm.org/D17821 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D17821: [OpenCL] Complete image types support
This revision was automatically updated to reflect the committed changes. Closed by commit rL265783: [OpenCL] Complete image types support. (authored by bader). Changed prior to commit: http://reviews.llvm.org/D17821?vs=51303&id=53021#toc Repository: rL LLVM http://reviews.llvm.org/D17821 Files: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/BuiltinTypes.def cfe/trunk/include/clang/AST/OpenCLImageTypes.def cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/Sema.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/CodeGenOpenCL/images.cl cfe/trunk/test/CodeGenOpenCL/opencl_types.cl cfe/trunk/test/SemaOpenCL/images.cl cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl cfe/trunk/test/SemaOpenCL/invalid-image.cl cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl cfe/trunk/tools/libclang/CIndex.cpp Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp === --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp @@ -2536,18 +2536,9 @@ case BuiltinType::UInt128: return true; -case BuiltinType::OCLImage1d: -case BuiltinType::OCLImage1dArray: -case BuiltinType::OCLImage1dBuffer: -case BuiltinType::OCLImage2d: -case BuiltinType::OCLImage2dArray: -case BuiltinType::OCLImage2dDepth: -case BuiltinType::OCLImage2dArrayDepth: -case BuiltinType::OCLImage2dMSAA: -case BuiltinType::OCLImage2dArrayMSAA: -case BuiltinType::OCLImage2dMSAADepth: -case BuiltinType::OCLImage2dArrayMSAADepth: -case BuiltinType::OCLImage3d: +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ +case BuiltinType::Id: +#include "clang/AST/OpenCLImageTypes.def" case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: case BuiltinType::OCLClkEvent: Index: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp === --- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp +++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp @@ -464,18 +464,9 @@ ResultType = llvm::IntegerType::get(getLLVMContext(), 128); break; -case BuiltinType::OCLImage1d: -case BuiltinType::OCLImage1dArray: -case BuiltinType::OCLImage1dBuffer: -case BuiltinType::OCLImage2d: -case BuiltinType::OCLImage2dArray: -case BuiltinType::OCLImage2dDepth: -case BuiltinType::OCLImage2dArrayDepth: -case BuiltinType::OCLImage2dMSAA: -case BuiltinType::OCLImage2dArrayMSAA: -case BuiltinType::OCLImage2dMSAADepth: -case BuiltinType::OCLImage2dArrayMSAADepth: -case BuiltinType::OCLImage3d: +#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ +case BuiltinType::Id: +#include "clang/AST/OpenCLImageTypes.def" case BuiltinType::OCLSampler: case BuiltinType::OCLEvent: case BuiltinType::OCLClkEvent: Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp === --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp @@ -463,39 +463,11 @@ return SelTy; } - case BuiltinType::OCLImage1d: -return getOrCreateStructPtrType("opencl_image1d_t", OCLImage1dDITy); - case BuiltinType::OCLImage1dArray: -return getOrCreateStructPtrType("opencl_image1d_array_t", -OCLImage1dArrayDITy); - case BuiltinType::OCLImage1dBuffer: -return getOrCreateStructPtrType("opencl_image1d_buffer_t", -OCLImage1dBufferDITy); - case BuiltinType::OCLImage2d: -return getOrCreateStructPtrType("opencl_image2d_t", OCLImage2dDITy); - case BuiltinType::OCLImage2dArray: -return getOrCreateStructPtrType("opencl_image2d_array_t", -OCLImage2dArrayDITy); - case BuiltinType::OCLImage2dDepth: -return getOrCreateStructPtrType("ope
r266180 - [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.
Author: bader Date: Wed Apr 13 03:33:41 2016 New Revision: 266180 URL: http://llvm.org/viewvc/llvm-project?rev=266180&view=rev Log: [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library. Putting OpenCLImageTypes.def to clangAST library violates layering requirement: "It's not OK for a Basic/ header to include an AST/ header". This fixes the modules build. Differential revision: http://reviews.llvm.org/D18954 Reviewers: Richard Smith, Vassil Vassilev. Added: cfe/trunk/include/clang/Basic/OpenCLImageTypes.def Removed: cfe/trunk/include/clang/AST/OpenCLImageTypes.def Modified: cfe/trunk/include/clang/AST/ASTContext.h cfe/trunk/include/clang/AST/Type.h cfe/trunk/include/clang/Basic/Specifiers.h cfe/trunk/include/clang/Basic/TokenKinds.def cfe/trunk/include/clang/Sema/DeclSpec.h cfe/trunk/include/clang/Serialization/ASTBitCodes.h cfe/trunk/lib/AST/ASTContext.cpp cfe/trunk/lib/AST/ASTImporter.cpp cfe/trunk/lib/AST/ExprConstant.cpp cfe/trunk/lib/AST/ItaniumMangle.cpp cfe/trunk/lib/AST/MicrosoftMangle.cpp cfe/trunk/lib/AST/NSAPI.cpp cfe/trunk/lib/AST/Type.cpp cfe/trunk/lib/AST/TypeLoc.cpp cfe/trunk/lib/Analysis/PrintfFormatString.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.h cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp cfe/trunk/lib/CodeGen/CodeGenTypes.cpp cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp cfe/trunk/lib/Index/USRGeneration.cpp cfe/trunk/lib/Parse/ParseDecl.cpp cfe/trunk/lib/Parse/ParseExpr.cpp cfe/trunk/lib/Parse/ParseTentative.cpp cfe/trunk/lib/Sema/DeclSpec.cpp cfe/trunk/lib/Sema/SemaExpr.cpp cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp cfe/trunk/lib/Sema/SemaType.cpp cfe/trunk/lib/Serialization/ASTCommon.cpp cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/tools/libclang/CIndex.cpp Modified: cfe/trunk/include/clang/AST/ASTContext.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=266180&r1=266179&r2=266180&view=diff == --- cfe/trunk/include/clang/AST/ASTContext.h (original) +++ cfe/trunk/include/clang/AST/ASTContext.h Wed Apr 13 03:33:41 2016 @@ -904,7 +904,7 @@ public: CanQualType ObjCBuiltinBoolTy; #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \ CanQualType SingletonId; -#include "clang/AST/OpenCLImageTypes.def" +#include "clang/Basic/OpenCLImageTypes.def" CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy; CanQualType OCLQueueTy, OCLNDRangeTy, OCLReserveIDTy; CanQualType OMPArraySectionTy; Removed: cfe/trunk/include/clang/AST/OpenCLImageTypes.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenCLImageTypes.def?rev=266179&view=auto == --- cfe/trunk/include/clang/AST/OpenCLImageTypes.def (original) +++ cfe/trunk/include/clang/AST/OpenCLImageTypes.def (removed) @@ -1,82 +0,0 @@ -//===-- OpenCLImageTypes.def - Metadata about BuiltinTypes --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===--===// -// This file extends builtin types database with OpenCL image singleton types. -// Custom code should define one of those two macros: -//GENERIC_IMAGE_TYPE(Type, Id) - a generic image with its Id without an -// access type -//IMAGE_TYPE(Type, Id, SingletonId, AccessType, CGSuffix) - an image type -// with given ID, singleton ID access type and a codegen suffix - -#ifdef GENERIC_IMAGE_TYPE - -#define IMAGE_READ_TYPE(Type, Id) GENERIC_IMAGE_TYPE(Type, Id) -#define IMAGE_WRITE_TYPE(Type, Id) -#define IMAGE_READ_WRITE_TYPE(Type, Id) - -#else - -#ifndef IMAGE_READ_TYPE -#define IMAGE_READ_TYPE(Type, Id) \ - IMAGE_TYPE(Type, Id##RO, Id##ROTy, read_only, ro) -#endif -#ifndef IMAGE_WRITE_TYPE -#define IMAGE_WRITE_TYPE(Type, Id) \ - IMAGE_TYPE(Type, Id##WO, Id##WOTy, write_only, wo) -#endif -#ifndef IMAGE_READ_WRITE_TYPE -#define IMAGE_READ_WRITE_TYPE(Type, Id) \ - IMAGE_TYPE(Type, Id##RW, Id##RWTy, read_write, rw) -#endif - -#endif - -IMAGE_READ_TYPE(image1d, OCLImage1d) -IMAGE_READ_TYPE(image1d_array, OCLImage1dArray) -IMAGE_READ_TYPE(image1d_buffer, OCLImage1dBuffer) -IMAGE_READ_TYPE(image2d, OCLImage2d) -IMAGE_READ_TYPE(image2d_array, OCLImage2dArray) -IMAGE_READ_TYPE(image2d_depth, OCLImage2dDepth) -IMAGE_READ_TYPE(image2d_array_depth, OCLImage2dArrayDepth) -IMAGE_READ_TYPE(image2d_msaa, OCLImage2dMSAA) -IMAGE_READ_TYPE(image2d_array_msaa, OCLImage2dArrayMSAA) -IMAGE_READ_TYPE(image2d_msaa_depth, OCLImage2dMSAADepth) -IMAGE_READ_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth) -IMAGE_READ_TYPE(image3d, O
r266187 - [modules] Add OpenCLImageTypes.def to module map to fix the modules build.
Author: bader Date: Wed Apr 13 04:54:47 2016 New Revision: 266187 URL: http://llvm.org/viewvc/llvm-project?rev=266187&view=rev Log: [modules] Add OpenCLImageTypes.def to module map to fix the modules build. Modified: cfe/trunk/include/clang/module.modulemap Modified: cfe/trunk/include/clang/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=266187&r1=266186&r2=266187&view=diff == --- cfe/trunk/include/clang/module.modulemap (original) +++ cfe/trunk/include/clang/module.modulemap Wed Apr 13 04:54:47 2016 @@ -41,6 +41,7 @@ module Clang_Basic { textual header "Basic/DiagnosticOptions.def" textual header "Basic/LangOptions.def" textual header "Basic/OpenCLExtensions.def" + textual header "Basic/OpenCLImageTypes.def" textual header "Basic/OpenMPKinds.def" textual header "Basic/OperatorKinds.def" textual header "Basic/Sanitizers.def" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D19071: [OpenCL] Add predefined macros.
bader added a comment. LGTM http://reviews.llvm.org/D19071 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.
bader added inline comments. Comment at: lib/Headers/opencl.h:14892-14898 @@ +14891,9 @@ + +/** +* Sampler-less Image Access +*/ + +float4 __const_func __attribute__((overloadable)) read_imagef(read_only image1d_t image, int coord); +int4 __const_func __attribute__((overloadable)) read_imagei(read_only image1d_t image, int coord); +uint4 __const_func __attribute__((overloadable)) read_imageui(read_only image1d_t image, int coord); + OpenCL 2.0 allows sampler-less reading from an image with 'read_write' access qualifiers and write_image to images with 'read_write' access qualifiers. Since 265783 clang differentiate image types with different access qualifiers, so now we have explicitly declare new built-in functions. Could you add these declaration, please? http://reviews.llvm.org/D18369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.
bader added inline comments. Comment at: lib/Headers/opencl.h:15372-15373 @@ +15371,4 @@ + */ +int __const_func __attribute__((overloadable)) get_image_width(image1d_t image); +int __const_func __attribute__((overloadable)) get_image_width(image1d_buffer_t image); +int __const_func __attribute__((overloadable)) get_image_width(image2d_t image); Please, add image access qualifier to Built-in Image Query Functions declarations. It's required by OpenCL 2.0 specification. OpenCL 1.x spec. defines built-in functions w/o access qualifiers (i.e. 'read_only' is applied). http://reviews.llvm.org/D18369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL header file.
bader added a comment. To clarify my last comment: I don't think we should define Image Query built-in functions only for 'read_only' access qualifier in OpenCL 1.x. It's just bug in OpenCL 1.x specifications. I think the intention was to provide these built-in functions for both 'read_only' and 'write_only' images. OpenCL 2.0 also provides 'read_write' flavors. http://reviews.llvm.org/D18369 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits