2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
3 Free Software Foundation, Inc.
4 Contributed by Steven Bosscher
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
23 /* Actually this is just a collection of routines that used to be
24 scattered around the sources. Now that they are all in a single
25 file, almost all of them can be static, and the other files don't
26 have this mess in them.
28 As a nice side-effect, this file can act as documentation of the
29 gfc_code and gfc_expr structures and all their friends and
37 /* Keep track of indentation for symbol tree dumps. */
38 static int show_level = 0;
40 /* The file handle we're dumping to is kept in a static variable. This
41 is not too cool, but it avoids a lot of passing it around. */
42 static FILE *dumpfile;
44 /* Forward declaration of some of the functions. */
45 static void show_expr (gfc_expr *p);
46 static void show_code_node (int, gfc_code *);
47 static void show_namespace (gfc_namespace *ns);
50 /* Do indentation for a specific level. */
53 code_indent (int level, gfc_st_label *label)
58 fprintf (dumpfile, "%-5d ", label->value);
60 fputs (" ", dumpfile);
62 for (i = 0; i < 2 * level; i++)
63 fputc (' ', dumpfile);
67 /* Simple indentation at the current level. This one
68 is used to show symbols. */
73 fputc ('\n', dumpfile);
74 code_indent (show_level, NULL);
78 /* Show type-specific information. */
81 show_typespec (gfc_typespec *ts)
83 fprintf (dumpfile, "(%s ", gfc_basic_typename (ts->type));
88 fprintf (dumpfile, "%s", ts->derived->name);
92 show_expr (ts->cl->length);
96 fprintf (dumpfile, "%d", ts->kind);
100 fputc (')', dumpfile);
104 /* Show an actual argument list. */
107 show_actual_arglist (gfc_actual_arglist *a)
109 fputc ('(', dumpfile);
111 for (; a; a = a->next)
113 fputc ('(', dumpfile);
115 fprintf (dumpfile, "%s = ", a->name);
119 fputs ("(arg not-present)", dumpfile);
121 fputc (')', dumpfile);
123 fputc (' ', dumpfile);
126 fputc (')', dumpfile);
130 /* Show a gfc_array_spec array specification structure. */
133 show_array_spec (gfc_array_spec *as)
140 fputs ("()", dumpfile);
144 fprintf (dumpfile, "(%d", as->rank);
150 case AS_EXPLICIT: c = "AS_EXPLICIT"; break;
151 case AS_DEFERRED: c = "AS_DEFERRED"; break;
152 case AS_ASSUMED_SIZE: c = "AS_ASSUMED_SIZE"; break;
153 case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;
155 gfc_internal_error ("show_array_spec(): Unhandled array shape "
158 fprintf (dumpfile, " %s ", c);
160 for (i = 0; i < as->rank; i++)
162 show_expr (as->lower[i]);
163 fputc (' ', dumpfile);
164 show_expr (as->upper[i]);
165 fputc (' ', dumpfile);
169 fputc (')', dumpfile);
173 /* Show a gfc_array_ref array reference structure. */
176 show_array_ref (gfc_array_ref * ar)
180 fputc ('(', dumpfile);
185 fputs ("FULL", dumpfile);
189 for (i = 0; i < ar->dimen; i++)
191 /* There are two types of array sections: either the
192 elements are identified by an integer array ('vector'),
193 or by an index range. In the former case we only have to
194 print the start expression which contains the vector, in
195 the latter case we have to print any of lower and upper
196 bound and the stride, if they're present. */
198 if (ar->start[i] != NULL)
199 show_expr (ar->start[i]);
201 if (ar->dimen_type[i] == DIMEN_RANGE)
203 fputc (':', dumpfile);
205 if (ar->end[i] != NULL)
206 show_expr (ar->end[i]);
208 if (ar->stride[i] != NULL)
210 fputc (':', dumpfile);
211 show_expr (ar->stride[i]);
215 if (i != ar->dimen - 1)
216 fputs (" , ", dumpfile);
221 for (i = 0; i < ar->dimen; i++)
223 show_expr (ar->start[i]);
224 if (i != ar->dimen - 1)
225 fputs (" , ", dumpfile);
230 fputs ("UNKNOWN", dumpfile);
234 gfc_internal_error ("show_array_ref(): Unknown array reference");
237 fputc (')', dumpfile);
241 /* Show a list of gfc_ref structures. */
244 show_ref (gfc_ref *p)
246 for (; p; p = p->next)
250 show_array_ref (&p->u.ar);
254 fprintf (dumpfile, " %% %s", p->u.c.component->name);
258 fputc ('(', dumpfile);
259 show_expr (p->u.ss.start);
260 fputc (':', dumpfile);
261 show_expr (p->u.ss.end);
262 fputc (')', dumpfile);
266 gfc_internal_error ("show_ref(): Bad component code");
271 /* Display a constructor. Works recursively for array constructors. */
274 show_constructor (gfc_constructor *c)
276 for (; c; c = c->next)
278 if (c->iterator == NULL)
282 fputc ('(', dumpfile);
285 fputc (' ', dumpfile);
286 show_expr (c->iterator->var);
287 fputc ('=', dumpfile);
288 show_expr (c->iterator->start);
289 fputc (',', dumpfile);
290 show_expr (c->iterator->end);
291 fputc (',', dumpfile);
292 show_expr (c->iterator->step);
294 fputc (')', dumpfile);
298 fputs (" , ", dumpfile);
304 show_char_const (const gfc_char_t *c, int length)
308 fputc ('\'', dumpfile);
309 for (i = 0; i < length; i++)
312 fputs ("''", dumpfile);
314 fputs (gfc_print_wide_char (c[i]), dumpfile);
316 fputc ('\'', dumpfile);
319 /* Show an expression. */
322 show_expr (gfc_expr *p)
329 fputs ("()", dumpfile);
333 switch (p->expr_type)
336 show_char_const (p->value.character.string, p->value.character.length);
341 fprintf (dumpfile, "%s(", p->ts.derived->name);
342 show_constructor (p->value.constructor);
343 fputc (')', dumpfile);
347 fputs ("(/ ", dumpfile);
348 show_constructor (p->value.constructor);
349 fputs (" /)", dumpfile);
355 fputs ("NULL()", dumpfile);
362 mpz_out_str (stdout, 10, p->value.integer);
364 if (p->ts.kind != gfc_default_integer_kind)
365 fprintf (dumpfile, "_%d", p->ts.kind);
369 if (p->value.logical)
370 fputs (".true.", dumpfile);
372 fputs (".false.", dumpfile);
376 mpfr_out_str (stdout, 10, 0, p->value.real, GFC_RND_MODE);
377 if (p->ts.kind != gfc_default_real_kind)
378 fprintf (dumpfile, "_%d", p->ts.kind);
382 show_char_const (p->value.character.string,
383 p->value.character.length);
387 fputs ("(complex ", dumpfile);
389 mpfr_out_str (stdout, 10, 0, p->value.complex.r, GFC_RND_MODE);
390 if (p->ts.kind != gfc_default_complex_kind)
391 fprintf (dumpfile, "_%d", p->ts.kind);
393 fputc (' ', dumpfile);
395 mpfr_out_str (stdout, 10, 0, p->value.complex.i, GFC_RND_MODE);
396 if (p->ts.kind != gfc_default_complex_kind)
397 fprintf (dumpfile, "_%d", p->ts.kind);
399 fputc (')', dumpfile);
403 fprintf (dumpfile, "%dH", p->representation.length);
404 c = p->representation.string;
405 for (i = 0; i < p->representation.length; i++, c++)
407 fputc (*c, dumpfile);
412 fputs ("???", dumpfile);
416 if (p->representation.string)
418 fputs (" {", dumpfile);
419 c = p->representation.string;
420 for (i = 0; i < p->representation.length; i++, c++)
422 fprintf (dumpfile, "%.2x", (unsigned int) *c);
423 if (i < p->representation.length - 1)
424 fputc (',', dumpfile);
426 fputc ('}', dumpfile);
432 if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)
433 fprintf (dumpfile, "%s:", p->symtree->n.sym->ns->proc_name->name);
434 fprintf (dumpfile, "%s", p->symtree->n.sym->name);
439 fputc ('(', dumpfile);
440 switch (p->value.op.op)
442 case INTRINSIC_UPLUS:
443 fputs ("U+ ", dumpfile);
445 case INTRINSIC_UMINUS:
446 fputs ("U- ", dumpfile);
449 fputs ("+ ", dumpfile);
451 case INTRINSIC_MINUS:
452 fputs ("- ", dumpfile);
454 case INTRINSIC_TIMES:
455 fputs ("* ", dumpfile);
457 case INTRINSIC_DIVIDE:
458 fputs ("/ ", dumpfile);
460 case INTRINSIC_POWER:
461 fputs ("** ", dumpfile);
463 case INTRINSIC_CONCAT:
464 fputs ("// ", dumpfile);
467 fputs ("AND ", dumpfile);
470 fputs ("OR ", dumpfile);
473 fputs ("EQV ", dumpfile);
476 fputs ("NEQV ", dumpfile);
479 case INTRINSIC_EQ_OS:
480 fputs ("= ", dumpfile);
483 case INTRINSIC_NE_OS:
484 fputs ("/= ", dumpfile);
487 case INTRINSIC_GT_OS:
488 fputs ("> ", dumpfile);
491 case INTRINSIC_GE_OS:
492 fputs (">= ", dumpfile);
495 case INTRINSIC_LT_OS:
496 fputs ("< ", dumpfile);
499 case INTRINSIC_LE_OS:
500 fputs ("<= ", dumpfile);
503 fputs ("NOT ", dumpfile);
505 case INTRINSIC_PARENTHESES:
506 fputs ("parens", dumpfile);
511 ("show_expr(): Bad intrinsic in expression!");
514 show_expr (p->value.op.op1);
518 fputc (' ', dumpfile);
519 show_expr (p->value.op.op2);
522 fputc (')', dumpfile);
526 if (p->value.function.name == NULL)
528 fprintf (dumpfile, "%s[", p->symtree->n.sym->name);
529 show_actual_arglist (p->value.function.actual);
530 fputc (']', dumpfile);
534 fprintf (dumpfile, "%s[[", p->value.function.name);
535 show_actual_arglist (p->value.function.actual);
536 fputc (']', dumpfile);
537 fputc (']', dumpfile);
543 gfc_internal_error ("show_expr(): Don't know how to show expr");
547 /* Show symbol attributes. The flavor and intent are followed by
548 whatever single bit attributes are present. */
551 show_attr (symbol_attribute *attr)
554 fprintf (dumpfile, "(%s %s %s %s %s",
555 gfc_code2string (flavors, attr->flavor),
556 gfc_intent_string (attr->intent),
557 gfc_code2string (access_types, attr->access),
558 gfc_code2string (procedures, attr->proc),
559 gfc_code2string (save_status, attr->save));
561 if (attr->allocatable)
562 fputs (" ALLOCATABLE", dumpfile);
564 fputs (" DIMENSION", dumpfile);
566 fputs (" EXTERNAL", dumpfile);
568 fputs (" INTRINSIC", dumpfile);
570 fputs (" OPTIONAL", dumpfile);
572 fputs (" POINTER", dumpfile);
573 if (attr->is_protected)
574 fputs (" PROTECTED", dumpfile);
576 fputs (" VALUE", dumpfile);
578 fputs (" VOLATILE", dumpfile);
579 if (attr->threadprivate)
580 fputs (" THREADPRIVATE", dumpfile);
582 fputs (" TARGET", dumpfile);
584 fputs (" DUMMY", dumpfile);
586 fputs (" RESULT", dumpfile);
588 fputs (" ENTRY", dumpfile);
590 fputs (" BIND(C)", dumpfile);
593 fputs (" DATA", dumpfile);
595 fputs (" USE-ASSOC", dumpfile);
596 if (attr->in_namelist)
597 fputs (" IN-NAMELIST", dumpfile);
599 fputs (" IN-COMMON", dumpfile);
602 fputs (" ABSTRACT INTERFACE", dumpfile);
604 fputs (" FUNCTION", dumpfile);
605 if (attr->subroutine)
606 fputs (" SUBROUTINE", dumpfile);
607 if (attr->implicit_type)
608 fputs (" IMPLICIT-TYPE", dumpfile);
611 fputs (" SEQUENCE", dumpfile);
613 fputs (" ELEMENTAL", dumpfile);
615 fputs (" PURE", dumpfile);
617 fputs (" RECURSIVE", dumpfile);
619 fputc (')', dumpfile);
623 /* Show components of a derived type. */
626 show_components (gfc_symbol *sym)
630 for (c = sym->components; c; c = c->next)
632 fprintf (dumpfile, "(%s ", c->name);
633 show_typespec (&c->ts);
635 fputs (" POINTER", dumpfile);
637 fputs (" DIMENSION", dumpfile);
638 fputc (' ', dumpfile);
639 show_array_spec (c->as);
641 fprintf (dumpfile, " %s", gfc_code2string (access_types, c->access));
642 fputc (')', dumpfile);
644 fputc (' ', dumpfile);
649 /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
650 show the interface. Information needed to reconstruct the list of
651 specific interfaces associated with a generic symbol is done within
655 show_symbol (gfc_symbol *sym)
657 gfc_formal_arglist *formal;
665 fprintf (dumpfile, "symbol %s ", sym->name);
666 show_typespec (&sym->ts);
667 show_attr (&sym->attr);
672 fputs ("value: ", dumpfile);
673 show_expr (sym->value);
679 fputs ("Array spec:", dumpfile);
680 show_array_spec (sym->as);
686 fputs ("Generic interfaces:", dumpfile);
687 for (intr = sym->generic; intr; intr = intr->next)
688 fprintf (dumpfile, " %s", intr->sym->name);
694 fprintf (dumpfile, "result: %s", sym->result->name);
700 fputs ("components: ", dumpfile);
701 show_components (sym);
707 fputs ("Formal arglist:", dumpfile);
709 for (formal = sym->formal; formal; formal = formal->next)
711 if (formal->sym != NULL)
712 fprintf (dumpfile, " %s", formal->sym->name);
714 fputs (" [Alt Return]", dumpfile);
721 fputs ("Formal namespace", dumpfile);
722 show_namespace (sym->formal_ns);
725 fputc ('\n', dumpfile);
729 /* Show a user-defined operator. Just prints an operator
730 and the name of the associated subroutine, really. */
733 show_uop (gfc_user_op *uop)
738 fprintf (dumpfile, "%s:", uop->name);
740 for (intr = uop->op; intr; intr = intr->next)
741 fprintf (dumpfile, " %s", intr->sym->name);
745 /* Workhorse function for traversing the user operator symtree. */
748 traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *))
755 traverse_uop (st->left, func);
756 traverse_uop (st->right, func);
760 /* Traverse the tree of user operator nodes. */
763 gfc_traverse_user_op (gfc_namespace *ns, void (*func) (gfc_user_op *))
765 traverse_uop (ns->uop_root, func);
769 /* Function to display a common block. */
772 show_common (gfc_symtree *st)
777 fprintf (dumpfile, "common: /%s/ ", st->name);
779 s = st->n.common->head;
782 fprintf (dumpfile, "%s", s->name);
785 fputs (", ", dumpfile);
787 fputc ('\n', dumpfile);
791 /* Worker function to display the symbol tree. */
794 show_symtree (gfc_symtree *st)
797 fprintf (dumpfile, "symtree: %s Ambig %d", st->name, st->ambiguous);
799 if (st->n.sym->ns != gfc_current_ns)
800 fprintf (dumpfile, " from namespace %s", st->n.sym->ns->proc_name->name);
802 show_symbol (st->n.sym);
806 /******************* Show gfc_code structures **************/
809 /* Show a list of code structures. Mutually recursive with
813 show_code (int level, gfc_code *c)
815 for (; c; c = c->next)
816 show_code_node (level, c);
820 show_namelist (gfc_namelist *n)
822 for (; n->next; n = n->next)
823 fprintf (dumpfile, "%s,", n->sym->name);
824 fprintf (dumpfile, "%s", n->sym->name);
827 /* Show a single OpenMP directive node and everything underneath it
831 show_omp_node (int level, gfc_code *c)
833 gfc_omp_clauses *omp_clauses = NULL;
834 const char *name = NULL;
838 case EXEC_OMP_ATOMIC: name = "ATOMIC"; break;
839 case EXEC_OMP_BARRIER: name = "BARRIER"; break;
840 case EXEC_OMP_CRITICAL: name = "CRITICAL"; break;
841 case EXEC_OMP_FLUSH: name = "FLUSH"; break;
842 case EXEC_OMP_DO: name = "DO"; break;
843 case EXEC_OMP_MASTER: name = "MASTER"; break;
844 case EXEC_OMP_ORDERED: name = "ORDERED"; break;
845 case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
846 case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break;
847 case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break;
848 case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break;
849 case EXEC_OMP_SECTIONS: name = "SECTIONS"; break;
850 case EXEC_OMP_SINGLE: name = "SINGLE"; break;
851 case EXEC_OMP_TASK: name = "TASK"; break;
852 case EXEC_OMP_TASKWAIT: name = "TASKWAIT"; break;
853 case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break;
857 fprintf (dumpfile, "!$OMP %s", name);
861 case EXEC_OMP_PARALLEL:
862 case EXEC_OMP_PARALLEL_DO:
863 case EXEC_OMP_PARALLEL_SECTIONS:
864 case EXEC_OMP_SECTIONS:
865 case EXEC_OMP_SINGLE:
866 case EXEC_OMP_WORKSHARE:
867 case EXEC_OMP_PARALLEL_WORKSHARE:
869 omp_clauses = c->ext.omp_clauses;
871 case EXEC_OMP_CRITICAL:
873 fprintf (dumpfile, " (%s)", c->ext.omp_name);
876 if (c->ext.omp_namelist)
878 fputs (" (", dumpfile);
879 show_namelist (c->ext.omp_namelist);
880 fputc (')', dumpfile);
883 case EXEC_OMP_BARRIER:
884 case EXEC_OMP_TASKWAIT:
893 if (omp_clauses->if_expr)
895 fputs (" IF(", dumpfile);
896 show_expr (omp_clauses->if_expr);
897 fputc (')', dumpfile);
899 if (omp_clauses->num_threads)
901 fputs (" NUM_THREADS(", dumpfile);
902 show_expr (omp_clauses->num_threads);
903 fputc (')', dumpfile);
905 if (omp_clauses->sched_kind != OMP_SCHED_NONE)
908 switch (omp_clauses->sched_kind)
910 case OMP_SCHED_STATIC: type = "STATIC"; break;
911 case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break;
912 case OMP_SCHED_GUIDED: type = "GUIDED"; break;
913 case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
914 case OMP_SCHED_AUTO: type = "AUTO"; break;
918 fprintf (dumpfile, " SCHEDULE (%s", type);
919 if (omp_clauses->chunk_size)
921 fputc (',', dumpfile);
922 show_expr (omp_clauses->chunk_size);
924 fputc (')', dumpfile);
926 if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
929 switch (omp_clauses->default_sharing)
931 case OMP_DEFAULT_NONE: type = "NONE"; break;
932 case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break;
933 case OMP_DEFAULT_SHARED: type = "SHARED"; break;
934 case OMP_DEFAULT_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
938 fprintf (dumpfile, " DEFAULT(%s)", type);
940 if (omp_clauses->ordered)
941 fputs (" ORDERED", dumpfile);
942 if (omp_clauses->untied)
943 fputs (" UNTIED", dumpfile);
944 if (omp_clauses->collapse)
945 fprintf (dumpfile, " COLLAPSE(%d)", omp_clauses->collapse);
946 for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
947 if (omp_clauses->lists[list_type] != NULL
948 && list_type != OMP_LIST_COPYPRIVATE)
951 if (list_type >= OMP_LIST_REDUCTION_FIRST)
955 case OMP_LIST_PLUS: type = "+"; break;
956 case OMP_LIST_MULT: type = "*"; break;
957 case OMP_LIST_SUB: type = "-"; break;
958 case OMP_LIST_AND: type = ".AND."; break;
959 case OMP_LIST_OR: type = ".OR."; break;
960 case OMP_LIST_EQV: type = ".EQV."; break;
961 case OMP_LIST_NEQV: type = ".NEQV."; break;
962 case OMP_LIST_MAX: type = "MAX"; break;
963 case OMP_LIST_MIN: type = "MIN"; break;
964 case OMP_LIST_IAND: type = "IAND"; break;
965 case OMP_LIST_IOR: type = "IOR"; break;
966 case OMP_LIST_IEOR: type = "IEOR"; break;
970 fprintf (dumpfile, " REDUCTION(%s:", type);
976 case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
977 case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
978 case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
979 case OMP_LIST_SHARED: type = "SHARED"; break;
980 case OMP_LIST_COPYIN: type = "COPYIN"; break;
984 fprintf (dumpfile, " %s(", type);
986 show_namelist (omp_clauses->lists[list_type]);
987 fputc (')', dumpfile);
990 fputc ('\n', dumpfile);
991 if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
993 gfc_code *d = c->block;
996 show_code (level + 1, d->next);
997 if (d->block == NULL)
999 code_indent (level, 0);
1000 fputs ("!$OMP SECTION\n", dumpfile);
1005 show_code (level + 1, c->block->next);
1006 if (c->op == EXEC_OMP_ATOMIC)
1008 code_indent (level, 0);
1009 fprintf (dumpfile, "!$OMP END %s", name);
1010 if (omp_clauses != NULL)
1012 if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
1014 fputs (" COPYPRIVATE(", dumpfile);
1015 show_namelist (omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
1016 fputc (')', dumpfile);
1018 else if (omp_clauses->nowait)
1019 fputs (" NOWAIT", dumpfile);
1021 else if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_name)
1022 fprintf (dumpfile, " (%s)", c->ext.omp_name);
1026 /* Show a single code node and everything underneath it if necessary. */
1029 show_code_node (int level, gfc_code *c)
1031 gfc_forall_iterator *fa;
1041 code_indent (level, c->here);
1046 fputs ("NOP", dumpfile);
1050 fputs ("CONTINUE", dumpfile);
1054 fprintf (dumpfile, "ENTRY %s", c->ext.entry->sym->name);
1057 case EXEC_INIT_ASSIGN:
1059 fputs ("ASSIGN ", dumpfile);
1060 show_expr (c->expr);
1061 fputc (' ', dumpfile);
1062 show_expr (c->expr2);
1065 case EXEC_LABEL_ASSIGN:
1066 fputs ("LABEL ASSIGN ", dumpfile);
1067 show_expr (c->expr);
1068 fprintf (dumpfile, " %d", c->label->value);
1071 case EXEC_POINTER_ASSIGN:
1072 fputs ("POINTER ASSIGN ", dumpfile);
1073 show_expr (c->expr);
1074 fputc (' ', dumpfile);
1075 show_expr (c->expr2);
1079 fputs ("GOTO ", dumpfile);
1081 fprintf (dumpfile, "%d", c->label->value);
1084 show_expr (c->expr);
1088 fputs (", (", dumpfile);
1089 for (; d; d = d ->block)
1091 code_indent (level, d->label);
1092 if (d->block != NULL)
1093 fputc (',', dumpfile);
1095 fputc (')', dumpfile);
1102 case EXEC_ASSIGN_CALL:
1103 if (c->resolved_sym)
1104 fprintf (dumpfile, "CALL %s ", c->resolved_sym->name);
1105 else if (c->symtree)
1106 fprintf (dumpfile, "CALL %s ", c->symtree->name);
1108 fputs ("CALL ?? ", dumpfile);
1110 show_actual_arglist (c->ext.actual);
1114 fputs ("RETURN ", dumpfile);
1116 show_expr (c->expr);
1120 fputs ("PAUSE ", dumpfile);
1122 if (c->expr != NULL)
1123 show_expr (c->expr);
1125 fprintf (dumpfile, "%d", c->ext.stop_code);
1130 fputs ("STOP ", dumpfile);
1132 if (c->expr != NULL)
1133 show_expr (c->expr);
1135 fprintf (dumpfile, "%d", c->ext.stop_code);
1139 case EXEC_ARITHMETIC_IF:
1140 fputs ("IF ", dumpfile);
1141 show_expr (c->expr);
1142 fprintf (dumpfile, " %d, %d, %d",
1143 c->label->value, c->label2->value, c->label3->value);
1148 fputs ("IF ", dumpfile);
1149 show_expr (d->expr);
1150 fputc ('\n', dumpfile);
1151 show_code (level + 1, d->next);
1154 for (; d; d = d->block)
1156 code_indent (level, 0);
1158 if (d->expr == NULL)
1159 fputs ("ELSE\n", dumpfile);
1162 fputs ("ELSE IF ", dumpfile);
1163 show_expr (d->expr);
1164 fputc ('\n', dumpfile);
1167 show_code (level + 1, d->next);
1170 code_indent (level, c->label);
1172 fputs ("ENDIF", dumpfile);
1177 fputs ("SELECT CASE ", dumpfile);
1178 show_expr (c->expr);
1179 fputc ('\n', dumpfile);
1181 for (; d; d = d->block)
1183 code_indent (level, 0);
1185 fputs ("CASE ", dumpfile);
1186 for (cp = d->ext.case_list; cp; cp = cp->next)
1188 fputc ('(', dumpfile);
1189 show_expr (cp->low);
1190 fputc (' ', dumpfile);
1191 show_expr (cp->high);
1192 fputc (')', dumpfile);
1193 fputc (' ', dumpfile);
1195 fputc ('\n', dumpfile);
1197 show_code (level + 1, d->next);
1200 code_indent (level, c->label);
1201 fputs ("END SELECT", dumpfile);
1205 fputs ("WHERE ", dumpfile);
1208 show_expr (d->expr);
1209 fputc ('\n', dumpfile);
1211 show_code (level + 1, d->next);
1213 for (d = d->block; d; d = d->block)
1215 code_indent (level, 0);
1216 fputs ("ELSE WHERE ", dumpfile);
1217 show_expr (d->expr);
1218 fputc ('\n', dumpfile);
1219 show_code (level + 1, d->next);
1222 code_indent (level, 0);
1223 fputs ("END WHERE", dumpfile);
1228 fputs ("FORALL ", dumpfile);
1229 for (fa = c->ext.forall_iterator; fa; fa = fa->next)
1231 show_expr (fa->var);
1232 fputc (' ', dumpfile);
1233 show_expr (fa->start);
1234 fputc (':', dumpfile);
1235 show_expr (fa->end);
1236 fputc (':', dumpfile);
1237 show_expr (fa->stride);
1239 if (fa->next != NULL)
1240 fputc (',', dumpfile);
1243 if (c->expr != NULL)
1245 fputc (',', dumpfile);
1246 show_expr (c->expr);
1248 fputc ('\n', dumpfile);
1250 show_code (level + 1, c->block->next);
1252 code_indent (level, 0);
1253 fputs ("END FORALL", dumpfile);
1257 fputs ("DO ", dumpfile);
1259 show_expr (c->ext.iterator->var);
1260 fputc ('=', dumpfile);
1261 show_expr (c->ext.iterator->start);
1262 fputc (' ', dumpfile);
1263 show_expr (c->ext.iterator->end);
1264 fputc (' ', dumpfile);
1265 show_expr (c->ext.iterator->step);
1266 fputc ('\n', dumpfile);
1268 show_code (level + 1, c->block->next);
1270 code_indent (level, 0);
1271 fputs ("END DO", dumpfile);
1275 fputs ("DO WHILE ", dumpfile);
1276 show_expr (c->expr);
1277 fputc ('\n', dumpfile);
1279 show_code (level + 1, c->block->next);
1281 code_indent (level, c->label);
1282 fputs ("END DO", dumpfile);
1286 fputs ("CYCLE", dumpfile);
1288 fprintf (dumpfile, " %s", c->symtree->n.sym->name);
1292 fputs ("EXIT", dumpfile);
1294 fprintf (dumpfile, " %s", c->symtree->n.sym->name);
1298 fputs ("ALLOCATE ", dumpfile);
1301 fputs (" STAT=", dumpfile);
1302 show_expr (c->expr);
1305 for (a = c->ext.alloc_list; a; a = a->next)
1307 fputc (' ', dumpfile);
1308 show_expr (a->expr);
1313 case EXEC_DEALLOCATE:
1314 fputs ("DEALLOCATE ", dumpfile);
1317 fputs (" STAT=", dumpfile);
1318 show_expr (c->expr);
1321 for (a = c->ext.alloc_list; a; a = a->next)
1323 fputc (' ', dumpfile);
1324 show_expr (a->expr);
1330 fputs ("OPEN", dumpfile);
1335 fputs (" UNIT=", dumpfile);
1336 show_expr (open->unit);
1340 fputs (" IOMSG=", dumpfile);
1341 show_expr (open->iomsg);
1345 fputs (" IOSTAT=", dumpfile);
1346 show_expr (open->iostat);
1350 fputs (" FILE=", dumpfile);
1351 show_expr (open->file);
1355 fputs (" STATUS=", dumpfile);
1356 show_expr (open->status);
1360 fputs (" ACCESS=", dumpfile);
1361 show_expr (open->access);
1365 fputs (" FORM=", dumpfile);
1366 show_expr (open->form);
1370 fputs (" RECL=", dumpfile);
1371 show_expr (open->recl);
1375 fputs (" BLANK=", dumpfile);
1376 show_expr (open->blank);
1380 fputs (" POSITION=", dumpfile);
1381 show_expr (open->position);
1385 fputs (" ACTION=", dumpfile);
1386 show_expr (open->action);
1390 fputs (" DELIM=", dumpfile);
1391 show_expr (open->delim);
1395 fputs (" PAD=", dumpfile);
1396 show_expr (open->pad);
1400 fputs (" DECIMAL=", dumpfile);
1401 show_expr (open->decimal);
1405 fputs (" ENCODING=", dumpfile);
1406 show_expr (open->encoding);
1410 fputs (" ROUND=", dumpfile);
1411 show_expr (open->round);
1415 fputs (" SIGN=", dumpfile);
1416 show_expr (open->sign);
1420 fputs (" CONVERT=", dumpfile);
1421 show_expr (open->convert);
1423 if (open->asynchronous)
1425 fputs (" ASYNCHRONOUS=", dumpfile);
1426 show_expr (open->asynchronous);
1428 if (open->err != NULL)
1429 fprintf (dumpfile, " ERR=%d", open->err->value);
1434 fputs ("CLOSE", dumpfile);
1435 close = c->ext.close;
1439 fputs (" UNIT=", dumpfile);
1440 show_expr (close->unit);
1444 fputs (" IOMSG=", dumpfile);
1445 show_expr (close->iomsg);
1449 fputs (" IOSTAT=", dumpfile);
1450 show_expr (close->iostat);
1454 fputs (" STATUS=", dumpfile);
1455 show_expr (close->status);
1457 if (close->err != NULL)
1458 fprintf (dumpfile, " ERR=%d", close->err->value);
1461 case EXEC_BACKSPACE:
1462 fputs ("BACKSPACE", dumpfile);
1466 fputs ("ENDFILE", dumpfile);
1470 fputs ("REWIND", dumpfile);
1474 fputs ("FLUSH", dumpfile);
1477 fp = c->ext.filepos;
1481 fputs (" UNIT=", dumpfile);
1482 show_expr (fp->unit);
1486 fputs (" IOMSG=", dumpfile);
1487 show_expr (fp->iomsg);
1491 fputs (" IOSTAT=", dumpfile);
1492 show_expr (fp->iostat);
1494 if (fp->err != NULL)
1495 fprintf (dumpfile, " ERR=%d", fp->err->value);
1499 fputs ("INQUIRE", dumpfile);
1504 fputs (" UNIT=", dumpfile);
1505 show_expr (i->unit);
1509 fputs (" FILE=", dumpfile);
1510 show_expr (i->file);
1515 fputs (" IOMSG=", dumpfile);
1516 show_expr (i->iomsg);
1520 fputs (" IOSTAT=", dumpfile);
1521 show_expr (i->iostat);
1525 fputs (" EXIST=", dumpfile);
1526 show_expr (i->exist);
1530 fputs (" OPENED=", dumpfile);
1531 show_expr (i->opened);
1535 fputs (" NUMBER=", dumpfile);
1536 show_expr (i->number);
1540 fputs (" NAMED=", dumpfile);
1541 show_expr (i->named);
1545 fputs (" NAME=", dumpfile);
1546 show_expr (i->name);
1550 fputs (" ACCESS=", dumpfile);
1551 show_expr (i->access);
1555 fputs (" SEQUENTIAL=", dumpfile);
1556 show_expr (i->sequential);
1561 fputs (" DIRECT=", dumpfile);
1562 show_expr (i->direct);
1566 fputs (" FORM=", dumpfile);
1567 show_expr (i->form);
1571 fputs (" FORMATTED", dumpfile);
1572 show_expr (i->formatted);
1576 fputs (" UNFORMATTED=", dumpfile);
1577 show_expr (i->unformatted);
1581 fputs (" RECL=", dumpfile);
1582 show_expr (i->recl);
1586 fputs (" NEXTREC=", dumpfile);
1587 show_expr (i->nextrec);
1591 fputs (" BLANK=", dumpfile);
1592 show_expr (i->blank);
1596 fputs (" POSITION=", dumpfile);
1597 show_expr (i->position);
1601 fputs (" ACTION=", dumpfile);
1602 show_expr (i->action);
1606 fputs (" READ=", dumpfile);
1607 show_expr (i->read);
1611 fputs (" WRITE=", dumpfile);
1612 show_expr (i->write);
1616 fputs (" READWRITE=", dumpfile);
1617 show_expr (i->readwrite);
1621 fputs (" DELIM=", dumpfile);
1622 show_expr (i->delim);
1626 fputs (" PAD=", dumpfile);
1631 fputs (" CONVERT=", dumpfile);
1632 show_expr (i->convert);
1634 if (i->asynchronous)
1636 fputs (" ASYNCHRONOUS=", dumpfile);
1637 show_expr (i->asynchronous);
1641 fputs (" DECIMAL=", dumpfile);
1642 show_expr (i->decimal);
1646 fputs (" ENCODING=", dumpfile);
1647 show_expr (i->encoding);
1651 fputs (" PENDING=", dumpfile);
1652 show_expr (i->pending);
1656 fputs (" ROUND=", dumpfile);
1657 show_expr (i->round);
1661 fputs (" SIGN=", dumpfile);
1662 show_expr (i->sign);
1666 fputs (" SIZE=", dumpfile);
1667 show_expr (i->size);
1671 fputs (" ID=", dumpfile);
1676 fprintf (dumpfile, " ERR=%d", i->err->value);
1680 fputs ("IOLENGTH ", dumpfile);
1681 show_expr (c->expr);
1686 fputs ("READ", dumpfile);
1690 fputs ("WRITE", dumpfile);
1696 fputs (" UNIT=", dumpfile);
1697 show_expr (dt->io_unit);
1700 if (dt->format_expr)
1702 fputs (" FMT=", dumpfile);
1703 show_expr (dt->format_expr);
1706 if (dt->format_label != NULL)
1707 fprintf (dumpfile, " FMT=%d", dt->format_label->value);
1709 fprintf (dumpfile, " NML=%s", dt->namelist->name);
1713 fputs (" IOMSG=", dumpfile);
1714 show_expr (dt->iomsg);
1718 fputs (" IOSTAT=", dumpfile);
1719 show_expr (dt->iostat);
1723 fputs (" SIZE=", dumpfile);
1724 show_expr (dt->size);
1728 fputs (" REC=", dumpfile);
1729 show_expr (dt->rec);
1733 fputs (" ADVANCE=", dumpfile);
1734 show_expr (dt->advance);
1738 fputs (" ID=", dumpfile);
1743 fputs (" POS=", dumpfile);
1744 show_expr (dt->pos);
1746 if (dt->asynchronous)
1748 fputs (" ASYNCHRONOUS=", dumpfile);
1749 show_expr (dt->asynchronous);
1753 fputs (" BLANK=", dumpfile);
1754 show_expr (dt->blank);
1758 fputs (" DECIMAL=", dumpfile);
1759 show_expr (dt->decimal);
1763 fputs (" DELIM=", dumpfile);
1764 show_expr (dt->delim);
1768 fputs (" PAD=", dumpfile);
1769 show_expr (dt->pad);
1773 fputs (" ROUND=", dumpfile);
1774 show_expr (dt->round);
1778 fputs (" SIGN=", dumpfile);
1779 show_expr (dt->sign);
1783 fputc ('\n', dumpfile);
1784 for (c = c->block->next; c; c = c->next)
1785 show_code_node (level + (c->next != NULL), c);
1789 fputs ("TRANSFER ", dumpfile);
1790 show_expr (c->expr);
1794 fputs ("DT_END", dumpfile);
1797 if (dt->err != NULL)
1798 fprintf (dumpfile, " ERR=%d", dt->err->value);
1799 if (dt->end != NULL)
1800 fprintf (dumpfile, " END=%d", dt->end->value);
1801 if (dt->eor != NULL)
1802 fprintf (dumpfile, " EOR=%d", dt->eor->value);
1805 case EXEC_OMP_ATOMIC:
1806 case EXEC_OMP_BARRIER:
1807 case EXEC_OMP_CRITICAL:
1808 case EXEC_OMP_FLUSH:
1810 case EXEC_OMP_MASTER:
1811 case EXEC_OMP_ORDERED:
1812 case EXEC_OMP_PARALLEL:
1813 case EXEC_OMP_PARALLEL_DO:
1814 case EXEC_OMP_PARALLEL_SECTIONS:
1815 case EXEC_OMP_PARALLEL_WORKSHARE:
1816 case EXEC_OMP_SECTIONS:
1817 case EXEC_OMP_SINGLE:
1819 case EXEC_OMP_TASKWAIT:
1820 case EXEC_OMP_WORKSHARE:
1821 show_omp_node (level, c);
1825 gfc_internal_error ("show_code_node(): Bad statement code");
1828 fputc ('\n', dumpfile);
1832 /* Show an equivalence chain. */
1835 show_equiv (gfc_equiv *eq)
1838 fputs ("Equivalence: ", dumpfile);
1841 show_expr (eq->expr);
1844 fputs (", ", dumpfile);
1849 /* Show a freakin' whole namespace. */
1852 show_namespace (gfc_namespace *ns)
1854 gfc_interface *intr;
1855 gfc_namespace *save;
1856 gfc_intrinsic_op op;
1860 save = gfc_current_ns;
1864 fputs ("Namespace:", dumpfile);
1872 while (i < GFC_LETTERS - 1
1873 && gfc_compare_types(&ns->default_type[i+1],
1874 &ns->default_type[l]))
1878 fprintf (dumpfile, " %c-%c: ", l+'A', i+'A');
1880 fprintf (dumpfile, " %c: ", l+'A');
1882 show_typespec(&ns->default_type[l]);
1884 } while (i < GFC_LETTERS);
1886 if (ns->proc_name != NULL)
1889 fprintf (dumpfile, "procedure name = %s", ns->proc_name->name);
1892 gfc_current_ns = ns;
1893 gfc_traverse_symtree (ns->common_root, show_common);
1895 gfc_traverse_symtree (ns->sym_root, show_symtree);
1897 for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
1899 /* User operator interfaces */
1905 fprintf (dumpfile, "Operator interfaces for %s:",
1906 gfc_op2string (op));
1908 for (; intr; intr = intr->next)
1909 fprintf (dumpfile, " %s", intr->sym->name);
1912 if (ns->uop_root != NULL)
1915 fputs ("User operators:\n", dumpfile);
1916 gfc_traverse_user_op (ns, show_uop);
1920 for (eq = ns->equiv; eq; eq = eq->next)
1923 fputc ('\n', dumpfile);
1924 fputc ('\n', dumpfile);
1926 show_code (0, ns->code);
1928 for (ns = ns->contained; ns; ns = ns->sibling)
1931 fputs ("CONTAINS\n", dumpfile);
1932 show_namespace (ns);
1936 fputc ('\n', dumpfile);
1937 gfc_current_ns = save;
1941 /* Main function for dumping a parse tree. */
1944 gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
1947 show_namespace (ns);