re PR libfortran/68744 (FAIL: gfortran.dg/backtrace_1.f90 -O0 execution test)
[official-gcc.git] / gcc / tree-pretty-print.c
blob9c13d848829de06d233d46292f625aba02543de9
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2016 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
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.
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/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "backend.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "predict.h"
28 #include "cgraph.h"
29 #include "tree-pretty-print.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "dumpfile.h"
34 #include "internal-fn.h"
35 #include "gomp-constants.h"
37 /* Local functions, macros and variables. */
38 static const char *op_symbol (const_tree);
39 static void pretty_print_string (pretty_printer *, const char*);
40 static void newline_and_indent (pretty_printer *, int);
41 static void maybe_init_pretty_print (FILE *);
42 static void print_struct_decl (pretty_printer *, const_tree, int, int);
43 static void do_niy (pretty_printer *, const_tree);
45 #define INDENT(SPACE) do { \
46 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
48 #define NIY do_niy (pp, node)
50 static pretty_printer *tree_pp;
52 /* Try to print something for an unknown tree code. */
54 static void
55 do_niy (pretty_printer *pp, const_tree node)
57 int i, len;
59 pp_string (pp, "<<< Unknown tree: ");
60 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
62 if (EXPR_P (node))
64 len = TREE_OPERAND_LENGTH (node);
65 for (i = 0; i < len; ++i)
67 newline_and_indent (pp, 2);
68 dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false);
72 pp_string (pp, " >>>");
75 /* Debugging function to print out a generic expression. */
77 DEBUG_FUNCTION void
78 debug_generic_expr (tree t)
80 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
81 fprintf (stderr, "\n");
84 /* Debugging function to print out a generic statement. */
86 DEBUG_FUNCTION void
87 debug_generic_stmt (tree t)
89 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
90 fprintf (stderr, "\n");
93 /* Debugging function to print out a chain of trees . */
95 DEBUG_FUNCTION void
96 debug_tree_chain (tree t)
98 hash_set<tree> seen;
100 while (t)
102 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
103 fprintf (stderr, " ");
104 t = TREE_CHAIN (t);
105 if (seen.add (t))
107 fprintf (stderr, "... [cycled back to ");
108 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
109 fprintf (stderr, "]");
110 break;
113 fprintf (stderr, "\n");
116 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
117 void
118 print_generic_decl (FILE *file, tree decl, int flags)
120 maybe_init_pretty_print (file);
121 print_declaration (tree_pp, decl, 2, flags);
122 pp_write_text_to_stream (tree_pp);
125 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
126 to show in the dump. See TDF_* in dumpfile.h. */
128 void
129 print_generic_stmt (FILE *file, tree t, int flags)
131 maybe_init_pretty_print (file);
132 dump_generic_node (tree_pp, t, 0, flags, true);
133 pp_newline_and_flush (tree_pp);
136 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
137 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
138 INDENT spaces. */
140 void
141 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
143 int i;
145 maybe_init_pretty_print (file);
147 for (i = 0; i < indent; i++)
148 pp_space (tree_pp);
149 dump_generic_node (tree_pp, t, indent, flags, true);
150 pp_newline_and_flush (tree_pp);
153 /* Print a single expression T on file FILE. FLAGS specifies details to show
154 in the dump. See TDF_* in dumpfile.h. */
156 void
157 print_generic_expr (FILE *file, tree t, int flags)
159 maybe_init_pretty_print (file);
160 dump_generic_node (tree_pp, t, 0, flags, false);
161 pp_flush (tree_pp);
164 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
165 in FLAGS. */
167 static void
168 dump_decl_name (pretty_printer *pp, tree node, int flags)
170 if (DECL_NAME (node))
172 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
173 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
174 else
175 pp_tree_identifier (pp, DECL_NAME (node));
177 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
179 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
180 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
181 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
183 if (flags & TDF_NOUID)
184 pp_string (pp, "D#xxxx");
185 else
186 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
188 else
190 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
191 if (flags & TDF_NOUID)
192 pp_printf (pp, "%c.xxxx", c);
193 else
194 pp_printf (pp, "%c.%u", c, DECL_UID (node));
197 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
199 if (flags & TDF_NOUID)
200 pp_printf (pp, "ptD.xxxx");
201 else
202 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
206 /* Like the above, but used for pretty printing function calls. */
208 static void
209 dump_function_name (pretty_printer *pp, tree node, int flags)
211 if (CONVERT_EXPR_P (node))
212 node = TREE_OPERAND (node, 0);
213 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
214 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
215 else
216 dump_decl_name (pp, node, flags);
219 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
220 FLAGS are as in dump_generic_node. */
222 static void
223 dump_function_declaration (pretty_printer *pp, tree node,
224 int spc, int flags)
226 bool wrote_arg = false;
227 tree arg;
229 pp_space (pp);
230 pp_left_paren (pp);
232 /* Print the argument types. */
233 arg = TYPE_ARG_TYPES (node);
234 while (arg && arg != void_list_node && arg != error_mark_node)
236 if (wrote_arg)
238 pp_comma (pp);
239 pp_space (pp);
241 wrote_arg = true;
242 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
243 arg = TREE_CHAIN (arg);
246 /* Drop the trailing void_type_node if we had any previous argument. */
247 if (arg == void_list_node && !wrote_arg)
248 pp_string (pp, "void");
249 /* Properly dump vararg function types. */
250 else if (!arg && wrote_arg)
251 pp_string (pp, ", ...");
252 /* Avoid printing any arg for unprototyped functions. */
254 pp_right_paren (pp);
257 /* Dump the domain associated with an array. */
259 static void
260 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
262 pp_left_bracket (pp);
263 if (domain)
265 tree min = TYPE_MIN_VALUE (domain);
266 tree max = TYPE_MAX_VALUE (domain);
268 if (min && max
269 && integer_zerop (min)
270 && tree_fits_shwi_p (max))
271 pp_wide_integer (pp, tree_to_shwi (max) + 1);
272 else
274 if (min)
275 dump_generic_node (pp, min, spc, flags, false);
276 pp_colon (pp);
277 if (max)
278 dump_generic_node (pp, max, spc, flags, false);
281 else
282 pp_string (pp, "<unknown>");
283 pp_right_bracket (pp);
287 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
288 dump_generic_node. */
290 static void
291 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
293 const char *name;
295 switch (OMP_CLAUSE_CODE (clause))
297 case OMP_CLAUSE_PRIVATE:
298 name = "private";
299 goto print_remap;
300 case OMP_CLAUSE_SHARED:
301 name = "shared";
302 goto print_remap;
303 case OMP_CLAUSE_FIRSTPRIVATE:
304 name = "firstprivate";
305 goto print_remap;
306 case OMP_CLAUSE_LASTPRIVATE:
307 name = "lastprivate";
308 goto print_remap;
309 case OMP_CLAUSE_COPYIN:
310 name = "copyin";
311 goto print_remap;
312 case OMP_CLAUSE_COPYPRIVATE:
313 name = "copyprivate";
314 goto print_remap;
315 case OMP_CLAUSE_UNIFORM:
316 name = "uniform";
317 goto print_remap;
318 case OMP_CLAUSE_USE_DEVICE_PTR:
319 name = "use_device_ptr";
320 goto print_remap;
321 case OMP_CLAUSE_IS_DEVICE_PTR:
322 name = "is_device_ptr";
323 goto print_remap;
324 case OMP_CLAUSE__LOOPTEMP_:
325 name = "_looptemp_";
326 goto print_remap;
327 case OMP_CLAUSE_DEVICE_RESIDENT:
328 name = "device_resident";
329 goto print_remap;
330 case OMP_CLAUSE_TO_DECLARE:
331 name = "to";
332 goto print_remap;
333 case OMP_CLAUSE_LINK:
334 name = "link";
335 goto print_remap;
336 print_remap:
337 pp_string (pp, name);
338 pp_left_paren (pp);
339 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
340 spc, flags, false);
341 pp_right_paren (pp);
342 break;
344 case OMP_CLAUSE_REDUCTION:
345 pp_string (pp, "reduction(");
346 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
348 pp_string (pp,
349 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
350 pp_colon (pp);
352 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
353 spc, flags, false);
354 pp_right_paren (pp);
355 break;
357 case OMP_CLAUSE_IF:
358 pp_string (pp, "if(");
359 switch (OMP_CLAUSE_IF_MODIFIER (clause))
361 case ERROR_MARK: break;
362 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
363 case OMP_TASK: pp_string (pp, "task:"); break;
364 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
365 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
366 case OMP_TARGET: pp_string (pp, "target:"); break;
367 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
368 case OMP_TARGET_ENTER_DATA:
369 pp_string (pp, "target enter data:"); break;
370 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
371 default: gcc_unreachable ();
373 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
374 spc, flags, false);
375 pp_right_paren (pp);
376 break;
378 case OMP_CLAUSE_NUM_THREADS:
379 pp_string (pp, "num_threads(");
380 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
381 spc, flags, false);
382 pp_right_paren (pp);
383 break;
385 case OMP_CLAUSE__CILK_FOR_COUNT_:
386 pp_string (pp, "_Cilk_for_count_(");
387 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
388 spc, flags, false);
389 pp_right_paren (pp);
390 break;
392 case OMP_CLAUSE_NOWAIT:
393 pp_string (pp, "nowait");
394 break;
395 case OMP_CLAUSE_ORDERED:
396 pp_string (pp, "ordered");
397 if (OMP_CLAUSE_ORDERED_EXPR (clause))
399 pp_left_paren (pp);
400 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
401 spc, flags, false);
402 pp_right_paren (pp);
404 break;
406 case OMP_CLAUSE_DEFAULT:
407 pp_string (pp, "default(");
408 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
410 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
411 break;
412 case OMP_CLAUSE_DEFAULT_SHARED:
413 pp_string (pp, "shared");
414 break;
415 case OMP_CLAUSE_DEFAULT_NONE:
416 pp_string (pp, "none");
417 break;
418 case OMP_CLAUSE_DEFAULT_PRIVATE:
419 pp_string (pp, "private");
420 break;
421 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
422 pp_string (pp, "firstprivate");
423 break;
424 default:
425 gcc_unreachable ();
427 pp_right_paren (pp);
428 break;
430 case OMP_CLAUSE_SCHEDULE:
431 pp_string (pp, "schedule(");
432 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
433 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
434 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
436 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
437 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
438 pp_string (pp, "monotonic");
439 else
440 pp_string (pp, "nonmonotonic");
441 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
442 pp_comma (pp);
443 else
444 pp_colon (pp);
446 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
447 pp_string (pp, "simd:");
449 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
451 case OMP_CLAUSE_SCHEDULE_STATIC:
452 pp_string (pp, "static");
453 break;
454 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
455 pp_string (pp, "dynamic");
456 break;
457 case OMP_CLAUSE_SCHEDULE_GUIDED:
458 pp_string (pp, "guided");
459 break;
460 case OMP_CLAUSE_SCHEDULE_RUNTIME:
461 pp_string (pp, "runtime");
462 break;
463 case OMP_CLAUSE_SCHEDULE_AUTO:
464 pp_string (pp, "auto");
465 break;
466 case OMP_CLAUSE_SCHEDULE_CILKFOR:
467 pp_string (pp, "cilk-for grain");
468 break;
469 default:
470 gcc_unreachable ();
472 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
474 pp_comma (pp);
475 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
476 spc, flags, false);
478 pp_right_paren (pp);
479 break;
481 case OMP_CLAUSE_UNTIED:
482 pp_string (pp, "untied");
483 break;
485 case OMP_CLAUSE_COLLAPSE:
486 pp_string (pp, "collapse(");
487 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
488 spc, flags, false);
489 pp_right_paren (pp);
490 break;
492 case OMP_CLAUSE_FINAL:
493 pp_string (pp, "final(");
494 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
495 spc, flags, false);
496 pp_right_paren (pp);
497 break;
499 case OMP_CLAUSE_MERGEABLE:
500 pp_string (pp, "mergeable");
501 break;
503 case OMP_CLAUSE_LINEAR:
504 pp_string (pp, "linear(");
505 switch (OMP_CLAUSE_LINEAR_KIND (clause))
507 case OMP_CLAUSE_LINEAR_DEFAULT:
508 break;
509 case OMP_CLAUSE_LINEAR_REF:
510 pp_string (pp, "ref(");
511 break;
512 case OMP_CLAUSE_LINEAR_VAL:
513 pp_string (pp, "val(");
514 break;
515 case OMP_CLAUSE_LINEAR_UVAL:
516 pp_string (pp, "uval(");
517 break;
518 default:
519 gcc_unreachable ();
521 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
522 spc, flags, false);
523 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
524 pp_right_paren (pp);
525 pp_colon (pp);
526 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
527 spc, flags, false);
528 pp_right_paren (pp);
529 break;
531 case OMP_CLAUSE_ALIGNED:
532 pp_string (pp, "aligned(");
533 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
534 spc, flags, false);
535 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
537 pp_colon (pp);
538 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
539 spc, flags, false);
541 pp_right_paren (pp);
542 break;
544 case OMP_CLAUSE_DEPEND:
545 pp_string (pp, "depend(");
546 switch (OMP_CLAUSE_DEPEND_KIND (clause))
548 case OMP_CLAUSE_DEPEND_IN:
549 pp_string (pp, "in");
550 break;
551 case OMP_CLAUSE_DEPEND_OUT:
552 pp_string (pp, "out");
553 break;
554 case OMP_CLAUSE_DEPEND_INOUT:
555 pp_string (pp, "inout");
556 break;
557 case OMP_CLAUSE_DEPEND_SOURCE:
558 pp_string (pp, "source)");
559 return;
560 case OMP_CLAUSE_DEPEND_SINK:
561 pp_string (pp, "sink:");
562 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
563 if (TREE_CODE (t) == TREE_LIST)
565 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
566 if (TREE_PURPOSE (t) != integer_zero_node)
568 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
569 pp_minus (pp);
570 else
571 pp_plus (pp);
572 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
573 false);
575 if (TREE_CHAIN (t))
576 pp_comma (pp);
578 else
579 gcc_unreachable ();
580 pp_right_paren (pp);
581 return;
582 default:
583 gcc_unreachable ();
585 pp_colon (pp);
586 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
587 spc, flags, false);
588 pp_right_paren (pp);
589 break;
591 case OMP_CLAUSE_MAP:
592 pp_string (pp, "map(");
593 switch (OMP_CLAUSE_MAP_KIND (clause))
595 case GOMP_MAP_ALLOC:
596 case GOMP_MAP_POINTER:
597 pp_string (pp, "alloc");
598 break;
599 case GOMP_MAP_TO:
600 case GOMP_MAP_TO_PSET:
601 pp_string (pp, "to");
602 break;
603 case GOMP_MAP_FROM:
604 pp_string (pp, "from");
605 break;
606 case GOMP_MAP_TOFROM:
607 pp_string (pp, "tofrom");
608 break;
609 case GOMP_MAP_FORCE_ALLOC:
610 pp_string (pp, "force_alloc");
611 break;
612 case GOMP_MAP_FORCE_TO:
613 pp_string (pp, "force_to");
614 break;
615 case GOMP_MAP_FORCE_FROM:
616 pp_string (pp, "force_from");
617 break;
618 case GOMP_MAP_FORCE_TOFROM:
619 pp_string (pp, "force_tofrom");
620 break;
621 case GOMP_MAP_FORCE_PRESENT:
622 pp_string (pp, "force_present");
623 break;
624 case GOMP_MAP_FORCE_DEALLOC:
625 pp_string (pp, "delete");
626 break;
627 case GOMP_MAP_FORCE_DEVICEPTR:
628 pp_string (pp, "force_deviceptr");
629 break;
630 case GOMP_MAP_ALWAYS_TO:
631 pp_string (pp, "always,to");
632 break;
633 case GOMP_MAP_ALWAYS_FROM:
634 pp_string (pp, "always,from");
635 break;
636 case GOMP_MAP_ALWAYS_TOFROM:
637 pp_string (pp, "always,tofrom");
638 break;
639 case GOMP_MAP_RELEASE:
640 pp_string (pp, "release");
641 break;
642 case GOMP_MAP_FIRSTPRIVATE_POINTER:
643 pp_string (pp, "firstprivate");
644 break;
645 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
646 pp_string (pp, "firstprivate ref");
647 break;
648 case GOMP_MAP_STRUCT:
649 pp_string (pp, "struct");
650 break;
651 case GOMP_MAP_ALWAYS_POINTER:
652 pp_string (pp, "always_pointer");
653 break;
654 case GOMP_MAP_DEVICE_RESIDENT:
655 pp_string (pp, "device_resident");
656 break;
657 case GOMP_MAP_LINK:
658 pp_string (pp, "link");
659 break;
660 default:
661 gcc_unreachable ();
663 pp_colon (pp);
664 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
665 spc, flags, false);
666 print_clause_size:
667 if (OMP_CLAUSE_SIZE (clause))
669 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
670 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
672 case GOMP_MAP_POINTER:
673 case GOMP_MAP_FIRSTPRIVATE_POINTER:
674 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
675 case GOMP_MAP_ALWAYS_POINTER:
676 pp_string (pp, " [pointer assign, bias: ");
677 break;
678 case GOMP_MAP_TO_PSET:
679 pp_string (pp, " [pointer set, len: ");
680 break;
681 default:
682 pp_string (pp, " [len: ");
683 break;
685 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
686 spc, flags, false);
687 pp_right_bracket (pp);
689 pp_right_paren (pp);
690 break;
692 case OMP_CLAUSE_FROM:
693 pp_string (pp, "from(");
694 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
695 spc, flags, false);
696 goto print_clause_size;
698 case OMP_CLAUSE_TO:
699 pp_string (pp, "to(");
700 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
701 spc, flags, false);
702 goto print_clause_size;
704 case OMP_CLAUSE__CACHE_:
705 pp_string (pp, "(");
706 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
707 spc, flags, false);
708 goto print_clause_size;
710 case OMP_CLAUSE_NUM_TEAMS:
711 pp_string (pp, "num_teams(");
712 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
713 spc, flags, false);
714 pp_right_paren (pp);
715 break;
717 case OMP_CLAUSE_THREAD_LIMIT:
718 pp_string (pp, "thread_limit(");
719 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
720 spc, flags, false);
721 pp_right_paren (pp);
722 break;
724 case OMP_CLAUSE_DEVICE:
725 pp_string (pp, "device(");
726 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
727 spc, flags, false);
728 pp_right_paren (pp);
729 break;
731 case OMP_CLAUSE_DIST_SCHEDULE:
732 pp_string (pp, "dist_schedule(static");
733 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
735 pp_comma (pp);
736 dump_generic_node (pp,
737 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
738 spc, flags, false);
740 pp_right_paren (pp);
741 break;
743 case OMP_CLAUSE_PROC_BIND:
744 pp_string (pp, "proc_bind(");
745 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
747 case OMP_CLAUSE_PROC_BIND_MASTER:
748 pp_string (pp, "master");
749 break;
750 case OMP_CLAUSE_PROC_BIND_CLOSE:
751 pp_string (pp, "close");
752 break;
753 case OMP_CLAUSE_PROC_BIND_SPREAD:
754 pp_string (pp, "spread");
755 break;
756 default:
757 gcc_unreachable ();
759 pp_right_paren (pp);
760 break;
762 case OMP_CLAUSE_SAFELEN:
763 pp_string (pp, "safelen(");
764 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
765 spc, flags, false);
766 pp_right_paren (pp);
767 break;
769 case OMP_CLAUSE_SIMDLEN:
770 pp_string (pp, "simdlen(");
771 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
772 spc, flags, false);
773 pp_right_paren (pp);
774 break;
776 case OMP_CLAUSE_PRIORITY:
777 pp_string (pp, "priority(");
778 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
779 spc, flags, false);
780 pp_right_paren (pp);
781 break;
783 case OMP_CLAUSE_GRAINSIZE:
784 pp_string (pp, "grainsize(");
785 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
786 spc, flags, false);
787 pp_right_paren (pp);
788 break;
790 case OMP_CLAUSE_NUM_TASKS:
791 pp_string (pp, "num_tasks(");
792 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
793 spc, flags, false);
794 pp_right_paren (pp);
795 break;
797 case OMP_CLAUSE_HINT:
798 pp_string (pp, "hint(");
799 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
800 spc, flags, false);
801 pp_right_paren (pp);
802 break;
804 case OMP_CLAUSE_DEFAULTMAP:
805 pp_string (pp, "defaultmap(tofrom:scalar)");
806 break;
808 case OMP_CLAUSE__SIMDUID_:
809 pp_string (pp, "_simduid_(");
810 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
811 spc, flags, false);
812 pp_right_paren (pp);
813 break;
815 case OMP_CLAUSE_GANG:
816 pp_string (pp, "gang");
817 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
819 pp_string (pp, "(num: ");
820 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
821 spc, flags, false);
823 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
825 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
826 pp_left_paren (pp);
827 else
828 pp_space (pp);
829 pp_string (pp, "static:");
830 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
831 == integer_minus_one_node)
832 pp_character (pp, '*');
833 else
834 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
835 spc, flags, false);
837 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
838 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
839 pp_right_paren (pp);
840 break;
842 case OMP_CLAUSE_ASYNC:
843 pp_string (pp, "async");
844 if (OMP_CLAUSE_ASYNC_EXPR (clause))
846 pp_character(pp, '(');
847 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
848 spc, flags, false);
849 pp_character(pp, ')');
851 break;
853 case OMP_CLAUSE_AUTO:
854 case OMP_CLAUSE_SEQ:
855 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
856 break;
858 case OMP_CLAUSE_WAIT:
859 pp_string (pp, "wait(");
860 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
861 spc, flags, false);
862 pp_character(pp, ')');
863 break;
865 case OMP_CLAUSE_WORKER:
866 pp_string (pp, "worker");
867 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
869 pp_left_paren (pp);
870 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
871 spc, flags, false);
872 pp_right_paren (pp);
874 break;
876 case OMP_CLAUSE_VECTOR:
877 pp_string (pp, "vector");
878 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
880 pp_left_paren (pp);
881 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
882 spc, flags, false);
883 pp_right_paren (pp);
885 break;
887 case OMP_CLAUSE_NUM_GANGS:
888 pp_string (pp, "num_gangs(");
889 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
890 spc, flags, false);
891 pp_character (pp, ')');
892 break;
894 case OMP_CLAUSE_NUM_WORKERS:
895 pp_string (pp, "num_workers(");
896 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
897 spc, flags, false);
898 pp_character (pp, ')');
899 break;
901 case OMP_CLAUSE_VECTOR_LENGTH:
902 pp_string (pp, "vector_length(");
903 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
904 spc, flags, false);
905 pp_character (pp, ')');
906 break;
908 case OMP_CLAUSE_INBRANCH:
909 pp_string (pp, "inbranch");
910 break;
911 case OMP_CLAUSE_NOTINBRANCH:
912 pp_string (pp, "notinbranch");
913 break;
914 case OMP_CLAUSE_FOR:
915 pp_string (pp, "for");
916 break;
917 case OMP_CLAUSE_PARALLEL:
918 pp_string (pp, "parallel");
919 break;
920 case OMP_CLAUSE_SECTIONS:
921 pp_string (pp, "sections");
922 break;
923 case OMP_CLAUSE_TASKGROUP:
924 pp_string (pp, "taskgroup");
925 break;
926 case OMP_CLAUSE_NOGROUP:
927 pp_string (pp, "nogroup");
928 break;
929 case OMP_CLAUSE_THREADS:
930 pp_string (pp, "threads");
931 break;
932 case OMP_CLAUSE_SIMD:
933 pp_string (pp, "simd");
934 break;
935 case OMP_CLAUSE_INDEPENDENT:
936 pp_string (pp, "independent");
937 break;
938 case OMP_CLAUSE_TILE:
939 pp_string (pp, "tile(");
940 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
941 spc, flags, false);
942 pp_right_paren (pp);
943 break;
945 case OMP_CLAUSE__GRIDDIM_:
946 pp_string (pp, "_griddim_(");
947 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
948 pp_colon (pp);
949 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
950 false);
951 pp_comma (pp);
952 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
953 false);
954 pp_right_paren (pp);
955 break;
957 default:
958 /* Should never happen. */
959 dump_generic_node (pp, clause, spc, flags, false);
960 break;
965 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
966 dump_generic_node. */
968 void
969 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
971 if (clause == NULL)
972 return;
974 pp_space (pp);
975 while (1)
977 dump_omp_clause (pp, clause, spc, flags);
978 clause = OMP_CLAUSE_CHAIN (clause);
979 if (clause == NULL)
980 return;
981 pp_space (pp);
986 /* Dump location LOC to PP. */
988 void
989 dump_location (pretty_printer *pp, location_t loc)
991 expanded_location xloc = expand_location (loc);
993 pp_left_bracket (pp);
994 if (xloc.file)
996 pp_string (pp, xloc.file);
997 pp_string (pp, ":");
999 pp_decimal_int (pp, xloc.line);
1000 pp_colon (pp);
1001 pp_decimal_int (pp, xloc.column);
1002 pp_string (pp, "] ");
1006 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1007 dump_generic_node. */
1009 static void
1010 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
1012 tree t;
1014 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1016 if (flags & TDF_ADDRESS)
1017 pp_printf (pp, "[%p] ", (void *) block);
1019 if (BLOCK_ABSTRACT (block))
1020 pp_string (pp, "[abstract] ");
1022 if (TREE_ASM_WRITTEN (block))
1023 pp_string (pp, "[written] ");
1025 if (flags & TDF_SLIM)
1026 return;
1028 if (BLOCK_SOURCE_LOCATION (block))
1029 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1031 newline_and_indent (pp, spc + 2);
1033 if (BLOCK_SUPERCONTEXT (block))
1035 pp_string (pp, "SUPERCONTEXT: ");
1036 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1037 flags | TDF_SLIM, false);
1038 newline_and_indent (pp, spc + 2);
1041 if (BLOCK_SUBBLOCKS (block))
1043 pp_string (pp, "SUBBLOCKS: ");
1044 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1046 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1047 pp_space (pp);
1049 newline_and_indent (pp, spc + 2);
1052 if (BLOCK_CHAIN (block))
1054 pp_string (pp, "SIBLINGS: ");
1055 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1057 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1058 pp_space (pp);
1060 newline_and_indent (pp, spc + 2);
1063 if (BLOCK_VARS (block))
1065 pp_string (pp, "VARS: ");
1066 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1068 dump_generic_node (pp, t, 0, flags, false);
1069 pp_space (pp);
1071 newline_and_indent (pp, spc + 2);
1074 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1076 unsigned i;
1077 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1079 pp_string (pp, "NONLOCALIZED_VARS: ");
1080 FOR_EACH_VEC_ELT (*nlv, i, t)
1082 dump_generic_node (pp, t, 0, flags, false);
1083 pp_space (pp);
1085 newline_and_indent (pp, spc + 2);
1088 if (BLOCK_ABSTRACT_ORIGIN (block))
1090 pp_string (pp, "ABSTRACT_ORIGIN: ");
1091 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1092 flags | TDF_SLIM, false);
1093 newline_and_indent (pp, spc + 2);
1096 if (BLOCK_FRAGMENT_ORIGIN (block))
1098 pp_string (pp, "FRAGMENT_ORIGIN: ");
1099 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1100 flags | TDF_SLIM, false);
1101 newline_and_indent (pp, spc + 2);
1104 if (BLOCK_FRAGMENT_CHAIN (block))
1106 pp_string (pp, "FRAGMENT_CHAIN: ");
1107 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1109 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1110 pp_space (pp);
1112 newline_and_indent (pp, spc + 2);
1117 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1118 indent. FLAGS specifies details to show in the dump (see TDF_* in
1119 dumpfile.h). If IS_STMT is true, the object printed is considered
1120 to be a statement and it is terminated by ';' if appropriate. */
1123 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
1124 bool is_stmt)
1126 tree type;
1127 tree op0, op1;
1128 const char *str;
1129 bool is_expr;
1130 enum tree_code code;
1132 if (node == NULL_TREE)
1133 return spc;
1135 is_expr = EXPR_P (node);
1137 if (is_stmt && (flags & TDF_STMTADDR))
1138 pp_printf (pp, "<&%p> ", (void *)node);
1140 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1141 dump_location (pp, EXPR_LOCATION (node));
1143 code = TREE_CODE (node);
1144 switch (code)
1146 case ERROR_MARK:
1147 pp_string (pp, "<<< error >>>");
1148 break;
1150 case IDENTIFIER_NODE:
1151 pp_tree_identifier (pp, node);
1152 break;
1154 case TREE_LIST:
1155 while (node && node != error_mark_node)
1157 if (TREE_PURPOSE (node))
1159 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1160 pp_space (pp);
1162 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1163 node = TREE_CHAIN (node);
1164 if (node && TREE_CODE (node) == TREE_LIST)
1166 pp_comma (pp);
1167 pp_space (pp);
1170 break;
1172 case TREE_BINFO:
1173 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1174 break;
1176 case TREE_VEC:
1178 size_t i;
1179 if (TREE_VEC_LENGTH (node) > 0)
1181 size_t len = TREE_VEC_LENGTH (node);
1182 for (i = 0; i < len - 1; i++)
1184 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1185 false);
1186 pp_comma (pp);
1187 pp_space (pp);
1189 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1190 flags, false);
1193 break;
1195 case VOID_TYPE:
1196 case POINTER_BOUNDS_TYPE:
1197 case INTEGER_TYPE:
1198 case REAL_TYPE:
1199 case FIXED_POINT_TYPE:
1200 case COMPLEX_TYPE:
1201 case VECTOR_TYPE:
1202 case ENUMERAL_TYPE:
1203 case BOOLEAN_TYPE:
1205 unsigned int quals = TYPE_QUALS (node);
1206 enum tree_code_class tclass;
1208 if (quals & TYPE_QUAL_ATOMIC)
1209 pp_string (pp, "atomic ");
1210 if (quals & TYPE_QUAL_CONST)
1211 pp_string (pp, "const ");
1212 else if (quals & TYPE_QUAL_VOLATILE)
1213 pp_string (pp, "volatile ");
1214 else if (quals & TYPE_QUAL_RESTRICT)
1215 pp_string (pp, "restrict ");
1217 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1219 pp_string (pp, "<address-space-");
1220 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1221 pp_string (pp, "> ");
1224 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1226 if (tclass == tcc_declaration)
1228 if (DECL_NAME (node))
1229 dump_decl_name (pp, node, flags);
1230 else
1231 pp_string (pp, "<unnamed type decl>");
1233 else if (tclass == tcc_type)
1235 if (TYPE_NAME (node))
1237 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1238 pp_tree_identifier (pp, TYPE_NAME (node));
1239 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1240 && DECL_NAME (TYPE_NAME (node)))
1241 dump_decl_name (pp, TYPE_NAME (node), flags);
1242 else
1243 pp_string (pp, "<unnamed type>");
1245 else if (TREE_CODE (node) == VECTOR_TYPE)
1247 pp_string (pp, "vector");
1248 pp_left_paren (pp);
1249 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1250 pp_string (pp, ") ");
1251 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1253 else if (TREE_CODE (node) == INTEGER_TYPE)
1255 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1256 pp_string (pp, (TYPE_UNSIGNED (node)
1257 ? "unsigned char"
1258 : "signed char"));
1259 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1260 pp_string (pp, (TYPE_UNSIGNED (node)
1261 ? "unsigned short"
1262 : "signed short"));
1263 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1264 pp_string (pp, (TYPE_UNSIGNED (node)
1265 ? "unsigned int"
1266 : "signed int"));
1267 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1268 pp_string (pp, (TYPE_UNSIGNED (node)
1269 ? "unsigned long"
1270 : "signed long"));
1271 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1272 pp_string (pp, (TYPE_UNSIGNED (node)
1273 ? "unsigned long long"
1274 : "signed long long"));
1275 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1276 && exact_log2 (TYPE_PRECISION (node)) != -1)
1278 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1279 pp_decimal_int (pp, TYPE_PRECISION (node));
1280 pp_string (pp, "_t");
1282 else
1284 pp_string (pp, (TYPE_UNSIGNED (node)
1285 ? "<unnamed-unsigned:"
1286 : "<unnamed-signed:"));
1287 pp_decimal_int (pp, TYPE_PRECISION (node));
1288 pp_greater (pp);
1291 else if (TREE_CODE (node) == COMPLEX_TYPE)
1293 pp_string (pp, "__complex__ ");
1294 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1296 else if (TREE_CODE (node) == REAL_TYPE)
1298 pp_string (pp, "<float:");
1299 pp_decimal_int (pp, TYPE_PRECISION (node));
1300 pp_greater (pp);
1302 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1304 pp_string (pp, "<fixed-point-");
1305 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1306 pp_decimal_int (pp, TYPE_PRECISION (node));
1307 pp_greater (pp);
1309 else if (TREE_CODE (node) == VOID_TYPE)
1310 pp_string (pp, "void");
1311 else
1312 pp_string (pp, "<unnamed type>");
1314 break;
1317 case POINTER_TYPE:
1318 case REFERENCE_TYPE:
1319 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1321 if (TREE_TYPE (node) == NULL)
1323 pp_string (pp, str);
1324 pp_string (pp, "<null type>");
1326 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1328 tree fnode = TREE_TYPE (node);
1330 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1331 pp_space (pp);
1332 pp_left_paren (pp);
1333 pp_string (pp, str);
1334 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1335 dump_decl_name (pp, TYPE_NAME (node), flags);
1336 else if (flags & TDF_NOUID)
1337 pp_printf (pp, "<Txxxx>");
1338 else
1339 pp_printf (pp, "<T%x>", TYPE_UID (node));
1341 pp_right_paren (pp);
1342 dump_function_declaration (pp, fnode, spc, flags);
1344 else
1346 unsigned int quals = TYPE_QUALS (node);
1348 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1349 pp_space (pp);
1350 pp_string (pp, str);
1352 if (quals & TYPE_QUAL_CONST)
1353 pp_string (pp, " const");
1354 if (quals & TYPE_QUAL_VOLATILE)
1355 pp_string (pp, " volatile");
1356 if (quals & TYPE_QUAL_RESTRICT)
1357 pp_string (pp, " restrict");
1359 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1361 pp_string (pp, " <address-space-");
1362 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1363 pp_greater (pp);
1366 if (TYPE_REF_CAN_ALIAS_ALL (node))
1367 pp_string (pp, " {ref-all}");
1369 break;
1371 case OFFSET_TYPE:
1372 NIY;
1373 break;
1375 case MEM_REF:
1377 if (integer_zerop (TREE_OPERAND (node, 1))
1378 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1379 infer them and MEM_ATTR caching will share MEM_REFs
1380 with differently-typed op0s. */
1381 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1382 /* Released SSA_NAMES have no TREE_TYPE. */
1383 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1384 /* Same pointer types, but ignoring POINTER_TYPE vs.
1385 REFERENCE_TYPE. */
1386 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1387 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1388 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1389 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1390 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1391 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1392 /* Same value types ignoring qualifiers. */
1393 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1394 == TYPE_MAIN_VARIANT
1395 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1396 && (!(flags & TDF_ALIAS)
1397 || MR_DEPENDENCE_CLIQUE (node) == 0))
1399 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1401 pp_star (pp);
1402 dump_generic_node (pp, TREE_OPERAND (node, 0),
1403 spc, flags, false);
1405 else
1406 dump_generic_node (pp,
1407 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1408 spc, flags, false);
1410 else
1412 tree ptype;
1414 pp_string (pp, "MEM[");
1415 pp_left_paren (pp);
1416 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1417 dump_generic_node (pp, ptype,
1418 spc, flags | TDF_SLIM, false);
1419 pp_right_paren (pp);
1420 dump_generic_node (pp, TREE_OPERAND (node, 0),
1421 spc, flags, false);
1422 if (!integer_zerop (TREE_OPERAND (node, 1)))
1424 pp_string (pp, " + ");
1425 dump_generic_node (pp, TREE_OPERAND (node, 1),
1426 spc, flags, false);
1428 if ((flags & TDF_ALIAS)
1429 && MR_DEPENDENCE_CLIQUE (node) != 0)
1431 pp_string (pp, " clique ");
1432 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1433 pp_string (pp, " base ");
1434 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1436 pp_right_bracket (pp);
1438 break;
1441 case TARGET_MEM_REF:
1443 const char *sep = "";
1444 tree tmp;
1446 pp_string (pp, "MEM[");
1448 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1450 pp_string (pp, sep);
1451 sep = ", ";
1452 pp_string (pp, "symbol: ");
1453 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1454 spc, flags, false);
1456 else
1458 pp_string (pp, sep);
1459 sep = ", ";
1460 pp_string (pp, "base: ");
1461 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1463 tmp = TMR_INDEX2 (node);
1464 if (tmp)
1466 pp_string (pp, sep);
1467 sep = ", ";
1468 pp_string (pp, "base: ");
1469 dump_generic_node (pp, tmp, spc, flags, false);
1471 tmp = TMR_INDEX (node);
1472 if (tmp)
1474 pp_string (pp, sep);
1475 sep = ", ";
1476 pp_string (pp, "index: ");
1477 dump_generic_node (pp, tmp, spc, flags, false);
1479 tmp = TMR_STEP (node);
1480 if (tmp)
1482 pp_string (pp, sep);
1483 sep = ", ";
1484 pp_string (pp, "step: ");
1485 dump_generic_node (pp, tmp, spc, flags, false);
1487 tmp = TMR_OFFSET (node);
1488 if (tmp)
1490 pp_string (pp, sep);
1491 sep = ", ";
1492 pp_string (pp, "offset: ");
1493 dump_generic_node (pp, tmp, spc, flags, false);
1495 pp_right_bracket (pp);
1497 break;
1499 case ARRAY_TYPE:
1501 tree tmp;
1503 /* Print the innermost component type. */
1504 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1505 tmp = TREE_TYPE (tmp))
1507 dump_generic_node (pp, tmp, spc, flags, false);
1509 /* Print the dimensions. */
1510 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1511 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1512 break;
1515 case RECORD_TYPE:
1516 case UNION_TYPE:
1517 case QUAL_UNION_TYPE:
1519 unsigned int quals = TYPE_QUALS (node);
1521 if (quals & TYPE_QUAL_ATOMIC)
1522 pp_string (pp, "atomic ");
1523 if (quals & TYPE_QUAL_CONST)
1524 pp_string (pp, "const ");
1525 if (quals & TYPE_QUAL_VOLATILE)
1526 pp_string (pp, "volatile ");
1528 /* Print the name of the structure. */
1529 if (TREE_CODE (node) == RECORD_TYPE)
1530 pp_string (pp, "struct ");
1531 else if (TREE_CODE (node) == UNION_TYPE)
1532 pp_string (pp, "union ");
1534 if (TYPE_NAME (node))
1535 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1536 else if (!(flags & TDF_SLIM))
1537 /* FIXME: If we eliminate the 'else' above and attempt
1538 to show the fields for named types, we may get stuck
1539 following a cycle of pointers to structs. The alleged
1540 self-reference check in print_struct_decl will not detect
1541 cycles involving more than one pointer or struct type. */
1542 print_struct_decl (pp, node, spc, flags);
1543 break;
1546 case LANG_TYPE:
1547 NIY;
1548 break;
1550 case INTEGER_CST:
1551 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1553 /* In the case of a pointer, one may want to divide by the
1554 size of the pointed-to type. Unfortunately, this not
1555 straightforward. The C front-end maps expressions
1557 (int *) 5
1558 int *p; (p + 5)
1560 in such a way that the two INTEGER_CST nodes for "5" have
1561 different values but identical types. In the latter
1562 case, the 5 is multiplied by sizeof (int) in c-common.c
1563 (pointer_int_sum) to convert it to a byte address, and
1564 yet the type of the node is left unchanged. Argh. What
1565 is consistent though is that the number value corresponds
1566 to bytes (UNITS) offset.
1568 NB: Neither of the following divisors can be trivially
1569 used to recover the original literal:
1571 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1572 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1573 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1574 pp_string (pp, "B"); /* pseudo-unit */
1576 else if (tree_fits_shwi_p (node))
1577 pp_wide_integer (pp, tree_to_shwi (node));
1578 else if (tree_fits_uhwi_p (node))
1579 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1580 else
1582 wide_int val = node;
1584 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1586 pp_minus (pp);
1587 val = -val;
1589 print_hex (val, pp_buffer (pp)->digit_buffer);
1590 pp_string (pp, pp_buffer (pp)->digit_buffer);
1592 if (TREE_OVERFLOW (node))
1593 pp_string (pp, "(OVF)");
1594 break;
1596 case REAL_CST:
1597 /* Code copied from print_node. */
1599 REAL_VALUE_TYPE d;
1600 if (TREE_OVERFLOW (node))
1601 pp_string (pp, " overflow");
1603 d = TREE_REAL_CST (node);
1604 if (REAL_VALUE_ISINF (d))
1605 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1606 else if (REAL_VALUE_ISNAN (d))
1607 pp_string (pp, " Nan");
1608 else
1610 char string[100];
1611 real_to_decimal (string, &d, sizeof (string), 0, 1);
1612 pp_string (pp, string);
1614 break;
1617 case FIXED_CST:
1619 char string[100];
1620 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1621 pp_string (pp, string);
1622 break;
1625 case COMPLEX_CST:
1626 pp_string (pp, "__complex__ (");
1627 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1628 pp_string (pp, ", ");
1629 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1630 pp_right_paren (pp);
1631 break;
1633 case STRING_CST:
1634 pp_string (pp, "\"");
1635 pretty_print_string (pp, TREE_STRING_POINTER (node));
1636 pp_string (pp, "\"");
1637 break;
1639 case VECTOR_CST:
1641 unsigned i;
1642 pp_string (pp, "{ ");
1643 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1645 if (i != 0)
1646 pp_string (pp, ", ");
1647 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1648 spc, flags, false);
1650 pp_string (pp, " }");
1652 break;
1654 case FUNCTION_TYPE:
1655 case METHOD_TYPE:
1656 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1657 pp_space (pp);
1658 if (TREE_CODE (node) == METHOD_TYPE)
1660 if (TYPE_METHOD_BASETYPE (node))
1661 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1662 flags);
1663 else
1664 pp_string (pp, "<null method basetype>");
1665 pp_colon_colon (pp);
1667 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1668 dump_decl_name (pp, TYPE_NAME (node), flags);
1669 else if (flags & TDF_NOUID)
1670 pp_printf (pp, "<Txxxx>");
1671 else
1672 pp_printf (pp, "<T%x>", TYPE_UID (node));
1673 dump_function_declaration (pp, node, spc, flags);
1674 break;
1676 case FUNCTION_DECL:
1677 case CONST_DECL:
1678 dump_decl_name (pp, node, flags);
1679 break;
1681 case LABEL_DECL:
1682 if (DECL_NAME (node))
1683 dump_decl_name (pp, node, flags);
1684 else if (LABEL_DECL_UID (node) != -1)
1685 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1686 else
1688 if (flags & TDF_NOUID)
1689 pp_string (pp, "<D.xxxx>");
1690 else
1691 pp_printf (pp, "<D.%u>", DECL_UID (node));
1693 break;
1695 case TYPE_DECL:
1696 if (DECL_IS_BUILTIN (node))
1698 /* Don't print the declaration of built-in types. */
1699 break;
1701 if (DECL_NAME (node))
1702 dump_decl_name (pp, node, flags);
1703 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1705 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1706 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1707 && TYPE_METHODS (TREE_TYPE (node)))
1709 /* The type is a c++ class: all structures have at least
1710 4 methods. */
1711 pp_string (pp, "class ");
1712 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1714 else
1716 pp_string (pp,
1717 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1718 ? "union" : "struct "));
1719 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1722 else
1723 pp_string (pp, "<anon>");
1724 break;
1726 case VAR_DECL:
1727 case PARM_DECL:
1728 case FIELD_DECL:
1729 case DEBUG_EXPR_DECL:
1730 case NAMESPACE_DECL:
1731 case NAMELIST_DECL:
1732 dump_decl_name (pp, node, flags);
1733 break;
1735 case RESULT_DECL:
1736 pp_string (pp, "<retval>");
1737 break;
1739 case COMPONENT_REF:
1740 op0 = TREE_OPERAND (node, 0);
1741 str = ".";
1742 if (op0
1743 && (TREE_CODE (op0) == INDIRECT_REF
1744 || (TREE_CODE (op0) == MEM_REF
1745 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1746 && integer_zerop (TREE_OPERAND (op0, 1))
1747 /* Dump the types of INTEGER_CSTs explicitly, for we
1748 can't infer them and MEM_ATTR caching will share
1749 MEM_REFs with differently-typed op0s. */
1750 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1751 /* Released SSA_NAMES have no TREE_TYPE. */
1752 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1753 /* Same pointer types, but ignoring POINTER_TYPE vs.
1754 REFERENCE_TYPE. */
1755 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1756 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1757 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1758 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1759 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1760 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1761 /* Same value types ignoring qualifiers. */
1762 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1763 == TYPE_MAIN_VARIANT
1764 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1765 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1767 op0 = TREE_OPERAND (op0, 0);
1768 str = "->";
1770 if (op_prio (op0) < op_prio (node))
1771 pp_left_paren (pp);
1772 dump_generic_node (pp, op0, spc, flags, false);
1773 if (op_prio (op0) < op_prio (node))
1774 pp_right_paren (pp);
1775 pp_string (pp, str);
1776 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1777 op0 = component_ref_field_offset (node);
1778 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1780 pp_string (pp, "{off: ");
1781 dump_generic_node (pp, op0, spc, flags, false);
1782 pp_right_brace (pp);
1784 break;
1786 case BIT_FIELD_REF:
1787 pp_string (pp, "BIT_FIELD_REF <");
1788 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1789 pp_string (pp, ", ");
1790 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1791 pp_string (pp, ", ");
1792 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1793 pp_greater (pp);
1794 break;
1796 case ARRAY_REF:
1797 case ARRAY_RANGE_REF:
1798 op0 = TREE_OPERAND (node, 0);
1799 if (op_prio (op0) < op_prio (node))
1800 pp_left_paren (pp);
1801 dump_generic_node (pp, op0, spc, flags, false);
1802 if (op_prio (op0) < op_prio (node))
1803 pp_right_paren (pp);
1804 pp_left_bracket (pp);
1805 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1806 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1807 pp_string (pp, " ...");
1808 pp_right_bracket (pp);
1810 op0 = array_ref_low_bound (node);
1811 op1 = array_ref_element_size (node);
1813 if (!integer_zerop (op0)
1814 || TREE_OPERAND (node, 2)
1815 || TREE_OPERAND (node, 3))
1817 pp_string (pp, "{lb: ");
1818 dump_generic_node (pp, op0, spc, flags, false);
1819 pp_string (pp, " sz: ");
1820 dump_generic_node (pp, op1, spc, flags, false);
1821 pp_right_brace (pp);
1823 break;
1825 case CONSTRUCTOR:
1827 unsigned HOST_WIDE_INT ix;
1828 tree field, val;
1829 bool is_struct_init = false;
1830 bool is_array_init = false;
1831 widest_int curidx;
1832 pp_left_brace (pp);
1833 if (TREE_CLOBBER_P (node))
1834 pp_string (pp, "CLOBBER");
1835 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1836 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1837 is_struct_init = true;
1838 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1839 && TYPE_DOMAIN (TREE_TYPE (node))
1840 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1841 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1842 == INTEGER_CST)
1844 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1845 is_array_init = true;
1846 curidx = wi::to_widest (minv);
1848 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1850 if (field)
1852 if (is_struct_init)
1854 pp_dot (pp);
1855 dump_generic_node (pp, field, spc, flags, false);
1856 pp_equal (pp);
1858 else if (is_array_init
1859 && (TREE_CODE (field) != INTEGER_CST
1860 || curidx != wi::to_widest (field)))
1862 pp_left_bracket (pp);
1863 if (TREE_CODE (field) == RANGE_EXPR)
1865 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1866 flags, false);
1867 pp_string (pp, " ... ");
1868 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1869 flags, false);
1870 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1871 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1873 else
1874 dump_generic_node (pp, field, spc, flags, false);
1875 if (TREE_CODE (field) == INTEGER_CST)
1876 curidx = wi::to_widest (field);
1877 pp_string (pp, "]=");
1880 if (is_array_init)
1881 curidx += 1;
1882 if (val && TREE_CODE (val) == ADDR_EXPR)
1883 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1884 val = TREE_OPERAND (val, 0);
1885 if (val && TREE_CODE (val) == FUNCTION_DECL)
1886 dump_decl_name (pp, val, flags);
1887 else
1888 dump_generic_node (pp, val, spc, flags, false);
1889 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1891 pp_comma (pp);
1892 pp_space (pp);
1895 pp_right_brace (pp);
1897 break;
1899 case COMPOUND_EXPR:
1901 tree *tp;
1902 if (flags & TDF_SLIM)
1904 pp_string (pp, "<COMPOUND_EXPR>");
1905 break;
1908 dump_generic_node (pp, TREE_OPERAND (node, 0),
1909 spc, flags, !(flags & TDF_SLIM));
1910 if (flags & TDF_SLIM)
1911 newline_and_indent (pp, spc);
1912 else
1914 pp_comma (pp);
1915 pp_space (pp);
1918 for (tp = &TREE_OPERAND (node, 1);
1919 TREE_CODE (*tp) == COMPOUND_EXPR;
1920 tp = &TREE_OPERAND (*tp, 1))
1922 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1923 spc, flags, !(flags & TDF_SLIM));
1924 if (flags & TDF_SLIM)
1925 newline_and_indent (pp, spc);
1926 else
1928 pp_comma (pp);
1929 pp_space (pp);
1933 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1935 break;
1937 case STATEMENT_LIST:
1939 tree_stmt_iterator si;
1940 bool first = true;
1942 if (flags & TDF_SLIM)
1944 pp_string (pp, "<STATEMENT_LIST>");
1945 break;
1948 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1950 if (!first)
1951 newline_and_indent (pp, spc);
1952 else
1953 first = false;
1954 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1957 break;
1959 case MODIFY_EXPR:
1960 case INIT_EXPR:
1961 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1962 false);
1963 pp_space (pp);
1964 pp_equal (pp);
1965 pp_space (pp);
1966 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1967 false);
1968 break;
1970 case TARGET_EXPR:
1971 pp_string (pp, "TARGET_EXPR <");
1972 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1973 pp_comma (pp);
1974 pp_space (pp);
1975 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1976 pp_greater (pp);
1977 break;
1979 case DECL_EXPR:
1980 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1981 is_stmt = false;
1982 break;
1984 case COND_EXPR:
1985 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1987 pp_string (pp, "if (");
1988 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1989 pp_right_paren (pp);
1990 /* The lowered cond_exprs should always be printed in full. */
1991 if (COND_EXPR_THEN (node)
1992 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1993 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1994 && COND_EXPR_ELSE (node)
1995 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1996 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1998 pp_space (pp);
1999 dump_generic_node (pp, COND_EXPR_THEN (node),
2000 0, flags, true);
2001 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2003 pp_string (pp, " else ");
2004 dump_generic_node (pp, COND_EXPR_ELSE (node),
2005 0, flags, true);
2008 else if (!(flags & TDF_SLIM))
2010 /* Output COND_EXPR_THEN. */
2011 if (COND_EXPR_THEN (node))
2013 newline_and_indent (pp, spc+2);
2014 pp_left_brace (pp);
2015 newline_and_indent (pp, spc+4);
2016 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2017 flags, true);
2018 newline_and_indent (pp, spc+2);
2019 pp_right_brace (pp);
2022 /* Output COND_EXPR_ELSE. */
2023 if (COND_EXPR_ELSE (node)
2024 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2026 newline_and_indent (pp, spc);
2027 pp_string (pp, "else");
2028 newline_and_indent (pp, spc+2);
2029 pp_left_brace (pp);
2030 newline_and_indent (pp, spc+4);
2031 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2032 flags, true);
2033 newline_and_indent (pp, spc+2);
2034 pp_right_brace (pp);
2037 is_expr = false;
2039 else
2041 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2042 pp_space (pp);
2043 pp_question (pp);
2044 pp_space (pp);
2045 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2046 pp_space (pp);
2047 pp_colon (pp);
2048 pp_space (pp);
2049 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2051 break;
2053 case BIND_EXPR:
2054 pp_left_brace (pp);
2055 if (!(flags & TDF_SLIM))
2057 if (BIND_EXPR_VARS (node))
2059 pp_newline (pp);
2061 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2063 print_declaration (pp, op0, spc+2, flags);
2064 pp_newline (pp);
2068 newline_and_indent (pp, spc+2);
2069 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2070 newline_and_indent (pp, spc);
2071 pp_right_brace (pp);
2073 is_expr = false;
2074 break;
2076 case CALL_EXPR:
2077 if (CALL_EXPR_FN (node) != NULL_TREE)
2078 print_call_name (pp, CALL_EXPR_FN (node), flags);
2079 else
2080 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2082 /* Print parameters. */
2083 pp_space (pp);
2084 pp_left_paren (pp);
2086 tree arg;
2087 call_expr_arg_iterator iter;
2088 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2090 dump_generic_node (pp, arg, spc, flags, false);
2091 if (more_call_expr_args_p (&iter))
2093 pp_comma (pp);
2094 pp_space (pp);
2098 if (CALL_EXPR_VA_ARG_PACK (node))
2100 if (call_expr_nargs (node) > 0)
2102 pp_comma (pp);
2103 pp_space (pp);
2105 pp_string (pp, "__builtin_va_arg_pack ()");
2107 pp_right_paren (pp);
2109 op1 = CALL_EXPR_STATIC_CHAIN (node);
2110 if (op1)
2112 pp_string (pp, " [static-chain: ");
2113 dump_generic_node (pp, op1, spc, flags, false);
2114 pp_right_bracket (pp);
2117 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2118 pp_string (pp, " [return slot optimization]");
2119 if (CALL_EXPR_TAILCALL (node))
2120 pp_string (pp, " [tail call]");
2121 break;
2123 case WITH_CLEANUP_EXPR:
2124 NIY;
2125 break;
2127 case CLEANUP_POINT_EXPR:
2128 pp_string (pp, "<<cleanup_point ");
2129 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2130 pp_string (pp, ">>");
2131 break;
2133 case PLACEHOLDER_EXPR:
2134 pp_string (pp, "<PLACEHOLDER_EXPR ");
2135 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2136 pp_greater (pp);
2137 break;
2139 /* Binary arithmetic and logic expressions. */
2140 case WIDEN_SUM_EXPR:
2141 case WIDEN_MULT_EXPR:
2142 case MULT_EXPR:
2143 case MULT_HIGHPART_EXPR:
2144 case PLUS_EXPR:
2145 case POINTER_PLUS_EXPR:
2146 case MINUS_EXPR:
2147 case TRUNC_DIV_EXPR:
2148 case CEIL_DIV_EXPR:
2149 case FLOOR_DIV_EXPR:
2150 case ROUND_DIV_EXPR:
2151 case TRUNC_MOD_EXPR:
2152 case CEIL_MOD_EXPR:
2153 case FLOOR_MOD_EXPR:
2154 case ROUND_MOD_EXPR:
2155 case RDIV_EXPR:
2156 case EXACT_DIV_EXPR:
2157 case LSHIFT_EXPR:
2158 case RSHIFT_EXPR:
2159 case LROTATE_EXPR:
2160 case RROTATE_EXPR:
2161 case WIDEN_LSHIFT_EXPR:
2162 case BIT_IOR_EXPR:
2163 case BIT_XOR_EXPR:
2164 case BIT_AND_EXPR:
2165 case TRUTH_ANDIF_EXPR:
2166 case TRUTH_ORIF_EXPR:
2167 case TRUTH_AND_EXPR:
2168 case TRUTH_OR_EXPR:
2169 case TRUTH_XOR_EXPR:
2170 case LT_EXPR:
2171 case LE_EXPR:
2172 case GT_EXPR:
2173 case GE_EXPR:
2174 case EQ_EXPR:
2175 case NE_EXPR:
2176 case UNLT_EXPR:
2177 case UNLE_EXPR:
2178 case UNGT_EXPR:
2179 case UNGE_EXPR:
2180 case UNEQ_EXPR:
2181 case LTGT_EXPR:
2182 case ORDERED_EXPR:
2183 case UNORDERED_EXPR:
2185 const char *op = op_symbol (node);
2186 op0 = TREE_OPERAND (node, 0);
2187 op1 = TREE_OPERAND (node, 1);
2189 /* When the operands are expressions with less priority,
2190 keep semantics of the tree representation. */
2191 if (op_prio (op0) <= op_prio (node))
2193 pp_left_paren (pp);
2194 dump_generic_node (pp, op0, spc, flags, false);
2195 pp_right_paren (pp);
2197 else
2198 dump_generic_node (pp, op0, spc, flags, false);
2200 pp_space (pp);
2201 pp_string (pp, op);
2202 pp_space (pp);
2204 /* When the operands are expressions with less priority,
2205 keep semantics of the tree representation. */
2206 if (op_prio (op1) <= op_prio (node))
2208 pp_left_paren (pp);
2209 dump_generic_node (pp, op1, spc, flags, false);
2210 pp_right_paren (pp);
2212 else
2213 dump_generic_node (pp, op1, spc, flags, false);
2215 break;
2217 /* Unary arithmetic and logic expressions. */
2218 case NEGATE_EXPR:
2219 case BIT_NOT_EXPR:
2220 case TRUTH_NOT_EXPR:
2221 case ADDR_EXPR:
2222 case PREDECREMENT_EXPR:
2223 case PREINCREMENT_EXPR:
2224 case INDIRECT_REF:
2225 if (TREE_CODE (node) == ADDR_EXPR
2226 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2227 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2228 ; /* Do not output '&' for strings and function pointers. */
2229 else
2230 pp_string (pp, op_symbol (node));
2232 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2234 pp_left_paren (pp);
2235 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2236 pp_right_paren (pp);
2238 else
2239 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2240 break;
2242 case POSTDECREMENT_EXPR:
2243 case POSTINCREMENT_EXPR:
2244 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2246 pp_left_paren (pp);
2247 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2248 pp_right_paren (pp);
2250 else
2251 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2252 pp_string (pp, op_symbol (node));
2253 break;
2255 case MIN_EXPR:
2256 pp_string (pp, "MIN_EXPR <");
2257 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2258 pp_string (pp, ", ");
2259 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2260 pp_greater (pp);
2261 break;
2263 case MAX_EXPR:
2264 pp_string (pp, "MAX_EXPR <");
2265 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2266 pp_string (pp, ", ");
2267 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2268 pp_greater (pp);
2269 break;
2271 case ABS_EXPR:
2272 pp_string (pp, "ABS_EXPR <");
2273 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2274 pp_greater (pp);
2275 break;
2277 case RANGE_EXPR:
2278 NIY;
2279 break;
2281 case ADDR_SPACE_CONVERT_EXPR:
2282 case FIXED_CONVERT_EXPR:
2283 case FIX_TRUNC_EXPR:
2284 case FLOAT_EXPR:
2285 CASE_CONVERT:
2286 type = TREE_TYPE (node);
2287 op0 = TREE_OPERAND (node, 0);
2288 if (type != TREE_TYPE (op0))
2290 pp_left_paren (pp);
2291 dump_generic_node (pp, type, spc, flags, false);
2292 pp_string (pp, ") ");
2294 if (op_prio (op0) < op_prio (node))
2295 pp_left_paren (pp);
2296 dump_generic_node (pp, op0, spc, flags, false);
2297 if (op_prio (op0) < op_prio (node))
2298 pp_right_paren (pp);
2299 break;
2301 case VIEW_CONVERT_EXPR:
2302 pp_string (pp, "VIEW_CONVERT_EXPR<");
2303 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2304 pp_string (pp, ">(");
2305 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2306 pp_right_paren (pp);
2307 break;
2309 case PAREN_EXPR:
2310 pp_string (pp, "((");
2311 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2312 pp_string (pp, "))");
2313 break;
2315 case NON_LVALUE_EXPR:
2316 pp_string (pp, "NON_LVALUE_EXPR <");
2317 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2318 pp_greater (pp);
2319 break;
2321 case SAVE_EXPR:
2322 pp_string (pp, "SAVE_EXPR <");
2323 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2324 pp_greater (pp);
2325 break;
2327 case COMPLEX_EXPR:
2328 pp_string (pp, "COMPLEX_EXPR <");
2329 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2330 pp_string (pp, ", ");
2331 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2332 pp_greater (pp);
2333 break;
2335 case CONJ_EXPR:
2336 pp_string (pp, "CONJ_EXPR <");
2337 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2338 pp_greater (pp);
2339 break;
2341 case REALPART_EXPR:
2342 pp_string (pp, "REALPART_EXPR <");
2343 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2344 pp_greater (pp);
2345 break;
2347 case IMAGPART_EXPR:
2348 pp_string (pp, "IMAGPART_EXPR <");
2349 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2350 pp_greater (pp);
2351 break;
2353 case VA_ARG_EXPR:
2354 pp_string (pp, "VA_ARG_EXPR <");
2355 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2356 pp_greater (pp);
2357 break;
2359 case TRY_FINALLY_EXPR:
2360 case TRY_CATCH_EXPR:
2361 pp_string (pp, "try");
2362 newline_and_indent (pp, spc+2);
2363 pp_left_brace (pp);
2364 newline_and_indent (pp, spc+4);
2365 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2366 newline_and_indent (pp, spc+2);
2367 pp_right_brace (pp);
2368 newline_and_indent (pp, spc);
2369 pp_string (pp,
2370 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2371 newline_and_indent (pp, spc+2);
2372 pp_left_brace (pp);
2373 newline_and_indent (pp, spc+4);
2374 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2375 newline_and_indent (pp, spc+2);
2376 pp_right_brace (pp);
2377 is_expr = false;
2378 break;
2380 case CATCH_EXPR:
2381 pp_string (pp, "catch (");
2382 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2383 pp_right_paren (pp);
2384 newline_and_indent (pp, spc+2);
2385 pp_left_brace (pp);
2386 newline_and_indent (pp, spc+4);
2387 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2388 newline_and_indent (pp, spc+2);
2389 pp_right_brace (pp);
2390 is_expr = false;
2391 break;
2393 case EH_FILTER_EXPR:
2394 pp_string (pp, "<<<eh_filter (");
2395 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2396 pp_string (pp, ")>>>");
2397 newline_and_indent (pp, spc+2);
2398 pp_left_brace (pp);
2399 newline_and_indent (pp, spc+4);
2400 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2401 newline_and_indent (pp, spc+2);
2402 pp_right_brace (pp);
2403 is_expr = false;
2404 break;
2406 case LABEL_EXPR:
2407 op0 = TREE_OPERAND (node, 0);
2408 /* If this is for break or continue, don't bother printing it. */
2409 if (DECL_NAME (op0))
2411 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2412 if (strcmp (name, "break") == 0
2413 || strcmp (name, "continue") == 0)
2414 break;
2416 dump_generic_node (pp, op0, spc, flags, false);
2417 pp_colon (pp);
2418 if (DECL_NONLOCAL (op0))
2419 pp_string (pp, " [non-local]");
2420 break;
2422 case LOOP_EXPR:
2423 pp_string (pp, "while (1)");
2424 if (!(flags & TDF_SLIM))
2426 newline_and_indent (pp, spc+2);
2427 pp_left_brace (pp);
2428 newline_and_indent (pp, spc+4);
2429 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2430 newline_and_indent (pp, spc+2);
2431 pp_right_brace (pp);
2433 is_expr = false;
2434 break;
2436 case PREDICT_EXPR:
2437 pp_string (pp, "// predicted ");
2438 if (PREDICT_EXPR_OUTCOME (node))
2439 pp_string (pp, "likely by ");
2440 else
2441 pp_string (pp, "unlikely by ");
2442 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2443 pp_string (pp, " predictor.");
2444 break;
2446 case ANNOTATE_EXPR:
2447 pp_string (pp, "ANNOTATE_EXPR <");
2448 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2449 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2451 case annot_expr_ivdep_kind:
2452 pp_string (pp, ", ivdep");
2453 break;
2454 case annot_expr_no_vector_kind:
2455 pp_string (pp, ", no-vector");
2456 break;
2457 case annot_expr_vector_kind:
2458 pp_string (pp, ", vector");
2459 break;
2460 default:
2461 gcc_unreachable ();
2463 pp_greater (pp);
2464 break;
2466 case RETURN_EXPR:
2467 pp_string (pp, "return");
2468 op0 = TREE_OPERAND (node, 0);
2469 if (op0)
2471 pp_space (pp);
2472 if (TREE_CODE (op0) == MODIFY_EXPR)
2473 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2474 spc, flags, false);
2475 else
2476 dump_generic_node (pp, op0, spc, flags, false);
2478 break;
2480 case EXIT_EXPR:
2481 pp_string (pp, "if (");
2482 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2483 pp_string (pp, ") break");
2484 break;
2486 case SWITCH_EXPR:
2487 pp_string (pp, "switch (");
2488 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2489 pp_right_paren (pp);
2490 if (!(flags & TDF_SLIM))
2492 newline_and_indent (pp, spc+2);
2493 pp_left_brace (pp);
2494 if (SWITCH_BODY (node))
2496 newline_and_indent (pp, spc+4);
2497 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2498 true);
2500 else
2502 tree vec = SWITCH_LABELS (node);
2503 size_t i, n = TREE_VEC_LENGTH (vec);
2504 for (i = 0; i < n; ++i)
2506 tree elt = TREE_VEC_ELT (vec, i);
2507 newline_and_indent (pp, spc+4);
2508 if (elt)
2510 dump_generic_node (pp, elt, spc+4, flags, false);
2511 pp_string (pp, " goto ");
2512 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2513 flags, true);
2514 pp_semicolon (pp);
2516 else
2517 pp_string (pp, "case ???: goto ???;");
2520 newline_and_indent (pp, spc+2);
2521 pp_right_brace (pp);
2523 is_expr = false;
2524 break;
2526 case GOTO_EXPR:
2527 op0 = GOTO_DESTINATION (node);
2528 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2530 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2531 if (strcmp (name, "break") == 0
2532 || strcmp (name, "continue") == 0)
2534 pp_string (pp, name);
2535 break;
2538 pp_string (pp, "goto ");
2539 dump_generic_node (pp, op0, spc, flags, false);
2540 break;
2542 case ASM_EXPR:
2543 pp_string (pp, "__asm__");
2544 if (ASM_VOLATILE_P (node))
2545 pp_string (pp, " __volatile__");
2546 pp_left_paren (pp);
2547 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2548 pp_colon (pp);
2549 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2550 pp_colon (pp);
2551 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2552 if (ASM_CLOBBERS (node))
2554 pp_colon (pp);
2555 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2557 pp_right_paren (pp);
2558 break;
2560 case CASE_LABEL_EXPR:
2561 if (CASE_LOW (node) && CASE_HIGH (node))
2563 pp_string (pp, "case ");
2564 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2565 pp_string (pp, " ... ");
2566 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2568 else if (CASE_LOW (node))
2570 pp_string (pp, "case ");
2571 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2573 else
2574 pp_string (pp, "default");
2575 pp_colon (pp);
2576 break;
2578 case OBJ_TYPE_REF:
2579 pp_string (pp, "OBJ_TYPE_REF(");
2580 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2581 pp_semicolon (pp);
2582 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2584 pp_string (pp, "(");
2585 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2586 pp_string (pp, ")");
2588 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2589 pp_arrow (pp);
2590 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2591 pp_right_paren (pp);
2592 break;
2594 case SSA_NAME:
2595 if (SSA_NAME_IDENTIFIER (node))
2596 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2597 spc, flags, false);
2598 pp_underscore (pp);
2599 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2600 if (SSA_NAME_IS_DEFAULT_DEF (node))
2601 pp_string (pp, "(D)");
2602 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2603 pp_string (pp, "(ab)");
2604 break;
2606 case WITH_SIZE_EXPR:
2607 pp_string (pp, "WITH_SIZE_EXPR <");
2608 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2609 pp_string (pp, ", ");
2610 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2611 pp_greater (pp);
2612 break;
2614 case ASSERT_EXPR:
2615 pp_string (pp, "ASSERT_EXPR <");
2616 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2617 pp_string (pp, ", ");
2618 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2619 pp_greater (pp);
2620 break;
2622 case SCEV_KNOWN:
2623 pp_string (pp, "scev_known");
2624 break;
2626 case SCEV_NOT_KNOWN:
2627 pp_string (pp, "scev_not_known");
2628 break;
2630 case POLYNOMIAL_CHREC:
2631 pp_left_brace (pp);
2632 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2633 pp_string (pp, ", +, ");
2634 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2635 pp_string (pp, "}_");
2636 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2637 is_stmt = false;
2638 break;
2640 case REALIGN_LOAD_EXPR:
2641 pp_string (pp, "REALIGN_LOAD <");
2642 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2643 pp_string (pp, ", ");
2644 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2645 pp_string (pp, ", ");
2646 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2647 pp_greater (pp);
2648 break;
2650 case VEC_COND_EXPR:
2651 pp_string (pp, " VEC_COND_EXPR < ");
2652 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2653 pp_string (pp, " , ");
2654 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2655 pp_string (pp, " , ");
2656 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2657 pp_string (pp, " > ");
2658 break;
2660 case VEC_PERM_EXPR:
2661 pp_string (pp, " VEC_PERM_EXPR < ");
2662 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2663 pp_string (pp, " , ");
2664 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2665 pp_string (pp, " , ");
2666 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2667 pp_string (pp, " > ");
2668 break;
2670 case DOT_PROD_EXPR:
2671 pp_string (pp, " DOT_PROD_EXPR < ");
2672 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2673 pp_string (pp, ", ");
2674 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2675 pp_string (pp, ", ");
2676 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2677 pp_string (pp, " > ");
2678 break;
2680 case WIDEN_MULT_PLUS_EXPR:
2681 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2682 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2683 pp_string (pp, ", ");
2684 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2685 pp_string (pp, ", ");
2686 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2687 pp_string (pp, " > ");
2688 break;
2690 case WIDEN_MULT_MINUS_EXPR:
2691 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2692 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2693 pp_string (pp, ", ");
2694 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2695 pp_string (pp, ", ");
2696 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2697 pp_string (pp, " > ");
2698 break;
2700 case FMA_EXPR:
2701 pp_string (pp, " FMA_EXPR < ");
2702 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2703 pp_string (pp, ", ");
2704 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2705 pp_string (pp, ", ");
2706 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2707 pp_string (pp, " > ");
2708 break;
2710 case OACC_PARALLEL:
2711 pp_string (pp, "#pragma acc parallel");
2712 goto dump_omp_clauses_body;
2714 case OACC_KERNELS:
2715 pp_string (pp, "#pragma acc kernels");
2716 goto dump_omp_clauses_body;
2718 case OACC_DATA:
2719 pp_string (pp, "#pragma acc data");
2720 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2721 goto dump_omp_body;
2723 case OACC_HOST_DATA:
2724 pp_string (pp, "#pragma acc host_data");
2725 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2726 goto dump_omp_body;
2728 case OACC_DECLARE:
2729 pp_string (pp, "#pragma acc declare");
2730 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2731 break;
2733 case OACC_UPDATE:
2734 pp_string (pp, "#pragma acc update");
2735 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2736 break;
2738 case OACC_ENTER_DATA:
2739 pp_string (pp, "#pragma acc enter data");
2740 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2741 break;
2743 case OACC_EXIT_DATA:
2744 pp_string (pp, "#pragma acc exit data");
2745 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2746 break;
2748 case OACC_CACHE:
2749 pp_string (pp, "#pragma acc cache");
2750 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2751 break;
2753 case OMP_PARALLEL:
2754 pp_string (pp, "#pragma omp parallel");
2755 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2756 goto dump_omp_body;
2758 dump_omp_clauses_body:
2759 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2760 goto dump_omp_body;
2762 dump_omp_body:
2763 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2765 newline_and_indent (pp, spc + 2);
2766 pp_left_brace (pp);
2767 newline_and_indent (pp, spc + 4);
2768 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2769 newline_and_indent (pp, spc + 2);
2770 pp_right_brace (pp);
2772 is_expr = false;
2773 break;
2775 case OMP_TASK:
2776 pp_string (pp, "#pragma omp task");
2777 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2778 goto dump_omp_body;
2780 case OMP_FOR:
2781 pp_string (pp, "#pragma omp for");
2782 goto dump_omp_loop;
2784 case OMP_SIMD:
2785 pp_string (pp, "#pragma omp simd");
2786 goto dump_omp_loop;
2788 case CILK_SIMD:
2789 pp_string (pp, "#pragma simd");
2790 goto dump_omp_loop;
2792 case CILK_FOR:
2793 /* This label points one line after dumping the clauses.
2794 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2795 parameters are printed out. */
2796 goto dump_omp_loop_cilk_for;
2798 case OMP_DISTRIBUTE:
2799 pp_string (pp, "#pragma omp distribute");
2800 goto dump_omp_loop;
2802 case OMP_TASKLOOP:
2803 pp_string (pp, "#pragma omp taskloop");
2804 goto dump_omp_loop;
2806 case OACC_LOOP:
2807 pp_string (pp, "#pragma acc loop");
2808 goto dump_omp_loop;
2810 case OMP_TEAMS:
2811 pp_string (pp, "#pragma omp teams");
2812 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2813 goto dump_omp_body;
2815 case OMP_TARGET_DATA:
2816 pp_string (pp, "#pragma omp target data");
2817 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2818 goto dump_omp_body;
2820 case OMP_TARGET_ENTER_DATA:
2821 pp_string (pp, "#pragma omp target enter data");
2822 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2823 is_expr = false;
2824 break;
2826 case OMP_TARGET_EXIT_DATA:
2827 pp_string (pp, "#pragma omp target exit data");
2828 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2829 is_expr = false;
2830 break;
2832 case OMP_TARGET:
2833 pp_string (pp, "#pragma omp target");
2834 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2835 goto dump_omp_body;
2837 case OMP_TARGET_UPDATE:
2838 pp_string (pp, "#pragma omp target update");
2839 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2840 is_expr = false;
2841 break;
2843 dump_omp_loop:
2844 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2846 dump_omp_loop_cilk_for:
2847 if (!(flags & TDF_SLIM))
2849 int i;
2851 if (OMP_FOR_PRE_BODY (node))
2853 if (TREE_CODE (node) == CILK_FOR)
2854 pp_string (pp, " ");
2855 else
2856 newline_and_indent (pp, spc + 2);
2857 pp_left_brace (pp);
2858 spc += 4;
2859 newline_and_indent (pp, spc);
2860 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2861 spc, flags, false);
2863 if (OMP_FOR_INIT (node))
2865 spc -= 2;
2866 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2868 spc += 2;
2869 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2870 newline_and_indent (pp, spc);
2871 if (TREE_CODE (node) == CILK_FOR)
2872 pp_string (pp, "_Cilk_for (");
2873 else
2874 pp_string (pp, "for (");
2875 dump_generic_node (pp,
2876 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2877 spc, flags, false);
2878 pp_string (pp, "; ");
2879 dump_generic_node (pp,
2880 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2881 spc, flags, false);
2882 pp_string (pp, "; ");
2883 dump_generic_node (pp,
2884 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2885 spc, flags, false);
2886 pp_right_paren (pp);
2888 if (TREE_CODE (node) == CILK_FOR)
2889 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2891 if (OMP_FOR_BODY (node))
2893 newline_and_indent (pp, spc + 2);
2894 pp_left_brace (pp);
2895 newline_and_indent (pp, spc + 4);
2896 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2897 false);
2898 newline_and_indent (pp, spc + 2);
2899 pp_right_brace (pp);
2901 if (OMP_FOR_INIT (node))
2902 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2903 if (OMP_FOR_PRE_BODY (node))
2905 spc -= 4;
2906 newline_and_indent (pp, spc + 2);
2907 pp_right_brace (pp);
2910 is_expr = false;
2911 break;
2913 case OMP_SECTIONS:
2914 pp_string (pp, "#pragma omp sections");
2915 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2916 goto dump_omp_body;
2918 case OMP_SECTION:
2919 pp_string (pp, "#pragma omp section");
2920 goto dump_omp_body;
2922 case OMP_MASTER:
2923 pp_string (pp, "#pragma omp master");
2924 goto dump_omp_body;
2926 case OMP_TASKGROUP:
2927 pp_string (pp, "#pragma omp taskgroup");
2928 goto dump_omp_body;
2930 case OMP_ORDERED:
2931 pp_string (pp, "#pragma omp ordered");
2932 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
2933 goto dump_omp_body;
2935 case OMP_CRITICAL:
2936 pp_string (pp, "#pragma omp critical");
2937 if (OMP_CRITICAL_NAME (node))
2939 pp_space (pp);
2940 pp_left_paren (pp);
2941 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2942 flags, false);
2943 pp_right_paren (pp);
2945 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
2946 goto dump_omp_body;
2948 case OMP_ATOMIC:
2949 pp_string (pp, "#pragma omp atomic");
2950 if (OMP_ATOMIC_SEQ_CST (node))
2951 pp_string (pp, " seq_cst");
2952 newline_and_indent (pp, spc + 2);
2953 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2954 pp_space (pp);
2955 pp_equal (pp);
2956 pp_space (pp);
2957 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2958 break;
2960 case OMP_ATOMIC_READ:
2961 pp_string (pp, "#pragma omp atomic read");
2962 if (OMP_ATOMIC_SEQ_CST (node))
2963 pp_string (pp, " seq_cst");
2964 newline_and_indent (pp, spc + 2);
2965 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2966 pp_space (pp);
2967 break;
2969 case OMP_ATOMIC_CAPTURE_OLD:
2970 case OMP_ATOMIC_CAPTURE_NEW:
2971 pp_string (pp, "#pragma omp atomic capture");
2972 if (OMP_ATOMIC_SEQ_CST (node))
2973 pp_string (pp, " seq_cst");
2974 newline_and_indent (pp, spc + 2);
2975 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2976 pp_space (pp);
2977 pp_equal (pp);
2978 pp_space (pp);
2979 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2980 break;
2982 case OMP_SINGLE:
2983 pp_string (pp, "#pragma omp single");
2984 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2985 goto dump_omp_body;
2987 case OMP_CLAUSE:
2988 dump_omp_clause (pp, node, spc, flags);
2989 is_expr = false;
2990 break;
2992 case TRANSACTION_EXPR:
2993 if (TRANSACTION_EXPR_OUTER (node))
2994 pp_string (pp, "__transaction_atomic [[outer]]");
2995 else if (TRANSACTION_EXPR_RELAXED (node))
2996 pp_string (pp, "__transaction_relaxed");
2997 else
2998 pp_string (pp, "__transaction_atomic");
2999 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3001 newline_and_indent (pp, spc);
3002 pp_left_brace (pp);
3003 newline_and_indent (pp, spc + 2);
3004 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3005 spc + 2, flags, false);
3006 newline_and_indent (pp, spc);
3007 pp_right_brace (pp);
3009 is_expr = false;
3010 break;
3012 case REDUC_MAX_EXPR:
3013 pp_string (pp, " REDUC_MAX_EXPR < ");
3014 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3015 pp_string (pp, " > ");
3016 break;
3018 case REDUC_MIN_EXPR:
3019 pp_string (pp, " REDUC_MIN_EXPR < ");
3020 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3021 pp_string (pp, " > ");
3022 break;
3024 case REDUC_PLUS_EXPR:
3025 pp_string (pp, " REDUC_PLUS_EXPR < ");
3026 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3027 pp_string (pp, " > ");
3028 break;
3030 case VEC_WIDEN_MULT_HI_EXPR:
3031 case VEC_WIDEN_MULT_LO_EXPR:
3032 case VEC_WIDEN_MULT_EVEN_EXPR:
3033 case VEC_WIDEN_MULT_ODD_EXPR:
3034 case VEC_WIDEN_LSHIFT_HI_EXPR:
3035 case VEC_WIDEN_LSHIFT_LO_EXPR:
3036 pp_space (pp);
3037 for (str = get_tree_code_name (code); *str; str++)
3038 pp_character (pp, TOUPPER (*str));
3039 pp_string (pp, " < ");
3040 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3041 pp_string (pp, ", ");
3042 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3043 pp_string (pp, " > ");
3044 break;
3046 case VEC_UNPACK_HI_EXPR:
3047 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3048 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3049 pp_string (pp, " > ");
3050 break;
3052 case VEC_UNPACK_LO_EXPR:
3053 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3054 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3055 pp_string (pp, " > ");
3056 break;
3058 case VEC_UNPACK_FLOAT_HI_EXPR:
3059 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3060 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3061 pp_string (pp, " > ");
3062 break;
3064 case VEC_UNPACK_FLOAT_LO_EXPR:
3065 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3066 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3067 pp_string (pp, " > ");
3068 break;
3070 case VEC_PACK_TRUNC_EXPR:
3071 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3072 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3073 pp_string (pp, ", ");
3074 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3075 pp_string (pp, " > ");
3076 break;
3078 case VEC_PACK_SAT_EXPR:
3079 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3080 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3081 pp_string (pp, ", ");
3082 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3083 pp_string (pp, " > ");
3084 break;
3086 case VEC_PACK_FIX_TRUNC_EXPR:
3087 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3088 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3089 pp_string (pp, ", ");
3090 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3091 pp_string (pp, " > ");
3092 break;
3094 case BLOCK:
3095 dump_block_node (pp, node, spc, flags);
3096 break;
3098 case CILK_SPAWN_STMT:
3099 pp_string (pp, "_Cilk_spawn ");
3100 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3101 break;
3103 case CILK_SYNC_STMT:
3104 pp_string (pp, "_Cilk_sync");
3105 break;
3107 default:
3108 NIY;
3111 if (is_stmt && is_expr)
3112 pp_semicolon (pp);
3114 return spc;
3117 /* Print the declaration of a variable. */
3119 void
3120 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
3122 INDENT (spc);
3124 if (TREE_CODE(t) == NAMELIST_DECL)
3126 pp_string(pp, "namelist ");
3127 dump_decl_name (pp, t, flags);
3128 pp_semicolon (pp);
3129 return;
3132 if (TREE_CODE (t) == TYPE_DECL)
3133 pp_string (pp, "typedef ");
3135 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3136 pp_string (pp, "register ");
3138 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3139 pp_string (pp, "extern ");
3140 else if (TREE_STATIC (t))
3141 pp_string (pp, "static ");
3143 /* Print the type and name. */
3144 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3146 tree tmp;
3148 /* Print array's type. */
3149 tmp = TREE_TYPE (t);
3150 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3151 tmp = TREE_TYPE (tmp);
3152 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3154 /* Print variable's name. */
3155 pp_space (pp);
3156 dump_generic_node (pp, t, spc, flags, false);
3158 /* Print the dimensions. */
3159 tmp = TREE_TYPE (t);
3160 while (TREE_CODE (tmp) == ARRAY_TYPE)
3162 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3163 tmp = TREE_TYPE (tmp);
3166 else if (TREE_CODE (t) == FUNCTION_DECL)
3168 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3169 pp_space (pp);
3170 dump_decl_name (pp, t, flags);
3171 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3173 else
3175 /* Print type declaration. */
3176 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3178 /* Print variable's name. */
3179 pp_space (pp);
3180 dump_generic_node (pp, t, spc, flags, false);
3183 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3185 pp_string (pp, " __asm__ ");
3186 pp_left_paren (pp);
3187 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3188 pp_right_paren (pp);
3191 /* The initial value of a function serves to determine whether the function
3192 is declared or defined. So the following does not apply to function
3193 nodes. */
3194 if (TREE_CODE (t) != FUNCTION_DECL)
3196 /* Print the initial value. */
3197 if (DECL_INITIAL (t))
3199 pp_space (pp);
3200 pp_equal (pp);
3201 pp_space (pp);
3202 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3206 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3208 pp_string (pp, " [value-expr: ");
3209 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3210 pp_right_bracket (pp);
3213 pp_semicolon (pp);
3217 /* Prints a structure: name, fields, and methods.
3218 FIXME: Still incomplete. */
3220 static void
3221 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3223 /* Print the name of the structure. */
3224 if (TYPE_NAME (node))
3226 INDENT (spc);
3227 if (TREE_CODE (node) == RECORD_TYPE)
3228 pp_string (pp, "struct ");
3229 else if ((TREE_CODE (node) == UNION_TYPE
3230 || TREE_CODE (node) == QUAL_UNION_TYPE))
3231 pp_string (pp, "union ");
3233 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3236 /* Print the contents of the structure. */
3237 pp_newline (pp);
3238 INDENT (spc);
3239 pp_left_brace (pp);
3240 pp_newline (pp);
3242 /* Print the fields of the structure. */
3244 tree tmp;
3245 tmp = TYPE_FIELDS (node);
3246 while (tmp)
3248 /* Avoid to print recursively the structure. */
3249 /* FIXME : Not implemented correctly...,
3250 what about the case when we have a cycle in the contain graph? ...
3251 Maybe this could be solved by looking at the scope in which the
3252 structure was declared. */
3253 if (TREE_TYPE (tmp) != node
3254 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3255 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3257 print_declaration (pp, tmp, spc+2, flags);
3258 pp_newline (pp);
3260 tmp = DECL_CHAIN (tmp);
3263 INDENT (spc);
3264 pp_right_brace (pp);
3267 /* Return the priority of the operator CODE.
3269 From lowest to highest precedence with either left-to-right (L-R)
3270 or right-to-left (R-L) associativity]:
3272 1 [L-R] ,
3273 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3274 3 [R-L] ?:
3275 4 [L-R] ||
3276 5 [L-R] &&
3277 6 [L-R] |
3278 7 [L-R] ^
3279 8 [L-R] &
3280 9 [L-R] == !=
3281 10 [L-R] < <= > >=
3282 11 [L-R] << >>
3283 12 [L-R] + -
3284 13 [L-R] * / %
3285 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3286 15 [L-R] fn() [] -> .
3288 unary +, - and * have higher precedence than the corresponding binary
3289 operators. */
3292 op_code_prio (enum tree_code code)
3294 switch (code)
3296 case TREE_LIST:
3297 case COMPOUND_EXPR:
3298 case BIND_EXPR:
3299 return 1;
3301 case MODIFY_EXPR:
3302 case INIT_EXPR:
3303 return 2;
3305 case COND_EXPR:
3306 return 3;
3308 case TRUTH_OR_EXPR:
3309 case TRUTH_ORIF_EXPR:
3310 return 4;
3312 case TRUTH_AND_EXPR:
3313 case TRUTH_ANDIF_EXPR:
3314 return 5;
3316 case BIT_IOR_EXPR:
3317 return 6;
3319 case BIT_XOR_EXPR:
3320 case TRUTH_XOR_EXPR:
3321 return 7;
3323 case BIT_AND_EXPR:
3324 return 8;
3326 case EQ_EXPR:
3327 case NE_EXPR:
3328 return 9;
3330 case UNLT_EXPR:
3331 case UNLE_EXPR:
3332 case UNGT_EXPR:
3333 case UNGE_EXPR:
3334 case UNEQ_EXPR:
3335 case LTGT_EXPR:
3336 case ORDERED_EXPR:
3337 case UNORDERED_EXPR:
3338 case LT_EXPR:
3339 case LE_EXPR:
3340 case GT_EXPR:
3341 case GE_EXPR:
3342 return 10;
3344 case LSHIFT_EXPR:
3345 case RSHIFT_EXPR:
3346 case LROTATE_EXPR:
3347 case RROTATE_EXPR:
3348 case VEC_WIDEN_LSHIFT_HI_EXPR:
3349 case VEC_WIDEN_LSHIFT_LO_EXPR:
3350 case WIDEN_LSHIFT_EXPR:
3351 return 11;
3353 case WIDEN_SUM_EXPR:
3354 case PLUS_EXPR:
3355 case POINTER_PLUS_EXPR:
3356 case MINUS_EXPR:
3357 return 12;
3359 case VEC_WIDEN_MULT_HI_EXPR:
3360 case VEC_WIDEN_MULT_LO_EXPR:
3361 case WIDEN_MULT_EXPR:
3362 case DOT_PROD_EXPR:
3363 case WIDEN_MULT_PLUS_EXPR:
3364 case WIDEN_MULT_MINUS_EXPR:
3365 case MULT_EXPR:
3366 case MULT_HIGHPART_EXPR:
3367 case TRUNC_DIV_EXPR:
3368 case CEIL_DIV_EXPR:
3369 case FLOOR_DIV_EXPR:
3370 case ROUND_DIV_EXPR:
3371 case RDIV_EXPR:
3372 case EXACT_DIV_EXPR:
3373 case TRUNC_MOD_EXPR:
3374 case CEIL_MOD_EXPR:
3375 case FLOOR_MOD_EXPR:
3376 case ROUND_MOD_EXPR:
3377 case FMA_EXPR:
3378 return 13;
3380 case TRUTH_NOT_EXPR:
3381 case BIT_NOT_EXPR:
3382 case POSTINCREMENT_EXPR:
3383 case POSTDECREMENT_EXPR:
3384 case PREINCREMENT_EXPR:
3385 case PREDECREMENT_EXPR:
3386 case NEGATE_EXPR:
3387 case INDIRECT_REF:
3388 case ADDR_EXPR:
3389 case FLOAT_EXPR:
3390 CASE_CONVERT:
3391 case FIX_TRUNC_EXPR:
3392 case TARGET_EXPR:
3393 return 14;
3395 case CALL_EXPR:
3396 case ARRAY_REF:
3397 case ARRAY_RANGE_REF:
3398 case COMPONENT_REF:
3399 return 15;
3401 /* Special expressions. */
3402 case MIN_EXPR:
3403 case MAX_EXPR:
3404 case ABS_EXPR:
3405 case REALPART_EXPR:
3406 case IMAGPART_EXPR:
3407 case REDUC_MAX_EXPR:
3408 case REDUC_MIN_EXPR:
3409 case REDUC_PLUS_EXPR:
3410 case VEC_UNPACK_HI_EXPR:
3411 case VEC_UNPACK_LO_EXPR:
3412 case VEC_UNPACK_FLOAT_HI_EXPR:
3413 case VEC_UNPACK_FLOAT_LO_EXPR:
3414 case VEC_PACK_TRUNC_EXPR:
3415 case VEC_PACK_SAT_EXPR:
3416 return 16;
3418 default:
3419 /* Return an arbitrarily high precedence to avoid surrounding single
3420 VAR_DECLs in ()s. */
3421 return 9999;
3425 /* Return the priority of the operator OP. */
3428 op_prio (const_tree op)
3430 enum tree_code code;
3432 if (op == NULL)
3433 return 9999;
3435 code = TREE_CODE (op);
3436 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3437 return op_prio (TREE_OPERAND (op, 0));
3439 return op_code_prio (code);
3442 /* Return the symbol associated with operator CODE. */
3444 const char *
3445 op_symbol_code (enum tree_code code)
3447 switch (code)
3449 case MODIFY_EXPR:
3450 return "=";
3452 case TRUTH_OR_EXPR:
3453 case TRUTH_ORIF_EXPR:
3454 return "||";
3456 case TRUTH_AND_EXPR:
3457 case TRUTH_ANDIF_EXPR:
3458 return "&&";
3460 case BIT_IOR_EXPR:
3461 return "|";
3463 case TRUTH_XOR_EXPR:
3464 case BIT_XOR_EXPR:
3465 return "^";
3467 case ADDR_EXPR:
3468 case BIT_AND_EXPR:
3469 return "&";
3471 case ORDERED_EXPR:
3472 return "ord";
3473 case UNORDERED_EXPR:
3474 return "unord";
3476 case EQ_EXPR:
3477 return "==";
3478 case UNEQ_EXPR:
3479 return "u==";
3481 case NE_EXPR:
3482 return "!=";
3484 case LT_EXPR:
3485 return "<";
3486 case UNLT_EXPR:
3487 return "u<";
3489 case LE_EXPR:
3490 return "<=";
3491 case UNLE_EXPR:
3492 return "u<=";
3494 case GT_EXPR:
3495 return ">";
3496 case UNGT_EXPR:
3497 return "u>";
3499 case GE_EXPR:
3500 return ">=";
3501 case UNGE_EXPR:
3502 return "u>=";
3504 case LTGT_EXPR:
3505 return "<>";
3507 case LSHIFT_EXPR:
3508 return "<<";
3510 case RSHIFT_EXPR:
3511 return ">>";
3513 case LROTATE_EXPR:
3514 return "r<<";
3516 case RROTATE_EXPR:
3517 return "r>>";
3519 case WIDEN_LSHIFT_EXPR:
3520 return "w<<";
3522 case POINTER_PLUS_EXPR:
3523 return "+";
3525 case PLUS_EXPR:
3526 return "+";
3528 case REDUC_PLUS_EXPR:
3529 return "r+";
3531 case WIDEN_SUM_EXPR:
3532 return "w+";
3534 case WIDEN_MULT_EXPR:
3535 return "w*";
3537 case MULT_HIGHPART_EXPR:
3538 return "h*";
3540 case NEGATE_EXPR:
3541 case MINUS_EXPR:
3542 return "-";
3544 case BIT_NOT_EXPR:
3545 return "~";
3547 case TRUTH_NOT_EXPR:
3548 return "!";
3550 case MULT_EXPR:
3551 case INDIRECT_REF:
3552 return "*";
3554 case TRUNC_DIV_EXPR:
3555 case RDIV_EXPR:
3556 return "/";
3558 case CEIL_DIV_EXPR:
3559 return "/[cl]";
3561 case FLOOR_DIV_EXPR:
3562 return "/[fl]";
3564 case ROUND_DIV_EXPR:
3565 return "/[rd]";
3567 case EXACT_DIV_EXPR:
3568 return "/[ex]";
3570 case TRUNC_MOD_EXPR:
3571 return "%";
3573 case CEIL_MOD_EXPR:
3574 return "%[cl]";
3576 case FLOOR_MOD_EXPR:
3577 return "%[fl]";
3579 case ROUND_MOD_EXPR:
3580 return "%[rd]";
3582 case PREDECREMENT_EXPR:
3583 return " --";
3585 case PREINCREMENT_EXPR:
3586 return " ++";
3588 case POSTDECREMENT_EXPR:
3589 return "-- ";
3591 case POSTINCREMENT_EXPR:
3592 return "++ ";
3594 case MAX_EXPR:
3595 return "max";
3597 case MIN_EXPR:
3598 return "min";
3600 default:
3601 return "<<< ??? >>>";
3605 /* Return the symbol associated with operator OP. */
3607 static const char *
3608 op_symbol (const_tree op)
3610 return op_symbol_code (TREE_CODE (op));
3613 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3614 the gimple_call_fn of a GIMPLE_CALL. */
3616 void
3617 print_call_name (pretty_printer *pp, tree node, int flags)
3619 tree op0 = node;
3621 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3622 op0 = TREE_OPERAND (op0, 0);
3624 again:
3625 switch (TREE_CODE (op0))
3627 case VAR_DECL:
3628 case PARM_DECL:
3629 case FUNCTION_DECL:
3630 dump_function_name (pp, op0, flags);
3631 break;
3633 case ADDR_EXPR:
3634 case INDIRECT_REF:
3635 CASE_CONVERT:
3636 op0 = TREE_OPERAND (op0, 0);
3637 goto again;
3639 case COND_EXPR:
3640 pp_left_paren (pp);
3641 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3642 pp_string (pp, ") ? ");
3643 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3644 pp_string (pp, " : ");
3645 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3646 break;
3648 case ARRAY_REF:
3649 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3650 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3651 else
3652 dump_generic_node (pp, op0, 0, flags, false);
3653 break;
3655 case MEM_REF:
3656 if (integer_zerop (TREE_OPERAND (op0, 1)))
3658 op0 = TREE_OPERAND (op0, 0);
3659 goto again;
3661 /* Fallthru. */
3662 case COMPONENT_REF:
3663 case SSA_NAME:
3664 case OBJ_TYPE_REF:
3665 dump_generic_node (pp, op0, 0, flags, false);
3666 break;
3668 default:
3669 NIY;
3673 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3675 static void
3676 pretty_print_string (pretty_printer *pp, const char *str)
3678 if (str == NULL)
3679 return;
3681 while (*str)
3683 switch (str[0])
3685 case '\b':
3686 pp_string (pp, "\\b");
3687 break;
3689 case '\f':
3690 pp_string (pp, "\\f");
3691 break;
3693 case '\n':
3694 pp_string (pp, "\\n");
3695 break;
3697 case '\r':
3698 pp_string (pp, "\\r");
3699 break;
3701 case '\t':
3702 pp_string (pp, "\\t");
3703 break;
3705 case '\v':
3706 pp_string (pp, "\\v");
3707 break;
3709 case '\\':
3710 pp_string (pp, "\\\\");
3711 break;
3713 case '\"':
3714 pp_string (pp, "\\\"");
3715 break;
3717 case '\'':
3718 pp_string (pp, "\\'");
3719 break;
3721 /* No need to handle \0; the loop terminates on \0. */
3723 case '\1':
3724 pp_string (pp, "\\1");
3725 break;
3727 case '\2':
3728 pp_string (pp, "\\2");
3729 break;
3731 case '\3':
3732 pp_string (pp, "\\3");
3733 break;
3735 case '\4':
3736 pp_string (pp, "\\4");
3737 break;
3739 case '\5':
3740 pp_string (pp, "\\5");
3741 break;
3743 case '\6':
3744 pp_string (pp, "\\6");
3745 break;
3747 case '\7':
3748 pp_string (pp, "\\7");
3749 break;
3751 default:
3752 pp_character (pp, str[0]);
3753 break;
3755 str++;
3759 static void
3760 maybe_init_pretty_print (FILE *file)
3762 if (!tree_pp)
3764 tree_pp = new pretty_printer ();
3765 pp_needs_newline (tree_pp) = true;
3766 pp_translate_identifiers (tree_pp) = false;
3769 tree_pp->buffer->stream = file;
3772 static void
3773 newline_and_indent (pretty_printer *pp, int spc)
3775 pp_newline (pp);
3776 INDENT (spc);
3779 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3780 it can also be used in front ends.
3781 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3784 void
3785 percent_K_format (text_info *text)
3787 tree t = va_arg (*text->args_ptr, tree), block;
3788 text->set_location (0, EXPR_LOCATION (t), true);
3789 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3790 block = TREE_BLOCK (t);
3791 *pp_ti_abstract_origin (text) = NULL;
3793 if (in_lto_p)
3795 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3796 representing the outermost block of an inlined function.
3797 So walk the BLOCK tree until we hit such a scope. */
3798 while (block
3799 && TREE_CODE (block) == BLOCK)
3801 if (inlined_function_outer_scope_p (block))
3803 *pp_ti_abstract_origin (text) = block;
3804 break;
3806 block = BLOCK_SUPERCONTEXT (block);
3808 return;
3811 while (block
3812 && TREE_CODE (block) == BLOCK
3813 && BLOCK_ABSTRACT_ORIGIN (block))
3815 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3817 while (TREE_CODE (ao) == BLOCK
3818 && BLOCK_ABSTRACT_ORIGIN (ao)
3819 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3820 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3822 if (TREE_CODE (ao) == FUNCTION_DECL)
3824 *pp_ti_abstract_origin (text) = block;
3825 break;
3827 block = BLOCK_SUPERCONTEXT (block);
3831 /* Print the identifier ID to PRETTY-PRINTER. */
3833 void
3834 pp_tree_identifier (pretty_printer *pp, tree id)
3836 if (pp_translate_identifiers (pp))
3838 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3839 pp_append_text (pp, text, text + strlen (text));
3841 else
3842 pp_append_text (pp, IDENTIFIER_POINTER (id),
3843 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3846 /* A helper function that is used to dump function information before the
3847 function dump. */
3849 void
3850 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3852 const char *dname, *aname;
3853 struct cgraph_node *node = cgraph_node::get (fdecl);
3854 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3856 dname = lang_hooks.decl_printable_name (fdecl, 2);
3858 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3859 aname = (IDENTIFIER_POINTER
3860 (DECL_ASSEMBLER_NAME (fdecl)));
3861 else
3862 aname = "<unset-asm-name>";
3864 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3865 dname, aname, fun->funcdef_no);
3866 if (!(flags & TDF_NOUID))
3867 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3868 if (node)
3870 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3871 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3872 node->frequency == NODE_FREQUENCY_HOT
3873 ? " (hot)"
3874 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3875 ? " (unlikely executed)"
3876 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3877 ? " (executed once)"
3878 : "");
3880 else
3881 fprintf (dump_file, ")\n\n");
3884 /* Dump double_int D to pretty_printer PP. UNS is true
3885 if D is unsigned and false otherwise. */
3886 void
3887 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3889 if (d.fits_shwi ())
3890 pp_wide_integer (pp, d.low);
3891 else if (d.fits_uhwi ())
3892 pp_unsigned_wide_integer (pp, d.low);
3893 else
3895 unsigned HOST_WIDE_INT low = d.low;
3896 HOST_WIDE_INT high = d.high;
3897 if (!uns && d.is_negative ())
3899 pp_minus (pp);
3900 high = ~high + !low;
3901 low = -low;
3903 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3904 systems? */
3905 sprintf (pp_buffer (pp)->digit_buffer,
3906 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3907 (unsigned HOST_WIDE_INT) high, low);
3908 pp_string (pp, pp_buffer (pp)->digit_buffer);