summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-10-17 06:11:48 +0000
committerChris Lattner <sabre@nondot.org>2008-10-17 06:11:48 +0000
commit7e9e3b3d4b394bb2b7b22f026d19ea0d10cd995f (patch)
tree71d89e11edd400b9a72c11a80f718568f01470fc /llvm/lib
parent27f174214df22c5353f7442b5262694426e5c6ed (diff)
downloadbcm5719-llvm-7e9e3b3d4b394bb2b7b22f026d19ea0d10cd995f.tar.gz
bcm5719-llvm-7e9e3b3d4b394bb2b7b22f026d19ea0d10cd995f.zip
add some simple hacky long double support for the CBE. This
should work for intel long double, but ppc long double aborts in convert. llvm-svn: 57672
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/CBackend/CBackend.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Target/CBackend/CBackend.cpp b/llvm/lib/Target/CBackend/CBackend.cpp
index 7ec649d0c52..72bc920b032 100644
--- a/llvm/lib/Target/CBackend/CBackend.cpp
+++ b/llvm/lib/Target/CBackend/CBackend.cpp
@@ -1129,11 +1129,21 @@ void CWriter::printConstant(Constant *CPV, bool Static) {
"long double")
<< "*)&FPConstant" << I->second << ')';
} else {
- assert(FPC->getType() == Type::FloatTy ||
- FPC->getType() == Type::DoubleTy);
- double V = FPC->getType() == Type::FloatTy ?
- FPC->getValueAPF().convertToFloat() :
- FPC->getValueAPF().convertToDouble();
+ double V;
+ if (FPC->getType() == Type::FloatTy)
+ V = FPC->getValueAPF().convertToFloat();
+ else if (FPC->getType() == Type::DoubleTy)
+ V = FPC->getValueAPF().convertToDouble();
+ else {
+ // Long double. Convert the number to double, discarding precision.
+ // This is not awesome, but it at least makes the CBE output somewhat
+ // useful.
+ APFloat Tmp = FPC->getValueAPF();
+ bool LosesInfo;
+ Tmp.convert(APFloat::IEEEdouble, APFloat::rmTowardZero, &LosesInfo);
+ V = Tmp.convertToDouble();
+ }
+
if (IsNAN(V)) {
// The value is NaN
OpenPOWER on IntegriCloud