diff options
author | Anastasia Stulova <anastasia.stulova@arm.com> | 2016-02-17 11:34:37 +0000 |
---|---|---|
committer | Anastasia Stulova <anastasia.stulova@arm.com> | 2016-02-17 11:34:37 +0000 |
commit | 5c1a2c5d3e8f854ead984c022647be4c1d6bf178 (patch) | |
tree | 4b1e9ef378b5919d1bb2b9935a25268957cad21f /clang/lib/Lex/LiteralSupport.cpp | |
parent | 219fae9e36b0c2ca895db1b784337b2843c4f00b (diff) | |
download | bcm5719-llvm-5c1a2c5d3e8f854ead984c022647be4c1d6bf178.tar.gz bcm5719-llvm-5c1a2c5d3e8f854ead984c022647be4c1d6bf178.zip |
[OpenCL] Added half type literal with suffix h.
OpenCL Extension v1.2 s9.5 allows half precision floating point
type literals with suffices h or H when cl_khr_fp16 is enabled.
Example: half x = 1.0h;
Patch by Liu Yaxun (Sam)!
Differential Revision: http://reviews.llvm.org/D16865
llvm-svn: 261084
Diffstat (limited to 'clang/lib/Lex/LiteralSupport.cpp')
-rw-r--r-- | clang/lib/Lex/LiteralSupport.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index 0c0626c8a85..57494f87433 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -522,6 +522,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isLong = false; isUnsigned = false; isLongLong = false; + isHalf = false; isFloat = false; isImaginary = false; MicrosoftInteger = 0; @@ -555,10 +556,18 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, // we break out of the loop. for (; s != ThisTokEnd; ++s) { switch (*s) { + case 'h': // FP Suffix for "half". + case 'H': + // OpenCL Extension v1.2 s9.5 - h or H suffix for half type. + if (!PP.getLangOpts().Half) break; + if (!isFPConstant) break; // Error for integer constant. + if (isHalf || isFloat || isLong) break; // HH, FH, LH invalid. + isHalf = true; + continue; // Success. case 'f': // FP Suffix for "float" case 'F': if (!isFPConstant) break; // Error for integer constant. - if (isFloat || isLong) break; // FF, LF invalid. + if (isHalf || isFloat || isLong) break; // HF, FF, LF invalid. isFloat = true; continue; // Success. case 'u': @@ -570,7 +579,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, case 'l': case 'L': if (isLong || isLongLong) break; // Cannot be repeated. - if (isFloat) break; // LF invalid. + if (isHalf || isFloat) break; // LH, LF invalid. // Check for long long. The L's need to be adjacent and the same case. if (s[1] == s[0]) { @@ -647,6 +656,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, isUnsigned = false; isLongLong = false; isFloat = false; + isHalf = false; isImaginary = false; MicrosoftInteger = 0; |