PR c++/87582
[official-gcc.git] / gcc / tree-pretty-print.c
blob81414d117e154bd393c2b96a03ebe1ff8213739e
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2018 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"
36 #include "gimple.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree);
40 static void pretty_print_string (pretty_printer *, const char*, unsigned);
41 static void newline_and_indent (pretty_printer *, int);
42 static void maybe_init_pretty_print (FILE *);
43 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
44 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
46 #define INDENT(SPACE) do { \
47 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
49 #define NIY do_niy (pp, node, flags)
51 static pretty_printer *tree_pp;
53 /* Try to print something for an unknown tree code. */
55 static void
56 do_niy (pretty_printer *pp, const_tree node, dump_flags_t flags)
58 int i, len;
60 pp_string (pp, "<<< Unknown tree: ");
61 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
63 if (EXPR_P (node))
65 len = TREE_OPERAND_LENGTH (node);
66 for (i = 0; i < len; ++i)
68 newline_and_indent (pp, 2);
69 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
73 pp_string (pp, " >>>");
76 /* Debugging function to print out a generic expression. */
78 DEBUG_FUNCTION void
79 debug_generic_expr (tree t)
81 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
82 fprintf (stderr, "\n");
85 /* Debugging function to print out a generic statement. */
87 DEBUG_FUNCTION void
88 debug_generic_stmt (tree t)
90 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
91 fprintf (stderr, "\n");
94 /* Debugging function to print out a chain of trees . */
96 DEBUG_FUNCTION void
97 debug_tree_chain (tree t)
99 hash_set<tree> seen;
101 while (t)
103 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
104 fprintf (stderr, " ");
105 t = TREE_CHAIN (t);
106 if (seen.add (t))
108 fprintf (stderr, "... [cycled back to ");
109 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
110 fprintf (stderr, "]");
111 break;
114 fprintf (stderr, "\n");
117 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
118 void
119 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
121 maybe_init_pretty_print (file);
122 print_declaration (tree_pp, decl, 2, flags);
123 pp_write_text_to_stream (tree_pp);
126 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
127 to show in the dump. See TDF_* in dumpfile.h. */
129 void
130 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
132 maybe_init_pretty_print (file);
133 dump_generic_node (tree_pp, t, 0, flags, true);
134 pp_newline_and_flush (tree_pp);
137 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
138 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
139 INDENT spaces. */
141 void
142 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
144 int i;
146 maybe_init_pretty_print (file);
148 for (i = 0; i < indent; i++)
149 pp_space (tree_pp);
150 dump_generic_node (tree_pp, t, indent, flags, true);
151 pp_newline_and_flush (tree_pp);
154 /* Print a single expression T on file FILE. FLAGS specifies details to show
155 in the dump. See TDF_* in dumpfile.h. */
157 void
158 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
160 maybe_init_pretty_print (file);
161 dump_generic_node (tree_pp, t, 0, flags, false);
162 pp_flush (tree_pp);
165 /* Print a single expression T to string, and return it. */
167 char *
168 print_generic_expr_to_str (tree t)
170 pretty_printer pp;
171 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
172 return xstrdup (pp_formatted_text (&pp));
175 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
176 in it are replaced with Dxxxx, as long as they are at the start or
177 preceded by $ and at the end or followed by $. See make_fancy_name
178 in tree-sra.c. */
180 static void
181 dump_fancy_name (pretty_printer *pp, tree name)
183 int cnt = 0;
184 int length = IDENTIFIER_LENGTH (name);
185 const char *n = IDENTIFIER_POINTER (name);
188 n = strchr (n, 'D');
189 if (n == NULL)
190 break;
191 if (ISDIGIT (n[1])
192 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
194 int l = 2;
195 while (ISDIGIT (n[l]))
196 l++;
197 if (n[l] == '\0' || n[l] == '$')
199 cnt++;
200 length += 5 - l;
202 n += l;
204 else
205 n++;
207 while (1);
208 if (cnt == 0)
210 pp_tree_identifier (pp, name);
211 return;
214 char *str = XNEWVEC (char, length + 1);
215 char *p = str;
216 const char *q;
217 q = n = IDENTIFIER_POINTER (name);
220 q = strchr (q, 'D');
221 if (q == NULL)
222 break;
223 if (ISDIGIT (q[1])
224 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
226 int l = 2;
227 while (ISDIGIT (q[l]))
228 l++;
229 if (q[l] == '\0' || q[l] == '$')
231 memcpy (p, n, q - n);
232 memcpy (p + (q - n), "Dxxxx", 5);
233 p += (q - n) + 5;
234 n = q + l;
236 q += l;
238 else
239 q++;
241 while (1);
242 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
243 str[length] = '\0';
244 if (pp_translate_identifiers (pp))
246 const char *text = identifier_to_locale (str);
247 pp_append_text (pp, text, text + strlen (text));
249 else
250 pp_append_text (pp, str, str + length);
251 XDELETEVEC (str);
254 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
255 in FLAGS. */
257 static void
258 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
260 tree name = DECL_NAME (node);
261 if (name)
263 if ((flags & TDF_ASMNAME)
264 && HAS_DECL_ASSEMBLER_NAME_P (node)
265 && DECL_ASSEMBLER_NAME_SET_P (node))
266 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
267 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
268 -g might have created more fancy names and their indexes
269 could get out of sync. Usually those should be DECL_IGNORED_P
270 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
271 names, let's hope those never get out of sync after doing the
272 dump_fancy_name sanitization. */
273 else if ((flags & TDF_COMPARE_DEBUG)
274 && DECL_NAMELESS (node)
275 && DECL_IGNORED_P (node))
276 name = NULL_TREE;
277 /* For DECL_NAMELESS names look for embedded uids in the
278 names and sanitize them for TDF_NOUID. */
279 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
280 dump_fancy_name (pp, name);
281 else
282 pp_tree_identifier (pp, name);
284 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
285 if ((flags & TDF_UID) || name == NULL_TREE)
287 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
288 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
289 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
291 if (flags & TDF_NOUID)
292 pp_string (pp, "D#xxxx");
293 else
294 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
296 else
298 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
299 if (flags & TDF_NOUID)
300 pp_printf (pp, "%c.xxxx", c);
301 else
302 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
305 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
307 if (flags & TDF_NOUID)
308 pp_printf (pp, "ptD.xxxx");
309 else
310 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
314 /* Like the above, but used for pretty printing function calls. */
316 static void
317 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
319 if (CONVERT_EXPR_P (node))
320 node = TREE_OPERAND (node, 0);
321 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
322 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
323 else
324 dump_decl_name (pp, node, flags);
327 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
328 FLAGS are as in dump_generic_node. */
330 static void
331 dump_function_declaration (pretty_printer *pp, tree node,
332 int spc, dump_flags_t flags)
334 bool wrote_arg = false;
335 tree arg;
337 pp_space (pp);
338 pp_left_paren (pp);
340 /* Print the argument types. */
341 arg = TYPE_ARG_TYPES (node);
342 while (arg && arg != void_list_node && arg != error_mark_node)
344 if (wrote_arg)
346 pp_comma (pp);
347 pp_space (pp);
349 wrote_arg = true;
350 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
351 arg = TREE_CHAIN (arg);
354 /* Drop the trailing void_type_node if we had any previous argument. */
355 if (arg == void_list_node && !wrote_arg)
356 pp_string (pp, "void");
357 /* Properly dump vararg function types. */
358 else if (!arg && wrote_arg)
359 pp_string (pp, ", ...");
360 /* Avoid printing any arg for unprototyped functions. */
362 pp_right_paren (pp);
365 /* Dump the domain associated with an array. */
367 static void
368 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
370 pp_left_bracket (pp);
371 if (domain)
373 tree min = TYPE_MIN_VALUE (domain);
374 tree max = TYPE_MAX_VALUE (domain);
376 if (min && max
377 && integer_zerop (min)
378 && tree_fits_shwi_p (max))
379 pp_wide_integer (pp, tree_to_shwi (max) + 1);
380 else
382 if (min)
383 dump_generic_node (pp, min, spc, flags, false);
384 pp_colon (pp);
385 if (max)
386 dump_generic_node (pp, max, spc, flags, false);
389 else
390 pp_string (pp, "<unknown>");
391 pp_right_bracket (pp);
395 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
396 dump_generic_node. */
398 static void
399 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
401 const char *name;
403 switch (OMP_CLAUSE_CODE (clause))
405 case OMP_CLAUSE_PRIVATE:
406 name = "private";
407 goto print_remap;
408 case OMP_CLAUSE_SHARED:
409 name = "shared";
410 goto print_remap;
411 case OMP_CLAUSE_FIRSTPRIVATE:
412 name = "firstprivate";
413 goto print_remap;
414 case OMP_CLAUSE_LASTPRIVATE:
415 name = "lastprivate";
416 goto print_remap;
417 case OMP_CLAUSE_COPYIN:
418 name = "copyin";
419 goto print_remap;
420 case OMP_CLAUSE_COPYPRIVATE:
421 name = "copyprivate";
422 goto print_remap;
423 case OMP_CLAUSE_UNIFORM:
424 name = "uniform";
425 goto print_remap;
426 case OMP_CLAUSE_USE_DEVICE_PTR:
427 name = "use_device_ptr";
428 goto print_remap;
429 case OMP_CLAUSE_IS_DEVICE_PTR:
430 name = "is_device_ptr";
431 goto print_remap;
432 case OMP_CLAUSE__LOOPTEMP_:
433 name = "_looptemp_";
434 goto print_remap;
435 case OMP_CLAUSE_TO_DECLARE:
436 name = "to";
437 goto print_remap;
438 case OMP_CLAUSE_LINK:
439 name = "link";
440 goto print_remap;
441 print_remap:
442 pp_string (pp, name);
443 pp_left_paren (pp);
444 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
445 spc, flags, false);
446 pp_right_paren (pp);
447 break;
449 case OMP_CLAUSE_REDUCTION:
450 pp_string (pp, "reduction(");
451 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
453 pp_string (pp,
454 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
455 pp_colon (pp);
457 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
458 spc, flags, false);
459 pp_right_paren (pp);
460 break;
462 case OMP_CLAUSE_IF:
463 pp_string (pp, "if(");
464 switch (OMP_CLAUSE_IF_MODIFIER (clause))
466 case ERROR_MARK: break;
467 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
468 case OMP_TASK: pp_string (pp, "task:"); break;
469 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
470 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
471 case OMP_TARGET: pp_string (pp, "target:"); break;
472 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
473 case OMP_TARGET_ENTER_DATA:
474 pp_string (pp, "target enter data:"); break;
475 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
476 default: gcc_unreachable ();
478 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
479 spc, flags, false);
480 pp_right_paren (pp);
481 break;
483 case OMP_CLAUSE_NUM_THREADS:
484 pp_string (pp, "num_threads(");
485 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
486 spc, flags, false);
487 pp_right_paren (pp);
488 break;
490 case OMP_CLAUSE_NOWAIT:
491 pp_string (pp, "nowait");
492 break;
493 case OMP_CLAUSE_ORDERED:
494 pp_string (pp, "ordered");
495 if (OMP_CLAUSE_ORDERED_EXPR (clause))
497 pp_left_paren (pp);
498 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
499 spc, flags, false);
500 pp_right_paren (pp);
502 break;
504 case OMP_CLAUSE_DEFAULT:
505 pp_string (pp, "default(");
506 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
508 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
509 break;
510 case OMP_CLAUSE_DEFAULT_SHARED:
511 pp_string (pp, "shared");
512 break;
513 case OMP_CLAUSE_DEFAULT_NONE:
514 pp_string (pp, "none");
515 break;
516 case OMP_CLAUSE_DEFAULT_PRIVATE:
517 pp_string (pp, "private");
518 break;
519 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
520 pp_string (pp, "firstprivate");
521 break;
522 case OMP_CLAUSE_DEFAULT_PRESENT:
523 pp_string (pp, "present");
524 break;
525 default:
526 gcc_unreachable ();
528 pp_right_paren (pp);
529 break;
531 case OMP_CLAUSE_SCHEDULE:
532 pp_string (pp, "schedule(");
533 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
534 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
535 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
537 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
538 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
539 pp_string (pp, "monotonic");
540 else
541 pp_string (pp, "nonmonotonic");
542 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
543 pp_comma (pp);
544 else
545 pp_colon (pp);
547 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
548 pp_string (pp, "simd:");
550 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
552 case OMP_CLAUSE_SCHEDULE_STATIC:
553 pp_string (pp, "static");
554 break;
555 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
556 pp_string (pp, "dynamic");
557 break;
558 case OMP_CLAUSE_SCHEDULE_GUIDED:
559 pp_string (pp, "guided");
560 break;
561 case OMP_CLAUSE_SCHEDULE_RUNTIME:
562 pp_string (pp, "runtime");
563 break;
564 case OMP_CLAUSE_SCHEDULE_AUTO:
565 pp_string (pp, "auto");
566 break;
567 default:
568 gcc_unreachable ();
570 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
572 pp_comma (pp);
573 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
574 spc, flags, false);
576 pp_right_paren (pp);
577 break;
579 case OMP_CLAUSE_UNTIED:
580 pp_string (pp, "untied");
581 break;
583 case OMP_CLAUSE_COLLAPSE:
584 pp_string (pp, "collapse(");
585 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
586 spc, flags, false);
587 pp_right_paren (pp);
588 break;
590 case OMP_CLAUSE_FINAL:
591 pp_string (pp, "final(");
592 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
593 spc, flags, false);
594 pp_right_paren (pp);
595 break;
597 case OMP_CLAUSE_MERGEABLE:
598 pp_string (pp, "mergeable");
599 break;
601 case OMP_CLAUSE_LINEAR:
602 pp_string (pp, "linear(");
603 switch (OMP_CLAUSE_LINEAR_KIND (clause))
605 case OMP_CLAUSE_LINEAR_DEFAULT:
606 break;
607 case OMP_CLAUSE_LINEAR_REF:
608 pp_string (pp, "ref(");
609 break;
610 case OMP_CLAUSE_LINEAR_VAL:
611 pp_string (pp, "val(");
612 break;
613 case OMP_CLAUSE_LINEAR_UVAL:
614 pp_string (pp, "uval(");
615 break;
616 default:
617 gcc_unreachable ();
619 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
620 spc, flags, false);
621 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
622 pp_right_paren (pp);
623 pp_colon (pp);
624 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
625 spc, flags, false);
626 pp_right_paren (pp);
627 break;
629 case OMP_CLAUSE_ALIGNED:
630 pp_string (pp, "aligned(");
631 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
632 spc, flags, false);
633 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
635 pp_colon (pp);
636 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
637 spc, flags, false);
639 pp_right_paren (pp);
640 break;
642 case OMP_CLAUSE_DEPEND:
643 pp_string (pp, "depend(");
644 switch (OMP_CLAUSE_DEPEND_KIND (clause))
646 case OMP_CLAUSE_DEPEND_IN:
647 pp_string (pp, "in");
648 break;
649 case OMP_CLAUSE_DEPEND_OUT:
650 pp_string (pp, "out");
651 break;
652 case OMP_CLAUSE_DEPEND_INOUT:
653 pp_string (pp, "inout");
654 break;
655 case OMP_CLAUSE_DEPEND_SOURCE:
656 pp_string (pp, "source)");
657 return;
658 case OMP_CLAUSE_DEPEND_SINK:
659 pp_string (pp, "sink:");
660 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
661 if (TREE_CODE (t) == TREE_LIST)
663 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
664 if (TREE_PURPOSE (t) != integer_zero_node)
666 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
667 pp_minus (pp);
668 else
669 pp_plus (pp);
670 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
671 false);
673 if (TREE_CHAIN (t))
674 pp_comma (pp);
676 else
677 gcc_unreachable ();
678 pp_right_paren (pp);
679 return;
680 default:
681 gcc_unreachable ();
683 pp_colon (pp);
684 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
685 spc, flags, false);
686 pp_right_paren (pp);
687 break;
689 case OMP_CLAUSE_MAP:
690 pp_string (pp, "map(");
691 switch (OMP_CLAUSE_MAP_KIND (clause))
693 case GOMP_MAP_ALLOC:
694 case GOMP_MAP_POINTER:
695 pp_string (pp, "alloc");
696 break;
697 case GOMP_MAP_TO:
698 case GOMP_MAP_TO_PSET:
699 pp_string (pp, "to");
700 break;
701 case GOMP_MAP_FROM:
702 pp_string (pp, "from");
703 break;
704 case GOMP_MAP_TOFROM:
705 pp_string (pp, "tofrom");
706 break;
707 case GOMP_MAP_FORCE_ALLOC:
708 pp_string (pp, "force_alloc");
709 break;
710 case GOMP_MAP_FORCE_TO:
711 pp_string (pp, "force_to");
712 break;
713 case GOMP_MAP_FORCE_FROM:
714 pp_string (pp, "force_from");
715 break;
716 case GOMP_MAP_FORCE_TOFROM:
717 pp_string (pp, "force_tofrom");
718 break;
719 case GOMP_MAP_FORCE_PRESENT:
720 pp_string (pp, "force_present");
721 break;
722 case GOMP_MAP_DELETE:
723 pp_string (pp, "delete");
724 break;
725 case GOMP_MAP_FORCE_DEVICEPTR:
726 pp_string (pp, "force_deviceptr");
727 break;
728 case GOMP_MAP_ALWAYS_TO:
729 pp_string (pp, "always,to");
730 break;
731 case GOMP_MAP_ALWAYS_FROM:
732 pp_string (pp, "always,from");
733 break;
734 case GOMP_MAP_ALWAYS_TOFROM:
735 pp_string (pp, "always,tofrom");
736 break;
737 case GOMP_MAP_RELEASE:
738 pp_string (pp, "release");
739 break;
740 case GOMP_MAP_FIRSTPRIVATE_POINTER:
741 pp_string (pp, "firstprivate");
742 break;
743 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
744 pp_string (pp, "firstprivate ref");
745 break;
746 case GOMP_MAP_STRUCT:
747 pp_string (pp, "struct");
748 break;
749 case GOMP_MAP_ALWAYS_POINTER:
750 pp_string (pp, "always_pointer");
751 break;
752 case GOMP_MAP_DEVICE_RESIDENT:
753 pp_string (pp, "device_resident");
754 break;
755 case GOMP_MAP_LINK:
756 pp_string (pp, "link");
757 break;
758 default:
759 gcc_unreachable ();
761 pp_colon (pp);
762 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
763 spc, flags, false);
764 print_clause_size:
765 if (OMP_CLAUSE_SIZE (clause))
767 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
768 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
770 case GOMP_MAP_POINTER:
771 case GOMP_MAP_FIRSTPRIVATE_POINTER:
772 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
773 case GOMP_MAP_ALWAYS_POINTER:
774 pp_string (pp, " [pointer assign, bias: ");
775 break;
776 case GOMP_MAP_TO_PSET:
777 pp_string (pp, " [pointer set, len: ");
778 break;
779 default:
780 pp_string (pp, " [len: ");
781 break;
783 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
784 spc, flags, false);
785 pp_right_bracket (pp);
787 pp_right_paren (pp);
788 break;
790 case OMP_CLAUSE_FROM:
791 pp_string (pp, "from(");
792 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
793 spc, flags, false);
794 goto print_clause_size;
796 case OMP_CLAUSE_TO:
797 pp_string (pp, "to(");
798 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
799 spc, flags, false);
800 goto print_clause_size;
802 case OMP_CLAUSE__CACHE_:
803 pp_string (pp, "(");
804 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
805 spc, flags, false);
806 goto print_clause_size;
808 case OMP_CLAUSE_NUM_TEAMS:
809 pp_string (pp, "num_teams(");
810 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
811 spc, flags, false);
812 pp_right_paren (pp);
813 break;
815 case OMP_CLAUSE_THREAD_LIMIT:
816 pp_string (pp, "thread_limit(");
817 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
818 spc, flags, false);
819 pp_right_paren (pp);
820 break;
822 case OMP_CLAUSE_DEVICE:
823 pp_string (pp, "device(");
824 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
825 spc, flags, false);
826 pp_right_paren (pp);
827 break;
829 case OMP_CLAUSE_DIST_SCHEDULE:
830 pp_string (pp, "dist_schedule(static");
831 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
833 pp_comma (pp);
834 dump_generic_node (pp,
835 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
836 spc, flags, false);
838 pp_right_paren (pp);
839 break;
841 case OMP_CLAUSE_PROC_BIND:
842 pp_string (pp, "proc_bind(");
843 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
845 case OMP_CLAUSE_PROC_BIND_MASTER:
846 pp_string (pp, "master");
847 break;
848 case OMP_CLAUSE_PROC_BIND_CLOSE:
849 pp_string (pp, "close");
850 break;
851 case OMP_CLAUSE_PROC_BIND_SPREAD:
852 pp_string (pp, "spread");
853 break;
854 default:
855 gcc_unreachable ();
857 pp_right_paren (pp);
858 break;
860 case OMP_CLAUSE_SAFELEN:
861 pp_string (pp, "safelen(");
862 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
863 spc, flags, false);
864 pp_right_paren (pp);
865 break;
867 case OMP_CLAUSE_SIMDLEN:
868 pp_string (pp, "simdlen(");
869 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
870 spc, flags, false);
871 pp_right_paren (pp);
872 break;
874 case OMP_CLAUSE_PRIORITY:
875 pp_string (pp, "priority(");
876 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
877 spc, flags, false);
878 pp_right_paren (pp);
879 break;
881 case OMP_CLAUSE_GRAINSIZE:
882 pp_string (pp, "grainsize(");
883 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
884 spc, flags, false);
885 pp_right_paren (pp);
886 break;
888 case OMP_CLAUSE_NUM_TASKS:
889 pp_string (pp, "num_tasks(");
890 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
891 spc, flags, false);
892 pp_right_paren (pp);
893 break;
895 case OMP_CLAUSE_HINT:
896 pp_string (pp, "hint(");
897 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
898 spc, flags, false);
899 pp_right_paren (pp);
900 break;
902 case OMP_CLAUSE_DEFAULTMAP:
903 pp_string (pp, "defaultmap(tofrom:scalar)");
904 break;
906 case OMP_CLAUSE__SIMDUID_:
907 pp_string (pp, "_simduid_(");
908 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
909 spc, flags, false);
910 pp_right_paren (pp);
911 break;
913 case OMP_CLAUSE__SIMT_:
914 pp_string (pp, "_simt_");
915 break;
917 case OMP_CLAUSE_GANG:
918 pp_string (pp, "gang");
919 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
921 pp_string (pp, "(num: ");
922 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
923 spc, flags, false);
925 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
927 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
928 pp_left_paren (pp);
929 else
930 pp_space (pp);
931 pp_string (pp, "static:");
932 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
933 == integer_minus_one_node)
934 pp_character (pp, '*');
935 else
936 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
937 spc, flags, false);
939 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
940 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
941 pp_right_paren (pp);
942 break;
944 case OMP_CLAUSE_ASYNC:
945 pp_string (pp, "async");
946 if (OMP_CLAUSE_ASYNC_EXPR (clause))
948 pp_character(pp, '(');
949 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
950 spc, flags, false);
951 pp_character(pp, ')');
953 break;
955 case OMP_CLAUSE_AUTO:
956 case OMP_CLAUSE_SEQ:
957 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
958 break;
960 case OMP_CLAUSE_WAIT:
961 pp_string (pp, "wait(");
962 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
963 spc, flags, false);
964 pp_character(pp, ')');
965 break;
967 case OMP_CLAUSE_WORKER:
968 pp_string (pp, "worker");
969 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
971 pp_left_paren (pp);
972 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
973 spc, flags, false);
974 pp_right_paren (pp);
976 break;
978 case OMP_CLAUSE_VECTOR:
979 pp_string (pp, "vector");
980 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
982 pp_left_paren (pp);
983 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
984 spc, flags, false);
985 pp_right_paren (pp);
987 break;
989 case OMP_CLAUSE_NUM_GANGS:
990 pp_string (pp, "num_gangs(");
991 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
992 spc, flags, false);
993 pp_character (pp, ')');
994 break;
996 case OMP_CLAUSE_NUM_WORKERS:
997 pp_string (pp, "num_workers(");
998 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
999 spc, flags, false);
1000 pp_character (pp, ')');
1001 break;
1003 case OMP_CLAUSE_VECTOR_LENGTH:
1004 pp_string (pp, "vector_length(");
1005 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1006 spc, flags, false);
1007 pp_character (pp, ')');
1008 break;
1010 case OMP_CLAUSE_INBRANCH:
1011 pp_string (pp, "inbranch");
1012 break;
1013 case OMP_CLAUSE_NOTINBRANCH:
1014 pp_string (pp, "notinbranch");
1015 break;
1016 case OMP_CLAUSE_FOR:
1017 pp_string (pp, "for");
1018 break;
1019 case OMP_CLAUSE_PARALLEL:
1020 pp_string (pp, "parallel");
1021 break;
1022 case OMP_CLAUSE_SECTIONS:
1023 pp_string (pp, "sections");
1024 break;
1025 case OMP_CLAUSE_TASKGROUP:
1026 pp_string (pp, "taskgroup");
1027 break;
1028 case OMP_CLAUSE_NOGROUP:
1029 pp_string (pp, "nogroup");
1030 break;
1031 case OMP_CLAUSE_THREADS:
1032 pp_string (pp, "threads");
1033 break;
1034 case OMP_CLAUSE_SIMD:
1035 pp_string (pp, "simd");
1036 break;
1037 case OMP_CLAUSE_INDEPENDENT:
1038 pp_string (pp, "independent");
1039 break;
1040 case OMP_CLAUSE_TILE:
1041 pp_string (pp, "tile(");
1042 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1043 spc, flags, false);
1044 pp_right_paren (pp);
1045 break;
1047 case OMP_CLAUSE__GRIDDIM_:
1048 pp_string (pp, "_griddim_(");
1049 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1050 pp_colon (pp);
1051 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1052 false);
1053 pp_comma (pp);
1054 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1055 false);
1056 pp_right_paren (pp);
1057 break;
1058 case OMP_CLAUSE_IF_PRESENT:
1059 pp_string (pp, "if_present");
1060 break;
1061 case OMP_CLAUSE_FINALIZE:
1062 pp_string (pp, "finalize");
1063 break;
1065 default:
1066 /* Should never happen. */
1067 dump_generic_node (pp, clause, spc, flags, false);
1068 break;
1073 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1074 dump_generic_node. */
1076 void
1077 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1079 if (clause == NULL)
1080 return;
1082 pp_space (pp);
1083 while (1)
1085 dump_omp_clause (pp, clause, spc, flags);
1086 clause = OMP_CLAUSE_CHAIN (clause);
1087 if (clause == NULL)
1088 return;
1089 pp_space (pp);
1094 /* Dump location LOC to PP. */
1096 void
1097 dump_location (pretty_printer *pp, location_t loc)
1099 expanded_location xloc = expand_location (loc);
1101 pp_left_bracket (pp);
1102 if (xloc.file)
1104 pp_string (pp, xloc.file);
1105 pp_string (pp, ":");
1107 pp_decimal_int (pp, xloc.line);
1108 pp_colon (pp);
1109 pp_decimal_int (pp, xloc.column);
1110 pp_string (pp, "] ");
1114 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1115 dump_generic_node. */
1117 static void
1118 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1120 tree t;
1122 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1124 if (flags & TDF_ADDRESS)
1125 pp_printf (pp, "[%p] ", (void *) block);
1127 if (TREE_ASM_WRITTEN (block))
1128 pp_string (pp, "[written] ");
1130 if (flags & TDF_SLIM)
1131 return;
1133 if (BLOCK_SOURCE_LOCATION (block))
1134 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1136 newline_and_indent (pp, spc + 2);
1138 if (BLOCK_SUPERCONTEXT (block))
1140 pp_string (pp, "SUPERCONTEXT: ");
1141 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1142 flags | TDF_SLIM, false);
1143 newline_and_indent (pp, spc + 2);
1146 if (BLOCK_SUBBLOCKS (block))
1148 pp_string (pp, "SUBBLOCKS: ");
1149 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1151 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1152 pp_space (pp);
1154 newline_and_indent (pp, spc + 2);
1157 if (BLOCK_CHAIN (block))
1159 pp_string (pp, "SIBLINGS: ");
1160 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1162 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1163 pp_space (pp);
1165 newline_and_indent (pp, spc + 2);
1168 if (BLOCK_VARS (block))
1170 pp_string (pp, "VARS: ");
1171 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1173 dump_generic_node (pp, t, 0, flags, false);
1174 pp_space (pp);
1176 newline_and_indent (pp, spc + 2);
1179 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1181 unsigned i;
1182 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1184 pp_string (pp, "NONLOCALIZED_VARS: ");
1185 FOR_EACH_VEC_ELT (*nlv, i, t)
1187 dump_generic_node (pp, t, 0, flags, false);
1188 pp_space (pp);
1190 newline_and_indent (pp, spc + 2);
1193 if (BLOCK_ABSTRACT_ORIGIN (block))
1195 pp_string (pp, "ABSTRACT_ORIGIN: ");
1196 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1197 flags | TDF_SLIM, false);
1198 newline_and_indent (pp, spc + 2);
1201 if (BLOCK_FRAGMENT_ORIGIN (block))
1203 pp_string (pp, "FRAGMENT_ORIGIN: ");
1204 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1205 flags | TDF_SLIM, false);
1206 newline_and_indent (pp, spc + 2);
1209 if (BLOCK_FRAGMENT_CHAIN (block))
1211 pp_string (pp, "FRAGMENT_CHAIN: ");
1212 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1214 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1215 pp_space (pp);
1217 newline_and_indent (pp, spc + 2);
1222 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1223 indent. FLAGS specifies details to show in the dump (see TDF_* in
1224 dumpfile.h). If IS_STMT is true, the object printed is considered
1225 to be a statement and it is terminated by ';' if appropriate. */
1228 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1229 bool is_stmt)
1231 tree type;
1232 tree op0, op1;
1233 const char *str;
1234 bool is_expr;
1235 enum tree_code code;
1237 if (node == NULL_TREE)
1238 return spc;
1240 is_expr = EXPR_P (node);
1242 if (is_stmt && (flags & TDF_STMTADDR))
1243 pp_printf (pp, "<&%p> ", (void *)node);
1245 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1246 dump_location (pp, EXPR_LOCATION (node));
1248 code = TREE_CODE (node);
1249 switch (code)
1251 case ERROR_MARK:
1252 pp_string (pp, "<<< error >>>");
1253 break;
1255 case IDENTIFIER_NODE:
1256 pp_tree_identifier (pp, node);
1257 break;
1259 case TREE_LIST:
1260 while (node && node != error_mark_node)
1262 if (TREE_PURPOSE (node))
1264 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1265 pp_space (pp);
1267 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1268 node = TREE_CHAIN (node);
1269 if (node && TREE_CODE (node) == TREE_LIST)
1271 pp_comma (pp);
1272 pp_space (pp);
1275 break;
1277 case TREE_BINFO:
1278 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1279 break;
1281 case TREE_VEC:
1283 size_t i;
1284 if (TREE_VEC_LENGTH (node) > 0)
1286 size_t len = TREE_VEC_LENGTH (node);
1287 for (i = 0; i < len - 1; i++)
1289 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1290 false);
1291 pp_comma (pp);
1292 pp_space (pp);
1294 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1295 flags, false);
1298 break;
1300 case VOID_TYPE:
1301 case INTEGER_TYPE:
1302 case REAL_TYPE:
1303 case FIXED_POINT_TYPE:
1304 case COMPLEX_TYPE:
1305 case VECTOR_TYPE:
1306 case ENUMERAL_TYPE:
1307 case BOOLEAN_TYPE:
1309 unsigned int quals = TYPE_QUALS (node);
1310 enum tree_code_class tclass;
1312 if (quals & TYPE_QUAL_ATOMIC)
1313 pp_string (pp, "atomic ");
1314 if (quals & TYPE_QUAL_CONST)
1315 pp_string (pp, "const ");
1316 else if (quals & TYPE_QUAL_VOLATILE)
1317 pp_string (pp, "volatile ");
1318 else if (quals & TYPE_QUAL_RESTRICT)
1319 pp_string (pp, "restrict ");
1321 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1323 pp_string (pp, "<address-space-");
1324 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1325 pp_string (pp, "> ");
1328 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1330 if (tclass == tcc_declaration)
1332 if (DECL_NAME (node))
1333 dump_decl_name (pp, node, flags);
1334 else
1335 pp_string (pp, "<unnamed type decl>");
1337 else if (tclass == tcc_type)
1339 if (TYPE_NAME (node))
1341 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1342 pp_tree_identifier (pp, TYPE_NAME (node));
1343 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1344 && DECL_NAME (TYPE_NAME (node)))
1345 dump_decl_name (pp, TYPE_NAME (node), flags);
1346 else
1347 pp_string (pp, "<unnamed type>");
1349 else if (TREE_CODE (node) == VECTOR_TYPE)
1351 pp_string (pp, "vector");
1352 pp_left_paren (pp);
1353 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1354 pp_string (pp, ") ");
1355 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1357 else if (TREE_CODE (node) == INTEGER_TYPE)
1359 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1360 pp_string (pp, (TYPE_UNSIGNED (node)
1361 ? "unsigned char"
1362 : "signed char"));
1363 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1364 pp_string (pp, (TYPE_UNSIGNED (node)
1365 ? "unsigned short"
1366 : "signed short"));
1367 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1368 pp_string (pp, (TYPE_UNSIGNED (node)
1369 ? "unsigned int"
1370 : "signed int"));
1371 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1372 pp_string (pp, (TYPE_UNSIGNED (node)
1373 ? "unsigned long"
1374 : "signed long"));
1375 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1376 pp_string (pp, (TYPE_UNSIGNED (node)
1377 ? "unsigned long long"
1378 : "signed long long"));
1379 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1380 && pow2p_hwi (TYPE_PRECISION (node)))
1382 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1383 pp_decimal_int (pp, TYPE_PRECISION (node));
1384 pp_string (pp, "_t");
1386 else
1388 pp_string (pp, (TYPE_UNSIGNED (node)
1389 ? "<unnamed-unsigned:"
1390 : "<unnamed-signed:"));
1391 pp_decimal_int (pp, TYPE_PRECISION (node));
1392 pp_greater (pp);
1395 else if (TREE_CODE (node) == COMPLEX_TYPE)
1397 pp_string (pp, "__complex__ ");
1398 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1400 else if (TREE_CODE (node) == REAL_TYPE)
1402 pp_string (pp, "<float:");
1403 pp_decimal_int (pp, TYPE_PRECISION (node));
1404 pp_greater (pp);
1406 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1408 pp_string (pp, "<fixed-point-");
1409 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1410 pp_decimal_int (pp, TYPE_PRECISION (node));
1411 pp_greater (pp);
1413 else if (TREE_CODE (node) == VOID_TYPE)
1414 pp_string (pp, "void");
1415 else
1416 pp_string (pp, "<unnamed type>");
1418 break;
1421 case POINTER_TYPE:
1422 case REFERENCE_TYPE:
1423 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1425 if (TREE_TYPE (node) == NULL)
1427 pp_string (pp, str);
1428 pp_string (pp, "<null type>");
1430 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1432 tree fnode = TREE_TYPE (node);
1434 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1435 pp_space (pp);
1436 pp_left_paren (pp);
1437 pp_string (pp, str);
1438 if (TYPE_IDENTIFIER (node))
1439 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1440 else if (flags & TDF_NOUID)
1441 pp_printf (pp, "<Txxxx>");
1442 else
1443 pp_printf (pp, "<T%x>", TYPE_UID (node));
1445 pp_right_paren (pp);
1446 dump_function_declaration (pp, fnode, spc, flags);
1448 else
1450 unsigned int quals = TYPE_QUALS (node);
1452 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1453 pp_space (pp);
1454 pp_string (pp, str);
1456 if (quals & TYPE_QUAL_CONST)
1457 pp_string (pp, " const");
1458 if (quals & TYPE_QUAL_VOLATILE)
1459 pp_string (pp, " volatile");
1460 if (quals & TYPE_QUAL_RESTRICT)
1461 pp_string (pp, " restrict");
1463 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1465 pp_string (pp, " <address-space-");
1466 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1467 pp_greater (pp);
1470 if (TYPE_REF_CAN_ALIAS_ALL (node))
1471 pp_string (pp, " {ref-all}");
1473 break;
1475 case OFFSET_TYPE:
1476 NIY;
1477 break;
1479 case MEM_REF:
1481 if (flags & TDF_GIMPLE)
1483 pp_string (pp, "__MEM <");
1484 dump_generic_node (pp, TREE_TYPE (node),
1485 spc, flags | TDF_SLIM, false);
1486 if (TYPE_ALIGN (TREE_TYPE (node))
1487 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1489 pp_string (pp, ", ");
1490 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1492 pp_greater (pp);
1493 pp_string (pp, " (");
1494 if (TREE_TYPE (TREE_OPERAND (node, 0))
1495 != TREE_TYPE (TREE_OPERAND (node, 1)))
1497 pp_left_paren (pp);
1498 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1499 spc, flags | TDF_SLIM, false);
1500 pp_right_paren (pp);
1502 dump_generic_node (pp, TREE_OPERAND (node, 0),
1503 spc, flags | TDF_SLIM, false);
1504 if (! integer_zerop (TREE_OPERAND (node, 1)))
1506 pp_string (pp, " + ");
1507 dump_generic_node (pp, TREE_OPERAND (node, 1),
1508 spc, flags | TDF_SLIM, false);
1510 pp_right_paren (pp);
1512 else if (integer_zerop (TREE_OPERAND (node, 1))
1513 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1514 infer them and MEM_ATTR caching will share MEM_REFs
1515 with differently-typed op0s. */
1516 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1517 /* Released SSA_NAMES have no TREE_TYPE. */
1518 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1519 /* Same pointer types, but ignoring POINTER_TYPE vs.
1520 REFERENCE_TYPE. */
1521 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1522 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1523 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1524 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1525 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1526 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1527 /* Same value types ignoring qualifiers. */
1528 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1529 == TYPE_MAIN_VARIANT
1530 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1531 && (!(flags & TDF_ALIAS)
1532 || MR_DEPENDENCE_CLIQUE (node) == 0))
1534 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1536 pp_star (pp);
1537 dump_generic_node (pp, TREE_OPERAND (node, 0),
1538 spc, flags, false);
1540 else
1541 dump_generic_node (pp,
1542 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1543 spc, flags, false);
1545 else
1547 tree ptype;
1549 pp_string (pp, "MEM[");
1550 pp_left_paren (pp);
1551 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1552 dump_generic_node (pp, ptype,
1553 spc, flags | TDF_SLIM, false);
1554 pp_right_paren (pp);
1555 dump_generic_node (pp, TREE_OPERAND (node, 0),
1556 spc, flags, false);
1557 if (!integer_zerop (TREE_OPERAND (node, 1)))
1559 pp_string (pp, " + ");
1560 dump_generic_node (pp, TREE_OPERAND (node, 1),
1561 spc, flags, false);
1563 if ((flags & TDF_ALIAS)
1564 && MR_DEPENDENCE_CLIQUE (node) != 0)
1566 pp_string (pp, " clique ");
1567 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1568 pp_string (pp, " base ");
1569 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1571 pp_right_bracket (pp);
1573 break;
1576 case TARGET_MEM_REF:
1578 const char *sep = "";
1579 tree tmp;
1581 pp_string (pp, "MEM[");
1583 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1585 pp_string (pp, sep);
1586 sep = ", ";
1587 pp_string (pp, "symbol: ");
1588 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1589 spc, flags, false);
1591 else
1593 pp_string (pp, sep);
1594 sep = ", ";
1595 pp_string (pp, "base: ");
1596 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1598 tmp = TMR_INDEX2 (node);
1599 if (tmp)
1601 pp_string (pp, sep);
1602 sep = ", ";
1603 pp_string (pp, "base: ");
1604 dump_generic_node (pp, tmp, spc, flags, false);
1606 tmp = TMR_INDEX (node);
1607 if (tmp)
1609 pp_string (pp, sep);
1610 sep = ", ";
1611 pp_string (pp, "index: ");
1612 dump_generic_node (pp, tmp, spc, flags, false);
1614 tmp = TMR_STEP (node);
1615 if (tmp)
1617 pp_string (pp, sep);
1618 sep = ", ";
1619 pp_string (pp, "step: ");
1620 dump_generic_node (pp, tmp, spc, flags, false);
1622 tmp = TMR_OFFSET (node);
1623 if (tmp)
1625 pp_string (pp, sep);
1626 sep = ", ";
1627 pp_string (pp, "offset: ");
1628 dump_generic_node (pp, tmp, spc, flags, false);
1630 pp_right_bracket (pp);
1632 break;
1634 case ARRAY_TYPE:
1636 tree tmp;
1638 /* Print the innermost component type. */
1639 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1640 tmp = TREE_TYPE (tmp))
1642 dump_generic_node (pp, tmp, spc, flags, false);
1644 /* Print the dimensions. */
1645 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1646 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1647 break;
1650 case RECORD_TYPE:
1651 case UNION_TYPE:
1652 case QUAL_UNION_TYPE:
1654 unsigned int quals = TYPE_QUALS (node);
1656 if (quals & TYPE_QUAL_ATOMIC)
1657 pp_string (pp, "atomic ");
1658 if (quals & TYPE_QUAL_CONST)
1659 pp_string (pp, "const ");
1660 if (quals & TYPE_QUAL_VOLATILE)
1661 pp_string (pp, "volatile ");
1663 /* Print the name of the structure. */
1664 if (TREE_CODE (node) == RECORD_TYPE)
1665 pp_string (pp, "struct ");
1666 else if (TREE_CODE (node) == UNION_TYPE)
1667 pp_string (pp, "union ");
1669 if (TYPE_NAME (node))
1670 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1671 else if (!(flags & TDF_SLIM))
1672 /* FIXME: If we eliminate the 'else' above and attempt
1673 to show the fields for named types, we may get stuck
1674 following a cycle of pointers to structs. The alleged
1675 self-reference check in print_struct_decl will not detect
1676 cycles involving more than one pointer or struct type. */
1677 print_struct_decl (pp, node, spc, flags);
1678 break;
1681 case LANG_TYPE:
1682 NIY;
1683 break;
1685 case INTEGER_CST:
1686 if (flags & TDF_GIMPLE
1687 && (POINTER_TYPE_P (TREE_TYPE (node))
1688 || (TYPE_PRECISION (TREE_TYPE (node))
1689 < TYPE_PRECISION (integer_type_node))
1690 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1692 pp_string (pp, "_Literal (");
1693 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1694 pp_string (pp, ") ");
1696 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1697 && ! (flags & TDF_GIMPLE))
1699 /* In the case of a pointer, one may want to divide by the
1700 size of the pointed-to type. Unfortunately, this not
1701 straightforward. The C front-end maps expressions
1703 (int *) 5
1704 int *p; (p + 5)
1706 in such a way that the two INTEGER_CST nodes for "5" have
1707 different values but identical types. In the latter
1708 case, the 5 is multiplied by sizeof (int) in c-common.c
1709 (pointer_int_sum) to convert it to a byte address, and
1710 yet the type of the node is left unchanged. Argh. What
1711 is consistent though is that the number value corresponds
1712 to bytes (UNITS) offset.
1714 NB: Neither of the following divisors can be trivially
1715 used to recover the original literal:
1717 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1718 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1719 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1720 pp_string (pp, "B"); /* pseudo-unit */
1722 else if (tree_fits_shwi_p (node))
1723 pp_wide_integer (pp, tree_to_shwi (node));
1724 else if (tree_fits_uhwi_p (node))
1725 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1726 else
1728 wide_int val = wi::to_wide (node);
1730 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1732 pp_minus (pp);
1733 val = -val;
1735 print_hex (val, pp_buffer (pp)->digit_buffer);
1736 pp_string (pp, pp_buffer (pp)->digit_buffer);
1738 if ((flags & TDF_GIMPLE)
1739 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1740 || (TYPE_PRECISION (TREE_TYPE (node))
1741 < TYPE_PRECISION (integer_type_node))
1742 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1744 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1745 pp_character (pp, 'u');
1746 if (TYPE_PRECISION (TREE_TYPE (node))
1747 == TYPE_PRECISION (unsigned_type_node))
1749 else if (TYPE_PRECISION (TREE_TYPE (node))
1750 == TYPE_PRECISION (long_unsigned_type_node))
1751 pp_character (pp, 'l');
1752 else if (TYPE_PRECISION (TREE_TYPE (node))
1753 == TYPE_PRECISION (long_long_unsigned_type_node))
1754 pp_string (pp, "ll");
1756 if (TREE_OVERFLOW (node))
1757 pp_string (pp, "(OVF)");
1758 break;
1760 case POLY_INT_CST:
1761 pp_string (pp, "POLY_INT_CST [");
1762 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
1763 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
1765 pp_string (pp, ", ");
1766 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
1767 spc, flags, false);
1769 pp_string (pp, "]");
1770 break;
1772 case REAL_CST:
1773 /* Code copied from print_node. */
1775 REAL_VALUE_TYPE d;
1776 if (TREE_OVERFLOW (node))
1777 pp_string (pp, " overflow");
1779 d = TREE_REAL_CST (node);
1780 if (REAL_VALUE_ISINF (d))
1781 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1782 else if (REAL_VALUE_ISNAN (d))
1783 pp_string (pp, " Nan");
1784 else
1786 char string[100];
1787 real_to_decimal (string, &d, sizeof (string), 0, 1);
1788 pp_string (pp, string);
1790 break;
1793 case FIXED_CST:
1795 char string[100];
1796 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1797 pp_string (pp, string);
1798 break;
1801 case COMPLEX_CST:
1802 pp_string (pp, "__complex__ (");
1803 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1804 pp_string (pp, ", ");
1805 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1806 pp_right_paren (pp);
1807 break;
1809 case STRING_CST:
1811 pp_string (pp, "\"");
1812 if (unsigned nbytes = TREE_STRING_LENGTH (node))
1813 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
1814 pp_string (pp, "\"");
1815 break;
1818 case VECTOR_CST:
1820 unsigned i;
1821 pp_string (pp, "{ ");
1822 unsigned HOST_WIDE_INT nunits;
1823 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
1824 nunits = vector_cst_encoded_nelts (node);
1825 for (i = 0; i < nunits; ++i)
1827 if (i != 0)
1828 pp_string (pp, ", ");
1829 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1830 spc, flags, false);
1832 if (!VECTOR_CST_NELTS (node).is_constant ())
1833 pp_string (pp, ", ...");
1834 pp_string (pp, " }");
1836 break;
1838 case FUNCTION_TYPE:
1839 case METHOD_TYPE:
1840 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1841 pp_space (pp);
1842 if (TREE_CODE (node) == METHOD_TYPE)
1844 if (TYPE_METHOD_BASETYPE (node))
1845 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1846 spc, flags, false);
1847 else
1848 pp_string (pp, "<null method basetype>");
1849 pp_colon_colon (pp);
1851 if (TYPE_IDENTIFIER (node))
1852 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1853 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1854 dump_decl_name (pp, TYPE_NAME (node), flags);
1855 else if (flags & TDF_NOUID)
1856 pp_printf (pp, "<Txxxx>");
1857 else
1858 pp_printf (pp, "<T%x>", TYPE_UID (node));
1859 dump_function_declaration (pp, node, spc, flags);
1860 break;
1862 case FUNCTION_DECL:
1863 case CONST_DECL:
1864 dump_decl_name (pp, node, flags);
1865 break;
1867 case LABEL_DECL:
1868 if (DECL_NAME (node))
1869 dump_decl_name (pp, node, flags);
1870 else if (LABEL_DECL_UID (node) != -1)
1872 if (flags & TDF_GIMPLE)
1873 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1874 else
1875 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1877 else
1879 if (flags & TDF_NOUID)
1880 pp_string (pp, "<D.xxxx>");
1881 else
1883 if (flags & TDF_GIMPLE)
1884 pp_printf (pp, "<D%u>", DECL_UID (node));
1885 else
1886 pp_printf (pp, "<D.%u>", DECL_UID (node));
1889 break;
1891 case TYPE_DECL:
1892 if (DECL_IS_BUILTIN (node))
1894 /* Don't print the declaration of built-in types. */
1895 break;
1897 if (DECL_NAME (node))
1898 dump_decl_name (pp, node, flags);
1899 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1901 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1902 ? "union" : "struct "));
1903 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1905 else
1906 pp_string (pp, "<anon>");
1907 break;
1909 case VAR_DECL:
1910 case PARM_DECL:
1911 case FIELD_DECL:
1912 case DEBUG_EXPR_DECL:
1913 case NAMESPACE_DECL:
1914 case NAMELIST_DECL:
1915 dump_decl_name (pp, node, flags);
1916 break;
1918 case RESULT_DECL:
1919 pp_string (pp, "<retval>");
1920 break;
1922 case COMPONENT_REF:
1923 op0 = TREE_OPERAND (node, 0);
1924 str = ".";
1925 if (op0
1926 && (TREE_CODE (op0) == INDIRECT_REF
1927 || (TREE_CODE (op0) == MEM_REF
1928 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1929 && integer_zerop (TREE_OPERAND (op0, 1))
1930 /* Dump the types of INTEGER_CSTs explicitly, for we
1931 can't infer them and MEM_ATTR caching will share
1932 MEM_REFs with differently-typed op0s. */
1933 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1934 /* Released SSA_NAMES have no TREE_TYPE. */
1935 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1936 /* Same pointer types, but ignoring POINTER_TYPE vs.
1937 REFERENCE_TYPE. */
1938 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1939 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1940 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1941 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1942 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1943 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1944 /* Same value types ignoring qualifiers. */
1945 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1946 == TYPE_MAIN_VARIANT
1947 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1948 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1950 op0 = TREE_OPERAND (op0, 0);
1951 str = "->";
1953 if (op_prio (op0) < op_prio (node))
1954 pp_left_paren (pp);
1955 dump_generic_node (pp, op0, spc, flags, false);
1956 if (op_prio (op0) < op_prio (node))
1957 pp_right_paren (pp);
1958 pp_string (pp, str);
1959 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1960 op0 = component_ref_field_offset (node);
1961 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1963 pp_string (pp, "{off: ");
1964 dump_generic_node (pp, op0, spc, flags, false);
1965 pp_right_brace (pp);
1967 break;
1969 case BIT_FIELD_REF:
1970 pp_string (pp, "BIT_FIELD_REF <");
1971 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1972 pp_string (pp, ", ");
1973 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1974 pp_string (pp, ", ");
1975 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1976 pp_greater (pp);
1977 break;
1979 case BIT_INSERT_EXPR:
1980 pp_string (pp, "BIT_INSERT_EXPR <");
1981 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1982 pp_string (pp, ", ");
1983 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1984 pp_string (pp, ", ");
1985 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1986 pp_string (pp, " (");
1987 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1988 pp_decimal_int (pp,
1989 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1990 else
1991 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1992 spc, flags, false);
1993 pp_string (pp, " bits)>");
1994 break;
1996 case ARRAY_REF:
1997 case ARRAY_RANGE_REF:
1998 op0 = TREE_OPERAND (node, 0);
1999 if (op_prio (op0) < op_prio (node))
2000 pp_left_paren (pp);
2001 dump_generic_node (pp, op0, spc, flags, false);
2002 if (op_prio (op0) < op_prio (node))
2003 pp_right_paren (pp);
2004 pp_left_bracket (pp);
2005 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2006 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2007 pp_string (pp, " ...");
2008 pp_right_bracket (pp);
2010 op0 = array_ref_low_bound (node);
2011 op1 = array_ref_element_size (node);
2013 if (!integer_zerop (op0)
2014 || TREE_OPERAND (node, 2)
2015 || TREE_OPERAND (node, 3))
2017 pp_string (pp, "{lb: ");
2018 dump_generic_node (pp, op0, spc, flags, false);
2019 pp_string (pp, " sz: ");
2020 dump_generic_node (pp, op1, spc, flags, false);
2021 pp_right_brace (pp);
2023 break;
2025 case CONSTRUCTOR:
2027 unsigned HOST_WIDE_INT ix;
2028 tree field, val;
2029 bool is_struct_init = false;
2030 bool is_array_init = false;
2031 widest_int curidx;
2032 pp_left_brace (pp);
2033 if (TREE_CLOBBER_P (node))
2034 pp_string (pp, "CLOBBER");
2035 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2036 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2037 is_struct_init = true;
2038 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2039 && TYPE_DOMAIN (TREE_TYPE (node))
2040 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2041 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2042 == INTEGER_CST)
2044 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2045 is_array_init = true;
2046 curidx = wi::to_widest (minv);
2048 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2050 if (field)
2052 if (is_struct_init)
2054 pp_dot (pp);
2055 dump_generic_node (pp, field, spc, flags, false);
2056 pp_equal (pp);
2058 else if (is_array_init
2059 && (TREE_CODE (field) != INTEGER_CST
2060 || curidx != wi::to_widest (field)))
2062 pp_left_bracket (pp);
2063 if (TREE_CODE (field) == RANGE_EXPR)
2065 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2066 flags, false);
2067 pp_string (pp, " ... ");
2068 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2069 flags, false);
2070 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2071 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2073 else
2074 dump_generic_node (pp, field, spc, flags, false);
2075 if (TREE_CODE (field) == INTEGER_CST)
2076 curidx = wi::to_widest (field);
2077 pp_string (pp, "]=");
2080 if (is_array_init)
2081 curidx += 1;
2082 if (val && TREE_CODE (val) == ADDR_EXPR)
2083 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2084 val = TREE_OPERAND (val, 0);
2085 if (val && TREE_CODE (val) == FUNCTION_DECL)
2086 dump_decl_name (pp, val, flags);
2087 else
2088 dump_generic_node (pp, val, spc, flags, false);
2089 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2091 pp_comma (pp);
2092 pp_space (pp);
2095 pp_right_brace (pp);
2097 break;
2099 case COMPOUND_EXPR:
2101 tree *tp;
2102 if (flags & TDF_SLIM)
2104 pp_string (pp, "<COMPOUND_EXPR>");
2105 break;
2108 dump_generic_node (pp, TREE_OPERAND (node, 0),
2109 spc, flags, !(flags & TDF_SLIM));
2110 if (flags & TDF_SLIM)
2111 newline_and_indent (pp, spc);
2112 else
2114 pp_comma (pp);
2115 pp_space (pp);
2118 for (tp = &TREE_OPERAND (node, 1);
2119 TREE_CODE (*tp) == COMPOUND_EXPR;
2120 tp = &TREE_OPERAND (*tp, 1))
2122 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2123 spc, flags, !(flags & TDF_SLIM));
2124 if (flags & TDF_SLIM)
2125 newline_and_indent (pp, spc);
2126 else
2128 pp_comma (pp);
2129 pp_space (pp);
2133 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2135 break;
2137 case STATEMENT_LIST:
2139 tree_stmt_iterator si;
2140 bool first = true;
2142 if (flags & TDF_SLIM)
2144 pp_string (pp, "<STATEMENT_LIST>");
2145 break;
2148 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2150 if (!first)
2151 newline_and_indent (pp, spc);
2152 else
2153 first = false;
2154 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2157 break;
2159 case MODIFY_EXPR:
2160 case INIT_EXPR:
2161 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2162 false);
2163 pp_space (pp);
2164 pp_equal (pp);
2165 pp_space (pp);
2166 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2167 false);
2168 break;
2170 case TARGET_EXPR:
2171 pp_string (pp, "TARGET_EXPR <");
2172 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2173 pp_comma (pp);
2174 pp_space (pp);
2175 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2176 pp_greater (pp);
2177 break;
2179 case DECL_EXPR:
2180 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2181 is_stmt = false;
2182 break;
2184 case COND_EXPR:
2185 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2187 pp_string (pp, "if (");
2188 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2189 pp_right_paren (pp);
2190 /* The lowered cond_exprs should always be printed in full. */
2191 if (COND_EXPR_THEN (node)
2192 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2193 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2194 && COND_EXPR_ELSE (node)
2195 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2196 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2198 pp_space (pp);
2199 dump_generic_node (pp, COND_EXPR_THEN (node),
2200 0, flags, true);
2201 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2203 pp_string (pp, " else ");
2204 dump_generic_node (pp, COND_EXPR_ELSE (node),
2205 0, flags, true);
2208 else if (!(flags & TDF_SLIM))
2210 /* Output COND_EXPR_THEN. */
2211 if (COND_EXPR_THEN (node))
2213 newline_and_indent (pp, spc+2);
2214 pp_left_brace (pp);
2215 newline_and_indent (pp, spc+4);
2216 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2217 flags, true);
2218 newline_and_indent (pp, spc+2);
2219 pp_right_brace (pp);
2222 /* Output COND_EXPR_ELSE. */
2223 if (COND_EXPR_ELSE (node)
2224 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2226 newline_and_indent (pp, spc);
2227 pp_string (pp, "else");
2228 newline_and_indent (pp, spc+2);
2229 pp_left_brace (pp);
2230 newline_and_indent (pp, spc+4);
2231 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2232 flags, true);
2233 newline_and_indent (pp, spc+2);
2234 pp_right_brace (pp);
2237 is_expr = false;
2239 else
2241 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2242 pp_space (pp);
2243 pp_question (pp);
2244 pp_space (pp);
2245 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2246 pp_space (pp);
2247 pp_colon (pp);
2248 pp_space (pp);
2249 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2251 break;
2253 case BIND_EXPR:
2254 pp_left_brace (pp);
2255 if (!(flags & TDF_SLIM))
2257 if (BIND_EXPR_VARS (node))
2259 pp_newline (pp);
2261 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2263 print_declaration (pp, op0, spc+2, flags);
2264 pp_newline (pp);
2268 newline_and_indent (pp, spc+2);
2269 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2270 newline_and_indent (pp, spc);
2271 pp_right_brace (pp);
2273 is_expr = false;
2274 break;
2276 case CALL_EXPR:
2277 if (CALL_EXPR_FN (node) != NULL_TREE)
2278 print_call_name (pp, CALL_EXPR_FN (node), flags);
2279 else
2281 pp_dot (pp);
2282 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2285 /* Print parameters. */
2286 pp_space (pp);
2287 pp_left_paren (pp);
2289 tree arg;
2290 call_expr_arg_iterator iter;
2291 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2293 dump_generic_node (pp, arg, spc, flags, false);
2294 if (more_call_expr_args_p (&iter))
2296 pp_comma (pp);
2297 pp_space (pp);
2301 if (CALL_EXPR_VA_ARG_PACK (node))
2303 if (call_expr_nargs (node) > 0)
2305 pp_comma (pp);
2306 pp_space (pp);
2308 pp_string (pp, "__builtin_va_arg_pack ()");
2310 pp_right_paren (pp);
2312 op1 = CALL_EXPR_STATIC_CHAIN (node);
2313 if (op1)
2315 pp_string (pp, " [static-chain: ");
2316 dump_generic_node (pp, op1, spc, flags, false);
2317 pp_right_bracket (pp);
2320 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2321 pp_string (pp, " [return slot optimization]");
2322 if (CALL_EXPR_TAILCALL (node))
2323 pp_string (pp, " [tail call]");
2324 break;
2326 case WITH_CLEANUP_EXPR:
2327 NIY;
2328 break;
2330 case CLEANUP_POINT_EXPR:
2331 pp_string (pp, "<<cleanup_point ");
2332 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2333 pp_string (pp, ">>");
2334 break;
2336 case PLACEHOLDER_EXPR:
2337 pp_string (pp, "<PLACEHOLDER_EXPR ");
2338 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2339 pp_greater (pp);
2340 break;
2342 /* Binary arithmetic and logic expressions. */
2343 case WIDEN_SUM_EXPR:
2344 case WIDEN_MULT_EXPR:
2345 case MULT_EXPR:
2346 case MULT_HIGHPART_EXPR:
2347 case PLUS_EXPR:
2348 case POINTER_PLUS_EXPR:
2349 case POINTER_DIFF_EXPR:
2350 case MINUS_EXPR:
2351 case TRUNC_DIV_EXPR:
2352 case CEIL_DIV_EXPR:
2353 case FLOOR_DIV_EXPR:
2354 case ROUND_DIV_EXPR:
2355 case TRUNC_MOD_EXPR:
2356 case CEIL_MOD_EXPR:
2357 case FLOOR_MOD_EXPR:
2358 case ROUND_MOD_EXPR:
2359 case RDIV_EXPR:
2360 case EXACT_DIV_EXPR:
2361 case LSHIFT_EXPR:
2362 case RSHIFT_EXPR:
2363 case LROTATE_EXPR:
2364 case RROTATE_EXPR:
2365 case WIDEN_LSHIFT_EXPR:
2366 case BIT_IOR_EXPR:
2367 case BIT_XOR_EXPR:
2368 case BIT_AND_EXPR:
2369 case TRUTH_ANDIF_EXPR:
2370 case TRUTH_ORIF_EXPR:
2371 case TRUTH_AND_EXPR:
2372 case TRUTH_OR_EXPR:
2373 case TRUTH_XOR_EXPR:
2374 case LT_EXPR:
2375 case LE_EXPR:
2376 case GT_EXPR:
2377 case GE_EXPR:
2378 case EQ_EXPR:
2379 case NE_EXPR:
2380 case UNLT_EXPR:
2381 case UNLE_EXPR:
2382 case UNGT_EXPR:
2383 case UNGE_EXPR:
2384 case UNEQ_EXPR:
2385 case LTGT_EXPR:
2386 case ORDERED_EXPR:
2387 case UNORDERED_EXPR:
2389 const char *op = op_symbol (node);
2390 op0 = TREE_OPERAND (node, 0);
2391 op1 = TREE_OPERAND (node, 1);
2393 /* When the operands are expressions with less priority,
2394 keep semantics of the tree representation. */
2395 if (op_prio (op0) <= op_prio (node))
2397 pp_left_paren (pp);
2398 dump_generic_node (pp, op0, spc, flags, false);
2399 pp_right_paren (pp);
2401 else
2402 dump_generic_node (pp, op0, spc, flags, false);
2404 pp_space (pp);
2405 pp_string (pp, op);
2406 pp_space (pp);
2408 /* When the operands are expressions with less priority,
2409 keep semantics of the tree representation. */
2410 if (op_prio (op1) <= op_prio (node))
2412 pp_left_paren (pp);
2413 dump_generic_node (pp, op1, spc, flags, false);
2414 pp_right_paren (pp);
2416 else
2417 dump_generic_node (pp, op1, spc, flags, false);
2419 break;
2421 /* Unary arithmetic and logic expressions. */
2422 case NEGATE_EXPR:
2423 case BIT_NOT_EXPR:
2424 case TRUTH_NOT_EXPR:
2425 case ADDR_EXPR:
2426 case PREDECREMENT_EXPR:
2427 case PREINCREMENT_EXPR:
2428 case INDIRECT_REF:
2429 if (TREE_CODE (node) == ADDR_EXPR
2430 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2431 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2432 ; /* Do not output '&' for strings and function pointers. */
2433 else
2434 pp_string (pp, op_symbol (node));
2436 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2438 pp_left_paren (pp);
2439 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2440 pp_right_paren (pp);
2442 else
2443 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2444 break;
2446 case POSTDECREMENT_EXPR:
2447 case POSTINCREMENT_EXPR:
2448 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2450 pp_left_paren (pp);
2451 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2452 pp_right_paren (pp);
2454 else
2455 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2456 pp_string (pp, op_symbol (node));
2457 break;
2459 case MIN_EXPR:
2460 pp_string (pp, "MIN_EXPR <");
2461 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2462 pp_string (pp, ", ");
2463 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2464 pp_greater (pp);
2465 break;
2467 case MAX_EXPR:
2468 pp_string (pp, "MAX_EXPR <");
2469 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2470 pp_string (pp, ", ");
2471 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2472 pp_greater (pp);
2473 break;
2475 case ABS_EXPR:
2476 pp_string (pp, "ABS_EXPR <");
2477 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2478 pp_greater (pp);
2479 break;
2481 case ABSU_EXPR:
2482 pp_string (pp, "ABSU_EXPR <");
2483 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2484 pp_greater (pp);
2485 break;
2487 case RANGE_EXPR:
2488 NIY;
2489 break;
2491 case ADDR_SPACE_CONVERT_EXPR:
2492 case FIXED_CONVERT_EXPR:
2493 case FIX_TRUNC_EXPR:
2494 case FLOAT_EXPR:
2495 CASE_CONVERT:
2496 type = TREE_TYPE (node);
2497 op0 = TREE_OPERAND (node, 0);
2498 if (type != TREE_TYPE (op0))
2500 pp_left_paren (pp);
2501 dump_generic_node (pp, type, spc, flags, false);
2502 pp_string (pp, ") ");
2504 if (op_prio (op0) < op_prio (node))
2505 pp_left_paren (pp);
2506 dump_generic_node (pp, op0, spc, flags, false);
2507 if (op_prio (op0) < op_prio (node))
2508 pp_right_paren (pp);
2509 break;
2511 case VIEW_CONVERT_EXPR:
2512 pp_string (pp, "VIEW_CONVERT_EXPR<");
2513 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2514 pp_string (pp, ">(");
2515 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2516 pp_right_paren (pp);
2517 break;
2519 case PAREN_EXPR:
2520 pp_string (pp, "((");
2521 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2522 pp_string (pp, "))");
2523 break;
2525 case NON_LVALUE_EXPR:
2526 pp_string (pp, "NON_LVALUE_EXPR <");
2527 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2528 pp_greater (pp);
2529 break;
2531 case SAVE_EXPR:
2532 pp_string (pp, "SAVE_EXPR <");
2533 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2534 pp_greater (pp);
2535 break;
2537 case COMPLEX_EXPR:
2538 pp_string (pp, "COMPLEX_EXPR <");
2539 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2540 pp_string (pp, ", ");
2541 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2542 pp_greater (pp);
2543 break;
2545 case CONJ_EXPR:
2546 pp_string (pp, "CONJ_EXPR <");
2547 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2548 pp_greater (pp);
2549 break;
2551 case REALPART_EXPR:
2552 if (flags & TDF_GIMPLE)
2554 pp_string (pp, "__real ");
2555 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2557 else
2559 pp_string (pp, "REALPART_EXPR <");
2560 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2561 pp_greater (pp);
2563 break;
2565 case IMAGPART_EXPR:
2566 if (flags & TDF_GIMPLE)
2568 pp_string (pp, "__imag ");
2569 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2571 else
2573 pp_string (pp, "IMAGPART_EXPR <");
2574 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2575 pp_greater (pp);
2577 break;
2579 case VA_ARG_EXPR:
2580 pp_string (pp, "VA_ARG_EXPR <");
2581 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2582 pp_greater (pp);
2583 break;
2585 case TRY_FINALLY_EXPR:
2586 case TRY_CATCH_EXPR:
2587 pp_string (pp, "try");
2588 newline_and_indent (pp, spc+2);
2589 pp_left_brace (pp);
2590 newline_and_indent (pp, spc+4);
2591 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2592 newline_and_indent (pp, spc+2);
2593 pp_right_brace (pp);
2594 newline_and_indent (pp, spc);
2595 pp_string (pp,
2596 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2597 newline_and_indent (pp, spc+2);
2598 pp_left_brace (pp);
2599 newline_and_indent (pp, spc+4);
2600 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2601 newline_and_indent (pp, spc+2);
2602 pp_right_brace (pp);
2603 is_expr = false;
2604 break;
2606 case CATCH_EXPR:
2607 pp_string (pp, "catch (");
2608 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2609 pp_right_paren (pp);
2610 newline_and_indent (pp, spc+2);
2611 pp_left_brace (pp);
2612 newline_and_indent (pp, spc+4);
2613 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2614 newline_and_indent (pp, spc+2);
2615 pp_right_brace (pp);
2616 is_expr = false;
2617 break;
2619 case EH_FILTER_EXPR:
2620 pp_string (pp, "<<<eh_filter (");
2621 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2622 pp_string (pp, ")>>>");
2623 newline_and_indent (pp, spc+2);
2624 pp_left_brace (pp);
2625 newline_and_indent (pp, spc+4);
2626 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2627 newline_and_indent (pp, spc+2);
2628 pp_right_brace (pp);
2629 is_expr = false;
2630 break;
2632 case LABEL_EXPR:
2633 op0 = TREE_OPERAND (node, 0);
2634 /* If this is for break or continue, don't bother printing it. */
2635 if (DECL_NAME (op0))
2637 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2638 if (strcmp (name, "break") == 0
2639 || strcmp (name, "continue") == 0)
2640 break;
2642 dump_generic_node (pp, op0, spc, flags, false);
2643 pp_colon (pp);
2644 if (DECL_NONLOCAL (op0))
2645 pp_string (pp, " [non-local]");
2646 break;
2648 case LOOP_EXPR:
2649 pp_string (pp, "while (1)");
2650 if (!(flags & TDF_SLIM))
2652 newline_and_indent (pp, spc+2);
2653 pp_left_brace (pp);
2654 newline_and_indent (pp, spc+4);
2655 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2656 newline_and_indent (pp, spc+2);
2657 pp_right_brace (pp);
2659 is_expr = false;
2660 break;
2662 case PREDICT_EXPR:
2663 pp_string (pp, "// predicted ");
2664 if (PREDICT_EXPR_OUTCOME (node))
2665 pp_string (pp, "likely by ");
2666 else
2667 pp_string (pp, "unlikely by ");
2668 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2669 pp_string (pp, " predictor.");
2670 break;
2672 case ANNOTATE_EXPR:
2673 pp_string (pp, "ANNOTATE_EXPR <");
2674 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2675 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2677 case annot_expr_ivdep_kind:
2678 pp_string (pp, ", ivdep");
2679 break;
2680 case annot_expr_unroll_kind:
2681 pp_printf (pp, ", unroll %d",
2682 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2683 break;
2684 case annot_expr_no_vector_kind:
2685 pp_string (pp, ", no-vector");
2686 break;
2687 case annot_expr_vector_kind:
2688 pp_string (pp, ", vector");
2689 break;
2690 case annot_expr_parallel_kind:
2691 pp_string (pp, ", parallel");
2692 break;
2693 default:
2694 gcc_unreachable ();
2696 pp_greater (pp);
2697 break;
2699 case RETURN_EXPR:
2700 pp_string (pp, "return");
2701 op0 = TREE_OPERAND (node, 0);
2702 if (op0)
2704 pp_space (pp);
2705 if (TREE_CODE (op0) == MODIFY_EXPR)
2706 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2707 spc, flags, false);
2708 else
2709 dump_generic_node (pp, op0, spc, flags, false);
2711 break;
2713 case EXIT_EXPR:
2714 pp_string (pp, "if (");
2715 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2716 pp_string (pp, ") break");
2717 break;
2719 case SWITCH_EXPR:
2720 pp_string (pp, "switch (");
2721 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2722 pp_right_paren (pp);
2723 if (!(flags & TDF_SLIM))
2725 newline_and_indent (pp, spc+2);
2726 pp_left_brace (pp);
2727 if (SWITCH_BODY (node))
2729 newline_and_indent (pp, spc+4);
2730 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2731 true);
2733 newline_and_indent (pp, spc+2);
2734 pp_right_brace (pp);
2736 is_expr = false;
2737 break;
2739 case GOTO_EXPR:
2740 op0 = GOTO_DESTINATION (node);
2741 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2743 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2744 if (strcmp (name, "break") == 0
2745 || strcmp (name, "continue") == 0)
2747 pp_string (pp, name);
2748 break;
2751 pp_string (pp, "goto ");
2752 dump_generic_node (pp, op0, spc, flags, false);
2753 break;
2755 case ASM_EXPR:
2756 pp_string (pp, "__asm__");
2757 if (ASM_VOLATILE_P (node))
2758 pp_string (pp, " __volatile__");
2759 pp_left_paren (pp);
2760 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2761 pp_colon (pp);
2762 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2763 pp_colon (pp);
2764 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2765 if (ASM_CLOBBERS (node))
2767 pp_colon (pp);
2768 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2770 pp_right_paren (pp);
2771 break;
2773 case CASE_LABEL_EXPR:
2774 if (CASE_LOW (node) && CASE_HIGH (node))
2776 pp_string (pp, "case ");
2777 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2778 pp_string (pp, " ... ");
2779 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2781 else if (CASE_LOW (node))
2783 pp_string (pp, "case ");
2784 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2786 else
2787 pp_string (pp, "default");
2788 pp_colon (pp);
2789 break;
2791 case OBJ_TYPE_REF:
2792 pp_string (pp, "OBJ_TYPE_REF(");
2793 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2794 pp_semicolon (pp);
2795 /* We omit the class type for -fcompare-debug because we may
2796 drop TYPE_BINFO early depending on debug info, and then
2797 virtual_method_call_p would return false, whereas when
2798 TYPE_BINFO is preserved it may still return true and then
2799 we'd print the class type. Compare tree and rtl dumps for
2800 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
2801 for example, at occurrences of OBJ_TYPE_REF. */
2802 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
2803 && virtual_method_call_p (node))
2805 pp_string (pp, "(");
2806 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2807 pp_string (pp, ")");
2809 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2810 pp_arrow (pp);
2811 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2812 pp_right_paren (pp);
2813 break;
2815 case SSA_NAME:
2816 if (SSA_NAME_IDENTIFIER (node))
2818 if ((flags & TDF_NOUID)
2819 && SSA_NAME_VAR (node)
2820 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2821 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2822 else if (! (flags & TDF_GIMPLE)
2823 || SSA_NAME_VAR (node))
2824 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2825 spc, flags, false);
2827 pp_underscore (pp);
2828 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2829 if (SSA_NAME_IS_DEFAULT_DEF (node))
2830 pp_string (pp, "(D)");
2831 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2832 pp_string (pp, "(ab)");
2833 break;
2835 case WITH_SIZE_EXPR:
2836 pp_string (pp, "WITH_SIZE_EXPR <");
2837 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2838 pp_string (pp, ", ");
2839 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2840 pp_greater (pp);
2841 break;
2843 case ASSERT_EXPR:
2844 pp_string (pp, "ASSERT_EXPR <");
2845 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2846 pp_string (pp, ", ");
2847 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2848 pp_greater (pp);
2849 break;
2851 case SCEV_KNOWN:
2852 pp_string (pp, "scev_known");
2853 break;
2855 case SCEV_NOT_KNOWN:
2856 pp_string (pp, "scev_not_known");
2857 break;
2859 case POLYNOMIAL_CHREC:
2860 pp_left_brace (pp);
2861 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2862 pp_string (pp, ", +, ");
2863 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2864 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
2865 is_stmt = false;
2866 break;
2868 case REALIGN_LOAD_EXPR:
2869 pp_string (pp, "REALIGN_LOAD <");
2870 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2871 pp_string (pp, ", ");
2872 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2873 pp_string (pp, ", ");
2874 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2875 pp_greater (pp);
2876 break;
2878 case VEC_COND_EXPR:
2879 pp_string (pp, " VEC_COND_EXPR < ");
2880 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2881 pp_string (pp, " , ");
2882 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2883 pp_string (pp, " , ");
2884 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2885 pp_string (pp, " > ");
2886 break;
2888 case VEC_PERM_EXPR:
2889 pp_string (pp, " VEC_PERM_EXPR < ");
2890 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2891 pp_string (pp, " , ");
2892 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2893 pp_string (pp, " , ");
2894 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2895 pp_string (pp, " > ");
2896 break;
2898 case DOT_PROD_EXPR:
2899 pp_string (pp, " DOT_PROD_EXPR < ");
2900 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2901 pp_string (pp, ", ");
2902 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2903 pp_string (pp, ", ");
2904 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2905 pp_string (pp, " > ");
2906 break;
2908 case WIDEN_MULT_PLUS_EXPR:
2909 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2910 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2911 pp_string (pp, ", ");
2912 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2913 pp_string (pp, ", ");
2914 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2915 pp_string (pp, " > ");
2916 break;
2918 case WIDEN_MULT_MINUS_EXPR:
2919 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2920 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2921 pp_string (pp, ", ");
2922 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2923 pp_string (pp, ", ");
2924 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2925 pp_string (pp, " > ");
2926 break;
2928 case OACC_PARALLEL:
2929 pp_string (pp, "#pragma acc parallel");
2930 goto dump_omp_clauses_body;
2932 case OACC_KERNELS:
2933 pp_string (pp, "#pragma acc kernels");
2934 goto dump_omp_clauses_body;
2936 case OACC_DATA:
2937 pp_string (pp, "#pragma acc data");
2938 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2939 goto dump_omp_body;
2941 case OACC_HOST_DATA:
2942 pp_string (pp, "#pragma acc host_data");
2943 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2944 goto dump_omp_body;
2946 case OACC_DECLARE:
2947 pp_string (pp, "#pragma acc declare");
2948 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2949 break;
2951 case OACC_UPDATE:
2952 pp_string (pp, "#pragma acc update");
2953 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2954 break;
2956 case OACC_ENTER_DATA:
2957 pp_string (pp, "#pragma acc enter data");
2958 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2959 break;
2961 case OACC_EXIT_DATA:
2962 pp_string (pp, "#pragma acc exit data");
2963 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2964 break;
2966 case OACC_CACHE:
2967 pp_string (pp, "#pragma acc cache");
2968 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2969 break;
2971 case OMP_PARALLEL:
2972 pp_string (pp, "#pragma omp parallel");
2973 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2974 goto dump_omp_body;
2976 dump_omp_clauses_body:
2977 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2978 goto dump_omp_body;
2980 dump_omp_body:
2981 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2983 newline_and_indent (pp, spc + 2);
2984 pp_left_brace (pp);
2985 newline_and_indent (pp, spc + 4);
2986 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2987 newline_and_indent (pp, spc + 2);
2988 pp_right_brace (pp);
2990 is_expr = false;
2991 break;
2993 case OMP_TASK:
2994 pp_string (pp, "#pragma omp task");
2995 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2996 goto dump_omp_body;
2998 case OMP_FOR:
2999 pp_string (pp, "#pragma omp for");
3000 goto dump_omp_loop;
3002 case OMP_SIMD:
3003 pp_string (pp, "#pragma omp simd");
3004 goto dump_omp_loop;
3006 case OMP_DISTRIBUTE:
3007 pp_string (pp, "#pragma omp distribute");
3008 goto dump_omp_loop;
3010 case OMP_TASKLOOP:
3011 pp_string (pp, "#pragma omp taskloop");
3012 goto dump_omp_loop;
3014 case OACC_LOOP:
3015 pp_string (pp, "#pragma acc loop");
3016 goto dump_omp_loop;
3018 case OMP_TEAMS:
3019 pp_string (pp, "#pragma omp teams");
3020 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3021 goto dump_omp_body;
3023 case OMP_TARGET_DATA:
3024 pp_string (pp, "#pragma omp target data");
3025 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3026 goto dump_omp_body;
3028 case OMP_TARGET_ENTER_DATA:
3029 pp_string (pp, "#pragma omp target enter data");
3030 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3031 is_expr = false;
3032 break;
3034 case OMP_TARGET_EXIT_DATA:
3035 pp_string (pp, "#pragma omp target exit data");
3036 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3037 is_expr = false;
3038 break;
3040 case OMP_TARGET:
3041 pp_string (pp, "#pragma omp target");
3042 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3043 goto dump_omp_body;
3045 case OMP_TARGET_UPDATE:
3046 pp_string (pp, "#pragma omp target update");
3047 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3048 is_expr = false;
3049 break;
3051 dump_omp_loop:
3052 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3053 if (!(flags & TDF_SLIM))
3055 int i;
3057 if (OMP_FOR_PRE_BODY (node))
3059 newline_and_indent (pp, spc + 2);
3060 pp_left_brace (pp);
3061 spc += 4;
3062 newline_and_indent (pp, spc);
3063 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3064 spc, flags, false);
3066 if (OMP_FOR_INIT (node))
3068 spc -= 2;
3069 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3071 spc += 2;
3072 newline_and_indent (pp, spc);
3073 pp_string (pp, "for (");
3074 dump_generic_node (pp,
3075 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3076 spc, flags, false);
3077 pp_string (pp, "; ");
3078 dump_generic_node (pp,
3079 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3080 spc, flags, false);
3081 pp_string (pp, "; ");
3082 dump_generic_node (pp,
3083 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3084 spc, flags, false);
3085 pp_right_paren (pp);
3088 if (OMP_FOR_BODY (node))
3090 newline_and_indent (pp, spc + 2);
3091 pp_left_brace (pp);
3092 newline_and_indent (pp, spc + 4);
3093 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3094 false);
3095 newline_and_indent (pp, spc + 2);
3096 pp_right_brace (pp);
3098 if (OMP_FOR_INIT (node))
3099 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3100 if (OMP_FOR_PRE_BODY (node))
3102 spc -= 4;
3103 newline_and_indent (pp, spc + 2);
3104 pp_right_brace (pp);
3107 is_expr = false;
3108 break;
3110 case OMP_SECTIONS:
3111 pp_string (pp, "#pragma omp sections");
3112 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3113 goto dump_omp_body;
3115 case OMP_SECTION:
3116 pp_string (pp, "#pragma omp section");
3117 goto dump_omp_body;
3119 case OMP_MASTER:
3120 pp_string (pp, "#pragma omp master");
3121 goto dump_omp_body;
3123 case OMP_TASKGROUP:
3124 pp_string (pp, "#pragma omp taskgroup");
3125 goto dump_omp_body;
3127 case OMP_ORDERED:
3128 pp_string (pp, "#pragma omp ordered");
3129 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3130 goto dump_omp_body;
3132 case OMP_CRITICAL:
3133 pp_string (pp, "#pragma omp critical");
3134 if (OMP_CRITICAL_NAME (node))
3136 pp_space (pp);
3137 pp_left_paren (pp);
3138 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3139 flags, false);
3140 pp_right_paren (pp);
3142 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3143 goto dump_omp_body;
3145 case OMP_ATOMIC:
3146 pp_string (pp, "#pragma omp atomic");
3147 if (OMP_ATOMIC_SEQ_CST (node))
3148 pp_string (pp, " seq_cst");
3149 newline_and_indent (pp, spc + 2);
3150 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3151 pp_space (pp);
3152 pp_equal (pp);
3153 pp_space (pp);
3154 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3155 break;
3157 case OMP_ATOMIC_READ:
3158 pp_string (pp, "#pragma omp atomic read");
3159 if (OMP_ATOMIC_SEQ_CST (node))
3160 pp_string (pp, " seq_cst");
3161 newline_and_indent (pp, spc + 2);
3162 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3163 pp_space (pp);
3164 break;
3166 case OMP_ATOMIC_CAPTURE_OLD:
3167 case OMP_ATOMIC_CAPTURE_NEW:
3168 pp_string (pp, "#pragma omp atomic capture");
3169 if (OMP_ATOMIC_SEQ_CST (node))
3170 pp_string (pp, " seq_cst");
3171 newline_and_indent (pp, spc + 2);
3172 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3173 pp_space (pp);
3174 pp_equal (pp);
3175 pp_space (pp);
3176 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3177 break;
3179 case OMP_SINGLE:
3180 pp_string (pp, "#pragma omp single");
3181 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3182 goto dump_omp_body;
3184 case OMP_CLAUSE:
3185 dump_omp_clause (pp, node, spc, flags);
3186 is_expr = false;
3187 break;
3189 case TRANSACTION_EXPR:
3190 if (TRANSACTION_EXPR_OUTER (node))
3191 pp_string (pp, "__transaction_atomic [[outer]]");
3192 else if (TRANSACTION_EXPR_RELAXED (node))
3193 pp_string (pp, "__transaction_relaxed");
3194 else
3195 pp_string (pp, "__transaction_atomic");
3196 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3198 newline_and_indent (pp, spc);
3199 pp_left_brace (pp);
3200 newline_and_indent (pp, spc + 2);
3201 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3202 spc + 2, flags, false);
3203 newline_and_indent (pp, spc);
3204 pp_right_brace (pp);
3206 is_expr = false;
3207 break;
3209 case VEC_SERIES_EXPR:
3210 case VEC_WIDEN_MULT_HI_EXPR:
3211 case VEC_WIDEN_MULT_LO_EXPR:
3212 case VEC_WIDEN_MULT_EVEN_EXPR:
3213 case VEC_WIDEN_MULT_ODD_EXPR:
3214 case VEC_WIDEN_LSHIFT_HI_EXPR:
3215 case VEC_WIDEN_LSHIFT_LO_EXPR:
3216 pp_space (pp);
3217 for (str = get_tree_code_name (code); *str; str++)
3218 pp_character (pp, TOUPPER (*str));
3219 pp_string (pp, " < ");
3220 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3221 pp_string (pp, ", ");
3222 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3223 pp_string (pp, " > ");
3224 break;
3226 case VEC_DUPLICATE_EXPR:
3227 pp_space (pp);
3228 for (str = get_tree_code_name (code); *str; str++)
3229 pp_character (pp, TOUPPER (*str));
3230 pp_string (pp, " < ");
3231 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3232 pp_string (pp, " > ");
3233 break;
3235 case VEC_UNPACK_HI_EXPR:
3236 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3237 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3238 pp_string (pp, " > ");
3239 break;
3241 case VEC_UNPACK_LO_EXPR:
3242 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3243 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3244 pp_string (pp, " > ");
3245 break;
3247 case VEC_UNPACK_FLOAT_HI_EXPR:
3248 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3249 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3250 pp_string (pp, " > ");
3251 break;
3253 case VEC_UNPACK_FLOAT_LO_EXPR:
3254 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3255 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3256 pp_string (pp, " > ");
3257 break;
3259 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3260 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3261 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3262 pp_string (pp, " > ");
3263 break;
3265 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3266 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3267 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3268 pp_string (pp, " > ");
3269 break;
3271 case VEC_PACK_TRUNC_EXPR:
3272 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3273 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3274 pp_string (pp, ", ");
3275 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3276 pp_string (pp, " > ");
3277 break;
3279 case VEC_PACK_SAT_EXPR:
3280 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3281 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3282 pp_string (pp, ", ");
3283 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3284 pp_string (pp, " > ");
3285 break;
3287 case VEC_PACK_FIX_TRUNC_EXPR:
3288 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3289 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3290 pp_string (pp, ", ");
3291 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3292 pp_string (pp, " > ");
3293 break;
3295 case VEC_PACK_FLOAT_EXPR:
3296 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3297 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3298 pp_string (pp, ", ");
3299 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3300 pp_string (pp, " > ");
3301 break;
3303 case BLOCK:
3304 dump_block_node (pp, node, spc, flags);
3305 break;
3307 case DEBUG_BEGIN_STMT:
3308 pp_string (pp, "# DEBUG BEGIN STMT");
3309 break;
3311 default:
3312 NIY;
3315 if (is_stmt && is_expr)
3316 pp_semicolon (pp);
3318 return spc;
3321 /* Print the declaration of a variable. */
3323 void
3324 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3326 INDENT (spc);
3328 if (TREE_CODE(t) == NAMELIST_DECL)
3330 pp_string(pp, "namelist ");
3331 dump_decl_name (pp, t, flags);
3332 pp_semicolon (pp);
3333 return;
3336 if (TREE_CODE (t) == TYPE_DECL)
3337 pp_string (pp, "typedef ");
3339 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3340 pp_string (pp, "register ");
3342 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3343 pp_string (pp, "extern ");
3344 else if (TREE_STATIC (t))
3345 pp_string (pp, "static ");
3347 /* Print the type and name. */
3348 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3350 tree tmp;
3352 /* Print array's type. */
3353 tmp = TREE_TYPE (t);
3354 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3355 tmp = TREE_TYPE (tmp);
3356 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3358 /* Print variable's name. */
3359 pp_space (pp);
3360 dump_generic_node (pp, t, spc, flags, false);
3362 /* Print the dimensions. */
3363 tmp = TREE_TYPE (t);
3364 while (TREE_CODE (tmp) == ARRAY_TYPE)
3366 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3367 tmp = TREE_TYPE (tmp);
3370 else if (TREE_CODE (t) == FUNCTION_DECL)
3372 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3373 pp_space (pp);
3374 dump_decl_name (pp, t, flags);
3375 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3377 else
3379 /* Print type declaration. */
3380 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3382 /* Print variable's name. */
3383 pp_space (pp);
3384 dump_generic_node (pp, t, spc, flags, false);
3387 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3389 pp_string (pp, " __asm__ ");
3390 pp_left_paren (pp);
3391 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3392 pp_right_paren (pp);
3395 /* The initial value of a function serves to determine whether the function
3396 is declared or defined. So the following does not apply to function
3397 nodes. */
3398 if (TREE_CODE (t) != FUNCTION_DECL)
3400 /* Print the initial value. */
3401 if (DECL_INITIAL (t))
3403 pp_space (pp);
3404 pp_equal (pp);
3405 pp_space (pp);
3406 if (!(flags & TDF_SLIM))
3407 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3408 else
3409 pp_string (pp, "<<< omitted >>>");
3413 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3415 pp_string (pp, " [value-expr: ");
3416 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3417 pp_right_bracket (pp);
3420 pp_semicolon (pp);
3424 /* Prints a structure: name, fields, and methods.
3425 FIXME: Still incomplete. */
3427 static void
3428 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3429 dump_flags_t flags)
3431 /* Print the name of the structure. */
3432 if (TYPE_NAME (node))
3434 INDENT (spc);
3435 if (TREE_CODE (node) == RECORD_TYPE)
3436 pp_string (pp, "struct ");
3437 else if ((TREE_CODE (node) == UNION_TYPE
3438 || TREE_CODE (node) == QUAL_UNION_TYPE))
3439 pp_string (pp, "union ");
3441 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3444 /* Print the contents of the structure. */
3445 pp_newline (pp);
3446 INDENT (spc);
3447 pp_left_brace (pp);
3448 pp_newline (pp);
3450 /* Print the fields of the structure. */
3452 tree tmp;
3453 tmp = TYPE_FIELDS (node);
3454 while (tmp)
3456 /* Avoid to print recursively the structure. */
3457 /* FIXME : Not implemented correctly...,
3458 what about the case when we have a cycle in the contain graph? ...
3459 Maybe this could be solved by looking at the scope in which the
3460 structure was declared. */
3461 if (TREE_TYPE (tmp) != node
3462 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3463 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3465 print_declaration (pp, tmp, spc+2, flags);
3466 pp_newline (pp);
3468 tmp = DECL_CHAIN (tmp);
3471 INDENT (spc);
3472 pp_right_brace (pp);
3475 /* Return the priority of the operator CODE.
3477 From lowest to highest precedence with either left-to-right (L-R)
3478 or right-to-left (R-L) associativity]:
3480 1 [L-R] ,
3481 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3482 3 [R-L] ?:
3483 4 [L-R] ||
3484 5 [L-R] &&
3485 6 [L-R] |
3486 7 [L-R] ^
3487 8 [L-R] &
3488 9 [L-R] == !=
3489 10 [L-R] < <= > >=
3490 11 [L-R] << >>
3491 12 [L-R] + -
3492 13 [L-R] * / %
3493 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3494 15 [L-R] fn() [] -> .
3496 unary +, - and * have higher precedence than the corresponding binary
3497 operators. */
3500 op_code_prio (enum tree_code code)
3502 switch (code)
3504 case TREE_LIST:
3505 case COMPOUND_EXPR:
3506 case BIND_EXPR:
3507 return 1;
3509 case MODIFY_EXPR:
3510 case INIT_EXPR:
3511 return 2;
3513 case COND_EXPR:
3514 return 3;
3516 case TRUTH_OR_EXPR:
3517 case TRUTH_ORIF_EXPR:
3518 return 4;
3520 case TRUTH_AND_EXPR:
3521 case TRUTH_ANDIF_EXPR:
3522 return 5;
3524 case BIT_IOR_EXPR:
3525 return 6;
3527 case BIT_XOR_EXPR:
3528 case TRUTH_XOR_EXPR:
3529 return 7;
3531 case BIT_AND_EXPR:
3532 return 8;
3534 case EQ_EXPR:
3535 case NE_EXPR:
3536 return 9;
3538 case UNLT_EXPR:
3539 case UNLE_EXPR:
3540 case UNGT_EXPR:
3541 case UNGE_EXPR:
3542 case UNEQ_EXPR:
3543 case LTGT_EXPR:
3544 case ORDERED_EXPR:
3545 case UNORDERED_EXPR:
3546 case LT_EXPR:
3547 case LE_EXPR:
3548 case GT_EXPR:
3549 case GE_EXPR:
3550 return 10;
3552 case LSHIFT_EXPR:
3553 case RSHIFT_EXPR:
3554 case LROTATE_EXPR:
3555 case RROTATE_EXPR:
3556 case VEC_WIDEN_LSHIFT_HI_EXPR:
3557 case VEC_WIDEN_LSHIFT_LO_EXPR:
3558 case WIDEN_LSHIFT_EXPR:
3559 return 11;
3561 case WIDEN_SUM_EXPR:
3562 case PLUS_EXPR:
3563 case POINTER_PLUS_EXPR:
3564 case POINTER_DIFF_EXPR:
3565 case MINUS_EXPR:
3566 return 12;
3568 case VEC_WIDEN_MULT_HI_EXPR:
3569 case VEC_WIDEN_MULT_LO_EXPR:
3570 case WIDEN_MULT_EXPR:
3571 case DOT_PROD_EXPR:
3572 case WIDEN_MULT_PLUS_EXPR:
3573 case WIDEN_MULT_MINUS_EXPR:
3574 case MULT_EXPR:
3575 case MULT_HIGHPART_EXPR:
3576 case TRUNC_DIV_EXPR:
3577 case CEIL_DIV_EXPR:
3578 case FLOOR_DIV_EXPR:
3579 case ROUND_DIV_EXPR:
3580 case RDIV_EXPR:
3581 case EXACT_DIV_EXPR:
3582 case TRUNC_MOD_EXPR:
3583 case CEIL_MOD_EXPR:
3584 case FLOOR_MOD_EXPR:
3585 case ROUND_MOD_EXPR:
3586 return 13;
3588 case TRUTH_NOT_EXPR:
3589 case BIT_NOT_EXPR:
3590 case POSTINCREMENT_EXPR:
3591 case POSTDECREMENT_EXPR:
3592 case PREINCREMENT_EXPR:
3593 case PREDECREMENT_EXPR:
3594 case NEGATE_EXPR:
3595 case INDIRECT_REF:
3596 case ADDR_EXPR:
3597 case FLOAT_EXPR:
3598 CASE_CONVERT:
3599 case FIX_TRUNC_EXPR:
3600 case TARGET_EXPR:
3601 return 14;
3603 case CALL_EXPR:
3604 case ARRAY_REF:
3605 case ARRAY_RANGE_REF:
3606 case COMPONENT_REF:
3607 return 15;
3609 /* Special expressions. */
3610 case MIN_EXPR:
3611 case MAX_EXPR:
3612 case ABS_EXPR:
3613 case REALPART_EXPR:
3614 case IMAGPART_EXPR:
3615 case VEC_UNPACK_HI_EXPR:
3616 case VEC_UNPACK_LO_EXPR:
3617 case VEC_UNPACK_FLOAT_HI_EXPR:
3618 case VEC_UNPACK_FLOAT_LO_EXPR:
3619 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3620 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3621 case VEC_PACK_TRUNC_EXPR:
3622 case VEC_PACK_SAT_EXPR:
3623 return 16;
3625 default:
3626 /* Return an arbitrarily high precedence to avoid surrounding single
3627 VAR_DECLs in ()s. */
3628 return 9999;
3632 /* Return the priority of the operator OP. */
3635 op_prio (const_tree op)
3637 enum tree_code code;
3639 if (op == NULL)
3640 return 9999;
3642 code = TREE_CODE (op);
3643 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3644 return op_prio (TREE_OPERAND (op, 0));
3646 return op_code_prio (code);
3649 /* Return the symbol associated with operator CODE. */
3651 const char *
3652 op_symbol_code (enum tree_code code)
3654 switch (code)
3656 case MODIFY_EXPR:
3657 return "=";
3659 case TRUTH_OR_EXPR:
3660 case TRUTH_ORIF_EXPR:
3661 return "||";
3663 case TRUTH_AND_EXPR:
3664 case TRUTH_ANDIF_EXPR:
3665 return "&&";
3667 case BIT_IOR_EXPR:
3668 return "|";
3670 case TRUTH_XOR_EXPR:
3671 case BIT_XOR_EXPR:
3672 return "^";
3674 case ADDR_EXPR:
3675 case BIT_AND_EXPR:
3676 return "&";
3678 case ORDERED_EXPR:
3679 return "ord";
3680 case UNORDERED_EXPR:
3681 return "unord";
3683 case EQ_EXPR:
3684 return "==";
3685 case UNEQ_EXPR:
3686 return "u==";
3688 case NE_EXPR:
3689 return "!=";
3691 case LT_EXPR:
3692 return "<";
3693 case UNLT_EXPR:
3694 return "u<";
3696 case LE_EXPR:
3697 return "<=";
3698 case UNLE_EXPR:
3699 return "u<=";
3701 case GT_EXPR:
3702 return ">";
3703 case UNGT_EXPR:
3704 return "u>";
3706 case GE_EXPR:
3707 return ">=";
3708 case UNGE_EXPR:
3709 return "u>=";
3711 case LTGT_EXPR:
3712 return "<>";
3714 case LSHIFT_EXPR:
3715 return "<<";
3717 case RSHIFT_EXPR:
3718 return ">>";
3720 case LROTATE_EXPR:
3721 return "r<<";
3723 case RROTATE_EXPR:
3724 return "r>>";
3726 case WIDEN_LSHIFT_EXPR:
3727 return "w<<";
3729 case POINTER_PLUS_EXPR:
3730 return "+";
3732 case PLUS_EXPR:
3733 return "+";
3735 case WIDEN_SUM_EXPR:
3736 return "w+";
3738 case WIDEN_MULT_EXPR:
3739 return "w*";
3741 case MULT_HIGHPART_EXPR:
3742 return "h*";
3744 case NEGATE_EXPR:
3745 case MINUS_EXPR:
3746 case POINTER_DIFF_EXPR:
3747 return "-";
3749 case BIT_NOT_EXPR:
3750 return "~";
3752 case TRUTH_NOT_EXPR:
3753 return "!";
3755 case MULT_EXPR:
3756 case INDIRECT_REF:
3757 return "*";
3759 case TRUNC_DIV_EXPR:
3760 case RDIV_EXPR:
3761 return "/";
3763 case CEIL_DIV_EXPR:
3764 return "/[cl]";
3766 case FLOOR_DIV_EXPR:
3767 return "/[fl]";
3769 case ROUND_DIV_EXPR:
3770 return "/[rd]";
3772 case EXACT_DIV_EXPR:
3773 return "/[ex]";
3775 case TRUNC_MOD_EXPR:
3776 return "%";
3778 case CEIL_MOD_EXPR:
3779 return "%[cl]";
3781 case FLOOR_MOD_EXPR:
3782 return "%[fl]";
3784 case ROUND_MOD_EXPR:
3785 return "%[rd]";
3787 case PREDECREMENT_EXPR:
3788 return " --";
3790 case PREINCREMENT_EXPR:
3791 return " ++";
3793 case POSTDECREMENT_EXPR:
3794 return "-- ";
3796 case POSTINCREMENT_EXPR:
3797 return "++ ";
3799 case MAX_EXPR:
3800 return "max";
3802 case MIN_EXPR:
3803 return "min";
3805 default:
3806 return "<<< ??? >>>";
3810 /* Return the symbol associated with operator OP. */
3812 static const char *
3813 op_symbol (const_tree op)
3815 return op_symbol_code (TREE_CODE (op));
3818 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3819 the gimple_call_fn of a GIMPLE_CALL. */
3821 void
3822 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3824 tree op0 = node;
3826 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3827 op0 = TREE_OPERAND (op0, 0);
3829 again:
3830 switch (TREE_CODE (op0))
3832 case VAR_DECL:
3833 case PARM_DECL:
3834 case FUNCTION_DECL:
3835 dump_function_name (pp, op0, flags);
3836 break;
3838 case ADDR_EXPR:
3839 case INDIRECT_REF:
3840 CASE_CONVERT:
3841 op0 = TREE_OPERAND (op0, 0);
3842 goto again;
3844 case COND_EXPR:
3845 pp_left_paren (pp);
3846 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3847 pp_string (pp, ") ? ");
3848 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3849 pp_string (pp, " : ");
3850 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3851 break;
3853 case ARRAY_REF:
3854 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3855 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3856 else
3857 dump_generic_node (pp, op0, 0, flags, false);
3858 break;
3860 case MEM_REF:
3861 if (integer_zerop (TREE_OPERAND (op0, 1)))
3863 op0 = TREE_OPERAND (op0, 0);
3864 goto again;
3866 /* Fallthru. */
3867 case COMPONENT_REF:
3868 case SSA_NAME:
3869 case OBJ_TYPE_REF:
3870 dump_generic_node (pp, op0, 0, flags, false);
3871 break;
3873 default:
3874 NIY;
3878 /* Print the first N characters in the array STR, replacing non-printable
3879 characters (including embedded nuls) with unambiguous escape sequences. */
3881 static void
3882 pretty_print_string (pretty_printer *pp, const char *str, unsigned n)
3884 if (str == NULL)
3885 return;
3887 for ( ; n; --n, ++str)
3889 switch (str[0])
3891 case '\b':
3892 pp_string (pp, "\\b");
3893 break;
3895 case '\f':
3896 pp_string (pp, "\\f");
3897 break;
3899 case '\n':
3900 pp_string (pp, "\\n");
3901 break;
3903 case '\r':
3904 pp_string (pp, "\\r");
3905 break;
3907 case '\t':
3908 pp_string (pp, "\\t");
3909 break;
3911 case '\v':
3912 pp_string (pp, "\\v");
3913 break;
3915 case '\\':
3916 pp_string (pp, "\\\\");
3917 break;
3919 case '\"':
3920 pp_string (pp, "\\\"");
3921 break;
3923 case '\'':
3924 pp_string (pp, "\\'");
3925 break;
3927 default:
3928 if (str[0] || n > 1)
3930 if (!ISPRINT (str[0]))
3932 char buf[5];
3933 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
3934 pp_string (pp, buf);
3936 else
3937 pp_character (pp, str[0]);
3938 break;
3944 static void
3945 maybe_init_pretty_print (FILE *file)
3947 if (!tree_pp)
3949 tree_pp = new pretty_printer ();
3950 pp_needs_newline (tree_pp) = true;
3951 pp_translate_identifiers (tree_pp) = false;
3954 tree_pp->buffer->stream = file;
3957 static void
3958 newline_and_indent (pretty_printer *pp, int spc)
3960 pp_newline (pp);
3961 INDENT (spc);
3964 /* Handle the %K format for TEXT. Separate from default_tree_printer
3965 so it can also be used in front ends.
3966 The location LOC and BLOCK are expected to be extracted by the caller
3967 from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
3969 void
3970 percent_K_format (text_info *text, location_t loc, tree block)
3972 text->set_location (0, loc, SHOW_RANGE_WITH_CARET);
3973 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3974 *pp_ti_abstract_origin (text) = NULL;
3976 while (block
3977 && TREE_CODE (block) == BLOCK
3978 && BLOCK_ABSTRACT_ORIGIN (block))
3980 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3981 if (TREE_CODE (ao) == FUNCTION_DECL)
3983 *pp_ti_abstract_origin (text) = block;
3984 break;
3986 block = BLOCK_SUPERCONTEXT (block);
3990 /* Print the identifier ID to PRETTY-PRINTER. */
3992 void
3993 pp_tree_identifier (pretty_printer *pp, tree id)
3995 if (pp_translate_identifiers (pp))
3997 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3998 pp_append_text (pp, text, text + strlen (text));
4000 else
4001 pp_append_text (pp, IDENTIFIER_POINTER (id),
4002 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4005 /* A helper function that is used to dump function information before the
4006 function dump. */
4008 void
4009 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4011 const char *dname, *aname;
4012 struct cgraph_node *node = cgraph_node::get (fdecl);
4013 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4015 dname = lang_hooks.decl_printable_name (fdecl, 1);
4017 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4018 aname = (IDENTIFIER_POINTER
4019 (DECL_ASSEMBLER_NAME (fdecl)));
4020 else
4021 aname = "<unset-asm-name>";
4023 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4024 dname, aname, fun->funcdef_no);
4025 if (!(flags & TDF_NOUID))
4026 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4027 if (node)
4029 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4030 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4031 node->frequency == NODE_FREQUENCY_HOT
4032 ? " (hot)"
4033 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4034 ? " (unlikely executed)"
4035 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4036 ? " (executed once)"
4037 : "");
4039 else
4040 fprintf (dump_file, ")\n\n");
4043 /* Dump double_int D to pretty_printer PP. UNS is true
4044 if D is unsigned and false otherwise. */
4045 void
4046 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4048 if (d.fits_shwi ())
4049 pp_wide_integer (pp, d.low);
4050 else if (d.fits_uhwi ())
4051 pp_unsigned_wide_integer (pp, d.low);
4052 else
4054 unsigned HOST_WIDE_INT low = d.low;
4055 HOST_WIDE_INT high = d.high;
4056 if (!uns && d.is_negative ())
4058 pp_minus (pp);
4059 high = ~high + !low;
4060 low = -low;
4062 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4063 systems? */
4064 sprintf (pp_buffer (pp)->digit_buffer,
4065 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4066 (unsigned HOST_WIDE_INT) high, low);
4067 pp_string (pp, pp_buffer (pp)->digit_buffer);