Emit a no longer supported warning for gcoff* options.
[official-gcc.git] / gcc / tree-pretty-print.c
blob61a28c6757fbc7db468f6c86d27e47a569fd2671
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"
36 #include "gimple.h"
38 /* Local functions, macros and variables. */
39 static const char *op_symbol (const_tree);
40 static void pretty_print_string (pretty_printer *, const char*);
41 static void newline_and_indent (pretty_printer *, int);
42 static void maybe_init_pretty_print (FILE *);
43 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
44 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
46 #define INDENT(SPACE) do { \
47 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
49 #define NIY do_niy (pp, node, flags)
51 static pretty_printer *tree_pp;
53 /* Try to print something for an unknown tree code. */
55 static void
56 do_niy (pretty_printer *pp, const_tree node, dump_flags_t flags)
58 int i, len;
60 pp_string (pp, "<<< Unknown tree: ");
61 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
63 if (EXPR_P (node))
65 len = TREE_OPERAND_LENGTH (node);
66 for (i = 0; i < len; ++i)
68 newline_and_indent (pp, 2);
69 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
73 pp_string (pp, " >>>");
76 /* Debugging function to print out a generic expression. */
78 DEBUG_FUNCTION void
79 debug_generic_expr (tree t)
81 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
82 fprintf (stderr, "\n");
85 /* Debugging function to print out a generic statement. */
87 DEBUG_FUNCTION void
88 debug_generic_stmt (tree t)
90 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
91 fprintf (stderr, "\n");
94 /* Debugging function to print out a chain of trees . */
96 DEBUG_FUNCTION void
97 debug_tree_chain (tree t)
99 hash_set<tree> seen;
101 while (t)
103 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
104 fprintf (stderr, " ");
105 t = TREE_CHAIN (t);
106 if (seen.add (t))
108 fprintf (stderr, "... [cycled back to ");
109 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
110 fprintf (stderr, "]");
111 break;
114 fprintf (stderr, "\n");
117 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
118 void
119 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
121 maybe_init_pretty_print (file);
122 print_declaration (tree_pp, decl, 2, flags);
123 pp_write_text_to_stream (tree_pp);
126 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
127 to show in the dump. See TDF_* in dumpfile.h. */
129 void
130 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
132 maybe_init_pretty_print (file);
133 dump_generic_node (tree_pp, t, 0, flags, true);
134 pp_newline_and_flush (tree_pp);
137 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
138 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
139 INDENT spaces. */
141 void
142 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
144 int i;
146 maybe_init_pretty_print (file);
148 for (i = 0; i < indent; i++)
149 pp_space (tree_pp);
150 dump_generic_node (tree_pp, t, indent, flags, true);
151 pp_newline_and_flush (tree_pp);
154 /* Print a single expression T on file FILE. FLAGS specifies details to show
155 in the dump. See TDF_* in dumpfile.h. */
157 void
158 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
160 maybe_init_pretty_print (file);
161 dump_generic_node (tree_pp, t, 0, flags, false);
162 pp_flush (tree_pp);
165 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
166 in it are replaced with Dxxxx, as long as they are at the start or
167 preceded by $ and at the end or followed by $. See make_fancy_name
168 in tree-sra.c. */
170 static void
171 dump_fancy_name (pretty_printer *pp, tree name)
173 int cnt = 0;
174 int length = IDENTIFIER_LENGTH (name);
175 const char *n = IDENTIFIER_POINTER (name);
178 n = strchr (n, 'D');
179 if (n == NULL)
180 break;
181 if (ISDIGIT (n[1])
182 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
184 int l = 2;
185 while (ISDIGIT (n[l]))
186 l++;
187 if (n[l] == '\0' || n[l] == '$')
189 cnt++;
190 length += 5 - l;
192 n += l;
194 else
195 n++;
197 while (1);
198 if (cnt == 0)
200 pp_tree_identifier (pp, name);
201 return;
204 char *str = XNEWVEC (char, length + 1);
205 char *p = str;
206 const char *q;
207 q = n = IDENTIFIER_POINTER (name);
210 q = strchr (q, 'D');
211 if (q == NULL)
212 break;
213 if (ISDIGIT (q[1])
214 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
216 int l = 2;
217 while (ISDIGIT (q[l]))
218 l++;
219 if (q[l] == '\0' || q[l] == '$')
221 memcpy (p, n, q - n);
222 memcpy (p + (q - n), "Dxxxx", 5);
223 p += (q - n) + 5;
224 n = q + l;
226 q += l;
228 else
229 q++;
231 while (1);
232 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
233 str[length] = '\0';
234 if (pp_translate_identifiers (pp))
236 const char *text = identifier_to_locale (str);
237 pp_append_text (pp, text, text + strlen (text));
239 else
240 pp_append_text (pp, str, str + length);
241 XDELETEVEC (str);
244 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
245 in FLAGS. */
247 static void
248 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
250 if (DECL_NAME (node))
252 if ((flags & TDF_ASMNAME)
253 && HAS_DECL_ASSEMBLER_NAME_P (node)
254 && DECL_ASSEMBLER_NAME_SET_P (node))
255 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
256 /* For DECL_NAMELESS names look for embedded uids in the
257 names and sanitize them for TDF_NOUID. */
258 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
259 dump_fancy_name (pp, DECL_NAME (node));
260 else
261 pp_tree_identifier (pp, DECL_NAME (node));
263 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
264 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
266 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
267 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
268 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
270 if (flags & TDF_NOUID)
271 pp_string (pp, "D#xxxx");
272 else
273 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
275 else
277 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
278 if (flags & TDF_NOUID)
279 pp_printf (pp, "%c.xxxx", c);
280 else
281 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
284 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
286 if (flags & TDF_NOUID)
287 pp_printf (pp, "ptD.xxxx");
288 else
289 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
293 /* Like the above, but used for pretty printing function calls. */
295 static void
296 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
298 if (CONVERT_EXPR_P (node))
299 node = TREE_OPERAND (node, 0);
300 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
301 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
302 else
303 dump_decl_name (pp, node, flags);
306 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
307 FLAGS are as in dump_generic_node. */
309 static void
310 dump_function_declaration (pretty_printer *pp, tree node,
311 int spc, dump_flags_t flags)
313 bool wrote_arg = false;
314 tree arg;
316 pp_space (pp);
317 pp_left_paren (pp);
319 /* Print the argument types. */
320 arg = TYPE_ARG_TYPES (node);
321 while (arg && arg != void_list_node && arg != error_mark_node)
323 if (wrote_arg)
325 pp_comma (pp);
326 pp_space (pp);
328 wrote_arg = true;
329 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
330 arg = TREE_CHAIN (arg);
333 /* Drop the trailing void_type_node if we had any previous argument. */
334 if (arg == void_list_node && !wrote_arg)
335 pp_string (pp, "void");
336 /* Properly dump vararg function types. */
337 else if (!arg && wrote_arg)
338 pp_string (pp, ", ...");
339 /* Avoid printing any arg for unprototyped functions. */
341 pp_right_paren (pp);
344 /* Dump the domain associated with an array. */
346 static void
347 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
349 pp_left_bracket (pp);
350 if (domain)
352 tree min = TYPE_MIN_VALUE (domain);
353 tree max = TYPE_MAX_VALUE (domain);
355 if (min && max
356 && integer_zerop (min)
357 && tree_fits_shwi_p (max))
358 pp_wide_integer (pp, tree_to_shwi (max) + 1);
359 else
361 if (min)
362 dump_generic_node (pp, min, spc, flags, false);
363 pp_colon (pp);
364 if (max)
365 dump_generic_node (pp, max, spc, flags, false);
368 else
369 pp_string (pp, "<unknown>");
370 pp_right_bracket (pp);
374 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
375 dump_generic_node. */
377 static void
378 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
380 const char *name;
382 switch (OMP_CLAUSE_CODE (clause))
384 case OMP_CLAUSE_PRIVATE:
385 name = "private";
386 goto print_remap;
387 case OMP_CLAUSE_SHARED:
388 name = "shared";
389 goto print_remap;
390 case OMP_CLAUSE_FIRSTPRIVATE:
391 name = "firstprivate";
392 goto print_remap;
393 case OMP_CLAUSE_LASTPRIVATE:
394 name = "lastprivate";
395 goto print_remap;
396 case OMP_CLAUSE_COPYIN:
397 name = "copyin";
398 goto print_remap;
399 case OMP_CLAUSE_COPYPRIVATE:
400 name = "copyprivate";
401 goto print_remap;
402 case OMP_CLAUSE_UNIFORM:
403 name = "uniform";
404 goto print_remap;
405 case OMP_CLAUSE_USE_DEVICE_PTR:
406 name = "use_device_ptr";
407 goto print_remap;
408 case OMP_CLAUSE_IS_DEVICE_PTR:
409 name = "is_device_ptr";
410 goto print_remap;
411 case OMP_CLAUSE__LOOPTEMP_:
412 name = "_looptemp_";
413 goto print_remap;
414 case OMP_CLAUSE_TO_DECLARE:
415 name = "to";
416 goto print_remap;
417 case OMP_CLAUSE_LINK:
418 name = "link";
419 goto print_remap;
420 print_remap:
421 pp_string (pp, name);
422 pp_left_paren (pp);
423 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
424 spc, flags, false);
425 pp_right_paren (pp);
426 break;
428 case OMP_CLAUSE_REDUCTION:
429 pp_string (pp, "reduction(");
430 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
432 pp_string (pp,
433 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
434 pp_colon (pp);
436 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
437 spc, flags, false);
438 pp_right_paren (pp);
439 break;
441 case OMP_CLAUSE_IF:
442 pp_string (pp, "if(");
443 switch (OMP_CLAUSE_IF_MODIFIER (clause))
445 case ERROR_MARK: break;
446 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
447 case OMP_TASK: pp_string (pp, "task:"); break;
448 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
449 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
450 case OMP_TARGET: pp_string (pp, "target:"); break;
451 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
452 case OMP_TARGET_ENTER_DATA:
453 pp_string (pp, "target enter data:"); break;
454 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
455 default: gcc_unreachable ();
457 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
458 spc, flags, false);
459 pp_right_paren (pp);
460 break;
462 case OMP_CLAUSE_NUM_THREADS:
463 pp_string (pp, "num_threads(");
464 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
465 spc, flags, false);
466 pp_right_paren (pp);
467 break;
469 case OMP_CLAUSE__CILK_FOR_COUNT_:
470 pp_string (pp, "_Cilk_for_count_(");
471 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
472 spc, flags, false);
473 pp_right_paren (pp);
474 break;
476 case OMP_CLAUSE_NOWAIT:
477 pp_string (pp, "nowait");
478 break;
479 case OMP_CLAUSE_ORDERED:
480 pp_string (pp, "ordered");
481 if (OMP_CLAUSE_ORDERED_EXPR (clause))
483 pp_left_paren (pp);
484 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
485 spc, flags, false);
486 pp_right_paren (pp);
488 break;
490 case OMP_CLAUSE_DEFAULT:
491 pp_string (pp, "default(");
492 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
494 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
495 break;
496 case OMP_CLAUSE_DEFAULT_SHARED:
497 pp_string (pp, "shared");
498 break;
499 case OMP_CLAUSE_DEFAULT_NONE:
500 pp_string (pp, "none");
501 break;
502 case OMP_CLAUSE_DEFAULT_PRIVATE:
503 pp_string (pp, "private");
504 break;
505 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
506 pp_string (pp, "firstprivate");
507 break;
508 case OMP_CLAUSE_DEFAULT_PRESENT:
509 pp_string (pp, "present");
510 break;
511 default:
512 gcc_unreachable ();
514 pp_right_paren (pp);
515 break;
517 case OMP_CLAUSE_SCHEDULE:
518 pp_string (pp, "schedule(");
519 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
520 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
521 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
523 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
524 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
525 pp_string (pp, "monotonic");
526 else
527 pp_string (pp, "nonmonotonic");
528 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
529 pp_comma (pp);
530 else
531 pp_colon (pp);
533 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
534 pp_string (pp, "simd:");
536 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
538 case OMP_CLAUSE_SCHEDULE_STATIC:
539 pp_string (pp, "static");
540 break;
541 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
542 pp_string (pp, "dynamic");
543 break;
544 case OMP_CLAUSE_SCHEDULE_GUIDED:
545 pp_string (pp, "guided");
546 break;
547 case OMP_CLAUSE_SCHEDULE_RUNTIME:
548 pp_string (pp, "runtime");
549 break;
550 case OMP_CLAUSE_SCHEDULE_AUTO:
551 pp_string (pp, "auto");
552 break;
553 case OMP_CLAUSE_SCHEDULE_CILKFOR:
554 pp_string (pp, "cilk-for grain");
555 break;
556 default:
557 gcc_unreachable ();
559 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
561 pp_comma (pp);
562 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
563 spc, flags, false);
565 pp_right_paren (pp);
566 break;
568 case OMP_CLAUSE_UNTIED:
569 pp_string (pp, "untied");
570 break;
572 case OMP_CLAUSE_COLLAPSE:
573 pp_string (pp, "collapse(");
574 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
575 spc, flags, false);
576 pp_right_paren (pp);
577 break;
579 case OMP_CLAUSE_FINAL:
580 pp_string (pp, "final(");
581 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
582 spc, flags, false);
583 pp_right_paren (pp);
584 break;
586 case OMP_CLAUSE_MERGEABLE:
587 pp_string (pp, "mergeable");
588 break;
590 case OMP_CLAUSE_LINEAR:
591 pp_string (pp, "linear(");
592 switch (OMP_CLAUSE_LINEAR_KIND (clause))
594 case OMP_CLAUSE_LINEAR_DEFAULT:
595 break;
596 case OMP_CLAUSE_LINEAR_REF:
597 pp_string (pp, "ref(");
598 break;
599 case OMP_CLAUSE_LINEAR_VAL:
600 pp_string (pp, "val(");
601 break;
602 case OMP_CLAUSE_LINEAR_UVAL:
603 pp_string (pp, "uval(");
604 break;
605 default:
606 gcc_unreachable ();
608 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
609 spc, flags, false);
610 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
611 pp_right_paren (pp);
612 pp_colon (pp);
613 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
614 spc, flags, false);
615 pp_right_paren (pp);
616 break;
618 case OMP_CLAUSE_ALIGNED:
619 pp_string (pp, "aligned(");
620 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
621 spc, flags, false);
622 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
624 pp_colon (pp);
625 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
626 spc, flags, false);
628 pp_right_paren (pp);
629 break;
631 case OMP_CLAUSE_DEPEND:
632 pp_string (pp, "depend(");
633 switch (OMP_CLAUSE_DEPEND_KIND (clause))
635 case OMP_CLAUSE_DEPEND_IN:
636 pp_string (pp, "in");
637 break;
638 case OMP_CLAUSE_DEPEND_OUT:
639 pp_string (pp, "out");
640 break;
641 case OMP_CLAUSE_DEPEND_INOUT:
642 pp_string (pp, "inout");
643 break;
644 case OMP_CLAUSE_DEPEND_SOURCE:
645 pp_string (pp, "source)");
646 return;
647 case OMP_CLAUSE_DEPEND_SINK:
648 pp_string (pp, "sink:");
649 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
650 if (TREE_CODE (t) == TREE_LIST)
652 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
653 if (TREE_PURPOSE (t) != integer_zero_node)
655 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
656 pp_minus (pp);
657 else
658 pp_plus (pp);
659 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
660 false);
662 if (TREE_CHAIN (t))
663 pp_comma (pp);
665 else
666 gcc_unreachable ();
667 pp_right_paren (pp);
668 return;
669 default:
670 gcc_unreachable ();
672 pp_colon (pp);
673 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
674 spc, flags, false);
675 pp_right_paren (pp);
676 break;
678 case OMP_CLAUSE_MAP:
679 pp_string (pp, "map(");
680 switch (OMP_CLAUSE_MAP_KIND (clause))
682 case GOMP_MAP_ALLOC:
683 case GOMP_MAP_POINTER:
684 pp_string (pp, "alloc");
685 break;
686 case GOMP_MAP_TO:
687 case GOMP_MAP_TO_PSET:
688 pp_string (pp, "to");
689 break;
690 case GOMP_MAP_FROM:
691 pp_string (pp, "from");
692 break;
693 case GOMP_MAP_TOFROM:
694 pp_string (pp, "tofrom");
695 break;
696 case GOMP_MAP_FORCE_ALLOC:
697 pp_string (pp, "force_alloc");
698 break;
699 case GOMP_MAP_FORCE_TO:
700 pp_string (pp, "force_to");
701 break;
702 case GOMP_MAP_FORCE_FROM:
703 pp_string (pp, "force_from");
704 break;
705 case GOMP_MAP_FORCE_TOFROM:
706 pp_string (pp, "force_tofrom");
707 break;
708 case GOMP_MAP_FORCE_PRESENT:
709 pp_string (pp, "force_present");
710 break;
711 case GOMP_MAP_DELETE:
712 pp_string (pp, "delete");
713 break;
714 case GOMP_MAP_FORCE_DEVICEPTR:
715 pp_string (pp, "force_deviceptr");
716 break;
717 case GOMP_MAP_ALWAYS_TO:
718 pp_string (pp, "always,to");
719 break;
720 case GOMP_MAP_ALWAYS_FROM:
721 pp_string (pp, "always,from");
722 break;
723 case GOMP_MAP_ALWAYS_TOFROM:
724 pp_string (pp, "always,tofrom");
725 break;
726 case GOMP_MAP_RELEASE:
727 pp_string (pp, "release");
728 break;
729 case GOMP_MAP_FIRSTPRIVATE_POINTER:
730 pp_string (pp, "firstprivate");
731 break;
732 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
733 pp_string (pp, "firstprivate ref");
734 break;
735 case GOMP_MAP_STRUCT:
736 pp_string (pp, "struct");
737 break;
738 case GOMP_MAP_ALWAYS_POINTER:
739 pp_string (pp, "always_pointer");
740 break;
741 case GOMP_MAP_DEVICE_RESIDENT:
742 pp_string (pp, "device_resident");
743 break;
744 case GOMP_MAP_LINK:
745 pp_string (pp, "link");
746 break;
747 default:
748 gcc_unreachable ();
750 pp_colon (pp);
751 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
752 spc, flags, false);
753 print_clause_size:
754 if (OMP_CLAUSE_SIZE (clause))
756 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
757 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
759 case GOMP_MAP_POINTER:
760 case GOMP_MAP_FIRSTPRIVATE_POINTER:
761 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
762 case GOMP_MAP_ALWAYS_POINTER:
763 pp_string (pp, " [pointer assign, bias: ");
764 break;
765 case GOMP_MAP_TO_PSET:
766 pp_string (pp, " [pointer set, len: ");
767 break;
768 default:
769 pp_string (pp, " [len: ");
770 break;
772 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
773 spc, flags, false);
774 pp_right_bracket (pp);
776 pp_right_paren (pp);
777 break;
779 case OMP_CLAUSE_FROM:
780 pp_string (pp, "from(");
781 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
782 spc, flags, false);
783 goto print_clause_size;
785 case OMP_CLAUSE_TO:
786 pp_string (pp, "to(");
787 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
788 spc, flags, false);
789 goto print_clause_size;
791 case OMP_CLAUSE__CACHE_:
792 pp_string (pp, "(");
793 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
794 spc, flags, false);
795 goto print_clause_size;
797 case OMP_CLAUSE_NUM_TEAMS:
798 pp_string (pp, "num_teams(");
799 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
800 spc, flags, false);
801 pp_right_paren (pp);
802 break;
804 case OMP_CLAUSE_THREAD_LIMIT:
805 pp_string (pp, "thread_limit(");
806 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
807 spc, flags, false);
808 pp_right_paren (pp);
809 break;
811 case OMP_CLAUSE_DEVICE:
812 pp_string (pp, "device(");
813 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
814 spc, flags, false);
815 pp_right_paren (pp);
816 break;
818 case OMP_CLAUSE_DIST_SCHEDULE:
819 pp_string (pp, "dist_schedule(static");
820 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
822 pp_comma (pp);
823 dump_generic_node (pp,
824 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
825 spc, flags, false);
827 pp_right_paren (pp);
828 break;
830 case OMP_CLAUSE_PROC_BIND:
831 pp_string (pp, "proc_bind(");
832 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
834 case OMP_CLAUSE_PROC_BIND_MASTER:
835 pp_string (pp, "master");
836 break;
837 case OMP_CLAUSE_PROC_BIND_CLOSE:
838 pp_string (pp, "close");
839 break;
840 case OMP_CLAUSE_PROC_BIND_SPREAD:
841 pp_string (pp, "spread");
842 break;
843 default:
844 gcc_unreachable ();
846 pp_right_paren (pp);
847 break;
849 case OMP_CLAUSE_SAFELEN:
850 pp_string (pp, "safelen(");
851 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
852 spc, flags, false);
853 pp_right_paren (pp);
854 break;
856 case OMP_CLAUSE_SIMDLEN:
857 pp_string (pp, "simdlen(");
858 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
859 spc, flags, false);
860 pp_right_paren (pp);
861 break;
863 case OMP_CLAUSE_PRIORITY:
864 pp_string (pp, "priority(");
865 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
866 spc, flags, false);
867 pp_right_paren (pp);
868 break;
870 case OMP_CLAUSE_GRAINSIZE:
871 pp_string (pp, "grainsize(");
872 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
873 spc, flags, false);
874 pp_right_paren (pp);
875 break;
877 case OMP_CLAUSE_NUM_TASKS:
878 pp_string (pp, "num_tasks(");
879 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
880 spc, flags, false);
881 pp_right_paren (pp);
882 break;
884 case OMP_CLAUSE_HINT:
885 pp_string (pp, "hint(");
886 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
887 spc, flags, false);
888 pp_right_paren (pp);
889 break;
891 case OMP_CLAUSE_DEFAULTMAP:
892 pp_string (pp, "defaultmap(tofrom:scalar)");
893 break;
895 case OMP_CLAUSE__SIMDUID_:
896 pp_string (pp, "_simduid_(");
897 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
898 spc, flags, false);
899 pp_right_paren (pp);
900 break;
902 case OMP_CLAUSE__SIMT_:
903 pp_string (pp, "_simt_");
904 break;
906 case OMP_CLAUSE_GANG:
907 pp_string (pp, "gang");
908 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
910 pp_string (pp, "(num: ");
911 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
912 spc, flags, false);
914 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
916 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
917 pp_left_paren (pp);
918 else
919 pp_space (pp);
920 pp_string (pp, "static:");
921 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
922 == integer_minus_one_node)
923 pp_character (pp, '*');
924 else
925 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
926 spc, flags, false);
928 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
929 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
930 pp_right_paren (pp);
931 break;
933 case OMP_CLAUSE_ASYNC:
934 pp_string (pp, "async");
935 if (OMP_CLAUSE_ASYNC_EXPR (clause))
937 pp_character(pp, '(');
938 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
939 spc, flags, false);
940 pp_character(pp, ')');
942 break;
944 case OMP_CLAUSE_AUTO:
945 case OMP_CLAUSE_SEQ:
946 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
947 break;
949 case OMP_CLAUSE_WAIT:
950 pp_string (pp, "wait(");
951 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
952 spc, flags, false);
953 pp_character(pp, ')');
954 break;
956 case OMP_CLAUSE_WORKER:
957 pp_string (pp, "worker");
958 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
960 pp_left_paren (pp);
961 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
962 spc, flags, false);
963 pp_right_paren (pp);
965 break;
967 case OMP_CLAUSE_VECTOR:
968 pp_string (pp, "vector");
969 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
971 pp_left_paren (pp);
972 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
973 spc, flags, false);
974 pp_right_paren (pp);
976 break;
978 case OMP_CLAUSE_NUM_GANGS:
979 pp_string (pp, "num_gangs(");
980 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
981 spc, flags, false);
982 pp_character (pp, ')');
983 break;
985 case OMP_CLAUSE_NUM_WORKERS:
986 pp_string (pp, "num_workers(");
987 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
988 spc, flags, false);
989 pp_character (pp, ')');
990 break;
992 case OMP_CLAUSE_VECTOR_LENGTH:
993 pp_string (pp, "vector_length(");
994 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
995 spc, flags, false);
996 pp_character (pp, ')');
997 break;
999 case OMP_CLAUSE_INBRANCH:
1000 pp_string (pp, "inbranch");
1001 break;
1002 case OMP_CLAUSE_NOTINBRANCH:
1003 pp_string (pp, "notinbranch");
1004 break;
1005 case OMP_CLAUSE_FOR:
1006 pp_string (pp, "for");
1007 break;
1008 case OMP_CLAUSE_PARALLEL:
1009 pp_string (pp, "parallel");
1010 break;
1011 case OMP_CLAUSE_SECTIONS:
1012 pp_string (pp, "sections");
1013 break;
1014 case OMP_CLAUSE_TASKGROUP:
1015 pp_string (pp, "taskgroup");
1016 break;
1017 case OMP_CLAUSE_NOGROUP:
1018 pp_string (pp, "nogroup");
1019 break;
1020 case OMP_CLAUSE_THREADS:
1021 pp_string (pp, "threads");
1022 break;
1023 case OMP_CLAUSE_SIMD:
1024 pp_string (pp, "simd");
1025 break;
1026 case OMP_CLAUSE_INDEPENDENT:
1027 pp_string (pp, "independent");
1028 break;
1029 case OMP_CLAUSE_TILE:
1030 pp_string (pp, "tile(");
1031 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1032 spc, flags, false);
1033 pp_right_paren (pp);
1034 break;
1036 case OMP_CLAUSE__GRIDDIM_:
1037 pp_string (pp, "_griddim_(");
1038 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1039 pp_colon (pp);
1040 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1041 false);
1042 pp_comma (pp);
1043 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1044 false);
1045 pp_right_paren (pp);
1046 break;
1048 default:
1049 /* Should never happen. */
1050 dump_generic_node (pp, clause, spc, flags, false);
1051 break;
1056 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1057 dump_generic_node. */
1059 void
1060 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1062 if (clause == NULL)
1063 return;
1065 pp_space (pp);
1066 while (1)
1068 dump_omp_clause (pp, clause, spc, flags);
1069 clause = OMP_CLAUSE_CHAIN (clause);
1070 if (clause == NULL)
1071 return;
1072 pp_space (pp);
1077 /* Dump location LOC to PP. */
1079 void
1080 dump_location (pretty_printer *pp, location_t loc)
1082 expanded_location xloc = expand_location (loc);
1084 pp_left_bracket (pp);
1085 if (xloc.file)
1087 pp_string (pp, xloc.file);
1088 pp_string (pp, ":");
1090 pp_decimal_int (pp, xloc.line);
1091 pp_colon (pp);
1092 pp_decimal_int (pp, xloc.column);
1093 pp_string (pp, "] ");
1097 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1098 dump_generic_node. */
1100 static void
1101 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1103 tree t;
1105 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1107 if (flags & TDF_ADDRESS)
1108 pp_printf (pp, "[%p] ", (void *) block);
1110 if (BLOCK_ABSTRACT (block))
1111 pp_string (pp, "[abstract] ");
1113 if (TREE_ASM_WRITTEN (block))
1114 pp_string (pp, "[written] ");
1116 if (flags & TDF_SLIM)
1117 return;
1119 if (BLOCK_SOURCE_LOCATION (block))
1120 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1122 newline_and_indent (pp, spc + 2);
1124 if (BLOCK_SUPERCONTEXT (block))
1126 pp_string (pp, "SUPERCONTEXT: ");
1127 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1128 flags | TDF_SLIM, false);
1129 newline_and_indent (pp, spc + 2);
1132 if (BLOCK_SUBBLOCKS (block))
1134 pp_string (pp, "SUBBLOCKS: ");
1135 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1137 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1138 pp_space (pp);
1140 newline_and_indent (pp, spc + 2);
1143 if (BLOCK_CHAIN (block))
1145 pp_string (pp, "SIBLINGS: ");
1146 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1148 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1149 pp_space (pp);
1151 newline_and_indent (pp, spc + 2);
1154 if (BLOCK_VARS (block))
1156 pp_string (pp, "VARS: ");
1157 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1159 dump_generic_node (pp, t, 0, flags, false);
1160 pp_space (pp);
1162 newline_and_indent (pp, spc + 2);
1165 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1167 unsigned i;
1168 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1170 pp_string (pp, "NONLOCALIZED_VARS: ");
1171 FOR_EACH_VEC_ELT (*nlv, i, t)
1173 dump_generic_node (pp, t, 0, flags, false);
1174 pp_space (pp);
1176 newline_and_indent (pp, spc + 2);
1179 if (BLOCK_ABSTRACT_ORIGIN (block))
1181 pp_string (pp, "ABSTRACT_ORIGIN: ");
1182 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1183 flags | TDF_SLIM, false);
1184 newline_and_indent (pp, spc + 2);
1187 if (BLOCK_FRAGMENT_ORIGIN (block))
1189 pp_string (pp, "FRAGMENT_ORIGIN: ");
1190 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1191 flags | TDF_SLIM, false);
1192 newline_and_indent (pp, spc + 2);
1195 if (BLOCK_FRAGMENT_CHAIN (block))
1197 pp_string (pp, "FRAGMENT_CHAIN: ");
1198 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1200 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1201 pp_space (pp);
1203 newline_and_indent (pp, spc + 2);
1208 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1209 indent. FLAGS specifies details to show in the dump (see TDF_* in
1210 dumpfile.h). If IS_STMT is true, the object printed is considered
1211 to be a statement and it is terminated by ';' if appropriate. */
1214 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1215 bool is_stmt)
1217 tree type;
1218 tree op0, op1;
1219 const char *str;
1220 bool is_expr;
1221 enum tree_code code;
1223 if (node == NULL_TREE)
1224 return spc;
1226 is_expr = EXPR_P (node);
1228 if (is_stmt && (flags & TDF_STMTADDR))
1229 pp_printf (pp, "<&%p> ", (void *)node);
1231 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1232 dump_location (pp, EXPR_LOCATION (node));
1234 code = TREE_CODE (node);
1235 switch (code)
1237 case ERROR_MARK:
1238 pp_string (pp, "<<< error >>>");
1239 break;
1241 case IDENTIFIER_NODE:
1242 pp_tree_identifier (pp, node);
1243 break;
1245 case TREE_LIST:
1246 while (node && node != error_mark_node)
1248 if (TREE_PURPOSE (node))
1250 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1251 pp_space (pp);
1253 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1254 node = TREE_CHAIN (node);
1255 if (node && TREE_CODE (node) == TREE_LIST)
1257 pp_comma (pp);
1258 pp_space (pp);
1261 break;
1263 case TREE_BINFO:
1264 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1265 break;
1267 case TREE_VEC:
1269 size_t i;
1270 if (TREE_VEC_LENGTH (node) > 0)
1272 size_t len = TREE_VEC_LENGTH (node);
1273 for (i = 0; i < len - 1; i++)
1275 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1276 false);
1277 pp_comma (pp);
1278 pp_space (pp);
1280 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1281 flags, false);
1284 break;
1286 case VOID_TYPE:
1287 case POINTER_BOUNDS_TYPE:
1288 case INTEGER_TYPE:
1289 case REAL_TYPE:
1290 case FIXED_POINT_TYPE:
1291 case COMPLEX_TYPE:
1292 case VECTOR_TYPE:
1293 case ENUMERAL_TYPE:
1294 case BOOLEAN_TYPE:
1296 unsigned int quals = TYPE_QUALS (node);
1297 enum tree_code_class tclass;
1299 if (quals & TYPE_QUAL_ATOMIC)
1300 pp_string (pp, "atomic ");
1301 if (quals & TYPE_QUAL_CONST)
1302 pp_string (pp, "const ");
1303 else if (quals & TYPE_QUAL_VOLATILE)
1304 pp_string (pp, "volatile ");
1305 else if (quals & TYPE_QUAL_RESTRICT)
1306 pp_string (pp, "restrict ");
1308 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1310 pp_string (pp, "<address-space-");
1311 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1312 pp_string (pp, "> ");
1315 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1317 if (tclass == tcc_declaration)
1319 if (DECL_NAME (node))
1320 dump_decl_name (pp, node, flags);
1321 else
1322 pp_string (pp, "<unnamed type decl>");
1324 else if (tclass == tcc_type)
1326 if (TYPE_NAME (node))
1328 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1329 pp_tree_identifier (pp, TYPE_NAME (node));
1330 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1331 && DECL_NAME (TYPE_NAME (node)))
1332 dump_decl_name (pp, TYPE_NAME (node), flags);
1333 else
1334 pp_string (pp, "<unnamed type>");
1336 else if (TREE_CODE (node) == VECTOR_TYPE)
1338 pp_string (pp, "vector");
1339 pp_left_paren (pp);
1340 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1341 pp_string (pp, ") ");
1342 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1344 else if (TREE_CODE (node) == INTEGER_TYPE)
1346 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1347 pp_string (pp, (TYPE_UNSIGNED (node)
1348 ? "unsigned char"
1349 : "signed char"));
1350 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1351 pp_string (pp, (TYPE_UNSIGNED (node)
1352 ? "unsigned short"
1353 : "signed short"));
1354 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1355 pp_string (pp, (TYPE_UNSIGNED (node)
1356 ? "unsigned int"
1357 : "signed int"));
1358 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1359 pp_string (pp, (TYPE_UNSIGNED (node)
1360 ? "unsigned long"
1361 : "signed long"));
1362 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1363 pp_string (pp, (TYPE_UNSIGNED (node)
1364 ? "unsigned long long"
1365 : "signed long long"));
1366 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1367 && pow2p_hwi (TYPE_PRECISION (node)))
1369 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1370 pp_decimal_int (pp, TYPE_PRECISION (node));
1371 pp_string (pp, "_t");
1373 else
1375 pp_string (pp, (TYPE_UNSIGNED (node)
1376 ? "<unnamed-unsigned:"
1377 : "<unnamed-signed:"));
1378 pp_decimal_int (pp, TYPE_PRECISION (node));
1379 pp_greater (pp);
1382 else if (TREE_CODE (node) == COMPLEX_TYPE)
1384 pp_string (pp, "__complex__ ");
1385 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1387 else if (TREE_CODE (node) == REAL_TYPE)
1389 pp_string (pp, "<float:");
1390 pp_decimal_int (pp, TYPE_PRECISION (node));
1391 pp_greater (pp);
1393 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1395 pp_string (pp, "<fixed-point-");
1396 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1397 pp_decimal_int (pp, TYPE_PRECISION (node));
1398 pp_greater (pp);
1400 else if (TREE_CODE (node) == VOID_TYPE)
1401 pp_string (pp, "void");
1402 else
1403 pp_string (pp, "<unnamed type>");
1405 break;
1408 case POINTER_TYPE:
1409 case REFERENCE_TYPE:
1410 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1412 if (TREE_TYPE (node) == NULL)
1414 pp_string (pp, str);
1415 pp_string (pp, "<null type>");
1417 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1419 tree fnode = TREE_TYPE (node);
1421 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1422 pp_space (pp);
1423 pp_left_paren (pp);
1424 pp_string (pp, str);
1425 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1426 dump_decl_name (pp, TYPE_NAME (node), flags);
1427 else if (flags & TDF_NOUID)
1428 pp_printf (pp, "<Txxxx>");
1429 else
1430 pp_printf (pp, "<T%x>", TYPE_UID (node));
1432 pp_right_paren (pp);
1433 dump_function_declaration (pp, fnode, spc, flags);
1435 else
1437 unsigned int quals = TYPE_QUALS (node);
1439 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1440 pp_space (pp);
1441 pp_string (pp, str);
1443 if (quals & TYPE_QUAL_CONST)
1444 pp_string (pp, " const");
1445 if (quals & TYPE_QUAL_VOLATILE)
1446 pp_string (pp, " volatile");
1447 if (quals & TYPE_QUAL_RESTRICT)
1448 pp_string (pp, " restrict");
1450 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1452 pp_string (pp, " <address-space-");
1453 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1454 pp_greater (pp);
1457 if (TYPE_REF_CAN_ALIAS_ALL (node))
1458 pp_string (pp, " {ref-all}");
1460 break;
1462 case OFFSET_TYPE:
1463 NIY;
1464 break;
1466 case MEM_REF:
1468 if (flags & TDF_GIMPLE)
1470 pp_string (pp, "__MEM <");
1471 dump_generic_node (pp, TREE_TYPE (node),
1472 spc, flags | TDF_SLIM, false);
1473 if (TYPE_ALIGN (TREE_TYPE (node))
1474 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1476 pp_string (pp, ", ");
1477 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1479 pp_greater (pp);
1480 pp_string (pp, " (");
1481 if (TREE_TYPE (TREE_OPERAND (node, 0))
1482 != TREE_TYPE (TREE_OPERAND (node, 1)))
1484 pp_left_paren (pp);
1485 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1486 spc, flags | TDF_SLIM, false);
1487 pp_right_paren (pp);
1489 dump_generic_node (pp, TREE_OPERAND (node, 0),
1490 spc, flags | TDF_SLIM, false);
1491 if (! integer_zerop (TREE_OPERAND (node, 1)))
1493 pp_string (pp, " + ");
1494 dump_generic_node (pp, TREE_OPERAND (node, 1),
1495 spc, flags | TDF_SLIM, false);
1497 pp_right_paren (pp);
1499 else if (integer_zerop (TREE_OPERAND (node, 1))
1500 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1501 infer them and MEM_ATTR caching will share MEM_REFs
1502 with differently-typed op0s. */
1503 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1504 /* Released SSA_NAMES have no TREE_TYPE. */
1505 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1506 /* Same pointer types, but ignoring POINTER_TYPE vs.
1507 REFERENCE_TYPE. */
1508 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1509 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1510 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1511 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1512 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1513 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1514 /* Same value types ignoring qualifiers. */
1515 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1516 == TYPE_MAIN_VARIANT
1517 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1518 && (!(flags & TDF_ALIAS)
1519 || MR_DEPENDENCE_CLIQUE (node) == 0))
1521 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1523 pp_star (pp);
1524 dump_generic_node (pp, TREE_OPERAND (node, 0),
1525 spc, flags, false);
1527 else
1528 dump_generic_node (pp,
1529 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1530 spc, flags, false);
1532 else
1534 tree ptype;
1536 pp_string (pp, "MEM[");
1537 pp_left_paren (pp);
1538 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1539 dump_generic_node (pp, ptype,
1540 spc, flags | TDF_SLIM, false);
1541 pp_right_paren (pp);
1542 dump_generic_node (pp, TREE_OPERAND (node, 0),
1543 spc, flags, false);
1544 if (!integer_zerop (TREE_OPERAND (node, 1)))
1546 pp_string (pp, " + ");
1547 dump_generic_node (pp, TREE_OPERAND (node, 1),
1548 spc, flags, false);
1550 if ((flags & TDF_ALIAS)
1551 && MR_DEPENDENCE_CLIQUE (node) != 0)
1553 pp_string (pp, " clique ");
1554 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1555 pp_string (pp, " base ");
1556 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1558 pp_right_bracket (pp);
1560 break;
1563 case TARGET_MEM_REF:
1565 const char *sep = "";
1566 tree tmp;
1568 pp_string (pp, "MEM[");
1570 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1572 pp_string (pp, sep);
1573 sep = ", ";
1574 pp_string (pp, "symbol: ");
1575 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1576 spc, flags, false);
1578 else
1580 pp_string (pp, sep);
1581 sep = ", ";
1582 pp_string (pp, "base: ");
1583 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1585 tmp = TMR_INDEX2 (node);
1586 if (tmp)
1588 pp_string (pp, sep);
1589 sep = ", ";
1590 pp_string (pp, "base: ");
1591 dump_generic_node (pp, tmp, spc, flags, false);
1593 tmp = TMR_INDEX (node);
1594 if (tmp)
1596 pp_string (pp, sep);
1597 sep = ", ";
1598 pp_string (pp, "index: ");
1599 dump_generic_node (pp, tmp, spc, flags, false);
1601 tmp = TMR_STEP (node);
1602 if (tmp)
1604 pp_string (pp, sep);
1605 sep = ", ";
1606 pp_string (pp, "step: ");
1607 dump_generic_node (pp, tmp, spc, flags, false);
1609 tmp = TMR_OFFSET (node);
1610 if (tmp)
1612 pp_string (pp, sep);
1613 sep = ", ";
1614 pp_string (pp, "offset: ");
1615 dump_generic_node (pp, tmp, spc, flags, false);
1617 pp_right_bracket (pp);
1619 break;
1621 case ARRAY_TYPE:
1623 tree tmp;
1625 /* Print the innermost component type. */
1626 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1627 tmp = TREE_TYPE (tmp))
1629 dump_generic_node (pp, tmp, spc, flags, false);
1631 /* Print the dimensions. */
1632 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1633 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1634 break;
1637 case RECORD_TYPE:
1638 case UNION_TYPE:
1639 case QUAL_UNION_TYPE:
1641 unsigned int quals = TYPE_QUALS (node);
1643 if (quals & TYPE_QUAL_ATOMIC)
1644 pp_string (pp, "atomic ");
1645 if (quals & TYPE_QUAL_CONST)
1646 pp_string (pp, "const ");
1647 if (quals & TYPE_QUAL_VOLATILE)
1648 pp_string (pp, "volatile ");
1650 /* Print the name of the structure. */
1651 if (TREE_CODE (node) == RECORD_TYPE)
1652 pp_string (pp, "struct ");
1653 else if (TREE_CODE (node) == UNION_TYPE)
1654 pp_string (pp, "union ");
1656 if (TYPE_NAME (node))
1657 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1658 else if (!(flags & TDF_SLIM))
1659 /* FIXME: If we eliminate the 'else' above and attempt
1660 to show the fields for named types, we may get stuck
1661 following a cycle of pointers to structs. The alleged
1662 self-reference check in print_struct_decl will not detect
1663 cycles involving more than one pointer or struct type. */
1664 print_struct_decl (pp, node, spc, flags);
1665 break;
1668 case LANG_TYPE:
1669 NIY;
1670 break;
1672 case INTEGER_CST:
1673 if (flags & TDF_GIMPLE
1674 && (POINTER_TYPE_P (TREE_TYPE (node))
1675 || (TYPE_PRECISION (TREE_TYPE (node))
1676 < TYPE_PRECISION (integer_type_node))
1677 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1679 pp_string (pp, "_Literal (");
1680 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1681 pp_string (pp, ") ");
1683 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1684 && ! (flags & TDF_GIMPLE))
1686 /* In the case of a pointer, one may want to divide by the
1687 size of the pointed-to type. Unfortunately, this not
1688 straightforward. The C front-end maps expressions
1690 (int *) 5
1691 int *p; (p + 5)
1693 in such a way that the two INTEGER_CST nodes for "5" have
1694 different values but identical types. In the latter
1695 case, the 5 is multiplied by sizeof (int) in c-common.c
1696 (pointer_int_sum) to convert it to a byte address, and
1697 yet the type of the node is left unchanged. Argh. What
1698 is consistent though is that the number value corresponds
1699 to bytes (UNITS) offset.
1701 NB: Neither of the following divisors can be trivially
1702 used to recover the original literal:
1704 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1705 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1706 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1707 pp_string (pp, "B"); /* pseudo-unit */
1709 else if (tree_fits_shwi_p (node))
1710 pp_wide_integer (pp, tree_to_shwi (node));
1711 else if (tree_fits_uhwi_p (node))
1712 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1713 else
1715 wide_int val = wi::to_wide (node);
1717 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1719 pp_minus (pp);
1720 val = -val;
1722 print_hex (val, pp_buffer (pp)->digit_buffer);
1723 pp_string (pp, pp_buffer (pp)->digit_buffer);
1725 if ((flags & TDF_GIMPLE)
1726 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1727 || (TYPE_PRECISION (TREE_TYPE (node))
1728 < TYPE_PRECISION (integer_type_node))
1729 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1731 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1732 pp_character (pp, 'u');
1733 if (TYPE_PRECISION (TREE_TYPE (node))
1734 == TYPE_PRECISION (unsigned_type_node))
1736 else if (TYPE_PRECISION (TREE_TYPE (node))
1737 == TYPE_PRECISION (long_unsigned_type_node))
1738 pp_character (pp, 'l');
1739 else if (TYPE_PRECISION (TREE_TYPE (node))
1740 == TYPE_PRECISION (long_long_unsigned_type_node))
1741 pp_string (pp, "ll");
1743 if (TREE_OVERFLOW (node))
1744 pp_string (pp, "(OVF)");
1745 break;
1747 case REAL_CST:
1748 /* Code copied from print_node. */
1750 REAL_VALUE_TYPE d;
1751 if (TREE_OVERFLOW (node))
1752 pp_string (pp, " overflow");
1754 d = TREE_REAL_CST (node);
1755 if (REAL_VALUE_ISINF (d))
1756 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1757 else if (REAL_VALUE_ISNAN (d))
1758 pp_string (pp, " Nan");
1759 else
1761 char string[100];
1762 real_to_decimal (string, &d, sizeof (string), 0, 1);
1763 pp_string (pp, string);
1765 break;
1768 case FIXED_CST:
1770 char string[100];
1771 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1772 pp_string (pp, string);
1773 break;
1776 case COMPLEX_CST:
1777 pp_string (pp, "__complex__ (");
1778 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1779 pp_string (pp, ", ");
1780 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1781 pp_right_paren (pp);
1782 break;
1784 case STRING_CST:
1785 pp_string (pp, "\"");
1786 pretty_print_string (pp, TREE_STRING_POINTER (node));
1787 pp_string (pp, "\"");
1788 break;
1790 case VECTOR_CST:
1792 unsigned i;
1793 pp_string (pp, "{ ");
1794 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1796 if (i != 0)
1797 pp_string (pp, ", ");
1798 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1799 spc, flags, false);
1801 pp_string (pp, " }");
1803 break;
1805 case FUNCTION_TYPE:
1806 case METHOD_TYPE:
1807 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1808 pp_space (pp);
1809 if (TREE_CODE (node) == METHOD_TYPE)
1811 if (TYPE_METHOD_BASETYPE (node))
1812 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1813 flags);
1814 else
1815 pp_string (pp, "<null method basetype>");
1816 pp_colon_colon (pp);
1818 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1819 dump_decl_name (pp, TYPE_NAME (node), flags);
1820 else if (flags & TDF_NOUID)
1821 pp_printf (pp, "<Txxxx>");
1822 else
1823 pp_printf (pp, "<T%x>", TYPE_UID (node));
1824 dump_function_declaration (pp, node, spc, flags);
1825 break;
1827 case FUNCTION_DECL:
1828 case CONST_DECL:
1829 dump_decl_name (pp, node, flags);
1830 break;
1832 case LABEL_DECL:
1833 if (DECL_NAME (node))
1834 dump_decl_name (pp, node, flags);
1835 else if (LABEL_DECL_UID (node) != -1)
1837 if (flags & TDF_GIMPLE)
1838 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
1839 else
1840 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1842 else
1844 if (flags & TDF_NOUID)
1845 pp_string (pp, "<D.xxxx>");
1846 else
1848 if (flags & TDF_GIMPLE)
1849 pp_printf (pp, "<D%u>", DECL_UID (node));
1850 else
1851 pp_printf (pp, "<D.%u>", DECL_UID (node));
1854 break;
1856 case TYPE_DECL:
1857 if (DECL_IS_BUILTIN (node))
1859 /* Don't print the declaration of built-in types. */
1860 break;
1862 if (DECL_NAME (node))
1863 dump_decl_name (pp, node, flags);
1864 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1866 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1867 ? "union" : "struct "));
1868 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1870 else
1871 pp_string (pp, "<anon>");
1872 break;
1874 case VAR_DECL:
1875 case PARM_DECL:
1876 case FIELD_DECL:
1877 case DEBUG_EXPR_DECL:
1878 case NAMESPACE_DECL:
1879 case NAMELIST_DECL:
1880 dump_decl_name (pp, node, flags);
1881 break;
1883 case RESULT_DECL:
1884 pp_string (pp, "<retval>");
1885 break;
1887 case COMPONENT_REF:
1888 op0 = TREE_OPERAND (node, 0);
1889 str = ".";
1890 if (op0
1891 && (TREE_CODE (op0) == INDIRECT_REF
1892 || (TREE_CODE (op0) == MEM_REF
1893 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1894 && integer_zerop (TREE_OPERAND (op0, 1))
1895 /* Dump the types of INTEGER_CSTs explicitly, for we
1896 can't infer them and MEM_ATTR caching will share
1897 MEM_REFs with differently-typed op0s. */
1898 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1899 /* Released SSA_NAMES have no TREE_TYPE. */
1900 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1901 /* Same pointer types, but ignoring POINTER_TYPE vs.
1902 REFERENCE_TYPE. */
1903 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1904 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1905 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1906 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1907 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1908 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1909 /* Same value types ignoring qualifiers. */
1910 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1911 == TYPE_MAIN_VARIANT
1912 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1913 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1915 op0 = TREE_OPERAND (op0, 0);
1916 str = "->";
1918 if (op_prio (op0) < op_prio (node))
1919 pp_left_paren (pp);
1920 dump_generic_node (pp, op0, spc, flags, false);
1921 if (op_prio (op0) < op_prio (node))
1922 pp_right_paren (pp);
1923 pp_string (pp, str);
1924 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1925 op0 = component_ref_field_offset (node);
1926 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1928 pp_string (pp, "{off: ");
1929 dump_generic_node (pp, op0, spc, flags, false);
1930 pp_right_brace (pp);
1932 break;
1934 case BIT_FIELD_REF:
1935 pp_string (pp, "BIT_FIELD_REF <");
1936 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1937 pp_string (pp, ", ");
1938 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1939 pp_string (pp, ", ");
1940 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1941 pp_greater (pp);
1942 break;
1944 case BIT_INSERT_EXPR:
1945 pp_string (pp, "BIT_INSERT_EXPR <");
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_string (pp, " (");
1952 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
1953 pp_decimal_int (pp,
1954 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
1955 else
1956 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
1957 spc, flags, false);
1958 pp_string (pp, " bits)>");
1959 break;
1961 case ARRAY_REF:
1962 case ARRAY_RANGE_REF:
1963 op0 = TREE_OPERAND (node, 0);
1964 if (op_prio (op0) < op_prio (node))
1965 pp_left_paren (pp);
1966 dump_generic_node (pp, op0, spc, flags, false);
1967 if (op_prio (op0) < op_prio (node))
1968 pp_right_paren (pp);
1969 pp_left_bracket (pp);
1970 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1971 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1972 pp_string (pp, " ...");
1973 pp_right_bracket (pp);
1975 op0 = array_ref_low_bound (node);
1976 op1 = array_ref_element_size (node);
1978 if (!integer_zerop (op0)
1979 || TREE_OPERAND (node, 2)
1980 || TREE_OPERAND (node, 3))
1982 pp_string (pp, "{lb: ");
1983 dump_generic_node (pp, op0, spc, flags, false);
1984 pp_string (pp, " sz: ");
1985 dump_generic_node (pp, op1, spc, flags, false);
1986 pp_right_brace (pp);
1988 break;
1990 case CONSTRUCTOR:
1992 unsigned HOST_WIDE_INT ix;
1993 tree field, val;
1994 bool is_struct_init = false;
1995 bool is_array_init = false;
1996 widest_int curidx;
1997 pp_left_brace (pp);
1998 if (TREE_CLOBBER_P (node))
1999 pp_string (pp, "CLOBBER");
2000 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2001 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2002 is_struct_init = true;
2003 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2004 && TYPE_DOMAIN (TREE_TYPE (node))
2005 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2006 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2007 == INTEGER_CST)
2009 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2010 is_array_init = true;
2011 curidx = wi::to_widest (minv);
2013 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2015 if (field)
2017 if (is_struct_init)
2019 pp_dot (pp);
2020 dump_generic_node (pp, field, spc, flags, false);
2021 pp_equal (pp);
2023 else if (is_array_init
2024 && (TREE_CODE (field) != INTEGER_CST
2025 || curidx != wi::to_widest (field)))
2027 pp_left_bracket (pp);
2028 if (TREE_CODE (field) == RANGE_EXPR)
2030 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2031 flags, false);
2032 pp_string (pp, " ... ");
2033 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2034 flags, false);
2035 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2036 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2038 else
2039 dump_generic_node (pp, field, spc, flags, false);
2040 if (TREE_CODE (field) == INTEGER_CST)
2041 curidx = wi::to_widest (field);
2042 pp_string (pp, "]=");
2045 if (is_array_init)
2046 curidx += 1;
2047 if (val && TREE_CODE (val) == ADDR_EXPR)
2048 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2049 val = TREE_OPERAND (val, 0);
2050 if (val && TREE_CODE (val) == FUNCTION_DECL)
2051 dump_decl_name (pp, val, flags);
2052 else
2053 dump_generic_node (pp, val, spc, flags, false);
2054 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2056 pp_comma (pp);
2057 pp_space (pp);
2060 pp_right_brace (pp);
2062 break;
2064 case COMPOUND_EXPR:
2066 tree *tp;
2067 if (flags & TDF_SLIM)
2069 pp_string (pp, "<COMPOUND_EXPR>");
2070 break;
2073 dump_generic_node (pp, TREE_OPERAND (node, 0),
2074 spc, flags, !(flags & TDF_SLIM));
2075 if (flags & TDF_SLIM)
2076 newline_and_indent (pp, spc);
2077 else
2079 pp_comma (pp);
2080 pp_space (pp);
2083 for (tp = &TREE_OPERAND (node, 1);
2084 TREE_CODE (*tp) == COMPOUND_EXPR;
2085 tp = &TREE_OPERAND (*tp, 1))
2087 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2088 spc, flags, !(flags & TDF_SLIM));
2089 if (flags & TDF_SLIM)
2090 newline_and_indent (pp, spc);
2091 else
2093 pp_comma (pp);
2094 pp_space (pp);
2098 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2100 break;
2102 case STATEMENT_LIST:
2104 tree_stmt_iterator si;
2105 bool first = true;
2107 if (flags & TDF_SLIM)
2109 pp_string (pp, "<STATEMENT_LIST>");
2110 break;
2113 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2115 if (!first)
2116 newline_and_indent (pp, spc);
2117 else
2118 first = false;
2119 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2122 break;
2124 case MODIFY_EXPR:
2125 case INIT_EXPR:
2126 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2127 false);
2128 pp_space (pp);
2129 pp_equal (pp);
2130 pp_space (pp);
2131 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2132 false);
2133 break;
2135 case TARGET_EXPR:
2136 pp_string (pp, "TARGET_EXPR <");
2137 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2138 pp_comma (pp);
2139 pp_space (pp);
2140 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2141 pp_greater (pp);
2142 break;
2144 case DECL_EXPR:
2145 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2146 is_stmt = false;
2147 break;
2149 case COND_EXPR:
2150 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2152 pp_string (pp, "if (");
2153 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2154 pp_right_paren (pp);
2155 /* The lowered cond_exprs should always be printed in full. */
2156 if (COND_EXPR_THEN (node)
2157 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2158 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2159 && COND_EXPR_ELSE (node)
2160 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2161 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2163 pp_space (pp);
2164 dump_generic_node (pp, COND_EXPR_THEN (node),
2165 0, flags, true);
2166 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2168 pp_string (pp, " else ");
2169 dump_generic_node (pp, COND_EXPR_ELSE (node),
2170 0, flags, true);
2173 else if (!(flags & TDF_SLIM))
2175 /* Output COND_EXPR_THEN. */
2176 if (COND_EXPR_THEN (node))
2178 newline_and_indent (pp, spc+2);
2179 pp_left_brace (pp);
2180 newline_and_indent (pp, spc+4);
2181 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2182 flags, true);
2183 newline_and_indent (pp, spc+2);
2184 pp_right_brace (pp);
2187 /* Output COND_EXPR_ELSE. */
2188 if (COND_EXPR_ELSE (node)
2189 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2191 newline_and_indent (pp, spc);
2192 pp_string (pp, "else");
2193 newline_and_indent (pp, spc+2);
2194 pp_left_brace (pp);
2195 newline_and_indent (pp, spc+4);
2196 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2197 flags, true);
2198 newline_and_indent (pp, spc+2);
2199 pp_right_brace (pp);
2202 is_expr = false;
2204 else
2206 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2207 pp_space (pp);
2208 pp_question (pp);
2209 pp_space (pp);
2210 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2211 pp_space (pp);
2212 pp_colon (pp);
2213 pp_space (pp);
2214 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2216 break;
2218 case BIND_EXPR:
2219 pp_left_brace (pp);
2220 if (!(flags & TDF_SLIM))
2222 if (BIND_EXPR_VARS (node))
2224 pp_newline (pp);
2226 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2228 print_declaration (pp, op0, spc+2, flags);
2229 pp_newline (pp);
2233 newline_and_indent (pp, spc+2);
2234 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2235 newline_and_indent (pp, spc);
2236 pp_right_brace (pp);
2238 is_expr = false;
2239 break;
2241 case CALL_EXPR:
2242 if (CALL_EXPR_FN (node) != NULL_TREE)
2243 print_call_name (pp, CALL_EXPR_FN (node), flags);
2244 else
2245 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2247 /* Print parameters. */
2248 pp_space (pp);
2249 pp_left_paren (pp);
2251 tree arg;
2252 call_expr_arg_iterator iter;
2253 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2255 dump_generic_node (pp, arg, spc, flags, false);
2256 if (more_call_expr_args_p (&iter))
2258 pp_comma (pp);
2259 pp_space (pp);
2263 if (CALL_EXPR_VA_ARG_PACK (node))
2265 if (call_expr_nargs (node) > 0)
2267 pp_comma (pp);
2268 pp_space (pp);
2270 pp_string (pp, "__builtin_va_arg_pack ()");
2272 pp_right_paren (pp);
2274 op1 = CALL_EXPR_STATIC_CHAIN (node);
2275 if (op1)
2277 pp_string (pp, " [static-chain: ");
2278 dump_generic_node (pp, op1, spc, flags, false);
2279 pp_right_bracket (pp);
2282 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2283 pp_string (pp, " [return slot optimization]");
2284 if (CALL_EXPR_TAILCALL (node))
2285 pp_string (pp, " [tail call]");
2286 break;
2288 case WITH_CLEANUP_EXPR:
2289 NIY;
2290 break;
2292 case CLEANUP_POINT_EXPR:
2293 pp_string (pp, "<<cleanup_point ");
2294 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2295 pp_string (pp, ">>");
2296 break;
2298 case PLACEHOLDER_EXPR:
2299 pp_string (pp, "<PLACEHOLDER_EXPR ");
2300 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2301 pp_greater (pp);
2302 break;
2304 /* Binary arithmetic and logic expressions. */
2305 case WIDEN_SUM_EXPR:
2306 case WIDEN_MULT_EXPR:
2307 case MULT_EXPR:
2308 case MULT_HIGHPART_EXPR:
2309 case PLUS_EXPR:
2310 case POINTER_PLUS_EXPR:
2311 case MINUS_EXPR:
2312 case TRUNC_DIV_EXPR:
2313 case CEIL_DIV_EXPR:
2314 case FLOOR_DIV_EXPR:
2315 case ROUND_DIV_EXPR:
2316 case TRUNC_MOD_EXPR:
2317 case CEIL_MOD_EXPR:
2318 case FLOOR_MOD_EXPR:
2319 case ROUND_MOD_EXPR:
2320 case RDIV_EXPR:
2321 case EXACT_DIV_EXPR:
2322 case LSHIFT_EXPR:
2323 case RSHIFT_EXPR:
2324 case LROTATE_EXPR:
2325 case RROTATE_EXPR:
2326 case WIDEN_LSHIFT_EXPR:
2327 case BIT_IOR_EXPR:
2328 case BIT_XOR_EXPR:
2329 case BIT_AND_EXPR:
2330 case TRUTH_ANDIF_EXPR:
2331 case TRUTH_ORIF_EXPR:
2332 case TRUTH_AND_EXPR:
2333 case TRUTH_OR_EXPR:
2334 case TRUTH_XOR_EXPR:
2335 case LT_EXPR:
2336 case LE_EXPR:
2337 case GT_EXPR:
2338 case GE_EXPR:
2339 case EQ_EXPR:
2340 case NE_EXPR:
2341 case UNLT_EXPR:
2342 case UNLE_EXPR:
2343 case UNGT_EXPR:
2344 case UNGE_EXPR:
2345 case UNEQ_EXPR:
2346 case LTGT_EXPR:
2347 case ORDERED_EXPR:
2348 case UNORDERED_EXPR:
2350 const char *op = op_symbol (node);
2351 op0 = TREE_OPERAND (node, 0);
2352 op1 = TREE_OPERAND (node, 1);
2354 /* When the operands are expressions with less priority,
2355 keep semantics of the tree representation. */
2356 if (op_prio (op0) <= op_prio (node))
2358 pp_left_paren (pp);
2359 dump_generic_node (pp, op0, spc, flags, false);
2360 pp_right_paren (pp);
2362 else
2363 dump_generic_node (pp, op0, spc, flags, false);
2365 pp_space (pp);
2366 pp_string (pp, op);
2367 pp_space (pp);
2369 /* When the operands are expressions with less priority,
2370 keep semantics of the tree representation. */
2371 if (op_prio (op1) <= op_prio (node))
2373 pp_left_paren (pp);
2374 dump_generic_node (pp, op1, spc, flags, false);
2375 pp_right_paren (pp);
2377 else
2378 dump_generic_node (pp, op1, spc, flags, false);
2380 break;
2382 /* Unary arithmetic and logic expressions. */
2383 case NEGATE_EXPR:
2384 case BIT_NOT_EXPR:
2385 case TRUTH_NOT_EXPR:
2386 case ADDR_EXPR:
2387 case PREDECREMENT_EXPR:
2388 case PREINCREMENT_EXPR:
2389 case INDIRECT_REF:
2390 if (TREE_CODE (node) == ADDR_EXPR
2391 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2392 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2393 ; /* Do not output '&' for strings and function pointers. */
2394 else
2395 pp_string (pp, op_symbol (node));
2397 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2399 pp_left_paren (pp);
2400 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2401 pp_right_paren (pp);
2403 else
2404 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2405 break;
2407 case POSTDECREMENT_EXPR:
2408 case POSTINCREMENT_EXPR:
2409 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2411 pp_left_paren (pp);
2412 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2413 pp_right_paren (pp);
2415 else
2416 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2417 pp_string (pp, op_symbol (node));
2418 break;
2420 case MIN_EXPR:
2421 pp_string (pp, "MIN_EXPR <");
2422 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2423 pp_string (pp, ", ");
2424 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2425 pp_greater (pp);
2426 break;
2428 case MAX_EXPR:
2429 pp_string (pp, "MAX_EXPR <");
2430 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2431 pp_string (pp, ", ");
2432 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2433 pp_greater (pp);
2434 break;
2436 case ABS_EXPR:
2437 pp_string (pp, "ABS_EXPR <");
2438 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2439 pp_greater (pp);
2440 break;
2442 case RANGE_EXPR:
2443 NIY;
2444 break;
2446 case ADDR_SPACE_CONVERT_EXPR:
2447 case FIXED_CONVERT_EXPR:
2448 case FIX_TRUNC_EXPR:
2449 case FLOAT_EXPR:
2450 CASE_CONVERT:
2451 type = TREE_TYPE (node);
2452 op0 = TREE_OPERAND (node, 0);
2453 if (type != TREE_TYPE (op0))
2455 pp_left_paren (pp);
2456 dump_generic_node (pp, type, spc, flags, false);
2457 pp_string (pp, ") ");
2459 if (op_prio (op0) < op_prio (node))
2460 pp_left_paren (pp);
2461 dump_generic_node (pp, op0, spc, flags, false);
2462 if (op_prio (op0) < op_prio (node))
2463 pp_right_paren (pp);
2464 break;
2466 case VIEW_CONVERT_EXPR:
2467 pp_string (pp, "VIEW_CONVERT_EXPR<");
2468 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2469 pp_string (pp, ">(");
2470 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2471 pp_right_paren (pp);
2472 break;
2474 case PAREN_EXPR:
2475 pp_string (pp, "((");
2476 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2477 pp_string (pp, "))");
2478 break;
2480 case NON_LVALUE_EXPR:
2481 pp_string (pp, "NON_LVALUE_EXPR <");
2482 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2483 pp_greater (pp);
2484 break;
2486 case SAVE_EXPR:
2487 pp_string (pp, "SAVE_EXPR <");
2488 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2489 pp_greater (pp);
2490 break;
2492 case COMPLEX_EXPR:
2493 pp_string (pp, "COMPLEX_EXPR <");
2494 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2495 pp_string (pp, ", ");
2496 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2497 pp_greater (pp);
2498 break;
2500 case CONJ_EXPR:
2501 pp_string (pp, "CONJ_EXPR <");
2502 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2503 pp_greater (pp);
2504 break;
2506 case REALPART_EXPR:
2507 if (flags & TDF_GIMPLE)
2509 pp_string (pp, "__real ");
2510 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2512 else
2514 pp_string (pp, "REALPART_EXPR <");
2515 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2516 pp_greater (pp);
2518 break;
2520 case IMAGPART_EXPR:
2521 if (flags & TDF_GIMPLE)
2523 pp_string (pp, "__imag ");
2524 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2526 else
2528 pp_string (pp, "IMAGPART_EXPR <");
2529 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2530 pp_greater (pp);
2532 break;
2534 case VA_ARG_EXPR:
2535 pp_string (pp, "VA_ARG_EXPR <");
2536 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2537 pp_greater (pp);
2538 break;
2540 case TRY_FINALLY_EXPR:
2541 case TRY_CATCH_EXPR:
2542 pp_string (pp, "try");
2543 newline_and_indent (pp, spc+2);
2544 pp_left_brace (pp);
2545 newline_and_indent (pp, spc+4);
2546 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2547 newline_and_indent (pp, spc+2);
2548 pp_right_brace (pp);
2549 newline_and_indent (pp, spc);
2550 pp_string (pp,
2551 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2552 newline_and_indent (pp, spc+2);
2553 pp_left_brace (pp);
2554 newline_and_indent (pp, spc+4);
2555 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2556 newline_and_indent (pp, spc+2);
2557 pp_right_brace (pp);
2558 is_expr = false;
2559 break;
2561 case CATCH_EXPR:
2562 pp_string (pp, "catch (");
2563 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2564 pp_right_paren (pp);
2565 newline_and_indent (pp, spc+2);
2566 pp_left_brace (pp);
2567 newline_and_indent (pp, spc+4);
2568 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2569 newline_and_indent (pp, spc+2);
2570 pp_right_brace (pp);
2571 is_expr = false;
2572 break;
2574 case EH_FILTER_EXPR:
2575 pp_string (pp, "<<<eh_filter (");
2576 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2577 pp_string (pp, ")>>>");
2578 newline_and_indent (pp, spc+2);
2579 pp_left_brace (pp);
2580 newline_and_indent (pp, spc+4);
2581 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2582 newline_and_indent (pp, spc+2);
2583 pp_right_brace (pp);
2584 is_expr = false;
2585 break;
2587 case LABEL_EXPR:
2588 op0 = TREE_OPERAND (node, 0);
2589 /* If this is for break or continue, don't bother printing it. */
2590 if (DECL_NAME (op0))
2592 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2593 if (strcmp (name, "break") == 0
2594 || strcmp (name, "continue") == 0)
2595 break;
2597 dump_generic_node (pp, op0, spc, flags, false);
2598 pp_colon (pp);
2599 if (DECL_NONLOCAL (op0))
2600 pp_string (pp, " [non-local]");
2601 break;
2603 case LOOP_EXPR:
2604 pp_string (pp, "while (1)");
2605 if (!(flags & TDF_SLIM))
2607 newline_and_indent (pp, spc+2);
2608 pp_left_brace (pp);
2609 newline_and_indent (pp, spc+4);
2610 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2611 newline_and_indent (pp, spc+2);
2612 pp_right_brace (pp);
2614 is_expr = false;
2615 break;
2617 case PREDICT_EXPR:
2618 pp_string (pp, "// predicted ");
2619 if (PREDICT_EXPR_OUTCOME (node))
2620 pp_string (pp, "likely by ");
2621 else
2622 pp_string (pp, "unlikely by ");
2623 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2624 pp_string (pp, " predictor.");
2625 break;
2627 case ANNOTATE_EXPR:
2628 pp_string (pp, "ANNOTATE_EXPR <");
2629 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2630 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2632 case annot_expr_ivdep_kind:
2633 pp_string (pp, ", ivdep");
2634 break;
2635 case annot_expr_no_vector_kind:
2636 pp_string (pp, ", no-vector");
2637 break;
2638 case annot_expr_vector_kind:
2639 pp_string (pp, ", vector");
2640 break;
2641 default:
2642 gcc_unreachable ();
2644 pp_greater (pp);
2645 break;
2647 case RETURN_EXPR:
2648 pp_string (pp, "return");
2649 op0 = TREE_OPERAND (node, 0);
2650 if (op0)
2652 pp_space (pp);
2653 if (TREE_CODE (op0) == MODIFY_EXPR)
2654 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2655 spc, flags, false);
2656 else
2657 dump_generic_node (pp, op0, spc, flags, false);
2659 break;
2661 case EXIT_EXPR:
2662 pp_string (pp, "if (");
2663 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2664 pp_string (pp, ") break");
2665 break;
2667 case SWITCH_EXPR:
2668 pp_string (pp, "switch (");
2669 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2670 pp_right_paren (pp);
2671 if (!(flags & TDF_SLIM))
2673 newline_and_indent (pp, spc+2);
2674 pp_left_brace (pp);
2675 if (SWITCH_BODY (node))
2677 newline_and_indent (pp, spc+4);
2678 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2679 true);
2681 else
2683 tree vec = SWITCH_LABELS (node);
2684 size_t i, n = TREE_VEC_LENGTH (vec);
2685 for (i = 0; i < n; ++i)
2687 tree elt = TREE_VEC_ELT (vec, i);
2688 newline_and_indent (pp, spc+4);
2689 if (elt)
2691 dump_generic_node (pp, elt, spc+4, flags, false);
2692 pp_string (pp, " goto ");
2693 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2694 flags, true);
2695 pp_semicolon (pp);
2697 else
2698 pp_string (pp, "case ???: goto ???;");
2701 newline_and_indent (pp, spc+2);
2702 pp_right_brace (pp);
2704 is_expr = false;
2705 break;
2707 case GOTO_EXPR:
2708 op0 = GOTO_DESTINATION (node);
2709 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2711 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2712 if (strcmp (name, "break") == 0
2713 || strcmp (name, "continue") == 0)
2715 pp_string (pp, name);
2716 break;
2719 pp_string (pp, "goto ");
2720 dump_generic_node (pp, op0, spc, flags, false);
2721 break;
2723 case ASM_EXPR:
2724 pp_string (pp, "__asm__");
2725 if (ASM_VOLATILE_P (node))
2726 pp_string (pp, " __volatile__");
2727 pp_left_paren (pp);
2728 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2729 pp_colon (pp);
2730 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2731 pp_colon (pp);
2732 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2733 if (ASM_CLOBBERS (node))
2735 pp_colon (pp);
2736 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2738 pp_right_paren (pp);
2739 break;
2741 case CASE_LABEL_EXPR:
2742 if (CASE_LOW (node) && CASE_HIGH (node))
2744 pp_string (pp, "case ");
2745 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2746 pp_string (pp, " ... ");
2747 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2749 else if (CASE_LOW (node))
2751 pp_string (pp, "case ");
2752 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2754 else
2755 pp_string (pp, "default");
2756 pp_colon (pp);
2757 break;
2759 case OBJ_TYPE_REF:
2760 pp_string (pp, "OBJ_TYPE_REF(");
2761 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2762 pp_semicolon (pp);
2763 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2765 pp_string (pp, "(");
2766 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2767 pp_string (pp, ")");
2769 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2770 pp_arrow (pp);
2771 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2772 pp_right_paren (pp);
2773 break;
2775 case SSA_NAME:
2776 if (SSA_NAME_IDENTIFIER (node))
2778 if ((flags & TDF_NOUID)
2779 && SSA_NAME_VAR (node)
2780 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2781 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2782 else if (! (flags & TDF_GIMPLE)
2783 || SSA_NAME_VAR (node))
2784 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2785 spc, flags, false);
2787 pp_underscore (pp);
2788 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2789 if (SSA_NAME_IS_DEFAULT_DEF (node))
2790 pp_string (pp, "(D)");
2791 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2792 pp_string (pp, "(ab)");
2793 break;
2795 case WITH_SIZE_EXPR:
2796 pp_string (pp, "WITH_SIZE_EXPR <");
2797 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2798 pp_string (pp, ", ");
2799 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2800 pp_greater (pp);
2801 break;
2803 case ASSERT_EXPR:
2804 pp_string (pp, "ASSERT_EXPR <");
2805 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2806 pp_string (pp, ", ");
2807 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2808 pp_greater (pp);
2809 break;
2811 case SCEV_KNOWN:
2812 pp_string (pp, "scev_known");
2813 break;
2815 case SCEV_NOT_KNOWN:
2816 pp_string (pp, "scev_not_known");
2817 break;
2819 case POLYNOMIAL_CHREC:
2820 pp_left_brace (pp);
2821 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2822 pp_string (pp, ", +, ");
2823 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2824 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
2825 is_stmt = false;
2826 break;
2828 case REALIGN_LOAD_EXPR:
2829 pp_string (pp, "REALIGN_LOAD <");
2830 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2831 pp_string (pp, ", ");
2832 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2833 pp_string (pp, ", ");
2834 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2835 pp_greater (pp);
2836 break;
2838 case VEC_COND_EXPR:
2839 pp_string (pp, " VEC_COND_EXPR < ");
2840 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2841 pp_string (pp, " , ");
2842 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2843 pp_string (pp, " , ");
2844 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2845 pp_string (pp, " > ");
2846 break;
2848 case VEC_PERM_EXPR:
2849 pp_string (pp, " VEC_PERM_EXPR < ");
2850 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2851 pp_string (pp, " , ");
2852 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2853 pp_string (pp, " , ");
2854 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2855 pp_string (pp, " > ");
2856 break;
2858 case DOT_PROD_EXPR:
2859 pp_string (pp, " DOT_PROD_EXPR < ");
2860 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2861 pp_string (pp, ", ");
2862 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2863 pp_string (pp, ", ");
2864 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2865 pp_string (pp, " > ");
2866 break;
2868 case WIDEN_MULT_PLUS_EXPR:
2869 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2870 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2871 pp_string (pp, ", ");
2872 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2873 pp_string (pp, ", ");
2874 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2875 pp_string (pp, " > ");
2876 break;
2878 case WIDEN_MULT_MINUS_EXPR:
2879 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2880 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2881 pp_string (pp, ", ");
2882 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2883 pp_string (pp, ", ");
2884 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2885 pp_string (pp, " > ");
2886 break;
2888 case FMA_EXPR:
2889 pp_string (pp, " FMA_EXPR < ");
2890 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2891 pp_string (pp, ", ");
2892 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2893 pp_string (pp, ", ");
2894 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2895 pp_string (pp, " > ");
2896 break;
2898 case OACC_PARALLEL:
2899 pp_string (pp, "#pragma acc parallel");
2900 goto dump_omp_clauses_body;
2902 case OACC_KERNELS:
2903 pp_string (pp, "#pragma acc kernels");
2904 goto dump_omp_clauses_body;
2906 case OACC_DATA:
2907 pp_string (pp, "#pragma acc data");
2908 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2909 goto dump_omp_body;
2911 case OACC_HOST_DATA:
2912 pp_string (pp, "#pragma acc host_data");
2913 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2914 goto dump_omp_body;
2916 case OACC_DECLARE:
2917 pp_string (pp, "#pragma acc declare");
2918 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2919 break;
2921 case OACC_UPDATE:
2922 pp_string (pp, "#pragma acc update");
2923 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2924 break;
2926 case OACC_ENTER_DATA:
2927 pp_string (pp, "#pragma acc enter data");
2928 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2929 break;
2931 case OACC_EXIT_DATA:
2932 pp_string (pp, "#pragma acc exit data");
2933 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2934 break;
2936 case OACC_CACHE:
2937 pp_string (pp, "#pragma acc cache");
2938 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2939 break;
2941 case OMP_PARALLEL:
2942 pp_string (pp, "#pragma omp parallel");
2943 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2944 goto dump_omp_body;
2946 dump_omp_clauses_body:
2947 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
2948 goto dump_omp_body;
2950 dump_omp_body:
2951 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2953 newline_and_indent (pp, spc + 2);
2954 pp_left_brace (pp);
2955 newline_and_indent (pp, spc + 4);
2956 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2957 newline_and_indent (pp, spc + 2);
2958 pp_right_brace (pp);
2960 is_expr = false;
2961 break;
2963 case OMP_TASK:
2964 pp_string (pp, "#pragma omp task");
2965 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2966 goto dump_omp_body;
2968 case OMP_FOR:
2969 pp_string (pp, "#pragma omp for");
2970 goto dump_omp_loop;
2972 case OMP_SIMD:
2973 pp_string (pp, "#pragma omp simd");
2974 goto dump_omp_loop;
2976 case CILK_SIMD:
2977 pp_string (pp, "#pragma simd");
2978 goto dump_omp_loop;
2980 case CILK_FOR:
2981 /* This label points one line after dumping the clauses.
2982 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2983 parameters are printed out. */
2984 goto dump_omp_loop_cilk_for;
2986 case OMP_DISTRIBUTE:
2987 pp_string (pp, "#pragma omp distribute");
2988 goto dump_omp_loop;
2990 case OMP_TASKLOOP:
2991 pp_string (pp, "#pragma omp taskloop");
2992 goto dump_omp_loop;
2994 case OACC_LOOP:
2995 pp_string (pp, "#pragma acc loop");
2996 goto dump_omp_loop;
2998 case OMP_TEAMS:
2999 pp_string (pp, "#pragma omp teams");
3000 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3001 goto dump_omp_body;
3003 case OMP_TARGET_DATA:
3004 pp_string (pp, "#pragma omp target data");
3005 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3006 goto dump_omp_body;
3008 case OMP_TARGET_ENTER_DATA:
3009 pp_string (pp, "#pragma omp target enter data");
3010 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3011 is_expr = false;
3012 break;
3014 case OMP_TARGET_EXIT_DATA:
3015 pp_string (pp, "#pragma omp target exit data");
3016 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3017 is_expr = false;
3018 break;
3020 case OMP_TARGET:
3021 pp_string (pp, "#pragma omp target");
3022 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3023 goto dump_omp_body;
3025 case OMP_TARGET_UPDATE:
3026 pp_string (pp, "#pragma omp target update");
3027 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3028 is_expr = false;
3029 break;
3031 dump_omp_loop:
3032 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3034 dump_omp_loop_cilk_for:
3035 if (!(flags & TDF_SLIM))
3037 int i;
3039 if (OMP_FOR_PRE_BODY (node))
3041 if (TREE_CODE (node) == CILK_FOR)
3042 pp_string (pp, " ");
3043 else
3044 newline_and_indent (pp, spc + 2);
3045 pp_left_brace (pp);
3046 spc += 4;
3047 newline_and_indent (pp, spc);
3048 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3049 spc, flags, false);
3051 if (OMP_FOR_INIT (node))
3053 spc -= 2;
3054 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3056 spc += 2;
3057 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
3058 newline_and_indent (pp, spc);
3059 if (TREE_CODE (node) == CILK_FOR)
3060 pp_string (pp, "_Cilk_for (");
3061 else
3062 pp_string (pp, "for (");
3063 dump_generic_node (pp,
3064 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3065 spc, flags, false);
3066 pp_string (pp, "; ");
3067 dump_generic_node (pp,
3068 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3069 spc, flags, false);
3070 pp_string (pp, "; ");
3071 dump_generic_node (pp,
3072 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3073 spc, flags, false);
3074 pp_right_paren (pp);
3076 if (TREE_CODE (node) == CILK_FOR)
3077 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3079 if (OMP_FOR_BODY (node))
3081 newline_and_indent (pp, spc + 2);
3082 pp_left_brace (pp);
3083 newline_and_indent (pp, spc + 4);
3084 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3085 false);
3086 newline_and_indent (pp, spc + 2);
3087 pp_right_brace (pp);
3089 if (OMP_FOR_INIT (node))
3090 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3091 if (OMP_FOR_PRE_BODY (node))
3093 spc -= 4;
3094 newline_and_indent (pp, spc + 2);
3095 pp_right_brace (pp);
3098 is_expr = false;
3099 break;
3101 case OMP_SECTIONS:
3102 pp_string (pp, "#pragma omp sections");
3103 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3104 goto dump_omp_body;
3106 case OMP_SECTION:
3107 pp_string (pp, "#pragma omp section");
3108 goto dump_omp_body;
3110 case OMP_MASTER:
3111 pp_string (pp, "#pragma omp master");
3112 goto dump_omp_body;
3114 case OMP_TASKGROUP:
3115 pp_string (pp, "#pragma omp taskgroup");
3116 goto dump_omp_body;
3118 case OMP_ORDERED:
3119 pp_string (pp, "#pragma omp ordered");
3120 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3121 goto dump_omp_body;
3123 case OMP_CRITICAL:
3124 pp_string (pp, "#pragma omp critical");
3125 if (OMP_CRITICAL_NAME (node))
3127 pp_space (pp);
3128 pp_left_paren (pp);
3129 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3130 flags, false);
3131 pp_right_paren (pp);
3133 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3134 goto dump_omp_body;
3136 case OMP_ATOMIC:
3137 pp_string (pp, "#pragma omp atomic");
3138 if (OMP_ATOMIC_SEQ_CST (node))
3139 pp_string (pp, " seq_cst");
3140 newline_and_indent (pp, spc + 2);
3141 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3142 pp_space (pp);
3143 pp_equal (pp);
3144 pp_space (pp);
3145 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3146 break;
3148 case OMP_ATOMIC_READ:
3149 pp_string (pp, "#pragma omp atomic read");
3150 if (OMP_ATOMIC_SEQ_CST (node))
3151 pp_string (pp, " seq_cst");
3152 newline_and_indent (pp, spc + 2);
3153 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3154 pp_space (pp);
3155 break;
3157 case OMP_ATOMIC_CAPTURE_OLD:
3158 case OMP_ATOMIC_CAPTURE_NEW:
3159 pp_string (pp, "#pragma omp atomic capture");
3160 if (OMP_ATOMIC_SEQ_CST (node))
3161 pp_string (pp, " seq_cst");
3162 newline_and_indent (pp, spc + 2);
3163 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3164 pp_space (pp);
3165 pp_equal (pp);
3166 pp_space (pp);
3167 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3168 break;
3170 case OMP_SINGLE:
3171 pp_string (pp, "#pragma omp single");
3172 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3173 goto dump_omp_body;
3175 case OMP_CLAUSE:
3176 dump_omp_clause (pp, node, spc, flags);
3177 is_expr = false;
3178 break;
3180 case TRANSACTION_EXPR:
3181 if (TRANSACTION_EXPR_OUTER (node))
3182 pp_string (pp, "__transaction_atomic [[outer]]");
3183 else if (TRANSACTION_EXPR_RELAXED (node))
3184 pp_string (pp, "__transaction_relaxed");
3185 else
3186 pp_string (pp, "__transaction_atomic");
3187 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3189 newline_and_indent (pp, spc);
3190 pp_left_brace (pp);
3191 newline_and_indent (pp, spc + 2);
3192 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3193 spc + 2, flags, false);
3194 newline_and_indent (pp, spc);
3195 pp_right_brace (pp);
3197 is_expr = false;
3198 break;
3200 case REDUC_MAX_EXPR:
3201 pp_string (pp, " REDUC_MAX_EXPR < ");
3202 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3203 pp_string (pp, " > ");
3204 break;
3206 case REDUC_MIN_EXPR:
3207 pp_string (pp, " REDUC_MIN_EXPR < ");
3208 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3209 pp_string (pp, " > ");
3210 break;
3212 case REDUC_PLUS_EXPR:
3213 pp_string (pp, " REDUC_PLUS_EXPR < ");
3214 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3215 pp_string (pp, " > ");
3216 break;
3218 case VEC_WIDEN_MULT_HI_EXPR:
3219 case VEC_WIDEN_MULT_LO_EXPR:
3220 case VEC_WIDEN_MULT_EVEN_EXPR:
3221 case VEC_WIDEN_MULT_ODD_EXPR:
3222 case VEC_WIDEN_LSHIFT_HI_EXPR:
3223 case VEC_WIDEN_LSHIFT_LO_EXPR:
3224 pp_space (pp);
3225 for (str = get_tree_code_name (code); *str; str++)
3226 pp_character (pp, TOUPPER (*str));
3227 pp_string (pp, " < ");
3228 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3229 pp_string (pp, ", ");
3230 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3231 pp_string (pp, " > ");
3232 break;
3234 case VEC_UNPACK_HI_EXPR:
3235 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3236 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3237 pp_string (pp, " > ");
3238 break;
3240 case VEC_UNPACK_LO_EXPR:
3241 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3242 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3243 pp_string (pp, " > ");
3244 break;
3246 case VEC_UNPACK_FLOAT_HI_EXPR:
3247 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3248 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3249 pp_string (pp, " > ");
3250 break;
3252 case VEC_UNPACK_FLOAT_LO_EXPR:
3253 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3254 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3255 pp_string (pp, " > ");
3256 break;
3258 case VEC_PACK_TRUNC_EXPR:
3259 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3260 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3261 pp_string (pp, ", ");
3262 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3263 pp_string (pp, " > ");
3264 break;
3266 case VEC_PACK_SAT_EXPR:
3267 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3268 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3269 pp_string (pp, ", ");
3270 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3271 pp_string (pp, " > ");
3272 break;
3274 case VEC_PACK_FIX_TRUNC_EXPR:
3275 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3276 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3277 pp_string (pp, ", ");
3278 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3279 pp_string (pp, " > ");
3280 break;
3282 case BLOCK:
3283 dump_block_node (pp, node, spc, flags);
3284 break;
3286 case CILK_SPAWN_STMT:
3287 pp_string (pp, "_Cilk_spawn ");
3288 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3289 break;
3291 case CILK_SYNC_STMT:
3292 pp_string (pp, "_Cilk_sync");
3293 break;
3295 default:
3296 NIY;
3299 if (is_stmt && is_expr)
3300 pp_semicolon (pp);
3302 return spc;
3305 /* Print the declaration of a variable. */
3307 void
3308 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3310 INDENT (spc);
3312 if (TREE_CODE(t) == NAMELIST_DECL)
3314 pp_string(pp, "namelist ");
3315 dump_decl_name (pp, t, flags);
3316 pp_semicolon (pp);
3317 return;
3320 if (TREE_CODE (t) == TYPE_DECL)
3321 pp_string (pp, "typedef ");
3323 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3324 pp_string (pp, "register ");
3326 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3327 pp_string (pp, "extern ");
3328 else if (TREE_STATIC (t))
3329 pp_string (pp, "static ");
3331 /* Print the type and name. */
3332 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3334 tree tmp;
3336 /* Print array's type. */
3337 tmp = TREE_TYPE (t);
3338 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3339 tmp = TREE_TYPE (tmp);
3340 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3342 /* Print variable's name. */
3343 pp_space (pp);
3344 dump_generic_node (pp, t, spc, flags, false);
3346 /* Print the dimensions. */
3347 tmp = TREE_TYPE (t);
3348 while (TREE_CODE (tmp) == ARRAY_TYPE)
3350 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3351 tmp = TREE_TYPE (tmp);
3354 else if (TREE_CODE (t) == FUNCTION_DECL)
3356 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3357 pp_space (pp);
3358 dump_decl_name (pp, t, flags);
3359 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3361 else
3363 /* Print type declaration. */
3364 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3366 /* Print variable's name. */
3367 pp_space (pp);
3368 dump_generic_node (pp, t, spc, flags, false);
3371 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3373 pp_string (pp, " __asm__ ");
3374 pp_left_paren (pp);
3375 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3376 pp_right_paren (pp);
3379 /* The initial value of a function serves to determine whether the function
3380 is declared or defined. So the following does not apply to function
3381 nodes. */
3382 if (TREE_CODE (t) != FUNCTION_DECL)
3384 /* Print the initial value. */
3385 if (DECL_INITIAL (t))
3387 pp_space (pp);
3388 pp_equal (pp);
3389 pp_space (pp);
3390 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3394 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3396 pp_string (pp, " [value-expr: ");
3397 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3398 pp_right_bracket (pp);
3401 pp_semicolon (pp);
3405 /* Prints a structure: name, fields, and methods.
3406 FIXME: Still incomplete. */
3408 static void
3409 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3410 dump_flags_t flags)
3412 /* Print the name of the structure. */
3413 if (TYPE_NAME (node))
3415 INDENT (spc);
3416 if (TREE_CODE (node) == RECORD_TYPE)
3417 pp_string (pp, "struct ");
3418 else if ((TREE_CODE (node) == UNION_TYPE
3419 || TREE_CODE (node) == QUAL_UNION_TYPE))
3420 pp_string (pp, "union ");
3422 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3425 /* Print the contents of the structure. */
3426 pp_newline (pp);
3427 INDENT (spc);
3428 pp_left_brace (pp);
3429 pp_newline (pp);
3431 /* Print the fields of the structure. */
3433 tree tmp;
3434 tmp = TYPE_FIELDS (node);
3435 while (tmp)
3437 /* Avoid to print recursively the structure. */
3438 /* FIXME : Not implemented correctly...,
3439 what about the case when we have a cycle in the contain graph? ...
3440 Maybe this could be solved by looking at the scope in which the
3441 structure was declared. */
3442 if (TREE_TYPE (tmp) != node
3443 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3444 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3446 print_declaration (pp, tmp, spc+2, flags);
3447 pp_newline (pp);
3449 tmp = DECL_CHAIN (tmp);
3452 INDENT (spc);
3453 pp_right_brace (pp);
3456 /* Return the priority of the operator CODE.
3458 From lowest to highest precedence with either left-to-right (L-R)
3459 or right-to-left (R-L) associativity]:
3461 1 [L-R] ,
3462 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3463 3 [R-L] ?:
3464 4 [L-R] ||
3465 5 [L-R] &&
3466 6 [L-R] |
3467 7 [L-R] ^
3468 8 [L-R] &
3469 9 [L-R] == !=
3470 10 [L-R] < <= > >=
3471 11 [L-R] << >>
3472 12 [L-R] + -
3473 13 [L-R] * / %
3474 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3475 15 [L-R] fn() [] -> .
3477 unary +, - and * have higher precedence than the corresponding binary
3478 operators. */
3481 op_code_prio (enum tree_code code)
3483 switch (code)
3485 case TREE_LIST:
3486 case COMPOUND_EXPR:
3487 case BIND_EXPR:
3488 return 1;
3490 case MODIFY_EXPR:
3491 case INIT_EXPR:
3492 return 2;
3494 case COND_EXPR:
3495 return 3;
3497 case TRUTH_OR_EXPR:
3498 case TRUTH_ORIF_EXPR:
3499 return 4;
3501 case TRUTH_AND_EXPR:
3502 case TRUTH_ANDIF_EXPR:
3503 return 5;
3505 case BIT_IOR_EXPR:
3506 return 6;
3508 case BIT_XOR_EXPR:
3509 case TRUTH_XOR_EXPR:
3510 return 7;
3512 case BIT_AND_EXPR:
3513 return 8;
3515 case EQ_EXPR:
3516 case NE_EXPR:
3517 return 9;
3519 case UNLT_EXPR:
3520 case UNLE_EXPR:
3521 case UNGT_EXPR:
3522 case UNGE_EXPR:
3523 case UNEQ_EXPR:
3524 case LTGT_EXPR:
3525 case ORDERED_EXPR:
3526 case UNORDERED_EXPR:
3527 case LT_EXPR:
3528 case LE_EXPR:
3529 case GT_EXPR:
3530 case GE_EXPR:
3531 return 10;
3533 case LSHIFT_EXPR:
3534 case RSHIFT_EXPR:
3535 case LROTATE_EXPR:
3536 case RROTATE_EXPR:
3537 case VEC_WIDEN_LSHIFT_HI_EXPR:
3538 case VEC_WIDEN_LSHIFT_LO_EXPR:
3539 case WIDEN_LSHIFT_EXPR:
3540 return 11;
3542 case WIDEN_SUM_EXPR:
3543 case PLUS_EXPR:
3544 case POINTER_PLUS_EXPR:
3545 case MINUS_EXPR:
3546 return 12;
3548 case VEC_WIDEN_MULT_HI_EXPR:
3549 case VEC_WIDEN_MULT_LO_EXPR:
3550 case WIDEN_MULT_EXPR:
3551 case DOT_PROD_EXPR:
3552 case WIDEN_MULT_PLUS_EXPR:
3553 case WIDEN_MULT_MINUS_EXPR:
3554 case MULT_EXPR:
3555 case MULT_HIGHPART_EXPR:
3556 case TRUNC_DIV_EXPR:
3557 case CEIL_DIV_EXPR:
3558 case FLOOR_DIV_EXPR:
3559 case ROUND_DIV_EXPR:
3560 case RDIV_EXPR:
3561 case EXACT_DIV_EXPR:
3562 case TRUNC_MOD_EXPR:
3563 case CEIL_MOD_EXPR:
3564 case FLOOR_MOD_EXPR:
3565 case ROUND_MOD_EXPR:
3566 case FMA_EXPR:
3567 return 13;
3569 case TRUTH_NOT_EXPR:
3570 case BIT_NOT_EXPR:
3571 case POSTINCREMENT_EXPR:
3572 case POSTDECREMENT_EXPR:
3573 case PREINCREMENT_EXPR:
3574 case PREDECREMENT_EXPR:
3575 case NEGATE_EXPR:
3576 case INDIRECT_REF:
3577 case ADDR_EXPR:
3578 case FLOAT_EXPR:
3579 CASE_CONVERT:
3580 case FIX_TRUNC_EXPR:
3581 case TARGET_EXPR:
3582 return 14;
3584 case CALL_EXPR:
3585 case ARRAY_REF:
3586 case ARRAY_RANGE_REF:
3587 case COMPONENT_REF:
3588 return 15;
3590 /* Special expressions. */
3591 case MIN_EXPR:
3592 case MAX_EXPR:
3593 case ABS_EXPR:
3594 case REALPART_EXPR:
3595 case IMAGPART_EXPR:
3596 case REDUC_MAX_EXPR:
3597 case REDUC_MIN_EXPR:
3598 case REDUC_PLUS_EXPR:
3599 case VEC_UNPACK_HI_EXPR:
3600 case VEC_UNPACK_LO_EXPR:
3601 case VEC_UNPACK_FLOAT_HI_EXPR:
3602 case VEC_UNPACK_FLOAT_LO_EXPR:
3603 case VEC_PACK_TRUNC_EXPR:
3604 case VEC_PACK_SAT_EXPR:
3605 return 16;
3607 default:
3608 /* Return an arbitrarily high precedence to avoid surrounding single
3609 VAR_DECLs in ()s. */
3610 return 9999;
3614 /* Return the priority of the operator OP. */
3617 op_prio (const_tree op)
3619 enum tree_code code;
3621 if (op == NULL)
3622 return 9999;
3624 code = TREE_CODE (op);
3625 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3626 return op_prio (TREE_OPERAND (op, 0));
3628 return op_code_prio (code);
3631 /* Return the symbol associated with operator CODE. */
3633 const char *
3634 op_symbol_code (enum tree_code code)
3636 switch (code)
3638 case MODIFY_EXPR:
3639 return "=";
3641 case TRUTH_OR_EXPR:
3642 case TRUTH_ORIF_EXPR:
3643 return "||";
3645 case TRUTH_AND_EXPR:
3646 case TRUTH_ANDIF_EXPR:
3647 return "&&";
3649 case BIT_IOR_EXPR:
3650 return "|";
3652 case TRUTH_XOR_EXPR:
3653 case BIT_XOR_EXPR:
3654 return "^";
3656 case ADDR_EXPR:
3657 case BIT_AND_EXPR:
3658 return "&";
3660 case ORDERED_EXPR:
3661 return "ord";
3662 case UNORDERED_EXPR:
3663 return "unord";
3665 case EQ_EXPR:
3666 return "==";
3667 case UNEQ_EXPR:
3668 return "u==";
3670 case NE_EXPR:
3671 return "!=";
3673 case LT_EXPR:
3674 return "<";
3675 case UNLT_EXPR:
3676 return "u<";
3678 case LE_EXPR:
3679 return "<=";
3680 case UNLE_EXPR:
3681 return "u<=";
3683 case GT_EXPR:
3684 return ">";
3685 case UNGT_EXPR:
3686 return "u>";
3688 case GE_EXPR:
3689 return ">=";
3690 case UNGE_EXPR:
3691 return "u>=";
3693 case LTGT_EXPR:
3694 return "<>";
3696 case LSHIFT_EXPR:
3697 return "<<";
3699 case RSHIFT_EXPR:
3700 return ">>";
3702 case LROTATE_EXPR:
3703 return "r<<";
3705 case RROTATE_EXPR:
3706 return "r>>";
3708 case WIDEN_LSHIFT_EXPR:
3709 return "w<<";
3711 case POINTER_PLUS_EXPR:
3712 return "+";
3714 case PLUS_EXPR:
3715 return "+";
3717 case REDUC_PLUS_EXPR:
3718 return "r+";
3720 case WIDEN_SUM_EXPR:
3721 return "w+";
3723 case WIDEN_MULT_EXPR:
3724 return "w*";
3726 case MULT_HIGHPART_EXPR:
3727 return "h*";
3729 case NEGATE_EXPR:
3730 case MINUS_EXPR:
3731 return "-";
3733 case BIT_NOT_EXPR:
3734 return "~";
3736 case TRUTH_NOT_EXPR:
3737 return "!";
3739 case MULT_EXPR:
3740 case INDIRECT_REF:
3741 return "*";
3743 case TRUNC_DIV_EXPR:
3744 case RDIV_EXPR:
3745 return "/";
3747 case CEIL_DIV_EXPR:
3748 return "/[cl]";
3750 case FLOOR_DIV_EXPR:
3751 return "/[fl]";
3753 case ROUND_DIV_EXPR:
3754 return "/[rd]";
3756 case EXACT_DIV_EXPR:
3757 return "/[ex]";
3759 case TRUNC_MOD_EXPR:
3760 return "%";
3762 case CEIL_MOD_EXPR:
3763 return "%[cl]";
3765 case FLOOR_MOD_EXPR:
3766 return "%[fl]";
3768 case ROUND_MOD_EXPR:
3769 return "%[rd]";
3771 case PREDECREMENT_EXPR:
3772 return " --";
3774 case PREINCREMENT_EXPR:
3775 return " ++";
3777 case POSTDECREMENT_EXPR:
3778 return "-- ";
3780 case POSTINCREMENT_EXPR:
3781 return "++ ";
3783 case MAX_EXPR:
3784 return "max";
3786 case MIN_EXPR:
3787 return "min";
3789 default:
3790 return "<<< ??? >>>";
3794 /* Return the symbol associated with operator OP. */
3796 static const char *
3797 op_symbol (const_tree op)
3799 return op_symbol_code (TREE_CODE (op));
3802 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3803 the gimple_call_fn of a GIMPLE_CALL. */
3805 void
3806 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3808 tree op0 = node;
3810 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3811 op0 = TREE_OPERAND (op0, 0);
3813 again:
3814 switch (TREE_CODE (op0))
3816 case VAR_DECL:
3817 case PARM_DECL:
3818 case FUNCTION_DECL:
3819 dump_function_name (pp, op0, flags);
3820 break;
3822 case ADDR_EXPR:
3823 case INDIRECT_REF:
3824 CASE_CONVERT:
3825 op0 = TREE_OPERAND (op0, 0);
3826 goto again;
3828 case COND_EXPR:
3829 pp_left_paren (pp);
3830 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3831 pp_string (pp, ") ? ");
3832 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3833 pp_string (pp, " : ");
3834 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3835 break;
3837 case ARRAY_REF:
3838 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3839 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3840 else
3841 dump_generic_node (pp, op0, 0, flags, false);
3842 break;
3844 case MEM_REF:
3845 if (integer_zerop (TREE_OPERAND (op0, 1)))
3847 op0 = TREE_OPERAND (op0, 0);
3848 goto again;
3850 /* Fallthru. */
3851 case COMPONENT_REF:
3852 case SSA_NAME:
3853 case OBJ_TYPE_REF:
3854 dump_generic_node (pp, op0, 0, flags, false);
3855 break;
3857 default:
3858 NIY;
3862 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3864 static void
3865 pretty_print_string (pretty_printer *pp, const char *str)
3867 if (str == NULL)
3868 return;
3870 while (*str)
3872 switch (str[0])
3874 case '\b':
3875 pp_string (pp, "\\b");
3876 break;
3878 case '\f':
3879 pp_string (pp, "\\f");
3880 break;
3882 case '\n':
3883 pp_string (pp, "\\n");
3884 break;
3886 case '\r':
3887 pp_string (pp, "\\r");
3888 break;
3890 case '\t':
3891 pp_string (pp, "\\t");
3892 break;
3894 case '\v':
3895 pp_string (pp, "\\v");
3896 break;
3898 case '\\':
3899 pp_string (pp, "\\\\");
3900 break;
3902 case '\"':
3903 pp_string (pp, "\\\"");
3904 break;
3906 case '\'':
3907 pp_string (pp, "\\'");
3908 break;
3910 /* No need to handle \0; the loop terminates on \0. */
3912 case '\1':
3913 pp_string (pp, "\\1");
3914 break;
3916 case '\2':
3917 pp_string (pp, "\\2");
3918 break;
3920 case '\3':
3921 pp_string (pp, "\\3");
3922 break;
3924 case '\4':
3925 pp_string (pp, "\\4");
3926 break;
3928 case '\5':
3929 pp_string (pp, "\\5");
3930 break;
3932 case '\6':
3933 pp_string (pp, "\\6");
3934 break;
3936 case '\7':
3937 pp_string (pp, "\\7");
3938 break;
3940 default:
3941 if (!ISPRINT (str[0]))
3943 char buf[5];
3944 sprintf (buf, "\\x%x", (unsigned char)str[0]);
3945 pp_string (pp, buf);
3947 else
3948 pp_character (pp, str[0]);
3949 break;
3951 str++;
3955 static void
3956 maybe_init_pretty_print (FILE *file)
3958 if (!tree_pp)
3960 tree_pp = new pretty_printer ();
3961 pp_needs_newline (tree_pp) = true;
3962 pp_translate_identifiers (tree_pp) = false;
3965 tree_pp->buffer->stream = file;
3968 static void
3969 newline_and_indent (pretty_printer *pp, int spc)
3971 pp_newline (pp);
3972 INDENT (spc);
3975 /* Handle the %K format for TEXT. Separate from default_tree_printer
3976 so it can also be used in front ends.
3977 Argument is a statement from which EXPR_LOCATION and TREE_BLOCK will
3978 be recorded. */
3980 void
3981 percent_K_format (text_info *text, tree t)
3983 text->set_location (0, EXPR_LOCATION (t), true);
3984 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3985 tree block = TREE_BLOCK (t);
3986 *pp_ti_abstract_origin (text) = NULL;
3988 if (in_lto_p)
3990 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3991 representing the outermost block of an inlined function.
3992 So walk the BLOCK tree until we hit such a scope. */
3993 while (block
3994 && TREE_CODE (block) == BLOCK)
3996 if (inlined_function_outer_scope_p (block))
3998 *pp_ti_abstract_origin (text) = block;
3999 break;
4001 block = BLOCK_SUPERCONTEXT (block);
4003 return;
4006 while (block
4007 && TREE_CODE (block) == BLOCK
4008 && BLOCK_ABSTRACT_ORIGIN (block))
4010 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4012 while (TREE_CODE (ao) == BLOCK
4013 && BLOCK_ABSTRACT_ORIGIN (ao)
4014 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
4015 ao = BLOCK_ABSTRACT_ORIGIN (ao);
4017 if (TREE_CODE (ao) == FUNCTION_DECL)
4019 *pp_ti_abstract_origin (text) = block;
4020 break;
4022 block = BLOCK_SUPERCONTEXT (block);
4026 /* Print the identifier ID to PRETTY-PRINTER. */
4028 void
4029 pp_tree_identifier (pretty_printer *pp, tree id)
4031 if (pp_translate_identifiers (pp))
4033 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4034 pp_append_text (pp, text, text + strlen (text));
4036 else
4037 pp_append_text (pp, IDENTIFIER_POINTER (id),
4038 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4041 /* A helper function that is used to dump function information before the
4042 function dump. */
4044 void
4045 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4047 const char *dname, *aname;
4048 struct cgraph_node *node = cgraph_node::get (fdecl);
4049 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4051 dname = lang_hooks.decl_printable_name (fdecl, 1);
4053 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4054 aname = (IDENTIFIER_POINTER
4055 (DECL_ASSEMBLER_NAME (fdecl)));
4056 else
4057 aname = "<unset-asm-name>";
4059 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4060 dname, aname, fun->funcdef_no);
4061 if (!(flags & TDF_NOUID))
4062 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4063 if (node)
4065 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
4066 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4067 node->frequency == NODE_FREQUENCY_HOT
4068 ? " (hot)"
4069 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4070 ? " (unlikely executed)"
4071 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4072 ? " (executed once)"
4073 : "");
4075 else
4076 fprintf (dump_file, ")\n\n");
4079 /* Dump double_int D to pretty_printer PP. UNS is true
4080 if D is unsigned and false otherwise. */
4081 void
4082 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4084 if (d.fits_shwi ())
4085 pp_wide_integer (pp, d.low);
4086 else if (d.fits_uhwi ())
4087 pp_unsigned_wide_integer (pp, d.low);
4088 else
4090 unsigned HOST_WIDE_INT low = d.low;
4091 HOST_WIDE_INT high = d.high;
4092 if (!uns && d.is_negative ())
4094 pp_minus (pp);
4095 high = ~high + !low;
4096 low = -low;
4098 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4099 systems? */
4100 sprintf (pp_buffer (pp)->digit_buffer,
4101 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4102 (unsigned HOST_WIDE_INT) high, low);
4103 pp_string (pp, pp_buffer (pp)->digit_buffer);