This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
definition of REAL_VALUE_TYPE is wrong...
- From: <apl at alum dot mit dot edu>
- To: gcc at gcc dot gnu dot org
- Cc: apl at alum dot mit dot edu
- Date: Thu, 28 Mar 2002 15:56:57 -0500 (EST)
- Subject: definition of REAL_VALUE_TYPE is wrong...
I have a machine with JUST a 32-bit float as the only real type.
It also is word addressed (BITS_PER_UNIT == 32)
The definition in real.h does the wrong thing, resulting in the
REAL_VALUE_TYPE having an array of 1 HOST_WIDE_INT (which on a sparc host
is 32 bits. This causes all sorts of havoc when converting a
CONST_DOUBLE to a float via
REAL_VALUE_FROM_CONST_DOUBLE (rv, x);
REAL_VALUE_TO_TARGET_SINGLE (rv, value);
The first macro only moves 32 bits of the CONST_DOUBLE to rv,
and the conversion to single appears to use 64 bits (only 32 of
which were ever initialized...
Here's the cut down definition that I see, Note that
MAX_LONG_DOUBLE_TYPE_SIZE defaults to 64 (which would match the
size of the CONST_DOUBLE values maintained on the host side.
#define N (MAX_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
#define S sizeof (HOST_WIDE_INT)
typedef struct {
HOST_WIDE_INT r[N/S + (N%S ? 1 : 0)]; /* round up */
} REAL_VALUE_TYPE;
But that only works correctly on machines where the HOST and TARGET
have the same size units (e.g. both 8-bit byte machines), and fails
when either the host or target have funny machine word sizes.
If we used HOST_BITS_PER_CHAR, we might get a better result, although
I think it really should be using HOST_BITS_PER_LONG and something
more like:
#define N (MAX_LONG_DOUBLE_TYPE_SIZE / HOST_BITS_PER_LONG)
#define S (MAX_LONG_DOUBLE_TYPE_SIZE % HOST_BITS_PER_LONG)
typedef struct {
HOST_WIDE_INT r[N + (S ? 1 : 0)]; /* round up */
} REAL_VALUE_TYPE;
Is there a better way to fix this than
Index: real.h
===================================================================
RCS file: /export/home/cvsroot/uberbaum/gcc/real.h,v
retrieving revision 1.1.1.9
diff -u -r1.1.1.9 real.h
--- real.h 2002/03/26 14:58:45 1.1.1.9
+++ real.h 2002/03/28 20:18:19
@@ -79,13 +79,13 @@
required to hold MAX_LONG_DOUBLE_TYPE_SIZE bits. */
#if MAX_LONG_DOUBLE_TYPE_SIZE == 128
/* For 128 bit reals, we calculate internally with extra precision. */
-#define N (160 / BITS_PER_UNIT)
+#define N (160 / HOST_BITS_PER_LONG)
#else
-#define N (MAX_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT)
+#define N (MAX_LONG_DOUBLE_TYPE_SIZE / HOST_BITS_PER_LONG)
#endif
-#define S sizeof (HOST_WIDE_INT)
+#define S (MAX_LONG_DOUBLE_TYPE_SIZE % HOST_BITS_PER_LONG)
typedef struct {
- HOST_WIDE_INT r[N/S + (N%S ? 1 : 0)]; /* round up */
+ HOST_WIDE_INT r[N + (S ? 1 : 0)]; /* round up */
} REAL_VALUE_TYPE;
#undef N
#undef S