2 Copyright (C) 2003-2023 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 #include "parse.h" /* For gfc_ascii_statement. */
41 /* Keep track of indentation for symbol tree dumps. */
42 static int show_level
= 0;
44 /* The file handle we're dumping to is kept in a static variable. This
45 is not too cool, but it avoids a lot of passing it around. */
46 static FILE *dumpfile
;
48 /* Forward declaration of some of the functions. */
49 static void show_expr (gfc_expr
*p
);
50 static void show_code_node (int, gfc_code
*);
51 static void show_namespace (gfc_namespace
*ns
);
52 static void show_code (int, gfc_code
*);
53 static void show_symbol (gfc_symbol
*);
54 static void show_typespec (gfc_typespec
*);
55 static void show_ref (gfc_ref
*);
56 static void show_attr (symbol_attribute
*, const char *);
59 debug (symbol_attribute
*attr
)
63 show_attr (attr
, NULL
);
64 fputc ('\n', dumpfile
);
69 debug (gfc_formal_arglist
*formal
)
73 for (; formal
; formal
= formal
->next
)
75 fputc ('\n', dumpfile
);
76 show_symbol (formal
->sym
);
78 fputc ('\n', dumpfile
);
83 debug (symbol_attribute attr
)
96 fputc (' ', dumpfile
);
97 show_typespec (&e
->ts
);
100 fputs ("() ", dumpfile
);
102 fputc ('\n', dumpfile
);
107 debug (gfc_typespec
*ts
)
109 FILE *tmp
= dumpfile
;
112 fputc ('\n', dumpfile
);
117 debug (gfc_typespec ts
)
125 FILE *tmp
= dumpfile
;
128 fputc ('\n', dumpfile
);
133 debug (gfc_namespace
*ns
)
135 FILE *tmp
= dumpfile
;
138 fputc ('\n', dumpfile
);
143 gfc_debug_expr (gfc_expr
*e
)
145 FILE *tmp
= dumpfile
;
148 fputc ('\n', dumpfile
);
152 /* Allow for dumping of a piece of code in the debugger. */
155 gfc_debug_code (gfc_code
*c
)
157 FILE *tmp
= dumpfile
;
160 fputc ('\n', dumpfile
);
165 debug (gfc_symbol
*sym
)
167 FILE *tmp
= dumpfile
;
170 fputc ('\n', dumpfile
);
174 /* Do indentation for a specific level. */
177 code_indent (int level
, gfc_st_label
*label
)
182 fprintf (dumpfile
, "%-5d ", label
->value
);
184 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
185 fputc (' ', dumpfile
);
189 /* Simple indentation at the current level. This one
190 is used to show symbols. */
195 fputc ('\n', dumpfile
);
196 code_indent (show_level
, NULL
);
200 /* Show type-specific information. */
203 show_typespec (gfc_typespec
*ts
)
205 if (ts
->type
== BT_ASSUMED
)
207 fputs ("(TYPE(*))", dumpfile
);
211 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
218 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
223 show_expr (ts
->u
.cl
->length
);
224 fprintf(dumpfile
, " %d", ts
->kind
);
228 fprintf (dumpfile
, "%d", ts
->kind
);
231 if (ts
->is_c_interop
)
232 fputs (" C_INTEROP", dumpfile
);
235 fputs (" ISO_C", dumpfile
);
238 fputs (" DEFERRED", dumpfile
);
240 fputc (')', dumpfile
);
244 /* Show an actual argument list. */
247 show_actual_arglist (gfc_actual_arglist
*a
)
249 fputc ('(', dumpfile
);
251 for (; a
; a
= a
->next
)
253 fputc ('(', dumpfile
);
255 fprintf (dumpfile
, "%s = ", a
->name
);
259 fputs ("(arg not-present)", dumpfile
);
261 fputc (')', dumpfile
);
263 fputc (' ', dumpfile
);
266 fputc (')', dumpfile
);
270 /* Show a gfc_array_spec array specification structure. */
273 show_array_spec (gfc_array_spec
*as
)
280 fputs ("()", dumpfile
);
284 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
286 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
290 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
291 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
292 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
293 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
294 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
296 gfc_internal_error ("show_array_spec(): Unhandled array shape "
299 fprintf (dumpfile
, " %s ", c
);
301 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
303 show_expr (as
->lower
[i
]);
304 fputc (' ', dumpfile
);
305 show_expr (as
->upper
[i
]);
306 fputc (' ', dumpfile
);
310 fputc (')', dumpfile
);
314 /* Show a gfc_array_ref array reference structure. */
317 show_array_ref (gfc_array_ref
* ar
)
321 fputc ('(', dumpfile
);
326 fputs ("FULL", dumpfile
);
330 for (i
= 0; i
< ar
->dimen
; i
++)
332 /* There are two types of array sections: either the
333 elements are identified by an integer array ('vector'),
334 or by an index range. In the former case we only have to
335 print the start expression which contains the vector, in
336 the latter case we have to print any of lower and upper
337 bound and the stride, if they're present. */
339 if (ar
->start
[i
] != NULL
)
340 show_expr (ar
->start
[i
]);
342 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
344 fputc (':', dumpfile
);
346 if (ar
->end
[i
] != NULL
)
347 show_expr (ar
->end
[i
]);
349 if (ar
->stride
[i
] != NULL
)
351 fputc (':', dumpfile
);
352 show_expr (ar
->stride
[i
]);
356 if (i
!= ar
->dimen
- 1)
357 fputs (" , ", dumpfile
);
362 for (i
= 0; i
< ar
->dimen
; i
++)
364 show_expr (ar
->start
[i
]);
365 if (i
!= ar
->dimen
- 1)
366 fputs (" , ", dumpfile
);
371 fputs ("UNKNOWN", dumpfile
);
375 gfc_internal_error ("show_array_ref(): Unknown array reference");
378 fputc (')', dumpfile
);
379 if (ar
->codimen
== 0)
382 /* Show coarray part of the reference, if any. */
383 fputc ('[',dumpfile
);
384 for (i
= ar
->dimen
; i
< ar
->dimen
+ ar
->codimen
; i
++)
386 if (ar
->dimen_type
[i
] == DIMEN_STAR
)
388 else if (ar
->dimen_type
[i
] == DIMEN_THIS_IMAGE
)
389 fputs("THIS_IMAGE", dumpfile
);
392 show_expr (ar
->start
[i
]);
395 fputc(':', dumpfile
);
396 show_expr (ar
->end
[i
]);
399 if (i
!= ar
->dimen
+ ar
->codimen
- 1)
400 fputs (" , ", dumpfile
);
403 fputc (']',dumpfile
);
407 /* Show a list of gfc_ref structures. */
410 show_ref (gfc_ref
*p
)
412 for (; p
; p
= p
->next
)
416 show_array_ref (&p
->u
.ar
);
420 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
424 fputc ('(', dumpfile
);
425 show_expr (p
->u
.ss
.start
);
426 fputc (':', dumpfile
);
427 show_expr (p
->u
.ss
.end
);
428 fputc (')', dumpfile
);
435 fprintf (dumpfile
, " INQUIRY_KIND ");
438 fprintf (dumpfile
, " INQUIRY_LEN ");
441 fprintf (dumpfile
, " INQUIRY_RE ");
444 fprintf (dumpfile
, " INQUIRY_IM ");
449 gfc_internal_error ("show_ref(): Bad component code");
454 /* Display a constructor. Works recursively for array constructors. */
457 show_constructor (gfc_constructor_base base
)
460 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
462 if (c
->iterator
== NULL
)
466 fputc ('(', dumpfile
);
469 fputc (' ', dumpfile
);
470 show_expr (c
->iterator
->var
);
471 fputc ('=', dumpfile
);
472 show_expr (c
->iterator
->start
);
473 fputc (',', dumpfile
);
474 show_expr (c
->iterator
->end
);
475 fputc (',', dumpfile
);
476 show_expr (c
->iterator
->step
);
478 fputc (')', dumpfile
);
481 if (gfc_constructor_next (c
) != NULL
)
482 fputs (" , ", dumpfile
);
488 show_char_const (const gfc_char_t
*c
, gfc_charlen_t length
)
490 fputc ('\'', dumpfile
);
491 for (size_t i
= 0; i
< (size_t) length
; i
++)
494 fputs ("''", dumpfile
);
496 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
498 fputc ('\'', dumpfile
);
502 /* Show a component-call expression. */
505 show_compcall (gfc_expr
* p
)
507 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
509 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
511 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
513 show_actual_arglist (p
->value
.compcall
.actual
);
517 /* Show an expression. */
520 show_expr (gfc_expr
*p
)
527 fputs ("()", dumpfile
);
531 switch (p
->expr_type
)
534 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
539 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
540 show_constructor (p
->value
.constructor
);
541 fputc (')', dumpfile
);
545 fputs ("(/ ", dumpfile
);
546 show_constructor (p
->value
.constructor
);
547 fputs (" /)", dumpfile
);
553 fputs ("NULL()", dumpfile
);
560 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
562 if (p
->ts
.kind
!= gfc_default_integer_kind
)
563 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
567 if (p
->value
.logical
)
568 fputs (".true.", dumpfile
);
570 fputs (".false.", dumpfile
);
574 mpfr_out_str (dumpfile
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
575 if (p
->ts
.kind
!= gfc_default_real_kind
)
576 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
580 show_char_const (p
->value
.character
.string
,
581 p
->value
.character
.length
);
585 fputs ("(complex ", dumpfile
);
587 mpfr_out_str (dumpfile
, 10, 0, mpc_realref (p
->value
.complex),
589 if (p
->ts
.kind
!= gfc_default_complex_kind
)
590 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
592 fputc (' ', dumpfile
);
594 mpfr_out_str (dumpfile
, 10, 0, mpc_imagref (p
->value
.complex),
596 if (p
->ts
.kind
!= gfc_default_complex_kind
)
597 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
599 fputc (')', dumpfile
);
604 fputs ("b'", dumpfile
);
605 else if (p
->boz
.rdx
== 8)
606 fputs ("o'", dumpfile
);
608 fputs ("z'", dumpfile
);
609 fprintf (dumpfile
, "%s'", p
->boz
.str
);
613 fprintf (dumpfile
, HOST_WIDE_INT_PRINT_DEC
"H",
614 p
->representation
.length
);
615 c
= p
->representation
.string
;
616 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
618 fputc (*c
, dumpfile
);
623 fputs ("???", dumpfile
);
627 if (p
->representation
.string
)
629 fputs (" {", dumpfile
);
630 c
= p
->representation
.string
;
631 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
633 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
634 if (i
< p
->representation
.length
- 1)
635 fputc (',', dumpfile
);
637 fputc ('}', dumpfile
);
643 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
644 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
645 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
650 fputc ('(', dumpfile
);
651 switch (p
->value
.op
.op
)
653 case INTRINSIC_UPLUS
:
654 fputs ("U+ ", dumpfile
);
656 case INTRINSIC_UMINUS
:
657 fputs ("U- ", dumpfile
);
660 fputs ("+ ", dumpfile
);
662 case INTRINSIC_MINUS
:
663 fputs ("- ", dumpfile
);
665 case INTRINSIC_TIMES
:
666 fputs ("* ", dumpfile
);
668 case INTRINSIC_DIVIDE
:
669 fputs ("/ ", dumpfile
);
671 case INTRINSIC_POWER
:
672 fputs ("** ", dumpfile
);
674 case INTRINSIC_CONCAT
:
675 fputs ("// ", dumpfile
);
678 fputs ("AND ", dumpfile
);
681 fputs ("OR ", dumpfile
);
684 fputs ("EQV ", dumpfile
);
687 fputs ("NEQV ", dumpfile
);
690 case INTRINSIC_EQ_OS
:
691 fputs ("== ", dumpfile
);
694 case INTRINSIC_NE_OS
:
695 fputs ("/= ", dumpfile
);
698 case INTRINSIC_GT_OS
:
699 fputs ("> ", dumpfile
);
702 case INTRINSIC_GE_OS
:
703 fputs (">= ", dumpfile
);
706 case INTRINSIC_LT_OS
:
707 fputs ("< ", dumpfile
);
710 case INTRINSIC_LE_OS
:
711 fputs ("<= ", dumpfile
);
714 fputs ("NOT ", dumpfile
);
716 case INTRINSIC_PARENTHESES
:
717 fputs ("parens ", dumpfile
);
722 ("show_expr(): Bad intrinsic in expression");
725 show_expr (p
->value
.op
.op1
);
729 fputc (' ', dumpfile
);
730 show_expr (p
->value
.op
.op2
);
733 fputc (')', dumpfile
);
737 if (p
->value
.function
.name
== NULL
)
739 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
740 if (gfc_is_proc_ptr_comp (p
))
742 fputc ('[', dumpfile
);
743 show_actual_arglist (p
->value
.function
.actual
);
744 fputc (']', dumpfile
);
748 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
749 if (gfc_is_proc_ptr_comp (p
))
751 fputc ('[', dumpfile
);
752 fputc ('[', dumpfile
);
753 show_actual_arglist (p
->value
.function
.actual
);
754 fputc (']', dumpfile
);
755 fputc (']', dumpfile
);
765 gfc_internal_error ("show_expr(): Don't know how to show expr");
769 /* Show symbol attributes. The flavor and intent are followed by
770 whatever single bit attributes are present. */
773 show_attr (symbol_attribute
*attr
, const char * module
)
775 fputc ('(', dumpfile
);
776 if (attr
->flavor
!= FL_UNKNOWN
)
778 if (attr
->flavor
== FL_DERIVED
&& attr
->pdt_template
)
779 fputs ("PDT-TEMPLATE ", dumpfile
);
781 fprintf (dumpfile
, "%s ", gfc_code2string (flavors
, attr
->flavor
));
783 if (attr
->access
!= ACCESS_UNKNOWN
)
784 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
785 if (attr
->proc
!= PROC_UNKNOWN
)
786 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
787 if (attr
->save
!= SAVE_NONE
)
788 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
790 if (attr
->artificial
)
791 fputs (" ARTIFICIAL", dumpfile
);
792 if (attr
->allocatable
)
793 fputs (" ALLOCATABLE", dumpfile
);
794 if (attr
->asynchronous
)
795 fputs (" ASYNCHRONOUS", dumpfile
);
796 if (attr
->codimension
)
797 fputs (" CODIMENSION", dumpfile
);
799 fputs (" DIMENSION", dumpfile
);
800 if (attr
->contiguous
)
801 fputs (" CONTIGUOUS", dumpfile
);
803 fputs (" EXTERNAL", dumpfile
);
805 fputs (" INTRINSIC", dumpfile
);
807 fputs (" OPTIONAL", dumpfile
);
809 fputs (" KIND", dumpfile
);
811 fputs (" LEN", dumpfile
);
813 fputs (" POINTER", dumpfile
);
814 if (attr
->subref_array_pointer
)
815 fputs (" SUBREF-ARRAY-POINTER", dumpfile
);
816 if (attr
->cray_pointer
)
817 fputs (" CRAY-POINTER", dumpfile
);
818 if (attr
->cray_pointee
)
819 fputs (" CRAY-POINTEE", dumpfile
);
820 if (attr
->is_protected
)
821 fputs (" PROTECTED", dumpfile
);
823 fputs (" VALUE", dumpfile
);
825 fputs (" VOLATILE", dumpfile
);
826 if (attr
->threadprivate
)
827 fputs (" THREADPRIVATE", dumpfile
);
829 fputs (" TARGET", dumpfile
);
832 fputs (" DUMMY", dumpfile
);
833 if (attr
->intent
!= INTENT_UNKNOWN
)
834 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
838 fputs (" RESULT", dumpfile
);
840 fputs (" ENTRY", dumpfile
);
841 if (attr
->entry_master
)
842 fputs (" ENTRY-MASTER", dumpfile
);
843 if (attr
->mixed_entry_master
)
844 fputs (" MIXED-ENTRY-MASTER", dumpfile
);
846 fputs (" BIND(C)", dumpfile
);
849 fputs (" DATA", dumpfile
);
852 fputs (" USE-ASSOC", dumpfile
);
854 fprintf (dumpfile
, "(%s)", module
);
857 if (attr
->in_namelist
)
858 fputs (" IN-NAMELIST", dumpfile
);
860 fputs (" IN-COMMON", dumpfile
);
863 fputs (" ABSTRACT", dumpfile
);
865 fputs (" FUNCTION", dumpfile
);
866 if (attr
->subroutine
)
867 fputs (" SUBROUTINE", dumpfile
);
868 if (attr
->implicit_type
)
869 fputs (" IMPLICIT-TYPE", dumpfile
);
872 fputs (" SEQUENCE", dumpfile
);
873 if (attr
->alloc_comp
)
874 fputs (" ALLOC-COMP", dumpfile
);
875 if (attr
->pointer_comp
)
876 fputs (" POINTER-COMP", dumpfile
);
877 if (attr
->proc_pointer_comp
)
878 fputs (" PROC-POINTER-COMP", dumpfile
);
879 if (attr
->private_comp
)
880 fputs (" PRIVATE-COMP", dumpfile
);
882 fputs (" ZERO-COMP", dumpfile
);
883 if (attr
->coarray_comp
)
884 fputs (" COARRAY-COMP", dumpfile
);
886 fputs (" LOCK-COMP", dumpfile
);
887 if (attr
->event_comp
)
888 fputs (" EVENT-COMP", dumpfile
);
889 if (attr
->defined_assign_comp
)
890 fputs (" DEFINED-ASSIGNED-COMP", dumpfile
);
891 if (attr
->unlimited_polymorphic
)
892 fputs (" UNLIMITED-POLYMORPHIC", dumpfile
);
893 if (attr
->has_dtio_procs
)
894 fputs (" HAS-DTIO-PROCS", dumpfile
);
896 fputs (" CAF-TOKEN", dumpfile
);
897 if (attr
->select_type_temporary
)
898 fputs (" SELECT-TYPE-TEMPORARY", dumpfile
);
899 if (attr
->associate_var
)
900 fputs (" ASSOCIATE-VAR", dumpfile
);
902 fputs (" PDT-KIND", dumpfile
);
904 fputs (" PDT-LEN", dumpfile
);
906 fputs (" PDT-TYPE", dumpfile
);
908 fputs (" PDT-ARRAY", dumpfile
);
909 if (attr
->pdt_string
)
910 fputs (" PDT-STRING", dumpfile
);
911 if (attr
->omp_udr_artificial_var
)
912 fputs (" OMP-UDR-ARTIFICIAL-VAR", dumpfile
);
913 if (attr
->omp_declare_target
)
914 fputs (" OMP-DECLARE-TARGET", dumpfile
);
915 if (attr
->omp_declare_target_link
)
916 fputs (" OMP-DECLARE-TARGET-LINK", dumpfile
);
918 fputs (" ELEMENTAL", dumpfile
);
920 fputs (" PURE", dumpfile
);
921 if (attr
->implicit_pure
)
922 fputs (" IMPLICIT-PURE", dumpfile
);
924 fputs (" RECURSIVE", dumpfile
);
925 if (attr
->unmaskable
)
926 fputs (" UNMASKABKE", dumpfile
);
928 fputs (" MASKED", dumpfile
);
930 fputs (" CONTAINED", dumpfile
);
932 fputs (" MOD-PROC", dumpfile
);
933 if (attr
->module_procedure
)
934 fputs (" MODULE-PROCEDURE", dumpfile
);
935 if (attr
->public_used
)
936 fputs (" PUBLIC_USED", dumpfile
);
937 if (attr
->array_outer_dependency
)
938 fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile
);
940 fputs (" NORETURN", dumpfile
);
941 if (attr
->always_explicit
)
942 fputs (" ALWAYS-EXPLICIT", dumpfile
);
943 if (attr
->is_main_program
)
944 fputs (" IS-MAIN-PROGRAM", dumpfile
);
945 if (attr
->oacc_routine_nohost
)
946 fputs (" OACC-ROUTINE-NOHOST", dumpfile
);
948 /* FIXME: Still missing are oacc_routine_lop and ext_attr. */
949 fputc (')', dumpfile
);
953 /* Show components of a derived type. */
956 show_components (gfc_symbol
*sym
)
960 for (c
= sym
->components
; c
; c
= c
->next
)
963 fprintf (dumpfile
, "(%s ", c
->name
);
964 show_typespec (&c
->ts
);
967 fputs (" kind_expr: ", dumpfile
);
968 show_expr (c
->kind_expr
);
972 fputs ("PDT parameters", dumpfile
);
973 show_actual_arglist (c
->param_list
);
976 if (c
->attr
.allocatable
)
977 fputs (" ALLOCATABLE", dumpfile
);
978 if (c
->attr
.pdt_kind
)
979 fputs (" KIND", dumpfile
);
981 fputs (" LEN", dumpfile
);
983 fputs (" POINTER", dumpfile
);
984 if (c
->attr
.proc_pointer
)
985 fputs (" PPC", dumpfile
);
986 if (c
->attr
.dimension
)
987 fputs (" DIMENSION", dumpfile
);
988 fputc (' ', dumpfile
);
989 show_array_spec (c
->as
);
991 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
992 fputc (')', dumpfile
);
994 fputc (' ', dumpfile
);
999 /* Show the f2k_derived namespace with procedure bindings. */
1002 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
1007 fputs ("GENERIC", dumpfile
);
1010 fputs ("PROCEDURE, ", dumpfile
);
1012 fputs ("NOPASS", dumpfile
);
1016 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
1018 fputs ("PASS", dumpfile
);
1020 if (tb
->non_overridable
)
1021 fputs (", NON_OVERRIDABLE", dumpfile
);
1024 if (tb
->access
== ACCESS_PUBLIC
)
1025 fputs (", PUBLIC", dumpfile
);
1027 fputs (", PRIVATE", dumpfile
);
1029 fprintf (dumpfile
, " :: %s => ", name
);
1034 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
1036 fputs (g
->specific_st
->name
, dumpfile
);
1038 fputs (", ", dumpfile
);
1042 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
1046 show_typebound_symtree (gfc_symtree
* st
)
1048 gcc_assert (st
->n
.tb
);
1049 show_typebound_proc (st
->n
.tb
, st
->name
);
1053 show_f2k_derived (gfc_namespace
* f2k
)
1059 fputs ("Procedure bindings:", dumpfile
);
1062 /* Finalizer bindings. */
1063 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
1066 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
1069 /* Type-bound procedures. */
1070 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
1075 fputs ("Operator bindings:", dumpfile
);
1078 /* User-defined operators. */
1079 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
1081 /* Intrinsic operators. */
1082 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
1084 show_typebound_proc (f2k
->tb_op
[op
],
1085 gfc_op2string ((gfc_intrinsic_op
) op
));
1091 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
1092 show the interface. Information needed to reconstruct the list of
1093 specific interfaces associated with a generic symbol is done within
1097 show_symbol (gfc_symbol
*sym
)
1099 gfc_formal_arglist
*formal
;
1100 gfc_interface
*intr
;
1106 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
1107 len
= strlen (sym
->name
);
1108 for (i
=len
; i
<12; i
++)
1109 fputc(' ', dumpfile
);
1111 if (sym
->binding_label
)
1112 fprintf (dumpfile
,"|| binding_label: '%s' ", sym
->binding_label
);
1117 fputs ("type spec : ", dumpfile
);
1118 show_typespec (&sym
->ts
);
1121 fputs ("attributes: ", dumpfile
);
1122 show_attr (&sym
->attr
, sym
->module
);
1127 fputs ("value: ", dumpfile
);
1128 show_expr (sym
->value
);
1131 if (sym
->ts
.type
!= BT_CLASS
&& sym
->as
)
1134 fputs ("Array spec:", dumpfile
);
1135 show_array_spec (sym
->as
);
1137 else if (sym
->ts
.type
== BT_CLASS
&& CLASS_DATA (sym
)->as
)
1140 fputs ("Array spec:", dumpfile
);
1141 show_array_spec (CLASS_DATA (sym
)->as
);
1147 fputs ("Generic interfaces:", dumpfile
);
1148 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
1149 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1155 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
1158 if (sym
->components
)
1161 fputs ("components: ", dumpfile
);
1162 show_components (sym
);
1165 if (sym
->f2k_derived
)
1168 if (sym
->hash_value
)
1169 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
1170 show_f2k_derived (sym
->f2k_derived
);
1176 fputs ("Formal arglist:", dumpfile
);
1178 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
1180 if (formal
->sym
!= NULL
)
1181 fprintf (dumpfile
, " %s", formal
->sym
->name
);
1183 fputs (" [Alt Return]", dumpfile
);
1187 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
1188 && sym
->attr
.proc
!= PROC_ST_FUNCTION
1189 && !sym
->attr
.entry
)
1192 fputs ("Formal namespace", dumpfile
);
1193 show_namespace (sym
->formal_ns
);
1196 if (sym
->attr
.flavor
== FL_VARIABLE
1200 fputs ("PDT parameters", dumpfile
);
1201 show_actual_arglist (sym
->param_list
);
1204 if (sym
->attr
.flavor
== FL_NAMELIST
)
1208 fputs ("variables : ", dumpfile
);
1209 for (nl
= sym
->namelist
; nl
; nl
= nl
->next
)
1210 fprintf (dumpfile
, " %s",nl
->sym
->name
);
1217 /* Show a user-defined operator. Just prints an operator
1218 and the name of the associated subroutine, really. */
1221 show_uop (gfc_user_op
*uop
)
1223 gfc_interface
*intr
;
1226 fprintf (dumpfile
, "%s:", uop
->name
);
1228 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
1229 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1233 /* Workhorse function for traversing the user operator symtree. */
1236 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
1241 (*func
) (st
->n
.uop
);
1243 traverse_uop (st
->left
, func
);
1244 traverse_uop (st
->right
, func
);
1248 /* Traverse the tree of user operator nodes. */
1251 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
1253 traverse_uop (ns
->uop_root
, func
);
1257 /* Function to display a common block. */
1260 show_common (gfc_symtree
*st
)
1265 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
1267 s
= st
->n
.common
->head
;
1270 fprintf (dumpfile
, "%s", s
->name
);
1273 fputs (", ", dumpfile
);
1275 fputc ('\n', dumpfile
);
1279 /* Worker function to display the symbol tree. */
1282 show_symtree (gfc_symtree
*st
)
1288 len
= strlen(st
->name
);
1289 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
1291 for (i
=len
; i
<12; i
++)
1292 fputc(' ', dumpfile
);
1295 fputs( " Ambiguous", dumpfile
);
1297 if (st
->n
.sym
->ns
!= gfc_current_ns
)
1298 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1299 st
->n
.sym
->ns
->proc_name
->name
);
1301 show_symbol (st
->n
.sym
);
1305 /******************* Show gfc_code structures **************/
1308 /* Show a list of code structures. Mutually recursive with
1309 show_code_node(). */
1312 show_code (int level
, gfc_code
*c
)
1314 for (; c
; c
= c
->next
)
1315 show_code_node (level
, c
);
1319 show_iterator (gfc_namespace
*ns
)
1321 for (gfc_symbol
*sym
= ns
->omp_affinity_iterators
; sym
; sym
= sym
->tlink
)
1324 if (sym
!= ns
->omp_affinity_iterators
)
1325 fputc (',', dumpfile
);
1326 fputs (sym
->name
, dumpfile
);
1327 fputc ('=', dumpfile
);
1328 c
= gfc_constructor_first (sym
->value
->value
.constructor
);
1329 show_expr (c
->expr
);
1330 fputc (':', dumpfile
);
1331 c
= gfc_constructor_next (c
);
1332 show_expr (c
->expr
);
1333 c
= gfc_constructor_next (c
);
1336 fputc (':', dumpfile
);
1337 show_expr (c
->expr
);
1343 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1345 gfc_namespace
*ns_iter
= NULL
, *ns_curr
= gfc_current_ns
;
1346 gfc_omp_namelist
*n2
= n
;
1347 for (; n
; n
= n
->next
)
1349 gfc_current_ns
= ns_curr
;
1350 if (list_type
== OMP_LIST_AFFINITY
|| list_type
== OMP_LIST_DEPEND
)
1352 gfc_current_ns
= n
->u2
.ns
? n
->u2
.ns
: ns_curr
;
1353 if (n
->u2
.ns
!= ns_iter
)
1357 fputs (") ", dumpfile
);
1358 if (list_type
== OMP_LIST_AFFINITY
)
1359 fputs ("AFFINITY (", dumpfile
);
1360 else if (n
->u
.depend_doacross_op
== OMP_DOACROSS_SINK_FIRST
)
1361 fputs ("DOACROSS (", dumpfile
);
1363 fputs ("DEPEND (", dumpfile
);
1367 fputs ("ITERATOR(", dumpfile
);
1368 show_iterator (n
->u2
.ns
);
1369 fputc (')', dumpfile
);
1370 fputc (list_type
== OMP_LIST_AFFINITY
? ':' : ',', dumpfile
);
1375 if (list_type
== OMP_LIST_ALLOCATE
)
1377 if (n
->u2
.allocator
)
1379 fputs ("allocator(", dumpfile
);
1380 show_expr (n
->u2
.allocator
);
1381 fputc (')', dumpfile
);
1383 if (n
->expr
&& n
->u
.align
)
1384 fputc (',', dumpfile
);
1387 fputs ("align(", dumpfile
);
1388 show_expr (n
->u
.align
);
1389 fputc (')', dumpfile
);
1391 if (n
->u2
.allocator
|| n
->u
.align
)
1392 fputc (':', dumpfile
);
1394 show_expr (n
->expr
);
1396 fputs (n
->sym
->name
, dumpfile
);
1398 fputs (") ALLOCATE(", dumpfile
);
1401 if (list_type
== OMP_LIST_REDUCTION
)
1402 switch (n
->u
.reduction_op
)
1404 case OMP_REDUCTION_PLUS
:
1405 case OMP_REDUCTION_TIMES
:
1406 case OMP_REDUCTION_MINUS
:
1407 case OMP_REDUCTION_AND
:
1408 case OMP_REDUCTION_OR
:
1409 case OMP_REDUCTION_EQV
:
1410 case OMP_REDUCTION_NEQV
:
1411 fprintf (dumpfile
, "%s:",
1412 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1414 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1415 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1416 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1417 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1418 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1419 case OMP_REDUCTION_USER
:
1421 fprintf (dumpfile
, "%s:", n
->u2
.udr
->udr
->name
);
1425 else if (list_type
== OMP_LIST_DEPEND
)
1426 switch (n
->u
.depend_doacross_op
)
1428 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1429 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1430 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1431 case OMP_DEPEND_INOUTSET
: fputs ("inoutset:", dumpfile
); break;
1432 case OMP_DEPEND_DEPOBJ
: fputs ("depobj:", dumpfile
); break;
1433 case OMP_DEPEND_MUTEXINOUTSET
:
1434 fputs ("mutexinoutset:", dumpfile
);
1436 case OMP_DEPEND_SINK_FIRST
:
1437 case OMP_DOACROSS_SINK_FIRST
:
1438 fputs ("sink:", dumpfile
);
1442 fputs ("omp_cur_iteration", dumpfile
);
1444 fprintf (dumpfile
, "%s", n
->sym
->name
);
1447 fputc ('+', dumpfile
);
1448 show_expr (n
->expr
);
1450 if (n
->next
== NULL
)
1452 else if (n
->next
->u
.depend_doacross_op
!= OMP_DOACROSS_SINK
)
1454 if (n
->next
->u
.depend_doacross_op
1455 == OMP_DOACROSS_SINK_FIRST
)
1456 fputs (") DOACROSS(", dumpfile
);
1458 fputs (") DEPEND(", dumpfile
);
1461 fputc (',', dumpfile
);
1467 else if (list_type
== OMP_LIST_MAP
)
1468 switch (n
->u
.map_op
)
1470 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1471 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1472 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1473 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1474 case OMP_MAP_PRESENT_ALLOC
: fputs ("present,alloc:", dumpfile
); break;
1475 case OMP_MAP_PRESENT_TO
: fputs ("present,to:", dumpfile
); break;
1476 case OMP_MAP_PRESENT_FROM
: fputs ("present,from:", dumpfile
); break;
1477 case OMP_MAP_PRESENT_TOFROM
:
1478 fputs ("present,tofrom:", dumpfile
); break;
1479 case OMP_MAP_ALWAYS_TO
: fputs ("always,to:", dumpfile
); break;
1480 case OMP_MAP_ALWAYS_FROM
: fputs ("always,from:", dumpfile
); break;
1481 case OMP_MAP_ALWAYS_TOFROM
: fputs ("always,tofrom:", dumpfile
); break;
1482 case OMP_MAP_ALWAYS_PRESENT_TO
:
1483 fputs ("always,present,to:", dumpfile
); break;
1484 case OMP_MAP_ALWAYS_PRESENT_FROM
:
1485 fputs ("always,present,from:", dumpfile
); break;
1486 case OMP_MAP_ALWAYS_PRESENT_TOFROM
:
1487 fputs ("always,present,tofrom:", dumpfile
); break;
1488 case OMP_MAP_DELETE
: fputs ("delete:", dumpfile
); break;
1489 case OMP_MAP_RELEASE
: fputs ("release:", dumpfile
); break;
1492 else if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.old_modifier
)
1493 switch (n
->u
.linear
.op
)
1495 case OMP_LINEAR_REF
: fputs ("ref(", dumpfile
); break;
1496 case OMP_LINEAR_VAL
: fputs ("val(", dumpfile
); break;
1497 case OMP_LINEAR_UVAL
: fputs ("uval(", dumpfile
); break;
1500 else if (list_type
== OMP_LIST_USES_ALLOCATORS
)
1502 if (n
->u
.memspace_sym
)
1504 fputs ("memspace(", dumpfile
);
1505 fputs (n
->sym
->name
, dumpfile
);
1506 fputc (')', dumpfile
);
1508 if (n
->u
.memspace_sym
&& n
->u2
.traits_sym
)
1509 fputc (',', dumpfile
);
1510 if (n
->u2
.traits_sym
)
1512 fputs ("traits(", dumpfile
);
1513 fputs (n
->u2
.traits_sym
->name
, dumpfile
);
1514 fputc (')', dumpfile
);
1516 if (n
->u
.memspace_sym
|| n
->u2
.traits_sym
)
1517 fputc (':', dumpfile
);
1518 fputs (n
->sym
->name
, dumpfile
);
1520 fputs (", ", dumpfile
);
1523 fprintf (dumpfile
, "%s", n
->sym
? n
->sym
->name
: "omp_all_memory");
1524 if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.op
!= OMP_LINEAR_DEFAULT
)
1525 fputc (')', dumpfile
);
1528 fputc (':', dumpfile
);
1529 show_expr (n
->expr
);
1532 fputc (',', dumpfile
);
1534 gfc_current_ns
= ns_curr
;
1538 show_omp_assumes (gfc_omp_assumptions
*assume
)
1540 for (int i
= 0; i
< assume
->n_absent
; i
++)
1542 fputs (" ABSENT (", dumpfile
);
1543 fputs (gfc_ascii_statement (assume
->absent
[i
], true), dumpfile
);
1544 fputc (')', dumpfile
);
1546 for (int i
= 0; i
< assume
->n_contains
; i
++)
1548 fputs (" CONTAINS (", dumpfile
);
1549 fputs (gfc_ascii_statement (assume
->contains
[i
], true), dumpfile
);
1550 fputc (')', dumpfile
);
1552 for (gfc_expr_list
*el
= assume
->holds
; el
; el
= el
->next
)
1554 fputs (" HOLDS (", dumpfile
);
1555 show_expr (el
->expr
);
1556 fputc (')', dumpfile
);
1558 if (assume
->no_openmp
)
1559 fputs (" NO_OPENMP", dumpfile
);
1560 if (assume
->no_openmp_routines
)
1561 fputs (" NO_OPENMP_ROUTINES", dumpfile
);
1562 if (assume
->no_parallelism
)
1563 fputs (" NO_PARALLELISM", dumpfile
);
1566 /* Show OpenMP or OpenACC clauses. */
1569 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1573 switch (omp_clauses
->cancel
)
1575 case OMP_CANCEL_UNKNOWN
:
1577 case OMP_CANCEL_PARALLEL
:
1578 fputs (" PARALLEL", dumpfile
);
1580 case OMP_CANCEL_SECTIONS
:
1581 fputs (" SECTIONS", dumpfile
);
1584 fputs (" DO", dumpfile
);
1586 case OMP_CANCEL_TASKGROUP
:
1587 fputs (" TASKGROUP", dumpfile
);
1590 if (omp_clauses
->if_expr
)
1592 fputs (" IF(", dumpfile
);
1593 show_expr (omp_clauses
->if_expr
);
1594 fputc (')', dumpfile
);
1596 for (i
= 0; i
< OMP_IF_LAST
; i
++)
1597 if (omp_clauses
->if_exprs
[i
])
1599 static const char *ifs
[] = {
1608 "TARGET ENTER DATA",
1611 fputs (" IF(", dumpfile
);
1612 fputs (ifs
[i
], dumpfile
);
1613 fputs (": ", dumpfile
);
1614 show_expr (omp_clauses
->if_exprs
[i
]);
1615 fputc (')', dumpfile
);
1617 if (omp_clauses
->final_expr
)
1619 fputs (" FINAL(", dumpfile
);
1620 show_expr (omp_clauses
->final_expr
);
1621 fputc (')', dumpfile
);
1623 if (omp_clauses
->num_threads
)
1625 fputs (" NUM_THREADS(", dumpfile
);
1626 show_expr (omp_clauses
->num_threads
);
1627 fputc (')', dumpfile
);
1629 if (omp_clauses
->async
)
1631 fputs (" ASYNC", dumpfile
);
1632 if (omp_clauses
->async_expr
)
1634 fputc ('(', dumpfile
);
1635 show_expr (omp_clauses
->async_expr
);
1636 fputc (')', dumpfile
);
1639 if (omp_clauses
->num_gangs_expr
)
1641 fputs (" NUM_GANGS(", dumpfile
);
1642 show_expr (omp_clauses
->num_gangs_expr
);
1643 fputc (')', dumpfile
);
1645 if (omp_clauses
->num_workers_expr
)
1647 fputs (" NUM_WORKERS(", dumpfile
);
1648 show_expr (omp_clauses
->num_workers_expr
);
1649 fputc (')', dumpfile
);
1651 if (omp_clauses
->vector_length_expr
)
1653 fputs (" VECTOR_LENGTH(", dumpfile
);
1654 show_expr (omp_clauses
->vector_length_expr
);
1655 fputc (')', dumpfile
);
1657 if (omp_clauses
->gang
)
1659 fputs (" GANG", dumpfile
);
1660 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1662 fputc ('(', dumpfile
);
1663 if (omp_clauses
->gang_num_expr
)
1665 fprintf (dumpfile
, "num:");
1666 show_expr (omp_clauses
->gang_num_expr
);
1668 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1669 fputc (',', dumpfile
);
1670 if (omp_clauses
->gang_static
)
1672 fprintf (dumpfile
, "static:");
1673 if (omp_clauses
->gang_static_expr
)
1674 show_expr (omp_clauses
->gang_static_expr
);
1676 fputc ('*', dumpfile
);
1678 fputc (')', dumpfile
);
1681 if (omp_clauses
->worker
)
1683 fputs (" WORKER", dumpfile
);
1684 if (omp_clauses
->worker_expr
)
1686 fputc ('(', dumpfile
);
1687 show_expr (omp_clauses
->worker_expr
);
1688 fputc (')', dumpfile
);
1691 if (omp_clauses
->vector
)
1693 fputs (" VECTOR", dumpfile
);
1694 if (omp_clauses
->vector_expr
)
1696 fputc ('(', dumpfile
);
1697 show_expr (omp_clauses
->vector_expr
);
1698 fputc (')', dumpfile
);
1701 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1704 switch (omp_clauses
->sched_kind
)
1706 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1707 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1708 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1709 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1710 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1714 fputs (" SCHEDULE (", dumpfile
);
1715 if (omp_clauses
->sched_simd
)
1717 if (omp_clauses
->sched_monotonic
1718 || omp_clauses
->sched_nonmonotonic
)
1719 fputs ("SIMD, ", dumpfile
);
1721 fputs ("SIMD: ", dumpfile
);
1723 if (omp_clauses
->sched_monotonic
)
1724 fputs ("MONOTONIC: ", dumpfile
);
1725 else if (omp_clauses
->sched_nonmonotonic
)
1726 fputs ("NONMONOTONIC: ", dumpfile
);
1727 fputs (type
, dumpfile
);
1728 if (omp_clauses
->chunk_size
)
1730 fputc (',', dumpfile
);
1731 show_expr (omp_clauses
->chunk_size
);
1733 fputc (')', dumpfile
);
1735 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1738 switch (omp_clauses
->default_sharing
)
1740 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1741 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1742 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1743 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1744 case OMP_DEFAULT_PRESENT
: type
= "PRESENT"; break;
1748 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1750 if (omp_clauses
->tile_list
)
1752 gfc_expr_list
*list
;
1753 fputs (" TILE(", dumpfile
);
1754 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1756 show_expr (list
->expr
);
1758 fputs (", ", dumpfile
);
1760 fputc (')', dumpfile
);
1762 if (omp_clauses
->wait_list
)
1764 gfc_expr_list
*list
;
1765 fputs (" WAIT(", dumpfile
);
1766 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1768 show_expr (list
->expr
);
1770 fputs (", ", dumpfile
);
1772 fputc (')', dumpfile
);
1774 if (omp_clauses
->seq
)
1775 fputs (" SEQ", dumpfile
);
1776 if (omp_clauses
->independent
)
1777 fputs (" INDEPENDENT", dumpfile
);
1778 if (omp_clauses
->order_concurrent
)
1780 fputs (" ORDER(", dumpfile
);
1781 if (omp_clauses
->order_unconstrained
)
1782 fputs ("UNCONSTRAINED:", dumpfile
);
1783 else if (omp_clauses
->order_reproducible
)
1784 fputs ("REPRODUCIBLE:", dumpfile
);
1785 fputs ("CONCURRENT)", dumpfile
);
1787 if (omp_clauses
->ordered
)
1789 if (omp_clauses
->orderedc
)
1790 fprintf (dumpfile
, " ORDERED(%d)", omp_clauses
->orderedc
);
1792 fputs (" ORDERED", dumpfile
);
1794 if (omp_clauses
->untied
)
1795 fputs (" UNTIED", dumpfile
);
1796 if (omp_clauses
->mergeable
)
1797 fputs (" MERGEABLE", dumpfile
);
1798 if (omp_clauses
->collapse
)
1799 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1800 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1801 if (omp_clauses
->lists
[list_type
] != NULL
1802 && list_type
!= OMP_LIST_COPYPRIVATE
)
1804 const char *type
= NULL
;
1807 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1808 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1809 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1810 case OMP_LIST_COPYPRIVATE
: type
= "COPYPRIVATE"; break;
1811 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1812 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1813 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1814 case OMP_LIST_AFFINITY
: type
= "AFFINITY"; break;
1815 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1816 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1817 case OMP_LIST_DEPEND
:
1818 if (omp_clauses
->lists
[list_type
]
1819 && (omp_clauses
->lists
[list_type
]->u
.depend_doacross_op
1820 == OMP_DOACROSS_SINK_FIRST
))
1825 case OMP_LIST_MAP
: type
= "MAP"; break;
1826 case OMP_LIST_TO
: type
= "TO"; break;
1827 case OMP_LIST_FROM
: type
= "FROM"; break;
1828 case OMP_LIST_REDUCTION
:
1829 case OMP_LIST_REDUCTION_INSCAN
:
1830 case OMP_LIST_REDUCTION_TASK
: type
= "REDUCTION"; break;
1831 case OMP_LIST_IN_REDUCTION
: type
= "IN_REDUCTION"; break;
1832 case OMP_LIST_TASK_REDUCTION
: type
= "TASK_REDUCTION"; break;
1833 case OMP_LIST_DEVICE_RESIDENT
: type
= "DEVICE_RESIDENT"; break;
1834 case OMP_LIST_ENTER
: type
= "ENTER"; break;
1835 case OMP_LIST_LINK
: type
= "LINK"; break;
1836 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1837 case OMP_LIST_CACHE
: type
= "CACHE"; break;
1838 case OMP_LIST_IS_DEVICE_PTR
: type
= "IS_DEVICE_PTR"; break;
1839 case OMP_LIST_USE_DEVICE_PTR
: type
= "USE_DEVICE_PTR"; break;
1840 case OMP_LIST_HAS_DEVICE_ADDR
: type
= "HAS_DEVICE_ADDR"; break;
1841 case OMP_LIST_USE_DEVICE_ADDR
: type
= "USE_DEVICE_ADDR"; break;
1842 case OMP_LIST_NONTEMPORAL
: type
= "NONTEMPORAL"; break;
1843 case OMP_LIST_ALLOCATE
: type
= "ALLOCATE"; break;
1844 case OMP_LIST_SCAN_IN
: type
= "INCLUSIVE"; break;
1845 case OMP_LIST_SCAN_EX
: type
= "EXCLUSIVE"; break;
1846 case OMP_LIST_USES_ALLOCATORS
: type
= "USES_ALLOCATORS"; break;
1850 fprintf (dumpfile
, " %s(", type
);
1851 if (list_type
== OMP_LIST_REDUCTION_INSCAN
)
1852 fputs ("inscan, ", dumpfile
);
1853 if (list_type
== OMP_LIST_REDUCTION_TASK
)
1854 fputs ("task, ", dumpfile
);
1855 if ((list_type
== OMP_LIST_TO
|| list_type
== OMP_LIST_FROM
)
1856 && omp_clauses
->lists
[list_type
]->u
.present_modifier
)
1857 fputs ("present:", dumpfile
);
1858 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1859 fputc (')', dumpfile
);
1861 if (omp_clauses
->safelen_expr
)
1863 fputs (" SAFELEN(", dumpfile
);
1864 show_expr (omp_clauses
->safelen_expr
);
1865 fputc (')', dumpfile
);
1867 if (omp_clauses
->simdlen_expr
)
1869 fputs (" SIMDLEN(", dumpfile
);
1870 show_expr (omp_clauses
->simdlen_expr
);
1871 fputc (')', dumpfile
);
1873 if (omp_clauses
->inbranch
)
1874 fputs (" INBRANCH", dumpfile
);
1875 if (omp_clauses
->notinbranch
)
1876 fputs (" NOTINBRANCH", dumpfile
);
1877 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1880 switch (omp_clauses
->proc_bind
)
1882 case OMP_PROC_BIND_PRIMARY
: type
= "PRIMARY"; break;
1883 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1884 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1885 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1889 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1891 if (omp_clauses
->bind
!= OMP_BIND_UNSET
)
1894 switch (omp_clauses
->bind
)
1896 case OMP_BIND_TEAMS
: type
= "TEAMS"; break;
1897 case OMP_BIND_PARALLEL
: type
= "PARALLEL"; break;
1898 case OMP_BIND_THREAD
: type
= "THREAD"; break;
1902 fprintf (dumpfile
, " BIND(%s)", type
);
1904 if (omp_clauses
->num_teams_upper
)
1906 fputs (" NUM_TEAMS(", dumpfile
);
1907 if (omp_clauses
->num_teams_lower
)
1909 show_expr (omp_clauses
->num_teams_lower
);
1910 fputc (':', dumpfile
);
1912 show_expr (omp_clauses
->num_teams_upper
);
1913 fputc (')', dumpfile
);
1915 if (omp_clauses
->device
)
1917 fputs (" DEVICE(", dumpfile
);
1918 if (omp_clauses
->ancestor
)
1919 fputs ("ANCESTOR:", dumpfile
);
1920 show_expr (omp_clauses
->device
);
1921 fputc (')', dumpfile
);
1923 if (omp_clauses
->thread_limit
)
1925 fputs (" THREAD_LIMIT(", dumpfile
);
1926 show_expr (omp_clauses
->thread_limit
);
1927 fputc (')', dumpfile
);
1929 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
1931 fputs (" DIST_SCHEDULE (STATIC", dumpfile
);
1932 if (omp_clauses
->dist_chunk_size
)
1934 fputc (',', dumpfile
);
1935 show_expr (omp_clauses
->dist_chunk_size
);
1937 fputc (')', dumpfile
);
1939 for (int i
= 0; i
< OMP_DEFAULTMAP_CAT_NUM
; i
++)
1941 const char *dfltmap
;
1942 if (omp_clauses
->defaultmap
[i
] == OMP_DEFAULTMAP_UNSET
)
1944 fputs (" DEFAULTMAP (", dumpfile
);
1945 switch (omp_clauses
->defaultmap
[i
])
1947 case OMP_DEFAULTMAP_ALLOC
: dfltmap
= "ALLOC"; break;
1948 case OMP_DEFAULTMAP_TO
: dfltmap
= "TO"; break;
1949 case OMP_DEFAULTMAP_FROM
: dfltmap
= "FROM"; break;
1950 case OMP_DEFAULTMAP_TOFROM
: dfltmap
= "TOFROM"; break;
1951 case OMP_DEFAULTMAP_FIRSTPRIVATE
: dfltmap
= "FIRSTPRIVATE"; break;
1952 case OMP_DEFAULTMAP_NONE
: dfltmap
= "NONE"; break;
1953 case OMP_DEFAULTMAP_DEFAULT
: dfltmap
= "DEFAULT"; break;
1954 case OMP_DEFAULTMAP_PRESENT
: dfltmap
= "PRESENT"; break;
1955 default: gcc_unreachable ();
1957 fputs (dfltmap
, dumpfile
);
1958 if (i
!= OMP_DEFAULTMAP_CAT_UNCATEGORIZED
)
1960 fputc (':', dumpfile
);
1961 switch ((enum gfc_omp_defaultmap_category
) i
)
1963 case OMP_DEFAULTMAP_CAT_SCALAR
: dfltmap
= "SCALAR"; break;
1964 case OMP_DEFAULTMAP_CAT_AGGREGATE
: dfltmap
= "AGGREGATE"; break;
1965 case OMP_DEFAULTMAP_CAT_ALLOCATABLE
: dfltmap
= "ALLOCATABLE"; break;
1966 case OMP_DEFAULTMAP_CAT_POINTER
: dfltmap
= "POINTER"; break;
1967 default: gcc_unreachable ();
1969 fputs (dfltmap
, dumpfile
);
1971 fputc (')', dumpfile
);
1973 if (omp_clauses
->weak
)
1974 fputs (" WEAK", dumpfile
);
1975 if (omp_clauses
->compare
)
1976 fputs (" COMPARE", dumpfile
);
1977 if (omp_clauses
->nogroup
)
1978 fputs (" NOGROUP", dumpfile
);
1979 if (omp_clauses
->simd
)
1980 fputs (" SIMD", dumpfile
);
1981 if (omp_clauses
->threads
)
1982 fputs (" THREADS", dumpfile
);
1983 if (omp_clauses
->grainsize
)
1985 fputs (" GRAINSIZE(", dumpfile
);
1986 if (omp_clauses
->grainsize_strict
)
1987 fputs ("strict: ", dumpfile
);
1988 show_expr (omp_clauses
->grainsize
);
1989 fputc (')', dumpfile
);
1991 if (omp_clauses
->filter
)
1993 fputs (" FILTER(", dumpfile
);
1994 show_expr (omp_clauses
->filter
);
1995 fputc (')', dumpfile
);
1997 if (omp_clauses
->hint
)
1999 fputs (" HINT(", dumpfile
);
2000 show_expr (omp_clauses
->hint
);
2001 fputc (')', dumpfile
);
2003 if (omp_clauses
->num_tasks
)
2005 fputs (" NUM_TASKS(", dumpfile
);
2006 if (omp_clauses
->num_tasks_strict
)
2007 fputs ("strict: ", dumpfile
);
2008 show_expr (omp_clauses
->num_tasks
);
2009 fputc (')', dumpfile
);
2011 if (omp_clauses
->priority
)
2013 fputs (" PRIORITY(", dumpfile
);
2014 show_expr (omp_clauses
->priority
);
2015 fputc (')', dumpfile
);
2017 if (omp_clauses
->detach
)
2019 fputs (" DETACH(", dumpfile
);
2020 show_expr (omp_clauses
->detach
);
2021 fputc (')', dumpfile
);
2023 if (omp_clauses
->destroy
)
2024 fputs (" DESTROY", dumpfile
);
2025 if (omp_clauses
->depend_source
)
2026 fputs (" DEPEND(source)", dumpfile
);
2027 if (omp_clauses
->doacross_source
)
2028 fputs (" DOACROSS(source:)", dumpfile
);
2029 if (omp_clauses
->capture
)
2030 fputs (" CAPTURE", dumpfile
);
2031 if (omp_clauses
->depobj_update
!= OMP_DEPEND_UNSET
)
2033 const char *deptype
;
2034 fputs (" UPDATE(", dumpfile
);
2035 switch (omp_clauses
->depobj_update
)
2037 case OMP_DEPEND_IN
: deptype
= "IN"; break;
2038 case OMP_DEPEND_OUT
: deptype
= "OUT"; break;
2039 case OMP_DEPEND_INOUT
: deptype
= "INOUT"; break;
2040 case OMP_DEPEND_INOUTSET
: deptype
= "INOUTSET"; break;
2041 case OMP_DEPEND_MUTEXINOUTSET
: deptype
= "MUTEXINOUTSET"; break;
2042 default: gcc_unreachable ();
2044 fputs (deptype
, dumpfile
);
2045 fputc (')', dumpfile
);
2047 if (omp_clauses
->atomic_op
!= GFC_OMP_ATOMIC_UNSET
)
2049 const char *atomic_op
;
2050 switch (omp_clauses
->atomic_op
& GFC_OMP_ATOMIC_MASK
)
2052 case GFC_OMP_ATOMIC_READ
: atomic_op
= "READ"; break;
2053 case GFC_OMP_ATOMIC_WRITE
: atomic_op
= "WRITE"; break;
2054 case GFC_OMP_ATOMIC_UPDATE
: atomic_op
= "UPDATE"; break;
2055 default: gcc_unreachable ();
2057 fputc (' ', dumpfile
);
2058 fputs (atomic_op
, dumpfile
);
2060 if (omp_clauses
->memorder
!= OMP_MEMORDER_UNSET
)
2062 const char *memorder
;
2063 switch (omp_clauses
->memorder
)
2065 case OMP_MEMORDER_ACQ_REL
: memorder
= "ACQ_REL"; break;
2066 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2067 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2068 case OMP_MEMORDER_RELEASE
: memorder
= "RELEASE"; break;
2069 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2070 default: gcc_unreachable ();
2072 fputc (' ', dumpfile
);
2073 fputs (memorder
, dumpfile
);
2075 if (omp_clauses
->fail
!= OMP_MEMORDER_UNSET
)
2077 const char *memorder
;
2078 switch (omp_clauses
->fail
)
2080 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2081 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2082 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2083 default: gcc_unreachable ();
2085 fputs (" FAIL(", dumpfile
);
2086 fputs (memorder
, dumpfile
);
2087 putc (')', dumpfile
);
2089 if (omp_clauses
->at
!= OMP_AT_UNSET
)
2091 if (omp_clauses
->at
!= OMP_AT_COMPILATION
)
2092 fputs (" AT (COMPILATION)", dumpfile
);
2094 fputs (" AT (EXECUTION)", dumpfile
);
2096 if (omp_clauses
->severity
!= OMP_SEVERITY_UNSET
)
2098 if (omp_clauses
->severity
!= OMP_SEVERITY_FATAL
)
2099 fputs (" SEVERITY (FATAL)", dumpfile
);
2101 fputs (" SEVERITY (WARNING)", dumpfile
);
2103 if (omp_clauses
->message
)
2105 fputs (" ERROR (", dumpfile
);
2106 show_expr (omp_clauses
->message
);
2107 fputc (')', dumpfile
);
2109 if (omp_clauses
->assume
)
2110 show_omp_assumes (omp_clauses
->assume
);
2113 /* Show a single OpenMP or OpenACC directive node and everything underneath it
2117 show_omp_node (int level
, gfc_code
*c
)
2119 gfc_omp_clauses
*omp_clauses
= NULL
;
2120 const char *name
= NULL
;
2121 bool is_oacc
= false;
2125 case EXEC_OACC_PARALLEL_LOOP
:
2126 name
= "PARALLEL LOOP"; is_oacc
= true; break;
2127 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
2128 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
2129 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
2130 case EXEC_OACC_SERIAL_LOOP
: name
= "SERIAL LOOP"; is_oacc
= true; break;
2131 case EXEC_OACC_SERIAL
: name
= "SERIAL"; is_oacc
= true; break;
2132 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
2133 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
2134 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
2135 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
2136 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
2137 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
2138 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
2139 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
2140 case EXEC_OMP_ALLOCATE
: name
= "ALLOCATE"; break;
2141 case EXEC_OMP_ALLOCATORS
: name
= "ALLOCATORS"; break;
2142 case EXEC_OMP_ASSUME
: name
= "ASSUME"; break;
2143 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
2144 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
2145 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
2146 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
2147 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
2148 case EXEC_OMP_DISTRIBUTE
: name
= "DISTRIBUTE"; break;
2149 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2150 name
= "DISTRIBUTE PARALLEL DO"; break;
2151 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2152 name
= "DISTRIBUTE PARALLEL DO SIMD"; break;
2153 case EXEC_OMP_DISTRIBUTE_SIMD
: name
= "DISTRIBUTE SIMD"; break;
2154 case EXEC_OMP_DO
: name
= "DO"; break;
2155 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
2156 case EXEC_OMP_ERROR
: name
= "ERROR"; break;
2157 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
2158 case EXEC_OMP_LOOP
: name
= "LOOP"; break;
2159 case EXEC_OMP_MASKED
: name
= "MASKED"; break;
2160 case EXEC_OMP_MASKED_TASKLOOP
: name
= "MASKED TASKLOOP"; break;
2161 case EXEC_OMP_MASKED_TASKLOOP_SIMD
: name
= "MASKED TASKLOOP SIMD"; break;
2162 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
2163 case EXEC_OMP_MASTER_TASKLOOP
: name
= "MASTER TASKLOOP"; break;
2164 case EXEC_OMP_MASTER_TASKLOOP_SIMD
: name
= "MASTER TASKLOOP SIMD"; break;
2165 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
2166 case EXEC_OMP_DEPOBJ
: name
= "DEPOBJ"; break;
2167 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
2168 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
2169 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
2170 case EXEC_OMP_PARALLEL_LOOP
: name
= "PARALLEL LOOP"; break;
2171 case EXEC_OMP_PARALLEL_MASTER
: name
= "PARALLEL MASTER"; break;
2172 case EXEC_OMP_PARALLEL_MASKED
: name
= "PARALLEL MASK"; break;
2173 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2174 name
= "PARALLEL MASK TASKLOOP"; break;
2175 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2176 name
= "PARALLEL MASK TASKLOOP SIMD"; break;
2177 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2178 name
= "PARALLEL MASTER TASKLOOP"; break;
2179 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2180 name
= "PARALLEL MASTER TASKLOOP SIMD"; break;
2181 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
2182 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
2183 case EXEC_OMP_SCAN
: name
= "SCAN"; break;
2184 case EXEC_OMP_SCOPE
: name
= "SCOPE"; break;
2185 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
2186 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
2187 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
2188 case EXEC_OMP_TARGET
: name
= "TARGET"; break;
2189 case EXEC_OMP_TARGET_DATA
: name
= "TARGET DATA"; break;
2190 case EXEC_OMP_TARGET_ENTER_DATA
: name
= "TARGET ENTER DATA"; break;
2191 case EXEC_OMP_TARGET_EXIT_DATA
: name
= "TARGET EXIT DATA"; break;
2192 case EXEC_OMP_TARGET_PARALLEL
: name
= "TARGET PARALLEL"; break;
2193 case EXEC_OMP_TARGET_PARALLEL_DO
: name
= "TARGET PARALLEL DO"; break;
2194 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2195 name
= "TARGET_PARALLEL_DO_SIMD"; break;
2196 case EXEC_OMP_TARGET_PARALLEL_LOOP
: name
= "TARGET PARALLEL LOOP"; break;
2197 case EXEC_OMP_TARGET_SIMD
: name
= "TARGET SIMD"; break;
2198 case EXEC_OMP_TARGET_TEAMS
: name
= "TARGET TEAMS"; break;
2199 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2200 name
= "TARGET TEAMS DISTRIBUTE"; break;
2201 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2202 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
2203 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2204 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2205 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2206 name
= "TARGET TEAMS DISTRIBUTE SIMD"; break;
2207 case EXEC_OMP_TARGET_TEAMS_LOOP
: name
= "TARGET TEAMS LOOP"; break;
2208 case EXEC_OMP_TARGET_UPDATE
: name
= "TARGET UPDATE"; break;
2209 case EXEC_OMP_TASK
: name
= "TASK"; break;
2210 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
2211 case EXEC_OMP_TASKLOOP
: name
= "TASKLOOP"; break;
2212 case EXEC_OMP_TASKLOOP_SIMD
: name
= "TASKLOOP SIMD"; break;
2213 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
2214 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
2215 case EXEC_OMP_TEAMS
: name
= "TEAMS"; break;
2216 case EXEC_OMP_TEAMS_DISTRIBUTE
: name
= "TEAMS DISTRIBUTE"; break;
2217 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2218 name
= "TEAMS DISTRIBUTE PARALLEL DO"; break;
2219 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2220 name
= "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2221 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
: name
= "TEAMS DISTRIBUTE SIMD"; break;
2222 case EXEC_OMP_TEAMS_LOOP
: name
= "TEAMS LOOP"; break;
2223 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
2227 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
2230 case EXEC_OACC_PARALLEL_LOOP
:
2231 case EXEC_OACC_PARALLEL
:
2232 case EXEC_OACC_KERNELS_LOOP
:
2233 case EXEC_OACC_KERNELS
:
2234 case EXEC_OACC_SERIAL_LOOP
:
2235 case EXEC_OACC_SERIAL
:
2236 case EXEC_OACC_DATA
:
2237 case EXEC_OACC_HOST_DATA
:
2238 case EXEC_OACC_LOOP
:
2239 case EXEC_OACC_UPDATE
:
2240 case EXEC_OACC_WAIT
:
2241 case EXEC_OACC_CACHE
:
2242 case EXEC_OACC_ENTER_DATA
:
2243 case EXEC_OACC_EXIT_DATA
:
2244 case EXEC_OMP_ALLOCATE
:
2245 case EXEC_OMP_ALLOCATORS
:
2246 case EXEC_OMP_ASSUME
:
2247 case EXEC_OMP_CANCEL
:
2248 case EXEC_OMP_CANCELLATION_POINT
:
2249 case EXEC_OMP_DISTRIBUTE
:
2250 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2251 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2252 case EXEC_OMP_DISTRIBUTE_SIMD
:
2254 case EXEC_OMP_DO_SIMD
:
2255 case EXEC_OMP_ERROR
:
2257 case EXEC_OMP_ORDERED
:
2258 case EXEC_OMP_MASKED
:
2259 case EXEC_OMP_PARALLEL
:
2260 case EXEC_OMP_PARALLEL_DO
:
2261 case EXEC_OMP_PARALLEL_DO_SIMD
:
2262 case EXEC_OMP_PARALLEL_LOOP
:
2263 case EXEC_OMP_PARALLEL_MASKED
:
2264 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2265 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2266 case EXEC_OMP_PARALLEL_MASTER
:
2267 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2268 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2269 case EXEC_OMP_PARALLEL_SECTIONS
:
2270 case EXEC_OMP_PARALLEL_WORKSHARE
:
2272 case EXEC_OMP_SCOPE
:
2273 case EXEC_OMP_SECTIONS
:
2275 case EXEC_OMP_SINGLE
:
2276 case EXEC_OMP_TARGET
:
2277 case EXEC_OMP_TARGET_DATA
:
2278 case EXEC_OMP_TARGET_ENTER_DATA
:
2279 case EXEC_OMP_TARGET_EXIT_DATA
:
2280 case EXEC_OMP_TARGET_PARALLEL
:
2281 case EXEC_OMP_TARGET_PARALLEL_DO
:
2282 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2283 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
2284 case EXEC_OMP_TARGET_SIMD
:
2285 case EXEC_OMP_TARGET_TEAMS
:
2286 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2287 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2288 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2289 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2290 case EXEC_OMP_TARGET_TEAMS_LOOP
:
2291 case EXEC_OMP_TARGET_UPDATE
:
2293 case EXEC_OMP_TASKLOOP
:
2294 case EXEC_OMP_TASKLOOP_SIMD
:
2295 case EXEC_OMP_TEAMS
:
2296 case EXEC_OMP_TEAMS_DISTRIBUTE
:
2297 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2298 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2299 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
2300 case EXEC_OMP_TEAMS_LOOP
:
2301 case EXEC_OMP_WORKSHARE
:
2302 omp_clauses
= c
->ext
.omp_clauses
;
2304 case EXEC_OMP_CRITICAL
:
2305 omp_clauses
= c
->ext
.omp_clauses
;
2307 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2309 case EXEC_OMP_DEPOBJ
:
2310 omp_clauses
= c
->ext
.omp_clauses
;
2313 fputc ('(', dumpfile
);
2314 show_expr (c
->ext
.omp_clauses
->depobj
);
2315 fputc (')', dumpfile
);
2318 case EXEC_OMP_FLUSH
:
2319 if (c
->ext
.omp_namelist
)
2321 fputs (" (", dumpfile
);
2322 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
2323 fputc (')', dumpfile
);
2326 case EXEC_OMP_BARRIER
:
2327 case EXEC_OMP_TASKWAIT
:
2328 case EXEC_OMP_TASKYIELD
:
2330 case EXEC_OACC_ATOMIC
:
2331 case EXEC_OMP_ATOMIC
:
2332 omp_clauses
= c
->block
? c
->block
->ext
.omp_clauses
: NULL
;
2338 show_omp_clauses (omp_clauses
);
2339 fputc ('\n', dumpfile
);
2341 /* OpenMP and OpenACC executable directives don't have associated blocks. */
2342 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
2343 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
2344 || c
->op
== EXEC_OMP_TARGET_UPDATE
|| c
->op
== EXEC_OMP_TARGET_ENTER_DATA
2345 || c
->op
== EXEC_OMP_TARGET_EXIT_DATA
|| c
->op
== EXEC_OMP_SCAN
2346 || c
->op
== EXEC_OMP_DEPOBJ
|| c
->op
== EXEC_OMP_ERROR
2347 || (c
->op
== EXEC_OMP_ORDERED
&& c
->block
== NULL
))
2349 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
2351 gfc_code
*d
= c
->block
;
2354 show_code (level
+ 1, d
->next
);
2355 if (d
->block
== NULL
)
2357 code_indent (level
, 0);
2358 fputs ("!$OMP SECTION\n", dumpfile
);
2363 show_code (level
+ 1, c
->block
->next
);
2364 if (c
->op
== EXEC_OMP_ATOMIC
)
2366 fputc ('\n', dumpfile
);
2367 code_indent (level
, 0);
2368 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
2369 if (omp_clauses
!= NULL
)
2371 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
2373 fputs (" COPYPRIVATE(", dumpfile
);
2374 show_omp_namelist (OMP_LIST_COPYPRIVATE
,
2375 omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
2376 fputc (')', dumpfile
);
2378 else if (omp_clauses
->nowait
)
2379 fputs (" NOWAIT", dumpfile
);
2381 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_clauses
)
2382 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2386 /* Show a single code node and everything underneath it if necessary. */
2389 show_code_node (int level
, gfc_code
*c
)
2391 gfc_forall_iterator
*fa
;
2404 fputc ('\n', dumpfile
);
2405 code_indent (level
, c
->here
);
2412 case EXEC_END_PROCEDURE
:
2416 fputs ("NOP", dumpfile
);
2420 fputs ("CONTINUE", dumpfile
);
2424 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
2427 case EXEC_INIT_ASSIGN
:
2429 fputs ("ASSIGN ", dumpfile
);
2430 show_expr (c
->expr1
);
2431 fputc (' ', dumpfile
);
2432 show_expr (c
->expr2
);
2435 case EXEC_LABEL_ASSIGN
:
2436 fputs ("LABEL ASSIGN ", dumpfile
);
2437 show_expr (c
->expr1
);
2438 fprintf (dumpfile
, " %d", c
->label1
->value
);
2441 case EXEC_POINTER_ASSIGN
:
2442 fputs ("POINTER ASSIGN ", dumpfile
);
2443 show_expr (c
->expr1
);
2444 fputc (' ', dumpfile
);
2445 show_expr (c
->expr2
);
2449 fputs ("GOTO ", dumpfile
);
2451 fprintf (dumpfile
, "%d", c
->label1
->value
);
2454 show_expr (c
->expr1
);
2458 fputs (", (", dumpfile
);
2459 for (; d
; d
= d
->block
)
2461 code_indent (level
, d
->label1
);
2462 if (d
->block
!= NULL
)
2463 fputc (',', dumpfile
);
2465 fputc (')', dumpfile
);
2472 case EXEC_ASSIGN_CALL
:
2473 if (c
->resolved_sym
)
2474 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
2475 else if (c
->symtree
)
2476 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
2478 fputs ("CALL ?? ", dumpfile
);
2480 show_actual_arglist (c
->ext
.actual
);
2484 fputs ("CALL ", dumpfile
);
2485 show_compcall (c
->expr1
);
2489 fputs ("CALL ", dumpfile
);
2490 show_expr (c
->expr1
);
2491 show_actual_arglist (c
->ext
.actual
);
2495 fputs ("RETURN ", dumpfile
);
2497 show_expr (c
->expr1
);
2501 fputs ("PAUSE ", dumpfile
);
2503 if (c
->expr1
!= NULL
)
2504 show_expr (c
->expr1
);
2506 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2510 case EXEC_ERROR_STOP
:
2511 fputs ("ERROR ", dumpfile
);
2515 fputs ("STOP ", dumpfile
);
2517 if (c
->expr1
!= NULL
)
2518 show_expr (c
->expr1
);
2520 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2521 if (c
->expr2
!= NULL
)
2523 fputs (" QUIET=", dumpfile
);
2524 show_expr (c
->expr2
);
2529 case EXEC_FAIL_IMAGE
:
2530 fputs ("FAIL IMAGE ", dumpfile
);
2533 case EXEC_CHANGE_TEAM
:
2534 fputs ("CHANGE TEAM", dumpfile
);
2538 fputs ("END TEAM", dumpfile
);
2541 case EXEC_FORM_TEAM
:
2542 fputs ("FORM TEAM", dumpfile
);
2545 case EXEC_SYNC_TEAM
:
2546 fputs ("SYNC TEAM", dumpfile
);
2550 fputs ("SYNC ALL ", dumpfile
);
2551 if (c
->expr2
!= NULL
)
2553 fputs (" stat=", dumpfile
);
2554 show_expr (c
->expr2
);
2556 if (c
->expr3
!= NULL
)
2558 fputs (" errmsg=", dumpfile
);
2559 show_expr (c
->expr3
);
2563 case EXEC_SYNC_MEMORY
:
2564 fputs ("SYNC MEMORY ", dumpfile
);
2565 if (c
->expr2
!= NULL
)
2567 fputs (" stat=", dumpfile
);
2568 show_expr (c
->expr2
);
2570 if (c
->expr3
!= NULL
)
2572 fputs (" errmsg=", dumpfile
);
2573 show_expr (c
->expr3
);
2577 case EXEC_SYNC_IMAGES
:
2578 fputs ("SYNC IMAGES image-set=", dumpfile
);
2579 if (c
->expr1
!= NULL
)
2580 show_expr (c
->expr1
);
2582 fputs ("* ", dumpfile
);
2583 if (c
->expr2
!= NULL
)
2585 fputs (" stat=", dumpfile
);
2586 show_expr (c
->expr2
);
2588 if (c
->expr3
!= NULL
)
2590 fputs (" errmsg=", dumpfile
);
2591 show_expr (c
->expr3
);
2595 case EXEC_EVENT_POST
:
2596 case EXEC_EVENT_WAIT
:
2597 if (c
->op
== EXEC_EVENT_POST
)
2598 fputs ("EVENT POST ", dumpfile
);
2600 fputs ("EVENT WAIT ", dumpfile
);
2602 fputs ("event-variable=", dumpfile
);
2603 if (c
->expr1
!= NULL
)
2604 show_expr (c
->expr1
);
2605 if (c
->expr4
!= NULL
)
2607 fputs (" until_count=", dumpfile
);
2608 show_expr (c
->expr4
);
2610 if (c
->expr2
!= NULL
)
2612 fputs (" stat=", dumpfile
);
2613 show_expr (c
->expr2
);
2615 if (c
->expr3
!= NULL
)
2617 fputs (" errmsg=", dumpfile
);
2618 show_expr (c
->expr3
);
2624 if (c
->op
== EXEC_LOCK
)
2625 fputs ("LOCK ", dumpfile
);
2627 fputs ("UNLOCK ", dumpfile
);
2629 fputs ("lock-variable=", dumpfile
);
2630 if (c
->expr1
!= NULL
)
2631 show_expr (c
->expr1
);
2632 if (c
->expr4
!= NULL
)
2634 fputs (" acquired_lock=", dumpfile
);
2635 show_expr (c
->expr4
);
2637 if (c
->expr2
!= NULL
)
2639 fputs (" stat=", dumpfile
);
2640 show_expr (c
->expr2
);
2642 if (c
->expr3
!= NULL
)
2644 fputs (" errmsg=", dumpfile
);
2645 show_expr (c
->expr3
);
2649 case EXEC_ARITHMETIC_IF
:
2650 fputs ("IF ", dumpfile
);
2651 show_expr (c
->expr1
);
2652 fprintf (dumpfile
, " %d, %d, %d",
2653 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
2658 fputs ("IF ", dumpfile
);
2659 show_expr (d
->expr1
);
2662 show_code (level
+ 1, d
->next
);
2666 for (; d
; d
= d
->block
)
2668 fputs("\n", dumpfile
);
2669 code_indent (level
, 0);
2670 if (d
->expr1
== NULL
)
2671 fputs ("ELSE", dumpfile
);
2674 fputs ("ELSE IF ", dumpfile
);
2675 show_expr (d
->expr1
);
2679 show_code (level
+ 1, d
->next
);
2684 code_indent (level
, c
->label1
);
2688 fputs ("ENDIF", dumpfile
);
2693 const char* blocktype
;
2694 gfc_namespace
*saved_ns
;
2695 gfc_association_list
*alist
;
2697 if (c
->ext
.block
.assoc
)
2698 blocktype
= "ASSOCIATE";
2700 blocktype
= "BLOCK";
2702 fprintf (dumpfile
, "%s ", blocktype
);
2703 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
2705 fprintf (dumpfile
, " %s = ", alist
->name
);
2706 show_expr (alist
->target
);
2710 ns
= c
->ext
.block
.ns
;
2711 saved_ns
= gfc_current_ns
;
2712 gfc_current_ns
= ns
;
2713 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2714 gfc_current_ns
= saved_ns
;
2715 show_code (show_level
, ns
->code
);
2718 fprintf (dumpfile
, "END %s ", blocktype
);
2722 case EXEC_END_BLOCK
:
2723 /* Only come here when there is a label on an
2724 END ASSOCIATE construct. */
2728 case EXEC_SELECT_TYPE
:
2729 case EXEC_SELECT_RANK
:
2731 fputc ('\n', dumpfile
);
2732 code_indent (level
, 0);
2733 if (c
->op
== EXEC_SELECT_RANK
)
2734 fputs ("SELECT RANK ", dumpfile
);
2735 else if (c
->op
== EXEC_SELECT_TYPE
)
2736 fputs ("SELECT TYPE ", dumpfile
);
2738 fputs ("SELECT CASE ", dumpfile
);
2739 show_expr (c
->expr1
);
2741 for (; d
; d
= d
->block
)
2743 fputc ('\n', dumpfile
);
2744 code_indent (level
, 0);
2745 fputs ("CASE ", dumpfile
);
2746 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
2748 fputc ('(', dumpfile
);
2749 show_expr (cp
->low
);
2750 fputc (' ', dumpfile
);
2751 show_expr (cp
->high
);
2752 fputc (')', dumpfile
);
2753 fputc (' ', dumpfile
);
2756 show_code (level
+ 1, d
->next
);
2757 fputc ('\n', dumpfile
);
2760 code_indent (level
, c
->label1
);
2761 fputs ("END SELECT", dumpfile
);
2765 fputs ("WHERE ", dumpfile
);
2768 show_expr (d
->expr1
);
2769 fputc ('\n', dumpfile
);
2771 show_code (level
+ 1, d
->next
);
2773 for (d
= d
->block
; d
; d
= d
->block
)
2775 code_indent (level
, 0);
2776 fputs ("ELSE WHERE ", dumpfile
);
2777 show_expr (d
->expr1
);
2778 fputc ('\n', dumpfile
);
2779 show_code (level
+ 1, d
->next
);
2782 code_indent (level
, 0);
2783 fputs ("END WHERE", dumpfile
);
2788 fputs ("FORALL ", dumpfile
);
2789 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2791 show_expr (fa
->var
);
2792 fputc (' ', dumpfile
);
2793 show_expr (fa
->start
);
2794 fputc (':', dumpfile
);
2795 show_expr (fa
->end
);
2796 fputc (':', dumpfile
);
2797 show_expr (fa
->stride
);
2799 if (fa
->next
!= NULL
)
2800 fputc (',', dumpfile
);
2803 if (c
->expr1
!= NULL
)
2805 fputc (',', dumpfile
);
2806 show_expr (c
->expr1
);
2808 fputc ('\n', dumpfile
);
2810 show_code (level
+ 1, c
->block
->next
);
2812 code_indent (level
, 0);
2813 fputs ("END FORALL", dumpfile
);
2817 fputs ("CRITICAL\n", dumpfile
);
2818 show_code (level
+ 1, c
->block
->next
);
2819 code_indent (level
, 0);
2820 fputs ("END CRITICAL", dumpfile
);
2824 fputs ("DO ", dumpfile
);
2826 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
2828 show_expr (c
->ext
.iterator
->var
);
2829 fputc ('=', dumpfile
);
2830 show_expr (c
->ext
.iterator
->start
);
2831 fputc (' ', dumpfile
);
2832 show_expr (c
->ext
.iterator
->end
);
2833 fputc (' ', dumpfile
);
2834 show_expr (c
->ext
.iterator
->step
);
2837 show_code (level
+ 1, c
->block
->next
);
2844 fputs ("END DO", dumpfile
);
2847 case EXEC_DO_CONCURRENT
:
2848 fputs ("DO CONCURRENT ", dumpfile
);
2849 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2851 show_expr (fa
->var
);
2852 fputc (' ', dumpfile
);
2853 show_expr (fa
->start
);
2854 fputc (':', dumpfile
);
2855 show_expr (fa
->end
);
2856 fputc (':', dumpfile
);
2857 show_expr (fa
->stride
);
2859 if (fa
->next
!= NULL
)
2860 fputc (',', dumpfile
);
2862 show_expr (c
->expr1
);
2865 show_code (level
+ 1, c
->block
->next
);
2867 code_indent (level
, c
->label1
);
2869 fputs ("END DO", dumpfile
);
2873 fputs ("DO WHILE ", dumpfile
);
2874 show_expr (c
->expr1
);
2875 fputc ('\n', dumpfile
);
2877 show_code (level
+ 1, c
->block
->next
);
2879 code_indent (level
, c
->label1
);
2880 fputs ("END DO", dumpfile
);
2884 fputs ("CYCLE", dumpfile
);
2886 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2890 fputs ("EXIT", dumpfile
);
2892 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2896 fputs ("ALLOCATE ", dumpfile
);
2899 fputs (" STAT=", dumpfile
);
2900 show_expr (c
->expr1
);
2905 fputs (" ERRMSG=", dumpfile
);
2906 show_expr (c
->expr2
);
2912 fputs (" MOLD=", dumpfile
);
2914 fputs (" SOURCE=", dumpfile
);
2915 show_expr (c
->expr3
);
2918 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2920 fputc (' ', dumpfile
);
2921 show_expr (a
->expr
);
2926 case EXEC_DEALLOCATE
:
2927 fputs ("DEALLOCATE ", dumpfile
);
2930 fputs (" STAT=", dumpfile
);
2931 show_expr (c
->expr1
);
2936 fputs (" ERRMSG=", dumpfile
);
2937 show_expr (c
->expr2
);
2940 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2942 fputc (' ', dumpfile
);
2943 show_expr (a
->expr
);
2949 fputs ("OPEN", dumpfile
);
2954 fputs (" UNIT=", dumpfile
);
2955 show_expr (open
->unit
);
2959 fputs (" IOMSG=", dumpfile
);
2960 show_expr (open
->iomsg
);
2964 fputs (" IOSTAT=", dumpfile
);
2965 show_expr (open
->iostat
);
2969 fputs (" FILE=", dumpfile
);
2970 show_expr (open
->file
);
2974 fputs (" STATUS=", dumpfile
);
2975 show_expr (open
->status
);
2979 fputs (" ACCESS=", dumpfile
);
2980 show_expr (open
->access
);
2984 fputs (" FORM=", dumpfile
);
2985 show_expr (open
->form
);
2989 fputs (" RECL=", dumpfile
);
2990 show_expr (open
->recl
);
2994 fputs (" BLANK=", dumpfile
);
2995 show_expr (open
->blank
);
2999 fputs (" POSITION=", dumpfile
);
3000 show_expr (open
->position
);
3004 fputs (" ACTION=", dumpfile
);
3005 show_expr (open
->action
);
3009 fputs (" DELIM=", dumpfile
);
3010 show_expr (open
->delim
);
3014 fputs (" PAD=", dumpfile
);
3015 show_expr (open
->pad
);
3019 fputs (" DECIMAL=", dumpfile
);
3020 show_expr (open
->decimal
);
3024 fputs (" ENCODING=", dumpfile
);
3025 show_expr (open
->encoding
);
3029 fputs (" ROUND=", dumpfile
);
3030 show_expr (open
->round
);
3034 fputs (" SIGN=", dumpfile
);
3035 show_expr (open
->sign
);
3039 fputs (" CONVERT=", dumpfile
);
3040 show_expr (open
->convert
);
3042 if (open
->asynchronous
)
3044 fputs (" ASYNCHRONOUS=", dumpfile
);
3045 show_expr (open
->asynchronous
);
3047 if (open
->err
!= NULL
)
3048 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
3053 fputs ("CLOSE", dumpfile
);
3054 close
= c
->ext
.close
;
3058 fputs (" UNIT=", dumpfile
);
3059 show_expr (close
->unit
);
3063 fputs (" IOMSG=", dumpfile
);
3064 show_expr (close
->iomsg
);
3068 fputs (" IOSTAT=", dumpfile
);
3069 show_expr (close
->iostat
);
3073 fputs (" STATUS=", dumpfile
);
3074 show_expr (close
->status
);
3076 if (close
->err
!= NULL
)
3077 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
3080 case EXEC_BACKSPACE
:
3081 fputs ("BACKSPACE", dumpfile
);
3085 fputs ("ENDFILE", dumpfile
);
3089 fputs ("REWIND", dumpfile
);
3093 fputs ("FLUSH", dumpfile
);
3096 fp
= c
->ext
.filepos
;
3100 fputs (" UNIT=", dumpfile
);
3101 show_expr (fp
->unit
);
3105 fputs (" IOMSG=", dumpfile
);
3106 show_expr (fp
->iomsg
);
3110 fputs (" IOSTAT=", dumpfile
);
3111 show_expr (fp
->iostat
);
3113 if (fp
->err
!= NULL
)
3114 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
3118 fputs ("INQUIRE", dumpfile
);
3123 fputs (" UNIT=", dumpfile
);
3124 show_expr (i
->unit
);
3128 fputs (" FILE=", dumpfile
);
3129 show_expr (i
->file
);
3134 fputs (" IOMSG=", dumpfile
);
3135 show_expr (i
->iomsg
);
3139 fputs (" IOSTAT=", dumpfile
);
3140 show_expr (i
->iostat
);
3144 fputs (" EXIST=", dumpfile
);
3145 show_expr (i
->exist
);
3149 fputs (" OPENED=", dumpfile
);
3150 show_expr (i
->opened
);
3154 fputs (" NUMBER=", dumpfile
);
3155 show_expr (i
->number
);
3159 fputs (" NAMED=", dumpfile
);
3160 show_expr (i
->named
);
3164 fputs (" NAME=", dumpfile
);
3165 show_expr (i
->name
);
3169 fputs (" ACCESS=", dumpfile
);
3170 show_expr (i
->access
);
3174 fputs (" SEQUENTIAL=", dumpfile
);
3175 show_expr (i
->sequential
);
3180 fputs (" DIRECT=", dumpfile
);
3181 show_expr (i
->direct
);
3185 fputs (" FORM=", dumpfile
);
3186 show_expr (i
->form
);
3190 fputs (" FORMATTED", dumpfile
);
3191 show_expr (i
->formatted
);
3195 fputs (" UNFORMATTED=", dumpfile
);
3196 show_expr (i
->unformatted
);
3200 fputs (" RECL=", dumpfile
);
3201 show_expr (i
->recl
);
3205 fputs (" NEXTREC=", dumpfile
);
3206 show_expr (i
->nextrec
);
3210 fputs (" BLANK=", dumpfile
);
3211 show_expr (i
->blank
);
3215 fputs (" POSITION=", dumpfile
);
3216 show_expr (i
->position
);
3220 fputs (" ACTION=", dumpfile
);
3221 show_expr (i
->action
);
3225 fputs (" READ=", dumpfile
);
3226 show_expr (i
->read
);
3230 fputs (" WRITE=", dumpfile
);
3231 show_expr (i
->write
);
3235 fputs (" READWRITE=", dumpfile
);
3236 show_expr (i
->readwrite
);
3240 fputs (" DELIM=", dumpfile
);
3241 show_expr (i
->delim
);
3245 fputs (" PAD=", dumpfile
);
3250 fputs (" CONVERT=", dumpfile
);
3251 show_expr (i
->convert
);
3253 if (i
->asynchronous
)
3255 fputs (" ASYNCHRONOUS=", dumpfile
);
3256 show_expr (i
->asynchronous
);
3260 fputs (" DECIMAL=", dumpfile
);
3261 show_expr (i
->decimal
);
3265 fputs (" ENCODING=", dumpfile
);
3266 show_expr (i
->encoding
);
3270 fputs (" PENDING=", dumpfile
);
3271 show_expr (i
->pending
);
3275 fputs (" ROUND=", dumpfile
);
3276 show_expr (i
->round
);
3280 fputs (" SIGN=", dumpfile
);
3281 show_expr (i
->sign
);
3285 fputs (" SIZE=", dumpfile
);
3286 show_expr (i
->size
);
3290 fputs (" ID=", dumpfile
);
3295 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
3299 fputs ("IOLENGTH ", dumpfile
);
3300 show_expr (c
->expr1
);
3305 fputs ("READ", dumpfile
);
3309 fputs ("WRITE", dumpfile
);
3315 fputs (" UNIT=", dumpfile
);
3316 show_expr (dt
->io_unit
);
3319 if (dt
->format_expr
)
3321 fputs (" FMT=", dumpfile
);
3322 show_expr (dt
->format_expr
);
3325 if (dt
->format_label
!= NULL
)
3326 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
3328 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
3332 fputs (" IOMSG=", dumpfile
);
3333 show_expr (dt
->iomsg
);
3337 fputs (" IOSTAT=", dumpfile
);
3338 show_expr (dt
->iostat
);
3342 fputs (" SIZE=", dumpfile
);
3343 show_expr (dt
->size
);
3347 fputs (" REC=", dumpfile
);
3348 show_expr (dt
->rec
);
3352 fputs (" ADVANCE=", dumpfile
);
3353 show_expr (dt
->advance
);
3357 fputs (" ID=", dumpfile
);
3362 fputs (" POS=", dumpfile
);
3363 show_expr (dt
->pos
);
3365 if (dt
->asynchronous
)
3367 fputs (" ASYNCHRONOUS=", dumpfile
);
3368 show_expr (dt
->asynchronous
);
3372 fputs (" BLANK=", dumpfile
);
3373 show_expr (dt
->blank
);
3377 fputs (" DECIMAL=", dumpfile
);
3378 show_expr (dt
->decimal
);
3382 fputs (" DELIM=", dumpfile
);
3383 show_expr (dt
->delim
);
3387 fputs (" PAD=", dumpfile
);
3388 show_expr (dt
->pad
);
3392 fputs (" ROUND=", dumpfile
);
3393 show_expr (dt
->round
);
3397 fputs (" SIGN=", dumpfile
);
3398 show_expr (dt
->sign
);
3402 for (c
= c
->block
->next
; c
; c
= c
->next
)
3403 show_code_node (level
+ (c
->next
!= NULL
), c
);
3407 fputs ("TRANSFER ", dumpfile
);
3408 show_expr (c
->expr1
);
3412 fputs ("DT_END", dumpfile
);
3415 if (dt
->err
!= NULL
)
3416 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
3417 if (dt
->end
!= NULL
)
3418 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
3419 if (dt
->eor
!= NULL
)
3420 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
3424 fputs ("WAIT", dumpfile
);
3426 if (c
->ext
.wait
!= NULL
)
3428 gfc_wait
*wait
= c
->ext
.wait
;
3431 fputs (" UNIT=", dumpfile
);
3432 show_expr (wait
->unit
);
3436 fputs (" IOSTAT=", dumpfile
);
3437 show_expr (wait
->iostat
);
3441 fputs (" IOMSG=", dumpfile
);
3442 show_expr (wait
->iomsg
);
3446 fputs (" ID=", dumpfile
);
3447 show_expr (wait
->id
);
3450 fprintf (dumpfile
, " ERR=%d", wait
->err
->value
);
3452 fprintf (dumpfile
, " END=%d", wait
->end
->value
);
3454 fprintf (dumpfile
, " EOR=%d", wait
->eor
->value
);
3458 case EXEC_OACC_PARALLEL_LOOP
:
3459 case EXEC_OACC_PARALLEL
:
3460 case EXEC_OACC_KERNELS_LOOP
:
3461 case EXEC_OACC_KERNELS
:
3462 case EXEC_OACC_SERIAL_LOOP
:
3463 case EXEC_OACC_SERIAL
:
3464 case EXEC_OACC_DATA
:
3465 case EXEC_OACC_HOST_DATA
:
3466 case EXEC_OACC_LOOP
:
3467 case EXEC_OACC_UPDATE
:
3468 case EXEC_OACC_WAIT
:
3469 case EXEC_OACC_CACHE
:
3470 case EXEC_OACC_ENTER_DATA
:
3471 case EXEC_OACC_EXIT_DATA
:
3472 case EXEC_OMP_ALLOCATE
:
3473 case EXEC_OMP_ALLOCATORS
:
3474 case EXEC_OMP_ASSUME
:
3475 case EXEC_OMP_ATOMIC
:
3476 case EXEC_OMP_CANCEL
:
3477 case EXEC_OMP_CANCELLATION_POINT
:
3478 case EXEC_OMP_BARRIER
:
3479 case EXEC_OMP_CRITICAL
:
3480 case EXEC_OMP_DEPOBJ
:
3481 case EXEC_OMP_DISTRIBUTE
:
3482 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
3483 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
3484 case EXEC_OMP_DISTRIBUTE_SIMD
:
3486 case EXEC_OMP_DO_SIMD
:
3487 case EXEC_OMP_ERROR
:
3488 case EXEC_OMP_FLUSH
:
3490 case EXEC_OMP_MASKED
:
3491 case EXEC_OMP_MASKED_TASKLOOP
:
3492 case EXEC_OMP_MASKED_TASKLOOP_SIMD
:
3493 case EXEC_OMP_MASTER
:
3494 case EXEC_OMP_MASTER_TASKLOOP
:
3495 case EXEC_OMP_MASTER_TASKLOOP_SIMD
:
3496 case EXEC_OMP_ORDERED
:
3497 case EXEC_OMP_PARALLEL
:
3498 case EXEC_OMP_PARALLEL_DO
:
3499 case EXEC_OMP_PARALLEL_DO_SIMD
:
3500 case EXEC_OMP_PARALLEL_LOOP
:
3501 case EXEC_OMP_PARALLEL_MASKED
:
3502 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
3503 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
3504 case EXEC_OMP_PARALLEL_MASTER
:
3505 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
3506 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
3507 case EXEC_OMP_PARALLEL_SECTIONS
:
3508 case EXEC_OMP_PARALLEL_WORKSHARE
:
3510 case EXEC_OMP_SCOPE
:
3511 case EXEC_OMP_SECTIONS
:
3513 case EXEC_OMP_SINGLE
:
3514 case EXEC_OMP_TARGET
:
3515 case EXEC_OMP_TARGET_DATA
:
3516 case EXEC_OMP_TARGET_ENTER_DATA
:
3517 case EXEC_OMP_TARGET_EXIT_DATA
:
3518 case EXEC_OMP_TARGET_PARALLEL
:
3519 case EXEC_OMP_TARGET_PARALLEL_DO
:
3520 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
3521 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
3522 case EXEC_OMP_TARGET_SIMD
:
3523 case EXEC_OMP_TARGET_TEAMS
:
3524 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
3525 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3526 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3527 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
3528 case EXEC_OMP_TARGET_TEAMS_LOOP
:
3529 case EXEC_OMP_TARGET_UPDATE
:
3531 case EXEC_OMP_TASKGROUP
:
3532 case EXEC_OMP_TASKLOOP
:
3533 case EXEC_OMP_TASKLOOP_SIMD
:
3534 case EXEC_OMP_TASKWAIT
:
3535 case EXEC_OMP_TASKYIELD
:
3536 case EXEC_OMP_TEAMS
:
3537 case EXEC_OMP_TEAMS_DISTRIBUTE
:
3538 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3539 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3540 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
3541 case EXEC_OMP_TEAMS_LOOP
:
3542 case EXEC_OMP_WORKSHARE
:
3543 show_omp_node (level
, c
);
3547 gfc_internal_error ("show_code_node(): Bad statement code");
3552 /* Show an equivalence chain. */
3555 show_equiv (gfc_equiv
*eq
)
3558 fputs ("Equivalence: ", dumpfile
);
3561 show_expr (eq
->expr
);
3564 fputs (", ", dumpfile
);
3569 /* Show a freakin' whole namespace. */
3572 show_namespace (gfc_namespace
*ns
)
3574 gfc_interface
*intr
;
3575 gfc_namespace
*save
;
3581 save
= gfc_current_ns
;
3584 fputs ("Namespace:", dumpfile
);
3590 while (i
< GFC_LETTERS
- 1
3591 && gfc_compare_types (&ns
->default_type
[i
+1],
3592 &ns
->default_type
[l
]))
3596 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
3598 fprintf (dumpfile
, " %c: ", l
+'A');
3600 show_typespec(&ns
->default_type
[l
]);
3602 } while (i
< GFC_LETTERS
);
3604 if (ns
->proc_name
!= NULL
)
3607 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
3611 gfc_current_ns
= ns
;
3612 gfc_traverse_symtree (ns
->common_root
, show_common
);
3614 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
3616 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
3618 /* User operator interfaces */
3624 fprintf (dumpfile
, "Operator interfaces for %s:",
3625 gfc_op2string ((gfc_intrinsic_op
) op
));
3627 for (; intr
; intr
= intr
->next
)
3628 fprintf (dumpfile
, " %s", intr
->sym
->name
);
3631 if (ns
->uop_root
!= NULL
)
3634 fputs ("User operators:\n", dumpfile
);
3635 gfc_traverse_user_op (ns
, show_uop
);
3638 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
3641 if (ns
->oacc_declare
)
3643 struct gfc_oacc_declare
*decl
;
3644 /* Dump !$ACC DECLARE clauses. */
3645 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
3648 fprintf (dumpfile
, "!$ACC DECLARE");
3649 show_omp_clauses (decl
->clauses
);
3653 if (ns
->omp_assumes
)
3656 fprintf (dumpfile
, "!$OMP ASSUMES");
3657 show_omp_assumes (ns
->omp_assumes
);
3660 fputc ('\n', dumpfile
);
3662 fputs ("code:", dumpfile
);
3663 show_code (show_level
, ns
->code
);
3666 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
3668 fputs ("\nCONTAINS\n", dumpfile
);
3670 show_namespace (ns
);
3674 fputc ('\n', dumpfile
);
3675 gfc_current_ns
= save
;
3679 /* Main function for dumping a parse tree. */
3682 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
3685 show_namespace (ns
);
3688 /* This part writes BIND(C) definition for use in external C programs. */
3690 static void write_interop_decl (gfc_symbol
*);
3691 static void write_proc (gfc_symbol
*, bool);
3694 gfc_dump_c_prototypes (gfc_namespace
*ns
, FILE *file
)
3697 gfc_get_errors (NULL
, &error_count
);
3698 if (error_count
!= 0)
3701 gfc_traverse_ns (ns
, write_interop_decl
);
3704 /* Loop over all global symbols, writing out their declarations. */
3707 gfc_dump_external_c_prototypes (FILE * file
)
3711 _("/* Prototypes for external procedures generated from %s\n"
3712 " by GNU Fortran %s%s.\n\n"
3713 " Use of this interface is discouraged, consider using the\n"
3714 " BIND(C) feature of standard Fortran instead. */\n\n"),
3715 gfc_source_file
, pkgversion_string
, version_string
);
3717 for (gfc_current_ns
= gfc_global_ns_list
; gfc_current_ns
;
3718 gfc_current_ns
= gfc_current_ns
->sibling
)
3720 gfc_symbol
*sym
= gfc_current_ns
->proc_name
;
3722 if (sym
== NULL
|| sym
->attr
.flavor
!= FL_PROCEDURE
3723 || sym
->attr
.is_bind_c
)
3726 write_proc (sym
, false);
3731 enum type_return
{ T_OK
=0, T_WARN
, T_ERROR
};
3733 /* Return the name of the type for later output. Both function pointers and
3734 void pointers will be mapped to void *. */
3736 static enum type_return
3737 get_c_type_name (gfc_typespec
*ts
, gfc_array_spec
*as
, const char **pre
,
3738 const char **type_name
, bool *asterisk
, const char **post
,
3741 static char post_buffer
[40];
3742 enum type_return ret
;
3748 *type_name
= "<error>";
3749 if (ts
->type
== BT_REAL
|| ts
->type
== BT_INTEGER
|| ts
->type
== BT_COMPLEX
)
3751 if (ts
->is_c_interop
&& ts
->interop_kind
)
3756 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3758 if (c_interop_kinds_table
[i
].f90_type
== ts
->type
3759 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3761 /* Skip over 'c_'. */
3762 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3763 if (strcmp (*type_name
, "long_long") == 0)
3764 *type_name
= "long long";
3765 if (strcmp (*type_name
, "long_double") == 0)
3766 *type_name
= "long double";
3767 if (strcmp (*type_name
, "signed_char") == 0)
3768 *type_name
= "signed char";
3769 else if (strcmp (*type_name
, "size_t") == 0)
3770 *type_name
= "ssize_t";
3771 else if (strcmp (*type_name
, "float_complex") == 0)
3772 *type_name
= "__GFORTRAN_FLOAT_COMPLEX";
3773 else if (strcmp (*type_name
, "double_complex") == 0)
3774 *type_name
= "__GFORTRAN_DOUBLE_COMPLEX";
3775 else if (strcmp (*type_name
, "long_double_complex") == 0)
3776 *type_name
= "__GFORTRAN_LONG_DOUBLE_COMPLEX";
3782 else if (ts
->type
== BT_LOGICAL
)
3784 if (ts
->is_c_interop
&& ts
->interop_kind
)
3786 *type_name
= "_Bool";
3791 /* Let's select an appropriate int, with a warning. */
3792 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3794 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3795 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3797 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3803 else if (ts
->type
== BT_CHARACTER
)
3805 if (ts
->is_c_interop
)
3807 *type_name
= "char";
3812 if (ts
->kind
== gfc_default_character_kind
)
3813 *type_name
= "char";
3815 /* Let's select an appropriate int. */
3816 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3818 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3819 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3821 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3829 else if (ts
->type
== BT_DERIVED
)
3831 if (ts
->u
.derived
->from_intmod
== INTMOD_ISO_C_BINDING
)
3833 if (strcmp (ts
->u
.derived
->name
, "c_ptr") == 0)
3834 *type_name
= "void";
3835 else if (strcmp (ts
->u
.derived
->name
, "c_funptr") == 0)
3837 *type_name
= "int ";
3853 *type_name
= ts
->u
.derived
->name
;
3858 if (ret
!= T_ERROR
&& as
)
3862 size_ok
= spec_size (as
, &sz
);
3863 gcc_assert (size_ok
== true);
3864 gmp_snprintf (post_buffer
, sizeof(post_buffer
), "[%Zd]", sz
);
3865 *post
= post_buffer
;
3871 /* Write out a declaration. */
3873 write_decl (gfc_typespec
*ts
, gfc_array_spec
*as
, const char *sym_name
,
3874 bool func_ret
, locus
*where
, bool bind_c
)
3876 const char *pre
, *type_name
, *post
;
3878 enum type_return rok
;
3880 rok
= get_c_type_name (ts
, as
, &pre
, &type_name
, &asterisk
, &post
, func_ret
);
3883 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3884 gfc_typename (ts
), where
);
3885 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
3889 fputs (type_name
, dumpfile
);
3890 fputs (pre
, dumpfile
);
3892 fputs ("*", dumpfile
);
3894 fputs (sym_name
, dumpfile
);
3895 fputs (post
, dumpfile
);
3897 if (rok
== T_WARN
&& bind_c
)
3898 fprintf (dumpfile
," /* WARNING: Converting '%s' to interoperable type */",
3902 /* Write out an interoperable type. It will be written as a typedef
3906 write_type (gfc_symbol
*sym
)
3910 fprintf (dumpfile
, "typedef struct %s {\n", sym
->name
);
3911 for (c
= sym
->components
; c
; c
= c
->next
)
3913 fputs (" ", dumpfile
);
3914 write_decl (&(c
->ts
), c
->as
, c
->name
, false, &sym
->declared_at
, true);
3915 fputs (";\n", dumpfile
);
3918 fprintf (dumpfile
, "} %s;\n", sym
->name
);
3921 /* Write out a variable. */
3924 write_variable (gfc_symbol
*sym
)
3926 const char *sym_name
;
3928 gcc_assert (sym
->attr
.flavor
== FL_VARIABLE
);
3930 if (sym
->binding_label
)
3931 sym_name
= sym
->binding_label
;
3933 sym_name
= sym
->name
;
3935 fputs ("extern ", dumpfile
);
3936 write_decl (&(sym
->ts
), sym
->as
, sym_name
, false, &sym
->declared_at
, true);
3937 fputs (";\n", dumpfile
);
3941 /* Write out a procedure, including its arguments. */
3943 write_proc (gfc_symbol
*sym
, bool bind_c
)
3945 const char *pre
, *type_name
, *post
;
3947 enum type_return rok
;
3948 gfc_formal_arglist
*f
;
3949 const char *sym_name
;
3950 const char *intent_in
;
3951 bool external_character
;
3953 external_character
= sym
->ts
.type
== BT_CHARACTER
&& !bind_c
;
3955 if (sym
->binding_label
)
3956 sym_name
= sym
->binding_label
;
3958 sym_name
= sym
->name
;
3960 if (sym
->ts
.type
== BT_UNKNOWN
|| external_character
)
3962 fprintf (dumpfile
, "void ");
3963 fputs (sym_name
, dumpfile
);
3966 write_decl (&(sym
->ts
), sym
->as
, sym_name
, true, &sym
->declared_at
, bind_c
);
3969 fputs ("_", dumpfile
);
3971 fputs (" (", dumpfile
);
3972 if (external_character
)
3974 fprintf (dumpfile
, "char *result_%s, size_t result_%s_len",
3975 sym_name
, sym_name
);
3977 fputs (", ", dumpfile
);
3980 for (f
= sym
->formal
; f
; f
= f
->next
)
3984 rok
= get_c_type_name (&(s
->ts
), NULL
, &pre
, &type_name
, &asterisk
,
3988 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3989 gfc_typename (&s
->ts
), &s
->declared_at
);
3990 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
3991 gfc_typename (&s
->ts
));
3998 if (s
->attr
.intent
== INTENT_IN
&& !s
->attr
.value
)
3999 intent_in
= "const ";
4003 fputs (intent_in
, dumpfile
);
4004 fputs (type_name
, dumpfile
);
4005 fputs (pre
, dumpfile
);
4007 fputs ("*", dumpfile
);
4009 fputs (s
->name
, dumpfile
);
4010 fputs (post
, dumpfile
);
4011 if (bind_c
&& rok
== T_WARN
)
4012 fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile
);
4015 fputs(", ", dumpfile
);
4018 for (f
= sym
->formal
; f
; f
= f
->next
)
4019 if (f
->sym
->ts
.type
== BT_CHARACTER
)
4020 fprintf (dumpfile
, ", size_t %s_len", f
->sym
->name
);
4022 fputs (");\n", dumpfile
);
4026 /* Write a C-interoperable declaration as a C prototype or extern
4030 write_interop_decl (gfc_symbol
*sym
)
4032 /* Only dump bind(c) entities. */
4033 if (!sym
->attr
.is_bind_c
)
4036 /* Don't dump our iso c module. */
4037 if (sym
->from_intmod
== INTMOD_ISO_C_BINDING
)
4040 if (sym
->attr
.flavor
== FL_VARIABLE
)
4041 write_variable (sym
);
4042 else if (sym
->attr
.flavor
== FL_DERIVED
)
4044 else if (sym
->attr
.flavor
== FL_PROCEDURE
)
4045 write_proc (sym
, true);
4048 /* This section deals with dumping the global symbol tree. */
4050 /* Callback function for printing out the contents of the tree. */
4053 show_global_symbol (gfc_gsymbol
*gsym
, void *f_data
)
4056 out
= (FILE *) f_data
;
4059 fprintf (out
, "name=%s", gsym
->name
);
4062 fprintf (out
, ", sym_name=%s", gsym
->sym_name
);
4065 fprintf (out
, ", mod_name=%s", gsym
->mod_name
);
4067 if (gsym
->binding_label
)
4068 fprintf (out
, ", binding_label=%s", gsym
->binding_label
);
4073 /* Show all global symbols. */
4076 gfc_dump_global_symbols (FILE *f
)
4078 if (gfc_gsym_root
== NULL
)
4079 fprintf (f
, "empty\n");
4081 gfc_traverse_gsymbol (gfc_gsym_root
, show_global_symbol
, (void *) f
);
4084 /* Show an array ref. */
4087 debug (gfc_array_ref
*ar
)
4089 FILE *tmp
= dumpfile
;
4091 show_array_ref (ar
);
4092 fputc ('\n', dumpfile
);