1 /* Intrinsic function resolution.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
4 Contributed by Andy Vaught & Katherine Holcomb
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
24 /* Assign name and types to intrinsic procedures. For functions, the
25 first argument to a resolution function is an expression pointer to
26 the original function node and the rest are pointers to the
27 arguments of the function call. For subroutines, a pointer to the
28 code node is passed. The result type and library subroutine name
29 are generally set according to the function arguments. */
33 #include "coretypes.h"
36 #include "intrinsic.h"
39 /* Given printf-like arguments, return a stable version of the result string.
41 We already have a working, optimized string hashing table in the form of
42 the identifier table. Reusing this table is likely not to be wasted,
43 since if the function name makes it to the gimple output of the frontend,
44 we'll have to create the identifier anyway. */
47 gfc_get_string (const char *format
, ...)
53 va_start (ap
, format
);
54 vsnprintf (temp_name
, sizeof(temp_name
), format
, ap
);
56 temp_name
[sizeof(temp_name
)-1] = 0;
58 ident
= get_identifier (temp_name
);
59 return IDENTIFIER_POINTER (ident
);
62 /********************** Resolution functions **********************/
66 gfc_resolve_abs (gfc_expr
* f
, gfc_expr
* a
)
69 if (f
->ts
.type
== BT_COMPLEX
)
72 f
->value
.function
.name
=
73 gfc_get_string ("__abs_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
78 gfc_resolve_acos (gfc_expr
* f
, gfc_expr
* x
)
81 f
->value
.function
.name
=
82 gfc_get_string ("__acos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
87 gfc_resolve_acosh (gfc_expr
* f
, gfc_expr
* x
)
90 f
->value
.function
.name
=
91 gfc_get_string ("__acosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
96 gfc_resolve_aimag (gfc_expr
* f
, gfc_expr
* x
)
99 f
->ts
.kind
= x
->ts
.kind
;
100 f
->value
.function
.name
=
101 gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
106 gfc_resolve_aint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
108 f
->ts
.type
= a
->ts
.type
;
109 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
111 /* The resolved name is only used for specific intrinsics where
112 the return kind is the same as the arg kind. */
113 f
->value
.function
.name
=
114 gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
119 gfc_resolve_dint (gfc_expr
* f
, gfc_expr
* a
)
121 gfc_resolve_aint (f
, a
, NULL
);
126 gfc_resolve_all (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
132 gfc_resolve_dim_arg (dim
);
133 f
->rank
= mask
->rank
- 1;
134 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
137 f
->value
.function
.name
=
138 gfc_get_string (PREFIX("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
144 gfc_resolve_anint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
146 f
->ts
.type
= a
->ts
.type
;
147 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
149 /* The resolved name is only used for specific intrinsics where
150 the return kind is the same as the arg kind. */
151 f
->value
.function
.name
=
152 gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
157 gfc_resolve_dnint (gfc_expr
* f
, gfc_expr
* a
)
159 gfc_resolve_anint (f
, a
, NULL
);
164 gfc_resolve_any (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
170 gfc_resolve_dim_arg (dim
);
171 f
->rank
= mask
->rank
- 1;
172 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
175 f
->value
.function
.name
=
176 gfc_get_string (PREFIX("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
182 gfc_resolve_asin (gfc_expr
* f
, gfc_expr
* x
)
185 f
->value
.function
.name
=
186 gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
190 gfc_resolve_asinh (gfc_expr
* f
, gfc_expr
* x
)
193 f
->value
.function
.name
=
194 gfc_get_string ("__asinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
198 gfc_resolve_atan (gfc_expr
* f
, gfc_expr
* x
)
201 f
->value
.function
.name
=
202 gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
206 gfc_resolve_atanh (gfc_expr
* f
, gfc_expr
* x
)
209 f
->value
.function
.name
=
210 gfc_get_string ("__atanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
214 gfc_resolve_atan2 (gfc_expr
* f
, gfc_expr
* x
,
215 gfc_expr
* y ATTRIBUTE_UNUSED
)
218 f
->value
.function
.name
=
219 gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
223 /* Resolve the BESYN and BESJN intrinsics. */
226 gfc_resolve_besn (gfc_expr
* f
, gfc_expr
* n
, gfc_expr
* x
)
231 if (n
->ts
.kind
!= gfc_c_int_kind
)
233 ts
.type
= BT_INTEGER
;
234 ts
.kind
= gfc_c_int_kind
;
235 gfc_convert_type (n
, &ts
, 2);
237 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
242 gfc_resolve_btest (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* pos
)
244 f
->ts
.type
= BT_LOGICAL
;
245 f
->ts
.kind
= gfc_default_logical_kind
;
247 f
->value
.function
.name
= gfc_get_string ("__btest_%d_%d", i
->ts
.kind
,
253 gfc_resolve_ceiling (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
255 f
->ts
.type
= BT_INTEGER
;
256 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
257 : mpz_get_si (kind
->value
.integer
);
259 f
->value
.function
.name
=
260 gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
261 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
266 gfc_resolve_char (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
268 f
->ts
.type
= BT_CHARACTER
;
269 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_character_kind
270 : mpz_get_si (kind
->value
.integer
);
272 f
->value
.function
.name
=
273 gfc_get_string ("__char_%d_%c%d", f
->ts
.kind
,
274 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
279 gfc_resolve_chdir (gfc_expr
* f
, gfc_expr
* d ATTRIBUTE_UNUSED
)
281 f
->ts
.type
= BT_INTEGER
;
282 f
->ts
.kind
= gfc_default_integer_kind
;
283 f
->value
.function
.name
= gfc_get_string (PREFIX("chdir_i%d"), f
->ts
.kind
);
288 gfc_resolve_chdir_sub (gfc_code
* c
)
293 if (c
->ext
.actual
->next
->expr
!= NULL
)
294 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
296 kind
= gfc_default_integer_kind
;
298 name
= gfc_get_string (PREFIX("chdir_i%d_sub"), kind
);
299 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
304 gfc_resolve_cmplx (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* y
, gfc_expr
* kind
)
306 f
->ts
.type
= BT_COMPLEX
;
307 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_real_kind
308 : mpz_get_si (kind
->value
.integer
);
311 f
->value
.function
.name
=
312 gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
313 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
315 f
->value
.function
.name
=
316 gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
317 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
318 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
322 gfc_resolve_dcmplx (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* y
)
324 gfc_resolve_cmplx (f
, x
, y
, gfc_int_expr (gfc_default_double_kind
));
328 gfc_resolve_conjg (gfc_expr
* f
, gfc_expr
* x
)
331 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
336 gfc_resolve_cos (gfc_expr
* f
, gfc_expr
* x
)
339 f
->value
.function
.name
=
340 gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
345 gfc_resolve_cosh (gfc_expr
* f
, gfc_expr
* x
)
348 f
->value
.function
.name
=
349 gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
354 gfc_resolve_count (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
356 f
->ts
.type
= BT_INTEGER
;
357 f
->ts
.kind
= gfc_default_integer_kind
;
361 f
->rank
= mask
->rank
- 1;
362 gfc_resolve_dim_arg (dim
);
363 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
366 f
->value
.function
.name
=
367 gfc_get_string (PREFIX("count_%d_%c%d"), f
->ts
.kind
,
368 gfc_type_letter (mask
->ts
.type
), mask
->ts
.kind
);
373 gfc_resolve_cshift (gfc_expr
* f
, gfc_expr
* array
,
380 f
->rank
= array
->rank
;
381 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
388 /* Convert shift to at least gfc_default_integer_kind, so we don't need
389 kind=1 and kind=2 versions of the library functions. */
390 if (shift
->ts
.kind
< gfc_default_integer_kind
)
393 ts
.type
= BT_INTEGER
;
394 ts
.kind
= gfc_default_integer_kind
;
395 gfc_convert_type_warn (shift
, &ts
, 2, 0);
400 gfc_resolve_dim_arg (dim
);
401 /* Convert dim to shift's kind, so we don't need so many variations. */
402 if (dim
->ts
.kind
!= shift
->ts
.kind
)
403 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
405 f
->value
.function
.name
=
406 gfc_get_string (PREFIX("cshift%d_%d%s"), n
, shift
->ts
.kind
,
407 array
->ts
.type
== BT_CHARACTER
? "_char" : "");
412 gfc_resolve_dble (gfc_expr
* f
, gfc_expr
* a
)
414 f
->ts
.type
= BT_REAL
;
415 f
->ts
.kind
= gfc_default_double_kind
;
416 f
->value
.function
.name
=
417 gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
422 gfc_resolve_dim (gfc_expr
* f
, gfc_expr
* x
,
423 gfc_expr
* y ATTRIBUTE_UNUSED
)
426 f
->value
.function
.name
=
427 gfc_get_string ("__dim_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
432 gfc_resolve_dot_product (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b
)
436 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
438 f
->ts
.type
= BT_LOGICAL
;
439 f
->ts
.kind
= gfc_default_logical_kind
;
443 temp
.expr_type
= EXPR_OP
;
444 gfc_clear_ts (&temp
.ts
);
445 temp
.value
.op
.operator = INTRINSIC_NONE
;
446 temp
.value
.op
.op1
= a
;
447 temp
.value
.op
.op2
= b
;
448 gfc_type_convert_binary (&temp
);
452 f
->value
.function
.name
=
453 gfc_get_string (PREFIX("dot_product_%c%d"), gfc_type_letter (f
->ts
.type
),
459 gfc_resolve_dprod (gfc_expr
* f
,
460 gfc_expr
* a ATTRIBUTE_UNUSED
,
461 gfc_expr
* b ATTRIBUTE_UNUSED
)
463 f
->ts
.kind
= gfc_default_double_kind
;
464 f
->ts
.type
= BT_REAL
;
466 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d", f
->ts
.kind
);
471 gfc_resolve_eoshift (gfc_expr
* f
, gfc_expr
* array
,
479 f
->rank
= array
->rank
;
480 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
485 if (boundary
&& boundary
->rank
> 0)
488 /* Convert shift to at least gfc_default_integer_kind, so we don't need
489 kind=1 and kind=2 versions of the library functions. */
490 if (shift
->ts
.kind
< gfc_default_integer_kind
)
493 ts
.type
= BT_INTEGER
;
494 ts
.kind
= gfc_default_integer_kind
;
495 gfc_convert_type_warn (shift
, &ts
, 2, 0);
500 gfc_resolve_dim_arg (dim
);
501 /* Convert dim to shift's kind, so we don't need so many variations. */
502 if (dim
->ts
.kind
!= shift
->ts
.kind
)
503 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
506 f
->value
.function
.name
=
507 gfc_get_string (PREFIX("eoshift%d_%d%s"), n
, shift
->ts
.kind
,
508 array
->ts
.type
== BT_CHARACTER
? "_char" : "");
513 gfc_resolve_exp (gfc_expr
* f
, gfc_expr
* x
)
516 f
->value
.function
.name
=
517 gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
522 gfc_resolve_exponent (gfc_expr
* f
, gfc_expr
* x
)
524 f
->ts
.type
= BT_INTEGER
;
525 f
->ts
.kind
= gfc_default_integer_kind
;
527 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
532 gfc_resolve_floor (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
534 f
->ts
.type
= BT_INTEGER
;
535 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
536 : mpz_get_si (kind
->value
.integer
);
538 f
->value
.function
.name
=
539 gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
540 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
545 gfc_resolve_fnum (gfc_expr
* f
, gfc_expr
* n
)
547 f
->ts
.type
= BT_INTEGER
;
548 f
->ts
.kind
= gfc_default_integer_kind
;
549 if (n
->ts
.kind
!= f
->ts
.kind
)
550 gfc_convert_type (n
, &f
->ts
, 2);
551 f
->value
.function
.name
= gfc_get_string (PREFIX("fnum_i%d"), f
->ts
.kind
);
556 gfc_resolve_fraction (gfc_expr
* f
, gfc_expr
* x
)
559 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
563 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
566 gfc_resolve_g77_math1 (gfc_expr
* f
, gfc_expr
* x
)
569 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
574 gfc_resolve_getcwd (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
576 f
->ts
.type
= BT_INTEGER
;
578 f
->value
.function
.name
= gfc_get_string (PREFIX("getcwd"));
583 gfc_resolve_getgid (gfc_expr
* f
)
585 f
->ts
.type
= BT_INTEGER
;
587 f
->value
.function
.name
= gfc_get_string (PREFIX("getgid"));
592 gfc_resolve_getpid (gfc_expr
* f
)
594 f
->ts
.type
= BT_INTEGER
;
596 f
->value
.function
.name
= gfc_get_string (PREFIX("getpid"));
601 gfc_resolve_getuid (gfc_expr
* f
)
603 f
->ts
.type
= BT_INTEGER
;
605 f
->value
.function
.name
= gfc_get_string (PREFIX("getuid"));
609 gfc_resolve_hostnm (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
611 f
->ts
.type
= BT_INTEGER
;
613 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
617 gfc_resolve_iand (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
619 /* If the kind of i and j are different, then g77 cross-promoted the
620 kinds to the largest value. The Fortran 95 standard requires the
622 if (i
->ts
.kind
!= j
->ts
.kind
)
624 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
625 gfc_convert_type(j
, &i
->ts
, 2);
627 gfc_convert_type(i
, &j
->ts
, 2);
631 f
->value
.function
.name
= gfc_get_string ("__iand_%d", i
->ts
.kind
);
636 gfc_resolve_ibclr (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* pos ATTRIBUTE_UNUSED
)
639 f
->value
.function
.name
= gfc_get_string ("__ibclr_%d", i
->ts
.kind
);
644 gfc_resolve_ibits (gfc_expr
* f
, gfc_expr
* i
,
645 gfc_expr
* pos ATTRIBUTE_UNUSED
,
646 gfc_expr
* len ATTRIBUTE_UNUSED
)
649 f
->value
.function
.name
= gfc_get_string ("__ibits_%d", i
->ts
.kind
);
654 gfc_resolve_ibset (gfc_expr
* f
, gfc_expr
* i
,
655 gfc_expr
* pos ATTRIBUTE_UNUSED
)
658 f
->value
.function
.name
= gfc_get_string ("__ibset_%d", i
->ts
.kind
);
663 gfc_resolve_ichar (gfc_expr
* f
, gfc_expr
* c
)
665 f
->ts
.type
= BT_INTEGER
;
666 f
->ts
.kind
= gfc_default_integer_kind
;
668 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
673 gfc_resolve_idnint (gfc_expr
* f
, gfc_expr
* a
)
675 gfc_resolve_nint (f
, a
, NULL
);
680 gfc_resolve_ierrno (gfc_expr
* f
)
682 f
->ts
.type
= BT_INTEGER
;
683 f
->ts
.kind
= gfc_default_integer_kind
;
684 f
->value
.function
.name
= gfc_get_string (PREFIX("ierrno_i%d"), f
->ts
.kind
);
689 gfc_resolve_ieor (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
691 /* If the kind of i and j are different, then g77 cross-promoted the
692 kinds to the largest value. The Fortran 95 standard requires the
694 if (i
->ts
.kind
!= j
->ts
.kind
)
696 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
697 gfc_convert_type(j
, &i
->ts
, 2);
699 gfc_convert_type(i
, &j
->ts
, 2);
703 f
->value
.function
.name
= gfc_get_string ("__ieor_%d", i
->ts
.kind
);
708 gfc_resolve_ior (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
710 /* If the kind of i and j are different, then g77 cross-promoted the
711 kinds to the largest value. The Fortran 95 standard requires the
713 if (i
->ts
.kind
!= j
->ts
.kind
)
715 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
716 gfc_convert_type(j
, &i
->ts
, 2);
718 gfc_convert_type(i
, &j
->ts
, 2);
722 f
->value
.function
.name
= gfc_get_string ("__ior_%d", i
->ts
.kind
);
727 gfc_resolve_int (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
729 f
->ts
.type
= BT_INTEGER
;
730 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
731 : mpz_get_si (kind
->value
.integer
);
733 f
->value
.function
.name
=
734 gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
, gfc_type_letter (a
->ts
.type
),
740 gfc_resolve_isatty (gfc_expr
* f
, gfc_expr
* u
)
744 f
->ts
.type
= BT_LOGICAL
;
745 f
->ts
.kind
= gfc_default_integer_kind
;
746 if (u
->ts
.kind
!= gfc_c_int_kind
)
748 ts
.type
= BT_INTEGER
;
749 ts
.kind
= gfc_c_int_kind
;
752 gfc_convert_type (u
, &ts
, 2);
755 f
->value
.function
.name
= gfc_get_string (PREFIX("isatty_l%d"), f
->ts
.kind
);
760 gfc_resolve_ishft (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* shift
)
763 f
->value
.function
.name
=
764 gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
769 gfc_resolve_ishftc (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* shift
,
774 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: shift
->ts
.kind
;
777 f
->value
.function
.name
=
778 gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
783 gfc_resolve_kill (gfc_expr
* f
, ATTRIBUTE_UNUSED gfc_expr
* p
,
784 ATTRIBUTE_UNUSED gfc_expr
* s
)
786 f
->ts
.type
= BT_INTEGER
;
787 f
->ts
.kind
= gfc_default_integer_kind
;
789 f
->value
.function
.name
= gfc_get_string (PREFIX("kill_i%d"), f
->ts
.kind
);
794 gfc_resolve_lbound (gfc_expr
* f
, gfc_expr
* array
,
797 static char lbound
[] = "__lbound";
799 f
->ts
.type
= BT_INTEGER
;
800 f
->ts
.kind
= gfc_default_integer_kind
;
805 f
->shape
= gfc_get_shape (1);
806 mpz_init_set_ui (f
->shape
[0], array
->rank
);
809 f
->value
.function
.name
= lbound
;
814 gfc_resolve_len (gfc_expr
* f
, gfc_expr
* string
)
816 f
->ts
.type
= BT_INTEGER
;
817 f
->ts
.kind
= gfc_default_integer_kind
;
818 f
->value
.function
.name
= gfc_get_string ("__len_%d", string
->ts
.kind
);
823 gfc_resolve_len_trim (gfc_expr
* f
, gfc_expr
* string
)
825 f
->ts
.type
= BT_INTEGER
;
826 f
->ts
.kind
= gfc_default_integer_kind
;
827 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
832 gfc_resolve_link (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
833 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
835 f
->ts
.type
= BT_INTEGER
;
836 f
->ts
.kind
= gfc_default_integer_kind
;
837 f
->value
.function
.name
= gfc_get_string (PREFIX("link_i%d"), f
->ts
.kind
);
842 gfc_resolve_log (gfc_expr
* f
, gfc_expr
* x
)
845 f
->value
.function
.name
=
846 gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
851 gfc_resolve_log10 (gfc_expr
* f
, gfc_expr
* x
)
854 f
->value
.function
.name
=
855 gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
860 gfc_resolve_logical (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
862 f
->ts
.type
= BT_LOGICAL
;
863 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_logical_kind
864 : mpz_get_si (kind
->value
.integer
);
867 f
->value
.function
.name
=
868 gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
869 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
874 gfc_resolve_matmul (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b
)
878 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
880 f
->ts
.type
= BT_LOGICAL
;
881 f
->ts
.kind
= gfc_default_logical_kind
;
885 temp
.expr_type
= EXPR_OP
;
886 gfc_clear_ts (&temp
.ts
);
887 temp
.value
.op
.operator = INTRINSIC_NONE
;
888 temp
.value
.op
.op1
= a
;
889 temp
.value
.op
.op2
= b
;
890 gfc_type_convert_binary (&temp
);
894 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
896 f
->value
.function
.name
=
897 gfc_get_string (PREFIX("matmul_%c%d"), gfc_type_letter (f
->ts
.type
),
903 gfc_resolve_minmax (const char * name
, gfc_expr
* f
, gfc_actual_arglist
* args
)
905 gfc_actual_arglist
*a
;
907 f
->ts
.type
= args
->expr
->ts
.type
;
908 f
->ts
.kind
= args
->expr
->ts
.kind
;
909 /* Find the largest type kind. */
910 for (a
= args
->next
; a
; a
= a
->next
)
912 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
913 f
->ts
.kind
= a
->expr
->ts
.kind
;
916 /* Convert all parameters to the required kind. */
917 for (a
= args
; a
; a
= a
->next
)
919 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
920 gfc_convert_type (a
->expr
, &f
->ts
, 2);
923 f
->value
.function
.name
=
924 gfc_get_string (name
, gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
929 gfc_resolve_max (gfc_expr
* f
, gfc_actual_arglist
* args
)
931 gfc_resolve_minmax ("__max_%c%d", f
, args
);
936 gfc_resolve_maxloc (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
941 f
->ts
.type
= BT_INTEGER
;
942 f
->ts
.kind
= gfc_default_integer_kind
;
948 f
->rank
= array
->rank
- 1;
949 gfc_resolve_dim_arg (dim
);
952 name
= mask
? "mmaxloc" : "maxloc";
953 f
->value
.function
.name
=
954 gfc_get_string (PREFIX("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
955 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
960 gfc_resolve_maxval (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
967 f
->rank
= array
->rank
- 1;
968 gfc_resolve_dim_arg (dim
);
971 f
->value
.function
.name
=
972 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mmaxval" : "maxval",
973 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
978 gfc_resolve_merge (gfc_expr
* f
, gfc_expr
* tsource
,
979 gfc_expr
* fsource ATTRIBUTE_UNUSED
,
980 gfc_expr
* mask ATTRIBUTE_UNUSED
)
983 f
->value
.function
.name
=
984 gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
990 gfc_resolve_min (gfc_expr
* f
, gfc_actual_arglist
* args
)
992 gfc_resolve_minmax ("__min_%c%d", f
, args
);
997 gfc_resolve_minloc (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1002 f
->ts
.type
= BT_INTEGER
;
1003 f
->ts
.kind
= gfc_default_integer_kind
;
1009 f
->rank
= array
->rank
- 1;
1010 gfc_resolve_dim_arg (dim
);
1013 name
= mask
? "mminloc" : "minloc";
1014 f
->value
.function
.name
=
1015 gfc_get_string (PREFIX("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
1016 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1021 gfc_resolve_minval (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1028 f
->rank
= array
->rank
- 1;
1029 gfc_resolve_dim_arg (dim
);
1032 f
->value
.function
.name
=
1033 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mminval" : "minval",
1034 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1039 gfc_resolve_mod (gfc_expr
* f
, gfc_expr
* a
,
1040 gfc_expr
* p ATTRIBUTE_UNUSED
)
1043 f
->value
.function
.name
=
1044 gfc_get_string ("__mod_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1049 gfc_resolve_modulo (gfc_expr
* f
, gfc_expr
* a
,
1050 gfc_expr
* p ATTRIBUTE_UNUSED
)
1053 f
->value
.function
.name
=
1054 gfc_get_string ("__modulo_%c%d", gfc_type_letter (a
->ts
.type
),
1059 gfc_resolve_nearest (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
*p ATTRIBUTE_UNUSED
)
1062 f
->value
.function
.name
=
1063 gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
1068 gfc_resolve_nint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
1070 f
->ts
.type
= BT_INTEGER
;
1071 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
1072 : mpz_get_si (kind
->value
.integer
);
1074 f
->value
.function
.name
=
1075 gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
1080 gfc_resolve_not (gfc_expr
* f
, gfc_expr
* i
)
1083 f
->value
.function
.name
= gfc_get_string ("__not_%d", i
->ts
.kind
);
1088 gfc_resolve_pack (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* mask
,
1089 gfc_expr
* vector ATTRIBUTE_UNUSED
)
1094 if (mask
->rank
!= 0)
1095 f
->value
.function
.name
= (array
->ts
.type
== BT_CHARACTER
1096 ? PREFIX("pack_char")
1100 /* We convert mask to default logical only in the scalar case.
1101 In the array case we can simply read the array as if it were
1102 of type default logical. */
1103 if (mask
->ts
.kind
!= gfc_default_logical_kind
)
1107 ts
.type
= BT_LOGICAL
;
1108 ts
.kind
= gfc_default_logical_kind
;
1109 gfc_convert_type (mask
, &ts
, 2);
1112 f
->value
.function
.name
= (array
->ts
.type
== BT_CHARACTER
1113 ? PREFIX("pack_s_char")
1114 : PREFIX("pack_s"));
1120 gfc_resolve_product (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1127 f
->rank
= array
->rank
- 1;
1128 gfc_resolve_dim_arg (dim
);
1131 f
->value
.function
.name
=
1132 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mproduct" : "product",
1133 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1138 gfc_resolve_real (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
1140 f
->ts
.type
= BT_REAL
;
1143 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1145 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
) ?
1146 a
->ts
.kind
: gfc_default_real_kind
;
1148 f
->value
.function
.name
=
1149 gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1150 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1155 gfc_resolve_realpart (gfc_expr
* f
, gfc_expr
* a
)
1157 f
->ts
.type
= BT_REAL
;
1158 f
->ts
.kind
= a
->ts
.kind
;
1159 f
->value
.function
.name
=
1160 gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1161 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1166 gfc_resolve_rename (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
1167 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
1169 f
->ts
.type
= BT_INTEGER
;
1170 f
->ts
.kind
= gfc_default_integer_kind
;
1171 f
->value
.function
.name
= gfc_get_string (PREFIX("rename_i%d"), f
->ts
.kind
);
1176 gfc_resolve_repeat (gfc_expr
* f
, gfc_expr
* string
,
1177 gfc_expr
* ncopies ATTRIBUTE_UNUSED
)
1179 f
->ts
.type
= BT_CHARACTER
;
1180 f
->ts
.kind
= string
->ts
.kind
;
1181 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
1186 gfc_resolve_reshape (gfc_expr
* f
, gfc_expr
* source
, gfc_expr
* shape
,
1187 gfc_expr
* pad ATTRIBUTE_UNUSED
,
1188 gfc_expr
* order ATTRIBUTE_UNUSED
)
1196 gfc_array_size (shape
, &rank
);
1197 f
->rank
= mpz_get_si (rank
);
1199 switch (source
->ts
.type
)
1202 kind
= source
->ts
.kind
* 2;
1208 kind
= source
->ts
.kind
;
1222 if (source
->ts
.type
== BT_COMPLEX
)
1223 f
->value
.function
.name
=
1224 gfc_get_string (PREFIX("reshape_%c%d"),
1225 gfc_type_letter (BT_COMPLEX
), source
->ts
.kind
);
1227 f
->value
.function
.name
=
1228 gfc_get_string (PREFIX("reshape_%d"), source
->ts
.kind
);
1233 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
1234 ? PREFIX("reshape_char")
1235 : PREFIX("reshape"));
1239 /* TODO: Make this work with a constant ORDER parameter. */
1240 if (shape
->expr_type
== EXPR_ARRAY
1241 && gfc_is_constant_expr (shape
)
1245 f
->shape
= gfc_get_shape (f
->rank
);
1246 c
= shape
->value
.constructor
;
1247 for (i
= 0; i
< f
->rank
; i
++)
1249 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
1254 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
1255 so many runtime variations. */
1256 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
1258 gfc_typespec ts
= shape
->ts
;
1259 ts
.kind
= gfc_index_integer_kind
;
1260 gfc_convert_type_warn (shape
, &ts
, 2, 0);
1262 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
1263 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
1268 gfc_resolve_rrspacing (gfc_expr
* f
, gfc_expr
* x
)
1271 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
1276 gfc_resolve_scale (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* i
)
1280 /* The implementation calls scalbn which takes an int as the
1282 if (i
->ts
.kind
!= gfc_c_int_kind
)
1286 ts
.type
= BT_INTEGER
;
1287 ts
.kind
= gfc_default_integer_kind
;
1289 gfc_convert_type_warn (i
, &ts
, 2, 0);
1292 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
1297 gfc_resolve_scan (gfc_expr
* f
, gfc_expr
* string
,
1298 gfc_expr
* set ATTRIBUTE_UNUSED
,
1299 gfc_expr
* back ATTRIBUTE_UNUSED
)
1301 f
->ts
.type
= BT_INTEGER
;
1302 f
->ts
.kind
= gfc_default_integer_kind
;
1303 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
1308 gfc_resolve_set_exponent (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* i
)
1312 /* The library implementation uses GFC_INTEGER_4 unconditionally,
1313 convert type so we don't have to implement all possible
1315 if (i
->ts
.kind
!= 4)
1319 ts
.type
= BT_INTEGER
;
1320 ts
.kind
= gfc_default_integer_kind
;
1322 gfc_convert_type_warn (i
, &ts
, 2, 0);
1325 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
1330 gfc_resolve_shape (gfc_expr
* f
, gfc_expr
* array
)
1332 f
->ts
.type
= BT_INTEGER
;
1333 f
->ts
.kind
= gfc_default_integer_kind
;
1335 f
->value
.function
.name
= gfc_get_string (PREFIX("shape_%d"), f
->ts
.kind
);
1336 f
->shape
= gfc_get_shape (1);
1337 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1342 gfc_resolve_sign (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b ATTRIBUTE_UNUSED
)
1345 f
->value
.function
.name
=
1346 gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1351 gfc_resolve_sin (gfc_expr
* f
, gfc_expr
* x
)
1354 f
->value
.function
.name
=
1355 gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1360 gfc_resolve_sinh (gfc_expr
* f
, gfc_expr
* x
)
1363 f
->value
.function
.name
=
1364 gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1369 gfc_resolve_spacing (gfc_expr
* f
, gfc_expr
* x
)
1372 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
1377 gfc_resolve_spread (gfc_expr
* f
, gfc_expr
* source
,
1382 f
->rank
= source
->rank
+ 1;
1383 f
->value
.function
.name
= (source
->ts
.type
== BT_CHARACTER
1384 ? PREFIX("spread_char")
1385 : PREFIX("spread"));
1387 gfc_resolve_dim_arg (dim
);
1388 gfc_resolve_index (ncopies
, 1);
1393 gfc_resolve_sqrt (gfc_expr
* f
, gfc_expr
* x
)
1396 f
->value
.function
.name
=
1397 gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1401 /* Resolve the g77 compatibility function STAT AND FSTAT. */
1404 gfc_resolve_stat (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
,
1405 gfc_expr
* a ATTRIBUTE_UNUSED
)
1407 f
->ts
.type
= BT_INTEGER
;
1408 f
->ts
.kind
= gfc_default_integer_kind
;
1409 f
->value
.function
.name
= gfc_get_string (PREFIX("stat_i%d"), f
->ts
.kind
);
1414 gfc_resolve_fstat (gfc_expr
* f
, gfc_expr
* n
, gfc_expr
* a ATTRIBUTE_UNUSED
)
1416 f
->ts
.type
= BT_INTEGER
;
1417 f
->ts
.kind
= gfc_default_integer_kind
;
1418 if (n
->ts
.kind
!= f
->ts
.kind
)
1419 gfc_convert_type (n
, &f
->ts
, 2);
1421 f
->value
.function
.name
= gfc_get_string (PREFIX("fstat_i%d"), f
->ts
.kind
);
1426 gfc_resolve_sum (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1433 f
->rank
= array
->rank
- 1;
1434 gfc_resolve_dim_arg (dim
);
1437 f
->value
.function
.name
=
1438 gfc_get_string (PREFIX("%s_%c%d"), mask
? "msum" : "sum",
1439 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1444 gfc_resolve_symlnk (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
1445 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
1447 f
->ts
.type
= BT_INTEGER
;
1448 f
->ts
.kind
= gfc_default_integer_kind
;
1449 f
->value
.function
.name
= gfc_get_string (PREFIX("symlnk_i%d"), f
->ts
.kind
);
1453 /* Resolve the g77 compatibility function SYSTEM. */
1456 gfc_resolve_system (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
1458 f
->ts
.type
= BT_INTEGER
;
1460 f
->value
.function
.name
= gfc_get_string (PREFIX("system"));
1465 gfc_resolve_tan (gfc_expr
* f
, gfc_expr
* x
)
1468 f
->value
.function
.name
=
1469 gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1474 gfc_resolve_tanh (gfc_expr
* f
, gfc_expr
* x
)
1477 f
->value
.function
.name
=
1478 gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1483 gfc_resolve_time (gfc_expr
* f
)
1485 f
->ts
.type
= BT_INTEGER
;
1487 f
->value
.function
.name
= gfc_get_string (PREFIX("time_func"));
1492 gfc_resolve_time8 (gfc_expr
* f
)
1494 f
->ts
.type
= BT_INTEGER
;
1496 f
->value
.function
.name
= gfc_get_string (PREFIX("time8_func"));
1501 gfc_resolve_transfer (gfc_expr
* f
, gfc_expr
* source ATTRIBUTE_UNUSED
,
1502 gfc_expr
* mold
, gfc_expr
* size
)
1504 /* TODO: Make this do something meaningful. */
1505 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
1509 if (size
== NULL
&& mold
->rank
== 0)
1512 f
->value
.function
.name
= transfer0
;
1517 f
->value
.function
.name
= transfer1
;
1523 gfc_resolve_transpose (gfc_expr
* f
, gfc_expr
* matrix
)
1531 f
->shape
= gfc_get_shape (2);
1532 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
1533 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
1536 kind
= matrix
->ts
.kind
;
1544 switch (matrix
->ts
.type
)
1547 f
->value
.function
.name
=
1548 gfc_get_string (PREFIX("transpose_c%d"), kind
);
1554 /* Use the integer routines for real and logical cases. This
1555 assumes they all have the same alignment requirements. */
1556 f
->value
.function
.name
=
1557 gfc_get_string (PREFIX("transpose_i%d"), kind
);
1561 f
->value
.function
.name
= PREFIX("transpose");
1567 f
->value
.function
.name
= (matrix
->ts
.type
== BT_CHARACTER
1568 ? PREFIX("transpose_char")
1569 : PREFIX("transpose"));
1576 gfc_resolve_trim (gfc_expr
* f
, gfc_expr
* string
)
1578 f
->ts
.type
= BT_CHARACTER
;
1579 f
->ts
.kind
= string
->ts
.kind
;
1580 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
1585 gfc_resolve_ubound (gfc_expr
* f
, gfc_expr
* array
,
1588 static char ubound
[] = "__ubound";
1590 f
->ts
.type
= BT_INTEGER
;
1591 f
->ts
.kind
= gfc_default_integer_kind
;
1596 f
->shape
= gfc_get_shape (1);
1597 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1600 f
->value
.function
.name
= ubound
;
1604 /* Resolve the g77 compatibility function UMASK. */
1607 gfc_resolve_umask (gfc_expr
* f
, gfc_expr
* n
)
1609 f
->ts
.type
= BT_INTEGER
;
1610 f
->ts
.kind
= n
->ts
.kind
;
1611 f
->value
.function
.name
= gfc_get_string (PREFIX("umask_i%d"), n
->ts
.kind
);
1615 /* Resolve the g77 compatibility function UNLINK. */
1618 gfc_resolve_unlink (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
1620 f
->ts
.type
= BT_INTEGER
;
1622 f
->value
.function
.name
= gfc_get_string (PREFIX("unlink"));
1626 gfc_resolve_unpack (gfc_expr
* f
, gfc_expr
* vector
, gfc_expr
* mask
,
1627 gfc_expr
* field ATTRIBUTE_UNUSED
)
1630 f
->rank
= mask
->rank
;
1632 f
->value
.function
.name
=
1633 gfc_get_string (PREFIX("unpack%d%s"), field
->rank
> 0 ? 1 : 0,
1634 vector
->ts
.type
== BT_CHARACTER
? "_char" : "");
1639 gfc_resolve_verify (gfc_expr
* f
, gfc_expr
* string
,
1640 gfc_expr
* set ATTRIBUTE_UNUSED
,
1641 gfc_expr
* back ATTRIBUTE_UNUSED
)
1643 f
->ts
.type
= BT_INTEGER
;
1644 f
->ts
.kind
= gfc_default_integer_kind
;
1645 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
1649 /* Intrinsic subroutine resolution. */
1652 gfc_resolve_cpu_time (gfc_code
* c ATTRIBUTE_UNUSED
)
1656 name
= gfc_get_string (PREFIX("cpu_time_%d"),
1657 c
->ext
.actual
->expr
->ts
.kind
);
1658 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1663 gfc_resolve_mvbits (gfc_code
* c
)
1668 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1669 name
= gfc_get_string (PREFIX("mvbits_i%d"), kind
);
1671 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1676 gfc_resolve_random_number (gfc_code
* c ATTRIBUTE_UNUSED
)
1681 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1682 if (c
->ext
.actual
->expr
->rank
== 0)
1683 name
= gfc_get_string (PREFIX("random_r%d"), kind
);
1685 name
= gfc_get_string (PREFIX("arandom_r%d"), kind
);
1687 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1692 gfc_resolve_rename_sub (gfc_code
* c
)
1697 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1698 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1700 kind
= gfc_default_integer_kind
;
1702 name
= gfc_get_string (PREFIX("rename_i%d_sub"), kind
);
1703 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1708 gfc_resolve_kill_sub (gfc_code
* c
)
1713 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1714 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1716 kind
= gfc_default_integer_kind
;
1718 name
= gfc_get_string (PREFIX("kill_i%d_sub"), kind
);
1719 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1724 gfc_resolve_link_sub (gfc_code
* c
)
1729 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1730 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1732 kind
= gfc_default_integer_kind
;
1734 name
= gfc_get_string (PREFIX("link_i%d_sub"), kind
);
1735 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1740 gfc_resolve_symlnk_sub (gfc_code
* c
)
1745 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1746 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1748 kind
= gfc_default_integer_kind
;
1750 name
= gfc_get_string (PREFIX("symlnk_i%d_sub"), kind
);
1751 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1755 /* G77 compatibility subroutines etime() and dtime(). */
1758 gfc_resolve_etime_sub (gfc_code
* c
)
1762 name
= gfc_get_string (PREFIX("etime_sub"));
1763 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1767 /* G77 compatibility subroutine second(). */
1770 gfc_resolve_second_sub (gfc_code
* c
)
1774 name
= gfc_get_string (PREFIX("second_sub"));
1775 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1780 gfc_resolve_sleep_sub (gfc_code
* c
)
1785 if (c
->ext
.actual
->expr
!= NULL
)
1786 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1788 kind
= gfc_default_integer_kind
;
1790 name
= gfc_get_string (PREFIX("sleep_i%d_sub"), kind
);
1791 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1795 /* G77 compatibility function srand(). */
1798 gfc_resolve_srand (gfc_code
* c
)
1801 name
= gfc_get_string (PREFIX("srand"));
1802 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1806 /* Resolve the getarg intrinsic subroutine. */
1809 gfc_resolve_getarg (gfc_code
* c
)
1814 kind
= gfc_default_integer_kind
;
1815 name
= gfc_get_string (PREFIX("getarg_i%d"), kind
);
1816 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1819 /* Resolve the getcwd intrinsic subroutine. */
1822 gfc_resolve_getcwd_sub (gfc_code
* c
)
1827 if (c
->ext
.actual
->next
->expr
!= NULL
)
1828 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1830 kind
= gfc_default_integer_kind
;
1832 name
= gfc_get_string (PREFIX("getcwd_i%d_sub"), kind
);
1833 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1837 /* Resolve the get_command intrinsic subroutine. */
1840 gfc_resolve_get_command (gfc_code
* c
)
1845 kind
= gfc_default_integer_kind
;
1846 name
= gfc_get_string (PREFIX("get_command_i%d"), kind
);
1847 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1851 /* Resolve the get_command_argument intrinsic subroutine. */
1854 gfc_resolve_get_command_argument (gfc_code
* c
)
1859 kind
= gfc_default_integer_kind
;
1860 name
= gfc_get_string (PREFIX("get_command_argument_i%d"), kind
);
1861 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1864 /* Resolve the get_environment_variable intrinsic subroutine. */
1867 gfc_resolve_get_environment_variable (gfc_code
* code
)
1872 kind
= gfc_default_integer_kind
;
1873 name
= gfc_get_string (PREFIX("get_environment_variable_i%d"), kind
);
1874 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1877 /* Resolve the SYSTEM intrinsic subroutine. */
1880 gfc_resolve_system_sub (gfc_code
* c
)
1884 name
= gfc_get_string (PREFIX("system_sub"));
1885 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1888 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
1891 gfc_resolve_system_clock (gfc_code
* c
)
1896 if (c
->ext
.actual
->expr
!= NULL
)
1897 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1898 else if (c
->ext
.actual
->next
->expr
!= NULL
)
1899 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1900 else if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1901 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1903 kind
= gfc_default_integer_kind
;
1905 name
= gfc_get_string (PREFIX("system_clock_%d"), kind
);
1906 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1909 /* Resolve the EXIT intrinsic subroutine. */
1912 gfc_resolve_exit (gfc_code
* c
)
1917 if (c
->ext
.actual
->expr
!= NULL
)
1918 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1920 kind
= gfc_default_integer_kind
;
1922 name
= gfc_get_string (PREFIX("exit_i%d"), kind
);
1923 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1926 /* Resolve the FLUSH intrinsic subroutine. */
1929 gfc_resolve_flush (gfc_code
* c
)
1935 ts
.type
= BT_INTEGER
;
1936 ts
.kind
= gfc_default_integer_kind
;
1937 n
= c
->ext
.actual
->expr
;
1939 && n
->ts
.kind
!= ts
.kind
)
1940 gfc_convert_type (n
, &ts
, 2);
1942 name
= gfc_get_string (PREFIX("flush_i%d"), ts
.kind
);
1943 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1948 gfc_resolve_gerror (gfc_code
* c
)
1950 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
1955 gfc_resolve_getlog (gfc_code
* c
)
1957 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
1962 gfc_resolve_hostnm_sub (gfc_code
* c
)
1967 if (c
->ext
.actual
->next
->expr
!= NULL
)
1968 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1970 kind
= gfc_default_integer_kind
;
1972 name
= gfc_get_string (PREFIX("hostnm_i%d_sub"), kind
);
1973 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1978 gfc_resolve_perror (gfc_code
* c
)
1980 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
1983 /* Resolve the STAT and FSTAT intrinsic subroutines. */
1986 gfc_resolve_stat_sub (gfc_code
* c
)
1990 name
= gfc_get_string (PREFIX("stat_i%d_sub"), gfc_default_integer_kind
);
1991 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1996 gfc_resolve_fstat_sub (gfc_code
* c
)
2002 u
= c
->ext
.actual
->expr
;
2003 ts
= &c
->ext
.actual
->next
->expr
->ts
;
2004 if (u
->ts
.kind
!= ts
->kind
)
2005 gfc_convert_type (u
, ts
, 2);
2006 name
= gfc_get_string (PREFIX("fstat_i%d_sub"), ts
->kind
);
2007 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2012 gfc_resolve_ttynam_sub (gfc_code
* c
)
2016 if (c
->ext
.actual
->expr
->ts
.kind
!= gfc_c_int_kind
)
2018 ts
.type
= BT_INTEGER
;
2019 ts
.kind
= gfc_c_int_kind
;
2022 gfc_convert_type (c
->ext
.actual
->expr
, &ts
, 2);
2025 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX("ttynam_sub"));
2029 /* Resolve the UMASK intrinsic subroutine. */
2032 gfc_resolve_umask_sub (gfc_code
* c
)
2037 if (c
->ext
.actual
->next
->expr
!= NULL
)
2038 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2040 kind
= gfc_default_integer_kind
;
2042 name
= gfc_get_string (PREFIX("umask_i%d_sub"), kind
);
2043 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
2046 /* Resolve the UNLINK intrinsic subroutine. */
2049 gfc_resolve_unlink_sub (gfc_code
* c
)
2054 if (c
->ext
.actual
->next
->expr
!= NULL
)
2055 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
2057 kind
= gfc_default_integer_kind
;
2059 name
= gfc_get_string (PREFIX("unlink_i%d_sub"), kind
);
2060 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);