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