Do not error when -E provided (PR pch/78970).
[official-gcc.git] / gcc / tree-pretty-print.c
blob36b29d538783f40dd22c597184089a7d5000119a
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2017 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "backend.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "predict.h"
28 #include "cgraph.h"
29 #include "tree-pretty-print.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "dumpfile.h"
34 #include "internal-fn.h"
35 #include "gomp-constants.h"
37 /* Local functions, macros and variables. */
38 static const char *op_symbol (const_tree);
39 static void pretty_print_string (pretty_printer *, const char*);
40 static void newline_and_indent (pretty_printer *, int);
41 static void maybe_init_pretty_print (FILE *);
42 static void print_struct_decl (pretty_printer *, const_tree, int, int);
43 static void do_niy (pretty_printer *, const_tree, int);
45 #define INDENT(SPACE) do { \
46 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
48 #define NIY do_niy (pp, node, flags)
50 static pretty_printer *tree_pp;
52 /* Try to print something for an unknown tree code. */
54 static void
55 do_niy (pretty_printer *pp, const_tree node, int flags)
57 int i, len;
59 pp_string (pp, "<<< Unknown tree: ");
60 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
62 if (EXPR_P (node))
64 len = TREE_OPERAND_LENGTH (node);
65 for (i = 0; i < len; ++i)
67 newline_and_indent (pp, 2);
68 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
72 pp_string (pp, " >>>");
75 /* Debugging function to print out a generic expression. */
77 DEBUG_FUNCTION void
78 debug_generic_expr (tree t)
80 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
81 fprintf (stderr, "\n");
84 /* Debugging function to print out a generic statement. */
86 DEBUG_FUNCTION void
87 debug_generic_stmt (tree t)
89 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
90 fprintf (stderr, "\n");
93 /* Debugging function to print out a chain of trees . */
95 DEBUG_FUNCTION void
96 debug_tree_chain (tree t)
98 hash_set<tree> seen;
100 while (t)
102 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
103 fprintf (stderr, " ");
104 t = TREE_CHAIN (t);
105 if (seen.add (t))
107 fprintf (stderr, "... [cycled back to ");
108 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
109 fprintf (stderr, "]");
110 break;
113 fprintf (stderr, "\n");
116 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
117 void
118 print_generic_decl (FILE *file, tree decl, int flags)
120 maybe_init_pretty_print (file);
121 print_declaration (tree_pp, decl, 2, flags);
122 pp_write_text_to_stream (tree_pp);
125 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
126 to show in the dump. See TDF_* in dumpfile.h. */
128 void
129 print_generic_stmt (FILE *file, tree t, int flags)
131 maybe_init_pretty_print (file);
132 dump_generic_node (tree_pp, t, 0, flags, true);
133 pp_newline_and_flush (tree_pp);
136 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
137 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
138 INDENT spaces. */
140 void
141 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
143 int i;
145 maybe_init_pretty_print (file);
147 for (i = 0; i < indent; i++)
148 pp_space (tree_pp);
149 dump_generic_node (tree_pp, t, indent, flags, true);
150 pp_newline_and_flush (tree_pp);
153 /* Print a single expression T on file FILE. FLAGS specifies details to show
154 in the dump. See TDF_* in dumpfile.h. */
156 void
157 print_generic_expr (FILE *file, tree t, int flags)
159 maybe_init_pretty_print (file);
160 dump_generic_node (tree_pp, t, 0, flags, false);
161 pp_flush (tree_pp);
164 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
165 in it are replaced with Dxxxx, as long as they are at the start or
166 preceded by $ and at the end or followed by $. See make_fancy_name
167 in tree-sra.c. */
169 static void
170 dump_fancy_name (pretty_printer *pp, tree name)
172 int cnt = 0;
173 int length = IDENTIFIER_LENGTH (name);
174 const char *n = IDENTIFIER_POINTER (name);
177 n = strchr (n, 'D');
178 if (n == NULL)
179 break;
180 if (ISDIGIT (n[1])
181 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
183 int l = 2;
184 while (ISDIGIT (n[l]))
185 l++;
186 if (n[l] == '\0' || n[l] == '$')
188 cnt++;
189 length += 5 - l;
191 n += l;
193 else
194 n++;
196 while (1);
197 if (cnt == 0)
199 pp_tree_identifier (pp, name);
200 return;
203 char *str = XNEWVEC (char, length + 1);
204 char *p = str;
205 const char *q;
206 q = n = IDENTIFIER_POINTER (name);
209 q = strchr (q, 'D');
210 if (q == NULL)
211 break;
212 if (ISDIGIT (q[1])
213 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
215 int l = 2;
216 while (ISDIGIT (q[l]))
217 l++;
218 if (q[l] == '\0' || q[l] == '$')
220 memcpy (p, n, q - n);
221 memcpy (p + (q - n), "Dxxxx", 5);
222 p += (q - n) + 5;
223 n = q + l;
225 q += l;
227 else
228 q++;
230 while (1);
231 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
232 str[length] = '\0';
233 if (pp_translate_identifiers (pp))
235 const char *text = identifier_to_locale (str);
236 pp_append_text (pp, text, text + strlen (text));
238 else
239 pp_append_text (pp, str, str + length);
240 XDELETEVEC (str);
243 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
244 in FLAGS. */
246 static void
247 dump_decl_name (pretty_printer *pp, tree node, int flags)
249 if (DECL_NAME (node))
251 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
252 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
253 /* For DECL_NAMELESS names look for embedded uids in the
254 names and sanitize them for TDF_NOUID. */
255 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
256 dump_fancy_name (pp, DECL_NAME (node));
257 else
258 pp_tree_identifier (pp, DECL_NAME (node));
260 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
261 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
263 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
264 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
265 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
267 if (flags & TDF_NOUID)
268 pp_string (pp, "D#xxxx");
269 else
270 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
272 else
274 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
275 if (flags & TDF_NOUID)
276 pp_printf (pp, "%c.xxxx", c);
277 else
278 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
281 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
283 if (flags & TDF_NOUID)
284 pp_printf (pp, "ptD.xxxx");
285 else
286 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
290 /* Like the above, but used for pretty printing function calls. */
292 static void
293 dump_function_name (pretty_printer *pp, tree node, int flags)
295 if (CONVERT_EXPR_P (node))
296 node = TREE_OPERAND (node, 0);
297 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
298 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
299 else
300 dump_decl_name (pp, node, flags);
303 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
304 FLAGS are as in dump_generic_node. */
306 static void
307 dump_function_declaration (pretty_printer *pp, tree node,
308 int spc, int flags)
310 bool wrote_arg = false;
311 tree arg;
313 pp_space (pp);
314 pp_left_paren (pp);
316 /* Print the argument types. */
317 arg = TYPE_ARG_TYPES (node);
318 while (arg && arg != void_list_node && arg != error_mark_node)
320 if (wrote_arg)
322 pp_comma (pp);
323 pp_space (pp);
325 wrote_arg = true;
326 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
327 arg = TREE_CHAIN (arg);
330 /* Drop the trailing void_type_node if we had any previous argument. */
331 if (arg == void_list_node && !wrote_arg)
332 pp_string (pp, "void");
333 /* Properly dump vararg function types. */
334 else if (!arg && wrote_arg)
335 pp_string (pp, ", ...");
336 /* Avoid printing any arg for unprototyped functions. */
338 pp_right_paren (pp);
341 /* Dump the domain associated with an array. */
343 static void
344 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
346 pp_left_bracket (pp);
347 if (domain)
349 tree min = TYPE_MIN_VALUE (domain);
350 tree max = TYPE_MAX_VALUE (domain);
352 if (min && max
353 && integer_zerop (min)
354 && tree_fits_shwi_p (max))
355 pp_wide_integer (pp, tree_to_shwi (max) + 1);
356 else
358 if (min)
359 dump_generic_node (pp, min, spc, flags, false);
360 pp_colon (pp);
361 if (max)
362 dump_generic_node (pp, max, spc, flags, false);
365 else
366 pp_string (pp, "<unknown>");
367 pp_right_bracket (pp);
371 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
372 dump_generic_node. */
374 static void
375 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
377 const char *name;
379 switch (OMP_CLAUSE_CODE (clause))
381 case OMP_CLAUSE_PRIVATE:
382 name = "private";
383 goto print_remap;
384 case OMP_CLAUSE_SHARED:
385 name = "shared";
386 goto print_remap;
387 case OMP_CLAUSE_FIRSTPRIVATE:
388 name = "firstprivate";
389 goto print_remap;
390 case OMP_CLAUSE_LASTPRIVATE:
391 name = "lastprivate";
392 goto print_remap;
393 case OMP_CLAUSE_COPYIN:
394 name = "copyin";
395 goto print_remap;
396 case OMP_CLAUSE_COPYPRIVATE:
397 name = "copyprivate";
398 goto print_remap;
399 case OMP_CLAUSE_UNIFORM:
400 name = "uniform";
401 goto print_remap;
402 case OMP_CLAUSE_USE_DEVICE_PTR:
403 name = "use_device_ptr";
404 goto print_remap;
405 case OMP_CLAUSE_IS_DEVICE_PTR:
406 name = "is_device_ptr";
407 goto print_remap;
408 case OMP_CLAUSE__LOOPTEMP_:
409 name = "_looptemp_";
410 goto print_remap;
411 case OMP_CLAUSE_TO_DECLARE:
412 name = "to";
413 goto print_remap;
414 case OMP_CLAUSE_LINK:
415 name = "link";
416 goto print_remap;
417 print_remap:
418 pp_string (pp, name);
419 pp_left_paren (pp);
420 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
421 spc, flags, false);
422 pp_right_paren (pp);
423 break;
425 case OMP_CLAUSE_REDUCTION:
426 pp_string (pp, "reduction(");
427 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
429 pp_string (pp,
430 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
431 pp_colon (pp);
433 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
434 spc, flags, false);
435 pp_right_paren (pp);
436 break;
438 case OMP_CLAUSE_IF:
439 pp_string (pp, "if(");
440 switch (OMP_CLAUSE_IF_MODIFIER (clause))
442 case ERROR_MARK: break;
443 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
444 case OMP_TASK: pp_string (pp, "task:"); break;
445 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
446 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
447 case OMP_TARGET: pp_string (pp, "target:"); break;
448 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
449 case OMP_TARGET_ENTER_DATA:
450 pp_string (pp, "target enter data:"); break;
451 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
452 default: gcc_unreachable ();
454 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
455 spc, flags, false);
456 pp_right_paren (pp);
457 break;
459 case OMP_CLAUSE_NUM_THREADS:
460 pp_string (pp, "num_threads(");
461 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
462 spc, flags, false);
463 pp_right_paren (pp);
464 break;
466 case OMP_CLAUSE__CILK_FOR_COUNT_:
467 pp_string (pp, "_Cilk_for_count_(");
468 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
469 spc, flags, false);
470 pp_right_paren (pp);
471 break;
473 case OMP_CLAUSE_NOWAIT:
474 pp_string (pp, "nowait");
475 break;
476 case OMP_CLAUSE_ORDERED:
477 pp_string (pp, "ordered");
478 if (OMP_CLAUSE_ORDERED_EXPR (clause))
480 pp_left_paren (pp);
481 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
482 spc, flags, false);
483 pp_right_paren (pp);
485 break;
487 case OMP_CLAUSE_DEFAULT:
488 pp_string (pp, "default(");
489 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
491 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
492 break;
493 case OMP_CLAUSE_DEFAULT_SHARED:
494 pp_string (pp, "shared");
495 break;
496 case OMP_CLAUSE_DEFAULT_NONE:
497 pp_string (pp, "none");
498 break;
499 case OMP_CLAUSE_DEFAULT_PRIVATE:
500 pp_string (pp, "private");
501 break;
502 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
503 pp_string (pp, "firstprivate");
504 break;
505 default:
506 gcc_unreachable ();
508 pp_right_paren (pp);
509 break;
511 case OMP_CLAUSE_SCHEDULE:
512 pp_string (pp, "schedule(");
513 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
514 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
515 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
517 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
518 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
519 pp_string (pp, "monotonic");
520 else
521 pp_string (pp, "nonmonotonic");
522 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
523 pp_comma (pp);
524 else
525 pp_colon (pp);
527 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
528 pp_string (pp, "simd:");
530 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
532 case OMP_CLAUSE_SCHEDULE_STATIC:
533 pp_string (pp, "static");
534 break;
535 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
536 pp_string (pp, "dynamic");
537 break;
538 case OMP_CLAUSE_SCHEDULE_GUIDED:
539 pp_string (pp, "guided");
540 break;
541 case OMP_CLAUSE_SCHEDULE_RUNTIME:
542 pp_string (pp, "runtime");
543 break;
544 case OMP_CLAUSE_SCHEDULE_AUTO:
545 pp_string (pp, "auto");
546 break;
547 case OMP_CLAUSE_SCHEDULE_CILKFOR:
548 pp_string (pp, "cilk-for grain");
549 break;
550 default:
551 gcc_unreachable ();
553 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
555 pp_comma (pp);
556 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
557 spc, flags, false);
559 pp_right_paren (pp);
560 break;
562 case OMP_CLAUSE_UNTIED:
563 pp_string (pp, "untied");
564 break;
566 case OMP_CLAUSE_COLLAPSE:
567 pp_string (pp, "collapse(");
568 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
569 spc, flags, false);
570 pp_right_paren (pp);
571 break;
573 case OMP_CLAUSE_FINAL:
574 pp_string (pp, "final(");
575 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
576 spc, flags, false);
577 pp_right_paren (pp);
578 break;
580 case OMP_CLAUSE_MERGEABLE:
581 pp_string (pp, "mergeable");
582 break;
584 case OMP_CLAUSE_LINEAR:
585 pp_string (pp, "linear(");
586 switch (OMP_CLAUSE_LINEAR_KIND (clause))
588 case OMP_CLAUSE_LINEAR_DEFAULT:
589 break;
590 case OMP_CLAUSE_LINEAR_REF:
591 pp_string (pp, "ref(");
592 break;
593 case OMP_CLAUSE_LINEAR_VAL:
594 pp_string (pp, "val(");
595 break;
596 case OMP_CLAUSE_LINEAR_UVAL:
597 pp_string (pp, "uval(");
598 break;
599 default:
600 gcc_unreachable ();
602 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
603 spc, flags, false);
604 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
605 pp_right_paren (pp);
606 pp_colon (pp);
607 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
608 spc, flags, false);
609 pp_right_paren (pp);
610 break;
612 case OMP_CLAUSE_ALIGNED:
613 pp_string (pp, "aligned(");
614 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
615 spc, flags, false);
616 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
618 pp_colon (pp);
619 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
620 spc, flags, false);
622 pp_right_paren (pp);
623 break;
625 case OMP_CLAUSE_DEPEND:
626 pp_string (pp, "depend(");
627 switch (OMP_CLAUSE_DEPEND_KIND (clause))
629 case OMP_CLAUSE_DEPEND_IN:
630 pp_string (pp, "in");
631 break;
632 case OMP_CLAUSE_DEPEND_OUT:
633 pp_string (pp, "out");
634 break;
635 case OMP_CLAUSE_DEPEND_INOUT:
636 pp_string (pp, "inout");
637 break;
638 case OMP_CLAUSE_DEPEND_SOURCE:
639 pp_string (pp, "source)");
640 return;
641 case OMP_CLAUSE_DEPEND_SINK:
642 pp_string (pp, "sink:");
643 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
644 if (TREE_CODE (t) == TREE_LIST)
646 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
647 if (TREE_PURPOSE (t) != integer_zero_node)
649 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
650 pp_minus (pp);
651 else
652 pp_plus (pp);
653 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
654 false);
656 if (TREE_CHAIN (t))
657 pp_comma (pp);
659 else
660 gcc_unreachable ();
661 pp_right_paren (pp);
662 return;
663 default:
664 gcc_unreachable ();
666 pp_colon (pp);
667 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
668 spc, flags, false);
669 pp_right_paren (pp);
670 break;
672 case OMP_CLAUSE_MAP:
673 pp_string (pp, "map(");
674 switch (OMP_CLAUSE_MAP_KIND (clause))
676 case GOMP_MAP_ALLOC:
677 case GOMP_MAP_POINTER:
678 pp_string (pp, "alloc");
679 break;
680 case GOMP_MAP_TO:
681 case GOMP_MAP_TO_PSET:
682 pp_string (pp, "to");
683 break;
684 case GOMP_MAP_FROM:
685 pp_string (pp, "from");
686 break;
687 case GOMP_MAP_TOFROM:
688 pp_string (pp, "tofrom");
689 break;
690 case GOMP_MAP_FORCE_ALLOC:
691 pp_string (pp, "force_alloc");
692 break;
693 case GOMP_MAP_FORCE_TO:
694 pp_string (pp, "force_to");
695 break;
696 case GOMP_MAP_FORCE_FROM:
697 pp_string (pp, "force_from");
698 break;
699 case GOMP_MAP_FORCE_TOFROM:
700 pp_string (pp, "force_tofrom");
701 break;
702 case GOMP_MAP_FORCE_PRESENT:
703 pp_string (pp, "force_present");
704 break;
705 case GOMP_MAP_DELETE:
706 pp_string (pp, "delete");
707 break;
708 case GOMP_MAP_FORCE_DEVICEPTR:
709 pp_string (pp, "force_deviceptr");
710 break;
711 case GOMP_MAP_ALWAYS_TO:
712 pp_string (pp, "always,to");
713 break;
714 case GOMP_MAP_ALWAYS_FROM:
715 pp_string (pp, "always,from");
716 break;
717 case GOMP_MAP_ALWAYS_TOFROM:
718 pp_string (pp, "always,tofrom");
719 break;
720 case GOMP_MAP_RELEASE:
721 pp_string (pp, "release");
722 break;
723 case GOMP_MAP_FIRSTPRIVATE_POINTER:
724 pp_string (pp, "firstprivate");
725 break;
726 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
727 pp_string (pp, "firstprivate ref");
728 break;
729 case GOMP_MAP_STRUCT:
730 pp_string (pp, "struct");
731 break;
732 case GOMP_MAP_ALWAYS_POINTER:
733 pp_string (pp, "always_pointer");
734 break;
735 case GOMP_MAP_DEVICE_RESIDENT:
736 pp_string (pp, "device_resident");
737 break;
738 case GOMP_MAP_LINK:
739 pp_string (pp, "link");
740 break;
741 default:
742 gcc_unreachable ();
744 pp_colon (pp);
745 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
746 spc, flags, false);
747 print_clause_size:
748 if (OMP_CLAUSE_SIZE (clause))
750 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
751 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
753 case GOMP_MAP_POINTER:
754 case GOMP_MAP_FIRSTPRIVATE_POINTER:
755 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
756 case GOMP_MAP_ALWAYS_POINTER:
757 pp_string (pp, " [pointer assign, bias: ");
758 break;
759 case GOMP_MAP_TO_PSET:
760 pp_string (pp, " [pointer set, len: ");
761 break;
762 default:
763 pp_string (pp, " [len: ");
764 break;
766 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
767 spc, flags, false);
768 pp_right_bracket (pp);
770 pp_right_paren (pp);
771 break;
773 case OMP_CLAUSE_FROM:
774 pp_string (pp, "from(");
775 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
776 spc, flags, false);
777 goto print_clause_size;
779 case OMP_CLAUSE_TO:
780 pp_string (pp, "to(");
781 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
782 spc, flags, false);
783 goto print_clause_size;
785 case OMP_CLAUSE__CACHE_:
786 pp_string (pp, "(");
787 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
788 spc, flags, false);
789 goto print_clause_size;
791 case OMP_CLAUSE_NUM_TEAMS:
792 pp_string (pp, "num_teams(");
793 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
794 spc, flags, false);
795 pp_right_paren (pp);
796 break;
798 case OMP_CLAUSE_THREAD_LIMIT:
799 pp_string (pp, "thread_limit(");
800 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
801 spc, flags, false);
802 pp_right_paren (pp);
803 break;
805 case OMP_CLAUSE_DEVICE:
806 pp_string (pp, "device(");
807 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
808 spc, flags, false);
809 pp_right_paren (pp);
810 break;
812 case OMP_CLAUSE_DIST_SCHEDULE:
813 pp_string (pp, "dist_schedule(static");
814 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
816 pp_comma (pp);
817 dump_generic_node (pp,
818 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
819 spc, flags, false);
821 pp_right_paren (pp);
822 break;
824 case OMP_CLAUSE_PROC_BIND:
825 pp_string (pp, "proc_bind(");
826 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
828 case OMP_CLAUSE_PROC_BIND_MASTER:
829 pp_string (pp, "master");
830 break;
831 case OMP_CLAUSE_PROC_BIND_CLOSE:
832 pp_string (pp, "close");
833 break;
834 case OMP_CLAUSE_PROC_BIND_SPREAD:
835 pp_string (pp, "spread");
836 break;
837 default:
838 gcc_unreachable ();
840 pp_right_paren (pp);
841 break;
843 case OMP_CLAUSE_SAFELEN:
844 pp_string (pp, "safelen(");
845 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
846 spc, flags, false);
847 pp_right_paren (pp);
848 break;
850 case OMP_CLAUSE_SIMDLEN:
851 pp_string (pp, "simdlen(");
852 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
853 spc, flags, false);
854 pp_right_paren (pp);
855 break;
857 case OMP_CLAUSE_PRIORITY:
858 pp_string (pp, "priority(");
859 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
860 spc, flags, false);
861 pp_right_paren (pp);
862 break;
864 case OMP_CLAUSE_GRAINSIZE:
865 pp_string (pp, "grainsize(");
866 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
867 spc, flags, false);
868 pp_right_paren (pp);
869 break;
871 case OMP_CLAUSE_NUM_TASKS:
872 pp_string (pp, "num_tasks(");
873 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
874 spc, flags, false);
875 pp_right_paren (pp);
876 break;
878 case OMP_CLAUSE_HINT:
879 pp_string (pp, "hint(");
880 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
881 spc, flags, false);
882 pp_right_paren (pp);
883 break;
885 case OMP_CLAUSE_DEFAULTMAP:
886 pp_string (pp, "defaultmap(tofrom:scalar)");
887 break;
889 case OMP_CLAUSE__SIMDUID_:
890 pp_string (pp, "_simduid_(");
891 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
892 spc, flags, false);
893 pp_right_paren (pp);
894 break;
896 case OMP_CLAUSE__SIMT_:
897 pp_string (pp, "_simt_");
898 break;
900 case OMP_CLAUSE_GANG:
901 pp_string (pp, "gang");
902 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
904 pp_string (pp, "(num: ");
905 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
906 spc, flags, false);
908 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
910 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
911 pp_left_paren (pp);
912 else
913 pp_space (pp);
914 pp_string (pp, "static:");
915 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
916 == integer_minus_one_node)
917 pp_character (pp, '*');
918 else
919 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
920 spc, flags, false);
922 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
923 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
924 pp_right_paren (pp);
925 break;
927 case OMP_CLAUSE_ASYNC:
928 pp_string (pp, "async");
929 if (OMP_CLAUSE_ASYNC_EXPR (clause))
931 pp_character(pp, '(');
932 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
933 spc, flags, false);
934 pp_character(pp, ')');
936 break;
938 case OMP_CLAUSE_AUTO:
939 case OMP_CLAUSE_SEQ:
940 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
941 break;
943 case OMP_CLAUSE_WAIT:
944 pp_string (pp, "wait(");
945 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
946 spc, flags, false);
947 pp_character(pp, ')');
948 break;
950 case OMP_CLAUSE_WORKER:
951 pp_string (pp, "worker");
952 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
954 pp_left_paren (pp);
955 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
956 spc, flags, false);
957 pp_right_paren (pp);
959 break;
961 case OMP_CLAUSE_VECTOR:
962 pp_string (pp, "vector");
963 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
965 pp_left_paren (pp);
966 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
967 spc, flags, false);
968 pp_right_paren (pp);
970 break;
972 case OMP_CLAUSE_NUM_GANGS:
973 pp_string (pp, "num_gangs(");
974 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
975 spc, flags, false);
976 pp_character (pp, ')');
977 break;
979 case OMP_CLAUSE_NUM_WORKERS:
980 pp_string (pp, "num_workers(");
981 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
982 spc, flags, false);
983 pp_character (pp, ')');
984 break;
986 case OMP_CLAUSE_VECTOR_LENGTH:
987 pp_string (pp, "vector_length(");
988 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
989 spc, flags, false);
990 pp_character (pp, ')');
991 break;
993 case OMP_CLAUSE_INBRANCH:
994 pp_string (pp, "inbranch");
995 break;
996 case OMP_CLAUSE_NOTINBRANCH:
997 pp_string (pp, "notinbranch");
998 break;
999 case OMP_CLAUSE_FOR:
1000 pp_string (pp, "for");
1001 break;
1002 case OMP_CLAUSE_PARALLEL:
1003 pp_string (pp, "parallel");
1004 break;
1005 case OMP_CLAUSE_SECTIONS:
1006 pp_string (pp, "sections");
1007 break;
1008 case OMP_CLAUSE_TASKGROUP:
1009 pp_string (pp, "taskgroup");
1010 break;
1011 case OMP_CLAUSE_NOGROUP:
1012 pp_string (pp, "nogroup");
1013 break;
1014 case OMP_CLAUSE_THREADS:
1015 pp_string (pp, "threads");
1016 break;
1017 case OMP_CLAUSE_SIMD:
1018 pp_string (pp, "simd");
1019 break;
1020 case OMP_CLAUSE_INDEPENDENT:
1021 pp_string (pp, "independent");
1022 break;
1023 case OMP_CLAUSE_TILE:
1024 pp_string (pp, "tile(");
1025 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1026 spc, flags, false);
1027 pp_right_paren (pp);
1028 break;
1030 case OMP_CLAUSE__GRIDDIM_:
1031 pp_string (pp, "_griddim_(");
1032 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1033 pp_colon (pp);
1034 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1035 false);
1036 pp_comma (pp);
1037 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1038 false);
1039 pp_right_paren (pp);
1040 break;
1042 default:
1043 /* Should never happen. */
1044 dump_generic_node (pp, clause, spc, flags, false);
1045 break;
1050 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1051 dump_generic_node. */
1053 void
1054 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
1056 if (clause == NULL)
1057 return;
1059 pp_space (pp);
1060 while (1)
1062 dump_omp_clause (pp, clause, spc, flags);
1063 clause = OMP_CLAUSE_CHAIN (clause);
1064 if (clause == NULL)
1065 return;
1066 pp_space (pp);
1071 /* Dump location LOC to PP. */
1073 void
1074 dump_location (pretty_printer *pp, location_t loc)
1076 expanded_location xloc = expand_location (loc);
1078 pp_left_bracket (pp);
1079 if (xloc.file)
1081 pp_string (pp, xloc.file);
1082 pp_string (pp, ":");
1084 pp_decimal_int (pp, xloc.line);
1085 pp_colon (pp);
1086 pp_decimal_int (pp, xloc.column);
1087 pp_string (pp, "] ");
1091 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1092 dump_generic_node. */
1094 static void
1095 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
1097 tree t;
1099 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1101 if (flags & TDF_ADDRESS)
1102 pp_printf (pp, "[%p] ", (void *) block);
1104 if (BLOCK_ABSTRACT (block))
1105 pp_string (pp, "[abstract] ");
1107 if (TREE_ASM_WRITTEN (block))
1108 pp_string (pp, "[written] ");
1110 if (flags & TDF_SLIM)
1111 return;
1113 if (BLOCK_SOURCE_LOCATION (block))
1114 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1116 newline_and_indent (pp, spc + 2);
1118 if (BLOCK_SUPERCONTEXT (block))
1120 pp_string (pp, "SUPERCONTEXT: ");
1121 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1122 flags | TDF_SLIM, false);
1123 newline_and_indent (pp, spc + 2);
1126 if (BLOCK_SUBBLOCKS (block))
1128 pp_string (pp, "SUBBLOCKS: ");
1129 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1131 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1132 pp_space (pp);
1134 newline_and_indent (pp, spc + 2);
1137 if (BLOCK_CHAIN (block))
1139 pp_string (pp, "SIBLINGS: ");
1140 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1142 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1143 pp_space (pp);
1145 newline_and_indent (pp, spc + 2);
1148 if (BLOCK_VARS (block))
1150 pp_string (pp, "VARS: ");
1151 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1153 dump_generic_node (pp, t, 0, flags, false);
1154 pp_space (pp);
1156 newline_and_indent (pp, spc + 2);
1159 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1161 unsigned i;
1162 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1164 pp_string (pp, "NONLOCALIZED_VARS: ");
1165 FOR_EACH_VEC_ELT (*nlv, i, t)
1167 dump_generic_node (pp, t, 0, flags, false);
1168 pp_space (pp);
1170 newline_and_indent (pp, spc + 2);
1173 if (BLOCK_ABSTRACT_ORIGIN (block))
1175 pp_string (pp, "ABSTRACT_ORIGIN: ");
1176 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1177 flags | TDF_SLIM, false);
1178 newline_and_indent (pp, spc + 2);
1181 if (BLOCK_FRAGMENT_ORIGIN (block))
1183 pp_string (pp, "FRAGMENT_ORIGIN: ");
1184 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1185 flags | TDF_SLIM, false);
1186 newline_and_indent (pp, spc + 2);
1189 if (BLOCK_FRAGMENT_CHAIN (block))
1191 pp_string (pp, "FRAGMENT_CHAIN: ");
1192 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1194 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1195 pp_space (pp);
1197 newline_and_indent (pp, spc + 2);
1202 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1203 indent. FLAGS specifies details to show in the dump (see TDF_* in
1204 dumpfile.h). If IS_STMT is true, the object printed is considered
1205 to be a statement and it is terminated by ';' if appropriate. */
1208 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
1209 bool is_stmt)
1211 tree type;
1212 tree op0, op1;
1213 const char *str;
1214 bool is_expr;
1215 enum tree_code code;
1217 if (node == NULL_TREE)
1218 return spc;
1220 is_expr = EXPR_P (node);
1222 if (is_stmt && (flags & TDF_STMTADDR))
1223 pp_printf (pp, "<&%p> ", (void *)node);
1225 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1226 dump_location (pp, EXPR_LOCATION (node));
1228 code = TREE_CODE (node);
1229 switch (code)
1231 case ERROR_MARK:
1232 pp_string (pp, "<<< error >>>");
1233 break;
1235 case IDENTIFIER_NODE:
1236 pp_tree_identifier (pp, node);
1237 break;
1239 case TREE_LIST:
1240 while (node && node != error_mark_node)
1242 if (TREE_PURPOSE (node))
1244 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1245 pp_space (pp);
1247 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1248 node = TREE_CHAIN (node);
1249 if (node && TREE_CODE (node) == TREE_LIST)
1251 pp_comma (pp);
1252 pp_space (pp);
1255 break;
1257 case TREE_BINFO:
1258 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1259 break;
1261 case TREE_VEC:
1263 size_t i;
1264 if (TREE_VEC_LENGTH (node) > 0)
1266 size_t len = TREE_VEC_LENGTH (node);
1267 for (i = 0; i < len - 1; i++)
1269 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1270 false);
1271 pp_comma (pp);
1272 pp_space (pp);
1274 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1275 flags, false);
1278 break;
1280 case VOID_TYPE:
1281 case POINTER_BOUNDS_TYPE:
1282 case INTEGER_TYPE:
1283 case REAL_TYPE:
1284 case FIXED_POINT_TYPE:
1285 case COMPLEX_TYPE:
1286 case VECTOR_TYPE:
1287 case ENUMERAL_TYPE:
1288 case BOOLEAN_TYPE:
1290 unsigned int quals = TYPE_QUALS (node);
1291 enum tree_code_class tclass;
1293 if (quals & TYPE_QUAL_ATOMIC)
1294 pp_string (pp, "atomic ");
1295 if (quals & TYPE_QUAL_CONST)
1296 pp_string (pp, "const ");
1297 else if (quals & TYPE_QUAL_VOLATILE)
1298 pp_string (pp, "volatile ");
1299 else if (quals & TYPE_QUAL_RESTRICT)
1300 pp_string (pp, "restrict ");
1302 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1304 pp_string (pp, "<address-space-");
1305 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1306 pp_string (pp, "> ");
1309 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1311 if (tclass == tcc_declaration)
1313 if (DECL_NAME (node))
1314 dump_decl_name (pp, node, flags);
1315 else
1316 pp_string (pp, "<unnamed type decl>");
1318 else if (tclass == tcc_type)
1320 if (TYPE_NAME (node))
1322 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1323 pp_tree_identifier (pp, TYPE_NAME (node));
1324 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1325 && DECL_NAME (TYPE_NAME (node)))
1326 dump_decl_name (pp, TYPE_NAME (node), flags);
1327 else
1328 pp_string (pp, "<unnamed type>");
1330 else if (TREE_CODE (node) == VECTOR_TYPE)
1332 pp_string (pp, "vector");
1333 pp_left_paren (pp);
1334 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1335 pp_string (pp, ") ");
1336 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1338 else if (TREE_CODE (node) == INTEGER_TYPE)
1340 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1341 pp_string (pp, (TYPE_UNSIGNED (node)
1342 ? "unsigned char"
1343 : "signed char"));
1344 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1345 pp_string (pp, (TYPE_UNSIGNED (node)
1346 ? "unsigned short"
1347 : "signed short"));
1348 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1349 pp_string (pp, (TYPE_UNSIGNED (node)
1350 ? "unsigned int"
1351 : "signed int"));
1352 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1353 pp_string (pp, (TYPE_UNSIGNED (node)
1354 ? "unsigned long"
1355 : "signed long"));
1356 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1357 pp_string (pp, (TYPE_UNSIGNED (node)
1358 ? "unsigned long long"
1359 : "signed long long"));
1360 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1361 && pow2p_hwi (TYPE_PRECISION (node)))
1363 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1364 pp_decimal_int (pp, TYPE_PRECISION (node));
1365 pp_string (pp, "_t");
1367 else
1369 pp_string (pp, (TYPE_UNSIGNED (node)
1370 ? "<unnamed-unsigned:"
1371 : "<unnamed-signed:"));
1372 pp_decimal_int (pp, TYPE_PRECISION (node));
1373 pp_greater (pp);
1376 else if (TREE_CODE (node) == COMPLEX_TYPE)
1378 pp_string (pp, "__complex__ ");
1379 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1381 else if (TREE_CODE (node) == REAL_TYPE)
1383 pp_string (pp, "<float:");
1384 pp_decimal_int (pp, TYPE_PRECISION (node));
1385 pp_greater (pp);
1387 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1389 pp_string (pp, "<fixed-point-");
1390 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1391 pp_decimal_int (pp, TYPE_PRECISION (node));
1392 pp_greater (pp);
1394 else if (TREE_CODE (node) == VOID_TYPE)
1395 pp_string (pp, "void");
1396 else
1397 pp_string (pp, "<unnamed type>");
1399 break;
1402 case POINTER_TYPE:
1403 case REFERENCE_TYPE:
1404 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1406 if (TREE_TYPE (node) == NULL)
1408 pp_string (pp, str);
1409 pp_string (pp, "<null type>");
1411 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1413 tree fnode = TREE_TYPE (node);
1415 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1416 pp_space (pp);
1417 pp_left_paren (pp);
1418 pp_string (pp, str);
1419 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1420 dump_decl_name (pp, TYPE_NAME (node), flags);
1421 else if (flags & TDF_NOUID)
1422 pp_printf (pp, "<Txxxx>");
1423 else
1424 pp_printf (pp, "<T%x>", TYPE_UID (node));
1426 pp_right_paren (pp);
1427 dump_function_declaration (pp, fnode, spc, flags);
1429 else
1431 unsigned int quals = TYPE_QUALS (node);
1433 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1434 pp_space (pp);
1435 pp_string (pp, str);
1437 if (quals & TYPE_QUAL_CONST)
1438 pp_string (pp, " const");
1439 if (quals & TYPE_QUAL_VOLATILE)
1440 pp_string (pp, " volatile");
1441 if (quals & TYPE_QUAL_RESTRICT)
1442 pp_string (pp, " restrict");
1444 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1446 pp_string (pp, " <address-space-");
1447 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1448 pp_greater (pp);
1451 if (TYPE_REF_CAN_ALIAS_ALL (node))
1452 pp_string (pp, " {ref-all}");
1454 break;
1456 case OFFSET_TYPE:
1457 NIY;
1458 break;
1460 case MEM_REF:
1462 if (integer_zerop (TREE_OPERAND (node, 1))
1463 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1464 infer them and MEM_ATTR caching will share MEM_REFs
1465 with differently-typed op0s. */
1466 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1467 /* Released SSA_NAMES have no TREE_TYPE. */
1468 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1469 /* Same pointer types, but ignoring POINTER_TYPE vs.
1470 REFERENCE_TYPE. */
1471 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1472 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1473 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1474 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1475 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1476 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1477 /* Same value types ignoring qualifiers. */
1478 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1479 == TYPE_MAIN_VARIANT
1480 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1481 && (!(flags & TDF_ALIAS)
1482 || MR_DEPENDENCE_CLIQUE (node) == 0))
1484 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1486 pp_star (pp);
1487 dump_generic_node (pp, TREE_OPERAND (node, 0),
1488 spc, flags, false);
1490 else
1491 dump_generic_node (pp,
1492 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1493 spc, flags, false);
1495 else
1497 tree ptype;
1499 pp_string (pp, "MEM[");
1500 pp_left_paren (pp);
1501 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1502 dump_generic_node (pp, ptype,
1503 spc, flags | TDF_SLIM, false);
1504 pp_right_paren (pp);
1505 dump_generic_node (pp, TREE_OPERAND (node, 0),
1506 spc, flags, false);
1507 if (!integer_zerop (TREE_OPERAND (node, 1)))
1509 pp_string (pp, " + ");
1510 dump_generic_node (pp, TREE_OPERAND (node, 1),
1511 spc, flags, false);
1513 if ((flags & TDF_ALIAS)
1514 && MR_DEPENDENCE_CLIQUE (node) != 0)
1516 pp_string (pp, " clique ");
1517 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1518 pp_string (pp, " base ");
1519 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1521 pp_right_bracket (pp);
1523 break;
1526 case TARGET_MEM_REF:
1528 const char *sep = "";
1529 tree tmp;
1531 pp_string (pp, "MEM[");
1533 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1535 pp_string (pp, sep);
1536 sep = ", ";
1537 pp_string (pp, "symbol: ");
1538 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1539 spc, flags, false);
1541 else
1543 pp_string (pp, sep);
1544 sep = ", ";
1545 pp_string (pp, "base: ");
1546 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1548 tmp = TMR_INDEX2 (node);
1549 if (tmp)
1551 pp_string (pp, sep);
1552 sep = ", ";
1553 pp_string (pp, "base: ");
1554 dump_generic_node (pp, tmp, spc, flags, false);
1556 tmp = TMR_INDEX (node);
1557 if (tmp)
1559 pp_string (pp, sep);
1560 sep = ", ";
1561 pp_string (pp, "index: ");
1562 dump_generic_node (pp, tmp, spc, flags, false);
1564 tmp = TMR_STEP (node);
1565 if (tmp)
1567 pp_string (pp, sep);
1568 sep = ", ";
1569 pp_string (pp, "step: ");
1570 dump_generic_node (pp, tmp, spc, flags, false);
1572 tmp = TMR_OFFSET (node);
1573 if (tmp)
1575 pp_string (pp, sep);
1576 sep = ", ";
1577 pp_string (pp, "offset: ");
1578 dump_generic_node (pp, tmp, spc, flags, false);
1580 pp_right_bracket (pp);
1582 break;
1584 case ARRAY_TYPE:
1586 tree tmp;
1588 /* Print the innermost component type. */
1589 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1590 tmp = TREE_TYPE (tmp))
1592 dump_generic_node (pp, tmp, spc, flags, false);
1594 /* Print the dimensions. */
1595 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1596 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1597 break;
1600 case RECORD_TYPE:
1601 case UNION_TYPE:
1602 case QUAL_UNION_TYPE:
1604 unsigned int quals = TYPE_QUALS (node);
1606 if (quals & TYPE_QUAL_ATOMIC)
1607 pp_string (pp, "atomic ");
1608 if (quals & TYPE_QUAL_CONST)
1609 pp_string (pp, "const ");
1610 if (quals & TYPE_QUAL_VOLATILE)
1611 pp_string (pp, "volatile ");
1613 /* Print the name of the structure. */
1614 if (TREE_CODE (node) == RECORD_TYPE)
1615 pp_string (pp, "struct ");
1616 else if (TREE_CODE (node) == UNION_TYPE)
1617 pp_string (pp, "union ");
1619 if (TYPE_NAME (node))
1620 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1621 else if (!(flags & TDF_SLIM))
1622 /* FIXME: If we eliminate the 'else' above and attempt
1623 to show the fields for named types, we may get stuck
1624 following a cycle of pointers to structs. The alleged
1625 self-reference check in print_struct_decl will not detect
1626 cycles involving more than one pointer or struct type. */
1627 print_struct_decl (pp, node, spc, flags);
1628 break;
1631 case LANG_TYPE:
1632 NIY;
1633 break;
1635 case INTEGER_CST:
1636 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1638 /* In the case of a pointer, one may want to divide by the
1639 size of the pointed-to type. Unfortunately, this not
1640 straightforward. The C front-end maps expressions
1642 (int *) 5
1643 int *p; (p + 5)
1645 in such a way that the two INTEGER_CST nodes for "5" have
1646 different values but identical types. In the latter
1647 case, the 5 is multiplied by sizeof (int) in c-common.c
1648 (pointer_int_sum) to convert it to a byte address, and
1649 yet the type of the node is left unchanged. Argh. What
1650 is consistent though is that the number value corresponds
1651 to bytes (UNITS) offset.
1653 NB: Neither of the following divisors can be trivially
1654 used to recover the original literal:
1656 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1657 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1658 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1659 pp_string (pp, "B"); /* pseudo-unit */
1661 else if (tree_fits_shwi_p (node))
1662 pp_wide_integer (pp, tree_to_shwi (node));
1663 else if (tree_fits_uhwi_p (node))
1664 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1665 else
1667 wide_int val = node;
1669 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1671 pp_minus (pp);
1672 val = -val;
1674 print_hex (val, pp_buffer (pp)->digit_buffer);
1675 pp_string (pp, pp_buffer (pp)->digit_buffer);
1677 if (TREE_OVERFLOW (node))
1678 pp_string (pp, "(OVF)");
1679 break;
1681 case REAL_CST:
1682 /* Code copied from print_node. */
1684 REAL_VALUE_TYPE d;
1685 if (TREE_OVERFLOW (node))
1686 pp_string (pp, " overflow");
1688 d = TREE_REAL_CST (node);
1689 if (REAL_VALUE_ISINF (d))
1690 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1691 else if (REAL_VALUE_ISNAN (d))
1692 pp_string (pp, " Nan");
1693 else
1695 char string[100];
1696 real_to_decimal (string, &d, sizeof (string), 0, 1);
1697 pp_string (pp, string);
1699 break;
1702 case FIXED_CST:
1704 char string[100];
1705 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1706 pp_string (pp, string);
1707 break;
1710 case COMPLEX_CST:
1711 pp_string (pp, "__complex__ (");
1712 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1713 pp_string (pp, ", ");
1714 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1715 pp_right_paren (pp);
1716 break;
1718 case STRING_CST:
1719 pp_string (pp, "\"");
1720 pretty_print_string (pp, TREE_STRING_POINTER (node));
1721 pp_string (pp, "\"");
1722 break;
1724 case VECTOR_CST:
1726 unsigned i;
1727 pp_string (pp, "{ ");
1728 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1730 if (i != 0)
1731 pp_string (pp, ", ");
1732 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1733 spc, flags, false);
1735 pp_string (pp, " }");
1737 break;
1739 case FUNCTION_TYPE:
1740 case METHOD_TYPE:
1741 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1742 pp_space (pp);
1743 if (TREE_CODE (node) == METHOD_TYPE)
1745 if (TYPE_METHOD_BASETYPE (node))
1746 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1747 flags);
1748 else
1749 pp_string (pp, "<null method basetype>");
1750 pp_colon_colon (pp);
1752 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1753 dump_decl_name (pp, TYPE_NAME (node), flags);
1754 else if (flags & TDF_NOUID)
1755 pp_printf (pp, "<Txxxx>");
1756 else
1757 pp_printf (pp, "<T%x>", TYPE_UID (node));
1758 dump_function_declaration (pp, node, spc, flags);
1759 break;
1761 case FUNCTION_DECL:
1762 case CONST_DECL:
1763 dump_decl_name (pp, node, flags);
1764 break;
1766 case LABEL_DECL:
1767 if (DECL_NAME (node))
1768 dump_decl_name (pp, node, flags);
1769 else if (LABEL_DECL_UID (node) != -1)
1771 if (flags & TDF_GIMPLE)
1772 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1773 else
1774 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1776 else
1778 if (flags & TDF_NOUID)
1779 pp_string (pp, "<D.xxxx>");
1780 else
1782 if (flags & TDF_GIMPLE)
1783 pp_printf (pp, "<D%u>", DECL_UID (node));
1784 else
1785 pp_printf (pp, "<D.%u>", DECL_UID (node));
1788 break;
1790 case TYPE_DECL:
1791 if (DECL_IS_BUILTIN (node))
1793 /* Don't print the declaration of built-in types. */
1794 break;
1796 if (DECL_NAME (node))
1797 dump_decl_name (pp, node, flags);
1798 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1800 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1801 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1802 && TYPE_METHODS (TREE_TYPE (node)))
1804 /* The type is a c++ class: all structures have at least
1805 4 methods. */
1806 pp_string (pp, "class ");
1807 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1809 else
1811 pp_string (pp,
1812 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1813 ? "union" : "struct "));
1814 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1817 else
1818 pp_string (pp, "<anon>");
1819 break;
1821 case VAR_DECL:
1822 case PARM_DECL:
1823 case FIELD_DECL:
1824 case DEBUG_EXPR_DECL:
1825 case NAMESPACE_DECL:
1826 case NAMELIST_DECL:
1827 dump_decl_name (pp, node, flags);
1828 break;
1830 case RESULT_DECL:
1831 pp_string (pp, "<retval>");
1832 break;
1834 case COMPONENT_REF:
1835 op0 = TREE_OPERAND (node, 0);
1836 str = ".";
1837 if (op0
1838 && (TREE_CODE (op0) == INDIRECT_REF
1839 || (TREE_CODE (op0) == MEM_REF
1840 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1841 && integer_zerop (TREE_OPERAND (op0, 1))
1842 /* Dump the types of INTEGER_CSTs explicitly, for we
1843 can't infer them and MEM_ATTR caching will share
1844 MEM_REFs with differently-typed op0s. */
1845 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1846 /* Released SSA_NAMES have no TREE_TYPE. */
1847 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1848 /* Same pointer types, but ignoring POINTER_TYPE vs.
1849 REFERENCE_TYPE. */
1850 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1851 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1852 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1853 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1854 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1855 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1856 /* Same value types ignoring qualifiers. */
1857 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1858 == TYPE_MAIN_VARIANT
1859 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1860 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1862 op0 = TREE_OPERAND (op0, 0);
1863 str = "->";
1865 if (op_prio (op0) < op_prio (node))
1866 pp_left_paren (pp);
1867 dump_generic_node (pp, op0, spc, flags, false);
1868 if (op_prio (op0) < op_prio (node))
1869 pp_right_paren (pp);
1870 pp_string (pp, str);
1871 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1872 op0 = component_ref_field_offset (node);
1873 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1875 pp_string (pp, "{off: ");
1876 dump_generic_node (pp, op0, spc, flags, false);
1877 pp_right_brace (pp);
1879 break;
1881 case BIT_FIELD_REF:
1882 pp_string (pp, "BIT_FIELD_REF <");
1883 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1884 pp_string (pp, ", ");
1885 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1886 pp_string (pp, ", ");
1887 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1888 pp_greater (pp);
1889 break;
1891 case BIT_INSERT_EXPR:
1892 pp_string (pp, "BIT_INSERT_EXPR <");
1893 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1894 pp_string (pp, ", ");
1895 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1896 pp_string (pp, ", ");
1897 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1898 pp_string (pp, " (");
1899 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1900 pp_decimal_int (pp,
1901 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1902 else
1903 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1904 spc, flags, false);
1905 pp_string (pp, " bits)>");
1906 break;
1908 case ARRAY_REF:
1909 case ARRAY_RANGE_REF:
1910 op0 = TREE_OPERAND (node, 0);
1911 if (op_prio (op0) < op_prio (node))
1912 pp_left_paren (pp);
1913 dump_generic_node (pp, op0, spc, flags, false);
1914 if (op_prio (op0) < op_prio (node))
1915 pp_right_paren (pp);
1916 pp_left_bracket (pp);
1917 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1918 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1919 pp_string (pp, " ...");
1920 pp_right_bracket (pp);
1922 op0 = array_ref_low_bound (node);
1923 op1 = array_ref_element_size (node);
1925 if (!integer_zerop (op0)
1926 || TREE_OPERAND (node, 2)
1927 || TREE_OPERAND (node, 3))
1929 pp_string (pp, "{lb: ");
1930 dump_generic_node (pp, op0, spc, flags, false);
1931 pp_string (pp, " sz: ");
1932 dump_generic_node (pp, op1, spc, flags, false);
1933 pp_right_brace (pp);
1935 break;
1937 case CONSTRUCTOR:
1939 unsigned HOST_WIDE_INT ix;
1940 tree field, val;
1941 bool is_struct_init = false;
1942 bool is_array_init = false;
1943 widest_int curidx;
1944 pp_left_brace (pp);
1945 if (TREE_CLOBBER_P (node))
1946 pp_string (pp, "CLOBBER");
1947 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1948 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1949 is_struct_init = true;
1950 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1951 && TYPE_DOMAIN (TREE_TYPE (node))
1952 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1953 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1954 == INTEGER_CST)
1956 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1957 is_array_init = true;
1958 curidx = wi::to_widest (minv);
1960 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1962 if (field)
1964 if (is_struct_init)
1966 pp_dot (pp);
1967 dump_generic_node (pp, field, spc, flags, false);
1968 pp_equal (pp);
1970 else if (is_array_init
1971 && (TREE_CODE (field) != INTEGER_CST
1972 || curidx != wi::to_widest (field)))
1974 pp_left_bracket (pp);
1975 if (TREE_CODE (field) == RANGE_EXPR)
1977 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1978 flags, false);
1979 pp_string (pp, " ... ");
1980 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1981 flags, false);
1982 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1983 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1985 else
1986 dump_generic_node (pp, field, spc, flags, false);
1987 if (TREE_CODE (field) == INTEGER_CST)
1988 curidx = wi::to_widest (field);
1989 pp_string (pp, "]=");
1992 if (is_array_init)
1993 curidx += 1;
1994 if (val && TREE_CODE (val) == ADDR_EXPR)
1995 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1996 val = TREE_OPERAND (val, 0);
1997 if (val && TREE_CODE (val) == FUNCTION_DECL)
1998 dump_decl_name (pp, val, flags);
1999 else
2000 dump_generic_node (pp, val, spc, flags, false);
2001 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2003 pp_comma (pp);
2004 pp_space (pp);
2007 pp_right_brace (pp);
2009 break;
2011 case COMPOUND_EXPR:
2013 tree *tp;
2014 if (flags & TDF_SLIM)
2016 pp_string (pp, "<COMPOUND_EXPR>");
2017 break;
2020 dump_generic_node (pp, TREE_OPERAND (node, 0),
2021 spc, flags, !(flags & TDF_SLIM));
2022 if (flags & TDF_SLIM)
2023 newline_and_indent (pp, spc);
2024 else
2026 pp_comma (pp);
2027 pp_space (pp);
2030 for (tp = &TREE_OPERAND (node, 1);
2031 TREE_CODE (*tp) == COMPOUND_EXPR;
2032 tp = &TREE_OPERAND (*tp, 1))
2034 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2035 spc, flags, !(flags & TDF_SLIM));
2036 if (flags & TDF_SLIM)
2037 newline_and_indent (pp, spc);
2038 else
2040 pp_comma (pp);
2041 pp_space (pp);
2045 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2047 break;
2049 case STATEMENT_LIST:
2051 tree_stmt_iterator si;
2052 bool first = true;
2054 if (flags & TDF_SLIM)
2056 pp_string (pp, "<STATEMENT_LIST>");
2057 break;
2060 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2062 if (!first)
2063 newline_and_indent (pp, spc);
2064 else
2065 first = false;
2066 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2069 break;
2071 case MODIFY_EXPR:
2072 case INIT_EXPR:
2073 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2074 false);
2075 pp_space (pp);
2076 pp_equal (pp);
2077 pp_space (pp);
2078 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2079 false);
2080 break;
2082 case TARGET_EXPR:
2083 pp_string (pp, "TARGET_EXPR <");
2084 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2085 pp_comma (pp);
2086 pp_space (pp);
2087 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2088 pp_greater (pp);
2089 break;
2091 case DECL_EXPR:
2092 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2093 is_stmt = false;
2094 break;
2096 case COND_EXPR:
2097 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2099 pp_string (pp, "if (");
2100 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2101 pp_right_paren (pp);
2102 /* The lowered cond_exprs should always be printed in full. */
2103 if (COND_EXPR_THEN (node)
2104 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2105 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2106 && COND_EXPR_ELSE (node)
2107 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2108 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2110 pp_space (pp);
2111 dump_generic_node (pp, COND_EXPR_THEN (node),
2112 0, flags, true);
2113 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2115 pp_string (pp, " else ");
2116 dump_generic_node (pp, COND_EXPR_ELSE (node),
2117 0, flags, true);
2120 else if (!(flags & TDF_SLIM))
2122 /* Output COND_EXPR_THEN. */
2123 if (COND_EXPR_THEN (node))
2125 newline_and_indent (pp, spc+2);
2126 pp_left_brace (pp);
2127 newline_and_indent (pp, spc+4);
2128 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2129 flags, true);
2130 newline_and_indent (pp, spc+2);
2131 pp_right_brace (pp);
2134 /* Output COND_EXPR_ELSE. */
2135 if (COND_EXPR_ELSE (node)
2136 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2138 newline_and_indent (pp, spc);
2139 pp_string (pp, "else");
2140 newline_and_indent (pp, spc+2);
2141 pp_left_brace (pp);
2142 newline_and_indent (pp, spc+4);
2143 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2144 flags, true);
2145 newline_and_indent (pp, spc+2);
2146 pp_right_brace (pp);
2149 is_expr = false;
2151 else
2153 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2154 pp_space (pp);
2155 pp_question (pp);
2156 pp_space (pp);
2157 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2158 pp_space (pp);
2159 pp_colon (pp);
2160 pp_space (pp);
2161 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2163 break;
2165 case BIND_EXPR:
2166 pp_left_brace (pp);
2167 if (!(flags & TDF_SLIM))
2169 if (BIND_EXPR_VARS (node))
2171 pp_newline (pp);
2173 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2175 print_declaration (pp, op0, spc+2, flags);
2176 pp_newline (pp);
2180 newline_and_indent (pp, spc+2);
2181 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2182 newline_and_indent (pp, spc);
2183 pp_right_brace (pp);
2185 is_expr = false;
2186 break;
2188 case CALL_EXPR:
2189 if (CALL_EXPR_FN (node) != NULL_TREE)
2190 print_call_name (pp, CALL_EXPR_FN (node), flags);
2191 else
2192 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2194 /* Print parameters. */
2195 pp_space (pp);
2196 pp_left_paren (pp);
2198 tree arg;
2199 call_expr_arg_iterator iter;
2200 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2202 dump_generic_node (pp, arg, spc, flags, false);
2203 if (more_call_expr_args_p (&iter))
2205 pp_comma (pp);
2206 pp_space (pp);
2210 if (CALL_EXPR_VA_ARG_PACK (node))
2212 if (call_expr_nargs (node) > 0)
2214 pp_comma (pp);
2215 pp_space (pp);
2217 pp_string (pp, "__builtin_va_arg_pack ()");
2219 pp_right_paren (pp);
2221 op1 = CALL_EXPR_STATIC_CHAIN (node);
2222 if (op1)
2224 pp_string (pp, " [static-chain: ");
2225 dump_generic_node (pp, op1, spc, flags, false);
2226 pp_right_bracket (pp);
2229 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2230 pp_string (pp, " [return slot optimization]");
2231 if (CALL_EXPR_TAILCALL (node))
2232 pp_string (pp, " [tail call]");
2233 break;
2235 case WITH_CLEANUP_EXPR:
2236 NIY;
2237 break;
2239 case CLEANUP_POINT_EXPR:
2240 pp_string (pp, "<<cleanup_point ");
2241 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2242 pp_string (pp, ">>");
2243 break;
2245 case PLACEHOLDER_EXPR:
2246 pp_string (pp, "<PLACEHOLDER_EXPR ");
2247 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2248 pp_greater (pp);
2249 break;
2251 /* Binary arithmetic and logic expressions. */
2252 case WIDEN_SUM_EXPR:
2253 case WIDEN_MULT_EXPR:
2254 case MULT_EXPR:
2255 case MULT_HIGHPART_EXPR:
2256 case PLUS_EXPR:
2257 case POINTER_PLUS_EXPR:
2258 case MINUS_EXPR:
2259 case TRUNC_DIV_EXPR:
2260 case CEIL_DIV_EXPR:
2261 case FLOOR_DIV_EXPR:
2262 case ROUND_DIV_EXPR:
2263 case TRUNC_MOD_EXPR:
2264 case CEIL_MOD_EXPR:
2265 case FLOOR_MOD_EXPR:
2266 case ROUND_MOD_EXPR:
2267 case RDIV_EXPR:
2268 case EXACT_DIV_EXPR:
2269 case LSHIFT_EXPR:
2270 case RSHIFT_EXPR:
2271 case LROTATE_EXPR:
2272 case RROTATE_EXPR:
2273 case WIDEN_LSHIFT_EXPR:
2274 case BIT_IOR_EXPR:
2275 case BIT_XOR_EXPR:
2276 case BIT_AND_EXPR:
2277 case TRUTH_ANDIF_EXPR:
2278 case TRUTH_ORIF_EXPR:
2279 case TRUTH_AND_EXPR:
2280 case TRUTH_OR_EXPR:
2281 case TRUTH_XOR_EXPR:
2282 case LT_EXPR:
2283 case LE_EXPR:
2284 case GT_EXPR:
2285 case GE_EXPR:
2286 case EQ_EXPR:
2287 case NE_EXPR:
2288 case UNLT_EXPR:
2289 case UNLE_EXPR:
2290 case UNGT_EXPR:
2291 case UNGE_EXPR:
2292 case UNEQ_EXPR:
2293 case LTGT_EXPR:
2294 case ORDERED_EXPR:
2295 case UNORDERED_EXPR:
2297 const char *op = op_symbol (node);
2298 op0 = TREE_OPERAND (node, 0);
2299 op1 = TREE_OPERAND (node, 1);
2301 /* When the operands are expressions with less priority,
2302 keep semantics of the tree representation. */
2303 if (op_prio (op0) <= op_prio (node))
2305 pp_left_paren (pp);
2306 dump_generic_node (pp, op0, spc, flags, false);
2307 pp_right_paren (pp);
2309 else
2310 dump_generic_node (pp, op0, spc, flags, false);
2312 pp_space (pp);
2313 pp_string (pp, op);
2314 pp_space (pp);
2316 /* When the operands are expressions with less priority,
2317 keep semantics of the tree representation. */
2318 if (op_prio (op1) <= op_prio (node))
2320 pp_left_paren (pp);
2321 dump_generic_node (pp, op1, spc, flags, false);
2322 pp_right_paren (pp);
2324 else
2325 dump_generic_node (pp, op1, spc, flags, false);
2327 break;
2329 /* Unary arithmetic and logic expressions. */
2330 case NEGATE_EXPR:
2331 case BIT_NOT_EXPR:
2332 case TRUTH_NOT_EXPR:
2333 case ADDR_EXPR:
2334 case PREDECREMENT_EXPR:
2335 case PREINCREMENT_EXPR:
2336 case INDIRECT_REF:
2337 if (TREE_CODE (node) == ADDR_EXPR
2338 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2339 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2340 ; /* Do not output '&' for strings and function pointers. */
2341 else
2342 pp_string (pp, op_symbol (node));
2344 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2346 pp_left_paren (pp);
2347 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2348 pp_right_paren (pp);
2350 else
2351 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2352 break;
2354 case POSTDECREMENT_EXPR:
2355 case POSTINCREMENT_EXPR:
2356 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2358 pp_left_paren (pp);
2359 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2360 pp_right_paren (pp);
2362 else
2363 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2364 pp_string (pp, op_symbol (node));
2365 break;
2367 case MIN_EXPR:
2368 pp_string (pp, "MIN_EXPR <");
2369 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2370 pp_string (pp, ", ");
2371 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2372 pp_greater (pp);
2373 break;
2375 case MAX_EXPR:
2376 pp_string (pp, "MAX_EXPR <");
2377 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2378 pp_string (pp, ", ");
2379 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2380 pp_greater (pp);
2381 break;
2383 case ABS_EXPR:
2384 pp_string (pp, "ABS_EXPR <");
2385 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2386 pp_greater (pp);
2387 break;
2389 case RANGE_EXPR:
2390 NIY;
2391 break;
2393 case ADDR_SPACE_CONVERT_EXPR:
2394 case FIXED_CONVERT_EXPR:
2395 case FIX_TRUNC_EXPR:
2396 case FLOAT_EXPR:
2397 CASE_CONVERT:
2398 type = TREE_TYPE (node);
2399 op0 = TREE_OPERAND (node, 0);
2400 if (type != TREE_TYPE (op0))
2402 pp_left_paren (pp);
2403 dump_generic_node (pp, type, spc, flags, false);
2404 pp_string (pp, ") ");
2406 if (op_prio (op0) < op_prio (node))
2407 pp_left_paren (pp);
2408 dump_generic_node (pp, op0, spc, flags, false);
2409 if (op_prio (op0) < op_prio (node))
2410 pp_right_paren (pp);
2411 break;
2413 case VIEW_CONVERT_EXPR:
2414 pp_string (pp, "VIEW_CONVERT_EXPR<");
2415 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2416 pp_string (pp, ">(");
2417 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2418 pp_right_paren (pp);
2419 break;
2421 case PAREN_EXPR:
2422 pp_string (pp, "((");
2423 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2424 pp_string (pp, "))");
2425 break;
2427 case NON_LVALUE_EXPR:
2428 pp_string (pp, "NON_LVALUE_EXPR <");
2429 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2430 pp_greater (pp);
2431 break;
2433 case SAVE_EXPR:
2434 pp_string (pp, "SAVE_EXPR <");
2435 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2436 pp_greater (pp);
2437 break;
2439 case COMPLEX_EXPR:
2440 pp_string (pp, "COMPLEX_EXPR <");
2441 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2442 pp_string (pp, ", ");
2443 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2444 pp_greater (pp);
2445 break;
2447 case CONJ_EXPR:
2448 pp_string (pp, "CONJ_EXPR <");
2449 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2450 pp_greater (pp);
2451 break;
2453 case REALPART_EXPR:
2454 if (flags & TDF_GIMPLE)
2456 pp_string (pp, "__real ");
2457 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2459 else
2461 pp_string (pp, "REALPART_EXPR <");
2462 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2463 pp_greater (pp);
2465 break;
2467 case IMAGPART_EXPR:
2468 if (flags & TDF_GIMPLE)
2470 pp_string (pp, "__imag ");
2471 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2473 else
2475 pp_string (pp, "IMAGPART_EXPR <");
2476 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2477 pp_greater (pp);
2479 break;
2481 case VA_ARG_EXPR:
2482 pp_string (pp, "VA_ARG_EXPR <");
2483 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2484 pp_greater (pp);
2485 break;
2487 case TRY_FINALLY_EXPR:
2488 case TRY_CATCH_EXPR:
2489 pp_string (pp, "try");
2490 newline_and_indent (pp, spc+2);
2491 pp_left_brace (pp);
2492 newline_and_indent (pp, spc+4);
2493 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2494 newline_and_indent (pp, spc+2);
2495 pp_right_brace (pp);
2496 newline_and_indent (pp, spc);
2497 pp_string (pp,
2498 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2499 newline_and_indent (pp, spc+2);
2500 pp_left_brace (pp);
2501 newline_and_indent (pp, spc+4);
2502 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2503 newline_and_indent (pp, spc+2);
2504 pp_right_brace (pp);
2505 is_expr = false;
2506 break;
2508 case CATCH_EXPR:
2509 pp_string (pp, "catch (");
2510 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2511 pp_right_paren (pp);
2512 newline_and_indent (pp, spc+2);
2513 pp_left_brace (pp);
2514 newline_and_indent (pp, spc+4);
2515 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2516 newline_and_indent (pp, spc+2);
2517 pp_right_brace (pp);
2518 is_expr = false;
2519 break;
2521 case EH_FILTER_EXPR:
2522 pp_string (pp, "<<<eh_filter (");
2523 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2524 pp_string (pp, ")>>>");
2525 newline_and_indent (pp, spc+2);
2526 pp_left_brace (pp);
2527 newline_and_indent (pp, spc+4);
2528 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2529 newline_and_indent (pp, spc+2);
2530 pp_right_brace (pp);
2531 is_expr = false;
2532 break;
2534 case LABEL_EXPR:
2535 op0 = TREE_OPERAND (node, 0);
2536 /* If this is for break or continue, don't bother printing it. */
2537 if (DECL_NAME (op0))
2539 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2540 if (strcmp (name, "break") == 0
2541 || strcmp (name, "continue") == 0)
2542 break;
2544 dump_generic_node (pp, op0, spc, flags, false);
2545 pp_colon (pp);
2546 if (DECL_NONLOCAL (op0))
2547 pp_string (pp, " [non-local]");
2548 break;
2550 case LOOP_EXPR:
2551 pp_string (pp, "while (1)");
2552 if (!(flags & TDF_SLIM))
2554 newline_and_indent (pp, spc+2);
2555 pp_left_brace (pp);
2556 newline_and_indent (pp, spc+4);
2557 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2558 newline_and_indent (pp, spc+2);
2559 pp_right_brace (pp);
2561 is_expr = false;
2562 break;
2564 case PREDICT_EXPR:
2565 pp_string (pp, "// predicted ");
2566 if (PREDICT_EXPR_OUTCOME (node))
2567 pp_string (pp, "likely by ");
2568 else
2569 pp_string (pp, "unlikely by ");
2570 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2571 pp_string (pp, " predictor.");
2572 break;
2574 case ANNOTATE_EXPR:
2575 pp_string (pp, "ANNOTATE_EXPR <");
2576 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2577 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2579 case annot_expr_ivdep_kind:
2580 pp_string (pp, ", ivdep");
2581 break;
2582 case annot_expr_no_vector_kind:
2583 pp_string (pp, ", no-vector");
2584 break;
2585 case annot_expr_vector_kind:
2586 pp_string (pp, ", vector");
2587 break;
2588 default:
2589 gcc_unreachable ();
2591 pp_greater (pp);
2592 break;
2594 case RETURN_EXPR:
2595 pp_string (pp, "return");
2596 op0 = TREE_OPERAND (node, 0);
2597 if (op0)
2599 pp_space (pp);
2600 if (TREE_CODE (op0) == MODIFY_EXPR)
2601 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2602 spc, flags, false);
2603 else
2604 dump_generic_node (pp, op0, spc, flags, false);
2606 break;
2608 case EXIT_EXPR:
2609 pp_string (pp, "if (");
2610 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2611 pp_string (pp, ") break");
2612 break;
2614 case SWITCH_EXPR:
2615 pp_string (pp, "switch (");
2616 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2617 pp_right_paren (pp);
2618 if (!(flags & TDF_SLIM))
2620 newline_and_indent (pp, spc+2);
2621 pp_left_brace (pp);
2622 if (SWITCH_BODY (node))
2624 newline_and_indent (pp, spc+4);
2625 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2626 true);
2628 else
2630 tree vec = SWITCH_LABELS (node);
2631 size_t i, n = TREE_VEC_LENGTH (vec);
2632 for (i = 0; i < n; ++i)
2634 tree elt = TREE_VEC_ELT (vec, i);
2635 newline_and_indent (pp, spc+4);
2636 if (elt)
2638 dump_generic_node (pp, elt, spc+4, flags, false);
2639 pp_string (pp, " goto ");
2640 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2641 flags, true);
2642 pp_semicolon (pp);
2644 else
2645 pp_string (pp, "case ???: goto ???;");
2648 newline_and_indent (pp, spc+2);
2649 pp_right_brace (pp);
2651 is_expr = false;
2652 break;
2654 case GOTO_EXPR:
2655 op0 = GOTO_DESTINATION (node);
2656 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2658 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2659 if (strcmp (name, "break") == 0
2660 || strcmp (name, "continue") == 0)
2662 pp_string (pp, name);
2663 break;
2666 pp_string (pp, "goto ");
2667 dump_generic_node (pp, op0, spc, flags, false);
2668 break;
2670 case ASM_EXPR:
2671 pp_string (pp, "__asm__");
2672 if (ASM_VOLATILE_P (node))
2673 pp_string (pp, " __volatile__");
2674 pp_left_paren (pp);
2675 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2676 pp_colon (pp);
2677 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2678 pp_colon (pp);
2679 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2680 if (ASM_CLOBBERS (node))
2682 pp_colon (pp);
2683 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2685 pp_right_paren (pp);
2686 break;
2688 case CASE_LABEL_EXPR:
2689 if (CASE_LOW (node) && CASE_HIGH (node))
2691 pp_string (pp, "case ");
2692 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2693 pp_string (pp, " ... ");
2694 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2696 else if (CASE_LOW (node))
2698 pp_string (pp, "case ");
2699 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2701 else
2702 pp_string (pp, "default");
2703 pp_colon (pp);
2704 break;
2706 case OBJ_TYPE_REF:
2707 pp_string (pp, "OBJ_TYPE_REF(");
2708 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2709 pp_semicolon (pp);
2710 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2712 pp_string (pp, "(");
2713 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2714 pp_string (pp, ")");
2716 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2717 pp_arrow (pp);
2718 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2719 pp_right_paren (pp);
2720 break;
2722 case SSA_NAME:
2723 if (SSA_NAME_IDENTIFIER (node))
2725 if ((flags & TDF_NOUID)
2726 && SSA_NAME_VAR (node)
2727 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2728 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2729 else if (! (flags & TDF_GIMPLE)
2730 || SSA_NAME_VAR (node))
2731 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2732 spc, flags, false);
2734 pp_underscore (pp);
2735 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2736 if (SSA_NAME_IS_DEFAULT_DEF (node))
2737 pp_string (pp, "(D)");
2738 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2739 pp_string (pp, "(ab)");
2740 break;
2742 case WITH_SIZE_EXPR:
2743 pp_string (pp, "WITH_SIZE_EXPR <");
2744 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2745 pp_string (pp, ", ");
2746 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2747 pp_greater (pp);
2748 break;
2750 case ASSERT_EXPR:
2751 pp_string (pp, "ASSERT_EXPR <");
2752 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2753 pp_string (pp, ", ");
2754 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2755 pp_greater (pp);
2756 break;
2758 case SCEV_KNOWN:
2759 pp_string (pp, "scev_known");
2760 break;
2762 case SCEV_NOT_KNOWN:
2763 pp_string (pp, "scev_not_known");
2764 break;
2766 case POLYNOMIAL_CHREC:
2767 pp_left_brace (pp);
2768 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2769 pp_string (pp, ", +, ");
2770 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2771 pp_string (pp, "}_");
2772 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2773 is_stmt = false;
2774 break;
2776 case REALIGN_LOAD_EXPR:
2777 pp_string (pp, "REALIGN_LOAD <");
2778 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2779 pp_string (pp, ", ");
2780 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2781 pp_string (pp, ", ");
2782 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2783 pp_greater (pp);
2784 break;
2786 case VEC_COND_EXPR:
2787 pp_string (pp, " VEC_COND_EXPR < ");
2788 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2789 pp_string (pp, " , ");
2790 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2791 pp_string (pp, " , ");
2792 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2793 pp_string (pp, " > ");
2794 break;
2796 case VEC_PERM_EXPR:
2797 pp_string (pp, " VEC_PERM_EXPR < ");
2798 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2799 pp_string (pp, " , ");
2800 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2801 pp_string (pp, " , ");
2802 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2803 pp_string (pp, " > ");
2804 break;
2806 case DOT_PROD_EXPR:
2807 pp_string (pp, " DOT_PROD_EXPR < ");
2808 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2809 pp_string (pp, ", ");
2810 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2811 pp_string (pp, ", ");
2812 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2813 pp_string (pp, " > ");
2814 break;
2816 case WIDEN_MULT_PLUS_EXPR:
2817 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2818 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2819 pp_string (pp, ", ");
2820 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2821 pp_string (pp, ", ");
2822 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2823 pp_string (pp, " > ");
2824 break;
2826 case WIDEN_MULT_MINUS_EXPR:
2827 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2828 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2829 pp_string (pp, ", ");
2830 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2831 pp_string (pp, ", ");
2832 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2833 pp_string (pp, " > ");
2834 break;
2836 case FMA_EXPR:
2837 pp_string (pp, " FMA_EXPR < ");
2838 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2839 pp_string (pp, ", ");
2840 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2841 pp_string (pp, ", ");
2842 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2843 pp_string (pp, " > ");
2844 break;
2846 case OACC_PARALLEL:
2847 pp_string (pp, "#pragma acc parallel");
2848 goto dump_omp_clauses_body;
2850 case OACC_KERNELS:
2851 pp_string (pp, "#pragma acc kernels");
2852 goto dump_omp_clauses_body;
2854 case OACC_DATA:
2855 pp_string (pp, "#pragma acc data");
2856 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2857 goto dump_omp_body;
2859 case OACC_HOST_DATA:
2860 pp_string (pp, "#pragma acc host_data");
2861 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2862 goto dump_omp_body;
2864 case OACC_DECLARE:
2865 pp_string (pp, "#pragma acc declare");
2866 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2867 break;
2869 case OACC_UPDATE:
2870 pp_string (pp, "#pragma acc update");
2871 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2872 break;
2874 case OACC_ENTER_DATA:
2875 pp_string (pp, "#pragma acc enter data");
2876 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2877 break;
2879 case OACC_EXIT_DATA:
2880 pp_string (pp, "#pragma acc exit data");
2881 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2882 break;
2884 case OACC_CACHE:
2885 pp_string (pp, "#pragma acc cache");
2886 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2887 break;
2889 case OMP_PARALLEL:
2890 pp_string (pp, "#pragma omp parallel");
2891 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2892 goto dump_omp_body;
2894 dump_omp_clauses_body:
2895 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2896 goto dump_omp_body;
2898 dump_omp_body:
2899 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2901 newline_and_indent (pp, spc + 2);
2902 pp_left_brace (pp);
2903 newline_and_indent (pp, spc + 4);
2904 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2905 newline_and_indent (pp, spc + 2);
2906 pp_right_brace (pp);
2908 is_expr = false;
2909 break;
2911 case OMP_TASK:
2912 pp_string (pp, "#pragma omp task");
2913 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2914 goto dump_omp_body;
2916 case OMP_FOR:
2917 pp_string (pp, "#pragma omp for");
2918 goto dump_omp_loop;
2920 case OMP_SIMD:
2921 pp_string (pp, "#pragma omp simd");
2922 goto dump_omp_loop;
2924 case CILK_SIMD:
2925 pp_string (pp, "#pragma simd");
2926 goto dump_omp_loop;
2928 case CILK_FOR:
2929 /* This label points one line after dumping the clauses.
2930 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2931 parameters are printed out. */
2932 goto dump_omp_loop_cilk_for;
2934 case OMP_DISTRIBUTE:
2935 pp_string (pp, "#pragma omp distribute");
2936 goto dump_omp_loop;
2938 case OMP_TASKLOOP:
2939 pp_string (pp, "#pragma omp taskloop");
2940 goto dump_omp_loop;
2942 case OACC_LOOP:
2943 pp_string (pp, "#pragma acc loop");
2944 goto dump_omp_loop;
2946 case OMP_TEAMS:
2947 pp_string (pp, "#pragma omp teams");
2948 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2949 goto dump_omp_body;
2951 case OMP_TARGET_DATA:
2952 pp_string (pp, "#pragma omp target data");
2953 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2954 goto dump_omp_body;
2956 case OMP_TARGET_ENTER_DATA:
2957 pp_string (pp, "#pragma omp target enter data");
2958 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2959 is_expr = false;
2960 break;
2962 case OMP_TARGET_EXIT_DATA:
2963 pp_string (pp, "#pragma omp target exit data");
2964 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2965 is_expr = false;
2966 break;
2968 case OMP_TARGET:
2969 pp_string (pp, "#pragma omp target");
2970 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2971 goto dump_omp_body;
2973 case OMP_TARGET_UPDATE:
2974 pp_string (pp, "#pragma omp target update");
2975 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2976 is_expr = false;
2977 break;
2979 dump_omp_loop:
2980 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2982 dump_omp_loop_cilk_for:
2983 if (!(flags & TDF_SLIM))
2985 int i;
2987 if (OMP_FOR_PRE_BODY (node))
2989 if (TREE_CODE (node) == CILK_FOR)
2990 pp_string (pp, " ");
2991 else
2992 newline_and_indent (pp, spc + 2);
2993 pp_left_brace (pp);
2994 spc += 4;
2995 newline_and_indent (pp, spc);
2996 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2997 spc, flags, false);
2999 if (OMP_FOR_INIT (node))
3001 spc -= 2;
3002 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3004 spc += 2;
3005 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
3006 newline_and_indent (pp, spc);
3007 if (TREE_CODE (node) == CILK_FOR)
3008 pp_string (pp, "_Cilk_for (");
3009 else
3010 pp_string (pp, "for (");
3011 dump_generic_node (pp,
3012 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3013 spc, flags, false);
3014 pp_string (pp, "; ");
3015 dump_generic_node (pp,
3016 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3017 spc, flags, false);
3018 pp_string (pp, "; ");
3019 dump_generic_node (pp,
3020 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3021 spc, flags, false);
3022 pp_right_paren (pp);
3024 if (TREE_CODE (node) == CILK_FOR)
3025 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3027 if (OMP_FOR_BODY (node))
3029 newline_and_indent (pp, spc + 2);
3030 pp_left_brace (pp);
3031 newline_and_indent (pp, spc + 4);
3032 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3033 false);
3034 newline_and_indent (pp, spc + 2);
3035 pp_right_brace (pp);
3037 if (OMP_FOR_INIT (node))
3038 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3039 if (OMP_FOR_PRE_BODY (node))
3041 spc -= 4;
3042 newline_and_indent (pp, spc + 2);
3043 pp_right_brace (pp);
3046 is_expr = false;
3047 break;
3049 case OMP_SECTIONS:
3050 pp_string (pp, "#pragma omp sections");
3051 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3052 goto dump_omp_body;
3054 case OMP_SECTION:
3055 pp_string (pp, "#pragma omp section");
3056 goto dump_omp_body;
3058 case OMP_MASTER:
3059 pp_string (pp, "#pragma omp master");
3060 goto dump_omp_body;
3062 case OMP_TASKGROUP:
3063 pp_string (pp, "#pragma omp taskgroup");
3064 goto dump_omp_body;
3066 case OMP_ORDERED:
3067 pp_string (pp, "#pragma omp ordered");
3068 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3069 goto dump_omp_body;
3071 case OMP_CRITICAL:
3072 pp_string (pp, "#pragma omp critical");
3073 if (OMP_CRITICAL_NAME (node))
3075 pp_space (pp);
3076 pp_left_paren (pp);
3077 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3078 flags, false);
3079 pp_right_paren (pp);
3081 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3082 goto dump_omp_body;
3084 case OMP_ATOMIC:
3085 pp_string (pp, "#pragma omp atomic");
3086 if (OMP_ATOMIC_SEQ_CST (node))
3087 pp_string (pp, " seq_cst");
3088 newline_and_indent (pp, spc + 2);
3089 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3090 pp_space (pp);
3091 pp_equal (pp);
3092 pp_space (pp);
3093 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3094 break;
3096 case OMP_ATOMIC_READ:
3097 pp_string (pp, "#pragma omp atomic read");
3098 if (OMP_ATOMIC_SEQ_CST (node))
3099 pp_string (pp, " seq_cst");
3100 newline_and_indent (pp, spc + 2);
3101 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3102 pp_space (pp);
3103 break;
3105 case OMP_ATOMIC_CAPTURE_OLD:
3106 case OMP_ATOMIC_CAPTURE_NEW:
3107 pp_string (pp, "#pragma omp atomic capture");
3108 if (OMP_ATOMIC_SEQ_CST (node))
3109 pp_string (pp, " seq_cst");
3110 newline_and_indent (pp, spc + 2);
3111 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3112 pp_space (pp);
3113 pp_equal (pp);
3114 pp_space (pp);
3115 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3116 break;
3118 case OMP_SINGLE:
3119 pp_string (pp, "#pragma omp single");
3120 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3121 goto dump_omp_body;
3123 case OMP_CLAUSE:
3124 dump_omp_clause (pp, node, spc, flags);
3125 is_expr = false;
3126 break;
3128 case TRANSACTION_EXPR:
3129 if (TRANSACTION_EXPR_OUTER (node))
3130 pp_string (pp, "__transaction_atomic [[outer]]");
3131 else if (TRANSACTION_EXPR_RELAXED (node))
3132 pp_string (pp, "__transaction_relaxed");
3133 else
3134 pp_string (pp, "__transaction_atomic");
3135 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3137 newline_and_indent (pp, spc);
3138 pp_left_brace (pp);
3139 newline_and_indent (pp, spc + 2);
3140 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3141 spc + 2, flags, false);
3142 newline_and_indent (pp, spc);
3143 pp_right_brace (pp);
3145 is_expr = false;
3146 break;
3148 case REDUC_MAX_EXPR:
3149 pp_string (pp, " REDUC_MAX_EXPR < ");
3150 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3151 pp_string (pp, " > ");
3152 break;
3154 case REDUC_MIN_EXPR:
3155 pp_string (pp, " REDUC_MIN_EXPR < ");
3156 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3157 pp_string (pp, " > ");
3158 break;
3160 case REDUC_PLUS_EXPR:
3161 pp_string (pp, " REDUC_PLUS_EXPR < ");
3162 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3163 pp_string (pp, " > ");
3164 break;
3166 case VEC_WIDEN_MULT_HI_EXPR:
3167 case VEC_WIDEN_MULT_LO_EXPR:
3168 case VEC_WIDEN_MULT_EVEN_EXPR:
3169 case VEC_WIDEN_MULT_ODD_EXPR:
3170 case VEC_WIDEN_LSHIFT_HI_EXPR:
3171 case VEC_WIDEN_LSHIFT_LO_EXPR:
3172 pp_space (pp);
3173 for (str = get_tree_code_name (code); *str; str++)
3174 pp_character (pp, TOUPPER (*str));
3175 pp_string (pp, " < ");
3176 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3177 pp_string (pp, ", ");
3178 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3179 pp_string (pp, " > ");
3180 break;
3182 case VEC_UNPACK_HI_EXPR:
3183 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3184 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3185 pp_string (pp, " > ");
3186 break;
3188 case VEC_UNPACK_LO_EXPR:
3189 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3190 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3191 pp_string (pp, " > ");
3192 break;
3194 case VEC_UNPACK_FLOAT_HI_EXPR:
3195 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3196 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3197 pp_string (pp, " > ");
3198 break;
3200 case VEC_UNPACK_FLOAT_LO_EXPR:
3201 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3202 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3203 pp_string (pp, " > ");
3204 break;
3206 case VEC_PACK_TRUNC_EXPR:
3207 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3208 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3209 pp_string (pp, ", ");
3210 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3211 pp_string (pp, " > ");
3212 break;
3214 case VEC_PACK_SAT_EXPR:
3215 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3216 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3217 pp_string (pp, ", ");
3218 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3219 pp_string (pp, " > ");
3220 break;
3222 case VEC_PACK_FIX_TRUNC_EXPR:
3223 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3224 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3225 pp_string (pp, ", ");
3226 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3227 pp_string (pp, " > ");
3228 break;
3230 case BLOCK:
3231 dump_block_node (pp, node, spc, flags);
3232 break;
3234 case CILK_SPAWN_STMT:
3235 pp_string (pp, "_Cilk_spawn ");
3236 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3237 break;
3239 case CILK_SYNC_STMT:
3240 pp_string (pp, "_Cilk_sync");
3241 break;
3243 default:
3244 NIY;
3247 if (is_stmt && is_expr)
3248 pp_semicolon (pp);
3250 return spc;
3253 /* Print the declaration of a variable. */
3255 void
3256 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
3258 INDENT (spc);
3260 if (TREE_CODE(t) == NAMELIST_DECL)
3262 pp_string(pp, "namelist ");
3263 dump_decl_name (pp, t, flags);
3264 pp_semicolon (pp);
3265 return;
3268 if (TREE_CODE (t) == TYPE_DECL)
3269 pp_string (pp, "typedef ");
3271 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3272 pp_string (pp, "register ");
3274 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3275 pp_string (pp, "extern ");
3276 else if (TREE_STATIC (t))
3277 pp_string (pp, "static ");
3279 /* Print the type and name. */
3280 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3282 tree tmp;
3284 /* Print array's type. */
3285 tmp = TREE_TYPE (t);
3286 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3287 tmp = TREE_TYPE (tmp);
3288 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3290 /* Print variable's name. */
3291 pp_space (pp);
3292 dump_generic_node (pp, t, spc, flags, false);
3294 /* Print the dimensions. */
3295 tmp = TREE_TYPE (t);
3296 while (TREE_CODE (tmp) == ARRAY_TYPE)
3298 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3299 tmp = TREE_TYPE (tmp);
3302 else if (TREE_CODE (t) == FUNCTION_DECL)
3304 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3305 pp_space (pp);
3306 dump_decl_name (pp, t, flags);
3307 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3309 else
3311 /* Print type declaration. */
3312 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3314 /* Print variable's name. */
3315 pp_space (pp);
3316 dump_generic_node (pp, t, spc, flags, false);
3319 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3321 pp_string (pp, " __asm__ ");
3322 pp_left_paren (pp);
3323 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3324 pp_right_paren (pp);
3327 /* The initial value of a function serves to determine whether the function
3328 is declared or defined. So the following does not apply to function
3329 nodes. */
3330 if (TREE_CODE (t) != FUNCTION_DECL)
3332 /* Print the initial value. */
3333 if (DECL_INITIAL (t))
3335 pp_space (pp);
3336 pp_equal (pp);
3337 pp_space (pp);
3338 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3342 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3344 pp_string (pp, " [value-expr: ");
3345 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3346 pp_right_bracket (pp);
3349 pp_semicolon (pp);
3353 /* Prints a structure: name, fields, and methods.
3354 FIXME: Still incomplete. */
3356 static void
3357 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3359 /* Print the name of the structure. */
3360 if (TYPE_NAME (node))
3362 INDENT (spc);
3363 if (TREE_CODE (node) == RECORD_TYPE)
3364 pp_string (pp, "struct ");
3365 else if ((TREE_CODE (node) == UNION_TYPE
3366 || TREE_CODE (node) == QUAL_UNION_TYPE))
3367 pp_string (pp, "union ");
3369 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3372 /* Print the contents of the structure. */
3373 pp_newline (pp);
3374 INDENT (spc);
3375 pp_left_brace (pp);
3376 pp_newline (pp);
3378 /* Print the fields of the structure. */
3380 tree tmp;
3381 tmp = TYPE_FIELDS (node);
3382 while (tmp)
3384 /* Avoid to print recursively the structure. */
3385 /* FIXME : Not implemented correctly...,
3386 what about the case when we have a cycle in the contain graph? ...
3387 Maybe this could be solved by looking at the scope in which the
3388 structure was declared. */
3389 if (TREE_TYPE (tmp) != node
3390 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3391 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3393 print_declaration (pp, tmp, spc+2, flags);
3394 pp_newline (pp);
3396 tmp = DECL_CHAIN (tmp);
3399 INDENT (spc);
3400 pp_right_brace (pp);
3403 /* Return the priority of the operator CODE.
3405 From lowest to highest precedence with either left-to-right (L-R)
3406 or right-to-left (R-L) associativity]:
3408 1 [L-R] ,
3409 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3410 3 [R-L] ?:
3411 4 [L-R] ||
3412 5 [L-R] &&
3413 6 [L-R] |
3414 7 [L-R] ^
3415 8 [L-R] &
3416 9 [L-R] == !=
3417 10 [L-R] < <= > >=
3418 11 [L-R] << >>
3419 12 [L-R] + -
3420 13 [L-R] * / %
3421 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3422 15 [L-R] fn() [] -> .
3424 unary +, - and * have higher precedence than the corresponding binary
3425 operators. */
3428 op_code_prio (enum tree_code code)
3430 switch (code)
3432 case TREE_LIST:
3433 case COMPOUND_EXPR:
3434 case BIND_EXPR:
3435 return 1;
3437 case MODIFY_EXPR:
3438 case INIT_EXPR:
3439 return 2;
3441 case COND_EXPR:
3442 return 3;
3444 case TRUTH_OR_EXPR:
3445 case TRUTH_ORIF_EXPR:
3446 return 4;
3448 case TRUTH_AND_EXPR:
3449 case TRUTH_ANDIF_EXPR:
3450 return 5;
3452 case BIT_IOR_EXPR:
3453 return 6;
3455 case BIT_XOR_EXPR:
3456 case TRUTH_XOR_EXPR:
3457 return 7;
3459 case BIT_AND_EXPR:
3460 return 8;
3462 case EQ_EXPR:
3463 case NE_EXPR:
3464 return 9;
3466 case UNLT_EXPR:
3467 case UNLE_EXPR:
3468 case UNGT_EXPR:
3469 case UNGE_EXPR:
3470 case UNEQ_EXPR:
3471 case LTGT_EXPR:
3472 case ORDERED_EXPR:
3473 case UNORDERED_EXPR:
3474 case LT_EXPR:
3475 case LE_EXPR:
3476 case GT_EXPR:
3477 case GE_EXPR:
3478 return 10;
3480 case LSHIFT_EXPR:
3481 case RSHIFT_EXPR:
3482 case LROTATE_EXPR:
3483 case RROTATE_EXPR:
3484 case VEC_WIDEN_LSHIFT_HI_EXPR:
3485 case VEC_WIDEN_LSHIFT_LO_EXPR:
3486 case WIDEN_LSHIFT_EXPR:
3487 return 11;
3489 case WIDEN_SUM_EXPR:
3490 case PLUS_EXPR:
3491 case POINTER_PLUS_EXPR:
3492 case MINUS_EXPR:
3493 return 12;
3495 case VEC_WIDEN_MULT_HI_EXPR:
3496 case VEC_WIDEN_MULT_LO_EXPR:
3497 case WIDEN_MULT_EXPR:
3498 case DOT_PROD_EXPR:
3499 case WIDEN_MULT_PLUS_EXPR:
3500 case WIDEN_MULT_MINUS_EXPR:
3501 case MULT_EXPR:
3502 case MULT_HIGHPART_EXPR:
3503 case TRUNC_DIV_EXPR:
3504 case CEIL_DIV_EXPR:
3505 case FLOOR_DIV_EXPR:
3506 case ROUND_DIV_EXPR:
3507 case RDIV_EXPR:
3508 case EXACT_DIV_EXPR:
3509 case TRUNC_MOD_EXPR:
3510 case CEIL_MOD_EXPR:
3511 case FLOOR_MOD_EXPR:
3512 case ROUND_MOD_EXPR:
3513 case FMA_EXPR:
3514 return 13;
3516 case TRUTH_NOT_EXPR:
3517 case BIT_NOT_EXPR:
3518 case POSTINCREMENT_EXPR:
3519 case POSTDECREMENT_EXPR:
3520 case PREINCREMENT_EXPR:
3521 case PREDECREMENT_EXPR:
3522 case NEGATE_EXPR:
3523 case INDIRECT_REF:
3524 case ADDR_EXPR:
3525 case FLOAT_EXPR:
3526 CASE_CONVERT:
3527 case FIX_TRUNC_EXPR:
3528 case TARGET_EXPR:
3529 return 14;
3531 case CALL_EXPR:
3532 case ARRAY_REF:
3533 case ARRAY_RANGE_REF:
3534 case COMPONENT_REF:
3535 return 15;
3537 /* Special expressions. */
3538 case MIN_EXPR:
3539 case MAX_EXPR:
3540 case ABS_EXPR:
3541 case REALPART_EXPR:
3542 case IMAGPART_EXPR:
3543 case REDUC_MAX_EXPR:
3544 case REDUC_MIN_EXPR:
3545 case REDUC_PLUS_EXPR:
3546 case VEC_UNPACK_HI_EXPR:
3547 case VEC_UNPACK_LO_EXPR:
3548 case VEC_UNPACK_FLOAT_HI_EXPR:
3549 case VEC_UNPACK_FLOAT_LO_EXPR:
3550 case VEC_PACK_TRUNC_EXPR:
3551 case VEC_PACK_SAT_EXPR:
3552 return 16;
3554 default:
3555 /* Return an arbitrarily high precedence to avoid surrounding single
3556 VAR_DECLs in ()s. */
3557 return 9999;
3561 /* Return the priority of the operator OP. */
3564 op_prio (const_tree op)
3566 enum tree_code code;
3568 if (op == NULL)
3569 return 9999;
3571 code = TREE_CODE (op);
3572 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3573 return op_prio (TREE_OPERAND (op, 0));
3575 return op_code_prio (code);
3578 /* Return the symbol associated with operator CODE. */
3580 const char *
3581 op_symbol_code (enum tree_code code)
3583 switch (code)
3585 case MODIFY_EXPR:
3586 return "=";
3588 case TRUTH_OR_EXPR:
3589 case TRUTH_ORIF_EXPR:
3590 return "||";
3592 case TRUTH_AND_EXPR:
3593 case TRUTH_ANDIF_EXPR:
3594 return "&&";
3596 case BIT_IOR_EXPR:
3597 return "|";
3599 case TRUTH_XOR_EXPR:
3600 case BIT_XOR_EXPR:
3601 return "^";
3603 case ADDR_EXPR:
3604 case BIT_AND_EXPR:
3605 return "&";
3607 case ORDERED_EXPR:
3608 return "ord";
3609 case UNORDERED_EXPR:
3610 return "unord";
3612 case EQ_EXPR:
3613 return "==";
3614 case UNEQ_EXPR:
3615 return "u==";
3617 case NE_EXPR:
3618 return "!=";
3620 case LT_EXPR:
3621 return "<";
3622 case UNLT_EXPR:
3623 return "u<";
3625 case LE_EXPR:
3626 return "<=";
3627 case UNLE_EXPR:
3628 return "u<=";
3630 case GT_EXPR:
3631 return ">";
3632 case UNGT_EXPR:
3633 return "u>";
3635 case GE_EXPR:
3636 return ">=";
3637 case UNGE_EXPR:
3638 return "u>=";
3640 case LTGT_EXPR:
3641 return "<>";
3643 case LSHIFT_EXPR:
3644 return "<<";
3646 case RSHIFT_EXPR:
3647 return ">>";
3649 case LROTATE_EXPR:
3650 return "r<<";
3652 case RROTATE_EXPR:
3653 return "r>>";
3655 case WIDEN_LSHIFT_EXPR:
3656 return "w<<";
3658 case POINTER_PLUS_EXPR:
3659 return "+";
3661 case PLUS_EXPR:
3662 return "+";
3664 case REDUC_PLUS_EXPR:
3665 return "r+";
3667 case WIDEN_SUM_EXPR:
3668 return "w+";
3670 case WIDEN_MULT_EXPR:
3671 return "w*";
3673 case MULT_HIGHPART_EXPR:
3674 return "h*";
3676 case NEGATE_EXPR:
3677 case MINUS_EXPR:
3678 return "-";
3680 case BIT_NOT_EXPR:
3681 return "~";
3683 case TRUTH_NOT_EXPR:
3684 return "!";
3686 case MULT_EXPR:
3687 case INDIRECT_REF:
3688 return "*";
3690 case TRUNC_DIV_EXPR:
3691 case RDIV_EXPR:
3692 return "/";
3694 case CEIL_DIV_EXPR:
3695 return "/[cl]";
3697 case FLOOR_DIV_EXPR:
3698 return "/[fl]";
3700 case ROUND_DIV_EXPR:
3701 return "/[rd]";
3703 case EXACT_DIV_EXPR:
3704 return "/[ex]";
3706 case TRUNC_MOD_EXPR:
3707 return "%";
3709 case CEIL_MOD_EXPR:
3710 return "%[cl]";
3712 case FLOOR_MOD_EXPR:
3713 return "%[fl]";
3715 case ROUND_MOD_EXPR:
3716 return "%[rd]";
3718 case PREDECREMENT_EXPR:
3719 return " --";
3721 case PREINCREMENT_EXPR:
3722 return " ++";
3724 case POSTDECREMENT_EXPR:
3725 return "-- ";
3727 case POSTINCREMENT_EXPR:
3728 return "++ ";
3730 case MAX_EXPR:
3731 return "max";
3733 case MIN_EXPR:
3734 return "min";
3736 default:
3737 return "<<< ??? >>>";
3741 /* Return the symbol associated with operator OP. */
3743 static const char *
3744 op_symbol (const_tree op)
3746 return op_symbol_code (TREE_CODE (op));
3749 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3750 the gimple_call_fn of a GIMPLE_CALL. */
3752 void
3753 print_call_name (pretty_printer *pp, tree node, int flags)
3755 tree op0 = node;
3757 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3758 op0 = TREE_OPERAND (op0, 0);
3760 again:
3761 switch (TREE_CODE (op0))
3763 case VAR_DECL:
3764 case PARM_DECL:
3765 case FUNCTION_DECL:
3766 dump_function_name (pp, op0, flags);
3767 break;
3769 case ADDR_EXPR:
3770 case INDIRECT_REF:
3771 CASE_CONVERT:
3772 op0 = TREE_OPERAND (op0, 0);
3773 goto again;
3775 case COND_EXPR:
3776 pp_left_paren (pp);
3777 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3778 pp_string (pp, ") ? ");
3779 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3780 pp_string (pp, " : ");
3781 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3782 break;
3784 case ARRAY_REF:
3785 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3786 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3787 else
3788 dump_generic_node (pp, op0, 0, flags, false);
3789 break;
3791 case MEM_REF:
3792 if (integer_zerop (TREE_OPERAND (op0, 1)))
3794 op0 = TREE_OPERAND (op0, 0);
3795 goto again;
3797 /* Fallthru. */
3798 case COMPONENT_REF:
3799 case SSA_NAME:
3800 case OBJ_TYPE_REF:
3801 dump_generic_node (pp, op0, 0, flags, false);
3802 break;
3804 default:
3805 NIY;
3809 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3811 static void
3812 pretty_print_string (pretty_printer *pp, const char *str)
3814 if (str == NULL)
3815 return;
3817 while (*str)
3819 switch (str[0])
3821 case '\b':
3822 pp_string (pp, "\\b");
3823 break;
3825 case '\f':
3826 pp_string (pp, "\\f");
3827 break;
3829 case '\n':
3830 pp_string (pp, "\\n");
3831 break;
3833 case '\r':
3834 pp_string (pp, "\\r");
3835 break;
3837 case '\t':
3838 pp_string (pp, "\\t");
3839 break;
3841 case '\v':
3842 pp_string (pp, "\\v");
3843 break;
3845 case '\\':
3846 pp_string (pp, "\\\\");
3847 break;
3849 case '\"':
3850 pp_string (pp, "\\\"");
3851 break;
3853 case '\'':
3854 pp_string (pp, "\\'");
3855 break;
3857 /* No need to handle \0; the loop terminates on \0. */
3859 case '\1':
3860 pp_string (pp, "\\1");
3861 break;
3863 case '\2':
3864 pp_string (pp, "\\2");
3865 break;
3867 case '\3':
3868 pp_string (pp, "\\3");
3869 break;
3871 case '\4':
3872 pp_string (pp, "\\4");
3873 break;
3875 case '\5':
3876 pp_string (pp, "\\5");
3877 break;
3879 case '\6':
3880 pp_string (pp, "\\6");
3881 break;
3883 case '\7':
3884 pp_string (pp, "\\7");
3885 break;
3887 default:
3888 if (!ISPRINT (str[0]))
3890 char buf[5];
3891 sprintf (buf, "\\x%x", (unsigned char)str[0]);
3892 pp_string (pp, buf);
3894 else
3895 pp_character (pp, str[0]);
3896 break;
3898 str++;
3902 static void
3903 maybe_init_pretty_print (FILE *file)
3905 if (!tree_pp)
3907 tree_pp = new pretty_printer ();
3908 pp_needs_newline (tree_pp) = true;
3909 pp_translate_identifiers (tree_pp) = false;
3912 tree_pp->buffer->stream = file;
3915 static void
3916 newline_and_indent (pretty_printer *pp, int spc)
3918 pp_newline (pp);
3919 INDENT (spc);
3922 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3923 it can also be used in front ends.
3924 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3927 void
3928 percent_K_format (text_info *text)
3930 tree t = va_arg (*text->args_ptr, tree), block;
3931 text->set_location (0, EXPR_LOCATION (t), true);
3932 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3933 block = TREE_BLOCK (t);
3934 *pp_ti_abstract_origin (text) = NULL;
3936 if (in_lto_p)
3938 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3939 representing the outermost block of an inlined function.
3940 So walk the BLOCK tree until we hit such a scope. */
3941 while (block
3942 && TREE_CODE (block) == BLOCK)
3944 if (inlined_function_outer_scope_p (block))
3946 *pp_ti_abstract_origin (text) = block;
3947 break;
3949 block = BLOCK_SUPERCONTEXT (block);
3951 return;
3954 while (block
3955 && TREE_CODE (block) == BLOCK
3956 && BLOCK_ABSTRACT_ORIGIN (block))
3958 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3960 while (TREE_CODE (ao) == BLOCK
3961 && BLOCK_ABSTRACT_ORIGIN (ao)
3962 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3963 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3965 if (TREE_CODE (ao) == FUNCTION_DECL)
3967 *pp_ti_abstract_origin (text) = block;
3968 break;
3970 block = BLOCK_SUPERCONTEXT (block);
3974 /* Print the identifier ID to PRETTY-PRINTER. */
3976 void
3977 pp_tree_identifier (pretty_printer *pp, tree id)
3979 if (pp_translate_identifiers (pp))
3981 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3982 pp_append_text (pp, text, text + strlen (text));
3984 else
3985 pp_append_text (pp, IDENTIFIER_POINTER (id),
3986 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3989 /* A helper function that is used to dump function information before the
3990 function dump. */
3992 void
3993 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3995 const char *dname, *aname;
3996 struct cgraph_node *node = cgraph_node::get (fdecl);
3997 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3999 dname = lang_hooks.decl_printable_name (fdecl, 2);
4001 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4002 aname = (IDENTIFIER_POINTER
4003 (DECL_ASSEMBLER_NAME (fdecl)));
4004 else
4005 aname = "<unset-asm-name>";
4007 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4008 dname, aname, fun->funcdef_no);
4009 if (!(flags & TDF_NOUID))
4010 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4011 if (node)
4013 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
4014 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4015 node->frequency == NODE_FREQUENCY_HOT
4016 ? " (hot)"
4017 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4018 ? " (unlikely executed)"
4019 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4020 ? " (executed once)"
4021 : "");
4023 else
4024 fprintf (dump_file, ")\n\n");
4027 /* Dump double_int D to pretty_printer PP. UNS is true
4028 if D is unsigned and false otherwise. */
4029 void
4030 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4032 if (d.fits_shwi ())
4033 pp_wide_integer (pp, d.low);
4034 else if (d.fits_uhwi ())
4035 pp_unsigned_wide_integer (pp, d.low);
4036 else
4038 unsigned HOST_WIDE_INT low = d.low;
4039 HOST_WIDE_INT high = d.high;
4040 if (!uns && d.is_negative ())
4042 pp_minus (pp);
4043 high = ~high + !low;
4044 low = -low;
4046 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4047 systems? */
4048 sprintf (pp_buffer (pp)->digit_buffer,
4049 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4050 (unsigned HOST_WIDE_INT) high, low);
4051 pp_string (pp, pp_buffer (pp)->digit_buffer);