2 Copyright (C) 2003-2016 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
);
52 /* Allow dumping of an expression in the debugger. */
53 void gfc_debug_expr (gfc_expr
*);
56 gfc_debug_expr (gfc_expr
*e
)
61 fputc ('\n', dumpfile
);
66 /* Do indentation for a specific level. */
69 code_indent (int level
, gfc_st_label
*label
)
74 fprintf (dumpfile
, "%-5d ", label
->value
);
76 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
77 fputc (' ', dumpfile
);
81 /* Simple indentation at the current level. This one
82 is used to show symbols. */
87 fputc ('\n', dumpfile
);
88 code_indent (show_level
, NULL
);
92 /* Show type-specific information. */
95 show_typespec (gfc_typespec
*ts
)
97 if (ts
->type
== BT_ASSUMED
)
99 fputs ("(TYPE(*))", dumpfile
);
103 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
110 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
115 show_expr (ts
->u
.cl
->length
);
116 fprintf(dumpfile
, " %d", ts
->kind
);
120 fprintf (dumpfile
, "%d", ts
->kind
);
124 fputc (')', dumpfile
);
128 /* Show an actual argument list. */
131 show_actual_arglist (gfc_actual_arglist
*a
)
133 fputc ('(', dumpfile
);
135 for (; a
; a
= a
->next
)
137 fputc ('(', dumpfile
);
139 fprintf (dumpfile
, "%s = ", a
->name
);
143 fputs ("(arg not-present)", dumpfile
);
145 fputc (')', dumpfile
);
147 fputc (' ', dumpfile
);
150 fputc (')', dumpfile
);
154 /* Show a gfc_array_spec array specification structure. */
157 show_array_spec (gfc_array_spec
*as
)
164 fputs ("()", dumpfile
);
168 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
170 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
174 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
175 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
176 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
177 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
178 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
180 gfc_internal_error ("show_array_spec(): Unhandled array shape "
183 fprintf (dumpfile
, " %s ", c
);
185 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
187 show_expr (as
->lower
[i
]);
188 fputc (' ', dumpfile
);
189 show_expr (as
->upper
[i
]);
190 fputc (' ', dumpfile
);
194 fputc (')', dumpfile
);
198 /* Show a gfc_array_ref array reference structure. */
201 show_array_ref (gfc_array_ref
* ar
)
205 fputc ('(', dumpfile
);
210 fputs ("FULL", dumpfile
);
214 for (i
= 0; i
< ar
->dimen
; i
++)
216 /* There are two types of array sections: either the
217 elements are identified by an integer array ('vector'),
218 or by an index range. In the former case we only have to
219 print the start expression which contains the vector, in
220 the latter case we have to print any of lower and upper
221 bound and the stride, if they're present. */
223 if (ar
->start
[i
] != NULL
)
224 show_expr (ar
->start
[i
]);
226 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
228 fputc (':', dumpfile
);
230 if (ar
->end
[i
] != NULL
)
231 show_expr (ar
->end
[i
]);
233 if (ar
->stride
[i
] != NULL
)
235 fputc (':', dumpfile
);
236 show_expr (ar
->stride
[i
]);
240 if (i
!= ar
->dimen
- 1)
241 fputs (" , ", dumpfile
);
246 for (i
= 0; i
< ar
->dimen
; i
++)
248 show_expr (ar
->start
[i
]);
249 if (i
!= ar
->dimen
- 1)
250 fputs (" , ", dumpfile
);
255 fputs ("UNKNOWN", dumpfile
);
259 gfc_internal_error ("show_array_ref(): Unknown array reference");
262 fputc (')', dumpfile
);
266 /* Show a list of gfc_ref structures. */
269 show_ref (gfc_ref
*p
)
271 for (; p
; p
= p
->next
)
275 show_array_ref (&p
->u
.ar
);
279 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
283 fputc ('(', dumpfile
);
284 show_expr (p
->u
.ss
.start
);
285 fputc (':', dumpfile
);
286 show_expr (p
->u
.ss
.end
);
287 fputc (')', dumpfile
);
291 gfc_internal_error ("show_ref(): Bad component code");
296 /* Display a constructor. Works recursively for array constructors. */
299 show_constructor (gfc_constructor_base base
)
302 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
304 if (c
->iterator
== NULL
)
308 fputc ('(', dumpfile
);
311 fputc (' ', dumpfile
);
312 show_expr (c
->iterator
->var
);
313 fputc ('=', dumpfile
);
314 show_expr (c
->iterator
->start
);
315 fputc (',', dumpfile
);
316 show_expr (c
->iterator
->end
);
317 fputc (',', dumpfile
);
318 show_expr (c
->iterator
->step
);
320 fputc (')', dumpfile
);
323 if (gfc_constructor_next (c
) != NULL
)
324 fputs (" , ", dumpfile
);
330 show_char_const (const gfc_char_t
*c
, int length
)
334 fputc ('\'', dumpfile
);
335 for (i
= 0; i
< length
; i
++)
338 fputs ("''", dumpfile
);
340 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
342 fputc ('\'', dumpfile
);
346 /* Show a component-call expression. */
349 show_compcall (gfc_expr
* p
)
351 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
353 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
355 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
357 show_actual_arglist (p
->value
.compcall
.actual
);
361 /* Show an expression. */
364 show_expr (gfc_expr
*p
)
371 fputs ("()", dumpfile
);
375 switch (p
->expr_type
)
378 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
383 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
384 show_constructor (p
->value
.constructor
);
385 fputc (')', dumpfile
);
389 fputs ("(/ ", dumpfile
);
390 show_constructor (p
->value
.constructor
);
391 fputs (" /)", dumpfile
);
397 fputs ("NULL()", dumpfile
);
404 mpz_out_str (stdout
, 10, p
->value
.integer
);
406 if (p
->ts
.kind
!= gfc_default_integer_kind
)
407 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
411 if (p
->value
.logical
)
412 fputs (".true.", dumpfile
);
414 fputs (".false.", dumpfile
);
418 mpfr_out_str (stdout
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
419 if (p
->ts
.kind
!= gfc_default_real_kind
)
420 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
424 show_char_const (p
->value
.character
.string
,
425 p
->value
.character
.length
);
429 fputs ("(complex ", dumpfile
);
431 mpfr_out_str (stdout
, 10, 0, mpc_realref (p
->value
.complex),
433 if (p
->ts
.kind
!= gfc_default_complex_kind
)
434 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
436 fputc (' ', dumpfile
);
438 mpfr_out_str (stdout
, 10, 0, mpc_imagref (p
->value
.complex),
440 if (p
->ts
.kind
!= gfc_default_complex_kind
)
441 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
443 fputc (')', dumpfile
);
447 fprintf (dumpfile
, "%dH", p
->representation
.length
);
448 c
= p
->representation
.string
;
449 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
451 fputc (*c
, dumpfile
);
456 fputs ("???", dumpfile
);
460 if (p
->representation
.string
)
462 fputs (" {", dumpfile
);
463 c
= p
->representation
.string
;
464 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
466 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
467 if (i
< p
->representation
.length
- 1)
468 fputc (',', dumpfile
);
470 fputc ('}', dumpfile
);
476 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
477 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
478 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
483 fputc ('(', dumpfile
);
484 switch (p
->value
.op
.op
)
486 case INTRINSIC_UPLUS
:
487 fputs ("U+ ", dumpfile
);
489 case INTRINSIC_UMINUS
:
490 fputs ("U- ", dumpfile
);
493 fputs ("+ ", dumpfile
);
495 case INTRINSIC_MINUS
:
496 fputs ("- ", dumpfile
);
498 case INTRINSIC_TIMES
:
499 fputs ("* ", dumpfile
);
501 case INTRINSIC_DIVIDE
:
502 fputs ("/ ", dumpfile
);
504 case INTRINSIC_POWER
:
505 fputs ("** ", dumpfile
);
507 case INTRINSIC_CONCAT
:
508 fputs ("// ", dumpfile
);
511 fputs ("AND ", dumpfile
);
514 fputs ("OR ", dumpfile
);
517 fputs ("EQV ", dumpfile
);
520 fputs ("NEQV ", dumpfile
);
523 case INTRINSIC_EQ_OS
:
524 fputs ("= ", dumpfile
);
527 case INTRINSIC_NE_OS
:
528 fputs ("/= ", dumpfile
);
531 case INTRINSIC_GT_OS
:
532 fputs ("> ", dumpfile
);
535 case INTRINSIC_GE_OS
:
536 fputs (">= ", dumpfile
);
539 case INTRINSIC_LT_OS
:
540 fputs ("< ", dumpfile
);
543 case INTRINSIC_LE_OS
:
544 fputs ("<= ", dumpfile
);
547 fputs ("NOT ", dumpfile
);
549 case INTRINSIC_PARENTHESES
:
550 fputs ("parens ", dumpfile
);
555 ("show_expr(): Bad intrinsic in expression!");
558 show_expr (p
->value
.op
.op1
);
562 fputc (' ', dumpfile
);
563 show_expr (p
->value
.op
.op2
);
566 fputc (')', dumpfile
);
570 if (p
->value
.function
.name
== NULL
)
572 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
573 if (gfc_is_proc_ptr_comp (p
))
575 fputc ('[', dumpfile
);
576 show_actual_arglist (p
->value
.function
.actual
);
577 fputc (']', dumpfile
);
581 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
582 if (gfc_is_proc_ptr_comp (p
))
584 fputc ('[', dumpfile
);
585 fputc ('[', dumpfile
);
586 show_actual_arglist (p
->value
.function
.actual
);
587 fputc (']', dumpfile
);
588 fputc (']', dumpfile
);
598 gfc_internal_error ("show_expr(): Don't know how to show expr");
602 /* Show symbol attributes. The flavor and intent are followed by
603 whatever single bit attributes are present. */
606 show_attr (symbol_attribute
*attr
, const char * module
)
608 if (attr
->flavor
!= FL_UNKNOWN
)
609 fprintf (dumpfile
, "(%s ", gfc_code2string (flavors
, attr
->flavor
));
610 if (attr
->access
!= ACCESS_UNKNOWN
)
611 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
612 if (attr
->proc
!= PROC_UNKNOWN
)
613 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
614 if (attr
->save
!= SAVE_NONE
)
615 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
617 if (attr
->artificial
)
618 fputs (" ARTIFICIAL", dumpfile
);
619 if (attr
->allocatable
)
620 fputs (" ALLOCATABLE", dumpfile
);
621 if (attr
->asynchronous
)
622 fputs (" ASYNCHRONOUS", dumpfile
);
623 if (attr
->codimension
)
624 fputs (" CODIMENSION", dumpfile
);
626 fputs (" DIMENSION", dumpfile
);
627 if (attr
->contiguous
)
628 fputs (" CONTIGUOUS", dumpfile
);
630 fputs (" EXTERNAL", dumpfile
);
632 fputs (" INTRINSIC", dumpfile
);
634 fputs (" OPTIONAL", dumpfile
);
636 fputs (" POINTER", dumpfile
);
637 if (attr
->is_protected
)
638 fputs (" PROTECTED", dumpfile
);
640 fputs (" VALUE", dumpfile
);
642 fputs (" VOLATILE", dumpfile
);
643 if (attr
->threadprivate
)
644 fputs (" THREADPRIVATE", dumpfile
);
646 fputs (" TARGET", dumpfile
);
649 fputs (" DUMMY", dumpfile
);
650 if (attr
->intent
!= INTENT_UNKNOWN
)
651 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
655 fputs (" RESULT", dumpfile
);
657 fputs (" ENTRY", dumpfile
);
659 fputs (" BIND(C)", dumpfile
);
662 fputs (" DATA", dumpfile
);
665 fputs (" USE-ASSOC", dumpfile
);
667 fprintf (dumpfile
, "(%s)", module
);
670 if (attr
->in_namelist
)
671 fputs (" IN-NAMELIST", dumpfile
);
673 fputs (" IN-COMMON", dumpfile
);
676 fputs (" ABSTRACT", dumpfile
);
678 fputs (" FUNCTION", dumpfile
);
679 if (attr
->subroutine
)
680 fputs (" SUBROUTINE", dumpfile
);
681 if (attr
->implicit_type
)
682 fputs (" IMPLICIT-TYPE", dumpfile
);
685 fputs (" SEQUENCE", dumpfile
);
687 fputs (" ELEMENTAL", dumpfile
);
689 fputs (" PURE", dumpfile
);
691 fputs (" RECURSIVE", dumpfile
);
693 fputc (')', dumpfile
);
697 /* Show components of a derived type. */
700 show_components (gfc_symbol
*sym
)
704 for (c
= sym
->components
; c
; c
= c
->next
)
706 fprintf (dumpfile
, "(%s ", c
->name
);
707 show_typespec (&c
->ts
);
708 if (c
->attr
.allocatable
)
709 fputs (" ALLOCATABLE", dumpfile
);
711 fputs (" POINTER", dumpfile
);
712 if (c
->attr
.proc_pointer
)
713 fputs (" PPC", dumpfile
);
714 if (c
->attr
.dimension
)
715 fputs (" DIMENSION", dumpfile
);
716 fputc (' ', dumpfile
);
717 show_array_spec (c
->as
);
719 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
720 fputc (')', dumpfile
);
722 fputc (' ', dumpfile
);
727 /* Show the f2k_derived namespace with procedure bindings. */
730 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
735 fputs ("GENERIC", dumpfile
);
738 fputs ("PROCEDURE, ", dumpfile
);
740 fputs ("NOPASS", dumpfile
);
744 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
746 fputs ("PASS", dumpfile
);
748 if (tb
->non_overridable
)
749 fputs (", NON_OVERRIDABLE", dumpfile
);
752 if (tb
->access
== ACCESS_PUBLIC
)
753 fputs (", PUBLIC", dumpfile
);
755 fputs (", PRIVATE", dumpfile
);
757 fprintf (dumpfile
, " :: %s => ", name
);
762 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
764 fputs (g
->specific_st
->name
, dumpfile
);
766 fputs (", ", dumpfile
);
770 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
774 show_typebound_symtree (gfc_symtree
* st
)
776 gcc_assert (st
->n
.tb
);
777 show_typebound_proc (st
->n
.tb
, st
->name
);
781 show_f2k_derived (gfc_namespace
* f2k
)
787 fputs ("Procedure bindings:", dumpfile
);
790 /* Finalizer bindings. */
791 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
794 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
797 /* Type-bound procedures. */
798 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
803 fputs ("Operator bindings:", dumpfile
);
806 /* User-defined operators. */
807 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
809 /* Intrinsic operators. */
810 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
812 show_typebound_proc (f2k
->tb_op
[op
],
813 gfc_op2string ((gfc_intrinsic_op
) op
));
819 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
820 show the interface. Information needed to reconstruct the list of
821 specific interfaces associated with a generic symbol is done within
825 show_symbol (gfc_symbol
*sym
)
827 gfc_formal_arglist
*formal
;
834 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
835 len
= strlen (sym
->name
);
836 for (i
=len
; i
<12; i
++)
837 fputc(' ', dumpfile
);
842 fputs ("type spec : ", dumpfile
);
843 show_typespec (&sym
->ts
);
846 fputs ("attributes: ", dumpfile
);
847 show_attr (&sym
->attr
, sym
->module
);
852 fputs ("value: ", dumpfile
);
853 show_expr (sym
->value
);
859 fputs ("Array spec:", dumpfile
);
860 show_array_spec (sym
->as
);
866 fputs ("Generic interfaces:", dumpfile
);
867 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
868 fprintf (dumpfile
, " %s", intr
->sym
->name
);
874 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
880 fputs ("components: ", dumpfile
);
881 show_components (sym
);
884 if (sym
->f2k_derived
)
888 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
889 show_f2k_derived (sym
->f2k_derived
);
895 fputs ("Formal arglist:", dumpfile
);
897 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
899 if (formal
->sym
!= NULL
)
900 fprintf (dumpfile
, " %s", formal
->sym
->name
);
902 fputs (" [Alt Return]", dumpfile
);
906 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
907 && sym
->attr
.proc
!= PROC_ST_FUNCTION
911 fputs ("Formal namespace", dumpfile
);
912 show_namespace (sym
->formal_ns
);
918 /* Show a user-defined operator. Just prints an operator
919 and the name of the associated subroutine, really. */
922 show_uop (gfc_user_op
*uop
)
927 fprintf (dumpfile
, "%s:", uop
->name
);
929 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
930 fprintf (dumpfile
, " %s", intr
->sym
->name
);
934 /* Workhorse function for traversing the user operator symtree. */
937 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
944 traverse_uop (st
->left
, func
);
945 traverse_uop (st
->right
, func
);
949 /* Traverse the tree of user operator nodes. */
952 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
954 traverse_uop (ns
->uop_root
, func
);
958 /* Function to display a common block. */
961 show_common (gfc_symtree
*st
)
966 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
968 s
= st
->n
.common
->head
;
971 fprintf (dumpfile
, "%s", s
->name
);
974 fputs (", ", dumpfile
);
976 fputc ('\n', dumpfile
);
980 /* Worker function to display the symbol tree. */
983 show_symtree (gfc_symtree
*st
)
989 len
= strlen(st
->name
);
990 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
992 for (i
=len
; i
<12; i
++)
993 fputc(' ', dumpfile
);
996 fputs( " Ambiguous", dumpfile
);
998 if (st
->n
.sym
->ns
!= gfc_current_ns
)
999 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1000 st
->n
.sym
->ns
->proc_name
->name
);
1002 show_symbol (st
->n
.sym
);
1006 /******************* Show gfc_code structures **************/
1009 /* Show a list of code structures. Mutually recursive with
1010 show_code_node(). */
1013 show_code (int level
, gfc_code
*c
)
1015 for (; c
; c
= c
->next
)
1016 show_code_node (level
, c
);
1020 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1022 for (; n
; n
= n
->next
)
1024 if (list_type
== OMP_LIST_REDUCTION
)
1025 switch (n
->u
.reduction_op
)
1027 case OMP_REDUCTION_PLUS
:
1028 case OMP_REDUCTION_TIMES
:
1029 case OMP_REDUCTION_MINUS
:
1030 case OMP_REDUCTION_AND
:
1031 case OMP_REDUCTION_OR
:
1032 case OMP_REDUCTION_EQV
:
1033 case OMP_REDUCTION_NEQV
:
1034 fprintf (dumpfile
, "%s:",
1035 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1037 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1038 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1039 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1040 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1041 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1042 case OMP_REDUCTION_USER
:
1044 fprintf (dumpfile
, "%s:", n
->udr
->udr
->name
);
1048 else if (list_type
== OMP_LIST_DEPEND
)
1049 switch (n
->u
.depend_op
)
1051 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1052 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1053 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1056 else if (list_type
== OMP_LIST_MAP
)
1057 switch (n
->u
.map_op
)
1059 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1060 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1061 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1062 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1065 fprintf (dumpfile
, "%s", n
->sym
->name
);
1068 fputc (':', dumpfile
);
1069 show_expr (n
->expr
);
1072 fputc (',', dumpfile
);
1077 /* Show OpenMP or OpenACC clauses. */
1080 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1084 switch (omp_clauses
->cancel
)
1086 case OMP_CANCEL_UNKNOWN
:
1088 case OMP_CANCEL_PARALLEL
:
1089 fputs (" PARALLEL", dumpfile
);
1091 case OMP_CANCEL_SECTIONS
:
1092 fputs (" SECTIONS", dumpfile
);
1095 fputs (" DO", dumpfile
);
1097 case OMP_CANCEL_TASKGROUP
:
1098 fputs (" TASKGROUP", dumpfile
);
1101 if (omp_clauses
->if_expr
)
1103 fputs (" IF(", dumpfile
);
1104 show_expr (omp_clauses
->if_expr
);
1105 fputc (')', dumpfile
);
1107 if (omp_clauses
->final_expr
)
1109 fputs (" FINAL(", dumpfile
);
1110 show_expr (omp_clauses
->final_expr
);
1111 fputc (')', dumpfile
);
1113 if (omp_clauses
->num_threads
)
1115 fputs (" NUM_THREADS(", dumpfile
);
1116 show_expr (omp_clauses
->num_threads
);
1117 fputc (')', dumpfile
);
1119 if (omp_clauses
->async
)
1121 fputs (" ASYNC", dumpfile
);
1122 if (omp_clauses
->async_expr
)
1124 fputc ('(', dumpfile
);
1125 show_expr (omp_clauses
->async_expr
);
1126 fputc (')', dumpfile
);
1129 if (omp_clauses
->num_gangs_expr
)
1131 fputs (" NUM_GANGS(", dumpfile
);
1132 show_expr (omp_clauses
->num_gangs_expr
);
1133 fputc (')', dumpfile
);
1135 if (omp_clauses
->num_workers_expr
)
1137 fputs (" NUM_WORKERS(", dumpfile
);
1138 show_expr (omp_clauses
->num_workers_expr
);
1139 fputc (')', dumpfile
);
1141 if (omp_clauses
->vector_length_expr
)
1143 fputs (" VECTOR_LENGTH(", dumpfile
);
1144 show_expr (omp_clauses
->vector_length_expr
);
1145 fputc (')', dumpfile
);
1147 if (omp_clauses
->gang
)
1149 fputs (" GANG", dumpfile
);
1150 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1152 fputc ('(', dumpfile
);
1153 if (omp_clauses
->gang_num_expr
)
1155 fprintf (dumpfile
, "num:");
1156 show_expr (omp_clauses
->gang_num_expr
);
1158 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1159 fputc (',', dumpfile
);
1160 if (omp_clauses
->gang_static
)
1162 fprintf (dumpfile
, "static:");
1163 if (omp_clauses
->gang_static_expr
)
1164 show_expr (omp_clauses
->gang_static_expr
);
1166 fputc ('*', dumpfile
);
1168 fputc (')', dumpfile
);
1171 if (omp_clauses
->worker
)
1173 fputs (" WORKER", dumpfile
);
1174 if (omp_clauses
->worker_expr
)
1176 fputc ('(', dumpfile
);
1177 show_expr (omp_clauses
->worker_expr
);
1178 fputc (')', dumpfile
);
1181 if (omp_clauses
->vector
)
1183 fputs (" VECTOR", dumpfile
);
1184 if (omp_clauses
->vector_expr
)
1186 fputc ('(', dumpfile
);
1187 show_expr (omp_clauses
->vector_expr
);
1188 fputc (')', dumpfile
);
1191 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1194 switch (omp_clauses
->sched_kind
)
1196 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1197 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1198 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1199 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1200 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1204 fprintf (dumpfile
, " SCHEDULE (%s", type
);
1205 if (omp_clauses
->chunk_size
)
1207 fputc (',', dumpfile
);
1208 show_expr (omp_clauses
->chunk_size
);
1210 fputc (')', dumpfile
);
1212 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1215 switch (omp_clauses
->default_sharing
)
1217 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1218 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1219 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1220 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1224 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1226 if (omp_clauses
->tile_list
)
1228 gfc_expr_list
*list
;
1229 fputs (" TILE(", dumpfile
);
1230 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1232 show_expr (list
->expr
);
1234 fputs (", ", dumpfile
);
1236 fputc (')', dumpfile
);
1238 if (omp_clauses
->wait_list
)
1240 gfc_expr_list
*list
;
1241 fputs (" WAIT(", dumpfile
);
1242 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1244 show_expr (list
->expr
);
1246 fputs (", ", dumpfile
);
1248 fputc (')', dumpfile
);
1250 if (omp_clauses
->seq
)
1251 fputs (" SEQ", dumpfile
);
1252 if (omp_clauses
->independent
)
1253 fputs (" INDEPENDENT", dumpfile
);
1254 if (omp_clauses
->ordered
)
1255 fputs (" ORDERED", dumpfile
);
1256 if (omp_clauses
->untied
)
1257 fputs (" UNTIED", dumpfile
);
1258 if (omp_clauses
->mergeable
)
1259 fputs (" MERGEABLE", dumpfile
);
1260 if (omp_clauses
->collapse
)
1261 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1262 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1263 if (omp_clauses
->lists
[list_type
] != NULL
1264 && list_type
!= OMP_LIST_COPYPRIVATE
)
1266 const char *type
= NULL
;
1269 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1270 case OMP_LIST_DEVICE_RESIDENT
: type
= "USE_DEVICE"; break;
1271 case OMP_LIST_CACHE
: type
= ""; break;
1272 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1273 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1274 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1275 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1276 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1277 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1278 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1279 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1280 case OMP_LIST_REDUCTION
: type
= "REDUCTION"; break;
1281 case OMP_LIST_DEPEND
: type
= "DEPEND"; break;
1285 fprintf (dumpfile
, " %s(", type
);
1286 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1287 fputc (')', dumpfile
);
1289 if (omp_clauses
->safelen_expr
)
1291 fputs (" SAFELEN(", dumpfile
);
1292 show_expr (omp_clauses
->safelen_expr
);
1293 fputc (')', dumpfile
);
1295 if (omp_clauses
->simdlen_expr
)
1297 fputs (" SIMDLEN(", dumpfile
);
1298 show_expr (omp_clauses
->simdlen_expr
);
1299 fputc (')', dumpfile
);
1301 if (omp_clauses
->inbranch
)
1302 fputs (" INBRANCH", dumpfile
);
1303 if (omp_clauses
->notinbranch
)
1304 fputs (" NOTINBRANCH", dumpfile
);
1305 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1308 switch (omp_clauses
->proc_bind
)
1310 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1311 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1312 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1316 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1318 if (omp_clauses
->num_teams
)
1320 fputs (" NUM_TEAMS(", dumpfile
);
1321 show_expr (omp_clauses
->num_teams
);
1322 fputc (')', dumpfile
);
1324 if (omp_clauses
->device
)
1326 fputs (" DEVICE(", dumpfile
);
1327 show_expr (omp_clauses
->device
);
1328 fputc (')', dumpfile
);
1330 if (omp_clauses
->thread_limit
)
1332 fputs (" THREAD_LIMIT(", dumpfile
);
1333 show_expr (omp_clauses
->thread_limit
);
1334 fputc (')', dumpfile
);
1336 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
1338 fprintf (dumpfile
, " DIST_SCHEDULE (static");
1339 if (omp_clauses
->dist_chunk_size
)
1341 fputc (',', dumpfile
);
1342 show_expr (omp_clauses
->dist_chunk_size
);
1344 fputc (')', dumpfile
);
1348 /* Show a single OpenMP or OpenACC directive node and everything underneath it
1352 show_omp_node (int level
, gfc_code
*c
)
1354 gfc_omp_clauses
*omp_clauses
= NULL
;
1355 const char *name
= NULL
;
1356 bool is_oacc
= false;
1360 case EXEC_OACC_PARALLEL_LOOP
: name
= "PARALLEL LOOP"; is_oacc
= true; break;
1361 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
1362 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
1363 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
1364 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
1365 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
1366 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
1367 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
1368 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
1369 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
1370 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
1371 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
1372 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
1373 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
1374 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
1375 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
1376 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
1377 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
1378 case EXEC_OMP_DO
: name
= "DO"; break;
1379 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
1380 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
1381 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
1382 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
1383 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
1384 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
1385 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
1386 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
1387 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
1388 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
1389 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
1390 case EXEC_OMP_TASK
: name
= "TASK"; break;
1391 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
1392 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
1393 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
1394 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
1398 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
1401 case EXEC_OACC_PARALLEL_LOOP
:
1402 case EXEC_OACC_PARALLEL
:
1403 case EXEC_OACC_KERNELS_LOOP
:
1404 case EXEC_OACC_KERNELS
:
1405 case EXEC_OACC_DATA
:
1406 case EXEC_OACC_HOST_DATA
:
1407 case EXEC_OACC_LOOP
:
1408 case EXEC_OACC_UPDATE
:
1409 case EXEC_OACC_WAIT
:
1410 case EXEC_OACC_CACHE
:
1411 case EXEC_OACC_ENTER_DATA
:
1412 case EXEC_OACC_EXIT_DATA
:
1413 case EXEC_OMP_CANCEL
:
1414 case EXEC_OMP_CANCELLATION_POINT
:
1416 case EXEC_OMP_DO_SIMD
:
1417 case EXEC_OMP_PARALLEL
:
1418 case EXEC_OMP_PARALLEL_DO
:
1419 case EXEC_OMP_PARALLEL_DO_SIMD
:
1420 case EXEC_OMP_PARALLEL_SECTIONS
:
1421 case EXEC_OMP_SECTIONS
:
1423 case EXEC_OMP_SINGLE
:
1424 case EXEC_OMP_WORKSHARE
:
1425 case EXEC_OMP_PARALLEL_WORKSHARE
:
1427 omp_clauses
= c
->ext
.omp_clauses
;
1429 case EXEC_OMP_CRITICAL
:
1430 if (c
->ext
.omp_name
)
1431 fprintf (dumpfile
, " (%s)", c
->ext
.omp_name
);
1433 case EXEC_OMP_FLUSH
:
1434 if (c
->ext
.omp_namelist
)
1436 fputs (" (", dumpfile
);
1437 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
1438 fputc (')', dumpfile
);
1441 case EXEC_OMP_BARRIER
:
1442 case EXEC_OMP_TASKWAIT
:
1443 case EXEC_OMP_TASKYIELD
:
1449 show_omp_clauses (omp_clauses
);
1450 fputc ('\n', dumpfile
);
1452 /* OpenACC executable directives don't have associated blocks. */
1453 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
1454 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
)
1456 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
1458 gfc_code
*d
= c
->block
;
1461 show_code (level
+ 1, d
->next
);
1462 if (d
->block
== NULL
)
1464 code_indent (level
, 0);
1465 fputs ("!$OMP SECTION\n", dumpfile
);
1470 show_code (level
+ 1, c
->block
->next
);
1471 if (c
->op
== EXEC_OMP_ATOMIC
)
1473 fputc ('\n', dumpfile
);
1474 code_indent (level
, 0);
1475 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
1476 if (omp_clauses
!= NULL
)
1478 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
1480 fputs (" COPYPRIVATE(", dumpfile
);
1481 show_omp_namelist (OMP_LIST_COPYPRIVATE
,
1482 omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
1483 fputc (')', dumpfile
);
1485 else if (omp_clauses
->nowait
)
1486 fputs (" NOWAIT", dumpfile
);
1488 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_name
)
1489 fprintf (dumpfile
, " (%s)", c
->ext
.omp_name
);
1493 /* Show a single code node and everything underneath it if necessary. */
1496 show_code_node (int level
, gfc_code
*c
)
1498 gfc_forall_iterator
*fa
;
1511 fputc ('\n', dumpfile
);
1512 code_indent (level
, c
->here
);
1519 case EXEC_END_PROCEDURE
:
1523 fputs ("NOP", dumpfile
);
1527 fputs ("CONTINUE", dumpfile
);
1531 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
1534 case EXEC_INIT_ASSIGN
:
1536 fputs ("ASSIGN ", dumpfile
);
1537 show_expr (c
->expr1
);
1538 fputc (' ', dumpfile
);
1539 show_expr (c
->expr2
);
1542 case EXEC_LABEL_ASSIGN
:
1543 fputs ("LABEL ASSIGN ", dumpfile
);
1544 show_expr (c
->expr1
);
1545 fprintf (dumpfile
, " %d", c
->label1
->value
);
1548 case EXEC_POINTER_ASSIGN
:
1549 fputs ("POINTER ASSIGN ", dumpfile
);
1550 show_expr (c
->expr1
);
1551 fputc (' ', dumpfile
);
1552 show_expr (c
->expr2
);
1556 fputs ("GOTO ", dumpfile
);
1558 fprintf (dumpfile
, "%d", c
->label1
->value
);
1561 show_expr (c
->expr1
);
1565 fputs (", (", dumpfile
);
1566 for (; d
; d
= d
->block
)
1568 code_indent (level
, d
->label1
);
1569 if (d
->block
!= NULL
)
1570 fputc (',', dumpfile
);
1572 fputc (')', dumpfile
);
1579 case EXEC_ASSIGN_CALL
:
1580 if (c
->resolved_sym
)
1581 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
1582 else if (c
->symtree
)
1583 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
1585 fputs ("CALL ?? ", dumpfile
);
1587 show_actual_arglist (c
->ext
.actual
);
1591 fputs ("CALL ", dumpfile
);
1592 show_compcall (c
->expr1
);
1596 fputs ("CALL ", dumpfile
);
1597 show_expr (c
->expr1
);
1598 show_actual_arglist (c
->ext
.actual
);
1602 fputs ("RETURN ", dumpfile
);
1604 show_expr (c
->expr1
);
1608 fputs ("PAUSE ", dumpfile
);
1610 if (c
->expr1
!= NULL
)
1611 show_expr (c
->expr1
);
1613 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1617 case EXEC_ERROR_STOP
:
1618 fputs ("ERROR ", dumpfile
);
1622 fputs ("STOP ", dumpfile
);
1624 if (c
->expr1
!= NULL
)
1625 show_expr (c
->expr1
);
1627 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1632 fputs ("SYNC ALL ", dumpfile
);
1633 if (c
->expr2
!= NULL
)
1635 fputs (" stat=", dumpfile
);
1636 show_expr (c
->expr2
);
1638 if (c
->expr3
!= NULL
)
1640 fputs (" errmsg=", dumpfile
);
1641 show_expr (c
->expr3
);
1645 case EXEC_SYNC_MEMORY
:
1646 fputs ("SYNC MEMORY ", dumpfile
);
1647 if (c
->expr2
!= NULL
)
1649 fputs (" stat=", dumpfile
);
1650 show_expr (c
->expr2
);
1652 if (c
->expr3
!= NULL
)
1654 fputs (" errmsg=", dumpfile
);
1655 show_expr (c
->expr3
);
1659 case EXEC_SYNC_IMAGES
:
1660 fputs ("SYNC IMAGES image-set=", dumpfile
);
1661 if (c
->expr1
!= NULL
)
1662 show_expr (c
->expr1
);
1664 fputs ("* ", dumpfile
);
1665 if (c
->expr2
!= NULL
)
1667 fputs (" stat=", dumpfile
);
1668 show_expr (c
->expr2
);
1670 if (c
->expr3
!= NULL
)
1672 fputs (" errmsg=", dumpfile
);
1673 show_expr (c
->expr3
);
1677 case EXEC_EVENT_POST
:
1678 case EXEC_EVENT_WAIT
:
1679 if (c
->op
== EXEC_EVENT_POST
)
1680 fputs ("EVENT POST ", dumpfile
);
1682 fputs ("EVENT WAIT ", dumpfile
);
1684 fputs ("event-variable=", dumpfile
);
1685 if (c
->expr1
!= NULL
)
1686 show_expr (c
->expr1
);
1687 if (c
->expr4
!= NULL
)
1689 fputs (" until_count=", dumpfile
);
1690 show_expr (c
->expr4
);
1692 if (c
->expr2
!= NULL
)
1694 fputs (" stat=", dumpfile
);
1695 show_expr (c
->expr2
);
1697 if (c
->expr3
!= NULL
)
1699 fputs (" errmsg=", dumpfile
);
1700 show_expr (c
->expr3
);
1706 if (c
->op
== EXEC_LOCK
)
1707 fputs ("LOCK ", dumpfile
);
1709 fputs ("UNLOCK ", dumpfile
);
1711 fputs ("lock-variable=", dumpfile
);
1712 if (c
->expr1
!= NULL
)
1713 show_expr (c
->expr1
);
1714 if (c
->expr4
!= NULL
)
1716 fputs (" acquired_lock=", dumpfile
);
1717 show_expr (c
->expr4
);
1719 if (c
->expr2
!= NULL
)
1721 fputs (" stat=", dumpfile
);
1722 show_expr (c
->expr2
);
1724 if (c
->expr3
!= NULL
)
1726 fputs (" errmsg=", dumpfile
);
1727 show_expr (c
->expr3
);
1731 case EXEC_ARITHMETIC_IF
:
1732 fputs ("IF ", dumpfile
);
1733 show_expr (c
->expr1
);
1734 fprintf (dumpfile
, " %d, %d, %d",
1735 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
1740 fputs ("IF ", dumpfile
);
1741 show_expr (d
->expr1
);
1744 show_code (level
+ 1, d
->next
);
1748 for (; d
; d
= d
->block
)
1750 code_indent (level
, 0);
1752 if (d
->expr1
== NULL
)
1753 fputs ("ELSE", dumpfile
);
1756 fputs ("ELSE IF ", dumpfile
);
1757 show_expr (d
->expr1
);
1761 show_code (level
+ 1, d
->next
);
1766 code_indent (level
, c
->label1
);
1770 fputs ("ENDIF", dumpfile
);
1775 const char* blocktype
;
1776 gfc_namespace
*saved_ns
;
1777 gfc_association_list
*alist
;
1779 if (c
->ext
.block
.assoc
)
1780 blocktype
= "ASSOCIATE";
1782 blocktype
= "BLOCK";
1784 fprintf (dumpfile
, "%s ", blocktype
);
1785 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
1787 fprintf (dumpfile
, " %s = ", alist
->name
);
1788 show_expr (alist
->target
);
1792 ns
= c
->ext
.block
.ns
;
1793 saved_ns
= gfc_current_ns
;
1794 gfc_current_ns
= ns
;
1795 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
1796 gfc_current_ns
= saved_ns
;
1797 show_code (show_level
, ns
->code
);
1800 fprintf (dumpfile
, "END %s ", blocktype
);
1804 case EXEC_END_BLOCK
:
1805 /* Only come here when there is a label on an
1806 END ASSOCIATE construct. */
1811 fputs ("SELECT CASE ", dumpfile
);
1812 show_expr (c
->expr1
);
1813 fputc ('\n', dumpfile
);
1815 for (; d
; d
= d
->block
)
1817 code_indent (level
, 0);
1819 fputs ("CASE ", dumpfile
);
1820 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
1822 fputc ('(', dumpfile
);
1823 show_expr (cp
->low
);
1824 fputc (' ', dumpfile
);
1825 show_expr (cp
->high
);
1826 fputc (')', dumpfile
);
1827 fputc (' ', dumpfile
);
1829 fputc ('\n', dumpfile
);
1831 show_code (level
+ 1, d
->next
);
1834 code_indent (level
, c
->label1
);
1835 fputs ("END SELECT", dumpfile
);
1839 fputs ("WHERE ", dumpfile
);
1842 show_expr (d
->expr1
);
1843 fputc ('\n', dumpfile
);
1845 show_code (level
+ 1, d
->next
);
1847 for (d
= d
->block
; d
; d
= d
->block
)
1849 code_indent (level
, 0);
1850 fputs ("ELSE WHERE ", dumpfile
);
1851 show_expr (d
->expr1
);
1852 fputc ('\n', dumpfile
);
1853 show_code (level
+ 1, d
->next
);
1856 code_indent (level
, 0);
1857 fputs ("END WHERE", dumpfile
);
1862 fputs ("FORALL ", dumpfile
);
1863 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
1865 show_expr (fa
->var
);
1866 fputc (' ', dumpfile
);
1867 show_expr (fa
->start
);
1868 fputc (':', dumpfile
);
1869 show_expr (fa
->end
);
1870 fputc (':', dumpfile
);
1871 show_expr (fa
->stride
);
1873 if (fa
->next
!= NULL
)
1874 fputc (',', dumpfile
);
1877 if (c
->expr1
!= NULL
)
1879 fputc (',', dumpfile
);
1880 show_expr (c
->expr1
);
1882 fputc ('\n', dumpfile
);
1884 show_code (level
+ 1, c
->block
->next
);
1886 code_indent (level
, 0);
1887 fputs ("END FORALL", dumpfile
);
1891 fputs ("CRITICAL\n", dumpfile
);
1892 show_code (level
+ 1, c
->block
->next
);
1893 code_indent (level
, 0);
1894 fputs ("END CRITICAL", dumpfile
);
1898 fputs ("DO ", dumpfile
);
1900 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
1902 show_expr (c
->ext
.iterator
->var
);
1903 fputc ('=', dumpfile
);
1904 show_expr (c
->ext
.iterator
->start
);
1905 fputc (' ', dumpfile
);
1906 show_expr (c
->ext
.iterator
->end
);
1907 fputc (' ', dumpfile
);
1908 show_expr (c
->ext
.iterator
->step
);
1911 show_code (level
+ 1, c
->block
->next
);
1918 fputs ("END DO", dumpfile
);
1921 case EXEC_DO_CONCURRENT
:
1922 fputs ("DO CONCURRENT ", dumpfile
);
1923 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
1925 show_expr (fa
->var
);
1926 fputc (' ', dumpfile
);
1927 show_expr (fa
->start
);
1928 fputc (':', dumpfile
);
1929 show_expr (fa
->end
);
1930 fputc (':', dumpfile
);
1931 show_expr (fa
->stride
);
1933 if (fa
->next
!= NULL
)
1934 fputc (',', dumpfile
);
1936 show_expr (c
->expr1
);
1938 show_code (level
+ 1, c
->block
->next
);
1939 code_indent (level
, c
->label1
);
1940 fputs ("END DO", dumpfile
);
1944 fputs ("DO WHILE ", dumpfile
);
1945 show_expr (c
->expr1
);
1946 fputc ('\n', dumpfile
);
1948 show_code (level
+ 1, c
->block
->next
);
1950 code_indent (level
, c
->label1
);
1951 fputs ("END DO", dumpfile
);
1955 fputs ("CYCLE", dumpfile
);
1957 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
1961 fputs ("EXIT", dumpfile
);
1963 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
1967 fputs ("ALLOCATE ", dumpfile
);
1970 fputs (" STAT=", dumpfile
);
1971 show_expr (c
->expr1
);
1976 fputs (" ERRMSG=", dumpfile
);
1977 show_expr (c
->expr2
);
1983 fputs (" MOLD=", dumpfile
);
1985 fputs (" SOURCE=", dumpfile
);
1986 show_expr (c
->expr3
);
1989 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
1991 fputc (' ', dumpfile
);
1992 show_expr (a
->expr
);
1997 case EXEC_DEALLOCATE
:
1998 fputs ("DEALLOCATE ", dumpfile
);
2001 fputs (" STAT=", dumpfile
);
2002 show_expr (c
->expr1
);
2007 fputs (" ERRMSG=", dumpfile
);
2008 show_expr (c
->expr2
);
2011 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2013 fputc (' ', dumpfile
);
2014 show_expr (a
->expr
);
2020 fputs ("OPEN", dumpfile
);
2025 fputs (" UNIT=", dumpfile
);
2026 show_expr (open
->unit
);
2030 fputs (" IOMSG=", dumpfile
);
2031 show_expr (open
->iomsg
);
2035 fputs (" IOSTAT=", dumpfile
);
2036 show_expr (open
->iostat
);
2040 fputs (" FILE=", dumpfile
);
2041 show_expr (open
->file
);
2045 fputs (" STATUS=", dumpfile
);
2046 show_expr (open
->status
);
2050 fputs (" ACCESS=", dumpfile
);
2051 show_expr (open
->access
);
2055 fputs (" FORM=", dumpfile
);
2056 show_expr (open
->form
);
2060 fputs (" RECL=", dumpfile
);
2061 show_expr (open
->recl
);
2065 fputs (" BLANK=", dumpfile
);
2066 show_expr (open
->blank
);
2070 fputs (" POSITION=", dumpfile
);
2071 show_expr (open
->position
);
2075 fputs (" ACTION=", dumpfile
);
2076 show_expr (open
->action
);
2080 fputs (" DELIM=", dumpfile
);
2081 show_expr (open
->delim
);
2085 fputs (" PAD=", dumpfile
);
2086 show_expr (open
->pad
);
2090 fputs (" DECIMAL=", dumpfile
);
2091 show_expr (open
->decimal
);
2095 fputs (" ENCODING=", dumpfile
);
2096 show_expr (open
->encoding
);
2100 fputs (" ROUND=", dumpfile
);
2101 show_expr (open
->round
);
2105 fputs (" SIGN=", dumpfile
);
2106 show_expr (open
->sign
);
2110 fputs (" CONVERT=", dumpfile
);
2111 show_expr (open
->convert
);
2113 if (open
->asynchronous
)
2115 fputs (" ASYNCHRONOUS=", dumpfile
);
2116 show_expr (open
->asynchronous
);
2118 if (open
->err
!= NULL
)
2119 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
2124 fputs ("CLOSE", dumpfile
);
2125 close
= c
->ext
.close
;
2129 fputs (" UNIT=", dumpfile
);
2130 show_expr (close
->unit
);
2134 fputs (" IOMSG=", dumpfile
);
2135 show_expr (close
->iomsg
);
2139 fputs (" IOSTAT=", dumpfile
);
2140 show_expr (close
->iostat
);
2144 fputs (" STATUS=", dumpfile
);
2145 show_expr (close
->status
);
2147 if (close
->err
!= NULL
)
2148 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
2151 case EXEC_BACKSPACE
:
2152 fputs ("BACKSPACE", dumpfile
);
2156 fputs ("ENDFILE", dumpfile
);
2160 fputs ("REWIND", dumpfile
);
2164 fputs ("FLUSH", dumpfile
);
2167 fp
= c
->ext
.filepos
;
2171 fputs (" UNIT=", dumpfile
);
2172 show_expr (fp
->unit
);
2176 fputs (" IOMSG=", dumpfile
);
2177 show_expr (fp
->iomsg
);
2181 fputs (" IOSTAT=", dumpfile
);
2182 show_expr (fp
->iostat
);
2184 if (fp
->err
!= NULL
)
2185 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
2189 fputs ("INQUIRE", dumpfile
);
2194 fputs (" UNIT=", dumpfile
);
2195 show_expr (i
->unit
);
2199 fputs (" FILE=", dumpfile
);
2200 show_expr (i
->file
);
2205 fputs (" IOMSG=", dumpfile
);
2206 show_expr (i
->iomsg
);
2210 fputs (" IOSTAT=", dumpfile
);
2211 show_expr (i
->iostat
);
2215 fputs (" EXIST=", dumpfile
);
2216 show_expr (i
->exist
);
2220 fputs (" OPENED=", dumpfile
);
2221 show_expr (i
->opened
);
2225 fputs (" NUMBER=", dumpfile
);
2226 show_expr (i
->number
);
2230 fputs (" NAMED=", dumpfile
);
2231 show_expr (i
->named
);
2235 fputs (" NAME=", dumpfile
);
2236 show_expr (i
->name
);
2240 fputs (" ACCESS=", dumpfile
);
2241 show_expr (i
->access
);
2245 fputs (" SEQUENTIAL=", dumpfile
);
2246 show_expr (i
->sequential
);
2251 fputs (" DIRECT=", dumpfile
);
2252 show_expr (i
->direct
);
2256 fputs (" FORM=", dumpfile
);
2257 show_expr (i
->form
);
2261 fputs (" FORMATTED", dumpfile
);
2262 show_expr (i
->formatted
);
2266 fputs (" UNFORMATTED=", dumpfile
);
2267 show_expr (i
->unformatted
);
2271 fputs (" RECL=", dumpfile
);
2272 show_expr (i
->recl
);
2276 fputs (" NEXTREC=", dumpfile
);
2277 show_expr (i
->nextrec
);
2281 fputs (" BLANK=", dumpfile
);
2282 show_expr (i
->blank
);
2286 fputs (" POSITION=", dumpfile
);
2287 show_expr (i
->position
);
2291 fputs (" ACTION=", dumpfile
);
2292 show_expr (i
->action
);
2296 fputs (" READ=", dumpfile
);
2297 show_expr (i
->read
);
2301 fputs (" WRITE=", dumpfile
);
2302 show_expr (i
->write
);
2306 fputs (" READWRITE=", dumpfile
);
2307 show_expr (i
->readwrite
);
2311 fputs (" DELIM=", dumpfile
);
2312 show_expr (i
->delim
);
2316 fputs (" PAD=", dumpfile
);
2321 fputs (" CONVERT=", dumpfile
);
2322 show_expr (i
->convert
);
2324 if (i
->asynchronous
)
2326 fputs (" ASYNCHRONOUS=", dumpfile
);
2327 show_expr (i
->asynchronous
);
2331 fputs (" DECIMAL=", dumpfile
);
2332 show_expr (i
->decimal
);
2336 fputs (" ENCODING=", dumpfile
);
2337 show_expr (i
->encoding
);
2341 fputs (" PENDING=", dumpfile
);
2342 show_expr (i
->pending
);
2346 fputs (" ROUND=", dumpfile
);
2347 show_expr (i
->round
);
2351 fputs (" SIGN=", dumpfile
);
2352 show_expr (i
->sign
);
2356 fputs (" SIZE=", dumpfile
);
2357 show_expr (i
->size
);
2361 fputs (" ID=", dumpfile
);
2366 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
2370 fputs ("IOLENGTH ", dumpfile
);
2371 show_expr (c
->expr1
);
2376 fputs ("READ", dumpfile
);
2380 fputs ("WRITE", dumpfile
);
2386 fputs (" UNIT=", dumpfile
);
2387 show_expr (dt
->io_unit
);
2390 if (dt
->format_expr
)
2392 fputs (" FMT=", dumpfile
);
2393 show_expr (dt
->format_expr
);
2396 if (dt
->format_label
!= NULL
)
2397 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
2399 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
2403 fputs (" IOMSG=", dumpfile
);
2404 show_expr (dt
->iomsg
);
2408 fputs (" IOSTAT=", dumpfile
);
2409 show_expr (dt
->iostat
);
2413 fputs (" SIZE=", dumpfile
);
2414 show_expr (dt
->size
);
2418 fputs (" REC=", dumpfile
);
2419 show_expr (dt
->rec
);
2423 fputs (" ADVANCE=", dumpfile
);
2424 show_expr (dt
->advance
);
2428 fputs (" ID=", dumpfile
);
2433 fputs (" POS=", dumpfile
);
2434 show_expr (dt
->pos
);
2436 if (dt
->asynchronous
)
2438 fputs (" ASYNCHRONOUS=", dumpfile
);
2439 show_expr (dt
->asynchronous
);
2443 fputs (" BLANK=", dumpfile
);
2444 show_expr (dt
->blank
);
2448 fputs (" DECIMAL=", dumpfile
);
2449 show_expr (dt
->decimal
);
2453 fputs (" DELIM=", dumpfile
);
2454 show_expr (dt
->delim
);
2458 fputs (" PAD=", dumpfile
);
2459 show_expr (dt
->pad
);
2463 fputs (" ROUND=", dumpfile
);
2464 show_expr (dt
->round
);
2468 fputs (" SIGN=", dumpfile
);
2469 show_expr (dt
->sign
);
2473 for (c
= c
->block
->next
; c
; c
= c
->next
)
2474 show_code_node (level
+ (c
->next
!= NULL
), c
);
2478 fputs ("TRANSFER ", dumpfile
);
2479 show_expr (c
->expr1
);
2483 fputs ("DT_END", dumpfile
);
2486 if (dt
->err
!= NULL
)
2487 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
2488 if (dt
->end
!= NULL
)
2489 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
2490 if (dt
->eor
!= NULL
)
2491 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
2494 case EXEC_OACC_PARALLEL_LOOP
:
2495 case EXEC_OACC_PARALLEL
:
2496 case EXEC_OACC_KERNELS_LOOP
:
2497 case EXEC_OACC_KERNELS
:
2498 case EXEC_OACC_DATA
:
2499 case EXEC_OACC_HOST_DATA
:
2500 case EXEC_OACC_LOOP
:
2501 case EXEC_OACC_UPDATE
:
2502 case EXEC_OACC_WAIT
:
2503 case EXEC_OACC_CACHE
:
2504 case EXEC_OACC_ENTER_DATA
:
2505 case EXEC_OACC_EXIT_DATA
:
2506 case EXEC_OMP_ATOMIC
:
2507 case EXEC_OMP_CANCEL
:
2508 case EXEC_OMP_CANCELLATION_POINT
:
2509 case EXEC_OMP_BARRIER
:
2510 case EXEC_OMP_CRITICAL
:
2511 case EXEC_OMP_FLUSH
:
2513 case EXEC_OMP_DO_SIMD
:
2514 case EXEC_OMP_MASTER
:
2515 case EXEC_OMP_ORDERED
:
2516 case EXEC_OMP_PARALLEL
:
2517 case EXEC_OMP_PARALLEL_DO
:
2518 case EXEC_OMP_PARALLEL_DO_SIMD
:
2519 case EXEC_OMP_PARALLEL_SECTIONS
:
2520 case EXEC_OMP_PARALLEL_WORKSHARE
:
2521 case EXEC_OMP_SECTIONS
:
2523 case EXEC_OMP_SINGLE
:
2525 case EXEC_OMP_TASKGROUP
:
2526 case EXEC_OMP_TASKWAIT
:
2527 case EXEC_OMP_TASKYIELD
:
2528 case EXEC_OMP_WORKSHARE
:
2529 show_omp_node (level
, c
);
2533 gfc_internal_error ("show_code_node(): Bad statement code");
2538 /* Show an equivalence chain. */
2541 show_equiv (gfc_equiv
*eq
)
2544 fputs ("Equivalence: ", dumpfile
);
2547 show_expr (eq
->expr
);
2550 fputs (", ", dumpfile
);
2555 /* Show a freakin' whole namespace. */
2558 show_namespace (gfc_namespace
*ns
)
2560 gfc_interface
*intr
;
2561 gfc_namespace
*save
;
2567 save
= gfc_current_ns
;
2570 fputs ("Namespace:", dumpfile
);
2576 while (i
< GFC_LETTERS
- 1
2577 && gfc_compare_types (&ns
->default_type
[i
+1],
2578 &ns
->default_type
[l
]))
2582 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
2584 fprintf (dumpfile
, " %c: ", l
+'A');
2586 show_typespec(&ns
->default_type
[l
]);
2588 } while (i
< GFC_LETTERS
);
2590 if (ns
->proc_name
!= NULL
)
2593 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
2597 gfc_current_ns
= ns
;
2598 gfc_traverse_symtree (ns
->common_root
, show_common
);
2600 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2602 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
2604 /* User operator interfaces */
2610 fprintf (dumpfile
, "Operator interfaces for %s:",
2611 gfc_op2string ((gfc_intrinsic_op
) op
));
2613 for (; intr
; intr
= intr
->next
)
2614 fprintf (dumpfile
, " %s", intr
->sym
->name
);
2617 if (ns
->uop_root
!= NULL
)
2620 fputs ("User operators:\n", dumpfile
);
2621 gfc_traverse_user_op (ns
, show_uop
);
2624 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
2627 if (ns
->oacc_declare
)
2629 struct gfc_oacc_declare
*decl
;
2630 /* Dump !$ACC DECLARE clauses. */
2631 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
2634 fprintf (dumpfile
, "!$ACC DECLARE");
2635 show_omp_clauses (decl
->clauses
);
2639 fputc ('\n', dumpfile
);
2641 fputs ("code:", dumpfile
);
2642 show_code (show_level
, ns
->code
);
2645 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
2647 fputs ("\nCONTAINS\n", dumpfile
);
2649 show_namespace (ns
);
2653 fputc ('\n', dumpfile
);
2654 gfc_current_ns
= save
;
2658 /* Main function for dumping a parse tree. */
2661 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
2664 show_namespace (ns
);