PR c++/81124
[official-gcc.git] / gcc / tree-pretty-print.c
blobb70e32573eecfb993839985ef3c89698c394faaa
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, dump_flags_t);
43 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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, dump_flags_t 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 case OMP_CLAUSE_DEFAULT_PRESENT:
506 pp_string (pp, "present");
507 break;
508 default:
509 gcc_unreachable ();
511 pp_right_paren (pp);
512 break;
514 case OMP_CLAUSE_SCHEDULE:
515 pp_string (pp, "schedule(");
516 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
517 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
518 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
520 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
521 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
522 pp_string (pp, "monotonic");
523 else
524 pp_string (pp, "nonmonotonic");
525 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
526 pp_comma (pp);
527 else
528 pp_colon (pp);
530 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
531 pp_string (pp, "simd:");
533 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
535 case OMP_CLAUSE_SCHEDULE_STATIC:
536 pp_string (pp, "static");
537 break;
538 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
539 pp_string (pp, "dynamic");
540 break;
541 case OMP_CLAUSE_SCHEDULE_GUIDED:
542 pp_string (pp, "guided");
543 break;
544 case OMP_CLAUSE_SCHEDULE_RUNTIME:
545 pp_string (pp, "runtime");
546 break;
547 case OMP_CLAUSE_SCHEDULE_AUTO:
548 pp_string (pp, "auto");
549 break;
550 case OMP_CLAUSE_SCHEDULE_CILKFOR:
551 pp_string (pp, "cilk-for grain");
552 break;
553 default:
554 gcc_unreachable ();
556 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
558 pp_comma (pp);
559 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
560 spc, flags, false);
562 pp_right_paren (pp);
563 break;
565 case OMP_CLAUSE_UNTIED:
566 pp_string (pp, "untied");
567 break;
569 case OMP_CLAUSE_COLLAPSE:
570 pp_string (pp, "collapse(");
571 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
572 spc, flags, false);
573 pp_right_paren (pp);
574 break;
576 case OMP_CLAUSE_FINAL:
577 pp_string (pp, "final(");
578 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
579 spc, flags, false);
580 pp_right_paren (pp);
581 break;
583 case OMP_CLAUSE_MERGEABLE:
584 pp_string (pp, "mergeable");
585 break;
587 case OMP_CLAUSE_LINEAR:
588 pp_string (pp, "linear(");
589 switch (OMP_CLAUSE_LINEAR_KIND (clause))
591 case OMP_CLAUSE_LINEAR_DEFAULT:
592 break;
593 case OMP_CLAUSE_LINEAR_REF:
594 pp_string (pp, "ref(");
595 break;
596 case OMP_CLAUSE_LINEAR_VAL:
597 pp_string (pp, "val(");
598 break;
599 case OMP_CLAUSE_LINEAR_UVAL:
600 pp_string (pp, "uval(");
601 break;
602 default:
603 gcc_unreachable ();
605 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
606 spc, flags, false);
607 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
608 pp_right_paren (pp);
609 pp_colon (pp);
610 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
611 spc, flags, false);
612 pp_right_paren (pp);
613 break;
615 case OMP_CLAUSE_ALIGNED:
616 pp_string (pp, "aligned(");
617 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
618 spc, flags, false);
619 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
621 pp_colon (pp);
622 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
623 spc, flags, false);
625 pp_right_paren (pp);
626 break;
628 case OMP_CLAUSE_DEPEND:
629 pp_string (pp, "depend(");
630 switch (OMP_CLAUSE_DEPEND_KIND (clause))
632 case OMP_CLAUSE_DEPEND_IN:
633 pp_string (pp, "in");
634 break;
635 case OMP_CLAUSE_DEPEND_OUT:
636 pp_string (pp, "out");
637 break;
638 case OMP_CLAUSE_DEPEND_INOUT:
639 pp_string (pp, "inout");
640 break;
641 case OMP_CLAUSE_DEPEND_SOURCE:
642 pp_string (pp, "source)");
643 return;
644 case OMP_CLAUSE_DEPEND_SINK:
645 pp_string (pp, "sink:");
646 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
647 if (TREE_CODE (t) == TREE_LIST)
649 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
650 if (TREE_PURPOSE (t) != integer_zero_node)
652 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
653 pp_minus (pp);
654 else
655 pp_plus (pp);
656 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
657 false);
659 if (TREE_CHAIN (t))
660 pp_comma (pp);
662 else
663 gcc_unreachable ();
664 pp_right_paren (pp);
665 return;
666 default:
667 gcc_unreachable ();
669 pp_colon (pp);
670 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
671 spc, flags, false);
672 pp_right_paren (pp);
673 break;
675 case OMP_CLAUSE_MAP:
676 pp_string (pp, "map(");
677 switch (OMP_CLAUSE_MAP_KIND (clause))
679 case GOMP_MAP_ALLOC:
680 case GOMP_MAP_POINTER:
681 pp_string (pp, "alloc");
682 break;
683 case GOMP_MAP_TO:
684 case GOMP_MAP_TO_PSET:
685 pp_string (pp, "to");
686 break;
687 case GOMP_MAP_FROM:
688 pp_string (pp, "from");
689 break;
690 case GOMP_MAP_TOFROM:
691 pp_string (pp, "tofrom");
692 break;
693 case GOMP_MAP_FORCE_ALLOC:
694 pp_string (pp, "force_alloc");
695 break;
696 case GOMP_MAP_FORCE_TO:
697 pp_string (pp, "force_to");
698 break;
699 case GOMP_MAP_FORCE_FROM:
700 pp_string (pp, "force_from");
701 break;
702 case GOMP_MAP_FORCE_TOFROM:
703 pp_string (pp, "force_tofrom");
704 break;
705 case GOMP_MAP_FORCE_PRESENT:
706 pp_string (pp, "force_present");
707 break;
708 case GOMP_MAP_DELETE:
709 pp_string (pp, "delete");
710 break;
711 case GOMP_MAP_FORCE_DEVICEPTR:
712 pp_string (pp, "force_deviceptr");
713 break;
714 case GOMP_MAP_ALWAYS_TO:
715 pp_string (pp, "always,to");
716 break;
717 case GOMP_MAP_ALWAYS_FROM:
718 pp_string (pp, "always,from");
719 break;
720 case GOMP_MAP_ALWAYS_TOFROM:
721 pp_string (pp, "always,tofrom");
722 break;
723 case GOMP_MAP_RELEASE:
724 pp_string (pp, "release");
725 break;
726 case GOMP_MAP_FIRSTPRIVATE_POINTER:
727 pp_string (pp, "firstprivate");
728 break;
729 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
730 pp_string (pp, "firstprivate ref");
731 break;
732 case GOMP_MAP_STRUCT:
733 pp_string (pp, "struct");
734 break;
735 case GOMP_MAP_ALWAYS_POINTER:
736 pp_string (pp, "always_pointer");
737 break;
738 case GOMP_MAP_DEVICE_RESIDENT:
739 pp_string (pp, "device_resident");
740 break;
741 case GOMP_MAP_LINK:
742 pp_string (pp, "link");
743 break;
744 default:
745 gcc_unreachable ();
747 pp_colon (pp);
748 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
749 spc, flags, false);
750 print_clause_size:
751 if (OMP_CLAUSE_SIZE (clause))
753 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
754 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
756 case GOMP_MAP_POINTER:
757 case GOMP_MAP_FIRSTPRIVATE_POINTER:
758 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
759 case GOMP_MAP_ALWAYS_POINTER:
760 pp_string (pp, " [pointer assign, bias: ");
761 break;
762 case GOMP_MAP_TO_PSET:
763 pp_string (pp, " [pointer set, len: ");
764 break;
765 default:
766 pp_string (pp, " [len: ");
767 break;
769 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
770 spc, flags, false);
771 pp_right_bracket (pp);
773 pp_right_paren (pp);
774 break;
776 case OMP_CLAUSE_FROM:
777 pp_string (pp, "from(");
778 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
779 spc, flags, false);
780 goto print_clause_size;
782 case OMP_CLAUSE_TO:
783 pp_string (pp, "to(");
784 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
785 spc, flags, false);
786 goto print_clause_size;
788 case OMP_CLAUSE__CACHE_:
789 pp_string (pp, "(");
790 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
791 spc, flags, false);
792 goto print_clause_size;
794 case OMP_CLAUSE_NUM_TEAMS:
795 pp_string (pp, "num_teams(");
796 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
797 spc, flags, false);
798 pp_right_paren (pp);
799 break;
801 case OMP_CLAUSE_THREAD_LIMIT:
802 pp_string (pp, "thread_limit(");
803 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
804 spc, flags, false);
805 pp_right_paren (pp);
806 break;
808 case OMP_CLAUSE_DEVICE:
809 pp_string (pp, "device(");
810 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
811 spc, flags, false);
812 pp_right_paren (pp);
813 break;
815 case OMP_CLAUSE_DIST_SCHEDULE:
816 pp_string (pp, "dist_schedule(static");
817 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
819 pp_comma (pp);
820 dump_generic_node (pp,
821 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
822 spc, flags, false);
824 pp_right_paren (pp);
825 break;
827 case OMP_CLAUSE_PROC_BIND:
828 pp_string (pp, "proc_bind(");
829 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
831 case OMP_CLAUSE_PROC_BIND_MASTER:
832 pp_string (pp, "master");
833 break;
834 case OMP_CLAUSE_PROC_BIND_CLOSE:
835 pp_string (pp, "close");
836 break;
837 case OMP_CLAUSE_PROC_BIND_SPREAD:
838 pp_string (pp, "spread");
839 break;
840 default:
841 gcc_unreachable ();
843 pp_right_paren (pp);
844 break;
846 case OMP_CLAUSE_SAFELEN:
847 pp_string (pp, "safelen(");
848 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
849 spc, flags, false);
850 pp_right_paren (pp);
851 break;
853 case OMP_CLAUSE_SIMDLEN:
854 pp_string (pp, "simdlen(");
855 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
856 spc, flags, false);
857 pp_right_paren (pp);
858 break;
860 case OMP_CLAUSE_PRIORITY:
861 pp_string (pp, "priority(");
862 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
863 spc, flags, false);
864 pp_right_paren (pp);
865 break;
867 case OMP_CLAUSE_GRAINSIZE:
868 pp_string (pp, "grainsize(");
869 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
870 spc, flags, false);
871 pp_right_paren (pp);
872 break;
874 case OMP_CLAUSE_NUM_TASKS:
875 pp_string (pp, "num_tasks(");
876 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
877 spc, flags, false);
878 pp_right_paren (pp);
879 break;
881 case OMP_CLAUSE_HINT:
882 pp_string (pp, "hint(");
883 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
884 spc, flags, false);
885 pp_right_paren (pp);
886 break;
888 case OMP_CLAUSE_DEFAULTMAP:
889 pp_string (pp, "defaultmap(tofrom:scalar)");
890 break;
892 case OMP_CLAUSE__SIMDUID_:
893 pp_string (pp, "_simduid_(");
894 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
895 spc, flags, false);
896 pp_right_paren (pp);
897 break;
899 case OMP_CLAUSE__SIMT_:
900 pp_string (pp, "_simt_");
901 break;
903 case OMP_CLAUSE_GANG:
904 pp_string (pp, "gang");
905 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
907 pp_string (pp, "(num: ");
908 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
909 spc, flags, false);
911 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
913 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
914 pp_left_paren (pp);
915 else
916 pp_space (pp);
917 pp_string (pp, "static:");
918 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
919 == integer_minus_one_node)
920 pp_character (pp, '*');
921 else
922 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
923 spc, flags, false);
925 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
926 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
927 pp_right_paren (pp);
928 break;
930 case OMP_CLAUSE_ASYNC:
931 pp_string (pp, "async");
932 if (OMP_CLAUSE_ASYNC_EXPR (clause))
934 pp_character(pp, '(');
935 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
936 spc, flags, false);
937 pp_character(pp, ')');
939 break;
941 case OMP_CLAUSE_AUTO:
942 case OMP_CLAUSE_SEQ:
943 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
944 break;
946 case OMP_CLAUSE_WAIT:
947 pp_string (pp, "wait(");
948 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
949 spc, flags, false);
950 pp_character(pp, ')');
951 break;
953 case OMP_CLAUSE_WORKER:
954 pp_string (pp, "worker");
955 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
957 pp_left_paren (pp);
958 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
959 spc, flags, false);
960 pp_right_paren (pp);
962 break;
964 case OMP_CLAUSE_VECTOR:
965 pp_string (pp, "vector");
966 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
968 pp_left_paren (pp);
969 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
970 spc, flags, false);
971 pp_right_paren (pp);
973 break;
975 case OMP_CLAUSE_NUM_GANGS:
976 pp_string (pp, "num_gangs(");
977 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
978 spc, flags, false);
979 pp_character (pp, ')');
980 break;
982 case OMP_CLAUSE_NUM_WORKERS:
983 pp_string (pp, "num_workers(");
984 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
985 spc, flags, false);
986 pp_character (pp, ')');
987 break;
989 case OMP_CLAUSE_VECTOR_LENGTH:
990 pp_string (pp, "vector_length(");
991 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
992 spc, flags, false);
993 pp_character (pp, ')');
994 break;
996 case OMP_CLAUSE_INBRANCH:
997 pp_string (pp, "inbranch");
998 break;
999 case OMP_CLAUSE_NOTINBRANCH:
1000 pp_string (pp, "notinbranch");
1001 break;
1002 case OMP_CLAUSE_FOR:
1003 pp_string (pp, "for");
1004 break;
1005 case OMP_CLAUSE_PARALLEL:
1006 pp_string (pp, "parallel");
1007 break;
1008 case OMP_CLAUSE_SECTIONS:
1009 pp_string (pp, "sections");
1010 break;
1011 case OMP_CLAUSE_TASKGROUP:
1012 pp_string (pp, "taskgroup");
1013 break;
1014 case OMP_CLAUSE_NOGROUP:
1015 pp_string (pp, "nogroup");
1016 break;
1017 case OMP_CLAUSE_THREADS:
1018 pp_string (pp, "threads");
1019 break;
1020 case OMP_CLAUSE_SIMD:
1021 pp_string (pp, "simd");
1022 break;
1023 case OMP_CLAUSE_INDEPENDENT:
1024 pp_string (pp, "independent");
1025 break;
1026 case OMP_CLAUSE_TILE:
1027 pp_string (pp, "tile(");
1028 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1029 spc, flags, false);
1030 pp_right_paren (pp);
1031 break;
1033 case OMP_CLAUSE__GRIDDIM_:
1034 pp_string (pp, "_griddim_(");
1035 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1036 pp_colon (pp);
1037 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1038 false);
1039 pp_comma (pp);
1040 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1041 false);
1042 pp_right_paren (pp);
1043 break;
1045 default:
1046 /* Should never happen. */
1047 dump_generic_node (pp, clause, spc, flags, false);
1048 break;
1053 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1054 dump_generic_node. */
1056 void
1057 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1059 if (clause == NULL)
1060 return;
1062 pp_space (pp);
1063 while (1)
1065 dump_omp_clause (pp, clause, spc, flags);
1066 clause = OMP_CLAUSE_CHAIN (clause);
1067 if (clause == NULL)
1068 return;
1069 pp_space (pp);
1074 /* Dump location LOC to PP. */
1076 void
1077 dump_location (pretty_printer *pp, location_t loc)
1079 expanded_location xloc = expand_location (loc);
1081 pp_left_bracket (pp);
1082 if (xloc.file)
1084 pp_string (pp, xloc.file);
1085 pp_string (pp, ":");
1087 pp_decimal_int (pp, xloc.line);
1088 pp_colon (pp);
1089 pp_decimal_int (pp, xloc.column);
1090 pp_string (pp, "] ");
1094 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1095 dump_generic_node. */
1097 static void
1098 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1100 tree t;
1102 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1104 if (flags & TDF_ADDRESS)
1105 pp_printf (pp, "[%p] ", (void *) block);
1107 if (BLOCK_ABSTRACT (block))
1108 pp_string (pp, "[abstract] ");
1110 if (TREE_ASM_WRITTEN (block))
1111 pp_string (pp, "[written] ");
1113 if (flags & TDF_SLIM)
1114 return;
1116 if (BLOCK_SOURCE_LOCATION (block))
1117 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1119 newline_and_indent (pp, spc + 2);
1121 if (BLOCK_SUPERCONTEXT (block))
1123 pp_string (pp, "SUPERCONTEXT: ");
1124 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1125 flags | TDF_SLIM, false);
1126 newline_and_indent (pp, spc + 2);
1129 if (BLOCK_SUBBLOCKS (block))
1131 pp_string (pp, "SUBBLOCKS: ");
1132 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1134 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1135 pp_space (pp);
1137 newline_and_indent (pp, spc + 2);
1140 if (BLOCK_CHAIN (block))
1142 pp_string (pp, "SIBLINGS: ");
1143 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1145 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1146 pp_space (pp);
1148 newline_and_indent (pp, spc + 2);
1151 if (BLOCK_VARS (block))
1153 pp_string (pp, "VARS: ");
1154 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1156 dump_generic_node (pp, t, 0, flags, false);
1157 pp_space (pp);
1159 newline_and_indent (pp, spc + 2);
1162 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1164 unsigned i;
1165 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1167 pp_string (pp, "NONLOCALIZED_VARS: ");
1168 FOR_EACH_VEC_ELT (*nlv, i, t)
1170 dump_generic_node (pp, t, 0, flags, false);
1171 pp_space (pp);
1173 newline_and_indent (pp, spc + 2);
1176 if (BLOCK_ABSTRACT_ORIGIN (block))
1178 pp_string (pp, "ABSTRACT_ORIGIN: ");
1179 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1180 flags | TDF_SLIM, false);
1181 newline_and_indent (pp, spc + 2);
1184 if (BLOCK_FRAGMENT_ORIGIN (block))
1186 pp_string (pp, "FRAGMENT_ORIGIN: ");
1187 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1188 flags | TDF_SLIM, false);
1189 newline_and_indent (pp, spc + 2);
1192 if (BLOCK_FRAGMENT_CHAIN (block))
1194 pp_string (pp, "FRAGMENT_CHAIN: ");
1195 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1197 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1198 pp_space (pp);
1200 newline_and_indent (pp, spc + 2);
1205 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1206 indent. FLAGS specifies details to show in the dump (see TDF_* in
1207 dumpfile.h). If IS_STMT is true, the object printed is considered
1208 to be a statement and it is terminated by ';' if appropriate. */
1211 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1212 bool is_stmt)
1214 tree type;
1215 tree op0, op1;
1216 const char *str;
1217 bool is_expr;
1218 enum tree_code code;
1220 if (node == NULL_TREE)
1221 return spc;
1223 is_expr = EXPR_P (node);
1225 if (is_stmt && (flags & TDF_STMTADDR))
1226 pp_printf (pp, "<&%p> ", (void *)node);
1228 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1229 dump_location (pp, EXPR_LOCATION (node));
1231 code = TREE_CODE (node);
1232 switch (code)
1234 case ERROR_MARK:
1235 pp_string (pp, "<<< error >>>");
1236 break;
1238 case IDENTIFIER_NODE:
1239 pp_tree_identifier (pp, node);
1240 break;
1242 case TREE_LIST:
1243 while (node && node != error_mark_node)
1245 if (TREE_PURPOSE (node))
1247 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1248 pp_space (pp);
1250 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1251 node = TREE_CHAIN (node);
1252 if (node && TREE_CODE (node) == TREE_LIST)
1254 pp_comma (pp);
1255 pp_space (pp);
1258 break;
1260 case TREE_BINFO:
1261 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1262 break;
1264 case TREE_VEC:
1266 size_t i;
1267 if (TREE_VEC_LENGTH (node) > 0)
1269 size_t len = TREE_VEC_LENGTH (node);
1270 for (i = 0; i < len - 1; i++)
1272 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1273 false);
1274 pp_comma (pp);
1275 pp_space (pp);
1277 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1278 flags, false);
1281 break;
1283 case VOID_TYPE:
1284 case POINTER_BOUNDS_TYPE:
1285 case INTEGER_TYPE:
1286 case REAL_TYPE:
1287 case FIXED_POINT_TYPE:
1288 case COMPLEX_TYPE:
1289 case VECTOR_TYPE:
1290 case ENUMERAL_TYPE:
1291 case BOOLEAN_TYPE:
1293 unsigned int quals = TYPE_QUALS (node);
1294 enum tree_code_class tclass;
1296 if (quals & TYPE_QUAL_ATOMIC)
1297 pp_string (pp, "atomic ");
1298 if (quals & TYPE_QUAL_CONST)
1299 pp_string (pp, "const ");
1300 else if (quals & TYPE_QUAL_VOLATILE)
1301 pp_string (pp, "volatile ");
1302 else if (quals & TYPE_QUAL_RESTRICT)
1303 pp_string (pp, "restrict ");
1305 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1307 pp_string (pp, "<address-space-");
1308 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1309 pp_string (pp, "> ");
1312 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1314 if (tclass == tcc_declaration)
1316 if (DECL_NAME (node))
1317 dump_decl_name (pp, node, flags);
1318 else
1319 pp_string (pp, "<unnamed type decl>");
1321 else if (tclass == tcc_type)
1323 if (TYPE_NAME (node))
1325 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1326 pp_tree_identifier (pp, TYPE_NAME (node));
1327 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1328 && DECL_NAME (TYPE_NAME (node)))
1329 dump_decl_name (pp, TYPE_NAME (node), flags);
1330 else
1331 pp_string (pp, "<unnamed type>");
1333 else if (TREE_CODE (node) == VECTOR_TYPE)
1335 pp_string (pp, "vector");
1336 pp_left_paren (pp);
1337 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1338 pp_string (pp, ") ");
1339 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1341 else if (TREE_CODE (node) == INTEGER_TYPE)
1343 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1344 pp_string (pp, (TYPE_UNSIGNED (node)
1345 ? "unsigned char"
1346 : "signed char"));
1347 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1348 pp_string (pp, (TYPE_UNSIGNED (node)
1349 ? "unsigned short"
1350 : "signed short"));
1351 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1352 pp_string (pp, (TYPE_UNSIGNED (node)
1353 ? "unsigned int"
1354 : "signed int"));
1355 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1356 pp_string (pp, (TYPE_UNSIGNED (node)
1357 ? "unsigned long"
1358 : "signed long"));
1359 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1360 pp_string (pp, (TYPE_UNSIGNED (node)
1361 ? "unsigned long long"
1362 : "signed long long"));
1363 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1364 && pow2p_hwi (TYPE_PRECISION (node)))
1366 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1367 pp_decimal_int (pp, TYPE_PRECISION (node));
1368 pp_string (pp, "_t");
1370 else
1372 pp_string (pp, (TYPE_UNSIGNED (node)
1373 ? "<unnamed-unsigned:"
1374 : "<unnamed-signed:"));
1375 pp_decimal_int (pp, TYPE_PRECISION (node));
1376 pp_greater (pp);
1379 else if (TREE_CODE (node) == COMPLEX_TYPE)
1381 pp_string (pp, "__complex__ ");
1382 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1384 else if (TREE_CODE (node) == REAL_TYPE)
1386 pp_string (pp, "<float:");
1387 pp_decimal_int (pp, TYPE_PRECISION (node));
1388 pp_greater (pp);
1390 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1392 pp_string (pp, "<fixed-point-");
1393 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1394 pp_decimal_int (pp, TYPE_PRECISION (node));
1395 pp_greater (pp);
1397 else if (TREE_CODE (node) == VOID_TYPE)
1398 pp_string (pp, "void");
1399 else
1400 pp_string (pp, "<unnamed type>");
1402 break;
1405 case POINTER_TYPE:
1406 case REFERENCE_TYPE:
1407 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1409 if (TREE_TYPE (node) == NULL)
1411 pp_string (pp, str);
1412 pp_string (pp, "<null type>");
1414 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1416 tree fnode = TREE_TYPE (node);
1418 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1419 pp_space (pp);
1420 pp_left_paren (pp);
1421 pp_string (pp, str);
1422 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1423 dump_decl_name (pp, TYPE_NAME (node), flags);
1424 else if (flags & TDF_NOUID)
1425 pp_printf (pp, "<Txxxx>");
1426 else
1427 pp_printf (pp, "<T%x>", TYPE_UID (node));
1429 pp_right_paren (pp);
1430 dump_function_declaration (pp, fnode, spc, flags);
1432 else
1434 unsigned int quals = TYPE_QUALS (node);
1436 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1437 pp_space (pp);
1438 pp_string (pp, str);
1440 if (quals & TYPE_QUAL_CONST)
1441 pp_string (pp, " const");
1442 if (quals & TYPE_QUAL_VOLATILE)
1443 pp_string (pp, " volatile");
1444 if (quals & TYPE_QUAL_RESTRICT)
1445 pp_string (pp, " restrict");
1447 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1449 pp_string (pp, " <address-space-");
1450 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1451 pp_greater (pp);
1454 if (TYPE_REF_CAN_ALIAS_ALL (node))
1455 pp_string (pp, " {ref-all}");
1457 break;
1459 case OFFSET_TYPE:
1460 NIY;
1461 break;
1463 case MEM_REF:
1465 if (flags & TDF_GIMPLE)
1467 pp_string (pp, "__MEM <");
1468 dump_generic_node (pp, TREE_TYPE (node),
1469 spc, flags | TDF_SLIM, false);
1470 if (TYPE_ALIGN (TREE_TYPE (node))
1471 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1473 pp_string (pp, ", ");
1474 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1476 pp_greater (pp);
1477 pp_string (pp, " (");
1478 if (TREE_TYPE (TREE_OPERAND (node, 0))
1479 != TREE_TYPE (TREE_OPERAND (node, 1)))
1481 pp_left_paren (pp);
1482 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1483 spc, flags | TDF_SLIM, false);
1484 pp_right_paren (pp);
1486 dump_generic_node (pp, TREE_OPERAND (node, 0),
1487 spc, flags | TDF_SLIM, false);
1488 if (! integer_zerop (TREE_OPERAND (node, 1)))
1490 pp_string (pp, " + ");
1491 dump_generic_node (pp, TREE_OPERAND (node, 1),
1492 spc, flags | TDF_SLIM, false);
1494 pp_right_paren (pp);
1496 else if (integer_zerop (TREE_OPERAND (node, 1))
1497 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1498 infer them and MEM_ATTR caching will share MEM_REFs
1499 with differently-typed op0s. */
1500 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1501 /* Released SSA_NAMES have no TREE_TYPE. */
1502 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1503 /* Same pointer types, but ignoring POINTER_TYPE vs.
1504 REFERENCE_TYPE. */
1505 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1506 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1507 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1508 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1509 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1510 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1511 /* Same value types ignoring qualifiers. */
1512 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1513 == TYPE_MAIN_VARIANT
1514 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1515 && (!(flags & TDF_ALIAS)
1516 || MR_DEPENDENCE_CLIQUE (node) == 0))
1518 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1520 pp_star (pp);
1521 dump_generic_node (pp, TREE_OPERAND (node, 0),
1522 spc, flags, false);
1524 else
1525 dump_generic_node (pp,
1526 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1527 spc, flags, false);
1529 else
1531 tree ptype;
1533 pp_string (pp, "MEM[");
1534 pp_left_paren (pp);
1535 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1536 dump_generic_node (pp, ptype,
1537 spc, flags | TDF_SLIM, false);
1538 pp_right_paren (pp);
1539 dump_generic_node (pp, TREE_OPERAND (node, 0),
1540 spc, flags, false);
1541 if (!integer_zerop (TREE_OPERAND (node, 1)))
1543 pp_string (pp, " + ");
1544 dump_generic_node (pp, TREE_OPERAND (node, 1),
1545 spc, flags, false);
1547 if ((flags & TDF_ALIAS)
1548 && MR_DEPENDENCE_CLIQUE (node) != 0)
1550 pp_string (pp, " clique ");
1551 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1552 pp_string (pp, " base ");
1553 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1555 pp_right_bracket (pp);
1557 break;
1560 case TARGET_MEM_REF:
1562 const char *sep = "";
1563 tree tmp;
1565 pp_string (pp, "MEM[");
1567 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1569 pp_string (pp, sep);
1570 sep = ", ";
1571 pp_string (pp, "symbol: ");
1572 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1573 spc, flags, false);
1575 else
1577 pp_string (pp, sep);
1578 sep = ", ";
1579 pp_string (pp, "base: ");
1580 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1582 tmp = TMR_INDEX2 (node);
1583 if (tmp)
1585 pp_string (pp, sep);
1586 sep = ", ";
1587 pp_string (pp, "base: ");
1588 dump_generic_node (pp, tmp, spc, flags, false);
1590 tmp = TMR_INDEX (node);
1591 if (tmp)
1593 pp_string (pp, sep);
1594 sep = ", ";
1595 pp_string (pp, "index: ");
1596 dump_generic_node (pp, tmp, spc, flags, false);
1598 tmp = TMR_STEP (node);
1599 if (tmp)
1601 pp_string (pp, sep);
1602 sep = ", ";
1603 pp_string (pp, "step: ");
1604 dump_generic_node (pp, tmp, spc, flags, false);
1606 tmp = TMR_OFFSET (node);
1607 if (tmp)
1609 pp_string (pp, sep);
1610 sep = ", ";
1611 pp_string (pp, "offset: ");
1612 dump_generic_node (pp, tmp, spc, flags, false);
1614 pp_right_bracket (pp);
1616 break;
1618 case ARRAY_TYPE:
1620 tree tmp;
1622 /* Print the innermost component type. */
1623 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1624 tmp = TREE_TYPE (tmp))
1626 dump_generic_node (pp, tmp, spc, flags, false);
1628 /* Print the dimensions. */
1629 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1630 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1631 break;
1634 case RECORD_TYPE:
1635 case UNION_TYPE:
1636 case QUAL_UNION_TYPE:
1638 unsigned int quals = TYPE_QUALS (node);
1640 if (quals & TYPE_QUAL_ATOMIC)
1641 pp_string (pp, "atomic ");
1642 if (quals & TYPE_QUAL_CONST)
1643 pp_string (pp, "const ");
1644 if (quals & TYPE_QUAL_VOLATILE)
1645 pp_string (pp, "volatile ");
1647 /* Print the name of the structure. */
1648 if (TREE_CODE (node) == RECORD_TYPE)
1649 pp_string (pp, "struct ");
1650 else if (TREE_CODE (node) == UNION_TYPE)
1651 pp_string (pp, "union ");
1653 if (TYPE_NAME (node))
1654 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1655 else if (!(flags & TDF_SLIM))
1656 /* FIXME: If we eliminate the 'else' above and attempt
1657 to show the fields for named types, we may get stuck
1658 following a cycle of pointers to structs. The alleged
1659 self-reference check in print_struct_decl will not detect
1660 cycles involving more than one pointer or struct type. */
1661 print_struct_decl (pp, node, spc, flags);
1662 break;
1665 case LANG_TYPE:
1666 NIY;
1667 break;
1669 case INTEGER_CST:
1670 if (flags & TDF_GIMPLE
1671 && (POINTER_TYPE_P (TREE_TYPE (node))
1672 || (TYPE_PRECISION (TREE_TYPE (node))
1673 < TYPE_PRECISION (integer_type_node))
1674 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1676 pp_string (pp, "_Literal (");
1677 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1678 pp_string (pp, ") ");
1680 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1681 && ! (flags & TDF_GIMPLE))
1683 /* In the case of a pointer, one may want to divide by the
1684 size of the pointed-to type. Unfortunately, this not
1685 straightforward. The C front-end maps expressions
1687 (int *) 5
1688 int *p; (p + 5)
1690 in such a way that the two INTEGER_CST nodes for "5" have
1691 different values but identical types. In the latter
1692 case, the 5 is multiplied by sizeof (int) in c-common.c
1693 (pointer_int_sum) to convert it to a byte address, and
1694 yet the type of the node is left unchanged. Argh. What
1695 is consistent though is that the number value corresponds
1696 to bytes (UNITS) offset.
1698 NB: Neither of the following divisors can be trivially
1699 used to recover the original literal:
1701 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1702 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1703 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1704 pp_string (pp, "B"); /* pseudo-unit */
1706 else if (tree_fits_shwi_p (node))
1707 pp_wide_integer (pp, tree_to_shwi (node));
1708 else if (tree_fits_uhwi_p (node))
1709 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1710 else
1712 wide_int val = node;
1714 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1716 pp_minus (pp);
1717 val = -val;
1719 print_hex (val, pp_buffer (pp)->digit_buffer);
1720 pp_string (pp, pp_buffer (pp)->digit_buffer);
1722 if ((flags & TDF_GIMPLE)
1723 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1724 || (TYPE_PRECISION (TREE_TYPE (node))
1725 < TYPE_PRECISION (integer_type_node))
1726 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1728 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1729 pp_character (pp, 'u');
1730 if (TYPE_PRECISION (TREE_TYPE (node))
1731 == TYPE_PRECISION (unsigned_type_node))
1733 else if (TYPE_PRECISION (TREE_TYPE (node))
1734 == TYPE_PRECISION (long_unsigned_type_node))
1735 pp_character (pp, 'l');
1736 else if (TYPE_PRECISION (TREE_TYPE (node))
1737 == TYPE_PRECISION (long_long_unsigned_type_node))
1738 pp_string (pp, "ll");
1740 if (TREE_OVERFLOW (node))
1741 pp_string (pp, "(OVF)");
1742 break;
1744 case REAL_CST:
1745 /* Code copied from print_node. */
1747 REAL_VALUE_TYPE d;
1748 if (TREE_OVERFLOW (node))
1749 pp_string (pp, " overflow");
1751 d = TREE_REAL_CST (node);
1752 if (REAL_VALUE_ISINF (d))
1753 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1754 else if (REAL_VALUE_ISNAN (d))
1755 pp_string (pp, " Nan");
1756 else
1758 char string[100];
1759 real_to_decimal (string, &d, sizeof (string), 0, 1);
1760 pp_string (pp, string);
1762 break;
1765 case FIXED_CST:
1767 char string[100];
1768 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1769 pp_string (pp, string);
1770 break;
1773 case COMPLEX_CST:
1774 pp_string (pp, "__complex__ (");
1775 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1776 pp_string (pp, ", ");
1777 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1778 pp_right_paren (pp);
1779 break;
1781 case STRING_CST:
1782 pp_string (pp, "\"");
1783 pretty_print_string (pp, TREE_STRING_POINTER (node));
1784 pp_string (pp, "\"");
1785 break;
1787 case VECTOR_CST:
1789 unsigned i;
1790 pp_string (pp, "{ ");
1791 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1793 if (i != 0)
1794 pp_string (pp, ", ");
1795 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1796 spc, flags, false);
1798 pp_string (pp, " }");
1800 break;
1802 case FUNCTION_TYPE:
1803 case METHOD_TYPE:
1804 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1805 pp_space (pp);
1806 if (TREE_CODE (node) == METHOD_TYPE)
1808 if (TYPE_METHOD_BASETYPE (node))
1809 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1810 flags);
1811 else
1812 pp_string (pp, "<null method basetype>");
1813 pp_colon_colon (pp);
1815 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1816 dump_decl_name (pp, TYPE_NAME (node), flags);
1817 else if (flags & TDF_NOUID)
1818 pp_printf (pp, "<Txxxx>");
1819 else
1820 pp_printf (pp, "<T%x>", TYPE_UID (node));
1821 dump_function_declaration (pp, node, spc, flags);
1822 break;
1824 case FUNCTION_DECL:
1825 case CONST_DECL:
1826 dump_decl_name (pp, node, flags);
1827 break;
1829 case LABEL_DECL:
1830 if (DECL_NAME (node))
1831 dump_decl_name (pp, node, flags);
1832 else if (LABEL_DECL_UID (node) != -1)
1834 if (flags & TDF_GIMPLE)
1835 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1836 else
1837 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1839 else
1841 if (flags & TDF_NOUID)
1842 pp_string (pp, "<D.xxxx>");
1843 else
1845 if (flags & TDF_GIMPLE)
1846 pp_printf (pp, "<D%u>", DECL_UID (node));
1847 else
1848 pp_printf (pp, "<D.%u>", DECL_UID (node));
1851 break;
1853 case TYPE_DECL:
1854 if (DECL_IS_BUILTIN (node))
1856 /* Don't print the declaration of built-in types. */
1857 break;
1859 if (DECL_NAME (node))
1860 dump_decl_name (pp, node, flags);
1861 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1863 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1864 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1865 && TYPE_METHODS (TREE_TYPE (node)))
1867 /* The type is a c++ class: all structures have at least
1868 4 methods. */
1869 pp_string (pp, "class ");
1870 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1872 else
1874 pp_string (pp,
1875 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1876 ? "union" : "struct "));
1877 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1880 else
1881 pp_string (pp, "<anon>");
1882 break;
1884 case VAR_DECL:
1885 case PARM_DECL:
1886 case FIELD_DECL:
1887 case DEBUG_EXPR_DECL:
1888 case NAMESPACE_DECL:
1889 case NAMELIST_DECL:
1890 dump_decl_name (pp, node, flags);
1891 break;
1893 case RESULT_DECL:
1894 pp_string (pp, "<retval>");
1895 break;
1897 case COMPONENT_REF:
1898 op0 = TREE_OPERAND (node, 0);
1899 str = ".";
1900 if (op0
1901 && (TREE_CODE (op0) == INDIRECT_REF
1902 || (TREE_CODE (op0) == MEM_REF
1903 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1904 && integer_zerop (TREE_OPERAND (op0, 1))
1905 /* Dump the types of INTEGER_CSTs explicitly, for we
1906 can't infer them and MEM_ATTR caching will share
1907 MEM_REFs with differently-typed op0s. */
1908 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1909 /* Released SSA_NAMES have no TREE_TYPE. */
1910 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1911 /* Same pointer types, but ignoring POINTER_TYPE vs.
1912 REFERENCE_TYPE. */
1913 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1914 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1915 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1916 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1917 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1918 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1919 /* Same value types ignoring qualifiers. */
1920 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1921 == TYPE_MAIN_VARIANT
1922 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1923 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1925 op0 = TREE_OPERAND (op0, 0);
1926 str = "->";
1928 if (op_prio (op0) < op_prio (node))
1929 pp_left_paren (pp);
1930 dump_generic_node (pp, op0, spc, flags, false);
1931 if (op_prio (op0) < op_prio (node))
1932 pp_right_paren (pp);
1933 pp_string (pp, str);
1934 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1935 op0 = component_ref_field_offset (node);
1936 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1938 pp_string (pp, "{off: ");
1939 dump_generic_node (pp, op0, spc, flags, false);
1940 pp_right_brace (pp);
1942 break;
1944 case BIT_FIELD_REF:
1945 pp_string (pp, "BIT_FIELD_REF <");
1946 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1947 pp_string (pp, ", ");
1948 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1949 pp_string (pp, ", ");
1950 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1951 pp_greater (pp);
1952 break;
1954 case BIT_INSERT_EXPR:
1955 pp_string (pp, "BIT_INSERT_EXPR <");
1956 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1957 pp_string (pp, ", ");
1958 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1959 pp_string (pp, ", ");
1960 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1961 pp_string (pp, " (");
1962 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1963 pp_decimal_int (pp,
1964 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1965 else
1966 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1967 spc, flags, false);
1968 pp_string (pp, " bits)>");
1969 break;
1971 case ARRAY_REF:
1972 case ARRAY_RANGE_REF:
1973 op0 = TREE_OPERAND (node, 0);
1974 if (op_prio (op0) < op_prio (node))
1975 pp_left_paren (pp);
1976 dump_generic_node (pp, op0, spc, flags, false);
1977 if (op_prio (op0) < op_prio (node))
1978 pp_right_paren (pp);
1979 pp_left_bracket (pp);
1980 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1981 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1982 pp_string (pp, " ...");
1983 pp_right_bracket (pp);
1985 op0 = array_ref_low_bound (node);
1986 op1 = array_ref_element_size (node);
1988 if (!integer_zerop (op0)
1989 || TREE_OPERAND (node, 2)
1990 || TREE_OPERAND (node, 3))
1992 pp_string (pp, "{lb: ");
1993 dump_generic_node (pp, op0, spc, flags, false);
1994 pp_string (pp, " sz: ");
1995 dump_generic_node (pp, op1, spc, flags, false);
1996 pp_right_brace (pp);
1998 break;
2000 case CONSTRUCTOR:
2002 unsigned HOST_WIDE_INT ix;
2003 tree field, val;
2004 bool is_struct_init = false;
2005 bool is_array_init = false;
2006 widest_int curidx;
2007 pp_left_brace (pp);
2008 if (TREE_CLOBBER_P (node))
2009 pp_string (pp, "CLOBBER");
2010 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2011 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2012 is_struct_init = true;
2013 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2014 && TYPE_DOMAIN (TREE_TYPE (node))
2015 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2016 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2017 == INTEGER_CST)
2019 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2020 is_array_init = true;
2021 curidx = wi::to_widest (minv);
2023 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2025 if (field)
2027 if (is_struct_init)
2029 pp_dot (pp);
2030 dump_generic_node (pp, field, spc, flags, false);
2031 pp_equal (pp);
2033 else if (is_array_init
2034 && (TREE_CODE (field) != INTEGER_CST
2035 || curidx != wi::to_widest (field)))
2037 pp_left_bracket (pp);
2038 if (TREE_CODE (field) == RANGE_EXPR)
2040 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2041 flags, false);
2042 pp_string (pp, " ... ");
2043 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2044 flags, false);
2045 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2046 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2048 else
2049 dump_generic_node (pp, field, spc, flags, false);
2050 if (TREE_CODE (field) == INTEGER_CST)
2051 curidx = wi::to_widest (field);
2052 pp_string (pp, "]=");
2055 if (is_array_init)
2056 curidx += 1;
2057 if (val && TREE_CODE (val) == ADDR_EXPR)
2058 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2059 val = TREE_OPERAND (val, 0);
2060 if (val && TREE_CODE (val) == FUNCTION_DECL)
2061 dump_decl_name (pp, val, flags);
2062 else
2063 dump_generic_node (pp, val, spc, flags, false);
2064 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2066 pp_comma (pp);
2067 pp_space (pp);
2070 pp_right_brace (pp);
2072 break;
2074 case COMPOUND_EXPR:
2076 tree *tp;
2077 if (flags & TDF_SLIM)
2079 pp_string (pp, "<COMPOUND_EXPR>");
2080 break;
2083 dump_generic_node (pp, TREE_OPERAND (node, 0),
2084 spc, flags, !(flags & TDF_SLIM));
2085 if (flags & TDF_SLIM)
2086 newline_and_indent (pp, spc);
2087 else
2089 pp_comma (pp);
2090 pp_space (pp);
2093 for (tp = &TREE_OPERAND (node, 1);
2094 TREE_CODE (*tp) == COMPOUND_EXPR;
2095 tp = &TREE_OPERAND (*tp, 1))
2097 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2098 spc, flags, !(flags & TDF_SLIM));
2099 if (flags & TDF_SLIM)
2100 newline_and_indent (pp, spc);
2101 else
2103 pp_comma (pp);
2104 pp_space (pp);
2108 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2110 break;
2112 case STATEMENT_LIST:
2114 tree_stmt_iterator si;
2115 bool first = true;
2117 if (flags & TDF_SLIM)
2119 pp_string (pp, "<STATEMENT_LIST>");
2120 break;
2123 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2125 if (!first)
2126 newline_and_indent (pp, spc);
2127 else
2128 first = false;
2129 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2132 break;
2134 case MODIFY_EXPR:
2135 case INIT_EXPR:
2136 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2137 false);
2138 pp_space (pp);
2139 pp_equal (pp);
2140 pp_space (pp);
2141 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2142 false);
2143 break;
2145 case TARGET_EXPR:
2146 pp_string (pp, "TARGET_EXPR <");
2147 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2148 pp_comma (pp);
2149 pp_space (pp);
2150 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2151 pp_greater (pp);
2152 break;
2154 case DECL_EXPR:
2155 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2156 is_stmt = false;
2157 break;
2159 case COND_EXPR:
2160 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2162 pp_string (pp, "if (");
2163 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2164 pp_right_paren (pp);
2165 /* The lowered cond_exprs should always be printed in full. */
2166 if (COND_EXPR_THEN (node)
2167 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2168 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2169 && COND_EXPR_ELSE (node)
2170 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2171 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2173 pp_space (pp);
2174 dump_generic_node (pp, COND_EXPR_THEN (node),
2175 0, flags, true);
2176 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2178 pp_string (pp, " else ");
2179 dump_generic_node (pp, COND_EXPR_ELSE (node),
2180 0, flags, true);
2183 else if (!(flags & TDF_SLIM))
2185 /* Output COND_EXPR_THEN. */
2186 if (COND_EXPR_THEN (node))
2188 newline_and_indent (pp, spc+2);
2189 pp_left_brace (pp);
2190 newline_and_indent (pp, spc+4);
2191 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2192 flags, true);
2193 newline_and_indent (pp, spc+2);
2194 pp_right_brace (pp);
2197 /* Output COND_EXPR_ELSE. */
2198 if (COND_EXPR_ELSE (node)
2199 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2201 newline_and_indent (pp, spc);
2202 pp_string (pp, "else");
2203 newline_and_indent (pp, spc+2);
2204 pp_left_brace (pp);
2205 newline_and_indent (pp, spc+4);
2206 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2207 flags, true);
2208 newline_and_indent (pp, spc+2);
2209 pp_right_brace (pp);
2212 is_expr = false;
2214 else
2216 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2217 pp_space (pp);
2218 pp_question (pp);
2219 pp_space (pp);
2220 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2221 pp_space (pp);
2222 pp_colon (pp);
2223 pp_space (pp);
2224 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2226 break;
2228 case BIND_EXPR:
2229 pp_left_brace (pp);
2230 if (!(flags & TDF_SLIM))
2232 if (BIND_EXPR_VARS (node))
2234 pp_newline (pp);
2236 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2238 print_declaration (pp, op0, spc+2, flags);
2239 pp_newline (pp);
2243 newline_and_indent (pp, spc+2);
2244 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2245 newline_and_indent (pp, spc);
2246 pp_right_brace (pp);
2248 is_expr = false;
2249 break;
2251 case CALL_EXPR:
2252 if (CALL_EXPR_FN (node) != NULL_TREE)
2253 print_call_name (pp, CALL_EXPR_FN (node), flags);
2254 else
2255 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2257 /* Print parameters. */
2258 pp_space (pp);
2259 pp_left_paren (pp);
2261 tree arg;
2262 call_expr_arg_iterator iter;
2263 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2265 dump_generic_node (pp, arg, spc, flags, false);
2266 if (more_call_expr_args_p (&iter))
2268 pp_comma (pp);
2269 pp_space (pp);
2273 if (CALL_EXPR_VA_ARG_PACK (node))
2275 if (call_expr_nargs (node) > 0)
2277 pp_comma (pp);
2278 pp_space (pp);
2280 pp_string (pp, "__builtin_va_arg_pack ()");
2282 pp_right_paren (pp);
2284 op1 = CALL_EXPR_STATIC_CHAIN (node);
2285 if (op1)
2287 pp_string (pp, " [static-chain: ");
2288 dump_generic_node (pp, op1, spc, flags, false);
2289 pp_right_bracket (pp);
2292 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2293 pp_string (pp, " [return slot optimization]");
2294 if (CALL_EXPR_TAILCALL (node))
2295 pp_string (pp, " [tail call]");
2296 break;
2298 case WITH_CLEANUP_EXPR:
2299 NIY;
2300 break;
2302 case CLEANUP_POINT_EXPR:
2303 pp_string (pp, "<<cleanup_point ");
2304 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2305 pp_string (pp, ">>");
2306 break;
2308 case PLACEHOLDER_EXPR:
2309 pp_string (pp, "<PLACEHOLDER_EXPR ");
2310 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2311 pp_greater (pp);
2312 break;
2314 /* Binary arithmetic and logic expressions. */
2315 case WIDEN_SUM_EXPR:
2316 case WIDEN_MULT_EXPR:
2317 case MULT_EXPR:
2318 case MULT_HIGHPART_EXPR:
2319 case PLUS_EXPR:
2320 case POINTER_PLUS_EXPR:
2321 case MINUS_EXPR:
2322 case TRUNC_DIV_EXPR:
2323 case CEIL_DIV_EXPR:
2324 case FLOOR_DIV_EXPR:
2325 case ROUND_DIV_EXPR:
2326 case TRUNC_MOD_EXPR:
2327 case CEIL_MOD_EXPR:
2328 case FLOOR_MOD_EXPR:
2329 case ROUND_MOD_EXPR:
2330 case RDIV_EXPR:
2331 case EXACT_DIV_EXPR:
2332 case LSHIFT_EXPR:
2333 case RSHIFT_EXPR:
2334 case LROTATE_EXPR:
2335 case RROTATE_EXPR:
2336 case WIDEN_LSHIFT_EXPR:
2337 case BIT_IOR_EXPR:
2338 case BIT_XOR_EXPR:
2339 case BIT_AND_EXPR:
2340 case TRUTH_ANDIF_EXPR:
2341 case TRUTH_ORIF_EXPR:
2342 case TRUTH_AND_EXPR:
2343 case TRUTH_OR_EXPR:
2344 case TRUTH_XOR_EXPR:
2345 case LT_EXPR:
2346 case LE_EXPR:
2347 case GT_EXPR:
2348 case GE_EXPR:
2349 case EQ_EXPR:
2350 case NE_EXPR:
2351 case UNLT_EXPR:
2352 case UNLE_EXPR:
2353 case UNGT_EXPR:
2354 case UNGE_EXPR:
2355 case UNEQ_EXPR:
2356 case LTGT_EXPR:
2357 case ORDERED_EXPR:
2358 case UNORDERED_EXPR:
2360 const char *op = op_symbol (node);
2361 op0 = TREE_OPERAND (node, 0);
2362 op1 = TREE_OPERAND (node, 1);
2364 /* When the operands are expressions with less priority,
2365 keep semantics of the tree representation. */
2366 if (op_prio (op0) <= op_prio (node))
2368 pp_left_paren (pp);
2369 dump_generic_node (pp, op0, spc, flags, false);
2370 pp_right_paren (pp);
2372 else
2373 dump_generic_node (pp, op0, spc, flags, false);
2375 pp_space (pp);
2376 pp_string (pp, op);
2377 pp_space (pp);
2379 /* When the operands are expressions with less priority,
2380 keep semantics of the tree representation. */
2381 if (op_prio (op1) <= op_prio (node))
2383 pp_left_paren (pp);
2384 dump_generic_node (pp, op1, spc, flags, false);
2385 pp_right_paren (pp);
2387 else
2388 dump_generic_node (pp, op1, spc, flags, false);
2390 break;
2392 /* Unary arithmetic and logic expressions. */
2393 case NEGATE_EXPR:
2394 case BIT_NOT_EXPR:
2395 case TRUTH_NOT_EXPR:
2396 case ADDR_EXPR:
2397 case PREDECREMENT_EXPR:
2398 case PREINCREMENT_EXPR:
2399 case INDIRECT_REF:
2400 if (TREE_CODE (node) == ADDR_EXPR
2401 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2402 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2403 ; /* Do not output '&' for strings and function pointers. */
2404 else
2405 pp_string (pp, op_symbol (node));
2407 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2409 pp_left_paren (pp);
2410 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2411 pp_right_paren (pp);
2413 else
2414 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2415 break;
2417 case POSTDECREMENT_EXPR:
2418 case POSTINCREMENT_EXPR:
2419 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2421 pp_left_paren (pp);
2422 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2423 pp_right_paren (pp);
2425 else
2426 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2427 pp_string (pp, op_symbol (node));
2428 break;
2430 case MIN_EXPR:
2431 pp_string (pp, "MIN_EXPR <");
2432 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2433 pp_string (pp, ", ");
2434 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2435 pp_greater (pp);
2436 break;
2438 case MAX_EXPR:
2439 pp_string (pp, "MAX_EXPR <");
2440 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2441 pp_string (pp, ", ");
2442 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2443 pp_greater (pp);
2444 break;
2446 case ABS_EXPR:
2447 pp_string (pp, "ABS_EXPR <");
2448 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2449 pp_greater (pp);
2450 break;
2452 case RANGE_EXPR:
2453 NIY;
2454 break;
2456 case ADDR_SPACE_CONVERT_EXPR:
2457 case FIXED_CONVERT_EXPR:
2458 case FIX_TRUNC_EXPR:
2459 case FLOAT_EXPR:
2460 CASE_CONVERT:
2461 type = TREE_TYPE (node);
2462 op0 = TREE_OPERAND (node, 0);
2463 if (type != TREE_TYPE (op0))
2465 pp_left_paren (pp);
2466 dump_generic_node (pp, type, spc, flags, false);
2467 pp_string (pp, ") ");
2469 if (op_prio (op0) < op_prio (node))
2470 pp_left_paren (pp);
2471 dump_generic_node (pp, op0, spc, flags, false);
2472 if (op_prio (op0) < op_prio (node))
2473 pp_right_paren (pp);
2474 break;
2476 case VIEW_CONVERT_EXPR:
2477 pp_string (pp, "VIEW_CONVERT_EXPR<");
2478 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2479 pp_string (pp, ">(");
2480 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2481 pp_right_paren (pp);
2482 break;
2484 case PAREN_EXPR:
2485 pp_string (pp, "((");
2486 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2487 pp_string (pp, "))");
2488 break;
2490 case NON_LVALUE_EXPR:
2491 pp_string (pp, "NON_LVALUE_EXPR <");
2492 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2493 pp_greater (pp);
2494 break;
2496 case SAVE_EXPR:
2497 pp_string (pp, "SAVE_EXPR <");
2498 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2499 pp_greater (pp);
2500 break;
2502 case COMPLEX_EXPR:
2503 pp_string (pp, "COMPLEX_EXPR <");
2504 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2505 pp_string (pp, ", ");
2506 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2507 pp_greater (pp);
2508 break;
2510 case CONJ_EXPR:
2511 pp_string (pp, "CONJ_EXPR <");
2512 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2513 pp_greater (pp);
2514 break;
2516 case REALPART_EXPR:
2517 if (flags & TDF_GIMPLE)
2519 pp_string (pp, "__real ");
2520 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2522 else
2524 pp_string (pp, "REALPART_EXPR <");
2525 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2526 pp_greater (pp);
2528 break;
2530 case IMAGPART_EXPR:
2531 if (flags & TDF_GIMPLE)
2533 pp_string (pp, "__imag ");
2534 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2536 else
2538 pp_string (pp, "IMAGPART_EXPR <");
2539 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2540 pp_greater (pp);
2542 break;
2544 case VA_ARG_EXPR:
2545 pp_string (pp, "VA_ARG_EXPR <");
2546 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2547 pp_greater (pp);
2548 break;
2550 case TRY_FINALLY_EXPR:
2551 case TRY_CATCH_EXPR:
2552 pp_string (pp, "try");
2553 newline_and_indent (pp, spc+2);
2554 pp_left_brace (pp);
2555 newline_and_indent (pp, spc+4);
2556 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2557 newline_and_indent (pp, spc+2);
2558 pp_right_brace (pp);
2559 newline_and_indent (pp, spc);
2560 pp_string (pp,
2561 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2562 newline_and_indent (pp, spc+2);
2563 pp_left_brace (pp);
2564 newline_and_indent (pp, spc+4);
2565 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2566 newline_and_indent (pp, spc+2);
2567 pp_right_brace (pp);
2568 is_expr = false;
2569 break;
2571 case CATCH_EXPR:
2572 pp_string (pp, "catch (");
2573 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2574 pp_right_paren (pp);
2575 newline_and_indent (pp, spc+2);
2576 pp_left_brace (pp);
2577 newline_and_indent (pp, spc+4);
2578 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2579 newline_and_indent (pp, spc+2);
2580 pp_right_brace (pp);
2581 is_expr = false;
2582 break;
2584 case EH_FILTER_EXPR:
2585 pp_string (pp, "<<<eh_filter (");
2586 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2587 pp_string (pp, ")>>>");
2588 newline_and_indent (pp, spc+2);
2589 pp_left_brace (pp);
2590 newline_and_indent (pp, spc+4);
2591 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2592 newline_and_indent (pp, spc+2);
2593 pp_right_brace (pp);
2594 is_expr = false;
2595 break;
2597 case LABEL_EXPR:
2598 op0 = TREE_OPERAND (node, 0);
2599 /* If this is for break or continue, don't bother printing it. */
2600 if (DECL_NAME (op0))
2602 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2603 if (strcmp (name, "break") == 0
2604 || strcmp (name, "continue") == 0)
2605 break;
2607 dump_generic_node (pp, op0, spc, flags, false);
2608 pp_colon (pp);
2609 if (DECL_NONLOCAL (op0))
2610 pp_string (pp, " [non-local]");
2611 break;
2613 case LOOP_EXPR:
2614 pp_string (pp, "while (1)");
2615 if (!(flags & TDF_SLIM))
2617 newline_and_indent (pp, spc+2);
2618 pp_left_brace (pp);
2619 newline_and_indent (pp, spc+4);
2620 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2621 newline_and_indent (pp, spc+2);
2622 pp_right_brace (pp);
2624 is_expr = false;
2625 break;
2627 case PREDICT_EXPR:
2628 pp_string (pp, "// predicted ");
2629 if (PREDICT_EXPR_OUTCOME (node))
2630 pp_string (pp, "likely by ");
2631 else
2632 pp_string (pp, "unlikely by ");
2633 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2634 pp_string (pp, " predictor.");
2635 break;
2637 case ANNOTATE_EXPR:
2638 pp_string (pp, "ANNOTATE_EXPR <");
2639 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2640 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2642 case annot_expr_ivdep_kind:
2643 pp_string (pp, ", ivdep");
2644 break;
2645 case annot_expr_no_vector_kind:
2646 pp_string (pp, ", no-vector");
2647 break;
2648 case annot_expr_vector_kind:
2649 pp_string (pp, ", vector");
2650 break;
2651 default:
2652 gcc_unreachable ();
2654 pp_greater (pp);
2655 break;
2657 case RETURN_EXPR:
2658 pp_string (pp, "return");
2659 op0 = TREE_OPERAND (node, 0);
2660 if (op0)
2662 pp_space (pp);
2663 if (TREE_CODE (op0) == MODIFY_EXPR)
2664 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2665 spc, flags, false);
2666 else
2667 dump_generic_node (pp, op0, spc, flags, false);
2669 break;
2671 case EXIT_EXPR:
2672 pp_string (pp, "if (");
2673 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2674 pp_string (pp, ") break");
2675 break;
2677 case SWITCH_EXPR:
2678 pp_string (pp, "switch (");
2679 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2680 pp_right_paren (pp);
2681 if (!(flags & TDF_SLIM))
2683 newline_and_indent (pp, spc+2);
2684 pp_left_brace (pp);
2685 if (SWITCH_BODY (node))
2687 newline_and_indent (pp, spc+4);
2688 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2689 true);
2691 else
2693 tree vec = SWITCH_LABELS (node);
2694 size_t i, n = TREE_VEC_LENGTH (vec);
2695 for (i = 0; i < n; ++i)
2697 tree elt = TREE_VEC_ELT (vec, i);
2698 newline_and_indent (pp, spc+4);
2699 if (elt)
2701 dump_generic_node (pp, elt, spc+4, flags, false);
2702 pp_string (pp, " goto ");
2703 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2704 flags, true);
2705 pp_semicolon (pp);
2707 else
2708 pp_string (pp, "case ???: goto ???;");
2711 newline_and_indent (pp, spc+2);
2712 pp_right_brace (pp);
2714 is_expr = false;
2715 break;
2717 case GOTO_EXPR:
2718 op0 = GOTO_DESTINATION (node);
2719 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2721 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2722 if (strcmp (name, "break") == 0
2723 || strcmp (name, "continue") == 0)
2725 pp_string (pp, name);
2726 break;
2729 pp_string (pp, "goto ");
2730 dump_generic_node (pp, op0, spc, flags, false);
2731 break;
2733 case ASM_EXPR:
2734 pp_string (pp, "__asm__");
2735 if (ASM_VOLATILE_P (node))
2736 pp_string (pp, " __volatile__");
2737 pp_left_paren (pp);
2738 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2739 pp_colon (pp);
2740 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2741 pp_colon (pp);
2742 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2743 if (ASM_CLOBBERS (node))
2745 pp_colon (pp);
2746 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2748 pp_right_paren (pp);
2749 break;
2751 case CASE_LABEL_EXPR:
2752 if (CASE_LOW (node) && CASE_HIGH (node))
2754 pp_string (pp, "case ");
2755 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2756 pp_string (pp, " ... ");
2757 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2759 else if (CASE_LOW (node))
2761 pp_string (pp, "case ");
2762 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2764 else
2765 pp_string (pp, "default");
2766 pp_colon (pp);
2767 break;
2769 case OBJ_TYPE_REF:
2770 pp_string (pp, "OBJ_TYPE_REF(");
2771 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2772 pp_semicolon (pp);
2773 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2775 pp_string (pp, "(");
2776 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2777 pp_string (pp, ")");
2779 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2780 pp_arrow (pp);
2781 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2782 pp_right_paren (pp);
2783 break;
2785 case SSA_NAME:
2786 if (SSA_NAME_IDENTIFIER (node))
2788 if ((flags & TDF_NOUID)
2789 && SSA_NAME_VAR (node)
2790 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2791 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2792 else if (! (flags & TDF_GIMPLE)
2793 || SSA_NAME_VAR (node))
2794 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2795 spc, flags, false);
2797 pp_underscore (pp);
2798 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2799 if (SSA_NAME_IS_DEFAULT_DEF (node))
2800 pp_string (pp, "(D)");
2801 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2802 pp_string (pp, "(ab)");
2803 break;
2805 case WITH_SIZE_EXPR:
2806 pp_string (pp, "WITH_SIZE_EXPR <");
2807 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2808 pp_string (pp, ", ");
2809 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2810 pp_greater (pp);
2811 break;
2813 case ASSERT_EXPR:
2814 pp_string (pp, "ASSERT_EXPR <");
2815 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2816 pp_string (pp, ", ");
2817 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2818 pp_greater (pp);
2819 break;
2821 case SCEV_KNOWN:
2822 pp_string (pp, "scev_known");
2823 break;
2825 case SCEV_NOT_KNOWN:
2826 pp_string (pp, "scev_not_known");
2827 break;
2829 case POLYNOMIAL_CHREC:
2830 pp_left_brace (pp);
2831 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2832 pp_string (pp, ", +, ");
2833 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2834 pp_string (pp, "}_");
2835 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2836 is_stmt = false;
2837 break;
2839 case REALIGN_LOAD_EXPR:
2840 pp_string (pp, "REALIGN_LOAD <");
2841 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2842 pp_string (pp, ", ");
2843 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2844 pp_string (pp, ", ");
2845 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2846 pp_greater (pp);
2847 break;
2849 case VEC_COND_EXPR:
2850 pp_string (pp, " VEC_COND_EXPR < ");
2851 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2852 pp_string (pp, " , ");
2853 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2854 pp_string (pp, " , ");
2855 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2856 pp_string (pp, " > ");
2857 break;
2859 case VEC_PERM_EXPR:
2860 pp_string (pp, " VEC_PERM_EXPR < ");
2861 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2862 pp_string (pp, " , ");
2863 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2864 pp_string (pp, " , ");
2865 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2866 pp_string (pp, " > ");
2867 break;
2869 case DOT_PROD_EXPR:
2870 pp_string (pp, " DOT_PROD_EXPR < ");
2871 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2872 pp_string (pp, ", ");
2873 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2874 pp_string (pp, ", ");
2875 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2876 pp_string (pp, " > ");
2877 break;
2879 case WIDEN_MULT_PLUS_EXPR:
2880 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2881 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2882 pp_string (pp, ", ");
2883 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2884 pp_string (pp, ", ");
2885 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2886 pp_string (pp, " > ");
2887 break;
2889 case WIDEN_MULT_MINUS_EXPR:
2890 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2891 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2892 pp_string (pp, ", ");
2893 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2894 pp_string (pp, ", ");
2895 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2896 pp_string (pp, " > ");
2897 break;
2899 case FMA_EXPR:
2900 pp_string (pp, " FMA_EXPR < ");
2901 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2902 pp_string (pp, ", ");
2903 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2904 pp_string (pp, ", ");
2905 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2906 pp_string (pp, " > ");
2907 break;
2909 case OACC_PARALLEL:
2910 pp_string (pp, "#pragma acc parallel");
2911 goto dump_omp_clauses_body;
2913 case OACC_KERNELS:
2914 pp_string (pp, "#pragma acc kernels");
2915 goto dump_omp_clauses_body;
2917 case OACC_DATA:
2918 pp_string (pp, "#pragma acc data");
2919 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2920 goto dump_omp_body;
2922 case OACC_HOST_DATA:
2923 pp_string (pp, "#pragma acc host_data");
2924 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2925 goto dump_omp_body;
2927 case OACC_DECLARE:
2928 pp_string (pp, "#pragma acc declare");
2929 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2930 break;
2932 case OACC_UPDATE:
2933 pp_string (pp, "#pragma acc update");
2934 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2935 break;
2937 case OACC_ENTER_DATA:
2938 pp_string (pp, "#pragma acc enter data");
2939 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2940 break;
2942 case OACC_EXIT_DATA:
2943 pp_string (pp, "#pragma acc exit data");
2944 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2945 break;
2947 case OACC_CACHE:
2948 pp_string (pp, "#pragma acc cache");
2949 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2950 break;
2952 case OMP_PARALLEL:
2953 pp_string (pp, "#pragma omp parallel");
2954 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2955 goto dump_omp_body;
2957 dump_omp_clauses_body:
2958 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2959 goto dump_omp_body;
2961 dump_omp_body:
2962 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2964 newline_and_indent (pp, spc + 2);
2965 pp_left_brace (pp);
2966 newline_and_indent (pp, spc + 4);
2967 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2968 newline_and_indent (pp, spc + 2);
2969 pp_right_brace (pp);
2971 is_expr = false;
2972 break;
2974 case OMP_TASK:
2975 pp_string (pp, "#pragma omp task");
2976 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2977 goto dump_omp_body;
2979 case OMP_FOR:
2980 pp_string (pp, "#pragma omp for");
2981 goto dump_omp_loop;
2983 case OMP_SIMD:
2984 pp_string (pp, "#pragma omp simd");
2985 goto dump_omp_loop;
2987 case CILK_SIMD:
2988 pp_string (pp, "#pragma simd");
2989 goto dump_omp_loop;
2991 case CILK_FOR:
2992 /* This label points one line after dumping the clauses.
2993 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2994 parameters are printed out. */
2995 goto dump_omp_loop_cilk_for;
2997 case OMP_DISTRIBUTE:
2998 pp_string (pp, "#pragma omp distribute");
2999 goto dump_omp_loop;
3001 case OMP_TASKLOOP:
3002 pp_string (pp, "#pragma omp taskloop");
3003 goto dump_omp_loop;
3005 case OACC_LOOP:
3006 pp_string (pp, "#pragma acc loop");
3007 goto dump_omp_loop;
3009 case OMP_TEAMS:
3010 pp_string (pp, "#pragma omp teams");
3011 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3012 goto dump_omp_body;
3014 case OMP_TARGET_DATA:
3015 pp_string (pp, "#pragma omp target data");
3016 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3017 goto dump_omp_body;
3019 case OMP_TARGET_ENTER_DATA:
3020 pp_string (pp, "#pragma omp target enter data");
3021 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3022 is_expr = false;
3023 break;
3025 case OMP_TARGET_EXIT_DATA:
3026 pp_string (pp, "#pragma omp target exit data");
3027 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3028 is_expr = false;
3029 break;
3031 case OMP_TARGET:
3032 pp_string (pp, "#pragma omp target");
3033 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3034 goto dump_omp_body;
3036 case OMP_TARGET_UPDATE:
3037 pp_string (pp, "#pragma omp target update");
3038 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3039 is_expr = false;
3040 break;
3042 dump_omp_loop:
3043 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3045 dump_omp_loop_cilk_for:
3046 if (!(flags & TDF_SLIM))
3048 int i;
3050 if (OMP_FOR_PRE_BODY (node))
3052 if (TREE_CODE (node) == CILK_FOR)
3053 pp_string (pp, " ");
3054 else
3055 newline_and_indent (pp, spc + 2);
3056 pp_left_brace (pp);
3057 spc += 4;
3058 newline_and_indent (pp, spc);
3059 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3060 spc, flags, false);
3062 if (OMP_FOR_INIT (node))
3064 spc -= 2;
3065 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3067 spc += 2;
3068 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
3069 newline_and_indent (pp, spc);
3070 if (TREE_CODE (node) == CILK_FOR)
3071 pp_string (pp, "_Cilk_for (");
3072 else
3073 pp_string (pp, "for (");
3074 dump_generic_node (pp,
3075 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3076 spc, flags, false);
3077 pp_string (pp, "; ");
3078 dump_generic_node (pp,
3079 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3080 spc, flags, false);
3081 pp_string (pp, "; ");
3082 dump_generic_node (pp,
3083 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3084 spc, flags, false);
3085 pp_right_paren (pp);
3087 if (TREE_CODE (node) == CILK_FOR)
3088 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3090 if (OMP_FOR_BODY (node))
3092 newline_and_indent (pp, spc + 2);
3093 pp_left_brace (pp);
3094 newline_and_indent (pp, spc + 4);
3095 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3096 false);
3097 newline_and_indent (pp, spc + 2);
3098 pp_right_brace (pp);
3100 if (OMP_FOR_INIT (node))
3101 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3102 if (OMP_FOR_PRE_BODY (node))
3104 spc -= 4;
3105 newline_and_indent (pp, spc + 2);
3106 pp_right_brace (pp);
3109 is_expr = false;
3110 break;
3112 case OMP_SECTIONS:
3113 pp_string (pp, "#pragma omp sections");
3114 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3115 goto dump_omp_body;
3117 case OMP_SECTION:
3118 pp_string (pp, "#pragma omp section");
3119 goto dump_omp_body;
3121 case OMP_MASTER:
3122 pp_string (pp, "#pragma omp master");
3123 goto dump_omp_body;
3125 case OMP_TASKGROUP:
3126 pp_string (pp, "#pragma omp taskgroup");
3127 goto dump_omp_body;
3129 case OMP_ORDERED:
3130 pp_string (pp, "#pragma omp ordered");
3131 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3132 goto dump_omp_body;
3134 case OMP_CRITICAL:
3135 pp_string (pp, "#pragma omp critical");
3136 if (OMP_CRITICAL_NAME (node))
3138 pp_space (pp);
3139 pp_left_paren (pp);
3140 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3141 flags, false);
3142 pp_right_paren (pp);
3144 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3145 goto dump_omp_body;
3147 case OMP_ATOMIC:
3148 pp_string (pp, "#pragma omp atomic");
3149 if (OMP_ATOMIC_SEQ_CST (node))
3150 pp_string (pp, " seq_cst");
3151 newline_and_indent (pp, spc + 2);
3152 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3153 pp_space (pp);
3154 pp_equal (pp);
3155 pp_space (pp);
3156 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3157 break;
3159 case OMP_ATOMIC_READ:
3160 pp_string (pp, "#pragma omp atomic read");
3161 if (OMP_ATOMIC_SEQ_CST (node))
3162 pp_string (pp, " seq_cst");
3163 newline_and_indent (pp, spc + 2);
3164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3165 pp_space (pp);
3166 break;
3168 case OMP_ATOMIC_CAPTURE_OLD:
3169 case OMP_ATOMIC_CAPTURE_NEW:
3170 pp_string (pp, "#pragma omp atomic capture");
3171 if (OMP_ATOMIC_SEQ_CST (node))
3172 pp_string (pp, " seq_cst");
3173 newline_and_indent (pp, spc + 2);
3174 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3175 pp_space (pp);
3176 pp_equal (pp);
3177 pp_space (pp);
3178 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3179 break;
3181 case OMP_SINGLE:
3182 pp_string (pp, "#pragma omp single");
3183 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3184 goto dump_omp_body;
3186 case OMP_CLAUSE:
3187 dump_omp_clause (pp, node, spc, flags);
3188 is_expr = false;
3189 break;
3191 case TRANSACTION_EXPR:
3192 if (TRANSACTION_EXPR_OUTER (node))
3193 pp_string (pp, "__transaction_atomic [[outer]]");
3194 else if (TRANSACTION_EXPR_RELAXED (node))
3195 pp_string (pp, "__transaction_relaxed");
3196 else
3197 pp_string (pp, "__transaction_atomic");
3198 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3200 newline_and_indent (pp, spc);
3201 pp_left_brace (pp);
3202 newline_and_indent (pp, spc + 2);
3203 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3204 spc + 2, flags, false);
3205 newline_and_indent (pp, spc);
3206 pp_right_brace (pp);
3208 is_expr = false;
3209 break;
3211 case REDUC_MAX_EXPR:
3212 pp_string (pp, " REDUC_MAX_EXPR < ");
3213 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3214 pp_string (pp, " > ");
3215 break;
3217 case REDUC_MIN_EXPR:
3218 pp_string (pp, " REDUC_MIN_EXPR < ");
3219 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3220 pp_string (pp, " > ");
3221 break;
3223 case REDUC_PLUS_EXPR:
3224 pp_string (pp, " REDUC_PLUS_EXPR < ");
3225 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3226 pp_string (pp, " > ");
3227 break;
3229 case VEC_WIDEN_MULT_HI_EXPR:
3230 case VEC_WIDEN_MULT_LO_EXPR:
3231 case VEC_WIDEN_MULT_EVEN_EXPR:
3232 case VEC_WIDEN_MULT_ODD_EXPR:
3233 case VEC_WIDEN_LSHIFT_HI_EXPR:
3234 case VEC_WIDEN_LSHIFT_LO_EXPR:
3235 pp_space (pp);
3236 for (str = get_tree_code_name (code); *str; str++)
3237 pp_character (pp, TOUPPER (*str));
3238 pp_string (pp, " < ");
3239 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3240 pp_string (pp, ", ");
3241 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3242 pp_string (pp, " > ");
3243 break;
3245 case VEC_UNPACK_HI_EXPR:
3246 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3247 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3248 pp_string (pp, " > ");
3249 break;
3251 case VEC_UNPACK_LO_EXPR:
3252 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3253 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3254 pp_string (pp, " > ");
3255 break;
3257 case VEC_UNPACK_FLOAT_HI_EXPR:
3258 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3259 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3260 pp_string (pp, " > ");
3261 break;
3263 case VEC_UNPACK_FLOAT_LO_EXPR:
3264 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3265 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3266 pp_string (pp, " > ");
3267 break;
3269 case VEC_PACK_TRUNC_EXPR:
3270 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3271 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3272 pp_string (pp, ", ");
3273 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3274 pp_string (pp, " > ");
3275 break;
3277 case VEC_PACK_SAT_EXPR:
3278 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3279 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3280 pp_string (pp, ", ");
3281 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3282 pp_string (pp, " > ");
3283 break;
3285 case VEC_PACK_FIX_TRUNC_EXPR:
3286 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3287 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3288 pp_string (pp, ", ");
3289 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3290 pp_string (pp, " > ");
3291 break;
3293 case BLOCK:
3294 dump_block_node (pp, node, spc, flags);
3295 break;
3297 case CILK_SPAWN_STMT:
3298 pp_string (pp, "_Cilk_spawn ");
3299 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3300 break;
3302 case CILK_SYNC_STMT:
3303 pp_string (pp, "_Cilk_sync");
3304 break;
3306 default:
3307 NIY;
3310 if (is_stmt && is_expr)
3311 pp_semicolon (pp);
3313 return spc;
3316 /* Print the declaration of a variable. */
3318 void
3319 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3321 INDENT (spc);
3323 if (TREE_CODE(t) == NAMELIST_DECL)
3325 pp_string(pp, "namelist ");
3326 dump_decl_name (pp, t, flags);
3327 pp_semicolon (pp);
3328 return;
3331 if (TREE_CODE (t) == TYPE_DECL)
3332 pp_string (pp, "typedef ");
3334 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3335 pp_string (pp, "register ");
3337 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3338 pp_string (pp, "extern ");
3339 else if (TREE_STATIC (t))
3340 pp_string (pp, "static ");
3342 /* Print the type and name. */
3343 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3345 tree tmp;
3347 /* Print array's type. */
3348 tmp = TREE_TYPE (t);
3349 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3350 tmp = TREE_TYPE (tmp);
3351 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3353 /* Print variable's name. */
3354 pp_space (pp);
3355 dump_generic_node (pp, t, spc, flags, false);
3357 /* Print the dimensions. */
3358 tmp = TREE_TYPE (t);
3359 while (TREE_CODE (tmp) == ARRAY_TYPE)
3361 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3362 tmp = TREE_TYPE (tmp);
3365 else if (TREE_CODE (t) == FUNCTION_DECL)
3367 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3368 pp_space (pp);
3369 dump_decl_name (pp, t, flags);
3370 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3372 else
3374 /* Print type declaration. */
3375 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3377 /* Print variable's name. */
3378 pp_space (pp);
3379 dump_generic_node (pp, t, spc, flags, false);
3382 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3384 pp_string (pp, " __asm__ ");
3385 pp_left_paren (pp);
3386 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3387 pp_right_paren (pp);
3390 /* The initial value of a function serves to determine whether the function
3391 is declared or defined. So the following does not apply to function
3392 nodes. */
3393 if (TREE_CODE (t) != FUNCTION_DECL)
3395 /* Print the initial value. */
3396 if (DECL_INITIAL (t))
3398 pp_space (pp);
3399 pp_equal (pp);
3400 pp_space (pp);
3401 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3405 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3407 pp_string (pp, " [value-expr: ");
3408 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3409 pp_right_bracket (pp);
3412 pp_semicolon (pp);
3416 /* Prints a structure: name, fields, and methods.
3417 FIXME: Still incomplete. */
3419 static void
3420 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3421 dump_flags_t flags)
3423 /* Print the name of the structure. */
3424 if (TYPE_NAME (node))
3426 INDENT (spc);
3427 if (TREE_CODE (node) == RECORD_TYPE)
3428 pp_string (pp, "struct ");
3429 else if ((TREE_CODE (node) == UNION_TYPE
3430 || TREE_CODE (node) == QUAL_UNION_TYPE))
3431 pp_string (pp, "union ");
3433 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3436 /* Print the contents of the structure. */
3437 pp_newline (pp);
3438 INDENT (spc);
3439 pp_left_brace (pp);
3440 pp_newline (pp);
3442 /* Print the fields of the structure. */
3444 tree tmp;
3445 tmp = TYPE_FIELDS (node);
3446 while (tmp)
3448 /* Avoid to print recursively the structure. */
3449 /* FIXME : Not implemented correctly...,
3450 what about the case when we have a cycle in the contain graph? ...
3451 Maybe this could be solved by looking at the scope in which the
3452 structure was declared. */
3453 if (TREE_TYPE (tmp) != node
3454 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3455 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3457 print_declaration (pp, tmp, spc+2, flags);
3458 pp_newline (pp);
3460 tmp = DECL_CHAIN (tmp);
3463 INDENT (spc);
3464 pp_right_brace (pp);
3467 /* Return the priority of the operator CODE.
3469 From lowest to highest precedence with either left-to-right (L-R)
3470 or right-to-left (R-L) associativity]:
3472 1 [L-R] ,
3473 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3474 3 [R-L] ?:
3475 4 [L-R] ||
3476 5 [L-R] &&
3477 6 [L-R] |
3478 7 [L-R] ^
3479 8 [L-R] &
3480 9 [L-R] == !=
3481 10 [L-R] < <= > >=
3482 11 [L-R] << >>
3483 12 [L-R] + -
3484 13 [L-R] * / %
3485 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3486 15 [L-R] fn() [] -> .
3488 unary +, - and * have higher precedence than the corresponding binary
3489 operators. */
3492 op_code_prio (enum tree_code code)
3494 switch (code)
3496 case TREE_LIST:
3497 case COMPOUND_EXPR:
3498 case BIND_EXPR:
3499 return 1;
3501 case MODIFY_EXPR:
3502 case INIT_EXPR:
3503 return 2;
3505 case COND_EXPR:
3506 return 3;
3508 case TRUTH_OR_EXPR:
3509 case TRUTH_ORIF_EXPR:
3510 return 4;
3512 case TRUTH_AND_EXPR:
3513 case TRUTH_ANDIF_EXPR:
3514 return 5;
3516 case BIT_IOR_EXPR:
3517 return 6;
3519 case BIT_XOR_EXPR:
3520 case TRUTH_XOR_EXPR:
3521 return 7;
3523 case BIT_AND_EXPR:
3524 return 8;
3526 case EQ_EXPR:
3527 case NE_EXPR:
3528 return 9;
3530 case UNLT_EXPR:
3531 case UNLE_EXPR:
3532 case UNGT_EXPR:
3533 case UNGE_EXPR:
3534 case UNEQ_EXPR:
3535 case LTGT_EXPR:
3536 case ORDERED_EXPR:
3537 case UNORDERED_EXPR:
3538 case LT_EXPR:
3539 case LE_EXPR:
3540 case GT_EXPR:
3541 case GE_EXPR:
3542 return 10;
3544 case LSHIFT_EXPR:
3545 case RSHIFT_EXPR:
3546 case LROTATE_EXPR:
3547 case RROTATE_EXPR:
3548 case VEC_WIDEN_LSHIFT_HI_EXPR:
3549 case VEC_WIDEN_LSHIFT_LO_EXPR:
3550 case WIDEN_LSHIFT_EXPR:
3551 return 11;
3553 case WIDEN_SUM_EXPR:
3554 case PLUS_EXPR:
3555 case POINTER_PLUS_EXPR:
3556 case MINUS_EXPR:
3557 return 12;
3559 case VEC_WIDEN_MULT_HI_EXPR:
3560 case VEC_WIDEN_MULT_LO_EXPR:
3561 case WIDEN_MULT_EXPR:
3562 case DOT_PROD_EXPR:
3563 case WIDEN_MULT_PLUS_EXPR:
3564 case WIDEN_MULT_MINUS_EXPR:
3565 case MULT_EXPR:
3566 case MULT_HIGHPART_EXPR:
3567 case TRUNC_DIV_EXPR:
3568 case CEIL_DIV_EXPR:
3569 case FLOOR_DIV_EXPR:
3570 case ROUND_DIV_EXPR:
3571 case RDIV_EXPR:
3572 case EXACT_DIV_EXPR:
3573 case TRUNC_MOD_EXPR:
3574 case CEIL_MOD_EXPR:
3575 case FLOOR_MOD_EXPR:
3576 case ROUND_MOD_EXPR:
3577 case FMA_EXPR:
3578 return 13;
3580 case TRUTH_NOT_EXPR:
3581 case BIT_NOT_EXPR:
3582 case POSTINCREMENT_EXPR:
3583 case POSTDECREMENT_EXPR:
3584 case PREINCREMENT_EXPR:
3585 case PREDECREMENT_EXPR:
3586 case NEGATE_EXPR:
3587 case INDIRECT_REF:
3588 case ADDR_EXPR:
3589 case FLOAT_EXPR:
3590 CASE_CONVERT:
3591 case FIX_TRUNC_EXPR:
3592 case TARGET_EXPR:
3593 return 14;
3595 case CALL_EXPR:
3596 case ARRAY_REF:
3597 case ARRAY_RANGE_REF:
3598 case COMPONENT_REF:
3599 return 15;
3601 /* Special expressions. */
3602 case MIN_EXPR:
3603 case MAX_EXPR:
3604 case ABS_EXPR:
3605 case REALPART_EXPR:
3606 case IMAGPART_EXPR:
3607 case REDUC_MAX_EXPR:
3608 case REDUC_MIN_EXPR:
3609 case REDUC_PLUS_EXPR:
3610 case VEC_UNPACK_HI_EXPR:
3611 case VEC_UNPACK_LO_EXPR:
3612 case VEC_UNPACK_FLOAT_HI_EXPR:
3613 case VEC_UNPACK_FLOAT_LO_EXPR:
3614 case VEC_PACK_TRUNC_EXPR:
3615 case VEC_PACK_SAT_EXPR:
3616 return 16;
3618 default:
3619 /* Return an arbitrarily high precedence to avoid surrounding single
3620 VAR_DECLs in ()s. */
3621 return 9999;
3625 /* Return the priority of the operator OP. */
3628 op_prio (const_tree op)
3630 enum tree_code code;
3632 if (op == NULL)
3633 return 9999;
3635 code = TREE_CODE (op);
3636 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3637 return op_prio (TREE_OPERAND (op, 0));
3639 return op_code_prio (code);
3642 /* Return the symbol associated with operator CODE. */
3644 const char *
3645 op_symbol_code (enum tree_code code)
3647 switch (code)
3649 case MODIFY_EXPR:
3650 return "=";
3652 case TRUTH_OR_EXPR:
3653 case TRUTH_ORIF_EXPR:
3654 return "||";
3656 case TRUTH_AND_EXPR:
3657 case TRUTH_ANDIF_EXPR:
3658 return "&&";
3660 case BIT_IOR_EXPR:
3661 return "|";
3663 case TRUTH_XOR_EXPR:
3664 case BIT_XOR_EXPR:
3665 return "^";
3667 case ADDR_EXPR:
3668 case BIT_AND_EXPR:
3669 return "&";
3671 case ORDERED_EXPR:
3672 return "ord";
3673 case UNORDERED_EXPR:
3674 return "unord";
3676 case EQ_EXPR:
3677 return "==";
3678 case UNEQ_EXPR:
3679 return "u==";
3681 case NE_EXPR:
3682 return "!=";
3684 case LT_EXPR:
3685 return "<";
3686 case UNLT_EXPR:
3687 return "u<";
3689 case LE_EXPR:
3690 return "<=";
3691 case UNLE_EXPR:
3692 return "u<=";
3694 case GT_EXPR:
3695 return ">";
3696 case UNGT_EXPR:
3697 return "u>";
3699 case GE_EXPR:
3700 return ">=";
3701 case UNGE_EXPR:
3702 return "u>=";
3704 case LTGT_EXPR:
3705 return "<>";
3707 case LSHIFT_EXPR:
3708 return "<<";
3710 case RSHIFT_EXPR:
3711 return ">>";
3713 case LROTATE_EXPR:
3714 return "r<<";
3716 case RROTATE_EXPR:
3717 return "r>>";
3719 case WIDEN_LSHIFT_EXPR:
3720 return "w<<";
3722 case POINTER_PLUS_EXPR:
3723 return "+";
3725 case PLUS_EXPR:
3726 return "+";
3728 case REDUC_PLUS_EXPR:
3729 return "r+";
3731 case WIDEN_SUM_EXPR:
3732 return "w+";
3734 case WIDEN_MULT_EXPR:
3735 return "w*";
3737 case MULT_HIGHPART_EXPR:
3738 return "h*";
3740 case NEGATE_EXPR:
3741 case MINUS_EXPR:
3742 return "-";
3744 case BIT_NOT_EXPR:
3745 return "~";
3747 case TRUTH_NOT_EXPR:
3748 return "!";
3750 case MULT_EXPR:
3751 case INDIRECT_REF:
3752 return "*";
3754 case TRUNC_DIV_EXPR:
3755 case RDIV_EXPR:
3756 return "/";
3758 case CEIL_DIV_EXPR:
3759 return "/[cl]";
3761 case FLOOR_DIV_EXPR:
3762 return "/[fl]";
3764 case ROUND_DIV_EXPR:
3765 return "/[rd]";
3767 case EXACT_DIV_EXPR:
3768 return "/[ex]";
3770 case TRUNC_MOD_EXPR:
3771 return "%";
3773 case CEIL_MOD_EXPR:
3774 return "%[cl]";
3776 case FLOOR_MOD_EXPR:
3777 return "%[fl]";
3779 case ROUND_MOD_EXPR:
3780 return "%[rd]";
3782 case PREDECREMENT_EXPR:
3783 return " --";
3785 case PREINCREMENT_EXPR:
3786 return " ++";
3788 case POSTDECREMENT_EXPR:
3789 return "-- ";
3791 case POSTINCREMENT_EXPR:
3792 return "++ ";
3794 case MAX_EXPR:
3795 return "max";
3797 case MIN_EXPR:
3798 return "min";
3800 default:
3801 return "<<< ??? >>>";
3805 /* Return the symbol associated with operator OP. */
3807 static const char *
3808 op_symbol (const_tree op)
3810 return op_symbol_code (TREE_CODE (op));
3813 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3814 the gimple_call_fn of a GIMPLE_CALL. */
3816 void
3817 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3819 tree op0 = node;
3821 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3822 op0 = TREE_OPERAND (op0, 0);
3824 again:
3825 switch (TREE_CODE (op0))
3827 case VAR_DECL:
3828 case PARM_DECL:
3829 case FUNCTION_DECL:
3830 dump_function_name (pp, op0, flags);
3831 break;
3833 case ADDR_EXPR:
3834 case INDIRECT_REF:
3835 CASE_CONVERT:
3836 op0 = TREE_OPERAND (op0, 0);
3837 goto again;
3839 case COND_EXPR:
3840 pp_left_paren (pp);
3841 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3842 pp_string (pp, ") ? ");
3843 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3844 pp_string (pp, " : ");
3845 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3846 break;
3848 case ARRAY_REF:
3849 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3850 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3851 else
3852 dump_generic_node (pp, op0, 0, flags, false);
3853 break;
3855 case MEM_REF:
3856 if (integer_zerop (TREE_OPERAND (op0, 1)))
3858 op0 = TREE_OPERAND (op0, 0);
3859 goto again;
3861 /* Fallthru. */
3862 case COMPONENT_REF:
3863 case SSA_NAME:
3864 case OBJ_TYPE_REF:
3865 dump_generic_node (pp, op0, 0, flags, false);
3866 break;
3868 default:
3869 NIY;
3873 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3875 static void
3876 pretty_print_string (pretty_printer *pp, const char *str)
3878 if (str == NULL)
3879 return;
3881 while (*str)
3883 switch (str[0])
3885 case '\b':
3886 pp_string (pp, "\\b");
3887 break;
3889 case '\f':
3890 pp_string (pp, "\\f");
3891 break;
3893 case '\n':
3894 pp_string (pp, "\\n");
3895 break;
3897 case '\r':
3898 pp_string (pp, "\\r");
3899 break;
3901 case '\t':
3902 pp_string (pp, "\\t");
3903 break;
3905 case '\v':
3906 pp_string (pp, "\\v");
3907 break;
3909 case '\\':
3910 pp_string (pp, "\\\\");
3911 break;
3913 case '\"':
3914 pp_string (pp, "\\\"");
3915 break;
3917 case '\'':
3918 pp_string (pp, "\\'");
3919 break;
3921 /* No need to handle \0; the loop terminates on \0. */
3923 case '\1':
3924 pp_string (pp, "\\1");
3925 break;
3927 case '\2':
3928 pp_string (pp, "\\2");
3929 break;
3931 case '\3':
3932 pp_string (pp, "\\3");
3933 break;
3935 case '\4':
3936 pp_string (pp, "\\4");
3937 break;
3939 case '\5':
3940 pp_string (pp, "\\5");
3941 break;
3943 case '\6':
3944 pp_string (pp, "\\6");
3945 break;
3947 case '\7':
3948 pp_string (pp, "\\7");
3949 break;
3951 default:
3952 if (!ISPRINT (str[0]))
3954 char buf[5];
3955 sprintf (buf, "\\x%x", (unsigned char)str[0]);
3956 pp_string (pp, buf);
3958 else
3959 pp_character (pp, str[0]);
3960 break;
3962 str++;
3966 static void
3967 maybe_init_pretty_print (FILE *file)
3969 if (!tree_pp)
3971 tree_pp = new pretty_printer ();
3972 pp_needs_newline (tree_pp) = true;
3973 pp_translate_identifiers (tree_pp) = false;
3976 tree_pp->buffer->stream = file;
3979 static void
3980 newline_and_indent (pretty_printer *pp, int spc)
3982 pp_newline (pp);
3983 INDENT (spc);
3986 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3987 it can also be used in front ends.
3988 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3991 void
3992 percent_K_format (text_info *text)
3994 tree t = va_arg (*text->args_ptr, tree), block;
3995 text->set_location (0, EXPR_LOCATION (t), true);
3996 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3997 block = TREE_BLOCK (t);
3998 *pp_ti_abstract_origin (text) = NULL;
4000 if (in_lto_p)
4002 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
4003 representing the outermost block of an inlined function.
4004 So walk the BLOCK tree until we hit such a scope. */
4005 while (block
4006 && TREE_CODE (block) == BLOCK)
4008 if (inlined_function_outer_scope_p (block))
4010 *pp_ti_abstract_origin (text) = block;
4011 break;
4013 block = BLOCK_SUPERCONTEXT (block);
4015 return;
4018 while (block
4019 && TREE_CODE (block) == BLOCK
4020 && BLOCK_ABSTRACT_ORIGIN (block))
4022 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4024 while (TREE_CODE (ao) == BLOCK
4025 && BLOCK_ABSTRACT_ORIGIN (ao)
4026 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
4027 ao = BLOCK_ABSTRACT_ORIGIN (ao);
4029 if (TREE_CODE (ao) == FUNCTION_DECL)
4031 *pp_ti_abstract_origin (text) = block;
4032 break;
4034 block = BLOCK_SUPERCONTEXT (block);
4038 /* Print the identifier ID to PRETTY-PRINTER. */
4040 void
4041 pp_tree_identifier (pretty_printer *pp, tree id)
4043 if (pp_translate_identifiers (pp))
4045 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4046 pp_append_text (pp, text, text + strlen (text));
4048 else
4049 pp_append_text (pp, IDENTIFIER_POINTER (id),
4050 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4053 /* A helper function that is used to dump function information before the
4054 function dump. */
4056 void
4057 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4059 const char *dname, *aname;
4060 struct cgraph_node *node = cgraph_node::get (fdecl);
4061 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4063 dname = lang_hooks.decl_printable_name (fdecl, 2);
4065 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4066 aname = (IDENTIFIER_POINTER
4067 (DECL_ASSEMBLER_NAME (fdecl)));
4068 else
4069 aname = "<unset-asm-name>";
4071 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4072 dname, aname, fun->funcdef_no);
4073 if (!(flags & TDF_NOUID))
4074 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4075 if (node)
4077 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
4078 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4079 node->frequency == NODE_FREQUENCY_HOT
4080 ? " (hot)"
4081 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4082 ? " (unlikely executed)"
4083 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4084 ? " (executed once)"
4085 : "");
4087 else
4088 fprintf (dump_file, ")\n\n");
4091 /* Dump double_int D to pretty_printer PP. UNS is true
4092 if D is unsigned and false otherwise. */
4093 void
4094 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4096 if (d.fits_shwi ())
4097 pp_wide_integer (pp, d.low);
4098 else if (d.fits_uhwi ())
4099 pp_unsigned_wide_integer (pp, d.low);
4100 else
4102 unsigned HOST_WIDE_INT low = d.low;
4103 HOST_WIDE_INT high = d.high;
4104 if (!uns && d.is_negative ())
4106 pp_minus (pp);
4107 high = ~high + !low;
4108 low = -low;
4110 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4111 systems? */
4112 sprintf (pp_buffer (pp)->digit_buffer,
4113 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4114 (unsigned HOST_WIDE_INT) high, low);
4115 pp_string (pp, pp_buffer (pp)->digit_buffer);