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 *);
58 /* Allow dumping of an expression in the debugger. */
59 void gfc_debug_expr (gfc_expr
*);
61 void debug (symbol_attribute
*attr
)
65 show_attr (attr
, NULL
);
66 fputc ('\n', dumpfile
);
70 void debug (gfc_formal_arglist
*formal
)
74 for (; formal
; formal
= formal
->next
)
76 fputc ('\n', dumpfile
);
77 show_symbol (formal
->sym
);
79 fputc ('\n', dumpfile
);
83 void debug (symbol_attribute attr
)
88 void debug (gfc_expr
*e
)
95 fputc (' ', dumpfile
);
96 show_typespec (&e
->ts
);
99 fputs ("() ", dumpfile
);
101 fputc ('\n', dumpfile
);
105 void debug (gfc_typespec
*ts
)
107 FILE *tmp
= dumpfile
;
110 fputc ('\n', dumpfile
);
114 void debug (gfc_typespec ts
)
119 void debug (gfc_ref
*p
)
121 FILE *tmp
= dumpfile
;
124 fputc ('\n', dumpfile
);
129 debug (gfc_namespace
*ns
)
131 FILE *tmp
= dumpfile
;
134 fputc ('\n', dumpfile
);
139 gfc_debug_expr (gfc_expr
*e
)
141 FILE *tmp
= dumpfile
;
144 fputc ('\n', dumpfile
);
148 /* Allow for dumping of a piece of code in the debugger. */
151 gfc_debug_code (gfc_code
*c
)
153 FILE *tmp
= dumpfile
;
156 fputc ('\n', dumpfile
);
160 void debug (gfc_symbol
*sym
)
162 FILE *tmp
= dumpfile
;
165 fputc ('\n', dumpfile
);
169 /* Do indentation for a specific level. */
172 code_indent (int level
, gfc_st_label
*label
)
177 fprintf (dumpfile
, "%-5d ", label
->value
);
179 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
180 fputc (' ', dumpfile
);
184 /* Simple indentation at the current level. This one
185 is used to show symbols. */
190 fputc ('\n', dumpfile
);
191 code_indent (show_level
, NULL
);
195 /* Show type-specific information. */
198 show_typespec (gfc_typespec
*ts
)
200 if (ts
->type
== BT_ASSUMED
)
202 fputs ("(TYPE(*))", dumpfile
);
206 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
213 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
218 show_expr (ts
->u
.cl
->length
);
219 fprintf(dumpfile
, " %d", ts
->kind
);
223 fprintf (dumpfile
, "%d", ts
->kind
);
226 if (ts
->is_c_interop
)
227 fputs (" C_INTEROP", dumpfile
);
230 fputs (" ISO_C", dumpfile
);
233 fputs (" DEFERRED", dumpfile
);
235 fputc (')', dumpfile
);
239 /* Show an actual argument list. */
242 show_actual_arglist (gfc_actual_arglist
*a
)
244 fputc ('(', dumpfile
);
246 for (; a
; a
= a
->next
)
248 fputc ('(', dumpfile
);
250 fprintf (dumpfile
, "%s = ", a
->name
);
254 fputs ("(arg not-present)", dumpfile
);
256 fputc (')', dumpfile
);
258 fputc (' ', dumpfile
);
261 fputc (')', dumpfile
);
265 /* Show a gfc_array_spec array specification structure. */
268 show_array_spec (gfc_array_spec
*as
)
275 fputs ("()", dumpfile
);
279 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
281 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
285 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
286 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
287 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
288 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
289 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
291 gfc_internal_error ("show_array_spec(): Unhandled array shape "
294 fprintf (dumpfile
, " %s ", c
);
296 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
298 show_expr (as
->lower
[i
]);
299 fputc (' ', dumpfile
);
300 show_expr (as
->upper
[i
]);
301 fputc (' ', dumpfile
);
305 fputc (')', dumpfile
);
309 /* Show a gfc_array_ref array reference structure. */
312 show_array_ref (gfc_array_ref
* ar
)
316 fputc ('(', dumpfile
);
321 fputs ("FULL", dumpfile
);
325 for (i
= 0; i
< ar
->dimen
; i
++)
327 /* There are two types of array sections: either the
328 elements are identified by an integer array ('vector'),
329 or by an index range. In the former case we only have to
330 print the start expression which contains the vector, in
331 the latter case we have to print any of lower and upper
332 bound and the stride, if they're present. */
334 if (ar
->start
[i
] != NULL
)
335 show_expr (ar
->start
[i
]);
337 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
339 fputc (':', dumpfile
);
341 if (ar
->end
[i
] != NULL
)
342 show_expr (ar
->end
[i
]);
344 if (ar
->stride
[i
] != NULL
)
346 fputc (':', dumpfile
);
347 show_expr (ar
->stride
[i
]);
351 if (i
!= ar
->dimen
- 1)
352 fputs (" , ", dumpfile
);
357 for (i
= 0; i
< ar
->dimen
; i
++)
359 show_expr (ar
->start
[i
]);
360 if (i
!= ar
->dimen
- 1)
361 fputs (" , ", dumpfile
);
366 fputs ("UNKNOWN", dumpfile
);
370 gfc_internal_error ("show_array_ref(): Unknown array reference");
373 fputc (')', dumpfile
);
374 if (ar
->codimen
== 0)
377 /* Show coarray part of the reference, if any. */
378 fputc ('[',dumpfile
);
379 for (i
= ar
->dimen
; i
< ar
->dimen
+ ar
->codimen
; i
++)
381 if (ar
->dimen_type
[i
] == DIMEN_STAR
)
383 else if (ar
->dimen_type
[i
] == DIMEN_THIS_IMAGE
)
384 fputs("THIS_IMAGE", dumpfile
);
387 show_expr (ar
->start
[i
]);
390 fputc(':', dumpfile
);
391 show_expr (ar
->end
[i
]);
394 if (i
!= ar
->dimen
+ ar
->codimen
- 1)
395 fputs (" , ", dumpfile
);
398 fputc (']',dumpfile
);
402 /* Show a list of gfc_ref structures. */
405 show_ref (gfc_ref
*p
)
407 for (; p
; p
= p
->next
)
411 show_array_ref (&p
->u
.ar
);
415 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
419 fputc ('(', dumpfile
);
420 show_expr (p
->u
.ss
.start
);
421 fputc (':', dumpfile
);
422 show_expr (p
->u
.ss
.end
);
423 fputc (')', dumpfile
);
430 fprintf (dumpfile
, " INQUIRY_KIND ");
433 fprintf (dumpfile
, " INQUIRY_LEN ");
436 fprintf (dumpfile
, " INQUIRY_RE ");
439 fprintf (dumpfile
, " INQUIRY_IM ");
444 gfc_internal_error ("show_ref(): Bad component code");
449 /* Display a constructor. Works recursively for array constructors. */
452 show_constructor (gfc_constructor_base base
)
455 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
457 if (c
->iterator
== NULL
)
461 fputc ('(', dumpfile
);
464 fputc (' ', dumpfile
);
465 show_expr (c
->iterator
->var
);
466 fputc ('=', dumpfile
);
467 show_expr (c
->iterator
->start
);
468 fputc (',', dumpfile
);
469 show_expr (c
->iterator
->end
);
470 fputc (',', dumpfile
);
471 show_expr (c
->iterator
->step
);
473 fputc (')', dumpfile
);
476 if (gfc_constructor_next (c
) != NULL
)
477 fputs (" , ", dumpfile
);
483 show_char_const (const gfc_char_t
*c
, gfc_charlen_t length
)
485 fputc ('\'', dumpfile
);
486 for (size_t i
= 0; i
< (size_t) length
; i
++)
489 fputs ("''", dumpfile
);
491 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
493 fputc ('\'', dumpfile
);
497 /* Show a component-call expression. */
500 show_compcall (gfc_expr
* p
)
502 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
504 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
506 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
508 show_actual_arglist (p
->value
.compcall
.actual
);
512 /* Show an expression. */
515 show_expr (gfc_expr
*p
)
522 fputs ("()", dumpfile
);
526 switch (p
->expr_type
)
529 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
534 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
535 show_constructor (p
->value
.constructor
);
536 fputc (')', dumpfile
);
540 fputs ("(/ ", dumpfile
);
541 show_constructor (p
->value
.constructor
);
542 fputs (" /)", dumpfile
);
548 fputs ("NULL()", dumpfile
);
555 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
557 if (p
->ts
.kind
!= gfc_default_integer_kind
)
558 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
562 if (p
->value
.logical
)
563 fputs (".true.", dumpfile
);
565 fputs (".false.", dumpfile
);
569 mpfr_out_str (dumpfile
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
570 if (p
->ts
.kind
!= gfc_default_real_kind
)
571 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
575 show_char_const (p
->value
.character
.string
,
576 p
->value
.character
.length
);
580 fputs ("(complex ", dumpfile
);
582 mpfr_out_str (dumpfile
, 10, 0, mpc_realref (p
->value
.complex),
584 if (p
->ts
.kind
!= gfc_default_complex_kind
)
585 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
587 fputc (' ', dumpfile
);
589 mpfr_out_str (dumpfile
, 10, 0, mpc_imagref (p
->value
.complex),
591 if (p
->ts
.kind
!= gfc_default_complex_kind
)
592 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
594 fputc (')', dumpfile
);
599 fputs ("b'", dumpfile
);
600 else if (p
->boz
.rdx
== 8)
601 fputs ("o'", dumpfile
);
603 fputs ("z'", dumpfile
);
604 fprintf (dumpfile
, "%s'", p
->boz
.str
);
608 fprintf (dumpfile
, HOST_WIDE_INT_PRINT_DEC
"H",
609 p
->representation
.length
);
610 c
= p
->representation
.string
;
611 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
613 fputc (*c
, dumpfile
);
618 fputs ("???", dumpfile
);
622 if (p
->representation
.string
)
624 fputs (" {", dumpfile
);
625 c
= p
->representation
.string
;
626 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
628 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
629 if (i
< p
->representation
.length
- 1)
630 fputc (',', dumpfile
);
632 fputc ('}', dumpfile
);
638 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
639 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
640 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
645 fputc ('(', dumpfile
);
646 switch (p
->value
.op
.op
)
648 case INTRINSIC_UPLUS
:
649 fputs ("U+ ", dumpfile
);
651 case INTRINSIC_UMINUS
:
652 fputs ("U- ", dumpfile
);
655 fputs ("+ ", dumpfile
);
657 case INTRINSIC_MINUS
:
658 fputs ("- ", dumpfile
);
660 case INTRINSIC_TIMES
:
661 fputs ("* ", dumpfile
);
663 case INTRINSIC_DIVIDE
:
664 fputs ("/ ", dumpfile
);
666 case INTRINSIC_POWER
:
667 fputs ("** ", dumpfile
);
669 case INTRINSIC_CONCAT
:
670 fputs ("// ", dumpfile
);
673 fputs ("AND ", dumpfile
);
676 fputs ("OR ", dumpfile
);
679 fputs ("EQV ", dumpfile
);
682 fputs ("NEQV ", dumpfile
);
685 case INTRINSIC_EQ_OS
:
686 fputs ("== ", dumpfile
);
689 case INTRINSIC_NE_OS
:
690 fputs ("/= ", dumpfile
);
693 case INTRINSIC_GT_OS
:
694 fputs ("> ", dumpfile
);
697 case INTRINSIC_GE_OS
:
698 fputs (">= ", dumpfile
);
701 case INTRINSIC_LT_OS
:
702 fputs ("< ", dumpfile
);
705 case INTRINSIC_LE_OS
:
706 fputs ("<= ", dumpfile
);
709 fputs ("NOT ", dumpfile
);
711 case INTRINSIC_PARENTHESES
:
712 fputs ("parens ", dumpfile
);
717 ("show_expr(): Bad intrinsic in expression");
720 show_expr (p
->value
.op
.op1
);
724 fputc (' ', dumpfile
);
725 show_expr (p
->value
.op
.op2
);
728 fputc (')', dumpfile
);
732 if (p
->value
.function
.name
== NULL
)
734 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
735 if (gfc_is_proc_ptr_comp (p
))
737 fputc ('[', dumpfile
);
738 show_actual_arglist (p
->value
.function
.actual
);
739 fputc (']', dumpfile
);
743 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
744 if (gfc_is_proc_ptr_comp (p
))
746 fputc ('[', dumpfile
);
747 fputc ('[', dumpfile
);
748 show_actual_arglist (p
->value
.function
.actual
);
749 fputc (']', dumpfile
);
750 fputc (']', dumpfile
);
760 gfc_internal_error ("show_expr(): Don't know how to show expr");
764 /* Show symbol attributes. The flavor and intent are followed by
765 whatever single bit attributes are present. */
768 show_attr (symbol_attribute
*attr
, const char * module
)
770 fputc ('(', dumpfile
);
771 if (attr
->flavor
!= FL_UNKNOWN
)
773 if (attr
->flavor
== FL_DERIVED
&& attr
->pdt_template
)
774 fputs ("PDT-TEMPLATE ", dumpfile
);
776 fprintf (dumpfile
, "%s ", gfc_code2string (flavors
, attr
->flavor
));
778 if (attr
->access
!= ACCESS_UNKNOWN
)
779 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
780 if (attr
->proc
!= PROC_UNKNOWN
)
781 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
782 if (attr
->save
!= SAVE_NONE
)
783 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
785 if (attr
->artificial
)
786 fputs (" ARTIFICIAL", dumpfile
);
787 if (attr
->allocatable
)
788 fputs (" ALLOCATABLE", dumpfile
);
789 if (attr
->asynchronous
)
790 fputs (" ASYNCHRONOUS", dumpfile
);
791 if (attr
->codimension
)
792 fputs (" CODIMENSION", dumpfile
);
794 fputs (" DIMENSION", dumpfile
);
795 if (attr
->contiguous
)
796 fputs (" CONTIGUOUS", dumpfile
);
798 fputs (" EXTERNAL", dumpfile
);
800 fputs (" INTRINSIC", dumpfile
);
802 fputs (" OPTIONAL", dumpfile
);
804 fputs (" KIND", dumpfile
);
806 fputs (" LEN", dumpfile
);
808 fputs (" POINTER", dumpfile
);
809 if (attr
->subref_array_pointer
)
810 fputs (" SUBREF-ARRAY-POINTER", dumpfile
);
811 if (attr
->cray_pointer
)
812 fputs (" CRAY-POINTER", dumpfile
);
813 if (attr
->cray_pointee
)
814 fputs (" CRAY-POINTEE", dumpfile
);
815 if (attr
->is_protected
)
816 fputs (" PROTECTED", dumpfile
);
818 fputs (" VALUE", dumpfile
);
820 fputs (" VOLATILE", dumpfile
);
821 if (attr
->threadprivate
)
822 fputs (" THREADPRIVATE", dumpfile
);
824 fputs (" TARGET", dumpfile
);
827 fputs (" DUMMY", dumpfile
);
828 if (attr
->intent
!= INTENT_UNKNOWN
)
829 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
833 fputs (" RESULT", dumpfile
);
835 fputs (" ENTRY", dumpfile
);
836 if (attr
->entry_master
)
837 fputs (" ENTRY-MASTER", dumpfile
);
838 if (attr
->mixed_entry_master
)
839 fputs (" MIXED-ENTRY-MASTER", dumpfile
);
841 fputs (" BIND(C)", dumpfile
);
844 fputs (" DATA", dumpfile
);
847 fputs (" USE-ASSOC", dumpfile
);
849 fprintf (dumpfile
, "(%s)", module
);
852 if (attr
->in_namelist
)
853 fputs (" IN-NAMELIST", dumpfile
);
855 fputs (" IN-COMMON", dumpfile
);
858 fputs (" ABSTRACT", dumpfile
);
860 fputs (" FUNCTION", dumpfile
);
861 if (attr
->subroutine
)
862 fputs (" SUBROUTINE", dumpfile
);
863 if (attr
->implicit_type
)
864 fputs (" IMPLICIT-TYPE", dumpfile
);
867 fputs (" SEQUENCE", dumpfile
);
868 if (attr
->alloc_comp
)
869 fputs (" ALLOC-COMP", dumpfile
);
870 if (attr
->pointer_comp
)
871 fputs (" POINTER-COMP", dumpfile
);
872 if (attr
->proc_pointer_comp
)
873 fputs (" PROC-POINTER-COMP", dumpfile
);
874 if (attr
->private_comp
)
875 fputs (" PRIVATE-COMP", dumpfile
);
877 fputs (" ZERO-COMP", dumpfile
);
878 if (attr
->coarray_comp
)
879 fputs (" COARRAY-COMP", dumpfile
);
881 fputs (" LOCK-COMP", dumpfile
);
882 if (attr
->event_comp
)
883 fputs (" EVENT-COMP", dumpfile
);
884 if (attr
->defined_assign_comp
)
885 fputs (" DEFINED-ASSIGNED-COMP", dumpfile
);
886 if (attr
->unlimited_polymorphic
)
887 fputs (" UNLIMITED-POLYMORPHIC", dumpfile
);
888 if (attr
->has_dtio_procs
)
889 fputs (" HAS-DTIO-PROCS", dumpfile
);
891 fputs (" CAF-TOKEN", dumpfile
);
892 if (attr
->select_type_temporary
)
893 fputs (" SELECT-TYPE-TEMPORARY", dumpfile
);
894 if (attr
->associate_var
)
895 fputs (" ASSOCIATE-VAR", dumpfile
);
897 fputs (" PDT-KIND", dumpfile
);
899 fputs (" PDT-LEN", dumpfile
);
901 fputs (" PDT-TYPE", dumpfile
);
903 fputs (" PDT-ARRAY", dumpfile
);
904 if (attr
->pdt_string
)
905 fputs (" PDT-STRING", dumpfile
);
906 if (attr
->omp_udr_artificial_var
)
907 fputs (" OMP-UDR-ARTIFICIAL-VAR", dumpfile
);
908 if (attr
->omp_declare_target
)
909 fputs (" OMP-DECLARE-TARGET", dumpfile
);
910 if (attr
->omp_declare_target_link
)
911 fputs (" OMP-DECLARE-TARGET-LINK", dumpfile
);
913 fputs (" ELEMENTAL", dumpfile
);
915 fputs (" PURE", dumpfile
);
916 if (attr
->implicit_pure
)
917 fputs (" IMPLICIT-PURE", dumpfile
);
919 fputs (" RECURSIVE", dumpfile
);
920 if (attr
->unmaskable
)
921 fputs (" UNMASKABKE", dumpfile
);
923 fputs (" MASKED", dumpfile
);
925 fputs (" CONTAINED", dumpfile
);
927 fputs (" MOD-PROC", dumpfile
);
928 if (attr
->module_procedure
)
929 fputs (" MODULE-PROCEDURE", dumpfile
);
930 if (attr
->public_used
)
931 fputs (" PUBLIC_USED", dumpfile
);
932 if (attr
->array_outer_dependency
)
933 fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile
);
935 fputs (" NORETURN", dumpfile
);
936 if (attr
->always_explicit
)
937 fputs (" ALWAYS-EXPLICIT", dumpfile
);
938 if (attr
->is_main_program
)
939 fputs (" IS-MAIN-PROGRAM", dumpfile
);
940 if (attr
->oacc_routine_nohost
)
941 fputs (" OACC-ROUTINE-NOHOST", dumpfile
);
943 /* FIXME: Still missing are oacc_routine_lop and ext_attr. */
944 fputc (')', dumpfile
);
948 /* Show components of a derived type. */
951 show_components (gfc_symbol
*sym
)
955 for (c
= sym
->components
; c
; c
= c
->next
)
958 fprintf (dumpfile
, "(%s ", c
->name
);
959 show_typespec (&c
->ts
);
962 fputs (" kind_expr: ", dumpfile
);
963 show_expr (c
->kind_expr
);
967 fputs ("PDT parameters", dumpfile
);
968 show_actual_arglist (c
->param_list
);
971 if (c
->attr
.allocatable
)
972 fputs (" ALLOCATABLE", dumpfile
);
973 if (c
->attr
.pdt_kind
)
974 fputs (" KIND", dumpfile
);
976 fputs (" LEN", dumpfile
);
978 fputs (" POINTER", dumpfile
);
979 if (c
->attr
.proc_pointer
)
980 fputs (" PPC", dumpfile
);
981 if (c
->attr
.dimension
)
982 fputs (" DIMENSION", dumpfile
);
983 fputc (' ', dumpfile
);
984 show_array_spec (c
->as
);
986 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
987 fputc (')', dumpfile
);
989 fputc (' ', dumpfile
);
994 /* Show the f2k_derived namespace with procedure bindings. */
997 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
1002 fputs ("GENERIC", dumpfile
);
1005 fputs ("PROCEDURE, ", dumpfile
);
1007 fputs ("NOPASS", dumpfile
);
1011 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
1013 fputs ("PASS", dumpfile
);
1015 if (tb
->non_overridable
)
1016 fputs (", NON_OVERRIDABLE", dumpfile
);
1019 if (tb
->access
== ACCESS_PUBLIC
)
1020 fputs (", PUBLIC", dumpfile
);
1022 fputs (", PRIVATE", dumpfile
);
1024 fprintf (dumpfile
, " :: %s => ", name
);
1029 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
1031 fputs (g
->specific_st
->name
, dumpfile
);
1033 fputs (", ", dumpfile
);
1037 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
1041 show_typebound_symtree (gfc_symtree
* st
)
1043 gcc_assert (st
->n
.tb
);
1044 show_typebound_proc (st
->n
.tb
, st
->name
);
1048 show_f2k_derived (gfc_namespace
* f2k
)
1054 fputs ("Procedure bindings:", dumpfile
);
1057 /* Finalizer bindings. */
1058 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
1061 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
1064 /* Type-bound procedures. */
1065 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
1070 fputs ("Operator bindings:", dumpfile
);
1073 /* User-defined operators. */
1074 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
1076 /* Intrinsic operators. */
1077 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
1079 show_typebound_proc (f2k
->tb_op
[op
],
1080 gfc_op2string ((gfc_intrinsic_op
) op
));
1086 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
1087 show the interface. Information needed to reconstruct the list of
1088 specific interfaces associated with a generic symbol is done within
1092 show_symbol (gfc_symbol
*sym
)
1094 gfc_formal_arglist
*formal
;
1095 gfc_interface
*intr
;
1101 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
1102 len
= strlen (sym
->name
);
1103 for (i
=len
; i
<12; i
++)
1104 fputc(' ', dumpfile
);
1106 if (sym
->binding_label
)
1107 fprintf (dumpfile
,"|| binding_label: '%s' ", sym
->binding_label
);
1112 fputs ("type spec : ", dumpfile
);
1113 show_typespec (&sym
->ts
);
1116 fputs ("attributes: ", dumpfile
);
1117 show_attr (&sym
->attr
, sym
->module
);
1122 fputs ("value: ", dumpfile
);
1123 show_expr (sym
->value
);
1126 if (sym
->ts
.type
!= BT_CLASS
&& sym
->as
)
1129 fputs ("Array spec:", dumpfile
);
1130 show_array_spec (sym
->as
);
1132 else if (sym
->ts
.type
== BT_CLASS
&& CLASS_DATA (sym
)->as
)
1135 fputs ("Array spec:", dumpfile
);
1136 show_array_spec (CLASS_DATA (sym
)->as
);
1142 fputs ("Generic interfaces:", dumpfile
);
1143 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
1144 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1150 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
1153 if (sym
->components
)
1156 fputs ("components: ", dumpfile
);
1157 show_components (sym
);
1160 if (sym
->f2k_derived
)
1163 if (sym
->hash_value
)
1164 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
1165 show_f2k_derived (sym
->f2k_derived
);
1171 fputs ("Formal arglist:", dumpfile
);
1173 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
1175 if (formal
->sym
!= NULL
)
1176 fprintf (dumpfile
, " %s", formal
->sym
->name
);
1178 fputs (" [Alt Return]", dumpfile
);
1182 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
1183 && sym
->attr
.proc
!= PROC_ST_FUNCTION
1184 && !sym
->attr
.entry
)
1187 fputs ("Formal namespace", dumpfile
);
1188 show_namespace (sym
->formal_ns
);
1191 if (sym
->attr
.flavor
== FL_VARIABLE
1195 fputs ("PDT parameters", dumpfile
);
1196 show_actual_arglist (sym
->param_list
);
1199 if (sym
->attr
.flavor
== FL_NAMELIST
)
1203 fputs ("variables : ", dumpfile
);
1204 for (nl
= sym
->namelist
; nl
; nl
= nl
->next
)
1205 fprintf (dumpfile
, " %s",nl
->sym
->name
);
1212 /* Show a user-defined operator. Just prints an operator
1213 and the name of the associated subroutine, really. */
1216 show_uop (gfc_user_op
*uop
)
1218 gfc_interface
*intr
;
1221 fprintf (dumpfile
, "%s:", uop
->name
);
1223 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
1224 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1228 /* Workhorse function for traversing the user operator symtree. */
1231 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
1236 (*func
) (st
->n
.uop
);
1238 traverse_uop (st
->left
, func
);
1239 traverse_uop (st
->right
, func
);
1243 /* Traverse the tree of user operator nodes. */
1246 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
1248 traverse_uop (ns
->uop_root
, func
);
1252 /* Function to display a common block. */
1255 show_common (gfc_symtree
*st
)
1260 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
1262 s
= st
->n
.common
->head
;
1265 fprintf (dumpfile
, "%s", s
->name
);
1268 fputs (", ", dumpfile
);
1270 fputc ('\n', dumpfile
);
1274 /* Worker function to display the symbol tree. */
1277 show_symtree (gfc_symtree
*st
)
1283 len
= strlen(st
->name
);
1284 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
1286 for (i
=len
; i
<12; i
++)
1287 fputc(' ', dumpfile
);
1290 fputs( " Ambiguous", dumpfile
);
1292 if (st
->n
.sym
->ns
!= gfc_current_ns
)
1293 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1294 st
->n
.sym
->ns
->proc_name
->name
);
1296 show_symbol (st
->n
.sym
);
1300 /******************* Show gfc_code structures **************/
1303 /* Show a list of code structures. Mutually recursive with
1304 show_code_node(). */
1307 show_code (int level
, gfc_code
*c
)
1309 for (; c
; c
= c
->next
)
1310 show_code_node (level
, c
);
1314 show_iterator (gfc_namespace
*ns
)
1316 for (gfc_symbol
*sym
= ns
->omp_affinity_iterators
; sym
; sym
= sym
->tlink
)
1319 if (sym
!= ns
->omp_affinity_iterators
)
1320 fputc (',', dumpfile
);
1321 fputs (sym
->name
, dumpfile
);
1322 fputc ('=', dumpfile
);
1323 c
= gfc_constructor_first (sym
->value
->value
.constructor
);
1324 show_expr (c
->expr
);
1325 fputc (':', dumpfile
);
1326 c
= gfc_constructor_next (c
);
1327 show_expr (c
->expr
);
1328 c
= gfc_constructor_next (c
);
1331 fputc (':', dumpfile
);
1332 show_expr (c
->expr
);
1338 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1340 gfc_namespace
*ns_iter
= NULL
, *ns_curr
= gfc_current_ns
;
1341 gfc_omp_namelist
*n2
= n
;
1342 for (; n
; n
= n
->next
)
1344 gfc_current_ns
= ns_curr
;
1345 if (list_type
== OMP_LIST_AFFINITY
|| list_type
== OMP_LIST_DEPEND
)
1347 gfc_current_ns
= n
->u2
.ns
? n
->u2
.ns
: ns_curr
;
1348 if (n
->u2
.ns
!= ns_iter
)
1352 fputs (") ", dumpfile
);
1353 if (list_type
== OMP_LIST_AFFINITY
)
1354 fputs ("AFFINITY (", dumpfile
);
1355 else if (n
->u
.depend_doacross_op
== OMP_DOACROSS_SINK_FIRST
)
1356 fputs ("DOACROSS (", dumpfile
);
1358 fputs ("DEPEND (", dumpfile
);
1362 fputs ("ITERATOR(", dumpfile
);
1363 show_iterator (n
->u2
.ns
);
1364 fputc (')', dumpfile
);
1365 fputc (list_type
== OMP_LIST_AFFINITY
? ':' : ',', dumpfile
);
1370 if (list_type
== OMP_LIST_ALLOCATE
)
1374 fputs ("allocator(", dumpfile
);
1375 show_expr (n
->expr
);
1376 fputc (')', dumpfile
);
1378 if (n
->expr
&& n
->u
.align
)
1379 fputc (',', dumpfile
);
1382 fputs ("allocator(", dumpfile
);
1383 show_expr (n
->u
.align
);
1384 fputc (')', dumpfile
);
1386 if (n
->expr
|| n
->u
.align
)
1387 fputc (':', dumpfile
);
1388 fputs (n
->sym
->name
, dumpfile
);
1390 fputs (") ALLOCATE(", dumpfile
);
1393 if (list_type
== OMP_LIST_REDUCTION
)
1394 switch (n
->u
.reduction_op
)
1396 case OMP_REDUCTION_PLUS
:
1397 case OMP_REDUCTION_TIMES
:
1398 case OMP_REDUCTION_MINUS
:
1399 case OMP_REDUCTION_AND
:
1400 case OMP_REDUCTION_OR
:
1401 case OMP_REDUCTION_EQV
:
1402 case OMP_REDUCTION_NEQV
:
1403 fprintf (dumpfile
, "%s:",
1404 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1406 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1407 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1408 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1409 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1410 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1411 case OMP_REDUCTION_USER
:
1413 fprintf (dumpfile
, "%s:", n
->u2
.udr
->udr
->name
);
1417 else if (list_type
== OMP_LIST_DEPEND
)
1418 switch (n
->u
.depend_doacross_op
)
1420 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1421 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1422 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1423 case OMP_DEPEND_INOUTSET
: fputs ("inoutset:", dumpfile
); break;
1424 case OMP_DEPEND_DEPOBJ
: fputs ("depobj:", dumpfile
); break;
1425 case OMP_DEPEND_MUTEXINOUTSET
:
1426 fputs ("mutexinoutset:", dumpfile
);
1428 case OMP_DEPEND_SINK_FIRST
:
1429 case OMP_DOACROSS_SINK_FIRST
:
1430 fputs ("sink:", dumpfile
);
1434 fputs ("omp_cur_iteration", dumpfile
);
1436 fprintf (dumpfile
, "%s", n
->sym
->name
);
1439 fputc ('+', dumpfile
);
1440 show_expr (n
->expr
);
1442 if (n
->next
== NULL
)
1444 else if (n
->next
->u
.depend_doacross_op
!= OMP_DOACROSS_SINK
)
1446 if (n
->next
->u
.depend_doacross_op
1447 == OMP_DOACROSS_SINK_FIRST
)
1448 fputs (") DOACROSS(", dumpfile
);
1450 fputs (") DEPEND(", dumpfile
);
1453 fputc (',', dumpfile
);
1459 else if (list_type
== OMP_LIST_MAP
)
1460 switch (n
->u
.map_op
)
1462 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1463 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1464 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1465 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1466 case OMP_MAP_ALWAYS_TO
: fputs ("always,to:", dumpfile
); break;
1467 case OMP_MAP_ALWAYS_FROM
: fputs ("always,from:", dumpfile
); break;
1468 case OMP_MAP_ALWAYS_TOFROM
: fputs ("always,tofrom:", dumpfile
); break;
1469 case OMP_MAP_DELETE
: fputs ("delete:", dumpfile
); break;
1470 case OMP_MAP_RELEASE
: fputs ("release:", dumpfile
); break;
1473 else if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.old_modifier
)
1474 switch (n
->u
.linear
.op
)
1476 case OMP_LINEAR_REF
: fputs ("ref(", dumpfile
); break;
1477 case OMP_LINEAR_VAL
: fputs ("val(", dumpfile
); break;
1478 case OMP_LINEAR_UVAL
: fputs ("uval(", dumpfile
); break;
1481 fprintf (dumpfile
, "%s", n
->sym
? n
->sym
->name
: "omp_all_memory");
1482 if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.op
!= OMP_LINEAR_DEFAULT
)
1483 fputc (')', dumpfile
);
1486 fputc (':', dumpfile
);
1487 show_expr (n
->expr
);
1490 fputc (',', dumpfile
);
1492 gfc_current_ns
= ns_curr
;
1496 show_omp_assumes (gfc_omp_assumptions
*assume
)
1498 for (int i
= 0; i
< assume
->n_absent
; i
++)
1500 fputs (" ABSENT (", dumpfile
);
1501 fputs (gfc_ascii_statement (assume
->absent
[i
], true), dumpfile
);
1502 fputc (')', dumpfile
);
1504 for (int i
= 0; i
< assume
->n_contains
; i
++)
1506 fputs (" CONTAINS (", dumpfile
);
1507 fputs (gfc_ascii_statement (assume
->contains
[i
], true), dumpfile
);
1508 fputc (')', dumpfile
);
1510 for (gfc_expr_list
*el
= assume
->holds
; el
; el
= el
->next
)
1512 fputs (" HOLDS (", dumpfile
);
1513 show_expr (el
->expr
);
1514 fputc (')', dumpfile
);
1516 if (assume
->no_openmp
)
1517 fputs (" NO_OPENMP", dumpfile
);
1518 if (assume
->no_openmp_routines
)
1519 fputs (" NO_OPENMP_ROUTINES", dumpfile
);
1520 if (assume
->no_parallelism
)
1521 fputs (" NO_PARALLELISM", dumpfile
);
1524 /* Show OpenMP or OpenACC clauses. */
1527 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1531 switch (omp_clauses
->cancel
)
1533 case OMP_CANCEL_UNKNOWN
:
1535 case OMP_CANCEL_PARALLEL
:
1536 fputs (" PARALLEL", dumpfile
);
1538 case OMP_CANCEL_SECTIONS
:
1539 fputs (" SECTIONS", dumpfile
);
1542 fputs (" DO", dumpfile
);
1544 case OMP_CANCEL_TASKGROUP
:
1545 fputs (" TASKGROUP", dumpfile
);
1548 if (omp_clauses
->if_expr
)
1550 fputs (" IF(", dumpfile
);
1551 show_expr (omp_clauses
->if_expr
);
1552 fputc (')', dumpfile
);
1554 if (omp_clauses
->final_expr
)
1556 fputs (" FINAL(", dumpfile
);
1557 show_expr (omp_clauses
->final_expr
);
1558 fputc (')', dumpfile
);
1560 if (omp_clauses
->num_threads
)
1562 fputs (" NUM_THREADS(", dumpfile
);
1563 show_expr (omp_clauses
->num_threads
);
1564 fputc (')', dumpfile
);
1566 if (omp_clauses
->async
)
1568 fputs (" ASYNC", dumpfile
);
1569 if (omp_clauses
->async_expr
)
1571 fputc ('(', dumpfile
);
1572 show_expr (omp_clauses
->async_expr
);
1573 fputc (')', dumpfile
);
1576 if (omp_clauses
->num_gangs_expr
)
1578 fputs (" NUM_GANGS(", dumpfile
);
1579 show_expr (omp_clauses
->num_gangs_expr
);
1580 fputc (')', dumpfile
);
1582 if (omp_clauses
->num_workers_expr
)
1584 fputs (" NUM_WORKERS(", dumpfile
);
1585 show_expr (omp_clauses
->num_workers_expr
);
1586 fputc (')', dumpfile
);
1588 if (omp_clauses
->vector_length_expr
)
1590 fputs (" VECTOR_LENGTH(", dumpfile
);
1591 show_expr (omp_clauses
->vector_length_expr
);
1592 fputc (')', dumpfile
);
1594 if (omp_clauses
->gang
)
1596 fputs (" GANG", dumpfile
);
1597 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1599 fputc ('(', dumpfile
);
1600 if (omp_clauses
->gang_num_expr
)
1602 fprintf (dumpfile
, "num:");
1603 show_expr (omp_clauses
->gang_num_expr
);
1605 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1606 fputc (',', dumpfile
);
1607 if (omp_clauses
->gang_static
)
1609 fprintf (dumpfile
, "static:");
1610 if (omp_clauses
->gang_static_expr
)
1611 show_expr (omp_clauses
->gang_static_expr
);
1613 fputc ('*', dumpfile
);
1615 fputc (')', dumpfile
);
1618 if (omp_clauses
->worker
)
1620 fputs (" WORKER", dumpfile
);
1621 if (omp_clauses
->worker_expr
)
1623 fputc ('(', dumpfile
);
1624 show_expr (omp_clauses
->worker_expr
);
1625 fputc (')', dumpfile
);
1628 if (omp_clauses
->vector
)
1630 fputs (" VECTOR", dumpfile
);
1631 if (omp_clauses
->vector_expr
)
1633 fputc ('(', dumpfile
);
1634 show_expr (omp_clauses
->vector_expr
);
1635 fputc (')', dumpfile
);
1638 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1641 switch (omp_clauses
->sched_kind
)
1643 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1644 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1645 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1646 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1647 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1651 fputs (" SCHEDULE (", dumpfile
);
1652 if (omp_clauses
->sched_simd
)
1654 if (omp_clauses
->sched_monotonic
1655 || omp_clauses
->sched_nonmonotonic
)
1656 fputs ("SIMD, ", dumpfile
);
1658 fputs ("SIMD: ", dumpfile
);
1660 if (omp_clauses
->sched_monotonic
)
1661 fputs ("MONOTONIC: ", dumpfile
);
1662 else if (omp_clauses
->sched_nonmonotonic
)
1663 fputs ("NONMONOTONIC: ", dumpfile
);
1664 fputs (type
, dumpfile
);
1665 if (omp_clauses
->chunk_size
)
1667 fputc (',', dumpfile
);
1668 show_expr (omp_clauses
->chunk_size
);
1670 fputc (')', dumpfile
);
1672 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1675 switch (omp_clauses
->default_sharing
)
1677 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1678 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1679 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1680 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1681 case OMP_DEFAULT_PRESENT
: type
= "PRESENT"; break;
1685 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1687 if (omp_clauses
->tile_list
)
1689 gfc_expr_list
*list
;
1690 fputs (" TILE(", dumpfile
);
1691 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1693 show_expr (list
->expr
);
1695 fputs (", ", dumpfile
);
1697 fputc (')', dumpfile
);
1699 if (omp_clauses
->wait_list
)
1701 gfc_expr_list
*list
;
1702 fputs (" WAIT(", dumpfile
);
1703 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1705 show_expr (list
->expr
);
1707 fputs (", ", dumpfile
);
1709 fputc (')', dumpfile
);
1711 if (omp_clauses
->seq
)
1712 fputs (" SEQ", dumpfile
);
1713 if (omp_clauses
->independent
)
1714 fputs (" INDEPENDENT", dumpfile
);
1715 if (omp_clauses
->order_concurrent
)
1717 fputs (" ORDER(", dumpfile
);
1718 if (omp_clauses
->order_unconstrained
)
1719 fputs ("UNCONSTRAINED:", dumpfile
);
1720 else if (omp_clauses
->order_reproducible
)
1721 fputs ("REPRODUCIBLE:", dumpfile
);
1722 fputs ("CONCURRENT)", dumpfile
);
1724 if (omp_clauses
->ordered
)
1726 if (omp_clauses
->orderedc
)
1727 fprintf (dumpfile
, " ORDERED(%d)", omp_clauses
->orderedc
);
1729 fputs (" ORDERED", dumpfile
);
1731 if (omp_clauses
->untied
)
1732 fputs (" UNTIED", dumpfile
);
1733 if (omp_clauses
->mergeable
)
1734 fputs (" MERGEABLE", dumpfile
);
1735 if (omp_clauses
->collapse
)
1736 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1737 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1738 if (omp_clauses
->lists
[list_type
] != NULL
1739 && list_type
!= OMP_LIST_COPYPRIVATE
)
1741 const char *type
= NULL
;
1744 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1745 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1746 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1747 case OMP_LIST_COPYPRIVATE
: type
= "COPYPRIVATE"; break;
1748 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1749 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1750 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1751 case OMP_LIST_AFFINITY
: type
= "AFFINITY"; break;
1752 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1753 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1754 case OMP_LIST_DEPEND
:
1755 if (omp_clauses
->lists
[list_type
]
1756 && (omp_clauses
->lists
[list_type
]->u
.depend_doacross_op
1757 == OMP_DOACROSS_SINK_FIRST
))
1762 case OMP_LIST_MAP
: type
= "MAP"; break;
1763 case OMP_LIST_TO
: type
= "TO"; break;
1764 case OMP_LIST_FROM
: type
= "FROM"; break;
1765 case OMP_LIST_REDUCTION
:
1766 case OMP_LIST_REDUCTION_INSCAN
:
1767 case OMP_LIST_REDUCTION_TASK
: type
= "REDUCTION"; break;
1768 case OMP_LIST_IN_REDUCTION
: type
= "IN_REDUCTION"; break;
1769 case OMP_LIST_TASK_REDUCTION
: type
= "TASK_REDUCTION"; break;
1770 case OMP_LIST_DEVICE_RESIDENT
: type
= "DEVICE_RESIDENT"; break;
1771 case OMP_LIST_ENTER
: type
= "ENTER"; break;
1772 case OMP_LIST_LINK
: type
= "LINK"; break;
1773 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1774 case OMP_LIST_CACHE
: type
= "CACHE"; break;
1775 case OMP_LIST_IS_DEVICE_PTR
: type
= "IS_DEVICE_PTR"; break;
1776 case OMP_LIST_USE_DEVICE_PTR
: type
= "USE_DEVICE_PTR"; break;
1777 case OMP_LIST_HAS_DEVICE_ADDR
: type
= "HAS_DEVICE_ADDR"; break;
1778 case OMP_LIST_USE_DEVICE_ADDR
: type
= "USE_DEVICE_ADDR"; break;
1779 case OMP_LIST_NONTEMPORAL
: type
= "NONTEMPORAL"; break;
1780 case OMP_LIST_ALLOCATE
: type
= "ALLOCATE"; break;
1781 case OMP_LIST_SCAN_IN
: type
= "INCLUSIVE"; break;
1782 case OMP_LIST_SCAN_EX
: type
= "EXCLUSIVE"; break;
1786 fprintf (dumpfile
, " %s(", type
);
1787 if (list_type
== OMP_LIST_REDUCTION_INSCAN
)
1788 fputs ("inscan, ", dumpfile
);
1789 if (list_type
== OMP_LIST_REDUCTION_TASK
)
1790 fputs ("task, ", dumpfile
);
1791 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1792 fputc (')', dumpfile
);
1794 if (omp_clauses
->safelen_expr
)
1796 fputs (" SAFELEN(", dumpfile
);
1797 show_expr (omp_clauses
->safelen_expr
);
1798 fputc (')', dumpfile
);
1800 if (omp_clauses
->simdlen_expr
)
1802 fputs (" SIMDLEN(", dumpfile
);
1803 show_expr (omp_clauses
->simdlen_expr
);
1804 fputc (')', dumpfile
);
1806 if (omp_clauses
->inbranch
)
1807 fputs (" INBRANCH", dumpfile
);
1808 if (omp_clauses
->notinbranch
)
1809 fputs (" NOTINBRANCH", dumpfile
);
1810 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1813 switch (omp_clauses
->proc_bind
)
1815 case OMP_PROC_BIND_PRIMARY
: type
= "PRIMARY"; break;
1816 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1817 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1818 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1822 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1824 if (omp_clauses
->bind
!= OMP_BIND_UNSET
)
1827 switch (omp_clauses
->bind
)
1829 case OMP_BIND_TEAMS
: type
= "TEAMS"; break;
1830 case OMP_BIND_PARALLEL
: type
= "PARALLEL"; break;
1831 case OMP_BIND_THREAD
: type
= "THREAD"; break;
1835 fprintf (dumpfile
, " BIND(%s)", type
);
1837 if (omp_clauses
->num_teams_upper
)
1839 fputs (" NUM_TEAMS(", dumpfile
);
1840 if (omp_clauses
->num_teams_lower
)
1842 show_expr (omp_clauses
->num_teams_lower
);
1843 fputc (':', dumpfile
);
1845 show_expr (omp_clauses
->num_teams_upper
);
1846 fputc (')', dumpfile
);
1848 if (omp_clauses
->device
)
1850 fputs (" DEVICE(", dumpfile
);
1851 if (omp_clauses
->ancestor
)
1852 fputs ("ANCESTOR:", dumpfile
);
1853 show_expr (omp_clauses
->device
);
1854 fputc (')', dumpfile
);
1856 if (omp_clauses
->thread_limit
)
1858 fputs (" THREAD_LIMIT(", dumpfile
);
1859 show_expr (omp_clauses
->thread_limit
);
1860 fputc (')', dumpfile
);
1862 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
1864 fputs (" DIST_SCHEDULE (STATIC", dumpfile
);
1865 if (omp_clauses
->dist_chunk_size
)
1867 fputc (',', dumpfile
);
1868 show_expr (omp_clauses
->dist_chunk_size
);
1870 fputc (')', dumpfile
);
1872 for (int i
= 0; i
< OMP_DEFAULTMAP_CAT_NUM
; i
++)
1874 const char *dfltmap
;
1875 if (omp_clauses
->defaultmap
[i
] == OMP_DEFAULTMAP_UNSET
)
1877 fputs (" DEFAULTMAP (", dumpfile
);
1878 switch (omp_clauses
->defaultmap
[i
])
1880 case OMP_DEFAULTMAP_ALLOC
: dfltmap
= "ALLOC"; break;
1881 case OMP_DEFAULTMAP_TO
: dfltmap
= "TO"; break;
1882 case OMP_DEFAULTMAP_FROM
: dfltmap
= "FROM"; break;
1883 case OMP_DEFAULTMAP_TOFROM
: dfltmap
= "TOFROM"; break;
1884 case OMP_DEFAULTMAP_FIRSTPRIVATE
: dfltmap
= "FIRSTPRIVATE"; break;
1885 case OMP_DEFAULTMAP_NONE
: dfltmap
= "NONE"; break;
1886 case OMP_DEFAULTMAP_DEFAULT
: dfltmap
= "DEFAULT"; break;
1887 case OMP_DEFAULTMAP_PRESENT
: dfltmap
= "PRESENT"; break;
1888 default: gcc_unreachable ();
1890 fputs (dfltmap
, dumpfile
);
1891 if (i
!= OMP_DEFAULTMAP_CAT_UNCATEGORIZED
)
1893 fputc (':', dumpfile
);
1894 switch ((enum gfc_omp_defaultmap_category
) i
)
1896 case OMP_DEFAULTMAP_CAT_SCALAR
: dfltmap
= "SCALAR"; break;
1897 case OMP_DEFAULTMAP_CAT_AGGREGATE
: dfltmap
= "AGGREGATE"; break;
1898 case OMP_DEFAULTMAP_CAT_ALLOCATABLE
: dfltmap
= "ALLOCATABLE"; break;
1899 case OMP_DEFAULTMAP_CAT_POINTER
: dfltmap
= "POINTER"; break;
1900 default: gcc_unreachable ();
1902 fputs (dfltmap
, dumpfile
);
1904 fputc (')', dumpfile
);
1906 if (omp_clauses
->weak
)
1907 fputs (" WEAK", dumpfile
);
1908 if (omp_clauses
->compare
)
1909 fputs (" COMPARE", dumpfile
);
1910 if (omp_clauses
->nogroup
)
1911 fputs (" NOGROUP", dumpfile
);
1912 if (omp_clauses
->simd
)
1913 fputs (" SIMD", dumpfile
);
1914 if (omp_clauses
->threads
)
1915 fputs (" THREADS", dumpfile
);
1916 if (omp_clauses
->grainsize
)
1918 fputs (" GRAINSIZE(", dumpfile
);
1919 if (omp_clauses
->grainsize_strict
)
1920 fputs ("strict: ", dumpfile
);
1921 show_expr (omp_clauses
->grainsize
);
1922 fputc (')', dumpfile
);
1924 if (omp_clauses
->filter
)
1926 fputs (" FILTER(", dumpfile
);
1927 show_expr (omp_clauses
->filter
);
1928 fputc (')', dumpfile
);
1930 if (omp_clauses
->hint
)
1932 fputs (" HINT(", dumpfile
);
1933 show_expr (omp_clauses
->hint
);
1934 fputc (')', dumpfile
);
1936 if (omp_clauses
->num_tasks
)
1938 fputs (" NUM_TASKS(", dumpfile
);
1939 if (omp_clauses
->num_tasks_strict
)
1940 fputs ("strict: ", dumpfile
);
1941 show_expr (omp_clauses
->num_tasks
);
1942 fputc (')', dumpfile
);
1944 if (omp_clauses
->priority
)
1946 fputs (" PRIORITY(", dumpfile
);
1947 show_expr (omp_clauses
->priority
);
1948 fputc (')', dumpfile
);
1950 if (omp_clauses
->detach
)
1952 fputs (" DETACH(", dumpfile
);
1953 show_expr (omp_clauses
->detach
);
1954 fputc (')', dumpfile
);
1956 for (i
= 0; i
< OMP_IF_LAST
; i
++)
1957 if (omp_clauses
->if_exprs
[i
])
1959 static const char *ifs
[] = {
1968 "TARGET ENTER DATA",
1971 fputs (" IF(", dumpfile
);
1972 fputs (ifs
[i
], dumpfile
);
1973 fputs (": ", dumpfile
);
1974 show_expr (omp_clauses
->if_exprs
[i
]);
1975 fputc (')', dumpfile
);
1977 if (omp_clauses
->destroy
)
1978 fputs (" DESTROY", dumpfile
);
1979 if (omp_clauses
->depend_source
)
1980 fputs (" DEPEND(source)", dumpfile
);
1981 if (omp_clauses
->doacross_source
)
1982 fputs (" DOACROSS(source:)", dumpfile
);
1983 if (omp_clauses
->capture
)
1984 fputs (" CAPTURE", dumpfile
);
1985 if (omp_clauses
->depobj_update
!= OMP_DEPEND_UNSET
)
1987 const char *deptype
;
1988 fputs (" UPDATE(", dumpfile
);
1989 switch (omp_clauses
->depobj_update
)
1991 case OMP_DEPEND_IN
: deptype
= "IN"; break;
1992 case OMP_DEPEND_OUT
: deptype
= "OUT"; break;
1993 case OMP_DEPEND_INOUT
: deptype
= "INOUT"; break;
1994 case OMP_DEPEND_INOUTSET
: deptype
= "INOUTSET"; break;
1995 case OMP_DEPEND_MUTEXINOUTSET
: deptype
= "MUTEXINOUTSET"; break;
1996 default: gcc_unreachable ();
1998 fputs (deptype
, dumpfile
);
1999 fputc (')', dumpfile
);
2001 if (omp_clauses
->atomic_op
!= GFC_OMP_ATOMIC_UNSET
)
2003 const char *atomic_op
;
2004 switch (omp_clauses
->atomic_op
& GFC_OMP_ATOMIC_MASK
)
2006 case GFC_OMP_ATOMIC_READ
: atomic_op
= "READ"; break;
2007 case GFC_OMP_ATOMIC_WRITE
: atomic_op
= "WRITE"; break;
2008 case GFC_OMP_ATOMIC_UPDATE
: atomic_op
= "UPDATE"; break;
2009 default: gcc_unreachable ();
2011 fputc (' ', dumpfile
);
2012 fputs (atomic_op
, dumpfile
);
2014 if (omp_clauses
->memorder
!= OMP_MEMORDER_UNSET
)
2016 const char *memorder
;
2017 switch (omp_clauses
->memorder
)
2019 case OMP_MEMORDER_ACQ_REL
: memorder
= "ACQ_REL"; break;
2020 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2021 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2022 case OMP_MEMORDER_RELEASE
: memorder
= "RELEASE"; break;
2023 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2024 default: gcc_unreachable ();
2026 fputc (' ', dumpfile
);
2027 fputs (memorder
, dumpfile
);
2029 if (omp_clauses
->fail
!= OMP_MEMORDER_UNSET
)
2031 const char *memorder
;
2032 switch (omp_clauses
->fail
)
2034 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2035 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2036 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2037 default: gcc_unreachable ();
2039 fputs (" FAIL(", dumpfile
);
2040 fputs (memorder
, dumpfile
);
2041 putc (')', dumpfile
);
2043 if (omp_clauses
->at
!= OMP_AT_UNSET
)
2045 if (omp_clauses
->at
!= OMP_AT_COMPILATION
)
2046 fputs (" AT (COMPILATION)", dumpfile
);
2048 fputs (" AT (EXECUTION)", dumpfile
);
2050 if (omp_clauses
->severity
!= OMP_SEVERITY_UNSET
)
2052 if (omp_clauses
->severity
!= OMP_SEVERITY_FATAL
)
2053 fputs (" SEVERITY (FATAL)", dumpfile
);
2055 fputs (" SEVERITY (WARNING)", dumpfile
);
2057 if (omp_clauses
->message
)
2059 fputs (" ERROR (", dumpfile
);
2060 show_expr (omp_clauses
->message
);
2061 fputc (')', dumpfile
);
2063 if (omp_clauses
->assume
)
2064 show_omp_assumes (omp_clauses
->assume
);
2067 /* Show a single OpenMP or OpenACC directive node and everything underneath it
2071 show_omp_node (int level
, gfc_code
*c
)
2073 gfc_omp_clauses
*omp_clauses
= NULL
;
2074 const char *name
= NULL
;
2075 bool is_oacc
= false;
2079 case EXEC_OACC_PARALLEL_LOOP
:
2080 name
= "PARALLEL LOOP"; is_oacc
= true; break;
2081 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
2082 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
2083 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
2084 case EXEC_OACC_SERIAL_LOOP
: name
= "SERIAL LOOP"; is_oacc
= true; break;
2085 case EXEC_OACC_SERIAL
: name
= "SERIAL"; is_oacc
= true; break;
2086 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
2087 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
2088 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
2089 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
2090 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
2091 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
2092 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
2093 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
2094 case EXEC_OMP_ASSUME
: name
= "ASSUME"; break;
2095 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
2096 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
2097 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
2098 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
2099 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
2100 case EXEC_OMP_DISTRIBUTE
: name
= "DISTRIBUTE"; break;
2101 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2102 name
= "DISTRIBUTE PARALLEL DO"; break;
2103 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2104 name
= "DISTRIBUTE PARALLEL DO SIMD"; break;
2105 case EXEC_OMP_DISTRIBUTE_SIMD
: name
= "DISTRIBUTE SIMD"; break;
2106 case EXEC_OMP_DO
: name
= "DO"; break;
2107 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
2108 case EXEC_OMP_ERROR
: name
= "ERROR"; break;
2109 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
2110 case EXEC_OMP_LOOP
: name
= "LOOP"; break;
2111 case EXEC_OMP_MASKED
: name
= "MASKED"; break;
2112 case EXEC_OMP_MASKED_TASKLOOP
: name
= "MASKED TASKLOOP"; break;
2113 case EXEC_OMP_MASKED_TASKLOOP_SIMD
: name
= "MASKED TASKLOOP SIMD"; break;
2114 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
2115 case EXEC_OMP_MASTER_TASKLOOP
: name
= "MASTER TASKLOOP"; break;
2116 case EXEC_OMP_MASTER_TASKLOOP_SIMD
: name
= "MASTER TASKLOOP SIMD"; break;
2117 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
2118 case EXEC_OMP_DEPOBJ
: name
= "DEPOBJ"; break;
2119 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
2120 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
2121 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
2122 case EXEC_OMP_PARALLEL_LOOP
: name
= "PARALLEL LOOP"; break;
2123 case EXEC_OMP_PARALLEL_MASTER
: name
= "PARALLEL MASTER"; break;
2124 case EXEC_OMP_PARALLEL_MASKED
: name
= "PARALLEL MASK"; break;
2125 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2126 name
= "PARALLEL MASK TASKLOOP"; break;
2127 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2128 name
= "PARALLEL MASK TASKLOOP SIMD"; break;
2129 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2130 name
= "PARALLEL MASTER TASKLOOP"; break;
2131 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2132 name
= "PARALLEL MASTER TASKLOOP SIMD"; break;
2133 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
2134 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
2135 case EXEC_OMP_SCAN
: name
= "SCAN"; break;
2136 case EXEC_OMP_SCOPE
: name
= "SCOPE"; break;
2137 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
2138 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
2139 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
2140 case EXEC_OMP_TARGET
: name
= "TARGET"; break;
2141 case EXEC_OMP_TARGET_DATA
: name
= "TARGET DATA"; break;
2142 case EXEC_OMP_TARGET_ENTER_DATA
: name
= "TARGET ENTER DATA"; break;
2143 case EXEC_OMP_TARGET_EXIT_DATA
: name
= "TARGET EXIT DATA"; break;
2144 case EXEC_OMP_TARGET_PARALLEL
: name
= "TARGET PARALLEL"; break;
2145 case EXEC_OMP_TARGET_PARALLEL_DO
: name
= "TARGET PARALLEL DO"; break;
2146 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2147 name
= "TARGET_PARALLEL_DO_SIMD"; break;
2148 case EXEC_OMP_TARGET_PARALLEL_LOOP
: name
= "TARGET PARALLEL LOOP"; break;
2149 case EXEC_OMP_TARGET_SIMD
: name
= "TARGET SIMD"; break;
2150 case EXEC_OMP_TARGET_TEAMS
: name
= "TARGET TEAMS"; break;
2151 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2152 name
= "TARGET TEAMS DISTRIBUTE"; break;
2153 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2154 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
2155 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2156 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2157 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2158 name
= "TARGET TEAMS DISTRIBUTE SIMD"; break;
2159 case EXEC_OMP_TARGET_TEAMS_LOOP
: name
= "TARGET TEAMS LOOP"; break;
2160 case EXEC_OMP_TARGET_UPDATE
: name
= "TARGET UPDATE"; break;
2161 case EXEC_OMP_TASK
: name
= "TASK"; break;
2162 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
2163 case EXEC_OMP_TASKLOOP
: name
= "TASKLOOP"; break;
2164 case EXEC_OMP_TASKLOOP_SIMD
: name
= "TASKLOOP SIMD"; break;
2165 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
2166 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
2167 case EXEC_OMP_TEAMS
: name
= "TEAMS"; break;
2168 case EXEC_OMP_TEAMS_DISTRIBUTE
: name
= "TEAMS DISTRIBUTE"; break;
2169 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2170 name
= "TEAMS DISTRIBUTE PARALLEL DO"; break;
2171 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2172 name
= "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2173 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
: name
= "TEAMS DISTRIBUTE SIMD"; break;
2174 case EXEC_OMP_TEAMS_LOOP
: name
= "TEAMS LOOP"; break;
2175 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
2179 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
2182 case EXEC_OACC_PARALLEL_LOOP
:
2183 case EXEC_OACC_PARALLEL
:
2184 case EXEC_OACC_KERNELS_LOOP
:
2185 case EXEC_OACC_KERNELS
:
2186 case EXEC_OACC_SERIAL_LOOP
:
2187 case EXEC_OACC_SERIAL
:
2188 case EXEC_OACC_DATA
:
2189 case EXEC_OACC_HOST_DATA
:
2190 case EXEC_OACC_LOOP
:
2191 case EXEC_OACC_UPDATE
:
2192 case EXEC_OACC_WAIT
:
2193 case EXEC_OACC_CACHE
:
2194 case EXEC_OACC_ENTER_DATA
:
2195 case EXEC_OACC_EXIT_DATA
:
2196 case EXEC_OMP_ASSUME
:
2197 case EXEC_OMP_CANCEL
:
2198 case EXEC_OMP_CANCELLATION_POINT
:
2199 case EXEC_OMP_DISTRIBUTE
:
2200 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2201 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2202 case EXEC_OMP_DISTRIBUTE_SIMD
:
2204 case EXEC_OMP_DO_SIMD
:
2205 case EXEC_OMP_ERROR
:
2207 case EXEC_OMP_ORDERED
:
2208 case EXEC_OMP_MASKED
:
2209 case EXEC_OMP_PARALLEL
:
2210 case EXEC_OMP_PARALLEL_DO
:
2211 case EXEC_OMP_PARALLEL_DO_SIMD
:
2212 case EXEC_OMP_PARALLEL_LOOP
:
2213 case EXEC_OMP_PARALLEL_MASKED
:
2214 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2215 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2216 case EXEC_OMP_PARALLEL_MASTER
:
2217 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2218 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2219 case EXEC_OMP_PARALLEL_SECTIONS
:
2220 case EXEC_OMP_PARALLEL_WORKSHARE
:
2222 case EXEC_OMP_SCOPE
:
2223 case EXEC_OMP_SECTIONS
:
2225 case EXEC_OMP_SINGLE
:
2226 case EXEC_OMP_TARGET
:
2227 case EXEC_OMP_TARGET_DATA
:
2228 case EXEC_OMP_TARGET_ENTER_DATA
:
2229 case EXEC_OMP_TARGET_EXIT_DATA
:
2230 case EXEC_OMP_TARGET_PARALLEL
:
2231 case EXEC_OMP_TARGET_PARALLEL_DO
:
2232 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2233 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
2234 case EXEC_OMP_TARGET_SIMD
:
2235 case EXEC_OMP_TARGET_TEAMS
:
2236 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2237 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2238 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2239 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2240 case EXEC_OMP_TARGET_TEAMS_LOOP
:
2241 case EXEC_OMP_TARGET_UPDATE
:
2243 case EXEC_OMP_TASKLOOP
:
2244 case EXEC_OMP_TASKLOOP_SIMD
:
2245 case EXEC_OMP_TEAMS
:
2246 case EXEC_OMP_TEAMS_DISTRIBUTE
:
2247 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2248 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2249 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
2250 case EXEC_OMP_TEAMS_LOOP
:
2251 case EXEC_OMP_WORKSHARE
:
2252 omp_clauses
= c
->ext
.omp_clauses
;
2254 case EXEC_OMP_CRITICAL
:
2255 omp_clauses
= c
->ext
.omp_clauses
;
2257 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2259 case EXEC_OMP_DEPOBJ
:
2260 omp_clauses
= c
->ext
.omp_clauses
;
2263 fputc ('(', dumpfile
);
2264 show_expr (c
->ext
.omp_clauses
->depobj
);
2265 fputc (')', dumpfile
);
2268 case EXEC_OMP_FLUSH
:
2269 if (c
->ext
.omp_namelist
)
2271 fputs (" (", dumpfile
);
2272 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
2273 fputc (')', dumpfile
);
2276 case EXEC_OMP_BARRIER
:
2277 case EXEC_OMP_TASKWAIT
:
2278 case EXEC_OMP_TASKYIELD
:
2280 case EXEC_OACC_ATOMIC
:
2281 case EXEC_OMP_ATOMIC
:
2282 omp_clauses
= c
->block
? c
->block
->ext
.omp_clauses
: NULL
;
2288 show_omp_clauses (omp_clauses
);
2289 fputc ('\n', dumpfile
);
2291 /* OpenMP and OpenACC executable directives don't have associated blocks. */
2292 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
2293 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
2294 || c
->op
== EXEC_OMP_TARGET_UPDATE
|| c
->op
== EXEC_OMP_TARGET_ENTER_DATA
2295 || c
->op
== EXEC_OMP_TARGET_EXIT_DATA
|| c
->op
== EXEC_OMP_SCAN
2296 || c
->op
== EXEC_OMP_DEPOBJ
|| c
->op
== EXEC_OMP_ERROR
2297 || (c
->op
== EXEC_OMP_ORDERED
&& c
->block
== NULL
))
2299 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
2301 gfc_code
*d
= c
->block
;
2304 show_code (level
+ 1, d
->next
);
2305 if (d
->block
== NULL
)
2307 code_indent (level
, 0);
2308 fputs ("!$OMP SECTION\n", dumpfile
);
2313 show_code (level
+ 1, c
->block
->next
);
2314 if (c
->op
== EXEC_OMP_ATOMIC
)
2316 fputc ('\n', dumpfile
);
2317 code_indent (level
, 0);
2318 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
2319 if (omp_clauses
!= NULL
)
2321 if (omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
])
2323 fputs (" COPYPRIVATE(", dumpfile
);
2324 show_omp_namelist (OMP_LIST_COPYPRIVATE
,
2325 omp_clauses
->lists
[OMP_LIST_COPYPRIVATE
]);
2326 fputc (')', dumpfile
);
2328 else if (omp_clauses
->nowait
)
2329 fputs (" NOWAIT", dumpfile
);
2331 else if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_clauses
)
2332 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2336 /* Show a single code node and everything underneath it if necessary. */
2339 show_code_node (int level
, gfc_code
*c
)
2341 gfc_forall_iterator
*fa
;
2354 fputc ('\n', dumpfile
);
2355 code_indent (level
, c
->here
);
2362 case EXEC_END_PROCEDURE
:
2366 fputs ("NOP", dumpfile
);
2370 fputs ("CONTINUE", dumpfile
);
2374 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
2377 case EXEC_INIT_ASSIGN
:
2379 fputs ("ASSIGN ", dumpfile
);
2380 show_expr (c
->expr1
);
2381 fputc (' ', dumpfile
);
2382 show_expr (c
->expr2
);
2385 case EXEC_LABEL_ASSIGN
:
2386 fputs ("LABEL ASSIGN ", dumpfile
);
2387 show_expr (c
->expr1
);
2388 fprintf (dumpfile
, " %d", c
->label1
->value
);
2391 case EXEC_POINTER_ASSIGN
:
2392 fputs ("POINTER ASSIGN ", dumpfile
);
2393 show_expr (c
->expr1
);
2394 fputc (' ', dumpfile
);
2395 show_expr (c
->expr2
);
2399 fputs ("GOTO ", dumpfile
);
2401 fprintf (dumpfile
, "%d", c
->label1
->value
);
2404 show_expr (c
->expr1
);
2408 fputs (", (", dumpfile
);
2409 for (; d
; d
= d
->block
)
2411 code_indent (level
, d
->label1
);
2412 if (d
->block
!= NULL
)
2413 fputc (',', dumpfile
);
2415 fputc (')', dumpfile
);
2422 case EXEC_ASSIGN_CALL
:
2423 if (c
->resolved_sym
)
2424 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
2425 else if (c
->symtree
)
2426 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
2428 fputs ("CALL ?? ", dumpfile
);
2430 show_actual_arglist (c
->ext
.actual
);
2434 fputs ("CALL ", dumpfile
);
2435 show_compcall (c
->expr1
);
2439 fputs ("CALL ", dumpfile
);
2440 show_expr (c
->expr1
);
2441 show_actual_arglist (c
->ext
.actual
);
2445 fputs ("RETURN ", dumpfile
);
2447 show_expr (c
->expr1
);
2451 fputs ("PAUSE ", dumpfile
);
2453 if (c
->expr1
!= NULL
)
2454 show_expr (c
->expr1
);
2456 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2460 case EXEC_ERROR_STOP
:
2461 fputs ("ERROR ", dumpfile
);
2465 fputs ("STOP ", dumpfile
);
2467 if (c
->expr1
!= NULL
)
2468 show_expr (c
->expr1
);
2470 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2471 if (c
->expr2
!= NULL
)
2473 fputs (" QUIET=", dumpfile
);
2474 show_expr (c
->expr2
);
2479 case EXEC_FAIL_IMAGE
:
2480 fputs ("FAIL IMAGE ", dumpfile
);
2483 case EXEC_CHANGE_TEAM
:
2484 fputs ("CHANGE TEAM", dumpfile
);
2488 fputs ("END TEAM", dumpfile
);
2491 case EXEC_FORM_TEAM
:
2492 fputs ("FORM TEAM", dumpfile
);
2495 case EXEC_SYNC_TEAM
:
2496 fputs ("SYNC TEAM", dumpfile
);
2500 fputs ("SYNC ALL ", dumpfile
);
2501 if (c
->expr2
!= NULL
)
2503 fputs (" stat=", dumpfile
);
2504 show_expr (c
->expr2
);
2506 if (c
->expr3
!= NULL
)
2508 fputs (" errmsg=", dumpfile
);
2509 show_expr (c
->expr3
);
2513 case EXEC_SYNC_MEMORY
:
2514 fputs ("SYNC MEMORY ", dumpfile
);
2515 if (c
->expr2
!= NULL
)
2517 fputs (" stat=", dumpfile
);
2518 show_expr (c
->expr2
);
2520 if (c
->expr3
!= NULL
)
2522 fputs (" errmsg=", dumpfile
);
2523 show_expr (c
->expr3
);
2527 case EXEC_SYNC_IMAGES
:
2528 fputs ("SYNC IMAGES image-set=", dumpfile
);
2529 if (c
->expr1
!= NULL
)
2530 show_expr (c
->expr1
);
2532 fputs ("* ", dumpfile
);
2533 if (c
->expr2
!= NULL
)
2535 fputs (" stat=", dumpfile
);
2536 show_expr (c
->expr2
);
2538 if (c
->expr3
!= NULL
)
2540 fputs (" errmsg=", dumpfile
);
2541 show_expr (c
->expr3
);
2545 case EXEC_EVENT_POST
:
2546 case EXEC_EVENT_WAIT
:
2547 if (c
->op
== EXEC_EVENT_POST
)
2548 fputs ("EVENT POST ", dumpfile
);
2550 fputs ("EVENT WAIT ", dumpfile
);
2552 fputs ("event-variable=", dumpfile
);
2553 if (c
->expr1
!= NULL
)
2554 show_expr (c
->expr1
);
2555 if (c
->expr4
!= NULL
)
2557 fputs (" until_count=", dumpfile
);
2558 show_expr (c
->expr4
);
2560 if (c
->expr2
!= NULL
)
2562 fputs (" stat=", dumpfile
);
2563 show_expr (c
->expr2
);
2565 if (c
->expr3
!= NULL
)
2567 fputs (" errmsg=", dumpfile
);
2568 show_expr (c
->expr3
);
2574 if (c
->op
== EXEC_LOCK
)
2575 fputs ("LOCK ", dumpfile
);
2577 fputs ("UNLOCK ", dumpfile
);
2579 fputs ("lock-variable=", dumpfile
);
2580 if (c
->expr1
!= NULL
)
2581 show_expr (c
->expr1
);
2582 if (c
->expr4
!= NULL
)
2584 fputs (" acquired_lock=", dumpfile
);
2585 show_expr (c
->expr4
);
2587 if (c
->expr2
!= NULL
)
2589 fputs (" stat=", dumpfile
);
2590 show_expr (c
->expr2
);
2592 if (c
->expr3
!= NULL
)
2594 fputs (" errmsg=", dumpfile
);
2595 show_expr (c
->expr3
);
2599 case EXEC_ARITHMETIC_IF
:
2600 fputs ("IF ", dumpfile
);
2601 show_expr (c
->expr1
);
2602 fprintf (dumpfile
, " %d, %d, %d",
2603 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
2608 fputs ("IF ", dumpfile
);
2609 show_expr (d
->expr1
);
2612 show_code (level
+ 1, d
->next
);
2616 for (; d
; d
= d
->block
)
2618 fputs("\n", dumpfile
);
2619 code_indent (level
, 0);
2620 if (d
->expr1
== NULL
)
2621 fputs ("ELSE", dumpfile
);
2624 fputs ("ELSE IF ", dumpfile
);
2625 show_expr (d
->expr1
);
2629 show_code (level
+ 1, d
->next
);
2634 code_indent (level
, c
->label1
);
2638 fputs ("ENDIF", dumpfile
);
2643 const char* blocktype
;
2644 gfc_namespace
*saved_ns
;
2645 gfc_association_list
*alist
;
2647 if (c
->ext
.block
.assoc
)
2648 blocktype
= "ASSOCIATE";
2650 blocktype
= "BLOCK";
2652 fprintf (dumpfile
, "%s ", blocktype
);
2653 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
2655 fprintf (dumpfile
, " %s = ", alist
->name
);
2656 show_expr (alist
->target
);
2660 ns
= c
->ext
.block
.ns
;
2661 saved_ns
= gfc_current_ns
;
2662 gfc_current_ns
= ns
;
2663 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2664 gfc_current_ns
= saved_ns
;
2665 show_code (show_level
, ns
->code
);
2668 fprintf (dumpfile
, "END %s ", blocktype
);
2672 case EXEC_END_BLOCK
:
2673 /* Only come here when there is a label on an
2674 END ASSOCIATE construct. */
2678 case EXEC_SELECT_TYPE
:
2679 case EXEC_SELECT_RANK
:
2681 fputc ('\n', dumpfile
);
2682 code_indent (level
, 0);
2683 if (c
->op
== EXEC_SELECT_RANK
)
2684 fputs ("SELECT RANK ", dumpfile
);
2685 else if (c
->op
== EXEC_SELECT_TYPE
)
2686 fputs ("SELECT TYPE ", dumpfile
);
2688 fputs ("SELECT CASE ", dumpfile
);
2689 show_expr (c
->expr1
);
2691 for (; d
; d
= d
->block
)
2693 fputc ('\n', dumpfile
);
2694 code_indent (level
, 0);
2695 fputs ("CASE ", dumpfile
);
2696 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
2698 fputc ('(', dumpfile
);
2699 show_expr (cp
->low
);
2700 fputc (' ', dumpfile
);
2701 show_expr (cp
->high
);
2702 fputc (')', dumpfile
);
2703 fputc (' ', dumpfile
);
2706 show_code (level
+ 1, d
->next
);
2707 fputc ('\n', dumpfile
);
2710 code_indent (level
, c
->label1
);
2711 fputs ("END SELECT", dumpfile
);
2715 fputs ("WHERE ", dumpfile
);
2718 show_expr (d
->expr1
);
2719 fputc ('\n', dumpfile
);
2721 show_code (level
+ 1, d
->next
);
2723 for (d
= d
->block
; d
; d
= d
->block
)
2725 code_indent (level
, 0);
2726 fputs ("ELSE WHERE ", dumpfile
);
2727 show_expr (d
->expr1
);
2728 fputc ('\n', dumpfile
);
2729 show_code (level
+ 1, d
->next
);
2732 code_indent (level
, 0);
2733 fputs ("END WHERE", dumpfile
);
2738 fputs ("FORALL ", dumpfile
);
2739 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2741 show_expr (fa
->var
);
2742 fputc (' ', dumpfile
);
2743 show_expr (fa
->start
);
2744 fputc (':', dumpfile
);
2745 show_expr (fa
->end
);
2746 fputc (':', dumpfile
);
2747 show_expr (fa
->stride
);
2749 if (fa
->next
!= NULL
)
2750 fputc (',', dumpfile
);
2753 if (c
->expr1
!= NULL
)
2755 fputc (',', dumpfile
);
2756 show_expr (c
->expr1
);
2758 fputc ('\n', dumpfile
);
2760 show_code (level
+ 1, c
->block
->next
);
2762 code_indent (level
, 0);
2763 fputs ("END FORALL", dumpfile
);
2767 fputs ("CRITICAL\n", dumpfile
);
2768 show_code (level
+ 1, c
->block
->next
);
2769 code_indent (level
, 0);
2770 fputs ("END CRITICAL", dumpfile
);
2774 fputs ("DO ", dumpfile
);
2776 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
2778 show_expr (c
->ext
.iterator
->var
);
2779 fputc ('=', dumpfile
);
2780 show_expr (c
->ext
.iterator
->start
);
2781 fputc (' ', dumpfile
);
2782 show_expr (c
->ext
.iterator
->end
);
2783 fputc (' ', dumpfile
);
2784 show_expr (c
->ext
.iterator
->step
);
2787 show_code (level
+ 1, c
->block
->next
);
2794 fputs ("END DO", dumpfile
);
2797 case EXEC_DO_CONCURRENT
:
2798 fputs ("DO CONCURRENT ", dumpfile
);
2799 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2801 show_expr (fa
->var
);
2802 fputc (' ', dumpfile
);
2803 show_expr (fa
->start
);
2804 fputc (':', dumpfile
);
2805 show_expr (fa
->end
);
2806 fputc (':', dumpfile
);
2807 show_expr (fa
->stride
);
2809 if (fa
->next
!= NULL
)
2810 fputc (',', dumpfile
);
2812 show_expr (c
->expr1
);
2815 show_code (level
+ 1, c
->block
->next
);
2817 code_indent (level
, c
->label1
);
2819 fputs ("END DO", dumpfile
);
2823 fputs ("DO WHILE ", dumpfile
);
2824 show_expr (c
->expr1
);
2825 fputc ('\n', dumpfile
);
2827 show_code (level
+ 1, c
->block
->next
);
2829 code_indent (level
, c
->label1
);
2830 fputs ("END DO", dumpfile
);
2834 fputs ("CYCLE", dumpfile
);
2836 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2840 fputs ("EXIT", dumpfile
);
2842 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
2846 fputs ("ALLOCATE ", dumpfile
);
2849 fputs (" STAT=", dumpfile
);
2850 show_expr (c
->expr1
);
2855 fputs (" ERRMSG=", dumpfile
);
2856 show_expr (c
->expr2
);
2862 fputs (" MOLD=", dumpfile
);
2864 fputs (" SOURCE=", dumpfile
);
2865 show_expr (c
->expr3
);
2868 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2870 fputc (' ', dumpfile
);
2871 show_expr (a
->expr
);
2876 case EXEC_DEALLOCATE
:
2877 fputs ("DEALLOCATE ", dumpfile
);
2880 fputs (" STAT=", dumpfile
);
2881 show_expr (c
->expr1
);
2886 fputs (" ERRMSG=", dumpfile
);
2887 show_expr (c
->expr2
);
2890 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
2892 fputc (' ', dumpfile
);
2893 show_expr (a
->expr
);
2899 fputs ("OPEN", dumpfile
);
2904 fputs (" UNIT=", dumpfile
);
2905 show_expr (open
->unit
);
2909 fputs (" IOMSG=", dumpfile
);
2910 show_expr (open
->iomsg
);
2914 fputs (" IOSTAT=", dumpfile
);
2915 show_expr (open
->iostat
);
2919 fputs (" FILE=", dumpfile
);
2920 show_expr (open
->file
);
2924 fputs (" STATUS=", dumpfile
);
2925 show_expr (open
->status
);
2929 fputs (" ACCESS=", dumpfile
);
2930 show_expr (open
->access
);
2934 fputs (" FORM=", dumpfile
);
2935 show_expr (open
->form
);
2939 fputs (" RECL=", dumpfile
);
2940 show_expr (open
->recl
);
2944 fputs (" BLANK=", dumpfile
);
2945 show_expr (open
->blank
);
2949 fputs (" POSITION=", dumpfile
);
2950 show_expr (open
->position
);
2954 fputs (" ACTION=", dumpfile
);
2955 show_expr (open
->action
);
2959 fputs (" DELIM=", dumpfile
);
2960 show_expr (open
->delim
);
2964 fputs (" PAD=", dumpfile
);
2965 show_expr (open
->pad
);
2969 fputs (" DECIMAL=", dumpfile
);
2970 show_expr (open
->decimal
);
2974 fputs (" ENCODING=", dumpfile
);
2975 show_expr (open
->encoding
);
2979 fputs (" ROUND=", dumpfile
);
2980 show_expr (open
->round
);
2984 fputs (" SIGN=", dumpfile
);
2985 show_expr (open
->sign
);
2989 fputs (" CONVERT=", dumpfile
);
2990 show_expr (open
->convert
);
2992 if (open
->asynchronous
)
2994 fputs (" ASYNCHRONOUS=", dumpfile
);
2995 show_expr (open
->asynchronous
);
2997 if (open
->err
!= NULL
)
2998 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
3003 fputs ("CLOSE", dumpfile
);
3004 close
= c
->ext
.close
;
3008 fputs (" UNIT=", dumpfile
);
3009 show_expr (close
->unit
);
3013 fputs (" IOMSG=", dumpfile
);
3014 show_expr (close
->iomsg
);
3018 fputs (" IOSTAT=", dumpfile
);
3019 show_expr (close
->iostat
);
3023 fputs (" STATUS=", dumpfile
);
3024 show_expr (close
->status
);
3026 if (close
->err
!= NULL
)
3027 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
3030 case EXEC_BACKSPACE
:
3031 fputs ("BACKSPACE", dumpfile
);
3035 fputs ("ENDFILE", dumpfile
);
3039 fputs ("REWIND", dumpfile
);
3043 fputs ("FLUSH", dumpfile
);
3046 fp
= c
->ext
.filepos
;
3050 fputs (" UNIT=", dumpfile
);
3051 show_expr (fp
->unit
);
3055 fputs (" IOMSG=", dumpfile
);
3056 show_expr (fp
->iomsg
);
3060 fputs (" IOSTAT=", dumpfile
);
3061 show_expr (fp
->iostat
);
3063 if (fp
->err
!= NULL
)
3064 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
3068 fputs ("INQUIRE", dumpfile
);
3073 fputs (" UNIT=", dumpfile
);
3074 show_expr (i
->unit
);
3078 fputs (" FILE=", dumpfile
);
3079 show_expr (i
->file
);
3084 fputs (" IOMSG=", dumpfile
);
3085 show_expr (i
->iomsg
);
3089 fputs (" IOSTAT=", dumpfile
);
3090 show_expr (i
->iostat
);
3094 fputs (" EXIST=", dumpfile
);
3095 show_expr (i
->exist
);
3099 fputs (" OPENED=", dumpfile
);
3100 show_expr (i
->opened
);
3104 fputs (" NUMBER=", dumpfile
);
3105 show_expr (i
->number
);
3109 fputs (" NAMED=", dumpfile
);
3110 show_expr (i
->named
);
3114 fputs (" NAME=", dumpfile
);
3115 show_expr (i
->name
);
3119 fputs (" ACCESS=", dumpfile
);
3120 show_expr (i
->access
);
3124 fputs (" SEQUENTIAL=", dumpfile
);
3125 show_expr (i
->sequential
);
3130 fputs (" DIRECT=", dumpfile
);
3131 show_expr (i
->direct
);
3135 fputs (" FORM=", dumpfile
);
3136 show_expr (i
->form
);
3140 fputs (" FORMATTED", dumpfile
);
3141 show_expr (i
->formatted
);
3145 fputs (" UNFORMATTED=", dumpfile
);
3146 show_expr (i
->unformatted
);
3150 fputs (" RECL=", dumpfile
);
3151 show_expr (i
->recl
);
3155 fputs (" NEXTREC=", dumpfile
);
3156 show_expr (i
->nextrec
);
3160 fputs (" BLANK=", dumpfile
);
3161 show_expr (i
->blank
);
3165 fputs (" POSITION=", dumpfile
);
3166 show_expr (i
->position
);
3170 fputs (" ACTION=", dumpfile
);
3171 show_expr (i
->action
);
3175 fputs (" READ=", dumpfile
);
3176 show_expr (i
->read
);
3180 fputs (" WRITE=", dumpfile
);
3181 show_expr (i
->write
);
3185 fputs (" READWRITE=", dumpfile
);
3186 show_expr (i
->readwrite
);
3190 fputs (" DELIM=", dumpfile
);
3191 show_expr (i
->delim
);
3195 fputs (" PAD=", dumpfile
);
3200 fputs (" CONVERT=", dumpfile
);
3201 show_expr (i
->convert
);
3203 if (i
->asynchronous
)
3205 fputs (" ASYNCHRONOUS=", dumpfile
);
3206 show_expr (i
->asynchronous
);
3210 fputs (" DECIMAL=", dumpfile
);
3211 show_expr (i
->decimal
);
3215 fputs (" ENCODING=", dumpfile
);
3216 show_expr (i
->encoding
);
3220 fputs (" PENDING=", dumpfile
);
3221 show_expr (i
->pending
);
3225 fputs (" ROUND=", dumpfile
);
3226 show_expr (i
->round
);
3230 fputs (" SIGN=", dumpfile
);
3231 show_expr (i
->sign
);
3235 fputs (" SIZE=", dumpfile
);
3236 show_expr (i
->size
);
3240 fputs (" ID=", dumpfile
);
3245 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
3249 fputs ("IOLENGTH ", dumpfile
);
3250 show_expr (c
->expr1
);
3255 fputs ("READ", dumpfile
);
3259 fputs ("WRITE", dumpfile
);
3265 fputs (" UNIT=", dumpfile
);
3266 show_expr (dt
->io_unit
);
3269 if (dt
->format_expr
)
3271 fputs (" FMT=", dumpfile
);
3272 show_expr (dt
->format_expr
);
3275 if (dt
->format_label
!= NULL
)
3276 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
3278 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
3282 fputs (" IOMSG=", dumpfile
);
3283 show_expr (dt
->iomsg
);
3287 fputs (" IOSTAT=", dumpfile
);
3288 show_expr (dt
->iostat
);
3292 fputs (" SIZE=", dumpfile
);
3293 show_expr (dt
->size
);
3297 fputs (" REC=", dumpfile
);
3298 show_expr (dt
->rec
);
3302 fputs (" ADVANCE=", dumpfile
);
3303 show_expr (dt
->advance
);
3307 fputs (" ID=", dumpfile
);
3312 fputs (" POS=", dumpfile
);
3313 show_expr (dt
->pos
);
3315 if (dt
->asynchronous
)
3317 fputs (" ASYNCHRONOUS=", dumpfile
);
3318 show_expr (dt
->asynchronous
);
3322 fputs (" BLANK=", dumpfile
);
3323 show_expr (dt
->blank
);
3327 fputs (" DECIMAL=", dumpfile
);
3328 show_expr (dt
->decimal
);
3332 fputs (" DELIM=", dumpfile
);
3333 show_expr (dt
->delim
);
3337 fputs (" PAD=", dumpfile
);
3338 show_expr (dt
->pad
);
3342 fputs (" ROUND=", dumpfile
);
3343 show_expr (dt
->round
);
3347 fputs (" SIGN=", dumpfile
);
3348 show_expr (dt
->sign
);
3352 for (c
= c
->block
->next
; c
; c
= c
->next
)
3353 show_code_node (level
+ (c
->next
!= NULL
), c
);
3357 fputs ("TRANSFER ", dumpfile
);
3358 show_expr (c
->expr1
);
3362 fputs ("DT_END", dumpfile
);
3365 if (dt
->err
!= NULL
)
3366 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
3367 if (dt
->end
!= NULL
)
3368 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
3369 if (dt
->eor
!= NULL
)
3370 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
3374 fputs ("WAIT", dumpfile
);
3376 if (c
->ext
.wait
!= NULL
)
3378 gfc_wait
*wait
= c
->ext
.wait
;
3381 fputs (" UNIT=", dumpfile
);
3382 show_expr (wait
->unit
);
3386 fputs (" IOSTAT=", dumpfile
);
3387 show_expr (wait
->iostat
);
3391 fputs (" IOMSG=", dumpfile
);
3392 show_expr (wait
->iomsg
);
3396 fputs (" ID=", dumpfile
);
3397 show_expr (wait
->id
);
3400 fprintf (dumpfile
, " ERR=%d", wait
->err
->value
);
3402 fprintf (dumpfile
, " END=%d", wait
->end
->value
);
3404 fprintf (dumpfile
, " EOR=%d", wait
->eor
->value
);
3408 case EXEC_OACC_PARALLEL_LOOP
:
3409 case EXEC_OACC_PARALLEL
:
3410 case EXEC_OACC_KERNELS_LOOP
:
3411 case EXEC_OACC_KERNELS
:
3412 case EXEC_OACC_SERIAL_LOOP
:
3413 case EXEC_OACC_SERIAL
:
3414 case EXEC_OACC_DATA
:
3415 case EXEC_OACC_HOST_DATA
:
3416 case EXEC_OACC_LOOP
:
3417 case EXEC_OACC_UPDATE
:
3418 case EXEC_OACC_WAIT
:
3419 case EXEC_OACC_CACHE
:
3420 case EXEC_OACC_ENTER_DATA
:
3421 case EXEC_OACC_EXIT_DATA
:
3422 case EXEC_OMP_ASSUME
:
3423 case EXEC_OMP_ATOMIC
:
3424 case EXEC_OMP_CANCEL
:
3425 case EXEC_OMP_CANCELLATION_POINT
:
3426 case EXEC_OMP_BARRIER
:
3427 case EXEC_OMP_CRITICAL
:
3428 case EXEC_OMP_DEPOBJ
:
3429 case EXEC_OMP_DISTRIBUTE
:
3430 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
3431 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
3432 case EXEC_OMP_DISTRIBUTE_SIMD
:
3434 case EXEC_OMP_DO_SIMD
:
3435 case EXEC_OMP_ERROR
:
3436 case EXEC_OMP_FLUSH
:
3438 case EXEC_OMP_MASKED
:
3439 case EXEC_OMP_MASKED_TASKLOOP
:
3440 case EXEC_OMP_MASKED_TASKLOOP_SIMD
:
3441 case EXEC_OMP_MASTER
:
3442 case EXEC_OMP_MASTER_TASKLOOP
:
3443 case EXEC_OMP_MASTER_TASKLOOP_SIMD
:
3444 case EXEC_OMP_ORDERED
:
3445 case EXEC_OMP_PARALLEL
:
3446 case EXEC_OMP_PARALLEL_DO
:
3447 case EXEC_OMP_PARALLEL_DO_SIMD
:
3448 case EXEC_OMP_PARALLEL_LOOP
:
3449 case EXEC_OMP_PARALLEL_MASKED
:
3450 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
3451 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
3452 case EXEC_OMP_PARALLEL_MASTER
:
3453 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
3454 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
3455 case EXEC_OMP_PARALLEL_SECTIONS
:
3456 case EXEC_OMP_PARALLEL_WORKSHARE
:
3458 case EXEC_OMP_SCOPE
:
3459 case EXEC_OMP_SECTIONS
:
3461 case EXEC_OMP_SINGLE
:
3462 case EXEC_OMP_TARGET
:
3463 case EXEC_OMP_TARGET_DATA
:
3464 case EXEC_OMP_TARGET_ENTER_DATA
:
3465 case EXEC_OMP_TARGET_EXIT_DATA
:
3466 case EXEC_OMP_TARGET_PARALLEL
:
3467 case EXEC_OMP_TARGET_PARALLEL_DO
:
3468 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
3469 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
3470 case EXEC_OMP_TARGET_SIMD
:
3471 case EXEC_OMP_TARGET_TEAMS
:
3472 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
3473 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3474 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3475 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
3476 case EXEC_OMP_TARGET_TEAMS_LOOP
:
3477 case EXEC_OMP_TARGET_UPDATE
:
3479 case EXEC_OMP_TASKGROUP
:
3480 case EXEC_OMP_TASKLOOP
:
3481 case EXEC_OMP_TASKLOOP_SIMD
:
3482 case EXEC_OMP_TASKWAIT
:
3483 case EXEC_OMP_TASKYIELD
:
3484 case EXEC_OMP_TEAMS
:
3485 case EXEC_OMP_TEAMS_DISTRIBUTE
:
3486 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3487 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3488 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
3489 case EXEC_OMP_TEAMS_LOOP
:
3490 case EXEC_OMP_WORKSHARE
:
3491 show_omp_node (level
, c
);
3495 gfc_internal_error ("show_code_node(): Bad statement code");
3500 /* Show an equivalence chain. */
3503 show_equiv (gfc_equiv
*eq
)
3506 fputs ("Equivalence: ", dumpfile
);
3509 show_expr (eq
->expr
);
3512 fputs (", ", dumpfile
);
3517 /* Show a freakin' whole namespace. */
3520 show_namespace (gfc_namespace
*ns
)
3522 gfc_interface
*intr
;
3523 gfc_namespace
*save
;
3529 save
= gfc_current_ns
;
3532 fputs ("Namespace:", dumpfile
);
3538 while (i
< GFC_LETTERS
- 1
3539 && gfc_compare_types (&ns
->default_type
[i
+1],
3540 &ns
->default_type
[l
]))
3544 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
3546 fprintf (dumpfile
, " %c: ", l
+'A');
3548 show_typespec(&ns
->default_type
[l
]);
3550 } while (i
< GFC_LETTERS
);
3552 if (ns
->proc_name
!= NULL
)
3555 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
3559 gfc_current_ns
= ns
;
3560 gfc_traverse_symtree (ns
->common_root
, show_common
);
3562 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
3564 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
3566 /* User operator interfaces */
3572 fprintf (dumpfile
, "Operator interfaces for %s:",
3573 gfc_op2string ((gfc_intrinsic_op
) op
));
3575 for (; intr
; intr
= intr
->next
)
3576 fprintf (dumpfile
, " %s", intr
->sym
->name
);
3579 if (ns
->uop_root
!= NULL
)
3582 fputs ("User operators:\n", dumpfile
);
3583 gfc_traverse_user_op (ns
, show_uop
);
3586 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
3589 if (ns
->oacc_declare
)
3591 struct gfc_oacc_declare
*decl
;
3592 /* Dump !$ACC DECLARE clauses. */
3593 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
3596 fprintf (dumpfile
, "!$ACC DECLARE");
3597 show_omp_clauses (decl
->clauses
);
3601 if (ns
->omp_assumes
)
3604 fprintf (dumpfile
, "!$OMP ASSUMES");
3605 show_omp_assumes (ns
->omp_assumes
);
3608 fputc ('\n', dumpfile
);
3610 fputs ("code:", dumpfile
);
3611 show_code (show_level
, ns
->code
);
3614 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
3616 fputs ("\nCONTAINS\n", dumpfile
);
3618 show_namespace (ns
);
3622 fputc ('\n', dumpfile
);
3623 gfc_current_ns
= save
;
3627 /* Main function for dumping a parse tree. */
3630 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
3633 show_namespace (ns
);
3636 /* This part writes BIND(C) definition for use in external C programs. */
3638 static void write_interop_decl (gfc_symbol
*);
3639 static void write_proc (gfc_symbol
*, bool);
3642 gfc_dump_c_prototypes (gfc_namespace
*ns
, FILE *file
)
3645 gfc_get_errors (NULL
, &error_count
);
3646 if (error_count
!= 0)
3649 gfc_traverse_ns (ns
, write_interop_decl
);
3652 /* Loop over all global symbols, writing out their declarations. */
3655 gfc_dump_external_c_prototypes (FILE * file
)
3659 _("/* Prototypes for external procedures generated from %s\n"
3660 " by GNU Fortran %s%s.\n\n"
3661 " Use of this interface is discouraged, consider using the\n"
3662 " BIND(C) feature of standard Fortran instead. */\n\n"),
3663 gfc_source_file
, pkgversion_string
, version_string
);
3665 for (gfc_current_ns
= gfc_global_ns_list
; gfc_current_ns
;
3666 gfc_current_ns
= gfc_current_ns
->sibling
)
3668 gfc_symbol
*sym
= gfc_current_ns
->proc_name
;
3670 if (sym
== NULL
|| sym
->attr
.flavor
!= FL_PROCEDURE
3671 || sym
->attr
.is_bind_c
)
3674 write_proc (sym
, false);
3679 enum type_return
{ T_OK
=0, T_WARN
, T_ERROR
};
3681 /* Return the name of the type for later output. Both function pointers and
3682 void pointers will be mapped to void *. */
3684 static enum type_return
3685 get_c_type_name (gfc_typespec
*ts
, gfc_array_spec
*as
, const char **pre
,
3686 const char **type_name
, bool *asterisk
, const char **post
,
3689 static char post_buffer
[40];
3690 enum type_return ret
;
3696 *type_name
= "<error>";
3697 if (ts
->type
== BT_REAL
|| ts
->type
== BT_INTEGER
|| ts
->type
== BT_COMPLEX
)
3699 if (ts
->is_c_interop
&& ts
->interop_kind
)
3704 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3706 if (c_interop_kinds_table
[i
].f90_type
== ts
->type
3707 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3709 /* Skip over 'c_'. */
3710 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3711 if (strcmp (*type_name
, "long_long") == 0)
3712 *type_name
= "long long";
3713 if (strcmp (*type_name
, "long_double") == 0)
3714 *type_name
= "long double";
3715 if (strcmp (*type_name
, "signed_char") == 0)
3716 *type_name
= "signed char";
3717 else if (strcmp (*type_name
, "size_t") == 0)
3718 *type_name
= "ssize_t";
3719 else if (strcmp (*type_name
, "float_complex") == 0)
3720 *type_name
= "__GFORTRAN_FLOAT_COMPLEX";
3721 else if (strcmp (*type_name
, "double_complex") == 0)
3722 *type_name
= "__GFORTRAN_DOUBLE_COMPLEX";
3723 else if (strcmp (*type_name
, "long_double_complex") == 0)
3724 *type_name
= "__GFORTRAN_LONG_DOUBLE_COMPLEX";
3730 else if (ts
->type
== BT_LOGICAL
)
3732 if (ts
->is_c_interop
&& ts
->interop_kind
)
3734 *type_name
= "_Bool";
3739 /* Let's select an appropriate int, with a warning. */
3740 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3742 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3743 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3745 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3751 else if (ts
->type
== BT_CHARACTER
)
3753 if (ts
->is_c_interop
)
3755 *type_name
= "char";
3760 if (ts
->kind
== gfc_default_character_kind
)
3761 *type_name
= "char";
3763 /* Let's select an appropriate int. */
3764 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3766 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3767 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3769 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3777 else if (ts
->type
== BT_DERIVED
)
3779 if (ts
->u
.derived
->from_intmod
== INTMOD_ISO_C_BINDING
)
3781 if (strcmp (ts
->u
.derived
->name
, "c_ptr") == 0)
3782 *type_name
= "void";
3783 else if (strcmp (ts
->u
.derived
->name
, "c_funptr") == 0)
3785 *type_name
= "int ";
3801 *type_name
= ts
->u
.derived
->name
;
3806 if (ret
!= T_ERROR
&& as
)
3810 size_ok
= spec_size (as
, &sz
);
3811 gcc_assert (size_ok
== true);
3812 gmp_snprintf (post_buffer
, sizeof(post_buffer
), "[%Zd]", sz
);
3813 *post
= post_buffer
;
3819 /* Write out a declaration. */
3821 write_decl (gfc_typespec
*ts
, gfc_array_spec
*as
, const char *sym_name
,
3822 bool func_ret
, locus
*where
, bool bind_c
)
3824 const char *pre
, *type_name
, *post
;
3826 enum type_return rok
;
3828 rok
= get_c_type_name (ts
, as
, &pre
, &type_name
, &asterisk
, &post
, func_ret
);
3831 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3832 gfc_typename (ts
), where
);
3833 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
3837 fputs (type_name
, dumpfile
);
3838 fputs (pre
, dumpfile
);
3840 fputs ("*", dumpfile
);
3842 fputs (sym_name
, dumpfile
);
3843 fputs (post
, dumpfile
);
3845 if (rok
== T_WARN
&& bind_c
)
3846 fprintf (dumpfile
," /* WARNING: Converting '%s' to interoperable type */",
3850 /* Write out an interoperable type. It will be written as a typedef
3854 write_type (gfc_symbol
*sym
)
3858 fprintf (dumpfile
, "typedef struct %s {\n", sym
->name
);
3859 for (c
= sym
->components
; c
; c
= c
->next
)
3861 fputs (" ", dumpfile
);
3862 write_decl (&(c
->ts
), c
->as
, c
->name
, false, &sym
->declared_at
, true);
3863 fputs (";\n", dumpfile
);
3866 fprintf (dumpfile
, "} %s;\n", sym
->name
);
3869 /* Write out a variable. */
3872 write_variable (gfc_symbol
*sym
)
3874 const char *sym_name
;
3876 gcc_assert (sym
->attr
.flavor
== FL_VARIABLE
);
3878 if (sym
->binding_label
)
3879 sym_name
= sym
->binding_label
;
3881 sym_name
= sym
->name
;
3883 fputs ("extern ", dumpfile
);
3884 write_decl (&(sym
->ts
), sym
->as
, sym_name
, false, &sym
->declared_at
, true);
3885 fputs (";\n", dumpfile
);
3889 /* Write out a procedure, including its arguments. */
3891 write_proc (gfc_symbol
*sym
, bool bind_c
)
3893 const char *pre
, *type_name
, *post
;
3895 enum type_return rok
;
3896 gfc_formal_arglist
*f
;
3897 const char *sym_name
;
3898 const char *intent_in
;
3899 bool external_character
;
3901 external_character
= sym
->ts
.type
== BT_CHARACTER
&& !bind_c
;
3903 if (sym
->binding_label
)
3904 sym_name
= sym
->binding_label
;
3906 sym_name
= sym
->name
;
3908 if (sym
->ts
.type
== BT_UNKNOWN
|| external_character
)
3910 fprintf (dumpfile
, "void ");
3911 fputs (sym_name
, dumpfile
);
3914 write_decl (&(sym
->ts
), sym
->as
, sym_name
, true, &sym
->declared_at
, bind_c
);
3917 fputs ("_", dumpfile
);
3919 fputs (" (", dumpfile
);
3920 if (external_character
)
3922 fprintf (dumpfile
, "char *result_%s, size_t result_%s_len",
3923 sym_name
, sym_name
);
3925 fputs (", ", dumpfile
);
3928 for (f
= sym
->formal
; f
; f
= f
->next
)
3932 rok
= get_c_type_name (&(s
->ts
), NULL
, &pre
, &type_name
, &asterisk
,
3936 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3937 gfc_typename (&s
->ts
), &s
->declared_at
);
3938 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
3939 gfc_typename (&s
->ts
));
3946 if (s
->attr
.intent
== INTENT_IN
&& !s
->attr
.value
)
3947 intent_in
= "const ";
3951 fputs (intent_in
, dumpfile
);
3952 fputs (type_name
, dumpfile
);
3953 fputs (pre
, dumpfile
);
3955 fputs ("*", dumpfile
);
3957 fputs (s
->name
, dumpfile
);
3958 fputs (post
, dumpfile
);
3959 if (bind_c
&& rok
== T_WARN
)
3960 fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile
);
3963 fputs(", ", dumpfile
);
3966 for (f
= sym
->formal
; f
; f
= f
->next
)
3967 if (f
->sym
->ts
.type
== BT_CHARACTER
)
3968 fprintf (dumpfile
, ", size_t %s_len", f
->sym
->name
);
3970 fputs (");\n", dumpfile
);
3974 /* Write a C-interoperable declaration as a C prototype or extern
3978 write_interop_decl (gfc_symbol
*sym
)
3980 /* Only dump bind(c) entities. */
3981 if (!sym
->attr
.is_bind_c
)
3984 /* Don't dump our iso c module. */
3985 if (sym
->from_intmod
== INTMOD_ISO_C_BINDING
)
3988 if (sym
->attr
.flavor
== FL_VARIABLE
)
3989 write_variable (sym
);
3990 else if (sym
->attr
.flavor
== FL_DERIVED
)
3992 else if (sym
->attr
.flavor
== FL_PROCEDURE
)
3993 write_proc (sym
, true);
3996 /* This section deals with dumping the global symbol tree. */
3998 /* Callback function for printing out the contents of the tree. */
4001 show_global_symbol (gfc_gsymbol
*gsym
, void *f_data
)
4004 out
= (FILE *) f_data
;
4007 fprintf (out
, "name=%s", gsym
->name
);
4010 fprintf (out
, ", sym_name=%s", gsym
->sym_name
);
4013 fprintf (out
, ", mod_name=%s", gsym
->mod_name
);
4015 if (gsym
->binding_label
)
4016 fprintf (out
, ", binding_label=%s", gsym
->binding_label
);
4021 /* Show all global symbols. */
4024 gfc_dump_global_symbols (FILE *f
)
4026 if (gfc_gsym_root
== NULL
)
4027 fprintf (f
, "empty\n");
4029 gfc_traverse_gsymbol (gfc_gsym_root
, show_global_symbol
, (void *) f
);
4032 /* Show an array ref. */
4034 void debug (gfc_array_ref
*ar
)
4036 FILE *tmp
= dumpfile
;
4038 show_array_ref (ar
);
4039 fputc ('\n', dumpfile
);