diff options
author | Guy Benyei <guy.benyei@intel.com> | 2013-01-20 12:31:11 +0000 |
---|---|---|
committer | Guy Benyei <guy.benyei@intel.com> | 2013-01-20 12:31:11 +0000 |
commit | 1b4fb3e08b28f12d508aec0bbdcb6f41cfb0ee38 (patch) | |
tree | 5cf8e9985a92136f34520167b6a007eb00fe1468 /clang/lib | |
parent | 359e09d4f50f381dc85d64bc7ea4e06013d09779 (diff) | |
download | llvm-1b4fb3e08b28f12d508aec0bbdcb6f41cfb0ee38.zip llvm-1b4fb3e08b28f12d508aec0bbdcb6f41cfb0ee38.tar.gz llvm-1b4fb3e08b28f12d508aec0bbdcb6f41cfb0ee38.tar.bz2 |
Implement OpenCL event_t as Clang builtin type, including event_t related OpenCL restrictions (OpenCL 1.2 spec 6.9)
llvm-svn: 172973
Diffstat (limited to 'clang/lib')
30 files changed, 146 insertions, 8 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index ace9dc0..b18fa67 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -893,6 +893,8 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) { InitBuiltinType(OCLImage2dTy, BuiltinType::OCLImage2d); InitBuiltinType(OCLImage2dArrayTy, BuiltinType::OCLImage2dArray); InitBuiltinType(OCLImage3dTy, BuiltinType::OCLImage3d); + + InitBuiltinType(OCLEventTy, BuiltinType::OCLEvent); } // Builtin type for __objc_yes and __objc_no @@ -1434,6 +1436,7 @@ ASTContext::getTypeInfoImpl(const Type *T) const { Width = Target->getPointerWidth(0); Align = Target->getPointerAlign(0); break; + case BuiltinType::OCLEvent: case BuiltinType::OCLImage1d: case BuiltinType::OCLImage1dArray: case BuiltinType::OCLImage1dBuffer: @@ -4895,6 +4898,7 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C, case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: case BuiltinType::OCLImage3d: + case BuiltinType::OCLEvent: case BuiltinType::Dependent: #define BUILTIN_TYPE(KIND, ID) #define PLACEHOLDER_TYPE(KIND, ID) \ diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 718002f..e3ff29d 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1400,6 +1400,7 @@ void CastExpr::CheckCastConsistency() const { case CK_ARCConsumeObject: case CK_ARCReclaimReturnedObject: case CK_ARCExtendBlockObject: + case CK_ZeroToOCLEvent: assert(!getType()->isBooleanType() && "unheralded conversion to bool"); goto CheckNoBasePath; @@ -1531,6 +1532,8 @@ const char *CastExpr::getCastKindName() const { return "CopyAndAutoreleaseBlockObject"; case CK_BuiltinFnToFnPtr: return "BuiltinFnToFnPtr"; + case CK_ZeroToOCLEvent: + return "ZeroToOCLEvent"; } llvm_unreachable("Unhandled cast kind!"); diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 9965e12..64fd40b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5372,6 +5372,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) { case CK_IntegralComplexCast: case CK_IntegralComplexToFloatingComplex: case CK_BuiltinFnToFnPtr: + case CK_ZeroToOCLEvent: llvm_unreachable("invalid cast kind for integral value"); case CK_BitCast: @@ -5859,6 +5860,7 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) { case CK_ARCExtendBlockObject: case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: + case CK_ZeroToOCLEvent: llvm_unreachable("invalid cast kind for complex value"); case CK_LValueToRValue: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 65e630e..926384d 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -1886,6 +1886,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { case BuiltinType::OCLImage2d: Out << "11ocl_image2d"; break; case BuiltinType::OCLImage2dArray: Out << "16ocl_image2darray"; break; case BuiltinType::OCLImage3d: Out << "11ocl_image3d"; break; + case BuiltinType::OCLEvent: Out << "9ocl_event"; break; } } diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index bd0125d..0b77ac8 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -1060,6 +1060,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, case BuiltinType::OCLImage2d: Out << "PAUocl_image2d@@"; break; case BuiltinType::OCLImage2dArray: Out << "PAUocl_image2darray@@"; break; case BuiltinType::OCLImage3d: Out << "PAUocl_image3d@@"; break; + case BuiltinType::OCLEvent: Out << "PAUocl_event@@"; break; case BuiltinType::NullPtr: Out << "$$T"; break; diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp index 35cc7d0..c8cf920 100644 --- a/clang/lib/AST/NSAPI.cpp +++ b/clang/lib/AST/NSAPI.cpp @@ -351,6 +351,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const { case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: case BuiltinType::OCLImage3d: + case BuiltinType::OCLEvent: case BuiltinType::BoundMember: case BuiltinType::Dependent: case BuiltinType::Overload: diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 45ec4ed..524d005 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1518,6 +1518,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const { case OCLImage2d: return "image2d_t"; case OCLImage2dArray: return "image2d_array_t"; case OCLImage3d: return "image3d_t"; + case OCLEvent: return "event_t"; } llvm_unreachable("Invalid builtin type."); diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp index a5baf70..3efa148 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -268,6 +268,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const { case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: case BuiltinType::OCLImage3d: + case BuiltinType::OCLEvent: case BuiltinType::BuiltinFn: return TST_unspecified; } diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 37df4b3..264d075 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -426,6 +426,9 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { case BuiltinType::OCLImage3d: return getOrCreateStructPtrType("opencl_image3d_t", OCLImage3dDITy); + case BuiltinType::OCLEvent: + return getOrCreateStructPtrType("opencl_event_t", + OCLEventDITy); case BuiltinType::UChar: case BuiltinType::Char_U: Encoding = llvm::dwarf::DW_ATE_unsigned_char; break; diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 3ecf2ed..fbbee0b 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -55,6 +55,7 @@ class CGDebugInfo { llvm::DIType OCLImage1dDITy, OCLImage1dArrayDITy, OCLImage1dBufferDITy; llvm::DIType OCLImage2dDITy, OCLImage2dArrayDITy; llvm::DIType OCLImage3dDITy; + llvm::DIType OCLEventDITy; /// TypeCache - Cache of previously constructed Types. llvm::DenseMap<void *, llvm::WeakVH> TypeCache; diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index cdbd6e7..9bef08b 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -2639,6 +2639,8 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { ConvertType(ToType)); return MakeAddrLValue(V, E->getType()); } + case CK_ZeroToOCLEvent: + llvm_unreachable("NULL to OpenCL event lvalue cast is not valid"); } llvm_unreachable("Unhandled lvalue cast kind?"); diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index b037113..a35ef0c 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -648,6 +648,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { case CK_ARCExtendBlockObject: case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: + case CK_ZeroToOCLEvent: llvm_unreachable("cast kind invalid for aggregate types"); } } diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index 1270297..0a53d4f 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -428,6 +428,7 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastExpr::CastKind CK, Expr *Op, case CK_ARCExtendBlockObject: case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: + case CK_ZeroToOCLEvent: llvm_unreachable("invalid cast kind for complex value"); case CK_FloatingRealToComplex: diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp index 2c107cb..80ab2ed 100644 --- a/clang/lib/CodeGen/CGExprConstant.cpp +++ b/clang/lib/CodeGen/CGExprConstant.cpp @@ -747,6 +747,7 @@ public: case CK_FloatingToIntegral: case CK_FloatingToBoolean: case CK_FloatingCast: + case CK_ZeroToOCLEvent: return 0; } llvm_unreachable("Invalid CastKind"); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 5715913..ed927e2 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1383,6 +1383,11 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { return EmitComplexToScalarConversion(V, E->getType(), DestTy); } + case CK_ZeroToOCLEvent: { + assert(DestTy->isEventT() && "CK_ZeroToOCLEvent cast on non event type"); + return llvm::Constant::getNullValue(ConvertType(DestTy)); + } + } llvm_unreachable("unknown scalar cast"); diff --git a/clang/lib/CodeGen/CGOpenCLRuntime.cpp b/clang/lib/CodeGen/CGOpenCLRuntime.cpp index bb239c6..215d096 100644 --- a/clang/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenCLRuntime.cpp @@ -55,5 +55,8 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { case BuiltinType::OCLImage3d: return llvm::PointerType::get(llvm::StructType::create( CGM.getLLVMContext(), "opencl.image3d_t"), 0); + case BuiltinType::OCLEvent: + return llvm::PointerType::get(llvm::StructType::create( + CGM.getLLVMContext(), "opencl.event_t"), 0); } } diff --git a/clang/lib/CodeGen/CGRTTI.cpp b/clang/lib/CodeGen/CGRTTI.cpp index 41b73e23..3d65892 100644 --- a/clang/lib/CodeGen/CGRTTI.cpp +++ b/clang/lib/CodeGen/CGRTTI.cpp @@ -197,6 +197,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) { case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: case BuiltinType::OCLImage3d: + case BuiltinType::OCLEvent: return true; case BuiltinType::Dependent: diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 2c5f2d8..c186ebff 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -374,6 +374,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { case BuiltinType::OCLImage2d: case BuiltinType::OCLImage2dArray: case BuiltinType::OCLImage3d: + case BuiltinType::OCLEvent: ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty); break; diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index 312c86f..215aacd 100644 --- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -1075,6 +1075,7 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, case CK_NonAtomicToAtomic: case CK_CopyAndAutoreleaseBlockObject: case CK_BuiltinFnToFnPtr: + case CK_ZeroToOCLEvent: return false; } } diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index f9c68c7..cfe5d1b 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2783,6 +2783,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, isInvalid = DS.SetTypeSpecType(DeclSpec::TST_image3d_t, Loc, PrevSpec, DiagID); break; + case tok::kw_event_t: + isInvalid = DS.SetTypeSpecType(DeclSpec::TST_event_t, Loc, + PrevSpec, DiagID); + break; case tok::kw___unknown_anytype: isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc, PrevSpec, DiagID); @@ -3633,6 +3637,7 @@ bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const { case tok::kw_image2d_t: case tok::kw_image2d_array_t: case tok::kw_image3d_t: + case tok::kw_event_t: // struct-or-union-specifier (C99) or class-specifier (C++) case tok::kw_class: @@ -3713,6 +3718,7 @@ bool Parser::isTypeSpecifierQualifier() { case tok::kw_image2d_t: case tok::kw_image2d_array_t: case tok::kw_image3d_t: + case tok::kw_event_t: // struct-or-union-specifier (C99) or class-specifier (C++) case tok::kw_class: @@ -3865,6 +3871,7 @@ bool Parser::isDeclarationSpecifier(bool DisambiguatingWithExpression) { case tok::kw_image2d_t: case tok::kw_image2d_array_t: case tok::kw_image3d_t: + case tok::kw_event_t: // struct-or-union-specifier (C99) or class-specifier (C++) case tok::kw_class: diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index d6d38c7..9c788a1 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -1024,6 +1024,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, case tok::kw_image2d_t: case tok::kw_image2d_array_t: case tok::kw_image3d_t: { + case tok::kw_event_t: if (!getLangOpts().CPlusPlus) { Diag(Tok, diag::err_expected_expression); return ExprError(); diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 78d73bc..1116daa 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -843,6 +843,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw_image2d_t: case tok::kw_image2d_array_t: case tok::kw_image3d_t: + case tok::kw_event_t: case tok::kw___unknown_anytype: return TPResult::False(); diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp index 35b07361..6d30b89 100644 --- a/clang/lib/Sema/DeclSpec.cpp +++ b/clang/lib/Sema/DeclSpec.cpp @@ -286,6 +286,7 @@ bool Declarator::isDeclarationOfFunction() const { case TST_image2d_t: case TST_image2d_array_t: case TST_image3d_t: + case TST_event_t: return false; case TST_decltype: @@ -427,6 +428,7 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T) { case DeclSpec::TST_image2d_t: return "image2d_t"; case DeclSpec::TST_image2d_array_t: return "image2d_array_t"; case DeclSpec::TST_image3d_t: return "image3d_t"; + case DeclSpec::TST_event_t: return "event_t"; case DeclSpec::TST_error: return "(error)"; } llvm_unreachable("Unknown typespec!"); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index dbdbc3d..7936efa1 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -4401,6 +4401,22 @@ Sema::ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, SC = SC_OpenCLWorkGroupLocal; SCAsWritten = SC_OpenCLWorkGroupLocal; } + + // OpenCL 1.2 spec, p6.9 r: + // The event type cannot be used to declare a program scope variable. + // The event type cannot be used with the __local, __constant and __global + // address space qualifiers. + if (R->isEventT()) { + if (S->getParent() == 0) { + Diag(D.getLocStart(), diag::err_event_t_global_var); + D.setInvalidType(); + } + + if (R.getAddressSpace()) { + Diag(D.getLocStart(), diag::err_event_t_addr_space_qual); + D.setInvalidType(); + } + } } bool isExplicitSpecialization = false; @@ -6136,12 +6152,26 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, } } - // OpenCL v1.2 s6.8 static is invalid for kernel functions. - if ((getLangOpts().OpenCLVersion >= 120) - && NewFD->hasAttr<OpenCLKernelAttr>() - && (SC == SC_Static)) { - Diag(D.getIdentifierLoc(), diag::err_static_kernel); - D.setInvalidType(); + if (NewFD->hasAttr<OpenCLKernelAttr>()) { + + // OpenCL v1.2 s6.8 static is invalid for kernel functions. + if ((getLangOpts().OpenCLVersion >= 120) + && (SC == SC_Static)) { + Diag(D.getIdentifierLoc(), diag::err_static_kernel); + D.setInvalidType(); + } + + // OpenCL v1.2 s6.8 n: + // Arguments to kernel functions in a program cannot be declared to be of + // type event_t. + for (FunctionDecl::param_iterator PI = NewFD->param_begin(), + PE = NewFD->param_end(); PI != PE; ++PI) { + if ((*PI)->getType()->isEventT()) { + Diag((*PI)->getLocation(), diag::err_event_t_kernel_arg); + D.setInvalidType(); + } + } + } MarkUnusedFileScopedDecl(NewFD); @@ -9776,6 +9806,14 @@ FieldDecl *Sema::HandleField(Scope *S, RecordDecl *Record, } } + // OpenCL 1.2 spec, s6.9 r: + // The event type cannot be used to declare a structure or union field. + if (LangOpts.OpenCL && T->isEventT()) { + Diag(Loc, diag::err_event_t_struct_field); + D.setInvalidType(); + } + + DiagnoseFunctionSpecifiers(D); if (D.getDeclSpec().isThreadSpecified()) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 26bb6ef..e661110 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2424,6 +2424,7 @@ void InitializationSequence::Step::Destroy() { case SK_PassByIndirectRestore: case SK_ProduceObjCObject: case SK_StdInitializerList: + case SK_OCLZeroEvent: break; case SK_ConversionSequence: @@ -2652,6 +2653,13 @@ void InitializationSequence::AddStdInitializerListConstructionStep(QualType T) { Steps.push_back(S); } +void InitializationSequence::AddOCLZeroEventStep(QualType T) { + Step S; + S.Kind = SK_OCLZeroEvent; + S.Type = T; + Steps.push_back(S); +} + void InitializationSequence::RewrapReferenceInitList(QualType T, InitListExpr *Syntactic) { assert(Syntactic->getNumInits() == 1 && @@ -4009,6 +4017,27 @@ static bool tryObjCWritebackConversion(Sema &S, return true; } +// +// OpenCL 1.2 spec, s6.12.10 +// +// The event argument can also be used to associate the +// async_work_group_copy with a previous async copy allowing +// an event to be shared by multiple async copies; otherwise +// event should be zero. +// +static bool TryOCLZeroEventInitialization(Sema &S, + InitializationSequence &Sequence, + QualType DestType, + Expr *Initializer) { + if (!S.getLangOpts().OpenCL || !DestType->isEventT() || + !Initializer->isIntegerConstantExpr(S.getASTContext()) || + (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0)) + return false; + + Sequence.AddOCLZeroEventStep(DestType); + return true; +} + InitializationSequence::InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, @@ -4152,6 +4181,10 @@ InitializationSequence::InitializationSequence(Sema &S, return; } + + if (TryOCLZeroEventInitialization(S, *this, DestType, Initializer)) + return; + // Handle initialization in C AddCAssignmentStep(DestType); MaybeProduceObjCObject(S, *this, Entity); @@ -4940,7 +4973,8 @@ InitializationSequence::Perform(Sema &S, case SK_PassByIndirectCopyRestore: case SK_PassByIndirectRestore: case SK_ProduceObjCObject: - case SK_StdInitializerList: { + case SK_StdInitializerList: + case SK_OCLZeroEvent: { assert(Args.size() == 1); CurInit = Args[0]; if (!CurInit.get()) return ExprError(); @@ -5453,6 +5487,15 @@ InitializationSequence::Perform(Sema &S, CurInit = S.Owned(Semantic); break; } + case SK_OCLZeroEvent: { + assert(Step->Type->isEventT() && + "Event initialization on non event type."); + + CurInit = S.ImpCastExprToType(CurInit.take(), Step->Type, + CK_ZeroToOCLEvent, + CurInit.get()->getValueKind()); + break; + } } } @@ -6139,6 +6182,10 @@ void InitializationSequence::dump(raw_ostream &OS) const { case SK_StdInitializerList: OS << "std::initializer_list from initializer list"; break; + + case SK_OCLZeroEvent: + OS << "OpenCL event_t from zero"; + break; } } } diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp index 6c70320..bb20913 100644 --- a/clang/lib/Sema/SemaTemplateVariadic.cpp +++ b/clang/lib/Sema/SemaTemplateVariadic.cpp @@ -737,6 +737,7 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) { case TST_image2d_t: case TST_image2d_array_t: case TST_image3d_t: + case TST_event_t: case TST_error: break; } diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 35816a42..a3b0c45 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -952,6 +952,10 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { Result = Context.OCLImage3dTy; break; + case DeclSpec::TST_event_t: + Result = Context.OCLEventTy; + break; + case DeclSpec::TST_error: Result = Context.IntTy; declarator.setInvalidType(true); diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp index bcd8e87..bf1e25a 100644 --- a/clang/lib/Serialization/ASTCommon.cpp +++ b/clang/lib/Serialization/ASTCommon.cpp @@ -66,6 +66,7 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) { case BuiltinType::OCLImage2d: ID = PREDEF_TYPE_IMAGE2D_ID; break; case BuiltinType::OCLImage2dArray: ID = PREDEF_TYPE_IMAGE2D_ARR_ID; break; case BuiltinType::OCLImage3d: ID = PREDEF_TYPE_IMAGE3D_ID; break; + case BuiltinType::OCLEvent: ID = PREDEF_TYPE_EVENT_ID; break; case BuiltinType::BuiltinFn: ID = PREDEF_TYPE_BUILTIN_FN; break; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index c378570..00bae0a 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4807,6 +4807,7 @@ QualType ASTReader::GetType(TypeID ID) { case PREDEF_TYPE_IMAGE2D_ID: T = Context.OCLImage2dTy; break; case PREDEF_TYPE_IMAGE2D_ARR_ID: T = Context.OCLImage2dArrayTy; break; case PREDEF_TYPE_IMAGE3D_ID: T = Context.OCLImage3dTy; break; + case PREDEF_TYPE_EVENT_ID: T = Context.OCLEventTy; break; case PREDEF_TYPE_AUTO_DEDUCT: T = Context.getAutoDeductType(); break; case PREDEF_TYPE_AUTO_RREF_DEDUCT: diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp index f1ef0f6..ea2fc3c 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -306,7 +306,8 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, case CK_CPointerToObjCPointerCast: case CK_BlockPointerToObjCPointerCast: case CK_AnyPointerToBlockPointerCast: - case CK_ObjCObjectLValueCast: { + case CK_ObjCObjectLValueCast: + case CK_ZeroToOCLEvent: { // Delegate to SValBuilder to process. SVal V = state->getSVal(Ex, LCtx); V = svalBuilder.evalCast(V, T, ExTy); |