From 89c89d11070fb2c05e8a883f0d047ab3cd8f8a4c Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Fri, 15 Sep 1995 17:06:46 -0400 Subject: (FLO_union_type): Add words field if double precision to get at the separate words. (FLO_union_type): Add words field if double precision to get at the separate words. (FLO_union_type, pack_d, unpack_d): Use FLOAT_BIT_ORDER_MISMATCH to determine when the bitfields need to be reversed, and FLOAT_WORD_ORDER_MISMATCH when the words need to be reversed. From-SVN: r10357 --- gcc/config/fp-bit.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'gcc') diff --git a/gcc/config/fp-bit.c b/gcc/config/fp-bit.c index 6c7491e..4ee08f1 100644 --- a/gcc/config/fp-bit.c +++ b/gcc/config/fp-bit.c @@ -243,7 +243,11 @@ typedef union FLO_type value; fractype value_raw; -#ifdef FLOAT_WORD_ORDER_MISMATCH +#ifndef FLOAT + halffractype words[2]; +#endif + +#ifdef FLOAT_BIT_ORDER_MISMATCH struct { fractype fraction:FRACBITS __attribute__ ((packed)); @@ -254,8 +258,6 @@ typedef union #endif #ifdef _DEBUG_BITFLOAT - halffractype l[2]; - struct { unsigned int sign:1 __attribute__ ((packed)); @@ -414,7 +416,7 @@ 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 +#ifdef FLOAT_BIT_ORDER_MISMATCH dst.bits.fraction = fraction; dst.bits.exp = exp; dst.bits.sign = sign; @@ -424,6 +426,14 @@ pack_d ( fp_number_type * src) dst.value_raw |= ((fractype) (sign & 1)) << (FRACBITS | EXPBITS); #endif +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT) + { + halffractype tmp = dst.words[0]; + dst.words[0] = dst.words[1]; + dst.words[1] = tmp; + } +#endif + return dst.value; } @@ -437,7 +447,15 @@ unpack_d (FLO_union_type * src, fp_number_type * dst) int exp; int sign; -#ifdef FLOAT_WORD_ORDER_MISMATCH +#if defined(FLOAT_WORD_ORDER_MISMATCH) && !defined(FLOAT) + FLO_union_type swapped; + + swapped.words[0] = src->words[1]; + swapped.words[1] = src->words[0]; + src = &swapped; +#endif + +#ifdef FLOAT_BIT_ORDER_MISMATCH fraction = src->bits.fraction; exp = src->bits.exp; sign = src->bits.sign; -- cgit v1.1