From 07b52b367f2c89e21c8c8d8430760575a81adfe7 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Wed, 25 Aug 2004 19:37:26 +0000 Subject: [PATCH] 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 --- lib/Target/CBackend/CBackend.cpp | 10 +++++++++- lib/Target/CBackend/Writer.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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; } } -- 2.34.1