[llvm-commits] [llvm] r57672 - /llvm/trunk/lib/Target/CBackend/CBackend.cpp
Chris Lattner
sabre at nondot.org
Thu Oct 16 23:11:49 PDT 2008
Author: lattner
Date: Fri Oct 17 01:11:48 2008
New Revision: 57672
URL: http://llvm.org/viewvc/llvm-project?rev=57672&view=rev
Log:
add some simple hacky long double support for the CBE. This
should work for intel long double, but ppc long double aborts
in convert.
Modified:
llvm/trunk/lib/Target/CBackend/CBackend.cpp
Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=57672&r1=57671&r2=57672&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original)
+++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Fri Oct 17 01:11:48 2008
@@ -1129,11 +1129,21 @@
"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
More information about the llvm-commits
mailing list