Mercurial > hg > CbC > CbC_gcc
comparison libgfortran/generated/minloc0_16_i2.c @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Implementation of the MINLOC intrinsic | 1 /* Implementation of the MINLOC intrinsic |
2 Copyright (C) 2002-2017 Free Software Foundation, Inc. | 2 Copyright (C) 2002-2018 Free Software Foundation, Inc. |
3 Contributed by Paul Brook <paul@nowt.org> | 3 Contributed by Paul Brook <paul@nowt.org> |
4 | 4 |
5 This file is part of the GNU Fortran 95 runtime library (libgfortran). | 5 This file is part of the GNU Fortran 95 runtime library (libgfortran). |
6 | 6 |
7 Libgfortran is free software; you can redistribute it and/or | 7 Libgfortran is free software; you can redistribute it and/or |
22 a copy of the GCC Runtime Library Exception along with this program; | 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 | 23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
24 <http://www.gnu.org/licenses/>. */ | 24 <http://www.gnu.org/licenses/>. */ |
25 | 25 |
26 #include "libgfortran.h" | 26 #include "libgfortran.h" |
27 #include <assert.h> | |
27 | 28 |
28 | 29 |
29 #if defined (HAVE_GFC_INTEGER_2) && defined (HAVE_GFC_INTEGER_16) | 30 #if defined (HAVE_GFC_INTEGER_2) && defined (HAVE_GFC_INTEGER_16) |
30 | 31 |
31 | 32 |
32 extern void minloc0_16_i2 (gfc_array_i16 * const restrict retarray, | 33 extern void minloc0_16_i2 (gfc_array_i16 * const restrict retarray, |
33 gfc_array_i2 * const restrict array); | 34 gfc_array_i2 * const restrict array, GFC_LOGICAL_4); |
34 export_proto(minloc0_16_i2); | 35 export_proto(minloc0_16_i2); |
35 | 36 |
36 void | 37 void |
37 minloc0_16_i2 (gfc_array_i16 * const restrict retarray, | 38 minloc0_16_i2 (gfc_array_i16 * const restrict retarray, |
38 gfc_array_i2 * const restrict array) | 39 gfc_array_i2 * const restrict array, GFC_LOGICAL_4 back) |
39 { | 40 { |
40 index_type count[GFC_MAX_DIMENSIONS]; | 41 index_type count[GFC_MAX_DIMENSIONS]; |
41 index_type extent[GFC_MAX_DIMENSIONS]; | 42 index_type extent[GFC_MAX_DIMENSIONS]; |
42 index_type sstride[GFC_MAX_DIMENSIONS]; | 43 index_type sstride[GFC_MAX_DIMENSIONS]; |
43 index_type dstride; | 44 index_type dstride; |
51 runtime_error ("Rank of array needs to be > 0"); | 52 runtime_error ("Rank of array needs to be > 0"); |
52 | 53 |
53 if (retarray->base_addr == NULL) | 54 if (retarray->base_addr == NULL) |
54 { | 55 { |
55 GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1); | 56 GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1); |
56 retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; | 57 retarray->dtype.rank = 1; |
57 retarray->offset = 0; | 58 retarray->offset = 0; |
58 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); | 59 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); |
59 } | 60 } |
60 else | 61 else |
61 { | 62 { |
97 #else | 98 #else |
98 minval = GFC_INTEGER_2_HUGE; | 99 minval = GFC_INTEGER_2_HUGE; |
99 #endif | 100 #endif |
100 while (base) | 101 while (base) |
101 { | 102 { |
102 do | |
103 { | |
104 /* Implementation start. */ | 103 /* Implementation start. */ |
105 | 104 |
106 #if defined(GFC_INTEGER_2_QUIET_NAN) | 105 #if defined(GFC_INTEGER_2_QUIET_NAN) |
107 } | |
108 while (0); | |
109 if (unlikely (!fast)) | 106 if (unlikely (!fast)) |
110 { | 107 { |
111 do | 108 do |
112 { | 109 { |
113 if (*base <= minval) | 110 if (*base <= minval) |
122 } | 119 } |
123 while (++count[0] != extent[0]); | 120 while (++count[0] != extent[0]); |
124 if (likely (fast)) | 121 if (likely (fast)) |
125 continue; | 122 continue; |
126 } | 123 } |
127 else do | 124 else |
128 { | 125 #endif |
129 #endif | 126 if (back) |
130 if (*base < minval) | 127 do |
128 { | |
129 if (unlikely (*base <= minval)) | |
131 { | 130 { |
132 minval = *base; | 131 minval = *base; |
133 for (n = 0; n < rank; n++) | 132 for (n = 0; n < rank; n++) |
134 dest[n * dstride] = count[n] + 1; | 133 dest[n * dstride] = count[n] + 1; |
134 } | |
135 base += sstride[0]; | |
136 } | |
137 while (++count[0] != extent[0]); | |
138 else | |
139 do | |
140 { | |
141 if (unlikely (*base < minval)) | |
142 { | |
143 minval = *base; | |
144 for (n = 0; n < rank; n++) | |
145 dest[n * dstride] = count[n] + 1; | |
135 } | 146 } |
136 /* Implementation end. */ | 147 /* Implementation end. */ |
137 /* Advance to the next element. */ | 148 /* Advance to the next element. */ |
138 base += sstride[0]; | 149 base += sstride[0]; |
139 } | 150 } |
163 while (count[n] == extent[n]); | 174 while (count[n] == extent[n]); |
164 } | 175 } |
165 } | 176 } |
166 } | 177 } |
167 | 178 |
168 | |
169 extern void mminloc0_16_i2 (gfc_array_i16 * const restrict, | 179 extern void mminloc0_16_i2 (gfc_array_i16 * const restrict, |
170 gfc_array_i2 * const restrict, gfc_array_l1 * const restrict); | 180 gfc_array_i2 * const restrict, gfc_array_l1 * const restrict, |
181 GFC_LOGICAL_4); | |
171 export_proto(mminloc0_16_i2); | 182 export_proto(mminloc0_16_i2); |
172 | 183 |
173 void | 184 void |
174 mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, | 185 mminloc0_16_i2 (gfc_array_i16 * const restrict retarray, |
175 gfc_array_i2 * const restrict array, | 186 gfc_array_i2 * const restrict array, |
176 gfc_array_l1 * const restrict mask) | 187 gfc_array_l1 * const restrict mask, GFC_LOGICAL_4 back) |
177 { | 188 { |
178 index_type count[GFC_MAX_DIMENSIONS]; | 189 index_type count[GFC_MAX_DIMENSIONS]; |
179 index_type extent[GFC_MAX_DIMENSIONS]; | 190 index_type extent[GFC_MAX_DIMENSIONS]; |
180 index_type sstride[GFC_MAX_DIMENSIONS]; | 191 index_type sstride[GFC_MAX_DIMENSIONS]; |
181 index_type mstride[GFC_MAX_DIMENSIONS]; | 192 index_type mstride[GFC_MAX_DIMENSIONS]; |
192 runtime_error ("Rank of array needs to be > 0"); | 203 runtime_error ("Rank of array needs to be > 0"); |
193 | 204 |
194 if (retarray->base_addr == NULL) | 205 if (retarray->base_addr == NULL) |
195 { | 206 { |
196 GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1); | 207 GFC_DIMENSION_SET(retarray->dim[0], 0, rank - 1, 1); |
197 retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; | 208 retarray->dtype.rank = 1; |
198 retarray->offset = 0; | 209 retarray->offset = 0; |
199 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); | 210 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); |
200 } | 211 } |
201 else | 212 else |
202 { | 213 { |
255 #else | 266 #else |
256 minval = GFC_INTEGER_2_HUGE; | 267 minval = GFC_INTEGER_2_HUGE; |
257 #endif | 268 #endif |
258 while (base) | 269 while (base) |
259 { | 270 { |
260 do | |
261 { | |
262 /* Implementation start. */ | 271 /* Implementation start. */ |
263 | 272 |
264 } | |
265 while (0); | |
266 if (unlikely (!fast)) | 273 if (unlikely (!fast)) |
267 { | 274 { |
268 do | 275 do |
269 { | 276 { |
270 if (*mbase) | 277 if (*mbase) |
288 } | 295 } |
289 while (++count[0] != extent[0]); | 296 while (++count[0] != extent[0]); |
290 if (likely (fast)) | 297 if (likely (fast)) |
291 continue; | 298 continue; |
292 } | 299 } |
293 else do | 300 else |
294 { | 301 if (back) |
295 if (*mbase && *base < minval) | 302 do |
296 { | 303 { |
297 minval = *base; | 304 if (unlikely (*mbase && (*base <= minval))) |
298 for (n = 0; n < rank; n++) | 305 { |
299 dest[n * dstride] = count[n] + 1; | 306 minval = *base; |
300 } | 307 for (n = 0; n < rank; n++) |
308 dest[n * dstride] = count[n] + 1; | |
309 } | |
310 base += sstride[0]; | |
311 } | |
312 while (++count[0] != extent[0]); | |
313 else | |
314 do | |
315 { | |
316 if (unlikely (*mbase && (*base < minval))) | |
317 { | |
318 minval = *base; | |
319 for (n = 0; n < rank; n++) | |
320 dest[n * dstride] = count[n] + 1; | |
321 } | |
301 /* Implementation end. */ | 322 /* Implementation end. */ |
302 /* Advance to the next element. */ | 323 /* Advance to the next element. */ |
303 base += sstride[0]; | 324 base += sstride[0]; |
304 mbase += mstride[0]; | 325 mbase += mstride[0]; |
305 } | 326 } |
331 while (count[n] == extent[n]); | 352 while (count[n] == extent[n]); |
332 } | 353 } |
333 } | 354 } |
334 } | 355 } |
335 | 356 |
336 | |
337 extern void sminloc0_16_i2 (gfc_array_i16 * const restrict, | 357 extern void sminloc0_16_i2 (gfc_array_i16 * const restrict, |
338 gfc_array_i2 * const restrict, GFC_LOGICAL_4 *); | 358 gfc_array_i2 * const restrict, GFC_LOGICAL_4 *, GFC_LOGICAL_4); |
339 export_proto(sminloc0_16_i2); | 359 export_proto(sminloc0_16_i2); |
340 | 360 |
341 void | 361 void |
342 sminloc0_16_i2 (gfc_array_i16 * const restrict retarray, | 362 sminloc0_16_i2 (gfc_array_i16 * const restrict retarray, |
343 gfc_array_i2 * const restrict array, | 363 gfc_array_i2 * const restrict array, |
344 GFC_LOGICAL_4 * mask) | 364 GFC_LOGICAL_4 * mask, GFC_LOGICAL_4 back) |
345 { | 365 { |
346 index_type rank; | 366 index_type rank; |
347 index_type dstride; | 367 index_type dstride; |
348 index_type n; | 368 index_type n; |
349 GFC_INTEGER_16 *dest; | 369 GFC_INTEGER_16 *dest; |
350 | 370 |
351 if (*mask) | 371 if (*mask) |
352 { | 372 { |
353 minloc0_16_i2 (retarray, array); | 373 minloc0_16_i2 (retarray, array, back); |
354 return; | 374 return; |
355 } | 375 } |
356 | 376 |
357 rank = GFC_DESCRIPTOR_RANK (array); | 377 rank = GFC_DESCRIPTOR_RANK (array); |
358 | 378 |
360 runtime_error ("Rank of array needs to be > 0"); | 380 runtime_error ("Rank of array needs to be > 0"); |
361 | 381 |
362 if (retarray->base_addr == NULL) | 382 if (retarray->base_addr == NULL) |
363 { | 383 { |
364 GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1); | 384 GFC_DIMENSION_SET(retarray->dim[0], 0, rank-1, 1); |
365 retarray->dtype = (retarray->dtype & ~GFC_DTYPE_RANK_MASK) | 1; | 385 retarray->dtype.rank = 1; |
366 retarray->offset = 0; | 386 retarray->offset = 0; |
367 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); | 387 retarray->base_addr = xmallocarray (rank, sizeof (GFC_INTEGER_16)); |
368 } | 388 } |
369 else if (unlikely (compile_options.bounds_check)) | 389 else if (unlikely (compile_options.bounds_check)) |
370 { | 390 { |