diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-23 11:26:29 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-23 11:26:29 +0000 |
commit | e68e77569ff424d7c28f7386434103ecf2ebb9cb (patch) | |
tree | 6f26226007f2aa48bfd5f90897d969957656f492 /lib | |
parent | d25dc3358bc81d380eb09f59b4d29dd6c53215ac (diff) | |
download | external_llvm-e68e77569ff424d7c28f7386434103ecf2ebb9cb.zip external_llvm-e68e77569ff424d7c28f7386434103ecf2ebb9cb.tar.gz external_llvm-e68e77569ff424d7c28f7386434103ecf2ebb9cb.tar.bz2 |
Move ftostr into its last user (cppbackend) and simplify it a bit.
New code should use raw_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153326 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 12 | ||||
-rw-r--r-- | lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 107c6cc..efa54d2 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -195,6 +195,18 @@ void CppWriter::error(const std::string& msg) { report_fatal_error(msg); } +static inline std::string ftostr(const APFloat& V) { + std::string Buf; + if (&V.getSemantics() == &APFloat::IEEEdouble) { + raw_string_ostream(Buf) << V.convertToDouble(); + return Buf; + } else if (&V.getSemantics() == &APFloat::IEEEsingle) { + raw_string_ostream(Buf) << (double)V.convertToFloat(); + return Buf; + } + return "<unknown format in ftostr>"; // error +} + // printCFP - Print a floating point constant .. very carefully :) // This makes sure that conversion to/from floating yields the same binary // result so that we don't lose precision. diff --git a/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp b/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp index ec7e2a7..80fb4de 100644 --- a/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp +++ b/lib/Target/PTX/InstPrinter/PTXInstPrinter.cpp @@ -18,6 +18,7 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/ADT/APFloat.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" |