Prepare the writer for a non-broken implementation of writing floating
authorReid Spencer <rspencer@reidspencer.com>
Sun, 11 Jul 2004 17:22:07 +0000 (17:22 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Sun, 11 Jul 2004 17:22:07 +0000 (17:22 +0000)
point values. This will be fixed when I figure out how to do it correctly
without depending on knowing the endianess of a platform.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14762 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Writer/ConstantWriter.cpp
lib/Bytecode/Writer/WriterPrimitives.h

index 029e6cc2b5410ca5804fe87854d229fed6606afb..8ea192b0a82f8af1a5ab190a07fc08adcf19dd16 100644 (file)
@@ -176,12 +176,12 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
 
   case Type::FloatTyID: {   // Floating point types...
     float Tmp = (float)cast<ConstantFP>(CPV)->getValue();
-    output_data(&Tmp, &Tmp+1, Out);
+    output_float(Tmp, Out);
     break;
   }
   case Type::DoubleTyID: {
     double Tmp = cast<ConstantFP>(CPV)->getValue();
-    output_data(&Tmp, &Tmp+1, Out);
+    output_double(Tmp, Out);
     break;
   }
 
index b76cc55e163d74daae8a980fcdb777fb2d0198eb..02c225baf1bca741392a2bbab32b49d0cf9c4b66 100644 (file)
@@ -119,6 +119,23 @@ static inline void output_data(const void *Ptr, const void *End,
   Out.insert(Out.end(), (const unsigned char*)Ptr, (const unsigned char*)End);
 }
 
+static inline void output_float(float& FloatVal, 
+                               std::deque<unsigned char>& Out) {
+  /// FIXME: This is a broken implementation! It writes
+  /// it in a platform-specific endianess. Need to make
+  /// it little endian always.
+  output_data(&FloatVal, &FloatVal+1, Out);
+}
+
+static inline void output_double(double& DoubleVal, 
+                               std::deque<unsigned char>& Out) {
+  /// FIXME: This is a broken implementation! It writes
+  /// it in a platform-specific endianess. Need to make
+  /// it little endian always.
+  output_data(&DoubleVal, &DoubleVal+1, Out);
+}
+
 } // End llvm namespace
 
+// vim: sw=2 ai
 #endif