aboutsummaryrefslogtreecommitdiffstats
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
commitabec474236601d7c10469a212decd010727ba060 (patch)
tree230fbb88bcd584a59f24b3f6e87a9f44b3fc2faa
parentb2a14325079f64debd7df6d5a8ed2037b3128154 (diff)
downloadexternal_llvm-abec474236601d7c10469a212decd010727ba060.zip
external_llvm-abec474236601d7c10469a212decd010727ba060.tar.gz
external_llvm-abec474236601d7c10469a212decd010727ba060.tar.bz2
add some simple hacky long double support for the CBE. This
should work for intel long double, but ppc long double aborts in convert. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57672 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/CBackend/CBackend.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp
index 7ec649d..72bc920 100644
--- a/lib/Target/CBackend/CBackend.cpp
+++ b/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