From 9c1338b71c236bae2db922717af5dddbdd064291 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 7 Nov 2002 22:12:53 +0000 Subject: [PATCH] _REALLY_ fix the float constant problem git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4609 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 7 ++++--- lib/Target/CBackend/Writer.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 3a0fbe99b9b..f318764b026 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -778,11 +778,12 @@ void CWriter::printFunction(Function *F) { Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec << "; /* " << Val << " */\n"; - else if (FPC->getType() == Type::FloatTy) + else if (FPC->getType() == Type::FloatTy) { + float fVal = Val; Out << " const ConstantFloatTy FloatConstant" << FPCounter++ - << " = 0x" << std::hex << *(unsigned*)&Val << std::dec + << " = 0x" << std::hex << *(unsigned*)&fVal << std::dec << "; /* " << Val << " */\n"; - else + } else assert(0 && "Unknown float type!"); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 3a0fbe99b9b..f318764b026 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -778,11 +778,12 @@ void CWriter::printFunction(Function *F) { Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec << "; /* " << Val << " */\n"; - else if (FPC->getType() == Type::FloatTy) + else if (FPC->getType() == Type::FloatTy) { + float fVal = Val; Out << " const ConstantFloatTy FloatConstant" << FPCounter++ - << " = 0x" << std::hex << *(unsigned*)&Val << std::dec + << " = 0x" << std::hex << *(unsigned*)&fVal << std::dec << "; /* " << Val << " */\n"; - else + } else assert(0 && "Unknown float type!"); } -- 2.34.1