summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorPetar Jovanovic <petar.jovanovic@imgtec.com>2015-02-26 18:19:22 +0000
committerPetar Jovanovic <petar.jovanovic@imgtec.com>2015-02-26 18:19:22 +0000
commitd55ae6ba37b158a254d87d7ad8511392b7dadb43 (patch)
treeefabf70df0ba4b7f2a8644399e0d8559a481e825 /clang/lib/AST/ExprConstant.cpp
parentda86749a92f60e63aadd25a3cfed173a1cb189e4 (diff)
downloadbcm5719-llvm-d55ae6ba37b158a254d87d7ad8511392b7dadb43.tar.gz
bcm5719-llvm-d55ae6ba37b158a254d87d7ad8511392b7dadb43.zip
Add support for generating MIPS legacy NaN
Currently, the NaN values emitted for MIPS architectures do not cover non-IEEE754-2008 compliant case. This change fixes the issue. Patch by Vladimir Radosavljevic. Differential Revision: http://reviews.llvm.org/D7882 llvm-svn: 230653
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 6569626a357..083572bc3e1 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -7590,10 +7590,23 @@ static bool TryEvaluateBuiltinNaN(const ASTContext &Context,
else if (S->getString().getAsInteger(0, fill))
return false;
- if (SNaN)
- Result = llvm::APFloat::getSNaN(Sem, false, &fill);
- else
- Result = llvm::APFloat::getQNaN(Sem, false, &fill);
+ if (Context.getTargetInfo().isNan2008()) {
+ if (SNaN)
+ Result = llvm::APFloat::getSNaN(Sem, false, &fill);
+ else
+ Result = llvm::APFloat::getQNaN(Sem, false, &fill);
+ } else {
+ // Prior to IEEE 754-2008, architectures were allowed to choose whether
+ // the first bit of their significand was set for qNaN or sNaN. MIPS chose
+ // a different encoding to what became a standard in 2008, and for pre-
+ // 2008 revisions, MIPS interpreted sNaN-2008 as qNan and qNaN-2008 as
+ // sNaN. This is now known as "legacy NaN" encoding.
+ if (SNaN)
+ Result = llvm::APFloat::getQNaN(Sem, false, &fill);
+ else
+ Result = llvm::APFloat::getSNaN(Sem, false, &fill);
+ }
+
return true;
}
OpenPOWER on IntegriCloud