diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1995-09-11 18:53:34 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1995-09-11 18:53:34 -0400 |
commit | d5f274087565b02a4f56ed90daf7bb0d5b6d5634 (patch) | |
tree | 3c8f1e6284f6e2a0110edfc94ca3e5c9aeab27ac | |
parent | 446c894728d5e93da730764a781454361002048a (diff) | |
download | gcc-d5f274087565b02a4f56ed90daf7bb0d5b6d5634.zip gcc-d5f274087565b02a4f56ed90daf7bb0d5b6d5634.tar.gz gcc-d5f274087565b02a4f56ed90daf7bb0d5b6d5634.tar.bz2 |
(FLO_union_type): Remove bitfields to set sign...
(FLO_union_type): Remove bitfields to set sign, exponent, and
mantissa, and add value_raw field, which is an integer of the
appropriate type. If _DEBUG_BITFLOAT is defined, provide little and
big endian bitfields. If the macro FLOAT_BIT_ORDER_MISMATCH is
defined, use explicit bitfields.
(pack_d, unpack_d): Switch to use value_raw and explicit shifts and
masks so that we don't have to worry about whether the target is big
or little endian unless FLOAT_BIT_ORDER_MISMATCH is defined. If
single precision floating point, rename to pack_f and unpack_f, so
there is no confusion in the debugger.
From-SVN: r10313
-rw-r--r-- | gcc/config/fp-bit.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/gcc/config/fp-bit.c b/gcc/config/fp-bit.c index 3c17f40..6c7491e 100644 --- a/gcc/config/fp-bit.c +++ b/gcc/config/fp-bit.c @@ -243,6 +243,16 @@ typedef union FLO_type value; fractype value_raw; +#ifdef FLOAT_WORD_ORDER_MISMATCH + struct + { + fractype fraction:FRACBITS __attribute__ ((packed)); + unsigned int exp:EXPBITS __attribute__ ((packed)); + unsigned int sign:1 __attribute__ ((packed)); + } + bits; +#endif + #ifdef _DEBUG_BITFLOAT halffractype l[2]; @@ -404,9 +414,16 @@ pack_d ( fp_number_type * src) /* We previously used bitfields to store the number, but this doesn't handle little/big endian systems conviently, so use shifts and masks */ +#ifdef FLOAT_WORD_ORDER_MISMATCH + dst.bits.fraction = fraction; + dst.bits.exp = exp; + dst.bits.sign = sign; +#else dst.value_raw = fraction & ((((fractype)1) << FRACBITS) - (fractype)1); dst.value_raw |= ((fractype) (exp & ((1 << EXPBITS) - 1))) << FRACBITS; dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS); +#endif + return dst.value; } @@ -416,9 +433,19 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) /* We previously used bitfields to store the number, but this doesn't handle little/big endian systems conviently, so use shifts and masks */ - fractype fraction = src->value_raw & ((((fractype)1) << FRACBITS) - (fractype)1); - int exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1); - int sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1; + fractype fraction; + int exp; + int sign; + +#ifdef FLOAT_WORD_ORDER_MISMATCH + fraction = src->bits.fraction; + exp = src->bits.exp; + sign = src->bits.sign; +#else + fraction = src->value_raw & ((((fractype)1) << FRACBITS) - (fractype)1); + exp = ((int)(src->value_raw >> FRACBITS)) & ((1 << EXPBITS) - 1); + sign = ((int)(src->value_raw >> (FRACBITS + EXPBITS))) & 1; +#endif dst->sign = sign; if (exp == 0) |