diff options
author | Chris Lattner <sabre@nondot.org> | 2002-11-07 19:43:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-11-07 19:43:59 +0000 |
commit | eb6f8c757f6c90cf5fb557df1e508e4999604974 (patch) | |
tree | ff6bddc540172403a12624bd35876564e69af050 | |
parent | a4479cd94615f84fe87533081e521669113557c7 (diff) | |
download | external_llvm-eb6f8c757f6c90cf5fb557df1e508e4999604974.zip external_llvm-eb6f8c757f6c90cf5fb557df1e508e4999604974.tar.gz external_llvm-eb6f8c757f6c90cf5fb557df1e508e4999604974.tar.bz2 |
Print out 'float' constants correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4607 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 15 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 15 |
2 files changed, 24 insertions, 6 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 0e274c7..3a0fbe9 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -535,6 +535,7 @@ void CWriter::printModule(Module *M) { << "\n\n/* Support for floating point constants */\n" << "typedef unsigned long long ConstantDoubleTy;\n" + << "typedef unsigned int ConstantFloatTy;\n" << "\n\n/* Global Declarations */\n"; @@ -772,9 +773,17 @@ void CWriter::printFunction(Function *F) { double Val = FPC->getValue(); FPConstantMap[FPC] = FPCounter; // Number the FP constants - Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ - << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec - << "; /* " << Val << " */\n"; + + if (FPC->getType() == Type::DoubleTy) + Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ + << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec + << "; /* " << Val << " */\n"; + else if (FPC->getType() == Type::FloatTy) + Out << " const ConstantFloatTy FloatConstant" << FPCounter++ + << " = 0x" << std::hex << *(unsigned*)&Val << std::dec + << "; /* " << Val << " */\n"; + else + assert(0 && "Unknown float type!"); } Out << "\n"; diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 0e274c7..3a0fbe9 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -535,6 +535,7 @@ void CWriter::printModule(Module *M) { << "\n\n/* Support for floating point constants */\n" << "typedef unsigned long long ConstantDoubleTy;\n" + << "typedef unsigned int ConstantFloatTy;\n" << "\n\n/* Global Declarations */\n"; @@ -772,9 +773,17 @@ void CWriter::printFunction(Function *F) { double Val = FPC->getValue(); FPConstantMap[FPC] = FPCounter; // Number the FP constants - Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ - << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec - << "; /* " << Val << " */\n"; + + if (FPC->getType() == Type::DoubleTy) + Out << " const ConstantDoubleTy FloatConstant" << FPCounter++ + << " = 0x" << std::hex << *(unsigned long long*)&Val << std::dec + << "; /* " << Val << " */\n"; + else if (FPC->getType() == Type::FloatTy) + Out << " const ConstantFloatTy FloatConstant" << FPCounter++ + << " = 0x" << std::hex << *(unsigned*)&Val << std::dec + << "; /* " << Val << " */\n"; + else + assert(0 && "Unknown float type!"); } Out << "\n"; |