+2006-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/26769
+ * iresolve.c (gfc_resolve_reshape): Use reshape_r16 for real(16).
+ (gfc_resolve_transpose): Use transpose_r16 for real(16).
+
2006-04-21 Paul Thomas <pault@gcc.gnu.org>
PR fortran/27122
/* Intrinsic function resolution.
- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
- Inc.
+ Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
+ Free Software Foundation, Inc.
Contributed by Andy Vaught & Katherine Holcomb
This file is part of GCC.
f->value.function.name =
gfc_get_string (PREFIX("reshape_%c%d"),
gfc_type_letter (BT_COMPLEX), source->ts.kind);
- else if (source->ts.type == BT_REAL && kind == 10)
+ else if (source->ts.type == BT_REAL && (kind == 10 || kind == 16))
f->value.function.name =
gfc_get_string (PREFIX("reshape_%c%d"),
gfc_type_letter (BT_REAL), source->ts.kind);
break;
case BT_REAL:
- /* There is no kind=10 integer type. We need to
+ /* There is no kind=10 integer type and on 32-bit targets
+ there is usually no kind=16 integer type. We need to
call the real version. */
- if (kind == 10)
+ if (kind == 10 || kind == 16)
{
f->value.function.name =
gfc_get_string (PREFIX("transpose_r%d"), kind);
+2006-04-22 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/26769
+ * Makefile.am (i_transpose_c): Add generated/transpose_r16.c.
+ (i_reshape_c): Add generated/reshape_r16.c.
+ * Makefile.in: Regenerated.
+ * generated/transpose_r16.c: Generated new file.
+ * generated/redhape_r16.c: Generated new file.
+
2006-04-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/27138
generated/transpose_i8.c \
generated/transpose_i16.c \
generated/transpose_r10.c \
+generated/transpose_r16.c \
generated/transpose_c4.c \
generated/transpose_c8.c \
generated/transpose_c10.c \
generated/reshape_i8.c \
generated/reshape_i16.c \
generated/reshape_r10.c \
+generated/reshape_r16.c \
generated/reshape_c4.c \
generated/reshape_c8.c \
generated/reshape_c10.c \
matmul_c8.lo matmul_c10.lo matmul_c16.lo
am__objects_17 = matmul_l4.lo matmul_l8.lo matmul_l16.lo
am__objects_18 = transpose_i4.lo transpose_i8.lo transpose_i16.lo \
- transpose_r10.lo transpose_c4.lo transpose_c8.lo \
- transpose_c10.lo transpose_c16.lo
+ transpose_r10.lo transpose_r16.lo transpose_c4.lo \
+ transpose_c8.lo transpose_c10.lo transpose_c16.lo
am__objects_19 = shape_i4.lo shape_i8.lo shape_i16.lo
am__objects_20 = eoshift1_4.lo eoshift1_8.lo eoshift1_16.lo
am__objects_21 = eoshift3_4.lo eoshift3_8.lo eoshift3_16.lo
am__objects_22 = cshift1_4.lo cshift1_8.lo cshift1_16.lo
am__objects_23 = reshape_i4.lo reshape_i8.lo reshape_i16.lo \
- reshape_r10.lo reshape_c4.lo reshape_c8.lo reshape_c10.lo \
- reshape_c16.lo
+ reshape_r10.lo reshape_r16.lo reshape_c4.lo reshape_c8.lo \
+ reshape_c10.lo reshape_c16.lo
am__objects_24 = in_pack_i4.lo in_pack_i8.lo in_pack_i16.lo \
in_pack_c4.lo in_pack_c8.lo in_pack_c10.lo in_pack_c16.lo
am__objects_25 = in_unpack_i4.lo in_unpack_i8.lo in_unpack_i16.lo \
generated/transpose_i8.c \
generated/transpose_i16.c \
generated/transpose_r10.c \
+generated/transpose_r16.c \
generated/transpose_c4.c \
generated/transpose_c8.c \
generated/transpose_c10.c \
generated/reshape_i8.c \
generated/reshape_i16.c \
generated/reshape_r10.c \
+generated/reshape_r16.c \
generated/reshape_c4.c \
generated/reshape_c8.c \
generated/reshape_c10.c \
transpose_r10.lo: generated/transpose_r10.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o transpose_r10.lo `test -f 'generated/transpose_r10.c' || echo '$(srcdir)/'`generated/transpose_r10.c
+transpose_r16.lo: generated/transpose_r16.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o transpose_r16.lo `test -f 'generated/transpose_r16.c' || echo '$(srcdir)/'`generated/transpose_r16.c
+
transpose_c4.lo: generated/transpose_c4.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o transpose_c4.lo `test -f 'generated/transpose_c4.c' || echo '$(srcdir)/'`generated/transpose_c4.c
reshape_r10.lo: generated/reshape_r10.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reshape_r10.lo `test -f 'generated/reshape_r10.c' || echo '$(srcdir)/'`generated/reshape_r10.c
+reshape_r16.lo: generated/reshape_r16.c
+ $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reshape_r16.lo `test -f 'generated/reshape_r16.c' || echo '$(srcdir)/'`generated/reshape_r16.c
+
reshape_c4.lo: generated/reshape_c4.c
$(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o reshape_c4.lo `test -f 'generated/reshape_c4.c' || echo '$(srcdir)/'`generated/reshape_c4.c
--- /dev/null
+/* Implementation of the RESHAPE
+ Copyright 2002 Free Software Foundation, Inc.
+ Contributed by Paul Brook <paul@nowt.org>
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with libgfortran; see the file COPYING. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+#include "config.h"
+#include <stdlib.h>
+#include <assert.h>
+#include "libgfortran.h"
+
+#if defined (HAVE_GFC_REAL_16)
+
+typedef GFC_ARRAY_DESCRIPTOR(1, index_type) shape_type;
+
+/* The shape parameter is ignored. We can currently deduce the shape from the
+ return array. */
+
+extern void reshape_r16 (gfc_array_r16 * const restrict,
+ gfc_array_r16 * const restrict,
+ shape_type * const restrict,
+ gfc_array_r16 * const restrict,
+ shape_type * const restrict);
+export_proto(reshape_r16);
+
+void
+reshape_r16 (gfc_array_r16 * const restrict ret,
+ gfc_array_r16 * const restrict source,
+ shape_type * const restrict shape,
+ gfc_array_r16 * const restrict pad,
+ shape_type * const restrict order)
+{
+ /* r.* indicates the return array. */
+ index_type rcount[GFC_MAX_DIMENSIONS];
+ index_type rextent[GFC_MAX_DIMENSIONS];
+ index_type rstride[GFC_MAX_DIMENSIONS];
+ index_type rstride0;
+ index_type rdim;
+ index_type rsize;
+ index_type rs;
+ index_type rex;
+ GFC_REAL_16 *rptr;
+ /* s.* indicates the source array. */
+ index_type scount[GFC_MAX_DIMENSIONS];
+ index_type sextent[GFC_MAX_DIMENSIONS];
+ index_type sstride[GFC_MAX_DIMENSIONS];
+ index_type sstride0;
+ index_type sdim;
+ index_type ssize;
+ const GFC_REAL_16 *sptr;
+ /* p.* indicates the pad array. */
+ index_type pcount[GFC_MAX_DIMENSIONS];
+ index_type pextent[GFC_MAX_DIMENSIONS];
+ index_type pstride[GFC_MAX_DIMENSIONS];
+ index_type pdim;
+ index_type psize;
+ const GFC_REAL_16 *pptr;
+
+ const GFC_REAL_16 *src;
+ int n;
+ int dim;
+
+ if (source->dim[0].stride == 0)
+ source->dim[0].stride = 1;
+ if (shape->dim[0].stride == 0)
+ shape->dim[0].stride = 1;
+ if (pad && pad->dim[0].stride == 0)
+ pad->dim[0].stride = 1;
+ if (order && order->dim[0].stride == 0)
+ order->dim[0].stride = 1;
+
+ if (ret->data == NULL)
+ {
+ rdim = shape->dim[0].ubound - shape->dim[0].lbound + 1;
+ rs = 1;
+ for (n=0; n < rdim; n++)
+ {
+ ret->dim[n].lbound = 0;
+ rex = shape->data[n * shape->dim[0].stride];
+ ret->dim[n].ubound = rex - 1;
+ ret->dim[n].stride = rs;
+ rs *= rex;
+ }
+ ret->offset = 0;
+ ret->data = internal_malloc_size ( rs * sizeof (GFC_REAL_16));
+ ret->dtype = (source->dtype & ~GFC_DTYPE_RANK_MASK) | rdim;
+ }
+ else
+ {
+ rdim = GFC_DESCRIPTOR_RANK (ret);
+ if (ret->dim[0].stride == 0)
+ ret->dim[0].stride = 1;
+ }
+
+ rsize = 1;
+ for (n = 0; n < rdim; n++)
+ {
+ if (order)
+ dim = order->data[n * order->dim[0].stride] - 1;
+ else
+ dim = n;
+
+ rcount[n] = 0;
+ rstride[n] = ret->dim[dim].stride;
+ rextent[n] = ret->dim[dim].ubound + 1 - ret->dim[dim].lbound;
+
+ if (rextent[n] != shape->data[dim * shape->dim[0].stride])
+ runtime_error ("shape and target do not conform");
+
+ if (rsize == rstride[n])
+ rsize *= rextent[n];
+ else
+ rsize = 0;
+ if (rextent[n] <= 0)
+ return;
+ }
+
+ sdim = GFC_DESCRIPTOR_RANK (source);
+ ssize = 1;
+ for (n = 0; n < sdim; n++)
+ {
+ scount[n] = 0;
+ sstride[n] = source->dim[n].stride;
+ sextent[n] = source->dim[n].ubound + 1 - source->dim[n].lbound;
+ if (sextent[n] <= 0)
+ abort ();
+
+ if (ssize == sstride[n])
+ ssize *= sextent[n];
+ else
+ ssize = 0;
+ }
+
+ if (pad)
+ {
+ pdim = GFC_DESCRIPTOR_RANK (pad);
+ psize = 1;
+ for (n = 0; n < pdim; n++)
+ {
+ pcount[n] = 0;
+ pstride[n] = pad->dim[n].stride;
+ pextent[n] = pad->dim[n].ubound + 1 - pad->dim[n].lbound;
+ if (pextent[n] <= 0)
+ abort ();
+ if (psize == pstride[n])
+ psize *= pextent[n];
+ else
+ psize = 0;
+ }
+ pptr = pad->data;
+ }
+ else
+ {
+ pdim = 0;
+ psize = 1;
+ pptr = NULL;
+ }
+
+ if (rsize != 0 && ssize != 0 && psize != 0)
+ {
+ rsize *= sizeof (GFC_REAL_16);
+ ssize *= sizeof (GFC_REAL_16);
+ psize *= sizeof (GFC_REAL_16);
+ reshape_packed ((char *)ret->data, rsize, (char *)source->data,
+ ssize, pad ? (char *)pad->data : NULL, psize);
+ return;
+ }
+ rptr = ret->data;
+ src = sptr = source->data;
+ rstride0 = rstride[0];
+ sstride0 = sstride[0];
+
+ while (rptr)
+ {
+ /* Select between the source and pad arrays. */
+ *rptr = *src;
+ /* Advance to the next element. */
+ rptr += rstride0;
+ src += sstride0;
+ rcount[0]++;
+ scount[0]++;
+ /* Advance to the next destination element. */
+ n = 0;
+ while (rcount[n] == rextent[n])
+ {
+ /* When we get to the end of a dimension, reset it and increment
+ the next dimension. */
+ rcount[n] = 0;
+ /* We could precalculate these products, but this is a less
+ frequently used path so proabably not worth it. */
+ rptr -= rstride[n] * rextent[n];
+ n++;
+ if (n == rdim)
+ {
+ /* Break out of the loop. */
+ rptr = NULL;
+ break;
+ }
+ else
+ {
+ rcount[n]++;
+ rptr += rstride[n];
+ }
+ }
+ /* Advance to the next source element. */
+ n = 0;
+ while (scount[n] == sextent[n])
+ {
+ /* When we get to the end of a dimension, reset it and increment
+ the next dimension. */
+ scount[n] = 0;
+ /* We could precalculate these products, but this is a less
+ frequently used path so proabably not worth it. */
+ src -= sstride[n] * sextent[n];
+ n++;
+ if (n == sdim)
+ {
+ if (sptr && pad)
+ {
+ /* Switch to the pad array. */
+ sptr = NULL;
+ sdim = pdim;
+ for (dim = 0; dim < pdim; dim++)
+ {
+ scount[dim] = pcount[dim];
+ sextent[dim] = pextent[dim];
+ sstride[dim] = pstride[dim];
+ sstride0 = sstride[0];
+ }
+ }
+ /* We now start again from the beginning of the pad array. */
+ src = pptr;
+ break;
+ }
+ else
+ {
+ scount[n]++;
+ src += sstride[n];
+ }
+ }
+ }
+}
+
+#endif
--- /dev/null
+/* Implementation of the TRANSPOSE intrinsic
+ Copyright 2003, 2005 Free Software Foundation, Inc.
+ Contributed by Tobias Schlüter
+
+This file is part of the GNU Fortran 95 runtime library (libgfortran).
+
+Libgfortran is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+In addition to the permissions in the GNU General Public License, the
+Free Software Foundation gives you unlimited permission to link the
+compiled version of this file into combinations with other programs,
+and to distribute those combinations without any restriction coming
+from the use of this file. (The General Public License restrictions
+do apply in other respects; for example, they cover modification of
+the file, and distribution when not linked into a combine
+executable.)
+
+Libgfortran is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public
+License along with libgfortran; see the file COPYING. If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA. */
+
+#include "config.h"
+#include <assert.h>
+#include "libgfortran.h"
+
+#if defined (HAVE_GFC_REAL_16)
+
+extern void transpose_r16 (gfc_array_r16 * const restrict ret,
+ gfc_array_r16 * const restrict source);
+export_proto(transpose_r16);
+
+void
+transpose_r16 (gfc_array_r16 * const restrict ret,
+ gfc_array_r16 * const restrict source)
+{
+ /* r.* indicates the return array. */
+ index_type rxstride, rystride;
+ GFC_REAL_16 *rptr;
+ /* s.* indicates the source array. */
+ index_type sxstride, systride;
+ const GFC_REAL_16 *sptr;
+
+ index_type xcount, ycount;
+ index_type x, y;
+
+ assert (GFC_DESCRIPTOR_RANK (source) == 2);
+
+ if (ret->data == NULL)
+ {
+ assert (GFC_DESCRIPTOR_RANK (ret) == 2);
+ assert (ret->dtype == source->dtype);
+
+ ret->dim[0].lbound = 0;
+ ret->dim[0].ubound = source->dim[1].ubound - source->dim[1].lbound;
+ ret->dim[0].stride = 1;
+
+ ret->dim[1].lbound = 0;
+ ret->dim[1].ubound = source->dim[0].ubound - source->dim[0].lbound;
+ ret->dim[1].stride = ret->dim[0].ubound+1;
+
+ ret->data = internal_malloc_size (sizeof (GFC_REAL_16) * size0 ((array_t *) ret));
+ ret->offset = 0;
+ }
+
+ if (ret->dim[0].stride == 0)
+ ret->dim[0].stride = 1;
+ if (source->dim[0].stride == 0)
+ source->dim[0].stride = 1;
+
+ sxstride = source->dim[0].stride;
+ systride = source->dim[1].stride;
+ xcount = source->dim[0].ubound + 1 - source->dim[0].lbound;
+ ycount = source->dim[1].ubound + 1 - source->dim[1].lbound;
+
+ rxstride = ret->dim[0].stride;
+ rystride = ret->dim[1].stride;
+
+ rptr = ret->data;
+ sptr = source->data;
+
+ for (y=0; y < ycount; y++)
+ {
+ for (x=0; x < xcount; x++)
+ {
+ *rptr = *sptr;
+
+ sptr += sxstride;
+ rptr += rystride;
+ }
+ sptr += systride - (sxstride * xcount);
+ rptr += rxstride - (rystride * xcount);
+ }
+}
+
+#endif