aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2019-03-04 17:51:32 -0800
committerYi Kong <yikong@google.com>2019-03-05 05:33:27 +0000
commita71400342678e0bd321510c0150f7bb30193e49b (patch)
tree0a845285e622edeb57bc86a435dccac020cdfd70
parent748b59d93fc083b42c7530c7c91d3391ba12c3fe (diff)
downloadclang-a71400342678e0bd321510c0150f7bb30193e49b.tar.gz
Revert removal of F16 literal support for non ARM/SPIR Targets
This reverts commit 57a6ce7a and 248e5bf6. frameworks/ml/nn still makes heavy use of _Float16 on x86. Let's keep this working until they figure out a way to avoid using it. Bug: 127391056 Change-Id: I98192c407ec1192ec6e340646ffc2c3d86f83d3b
-rw-r--r--lib/Lex/LiteralSupport.cpp12
-rw-r--r--lib/Sema/SemaType.cpp5
-rw-r--r--test/SemaCUDA/float16.cu7
-rw-r--r--test/SemaCXX/Float16.cpp18
4 files changed, 5 insertions, 37 deletions
diff --git a/lib/Lex/LiteralSupport.cpp b/lib/Lex/LiteralSupport.cpp
index 2108408377..834c80780d 100644
--- a/lib/Lex/LiteralSupport.cpp
+++ b/lib/Lex/LiteralSupport.cpp
@@ -616,14 +616,10 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
if (isHalf || isFloat || isLong || isFloat128)
break; // HF, FF, LF, QF invalid.
- // CUDA host and device may have different _Float16 support, therefore
- // allows f16 literals to avoid false alarm.
- // ToDo: more precise check for CUDA.
- if ((PP.getTargetInfo().hasFloat16Type() || PP.getLangOpts().CUDA) &&
- s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
- s += 2; // success, eat up 2 characters.
- isFloat16 = true;
- continue;
+ if (s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
+ s += 2; // success, eat up 2 characters.
+ isFloat16 = true;
+ continue;
}
isFloat = true;
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 090d9431be..321bed63d9 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -1442,10 +1442,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
Result = Context.Int128Ty;
break;
case DeclSpec::TST_float16:
- // CUDA host and device may have different _Float16 support, therefore
- // do not diagnose _Float16 usage to avoid false alarm.
- // ToDo: more precise diagnostics for CUDA.
- if (!S.Context.getTargetInfo().hasFloat16Type() && !S.getLangOpts().CUDA)
+ if (!S.Context.getTargetInfo().hasFloat16Type())
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported)
<< "_Float16";
Result = Context.Float16Ty;
diff --git a/test/SemaCUDA/float16.cu b/test/SemaCUDA/float16.cu
deleted file mode 100644
index a9cbe87f32..0000000000
--- a/test/SemaCUDA/float16.cu
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify %s
-// expected-no-diagnostics
-#include "Inputs/cuda.h"
-
-__device__ void f(_Float16 x);
-
-__device__ _Float16 x = 1.0f16;
diff --git a/test/SemaCXX/Float16.cpp b/test/SemaCXX/Float16.cpp
deleted file mode 100644
index f27c383985..0000000000
--- a/test/SemaCXX/Float16.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
-// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
-
-#ifdef HAVE
-// expected-no-diagnostics
-#endif // HAVE
-
-#ifndef HAVE
-// expected-error@+2{{_Float16 is not supported on this target}}
-#endif // !HAVE
-_Float16 f;
-
-#ifndef HAVE
-// expected-error@+2{{invalid suffix 'F16' on floating constant}}
-#endif // !HAVE
-const auto g = 1.1F16;