aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/Makefile.in3
-rw-r--r--gcc/config/dfp-bit.c74
-rw-r--r--gcc/dfp.c90
4 files changed, 38 insertions, 144 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9360ae0..9bcfca1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2007-09-10 Janis Johnson <janis187@us.ibm.com>
+ Ben Elliston <bje@au.ibm.com>
+
+ * dfp.c: Include decimal128Local.h;
+ (dfp_byte_swap): Remove.
+ (encode_decimal32, decode_decimal32): Don't handle endianness.
+ (encode_decimal64, decode_decimal64): Ditto.
+ (encode_decimal128, decode_decimal128): Ditto.
+ * config/dfp-bit.c (host_to_ieee32, ieee_to_host_32): Ditto.
+ (__swap64): Remove.
+ (host_to_ieee_64, ieee_to_host_64): Don't handle endianness.
+ (__swap128): Remove
+ (host_to_ieee_128, ieee_to_host_128): Don't handle endianness.
+ * Makefile.in (DECNUM_H): Add decimal128Local.h.
+
2007-09-10 David Daney <ddaney@avtrex.com>
* config/mips/mips.md (UNSPEC_MEMORY_BARRIER): New entry in
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 273dda5..ef7a949 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -815,7 +815,8 @@ PREDICT_H = predict.h predict.def
CPPLIB_H = $(srcdir)/../libcpp/include/line-map.h \
$(srcdir)/../libcpp/include/cpplib.h
DECNUM_H = $(DECNUM)/decContext.h $(DECNUM)/decDPD.h $(DECNUM)/decNumber.h \
- $(DECNUMFMT)/decimal32.h $(DECNUMFMT)/decimal64.h $(DECNUMFMT)/decimal128.h
+ $(DECNUMFMT)/decimal32.h $(DECNUMFMT)/decimal64.h \
+ $(DECNUMFMT)/decimal128.h $(DECNUMFMT)/decimal128Local.h
MKDEPS_H = $(srcdir)/../libcpp/include/mkdeps.h
SYMTAB_H = $(srcdir)/../libcpp/include/symtab.h
CPP_ID_DATA_H = $(CPPLIB_H) $(srcdir)/../libcpp/include/cpp-id-data.h
diff --git a/gcc/config/dfp-bit.c b/gcc/config/dfp-bit.c
index 325306a..252abe0 100644
--- a/gcc/config/dfp-bit.c
+++ b/gcc/config/dfp-bit.c
@@ -70,8 +70,6 @@ typedef decNumber* (*dfp_unary_func)
/* A pointer to a binary decNumber operation. */
typedef decNumber* (*dfp_binary_func)
(decNumber *, const decNumber *, const decNumber *, decContext *);
-
-extern uint32_t __dec_byte_swap (uint32_t);
/* Unary operations. */
@@ -190,101 +188,41 @@ dfp_compare_op (dfp_binary_func op, DFP_C_TYPE arg_a, DFP_C_TYPE arg_b)
void
__host_to_ieee_32 (_Decimal32 in, decimal32 *out)
{
- uint32_t t;
-
- if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
- {
- memcpy (&t, &in, 4);
- t = __dec_byte_swap (t);
- memcpy (out, &t, 4);
- }
- else
- memcpy (out, &in, 4);
+ memcpy (out, &in, 4);
}
void
__ieee_to_host_32 (decimal32 in, _Decimal32 *out)
{
- uint32_t t;
-
- if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
- {
- memcpy (&t, &in, 4);
- t = __dec_byte_swap (t);
- memcpy (out, &t, 4);
- }
- else
- memcpy (out, &in, 4);
+ memcpy (out, &in, 4);
}
#endif /* L_conv_sd */
#if defined(L_conv_dd)
-static void
-__swap64 (char *src, char *dst)
-{
- uint32_t t1, t2;
-
- if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
- {
- memcpy (&t1, src, 4);
- memcpy (&t2, src + 4, 4);
- t1 = __dec_byte_swap (t1);
- t2 = __dec_byte_swap (t2);
- memcpy (dst, &t2, 4);
- memcpy (dst + 4, &t1, 4);
- }
- else
- memcpy (dst, src, 8);
-}
-
void
__host_to_ieee_64 (_Decimal64 in, decimal64 *out)
{
- __swap64 ((char *) &in, (char *) out);
+ memcpy (out, &in, 8);
}
void
__ieee_to_host_64 (decimal64 in, _Decimal64 *out)
{
- __swap64 ((char *) &in, (char *) out);
+ memcpy (out, &in, 8);
}
#endif /* L_conv_dd */
#if defined(L_conv_td)
-static void
-__swap128 (char *src, char *dst)
-{
- uint32_t t1, t2, t3, t4;
-
- if (!LIBGCC2_FLOAT_WORDS_BIG_ENDIAN)
- {
- memcpy (&t1, src, 4);
- memcpy (&t2, src + 4, 4);
- memcpy (&t3, src + 8, 4);
- memcpy (&t4, src + 12, 4);
- t1 = __dec_byte_swap (t1);
- t2 = __dec_byte_swap (t2);
- t3 = __dec_byte_swap (t3);
- t4 = __dec_byte_swap (t4);
- memcpy (dst, &t4, 4);
- memcpy (dst + 4, &t3, 4);
- memcpy (dst + 8, &t2, 4);
- memcpy (dst + 12, &t1, 4);
- }
- else
- memcpy (dst, src, 16);
-}
-
void
__host_to_ieee_128 (_Decimal128 in, decimal128 *out)
{
- __swap128 ((char *) &in, (char *) out);
+ memcpy (out, &in, 16);
}
void
__ieee_to_host_128 (decimal128 in, _Decimal128 *out)
{
- __swap128 ((char *) &in, (char *) out);
+ memcpy (out, &in, 16);
}
#endif /* L_conv_td */
diff --git a/gcc/dfp.c b/gcc/dfp.c
index 2328589..88ffded 100644
--- a/gcc/dfp.c
+++ b/gcc/dfp.c
@@ -31,29 +31,11 @@ along with GCC; see the file COPYING3. If not see
decNumber structure is large enough to hold decimal128 digits. */
#include "decimal128.h"
+#include "decimal128Local.h"
#include "decimal64.h"
#include "decimal32.h"
#include "decNumber.h"
-static uint32_t
-dfp_byte_swap (uint32_t in)
-{
- uint32_t out = 0;
- unsigned char *p = (unsigned char *) &out;
- union {
- uint32_t i;
- unsigned char b[4];
- } u;
-
- u.i = in;
- p[0] = u.b[3];
- p[1] = u.b[2];
- p[2] = u.b[1];
- p[3] = u.b[0];
-
- return out;
-}
-
/* Initialize R (a real with the decimal flag set) from DN. Can
utilize status passed in via CONTEXT, if a previous operation had
interesting status. */
@@ -155,10 +137,7 @@ encode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal32FromNumber (&d32, &dn, &set);
- if (FLOAT_WORDS_BIG_ENDIAN)
- buf[0] = *(uint32_t *) d32.bytes;
- else
- buf[0] = dfp_byte_swap (*(uint32_t *) d32.bytes);
+ buf[0] = *(uint32_t *) d32.bytes;
}
/* Decode an IEEE 754R decimal32 type into a real. */
@@ -174,10 +153,7 @@ decode_decimal32 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
- if (FLOAT_WORDS_BIG_ENDIAN)
- *((uint32_t *) d32.bytes) = (uint32_t) buf[0];
- else
- *((uint32_t *) d32.bytes) = dfp_byte_swap ((uint32_t) buf[0]);
+ *((uint32_t *) d32.bytes) = (uint32_t) buf[0];
decimal32ToNumber (&d32, &dn);
decimal_from_decnumber (r, &dn, &set);
@@ -199,16 +175,8 @@ encode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal64FromNumber (&d64, &dn, &set);
- if (FLOAT_WORDS_BIG_ENDIAN)
- {
- buf[0] = *(uint32_t *) &d64.bytes[0];
- buf[1] = *(uint32_t *) &d64.bytes[4];
- }
- else
- {
- buf[1] = dfp_byte_swap (*(uint32_t *) &d64.bytes[0]);
- buf[0] = dfp_byte_swap (*(uint32_t *) &d64.bytes[4]);
- }
+ buf[0] = *(uint32_t *) &d64.bytes[0];
+ buf[1] = *(uint32_t *) &d64.bytes[4];
}
/* Decode an IEEE 754R decimal64 type into a real. */
@@ -224,16 +192,8 @@ decode_decimal64 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
- if (FLOAT_WORDS_BIG_ENDIAN)
- {
- *((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[0];
- *((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[1];
- }
- else
- {
- *((uint32_t *) &d64.bytes[0]) = dfp_byte_swap ((uint32_t) buf[1]);
- *((uint32_t *) &d64.bytes[4]) = dfp_byte_swap ((uint32_t) buf[0]);
- }
+ *((uint32_t *) &d64.bytes[0]) = (uint32_t) buf[0];
+ *((uint32_t *) &d64.bytes[4]) = (uint32_t) buf[1];
decimal64ToNumber (&d64, &dn);
decimal_from_decnumber (r, &dn, &set);
@@ -255,20 +215,10 @@ encode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decimal_to_decnumber (r, &dn);
decimal128FromNumber (&d128, &dn, &set);
- if (FLOAT_WORDS_BIG_ENDIAN)
- {
- buf[0] = *(uint32_t *) &d128.bytes[0];
- buf[1] = *(uint32_t *) &d128.bytes[4];
- buf[2] = *(uint32_t *) &d128.bytes[8];
- buf[3] = *(uint32_t *) &d128.bytes[12];
- }
- else
- {
- buf[0] = dfp_byte_swap (*(uint32_t *) &d128.bytes[12]);
- buf[1] = dfp_byte_swap (*(uint32_t *) &d128.bytes[8]);
- buf[2] = dfp_byte_swap (*(uint32_t *) &d128.bytes[4]);
- buf[3] = dfp_byte_swap (*(uint32_t *) &d128.bytes[0]);
- }
+ buf[0] = *(uint32_t *) &d128.bytes[0];
+ buf[1] = *(uint32_t *) &d128.bytes[4];
+ buf[2] = *(uint32_t *) &d128.bytes[8];
+ buf[3] = *(uint32_t *) &d128.bytes[12];
}
/* Decode an IEEE 754R decimal128 type into a real. */
@@ -284,20 +234,10 @@ decode_decimal128 (const struct real_format *fmt ATTRIBUTE_UNUSED,
decContextDefault (&set, DEC_INIT_DECIMAL128);
set.traps = 0;
- if (FLOAT_WORDS_BIG_ENDIAN)
- {
- *((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[0];
- *((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[1];
- *((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[2];
- *((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[3];
- }
- else
- {
- *((uint32_t *) &d128.bytes[0]) = dfp_byte_swap ((uint32_t) buf[3]);
- *((uint32_t *) &d128.bytes[4]) = dfp_byte_swap ((uint32_t) buf[2]);
- *((uint32_t *) &d128.bytes[8]) = dfp_byte_swap ((uint32_t) buf[1]);
- *((uint32_t *) &d128.bytes[12]) = dfp_byte_swap ((uint32_t) buf[0]);
- }
+ *((uint32_t *) &d128.bytes[0]) = (uint32_t) buf[0];
+ *((uint32_t *) &d128.bytes[4]) = (uint32_t) buf[1];
+ *((uint32_t *) &d128.bytes[8]) = (uint32_t) buf[2];
+ *((uint32_t *) &d128.bytes[12]) = (uint32_t) buf[3];
decimal128ToNumber (&d128, &dn);
decimal_from_decnumber (r, &dn, &set);