PR tree-optimization/83482
[official-gcc.git] / gcc / tree-pretty-print.c
blob681ff944487ba12372e7fdf9100a537a3adf8923
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2017 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*);
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 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
166 in it are replaced with Dxxxx, as long as they are at the start or
167 preceded by $ and at the end or followed by $. See make_fancy_name
168 in tree-sra.c. */
170 static void
171 dump_fancy_name (pretty_printer *pp, tree name)
173 int cnt = 0;
174 int length = IDENTIFIER_LENGTH (name);
175 const char *n = IDENTIFIER_POINTER (name);
178 n = strchr (n, 'D');
179 if (n == NULL)
180 break;
181 if (ISDIGIT (n[1])
182 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
184 int l = 2;
185 while (ISDIGIT (n[l]))
186 l++;
187 if (n[l] == '\0' || n[l] == '$')
189 cnt++;
190 length += 5 - l;
192 n += l;
194 else
195 n++;
197 while (1);
198 if (cnt == 0)
200 pp_tree_identifier (pp, name);
201 return;
204 char *str = XNEWVEC (char, length + 1);
205 char *p = str;
206 const char *q;
207 q = n = IDENTIFIER_POINTER (name);
210 q = strchr (q, 'D');
211 if (q == NULL)
212 break;
213 if (ISDIGIT (q[1])
214 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
216 int l = 2;
217 while (ISDIGIT (q[l]))
218 l++;
219 if (q[l] == '\0' || q[l] == '$')
221 memcpy (p, n, q - n);
222 memcpy (p + (q - n), "Dxxxx", 5);
223 p += (q - n) + 5;
224 n = q + l;
226 q += l;
228 else
229 q++;
231 while (1);
232 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
233 str[length] = '\0';
234 if (pp_translate_identifiers (pp))
236 const char *text = identifier_to_locale (str);
237 pp_append_text (pp, text, text + strlen (text));
239 else
240 pp_append_text (pp, str, str + length);
241 XDELETEVEC (str);
244 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
245 in FLAGS. */
247 static void
248 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
250 if (DECL_NAME (node))
252 if ((flags & TDF_ASMNAME)
253 && HAS_DECL_ASSEMBLER_NAME_P (node)
254 && DECL_ASSEMBLER_NAME_SET_P (node))
255 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
256 /* For DECL_NAMELESS names look for embedded uids in the
257 names and sanitize them for TDF_NOUID. */
258 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
259 dump_fancy_name (pp, DECL_NAME (node));
260 else
261 pp_tree_identifier (pp, DECL_NAME (node));
263 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
264 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
266 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
267 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
268 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
270 if (flags & TDF_NOUID)
271 pp_string (pp, "D#xxxx");
272 else
273 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
275 else
277 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
278 if (flags & TDF_NOUID)
279 pp_printf (pp, "%c.xxxx", c);
280 else
281 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
284 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
286 if (flags & TDF_NOUID)
287 pp_printf (pp, "ptD.xxxx");
288 else
289 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
293 /* Like the above, but used for pretty printing function calls. */
295 static void
296 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
298 if (CONVERT_EXPR_P (node))
299 node = TREE_OPERAND (node, 0);
300 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
301 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
302 else
303 dump_decl_name (pp, node, flags);
306 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
307 FLAGS are as in dump_generic_node. */
309 static void
310 dump_function_declaration (pretty_printer *pp, tree node,
311 int spc, dump_flags_t flags)
313 bool wrote_arg = false;
314 tree arg;
316 pp_space (pp);
317 pp_left_paren (pp);
319 /* Print the argument types. */
320 arg = TYPE_ARG_TYPES (node);
321 while (arg && arg != void_list_node && arg != error_mark_node)
323 if (wrote_arg)
325 pp_comma (pp);
326 pp_space (pp);
328 wrote_arg = true;
329 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
330 arg = TREE_CHAIN (arg);
333 /* Drop the trailing void_type_node if we had any previous argument. */
334 if (arg == void_list_node && !wrote_arg)
335 pp_string (pp, "void");
336 /* Properly dump vararg function types. */
337 else if (!arg && wrote_arg)
338 pp_string (pp, ", ...");
339 /* Avoid printing any arg for unprototyped functions. */
341 pp_right_paren (pp);
344 /* Dump the domain associated with an array. */
346 static void
347 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
349 pp_left_bracket (pp);
350 if (domain)
352 tree min = TYPE_MIN_VALUE (domain);
353 tree max = TYPE_MAX_VALUE (domain);
355 if (min && max
356 && integer_zerop (min)
357 && tree_fits_shwi_p (max))
358 pp_wide_integer (pp, tree_to_shwi (max) + 1);
359 else
361 if (min)
362 dump_generic_node (pp, min, spc, flags, false);
363 pp_colon (pp);
364 if (max)
365 dump_generic_node (pp, max, spc, flags, false);
368 else
369 pp_string (pp, "<unknown>");
370 pp_right_bracket (pp);
374 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
375 dump_generic_node. */
377 static void
378 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
380 const char *name;
382 switch (OMP_CLAUSE_CODE (clause))
384 case OMP_CLAUSE_PRIVATE:
385 name = "private";
386 goto print_remap;
387 case OMP_CLAUSE_SHARED:
388 name = "shared";
389 goto print_remap;
390 case OMP_CLAUSE_FIRSTPRIVATE:
391 name = "firstprivate";
392 goto print_remap;
393 case OMP_CLAUSE_LASTPRIVATE:
394 name = "lastprivate";
395 goto print_remap;
396 case OMP_CLAUSE_COPYIN:
397 name = "copyin";
398 goto print_remap;
399 case OMP_CLAUSE_COPYPRIVATE:
400 name = "copyprivate";
401 goto print_remap;
402 case OMP_CLAUSE_UNIFORM:
403 name = "uniform";
404 goto print_remap;
405 case OMP_CLAUSE_USE_DEVICE_PTR:
406 name = "use_device_ptr";
407 goto print_remap;
408 case OMP_CLAUSE_IS_DEVICE_PTR:
409 name = "is_device_ptr";
410 goto print_remap;
411 case OMP_CLAUSE__LOOPTEMP_:
412 name = "_looptemp_";
413 goto print_remap;
414 case OMP_CLAUSE_TO_DECLARE:
415 name = "to";
416 goto print_remap;
417 case OMP_CLAUSE_LINK:
418 name = "link";
419 goto print_remap;
420 print_remap:
421 pp_string (pp, name);
422 pp_left_paren (pp);
423 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
424 spc, flags, false);
425 pp_right_paren (pp);
426 break;
428 case OMP_CLAUSE_REDUCTION:
429 pp_string (pp, "reduction(");
430 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
432 pp_string (pp,
433 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
434 pp_colon (pp);
436 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
437 spc, flags, false);
438 pp_right_paren (pp);
439 break;
441 case OMP_CLAUSE_IF:
442 pp_string (pp, "if(");
443 switch (OMP_CLAUSE_IF_MODIFIER (clause))
445 case ERROR_MARK: break;
446 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
447 case OMP_TASK: pp_string (pp, "task:"); break;
448 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
449 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
450 case OMP_TARGET: pp_string (pp, "target:"); break;
451 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
452 case OMP_TARGET_ENTER_DATA:
453 pp_string (pp, "target enter data:"); break;
454 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
455 default: gcc_unreachable ();
457 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
458 spc, flags, false);
459 pp_right_paren (pp);
460 break;
462 case OMP_CLAUSE_NUM_THREADS:
463 pp_string (pp, "num_threads(");
464 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
465 spc, flags, false);
466 pp_right_paren (pp);
467 break;
469 case OMP_CLAUSE_NOWAIT:
470 pp_string (pp, "nowait");
471 break;
472 case OMP_CLAUSE_ORDERED:
473 pp_string (pp, "ordered");
474 if (OMP_CLAUSE_ORDERED_EXPR (clause))
476 pp_left_paren (pp);
477 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
478 spc, flags, false);
479 pp_right_paren (pp);
481 break;
483 case OMP_CLAUSE_DEFAULT:
484 pp_string (pp, "default(");
485 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
487 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
488 break;
489 case OMP_CLAUSE_DEFAULT_SHARED:
490 pp_string (pp, "shared");
491 break;
492 case OMP_CLAUSE_DEFAULT_NONE:
493 pp_string (pp, "none");
494 break;
495 case OMP_CLAUSE_DEFAULT_PRIVATE:
496 pp_string (pp, "private");
497 break;
498 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
499 pp_string (pp, "firstprivate");
500 break;
501 case OMP_CLAUSE_DEFAULT_PRESENT:
502 pp_string (pp, "present");
503 break;
504 default:
505 gcc_unreachable ();
507 pp_right_paren (pp);
508 break;
510 case OMP_CLAUSE_SCHEDULE:
511 pp_string (pp, "schedule(");
512 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
513 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
514 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
516 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
517 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
518 pp_string (pp, "monotonic");
519 else
520 pp_string (pp, "nonmonotonic");
521 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
522 pp_comma (pp);
523 else
524 pp_colon (pp);
526 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
527 pp_string (pp, "simd:");
529 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
531 case OMP_CLAUSE_SCHEDULE_STATIC:
532 pp_string (pp, "static");
533 break;
534 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
535 pp_string (pp, "dynamic");
536 break;
537 case OMP_CLAUSE_SCHEDULE_GUIDED:
538 pp_string (pp, "guided");
539 break;
540 case OMP_CLAUSE_SCHEDULE_RUNTIME:
541 pp_string (pp, "runtime");
542 break;
543 case OMP_CLAUSE_SCHEDULE_AUTO:
544 pp_string (pp, "auto");
545 break;
546 default:
547 gcc_unreachable ();
549 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
551 pp_comma (pp);
552 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
553 spc, flags, false);
555 pp_right_paren (pp);
556 break;
558 case OMP_CLAUSE_UNTIED:
559 pp_string (pp, "untied");
560 break;
562 case OMP_CLAUSE_COLLAPSE:
563 pp_string (pp, "collapse(");
564 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
565 spc, flags, false);
566 pp_right_paren (pp);
567 break;
569 case OMP_CLAUSE_FINAL:
570 pp_string (pp, "final(");
571 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
572 spc, flags, false);
573 pp_right_paren (pp);
574 break;
576 case OMP_CLAUSE_MERGEABLE:
577 pp_string (pp, "mergeable");
578 break;
580 case OMP_CLAUSE_LINEAR:
581 pp_string (pp, "linear(");
582 switch (OMP_CLAUSE_LINEAR_KIND (clause))
584 case OMP_CLAUSE_LINEAR_DEFAULT:
585 break;
586 case OMP_CLAUSE_LINEAR_REF:
587 pp_string (pp, "ref(");
588 break;
589 case OMP_CLAUSE_LINEAR_VAL:
590 pp_string (pp, "val(");
591 break;
592 case OMP_CLAUSE_LINEAR_UVAL:
593 pp_string (pp, "uval(");
594 break;
595 default:
596 gcc_unreachable ();
598 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
599 spc, flags, false);
600 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
601 pp_right_paren (pp);
602 pp_colon (pp);
603 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
604 spc, flags, false);
605 pp_right_paren (pp);
606 break;
608 case OMP_CLAUSE_ALIGNED:
609 pp_string (pp, "aligned(");
610 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
611 spc, flags, false);
612 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
614 pp_colon (pp);
615 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
616 spc, flags, false);
618 pp_right_paren (pp);
619 break;
621 case OMP_CLAUSE_DEPEND:
622 pp_string (pp, "depend(");
623 switch (OMP_CLAUSE_DEPEND_KIND (clause))
625 case OMP_CLAUSE_DEPEND_IN:
626 pp_string (pp, "in");
627 break;
628 case OMP_CLAUSE_DEPEND_OUT:
629 pp_string (pp, "out");
630 break;
631 case OMP_CLAUSE_DEPEND_INOUT:
632 pp_string (pp, "inout");
633 break;
634 case OMP_CLAUSE_DEPEND_SOURCE:
635 pp_string (pp, "source)");
636 return;
637 case OMP_CLAUSE_DEPEND_SINK:
638 pp_string (pp, "sink:");
639 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
640 if (TREE_CODE (t) == TREE_LIST)
642 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
643 if (TREE_PURPOSE (t) != integer_zero_node)
645 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
646 pp_minus (pp);
647 else
648 pp_plus (pp);
649 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
650 false);
652 if (TREE_CHAIN (t))
653 pp_comma (pp);
655 else
656 gcc_unreachable ();
657 pp_right_paren (pp);
658 return;
659 default:
660 gcc_unreachable ();
662 pp_colon (pp);
663 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
664 spc, flags, false);
665 pp_right_paren (pp);
666 break;
668 case OMP_CLAUSE_MAP:
669 pp_string (pp, "map(");
670 switch (OMP_CLAUSE_MAP_KIND (clause))
672 case GOMP_MAP_ALLOC:
673 case GOMP_MAP_POINTER:
674 pp_string (pp, "alloc");
675 break;
676 case GOMP_MAP_TO:
677 case GOMP_MAP_TO_PSET:
678 pp_string (pp, "to");
679 break;
680 case GOMP_MAP_FROM:
681 pp_string (pp, "from");
682 break;
683 case GOMP_MAP_TOFROM:
684 pp_string (pp, "tofrom");
685 break;
686 case GOMP_MAP_FORCE_ALLOC:
687 pp_string (pp, "force_alloc");
688 break;
689 case GOMP_MAP_FORCE_TO:
690 pp_string (pp, "force_to");
691 break;
692 case GOMP_MAP_FORCE_FROM:
693 pp_string (pp, "force_from");
694 break;
695 case GOMP_MAP_FORCE_TOFROM:
696 pp_string (pp, "force_tofrom");
697 break;
698 case GOMP_MAP_FORCE_PRESENT:
699 pp_string (pp, "force_present");
700 break;
701 case GOMP_MAP_DELETE:
702 pp_string (pp, "delete");
703 break;
704 case GOMP_MAP_FORCE_DEVICEPTR:
705 pp_string (pp, "force_deviceptr");
706 break;
707 case GOMP_MAP_ALWAYS_TO:
708 pp_string (pp, "always,to");
709 break;
710 case GOMP_MAP_ALWAYS_FROM:
711 pp_string (pp, "always,from");
712 break;
713 case GOMP_MAP_ALWAYS_TOFROM:
714 pp_string (pp, "always,tofrom");
715 break;
716 case GOMP_MAP_RELEASE:
717 pp_string (pp, "release");
718 break;
719 case GOMP_MAP_FIRSTPRIVATE_POINTER:
720 pp_string (pp, "firstprivate");
721 break;
722 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
723 pp_string (pp, "firstprivate ref");
724 break;
725 case GOMP_MAP_STRUCT:
726 pp_string (pp, "struct");
727 break;
728 case GOMP_MAP_ALWAYS_POINTER:
729 pp_string (pp, "always_pointer");
730 break;
731 case GOMP_MAP_DEVICE_RESIDENT:
732 pp_string (pp, "device_resident");
733 break;
734 case GOMP_MAP_LINK:
735 pp_string (pp, "link");
736 break;
737 default:
738 gcc_unreachable ();
740 pp_colon (pp);
741 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
742 spc, flags, false);
743 print_clause_size:
744 if (OMP_CLAUSE_SIZE (clause))
746 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
747 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
749 case GOMP_MAP_POINTER:
750 case GOMP_MAP_FIRSTPRIVATE_POINTER:
751 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
752 case GOMP_MAP_ALWAYS_POINTER:
753 pp_string (pp, " [pointer assign, bias: ");
754 break;
755 case GOMP_MAP_TO_PSET:
756 pp_string (pp, " [pointer set, len: ");
757 break;
758 default:
759 pp_string (pp, " [len: ");
760 break;
762 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
763 spc, flags, false);
764 pp_right_bracket (pp);
766 pp_right_paren (pp);
767 break;
769 case OMP_CLAUSE_FROM:
770 pp_string (pp, "from(");
771 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
772 spc, flags, false);
773 goto print_clause_size;
775 case OMP_CLAUSE_TO:
776 pp_string (pp, "to(");
777 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
778 spc, flags, false);
779 goto print_clause_size;
781 case OMP_CLAUSE__CACHE_:
782 pp_string (pp, "(");
783 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
784 spc, flags, false);
785 goto print_clause_size;
787 case OMP_CLAUSE_NUM_TEAMS:
788 pp_string (pp, "num_teams(");
789 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
790 spc, flags, false);
791 pp_right_paren (pp);
792 break;
794 case OMP_CLAUSE_THREAD_LIMIT:
795 pp_string (pp, "thread_limit(");
796 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
797 spc, flags, false);
798 pp_right_paren (pp);
799 break;
801 case OMP_CLAUSE_DEVICE:
802 pp_string (pp, "device(");
803 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
804 spc, flags, false);
805 pp_right_paren (pp);
806 break;
808 case OMP_CLAUSE_DIST_SCHEDULE:
809 pp_string (pp, "dist_schedule(static");
810 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
812 pp_comma (pp);
813 dump_generic_node (pp,
814 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
815 spc, flags, false);
817 pp_right_paren (pp);
818 break;
820 case OMP_CLAUSE_PROC_BIND:
821 pp_string (pp, "proc_bind(");
822 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
824 case OMP_CLAUSE_PROC_BIND_MASTER:
825 pp_string (pp, "master");
826 break;
827 case OMP_CLAUSE_PROC_BIND_CLOSE:
828 pp_string (pp, "close");
829 break;
830 case OMP_CLAUSE_PROC_BIND_SPREAD:
831 pp_string (pp, "spread");
832 break;
833 default:
834 gcc_unreachable ();
836 pp_right_paren (pp);
837 break;
839 case OMP_CLAUSE_SAFELEN:
840 pp_string (pp, "safelen(");
841 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
842 spc, flags, false);
843 pp_right_paren (pp);
844 break;
846 case OMP_CLAUSE_SIMDLEN:
847 pp_string (pp, "simdlen(");
848 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
849 spc, flags, false);
850 pp_right_paren (pp);
851 break;
853 case OMP_CLAUSE_PRIORITY:
854 pp_string (pp, "priority(");
855 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
856 spc, flags, false);
857 pp_right_paren (pp);
858 break;
860 case OMP_CLAUSE_GRAINSIZE:
861 pp_string (pp, "grainsize(");
862 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
863 spc, flags, false);
864 pp_right_paren (pp);
865 break;
867 case OMP_CLAUSE_NUM_TASKS:
868 pp_string (pp, "num_tasks(");
869 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
870 spc, flags, false);
871 pp_right_paren (pp);
872 break;
874 case OMP_CLAUSE_HINT:
875 pp_string (pp, "hint(");
876 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
877 spc, flags, false);
878 pp_right_paren (pp);
879 break;
881 case OMP_CLAUSE_DEFAULTMAP:
882 pp_string (pp, "defaultmap(tofrom:scalar)");
883 break;
885 case OMP_CLAUSE__SIMDUID_:
886 pp_string (pp, "_simduid_(");
887 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
888 spc, flags, false);
889 pp_right_paren (pp);
890 break;
892 case OMP_CLAUSE__SIMT_:
893 pp_string (pp, "_simt_");
894 break;
896 case OMP_CLAUSE_GANG:
897 pp_string (pp, "gang");
898 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
900 pp_string (pp, "(num: ");
901 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
902 spc, flags, false);
904 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
906 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
907 pp_left_paren (pp);
908 else
909 pp_space (pp);
910 pp_string (pp, "static:");
911 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
912 == integer_minus_one_node)
913 pp_character (pp, '*');
914 else
915 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
916 spc, flags, false);
918 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
919 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
920 pp_right_paren (pp);
921 break;
923 case OMP_CLAUSE_ASYNC:
924 pp_string (pp, "async");
925 if (OMP_CLAUSE_ASYNC_EXPR (clause))
927 pp_character(pp, '(');
928 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
929 spc, flags, false);
930 pp_character(pp, ')');
932 break;
934 case OMP_CLAUSE_AUTO:
935 case OMP_CLAUSE_SEQ:
936 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
937 break;
939 case OMP_CLAUSE_WAIT:
940 pp_string (pp, "wait(");
941 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
942 spc, flags, false);
943 pp_character(pp, ')');
944 break;
946 case OMP_CLAUSE_WORKER:
947 pp_string (pp, "worker");
948 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
950 pp_left_paren (pp);
951 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
952 spc, flags, false);
953 pp_right_paren (pp);
955 break;
957 case OMP_CLAUSE_VECTOR:
958 pp_string (pp, "vector");
959 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
961 pp_left_paren (pp);
962 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
963 spc, flags, false);
964 pp_right_paren (pp);
966 break;
968 case OMP_CLAUSE_NUM_GANGS:
969 pp_string (pp, "num_gangs(");
970 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
971 spc, flags, false);
972 pp_character (pp, ')');
973 break;
975 case OMP_CLAUSE_NUM_WORKERS:
976 pp_string (pp, "num_workers(");
977 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
978 spc, flags, false);
979 pp_character (pp, ')');
980 break;
982 case OMP_CLAUSE_VECTOR_LENGTH:
983 pp_string (pp, "vector_length(");
984 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
985 spc, flags, false);
986 pp_character (pp, ')');
987 break;
989 case OMP_CLAUSE_INBRANCH:
990 pp_string (pp, "inbranch");
991 break;
992 case OMP_CLAUSE_NOTINBRANCH:
993 pp_string (pp, "notinbranch");
994 break;
995 case OMP_CLAUSE_FOR:
996 pp_string (pp, "for");
997 break;
998 case OMP_CLAUSE_PARALLEL:
999 pp_string (pp, "parallel");
1000 break;
1001 case OMP_CLAUSE_SECTIONS:
1002 pp_string (pp, "sections");
1003 break;
1004 case OMP_CLAUSE_TASKGROUP:
1005 pp_string (pp, "taskgroup");
1006 break;
1007 case OMP_CLAUSE_NOGROUP:
1008 pp_string (pp, "nogroup");
1009 break;
1010 case OMP_CLAUSE_THREADS:
1011 pp_string (pp, "threads");
1012 break;
1013 case OMP_CLAUSE_SIMD:
1014 pp_string (pp, "simd");
1015 break;
1016 case OMP_CLAUSE_INDEPENDENT:
1017 pp_string (pp, "independent");
1018 break;
1019 case OMP_CLAUSE_TILE:
1020 pp_string (pp, "tile(");
1021 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1022 spc, flags, false);
1023 pp_right_paren (pp);
1024 break;
1026 case OMP_CLAUSE__GRIDDIM_:
1027 pp_string (pp, "_griddim_(");
1028 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1029 pp_colon (pp);
1030 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1031 false);
1032 pp_comma (pp);
1033 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1034 false);
1035 pp_right_paren (pp);
1036 break;
1038 default:
1039 /* Should never happen. */
1040 dump_generic_node (pp, clause, spc, flags, false);
1041 break;
1046 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1047 dump_generic_node. */
1049 void
1050 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1052 if (clause == NULL)
1053 return;
1055 pp_space (pp);
1056 while (1)
1058 dump_omp_clause (pp, clause, spc, flags);
1059 clause = OMP_CLAUSE_CHAIN (clause);
1060 if (clause == NULL)
1061 return;
1062 pp_space (pp);
1067 /* Dump location LOC to PP. */
1069 void
1070 dump_location (pretty_printer *pp, location_t loc)
1072 expanded_location xloc = expand_location (loc);
1074 pp_left_bracket (pp);
1075 if (xloc.file)
1077 pp_string (pp, xloc.file);
1078 pp_string (pp, ":");
1080 pp_decimal_int (pp, xloc.line);
1081 pp_colon (pp);
1082 pp_decimal_int (pp, xloc.column);
1083 pp_string (pp, "] ");
1087 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1088 dump_generic_node. */
1090 static void
1091 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1093 tree t;
1095 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1097 if (flags & TDF_ADDRESS)
1098 pp_printf (pp, "[%p] ", (void *) block);
1100 if (BLOCK_ABSTRACT (block))
1101 pp_string (pp, "[abstract] ");
1103 if (TREE_ASM_WRITTEN (block))
1104 pp_string (pp, "[written] ");
1106 if (flags & TDF_SLIM)
1107 return;
1109 if (BLOCK_SOURCE_LOCATION (block))
1110 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1112 newline_and_indent (pp, spc + 2);
1114 if (BLOCK_SUPERCONTEXT (block))
1116 pp_string (pp, "SUPERCONTEXT: ");
1117 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1118 flags | TDF_SLIM, false);
1119 newline_and_indent (pp, spc + 2);
1122 if (BLOCK_SUBBLOCKS (block))
1124 pp_string (pp, "SUBBLOCKS: ");
1125 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1127 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1128 pp_space (pp);
1130 newline_and_indent (pp, spc + 2);
1133 if (BLOCK_CHAIN (block))
1135 pp_string (pp, "SIBLINGS: ");
1136 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1138 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1139 pp_space (pp);
1141 newline_and_indent (pp, spc + 2);
1144 if (BLOCK_VARS (block))
1146 pp_string (pp, "VARS: ");
1147 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1149 dump_generic_node (pp, t, 0, flags, false);
1150 pp_space (pp);
1152 newline_and_indent (pp, spc + 2);
1155 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1157 unsigned i;
1158 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1160 pp_string (pp, "NONLOCALIZED_VARS: ");
1161 FOR_EACH_VEC_ELT (*nlv, i, t)
1163 dump_generic_node (pp, t, 0, flags, false);
1164 pp_space (pp);
1166 newline_and_indent (pp, spc + 2);
1169 if (BLOCK_ABSTRACT_ORIGIN (block))
1171 pp_string (pp, "ABSTRACT_ORIGIN: ");
1172 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1173 flags | TDF_SLIM, false);
1174 newline_and_indent (pp, spc + 2);
1177 if (BLOCK_FRAGMENT_ORIGIN (block))
1179 pp_string (pp, "FRAGMENT_ORIGIN: ");
1180 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1181 flags | TDF_SLIM, false);
1182 newline_and_indent (pp, spc + 2);
1185 if (BLOCK_FRAGMENT_CHAIN (block))
1187 pp_string (pp, "FRAGMENT_CHAIN: ");
1188 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1190 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1191 pp_space (pp);
1193 newline_and_indent (pp, spc + 2);
1198 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1199 indent. FLAGS specifies details to show in the dump (see TDF_* in
1200 dumpfile.h). If IS_STMT is true, the object printed is considered
1201 to be a statement and it is terminated by ';' if appropriate. */
1204 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1205 bool is_stmt)
1207 tree type;
1208 tree op0, op1;
1209 const char *str;
1210 bool is_expr;
1211 enum tree_code code;
1213 if (node == NULL_TREE)
1214 return spc;
1216 is_expr = EXPR_P (node);
1218 if (is_stmt && (flags & TDF_STMTADDR))
1219 pp_printf (pp, "<&%p> ", (void *)node);
1221 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1222 dump_location (pp, EXPR_LOCATION (node));
1224 code = TREE_CODE (node);
1225 switch (code)
1227 case ERROR_MARK:
1228 pp_string (pp, "<<< error >>>");
1229 break;
1231 case IDENTIFIER_NODE:
1232 pp_tree_identifier (pp, node);
1233 break;
1235 case TREE_LIST:
1236 while (node && node != error_mark_node)
1238 if (TREE_PURPOSE (node))
1240 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1241 pp_space (pp);
1243 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1244 node = TREE_CHAIN (node);
1245 if (node && TREE_CODE (node) == TREE_LIST)
1247 pp_comma (pp);
1248 pp_space (pp);
1251 break;
1253 case TREE_BINFO:
1254 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1255 break;
1257 case TREE_VEC:
1259 size_t i;
1260 if (TREE_VEC_LENGTH (node) > 0)
1262 size_t len = TREE_VEC_LENGTH (node);
1263 for (i = 0; i < len - 1; i++)
1265 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1266 false);
1267 pp_comma (pp);
1268 pp_space (pp);
1270 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1271 flags, false);
1274 break;
1276 case VOID_TYPE:
1277 case POINTER_BOUNDS_TYPE:
1278 case INTEGER_TYPE:
1279 case REAL_TYPE:
1280 case FIXED_POINT_TYPE:
1281 case COMPLEX_TYPE:
1282 case VECTOR_TYPE:
1283 case ENUMERAL_TYPE:
1284 case BOOLEAN_TYPE:
1286 unsigned int quals = TYPE_QUALS (node);
1287 enum tree_code_class tclass;
1289 if (quals & TYPE_QUAL_ATOMIC)
1290 pp_string (pp, "atomic ");
1291 if (quals & TYPE_QUAL_CONST)
1292 pp_string (pp, "const ");
1293 else if (quals & TYPE_QUAL_VOLATILE)
1294 pp_string (pp, "volatile ");
1295 else if (quals & TYPE_QUAL_RESTRICT)
1296 pp_string (pp, "restrict ");
1298 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1300 pp_string (pp, "<address-space-");
1301 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1302 pp_string (pp, "> ");
1305 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1307 if (tclass == tcc_declaration)
1309 if (DECL_NAME (node))
1310 dump_decl_name (pp, node, flags);
1311 else
1312 pp_string (pp, "<unnamed type decl>");
1314 else if (tclass == tcc_type)
1316 if (TYPE_NAME (node))
1318 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1319 pp_tree_identifier (pp, TYPE_NAME (node));
1320 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1321 && DECL_NAME (TYPE_NAME (node)))
1322 dump_decl_name (pp, TYPE_NAME (node), flags);
1323 else
1324 pp_string (pp, "<unnamed type>");
1326 else if (TREE_CODE (node) == VECTOR_TYPE)
1328 pp_string (pp, "vector");
1329 pp_left_paren (pp);
1330 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1331 pp_string (pp, ") ");
1332 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1334 else if (TREE_CODE (node) == INTEGER_TYPE)
1336 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1337 pp_string (pp, (TYPE_UNSIGNED (node)
1338 ? "unsigned char"
1339 : "signed char"));
1340 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1341 pp_string (pp, (TYPE_UNSIGNED (node)
1342 ? "unsigned short"
1343 : "signed short"));
1344 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1345 pp_string (pp, (TYPE_UNSIGNED (node)
1346 ? "unsigned int"
1347 : "signed int"));
1348 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1349 pp_string (pp, (TYPE_UNSIGNED (node)
1350 ? "unsigned long"
1351 : "signed long"));
1352 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1353 pp_string (pp, (TYPE_UNSIGNED (node)
1354 ? "unsigned long long"
1355 : "signed long long"));
1356 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1357 && pow2p_hwi (TYPE_PRECISION (node)))
1359 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1360 pp_decimal_int (pp, TYPE_PRECISION (node));
1361 pp_string (pp, "_t");
1363 else
1365 pp_string (pp, (TYPE_UNSIGNED (node)
1366 ? "<unnamed-unsigned:"
1367 : "<unnamed-signed:"));
1368 pp_decimal_int (pp, TYPE_PRECISION (node));
1369 pp_greater (pp);
1372 else if (TREE_CODE (node) == COMPLEX_TYPE)
1374 pp_string (pp, "__complex__ ");
1375 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1377 else if (TREE_CODE (node) == REAL_TYPE)
1379 pp_string (pp, "<float:");
1380 pp_decimal_int (pp, TYPE_PRECISION (node));
1381 pp_greater (pp);
1383 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1385 pp_string (pp, "<fixed-point-");
1386 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1387 pp_decimal_int (pp, TYPE_PRECISION (node));
1388 pp_greater (pp);
1390 else if (TREE_CODE (node) == VOID_TYPE)
1391 pp_string (pp, "void");
1392 else
1393 pp_string (pp, "<unnamed type>");
1395 break;
1398 case POINTER_TYPE:
1399 case REFERENCE_TYPE:
1400 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1402 if (TREE_TYPE (node) == NULL)
1404 pp_string (pp, str);
1405 pp_string (pp, "<null type>");
1407 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1409 tree fnode = TREE_TYPE (node);
1411 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1412 pp_space (pp);
1413 pp_left_paren (pp);
1414 pp_string (pp, str);
1415 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1416 dump_decl_name (pp, TYPE_NAME (node), flags);
1417 else if (flags & TDF_NOUID)
1418 pp_printf (pp, "<Txxxx>");
1419 else
1420 pp_printf (pp, "<T%x>", TYPE_UID (node));
1422 pp_right_paren (pp);
1423 dump_function_declaration (pp, fnode, spc, flags);
1425 else
1427 unsigned int quals = TYPE_QUALS (node);
1429 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1430 pp_space (pp);
1431 pp_string (pp, str);
1433 if (quals & TYPE_QUAL_CONST)
1434 pp_string (pp, " const");
1435 if (quals & TYPE_QUAL_VOLATILE)
1436 pp_string (pp, " volatile");
1437 if (quals & TYPE_QUAL_RESTRICT)
1438 pp_string (pp, " restrict");
1440 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1442 pp_string (pp, " <address-space-");
1443 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1444 pp_greater (pp);
1447 if (TYPE_REF_CAN_ALIAS_ALL (node))
1448 pp_string (pp, " {ref-all}");
1450 break;
1452 case OFFSET_TYPE:
1453 NIY;
1454 break;
1456 case MEM_REF:
1458 if (flags & TDF_GIMPLE)
1460 pp_string (pp, "__MEM <");
1461 dump_generic_node (pp, TREE_TYPE (node),
1462 spc, flags | TDF_SLIM, false);
1463 if (TYPE_ALIGN (TREE_TYPE (node))
1464 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1466 pp_string (pp, ", ");
1467 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1469 pp_greater (pp);
1470 pp_string (pp, " (");
1471 if (TREE_TYPE (TREE_OPERAND (node, 0))
1472 != TREE_TYPE (TREE_OPERAND (node, 1)))
1474 pp_left_paren (pp);
1475 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1476 spc, flags | TDF_SLIM, false);
1477 pp_right_paren (pp);
1479 dump_generic_node (pp, TREE_OPERAND (node, 0),
1480 spc, flags | TDF_SLIM, false);
1481 if (! integer_zerop (TREE_OPERAND (node, 1)))
1483 pp_string (pp, " + ");
1484 dump_generic_node (pp, TREE_OPERAND (node, 1),
1485 spc, flags | TDF_SLIM, false);
1487 pp_right_paren (pp);
1489 else if (integer_zerop (TREE_OPERAND (node, 1))
1490 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1491 infer them and MEM_ATTR caching will share MEM_REFs
1492 with differently-typed op0s. */
1493 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1494 /* Released SSA_NAMES have no TREE_TYPE. */
1495 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1496 /* Same pointer types, but ignoring POINTER_TYPE vs.
1497 REFERENCE_TYPE. */
1498 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1499 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1500 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1501 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1502 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1503 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1504 /* Same value types ignoring qualifiers. */
1505 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1506 == TYPE_MAIN_VARIANT
1507 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1508 && (!(flags & TDF_ALIAS)
1509 || MR_DEPENDENCE_CLIQUE (node) == 0))
1511 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1513 pp_star (pp);
1514 dump_generic_node (pp, TREE_OPERAND (node, 0),
1515 spc, flags, false);
1517 else
1518 dump_generic_node (pp,
1519 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1520 spc, flags, false);
1522 else
1524 tree ptype;
1526 pp_string (pp, "MEM[");
1527 pp_left_paren (pp);
1528 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1529 dump_generic_node (pp, ptype,
1530 spc, flags | TDF_SLIM, false);
1531 pp_right_paren (pp);
1532 dump_generic_node (pp, TREE_OPERAND (node, 0),
1533 spc, flags, false);
1534 if (!integer_zerop (TREE_OPERAND (node, 1)))
1536 pp_string (pp, " + ");
1537 dump_generic_node (pp, TREE_OPERAND (node, 1),
1538 spc, flags, false);
1540 if ((flags & TDF_ALIAS)
1541 && MR_DEPENDENCE_CLIQUE (node) != 0)
1543 pp_string (pp, " clique ");
1544 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1545 pp_string (pp, " base ");
1546 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1548 pp_right_bracket (pp);
1550 break;
1553 case TARGET_MEM_REF:
1555 const char *sep = "";
1556 tree tmp;
1558 pp_string (pp, "MEM[");
1560 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1562 pp_string (pp, sep);
1563 sep = ", ";
1564 pp_string (pp, "symbol: ");
1565 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1566 spc, flags, false);
1568 else
1570 pp_string (pp, sep);
1571 sep = ", ";
1572 pp_string (pp, "base: ");
1573 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1575 tmp = TMR_INDEX2 (node);
1576 if (tmp)
1578 pp_string (pp, sep);
1579 sep = ", ";
1580 pp_string (pp, "base: ");
1581 dump_generic_node (pp, tmp, spc, flags, false);
1583 tmp = TMR_INDEX (node);
1584 if (tmp)
1586 pp_string (pp, sep);
1587 sep = ", ";
1588 pp_string (pp, "index: ");
1589 dump_generic_node (pp, tmp, spc, flags, false);
1591 tmp = TMR_STEP (node);
1592 if (tmp)
1594 pp_string (pp, sep);
1595 sep = ", ";
1596 pp_string (pp, "step: ");
1597 dump_generic_node (pp, tmp, spc, flags, false);
1599 tmp = TMR_OFFSET (node);
1600 if (tmp)
1602 pp_string (pp, sep);
1603 sep = ", ";
1604 pp_string (pp, "offset: ");
1605 dump_generic_node (pp, tmp, spc, flags, false);
1607 pp_right_bracket (pp);
1609 break;
1611 case ARRAY_TYPE:
1613 tree tmp;
1615 /* Print the innermost component type. */
1616 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1617 tmp = TREE_TYPE (tmp))
1619 dump_generic_node (pp, tmp, spc, flags, false);
1621 /* Print the dimensions. */
1622 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1623 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1624 break;
1627 case RECORD_TYPE:
1628 case UNION_TYPE:
1629 case QUAL_UNION_TYPE:
1631 unsigned int quals = TYPE_QUALS (node);
1633 if (quals & TYPE_QUAL_ATOMIC)
1634 pp_string (pp, "atomic ");
1635 if (quals & TYPE_QUAL_CONST)
1636 pp_string (pp, "const ");
1637 if (quals & TYPE_QUAL_VOLATILE)
1638 pp_string (pp, "volatile ");
1640 /* Print the name of the structure. */
1641 if (TREE_CODE (node) == RECORD_TYPE)
1642 pp_string (pp, "struct ");
1643 else if (TREE_CODE (node) == UNION_TYPE)
1644 pp_string (pp, "union ");
1646 if (TYPE_NAME (node))
1647 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1648 else if (!(flags & TDF_SLIM))
1649 /* FIXME: If we eliminate the 'else' above and attempt
1650 to show the fields for named types, we may get stuck
1651 following a cycle of pointers to structs. The alleged
1652 self-reference check in print_struct_decl will not detect
1653 cycles involving more than one pointer or struct type. */
1654 print_struct_decl (pp, node, spc, flags);
1655 break;
1658 case LANG_TYPE:
1659 NIY;
1660 break;
1662 case INTEGER_CST:
1663 if (flags & TDF_GIMPLE
1664 && (POINTER_TYPE_P (TREE_TYPE (node))
1665 || (TYPE_PRECISION (TREE_TYPE (node))
1666 < TYPE_PRECISION (integer_type_node))
1667 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1669 pp_string (pp, "_Literal (");
1670 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1671 pp_string (pp, ") ");
1673 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1674 && ! (flags & TDF_GIMPLE))
1676 /* In the case of a pointer, one may want to divide by the
1677 size of the pointed-to type. Unfortunately, this not
1678 straightforward. The C front-end maps expressions
1680 (int *) 5
1681 int *p; (p + 5)
1683 in such a way that the two INTEGER_CST nodes for "5" have
1684 different values but identical types. In the latter
1685 case, the 5 is multiplied by sizeof (int) in c-common.c
1686 (pointer_int_sum) to convert it to a byte address, and
1687 yet the type of the node is left unchanged. Argh. What
1688 is consistent though is that the number value corresponds
1689 to bytes (UNITS) offset.
1691 NB: Neither of the following divisors can be trivially
1692 used to recover the original literal:
1694 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1695 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1696 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1697 pp_string (pp, "B"); /* pseudo-unit */
1699 else if (tree_fits_shwi_p (node))
1700 pp_wide_integer (pp, tree_to_shwi (node));
1701 else if (tree_fits_uhwi_p (node))
1702 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1703 else
1705 wide_int val = wi::to_wide (node);
1707 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1709 pp_minus (pp);
1710 val = -val;
1712 print_hex (val, pp_buffer (pp)->digit_buffer);
1713 pp_string (pp, pp_buffer (pp)->digit_buffer);
1715 if ((flags & TDF_GIMPLE)
1716 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1717 || (TYPE_PRECISION (TREE_TYPE (node))
1718 < TYPE_PRECISION (integer_type_node))
1719 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1721 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1722 pp_character (pp, 'u');
1723 if (TYPE_PRECISION (TREE_TYPE (node))
1724 == TYPE_PRECISION (unsigned_type_node))
1726 else if (TYPE_PRECISION (TREE_TYPE (node))
1727 == TYPE_PRECISION (long_unsigned_type_node))
1728 pp_character (pp, 'l');
1729 else if (TYPE_PRECISION (TREE_TYPE (node))
1730 == TYPE_PRECISION (long_long_unsigned_type_node))
1731 pp_string (pp, "ll");
1733 if (TREE_OVERFLOW (node))
1734 pp_string (pp, "(OVF)");
1735 break;
1737 case REAL_CST:
1738 /* Code copied from print_node. */
1740 REAL_VALUE_TYPE d;
1741 if (TREE_OVERFLOW (node))
1742 pp_string (pp, " overflow");
1744 d = TREE_REAL_CST (node);
1745 if (REAL_VALUE_ISINF (d))
1746 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1747 else if (REAL_VALUE_ISNAN (d))
1748 pp_string (pp, " Nan");
1749 else
1751 char string[100];
1752 real_to_decimal (string, &d, sizeof (string), 0, 1);
1753 pp_string (pp, string);
1755 break;
1758 case FIXED_CST:
1760 char string[100];
1761 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1762 pp_string (pp, string);
1763 break;
1766 case COMPLEX_CST:
1767 pp_string (pp, "__complex__ (");
1768 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1769 pp_string (pp, ", ");
1770 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1771 pp_right_paren (pp);
1772 break;
1774 case STRING_CST:
1775 pp_string (pp, "\"");
1776 pretty_print_string (pp, TREE_STRING_POINTER (node));
1777 pp_string (pp, "\"");
1778 break;
1780 case VECTOR_CST:
1782 unsigned i;
1783 pp_string (pp, "{ ");
1784 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1786 if (i != 0)
1787 pp_string (pp, ", ");
1788 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1789 spc, flags, false);
1791 pp_string (pp, " }");
1793 break;
1795 case FUNCTION_TYPE:
1796 case METHOD_TYPE:
1797 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1798 pp_space (pp);
1799 if (TREE_CODE (node) == METHOD_TYPE)
1801 if (TYPE_METHOD_BASETYPE (node))
1802 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1803 flags);
1804 else
1805 pp_string (pp, "<null method basetype>");
1806 pp_colon_colon (pp);
1808 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1809 dump_decl_name (pp, TYPE_NAME (node), flags);
1810 else if (flags & TDF_NOUID)
1811 pp_printf (pp, "<Txxxx>");
1812 else
1813 pp_printf (pp, "<T%x>", TYPE_UID (node));
1814 dump_function_declaration (pp, node, spc, flags);
1815 break;
1817 case FUNCTION_DECL:
1818 case CONST_DECL:
1819 dump_decl_name (pp, node, flags);
1820 break;
1822 case LABEL_DECL:
1823 if (DECL_NAME (node))
1824 dump_decl_name (pp, node, flags);
1825 else if (LABEL_DECL_UID (node) != -1)
1827 if (flags & TDF_GIMPLE)
1828 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1829 else
1830 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1832 else
1834 if (flags & TDF_NOUID)
1835 pp_string (pp, "<D.xxxx>");
1836 else
1838 if (flags & TDF_GIMPLE)
1839 pp_printf (pp, "<D%u>", DECL_UID (node));
1840 else
1841 pp_printf (pp, "<D.%u>", DECL_UID (node));
1844 break;
1846 case TYPE_DECL:
1847 if (DECL_IS_BUILTIN (node))
1849 /* Don't print the declaration of built-in types. */
1850 break;
1852 if (DECL_NAME (node))
1853 dump_decl_name (pp, node, flags);
1854 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1856 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1857 ? "union" : "struct "));
1858 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1860 else
1861 pp_string (pp, "<anon>");
1862 break;
1864 case VAR_DECL:
1865 case PARM_DECL:
1866 case FIELD_DECL:
1867 case DEBUG_EXPR_DECL:
1868 case NAMESPACE_DECL:
1869 case NAMELIST_DECL:
1870 dump_decl_name (pp, node, flags);
1871 break;
1873 case RESULT_DECL:
1874 pp_string (pp, "<retval>");
1875 break;
1877 case COMPONENT_REF:
1878 op0 = TREE_OPERAND (node, 0);
1879 str = ".";
1880 if (op0
1881 && (TREE_CODE (op0) == INDIRECT_REF
1882 || (TREE_CODE (op0) == MEM_REF
1883 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1884 && integer_zerop (TREE_OPERAND (op0, 1))
1885 /* Dump the types of INTEGER_CSTs explicitly, for we
1886 can't infer them and MEM_ATTR caching will share
1887 MEM_REFs with differently-typed op0s. */
1888 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1889 /* Released SSA_NAMES have no TREE_TYPE. */
1890 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1891 /* Same pointer types, but ignoring POINTER_TYPE vs.
1892 REFERENCE_TYPE. */
1893 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1894 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1895 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1896 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1897 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1898 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1899 /* Same value types ignoring qualifiers. */
1900 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1901 == TYPE_MAIN_VARIANT
1902 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1903 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1905 op0 = TREE_OPERAND (op0, 0);
1906 str = "->";
1908 if (op_prio (op0) < op_prio (node))
1909 pp_left_paren (pp);
1910 dump_generic_node (pp, op0, spc, flags, false);
1911 if (op_prio (op0) < op_prio (node))
1912 pp_right_paren (pp);
1913 pp_string (pp, str);
1914 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1915 op0 = component_ref_field_offset (node);
1916 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1918 pp_string (pp, "{off: ");
1919 dump_generic_node (pp, op0, spc, flags, false);
1920 pp_right_brace (pp);
1922 break;
1924 case BIT_FIELD_REF:
1925 pp_string (pp, "BIT_FIELD_REF <");
1926 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1927 pp_string (pp, ", ");
1928 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1929 pp_string (pp, ", ");
1930 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1931 pp_greater (pp);
1932 break;
1934 case BIT_INSERT_EXPR:
1935 pp_string (pp, "BIT_INSERT_EXPR <");
1936 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1937 pp_string (pp, ", ");
1938 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1939 pp_string (pp, ", ");
1940 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1941 pp_string (pp, " (");
1942 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1943 pp_decimal_int (pp,
1944 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1945 else
1946 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1947 spc, flags, false);
1948 pp_string (pp, " bits)>");
1949 break;
1951 case ARRAY_REF:
1952 case ARRAY_RANGE_REF:
1953 op0 = TREE_OPERAND (node, 0);
1954 if (op_prio (op0) < op_prio (node))
1955 pp_left_paren (pp);
1956 dump_generic_node (pp, op0, spc, flags, false);
1957 if (op_prio (op0) < op_prio (node))
1958 pp_right_paren (pp);
1959 pp_left_bracket (pp);
1960 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1961 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1962 pp_string (pp, " ...");
1963 pp_right_bracket (pp);
1965 op0 = array_ref_low_bound (node);
1966 op1 = array_ref_element_size (node);
1968 if (!integer_zerop (op0)
1969 || TREE_OPERAND (node, 2)
1970 || TREE_OPERAND (node, 3))
1972 pp_string (pp, "{lb: ");
1973 dump_generic_node (pp, op0, spc, flags, false);
1974 pp_string (pp, " sz: ");
1975 dump_generic_node (pp, op1, spc, flags, false);
1976 pp_right_brace (pp);
1978 break;
1980 case CONSTRUCTOR:
1982 unsigned HOST_WIDE_INT ix;
1983 tree field, val;
1984 bool is_struct_init = false;
1985 bool is_array_init = false;
1986 widest_int curidx;
1987 pp_left_brace (pp);
1988 if (TREE_CLOBBER_P (node))
1989 pp_string (pp, "CLOBBER");
1990 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1991 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1992 is_struct_init = true;
1993 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1994 && TYPE_DOMAIN (TREE_TYPE (node))
1995 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1996 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1997 == INTEGER_CST)
1999 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2000 is_array_init = true;
2001 curidx = wi::to_widest (minv);
2003 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2005 if (field)
2007 if (is_struct_init)
2009 pp_dot (pp);
2010 dump_generic_node (pp, field, spc, flags, false);
2011 pp_equal (pp);
2013 else if (is_array_init
2014 && (TREE_CODE (field) != INTEGER_CST
2015 || curidx != wi::to_widest (field)))
2017 pp_left_bracket (pp);
2018 if (TREE_CODE (field) == RANGE_EXPR)
2020 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2021 flags, false);
2022 pp_string (pp, " ... ");
2023 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2024 flags, false);
2025 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2026 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2028 else
2029 dump_generic_node (pp, field, spc, flags, false);
2030 if (TREE_CODE (field) == INTEGER_CST)
2031 curidx = wi::to_widest (field);
2032 pp_string (pp, "]=");
2035 if (is_array_init)
2036 curidx += 1;
2037 if (val && TREE_CODE (val) == ADDR_EXPR)
2038 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2039 val = TREE_OPERAND (val, 0);
2040 if (val && TREE_CODE (val) == FUNCTION_DECL)
2041 dump_decl_name (pp, val, flags);
2042 else
2043 dump_generic_node (pp, val, spc, flags, false);
2044 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2046 pp_comma (pp);
2047 pp_space (pp);
2050 pp_right_brace (pp);
2052 break;
2054 case COMPOUND_EXPR:
2056 tree *tp;
2057 if (flags & TDF_SLIM)
2059 pp_string (pp, "<COMPOUND_EXPR>");
2060 break;
2063 dump_generic_node (pp, TREE_OPERAND (node, 0),
2064 spc, flags, !(flags & TDF_SLIM));
2065 if (flags & TDF_SLIM)
2066 newline_and_indent (pp, spc);
2067 else
2069 pp_comma (pp);
2070 pp_space (pp);
2073 for (tp = &TREE_OPERAND (node, 1);
2074 TREE_CODE (*tp) == COMPOUND_EXPR;
2075 tp = &TREE_OPERAND (*tp, 1))
2077 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2078 spc, flags, !(flags & TDF_SLIM));
2079 if (flags & TDF_SLIM)
2080 newline_and_indent (pp, spc);
2081 else
2083 pp_comma (pp);
2084 pp_space (pp);
2088 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2090 break;
2092 case STATEMENT_LIST:
2094 tree_stmt_iterator si;
2095 bool first = true;
2097 if (flags & TDF_SLIM)
2099 pp_string (pp, "<STATEMENT_LIST>");
2100 break;
2103 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2105 if (!first)
2106 newline_and_indent (pp, spc);
2107 else
2108 first = false;
2109 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2112 break;
2114 case MODIFY_EXPR:
2115 case INIT_EXPR:
2116 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2117 false);
2118 pp_space (pp);
2119 pp_equal (pp);
2120 pp_space (pp);
2121 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2122 false);
2123 break;
2125 case TARGET_EXPR:
2126 pp_string (pp, "TARGET_EXPR <");
2127 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2128 pp_comma (pp);
2129 pp_space (pp);
2130 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2131 pp_greater (pp);
2132 break;
2134 case DECL_EXPR:
2135 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2136 is_stmt = false;
2137 break;
2139 case COND_EXPR:
2140 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2142 pp_string (pp, "if (");
2143 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2144 pp_right_paren (pp);
2145 /* The lowered cond_exprs should always be printed in full. */
2146 if (COND_EXPR_THEN (node)
2147 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2148 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2149 && COND_EXPR_ELSE (node)
2150 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2151 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2153 pp_space (pp);
2154 dump_generic_node (pp, COND_EXPR_THEN (node),
2155 0, flags, true);
2156 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2158 pp_string (pp, " else ");
2159 dump_generic_node (pp, COND_EXPR_ELSE (node),
2160 0, flags, true);
2163 else if (!(flags & TDF_SLIM))
2165 /* Output COND_EXPR_THEN. */
2166 if (COND_EXPR_THEN (node))
2168 newline_and_indent (pp, spc+2);
2169 pp_left_brace (pp);
2170 newline_and_indent (pp, spc+4);
2171 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2172 flags, true);
2173 newline_and_indent (pp, spc+2);
2174 pp_right_brace (pp);
2177 /* Output COND_EXPR_ELSE. */
2178 if (COND_EXPR_ELSE (node)
2179 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2181 newline_and_indent (pp, spc);
2182 pp_string (pp, "else");
2183 newline_and_indent (pp, spc+2);
2184 pp_left_brace (pp);
2185 newline_and_indent (pp, spc+4);
2186 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2187 flags, true);
2188 newline_and_indent (pp, spc+2);
2189 pp_right_brace (pp);
2192 is_expr = false;
2194 else
2196 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2197 pp_space (pp);
2198 pp_question (pp);
2199 pp_space (pp);
2200 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2201 pp_space (pp);
2202 pp_colon (pp);
2203 pp_space (pp);
2204 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2206 break;
2208 case BIND_EXPR:
2209 pp_left_brace (pp);
2210 if (!(flags & TDF_SLIM))
2212 if (BIND_EXPR_VARS (node))
2214 pp_newline (pp);
2216 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2218 print_declaration (pp, op0, spc+2, flags);
2219 pp_newline (pp);
2223 newline_and_indent (pp, spc+2);
2224 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2225 newline_and_indent (pp, spc);
2226 pp_right_brace (pp);
2228 is_expr = false;
2229 break;
2231 case CALL_EXPR:
2232 if (CALL_EXPR_FN (node) != NULL_TREE)
2233 print_call_name (pp, CALL_EXPR_FN (node), flags);
2234 else
2235 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2237 /* Print parameters. */
2238 pp_space (pp);
2239 pp_left_paren (pp);
2241 tree arg;
2242 call_expr_arg_iterator iter;
2243 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2245 dump_generic_node (pp, arg, spc, flags, false);
2246 if (more_call_expr_args_p (&iter))
2248 pp_comma (pp);
2249 pp_space (pp);
2253 if (CALL_EXPR_VA_ARG_PACK (node))
2255 if (call_expr_nargs (node) > 0)
2257 pp_comma (pp);
2258 pp_space (pp);
2260 pp_string (pp, "__builtin_va_arg_pack ()");
2262 pp_right_paren (pp);
2264 op1 = CALL_EXPR_STATIC_CHAIN (node);
2265 if (op1)
2267 pp_string (pp, " [static-chain: ");
2268 dump_generic_node (pp, op1, spc, flags, false);
2269 pp_right_bracket (pp);
2272 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2273 pp_string (pp, " [return slot optimization]");
2274 if (CALL_EXPR_TAILCALL (node))
2275 pp_string (pp, " [tail call]");
2276 break;
2278 case WITH_CLEANUP_EXPR:
2279 NIY;
2280 break;
2282 case CLEANUP_POINT_EXPR:
2283 pp_string (pp, "<<cleanup_point ");
2284 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2285 pp_string (pp, ">>");
2286 break;
2288 case PLACEHOLDER_EXPR:
2289 pp_string (pp, "<PLACEHOLDER_EXPR ");
2290 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2291 pp_greater (pp);
2292 break;
2294 /* Binary arithmetic and logic expressions. */
2295 case WIDEN_SUM_EXPR:
2296 case WIDEN_MULT_EXPR:
2297 case MULT_EXPR:
2298 case MULT_HIGHPART_EXPR:
2299 case PLUS_EXPR:
2300 case POINTER_PLUS_EXPR:
2301 case POINTER_DIFF_EXPR:
2302 case MINUS_EXPR:
2303 case TRUNC_DIV_EXPR:
2304 case CEIL_DIV_EXPR:
2305 case FLOOR_DIV_EXPR:
2306 case ROUND_DIV_EXPR:
2307 case TRUNC_MOD_EXPR:
2308 case CEIL_MOD_EXPR:
2309 case FLOOR_MOD_EXPR:
2310 case ROUND_MOD_EXPR:
2311 case RDIV_EXPR:
2312 case EXACT_DIV_EXPR:
2313 case LSHIFT_EXPR:
2314 case RSHIFT_EXPR:
2315 case LROTATE_EXPR:
2316 case RROTATE_EXPR:
2317 case WIDEN_LSHIFT_EXPR:
2318 case BIT_IOR_EXPR:
2319 case BIT_XOR_EXPR:
2320 case BIT_AND_EXPR:
2321 case TRUTH_ANDIF_EXPR:
2322 case TRUTH_ORIF_EXPR:
2323 case TRUTH_AND_EXPR:
2324 case TRUTH_OR_EXPR:
2325 case TRUTH_XOR_EXPR:
2326 case LT_EXPR:
2327 case LE_EXPR:
2328 case GT_EXPR:
2329 case GE_EXPR:
2330 case EQ_EXPR:
2331 case NE_EXPR:
2332 case UNLT_EXPR:
2333 case UNLE_EXPR:
2334 case UNGT_EXPR:
2335 case UNGE_EXPR:
2336 case UNEQ_EXPR:
2337 case LTGT_EXPR:
2338 case ORDERED_EXPR:
2339 case UNORDERED_EXPR:
2341 const char *op = op_symbol (node);
2342 op0 = TREE_OPERAND (node, 0);
2343 op1 = TREE_OPERAND (node, 1);
2345 /* When the operands are expressions with less priority,
2346 keep semantics of the tree representation. */
2347 if (op_prio (op0) <= op_prio (node))
2349 pp_left_paren (pp);
2350 dump_generic_node (pp, op0, spc, flags, false);
2351 pp_right_paren (pp);
2353 else
2354 dump_generic_node (pp, op0, spc, flags, false);
2356 pp_space (pp);
2357 pp_string (pp, op);
2358 pp_space (pp);
2360 /* When the operands are expressions with less priority,
2361 keep semantics of the tree representation. */
2362 if (op_prio (op1) <= op_prio (node))
2364 pp_left_paren (pp);
2365 dump_generic_node (pp, op1, spc, flags, false);
2366 pp_right_paren (pp);
2368 else
2369 dump_generic_node (pp, op1, spc, flags, false);
2371 break;
2373 /* Unary arithmetic and logic expressions. */
2374 case NEGATE_EXPR:
2375 case BIT_NOT_EXPR:
2376 case TRUTH_NOT_EXPR:
2377 case ADDR_EXPR:
2378 case PREDECREMENT_EXPR:
2379 case PREINCREMENT_EXPR:
2380 case INDIRECT_REF:
2381 if (TREE_CODE (node) == ADDR_EXPR
2382 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2383 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2384 ; /* Do not output '&' for strings and function pointers. */
2385 else
2386 pp_string (pp, op_symbol (node));
2388 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2390 pp_left_paren (pp);
2391 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2392 pp_right_paren (pp);
2394 else
2395 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2396 break;
2398 case POSTDECREMENT_EXPR:
2399 case POSTINCREMENT_EXPR:
2400 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2402 pp_left_paren (pp);
2403 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2404 pp_right_paren (pp);
2406 else
2407 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2408 pp_string (pp, op_symbol (node));
2409 break;
2411 case MIN_EXPR:
2412 pp_string (pp, "MIN_EXPR <");
2413 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2414 pp_string (pp, ", ");
2415 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2416 pp_greater (pp);
2417 break;
2419 case MAX_EXPR:
2420 pp_string (pp, "MAX_EXPR <");
2421 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2422 pp_string (pp, ", ");
2423 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2424 pp_greater (pp);
2425 break;
2427 case ABS_EXPR:
2428 pp_string (pp, "ABS_EXPR <");
2429 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2430 pp_greater (pp);
2431 break;
2433 case RANGE_EXPR:
2434 NIY;
2435 break;
2437 case ADDR_SPACE_CONVERT_EXPR:
2438 case FIXED_CONVERT_EXPR:
2439 case FIX_TRUNC_EXPR:
2440 case FLOAT_EXPR:
2441 CASE_CONVERT:
2442 type = TREE_TYPE (node);
2443 op0 = TREE_OPERAND (node, 0);
2444 if (type != TREE_TYPE (op0))
2446 pp_left_paren (pp);
2447 dump_generic_node (pp, type, spc, flags, false);
2448 pp_string (pp, ") ");
2450 if (op_prio (op0) < op_prio (node))
2451 pp_left_paren (pp);
2452 dump_generic_node (pp, op0, spc, flags, false);
2453 if (op_prio (op0) < op_prio (node))
2454 pp_right_paren (pp);
2455 break;
2457 case VIEW_CONVERT_EXPR:
2458 pp_string (pp, "VIEW_CONVERT_EXPR<");
2459 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2460 pp_string (pp, ">(");
2461 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2462 pp_right_paren (pp);
2463 break;
2465 case PAREN_EXPR:
2466 pp_string (pp, "((");
2467 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2468 pp_string (pp, "))");
2469 break;
2471 case NON_LVALUE_EXPR:
2472 pp_string (pp, "NON_LVALUE_EXPR <");
2473 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2474 pp_greater (pp);
2475 break;
2477 case SAVE_EXPR:
2478 pp_string (pp, "SAVE_EXPR <");
2479 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2480 pp_greater (pp);
2481 break;
2483 case COMPLEX_EXPR:
2484 pp_string (pp, "COMPLEX_EXPR <");
2485 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2486 pp_string (pp, ", ");
2487 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2488 pp_greater (pp);
2489 break;
2491 case CONJ_EXPR:
2492 pp_string (pp, "CONJ_EXPR <");
2493 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2494 pp_greater (pp);
2495 break;
2497 case REALPART_EXPR:
2498 if (flags & TDF_GIMPLE)
2500 pp_string (pp, "__real ");
2501 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2503 else
2505 pp_string (pp, "REALPART_EXPR <");
2506 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2507 pp_greater (pp);
2509 break;
2511 case IMAGPART_EXPR:
2512 if (flags & TDF_GIMPLE)
2514 pp_string (pp, "__imag ");
2515 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2517 else
2519 pp_string (pp, "IMAGPART_EXPR <");
2520 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2521 pp_greater (pp);
2523 break;
2525 case VA_ARG_EXPR:
2526 pp_string (pp, "VA_ARG_EXPR <");
2527 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2528 pp_greater (pp);
2529 break;
2531 case TRY_FINALLY_EXPR:
2532 case TRY_CATCH_EXPR:
2533 pp_string (pp, "try");
2534 newline_and_indent (pp, spc+2);
2535 pp_left_brace (pp);
2536 newline_and_indent (pp, spc+4);
2537 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2538 newline_and_indent (pp, spc+2);
2539 pp_right_brace (pp);
2540 newline_and_indent (pp, spc);
2541 pp_string (pp,
2542 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2543 newline_and_indent (pp, spc+2);
2544 pp_left_brace (pp);
2545 newline_and_indent (pp, spc+4);
2546 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2547 newline_and_indent (pp, spc+2);
2548 pp_right_brace (pp);
2549 is_expr = false;
2550 break;
2552 case CATCH_EXPR:
2553 pp_string (pp, "catch (");
2554 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2555 pp_right_paren (pp);
2556 newline_and_indent (pp, spc+2);
2557 pp_left_brace (pp);
2558 newline_and_indent (pp, spc+4);
2559 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2560 newline_and_indent (pp, spc+2);
2561 pp_right_brace (pp);
2562 is_expr = false;
2563 break;
2565 case EH_FILTER_EXPR:
2566 pp_string (pp, "<<<eh_filter (");
2567 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2568 pp_string (pp, ")>>>");
2569 newline_and_indent (pp, spc+2);
2570 pp_left_brace (pp);
2571 newline_and_indent (pp, spc+4);
2572 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2573 newline_and_indent (pp, spc+2);
2574 pp_right_brace (pp);
2575 is_expr = false;
2576 break;
2578 case LABEL_EXPR:
2579 op0 = TREE_OPERAND (node, 0);
2580 /* If this is for break or continue, don't bother printing it. */
2581 if (DECL_NAME (op0))
2583 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2584 if (strcmp (name, "break") == 0
2585 || strcmp (name, "continue") == 0)
2586 break;
2588 dump_generic_node (pp, op0, spc, flags, false);
2589 pp_colon (pp);
2590 if (DECL_NONLOCAL (op0))
2591 pp_string (pp, " [non-local]");
2592 break;
2594 case LOOP_EXPR:
2595 pp_string (pp, "while (1)");
2596 if (!(flags & TDF_SLIM))
2598 newline_and_indent (pp, spc+2);
2599 pp_left_brace (pp);
2600 newline_and_indent (pp, spc+4);
2601 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2602 newline_and_indent (pp, spc+2);
2603 pp_right_brace (pp);
2605 is_expr = false;
2606 break;
2608 case PREDICT_EXPR:
2609 pp_string (pp, "// predicted ");
2610 if (PREDICT_EXPR_OUTCOME (node))
2611 pp_string (pp, "likely by ");
2612 else
2613 pp_string (pp, "unlikely by ");
2614 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2615 pp_string (pp, " predictor.");
2616 break;
2618 case ANNOTATE_EXPR:
2619 pp_string (pp, "ANNOTATE_EXPR <");
2620 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2621 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2623 case annot_expr_ivdep_kind:
2624 pp_string (pp, ", ivdep");
2625 break;
2626 case annot_expr_unroll_kind:
2627 pp_printf (pp, ", unroll %d",
2628 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2629 break;
2630 case annot_expr_no_vector_kind:
2631 pp_string (pp, ", no-vector");
2632 break;
2633 case annot_expr_vector_kind:
2634 pp_string (pp, ", vector");
2635 break;
2636 case annot_expr_parallel_kind:
2637 pp_string (pp, ", parallel");
2638 break;
2639 default:
2640 gcc_unreachable ();
2642 pp_greater (pp);
2643 break;
2645 case RETURN_EXPR:
2646 pp_string (pp, "return");
2647 op0 = TREE_OPERAND (node, 0);
2648 if (op0)
2650 pp_space (pp);
2651 if (TREE_CODE (op0) == MODIFY_EXPR)
2652 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2653 spc, flags, false);
2654 else
2655 dump_generic_node (pp, op0, spc, flags, false);
2657 break;
2659 case EXIT_EXPR:
2660 pp_string (pp, "if (");
2661 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2662 pp_string (pp, ") break");
2663 break;
2665 case SWITCH_EXPR:
2666 pp_string (pp, "switch (");
2667 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2668 pp_right_paren (pp);
2669 if (!(flags & TDF_SLIM))
2671 newline_and_indent (pp, spc+2);
2672 pp_left_brace (pp);
2673 if (SWITCH_BODY (node))
2675 newline_and_indent (pp, spc+4);
2676 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2677 true);
2679 newline_and_indent (pp, spc+2);
2680 pp_right_brace (pp);
2682 is_expr = false;
2683 break;
2685 case GOTO_EXPR:
2686 op0 = GOTO_DESTINATION (node);
2687 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2689 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2690 if (strcmp (name, "break") == 0
2691 || strcmp (name, "continue") == 0)
2693 pp_string (pp, name);
2694 break;
2697 pp_string (pp, "goto ");
2698 dump_generic_node (pp, op0, spc, flags, false);
2699 break;
2701 case ASM_EXPR:
2702 pp_string (pp, "__asm__");
2703 if (ASM_VOLATILE_P (node))
2704 pp_string (pp, " __volatile__");
2705 pp_left_paren (pp);
2706 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2707 pp_colon (pp);
2708 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2709 pp_colon (pp);
2710 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2711 if (ASM_CLOBBERS (node))
2713 pp_colon (pp);
2714 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2716 pp_right_paren (pp);
2717 break;
2719 case CASE_LABEL_EXPR:
2720 if (CASE_LOW (node) && CASE_HIGH (node))
2722 pp_string (pp, "case ");
2723 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2724 pp_string (pp, " ... ");
2725 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2727 else if (CASE_LOW (node))
2729 pp_string (pp, "case ");
2730 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2732 else
2733 pp_string (pp, "default");
2734 pp_colon (pp);
2735 break;
2737 case OBJ_TYPE_REF:
2738 pp_string (pp, "OBJ_TYPE_REF(");
2739 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2740 pp_semicolon (pp);
2741 /* We omit the class type for -fcompare-debug because we may
2742 drop TYPE_BINFO early depending on debug info, and then
2743 virtual_method_call_p would return false, whereas when
2744 TYPE_BINFO is preserved it may still return true and then
2745 we'd print the class type. Compare tree and rtl dumps for
2746 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
2747 for example, at occurrences of OBJ_TYPE_REF. */
2748 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
2749 && virtual_method_call_p (node))
2751 pp_string (pp, "(");
2752 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2753 pp_string (pp, ")");
2755 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2756 pp_arrow (pp);
2757 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2758 pp_right_paren (pp);
2759 break;
2761 case SSA_NAME:
2762 if (SSA_NAME_IDENTIFIER (node))
2764 if ((flags & TDF_NOUID)
2765 && SSA_NAME_VAR (node)
2766 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2767 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2768 else if (! (flags & TDF_GIMPLE)
2769 || SSA_NAME_VAR (node))
2770 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2771 spc, flags, false);
2773 pp_underscore (pp);
2774 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2775 if (SSA_NAME_IS_DEFAULT_DEF (node))
2776 pp_string (pp, "(D)");
2777 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2778 pp_string (pp, "(ab)");
2779 break;
2781 case WITH_SIZE_EXPR:
2782 pp_string (pp, "WITH_SIZE_EXPR <");
2783 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2784 pp_string (pp, ", ");
2785 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2786 pp_greater (pp);
2787 break;
2789 case ASSERT_EXPR:
2790 pp_string (pp, "ASSERT_EXPR <");
2791 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2792 pp_string (pp, ", ");
2793 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2794 pp_greater (pp);
2795 break;
2797 case SCEV_KNOWN:
2798 pp_string (pp, "scev_known");
2799 break;
2801 case SCEV_NOT_KNOWN:
2802 pp_string (pp, "scev_not_known");
2803 break;
2805 case POLYNOMIAL_CHREC:
2806 pp_left_brace (pp);
2807 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2808 pp_string (pp, ", +, ");
2809 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2810 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
2811 is_stmt = false;
2812 break;
2814 case REALIGN_LOAD_EXPR:
2815 pp_string (pp, "REALIGN_LOAD <");
2816 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2817 pp_string (pp, ", ");
2818 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2819 pp_string (pp, ", ");
2820 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2821 pp_greater (pp);
2822 break;
2824 case VEC_COND_EXPR:
2825 pp_string (pp, " VEC_COND_EXPR < ");
2826 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2827 pp_string (pp, " , ");
2828 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2829 pp_string (pp, " , ");
2830 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2831 pp_string (pp, " > ");
2832 break;
2834 case VEC_PERM_EXPR:
2835 pp_string (pp, " VEC_PERM_EXPR < ");
2836 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2837 pp_string (pp, " , ");
2838 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2839 pp_string (pp, " , ");
2840 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2841 pp_string (pp, " > ");
2842 break;
2844 case DOT_PROD_EXPR:
2845 pp_string (pp, " DOT_PROD_EXPR < ");
2846 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2847 pp_string (pp, ", ");
2848 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2849 pp_string (pp, ", ");
2850 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2851 pp_string (pp, " > ");
2852 break;
2854 case WIDEN_MULT_PLUS_EXPR:
2855 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2856 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2857 pp_string (pp, ", ");
2858 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2859 pp_string (pp, ", ");
2860 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2861 pp_string (pp, " > ");
2862 break;
2864 case WIDEN_MULT_MINUS_EXPR:
2865 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2866 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2867 pp_string (pp, ", ");
2868 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2869 pp_string (pp, ", ");
2870 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2871 pp_string (pp, " > ");
2872 break;
2874 case FMA_EXPR:
2875 pp_string (pp, " FMA_EXPR < ");
2876 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2877 pp_string (pp, ", ");
2878 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2879 pp_string (pp, ", ");
2880 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2881 pp_string (pp, " > ");
2882 break;
2884 case OACC_PARALLEL:
2885 pp_string (pp, "#pragma acc parallel");
2886 goto dump_omp_clauses_body;
2888 case OACC_KERNELS:
2889 pp_string (pp, "#pragma acc kernels");
2890 goto dump_omp_clauses_body;
2892 case OACC_DATA:
2893 pp_string (pp, "#pragma acc data");
2894 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2895 goto dump_omp_body;
2897 case OACC_HOST_DATA:
2898 pp_string (pp, "#pragma acc host_data");
2899 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2900 goto dump_omp_body;
2902 case OACC_DECLARE:
2903 pp_string (pp, "#pragma acc declare");
2904 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2905 break;
2907 case OACC_UPDATE:
2908 pp_string (pp, "#pragma acc update");
2909 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2910 break;
2912 case OACC_ENTER_DATA:
2913 pp_string (pp, "#pragma acc enter data");
2914 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2915 break;
2917 case OACC_EXIT_DATA:
2918 pp_string (pp, "#pragma acc exit data");
2919 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2920 break;
2922 case OACC_CACHE:
2923 pp_string (pp, "#pragma acc cache");
2924 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2925 break;
2927 case OMP_PARALLEL:
2928 pp_string (pp, "#pragma omp parallel");
2929 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2930 goto dump_omp_body;
2932 dump_omp_clauses_body:
2933 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2934 goto dump_omp_body;
2936 dump_omp_body:
2937 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2939 newline_and_indent (pp, spc + 2);
2940 pp_left_brace (pp);
2941 newline_and_indent (pp, spc + 4);
2942 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2943 newline_and_indent (pp, spc + 2);
2944 pp_right_brace (pp);
2946 is_expr = false;
2947 break;
2949 case OMP_TASK:
2950 pp_string (pp, "#pragma omp task");
2951 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2952 goto dump_omp_body;
2954 case OMP_FOR:
2955 pp_string (pp, "#pragma omp for");
2956 goto dump_omp_loop;
2958 case OMP_SIMD:
2959 pp_string (pp, "#pragma omp simd");
2960 goto dump_omp_loop;
2962 case OMP_DISTRIBUTE:
2963 pp_string (pp, "#pragma omp distribute");
2964 goto dump_omp_loop;
2966 case OMP_TASKLOOP:
2967 pp_string (pp, "#pragma omp taskloop");
2968 goto dump_omp_loop;
2970 case OACC_LOOP:
2971 pp_string (pp, "#pragma acc loop");
2972 goto dump_omp_loop;
2974 case OMP_TEAMS:
2975 pp_string (pp, "#pragma omp teams");
2976 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2977 goto dump_omp_body;
2979 case OMP_TARGET_DATA:
2980 pp_string (pp, "#pragma omp target data");
2981 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2982 goto dump_omp_body;
2984 case OMP_TARGET_ENTER_DATA:
2985 pp_string (pp, "#pragma omp target enter data");
2986 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2987 is_expr = false;
2988 break;
2990 case OMP_TARGET_EXIT_DATA:
2991 pp_string (pp, "#pragma omp target exit data");
2992 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2993 is_expr = false;
2994 break;
2996 case OMP_TARGET:
2997 pp_string (pp, "#pragma omp target");
2998 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2999 goto dump_omp_body;
3001 case OMP_TARGET_UPDATE:
3002 pp_string (pp, "#pragma omp target update");
3003 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3004 is_expr = false;
3005 break;
3007 dump_omp_loop:
3008 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3009 if (!(flags & TDF_SLIM))
3011 int i;
3013 if (OMP_FOR_PRE_BODY (node))
3015 newline_and_indent (pp, spc + 2);
3016 pp_left_brace (pp);
3017 spc += 4;
3018 newline_and_indent (pp, spc);
3019 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3020 spc, flags, false);
3022 if (OMP_FOR_INIT (node))
3024 spc -= 2;
3025 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3027 spc += 2;
3028 newline_and_indent (pp, spc);
3029 pp_string (pp, "for (");
3030 dump_generic_node (pp,
3031 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3032 spc, flags, false);
3033 pp_string (pp, "; ");
3034 dump_generic_node (pp,
3035 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3036 spc, flags, false);
3037 pp_string (pp, "; ");
3038 dump_generic_node (pp,
3039 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3040 spc, flags, false);
3041 pp_right_paren (pp);
3044 if (OMP_FOR_BODY (node))
3046 newline_and_indent (pp, spc + 2);
3047 pp_left_brace (pp);
3048 newline_and_indent (pp, spc + 4);
3049 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3050 false);
3051 newline_and_indent (pp, spc + 2);
3052 pp_right_brace (pp);
3054 if (OMP_FOR_INIT (node))
3055 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3056 if (OMP_FOR_PRE_BODY (node))
3058 spc -= 4;
3059 newline_and_indent (pp, spc + 2);
3060 pp_right_brace (pp);
3063 is_expr = false;
3064 break;
3066 case OMP_SECTIONS:
3067 pp_string (pp, "#pragma omp sections");
3068 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3069 goto dump_omp_body;
3071 case OMP_SECTION:
3072 pp_string (pp, "#pragma omp section");
3073 goto dump_omp_body;
3075 case OMP_MASTER:
3076 pp_string (pp, "#pragma omp master");
3077 goto dump_omp_body;
3079 case OMP_TASKGROUP:
3080 pp_string (pp, "#pragma omp taskgroup");
3081 goto dump_omp_body;
3083 case OMP_ORDERED:
3084 pp_string (pp, "#pragma omp ordered");
3085 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3086 goto dump_omp_body;
3088 case OMP_CRITICAL:
3089 pp_string (pp, "#pragma omp critical");
3090 if (OMP_CRITICAL_NAME (node))
3092 pp_space (pp);
3093 pp_left_paren (pp);
3094 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3095 flags, false);
3096 pp_right_paren (pp);
3098 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3099 goto dump_omp_body;
3101 case OMP_ATOMIC:
3102 pp_string (pp, "#pragma omp atomic");
3103 if (OMP_ATOMIC_SEQ_CST (node))
3104 pp_string (pp, " seq_cst");
3105 newline_and_indent (pp, spc + 2);
3106 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3107 pp_space (pp);
3108 pp_equal (pp);
3109 pp_space (pp);
3110 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3111 break;
3113 case OMP_ATOMIC_READ:
3114 pp_string (pp, "#pragma omp atomic read");
3115 if (OMP_ATOMIC_SEQ_CST (node))
3116 pp_string (pp, " seq_cst");
3117 newline_and_indent (pp, spc + 2);
3118 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3119 pp_space (pp);
3120 break;
3122 case OMP_ATOMIC_CAPTURE_OLD:
3123 case OMP_ATOMIC_CAPTURE_NEW:
3124 pp_string (pp, "#pragma omp atomic capture");
3125 if (OMP_ATOMIC_SEQ_CST (node))
3126 pp_string (pp, " seq_cst");
3127 newline_and_indent (pp, spc + 2);
3128 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3129 pp_space (pp);
3130 pp_equal (pp);
3131 pp_space (pp);
3132 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3133 break;
3135 case OMP_SINGLE:
3136 pp_string (pp, "#pragma omp single");
3137 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3138 goto dump_omp_body;
3140 case OMP_CLAUSE:
3141 dump_omp_clause (pp, node, spc, flags);
3142 is_expr = false;
3143 break;
3145 case TRANSACTION_EXPR:
3146 if (TRANSACTION_EXPR_OUTER (node))
3147 pp_string (pp, "__transaction_atomic [[outer]]");
3148 else if (TRANSACTION_EXPR_RELAXED (node))
3149 pp_string (pp, "__transaction_relaxed");
3150 else
3151 pp_string (pp, "__transaction_atomic");
3152 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3154 newline_and_indent (pp, spc);
3155 pp_left_brace (pp);
3156 newline_and_indent (pp, spc + 2);
3157 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3158 spc + 2, flags, false);
3159 newline_and_indent (pp, spc);
3160 pp_right_brace (pp);
3162 is_expr = false;
3163 break;
3165 case VEC_SERIES_EXPR:
3166 case VEC_WIDEN_MULT_HI_EXPR:
3167 case VEC_WIDEN_MULT_LO_EXPR:
3168 case VEC_WIDEN_MULT_EVEN_EXPR:
3169 case VEC_WIDEN_MULT_ODD_EXPR:
3170 case VEC_WIDEN_LSHIFT_HI_EXPR:
3171 case VEC_WIDEN_LSHIFT_LO_EXPR:
3172 pp_space (pp);
3173 for (str = get_tree_code_name (code); *str; str++)
3174 pp_character (pp, TOUPPER (*str));
3175 pp_string (pp, " < ");
3176 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3177 pp_string (pp, ", ");
3178 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3179 pp_string (pp, " > ");
3180 break;
3182 case VEC_DUPLICATE_EXPR:
3183 pp_space (pp);
3184 for (str = get_tree_code_name (code); *str; str++)
3185 pp_character (pp, TOUPPER (*str));
3186 pp_string (pp, " < ");
3187 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3188 pp_string (pp, " > ");
3189 break;
3191 case VEC_UNPACK_HI_EXPR:
3192 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3193 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3194 pp_string (pp, " > ");
3195 break;
3197 case VEC_UNPACK_LO_EXPR:
3198 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3199 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3200 pp_string (pp, " > ");
3201 break;
3203 case VEC_UNPACK_FLOAT_HI_EXPR:
3204 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3205 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3206 pp_string (pp, " > ");
3207 break;
3209 case VEC_UNPACK_FLOAT_LO_EXPR:
3210 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3211 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3212 pp_string (pp, " > ");
3213 break;
3215 case VEC_PACK_TRUNC_EXPR:
3216 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3217 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3218 pp_string (pp, ", ");
3219 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3220 pp_string (pp, " > ");
3221 break;
3223 case VEC_PACK_SAT_EXPR:
3224 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3225 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3226 pp_string (pp, ", ");
3227 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3228 pp_string (pp, " > ");
3229 break;
3231 case VEC_PACK_FIX_TRUNC_EXPR:
3232 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3233 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3234 pp_string (pp, ", ");
3235 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3236 pp_string (pp, " > ");
3237 break;
3239 case BLOCK:
3240 dump_block_node (pp, node, spc, flags);
3241 break;
3243 case DEBUG_BEGIN_STMT:
3244 pp_string (pp, "# DEBUG BEGIN STMT");
3245 break;
3247 default:
3248 NIY;
3251 if (is_stmt && is_expr)
3252 pp_semicolon (pp);
3254 return spc;
3257 /* Print the declaration of a variable. */
3259 void
3260 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3262 INDENT (spc);
3264 if (TREE_CODE(t) == NAMELIST_DECL)
3266 pp_string(pp, "namelist ");
3267 dump_decl_name (pp, t, flags);
3268 pp_semicolon (pp);
3269 return;
3272 if (TREE_CODE (t) == TYPE_DECL)
3273 pp_string (pp, "typedef ");
3275 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3276 pp_string (pp, "register ");
3278 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3279 pp_string (pp, "extern ");
3280 else if (TREE_STATIC (t))
3281 pp_string (pp, "static ");
3283 /* Print the type and name. */
3284 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3286 tree tmp;
3288 /* Print array's type. */
3289 tmp = TREE_TYPE (t);
3290 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3291 tmp = TREE_TYPE (tmp);
3292 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3294 /* Print variable's name. */
3295 pp_space (pp);
3296 dump_generic_node (pp, t, spc, flags, false);
3298 /* Print the dimensions. */
3299 tmp = TREE_TYPE (t);
3300 while (TREE_CODE (tmp) == ARRAY_TYPE)
3302 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3303 tmp = TREE_TYPE (tmp);
3306 else if (TREE_CODE (t) == FUNCTION_DECL)
3308 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3309 pp_space (pp);
3310 dump_decl_name (pp, t, flags);
3311 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3313 else
3315 /* Print type declaration. */
3316 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3318 /* Print variable's name. */
3319 pp_space (pp);
3320 dump_generic_node (pp, t, spc, flags, false);
3323 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3325 pp_string (pp, " __asm__ ");
3326 pp_left_paren (pp);
3327 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3328 pp_right_paren (pp);
3331 /* The initial value of a function serves to determine whether the function
3332 is declared or defined. So the following does not apply to function
3333 nodes. */
3334 if (TREE_CODE (t) != FUNCTION_DECL)
3336 /* Print the initial value. */
3337 if (DECL_INITIAL (t))
3339 pp_space (pp);
3340 pp_equal (pp);
3341 pp_space (pp);
3342 if (!(flags & TDF_SLIM))
3343 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3344 else
3345 pp_string (pp, "<<< omitted >>>");
3349 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3351 pp_string (pp, " [value-expr: ");
3352 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3353 pp_right_bracket (pp);
3356 pp_semicolon (pp);
3360 /* Prints a structure: name, fields, and methods.
3361 FIXME: Still incomplete. */
3363 static void
3364 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3365 dump_flags_t flags)
3367 /* Print the name of the structure. */
3368 if (TYPE_NAME (node))
3370 INDENT (spc);
3371 if (TREE_CODE (node) == RECORD_TYPE)
3372 pp_string (pp, "struct ");
3373 else if ((TREE_CODE (node) == UNION_TYPE
3374 || TREE_CODE (node) == QUAL_UNION_TYPE))
3375 pp_string (pp, "union ");
3377 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3380 /* Print the contents of the structure. */
3381 pp_newline (pp);
3382 INDENT (spc);
3383 pp_left_brace (pp);
3384 pp_newline (pp);
3386 /* Print the fields of the structure. */
3388 tree tmp;
3389 tmp = TYPE_FIELDS (node);
3390 while (tmp)
3392 /* Avoid to print recursively the structure. */
3393 /* FIXME : Not implemented correctly...,
3394 what about the case when we have a cycle in the contain graph? ...
3395 Maybe this could be solved by looking at the scope in which the
3396 structure was declared. */
3397 if (TREE_TYPE (tmp) != node
3398 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3399 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3401 print_declaration (pp, tmp, spc+2, flags);
3402 pp_newline (pp);
3404 tmp = DECL_CHAIN (tmp);
3407 INDENT (spc);
3408 pp_right_brace (pp);
3411 /* Return the priority of the operator CODE.
3413 From lowest to highest precedence with either left-to-right (L-R)
3414 or right-to-left (R-L) associativity]:
3416 1 [L-R] ,
3417 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3418 3 [R-L] ?:
3419 4 [L-R] ||
3420 5 [L-R] &&
3421 6 [L-R] |
3422 7 [L-R] ^
3423 8 [L-R] &
3424 9 [L-R] == !=
3425 10 [L-R] < <= > >=
3426 11 [L-R] << >>
3427 12 [L-R] + -
3428 13 [L-R] * / %
3429 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3430 15 [L-R] fn() [] -> .
3432 unary +, - and * have higher precedence than the corresponding binary
3433 operators. */
3436 op_code_prio (enum tree_code code)
3438 switch (code)
3440 case TREE_LIST:
3441 case COMPOUND_EXPR:
3442 case BIND_EXPR:
3443 return 1;
3445 case MODIFY_EXPR:
3446 case INIT_EXPR:
3447 return 2;
3449 case COND_EXPR:
3450 return 3;
3452 case TRUTH_OR_EXPR:
3453 case TRUTH_ORIF_EXPR:
3454 return 4;
3456 case TRUTH_AND_EXPR:
3457 case TRUTH_ANDIF_EXPR:
3458 return 5;
3460 case BIT_IOR_EXPR:
3461 return 6;
3463 case BIT_XOR_EXPR:
3464 case TRUTH_XOR_EXPR:
3465 return 7;
3467 case BIT_AND_EXPR:
3468 return 8;
3470 case EQ_EXPR:
3471 case NE_EXPR:
3472 return 9;
3474 case UNLT_EXPR:
3475 case UNLE_EXPR:
3476 case UNGT_EXPR:
3477 case UNGE_EXPR:
3478 case UNEQ_EXPR:
3479 case LTGT_EXPR:
3480 case ORDERED_EXPR:
3481 case UNORDERED_EXPR:
3482 case LT_EXPR:
3483 case LE_EXPR:
3484 case GT_EXPR:
3485 case GE_EXPR:
3486 return 10;
3488 case LSHIFT_EXPR:
3489 case RSHIFT_EXPR:
3490 case LROTATE_EXPR:
3491 case RROTATE_EXPR:
3492 case VEC_WIDEN_LSHIFT_HI_EXPR:
3493 case VEC_WIDEN_LSHIFT_LO_EXPR:
3494 case WIDEN_LSHIFT_EXPR:
3495 return 11;
3497 case WIDEN_SUM_EXPR:
3498 case PLUS_EXPR:
3499 case POINTER_PLUS_EXPR:
3500 case POINTER_DIFF_EXPR:
3501 case MINUS_EXPR:
3502 return 12;
3504 case VEC_WIDEN_MULT_HI_EXPR:
3505 case VEC_WIDEN_MULT_LO_EXPR:
3506 case WIDEN_MULT_EXPR:
3507 case DOT_PROD_EXPR:
3508 case WIDEN_MULT_PLUS_EXPR:
3509 case WIDEN_MULT_MINUS_EXPR:
3510 case MULT_EXPR:
3511 case MULT_HIGHPART_EXPR:
3512 case TRUNC_DIV_EXPR:
3513 case CEIL_DIV_EXPR:
3514 case FLOOR_DIV_EXPR:
3515 case ROUND_DIV_EXPR:
3516 case RDIV_EXPR:
3517 case EXACT_DIV_EXPR:
3518 case TRUNC_MOD_EXPR:
3519 case CEIL_MOD_EXPR:
3520 case FLOOR_MOD_EXPR:
3521 case ROUND_MOD_EXPR:
3522 case FMA_EXPR:
3523 return 13;
3525 case TRUTH_NOT_EXPR:
3526 case BIT_NOT_EXPR:
3527 case POSTINCREMENT_EXPR:
3528 case POSTDECREMENT_EXPR:
3529 case PREINCREMENT_EXPR:
3530 case PREDECREMENT_EXPR:
3531 case NEGATE_EXPR:
3532 case INDIRECT_REF:
3533 case ADDR_EXPR:
3534 case FLOAT_EXPR:
3535 CASE_CONVERT:
3536 case FIX_TRUNC_EXPR:
3537 case TARGET_EXPR:
3538 return 14;
3540 case CALL_EXPR:
3541 case ARRAY_REF:
3542 case ARRAY_RANGE_REF:
3543 case COMPONENT_REF:
3544 return 15;
3546 /* Special expressions. */
3547 case MIN_EXPR:
3548 case MAX_EXPR:
3549 case ABS_EXPR:
3550 case REALPART_EXPR:
3551 case IMAGPART_EXPR:
3552 case VEC_UNPACK_HI_EXPR:
3553 case VEC_UNPACK_LO_EXPR:
3554 case VEC_UNPACK_FLOAT_HI_EXPR:
3555 case VEC_UNPACK_FLOAT_LO_EXPR:
3556 case VEC_PACK_TRUNC_EXPR:
3557 case VEC_PACK_SAT_EXPR:
3558 return 16;
3560 default:
3561 /* Return an arbitrarily high precedence to avoid surrounding single
3562 VAR_DECLs in ()s. */
3563 return 9999;
3567 /* Return the priority of the operator OP. */
3570 op_prio (const_tree op)
3572 enum tree_code code;
3574 if (op == NULL)
3575 return 9999;
3577 code = TREE_CODE (op);
3578 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3579 return op_prio (TREE_OPERAND (op, 0));
3581 return op_code_prio (code);
3584 /* Return the symbol associated with operator CODE. */
3586 const char *
3587 op_symbol_code (enum tree_code code)
3589 switch (code)
3591 case MODIFY_EXPR:
3592 return "=";
3594 case TRUTH_OR_EXPR:
3595 case TRUTH_ORIF_EXPR:
3596 return "||";
3598 case TRUTH_AND_EXPR:
3599 case TRUTH_ANDIF_EXPR:
3600 return "&&";
3602 case BIT_IOR_EXPR:
3603 return "|";
3605 case TRUTH_XOR_EXPR:
3606 case BIT_XOR_EXPR:
3607 return "^";
3609 case ADDR_EXPR:
3610 case BIT_AND_EXPR:
3611 return "&";
3613 case ORDERED_EXPR:
3614 return "ord";
3615 case UNORDERED_EXPR:
3616 return "unord";
3618 case EQ_EXPR:
3619 return "==";
3620 case UNEQ_EXPR:
3621 return "u==";
3623 case NE_EXPR:
3624 return "!=";
3626 case LT_EXPR:
3627 return "<";
3628 case UNLT_EXPR:
3629 return "u<";
3631 case LE_EXPR:
3632 return "<=";
3633 case UNLE_EXPR:
3634 return "u<=";
3636 case GT_EXPR:
3637 return ">";
3638 case UNGT_EXPR:
3639 return "u>";
3641 case GE_EXPR:
3642 return ">=";
3643 case UNGE_EXPR:
3644 return "u>=";
3646 case LTGT_EXPR:
3647 return "<>";
3649 case LSHIFT_EXPR:
3650 return "<<";
3652 case RSHIFT_EXPR:
3653 return ">>";
3655 case LROTATE_EXPR:
3656 return "r<<";
3658 case RROTATE_EXPR:
3659 return "r>>";
3661 case WIDEN_LSHIFT_EXPR:
3662 return "w<<";
3664 case POINTER_PLUS_EXPR:
3665 return "+";
3667 case PLUS_EXPR:
3668 return "+";
3670 case WIDEN_SUM_EXPR:
3671 return "w+";
3673 case WIDEN_MULT_EXPR:
3674 return "w*";
3676 case MULT_HIGHPART_EXPR:
3677 return "h*";
3679 case NEGATE_EXPR:
3680 case MINUS_EXPR:
3681 case POINTER_DIFF_EXPR:
3682 return "-";
3684 case BIT_NOT_EXPR:
3685 return "~";
3687 case TRUTH_NOT_EXPR:
3688 return "!";
3690 case MULT_EXPR:
3691 case INDIRECT_REF:
3692 return "*";
3694 case TRUNC_DIV_EXPR:
3695 case RDIV_EXPR:
3696 return "/";
3698 case CEIL_DIV_EXPR:
3699 return "/[cl]";
3701 case FLOOR_DIV_EXPR:
3702 return "/[fl]";
3704 case ROUND_DIV_EXPR:
3705 return "/[rd]";
3707 case EXACT_DIV_EXPR:
3708 return "/[ex]";
3710 case TRUNC_MOD_EXPR:
3711 return "%";
3713 case CEIL_MOD_EXPR:
3714 return "%[cl]";
3716 case FLOOR_MOD_EXPR:
3717 return "%[fl]";
3719 case ROUND_MOD_EXPR:
3720 return "%[rd]";
3722 case PREDECREMENT_EXPR:
3723 return " --";
3725 case PREINCREMENT_EXPR:
3726 return " ++";
3728 case POSTDECREMENT_EXPR:
3729 return "-- ";
3731 case POSTINCREMENT_EXPR:
3732 return "++ ";
3734 case MAX_EXPR:
3735 return "max";
3737 case MIN_EXPR:
3738 return "min";
3740 default:
3741 return "<<< ??? >>>";
3745 /* Return the symbol associated with operator OP. */
3747 static const char *
3748 op_symbol (const_tree op)
3750 return op_symbol_code (TREE_CODE (op));
3753 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3754 the gimple_call_fn of a GIMPLE_CALL. */
3756 void
3757 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3759 tree op0 = node;
3761 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3762 op0 = TREE_OPERAND (op0, 0);
3764 again:
3765 switch (TREE_CODE (op0))
3767 case VAR_DECL:
3768 case PARM_DECL:
3769 case FUNCTION_DECL:
3770 dump_function_name (pp, op0, flags);
3771 break;
3773 case ADDR_EXPR:
3774 case INDIRECT_REF:
3775 CASE_CONVERT:
3776 op0 = TREE_OPERAND (op0, 0);
3777 goto again;
3779 case COND_EXPR:
3780 pp_left_paren (pp);
3781 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3782 pp_string (pp, ") ? ");
3783 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3784 pp_string (pp, " : ");
3785 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3786 break;
3788 case ARRAY_REF:
3789 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3790 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3791 else
3792 dump_generic_node (pp, op0, 0, flags, false);
3793 break;
3795 case MEM_REF:
3796 if (integer_zerop (TREE_OPERAND (op0, 1)))
3798 op0 = TREE_OPERAND (op0, 0);
3799 goto again;
3801 /* Fallthru. */
3802 case COMPONENT_REF:
3803 case SSA_NAME:
3804 case OBJ_TYPE_REF:
3805 dump_generic_node (pp, op0, 0, flags, false);
3806 break;
3808 default:
3809 NIY;
3813 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3815 static void
3816 pretty_print_string (pretty_printer *pp, const char *str)
3818 if (str == NULL)
3819 return;
3821 while (*str)
3823 switch (str[0])
3825 case '\b':
3826 pp_string (pp, "\\b");
3827 break;
3829 case '\f':
3830 pp_string (pp, "\\f");
3831 break;
3833 case '\n':
3834 pp_string (pp, "\\n");
3835 break;
3837 case '\r':
3838 pp_string (pp, "\\r");
3839 break;
3841 case '\t':
3842 pp_string (pp, "\\t");
3843 break;
3845 case '\v':
3846 pp_string (pp, "\\v");
3847 break;
3849 case '\\':
3850 pp_string (pp, "\\\\");
3851 break;
3853 case '\"':
3854 pp_string (pp, "\\\"");
3855 break;
3857 case '\'':
3858 pp_string (pp, "\\'");
3859 break;
3861 /* No need to handle \0; the loop terminates on \0. */
3863 case '\1':
3864 pp_string (pp, "\\1");
3865 break;
3867 case '\2':
3868 pp_string (pp, "\\2");
3869 break;
3871 case '\3':
3872 pp_string (pp, "\\3");
3873 break;
3875 case '\4':
3876 pp_string (pp, "\\4");
3877 break;
3879 case '\5':
3880 pp_string (pp, "\\5");
3881 break;
3883 case '\6':
3884 pp_string (pp, "\\6");
3885 break;
3887 case '\7':
3888 pp_string (pp, "\\7");
3889 break;
3891 default:
3892 if (!ISPRINT (str[0]))
3894 char buf[5];
3895 sprintf (buf, "\\x%x", (unsigned char)str[0]);
3896 pp_string (pp, buf);
3898 else
3899 pp_character (pp, str[0]);
3900 break;
3902 str++;
3906 static void
3907 maybe_init_pretty_print (FILE *file)
3909 if (!tree_pp)
3911 tree_pp = new pretty_printer ();
3912 pp_needs_newline (tree_pp) = true;
3913 pp_translate_identifiers (tree_pp) = false;
3916 tree_pp->buffer->stream = file;
3919 static void
3920 newline_and_indent (pretty_printer *pp, int spc)
3922 pp_newline (pp);
3923 INDENT (spc);
3926 /* Handle the %K format for TEXT. Separate from default_tree_printer
3927 so it can also be used in front ends.
3928 Argument is a statement from which EXPR_LOCATION and TREE_BLOCK will
3929 be recorded. */
3931 void
3932 percent_K_format (text_info *text, tree t)
3934 text->set_location (0, EXPR_LOCATION (t), true);
3935 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3936 tree block = TREE_BLOCK (t);
3937 *pp_ti_abstract_origin (text) = NULL;
3939 if (in_lto_p)
3941 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3942 representing the outermost block of an inlined function.
3943 So walk the BLOCK tree until we hit such a scope. */
3944 while (block
3945 && TREE_CODE (block) == BLOCK)
3947 if (inlined_function_outer_scope_p (block))
3949 *pp_ti_abstract_origin (text) = block;
3950 break;
3952 block = BLOCK_SUPERCONTEXT (block);
3954 return;
3957 while (block
3958 && TREE_CODE (block) == BLOCK
3959 && BLOCK_ABSTRACT_ORIGIN (block))
3961 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3963 while (TREE_CODE (ao) == BLOCK
3964 && BLOCK_ABSTRACT_ORIGIN (ao)
3965 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3966 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3968 if (TREE_CODE (ao) == FUNCTION_DECL)
3970 *pp_ti_abstract_origin (text) = block;
3971 break;
3973 block = BLOCK_SUPERCONTEXT (block);
3977 /* Print the identifier ID to PRETTY-PRINTER. */
3979 void
3980 pp_tree_identifier (pretty_printer *pp, tree id)
3982 if (pp_translate_identifiers (pp))
3984 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3985 pp_append_text (pp, text, text + strlen (text));
3987 else
3988 pp_append_text (pp, IDENTIFIER_POINTER (id),
3989 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3992 /* A helper function that is used to dump function information before the
3993 function dump. */
3995 void
3996 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
3998 const char *dname, *aname;
3999 struct cgraph_node *node = cgraph_node::get (fdecl);
4000 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4002 dname = lang_hooks.decl_printable_name (fdecl, 1);
4004 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4005 aname = (IDENTIFIER_POINTER
4006 (DECL_ASSEMBLER_NAME (fdecl)));
4007 else
4008 aname = "<unset-asm-name>";
4010 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4011 dname, aname, fun->funcdef_no);
4012 if (!(flags & TDF_NOUID))
4013 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4014 if (node)
4016 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
4017 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4018 node->frequency == NODE_FREQUENCY_HOT
4019 ? " (hot)"
4020 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4021 ? " (unlikely executed)"
4022 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4023 ? " (executed once)"
4024 : "");
4026 else
4027 fprintf (dump_file, ")\n\n");
4030 /* Dump double_int D to pretty_printer PP. UNS is true
4031 if D is unsigned and false otherwise. */
4032 void
4033 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4035 if (d.fits_shwi ())
4036 pp_wide_integer (pp, d.low);
4037 else if (d.fits_uhwi ())
4038 pp_unsigned_wide_integer (pp, d.low);
4039 else
4041 unsigned HOST_WIDE_INT low = d.low;
4042 HOST_WIDE_INT high = d.high;
4043 if (!uns && d.is_negative ())
4045 pp_minus (pp);
4046 high = ~high + !low;
4047 low = -low;
4049 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4050 systems? */
4051 sprintf (pp_buffer (pp)->digit_buffer,
4052 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4053 (unsigned HOST_WIDE_INT) high, low);
4054 pp_string (pp, pp_buffer (pp)->digit_buffer);