[llvm-commits] CVS: llvm/lib/Bytecode/Writer/ConstantWriter.cpp WriterPrimitives.h

LLVM llvm at cs.uiuc.edu
Sun Jul 11 12:23:02 PDT 2004


Changes in directory llvm/lib/Bytecode/Writer:

ConstantWriter.cpp updated: 1.38 -> 1.39
WriterPrimitives.h updated: 1.5 -> 1.6

---
Log message:

Prepare the writer for a non-broken implementation of writing floating
point values. This will be fixed when I figure out how to do it correctly
without depending on knowing the endianess of a platform.


---
Diffs of the changes:  (+19 -2)

Index: llvm/lib/Bytecode/Writer/ConstantWriter.cpp
diff -u llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.38 llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.39
--- llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.38	Sun Jul  4 06:37:54 2004
+++ llvm/lib/Bytecode/Writer/ConstantWriter.cpp	Sun Jul 11 12:22:07 2004
@@ -176,12 +176,12 @@
 
   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: llvm/lib/Bytecode/Writer/WriterPrimitives.h
diff -u llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.5 llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.6
--- llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.5	Thu Jun 24 19:11:25 2004
+++ llvm/lib/Bytecode/Writer/WriterPrimitives.h	Sun Jul 11 12:22:07 2004
@@ -119,6 +119,23 @@
   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





More information about the llvm-commits mailing list