[gcc]
[official-gcc.git] / gcc / tree-pretty-print.c
blobebbf606ff8b60682bad0235f19ac72398c160005
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2016 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "backend.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "predict.h"
28 #include "cgraph.h"
29 #include "tree-pretty-print.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "dumpfile.h"
34 #include "internal-fn.h"
35 #include "gomp-constants.h"
37 /* Local functions, macros and variables. */
38 static const char *op_symbol (const_tree);
39 static void pretty_print_string (pretty_printer *, const char*);
40 static void newline_and_indent (pretty_printer *, int);
41 static void maybe_init_pretty_print (FILE *);
42 static void print_struct_decl (pretty_printer *, const_tree, int, int);
43 static void do_niy (pretty_printer *, const_tree, 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 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
262 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
263 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
264 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
266 if (flags & TDF_NOUID)
267 pp_string (pp, "D#xxxx");
268 else
269 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
271 else
273 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
274 if (flags & TDF_NOUID)
275 pp_printf (pp, "%c.xxxx", c);
276 else
277 pp_printf (pp, "%c.%u", c, DECL_UID (node));
280 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
282 if (flags & TDF_NOUID)
283 pp_printf (pp, "ptD.xxxx");
284 else
285 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
289 /* Like the above, but used for pretty printing function calls. */
291 static void
292 dump_function_name (pretty_printer *pp, tree node, int flags)
294 if (CONVERT_EXPR_P (node))
295 node = TREE_OPERAND (node, 0);
296 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
297 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
298 else
299 dump_decl_name (pp, node, flags);
302 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
303 FLAGS are as in dump_generic_node. */
305 static void
306 dump_function_declaration (pretty_printer *pp, tree node,
307 int spc, int flags)
309 bool wrote_arg = false;
310 tree arg;
312 pp_space (pp);
313 pp_left_paren (pp);
315 /* Print the argument types. */
316 arg = TYPE_ARG_TYPES (node);
317 while (arg && arg != void_list_node && arg != error_mark_node)
319 if (wrote_arg)
321 pp_comma (pp);
322 pp_space (pp);
324 wrote_arg = true;
325 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
326 arg = TREE_CHAIN (arg);
329 /* Drop the trailing void_type_node if we had any previous argument. */
330 if (arg == void_list_node && !wrote_arg)
331 pp_string (pp, "void");
332 /* Properly dump vararg function types. */
333 else if (!arg && wrote_arg)
334 pp_string (pp, ", ...");
335 /* Avoid printing any arg for unprototyped functions. */
337 pp_right_paren (pp);
340 /* Dump the domain associated with an array. */
342 static void
343 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
345 pp_left_bracket (pp);
346 if (domain)
348 tree min = TYPE_MIN_VALUE (domain);
349 tree max = TYPE_MAX_VALUE (domain);
351 if (min && max
352 && integer_zerop (min)
353 && tree_fits_shwi_p (max))
354 pp_wide_integer (pp, tree_to_shwi (max) + 1);
355 else
357 if (min)
358 dump_generic_node (pp, min, spc, flags, false);
359 pp_colon (pp);
360 if (max)
361 dump_generic_node (pp, max, spc, flags, false);
364 else
365 pp_string (pp, "<unknown>");
366 pp_right_bracket (pp);
370 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
371 dump_generic_node. */
373 static void
374 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
376 const char *name;
378 switch (OMP_CLAUSE_CODE (clause))
380 case OMP_CLAUSE_PRIVATE:
381 name = "private";
382 goto print_remap;
383 case OMP_CLAUSE_SHARED:
384 name = "shared";
385 goto print_remap;
386 case OMP_CLAUSE_FIRSTPRIVATE:
387 name = "firstprivate";
388 goto print_remap;
389 case OMP_CLAUSE_LASTPRIVATE:
390 name = "lastprivate";
391 goto print_remap;
392 case OMP_CLAUSE_COPYIN:
393 name = "copyin";
394 goto print_remap;
395 case OMP_CLAUSE_COPYPRIVATE:
396 name = "copyprivate";
397 goto print_remap;
398 case OMP_CLAUSE_UNIFORM:
399 name = "uniform";
400 goto print_remap;
401 case OMP_CLAUSE_USE_DEVICE_PTR:
402 name = "use_device_ptr";
403 goto print_remap;
404 case OMP_CLAUSE_IS_DEVICE_PTR:
405 name = "is_device_ptr";
406 goto print_remap;
407 case OMP_CLAUSE__LOOPTEMP_:
408 name = "_looptemp_";
409 goto print_remap;
410 case OMP_CLAUSE_TO_DECLARE:
411 name = "to";
412 goto print_remap;
413 case OMP_CLAUSE_LINK:
414 name = "link";
415 goto print_remap;
416 print_remap:
417 pp_string (pp, name);
418 pp_left_paren (pp);
419 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
420 spc, flags, false);
421 pp_right_paren (pp);
422 break;
424 case OMP_CLAUSE_REDUCTION:
425 pp_string (pp, "reduction(");
426 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
428 pp_string (pp,
429 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
430 pp_colon (pp);
432 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
433 spc, flags, false);
434 pp_right_paren (pp);
435 break;
437 case OMP_CLAUSE_IF:
438 pp_string (pp, "if(");
439 switch (OMP_CLAUSE_IF_MODIFIER (clause))
441 case ERROR_MARK: break;
442 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
443 case OMP_TASK: pp_string (pp, "task:"); break;
444 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
445 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
446 case OMP_TARGET: pp_string (pp, "target:"); break;
447 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
448 case OMP_TARGET_ENTER_DATA:
449 pp_string (pp, "target enter data:"); break;
450 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
451 default: gcc_unreachable ();
453 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
454 spc, flags, false);
455 pp_right_paren (pp);
456 break;
458 case OMP_CLAUSE_NUM_THREADS:
459 pp_string (pp, "num_threads(");
460 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
461 spc, flags, false);
462 pp_right_paren (pp);
463 break;
465 case OMP_CLAUSE__CILK_FOR_COUNT_:
466 pp_string (pp, "_Cilk_for_count_(");
467 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
468 spc, flags, false);
469 pp_right_paren (pp);
470 break;
472 case OMP_CLAUSE_NOWAIT:
473 pp_string (pp, "nowait");
474 break;
475 case OMP_CLAUSE_ORDERED:
476 pp_string (pp, "ordered");
477 if (OMP_CLAUSE_ORDERED_EXPR (clause))
479 pp_left_paren (pp);
480 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
481 spc, flags, false);
482 pp_right_paren (pp);
484 break;
486 case OMP_CLAUSE_DEFAULT:
487 pp_string (pp, "default(");
488 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
490 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
491 break;
492 case OMP_CLAUSE_DEFAULT_SHARED:
493 pp_string (pp, "shared");
494 break;
495 case OMP_CLAUSE_DEFAULT_NONE:
496 pp_string (pp, "none");
497 break;
498 case OMP_CLAUSE_DEFAULT_PRIVATE:
499 pp_string (pp, "private");
500 break;
501 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
502 pp_string (pp, "firstprivate");
503 break;
504 default:
505 gcc_unreachable ();
507 pp_right_paren (pp);
508 break;
510 case OMP_CLAUSE_SCHEDULE:
511 pp_string (pp, "schedule(");
512 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
513 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
514 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
516 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
517 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
518 pp_string (pp, "monotonic");
519 else
520 pp_string (pp, "nonmonotonic");
521 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
522 pp_comma (pp);
523 else
524 pp_colon (pp);
526 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
527 pp_string (pp, "simd:");
529 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
531 case OMP_CLAUSE_SCHEDULE_STATIC:
532 pp_string (pp, "static");
533 break;
534 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
535 pp_string (pp, "dynamic");
536 break;
537 case OMP_CLAUSE_SCHEDULE_GUIDED:
538 pp_string (pp, "guided");
539 break;
540 case OMP_CLAUSE_SCHEDULE_RUNTIME:
541 pp_string (pp, "runtime");
542 break;
543 case OMP_CLAUSE_SCHEDULE_AUTO:
544 pp_string (pp, "auto");
545 break;
546 case OMP_CLAUSE_SCHEDULE_CILKFOR:
547 pp_string (pp, "cilk-for grain");
548 break;
549 default:
550 gcc_unreachable ();
552 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
554 pp_comma (pp);
555 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
556 spc, flags, false);
558 pp_right_paren (pp);
559 break;
561 case OMP_CLAUSE_UNTIED:
562 pp_string (pp, "untied");
563 break;
565 case OMP_CLAUSE_COLLAPSE:
566 pp_string (pp, "collapse(");
567 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
568 spc, flags, false);
569 pp_right_paren (pp);
570 break;
572 case OMP_CLAUSE_FINAL:
573 pp_string (pp, "final(");
574 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
575 spc, flags, false);
576 pp_right_paren (pp);
577 break;
579 case OMP_CLAUSE_MERGEABLE:
580 pp_string (pp, "mergeable");
581 break;
583 case OMP_CLAUSE_LINEAR:
584 pp_string (pp, "linear(");
585 switch (OMP_CLAUSE_LINEAR_KIND (clause))
587 case OMP_CLAUSE_LINEAR_DEFAULT:
588 break;
589 case OMP_CLAUSE_LINEAR_REF:
590 pp_string (pp, "ref(");
591 break;
592 case OMP_CLAUSE_LINEAR_VAL:
593 pp_string (pp, "val(");
594 break;
595 case OMP_CLAUSE_LINEAR_UVAL:
596 pp_string (pp, "uval(");
597 break;
598 default:
599 gcc_unreachable ();
601 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
602 spc, flags, false);
603 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
604 pp_right_paren (pp);
605 pp_colon (pp);
606 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
607 spc, flags, false);
608 pp_right_paren (pp);
609 break;
611 case OMP_CLAUSE_ALIGNED:
612 pp_string (pp, "aligned(");
613 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
614 spc, flags, false);
615 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
617 pp_colon (pp);
618 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
619 spc, flags, false);
621 pp_right_paren (pp);
622 break;
624 case OMP_CLAUSE_DEPEND:
625 pp_string (pp, "depend(");
626 switch (OMP_CLAUSE_DEPEND_KIND (clause))
628 case OMP_CLAUSE_DEPEND_IN:
629 pp_string (pp, "in");
630 break;
631 case OMP_CLAUSE_DEPEND_OUT:
632 pp_string (pp, "out");
633 break;
634 case OMP_CLAUSE_DEPEND_INOUT:
635 pp_string (pp, "inout");
636 break;
637 case OMP_CLAUSE_DEPEND_SOURCE:
638 pp_string (pp, "source)");
639 return;
640 case OMP_CLAUSE_DEPEND_SINK:
641 pp_string (pp, "sink:");
642 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
643 if (TREE_CODE (t) == TREE_LIST)
645 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
646 if (TREE_PURPOSE (t) != integer_zero_node)
648 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
649 pp_minus (pp);
650 else
651 pp_plus (pp);
652 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
653 false);
655 if (TREE_CHAIN (t))
656 pp_comma (pp);
658 else
659 gcc_unreachable ();
660 pp_right_paren (pp);
661 return;
662 default:
663 gcc_unreachable ();
665 pp_colon (pp);
666 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
667 spc, flags, false);
668 pp_right_paren (pp);
669 break;
671 case OMP_CLAUSE_MAP:
672 pp_string (pp, "map(");
673 switch (OMP_CLAUSE_MAP_KIND (clause))
675 case GOMP_MAP_ALLOC:
676 case GOMP_MAP_POINTER:
677 pp_string (pp, "alloc");
678 break;
679 case GOMP_MAP_TO:
680 case GOMP_MAP_TO_PSET:
681 pp_string (pp, "to");
682 break;
683 case GOMP_MAP_FROM:
684 pp_string (pp, "from");
685 break;
686 case GOMP_MAP_TOFROM:
687 pp_string (pp, "tofrom");
688 break;
689 case GOMP_MAP_FORCE_ALLOC:
690 pp_string (pp, "force_alloc");
691 break;
692 case GOMP_MAP_FORCE_TO:
693 pp_string (pp, "force_to");
694 break;
695 case GOMP_MAP_FORCE_FROM:
696 pp_string (pp, "force_from");
697 break;
698 case GOMP_MAP_FORCE_TOFROM:
699 pp_string (pp, "force_tofrom");
700 break;
701 case GOMP_MAP_FORCE_PRESENT:
702 pp_string (pp, "force_present");
703 break;
704 case GOMP_MAP_DELETE:
705 pp_string (pp, "delete");
706 break;
707 case GOMP_MAP_FORCE_DEVICEPTR:
708 pp_string (pp, "force_deviceptr");
709 break;
710 case GOMP_MAP_ALWAYS_TO:
711 pp_string (pp, "always,to");
712 break;
713 case GOMP_MAP_ALWAYS_FROM:
714 pp_string (pp, "always,from");
715 break;
716 case GOMP_MAP_ALWAYS_TOFROM:
717 pp_string (pp, "always,tofrom");
718 break;
719 case GOMP_MAP_RELEASE:
720 pp_string (pp, "release");
721 break;
722 case GOMP_MAP_FIRSTPRIVATE_POINTER:
723 pp_string (pp, "firstprivate");
724 break;
725 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
726 pp_string (pp, "firstprivate ref");
727 break;
728 case GOMP_MAP_STRUCT:
729 pp_string (pp, "struct");
730 break;
731 case GOMP_MAP_ALWAYS_POINTER:
732 pp_string (pp, "always_pointer");
733 break;
734 case GOMP_MAP_DEVICE_RESIDENT:
735 pp_string (pp, "device_resident");
736 break;
737 case GOMP_MAP_LINK:
738 pp_string (pp, "link");
739 break;
740 default:
741 gcc_unreachable ();
743 pp_colon (pp);
744 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
745 spc, flags, false);
746 print_clause_size:
747 if (OMP_CLAUSE_SIZE (clause))
749 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
750 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
752 case GOMP_MAP_POINTER:
753 case GOMP_MAP_FIRSTPRIVATE_POINTER:
754 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
755 case GOMP_MAP_ALWAYS_POINTER:
756 pp_string (pp, " [pointer assign, bias: ");
757 break;
758 case GOMP_MAP_TO_PSET:
759 pp_string (pp, " [pointer set, len: ");
760 break;
761 default:
762 pp_string (pp, " [len: ");
763 break;
765 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
766 spc, flags, false);
767 pp_right_bracket (pp);
769 pp_right_paren (pp);
770 break;
772 case OMP_CLAUSE_FROM:
773 pp_string (pp, "from(");
774 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
775 spc, flags, false);
776 goto print_clause_size;
778 case OMP_CLAUSE_TO:
779 pp_string (pp, "to(");
780 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
781 spc, flags, false);
782 goto print_clause_size;
784 case OMP_CLAUSE__CACHE_:
785 pp_string (pp, "(");
786 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
787 spc, flags, false);
788 goto print_clause_size;
790 case OMP_CLAUSE_NUM_TEAMS:
791 pp_string (pp, "num_teams(");
792 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
793 spc, flags, false);
794 pp_right_paren (pp);
795 break;
797 case OMP_CLAUSE_THREAD_LIMIT:
798 pp_string (pp, "thread_limit(");
799 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
800 spc, flags, false);
801 pp_right_paren (pp);
802 break;
804 case OMP_CLAUSE_DEVICE:
805 pp_string (pp, "device(");
806 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
807 spc, flags, false);
808 pp_right_paren (pp);
809 break;
811 case OMP_CLAUSE_DIST_SCHEDULE:
812 pp_string (pp, "dist_schedule(static");
813 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
815 pp_comma (pp);
816 dump_generic_node (pp,
817 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
818 spc, flags, false);
820 pp_right_paren (pp);
821 break;
823 case OMP_CLAUSE_PROC_BIND:
824 pp_string (pp, "proc_bind(");
825 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
827 case OMP_CLAUSE_PROC_BIND_MASTER:
828 pp_string (pp, "master");
829 break;
830 case OMP_CLAUSE_PROC_BIND_CLOSE:
831 pp_string (pp, "close");
832 break;
833 case OMP_CLAUSE_PROC_BIND_SPREAD:
834 pp_string (pp, "spread");
835 break;
836 default:
837 gcc_unreachable ();
839 pp_right_paren (pp);
840 break;
842 case OMP_CLAUSE_SAFELEN:
843 pp_string (pp, "safelen(");
844 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
845 spc, flags, false);
846 pp_right_paren (pp);
847 break;
849 case OMP_CLAUSE_SIMDLEN:
850 pp_string (pp, "simdlen(");
851 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
852 spc, flags, false);
853 pp_right_paren (pp);
854 break;
856 case OMP_CLAUSE_PRIORITY:
857 pp_string (pp, "priority(");
858 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
859 spc, flags, false);
860 pp_right_paren (pp);
861 break;
863 case OMP_CLAUSE_GRAINSIZE:
864 pp_string (pp, "grainsize(");
865 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
866 spc, flags, false);
867 pp_right_paren (pp);
868 break;
870 case OMP_CLAUSE_NUM_TASKS:
871 pp_string (pp, "num_tasks(");
872 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
873 spc, flags, false);
874 pp_right_paren (pp);
875 break;
877 case OMP_CLAUSE_HINT:
878 pp_string (pp, "hint(");
879 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
880 spc, flags, false);
881 pp_right_paren (pp);
882 break;
884 case OMP_CLAUSE_DEFAULTMAP:
885 pp_string (pp, "defaultmap(tofrom:scalar)");
886 break;
888 case OMP_CLAUSE__SIMDUID_:
889 pp_string (pp, "_simduid_(");
890 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
891 spc, flags, false);
892 pp_right_paren (pp);
893 break;
895 case OMP_CLAUSE_GANG:
896 pp_string (pp, "gang");
897 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
899 pp_string (pp, "(num: ");
900 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
901 spc, flags, false);
903 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
905 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
906 pp_left_paren (pp);
907 else
908 pp_space (pp);
909 pp_string (pp, "static:");
910 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
911 == integer_minus_one_node)
912 pp_character (pp, '*');
913 else
914 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
915 spc, flags, false);
917 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
918 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
919 pp_right_paren (pp);
920 break;
922 case OMP_CLAUSE_ASYNC:
923 pp_string (pp, "async");
924 if (OMP_CLAUSE_ASYNC_EXPR (clause))
926 pp_character(pp, '(');
927 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
928 spc, flags, false);
929 pp_character(pp, ')');
931 break;
933 case OMP_CLAUSE_AUTO:
934 case OMP_CLAUSE_SEQ:
935 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
936 break;
938 case OMP_CLAUSE_WAIT:
939 pp_string (pp, "wait(");
940 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
941 spc, flags, false);
942 pp_character(pp, ')');
943 break;
945 case OMP_CLAUSE_WORKER:
946 pp_string (pp, "worker");
947 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
949 pp_left_paren (pp);
950 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
951 spc, flags, false);
952 pp_right_paren (pp);
954 break;
956 case OMP_CLAUSE_VECTOR:
957 pp_string (pp, "vector");
958 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
960 pp_left_paren (pp);
961 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
962 spc, flags, false);
963 pp_right_paren (pp);
965 break;
967 case OMP_CLAUSE_NUM_GANGS:
968 pp_string (pp, "num_gangs(");
969 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
970 spc, flags, false);
971 pp_character (pp, ')');
972 break;
974 case OMP_CLAUSE_NUM_WORKERS:
975 pp_string (pp, "num_workers(");
976 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
977 spc, flags, false);
978 pp_character (pp, ')');
979 break;
981 case OMP_CLAUSE_VECTOR_LENGTH:
982 pp_string (pp, "vector_length(");
983 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
984 spc, flags, false);
985 pp_character (pp, ')');
986 break;
988 case OMP_CLAUSE_INBRANCH:
989 pp_string (pp, "inbranch");
990 break;
991 case OMP_CLAUSE_NOTINBRANCH:
992 pp_string (pp, "notinbranch");
993 break;
994 case OMP_CLAUSE_FOR:
995 pp_string (pp, "for");
996 break;
997 case OMP_CLAUSE_PARALLEL:
998 pp_string (pp, "parallel");
999 break;
1000 case OMP_CLAUSE_SECTIONS:
1001 pp_string (pp, "sections");
1002 break;
1003 case OMP_CLAUSE_TASKGROUP:
1004 pp_string (pp, "taskgroup");
1005 break;
1006 case OMP_CLAUSE_NOGROUP:
1007 pp_string (pp, "nogroup");
1008 break;
1009 case OMP_CLAUSE_THREADS:
1010 pp_string (pp, "threads");
1011 break;
1012 case OMP_CLAUSE_SIMD:
1013 pp_string (pp, "simd");
1014 break;
1015 case OMP_CLAUSE_INDEPENDENT:
1016 pp_string (pp, "independent");
1017 break;
1018 case OMP_CLAUSE_TILE:
1019 pp_string (pp, "tile(");
1020 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1021 spc, flags, false);
1022 pp_right_paren (pp);
1023 break;
1025 case OMP_CLAUSE__GRIDDIM_:
1026 pp_string (pp, "_griddim_(");
1027 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1028 pp_colon (pp);
1029 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1030 false);
1031 pp_comma (pp);
1032 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1033 false);
1034 pp_right_paren (pp);
1035 break;
1037 default:
1038 /* Should never happen. */
1039 dump_generic_node (pp, clause, spc, flags, false);
1040 break;
1045 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1046 dump_generic_node. */
1048 void
1049 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
1051 if (clause == NULL)
1052 return;
1054 pp_space (pp);
1055 while (1)
1057 dump_omp_clause (pp, clause, spc, flags);
1058 clause = OMP_CLAUSE_CHAIN (clause);
1059 if (clause == NULL)
1060 return;
1061 pp_space (pp);
1066 /* Dump location LOC to PP. */
1068 void
1069 dump_location (pretty_printer *pp, location_t loc)
1071 expanded_location xloc = expand_location (loc);
1073 pp_left_bracket (pp);
1074 if (xloc.file)
1076 pp_string (pp, xloc.file);
1077 pp_string (pp, ":");
1079 pp_decimal_int (pp, xloc.line);
1080 pp_colon (pp);
1081 pp_decimal_int (pp, xloc.column);
1082 pp_string (pp, "] ");
1086 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1087 dump_generic_node. */
1089 static void
1090 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
1092 tree t;
1094 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1096 if (flags & TDF_ADDRESS)
1097 pp_printf (pp, "[%p] ", (void *) block);
1099 if (BLOCK_ABSTRACT (block))
1100 pp_string (pp, "[abstract] ");
1102 if (TREE_ASM_WRITTEN (block))
1103 pp_string (pp, "[written] ");
1105 if (flags & TDF_SLIM)
1106 return;
1108 if (BLOCK_SOURCE_LOCATION (block))
1109 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1111 newline_and_indent (pp, spc + 2);
1113 if (BLOCK_SUPERCONTEXT (block))
1115 pp_string (pp, "SUPERCONTEXT: ");
1116 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1117 flags | TDF_SLIM, false);
1118 newline_and_indent (pp, spc + 2);
1121 if (BLOCK_SUBBLOCKS (block))
1123 pp_string (pp, "SUBBLOCKS: ");
1124 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1126 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1127 pp_space (pp);
1129 newline_and_indent (pp, spc + 2);
1132 if (BLOCK_CHAIN (block))
1134 pp_string (pp, "SIBLINGS: ");
1135 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1137 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1138 pp_space (pp);
1140 newline_and_indent (pp, spc + 2);
1143 if (BLOCK_VARS (block))
1145 pp_string (pp, "VARS: ");
1146 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1148 dump_generic_node (pp, t, 0, flags, false);
1149 pp_space (pp);
1151 newline_and_indent (pp, spc + 2);
1154 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1156 unsigned i;
1157 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1159 pp_string (pp, "NONLOCALIZED_VARS: ");
1160 FOR_EACH_VEC_ELT (*nlv, i, t)
1162 dump_generic_node (pp, t, 0, flags, false);
1163 pp_space (pp);
1165 newline_and_indent (pp, spc + 2);
1168 if (BLOCK_ABSTRACT_ORIGIN (block))
1170 pp_string (pp, "ABSTRACT_ORIGIN: ");
1171 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1172 flags | TDF_SLIM, false);
1173 newline_and_indent (pp, spc + 2);
1176 if (BLOCK_FRAGMENT_ORIGIN (block))
1178 pp_string (pp, "FRAGMENT_ORIGIN: ");
1179 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1180 flags | TDF_SLIM, false);
1181 newline_and_indent (pp, spc + 2);
1184 if (BLOCK_FRAGMENT_CHAIN (block))
1186 pp_string (pp, "FRAGMENT_CHAIN: ");
1187 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1189 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1190 pp_space (pp);
1192 newline_and_indent (pp, spc + 2);
1197 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1198 indent. FLAGS specifies details to show in the dump (see TDF_* in
1199 dumpfile.h). If IS_STMT is true, the object printed is considered
1200 to be a statement and it is terminated by ';' if appropriate. */
1203 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
1204 bool is_stmt)
1206 tree type;
1207 tree op0, op1;
1208 const char *str;
1209 bool is_expr;
1210 enum tree_code code;
1212 if (node == NULL_TREE)
1213 return spc;
1215 is_expr = EXPR_P (node);
1217 if (is_stmt && (flags & TDF_STMTADDR))
1218 pp_printf (pp, "<&%p> ", (void *)node);
1220 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1221 dump_location (pp, EXPR_LOCATION (node));
1223 code = TREE_CODE (node);
1224 switch (code)
1226 case ERROR_MARK:
1227 pp_string (pp, "<<< error >>>");
1228 break;
1230 case IDENTIFIER_NODE:
1231 pp_tree_identifier (pp, node);
1232 break;
1234 case TREE_LIST:
1235 while (node && node != error_mark_node)
1237 if (TREE_PURPOSE (node))
1239 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1240 pp_space (pp);
1242 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1243 node = TREE_CHAIN (node);
1244 if (node && TREE_CODE (node) == TREE_LIST)
1246 pp_comma (pp);
1247 pp_space (pp);
1250 break;
1252 case TREE_BINFO:
1253 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1254 break;
1256 case TREE_VEC:
1258 size_t i;
1259 if (TREE_VEC_LENGTH (node) > 0)
1261 size_t len = TREE_VEC_LENGTH (node);
1262 for (i = 0; i < len - 1; i++)
1264 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1265 false);
1266 pp_comma (pp);
1267 pp_space (pp);
1269 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1270 flags, false);
1273 break;
1275 case VOID_TYPE:
1276 case POINTER_BOUNDS_TYPE:
1277 case INTEGER_TYPE:
1278 case REAL_TYPE:
1279 case FIXED_POINT_TYPE:
1280 case COMPLEX_TYPE:
1281 case VECTOR_TYPE:
1282 case ENUMERAL_TYPE:
1283 case BOOLEAN_TYPE:
1285 unsigned int quals = TYPE_QUALS (node);
1286 enum tree_code_class tclass;
1288 if (quals & TYPE_QUAL_ATOMIC)
1289 pp_string (pp, "atomic ");
1290 if (quals & TYPE_QUAL_CONST)
1291 pp_string (pp, "const ");
1292 else if (quals & TYPE_QUAL_VOLATILE)
1293 pp_string (pp, "volatile ");
1294 else if (quals & TYPE_QUAL_RESTRICT)
1295 pp_string (pp, "restrict ");
1297 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1299 pp_string (pp, "<address-space-");
1300 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1301 pp_string (pp, "> ");
1304 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1306 if (tclass == tcc_declaration)
1308 if (DECL_NAME (node))
1309 dump_decl_name (pp, node, flags);
1310 else
1311 pp_string (pp, "<unnamed type decl>");
1313 else if (tclass == tcc_type)
1315 if (TYPE_NAME (node))
1317 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1318 pp_tree_identifier (pp, TYPE_NAME (node));
1319 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1320 && DECL_NAME (TYPE_NAME (node)))
1321 dump_decl_name (pp, TYPE_NAME (node), flags);
1322 else
1323 pp_string (pp, "<unnamed type>");
1325 else if (TREE_CODE (node) == VECTOR_TYPE)
1327 pp_string (pp, "vector");
1328 pp_left_paren (pp);
1329 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1330 pp_string (pp, ") ");
1331 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1333 else if (TREE_CODE (node) == INTEGER_TYPE)
1335 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1336 pp_string (pp, (TYPE_UNSIGNED (node)
1337 ? "unsigned char"
1338 : "signed char"));
1339 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1340 pp_string (pp, (TYPE_UNSIGNED (node)
1341 ? "unsigned short"
1342 : "signed short"));
1343 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1344 pp_string (pp, (TYPE_UNSIGNED (node)
1345 ? "unsigned int"
1346 : "signed int"));
1347 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1348 pp_string (pp, (TYPE_UNSIGNED (node)
1349 ? "unsigned long"
1350 : "signed long"));
1351 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1352 pp_string (pp, (TYPE_UNSIGNED (node)
1353 ? "unsigned long long"
1354 : "signed long long"));
1355 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1356 && pow2p_hwi (TYPE_PRECISION (node)))
1358 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1359 pp_decimal_int (pp, TYPE_PRECISION (node));
1360 pp_string (pp, "_t");
1362 else
1364 pp_string (pp, (TYPE_UNSIGNED (node)
1365 ? "<unnamed-unsigned:"
1366 : "<unnamed-signed:"));
1367 pp_decimal_int (pp, TYPE_PRECISION (node));
1368 pp_greater (pp);
1371 else if (TREE_CODE (node) == COMPLEX_TYPE)
1373 pp_string (pp, "__complex__ ");
1374 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1376 else if (TREE_CODE (node) == REAL_TYPE)
1378 pp_string (pp, "<float:");
1379 pp_decimal_int (pp, TYPE_PRECISION (node));
1380 pp_greater (pp);
1382 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1384 pp_string (pp, "<fixed-point-");
1385 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1386 pp_decimal_int (pp, TYPE_PRECISION (node));
1387 pp_greater (pp);
1389 else if (TREE_CODE (node) == VOID_TYPE)
1390 pp_string (pp, "void");
1391 else
1392 pp_string (pp, "<unnamed type>");
1394 break;
1397 case POINTER_TYPE:
1398 case REFERENCE_TYPE:
1399 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1401 if (TREE_TYPE (node) == NULL)
1403 pp_string (pp, str);
1404 pp_string (pp, "<null type>");
1406 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1408 tree fnode = TREE_TYPE (node);
1410 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1411 pp_space (pp);
1412 pp_left_paren (pp);
1413 pp_string (pp, str);
1414 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1415 dump_decl_name (pp, TYPE_NAME (node), flags);
1416 else if (flags & TDF_NOUID)
1417 pp_printf (pp, "<Txxxx>");
1418 else
1419 pp_printf (pp, "<T%x>", TYPE_UID (node));
1421 pp_right_paren (pp);
1422 dump_function_declaration (pp, fnode, spc, flags);
1424 else
1426 unsigned int quals = TYPE_QUALS (node);
1428 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1429 pp_space (pp);
1430 pp_string (pp, str);
1432 if (quals & TYPE_QUAL_CONST)
1433 pp_string (pp, " const");
1434 if (quals & TYPE_QUAL_VOLATILE)
1435 pp_string (pp, " volatile");
1436 if (quals & TYPE_QUAL_RESTRICT)
1437 pp_string (pp, " restrict");
1439 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1441 pp_string (pp, " <address-space-");
1442 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1443 pp_greater (pp);
1446 if (TYPE_REF_CAN_ALIAS_ALL (node))
1447 pp_string (pp, " {ref-all}");
1449 break;
1451 case OFFSET_TYPE:
1452 NIY;
1453 break;
1455 case MEM_REF:
1457 if (integer_zerop (TREE_OPERAND (node, 1))
1458 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1459 infer them and MEM_ATTR caching will share MEM_REFs
1460 with differently-typed op0s. */
1461 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1462 /* Released SSA_NAMES have no TREE_TYPE. */
1463 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1464 /* Same pointer types, but ignoring POINTER_TYPE vs.
1465 REFERENCE_TYPE. */
1466 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1467 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1468 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1469 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1470 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1471 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1472 /* Same value types ignoring qualifiers. */
1473 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1474 == TYPE_MAIN_VARIANT
1475 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1476 && (!(flags & TDF_ALIAS)
1477 || MR_DEPENDENCE_CLIQUE (node) == 0))
1479 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1481 pp_star (pp);
1482 dump_generic_node (pp, TREE_OPERAND (node, 0),
1483 spc, flags, false);
1485 else
1486 dump_generic_node (pp,
1487 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1488 spc, flags, false);
1490 else
1492 tree ptype;
1494 pp_string (pp, "MEM[");
1495 pp_left_paren (pp);
1496 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1497 dump_generic_node (pp, ptype,
1498 spc, flags | TDF_SLIM, false);
1499 pp_right_paren (pp);
1500 dump_generic_node (pp, TREE_OPERAND (node, 0),
1501 spc, flags, false);
1502 if (!integer_zerop (TREE_OPERAND (node, 1)))
1504 pp_string (pp, " + ");
1505 dump_generic_node (pp, TREE_OPERAND (node, 1),
1506 spc, flags, false);
1508 if ((flags & TDF_ALIAS)
1509 && MR_DEPENDENCE_CLIQUE (node) != 0)
1511 pp_string (pp, " clique ");
1512 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1513 pp_string (pp, " base ");
1514 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1516 pp_right_bracket (pp);
1518 break;
1521 case TARGET_MEM_REF:
1523 const char *sep = "";
1524 tree tmp;
1526 pp_string (pp, "MEM[");
1528 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1530 pp_string (pp, sep);
1531 sep = ", ";
1532 pp_string (pp, "symbol: ");
1533 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1534 spc, flags, false);
1536 else
1538 pp_string (pp, sep);
1539 sep = ", ";
1540 pp_string (pp, "base: ");
1541 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1543 tmp = TMR_INDEX2 (node);
1544 if (tmp)
1546 pp_string (pp, sep);
1547 sep = ", ";
1548 pp_string (pp, "base: ");
1549 dump_generic_node (pp, tmp, spc, flags, false);
1551 tmp = TMR_INDEX (node);
1552 if (tmp)
1554 pp_string (pp, sep);
1555 sep = ", ";
1556 pp_string (pp, "index: ");
1557 dump_generic_node (pp, tmp, spc, flags, false);
1559 tmp = TMR_STEP (node);
1560 if (tmp)
1562 pp_string (pp, sep);
1563 sep = ", ";
1564 pp_string (pp, "step: ");
1565 dump_generic_node (pp, tmp, spc, flags, false);
1567 tmp = TMR_OFFSET (node);
1568 if (tmp)
1570 pp_string (pp, sep);
1571 sep = ", ";
1572 pp_string (pp, "offset: ");
1573 dump_generic_node (pp, tmp, spc, flags, false);
1575 pp_right_bracket (pp);
1577 break;
1579 case ARRAY_TYPE:
1581 tree tmp;
1583 /* Print the innermost component type. */
1584 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1585 tmp = TREE_TYPE (tmp))
1587 dump_generic_node (pp, tmp, spc, flags, false);
1589 /* Print the dimensions. */
1590 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1591 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1592 break;
1595 case RECORD_TYPE:
1596 case UNION_TYPE:
1597 case QUAL_UNION_TYPE:
1599 unsigned int quals = TYPE_QUALS (node);
1601 if (quals & TYPE_QUAL_ATOMIC)
1602 pp_string (pp, "atomic ");
1603 if (quals & TYPE_QUAL_CONST)
1604 pp_string (pp, "const ");
1605 if (quals & TYPE_QUAL_VOLATILE)
1606 pp_string (pp, "volatile ");
1608 /* Print the name of the structure. */
1609 if (TREE_CODE (node) == RECORD_TYPE)
1610 pp_string (pp, "struct ");
1611 else if (TREE_CODE (node) == UNION_TYPE)
1612 pp_string (pp, "union ");
1614 if (TYPE_NAME (node))
1615 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1616 else if (!(flags & TDF_SLIM))
1617 /* FIXME: If we eliminate the 'else' above and attempt
1618 to show the fields for named types, we may get stuck
1619 following a cycle of pointers to structs. The alleged
1620 self-reference check in print_struct_decl will not detect
1621 cycles involving more than one pointer or struct type. */
1622 print_struct_decl (pp, node, spc, flags);
1623 break;
1626 case LANG_TYPE:
1627 NIY;
1628 break;
1630 case INTEGER_CST:
1631 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1633 /* In the case of a pointer, one may want to divide by the
1634 size of the pointed-to type. Unfortunately, this not
1635 straightforward. The C front-end maps expressions
1637 (int *) 5
1638 int *p; (p + 5)
1640 in such a way that the two INTEGER_CST nodes for "5" have
1641 different values but identical types. In the latter
1642 case, the 5 is multiplied by sizeof (int) in c-common.c
1643 (pointer_int_sum) to convert it to a byte address, and
1644 yet the type of the node is left unchanged. Argh. What
1645 is consistent though is that the number value corresponds
1646 to bytes (UNITS) offset.
1648 NB: Neither of the following divisors can be trivially
1649 used to recover the original literal:
1651 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1652 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1653 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1654 pp_string (pp, "B"); /* pseudo-unit */
1656 else if (tree_fits_shwi_p (node))
1657 pp_wide_integer (pp, tree_to_shwi (node));
1658 else if (tree_fits_uhwi_p (node))
1659 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1660 else
1662 wide_int val = node;
1664 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1666 pp_minus (pp);
1667 val = -val;
1669 print_hex (val, pp_buffer (pp)->digit_buffer);
1670 pp_string (pp, pp_buffer (pp)->digit_buffer);
1672 if (TREE_OVERFLOW (node))
1673 pp_string (pp, "(OVF)");
1674 break;
1676 case REAL_CST:
1677 /* Code copied from print_node. */
1679 REAL_VALUE_TYPE d;
1680 if (TREE_OVERFLOW (node))
1681 pp_string (pp, " overflow");
1683 d = TREE_REAL_CST (node);
1684 if (REAL_VALUE_ISINF (d))
1685 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1686 else if (REAL_VALUE_ISNAN (d))
1687 pp_string (pp, " Nan");
1688 else
1690 char string[100];
1691 real_to_decimal (string, &d, sizeof (string), 0, 1);
1692 pp_string (pp, string);
1694 break;
1697 case FIXED_CST:
1699 char string[100];
1700 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1701 pp_string (pp, string);
1702 break;
1705 case COMPLEX_CST:
1706 pp_string (pp, "__complex__ (");
1707 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1708 pp_string (pp, ", ");
1709 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1710 pp_right_paren (pp);
1711 break;
1713 case STRING_CST:
1714 pp_string (pp, "\"");
1715 pretty_print_string (pp, TREE_STRING_POINTER (node));
1716 pp_string (pp, "\"");
1717 break;
1719 case VECTOR_CST:
1721 unsigned i;
1722 pp_string (pp, "{ ");
1723 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1725 if (i != 0)
1726 pp_string (pp, ", ");
1727 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1728 spc, flags, false);
1730 pp_string (pp, " }");
1732 break;
1734 case FUNCTION_TYPE:
1735 case METHOD_TYPE:
1736 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1737 pp_space (pp);
1738 if (TREE_CODE (node) == METHOD_TYPE)
1740 if (TYPE_METHOD_BASETYPE (node))
1741 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1742 flags);
1743 else
1744 pp_string (pp, "<null method basetype>");
1745 pp_colon_colon (pp);
1747 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1748 dump_decl_name (pp, TYPE_NAME (node), flags);
1749 else if (flags & TDF_NOUID)
1750 pp_printf (pp, "<Txxxx>");
1751 else
1752 pp_printf (pp, "<T%x>", TYPE_UID (node));
1753 dump_function_declaration (pp, node, spc, flags);
1754 break;
1756 case FUNCTION_DECL:
1757 case CONST_DECL:
1758 dump_decl_name (pp, node, flags);
1759 break;
1761 case LABEL_DECL:
1762 if (DECL_NAME (node))
1763 dump_decl_name (pp, node, flags);
1764 else if (LABEL_DECL_UID (node) != -1)
1765 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1766 else
1768 if (flags & TDF_NOUID)
1769 pp_string (pp, "<D.xxxx>");
1770 else
1771 pp_printf (pp, "<D.%u>", DECL_UID (node));
1773 break;
1775 case TYPE_DECL:
1776 if (DECL_IS_BUILTIN (node))
1778 /* Don't print the declaration of built-in types. */
1779 break;
1781 if (DECL_NAME (node))
1782 dump_decl_name (pp, node, flags);
1783 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1785 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1786 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1787 && TYPE_METHODS (TREE_TYPE (node)))
1789 /* The type is a c++ class: all structures have at least
1790 4 methods. */
1791 pp_string (pp, "class ");
1792 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1794 else
1796 pp_string (pp,
1797 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1798 ? "union" : "struct "));
1799 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1802 else
1803 pp_string (pp, "<anon>");
1804 break;
1806 case VAR_DECL:
1807 case PARM_DECL:
1808 case FIELD_DECL:
1809 case DEBUG_EXPR_DECL:
1810 case NAMESPACE_DECL:
1811 case NAMELIST_DECL:
1812 dump_decl_name (pp, node, flags);
1813 break;
1815 case RESULT_DECL:
1816 pp_string (pp, "<retval>");
1817 break;
1819 case COMPONENT_REF:
1820 op0 = TREE_OPERAND (node, 0);
1821 str = ".";
1822 if (op0
1823 && (TREE_CODE (op0) == INDIRECT_REF
1824 || (TREE_CODE (op0) == MEM_REF
1825 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1826 && integer_zerop (TREE_OPERAND (op0, 1))
1827 /* Dump the types of INTEGER_CSTs explicitly, for we
1828 can't infer them and MEM_ATTR caching will share
1829 MEM_REFs with differently-typed op0s. */
1830 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1831 /* Released SSA_NAMES have no TREE_TYPE. */
1832 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1833 /* Same pointer types, but ignoring POINTER_TYPE vs.
1834 REFERENCE_TYPE. */
1835 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1836 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1837 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1838 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1839 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1840 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1841 /* Same value types ignoring qualifiers. */
1842 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1843 == TYPE_MAIN_VARIANT
1844 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1845 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1847 op0 = TREE_OPERAND (op0, 0);
1848 str = "->";
1850 if (op_prio (op0) < op_prio (node))
1851 pp_left_paren (pp);
1852 dump_generic_node (pp, op0, spc, flags, false);
1853 if (op_prio (op0) < op_prio (node))
1854 pp_right_paren (pp);
1855 pp_string (pp, str);
1856 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1857 op0 = component_ref_field_offset (node);
1858 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1860 pp_string (pp, "{off: ");
1861 dump_generic_node (pp, op0, spc, flags, false);
1862 pp_right_brace (pp);
1864 break;
1866 case BIT_FIELD_REF:
1867 pp_string (pp, "BIT_FIELD_REF <");
1868 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1869 pp_string (pp, ", ");
1870 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1871 pp_string (pp, ", ");
1872 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1873 pp_greater (pp);
1874 break;
1876 case BIT_INSERT_EXPR:
1877 pp_string (pp, "BIT_INSERT_EXPR <");
1878 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1879 pp_string (pp, ", ");
1880 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1881 pp_string (pp, ", ");
1882 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1883 pp_string (pp, " (");
1884 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1885 pp_decimal_int (pp,
1886 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1887 else
1888 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1889 spc, flags, false);
1890 pp_string (pp, " bits)>");
1891 break;
1893 case ARRAY_REF:
1894 case ARRAY_RANGE_REF:
1895 op0 = TREE_OPERAND (node, 0);
1896 if (op_prio (op0) < op_prio (node))
1897 pp_left_paren (pp);
1898 dump_generic_node (pp, op0, spc, flags, false);
1899 if (op_prio (op0) < op_prio (node))
1900 pp_right_paren (pp);
1901 pp_left_bracket (pp);
1902 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1903 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1904 pp_string (pp, " ...");
1905 pp_right_bracket (pp);
1907 op0 = array_ref_low_bound (node);
1908 op1 = array_ref_element_size (node);
1910 if (!integer_zerop (op0)
1911 || TREE_OPERAND (node, 2)
1912 || TREE_OPERAND (node, 3))
1914 pp_string (pp, "{lb: ");
1915 dump_generic_node (pp, op0, spc, flags, false);
1916 pp_string (pp, " sz: ");
1917 dump_generic_node (pp, op1, spc, flags, false);
1918 pp_right_brace (pp);
1920 break;
1922 case CONSTRUCTOR:
1924 unsigned HOST_WIDE_INT ix;
1925 tree field, val;
1926 bool is_struct_init = false;
1927 bool is_array_init = false;
1928 widest_int curidx;
1929 pp_left_brace (pp);
1930 if (TREE_CLOBBER_P (node))
1931 pp_string (pp, "CLOBBER");
1932 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1933 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1934 is_struct_init = true;
1935 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1936 && TYPE_DOMAIN (TREE_TYPE (node))
1937 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1938 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1939 == INTEGER_CST)
1941 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1942 is_array_init = true;
1943 curidx = wi::to_widest (minv);
1945 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1947 if (field)
1949 if (is_struct_init)
1951 pp_dot (pp);
1952 dump_generic_node (pp, field, spc, flags, false);
1953 pp_equal (pp);
1955 else if (is_array_init
1956 && (TREE_CODE (field) != INTEGER_CST
1957 || curidx != wi::to_widest (field)))
1959 pp_left_bracket (pp);
1960 if (TREE_CODE (field) == RANGE_EXPR)
1962 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1963 flags, false);
1964 pp_string (pp, " ... ");
1965 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1966 flags, false);
1967 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1968 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1970 else
1971 dump_generic_node (pp, field, spc, flags, false);
1972 if (TREE_CODE (field) == INTEGER_CST)
1973 curidx = wi::to_widest (field);
1974 pp_string (pp, "]=");
1977 if (is_array_init)
1978 curidx += 1;
1979 if (val && TREE_CODE (val) == ADDR_EXPR)
1980 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1981 val = TREE_OPERAND (val, 0);
1982 if (val && TREE_CODE (val) == FUNCTION_DECL)
1983 dump_decl_name (pp, val, flags);
1984 else
1985 dump_generic_node (pp, val, spc, flags, false);
1986 if (ix != CONSTRUCTOR_NELTS (node) - 1)
1988 pp_comma (pp);
1989 pp_space (pp);
1992 pp_right_brace (pp);
1994 break;
1996 case COMPOUND_EXPR:
1998 tree *tp;
1999 if (flags & TDF_SLIM)
2001 pp_string (pp, "<COMPOUND_EXPR>");
2002 break;
2005 dump_generic_node (pp, TREE_OPERAND (node, 0),
2006 spc, flags, !(flags & TDF_SLIM));
2007 if (flags & TDF_SLIM)
2008 newline_and_indent (pp, spc);
2009 else
2011 pp_comma (pp);
2012 pp_space (pp);
2015 for (tp = &TREE_OPERAND (node, 1);
2016 TREE_CODE (*tp) == COMPOUND_EXPR;
2017 tp = &TREE_OPERAND (*tp, 1))
2019 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2020 spc, flags, !(flags & TDF_SLIM));
2021 if (flags & TDF_SLIM)
2022 newline_and_indent (pp, spc);
2023 else
2025 pp_comma (pp);
2026 pp_space (pp);
2030 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2032 break;
2034 case STATEMENT_LIST:
2036 tree_stmt_iterator si;
2037 bool first = true;
2039 if (flags & TDF_SLIM)
2041 pp_string (pp, "<STATEMENT_LIST>");
2042 break;
2045 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2047 if (!first)
2048 newline_and_indent (pp, spc);
2049 else
2050 first = false;
2051 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2054 break;
2056 case MODIFY_EXPR:
2057 case INIT_EXPR:
2058 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2059 false);
2060 pp_space (pp);
2061 pp_equal (pp);
2062 pp_space (pp);
2063 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2064 false);
2065 break;
2067 case TARGET_EXPR:
2068 pp_string (pp, "TARGET_EXPR <");
2069 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2070 pp_comma (pp);
2071 pp_space (pp);
2072 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2073 pp_greater (pp);
2074 break;
2076 case DECL_EXPR:
2077 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2078 is_stmt = false;
2079 break;
2081 case COND_EXPR:
2082 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2084 pp_string (pp, "if (");
2085 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2086 pp_right_paren (pp);
2087 /* The lowered cond_exprs should always be printed in full. */
2088 if (COND_EXPR_THEN (node)
2089 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2090 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2091 && COND_EXPR_ELSE (node)
2092 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2093 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2095 pp_space (pp);
2096 dump_generic_node (pp, COND_EXPR_THEN (node),
2097 0, flags, true);
2098 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2100 pp_string (pp, " else ");
2101 dump_generic_node (pp, COND_EXPR_ELSE (node),
2102 0, flags, true);
2105 else if (!(flags & TDF_SLIM))
2107 /* Output COND_EXPR_THEN. */
2108 if (COND_EXPR_THEN (node))
2110 newline_and_indent (pp, spc+2);
2111 pp_left_brace (pp);
2112 newline_and_indent (pp, spc+4);
2113 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2114 flags, true);
2115 newline_and_indent (pp, spc+2);
2116 pp_right_brace (pp);
2119 /* Output COND_EXPR_ELSE. */
2120 if (COND_EXPR_ELSE (node)
2121 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2123 newline_and_indent (pp, spc);
2124 pp_string (pp, "else");
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_ELSE (node), spc+4,
2129 flags, true);
2130 newline_and_indent (pp, spc+2);
2131 pp_right_brace (pp);
2134 is_expr = false;
2136 else
2138 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2139 pp_space (pp);
2140 pp_question (pp);
2141 pp_space (pp);
2142 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2143 pp_space (pp);
2144 pp_colon (pp);
2145 pp_space (pp);
2146 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2148 break;
2150 case BIND_EXPR:
2151 pp_left_brace (pp);
2152 if (!(flags & TDF_SLIM))
2154 if (BIND_EXPR_VARS (node))
2156 pp_newline (pp);
2158 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2160 print_declaration (pp, op0, spc+2, flags);
2161 pp_newline (pp);
2165 newline_and_indent (pp, spc+2);
2166 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2167 newline_and_indent (pp, spc);
2168 pp_right_brace (pp);
2170 is_expr = false;
2171 break;
2173 case CALL_EXPR:
2174 if (CALL_EXPR_FN (node) != NULL_TREE)
2175 print_call_name (pp, CALL_EXPR_FN (node), flags);
2176 else
2177 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2179 /* Print parameters. */
2180 pp_space (pp);
2181 pp_left_paren (pp);
2183 tree arg;
2184 call_expr_arg_iterator iter;
2185 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2187 dump_generic_node (pp, arg, spc, flags, false);
2188 if (more_call_expr_args_p (&iter))
2190 pp_comma (pp);
2191 pp_space (pp);
2195 if (CALL_EXPR_VA_ARG_PACK (node))
2197 if (call_expr_nargs (node) > 0)
2199 pp_comma (pp);
2200 pp_space (pp);
2202 pp_string (pp, "__builtin_va_arg_pack ()");
2204 pp_right_paren (pp);
2206 op1 = CALL_EXPR_STATIC_CHAIN (node);
2207 if (op1)
2209 pp_string (pp, " [static-chain: ");
2210 dump_generic_node (pp, op1, spc, flags, false);
2211 pp_right_bracket (pp);
2214 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2215 pp_string (pp, " [return slot optimization]");
2216 if (CALL_EXPR_TAILCALL (node))
2217 pp_string (pp, " [tail call]");
2218 break;
2220 case WITH_CLEANUP_EXPR:
2221 NIY;
2222 break;
2224 case CLEANUP_POINT_EXPR:
2225 pp_string (pp, "<<cleanup_point ");
2226 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2227 pp_string (pp, ">>");
2228 break;
2230 case PLACEHOLDER_EXPR:
2231 pp_string (pp, "<PLACEHOLDER_EXPR ");
2232 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2233 pp_greater (pp);
2234 break;
2236 /* Binary arithmetic and logic expressions. */
2237 case WIDEN_SUM_EXPR:
2238 case WIDEN_MULT_EXPR:
2239 case MULT_EXPR:
2240 case MULT_HIGHPART_EXPR:
2241 case PLUS_EXPR:
2242 case POINTER_PLUS_EXPR:
2243 case MINUS_EXPR:
2244 case TRUNC_DIV_EXPR:
2245 case CEIL_DIV_EXPR:
2246 case FLOOR_DIV_EXPR:
2247 case ROUND_DIV_EXPR:
2248 case TRUNC_MOD_EXPR:
2249 case CEIL_MOD_EXPR:
2250 case FLOOR_MOD_EXPR:
2251 case ROUND_MOD_EXPR:
2252 case RDIV_EXPR:
2253 case EXACT_DIV_EXPR:
2254 case LSHIFT_EXPR:
2255 case RSHIFT_EXPR:
2256 case LROTATE_EXPR:
2257 case RROTATE_EXPR:
2258 case WIDEN_LSHIFT_EXPR:
2259 case BIT_IOR_EXPR:
2260 case BIT_XOR_EXPR:
2261 case BIT_AND_EXPR:
2262 case TRUTH_ANDIF_EXPR:
2263 case TRUTH_ORIF_EXPR:
2264 case TRUTH_AND_EXPR:
2265 case TRUTH_OR_EXPR:
2266 case TRUTH_XOR_EXPR:
2267 case LT_EXPR:
2268 case LE_EXPR:
2269 case GT_EXPR:
2270 case GE_EXPR:
2271 case EQ_EXPR:
2272 case NE_EXPR:
2273 case UNLT_EXPR:
2274 case UNLE_EXPR:
2275 case UNGT_EXPR:
2276 case UNGE_EXPR:
2277 case UNEQ_EXPR:
2278 case LTGT_EXPR:
2279 case ORDERED_EXPR:
2280 case UNORDERED_EXPR:
2282 const char *op = op_symbol (node);
2283 op0 = TREE_OPERAND (node, 0);
2284 op1 = TREE_OPERAND (node, 1);
2286 /* When the operands are expressions with less priority,
2287 keep semantics of the tree representation. */
2288 if (op_prio (op0) <= op_prio (node))
2290 pp_left_paren (pp);
2291 dump_generic_node (pp, op0, spc, flags, false);
2292 pp_right_paren (pp);
2294 else
2295 dump_generic_node (pp, op0, spc, flags, false);
2297 pp_space (pp);
2298 pp_string (pp, op);
2299 pp_space (pp);
2301 /* When the operands are expressions with less priority,
2302 keep semantics of the tree representation. */
2303 if (op_prio (op1) <= op_prio (node))
2305 pp_left_paren (pp);
2306 dump_generic_node (pp, op1, spc, flags, false);
2307 pp_right_paren (pp);
2309 else
2310 dump_generic_node (pp, op1, spc, flags, false);
2312 break;
2314 /* Unary arithmetic and logic expressions. */
2315 case NEGATE_EXPR:
2316 case BIT_NOT_EXPR:
2317 case TRUTH_NOT_EXPR:
2318 case ADDR_EXPR:
2319 case PREDECREMENT_EXPR:
2320 case PREINCREMENT_EXPR:
2321 case INDIRECT_REF:
2322 if (TREE_CODE (node) == ADDR_EXPR
2323 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2324 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2325 ; /* Do not output '&' for strings and function pointers. */
2326 else
2327 pp_string (pp, op_symbol (node));
2329 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2331 pp_left_paren (pp);
2332 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2333 pp_right_paren (pp);
2335 else
2336 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2337 break;
2339 case POSTDECREMENT_EXPR:
2340 case POSTINCREMENT_EXPR:
2341 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2343 pp_left_paren (pp);
2344 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2345 pp_right_paren (pp);
2347 else
2348 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2349 pp_string (pp, op_symbol (node));
2350 break;
2352 case MIN_EXPR:
2353 pp_string (pp, "MIN_EXPR <");
2354 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2355 pp_string (pp, ", ");
2356 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2357 pp_greater (pp);
2358 break;
2360 case MAX_EXPR:
2361 pp_string (pp, "MAX_EXPR <");
2362 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2363 pp_string (pp, ", ");
2364 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2365 pp_greater (pp);
2366 break;
2368 case ABS_EXPR:
2369 pp_string (pp, "ABS_EXPR <");
2370 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2371 pp_greater (pp);
2372 break;
2374 case RANGE_EXPR:
2375 NIY;
2376 break;
2378 case ADDR_SPACE_CONVERT_EXPR:
2379 case FIXED_CONVERT_EXPR:
2380 case FIX_TRUNC_EXPR:
2381 case FLOAT_EXPR:
2382 CASE_CONVERT:
2383 type = TREE_TYPE (node);
2384 op0 = TREE_OPERAND (node, 0);
2385 if (type != TREE_TYPE (op0))
2387 pp_left_paren (pp);
2388 dump_generic_node (pp, type, spc, flags, false);
2389 pp_string (pp, ") ");
2391 if (op_prio (op0) < op_prio (node))
2392 pp_left_paren (pp);
2393 dump_generic_node (pp, op0, spc, flags, false);
2394 if (op_prio (op0) < op_prio (node))
2395 pp_right_paren (pp);
2396 break;
2398 case VIEW_CONVERT_EXPR:
2399 pp_string (pp, "VIEW_CONVERT_EXPR<");
2400 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2401 pp_string (pp, ">(");
2402 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2403 pp_right_paren (pp);
2404 break;
2406 case PAREN_EXPR:
2407 pp_string (pp, "((");
2408 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2409 pp_string (pp, "))");
2410 break;
2412 case NON_LVALUE_EXPR:
2413 pp_string (pp, "NON_LVALUE_EXPR <");
2414 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2415 pp_greater (pp);
2416 break;
2418 case SAVE_EXPR:
2419 pp_string (pp, "SAVE_EXPR <");
2420 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2421 pp_greater (pp);
2422 break;
2424 case COMPLEX_EXPR:
2425 pp_string (pp, "COMPLEX_EXPR <");
2426 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2427 pp_string (pp, ", ");
2428 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2429 pp_greater (pp);
2430 break;
2432 case CONJ_EXPR:
2433 pp_string (pp, "CONJ_EXPR <");
2434 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2435 pp_greater (pp);
2436 break;
2438 case REALPART_EXPR:
2439 pp_string (pp, "REALPART_EXPR <");
2440 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2441 pp_greater (pp);
2442 break;
2444 case IMAGPART_EXPR:
2445 pp_string (pp, "IMAGPART_EXPR <");
2446 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2447 pp_greater (pp);
2448 break;
2450 case VA_ARG_EXPR:
2451 pp_string (pp, "VA_ARG_EXPR <");
2452 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2453 pp_greater (pp);
2454 break;
2456 case TRY_FINALLY_EXPR:
2457 case TRY_CATCH_EXPR:
2458 pp_string (pp, "try");
2459 newline_and_indent (pp, spc+2);
2460 pp_left_brace (pp);
2461 newline_and_indent (pp, spc+4);
2462 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2463 newline_and_indent (pp, spc+2);
2464 pp_right_brace (pp);
2465 newline_and_indent (pp, spc);
2466 pp_string (pp,
2467 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2468 newline_and_indent (pp, spc+2);
2469 pp_left_brace (pp);
2470 newline_and_indent (pp, spc+4);
2471 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2472 newline_and_indent (pp, spc+2);
2473 pp_right_brace (pp);
2474 is_expr = false;
2475 break;
2477 case CATCH_EXPR:
2478 pp_string (pp, "catch (");
2479 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2480 pp_right_paren (pp);
2481 newline_and_indent (pp, spc+2);
2482 pp_left_brace (pp);
2483 newline_and_indent (pp, spc+4);
2484 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2485 newline_and_indent (pp, spc+2);
2486 pp_right_brace (pp);
2487 is_expr = false;
2488 break;
2490 case EH_FILTER_EXPR:
2491 pp_string (pp, "<<<eh_filter (");
2492 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2493 pp_string (pp, ")>>>");
2494 newline_and_indent (pp, spc+2);
2495 pp_left_brace (pp);
2496 newline_and_indent (pp, spc+4);
2497 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2498 newline_and_indent (pp, spc+2);
2499 pp_right_brace (pp);
2500 is_expr = false;
2501 break;
2503 case LABEL_EXPR:
2504 op0 = TREE_OPERAND (node, 0);
2505 /* If this is for break or continue, don't bother printing it. */
2506 if (DECL_NAME (op0))
2508 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2509 if (strcmp (name, "break") == 0
2510 || strcmp (name, "continue") == 0)
2511 break;
2513 dump_generic_node (pp, op0, spc, flags, false);
2514 pp_colon (pp);
2515 if (DECL_NONLOCAL (op0))
2516 pp_string (pp, " [non-local]");
2517 break;
2519 case LOOP_EXPR:
2520 pp_string (pp, "while (1)");
2521 if (!(flags & TDF_SLIM))
2523 newline_and_indent (pp, spc+2);
2524 pp_left_brace (pp);
2525 newline_and_indent (pp, spc+4);
2526 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2527 newline_and_indent (pp, spc+2);
2528 pp_right_brace (pp);
2530 is_expr = false;
2531 break;
2533 case PREDICT_EXPR:
2534 pp_string (pp, "// predicted ");
2535 if (PREDICT_EXPR_OUTCOME (node))
2536 pp_string (pp, "likely by ");
2537 else
2538 pp_string (pp, "unlikely by ");
2539 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2540 pp_string (pp, " predictor.");
2541 break;
2543 case ANNOTATE_EXPR:
2544 pp_string (pp, "ANNOTATE_EXPR <");
2545 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2546 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2548 case annot_expr_ivdep_kind:
2549 pp_string (pp, ", ivdep");
2550 break;
2551 case annot_expr_no_vector_kind:
2552 pp_string (pp, ", no-vector");
2553 break;
2554 case annot_expr_vector_kind:
2555 pp_string (pp, ", vector");
2556 break;
2557 default:
2558 gcc_unreachable ();
2560 pp_greater (pp);
2561 break;
2563 case RETURN_EXPR:
2564 pp_string (pp, "return");
2565 op0 = TREE_OPERAND (node, 0);
2566 if (op0)
2568 pp_space (pp);
2569 if (TREE_CODE (op0) == MODIFY_EXPR)
2570 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2571 spc, flags, false);
2572 else
2573 dump_generic_node (pp, op0, spc, flags, false);
2575 break;
2577 case EXIT_EXPR:
2578 pp_string (pp, "if (");
2579 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2580 pp_string (pp, ") break");
2581 break;
2583 case SWITCH_EXPR:
2584 pp_string (pp, "switch (");
2585 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2586 pp_right_paren (pp);
2587 if (!(flags & TDF_SLIM))
2589 newline_and_indent (pp, spc+2);
2590 pp_left_brace (pp);
2591 if (SWITCH_BODY (node))
2593 newline_and_indent (pp, spc+4);
2594 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2595 true);
2597 else
2599 tree vec = SWITCH_LABELS (node);
2600 size_t i, n = TREE_VEC_LENGTH (vec);
2601 for (i = 0; i < n; ++i)
2603 tree elt = TREE_VEC_ELT (vec, i);
2604 newline_and_indent (pp, spc+4);
2605 if (elt)
2607 dump_generic_node (pp, elt, spc+4, flags, false);
2608 pp_string (pp, " goto ");
2609 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2610 flags, true);
2611 pp_semicolon (pp);
2613 else
2614 pp_string (pp, "case ???: goto ???;");
2617 newline_and_indent (pp, spc+2);
2618 pp_right_brace (pp);
2620 is_expr = false;
2621 break;
2623 case GOTO_EXPR:
2624 op0 = GOTO_DESTINATION (node);
2625 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2627 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2628 if (strcmp (name, "break") == 0
2629 || strcmp (name, "continue") == 0)
2631 pp_string (pp, name);
2632 break;
2635 pp_string (pp, "goto ");
2636 dump_generic_node (pp, op0, spc, flags, false);
2637 break;
2639 case ASM_EXPR:
2640 pp_string (pp, "__asm__");
2641 if (ASM_VOLATILE_P (node))
2642 pp_string (pp, " __volatile__");
2643 pp_left_paren (pp);
2644 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2645 pp_colon (pp);
2646 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2647 pp_colon (pp);
2648 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2649 if (ASM_CLOBBERS (node))
2651 pp_colon (pp);
2652 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2654 pp_right_paren (pp);
2655 break;
2657 case CASE_LABEL_EXPR:
2658 if (CASE_LOW (node) && CASE_HIGH (node))
2660 pp_string (pp, "case ");
2661 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2662 pp_string (pp, " ... ");
2663 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2665 else if (CASE_LOW (node))
2667 pp_string (pp, "case ");
2668 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2670 else
2671 pp_string (pp, "default");
2672 pp_colon (pp);
2673 break;
2675 case OBJ_TYPE_REF:
2676 pp_string (pp, "OBJ_TYPE_REF(");
2677 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2678 pp_semicolon (pp);
2679 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2681 pp_string (pp, "(");
2682 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2683 pp_string (pp, ")");
2685 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2686 pp_arrow (pp);
2687 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2688 pp_right_paren (pp);
2689 break;
2691 case SSA_NAME:
2692 if (SSA_NAME_IDENTIFIER (node))
2694 if ((flags & TDF_NOUID)
2695 && SSA_NAME_VAR (node)
2696 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2697 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2698 else
2699 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2700 spc, flags, false);
2702 pp_underscore (pp);
2703 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2704 if (SSA_NAME_IS_DEFAULT_DEF (node))
2705 pp_string (pp, "(D)");
2706 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2707 pp_string (pp, "(ab)");
2708 break;
2710 case WITH_SIZE_EXPR:
2711 pp_string (pp, "WITH_SIZE_EXPR <");
2712 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2713 pp_string (pp, ", ");
2714 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2715 pp_greater (pp);
2716 break;
2718 case ASSERT_EXPR:
2719 pp_string (pp, "ASSERT_EXPR <");
2720 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2721 pp_string (pp, ", ");
2722 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2723 pp_greater (pp);
2724 break;
2726 case SCEV_KNOWN:
2727 pp_string (pp, "scev_known");
2728 break;
2730 case SCEV_NOT_KNOWN:
2731 pp_string (pp, "scev_not_known");
2732 break;
2734 case POLYNOMIAL_CHREC:
2735 pp_left_brace (pp);
2736 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2737 pp_string (pp, ", +, ");
2738 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2739 pp_string (pp, "}_");
2740 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2741 is_stmt = false;
2742 break;
2744 case REALIGN_LOAD_EXPR:
2745 pp_string (pp, "REALIGN_LOAD <");
2746 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2747 pp_string (pp, ", ");
2748 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2749 pp_string (pp, ", ");
2750 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2751 pp_greater (pp);
2752 break;
2754 case VEC_COND_EXPR:
2755 pp_string (pp, " VEC_COND_EXPR < ");
2756 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2757 pp_string (pp, " , ");
2758 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2759 pp_string (pp, " , ");
2760 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2761 pp_string (pp, " > ");
2762 break;
2764 case VEC_PERM_EXPR:
2765 pp_string (pp, " VEC_PERM_EXPR < ");
2766 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2767 pp_string (pp, " , ");
2768 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2769 pp_string (pp, " , ");
2770 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2771 pp_string (pp, " > ");
2772 break;
2774 case DOT_PROD_EXPR:
2775 pp_string (pp, " DOT_PROD_EXPR < ");
2776 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2777 pp_string (pp, ", ");
2778 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2779 pp_string (pp, ", ");
2780 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2781 pp_string (pp, " > ");
2782 break;
2784 case WIDEN_MULT_PLUS_EXPR:
2785 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2786 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2787 pp_string (pp, ", ");
2788 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2789 pp_string (pp, ", ");
2790 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2791 pp_string (pp, " > ");
2792 break;
2794 case WIDEN_MULT_MINUS_EXPR:
2795 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2796 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2797 pp_string (pp, ", ");
2798 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2799 pp_string (pp, ", ");
2800 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2801 pp_string (pp, " > ");
2802 break;
2804 case FMA_EXPR:
2805 pp_string (pp, " FMA_EXPR < ");
2806 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2807 pp_string (pp, ", ");
2808 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2809 pp_string (pp, ", ");
2810 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2811 pp_string (pp, " > ");
2812 break;
2814 case OACC_PARALLEL:
2815 pp_string (pp, "#pragma acc parallel");
2816 goto dump_omp_clauses_body;
2818 case OACC_KERNELS:
2819 pp_string (pp, "#pragma acc kernels");
2820 goto dump_omp_clauses_body;
2822 case OACC_DATA:
2823 pp_string (pp, "#pragma acc data");
2824 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2825 goto dump_omp_body;
2827 case OACC_HOST_DATA:
2828 pp_string (pp, "#pragma acc host_data");
2829 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2830 goto dump_omp_body;
2832 case OACC_DECLARE:
2833 pp_string (pp, "#pragma acc declare");
2834 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2835 break;
2837 case OACC_UPDATE:
2838 pp_string (pp, "#pragma acc update");
2839 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2840 break;
2842 case OACC_ENTER_DATA:
2843 pp_string (pp, "#pragma acc enter data");
2844 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2845 break;
2847 case OACC_EXIT_DATA:
2848 pp_string (pp, "#pragma acc exit data");
2849 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2850 break;
2852 case OACC_CACHE:
2853 pp_string (pp, "#pragma acc cache");
2854 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2855 break;
2857 case OMP_PARALLEL:
2858 pp_string (pp, "#pragma omp parallel");
2859 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2860 goto dump_omp_body;
2862 dump_omp_clauses_body:
2863 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2864 goto dump_omp_body;
2866 dump_omp_body:
2867 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2869 newline_and_indent (pp, spc + 2);
2870 pp_left_brace (pp);
2871 newline_and_indent (pp, spc + 4);
2872 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2873 newline_and_indent (pp, spc + 2);
2874 pp_right_brace (pp);
2876 is_expr = false;
2877 break;
2879 case OMP_TASK:
2880 pp_string (pp, "#pragma omp task");
2881 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2882 goto dump_omp_body;
2884 case OMP_FOR:
2885 pp_string (pp, "#pragma omp for");
2886 goto dump_omp_loop;
2888 case OMP_SIMD:
2889 pp_string (pp, "#pragma omp simd");
2890 goto dump_omp_loop;
2892 case CILK_SIMD:
2893 pp_string (pp, "#pragma simd");
2894 goto dump_omp_loop;
2896 case CILK_FOR:
2897 /* This label points one line after dumping the clauses.
2898 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2899 parameters are printed out. */
2900 goto dump_omp_loop_cilk_for;
2902 case OMP_DISTRIBUTE:
2903 pp_string (pp, "#pragma omp distribute");
2904 goto dump_omp_loop;
2906 case OMP_TASKLOOP:
2907 pp_string (pp, "#pragma omp taskloop");
2908 goto dump_omp_loop;
2910 case OACC_LOOP:
2911 pp_string (pp, "#pragma acc loop");
2912 goto dump_omp_loop;
2914 case OMP_TEAMS:
2915 pp_string (pp, "#pragma omp teams");
2916 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2917 goto dump_omp_body;
2919 case OMP_TARGET_DATA:
2920 pp_string (pp, "#pragma omp target data");
2921 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2922 goto dump_omp_body;
2924 case OMP_TARGET_ENTER_DATA:
2925 pp_string (pp, "#pragma omp target enter data");
2926 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2927 is_expr = false;
2928 break;
2930 case OMP_TARGET_EXIT_DATA:
2931 pp_string (pp, "#pragma omp target exit data");
2932 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2933 is_expr = false;
2934 break;
2936 case OMP_TARGET:
2937 pp_string (pp, "#pragma omp target");
2938 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2939 goto dump_omp_body;
2941 case OMP_TARGET_UPDATE:
2942 pp_string (pp, "#pragma omp target update");
2943 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2944 is_expr = false;
2945 break;
2947 dump_omp_loop:
2948 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2950 dump_omp_loop_cilk_for:
2951 if (!(flags & TDF_SLIM))
2953 int i;
2955 if (OMP_FOR_PRE_BODY (node))
2957 if (TREE_CODE (node) == CILK_FOR)
2958 pp_string (pp, " ");
2959 else
2960 newline_and_indent (pp, spc + 2);
2961 pp_left_brace (pp);
2962 spc += 4;
2963 newline_and_indent (pp, spc);
2964 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2965 spc, flags, false);
2967 if (OMP_FOR_INIT (node))
2969 spc -= 2;
2970 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2972 spc += 2;
2973 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2974 newline_and_indent (pp, spc);
2975 if (TREE_CODE (node) == CILK_FOR)
2976 pp_string (pp, "_Cilk_for (");
2977 else
2978 pp_string (pp, "for (");
2979 dump_generic_node (pp,
2980 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2981 spc, flags, false);
2982 pp_string (pp, "; ");
2983 dump_generic_node (pp,
2984 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2985 spc, flags, false);
2986 pp_string (pp, "; ");
2987 dump_generic_node (pp,
2988 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2989 spc, flags, false);
2990 pp_right_paren (pp);
2992 if (TREE_CODE (node) == CILK_FOR)
2993 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2995 if (OMP_FOR_BODY (node))
2997 newline_and_indent (pp, spc + 2);
2998 pp_left_brace (pp);
2999 newline_and_indent (pp, spc + 4);
3000 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3001 false);
3002 newline_and_indent (pp, spc + 2);
3003 pp_right_brace (pp);
3005 if (OMP_FOR_INIT (node))
3006 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3007 if (OMP_FOR_PRE_BODY (node))
3009 spc -= 4;
3010 newline_and_indent (pp, spc + 2);
3011 pp_right_brace (pp);
3014 is_expr = false;
3015 break;
3017 case OMP_SECTIONS:
3018 pp_string (pp, "#pragma omp sections");
3019 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3020 goto dump_omp_body;
3022 case OMP_SECTION:
3023 pp_string (pp, "#pragma omp section");
3024 goto dump_omp_body;
3026 case OMP_MASTER:
3027 pp_string (pp, "#pragma omp master");
3028 goto dump_omp_body;
3030 case OMP_TASKGROUP:
3031 pp_string (pp, "#pragma omp taskgroup");
3032 goto dump_omp_body;
3034 case OMP_ORDERED:
3035 pp_string (pp, "#pragma omp ordered");
3036 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3037 goto dump_omp_body;
3039 case OMP_CRITICAL:
3040 pp_string (pp, "#pragma omp critical");
3041 if (OMP_CRITICAL_NAME (node))
3043 pp_space (pp);
3044 pp_left_paren (pp);
3045 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3046 flags, false);
3047 pp_right_paren (pp);
3049 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3050 goto dump_omp_body;
3052 case OMP_ATOMIC:
3053 pp_string (pp, "#pragma omp atomic");
3054 if (OMP_ATOMIC_SEQ_CST (node))
3055 pp_string (pp, " seq_cst");
3056 newline_and_indent (pp, spc + 2);
3057 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3058 pp_space (pp);
3059 pp_equal (pp);
3060 pp_space (pp);
3061 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3062 break;
3064 case OMP_ATOMIC_READ:
3065 pp_string (pp, "#pragma omp atomic read");
3066 if (OMP_ATOMIC_SEQ_CST (node))
3067 pp_string (pp, " seq_cst");
3068 newline_and_indent (pp, spc + 2);
3069 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3070 pp_space (pp);
3071 break;
3073 case OMP_ATOMIC_CAPTURE_OLD:
3074 case OMP_ATOMIC_CAPTURE_NEW:
3075 pp_string (pp, "#pragma omp atomic capture");
3076 if (OMP_ATOMIC_SEQ_CST (node))
3077 pp_string (pp, " seq_cst");
3078 newline_and_indent (pp, spc + 2);
3079 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3080 pp_space (pp);
3081 pp_equal (pp);
3082 pp_space (pp);
3083 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3084 break;
3086 case OMP_SINGLE:
3087 pp_string (pp, "#pragma omp single");
3088 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3089 goto dump_omp_body;
3091 case OMP_CLAUSE:
3092 dump_omp_clause (pp, node, spc, flags);
3093 is_expr = false;
3094 break;
3096 case TRANSACTION_EXPR:
3097 if (TRANSACTION_EXPR_OUTER (node))
3098 pp_string (pp, "__transaction_atomic [[outer]]");
3099 else if (TRANSACTION_EXPR_RELAXED (node))
3100 pp_string (pp, "__transaction_relaxed");
3101 else
3102 pp_string (pp, "__transaction_atomic");
3103 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3105 newline_and_indent (pp, spc);
3106 pp_left_brace (pp);
3107 newline_and_indent (pp, spc + 2);
3108 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3109 spc + 2, flags, false);
3110 newline_and_indent (pp, spc);
3111 pp_right_brace (pp);
3113 is_expr = false;
3114 break;
3116 case REDUC_MAX_EXPR:
3117 pp_string (pp, " REDUC_MAX_EXPR < ");
3118 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3119 pp_string (pp, " > ");
3120 break;
3122 case REDUC_MIN_EXPR:
3123 pp_string (pp, " REDUC_MIN_EXPR < ");
3124 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3125 pp_string (pp, " > ");
3126 break;
3128 case REDUC_PLUS_EXPR:
3129 pp_string (pp, " REDUC_PLUS_EXPR < ");
3130 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3131 pp_string (pp, " > ");
3132 break;
3134 case VEC_WIDEN_MULT_HI_EXPR:
3135 case VEC_WIDEN_MULT_LO_EXPR:
3136 case VEC_WIDEN_MULT_EVEN_EXPR:
3137 case VEC_WIDEN_MULT_ODD_EXPR:
3138 case VEC_WIDEN_LSHIFT_HI_EXPR:
3139 case VEC_WIDEN_LSHIFT_LO_EXPR:
3140 pp_space (pp);
3141 for (str = get_tree_code_name (code); *str; str++)
3142 pp_character (pp, TOUPPER (*str));
3143 pp_string (pp, " < ");
3144 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3145 pp_string (pp, ", ");
3146 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3147 pp_string (pp, " > ");
3148 break;
3150 case VEC_UNPACK_HI_EXPR:
3151 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3152 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3153 pp_string (pp, " > ");
3154 break;
3156 case VEC_UNPACK_LO_EXPR:
3157 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3158 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3159 pp_string (pp, " > ");
3160 break;
3162 case VEC_UNPACK_FLOAT_HI_EXPR:
3163 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3165 pp_string (pp, " > ");
3166 break;
3168 case VEC_UNPACK_FLOAT_LO_EXPR:
3169 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3170 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3171 pp_string (pp, " > ");
3172 break;
3174 case VEC_PACK_TRUNC_EXPR:
3175 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
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_PACK_SAT_EXPR:
3183 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3184 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3185 pp_string (pp, ", ");
3186 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3187 pp_string (pp, " > ");
3188 break;
3190 case VEC_PACK_FIX_TRUNC_EXPR:
3191 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3192 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3193 pp_string (pp, ", ");
3194 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3195 pp_string (pp, " > ");
3196 break;
3198 case BLOCK:
3199 dump_block_node (pp, node, spc, flags);
3200 break;
3202 case CILK_SPAWN_STMT:
3203 pp_string (pp, "_Cilk_spawn ");
3204 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3205 break;
3207 case CILK_SYNC_STMT:
3208 pp_string (pp, "_Cilk_sync");
3209 break;
3211 default:
3212 NIY;
3215 if (is_stmt && is_expr)
3216 pp_semicolon (pp);
3218 return spc;
3221 /* Print the declaration of a variable. */
3223 void
3224 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
3226 INDENT (spc);
3228 if (TREE_CODE(t) == NAMELIST_DECL)
3230 pp_string(pp, "namelist ");
3231 dump_decl_name (pp, t, flags);
3232 pp_semicolon (pp);
3233 return;
3236 if (TREE_CODE (t) == TYPE_DECL)
3237 pp_string (pp, "typedef ");
3239 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3240 pp_string (pp, "register ");
3242 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3243 pp_string (pp, "extern ");
3244 else if (TREE_STATIC (t))
3245 pp_string (pp, "static ");
3247 /* Print the type and name. */
3248 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3250 tree tmp;
3252 /* Print array's type. */
3253 tmp = TREE_TYPE (t);
3254 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3255 tmp = TREE_TYPE (tmp);
3256 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3258 /* Print variable's name. */
3259 pp_space (pp);
3260 dump_generic_node (pp, t, spc, flags, false);
3262 /* Print the dimensions. */
3263 tmp = TREE_TYPE (t);
3264 while (TREE_CODE (tmp) == ARRAY_TYPE)
3266 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3267 tmp = TREE_TYPE (tmp);
3270 else if (TREE_CODE (t) == FUNCTION_DECL)
3272 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3273 pp_space (pp);
3274 dump_decl_name (pp, t, flags);
3275 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3277 else
3279 /* Print type declaration. */
3280 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3282 /* Print variable's name. */
3283 pp_space (pp);
3284 dump_generic_node (pp, t, spc, flags, false);
3287 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3289 pp_string (pp, " __asm__ ");
3290 pp_left_paren (pp);
3291 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3292 pp_right_paren (pp);
3295 /* The initial value of a function serves to determine whether the function
3296 is declared or defined. So the following does not apply to function
3297 nodes. */
3298 if (TREE_CODE (t) != FUNCTION_DECL)
3300 /* Print the initial value. */
3301 if (DECL_INITIAL (t))
3303 pp_space (pp);
3304 pp_equal (pp);
3305 pp_space (pp);
3306 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3310 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3312 pp_string (pp, " [value-expr: ");
3313 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3314 pp_right_bracket (pp);
3317 pp_semicolon (pp);
3321 /* Prints a structure: name, fields, and methods.
3322 FIXME: Still incomplete. */
3324 static void
3325 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3327 /* Print the name of the structure. */
3328 if (TYPE_NAME (node))
3330 INDENT (spc);
3331 if (TREE_CODE (node) == RECORD_TYPE)
3332 pp_string (pp, "struct ");
3333 else if ((TREE_CODE (node) == UNION_TYPE
3334 || TREE_CODE (node) == QUAL_UNION_TYPE))
3335 pp_string (pp, "union ");
3337 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3340 /* Print the contents of the structure. */
3341 pp_newline (pp);
3342 INDENT (spc);
3343 pp_left_brace (pp);
3344 pp_newline (pp);
3346 /* Print the fields of the structure. */
3348 tree tmp;
3349 tmp = TYPE_FIELDS (node);
3350 while (tmp)
3352 /* Avoid to print recursively the structure. */
3353 /* FIXME : Not implemented correctly...,
3354 what about the case when we have a cycle in the contain graph? ...
3355 Maybe this could be solved by looking at the scope in which the
3356 structure was declared. */
3357 if (TREE_TYPE (tmp) != node
3358 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3359 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3361 print_declaration (pp, tmp, spc+2, flags);
3362 pp_newline (pp);
3364 tmp = DECL_CHAIN (tmp);
3367 INDENT (spc);
3368 pp_right_brace (pp);
3371 /* Return the priority of the operator CODE.
3373 From lowest to highest precedence with either left-to-right (L-R)
3374 or right-to-left (R-L) associativity]:
3376 1 [L-R] ,
3377 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3378 3 [R-L] ?:
3379 4 [L-R] ||
3380 5 [L-R] &&
3381 6 [L-R] |
3382 7 [L-R] ^
3383 8 [L-R] &
3384 9 [L-R] == !=
3385 10 [L-R] < <= > >=
3386 11 [L-R] << >>
3387 12 [L-R] + -
3388 13 [L-R] * / %
3389 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3390 15 [L-R] fn() [] -> .
3392 unary +, - and * have higher precedence than the corresponding binary
3393 operators. */
3396 op_code_prio (enum tree_code code)
3398 switch (code)
3400 case TREE_LIST:
3401 case COMPOUND_EXPR:
3402 case BIND_EXPR:
3403 return 1;
3405 case MODIFY_EXPR:
3406 case INIT_EXPR:
3407 return 2;
3409 case COND_EXPR:
3410 return 3;
3412 case TRUTH_OR_EXPR:
3413 case TRUTH_ORIF_EXPR:
3414 return 4;
3416 case TRUTH_AND_EXPR:
3417 case TRUTH_ANDIF_EXPR:
3418 return 5;
3420 case BIT_IOR_EXPR:
3421 return 6;
3423 case BIT_XOR_EXPR:
3424 case TRUTH_XOR_EXPR:
3425 return 7;
3427 case BIT_AND_EXPR:
3428 return 8;
3430 case EQ_EXPR:
3431 case NE_EXPR:
3432 return 9;
3434 case UNLT_EXPR:
3435 case UNLE_EXPR:
3436 case UNGT_EXPR:
3437 case UNGE_EXPR:
3438 case UNEQ_EXPR:
3439 case LTGT_EXPR:
3440 case ORDERED_EXPR:
3441 case UNORDERED_EXPR:
3442 case LT_EXPR:
3443 case LE_EXPR:
3444 case GT_EXPR:
3445 case GE_EXPR:
3446 return 10;
3448 case LSHIFT_EXPR:
3449 case RSHIFT_EXPR:
3450 case LROTATE_EXPR:
3451 case RROTATE_EXPR:
3452 case VEC_WIDEN_LSHIFT_HI_EXPR:
3453 case VEC_WIDEN_LSHIFT_LO_EXPR:
3454 case WIDEN_LSHIFT_EXPR:
3455 return 11;
3457 case WIDEN_SUM_EXPR:
3458 case PLUS_EXPR:
3459 case POINTER_PLUS_EXPR:
3460 case MINUS_EXPR:
3461 return 12;
3463 case VEC_WIDEN_MULT_HI_EXPR:
3464 case VEC_WIDEN_MULT_LO_EXPR:
3465 case WIDEN_MULT_EXPR:
3466 case DOT_PROD_EXPR:
3467 case WIDEN_MULT_PLUS_EXPR:
3468 case WIDEN_MULT_MINUS_EXPR:
3469 case MULT_EXPR:
3470 case MULT_HIGHPART_EXPR:
3471 case TRUNC_DIV_EXPR:
3472 case CEIL_DIV_EXPR:
3473 case FLOOR_DIV_EXPR:
3474 case ROUND_DIV_EXPR:
3475 case RDIV_EXPR:
3476 case EXACT_DIV_EXPR:
3477 case TRUNC_MOD_EXPR:
3478 case CEIL_MOD_EXPR:
3479 case FLOOR_MOD_EXPR:
3480 case ROUND_MOD_EXPR:
3481 case FMA_EXPR:
3482 return 13;
3484 case TRUTH_NOT_EXPR:
3485 case BIT_NOT_EXPR:
3486 case POSTINCREMENT_EXPR:
3487 case POSTDECREMENT_EXPR:
3488 case PREINCREMENT_EXPR:
3489 case PREDECREMENT_EXPR:
3490 case NEGATE_EXPR:
3491 case INDIRECT_REF:
3492 case ADDR_EXPR:
3493 case FLOAT_EXPR:
3494 CASE_CONVERT:
3495 case FIX_TRUNC_EXPR:
3496 case TARGET_EXPR:
3497 return 14;
3499 case CALL_EXPR:
3500 case ARRAY_REF:
3501 case ARRAY_RANGE_REF:
3502 case COMPONENT_REF:
3503 return 15;
3505 /* Special expressions. */
3506 case MIN_EXPR:
3507 case MAX_EXPR:
3508 case ABS_EXPR:
3509 case REALPART_EXPR:
3510 case IMAGPART_EXPR:
3511 case REDUC_MAX_EXPR:
3512 case REDUC_MIN_EXPR:
3513 case REDUC_PLUS_EXPR:
3514 case VEC_UNPACK_HI_EXPR:
3515 case VEC_UNPACK_LO_EXPR:
3516 case VEC_UNPACK_FLOAT_HI_EXPR:
3517 case VEC_UNPACK_FLOAT_LO_EXPR:
3518 case VEC_PACK_TRUNC_EXPR:
3519 case VEC_PACK_SAT_EXPR:
3520 return 16;
3522 default:
3523 /* Return an arbitrarily high precedence to avoid surrounding single
3524 VAR_DECLs in ()s. */
3525 return 9999;
3529 /* Return the priority of the operator OP. */
3532 op_prio (const_tree op)
3534 enum tree_code code;
3536 if (op == NULL)
3537 return 9999;
3539 code = TREE_CODE (op);
3540 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3541 return op_prio (TREE_OPERAND (op, 0));
3543 return op_code_prio (code);
3546 /* Return the symbol associated with operator CODE. */
3548 const char *
3549 op_symbol_code (enum tree_code code)
3551 switch (code)
3553 case MODIFY_EXPR:
3554 return "=";
3556 case TRUTH_OR_EXPR:
3557 case TRUTH_ORIF_EXPR:
3558 return "||";
3560 case TRUTH_AND_EXPR:
3561 case TRUTH_ANDIF_EXPR:
3562 return "&&";
3564 case BIT_IOR_EXPR:
3565 return "|";
3567 case TRUTH_XOR_EXPR:
3568 case BIT_XOR_EXPR:
3569 return "^";
3571 case ADDR_EXPR:
3572 case BIT_AND_EXPR:
3573 return "&";
3575 case ORDERED_EXPR:
3576 return "ord";
3577 case UNORDERED_EXPR:
3578 return "unord";
3580 case EQ_EXPR:
3581 return "==";
3582 case UNEQ_EXPR:
3583 return "u==";
3585 case NE_EXPR:
3586 return "!=";
3588 case LT_EXPR:
3589 return "<";
3590 case UNLT_EXPR:
3591 return "u<";
3593 case LE_EXPR:
3594 return "<=";
3595 case UNLE_EXPR:
3596 return "u<=";
3598 case GT_EXPR:
3599 return ">";
3600 case UNGT_EXPR:
3601 return "u>";
3603 case GE_EXPR:
3604 return ">=";
3605 case UNGE_EXPR:
3606 return "u>=";
3608 case LTGT_EXPR:
3609 return "<>";
3611 case LSHIFT_EXPR:
3612 return "<<";
3614 case RSHIFT_EXPR:
3615 return ">>";
3617 case LROTATE_EXPR:
3618 return "r<<";
3620 case RROTATE_EXPR:
3621 return "r>>";
3623 case WIDEN_LSHIFT_EXPR:
3624 return "w<<";
3626 case POINTER_PLUS_EXPR:
3627 return "+";
3629 case PLUS_EXPR:
3630 return "+";
3632 case REDUC_PLUS_EXPR:
3633 return "r+";
3635 case WIDEN_SUM_EXPR:
3636 return "w+";
3638 case WIDEN_MULT_EXPR:
3639 return "w*";
3641 case MULT_HIGHPART_EXPR:
3642 return "h*";
3644 case NEGATE_EXPR:
3645 case MINUS_EXPR:
3646 return "-";
3648 case BIT_NOT_EXPR:
3649 return "~";
3651 case TRUTH_NOT_EXPR:
3652 return "!";
3654 case MULT_EXPR:
3655 case INDIRECT_REF:
3656 return "*";
3658 case TRUNC_DIV_EXPR:
3659 case RDIV_EXPR:
3660 return "/";
3662 case CEIL_DIV_EXPR:
3663 return "/[cl]";
3665 case FLOOR_DIV_EXPR:
3666 return "/[fl]";
3668 case ROUND_DIV_EXPR:
3669 return "/[rd]";
3671 case EXACT_DIV_EXPR:
3672 return "/[ex]";
3674 case TRUNC_MOD_EXPR:
3675 return "%";
3677 case CEIL_MOD_EXPR:
3678 return "%[cl]";
3680 case FLOOR_MOD_EXPR:
3681 return "%[fl]";
3683 case ROUND_MOD_EXPR:
3684 return "%[rd]";
3686 case PREDECREMENT_EXPR:
3687 return " --";
3689 case PREINCREMENT_EXPR:
3690 return " ++";
3692 case POSTDECREMENT_EXPR:
3693 return "-- ";
3695 case POSTINCREMENT_EXPR:
3696 return "++ ";
3698 case MAX_EXPR:
3699 return "max";
3701 case MIN_EXPR:
3702 return "min";
3704 default:
3705 return "<<< ??? >>>";
3709 /* Return the symbol associated with operator OP. */
3711 static const char *
3712 op_symbol (const_tree op)
3714 return op_symbol_code (TREE_CODE (op));
3717 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3718 the gimple_call_fn of a GIMPLE_CALL. */
3720 void
3721 print_call_name (pretty_printer *pp, tree node, int flags)
3723 tree op0 = node;
3725 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3726 op0 = TREE_OPERAND (op0, 0);
3728 again:
3729 switch (TREE_CODE (op0))
3731 case VAR_DECL:
3732 case PARM_DECL:
3733 case FUNCTION_DECL:
3734 dump_function_name (pp, op0, flags);
3735 break;
3737 case ADDR_EXPR:
3738 case INDIRECT_REF:
3739 CASE_CONVERT:
3740 op0 = TREE_OPERAND (op0, 0);
3741 goto again;
3743 case COND_EXPR:
3744 pp_left_paren (pp);
3745 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3746 pp_string (pp, ") ? ");
3747 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3748 pp_string (pp, " : ");
3749 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3750 break;
3752 case ARRAY_REF:
3753 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3754 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3755 else
3756 dump_generic_node (pp, op0, 0, flags, false);
3757 break;
3759 case MEM_REF:
3760 if (integer_zerop (TREE_OPERAND (op0, 1)))
3762 op0 = TREE_OPERAND (op0, 0);
3763 goto again;
3765 /* Fallthru. */
3766 case COMPONENT_REF:
3767 case SSA_NAME:
3768 case OBJ_TYPE_REF:
3769 dump_generic_node (pp, op0, 0, flags, false);
3770 break;
3772 default:
3773 NIY;
3777 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3779 static void
3780 pretty_print_string (pretty_printer *pp, const char *str)
3782 if (str == NULL)
3783 return;
3785 while (*str)
3787 switch (str[0])
3789 case '\b':
3790 pp_string (pp, "\\b");
3791 break;
3793 case '\f':
3794 pp_string (pp, "\\f");
3795 break;
3797 case '\n':
3798 pp_string (pp, "\\n");
3799 break;
3801 case '\r':
3802 pp_string (pp, "\\r");
3803 break;
3805 case '\t':
3806 pp_string (pp, "\\t");
3807 break;
3809 case '\v':
3810 pp_string (pp, "\\v");
3811 break;
3813 case '\\':
3814 pp_string (pp, "\\\\");
3815 break;
3817 case '\"':
3818 pp_string (pp, "\\\"");
3819 break;
3821 case '\'':
3822 pp_string (pp, "\\'");
3823 break;
3825 /* No need to handle \0; the loop terminates on \0. */
3827 case '\1':
3828 pp_string (pp, "\\1");
3829 break;
3831 case '\2':
3832 pp_string (pp, "\\2");
3833 break;
3835 case '\3':
3836 pp_string (pp, "\\3");
3837 break;
3839 case '\4':
3840 pp_string (pp, "\\4");
3841 break;
3843 case '\5':
3844 pp_string (pp, "\\5");
3845 break;
3847 case '\6':
3848 pp_string (pp, "\\6");
3849 break;
3851 case '\7':
3852 pp_string (pp, "\\7");
3853 break;
3855 default:
3856 pp_character (pp, str[0]);
3857 break;
3859 str++;
3863 static void
3864 maybe_init_pretty_print (FILE *file)
3866 if (!tree_pp)
3868 tree_pp = new pretty_printer ();
3869 pp_needs_newline (tree_pp) = true;
3870 pp_translate_identifiers (tree_pp) = false;
3873 tree_pp->buffer->stream = file;
3876 static void
3877 newline_and_indent (pretty_printer *pp, int spc)
3879 pp_newline (pp);
3880 INDENT (spc);
3883 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3884 it can also be used in front ends.
3885 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3888 void
3889 percent_K_format (text_info *text)
3891 tree t = va_arg (*text->args_ptr, tree), block;
3892 text->set_location (0, EXPR_LOCATION (t), true);
3893 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3894 block = TREE_BLOCK (t);
3895 *pp_ti_abstract_origin (text) = NULL;
3897 if (in_lto_p)
3899 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3900 representing the outermost block of an inlined function.
3901 So walk the BLOCK tree until we hit such a scope. */
3902 while (block
3903 && TREE_CODE (block) == BLOCK)
3905 if (inlined_function_outer_scope_p (block))
3907 *pp_ti_abstract_origin (text) = block;
3908 break;
3910 block = BLOCK_SUPERCONTEXT (block);
3912 return;
3915 while (block
3916 && TREE_CODE (block) == BLOCK
3917 && BLOCK_ABSTRACT_ORIGIN (block))
3919 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3921 while (TREE_CODE (ao) == BLOCK
3922 && BLOCK_ABSTRACT_ORIGIN (ao)
3923 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3924 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3926 if (TREE_CODE (ao) == FUNCTION_DECL)
3928 *pp_ti_abstract_origin (text) = block;
3929 break;
3931 block = BLOCK_SUPERCONTEXT (block);
3935 /* Print the identifier ID to PRETTY-PRINTER. */
3937 void
3938 pp_tree_identifier (pretty_printer *pp, tree id)
3940 if (pp_translate_identifiers (pp))
3942 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3943 pp_append_text (pp, text, text + strlen (text));
3945 else
3946 pp_append_text (pp, IDENTIFIER_POINTER (id),
3947 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3950 /* A helper function that is used to dump function information before the
3951 function dump. */
3953 void
3954 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3956 const char *dname, *aname;
3957 struct cgraph_node *node = cgraph_node::get (fdecl);
3958 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3960 dname = lang_hooks.decl_printable_name (fdecl, 2);
3962 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3963 aname = (IDENTIFIER_POINTER
3964 (DECL_ASSEMBLER_NAME (fdecl)));
3965 else
3966 aname = "<unset-asm-name>";
3968 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3969 dname, aname, fun->funcdef_no);
3970 if (!(flags & TDF_NOUID))
3971 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3972 if (node)
3974 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3975 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3976 node->frequency == NODE_FREQUENCY_HOT
3977 ? " (hot)"
3978 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3979 ? " (unlikely executed)"
3980 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3981 ? " (executed once)"
3982 : "");
3984 else
3985 fprintf (dump_file, ")\n\n");
3988 /* Dump double_int D to pretty_printer PP. UNS is true
3989 if D is unsigned and false otherwise. */
3990 void
3991 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3993 if (d.fits_shwi ())
3994 pp_wide_integer (pp, d.low);
3995 else if (d.fits_uhwi ())
3996 pp_unsigned_wide_integer (pp, d.low);
3997 else
3999 unsigned HOST_WIDE_INT low = d.low;
4000 HOST_WIDE_INT high = d.high;
4001 if (!uns && d.is_negative ())
4003 pp_minus (pp);
4004 high = ~high + !low;
4005 low = -low;
4007 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4008 systems? */
4009 sprintf (pp_buffer (pp)->digit_buffer,
4010 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4011 (unsigned HOST_WIDE_INT) high, low);
4012 pp_string (pp, pp_buffer (pp)->digit_buffer);