summaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorAndrew Savonichev <andrew.savonichev@intel.com>2018-11-08 11:25:41 +0000
committerAndrew Savonichev <andrew.savonichev@intel.com>2018-11-08 11:25:41 +0000
commit2a515b366ed1fc5e80f9310ba94f171db7cc3aa7 (patch)
treed6199c9a6cbac063f6d50f0051dc2d1ab444ba56 /lib/Sema
parent7668d4626c27696d1d5e4b2086b5882196fb4d68 (diff)
downloadclang-2a515b366ed1fc5e80f9310ba94f171db7cc3aa7.tar.gz
[OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346392 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/Sema.cpp4
-rw-r--r--lib/Sema/SemaExpr.cpp6
-rw-r--r--lib/Sema/SemaInit.cpp35
3 files changed, 41 insertions, 4 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index d6fe37f8e8..064de0259d 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -320,6 +320,10 @@ void Sema::Initialize() {
#define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \
setOpenCLExtensionForType(Context.Id, Ext);
#include "clang/Basic/OpenCLImageTypes.def"
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
+ addImplicitTypedef(#ExtType, Context.Id##Ty); \
+ setOpenCLExtensionForType(Context.Id##Ty, #Ext);
+#include "clang/Basic/OpenCLExtensionTypes.def"
};
if (Context.getTargetInfo().hasBuiltinMSVaList()) {
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a7dc08248e..428bd7a592 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -5066,6 +5066,9 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
#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 PLACEHOLDER_TYPE(ID, SINGLETON_ID)
#define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
#include "clang/AST/BuiltinTypes.def"
@@ -16566,6 +16569,9 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
#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 BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
#define PLACEHOLDER_TYPE(Id, SingletonId)
#include "clang/AST/BuiltinTypes.def"
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 1e4d12d20c..11a1f8509a 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1192,6 +1192,10 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity,
if (!VerifyOnly)
SemaRef.Diag(IList->getBeginLoc(), diag::err_init_objc_class) << DeclType;
hadError = true;
+ } else if (DeclType->isOCLIntelSubgroupAVCType()) {
+ // Checks for scalar type are sufficient for these types too.
+ CheckScalarType(Entity, IList, DeclType, Index, StructuredList,
+ StructuredIndex);
} else {
if (!VerifyOnly)
SemaRef.Diag(IList->getBeginLoc(), diag::err_illegal_initializer_type)
@@ -5252,6 +5256,11 @@ static bool TryOCLSamplerInitialization(Sema &S,
return true;
}
+static bool IsZeroInitializer(Expr *Initializer, Sema &S) {
+ return Initializer->isIntegerConstantExpr(S.getASTContext()) &&
+ (Initializer->EvaluateKnownConstInt(S.getASTContext()) == 0);
+}
+
static bool TryOCLZeroOpaqueTypeInitialization(Sema &S,
InitializationSequence &Sequence,
QualType DestType,
@@ -5268,8 +5277,23 @@ static bool TryOCLZeroOpaqueTypeInitialization(Sema &S,
// event should be zero.
//
if (DestType->isEventT() || DestType->isQueueT()) {
- if (!Initializer->isIntegerConstantExpr(S.getASTContext()) ||
- (Initializer->EvaluateKnownConstInt(S.getASTContext()) != 0))
+ if (!IsZeroInitializer(Initializer, S))
+ return false;
+
+ Sequence.AddOCLZeroOpaqueTypeStep(DestType);
+ return true;
+ }
+
+ // We should allow zero initialization for all types defined in the
+ // cl_intel_device_side_avc_motion_estimation extension, except
+ // intel_sub_group_avc_mce_payload_t and intel_sub_group_avc_mce_result_t.
+ if (S.getOpenCLOptions().isEnabled(
+ "cl_intel_device_side_avc_motion_estimation") &&
+ DestType->isOCLIntelSubgroupAVCType()) {
+ if (DestType->isOCLIntelSubgroupAVCMcePayloadType() ||
+ DestType->isOCLIntelSubgroupAVCMceResultType())
+ return false;
+ if (!IsZeroInitializer(Initializer, S))
return false;
Sequence.AddOCLZeroOpaqueTypeStep(DestType);
@@ -8026,7 +8050,9 @@ InitializationSequence::Perform(Sema &S,
// defined in SPIR spec v1.2 and also opencl-c.h
unsigned AddressingMode = (0x0E & SamplerValue) >> 1;
unsigned FilterMode = (0x30 & SamplerValue) >> 4;
- if (FilterMode != 1 && FilterMode != 2)
+ if (FilterMode != 1 && FilterMode != 2 &&
+ !S.getOpenCLOptions().isEnabled(
+ "cl_intel_device_side_avc_motion_estimation"))
S.Diag(Kind.getLocation(),
diag::warn_sampler_initializer_invalid_bits)
<< "Filter Mode";
@@ -8043,7 +8069,8 @@ InitializationSequence::Perform(Sema &S,
break;
}
case SK_OCLZeroOpaqueType: {
- assert((Step->Type->isEventT() || Step->Type->isQueueT()) &&
+ assert((Step->Type->isEventT() || Step->Type->isQueueT() ||
+ Step->Type->isOCLIntelSubgroupAVCType()) &&
"Wrong type for initialization of OpenCL opaque type.");
CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type,