[llvm-commits] [release_12] CVS: llvm-gcc/gcc/llvm-expand.c

John Criswell criswell at cs.uiuc.edu
Thu Mar 18 17:22:08 PST 2004


Changes in directory llvm-gcc/gcc:

llvm-expand.c updated: 1.30.2.1 -> 1.30.2.2

---
Log message:

Corrected floating point error on Sparc/Solaris again.
This fix, I believe, should work on *all* of the platforms correctly, and
it simplifies the code a lot.
Hopefully someone can test on a 32 bit PowerPC machine to ensure I've done
it right this time.



---
Diffs of the changes:  (+18 -12)

Index: llvm-gcc/gcc/llvm-expand.c
diff -u llvm-gcc/gcc/llvm-expand.c:1.30.2.1 llvm-gcc/gcc/llvm-expand.c:1.30.2.2
--- llvm-gcc/gcc/llvm-expand.c:1.30.2.1	Tue Mar 16 20:42:22 2004
+++ llvm-gcc/gcc/llvm-expand.c	Thu Mar 18 17:21:45 2004
@@ -4957,23 +4957,29 @@
     }    
 
     /* FIXME: This won't work right if endianness is non-agreeing? */
-    
+
+    /*
+     * Here's how this works:
+     *  REAL_VALUE_TO_TARGET_DOUBLE() will generate the floating point number
+     *  as an array of integers in the hosts's representation.  Each integer
+     *  in the array will hold 32 bits of the result REGARDLESS OF THE HOST'S
+     *  INTEGER SIZE.
+     *
+     *  This, then, makes the conversion pretty simple.  The tricky part is
+     *  getting the byte ordering correct and make sure you don't print any
+     *  more than 32 bits per integer on platforms with ints > 32 bits.
+     */
     *BufPtr++ = '0';
     *BufPtr++ = 'x';
     if (!(BYTES_BIG_ENDIAN)) {   /* If little endian */
-      Values = (char*)RealArr+Size;
-      while (Size--) {
-        sprintf(BufPtr, "%02X", (unsigned char)*--Values);
-        BufPtr += 2;
-      }
+      sprintf(Buffer+2,  "%08X", RealArr[1]);
+      sprintf(Buffer+10, "%08X", RealArr[0]);
+      *(Buffer+18) = 0;  /* Null terminate */
     } else {
-      Values = (char*)RealArr;
-      while (Size--) {
-        sprintf(BufPtr, "%02X", (unsigned char)*Values++);
-        BufPtr += 2;
-      }
+      sprintf(Buffer+2,  "%08X", RealArr[0]);
+      sprintf(Buffer+10, "%08X", RealArr[1]);
+      *(Buffer+18) = 0;  /* Null terminate */
     }
-    *BufPtr = 0;  /* Null terminate */
 
     Val = llvm_constant_new(Ty, Buffer);
     break;





More information about the llvm-commits mailing list