From a3e40c774f6cbd9727cf82fdf04fefb0a87ecf2d Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Tue, 15 Sep 2015 11:18:52 +0000 Subject: [PATCH] [OpenCL] Add new types for OpenCL 2.0. Patch by Pedro Ferreira. Reviewers: pekka.jaaskelainen Differential Revision: http://reviews.llvm.org/D12855 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247676 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/ASTContext.h | 7 ++- include/clang/AST/BuiltinTypes.def | 18 ++++++ include/clang/AST/Type.h | 73 +++++++++++++++++++---- include/clang/Basic/OpenCLExtensions.def | 3 + include/clang/Serialization/ASTBitCodes.h | 28 +++++++-- lib/AST/ASTContext.cpp | 31 ++++++++++ lib/AST/ItaniumMangle.cpp | 30 ++++++++++ lib/AST/MicrosoftMangle.cpp | 30 ++++++++++ lib/AST/NSAPI.cpp | 10 ++++ lib/AST/Type.cpp | 30 ++++++++++ lib/AST/TypeLoc.cpp | 10 ++++ lib/CodeGen/CGDebugInfo.cpp | 26 ++++++++ lib/CodeGen/CGDebugInfo.h | 10 ++++ lib/CodeGen/CGOpenCLRuntime.cpp | 34 +++++++++++ lib/CodeGen/CodeGenTypes.cpp | 10 ++++ lib/CodeGen/ItaniumCXXABI.cpp | 10 ++++ lib/Index/USRGeneration.cpp | 10 ++++ lib/Sema/Sema.cpp | 12 ++++ lib/Sema/SemaType.cpp | 7 +++ lib/Serialization/ASTCommon.cpp | 30 ++++++++++ lib/Serialization/ASTReader.cpp | 30 ++++++++++ test/PCH/ocl_types.h | 34 +++++++++++ tools/libclang/CIndex.cpp | 10 ++++ 23 files changed, 477 insertions(+), 16 deletions(-) diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 6391244ca0..7f6bc678c1 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -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. diff --git a/include/clang/AST/BuiltinTypes.def b/include/clang/AST/BuiltinTypes.def index ca4c6f65ce..85e237a2bf 100644 --- a/include/clang/AST/BuiltinTypes.def +++ b/include/clang/AST/BuiltinTypes.def @@ -160,6 +160,12 @@ BUILTIN_TYPE(OCLImage1dArray, OCLImage1dArrayTy) 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 diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index e1ebd72795..a44b3120f7 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -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 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 isImage2dArrayMSAATDepth() const; // OpenCL image_2d_array_msaa_depth_t + bool isImage3dT() const; // OpenCL image3d_t bool isImageType() const; // Any OpenCL image type bool isSamplerT() const; // OpenCL sampler_t bool isEventT() const; // OpenCL event_t + bool isClkEventT() const; // OpenCL clk_event_t + bool isQueueT() const; // OpenCL queue_t + bool isNDRangeT() const; // OpenCL ndrange_t + bool isReserveIDT() const; // OpenCL reserve_id_t bool isOpenCLSpecificType() const; // Any OpenCL specific type @@ -5354,6 +5364,30 @@ inline bool Type::isImage2dArrayT() const { return isSpecificBuiltinType(BuiltinType::OCLImage2dArray); } +inline bool Type::isImage2dDepthT() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dDepth); +} + +inline bool Type::isImage2dArrayDepthT() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dArrayDepth); +} + +inline bool Type::isImage2dMSAAT() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dMSAA); +} + +inline bool Type::isImage2dArrayMSAAT() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dArrayMSAA); +} + +inline bool Type::isImage2dMSAATDepth() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dMSAADepth); +} + +inline bool Type::isImage2dArrayMSAATDepth() const { + return isSpecificBuiltinType(BuiltinType::OCLImage2dArrayMSAADepth); +} + inline bool Type::isImage3dT() const { return isSpecificBuiltinType(BuiltinType::OCLImage3d); } @@ -5366,14 +5400,33 @@ inline bool Type::isEventT() const { return isSpecificBuiltinType(BuiltinType::OCLEvent); } +inline bool Type::isClkEventT() const { + return isSpecificBuiltinType(BuiltinType::OCLClkEvent); +} + +inline bool Type::isQueueT() const { + return isSpecificBuiltinType(BuiltinType::OCLQueue); +} + +inline bool Type::isNDRangeT() const { + return isSpecificBuiltinType(BuiltinType::OCLNDRange); +} + +inline bool Type::isReserveIDT() const { + return isSpecificBuiltinType(BuiltinType::OCLReserveID); +} + inline bool Type::isImageType() const { - return isImage3dT() || - isImage2dT() || isImage2dArrayT() || - isImage1dT() || isImage1dArrayT() || isImage1dBufferT(); + return isImage3dT() || isImage2dT() || isImage2dArrayT() || + isImage2dDepthT() || isImage2dArrayDepthT() || isImage2dMSAAT() || + isImage2dArrayMSAAT() || isImage2dMSAATDepth() || + isImage2dArrayMSAATDepth() || isImage1dT() || isImage1dArrayT() || + isImage1dBufferT(); } inline bool Type::isOpenCLSpecificType() const { - return isSamplerT() || isEventT() || isImageType(); + return isSamplerT() || isEventT() || isImageType() || isClkEventT() || + isQueueT() || isNDRangeT() || isReserveIDT(); } inline bool Type::isTemplateTypeParmType() const { diff --git a/include/clang/Basic/OpenCLExtensions.def b/include/clang/Basic/OpenCLExtensions.def index 103fa839b8..91fd9195b1 100644 --- a/include/clang/Basic/OpenCLExtensions.def +++ b/include/clang/Basic/OpenCLExtensions.def @@ -26,6 +26,9 @@ OPENCLEXT(cl_khr_local_int32_extended_atomics) OPENCLEXT(cl_khr_byte_addressable_store) OPENCLEXT(cl_khr_3d_image_writes) +// OpenCL 2.0 +OPENCLEXT(cl_khr_gl_msaa_sharing) + // Clang Extensions. OPENCLEXT(cl_clang_storage_class_specifiers) diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h index 4f317eb8d4..0dec07f949 100644 --- a/include/clang/Serialization/ASTBitCodes.h +++ b/include/clang/Serialization/ASTBitCodes.h @@ -770,14 +770,34 @@ namespace clang { PREDEF_TYPE_IMAGE2D_ID = 40, /// \brief OpenCL 2d image array type. PREDEF_TYPE_IMAGE2D_ARR_ID = 41, + /// \brief OpenCL 2d image depth type. + PREDEF_TYPE_IMAGE2D_DEP_ID = 42, + /// \brief OpenCL 2d image array depth type. + PREDEF_TYPE_IMAGE2D_ARR_DEP_ID = 43, + /// \brief OpenCL 2d image MSAA type. + PREDEF_TYPE_IMAGE2D_MSAA_ID = 44, + /// \brief OpenCL 2d image array MSAA type. + PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID = 45, + /// \brief OpenCL 2d image MSAA depth type. + PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID = 46, + /// \brief OpenCL 2d image array MSAA depth type. + PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID = 47, /// \brief OpenCL 3d image type. - PREDEF_TYPE_IMAGE3D_ID = 42, + PREDEF_TYPE_IMAGE3D_ID = 48, /// \brief OpenCL event type. - PREDEF_TYPE_EVENT_ID = 43, + PREDEF_TYPE_EVENT_ID = 49, + /// \brief OpenCL clk event type. + PREDEF_TYPE_CLK_EVENT_ID = 50, /// \brief OpenCL sampler type. - PREDEF_TYPE_SAMPLER_ID = 44, + PREDEF_TYPE_SAMPLER_ID = 51, + /// \brief OpenCL queue type. + PREDEF_TYPE_QUEUE_ID = 52, + /// \brief OpenCL ndrange type. + PREDEF_TYPE_NDRANGE_ID = 53, + /// \brief OpenCL reserve_id type. + PREDEF_TYPE_RESERVE_ID_ID = 54, /// \brief The placeholder type for OpenMP array section. - PREDEF_TYPE_OMP_ARRAY_SECTION = 45, + PREDEF_TYPE_OMP_ARRAY_SECTION = 55 }; /// \brief The number of predefined type IDs that are reserved for diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index b07a21301e..e5511cbd61 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1068,10 +1068,21 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target) { InitBuiltinType(OCLImage1dBufferTy, BuiltinType::OCLImage1dBuffer); InitBuiltinType(OCLImage2dTy, BuiltinType::OCLImage2d); InitBuiltinType(OCLImage2dArrayTy, BuiltinType::OCLImage2dArray); + InitBuiltinType(OCLImage2dDepthTy, BuiltinType::OCLImage2dDepth); + InitBuiltinType(OCLImage2dArrayDepthTy, BuiltinType::OCLImage2dArrayDepth); + InitBuiltinType(OCLImage2dMSAATy, BuiltinType::OCLImage2dMSAA); + InitBuiltinType(OCLImage2dArrayMSAATy, BuiltinType::OCLImage2dArrayMSAA); + InitBuiltinType(OCLImage2dMSAADepthTy, BuiltinType::OCLImage2dMSAADepth); + InitBuiltinType(OCLImage2dArrayMSAADepthTy, + BuiltinType::OCLImage2dArrayMSAADepth); InitBuiltinType(OCLImage3dTy, BuiltinType::OCLImage3d); InitBuiltinType(OCLSamplerTy, BuiltinType::OCLSampler); InitBuiltinType(OCLEventTy, BuiltinType::OCLEvent); + InitBuiltinType(OCLClkEventTy, BuiltinType::OCLClkEvent); + InitBuiltinType(OCLQueueTy, BuiltinType::OCLQueue); + InitBuiltinType(OCLNDRangeTy, BuiltinType::OCLNDRange); + InitBuiltinType(OCLReserveIDTy, BuiltinType::OCLReserveID); } // Builtin type for __objc_yes and __objc_no @@ -1638,11 +1649,21 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = Target->getIntAlign(); break; case BuiltinType::OCLEvent: + case BuiltinType::OCLClkEvent: + case BuiltinType::OCLQueue: + case BuiltinType::OCLNDRange: + case BuiltinType::OCLReserveID: 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: // Currently these types are pointers to opaque types. Width = Target->getPointerWidth(0); @@ -5374,8 +5395,18 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C, 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::OCLEvent: + case BuiltinType::OCLClkEvent: + case BuiltinType::OCLQueue: + case BuiltinType::OCLNDRange: + case BuiltinType::OCLReserveID: case BuiltinType::OCLSampler: case BuiltinType::Dependent: #define BUILTIN_TYPE(KIND, ID) diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 774ef9ae35..ba486321e5 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -2028,9 +2028,39 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { case BuiltinType::OCLImage1dBuffer: Out << "17ocl_image1dbuffer"; break; case BuiltinType::OCLImage2d: Out << "11ocl_image2d"; break; case BuiltinType::OCLImage2dArray: Out << "16ocl_image2darray"; break; + case BuiltinType::OCLImage2dDepth: + Out << "16ocl_image2ddepth"; + break; + case BuiltinType::OCLImage2dArrayDepth: + Out << "21ocl_image2darraydepth"; + break; + case BuiltinType::OCLImage2dMSAA: + Out << "15ocl_image2dmsaa"; + break; + case BuiltinType::OCLImage2dArrayMSAA: + Out << "20ocl_image2darraymsaa"; + break; + case BuiltinType::OCLImage2dMSAADepth: + Out << "20ocl_image2dmsaadepth"; + break; + case BuiltinType::OCLImage2dArrayMSAADepth: + Out << "35ocl_image2darraymsaadepth"; + break; case BuiltinType::OCLImage3d: Out << "11ocl_image3d"; break; case BuiltinType::OCLSampler: Out << "11ocl_sampler"; break; case BuiltinType::OCLEvent: Out << "9ocl_event"; break; + case BuiltinType::OCLClkEvent: + Out << "12ocl_clkevent"; + break; + case BuiltinType::OCLQueue: + Out << "9ocl_queue"; + break; + case BuiltinType::OCLNDRange: + Out << "11ocl_ndrange"; + break; + case BuiltinType::OCLReserveID: + Out << "13ocl_reserveid"; + break; } } diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index fcd7a4ab1e..a5ccac9c0a 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -1593,9 +1593,39 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers, case BuiltinType::OCLImage1dBuffer: Out << "PAUocl_image1dbuffer@@"; break; case BuiltinType::OCLImage2d: Out << "PAUocl_image2d@@"; break; case BuiltinType::OCLImage2dArray: Out << "PAUocl_image2darray@@"; break; + case BuiltinType::OCLImage2dDepth: + Out << "PAUocl_image2ddepth@@"; + break; + case BuiltinType::OCLImage2dArrayDepth: + Out << "PAUocl_image2darraydepth@@"; + break; + case BuiltinType::OCLImage2dMSAA: + Out << "PAUocl_image2dmsaa@@"; + break; + case BuiltinType::OCLImage2dArrayMSAA: + Out << "PAUocl_image2darraymsaa@@"; + break; + case BuiltinType::OCLImage2dMSAADepth: + Out << "PAUocl_image2dmsaadepth@@"; + break; + case BuiltinType::OCLImage2dArrayMSAADepth: + Out << "PAUocl_image2darraymsaadepth@@"; + break; case BuiltinType::OCLImage3d: Out << "PAUocl_image3d@@"; break; case BuiltinType::OCLSampler: Out << "PAUocl_sampler@@"; break; case BuiltinType::OCLEvent: Out << "PAUocl_event@@"; break; + case BuiltinType::OCLClkEvent: + Out << "PAUocl_clkevent@@"; + break; + case BuiltinType::OCLQueue: + Out << "PAUocl_queue@@"; + break; + case BuiltinType::OCLNDRange: + Out << "PAUocl_ndrange@@"; + break; + case BuiltinType::OCLReserveID: + Out << "PAUocl_reserveid@@"; + break; case BuiltinType::NullPtr: Out << "$$T"; break; diff --git a/lib/AST/NSAPI.cpp b/lib/AST/NSAPI.cpp index 17d5beb142..c562dae632 100644 --- a/lib/AST/NSAPI.cpp +++ b/lib/AST/NSAPI.cpp @@ -450,9 +450,19 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const { 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: case BuiltinType::BoundMember: case BuiltinType::Dependent: case BuiltinType::Overload: diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index dfa14aa18b..2d8d2fba93 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -2530,9 +2530,29 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const { case OCLImage1dBuffer: return "image1d_buffer_t"; case OCLImage2d: return "image2d_t"; case OCLImage2dArray: return "image2d_array_t"; + case OCLImage2dDepth: + return "image2d_depth_t"; + case OCLImage2dArrayDepth: + return "image2d_array_depth_t"; + case OCLImage2dMSAA: + return "image2d_msaa_t"; + case OCLImage2dArrayMSAA: + return "image2d_array_msaa_t"; + case OCLImage2dMSAADepth: + return "image2d_msaa_depth_t"; + case OCLImage2dArrayMSAADepth: + return "image2d_array_msaa_depth_t"; case OCLImage3d: return "image3d_t"; case OCLSampler: return "sampler_t"; case OCLEvent: return "event_t"; + case OCLClkEvent: + return "clk_event_t"; + case OCLQueue: + return "queue_t"; + case OCLNDRange: + return "event_t"; + case OCLReserveID: + return "reserve_id_t"; case OMPArraySection: return ""; } @@ -3434,9 +3454,19 @@ bool Type::canHaveNullability() const { 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: case BuiltinType::BuiltinFn: case BuiltinType::NullPtr: case BuiltinType::OMPArraySection: diff --git a/lib/AST/TypeLoc.cpp b/lib/AST/TypeLoc.cpp index 2dbad7edcf..a057a345a9 100644 --- a/lib/AST/TypeLoc.cpp +++ b/lib/AST/TypeLoc.cpp @@ -338,9 +338,19 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const { 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: case BuiltinType::BuiltinFn: case BuiltinType::OMPArraySection: return TST_unspecified; diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 006f6ddc77..b8cf83ee48 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -447,6 +447,24 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { case BuiltinType::OCLImage2dArray: return getOrCreateStructPtrType("opencl_image2d_array_t", OCLImage2dArrayDITy); + case BuiltinType::OCLImage2dDepth: + return getOrCreateStructPtrType("opencl_image2d_depth_t", + OCLImage2dDepthDITy); + case BuiltinType::OCLImage2dArrayDepth: + return getOrCreateStructPtrType("opencl_image2d_array_depth_t", + OCLImage2dArrayDepthDITy); + case BuiltinType::OCLImage2dMSAA: + return getOrCreateStructPtrType("opencl_image2d_msaa_t", + OCLImage2dMSAADITy); + case BuiltinType::OCLImage2dArrayMSAA: + return getOrCreateStructPtrType("opencl_image2d_array_msaa_t", + OCLImage2dArrayMSAADITy); + case BuiltinType::OCLImage2dMSAADepth: + return getOrCreateStructPtrType("opencl_image2d_msaa_depth_t", + OCLImage2dMSAADepthDITy); + case BuiltinType::OCLImage2dArrayMSAADepth: + return getOrCreateStructPtrType("opencl_image2d_array_msaa_depth_t", + OCLImage2dArrayMSAADepthDITy); case BuiltinType::OCLImage3d: return getOrCreateStructPtrType("opencl_image3d_t", OCLImage3dDITy); case BuiltinType::OCLSampler: @@ -455,6 +473,14 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { CGM.getContext().getTypeAlign(BT), llvm::dwarf::DW_ATE_unsigned); case BuiltinType::OCLEvent: return getOrCreateStructPtrType("opencl_event_t", OCLEventDITy); + case BuiltinType::OCLClkEvent: + return getOrCreateStructPtrType("opencl_clk_event_t", OCLClkEventDITy); + case BuiltinType::OCLQueue: + return getOrCreateStructPtrType("opencl_queue_t", OCLQueueDITy); + case BuiltinType::OCLNDRange: + return getOrCreateStructPtrType("opencl_ndrange_t", OCLNDRangeDITy); + case BuiltinType::OCLReserveID: + return getOrCreateStructPtrType("opencl_reserve_id_t", OCLReserveIDDITy); case BuiltinType::UChar: case BuiltinType::Char_U: diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 3ff377ec18..6a2a1424e5 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -65,8 +65,18 @@ class CGDebugInfo { llvm::DIType *OCLImage1dBufferDITy = nullptr; llvm::DIType *OCLImage2dDITy = nullptr; llvm::DIType *OCLImage2dArrayDITy = nullptr; + llvm::DIType *OCLImage2dDepthDITy = nullptr; + llvm::DIType *OCLImage2dArrayDepthDITy = nullptr; + llvm::DIType *OCLImage2dMSAADITy = nullptr; + llvm::DIType *OCLImage2dArrayMSAADITy = nullptr; + llvm::DIType *OCLImage2dMSAADepthDITy = nullptr; + llvm::DIType *OCLImage2dArrayMSAADepthDITy = nullptr; llvm::DIType *OCLImage3dDITy = nullptr; llvm::DIType *OCLEventDITy = nullptr; + llvm::DIType *OCLClkEventDITy = nullptr; + llvm::DIType *OCLQueueDITy = nullptr; + llvm::DIType *OCLNDRangeDITy = nullptr; + llvm::DIType *OCLReserveIDDITy = nullptr; /// Cache of previously constructed Types. llvm::DenseMap TypeCache; diff --git a/lib/CodeGen/CGOpenCLRuntime.cpp b/lib/CodeGen/CGOpenCLRuntime.cpp index 079ef7234d..8af39ceecd 100644 --- a/lib/CodeGen/CGOpenCLRuntime.cpp +++ b/lib/CodeGen/CGOpenCLRuntime.cpp @@ -55,6 +55,28 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { case BuiltinType::OCLImage2dArray: return llvm::PointerType::get(llvm::StructType::create( Ctx, "opencl.image2d_array_t"), ImgAddrSpc); + case BuiltinType::OCLImage2dDepth: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_depth_t"), ImgAddrSpc); + case BuiltinType::OCLImage2dArrayDepth: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_array_depth_t"), + ImgAddrSpc); + case BuiltinType::OCLImage2dMSAA: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_msaa_t"), ImgAddrSpc); + case BuiltinType::OCLImage2dArrayMSAA: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_array_msaa_t"), + ImgAddrSpc); + case BuiltinType::OCLImage2dMSAADepth: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_msaa_depth_t"), + ImgAddrSpc); + case BuiltinType::OCLImage2dArrayMSAADepth: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.image2d_array_msaa_depth_t"), + ImgAddrSpc); case BuiltinType::OCLImage3d: return llvm::PointerType::get(llvm::StructType::create( Ctx, "opencl.image3d_t"), ImgAddrSpc); @@ -63,5 +85,17 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) { case BuiltinType::OCLEvent: return llvm::PointerType::get(llvm::StructType::create( Ctx, "opencl.event_t"), 0); + case BuiltinType::OCLClkEvent: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.clk_event_t"), 0); + case BuiltinType::OCLQueue: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.queue_t"), 0); + case BuiltinType::OCLNDRange: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.ndrange_t"), 0); + case BuiltinType::OCLReserveID: + return llvm::PointerType::get( + llvm::StructType::create(Ctx, "opencl.reserve_id_t"), 0); } } diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 41aa0c1d8a..f0a25ba429 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -388,9 +388,19 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { 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: ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty); break; diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 85c7fd1603..7228a6d8c1 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -2508,9 +2508,19 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) { 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: return true; case BuiltinType::Dependent: diff --git a/lib/Index/USRGeneration.cpp b/lib/Index/USRGeneration.cpp index cc98a719a6..c57694fc10 100644 --- a/lib/Index/USRGeneration.cpp +++ b/lib/Index/USRGeneration.cpp @@ -610,8 +610,18 @@ void USRGenerator::VisitType(QualType T) { 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::OCLEvent: + case BuiltinType::OCLClkEvent: + case BuiltinType::OCLQueue: + case BuiltinType::OCLNDRange: + case BuiltinType::OCLReserveID: case BuiltinType::OCLSampler: IgnoreResults = true; return; diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 728032b856..b009123c8c 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -213,6 +213,18 @@ void Sema::Initialize() { addImplicitTypedef("sampler_t", Context.OCLSamplerTy); addImplicitTypedef("event_t", Context.OCLEventTy); if (getLangOpts().OpenCLVersion >= 200) { + addImplicitTypedef("image2d_depth_t", Context.OCLImage2dDepthTy); + addImplicitTypedef("image2d_array_depth_t", + Context.OCLImage2dArrayDepthTy); + addImplicitTypedef("image2d_msaa_t", Context.OCLImage2dMSAATy); + addImplicitTypedef("image2d_array_msaa_t", Context.OCLImage2dArrayMSAATy); + addImplicitTypedef("image2d_msaa_depth_t", Context.OCLImage2dMSAADepthTy); + addImplicitTypedef("image2d_array_msaa_depth_t", + Context.OCLImage2dArrayMSAADepthTy); + addImplicitTypedef("clk_event_t", Context.OCLClkEventTy); + addImplicitTypedef("queue_t", Context.OCLQueueTy); + addImplicitTypedef("ndrange_t", Context.OCLNDRangeTy); + addImplicitTypedef("reserve_id_t", Context.OCLReserveIDTy); addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy)); addImplicitTypedef("atomic_uint", Context.getAtomicType(Context.UnsignedIntTy)); diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 6304599227..73da718a81 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -1397,6 +1397,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { << Result << "cl_khr_fp64"; declarator.setInvalidType(true); } + } else if (!S.getOpenCLOptions().cl_khr_gl_msaa_sharing && + (Result->isImage2dMSAAT() || Result->isImage2dArrayMSAAT() || + Result->isImage2dArrayMSAATDepth() || + Result->isImage2dMSAATDepth())) { + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension) + << Result << "cl_khr_gl_msaa_sharing"; + declarator.setInvalidType(true); } } diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp index 0159c1648c..b117581a2d 100644 --- a/lib/Serialization/ASTCommon.cpp +++ b/lib/Serialization/ASTCommon.cpp @@ -67,9 +67,39 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) { 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: + ID = PREDEF_TYPE_IMAGE2D_DEP_ID; + break; + case BuiltinType::OCLImage2dArrayDepth: + ID = PREDEF_TYPE_IMAGE2D_ARR_DEP_ID; + break; + case BuiltinType::OCLImage2dMSAA: + ID = PREDEF_TYPE_IMAGE2D_MSAA_ID; + break; + case BuiltinType::OCLImage2dArrayMSAA: + ID = PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID; + break; + case BuiltinType::OCLImage2dMSAADepth: + ID = PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID; + break; + case BuiltinType::OCLImage2dArrayMSAADepth: + ID = PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID; + break; case BuiltinType::OCLImage3d: ID = PREDEF_TYPE_IMAGE3D_ID; break; case BuiltinType::OCLSampler: ID = PREDEF_TYPE_SAMPLER_ID; break; case BuiltinType::OCLEvent: ID = PREDEF_TYPE_EVENT_ID; break; + case BuiltinType::OCLClkEvent: + ID = PREDEF_TYPE_CLK_EVENT_ID; + break; + case BuiltinType::OCLQueue: + ID = PREDEF_TYPE_QUEUE_ID; + break; + case BuiltinType::OCLNDRange: + ID = PREDEF_TYPE_NDRANGE_ID; + break; + case BuiltinType::OCLReserveID: + ID = PREDEF_TYPE_RESERVE_ID_ID; + break; case BuiltinType::BuiltinFn: ID = PREDEF_TYPE_BUILTIN_FN; break; case BuiltinType::OMPArraySection: ID = PREDEF_TYPE_OMP_ARRAY_SECTION; break; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 43d6074120..16d686b66e 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -5824,9 +5824,39 @@ QualType ASTReader::GetType(TypeID ID) { 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: diff --git a/test/PCH/ocl_types.h b/test/PCH/ocl_types.h index 65c6acb7c5..93cf4f6644 100644 --- a/test/PCH/ocl_types.h +++ b/test/PCH/ocl_types.h @@ -23,3 +23,37 @@ typedef sampler_t smp_t; // 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 diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 2d25a3d7b8..a998a482a5 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1460,9 +1460,19 @@ bool CursorVisitor::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) { 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: -- 2.40.0