Branch data Line data Source code
1 : : /* Parse tree dumper
2 : : Copyright (C) 2003-2024 Free Software Foundation, Inc.
3 : : Contributed by Steven Bosscher
4 : :
5 : : This file is part of GCC.
6 : :
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
10 : : version.
11 : :
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
15 : : for more details.
16 : :
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/>. */
20 : :
21 : :
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.
26 : :
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
29 : : relatives.
30 : :
31 : : TODO: Dump DATA. */
32 : :
33 : : #include "config.h"
34 : : #include "system.h"
35 : : #include "coretypes.h"
36 : : #include "gfortran.h"
37 : : #include "constructor.h"
38 : : #include "version.h"
39 : : #include "parse.h" /* For gfc_ascii_statement. */
40 : :
41 : : /* Keep track of indentation for symbol tree dumps. */
42 : : static int show_level = 0;
43 : :
44 : : /* The file handle we're dumping to is kept in a static variable. This
45 : : is not too cool, but it avoids a lot of passing it around. */
46 : : static FILE *dumpfile;
47 : :
48 : : /* Forward declaration of some of the functions. */
49 : : static void show_expr (gfc_expr *p);
50 : : static void show_code_node (int, gfc_code *);
51 : : static void show_namespace (gfc_namespace *ns);
52 : : static void show_code (int, gfc_code *);
53 : : static void show_symbol (gfc_symbol *);
54 : : static void show_typespec (gfc_typespec *);
55 : : static void show_ref (gfc_ref *);
56 : : static void show_attr (symbol_attribute *, const char *);
57 : :
58 : : DEBUG_FUNCTION void
59 : 0 : debug (symbol_attribute *attr)
60 : : {
61 : 0 : FILE *tmp = dumpfile;
62 : 0 : dumpfile = stderr;
63 : 0 : show_attr (attr, NULL);
64 : 0 : fputc ('\n', dumpfile);
65 : 0 : dumpfile = tmp;
66 : 0 : }
67 : :
68 : : DEBUG_FUNCTION void
69 : 0 : debug (gfc_formal_arglist *formal)
70 : : {
71 : 0 : FILE *tmp = dumpfile;
72 : 0 : dumpfile = stderr;
73 : 0 : for (; formal; formal = formal->next)
74 : : {
75 : 0 : fputc ('\n', dumpfile);
76 : 0 : show_symbol (formal->sym);
77 : : }
78 : 0 : fputc ('\n', dumpfile);
79 : 0 : dumpfile = tmp;
80 : 0 : }
81 : :
82 : : DEBUG_FUNCTION void
83 : 0 : debug (symbol_attribute attr)
84 : : {
85 : 0 : debug (&attr);
86 : 0 : }
87 : :
88 : : DEBUG_FUNCTION void
89 : 0 : debug (gfc_expr *e)
90 : : {
91 : 0 : FILE *tmp = dumpfile;
92 : 0 : dumpfile = stderr;
93 : 0 : if (e != NULL)
94 : : {
95 : 0 : show_expr (e);
96 : 0 : fputc (' ', dumpfile);
97 : 0 : show_typespec (&e->ts);
98 : : }
99 : : else
100 : 0 : fputs ("() ", dumpfile);
101 : :
102 : 0 : fputc ('\n', dumpfile);
103 : 0 : dumpfile = tmp;
104 : 0 : }
105 : :
106 : : DEBUG_FUNCTION void
107 : 0 : debug (gfc_typespec *ts)
108 : : {
109 : 0 : FILE *tmp = dumpfile;
110 : 0 : dumpfile = stderr;
111 : 0 : show_typespec (ts);
112 : 0 : fputc ('\n', dumpfile);
113 : 0 : dumpfile = tmp;
114 : 0 : }
115 : :
116 : : DEBUG_FUNCTION void
117 : 0 : debug (gfc_typespec ts)
118 : : {
119 : 0 : debug (&ts);
120 : 0 : }
121 : :
122 : : DEBUG_FUNCTION void
123 : 0 : debug (gfc_ref *p)
124 : : {
125 : 0 : FILE *tmp = dumpfile;
126 : 0 : dumpfile = stderr;
127 : 0 : show_ref (p);
128 : 0 : fputc ('\n', dumpfile);
129 : 0 : dumpfile = tmp;
130 : 0 : }
131 : :
132 : : DEBUG_FUNCTION void
133 : 0 : debug (gfc_namespace *ns)
134 : : {
135 : 0 : FILE *tmp = dumpfile;
136 : 0 : dumpfile = stderr;
137 : 0 : show_namespace (ns);
138 : 0 : fputc ('\n', dumpfile);
139 : 0 : dumpfile = tmp;
140 : 0 : }
141 : :
142 : : DEBUG_FUNCTION void
143 : 0 : gfc_debug_expr (gfc_expr *e)
144 : : {
145 : 0 : FILE *tmp = dumpfile;
146 : 0 : dumpfile = stderr;
147 : 0 : show_expr (e);
148 : 0 : fputc ('\n', dumpfile);
149 : 0 : dumpfile = tmp;
150 : 0 : }
151 : :
152 : : /* Allow for dumping of a piece of code in the debugger. */
153 : :
154 : : DEBUG_FUNCTION void
155 : 0 : gfc_debug_code (gfc_code *c)
156 : : {
157 : 0 : FILE *tmp = dumpfile;
158 : 0 : dumpfile = stderr;
159 : 0 : show_code (1, c);
160 : 0 : fputc ('\n', dumpfile);
161 : 0 : dumpfile = tmp;
162 : 0 : }
163 : :
164 : : DEBUG_FUNCTION void
165 : 0 : debug (gfc_symbol *sym)
166 : : {
167 : 0 : FILE *tmp = dumpfile;
168 : 0 : dumpfile = stderr;
169 : 0 : show_symbol (sym);
170 : 0 : fputc ('\n', dumpfile);
171 : 0 : dumpfile = tmp;
172 : 0 : }
173 : :
174 : : /* Do indentation for a specific level. */
175 : :
176 : : static inline void
177 : 1944 : code_indent (int level, gfc_st_label *label)
178 : : {
179 : 1944 : int i;
180 : :
181 : 1944 : if (label != NULL)
182 : 0 : fprintf (dumpfile, "%-5d ", label->value);
183 : :
184 : 17560 : for (i = 0; i < (2 * level - (label ? 6 : 0)); i++)
185 : 6836 : fputc (' ', dumpfile);
186 : 1944 : }
187 : :
188 : :
189 : : /* Simple indentation at the current level. This one
190 : : is used to show symbols. */
191 : :
192 : : static inline void
193 : 1896 : show_indent (void)
194 : : {
195 : 1896 : fputc ('\n', dumpfile);
196 : 1896 : code_indent (show_level, NULL);
197 : 1896 : }
198 : :
199 : :
200 : : /* Show type-specific information. */
201 : :
202 : : static void
203 : 562 : show_typespec (gfc_typespec *ts)
204 : : {
205 : 562 : if (ts->type == BT_ASSUMED)
206 : : {
207 : 0 : fputs ("(TYPE(*))", dumpfile);
208 : 0 : return;
209 : : }
210 : :
211 : 562 : fprintf (dumpfile, "(%s ", gfc_basic_typename (ts->type));
212 : :
213 : 562 : switch (ts->type)
214 : : {
215 : 150 : case BT_DERIVED:
216 : 150 : case BT_CLASS:
217 : 150 : case BT_UNION:
218 : 150 : fprintf (dumpfile, "%s", ts->u.derived->name);
219 : 150 : break;
220 : :
221 : 16 : case BT_CHARACTER:
222 : 16 : if (ts->u.cl)
223 : 16 : show_expr (ts->u.cl->length);
224 : 16 : fprintf(dumpfile, " %d", ts->kind);
225 : 16 : break;
226 : :
227 : 396 : default:
228 : 396 : fprintf (dumpfile, "%d", ts->kind);
229 : 396 : break;
230 : : }
231 : 562 : if (ts->is_c_interop)
232 : 100 : fputs (" C_INTEROP", dumpfile);
233 : :
234 : 562 : if (ts->is_iso_c)
235 : 92 : fputs (" ISO_C", dumpfile);
236 : :
237 : 562 : if (ts->deferred)
238 : 0 : fputs (" DEFERRED", dumpfile);
239 : :
240 : 562 : fputc (')', dumpfile);
241 : : }
242 : :
243 : :
244 : : /* Show an actual argument list. */
245 : :
246 : : static void
247 : 24 : show_actual_arglist (gfc_actual_arglist *a)
248 : : {
249 : 24 : fputc ('(', dumpfile);
250 : :
251 : 72 : for (; a; a = a->next)
252 : : {
253 : 24 : fputc ('(', dumpfile);
254 : 24 : if (a->name != NULL)
255 : 0 : fprintf (dumpfile, "%s = ", a->name);
256 : 24 : if (a->expr != NULL)
257 : 24 : show_expr (a->expr);
258 : : else
259 : 0 : fputs ("(arg not-present)", dumpfile);
260 : :
261 : 24 : fputc (')', dumpfile);
262 : 24 : if (a->next != NULL)
263 : 0 : fputc (' ', dumpfile);
264 : : }
265 : :
266 : 24 : fputc (')', dumpfile);
267 : 24 : }
268 : :
269 : :
270 : : /* Show a gfc_array_spec array specification structure. */
271 : :
272 : : static void
273 : 142 : show_array_spec (gfc_array_spec *as)
274 : : {
275 : 142 : const char *c;
276 : 142 : int i;
277 : :
278 : 142 : if (as == NULL)
279 : : {
280 : 142 : fputs ("()", dumpfile);
281 : 142 : return;
282 : : }
283 : :
284 : 0 : fprintf (dumpfile, "(%d [%d]", as->rank, as->corank);
285 : :
286 : 0 : if (as->rank + as->corank > 0 || as->rank == -1)
287 : : {
288 : 0 : switch (as->type)
289 : : {
290 : : case AS_EXPLICIT: c = "AS_EXPLICIT"; break;
291 : 0 : case AS_DEFERRED: c = "AS_DEFERRED"; break;
292 : 0 : case AS_ASSUMED_SIZE: c = "AS_ASSUMED_SIZE"; break;
293 : 0 : case AS_ASSUMED_SHAPE: c = "AS_ASSUMED_SHAPE"; break;
294 : 0 : case AS_ASSUMED_RANK: c = "AS_ASSUMED_RANK"; break;
295 : 0 : default:
296 : 0 : gfc_internal_error ("show_array_spec(): Unhandled array shape "
297 : : "type.");
298 : : }
299 : 0 : fprintf (dumpfile, " %s ", c);
300 : :
301 : 0 : for (i = 0; i < as->rank + as->corank; i++)
302 : : {
303 : 0 : show_expr (as->lower[i]);
304 : 0 : fputc (' ', dumpfile);
305 : 0 : show_expr (as->upper[i]);
306 : 0 : fputc (' ', dumpfile);
307 : : }
308 : : }
309 : :
310 : 0 : fputc (')', dumpfile);
311 : : }
312 : :
313 : :
314 : : /* Show a gfc_array_ref array reference structure. */
315 : :
316 : : static void
317 : 0 : show_array_ref (gfc_array_ref * ar)
318 : : {
319 : 0 : int i;
320 : :
321 : 0 : fputc ('(', dumpfile);
322 : :
323 : 0 : switch (ar->type)
324 : : {
325 : 0 : case AR_FULL:
326 : 0 : fputs ("FULL", dumpfile);
327 : 0 : break;
328 : :
329 : : case AR_SECTION:
330 : 0 : for (i = 0; i < ar->dimen; i++)
331 : : {
332 : : /* There are two types of array sections: either the
333 : : elements are identified by an integer array ('vector'),
334 : : or by an index range. In the former case we only have to
335 : : print the start expression which contains the vector, in
336 : : the latter case we have to print any of lower and upper
337 : : bound and the stride, if they're present. */
338 : :
339 : 0 : if (ar->start[i] != NULL)
340 : 0 : show_expr (ar->start[i]);
341 : :
342 : 0 : if (ar->dimen_type[i] == DIMEN_RANGE)
343 : : {
344 : 0 : fputc (':', dumpfile);
345 : :
346 : 0 : if (ar->end[i] != NULL)
347 : 0 : show_expr (ar->end[i]);
348 : :
349 : 0 : if (ar->stride[i] != NULL)
350 : : {
351 : 0 : fputc (':', dumpfile);
352 : 0 : show_expr (ar->stride[i]);
353 : : }
354 : : }
355 : :
356 : 0 : if (i != ar->dimen - 1)
357 : 0 : fputs (" , ", dumpfile);
358 : : }
359 : : break;
360 : :
361 : : case AR_ELEMENT:
362 : 0 : for (i = 0; i < ar->dimen; i++)
363 : : {
364 : 0 : show_expr (ar->start[i]);
365 : 0 : if (i != ar->dimen - 1)
366 : 0 : fputs (" , ", dumpfile);
367 : : }
368 : : break;
369 : :
370 : 0 : case AR_UNKNOWN:
371 : 0 : fputs ("UNKNOWN", dumpfile);
372 : 0 : break;
373 : :
374 : 0 : default:
375 : 0 : gfc_internal_error ("show_array_ref(): Unknown array reference");
376 : : }
377 : :
378 : 0 : fputc (')', dumpfile);
379 : 0 : if (ar->codimen == 0)
380 : : return;
381 : :
382 : : /* Show coarray part of the reference, if any. */
383 : 0 : fputc ('[',dumpfile);
384 : 0 : for (i = ar->dimen; i < ar->dimen + ar->codimen; i++)
385 : : {
386 : 0 : if (ar->dimen_type[i] == DIMEN_STAR)
387 : 0 : fputc('*',dumpfile);
388 : 0 : else if (ar->dimen_type[i] == DIMEN_THIS_IMAGE)
389 : 0 : fputs("THIS_IMAGE", dumpfile);
390 : : else
391 : : {
392 : 0 : show_expr (ar->start[i]);
393 : 0 : if (ar->end[i])
394 : : {
395 : 0 : fputc(':', dumpfile);
396 : 0 : show_expr (ar->end[i]);
397 : : }
398 : : }
399 : 0 : if (i != ar->dimen + ar->codimen - 1)
400 : 0 : fputs (" , ", dumpfile);
401 : :
402 : : }
403 : 0 : fputc (']',dumpfile);
404 : : }
405 : :
406 : :
407 : : /* Show a list of gfc_ref structures. */
408 : :
409 : : static void
410 : 84 : show_ref (gfc_ref *p)
411 : : {
412 : 120 : for (; p; p = p->next)
413 : 36 : switch (p->type)
414 : : {
415 : 0 : case REF_ARRAY:
416 : 0 : show_array_ref (&p->u.ar);
417 : 0 : break;
418 : :
419 : 36 : case REF_COMPONENT:
420 : 36 : fprintf (dumpfile, " %% %s", p->u.c.component->name);
421 : 36 : break;
422 : :
423 : 0 : case REF_SUBSTRING:
424 : 0 : fputc ('(', dumpfile);
425 : 0 : show_expr (p->u.ss.start);
426 : 0 : fputc (':', dumpfile);
427 : 0 : show_expr (p->u.ss.end);
428 : 0 : fputc (')', dumpfile);
429 : 0 : break;
430 : :
431 : 0 : case REF_INQUIRY:
432 : 0 : switch (p->u.i)
433 : : {
434 : 0 : case INQUIRY_KIND:
435 : 0 : fprintf (dumpfile, " INQUIRY_KIND ");
436 : 0 : break;
437 : 0 : case INQUIRY_LEN:
438 : 0 : fprintf (dumpfile, " INQUIRY_LEN ");
439 : 0 : break;
440 : 0 : case INQUIRY_RE:
441 : 0 : fprintf (dumpfile, " INQUIRY_RE ");
442 : 0 : break;
443 : 0 : case INQUIRY_IM:
444 : 0 : fprintf (dumpfile, " INQUIRY_IM ");
445 : : }
446 : : break;
447 : :
448 : 0 : default:
449 : 0 : gfc_internal_error ("show_ref(): Bad component code");
450 : : }
451 : 84 : }
452 : :
453 : :
454 : : /* Display a constructor. Works recursively for array constructors. */
455 : :
456 : : static void
457 : 40 : show_constructor (gfc_constructor_base base)
458 : : {
459 : 40 : gfc_constructor *c;
460 : 170 : for (c = gfc_constructor_first (base); c; c = gfc_constructor_next (c))
461 : : {
462 : 130 : if (c->iterator == NULL)
463 : 130 : show_expr (c->expr);
464 : : else
465 : : {
466 : 0 : fputc ('(', dumpfile);
467 : 0 : show_expr (c->expr);
468 : :
469 : 0 : fputc (' ', dumpfile);
470 : 0 : show_expr (c->iterator->var);
471 : 0 : fputc ('=', dumpfile);
472 : 0 : show_expr (c->iterator->start);
473 : 0 : fputc (',', dumpfile);
474 : 0 : show_expr (c->iterator->end);
475 : 0 : fputc (',', dumpfile);
476 : 0 : show_expr (c->iterator->step);
477 : :
478 : 0 : fputc (')', dumpfile);
479 : : }
480 : :
481 : 130 : if (gfc_constructor_next (c) != NULL)
482 : 90 : fputs (" , ", dumpfile);
483 : : }
484 : 40 : }
485 : :
486 : :
487 : : static void
488 : 16 : show_char_const (const gfc_char_t *c, gfc_charlen_t length)
489 : : {
490 : 16 : fputc ('\'', dumpfile);
491 : 32 : for (size_t i = 0; i < (size_t) length; i++)
492 : : {
493 : 16 : if (c[i] == '\'')
494 : 0 : fputs ("''", dumpfile);
495 : : else
496 : 16 : fputs (gfc_print_wide_char (c[i]), dumpfile);
497 : : }
498 : 16 : fputc ('\'', dumpfile);
499 : 16 : }
500 : :
501 : :
502 : : /* Show a component-call expression. */
503 : :
504 : : static void
505 : 0 : show_compcall (gfc_expr* p)
506 : : {
507 : 0 : gcc_assert (p->expr_type == EXPR_COMPCALL);
508 : :
509 : 0 : fprintf (dumpfile, "%s", p->symtree->n.sym->name);
510 : 0 : show_ref (p->ref);
511 : 0 : fprintf (dumpfile, "%s", p->value.compcall.name);
512 : :
513 : 0 : show_actual_arglist (p->value.compcall.actual);
514 : 0 : }
515 : :
516 : :
517 : : /* Show an expression. */
518 : :
519 : : static void
520 : 518 : show_expr (gfc_expr *p)
521 : : {
522 : 518 : const char *c;
523 : 518 : int i;
524 : :
525 : 518 : if (p == NULL)
526 : : {
527 : 42 : fputs ("()", dumpfile);
528 : 42 : return;
529 : : }
530 : :
531 : 476 : switch (p->expr_type)
532 : : {
533 : 0 : case EXPR_SUBSTRING:
534 : 0 : show_char_const (p->value.character.string, p->value.character.length);
535 : 0 : show_ref (p->ref);
536 : 0 : break;
537 : :
538 : 40 : case EXPR_STRUCTURE:
539 : 40 : fprintf (dumpfile, "%s(", p->ts.u.derived->name);
540 : 40 : show_constructor (p->value.constructor);
541 : 40 : fputc (')', dumpfile);
542 : 40 : break;
543 : :
544 : 0 : case EXPR_ARRAY:
545 : 0 : fputs ("(/ ", dumpfile);
546 : 0 : show_constructor (p->value.constructor);
547 : 0 : fputs (" /)", dumpfile);
548 : :
549 : 0 : show_ref (p->ref);
550 : 0 : break;
551 : :
552 : 60 : case EXPR_NULL:
553 : 60 : fputs ("NULL()", dumpfile);
554 : 60 : break;
555 : :
556 : 256 : case EXPR_CONSTANT:
557 : 256 : switch (p->ts.type)
558 : : {
559 : 224 : case BT_INTEGER:
560 : 224 : mpz_out_str (dumpfile, 10, p->value.integer);
561 : :
562 : 224 : if (p->ts.kind != gfc_default_integer_kind)
563 : 22 : fprintf (dumpfile, "_%d", p->ts.kind);
564 : : break;
565 : :
566 : 0 : case BT_LOGICAL:
567 : 0 : if (p->value.logical)
568 : 0 : fputs (".true.", dumpfile);
569 : : else
570 : 0 : fputs (".false.", dumpfile);
571 : : break;
572 : :
573 : 16 : case BT_REAL:
574 : 16 : mpfr_out_str (dumpfile, 10, 0, p->value.real, GFC_RND_MODE);
575 : 16 : if (p->ts.kind != gfc_default_real_kind)
576 : 12 : fprintf (dumpfile, "_%d", p->ts.kind);
577 : : break;
578 : :
579 : 16 : case BT_CHARACTER:
580 : 16 : show_char_const (p->value.character.string,
581 : : p->value.character.length);
582 : 16 : break;
583 : :
584 : 0 : case BT_COMPLEX:
585 : 0 : fputs ("(complex ", dumpfile);
586 : :
587 : 0 : mpfr_out_str (dumpfile, 10, 0, mpc_realref (p->value.complex),
588 : : GFC_RND_MODE);
589 : 0 : if (p->ts.kind != gfc_default_complex_kind)
590 : 0 : fprintf (dumpfile, "_%d", p->ts.kind);
591 : :
592 : 0 : fputc (' ', dumpfile);
593 : :
594 : 0 : mpfr_out_str (dumpfile, 10, 0, mpc_imagref (p->value.complex),
595 : : GFC_RND_MODE);
596 : 0 : if (p->ts.kind != gfc_default_complex_kind)
597 : 0 : fprintf (dumpfile, "_%d", p->ts.kind);
598 : :
599 : 0 : fputc (')', dumpfile);
600 : 0 : break;
601 : :
602 : 0 : case BT_BOZ:
603 : 0 : if (p->boz.rdx == 2)
604 : 0 : fputs ("b'", dumpfile);
605 : 0 : else if (p->boz.rdx == 8)
606 : 0 : fputs ("o'", dumpfile);
607 : : else
608 : 0 : fputs ("z'", dumpfile);
609 : 0 : fprintf (dumpfile, "%s'", p->boz.str);
610 : 0 : break;
611 : :
612 : 0 : case BT_HOLLERITH:
613 : 0 : fprintf (dumpfile, HOST_WIDE_INT_PRINT_DEC "H",
614 : : p->representation.length);
615 : 0 : c = p->representation.string;
616 : 0 : for (i = 0; i < p->representation.length; i++, c++)
617 : : {
618 : 0 : fputc (*c, dumpfile);
619 : : }
620 : : break;
621 : :
622 : 0 : default:
623 : 0 : fputs ("???", dumpfile);
624 : 0 : break;
625 : : }
626 : :
627 : 256 : if (p->representation.string)
628 : : {
629 : 0 : fputs (" {", dumpfile);
630 : 0 : c = p->representation.string;
631 : 0 : for (i = 0; i < p->representation.length; i++, c++)
632 : : {
633 : 0 : fprintf (dumpfile, "%.2x", (unsigned int) *c);
634 : 0 : if (i < p->representation.length - 1)
635 : 0 : fputc (',', dumpfile);
636 : : }
637 : 0 : fputc ('}', dumpfile);
638 : : }
639 : :
640 : : break;
641 : :
642 : 84 : case EXPR_VARIABLE:
643 : 84 : if (p->symtree->n.sym->ns && p->symtree->n.sym->ns->proc_name)
644 : 84 : fprintf (dumpfile, "%s:", p->symtree->n.sym->ns->proc_name->name);
645 : 84 : fprintf (dumpfile, "%s", p->symtree->n.sym->name);
646 : 84 : show_ref (p->ref);
647 : 84 : break;
648 : :
649 : 12 : case EXPR_OP:
650 : 12 : fputc ('(', dumpfile);
651 : 12 : switch (p->value.op.op)
652 : : {
653 : 0 : case INTRINSIC_UPLUS:
654 : 0 : fputs ("U+ ", dumpfile);
655 : 0 : break;
656 : 0 : case INTRINSIC_UMINUS:
657 : 0 : fputs ("U- ", dumpfile);
658 : 0 : break;
659 : 0 : case INTRINSIC_PLUS:
660 : 0 : fputs ("+ ", dumpfile);
661 : 0 : break;
662 : 0 : case INTRINSIC_MINUS:
663 : 0 : fputs ("- ", dumpfile);
664 : 0 : break;
665 : 0 : case INTRINSIC_TIMES:
666 : 0 : fputs ("* ", dumpfile);
667 : 0 : break;
668 : 0 : case INTRINSIC_DIVIDE:
669 : 0 : fputs ("/ ", dumpfile);
670 : 0 : break;
671 : 0 : case INTRINSIC_POWER:
672 : 0 : fputs ("** ", dumpfile);
673 : 0 : break;
674 : 0 : case INTRINSIC_CONCAT:
675 : 0 : fputs ("// ", dumpfile);
676 : 0 : break;
677 : 0 : case INTRINSIC_AND:
678 : 0 : fputs ("AND ", dumpfile);
679 : 0 : break;
680 : 0 : case INTRINSIC_OR:
681 : 0 : fputs ("OR ", dumpfile);
682 : 0 : break;
683 : 0 : case INTRINSIC_EQV:
684 : 0 : fputs ("EQV ", dumpfile);
685 : 0 : break;
686 : 0 : case INTRINSIC_NEQV:
687 : 0 : fputs ("NEQV ", dumpfile);
688 : 0 : break;
689 : 0 : case INTRINSIC_EQ:
690 : 0 : case INTRINSIC_EQ_OS:
691 : 0 : fputs ("== ", dumpfile);
692 : 0 : break;
693 : 12 : case INTRINSIC_NE:
694 : 12 : case INTRINSIC_NE_OS:
695 : 12 : fputs ("/= ", dumpfile);
696 : 12 : break;
697 : 0 : case INTRINSIC_GT:
698 : 0 : case INTRINSIC_GT_OS:
699 : 0 : fputs ("> ", dumpfile);
700 : 0 : break;
701 : 0 : case INTRINSIC_GE:
702 : 0 : case INTRINSIC_GE_OS:
703 : 0 : fputs (">= ", dumpfile);
704 : 0 : break;
705 : 0 : case INTRINSIC_LT:
706 : 0 : case INTRINSIC_LT_OS:
707 : 0 : fputs ("< ", dumpfile);
708 : 0 : break;
709 : 0 : case INTRINSIC_LE:
710 : 0 : case INTRINSIC_LE_OS:
711 : 0 : fputs ("<= ", dumpfile);
712 : 0 : break;
713 : 0 : case INTRINSIC_NOT:
714 : 0 : fputs ("NOT ", dumpfile);
715 : 0 : break;
716 : 0 : case INTRINSIC_PARENTHESES:
717 : 0 : fputs ("parens ", dumpfile);
718 : 0 : break;
719 : :
720 : 0 : default:
721 : 0 : gfc_internal_error
722 : 0 : ("show_expr(): Bad intrinsic in expression");
723 : : }
724 : :
725 : 12 : show_expr (p->value.op.op1);
726 : :
727 : 12 : if (p->value.op.op2)
728 : : {
729 : 12 : fputc (' ', dumpfile);
730 : 12 : show_expr (p->value.op.op2);
731 : : }
732 : :
733 : 12 : fputc (')', dumpfile);
734 : 12 : break;
735 : :
736 : 24 : case EXPR_FUNCTION:
737 : 24 : if (p->value.function.name == NULL)
738 : : {
739 : 24 : fprintf (dumpfile, "%s", p->symtree->n.sym->name);
740 : 24 : if (gfc_is_proc_ptr_comp (p))
741 : 0 : show_ref (p->ref);
742 : 24 : fputc ('[', dumpfile);
743 : 24 : show_actual_arglist (p->value.function.actual);
744 : 24 : fputc (']', dumpfile);
745 : : }
746 : : else
747 : : {
748 : 0 : fprintf (dumpfile, "%s", p->value.function.name);
749 : 0 : if (gfc_is_proc_ptr_comp (p))
750 : 0 : show_ref (p->ref);
751 : 0 : fputc ('[', dumpfile);
752 : 0 : fputc ('[', dumpfile);
753 : 0 : show_actual_arglist (p->value.function.actual);
754 : 0 : fputc (']', dumpfile);
755 : 0 : fputc (']', dumpfile);
756 : : }
757 : :
758 : : break;
759 : :
760 : 0 : case EXPR_COMPCALL:
761 : 0 : show_compcall (p);
762 : 0 : break;
763 : :
764 : 0 : default:
765 : 0 : gfc_internal_error ("show_expr(): Don't know how to show expr");
766 : : }
767 : : }
768 : :
769 : : /* Show symbol attributes. The flavor and intent are followed by
770 : : whatever single bit attributes are present. */
771 : :
772 : : static void
773 : 332 : show_attr (symbol_attribute *attr, const char * module)
774 : : {
775 : 332 : fputc ('(', dumpfile);
776 : 332 : if (attr->flavor != FL_UNKNOWN)
777 : : {
778 : 332 : if (attr->flavor == FL_DERIVED && attr->pdt_template)
779 : 0 : fputs ("PDT-TEMPLATE ", dumpfile);
780 : : else
781 : 332 : fprintf (dumpfile, "%s ", gfc_code2string (flavors, attr->flavor));
782 : : }
783 : 332 : if (attr->access != ACCESS_UNKNOWN)
784 : 70 : fprintf (dumpfile, "%s ", gfc_code2string (access_types, attr->access));
785 : 332 : if (attr->proc != PROC_UNKNOWN)
786 : 38 : fprintf (dumpfile, "%s ", gfc_code2string (procedures, attr->proc));
787 : 332 : if (attr->save != SAVE_NONE)
788 : 18 : fprintf (dumpfile, "%s", gfc_code2string (save_status, attr->save));
789 : :
790 : 332 : if (attr->artificial)
791 : 24 : fputs (" ARTIFICIAL", dumpfile);
792 : 332 : if (attr->allocatable)
793 : 0 : fputs (" ALLOCATABLE", dumpfile);
794 : 332 : if (attr->asynchronous)
795 : 0 : fputs (" ASYNCHRONOUS", dumpfile);
796 : 332 : if (attr->codimension)
797 : 0 : fputs (" CODIMENSION", dumpfile);
798 : 332 : if (attr->dimension)
799 : 0 : fputs (" DIMENSION", dumpfile);
800 : 332 : if (attr->contiguous)
801 : 0 : fputs (" CONTIGUOUS", dumpfile);
802 : 332 : if (attr->external)
803 : 0 : fputs (" EXTERNAL", dumpfile);
804 : 332 : if (attr->intrinsic)
805 : 20 : fputs (" INTRINSIC", dumpfile);
806 : 332 : if (attr->optional)
807 : 0 : fputs (" OPTIONAL", dumpfile);
808 : 332 : if (attr->pdt_kind)
809 : 0 : fputs (" KIND", dumpfile);
810 : 332 : if (attr->pdt_len)
811 : 0 : fputs (" LEN", dumpfile);
812 : 332 : if (attr->pointer)
813 : 0 : fputs (" POINTER", dumpfile);
814 : 332 : if (attr->subref_array_pointer)
815 : 0 : fputs (" SUBREF-ARRAY-POINTER", dumpfile);
816 : 332 : if (attr->cray_pointer)
817 : 0 : fputs (" CRAY-POINTER", dumpfile);
818 : 332 : if (attr->cray_pointee)
819 : 0 : fputs (" CRAY-POINTEE", dumpfile);
820 : 332 : if (attr->is_protected)
821 : 0 : fputs (" PROTECTED", dumpfile);
822 : 332 : if (attr->value)
823 : 0 : fputs (" VALUE", dumpfile);
824 : 332 : if (attr->volatile_)
825 : 0 : fputs (" VOLATILE", dumpfile);
826 : 332 : if (attr->threadprivate)
827 : 0 : fputs (" THREADPRIVATE", dumpfile);
828 : 332 : if (attr->target)
829 : 18 : fputs (" TARGET", dumpfile);
830 : 332 : if (attr->dummy)
831 : : {
832 : 18 : fputs (" DUMMY", dumpfile);
833 : 18 : if (attr->intent != INTENT_UNKNOWN)
834 : 12 : fprintf (dumpfile, "(%s)", gfc_intent_string (attr->intent));
835 : : }
836 : :
837 : 332 : if (attr->result)
838 : 0 : fputs (" RESULT", dumpfile);
839 : 332 : if (attr->entry)
840 : 0 : fputs (" ENTRY", dumpfile);
841 : 332 : if (attr->entry_master)
842 : 0 : fputs (" ENTRY-MASTER", dumpfile);
843 : 332 : if (attr->mixed_entry_master)
844 : 0 : fputs (" MIXED-ENTRY-MASTER", dumpfile);
845 : 332 : if (attr->is_bind_c)
846 : 8 : fputs (" BIND(C)", dumpfile);
847 : :
848 : 332 : if (attr->data)
849 : 0 : fputs (" DATA", dumpfile);
850 : 332 : if (attr->use_assoc)
851 : : {
852 : 108 : fputs (" USE-ASSOC", dumpfile);
853 : 108 : if (module != NULL)
854 : 108 : fprintf (dumpfile, "(%s)", module);
855 : : }
856 : :
857 : 332 : if (attr->in_namelist)
858 : 0 : fputs (" IN-NAMELIST", dumpfile);
859 : 332 : if (attr->in_common)
860 : 0 : fputs (" IN-COMMON", dumpfile);
861 : :
862 : 332 : if (attr->abstract)
863 : 0 : fputs (" ABSTRACT", dumpfile);
864 : 332 : if (attr->function)
865 : 50 : fputs (" FUNCTION", dumpfile);
866 : 332 : if (attr->subroutine)
867 : 56 : fputs (" SUBROUTINE", dumpfile);
868 : 332 : if (attr->implicit_type)
869 : 24 : fputs (" IMPLICIT-TYPE", dumpfile);
870 : :
871 : 332 : if (attr->sequence)
872 : 0 : fputs (" SEQUENCE", dumpfile);
873 : 332 : if (attr->alloc_comp)
874 : 0 : fputs (" ALLOC-COMP", dumpfile);
875 : 332 : if (attr->pointer_comp)
876 : 0 : fputs (" POINTER-COMP", dumpfile);
877 : 332 : if (attr->proc_pointer_comp)
878 : 0 : fputs (" PROC-POINTER-COMP", dumpfile);
879 : 332 : if (attr->private_comp)
880 : 4 : fputs (" PRIVATE-COMP", dumpfile);
881 : 332 : if (attr->zero_comp)
882 : 6 : fputs (" ZERO-COMP", dumpfile);
883 : 332 : if (attr->coarray_comp)
884 : 0 : fputs (" COARRAY-COMP", dumpfile);
885 : 332 : if (attr->lock_comp)
886 : 0 : fputs (" LOCK-COMP", dumpfile);
887 : 332 : if (attr->event_comp)
888 : 0 : fputs (" EVENT-COMP", dumpfile);
889 : 332 : if (attr->defined_assign_comp)
890 : 0 : fputs (" DEFINED-ASSIGNED-COMP", dumpfile);
891 : 332 : if (attr->unlimited_polymorphic)
892 : 6 : fputs (" UNLIMITED-POLYMORPHIC", dumpfile);
893 : 332 : if (attr->has_dtio_procs)
894 : 0 : fputs (" HAS-DTIO-PROCS", dumpfile);
895 : 332 : if (attr->caf_token)
896 : 0 : fputs (" CAF-TOKEN", dumpfile);
897 : 332 : if (attr->select_type_temporary)
898 : 12 : fputs (" SELECT-TYPE-TEMPORARY", dumpfile);
899 : 332 : if (attr->associate_var)
900 : 12 : fputs (" ASSOCIATE-VAR", dumpfile);
901 : 332 : if (attr->pdt_kind)
902 : 0 : fputs (" PDT-KIND", dumpfile);
903 : 332 : if (attr->pdt_len)
904 : 0 : fputs (" PDT-LEN", dumpfile);
905 : 332 : if (attr->pdt_type)
906 : 0 : fputs (" PDT-TYPE", dumpfile);
907 : 332 : if (attr->pdt_array)
908 : 0 : fputs (" PDT-ARRAY", dumpfile);
909 : 332 : if (attr->pdt_string)
910 : 0 : fputs (" PDT-STRING", dumpfile);
911 : 332 : if (attr->omp_udr_artificial_var)
912 : 0 : fputs (" OMP-UDR-ARTIFICIAL-VAR", dumpfile);
913 : 332 : if (attr->omp_declare_target)
914 : 0 : fputs (" OMP-DECLARE-TARGET", dumpfile);
915 : 332 : if (attr->omp_declare_target_link)
916 : 0 : fputs (" OMP-DECLARE-TARGET-LINK", dumpfile);
917 : 332 : if (attr->omp_declare_target_indirect)
918 : 0 : fputs (" OMP-DECLARE-TARGET-INDIRECT", dumpfile);
919 : 332 : if (attr->elemental)
920 : 6 : fputs (" ELEMENTAL", dumpfile);
921 : 332 : if (attr->pure)
922 : 10 : fputs (" PURE", dumpfile);
923 : 332 : if (attr->implicit_pure)
924 : 0 : fputs (" IMPLICIT-PURE", dumpfile);
925 : 332 : if (attr->recursive)
926 : 0 : fputs (" RECURSIVE", dumpfile);
927 : 332 : if (attr->unmaskable)
928 : 0 : fputs (" UNMASKABKE", dumpfile);
929 : 332 : if (attr->masked)
930 : 0 : fputs (" MASKED", dumpfile);
931 : 332 : if (attr->contained)
932 : 6 : fputs (" CONTAINED", dumpfile);
933 : 332 : if (attr->mod_proc)
934 : 0 : fputs (" MOD-PROC", dumpfile);
935 : 332 : if (attr->module_procedure)
936 : 0 : fputs (" MODULE-PROCEDURE", dumpfile);
937 : 332 : if (attr->public_used)
938 : 0 : fputs (" PUBLIC_USED", dumpfile);
939 : 332 : if (attr->array_outer_dependency)
940 : 40 : fputs (" ARRAY-OUTER-DEPENDENCY", dumpfile);
941 : 332 : if (attr->noreturn)
942 : 0 : fputs (" NORETURN", dumpfile);
943 : 332 : if (attr->always_explicit)
944 : 0 : fputs (" ALWAYS-EXPLICIT", dumpfile);
945 : 332 : if (attr->is_main_program)
946 : 40 : fputs (" IS-MAIN-PROGRAM", dumpfile);
947 : 332 : if (attr->oacc_routine_nohost)
948 : 0 : fputs (" OACC-ROUTINE-NOHOST", dumpfile);
949 : :
950 : : /* FIXME: Still missing are oacc_routine_lop and ext_attr. */
951 : 332 : fputc (')', dumpfile);
952 : 332 : }
953 : :
954 : :
955 : : /* Show components of a derived type. */
956 : :
957 : : static void
958 : 40 : show_components (gfc_symbol *sym)
959 : : {
960 : 40 : gfc_component *c;
961 : :
962 : 182 : for (c = sym->components; c; c = c->next)
963 : : {
964 : 142 : show_indent ();
965 : 142 : fprintf (dumpfile, "(%s ", c->name);
966 : 142 : show_typespec (&c->ts);
967 : 142 : if (c->kind_expr)
968 : : {
969 : 0 : fputs (" kind_expr: ", dumpfile);
970 : 0 : show_expr (c->kind_expr);
971 : : }
972 : 142 : if (c->param_list)
973 : : {
974 : 0 : fputs ("PDT parameters", dumpfile);
975 : 0 : show_actual_arglist (c->param_list);
976 : : }
977 : :
978 : 142 : if (c->attr.allocatable)
979 : 12 : fputs (" ALLOCATABLE", dumpfile);
980 : 142 : if (c->attr.pdt_kind)
981 : 0 : fputs (" KIND", dumpfile);
982 : 142 : if (c->attr.pdt_len)
983 : 0 : fputs (" LEN", dumpfile);
984 : 142 : if (c->attr.pointer)
985 : 48 : fputs (" POINTER", dumpfile);
986 : 142 : if (c->attr.proc_pointer)
987 : 36 : fputs (" PPC", dumpfile);
988 : 142 : if (c->attr.dimension)
989 : 0 : fputs (" DIMENSION", dumpfile);
990 : 142 : fputc (' ', dumpfile);
991 : 142 : show_array_spec (c->as);
992 : 142 : if (c->attr.access)
993 : 136 : fprintf (dumpfile, " %s", gfc_code2string (access_types, c->attr.access));
994 : 142 : fputc (')', dumpfile);
995 : 142 : if (c->next != NULL)
996 : 102 : fputc (' ', dumpfile);
997 : : }
998 : 40 : }
999 : :
1000 : :
1001 : : /* Show the f2k_derived namespace with procedure bindings. */
1002 : :
1003 : : static void
1004 : 0 : show_typebound_proc (gfc_typebound_proc* tb, const char* name)
1005 : : {
1006 : 0 : show_indent ();
1007 : :
1008 : 0 : if (tb->is_generic)
1009 : 0 : fputs ("GENERIC", dumpfile);
1010 : : else
1011 : : {
1012 : 0 : fputs ("PROCEDURE, ", dumpfile);
1013 : 0 : if (tb->nopass)
1014 : 0 : fputs ("NOPASS", dumpfile);
1015 : : else
1016 : : {
1017 : 0 : if (tb->pass_arg)
1018 : 0 : fprintf (dumpfile, "PASS(%s)", tb->pass_arg);
1019 : : else
1020 : 0 : fputs ("PASS", dumpfile);
1021 : : }
1022 : 0 : if (tb->non_overridable)
1023 : 0 : fputs (", NON_OVERRIDABLE", dumpfile);
1024 : : }
1025 : :
1026 : 0 : if (tb->access == ACCESS_PUBLIC)
1027 : 0 : fputs (", PUBLIC", dumpfile);
1028 : : else
1029 : 0 : fputs (", PRIVATE", dumpfile);
1030 : :
1031 : 0 : fprintf (dumpfile, " :: %s => ", name);
1032 : :
1033 : 0 : if (tb->is_generic)
1034 : : {
1035 : 0 : gfc_tbp_generic* g;
1036 : 0 : for (g = tb->u.generic; g; g = g->next)
1037 : : {
1038 : 0 : fputs (g->specific_st->name, dumpfile);
1039 : 0 : if (g->next)
1040 : 0 : fputs (", ", dumpfile);
1041 : : }
1042 : : }
1043 : : else
1044 : 0 : fputs (tb->u.specific->n.sym->name, dumpfile);
1045 : 0 : }
1046 : :
1047 : : static void
1048 : 0 : show_typebound_symtree (gfc_symtree* st)
1049 : : {
1050 : 0 : gcc_assert (st->n.tb);
1051 : 0 : show_typebound_proc (st->n.tb, st->name);
1052 : 0 : }
1053 : :
1054 : : static void
1055 : 24 : show_f2k_derived (gfc_namespace* f2k)
1056 : : {
1057 : 24 : gfc_finalizer* f;
1058 : 24 : int op;
1059 : :
1060 : 24 : show_indent ();
1061 : 24 : fputs ("Procedure bindings:", dumpfile);
1062 : 24 : ++show_level;
1063 : :
1064 : : /* Finalizer bindings. */
1065 : 24 : for (f = f2k->finalizers; f; f = f->next)
1066 : : {
1067 : 0 : show_indent ();
1068 : 0 : fprintf (dumpfile, "FINAL %s", f->proc_tree->n.sym->name);
1069 : : }
1070 : :
1071 : : /* Type-bound procedures. */
1072 : 24 : gfc_traverse_symtree (f2k->tb_sym_root, &show_typebound_symtree);
1073 : :
1074 : 24 : --show_level;
1075 : :
1076 : 24 : show_indent ();
1077 : 24 : fputs ("Operator bindings:", dumpfile);
1078 : 24 : ++show_level;
1079 : :
1080 : : /* User-defined operators. */
1081 : 24 : gfc_traverse_symtree (f2k->tb_uop_root, &show_typebound_symtree);
1082 : :
1083 : : /* Intrinsic operators. */
1084 : 720 : for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; ++op)
1085 : 672 : if (f2k->tb_op[op])
1086 : 0 : show_typebound_proc (f2k->tb_op[op],
1087 : : gfc_op2string ((gfc_intrinsic_op) op));
1088 : :
1089 : 24 : --show_level;
1090 : 24 : }
1091 : :
1092 : :
1093 : : /* Show a symbol. If a symbol is an ENTRY, SUBROUTINE or FUNCTION, we
1094 : : show the interface. Information needed to reconstruct the list of
1095 : : specific interfaces associated with a generic symbol is done within
1096 : : that symbol. */
1097 : :
1098 : : static void
1099 : 332 : show_symbol (gfc_symbol *sym)
1100 : : {
1101 : 332 : gfc_formal_arglist *formal;
1102 : 332 : gfc_interface *intr;
1103 : 332 : int i,len;
1104 : :
1105 : 332 : if (sym == NULL)
1106 : : return;
1107 : :
1108 : 332 : fprintf (dumpfile, "|| symbol: '%s' ", sym->name);
1109 : 332 : len = strlen (sym->name);
1110 : 1696 : for (i=len; i<12; i++)
1111 : 1364 : fputc(' ', dumpfile);
1112 : :
1113 : 332 : if (sym->binding_label)
1114 : 0 : fprintf (dumpfile,"|| binding_label: '%s' ", sym->binding_label);
1115 : :
1116 : 332 : ++show_level;
1117 : :
1118 : 332 : show_indent ();
1119 : 332 : fputs ("type spec : ", dumpfile);
1120 : 332 : show_typespec (&sym->ts);
1121 : :
1122 : 332 : show_indent ();
1123 : 332 : fputs ("attributes: ", dumpfile);
1124 : 332 : show_attr (&sym->attr, sym->module);
1125 : :
1126 : 332 : if (sym->value)
1127 : : {
1128 : 112 : show_indent ();
1129 : 112 : fputs ("value: ", dumpfile);
1130 : 112 : show_expr (sym->value);
1131 : : }
1132 : :
1133 : 332 : if (sym->ts.type != BT_CLASS && sym->as)
1134 : : {
1135 : 0 : show_indent ();
1136 : 0 : fputs ("Array spec:", dumpfile);
1137 : 0 : show_array_spec (sym->as);
1138 : : }
1139 : 332 : else if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)
1140 : : {
1141 : 0 : show_indent ();
1142 : 0 : fputs ("Array spec:", dumpfile);
1143 : 0 : show_array_spec (CLASS_DATA (sym)->as);
1144 : : }
1145 : :
1146 : 332 : if (sym->generic)
1147 : : {
1148 : 10 : show_indent ();
1149 : 10 : fputs ("Generic interfaces:", dumpfile);
1150 : 20 : for (intr = sym->generic; intr; intr = intr->next)
1151 : 10 : fprintf (dumpfile, " %s", intr->sym->name);
1152 : : }
1153 : :
1154 : 332 : if (sym->result)
1155 : : {
1156 : 44 : show_indent ();
1157 : 44 : fprintf (dumpfile, "result: %s", sym->result->name);
1158 : : }
1159 : :
1160 : 332 : if (sym->components)
1161 : : {
1162 : 40 : show_indent ();
1163 : 40 : fputs ("components: ", dumpfile);
1164 : 40 : show_components (sym);
1165 : : }
1166 : :
1167 : 332 : if (sym->f2k_derived)
1168 : : {
1169 : 24 : show_indent ();
1170 : 24 : if (sym->hash_value)
1171 : 6 : fprintf (dumpfile, "hash: %d", sym->hash_value);
1172 : 24 : show_f2k_derived (sym->f2k_derived);
1173 : : }
1174 : :
1175 : 332 : if (sym->formal)
1176 : : {
1177 : 20 : show_indent ();
1178 : 20 : fputs ("Formal arglist:", dumpfile);
1179 : :
1180 : 54 : for (formal = sym->formal; formal; formal = formal->next)
1181 : : {
1182 : 34 : if (formal->sym != NULL)
1183 : 34 : fprintf (dumpfile, " %s", formal->sym->name);
1184 : : else
1185 : 0 : fputs (" [Alt Return]", dumpfile);
1186 : : }
1187 : : }
1188 : :
1189 : 332 : if (sym->formal_ns && (sym->formal_ns->proc_name != sym)
1190 : 0 : && sym->attr.proc != PROC_ST_FUNCTION
1191 : 0 : && !sym->attr.entry)
1192 : : {
1193 : 0 : show_indent ();
1194 : 0 : fputs ("Formal namespace", dumpfile);
1195 : 0 : show_namespace (sym->formal_ns);
1196 : : }
1197 : :
1198 : 332 : if (sym->attr.flavor == FL_VARIABLE
1199 : 60 : && sym->param_list)
1200 : : {
1201 : 0 : show_indent ();
1202 : 0 : fputs ("PDT parameters", dumpfile);
1203 : 0 : show_actual_arglist (sym->param_list);
1204 : : }
1205 : :
1206 : 332 : if (sym->attr.flavor == FL_NAMELIST)
1207 : : {
1208 : 0 : gfc_namelist *nl;
1209 : 0 : show_indent ();
1210 : 0 : fputs ("variables : ", dumpfile);
1211 : 0 : for (nl = sym->namelist; nl; nl = nl->next)
1212 : 0 : fprintf (dumpfile, " %s",nl->sym->name);
1213 : : }
1214 : :
1215 : 332 : --show_level;
1216 : : }
1217 : :
1218 : :
1219 : : /* Show a user-defined operator. Just prints an operator
1220 : : and the name of the associated subroutine, really. */
1221 : :
1222 : : static void
1223 : 0 : show_uop (gfc_user_op *uop)
1224 : : {
1225 : 0 : gfc_interface *intr;
1226 : :
1227 : 0 : show_indent ();
1228 : 0 : fprintf (dumpfile, "%s:", uop->name);
1229 : :
1230 : 0 : for (intr = uop->op; intr; intr = intr->next)
1231 : 0 : fprintf (dumpfile, " %s", intr->sym->name);
1232 : 0 : }
1233 : :
1234 : :
1235 : : /* Workhorse function for traversing the user operator symtree. */
1236 : :
1237 : : static void
1238 : 300806 : traverse_uop (gfc_symtree *st, void (*func) (gfc_user_op *))
1239 : : {
1240 : 301288 : if (st == NULL)
1241 : 300806 : return;
1242 : :
1243 : 482 : (*func) (st->n.uop);
1244 : :
1245 : 482 : traverse_uop (st->left, func);
1246 : 482 : traverse_uop (st->right, func);
1247 : : }
1248 : :
1249 : :
1250 : : /* Traverse the tree of user operator nodes. */
1251 : :
1252 : : void
1253 : 300324 : gfc_traverse_user_op (gfc_namespace *ns, void (*func) (gfc_user_op *))
1254 : : {
1255 : 300324 : traverse_uop (ns->uop_root, func);
1256 : 300324 : }
1257 : :
1258 : :
1259 : : /* Function to display a common block. */
1260 : :
1261 : : static void
1262 : 0 : show_common (gfc_symtree *st)
1263 : : {
1264 : 0 : gfc_symbol *s;
1265 : :
1266 : 0 : show_indent ();
1267 : 0 : fprintf (dumpfile, "common: /%s/ ", st->name);
1268 : :
1269 : 0 : s = st->n.common->head;
1270 : 0 : while (s)
1271 : : {
1272 : 0 : fprintf (dumpfile, "%s", s->name);
1273 : 0 : s = s->common_next;
1274 : 0 : if (s)
1275 : 0 : fputs (", ", dumpfile);
1276 : : }
1277 : 0 : fputc ('\n', dumpfile);
1278 : 0 : }
1279 : :
1280 : :
1281 : : /* Worker function to display the symbol tree. */
1282 : :
1283 : : static void
1284 : 344 : show_symtree (gfc_symtree *st)
1285 : : {
1286 : 344 : int len, i;
1287 : :
1288 : 344 : show_indent ();
1289 : :
1290 : 344 : len = strlen(st->name);
1291 : 344 : fprintf (dumpfile, "symtree: '%s'", st->name);
1292 : :
1293 : 2148 : for (i=len; i<12; i++)
1294 : 1460 : fputc(' ', dumpfile);
1295 : :
1296 : 344 : if (st->ambiguous)
1297 : 0 : fputs( " Ambiguous", dumpfile);
1298 : :
1299 : 344 : if (st->n.sym->ns != gfc_current_ns)
1300 : 12 : fprintf (dumpfile, "|| symbol: '%s' from namespace '%s'", st->n.sym->name,
1301 : 12 : st->n.sym->ns->proc_name->name);
1302 : : else
1303 : 332 : show_symbol (st->n.sym);
1304 : 344 : }
1305 : :
1306 : :
1307 : : /******************* Show gfc_code structures **************/
1308 : :
1309 : :
1310 : : /* Show a list of code structures. Mutually recursive with
1311 : : show_code_node(). */
1312 : :
1313 : : static void
1314 : 112 : show_code (int level, gfc_code *c)
1315 : : {
1316 : 276 : for (; c; c = c->next)
1317 : 164 : show_code_node (level, c);
1318 : 60 : }
1319 : :
1320 : : static void
1321 : 0 : show_iterator (gfc_namespace *ns)
1322 : : {
1323 : 0 : for (gfc_symbol *sym = ns->omp_affinity_iterators; sym; sym = sym->tlink)
1324 : : {
1325 : 0 : gfc_constructor *c;
1326 : 0 : if (sym != ns->omp_affinity_iterators)
1327 : 0 : fputc (',', dumpfile);
1328 : 0 : fputs (sym->name, dumpfile);
1329 : 0 : fputc ('=', dumpfile);
1330 : 0 : c = gfc_constructor_first (sym->value->value.constructor);
1331 : 0 : show_expr (c->expr);
1332 : 0 : fputc (':', dumpfile);
1333 : 0 : c = gfc_constructor_next (c);
1334 : 0 : show_expr (c->expr);
1335 : 0 : c = gfc_constructor_next (c);
1336 : 0 : if (c)
1337 : : {
1338 : 0 : fputc (':', dumpfile);
1339 : 0 : show_expr (c->expr);
1340 : : }
1341 : : }
1342 : 0 : }
1343 : :
1344 : : static void
1345 : 0 : show_omp_namelist (int list_type, gfc_omp_namelist *n)
1346 : : {
1347 : 0 : gfc_namespace *ns_iter = NULL, *ns_curr = gfc_current_ns;
1348 : 0 : gfc_omp_namelist *n2 = n;
1349 : 0 : for (; n; n = n->next)
1350 : : {
1351 : 0 : gfc_current_ns = ns_curr;
1352 : 0 : if (list_type == OMP_LIST_AFFINITY || list_type == OMP_LIST_DEPEND)
1353 : : {
1354 : 0 : gfc_current_ns = n->u2.ns ? n->u2.ns : ns_curr;
1355 : 0 : if (n->u2.ns != ns_iter)
1356 : : {
1357 : 0 : if (n != n2)
1358 : : {
1359 : 0 : fputs (") ", dumpfile);
1360 : 0 : if (list_type == OMP_LIST_AFFINITY)
1361 : 0 : fputs ("AFFINITY (", dumpfile);
1362 : 0 : else if (n->u.depend_doacross_op == OMP_DOACROSS_SINK_FIRST)
1363 : 0 : fputs ("DOACROSS (", dumpfile);
1364 : : else
1365 : 0 : fputs ("DEPEND (", dumpfile);
1366 : : }
1367 : 0 : if (n->u2.ns)
1368 : : {
1369 : 0 : fputs ("ITERATOR(", dumpfile);
1370 : 0 : show_iterator (n->u2.ns);
1371 : 0 : fputc (')', dumpfile);
1372 : 0 : fputc (list_type == OMP_LIST_AFFINITY ? ':' : ',', dumpfile);
1373 : : }
1374 : : }
1375 : 0 : ns_iter = n->u2.ns;
1376 : : }
1377 : 0 : if (list_type == OMP_LIST_ALLOCATE)
1378 : : {
1379 : 0 : if (n->u2.allocator)
1380 : : {
1381 : 0 : fputs ("allocator(", dumpfile);
1382 : 0 : show_expr (n->u2.allocator);
1383 : 0 : fputc (')', dumpfile);
1384 : : }
1385 : 0 : if (n->expr && n->u.align)
1386 : 0 : fputc (',', dumpfile);
1387 : 0 : if (n->u.align)
1388 : : {
1389 : 0 : fputs ("align(", dumpfile);
1390 : 0 : show_expr (n->u.align);
1391 : 0 : fputc (')', dumpfile);
1392 : : }
1393 : 0 : if (n->u2.allocator || n->u.align)
1394 : 0 : fputc (':', dumpfile);
1395 : 0 : if (n->expr)
1396 : 0 : show_expr (n->expr);
1397 : : else
1398 : 0 : fputs (n->sym->name, dumpfile);
1399 : 0 : if (n->next)
1400 : 0 : fputs (") ALLOCATE(", dumpfile);
1401 : 0 : continue;
1402 : : }
1403 : 0 : if ((list_type == OMP_LIST_MAP || list_type == OMP_LIST_CACHE)
1404 : 0 : && n->u.map.readonly)
1405 : 0 : fputs ("readonly,", dumpfile);
1406 : 0 : if (list_type == OMP_LIST_REDUCTION)
1407 : 0 : switch (n->u.reduction_op)
1408 : : {
1409 : 0 : case OMP_REDUCTION_PLUS:
1410 : 0 : case OMP_REDUCTION_TIMES:
1411 : 0 : case OMP_REDUCTION_MINUS:
1412 : 0 : case OMP_REDUCTION_AND:
1413 : 0 : case OMP_REDUCTION_OR:
1414 : 0 : case OMP_REDUCTION_EQV:
1415 : 0 : case OMP_REDUCTION_NEQV:
1416 : 0 : fprintf (dumpfile, "%s:",
1417 : : gfc_op2string ((gfc_intrinsic_op) n->u.reduction_op));
1418 : 0 : break;
1419 : 0 : case OMP_REDUCTION_MAX: fputs ("max:", dumpfile); break;
1420 : 0 : case OMP_REDUCTION_MIN: fputs ("min:", dumpfile); break;
1421 : 0 : case OMP_REDUCTION_IAND: fputs ("iand:", dumpfile); break;
1422 : 0 : case OMP_REDUCTION_IOR: fputs ("ior:", dumpfile); break;
1423 : 0 : case OMP_REDUCTION_IEOR: fputs ("ieor:", dumpfile); break;
1424 : 0 : case OMP_REDUCTION_USER:
1425 : 0 : if (n->u2.udr)
1426 : 0 : fprintf (dumpfile, "%s:", n->u2.udr->udr->name);
1427 : : break;
1428 : : default: break;
1429 : : }
1430 : 0 : else if (list_type == OMP_LIST_DEPEND)
1431 : 0 : switch (n->u.depend_doacross_op)
1432 : : {
1433 : 0 : case OMP_DEPEND_IN: fputs ("in:", dumpfile); break;
1434 : 0 : case OMP_DEPEND_OUT: fputs ("out:", dumpfile); break;
1435 : 0 : case OMP_DEPEND_INOUT: fputs ("inout:", dumpfile); break;
1436 : 0 : case OMP_DEPEND_INOUTSET: fputs ("inoutset:", dumpfile); break;
1437 : 0 : case OMP_DEPEND_DEPOBJ: fputs ("depobj:", dumpfile); break;
1438 : 0 : case OMP_DEPEND_MUTEXINOUTSET:
1439 : 0 : fputs ("mutexinoutset:", dumpfile);
1440 : 0 : break;
1441 : 0 : case OMP_DEPEND_SINK_FIRST:
1442 : 0 : case OMP_DOACROSS_SINK_FIRST:
1443 : 0 : fputs ("sink:", dumpfile);
1444 : 0 : while (1)
1445 : : {
1446 : 0 : if (!n->sym)
1447 : 0 : fputs ("omp_cur_iteration", dumpfile);
1448 : : else
1449 : 0 : fprintf (dumpfile, "%s", n->sym->name);
1450 : 0 : if (n->expr)
1451 : : {
1452 : 0 : fputc ('+', dumpfile);
1453 : 0 : show_expr (n->expr);
1454 : : }
1455 : 0 : if (n->next == NULL)
1456 : : break;
1457 : 0 : else if (n->next->u.depend_doacross_op != OMP_DOACROSS_SINK)
1458 : : {
1459 : 0 : if (n->next->u.depend_doacross_op
1460 : : == OMP_DOACROSS_SINK_FIRST)
1461 : 0 : fputs (") DOACROSS(", dumpfile);
1462 : : else
1463 : 0 : fputs (") DEPEND(", dumpfile);
1464 : : break;
1465 : : }
1466 : 0 : fputc (',', dumpfile);
1467 : 0 : n = n->next;
1468 : : }
1469 : 0 : continue;
1470 : : default: break;
1471 : : }
1472 : 0 : else if (list_type == OMP_LIST_MAP)
1473 : 0 : switch (n->u.map.op)
1474 : : {
1475 : 0 : case OMP_MAP_ALLOC: fputs ("alloc:", dumpfile); break;
1476 : 0 : case OMP_MAP_TO: fputs ("to:", dumpfile); break;
1477 : 0 : case OMP_MAP_FROM: fputs ("from:", dumpfile); break;
1478 : 0 : case OMP_MAP_TOFROM: fputs ("tofrom:", dumpfile); break;
1479 : 0 : case OMP_MAP_PRESENT_ALLOC: fputs ("present,alloc:", dumpfile); break;
1480 : 0 : case OMP_MAP_PRESENT_TO: fputs ("present,to:", dumpfile); break;
1481 : 0 : case OMP_MAP_PRESENT_FROM: fputs ("present,from:", dumpfile); break;
1482 : 0 : case OMP_MAP_PRESENT_TOFROM:
1483 : 0 : fputs ("present,tofrom:", dumpfile); break;
1484 : 0 : case OMP_MAP_ALWAYS_TO: fputs ("always,to:", dumpfile); break;
1485 : 0 : case OMP_MAP_ALWAYS_FROM: fputs ("always,from:", dumpfile); break;
1486 : 0 : case OMP_MAP_ALWAYS_TOFROM: fputs ("always,tofrom:", dumpfile); break;
1487 : 0 : case OMP_MAP_ALWAYS_PRESENT_TO:
1488 : 0 : fputs ("always,present,to:", dumpfile); break;
1489 : 0 : case OMP_MAP_ALWAYS_PRESENT_FROM:
1490 : 0 : fputs ("always,present,from:", dumpfile); break;
1491 : 0 : case OMP_MAP_ALWAYS_PRESENT_TOFROM:
1492 : 0 : fputs ("always,present,tofrom:", dumpfile); break;
1493 : 0 : case OMP_MAP_DELETE: fputs ("delete:", dumpfile); break;
1494 : 0 : case OMP_MAP_RELEASE: fputs ("release:", dumpfile); break;
1495 : : default: break;
1496 : : }
1497 : 0 : else if (list_type == OMP_LIST_LINEAR && n->u.linear.old_modifier)
1498 : 0 : switch (n->u.linear.op)
1499 : : {
1500 : 0 : case OMP_LINEAR_REF: fputs ("ref(", dumpfile); break;
1501 : 0 : case OMP_LINEAR_VAL: fputs ("val(", dumpfile); break;
1502 : 0 : case OMP_LINEAR_UVAL: fputs ("uval(", dumpfile); break;
1503 : : default: break;
1504 : : }
1505 : 0 : else if (list_type == OMP_LIST_USES_ALLOCATORS)
1506 : : {
1507 : 0 : if (n->u.memspace_sym)
1508 : : {
1509 : 0 : fputs ("memspace(", dumpfile);
1510 : 0 : fputs (n->sym->name, dumpfile);
1511 : 0 : fputc (')', dumpfile);
1512 : : }
1513 : 0 : if (n->u.memspace_sym && n->u2.traits_sym)
1514 : 0 : fputc (',', dumpfile);
1515 : 0 : if (n->u2.traits_sym)
1516 : : {
1517 : 0 : fputs ("traits(", dumpfile);
1518 : 0 : fputs (n->u2.traits_sym->name, dumpfile);
1519 : 0 : fputc (')', dumpfile);
1520 : : }
1521 : 0 : if (n->u.memspace_sym || n->u2.traits_sym)
1522 : 0 : fputc (':', dumpfile);
1523 : 0 : fputs (n->sym->name, dumpfile);
1524 : 0 : if (n->next)
1525 : 0 : fputs (", ", dumpfile);
1526 : 0 : continue;
1527 : : }
1528 : 0 : fprintf (dumpfile, "%s", n->sym ? n->sym->name : "omp_all_memory");
1529 : 0 : if (list_type == OMP_LIST_LINEAR && n->u.linear.op != OMP_LINEAR_DEFAULT)
1530 : 0 : fputc (')', dumpfile);
1531 : 0 : if (n->expr)
1532 : : {
1533 : 0 : fputc (':', dumpfile);
1534 : 0 : show_expr (n->expr);
1535 : : }
1536 : 0 : if (n->next)
1537 : 0 : fputc (',', dumpfile);
1538 : : }
1539 : 0 : gfc_current_ns = ns_curr;
1540 : 0 : }
1541 : :
1542 : : static void
1543 : 0 : show_omp_assumes (gfc_omp_assumptions *assume)
1544 : : {
1545 : 0 : for (int i = 0; i < assume->n_absent; i++)
1546 : : {
1547 : 0 : fputs (" ABSENT (", dumpfile);
1548 : 0 : fputs (gfc_ascii_statement (assume->absent[i], true), dumpfile);
1549 : 0 : fputc (')', dumpfile);
1550 : : }
1551 : 0 : for (int i = 0; i < assume->n_contains; i++)
1552 : : {
1553 : 0 : fputs (" CONTAINS (", dumpfile);
1554 : 0 : fputs (gfc_ascii_statement (assume->contains[i], true), dumpfile);
1555 : 0 : fputc (')', dumpfile);
1556 : : }
1557 : 0 : for (gfc_expr_list *el = assume->holds; el; el = el->next)
1558 : : {
1559 : 0 : fputs (" HOLDS (", dumpfile);
1560 : 0 : show_expr (el->expr);
1561 : 0 : fputc (')', dumpfile);
1562 : : }
1563 : 0 : if (assume->no_openmp)
1564 : 0 : fputs (" NO_OPENMP", dumpfile);
1565 : 0 : if (assume->no_openmp_routines)
1566 : 0 : fputs (" NO_OPENMP_ROUTINES", dumpfile);
1567 : 0 : if (assume->no_parallelism)
1568 : 0 : fputs (" NO_PARALLELISM", dumpfile);
1569 : 0 : }
1570 : :
1571 : : /* Show OpenMP or OpenACC clauses. */
1572 : :
1573 : : static void
1574 : 0 : show_omp_clauses (gfc_omp_clauses *omp_clauses)
1575 : : {
1576 : 0 : int list_type, i;
1577 : :
1578 : 0 : switch (omp_clauses->cancel)
1579 : : {
1580 : : case OMP_CANCEL_UNKNOWN:
1581 : : break;
1582 : 0 : case OMP_CANCEL_PARALLEL:
1583 : 0 : fputs (" PARALLEL", dumpfile);
1584 : 0 : break;
1585 : 0 : case OMP_CANCEL_SECTIONS:
1586 : 0 : fputs (" SECTIONS", dumpfile);
1587 : 0 : break;
1588 : 0 : case OMP_CANCEL_DO:
1589 : 0 : fputs (" DO", dumpfile);
1590 : 0 : break;
1591 : 0 : case OMP_CANCEL_TASKGROUP:
1592 : 0 : fputs (" TASKGROUP", dumpfile);
1593 : 0 : break;
1594 : : }
1595 : 0 : if (omp_clauses->if_expr)
1596 : : {
1597 : 0 : fputs (" IF(", dumpfile);
1598 : 0 : show_expr (omp_clauses->if_expr);
1599 : 0 : fputc (')', dumpfile);
1600 : : }
1601 : 0 : for (i = 0; i < OMP_IF_LAST; i++)
1602 : 0 : if (omp_clauses->if_exprs[i])
1603 : : {
1604 : 0 : static const char *ifs[] = {
1605 : : "CANCEL",
1606 : : "PARALLEL",
1607 : : "SIMD",
1608 : : "TASK",
1609 : : "TASKLOOP",
1610 : : "TARGET",
1611 : : "TARGET DATA",
1612 : : "TARGET UPDATE",
1613 : : "TARGET ENTER DATA",
1614 : : "TARGET EXIT DATA"
1615 : : };
1616 : 0 : fputs (" IF(", dumpfile);
1617 : 0 : fputs (ifs[i], dumpfile);
1618 : 0 : fputs (": ", dumpfile);
1619 : 0 : show_expr (omp_clauses->if_exprs[i]);
1620 : 0 : fputc (')', dumpfile);
1621 : : }
1622 : 0 : if (omp_clauses->self_expr)
1623 : : {
1624 : 0 : fputs (" SELF(", dumpfile);
1625 : 0 : show_expr (omp_clauses->self_expr);
1626 : 0 : fputc (')', dumpfile);
1627 : : }
1628 : 0 : if (omp_clauses->final_expr)
1629 : : {
1630 : 0 : fputs (" FINAL(", dumpfile);
1631 : 0 : show_expr (omp_clauses->final_expr);
1632 : 0 : fputc (')', dumpfile);
1633 : : }
1634 : 0 : if (omp_clauses->num_threads)
1635 : : {
1636 : 0 : fputs (" NUM_THREADS(", dumpfile);
1637 : 0 : show_expr (omp_clauses->num_threads);
1638 : 0 : fputc (')', dumpfile);
1639 : : }
1640 : 0 : if (omp_clauses->async)
1641 : : {
1642 : 0 : fputs (" ASYNC", dumpfile);
1643 : 0 : if (omp_clauses->async_expr)
1644 : : {
1645 : 0 : fputc ('(', dumpfile);
1646 : 0 : show_expr (omp_clauses->async_expr);
1647 : 0 : fputc (')', dumpfile);
1648 : : }
1649 : : }
1650 : 0 : if (omp_clauses->num_gangs_expr)
1651 : : {
1652 : 0 : fputs (" NUM_GANGS(", dumpfile);
1653 : 0 : show_expr (omp_clauses->num_gangs_expr);
1654 : 0 : fputc (')', dumpfile);
1655 : : }
1656 : 0 : if (omp_clauses->num_workers_expr)
1657 : : {
1658 : 0 : fputs (" NUM_WORKERS(", dumpfile);
1659 : 0 : show_expr (omp_clauses->num_workers_expr);
1660 : 0 : fputc (')', dumpfile);
1661 : : }
1662 : 0 : if (omp_clauses->vector_length_expr)
1663 : : {
1664 : 0 : fputs (" VECTOR_LENGTH(", dumpfile);
1665 : 0 : show_expr (omp_clauses->vector_length_expr);
1666 : 0 : fputc (')', dumpfile);
1667 : : }
1668 : 0 : if (omp_clauses->gang)
1669 : : {
1670 : 0 : fputs (" GANG", dumpfile);
1671 : 0 : if (omp_clauses->gang_num_expr || omp_clauses->gang_static_expr)
1672 : : {
1673 : 0 : fputc ('(', dumpfile);
1674 : 0 : if (omp_clauses->gang_num_expr)
1675 : : {
1676 : 0 : fprintf (dumpfile, "num:");
1677 : 0 : show_expr (omp_clauses->gang_num_expr);
1678 : : }
1679 : 0 : if (omp_clauses->gang_num_expr && omp_clauses->gang_static)
1680 : 0 : fputc (',', dumpfile);
1681 : 0 : if (omp_clauses->gang_static)
1682 : : {
1683 : 0 : fprintf (dumpfile, "static:");
1684 : 0 : if (omp_clauses->gang_static_expr)
1685 : 0 : show_expr (omp_clauses->gang_static_expr);
1686 : : else
1687 : 0 : fputc ('*', dumpfile);
1688 : : }
1689 : 0 : fputc (')', dumpfile);
1690 : : }
1691 : : }
1692 : 0 : if (omp_clauses->worker)
1693 : : {
1694 : 0 : fputs (" WORKER", dumpfile);
1695 : 0 : if (omp_clauses->worker_expr)
1696 : : {
1697 : 0 : fputc ('(', dumpfile);
1698 : 0 : show_expr (omp_clauses->worker_expr);
1699 : 0 : fputc (')', dumpfile);
1700 : : }
1701 : : }
1702 : 0 : if (omp_clauses->vector)
1703 : : {
1704 : 0 : fputs (" VECTOR", dumpfile);
1705 : 0 : if (omp_clauses->vector_expr)
1706 : : {
1707 : 0 : fputc ('(', dumpfile);
1708 : 0 : show_expr (omp_clauses->vector_expr);
1709 : 0 : fputc (')', dumpfile);
1710 : : }
1711 : : }
1712 : 0 : if (omp_clauses->sched_kind != OMP_SCHED_NONE)
1713 : : {
1714 : 0 : const char *type;
1715 : 0 : switch (omp_clauses->sched_kind)
1716 : : {
1717 : : case OMP_SCHED_STATIC: type = "STATIC"; break;
1718 : 0 : case OMP_SCHED_DYNAMIC: type = "DYNAMIC"; break;
1719 : 0 : case OMP_SCHED_GUIDED: type = "GUIDED"; break;
1720 : 0 : case OMP_SCHED_RUNTIME: type = "RUNTIME"; break;
1721 : 0 : case OMP_SCHED_AUTO: type = "AUTO"; break;
1722 : 0 : default:
1723 : 0 : gcc_unreachable ();
1724 : : }
1725 : 0 : fputs (" SCHEDULE (", dumpfile);
1726 : 0 : if (omp_clauses->sched_simd)
1727 : : {
1728 : 0 : if (omp_clauses->sched_monotonic
1729 : 0 : || omp_clauses->sched_nonmonotonic)
1730 : 0 : fputs ("SIMD, ", dumpfile);
1731 : : else
1732 : 0 : fputs ("SIMD: ", dumpfile);
1733 : : }
1734 : 0 : if (omp_clauses->sched_monotonic)
1735 : 0 : fputs ("MONOTONIC: ", dumpfile);
1736 : 0 : else if (omp_clauses->sched_nonmonotonic)
1737 : 0 : fputs ("NONMONOTONIC: ", dumpfile);
1738 : 0 : fputs (type, dumpfile);
1739 : 0 : if (omp_clauses->chunk_size)
1740 : : {
1741 : 0 : fputc (',', dumpfile);
1742 : 0 : show_expr (omp_clauses->chunk_size);
1743 : : }
1744 : 0 : fputc (')', dumpfile);
1745 : : }
1746 : 0 : if (omp_clauses->default_sharing != OMP_DEFAULT_UNKNOWN)
1747 : : {
1748 : 0 : const char *type;
1749 : 0 : switch (omp_clauses->default_sharing)
1750 : : {
1751 : : case OMP_DEFAULT_NONE: type = "NONE"; break;
1752 : 0 : case OMP_DEFAULT_PRIVATE: type = "PRIVATE"; break;
1753 : 0 : case OMP_DEFAULT_SHARED: type = "SHARED"; break;
1754 : 0 : case OMP_DEFAULT_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
1755 : 0 : case OMP_DEFAULT_PRESENT: type = "PRESENT"; break;
1756 : 0 : default:
1757 : 0 : gcc_unreachable ();
1758 : : }
1759 : 0 : fprintf (dumpfile, " DEFAULT(%s)", type);
1760 : : }
1761 : 0 : if (omp_clauses->tile_list)
1762 : : {
1763 : 0 : gfc_expr_list *list;
1764 : 0 : fputs (" TILE(", dumpfile);
1765 : 0 : for (list = omp_clauses->tile_list; list; list = list->next)
1766 : : {
1767 : 0 : show_expr (list->expr);
1768 : 0 : if (list->next)
1769 : 0 : fputs (", ", dumpfile);
1770 : : }
1771 : 0 : fputc (')', dumpfile);
1772 : : }
1773 : 0 : if (omp_clauses->wait_list)
1774 : : {
1775 : 0 : gfc_expr_list *list;
1776 : 0 : fputs (" WAIT(", dumpfile);
1777 : 0 : for (list = omp_clauses->wait_list; list; list = list->next)
1778 : : {
1779 : 0 : show_expr (list->expr);
1780 : 0 : if (list->next)
1781 : 0 : fputs (", ", dumpfile);
1782 : : }
1783 : 0 : fputc (')', dumpfile);
1784 : : }
1785 : 0 : if (omp_clauses->seq)
1786 : 0 : fputs (" SEQ", dumpfile);
1787 : 0 : if (omp_clauses->independent)
1788 : 0 : fputs (" INDEPENDENT", dumpfile);
1789 : 0 : if (omp_clauses->order_concurrent)
1790 : : {
1791 : 0 : fputs (" ORDER(", dumpfile);
1792 : 0 : if (omp_clauses->order_unconstrained)
1793 : 0 : fputs ("UNCONSTRAINED:", dumpfile);
1794 : 0 : else if (omp_clauses->order_reproducible)
1795 : 0 : fputs ("REPRODUCIBLE:", dumpfile);
1796 : 0 : fputs ("CONCURRENT)", dumpfile);
1797 : : }
1798 : 0 : if (omp_clauses->ordered)
1799 : : {
1800 : 0 : if (omp_clauses->orderedc)
1801 : 0 : fprintf (dumpfile, " ORDERED(%d)", omp_clauses->orderedc);
1802 : : else
1803 : 0 : fputs (" ORDERED", dumpfile);
1804 : : }
1805 : 0 : if (omp_clauses->untied)
1806 : 0 : fputs (" UNTIED", dumpfile);
1807 : 0 : if (omp_clauses->mergeable)
1808 : 0 : fputs (" MERGEABLE", dumpfile);
1809 : 0 : if (omp_clauses->collapse)
1810 : 0 : fprintf (dumpfile, " COLLAPSE(%d)", omp_clauses->collapse);
1811 : 0 : for (list_type = 0; list_type < OMP_LIST_NUM; list_type++)
1812 : 0 : if (omp_clauses->lists[list_type] != NULL
1813 : 0 : && list_type != OMP_LIST_COPYPRIVATE)
1814 : : {
1815 : 0 : const char *type = NULL;
1816 : 0 : switch (list_type)
1817 : : {
1818 : : case OMP_LIST_PRIVATE: type = "PRIVATE"; break;
1819 : 0 : case OMP_LIST_FIRSTPRIVATE: type = "FIRSTPRIVATE"; break;
1820 : 0 : case OMP_LIST_LASTPRIVATE: type = "LASTPRIVATE"; break;
1821 : 0 : case OMP_LIST_COPYPRIVATE: type = "COPYPRIVATE"; break;
1822 : 0 : case OMP_LIST_SHARED: type = "SHARED"; break;
1823 : 0 : case OMP_LIST_COPYIN: type = "COPYIN"; break;
1824 : 0 : case OMP_LIST_UNIFORM: type = "UNIFORM"; break;
1825 : 0 : case OMP_LIST_AFFINITY: type = "AFFINITY"; break;
1826 : 0 : case OMP_LIST_ALIGNED: type = "ALIGNED"; break;
1827 : 0 : case OMP_LIST_LINEAR: type = "LINEAR"; break;
1828 : 0 : case OMP_LIST_DEPEND:
1829 : 0 : if (omp_clauses->lists[list_type]
1830 : 0 : && (omp_clauses->lists[list_type]->u.depend_doacross_op
1831 : : == OMP_DOACROSS_SINK_FIRST))
1832 : : type = "DOACROSS";
1833 : : else
1834 : 0 : type = "DEPEND";
1835 : : break;
1836 : 0 : case OMP_LIST_MAP: type = "MAP"; break;
1837 : 0 : case OMP_LIST_TO: type = "TO"; break;
1838 : 0 : case OMP_LIST_FROM: type = "FROM"; break;
1839 : 0 : case OMP_LIST_REDUCTION:
1840 : 0 : case OMP_LIST_REDUCTION_INSCAN:
1841 : 0 : case OMP_LIST_REDUCTION_TASK: type = "REDUCTION"; break;
1842 : 0 : case OMP_LIST_IN_REDUCTION: type = "IN_REDUCTION"; break;
1843 : 0 : case OMP_LIST_TASK_REDUCTION: type = "TASK_REDUCTION"; break;
1844 : 0 : case OMP_LIST_DEVICE_RESIDENT: type = "DEVICE_RESIDENT"; break;
1845 : 0 : case OMP_LIST_ENTER: type = "ENTER"; break;
1846 : 0 : case OMP_LIST_LINK: type = "LINK"; break;
1847 : 0 : case OMP_LIST_USE_DEVICE: type = "USE_DEVICE"; break;
1848 : 0 : case OMP_LIST_CACHE: type = "CACHE"; break;
1849 : 0 : case OMP_LIST_IS_DEVICE_PTR: type = "IS_DEVICE_PTR"; break;
1850 : 0 : case OMP_LIST_USE_DEVICE_PTR: type = "USE_DEVICE_PTR"; break;
1851 : 0 : case OMP_LIST_HAS_DEVICE_ADDR: type = "HAS_DEVICE_ADDR"; break;
1852 : 0 : case OMP_LIST_USE_DEVICE_ADDR: type = "USE_DEVICE_ADDR"; break;
1853 : 0 : case OMP_LIST_NONTEMPORAL: type = "NONTEMPORAL"; break;
1854 : 0 : case OMP_LIST_ALLOCATE: type = "ALLOCATE"; break;
1855 : 0 : case OMP_LIST_SCAN_IN: type = "INCLUSIVE"; break;
1856 : 0 : case OMP_LIST_SCAN_EX: type = "EXCLUSIVE"; break;
1857 : 0 : case OMP_LIST_USES_ALLOCATORS: type = "USES_ALLOCATORS"; break;
1858 : : default:
1859 : : gcc_unreachable ();
1860 : : }
1861 : 0 : fprintf (dumpfile, " %s(", type);
1862 : 0 : if (list_type == OMP_LIST_REDUCTION_INSCAN)
1863 : 0 : fputs ("inscan, ", dumpfile);
1864 : 0 : if (list_type == OMP_LIST_REDUCTION_TASK)
1865 : 0 : fputs ("task, ", dumpfile);
1866 : 0 : if ((list_type == OMP_LIST_TO || list_type == OMP_LIST_FROM)
1867 : 0 : && omp_clauses->lists[list_type]->u.present_modifier)
1868 : 0 : fputs ("present:", dumpfile);
1869 : 0 : show_omp_namelist (list_type, omp_clauses->lists[list_type]);
1870 : 0 : fputc (')', dumpfile);
1871 : : }
1872 : 0 : if (omp_clauses->safelen_expr)
1873 : : {
1874 : 0 : fputs (" SAFELEN(", dumpfile);
1875 : 0 : show_expr (omp_clauses->safelen_expr);
1876 : 0 : fputc (')', dumpfile);
1877 : : }
1878 : 0 : if (omp_clauses->simdlen_expr)
1879 : : {
1880 : 0 : fputs (" SIMDLEN(", dumpfile);
1881 : 0 : show_expr (omp_clauses->simdlen_expr);
1882 : 0 : fputc (')', dumpfile);
1883 : : }
1884 : 0 : if (omp_clauses->inbranch)
1885 : 0 : fputs (" INBRANCH", dumpfile);
1886 : 0 : if (omp_clauses->notinbranch)
1887 : 0 : fputs (" NOTINBRANCH", dumpfile);
1888 : 0 : if (omp_clauses->proc_bind != OMP_PROC_BIND_UNKNOWN)
1889 : : {
1890 : 0 : const char *type;
1891 : 0 : switch (omp_clauses->proc_bind)
1892 : : {
1893 : : case OMP_PROC_BIND_PRIMARY: type = "PRIMARY"; break;
1894 : 0 : case OMP_PROC_BIND_MASTER: type = "MASTER"; break;
1895 : 0 : case OMP_PROC_BIND_SPREAD: type = "SPREAD"; break;
1896 : 0 : case OMP_PROC_BIND_CLOSE: type = "CLOSE"; break;
1897 : 0 : default:
1898 : 0 : gcc_unreachable ();
1899 : : }
1900 : 0 : fprintf (dumpfile, " PROC_BIND(%s)", type);
1901 : : }
1902 : 0 : if (omp_clauses->bind != OMP_BIND_UNSET)
1903 : : {
1904 : 0 : const char *type;
1905 : 0 : switch (omp_clauses->bind)
1906 : : {
1907 : : case OMP_BIND_TEAMS: type = "TEAMS"; break;
1908 : 0 : case OMP_BIND_PARALLEL: type = "PARALLEL"; break;
1909 : 0 : case OMP_BIND_THREAD: type = "THREAD"; break;
1910 : 0 : default:
1911 : 0 : gcc_unreachable ();
1912 : : }
1913 : 0 : fprintf (dumpfile, " BIND(%s)", type);
1914 : : }
1915 : 0 : if (omp_clauses->num_teams_upper)
1916 : : {
1917 : 0 : fputs (" NUM_TEAMS(", dumpfile);
1918 : 0 : if (omp_clauses->num_teams_lower)
1919 : : {
1920 : 0 : show_expr (omp_clauses->num_teams_lower);
1921 : 0 : fputc (':', dumpfile);
1922 : : }
1923 : 0 : show_expr (omp_clauses->num_teams_upper);
1924 : 0 : fputc (')', dumpfile);
1925 : : }
1926 : 0 : if (omp_clauses->device)
1927 : : {
1928 : 0 : fputs (" DEVICE(", dumpfile);
1929 : 0 : if (omp_clauses->ancestor)
1930 : 0 : fputs ("ANCESTOR:", dumpfile);
1931 : 0 : show_expr (omp_clauses->device);
1932 : 0 : fputc (')', dumpfile);
1933 : : }
1934 : 0 : if (omp_clauses->thread_limit)
1935 : : {
1936 : 0 : fputs (" THREAD_LIMIT(", dumpfile);
1937 : 0 : show_expr (omp_clauses->thread_limit);
1938 : 0 : fputc (')', dumpfile);
1939 : : }
1940 : 0 : if (omp_clauses->dist_sched_kind != OMP_SCHED_NONE)
1941 : : {
1942 : 0 : fputs (" DIST_SCHEDULE (STATIC", dumpfile);
1943 : 0 : if (omp_clauses->dist_chunk_size)
1944 : : {
1945 : 0 : fputc (',', dumpfile);
1946 : 0 : show_expr (omp_clauses->dist_chunk_size);
1947 : : }
1948 : 0 : fputc (')', dumpfile);
1949 : : }
1950 : 0 : for (int i = 0; i < OMP_DEFAULTMAP_CAT_NUM; i++)
1951 : : {
1952 : 0 : const char *dfltmap;
1953 : 0 : if (omp_clauses->defaultmap[i] == OMP_DEFAULTMAP_UNSET)
1954 : 0 : continue;
1955 : 0 : fputs (" DEFAULTMAP (", dumpfile);
1956 : 0 : switch (omp_clauses->defaultmap[i])
1957 : : {
1958 : : case OMP_DEFAULTMAP_ALLOC: dfltmap = "ALLOC"; break;
1959 : 0 : case OMP_DEFAULTMAP_TO: dfltmap = "TO"; break;
1960 : 0 : case OMP_DEFAULTMAP_FROM: dfltmap = "FROM"; break;
1961 : 0 : case OMP_DEFAULTMAP_TOFROM: dfltmap = "TOFROM"; break;
1962 : 0 : case OMP_DEFAULTMAP_FIRSTPRIVATE: dfltmap = "FIRSTPRIVATE"; break;
1963 : 0 : case OMP_DEFAULTMAP_NONE: dfltmap = "NONE"; break;
1964 : 0 : case OMP_DEFAULTMAP_DEFAULT: dfltmap = "DEFAULT"; break;
1965 : 0 : case OMP_DEFAULTMAP_PRESENT: dfltmap = "PRESENT"; break;
1966 : 0 : default: gcc_unreachable ();
1967 : : }
1968 : 0 : fputs (dfltmap, dumpfile);
1969 : 0 : if (i != OMP_DEFAULTMAP_CAT_UNCATEGORIZED)
1970 : : {
1971 : 0 : fputc (':', dumpfile);
1972 : 0 : switch ((enum gfc_omp_defaultmap_category) i)
1973 : : {
1974 : : case OMP_DEFAULTMAP_CAT_SCALAR: dfltmap = "SCALAR"; break;
1975 : 0 : case OMP_DEFAULTMAP_CAT_AGGREGATE: dfltmap = "AGGREGATE"; break;
1976 : 0 : case OMP_DEFAULTMAP_CAT_ALLOCATABLE: dfltmap = "ALLOCATABLE"; break;
1977 : 0 : case OMP_DEFAULTMAP_CAT_POINTER: dfltmap = "POINTER"; break;
1978 : 0 : default: gcc_unreachable ();
1979 : : }
1980 : 0 : fputs (dfltmap, dumpfile);
1981 : : }
1982 : 0 : fputc (')', dumpfile);
1983 : : }
1984 : 0 : if (omp_clauses->weak)
1985 : 0 : fputs (" WEAK", dumpfile);
1986 : 0 : if (omp_clauses->compare)
1987 : 0 : fputs (" COMPARE", dumpfile);
1988 : 0 : if (omp_clauses->nogroup)
1989 : 0 : fputs (" NOGROUP", dumpfile);
1990 : 0 : if (omp_clauses->simd)
1991 : 0 : fputs (" SIMD", dumpfile);
1992 : 0 : if (omp_clauses->threads)
1993 : 0 : fputs (" THREADS", dumpfile);
1994 : 0 : if (omp_clauses->grainsize)
1995 : : {
1996 : 0 : fputs (" GRAINSIZE(", dumpfile);
1997 : 0 : if (omp_clauses->grainsize_strict)
1998 : 0 : fputs ("strict: ", dumpfile);
1999 : 0 : show_expr (omp_clauses->grainsize);
2000 : 0 : fputc (')', dumpfile);
2001 : : }
2002 : 0 : if (omp_clauses->filter)
2003 : : {
2004 : 0 : fputs (" FILTER(", dumpfile);
2005 : 0 : show_expr (omp_clauses->filter);
2006 : 0 : fputc (')', dumpfile);
2007 : : }
2008 : 0 : if (omp_clauses->hint)
2009 : : {
2010 : 0 : fputs (" HINT(", dumpfile);
2011 : 0 : show_expr (omp_clauses->hint);
2012 : 0 : fputc (')', dumpfile);
2013 : : }
2014 : 0 : if (omp_clauses->num_tasks)
2015 : : {
2016 : 0 : fputs (" NUM_TASKS(", dumpfile);
2017 : 0 : if (omp_clauses->num_tasks_strict)
2018 : 0 : fputs ("strict: ", dumpfile);
2019 : 0 : show_expr (omp_clauses->num_tasks);
2020 : 0 : fputc (')', dumpfile);
2021 : : }
2022 : 0 : if (omp_clauses->priority)
2023 : : {
2024 : 0 : fputs (" PRIORITY(", dumpfile);
2025 : 0 : show_expr (omp_clauses->priority);
2026 : 0 : fputc (')', dumpfile);
2027 : : }
2028 : 0 : if (omp_clauses->detach)
2029 : : {
2030 : 0 : fputs (" DETACH(", dumpfile);
2031 : 0 : show_expr (omp_clauses->detach);
2032 : 0 : fputc (')', dumpfile);
2033 : : }
2034 : 0 : if (omp_clauses->destroy)
2035 : 0 : fputs (" DESTROY", dumpfile);
2036 : 0 : if (omp_clauses->depend_source)
2037 : 0 : fputs (" DEPEND(source)", dumpfile);
2038 : 0 : if (omp_clauses->doacross_source)
2039 : 0 : fputs (" DOACROSS(source:)", dumpfile);
2040 : 0 : if (omp_clauses->capture)
2041 : 0 : fputs (" CAPTURE", dumpfile);
2042 : 0 : if (omp_clauses->depobj_update != OMP_DEPEND_UNSET)
2043 : : {
2044 : 0 : const char *deptype;
2045 : 0 : fputs (" UPDATE(", dumpfile);
2046 : 0 : switch (omp_clauses->depobj_update)
2047 : : {
2048 : : case OMP_DEPEND_IN: deptype = "IN"; break;
2049 : 0 : case OMP_DEPEND_OUT: deptype = "OUT"; break;
2050 : 0 : case OMP_DEPEND_INOUT: deptype = "INOUT"; break;
2051 : 0 : case OMP_DEPEND_INOUTSET: deptype = "INOUTSET"; break;
2052 : 0 : case OMP_DEPEND_MUTEXINOUTSET: deptype = "MUTEXINOUTSET"; break;
2053 : 0 : default: gcc_unreachable ();
2054 : : }
2055 : 0 : fputs (deptype, dumpfile);
2056 : 0 : fputc (')', dumpfile);
2057 : : }
2058 : 0 : if (omp_clauses->atomic_op != GFC_OMP_ATOMIC_UNSET)
2059 : : {
2060 : 0 : const char *atomic_op;
2061 : 0 : switch (omp_clauses->atomic_op & GFC_OMP_ATOMIC_MASK)
2062 : : {
2063 : : case GFC_OMP_ATOMIC_READ: atomic_op = "READ"; break;
2064 : 0 : case GFC_OMP_ATOMIC_WRITE: atomic_op = "WRITE"; break;
2065 : 0 : case GFC_OMP_ATOMIC_UPDATE: atomic_op = "UPDATE"; break;
2066 : 0 : default: gcc_unreachable ();
2067 : : }
2068 : 0 : fputc (' ', dumpfile);
2069 : 0 : fputs (atomic_op, dumpfile);
2070 : : }
2071 : 0 : if (omp_clauses->memorder != OMP_MEMORDER_UNSET)
2072 : : {
2073 : 0 : const char *memorder;
2074 : 0 : switch (omp_clauses->memorder)
2075 : : {
2076 : : case OMP_MEMORDER_ACQ_REL: memorder = "ACQ_REL"; break;
2077 : 0 : case OMP_MEMORDER_ACQUIRE: memorder = "AQUIRE"; break;
2078 : 0 : case OMP_MEMORDER_RELAXED: memorder = "RELAXED"; break;
2079 : 0 : case OMP_MEMORDER_RELEASE: memorder = "RELEASE"; break;
2080 : 0 : case OMP_MEMORDER_SEQ_CST: memorder = "SEQ_CST"; break;
2081 : 0 : default: gcc_unreachable ();
2082 : : }
2083 : 0 : fputc (' ', dumpfile);
2084 : 0 : fputs (memorder, dumpfile);
2085 : : }
2086 : 0 : if (omp_clauses->fail != OMP_MEMORDER_UNSET)
2087 : : {
2088 : 0 : const char *memorder;
2089 : 0 : switch (omp_clauses->fail)
2090 : : {
2091 : : case OMP_MEMORDER_ACQUIRE: memorder = "AQUIRE"; break;
2092 : 0 : case OMP_MEMORDER_RELAXED: memorder = "RELAXED"; break;
2093 : 0 : case OMP_MEMORDER_SEQ_CST: memorder = "SEQ_CST"; break;
2094 : 0 : default: gcc_unreachable ();
2095 : : }
2096 : 0 : fputs (" FAIL(", dumpfile);
2097 : 0 : fputs (memorder, dumpfile);
2098 : 0 : putc (')', dumpfile);
2099 : : }
2100 : 0 : if (omp_clauses->at != OMP_AT_UNSET)
2101 : : {
2102 : 0 : if (omp_clauses->at != OMP_AT_COMPILATION)
2103 : 0 : fputs (" AT (COMPILATION)", dumpfile);
2104 : : else
2105 : 0 : fputs (" AT (EXECUTION)", dumpfile);
2106 : : }
2107 : 0 : if (omp_clauses->severity != OMP_SEVERITY_UNSET)
2108 : : {
2109 : 0 : if (omp_clauses->severity != OMP_SEVERITY_FATAL)
2110 : 0 : fputs (" SEVERITY (FATAL)", dumpfile);
2111 : : else
2112 : 0 : fputs (" SEVERITY (WARNING)", dumpfile);
2113 : : }
2114 : 0 : if (omp_clauses->message)
2115 : : {
2116 : 0 : fputs (" ERROR (", dumpfile);
2117 : 0 : show_expr (omp_clauses->message);
2118 : 0 : fputc (')', dumpfile);
2119 : : }
2120 : 0 : if (omp_clauses->assume)
2121 : 0 : show_omp_assumes (omp_clauses->assume);
2122 : 0 : }
2123 : :
2124 : : /* Show a single OpenMP or OpenACC directive node and everything underneath it
2125 : : if necessary. */
2126 : :
2127 : : static void
2128 : 0 : show_omp_node (int level, gfc_code *c)
2129 : : {
2130 : 0 : gfc_omp_clauses *omp_clauses = NULL;
2131 : 0 : const char *name = NULL;
2132 : 0 : bool is_oacc = false;
2133 : :
2134 : 0 : switch (c->op)
2135 : : {
2136 : : case EXEC_OACC_PARALLEL_LOOP:
2137 : : name = "PARALLEL LOOP"; is_oacc = true; break;
2138 : 0 : case EXEC_OACC_PARALLEL: name = "PARALLEL"; is_oacc = true; break;
2139 : 0 : case EXEC_OACC_KERNELS_LOOP: name = "KERNELS LOOP"; is_oacc = true; break;
2140 : 0 : case EXEC_OACC_KERNELS: name = "KERNELS"; is_oacc = true; break;
2141 : 0 : case EXEC_OACC_SERIAL_LOOP: name = "SERIAL LOOP"; is_oacc = true; break;
2142 : 0 : case EXEC_OACC_SERIAL: name = "SERIAL"; is_oacc = true; break;
2143 : 0 : case EXEC_OACC_DATA: name = "DATA"; is_oacc = true; break;
2144 : 0 : case EXEC_OACC_HOST_DATA: name = "HOST_DATA"; is_oacc = true; break;
2145 : 0 : case EXEC_OACC_LOOP: name = "LOOP"; is_oacc = true; break;
2146 : 0 : case EXEC_OACC_UPDATE: name = "UPDATE"; is_oacc = true; break;
2147 : 0 : case EXEC_OACC_WAIT: name = "WAIT"; is_oacc = true; break;
2148 : 0 : case EXEC_OACC_CACHE: name = "CACHE"; is_oacc = true; break;
2149 : 0 : case EXEC_OACC_ENTER_DATA: name = "ENTER DATA"; is_oacc = true; break;
2150 : 0 : case EXEC_OACC_EXIT_DATA: name = "EXIT DATA"; is_oacc = true; break;
2151 : 0 : case EXEC_OMP_ALLOCATE: name = "ALLOCATE"; break;
2152 : 0 : case EXEC_OMP_ALLOCATORS: name = "ALLOCATORS"; break;
2153 : 0 : case EXEC_OMP_ASSUME: name = "ASSUME"; break;
2154 : 0 : case EXEC_OMP_ATOMIC: name = "ATOMIC"; break;
2155 : 0 : case EXEC_OMP_BARRIER: name = "BARRIER"; break;
2156 : 0 : case EXEC_OMP_CANCEL: name = "CANCEL"; break;
2157 : 0 : case EXEC_OMP_CANCELLATION_POINT: name = "CANCELLATION POINT"; break;
2158 : 0 : case EXEC_OMP_CRITICAL: name = "CRITICAL"; break;
2159 : 0 : case EXEC_OMP_DISTRIBUTE: name = "DISTRIBUTE"; break;
2160 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
2161 : 0 : name = "DISTRIBUTE PARALLEL DO"; break;
2162 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
2163 : 0 : name = "DISTRIBUTE PARALLEL DO SIMD"; break;
2164 : 0 : case EXEC_OMP_DISTRIBUTE_SIMD: name = "DISTRIBUTE SIMD"; break;
2165 : 0 : case EXEC_OMP_DO: name = "DO"; break;
2166 : 0 : case EXEC_OMP_DO_SIMD: name = "DO SIMD"; break;
2167 : 0 : case EXEC_OMP_ERROR: name = "ERROR"; break;
2168 : 0 : case EXEC_OMP_FLUSH: name = "FLUSH"; break;
2169 : 0 : case EXEC_OMP_LOOP: name = "LOOP"; break;
2170 : 0 : case EXEC_OMP_MASKED: name = "MASKED"; break;
2171 : 0 : case EXEC_OMP_MASKED_TASKLOOP: name = "MASKED TASKLOOP"; break;
2172 : 0 : case EXEC_OMP_MASKED_TASKLOOP_SIMD: name = "MASKED TASKLOOP SIMD"; break;
2173 : 0 : case EXEC_OMP_MASTER: name = "MASTER"; break;
2174 : 0 : case EXEC_OMP_MASTER_TASKLOOP: name = "MASTER TASKLOOP"; break;
2175 : 0 : case EXEC_OMP_MASTER_TASKLOOP_SIMD: name = "MASTER TASKLOOP SIMD"; break;
2176 : 0 : case EXEC_OMP_ORDERED: name = "ORDERED"; break;
2177 : 0 : case EXEC_OMP_DEPOBJ: name = "DEPOBJ"; break;
2178 : 0 : case EXEC_OMP_PARALLEL: name = "PARALLEL"; break;
2179 : 0 : case EXEC_OMP_PARALLEL_DO: name = "PARALLEL DO"; break;
2180 : 0 : case EXEC_OMP_PARALLEL_DO_SIMD: name = "PARALLEL DO SIMD"; break;
2181 : 0 : case EXEC_OMP_PARALLEL_LOOP: name = "PARALLEL LOOP"; break;
2182 : 0 : case EXEC_OMP_PARALLEL_MASTER: name = "PARALLEL MASTER"; break;
2183 : 0 : case EXEC_OMP_PARALLEL_MASKED: name = "PARALLEL MASK"; break;
2184 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP:
2185 : 0 : name = "PARALLEL MASK TASKLOOP"; break;
2186 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
2187 : 0 : name = "PARALLEL MASK TASKLOOP SIMD"; break;
2188 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP:
2189 : 0 : name = "PARALLEL MASTER TASKLOOP"; break;
2190 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
2191 : 0 : name = "PARALLEL MASTER TASKLOOP SIMD"; break;
2192 : 0 : case EXEC_OMP_PARALLEL_SECTIONS: name = "PARALLEL SECTIONS"; break;
2193 : 0 : case EXEC_OMP_PARALLEL_WORKSHARE: name = "PARALLEL WORKSHARE"; break;
2194 : 0 : case EXEC_OMP_SCAN: name = "SCAN"; break;
2195 : 0 : case EXEC_OMP_SCOPE: name = "SCOPE"; break;
2196 : 0 : case EXEC_OMP_SECTIONS: name = "SECTIONS"; break;
2197 : 0 : case EXEC_OMP_SIMD: name = "SIMD"; break;
2198 : 0 : case EXEC_OMP_SINGLE: name = "SINGLE"; break;
2199 : 0 : case EXEC_OMP_TARGET: name = "TARGET"; break;
2200 : 0 : case EXEC_OMP_TARGET_DATA: name = "TARGET DATA"; break;
2201 : 0 : case EXEC_OMP_TARGET_ENTER_DATA: name = "TARGET ENTER DATA"; break;
2202 : 0 : case EXEC_OMP_TARGET_EXIT_DATA: name = "TARGET EXIT DATA"; break;
2203 : 0 : case EXEC_OMP_TARGET_PARALLEL: name = "TARGET PARALLEL"; break;
2204 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO: name = "TARGET PARALLEL DO"; break;
2205 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
2206 : 0 : name = "TARGET_PARALLEL_DO_SIMD"; break;
2207 : 0 : case EXEC_OMP_TARGET_PARALLEL_LOOP: name = "TARGET PARALLEL LOOP"; break;
2208 : 0 : case EXEC_OMP_TARGET_SIMD: name = "TARGET SIMD"; break;
2209 : 0 : case EXEC_OMP_TARGET_TEAMS: name = "TARGET TEAMS"; break;
2210 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
2211 : 0 : name = "TARGET TEAMS DISTRIBUTE"; break;
2212 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
2213 : 0 : name = "TARGET TEAMS DISTRIBUTE PARALLEL DO"; break;
2214 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
2215 : 0 : name = "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2216 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
2217 : 0 : name = "TARGET TEAMS DISTRIBUTE SIMD"; break;
2218 : 0 : case EXEC_OMP_TARGET_TEAMS_LOOP: name = "TARGET TEAMS LOOP"; break;
2219 : 0 : case EXEC_OMP_TARGET_UPDATE: name = "TARGET UPDATE"; break;
2220 : 0 : case EXEC_OMP_TASK: name = "TASK"; break;
2221 : 0 : case EXEC_OMP_TASKGROUP: name = "TASKGROUP"; break;
2222 : 0 : case EXEC_OMP_TASKLOOP: name = "TASKLOOP"; break;
2223 : 0 : case EXEC_OMP_TASKLOOP_SIMD: name = "TASKLOOP SIMD"; break;
2224 : 0 : case EXEC_OMP_TASKWAIT: name = "TASKWAIT"; break;
2225 : 0 : case EXEC_OMP_TASKYIELD: name = "TASKYIELD"; break;
2226 : 0 : case EXEC_OMP_TEAMS: name = "TEAMS"; break;
2227 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE: name = "TEAMS DISTRIBUTE"; break;
2228 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
2229 : 0 : name = "TEAMS DISTRIBUTE PARALLEL DO"; break;
2230 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
2231 : 0 : name = "TEAMS DISTRIBUTE PARALLEL DO SIMD"; break;
2232 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD: name = "TEAMS DISTRIBUTE SIMD"; break;
2233 : 0 : case EXEC_OMP_TEAMS_LOOP: name = "TEAMS LOOP"; break;
2234 : 0 : case EXEC_OMP_WORKSHARE: name = "WORKSHARE"; break;
2235 : 0 : default:
2236 : 0 : gcc_unreachable ();
2237 : : }
2238 : 0 : fprintf (dumpfile, "!$%s %s", is_oacc ? "ACC" : "OMP", name);
2239 : 0 : switch (c->op)
2240 : : {
2241 : 0 : case EXEC_OACC_PARALLEL_LOOP:
2242 : 0 : case EXEC_OACC_PARALLEL:
2243 : 0 : case EXEC_OACC_KERNELS_LOOP:
2244 : 0 : case EXEC_OACC_KERNELS:
2245 : 0 : case EXEC_OACC_SERIAL_LOOP:
2246 : 0 : case EXEC_OACC_SERIAL:
2247 : 0 : case EXEC_OACC_DATA:
2248 : 0 : case EXEC_OACC_HOST_DATA:
2249 : 0 : case EXEC_OACC_LOOP:
2250 : 0 : case EXEC_OACC_UPDATE:
2251 : 0 : case EXEC_OACC_WAIT:
2252 : 0 : case EXEC_OACC_CACHE:
2253 : 0 : case EXEC_OACC_ENTER_DATA:
2254 : 0 : case EXEC_OACC_EXIT_DATA:
2255 : 0 : case EXEC_OMP_ALLOCATE:
2256 : 0 : case EXEC_OMP_ALLOCATORS:
2257 : 0 : case EXEC_OMP_ASSUME:
2258 : 0 : case EXEC_OMP_CANCEL:
2259 : 0 : case EXEC_OMP_CANCELLATION_POINT:
2260 : 0 : case EXEC_OMP_DISTRIBUTE:
2261 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
2262 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
2263 : 0 : case EXEC_OMP_DISTRIBUTE_SIMD:
2264 : 0 : case EXEC_OMP_DO:
2265 : 0 : case EXEC_OMP_DO_SIMD:
2266 : 0 : case EXEC_OMP_ERROR:
2267 : 0 : case EXEC_OMP_LOOP:
2268 : 0 : case EXEC_OMP_ORDERED:
2269 : 0 : case EXEC_OMP_MASKED:
2270 : 0 : case EXEC_OMP_PARALLEL:
2271 : 0 : case EXEC_OMP_PARALLEL_DO:
2272 : 0 : case EXEC_OMP_PARALLEL_DO_SIMD:
2273 : 0 : case EXEC_OMP_PARALLEL_LOOP:
2274 : 0 : case EXEC_OMP_PARALLEL_MASKED:
2275 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP:
2276 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
2277 : 0 : case EXEC_OMP_PARALLEL_MASTER:
2278 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP:
2279 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
2280 : 0 : case EXEC_OMP_PARALLEL_SECTIONS:
2281 : 0 : case EXEC_OMP_PARALLEL_WORKSHARE:
2282 : 0 : case EXEC_OMP_SCAN:
2283 : 0 : case EXEC_OMP_SCOPE:
2284 : 0 : case EXEC_OMP_SECTIONS:
2285 : 0 : case EXEC_OMP_SIMD:
2286 : 0 : case EXEC_OMP_SINGLE:
2287 : 0 : case EXEC_OMP_TARGET:
2288 : 0 : case EXEC_OMP_TARGET_DATA:
2289 : 0 : case EXEC_OMP_TARGET_ENTER_DATA:
2290 : 0 : case EXEC_OMP_TARGET_EXIT_DATA:
2291 : 0 : case EXEC_OMP_TARGET_PARALLEL:
2292 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO:
2293 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
2294 : 0 : case EXEC_OMP_TARGET_PARALLEL_LOOP:
2295 : 0 : case EXEC_OMP_TARGET_SIMD:
2296 : 0 : case EXEC_OMP_TARGET_TEAMS:
2297 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
2298 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
2299 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
2300 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
2301 : 0 : case EXEC_OMP_TARGET_TEAMS_LOOP:
2302 : 0 : case EXEC_OMP_TARGET_UPDATE:
2303 : 0 : case EXEC_OMP_TASK:
2304 : 0 : case EXEC_OMP_TASKLOOP:
2305 : 0 : case EXEC_OMP_TASKLOOP_SIMD:
2306 : 0 : case EXEC_OMP_TEAMS:
2307 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE:
2308 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
2309 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
2310 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
2311 : 0 : case EXEC_OMP_TEAMS_LOOP:
2312 : 0 : case EXEC_OMP_WORKSHARE:
2313 : 0 : omp_clauses = c->ext.omp_clauses;
2314 : 0 : break;
2315 : 0 : case EXEC_OMP_CRITICAL:
2316 : 0 : omp_clauses = c->ext.omp_clauses;
2317 : 0 : if (omp_clauses)
2318 : 0 : fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name);
2319 : : break;
2320 : 0 : case EXEC_OMP_DEPOBJ:
2321 : 0 : omp_clauses = c->ext.omp_clauses;
2322 : 0 : if (omp_clauses)
2323 : : {
2324 : 0 : fputc ('(', dumpfile);
2325 : 0 : show_expr (c->ext.omp_clauses->depobj);
2326 : 0 : fputc (')', dumpfile);
2327 : : }
2328 : : break;
2329 : 0 : case EXEC_OMP_FLUSH:
2330 : 0 : if (c->ext.omp_namelist)
2331 : : {
2332 : 0 : fputs (" (", dumpfile);
2333 : 0 : show_omp_namelist (OMP_LIST_NUM, c->ext.omp_namelist);
2334 : 0 : fputc (')', dumpfile);
2335 : : }
2336 : : return;
2337 : : case EXEC_OMP_BARRIER:
2338 : : case EXEC_OMP_TASKWAIT:
2339 : : case EXEC_OMP_TASKYIELD:
2340 : : return;
2341 : 0 : case EXEC_OACC_ATOMIC:
2342 : 0 : case EXEC_OMP_ATOMIC:
2343 : 0 : omp_clauses = c->block ? c->block->ext.omp_clauses : NULL;
2344 : 0 : break;
2345 : : default:
2346 : : break;
2347 : : }
2348 : 0 : if (omp_clauses)
2349 : 0 : show_omp_clauses (omp_clauses);
2350 : 0 : fputc ('\n', dumpfile);
2351 : :
2352 : : /* OpenMP and OpenACC executable directives don't have associated blocks. */
2353 : 0 : if (c->op == EXEC_OACC_CACHE || c->op == EXEC_OACC_UPDATE
2354 : : || c->op == EXEC_OACC_ENTER_DATA || c->op == EXEC_OACC_EXIT_DATA
2355 : : || c->op == EXEC_OMP_TARGET_UPDATE || c->op == EXEC_OMP_TARGET_ENTER_DATA
2356 : : || c->op == EXEC_OMP_TARGET_EXIT_DATA || c->op == EXEC_OMP_SCAN
2357 : : || c->op == EXEC_OMP_DEPOBJ || c->op == EXEC_OMP_ERROR
2358 : 0 : || (c->op == EXEC_OMP_ORDERED && c->block == NULL))
2359 : : return;
2360 : 0 : if (c->op == EXEC_OMP_SECTIONS || c->op == EXEC_OMP_PARALLEL_SECTIONS)
2361 : : {
2362 : 0 : gfc_code *d = c->block;
2363 : 0 : while (d != NULL)
2364 : : {
2365 : 0 : show_code (level + 1, d->next);
2366 : 0 : if (d->block == NULL)
2367 : : break;
2368 : 0 : code_indent (level, 0);
2369 : 0 : fputs ("!$OMP SECTION\n", dumpfile);
2370 : 0 : d = d->block;
2371 : : }
2372 : : }
2373 : : else
2374 : 0 : show_code (level + 1, c->block->next);
2375 : 0 : if (c->op == EXEC_OMP_ATOMIC)
2376 : : return;
2377 : 0 : fputc ('\n', dumpfile);
2378 : 0 : code_indent (level, 0);
2379 : 0 : fprintf (dumpfile, "!$%s END %s", is_oacc ? "ACC" : "OMP", name);
2380 : 0 : if (omp_clauses != NULL)
2381 : : {
2382 : 0 : if (omp_clauses->lists[OMP_LIST_COPYPRIVATE])
2383 : : {
2384 : 0 : fputs (" COPYPRIVATE(", dumpfile);
2385 : 0 : show_omp_namelist (OMP_LIST_COPYPRIVATE,
2386 : : omp_clauses->lists[OMP_LIST_COPYPRIVATE]);
2387 : 0 : fputc (')', dumpfile);
2388 : : }
2389 : 0 : else if (omp_clauses->nowait)
2390 : 0 : fputs (" NOWAIT", dumpfile);
2391 : : }
2392 : 0 : else if (c->op == EXEC_OMP_CRITICAL && c->ext.omp_clauses)
2393 : 0 : fprintf (dumpfile, " (%s)", c->ext.omp_clauses->critical_name);
2394 : : }
2395 : :
2396 : :
2397 : : /* Show a single code node and everything underneath it if necessary. */
2398 : :
2399 : : static void
2400 : 232 : show_code_node (int level, gfc_code *c)
2401 : : {
2402 : 232 : gfc_forall_iterator *fa;
2403 : 232 : gfc_open *open;
2404 : 232 : gfc_case *cp;
2405 : 232 : gfc_alloc *a;
2406 : 232 : gfc_code *d;
2407 : 232 : gfc_close *close;
2408 : 232 : gfc_filepos *fp;
2409 : 232 : gfc_inquire *i;
2410 : 232 : gfc_dt *dt;
2411 : 232 : gfc_namespace *ns;
2412 : :
2413 : 232 : if (c->here)
2414 : : {
2415 : 0 : fputc ('\n', dumpfile);
2416 : 0 : code_indent (level, c->here);
2417 : : }
2418 : : else
2419 : 232 : show_indent ();
2420 : :
2421 : 232 : switch (c->op)
2422 : : {
2423 : : case EXEC_END_PROCEDURE:
2424 : : break;
2425 : :
2426 : 0 : case EXEC_NOP:
2427 : 0 : fputs ("NOP", dumpfile);
2428 : 0 : break;
2429 : :
2430 : 0 : case EXEC_CONTINUE:
2431 : 0 : fputs ("CONTINUE", dumpfile);
2432 : 0 : break;
2433 : :
2434 : 0 : case EXEC_ENTRY:
2435 : 0 : fprintf (dumpfile, "ENTRY %s", c->ext.entry->sym->name);
2436 : 0 : break;
2437 : :
2438 : 6 : case EXEC_INIT_ASSIGN:
2439 : 6 : case EXEC_ASSIGN:
2440 : 6 : fputs ("ASSIGN ", dumpfile);
2441 : 6 : show_expr (c->expr1);
2442 : 6 : fputc (' ', dumpfile);
2443 : 6 : show_expr (c->expr2);
2444 : 6 : break;
2445 : :
2446 : 0 : case EXEC_LABEL_ASSIGN:
2447 : 0 : fputs ("LABEL ASSIGN ", dumpfile);
2448 : 0 : show_expr (c->expr1);
2449 : 0 : fprintf (dumpfile, " %d", c->label1->value);
2450 : 0 : break;
2451 : :
2452 : 0 : case EXEC_POINTER_ASSIGN:
2453 : 0 : fputs ("POINTER ASSIGN ", dumpfile);
2454 : 0 : show_expr (c->expr1);
2455 : 0 : fputc (' ', dumpfile);
2456 : 0 : show_expr (c->expr2);
2457 : 0 : break;
2458 : :
2459 : 0 : case EXEC_GOTO:
2460 : 0 : fputs ("GOTO ", dumpfile);
2461 : 0 : if (c->label1)
2462 : 0 : fprintf (dumpfile, "%d", c->label1->value);
2463 : : else
2464 : : {
2465 : 0 : show_expr (c->expr1);
2466 : 0 : d = c->block;
2467 : 0 : if (d != NULL)
2468 : : {
2469 : 0 : fputs (", (", dumpfile);
2470 : 0 : for (; d; d = d ->block)
2471 : : {
2472 : 0 : code_indent (level, d->label1);
2473 : 0 : if (d->block != NULL)
2474 : 0 : fputc (',', dumpfile);
2475 : : else
2476 : 0 : fputc (')', dumpfile);
2477 : : }
2478 : : }
2479 : : }
2480 : : break;
2481 : :
2482 : 0 : case EXEC_CALL:
2483 : 0 : case EXEC_ASSIGN_CALL:
2484 : 0 : if (c->resolved_sym)
2485 : 0 : fprintf (dumpfile, "CALL %s ", c->resolved_sym->name);
2486 : 0 : else if (c->symtree)
2487 : 0 : fprintf (dumpfile, "CALL %s ", c->symtree->name);
2488 : : else
2489 : 0 : fputs ("CALL ?? ", dumpfile);
2490 : :
2491 : 0 : show_actual_arglist (c->ext.actual);
2492 : 0 : break;
2493 : :
2494 : 0 : case EXEC_COMPCALL:
2495 : 0 : fputs ("CALL ", dumpfile);
2496 : 0 : show_compcall (c->expr1);
2497 : 0 : break;
2498 : :
2499 : 0 : case EXEC_CALL_PPC:
2500 : 0 : fputs ("CALL ", dumpfile);
2501 : 0 : show_expr (c->expr1);
2502 : 0 : show_actual_arglist (c->ext.actual);
2503 : 0 : break;
2504 : :
2505 : 0 : case EXEC_RETURN:
2506 : 0 : fputs ("RETURN ", dumpfile);
2507 : 0 : if (c->expr1)
2508 : 0 : show_expr (c->expr1);
2509 : : break;
2510 : :
2511 : 0 : case EXEC_PAUSE:
2512 : 0 : fputs ("PAUSE ", dumpfile);
2513 : :
2514 : 0 : if (c->expr1 != NULL)
2515 : 0 : show_expr (c->expr1);
2516 : : else
2517 : 0 : fprintf (dumpfile, "%d", c->ext.stop_code);
2518 : :
2519 : : break;
2520 : :
2521 : 0 : case EXEC_ERROR_STOP:
2522 : 0 : fputs ("ERROR ", dumpfile);
2523 : : /* Fall through. */
2524 : :
2525 : 24 : case EXEC_STOP:
2526 : 24 : fputs ("STOP ", dumpfile);
2527 : :
2528 : 24 : if (c->expr1 != NULL)
2529 : 24 : show_expr (c->expr1);
2530 : : else
2531 : 0 : fprintf (dumpfile, "%d", c->ext.stop_code);
2532 : 24 : if (c->expr2 != NULL)
2533 : : {
2534 : 0 : fputs (" QUIET=", dumpfile);
2535 : 0 : show_expr (c->expr2);
2536 : : }
2537 : :
2538 : : break;
2539 : :
2540 : 0 : case EXEC_FAIL_IMAGE:
2541 : 0 : fputs ("FAIL IMAGE ", dumpfile);
2542 : 0 : break;
2543 : :
2544 : 0 : case EXEC_CHANGE_TEAM:
2545 : 0 : fputs ("CHANGE TEAM", dumpfile);
2546 : 0 : break;
2547 : :
2548 : 0 : case EXEC_END_TEAM:
2549 : 0 : fputs ("END TEAM", dumpfile);
2550 : 0 : break;
2551 : :
2552 : 0 : case EXEC_FORM_TEAM:
2553 : 0 : fputs ("FORM TEAM", dumpfile);
2554 : 0 : break;
2555 : :
2556 : 0 : case EXEC_SYNC_TEAM:
2557 : 0 : fputs ("SYNC TEAM", dumpfile);
2558 : 0 : break;
2559 : :
2560 : 0 : case EXEC_SYNC_ALL:
2561 : 0 : fputs ("SYNC ALL ", dumpfile);
2562 : 0 : if (c->expr2 != NULL)
2563 : : {
2564 : 0 : fputs (" stat=", dumpfile);
2565 : 0 : show_expr (c->expr2);
2566 : : }
2567 : 0 : if (c->expr3 != NULL)
2568 : : {
2569 : 0 : fputs (" errmsg=", dumpfile);
2570 : 0 : show_expr (c->expr3);
2571 : : }
2572 : : break;
2573 : :
2574 : 0 : case EXEC_SYNC_MEMORY:
2575 : 0 : fputs ("SYNC MEMORY ", dumpfile);
2576 : 0 : if (c->expr2 != NULL)
2577 : : {
2578 : 0 : fputs (" stat=", dumpfile);
2579 : 0 : show_expr (c->expr2);
2580 : : }
2581 : 0 : if (c->expr3 != NULL)
2582 : : {
2583 : 0 : fputs (" errmsg=", dumpfile);
2584 : 0 : show_expr (c->expr3);
2585 : : }
2586 : : break;
2587 : :
2588 : 0 : case EXEC_SYNC_IMAGES:
2589 : 0 : fputs ("SYNC IMAGES image-set=", dumpfile);
2590 : 0 : if (c->expr1 != NULL)
2591 : 0 : show_expr (c->expr1);
2592 : : else
2593 : 0 : fputs ("* ", dumpfile);
2594 : 0 : if (c->expr2 != NULL)
2595 : : {
2596 : 0 : fputs (" stat=", dumpfile);
2597 : 0 : show_expr (c->expr2);
2598 : : }
2599 : 0 : if (c->expr3 != NULL)
2600 : : {
2601 : 0 : fputs (" errmsg=", dumpfile);
2602 : 0 : show_expr (c->expr3);
2603 : : }
2604 : : break;
2605 : :
2606 : 0 : case EXEC_EVENT_POST:
2607 : 0 : case EXEC_EVENT_WAIT:
2608 : 0 : if (c->op == EXEC_EVENT_POST)
2609 : 0 : fputs ("EVENT POST ", dumpfile);
2610 : : else
2611 : 0 : fputs ("EVENT WAIT ", dumpfile);
2612 : :
2613 : 0 : fputs ("event-variable=", dumpfile);
2614 : 0 : if (c->expr1 != NULL)
2615 : 0 : show_expr (c->expr1);
2616 : 0 : if (c->expr4 != NULL)
2617 : : {
2618 : 0 : fputs (" until_count=", dumpfile);
2619 : 0 : show_expr (c->expr4);
2620 : : }
2621 : 0 : if (c->expr2 != NULL)
2622 : : {
2623 : 0 : fputs (" stat=", dumpfile);
2624 : 0 : show_expr (c->expr2);
2625 : : }
2626 : 0 : if (c->expr3 != NULL)
2627 : : {
2628 : 0 : fputs (" errmsg=", dumpfile);
2629 : 0 : show_expr (c->expr3);
2630 : : }
2631 : : break;
2632 : :
2633 : 0 : case EXEC_LOCK:
2634 : 0 : case EXEC_UNLOCK:
2635 : 0 : if (c->op == EXEC_LOCK)
2636 : 0 : fputs ("LOCK ", dumpfile);
2637 : : else
2638 : 0 : fputs ("UNLOCK ", dumpfile);
2639 : :
2640 : 0 : fputs ("lock-variable=", dumpfile);
2641 : 0 : if (c->expr1 != NULL)
2642 : 0 : show_expr (c->expr1);
2643 : 0 : if (c->expr4 != NULL)
2644 : : {
2645 : 0 : fputs (" acquired_lock=", dumpfile);
2646 : 0 : show_expr (c->expr4);
2647 : : }
2648 : 0 : if (c->expr2 != NULL)
2649 : : {
2650 : 0 : fputs (" stat=", dumpfile);
2651 : 0 : show_expr (c->expr2);
2652 : : }
2653 : 0 : if (c->expr3 != NULL)
2654 : : {
2655 : 0 : fputs (" errmsg=", dumpfile);
2656 : 0 : show_expr (c->expr3);
2657 : : }
2658 : : break;
2659 : :
2660 : 0 : case EXEC_ARITHMETIC_IF:
2661 : 0 : fputs ("IF ", dumpfile);
2662 : 0 : show_expr (c->expr1);
2663 : 0 : fprintf (dumpfile, " %d, %d, %d",
2664 : 0 : c->label1->value, c->label2->value, c->label3->value);
2665 : 0 : break;
2666 : :
2667 : 12 : case EXEC_IF:
2668 : 12 : d = c->block;
2669 : 12 : fputs ("IF ", dumpfile);
2670 : 12 : show_expr (d->expr1);
2671 : :
2672 : 12 : ++show_level;
2673 : 12 : show_code (level + 1, d->next);
2674 : 12 : --show_level;
2675 : :
2676 : 12 : d = d->block;
2677 : 12 : for (; d; d = d->block)
2678 : : {
2679 : 0 : fputs("\n", dumpfile);
2680 : 0 : code_indent (level, 0);
2681 : 0 : if (d->expr1 == NULL)
2682 : 0 : fputs ("ELSE", dumpfile);
2683 : : else
2684 : : {
2685 : 0 : fputs ("ELSE IF ", dumpfile);
2686 : 0 : show_expr (d->expr1);
2687 : : }
2688 : :
2689 : 0 : ++show_level;
2690 : 0 : show_code (level + 1, d->next);
2691 : 0 : --show_level;
2692 : : }
2693 : :
2694 : 12 : if (c->label1)
2695 : 0 : code_indent (level, c->label1);
2696 : : else
2697 : 12 : show_indent ();
2698 : :
2699 : 12 : fputs ("ENDIF", dumpfile);
2700 : 12 : break;
2701 : :
2702 : 24 : case EXEC_BLOCK:
2703 : 24 : {
2704 : 24 : const char *blocktype, *sname = NULL;
2705 : 24 : gfc_namespace *saved_ns;
2706 : 24 : gfc_association_list *alist;
2707 : :
2708 : 24 : if (c->ext.block.ns && c->ext.block.ns->code
2709 : 24 : && c->ext.block.ns->code->op == EXEC_SELECT_TYPE)
2710 : : {
2711 : 12 : gfc_expr *fcn = c->ext.block.ns->code->expr1;
2712 : 12 : blocktype = "SELECT TYPE";
2713 : : /* expr1 is _loc(assoc_name->vptr) */
2714 : 12 : if (fcn && fcn->expr_type == EXPR_FUNCTION)
2715 : 12 : sname = fcn->value.function.actual->expr->symtree->n.sym->name;
2716 : : }
2717 : 12 : else if (c->ext.block.assoc)
2718 : : blocktype = "ASSOCIATE";
2719 : : else
2720 : 0 : blocktype = "BLOCK";
2721 : 24 : show_indent ();
2722 : 24 : fprintf (dumpfile, "%s ", blocktype);
2723 : 36 : for (alist = c->ext.block.assoc; alist; alist = alist->next)
2724 : : {
2725 : 12 : fprintf (dumpfile, " %s = ", sname ? sname : alist->name);
2726 : 12 : show_expr (alist->target);
2727 : : }
2728 : :
2729 : 24 : ++show_level;
2730 : 24 : ns = c->ext.block.ns;
2731 : 24 : saved_ns = gfc_current_ns;
2732 : 24 : gfc_current_ns = ns;
2733 : 24 : gfc_traverse_symtree (ns->sym_root, show_symtree);
2734 : 24 : gfc_current_ns = saved_ns;
2735 : 24 : show_code (show_level, ns->code);
2736 : 24 : --show_level;
2737 : 24 : show_indent ();
2738 : 24 : fprintf (dumpfile, "END %s ", blocktype);
2739 : 24 : break;
2740 : : }
2741 : :
2742 : : case EXEC_END_BLOCK:
2743 : : /* Only come here when there is a label on an
2744 : : END ASSOCIATE construct. */
2745 : : break;
2746 : :
2747 : 12 : case EXEC_SELECT:
2748 : 12 : case EXEC_SELECT_TYPE:
2749 : 12 : case EXEC_SELECT_RANK:
2750 : 12 : d = c->block;
2751 : 12 : fputc ('\n', dumpfile);
2752 : 12 : code_indent (level, 0);
2753 : 12 : if (c->op == EXEC_SELECT_RANK)
2754 : 0 : fputs ("SELECT RANK ", dumpfile);
2755 : 12 : else if (c->op == EXEC_SELECT_TYPE)
2756 : 12 : fputs ("SELECT CASE ", dumpfile); // Preceded by SELECT TYPE construct
2757 : : else
2758 : 0 : fputs ("SELECT CASE ", dumpfile);
2759 : 12 : show_expr (c->expr1);
2760 : :
2761 : 48 : for (; d; d = d->block)
2762 : : {
2763 : 24 : fputc ('\n', dumpfile);
2764 : 24 : code_indent (level, 0);
2765 : 24 : fputs ("CASE ", dumpfile);
2766 : 48 : for (cp = d->ext.block.case_list; cp; cp = cp->next)
2767 : : {
2768 : 24 : fputc ('(', dumpfile);
2769 : 24 : show_expr (cp->low);
2770 : 24 : fputc (' ', dumpfile);
2771 : 24 : show_expr (cp->high);
2772 : 24 : fputc (')', dumpfile);
2773 : 24 : fputc (' ', dumpfile);
2774 : : }
2775 : :
2776 : 24 : show_code (level + 1, d->next);
2777 : 24 : fputc ('\n', dumpfile);
2778 : : }
2779 : :
2780 : 12 : code_indent (level, c->label1);
2781 : 12 : fputs ("END SELECT", dumpfile);
2782 : 12 : break;
2783 : :
2784 : 0 : case EXEC_WHERE:
2785 : 0 : fputs ("WHERE ", dumpfile);
2786 : :
2787 : 0 : d = c->block;
2788 : 0 : show_expr (d->expr1);
2789 : 0 : fputc ('\n', dumpfile);
2790 : :
2791 : 0 : show_code (level + 1, d->next);
2792 : :
2793 : 0 : for (d = d->block; d; d = d->block)
2794 : : {
2795 : 0 : code_indent (level, 0);
2796 : 0 : fputs ("ELSE WHERE ", dumpfile);
2797 : 0 : show_expr (d->expr1);
2798 : 0 : fputc ('\n', dumpfile);
2799 : 0 : show_code (level + 1, d->next);
2800 : : }
2801 : :
2802 : 0 : code_indent (level, 0);
2803 : 0 : fputs ("END WHERE", dumpfile);
2804 : 0 : break;
2805 : :
2806 : :
2807 : 0 : case EXEC_FORALL:
2808 : 0 : fputs ("FORALL ", dumpfile);
2809 : 0 : for (fa = c->ext.forall_iterator; fa; fa = fa->next)
2810 : : {
2811 : 0 : show_expr (fa->var);
2812 : 0 : fputc (' ', dumpfile);
2813 : 0 : show_expr (fa->start);
2814 : 0 : fputc (':', dumpfile);
2815 : 0 : show_expr (fa->end);
2816 : 0 : fputc (':', dumpfile);
2817 : 0 : show_expr (fa->stride);
2818 : :
2819 : 0 : if (fa->next != NULL)
2820 : 0 : fputc (',', dumpfile);
2821 : : }
2822 : :
2823 : 0 : if (c->expr1 != NULL)
2824 : : {
2825 : 0 : fputc (',', dumpfile);
2826 : 0 : show_expr (c->expr1);
2827 : : }
2828 : 0 : fputc ('\n', dumpfile);
2829 : :
2830 : 0 : show_code (level + 1, c->block->next);
2831 : :
2832 : 0 : code_indent (level, 0);
2833 : 0 : fputs ("END FORALL", dumpfile);
2834 : 0 : break;
2835 : :
2836 : 0 : case EXEC_CRITICAL:
2837 : 0 : fputs ("CRITICAL\n", dumpfile);
2838 : 0 : show_code (level + 1, c->block->next);
2839 : 0 : code_indent (level, 0);
2840 : 0 : fputs ("END CRITICAL", dumpfile);
2841 : 0 : break;
2842 : :
2843 : 0 : case EXEC_DO:
2844 : 0 : fputs ("DO ", dumpfile);
2845 : 0 : if (c->label1)
2846 : 0 : fprintf (dumpfile, " %-5d ", c->label1->value);
2847 : :
2848 : 0 : show_expr (c->ext.iterator->var);
2849 : 0 : fputc ('=', dumpfile);
2850 : 0 : show_expr (c->ext.iterator->start);
2851 : 0 : fputc (' ', dumpfile);
2852 : 0 : show_expr (c->ext.iterator->end);
2853 : 0 : fputc (' ', dumpfile);
2854 : 0 : show_expr (c->ext.iterator->step);
2855 : :
2856 : 0 : ++show_level;
2857 : 0 : show_code (level + 1, c->block->next);
2858 : 0 : --show_level;
2859 : :
2860 : 0 : if (c->label1)
2861 : : break;
2862 : :
2863 : 0 : show_indent ();
2864 : 0 : fputs ("END DO", dumpfile);
2865 : 0 : break;
2866 : :
2867 : 0 : case EXEC_DO_CONCURRENT:
2868 : 0 : fputs ("DO CONCURRENT ", dumpfile);
2869 : 0 : for (fa = c->ext.forall_iterator; fa; fa = fa->next)
2870 : : {
2871 : 0 : show_expr (fa->var);
2872 : 0 : fputc (' ', dumpfile);
2873 : 0 : show_expr (fa->start);
2874 : 0 : fputc (':', dumpfile);
2875 : 0 : show_expr (fa->end);
2876 : 0 : fputc (':', dumpfile);
2877 : 0 : show_expr (fa->stride);
2878 : :
2879 : 0 : if (fa->next != NULL)
2880 : 0 : fputc (',', dumpfile);
2881 : : }
2882 : 0 : show_expr (c->expr1);
2883 : 0 : ++show_level;
2884 : :
2885 : 0 : show_code (level + 1, c->block->next);
2886 : 0 : --show_level;
2887 : 0 : code_indent (level, c->label1);
2888 : 0 : show_indent ();
2889 : 0 : fputs ("END DO", dumpfile);
2890 : 0 : break;
2891 : :
2892 : 0 : case EXEC_DO_WHILE:
2893 : 0 : fputs ("DO WHILE ", dumpfile);
2894 : 0 : show_expr (c->expr1);
2895 : 0 : fputc ('\n', dumpfile);
2896 : :
2897 : 0 : show_code (level + 1, c->block->next);
2898 : :
2899 : 0 : code_indent (level, c->label1);
2900 : 0 : fputs ("END DO", dumpfile);
2901 : 0 : break;
2902 : :
2903 : 0 : case EXEC_CYCLE:
2904 : 0 : fputs ("CYCLE", dumpfile);
2905 : 0 : if (c->symtree)
2906 : 0 : fprintf (dumpfile, " %s", c->symtree->n.sym->name);
2907 : : break;
2908 : :
2909 : 0 : case EXEC_EXIT:
2910 : 0 : fputs ("EXIT", dumpfile);
2911 : 0 : if (c->symtree)
2912 : 0 : fprintf (dumpfile, " %s", c->symtree->n.sym->name);
2913 : : break;
2914 : :
2915 : 12 : case EXEC_ALLOCATE:
2916 : 12 : fputs ("ALLOCATE ", dumpfile);
2917 : 12 : if (c->expr1)
2918 : : {
2919 : 0 : fputs (" STAT=", dumpfile);
2920 : 0 : show_expr (c->expr1);
2921 : : }
2922 : :
2923 : 12 : if (c->expr2)
2924 : : {
2925 : 0 : fputs (" ERRMSG=", dumpfile);
2926 : 0 : show_expr (c->expr2);
2927 : : }
2928 : :
2929 : 12 : if (c->expr3)
2930 : : {
2931 : 12 : if (c->expr3->mold)
2932 : 0 : fputs (" MOLD=", dumpfile);
2933 : : else
2934 : 12 : fputs (" SOURCE=", dumpfile);
2935 : 12 : show_expr (c->expr3);
2936 : : }
2937 : :
2938 : 24 : for (a = c->ext.alloc.list; a; a = a->next)
2939 : : {
2940 : 12 : fputc (' ', dumpfile);
2941 : 12 : show_expr (a->expr);
2942 : : }
2943 : :
2944 : : break;
2945 : :
2946 : 0 : case EXEC_DEALLOCATE:
2947 : 0 : fputs ("DEALLOCATE ", dumpfile);
2948 : 0 : if (c->expr1)
2949 : : {
2950 : 0 : fputs (" STAT=", dumpfile);
2951 : 0 : show_expr (c->expr1);
2952 : : }
2953 : :
2954 : 0 : if (c->expr2)
2955 : : {
2956 : 0 : fputs (" ERRMSG=", dumpfile);
2957 : 0 : show_expr (c->expr2);
2958 : : }
2959 : :
2960 : 0 : for (a = c->ext.alloc.list; a; a = a->next)
2961 : : {
2962 : 0 : fputc (' ', dumpfile);
2963 : 0 : show_expr (a->expr);
2964 : : }
2965 : :
2966 : : break;
2967 : :
2968 : 0 : case EXEC_OPEN:
2969 : 0 : fputs ("OPEN", dumpfile);
2970 : 0 : open = c->ext.open;
2971 : :
2972 : 0 : if (open->unit)
2973 : : {
2974 : 0 : fputs (" UNIT=", dumpfile);
2975 : 0 : show_expr (open->unit);
2976 : : }
2977 : 0 : if (open->iomsg)
2978 : : {
2979 : 0 : fputs (" IOMSG=", dumpfile);
2980 : 0 : show_expr (open->iomsg);
2981 : : }
2982 : 0 : if (open->iostat)
2983 : : {
2984 : 0 : fputs (" IOSTAT=", dumpfile);
2985 : 0 : show_expr (open->iostat);
2986 : : }
2987 : 0 : if (open->file)
2988 : : {
2989 : 0 : fputs (" FILE=", dumpfile);
2990 : 0 : show_expr (open->file);
2991 : : }
2992 : 0 : if (open->status)
2993 : : {
2994 : 0 : fputs (" STATUS=", dumpfile);
2995 : 0 : show_expr (open->status);
2996 : : }
2997 : 0 : if (open->access)
2998 : : {
2999 : 0 : fputs (" ACCESS=", dumpfile);
3000 : 0 : show_expr (open->access);
3001 : : }
3002 : 0 : if (open->form)
3003 : : {
3004 : 0 : fputs (" FORM=", dumpfile);
3005 : 0 : show_expr (open->form);
3006 : : }
3007 : 0 : if (open->recl)
3008 : : {
3009 : 0 : fputs (" RECL=", dumpfile);
3010 : 0 : show_expr (open->recl);
3011 : : }
3012 : 0 : if (open->blank)
3013 : : {
3014 : 0 : fputs (" BLANK=", dumpfile);
3015 : 0 : show_expr (open->blank);
3016 : : }
3017 : 0 : if (open->position)
3018 : : {
3019 : 0 : fputs (" POSITION=", dumpfile);
3020 : 0 : show_expr (open->position);
3021 : : }
3022 : 0 : if (open->action)
3023 : : {
3024 : 0 : fputs (" ACTION=", dumpfile);
3025 : 0 : show_expr (open->action);
3026 : : }
3027 : 0 : if (open->delim)
3028 : : {
3029 : 0 : fputs (" DELIM=", dumpfile);
3030 : 0 : show_expr (open->delim);
3031 : : }
3032 : 0 : if (open->pad)
3033 : : {
3034 : 0 : fputs (" PAD=", dumpfile);
3035 : 0 : show_expr (open->pad);
3036 : : }
3037 : 0 : if (open->decimal)
3038 : : {
3039 : 0 : fputs (" DECIMAL=", dumpfile);
3040 : 0 : show_expr (open->decimal);
3041 : : }
3042 : 0 : if (open->encoding)
3043 : : {
3044 : 0 : fputs (" ENCODING=", dumpfile);
3045 : 0 : show_expr (open->encoding);
3046 : : }
3047 : 0 : if (open->round)
3048 : : {
3049 : 0 : fputs (" ROUND=", dumpfile);
3050 : 0 : show_expr (open->round);
3051 : : }
3052 : 0 : if (open->sign)
3053 : : {
3054 : 0 : fputs (" SIGN=", dumpfile);
3055 : 0 : show_expr (open->sign);
3056 : : }
3057 : 0 : if (open->convert)
3058 : : {
3059 : 0 : fputs (" CONVERT=", dumpfile);
3060 : 0 : show_expr (open->convert);
3061 : : }
3062 : 0 : if (open->asynchronous)
3063 : : {
3064 : 0 : fputs (" ASYNCHRONOUS=", dumpfile);
3065 : 0 : show_expr (open->asynchronous);
3066 : : }
3067 : 0 : if (open->err != NULL)
3068 : 0 : fprintf (dumpfile, " ERR=%d", open->err->value);
3069 : :
3070 : : break;
3071 : :
3072 : 0 : case EXEC_CLOSE:
3073 : 0 : fputs ("CLOSE", dumpfile);
3074 : 0 : close = c->ext.close;
3075 : :
3076 : 0 : if (close->unit)
3077 : : {
3078 : 0 : fputs (" UNIT=", dumpfile);
3079 : 0 : show_expr (close->unit);
3080 : : }
3081 : 0 : if (close->iomsg)
3082 : : {
3083 : 0 : fputs (" IOMSG=", dumpfile);
3084 : 0 : show_expr (close->iomsg);
3085 : : }
3086 : 0 : if (close->iostat)
3087 : : {
3088 : 0 : fputs (" IOSTAT=", dumpfile);
3089 : 0 : show_expr (close->iostat);
3090 : : }
3091 : 0 : if (close->status)
3092 : : {
3093 : 0 : fputs (" STATUS=", dumpfile);
3094 : 0 : show_expr (close->status);
3095 : : }
3096 : 0 : if (close->err != NULL)
3097 : 0 : fprintf (dumpfile, " ERR=%d", close->err->value);
3098 : : break;
3099 : :
3100 : 0 : case EXEC_BACKSPACE:
3101 : 0 : fputs ("BACKSPACE", dumpfile);
3102 : 0 : goto show_filepos;
3103 : :
3104 : 0 : case EXEC_ENDFILE:
3105 : 0 : fputs ("ENDFILE", dumpfile);
3106 : 0 : goto show_filepos;
3107 : :
3108 : 0 : case EXEC_REWIND:
3109 : 0 : fputs ("REWIND", dumpfile);
3110 : 0 : goto show_filepos;
3111 : :
3112 : 0 : case EXEC_FLUSH:
3113 : 0 : fputs ("FLUSH", dumpfile);
3114 : :
3115 : 0 : show_filepos:
3116 : 0 : fp = c->ext.filepos;
3117 : :
3118 : 0 : if (fp->unit)
3119 : : {
3120 : 0 : fputs (" UNIT=", dumpfile);
3121 : 0 : show_expr (fp->unit);
3122 : : }
3123 : 0 : if (fp->iomsg)
3124 : : {
3125 : 0 : fputs (" IOMSG=", dumpfile);
3126 : 0 : show_expr (fp->iomsg);
3127 : : }
3128 : 0 : if (fp->iostat)
3129 : : {
3130 : 0 : fputs (" IOSTAT=", dumpfile);
3131 : 0 : show_expr (fp->iostat);
3132 : : }
3133 : 0 : if (fp->err != NULL)
3134 : 0 : fprintf (dumpfile, " ERR=%d", fp->err->value);
3135 : : break;
3136 : :
3137 : 0 : case EXEC_INQUIRE:
3138 : 0 : fputs ("INQUIRE", dumpfile);
3139 : 0 : i = c->ext.inquire;
3140 : :
3141 : 0 : if (i->unit)
3142 : : {
3143 : 0 : fputs (" UNIT=", dumpfile);
3144 : 0 : show_expr (i->unit);
3145 : : }
3146 : 0 : if (i->file)
3147 : : {
3148 : 0 : fputs (" FILE=", dumpfile);
3149 : 0 : show_expr (i->file);
3150 : : }
3151 : :
3152 : 0 : if (i->iomsg)
3153 : : {
3154 : 0 : fputs (" IOMSG=", dumpfile);
3155 : 0 : show_expr (i->iomsg);
3156 : : }
3157 : 0 : if (i->iostat)
3158 : : {
3159 : 0 : fputs (" IOSTAT=", dumpfile);
3160 : 0 : show_expr (i->iostat);
3161 : : }
3162 : 0 : if (i->exist)
3163 : : {
3164 : 0 : fputs (" EXIST=", dumpfile);
3165 : 0 : show_expr (i->exist);
3166 : : }
3167 : 0 : if (i->opened)
3168 : : {
3169 : 0 : fputs (" OPENED=", dumpfile);
3170 : 0 : show_expr (i->opened);
3171 : : }
3172 : 0 : if (i->number)
3173 : : {
3174 : 0 : fputs (" NUMBER=", dumpfile);
3175 : 0 : show_expr (i->number);
3176 : : }
3177 : 0 : if (i->named)
3178 : : {
3179 : 0 : fputs (" NAMED=", dumpfile);
3180 : 0 : show_expr (i->named);
3181 : : }
3182 : 0 : if (i->name)
3183 : : {
3184 : 0 : fputs (" NAME=", dumpfile);
3185 : 0 : show_expr (i->name);
3186 : : }
3187 : 0 : if (i->access)
3188 : : {
3189 : 0 : fputs (" ACCESS=", dumpfile);
3190 : 0 : show_expr (i->access);
3191 : : }
3192 : 0 : if (i->sequential)
3193 : : {
3194 : 0 : fputs (" SEQUENTIAL=", dumpfile);
3195 : 0 : show_expr (i->sequential);
3196 : : }
3197 : :
3198 : 0 : if (i->direct)
3199 : : {
3200 : 0 : fputs (" DIRECT=", dumpfile);
3201 : 0 : show_expr (i->direct);
3202 : : }
3203 : 0 : if (i->form)
3204 : : {
3205 : 0 : fputs (" FORM=", dumpfile);
3206 : 0 : show_expr (i->form);
3207 : : }
3208 : 0 : if (i->formatted)
3209 : : {
3210 : 0 : fputs (" FORMATTED", dumpfile);
3211 : 0 : show_expr (i->formatted);
3212 : : }
3213 : 0 : if (i->unformatted)
3214 : : {
3215 : 0 : fputs (" UNFORMATTED=", dumpfile);
3216 : 0 : show_expr (i->unformatted);
3217 : : }
3218 : 0 : if (i->recl)
3219 : : {
3220 : 0 : fputs (" RECL=", dumpfile);
3221 : 0 : show_expr (i->recl);
3222 : : }
3223 : 0 : if (i->nextrec)
3224 : : {
3225 : 0 : fputs (" NEXTREC=", dumpfile);
3226 : 0 : show_expr (i->nextrec);
3227 : : }
3228 : 0 : if (i->blank)
3229 : : {
3230 : 0 : fputs (" BLANK=", dumpfile);
3231 : 0 : show_expr (i->blank);
3232 : : }
3233 : 0 : if (i->position)
3234 : : {
3235 : 0 : fputs (" POSITION=", dumpfile);
3236 : 0 : show_expr (i->position);
3237 : : }
3238 : 0 : if (i->action)
3239 : : {
3240 : 0 : fputs (" ACTION=", dumpfile);
3241 : 0 : show_expr (i->action);
3242 : : }
3243 : 0 : if (i->read)
3244 : : {
3245 : 0 : fputs (" READ=", dumpfile);
3246 : 0 : show_expr (i->read);
3247 : : }
3248 : 0 : if (i->write)
3249 : : {
3250 : 0 : fputs (" WRITE=", dumpfile);
3251 : 0 : show_expr (i->write);
3252 : : }
3253 : 0 : if (i->readwrite)
3254 : : {
3255 : 0 : fputs (" READWRITE=", dumpfile);
3256 : 0 : show_expr (i->readwrite);
3257 : : }
3258 : 0 : if (i->delim)
3259 : : {
3260 : 0 : fputs (" DELIM=", dumpfile);
3261 : 0 : show_expr (i->delim);
3262 : : }
3263 : 0 : if (i->pad)
3264 : : {
3265 : 0 : fputs (" PAD=", dumpfile);
3266 : 0 : show_expr (i->pad);
3267 : : }
3268 : 0 : if (i->convert)
3269 : : {
3270 : 0 : fputs (" CONVERT=", dumpfile);
3271 : 0 : show_expr (i->convert);
3272 : : }
3273 : 0 : if (i->asynchronous)
3274 : : {
3275 : 0 : fputs (" ASYNCHRONOUS=", dumpfile);
3276 : 0 : show_expr (i->asynchronous);
3277 : : }
3278 : 0 : if (i->decimal)
3279 : : {
3280 : 0 : fputs (" DECIMAL=", dumpfile);
3281 : 0 : show_expr (i->decimal);
3282 : : }
3283 : 0 : if (i->encoding)
3284 : : {
3285 : 0 : fputs (" ENCODING=", dumpfile);
3286 : 0 : show_expr (i->encoding);
3287 : : }
3288 : 0 : if (i->pending)
3289 : : {
3290 : 0 : fputs (" PENDING=", dumpfile);
3291 : 0 : show_expr (i->pending);
3292 : : }
3293 : 0 : if (i->round)
3294 : : {
3295 : 0 : fputs (" ROUND=", dumpfile);
3296 : 0 : show_expr (i->round);
3297 : : }
3298 : 0 : if (i->sign)
3299 : : {
3300 : 0 : fputs (" SIGN=", dumpfile);
3301 : 0 : show_expr (i->sign);
3302 : : }
3303 : 0 : if (i->size)
3304 : : {
3305 : 0 : fputs (" SIZE=", dumpfile);
3306 : 0 : show_expr (i->size);
3307 : : }
3308 : 0 : if (i->id)
3309 : : {
3310 : 0 : fputs (" ID=", dumpfile);
3311 : 0 : show_expr (i->id);
3312 : : }
3313 : :
3314 : 0 : if (i->err != NULL)
3315 : 0 : fprintf (dumpfile, " ERR=%d", i->err->value);
3316 : : break;
3317 : :
3318 : 0 : case EXEC_IOLENGTH:
3319 : 0 : fputs ("IOLENGTH ", dumpfile);
3320 : 0 : show_expr (c->expr1);
3321 : 0 : goto show_dt_code;
3322 : 0 : break;
3323 : :
3324 : 0 : case EXEC_READ:
3325 : 0 : fputs ("READ", dumpfile);
3326 : 0 : goto show_dt;
3327 : :
3328 : 34 : case EXEC_WRITE:
3329 : 34 : fputs ("WRITE", dumpfile);
3330 : :
3331 : 34 : show_dt:
3332 : 34 : dt = c->ext.dt;
3333 : 34 : if (dt->io_unit)
3334 : : {
3335 : 34 : fputs (" UNIT=", dumpfile);
3336 : 34 : show_expr (dt->io_unit);
3337 : : }
3338 : :
3339 : 34 : if (dt->format_expr)
3340 : : {
3341 : 0 : fputs (" FMT=", dumpfile);
3342 : 0 : show_expr (dt->format_expr);
3343 : : }
3344 : :
3345 : 34 : if (dt->format_label != NULL)
3346 : 34 : fprintf (dumpfile, " FMT=%d", dt->format_label->value);
3347 : 34 : if (dt->namelist)
3348 : 0 : fprintf (dumpfile, " NML=%s", dt->namelist->name);
3349 : :
3350 : 34 : if (dt->iomsg)
3351 : : {
3352 : 0 : fputs (" IOMSG=", dumpfile);
3353 : 0 : show_expr (dt->iomsg);
3354 : : }
3355 : 34 : if (dt->iostat)
3356 : : {
3357 : 0 : fputs (" IOSTAT=", dumpfile);
3358 : 0 : show_expr (dt->iostat);
3359 : : }
3360 : 34 : if (dt->size)
3361 : : {
3362 : 0 : fputs (" SIZE=", dumpfile);
3363 : 0 : show_expr (dt->size);
3364 : : }
3365 : 34 : if (dt->rec)
3366 : : {
3367 : 0 : fputs (" REC=", dumpfile);
3368 : 0 : show_expr (dt->rec);
3369 : : }
3370 : 34 : if (dt->advance)
3371 : : {
3372 : 0 : fputs (" ADVANCE=", dumpfile);
3373 : 0 : show_expr (dt->advance);
3374 : : }
3375 : 34 : if (dt->id)
3376 : : {
3377 : 0 : fputs (" ID=", dumpfile);
3378 : 0 : show_expr (dt->id);
3379 : : }
3380 : 34 : if (dt->pos)
3381 : : {
3382 : 0 : fputs (" POS=", dumpfile);
3383 : 0 : show_expr (dt->pos);
3384 : : }
3385 : 34 : if (dt->asynchronous)
3386 : : {
3387 : 0 : fputs (" ASYNCHRONOUS=", dumpfile);
3388 : 0 : show_expr (dt->asynchronous);
3389 : : }
3390 : 34 : if (dt->blank)
3391 : : {
3392 : 0 : fputs (" BLANK=", dumpfile);
3393 : 0 : show_expr (dt->blank);
3394 : : }
3395 : 34 : if (dt->decimal)
3396 : : {
3397 : 0 : fputs (" DECIMAL=", dumpfile);
3398 : 0 : show_expr (dt->decimal);
3399 : : }
3400 : 34 : if (dt->delim)
3401 : : {
3402 : 0 : fputs (" DELIM=", dumpfile);
3403 : 0 : show_expr (dt->delim);
3404 : : }
3405 : 34 : if (dt->pad)
3406 : : {
3407 : 0 : fputs (" PAD=", dumpfile);
3408 : 0 : show_expr (dt->pad);
3409 : : }
3410 : 34 : if (dt->round)
3411 : : {
3412 : 0 : fputs (" ROUND=", dumpfile);
3413 : 0 : show_expr (dt->round);
3414 : : }
3415 : 34 : if (dt->sign)
3416 : : {
3417 : 0 : fputs (" SIGN=", dumpfile);
3418 : 0 : show_expr (dt->sign);
3419 : : }
3420 : :
3421 : 34 : show_dt_code:
3422 : 102 : for (c = c->block->next; c; c = c->next)
3423 : 68 : show_code_node (level + (c->next != NULL), c);
3424 : : return;
3425 : :
3426 : 34 : case EXEC_TRANSFER:
3427 : 34 : fputs ("TRANSFER ", dumpfile);
3428 : 34 : show_expr (c->expr1);
3429 : 34 : break;
3430 : :
3431 : 34 : case EXEC_DT_END:
3432 : 34 : fputs ("DT_END", dumpfile);
3433 : 34 : dt = c->ext.dt;
3434 : :
3435 : 34 : if (dt->err != NULL)
3436 : 0 : fprintf (dumpfile, " ERR=%d", dt->err->value);
3437 : 34 : if (dt->end != NULL)
3438 : 0 : fprintf (dumpfile, " END=%d", dt->end->value);
3439 : 34 : if (dt->eor != NULL)
3440 : 0 : fprintf (dumpfile, " EOR=%d", dt->eor->value);
3441 : : break;
3442 : :
3443 : 0 : case EXEC_WAIT:
3444 : 0 : fputs ("WAIT", dumpfile);
3445 : :
3446 : 0 : if (c->ext.wait != NULL)
3447 : : {
3448 : 0 : gfc_wait *wait = c->ext.wait;
3449 : 0 : if (wait->unit)
3450 : : {
3451 : 0 : fputs (" UNIT=", dumpfile);
3452 : 0 : show_expr (wait->unit);
3453 : : }
3454 : 0 : if (wait->iostat)
3455 : : {
3456 : 0 : fputs (" IOSTAT=", dumpfile);
3457 : 0 : show_expr (wait->iostat);
3458 : : }
3459 : 0 : if (wait->iomsg)
3460 : : {
3461 : 0 : fputs (" IOMSG=", dumpfile);
3462 : 0 : show_expr (wait->iomsg);
3463 : : }
3464 : 0 : if (wait->id)
3465 : : {
3466 : 0 : fputs (" ID=", dumpfile);
3467 : 0 : show_expr (wait->id);
3468 : : }
3469 : 0 : if (wait->err)
3470 : 0 : fprintf (dumpfile, " ERR=%d", wait->err->value);
3471 : 0 : if (wait->end)
3472 : 0 : fprintf (dumpfile, " END=%d", wait->end->value);
3473 : 0 : if (wait->eor)
3474 : 0 : fprintf (dumpfile, " EOR=%d", wait->eor->value);
3475 : : }
3476 : : break;
3477 : :
3478 : 0 : case EXEC_OACC_PARALLEL_LOOP:
3479 : 0 : case EXEC_OACC_PARALLEL:
3480 : 0 : case EXEC_OACC_KERNELS_LOOP:
3481 : 0 : case EXEC_OACC_KERNELS:
3482 : 0 : case EXEC_OACC_SERIAL_LOOP:
3483 : 0 : case EXEC_OACC_SERIAL:
3484 : 0 : case EXEC_OACC_DATA:
3485 : 0 : case EXEC_OACC_HOST_DATA:
3486 : 0 : case EXEC_OACC_LOOP:
3487 : 0 : case EXEC_OACC_UPDATE:
3488 : 0 : case EXEC_OACC_WAIT:
3489 : 0 : case EXEC_OACC_CACHE:
3490 : 0 : case EXEC_OACC_ENTER_DATA:
3491 : 0 : case EXEC_OACC_EXIT_DATA:
3492 : 0 : case EXEC_OMP_ALLOCATE:
3493 : 0 : case EXEC_OMP_ALLOCATORS:
3494 : 0 : case EXEC_OMP_ASSUME:
3495 : 0 : case EXEC_OMP_ATOMIC:
3496 : 0 : case EXEC_OMP_CANCEL:
3497 : 0 : case EXEC_OMP_CANCELLATION_POINT:
3498 : 0 : case EXEC_OMP_BARRIER:
3499 : 0 : case EXEC_OMP_CRITICAL:
3500 : 0 : case EXEC_OMP_DEPOBJ:
3501 : 0 : case EXEC_OMP_DISTRIBUTE:
3502 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
3503 : 0 : case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
3504 : 0 : case EXEC_OMP_DISTRIBUTE_SIMD:
3505 : 0 : case EXEC_OMP_DO:
3506 : 0 : case EXEC_OMP_DO_SIMD:
3507 : 0 : case EXEC_OMP_ERROR:
3508 : 0 : case EXEC_OMP_FLUSH:
3509 : 0 : case EXEC_OMP_LOOP:
3510 : 0 : case EXEC_OMP_MASKED:
3511 : 0 : case EXEC_OMP_MASKED_TASKLOOP:
3512 : 0 : case EXEC_OMP_MASKED_TASKLOOP_SIMD:
3513 : 0 : case EXEC_OMP_MASTER:
3514 : 0 : case EXEC_OMP_MASTER_TASKLOOP:
3515 : 0 : case EXEC_OMP_MASTER_TASKLOOP_SIMD:
3516 : 0 : case EXEC_OMP_ORDERED:
3517 : 0 : case EXEC_OMP_PARALLEL:
3518 : 0 : case EXEC_OMP_PARALLEL_DO:
3519 : 0 : case EXEC_OMP_PARALLEL_DO_SIMD:
3520 : 0 : case EXEC_OMP_PARALLEL_LOOP:
3521 : 0 : case EXEC_OMP_PARALLEL_MASKED:
3522 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP:
3523 : 0 : case EXEC_OMP_PARALLEL_MASKED_TASKLOOP_SIMD:
3524 : 0 : case EXEC_OMP_PARALLEL_MASTER:
3525 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP:
3526 : 0 : case EXEC_OMP_PARALLEL_MASTER_TASKLOOP_SIMD:
3527 : 0 : case EXEC_OMP_PARALLEL_SECTIONS:
3528 : 0 : case EXEC_OMP_PARALLEL_WORKSHARE:
3529 : 0 : case EXEC_OMP_SCAN:
3530 : 0 : case EXEC_OMP_SCOPE:
3531 : 0 : case EXEC_OMP_SECTIONS:
3532 : 0 : case EXEC_OMP_SIMD:
3533 : 0 : case EXEC_OMP_SINGLE:
3534 : 0 : case EXEC_OMP_TARGET:
3535 : 0 : case EXEC_OMP_TARGET_DATA:
3536 : 0 : case EXEC_OMP_TARGET_ENTER_DATA:
3537 : 0 : case EXEC_OMP_TARGET_EXIT_DATA:
3538 : 0 : case EXEC_OMP_TARGET_PARALLEL:
3539 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO:
3540 : 0 : case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
3541 : 0 : case EXEC_OMP_TARGET_PARALLEL_LOOP:
3542 : 0 : case EXEC_OMP_TARGET_SIMD:
3543 : 0 : case EXEC_OMP_TARGET_TEAMS:
3544 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
3545 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
3546 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
3547 : 0 : case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
3548 : 0 : case EXEC_OMP_TARGET_TEAMS_LOOP:
3549 : 0 : case EXEC_OMP_TARGET_UPDATE:
3550 : 0 : case EXEC_OMP_TASK:
3551 : 0 : case EXEC_OMP_TASKGROUP:
3552 : 0 : case EXEC_OMP_TASKLOOP:
3553 : 0 : case EXEC_OMP_TASKLOOP_SIMD:
3554 : 0 : case EXEC_OMP_TASKWAIT:
3555 : 0 : case EXEC_OMP_TASKYIELD:
3556 : 0 : case EXEC_OMP_TEAMS:
3557 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE:
3558 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
3559 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
3560 : 0 : case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
3561 : 0 : case EXEC_OMP_TEAMS_LOOP:
3562 : 0 : case EXEC_OMP_WORKSHARE:
3563 : 0 : show_omp_node (level, c);
3564 : 0 : break;
3565 : :
3566 : 0 : default:
3567 : 0 : gfc_internal_error ("show_code_node(): Bad statement code");
3568 : : }
3569 : : }
3570 : :
3571 : :
3572 : : /* Show an equivalence chain. */
3573 : :
3574 : : static void
3575 : 0 : show_equiv (gfc_equiv *eq)
3576 : : {
3577 : 0 : show_indent ();
3578 : 0 : fputs ("Equivalence: ", dumpfile);
3579 : 0 : while (eq)
3580 : : {
3581 : 0 : show_expr (eq->expr);
3582 : 0 : eq = eq->eq;
3583 : 0 : if (eq)
3584 : 0 : fputs (", ", dumpfile);
3585 : : }
3586 : 0 : }
3587 : :
3588 : :
3589 : : /* Show a freakin' whole namespace. */
3590 : :
3591 : : static void
3592 : 52 : show_namespace (gfc_namespace *ns)
3593 : : {
3594 : 52 : gfc_interface *intr;
3595 : 52 : gfc_namespace *save;
3596 : 52 : int op;
3597 : 52 : gfc_equiv *eq;
3598 : 52 : int i;
3599 : :
3600 : 52 : gcc_assert (ns);
3601 : 52 : save = gfc_current_ns;
3602 : :
3603 : 52 : show_indent ();
3604 : 52 : fputs ("Namespace:", dumpfile);
3605 : :
3606 : 52 : i = 0;
3607 : 88 : do
3608 : : {
3609 : 88 : int l = i;
3610 : 88 : while (i < GFC_LETTERS - 1
3611 : 1352 : && gfc_compare_types (&ns->default_type[i+1],
3612 : : &ns->default_type[l]))
3613 : : i++;
3614 : :
3615 : 88 : if (i > l)
3616 : 82 : fprintf (dumpfile, " %c-%c: ", l+'A', i+'A');
3617 : : else
3618 : 6 : fprintf (dumpfile, " %c: ", l+'A');
3619 : :
3620 : 88 : show_typespec(&ns->default_type[l]);
3621 : 88 : i++;
3622 : 88 : } while (i < GFC_LETTERS);
3623 : :
3624 : 52 : if (ns->proc_name != NULL)
3625 : : {
3626 : 52 : show_indent ();
3627 : 52 : fprintf (dumpfile, "procedure name = %s", ns->proc_name->name);
3628 : : }
3629 : :
3630 : 52 : ++show_level;
3631 : 52 : gfc_current_ns = ns;
3632 : 52 : gfc_traverse_symtree (ns->common_root, show_common);
3633 : :
3634 : 52 : gfc_traverse_symtree (ns->sym_root, show_symtree);
3635 : :
3636 : 1560 : for (op = GFC_INTRINSIC_BEGIN; op != GFC_INTRINSIC_END; op++)
3637 : : {
3638 : : /* User operator interfaces */
3639 : 1456 : intr = ns->op[op];
3640 : 1456 : if (intr == NULL)
3641 : 1456 : continue;
3642 : :
3643 : 0 : show_indent ();
3644 : 0 : fprintf (dumpfile, "Operator interfaces for %s:",
3645 : : gfc_op2string ((gfc_intrinsic_op) op));
3646 : :
3647 : 0 : for (; intr; intr = intr->next)
3648 : 0 : fprintf (dumpfile, " %s", intr->sym->name);
3649 : : }
3650 : :
3651 : 52 : if (ns->uop_root != NULL)
3652 : : {
3653 : 0 : show_indent ();
3654 : 0 : fputs ("User operators:\n", dumpfile);
3655 : 0 : gfc_traverse_user_op (ns, show_uop);
3656 : : }
3657 : :
3658 : 52 : for (eq = ns->equiv; eq; eq = eq->next)
3659 : 0 : show_equiv (eq);
3660 : :
3661 : 52 : if (ns->oacc_declare)
3662 : : {
3663 : : struct gfc_oacc_declare *decl;
3664 : : /* Dump !$ACC DECLARE clauses. */
3665 : 0 : for (decl = ns->oacc_declare; decl; decl = decl->next)
3666 : : {
3667 : 0 : show_indent ();
3668 : 0 : fprintf (dumpfile, "!$ACC DECLARE");
3669 : 0 : show_omp_clauses (decl->clauses);
3670 : : }
3671 : : }
3672 : :
3673 : 52 : if (ns->omp_assumes)
3674 : : {
3675 : 0 : show_indent ();
3676 : 0 : fprintf (dumpfile, "!$OMP ASSUMES");
3677 : 0 : show_omp_assumes (ns->omp_assumes);
3678 : : }
3679 : :
3680 : 52 : fputc ('\n', dumpfile);
3681 : 52 : show_indent ();
3682 : 52 : fputs ("code:", dumpfile);
3683 : 52 : show_code (show_level, ns->code);
3684 : 52 : --show_level;
3685 : :
3686 : 64 : for (ns = ns->contained; ns; ns = ns->sibling)
3687 : : {
3688 : 12 : fputs ("\nCONTAINS\n", dumpfile);
3689 : 12 : ++show_level;
3690 : 12 : show_namespace (ns);
3691 : 12 : --show_level;
3692 : : }
3693 : :
3694 : 52 : fputc ('\n', dumpfile);
3695 : 52 : gfc_current_ns = save;
3696 : 52 : }
3697 : :
3698 : :
3699 : : /* Main function for dumping a parse tree. */
3700 : :
3701 : : void
3702 : 40 : gfc_dump_parse_tree (gfc_namespace *ns, FILE *file)
3703 : : {
3704 : 40 : dumpfile = file;
3705 : 40 : show_namespace (ns);
3706 : 40 : }
3707 : :
3708 : : /* This part writes BIND(C) definition for use in external C programs. */
3709 : :
3710 : : static void write_interop_decl (gfc_symbol *);
3711 : : static void write_proc (gfc_symbol *, bool);
3712 : :
3713 : : void
3714 : 0 : gfc_dump_c_prototypes (gfc_namespace *ns, FILE *file)
3715 : : {
3716 : 0 : int error_count;
3717 : 0 : gfc_get_errors (NULL, &error_count);
3718 : 0 : if (error_count != 0)
3719 : 0 : return;
3720 : 0 : dumpfile = file;
3721 : 0 : gfc_traverse_ns (ns, write_interop_decl);
3722 : : }
3723 : :
3724 : : /* Loop over all global symbols, writing out their declarations. */
3725 : :
3726 : : void
3727 : 0 : gfc_dump_external_c_prototypes (FILE * file)
3728 : : {
3729 : 0 : dumpfile = file;
3730 : 0 : fprintf (dumpfile,
3731 : 0 : _("/* Prototypes for external procedures generated from %s\n"
3732 : : " by GNU Fortran %s%s.\n\n"
3733 : : " Use of this interface is discouraged, consider using the\n"
3734 : : " BIND(C) feature of standard Fortran instead. */\n\n"),
3735 : : gfc_source_file, pkgversion_string, version_string);
3736 : :
3737 : 0 : for (gfc_current_ns = gfc_global_ns_list; gfc_current_ns;
3738 : 0 : gfc_current_ns = gfc_current_ns->sibling)
3739 : : {
3740 : 0 : gfc_symbol *sym = gfc_current_ns->proc_name;
3741 : :
3742 : 0 : if (sym == NULL || sym->attr.flavor != FL_PROCEDURE
3743 : 0 : || sym->attr.is_bind_c)
3744 : 0 : continue;
3745 : :
3746 : 0 : write_proc (sym, false);
3747 : : }
3748 : 0 : return;
3749 : : }
3750 : :
3751 : : enum type_return { T_OK=0, T_WARN, T_ERROR };
3752 : :
3753 : : /* Return the name of the type for later output. Both function pointers and
3754 : : void pointers will be mapped to void *. */
3755 : :
3756 : : static enum type_return
3757 : 0 : get_c_type_name (gfc_typespec *ts, gfc_array_spec *as, const char **pre,
3758 : : const char **type_name, bool *asterisk, const char **post,
3759 : : bool func_ret)
3760 : : {
3761 : 0 : static char post_buffer[40];
3762 : 0 : enum type_return ret;
3763 : 0 : ret = T_ERROR;
3764 : :
3765 : 0 : *pre = " ";
3766 : 0 : *asterisk = false;
3767 : 0 : *post = "";
3768 : 0 : *type_name = "<error>";
3769 : 0 : if (ts->type == BT_REAL || ts->type == BT_INTEGER || ts->type == BT_COMPLEX)
3770 : : {
3771 : 0 : if (ts->is_c_interop && ts->interop_kind)
3772 : : ret = T_OK;
3773 : : else
3774 : 0 : ret = T_WARN;
3775 : :
3776 : 0 : for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3777 : : {
3778 : 0 : if (c_interop_kinds_table[i].f90_type == ts->type
3779 : 0 : && c_interop_kinds_table[i].value == ts->kind)
3780 : : {
3781 : : /* Skip over 'c_'. */
3782 : 0 : *type_name = c_interop_kinds_table[i].name + 2;
3783 : 0 : if (strcmp (*type_name, "long_long") == 0)
3784 : 0 : *type_name = "long long";
3785 : 0 : if (strcmp (*type_name, "long_double") == 0)
3786 : 0 : *type_name = "long double";
3787 : 0 : if (strcmp (*type_name, "signed_char") == 0)
3788 : 0 : *type_name = "signed char";
3789 : 0 : else if (strcmp (*type_name, "size_t") == 0)
3790 : 0 : *type_name = "ssize_t";
3791 : 0 : else if (strcmp (*type_name, "float_complex") == 0)
3792 : 0 : *type_name = "__GFORTRAN_FLOAT_COMPLEX";
3793 : 0 : else if (strcmp (*type_name, "double_complex") == 0)
3794 : 0 : *type_name = "__GFORTRAN_DOUBLE_COMPLEX";
3795 : 0 : else if (strcmp (*type_name, "long_double_complex") == 0)
3796 : 0 : *type_name = "__GFORTRAN_LONG_DOUBLE_COMPLEX";
3797 : :
3798 : : break;
3799 : : }
3800 : : }
3801 : : }
3802 : : else if (ts->type == BT_LOGICAL)
3803 : : {
3804 : 0 : if (ts->is_c_interop && ts->interop_kind)
3805 : : {
3806 : 0 : *type_name = "_Bool";
3807 : 0 : ret = T_OK;
3808 : : }
3809 : : else
3810 : : {
3811 : : /* Let's select an appropriate int, with a warning. */
3812 : 0 : for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3813 : : {
3814 : 0 : if (c_interop_kinds_table[i].f90_type == BT_INTEGER
3815 : 0 : && c_interop_kinds_table[i].value == ts->kind)
3816 : : {
3817 : 0 : *type_name = c_interop_kinds_table[i].name + 2;
3818 : 0 : ret = T_WARN;
3819 : : }
3820 : : }
3821 : : }
3822 : : }
3823 : : else if (ts->type == BT_CHARACTER)
3824 : : {
3825 : 0 : if (ts->is_c_interop)
3826 : : {
3827 : 0 : *type_name = "char";
3828 : 0 : ret = T_OK;
3829 : : }
3830 : : else
3831 : : {
3832 : 0 : if (ts->kind == gfc_default_character_kind)
3833 : 0 : *type_name = "char";
3834 : : else
3835 : : /* Let's select an appropriate int. */
3836 : 0 : for (int i = 0; i < ISOCBINDING_NUMBER; i++)
3837 : : {
3838 : 0 : if (c_interop_kinds_table[i].f90_type == BT_INTEGER
3839 : 0 : && c_interop_kinds_table[i].value == ts->kind)
3840 : : {
3841 : 0 : *type_name = c_interop_kinds_table[i].name + 2;
3842 : 0 : break;
3843 : : }
3844 : : }
3845 : : ret = T_WARN;
3846 : :
3847 : : }
3848 : : }
3849 : : else if (ts->type == BT_DERIVED)
3850 : : {
3851 : 0 : if (ts->u.derived->from_intmod == INTMOD_ISO_C_BINDING)
3852 : : {
3853 : 0 : if (strcmp (ts->u.derived->name, "c_ptr") == 0)
3854 : 0 : *type_name = "void";
3855 : 0 : else if (strcmp (ts->u.derived->name, "c_funptr") == 0)
3856 : : {
3857 : 0 : *type_name = "int ";
3858 : 0 : if (func_ret)
3859 : : {
3860 : 0 : *pre = "(";
3861 : 0 : *post = "())";
3862 : : }
3863 : : else
3864 : : {
3865 : 0 : *pre = "(";
3866 : 0 : *post = ")()";
3867 : : }
3868 : : }
3869 : 0 : *asterisk = true;
3870 : 0 : ret = T_OK;
3871 : : }
3872 : : else
3873 : 0 : *type_name = ts->u.derived->name;
3874 : :
3875 : : ret = T_OK;
3876 : : }
3877 : :
3878 : 0 : if (ret != T_ERROR && as)
3879 : : {
3880 : 0 : mpz_t sz;
3881 : 0 : bool size_ok;
3882 : 0 : size_ok = spec_size (as, &sz);
3883 : 0 : gcc_assert (size_ok == true);
3884 : 0 : gmp_snprintf (post_buffer, sizeof(post_buffer), "[%Zd]", sz);
3885 : 0 : *post = post_buffer;
3886 : 0 : mpz_clear (sz);
3887 : : }
3888 : 0 : return ret;
3889 : : }
3890 : :
3891 : : /* Write out a declaration. */
3892 : : static void
3893 : 0 : write_decl (gfc_typespec *ts, gfc_array_spec *as, const char *sym_name,
3894 : : bool func_ret, locus *where, bool bind_c)
3895 : : {
3896 : 0 : const char *pre, *type_name, *post;
3897 : 0 : bool asterisk;
3898 : 0 : enum type_return rok;
3899 : :
3900 : 0 : rok = get_c_type_name (ts, as, &pre, &type_name, &asterisk, &post, func_ret);
3901 : 0 : if (rok == T_ERROR)
3902 : : {
3903 : 0 : gfc_error_now ("Cannot convert %qs to interoperable type at %L",
3904 : : gfc_typename (ts), where);
3905 : 0 : fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */",
3906 : : gfc_typename (ts));
3907 : 0 : return;
3908 : : }
3909 : 0 : fputs (type_name, dumpfile);
3910 : 0 : fputs (pre, dumpfile);
3911 : 0 : if (asterisk)
3912 : 0 : fputs ("*", dumpfile);
3913 : :
3914 : 0 : fputs (sym_name, dumpfile);
3915 : 0 : fputs (post, dumpfile);
3916 : :
3917 : 0 : if (rok == T_WARN && bind_c)
3918 : 0 : fprintf (dumpfile," /* WARNING: Converting '%s' to interoperable type */",
3919 : : gfc_typename (ts));
3920 : : }
3921 : :
3922 : : /* Write out an interoperable type. It will be written as a typedef
3923 : : for a struct. */
3924 : :
3925 : : static void
3926 : 0 : write_type (gfc_symbol *sym)
3927 : : {
3928 : 0 : gfc_component *c;
3929 : :
3930 : 0 : fprintf (dumpfile, "typedef struct %s {\n", sym->name);
3931 : 0 : for (c = sym->components; c; c = c->next)
3932 : : {
3933 : 0 : fputs (" ", dumpfile);
3934 : 0 : write_decl (&(c->ts), c->as, c->name, false, &sym->declared_at, true);
3935 : 0 : fputs (";\n", dumpfile);
3936 : : }
3937 : :
3938 : 0 : fprintf (dumpfile, "} %s;\n", sym->name);
3939 : 0 : }
3940 : :
3941 : : /* Write out a variable. */
3942 : :
3943 : : static void
3944 : 0 : write_variable (gfc_symbol *sym)
3945 : : {
3946 : 0 : const char *sym_name;
3947 : :
3948 : 0 : gcc_assert (sym->attr.flavor == FL_VARIABLE);
3949 : :
3950 : 0 : if (sym->binding_label)
3951 : : sym_name = sym->binding_label;
3952 : : else
3953 : 0 : sym_name = sym->name;
3954 : :
3955 : 0 : fputs ("extern ", dumpfile);
3956 : 0 : write_decl (&(sym->ts), sym->as, sym_name, false, &sym->declared_at, true);
3957 : 0 : fputs (";\n", dumpfile);
3958 : 0 : }
3959 : :
3960 : :
3961 : : /* Write out a procedure, including its arguments. */
3962 : : static void
3963 : 0 : write_proc (gfc_symbol *sym, bool bind_c)
3964 : : {
3965 : 0 : const char *pre, *type_name, *post;
3966 : 0 : bool asterisk;
3967 : 0 : enum type_return rok;
3968 : 0 : gfc_formal_arglist *f;
3969 : 0 : const char *sym_name;
3970 : 0 : const char *intent_in;
3971 : 0 : bool external_character;
3972 : :
3973 : 0 : external_character = sym->ts.type == BT_CHARACTER && !bind_c;
3974 : :
3975 : 0 : if (sym->binding_label)
3976 : : sym_name = sym->binding_label;
3977 : : else
3978 : 0 : sym_name = sym->name;
3979 : :
3980 : 0 : if (sym->ts.type == BT_UNKNOWN || external_character)
3981 : : {
3982 : 0 : fprintf (dumpfile, "void ");
3983 : 0 : fputs (sym_name, dumpfile);
3984 : : }
3985 : : else
3986 : 0 : write_decl (&(sym->ts), sym->as, sym_name, true, &sym->declared_at, bind_c);
3987 : :
3988 : 0 : if (!bind_c)
3989 : 0 : fputs ("_", dumpfile);
3990 : :
3991 : 0 : fputs (" (", dumpfile);
3992 : 0 : if (external_character)
3993 : : {
3994 : 0 : fprintf (dumpfile, "char *result_%s, size_t result_%s_len",
3995 : : sym_name, sym_name);
3996 : 0 : if (sym->formal)
3997 : 0 : fputs (", ", dumpfile);
3998 : : }
3999 : :
4000 : 0 : for (f = sym->formal; f; f = f->next)
4001 : : {
4002 : 0 : gfc_symbol *s;
4003 : 0 : s = f->sym;
4004 : 0 : rok = get_c_type_name (&(s->ts), NULL, &pre, &type_name, &asterisk,
4005 : : &post, false);
4006 : 0 : if (rok == T_ERROR)
4007 : : {
4008 : 0 : gfc_error_now ("Cannot convert %qs to interoperable type at %L",
4009 : : gfc_typename (&s->ts), &s->declared_at);
4010 : 0 : fprintf (dumpfile, "/* Cannot convert '%s' to interoperable type */",
4011 : : gfc_typename (&s->ts));
4012 : 0 : return;
4013 : : }
4014 : :
4015 : 0 : if (!s->attr.value)
4016 : 0 : asterisk = true;
4017 : :
4018 : 0 : if (s->attr.intent == INTENT_IN && !s->attr.value)
4019 : : intent_in = "const ";
4020 : : else
4021 : 0 : intent_in = "";
4022 : :
4023 : 0 : fputs (intent_in, dumpfile);
4024 : 0 : fputs (type_name, dumpfile);
4025 : 0 : fputs (pre, dumpfile);
4026 : 0 : if (asterisk)
4027 : 0 : fputs ("*", dumpfile);
4028 : :
4029 : 0 : fputs (s->name, dumpfile);
4030 : 0 : fputs (post, dumpfile);
4031 : 0 : if (bind_c && rok == T_WARN)
4032 : 0 : fputs(" /* WARNING: non-interoperable KIND */ ", dumpfile);
4033 : :
4034 : 0 : if (f->next)
4035 : 0 : fputs(", ", dumpfile);
4036 : : }
4037 : 0 : if (!bind_c)
4038 : 0 : for (f = sym->formal; f; f = f->next)
4039 : 0 : if (f->sym->ts.type == BT_CHARACTER)
4040 : 0 : fprintf (dumpfile, ", size_t %s_len", f->sym->name);
4041 : :
4042 : 0 : fputs (");\n", dumpfile);
4043 : : }
4044 : :
4045 : :
4046 : : /* Write a C-interoperable declaration as a C prototype or extern
4047 : : declaration. */
4048 : :
4049 : : static void
4050 : 0 : write_interop_decl (gfc_symbol *sym)
4051 : : {
4052 : : /* Only dump bind(c) entities. */
4053 : 0 : if (!sym->attr.is_bind_c)
4054 : : return;
4055 : :
4056 : : /* Don't dump our iso c module. */
4057 : 0 : if (sym->from_intmod == INTMOD_ISO_C_BINDING)
4058 : : return;
4059 : :
4060 : 0 : if (sym->attr.flavor == FL_VARIABLE)
4061 : 0 : write_variable (sym);
4062 : 0 : else if (sym->attr.flavor == FL_DERIVED)
4063 : 0 : write_type (sym);
4064 : 0 : else if (sym->attr.flavor == FL_PROCEDURE)
4065 : 0 : write_proc (sym, true);
4066 : : }
4067 : :
4068 : : /* This section deals with dumping the global symbol tree. */
4069 : :
4070 : : /* Callback function for printing out the contents of the tree. */
4071 : :
4072 : : static void
4073 : 0 : show_global_symbol (gfc_gsymbol *gsym, void *f_data)
4074 : : {
4075 : 0 : FILE *out;
4076 : 0 : out = (FILE *) f_data;
4077 : :
4078 : 0 : if (gsym->name)
4079 : 0 : fprintf (out, "name=%s", gsym->name);
4080 : :
4081 : 0 : if (gsym->sym_name)
4082 : 0 : fprintf (out, ", sym_name=%s", gsym->sym_name);
4083 : :
4084 : 0 : if (gsym->mod_name)
4085 : 0 : fprintf (out, ", mod_name=%s", gsym->mod_name);
4086 : :
4087 : 0 : if (gsym->binding_label)
4088 : 0 : fprintf (out, ", binding_label=%s", gsym->binding_label);
4089 : :
4090 : 0 : fputc ('\n', out);
4091 : 0 : }
4092 : :
4093 : : /* Show all global symbols. */
4094 : :
4095 : : void
4096 : 0 : gfc_dump_global_symbols (FILE *f)
4097 : : {
4098 : 0 : if (gfc_gsym_root == NULL)
4099 : 0 : fprintf (f, "empty\n");
4100 : : else
4101 : 0 : gfc_traverse_gsymbol (gfc_gsym_root, show_global_symbol, (void *) f);
4102 : 0 : }
4103 : :
4104 : : /* Show an array ref. */
4105 : :
4106 : : DEBUG_FUNCTION void
4107 : 0 : debug (gfc_array_ref *ar)
4108 : : {
4109 : 0 : FILE *tmp = dumpfile;
4110 : 0 : dumpfile = stderr;
4111 : 0 : show_array_ref (ar);
4112 : 0 : fputc ('\n', dumpfile);
4113 : 0 : dumpfile = tmp;
4114 : 0 : }
|