[llvm-commits] CVS: llvm/lib/CWriter/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Nov 7 13:45:01 PST 2002


Changes in directory llvm/lib/CWriter:

Writer.cpp updated: 1.71 -> 1.72

---
Log message:

Print out 'float' constants correctly


---
Diffs of the changes:

Index: llvm/lib/CWriter/Writer.cpp
diff -u llvm/lib/CWriter/Writer.cpp:1.71 llvm/lib/CWriter/Writer.cpp:1.72
--- llvm/lib/CWriter/Writer.cpp:1.71	Wed Nov  6 15:40:23 2002
+++ llvm/lib/CWriter/Writer.cpp	Thu Nov  7 13:43:59 2002
@@ -535,6 +535,7 @@
 
       << "\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 @@
         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";





More information about the llvm-commits mailing list