Skip to content

Commit

Permalink
[OpenCL] Add support of cl_intel_device_side_avc_motion_estimation ex…
Browse files Browse the repository at this point in the history
…tension

Summary:
Documentation can be found at https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt

Patch by Kristina Bessonova


Reviewers: Anastasia, yaxunl, shafik

Reviewed By: Anastasia

Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, cfe-commits

Differential Revision: https://reviews.llvm.org/D51484

llvm-svn: 346326
  • Loading branch information
Andrew Savonichev committed Nov 7, 2018
1 parent d80ec9e commit 35dfce7
Show file tree
Hide file tree
Showing 37 changed files with 1,061 additions and 7 deletions.
16 changes: 15 additions & 1 deletion clang/include/clang-c/Index.h
Expand Up @@ -3297,7 +3297,21 @@ enum CXTypeKind {

CXType_ObjCObject = 161,
CXType_ObjCTypeParam = 162,
CXType_Attributed = 163
CXType_Attributed = 163,

CXType_OCLIntelSubgroupAVCMcePayload = 164,
CXType_OCLIntelSubgroupAVCImePayload = 165,
CXType_OCLIntelSubgroupAVCRefPayload = 166,
CXType_OCLIntelSubgroupAVCSicPayload = 167,
CXType_OCLIntelSubgroupAVCMceResult = 168,
CXType_OCLIntelSubgroupAVCImeResult = 169,
CXType_OCLIntelSubgroupAVCRefResult = 170,
CXType_OCLIntelSubgroupAVCSicResult = 171,
CXType_OCLIntelSubgroupAVCImeResultSingleRefStreamout = 172,
CXType_OCLIntelSubgroupAVCImeResultDualRefStreamout = 173,
CXType_OCLIntelSubgroupAVCImeSingleRefStreamin = 174,

CXType_OCLIntelSubgroupAVCImeDualRefStreamin = 175
};

/**
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/AST/ASTContext.h
Expand Up @@ -1062,6 +1062,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
CanQualType OCLQueueTy, OCLReserveIDTy;
CanQualType OMPArraySectionTy;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
CanQualType Id##Ty;
#include "clang/Basic/OpenCLExtensionTypes.def"

// Types for deductions in C++0x [stmt.ranged]'s desugaring. Built on demand.
mutable QualType AutoDeductTy; // Deduction against 'auto'.
Expand Down
33 changes: 32 additions & 1 deletion clang/include/clang/AST/Type.h
Expand Up @@ -2046,6 +2046,13 @@ class Type : public ExtQualsTypeCommonBase {
bool isQueueT() const; // OpenCL queue_t
bool isReserveIDT() const; // OpenCL reserve_id_t

#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
bool is##Id##Type() const;
#include "clang/Basic/OpenCLExtensionTypes.def"
// Type defined in cl_intel_device_side_avc_motion_estimation OpenCL extension
bool isOCLIntelSubgroupAVCType() const;
bool isOCLExtOpaqueType() const; // Any OpenCL extension type

bool isPipeType() const; // OpenCL pipe type
bool isOpenCLSpecificType() const; // Any OpenCL specific type

Expand Down Expand Up @@ -2393,6 +2400,9 @@ class BuiltinType : public Type {
// OpenCL image types
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) Id,
#include "clang/Basic/OpenCLImageTypes.def"
// OpenCL extension types
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) Id,
#include "clang/Basic/OpenCLExtensionTypes.def"
// All other builtin types
#define BUILTIN_TYPE(Id, SingletonId) Id,
#define LAST_BUILTIN_TYPE(Id) LastKind = Id
Expand Down Expand Up @@ -6454,9 +6464,30 @@ inline bool Type::isPipeType() const {
return isa<PipeType>(CanonicalType);
}

#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
inline bool Type::is##Id##Type() const { \
return isSpecificBuiltinType(BuiltinType::Id); \
}
#include "clang/Basic/OpenCLExtensionTypes.def"

inline bool Type::isOCLIntelSubgroupAVCType() const {
#define INTEL_SUBGROUP_AVC_TYPE(ExtType, Id) \
isOCLIntelSubgroupAVC##Id##Type() ||
return
#include "clang/Basic/OpenCLExtensionTypes.def"
false; // end of boolean or operation
}

inline bool Type::isOCLExtOpaqueType() const {
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) is##Id##Type() ||
return
#include "clang/Basic/OpenCLExtensionTypes.def"
false; // end of boolean or operation
}

inline bool Type::isOpenCLSpecificType() const {
return isSamplerT() || isEventT() || isImageType() || isClkEventT() ||
isQueueT() || isReserveIDT() || isPipeType();
isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType();
}

inline bool Type::isTemplateTypeParmType() const {
Expand Down
41 changes: 41 additions & 0 deletions clang/include/clang/Basic/OpenCLExtensionTypes.def
@@ -0,0 +1,41 @@
//===-- OpenCLExtensionTypes.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 extension types.
// Custom code should define this macro:
// EXT_OPAQUE_TYPE(Name, Id, Ext)

#ifdef EXT_OPAQUE_TYPE

#ifndef INTEL_SUBGROUP_AVC_TYPE
#define INTEL_SUBGROUP_AVC_TYPE(Name, Id) \
EXT_OPAQUE_TYPE(intel_sub_group_avc_##Name, OCLIntelSubgroupAVC##Id, \
cl_intel_device_side_avc_motion_estimation)
#endif

#endif

#ifdef INTEL_SUBGROUP_AVC_TYPE
INTEL_SUBGROUP_AVC_TYPE(mce_payload_t, McePayload)
INTEL_SUBGROUP_AVC_TYPE(ime_payload_t, ImePayload)
INTEL_SUBGROUP_AVC_TYPE(ref_payload_t, RefPayload)
INTEL_SUBGROUP_AVC_TYPE(sic_payload_t, SicPayload)
INTEL_SUBGROUP_AVC_TYPE(mce_result_t, MceResult)
INTEL_SUBGROUP_AVC_TYPE(ime_result_t, ImeResult)
INTEL_SUBGROUP_AVC_TYPE(ref_result_t, RefResult)
INTEL_SUBGROUP_AVC_TYPE(sic_result_t, SicResult)
INTEL_SUBGROUP_AVC_TYPE(ime_result_single_reference_streamout_t, ImeResultSingleRefStreamout)
INTEL_SUBGROUP_AVC_TYPE(ime_result_dual_reference_streamout_t, ImeResultDualRefStreamout)
INTEL_SUBGROUP_AVC_TYPE(ime_single_reference_streamin_t, ImeSingleRefStreamin)
INTEL_SUBGROUP_AVC_TYPE(ime_dual_reference_streamin_t, ImeDualRefStreamin)

#undef INTEL_SUBGROUP_AVC_TYPE
#endif // INTEL_SUBGROUP_AVC_TYPE

#undef EXT_OPAQUE_TYPE

1 change: 1 addition & 0 deletions clang/include/clang/Basic/OpenCLExtensions.def
Expand Up @@ -85,6 +85,7 @@ OPENCLEXT_INTERNAL(cl_amd_media_ops2, 100, ~0U)
// Intel OpenCL extensions
OPENCLEXT_INTERNAL(cl_intel_subgroups, 120, ~0U)
OPENCLEXT_INTERNAL(cl_intel_subgroups_short, 120, ~0U)
OPENCLEXT_INTERNAL(cl_intel_device_side_avc_motion_estimation, 120, ~0U)

#undef OPENCLEXT_INTERNAL

Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Sema/Initialization.h
Expand Up @@ -1335,6 +1335,10 @@ class InitializationSequence {
/// from a zero constant.
void AddOCLZeroOpaqueTypeStep(QualType T);

/// Add a step to initialize by zero types defined in the
/// cl_intel_device_side_avc_motion_estimation OpenCL extension
void AddOCLIntelSubgroupAVCZeroInitStep(QualType T);

/// Add steps to unwrap a initializer list for a reference around a
/// single element and rewrap it at the end.
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Serialization/ASTBitCodes.h
Expand Up @@ -1015,6 +1015,10 @@ namespace serialization {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/OpenCLImageTypes.def"
/// \brief OpenCL extension types with auto numeration
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/OpenCLExtensionTypes.def"
};

/// The number of predefined type IDs that are reserved for
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/module.modulemap
Expand Up @@ -52,6 +52,7 @@ module Clang_Basic {
textual header "Basic/LangOptions.def"
textual header "Basic/OpenCLExtensions.def"
textual header "Basic/OpenCLImageTypes.def"
textual header "Basic/OpenCLExtensionTypes.def"
textual header "Basic/OpenMPKinds.def"
textual header "Basic/OperatorKinds.def"
textual header "Basic/Sanitizers.def"
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/AST/ASTContext.cpp
Expand Up @@ -1241,6 +1241,10 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
InitBuiltinType(OCLClkEventTy, BuiltinType::OCLClkEvent);
InitBuiltinType(OCLQueueTy, BuiltinType::OCLQueue);
InitBuiltinType(OCLReserveIDTy, BuiltinType::OCLReserveID);

#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
InitBuiltinType(Id##Ty, BuiltinType::Id);
#include "clang/Basic/OpenCLExtensionTypes.def"
}

// Builtin type for __objc_yes and __objc_no
Expand Down Expand Up @@ -1892,6 +1896,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
AS = getTargetAddressSpace(
Target->getOpenCLTypeAddrSpace(getOpenCLTypeKind(T)));
Width = Target->getPointerWidth(AS);
Expand Down Expand Up @@ -6500,6 +6507,9 @@ static char getObjCEncodingForPrimitiveKind(const ASTContext *C,
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
case BuiltinType::OCLQueue:
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/ASTImporter.cpp
Expand Up @@ -988,6 +988,10 @@ ExpectedType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
case BuiltinType::Id: \
return Importer.getToContext().SingletonId;
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
return Importer.getToContext().Id##Ty;
#include "clang/Basic/OpenCLExtensionTypes.def"
#define SHARED_SINGLETON_TYPE(Expansion)
#define BUILTIN_TYPE(Id, SingletonId) \
case BuiltinType::Id: return Importer.getToContext().SingletonId;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/ExprConstant.cpp
Expand Up @@ -7644,6 +7644,9 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/AST/ItaniumMangle.cpp
Expand Up @@ -2635,6 +2635,12 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
case BuiltinType::OCLReserveID:
Out << "13ocl_reserveid";
break;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
type_name = "ocl_" #ExtType; \
Out << type_name.size() << type_name; \
break;
#include "clang/Basic/OpenCLExtensionTypes.def"
}
}

Expand Down
5 changes: 5 additions & 0 deletions clang/lib/AST/MicrosoftMangle.cpp
Expand Up @@ -1985,6 +1985,11 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
Out << "PA";
mangleArtificalTagType(TTK_Struct, "ocl_reserveid");
break;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
mangleArtificalTagType(TTK_Struct, "ocl_" #ExtType); \
break;
#include "clang/Basic/OpenCLExtensionTypes.def"

case BuiltinType::NullPtr:
Out << "$$T";
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/NSAPI.cpp
Expand Up @@ -475,6 +475,9 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/PrintfFormatString.cpp
Expand Up @@ -723,6 +723,9 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
#define SIGNED_TYPE(Id, SingletonId)
#define UNSIGNED_TYPE(Id, SingletonId)
#define FLOATING_TYPE(Id, SingletonId)
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/AST/Type.cpp
Expand Up @@ -2786,6 +2786,10 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
return "reserve_id_t";
case OMPArraySection:
return "<OpenMP array section type>";
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case Id: \
return #ExtType;
#include "clang/Basic/OpenCLExtensionTypes.def"
}

llvm_unreachable("Invalid builtin type.");
Expand Down Expand Up @@ -3746,6 +3750,9 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/AST/TypeLoc.cpp
Expand Up @@ -384,6 +384,9 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Expand Up @@ -659,6 +659,10 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
return getOrCreateStructPtrType("opencl_queue_t", OCLQueueDITy);
case BuiltinType::OCLReserveID:
return getOrCreateStructPtrType("opencl_reserve_id_t", OCLReserveIDDITy);
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty);
#include "clang/Basic/OpenCLExtensionTypes.def"

case BuiltinType::UChar:
case BuiltinType::Char_U:
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CGDebugInfo.h
Expand Up @@ -76,6 +76,9 @@ class CGDebugInfo {
llvm::DIType *OCLQueueDITy = nullptr;
llvm::DIType *OCLNDRangeDITy = nullptr;
llvm::DIType *OCLReserveIDDITy = nullptr;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
llvm::DIType *Id##Ty = nullptr;
#include "clang/Basic/OpenCLExtensionTypes.def"

/// Cache of previously constructed Types.
llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache;
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CGExprScalar.cpp
Expand Up @@ -2236,7 +2236,8 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
}

case CK_ZeroToOCLOpaqueType: {
assert((DestTy->isEventT() || DestTy->isQueueT()) &&
assert((DestTy->isEventT() || DestTy->isQueueT() ||
DestTy->isOCLIntelSubgroupAVCType()) &&
"CK_ZeroToOCLEvent cast on non-event type");
return llvm::Constant::getNullValue(ConvertType(DestTy));
}
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/CodeGen/CGOpenCLRuntime.cpp
Expand Up @@ -62,6 +62,11 @@ llvm::Type *CGOpenCLRuntime::convertOpenCLSpecificType(const Type *T) {
case BuiltinType::OCLReserveID:
return llvm::PointerType::get(
llvm::StructType::create(Ctx, "opencl.reserve_id_t"), AddrSpc);
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
return llvm::PointerType::get( \
llvm::StructType::create(Ctx, "opencl." #ExtType), AddrSpc);
#include "clang/Basic/OpenCLExtensionTypes.def"
}
}

Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CodeGenTypes.cpp
Expand Up @@ -503,6 +503,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/ItaniumCXXABI.cpp
Expand Up @@ -2812,6 +2812,9 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLImageTypes.def"
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id:
#include "clang/Basic/OpenCLExtensionTypes.def"
case BuiltinType::OCLSampler:
case BuiltinType::OCLEvent:
case BuiltinType::OCLClkEvent:
Expand Down

0 comments on commit 35dfce7

Please sign in to comment.