2 Copyright (C) 2003-2019 Free Software Foundation, Inc.
3 Contributed by Steven Bosscher
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* Actually this is just a collection of routines that used to be
23 scattered around the sources. Now that they are all in a single
24 file, almost all of them can be static, and the other files don't
25 have this mess in them.
27 As a nice side-effect, this file can act as documentation of the
28 gfc_code and gfc_expr structures and all their friends and
35 #include "coretypes.h"
37 #include "constructor.h"
39 /* Keep track of indentation for symbol tree dumps. */
40 static int show_level
= 0;
42 /* The file handle we're dumping to is kept in a static variable. This
43 is not too cool, but it avoids a lot of passing it around. */
44 static FILE *dumpfile
;
46 /* Forward declaration of some of the functions. */
47 static void show_expr (gfc_expr
*p
);
48 static void show_code_node (int, gfc_code
*);
49 static void show_namespace (gfc_namespace
*ns
);
50 static void show_code (int, gfc_code
*);
51 static void show_symbol (gfc_symbol
*);
52 static void show_typespec (gfc_typespec
*);
54 /* Allow dumping of an expression in the debugger. */
55 void gfc_debug_expr (gfc_expr
*);
57 void debug (gfc_expr
*e
)
62 fputc (' ', dumpfile
);
63 show_typespec (&e
->ts
);
64 fputc ('\n', dumpfile
);
68 void debug (gfc_typespec
*ts
)
73 fputc ('\n', dumpfile
);
77 void debug (gfc_typespec ts
)
83 gfc_debug_expr (gfc_expr
*e
)
88 fputc ('\n', dumpfile
);
92 /* Allow for dumping of a piece of code in the debugger. */
93 void gfc_debug_code (gfc_code
*c
);
96 gfc_debug_code (gfc_code
*c
)
101 fputc ('\n', dumpfile
);
105 void debug (gfc_symbol
*sym
)
107 FILE *tmp
= dumpfile
;
110 fputc ('\n', dumpfile
);
114 /* Do indentation for a specific level. */
117 code_indent (int level
, gfc_st_label
*label
)
122 fprintf (dumpfile
, "%-5d ", label
->value
);
124 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
125 fputc (' ', dumpfile
);
129 /* Simple indentation at the current level. This one
130 is used to show symbols. */
135 fputc ('\n', dumpfile
);
136 code_indent (show_level
, NULL
);
140 /* Show type-specific information. */
143 show_typespec (gfc_typespec
*ts
)
145 if (ts
->type
== BT_ASSUMED
)
147 fputs ("(TYPE(*))", dumpfile
);
151 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
158 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
163 show_expr (ts
->u
.cl
->length
);
164 fprintf(dumpfile
, " %d", ts
->kind
);
168 fprintf (dumpfile
, "%d", ts
->kind
);
171 if (ts
->is_c_interop
)
172 fputs (" C_INTEROP", dumpfile
);
175 fputs (" ISO_C", dumpfile
);
178 fputs (" DEFERRED", dumpfile
);
180 fputc (')', dumpfile
);
184 /* Show an actual argument list. */
187 show_actual_arglist (gfc_actual_arglist
*a
)
189 fputc ('(', dumpfile
);
191 for (; a
; a
= a
->next
)
193 fputc ('(', dumpfile
);
195 fprintf (dumpfile
, "%s = ", a
->name
);
199 fputs ("(arg not-present)", dumpfile
);
201 fputc (')', dumpfile
);
203 fputc (' ', dumpfile
);
206 fputc (')', dumpfile
);
210 /* Show a gfc_array_spec array specification structure. */
213 show_array_spec (gfc_array_spec
*as
)
220 fputs ("()", dumpfile
);
224 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
226 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
230 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
231 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
232 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
233 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
234 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
236 gfc_internal_error ("show_array_spec(): Unhandled array shape "
239 fprintf (dumpfile
, " %s ", c
);
241 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
243 show_expr (as
->lower
[i
]);
244 fputc (' ', dumpfile
);
245 show_expr (as
->upper
[i
]);
246 fputc (' ', dumpfile
);
250 fputc (')', dumpfile
);
254 /* Show a gfc_array_ref array reference structure. */
257 show_array_ref (gfc_array_ref
* ar
)
261 fputc ('(', dumpfile
);
266 fputs ("FULL", dumpfile
);
270 for (i
= 0; i
< ar
->dimen
; i
++)
272 /* There are two types of array sections: either the
273 elements are identified by an integer array ('vector'),
274 or by an index range. In the former case we only have to
275 print the start expression which contains the vector, in
276 the latter case we have to print any of lower and upper
277 bound and the stride, if they're present. */
279 if (ar
->start
[i
] != NULL
)
280 show_expr (ar
->start
[i
]);
282 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
284 fputc (':', dumpfile
);
286 if (ar
->end
[i
] != NULL
)
287 show_expr (ar
->end
[i
]);
289 if (ar
->stride
[i
] != NULL
)
291 fputc (':', dumpfile
);
292 show_expr (ar
->stride
[i
]);
296 if (i
!= ar
->dimen
- 1)
297 fputs (" , ", dumpfile
);
302 for (i
= 0; i
< ar
->dimen
; i
++)
304 show_expr (ar
->start
[i
]);
305 if (i
!= ar
->dimen
- 1)
306 fputs (" , ", dumpfile
);
311 fputs ("UNKNOWN", dumpfile
);
315 gfc_internal_error ("show_array_ref(): Unknown array reference");
318 fputc (')', dumpfile
);
322 /* Show a list of gfc_ref structures. */
325 show_ref (gfc_ref
*p
)
327 for (; p
; p
= p
->next
)
331 show_array_ref (&p
->u
.ar
);
335 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
339 fputc ('(', dumpfile
);
340 show_expr (p
->u
.ss
.start
);
341 fputc (':', dumpfile
);
342 show_expr (p
->u
.ss
.end
);
343 fputc (')', dumpfile
);
350 fprintf (dumpfile
, " INQUIRY_KIND ");
353 fprintf (dumpfile
, " INQUIRY_LEN ");
356 fprintf (dumpfile
, " INQUIRY_RE ");
359 fprintf (dumpfile
, " INQUIRY_IM ");
364 gfc_internal_error ("show_ref(): Bad component code");
369 /* Display a constructor. Works recursively for array constructors. */
372 show_constructor (gfc_constructor_base base
)
375 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
377 if (c
->iterator
== NULL
)
381 fputc ('(', dumpfile
);
384 fputc (' ', dumpfile
);
385 show_expr (c
->iterator
->var
);
386 fputc ('=', dumpfile
);
387 show_expr (c
->iterator
->start
);
388 fputc (',', dumpfile
);
389 show_expr (c
->iterator
->end
);
390 fputc (',', dumpfile
);
391 show_expr (c
->iterator
->step
);
393 fputc (')', dumpfile
);
396 if (gfc_constructor_next (c
) != NULL
)
397 fputs (" , ", dumpfile
);
403 show_char_const (const gfc_char_t
*c
, gfc_charlen_t length
)
405 fputc ('\'', dumpfile
);
406 for (size_t i
= 0; i
< (size_t) length
; i
++)
409 fputs ("''", dumpfile
);
411 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
413 fputc ('\'', dumpfile
);
417 /* Show a component-call expression. */
420 show_compcall (gfc_expr
* p
)
422 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
424 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
426 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
428 show_actual_arglist (p
->value
.compcall
.actual
);
432 /* Show an expression. */
435 show_expr (gfc_expr
*p
)
442 fputs ("()", dumpfile
);
446 switch (p
->expr_type
)
449 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
454 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
455 show_constructor (p
->value
.constructor
);
456 fputc (')', dumpfile
);
460 fputs ("(/ ", dumpfile
);
461 show_constructor (p
->value
.constructor
);
462 fputs (" /)", dumpfile
);
468 fputs ("NULL()", dumpfile
);
475 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
477 if (p
->ts
.kind
!= gfc_default_integer_kind
)
478 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
482 if (p
->value
.logical
)
483 fputs (".true.", dumpfile
);
485 fputs (".false.", dumpfile
);
489 mpfr_out_str (dumpfile
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
490 if (p
->ts
.kind
!= gfc_default_real_kind
)
491 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
495 show_char_const (p
->value
.character
.string
,
496 p
->value
.character
.length
);
500 fputs ("(complex ", dumpfile
);
502 mpfr_out_str (dumpfile
, 10, 0, mpc_realref (p
->value
.complex),
504 if (p
->ts
.kind
!= gfc_default_complex_kind
)
505 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
507 fputc (' ', dumpfile
);
509 mpfr_out_str (dumpfile
, 10, 0, mpc_imagref (p
->value
.complex),
511 if (p
->ts
.kind
!= gfc_default_complex_kind
)
512 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
514 fputc (')', dumpfile
);
518 fprintf (dumpfile
, HOST_WIDE_INT_PRINT_DEC
"H",
519 p
->representation
.length
);
520 c
= p
->representation
.string
;
521 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
523 fputc (*c
, dumpfile
);
528 fputs ("???", dumpfile
);
532 if (p
->representation
.string
)
534 fputs (" {", dumpfile
);
535 c
= p
->representation
.string
;
536 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
538 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
539 if (i
< p
->representation
.length
- 1)
540 fputc (',', dumpfile
);
542 fputc ('}', dumpfile
);
548 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
549 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
550 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
555 fputc ('(', dumpfile
);
556 switch (p
->value
.op
.op
)
558 case INTRINSIC_UPLUS
:
559 fputs ("U+ ", dumpfile
);
561 case INTRINSIC_UMINUS
:
562 fputs ("U- ", dumpfile
);
565 fputs ("+ ", dumpfile
);
567 case INTRINSIC_MINUS
:
568 fputs ("- ", dumpfile
);
570 case INTRINSIC_TIMES
:
571 fputs ("* ", dumpfile
);
573 case INTRINSIC_DIVIDE
:
574 fputs ("/ ", dumpfile
);
576 case INTRINSIC_POWER
:
577 fputs ("** ", dumpfile
);
579 case INTRINSIC_CONCAT
:
580 fputs ("// ", dumpfile
);
583 fputs ("AND ", dumpfile
);
586 fputs ("OR ", dumpfile
);
589 fputs ("EQV ", dumpfile
);
592 fputs ("NEQV ", dumpfile
);
595 case INTRINSIC_EQ_OS
:
596 fputs ("= ", dumpfile
);
599 case INTRINSIC_NE_OS
:
600 fputs ("/= ", dumpfile
);
603 case INTRINSIC_GT_OS
:
604 fputs ("> ", dumpfile
);
607 case INTRINSIC_GE_OS
:
608 fputs (">= ", dumpfile
);
611 case INTRINSIC_LT_OS
:
612 fputs ("< ", dumpfile
);
615 case INTRINSIC_LE_OS
:
616 fputs ("<= ", dumpfile
);
619 fputs ("NOT ", dumpfile
);
621 case INTRINSIC_PARENTHESES
:
622 fputs ("parens ", dumpfile
);
627 ("show_expr(): Bad intrinsic in expression");
630 show_expr (p
->value
.op
.op1
);
634 fputc (' ', dumpfile
);
635 show_expr (p
->value
.op
.op2
);
638 fputc (')', dumpfile
);
642 if (p
->value
.function
.name
== NULL
)
644 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
645 if (gfc_is_proc_ptr_comp (p
))
647 fputc ('[', dumpfile
);
648 show_actual_arglist (p
->value
.function
.actual
);
649 fputc (']', dumpfile
);
653 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
654 if (gfc_is_proc_ptr_comp (p
))
656 fputc ('[', dumpfile
);
657 fputc ('[', dumpfile
);
658 show_actual_arglist (p
->value
.function
.actual
);
659 fputc (']', dumpfile
);
660 fputc (']', dumpfile
);
670 gfc_internal_error ("show_expr(): Don't know how to show expr");
674 /* Show symbol attributes. The flavor and intent are followed by
675 whatever single bit attributes are present. */
678 show_attr (symbol_attribute
*attr
, const char * module
)
680 if (attr
->flavor
!= FL_UNKNOWN
)
682 if (attr
->flavor
== FL_DERIVED
&& attr
->pdt_template
)
683 fputs (" (PDT template", dumpfile
);
685 fprintf (dumpfile
, "(%s ", gfc_code2string (flavors
, attr
->flavor
));
687 if (attr
->access
!= ACCESS_UNKNOWN
)
688 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
689 if (attr
->proc
!= PROC_UNKNOWN
)
690 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
691 if (attr
->save
!= SAVE_NONE
)
692 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
694 if (attr
->artificial
)
695 fputs (" ARTIFICIAL", dumpfile
);
696 if (attr
->allocatable
)
697 fputs (" ALLOCATABLE", dumpfile
);
698 if (attr
->asynchronous
)
699 fputs (" ASYNCHRONOUS", dumpfile
);
700 if (attr
->codimension
)
701 fputs (" CODIMENSION", dumpfile
);
703 fputs (" DIMENSION", dumpfile
);
704 if (attr
->contiguous
)
705 fputs (" CONTIGUOUS", dumpfile
);
707 fputs (" EXTERNAL", dumpfile
);
709 fputs (" INTRINSIC", dumpfile
);
711 fputs (" OPTIONAL", dumpfile
);
713 fputs (" KIND", dumpfile
);
715 fputs (" LEN", dumpfile
);
717 fputs (" POINTER", dumpfile
);
718 if (attr
->is_protected
)
719 fputs (" PROTECTED", dumpfile
);
721 fputs (" VALUE", dumpfile
);
723 fputs (" VOLATILE", dumpfile
);
724 if (attr
->threadprivate
)
725 fputs (" THREADPRIVATE", dumpfile
);
727 fputs (" TARGET", dumpfile
);
730 fputs (" DUMMY", dumpfile
);
731 if (attr
->intent
!= INTENT_UNKNOWN
)
732 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
736 fputs (" RESULT", dumpfile
);
738 fputs (" ENTRY", dumpfile
);
740 fputs (" BIND(C)", dumpfile
);
743 fputs (" DATA", dumpfile
);
746 fputs (" USE-ASSOC", dumpfile
);
748 fprintf (dumpfile
, "(%s)", module
);
751 if (attr
->in_namelist
)
752 fputs (" IN-NAMELIST", dumpfile
);
754 fputs (" IN-COMMON", dumpfile
);
757 fputs (" ABSTRACT", dumpfile
);
759 fputs (" FUNCTION", dumpfile
);
760 if (attr
->subroutine
)
761 fputs (" SUBROUTINE", dumpfile
);
762 if (attr
->implicit_type
)
763 fputs (" IMPLICIT-TYPE", dumpfile
);
766 fputs (" SEQUENCE", dumpfile
);
768 fputs (" ELEMENTAL", dumpfile
);
770 fputs (" PURE", dumpfile
);
771 if (attr
->implicit_pure
)
772 fputs (" IMPLICIT_PURE", dumpfile
);
774 fputs (" RECURSIVE", dumpfile
);
776 fputc (')', dumpfile
);
780 /* Show components of a derived type. */
783 show_components (gfc_symbol
*sym
)
787 for (c
= sym
->components
; c
; c
= c
->next
)
790 fprintf (dumpfile
, "(%s ", c
->name
);
791 show_typespec (&c
->ts
);
794 fputs (" kind_expr: ", dumpfile
);
795 show_expr (c
->kind_expr
);
799 fputs ("PDT parameters", dumpfile
);
800 show_actual_arglist (c
->param_list
);
803 if (c
->attr
.allocatable
)
804 fputs (" ALLOCATABLE", dumpfile
);
805 if (c
->attr
.pdt_kind
)
806 fputs (" KIND", dumpfile
);
808 fputs (" LEN", dumpfile
);
810 fputs (" POINTER", dumpfile
);
811 if (c
->attr
.proc_pointer
)
812 fputs (" PPC", dumpfile
);
813 if (c
->attr
.dimension
)
814 fputs (" DIMENSION", dumpfile
);
815 fputc (' ', dumpfile
);
816 show_array_spec (c
->as
);
818 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
819 fputc (')', dumpfile
);
821 fputc (' ', dumpfile
);
826 /* Show the f2k_derived namespace with procedure bindings. */
829 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
834 fputs ("GENERIC", dumpfile
);
837 fputs ("PROCEDURE, ", dumpfile
);
839 fputs ("NOPASS", dumpfile
);
843 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
845 fputs ("PASS", dumpfile
);
847 if (tb
->non_overridable
)
848 fputs (", NON_OVERRIDABLE", dumpfile
);
851 if (tb
->access
== ACCESS_PUBLIC
)
852 fputs (", PUBLIC", dumpfile
);
854 fputs (", PRIVATE", dumpfile
);
856 fprintf (dumpfile
, " :: %s => ", name
);
861 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
863 fputs (g
->specific_st
->name
, dumpfile
);
865 fputs (", ", dumpfile
);
869 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
873 show_typebound_symtree (gfc_symtree
* st
)
875 gcc_assert (st
->n
.tb
);
876 show_typebound_proc (st
->n
.tb
, st
->name
);
880 show_f2k_derived (gfc_namespace
* f2k
)
886 fputs ("Procedure bindings:", dumpfile
);
889 /* Finalizer bindings. */
890 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
893 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
896 /* Type-bound procedures. */
897 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
902 fputs ("Operator bindings:", dumpfile
);
905 /* User-defined operators. */
906 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
908 /* Intrinsic operators. */
909 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
911 show_typebound_proc (f2k
->tb_op
[op
],
912 gfc_op2string ((gfc_intrinsic_op
) op
));
918 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
919 show the interface. Information needed to reconstruct the list of
920 specific interfaces associated with a generic symbol is done within
924 show_symbol (gfc_symbol
*sym
)
926 gfc_formal_arglist
*formal
;
933 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
934 len
= strlen (sym
->name
);
935 for (i
=len
; i
<12; i
++)
936 fputc(' ', dumpfile
);
938 if (sym
->binding_label
)
939 fprintf (dumpfile
,"|| binding_label: '%s' ", sym
->binding_label
);
944 fputs ("type spec : ", dumpfile
);
945 show_typespec (&sym
->ts
);
948 fputs ("attributes: ", dumpfile
);
949 show_attr (&sym
->attr
, sym
->module
);
954 fputs ("value: ", dumpfile
);
955 show_expr (sym
->value
);
961 fputs ("Array spec:", dumpfile
);
962 show_array_spec (sym
->as
);
968 fputs ("Generic interfaces:", dumpfile
);
969 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
970 fprintf (dumpfile
, " %s", intr
->sym
->name
);
976 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
982 fputs ("components: ", dumpfile
);
983 show_components (sym
);
986 if (sym
->f2k_derived
)
990 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
991 show_f2k_derived (sym
->f2k_derived
);
997 fputs ("Formal arglist:", dumpfile
);
999 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
1001 if (formal
->sym
!= NULL
)
1002 fprintf (dumpfile
, " %s", formal
->sym
->name
);
1004 fputs (" [Alt Return]", dumpfile
);
1008 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
1009 && sym
->attr
.proc
!= PROC_ST_FUNCTION
1010 && !sym
->attr
.entry
)
1013 fputs ("Formal namespace", dumpfile
);
1014 show_namespace (sym
->formal_ns
);
1017 if (sym
->attr
.flavor
== FL_VARIABLE
1021 fputs ("PDT parameters", dumpfile
);
1022 show_actual_arglist (sym
->param_list
);
1025 if (sym
->attr
.flavor
== FL_NAMELIST
)
1029 fputs ("variables : ", dumpfile
);
1030 for (nl
= sym
->namelist
; nl
; nl
= nl
->next
)
1031 fprintf (dumpfile
, " %s",nl
->sym
->name
);
1038 /* Show a user-defined operator. Just prints an operator
1039 and the name of the associated subroutine, really. */
1042 show_uop (gfc_user_op
*uop
)
1044 gfc_interface
*intr
;
1047 fprintf (dumpfile
, "%s:", uop
->name
);
1049 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
1050 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1054 /* Workhorse function for traversing the user operator symtree. */
1057 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
1062 (*func
) (st
->n
.uop
);
1064 traverse_uop (st
->left
, func
);
1065 traverse_uop (st
->right
, func
);
1069 /* Traverse the tree of user operator nodes. */
1072 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
1074 traverse_uop (ns
->uop_root
, func
);
1078 /* Function to display a common block. */
1081 show_common (gfc_symtree
*st
)
1086 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
1088 s
= st
->n
.common
->head
;
1091 fprintf (dumpfile
, "%s", s
->name
);
1094 fputs (", ", dumpfile
);
1096 fputc ('\n', dumpfile
);
1100 /* Worker function to display the symbol tree. */
1103 show_symtree (gfc_symtree
*st
)
1109 len
= strlen(st
->name
);
1110 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
1112 for (i
=len
; i
<12; i
++)
1113 fputc(' ', dumpfile
);
1116 fputs( " Ambiguous", dumpfile
);
1118 if (st
->n
.sym
->ns
!= gfc_current_ns
)
1119 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1120 st
->n
.sym
->ns
->proc_name
->name
);
1122 show_symbol (st
->n
.sym
);
1126 /******************* Show gfc_code structures **************/
1129 /* Show a list of code structures. Mutually recursive with
1130 show_code_node(). */
1133 show_code (int level
, gfc_code
*c
)
1135 for (; c
; c
= c
->next
)
1136 show_code_node (level
, c
);
1140 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1142 for (; n
; n
= n
->next
)
1144 if (list_type
== OMP_LIST_REDUCTION
)
1145 switch (n
->u
.reduction_op
)
1147 case OMP_REDUCTION_PLUS
:
1148 case OMP_REDUCTION_TIMES
:
1149 case OMP_REDUCTION_MINUS
:
1150 case OMP_REDUCTION_AND
:
1151 case OMP_REDUCTION_OR
:
1152 case OMP_REDUCTION_EQV
:
1153 case OMP_REDUCTION_NEQV
:
1154 fprintf (dumpfile
, "%s:",
1155 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1157 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1158 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1159 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1160 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1161 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1162 case OMP_REDUCTION_USER
:
1164 fprintf (dumpfile
, "%s:", n
->udr
->udr
->name
);
1168 else if (list_type
== OMP_LIST_DEPEND
)
1169 switch (n
->u
.depend_op
)
1171 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1172 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1173 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1174 case OMP_DEPEND_SINK_FIRST
:
1175 fputs ("sink:", dumpfile
);
1178 fprintf (dumpfile
, "%s", n
->sym
->name
);
1181 fputc ('+', dumpfile
);
1182 show_expr (n
->expr
);
1184 if (n
->next
== NULL
)
1186 else if (n
->next
->u
.depend_op
!= OMP_DEPEND_SINK
)
1188 fputs (") DEPEND(", dumpfile
);
1191 fputc (',', dumpfile
);
1197 else if (list_type
== OMP_LIST_MAP
)
1198 switch (n
->u
.map_op
)
1200 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1201 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1202 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1203 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1206 else if (list_type
== OMP_LIST_LINEAR
)
1207 switch (n
->u
.linear_op
)
1209 case OMP_LINEAR_REF
: fputs ("ref(", dumpfile
); break;
1210 case OMP_LINEAR_VAL
: fputs ("val(", dumpfile
); break;
1211 case OMP_LINEAR_UVAL
: fputs ("uval(", dumpfile
); break;
1214 fprintf (dumpfile
, "%s", n
->sym
->name
);
1215 if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear_op
!= OMP_LINEAR_DEFAULT
)
1216 fputc (')', dumpfile
);
1219 fputc (':', dumpfile
);
1220 show_expr (n
->expr
);
1223 fputc (',', dumpfile
);
1228 /* Show OpenMP or OpenACC clauses. */
1231 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1235 switch (omp_clauses
->cancel
)
1237 case OMP_CANCEL_UNKNOWN
:
1239 case OMP_CANCEL_PARALLEL
:
1240 fputs (" PARALLEL", dumpfile
);
1242 case OMP_CANCEL_SECTIONS
:
1243 fputs (" SECTIONS", dumpfile
);
1246 fputs (" DO", dumpfile
);
1248 case OMP_CANCEL_TASKGROUP
:
1249 fputs (" TASKGROUP", dumpfile
);
1252 if (omp_clauses
->if_expr
)
1254 fputs (" IF(", dumpfile
);
1255 show_expr (omp_clauses
->if_expr
);
1256 fputc (')', dumpfile
);
1258 if (omp_clauses
->final_expr
)
1260 fputs (" FINAL(", dumpfile
);
1261 show_expr (omp_clauses
->final_expr
);
1262 fputc (')', dumpfile
);
1264 if (omp_clauses
->num_threads
)
1266 fputs (" NUM_THREADS(", dumpfile
);
1267 show_expr (omp_clauses
->num_threads
);
1268 fputc (')', dumpfile
);
1270 if (omp_clauses
->async
)
1272 fputs (" ASYNC", dumpfile
);
1273 if (omp_clauses
->async_expr
)
1275 fputc ('(', dumpfile
);
1276 show_expr (omp_clauses
->async_expr
);
1277 fputc (')', dumpfile
);
1280 if (omp_clauses
->num_gangs_expr
)
1282 fputs (" NUM_GANGS(", dumpfile
);
1283 show_expr (omp_clauses
->num_gangs_expr
);
1284 fputc (')', dumpfile
);
1286 if (omp_clauses
->num_workers_expr
)
1288 fputs (" NUM_WORKERS(", dumpfile
);
1289 show_expr (omp_clauses
->num_workers_expr
);
1290 fputc (')', dumpfile
);
1292 if (omp_clauses
->vector_length_expr
)
1294 fputs (" VECTOR_LENGTH(", dumpfile
);
1295 show_expr (omp_clauses
->vector_length_expr
);
1296 fputc (')', dumpfile
);
1298 if (omp_clauses
->gang
)
1300 fputs (" GANG", dumpfile
);
1301 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1303 fputc ('(', dumpfile
);
1304 if (omp_clauses
->gang_num_expr
)
1306 fprintf (dumpfile
, "num:");
1307 show_expr (omp_clauses
->gang_num_expr
);
1309 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1310 fputc (',', dumpfile
);
1311 if (omp_clauses
->gang_static
)
1313 fprintf (dumpfile
, "static:");
1314 if (omp_clauses
->gang_static_expr
)
1315 show_expr (omp_clauses
->gang_static_expr
);
1317 fputc ('*', dumpfile
);
1319 fputc (')', dumpfile
);
1322 if (omp_clauses
->worker
)
1324 fputs (" WORKER", dumpfile
);
1325 if (omp_clauses
->worker_expr
)
1327 fputc ('(', dumpfile
);
1328 show_expr (omp_clauses
->worker_expr
);
1329 fputc (')', dumpfile
);
1332 if (omp_clauses
->vector
)
1334 fputs (" VECTOR", dumpfile
);
1335 if (omp_clauses
->vector_expr
)
1337 fputc ('(', dumpfile
);
1338 show_expr (omp_clauses
->vector_expr
);
1339 fputc (')', dumpfile
);
1342 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1345 switch (omp_clauses
->sched_kind
)
1347 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1348 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1349 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1350 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1351 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1355 fputs (" SCHEDULE (", dumpfile
);
1356 if (omp_clauses
->sched_simd
)
1358 if (omp_clauses
->sched_monotonic
1359 || omp_clauses
->sched_nonmonotonic
)
1360 fputs ("SIMD, ", dumpfile
);
1362 fputs ("SIMD: ", dumpfile
);
1364 if (omp_clauses
->sched_monotonic
)
1365 fputs ("MONOTONIC: ", dumpfile
);
1366 else if (omp_clauses
->sched_nonmonotonic
)
1367 fputs ("NONMONOTONIC: ", dumpfile
);
1368 fputs (type
, dumpfile
);
1369 if (omp_clauses
->chunk_size
)
1371 fputc (',', dumpfile
);
1372 show_expr (omp_clauses
->chunk_size
);
1374 fputc (')', dumpfile
);
1376 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1379 switch (omp_clauses
->default_sharing
)
1381 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1382 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1383 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1384 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1385 case OMP_DEFAULT_PRESENT
: type
= "PRESENT"; break;
1389 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1391 if (omp_clauses
->tile_list
)
1393 gfc_expr_list
*list
;
1394 fputs (" TILE(", dumpfile
);
1395 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1397 show_expr (list
->expr
);
1399 fputs (", ", dumpfile
);
1401 fputc (')', dumpfile
);
1403 if (omp_clauses
->wait_list
)
1405 gfc_expr_list
*list
;
1406 fputs (" WAIT(", dumpfile
);
1407 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1409 show_expr (list
->expr
);
1411 fputs (", ", dumpfile
);
1413 fputc (')', dumpfile
);
1415 if (omp_clauses
->seq
)
1416 fputs (" SEQ", dumpfile
);
1417 if (omp_clauses
->independent
)
1418 fputs (" INDEPENDENT", dumpfile
);
1419 if (omp_clauses
->ordered
)
1421 if (omp_clauses
->orderedc
)
1422 fprintf (dumpfile
, " ORDERED(%d)", omp_clauses
->orderedc
);
1424 fputs (" ORDERED", dumpfile
);
1426 if (omp_clauses
->untied
)
1427 fputs (" UNTIED", dumpfile
);
1428 if (omp_clauses
->mergeable
)
1429 fputs (" MERGEABLE", dumpfile
);
1430 if (omp_clauses
->collapse
)
1431 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1432 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1433 if (omp_clauses
->lists
[list_type
] != NULL
1434 && list_type
!= OMP_LIST_COPYPRIVATE
)
1436 const char *type
= NULL
;
1439 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1440 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1441 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1442 case OMP_LIST_COPYPRIVATE
: type
= "COPYPRIVATE"; break;
1443 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1444 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1445 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1446 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1447 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1448 case OMP_LIST_DEPEND
: type
= "DEPEND"; break;
1449 case OMP_LIST_MAP
: type
= "MAP"; break;
1450 case OMP_LIST_TO
: type
= "TO"; break;
1451 case OMP_LIST_FROM
: type
= "FROM"; break;
1452 case OMP_LIST_REDUCTION
: type
= "REDUCTION"; break;
1453 case OMP_LIST_DEVICE_RESIDENT
: type
= "DEVICE_RESIDENT"; break;
1454 case OMP_LIST_LINK
: type
= "LINK"; break;
1455 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1456 case OMP_LIST_CACHE
: type
= "CACHE"; break;
1457 case OMP_LIST_IS_DEVICE_PTR
: type
= "IS_DEVICE_PTR"; break;
1458 case OMP_LIST_USE_DEVICE_PTR
: type
= "USE_DEVICE_PTR"; break;
1462 fprintf (dumpfile
, " %s(", type
);
1463 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1464 fputc (')', dumpfile
);
1466 if (omp_clauses
->safelen_expr
)
1468 fputs (" SAFELEN(", dumpfile
);
1469 show_expr (omp_clauses
->safelen_expr
);
1470 fputc (')', dumpfile
);
1472 if (omp_clauses
->simdlen_expr
)
1474 fputs (" SIMDLEN(", dumpfile
);
1475 show_expr (omp_clauses
->simdlen_expr
);
1476 fputc (')', dumpfile
);
1478 if (omp_clauses
->inbranch
)
1479 fputs (" INBRANCH", dumpfile
);
1480 if (omp_clauses
->notinbranch
)
1481 fputs (" NOTINBRANCH", dumpfile
);
1482 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1485 switch (omp_clauses
->proc_bind
)
1487 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1488 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1489 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1493 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1495 if (omp_clauses
->num_teams
)
1497 fputs (" NUM_TEAMS(", dumpfile
);
1498 show_expr (omp_clauses
->num_teams
);
1499 fputc (')', dumpfile
);
1501 if (omp_clauses
->device
)
1503 fputs (" DEVICE(", dumpfile
);
1504 show_expr (omp_clauses
->device
);
1505 fputc (')', dumpfile
);
1507 if (omp_clauses
->thread_limit
)
1509 fputs (" THREAD_LIMIT(", dumpfile
);
1510 show_expr (omp_clauses
->thread_limit
);
1511 fputc (')', dumpfile
);
1513 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
1515 fprintf (dumpfile
, " DIST_SCHEDULE (STATIC");
1516 if (omp_clauses
->dist_chunk_size
)
1518 fputc (',', dumpfile
);
1519 show_expr (omp_clauses
->dist_chunk_size
);
1521 fputc (')', dumpfile
);
1523 if (omp_clauses
->defaultmap
)
1524 fputs (" DEFALTMAP (TOFROM: SCALAR)", dumpfile
);
1525 if (omp_clauses
->nogroup
)
1526 fputs (" NOGROUP", dumpfile
);
1527 if (omp_clauses
->simd
)
1528 fputs (" SIMD", dumpfile
);
1529 if (omp_clauses
->threads
)
1530 fputs (" THREADS", dumpfile
);
1531 if (omp_clauses
->grainsize
)
1533 fputs (" GRAINSIZE(", dumpfile
);
1534 show_expr (omp_clauses
->grainsize
);
1535 fputc (')', dumpfile
);
1537 if (omp_clauses
->hint
)
1539 fputs (" HINT(", dumpfile
);
1540 show_expr (omp_clauses
->hint
);
1541 fputc (')', dumpfile
);
1543 if (omp_clauses
->num_tasks
)
1545 fputs (" NUM_TASKS(", dumpfile
);
1546 show_expr (omp_clauses
->num_tasks
);
1547 fputc (')', dumpfile
);
1549 if (omp_clauses
->priority
)
1551 fputs (" PRIORITY(", dumpfile
);
1552 show_expr (omp_clauses
->priority
);
1553 fputc (')', dumpfile
);
1555 for (i
= 0; i
< OMP_IF_LAST
; i
++)
1556 if (omp_clauses
->if_exprs
[i
])
1558 static const char *ifs
[] = {
1565 "TARGET ENTER DATA",
1568 fputs (" IF(", dumpfile
);
1569 fputs (ifs
[i
], dumpfile
);
1570 fputs (": ", dumpfile
);
1571 show_expr (omp_clauses
->if_exprs
[i
]);
1572 fputc (')', dumpfile
);
1574 if (omp_clauses
->depend_source
)
1575 fputs (" DEPEND(source)", dumpfile
);
1578 /* Show a single OpenMP or OpenACC directive node and everything underneath it
1582 show_omp_node (int level
, gfc_code
*c
)
1584 gfc_omp_clauses
*omp_clauses
= NULL
;
1585 const char *name
= NULL
;
1586 bool is_oacc
= false;
1590 case EXEC_OACC_PARALLEL_LOOP
:
1591 name
= "PARALLEL LOOP"; is_oacc
= true; break;
1592 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
1593 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
1594 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
1595 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
1596 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
1597 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
1598 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
1599 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
1600 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
1601 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
1602 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
1603 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
1604 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
1605 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
1606 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
1607 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
1608 case EXEC_OMP_DISTRIBUTE
: name
= "DISTRIBUTE"; break;
1609 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
1610 name
= "DISTRIBUTE PARALLEL DO"; break;
1611 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
1612 name
= "DISTRIBUTE PARALLEL DO SIMD"; break;
1613 case EXEC_OMP_DISTRIBUTE_SIMD
: name
= "DISTRIBUTE SIMD"; break;
1614 case EXEC_OMP_DO
: name
= "DO"; break;
1615 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
1616 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
1617 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
1618 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
1619 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
1620 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
1621 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
1622 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
1623 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
1624 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
1625 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
1626 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
1627 case EXEC_OMP_TARGET
: name
= "TARGET"; break;
1628 case EXEC_OMP_TARGET_DATA
: name
= "TARGET DATA"; break;
1629 case EXEC_OMP_TARGET_ENTER_DATA
: name
= "TARGET ENTER DATA"; break;
1630 case EXEC_OMP_TARGET_EXIT_DATA
: name
= "TARGET EXIT DATA"; break;
1631 case EXEC_OMP_TARGET_PARALLEL
: name
= "TARGET PARALLEL"; break;
1632 case EXEC_OMP_TARGET_PARALLEL_DO
: name
= "TARGET PARALLEL DO"; break;
1633 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
1634 name
= "TARGET_PARALLEL_DO_SIMD"; break;
1635 case EXEC_OMP_TARGET_SIMD
: name
= "TARGET SIMD"; break;
1636 case EXEC_OMP_TARGET_TEAMS
: name
= "TARGET TEAMS"; break;
1637 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
1638 name
= "TARGET TEAMS DISTRIBUTE"; break;
1639 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1640 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
1641 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1642 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1643 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
1644 name
= "TARGET TEAMS DISTRIBUTE SIMD"; break;
1645 case EXEC_OMP_TARGET_UPDATE
: name
= "TARGET UPDATE"; break;
1646 case EXEC_OMP_TASK
: name
= "TASK"; break;
1647 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
1648 case EXEC_OMP_TASKLOOP
: name
= "TASKLOOP"; break;
1649 case EXEC_OMP_TASKLOOP_SIMD
: name
= "TASKLOOP SIMD"; break;
1650 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
1651 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
1652 case EXEC_OMP_TEAMS
: name
= "TEAMS"; break;
1653 case EXEC_OMP_TEAMS_DISTRIBUTE
: name
= "TEAMS DISTRIBUTE"; break;
1654 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1655 name
= "TEAMS DISTRIBUTE PARALLEL DO"; break;
1656 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1657 name
= "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1658 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
: name
= "TEAMS DISTRIBUTE SIMD"; break;
1659 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
1663 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
1666 case EXEC_OACC_PARALLEL_LOOP
:
1667 case EXEC_OACC_PARALLEL
:
1668 case EXEC_OACC_KERNELS_LOOP
:
1669 case EXEC_OACC_KERNELS
:
1670 case EXEC_OACC_DATA
:
1671 case EXEC_OACC_HOST_DATA
:
1672 case EXEC_OACC_LOOP
:
1673 case EXEC_OACC_UPDATE
:
1674 case EXEC_OACC_WAIT
:
1675 case EXEC_OACC_CACHE
:
1676 case EXEC_OACC_ENTER_DATA
:
1677 case EXEC_OACC_EXIT_DATA
:
1678 case EXEC_OMP_CANCEL
:
1679 case EXEC_OMP_CANCELLATION_POINT
:
1680 case EXEC_OMP_DISTRIBUTE
:
1681 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
1682 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
1683 case EXEC_OMP_DISTRIBUTE_SIMD
:
1685 case EXEC_OMP_DO_SIMD
:
1686 case EXEC_OMP_ORDERED
:
1687 case EXEC_OMP_PARALLEL
:
1688 case EXEC_OMP_PARALLEL_DO
:
1689 case EXEC_OMP_PARALLEL_DO_SIMD
:
1690 case EXEC_OMP_PARALLEL_SECTIONS
:
1691 case EXEC_OMP_PARALLEL_WORKSHARE
:
1692 case EXEC_OMP_SECTIONS
:
1694 case EXEC_OMP_SINGLE
:
1695 case EXEC_OMP_TARGET
:
1696 case EXEC_OMP_TARGET_DATA
:
1697 case EXEC_OMP_TARGET_ENTER_DATA
:
1698 case EXEC_OMP_TARGET_EXIT_DATA
:
1699 case EXEC_OMP_TARGET_PARALLEL
:
1700 case EXEC_OMP_TARGET_PARALLEL_DO
:
1701 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
1702 case EXEC_OMP_TARGET_SIMD
:
1703 case EXEC_OMP_TARGET_TEAMS
:
1704 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
1705 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1706 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1707 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
1708 case EXEC_OMP_TARGET_UPDATE
:
1710 case EXEC_OMP_TASKLOOP
:
1711 case EXEC_OMP_TASKLOOP_SIMD
:
1712 case EXEC_OMP_TEAMS
:
1713 case EXEC_OMP_TEAMS_DISTRIBUTE
:
1714 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1715 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1716 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
1717 case EXEC_OMP_WORKSHARE
:
1718 omp_clauses
= c
->ext
.omp_clauses
;
1720 case EXEC_OMP_CRITICAL
:
1721 omp_clauses
= c
->ext
.omp_clauses
;
1723 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
1725 case EXEC_OMP_FLUSH
:
1726 if (c
->ext
.omp_namelist
)
1728 fputs (" (", dumpfile
);
1729 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
1730 fputc (')', dumpfile
);
1733 case EXEC_OMP_BARRIER
:
1734 case EXEC_OMP_TASKWAIT
:
1735 case EXEC_OMP_TASKYIELD
:
1741 show_omp_clauses (omp_clauses
);
1742 fputc ('\n', dumpfile
);
1744 /* OpenMP and OpenACC executable directives don't have associated blocks. */
1745 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
1746 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
1747 || c
->op
== EXEC_OMP_TARGET_UPDATE
|| c
->op
== EXEC_OMP_TARGET_ENTER_DATA
1748 || c
->op
== EXEC_OMP_TARGET_EXIT_DATA
1749 || (c
->op
== EXEC_OMP_ORDERED
&& c
->block
== NULL
))
1751 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
1753 gfc_code
*d
= c
->block
;
1756 show_code (level
+ 1, d
->next
);
1757 if (d
->block
== NULL
)
1759 code_indent (level
, 0);
1760 fputs ("!$OMP SECTION\n", dumpfile
);
1765 show_code (level
+ 1, c
->block
->next
);
1766 if (c
->op
== EXEC_OMP_ATOMIC
)
1768 fputc ('\n', dumpfile
);
1769 code_indent (level
, 0);
1770 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
1771 if (omp_clauses
!= NULL
)
1773 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
1775 fputs (" COPYPRIVATE(", dumpfile
);
1776 show_omp_namelist (OMP_LIST_COPYPRIVATE
,
1777 omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
1778 fputc (')', dumpfile
);
1780 else if (omp_clauses
->nowait
)
1781 fputs (" NOWAIT", dumpfile
);
1783 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_clauses
)
1784 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
1788 /* Show a single code node and everything underneath it if necessary. */
1791 show_code_node (int level
, gfc_code
*c
)
1793 gfc_forall_iterator
*fa
;
1806 fputc ('\n', dumpfile
);
1807 code_indent (level
, c
->here
);
1814 case EXEC_END_PROCEDURE
:
1818 fputs ("NOP", dumpfile
);
1822 fputs ("CONTINUE", dumpfile
);
1826 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
1829 case EXEC_INIT_ASSIGN
:
1831 fputs ("ASSIGN ", dumpfile
);
1832 show_expr (c
->expr1
);
1833 fputc (' ', dumpfile
);
1834 show_expr (c
->expr2
);
1837 case EXEC_LABEL_ASSIGN
:
1838 fputs ("LABEL ASSIGN ", dumpfile
);
1839 show_expr (c
->expr1
);
1840 fprintf (dumpfile
, " %d", c
->label1
->value
);
1843 case EXEC_POINTER_ASSIGN
:
1844 fputs ("POINTER ASSIGN ", dumpfile
);
1845 show_expr (c
->expr1
);
1846 fputc (' ', dumpfile
);
1847 show_expr (c
->expr2
);
1851 fputs ("GOTO ", dumpfile
);
1853 fprintf (dumpfile
, "%d", c
->label1
->value
);
1856 show_expr (c
->expr1
);
1860 fputs (", (", dumpfile
);
1861 for (; d
; d
= d
->block
)
1863 code_indent (level
, d
->label1
);
1864 if (d
->block
!= NULL
)
1865 fputc (',', dumpfile
);
1867 fputc (')', dumpfile
);
1874 case EXEC_ASSIGN_CALL
:
1875 if (c
->resolved_sym
)
1876 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
1877 else if (c
->symtree
)
1878 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
1880 fputs ("CALL ?? ", dumpfile
);
1882 show_actual_arglist (c
->ext
.actual
);
1886 fputs ("CALL ", dumpfile
);
1887 show_compcall (c
->expr1
);
1891 fputs ("CALL ", dumpfile
);
1892 show_expr (c
->expr1
);
1893 show_actual_arglist (c
->ext
.actual
);
1897 fputs ("RETURN ", dumpfile
);
1899 show_expr (c
->expr1
);
1903 fputs ("PAUSE ", dumpfile
);
1905 if (c
->expr1
!= NULL
)
1906 show_expr (c
->expr1
);
1908 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1912 case EXEC_ERROR_STOP
:
1913 fputs ("ERROR ", dumpfile
);
1917 fputs ("STOP ", dumpfile
);
1919 if (c
->expr1
!= NULL
)
1920 show_expr (c
->expr1
);
1922 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1926 case EXEC_FAIL_IMAGE
:
1927 fputs ("FAIL IMAGE ", dumpfile
);
1930 case EXEC_CHANGE_TEAM
:
1931 fputs ("CHANGE TEAM", dumpfile
);
1935 fputs ("END TEAM", dumpfile
);
1938 case EXEC_FORM_TEAM
:
1939 fputs ("FORM TEAM", dumpfile
);
1942 case EXEC_SYNC_TEAM
:
1943 fputs ("SYNC TEAM", dumpfile
);
1947 fputs ("SYNC ALL ", dumpfile
);
1948 if (c
->expr2
!= NULL
)
1950 fputs (" stat=", dumpfile
);
1951 show_expr (c
->expr2
);
1953 if (c
->expr3
!= NULL
)
1955 fputs (" errmsg=", dumpfile
);
1956 show_expr (c
->expr3
);
1960 case EXEC_SYNC_MEMORY
:
1961 fputs ("SYNC MEMORY ", dumpfile
);
1962 if (c
->expr2
!= NULL
)
1964 fputs (" stat=", dumpfile
);
1965 show_expr (c
->expr2
);
1967 if (c
->expr3
!= NULL
)
1969 fputs (" errmsg=", dumpfile
);
1970 show_expr (c
->expr3
);
1974 case EXEC_SYNC_IMAGES
:
1975 fputs ("SYNC IMAGES image-set=", dumpfile
);
1976 if (c
->expr1
!= NULL
)
1977 show_expr (c
->expr1
);
1979 fputs ("* ", dumpfile
);
1980 if (c
->expr2
!= NULL
)
1982 fputs (" stat=", dumpfile
);
1983 show_expr (c
->expr2
);
1985 if (c
->expr3
!= NULL
)
1987 fputs (" errmsg=", dumpfile
);
1988 show_expr (c
->expr3
);
1992 case EXEC_EVENT_POST
:
1993 case EXEC_EVENT_WAIT
:
1994 if (c
->op
== EXEC_EVENT_POST
)
1995 fputs ("EVENT POST ", dumpfile
);
1997 fputs ("EVENT WAIT ", dumpfile
);
1999 fputs ("event-variable=", dumpfile
);
2000 if (c
->expr1
!= NULL
)
2001 show_expr (c
->expr1
);
2002 if (c
->expr4
!= NULL
)
2004 fputs (" until_count=", dumpfile
);
2005 show_expr (c
->expr4
);
2007 if (c
->expr2
!= NULL
)
2009 fputs (" stat=", dumpfile
);
2010 show_expr (c
->expr2
);
2012 if (c
->expr3
!= NULL
)
2014 fputs (" errmsg=", dumpfile
);
2015 show_expr (c
->expr3
);
2021 if (c
->op
== EXEC_LOCK
)
2022 fputs ("LOCK ", dumpfile
);
2024 fputs ("UNLOCK ", dumpfile
);
2026 fputs ("lock-variable=", dumpfile
);
2027 if (c
->expr1
!= NULL
)
2028 show_expr (c
->expr1
);
2029 if (c
->expr4
!= NULL
)
2031 fputs (" acquired_lock=", dumpfile
);
2032 show_expr (c
->expr4
);
2034 if (c
->expr2
!= NULL
)
2036 fputs (" stat=", dumpfile
);
2037 show_expr (c
->expr2
);
2039 if (c
->expr3
!= NULL
)
2041 fputs (" errmsg=", dumpfile
);
2042 show_expr (c
->expr3
);
2046 case EXEC_ARITHMETIC_IF
:
2047 fputs ("IF ", dumpfile
);
2048 show_expr (c
->expr1
);
2049 fprintf (dumpfile
, " %d, %d, %d",
2050 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
2055 fputs ("IF ", dumpfile
);
2056 show_expr (d
->expr1
);
2059 show_code (level
+ 1, d
->next
);
2063 for (; d
; d
= d
->block
)
2065 fputs("\n", dumpfile
);
2066 code_indent (level
, 0);
2067 if (d
->expr1
== NULL
)
2068 fputs ("ELSE", dumpfile
);
2071 fputs ("ELSE IF ", dumpfile
);
2072 show_expr (d
->expr1
);
2076 show_code (level
+ 1, d
->next
);
2081 code_indent (level
, c
->label1
);
2085 fputs ("ENDIF", dumpfile
);
2090 const char* blocktype
;
2091 gfc_namespace
*saved_ns
;
2092 gfc_association_list
*alist
;
2094 if (c
->ext
.block
.assoc
)
2095 blocktype
= "ASSOCIATE";
2097 blocktype
= "BLOCK";
2099 fprintf (dumpfile
, "%s ", blocktype
);
2100 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
2102 fprintf (dumpfile
, " %s = ", alist
->name
);
2103 show_expr (alist
->target
);
2107 ns
= c
->ext
.block
.ns
;
2108 saved_ns
= gfc_current_ns
;
2109 gfc_current_ns
= ns
;
2110 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2111 gfc_current_ns
= saved_ns
;
2112 show_code (show_level
, ns
->code
);
2115 fprintf (dumpfile
, "END %s ", blocktype
);
2119 case EXEC_END_BLOCK
:
2120 /* Only come here when there is a label on an
2121 END ASSOCIATE construct. */
2125 case EXEC_SELECT_TYPE
:
2127 if (c
->op
== EXEC_SELECT_TYPE
)
2128 fputs ("SELECT TYPE ", dumpfile
);
2130 fputs ("SELECT CASE ", dumpfile
);
2131 show_expr (c
->expr1
);
2132 fputc ('\n', dumpfile
);
2134 for (; d
; d
= d
->block
)
2136 code_indent (level
, 0);
2138 fputs ("CASE ", dumpfile
);
2139 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
2141 fputc ('(', dumpfile
);
2142 show_expr (cp
->low
);
2143 fputc (' ', dumpfile
);
2144 show_expr (cp
->high
);
2145 fputc (')', dumpfile
);
2146 fputc (' ', dumpfile
);
2148 fputc ('\n', dumpfile
);
2150 show_code (level
+ 1, d
->next
);
2153 code_indent (level
, c
->label1
);
2154 fputs ("END SELECT", dumpfile
);
2158 fputs ("WHERE ", dumpfile
);
2161 show_expr (d
->expr1
);
2162 fputc ('\n', dumpfile
);
2164 show_code (level
+ 1, d
->next
);
2166 for (d
= d
->block
; d
; d
= d
->block
)
2168 code_indent (level
, 0);
2169 fputs ("ELSE WHERE ", dumpfile
);
2170 show_expr (d
->expr1
);
2171 fputc ('\n', dumpfile
);
2172 show_code (level
+ 1, d
->next
);
2175 code_indent (level
, 0);
2176 fputs ("END WHERE", dumpfile
);
2181 fputs ("FORALL ", dumpfile
);
2182 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2184 show_expr (fa
->var
);
2185 fputc (' ', dumpfile
);
2186 show_expr (fa
->start
);
2187 fputc (':', dumpfile
);
2188 show_expr (fa
->end
);
2189 fputc (':', dumpfile
);
2190 show_expr (fa
->stride
);
2192 if (fa
->next
!= NULL
)
2193 fputc (',', dumpfile
);
2196 if (c
->expr1
!= NULL
)
2198 fputc (',', dumpfile
);
2199 show_expr (c
->expr1
);
2201 fputc ('\n', dumpfile
);
2203 show_code (level
+ 1, c
->block
->next
);
2205 code_indent (level
, 0);
2206 fputs ("END FORALL", dumpfile
);
2210 fputs ("CRITICAL\n", dumpfile
);
2211 show_code (level
+ 1, c
->block
->next
);
2212 code_indent (level
, 0);
2213 fputs ("END CRITICAL", dumpfile
);
2217 fputs ("DO ", dumpfile
);
2219 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
2221 show_expr (c
->ext
.iterator
->var
);
2222 fputc ('=', dumpfile
);
2223 show_expr (c
->ext
.iterator
->start
);
2224 fputc (' ', dumpfile
);
2225 show_expr (c
->ext
.iterator
->end
);
2226 fputc (' ', dumpfile
);
2227 show_expr (c
->ext
.iterator
->step
);
2230 show_code (level
+ 1, c
->block
->next
);
2237 fputs ("END DO", dumpfile
);
2240 case EXEC_DO_CONCURRENT
:
2241 fputs ("DO CONCURRENT ", dumpfile
);
2242 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2244 show_expr (fa
->var
);
2245 fputc (' ', dumpfile
);
2246 show_expr (fa
->start
);
2247 fputc (':', dumpfile
);
2248 show_expr (fa
->end
);
2249 fputc (':', dumpfile
);
2250 show_expr (fa
->stride
);
2252 if (fa
->next
!= NULL
)
2253 fputc (',', dumpfile
);
2255 show_expr (c
->expr1
);
2258 show_code (level
+ 1, c
->block
->next
);
2260 code_indent (level
, c
->label1
);
2262 fputs ("END DO", dumpfile
);
2266 fputs ("DO WHILE ", dumpfile
);
2267 show_expr (c
->expr1
);
2268 fputc ('\n', dumpfile
);
2270 show_code (level
+ 1, c
->block
->next
);
2272 code_indent (level
, c
->label1
);
2273 fputs ("END DO", dumpfile
);
2277 fputs ("CYCLE", dumpfile
);
2279 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2283 fputs ("EXIT", dumpfile
);
2285 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2289 fputs ("ALLOCATE ", dumpfile
);
2292 fputs (" STAT=", dumpfile
);
2293 show_expr (c
->expr1
);
2298 fputs (" ERRMSG=", dumpfile
);
2299 show_expr (c
->expr2
);
2305 fputs (" MOLD=", dumpfile
);
2307 fputs (" SOURCE=", dumpfile
);
2308 show_expr (c
->expr3
);
2311 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2313 fputc (' ', dumpfile
);
2314 show_expr (a
->expr
);
2319 case EXEC_DEALLOCATE
:
2320 fputs ("DEALLOCATE ", dumpfile
);
2323 fputs (" STAT=", dumpfile
);
2324 show_expr (c
->expr1
);
2329 fputs (" ERRMSG=", dumpfile
);
2330 show_expr (c
->expr2
);
2333 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2335 fputc (' ', dumpfile
);
2336 show_expr (a
->expr
);
2342 fputs ("OPEN", dumpfile
);
2347 fputs (" UNIT=", dumpfile
);
2348 show_expr (open
->unit
);
2352 fputs (" IOMSG=", dumpfile
);
2353 show_expr (open
->iomsg
);
2357 fputs (" IOSTAT=", dumpfile
);
2358 show_expr (open
->iostat
);
2362 fputs (" FILE=", dumpfile
);
2363 show_expr (open
->file
);
2367 fputs (" STATUS=", dumpfile
);
2368 show_expr (open
->status
);
2372 fputs (" ACCESS=", dumpfile
);
2373 show_expr (open
->access
);
2377 fputs (" FORM=", dumpfile
);
2378 show_expr (open
->form
);
2382 fputs (" RECL=", dumpfile
);
2383 show_expr (open
->recl
);
2387 fputs (" BLANK=", dumpfile
);
2388 show_expr (open
->blank
);
2392 fputs (" POSITION=", dumpfile
);
2393 show_expr (open
->position
);
2397 fputs (" ACTION=", dumpfile
);
2398 show_expr (open
->action
);
2402 fputs (" DELIM=", dumpfile
);
2403 show_expr (open
->delim
);
2407 fputs (" PAD=", dumpfile
);
2408 show_expr (open
->pad
);
2412 fputs (" DECIMAL=", dumpfile
);
2413 show_expr (open
->decimal
);
2417 fputs (" ENCODING=", dumpfile
);
2418 show_expr (open
->encoding
);
2422 fputs (" ROUND=", dumpfile
);
2423 show_expr (open
->round
);
2427 fputs (" SIGN=", dumpfile
);
2428 show_expr (open
->sign
);
2432 fputs (" CONVERT=", dumpfile
);
2433 show_expr (open
->convert
);
2435 if (open
->asynchronous
)
2437 fputs (" ASYNCHRONOUS=", dumpfile
);
2438 show_expr (open
->asynchronous
);
2440 if (open
->err
!= NULL
)
2441 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
2446 fputs ("CLOSE", dumpfile
);
2447 close
= c
->ext
.close
;
2451 fputs (" UNIT=", dumpfile
);
2452 show_expr (close
->unit
);
2456 fputs (" IOMSG=", dumpfile
);
2457 show_expr (close
->iomsg
);
2461 fputs (" IOSTAT=", dumpfile
);
2462 show_expr (close
->iostat
);
2466 fputs (" STATUS=", dumpfile
);
2467 show_expr (close
->status
);
2469 if (close
->err
!= NULL
)
2470 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
2473 case EXEC_BACKSPACE
:
2474 fputs ("BACKSPACE", dumpfile
);
2478 fputs ("ENDFILE", dumpfile
);
2482 fputs ("REWIND", dumpfile
);
2486 fputs ("FLUSH", dumpfile
);
2489 fp
= c
->ext
.filepos
;
2493 fputs (" UNIT=", dumpfile
);
2494 show_expr (fp
->unit
);
2498 fputs (" IOMSG=", dumpfile
);
2499 show_expr (fp
->iomsg
);
2503 fputs (" IOSTAT=", dumpfile
);
2504 show_expr (fp
->iostat
);
2506 if (fp
->err
!= NULL
)
2507 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
2511 fputs ("INQUIRE", dumpfile
);
2516 fputs (" UNIT=", dumpfile
);
2517 show_expr (i
->unit
);
2521 fputs (" FILE=", dumpfile
);
2522 show_expr (i
->file
);
2527 fputs (" IOMSG=", dumpfile
);
2528 show_expr (i
->iomsg
);
2532 fputs (" IOSTAT=", dumpfile
);
2533 show_expr (i
->iostat
);
2537 fputs (" EXIST=", dumpfile
);
2538 show_expr (i
->exist
);
2542 fputs (" OPENED=", dumpfile
);
2543 show_expr (i
->opened
);
2547 fputs (" NUMBER=", dumpfile
);
2548 show_expr (i
->number
);
2552 fputs (" NAMED=", dumpfile
);
2553 show_expr (i
->named
);
2557 fputs (" NAME=", dumpfile
);
2558 show_expr (i
->name
);
2562 fputs (" ACCESS=", dumpfile
);
2563 show_expr (i
->access
);
2567 fputs (" SEQUENTIAL=", dumpfile
);
2568 show_expr (i
->sequential
);
2573 fputs (" DIRECT=", dumpfile
);
2574 show_expr (i
->direct
);
2578 fputs (" FORM=", dumpfile
);
2579 show_expr (i
->form
);
2583 fputs (" FORMATTED", dumpfile
);
2584 show_expr (i
->formatted
);
2588 fputs (" UNFORMATTED=", dumpfile
);
2589 show_expr (i
->unformatted
);
2593 fputs (" RECL=", dumpfile
);
2594 show_expr (i
->recl
);
2598 fputs (" NEXTREC=", dumpfile
);
2599 show_expr (i
->nextrec
);
2603 fputs (" BLANK=", dumpfile
);
2604 show_expr (i
->blank
);
2608 fputs (" POSITION=", dumpfile
);
2609 show_expr (i
->position
);
2613 fputs (" ACTION=", dumpfile
);
2614 show_expr (i
->action
);
2618 fputs (" READ=", dumpfile
);
2619 show_expr (i
->read
);
2623 fputs (" WRITE=", dumpfile
);
2624 show_expr (i
->write
);
2628 fputs (" READWRITE=", dumpfile
);
2629 show_expr (i
->readwrite
);
2633 fputs (" DELIM=", dumpfile
);
2634 show_expr (i
->delim
);
2638 fputs (" PAD=", dumpfile
);
2643 fputs (" CONVERT=", dumpfile
);
2644 show_expr (i
->convert
);
2646 if (i
->asynchronous
)
2648 fputs (" ASYNCHRONOUS=", dumpfile
);
2649 show_expr (i
->asynchronous
);
2653 fputs (" DECIMAL=", dumpfile
);
2654 show_expr (i
->decimal
);
2658 fputs (" ENCODING=", dumpfile
);
2659 show_expr (i
->encoding
);
2663 fputs (" PENDING=", dumpfile
);
2664 show_expr (i
->pending
);
2668 fputs (" ROUND=", dumpfile
);
2669 show_expr (i
->round
);
2673 fputs (" SIGN=", dumpfile
);
2674 show_expr (i
->sign
);
2678 fputs (" SIZE=", dumpfile
);
2679 show_expr (i
->size
);
2683 fputs (" ID=", dumpfile
);
2688 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
2692 fputs ("IOLENGTH ", dumpfile
);
2693 show_expr (c
->expr1
);
2698 fputs ("READ", dumpfile
);
2702 fputs ("WRITE", dumpfile
);
2708 fputs (" UNIT=", dumpfile
);
2709 show_expr (dt
->io_unit
);
2712 if (dt
->format_expr
)
2714 fputs (" FMT=", dumpfile
);
2715 show_expr (dt
->format_expr
);
2718 if (dt
->format_label
!= NULL
)
2719 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
2721 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
2725 fputs (" IOMSG=", dumpfile
);
2726 show_expr (dt
->iomsg
);
2730 fputs (" IOSTAT=", dumpfile
);
2731 show_expr (dt
->iostat
);
2735 fputs (" SIZE=", dumpfile
);
2736 show_expr (dt
->size
);
2740 fputs (" REC=", dumpfile
);
2741 show_expr (dt
->rec
);
2745 fputs (" ADVANCE=", dumpfile
);
2746 show_expr (dt
->advance
);
2750 fputs (" ID=", dumpfile
);
2755 fputs (" POS=", dumpfile
);
2756 show_expr (dt
->pos
);
2758 if (dt
->asynchronous
)
2760 fputs (" ASYNCHRONOUS=", dumpfile
);
2761 show_expr (dt
->asynchronous
);
2765 fputs (" BLANK=", dumpfile
);
2766 show_expr (dt
->blank
);
2770 fputs (" DECIMAL=", dumpfile
);
2771 show_expr (dt
->decimal
);
2775 fputs (" DELIM=", dumpfile
);
2776 show_expr (dt
->delim
);
2780 fputs (" PAD=", dumpfile
);
2781 show_expr (dt
->pad
);
2785 fputs (" ROUND=", dumpfile
);
2786 show_expr (dt
->round
);
2790 fputs (" SIGN=", dumpfile
);
2791 show_expr (dt
->sign
);
2795 for (c
= c
->block
->next
; c
; c
= c
->next
)
2796 show_code_node (level
+ (c
->next
!= NULL
), c
);
2800 fputs ("TRANSFER ", dumpfile
);
2801 show_expr (c
->expr1
);
2805 fputs ("DT_END", dumpfile
);
2808 if (dt
->err
!= NULL
)
2809 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
2810 if (dt
->end
!= NULL
)
2811 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
2812 if (dt
->eor
!= NULL
)
2813 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
2817 fputs ("WAIT", dumpfile
);
2819 if (c
->ext
.wait
!= NULL
)
2821 gfc_wait
*wait
= c
->ext
.wait
;
2824 fputs (" UNIT=", dumpfile
);
2825 show_expr (wait
->unit
);
2829 fputs (" IOSTAT=", dumpfile
);
2830 show_expr (wait
->iostat
);
2834 fputs (" IOMSG=", dumpfile
);
2835 show_expr (wait
->iomsg
);
2839 fputs (" ID=", dumpfile
);
2840 show_expr (wait
->id
);
2843 fprintf (dumpfile
, " ERR=%d", wait
->err
->value
);
2845 fprintf (dumpfile
, " END=%d", wait
->end
->value
);
2847 fprintf (dumpfile
, " EOR=%d", wait
->eor
->value
);
2851 case EXEC_OACC_PARALLEL_LOOP
:
2852 case EXEC_OACC_PARALLEL
:
2853 case EXEC_OACC_KERNELS_LOOP
:
2854 case EXEC_OACC_KERNELS
:
2855 case EXEC_OACC_DATA
:
2856 case EXEC_OACC_HOST_DATA
:
2857 case EXEC_OACC_LOOP
:
2858 case EXEC_OACC_UPDATE
:
2859 case EXEC_OACC_WAIT
:
2860 case EXEC_OACC_CACHE
:
2861 case EXEC_OACC_ENTER_DATA
:
2862 case EXEC_OACC_EXIT_DATA
:
2863 case EXEC_OMP_ATOMIC
:
2864 case EXEC_OMP_CANCEL
:
2865 case EXEC_OMP_CANCELLATION_POINT
:
2866 case EXEC_OMP_BARRIER
:
2867 case EXEC_OMP_CRITICAL
:
2868 case EXEC_OMP_DISTRIBUTE
:
2869 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2870 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2871 case EXEC_OMP_DISTRIBUTE_SIMD
:
2873 case EXEC_OMP_DO_SIMD
:
2874 case EXEC_OMP_FLUSH
:
2875 case EXEC_OMP_MASTER
:
2876 case EXEC_OMP_ORDERED
:
2877 case EXEC_OMP_PARALLEL
:
2878 case EXEC_OMP_PARALLEL_DO
:
2879 case EXEC_OMP_PARALLEL_DO_SIMD
:
2880 case EXEC_OMP_PARALLEL_SECTIONS
:
2881 case EXEC_OMP_PARALLEL_WORKSHARE
:
2882 case EXEC_OMP_SECTIONS
:
2884 case EXEC_OMP_SINGLE
:
2885 case EXEC_OMP_TARGET
:
2886 case EXEC_OMP_TARGET_DATA
:
2887 case EXEC_OMP_TARGET_ENTER_DATA
:
2888 case EXEC_OMP_TARGET_EXIT_DATA
:
2889 case EXEC_OMP_TARGET_PARALLEL
:
2890 case EXEC_OMP_TARGET_PARALLEL_DO
:
2891 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2892 case EXEC_OMP_TARGET_SIMD
:
2893 case EXEC_OMP_TARGET_TEAMS
:
2894 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2895 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2896 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2897 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2898 case EXEC_OMP_TARGET_UPDATE
:
2900 case EXEC_OMP_TASKGROUP
:
2901 case EXEC_OMP_TASKLOOP
:
2902 case EXEC_OMP_TASKLOOP_SIMD
:
2903 case EXEC_OMP_TASKWAIT
:
2904 case EXEC_OMP_TASKYIELD
:
2905 case EXEC_OMP_TEAMS
:
2906 case EXEC_OMP_TEAMS_DISTRIBUTE
:
2907 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2908 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2909 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
2910 case EXEC_OMP_WORKSHARE
:
2911 show_omp_node (level
, c
);
2915 gfc_internal_error ("show_code_node(): Bad statement code");
2920 /* Show an equivalence chain. */
2923 show_equiv (gfc_equiv
*eq
)
2926 fputs ("Equivalence: ", dumpfile
);
2929 show_expr (eq
->expr
);
2932 fputs (", ", dumpfile
);
2937 /* Show a freakin' whole namespace. */
2940 show_namespace (gfc_namespace
*ns
)
2942 gfc_interface
*intr
;
2943 gfc_namespace
*save
;
2949 save
= gfc_current_ns
;
2952 fputs ("Namespace:", dumpfile
);
2958 while (i
< GFC_LETTERS
- 1
2959 && gfc_compare_types (&ns
->default_type
[i
+1],
2960 &ns
->default_type
[l
]))
2964 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
2966 fprintf (dumpfile
, " %c: ", l
+'A');
2968 show_typespec(&ns
->default_type
[l
]);
2970 } while (i
< GFC_LETTERS
);
2972 if (ns
->proc_name
!= NULL
)
2975 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
2979 gfc_current_ns
= ns
;
2980 gfc_traverse_symtree (ns
->common_root
, show_common
);
2982 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2984 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
2986 /* User operator interfaces */
2992 fprintf (dumpfile
, "Operator interfaces for %s:",
2993 gfc_op2string ((gfc_intrinsic_op
) op
));
2995 for (; intr
; intr
= intr
->next
)
2996 fprintf (dumpfile
, " %s", intr
->sym
->name
);
2999 if (ns
->uop_root
!= NULL
)
3002 fputs ("User operators:\n", dumpfile
);
3003 gfc_traverse_user_op (ns
, show_uop
);
3006 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
3009 if (ns
->oacc_declare
)
3011 struct gfc_oacc_declare
*decl
;
3012 /* Dump !$ACC DECLARE clauses. */
3013 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
3016 fprintf (dumpfile
, "!$ACC DECLARE");
3017 show_omp_clauses (decl
->clauses
);
3021 fputc ('\n', dumpfile
);
3023 fputs ("code:", dumpfile
);
3024 show_code (show_level
, ns
->code
);
3027 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
3029 fputs ("\nCONTAINS\n", dumpfile
);
3031 show_namespace (ns
);
3035 fputc ('\n', dumpfile
);
3036 gfc_current_ns
= save
;
3040 /* Main function for dumping a parse tree. */
3043 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
3046 show_namespace (ns
);
3049 /* This part writes BIND(C) definition for use in external C programs. */
3051 static void write_interop_decl (gfc_symbol
*);
3054 gfc_dump_c_prototypes (gfc_namespace
*ns
, FILE *file
)
3057 gfc_get_errors (NULL
, &error_count
);
3058 if (error_count
!= 0)
3061 gfc_traverse_ns (ns
, write_interop_decl
);
3064 enum type_return
{ T_OK
=0, T_WARN
, T_ERROR
};
3066 /* Return the name of the type for later output. Both function pointers and
3067 void pointers will be mapped to void *. */
3069 static enum type_return
3070 get_c_type_name (gfc_typespec
*ts
, gfc_array_spec
*as
, const char **pre
,
3071 const char **type_name
, bool *asterisk
, const char **post
,
3074 static char post_buffer
[40];
3075 enum type_return ret
;
3081 *type_name
= "<error>";
3082 if (ts
->type
== BT_REAL
|| ts
->type
== BT_INTEGER
)
3084 if (ts
->is_c_interop
&& ts
->interop_kind
)
3086 *type_name
= ts
->interop_kind
->name
+ 2;
3087 if (strcmp (*type_name
, "signed_char") == 0)
3088 *type_name
= "signed char";
3089 else if (strcmp (*type_name
, "size_t") == 0)
3090 *type_name
= "ssize_t";
3096 /* The user did not specify a C interop type. Let's look through
3097 the available table and use the first one, but warn. */
3098 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3100 if (c_interop_kinds_table
[i
].f90_type
== ts
->type
3101 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3103 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3104 if (strcmp (*type_name
, "signed_char") == 0)
3105 *type_name
= "signed char";
3106 else if (strcmp (*type_name
, "size_t") == 0)
3107 *type_name
= "ssize_t";
3115 else if (ts
->type
== BT_LOGICAL
)
3117 if (ts
->is_c_interop
&& ts
->interop_kind
)
3119 *type_name
= "_Bool";
3124 /* Let's select an appropriate int, with a warning. */
3125 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3127 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3128 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3130 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3136 else if (ts
->type
== BT_CHARACTER
)
3138 if (ts
->is_c_interop
)
3140 *type_name
= "char";
3145 /* Let's select an appropriate int, with a warning. */
3146 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3148 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3149 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3151 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3157 else if (ts
->type
== BT_DERIVED
)
3159 if (ts
->u
.derived
->from_intmod
== INTMOD_ISO_C_BINDING
)
3161 if (strcmp (ts
->u
.derived
->name
, "c_ptr") == 0)
3162 *type_name
= "void";
3163 else if (strcmp (ts
->u
.derived
->name
, "c_funptr") == 0)
3165 *type_name
= "int ";
3180 *type_name
= ts
->u
.derived
->name
;
3184 if (ret
!= T_ERROR
&& as
)
3188 size_ok
= spec_size (as
, &sz
);
3189 gcc_assert (size_ok
== true);
3190 gmp_snprintf (post_buffer
, sizeof(post_buffer
), "[%Zd]", sz
);
3191 *post
= post_buffer
;
3197 /* Write out a declaration. */
3199 write_decl (gfc_typespec
*ts
, gfc_array_spec
*as
, const char *sym_name
,
3200 bool func_ret
, locus
*where
)
3202 const char *pre
, *type_name
, *post
;
3204 enum type_return rok
;
3206 rok
= get_c_type_name (ts
, as
, &pre
, &type_name
, &asterisk
, &post
, func_ret
);
3209 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3210 gfc_typename (ts
), where
);
3211 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
3215 fputs (type_name
, dumpfile
);
3216 fputs (pre
, dumpfile
);
3218 fputs ("*", dumpfile
);
3220 fputs (sym_name
, dumpfile
);
3221 fputs (post
, dumpfile
);
3224 fprintf (dumpfile
," /* WARNING: Converting '%s' to interoperable type */",
3228 /* Write out an interoperable type. It will be written as a typedef
3232 write_type (gfc_symbol
*sym
)
3236 fprintf (dumpfile
, "typedef struct %s {\n", sym
->name
);
3237 for (c
= sym
->components
; c
; c
= c
->next
)
3239 fputs (" ", dumpfile
);
3240 write_decl (&(c
->ts
), c
->as
, c
->name
, false, &sym
->declared_at
);
3241 fputs (";\n", dumpfile
);
3244 fprintf (dumpfile
, "} %s;\n", sym
->name
);
3247 /* Write out a variable. */
3250 write_variable (gfc_symbol
*sym
)
3252 const char *sym_name
;
3254 gcc_assert (sym
->attr
.flavor
== FL_VARIABLE
);
3256 if (sym
->binding_label
)
3257 sym_name
= sym
->binding_label
;
3259 sym_name
= sym
->name
;
3261 fputs ("extern ", dumpfile
);
3262 write_decl (&(sym
->ts
), sym
->as
, sym_name
, false, &sym
->declared_at
);
3263 fputs (";\n", dumpfile
);
3267 /* Write out a procedure, including its arguments. */
3269 write_proc (gfc_symbol
*sym
)
3271 const char *pre
, *type_name
, *post
;
3273 enum type_return rok
;
3274 gfc_formal_arglist
*f
;
3275 const char *sym_name
;
3276 const char *intent_in
;
3278 if (sym
->binding_label
)
3279 sym_name
= sym
->binding_label
;
3281 sym_name
= sym
->name
;
3283 if (sym
->ts
.type
== BT_UNKNOWN
)
3285 fprintf (dumpfile
, "void ");
3286 fputs (sym_name
, dumpfile
);
3289 write_decl (&(sym
->ts
), sym
->as
, sym_name
, true, &sym
->declared_at
);
3291 fputs (" (", dumpfile
);
3293 for (f
= sym
->formal
; f
; f
= f
->next
)
3297 rok
= get_c_type_name (&(s
->ts
), NULL
, &pre
, &type_name
, &asterisk
,
3301 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3302 gfc_typename (&s
->ts
), &s
->declared_at
);
3303 fprintf (stderr
, "/* Cannot convert '%s' to interoperable type */",
3304 gfc_typename (&s
->ts
));
3311 if (s
->attr
.intent
== INTENT_IN
&& !s
->attr
.value
)
3312 intent_in
= "const ";
3316 fputs (intent_in
, dumpfile
);
3317 fputs (type_name
, dumpfile
);
3318 fputs (pre
, dumpfile
);
3320 fputs ("*", dumpfile
);
3322 fputs (s
->name
, dumpfile
);
3323 fputs (post
, dumpfile
);
3325 fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile
);
3328 fputs(", ", dumpfile
);
3330 fputs (");\n", dumpfile
);
3334 /* Write a C-interoperable declaration as a C prototype or extern
3338 write_interop_decl (gfc_symbol
*sym
)
3340 /* Only dump bind(c) entities. */
3341 if (!sym
->attr
.is_bind_c
)
3344 /* Don't dump our iso c module. */
3345 if (sym
->from_intmod
== INTMOD_ISO_C_BINDING
)
3348 if (sym
->attr
.flavor
== FL_VARIABLE
)
3349 write_variable (sym
);
3350 else if (sym
->attr
.flavor
== FL_DERIVED
)
3352 else if (sym
->attr
.flavor
== FL_PROCEDURE
)