diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2022-01-15 11:31:38 +0100 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2022-01-15 11:31:38 +0100 |
commit | 02229c0ce3f2dc04d5e79d0967b8a6545cc284a6 (patch) | |
tree | 674f339f4fba31b06acadb22e38b078e409059e5 | |
parent | f660638317ef7c79eee6640d0275c9e8fc34beba (diff) | |
parent | dffb2646d1c231dbe1159e1d4cfeab374adf91af (diff) | |
download | gcc-devel/power-ieee128.zip gcc-devel/power-ieee128.tar.gz gcc-devel/power-ieee128.tar.bz2 |
Merge branch 'devel/power-ieee128' of git+ssh://gcc.gnu.org/git/gcc into devel/power-ieee128devel/power-ieee128
-rw-r--r-- | libgfortran/io/transfer.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 1e73874..ee6fed7 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -1145,11 +1145,28 @@ unformatted_read (st_parameter_dt *dtp, bt type, size /= 2; } #ifndef HAVE_GFC_REAL_17 +#if defined(HAVE_GFC_REAL_16) && GFC_REAL_16_DIGITS == 106 + /* IBM extended format is stored as a pair of IEEE754 + double values, with the more significant value first + in both big and little endian. */ + if (kind == 16 && (type == BT_REAL || type == BT_COMPLEX)) + { + nelems *= 2; + size /= 2; + } +#endif bswap_array (dest, dest, size, nelems); #else unit_convert bswap = convert & ~(GFC_CONVERT_R16_IEEE | GFC_CONVERT_R16_IBM); if (bswap == GFC_CONVERT_SWAP) - bswap_array (dest, dest, size, nelems); + { + if ((type == BT_REAL || type == BT_COMPLEX) + && ((kind == 16 && (convert & GFC_CONVERT_R16_IEEE) == 0) + || (kind == 17 && (convert & GFC_CONVERT_R16_IBM)))) + bswap_array (dest, dest, size / 2, nelems * 2); + else + bswap_array (dest, dest, size, nelems); + } if ((convert & GFC_CONVERT_R16_IEEE) && kind == 16 @@ -1274,6 +1291,18 @@ unformatted_write (st_parameter_dt *dtp, bt type, size /= 2; } +#if !defined(HAVE_GFC_REAL_17) && defined(HAVE_GFC_REAL_16) \ + && GFC_REAL_16_DIGITS == 106 + /* IBM extended format is stored as a pair of IEEE754 + double values, with the more significant value first + in both big and little endian. */ + if (kind == 16 && (type == BT_REAL || type == BT_COMPLEX)) + { + nelems *= 2; + size /= 2; + } +#endif + /* By now, all complex variables have been split into their constituent reals. */ @@ -1321,7 +1350,12 @@ unformatted_write (st_parameter_dt *dtp, bt type, if ((dtp->u.p.current_unit->flags.convert & ~(GFC_CONVERT_R16_IEEE | GFC_CONVERT_R16_IBM)) == GFC_CONVERT_SWAP) - bswap_array (buffer, buffer, size, nc); + bswap_array (buffer, buffer, size / 2, nc * 2); + } + else if (kind == 16 && (type == BT_REAL || type == BT_COMPLEX)) + { + bswap_array (buffer, p, size / 2, nc * 2); + p += size * nc; } else #endif |