diff options
author | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-09-11 22:53:34 +0000 |
---|---|---|
committer | kenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4> | 1995-09-11 22:53:34 +0000 |
commit | 30b51a2932f54b6ef6dbf1507a14afa9dac51349 (patch) | |
tree | 3c8f1e6284f6e2a0110edfc94ca3e5c9aeab27ac /gcc/config/fp-bit.c | |
parent | 617de311b3d9dd917e953df72d286b4bdf4a0ede (diff) | |
download | gcc-30b51a2932f54b6ef6dbf1507a14afa9dac51349.tar.gz |
(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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@10313 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/fp-bit.c')
-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 3c17f402e23..6c7491e35b6 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) |