2 Copyright (C) 2003-2017 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
*);
53 /* Allow dumping of an expression in the debugger. */
54 void gfc_debug_expr (gfc_expr
*);
57 gfc_debug_expr (gfc_expr
*e
)
62 fputc ('\n', dumpfile
);
66 /* Allow for dumping of a piece of code in the debugger. */
67 void gfc_debug_code (gfc_code
*c
);
70 gfc_debug_code (gfc_code
*c
)
75 fputc ('\n', dumpfile
);
79 /* Do indentation for a specific level. */
82 code_indent (int level
, gfc_st_label
*label
)
87 fprintf (dumpfile
, "%-5d ", label
->value
);
89 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
90 fputc (' ', dumpfile
);
94 /* Simple indentation at the current level. This one
95 is used to show symbols. */
100 fputc ('\n', dumpfile
);
101 code_indent (show_level
, NULL
);
105 /* Show type-specific information. */
108 show_typespec (gfc_typespec
*ts
)
110 if (ts
->type
== BT_ASSUMED
)
112 fputs ("(TYPE(*))", dumpfile
);
116 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
123 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
128 show_expr (ts
->u
.cl
->length
);
129 fprintf(dumpfile
, " %d", ts
->kind
);
133 fprintf (dumpfile
, "%d", ts
->kind
);
136 if (ts
->is_c_interop
)
137 fputs (" C_INTEROP", dumpfile
);
140 fputs (" ISO_C", dumpfile
);
143 fputs (" DEFERRED", dumpfile
);
145 fputc (')', dumpfile
);
149 /* Show an actual argument list. */
152 show_actual_arglist (gfc_actual_arglist
*a
)
154 fputc ('(', dumpfile
);
156 for (; a
; a
= a
->next
)
158 fputc ('(', dumpfile
);
160 fprintf (dumpfile
, "%s = ", a
->name
);
164 fputs ("(arg not-present)", dumpfile
);
166 fputc (')', dumpfile
);
168 fputc (' ', dumpfile
);
171 fputc (')', dumpfile
);
175 /* Show a gfc_array_spec array specification structure. */
178 show_array_spec (gfc_array_spec
*as
)
185 fputs ("()", dumpfile
);
189 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
191 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
195 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
196 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
197 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
198 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
199 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
201 gfc_internal_error ("show_array_spec(): Unhandled array shape "
204 fprintf (dumpfile
, " %s ", c
);
206 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
208 show_expr (as
->lower
[i
]);
209 fputc (' ', dumpfile
);
210 show_expr (as
->upper
[i
]);
211 fputc (' ', dumpfile
);
215 fputc (')', dumpfile
);
219 /* Show a gfc_array_ref array reference structure. */
222 show_array_ref (gfc_array_ref
* ar
)
226 fputc ('(', dumpfile
);
231 fputs ("FULL", dumpfile
);
235 for (i
= 0; i
< ar
->dimen
; i
++)
237 /* There are two types of array sections: either the
238 elements are identified by an integer array ('vector'),
239 or by an index range. In the former case we only have to
240 print the start expression which contains the vector, in
241 the latter case we have to print any of lower and upper
242 bound and the stride, if they're present. */
244 if (ar
->start
[i
] != NULL
)
245 show_expr (ar
->start
[i
]);
247 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
249 fputc (':', dumpfile
);
251 if (ar
->end
[i
] != NULL
)
252 show_expr (ar
->end
[i
]);
254 if (ar
->stride
[i
] != NULL
)
256 fputc (':', dumpfile
);
257 show_expr (ar
->stride
[i
]);
261 if (i
!= ar
->dimen
- 1)
262 fputs (" , ", dumpfile
);
267 for (i
= 0; i
< ar
->dimen
; i
++)
269 show_expr (ar
->start
[i
]);
270 if (i
!= ar
->dimen
- 1)
271 fputs (" , ", dumpfile
);
276 fputs ("UNKNOWN", dumpfile
);
280 gfc_internal_error ("show_array_ref(): Unknown array reference");
283 fputc (')', dumpfile
);
287 /* Show a list of gfc_ref structures. */
290 show_ref (gfc_ref
*p
)
292 for (; p
; p
= p
->next
)
296 show_array_ref (&p
->u
.ar
);
300 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
304 fputc ('(', dumpfile
);
305 show_expr (p
->u
.ss
.start
);
306 fputc (':', dumpfile
);
307 show_expr (p
->u
.ss
.end
);
308 fputc (')', dumpfile
);
312 gfc_internal_error ("show_ref(): Bad component code");
317 /* Display a constructor. Works recursively for array constructors. */
320 show_constructor (gfc_constructor_base base
)
323 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
325 if (c
->iterator
== NULL
)
329 fputc ('(', dumpfile
);
332 fputc (' ', dumpfile
);
333 show_expr (c
->iterator
->var
);
334 fputc ('=', dumpfile
);
335 show_expr (c
->iterator
->start
);
336 fputc (',', dumpfile
);
337 show_expr (c
->iterator
->end
);
338 fputc (',', dumpfile
);
339 show_expr (c
->iterator
->step
);
341 fputc (')', dumpfile
);
344 if (gfc_constructor_next (c
) != NULL
)
345 fputs (" , ", dumpfile
);
351 show_char_const (const gfc_char_t
*c
, int length
)
355 fputc ('\'', dumpfile
);
356 for (i
= 0; i
< length
; i
++)
359 fputs ("''", dumpfile
);
361 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
363 fputc ('\'', dumpfile
);
367 /* Show a component-call expression. */
370 show_compcall (gfc_expr
* p
)
372 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
374 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
376 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
378 show_actual_arglist (p
->value
.compcall
.actual
);
382 /* Show an expression. */
385 show_expr (gfc_expr
*p
)
392 fputs ("()", dumpfile
);
396 switch (p
->expr_type
)
399 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
404 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
405 show_constructor (p
->value
.constructor
);
406 fputc (')', dumpfile
);
410 fputs ("(/ ", dumpfile
);
411 show_constructor (p
->value
.constructor
);
412 fputs (" /)", dumpfile
);
418 fputs ("NULL()", dumpfile
);
425 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
427 if (p
->ts
.kind
!= gfc_default_integer_kind
)
428 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
432 if (p
->value
.logical
)
433 fputs (".true.", dumpfile
);
435 fputs (".false.", dumpfile
);
439 mpfr_out_str (dumpfile
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
440 if (p
->ts
.kind
!= gfc_default_real_kind
)
441 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
445 show_char_const (p
->value
.character
.string
,
446 p
->value
.character
.length
);
450 fputs ("(complex ", dumpfile
);
452 mpfr_out_str (dumpfile
, 10, 0, mpc_realref (p
->value
.complex),
454 if (p
->ts
.kind
!= gfc_default_complex_kind
)
455 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
457 fputc (' ', dumpfile
);
459 mpfr_out_str (dumpfile
, 10, 0, mpc_imagref (p
->value
.complex),
461 if (p
->ts
.kind
!= gfc_default_complex_kind
)
462 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
464 fputc (')', dumpfile
);
468 fprintf (dumpfile
, "%dH", p
->representation
.length
);
469 c
= p
->representation
.string
;
470 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
472 fputc (*c
, dumpfile
);
477 fputs ("???", dumpfile
);
481 if (p
->representation
.string
)
483 fputs (" {", dumpfile
);
484 c
= p
->representation
.string
;
485 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
487 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
488 if (i
< p
->representation
.length
- 1)
489 fputc (',', dumpfile
);
491 fputc ('}', dumpfile
);
497 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
498 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
499 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
504 fputc ('(', dumpfile
);
505 switch (p
->value
.op
.op
)
507 case INTRINSIC_UPLUS
:
508 fputs ("U+ ", dumpfile
);
510 case INTRINSIC_UMINUS
:
511 fputs ("U- ", dumpfile
);
514 fputs ("+ ", dumpfile
);
516 case INTRINSIC_MINUS
:
517 fputs ("- ", dumpfile
);
519 case INTRINSIC_TIMES
:
520 fputs ("* ", dumpfile
);
522 case INTRINSIC_DIVIDE
:
523 fputs ("/ ", dumpfile
);
525 case INTRINSIC_POWER
:
526 fputs ("** ", dumpfile
);
528 case INTRINSIC_CONCAT
:
529 fputs ("// ", dumpfile
);
532 fputs ("AND ", dumpfile
);
535 fputs ("OR ", dumpfile
);
538 fputs ("EQV ", dumpfile
);
541 fputs ("NEQV ", dumpfile
);
544 case INTRINSIC_EQ_OS
:
545 fputs ("= ", dumpfile
);
548 case INTRINSIC_NE_OS
:
549 fputs ("/= ", dumpfile
);
552 case INTRINSIC_GT_OS
:
553 fputs ("> ", dumpfile
);
556 case INTRINSIC_GE_OS
:
557 fputs (">= ", dumpfile
);
560 case INTRINSIC_LT_OS
:
561 fputs ("< ", dumpfile
);
564 case INTRINSIC_LE_OS
:
565 fputs ("<= ", dumpfile
);
568 fputs ("NOT ", dumpfile
);
570 case INTRINSIC_PARENTHESES
:
571 fputs ("parens ", dumpfile
);
576 ("show_expr(): Bad intrinsic in expression");
579 show_expr (p
->value
.op
.op1
);
583 fputc (' ', dumpfile
);
584 show_expr (p
->value
.op
.op2
);
587 fputc (')', dumpfile
);
591 if (p
->value
.function
.name
== NULL
)
593 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
594 if (gfc_is_proc_ptr_comp (p
))
596 fputc ('[', dumpfile
);
597 show_actual_arglist (p
->value
.function
.actual
);
598 fputc (']', dumpfile
);
602 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
603 if (gfc_is_proc_ptr_comp (p
))
605 fputc ('[', dumpfile
);
606 fputc ('[', dumpfile
);
607 show_actual_arglist (p
->value
.function
.actual
);
608 fputc (']', dumpfile
);
609 fputc (']', dumpfile
);
619 gfc_internal_error ("show_expr(): Don't know how to show expr");
623 /* Show symbol attributes. The flavor and intent are followed by
624 whatever single bit attributes are present. */
627 show_attr (symbol_attribute
*attr
, const char * module
)
629 if (attr
->flavor
!= FL_UNKNOWN
)
631 if (attr
->flavor
== FL_DERIVED
&& attr
->pdt_template
)
632 fputs (" (PDT template", dumpfile
);
634 fprintf (dumpfile
, "(%s ", gfc_code2string (flavors
, attr
->flavor
));
636 if (attr
->access
!= ACCESS_UNKNOWN
)
637 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
638 if (attr
->proc
!= PROC_UNKNOWN
)
639 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
640 if (attr
->save
!= SAVE_NONE
)
641 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
643 if (attr
->artificial
)
644 fputs (" ARTIFICIAL", dumpfile
);
645 if (attr
->allocatable
)
646 fputs (" ALLOCATABLE", dumpfile
);
647 if (attr
->asynchronous
)
648 fputs (" ASYNCHRONOUS", dumpfile
);
649 if (attr
->codimension
)
650 fputs (" CODIMENSION", dumpfile
);
652 fputs (" DIMENSION", dumpfile
);
653 if (attr
->contiguous
)
654 fputs (" CONTIGUOUS", dumpfile
);
656 fputs (" EXTERNAL", dumpfile
);
658 fputs (" INTRINSIC", dumpfile
);
660 fputs (" OPTIONAL", dumpfile
);
662 fputs (" KIND", dumpfile
);
664 fputs (" LEN", dumpfile
);
666 fputs (" POINTER", dumpfile
);
667 if (attr
->is_protected
)
668 fputs (" PROTECTED", dumpfile
);
670 fputs (" VALUE", dumpfile
);
672 fputs (" VOLATILE", dumpfile
);
673 if (attr
->threadprivate
)
674 fputs (" THREADPRIVATE", dumpfile
);
676 fputs (" TARGET", dumpfile
);
679 fputs (" DUMMY", dumpfile
);
680 if (attr
->intent
!= INTENT_UNKNOWN
)
681 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
685 fputs (" RESULT", dumpfile
);
687 fputs (" ENTRY", dumpfile
);
689 fputs (" BIND(C)", dumpfile
);
692 fputs (" DATA", dumpfile
);
695 fputs (" USE-ASSOC", dumpfile
);
697 fprintf (dumpfile
, "(%s)", module
);
700 if (attr
->in_namelist
)
701 fputs (" IN-NAMELIST", dumpfile
);
703 fputs (" IN-COMMON", dumpfile
);
706 fputs (" ABSTRACT", dumpfile
);
708 fputs (" FUNCTION", dumpfile
);
709 if (attr
->subroutine
)
710 fputs (" SUBROUTINE", dumpfile
);
711 if (attr
->implicit_type
)
712 fputs (" IMPLICIT-TYPE", dumpfile
);
715 fputs (" SEQUENCE", dumpfile
);
717 fputs (" ELEMENTAL", dumpfile
);
719 fputs (" PURE", dumpfile
);
721 fputs (" RECURSIVE", dumpfile
);
723 fputc (')', dumpfile
);
727 /* Show components of a derived type. */
730 show_components (gfc_symbol
*sym
)
734 for (c
= sym
->components
; c
; c
= c
->next
)
737 fprintf (dumpfile
, "(%s ", c
->name
);
738 show_typespec (&c
->ts
);
741 fputs (" kind_expr: ", dumpfile
);
742 show_expr (c
->kind_expr
);
746 fputs ("PDT parameters", dumpfile
);
747 show_actual_arglist (c
->param_list
);
750 if (c
->attr
.allocatable
)
751 fputs (" ALLOCATABLE", dumpfile
);
752 if (c
->attr
.pdt_kind
)
753 fputs (" KIND", dumpfile
);
755 fputs (" LEN", dumpfile
);
757 fputs (" POINTER", dumpfile
);
758 if (c
->attr
.proc_pointer
)
759 fputs (" PPC", dumpfile
);
760 if (c
->attr
.dimension
)
761 fputs (" DIMENSION", dumpfile
);
762 fputc (' ', dumpfile
);
763 show_array_spec (c
->as
);
765 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
766 fputc (')', dumpfile
);
768 fputc (' ', dumpfile
);
773 /* Show the f2k_derived namespace with procedure bindings. */
776 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
781 fputs ("GENERIC", dumpfile
);
784 fputs ("PROCEDURE, ", dumpfile
);
786 fputs ("NOPASS", dumpfile
);
790 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
792 fputs ("PASS", dumpfile
);
794 if (tb
->non_overridable
)
795 fputs (", NON_OVERRIDABLE", dumpfile
);
798 if (tb
->access
== ACCESS_PUBLIC
)
799 fputs (", PUBLIC", dumpfile
);
801 fputs (", PRIVATE", dumpfile
);
803 fprintf (dumpfile
, " :: %s => ", name
);
808 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
810 fputs (g
->specific_st
->name
, dumpfile
);
812 fputs (", ", dumpfile
);
816 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
820 show_typebound_symtree (gfc_symtree
* st
)
822 gcc_assert (st
->n
.tb
);
823 show_typebound_proc (st
->n
.tb
, st
->name
);
827 show_f2k_derived (gfc_namespace
* f2k
)
833 fputs ("Procedure bindings:", dumpfile
);
836 /* Finalizer bindings. */
837 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
840 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
843 /* Type-bound procedures. */
844 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
849 fputs ("Operator bindings:", dumpfile
);
852 /* User-defined operators. */
853 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
855 /* Intrinsic operators. */
856 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
858 show_typebound_proc (f2k
->tb_op
[op
],
859 gfc_op2string ((gfc_intrinsic_op
) op
));
865 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
866 show the interface. Information needed to reconstruct the list of
867 specific interfaces associated with a generic symbol is done within
871 show_symbol (gfc_symbol
*sym
)
873 gfc_formal_arglist
*formal
;
880 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
881 len
= strlen (sym
->name
);
882 for (i
=len
; i
<12; i
++)
883 fputc(' ', dumpfile
);
885 if (sym
->binding_label
)
886 fprintf (dumpfile
,"|| binding_label: '%s' ", sym
->binding_label
);
891 fputs ("type spec : ", dumpfile
);
892 show_typespec (&sym
->ts
);
895 fputs ("attributes: ", dumpfile
);
896 show_attr (&sym
->attr
, sym
->module
);
901 fputs ("value: ", dumpfile
);
902 show_expr (sym
->value
);
908 fputs ("Array spec:", dumpfile
);
909 show_array_spec (sym
->as
);
915 fputs ("Generic interfaces:", dumpfile
);
916 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
917 fprintf (dumpfile
, " %s", intr
->sym
->name
);
923 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
929 fputs ("components: ", dumpfile
);
930 show_components (sym
);
933 if (sym
->f2k_derived
)
937 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
938 show_f2k_derived (sym
->f2k_derived
);
944 fputs ("Formal arglist:", dumpfile
);
946 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
948 if (formal
->sym
!= NULL
)
949 fprintf (dumpfile
, " %s", formal
->sym
->name
);
951 fputs (" [Alt Return]", dumpfile
);
955 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
956 && sym
->attr
.proc
!= PROC_ST_FUNCTION
960 fputs ("Formal namespace", dumpfile
);
961 show_namespace (sym
->formal_ns
);
964 if (sym
->attr
.flavor
== FL_VARIABLE
968 fputs ("PDT parameters", dumpfile
);
969 show_actual_arglist (sym
->param_list
);
976 /* Show a user-defined operator. Just prints an operator
977 and the name of the associated subroutine, really. */
980 show_uop (gfc_user_op
*uop
)
985 fprintf (dumpfile
, "%s:", uop
->name
);
987 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
988 fprintf (dumpfile
, " %s", intr
->sym
->name
);
992 /* Workhorse function for traversing the user operator symtree. */
995 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
1000 (*func
) (st
->n
.uop
);
1002 traverse_uop (st
->left
, func
);
1003 traverse_uop (st
->right
, func
);
1007 /* Traverse the tree of user operator nodes. */
1010 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
1012 traverse_uop (ns
->uop_root
, func
);
1016 /* Function to display a common block. */
1019 show_common (gfc_symtree
*st
)
1024 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
1026 s
= st
->n
.common
->head
;
1029 fprintf (dumpfile
, "%s", s
->name
);
1032 fputs (", ", dumpfile
);
1034 fputc ('\n', dumpfile
);
1038 /* Worker function to display the symbol tree. */
1041 show_symtree (gfc_symtree
*st
)
1047 len
= strlen(st
->name
);
1048 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
1050 for (i
=len
; i
<12; i
++)
1051 fputc(' ', dumpfile
);
1054 fputs( " Ambiguous", dumpfile
);
1056 if (st
->n
.sym
->ns
!= gfc_current_ns
)
1057 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1058 st
->n
.sym
->ns
->proc_name
->name
);
1060 show_symbol (st
->n
.sym
);
1064 /******************* Show gfc_code structures **************/
1067 /* Show a list of code structures. Mutually recursive with
1068 show_code_node(). */
1071 show_code (int level
, gfc_code
*c
)
1073 for (; c
; c
= c
->next
)
1074 show_code_node (level
, c
);
1078 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1080 for (; n
; n
= n
->next
)
1082 if (list_type
== OMP_LIST_REDUCTION
)
1083 switch (n
->u
.reduction_op
)
1085 case OMP_REDUCTION_PLUS
:
1086 case OMP_REDUCTION_TIMES
:
1087 case OMP_REDUCTION_MINUS
:
1088 case OMP_REDUCTION_AND
:
1089 case OMP_REDUCTION_OR
:
1090 case OMP_REDUCTION_EQV
:
1091 case OMP_REDUCTION_NEQV
:
1092 fprintf (dumpfile
, "%s:",
1093 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1095 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1096 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1097 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1098 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1099 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1100 case OMP_REDUCTION_USER
:
1102 fprintf (dumpfile
, "%s:", n
->udr
->udr
->name
);
1106 else if (list_type
== OMP_LIST_DEPEND
)
1107 switch (n
->u
.depend_op
)
1109 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1110 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1111 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1112 case OMP_DEPEND_SINK_FIRST
:
1113 fputs ("sink:", dumpfile
);
1116 fprintf (dumpfile
, "%s", n
->sym
->name
);
1119 fputc ('+', dumpfile
);
1120 show_expr (n
->expr
);
1122 if (n
->next
== NULL
)
1124 else if (n
->next
->u
.depend_op
!= OMP_DEPEND_SINK
)
1126 fputs (") DEPEND(", dumpfile
);
1129 fputc (',', dumpfile
);
1135 else if (list_type
== OMP_LIST_MAP
)
1136 switch (n
->u
.map_op
)
1138 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1139 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1140 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1141 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1144 else if (list_type
== OMP_LIST_LINEAR
)
1145 switch (n
->u
.linear_op
)
1147 case OMP_LINEAR_REF
: fputs ("ref(", dumpfile
); break;
1148 case OMP_LINEAR_VAL
: fputs ("val(", dumpfile
); break;
1149 case OMP_LINEAR_UVAL
: fputs ("uval(", dumpfile
); break;
1152 fprintf (dumpfile
, "%s", n
->sym
->name
);
1153 if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear_op
!= OMP_LINEAR_DEFAULT
)
1154 fputc (')', dumpfile
);
1157 fputc (':', dumpfile
);
1158 show_expr (n
->expr
);
1161 fputc (',', dumpfile
);
1166 /* Show OpenMP or OpenACC clauses. */
1169 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1173 switch (omp_clauses
->cancel
)
1175 case OMP_CANCEL_UNKNOWN
:
1177 case OMP_CANCEL_PARALLEL
:
1178 fputs (" PARALLEL", dumpfile
);
1180 case OMP_CANCEL_SECTIONS
:
1181 fputs (" SECTIONS", dumpfile
);
1184 fputs (" DO", dumpfile
);
1186 case OMP_CANCEL_TASKGROUP
:
1187 fputs (" TASKGROUP", dumpfile
);
1190 if (omp_clauses
->if_expr
)
1192 fputs (" IF(", dumpfile
);
1193 show_expr (omp_clauses
->if_expr
);
1194 fputc (')', dumpfile
);
1196 if (omp_clauses
->final_expr
)
1198 fputs (" FINAL(", dumpfile
);
1199 show_expr (omp_clauses
->final_expr
);
1200 fputc (')', dumpfile
);
1202 if (omp_clauses
->num_threads
)
1204 fputs (" NUM_THREADS(", dumpfile
);
1205 show_expr (omp_clauses
->num_threads
);
1206 fputc (')', dumpfile
);
1208 if (omp_clauses
->async
)
1210 fputs (" ASYNC", dumpfile
);
1211 if (omp_clauses
->async_expr
)
1213 fputc ('(', dumpfile
);
1214 show_expr (omp_clauses
->async_expr
);
1215 fputc (')', dumpfile
);
1218 if (omp_clauses
->num_gangs_expr
)
1220 fputs (" NUM_GANGS(", dumpfile
);
1221 show_expr (omp_clauses
->num_gangs_expr
);
1222 fputc (')', dumpfile
);
1224 if (omp_clauses
->num_workers_expr
)
1226 fputs (" NUM_WORKERS(", dumpfile
);
1227 show_expr (omp_clauses
->num_workers_expr
);
1228 fputc (')', dumpfile
);
1230 if (omp_clauses
->vector_length_expr
)
1232 fputs (" VECTOR_LENGTH(", dumpfile
);
1233 show_expr (omp_clauses
->vector_length_expr
);
1234 fputc (')', dumpfile
);
1236 if (omp_clauses
->gang
)
1238 fputs (" GANG", dumpfile
);
1239 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1241 fputc ('(', dumpfile
);
1242 if (omp_clauses
->gang_num_expr
)
1244 fprintf (dumpfile
, "num:");
1245 show_expr (omp_clauses
->gang_num_expr
);
1247 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1248 fputc (',', dumpfile
);
1249 if (omp_clauses
->gang_static
)
1251 fprintf (dumpfile
, "static:");
1252 if (omp_clauses
->gang_static_expr
)
1253 show_expr (omp_clauses
->gang_static_expr
);
1255 fputc ('*', dumpfile
);
1257 fputc (')', dumpfile
);
1260 if (omp_clauses
->worker
)
1262 fputs (" WORKER", dumpfile
);
1263 if (omp_clauses
->worker_expr
)
1265 fputc ('(', dumpfile
);
1266 show_expr (omp_clauses
->worker_expr
);
1267 fputc (')', dumpfile
);
1270 if (omp_clauses
->vector
)
1272 fputs (" VECTOR", dumpfile
);
1273 if (omp_clauses
->vector_expr
)
1275 fputc ('(', dumpfile
);
1276 show_expr (omp_clauses
->vector_expr
);
1277 fputc (')', dumpfile
);
1280 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1283 switch (omp_clauses
->sched_kind
)
1285 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1286 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1287 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1288 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1289 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1293 fputs (" SCHEDULE (", dumpfile
);
1294 if (omp_clauses
->sched_simd
)
1296 if (omp_clauses
->sched_monotonic
1297 || omp_clauses
->sched_nonmonotonic
)
1298 fputs ("SIMD, ", dumpfile
);
1300 fputs ("SIMD: ", dumpfile
);
1302 if (omp_clauses
->sched_monotonic
)
1303 fputs ("MONOTONIC: ", dumpfile
);
1304 else if (omp_clauses
->sched_nonmonotonic
)
1305 fputs ("NONMONOTONIC: ", dumpfile
);
1306 fputs (type
, dumpfile
);
1307 if (omp_clauses
->chunk_size
)
1309 fputc (',', dumpfile
);
1310 show_expr (omp_clauses
->chunk_size
);
1312 fputc (')', dumpfile
);
1314 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1317 switch (omp_clauses
->default_sharing
)
1319 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1320 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1321 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1322 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1323 case OMP_DEFAULT_PRESENT
: type
= "PRESENT"; break;
1327 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1329 if (omp_clauses
->tile_list
)
1331 gfc_expr_list
*list
;
1332 fputs (" TILE(", dumpfile
);
1333 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1335 show_expr (list
->expr
);
1337 fputs (", ", dumpfile
);
1339 fputc (')', dumpfile
);
1341 if (omp_clauses
->wait_list
)
1343 gfc_expr_list
*list
;
1344 fputs (" WAIT(", dumpfile
);
1345 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1347 show_expr (list
->expr
);
1349 fputs (", ", dumpfile
);
1351 fputc (')', dumpfile
);
1353 if (omp_clauses
->seq
)
1354 fputs (" SEQ", dumpfile
);
1355 if (omp_clauses
->independent
)
1356 fputs (" INDEPENDENT", dumpfile
);
1357 if (omp_clauses
->ordered
)
1359 if (omp_clauses
->orderedc
)
1360 fprintf (dumpfile
, " ORDERED(%d)", omp_clauses
->orderedc
);
1362 fputs (" ORDERED", dumpfile
);
1364 if (omp_clauses
->untied
)
1365 fputs (" UNTIED", dumpfile
);
1366 if (omp_clauses
->mergeable
)
1367 fputs (" MERGEABLE", dumpfile
);
1368 if (omp_clauses
->collapse
)
1369 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1370 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1371 if (omp_clauses
->lists
[list_type
] != NULL
1372 && list_type
!= OMP_LIST_COPYPRIVATE
)
1374 const char *type
= NULL
;
1377 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1378 case OMP_LIST_DEVICE_RESIDENT
: type
= "USE_DEVICE"; break;
1379 case OMP_LIST_CACHE
: type
= ""; break;
1380 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1381 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1382 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1383 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1384 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1385 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1386 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1387 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1388 case OMP_LIST_REDUCTION
: type
= "REDUCTION"; break;
1389 case OMP_LIST_IS_DEVICE_PTR
: type
= "IS_DEVICE_PTR"; break;
1390 case OMP_LIST_USE_DEVICE_PTR
: type
= "USE_DEVICE_PTR"; break;
1391 case OMP_LIST_DEPEND
: type
= "DEPEND"; break;
1395 fprintf (dumpfile
, " %s(", type
);
1396 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1397 fputc (')', dumpfile
);
1399 if (omp_clauses
->safelen_expr
)
1401 fputs (" SAFELEN(", dumpfile
);
1402 show_expr (omp_clauses
->safelen_expr
);
1403 fputc (')', dumpfile
);
1405 if (omp_clauses
->simdlen_expr
)
1407 fputs (" SIMDLEN(", dumpfile
);
1408 show_expr (omp_clauses
->simdlen_expr
);
1409 fputc (')', dumpfile
);
1411 if (omp_clauses
->inbranch
)
1412 fputs (" INBRANCH", dumpfile
);
1413 if (omp_clauses
->notinbranch
)
1414 fputs (" NOTINBRANCH", dumpfile
);
1415 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1418 switch (omp_clauses
->proc_bind
)
1420 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1421 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1422 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1426 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1428 if (omp_clauses
->num_teams
)
1430 fputs (" NUM_TEAMS(", dumpfile
);
1431 show_expr (omp_clauses
->num_teams
);
1432 fputc (')', dumpfile
);
1434 if (omp_clauses
->device
)
1436 fputs (" DEVICE(", dumpfile
);
1437 show_expr (omp_clauses
->device
);
1438 fputc (')', dumpfile
);
1440 if (omp_clauses
->thread_limit
)
1442 fputs (" THREAD_LIMIT(", dumpfile
);
1443 show_expr (omp_clauses
->thread_limit
);
1444 fputc (')', dumpfile
);
1446 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
1448 fprintf (dumpfile
, " DIST_SCHEDULE (STATIC");
1449 if (omp_clauses
->dist_chunk_size
)
1451 fputc (',', dumpfile
);
1452 show_expr (omp_clauses
->dist_chunk_size
);
1454 fputc (')', dumpfile
);
1456 if (omp_clauses
->defaultmap
)
1457 fputs (" DEFALTMAP (TOFROM: SCALAR)", dumpfile
);
1458 if (omp_clauses
->nogroup
)
1459 fputs (" NOGROUP", dumpfile
);
1460 if (omp_clauses
->simd
)
1461 fputs (" SIMD", dumpfile
);
1462 if (omp_clauses
->threads
)
1463 fputs (" THREADS", dumpfile
);
1464 if (omp_clauses
->grainsize
)
1466 fputs (" GRAINSIZE(", dumpfile
);
1467 show_expr (omp_clauses
->grainsize
);
1468 fputc (')', dumpfile
);
1470 if (omp_clauses
->hint
)
1472 fputs (" HINT(", dumpfile
);
1473 show_expr (omp_clauses
->hint
);
1474 fputc (')', dumpfile
);
1476 if (omp_clauses
->num_tasks
)
1478 fputs (" NUM_TASKS(", dumpfile
);
1479 show_expr (omp_clauses
->num_tasks
);
1480 fputc (')', dumpfile
);
1482 if (omp_clauses
->priority
)
1484 fputs (" PRIORITY(", dumpfile
);
1485 show_expr (omp_clauses
->priority
);
1486 fputc (')', dumpfile
);
1488 for (i
= 0; i
< OMP_IF_LAST
; i
++)
1489 if (omp_clauses
->if_exprs
[i
])
1491 static const char *ifs
[] = {
1498 "TARGET ENTER DATA",
1501 fputs (" IF(", dumpfile
);
1502 fputs (ifs
[i
], dumpfile
);
1503 fputs (": ", dumpfile
);
1504 show_expr (omp_clauses
->if_exprs
[i
]);
1505 fputc (')', dumpfile
);
1507 if (omp_clauses
->depend_source
)
1508 fputs (" DEPEND(source)", dumpfile
);
1511 /* Show a single OpenMP or OpenACC directive node and everything underneath it
1515 show_omp_node (int level
, gfc_code
*c
)
1517 gfc_omp_clauses
*omp_clauses
= NULL
;
1518 const char *name
= NULL
;
1519 bool is_oacc
= false;
1523 case EXEC_OACC_PARALLEL_LOOP
:
1524 name
= "PARALLEL LOOP"; is_oacc
= true; break;
1525 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
1526 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
1527 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
1528 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
1529 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
1530 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
1531 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
1532 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
1533 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
1534 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
1535 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
1536 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
1537 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
1538 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
1539 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
1540 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
1541 case EXEC_OMP_DISTRIBUTE
: name
= "DISTRIBUTE"; break;
1542 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
1543 name
= "DISTRIBUTE PARALLEL DO"; break;
1544 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
1545 name
= "DISTRIBUTE PARALLEL DO SIMD"; break;
1546 case EXEC_OMP_DISTRIBUTE_SIMD
: name
= "DISTRIBUTE SIMD"; break;
1547 case EXEC_OMP_DO
: name
= "DO"; break;
1548 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
1549 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
1550 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
1551 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
1552 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
1553 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
1554 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
1555 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
1556 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
1557 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
1558 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
1559 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
1560 case EXEC_OMP_TARGET
: name
= "TARGET"; break;
1561 case EXEC_OMP_TARGET_DATA
: name
= "TARGET DATA"; break;
1562 case EXEC_OMP_TARGET_ENTER_DATA
: name
= "TARGET ENTER DATA"; break;
1563 case EXEC_OMP_TARGET_EXIT_DATA
: name
= "TARGET EXIT DATA"; break;
1564 case EXEC_OMP_TARGET_PARALLEL
: name
= "TARGET PARALLEL"; break;
1565 case EXEC_OMP_TARGET_PARALLEL_DO
: name
= "TARGET PARALLEL DO"; break;
1566 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
1567 name
= "TARGET_PARALLEL_DO_SIMD"; break;
1568 case EXEC_OMP_TARGET_SIMD
: name
= "TARGET SIMD"; break;
1569 case EXEC_OMP_TARGET_TEAMS
: name
= "TARGET TEAMS"; break;
1570 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
1571 name
= "TARGET TEAMS DISTRIBUTE"; break;
1572 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1573 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
1574 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1575 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1576 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
1577 name
= "TARGET TEAMS DISTRIBUTE SIMD"; break;
1578 case EXEC_OMP_TARGET_UPDATE
: name
= "TARGET UPDATE"; break;
1579 case EXEC_OMP_TASK
: name
= "TASK"; break;
1580 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
1581 case EXEC_OMP_TASKLOOP
: name
= "TASKLOOP"; break;
1582 case EXEC_OMP_TASKLOOP_SIMD
: name
= "TASKLOOP SIMD"; break;
1583 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
1584 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
1585 case EXEC_OMP_TEAMS
: name
= "TEAMS"; break;
1586 case EXEC_OMP_TEAMS_DISTRIBUTE
: name
= "TEAMS DISTRIBUTE"; break;
1587 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1588 name
= "TEAMS DISTRIBUTE PARALLEL DO"; break;
1589 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1590 name
= "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
1591 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
: name
= "TEAMS DISTRIBUTE SIMD"; break;
1592 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
1596 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
1599 case EXEC_OACC_PARALLEL_LOOP
:
1600 case EXEC_OACC_PARALLEL
:
1601 case EXEC_OACC_KERNELS_LOOP
:
1602 case EXEC_OACC_KERNELS
:
1603 case EXEC_OACC_DATA
:
1604 case EXEC_OACC_HOST_DATA
:
1605 case EXEC_OACC_LOOP
:
1606 case EXEC_OACC_UPDATE
:
1607 case EXEC_OACC_WAIT
:
1608 case EXEC_OACC_CACHE
:
1609 case EXEC_OACC_ENTER_DATA
:
1610 case EXEC_OACC_EXIT_DATA
:
1611 case EXEC_OMP_CANCEL
:
1612 case EXEC_OMP_CANCELLATION_POINT
:
1613 case EXEC_OMP_DISTRIBUTE
:
1614 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
1615 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
1616 case EXEC_OMP_DISTRIBUTE_SIMD
:
1618 case EXEC_OMP_DO_SIMD
:
1619 case EXEC_OMP_ORDERED
:
1620 case EXEC_OMP_PARALLEL
:
1621 case EXEC_OMP_PARALLEL_DO
:
1622 case EXEC_OMP_PARALLEL_DO_SIMD
:
1623 case EXEC_OMP_PARALLEL_SECTIONS
:
1624 case EXEC_OMP_PARALLEL_WORKSHARE
:
1625 case EXEC_OMP_SECTIONS
:
1627 case EXEC_OMP_SINGLE
:
1628 case EXEC_OMP_TARGET
:
1629 case EXEC_OMP_TARGET_DATA
:
1630 case EXEC_OMP_TARGET_ENTER_DATA
:
1631 case EXEC_OMP_TARGET_EXIT_DATA
:
1632 case EXEC_OMP_TARGET_PARALLEL
:
1633 case EXEC_OMP_TARGET_PARALLEL_DO
:
1634 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
1635 case EXEC_OMP_TARGET_SIMD
:
1636 case EXEC_OMP_TARGET_TEAMS
:
1637 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
1638 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1639 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1640 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
1641 case EXEC_OMP_TARGET_UPDATE
:
1643 case EXEC_OMP_TASKLOOP
:
1644 case EXEC_OMP_TASKLOOP_SIMD
:
1645 case EXEC_OMP_TEAMS
:
1646 case EXEC_OMP_TEAMS_DISTRIBUTE
:
1647 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
1648 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
1649 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
1650 case EXEC_OMP_WORKSHARE
:
1651 omp_clauses
= c
->ext
.omp_clauses
;
1653 case EXEC_OMP_CRITICAL
:
1654 omp_clauses
= c
->ext
.omp_clauses
;
1656 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
1658 case EXEC_OMP_FLUSH
:
1659 if (c
->ext
.omp_namelist
)
1661 fputs (" (", dumpfile
);
1662 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
1663 fputc (')', dumpfile
);
1666 case EXEC_OMP_BARRIER
:
1667 case EXEC_OMP_TASKWAIT
:
1668 case EXEC_OMP_TASKYIELD
:
1674 show_omp_clauses (omp_clauses
);
1675 fputc ('\n', dumpfile
);
1677 /* OpenMP and OpenACC executable directives don't have associated blocks. */
1678 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
1679 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
1680 || c
->op
== EXEC_OMP_TARGET_UPDATE
|| c
->op
== EXEC_OMP_TARGET_ENTER_DATA
1681 || c
->op
== EXEC_OMP_TARGET_EXIT_DATA
1682 || (c
->op
== EXEC_OMP_ORDERED
&& c
->block
== NULL
))
1684 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
1686 gfc_code
*d
= c
->block
;
1689 show_code (level
+ 1, d
->next
);
1690 if (d
->block
== NULL
)
1692 code_indent (level
, 0);
1693 fputs ("!$OMP SECTION\n", dumpfile
);
1698 show_code (level
+ 1, c
->block
->next
);
1699 if (c
->op
== EXEC_OMP_ATOMIC
)
1701 fputc ('\n', dumpfile
);
1702 code_indent (level
, 0);
1703 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
1704 if (omp_clauses
!= NULL
)
1706 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
1708 fputs (" COPYPRIVATE(", dumpfile
);
1709 show_omp_namelist (OMP_LIST_COPYPRIVATE
,
1710 omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
1711 fputc (')', dumpfile
);
1713 else if (omp_clauses
->nowait
)
1714 fputs (" NOWAIT", dumpfile
);
1716 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_clauses
)
1717 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
1721 /* Show a single code node and everything underneath it if necessary. */
1724 show_code_node (int level
, gfc_code
*c
)
1726 gfc_forall_iterator
*fa
;
1739 fputc ('\n', dumpfile
);
1740 code_indent (level
, c
->here
);
1747 case EXEC_END_PROCEDURE
:
1751 fputs ("NOP", dumpfile
);
1755 fputs ("CONTINUE", dumpfile
);
1759 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
1762 case EXEC_INIT_ASSIGN
:
1764 fputs ("ASSIGN ", dumpfile
);
1765 show_expr (c
->expr1
);
1766 fputc (' ', dumpfile
);
1767 show_expr (c
->expr2
);
1770 case EXEC_LABEL_ASSIGN
:
1771 fputs ("LABEL ASSIGN ", dumpfile
);
1772 show_expr (c
->expr1
);
1773 fprintf (dumpfile
, " %d", c
->label1
->value
);
1776 case EXEC_POINTER_ASSIGN
:
1777 fputs ("POINTER ASSIGN ", dumpfile
);
1778 show_expr (c
->expr1
);
1779 fputc (' ', dumpfile
);
1780 show_expr (c
->expr2
);
1784 fputs ("GOTO ", dumpfile
);
1786 fprintf (dumpfile
, "%d", c
->label1
->value
);
1789 show_expr (c
->expr1
);
1793 fputs (", (", dumpfile
);
1794 for (; d
; d
= d
->block
)
1796 code_indent (level
, d
->label1
);
1797 if (d
->block
!= NULL
)
1798 fputc (',', dumpfile
);
1800 fputc (')', dumpfile
);
1807 case EXEC_ASSIGN_CALL
:
1808 if (c
->resolved_sym
)
1809 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
1810 else if (c
->symtree
)
1811 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
1813 fputs ("CALL ?? ", dumpfile
);
1815 show_actual_arglist (c
->ext
.actual
);
1819 fputs ("CALL ", dumpfile
);
1820 show_compcall (c
->expr1
);
1824 fputs ("CALL ", dumpfile
);
1825 show_expr (c
->expr1
);
1826 show_actual_arglist (c
->ext
.actual
);
1830 fputs ("RETURN ", dumpfile
);
1832 show_expr (c
->expr1
);
1836 fputs ("PAUSE ", dumpfile
);
1838 if (c
->expr1
!= NULL
)
1839 show_expr (c
->expr1
);
1841 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1845 case EXEC_ERROR_STOP
:
1846 fputs ("ERROR ", dumpfile
);
1850 fputs ("STOP ", dumpfile
);
1852 if (c
->expr1
!= NULL
)
1853 show_expr (c
->expr1
);
1855 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
1859 case EXEC_FAIL_IMAGE
:
1860 fputs ("FAIL IMAGE ", dumpfile
);
1864 fputs ("SYNC ALL ", dumpfile
);
1865 if (c
->expr2
!= NULL
)
1867 fputs (" stat=", dumpfile
);
1868 show_expr (c
->expr2
);
1870 if (c
->expr3
!= NULL
)
1872 fputs (" errmsg=", dumpfile
);
1873 show_expr (c
->expr3
);
1877 case EXEC_SYNC_MEMORY
:
1878 fputs ("SYNC MEMORY ", dumpfile
);
1879 if (c
->expr2
!= NULL
)
1881 fputs (" stat=", dumpfile
);
1882 show_expr (c
->expr2
);
1884 if (c
->expr3
!= NULL
)
1886 fputs (" errmsg=", dumpfile
);
1887 show_expr (c
->expr3
);
1891 case EXEC_SYNC_IMAGES
:
1892 fputs ("SYNC IMAGES image-set=", dumpfile
);
1893 if (c
->expr1
!= NULL
)
1894 show_expr (c
->expr1
);
1896 fputs ("* ", dumpfile
);
1897 if (c
->expr2
!= NULL
)
1899 fputs (" stat=", dumpfile
);
1900 show_expr (c
->expr2
);
1902 if (c
->expr3
!= NULL
)
1904 fputs (" errmsg=", dumpfile
);
1905 show_expr (c
->expr3
);
1909 case EXEC_EVENT_POST
:
1910 case EXEC_EVENT_WAIT
:
1911 if (c
->op
== EXEC_EVENT_POST
)
1912 fputs ("EVENT POST ", dumpfile
);
1914 fputs ("EVENT WAIT ", dumpfile
);
1916 fputs ("event-variable=", dumpfile
);
1917 if (c
->expr1
!= NULL
)
1918 show_expr (c
->expr1
);
1919 if (c
->expr4
!= NULL
)
1921 fputs (" until_count=", dumpfile
);
1922 show_expr (c
->expr4
);
1924 if (c
->expr2
!= NULL
)
1926 fputs (" stat=", dumpfile
);
1927 show_expr (c
->expr2
);
1929 if (c
->expr3
!= NULL
)
1931 fputs (" errmsg=", dumpfile
);
1932 show_expr (c
->expr3
);
1938 if (c
->op
== EXEC_LOCK
)
1939 fputs ("LOCK ", dumpfile
);
1941 fputs ("UNLOCK ", dumpfile
);
1943 fputs ("lock-variable=", dumpfile
);
1944 if (c
->expr1
!= NULL
)
1945 show_expr (c
->expr1
);
1946 if (c
->expr4
!= NULL
)
1948 fputs (" acquired_lock=", dumpfile
);
1949 show_expr (c
->expr4
);
1951 if (c
->expr2
!= NULL
)
1953 fputs (" stat=", dumpfile
);
1954 show_expr (c
->expr2
);
1956 if (c
->expr3
!= NULL
)
1958 fputs (" errmsg=", dumpfile
);
1959 show_expr (c
->expr3
);
1963 case EXEC_ARITHMETIC_IF
:
1964 fputs ("IF ", dumpfile
);
1965 show_expr (c
->expr1
);
1966 fprintf (dumpfile
, " %d, %d, %d",
1967 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
1972 fputs ("IF ", dumpfile
);
1973 show_expr (d
->expr1
);
1976 show_code (level
+ 1, d
->next
);
1980 for (; d
; d
= d
->block
)
1982 code_indent (level
, 0);
1984 if (d
->expr1
== NULL
)
1985 fputs ("ELSE", dumpfile
);
1988 fputs ("ELSE IF ", dumpfile
);
1989 show_expr (d
->expr1
);
1993 show_code (level
+ 1, d
->next
);
1998 code_indent (level
, c
->label1
);
2002 fputs ("ENDIF", dumpfile
);
2007 const char* blocktype
;
2008 gfc_namespace
*saved_ns
;
2009 gfc_association_list
*alist
;
2011 if (c
->ext
.block
.assoc
)
2012 blocktype
= "ASSOCIATE";
2014 blocktype
= "BLOCK";
2016 fprintf (dumpfile
, "%s ", blocktype
);
2017 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
2019 fprintf (dumpfile
, " %s = ", alist
->name
);
2020 show_expr (alist
->target
);
2024 ns
= c
->ext
.block
.ns
;
2025 saved_ns
= gfc_current_ns
;
2026 gfc_current_ns
= ns
;
2027 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2028 gfc_current_ns
= saved_ns
;
2029 show_code (show_level
, ns
->code
);
2032 fprintf (dumpfile
, "END %s ", blocktype
);
2036 case EXEC_END_BLOCK
:
2037 /* Only come here when there is a label on an
2038 END ASSOCIATE construct. */
2042 case EXEC_SELECT_TYPE
:
2044 if (c
->op
== EXEC_SELECT_TYPE
)
2045 fputs ("SELECT TYPE ", dumpfile
);
2047 fputs ("SELECT CASE ", dumpfile
);
2048 show_expr (c
->expr1
);
2049 fputc ('\n', dumpfile
);
2051 for (; d
; d
= d
->block
)
2053 code_indent (level
, 0);
2055 fputs ("CASE ", dumpfile
);
2056 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
2058 fputc ('(', dumpfile
);
2059 show_expr (cp
->low
);
2060 fputc (' ', dumpfile
);
2061 show_expr (cp
->high
);
2062 fputc (')', dumpfile
);
2063 fputc (' ', dumpfile
);
2065 fputc ('\n', dumpfile
);
2067 show_code (level
+ 1, d
->next
);
2070 code_indent (level
, c
->label1
);
2071 fputs ("END SELECT", dumpfile
);
2075 fputs ("WHERE ", dumpfile
);
2078 show_expr (d
->expr1
);
2079 fputc ('\n', dumpfile
);
2081 show_code (level
+ 1, d
->next
);
2083 for (d
= d
->block
; d
; d
= d
->block
)
2085 code_indent (level
, 0);
2086 fputs ("ELSE WHERE ", dumpfile
);
2087 show_expr (d
->expr1
);
2088 fputc ('\n', dumpfile
);
2089 show_code (level
+ 1, d
->next
);
2092 code_indent (level
, 0);
2093 fputs ("END WHERE", dumpfile
);
2098 fputs ("FORALL ", dumpfile
);
2099 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2101 show_expr (fa
->var
);
2102 fputc (' ', dumpfile
);
2103 show_expr (fa
->start
);
2104 fputc (':', dumpfile
);
2105 show_expr (fa
->end
);
2106 fputc (':', dumpfile
);
2107 show_expr (fa
->stride
);
2109 if (fa
->next
!= NULL
)
2110 fputc (',', dumpfile
);
2113 if (c
->expr1
!= NULL
)
2115 fputc (',', dumpfile
);
2116 show_expr (c
->expr1
);
2118 fputc ('\n', dumpfile
);
2120 show_code (level
+ 1, c
->block
->next
);
2122 code_indent (level
, 0);
2123 fputs ("END FORALL", dumpfile
);
2127 fputs ("CRITICAL\n", dumpfile
);
2128 show_code (level
+ 1, c
->block
->next
);
2129 code_indent (level
, 0);
2130 fputs ("END CRITICAL", dumpfile
);
2134 fputs ("DO ", dumpfile
);
2136 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
2138 show_expr (c
->ext
.iterator
->var
);
2139 fputc ('=', dumpfile
);
2140 show_expr (c
->ext
.iterator
->start
);
2141 fputc (' ', dumpfile
);
2142 show_expr (c
->ext
.iterator
->end
);
2143 fputc (' ', dumpfile
);
2144 show_expr (c
->ext
.iterator
->step
);
2147 show_code (level
+ 1, c
->block
->next
);
2154 fputs ("END DO", dumpfile
);
2157 case EXEC_DO_CONCURRENT
:
2158 fputs ("DO CONCURRENT ", dumpfile
);
2159 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2161 show_expr (fa
->var
);
2162 fputc (' ', dumpfile
);
2163 show_expr (fa
->start
);
2164 fputc (':', dumpfile
);
2165 show_expr (fa
->end
);
2166 fputc (':', dumpfile
);
2167 show_expr (fa
->stride
);
2169 if (fa
->next
!= NULL
)
2170 fputc (',', dumpfile
);
2172 show_expr (c
->expr1
);
2174 show_code (level
+ 1, c
->block
->next
);
2175 code_indent (level
, c
->label1
);
2176 fputs ("END DO", dumpfile
);
2180 fputs ("DO WHILE ", dumpfile
);
2181 show_expr (c
->expr1
);
2182 fputc ('\n', dumpfile
);
2184 show_code (level
+ 1, c
->block
->next
);
2186 code_indent (level
, c
->label1
);
2187 fputs ("END DO", dumpfile
);
2191 fputs ("CYCLE", dumpfile
);
2193 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2197 fputs ("EXIT", dumpfile
);
2199 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2203 fputs ("ALLOCATE ", dumpfile
);
2206 fputs (" STAT=", dumpfile
);
2207 show_expr (c
->expr1
);
2212 fputs (" ERRMSG=", dumpfile
);
2213 show_expr (c
->expr2
);
2219 fputs (" MOLD=", dumpfile
);
2221 fputs (" SOURCE=", dumpfile
);
2222 show_expr (c
->expr3
);
2225 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2227 fputc (' ', dumpfile
);
2228 show_expr (a
->expr
);
2233 case EXEC_DEALLOCATE
:
2234 fputs ("DEALLOCATE ", dumpfile
);
2237 fputs (" STAT=", dumpfile
);
2238 show_expr (c
->expr1
);
2243 fputs (" ERRMSG=", dumpfile
);
2244 show_expr (c
->expr2
);
2247 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2249 fputc (' ', dumpfile
);
2250 show_expr (a
->expr
);
2256 fputs ("OPEN", dumpfile
);
2261 fputs (" UNIT=", dumpfile
);
2262 show_expr (open
->unit
);
2266 fputs (" IOMSG=", dumpfile
);
2267 show_expr (open
->iomsg
);
2271 fputs (" IOSTAT=", dumpfile
);
2272 show_expr (open
->iostat
);
2276 fputs (" FILE=", dumpfile
);
2277 show_expr (open
->file
);
2281 fputs (" STATUS=", dumpfile
);
2282 show_expr (open
->status
);
2286 fputs (" ACCESS=", dumpfile
);
2287 show_expr (open
->access
);
2291 fputs (" FORM=", dumpfile
);
2292 show_expr (open
->form
);
2296 fputs (" RECL=", dumpfile
);
2297 show_expr (open
->recl
);
2301 fputs (" BLANK=", dumpfile
);
2302 show_expr (open
->blank
);
2306 fputs (" POSITION=", dumpfile
);
2307 show_expr (open
->position
);
2311 fputs (" ACTION=", dumpfile
);
2312 show_expr (open
->action
);
2316 fputs (" DELIM=", dumpfile
);
2317 show_expr (open
->delim
);
2321 fputs (" PAD=", dumpfile
);
2322 show_expr (open
->pad
);
2326 fputs (" DECIMAL=", dumpfile
);
2327 show_expr (open
->decimal
);
2331 fputs (" ENCODING=", dumpfile
);
2332 show_expr (open
->encoding
);
2336 fputs (" ROUND=", dumpfile
);
2337 show_expr (open
->round
);
2341 fputs (" SIGN=", dumpfile
);
2342 show_expr (open
->sign
);
2346 fputs (" CONVERT=", dumpfile
);
2347 show_expr (open
->convert
);
2349 if (open
->asynchronous
)
2351 fputs (" ASYNCHRONOUS=", dumpfile
);
2352 show_expr (open
->asynchronous
);
2354 if (open
->err
!= NULL
)
2355 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
2360 fputs ("CLOSE", dumpfile
);
2361 close
= c
->ext
.close
;
2365 fputs (" UNIT=", dumpfile
);
2366 show_expr (close
->unit
);
2370 fputs (" IOMSG=", dumpfile
);
2371 show_expr (close
->iomsg
);
2375 fputs (" IOSTAT=", dumpfile
);
2376 show_expr (close
->iostat
);
2380 fputs (" STATUS=", dumpfile
);
2381 show_expr (close
->status
);
2383 if (close
->err
!= NULL
)
2384 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
2387 case EXEC_BACKSPACE
:
2388 fputs ("BACKSPACE", dumpfile
);
2392 fputs ("ENDFILE", dumpfile
);
2396 fputs ("REWIND", dumpfile
);
2400 fputs ("FLUSH", dumpfile
);
2403 fp
= c
->ext
.filepos
;
2407 fputs (" UNIT=", dumpfile
);
2408 show_expr (fp
->unit
);
2412 fputs (" IOMSG=", dumpfile
);
2413 show_expr (fp
->iomsg
);
2417 fputs (" IOSTAT=", dumpfile
);
2418 show_expr (fp
->iostat
);
2420 if (fp
->err
!= NULL
)
2421 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
2425 fputs ("INQUIRE", dumpfile
);
2430 fputs (" UNIT=", dumpfile
);
2431 show_expr (i
->unit
);
2435 fputs (" FILE=", dumpfile
);
2436 show_expr (i
->file
);
2441 fputs (" IOMSG=", dumpfile
);
2442 show_expr (i
->iomsg
);
2446 fputs (" IOSTAT=", dumpfile
);
2447 show_expr (i
->iostat
);
2451 fputs (" EXIST=", dumpfile
);
2452 show_expr (i
->exist
);
2456 fputs (" OPENED=", dumpfile
);
2457 show_expr (i
->opened
);
2461 fputs (" NUMBER=", dumpfile
);
2462 show_expr (i
->number
);
2466 fputs (" NAMED=", dumpfile
);
2467 show_expr (i
->named
);
2471 fputs (" NAME=", dumpfile
);
2472 show_expr (i
->name
);
2476 fputs (" ACCESS=", dumpfile
);
2477 show_expr (i
->access
);
2481 fputs (" SEQUENTIAL=", dumpfile
);
2482 show_expr (i
->sequential
);
2487 fputs (" DIRECT=", dumpfile
);
2488 show_expr (i
->direct
);
2492 fputs (" FORM=", dumpfile
);
2493 show_expr (i
->form
);
2497 fputs (" FORMATTED", dumpfile
);
2498 show_expr (i
->formatted
);
2502 fputs (" UNFORMATTED=", dumpfile
);
2503 show_expr (i
->unformatted
);
2507 fputs (" RECL=", dumpfile
);
2508 show_expr (i
->recl
);
2512 fputs (" NEXTREC=", dumpfile
);
2513 show_expr (i
->nextrec
);
2517 fputs (" BLANK=", dumpfile
);
2518 show_expr (i
->blank
);
2522 fputs (" POSITION=", dumpfile
);
2523 show_expr (i
->position
);
2527 fputs (" ACTION=", dumpfile
);
2528 show_expr (i
->action
);
2532 fputs (" READ=", dumpfile
);
2533 show_expr (i
->read
);
2537 fputs (" WRITE=", dumpfile
);
2538 show_expr (i
->write
);
2542 fputs (" READWRITE=", dumpfile
);
2543 show_expr (i
->readwrite
);
2547 fputs (" DELIM=", dumpfile
);
2548 show_expr (i
->delim
);
2552 fputs (" PAD=", dumpfile
);
2557 fputs (" CONVERT=", dumpfile
);
2558 show_expr (i
->convert
);
2560 if (i
->asynchronous
)
2562 fputs (" ASYNCHRONOUS=", dumpfile
);
2563 show_expr (i
->asynchronous
);
2567 fputs (" DECIMAL=", dumpfile
);
2568 show_expr (i
->decimal
);
2572 fputs (" ENCODING=", dumpfile
);
2573 show_expr (i
->encoding
);
2577 fputs (" PENDING=", dumpfile
);
2578 show_expr (i
->pending
);
2582 fputs (" ROUND=", dumpfile
);
2583 show_expr (i
->round
);
2587 fputs (" SIGN=", dumpfile
);
2588 show_expr (i
->sign
);
2592 fputs (" SIZE=", dumpfile
);
2593 show_expr (i
->size
);
2597 fputs (" ID=", dumpfile
);
2602 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
2606 fputs ("IOLENGTH ", dumpfile
);
2607 show_expr (c
->expr1
);
2612 fputs ("READ", dumpfile
);
2616 fputs ("WRITE", dumpfile
);
2622 fputs (" UNIT=", dumpfile
);
2623 show_expr (dt
->io_unit
);
2626 if (dt
->format_expr
)
2628 fputs (" FMT=", dumpfile
);
2629 show_expr (dt
->format_expr
);
2632 if (dt
->format_label
!= NULL
)
2633 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
2635 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
2639 fputs (" IOMSG=", dumpfile
);
2640 show_expr (dt
->iomsg
);
2644 fputs (" IOSTAT=", dumpfile
);
2645 show_expr (dt
->iostat
);
2649 fputs (" SIZE=", dumpfile
);
2650 show_expr (dt
->size
);
2654 fputs (" REC=", dumpfile
);
2655 show_expr (dt
->rec
);
2659 fputs (" ADVANCE=", dumpfile
);
2660 show_expr (dt
->advance
);
2664 fputs (" ID=", dumpfile
);
2669 fputs (" POS=", dumpfile
);
2670 show_expr (dt
->pos
);
2672 if (dt
->asynchronous
)
2674 fputs (" ASYNCHRONOUS=", dumpfile
);
2675 show_expr (dt
->asynchronous
);
2679 fputs (" BLANK=", dumpfile
);
2680 show_expr (dt
->blank
);
2684 fputs (" DECIMAL=", dumpfile
);
2685 show_expr (dt
->decimal
);
2689 fputs (" DELIM=", dumpfile
);
2690 show_expr (dt
->delim
);
2694 fputs (" PAD=", dumpfile
);
2695 show_expr (dt
->pad
);
2699 fputs (" ROUND=", dumpfile
);
2700 show_expr (dt
->round
);
2704 fputs (" SIGN=", dumpfile
);
2705 show_expr (dt
->sign
);
2709 for (c
= c
->block
->next
; c
; c
= c
->next
)
2710 show_code_node (level
+ (c
->next
!= NULL
), c
);
2714 fputs ("TRANSFER ", dumpfile
);
2715 show_expr (c
->expr1
);
2719 fputs ("DT_END", dumpfile
);
2722 if (dt
->err
!= NULL
)
2723 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
2724 if (dt
->end
!= NULL
)
2725 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
2726 if (dt
->eor
!= NULL
)
2727 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
2730 case EXEC_OACC_PARALLEL_LOOP
:
2731 case EXEC_OACC_PARALLEL
:
2732 case EXEC_OACC_KERNELS_LOOP
:
2733 case EXEC_OACC_KERNELS
:
2734 case EXEC_OACC_DATA
:
2735 case EXEC_OACC_HOST_DATA
:
2736 case EXEC_OACC_LOOP
:
2737 case EXEC_OACC_UPDATE
:
2738 case EXEC_OACC_WAIT
:
2739 case EXEC_OACC_CACHE
:
2740 case EXEC_OACC_ENTER_DATA
:
2741 case EXEC_OACC_EXIT_DATA
:
2742 case EXEC_OMP_ATOMIC
:
2743 case EXEC_OMP_CANCEL
:
2744 case EXEC_OMP_CANCELLATION_POINT
:
2745 case EXEC_OMP_BARRIER
:
2746 case EXEC_OMP_CRITICAL
:
2747 case EXEC_OMP_DISTRIBUTE
:
2748 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2749 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2750 case EXEC_OMP_DISTRIBUTE_SIMD
:
2752 case EXEC_OMP_DO_SIMD
:
2753 case EXEC_OMP_FLUSH
:
2754 case EXEC_OMP_MASTER
:
2755 case EXEC_OMP_ORDERED
:
2756 case EXEC_OMP_PARALLEL
:
2757 case EXEC_OMP_PARALLEL_DO
:
2758 case EXEC_OMP_PARALLEL_DO_SIMD
:
2759 case EXEC_OMP_PARALLEL_SECTIONS
:
2760 case EXEC_OMP_PARALLEL_WORKSHARE
:
2761 case EXEC_OMP_SECTIONS
:
2763 case EXEC_OMP_SINGLE
:
2764 case EXEC_OMP_TARGET
:
2765 case EXEC_OMP_TARGET_DATA
:
2766 case EXEC_OMP_TARGET_ENTER_DATA
:
2767 case EXEC_OMP_TARGET_EXIT_DATA
:
2768 case EXEC_OMP_TARGET_PARALLEL
:
2769 case EXEC_OMP_TARGET_PARALLEL_DO
:
2770 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2771 case EXEC_OMP_TARGET_SIMD
:
2772 case EXEC_OMP_TARGET_TEAMS
:
2773 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2774 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2775 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2776 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2777 case EXEC_OMP_TARGET_UPDATE
:
2779 case EXEC_OMP_TASKGROUP
:
2780 case EXEC_OMP_TASKLOOP
:
2781 case EXEC_OMP_TASKLOOP_SIMD
:
2782 case EXEC_OMP_TASKWAIT
:
2783 case EXEC_OMP_TASKYIELD
:
2784 case EXEC_OMP_TEAMS
:
2785 case EXEC_OMP_TEAMS_DISTRIBUTE
:
2786 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2787 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2788 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
2789 case EXEC_OMP_WORKSHARE
:
2790 show_omp_node (level
, c
);
2794 gfc_internal_error ("show_code_node(): Bad statement code");
2799 /* Show an equivalence chain. */
2802 show_equiv (gfc_equiv
*eq
)
2805 fputs ("Equivalence: ", dumpfile
);
2808 show_expr (eq
->expr
);
2811 fputs (", ", dumpfile
);
2816 /* Show a freakin' whole namespace. */
2819 show_namespace (gfc_namespace
*ns
)
2821 gfc_interface
*intr
;
2822 gfc_namespace
*save
;
2828 save
= gfc_current_ns
;
2831 fputs ("Namespace:", dumpfile
);
2837 while (i
< GFC_LETTERS
- 1
2838 && gfc_compare_types (&ns
->default_type
[i
+1],
2839 &ns
->default_type
[l
]))
2843 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
2845 fprintf (dumpfile
, " %c: ", l
+'A');
2847 show_typespec(&ns
->default_type
[l
]);
2849 } while (i
< GFC_LETTERS
);
2851 if (ns
->proc_name
!= NULL
)
2854 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
2858 gfc_current_ns
= ns
;
2859 gfc_traverse_symtree (ns
->common_root
, show_common
);
2861 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2863 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
2865 /* User operator interfaces */
2871 fprintf (dumpfile
, "Operator interfaces for %s:",
2872 gfc_op2string ((gfc_intrinsic_op
) op
));
2874 for (; intr
; intr
= intr
->next
)
2875 fprintf (dumpfile
, " %s", intr
->sym
->name
);
2878 if (ns
->uop_root
!= NULL
)
2881 fputs ("User operators:\n", dumpfile
);
2882 gfc_traverse_user_op (ns
, show_uop
);
2885 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
2888 if (ns
->oacc_declare
)
2890 struct gfc_oacc_declare
*decl
;
2891 /* Dump !$ACC DECLARE clauses. */
2892 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
2895 fprintf (dumpfile
, "!$ACC DECLARE");
2896 show_omp_clauses (decl
->clauses
);
2900 fputc ('\n', dumpfile
);
2902 fputs ("code:", dumpfile
);
2903 show_code (show_level
, ns
->code
);
2906 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
2908 fputs ("\nCONTAINS\n", dumpfile
);
2910 show_namespace (ns
);
2914 fputc ('\n', dumpfile
);
2915 gfc_current_ns
= save
;
2919 /* Main function for dumping a parse tree. */
2922 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
2925 show_namespace (ns
);
2928 /* This part writes BIND(C) definition for use in external C programs. */
2930 static void write_interop_decl (gfc_symbol
*);
2933 gfc_dump_c_prototypes (gfc_namespace
*ns
, FILE *file
)
2936 gfc_get_errors (NULL
, &error_count
);
2937 if (error_count
!= 0)
2940 gfc_traverse_ns (ns
, write_interop_decl
);
2943 enum type_return
{ T_OK
=0, T_WARN
, T_ERROR
};
2945 /* Return the name of the type for later output. Both function pointers and
2946 void pointers will be mapped to void *. */
2948 static enum type_return
2949 get_c_type_name (gfc_typespec
*ts
, gfc_array_spec
*as
, const char **pre
,
2950 const char **type_name
, bool *asterisk
, const char **post
,
2953 static char post_buffer
[40];
2954 enum type_return ret
;
2960 *type_name
= "<error>";
2961 if (ts
->type
== BT_REAL
|| ts
->type
== BT_INTEGER
)
2964 if (ts
->is_c_interop
&& ts
->interop_kind
)
2966 *type_name
= ts
->interop_kind
->name
+ 2;
2967 if (strcmp (*type_name
, "signed_char") == 0)
2968 *type_name
= "signed char";
2969 else if (strcmp (*type_name
, "size_t") == 0)
2970 *type_name
= "ssize_t";
2976 /* The user did not specify a C interop type. Let's look through
2977 the available table and use the first one, but warn. */
2979 for (i
=0; i
<ISOCBINDING_NUMBER
; i
++)
2981 if (c_interop_kinds_table
[i
].f90_type
== ts
->type
2982 && c_interop_kinds_table
[i
].value
== ts
->kind
)
2984 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
2985 if (strcmp (*type_name
, "signed_char") == 0)
2986 *type_name
= "signed char";
2987 else if (strcmp (*type_name
, "size_t") == 0)
2988 *type_name
= "ssize_t";
2996 else if (ts
->type
== BT_DERIVED
)
2998 if (ts
->u
.derived
->from_intmod
== INTMOD_ISO_C_BINDING
)
3000 if (strcmp (ts
->u
.derived
->name
, "c_ptr") == 0)
3001 *type_name
= "void";
3002 else if (strcmp (ts
->u
.derived
->name
, "c_funptr") == 0)
3004 *type_name
= "int ";
3019 *type_name
= ts
->u
.derived
->name
;
3023 if (ret
!= T_ERROR
&& as
)
3027 size_ok
= spec_size (as
, &sz
);
3028 gcc_assert (size_ok
== true);
3029 gmp_snprintf (post_buffer
, sizeof(post_buffer
), "[%Zd]", sz
);
3030 *post
= post_buffer
;
3036 /* Write out a declaration. */
3038 write_decl (gfc_typespec
*ts
, gfc_array_spec
*as
, const char *sym_name
,
3041 const char *pre
, *type_name
, *post
;
3043 enum type_return rok
;
3045 rok
= get_c_type_name (ts
, as
, &pre
, &type_name
, &asterisk
, &post
, func_ret
);
3046 gcc_assert (rok
!= T_ERROR
);
3047 fputs (type_name
, dumpfile
);
3048 fputs (pre
, dumpfile
);
3050 fputs ("*", dumpfile
);
3052 fputs (sym_name
, dumpfile
);
3053 fputs (post
, dumpfile
);
3056 fputs(" /* WARNING: non-interoperable KIND */", dumpfile
);
3059 /* Write out an interoperable type. It will be written as a typedef
3063 write_type (gfc_symbol
*sym
)
3067 fprintf (dumpfile
, "typedef struct %s {\n", sym
->name
);
3068 for (c
= sym
->components
; c
; c
= c
->next
)
3070 fputs (" ", dumpfile
);
3071 write_decl (&(c
->ts
), c
->as
, c
->name
, false);
3072 fputs (";\n", dumpfile
);
3075 fprintf (dumpfile
, "} %s;\n", sym
->name
);
3078 /* Write out a variable. */
3081 write_variable (gfc_symbol
*sym
)
3083 const char *sym_name
;
3085 gcc_assert (sym
->attr
.flavor
== FL_VARIABLE
);
3087 if (sym
->binding_label
)
3088 sym_name
= sym
->binding_label
;
3090 sym_name
= sym
->name
;
3092 fputs ("extern ", dumpfile
);
3093 write_decl (&(sym
->ts
), sym
->as
, sym_name
, false);
3094 fputs (";\n", dumpfile
);
3098 /* Write out a procedure, including its arguments. */
3100 write_proc (gfc_symbol
*sym
)
3102 const char *pre
, *type_name
, *post
;
3104 enum type_return rok
;
3105 gfc_formal_arglist
*f
;
3106 const char *sym_name
;
3107 const char *intent_in
;
3109 if (sym
->binding_label
)
3110 sym_name
= sym
->binding_label
;
3112 sym_name
= sym
->name
;
3114 if (sym
->ts
.type
== BT_UNKNOWN
)
3116 fprintf (dumpfile
, "void ");
3117 fputs (sym_name
, dumpfile
);
3120 write_decl (&(sym
->ts
), sym
->as
, sym
->name
, true);
3122 fputs (" (", dumpfile
);
3124 for (f
= sym
->formal
; f
; f
= f
->next
)
3128 rok
= get_c_type_name (&(s
->ts
), NULL
, &pre
, &type_name
, &asterisk
,
3130 gcc_assert (rok
!= T_ERROR
);
3135 if (s
->attr
.intent
== INTENT_IN
&& !s
->attr
.value
)
3136 intent_in
= "const ";
3140 fputs (intent_in
, dumpfile
);
3141 fputs (type_name
, dumpfile
);
3142 fputs (pre
, dumpfile
);
3144 fputs ("*", dumpfile
);
3146 fputs (s
->name
, dumpfile
);
3147 fputs (post
, dumpfile
);
3149 fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile
);
3151 fputs (f
->next
? ", " : ")", dumpfile
);
3153 fputs (";\n", dumpfile
);
3157 /* Write a C-interoperable declaration as a C prototype or extern
3161 write_interop_decl (gfc_symbol
*sym
)
3163 /* Only dump bind(c) entities. */
3164 if (!sym
->attr
.is_bind_c
)
3167 /* Don't dump our iso c module. */
3168 if (sym
->from_intmod
== INTMOD_ISO_C_BINDING
)
3171 if (sym
->attr
.flavor
== FL_VARIABLE
)
3172 write_variable (sym
);
3173 else if (sym
->attr
.flavor
== FL_DERIVED
)
3175 else if (sym
->attr
.flavor
== FL_PROCEDURE
)