Simplify X / X, 0 / X and X % X
[official-gcc.git] / gcc / tree-pretty-print.c
blob096eefdd4f63ceb5636994b84fab46ccf64e30b4
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 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
261 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
263 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
264 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
265 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
267 if (flags & TDF_NOUID)
268 pp_string (pp, "D#xxxx");
269 else
270 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
272 else
274 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
275 if (flags & TDF_NOUID)
276 pp_printf (pp, "%c.xxxx", c);
277 else
278 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
281 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
283 if (flags & TDF_NOUID)
284 pp_printf (pp, "ptD.xxxx");
285 else
286 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
290 /* Like the above, but used for pretty printing function calls. */
292 static void
293 dump_function_name (pretty_printer *pp, tree node, int flags)
295 if (CONVERT_EXPR_P (node))
296 node = TREE_OPERAND (node, 0);
297 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
298 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
299 else
300 dump_decl_name (pp, node, flags);
303 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
304 FLAGS are as in dump_generic_node. */
306 static void
307 dump_function_declaration (pretty_printer *pp, tree node,
308 int spc, int flags)
310 bool wrote_arg = false;
311 tree arg;
313 pp_space (pp);
314 pp_left_paren (pp);
316 /* Print the argument types. */
317 arg = TYPE_ARG_TYPES (node);
318 while (arg && arg != void_list_node && arg != error_mark_node)
320 if (wrote_arg)
322 pp_comma (pp);
323 pp_space (pp);
325 wrote_arg = true;
326 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
327 arg = TREE_CHAIN (arg);
330 /* Drop the trailing void_type_node if we had any previous argument. */
331 if (arg == void_list_node && !wrote_arg)
332 pp_string (pp, "void");
333 /* Properly dump vararg function types. */
334 else if (!arg && wrote_arg)
335 pp_string (pp, ", ...");
336 /* Avoid printing any arg for unprototyped functions. */
338 pp_right_paren (pp);
341 /* Dump the domain associated with an array. */
343 static void
344 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
346 pp_left_bracket (pp);
347 if (domain)
349 tree min = TYPE_MIN_VALUE (domain);
350 tree max = TYPE_MAX_VALUE (domain);
352 if (min && max
353 && integer_zerop (min)
354 && tree_fits_shwi_p (max))
355 pp_wide_integer (pp, tree_to_shwi (max) + 1);
356 else
358 if (min)
359 dump_generic_node (pp, min, spc, flags, false);
360 pp_colon (pp);
361 if (max)
362 dump_generic_node (pp, max, spc, flags, false);
365 else
366 pp_string (pp, "<unknown>");
367 pp_right_bracket (pp);
371 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
372 dump_generic_node. */
374 static void
375 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
377 const char *name;
379 switch (OMP_CLAUSE_CODE (clause))
381 case OMP_CLAUSE_PRIVATE:
382 name = "private";
383 goto print_remap;
384 case OMP_CLAUSE_SHARED:
385 name = "shared";
386 goto print_remap;
387 case OMP_CLAUSE_FIRSTPRIVATE:
388 name = "firstprivate";
389 goto print_remap;
390 case OMP_CLAUSE_LASTPRIVATE:
391 name = "lastprivate";
392 goto print_remap;
393 case OMP_CLAUSE_COPYIN:
394 name = "copyin";
395 goto print_remap;
396 case OMP_CLAUSE_COPYPRIVATE:
397 name = "copyprivate";
398 goto print_remap;
399 case OMP_CLAUSE_UNIFORM:
400 name = "uniform";
401 goto print_remap;
402 case OMP_CLAUSE_USE_DEVICE_PTR:
403 name = "use_device_ptr";
404 goto print_remap;
405 case OMP_CLAUSE_IS_DEVICE_PTR:
406 name = "is_device_ptr";
407 goto print_remap;
408 case OMP_CLAUSE__LOOPTEMP_:
409 name = "_looptemp_";
410 goto print_remap;
411 case OMP_CLAUSE_TO_DECLARE:
412 name = "to";
413 goto print_remap;
414 case OMP_CLAUSE_LINK:
415 name = "link";
416 goto print_remap;
417 print_remap:
418 pp_string (pp, name);
419 pp_left_paren (pp);
420 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
421 spc, flags, false);
422 pp_right_paren (pp);
423 break;
425 case OMP_CLAUSE_REDUCTION:
426 pp_string (pp, "reduction(");
427 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
429 pp_string (pp,
430 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
431 pp_colon (pp);
433 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
434 spc, flags, false);
435 pp_right_paren (pp);
436 break;
438 case OMP_CLAUSE_IF:
439 pp_string (pp, "if(");
440 switch (OMP_CLAUSE_IF_MODIFIER (clause))
442 case ERROR_MARK: break;
443 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
444 case OMP_TASK: pp_string (pp, "task:"); break;
445 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
446 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
447 case OMP_TARGET: pp_string (pp, "target:"); break;
448 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
449 case OMP_TARGET_ENTER_DATA:
450 pp_string (pp, "target enter data:"); break;
451 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
452 default: gcc_unreachable ();
454 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
455 spc, flags, false);
456 pp_right_paren (pp);
457 break;
459 case OMP_CLAUSE_NUM_THREADS:
460 pp_string (pp, "num_threads(");
461 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
462 spc, flags, false);
463 pp_right_paren (pp);
464 break;
466 case OMP_CLAUSE__CILK_FOR_COUNT_:
467 pp_string (pp, "_Cilk_for_count_(");
468 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
469 spc, flags, false);
470 pp_right_paren (pp);
471 break;
473 case OMP_CLAUSE_NOWAIT:
474 pp_string (pp, "nowait");
475 break;
476 case OMP_CLAUSE_ORDERED:
477 pp_string (pp, "ordered");
478 if (OMP_CLAUSE_ORDERED_EXPR (clause))
480 pp_left_paren (pp);
481 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
482 spc, flags, false);
483 pp_right_paren (pp);
485 break;
487 case OMP_CLAUSE_DEFAULT:
488 pp_string (pp, "default(");
489 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
491 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
492 break;
493 case OMP_CLAUSE_DEFAULT_SHARED:
494 pp_string (pp, "shared");
495 break;
496 case OMP_CLAUSE_DEFAULT_NONE:
497 pp_string (pp, "none");
498 break;
499 case OMP_CLAUSE_DEFAULT_PRIVATE:
500 pp_string (pp, "private");
501 break;
502 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
503 pp_string (pp, "firstprivate");
504 break;
505 default:
506 gcc_unreachable ();
508 pp_right_paren (pp);
509 break;
511 case OMP_CLAUSE_SCHEDULE:
512 pp_string (pp, "schedule(");
513 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
514 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
515 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
517 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
518 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
519 pp_string (pp, "monotonic");
520 else
521 pp_string (pp, "nonmonotonic");
522 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
523 pp_comma (pp);
524 else
525 pp_colon (pp);
527 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
528 pp_string (pp, "simd:");
530 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
532 case OMP_CLAUSE_SCHEDULE_STATIC:
533 pp_string (pp, "static");
534 break;
535 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
536 pp_string (pp, "dynamic");
537 break;
538 case OMP_CLAUSE_SCHEDULE_GUIDED:
539 pp_string (pp, "guided");
540 break;
541 case OMP_CLAUSE_SCHEDULE_RUNTIME:
542 pp_string (pp, "runtime");
543 break;
544 case OMP_CLAUSE_SCHEDULE_AUTO:
545 pp_string (pp, "auto");
546 break;
547 case OMP_CLAUSE_SCHEDULE_CILKFOR:
548 pp_string (pp, "cilk-for grain");
549 break;
550 default:
551 gcc_unreachable ();
553 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
555 pp_comma (pp);
556 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
557 spc, flags, false);
559 pp_right_paren (pp);
560 break;
562 case OMP_CLAUSE_UNTIED:
563 pp_string (pp, "untied");
564 break;
566 case OMP_CLAUSE_COLLAPSE:
567 pp_string (pp, "collapse(");
568 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
569 spc, flags, false);
570 pp_right_paren (pp);
571 break;
573 case OMP_CLAUSE_FINAL:
574 pp_string (pp, "final(");
575 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
576 spc, flags, false);
577 pp_right_paren (pp);
578 break;
580 case OMP_CLAUSE_MERGEABLE:
581 pp_string (pp, "mergeable");
582 break;
584 case OMP_CLAUSE_LINEAR:
585 pp_string (pp, "linear(");
586 switch (OMP_CLAUSE_LINEAR_KIND (clause))
588 case OMP_CLAUSE_LINEAR_DEFAULT:
589 break;
590 case OMP_CLAUSE_LINEAR_REF:
591 pp_string (pp, "ref(");
592 break;
593 case OMP_CLAUSE_LINEAR_VAL:
594 pp_string (pp, "val(");
595 break;
596 case OMP_CLAUSE_LINEAR_UVAL:
597 pp_string (pp, "uval(");
598 break;
599 default:
600 gcc_unreachable ();
602 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
603 spc, flags, false);
604 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
605 pp_right_paren (pp);
606 pp_colon (pp);
607 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
608 spc, flags, false);
609 pp_right_paren (pp);
610 break;
612 case OMP_CLAUSE_ALIGNED:
613 pp_string (pp, "aligned(");
614 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
615 spc, flags, false);
616 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
618 pp_colon (pp);
619 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
620 spc, flags, false);
622 pp_right_paren (pp);
623 break;
625 case OMP_CLAUSE_DEPEND:
626 pp_string (pp, "depend(");
627 switch (OMP_CLAUSE_DEPEND_KIND (clause))
629 case OMP_CLAUSE_DEPEND_IN:
630 pp_string (pp, "in");
631 break;
632 case OMP_CLAUSE_DEPEND_OUT:
633 pp_string (pp, "out");
634 break;
635 case OMP_CLAUSE_DEPEND_INOUT:
636 pp_string (pp, "inout");
637 break;
638 case OMP_CLAUSE_DEPEND_SOURCE:
639 pp_string (pp, "source)");
640 return;
641 case OMP_CLAUSE_DEPEND_SINK:
642 pp_string (pp, "sink:");
643 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
644 if (TREE_CODE (t) == TREE_LIST)
646 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
647 if (TREE_PURPOSE (t) != integer_zero_node)
649 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
650 pp_minus (pp);
651 else
652 pp_plus (pp);
653 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
654 false);
656 if (TREE_CHAIN (t))
657 pp_comma (pp);
659 else
660 gcc_unreachable ();
661 pp_right_paren (pp);
662 return;
663 default:
664 gcc_unreachable ();
666 pp_colon (pp);
667 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
668 spc, flags, false);
669 pp_right_paren (pp);
670 break;
672 case OMP_CLAUSE_MAP:
673 pp_string (pp, "map(");
674 switch (OMP_CLAUSE_MAP_KIND (clause))
676 case GOMP_MAP_ALLOC:
677 case GOMP_MAP_POINTER:
678 pp_string (pp, "alloc");
679 break;
680 case GOMP_MAP_TO:
681 case GOMP_MAP_TO_PSET:
682 pp_string (pp, "to");
683 break;
684 case GOMP_MAP_FROM:
685 pp_string (pp, "from");
686 break;
687 case GOMP_MAP_TOFROM:
688 pp_string (pp, "tofrom");
689 break;
690 case GOMP_MAP_FORCE_ALLOC:
691 pp_string (pp, "force_alloc");
692 break;
693 case GOMP_MAP_FORCE_TO:
694 pp_string (pp, "force_to");
695 break;
696 case GOMP_MAP_FORCE_FROM:
697 pp_string (pp, "force_from");
698 break;
699 case GOMP_MAP_FORCE_TOFROM:
700 pp_string (pp, "force_tofrom");
701 break;
702 case GOMP_MAP_FORCE_PRESENT:
703 pp_string (pp, "force_present");
704 break;
705 case GOMP_MAP_DELETE:
706 pp_string (pp, "delete");
707 break;
708 case GOMP_MAP_FORCE_DEVICEPTR:
709 pp_string (pp, "force_deviceptr");
710 break;
711 case GOMP_MAP_ALWAYS_TO:
712 pp_string (pp, "always,to");
713 break;
714 case GOMP_MAP_ALWAYS_FROM:
715 pp_string (pp, "always,from");
716 break;
717 case GOMP_MAP_ALWAYS_TOFROM:
718 pp_string (pp, "always,tofrom");
719 break;
720 case GOMP_MAP_RELEASE:
721 pp_string (pp, "release");
722 break;
723 case GOMP_MAP_FIRSTPRIVATE_POINTER:
724 pp_string (pp, "firstprivate");
725 break;
726 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
727 pp_string (pp, "firstprivate ref");
728 break;
729 case GOMP_MAP_STRUCT:
730 pp_string (pp, "struct");
731 break;
732 case GOMP_MAP_ALWAYS_POINTER:
733 pp_string (pp, "always_pointer");
734 break;
735 case GOMP_MAP_DEVICE_RESIDENT:
736 pp_string (pp, "device_resident");
737 break;
738 case GOMP_MAP_LINK:
739 pp_string (pp, "link");
740 break;
741 default:
742 gcc_unreachable ();
744 pp_colon (pp);
745 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
746 spc, flags, false);
747 print_clause_size:
748 if (OMP_CLAUSE_SIZE (clause))
750 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
751 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
753 case GOMP_MAP_POINTER:
754 case GOMP_MAP_FIRSTPRIVATE_POINTER:
755 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
756 case GOMP_MAP_ALWAYS_POINTER:
757 pp_string (pp, " [pointer assign, bias: ");
758 break;
759 case GOMP_MAP_TO_PSET:
760 pp_string (pp, " [pointer set, len: ");
761 break;
762 default:
763 pp_string (pp, " [len: ");
764 break;
766 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
767 spc, flags, false);
768 pp_right_bracket (pp);
770 pp_right_paren (pp);
771 break;
773 case OMP_CLAUSE_FROM:
774 pp_string (pp, "from(");
775 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
776 spc, flags, false);
777 goto print_clause_size;
779 case OMP_CLAUSE_TO:
780 pp_string (pp, "to(");
781 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
782 spc, flags, false);
783 goto print_clause_size;
785 case OMP_CLAUSE__CACHE_:
786 pp_string (pp, "(");
787 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
788 spc, flags, false);
789 goto print_clause_size;
791 case OMP_CLAUSE_NUM_TEAMS:
792 pp_string (pp, "num_teams(");
793 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
794 spc, flags, false);
795 pp_right_paren (pp);
796 break;
798 case OMP_CLAUSE_THREAD_LIMIT:
799 pp_string (pp, "thread_limit(");
800 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
801 spc, flags, false);
802 pp_right_paren (pp);
803 break;
805 case OMP_CLAUSE_DEVICE:
806 pp_string (pp, "device(");
807 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
808 spc, flags, false);
809 pp_right_paren (pp);
810 break;
812 case OMP_CLAUSE_DIST_SCHEDULE:
813 pp_string (pp, "dist_schedule(static");
814 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
816 pp_comma (pp);
817 dump_generic_node (pp,
818 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
819 spc, flags, false);
821 pp_right_paren (pp);
822 break;
824 case OMP_CLAUSE_PROC_BIND:
825 pp_string (pp, "proc_bind(");
826 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
828 case OMP_CLAUSE_PROC_BIND_MASTER:
829 pp_string (pp, "master");
830 break;
831 case OMP_CLAUSE_PROC_BIND_CLOSE:
832 pp_string (pp, "close");
833 break;
834 case OMP_CLAUSE_PROC_BIND_SPREAD:
835 pp_string (pp, "spread");
836 break;
837 default:
838 gcc_unreachable ();
840 pp_right_paren (pp);
841 break;
843 case OMP_CLAUSE_SAFELEN:
844 pp_string (pp, "safelen(");
845 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
846 spc, flags, false);
847 pp_right_paren (pp);
848 break;
850 case OMP_CLAUSE_SIMDLEN:
851 pp_string (pp, "simdlen(");
852 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
853 spc, flags, false);
854 pp_right_paren (pp);
855 break;
857 case OMP_CLAUSE_PRIORITY:
858 pp_string (pp, "priority(");
859 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
860 spc, flags, false);
861 pp_right_paren (pp);
862 break;
864 case OMP_CLAUSE_GRAINSIZE:
865 pp_string (pp, "grainsize(");
866 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
867 spc, flags, false);
868 pp_right_paren (pp);
869 break;
871 case OMP_CLAUSE_NUM_TASKS:
872 pp_string (pp, "num_tasks(");
873 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
874 spc, flags, false);
875 pp_right_paren (pp);
876 break;
878 case OMP_CLAUSE_HINT:
879 pp_string (pp, "hint(");
880 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
881 spc, flags, false);
882 pp_right_paren (pp);
883 break;
885 case OMP_CLAUSE_DEFAULTMAP:
886 pp_string (pp, "defaultmap(tofrom:scalar)");
887 break;
889 case OMP_CLAUSE__SIMDUID_:
890 pp_string (pp, "_simduid_(");
891 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
892 spc, flags, false);
893 pp_right_paren (pp);
894 break;
896 case OMP_CLAUSE_GANG:
897 pp_string (pp, "gang");
898 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
900 pp_string (pp, "(num: ");
901 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
902 spc, flags, false);
904 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
906 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
907 pp_left_paren (pp);
908 else
909 pp_space (pp);
910 pp_string (pp, "static:");
911 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
912 == integer_minus_one_node)
913 pp_character (pp, '*');
914 else
915 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
916 spc, flags, false);
918 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
919 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
920 pp_right_paren (pp);
921 break;
923 case OMP_CLAUSE_ASYNC:
924 pp_string (pp, "async");
925 if (OMP_CLAUSE_ASYNC_EXPR (clause))
927 pp_character(pp, '(');
928 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
929 spc, flags, false);
930 pp_character(pp, ')');
932 break;
934 case OMP_CLAUSE_AUTO:
935 case OMP_CLAUSE_SEQ:
936 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
937 break;
939 case OMP_CLAUSE_WAIT:
940 pp_string (pp, "wait(");
941 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
942 spc, flags, false);
943 pp_character(pp, ')');
944 break;
946 case OMP_CLAUSE_WORKER:
947 pp_string (pp, "worker");
948 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
950 pp_left_paren (pp);
951 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
952 spc, flags, false);
953 pp_right_paren (pp);
955 break;
957 case OMP_CLAUSE_VECTOR:
958 pp_string (pp, "vector");
959 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
961 pp_left_paren (pp);
962 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
963 spc, flags, false);
964 pp_right_paren (pp);
966 break;
968 case OMP_CLAUSE_NUM_GANGS:
969 pp_string (pp, "num_gangs(");
970 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
971 spc, flags, false);
972 pp_character (pp, ')');
973 break;
975 case OMP_CLAUSE_NUM_WORKERS:
976 pp_string (pp, "num_workers(");
977 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
978 spc, flags, false);
979 pp_character (pp, ')');
980 break;
982 case OMP_CLAUSE_VECTOR_LENGTH:
983 pp_string (pp, "vector_length(");
984 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
985 spc, flags, false);
986 pp_character (pp, ')');
987 break;
989 case OMP_CLAUSE_INBRANCH:
990 pp_string (pp, "inbranch");
991 break;
992 case OMP_CLAUSE_NOTINBRANCH:
993 pp_string (pp, "notinbranch");
994 break;
995 case OMP_CLAUSE_FOR:
996 pp_string (pp, "for");
997 break;
998 case OMP_CLAUSE_PARALLEL:
999 pp_string (pp, "parallel");
1000 break;
1001 case OMP_CLAUSE_SECTIONS:
1002 pp_string (pp, "sections");
1003 break;
1004 case OMP_CLAUSE_TASKGROUP:
1005 pp_string (pp, "taskgroup");
1006 break;
1007 case OMP_CLAUSE_NOGROUP:
1008 pp_string (pp, "nogroup");
1009 break;
1010 case OMP_CLAUSE_THREADS:
1011 pp_string (pp, "threads");
1012 break;
1013 case OMP_CLAUSE_SIMD:
1014 pp_string (pp, "simd");
1015 break;
1016 case OMP_CLAUSE_INDEPENDENT:
1017 pp_string (pp, "independent");
1018 break;
1019 case OMP_CLAUSE_TILE:
1020 pp_string (pp, "tile(");
1021 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1022 spc, flags, false);
1023 pp_right_paren (pp);
1024 break;
1026 case OMP_CLAUSE__GRIDDIM_:
1027 pp_string (pp, "_griddim_(");
1028 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1029 pp_colon (pp);
1030 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1031 false);
1032 pp_comma (pp);
1033 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1034 false);
1035 pp_right_paren (pp);
1036 break;
1038 default:
1039 /* Should never happen. */
1040 dump_generic_node (pp, clause, spc, flags, false);
1041 break;
1046 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1047 dump_generic_node. */
1049 void
1050 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
1052 if (clause == NULL)
1053 return;
1055 pp_space (pp);
1056 while (1)
1058 dump_omp_clause (pp, clause, spc, flags);
1059 clause = OMP_CLAUSE_CHAIN (clause);
1060 if (clause == NULL)
1061 return;
1062 pp_space (pp);
1067 /* Dump location LOC to PP. */
1069 void
1070 dump_location (pretty_printer *pp, location_t loc)
1072 expanded_location xloc = expand_location (loc);
1074 pp_left_bracket (pp);
1075 if (xloc.file)
1077 pp_string (pp, xloc.file);
1078 pp_string (pp, ":");
1080 pp_decimal_int (pp, xloc.line);
1081 pp_colon (pp);
1082 pp_decimal_int (pp, xloc.column);
1083 pp_string (pp, "] ");
1087 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1088 dump_generic_node. */
1090 static void
1091 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
1093 tree t;
1095 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1097 if (flags & TDF_ADDRESS)
1098 pp_printf (pp, "[%p] ", (void *) block);
1100 if (BLOCK_ABSTRACT (block))
1101 pp_string (pp, "[abstract] ");
1103 if (TREE_ASM_WRITTEN (block))
1104 pp_string (pp, "[written] ");
1106 if (flags & TDF_SLIM)
1107 return;
1109 if (BLOCK_SOURCE_LOCATION (block))
1110 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1112 newline_and_indent (pp, spc + 2);
1114 if (BLOCK_SUPERCONTEXT (block))
1116 pp_string (pp, "SUPERCONTEXT: ");
1117 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1118 flags | TDF_SLIM, false);
1119 newline_and_indent (pp, spc + 2);
1122 if (BLOCK_SUBBLOCKS (block))
1124 pp_string (pp, "SUBBLOCKS: ");
1125 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1127 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1128 pp_space (pp);
1130 newline_and_indent (pp, spc + 2);
1133 if (BLOCK_CHAIN (block))
1135 pp_string (pp, "SIBLINGS: ");
1136 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1138 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1139 pp_space (pp);
1141 newline_and_indent (pp, spc + 2);
1144 if (BLOCK_VARS (block))
1146 pp_string (pp, "VARS: ");
1147 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1149 dump_generic_node (pp, t, 0, flags, false);
1150 pp_space (pp);
1152 newline_and_indent (pp, spc + 2);
1155 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1157 unsigned i;
1158 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1160 pp_string (pp, "NONLOCALIZED_VARS: ");
1161 FOR_EACH_VEC_ELT (*nlv, i, t)
1163 dump_generic_node (pp, t, 0, flags, false);
1164 pp_space (pp);
1166 newline_and_indent (pp, spc + 2);
1169 if (BLOCK_ABSTRACT_ORIGIN (block))
1171 pp_string (pp, "ABSTRACT_ORIGIN: ");
1172 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1173 flags | TDF_SLIM, false);
1174 newline_and_indent (pp, spc + 2);
1177 if (BLOCK_FRAGMENT_ORIGIN (block))
1179 pp_string (pp, "FRAGMENT_ORIGIN: ");
1180 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1181 flags | TDF_SLIM, false);
1182 newline_and_indent (pp, spc + 2);
1185 if (BLOCK_FRAGMENT_CHAIN (block))
1187 pp_string (pp, "FRAGMENT_CHAIN: ");
1188 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1190 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1191 pp_space (pp);
1193 newline_and_indent (pp, spc + 2);
1198 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1199 indent. FLAGS specifies details to show in the dump (see TDF_* in
1200 dumpfile.h). If IS_STMT is true, the object printed is considered
1201 to be a statement and it is terminated by ';' if appropriate. */
1204 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
1205 bool is_stmt)
1207 tree type;
1208 tree op0, op1;
1209 const char *str;
1210 bool is_expr;
1211 enum tree_code code;
1213 if (node == NULL_TREE)
1214 return spc;
1216 is_expr = EXPR_P (node);
1218 if (is_stmt && (flags & TDF_STMTADDR))
1219 pp_printf (pp, "<&%p> ", (void *)node);
1221 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1222 dump_location (pp, EXPR_LOCATION (node));
1224 code = TREE_CODE (node);
1225 switch (code)
1227 case ERROR_MARK:
1228 pp_string (pp, "<<< error >>>");
1229 break;
1231 case IDENTIFIER_NODE:
1232 pp_tree_identifier (pp, node);
1233 break;
1235 case TREE_LIST:
1236 while (node && node != error_mark_node)
1238 if (TREE_PURPOSE (node))
1240 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1241 pp_space (pp);
1243 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1244 node = TREE_CHAIN (node);
1245 if (node && TREE_CODE (node) == TREE_LIST)
1247 pp_comma (pp);
1248 pp_space (pp);
1251 break;
1253 case TREE_BINFO:
1254 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1255 break;
1257 case TREE_VEC:
1259 size_t i;
1260 if (TREE_VEC_LENGTH (node) > 0)
1262 size_t len = TREE_VEC_LENGTH (node);
1263 for (i = 0; i < len - 1; i++)
1265 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1266 false);
1267 pp_comma (pp);
1268 pp_space (pp);
1270 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1271 flags, false);
1274 break;
1276 case VOID_TYPE:
1277 case POINTER_BOUNDS_TYPE:
1278 case INTEGER_TYPE:
1279 case REAL_TYPE:
1280 case FIXED_POINT_TYPE:
1281 case COMPLEX_TYPE:
1282 case VECTOR_TYPE:
1283 case ENUMERAL_TYPE:
1284 case BOOLEAN_TYPE:
1286 unsigned int quals = TYPE_QUALS (node);
1287 enum tree_code_class tclass;
1289 if (quals & TYPE_QUAL_ATOMIC)
1290 pp_string (pp, "atomic ");
1291 if (quals & TYPE_QUAL_CONST)
1292 pp_string (pp, "const ");
1293 else if (quals & TYPE_QUAL_VOLATILE)
1294 pp_string (pp, "volatile ");
1295 else if (quals & TYPE_QUAL_RESTRICT)
1296 pp_string (pp, "restrict ");
1298 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1300 pp_string (pp, "<address-space-");
1301 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1302 pp_string (pp, "> ");
1305 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1307 if (tclass == tcc_declaration)
1309 if (DECL_NAME (node))
1310 dump_decl_name (pp, node, flags);
1311 else
1312 pp_string (pp, "<unnamed type decl>");
1314 else if (tclass == tcc_type)
1316 if (TYPE_NAME (node))
1318 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1319 pp_tree_identifier (pp, TYPE_NAME (node));
1320 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1321 && DECL_NAME (TYPE_NAME (node)))
1322 dump_decl_name (pp, TYPE_NAME (node), flags);
1323 else
1324 pp_string (pp, "<unnamed type>");
1326 else if (TREE_CODE (node) == VECTOR_TYPE)
1328 pp_string (pp, "vector");
1329 pp_left_paren (pp);
1330 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1331 pp_string (pp, ") ");
1332 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1334 else if (TREE_CODE (node) == INTEGER_TYPE)
1336 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1337 pp_string (pp, (TYPE_UNSIGNED (node)
1338 ? "unsigned char"
1339 : "signed char"));
1340 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1341 pp_string (pp, (TYPE_UNSIGNED (node)
1342 ? "unsigned short"
1343 : "signed short"));
1344 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1345 pp_string (pp, (TYPE_UNSIGNED (node)
1346 ? "unsigned int"
1347 : "signed int"));
1348 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1349 pp_string (pp, (TYPE_UNSIGNED (node)
1350 ? "unsigned long"
1351 : "signed long"));
1352 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1353 pp_string (pp, (TYPE_UNSIGNED (node)
1354 ? "unsigned long long"
1355 : "signed long long"));
1356 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1357 && pow2p_hwi (TYPE_PRECISION (node)))
1359 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1360 pp_decimal_int (pp, TYPE_PRECISION (node));
1361 pp_string (pp, "_t");
1363 else
1365 pp_string (pp, (TYPE_UNSIGNED (node)
1366 ? "<unnamed-unsigned:"
1367 : "<unnamed-signed:"));
1368 pp_decimal_int (pp, TYPE_PRECISION (node));
1369 pp_greater (pp);
1372 else if (TREE_CODE (node) == COMPLEX_TYPE)
1374 pp_string (pp, "__complex__ ");
1375 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1377 else if (TREE_CODE (node) == REAL_TYPE)
1379 pp_string (pp, "<float:");
1380 pp_decimal_int (pp, TYPE_PRECISION (node));
1381 pp_greater (pp);
1383 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1385 pp_string (pp, "<fixed-point-");
1386 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1387 pp_decimal_int (pp, TYPE_PRECISION (node));
1388 pp_greater (pp);
1390 else if (TREE_CODE (node) == VOID_TYPE)
1391 pp_string (pp, "void");
1392 else
1393 pp_string (pp, "<unnamed type>");
1395 break;
1398 case POINTER_TYPE:
1399 case REFERENCE_TYPE:
1400 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1402 if (TREE_TYPE (node) == NULL)
1404 pp_string (pp, str);
1405 pp_string (pp, "<null type>");
1407 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1409 tree fnode = TREE_TYPE (node);
1411 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1412 pp_space (pp);
1413 pp_left_paren (pp);
1414 pp_string (pp, str);
1415 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1416 dump_decl_name (pp, TYPE_NAME (node), flags);
1417 else if (flags & TDF_NOUID)
1418 pp_printf (pp, "<Txxxx>");
1419 else
1420 pp_printf (pp, "<T%x>", TYPE_UID (node));
1422 pp_right_paren (pp);
1423 dump_function_declaration (pp, fnode, spc, flags);
1425 else
1427 unsigned int quals = TYPE_QUALS (node);
1429 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1430 pp_space (pp);
1431 pp_string (pp, str);
1433 if (quals & TYPE_QUAL_CONST)
1434 pp_string (pp, " const");
1435 if (quals & TYPE_QUAL_VOLATILE)
1436 pp_string (pp, " volatile");
1437 if (quals & TYPE_QUAL_RESTRICT)
1438 pp_string (pp, " restrict");
1440 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1442 pp_string (pp, " <address-space-");
1443 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1444 pp_greater (pp);
1447 if (TYPE_REF_CAN_ALIAS_ALL (node))
1448 pp_string (pp, " {ref-all}");
1450 break;
1452 case OFFSET_TYPE:
1453 NIY;
1454 break;
1456 case MEM_REF:
1458 if (integer_zerop (TREE_OPERAND (node, 1))
1459 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1460 infer them and MEM_ATTR caching will share MEM_REFs
1461 with differently-typed op0s. */
1462 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1463 /* Released SSA_NAMES have no TREE_TYPE. */
1464 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1465 /* Same pointer types, but ignoring POINTER_TYPE vs.
1466 REFERENCE_TYPE. */
1467 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1468 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1469 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1470 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1471 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1472 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1473 /* Same value types ignoring qualifiers. */
1474 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1475 == TYPE_MAIN_VARIANT
1476 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1477 && (!(flags & TDF_ALIAS)
1478 || MR_DEPENDENCE_CLIQUE (node) == 0))
1480 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1482 pp_star (pp);
1483 dump_generic_node (pp, TREE_OPERAND (node, 0),
1484 spc, flags, false);
1486 else
1487 dump_generic_node (pp,
1488 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1489 spc, flags, false);
1491 else
1493 tree ptype;
1495 pp_string (pp, "MEM[");
1496 pp_left_paren (pp);
1497 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1498 dump_generic_node (pp, ptype,
1499 spc, flags | TDF_SLIM, false);
1500 pp_right_paren (pp);
1501 dump_generic_node (pp, TREE_OPERAND (node, 0),
1502 spc, flags, false);
1503 if (!integer_zerop (TREE_OPERAND (node, 1)))
1505 pp_string (pp, " + ");
1506 dump_generic_node (pp, TREE_OPERAND (node, 1),
1507 spc, flags, false);
1509 if ((flags & TDF_ALIAS)
1510 && MR_DEPENDENCE_CLIQUE (node) != 0)
1512 pp_string (pp, " clique ");
1513 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1514 pp_string (pp, " base ");
1515 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1517 pp_right_bracket (pp);
1519 break;
1522 case TARGET_MEM_REF:
1524 const char *sep = "";
1525 tree tmp;
1527 pp_string (pp, "MEM[");
1529 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1531 pp_string (pp, sep);
1532 sep = ", ";
1533 pp_string (pp, "symbol: ");
1534 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1535 spc, flags, false);
1537 else
1539 pp_string (pp, sep);
1540 sep = ", ";
1541 pp_string (pp, "base: ");
1542 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1544 tmp = TMR_INDEX2 (node);
1545 if (tmp)
1547 pp_string (pp, sep);
1548 sep = ", ";
1549 pp_string (pp, "base: ");
1550 dump_generic_node (pp, tmp, spc, flags, false);
1552 tmp = TMR_INDEX (node);
1553 if (tmp)
1555 pp_string (pp, sep);
1556 sep = ", ";
1557 pp_string (pp, "index: ");
1558 dump_generic_node (pp, tmp, spc, flags, false);
1560 tmp = TMR_STEP (node);
1561 if (tmp)
1563 pp_string (pp, sep);
1564 sep = ", ";
1565 pp_string (pp, "step: ");
1566 dump_generic_node (pp, tmp, spc, flags, false);
1568 tmp = TMR_OFFSET (node);
1569 if (tmp)
1571 pp_string (pp, sep);
1572 sep = ", ";
1573 pp_string (pp, "offset: ");
1574 dump_generic_node (pp, tmp, spc, flags, false);
1576 pp_right_bracket (pp);
1578 break;
1580 case ARRAY_TYPE:
1582 tree tmp;
1584 /* Print the innermost component type. */
1585 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1586 tmp = TREE_TYPE (tmp))
1588 dump_generic_node (pp, tmp, spc, flags, false);
1590 /* Print the dimensions. */
1591 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1592 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1593 break;
1596 case RECORD_TYPE:
1597 case UNION_TYPE:
1598 case QUAL_UNION_TYPE:
1600 unsigned int quals = TYPE_QUALS (node);
1602 if (quals & TYPE_QUAL_ATOMIC)
1603 pp_string (pp, "atomic ");
1604 if (quals & TYPE_QUAL_CONST)
1605 pp_string (pp, "const ");
1606 if (quals & TYPE_QUAL_VOLATILE)
1607 pp_string (pp, "volatile ");
1609 /* Print the name of the structure. */
1610 if (TREE_CODE (node) == RECORD_TYPE)
1611 pp_string (pp, "struct ");
1612 else if (TREE_CODE (node) == UNION_TYPE)
1613 pp_string (pp, "union ");
1615 if (TYPE_NAME (node))
1616 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1617 else if (!(flags & TDF_SLIM))
1618 /* FIXME: If we eliminate the 'else' above and attempt
1619 to show the fields for named types, we may get stuck
1620 following a cycle of pointers to structs. The alleged
1621 self-reference check in print_struct_decl will not detect
1622 cycles involving more than one pointer or struct type. */
1623 print_struct_decl (pp, node, spc, flags);
1624 break;
1627 case LANG_TYPE:
1628 NIY;
1629 break;
1631 case INTEGER_CST:
1632 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1634 /* In the case of a pointer, one may want to divide by the
1635 size of the pointed-to type. Unfortunately, this not
1636 straightforward. The C front-end maps expressions
1638 (int *) 5
1639 int *p; (p + 5)
1641 in such a way that the two INTEGER_CST nodes for "5" have
1642 different values but identical types. In the latter
1643 case, the 5 is multiplied by sizeof (int) in c-common.c
1644 (pointer_int_sum) to convert it to a byte address, and
1645 yet the type of the node is left unchanged. Argh. What
1646 is consistent though is that the number value corresponds
1647 to bytes (UNITS) offset.
1649 NB: Neither of the following divisors can be trivially
1650 used to recover the original literal:
1652 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1653 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1654 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1655 pp_string (pp, "B"); /* pseudo-unit */
1657 else if (tree_fits_shwi_p (node))
1658 pp_wide_integer (pp, tree_to_shwi (node));
1659 else if (tree_fits_uhwi_p (node))
1660 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1661 else
1663 wide_int val = node;
1665 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1667 pp_minus (pp);
1668 val = -val;
1670 print_hex (val, pp_buffer (pp)->digit_buffer);
1671 pp_string (pp, pp_buffer (pp)->digit_buffer);
1673 if (TREE_OVERFLOW (node))
1674 pp_string (pp, "(OVF)");
1675 break;
1677 case REAL_CST:
1678 /* Code copied from print_node. */
1680 REAL_VALUE_TYPE d;
1681 if (TREE_OVERFLOW (node))
1682 pp_string (pp, " overflow");
1684 d = TREE_REAL_CST (node);
1685 if (REAL_VALUE_ISINF (d))
1686 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1687 else if (REAL_VALUE_ISNAN (d))
1688 pp_string (pp, " Nan");
1689 else
1691 char string[100];
1692 real_to_decimal (string, &d, sizeof (string), 0, 1);
1693 pp_string (pp, string);
1695 break;
1698 case FIXED_CST:
1700 char string[100];
1701 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1702 pp_string (pp, string);
1703 break;
1706 case COMPLEX_CST:
1707 pp_string (pp, "__complex__ (");
1708 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1709 pp_string (pp, ", ");
1710 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1711 pp_right_paren (pp);
1712 break;
1714 case STRING_CST:
1715 pp_string (pp, "\"");
1716 pretty_print_string (pp, TREE_STRING_POINTER (node));
1717 pp_string (pp, "\"");
1718 break;
1720 case VECTOR_CST:
1722 unsigned i;
1723 pp_string (pp, "{ ");
1724 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1726 if (i != 0)
1727 pp_string (pp, ", ");
1728 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1729 spc, flags, false);
1731 pp_string (pp, " }");
1733 break;
1735 case FUNCTION_TYPE:
1736 case METHOD_TYPE:
1737 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1738 pp_space (pp);
1739 if (TREE_CODE (node) == METHOD_TYPE)
1741 if (TYPE_METHOD_BASETYPE (node))
1742 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1743 flags);
1744 else
1745 pp_string (pp, "<null method basetype>");
1746 pp_colon_colon (pp);
1748 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1749 dump_decl_name (pp, TYPE_NAME (node), flags);
1750 else if (flags & TDF_NOUID)
1751 pp_printf (pp, "<Txxxx>");
1752 else
1753 pp_printf (pp, "<T%x>", TYPE_UID (node));
1754 dump_function_declaration (pp, node, spc, flags);
1755 break;
1757 case FUNCTION_DECL:
1758 case CONST_DECL:
1759 dump_decl_name (pp, node, flags);
1760 break;
1762 case LABEL_DECL:
1763 if (DECL_NAME (node))
1764 dump_decl_name (pp, node, flags);
1765 else if (LABEL_DECL_UID (node) != -1)
1767 if (flags & TDF_GIMPLE)
1768 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1769 else
1770 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1772 else
1774 if (flags & TDF_NOUID)
1775 pp_string (pp, "<D.xxxx>");
1776 else
1778 if (flags & TDF_GIMPLE)
1779 pp_printf (pp, "<D%u>", DECL_UID (node));
1780 else
1781 pp_printf (pp, "<D.%u>", DECL_UID (node));
1784 break;
1786 case TYPE_DECL:
1787 if (DECL_IS_BUILTIN (node))
1789 /* Don't print the declaration of built-in types. */
1790 break;
1792 if (DECL_NAME (node))
1793 dump_decl_name (pp, node, flags);
1794 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1796 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1797 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1798 && TYPE_METHODS (TREE_TYPE (node)))
1800 /* The type is a c++ class: all structures have at least
1801 4 methods. */
1802 pp_string (pp, "class ");
1803 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1805 else
1807 pp_string (pp,
1808 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1809 ? "union" : "struct "));
1810 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1813 else
1814 pp_string (pp, "<anon>");
1815 break;
1817 case VAR_DECL:
1818 case PARM_DECL:
1819 case FIELD_DECL:
1820 case DEBUG_EXPR_DECL:
1821 case NAMESPACE_DECL:
1822 case NAMELIST_DECL:
1823 dump_decl_name (pp, node, flags);
1824 break;
1826 case RESULT_DECL:
1827 pp_string (pp, "<retval>");
1828 break;
1830 case COMPONENT_REF:
1831 op0 = TREE_OPERAND (node, 0);
1832 str = ".";
1833 if (op0
1834 && (TREE_CODE (op0) == INDIRECT_REF
1835 || (TREE_CODE (op0) == MEM_REF
1836 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1837 && integer_zerop (TREE_OPERAND (op0, 1))
1838 /* Dump the types of INTEGER_CSTs explicitly, for we
1839 can't infer them and MEM_ATTR caching will share
1840 MEM_REFs with differently-typed op0s. */
1841 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1842 /* Released SSA_NAMES have no TREE_TYPE. */
1843 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1844 /* Same pointer types, but ignoring POINTER_TYPE vs.
1845 REFERENCE_TYPE. */
1846 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1847 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1848 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1849 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1850 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1851 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1852 /* Same value types ignoring qualifiers. */
1853 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1854 == TYPE_MAIN_VARIANT
1855 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1856 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1858 op0 = TREE_OPERAND (op0, 0);
1859 str = "->";
1861 if (op_prio (op0) < op_prio (node))
1862 pp_left_paren (pp);
1863 dump_generic_node (pp, op0, spc, flags, false);
1864 if (op_prio (op0) < op_prio (node))
1865 pp_right_paren (pp);
1866 pp_string (pp, str);
1867 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1868 op0 = component_ref_field_offset (node);
1869 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1871 pp_string (pp, "{off: ");
1872 dump_generic_node (pp, op0, spc, flags, false);
1873 pp_right_brace (pp);
1875 break;
1877 case BIT_FIELD_REF:
1878 pp_string (pp, "BIT_FIELD_REF <");
1879 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1880 pp_string (pp, ", ");
1881 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1882 pp_string (pp, ", ");
1883 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1884 pp_greater (pp);
1885 break;
1887 case BIT_INSERT_EXPR:
1888 pp_string (pp, "BIT_INSERT_EXPR <");
1889 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1890 pp_string (pp, ", ");
1891 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1892 pp_string (pp, ", ");
1893 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1894 pp_string (pp, " (");
1895 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1896 pp_decimal_int (pp,
1897 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1898 else
1899 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1900 spc, flags, false);
1901 pp_string (pp, " bits)>");
1902 break;
1904 case ARRAY_REF:
1905 case ARRAY_RANGE_REF:
1906 op0 = TREE_OPERAND (node, 0);
1907 if (op_prio (op0) < op_prio (node))
1908 pp_left_paren (pp);
1909 dump_generic_node (pp, op0, spc, flags, false);
1910 if (op_prio (op0) < op_prio (node))
1911 pp_right_paren (pp);
1912 pp_left_bracket (pp);
1913 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1914 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1915 pp_string (pp, " ...");
1916 pp_right_bracket (pp);
1918 op0 = array_ref_low_bound (node);
1919 op1 = array_ref_element_size (node);
1921 if (!integer_zerop (op0)
1922 || TREE_OPERAND (node, 2)
1923 || TREE_OPERAND (node, 3))
1925 pp_string (pp, "{lb: ");
1926 dump_generic_node (pp, op0, spc, flags, false);
1927 pp_string (pp, " sz: ");
1928 dump_generic_node (pp, op1, spc, flags, false);
1929 pp_right_brace (pp);
1931 break;
1933 case CONSTRUCTOR:
1935 unsigned HOST_WIDE_INT ix;
1936 tree field, val;
1937 bool is_struct_init = false;
1938 bool is_array_init = false;
1939 widest_int curidx;
1940 pp_left_brace (pp);
1941 if (TREE_CLOBBER_P (node))
1942 pp_string (pp, "CLOBBER");
1943 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1944 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1945 is_struct_init = true;
1946 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1947 && TYPE_DOMAIN (TREE_TYPE (node))
1948 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1949 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1950 == INTEGER_CST)
1952 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1953 is_array_init = true;
1954 curidx = wi::to_widest (minv);
1956 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1958 if (field)
1960 if (is_struct_init)
1962 pp_dot (pp);
1963 dump_generic_node (pp, field, spc, flags, false);
1964 pp_equal (pp);
1966 else if (is_array_init
1967 && (TREE_CODE (field) != INTEGER_CST
1968 || curidx != wi::to_widest (field)))
1970 pp_left_bracket (pp);
1971 if (TREE_CODE (field) == RANGE_EXPR)
1973 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1974 flags, false);
1975 pp_string (pp, " ... ");
1976 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1977 flags, false);
1978 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1979 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1981 else
1982 dump_generic_node (pp, field, spc, flags, false);
1983 if (TREE_CODE (field) == INTEGER_CST)
1984 curidx = wi::to_widest (field);
1985 pp_string (pp, "]=");
1988 if (is_array_init)
1989 curidx += 1;
1990 if (val && TREE_CODE (val) == ADDR_EXPR)
1991 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1992 val = TREE_OPERAND (val, 0);
1993 if (val && TREE_CODE (val) == FUNCTION_DECL)
1994 dump_decl_name (pp, val, flags);
1995 else
1996 dump_generic_node (pp, val, spc, flags, false);
1997 if (ix != CONSTRUCTOR_NELTS (node) - 1)
1999 pp_comma (pp);
2000 pp_space (pp);
2003 pp_right_brace (pp);
2005 break;
2007 case COMPOUND_EXPR:
2009 tree *tp;
2010 if (flags & TDF_SLIM)
2012 pp_string (pp, "<COMPOUND_EXPR>");
2013 break;
2016 dump_generic_node (pp, TREE_OPERAND (node, 0),
2017 spc, flags, !(flags & TDF_SLIM));
2018 if (flags & TDF_SLIM)
2019 newline_and_indent (pp, spc);
2020 else
2022 pp_comma (pp);
2023 pp_space (pp);
2026 for (tp = &TREE_OPERAND (node, 1);
2027 TREE_CODE (*tp) == COMPOUND_EXPR;
2028 tp = &TREE_OPERAND (*tp, 1))
2030 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2031 spc, flags, !(flags & TDF_SLIM));
2032 if (flags & TDF_SLIM)
2033 newline_and_indent (pp, spc);
2034 else
2036 pp_comma (pp);
2037 pp_space (pp);
2041 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2043 break;
2045 case STATEMENT_LIST:
2047 tree_stmt_iterator si;
2048 bool first = true;
2050 if (flags & TDF_SLIM)
2052 pp_string (pp, "<STATEMENT_LIST>");
2053 break;
2056 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2058 if (!first)
2059 newline_and_indent (pp, spc);
2060 else
2061 first = false;
2062 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2065 break;
2067 case MODIFY_EXPR:
2068 case INIT_EXPR:
2069 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2070 false);
2071 pp_space (pp);
2072 pp_equal (pp);
2073 pp_space (pp);
2074 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2075 false);
2076 break;
2078 case TARGET_EXPR:
2079 pp_string (pp, "TARGET_EXPR <");
2080 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2081 pp_comma (pp);
2082 pp_space (pp);
2083 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2084 pp_greater (pp);
2085 break;
2087 case DECL_EXPR:
2088 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2089 is_stmt = false;
2090 break;
2092 case COND_EXPR:
2093 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2095 pp_string (pp, "if (");
2096 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2097 pp_right_paren (pp);
2098 /* The lowered cond_exprs should always be printed in full. */
2099 if (COND_EXPR_THEN (node)
2100 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2101 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2102 && COND_EXPR_ELSE (node)
2103 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2104 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2106 pp_space (pp);
2107 dump_generic_node (pp, COND_EXPR_THEN (node),
2108 0, flags, true);
2109 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2111 pp_string (pp, " else ");
2112 dump_generic_node (pp, COND_EXPR_ELSE (node),
2113 0, flags, true);
2116 else if (!(flags & TDF_SLIM))
2118 /* Output COND_EXPR_THEN. */
2119 if (COND_EXPR_THEN (node))
2121 newline_and_indent (pp, spc+2);
2122 pp_left_brace (pp);
2123 newline_and_indent (pp, spc+4);
2124 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2125 flags, true);
2126 newline_and_indent (pp, spc+2);
2127 pp_right_brace (pp);
2130 /* Output COND_EXPR_ELSE. */
2131 if (COND_EXPR_ELSE (node)
2132 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2134 newline_and_indent (pp, spc);
2135 pp_string (pp, "else");
2136 newline_and_indent (pp, spc+2);
2137 pp_left_brace (pp);
2138 newline_and_indent (pp, spc+4);
2139 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2140 flags, true);
2141 newline_and_indent (pp, spc+2);
2142 pp_right_brace (pp);
2145 is_expr = false;
2147 else
2149 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2150 pp_space (pp);
2151 pp_question (pp);
2152 pp_space (pp);
2153 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2154 pp_space (pp);
2155 pp_colon (pp);
2156 pp_space (pp);
2157 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2159 break;
2161 case BIND_EXPR:
2162 pp_left_brace (pp);
2163 if (!(flags & TDF_SLIM))
2165 if (BIND_EXPR_VARS (node))
2167 pp_newline (pp);
2169 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2171 print_declaration (pp, op0, spc+2, flags);
2172 pp_newline (pp);
2176 newline_and_indent (pp, spc+2);
2177 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2178 newline_and_indent (pp, spc);
2179 pp_right_brace (pp);
2181 is_expr = false;
2182 break;
2184 case CALL_EXPR:
2185 if (CALL_EXPR_FN (node) != NULL_TREE)
2186 print_call_name (pp, CALL_EXPR_FN (node), flags);
2187 else
2188 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2190 /* Print parameters. */
2191 pp_space (pp);
2192 pp_left_paren (pp);
2194 tree arg;
2195 call_expr_arg_iterator iter;
2196 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2198 dump_generic_node (pp, arg, spc, flags, false);
2199 if (more_call_expr_args_p (&iter))
2201 pp_comma (pp);
2202 pp_space (pp);
2206 if (CALL_EXPR_VA_ARG_PACK (node))
2208 if (call_expr_nargs (node) > 0)
2210 pp_comma (pp);
2211 pp_space (pp);
2213 pp_string (pp, "__builtin_va_arg_pack ()");
2215 pp_right_paren (pp);
2217 op1 = CALL_EXPR_STATIC_CHAIN (node);
2218 if (op1)
2220 pp_string (pp, " [static-chain: ");
2221 dump_generic_node (pp, op1, spc, flags, false);
2222 pp_right_bracket (pp);
2225 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2226 pp_string (pp, " [return slot optimization]");
2227 if (CALL_EXPR_TAILCALL (node))
2228 pp_string (pp, " [tail call]");
2229 break;
2231 case WITH_CLEANUP_EXPR:
2232 NIY;
2233 break;
2235 case CLEANUP_POINT_EXPR:
2236 pp_string (pp, "<<cleanup_point ");
2237 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2238 pp_string (pp, ">>");
2239 break;
2241 case PLACEHOLDER_EXPR:
2242 pp_string (pp, "<PLACEHOLDER_EXPR ");
2243 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2244 pp_greater (pp);
2245 break;
2247 /* Binary arithmetic and logic expressions. */
2248 case WIDEN_SUM_EXPR:
2249 case WIDEN_MULT_EXPR:
2250 case MULT_EXPR:
2251 case MULT_HIGHPART_EXPR:
2252 case PLUS_EXPR:
2253 case POINTER_PLUS_EXPR:
2254 case MINUS_EXPR:
2255 case TRUNC_DIV_EXPR:
2256 case CEIL_DIV_EXPR:
2257 case FLOOR_DIV_EXPR:
2258 case ROUND_DIV_EXPR:
2259 case TRUNC_MOD_EXPR:
2260 case CEIL_MOD_EXPR:
2261 case FLOOR_MOD_EXPR:
2262 case ROUND_MOD_EXPR:
2263 case RDIV_EXPR:
2264 case EXACT_DIV_EXPR:
2265 case LSHIFT_EXPR:
2266 case RSHIFT_EXPR:
2267 case LROTATE_EXPR:
2268 case RROTATE_EXPR:
2269 case WIDEN_LSHIFT_EXPR:
2270 case BIT_IOR_EXPR:
2271 case BIT_XOR_EXPR:
2272 case BIT_AND_EXPR:
2273 case TRUTH_ANDIF_EXPR:
2274 case TRUTH_ORIF_EXPR:
2275 case TRUTH_AND_EXPR:
2276 case TRUTH_OR_EXPR:
2277 case TRUTH_XOR_EXPR:
2278 case LT_EXPR:
2279 case LE_EXPR:
2280 case GT_EXPR:
2281 case GE_EXPR:
2282 case EQ_EXPR:
2283 case NE_EXPR:
2284 case UNLT_EXPR:
2285 case UNLE_EXPR:
2286 case UNGT_EXPR:
2287 case UNGE_EXPR:
2288 case UNEQ_EXPR:
2289 case LTGT_EXPR:
2290 case ORDERED_EXPR:
2291 case UNORDERED_EXPR:
2293 const char *op = op_symbol (node);
2294 op0 = TREE_OPERAND (node, 0);
2295 op1 = TREE_OPERAND (node, 1);
2297 /* When the operands are expressions with less priority,
2298 keep semantics of the tree representation. */
2299 if (op_prio (op0) <= op_prio (node))
2301 pp_left_paren (pp);
2302 dump_generic_node (pp, op0, spc, flags, false);
2303 pp_right_paren (pp);
2305 else
2306 dump_generic_node (pp, op0, spc, flags, false);
2308 pp_space (pp);
2309 pp_string (pp, op);
2310 pp_space (pp);
2312 /* When the operands are expressions with less priority,
2313 keep semantics of the tree representation. */
2314 if (op_prio (op1) <= op_prio (node))
2316 pp_left_paren (pp);
2317 dump_generic_node (pp, op1, spc, flags, false);
2318 pp_right_paren (pp);
2320 else
2321 dump_generic_node (pp, op1, spc, flags, false);
2323 break;
2325 /* Unary arithmetic and logic expressions. */
2326 case NEGATE_EXPR:
2327 case BIT_NOT_EXPR:
2328 case TRUTH_NOT_EXPR:
2329 case ADDR_EXPR:
2330 case PREDECREMENT_EXPR:
2331 case PREINCREMENT_EXPR:
2332 case INDIRECT_REF:
2333 if (TREE_CODE (node) == ADDR_EXPR
2334 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2335 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2336 ; /* Do not output '&' for strings and function pointers. */
2337 else
2338 pp_string (pp, op_symbol (node));
2340 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2342 pp_left_paren (pp);
2343 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2344 pp_right_paren (pp);
2346 else
2347 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2348 break;
2350 case POSTDECREMENT_EXPR:
2351 case POSTINCREMENT_EXPR:
2352 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2354 pp_left_paren (pp);
2355 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2356 pp_right_paren (pp);
2358 else
2359 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2360 pp_string (pp, op_symbol (node));
2361 break;
2363 case MIN_EXPR:
2364 pp_string (pp, "MIN_EXPR <");
2365 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2366 pp_string (pp, ", ");
2367 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2368 pp_greater (pp);
2369 break;
2371 case MAX_EXPR:
2372 pp_string (pp, "MAX_EXPR <");
2373 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2374 pp_string (pp, ", ");
2375 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2376 pp_greater (pp);
2377 break;
2379 case ABS_EXPR:
2380 pp_string (pp, "ABS_EXPR <");
2381 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2382 pp_greater (pp);
2383 break;
2385 case RANGE_EXPR:
2386 NIY;
2387 break;
2389 case ADDR_SPACE_CONVERT_EXPR:
2390 case FIXED_CONVERT_EXPR:
2391 case FIX_TRUNC_EXPR:
2392 case FLOAT_EXPR:
2393 CASE_CONVERT:
2394 type = TREE_TYPE (node);
2395 op0 = TREE_OPERAND (node, 0);
2396 if (type != TREE_TYPE (op0))
2398 pp_left_paren (pp);
2399 dump_generic_node (pp, type, spc, flags, false);
2400 pp_string (pp, ") ");
2402 if (op_prio (op0) < op_prio (node))
2403 pp_left_paren (pp);
2404 dump_generic_node (pp, op0, spc, flags, false);
2405 if (op_prio (op0) < op_prio (node))
2406 pp_right_paren (pp);
2407 break;
2409 case VIEW_CONVERT_EXPR:
2410 pp_string (pp, "VIEW_CONVERT_EXPR<");
2411 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2412 pp_string (pp, ">(");
2413 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2414 pp_right_paren (pp);
2415 break;
2417 case PAREN_EXPR:
2418 pp_string (pp, "((");
2419 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2420 pp_string (pp, "))");
2421 break;
2423 case NON_LVALUE_EXPR:
2424 pp_string (pp, "NON_LVALUE_EXPR <");
2425 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2426 pp_greater (pp);
2427 break;
2429 case SAVE_EXPR:
2430 pp_string (pp, "SAVE_EXPR <");
2431 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2432 pp_greater (pp);
2433 break;
2435 case COMPLEX_EXPR:
2436 pp_string (pp, "COMPLEX_EXPR <");
2437 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2438 pp_string (pp, ", ");
2439 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2440 pp_greater (pp);
2441 break;
2443 case CONJ_EXPR:
2444 pp_string (pp, "CONJ_EXPR <");
2445 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2446 pp_greater (pp);
2447 break;
2449 case REALPART_EXPR:
2450 pp_string (pp, "REALPART_EXPR <");
2451 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2452 pp_greater (pp);
2453 break;
2455 case IMAGPART_EXPR:
2456 pp_string (pp, "IMAGPART_EXPR <");
2457 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2458 pp_greater (pp);
2459 break;
2461 case VA_ARG_EXPR:
2462 pp_string (pp, "VA_ARG_EXPR <");
2463 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2464 pp_greater (pp);
2465 break;
2467 case TRY_FINALLY_EXPR:
2468 case TRY_CATCH_EXPR:
2469 pp_string (pp, "try");
2470 newline_and_indent (pp, spc+2);
2471 pp_left_brace (pp);
2472 newline_and_indent (pp, spc+4);
2473 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2474 newline_and_indent (pp, spc+2);
2475 pp_right_brace (pp);
2476 newline_and_indent (pp, spc);
2477 pp_string (pp,
2478 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2479 newline_and_indent (pp, spc+2);
2480 pp_left_brace (pp);
2481 newline_and_indent (pp, spc+4);
2482 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2483 newline_and_indent (pp, spc+2);
2484 pp_right_brace (pp);
2485 is_expr = false;
2486 break;
2488 case CATCH_EXPR:
2489 pp_string (pp, "catch (");
2490 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2491 pp_right_paren (pp);
2492 newline_and_indent (pp, spc+2);
2493 pp_left_brace (pp);
2494 newline_and_indent (pp, spc+4);
2495 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2496 newline_and_indent (pp, spc+2);
2497 pp_right_brace (pp);
2498 is_expr = false;
2499 break;
2501 case EH_FILTER_EXPR:
2502 pp_string (pp, "<<<eh_filter (");
2503 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2504 pp_string (pp, ")>>>");
2505 newline_and_indent (pp, spc+2);
2506 pp_left_brace (pp);
2507 newline_and_indent (pp, spc+4);
2508 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2509 newline_and_indent (pp, spc+2);
2510 pp_right_brace (pp);
2511 is_expr = false;
2512 break;
2514 case LABEL_EXPR:
2515 op0 = TREE_OPERAND (node, 0);
2516 /* If this is for break or continue, don't bother printing it. */
2517 if (DECL_NAME (op0))
2519 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2520 if (strcmp (name, "break") == 0
2521 || strcmp (name, "continue") == 0)
2522 break;
2524 dump_generic_node (pp, op0, spc, flags, false);
2525 pp_colon (pp);
2526 if (DECL_NONLOCAL (op0))
2527 pp_string (pp, " [non-local]");
2528 break;
2530 case LOOP_EXPR:
2531 pp_string (pp, "while (1)");
2532 if (!(flags & TDF_SLIM))
2534 newline_and_indent (pp, spc+2);
2535 pp_left_brace (pp);
2536 newline_and_indent (pp, spc+4);
2537 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2538 newline_and_indent (pp, spc+2);
2539 pp_right_brace (pp);
2541 is_expr = false;
2542 break;
2544 case PREDICT_EXPR:
2545 pp_string (pp, "// predicted ");
2546 if (PREDICT_EXPR_OUTCOME (node))
2547 pp_string (pp, "likely by ");
2548 else
2549 pp_string (pp, "unlikely by ");
2550 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2551 pp_string (pp, " predictor.");
2552 break;
2554 case ANNOTATE_EXPR:
2555 pp_string (pp, "ANNOTATE_EXPR <");
2556 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2557 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2559 case annot_expr_ivdep_kind:
2560 pp_string (pp, ", ivdep");
2561 break;
2562 case annot_expr_no_vector_kind:
2563 pp_string (pp, ", no-vector");
2564 break;
2565 case annot_expr_vector_kind:
2566 pp_string (pp, ", vector");
2567 break;
2568 default:
2569 gcc_unreachable ();
2571 pp_greater (pp);
2572 break;
2574 case RETURN_EXPR:
2575 pp_string (pp, "return");
2576 op0 = TREE_OPERAND (node, 0);
2577 if (op0)
2579 pp_space (pp);
2580 if (TREE_CODE (op0) == MODIFY_EXPR)
2581 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2582 spc, flags, false);
2583 else
2584 dump_generic_node (pp, op0, spc, flags, false);
2586 break;
2588 case EXIT_EXPR:
2589 pp_string (pp, "if (");
2590 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2591 pp_string (pp, ") break");
2592 break;
2594 case SWITCH_EXPR:
2595 pp_string (pp, "switch (");
2596 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2597 pp_right_paren (pp);
2598 if (!(flags & TDF_SLIM))
2600 newline_and_indent (pp, spc+2);
2601 pp_left_brace (pp);
2602 if (SWITCH_BODY (node))
2604 newline_and_indent (pp, spc+4);
2605 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2606 true);
2608 else
2610 tree vec = SWITCH_LABELS (node);
2611 size_t i, n = TREE_VEC_LENGTH (vec);
2612 for (i = 0; i < n; ++i)
2614 tree elt = TREE_VEC_ELT (vec, i);
2615 newline_and_indent (pp, spc+4);
2616 if (elt)
2618 dump_generic_node (pp, elt, spc+4, flags, false);
2619 pp_string (pp, " goto ");
2620 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2621 flags, true);
2622 pp_semicolon (pp);
2624 else
2625 pp_string (pp, "case ???: goto ???;");
2628 newline_and_indent (pp, spc+2);
2629 pp_right_brace (pp);
2631 is_expr = false;
2632 break;
2634 case GOTO_EXPR:
2635 op0 = GOTO_DESTINATION (node);
2636 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2638 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2639 if (strcmp (name, "break") == 0
2640 || strcmp (name, "continue") == 0)
2642 pp_string (pp, name);
2643 break;
2646 pp_string (pp, "goto ");
2647 dump_generic_node (pp, op0, spc, flags, false);
2648 break;
2650 case ASM_EXPR:
2651 pp_string (pp, "__asm__");
2652 if (ASM_VOLATILE_P (node))
2653 pp_string (pp, " __volatile__");
2654 pp_left_paren (pp);
2655 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2656 pp_colon (pp);
2657 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2658 pp_colon (pp);
2659 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2660 if (ASM_CLOBBERS (node))
2662 pp_colon (pp);
2663 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2665 pp_right_paren (pp);
2666 break;
2668 case CASE_LABEL_EXPR:
2669 if (CASE_LOW (node) && CASE_HIGH (node))
2671 pp_string (pp, "case ");
2672 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2673 pp_string (pp, " ... ");
2674 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2676 else if (CASE_LOW (node))
2678 pp_string (pp, "case ");
2679 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2681 else
2682 pp_string (pp, "default");
2683 pp_colon (pp);
2684 break;
2686 case OBJ_TYPE_REF:
2687 pp_string (pp, "OBJ_TYPE_REF(");
2688 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2689 pp_semicolon (pp);
2690 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2692 pp_string (pp, "(");
2693 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2694 pp_string (pp, ")");
2696 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2697 pp_arrow (pp);
2698 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2699 pp_right_paren (pp);
2700 break;
2702 case SSA_NAME:
2703 if (SSA_NAME_IDENTIFIER (node))
2705 if ((flags & TDF_NOUID)
2706 && SSA_NAME_VAR (node)
2707 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2708 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2709 else if (! (flags & TDF_GIMPLE)
2710 || SSA_NAME_VAR (node))
2711 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2712 spc, flags, false);
2714 pp_underscore (pp);
2715 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2716 if (SSA_NAME_IS_DEFAULT_DEF (node))
2717 pp_string (pp, "(D)");
2718 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2719 pp_string (pp, "(ab)");
2720 break;
2722 case WITH_SIZE_EXPR:
2723 pp_string (pp, "WITH_SIZE_EXPR <");
2724 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2725 pp_string (pp, ", ");
2726 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2727 pp_greater (pp);
2728 break;
2730 case ASSERT_EXPR:
2731 pp_string (pp, "ASSERT_EXPR <");
2732 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2733 pp_string (pp, ", ");
2734 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2735 pp_greater (pp);
2736 break;
2738 case SCEV_KNOWN:
2739 pp_string (pp, "scev_known");
2740 break;
2742 case SCEV_NOT_KNOWN:
2743 pp_string (pp, "scev_not_known");
2744 break;
2746 case POLYNOMIAL_CHREC:
2747 pp_left_brace (pp);
2748 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2749 pp_string (pp, ", +, ");
2750 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2751 pp_string (pp, "}_");
2752 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2753 is_stmt = false;
2754 break;
2756 case REALIGN_LOAD_EXPR:
2757 pp_string (pp, "REALIGN_LOAD <");
2758 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2759 pp_string (pp, ", ");
2760 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2761 pp_string (pp, ", ");
2762 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2763 pp_greater (pp);
2764 break;
2766 case VEC_COND_EXPR:
2767 pp_string (pp, " VEC_COND_EXPR < ");
2768 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2769 pp_string (pp, " , ");
2770 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2771 pp_string (pp, " , ");
2772 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2773 pp_string (pp, " > ");
2774 break;
2776 case VEC_PERM_EXPR:
2777 pp_string (pp, " VEC_PERM_EXPR < ");
2778 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2779 pp_string (pp, " , ");
2780 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2781 pp_string (pp, " , ");
2782 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2783 pp_string (pp, " > ");
2784 break;
2786 case DOT_PROD_EXPR:
2787 pp_string (pp, " DOT_PROD_EXPR < ");
2788 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2789 pp_string (pp, ", ");
2790 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2791 pp_string (pp, ", ");
2792 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2793 pp_string (pp, " > ");
2794 break;
2796 case WIDEN_MULT_PLUS_EXPR:
2797 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2798 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2799 pp_string (pp, ", ");
2800 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2801 pp_string (pp, ", ");
2802 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2803 pp_string (pp, " > ");
2804 break;
2806 case WIDEN_MULT_MINUS_EXPR:
2807 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2808 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2809 pp_string (pp, ", ");
2810 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2811 pp_string (pp, ", ");
2812 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2813 pp_string (pp, " > ");
2814 break;
2816 case FMA_EXPR:
2817 pp_string (pp, " FMA_EXPR < ");
2818 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2819 pp_string (pp, ", ");
2820 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2821 pp_string (pp, ", ");
2822 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2823 pp_string (pp, " > ");
2824 break;
2826 case OACC_PARALLEL:
2827 pp_string (pp, "#pragma acc parallel");
2828 goto dump_omp_clauses_body;
2830 case OACC_KERNELS:
2831 pp_string (pp, "#pragma acc kernels");
2832 goto dump_omp_clauses_body;
2834 case OACC_DATA:
2835 pp_string (pp, "#pragma acc data");
2836 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2837 goto dump_omp_body;
2839 case OACC_HOST_DATA:
2840 pp_string (pp, "#pragma acc host_data");
2841 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2842 goto dump_omp_body;
2844 case OACC_DECLARE:
2845 pp_string (pp, "#pragma acc declare");
2846 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2847 break;
2849 case OACC_UPDATE:
2850 pp_string (pp, "#pragma acc update");
2851 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2852 break;
2854 case OACC_ENTER_DATA:
2855 pp_string (pp, "#pragma acc enter data");
2856 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2857 break;
2859 case OACC_EXIT_DATA:
2860 pp_string (pp, "#pragma acc exit data");
2861 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2862 break;
2864 case OACC_CACHE:
2865 pp_string (pp, "#pragma acc cache");
2866 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2867 break;
2869 case OMP_PARALLEL:
2870 pp_string (pp, "#pragma omp parallel");
2871 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2872 goto dump_omp_body;
2874 dump_omp_clauses_body:
2875 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2876 goto dump_omp_body;
2878 dump_omp_body:
2879 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2881 newline_and_indent (pp, spc + 2);
2882 pp_left_brace (pp);
2883 newline_and_indent (pp, spc + 4);
2884 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2885 newline_and_indent (pp, spc + 2);
2886 pp_right_brace (pp);
2888 is_expr = false;
2889 break;
2891 case OMP_TASK:
2892 pp_string (pp, "#pragma omp task");
2893 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2894 goto dump_omp_body;
2896 case OMP_FOR:
2897 pp_string (pp, "#pragma omp for");
2898 goto dump_omp_loop;
2900 case OMP_SIMD:
2901 pp_string (pp, "#pragma omp simd");
2902 goto dump_omp_loop;
2904 case CILK_SIMD:
2905 pp_string (pp, "#pragma simd");
2906 goto dump_omp_loop;
2908 case CILK_FOR:
2909 /* This label points one line after dumping the clauses.
2910 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2911 parameters are printed out. */
2912 goto dump_omp_loop_cilk_for;
2914 case OMP_DISTRIBUTE:
2915 pp_string (pp, "#pragma omp distribute");
2916 goto dump_omp_loop;
2918 case OMP_TASKLOOP:
2919 pp_string (pp, "#pragma omp taskloop");
2920 goto dump_omp_loop;
2922 case OACC_LOOP:
2923 pp_string (pp, "#pragma acc loop");
2924 goto dump_omp_loop;
2926 case OMP_TEAMS:
2927 pp_string (pp, "#pragma omp teams");
2928 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2929 goto dump_omp_body;
2931 case OMP_TARGET_DATA:
2932 pp_string (pp, "#pragma omp target data");
2933 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2934 goto dump_omp_body;
2936 case OMP_TARGET_ENTER_DATA:
2937 pp_string (pp, "#pragma omp target enter data");
2938 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
2939 is_expr = false;
2940 break;
2942 case OMP_TARGET_EXIT_DATA:
2943 pp_string (pp, "#pragma omp target exit data");
2944 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
2945 is_expr = false;
2946 break;
2948 case OMP_TARGET:
2949 pp_string (pp, "#pragma omp target");
2950 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2951 goto dump_omp_body;
2953 case OMP_TARGET_UPDATE:
2954 pp_string (pp, "#pragma omp target update");
2955 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2956 is_expr = false;
2957 break;
2959 dump_omp_loop:
2960 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2962 dump_omp_loop_cilk_for:
2963 if (!(flags & TDF_SLIM))
2965 int i;
2967 if (OMP_FOR_PRE_BODY (node))
2969 if (TREE_CODE (node) == CILK_FOR)
2970 pp_string (pp, " ");
2971 else
2972 newline_and_indent (pp, spc + 2);
2973 pp_left_brace (pp);
2974 spc += 4;
2975 newline_and_indent (pp, spc);
2976 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2977 spc, flags, false);
2979 if (OMP_FOR_INIT (node))
2981 spc -= 2;
2982 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2984 spc += 2;
2985 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2986 newline_and_indent (pp, spc);
2987 if (TREE_CODE (node) == CILK_FOR)
2988 pp_string (pp, "_Cilk_for (");
2989 else
2990 pp_string (pp, "for (");
2991 dump_generic_node (pp,
2992 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2993 spc, flags, false);
2994 pp_string (pp, "; ");
2995 dump_generic_node (pp,
2996 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2997 spc, flags, false);
2998 pp_string (pp, "; ");
2999 dump_generic_node (pp,
3000 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3001 spc, flags, false);
3002 pp_right_paren (pp);
3004 if (TREE_CODE (node) == CILK_FOR)
3005 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3007 if (OMP_FOR_BODY (node))
3009 newline_and_indent (pp, spc + 2);
3010 pp_left_brace (pp);
3011 newline_and_indent (pp, spc + 4);
3012 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3013 false);
3014 newline_and_indent (pp, spc + 2);
3015 pp_right_brace (pp);
3017 if (OMP_FOR_INIT (node))
3018 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3019 if (OMP_FOR_PRE_BODY (node))
3021 spc -= 4;
3022 newline_and_indent (pp, spc + 2);
3023 pp_right_brace (pp);
3026 is_expr = false;
3027 break;
3029 case OMP_SECTIONS:
3030 pp_string (pp, "#pragma omp sections");
3031 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3032 goto dump_omp_body;
3034 case OMP_SECTION:
3035 pp_string (pp, "#pragma omp section");
3036 goto dump_omp_body;
3038 case OMP_MASTER:
3039 pp_string (pp, "#pragma omp master");
3040 goto dump_omp_body;
3042 case OMP_TASKGROUP:
3043 pp_string (pp, "#pragma omp taskgroup");
3044 goto dump_omp_body;
3046 case OMP_ORDERED:
3047 pp_string (pp, "#pragma omp ordered");
3048 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3049 goto dump_omp_body;
3051 case OMP_CRITICAL:
3052 pp_string (pp, "#pragma omp critical");
3053 if (OMP_CRITICAL_NAME (node))
3055 pp_space (pp);
3056 pp_left_paren (pp);
3057 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3058 flags, false);
3059 pp_right_paren (pp);
3061 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3062 goto dump_omp_body;
3064 case OMP_ATOMIC:
3065 pp_string (pp, "#pragma omp atomic");
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 pp_equal (pp);
3072 pp_space (pp);
3073 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3074 break;
3076 case OMP_ATOMIC_READ:
3077 pp_string (pp, "#pragma omp atomic read");
3078 if (OMP_ATOMIC_SEQ_CST (node))
3079 pp_string (pp, " seq_cst");
3080 newline_and_indent (pp, spc + 2);
3081 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3082 pp_space (pp);
3083 break;
3085 case OMP_ATOMIC_CAPTURE_OLD:
3086 case OMP_ATOMIC_CAPTURE_NEW:
3087 pp_string (pp, "#pragma omp atomic capture");
3088 if (OMP_ATOMIC_SEQ_CST (node))
3089 pp_string (pp, " seq_cst");
3090 newline_and_indent (pp, spc + 2);
3091 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3092 pp_space (pp);
3093 pp_equal (pp);
3094 pp_space (pp);
3095 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3096 break;
3098 case OMP_SINGLE:
3099 pp_string (pp, "#pragma omp single");
3100 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3101 goto dump_omp_body;
3103 case OMP_CLAUSE:
3104 dump_omp_clause (pp, node, spc, flags);
3105 is_expr = false;
3106 break;
3108 case TRANSACTION_EXPR:
3109 if (TRANSACTION_EXPR_OUTER (node))
3110 pp_string (pp, "__transaction_atomic [[outer]]");
3111 else if (TRANSACTION_EXPR_RELAXED (node))
3112 pp_string (pp, "__transaction_relaxed");
3113 else
3114 pp_string (pp, "__transaction_atomic");
3115 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3117 newline_and_indent (pp, spc);
3118 pp_left_brace (pp);
3119 newline_and_indent (pp, spc + 2);
3120 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3121 spc + 2, flags, false);
3122 newline_and_indent (pp, spc);
3123 pp_right_brace (pp);
3125 is_expr = false;
3126 break;
3128 case REDUC_MAX_EXPR:
3129 pp_string (pp, " REDUC_MAX_EXPR < ");
3130 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3131 pp_string (pp, " > ");
3132 break;
3134 case REDUC_MIN_EXPR:
3135 pp_string (pp, " REDUC_MIN_EXPR < ");
3136 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3137 pp_string (pp, " > ");
3138 break;
3140 case REDUC_PLUS_EXPR:
3141 pp_string (pp, " REDUC_PLUS_EXPR < ");
3142 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3143 pp_string (pp, " > ");
3144 break;
3146 case VEC_WIDEN_MULT_HI_EXPR:
3147 case VEC_WIDEN_MULT_LO_EXPR:
3148 case VEC_WIDEN_MULT_EVEN_EXPR:
3149 case VEC_WIDEN_MULT_ODD_EXPR:
3150 case VEC_WIDEN_LSHIFT_HI_EXPR:
3151 case VEC_WIDEN_LSHIFT_LO_EXPR:
3152 pp_space (pp);
3153 for (str = get_tree_code_name (code); *str; str++)
3154 pp_character (pp, TOUPPER (*str));
3155 pp_string (pp, " < ");
3156 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3157 pp_string (pp, ", ");
3158 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3159 pp_string (pp, " > ");
3160 break;
3162 case VEC_UNPACK_HI_EXPR:
3163 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3165 pp_string (pp, " > ");
3166 break;
3168 case VEC_UNPACK_LO_EXPR:
3169 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3170 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3171 pp_string (pp, " > ");
3172 break;
3174 case VEC_UNPACK_FLOAT_HI_EXPR:
3175 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3176 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3177 pp_string (pp, " > ");
3178 break;
3180 case VEC_UNPACK_FLOAT_LO_EXPR:
3181 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3182 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3183 pp_string (pp, " > ");
3184 break;
3186 case VEC_PACK_TRUNC_EXPR:
3187 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3188 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3189 pp_string (pp, ", ");
3190 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3191 pp_string (pp, " > ");
3192 break;
3194 case VEC_PACK_SAT_EXPR:
3195 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3196 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3197 pp_string (pp, ", ");
3198 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3199 pp_string (pp, " > ");
3200 break;
3202 case VEC_PACK_FIX_TRUNC_EXPR:
3203 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3204 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3205 pp_string (pp, ", ");
3206 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3207 pp_string (pp, " > ");
3208 break;
3210 case BLOCK:
3211 dump_block_node (pp, node, spc, flags);
3212 break;
3214 case CILK_SPAWN_STMT:
3215 pp_string (pp, "_Cilk_spawn ");
3216 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3217 break;
3219 case CILK_SYNC_STMT:
3220 pp_string (pp, "_Cilk_sync");
3221 break;
3223 default:
3224 NIY;
3227 if (is_stmt && is_expr)
3228 pp_semicolon (pp);
3230 return spc;
3233 /* Print the declaration of a variable. */
3235 void
3236 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
3238 INDENT (spc);
3240 if (TREE_CODE(t) == NAMELIST_DECL)
3242 pp_string(pp, "namelist ");
3243 dump_decl_name (pp, t, flags);
3244 pp_semicolon (pp);
3245 return;
3248 if (TREE_CODE (t) == TYPE_DECL)
3249 pp_string (pp, "typedef ");
3251 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3252 pp_string (pp, "register ");
3254 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3255 pp_string (pp, "extern ");
3256 else if (TREE_STATIC (t))
3257 pp_string (pp, "static ");
3259 /* Print the type and name. */
3260 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3262 tree tmp;
3264 /* Print array's type. */
3265 tmp = TREE_TYPE (t);
3266 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3267 tmp = TREE_TYPE (tmp);
3268 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3270 /* Print variable's name. */
3271 pp_space (pp);
3272 dump_generic_node (pp, t, spc, flags, false);
3274 /* Print the dimensions. */
3275 tmp = TREE_TYPE (t);
3276 while (TREE_CODE (tmp) == ARRAY_TYPE)
3278 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3279 tmp = TREE_TYPE (tmp);
3282 else if (TREE_CODE (t) == FUNCTION_DECL)
3284 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3285 pp_space (pp);
3286 dump_decl_name (pp, t, flags);
3287 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3289 else
3291 /* Print type declaration. */
3292 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3294 /* Print variable's name. */
3295 pp_space (pp);
3296 dump_generic_node (pp, t, spc, flags, false);
3299 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3301 pp_string (pp, " __asm__ ");
3302 pp_left_paren (pp);
3303 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3304 pp_right_paren (pp);
3307 /* The initial value of a function serves to determine whether the function
3308 is declared or defined. So the following does not apply to function
3309 nodes. */
3310 if (TREE_CODE (t) != FUNCTION_DECL)
3312 /* Print the initial value. */
3313 if (DECL_INITIAL (t))
3315 pp_space (pp);
3316 pp_equal (pp);
3317 pp_space (pp);
3318 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3322 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3324 pp_string (pp, " [value-expr: ");
3325 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3326 pp_right_bracket (pp);
3329 pp_semicolon (pp);
3333 /* Prints a structure: name, fields, and methods.
3334 FIXME: Still incomplete. */
3336 static void
3337 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3339 /* Print the name of the structure. */
3340 if (TYPE_NAME (node))
3342 INDENT (spc);
3343 if (TREE_CODE (node) == RECORD_TYPE)
3344 pp_string (pp, "struct ");
3345 else if ((TREE_CODE (node) == UNION_TYPE
3346 || TREE_CODE (node) == QUAL_UNION_TYPE))
3347 pp_string (pp, "union ");
3349 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3352 /* Print the contents of the structure. */
3353 pp_newline (pp);
3354 INDENT (spc);
3355 pp_left_brace (pp);
3356 pp_newline (pp);
3358 /* Print the fields of the structure. */
3360 tree tmp;
3361 tmp = TYPE_FIELDS (node);
3362 while (tmp)
3364 /* Avoid to print recursively the structure. */
3365 /* FIXME : Not implemented correctly...,
3366 what about the case when we have a cycle in the contain graph? ...
3367 Maybe this could be solved by looking at the scope in which the
3368 structure was declared. */
3369 if (TREE_TYPE (tmp) != node
3370 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3371 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3373 print_declaration (pp, tmp, spc+2, flags);
3374 pp_newline (pp);
3376 tmp = DECL_CHAIN (tmp);
3379 INDENT (spc);
3380 pp_right_brace (pp);
3383 /* Return the priority of the operator CODE.
3385 From lowest to highest precedence with either left-to-right (L-R)
3386 or right-to-left (R-L) associativity]:
3388 1 [L-R] ,
3389 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3390 3 [R-L] ?:
3391 4 [L-R] ||
3392 5 [L-R] &&
3393 6 [L-R] |
3394 7 [L-R] ^
3395 8 [L-R] &
3396 9 [L-R] == !=
3397 10 [L-R] < <= > >=
3398 11 [L-R] << >>
3399 12 [L-R] + -
3400 13 [L-R] * / %
3401 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3402 15 [L-R] fn() [] -> .
3404 unary +, - and * have higher precedence than the corresponding binary
3405 operators. */
3408 op_code_prio (enum tree_code code)
3410 switch (code)
3412 case TREE_LIST:
3413 case COMPOUND_EXPR:
3414 case BIND_EXPR:
3415 return 1;
3417 case MODIFY_EXPR:
3418 case INIT_EXPR:
3419 return 2;
3421 case COND_EXPR:
3422 return 3;
3424 case TRUTH_OR_EXPR:
3425 case TRUTH_ORIF_EXPR:
3426 return 4;
3428 case TRUTH_AND_EXPR:
3429 case TRUTH_ANDIF_EXPR:
3430 return 5;
3432 case BIT_IOR_EXPR:
3433 return 6;
3435 case BIT_XOR_EXPR:
3436 case TRUTH_XOR_EXPR:
3437 return 7;
3439 case BIT_AND_EXPR:
3440 return 8;
3442 case EQ_EXPR:
3443 case NE_EXPR:
3444 return 9;
3446 case UNLT_EXPR:
3447 case UNLE_EXPR:
3448 case UNGT_EXPR:
3449 case UNGE_EXPR:
3450 case UNEQ_EXPR:
3451 case LTGT_EXPR:
3452 case ORDERED_EXPR:
3453 case UNORDERED_EXPR:
3454 case LT_EXPR:
3455 case LE_EXPR:
3456 case GT_EXPR:
3457 case GE_EXPR:
3458 return 10;
3460 case LSHIFT_EXPR:
3461 case RSHIFT_EXPR:
3462 case LROTATE_EXPR:
3463 case RROTATE_EXPR:
3464 case VEC_WIDEN_LSHIFT_HI_EXPR:
3465 case VEC_WIDEN_LSHIFT_LO_EXPR:
3466 case WIDEN_LSHIFT_EXPR:
3467 return 11;
3469 case WIDEN_SUM_EXPR:
3470 case PLUS_EXPR:
3471 case POINTER_PLUS_EXPR:
3472 case MINUS_EXPR:
3473 return 12;
3475 case VEC_WIDEN_MULT_HI_EXPR:
3476 case VEC_WIDEN_MULT_LO_EXPR:
3477 case WIDEN_MULT_EXPR:
3478 case DOT_PROD_EXPR:
3479 case WIDEN_MULT_PLUS_EXPR:
3480 case WIDEN_MULT_MINUS_EXPR:
3481 case MULT_EXPR:
3482 case MULT_HIGHPART_EXPR:
3483 case TRUNC_DIV_EXPR:
3484 case CEIL_DIV_EXPR:
3485 case FLOOR_DIV_EXPR:
3486 case ROUND_DIV_EXPR:
3487 case RDIV_EXPR:
3488 case EXACT_DIV_EXPR:
3489 case TRUNC_MOD_EXPR:
3490 case CEIL_MOD_EXPR:
3491 case FLOOR_MOD_EXPR:
3492 case ROUND_MOD_EXPR:
3493 case FMA_EXPR:
3494 return 13;
3496 case TRUTH_NOT_EXPR:
3497 case BIT_NOT_EXPR:
3498 case POSTINCREMENT_EXPR:
3499 case POSTDECREMENT_EXPR:
3500 case PREINCREMENT_EXPR:
3501 case PREDECREMENT_EXPR:
3502 case NEGATE_EXPR:
3503 case INDIRECT_REF:
3504 case ADDR_EXPR:
3505 case FLOAT_EXPR:
3506 CASE_CONVERT:
3507 case FIX_TRUNC_EXPR:
3508 case TARGET_EXPR:
3509 return 14;
3511 case CALL_EXPR:
3512 case ARRAY_REF:
3513 case ARRAY_RANGE_REF:
3514 case COMPONENT_REF:
3515 return 15;
3517 /* Special expressions. */
3518 case MIN_EXPR:
3519 case MAX_EXPR:
3520 case ABS_EXPR:
3521 case REALPART_EXPR:
3522 case IMAGPART_EXPR:
3523 case REDUC_MAX_EXPR:
3524 case REDUC_MIN_EXPR:
3525 case REDUC_PLUS_EXPR:
3526 case VEC_UNPACK_HI_EXPR:
3527 case VEC_UNPACK_LO_EXPR:
3528 case VEC_UNPACK_FLOAT_HI_EXPR:
3529 case VEC_UNPACK_FLOAT_LO_EXPR:
3530 case VEC_PACK_TRUNC_EXPR:
3531 case VEC_PACK_SAT_EXPR:
3532 return 16;
3534 default:
3535 /* Return an arbitrarily high precedence to avoid surrounding single
3536 VAR_DECLs in ()s. */
3537 return 9999;
3541 /* Return the priority of the operator OP. */
3544 op_prio (const_tree op)
3546 enum tree_code code;
3548 if (op == NULL)
3549 return 9999;
3551 code = TREE_CODE (op);
3552 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3553 return op_prio (TREE_OPERAND (op, 0));
3555 return op_code_prio (code);
3558 /* Return the symbol associated with operator CODE. */
3560 const char *
3561 op_symbol_code (enum tree_code code)
3563 switch (code)
3565 case MODIFY_EXPR:
3566 return "=";
3568 case TRUTH_OR_EXPR:
3569 case TRUTH_ORIF_EXPR:
3570 return "||";
3572 case TRUTH_AND_EXPR:
3573 case TRUTH_ANDIF_EXPR:
3574 return "&&";
3576 case BIT_IOR_EXPR:
3577 return "|";
3579 case TRUTH_XOR_EXPR:
3580 case BIT_XOR_EXPR:
3581 return "^";
3583 case ADDR_EXPR:
3584 case BIT_AND_EXPR:
3585 return "&";
3587 case ORDERED_EXPR:
3588 return "ord";
3589 case UNORDERED_EXPR:
3590 return "unord";
3592 case EQ_EXPR:
3593 return "==";
3594 case UNEQ_EXPR:
3595 return "u==";
3597 case NE_EXPR:
3598 return "!=";
3600 case LT_EXPR:
3601 return "<";
3602 case UNLT_EXPR:
3603 return "u<";
3605 case LE_EXPR:
3606 return "<=";
3607 case UNLE_EXPR:
3608 return "u<=";
3610 case GT_EXPR:
3611 return ">";
3612 case UNGT_EXPR:
3613 return "u>";
3615 case GE_EXPR:
3616 return ">=";
3617 case UNGE_EXPR:
3618 return "u>=";
3620 case LTGT_EXPR:
3621 return "<>";
3623 case LSHIFT_EXPR:
3624 return "<<";
3626 case RSHIFT_EXPR:
3627 return ">>";
3629 case LROTATE_EXPR:
3630 return "r<<";
3632 case RROTATE_EXPR:
3633 return "r>>";
3635 case WIDEN_LSHIFT_EXPR:
3636 return "w<<";
3638 case POINTER_PLUS_EXPR:
3639 return "+";
3641 case PLUS_EXPR:
3642 return "+";
3644 case REDUC_PLUS_EXPR:
3645 return "r+";
3647 case WIDEN_SUM_EXPR:
3648 return "w+";
3650 case WIDEN_MULT_EXPR:
3651 return "w*";
3653 case MULT_HIGHPART_EXPR:
3654 return "h*";
3656 case NEGATE_EXPR:
3657 case MINUS_EXPR:
3658 return "-";
3660 case BIT_NOT_EXPR:
3661 return "~";
3663 case TRUTH_NOT_EXPR:
3664 return "!";
3666 case MULT_EXPR:
3667 case INDIRECT_REF:
3668 return "*";
3670 case TRUNC_DIV_EXPR:
3671 case RDIV_EXPR:
3672 return "/";
3674 case CEIL_DIV_EXPR:
3675 return "/[cl]";
3677 case FLOOR_DIV_EXPR:
3678 return "/[fl]";
3680 case ROUND_DIV_EXPR:
3681 return "/[rd]";
3683 case EXACT_DIV_EXPR:
3684 return "/[ex]";
3686 case TRUNC_MOD_EXPR:
3687 return "%";
3689 case CEIL_MOD_EXPR:
3690 return "%[cl]";
3692 case FLOOR_MOD_EXPR:
3693 return "%[fl]";
3695 case ROUND_MOD_EXPR:
3696 return "%[rd]";
3698 case PREDECREMENT_EXPR:
3699 return " --";
3701 case PREINCREMENT_EXPR:
3702 return " ++";
3704 case POSTDECREMENT_EXPR:
3705 return "-- ";
3707 case POSTINCREMENT_EXPR:
3708 return "++ ";
3710 case MAX_EXPR:
3711 return "max";
3713 case MIN_EXPR:
3714 return "min";
3716 default:
3717 return "<<< ??? >>>";
3721 /* Return the symbol associated with operator OP. */
3723 static const char *
3724 op_symbol (const_tree op)
3726 return op_symbol_code (TREE_CODE (op));
3729 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3730 the gimple_call_fn of a GIMPLE_CALL. */
3732 void
3733 print_call_name (pretty_printer *pp, tree node, int flags)
3735 tree op0 = node;
3737 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3738 op0 = TREE_OPERAND (op0, 0);
3740 again:
3741 switch (TREE_CODE (op0))
3743 case VAR_DECL:
3744 case PARM_DECL:
3745 case FUNCTION_DECL:
3746 dump_function_name (pp, op0, flags);
3747 break;
3749 case ADDR_EXPR:
3750 case INDIRECT_REF:
3751 CASE_CONVERT:
3752 op0 = TREE_OPERAND (op0, 0);
3753 goto again;
3755 case COND_EXPR:
3756 pp_left_paren (pp);
3757 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3758 pp_string (pp, ") ? ");
3759 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3760 pp_string (pp, " : ");
3761 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3762 break;
3764 case ARRAY_REF:
3765 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3766 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3767 else
3768 dump_generic_node (pp, op0, 0, flags, false);
3769 break;
3771 case MEM_REF:
3772 if (integer_zerop (TREE_OPERAND (op0, 1)))
3774 op0 = TREE_OPERAND (op0, 0);
3775 goto again;
3777 /* Fallthru. */
3778 case COMPONENT_REF:
3779 case SSA_NAME:
3780 case OBJ_TYPE_REF:
3781 dump_generic_node (pp, op0, 0, flags, false);
3782 break;
3784 default:
3785 NIY;
3789 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3791 static void
3792 pretty_print_string (pretty_printer *pp, const char *str)
3794 if (str == NULL)
3795 return;
3797 while (*str)
3799 switch (str[0])
3801 case '\b':
3802 pp_string (pp, "\\b");
3803 break;
3805 case '\f':
3806 pp_string (pp, "\\f");
3807 break;
3809 case '\n':
3810 pp_string (pp, "\\n");
3811 break;
3813 case '\r':
3814 pp_string (pp, "\\r");
3815 break;
3817 case '\t':
3818 pp_string (pp, "\\t");
3819 break;
3821 case '\v':
3822 pp_string (pp, "\\v");
3823 break;
3825 case '\\':
3826 pp_string (pp, "\\\\");
3827 break;
3829 case '\"':
3830 pp_string (pp, "\\\"");
3831 break;
3833 case '\'':
3834 pp_string (pp, "\\'");
3835 break;
3837 /* No need to handle \0; the loop terminates on \0. */
3839 case '\1':
3840 pp_string (pp, "\\1");
3841 break;
3843 case '\2':
3844 pp_string (pp, "\\2");
3845 break;
3847 case '\3':
3848 pp_string (pp, "\\3");
3849 break;
3851 case '\4':
3852 pp_string (pp, "\\4");
3853 break;
3855 case '\5':
3856 pp_string (pp, "\\5");
3857 break;
3859 case '\6':
3860 pp_string (pp, "\\6");
3861 break;
3863 case '\7':
3864 pp_string (pp, "\\7");
3865 break;
3867 default:
3868 pp_character (pp, str[0]);
3869 break;
3871 str++;
3875 static void
3876 maybe_init_pretty_print (FILE *file)
3878 if (!tree_pp)
3880 tree_pp = new pretty_printer ();
3881 pp_needs_newline (tree_pp) = true;
3882 pp_translate_identifiers (tree_pp) = false;
3885 tree_pp->buffer->stream = file;
3888 static void
3889 newline_and_indent (pretty_printer *pp, int spc)
3891 pp_newline (pp);
3892 INDENT (spc);
3895 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3896 it can also be used in front ends.
3897 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3900 void
3901 percent_K_format (text_info *text)
3903 tree t = va_arg (*text->args_ptr, tree), block;
3904 text->set_location (0, EXPR_LOCATION (t), true);
3905 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3906 block = TREE_BLOCK (t);
3907 *pp_ti_abstract_origin (text) = NULL;
3909 if (in_lto_p)
3911 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3912 representing the outermost block of an inlined function.
3913 So walk the BLOCK tree until we hit such a scope. */
3914 while (block
3915 && TREE_CODE (block) == BLOCK)
3917 if (inlined_function_outer_scope_p (block))
3919 *pp_ti_abstract_origin (text) = block;
3920 break;
3922 block = BLOCK_SUPERCONTEXT (block);
3924 return;
3927 while (block
3928 && TREE_CODE (block) == BLOCK
3929 && BLOCK_ABSTRACT_ORIGIN (block))
3931 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3933 while (TREE_CODE (ao) == BLOCK
3934 && BLOCK_ABSTRACT_ORIGIN (ao)
3935 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3936 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3938 if (TREE_CODE (ao) == FUNCTION_DECL)
3940 *pp_ti_abstract_origin (text) = block;
3941 break;
3943 block = BLOCK_SUPERCONTEXT (block);
3947 /* Print the identifier ID to PRETTY-PRINTER. */
3949 void
3950 pp_tree_identifier (pretty_printer *pp, tree id)
3952 if (pp_translate_identifiers (pp))
3954 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3955 pp_append_text (pp, text, text + strlen (text));
3957 else
3958 pp_append_text (pp, IDENTIFIER_POINTER (id),
3959 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3962 /* A helper function that is used to dump function information before the
3963 function dump. */
3965 void
3966 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3968 const char *dname, *aname;
3969 struct cgraph_node *node = cgraph_node::get (fdecl);
3970 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3972 dname = lang_hooks.decl_printable_name (fdecl, 2);
3974 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3975 aname = (IDENTIFIER_POINTER
3976 (DECL_ASSEMBLER_NAME (fdecl)));
3977 else
3978 aname = "<unset-asm-name>";
3980 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3981 dname, aname, fun->funcdef_no);
3982 if (!(flags & TDF_NOUID))
3983 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3984 if (node)
3986 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3987 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3988 node->frequency == NODE_FREQUENCY_HOT
3989 ? " (hot)"
3990 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3991 ? " (unlikely executed)"
3992 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3993 ? " (executed once)"
3994 : "");
3996 else
3997 fprintf (dump_file, ")\n\n");
4000 /* Dump double_int D to pretty_printer PP. UNS is true
4001 if D is unsigned and false otherwise. */
4002 void
4003 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4005 if (d.fits_shwi ())
4006 pp_wide_integer (pp, d.low);
4007 else if (d.fits_uhwi ())
4008 pp_unsigned_wide_integer (pp, d.low);
4009 else
4011 unsigned HOST_WIDE_INT low = d.low;
4012 HOST_WIDE_INT high = d.high;
4013 if (!uns && d.is_negative ())
4015 pp_minus (pp);
4016 high = ~high + !low;
4017 low = -low;
4019 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4020 systems? */
4021 sprintf (pp_buffer (pp)->digit_buffer,
4022 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4023 (unsigned HOST_WIDE_INT) high, low);
4024 pp_string (pp, pp_buffer (pp)->digit_buffer);