2 Copyright (C) 2003-2024 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. */
40 #include "omp-api.h" /* For omp_get_name_from_fr_id. */
41 #include "gomp-constants.h" /* For GOMP_INTEROP_IFR_SEPARATOR. */
43 /* Keep track of indentation for symbol tree dumps. */
44 static int show_level
= 0;
46 /* The file handle we're dumping to is kept in a static variable. This
47 is not too cool, but it avoids a lot of passing it around. */
48 static FILE *dumpfile
;
50 /* Forward declaration of some of the functions. */
51 static void show_expr (gfc_expr
*p
);
52 static void show_code_node (int, gfc_code
*);
53 static void show_namespace (gfc_namespace
*ns
);
54 static void show_code (int, gfc_code
*);
55 static void show_symbol (gfc_symbol
*);
56 static void show_typespec (gfc_typespec
*);
57 static void show_ref (gfc_ref
*);
58 static void show_attr (symbol_attribute
*, const char *);
61 debug (symbol_attribute
*attr
)
65 show_attr (attr
, NULL
);
66 fputc ('\n', dumpfile
);
71 debug (gfc_formal_arglist
*formal
)
75 for (; formal
; formal
= formal
->next
)
77 fputc ('\n', dumpfile
);
78 show_symbol (formal
->sym
);
80 fputc ('\n', dumpfile
);
85 debug (symbol_attribute attr
)
98 fputc (' ', dumpfile
);
99 show_typespec (&e
->ts
);
102 fputs ("() ", dumpfile
);
104 fputc ('\n', dumpfile
);
109 debug (gfc_typespec
*ts
)
111 FILE *tmp
= dumpfile
;
114 fputc ('\n', dumpfile
);
119 debug (gfc_typespec ts
)
127 FILE *tmp
= dumpfile
;
130 fputc ('\n', dumpfile
);
135 debug (gfc_namespace
*ns
)
137 FILE *tmp
= dumpfile
;
140 fputc ('\n', dumpfile
);
145 gfc_debug_expr (gfc_expr
*e
)
147 FILE *tmp
= dumpfile
;
150 fputc ('\n', dumpfile
);
154 /* Allow for dumping of a piece of code in the debugger. */
157 gfc_debug_code (gfc_code
*c
)
159 FILE *tmp
= dumpfile
;
162 fputc ('\n', dumpfile
);
167 debug (gfc_symbol
*sym
)
169 FILE *tmp
= dumpfile
;
172 fputc ('\n', dumpfile
);
176 /* Do indentation for a specific level. */
179 code_indent (int level
, gfc_st_label
*label
)
184 fprintf (dumpfile
, "%-5d ", label
->value
);
186 for (i
= 0; i
< (2 * level
- (label
? 6 : 0)); i
++)
187 fputc (' ', dumpfile
);
191 /* Simple indentation at the current level. This one
192 is used to show symbols. */
197 fputc ('\n', dumpfile
);
198 code_indent (show_level
, NULL
);
202 /* Show type-specific information. */
205 show_typespec (gfc_typespec
*ts
)
207 if (ts
->type
== BT_ASSUMED
)
209 fputs ("(TYPE(*))", dumpfile
);
213 fprintf (dumpfile
, "(%s ", gfc_basic_typename (ts
->type
));
220 fprintf (dumpfile
, "%s", ts
->u
.derived
->name
);
225 show_expr (ts
->u
.cl
->length
);
226 fprintf(dumpfile
, " %d", ts
->kind
);
230 fprintf (dumpfile
, "%d", ts
->kind
);
233 if (ts
->is_c_interop
)
234 fputs (" C_INTEROP", dumpfile
);
237 fputs (" ISO_C", dumpfile
);
240 fputs (" DEFERRED", dumpfile
);
242 fputc (')', dumpfile
);
246 /* Show an actual argument list. */
249 show_actual_arglist (gfc_actual_arglist
*a
)
251 fputc ('(', dumpfile
);
253 for (; a
; a
= a
->next
)
255 fputc ('(', dumpfile
);
257 fprintf (dumpfile
, "%s = ", a
->name
);
261 fputs ("(arg not-present)", dumpfile
);
263 fputc (')', dumpfile
);
265 fputc (' ', dumpfile
);
268 fputc (')', dumpfile
);
272 /* Show a gfc_array_spec array specification structure. */
275 show_array_spec (gfc_array_spec
*as
)
282 fputs ("()", dumpfile
);
286 fprintf (dumpfile
, "(%d [%d]", as
->rank
, as
->corank
);
288 if (as
->rank
+ as
->corank
> 0 || as
->rank
== -1)
292 case AS_EXPLICIT
: c
= "AS_EXPLICIT"; break;
293 case AS_DEFERRED
: c
= "AS_DEFERRED"; break;
294 case AS_ASSUMED_SIZE
: c
= "AS_ASSUMED_SIZE"; break;
295 case AS_ASSUMED_SHAPE
: c
= "AS_ASSUMED_SHAPE"; break;
296 case AS_ASSUMED_RANK
: c
= "AS_ASSUMED_RANK"; break;
298 gfc_internal_error ("show_array_spec(): Unhandled array shape "
301 fprintf (dumpfile
, " %s ", c
);
303 for (i
= 0; i
< as
->rank
+ as
->corank
; i
++)
305 show_expr (as
->lower
[i
]);
306 fputc (' ', dumpfile
);
307 show_expr (as
->upper
[i
]);
308 fputc (' ', dumpfile
);
312 fputc (')', dumpfile
);
316 /* Show a gfc_array_ref array reference structure. */
319 show_array_ref (gfc_array_ref
* ar
)
323 fputc ('(', dumpfile
);
328 fputs ("FULL", dumpfile
);
332 for (i
= 0; i
< ar
->dimen
; i
++)
334 /* There are two types of array sections: either the
335 elements are identified by an integer array ('vector'),
336 or by an index range. In the former case we only have to
337 print the start expression which contains the vector, in
338 the latter case we have to print any of lower and upper
339 bound and the stride, if they're present. */
341 if (ar
->start
[i
] != NULL
)
342 show_expr (ar
->start
[i
]);
344 if (ar
->dimen_type
[i
] == DIMEN_RANGE
)
346 fputc (':', dumpfile
);
348 if (ar
->end
[i
] != NULL
)
349 show_expr (ar
->end
[i
]);
351 if (ar
->stride
[i
] != NULL
)
353 fputc (':', dumpfile
);
354 show_expr (ar
->stride
[i
]);
358 if (i
!= ar
->dimen
- 1)
359 fputs (" , ", dumpfile
);
364 for (i
= 0; i
< ar
->dimen
; i
++)
366 show_expr (ar
->start
[i
]);
367 if (i
!= ar
->dimen
- 1)
368 fputs (" , ", dumpfile
);
373 fputs ("UNKNOWN", dumpfile
);
377 gfc_internal_error ("show_array_ref(): Unknown array reference");
380 fputc (')', dumpfile
);
381 if (ar
->codimen
== 0)
384 /* Show coarray part of the reference, if any. */
385 fputc ('[',dumpfile
);
386 for (i
= ar
->dimen
; i
< ar
->dimen
+ ar
->codimen
; i
++)
388 if (ar
->dimen_type
[i
] == DIMEN_STAR
)
390 else if (ar
->dimen_type
[i
] == DIMEN_THIS_IMAGE
)
391 fputs("THIS_IMAGE", dumpfile
);
394 show_expr (ar
->start
[i
]);
397 fputc(':', dumpfile
);
398 show_expr (ar
->end
[i
]);
401 if (i
!= ar
->dimen
+ ar
->codimen
- 1)
402 fputs (" , ", dumpfile
);
405 fputc (']',dumpfile
);
409 /* Show a list of gfc_ref structures. */
412 show_ref (gfc_ref
*p
)
414 for (; p
; p
= p
->next
)
418 show_array_ref (&p
->u
.ar
);
422 fprintf (dumpfile
, " %% %s", p
->u
.c
.component
->name
);
426 fputc ('(', dumpfile
);
427 show_expr (p
->u
.ss
.start
);
428 fputc (':', dumpfile
);
429 show_expr (p
->u
.ss
.end
);
430 fputc (')', dumpfile
);
437 fprintf (dumpfile
, " INQUIRY_KIND ");
440 fprintf (dumpfile
, " INQUIRY_LEN ");
443 fprintf (dumpfile
, " INQUIRY_RE ");
446 fprintf (dumpfile
, " INQUIRY_IM ");
451 gfc_internal_error ("show_ref(): Bad component code");
456 /* Display a constructor. Works recursively for array constructors. */
459 show_constructor (gfc_constructor_base base
)
462 for (c
= gfc_constructor_first (base
); c
; c
= gfc_constructor_next (c
))
464 if (c
->iterator
== NULL
)
468 fputc ('(', dumpfile
);
471 fputc (' ', dumpfile
);
472 show_expr (c
->iterator
->var
);
473 fputc ('=', dumpfile
);
474 show_expr (c
->iterator
->start
);
475 fputc (',', dumpfile
);
476 show_expr (c
->iterator
->end
);
477 fputc (',', dumpfile
);
478 show_expr (c
->iterator
->step
);
480 fputc (')', dumpfile
);
483 if (gfc_constructor_next (c
) != NULL
)
484 fputs (" , ", dumpfile
);
490 show_char_const (const gfc_char_t
*c
, gfc_charlen_t length
)
492 fputc ('\'', dumpfile
);
493 for (size_t i
= 0; i
< (size_t) length
; i
++)
496 fputs ("''", dumpfile
);
498 fputs (gfc_print_wide_char (c
[i
]), dumpfile
);
500 fputc ('\'', dumpfile
);
504 /* Show a component-call expression. */
507 show_compcall (gfc_expr
* p
)
509 gcc_assert (p
->expr_type
== EXPR_COMPCALL
);
511 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
513 fprintf (dumpfile
, "%s", p
->value
.compcall
.name
);
515 show_actual_arglist (p
->value
.compcall
.actual
);
519 /* Show an expression. */
522 show_expr (gfc_expr
*p
)
529 fputs ("()", dumpfile
);
533 switch (p
->expr_type
)
536 show_char_const (p
->value
.character
.string
, p
->value
.character
.length
);
541 fprintf (dumpfile
, "%s(", p
->ts
.u
.derived
->name
);
542 show_constructor (p
->value
.constructor
);
543 fputc (')', dumpfile
);
547 fputs ("(/ ", dumpfile
);
548 show_constructor (p
->value
.constructor
);
549 fputs (" /)", dumpfile
);
555 fputs ("NULL()", dumpfile
);
562 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
564 if (p
->ts
.kind
!= gfc_default_integer_kind
)
565 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
569 mpz_out_str (dumpfile
, 10, p
->value
.integer
);
570 fputc('u', dumpfile
);
572 if (p
->ts
.kind
!= gfc_default_integer_kind
)
573 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
577 if (p
->value
.logical
)
578 fputs (".true.", dumpfile
);
580 fputs (".false.", dumpfile
);
584 mpfr_out_str (dumpfile
, 10, 0, p
->value
.real
, GFC_RND_MODE
);
585 if (p
->ts
.kind
!= gfc_default_real_kind
)
586 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
590 show_char_const (p
->value
.character
.string
,
591 p
->value
.character
.length
);
595 fputs ("(complex ", dumpfile
);
597 mpfr_out_str (dumpfile
, 10, 0, mpc_realref (p
->value
.complex),
599 if (p
->ts
.kind
!= gfc_default_complex_kind
)
600 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
602 fputc (' ', dumpfile
);
604 mpfr_out_str (dumpfile
, 10, 0, mpc_imagref (p
->value
.complex),
606 if (p
->ts
.kind
!= gfc_default_complex_kind
)
607 fprintf (dumpfile
, "_%d", p
->ts
.kind
);
609 fputc (')', dumpfile
);
614 fputs ("b'", dumpfile
);
615 else if (p
->boz
.rdx
== 8)
616 fputs ("o'", dumpfile
);
618 fputs ("z'", dumpfile
);
619 fprintf (dumpfile
, "%s'", p
->boz
.str
);
623 fprintf (dumpfile
, HOST_WIDE_INT_PRINT_DEC
"H",
624 p
->representation
.length
);
625 c
= p
->representation
.string
;
626 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
628 fputc (*c
, dumpfile
);
633 fputs ("???", dumpfile
);
637 if (p
->representation
.string
)
639 fputs (" {", dumpfile
);
640 c
= p
->representation
.string
;
641 for (i
= 0; i
< p
->representation
.length
; i
++, c
++)
643 fprintf (dumpfile
, "%.2x", (unsigned int) *c
);
644 if (i
< p
->representation
.length
- 1)
645 fputc (',', dumpfile
);
647 fputc ('}', dumpfile
);
653 if (p
->symtree
->n
.sym
->ns
&& p
->symtree
->n
.sym
->ns
->proc_name
)
654 fprintf (dumpfile
, "%s:", p
->symtree
->n
.sym
->ns
->proc_name
->name
);
655 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
660 fputc ('(', dumpfile
);
661 switch (p
->value
.op
.op
)
663 case INTRINSIC_UPLUS
:
664 fputs ("U+ ", dumpfile
);
666 case INTRINSIC_UMINUS
:
667 fputs ("U- ", dumpfile
);
670 fputs ("+ ", dumpfile
);
672 case INTRINSIC_MINUS
:
673 fputs ("- ", dumpfile
);
675 case INTRINSIC_TIMES
:
676 fputs ("* ", dumpfile
);
678 case INTRINSIC_DIVIDE
:
679 fputs ("/ ", dumpfile
);
681 case INTRINSIC_POWER
:
682 fputs ("** ", dumpfile
);
684 case INTRINSIC_CONCAT
:
685 fputs ("// ", dumpfile
);
688 fputs ("AND ", dumpfile
);
691 fputs ("OR ", dumpfile
);
694 fputs ("EQV ", dumpfile
);
697 fputs ("NEQV ", dumpfile
);
700 case INTRINSIC_EQ_OS
:
701 fputs ("== ", dumpfile
);
704 case INTRINSIC_NE_OS
:
705 fputs ("/= ", dumpfile
);
708 case INTRINSIC_GT_OS
:
709 fputs ("> ", dumpfile
);
712 case INTRINSIC_GE_OS
:
713 fputs (">= ", dumpfile
);
716 case INTRINSIC_LT_OS
:
717 fputs ("< ", dumpfile
);
720 case INTRINSIC_LE_OS
:
721 fputs ("<= ", dumpfile
);
724 fputs ("NOT ", dumpfile
);
726 case INTRINSIC_PARENTHESES
:
727 fputs ("parens ", dumpfile
);
732 ("show_expr(): Bad intrinsic in expression");
735 show_expr (p
->value
.op
.op1
);
739 fputc (' ', dumpfile
);
740 show_expr (p
->value
.op
.op2
);
743 fputc (')', dumpfile
);
747 if (p
->value
.function
.name
== NULL
)
749 fprintf (dumpfile
, "%s", p
->symtree
->n
.sym
->name
);
750 if (gfc_is_proc_ptr_comp (p
))
752 fputc ('[', dumpfile
);
753 show_actual_arglist (p
->value
.function
.actual
);
754 fputc (']', dumpfile
);
758 fprintf (dumpfile
, "%s", p
->value
.function
.name
);
759 if (gfc_is_proc_ptr_comp (p
))
761 fputc ('[', dumpfile
);
762 fputc ('[', dumpfile
);
763 show_actual_arglist (p
->value
.function
.actual
);
764 fputc (']', dumpfile
);
765 fputc (']', dumpfile
);
775 gfc_internal_error ("show_expr(): Don't know how to show expr");
779 /* Show symbol attributes. The flavor and intent are followed by
780 whatever single bit attributes are present. */
783 show_attr (symbol_attribute
*attr
, const char * module
)
785 fputc ('(', dumpfile
);
786 if (attr
->flavor
!= FL_UNKNOWN
)
788 if (attr
->flavor
== FL_DERIVED
&& attr
->pdt_template
)
789 fputs ("PDT-TEMPLATE ", dumpfile
);
791 fprintf (dumpfile
, "%s ", gfc_code2string (flavors
, attr
->flavor
));
793 if (attr
->access
!= ACCESS_UNKNOWN
)
794 fprintf (dumpfile
, "%s ", gfc_code2string (access_types
, attr
->access
));
795 if (attr
->proc
!= PROC_UNKNOWN
)
796 fprintf (dumpfile
, "%s ", gfc_code2string (procedures
, attr
->proc
));
797 if (attr
->save
!= SAVE_NONE
)
798 fprintf (dumpfile
, "%s", gfc_code2string (save_status
, attr
->save
));
800 if (attr
->artificial
)
801 fputs (" ARTIFICIAL", dumpfile
);
802 if (attr
->allocatable
)
803 fputs (" ALLOCATABLE", dumpfile
);
804 if (attr
->asynchronous
)
805 fputs (" ASYNCHRONOUS", dumpfile
);
806 if (attr
->codimension
)
807 fputs (" CODIMENSION", dumpfile
);
809 fputs (" DIMENSION", dumpfile
);
810 if (attr
->contiguous
)
811 fputs (" CONTIGUOUS", dumpfile
);
813 fputs (" EXTERNAL", dumpfile
);
815 fputs (" INTRINSIC", dumpfile
);
817 fputs (" OPTIONAL", dumpfile
);
819 fputs (" KIND", dumpfile
);
821 fputs (" LEN", dumpfile
);
823 fputs (" POINTER", dumpfile
);
824 if (attr
->subref_array_pointer
)
825 fputs (" SUBREF-ARRAY-POINTER", dumpfile
);
826 if (attr
->cray_pointer
)
827 fputs (" CRAY-POINTER", dumpfile
);
828 if (attr
->cray_pointee
)
829 fputs (" CRAY-POINTEE", dumpfile
);
830 if (attr
->is_protected
)
831 fputs (" PROTECTED", dumpfile
);
833 fputs (" VALUE", dumpfile
);
835 fputs (" VOLATILE", dumpfile
);
836 if (attr
->threadprivate
)
837 fputs (" THREADPRIVATE", dumpfile
);
839 fputs (" TARGET", dumpfile
);
842 fputs (" DUMMY", dumpfile
);
843 if (attr
->intent
!= INTENT_UNKNOWN
)
844 fprintf (dumpfile
, "(%s)", gfc_intent_string (attr
->intent
));
848 fputs (" RESULT", dumpfile
);
850 fputs (" ENTRY", dumpfile
);
851 if (attr
->entry_master
)
852 fputs (" ENTRY-MASTER", dumpfile
);
853 if (attr
->mixed_entry_master
)
854 fputs (" MIXED-ENTRY-MASTER", dumpfile
);
856 fputs (" BIND(C)", dumpfile
);
859 fputs (" DATA", dumpfile
);
862 fputs (" USE-ASSOC", dumpfile
);
864 fprintf (dumpfile
, "(%s)", module
);
867 if (attr
->in_namelist
)
868 fputs (" IN-NAMELIST", dumpfile
);
870 fputs (" IN-COMMON", dumpfile
);
873 fputs (" ABSTRACT", dumpfile
);
875 fputs (" FUNCTION", dumpfile
);
876 if (attr
->subroutine
)
877 fputs (" SUBROUTINE", dumpfile
);
878 if (attr
->implicit_type
)
879 fputs (" IMPLICIT-TYPE", dumpfile
);
882 fputs (" SEQUENCE", dumpfile
);
883 if (attr
->alloc_comp
)
884 fputs (" ALLOC-COMP", dumpfile
);
885 if (attr
->pointer_comp
)
886 fputs (" POINTER-COMP", dumpfile
);
887 if (attr
->proc_pointer_comp
)
888 fputs (" PROC-POINTER-COMP", dumpfile
);
889 if (attr
->private_comp
)
890 fputs (" PRIVATE-COMP", dumpfile
);
892 fputs (" ZERO-COMP", dumpfile
);
893 if (attr
->coarray_comp
)
894 fputs (" COARRAY-COMP", dumpfile
);
896 fputs (" LOCK-COMP", dumpfile
);
897 if (attr
->event_comp
)
898 fputs (" EVENT-COMP", dumpfile
);
899 if (attr
->defined_assign_comp
)
900 fputs (" DEFINED-ASSIGNED-COMP", dumpfile
);
901 if (attr
->unlimited_polymorphic
)
902 fputs (" UNLIMITED-POLYMORPHIC", dumpfile
);
903 if (attr
->has_dtio_procs
)
904 fputs (" HAS-DTIO-PROCS", dumpfile
);
906 fputs (" CAF-TOKEN", dumpfile
);
907 if (attr
->select_type_temporary
)
908 fputs (" SELECT-TYPE-TEMPORARY", dumpfile
);
909 if (attr
->associate_var
)
910 fputs (" ASSOCIATE-VAR", dumpfile
);
912 fputs (" PDT-KIND", dumpfile
);
914 fputs (" PDT-LEN", dumpfile
);
916 fputs (" PDT-TYPE", dumpfile
);
918 fputs (" PDT-ARRAY", dumpfile
);
919 if (attr
->pdt_string
)
920 fputs (" PDT-STRING", dumpfile
);
921 if (attr
->omp_udr_artificial_var
)
922 fputs (" OMP-UDR-ARTIFICIAL-VAR", dumpfile
);
923 if (attr
->omp_declare_target
)
924 fputs (" OMP-DECLARE-TARGET", dumpfile
);
925 if (attr
->omp_declare_target_link
)
926 fputs (" OMP-DECLARE-TARGET-LINK", dumpfile
);
927 if (attr
->omp_declare_target_indirect
)
928 fputs (" OMP-DECLARE-TARGET-INDIRECT", dumpfile
);
930 fputs (" ELEMENTAL", dumpfile
);
932 fputs (" PURE", dumpfile
);
933 if (attr
->implicit_pure
)
934 fputs (" IMPLICIT-PURE", dumpfile
);
936 fputs (" RECURSIVE", dumpfile
);
937 if (attr
->unmaskable
)
938 fputs (" UNMASKABKE", dumpfile
);
940 fputs (" MASKED", dumpfile
);
942 fputs (" CONTAINED", dumpfile
);
944 fputs (" MOD-PROC", dumpfile
);
945 if (attr
->module_procedure
)
946 fputs (" MODULE-PROCEDURE", dumpfile
);
947 if (attr
->public_used
)
948 fputs (" PUBLIC_USED", dumpfile
);
949 if (attr
->array_outer_dependency
)
950 fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile
);
952 fputs (" NORETURN", dumpfile
);
953 if (attr
->always_explicit
)
954 fputs (" ALWAYS-EXPLICIT", dumpfile
);
955 if (attr
->is_main_program
)
956 fputs (" IS-MAIN-PROGRAM", dumpfile
);
957 if (attr
->oacc_routine_nohost
)
958 fputs (" OACC-ROUTINE-NOHOST", dumpfile
);
960 /* FIXME: Still missing are oacc_routine_lop and ext_attr. */
961 fputc (')', dumpfile
);
965 /* Show components of a derived type. */
968 show_components (gfc_symbol
*sym
)
972 for (c
= sym
->components
; c
; c
= c
->next
)
975 fprintf (dumpfile
, "(%s ", c
->name
);
976 show_typespec (&c
->ts
);
979 fputs (" kind_expr: ", dumpfile
);
980 show_expr (c
->kind_expr
);
984 fputs ("PDT parameters", dumpfile
);
985 show_actual_arglist (c
->param_list
);
988 if (c
->attr
.allocatable
)
989 fputs (" ALLOCATABLE", dumpfile
);
990 if (c
->attr
.pdt_kind
)
991 fputs (" KIND", dumpfile
);
993 fputs (" LEN", dumpfile
);
995 fputs (" POINTER", dumpfile
);
996 if (c
->attr
.proc_pointer
)
997 fputs (" PPC", dumpfile
);
998 if (c
->attr
.dimension
)
999 fputs (" DIMENSION", dumpfile
);
1000 fputc (' ', dumpfile
);
1001 show_array_spec (c
->as
);
1003 fprintf (dumpfile
, " %s", gfc_code2string (access_types
, c
->attr
.access
));
1004 fputc (')', dumpfile
);
1005 if (c
->next
!= NULL
)
1006 fputc (' ', dumpfile
);
1011 /* Show the f2k_derived namespace with procedure bindings. */
1014 show_typebound_proc (gfc_typebound_proc
* tb
, const char* name
)
1019 fputs ("GENERIC", dumpfile
);
1022 fputs ("PROCEDURE, ", dumpfile
);
1024 fputs ("NOPASS", dumpfile
);
1028 fprintf (dumpfile
, "PASS(%s)", tb
->pass_arg
);
1030 fputs ("PASS", dumpfile
);
1032 if (tb
->non_overridable
)
1033 fputs (", NON_OVERRIDABLE", dumpfile
);
1036 if (tb
->access
== ACCESS_PUBLIC
)
1037 fputs (", PUBLIC", dumpfile
);
1039 fputs (", PRIVATE", dumpfile
);
1041 fprintf (dumpfile
, " :: %s => ", name
);
1046 for (g
= tb
->u
.generic
; g
; g
= g
->next
)
1048 fputs (g
->specific_st
->name
, dumpfile
);
1050 fputs (", ", dumpfile
);
1054 fputs (tb
->u
.specific
->n
.sym
->name
, dumpfile
);
1058 show_typebound_symtree (gfc_symtree
* st
)
1060 gcc_assert (st
->n
.tb
);
1061 show_typebound_proc (st
->n
.tb
, st
->name
);
1065 show_f2k_derived (gfc_namespace
* f2k
)
1071 fputs ("Procedure bindings:", dumpfile
);
1074 /* Finalizer bindings. */
1075 for (f
= f2k
->finalizers
; f
; f
= f
->next
)
1078 fprintf (dumpfile
, "FINAL %s", f
->proc_tree
->n
.sym
->name
);
1081 /* Type-bound procedures. */
1082 gfc_traverse_symtree (f2k
->tb_sym_root
, &show_typebound_symtree
);
1087 fputs ("Operator bindings:", dumpfile
);
1090 /* User-defined operators. */
1091 gfc_traverse_symtree (f2k
->tb_uop_root
, &show_typebound_symtree
);
1093 /* Intrinsic operators. */
1094 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; ++op
)
1096 show_typebound_proc (f2k
->tb_op
[op
],
1097 gfc_op2string ((gfc_intrinsic_op
) op
));
1103 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
1104 show the interface. Information needed to reconstruct the list of
1105 specific interfaces associated with a generic symbol is done within
1109 show_symbol (gfc_symbol
*sym
)
1111 gfc_formal_arglist
*formal
;
1112 gfc_interface
*intr
;
1118 fprintf (dumpfile
, "|| symbol: '%s' ", sym
->name
);
1119 len
= strlen (sym
->name
);
1120 for (i
=len
; i
<12; i
++)
1121 fputc(' ', dumpfile
);
1123 if (sym
->binding_label
)
1124 fprintf (dumpfile
,"|| binding_label: '%s' ", sym
->binding_label
);
1129 fputs ("type spec : ", dumpfile
);
1130 show_typespec (&sym
->ts
);
1133 fputs ("attributes: ", dumpfile
);
1134 show_attr (&sym
->attr
, sym
->module
);
1139 fputs ("value: ", dumpfile
);
1140 show_expr (sym
->value
);
1143 if (sym
->ts
.type
!= BT_CLASS
&& sym
->as
)
1146 fputs ("Array spec:", dumpfile
);
1147 show_array_spec (sym
->as
);
1149 else if (sym
->ts
.type
== BT_CLASS
&& CLASS_DATA (sym
)->as
)
1152 fputs ("Array spec:", dumpfile
);
1153 show_array_spec (CLASS_DATA (sym
)->as
);
1159 fputs ("Generic interfaces:", dumpfile
);
1160 for (intr
= sym
->generic
; intr
; intr
= intr
->next
)
1161 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1167 fprintf (dumpfile
, "result: %s", sym
->result
->name
);
1170 if (sym
->components
)
1173 fputs ("components: ", dumpfile
);
1174 show_components (sym
);
1177 if (sym
->f2k_derived
)
1180 if (sym
->hash_value
)
1181 fprintf (dumpfile
, "hash: %d", sym
->hash_value
);
1182 show_f2k_derived (sym
->f2k_derived
);
1188 fputs ("Formal arglist:", dumpfile
);
1190 for (formal
= sym
->formal
; formal
; formal
= formal
->next
)
1192 if (formal
->sym
!= NULL
)
1193 fprintf (dumpfile
, " %s", formal
->sym
->name
);
1195 fputs (" [Alt Return]", dumpfile
);
1199 if (sym
->formal_ns
&& (sym
->formal_ns
->proc_name
!= sym
)
1200 && sym
->attr
.proc
!= PROC_ST_FUNCTION
1201 && !sym
->attr
.entry
)
1204 fputs ("Formal namespace", dumpfile
);
1205 show_namespace (sym
->formal_ns
);
1208 if (sym
->attr
.flavor
== FL_VARIABLE
1212 fputs ("PDT parameters", dumpfile
);
1213 show_actual_arglist (sym
->param_list
);
1216 if (sym
->attr
.flavor
== FL_NAMELIST
)
1220 fputs ("variables : ", dumpfile
);
1221 for (nl
= sym
->namelist
; nl
; nl
= nl
->next
)
1222 fprintf (dumpfile
, " %s",nl
->sym
->name
);
1229 /* Show a user-defined operator. Just prints an operator
1230 and the name of the associated subroutine, really. */
1233 show_uop (gfc_user_op
*uop
)
1235 gfc_interface
*intr
;
1238 fprintf (dumpfile
, "%s:", uop
->name
);
1240 for (intr
= uop
->op
; intr
; intr
= intr
->next
)
1241 fprintf (dumpfile
, " %s", intr
->sym
->name
);
1245 /* Workhorse function for traversing the user operator symtree. */
1248 traverse_uop (gfc_symtree
*st
, void (*func
) (gfc_user_op
*))
1253 (*func
) (st
->n
.uop
);
1255 traverse_uop (st
->left
, func
);
1256 traverse_uop (st
->right
, func
);
1260 /* Traverse the tree of user operator nodes. */
1263 gfc_traverse_user_op (gfc_namespace
*ns
, void (*func
) (gfc_user_op
*))
1265 traverse_uop (ns
->uop_root
, func
);
1269 /* Function to display a common block. */
1272 show_common (gfc_symtree
*st
)
1277 fprintf (dumpfile
, "common: /%s/ ", st
->name
);
1279 s
= st
->n
.common
->head
;
1282 fprintf (dumpfile
, "%s", s
->name
);
1285 fputs (", ", dumpfile
);
1287 fputc ('\n', dumpfile
);
1291 /* Worker function to display the symbol tree. */
1294 show_symtree (gfc_symtree
*st
)
1300 len
= strlen(st
->name
);
1301 fprintf (dumpfile
, "symtree: '%s'", st
->name
);
1303 for (i
=len
; i
<12; i
++)
1304 fputc(' ', dumpfile
);
1307 fputs( " Ambiguous", dumpfile
);
1309 if (st
->n
.sym
->ns
!= gfc_current_ns
)
1310 fprintf (dumpfile
, "|| symbol: '%s' from namespace '%s'", st
->n
.sym
->name
,
1311 st
->n
.sym
->ns
->proc_name
->name
);
1313 show_symbol (st
->n
.sym
);
1317 /******************* Show gfc_code structures **************/
1320 /* Show a list of code structures. Mutually recursive with
1321 show_code_node(). */
1324 show_code (int level
, gfc_code
*c
)
1326 for (; c
; c
= c
->next
)
1327 show_code_node (level
, c
);
1331 show_iterator (gfc_namespace
*ns
)
1333 for (gfc_symbol
*sym
= ns
->omp_affinity_iterators
; sym
; sym
= sym
->tlink
)
1336 if (sym
!= ns
->omp_affinity_iterators
)
1337 fputc (',', dumpfile
);
1338 fputs (sym
->name
, dumpfile
);
1339 fputc ('=', dumpfile
);
1340 c
= gfc_constructor_first (sym
->value
->value
.constructor
);
1341 show_expr (c
->expr
);
1342 fputc (':', dumpfile
);
1343 c
= gfc_constructor_next (c
);
1344 show_expr (c
->expr
);
1345 c
= gfc_constructor_next (c
);
1348 fputc (':', dumpfile
);
1349 show_expr (c
->expr
);
1355 show_omp_namelist (int list_type
, gfc_omp_namelist
*n
)
1357 gfc_namespace
*ns_iter
= NULL
, *ns_curr
= gfc_current_ns
;
1358 gfc_omp_namelist
*n2
= n
;
1359 for (; n
; n
= n
->next
)
1361 gfc_current_ns
= ns_curr
;
1362 if (list_type
== OMP_LIST_AFFINITY
|| list_type
== OMP_LIST_DEPEND
)
1364 gfc_current_ns
= n
->u2
.ns
? n
->u2
.ns
: ns_curr
;
1365 if (n
->u2
.ns
!= ns_iter
)
1369 fputs (") ", dumpfile
);
1370 if (list_type
== OMP_LIST_AFFINITY
)
1371 fputs ("AFFINITY (", dumpfile
);
1372 else if (n
->u
.depend_doacross_op
== OMP_DOACROSS_SINK_FIRST
)
1373 fputs ("DOACROSS (", dumpfile
);
1375 fputs ("DEPEND (", dumpfile
);
1379 fputs ("ITERATOR(", dumpfile
);
1380 show_iterator (n
->u2
.ns
);
1381 fputc (')', dumpfile
);
1382 fputc (list_type
== OMP_LIST_AFFINITY
? ':' : ',', dumpfile
);
1387 else if (list_type
== OMP_LIST_INIT
&& n
!= n2
)
1388 fputs (") INIT(", dumpfile
);
1389 if (list_type
== OMP_LIST_ALLOCATE
)
1391 if (n
->u2
.allocator
)
1393 fputs ("allocator(", dumpfile
);
1394 show_expr (n
->u2
.allocator
);
1395 fputc (')', dumpfile
);
1397 if (n
->expr
&& n
->u
.align
)
1398 fputc (',', dumpfile
);
1401 fputs ("align(", dumpfile
);
1402 show_expr (n
->u
.align
);
1403 fputc (')', dumpfile
);
1405 if (n
->u2
.allocator
|| n
->u
.align
)
1406 fputc (':', dumpfile
);
1408 show_expr (n
->expr
);
1410 fputs (n
->sym
->name
, dumpfile
);
1412 fputs (") ALLOCATE(", dumpfile
);
1415 if ((list_type
== OMP_LIST_MAP
|| list_type
== OMP_LIST_CACHE
)
1416 && n
->u
.map
.readonly
)
1417 fputs ("readonly,", dumpfile
);
1418 if (list_type
== OMP_LIST_REDUCTION
)
1419 switch (n
->u
.reduction_op
)
1421 case OMP_REDUCTION_PLUS
:
1422 case OMP_REDUCTION_TIMES
:
1423 case OMP_REDUCTION_MINUS
:
1424 case OMP_REDUCTION_AND
:
1425 case OMP_REDUCTION_OR
:
1426 case OMP_REDUCTION_EQV
:
1427 case OMP_REDUCTION_NEQV
:
1428 fprintf (dumpfile
, "%s:",
1429 gfc_op2string ((gfc_intrinsic_op
) n
->u
.reduction_op
));
1431 case OMP_REDUCTION_MAX
: fputs ("max:", dumpfile
); break;
1432 case OMP_REDUCTION_MIN
: fputs ("min:", dumpfile
); break;
1433 case OMP_REDUCTION_IAND
: fputs ("iand:", dumpfile
); break;
1434 case OMP_REDUCTION_IOR
: fputs ("ior:", dumpfile
); break;
1435 case OMP_REDUCTION_IEOR
: fputs ("ieor:", dumpfile
); break;
1436 case OMP_REDUCTION_USER
:
1438 fprintf (dumpfile
, "%s:", n
->u2
.udr
->udr
->name
);
1442 else if (list_type
== OMP_LIST_DEPEND
)
1443 switch (n
->u
.depend_doacross_op
)
1445 case OMP_DEPEND_IN
: fputs ("in:", dumpfile
); break;
1446 case OMP_DEPEND_OUT
: fputs ("out:", dumpfile
); break;
1447 case OMP_DEPEND_INOUT
: fputs ("inout:", dumpfile
); break;
1448 case OMP_DEPEND_INOUTSET
: fputs ("inoutset:", dumpfile
); break;
1449 case OMP_DEPEND_DEPOBJ
: fputs ("depobj:", dumpfile
); break;
1450 case OMP_DEPEND_MUTEXINOUTSET
:
1451 fputs ("mutexinoutset:", dumpfile
);
1453 case OMP_DEPEND_SINK_FIRST
:
1454 case OMP_DOACROSS_SINK_FIRST
:
1455 fputs ("sink:", dumpfile
);
1459 fputs ("omp_cur_iteration", dumpfile
);
1461 fprintf (dumpfile
, "%s", n
->sym
->name
);
1464 fputc ('+', dumpfile
);
1465 show_expr (n
->expr
);
1467 if (n
->next
== NULL
)
1469 else if (n
->next
->u
.depend_doacross_op
!= OMP_DOACROSS_SINK
)
1471 if (n
->next
->u
.depend_doacross_op
1472 == OMP_DOACROSS_SINK_FIRST
)
1473 fputs (") DOACROSS(", dumpfile
);
1475 fputs (") DEPEND(", dumpfile
);
1478 fputc (',', dumpfile
);
1484 else if (list_type
== OMP_LIST_MAP
)
1485 switch (n
->u
.map
.op
)
1487 case OMP_MAP_ALLOC
: fputs ("alloc:", dumpfile
); break;
1488 case OMP_MAP_TO
: fputs ("to:", dumpfile
); break;
1489 case OMP_MAP_FROM
: fputs ("from:", dumpfile
); break;
1490 case OMP_MAP_TOFROM
: fputs ("tofrom:", dumpfile
); break;
1491 case OMP_MAP_PRESENT_ALLOC
: fputs ("present,alloc:", dumpfile
); break;
1492 case OMP_MAP_PRESENT_TO
: fputs ("present,to:", dumpfile
); break;
1493 case OMP_MAP_PRESENT_FROM
: fputs ("present,from:", dumpfile
); break;
1494 case OMP_MAP_PRESENT_TOFROM
:
1495 fputs ("present,tofrom:", dumpfile
); break;
1496 case OMP_MAP_ALWAYS_TO
: fputs ("always,to:", dumpfile
); break;
1497 case OMP_MAP_ALWAYS_FROM
: fputs ("always,from:", dumpfile
); break;
1498 case OMP_MAP_ALWAYS_TOFROM
: fputs ("always,tofrom:", dumpfile
); break;
1499 case OMP_MAP_ALWAYS_PRESENT_TO
:
1500 fputs ("always,present,to:", dumpfile
); break;
1501 case OMP_MAP_ALWAYS_PRESENT_FROM
:
1502 fputs ("always,present,from:", dumpfile
); break;
1503 case OMP_MAP_ALWAYS_PRESENT_TOFROM
:
1504 fputs ("always,present,tofrom:", dumpfile
); break;
1505 case OMP_MAP_DELETE
: fputs ("delete:", dumpfile
); break;
1506 case OMP_MAP_RELEASE
: fputs ("release:", dumpfile
); break;
1509 else if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.old_modifier
)
1510 switch (n
->u
.linear
.op
)
1512 case OMP_LINEAR_REF
: fputs ("ref(", dumpfile
); break;
1513 case OMP_LINEAR_VAL
: fputs ("val(", dumpfile
); break;
1514 case OMP_LINEAR_UVAL
: fputs ("uval(", dumpfile
); break;
1517 else if (list_type
== OMP_LIST_USES_ALLOCATORS
)
1519 if (n
->u
.memspace_sym
)
1521 fputs ("memspace(", dumpfile
);
1522 fputs (n
->sym
->name
, dumpfile
);
1523 fputc (')', dumpfile
);
1525 if (n
->u
.memspace_sym
&& n
->u2
.traits_sym
)
1526 fputc (',', dumpfile
);
1527 if (n
->u2
.traits_sym
)
1529 fputs ("traits(", dumpfile
);
1530 fputs (n
->u2
.traits_sym
->name
, dumpfile
);
1531 fputc (')', dumpfile
);
1533 if (n
->u
.memspace_sym
|| n
->u2
.traits_sym
)
1534 fputc (':', dumpfile
);
1535 fputs (n
->sym
->name
, dumpfile
);
1537 fputs (", ", dumpfile
);
1540 else if (list_type
== OMP_LIST_INIT
)
1542 if (n
->u
.init
.target
)
1543 fputs ("target,", dumpfile
);
1544 if (n
->u
.init
.targetsync
)
1545 fputs ("targetsync,", dumpfile
);
1546 if (n
->u2
.init_interop_fr
)
1548 char *attr_str
= n
->u
.init
.attr
;
1551 fputs ("prefer_type(", dumpfile
);
1554 fr_id
= n
->u2
.init_interop_fr
[idx
];
1555 fputc ('{', dumpfile
);
1556 if (fr_id
!= GOMP_INTEROP_IFR_NONE
)
1558 fputs ("fr(", dumpfile
);
1561 const char *fr_str
= omp_get_name_from_fr_id (fr_id
);
1563 fprintf (dumpfile
, "\"%s\"", fr_str
);
1565 fprintf (dumpfile
, "%d", fr_id
);
1566 fr_id
= n
->u2
.init_interop_fr
[++idx
];
1567 if (fr_id
!= GOMP_INTEROP_IFR_SEPARATOR
)
1568 fputc (',', dumpfile
);
1570 while (fr_id
!= GOMP_INTEROP_IFR_SEPARATOR
);
1571 fputc (')', dumpfile
);
1572 if (attr_str
&& (attr_str
[0] != ' ' || attr_str
[1] != '\0'))
1573 fputc (',', dumpfile
);
1576 fr_id
= n
->u2
.init_interop_fr
[++idx
];
1577 if (attr_str
&& attr_str
[0] == ' ' && attr_str
[1] == '\0')
1581 fputs ("attr(\"", dumpfile
);
1584 fputs ((char *) attr_str
, dumpfile
);
1585 fputc ('"', dumpfile
);
1586 attr_str
+= strlen (attr_str
) + 1;
1587 if (attr_str
[0] == '\0')
1589 fputs (",\"", dumpfile
);
1592 fputc (')', dumpfile
);
1594 fputc ('}', dumpfile
);
1595 fr_id
= n
->u2
.init_interop_fr
[++idx
];
1596 if (fr_id
== GOMP_INTEROP_IFR_SEPARATOR
)
1598 fputc (',', dumpfile
);
1603 fputc (')', dumpfile
);
1605 fputc (':', dumpfile
);
1607 fprintf (dumpfile
, "%s", n
->sym
? n
->sym
->name
: "omp_all_memory");
1608 if (list_type
== OMP_LIST_LINEAR
&& n
->u
.linear
.op
!= OMP_LINEAR_DEFAULT
)
1609 fputc (')', dumpfile
);
1612 fputc (':', dumpfile
);
1613 show_expr (n
->expr
);
1616 fputc (',', dumpfile
);
1618 gfc_current_ns
= ns_curr
;
1622 show_omp_assumes (gfc_omp_assumptions
*assume
)
1624 for (int i
= 0; i
< assume
->n_absent
; i
++)
1626 fputs (" ABSENT (", dumpfile
);
1627 fputs (gfc_ascii_statement (assume
->absent
[i
], true), dumpfile
);
1628 fputc (')', dumpfile
);
1630 for (int i
= 0; i
< assume
->n_contains
; i
++)
1632 fputs (" CONTAINS (", dumpfile
);
1633 fputs (gfc_ascii_statement (assume
->contains
[i
], true), dumpfile
);
1634 fputc (')', dumpfile
);
1636 for (gfc_expr_list
*el
= assume
->holds
; el
; el
= el
->next
)
1638 fputs (" HOLDS (", dumpfile
);
1639 show_expr (el
->expr
);
1640 fputc (')', dumpfile
);
1642 if (assume
->no_openmp
)
1643 fputs (" NO_OPENMP", dumpfile
);
1644 if (assume
->no_openmp_routines
)
1645 fputs (" NO_OPENMP_ROUTINES", dumpfile
);
1646 if (assume
->no_parallelism
)
1647 fputs (" NO_PARALLELISM", dumpfile
);
1650 /* Show OpenMP or OpenACC clauses. */
1653 show_omp_clauses (gfc_omp_clauses
*omp_clauses
)
1657 switch (omp_clauses
->cancel
)
1659 case OMP_CANCEL_UNKNOWN
:
1661 case OMP_CANCEL_PARALLEL
:
1662 fputs (" PARALLEL", dumpfile
);
1664 case OMP_CANCEL_SECTIONS
:
1665 fputs (" SECTIONS", dumpfile
);
1668 fputs (" DO", dumpfile
);
1670 case OMP_CANCEL_TASKGROUP
:
1671 fputs (" TASKGROUP", dumpfile
);
1674 if (omp_clauses
->if_expr
)
1676 fputs (" IF(", dumpfile
);
1677 show_expr (omp_clauses
->if_expr
);
1678 fputc (')', dumpfile
);
1680 for (i
= 0; i
< OMP_IF_LAST
; i
++)
1681 if (omp_clauses
->if_exprs
[i
])
1683 static const char *ifs
[] = {
1692 "TARGET ENTER DATA",
1695 fputs (" IF(", dumpfile
);
1696 fputs (ifs
[i
], dumpfile
);
1697 fputs (": ", dumpfile
);
1698 show_expr (omp_clauses
->if_exprs
[i
]);
1699 fputc (')', dumpfile
);
1701 if (omp_clauses
->self_expr
)
1703 fputs (" SELF(", dumpfile
);
1704 show_expr (omp_clauses
->self_expr
);
1705 fputc (')', dumpfile
);
1707 if (omp_clauses
->final_expr
)
1709 fputs (" FINAL(", dumpfile
);
1710 show_expr (omp_clauses
->final_expr
);
1711 fputc (')', dumpfile
);
1713 if (omp_clauses
->num_threads
)
1715 fputs (" NUM_THREADS(", dumpfile
);
1716 show_expr (omp_clauses
->num_threads
);
1717 fputc (')', dumpfile
);
1719 if (omp_clauses
->async
)
1721 fputs (" ASYNC", dumpfile
);
1722 if (omp_clauses
->async_expr
)
1724 fputc ('(', dumpfile
);
1725 show_expr (omp_clauses
->async_expr
);
1726 fputc (')', dumpfile
);
1729 if (omp_clauses
->num_gangs_expr
)
1731 fputs (" NUM_GANGS(", dumpfile
);
1732 show_expr (omp_clauses
->num_gangs_expr
);
1733 fputc (')', dumpfile
);
1735 if (omp_clauses
->num_workers_expr
)
1737 fputs (" NUM_WORKERS(", dumpfile
);
1738 show_expr (omp_clauses
->num_workers_expr
);
1739 fputc (')', dumpfile
);
1741 if (omp_clauses
->vector_length_expr
)
1743 fputs (" VECTOR_LENGTH(", dumpfile
);
1744 show_expr (omp_clauses
->vector_length_expr
);
1745 fputc (')', dumpfile
);
1747 if (omp_clauses
->gang
)
1749 fputs (" GANG", dumpfile
);
1750 if (omp_clauses
->gang_num_expr
|| omp_clauses
->gang_static_expr
)
1752 fputc ('(', dumpfile
);
1753 if (omp_clauses
->gang_num_expr
)
1755 fprintf (dumpfile
, "num:");
1756 show_expr (omp_clauses
->gang_num_expr
);
1758 if (omp_clauses
->gang_num_expr
&& omp_clauses
->gang_static
)
1759 fputc (',', dumpfile
);
1760 if (omp_clauses
->gang_static
)
1762 fprintf (dumpfile
, "static:");
1763 if (omp_clauses
->gang_static_expr
)
1764 show_expr (omp_clauses
->gang_static_expr
);
1766 fputc ('*', dumpfile
);
1768 fputc (')', dumpfile
);
1771 if (omp_clauses
->worker
)
1773 fputs (" WORKER", dumpfile
);
1774 if (omp_clauses
->worker_expr
)
1776 fputc ('(', dumpfile
);
1777 show_expr (omp_clauses
->worker_expr
);
1778 fputc (')', dumpfile
);
1781 if (omp_clauses
->vector
)
1783 fputs (" VECTOR", dumpfile
);
1784 if (omp_clauses
->vector_expr
)
1786 fputc ('(', dumpfile
);
1787 show_expr (omp_clauses
->vector_expr
);
1788 fputc (')', dumpfile
);
1791 if (omp_clauses
->sched_kind
!= OMP_SCHED_NONE
)
1794 switch (omp_clauses
->sched_kind
)
1796 case OMP_SCHED_STATIC
: type
= "STATIC"; break;
1797 case OMP_SCHED_DYNAMIC
: type
= "DYNAMIC"; break;
1798 case OMP_SCHED_GUIDED
: type
= "GUIDED"; break;
1799 case OMP_SCHED_RUNTIME
: type
= "RUNTIME"; break;
1800 case OMP_SCHED_AUTO
: type
= "AUTO"; break;
1804 fputs (" SCHEDULE (", dumpfile
);
1805 if (omp_clauses
->sched_simd
)
1807 if (omp_clauses
->sched_monotonic
1808 || omp_clauses
->sched_nonmonotonic
)
1809 fputs ("SIMD, ", dumpfile
);
1811 fputs ("SIMD: ", dumpfile
);
1813 if (omp_clauses
->sched_monotonic
)
1814 fputs ("MONOTONIC: ", dumpfile
);
1815 else if (omp_clauses
->sched_nonmonotonic
)
1816 fputs ("NONMONOTONIC: ", dumpfile
);
1817 fputs (type
, dumpfile
);
1818 if (omp_clauses
->chunk_size
)
1820 fputc (',', dumpfile
);
1821 show_expr (omp_clauses
->chunk_size
);
1823 fputc (')', dumpfile
);
1825 if (omp_clauses
->default_sharing
!= OMP_DEFAULT_UNKNOWN
)
1828 switch (omp_clauses
->default_sharing
)
1830 case OMP_DEFAULT_NONE
: type
= "NONE"; break;
1831 case OMP_DEFAULT_PRIVATE
: type
= "PRIVATE"; break;
1832 case OMP_DEFAULT_SHARED
: type
= "SHARED"; break;
1833 case OMP_DEFAULT_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1834 case OMP_DEFAULT_PRESENT
: type
= "PRESENT"; break;
1838 fprintf (dumpfile
, " DEFAULT(%s)", type
);
1840 if (omp_clauses
->tile_list
)
1842 gfc_expr_list
*list
;
1843 fputs (" TILE(", dumpfile
);
1844 for (list
= omp_clauses
->tile_list
; list
; list
= list
->next
)
1846 show_expr (list
->expr
);
1848 fputs (", ", dumpfile
);
1850 fputc (')', dumpfile
);
1852 if (omp_clauses
->wait_list
)
1854 gfc_expr_list
*list
;
1855 fputs (" WAIT(", dumpfile
);
1856 for (list
= omp_clauses
->wait_list
; list
; list
= list
->next
)
1858 show_expr (list
->expr
);
1860 fputs (", ", dumpfile
);
1862 fputc (')', dumpfile
);
1864 if (omp_clauses
->seq
)
1865 fputs (" SEQ", dumpfile
);
1866 if (omp_clauses
->independent
)
1867 fputs (" INDEPENDENT", dumpfile
);
1868 if (omp_clauses
->order_concurrent
)
1870 fputs (" ORDER(", dumpfile
);
1871 if (omp_clauses
->order_unconstrained
)
1872 fputs ("UNCONSTRAINED:", dumpfile
);
1873 else if (omp_clauses
->order_reproducible
)
1874 fputs ("REPRODUCIBLE:", dumpfile
);
1875 fputs ("CONCURRENT)", dumpfile
);
1877 if (omp_clauses
->ordered
)
1879 if (omp_clauses
->orderedc
)
1880 fprintf (dumpfile
, " ORDERED(%d)", omp_clauses
->orderedc
);
1882 fputs (" ORDERED", dumpfile
);
1884 if (omp_clauses
->untied
)
1885 fputs (" UNTIED", dumpfile
);
1886 if (omp_clauses
->mergeable
)
1887 fputs (" MERGEABLE", dumpfile
);
1888 if (omp_clauses
->nowait
)
1889 fputs (" NOWAIT", dumpfile
);
1890 if (omp_clauses
->collapse
)
1891 fprintf (dumpfile
, " COLLAPSE(%d)", omp_clauses
->collapse
);
1892 for (list_type
= 0; list_type
< OMP_LIST_NUM
; list_type
++)
1893 if (omp_clauses
->lists
[list_type
] != NULL
)
1895 const char *type
= NULL
;
1898 case OMP_LIST_PRIVATE
: type
= "PRIVATE"; break;
1899 case OMP_LIST_FIRSTPRIVATE
: type
= "FIRSTPRIVATE"; break;
1900 case OMP_LIST_LASTPRIVATE
: type
= "LASTPRIVATE"; break;
1901 case OMP_LIST_COPYPRIVATE
: type
= "COPYPRIVATE"; break;
1902 case OMP_LIST_SHARED
: type
= "SHARED"; break;
1903 case OMP_LIST_COPYIN
: type
= "COPYIN"; break;
1904 case OMP_LIST_UNIFORM
: type
= "UNIFORM"; break;
1905 case OMP_LIST_AFFINITY
: type
= "AFFINITY"; break;
1906 case OMP_LIST_ALIGNED
: type
= "ALIGNED"; break;
1907 case OMP_LIST_LINEAR
: type
= "LINEAR"; break;
1908 case OMP_LIST_DEPEND
:
1909 if (omp_clauses
->lists
[list_type
]
1910 && (omp_clauses
->lists
[list_type
]->u
.depend_doacross_op
1911 == OMP_DOACROSS_SINK_FIRST
))
1916 case OMP_LIST_MAP
: type
= "MAP"; break;
1917 case OMP_LIST_TO
: type
= "TO"; break;
1918 case OMP_LIST_FROM
: type
= "FROM"; break;
1919 case OMP_LIST_REDUCTION
:
1920 case OMP_LIST_REDUCTION_INSCAN
:
1921 case OMP_LIST_REDUCTION_TASK
: type
= "REDUCTION"; break;
1922 case OMP_LIST_IN_REDUCTION
: type
= "IN_REDUCTION"; break;
1923 case OMP_LIST_TASK_REDUCTION
: type
= "TASK_REDUCTION"; break;
1924 case OMP_LIST_DEVICE_RESIDENT
: type
= "DEVICE_RESIDENT"; break;
1925 case OMP_LIST_ENTER
: type
= "ENTER"; break;
1926 case OMP_LIST_LINK
: type
= "LINK"; break;
1927 case OMP_LIST_USE_DEVICE
: type
= "USE_DEVICE"; break;
1928 case OMP_LIST_CACHE
: type
= "CACHE"; break;
1929 case OMP_LIST_IS_DEVICE_PTR
: type
= "IS_DEVICE_PTR"; break;
1930 case OMP_LIST_USE_DEVICE_PTR
: type
= "USE_DEVICE_PTR"; break;
1931 case OMP_LIST_HAS_DEVICE_ADDR
: type
= "HAS_DEVICE_ADDR"; break;
1932 case OMP_LIST_USE_DEVICE_ADDR
: type
= "USE_DEVICE_ADDR"; break;
1933 case OMP_LIST_NONTEMPORAL
: type
= "NONTEMPORAL"; break;
1934 case OMP_LIST_ALLOCATE
: type
= "ALLOCATE"; break;
1935 case OMP_LIST_SCAN_IN
: type
= "INCLUSIVE"; break;
1936 case OMP_LIST_SCAN_EX
: type
= "EXCLUSIVE"; break;
1937 case OMP_LIST_USES_ALLOCATORS
: type
= "USES_ALLOCATORS"; break;
1938 case OMP_LIST_INIT
: type
= "INIT"; break;
1939 case OMP_LIST_USE
: type
= "USE"; break;
1940 case OMP_LIST_DESTROY
: type
= "DESTROY"; break;
1944 fprintf (dumpfile
, " %s(", type
);
1945 if (list_type
== OMP_LIST_REDUCTION_INSCAN
)
1946 fputs ("inscan, ", dumpfile
);
1947 if (list_type
== OMP_LIST_REDUCTION_TASK
)
1948 fputs ("task, ", dumpfile
);
1949 if ((list_type
== OMP_LIST_TO
|| list_type
== OMP_LIST_FROM
)
1950 && omp_clauses
->lists
[list_type
]->u
.present_modifier
)
1951 fputs ("present:", dumpfile
);
1952 show_omp_namelist (list_type
, omp_clauses
->lists
[list_type
]);
1953 fputc (')', dumpfile
);
1955 if (omp_clauses
->safelen_expr
)
1957 fputs (" SAFELEN(", dumpfile
);
1958 show_expr (omp_clauses
->safelen_expr
);
1959 fputc (')', dumpfile
);
1961 if (omp_clauses
->simdlen_expr
)
1963 fputs (" SIMDLEN(", dumpfile
);
1964 show_expr (omp_clauses
->simdlen_expr
);
1965 fputc (')', dumpfile
);
1967 if (omp_clauses
->inbranch
)
1968 fputs (" INBRANCH", dumpfile
);
1969 if (omp_clauses
->notinbranch
)
1970 fputs (" NOTINBRANCH", dumpfile
);
1971 if (omp_clauses
->proc_bind
!= OMP_PROC_BIND_UNKNOWN
)
1974 switch (omp_clauses
->proc_bind
)
1976 case OMP_PROC_BIND_PRIMARY
: type
= "PRIMARY"; break;
1977 case OMP_PROC_BIND_MASTER
: type
= "MASTER"; break;
1978 case OMP_PROC_BIND_SPREAD
: type
= "SPREAD"; break;
1979 case OMP_PROC_BIND_CLOSE
: type
= "CLOSE"; break;
1983 fprintf (dumpfile
, " PROC_BIND(%s)", type
);
1985 if (omp_clauses
->bind
!= OMP_BIND_UNSET
)
1988 switch (omp_clauses
->bind
)
1990 case OMP_BIND_TEAMS
: type
= "TEAMS"; break;
1991 case OMP_BIND_PARALLEL
: type
= "PARALLEL"; break;
1992 case OMP_BIND_THREAD
: type
= "THREAD"; break;
1996 fprintf (dumpfile
, " BIND(%s)", type
);
1998 if (omp_clauses
->num_teams_upper
)
2000 fputs (" NUM_TEAMS(", dumpfile
);
2001 if (omp_clauses
->num_teams_lower
)
2003 show_expr (omp_clauses
->num_teams_lower
);
2004 fputc (':', dumpfile
);
2006 show_expr (omp_clauses
->num_teams_upper
);
2007 fputc (')', dumpfile
);
2009 if (omp_clauses
->device
)
2011 fputs (" DEVICE(", dumpfile
);
2012 if (omp_clauses
->ancestor
)
2013 fputs ("ANCESTOR:", dumpfile
);
2014 show_expr (omp_clauses
->device
);
2015 fputc (')', dumpfile
);
2017 if (omp_clauses
->thread_limit
)
2019 fputs (" THREAD_LIMIT(", dumpfile
);
2020 show_expr (omp_clauses
->thread_limit
);
2021 fputc (')', dumpfile
);
2023 if (omp_clauses
->dist_sched_kind
!= OMP_SCHED_NONE
)
2025 fputs (" DIST_SCHEDULE (STATIC", dumpfile
);
2026 if (omp_clauses
->dist_chunk_size
)
2028 fputc (',', dumpfile
);
2029 show_expr (omp_clauses
->dist_chunk_size
);
2031 fputc (')', dumpfile
);
2033 for (int i
= 0; i
< OMP_DEFAULTMAP_CAT_NUM
; i
++)
2035 const char *dfltmap
;
2036 if (omp_clauses
->defaultmap
[i
] == OMP_DEFAULTMAP_UNSET
)
2038 fputs (" DEFAULTMAP (", dumpfile
);
2039 switch (omp_clauses
->defaultmap
[i
])
2041 case OMP_DEFAULTMAP_ALLOC
: dfltmap
= "ALLOC"; break;
2042 case OMP_DEFAULTMAP_TO
: dfltmap
= "TO"; break;
2043 case OMP_DEFAULTMAP_FROM
: dfltmap
= "FROM"; break;
2044 case OMP_DEFAULTMAP_TOFROM
: dfltmap
= "TOFROM"; break;
2045 case OMP_DEFAULTMAP_FIRSTPRIVATE
: dfltmap
= "FIRSTPRIVATE"; break;
2046 case OMP_DEFAULTMAP_NONE
: dfltmap
= "NONE"; break;
2047 case OMP_DEFAULTMAP_DEFAULT
: dfltmap
= "DEFAULT"; break;
2048 case OMP_DEFAULTMAP_PRESENT
: dfltmap
= "PRESENT"; break;
2049 default: gcc_unreachable ();
2051 fputs (dfltmap
, dumpfile
);
2052 if (i
!= OMP_DEFAULTMAP_CAT_UNCATEGORIZED
)
2054 fputc (':', dumpfile
);
2055 switch ((enum gfc_omp_defaultmap_category
) i
)
2057 case OMP_DEFAULTMAP_CAT_SCALAR
: dfltmap
= "SCALAR"; break;
2058 case OMP_DEFAULTMAP_CAT_AGGREGATE
: dfltmap
= "AGGREGATE"; break;
2059 case OMP_DEFAULTMAP_CAT_ALLOCATABLE
: dfltmap
= "ALLOCATABLE"; break;
2060 case OMP_DEFAULTMAP_CAT_POINTER
: dfltmap
= "POINTER"; break;
2061 default: gcc_unreachable ();
2063 fputs (dfltmap
, dumpfile
);
2065 fputc (')', dumpfile
);
2067 if (omp_clauses
->weak
)
2068 fputs (" WEAK", dumpfile
);
2069 if (omp_clauses
->compare
)
2070 fputs (" COMPARE", dumpfile
);
2071 if (omp_clauses
->nogroup
)
2072 fputs (" NOGROUP", dumpfile
);
2073 if (omp_clauses
->simd
)
2074 fputs (" SIMD", dumpfile
);
2075 if (omp_clauses
->threads
)
2076 fputs (" THREADS", dumpfile
);
2077 if (omp_clauses
->grainsize
)
2079 fputs (" GRAINSIZE(", dumpfile
);
2080 if (omp_clauses
->grainsize_strict
)
2081 fputs ("strict: ", dumpfile
);
2082 show_expr (omp_clauses
->grainsize
);
2083 fputc (')', dumpfile
);
2085 if (omp_clauses
->filter
)
2087 fputs (" FILTER(", dumpfile
);
2088 show_expr (omp_clauses
->filter
);
2089 fputc (')', dumpfile
);
2091 if (omp_clauses
->hint
)
2093 fputs (" HINT(", dumpfile
);
2094 show_expr (omp_clauses
->hint
);
2095 fputc (')', dumpfile
);
2097 if (omp_clauses
->num_tasks
)
2099 fputs (" NUM_TASKS(", dumpfile
);
2100 if (omp_clauses
->num_tasks_strict
)
2101 fputs ("strict: ", dumpfile
);
2102 show_expr (omp_clauses
->num_tasks
);
2103 fputc (')', dumpfile
);
2105 if (omp_clauses
->priority
)
2107 fputs (" PRIORITY(", dumpfile
);
2108 show_expr (omp_clauses
->priority
);
2109 fputc (')', dumpfile
);
2111 if (omp_clauses
->detach
)
2113 fputs (" DETACH(", dumpfile
);
2114 show_expr (omp_clauses
->detach
);
2115 fputc (')', dumpfile
);
2117 if (omp_clauses
->destroy
)
2118 fputs (" DESTROY", dumpfile
);
2119 if (omp_clauses
->depend_source
)
2120 fputs (" DEPEND(source)", dumpfile
);
2121 if (omp_clauses
->doacross_source
)
2122 fputs (" DOACROSS(source:)", dumpfile
);
2123 if (omp_clauses
->capture
)
2124 fputs (" CAPTURE", dumpfile
);
2125 if (omp_clauses
->depobj_update
!= OMP_DEPEND_UNSET
)
2127 const char *deptype
;
2128 fputs (" UPDATE(", dumpfile
);
2129 switch (omp_clauses
->depobj_update
)
2131 case OMP_DEPEND_IN
: deptype
= "IN"; break;
2132 case OMP_DEPEND_OUT
: deptype
= "OUT"; break;
2133 case OMP_DEPEND_INOUT
: deptype
= "INOUT"; break;
2134 case OMP_DEPEND_INOUTSET
: deptype
= "INOUTSET"; break;
2135 case OMP_DEPEND_MUTEXINOUTSET
: deptype
= "MUTEXINOUTSET"; break;
2136 default: gcc_unreachable ();
2138 fputs (deptype
, dumpfile
);
2139 fputc (')', dumpfile
);
2141 if (omp_clauses
->atomic_op
!= GFC_OMP_ATOMIC_UNSET
)
2143 const char *atomic_op
;
2144 switch (omp_clauses
->atomic_op
& GFC_OMP_ATOMIC_MASK
)
2146 case GFC_OMP_ATOMIC_READ
: atomic_op
= "READ"; break;
2147 case GFC_OMP_ATOMIC_WRITE
: atomic_op
= "WRITE"; break;
2148 case GFC_OMP_ATOMIC_UPDATE
: atomic_op
= "UPDATE"; break;
2149 default: gcc_unreachable ();
2151 fputc (' ', dumpfile
);
2152 fputs (atomic_op
, dumpfile
);
2154 if (omp_clauses
->memorder
!= OMP_MEMORDER_UNSET
)
2156 const char *memorder
;
2157 switch (omp_clauses
->memorder
)
2159 case OMP_MEMORDER_ACQ_REL
: memorder
= "ACQ_REL"; break;
2160 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2161 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2162 case OMP_MEMORDER_RELEASE
: memorder
= "RELEASE"; break;
2163 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2164 default: gcc_unreachable ();
2166 fputc (' ', dumpfile
);
2167 fputs (memorder
, dumpfile
);
2169 if (omp_clauses
->fail
!= OMP_MEMORDER_UNSET
)
2171 const char *memorder
;
2172 switch (omp_clauses
->fail
)
2174 case OMP_MEMORDER_ACQUIRE
: memorder
= "AQUIRE"; break;
2175 case OMP_MEMORDER_RELAXED
: memorder
= "RELAXED"; break;
2176 case OMP_MEMORDER_SEQ_CST
: memorder
= "SEQ_CST"; break;
2177 default: gcc_unreachable ();
2179 fputs (" FAIL(", dumpfile
);
2180 fputs (memorder
, dumpfile
);
2181 putc (')', dumpfile
);
2183 if (omp_clauses
->at
!= OMP_AT_UNSET
)
2185 if (omp_clauses
->at
!= OMP_AT_COMPILATION
)
2186 fputs (" AT (COMPILATION)", dumpfile
);
2188 fputs (" AT (EXECUTION)", dumpfile
);
2190 if (omp_clauses
->severity
!= OMP_SEVERITY_UNSET
)
2192 if (omp_clauses
->severity
!= OMP_SEVERITY_FATAL
)
2193 fputs (" SEVERITY (FATAL)", dumpfile
);
2195 fputs (" SEVERITY (WARNING)", dumpfile
);
2197 if (omp_clauses
->message
)
2199 fputs (" ERROR (", dumpfile
);
2200 show_expr (omp_clauses
->message
);
2201 fputc (')', dumpfile
);
2203 if (omp_clauses
->assume
)
2204 show_omp_assumes (omp_clauses
->assume
);
2205 if (omp_clauses
->full
)
2206 fputs (" FULL", dumpfile
);
2207 if (omp_clauses
->partial
)
2209 fputs (" PARTIAL", dumpfile
);
2210 if (omp_clauses
->partial
> 0)
2211 fprintf (dumpfile
, "(%d)", omp_clauses
->partial
);
2213 if (omp_clauses
->sizes_list
)
2215 gfc_expr_list
*sizes
;
2216 fputs (" SIZES(", dumpfile
);
2217 for (sizes
= omp_clauses
->sizes_list
; sizes
; sizes
= sizes
->next
)
2219 show_expr (sizes
->expr
);
2221 fputs (", ", dumpfile
);
2223 fputc (')', dumpfile
);
2227 /* Show a single OpenMP or OpenACC directive node and everything underneath it
2231 show_omp_node (int level
, gfc_code
*c
)
2233 gfc_omp_clauses
*omp_clauses
= NULL
;
2234 const char *name
= NULL
;
2235 bool is_oacc
= false;
2239 case EXEC_OACC_PARALLEL_LOOP
:
2240 name
= "PARALLEL LOOP"; is_oacc
= true; break;
2241 case EXEC_OACC_PARALLEL
: name
= "PARALLEL"; is_oacc
= true; break;
2242 case EXEC_OACC_KERNELS_LOOP
: name
= "KERNELS LOOP"; is_oacc
= true; break;
2243 case EXEC_OACC_KERNELS
: name
= "KERNELS"; is_oacc
= true; break;
2244 case EXEC_OACC_SERIAL_LOOP
: name
= "SERIAL LOOP"; is_oacc
= true; break;
2245 case EXEC_OACC_SERIAL
: name
= "SERIAL"; is_oacc
= true; break;
2246 case EXEC_OACC_DATA
: name
= "DATA"; is_oacc
= true; break;
2247 case EXEC_OACC_HOST_DATA
: name
= "HOST_DATA"; is_oacc
= true; break;
2248 case EXEC_OACC_LOOP
: name
= "LOOP"; is_oacc
= true; break;
2249 case EXEC_OACC_UPDATE
: name
= "UPDATE"; is_oacc
= true; break;
2250 case EXEC_OACC_WAIT
: name
= "WAIT"; is_oacc
= true; break;
2251 case EXEC_OACC_CACHE
: name
= "CACHE"; is_oacc
= true; break;
2252 case EXEC_OACC_ENTER_DATA
: name
= "ENTER DATA"; is_oacc
= true; break;
2253 case EXEC_OACC_EXIT_DATA
: name
= "EXIT DATA"; is_oacc
= true; break;
2254 case EXEC_OMP_ALLOCATE
: name
= "ALLOCATE"; break;
2255 case EXEC_OMP_ALLOCATORS
: name
= "ALLOCATORS"; break;
2256 case EXEC_OMP_ASSUME
: name
= "ASSUME"; break;
2257 case EXEC_OMP_ATOMIC
: name
= "ATOMIC"; break;
2258 case EXEC_OMP_BARRIER
: name
= "BARRIER"; break;
2259 case EXEC_OMP_CANCEL
: name
= "CANCEL"; break;
2260 case EXEC_OMP_CANCELLATION_POINT
: name
= "CANCELLATION POINT"; break;
2261 case EXEC_OMP_CRITICAL
: name
= "CRITICAL"; break;
2262 case EXEC_OMP_DISTRIBUTE
: name
= "DISTRIBUTE"; break;
2263 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2264 name
= "DISTRIBUTE PARALLEL DO"; break;
2265 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2266 name
= "DISTRIBUTE PARALLEL DO SIMD"; break;
2267 case EXEC_OMP_DISTRIBUTE_SIMD
: name
= "DISTRIBUTE SIMD"; break;
2268 case EXEC_OMP_DO
: name
= "DO"; break;
2269 case EXEC_OMP_DO_SIMD
: name
= "DO SIMD"; break;
2270 case EXEC_OMP_ERROR
: name
= "ERROR"; break;
2271 case EXEC_OMP_FLUSH
: name
= "FLUSH"; break;
2272 case EXEC_OMP_INTEROP
: name
= "INTEROP"; break;
2273 case EXEC_OMP_LOOP
: name
= "LOOP"; break;
2274 case EXEC_OMP_MASKED
: name
= "MASKED"; break;
2275 case EXEC_OMP_MASKED_TASKLOOP
: name
= "MASKED TASKLOOP"; break;
2276 case EXEC_OMP_MASKED_TASKLOOP_SIMD
: name
= "MASKED TASKLOOP SIMD"; break;
2277 case EXEC_OMP_MASTER
: name
= "MASTER"; break;
2278 case EXEC_OMP_MASTER_TASKLOOP
: name
= "MASTER TASKLOOP"; break;
2279 case EXEC_OMP_MASTER_TASKLOOP_SIMD
: name
= "MASTER TASKLOOP SIMD"; break;
2280 case EXEC_OMP_ORDERED
: name
= "ORDERED"; break;
2281 case EXEC_OMP_DEPOBJ
: name
= "DEPOBJ"; break;
2282 case EXEC_OMP_PARALLEL
: name
= "PARALLEL"; break;
2283 case EXEC_OMP_PARALLEL_DO
: name
= "PARALLEL DO"; break;
2284 case EXEC_OMP_PARALLEL_DO_SIMD
: name
= "PARALLEL DO SIMD"; break;
2285 case EXEC_OMP_PARALLEL_LOOP
: name
= "PARALLEL LOOP"; break;
2286 case EXEC_OMP_PARALLEL_MASTER
: name
= "PARALLEL MASTER"; break;
2287 case EXEC_OMP_PARALLEL_MASKED
: name
= "PARALLEL MASK"; break;
2288 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2289 name
= "PARALLEL MASK TASKLOOP"; break;
2290 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2291 name
= "PARALLEL MASK TASKLOOP SIMD"; break;
2292 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2293 name
= "PARALLEL MASTER TASKLOOP"; break;
2294 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2295 name
= "PARALLEL MASTER TASKLOOP SIMD"; break;
2296 case EXEC_OMP_PARALLEL_SECTIONS
: name
= "PARALLEL SECTIONS"; break;
2297 case EXEC_OMP_PARALLEL_WORKSHARE
: name
= "PARALLEL WORKSHARE"; break;
2298 case EXEC_OMP_SCAN
: name
= "SCAN"; break;
2299 case EXEC_OMP_SCOPE
: name
= "SCOPE"; break;
2300 case EXEC_OMP_SECTIONS
: name
= "SECTIONS"; break;
2301 case EXEC_OMP_SIMD
: name
= "SIMD"; break;
2302 case EXEC_OMP_SINGLE
: name
= "SINGLE"; break;
2303 case EXEC_OMP_TARGET
: name
= "TARGET"; break;
2304 case EXEC_OMP_TARGET_DATA
: name
= "TARGET DATA"; break;
2305 case EXEC_OMP_TARGET_ENTER_DATA
: name
= "TARGET ENTER DATA"; break;
2306 case EXEC_OMP_TARGET_EXIT_DATA
: name
= "TARGET EXIT DATA"; break;
2307 case EXEC_OMP_TARGET_PARALLEL
: name
= "TARGET PARALLEL"; break;
2308 case EXEC_OMP_TARGET_PARALLEL_DO
: name
= "TARGET PARALLEL DO"; break;
2309 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2310 name
= "TARGET_PARALLEL_DO_SIMD"; break;
2311 case EXEC_OMP_TARGET_PARALLEL_LOOP
: name
= "TARGET PARALLEL LOOP"; break;
2312 case EXEC_OMP_TARGET_SIMD
: name
= "TARGET SIMD"; break;
2313 case EXEC_OMP_TARGET_TEAMS
: name
= "TARGET TEAMS"; break;
2314 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2315 name
= "TARGET TEAMS DISTRIBUTE"; break;
2316 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2317 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
2318 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2319 name
= "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2320 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2321 name
= "TARGET TEAMS DISTRIBUTE SIMD"; break;
2322 case EXEC_OMP_TARGET_TEAMS_LOOP
: name
= "TARGET TEAMS LOOP"; break;
2323 case EXEC_OMP_TARGET_UPDATE
: name
= "TARGET UPDATE"; break;
2324 case EXEC_OMP_TASK
: name
= "TASK"; break;
2325 case EXEC_OMP_TASKGROUP
: name
= "TASKGROUP"; break;
2326 case EXEC_OMP_TASKLOOP
: name
= "TASKLOOP"; break;
2327 case EXEC_OMP_TASKLOOP_SIMD
: name
= "TASKLOOP SIMD"; break;
2328 case EXEC_OMP_TASKWAIT
: name
= "TASKWAIT"; break;
2329 case EXEC_OMP_TASKYIELD
: name
= "TASKYIELD"; break;
2330 case EXEC_OMP_TEAMS
: name
= "TEAMS"; break;
2331 case EXEC_OMP_TEAMS_DISTRIBUTE
: name
= "TEAMS DISTRIBUTE"; break;
2332 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2333 name
= "TEAMS DISTRIBUTE PARALLEL DO"; break;
2334 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2335 name
= "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2336 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
: name
= "TEAMS DISTRIBUTE SIMD"; break;
2337 case EXEC_OMP_TEAMS_LOOP
: name
= "TEAMS LOOP"; break;
2338 case EXEC_OMP_TILE
: name
= "TILE"; break;
2339 case EXEC_OMP_UNROLL
: name
= "UNROLL"; break;
2340 case EXEC_OMP_WORKSHARE
: name
= "WORKSHARE"; break;
2344 fprintf (dumpfile
, "!$%s %s", is_oacc
? "ACC" : "OMP", name
);
2347 case EXEC_OACC_PARALLEL_LOOP
:
2348 case EXEC_OACC_PARALLEL
:
2349 case EXEC_OACC_KERNELS_LOOP
:
2350 case EXEC_OACC_KERNELS
:
2351 case EXEC_OACC_SERIAL_LOOP
:
2352 case EXEC_OACC_SERIAL
:
2353 case EXEC_OACC_DATA
:
2354 case EXEC_OACC_HOST_DATA
:
2355 case EXEC_OACC_LOOP
:
2356 case EXEC_OACC_UPDATE
:
2357 case EXEC_OACC_WAIT
:
2358 case EXEC_OACC_CACHE
:
2359 case EXEC_OACC_ENTER_DATA
:
2360 case EXEC_OACC_EXIT_DATA
:
2361 case EXEC_OMP_ALLOCATE
:
2362 case EXEC_OMP_ALLOCATORS
:
2363 case EXEC_OMP_ASSUME
:
2364 case EXEC_OMP_CANCEL
:
2365 case EXEC_OMP_CANCELLATION_POINT
:
2366 case EXEC_OMP_DISTRIBUTE
:
2367 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
2368 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
2369 case EXEC_OMP_DISTRIBUTE_SIMD
:
2371 case EXEC_OMP_DO_SIMD
:
2372 case EXEC_OMP_ERROR
:
2373 case EXEC_OMP_INTEROP
:
2375 case EXEC_OMP_ORDERED
:
2376 case EXEC_OMP_MASKED
:
2377 case EXEC_OMP_PARALLEL
:
2378 case EXEC_OMP_PARALLEL_DO
:
2379 case EXEC_OMP_PARALLEL_DO_SIMD
:
2380 case EXEC_OMP_PARALLEL_LOOP
:
2381 case EXEC_OMP_PARALLEL_MASKED
:
2382 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
2383 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
2384 case EXEC_OMP_PARALLEL_MASTER
:
2385 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
2386 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
2387 case EXEC_OMP_PARALLEL_SECTIONS
:
2388 case EXEC_OMP_PARALLEL_WORKSHARE
:
2390 case EXEC_OMP_SCOPE
:
2391 case EXEC_OMP_SECTIONS
:
2393 case EXEC_OMP_SINGLE
:
2394 case EXEC_OMP_TARGET
:
2395 case EXEC_OMP_TARGET_DATA
:
2396 case EXEC_OMP_TARGET_ENTER_DATA
:
2397 case EXEC_OMP_TARGET_EXIT_DATA
:
2398 case EXEC_OMP_TARGET_PARALLEL
:
2399 case EXEC_OMP_TARGET_PARALLEL_DO
:
2400 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
2401 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
2402 case EXEC_OMP_TARGET_SIMD
:
2403 case EXEC_OMP_TARGET_TEAMS
:
2404 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
2405 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2406 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2407 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
2408 case EXEC_OMP_TARGET_TEAMS_LOOP
:
2409 case EXEC_OMP_TARGET_UPDATE
:
2411 case EXEC_OMP_TASKLOOP
:
2412 case EXEC_OMP_TASKLOOP_SIMD
:
2413 case EXEC_OMP_TEAMS
:
2414 case EXEC_OMP_TEAMS_DISTRIBUTE
:
2415 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
2416 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
2417 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
2418 case EXEC_OMP_TEAMS_LOOP
:
2420 case EXEC_OMP_UNROLL
:
2421 case EXEC_OMP_WORKSHARE
:
2422 omp_clauses
= c
->ext
.omp_clauses
;
2424 case EXEC_OMP_CRITICAL
:
2425 omp_clauses
= c
->ext
.omp_clauses
;
2427 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2429 case EXEC_OMP_DEPOBJ
:
2430 omp_clauses
= c
->ext
.omp_clauses
;
2433 fputc ('(', dumpfile
);
2434 show_expr (c
->ext
.omp_clauses
->depobj
);
2435 fputc (')', dumpfile
);
2438 case EXEC_OMP_FLUSH
:
2439 if (c
->ext
.omp_namelist
)
2441 fputs (" (", dumpfile
);
2442 show_omp_namelist (OMP_LIST_NUM
, c
->ext
.omp_namelist
);
2443 fputc (')', dumpfile
);
2446 case EXEC_OMP_BARRIER
:
2447 case EXEC_OMP_TASKWAIT
:
2448 case EXEC_OMP_TASKYIELD
:
2450 case EXEC_OACC_ATOMIC
:
2451 case EXEC_OMP_ATOMIC
:
2452 omp_clauses
= c
->block
? c
->block
->ext
.omp_clauses
: NULL
;
2458 show_omp_clauses (omp_clauses
);
2459 fputc ('\n', dumpfile
);
2461 /* OpenMP and OpenACC executable directives don't have associated blocks. */
2462 if (c
->op
== EXEC_OACC_CACHE
|| c
->op
== EXEC_OACC_UPDATE
2463 || c
->op
== EXEC_OACC_ENTER_DATA
|| c
->op
== EXEC_OACC_EXIT_DATA
2464 || c
->op
== EXEC_OMP_TARGET_UPDATE
|| c
->op
== EXEC_OMP_TARGET_ENTER_DATA
2465 || c
->op
== EXEC_OMP_TARGET_EXIT_DATA
|| c
->op
== EXEC_OMP_SCAN
2466 || c
->op
== EXEC_OMP_DEPOBJ
|| c
->op
== EXEC_OMP_ERROR
2467 || c
->op
== EXEC_OMP_INTEROP
2468 || (c
->op
== EXEC_OMP_ORDERED
&& c
->block
== NULL
))
2470 if (c
->op
== EXEC_OMP_SECTIONS
|| c
->op
== EXEC_OMP_PARALLEL_SECTIONS
)
2472 gfc_code
*d
= c
->block
;
2475 show_code (level
+ 1, d
->next
);
2476 if (d
->block
== NULL
)
2478 code_indent (level
, 0);
2479 fputs ("!$OMP SECTION\n", dumpfile
);
2484 show_code (level
+ 1, c
->block
->next
);
2485 if (c
->op
== EXEC_OMP_ATOMIC
)
2487 fputc ('\n', dumpfile
);
2488 code_indent (level
, 0);
2489 fprintf (dumpfile
, "!$%s END %s", is_oacc
? "ACC" : "OMP", name
);
2490 if (c
->op
== EXEC_OMP_CRITICAL
&& c
->ext
.omp_clauses
)
2491 fprintf (dumpfile
, " (%s)", c
->ext
.omp_clauses
->critical_name
);
2495 /* Show a single code node and everything underneath it if necessary. */
2498 show_code_node (int level
, gfc_code
*c
)
2500 gfc_forall_iterator
*fa
;
2513 fputc ('\n', dumpfile
);
2514 code_indent (level
, c
->here
);
2521 case EXEC_END_PROCEDURE
:
2525 fputs ("NOP", dumpfile
);
2529 fputs ("CONTINUE", dumpfile
);
2533 fprintf (dumpfile
, "ENTRY %s", c
->ext
.entry
->sym
->name
);
2536 case EXEC_INIT_ASSIGN
:
2538 fputs ("ASSIGN ", dumpfile
);
2539 show_expr (c
->expr1
);
2540 fputc (' ', dumpfile
);
2541 show_expr (c
->expr2
);
2544 case EXEC_LABEL_ASSIGN
:
2545 fputs ("LABEL ASSIGN ", dumpfile
);
2546 show_expr (c
->expr1
);
2547 fprintf (dumpfile
, " %d", c
->label1
->value
);
2550 case EXEC_POINTER_ASSIGN
:
2551 fputs ("POINTER ASSIGN ", dumpfile
);
2552 show_expr (c
->expr1
);
2553 fputc (' ', dumpfile
);
2554 show_expr (c
->expr2
);
2558 fputs ("GOTO ", dumpfile
);
2560 fprintf (dumpfile
, "%d", c
->label1
->value
);
2563 show_expr (c
->expr1
);
2567 fputs (", (", dumpfile
);
2568 for (; d
; d
= d
->block
)
2570 code_indent (level
, d
->label1
);
2571 if (d
->block
!= NULL
)
2572 fputc (',', dumpfile
);
2574 fputc (')', dumpfile
);
2581 case EXEC_ASSIGN_CALL
:
2582 if (c
->resolved_sym
)
2583 fprintf (dumpfile
, "CALL %s ", c
->resolved_sym
->name
);
2584 else if (c
->symtree
)
2585 fprintf (dumpfile
, "CALL %s ", c
->symtree
->name
);
2587 fputs ("CALL ?? ", dumpfile
);
2589 show_actual_arglist (c
->ext
.actual
);
2593 fputs ("CALL ", dumpfile
);
2594 show_compcall (c
->expr1
);
2598 fputs ("CALL ", dumpfile
);
2599 show_expr (c
->expr1
);
2600 show_actual_arglist (c
->ext
.actual
);
2604 fputs ("RETURN ", dumpfile
);
2606 show_expr (c
->expr1
);
2610 fputs ("PAUSE ", dumpfile
);
2612 if (c
->expr1
!= NULL
)
2613 show_expr (c
->expr1
);
2615 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2619 case EXEC_ERROR_STOP
:
2620 fputs ("ERROR ", dumpfile
);
2624 fputs ("STOP ", dumpfile
);
2626 if (c
->expr1
!= NULL
)
2627 show_expr (c
->expr1
);
2629 fprintf (dumpfile
, "%d", c
->ext
.stop_code
);
2630 if (c
->expr2
!= NULL
)
2632 fputs (" QUIET=", dumpfile
);
2633 show_expr (c
->expr2
);
2638 case EXEC_FAIL_IMAGE
:
2639 fputs ("FAIL IMAGE ", dumpfile
);
2642 case EXEC_CHANGE_TEAM
:
2643 fputs ("CHANGE TEAM", dumpfile
);
2647 fputs ("END TEAM", dumpfile
);
2650 case EXEC_FORM_TEAM
:
2651 fputs ("FORM TEAM", dumpfile
);
2654 case EXEC_SYNC_TEAM
:
2655 fputs ("SYNC TEAM", dumpfile
);
2659 fputs ("SYNC ALL ", dumpfile
);
2660 if (c
->expr2
!= NULL
)
2662 fputs (" stat=", dumpfile
);
2663 show_expr (c
->expr2
);
2665 if (c
->expr3
!= NULL
)
2667 fputs (" errmsg=", dumpfile
);
2668 show_expr (c
->expr3
);
2672 case EXEC_SYNC_MEMORY
:
2673 fputs ("SYNC MEMORY ", dumpfile
);
2674 if (c
->expr2
!= NULL
)
2676 fputs (" stat=", dumpfile
);
2677 show_expr (c
->expr2
);
2679 if (c
->expr3
!= NULL
)
2681 fputs (" errmsg=", dumpfile
);
2682 show_expr (c
->expr3
);
2686 case EXEC_SYNC_IMAGES
:
2687 fputs ("SYNC IMAGES image-set=", dumpfile
);
2688 if (c
->expr1
!= NULL
)
2689 show_expr (c
->expr1
);
2691 fputs ("* ", dumpfile
);
2692 if (c
->expr2
!= NULL
)
2694 fputs (" stat=", dumpfile
);
2695 show_expr (c
->expr2
);
2697 if (c
->expr3
!= NULL
)
2699 fputs (" errmsg=", dumpfile
);
2700 show_expr (c
->expr3
);
2704 case EXEC_EVENT_POST
:
2705 case EXEC_EVENT_WAIT
:
2706 if (c
->op
== EXEC_EVENT_POST
)
2707 fputs ("EVENT POST ", dumpfile
);
2709 fputs ("EVENT WAIT ", dumpfile
);
2711 fputs ("event-variable=", dumpfile
);
2712 if (c
->expr1
!= NULL
)
2713 show_expr (c
->expr1
);
2714 if (c
->expr4
!= NULL
)
2716 fputs (" until_count=", dumpfile
);
2717 show_expr (c
->expr4
);
2719 if (c
->expr2
!= NULL
)
2721 fputs (" stat=", dumpfile
);
2722 show_expr (c
->expr2
);
2724 if (c
->expr3
!= NULL
)
2726 fputs (" errmsg=", dumpfile
);
2727 show_expr (c
->expr3
);
2733 if (c
->op
== EXEC_LOCK
)
2734 fputs ("LOCK ", dumpfile
);
2736 fputs ("UNLOCK ", dumpfile
);
2738 fputs ("lock-variable=", dumpfile
);
2739 if (c
->expr1
!= NULL
)
2740 show_expr (c
->expr1
);
2741 if (c
->expr4
!= NULL
)
2743 fputs (" acquired_lock=", dumpfile
);
2744 show_expr (c
->expr4
);
2746 if (c
->expr2
!= NULL
)
2748 fputs (" stat=", dumpfile
);
2749 show_expr (c
->expr2
);
2751 if (c
->expr3
!= NULL
)
2753 fputs (" errmsg=", dumpfile
);
2754 show_expr (c
->expr3
);
2758 case EXEC_ARITHMETIC_IF
:
2759 fputs ("IF ", dumpfile
);
2760 show_expr (c
->expr1
);
2761 fprintf (dumpfile
, " %d, %d, %d",
2762 c
->label1
->value
, c
->label2
->value
, c
->label3
->value
);
2767 fputs ("IF ", dumpfile
);
2768 show_expr (d
->expr1
);
2771 show_code (level
+ 1, d
->next
);
2775 for (; d
; d
= d
->block
)
2777 fputs("\n", dumpfile
);
2778 code_indent (level
, 0);
2779 if (d
->expr1
== NULL
)
2780 fputs ("ELSE", dumpfile
);
2783 fputs ("ELSE IF ", dumpfile
);
2784 show_expr (d
->expr1
);
2788 show_code (level
+ 1, d
->next
);
2793 code_indent (level
, c
->label1
);
2797 fputs ("ENDIF", dumpfile
);
2802 const char *blocktype
, *sname
= NULL
;
2803 gfc_namespace
*saved_ns
;
2804 gfc_association_list
*alist
;
2806 if (c
->ext
.block
.ns
&& c
->ext
.block
.ns
->code
2807 && c
->ext
.block
.ns
->code
->op
== EXEC_SELECT_TYPE
)
2809 gfc_expr
*fcn
= c
->ext
.block
.ns
->code
->expr1
;
2810 blocktype
= "SELECT TYPE";
2811 /* expr1 is _loc(assoc_name->vptr) */
2812 if (fcn
&& fcn
->expr_type
== EXPR_FUNCTION
)
2813 sname
= fcn
->value
.function
.actual
->expr
->symtree
->n
.sym
->name
;
2815 else if (c
->ext
.block
.assoc
)
2816 blocktype
= "ASSOCIATE";
2818 blocktype
= "BLOCK";
2820 fprintf (dumpfile
, "%s ", blocktype
);
2821 for (alist
= c
->ext
.block
.assoc
; alist
; alist
= alist
->next
)
2823 fprintf (dumpfile
, " %s = ", sname
? sname
: alist
->name
);
2824 show_expr (alist
->target
);
2828 ns
= c
->ext
.block
.ns
;
2829 saved_ns
= gfc_current_ns
;
2830 gfc_current_ns
= ns
;
2831 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
2832 gfc_current_ns
= saved_ns
;
2833 show_code (show_level
, ns
->code
);
2836 fprintf (dumpfile
, "END %s ", blocktype
);
2840 case EXEC_END_BLOCK
:
2841 /* Only come here when there is a label on an
2842 END ASSOCIATE construct. */
2846 case EXEC_SELECT_TYPE
:
2847 case EXEC_SELECT_RANK
:
2849 fputc ('\n', dumpfile
);
2850 code_indent (level
, 0);
2851 if (c
->op
== EXEC_SELECT_RANK
)
2852 fputs ("SELECT RANK ", dumpfile
);
2853 else if (c
->op
== EXEC_SELECT_TYPE
)
2854 fputs ("SELECT CASE ", dumpfile
); // Preceded by SELECT TYPE construct
2856 fputs ("SELECT CASE ", dumpfile
);
2857 show_expr (c
->expr1
);
2859 for (; d
; d
= d
->block
)
2861 fputc ('\n', dumpfile
);
2862 code_indent (level
, 0);
2863 fputs ("CASE ", dumpfile
);
2864 for (cp
= d
->ext
.block
.case_list
; cp
; cp
= cp
->next
)
2866 fputc ('(', dumpfile
);
2867 show_expr (cp
->low
);
2868 fputc (' ', dumpfile
);
2869 show_expr (cp
->high
);
2870 fputc (')', dumpfile
);
2871 fputc (' ', dumpfile
);
2874 show_code (level
+ 1, d
->next
);
2875 fputc ('\n', dumpfile
);
2878 code_indent (level
, c
->label1
);
2879 fputs ("END SELECT", dumpfile
);
2883 fputs ("WHERE ", dumpfile
);
2886 show_expr (d
->expr1
);
2887 fputc ('\n', dumpfile
);
2889 show_code (level
+ 1, d
->next
);
2891 for (d
= d
->block
; d
; d
= d
->block
)
2893 code_indent (level
, 0);
2894 fputs ("ELSE WHERE ", dumpfile
);
2895 show_expr (d
->expr1
);
2896 fputc ('\n', dumpfile
);
2897 show_code (level
+ 1, d
->next
);
2900 code_indent (level
, 0);
2901 fputs ("END WHERE", dumpfile
);
2906 fputs ("FORALL ", dumpfile
);
2907 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2909 show_expr (fa
->var
);
2910 fputc (' ', dumpfile
);
2911 show_expr (fa
->start
);
2912 fputc (':', dumpfile
);
2913 show_expr (fa
->end
);
2914 fputc (':', dumpfile
);
2915 show_expr (fa
->stride
);
2917 if (fa
->next
!= NULL
)
2918 fputc (',', dumpfile
);
2921 if (c
->expr1
!= NULL
)
2923 fputc (',', dumpfile
);
2924 show_expr (c
->expr1
);
2926 fputc ('\n', dumpfile
);
2928 show_code (level
+ 1, c
->block
->next
);
2930 code_indent (level
, 0);
2931 fputs ("END FORALL", dumpfile
);
2935 fputs ("CRITICAL\n", dumpfile
);
2936 show_code (level
+ 1, c
->block
->next
);
2937 code_indent (level
, 0);
2938 fputs ("END CRITICAL", dumpfile
);
2942 fputs ("DO ", dumpfile
);
2944 fprintf (dumpfile
, " %-5d ", c
->label1
->value
);
2946 show_expr (c
->ext
.iterator
->var
);
2947 fputc ('=', dumpfile
);
2948 show_expr (c
->ext
.iterator
->start
);
2949 fputc (' ', dumpfile
);
2950 show_expr (c
->ext
.iterator
->end
);
2951 fputc (' ', dumpfile
);
2952 show_expr (c
->ext
.iterator
->step
);
2955 show_code (level
+ 1, c
->block
->next
);
2962 fputs ("END DO", dumpfile
);
2965 case EXEC_DO_CONCURRENT
:
2966 fputs ("DO CONCURRENT ", dumpfile
);
2967 for (fa
= c
->ext
.forall_iterator
; fa
; fa
= fa
->next
)
2969 show_expr (fa
->var
);
2970 fputc (' ', dumpfile
);
2971 show_expr (fa
->start
);
2972 fputc (':', dumpfile
);
2973 show_expr (fa
->end
);
2974 fputc (':', dumpfile
);
2975 show_expr (fa
->stride
);
2977 if (fa
->next
!= NULL
)
2978 fputc (',', dumpfile
);
2980 show_expr (c
->expr1
);
2983 show_code (level
+ 1, c
->block
->next
);
2985 code_indent (level
, c
->label1
);
2987 fputs ("END DO", dumpfile
);
2991 fputs ("DO WHILE ", dumpfile
);
2992 show_expr (c
->expr1
);
2993 fputc ('\n', dumpfile
);
2995 show_code (level
+ 1, c
->block
->next
);
2997 code_indent (level
, c
->label1
);
2998 fputs ("END DO", dumpfile
);
3002 fputs ("CYCLE", dumpfile
);
3004 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
3008 fputs ("EXIT", dumpfile
);
3010 fprintf (dumpfile
, " %s", c
->symtree
->n
.sym
->name
);
3014 fputs ("ALLOCATE ", dumpfile
);
3017 fputs (" STAT=", dumpfile
);
3018 show_expr (c
->expr1
);
3023 fputs (" ERRMSG=", dumpfile
);
3024 show_expr (c
->expr2
);
3030 fputs (" MOLD=", dumpfile
);
3032 fputs (" SOURCE=", dumpfile
);
3033 show_expr (c
->expr3
);
3036 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
3038 fputc (' ', dumpfile
);
3039 show_expr (a
->expr
);
3044 case EXEC_DEALLOCATE
:
3045 fputs ("DEALLOCATE ", dumpfile
);
3048 fputs (" STAT=", dumpfile
);
3049 show_expr (c
->expr1
);
3054 fputs (" ERRMSG=", dumpfile
);
3055 show_expr (c
->expr2
);
3058 for (a
= c
->ext
.alloc
.list
; a
; a
= a
->next
)
3060 fputc (' ', dumpfile
);
3061 show_expr (a
->expr
);
3067 fputs ("OPEN", dumpfile
);
3072 fputs (" UNIT=", dumpfile
);
3073 show_expr (open
->unit
);
3077 fputs (" IOMSG=", dumpfile
);
3078 show_expr (open
->iomsg
);
3082 fputs (" IOSTAT=", dumpfile
);
3083 show_expr (open
->iostat
);
3087 fputs (" FILE=", dumpfile
);
3088 show_expr (open
->file
);
3092 fputs (" STATUS=", dumpfile
);
3093 show_expr (open
->status
);
3097 fputs (" ACCESS=", dumpfile
);
3098 show_expr (open
->access
);
3102 fputs (" FORM=", dumpfile
);
3103 show_expr (open
->form
);
3107 fputs (" RECL=", dumpfile
);
3108 show_expr (open
->recl
);
3112 fputs (" BLANK=", dumpfile
);
3113 show_expr (open
->blank
);
3117 fputs (" POSITION=", dumpfile
);
3118 show_expr (open
->position
);
3122 fputs (" ACTION=", dumpfile
);
3123 show_expr (open
->action
);
3127 fputs (" DELIM=", dumpfile
);
3128 show_expr (open
->delim
);
3132 fputs (" PAD=", dumpfile
);
3133 show_expr (open
->pad
);
3137 fputs (" DECIMAL=", dumpfile
);
3138 show_expr (open
->decimal
);
3142 fputs (" ENCODING=", dumpfile
);
3143 show_expr (open
->encoding
);
3147 fputs (" ROUND=", dumpfile
);
3148 show_expr (open
->round
);
3152 fputs (" SIGN=", dumpfile
);
3153 show_expr (open
->sign
);
3157 fputs (" CONVERT=", dumpfile
);
3158 show_expr (open
->convert
);
3160 if (open
->asynchronous
)
3162 fputs (" ASYNCHRONOUS=", dumpfile
);
3163 show_expr (open
->asynchronous
);
3165 if (open
->err
!= NULL
)
3166 fprintf (dumpfile
, " ERR=%d", open
->err
->value
);
3171 fputs ("CLOSE", dumpfile
);
3172 close
= c
->ext
.close
;
3176 fputs (" UNIT=", dumpfile
);
3177 show_expr (close
->unit
);
3181 fputs (" IOMSG=", dumpfile
);
3182 show_expr (close
->iomsg
);
3186 fputs (" IOSTAT=", dumpfile
);
3187 show_expr (close
->iostat
);
3191 fputs (" STATUS=", dumpfile
);
3192 show_expr (close
->status
);
3194 if (close
->err
!= NULL
)
3195 fprintf (dumpfile
, " ERR=%d", close
->err
->value
);
3198 case EXEC_BACKSPACE
:
3199 fputs ("BACKSPACE", dumpfile
);
3203 fputs ("ENDFILE", dumpfile
);
3207 fputs ("REWIND", dumpfile
);
3211 fputs ("FLUSH", dumpfile
);
3214 fp
= c
->ext
.filepos
;
3218 fputs (" UNIT=", dumpfile
);
3219 show_expr (fp
->unit
);
3223 fputs (" IOMSG=", dumpfile
);
3224 show_expr (fp
->iomsg
);
3228 fputs (" IOSTAT=", dumpfile
);
3229 show_expr (fp
->iostat
);
3231 if (fp
->err
!= NULL
)
3232 fprintf (dumpfile
, " ERR=%d", fp
->err
->value
);
3236 fputs ("INQUIRE", dumpfile
);
3241 fputs (" UNIT=", dumpfile
);
3242 show_expr (i
->unit
);
3246 fputs (" FILE=", dumpfile
);
3247 show_expr (i
->file
);
3252 fputs (" IOMSG=", dumpfile
);
3253 show_expr (i
->iomsg
);
3257 fputs (" IOSTAT=", dumpfile
);
3258 show_expr (i
->iostat
);
3262 fputs (" EXIST=", dumpfile
);
3263 show_expr (i
->exist
);
3267 fputs (" OPENED=", dumpfile
);
3268 show_expr (i
->opened
);
3272 fputs (" NUMBER=", dumpfile
);
3273 show_expr (i
->number
);
3277 fputs (" NAMED=", dumpfile
);
3278 show_expr (i
->named
);
3282 fputs (" NAME=", dumpfile
);
3283 show_expr (i
->name
);
3287 fputs (" ACCESS=", dumpfile
);
3288 show_expr (i
->access
);
3292 fputs (" SEQUENTIAL=", dumpfile
);
3293 show_expr (i
->sequential
);
3298 fputs (" DIRECT=", dumpfile
);
3299 show_expr (i
->direct
);
3303 fputs (" FORM=", dumpfile
);
3304 show_expr (i
->form
);
3308 fputs (" FORMATTED", dumpfile
);
3309 show_expr (i
->formatted
);
3313 fputs (" UNFORMATTED=", dumpfile
);
3314 show_expr (i
->unformatted
);
3318 fputs (" RECL=", dumpfile
);
3319 show_expr (i
->recl
);
3323 fputs (" NEXTREC=", dumpfile
);
3324 show_expr (i
->nextrec
);
3328 fputs (" BLANK=", dumpfile
);
3329 show_expr (i
->blank
);
3333 fputs (" POSITION=", dumpfile
);
3334 show_expr (i
->position
);
3338 fputs (" ACTION=", dumpfile
);
3339 show_expr (i
->action
);
3343 fputs (" READ=", dumpfile
);
3344 show_expr (i
->read
);
3348 fputs (" WRITE=", dumpfile
);
3349 show_expr (i
->write
);
3353 fputs (" READWRITE=", dumpfile
);
3354 show_expr (i
->readwrite
);
3358 fputs (" DELIM=", dumpfile
);
3359 show_expr (i
->delim
);
3363 fputs (" PAD=", dumpfile
);
3368 fputs (" CONVERT=", dumpfile
);
3369 show_expr (i
->convert
);
3371 if (i
->asynchronous
)
3373 fputs (" ASYNCHRONOUS=", dumpfile
);
3374 show_expr (i
->asynchronous
);
3378 fputs (" DECIMAL=", dumpfile
);
3379 show_expr (i
->decimal
);
3383 fputs (" ENCODING=", dumpfile
);
3384 show_expr (i
->encoding
);
3388 fputs (" PENDING=", dumpfile
);
3389 show_expr (i
->pending
);
3393 fputs (" ROUND=", dumpfile
);
3394 show_expr (i
->round
);
3398 fputs (" SIGN=", dumpfile
);
3399 show_expr (i
->sign
);
3403 fputs (" SIZE=", dumpfile
);
3404 show_expr (i
->size
);
3408 fputs (" ID=", dumpfile
);
3413 fprintf (dumpfile
, " ERR=%d", i
->err
->value
);
3417 fputs ("IOLENGTH ", dumpfile
);
3418 show_expr (c
->expr1
);
3423 fputs ("READ", dumpfile
);
3427 fputs ("WRITE", dumpfile
);
3433 fputs (" UNIT=", dumpfile
);
3434 show_expr (dt
->io_unit
);
3437 if (dt
->format_expr
)
3439 fputs (" FMT=", dumpfile
);
3440 show_expr (dt
->format_expr
);
3443 if (dt
->format_label
!= NULL
)
3444 fprintf (dumpfile
, " FMT=%d", dt
->format_label
->value
);
3446 fprintf (dumpfile
, " NML=%s", dt
->namelist
->name
);
3450 fputs (" IOMSG=", dumpfile
);
3451 show_expr (dt
->iomsg
);
3455 fputs (" IOSTAT=", dumpfile
);
3456 show_expr (dt
->iostat
);
3460 fputs (" SIZE=", dumpfile
);
3461 show_expr (dt
->size
);
3465 fputs (" REC=", dumpfile
);
3466 show_expr (dt
->rec
);
3470 fputs (" ADVANCE=", dumpfile
);
3471 show_expr (dt
->advance
);
3475 fputs (" ID=", dumpfile
);
3480 fputs (" POS=", dumpfile
);
3481 show_expr (dt
->pos
);
3483 if (dt
->asynchronous
)
3485 fputs (" ASYNCHRONOUS=", dumpfile
);
3486 show_expr (dt
->asynchronous
);
3490 fputs (" BLANK=", dumpfile
);
3491 show_expr (dt
->blank
);
3495 fputs (" DECIMAL=", dumpfile
);
3496 show_expr (dt
->decimal
);
3500 fputs (" DELIM=", dumpfile
);
3501 show_expr (dt
->delim
);
3505 fputs (" PAD=", dumpfile
);
3506 show_expr (dt
->pad
);
3510 fputs (" ROUND=", dumpfile
);
3511 show_expr (dt
->round
);
3515 fputs (" SIGN=", dumpfile
);
3516 show_expr (dt
->sign
);
3520 for (c
= c
->block
->next
; c
; c
= c
->next
)
3521 show_code_node (level
+ (c
->next
!= NULL
), c
);
3525 fputs ("TRANSFER ", dumpfile
);
3526 show_expr (c
->expr1
);
3530 fputs ("DT_END", dumpfile
);
3533 if (dt
->err
!= NULL
)
3534 fprintf (dumpfile
, " ERR=%d", dt
->err
->value
);
3535 if (dt
->end
!= NULL
)
3536 fprintf (dumpfile
, " END=%d", dt
->end
->value
);
3537 if (dt
->eor
!= NULL
)
3538 fprintf (dumpfile
, " EOR=%d", dt
->eor
->value
);
3542 fputs ("WAIT", dumpfile
);
3544 if (c
->ext
.wait
!= NULL
)
3546 gfc_wait
*wait
= c
->ext
.wait
;
3549 fputs (" UNIT=", dumpfile
);
3550 show_expr (wait
->unit
);
3554 fputs (" IOSTAT=", dumpfile
);
3555 show_expr (wait
->iostat
);
3559 fputs (" IOMSG=", dumpfile
);
3560 show_expr (wait
->iomsg
);
3564 fputs (" ID=", dumpfile
);
3565 show_expr (wait
->id
);
3568 fprintf (dumpfile
, " ERR=%d", wait
->err
->value
);
3570 fprintf (dumpfile
, " END=%d", wait
->end
->value
);
3572 fprintf (dumpfile
, " EOR=%d", wait
->eor
->value
);
3576 case EXEC_OACC_PARALLEL_LOOP
:
3577 case EXEC_OACC_PARALLEL
:
3578 case EXEC_OACC_KERNELS_LOOP
:
3579 case EXEC_OACC_KERNELS
:
3580 case EXEC_OACC_SERIAL_LOOP
:
3581 case EXEC_OACC_SERIAL
:
3582 case EXEC_OACC_DATA
:
3583 case EXEC_OACC_HOST_DATA
:
3584 case EXEC_OACC_LOOP
:
3585 case EXEC_OACC_UPDATE
:
3586 case EXEC_OACC_WAIT
:
3587 case EXEC_OACC_CACHE
:
3588 case EXEC_OACC_ENTER_DATA
:
3589 case EXEC_OACC_EXIT_DATA
:
3590 case EXEC_OMP_ALLOCATE
:
3591 case EXEC_OMP_ALLOCATORS
:
3592 case EXEC_OMP_ASSUME
:
3593 case EXEC_OMP_ATOMIC
:
3594 case EXEC_OMP_CANCEL
:
3595 case EXEC_OMP_CANCELLATION_POINT
:
3596 case EXEC_OMP_BARRIER
:
3597 case EXEC_OMP_CRITICAL
:
3598 case EXEC_OMP_DEPOBJ
:
3599 case EXEC_OMP_DISTRIBUTE
:
3600 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO
:
3601 case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD
:
3602 case EXEC_OMP_DISTRIBUTE_SIMD
:
3604 case EXEC_OMP_DO_SIMD
:
3605 case EXEC_OMP_ERROR
:
3606 case EXEC_OMP_INTEROP
:
3607 case EXEC_OMP_FLUSH
:
3609 case EXEC_OMP_MASKED
:
3610 case EXEC_OMP_MASKED_TASKLOOP
:
3611 case EXEC_OMP_MASKED_TASKLOOP_SIMD
:
3612 case EXEC_OMP_MASTER
:
3613 case EXEC_OMP_MASTER_TASKLOOP
:
3614 case EXEC_OMP_MASTER_TASKLOOP_SIMD
:
3615 case EXEC_OMP_ORDERED
:
3616 case EXEC_OMP_PARALLEL
:
3617 case EXEC_OMP_PARALLEL_DO
:
3618 case EXEC_OMP_PARALLEL_DO_SIMD
:
3619 case EXEC_OMP_PARALLEL_LOOP
:
3620 case EXEC_OMP_PARALLEL_MASKED
:
3621 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP
:
3622 case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD
:
3623 case EXEC_OMP_PARALLEL_MASTER
:
3624 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP
:
3625 case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD
:
3626 case EXEC_OMP_PARALLEL_SECTIONS
:
3627 case EXEC_OMP_PARALLEL_WORKSHARE
:
3629 case EXEC_OMP_SCOPE
:
3630 case EXEC_OMP_SECTIONS
:
3632 case EXEC_OMP_SINGLE
:
3633 case EXEC_OMP_TARGET
:
3634 case EXEC_OMP_TARGET_DATA
:
3635 case EXEC_OMP_TARGET_ENTER_DATA
:
3636 case EXEC_OMP_TARGET_EXIT_DATA
:
3637 case EXEC_OMP_TARGET_PARALLEL
:
3638 case EXEC_OMP_TARGET_PARALLEL_DO
:
3639 case EXEC_OMP_TARGET_PARALLEL_DO_SIMD
:
3640 case EXEC_OMP_TARGET_PARALLEL_LOOP
:
3641 case EXEC_OMP_TARGET_SIMD
:
3642 case EXEC_OMP_TARGET_TEAMS
:
3643 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE
:
3644 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3645 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3646 case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD
:
3647 case EXEC_OMP_TARGET_TEAMS_LOOP
:
3648 case EXEC_OMP_TARGET_UPDATE
:
3650 case EXEC_OMP_TASKGROUP
:
3651 case EXEC_OMP_TASKLOOP
:
3652 case EXEC_OMP_TASKLOOP_SIMD
:
3653 case EXEC_OMP_TASKWAIT
:
3654 case EXEC_OMP_TASKYIELD
:
3655 case EXEC_OMP_TEAMS
:
3656 case EXEC_OMP_TEAMS_DISTRIBUTE
:
3657 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO
:
3658 case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD
:
3659 case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD
:
3660 case EXEC_OMP_TEAMS_LOOP
:
3662 case EXEC_OMP_UNROLL
:
3663 case EXEC_OMP_WORKSHARE
:
3664 show_omp_node (level
, c
);
3668 gfc_internal_error ("show_code_node(): Bad statement code");
3673 /* Show an equivalence chain. */
3676 show_equiv (gfc_equiv
*eq
)
3679 fputs ("Equivalence: ", dumpfile
);
3682 show_expr (eq
->expr
);
3685 fputs (", ", dumpfile
);
3690 /* Show a freakin' whole namespace. */
3693 show_namespace (gfc_namespace
*ns
)
3695 gfc_interface
*intr
;
3696 gfc_namespace
*save
;
3702 save
= gfc_current_ns
;
3705 fputs ("Namespace:", dumpfile
);
3711 while (i
< GFC_LETTERS
- 1
3712 && gfc_compare_types (&ns
->default_type
[i
+1],
3713 &ns
->default_type
[l
]))
3717 fprintf (dumpfile
, " %c-%c: ", l
+'A', i
+'A');
3719 fprintf (dumpfile
, " %c: ", l
+'A');
3721 show_typespec(&ns
->default_type
[l
]);
3723 } while (i
< GFC_LETTERS
);
3725 if (ns
->proc_name
!= NULL
)
3728 fprintf (dumpfile
, "procedure name = %s", ns
->proc_name
->name
);
3732 gfc_current_ns
= ns
;
3733 gfc_traverse_symtree (ns
->common_root
, show_common
);
3735 gfc_traverse_symtree (ns
->sym_root
, show_symtree
);
3737 for (op
= GFC_INTRINSIC_BEGIN
; op
!= GFC_INTRINSIC_END
; op
++)
3739 /* User operator interfaces */
3745 fprintf (dumpfile
, "Operator interfaces for %s:",
3746 gfc_op2string ((gfc_intrinsic_op
) op
));
3748 for (; intr
; intr
= intr
->next
)
3749 fprintf (dumpfile
, " %s", intr
->sym
->name
);
3752 if (ns
->uop_root
!= NULL
)
3755 fputs ("User operators:\n", dumpfile
);
3756 gfc_traverse_user_op (ns
, show_uop
);
3759 for (eq
= ns
->equiv
; eq
; eq
= eq
->next
)
3762 if (ns
->oacc_declare
)
3764 struct gfc_oacc_declare
*decl
;
3765 /* Dump !$ACC DECLARE clauses. */
3766 for (decl
= ns
->oacc_declare
; decl
; decl
= decl
->next
)
3769 fprintf (dumpfile
, "!$ACC DECLARE");
3770 show_omp_clauses (decl
->clauses
);
3774 if (ns
->omp_assumes
)
3777 fprintf (dumpfile
, "!$OMP ASSUMES");
3778 show_omp_assumes (ns
->omp_assumes
);
3781 fputc ('\n', dumpfile
);
3783 fputs ("code:", dumpfile
);
3784 show_code (show_level
, ns
->code
);
3787 for (ns
= ns
->contained
; ns
; ns
= ns
->sibling
)
3789 fputs ("\nCONTAINS\n", dumpfile
);
3791 show_namespace (ns
);
3795 fputc ('\n', dumpfile
);
3796 gfc_current_ns
= save
;
3800 /* Main function for dumping a parse tree. */
3803 gfc_dump_parse_tree (gfc_namespace
*ns
, FILE *file
)
3806 show_namespace (ns
);
3809 /* This part writes BIND(C) definition for use in external C programs. */
3811 static void write_interop_decl (gfc_symbol
*);
3812 static void write_proc (gfc_symbol
*, bool);
3815 gfc_dump_c_prototypes (gfc_namespace
*ns
, FILE *file
)
3818 gfc_get_errors (NULL
, &error_count
);
3819 if (error_count
!= 0)
3822 gfc_traverse_ns (ns
, write_interop_decl
);
3825 /* Loop over all global symbols, writing out their declarations. */
3828 gfc_dump_external_c_prototypes (FILE * file
)
3832 _("/* Prototypes for external procedures generated from %s\n"
3833 " by GNU Fortran %s%s.\n\n"
3834 " Use of this interface is discouraged, consider using the\n"
3835 " BIND(C) feature of standard Fortran instead. */\n\n"),
3836 gfc_source_file
, pkgversion_string
, version_string
);
3838 for (gfc_current_ns
= gfc_global_ns_list
; gfc_current_ns
;
3839 gfc_current_ns
= gfc_current_ns
->sibling
)
3841 gfc_symbol
*sym
= gfc_current_ns
->proc_name
;
3843 if (sym
== NULL
|| sym
->attr
.flavor
!= FL_PROCEDURE
3844 || sym
->attr
.is_bind_c
)
3847 write_proc (sym
, false);
3852 enum type_return
{ T_OK
=0, T_WARN
, T_ERROR
};
3854 /* Return the name of the type for later output. Both function pointers and
3855 void pointers will be mapped to void *. */
3857 static enum type_return
3858 get_c_type_name (gfc_typespec
*ts
, gfc_array_spec
*as
, const char **pre
,
3859 const char **type_name
, bool *asterisk
, const char **post
,
3862 static char post_buffer
[40];
3863 enum type_return ret
;
3869 *type_name
= "<error>";
3870 if (ts
->type
== BT_REAL
|| ts
->type
== BT_INTEGER
|| ts
->type
== BT_COMPLEX
3871 || ts
->type
== BT_UNSIGNED
)
3873 if (ts
->is_c_interop
&& ts
->interop_kind
)
3878 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3880 if (c_interop_kinds_table
[i
].f90_type
== ts
->type
3881 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3883 /* Skip over 'c_'. */
3884 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3885 if (strcmp (*type_name
, "long_long") == 0)
3886 *type_name
= "long long";
3887 if (strcmp (*type_name
, "long_double") == 0)
3888 *type_name
= "long double";
3889 if (strcmp (*type_name
, "signed_char") == 0)
3890 *type_name
= "signed char";
3891 else if (strcmp (*type_name
, "size_t") == 0)
3892 *type_name
= "ssize_t";
3893 else if (strcmp (*type_name
, "float_complex") == 0)
3894 *type_name
= "__GFORTRAN_FLOAT_COMPLEX";
3895 else if (strcmp (*type_name
, "double_complex") == 0)
3896 *type_name
= "__GFORTRAN_DOUBLE_COMPLEX";
3897 else if (strcmp (*type_name
, "long_double_complex") == 0)
3898 *type_name
= "__GFORTRAN_LONG_DOUBLE_COMPLEX";
3899 else if (strcmp (*type_name
, "unsigned") == 0)
3900 *type_name
= "unsigned int";
3901 else if (strcmp (*type_name
, "unsigned_char") == 0)
3902 *type_name
= "unsigned char";
3903 else if (strcmp (*type_name
, "unsigned_short") == 0)
3904 *type_name
= "unsigned short int";
3905 else if (strcmp (*type_name
, "unsigned_long") == 0)
3906 *type_name
= "unsigned long int";
3907 else if (strcmp (*type_name
, "unsigned_long long") == 0)
3908 *type_name
= "unsigned long long int";
3913 else if (ts
->type
== BT_LOGICAL
)
3915 if (ts
->is_c_interop
&& ts
->interop_kind
)
3917 *type_name
= "_Bool";
3922 /* Let's select an appropriate int, with a warning. */
3923 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3925 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3926 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3928 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3934 else if (ts
->type
== BT_CHARACTER
)
3936 if (ts
->is_c_interop
)
3938 *type_name
= "char";
3943 if (ts
->kind
== gfc_default_character_kind
)
3944 *type_name
= "char";
3946 /* Let's select an appropriate int. */
3947 for (int i
= 0; i
< ISOCBINDING_NUMBER
; i
++)
3949 if (c_interop_kinds_table
[i
].f90_type
== BT_INTEGER
3950 && c_interop_kinds_table
[i
].value
== ts
->kind
)
3952 *type_name
= c_interop_kinds_table
[i
].name
+ 2;
3960 else if (ts
->type
== BT_DERIVED
)
3962 if (ts
->u
.derived
->from_intmod
== INTMOD_ISO_C_BINDING
)
3964 if (strcmp (ts
->u
.derived
->name
, "c_ptr") == 0)
3965 *type_name
= "void";
3966 else if (strcmp (ts
->u
.derived
->name
, "c_funptr") == 0)
3968 *type_name
= "int ";
3984 *type_name
= ts
->u
.derived
->name
;
3989 if (ret
!= T_ERROR
&& as
)
3993 size_ok
= spec_size (as
, &sz
);
3994 gcc_assert (size_ok
== true);
3995 gmp_snprintf (post_buffer
, sizeof(post_buffer
), "[%Zd]", sz
);
3996 *post
= post_buffer
;
4002 /* Write out a declaration. */
4004 write_decl (gfc_typespec
*ts
, gfc_array_spec
*as
, const char *sym_name
,
4005 bool func_ret
, locus
*where
, bool bind_c
)
4007 const char *pre
, *type_name
, *post
;
4009 enum type_return rok
;
4011 rok
= get_c_type_name (ts
, as
, &pre
, &type_name
, &asterisk
, &post
, func_ret
);
4014 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
4015 gfc_typename (ts
), where
);
4016 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
4020 fputs (type_name
, dumpfile
);
4021 fputs (pre
, dumpfile
);
4023 fputs ("*", dumpfile
);
4025 fputs (sym_name
, dumpfile
);
4026 fputs (post
, dumpfile
);
4028 if (rok
== T_WARN
&& bind_c
)
4029 fprintf (dumpfile
," /* WARNING: Converting '%s' to interoperable type */",
4033 /* Write out an interoperable type. It will be written as a typedef
4037 write_type (gfc_symbol
*sym
)
4041 fprintf (dumpfile
, "typedef struct %s {\n", sym
->name
);
4042 for (c
= sym
->components
; c
; c
= c
->next
)
4044 fputs (" ", dumpfile
);
4045 write_decl (&(c
->ts
), c
->as
, c
->name
, false, &sym
->declared_at
, true);
4046 fputs (";\n", dumpfile
);
4049 fprintf (dumpfile
, "} %s;\n", sym
->name
);
4052 /* Write out a variable. */
4055 write_variable (gfc_symbol
*sym
)
4057 const char *sym_name
;
4059 gcc_assert (sym
->attr
.flavor
== FL_VARIABLE
);
4061 if (sym
->binding_label
)
4062 sym_name
= sym
->binding_label
;
4064 sym_name
= sym
->name
;
4066 fputs ("extern ", dumpfile
);
4067 write_decl (&(sym
->ts
), sym
->as
, sym_name
, false, &sym
->declared_at
, true);
4068 fputs (";\n", dumpfile
);
4072 /* Write out a procedure, including its arguments. */
4074 write_proc (gfc_symbol
*sym
, bool bind_c
)
4076 const char *pre
, *type_name
, *post
;
4078 enum type_return rok
;
4079 gfc_formal_arglist
*f
;
4080 const char *sym_name
;
4081 const char *intent_in
;
4082 bool external_character
;
4084 external_character
= sym
->ts
.type
== BT_CHARACTER
&& !bind_c
;
4086 if (sym
->binding_label
)
4087 sym_name
= sym
->binding_label
;
4089 sym_name
= sym
->name
;
4091 if (sym
->ts
.type
== BT_UNKNOWN
|| external_character
)
4093 fprintf (dumpfile
, "void ");
4094 fputs (sym_name
, dumpfile
);
4097 write_decl (&(sym
->ts
), sym
->as
, sym_name
, true, &sym
->declared_at
, bind_c
);
4100 fputs ("_", dumpfile
);
4102 fputs (" (", dumpfile
);
4103 if (external_character
)
4105 fprintf (dumpfile
, "char *result_%s, size_t result_%s_len",
4106 sym_name
, sym_name
);
4108 fputs (", ", dumpfile
);
4111 for (f
= sym
->formal
; f
; f
= f
->next
)
4115 rok
= get_c_type_name (&(s
->ts
), NULL
, &pre
, &type_name
, &asterisk
,
4119 gfc_error_now ("Cannot convert %qs to interoperable type at %L",
4120 gfc_typename (&s
->ts
), &s
->declared_at
);
4121 fprintf (dumpfile
, "/* Cannot convert '%s' to interoperable type */",
4122 gfc_typename (&s
->ts
));
4129 if (s
->attr
.intent
== INTENT_IN
&& !s
->attr
.value
)
4130 intent_in
= "const ";
4134 fputs (intent_in
, dumpfile
);
4135 fputs (type_name
, dumpfile
);
4136 fputs (pre
, dumpfile
);
4138 fputs ("*", dumpfile
);
4140 fputs (s
->name
, dumpfile
);
4141 fputs (post
, dumpfile
);
4142 if (bind_c
&& rok
== T_WARN
)
4143 fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile
);
4146 fputs(", ", dumpfile
);
4149 for (f
= sym
->formal
; f
; f
= f
->next
)
4150 if (f
->sym
->ts
.type
== BT_CHARACTER
)
4151 fprintf (dumpfile
, ", size_t %s_len", f
->sym
->name
);
4153 fputs (");\n", dumpfile
);
4157 /* Write a C-interoperable declaration as a C prototype or extern
4161 write_interop_decl (gfc_symbol
*sym
)
4163 /* Only dump bind(c) entities. */
4164 if (!sym
->attr
.is_bind_c
)
4167 /* Don't dump our iso c module. */
4168 if (sym
->from_intmod
== INTMOD_ISO_C_BINDING
)
4171 if (sym
->attr
.flavor
== FL_VARIABLE
)
4172 write_variable (sym
);
4173 else if (sym
->attr
.flavor
== FL_DERIVED
)
4175 else if (sym
->attr
.flavor
== FL_PROCEDURE
)
4176 write_proc (sym
, true);
4179 /* This section deals with dumping the global symbol tree. */
4181 /* Callback function for printing out the contents of the tree. */
4184 show_global_symbol (gfc_gsymbol
*gsym
, void *f_data
)
4187 out
= (FILE *) f_data
;
4190 fprintf (out
, "name=%s", gsym
->name
);
4193 fprintf (out
, ", sym_name=%s", gsym
->sym_name
);
4196 fprintf (out
, ", mod_name=%s", gsym
->mod_name
);
4198 if (gsym
->binding_label
)
4199 fprintf (out
, ", binding_label=%s", gsym
->binding_label
);
4204 /* Show all global symbols. */
4207 gfc_dump_global_symbols (FILE *f
)
4209 if (gfc_gsym_root
== NULL
)
4210 fprintf (f
, "empty\n");
4212 gfc_traverse_gsymbol (gfc_gsym_root
, show_global_symbol
, (void *) f
);
4215 /* Show an array ref. */
4218 debug (gfc_array_ref
*ar
)
4220 FILE *tmp
= dumpfile
;
4222 show_array_ref (ar
);
4223 fputc ('\n', dumpfile
);