2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / fortran / dump-parse-tree.c
blob44a4941e7b422f2bf49f1bf5e2f62dfb1ba23fbf
1 /* Parse tree dumper
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
11 version.
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
16 for more details.
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
30 relatives.
32 TODO: Dump DATA. */
34 #include "config.h"
35 #include "gfortran.h"
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. */
52 static inline void
53 code_indent (int level, gfc_st_label *label)
55 int i;
57 if (label != NULL)
58 fprintf (dumpfile, "%-5d ", label->value);
59 else
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. */
70 static inline void
71 show_indent (void)
73 fputc ('\n', dumpfile);
74 code_indent (show_level, NULL);
78 /* Show type-specific information. */
80 static void
81 show_typespec (gfc_typespec *ts)
83 fprintf (dumpfile, "(%s ", gfc_basic_typename (ts->type));
85 switch (ts->type)
87 case BT_DERIVED:
88 fprintf (dumpfile, "%s", ts->derived->name);
89 break;
91 case BT_CHARACTER:
92 show_expr (ts->cl->length);
93 break;
95 default:
96 fprintf (dumpfile, "%d", ts->kind);
97 break;
100 fputc (')', dumpfile);
104 /* Show an actual argument list. */
106 static void
107 show_actual_arglist (gfc_actual_arglist *a)
109 fputc ('(', dumpfile);
111 for (; a; a = a->next)
113 fputc ('(', dumpfile);
114 if (a->name != NULL)
115 fprintf (dumpfile, "%s = ", a->name);
116 if (a->expr != NULL)
117 show_expr (a->expr);
118 else
119 fputs ("(arg not-present)", dumpfile);
121 fputc (')', dumpfile);
122 if (a->next != NULL)
123 fputc (' ', dumpfile);
126 fputc (')', dumpfile);
130 /* Show a gfc_array_spec array specification structure. */
132 static void
133 show_array_spec (gfc_array_spec *as)
135 const char *c;
136 int i;
138 if (as == NULL)
140 fputs ("()", dumpfile);
141 return;
144 fprintf (dumpfile, "(%d", as->rank);
146 if (as->rank != 0)
148 switch (as->type)
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;
154 default:
155 gfc_internal_error ("show_array_spec(): Unhandled array shape "
156 "type.");
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. */
175 static void
176 show_array_ref (gfc_array_ref * ar)
178 int i;
180 fputc ('(', dumpfile);
182 switch (ar->type)
184 case AR_FULL:
185 fputs ("FULL", dumpfile);
186 break;
188 case AR_SECTION:
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);
218 break;
220 case AR_ELEMENT:
221 for (i = 0; i < ar->dimen; i++)
223 show_expr (ar->start[i]);
224 if (i != ar->dimen - 1)
225 fputs (" , ", dumpfile);
227 break;
229 case AR_UNKNOWN:
230 fputs ("UNKNOWN", dumpfile);
231 break;
233 default:
234 gfc_internal_error ("show_array_ref(): Unknown array reference");
237 fputc (')', dumpfile);
241 /* Show a list of gfc_ref structures. */
243 static void
244 show_ref (gfc_ref *p)
246 for (; p; p = p->next)
247 switch (p->type)
249 case REF_ARRAY:
250 show_array_ref (&p->u.ar);
251 break;
253 case REF_COMPONENT:
254 fprintf (dumpfile, " %% %s", p->u.c.component->name);
255 break;
257 case REF_SUBSTRING:
258 fputc ('(', dumpfile);
259 show_expr (p->u.ss.start);
260 fputc (':', dumpfile);
261 show_expr (p->u.ss.end);
262 fputc (')', dumpfile);
263 break;
265 default:
266 gfc_internal_error ("show_ref(): Bad component code");
271 /* Display a constructor. Works recursively for array constructors. */
273 static void
274 show_constructor (gfc_constructor *c)
276 for (; c; c = c->next)
278 if (c->iterator == NULL)
279 show_expr (c->expr);
280 else
282 fputc ('(', dumpfile);
283 show_expr (c->expr);
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);
297 if (c->next != NULL)
298 fputs (" , ", dumpfile);
303 static void
304 show_char_const (const gfc_char_t *c, int length)
306 int i;
308 fputc ('\'', dumpfile);
309 for (i = 0; i < length; i++)
311 if (c[i] == '\'')
312 fputs ("''", dumpfile);
313 else
314 fputs (gfc_print_wide_char (c[i]), dumpfile);
316 fputc ('\'', dumpfile);
319 /* Show an expression. */
321 static void
322 show_expr (gfc_expr *p)
324 const char *c;
325 int i;
327 if (p == NULL)
329 fputs ("()", dumpfile);
330 return;
333 switch (p->expr_type)
335 case EXPR_SUBSTRING:
336 show_char_const (p->value.character.string, p->value.character.length);
337 show_ref (p->ref);
338 break;
340 case EXPR_STRUCTURE:
341 fprintf (dumpfile, "%s(", p->ts.derived->name);
342 show_constructor (p->value.constructor);
343 fputc (')', dumpfile);
344 break;
346 case EXPR_ARRAY:
347 fputs ("(/ ", dumpfile);
348 show_constructor (p->value.constructor);
349 fputs (" /)", dumpfile);
351 show_ref (p->ref);
352 break;
354 case EXPR_NULL:
355 fputs ("NULL()", dumpfile);
356 break;
358 case EXPR_CONSTANT:
359 switch (p->ts.type)
361 case BT_INTEGER:
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);
366 break;
368 case BT_LOGICAL:
369 if (p->value.logical)
370 fputs (".true.", dumpfile);
371 else
372 fputs (".false.", dumpfile);
373 break;
375 case BT_REAL:
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);
379 break;
381 case BT_CHARACTER:
382 show_char_const (p->value.character.string,
383 p->value.character.length);
384 break;
386 case BT_COMPLEX:
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);
400 break;
402 case BT_HOLLERITH:
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);
409 break;
411 default:
412 fputs ("???", dumpfile);
413 break;
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);
429 break;
431 case EXPR_VARIABLE:
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);
435 show_ref (p->ref);
436 break;
438 case EXPR_OP:
439 fputc ('(', dumpfile);
440 switch (p->value.op.operator)
442 case INTRINSIC_UPLUS:
443 fputs ("U+ ", dumpfile);
444 break;
445 case INTRINSIC_UMINUS:
446 fputs ("U- ", dumpfile);
447 break;
448 case INTRINSIC_PLUS:
449 fputs ("+ ", dumpfile);
450 break;
451 case INTRINSIC_MINUS:
452 fputs ("- ", dumpfile);
453 break;
454 case INTRINSIC_TIMES:
455 fputs ("* ", dumpfile);
456 break;
457 case INTRINSIC_DIVIDE:
458 fputs ("/ ", dumpfile);
459 break;
460 case INTRINSIC_POWER:
461 fputs ("** ", dumpfile);
462 break;
463 case INTRINSIC_CONCAT:
464 fputs ("// ", dumpfile);
465 break;
466 case INTRINSIC_AND:
467 fputs ("AND ", dumpfile);
468 break;
469 case INTRINSIC_OR:
470 fputs ("OR ", dumpfile);
471 break;
472 case INTRINSIC_EQV:
473 fputs ("EQV ", dumpfile);
474 break;
475 case INTRINSIC_NEQV:
476 fputs ("NEQV ", dumpfile);
477 break;
478 case INTRINSIC_EQ:
479 case INTRINSIC_EQ_OS:
480 fputs ("= ", dumpfile);
481 break;
482 case INTRINSIC_NE:
483 case INTRINSIC_NE_OS:
484 fputs ("/= ", dumpfile);
485 break;
486 case INTRINSIC_GT:
487 case INTRINSIC_GT_OS:
488 fputs ("> ", dumpfile);
489 break;
490 case INTRINSIC_GE:
491 case INTRINSIC_GE_OS:
492 fputs (">= ", dumpfile);
493 break;
494 case INTRINSIC_LT:
495 case INTRINSIC_LT_OS:
496 fputs ("< ", dumpfile);
497 break;
498 case INTRINSIC_LE:
499 case INTRINSIC_LE_OS:
500 fputs ("<= ", dumpfile);
501 break;
502 case INTRINSIC_NOT:
503 fputs ("NOT ", dumpfile);
504 break;
505 case INTRINSIC_PARENTHESES:
506 fputs ("parens", dumpfile);
507 break;
509 default:
510 gfc_internal_error
511 ("show_expr(): Bad intrinsic in expression!");
514 show_expr (p->value.op.op1);
516 if (p->value.op.op2)
518 fputc (' ', dumpfile);
519 show_expr (p->value.op.op2);
522 fputc (')', dumpfile);
523 break;
525 case EXPR_FUNCTION:
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);
532 else
534 fprintf (dumpfile, "%s[[", p->value.function.name);
535 show_actual_arglist (p->value.function.actual);
536 fputc (']', dumpfile);
537 fputc (']', dumpfile);
540 break;
542 default:
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. */
550 static void
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);
563 if (attr->dimension)
564 fputs (" DIMENSION", dumpfile);
565 if (attr->external)
566 fputs (" EXTERNAL", dumpfile);
567 if (attr->intrinsic)
568 fputs (" INTRINSIC", dumpfile);
569 if (attr->optional)
570 fputs (" OPTIONAL", dumpfile);
571 if (attr->pointer)
572 fputs (" POINTER", dumpfile);
573 if (attr->protected)
574 fputs (" PROTECTED", dumpfile);
575 if (attr->value)
576 fputs (" VALUE", dumpfile);
577 if (attr->volatile_)
578 fputs (" VOLATILE", dumpfile);
579 if (attr->threadprivate)
580 fputs (" THREADPRIVATE", dumpfile);
581 if (attr->target)
582 fputs (" TARGET", dumpfile);
583 if (attr->dummy)
584 fputs (" DUMMY", dumpfile);
585 if (attr->result)
586 fputs (" RESULT", dumpfile);
587 if (attr->entry)
588 fputs (" ENTRY", dumpfile);
589 if (attr->is_bind_c)
590 fputs (" BIND(C)", dumpfile);
592 if (attr->data)
593 fputs (" DATA", dumpfile);
594 if (attr->use_assoc)
595 fputs (" USE-ASSOC", dumpfile);
596 if (attr->in_namelist)
597 fputs (" IN-NAMELIST", dumpfile);
598 if (attr->in_common)
599 fputs (" IN-COMMON", dumpfile);
601 if (attr->abstract)
602 fputs (" ABSTRACT INTERFACE", dumpfile);
603 if (attr->function)
604 fputs (" FUNCTION", dumpfile);
605 if (attr->subroutine)
606 fputs (" SUBROUTINE", dumpfile);
607 if (attr->implicit_type)
608 fputs (" IMPLICIT-TYPE", dumpfile);
610 if (attr->sequence)
611 fputs (" SEQUENCE", dumpfile);
612 if (attr->elemental)
613 fputs (" ELEMENTAL", dumpfile);
614 if (attr->pure)
615 fputs (" PURE", dumpfile);
616 if (attr->recursive)
617 fputs (" RECURSIVE", dumpfile);
619 fputc (')', dumpfile);
623 /* Show components of a derived type. */
625 static void
626 show_components (gfc_symbol *sym)
628 gfc_component *c;
630 for (c = sym->components; c; c = c->next)
632 fprintf (dumpfile, "(%s ", c->name);
633 show_typespec (&c->ts);
634 if (c->pointer)
635 fputs (" POINTER", dumpfile);
636 if (c->dimension)
637 fputs (" DIMENSION", dumpfile);
638 fputc (' ', dumpfile);
639 show_array_spec (c->as);
640 if (c->access)
641 fprintf (dumpfile, " %s", gfc_code2string (access_types, c->access));
642 fputc (')', dumpfile);
643 if (c->next != NULL)
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
652 that symbol. */
654 static void
655 show_symbol (gfc_symbol *sym)
657 gfc_formal_arglist *formal;
658 gfc_interface *intr;
660 if (sym == NULL)
661 return;
663 show_indent ();
665 fprintf (dumpfile, "symbol %s ", sym->name);
666 show_typespec (&sym->ts);
667 show_attr (&sym->attr);
669 if (sym->value)
671 show_indent ();
672 fputs ("value: ", dumpfile);
673 show_expr (sym->value);
676 if (sym->as)
678 show_indent ();
679 fputs ("Array spec:", dumpfile);
680 show_array_spec (sym->as);
683 if (sym->generic)
685 show_indent ();
686 fputs ("Generic interfaces:", dumpfile);
687 for (intr = sym->generic; intr; intr = intr->next)
688 fprintf (dumpfile, " %s", intr->sym->name);
691 if (sym->result)
693 show_indent ();
694 fprintf (dumpfile, "result: %s", sym->result->name);
697 if (sym->components)
699 show_indent ();
700 fputs ("components: ", dumpfile);
701 show_components (sym);
704 if (sym->formal)
706 show_indent ();
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);
713 else
714 fputs (" [Alt Return]", dumpfile);
718 if (sym->formal_ns)
720 show_indent ();
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. */
732 static void
733 show_uop (gfc_user_op *uop)
735 gfc_interface *intr;
737 show_indent ();
738 fprintf (dumpfile, "%s:", uop->name);
740 for (intr = uop->operator; intr; intr = intr->next)
741 fprintf (dumpfile, " %s", intr->sym->name);
745 /* Workhorse function for traversing the user operator symtree. */
747 static void
748 traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *))
750 if (st == NULL)
751 return;
753 (*func) (st->n.uop);
755 traverse_uop (st->left, func);
756 traverse_uop (st->right, func);
760 /* Traverse the tree of user operator nodes. */
762 void
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. */
771 static void
772 show_common (gfc_symtree *st)
774 gfc_symbol *s;
776 show_indent ();
777 fprintf (dumpfile, "common: /%s/ ", st->name);
779 s = st->n.common->head;
780 while (s)
782 fprintf (dumpfile, "%s", s->name);
783 s = s->common_next;
784 if (s)
785 fputs (", ", dumpfile);
787 fputc ('\n', dumpfile);
791 /* Worker function to display the symbol tree. */
793 static void
794 show_symtree (gfc_symtree *st)
796 show_indent ();
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);
801 else
802 show_symbol (st->n.sym);
806 /******************* Show gfc_code structures **************/
809 /* Show a list of code structures. Mutually recursive with
810 show_code_node(). */
812 static void
813 show_code (int level, gfc_code *c)
815 for (; c; c = c->next)
816 show_code_node (level, c);
819 static void
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
828 if necessary. */
830 static void
831 show_omp_node (int level, gfc_code *c)
833 gfc_omp_clauses *omp_clauses = NULL;
834 const char *name = NULL;
836 switch (c->op)
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_WORKSHARE: name = "WORKSHARE"; break;
852 default:
853 gcc_unreachable ();
855 fprintf (dumpfile, "!$OMP %s", name);
856 switch (c->op)
858 case EXEC_OMP_DO:
859 case EXEC_OMP_PARALLEL:
860 case EXEC_OMP_PARALLEL_DO:
861 case EXEC_OMP_PARALLEL_SECTIONS:
862 case EXEC_OMP_SECTIONS:
863 case EXEC_OMP_SINGLE:
864 case EXEC_OMP_WORKSHARE:
865 case EXEC_OMP_PARALLEL_WORKSHARE:
866 omp_clauses = c->ext.omp_clauses;
867 break;
868 case EXEC_OMP_CRITICAL:
869 if (c->ext.omp_name)
870 fprintf (dumpfile, " (%s)", c->ext.omp_name);
871 break;
872 case EXEC_OMP_FLUSH:
873 if (c->ext.omp_namelist)
875 fputs (" (", dumpfile);
876 show_namelist (c->ext.omp_namelist);
877 fputc (')', dumpfile);
879 return;
880 case EXEC_OMP_BARRIER:
881 return;
882 default:
883 break;
885 if (omp_clauses)
887 int list_type;
889 if (omp_clauses->if_expr)
891 fputs (" IF(", dumpfile);
892 show_expr (omp_clauses->if_expr);
893 fputc (')', dumpfile);
895 if (omp_clauses->num_threads)
897 fputs (" NUM_THREADS(", dumpfile);
898 show_expr (omp_clauses->num_threads);
899 fputc (')', dumpfile);
901 if (omp_clauses->sched_kind != OMP_SCHED_NONE)
903 const char *type;
904 switch (omp_clauses->sched_kind)
906 case OMP_SCHED_STATIC: type = "STATIC"; break;
907 case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break;
908 case OMP_SCHED_GUIDED: type = "GUIDED"; break;
909 case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
910 default:
911 gcc_unreachable ();
913 fprintf (dumpfile, " SCHEDULE (%s", type);
914 if (omp_clauses->chunk_size)
916 fputc (',', dumpfile);
917 show_expr (omp_clauses->chunk_size);
919 fputc (')', dumpfile);
921 if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
923 const char *type;
924 switch (omp_clauses->default_sharing)
926 case OMP_DEFAULT_NONE: type = "NONE"; break;
927 case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break;
928 case OMP_DEFAULT_SHARED: type = "SHARED"; break;
929 case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
930 default:
931 gcc_unreachable ();
933 fprintf (dumpfile, " DEFAULT(%s)", type);
935 if (omp_clauses->ordered)
936 fputs (" ORDERED", dumpfile);
937 for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
938 if (omp_clauses->lists[list_type] != NULL
939 && list_type != OMP_LIST_COPYPRIVATE)
941 const char *type;
942 if (list_type >= OMP_LIST_REDUCTION_FIRST)
944 switch (list_type)
946 case OMP_LIST_PLUS: type = "+"; break;
947 case OMP_LIST_MULT: type = "*"; break;
948 case OMP_LIST_SUB: type = "-"; break;
949 case OMP_LIST_AND: type = ".AND."; break;
950 case OMP_LIST_OR: type = ".OR."; break;
951 case OMP_LIST_EQV: type = ".EQV."; break;
952 case OMP_LIST_NEQV: type = ".NEQV."; break;
953 case OMP_LIST_MAX: type = "MAX"; break;
954 case OMP_LIST_MIN: type = "MIN"; break;
955 case OMP_LIST_IAND: type = "IAND"; break;
956 case OMP_LIST_IOR: type = "IOR"; break;
957 case OMP_LIST_IEOR: type = "IEOR"; break;
958 default:
959 gcc_unreachable ();
961 fprintf (dumpfile, " REDUCTION(%s:", type);
963 else
965 switch (list_type)
967 case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
968 case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
969 case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
970 case OMP_LIST_SHARED: type = "SHARED"; break;
971 case OMP_LIST_COPYIN: type = "COPYIN"; break;
972 default:
973 gcc_unreachable ();
975 fprintf (dumpfile, " %s(", type);
977 show_namelist (omp_clauses->lists[list_type]);
978 fputc (')', dumpfile);
981 fputc ('\n', dumpfile);
982 if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
984 gfc_code *d = c->block;
985 while (d != NULL)
987 show_code (level + 1, d->next);
988 if (d->block == NULL)
989 break;
990 code_indent (level, 0);
991 fputs ("!$OMP SECTION\n", dumpfile);
992 d = d->block;
995 else
996 show_code (level + 1, c->block->next);
997 if (c->op == EXEC_OMP_ATOMIC)
998 return;
999 code_indent (level, 0);
1000 fprintf (dumpfile, "!$OMP END %s", name);
1001 if (omp_clauses != NULL)
1003 if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
1005 fputs (" COPYPRIVATE(", dumpfile);
1006 show_namelist (omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
1007 fputc (')', dumpfile);
1009 else if (omp_clauses->nowait)
1010 fputs (" NOWAIT", dumpfile);
1012 else if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_name)
1013 fprintf (dumpfile, " (%s)", c->ext.omp_name);
1017 /* Show a single code node and everything underneath it if necessary. */
1019 static void
1020 show_code_node (int level, gfc_code *c)
1022 gfc_forall_iterator *fa;
1023 gfc_open *open;
1024 gfc_case *cp;
1025 gfc_alloc *a;
1026 gfc_code *d;
1027 gfc_close *close;
1028 gfc_filepos *fp;
1029 gfc_inquire *i;
1030 gfc_dt *dt;
1032 code_indent (level, c->here);
1034 switch (c->op)
1036 case EXEC_NOP:
1037 fputs ("NOP", dumpfile);
1038 break;
1040 case EXEC_CONTINUE:
1041 fputs ("CONTINUE", dumpfile);
1042 break;
1044 case EXEC_ENTRY:
1045 fprintf (dumpfile, "ENTRY %s", c->ext.entry->sym->name);
1046 break;
1048 case EXEC_INIT_ASSIGN:
1049 case EXEC_ASSIGN:
1050 fputs ("ASSIGN ", dumpfile);
1051 show_expr (c->expr);
1052 fputc (' ', dumpfile);
1053 show_expr (c->expr2);
1054 break;
1056 case EXEC_LABEL_ASSIGN:
1057 fputs ("LABEL ASSIGN ", dumpfile);
1058 show_expr (c->expr);
1059 fprintf (dumpfile, " %d", c->label->value);
1060 break;
1062 case EXEC_POINTER_ASSIGN:
1063 fputs ("POINTER ASSIGN ", dumpfile);
1064 show_expr (c->expr);
1065 fputc (' ', dumpfile);
1066 show_expr (c->expr2);
1067 break;
1069 case EXEC_GOTO:
1070 fputs ("GOTO ", dumpfile);
1071 if (c->label)
1072 fprintf (dumpfile, "%d", c->label->value);
1073 else
1075 show_expr (c->expr);
1076 d = c->block;
1077 if (d != NULL)
1079 fputs (", (", dumpfile);
1080 for (; d; d = d ->block)
1082 code_indent (level, d->label);
1083 if (d->block != NULL)
1084 fputc (',', dumpfile);
1085 else
1086 fputc (')', dumpfile);
1090 break;
1092 case EXEC_CALL:
1093 case EXEC_ASSIGN_CALL:
1094 if (c->resolved_sym)
1095 fprintf (dumpfile, "CALL %s ", c->resolved_sym->name);
1096 else if (c->symtree)
1097 fprintf (dumpfile, "CALL %s ", c->symtree->name);
1098 else
1099 fputs ("CALL ?? ", dumpfile);
1101 show_actual_arglist (c->ext.actual);
1102 break;
1104 case EXEC_RETURN:
1105 fputs ("RETURN ", dumpfile);
1106 if (c->expr)
1107 show_expr (c->expr);
1108 break;
1110 case EXEC_PAUSE:
1111 fputs ("PAUSE ", dumpfile);
1113 if (c->expr != NULL)
1114 show_expr (c->expr);
1115 else
1116 fprintf (dumpfile, "%d", c->ext.stop_code);
1118 break;
1120 case EXEC_STOP:
1121 fputs ("STOP ", dumpfile);
1123 if (c->expr != NULL)
1124 show_expr (c->expr);
1125 else
1126 fprintf (dumpfile, "%d", c->ext.stop_code);
1128 break;
1130 case EXEC_ARITHMETIC_IF:
1131 fputs ("IF ", dumpfile);
1132 show_expr (c->expr);
1133 fprintf (dumpfile, " %d, %d, %d",
1134 c->label->value, c->label2->value, c->label3->value);
1135 break;
1137 case EXEC_IF:
1138 d = c->block;
1139 fputs ("IF ", dumpfile);
1140 show_expr (d->expr);
1141 fputc ('\n', dumpfile);
1142 show_code (level + 1, d->next);
1144 d = d->block;
1145 for (; d; d = d->block)
1147 code_indent (level, 0);
1149 if (d->expr == NULL)
1150 fputs ("ELSE\n", dumpfile);
1151 else
1153 fputs ("ELSE IF ", dumpfile);
1154 show_expr (d->expr);
1155 fputc ('\n', dumpfile);
1158 show_code (level + 1, d->next);
1161 code_indent (level, c->label);
1163 fputs ("ENDIF", dumpfile);
1164 break;
1166 case EXEC_SELECT:
1167 d = c->block;
1168 fputs ("SELECT CASE ", dumpfile);
1169 show_expr (c->expr);
1170 fputc ('\n', dumpfile);
1172 for (; d; d = d->block)
1174 code_indent (level, 0);
1176 fputs ("CASE ", dumpfile);
1177 for (cp = d->ext.case_list; cp; cp = cp->next)
1179 fputc ('(', dumpfile);
1180 show_expr (cp->low);
1181 fputc (' ', dumpfile);
1182 show_expr (cp->high);
1183 fputc (')', dumpfile);
1184 fputc (' ', dumpfile);
1186 fputc ('\n', dumpfile);
1188 show_code (level + 1, d->next);
1191 code_indent (level, c->label);
1192 fputs ("END SELECT", dumpfile);
1193 break;
1195 case EXEC_WHERE:
1196 fputs ("WHERE ", dumpfile);
1198 d = c->block;
1199 show_expr (d->expr);
1200 fputc ('\n', dumpfile);
1202 show_code (level + 1, d->next);
1204 for (d = d->block; d; d = d->block)
1206 code_indent (level, 0);
1207 fputs ("ELSE WHERE ", dumpfile);
1208 show_expr (d->expr);
1209 fputc ('\n', dumpfile);
1210 show_code (level + 1, d->next);
1213 code_indent (level, 0);
1214 fputs ("END WHERE", dumpfile);
1215 break;
1218 case EXEC_FORALL:
1219 fputs ("FORALL ", dumpfile);
1220 for (fa = c->ext.forall_iterator; fa; fa = fa->next)
1222 show_expr (fa->var);
1223 fputc (' ', dumpfile);
1224 show_expr (fa->start);
1225 fputc (':', dumpfile);
1226 show_expr (fa->end);
1227 fputc (':', dumpfile);
1228 show_expr (fa->stride);
1230 if (fa->next != NULL)
1231 fputc (',', dumpfile);
1234 if (c->expr != NULL)
1236 fputc (',', dumpfile);
1237 show_expr (c->expr);
1239 fputc ('\n', dumpfile);
1241 show_code (level + 1, c->block->next);
1243 code_indent (level, 0);
1244 fputs ("END FORALL", dumpfile);
1245 break;
1247 case EXEC_DO:
1248 fputs ("DO ", dumpfile);
1250 show_expr (c->ext.iterator->var);
1251 fputc ('=', dumpfile);
1252 show_expr (c->ext.iterator->start);
1253 fputc (' ', dumpfile);
1254 show_expr (c->ext.iterator->end);
1255 fputc (' ', dumpfile);
1256 show_expr (c->ext.iterator->step);
1257 fputc ('\n', dumpfile);
1259 show_code (level + 1, c->block->next);
1261 code_indent (level, 0);
1262 fputs ("END DO", dumpfile);
1263 break;
1265 case EXEC_DO_WHILE:
1266 fputs ("DO WHILE ", dumpfile);
1267 show_expr (c->expr);
1268 fputc ('\n', dumpfile);
1270 show_code (level + 1, c->block->next);
1272 code_indent (level, c->label);
1273 fputs ("END DO", dumpfile);
1274 break;
1276 case EXEC_CYCLE:
1277 fputs ("CYCLE", dumpfile);
1278 if (c->symtree)
1279 fprintf (dumpfile, " %s", c->symtree->n.sym->name);
1280 break;
1282 case EXEC_EXIT:
1283 fputs ("EXIT", dumpfile);
1284 if (c->symtree)
1285 fprintf (dumpfile, " %s", c->symtree->n.sym->name);
1286 break;
1288 case EXEC_ALLOCATE:
1289 fputs ("ALLOCATE ", dumpfile);
1290 if (c->expr)
1292 fputs (" STAT=", dumpfile);
1293 show_expr (c->expr);
1296 for (a = c->ext.alloc_list; a; a = a->next)
1298 fputc (' ', dumpfile);
1299 show_expr (a->expr);
1302 break;
1304 case EXEC_DEALLOCATE:
1305 fputs ("DEALLOCATE ", dumpfile);
1306 if (c->expr)
1308 fputs (" STAT=", dumpfile);
1309 show_expr (c->expr);
1312 for (a = c->ext.alloc_list; a; a = a->next)
1314 fputc (' ', dumpfile);
1315 show_expr (a->expr);
1318 break;
1320 case EXEC_OPEN:
1321 fputs ("OPEN", dumpfile);
1322 open = c->ext.open;
1324 if (open->unit)
1326 fputs (" UNIT=", dumpfile);
1327 show_expr (open->unit);
1329 if (open->iomsg)
1331 fputs (" IOMSG=", dumpfile);
1332 show_expr (open->iomsg);
1334 if (open->iostat)
1336 fputs (" IOSTAT=", dumpfile);
1337 show_expr (open->iostat);
1339 if (open->file)
1341 fputs (" FILE=", dumpfile);
1342 show_expr (open->file);
1344 if (open->status)
1346 fputs (" STATUS=", dumpfile);
1347 show_expr (open->status);
1349 if (open->access)
1351 fputs (" ACCESS=", dumpfile);
1352 show_expr (open->access);
1354 if (open->form)
1356 fputs (" FORM=", dumpfile);
1357 show_expr (open->form);
1359 if (open->recl)
1361 fputs (" RECL=", dumpfile);
1362 show_expr (open->recl);
1364 if (open->blank)
1366 fputs (" BLANK=", dumpfile);
1367 show_expr (open->blank);
1369 if (open->position)
1371 fputs (" POSITION=", dumpfile);
1372 show_expr (open->position);
1374 if (open->action)
1376 fputs (" ACTION=", dumpfile);
1377 show_expr (open->action);
1379 if (open->delim)
1381 fputs (" DELIM=", dumpfile);
1382 show_expr (open->delim);
1384 if (open->pad)
1386 fputs (" PAD=", dumpfile);
1387 show_expr (open->pad);
1389 if (open->decimal)
1391 fputs (" DECIMAL=", dumpfile);
1392 show_expr (open->decimal);
1394 if (open->encoding)
1396 fputs (" ENCODING=", dumpfile);
1397 show_expr (open->encoding);
1399 if (open->round)
1401 fputs (" ROUND=", dumpfile);
1402 show_expr (open->round);
1404 if (open->sign)
1406 fputs (" SIGN=", dumpfile);
1407 show_expr (open->sign);
1409 if (open->convert)
1411 fputs (" CONVERT=", dumpfile);
1412 show_expr (open->convert);
1414 if (open->asynchronous)
1416 fputs (" ASYNCHRONOUS=", dumpfile);
1417 show_expr (open->asynchronous);
1419 if (open->err != NULL)
1420 fprintf (dumpfile, " ERR=%d", open->err->value);
1422 break;
1424 case EXEC_CLOSE:
1425 fputs ("CLOSE", dumpfile);
1426 close = c->ext.close;
1428 if (close->unit)
1430 fputs (" UNIT=", dumpfile);
1431 show_expr (close->unit);
1433 if (close->iomsg)
1435 fputs (" IOMSG=", dumpfile);
1436 show_expr (close->iomsg);
1438 if (close->iostat)
1440 fputs (" IOSTAT=", dumpfile);
1441 show_expr (close->iostat);
1443 if (close->status)
1445 fputs (" STATUS=", dumpfile);
1446 show_expr (close->status);
1448 if (close->err != NULL)
1449 fprintf (dumpfile, " ERR=%d", close->err->value);
1450 break;
1452 case EXEC_BACKSPACE:
1453 fputs ("BACKSPACE", dumpfile);
1454 goto show_filepos;
1456 case EXEC_ENDFILE:
1457 fputs ("ENDFILE", dumpfile);
1458 goto show_filepos;
1460 case EXEC_REWIND:
1461 fputs ("REWIND", dumpfile);
1462 goto show_filepos;
1464 case EXEC_FLUSH:
1465 fputs ("FLUSH", dumpfile);
1467 show_filepos:
1468 fp = c->ext.filepos;
1470 if (fp->unit)
1472 fputs (" UNIT=", dumpfile);
1473 show_expr (fp->unit);
1475 if (fp->iomsg)
1477 fputs (" IOMSG=", dumpfile);
1478 show_expr (fp->iomsg);
1480 if (fp->iostat)
1482 fputs (" IOSTAT=", dumpfile);
1483 show_expr (fp->iostat);
1485 if (fp->err != NULL)
1486 fprintf (dumpfile, " ERR=%d", fp->err->value);
1487 break;
1489 case EXEC_INQUIRE:
1490 fputs ("INQUIRE", dumpfile);
1491 i = c->ext.inquire;
1493 if (i->unit)
1495 fputs (" UNIT=", dumpfile);
1496 show_expr (i->unit);
1498 if (i->file)
1500 fputs (" FILE=", dumpfile);
1501 show_expr (i->file);
1504 if (i->iomsg)
1506 fputs (" IOMSG=", dumpfile);
1507 show_expr (i->iomsg);
1509 if (i->iostat)
1511 fputs (" IOSTAT=", dumpfile);
1512 show_expr (i->iostat);
1514 if (i->exist)
1516 fputs (" EXIST=", dumpfile);
1517 show_expr (i->exist);
1519 if (i->opened)
1521 fputs (" OPENED=", dumpfile);
1522 show_expr (i->opened);
1524 if (i->number)
1526 fputs (" NUMBER=", dumpfile);
1527 show_expr (i->number);
1529 if (i->named)
1531 fputs (" NAMED=", dumpfile);
1532 show_expr (i->named);
1534 if (i->name)
1536 fputs (" NAME=", dumpfile);
1537 show_expr (i->name);
1539 if (i->access)
1541 fputs (" ACCESS=", dumpfile);
1542 show_expr (i->access);
1544 if (i->sequential)
1546 fputs (" SEQUENTIAL=", dumpfile);
1547 show_expr (i->sequential);
1550 if (i->direct)
1552 fputs (" DIRECT=", dumpfile);
1553 show_expr (i->direct);
1555 if (i->form)
1557 fputs (" FORM=", dumpfile);
1558 show_expr (i->form);
1560 if (i->formatted)
1562 fputs (" FORMATTED", dumpfile);
1563 show_expr (i->formatted);
1565 if (i->unformatted)
1567 fputs (" UNFORMATTED=", dumpfile);
1568 show_expr (i->unformatted);
1570 if (i->recl)
1572 fputs (" RECL=", dumpfile);
1573 show_expr (i->recl);
1575 if (i->nextrec)
1577 fputs (" NEXTREC=", dumpfile);
1578 show_expr (i->nextrec);
1580 if (i->blank)
1582 fputs (" BLANK=", dumpfile);
1583 show_expr (i->blank);
1585 if (i->position)
1587 fputs (" POSITION=", dumpfile);
1588 show_expr (i->position);
1590 if (i->action)
1592 fputs (" ACTION=", dumpfile);
1593 show_expr (i->action);
1595 if (i->read)
1597 fputs (" READ=", dumpfile);
1598 show_expr (i->read);
1600 if (i->write)
1602 fputs (" WRITE=", dumpfile);
1603 show_expr (i->write);
1605 if (i->readwrite)
1607 fputs (" READWRITE=", dumpfile);
1608 show_expr (i->readwrite);
1610 if (i->delim)
1612 fputs (" DELIM=", dumpfile);
1613 show_expr (i->delim);
1615 if (i->pad)
1617 fputs (" PAD=", dumpfile);
1618 show_expr (i->pad);
1620 if (i->convert)
1622 fputs (" CONVERT=", dumpfile);
1623 show_expr (i->convert);
1625 if (i->asynchronous)
1627 fputs (" ASYNCHRONOUS=", dumpfile);
1628 show_expr (i->asynchronous);
1630 if (i->decimal)
1632 fputs (" DECIMAL=", dumpfile);
1633 show_expr (i->decimal);
1635 if (i->encoding)
1637 fputs (" ENCODING=", dumpfile);
1638 show_expr (i->encoding);
1640 if (i->pending)
1642 fputs (" PENDING=", dumpfile);
1643 show_expr (i->pending);
1645 if (i->round)
1647 fputs (" ROUND=", dumpfile);
1648 show_expr (i->round);
1650 if (i->sign)
1652 fputs (" SIGN=", dumpfile);
1653 show_expr (i->sign);
1655 if (i->size)
1657 fputs (" SIZE=", dumpfile);
1658 show_expr (i->size);
1660 if (i->id)
1662 fputs (" ID=", dumpfile);
1663 show_expr (i->id);
1666 if (i->err != NULL)
1667 fprintf (dumpfile, " ERR=%d", i->err->value);
1668 break;
1670 case EXEC_IOLENGTH:
1671 fputs ("IOLENGTH ", dumpfile);
1672 show_expr (c->expr);
1673 goto show_dt_code;
1674 break;
1676 case EXEC_READ:
1677 fputs ("READ", dumpfile);
1678 goto show_dt;
1680 case EXEC_WRITE:
1681 fputs ("WRITE", dumpfile);
1683 show_dt:
1684 dt = c->ext.dt;
1685 if (dt->io_unit)
1687 fputs (" UNIT=", dumpfile);
1688 show_expr (dt->io_unit);
1691 if (dt->format_expr)
1693 fputs (" FMT=", dumpfile);
1694 show_expr (dt->format_expr);
1697 if (dt->format_label != NULL)
1698 fprintf (dumpfile, " FMT=%d", dt->format_label->value);
1699 if (dt->namelist)
1700 fprintf (dumpfile, " NML=%s", dt->namelist->name);
1702 if (dt->iomsg)
1704 fputs (" IOMSG=", dumpfile);
1705 show_expr (dt->iomsg);
1707 if (dt->iostat)
1709 fputs (" IOSTAT=", dumpfile);
1710 show_expr (dt->iostat);
1712 if (dt->size)
1714 fputs (" SIZE=", dumpfile);
1715 show_expr (dt->size);
1717 if (dt->rec)
1719 fputs (" REC=", dumpfile);
1720 show_expr (dt->rec);
1722 if (dt->advance)
1724 fputs (" ADVANCE=", dumpfile);
1725 show_expr (dt->advance);
1727 if (dt->id)
1729 fputs (" ID=", dumpfile);
1730 show_expr (dt->id);
1732 if (dt->pos)
1734 fputs (" POS=", dumpfile);
1735 show_expr (dt->pos);
1737 if (dt->asynchronous)
1739 fputs (" ASYNCHRONOUS=", dumpfile);
1740 show_expr (dt->asynchronous);
1742 if (dt->blank)
1744 fputs (" BLANK=", dumpfile);
1745 show_expr (dt->blank);
1747 if (dt->decimal)
1749 fputs (" DECIMAL=", dumpfile);
1750 show_expr (dt->decimal);
1752 if (dt->delim)
1754 fputs (" DELIM=", dumpfile);
1755 show_expr (dt->delim);
1757 if (dt->pad)
1759 fputs (" PAD=", dumpfile);
1760 show_expr (dt->pad);
1762 if (dt->round)
1764 fputs (" ROUND=", dumpfile);
1765 show_expr (dt->round);
1767 if (dt->sign)
1769 fputs (" SIGN=", dumpfile);
1770 show_expr (dt->sign);
1773 show_dt_code:
1774 fputc ('\n', dumpfile);
1775 for (c = c->block->next; c; c = c->next)
1776 show_code_node (level + (c->next != NULL), c);
1777 return;
1779 case EXEC_TRANSFER:
1780 fputs ("TRANSFER ", dumpfile);
1781 show_expr (c->expr);
1782 break;
1784 case EXEC_DT_END:
1785 fputs ("DT_END", dumpfile);
1786 dt = c->ext.dt;
1788 if (dt->err != NULL)
1789 fprintf (dumpfile, " ERR=%d", dt->err->value);
1790 if (dt->end != NULL)
1791 fprintf (dumpfile, " END=%d", dt->end->value);
1792 if (dt->eor != NULL)
1793 fprintf (dumpfile, " EOR=%d", dt->eor->value);
1794 break;
1796 case EXEC_OMP_ATOMIC:
1797 case EXEC_OMP_BARRIER:
1798 case EXEC_OMP_CRITICAL:
1799 case EXEC_OMP_FLUSH:
1800 case EXEC_OMP_DO:
1801 case EXEC_OMP_MASTER:
1802 case EXEC_OMP_ORDERED:
1803 case EXEC_OMP_PARALLEL:
1804 case EXEC_OMP_PARALLEL_DO:
1805 case EXEC_OMP_PARALLEL_SECTIONS:
1806 case EXEC_OMP_PARALLEL_WORKSHARE:
1807 case EXEC_OMP_SECTIONS:
1808 case EXEC_OMP_SINGLE:
1809 case EXEC_OMP_WORKSHARE:
1810 show_omp_node (level, c);
1811 break;
1813 default:
1814 gfc_internal_error ("show_code_node(): Bad statement code");
1817 fputc ('\n', dumpfile);
1821 /* Show an equivalence chain. */
1823 static void
1824 show_equiv (gfc_equiv *eq)
1826 show_indent ();
1827 fputs ("Equivalence: ", dumpfile);
1828 while (eq)
1830 show_expr (eq->expr);
1831 eq = eq->eq;
1832 if (eq)
1833 fputs (", ", dumpfile);
1838 /* Show a freakin' whole namespace. */
1840 static void
1841 show_namespace (gfc_namespace *ns)
1843 gfc_interface *intr;
1844 gfc_namespace *save;
1845 gfc_intrinsic_op op;
1846 gfc_equiv *eq;
1847 int i;
1849 save = gfc_current_ns;
1850 show_level++;
1852 show_indent ();
1853 fputs ("Namespace:", dumpfile);
1855 if (ns != NULL)
1857 i = 0;
1860 int l = i;
1861 while (i < GFC_LETTERS - 1
1862 && gfc_compare_types(&ns->default_type[i+1],
1863 &ns->default_type[l]))
1864 i++;
1866 if (i > l)
1867 fprintf (dumpfile, " %c-%c: ", l+'A', i+'A');
1868 else
1869 fprintf (dumpfile, " %c: ", l+'A');
1871 show_typespec(&ns->default_type[l]);
1872 i++;
1873 } while (i < GFC_LETTERS);
1875 if (ns->proc_name != NULL)
1877 show_indent ();
1878 fprintf (dumpfile, "procedure name = %s", ns->proc_name->name);
1881 gfc_current_ns = ns;
1882 gfc_traverse_symtree (ns->common_root, show_common);
1884 gfc_traverse_symtree (ns->sym_root, show_symtree);
1886 for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
1888 /* User operator interfaces */
1889 intr = ns->operator[op];
1890 if (intr == NULL)
1891 continue;
1893 show_indent ();
1894 fprintf (dumpfile, "Operator interfaces for %s:",
1895 gfc_op2string (op));
1897 for (; intr; intr = intr->next)
1898 fprintf (dumpfile, " %s", intr->sym->name);
1901 if (ns->uop_root != NULL)
1903 show_indent ();
1904 fputs ("User operators:\n", dumpfile);
1905 gfc_traverse_user_op (ns, show_uop);
1909 for (eq = ns->equiv; eq; eq = eq->next)
1910 show_equiv (eq);
1912 fputc ('\n', dumpfile);
1913 fputc ('\n', dumpfile);
1915 show_code (0, ns->code);
1917 for (ns = ns->contained; ns; ns = ns->sibling)
1919 show_indent ();
1920 fputs ("CONTAINS\n", dumpfile);
1921 show_namespace (ns);
1924 show_level--;
1925 fputc ('\n', dumpfile);
1926 gfc_current_ns = save;
1930 /* Main function for dumping a parse tree. */
1932 void
1933 gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
1935 dumpfile = file;
1936 show_namespace (ns);