mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-21 23:17:16 +00:00
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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user