OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgfortran/] [generated/] [transpose_c4.c] - Blame information for rev 818

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 733 jeremybenn
/* Implementation of the TRANSPOSE intrinsic
2
   Copyright 2003, 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
3
   Contributed by Tobias Schlüter
4
 
5
This file is part of the GNU Fortran 95 runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or
8
modify it under the terms of the GNU General Public
9
License as published by the Free Software Foundation; either
10
version 3 of the License, or (at your option) any later version.
11
 
12
Libgfortran is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
Under Section 7 of GPL version 3, you are granted additional
18
permissions described in the GCC Runtime Library Exception, version
19
3.1, as published by the Free Software Foundation.
20
 
21
You should have received a copy of the GNU General Public License and
22
a copy of the GCC Runtime Library Exception along with this program;
23
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
<http://www.gnu.org/licenses/>.  */
25
 
26
#include "libgfortran.h"
27
#include <assert.h>
28
 
29
 
30
#if defined (HAVE_GFC_COMPLEX_4)
31
 
32
extern void transpose_c4 (gfc_array_c4 * const restrict ret,
33
        gfc_array_c4 * const restrict source);
34
export_proto(transpose_c4);
35
 
36
void
37
transpose_c4 (gfc_array_c4 * const restrict ret,
38
        gfc_array_c4 * const restrict source)
39
{
40
  /* r.* indicates the return array.  */
41
  index_type rxstride, rystride;
42
  GFC_COMPLEX_4 * restrict rptr;
43
  /* s.* indicates the source array.  */
44
  index_type sxstride, systride;
45
  const GFC_COMPLEX_4 *sptr;
46
 
47
  index_type xcount, ycount;
48
  index_type x, y;
49
 
50
  assert (GFC_DESCRIPTOR_RANK (source) == 2);
51
 
52
  if (ret->data == NULL)
53
    {
54
      assert (GFC_DESCRIPTOR_RANK (ret) == 2);
55
      assert (ret->dtype == source->dtype);
56
 
57
      GFC_DIMENSION_SET(ret->dim[0], 0, GFC_DESCRIPTOR_EXTENT(source,1) - 1,
58
                        1);
59
 
60
      GFC_DIMENSION_SET(ret->dim[1], 0, GFC_DESCRIPTOR_EXTENT(source,0) - 1,
61
                        GFC_DESCRIPTOR_EXTENT(source, 1));
62
 
63
      ret->data = internal_malloc_size (sizeof (GFC_COMPLEX_4) * size0 ((array_t *) ret));
64
      ret->offset = 0;
65
    } else if (unlikely (compile_options.bounds_check))
66
    {
67
      index_type ret_extent, src_extent;
68
 
69
      ret_extent = GFC_DESCRIPTOR_EXTENT(ret,0);
70
      src_extent = GFC_DESCRIPTOR_EXTENT(source,1);
71
 
72
      if (src_extent != ret_extent)
73
        runtime_error ("Incorrect extent in return value of TRANSPOSE"
74
                       " intrinsic in dimension 1: is %ld,"
75
                       " should be %ld", (long int) src_extent,
76
                       (long int) ret_extent);
77
 
78
      ret_extent = GFC_DESCRIPTOR_EXTENT(ret,1);
79
      src_extent = GFC_DESCRIPTOR_EXTENT(source,0);
80
 
81
      if (src_extent != ret_extent)
82
        runtime_error ("Incorrect extent in return value of TRANSPOSE"
83
                       " intrinsic in dimension 2: is %ld,"
84
                       " should be %ld", (long int) src_extent,
85
                       (long int) ret_extent);
86
 
87
    }
88
 
89
  sxstride = GFC_DESCRIPTOR_STRIDE(source,0);
90
  systride = GFC_DESCRIPTOR_STRIDE(source,1);
91
  xcount = GFC_DESCRIPTOR_EXTENT(source,0);
92
  ycount = GFC_DESCRIPTOR_EXTENT(source,1);
93
 
94
  rxstride = GFC_DESCRIPTOR_STRIDE(ret,0);
95
  rystride = GFC_DESCRIPTOR_STRIDE(ret,1);
96
 
97
  rptr = ret->data;
98
  sptr = source->data;
99
 
100
  for (y=0; y < ycount; y++)
101
    {
102
      for (x=0; x < xcount; x++)
103
        {
104
          *rptr = *sptr;
105
 
106
          sptr += sxstride;
107
          rptr += rystride;
108
        }
109
        sptr += systride - (sxstride * xcount);
110
        rptr += rxstride - (rystride * xcount);
111
    }
112
}
113
 
114
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.