From: Brian Gaeke Date: Wed, 25 Aug 2004 19:37:26 +0000 (+0000) Subject: Previous checkin broke printf(%a) support for fp constants-- re-fix it. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=07b52b367f2c89e21c8c8d8430760575a81adfe7;p=oota-llvm.git Previous checkin broke printf(%a) support for fp constants-- re-fix it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16051 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 960abd9caf8..b8208d4a4c7 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -590,7 +590,15 @@ void CWriter::printConstant(Constant *CPV) { Out << "LLVM_INF" << (FPC->getType() == Type::FloatTy ? "F" : "") << " /*inf*/ "; } else { - std::string Num = ftostr(FPC->getValue()); + std::string Num; +#if HAVE_PRINTF_A + // Print out the constant as a floating point number. + char Buffer[100]; + sprintf(Buffer, "%a", FPC->getValue()); + Num = Buffer; +#else + Num = ftostr(FPC->getValue()); +#endif Out << Num; } } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 960abd9caf8..b8208d4a4c7 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -590,7 +590,15 @@ void CWriter::printConstant(Constant *CPV) { Out << "LLVM_INF" << (FPC->getType() == Type::FloatTy ? "F" : "") << " /*inf*/ "; } else { - std::string Num = ftostr(FPC->getValue()); + std::string Num; +#if HAVE_PRINTF_A + // Print out the constant as a floating point number. + char Buffer[100]; + sprintf(Buffer, "%a", FPC->getValue()); + Num = Buffer; +#else + Num = ftostr(FPC->getValue()); +#endif Out << Num; } }