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, 59 Temple Place - Suite 330, 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_aimag (gfc_expr
* f
, gfc_expr
* x
)
90 f
->ts
.kind
= x
->ts
.kind
;
91 f
->value
.function
.name
=
92 gfc_get_string ("__aimag_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
97 gfc_resolve_aint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
99 f
->ts
.type
= a
->ts
.type
;
100 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
102 /* The resolved name is only used for specific intrinsics where
103 the return kind is the same as the arg kind. */
104 f
->value
.function
.name
=
105 gfc_get_string ("__aint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
110 gfc_resolve_dint (gfc_expr
* f
, gfc_expr
* a
)
112 gfc_resolve_aint (f
, a
, NULL
);
117 gfc_resolve_all (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
123 gfc_resolve_index (dim
, 1);
124 f
->rank
= mask
->rank
- 1;
125 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
128 f
->value
.function
.name
=
129 gfc_get_string (PREFIX("all_%c%d"), gfc_type_letter (mask
->ts
.type
),
135 gfc_resolve_anint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
137 f
->ts
.type
= a
->ts
.type
;
138 f
->ts
.kind
= (kind
== NULL
) ? a
->ts
.kind
: mpz_get_si (kind
->value
.integer
);
140 /* The resolved name is only used for specific intrinsics where
141 the return kind is the same as the arg kind. */
142 f
->value
.function
.name
=
143 gfc_get_string ("__anint_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
148 gfc_resolve_dnint (gfc_expr
* f
, gfc_expr
* a
)
150 gfc_resolve_anint (f
, a
, NULL
);
155 gfc_resolve_any (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
161 gfc_resolve_index (dim
, 1);
162 f
->rank
= mask
->rank
- 1;
163 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
166 f
->value
.function
.name
=
167 gfc_get_string (PREFIX("any_%c%d"), gfc_type_letter (mask
->ts
.type
),
173 gfc_resolve_asin (gfc_expr
* f
, gfc_expr
* x
)
176 f
->value
.function
.name
=
177 gfc_get_string ("__asin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
182 gfc_resolve_atan (gfc_expr
* f
, gfc_expr
* x
)
185 f
->value
.function
.name
=
186 gfc_get_string ("__atan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
191 gfc_resolve_atan2 (gfc_expr
* f
, gfc_expr
* x
,
192 gfc_expr
* y ATTRIBUTE_UNUSED
)
195 f
->value
.function
.name
=
196 gfc_get_string ("__atan2_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
200 /* Resolve the BESYN and BESJN intrinsics. */
203 gfc_resolve_besn (gfc_expr
* f
, gfc_expr
* n
, gfc_expr
* x
)
208 if (n
->ts
.kind
!= gfc_c_int_kind
)
210 ts
.type
= BT_INTEGER
;
211 ts
.kind
= gfc_c_int_kind
;
212 gfc_convert_type (n
, &ts
, 2);
214 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
219 gfc_resolve_btest (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* pos
)
221 f
->ts
.type
= BT_LOGICAL
;
222 f
->ts
.kind
= gfc_default_logical_kind
;
224 f
->value
.function
.name
= gfc_get_string ("__btest_%d_%d", i
->ts
.kind
,
230 gfc_resolve_ceiling (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
232 f
->ts
.type
= BT_INTEGER
;
233 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
234 : mpz_get_si (kind
->value
.integer
);
236 f
->value
.function
.name
=
237 gfc_get_string ("__ceiling_%d_%c%d", f
->ts
.kind
,
238 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
243 gfc_resolve_char (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
245 f
->ts
.type
= BT_CHARACTER
;
246 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_character_kind
247 : mpz_get_si (kind
->value
.integer
);
249 f
->value
.function
.name
=
250 gfc_get_string ("__char_%d_%c%d", f
->ts
.kind
,
251 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
256 gfc_resolve_chdir (gfc_expr
* f
, gfc_expr
* d ATTRIBUTE_UNUSED
)
258 f
->ts
.type
= BT_INTEGER
;
259 f
->ts
.kind
= gfc_default_integer_kind
;
260 f
->value
.function
.name
= gfc_get_string (PREFIX("chdir_i%d"), f
->ts
.kind
);
265 gfc_resolve_chdir_sub (gfc_code
* c
)
270 if (c
->ext
.actual
->next
->expr
!= NULL
)
271 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
273 kind
= gfc_default_integer_kind
;
275 name
= gfc_get_string (PREFIX("chdir_i%d_sub"), kind
);
276 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
281 gfc_resolve_cmplx (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* y
, gfc_expr
* kind
)
283 f
->ts
.type
= BT_COMPLEX
;
284 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_real_kind
285 : mpz_get_si (kind
->value
.integer
);
288 f
->value
.function
.name
=
289 gfc_get_string ("__cmplx0_%d_%c%d", f
->ts
.kind
,
290 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
292 f
->value
.function
.name
=
293 gfc_get_string ("__cmplx1_%d_%c%d_%c%d", f
->ts
.kind
,
294 gfc_type_letter (x
->ts
.type
), x
->ts
.kind
,
295 gfc_type_letter (y
->ts
.type
), y
->ts
.kind
);
299 gfc_resolve_dcmplx (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* y
)
301 gfc_resolve_cmplx (f
, x
, y
, gfc_int_expr (gfc_default_double_kind
));
305 gfc_resolve_conjg (gfc_expr
* f
, gfc_expr
* x
)
308 f
->value
.function
.name
= gfc_get_string ("__conjg_%d", x
->ts
.kind
);
313 gfc_resolve_cos (gfc_expr
* f
, gfc_expr
* x
)
316 f
->value
.function
.name
=
317 gfc_get_string ("__cos_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
322 gfc_resolve_cosh (gfc_expr
* f
, gfc_expr
* x
)
325 f
->value
.function
.name
=
326 gfc_get_string ("__cosh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
331 gfc_resolve_count (gfc_expr
* f
, gfc_expr
* mask
, gfc_expr
* dim
)
333 f
->ts
.type
= BT_INTEGER
;
334 f
->ts
.kind
= gfc_default_integer_kind
;
338 f
->rank
= mask
->rank
- 1;
339 gfc_resolve_index (dim
, 1);
340 f
->shape
= gfc_copy_shape_excluding (mask
->shape
, mask
->rank
, dim
);
343 f
->value
.function
.name
=
344 gfc_get_string (PREFIX("count_%d_%c%d"), f
->ts
.kind
,
345 gfc_type_letter (mask
->ts
.type
), mask
->ts
.kind
);
350 gfc_resolve_cshift (gfc_expr
* f
, gfc_expr
* array
,
357 f
->rank
= array
->rank
;
358 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
367 gfc_resolve_index (dim
, 1);
368 /* Convert dim to shift's kind, so we don't need so many variations. */
369 if (dim
->ts
.kind
!= shift
->ts
.kind
)
370 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
372 f
->value
.function
.name
=
373 gfc_get_string (PREFIX("cshift%d_%d"), n
, shift
->ts
.kind
);
378 gfc_resolve_dble (gfc_expr
* f
, gfc_expr
* a
)
380 f
->ts
.type
= BT_REAL
;
381 f
->ts
.kind
= gfc_default_double_kind
;
382 f
->value
.function
.name
=
383 gfc_get_string ("__dble_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
388 gfc_resolve_dim (gfc_expr
* f
, gfc_expr
* x
,
389 gfc_expr
* y ATTRIBUTE_UNUSED
)
392 f
->value
.function
.name
=
393 gfc_get_string ("__dim_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
398 gfc_resolve_dot_product (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b
)
402 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
404 f
->ts
.type
= BT_LOGICAL
;
405 f
->ts
.kind
= gfc_default_logical_kind
;
409 temp
.expr_type
= EXPR_OP
;
410 gfc_clear_ts (&temp
.ts
);
411 temp
.value
.op
.operator = INTRINSIC_NONE
;
412 temp
.value
.op
.op1
= a
;
413 temp
.value
.op
.op2
= b
;
414 gfc_type_convert_binary (&temp
);
418 f
->value
.function
.name
=
419 gfc_get_string (PREFIX("dot_product_%c%d"), gfc_type_letter (f
->ts
.type
),
425 gfc_resolve_dprod (gfc_expr
* f
,
426 gfc_expr
* a ATTRIBUTE_UNUSED
,
427 gfc_expr
* b ATTRIBUTE_UNUSED
)
429 f
->ts
.kind
= gfc_default_double_kind
;
430 f
->ts
.type
= BT_REAL
;
432 f
->value
.function
.name
= gfc_get_string ("__dprod_r%d", f
->ts
.kind
);
437 gfc_resolve_eoshift (gfc_expr
* f
, gfc_expr
* array
,
445 f
->rank
= array
->rank
;
446 f
->shape
= gfc_copy_shape (array
->shape
, array
->rank
);
451 if (boundary
&& boundary
->rank
> 0)
454 /* Convert dim to the same type as shift, so we don't need quite so many
456 if (dim
!= NULL
&& dim
->ts
.kind
!= shift
->ts
.kind
)
457 gfc_convert_type_warn (dim
, &shift
->ts
, 2, 0);
459 f
->value
.function
.name
=
460 gfc_get_string (PREFIX("eoshift%d_%d"), n
, shift
->ts
.kind
);
465 gfc_resolve_exp (gfc_expr
* f
, gfc_expr
* x
)
468 f
->value
.function
.name
=
469 gfc_get_string ("__exp_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
474 gfc_resolve_exponent (gfc_expr
* f
, gfc_expr
* x
)
476 f
->ts
.type
= BT_INTEGER
;
477 f
->ts
.kind
= gfc_default_integer_kind
;
479 f
->value
.function
.name
= gfc_get_string ("__exponent_%d", x
->ts
.kind
);
484 gfc_resolve_floor (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
486 f
->ts
.type
= BT_INTEGER
;
487 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
488 : mpz_get_si (kind
->value
.integer
);
490 f
->value
.function
.name
=
491 gfc_get_string ("__floor%d_%c%d", f
->ts
.kind
,
492 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
497 gfc_resolve_fnum (gfc_expr
* f
, gfc_expr
* n
)
499 f
->ts
.type
= BT_INTEGER
;
500 f
->ts
.kind
= gfc_default_integer_kind
;
501 if (n
->ts
.kind
!= f
->ts
.kind
)
502 gfc_convert_type (n
, &f
->ts
, 2);
503 f
->value
.function
.name
= gfc_get_string (PREFIX("fnum_i%d"), f
->ts
.kind
);
508 gfc_resolve_fraction (gfc_expr
* f
, gfc_expr
* x
)
511 f
->value
.function
.name
= gfc_get_string ("__fraction_%d", x
->ts
.kind
);
515 /* Resolve single-argument g77 math intrinsics, eg BESY0, ERF. */
518 gfc_resolve_g77_math1 (gfc_expr
* f
, gfc_expr
* x
)
521 f
->value
.function
.name
= gfc_get_string ("<intrinsic>");
526 gfc_resolve_getcwd (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
528 f
->ts
.type
= BT_INTEGER
;
530 f
->value
.function
.name
= gfc_get_string (PREFIX("getcwd"));
535 gfc_resolve_getgid (gfc_expr
* f
)
537 f
->ts
.type
= BT_INTEGER
;
539 f
->value
.function
.name
= gfc_get_string (PREFIX("getgid"));
544 gfc_resolve_getpid (gfc_expr
* f
)
546 f
->ts
.type
= BT_INTEGER
;
548 f
->value
.function
.name
= gfc_get_string (PREFIX("getpid"));
553 gfc_resolve_getuid (gfc_expr
* f
)
555 f
->ts
.type
= BT_INTEGER
;
557 f
->value
.function
.name
= gfc_get_string (PREFIX("getuid"));
561 gfc_resolve_hostnm (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
563 f
->ts
.type
= BT_INTEGER
;
565 f
->value
.function
.name
= gfc_get_string (PREFIX ("hostnm"));
569 gfc_resolve_iand (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
571 /* If the kind of i and j are different, then g77 cross-promoted the
572 kinds to the largest value. The Fortran 95 standard requires the
574 if (i
->ts
.kind
!= j
->ts
.kind
)
576 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
577 gfc_convert_type(j
, &i
->ts
, 2);
579 gfc_convert_type(i
, &j
->ts
, 2);
583 f
->value
.function
.name
= gfc_get_string ("__iand_%d", i
->ts
.kind
);
588 gfc_resolve_ibclr (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* pos ATTRIBUTE_UNUSED
)
591 f
->value
.function
.name
= gfc_get_string ("__ibclr_%d", i
->ts
.kind
);
596 gfc_resolve_ibits (gfc_expr
* f
, gfc_expr
* i
,
597 gfc_expr
* pos ATTRIBUTE_UNUSED
,
598 gfc_expr
* len ATTRIBUTE_UNUSED
)
601 f
->value
.function
.name
= gfc_get_string ("__ibits_%d", i
->ts
.kind
);
606 gfc_resolve_ibset (gfc_expr
* f
, gfc_expr
* i
,
607 gfc_expr
* pos ATTRIBUTE_UNUSED
)
610 f
->value
.function
.name
= gfc_get_string ("__ibset_%d", i
->ts
.kind
);
615 gfc_resolve_ichar (gfc_expr
* f
, gfc_expr
* c
)
617 f
->ts
.type
= BT_INTEGER
;
618 f
->ts
.kind
= gfc_default_integer_kind
;
620 f
->value
.function
.name
= gfc_get_string ("__ichar_%d", c
->ts
.kind
);
625 gfc_resolve_idnint (gfc_expr
* f
, gfc_expr
* a
)
627 gfc_resolve_nint (f
, a
, NULL
);
632 gfc_resolve_ierrno (gfc_expr
* f
)
634 f
->ts
.type
= BT_INTEGER
;
635 f
->ts
.kind
= gfc_default_integer_kind
;
636 f
->value
.function
.name
= gfc_get_string (PREFIX("ierrno_i%d"), f
->ts
.kind
);
641 gfc_resolve_ieor (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
643 /* If the kind of i and j are different, then g77 cross-promoted the
644 kinds to the largest value. The Fortran 95 standard requires the
646 if (i
->ts
.kind
!= j
->ts
.kind
)
648 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
649 gfc_convert_type(j
, &i
->ts
, 2);
651 gfc_convert_type(i
, &j
->ts
, 2);
655 f
->value
.function
.name
= gfc_get_string ("__ieor_%d", i
->ts
.kind
);
660 gfc_resolve_ior (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* j
)
662 /* If the kind of i and j are different, then g77 cross-promoted the
663 kinds to the largest value. The Fortran 95 standard requires the
665 if (i
->ts
.kind
!= j
->ts
.kind
)
667 if (i
->ts
.kind
== gfc_kind_max (i
,j
))
668 gfc_convert_type(j
, &i
->ts
, 2);
670 gfc_convert_type(i
, &j
->ts
, 2);
674 f
->value
.function
.name
= gfc_get_string ("__ior_%d", i
->ts
.kind
);
679 gfc_resolve_int (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
681 f
->ts
.type
= BT_INTEGER
;
682 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
683 : mpz_get_si (kind
->value
.integer
);
685 f
->value
.function
.name
=
686 gfc_get_string ("__int_%d_%c%d", f
->ts
.kind
, gfc_type_letter (a
->ts
.type
),
692 gfc_resolve_ishft (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* shift
)
695 f
->value
.function
.name
=
696 gfc_get_string ("__ishft_%d_%d", i
->ts
.kind
, shift
->ts
.kind
);
701 gfc_resolve_ishftc (gfc_expr
* f
, gfc_expr
* i
, gfc_expr
* shift
,
706 s_kind
= (size
== NULL
) ? gfc_default_integer_kind
: shift
->ts
.kind
;
709 f
->value
.function
.name
=
710 gfc_get_string ("__ishftc_%d_%d_%d", i
->ts
.kind
, shift
->ts
.kind
, s_kind
);
715 gfc_resolve_kill (gfc_expr
* f
, ATTRIBUTE_UNUSED gfc_expr
* p
,
716 ATTRIBUTE_UNUSED gfc_expr
* s
)
718 f
->ts
.type
= BT_INTEGER
;
719 f
->ts
.kind
= gfc_default_integer_kind
;
721 f
->value
.function
.name
= gfc_get_string (PREFIX("kill_i%d"), f
->ts
.kind
);
726 gfc_resolve_lbound (gfc_expr
* f
, gfc_expr
* array
,
729 static char lbound
[] = "__lbound";
731 f
->ts
.type
= BT_INTEGER
;
732 f
->ts
.kind
= gfc_default_integer_kind
;
737 f
->shape
= gfc_get_shape (1);
738 mpz_init_set_ui (f
->shape
[0], array
->rank
);
741 f
->value
.function
.name
= lbound
;
746 gfc_resolve_len (gfc_expr
* f
, gfc_expr
* string
)
748 f
->ts
.type
= BT_INTEGER
;
749 f
->ts
.kind
= gfc_default_integer_kind
;
750 f
->value
.function
.name
= gfc_get_string ("__len_%d", string
->ts
.kind
);
755 gfc_resolve_len_trim (gfc_expr
* f
, gfc_expr
* string
)
757 f
->ts
.type
= BT_INTEGER
;
758 f
->ts
.kind
= gfc_default_integer_kind
;
759 f
->value
.function
.name
= gfc_get_string ("__len_trim%d", string
->ts
.kind
);
764 gfc_resolve_link (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
765 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
767 f
->ts
.type
= BT_INTEGER
;
768 f
->ts
.kind
= gfc_default_integer_kind
;
769 f
->value
.function
.name
= gfc_get_string (PREFIX("link_i%d"), f
->ts
.kind
);
774 gfc_resolve_log (gfc_expr
* f
, gfc_expr
* x
)
777 f
->value
.function
.name
=
778 gfc_get_string ("__log_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
783 gfc_resolve_log10 (gfc_expr
* f
, gfc_expr
* x
)
786 f
->value
.function
.name
=
787 gfc_get_string ("__log10_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
792 gfc_resolve_logical (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
794 f
->ts
.type
= BT_LOGICAL
;
795 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_logical_kind
796 : mpz_get_si (kind
->value
.integer
);
799 f
->value
.function
.name
=
800 gfc_get_string ("__logical_%d_%c%d", f
->ts
.kind
,
801 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
806 gfc_resolve_matmul (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b
)
810 if (a
->ts
.type
== BT_LOGICAL
&& b
->ts
.type
== BT_LOGICAL
)
812 f
->ts
.type
= BT_LOGICAL
;
813 f
->ts
.kind
= gfc_default_logical_kind
;
817 temp
.expr_type
= EXPR_OP
;
818 gfc_clear_ts (&temp
.ts
);
819 temp
.value
.op
.operator = INTRINSIC_NONE
;
820 temp
.value
.op
.op1
= a
;
821 temp
.value
.op
.op2
= b
;
822 gfc_type_convert_binary (&temp
);
826 f
->rank
= (a
->rank
== 2 && b
->rank
== 2) ? 2 : 1;
828 f
->value
.function
.name
=
829 gfc_get_string (PREFIX("matmul_%c%d"), gfc_type_letter (f
->ts
.type
),
835 gfc_resolve_minmax (const char * name
, gfc_expr
* f
, gfc_actual_arglist
* args
)
837 gfc_actual_arglist
*a
;
839 f
->ts
.type
= args
->expr
->ts
.type
;
840 f
->ts
.kind
= args
->expr
->ts
.kind
;
841 /* Find the largest type kind. */
842 for (a
= args
->next
; a
; a
= a
->next
)
844 if (a
->expr
->ts
.kind
> f
->ts
.kind
)
845 f
->ts
.kind
= a
->expr
->ts
.kind
;
848 /* Convert all parameters to the required kind. */
849 for (a
= args
; a
; a
= a
->next
)
851 if (a
->expr
->ts
.kind
!= f
->ts
.kind
)
852 gfc_convert_type (a
->expr
, &f
->ts
, 2);
855 f
->value
.function
.name
=
856 gfc_get_string (name
, gfc_type_letter (f
->ts
.type
), f
->ts
.kind
);
861 gfc_resolve_max (gfc_expr
* f
, gfc_actual_arglist
* args
)
863 gfc_resolve_minmax ("__max_%c%d", f
, args
);
868 gfc_resolve_maxloc (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
873 f
->ts
.type
= BT_INTEGER
;
874 f
->ts
.kind
= gfc_default_integer_kind
;
880 f
->rank
= array
->rank
- 1;
881 gfc_resolve_index (dim
, 1);
884 name
= mask
? "mmaxloc" : "maxloc";
885 f
->value
.function
.name
=
886 gfc_get_string (PREFIX("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
887 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
892 gfc_resolve_maxval (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
899 f
->rank
= array
->rank
- 1;
900 gfc_resolve_index (dim
, 1);
903 f
->value
.function
.name
=
904 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mmaxval" : "maxval",
905 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
910 gfc_resolve_merge (gfc_expr
* f
, gfc_expr
* tsource
,
911 gfc_expr
* fsource ATTRIBUTE_UNUSED
,
912 gfc_expr
* mask ATTRIBUTE_UNUSED
)
915 f
->value
.function
.name
=
916 gfc_get_string ("__merge_%c%d", gfc_type_letter (tsource
->ts
.type
),
922 gfc_resolve_min (gfc_expr
* f
, gfc_actual_arglist
* args
)
924 gfc_resolve_minmax ("__min_%c%d", f
, args
);
929 gfc_resolve_minloc (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
934 f
->ts
.type
= BT_INTEGER
;
935 f
->ts
.kind
= gfc_default_integer_kind
;
941 f
->rank
= array
->rank
- 1;
942 gfc_resolve_index (dim
, 1);
945 name
= mask
? "mminloc" : "minloc";
946 f
->value
.function
.name
=
947 gfc_get_string (PREFIX("%s%d_%d_%c%d"), name
, dim
!= NULL
, f
->ts
.kind
,
948 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
953 gfc_resolve_minval (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
960 f
->rank
= array
->rank
- 1;
961 gfc_resolve_index (dim
, 1);
964 f
->value
.function
.name
=
965 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mminval" : "minval",
966 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
971 gfc_resolve_mod (gfc_expr
* f
, gfc_expr
* a
,
972 gfc_expr
* p ATTRIBUTE_UNUSED
)
975 f
->value
.function
.name
=
976 gfc_get_string ("__mod_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
981 gfc_resolve_modulo (gfc_expr
* f
, gfc_expr
* a
,
982 gfc_expr
* p ATTRIBUTE_UNUSED
)
985 f
->value
.function
.name
=
986 gfc_get_string ("__modulo_%c%d", gfc_type_letter (a
->ts
.type
),
991 gfc_resolve_nearest (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
*p ATTRIBUTE_UNUSED
)
994 f
->value
.function
.name
=
995 gfc_get_string ("__nearest_%c%d", gfc_type_letter (a
->ts
.type
),
1000 gfc_resolve_nint (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
1002 f
->ts
.type
= BT_INTEGER
;
1003 f
->ts
.kind
= (kind
== NULL
) ? gfc_default_integer_kind
1004 : mpz_get_si (kind
->value
.integer
);
1006 f
->value
.function
.name
=
1007 gfc_get_string ("__nint_%d_%d", f
->ts
.kind
, a
->ts
.kind
);
1012 gfc_resolve_not (gfc_expr
* f
, gfc_expr
* i
)
1015 f
->value
.function
.name
= gfc_get_string ("__not_%d", i
->ts
.kind
);
1020 gfc_resolve_pack (gfc_expr
* f
,
1021 gfc_expr
* array ATTRIBUTE_UNUSED
,
1023 gfc_expr
* vector ATTRIBUTE_UNUSED
)
1028 if (mask
->rank
!= 0)
1029 f
->value
.function
.name
= PREFIX("pack");
1032 /* We convert mask to default logical only in the scalar case.
1033 In the array case we can simply read the array as if it were
1034 of type default logical. */
1035 if (mask
->ts
.kind
!= gfc_default_logical_kind
)
1039 ts
.type
= BT_LOGICAL
;
1040 ts
.kind
= gfc_default_logical_kind
;
1041 gfc_convert_type (mask
, &ts
, 2);
1044 f
->value
.function
.name
= PREFIX("pack_s");
1050 gfc_resolve_product (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1057 f
->rank
= array
->rank
- 1;
1058 gfc_resolve_index (dim
, 1);
1061 f
->value
.function
.name
=
1062 gfc_get_string (PREFIX("%s_%c%d"), mask
? "mproduct" : "product",
1063 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1068 gfc_resolve_real (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* kind
)
1070 f
->ts
.type
= BT_REAL
;
1073 f
->ts
.kind
= mpz_get_si (kind
->value
.integer
);
1075 f
->ts
.kind
= (a
->ts
.type
== BT_COMPLEX
) ?
1076 a
->ts
.kind
: gfc_default_real_kind
;
1078 f
->value
.function
.name
=
1079 gfc_get_string ("__real_%d_%c%d", f
->ts
.kind
,
1080 gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1085 gfc_resolve_rename (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
1086 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
1088 f
->ts
.type
= BT_INTEGER
;
1089 f
->ts
.kind
= gfc_default_integer_kind
;
1090 f
->value
.function
.name
= gfc_get_string (PREFIX("rename_i%d"), f
->ts
.kind
);
1095 gfc_resolve_repeat (gfc_expr
* f
, gfc_expr
* string
,
1096 gfc_expr
* ncopies ATTRIBUTE_UNUSED
)
1098 f
->ts
.type
= BT_CHARACTER
;
1099 f
->ts
.kind
= string
->ts
.kind
;
1100 f
->value
.function
.name
= gfc_get_string ("__repeat_%d", string
->ts
.kind
);
1105 gfc_resolve_reshape (gfc_expr
* f
, gfc_expr
* source
, gfc_expr
* shape
,
1106 gfc_expr
* pad ATTRIBUTE_UNUSED
,
1107 gfc_expr
* order ATTRIBUTE_UNUSED
)
1115 gfc_array_size (shape
, &rank
);
1116 f
->rank
= mpz_get_si (rank
);
1118 switch (source
->ts
.type
)
1121 kind
= source
->ts
.kind
* 2;
1127 kind
= source
->ts
.kind
;
1140 f
->value
.function
.name
=
1141 gfc_get_string (PREFIX("reshape_%d"), source
->ts
.kind
);
1145 f
->value
.function
.name
= PREFIX("reshape");
1149 /* TODO: Make this work with a constant ORDER parameter. */
1150 if (shape
->expr_type
== EXPR_ARRAY
1151 && gfc_is_constant_expr (shape
)
1155 f
->shape
= gfc_get_shape (f
->rank
);
1156 c
= shape
->value
.constructor
;
1157 for (i
= 0; i
< f
->rank
; i
++)
1159 mpz_init_set (f
->shape
[i
], c
->expr
->value
.integer
);
1164 /* Force-convert both SHAPE and ORDER to index_kind so that we don't need
1165 so many runtime variations. */
1166 if (shape
->ts
.kind
!= gfc_index_integer_kind
)
1168 gfc_typespec ts
= shape
->ts
;
1169 ts
.kind
= gfc_index_integer_kind
;
1170 gfc_convert_type_warn (shape
, &ts
, 2, 0);
1172 if (order
&& order
->ts
.kind
!= gfc_index_integer_kind
)
1173 gfc_convert_type_warn (order
, &shape
->ts
, 2, 0);
1178 gfc_resolve_rrspacing (gfc_expr
* f
, gfc_expr
* x
)
1181 f
->value
.function
.name
= gfc_get_string ("__rrspacing_%d", x
->ts
.kind
);
1186 gfc_resolve_scale (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* i
)
1190 /* The implementation calls scalbn which takes an int as the
1192 if (i
->ts
.kind
!= gfc_c_int_kind
)
1196 ts
.type
= BT_INTEGER
;
1197 ts
.kind
= gfc_default_integer_kind
;
1199 gfc_convert_type_warn (i
, &ts
, 2, 0);
1202 f
->value
.function
.name
= gfc_get_string ("__scale_%d", x
->ts
.kind
);
1207 gfc_resolve_scan (gfc_expr
* f
, gfc_expr
* string
,
1208 gfc_expr
* set ATTRIBUTE_UNUSED
,
1209 gfc_expr
* back ATTRIBUTE_UNUSED
)
1211 f
->ts
.type
= BT_INTEGER
;
1212 f
->ts
.kind
= gfc_default_integer_kind
;
1213 f
->value
.function
.name
= gfc_get_string ("__scan_%d", string
->ts
.kind
);
1218 gfc_resolve_set_exponent (gfc_expr
* f
, gfc_expr
* x
, gfc_expr
* i
)
1222 /* The library implementation uses GFC_INTEGER_4 unconditionally,
1223 convert type so we don't have to implement all possible
1225 if (i
->ts
.kind
!= 4)
1229 ts
.type
= BT_INTEGER
;
1230 ts
.kind
= gfc_default_integer_kind
;
1232 gfc_convert_type_warn (i
, &ts
, 2, 0);
1235 f
->value
.function
.name
= gfc_get_string ("__set_exponent_%d", x
->ts
.kind
);
1240 gfc_resolve_shape (gfc_expr
* f
, gfc_expr
* array
)
1242 f
->ts
.type
= BT_INTEGER
;
1243 f
->ts
.kind
= gfc_default_integer_kind
;
1245 f
->value
.function
.name
= gfc_get_string (PREFIX("shape_%d"), f
->ts
.kind
);
1246 f
->shape
= gfc_get_shape (1);
1247 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1252 gfc_resolve_sign (gfc_expr
* f
, gfc_expr
* a
, gfc_expr
* b ATTRIBUTE_UNUSED
)
1255 f
->value
.function
.name
=
1256 gfc_get_string ("__sign_%c%d", gfc_type_letter (a
->ts
.type
), a
->ts
.kind
);
1261 gfc_resolve_sin (gfc_expr
* f
, gfc_expr
* x
)
1264 f
->value
.function
.name
=
1265 gfc_get_string ("__sin_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1270 gfc_resolve_sinh (gfc_expr
* f
, gfc_expr
* x
)
1273 f
->value
.function
.name
=
1274 gfc_get_string ("__sinh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1279 gfc_resolve_spacing (gfc_expr
* f
, gfc_expr
* x
)
1282 f
->value
.function
.name
= gfc_get_string ("__spacing_%d", x
->ts
.kind
);
1287 gfc_resolve_spread (gfc_expr
* f
, gfc_expr
* source
,
1292 f
->rank
= source
->rank
+ 1;
1293 f
->value
.function
.name
= PREFIX("spread");
1295 gfc_resolve_index (dim
, 1);
1296 gfc_resolve_index (ncopies
, 1);
1301 gfc_resolve_sqrt (gfc_expr
* f
, gfc_expr
* x
)
1304 f
->value
.function
.name
=
1305 gfc_get_string ("__sqrt_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1309 /* Resolve the g77 compatibility function STAT AND FSTAT. */
1312 gfc_resolve_stat (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
,
1313 gfc_expr
* a ATTRIBUTE_UNUSED
)
1315 f
->ts
.type
= BT_INTEGER
;
1316 f
->ts
.kind
= gfc_default_integer_kind
;
1317 f
->value
.function
.name
= gfc_get_string (PREFIX("stat_i%d"), f
->ts
.kind
);
1322 gfc_resolve_fstat (gfc_expr
* f
, gfc_expr
* n
, gfc_expr
* a ATTRIBUTE_UNUSED
)
1324 f
->ts
.type
= BT_INTEGER
;
1325 f
->ts
.kind
= gfc_default_integer_kind
;
1326 if (n
->ts
.kind
!= f
->ts
.kind
)
1327 gfc_convert_type (n
, &f
->ts
, 2);
1329 f
->value
.function
.name
= gfc_get_string (PREFIX("fstat_i%d"), f
->ts
.kind
);
1334 gfc_resolve_sum (gfc_expr
* f
, gfc_expr
* array
, gfc_expr
* dim
,
1341 f
->rank
= array
->rank
- 1;
1342 gfc_resolve_index (dim
, 1);
1345 f
->value
.function
.name
=
1346 gfc_get_string (PREFIX("%s_%c%d"), mask
? "msum" : "sum",
1347 gfc_type_letter (array
->ts
.type
), array
->ts
.kind
);
1352 gfc_resolve_symlnk (gfc_expr
* f
, gfc_expr
* p1 ATTRIBUTE_UNUSED
,
1353 gfc_expr
* p2 ATTRIBUTE_UNUSED
)
1355 f
->ts
.type
= BT_INTEGER
;
1356 f
->ts
.kind
= gfc_default_integer_kind
;
1357 f
->value
.function
.name
= gfc_get_string (PREFIX("symlnk_i%d"), f
->ts
.kind
);
1361 /* Resolve the g77 compatibility function SYSTEM. */
1364 gfc_resolve_system (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
1366 f
->ts
.type
= BT_INTEGER
;
1368 f
->value
.function
.name
= gfc_get_string (PREFIX("system"));
1373 gfc_resolve_tan (gfc_expr
* f
, gfc_expr
* x
)
1376 f
->value
.function
.name
=
1377 gfc_get_string ("__tan_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1382 gfc_resolve_tanh (gfc_expr
* f
, gfc_expr
* x
)
1385 f
->value
.function
.name
=
1386 gfc_get_string ("__tanh_%c%d", gfc_type_letter (x
->ts
.type
), x
->ts
.kind
);
1391 gfc_resolve_time (gfc_expr
* f
)
1393 f
->ts
.type
= BT_INTEGER
;
1395 f
->value
.function
.name
= gfc_get_string (PREFIX("time_func"));
1400 gfc_resolve_time8 (gfc_expr
* f
)
1402 f
->ts
.type
= BT_INTEGER
;
1404 f
->value
.function
.name
= gfc_get_string (PREFIX("time8_func"));
1409 gfc_resolve_transfer (gfc_expr
* f
, gfc_expr
* source ATTRIBUTE_UNUSED
,
1410 gfc_expr
* mold
, gfc_expr
* size
)
1412 /* TODO: Make this do something meaningful. */
1413 static char transfer0
[] = "__transfer0", transfer1
[] = "__transfer1";
1417 if (size
== NULL
&& mold
->rank
== 0)
1420 f
->value
.function
.name
= transfer0
;
1425 f
->value
.function
.name
= transfer1
;
1431 gfc_resolve_transpose (gfc_expr
* f
, gfc_expr
* matrix
)
1439 f
->shape
= gfc_get_shape (2);
1440 mpz_init_set (f
->shape
[0], matrix
->shape
[1]);
1441 mpz_init_set (f
->shape
[1], matrix
->shape
[0]);
1444 kind
= matrix
->ts
.kind
;
1450 switch (matrix
->ts
.type
)
1453 f
->value
.function
.name
=
1454 gfc_get_string (PREFIX("transpose_c%d"), kind
);
1460 /* Use the integer routines for real and logical cases. This
1461 assumes they all have the same alignment requirements. */
1462 f
->value
.function
.name
=
1463 gfc_get_string (PREFIX("transpose_i%d"), kind
);
1467 f
->value
.function
.name
= PREFIX("transpose");
1473 f
->value
.function
.name
= PREFIX("transpose");
1479 gfc_resolve_trim (gfc_expr
* f
, gfc_expr
* string
)
1481 f
->ts
.type
= BT_CHARACTER
;
1482 f
->ts
.kind
= string
->ts
.kind
;
1483 f
->value
.function
.name
= gfc_get_string ("__trim_%d", string
->ts
.kind
);
1488 gfc_resolve_ubound (gfc_expr
* f
, gfc_expr
* array
,
1491 static char ubound
[] = "__ubound";
1493 f
->ts
.type
= BT_INTEGER
;
1494 f
->ts
.kind
= gfc_default_integer_kind
;
1499 f
->shape
= gfc_get_shape (1);
1500 mpz_init_set_ui (f
->shape
[0], array
->rank
);
1503 f
->value
.function
.name
= ubound
;
1507 /* Resolve the g77 compatibility function UMASK. */
1510 gfc_resolve_umask (gfc_expr
* f
, gfc_expr
* n
)
1512 f
->ts
.type
= BT_INTEGER
;
1513 f
->ts
.kind
= n
->ts
.kind
;
1514 f
->value
.function
.name
= gfc_get_string (PREFIX("umask_i%d"), n
->ts
.kind
);
1518 /* Resolve the g77 compatibility function UNLINK. */
1521 gfc_resolve_unlink (gfc_expr
* f
, gfc_expr
* n ATTRIBUTE_UNUSED
)
1523 f
->ts
.type
= BT_INTEGER
;
1525 f
->value
.function
.name
= gfc_get_string (PREFIX("unlink"));
1529 gfc_resolve_unpack (gfc_expr
* f
, gfc_expr
* vector
, gfc_expr
* mask
,
1530 gfc_expr
* field ATTRIBUTE_UNUSED
)
1532 f
->ts
.type
= vector
->ts
.type
;
1533 f
->ts
.kind
= vector
->ts
.kind
;
1534 f
->rank
= mask
->rank
;
1536 f
->value
.function
.name
=
1537 gfc_get_string (PREFIX("unpack%d"), field
->rank
> 0 ? 1 : 0);
1542 gfc_resolve_verify (gfc_expr
* f
, gfc_expr
* string
,
1543 gfc_expr
* set ATTRIBUTE_UNUSED
,
1544 gfc_expr
* back ATTRIBUTE_UNUSED
)
1546 f
->ts
.type
= BT_INTEGER
;
1547 f
->ts
.kind
= gfc_default_integer_kind
;
1548 f
->value
.function
.name
= gfc_get_string ("__verify_%d", string
->ts
.kind
);
1552 /* Intrinsic subroutine resolution. */
1555 gfc_resolve_cpu_time (gfc_code
* c ATTRIBUTE_UNUSED
)
1559 name
= gfc_get_string (PREFIX("cpu_time_%d"),
1560 c
->ext
.actual
->expr
->ts
.kind
);
1561 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1566 gfc_resolve_mvbits (gfc_code
* c
)
1571 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1572 name
= gfc_get_string (PREFIX("mvbits_i%d"), kind
);
1574 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1579 gfc_resolve_random_number (gfc_code
* c ATTRIBUTE_UNUSED
)
1584 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1585 if (c
->ext
.actual
->expr
->rank
== 0)
1586 name
= gfc_get_string (PREFIX("random_r%d"), kind
);
1588 name
= gfc_get_string (PREFIX("arandom_r%d"), kind
);
1590 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1595 gfc_resolve_rename_sub (gfc_code
* c
)
1600 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1601 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1603 kind
= gfc_default_integer_kind
;
1605 name
= gfc_get_string (PREFIX("rename_i%d_sub"), kind
);
1606 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1611 gfc_resolve_kill_sub (gfc_code
* c
)
1616 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1617 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1619 kind
= gfc_default_integer_kind
;
1621 name
= gfc_get_string (PREFIX("kill_i%d_sub"), kind
);
1622 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1627 gfc_resolve_link_sub (gfc_code
* c
)
1632 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1633 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1635 kind
= gfc_default_integer_kind
;
1637 name
= gfc_get_string (PREFIX("link_i%d_sub"), kind
);
1638 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1643 gfc_resolve_symlnk_sub (gfc_code
* c
)
1648 if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1649 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1651 kind
= gfc_default_integer_kind
;
1653 name
= gfc_get_string (PREFIX("symlnk_i%d_sub"), kind
);
1654 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1658 /* G77 compatibility subroutines etime() and dtime(). */
1661 gfc_resolve_etime_sub (gfc_code
* c
)
1665 name
= gfc_get_string (PREFIX("etime_sub"));
1666 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1670 /* G77 compatibility subroutine second(). */
1673 gfc_resolve_second_sub (gfc_code
* c
)
1677 name
= gfc_get_string (PREFIX("second_sub"));
1678 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1683 gfc_resolve_sleep_sub (gfc_code
* c
)
1688 if (c
->ext
.actual
->expr
!= NULL
)
1689 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1691 kind
= gfc_default_integer_kind
;
1693 name
= gfc_get_string (PREFIX("sleep_i%d_sub"), kind
);
1694 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1698 /* G77 compatibility function srand(). */
1701 gfc_resolve_srand (gfc_code
* c
)
1704 name
= gfc_get_string (PREFIX("srand"));
1705 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1709 /* Resolve the getarg intrinsic subroutine. */
1712 gfc_resolve_getarg (gfc_code
* c
)
1717 kind
= gfc_default_integer_kind
;
1718 name
= gfc_get_string (PREFIX("getarg_i%d"), kind
);
1719 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1722 /* Resolve the getcwd intrinsic subroutine. */
1725 gfc_resolve_getcwd_sub (gfc_code
* c
)
1730 if (c
->ext
.actual
->next
->expr
!= NULL
)
1731 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1733 kind
= gfc_default_integer_kind
;
1735 name
= gfc_get_string (PREFIX("getcwd_i%d_sub"), kind
);
1736 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1740 /* Resolve the get_command intrinsic subroutine. */
1743 gfc_resolve_get_command (gfc_code
* c
)
1748 kind
= gfc_default_integer_kind
;
1749 name
= gfc_get_string (PREFIX("get_command_i%d"), kind
);
1750 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1754 /* Resolve the get_command_argument intrinsic subroutine. */
1757 gfc_resolve_get_command_argument (gfc_code
* c
)
1762 kind
= gfc_default_integer_kind
;
1763 name
= gfc_get_string (PREFIX("get_command_argument_i%d"), kind
);
1764 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1767 /* Resolve the get_environment_variable intrinsic subroutine. */
1770 gfc_resolve_get_environment_variable (gfc_code
* code
)
1775 kind
= gfc_default_integer_kind
;
1776 name
= gfc_get_string (PREFIX("get_environment_variable_i%d"), kind
);
1777 code
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1780 /* Resolve the SYSTEM intrinsic subroutine. */
1783 gfc_resolve_system_sub (gfc_code
* c
)
1787 name
= gfc_get_string (PREFIX("system_sub"));
1788 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1791 /* Determine if the arguments to SYSTEM_CLOCK are INTEGER(4) or INTEGER(8) */
1794 gfc_resolve_system_clock (gfc_code
* c
)
1799 if (c
->ext
.actual
->expr
!= NULL
)
1800 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1801 else if (c
->ext
.actual
->next
->expr
!= NULL
)
1802 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1803 else if (c
->ext
.actual
->next
->next
->expr
!= NULL
)
1804 kind
= c
->ext
.actual
->next
->next
->expr
->ts
.kind
;
1806 kind
= gfc_default_integer_kind
;
1808 name
= gfc_get_string (PREFIX("system_clock_%d"), kind
);
1809 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1812 /* Resolve the EXIT intrinsic subroutine. */
1815 gfc_resolve_exit (gfc_code
* c
)
1820 if (c
->ext
.actual
->expr
!= NULL
)
1821 kind
= c
->ext
.actual
->expr
->ts
.kind
;
1823 kind
= gfc_default_integer_kind
;
1825 name
= gfc_get_string (PREFIX("exit_i%d"), kind
);
1826 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1829 /* Resolve the FLUSH intrinsic subroutine. */
1832 gfc_resolve_flush (gfc_code
* c
)
1838 ts
.type
= BT_INTEGER
;
1839 ts
.kind
= gfc_default_integer_kind
;
1840 n
= c
->ext
.actual
->expr
;
1842 && n
->ts
.kind
!= ts
.kind
)
1843 gfc_convert_type (n
, &ts
, 2);
1845 name
= gfc_get_string (PREFIX("flush_i%d"), ts
.kind
);
1846 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1851 gfc_resolve_gerror (gfc_code
* c
)
1853 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("gerror"));
1858 gfc_resolve_getlog (gfc_code
* c
)
1860 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("getlog"));
1865 gfc_resolve_hostnm_sub (gfc_code
* c
)
1870 if (c
->ext
.actual
->next
->expr
!= NULL
)
1871 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1873 kind
= gfc_default_integer_kind
;
1875 name
= gfc_get_string (PREFIX("hostnm_i%d_sub"), kind
);
1876 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1881 gfc_resolve_perror (gfc_code
* c
)
1883 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (PREFIX ("perror_sub"));
1886 /* Resolve the STAT and FSTAT intrinsic subroutines. */
1889 gfc_resolve_stat_sub (gfc_code
* c
)
1893 name
= gfc_get_string (PREFIX("stat_i%d_sub"), gfc_default_integer_kind
);
1894 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1899 gfc_resolve_fstat_sub (gfc_code
* c
)
1905 u
= c
->ext
.actual
->expr
;
1906 ts
= &c
->ext
.actual
->next
->expr
->ts
;
1907 if (u
->ts
.kind
!= ts
->kind
)
1908 gfc_convert_type (u
, ts
, 2);
1909 name
= gfc_get_string (PREFIX("fstat_i%d_sub"), ts
->kind
);
1910 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1913 /* Resolve the UMASK intrinsic subroutine. */
1916 gfc_resolve_umask_sub (gfc_code
* c
)
1921 if (c
->ext
.actual
->next
->expr
!= NULL
)
1922 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1924 kind
= gfc_default_integer_kind
;
1926 name
= gfc_get_string (PREFIX("umask_i%d_sub"), kind
);
1927 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);
1930 /* Resolve the UNLINK intrinsic subroutine. */
1933 gfc_resolve_unlink_sub (gfc_code
* c
)
1938 if (c
->ext
.actual
->next
->expr
!= NULL
)
1939 kind
= c
->ext
.actual
->next
->expr
->ts
.kind
;
1941 kind
= gfc_default_integer_kind
;
1943 name
= gfc_get_string (PREFIX("unlink_i%d_sub"), kind
);
1944 c
->resolved_sym
= gfc_get_intrinsic_sub_symbol (name
);