aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/open.c
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2022-01-09 16:35:21 +0100
committerJakub Jelinek <jakub@redhat.com>2022-01-11 23:49:52 +0100
commit9840285d877c5820d75d1347fc2a4f176ab31b11 (patch)
treed26cdaba1d95d45635a068634a0b4285e3c1c813 /libgfortran/io/open.c
parente79f6e61d5849408c3137dbfa5d49e7066f9df7b (diff)
downloadgcc-9840285d877c5820d75d1347fc2a4f176ab31b11.zip
gcc-9840285d877c5820d75d1347fc2a4f176ab31b11.tar.gz
gcc-9840285d877c5820d75d1347fc2a4f176ab31b11.tar.bz2
Implement CONVERT specifier for OPEN.
This patch, based on Jakub's work, implements the CONVERT specifier for the power-ieee128 brach. It allows specifying the conversion as r16_ieee,big_endian and the other way around, based on a table. Setting the conversion via environment variable and via program option does not yet work. gcc/ChangeLog: * flag-types.h (enum gfc_convert): Add flags for conversion. gcc/fortran/ChangeLog: * libgfortran.h (unit_convert): Add flags. libgfortran/ChangeLog: * Makefile.in: Regenerate. * io/file_pos.c (unformatted_backspace): Mask off R16 parts for convert. * io/inquire.c (inquire_via_unit): Add cases for R16 parts. * io/open.c (st_open): Add cases for R16 conversion. * io/transfer.c (unformatted_read): Adjust for R16 conversions. (unformatted_write): Likewise. (us_read): Mask of R16 bits. (data_transfer_init): Likewiese. (write_us_marker): Likewise.
Diffstat (limited to 'libgfortran/io/open.c')
-rw-r--r--libgfortran/io/open.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index dfa04d0..c9276c7 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -153,6 +153,28 @@ static const st_option convert_opt[] =
{ "swap", GFC_CONVERT_SWAP},
{ "big_endian", GFC_CONVERT_BIG},
{ "little_endian", GFC_CONVERT_LITTLE},
+#ifdef HAVE_GFC_REAL_17
+ /* Rather than write a special parsing routine, enumerate all the
+ possibilities here. */
+ { "r16_ieee", GFC_CONVERT_R16_IEEE},
+ { "r16_ibm", GFC_CONVERT_R16_IBM},
+ { "native,r16_ieee", GFC_CONVERT_R16_IEEE},
+ { "native,r16_ibm", GFC_CONVERT_R16_IBM},
+ { "r16_ieee,native", GFC_CONVERT_R16_IEEE},
+ { "r16_ibm,native", GFC_CONVERT_R16_IBM},
+ { "swap,r16_ieee", GFC_CONVERT_R16_IEEE_SWAP},
+ { "swap,r16_ibm", GFC_CONVERT_R16_IBM_SWAP},
+ { "r16_ieee,swap", GFC_CONVERT_R16_IEEE_SWAP},
+ { "r16_ibm,swap", GFC_CONVERT_R16_IBM_SWAP},
+ { "big_endian,r16_ieee", GFC_CONVERT_R16_IEEE_BIG},
+ { "big_endian,r16_ibm", GFC_CONVERT_R16_IBM_BIG},
+ { "r16_ieee,big_endian", GFC_CONVERT_R16_IEEE_BIG},
+ { "r16_ibm,big_endian", GFC_CONVERT_R16_IBM_BIG},
+ { "little_endian,r16_ieee", GFC_CONVERT_R16_IEEE_LITTLE},
+ { "little_endian,r16_ibm", GFC_CONVERT_R16_IBM_LITTLE},
+ { "r16_ieee,little_endian", GFC_CONVERT_R16_IEEE_LITTLE},
+ { "r16_ibm,little_endian", GFC_CONVERT_R16_IBM_LITTLE},
+#endif
{ NULL, 0}
};
@@ -820,7 +842,14 @@ st_open (st_parameter_open *opp)
else
conv = compile_options.convert;
}
-
+
+ flags.convert = 0;
+
+#ifdef HAVE_GFC_REAL_17
+ flags.convert = conv & (GFC_CONVERT_R16_IEEE | GFC_CONVERT_R16_IBM);
+ conv &= ~(GFC_CONVERT_R16_IEEE | GFC_CONVERT_R16_IBM);
+#endif
+
switch (conv)
{
case GFC_CONVERT_NATIVE:
@@ -840,7 +869,7 @@ st_open (st_parameter_open *opp)
break;
}
- flags.convert = conv;
+ flags.convert |= conv;
if (flags.position != POSITION_UNSPECIFIED
&& flags.access == ACCESS_DIRECT)