diff options
author | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-09-19 17:11:22 +0000 |
---|---|---|
committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2016-09-19 17:11:22 +0000 |
commit | 042acb2cf7384a011464551ed489a1a539509d66 (patch) | |
tree | bbcd77f34f5a74762907c9469039b2b1f4485714 /clang/lib/Sema/SemaDecl.cpp | |
parent | e1d9628bba5f42790ba73d37fe961d560d921408 (diff) | |
download | bcm5719-llvm-042acb2cf7384a011464551ed489a1a539509d66.tar.gz bcm5719-llvm-042acb2cf7384a011464551ed489a1a539509d66.zip |
[OpenCL] Allow half type kernel argument when cl_khr_fp16 is enabled
llvm-svn: 281915
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f7b67658e60..3eb00625a45 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7526,7 +7526,7 @@ enum OpenCLParamType { RecordKernelParam }; -static OpenCLParamType getOpenCLKernelParameterType(QualType PT) { +static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) { if (PT->isPointerType()) { QualType PointeeType = PT->getPointeeType(); if (PointeeType->isPointerType()) @@ -7547,7 +7547,10 @@ static OpenCLParamType getOpenCLKernelParameterType(QualType PT) { if (PT->isEventT()) return InvalidKernelParam; - if (PT->isHalfType()) + // OpenCL extension spec v1.2 s9.5: + // This extension adds support for half scalar and vector types as built-in + // types that can be used for arithmetic operations, conversions etc. + if (!S.getOpenCLOptions().cl_khr_fp16 && PT->isHalfType()) return InvalidKernelParam; if (PT->isRecordType()) @@ -7568,7 +7571,7 @@ static void checkIsValidOpenCLKernelParameter( if (ValidTypes.count(PT.getTypePtr())) return; - switch (getOpenCLKernelParameterType(PT)) { + switch (getOpenCLKernelParameterType(S, PT)) { case PtrPtrKernelParam: // OpenCL v1.2 s6.9.a: // A kernel function argument cannot be declared as a @@ -7595,7 +7598,10 @@ static void checkIsValidOpenCLKernelParameter( // OpenCL v1.2 s6.8 n: // A kernel function argument cannot be declared // 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 elsewhere. + if (!PT->isHalfType()) + S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT; D.setInvalidType(); return; @@ -7651,7 +7657,7 @@ static void checkIsValidOpenCLKernelParameter( if (ValidTypes.count(QT.getTypePtr())) continue; - OpenCLParamType ParamType = getOpenCLKernelParameterType(QT); + OpenCLParamType ParamType = getOpenCLKernelParameterType(S, QT); if (ParamType == ValidKernelParam) continue; |