Add support for adjusting the number of units in a mode
[official-gcc.git] / gcc / tree-pretty-print.c
blobc6cd65fbe79c142052beb299e3787514e13fa9e7
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2018 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "backend.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "predict.h"
28 #include "cgraph.h"
29 #include "tree-pretty-print.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "dumpfile.h"
34 #include "internal-fn.h"
35 #include "gomp-constants.h"
36 #include "gimple.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree);
40 static void pretty_print_string (pretty_printer *, const char*);
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 POLY_INT_CST:
1738 pp_string (pp, "POLY_INT_CST [");
1739 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
1740 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
1742 pp_string (pp, ", ");
1743 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
1744 spc, flags, false);
1746 pp_string (pp, "]");
1747 break;
1749 case REAL_CST:
1750 /* Code copied from print_node. */
1752 REAL_VALUE_TYPE d;
1753 if (TREE_OVERFLOW (node))
1754 pp_string (pp, " overflow");
1756 d = TREE_REAL_CST (node);
1757 if (REAL_VALUE_ISINF (d))
1758 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1759 else if (REAL_VALUE_ISNAN (d))
1760 pp_string (pp, " Nan");
1761 else
1763 char string[100];
1764 real_to_decimal (string, &d, sizeof (string), 0, 1);
1765 pp_string (pp, string);
1767 break;
1770 case FIXED_CST:
1772 char string[100];
1773 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1774 pp_string (pp, string);
1775 break;
1778 case COMPLEX_CST:
1779 pp_string (pp, "__complex__ (");
1780 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1781 pp_string (pp, ", ");
1782 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1783 pp_right_paren (pp);
1784 break;
1786 case STRING_CST:
1787 pp_string (pp, "\"");
1788 pretty_print_string (pp, TREE_STRING_POINTER (node));
1789 pp_string (pp, "\"");
1790 break;
1792 case VECTOR_CST:
1794 unsigned i;
1795 pp_string (pp, "{ ");
1796 unsigned HOST_WIDE_INT nunits;
1797 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
1798 nunits = vector_cst_encoded_nelts (node);
1799 for (i = 0; i < nunits; ++i)
1801 if (i != 0)
1802 pp_string (pp, ", ");
1803 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1804 spc, flags, false);
1806 if (!VECTOR_CST_NELTS (node).is_constant ())
1807 pp_string (pp, ", ...");
1808 pp_string (pp, " }");
1810 break;
1812 case FUNCTION_TYPE:
1813 case METHOD_TYPE:
1814 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1815 pp_space (pp);
1816 if (TREE_CODE (node) == METHOD_TYPE)
1818 if (TYPE_METHOD_BASETYPE (node))
1819 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1820 flags);
1821 else
1822 pp_string (pp, "<null method basetype>");
1823 pp_colon_colon (pp);
1825 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1826 dump_decl_name (pp, TYPE_NAME (node), flags);
1827 else if (flags & TDF_NOUID)
1828 pp_printf (pp, "<Txxxx>");
1829 else
1830 pp_printf (pp, "<T%x>", TYPE_UID (node));
1831 dump_function_declaration (pp, node, spc, flags);
1832 break;
1834 case FUNCTION_DECL:
1835 case CONST_DECL:
1836 dump_decl_name (pp, node, flags);
1837 break;
1839 case LABEL_DECL:
1840 if (DECL_NAME (node))
1841 dump_decl_name (pp, node, flags);
1842 else if (LABEL_DECL_UID (node) != -1)
1844 if (flags & TDF_GIMPLE)
1845 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1846 else
1847 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1849 else
1851 if (flags & TDF_NOUID)
1852 pp_string (pp, "<D.xxxx>");
1853 else
1855 if (flags & TDF_GIMPLE)
1856 pp_printf (pp, "<D%u>", DECL_UID (node));
1857 else
1858 pp_printf (pp, "<D.%u>", DECL_UID (node));
1861 break;
1863 case TYPE_DECL:
1864 if (DECL_IS_BUILTIN (node))
1866 /* Don't print the declaration of built-in types. */
1867 break;
1869 if (DECL_NAME (node))
1870 dump_decl_name (pp, node, flags);
1871 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1873 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1874 ? "union" : "struct "));
1875 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1877 else
1878 pp_string (pp, "<anon>");
1879 break;
1881 case VAR_DECL:
1882 case PARM_DECL:
1883 case FIELD_DECL:
1884 case DEBUG_EXPR_DECL:
1885 case NAMESPACE_DECL:
1886 case NAMELIST_DECL:
1887 dump_decl_name (pp, node, flags);
1888 break;
1890 case RESULT_DECL:
1891 pp_string (pp, "<retval>");
1892 break;
1894 case COMPONENT_REF:
1895 op0 = TREE_OPERAND (node, 0);
1896 str = ".";
1897 if (op0
1898 && (TREE_CODE (op0) == INDIRECT_REF
1899 || (TREE_CODE (op0) == MEM_REF
1900 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1901 && integer_zerop (TREE_OPERAND (op0, 1))
1902 /* Dump the types of INTEGER_CSTs explicitly, for we
1903 can't infer them and MEM_ATTR caching will share
1904 MEM_REFs with differently-typed op0s. */
1905 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1906 /* Released SSA_NAMES have no TREE_TYPE. */
1907 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1908 /* Same pointer types, but ignoring POINTER_TYPE vs.
1909 REFERENCE_TYPE. */
1910 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1911 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1912 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1913 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1914 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1915 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1916 /* Same value types ignoring qualifiers. */
1917 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1918 == TYPE_MAIN_VARIANT
1919 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1920 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1922 op0 = TREE_OPERAND (op0, 0);
1923 str = "->";
1925 if (op_prio (op0) < op_prio (node))
1926 pp_left_paren (pp);
1927 dump_generic_node (pp, op0, spc, flags, false);
1928 if (op_prio (op0) < op_prio (node))
1929 pp_right_paren (pp);
1930 pp_string (pp, str);
1931 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1932 op0 = component_ref_field_offset (node);
1933 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1935 pp_string (pp, "{off: ");
1936 dump_generic_node (pp, op0, spc, flags, false);
1937 pp_right_brace (pp);
1939 break;
1941 case BIT_FIELD_REF:
1942 pp_string (pp, "BIT_FIELD_REF <");
1943 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1944 pp_string (pp, ", ");
1945 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1946 pp_string (pp, ", ");
1947 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1948 pp_greater (pp);
1949 break;
1951 case BIT_INSERT_EXPR:
1952 pp_string (pp, "BIT_INSERT_EXPR <");
1953 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1954 pp_string (pp, ", ");
1955 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1956 pp_string (pp, ", ");
1957 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1958 pp_string (pp, " (");
1959 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1960 pp_decimal_int (pp,
1961 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1962 else
1963 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1964 spc, flags, false);
1965 pp_string (pp, " bits)>");
1966 break;
1968 case ARRAY_REF:
1969 case ARRAY_RANGE_REF:
1970 op0 = TREE_OPERAND (node, 0);
1971 if (op_prio (op0) < op_prio (node))
1972 pp_left_paren (pp);
1973 dump_generic_node (pp, op0, spc, flags, false);
1974 if (op_prio (op0) < op_prio (node))
1975 pp_right_paren (pp);
1976 pp_left_bracket (pp);
1977 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1978 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1979 pp_string (pp, " ...");
1980 pp_right_bracket (pp);
1982 op0 = array_ref_low_bound (node);
1983 op1 = array_ref_element_size (node);
1985 if (!integer_zerop (op0)
1986 || TREE_OPERAND (node, 2)
1987 || TREE_OPERAND (node, 3))
1989 pp_string (pp, "{lb: ");
1990 dump_generic_node (pp, op0, spc, flags, false);
1991 pp_string (pp, " sz: ");
1992 dump_generic_node (pp, op1, spc, flags, false);
1993 pp_right_brace (pp);
1995 break;
1997 case CONSTRUCTOR:
1999 unsigned HOST_WIDE_INT ix;
2000 tree field, val;
2001 bool is_struct_init = false;
2002 bool is_array_init = false;
2003 widest_int curidx;
2004 pp_left_brace (pp);
2005 if (TREE_CLOBBER_P (node))
2006 pp_string (pp, "CLOBBER");
2007 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2008 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2009 is_struct_init = true;
2010 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2011 && TYPE_DOMAIN (TREE_TYPE (node))
2012 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2013 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2014 == INTEGER_CST)
2016 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2017 is_array_init = true;
2018 curidx = wi::to_widest (minv);
2020 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2022 if (field)
2024 if (is_struct_init)
2026 pp_dot (pp);
2027 dump_generic_node (pp, field, spc, flags, false);
2028 pp_equal (pp);
2030 else if (is_array_init
2031 && (TREE_CODE (field) != INTEGER_CST
2032 || curidx != wi::to_widest (field)))
2034 pp_left_bracket (pp);
2035 if (TREE_CODE (field) == RANGE_EXPR)
2037 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2038 flags, false);
2039 pp_string (pp, " ... ");
2040 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2041 flags, false);
2042 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2043 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2045 else
2046 dump_generic_node (pp, field, spc, flags, false);
2047 if (TREE_CODE (field) == INTEGER_CST)
2048 curidx = wi::to_widest (field);
2049 pp_string (pp, "]=");
2052 if (is_array_init)
2053 curidx += 1;
2054 if (val && TREE_CODE (val) == ADDR_EXPR)
2055 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2056 val = TREE_OPERAND (val, 0);
2057 if (val && TREE_CODE (val) == FUNCTION_DECL)
2058 dump_decl_name (pp, val, flags);
2059 else
2060 dump_generic_node (pp, val, spc, flags, false);
2061 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2063 pp_comma (pp);
2064 pp_space (pp);
2067 pp_right_brace (pp);
2069 break;
2071 case COMPOUND_EXPR:
2073 tree *tp;
2074 if (flags & TDF_SLIM)
2076 pp_string (pp, "<COMPOUND_EXPR>");
2077 break;
2080 dump_generic_node (pp, TREE_OPERAND (node, 0),
2081 spc, flags, !(flags & TDF_SLIM));
2082 if (flags & TDF_SLIM)
2083 newline_and_indent (pp, spc);
2084 else
2086 pp_comma (pp);
2087 pp_space (pp);
2090 for (tp = &TREE_OPERAND (node, 1);
2091 TREE_CODE (*tp) == COMPOUND_EXPR;
2092 tp = &TREE_OPERAND (*tp, 1))
2094 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2095 spc, flags, !(flags & TDF_SLIM));
2096 if (flags & TDF_SLIM)
2097 newline_and_indent (pp, spc);
2098 else
2100 pp_comma (pp);
2101 pp_space (pp);
2105 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2107 break;
2109 case STATEMENT_LIST:
2111 tree_stmt_iterator si;
2112 bool first = true;
2114 if (flags & TDF_SLIM)
2116 pp_string (pp, "<STATEMENT_LIST>");
2117 break;
2120 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2122 if (!first)
2123 newline_and_indent (pp, spc);
2124 else
2125 first = false;
2126 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2129 break;
2131 case MODIFY_EXPR:
2132 case INIT_EXPR:
2133 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2134 false);
2135 pp_space (pp);
2136 pp_equal (pp);
2137 pp_space (pp);
2138 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2139 false);
2140 break;
2142 case TARGET_EXPR:
2143 pp_string (pp, "TARGET_EXPR <");
2144 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2145 pp_comma (pp);
2146 pp_space (pp);
2147 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2148 pp_greater (pp);
2149 break;
2151 case DECL_EXPR:
2152 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2153 is_stmt = false;
2154 break;
2156 case COND_EXPR:
2157 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2159 pp_string (pp, "if (");
2160 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2161 pp_right_paren (pp);
2162 /* The lowered cond_exprs should always be printed in full. */
2163 if (COND_EXPR_THEN (node)
2164 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2165 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2166 && COND_EXPR_ELSE (node)
2167 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2168 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2170 pp_space (pp);
2171 dump_generic_node (pp, COND_EXPR_THEN (node),
2172 0, flags, true);
2173 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2175 pp_string (pp, " else ");
2176 dump_generic_node (pp, COND_EXPR_ELSE (node),
2177 0, flags, true);
2180 else if (!(flags & TDF_SLIM))
2182 /* Output COND_EXPR_THEN. */
2183 if (COND_EXPR_THEN (node))
2185 newline_and_indent (pp, spc+2);
2186 pp_left_brace (pp);
2187 newline_and_indent (pp, spc+4);
2188 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2189 flags, true);
2190 newline_and_indent (pp, spc+2);
2191 pp_right_brace (pp);
2194 /* Output COND_EXPR_ELSE. */
2195 if (COND_EXPR_ELSE (node)
2196 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2198 newline_and_indent (pp, spc);
2199 pp_string (pp, "else");
2200 newline_and_indent (pp, spc+2);
2201 pp_left_brace (pp);
2202 newline_and_indent (pp, spc+4);
2203 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2204 flags, true);
2205 newline_and_indent (pp, spc+2);
2206 pp_right_brace (pp);
2209 is_expr = false;
2211 else
2213 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2214 pp_space (pp);
2215 pp_question (pp);
2216 pp_space (pp);
2217 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2218 pp_space (pp);
2219 pp_colon (pp);
2220 pp_space (pp);
2221 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2223 break;
2225 case BIND_EXPR:
2226 pp_left_brace (pp);
2227 if (!(flags & TDF_SLIM))
2229 if (BIND_EXPR_VARS (node))
2231 pp_newline (pp);
2233 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2235 print_declaration (pp, op0, spc+2, flags);
2236 pp_newline (pp);
2240 newline_and_indent (pp, spc+2);
2241 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2242 newline_and_indent (pp, spc);
2243 pp_right_brace (pp);
2245 is_expr = false;
2246 break;
2248 case CALL_EXPR:
2249 if (CALL_EXPR_FN (node) != NULL_TREE)
2250 print_call_name (pp, CALL_EXPR_FN (node), flags);
2251 else
2252 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2254 /* Print parameters. */
2255 pp_space (pp);
2256 pp_left_paren (pp);
2258 tree arg;
2259 call_expr_arg_iterator iter;
2260 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2262 dump_generic_node (pp, arg, spc, flags, false);
2263 if (more_call_expr_args_p (&iter))
2265 pp_comma (pp);
2266 pp_space (pp);
2270 if (CALL_EXPR_VA_ARG_PACK (node))
2272 if (call_expr_nargs (node) > 0)
2274 pp_comma (pp);
2275 pp_space (pp);
2277 pp_string (pp, "__builtin_va_arg_pack ()");
2279 pp_right_paren (pp);
2281 op1 = CALL_EXPR_STATIC_CHAIN (node);
2282 if (op1)
2284 pp_string (pp, " [static-chain: ");
2285 dump_generic_node (pp, op1, spc, flags, false);
2286 pp_right_bracket (pp);
2289 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2290 pp_string (pp, " [return slot optimization]");
2291 if (CALL_EXPR_TAILCALL (node))
2292 pp_string (pp, " [tail call]");
2293 break;
2295 case WITH_CLEANUP_EXPR:
2296 NIY;
2297 break;
2299 case CLEANUP_POINT_EXPR:
2300 pp_string (pp, "<<cleanup_point ");
2301 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2302 pp_string (pp, ">>");
2303 break;
2305 case PLACEHOLDER_EXPR:
2306 pp_string (pp, "<PLACEHOLDER_EXPR ");
2307 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2308 pp_greater (pp);
2309 break;
2311 /* Binary arithmetic and logic expressions. */
2312 case WIDEN_SUM_EXPR:
2313 case WIDEN_MULT_EXPR:
2314 case MULT_EXPR:
2315 case MULT_HIGHPART_EXPR:
2316 case PLUS_EXPR:
2317 case POINTER_PLUS_EXPR:
2318 case POINTER_DIFF_EXPR:
2319 case MINUS_EXPR:
2320 case TRUNC_DIV_EXPR:
2321 case CEIL_DIV_EXPR:
2322 case FLOOR_DIV_EXPR:
2323 case ROUND_DIV_EXPR:
2324 case TRUNC_MOD_EXPR:
2325 case CEIL_MOD_EXPR:
2326 case FLOOR_MOD_EXPR:
2327 case ROUND_MOD_EXPR:
2328 case RDIV_EXPR:
2329 case EXACT_DIV_EXPR:
2330 case LSHIFT_EXPR:
2331 case RSHIFT_EXPR:
2332 case LROTATE_EXPR:
2333 case RROTATE_EXPR:
2334 case WIDEN_LSHIFT_EXPR:
2335 case BIT_IOR_EXPR:
2336 case BIT_XOR_EXPR:
2337 case BIT_AND_EXPR:
2338 case TRUTH_ANDIF_EXPR:
2339 case TRUTH_ORIF_EXPR:
2340 case TRUTH_AND_EXPR:
2341 case TRUTH_OR_EXPR:
2342 case TRUTH_XOR_EXPR:
2343 case LT_EXPR:
2344 case LE_EXPR:
2345 case GT_EXPR:
2346 case GE_EXPR:
2347 case EQ_EXPR:
2348 case NE_EXPR:
2349 case UNLT_EXPR:
2350 case UNLE_EXPR:
2351 case UNGT_EXPR:
2352 case UNGE_EXPR:
2353 case UNEQ_EXPR:
2354 case LTGT_EXPR:
2355 case ORDERED_EXPR:
2356 case UNORDERED_EXPR:
2358 const char *op = op_symbol (node);
2359 op0 = TREE_OPERAND (node, 0);
2360 op1 = TREE_OPERAND (node, 1);
2362 /* When the operands are expressions with less priority,
2363 keep semantics of the tree representation. */
2364 if (op_prio (op0) <= op_prio (node))
2366 pp_left_paren (pp);
2367 dump_generic_node (pp, op0, spc, flags, false);
2368 pp_right_paren (pp);
2370 else
2371 dump_generic_node (pp, op0, spc, flags, false);
2373 pp_space (pp);
2374 pp_string (pp, op);
2375 pp_space (pp);
2377 /* When the operands are expressions with less priority,
2378 keep semantics of the tree representation. */
2379 if (op_prio (op1) <= op_prio (node))
2381 pp_left_paren (pp);
2382 dump_generic_node (pp, op1, spc, flags, false);
2383 pp_right_paren (pp);
2385 else
2386 dump_generic_node (pp, op1, spc, flags, false);
2388 break;
2390 /* Unary arithmetic and logic expressions. */
2391 case NEGATE_EXPR:
2392 case BIT_NOT_EXPR:
2393 case TRUTH_NOT_EXPR:
2394 case ADDR_EXPR:
2395 case PREDECREMENT_EXPR:
2396 case PREINCREMENT_EXPR:
2397 case INDIRECT_REF:
2398 if (TREE_CODE (node) == ADDR_EXPR
2399 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2400 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2401 ; /* Do not output '&' for strings and function pointers. */
2402 else
2403 pp_string (pp, op_symbol (node));
2405 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2407 pp_left_paren (pp);
2408 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2409 pp_right_paren (pp);
2411 else
2412 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2413 break;
2415 case POSTDECREMENT_EXPR:
2416 case POSTINCREMENT_EXPR:
2417 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2419 pp_left_paren (pp);
2420 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2421 pp_right_paren (pp);
2423 else
2424 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2425 pp_string (pp, op_symbol (node));
2426 break;
2428 case MIN_EXPR:
2429 pp_string (pp, "MIN_EXPR <");
2430 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2431 pp_string (pp, ", ");
2432 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2433 pp_greater (pp);
2434 break;
2436 case MAX_EXPR:
2437 pp_string (pp, "MAX_EXPR <");
2438 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2439 pp_string (pp, ", ");
2440 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2441 pp_greater (pp);
2442 break;
2444 case ABS_EXPR:
2445 pp_string (pp, "ABS_EXPR <");
2446 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2447 pp_greater (pp);
2448 break;
2450 case RANGE_EXPR:
2451 NIY;
2452 break;
2454 case ADDR_SPACE_CONVERT_EXPR:
2455 case FIXED_CONVERT_EXPR:
2456 case FIX_TRUNC_EXPR:
2457 case FLOAT_EXPR:
2458 CASE_CONVERT:
2459 type = TREE_TYPE (node);
2460 op0 = TREE_OPERAND (node, 0);
2461 if (type != TREE_TYPE (op0))
2463 pp_left_paren (pp);
2464 dump_generic_node (pp, type, spc, flags, false);
2465 pp_string (pp, ") ");
2467 if (op_prio (op0) < op_prio (node))
2468 pp_left_paren (pp);
2469 dump_generic_node (pp, op0, spc, flags, false);
2470 if (op_prio (op0) < op_prio (node))
2471 pp_right_paren (pp);
2472 break;
2474 case VIEW_CONVERT_EXPR:
2475 pp_string (pp, "VIEW_CONVERT_EXPR<");
2476 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2477 pp_string (pp, ">(");
2478 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2479 pp_right_paren (pp);
2480 break;
2482 case PAREN_EXPR:
2483 pp_string (pp, "((");
2484 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2485 pp_string (pp, "))");
2486 break;
2488 case NON_LVALUE_EXPR:
2489 pp_string (pp, "NON_LVALUE_EXPR <");
2490 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2491 pp_greater (pp);
2492 break;
2494 case SAVE_EXPR:
2495 pp_string (pp, "SAVE_EXPR <");
2496 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2497 pp_greater (pp);
2498 break;
2500 case COMPLEX_EXPR:
2501 pp_string (pp, "COMPLEX_EXPR <");
2502 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2503 pp_string (pp, ", ");
2504 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2505 pp_greater (pp);
2506 break;
2508 case CONJ_EXPR:
2509 pp_string (pp, "CONJ_EXPR <");
2510 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2511 pp_greater (pp);
2512 break;
2514 case REALPART_EXPR:
2515 if (flags & TDF_GIMPLE)
2517 pp_string (pp, "__real ");
2518 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2520 else
2522 pp_string (pp, "REALPART_EXPR <");
2523 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2524 pp_greater (pp);
2526 break;
2528 case IMAGPART_EXPR:
2529 if (flags & TDF_GIMPLE)
2531 pp_string (pp, "__imag ");
2532 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2534 else
2536 pp_string (pp, "IMAGPART_EXPR <");
2537 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2538 pp_greater (pp);
2540 break;
2542 case VA_ARG_EXPR:
2543 pp_string (pp, "VA_ARG_EXPR <");
2544 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2545 pp_greater (pp);
2546 break;
2548 case TRY_FINALLY_EXPR:
2549 case TRY_CATCH_EXPR:
2550 pp_string (pp, "try");
2551 newline_and_indent (pp, spc+2);
2552 pp_left_brace (pp);
2553 newline_and_indent (pp, spc+4);
2554 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2555 newline_and_indent (pp, spc+2);
2556 pp_right_brace (pp);
2557 newline_and_indent (pp, spc);
2558 pp_string (pp,
2559 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2560 newline_and_indent (pp, spc+2);
2561 pp_left_brace (pp);
2562 newline_and_indent (pp, spc+4);
2563 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2564 newline_and_indent (pp, spc+2);
2565 pp_right_brace (pp);
2566 is_expr = false;
2567 break;
2569 case CATCH_EXPR:
2570 pp_string (pp, "catch (");
2571 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2572 pp_right_paren (pp);
2573 newline_and_indent (pp, spc+2);
2574 pp_left_brace (pp);
2575 newline_and_indent (pp, spc+4);
2576 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2577 newline_and_indent (pp, spc+2);
2578 pp_right_brace (pp);
2579 is_expr = false;
2580 break;
2582 case EH_FILTER_EXPR:
2583 pp_string (pp, "<<<eh_filter (");
2584 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2585 pp_string (pp, ")>>>");
2586 newline_and_indent (pp, spc+2);
2587 pp_left_brace (pp);
2588 newline_and_indent (pp, spc+4);
2589 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2590 newline_and_indent (pp, spc+2);
2591 pp_right_brace (pp);
2592 is_expr = false;
2593 break;
2595 case LABEL_EXPR:
2596 op0 = TREE_OPERAND (node, 0);
2597 /* If this is for break or continue, don't bother printing it. */
2598 if (DECL_NAME (op0))
2600 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2601 if (strcmp (name, "break") == 0
2602 || strcmp (name, "continue") == 0)
2603 break;
2605 dump_generic_node (pp, op0, spc, flags, false);
2606 pp_colon (pp);
2607 if (DECL_NONLOCAL (op0))
2608 pp_string (pp, " [non-local]");
2609 break;
2611 case LOOP_EXPR:
2612 pp_string (pp, "while (1)");
2613 if (!(flags & TDF_SLIM))
2615 newline_and_indent (pp, spc+2);
2616 pp_left_brace (pp);
2617 newline_and_indent (pp, spc+4);
2618 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2619 newline_and_indent (pp, spc+2);
2620 pp_right_brace (pp);
2622 is_expr = false;
2623 break;
2625 case PREDICT_EXPR:
2626 pp_string (pp, "// predicted ");
2627 if (PREDICT_EXPR_OUTCOME (node))
2628 pp_string (pp, "likely by ");
2629 else
2630 pp_string (pp, "unlikely by ");
2631 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2632 pp_string (pp, " predictor.");
2633 break;
2635 case ANNOTATE_EXPR:
2636 pp_string (pp, "ANNOTATE_EXPR <");
2637 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2638 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2640 case annot_expr_ivdep_kind:
2641 pp_string (pp, ", ivdep");
2642 break;
2643 case annot_expr_unroll_kind:
2644 pp_printf (pp, ", unroll %d",
2645 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2646 break;
2647 case annot_expr_no_vector_kind:
2648 pp_string (pp, ", no-vector");
2649 break;
2650 case annot_expr_vector_kind:
2651 pp_string (pp, ", vector");
2652 break;
2653 case annot_expr_parallel_kind:
2654 pp_string (pp, ", parallel");
2655 break;
2656 default:
2657 gcc_unreachable ();
2659 pp_greater (pp);
2660 break;
2662 case RETURN_EXPR:
2663 pp_string (pp, "return");
2664 op0 = TREE_OPERAND (node, 0);
2665 if (op0)
2667 pp_space (pp);
2668 if (TREE_CODE (op0) == MODIFY_EXPR)
2669 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2670 spc, flags, false);
2671 else
2672 dump_generic_node (pp, op0, spc, flags, false);
2674 break;
2676 case EXIT_EXPR:
2677 pp_string (pp, "if (");
2678 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2679 pp_string (pp, ") break");
2680 break;
2682 case SWITCH_EXPR:
2683 pp_string (pp, "switch (");
2684 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2685 pp_right_paren (pp);
2686 if (!(flags & TDF_SLIM))
2688 newline_and_indent (pp, spc+2);
2689 pp_left_brace (pp);
2690 if (SWITCH_BODY (node))
2692 newline_and_indent (pp, spc+4);
2693 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2694 true);
2696 newline_and_indent (pp, spc+2);
2697 pp_right_brace (pp);
2699 is_expr = false;
2700 break;
2702 case GOTO_EXPR:
2703 op0 = GOTO_DESTINATION (node);
2704 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2706 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2707 if (strcmp (name, "break") == 0
2708 || strcmp (name, "continue") == 0)
2710 pp_string (pp, name);
2711 break;
2714 pp_string (pp, "goto ");
2715 dump_generic_node (pp, op0, spc, flags, false);
2716 break;
2718 case ASM_EXPR:
2719 pp_string (pp, "__asm__");
2720 if (ASM_VOLATILE_P (node))
2721 pp_string (pp, " __volatile__");
2722 pp_left_paren (pp);
2723 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2724 pp_colon (pp);
2725 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2726 pp_colon (pp);
2727 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2728 if (ASM_CLOBBERS (node))
2730 pp_colon (pp);
2731 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2733 pp_right_paren (pp);
2734 break;
2736 case CASE_LABEL_EXPR:
2737 if (CASE_LOW (node) && CASE_HIGH (node))
2739 pp_string (pp, "case ");
2740 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2741 pp_string (pp, " ... ");
2742 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2744 else if (CASE_LOW (node))
2746 pp_string (pp, "case ");
2747 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2749 else
2750 pp_string (pp, "default");
2751 pp_colon (pp);
2752 break;
2754 case OBJ_TYPE_REF:
2755 pp_string (pp, "OBJ_TYPE_REF(");
2756 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2757 pp_semicolon (pp);
2758 /* We omit the class type for -fcompare-debug because we may
2759 drop TYPE_BINFO early depending on debug info, and then
2760 virtual_method_call_p would return false, whereas when
2761 TYPE_BINFO is preserved it may still return true and then
2762 we'd print the class type. Compare tree and rtl dumps for
2763 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
2764 for example, at occurrences of OBJ_TYPE_REF. */
2765 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
2766 && virtual_method_call_p (node))
2768 pp_string (pp, "(");
2769 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2770 pp_string (pp, ")");
2772 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2773 pp_arrow (pp);
2774 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2775 pp_right_paren (pp);
2776 break;
2778 case SSA_NAME:
2779 if (SSA_NAME_IDENTIFIER (node))
2781 if ((flags & TDF_NOUID)
2782 && SSA_NAME_VAR (node)
2783 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2784 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2785 else if (! (flags & TDF_GIMPLE)
2786 || SSA_NAME_VAR (node))
2787 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2788 spc, flags, false);
2790 pp_underscore (pp);
2791 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2792 if (SSA_NAME_IS_DEFAULT_DEF (node))
2793 pp_string (pp, "(D)");
2794 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2795 pp_string (pp, "(ab)");
2796 break;
2798 case WITH_SIZE_EXPR:
2799 pp_string (pp, "WITH_SIZE_EXPR <");
2800 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2801 pp_string (pp, ", ");
2802 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2803 pp_greater (pp);
2804 break;
2806 case ASSERT_EXPR:
2807 pp_string (pp, "ASSERT_EXPR <");
2808 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2809 pp_string (pp, ", ");
2810 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2811 pp_greater (pp);
2812 break;
2814 case SCEV_KNOWN:
2815 pp_string (pp, "scev_known");
2816 break;
2818 case SCEV_NOT_KNOWN:
2819 pp_string (pp, "scev_not_known");
2820 break;
2822 case POLYNOMIAL_CHREC:
2823 pp_left_brace (pp);
2824 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2825 pp_string (pp, ", +, ");
2826 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2827 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
2828 is_stmt = false;
2829 break;
2831 case REALIGN_LOAD_EXPR:
2832 pp_string (pp, "REALIGN_LOAD <");
2833 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2834 pp_string (pp, ", ");
2835 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2836 pp_string (pp, ", ");
2837 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2838 pp_greater (pp);
2839 break;
2841 case VEC_COND_EXPR:
2842 pp_string (pp, " VEC_COND_EXPR < ");
2843 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2844 pp_string (pp, " , ");
2845 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2846 pp_string (pp, " , ");
2847 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2848 pp_string (pp, " > ");
2849 break;
2851 case VEC_PERM_EXPR:
2852 pp_string (pp, " VEC_PERM_EXPR < ");
2853 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2854 pp_string (pp, " , ");
2855 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2856 pp_string (pp, " , ");
2857 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2858 pp_string (pp, " > ");
2859 break;
2861 case DOT_PROD_EXPR:
2862 pp_string (pp, " DOT_PROD_EXPR < ");
2863 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2864 pp_string (pp, ", ");
2865 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2866 pp_string (pp, ", ");
2867 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2868 pp_string (pp, " > ");
2869 break;
2871 case WIDEN_MULT_PLUS_EXPR:
2872 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2873 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2874 pp_string (pp, ", ");
2875 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2876 pp_string (pp, ", ");
2877 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2878 pp_string (pp, " > ");
2879 break;
2881 case WIDEN_MULT_MINUS_EXPR:
2882 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2883 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2884 pp_string (pp, ", ");
2885 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2886 pp_string (pp, ", ");
2887 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2888 pp_string (pp, " > ");
2889 break;
2891 case FMA_EXPR:
2892 pp_string (pp, " FMA_EXPR < ");
2893 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2894 pp_string (pp, ", ");
2895 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2896 pp_string (pp, ", ");
2897 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2898 pp_string (pp, " > ");
2899 break;
2901 case OACC_PARALLEL:
2902 pp_string (pp, "#pragma acc parallel");
2903 goto dump_omp_clauses_body;
2905 case OACC_KERNELS:
2906 pp_string (pp, "#pragma acc kernels");
2907 goto dump_omp_clauses_body;
2909 case OACC_DATA:
2910 pp_string (pp, "#pragma acc data");
2911 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2912 goto dump_omp_body;
2914 case OACC_HOST_DATA:
2915 pp_string (pp, "#pragma acc host_data");
2916 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2917 goto dump_omp_body;
2919 case OACC_DECLARE:
2920 pp_string (pp, "#pragma acc declare");
2921 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2922 break;
2924 case OACC_UPDATE:
2925 pp_string (pp, "#pragma acc update");
2926 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2927 break;
2929 case OACC_ENTER_DATA:
2930 pp_string (pp, "#pragma acc enter data");
2931 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2932 break;
2934 case OACC_EXIT_DATA:
2935 pp_string (pp, "#pragma acc exit data");
2936 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2937 break;
2939 case OACC_CACHE:
2940 pp_string (pp, "#pragma acc cache");
2941 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2942 break;
2944 case OMP_PARALLEL:
2945 pp_string (pp, "#pragma omp parallel");
2946 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2947 goto dump_omp_body;
2949 dump_omp_clauses_body:
2950 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2951 goto dump_omp_body;
2953 dump_omp_body:
2954 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2956 newline_and_indent (pp, spc + 2);
2957 pp_left_brace (pp);
2958 newline_and_indent (pp, spc + 4);
2959 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2960 newline_and_indent (pp, spc + 2);
2961 pp_right_brace (pp);
2963 is_expr = false;
2964 break;
2966 case OMP_TASK:
2967 pp_string (pp, "#pragma omp task");
2968 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2969 goto dump_omp_body;
2971 case OMP_FOR:
2972 pp_string (pp, "#pragma omp for");
2973 goto dump_omp_loop;
2975 case OMP_SIMD:
2976 pp_string (pp, "#pragma omp simd");
2977 goto dump_omp_loop;
2979 case OMP_DISTRIBUTE:
2980 pp_string (pp, "#pragma omp distribute");
2981 goto dump_omp_loop;
2983 case OMP_TASKLOOP:
2984 pp_string (pp, "#pragma omp taskloop");
2985 goto dump_omp_loop;
2987 case OACC_LOOP:
2988 pp_string (pp, "#pragma acc loop");
2989 goto dump_omp_loop;
2991 case OMP_TEAMS:
2992 pp_string (pp, "#pragma omp teams");
2993 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2994 goto dump_omp_body;
2996 case OMP_TARGET_DATA:
2997 pp_string (pp, "#pragma omp target data");
2998 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2999 goto dump_omp_body;
3001 case OMP_TARGET_ENTER_DATA:
3002 pp_string (pp, "#pragma omp target enter data");
3003 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3004 is_expr = false;
3005 break;
3007 case OMP_TARGET_EXIT_DATA:
3008 pp_string (pp, "#pragma omp target exit data");
3009 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3010 is_expr = false;
3011 break;
3013 case OMP_TARGET:
3014 pp_string (pp, "#pragma omp target");
3015 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3016 goto dump_omp_body;
3018 case OMP_TARGET_UPDATE:
3019 pp_string (pp, "#pragma omp target update");
3020 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3021 is_expr = false;
3022 break;
3024 dump_omp_loop:
3025 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3026 if (!(flags & TDF_SLIM))
3028 int i;
3030 if (OMP_FOR_PRE_BODY (node))
3032 newline_and_indent (pp, spc + 2);
3033 pp_left_brace (pp);
3034 spc += 4;
3035 newline_and_indent (pp, spc);
3036 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3037 spc, flags, false);
3039 if (OMP_FOR_INIT (node))
3041 spc -= 2;
3042 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3044 spc += 2;
3045 newline_and_indent (pp, spc);
3046 pp_string (pp, "for (");
3047 dump_generic_node (pp,
3048 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3049 spc, flags, false);
3050 pp_string (pp, "; ");
3051 dump_generic_node (pp,
3052 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3053 spc, flags, false);
3054 pp_string (pp, "; ");
3055 dump_generic_node (pp,
3056 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3057 spc, flags, false);
3058 pp_right_paren (pp);
3061 if (OMP_FOR_BODY (node))
3063 newline_and_indent (pp, spc + 2);
3064 pp_left_brace (pp);
3065 newline_and_indent (pp, spc + 4);
3066 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3067 false);
3068 newline_and_indent (pp, spc + 2);
3069 pp_right_brace (pp);
3071 if (OMP_FOR_INIT (node))
3072 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3073 if (OMP_FOR_PRE_BODY (node))
3075 spc -= 4;
3076 newline_and_indent (pp, spc + 2);
3077 pp_right_brace (pp);
3080 is_expr = false;
3081 break;
3083 case OMP_SECTIONS:
3084 pp_string (pp, "#pragma omp sections");
3085 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3086 goto dump_omp_body;
3088 case OMP_SECTION:
3089 pp_string (pp, "#pragma omp section");
3090 goto dump_omp_body;
3092 case OMP_MASTER:
3093 pp_string (pp, "#pragma omp master");
3094 goto dump_omp_body;
3096 case OMP_TASKGROUP:
3097 pp_string (pp, "#pragma omp taskgroup");
3098 goto dump_omp_body;
3100 case OMP_ORDERED:
3101 pp_string (pp, "#pragma omp ordered");
3102 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3103 goto dump_omp_body;
3105 case OMP_CRITICAL:
3106 pp_string (pp, "#pragma omp critical");
3107 if (OMP_CRITICAL_NAME (node))
3109 pp_space (pp);
3110 pp_left_paren (pp);
3111 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3112 flags, false);
3113 pp_right_paren (pp);
3115 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3116 goto dump_omp_body;
3118 case OMP_ATOMIC:
3119 pp_string (pp, "#pragma omp atomic");
3120 if (OMP_ATOMIC_SEQ_CST (node))
3121 pp_string (pp, " seq_cst");
3122 newline_and_indent (pp, spc + 2);
3123 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3124 pp_space (pp);
3125 pp_equal (pp);
3126 pp_space (pp);
3127 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3128 break;
3130 case OMP_ATOMIC_READ:
3131 pp_string (pp, "#pragma omp atomic read");
3132 if (OMP_ATOMIC_SEQ_CST (node))
3133 pp_string (pp, " seq_cst");
3134 newline_and_indent (pp, spc + 2);
3135 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3136 pp_space (pp);
3137 break;
3139 case OMP_ATOMIC_CAPTURE_OLD:
3140 case OMP_ATOMIC_CAPTURE_NEW:
3141 pp_string (pp, "#pragma omp atomic capture");
3142 if (OMP_ATOMIC_SEQ_CST (node))
3143 pp_string (pp, " seq_cst");
3144 newline_and_indent (pp, spc + 2);
3145 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3146 pp_space (pp);
3147 pp_equal (pp);
3148 pp_space (pp);
3149 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3150 break;
3152 case OMP_SINGLE:
3153 pp_string (pp, "#pragma omp single");
3154 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3155 goto dump_omp_body;
3157 case OMP_CLAUSE:
3158 dump_omp_clause (pp, node, spc, flags);
3159 is_expr = false;
3160 break;
3162 case TRANSACTION_EXPR:
3163 if (TRANSACTION_EXPR_OUTER (node))
3164 pp_string (pp, "__transaction_atomic [[outer]]");
3165 else if (TRANSACTION_EXPR_RELAXED (node))
3166 pp_string (pp, "__transaction_relaxed");
3167 else
3168 pp_string (pp, "__transaction_atomic");
3169 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3171 newline_and_indent (pp, spc);
3172 pp_left_brace (pp);
3173 newline_and_indent (pp, spc + 2);
3174 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3175 spc + 2, flags, false);
3176 newline_and_indent (pp, spc);
3177 pp_right_brace (pp);
3179 is_expr = false;
3180 break;
3182 case VEC_SERIES_EXPR:
3183 case VEC_WIDEN_MULT_HI_EXPR:
3184 case VEC_WIDEN_MULT_LO_EXPR:
3185 case VEC_WIDEN_MULT_EVEN_EXPR:
3186 case VEC_WIDEN_MULT_ODD_EXPR:
3187 case VEC_WIDEN_LSHIFT_HI_EXPR:
3188 case VEC_WIDEN_LSHIFT_LO_EXPR:
3189 pp_space (pp);
3190 for (str = get_tree_code_name (code); *str; str++)
3191 pp_character (pp, TOUPPER (*str));
3192 pp_string (pp, " < ");
3193 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3194 pp_string (pp, ", ");
3195 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3196 pp_string (pp, " > ");
3197 break;
3199 case VEC_DUPLICATE_EXPR:
3200 pp_space (pp);
3201 for (str = get_tree_code_name (code); *str; str++)
3202 pp_character (pp, TOUPPER (*str));
3203 pp_string (pp, " < ");
3204 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3205 pp_string (pp, " > ");
3206 break;
3208 case VEC_UNPACK_HI_EXPR:
3209 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3210 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3211 pp_string (pp, " > ");
3212 break;
3214 case VEC_UNPACK_LO_EXPR:
3215 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3216 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3217 pp_string (pp, " > ");
3218 break;
3220 case VEC_UNPACK_FLOAT_HI_EXPR:
3221 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3222 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3223 pp_string (pp, " > ");
3224 break;
3226 case VEC_UNPACK_FLOAT_LO_EXPR:
3227 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3228 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3229 pp_string (pp, " > ");
3230 break;
3232 case VEC_PACK_TRUNC_EXPR:
3233 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3234 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3235 pp_string (pp, ", ");
3236 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3237 pp_string (pp, " > ");
3238 break;
3240 case VEC_PACK_SAT_EXPR:
3241 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3242 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3243 pp_string (pp, ", ");
3244 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3245 pp_string (pp, " > ");
3246 break;
3248 case VEC_PACK_FIX_TRUNC_EXPR:
3249 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3250 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3251 pp_string (pp, ", ");
3252 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3253 pp_string (pp, " > ");
3254 break;
3256 case BLOCK:
3257 dump_block_node (pp, node, spc, flags);
3258 break;
3260 case DEBUG_BEGIN_STMT:
3261 pp_string (pp, "# DEBUG BEGIN STMT");
3262 break;
3264 default:
3265 NIY;
3268 if (is_stmt && is_expr)
3269 pp_semicolon (pp);
3271 return spc;
3274 /* Print the declaration of a variable. */
3276 void
3277 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3279 INDENT (spc);
3281 if (TREE_CODE(t) == NAMELIST_DECL)
3283 pp_string(pp, "namelist ");
3284 dump_decl_name (pp, t, flags);
3285 pp_semicolon (pp);
3286 return;
3289 if (TREE_CODE (t) == TYPE_DECL)
3290 pp_string (pp, "typedef ");
3292 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3293 pp_string (pp, "register ");
3295 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3296 pp_string (pp, "extern ");
3297 else if (TREE_STATIC (t))
3298 pp_string (pp, "static ");
3300 /* Print the type and name. */
3301 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3303 tree tmp;
3305 /* Print array's type. */
3306 tmp = TREE_TYPE (t);
3307 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3308 tmp = TREE_TYPE (tmp);
3309 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3311 /* Print variable's name. */
3312 pp_space (pp);
3313 dump_generic_node (pp, t, spc, flags, false);
3315 /* Print the dimensions. */
3316 tmp = TREE_TYPE (t);
3317 while (TREE_CODE (tmp) == ARRAY_TYPE)
3319 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3320 tmp = TREE_TYPE (tmp);
3323 else if (TREE_CODE (t) == FUNCTION_DECL)
3325 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3326 pp_space (pp);
3327 dump_decl_name (pp, t, flags);
3328 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3330 else
3332 /* Print type declaration. */
3333 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3335 /* Print variable's name. */
3336 pp_space (pp);
3337 dump_generic_node (pp, t, spc, flags, false);
3340 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3342 pp_string (pp, " __asm__ ");
3343 pp_left_paren (pp);
3344 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3345 pp_right_paren (pp);
3348 /* The initial value of a function serves to determine whether the function
3349 is declared or defined. So the following does not apply to function
3350 nodes. */
3351 if (TREE_CODE (t) != FUNCTION_DECL)
3353 /* Print the initial value. */
3354 if (DECL_INITIAL (t))
3356 pp_space (pp);
3357 pp_equal (pp);
3358 pp_space (pp);
3359 if (!(flags & TDF_SLIM))
3360 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3361 else
3362 pp_string (pp, "<<< omitted >>>");
3366 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3368 pp_string (pp, " [value-expr: ");
3369 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3370 pp_right_bracket (pp);
3373 pp_semicolon (pp);
3377 /* Prints a structure: name, fields, and methods.
3378 FIXME: Still incomplete. */
3380 static void
3381 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3382 dump_flags_t flags)
3384 /* Print the name of the structure. */
3385 if (TYPE_NAME (node))
3387 INDENT (spc);
3388 if (TREE_CODE (node) == RECORD_TYPE)
3389 pp_string (pp, "struct ");
3390 else if ((TREE_CODE (node) == UNION_TYPE
3391 || TREE_CODE (node) == QUAL_UNION_TYPE))
3392 pp_string (pp, "union ");
3394 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3397 /* Print the contents of the structure. */
3398 pp_newline (pp);
3399 INDENT (spc);
3400 pp_left_brace (pp);
3401 pp_newline (pp);
3403 /* Print the fields of the structure. */
3405 tree tmp;
3406 tmp = TYPE_FIELDS (node);
3407 while (tmp)
3409 /* Avoid to print recursively the structure. */
3410 /* FIXME : Not implemented correctly...,
3411 what about the case when we have a cycle in the contain graph? ...
3412 Maybe this could be solved by looking at the scope in which the
3413 structure was declared. */
3414 if (TREE_TYPE (tmp) != node
3415 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3416 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3418 print_declaration (pp, tmp, spc+2, flags);
3419 pp_newline (pp);
3421 tmp = DECL_CHAIN (tmp);
3424 INDENT (spc);
3425 pp_right_brace (pp);
3428 /* Return the priority of the operator CODE.
3430 From lowest to highest precedence with either left-to-right (L-R)
3431 or right-to-left (R-L) associativity]:
3433 1 [L-R] ,
3434 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3435 3 [R-L] ?:
3436 4 [L-R] ||
3437 5 [L-R] &&
3438 6 [L-R] |
3439 7 [L-R] ^
3440 8 [L-R] &
3441 9 [L-R] == !=
3442 10 [L-R] < <= > >=
3443 11 [L-R] << >>
3444 12 [L-R] + -
3445 13 [L-R] * / %
3446 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3447 15 [L-R] fn() [] -> .
3449 unary +, - and * have higher precedence than the corresponding binary
3450 operators. */
3453 op_code_prio (enum tree_code code)
3455 switch (code)
3457 case TREE_LIST:
3458 case COMPOUND_EXPR:
3459 case BIND_EXPR:
3460 return 1;
3462 case MODIFY_EXPR:
3463 case INIT_EXPR:
3464 return 2;
3466 case COND_EXPR:
3467 return 3;
3469 case TRUTH_OR_EXPR:
3470 case TRUTH_ORIF_EXPR:
3471 return 4;
3473 case TRUTH_AND_EXPR:
3474 case TRUTH_ANDIF_EXPR:
3475 return 5;
3477 case BIT_IOR_EXPR:
3478 return 6;
3480 case BIT_XOR_EXPR:
3481 case TRUTH_XOR_EXPR:
3482 return 7;
3484 case BIT_AND_EXPR:
3485 return 8;
3487 case EQ_EXPR:
3488 case NE_EXPR:
3489 return 9;
3491 case UNLT_EXPR:
3492 case UNLE_EXPR:
3493 case UNGT_EXPR:
3494 case UNGE_EXPR:
3495 case UNEQ_EXPR:
3496 case LTGT_EXPR:
3497 case ORDERED_EXPR:
3498 case UNORDERED_EXPR:
3499 case LT_EXPR:
3500 case LE_EXPR:
3501 case GT_EXPR:
3502 case GE_EXPR:
3503 return 10;
3505 case LSHIFT_EXPR:
3506 case RSHIFT_EXPR:
3507 case LROTATE_EXPR:
3508 case RROTATE_EXPR:
3509 case VEC_WIDEN_LSHIFT_HI_EXPR:
3510 case VEC_WIDEN_LSHIFT_LO_EXPR:
3511 case WIDEN_LSHIFT_EXPR:
3512 return 11;
3514 case WIDEN_SUM_EXPR:
3515 case PLUS_EXPR:
3516 case POINTER_PLUS_EXPR:
3517 case POINTER_DIFF_EXPR:
3518 case MINUS_EXPR:
3519 return 12;
3521 case VEC_WIDEN_MULT_HI_EXPR:
3522 case VEC_WIDEN_MULT_LO_EXPR:
3523 case WIDEN_MULT_EXPR:
3524 case DOT_PROD_EXPR:
3525 case WIDEN_MULT_PLUS_EXPR:
3526 case WIDEN_MULT_MINUS_EXPR:
3527 case MULT_EXPR:
3528 case MULT_HIGHPART_EXPR:
3529 case TRUNC_DIV_EXPR:
3530 case CEIL_DIV_EXPR:
3531 case FLOOR_DIV_EXPR:
3532 case ROUND_DIV_EXPR:
3533 case RDIV_EXPR:
3534 case EXACT_DIV_EXPR:
3535 case TRUNC_MOD_EXPR:
3536 case CEIL_MOD_EXPR:
3537 case FLOOR_MOD_EXPR:
3538 case ROUND_MOD_EXPR:
3539 case FMA_EXPR:
3540 return 13;
3542 case TRUTH_NOT_EXPR:
3543 case BIT_NOT_EXPR:
3544 case POSTINCREMENT_EXPR:
3545 case POSTDECREMENT_EXPR:
3546 case PREINCREMENT_EXPR:
3547 case PREDECREMENT_EXPR:
3548 case NEGATE_EXPR:
3549 case INDIRECT_REF:
3550 case ADDR_EXPR:
3551 case FLOAT_EXPR:
3552 CASE_CONVERT:
3553 case FIX_TRUNC_EXPR:
3554 case TARGET_EXPR:
3555 return 14;
3557 case CALL_EXPR:
3558 case ARRAY_REF:
3559 case ARRAY_RANGE_REF:
3560 case COMPONENT_REF:
3561 return 15;
3563 /* Special expressions. */
3564 case MIN_EXPR:
3565 case MAX_EXPR:
3566 case ABS_EXPR:
3567 case REALPART_EXPR:
3568 case IMAGPART_EXPR:
3569 case VEC_UNPACK_HI_EXPR:
3570 case VEC_UNPACK_LO_EXPR:
3571 case VEC_UNPACK_FLOAT_HI_EXPR:
3572 case VEC_UNPACK_FLOAT_LO_EXPR:
3573 case VEC_PACK_TRUNC_EXPR:
3574 case VEC_PACK_SAT_EXPR:
3575 return 16;
3577 default:
3578 /* Return an arbitrarily high precedence to avoid surrounding single
3579 VAR_DECLs in ()s. */
3580 return 9999;
3584 /* Return the priority of the operator OP. */
3587 op_prio (const_tree op)
3589 enum tree_code code;
3591 if (op == NULL)
3592 return 9999;
3594 code = TREE_CODE (op);
3595 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3596 return op_prio (TREE_OPERAND (op, 0));
3598 return op_code_prio (code);
3601 /* Return the symbol associated with operator CODE. */
3603 const char *
3604 op_symbol_code (enum tree_code code)
3606 switch (code)
3608 case MODIFY_EXPR:
3609 return "=";
3611 case TRUTH_OR_EXPR:
3612 case TRUTH_ORIF_EXPR:
3613 return "||";
3615 case TRUTH_AND_EXPR:
3616 case TRUTH_ANDIF_EXPR:
3617 return "&&";
3619 case BIT_IOR_EXPR:
3620 return "|";
3622 case TRUTH_XOR_EXPR:
3623 case BIT_XOR_EXPR:
3624 return "^";
3626 case ADDR_EXPR:
3627 case BIT_AND_EXPR:
3628 return "&";
3630 case ORDERED_EXPR:
3631 return "ord";
3632 case UNORDERED_EXPR:
3633 return "unord";
3635 case EQ_EXPR:
3636 return "==";
3637 case UNEQ_EXPR:
3638 return "u==";
3640 case NE_EXPR:
3641 return "!=";
3643 case LT_EXPR:
3644 return "<";
3645 case UNLT_EXPR:
3646 return "u<";
3648 case LE_EXPR:
3649 return "<=";
3650 case UNLE_EXPR:
3651 return "u<=";
3653 case GT_EXPR:
3654 return ">";
3655 case UNGT_EXPR:
3656 return "u>";
3658 case GE_EXPR:
3659 return ">=";
3660 case UNGE_EXPR:
3661 return "u>=";
3663 case LTGT_EXPR:
3664 return "<>";
3666 case LSHIFT_EXPR:
3667 return "<<";
3669 case RSHIFT_EXPR:
3670 return ">>";
3672 case LROTATE_EXPR:
3673 return "r<<";
3675 case RROTATE_EXPR:
3676 return "r>>";
3678 case WIDEN_LSHIFT_EXPR:
3679 return "w<<";
3681 case POINTER_PLUS_EXPR:
3682 return "+";
3684 case PLUS_EXPR:
3685 return "+";
3687 case WIDEN_SUM_EXPR:
3688 return "w+";
3690 case WIDEN_MULT_EXPR:
3691 return "w*";
3693 case MULT_HIGHPART_EXPR:
3694 return "h*";
3696 case NEGATE_EXPR:
3697 case MINUS_EXPR:
3698 case POINTER_DIFF_EXPR:
3699 return "-";
3701 case BIT_NOT_EXPR:
3702 return "~";
3704 case TRUTH_NOT_EXPR:
3705 return "!";
3707 case MULT_EXPR:
3708 case INDIRECT_REF:
3709 return "*";
3711 case TRUNC_DIV_EXPR:
3712 case RDIV_EXPR:
3713 return "/";
3715 case CEIL_DIV_EXPR:
3716 return "/[cl]";
3718 case FLOOR_DIV_EXPR:
3719 return "/[fl]";
3721 case ROUND_DIV_EXPR:
3722 return "/[rd]";
3724 case EXACT_DIV_EXPR:
3725 return "/[ex]";
3727 case TRUNC_MOD_EXPR:
3728 return "%";
3730 case CEIL_MOD_EXPR:
3731 return "%[cl]";
3733 case FLOOR_MOD_EXPR:
3734 return "%[fl]";
3736 case ROUND_MOD_EXPR:
3737 return "%[rd]";
3739 case PREDECREMENT_EXPR:
3740 return " --";
3742 case PREINCREMENT_EXPR:
3743 return " ++";
3745 case POSTDECREMENT_EXPR:
3746 return "-- ";
3748 case POSTINCREMENT_EXPR:
3749 return "++ ";
3751 case MAX_EXPR:
3752 return "max";
3754 case MIN_EXPR:
3755 return "min";
3757 default:
3758 return "<<< ??? >>>";
3762 /* Return the symbol associated with operator OP. */
3764 static const char *
3765 op_symbol (const_tree op)
3767 return op_symbol_code (TREE_CODE (op));
3770 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3771 the gimple_call_fn of a GIMPLE_CALL. */
3773 void
3774 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3776 tree op0 = node;
3778 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3779 op0 = TREE_OPERAND (op0, 0);
3781 again:
3782 switch (TREE_CODE (op0))
3784 case VAR_DECL:
3785 case PARM_DECL:
3786 case FUNCTION_DECL:
3787 dump_function_name (pp, op0, flags);
3788 break;
3790 case ADDR_EXPR:
3791 case INDIRECT_REF:
3792 CASE_CONVERT:
3793 op0 = TREE_OPERAND (op0, 0);
3794 goto again;
3796 case COND_EXPR:
3797 pp_left_paren (pp);
3798 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3799 pp_string (pp, ") ? ");
3800 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3801 pp_string (pp, " : ");
3802 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3803 break;
3805 case ARRAY_REF:
3806 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3807 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3808 else
3809 dump_generic_node (pp, op0, 0, flags, false);
3810 break;
3812 case MEM_REF:
3813 if (integer_zerop (TREE_OPERAND (op0, 1)))
3815 op0 = TREE_OPERAND (op0, 0);
3816 goto again;
3818 /* Fallthru. */
3819 case COMPONENT_REF:
3820 case SSA_NAME:
3821 case OBJ_TYPE_REF:
3822 dump_generic_node (pp, op0, 0, flags, false);
3823 break;
3825 default:
3826 NIY;
3830 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3832 static void
3833 pretty_print_string (pretty_printer *pp, const char *str)
3835 if (str == NULL)
3836 return;
3838 while (*str)
3840 switch (str[0])
3842 case '\b':
3843 pp_string (pp, "\\b");
3844 break;
3846 case '\f':
3847 pp_string (pp, "\\f");
3848 break;
3850 case '\n':
3851 pp_string (pp, "\\n");
3852 break;
3854 case '\r':
3855 pp_string (pp, "\\r");
3856 break;
3858 case '\t':
3859 pp_string (pp, "\\t");
3860 break;
3862 case '\v':
3863 pp_string (pp, "\\v");
3864 break;
3866 case '\\':
3867 pp_string (pp, "\\\\");
3868 break;
3870 case '\"':
3871 pp_string (pp, "\\\"");
3872 break;
3874 case '\'':
3875 pp_string (pp, "\\'");
3876 break;
3878 /* No need to handle \0; the loop terminates on \0. */
3880 case '\1':
3881 pp_string (pp, "\\1");
3882 break;
3884 case '\2':
3885 pp_string (pp, "\\2");
3886 break;
3888 case '\3':
3889 pp_string (pp, "\\3");
3890 break;
3892 case '\4':
3893 pp_string (pp, "\\4");
3894 break;
3896 case '\5':
3897 pp_string (pp, "\\5");
3898 break;
3900 case '\6':
3901 pp_string (pp, "\\6");
3902 break;
3904 case '\7':
3905 pp_string (pp, "\\7");
3906 break;
3908 default:
3909 if (!ISPRINT (str[0]))
3911 char buf[5];
3912 sprintf (buf, "\\x%x", (unsigned char)str[0]);
3913 pp_string (pp, buf);
3915 else
3916 pp_character (pp, str[0]);
3917 break;
3919 str++;
3923 static void
3924 maybe_init_pretty_print (FILE *file)
3926 if (!tree_pp)
3928 tree_pp = new pretty_printer ();
3929 pp_needs_newline (tree_pp) = true;
3930 pp_translate_identifiers (tree_pp) = false;
3933 tree_pp->buffer->stream = file;
3936 static void
3937 newline_and_indent (pretty_printer *pp, int spc)
3939 pp_newline (pp);
3940 INDENT (spc);
3943 /* Handle the %K format for TEXT. Separate from default_tree_printer
3944 so it can also be used in front ends.
3945 Argument is a statement from which EXPR_LOCATION and TREE_BLOCK will
3946 be recorded. */
3948 void
3949 percent_K_format (text_info *text, tree t)
3951 text->set_location (0, EXPR_LOCATION (t), true);
3952 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3953 tree block = TREE_BLOCK (t);
3954 *pp_ti_abstract_origin (text) = NULL;
3956 if (in_lto_p)
3958 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3959 representing the outermost block of an inlined function.
3960 So walk the BLOCK tree until we hit such a scope. */
3961 while (block
3962 && TREE_CODE (block) == BLOCK)
3964 if (inlined_function_outer_scope_p (block))
3966 *pp_ti_abstract_origin (text) = block;
3967 break;
3969 block = BLOCK_SUPERCONTEXT (block);
3971 return;
3974 while (block
3975 && TREE_CODE (block) == BLOCK
3976 && BLOCK_ABSTRACT_ORIGIN (block))
3978 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3980 while (TREE_CODE (ao) == BLOCK
3981 && BLOCK_ABSTRACT_ORIGIN (ao)
3982 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3983 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3985 if (TREE_CODE (ao) == FUNCTION_DECL)
3987 *pp_ti_abstract_origin (text) = block;
3988 break;
3990 block = BLOCK_SUPERCONTEXT (block);
3994 /* Print the identifier ID to PRETTY-PRINTER. */
3996 void
3997 pp_tree_identifier (pretty_printer *pp, tree id)
3999 if (pp_translate_identifiers (pp))
4001 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4002 pp_append_text (pp, text, text + strlen (text));
4004 else
4005 pp_append_text (pp, IDENTIFIER_POINTER (id),
4006 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4009 /* A helper function that is used to dump function information before the
4010 function dump. */
4012 void
4013 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4015 const char *dname, *aname;
4016 struct cgraph_node *node = cgraph_node::get (fdecl);
4017 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4019 dname = lang_hooks.decl_printable_name (fdecl, 1);
4021 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4022 aname = (IDENTIFIER_POINTER
4023 (DECL_ASSEMBLER_NAME (fdecl)));
4024 else
4025 aname = "<unset-asm-name>";
4027 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4028 dname, aname, fun->funcdef_no);
4029 if (!(flags & TDF_NOUID))
4030 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4031 if (node)
4033 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
4034 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4035 node->frequency == NODE_FREQUENCY_HOT
4036 ? " (hot)"
4037 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4038 ? " (unlikely executed)"
4039 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4040 ? " (executed once)"
4041 : "");
4043 else
4044 fprintf (dump_file, ")\n\n");
4047 /* Dump double_int D to pretty_printer PP. UNS is true
4048 if D is unsigned and false otherwise. */
4049 void
4050 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4052 if (d.fits_shwi ())
4053 pp_wide_integer (pp, d.low);
4054 else if (d.fits_uhwi ())
4055 pp_unsigned_wide_integer (pp, d.low);
4056 else
4058 unsigned HOST_WIDE_INT low = d.low;
4059 HOST_WIDE_INT high = d.high;
4060 if (!uns && d.is_negative ())
4062 pp_minus (pp);
4063 high = ~high + !low;
4064 low = -low;
4066 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4067 systems? */
4068 sprintf (pp_buffer (pp)->digit_buffer,
4069 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4070 (unsigned HOST_WIDE_INT) high, low);
4071 pp_string (pp, pp_buffer (pp)->digit_buffer);