]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libgfortran/generated/eoshift3_8.c
1 /* Implementation of the EOSHIFT intrinsic
2 Copyright 2002 Free Software Foundation, Inc.
3 Contributed by Paul Brook <paul@nowt.org>
5 This file is part of the GNU Fortran 95 runtime library (libgfor).
7 Libgfor is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 Ligbfor 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 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with libgfor; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
26 #include "libgfortran.h"
28 static const char zeros
[16] =
29 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
31 extern void eoshift3_8 (gfc_array_char
*, gfc_array_char
*,
32 gfc_array_i8
*, const gfc_array_char
*,
34 export_proto(eoshift3_8
);
37 eoshift3_8 (gfc_array_char
*ret
, gfc_array_char
*array
,
38 gfc_array_i8
*h
, const gfc_array_char
*bound
,
39 GFC_INTEGER_8
*pwhich
)
41 /* r.* indicates the return array. */
42 index_type rstride
[GFC_MAX_DIMENSIONS
- 1];
47 /* s.* indicates the source array. */
48 index_type sstride
[GFC_MAX_DIMENSIONS
- 1];
53 /* h.* indicates the shift array. */
54 index_type hstride
[GFC_MAX_DIMENSIONS
- 1];
56 const GFC_INTEGER_8
*hptr
;
57 /* b.* indicates the bound array. */
58 index_type bstride
[GFC_MAX_DIMENSIONS
- 1];
62 index_type count
[GFC_MAX_DIMENSIONS
- 1];
63 index_type extent
[GFC_MAX_DIMENSIONS
- 1];
77 size
= GFC_DESCRIPTOR_SIZE (ret
);
81 size
= GFC_DESCRIPTOR_SIZE (array
);
83 for (dim
= 0; dim
< GFC_DESCRIPTOR_RANK (array
); dim
++)
87 roffset
= ret
->dim
[dim
].stride
* size
;
90 soffset
= array
->dim
[dim
].stride
* size
;
93 len
= array
->dim
[dim
].ubound
+ 1 - array
->dim
[dim
].lbound
;
98 extent
[n
] = array
->dim
[dim
].ubound
+ 1 - array
->dim
[dim
].lbound
;
99 rstride
[n
] = ret
->dim
[dim
].stride
* size
;
100 sstride
[n
] = array
->dim
[dim
].stride
* size
;
102 hstride
[n
] = h
->dim
[n
].stride
;
104 bstride
[n
] = bound
->dim
[n
].stride
;
116 if (bound
&& bstride
[0] == 0)
119 dim
= GFC_DESCRIPTOR_RANK (array
);
120 rstride0
= rstride
[0];
121 sstride0
= sstride
[0];
122 hstride0
= hstride
[0];
123 bstride0
= bstride
[0];
134 /* Do the shift for this dimension. */
136 delta
= (sh
>= 0) ? sh
: -sh
;
139 src
= &sptr
[delta
* soffset
];
145 dest
= &rptr
[delta
* roffset
];
147 for (n
= 0; n
< len
- delta
; n
++)
149 memcpy (dest
, src
, size
);
159 memcpy (dest
, bptr
, size
);
163 /* Advance to the next section. */
170 while (count
[n
] == extent
[n
])
172 /* When we get to the end of a dimension, reset it and increment
173 the next dimension. */
175 /* We could precalculate these products, but this is a less
176 frequently used path so proabably not worth it. */
177 rptr
-= rstride
[n
] * extent
[n
];
178 sptr
-= sstride
[n
] * extent
[n
];
179 hptr
-= hstride
[n
] * extent
[n
];
180 bptr
-= bstride
[n
] * extent
[n
];
184 /* Break out of the loop. */