From ebbc95da49c6f4ae09947a9f4ab6a8616ea40e3b Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Thu, 9 Aug 2007 22:51:36 +0000 Subject: Patch 10 for long double. Doing constants right needs expanding ConstantFP to handle values bigger than double. If we assume host==target and host long double works correctly, this is not too bad, but we don't want to have that limitation longterm. I could implement accepting double constants as long double or something like that, which would lead to incorrect codegen with no errors; the more I think about that the worse it seems. Rather than do such a hack that would be backed out later, I'm settling for giving reasonable error messages, for now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40974 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Writer/BitcodeWriter.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index c5be80fc50..17c14f0a0d 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -525,11 +525,17 @@ static void WriteConstants(unsigned FirstVal, unsigned LastVal, } } else if (const ConstantFP *CFP = dyn_cast(C)) { Code = bitc::CST_CODE_FLOAT; - if (CFP->getType() == Type::FloatTy) { + const Type *Ty = CFP->getType(); + if (Ty == Type::FloatTy) { Record.push_back(FloatToBits((float)CFP->getValue())); - } else { - assert (CFP->getType() == Type::DoubleTy && "Unknown FP type!"); + } else if (Ty == Type::DoubleTy) { Record.push_back(DoubleToBits((double)CFP->getValue())); + // FIXME: make long double constants work. + } else if (Ty == Type::X86_FP80Ty || + Ty == Type::FP128Ty || Ty == Type::PPC_FP128Ty) { + assert (0 && "Long double constants not handled yet."); + } else { + assert (0 && "Unknown FP type!"); } } else if (isa(C) && cast(C)->isString()) { // Emit constant strings specially. -- cgit v1.2.3-18-g5258