PR libstdc++/87308 adjust regex used in std::any pretty printer
[official-gcc.git] / gcc / tree-pretty-print.c
blob99eca4ae4043d3305a2745f46c4a7b1f225761b5
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2018 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*, unsigned);
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 /* Print a single expression T to string, and return it. */
167 char *
168 print_generic_expr_to_str (tree t)
170 pretty_printer pp;
171 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
172 return xstrdup (pp_formatted_text (&pp));
175 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
176 in it are replaced with Dxxxx, as long as they are at the start or
177 preceded by $ and at the end or followed by $. See make_fancy_name
178 in tree-sra.c. */
180 static void
181 dump_fancy_name (pretty_printer *pp, tree name)
183 int cnt = 0;
184 int length = IDENTIFIER_LENGTH (name);
185 const char *n = IDENTIFIER_POINTER (name);
188 n = strchr (n, 'D');
189 if (n == NULL)
190 break;
191 if (ISDIGIT (n[1])
192 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
194 int l = 2;
195 while (ISDIGIT (n[l]))
196 l++;
197 if (n[l] == '\0' || n[l] == '$')
199 cnt++;
200 length += 5 - l;
202 n += l;
204 else
205 n++;
207 while (1);
208 if (cnt == 0)
210 pp_tree_identifier (pp, name);
211 return;
214 char *str = XNEWVEC (char, length + 1);
215 char *p = str;
216 const char *q;
217 q = n = IDENTIFIER_POINTER (name);
220 q = strchr (q, 'D');
221 if (q == NULL)
222 break;
223 if (ISDIGIT (q[1])
224 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
226 int l = 2;
227 while (ISDIGIT (q[l]))
228 l++;
229 if (q[l] == '\0' || q[l] == '$')
231 memcpy (p, n, q - n);
232 memcpy (p + (q - n), "Dxxxx", 5);
233 p += (q - n) + 5;
234 n = q + l;
236 q += l;
238 else
239 q++;
241 while (1);
242 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
243 str[length] = '\0';
244 if (pp_translate_identifiers (pp))
246 const char *text = identifier_to_locale (str);
247 pp_append_text (pp, text, text + strlen (text));
249 else
250 pp_append_text (pp, str, str + length);
251 XDELETEVEC (str);
254 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
255 in FLAGS. */
257 static void
258 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
260 tree name = DECL_NAME (node);
261 if (name)
263 if ((flags & TDF_ASMNAME)
264 && HAS_DECL_ASSEMBLER_NAME_P (node)
265 && DECL_ASSEMBLER_NAME_SET_P (node))
266 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
267 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
268 -g might have created more fancy names and their indexes
269 could get out of sync. Usually those should be DECL_IGNORED_P
270 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
271 names, let's hope those never get out of sync after doing the
272 dump_fancy_name sanitization. */
273 else if ((flags & TDF_COMPARE_DEBUG)
274 && DECL_NAMELESS (node)
275 && DECL_IGNORED_P (node))
276 name = NULL_TREE;
277 /* For DECL_NAMELESS names look for embedded uids in the
278 names and sanitize them for TDF_NOUID. */
279 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
280 dump_fancy_name (pp, name);
281 else
282 pp_tree_identifier (pp, name);
284 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
285 if ((flags & TDF_UID) || name == NULL_TREE)
287 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
288 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
289 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
291 if (flags & TDF_NOUID)
292 pp_string (pp, "D#xxxx");
293 else
294 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
296 else
298 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
299 if (flags & TDF_NOUID)
300 pp_printf (pp, "%c.xxxx", c);
301 else
302 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
305 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
307 if (flags & TDF_NOUID)
308 pp_printf (pp, "ptD.xxxx");
309 else
310 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
314 /* Like the above, but used for pretty printing function calls. */
316 static void
317 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
319 if (CONVERT_EXPR_P (node))
320 node = TREE_OPERAND (node, 0);
321 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
322 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
323 else
324 dump_decl_name (pp, node, flags);
327 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
328 FLAGS are as in dump_generic_node. */
330 static void
331 dump_function_declaration (pretty_printer *pp, tree node,
332 int spc, dump_flags_t flags)
334 bool wrote_arg = false;
335 tree arg;
337 pp_space (pp);
338 pp_left_paren (pp);
340 /* Print the argument types. */
341 arg = TYPE_ARG_TYPES (node);
342 while (arg && arg != void_list_node && arg != error_mark_node)
344 if (wrote_arg)
346 pp_comma (pp);
347 pp_space (pp);
349 wrote_arg = true;
350 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
351 arg = TREE_CHAIN (arg);
354 /* Drop the trailing void_type_node if we had any previous argument. */
355 if (arg == void_list_node && !wrote_arg)
356 pp_string (pp, "void");
357 /* Properly dump vararg function types. */
358 else if (!arg && wrote_arg)
359 pp_string (pp, ", ...");
360 /* Avoid printing any arg for unprototyped functions. */
362 pp_right_paren (pp);
365 /* Dump the domain associated with an array. */
367 static void
368 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
370 pp_left_bracket (pp);
371 if (domain)
373 tree min = TYPE_MIN_VALUE (domain);
374 tree max = TYPE_MAX_VALUE (domain);
376 if (min && max
377 && integer_zerop (min)
378 && tree_fits_shwi_p (max))
379 pp_wide_integer (pp, tree_to_shwi (max) + 1);
380 else
382 if (min)
383 dump_generic_node (pp, min, spc, flags, false);
384 pp_colon (pp);
385 if (max)
386 dump_generic_node (pp, max, spc, flags, false);
389 else
390 pp_string (pp, "<unknown>");
391 pp_right_bracket (pp);
395 /* Dump OpenMP iterators ITER. */
397 static void
398 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
400 pp_string (pp, "iterator(");
401 for (tree it = iter; it; it = TREE_CHAIN (it))
403 if (it != iter)
404 pp_string (pp, ", ");
405 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
406 false);
407 pp_space (pp);
408 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
409 pp_equal (pp);
410 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
411 pp_colon (pp);
412 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
413 pp_colon (pp);
414 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
416 pp_right_paren (pp);
420 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
421 dump_generic_node. */
423 static void
424 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
426 const char *name;
428 switch (OMP_CLAUSE_CODE (clause))
430 case OMP_CLAUSE_PRIVATE:
431 name = "private";
432 goto print_remap;
433 case OMP_CLAUSE_SHARED:
434 name = "shared";
435 goto print_remap;
436 case OMP_CLAUSE_FIRSTPRIVATE:
437 name = "firstprivate";
438 goto print_remap;
439 case OMP_CLAUSE_LASTPRIVATE:
440 name = "lastprivate";
441 if (!OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
442 goto print_remap;
443 pp_string (pp, "lastprivate(conditional:");
444 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
445 spc, flags, false);
446 pp_right_paren (pp);
447 break;
448 case OMP_CLAUSE_COPYIN:
449 name = "copyin";
450 goto print_remap;
451 case OMP_CLAUSE_COPYPRIVATE:
452 name = "copyprivate";
453 goto print_remap;
454 case OMP_CLAUSE_UNIFORM:
455 name = "uniform";
456 goto print_remap;
457 case OMP_CLAUSE_USE_DEVICE_PTR:
458 name = "use_device_ptr";
459 goto print_remap;
460 case OMP_CLAUSE_IS_DEVICE_PTR:
461 name = "is_device_ptr";
462 goto print_remap;
463 case OMP_CLAUSE__LOOPTEMP_:
464 name = "_looptemp_";
465 goto print_remap;
466 case OMP_CLAUSE__REDUCTEMP_:
467 name = "_reductemp_";
468 goto print_remap;
469 case OMP_CLAUSE_TO_DECLARE:
470 name = "to";
471 goto print_remap;
472 case OMP_CLAUSE_LINK:
473 name = "link";
474 goto print_remap;
475 case OMP_CLAUSE_NONTEMPORAL:
476 name = "nontemporal";
477 goto print_remap;
478 print_remap:
479 pp_string (pp, name);
480 pp_left_paren (pp);
481 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
482 spc, flags, false);
483 pp_right_paren (pp);
484 break;
486 case OMP_CLAUSE_TASK_REDUCTION:
487 case OMP_CLAUSE_IN_REDUCTION:
488 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
489 ? "in_" : "task_");
490 /* FALLTHRU */
491 case OMP_CLAUSE_REDUCTION:
492 pp_string (pp, "reduction(");
493 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
495 if (OMP_CLAUSE_REDUCTION_TASK (clause))
496 pp_string (pp, "task,");
497 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
498 pp_string (pp, "inscan,");
500 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
502 pp_string (pp,
503 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
504 pp_colon (pp);
506 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
507 spc, flags, false);
508 pp_right_paren (pp);
509 break;
511 case OMP_CLAUSE_IF:
512 pp_string (pp, "if(");
513 switch (OMP_CLAUSE_IF_MODIFIER (clause))
515 case ERROR_MARK: break;
516 case VOID_CST: pp_string (pp, "cancel:"); break;
517 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
518 case OMP_SIMD: pp_string (pp, "simd:"); break;
519 case OMP_TASK: pp_string (pp, "task:"); break;
520 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
521 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
522 case OMP_TARGET: pp_string (pp, "target:"); break;
523 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
524 case OMP_TARGET_ENTER_DATA:
525 pp_string (pp, "target enter data:"); break;
526 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
527 default: gcc_unreachable ();
529 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
530 spc, flags, false);
531 pp_right_paren (pp);
532 break;
534 case OMP_CLAUSE_NUM_THREADS:
535 pp_string (pp, "num_threads(");
536 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
537 spc, flags, false);
538 pp_right_paren (pp);
539 break;
541 case OMP_CLAUSE_NOWAIT:
542 pp_string (pp, "nowait");
543 break;
544 case OMP_CLAUSE_ORDERED:
545 pp_string (pp, "ordered");
546 if (OMP_CLAUSE_ORDERED_EXPR (clause))
548 pp_left_paren (pp);
549 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
550 spc, flags, false);
551 pp_right_paren (pp);
553 break;
555 case OMP_CLAUSE_DEFAULT:
556 pp_string (pp, "default(");
557 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
559 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
560 break;
561 case OMP_CLAUSE_DEFAULT_SHARED:
562 pp_string (pp, "shared");
563 break;
564 case OMP_CLAUSE_DEFAULT_NONE:
565 pp_string (pp, "none");
566 break;
567 case OMP_CLAUSE_DEFAULT_PRIVATE:
568 pp_string (pp, "private");
569 break;
570 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
571 pp_string (pp, "firstprivate");
572 break;
573 case OMP_CLAUSE_DEFAULT_PRESENT:
574 pp_string (pp, "present");
575 break;
576 default:
577 gcc_unreachable ();
579 pp_right_paren (pp);
580 break;
582 case OMP_CLAUSE_SCHEDULE:
583 pp_string (pp, "schedule(");
584 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
585 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
586 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
588 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
589 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
590 pp_string (pp, "monotonic");
591 else
592 pp_string (pp, "nonmonotonic");
593 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
594 pp_comma (pp);
595 else
596 pp_colon (pp);
598 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
599 pp_string (pp, "simd:");
601 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
603 case OMP_CLAUSE_SCHEDULE_STATIC:
604 pp_string (pp, "static");
605 break;
606 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
607 pp_string (pp, "dynamic");
608 break;
609 case OMP_CLAUSE_SCHEDULE_GUIDED:
610 pp_string (pp, "guided");
611 break;
612 case OMP_CLAUSE_SCHEDULE_RUNTIME:
613 pp_string (pp, "runtime");
614 break;
615 case OMP_CLAUSE_SCHEDULE_AUTO:
616 pp_string (pp, "auto");
617 break;
618 default:
619 gcc_unreachable ();
621 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
623 pp_comma (pp);
624 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
625 spc, flags, false);
627 pp_right_paren (pp);
628 break;
630 case OMP_CLAUSE_UNTIED:
631 pp_string (pp, "untied");
632 break;
634 case OMP_CLAUSE_COLLAPSE:
635 pp_string (pp, "collapse(");
636 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
637 spc, flags, false);
638 pp_right_paren (pp);
639 break;
641 case OMP_CLAUSE_FINAL:
642 pp_string (pp, "final(");
643 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
644 spc, flags, false);
645 pp_right_paren (pp);
646 break;
648 case OMP_CLAUSE_MERGEABLE:
649 pp_string (pp, "mergeable");
650 break;
652 case OMP_CLAUSE_LINEAR:
653 pp_string (pp, "linear(");
654 switch (OMP_CLAUSE_LINEAR_KIND (clause))
656 case OMP_CLAUSE_LINEAR_DEFAULT:
657 break;
658 case OMP_CLAUSE_LINEAR_REF:
659 pp_string (pp, "ref(");
660 break;
661 case OMP_CLAUSE_LINEAR_VAL:
662 pp_string (pp, "val(");
663 break;
664 case OMP_CLAUSE_LINEAR_UVAL:
665 pp_string (pp, "uval(");
666 break;
667 default:
668 gcc_unreachable ();
670 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
671 spc, flags, false);
672 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
673 pp_right_paren (pp);
674 pp_colon (pp);
675 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
676 spc, flags, false);
677 pp_right_paren (pp);
678 break;
680 case OMP_CLAUSE_ALIGNED:
681 pp_string (pp, "aligned(");
682 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
683 spc, flags, false);
684 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
686 pp_colon (pp);
687 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
688 spc, flags, false);
690 pp_right_paren (pp);
691 break;
693 case OMP_CLAUSE_DEPEND:
694 pp_string (pp, "depend(");
695 switch (OMP_CLAUSE_DEPEND_KIND (clause))
697 case OMP_CLAUSE_DEPEND_DEPOBJ:
698 name = "depobj";
699 break;
700 case OMP_CLAUSE_DEPEND_IN:
701 name = "in";
702 break;
703 case OMP_CLAUSE_DEPEND_OUT:
704 name = "out";
705 break;
706 case OMP_CLAUSE_DEPEND_INOUT:
707 name = "inout";
708 break;
709 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
710 name = "mutexinoutset";
711 break;
712 case OMP_CLAUSE_DEPEND_SOURCE:
713 pp_string (pp, "source)");
714 return;
715 case OMP_CLAUSE_DEPEND_LAST:
716 name = "__internal__";
717 break;
718 case OMP_CLAUSE_DEPEND_SINK:
719 pp_string (pp, "sink:");
720 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
721 if (TREE_CODE (t) == TREE_LIST)
723 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
724 if (TREE_PURPOSE (t) != integer_zero_node)
726 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
727 pp_minus (pp);
728 else
729 pp_plus (pp);
730 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
731 false);
733 if (TREE_CHAIN (t))
734 pp_comma (pp);
736 else
737 gcc_unreachable ();
738 pp_right_paren (pp);
739 return;
740 default:
741 gcc_unreachable ();
744 tree t = OMP_CLAUSE_DECL (clause);
745 if (TREE_CODE (t) == TREE_LIST
746 && TREE_PURPOSE (t)
747 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
749 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
750 pp_colon (pp);
751 t = TREE_VALUE (t);
753 pp_string (pp, name);
754 pp_colon (pp);
755 dump_generic_node (pp, t, spc, flags, false);
756 pp_right_paren (pp);
758 break;
760 case OMP_CLAUSE_MAP:
761 pp_string (pp, "map(");
762 switch (OMP_CLAUSE_MAP_KIND (clause))
764 case GOMP_MAP_ALLOC:
765 case GOMP_MAP_POINTER:
766 pp_string (pp, "alloc");
767 break;
768 case GOMP_MAP_TO:
769 case GOMP_MAP_TO_PSET:
770 pp_string (pp, "to");
771 break;
772 case GOMP_MAP_FROM:
773 pp_string (pp, "from");
774 break;
775 case GOMP_MAP_TOFROM:
776 pp_string (pp, "tofrom");
777 break;
778 case GOMP_MAP_FORCE_ALLOC:
779 pp_string (pp, "force_alloc");
780 break;
781 case GOMP_MAP_FORCE_TO:
782 pp_string (pp, "force_to");
783 break;
784 case GOMP_MAP_FORCE_FROM:
785 pp_string (pp, "force_from");
786 break;
787 case GOMP_MAP_FORCE_TOFROM:
788 pp_string (pp, "force_tofrom");
789 break;
790 case GOMP_MAP_FORCE_PRESENT:
791 pp_string (pp, "force_present");
792 break;
793 case GOMP_MAP_DELETE:
794 pp_string (pp, "delete");
795 break;
796 case GOMP_MAP_FORCE_DEVICEPTR:
797 pp_string (pp, "force_deviceptr");
798 break;
799 case GOMP_MAP_ALWAYS_TO:
800 pp_string (pp, "always,to");
801 break;
802 case GOMP_MAP_ALWAYS_FROM:
803 pp_string (pp, "always,from");
804 break;
805 case GOMP_MAP_ALWAYS_TOFROM:
806 pp_string (pp, "always,tofrom");
807 break;
808 case GOMP_MAP_RELEASE:
809 pp_string (pp, "release");
810 break;
811 case GOMP_MAP_FIRSTPRIVATE_POINTER:
812 pp_string (pp, "firstprivate");
813 break;
814 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
815 pp_string (pp, "firstprivate ref");
816 break;
817 case GOMP_MAP_STRUCT:
818 pp_string (pp, "struct");
819 break;
820 case GOMP_MAP_ALWAYS_POINTER:
821 pp_string (pp, "always_pointer");
822 break;
823 case GOMP_MAP_DEVICE_RESIDENT:
824 pp_string (pp, "device_resident");
825 break;
826 case GOMP_MAP_LINK:
827 pp_string (pp, "link");
828 break;
829 default:
830 gcc_unreachable ();
832 pp_colon (pp);
833 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
834 spc, flags, false);
835 print_clause_size:
836 if (OMP_CLAUSE_SIZE (clause))
838 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
839 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
841 case GOMP_MAP_POINTER:
842 case GOMP_MAP_FIRSTPRIVATE_POINTER:
843 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
844 case GOMP_MAP_ALWAYS_POINTER:
845 pp_string (pp, " [pointer assign, bias: ");
846 break;
847 case GOMP_MAP_TO_PSET:
848 pp_string (pp, " [pointer set, len: ");
849 break;
850 default:
851 pp_string (pp, " [len: ");
852 break;
854 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
855 spc, flags, false);
856 pp_right_bracket (pp);
858 pp_right_paren (pp);
859 break;
861 case OMP_CLAUSE_FROM:
862 pp_string (pp, "from(");
863 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
864 spc, flags, false);
865 goto print_clause_size;
867 case OMP_CLAUSE_TO:
868 pp_string (pp, "to(");
869 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
870 spc, flags, false);
871 goto print_clause_size;
873 case OMP_CLAUSE__CACHE_:
874 pp_string (pp, "(");
875 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
876 spc, flags, false);
877 goto print_clause_size;
879 case OMP_CLAUSE_NUM_TEAMS:
880 pp_string (pp, "num_teams(");
881 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
882 spc, flags, false);
883 pp_right_paren (pp);
884 break;
886 case OMP_CLAUSE_THREAD_LIMIT:
887 pp_string (pp, "thread_limit(");
888 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
889 spc, flags, false);
890 pp_right_paren (pp);
891 break;
893 case OMP_CLAUSE_DEVICE:
894 pp_string (pp, "device(");
895 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
896 spc, flags, false);
897 pp_right_paren (pp);
898 break;
900 case OMP_CLAUSE_DIST_SCHEDULE:
901 pp_string (pp, "dist_schedule(static");
902 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
904 pp_comma (pp);
905 dump_generic_node (pp,
906 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
907 spc, flags, false);
909 pp_right_paren (pp);
910 break;
912 case OMP_CLAUSE_PROC_BIND:
913 pp_string (pp, "proc_bind(");
914 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
916 case OMP_CLAUSE_PROC_BIND_MASTER:
917 pp_string (pp, "master");
918 break;
919 case OMP_CLAUSE_PROC_BIND_CLOSE:
920 pp_string (pp, "close");
921 break;
922 case OMP_CLAUSE_PROC_BIND_SPREAD:
923 pp_string (pp, "spread");
924 break;
925 default:
926 gcc_unreachable ();
928 pp_right_paren (pp);
929 break;
931 case OMP_CLAUSE_SAFELEN:
932 pp_string (pp, "safelen(");
933 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
934 spc, flags, false);
935 pp_right_paren (pp);
936 break;
938 case OMP_CLAUSE_SIMDLEN:
939 pp_string (pp, "simdlen(");
940 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
941 spc, flags, false);
942 pp_right_paren (pp);
943 break;
945 case OMP_CLAUSE_PRIORITY:
946 pp_string (pp, "priority(");
947 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
948 spc, flags, false);
949 pp_right_paren (pp);
950 break;
952 case OMP_CLAUSE_GRAINSIZE:
953 pp_string (pp, "grainsize(");
954 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
955 spc, flags, false);
956 pp_right_paren (pp);
957 break;
959 case OMP_CLAUSE_NUM_TASKS:
960 pp_string (pp, "num_tasks(");
961 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
962 spc, flags, false);
963 pp_right_paren (pp);
964 break;
966 case OMP_CLAUSE_HINT:
967 pp_string (pp, "hint(");
968 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
969 spc, flags, false);
970 pp_right_paren (pp);
971 break;
973 case OMP_CLAUSE_DEFAULTMAP:
974 pp_string (pp, "defaultmap(");
975 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
977 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
978 pp_string (pp, "alloc");
979 break;
980 case OMP_CLAUSE_DEFAULTMAP_TO:
981 pp_string (pp, "to");
982 break;
983 case OMP_CLAUSE_DEFAULTMAP_FROM:
984 pp_string (pp, "from");
985 break;
986 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
987 pp_string (pp, "tofrom");
988 break;
989 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
990 pp_string (pp, "firstprivate");
991 break;
992 case OMP_CLAUSE_DEFAULTMAP_NONE:
993 pp_string (pp, "none");
994 break;
995 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
996 pp_string (pp, "default");
997 break;
998 default:
999 gcc_unreachable ();
1001 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1003 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1004 break;
1005 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1006 pp_string (pp, ":scalar");
1007 break;
1008 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1009 pp_string (pp, ":aggregate");
1010 break;
1011 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1012 pp_string (pp, ":allocatable");
1013 break;
1014 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1015 pp_string (pp, ":pointer");
1016 break;
1017 default:
1018 gcc_unreachable ();
1020 pp_right_paren (pp);
1021 break;
1023 case OMP_CLAUSE__SIMDUID_:
1024 pp_string (pp, "_simduid_(");
1025 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1026 spc, flags, false);
1027 pp_right_paren (pp);
1028 break;
1030 case OMP_CLAUSE__SIMT_:
1031 pp_string (pp, "_simt_");
1032 break;
1034 case OMP_CLAUSE_GANG:
1035 pp_string (pp, "gang");
1036 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1038 pp_string (pp, "(num: ");
1039 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1040 spc, flags, false);
1042 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1044 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1045 pp_left_paren (pp);
1046 else
1047 pp_space (pp);
1048 pp_string (pp, "static:");
1049 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1050 == integer_minus_one_node)
1051 pp_character (pp, '*');
1052 else
1053 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1054 spc, flags, false);
1056 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1057 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1058 pp_right_paren (pp);
1059 break;
1061 case OMP_CLAUSE_ASYNC:
1062 pp_string (pp, "async");
1063 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1065 pp_character(pp, '(');
1066 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1067 spc, flags, false);
1068 pp_character(pp, ')');
1070 break;
1072 case OMP_CLAUSE_AUTO:
1073 case OMP_CLAUSE_SEQ:
1074 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1075 break;
1077 case OMP_CLAUSE_WAIT:
1078 pp_string (pp, "wait(");
1079 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1080 spc, flags, false);
1081 pp_character(pp, ')');
1082 break;
1084 case OMP_CLAUSE_WORKER:
1085 pp_string (pp, "worker");
1086 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1088 pp_left_paren (pp);
1089 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1090 spc, flags, false);
1091 pp_right_paren (pp);
1093 break;
1095 case OMP_CLAUSE_VECTOR:
1096 pp_string (pp, "vector");
1097 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1099 pp_left_paren (pp);
1100 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1101 spc, flags, false);
1102 pp_right_paren (pp);
1104 break;
1106 case OMP_CLAUSE_NUM_GANGS:
1107 pp_string (pp, "num_gangs(");
1108 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1109 spc, flags, false);
1110 pp_character (pp, ')');
1111 break;
1113 case OMP_CLAUSE_NUM_WORKERS:
1114 pp_string (pp, "num_workers(");
1115 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1116 spc, flags, false);
1117 pp_character (pp, ')');
1118 break;
1120 case OMP_CLAUSE_VECTOR_LENGTH:
1121 pp_string (pp, "vector_length(");
1122 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1123 spc, flags, false);
1124 pp_character (pp, ')');
1125 break;
1127 case OMP_CLAUSE_INBRANCH:
1128 pp_string (pp, "inbranch");
1129 break;
1130 case OMP_CLAUSE_NOTINBRANCH:
1131 pp_string (pp, "notinbranch");
1132 break;
1133 case OMP_CLAUSE_FOR:
1134 pp_string (pp, "for");
1135 break;
1136 case OMP_CLAUSE_PARALLEL:
1137 pp_string (pp, "parallel");
1138 break;
1139 case OMP_CLAUSE_SECTIONS:
1140 pp_string (pp, "sections");
1141 break;
1142 case OMP_CLAUSE_TASKGROUP:
1143 pp_string (pp, "taskgroup");
1144 break;
1145 case OMP_CLAUSE_NOGROUP:
1146 pp_string (pp, "nogroup");
1147 break;
1148 case OMP_CLAUSE_THREADS:
1149 pp_string (pp, "threads");
1150 break;
1151 case OMP_CLAUSE_SIMD:
1152 pp_string (pp, "simd");
1153 break;
1154 case OMP_CLAUSE_INDEPENDENT:
1155 pp_string (pp, "independent");
1156 break;
1157 case OMP_CLAUSE_TILE:
1158 pp_string (pp, "tile(");
1159 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1160 spc, flags, false);
1161 pp_right_paren (pp);
1162 break;
1164 case OMP_CLAUSE__GRIDDIM_:
1165 pp_string (pp, "_griddim_(");
1166 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1167 pp_colon (pp);
1168 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1169 false);
1170 pp_comma (pp);
1171 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1172 false);
1173 pp_right_paren (pp);
1174 break;
1175 case OMP_CLAUSE_IF_PRESENT:
1176 pp_string (pp, "if_present");
1177 break;
1178 case OMP_CLAUSE_FINALIZE:
1179 pp_string (pp, "finalize");
1180 break;
1182 default:
1183 /* Should never happen. */
1184 dump_generic_node (pp, clause, spc, flags, false);
1185 break;
1190 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1191 dump_generic_node. */
1193 void
1194 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1196 if (clause == NULL)
1197 return;
1199 pp_space (pp);
1200 while (1)
1202 dump_omp_clause (pp, clause, spc, flags);
1203 clause = OMP_CLAUSE_CHAIN (clause);
1204 if (clause == NULL)
1205 return;
1206 pp_space (pp);
1211 /* Dump location LOC to PP. */
1213 void
1214 dump_location (pretty_printer *pp, location_t loc)
1216 expanded_location xloc = expand_location (loc);
1218 pp_left_bracket (pp);
1219 if (xloc.file)
1221 pp_string (pp, xloc.file);
1222 pp_string (pp, ":");
1224 pp_decimal_int (pp, xloc.line);
1225 pp_colon (pp);
1226 pp_decimal_int (pp, xloc.column);
1227 pp_string (pp, "] ");
1231 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1232 dump_generic_node. */
1234 static void
1235 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1237 tree t;
1239 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1241 if (flags & TDF_ADDRESS)
1242 pp_printf (pp, "[%p] ", (void *) block);
1244 if (TREE_ASM_WRITTEN (block))
1245 pp_string (pp, "[written] ");
1247 if (flags & TDF_SLIM)
1248 return;
1250 if (BLOCK_SOURCE_LOCATION (block))
1251 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1253 newline_and_indent (pp, spc + 2);
1255 if (BLOCK_SUPERCONTEXT (block))
1257 pp_string (pp, "SUPERCONTEXT: ");
1258 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1259 flags | TDF_SLIM, false);
1260 newline_and_indent (pp, spc + 2);
1263 if (BLOCK_SUBBLOCKS (block))
1265 pp_string (pp, "SUBBLOCKS: ");
1266 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1268 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1269 pp_space (pp);
1271 newline_and_indent (pp, spc + 2);
1274 if (BLOCK_CHAIN (block))
1276 pp_string (pp, "SIBLINGS: ");
1277 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1279 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1280 pp_space (pp);
1282 newline_and_indent (pp, spc + 2);
1285 if (BLOCK_VARS (block))
1287 pp_string (pp, "VARS: ");
1288 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1290 dump_generic_node (pp, t, 0, flags, false);
1291 pp_space (pp);
1293 newline_and_indent (pp, spc + 2);
1296 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1298 unsigned i;
1299 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1301 pp_string (pp, "NONLOCALIZED_VARS: ");
1302 FOR_EACH_VEC_ELT (*nlv, i, t)
1304 dump_generic_node (pp, t, 0, flags, false);
1305 pp_space (pp);
1307 newline_and_indent (pp, spc + 2);
1310 if (BLOCK_ABSTRACT_ORIGIN (block))
1312 pp_string (pp, "ABSTRACT_ORIGIN: ");
1313 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1314 flags | TDF_SLIM, false);
1315 newline_and_indent (pp, spc + 2);
1318 if (BLOCK_FRAGMENT_ORIGIN (block))
1320 pp_string (pp, "FRAGMENT_ORIGIN: ");
1321 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1322 flags | TDF_SLIM, false);
1323 newline_and_indent (pp, spc + 2);
1326 if (BLOCK_FRAGMENT_CHAIN (block))
1328 pp_string (pp, "FRAGMENT_CHAIN: ");
1329 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1331 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1332 pp_space (pp);
1334 newline_and_indent (pp, spc + 2);
1338 /* Dump #pragma omp atomic memory order clause. */
1340 void
1341 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1343 switch (mo)
1345 case OMP_MEMORY_ORDER_RELAXED:
1346 pp_string (pp, " relaxed");
1347 break;
1348 case OMP_MEMORY_ORDER_SEQ_CST:
1349 pp_string (pp, " seq_cst");
1350 break;
1351 case OMP_MEMORY_ORDER_ACQ_REL:
1352 pp_string (pp, " acq_rel");
1353 break;
1354 case OMP_MEMORY_ORDER_ACQUIRE:
1355 pp_string (pp, " acquire");
1356 break;
1357 case OMP_MEMORY_ORDER_RELEASE:
1358 pp_string (pp, " release");
1359 break;
1360 case OMP_MEMORY_ORDER_UNSPECIFIED:
1361 break;
1362 default:
1363 gcc_unreachable ();
1367 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1368 indent. FLAGS specifies details to show in the dump (see TDF_* in
1369 dumpfile.h). If IS_STMT is true, the object printed is considered
1370 to be a statement and it is terminated by ';' if appropriate. */
1373 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1374 bool is_stmt)
1376 tree type;
1377 tree op0, op1;
1378 const char *str;
1379 bool is_expr;
1380 enum tree_code code;
1382 if (node == NULL_TREE)
1383 return spc;
1385 is_expr = EXPR_P (node);
1387 if (is_stmt && (flags & TDF_STMTADDR))
1388 pp_printf (pp, "<&%p> ", (void *)node);
1390 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1391 dump_location (pp, EXPR_LOCATION (node));
1393 code = TREE_CODE (node);
1394 switch (code)
1396 case ERROR_MARK:
1397 pp_string (pp, "<<< error >>>");
1398 break;
1400 case IDENTIFIER_NODE:
1401 pp_tree_identifier (pp, node);
1402 break;
1404 case TREE_LIST:
1405 while (node && node != error_mark_node)
1407 if (TREE_PURPOSE (node))
1409 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1410 pp_space (pp);
1412 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1413 node = TREE_CHAIN (node);
1414 if (node && TREE_CODE (node) == TREE_LIST)
1416 pp_comma (pp);
1417 pp_space (pp);
1420 break;
1422 case TREE_BINFO:
1423 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1424 break;
1426 case TREE_VEC:
1428 size_t i;
1429 if (TREE_VEC_LENGTH (node) > 0)
1431 size_t len = TREE_VEC_LENGTH (node);
1432 for (i = 0; i < len - 1; i++)
1434 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1435 false);
1436 pp_comma (pp);
1437 pp_space (pp);
1439 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1440 flags, false);
1443 break;
1445 case VOID_TYPE:
1446 case INTEGER_TYPE:
1447 case REAL_TYPE:
1448 case FIXED_POINT_TYPE:
1449 case COMPLEX_TYPE:
1450 case VECTOR_TYPE:
1451 case ENUMERAL_TYPE:
1452 case BOOLEAN_TYPE:
1454 unsigned int quals = TYPE_QUALS (node);
1455 enum tree_code_class tclass;
1457 if (quals & TYPE_QUAL_ATOMIC)
1458 pp_string (pp, "atomic ");
1459 if (quals & TYPE_QUAL_CONST)
1460 pp_string (pp, "const ");
1461 else if (quals & TYPE_QUAL_VOLATILE)
1462 pp_string (pp, "volatile ");
1463 else if (quals & TYPE_QUAL_RESTRICT)
1464 pp_string (pp, "restrict ");
1466 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1468 pp_string (pp, "<address-space-");
1469 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1470 pp_string (pp, "> ");
1473 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1475 if (tclass == tcc_declaration)
1477 if (DECL_NAME (node))
1478 dump_decl_name (pp, node, flags);
1479 else
1480 pp_string (pp, "<unnamed type decl>");
1482 else if (tclass == tcc_type)
1484 if (TYPE_NAME (node))
1486 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1487 pp_tree_identifier (pp, TYPE_NAME (node));
1488 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1489 && DECL_NAME (TYPE_NAME (node)))
1490 dump_decl_name (pp, TYPE_NAME (node), flags);
1491 else
1492 pp_string (pp, "<unnamed type>");
1494 else if (TREE_CODE (node) == VECTOR_TYPE)
1496 pp_string (pp, "vector");
1497 pp_left_paren (pp);
1498 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1499 pp_string (pp, ") ");
1500 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1502 else if (TREE_CODE (node) == INTEGER_TYPE)
1504 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1505 pp_string (pp, (TYPE_UNSIGNED (node)
1506 ? "unsigned char"
1507 : "signed char"));
1508 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1509 pp_string (pp, (TYPE_UNSIGNED (node)
1510 ? "unsigned short"
1511 : "signed short"));
1512 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1513 pp_string (pp, (TYPE_UNSIGNED (node)
1514 ? "unsigned int"
1515 : "signed int"));
1516 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1517 pp_string (pp, (TYPE_UNSIGNED (node)
1518 ? "unsigned long"
1519 : "signed long"));
1520 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1521 pp_string (pp, (TYPE_UNSIGNED (node)
1522 ? "unsigned long long"
1523 : "signed long long"));
1524 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1525 && pow2p_hwi (TYPE_PRECISION (node)))
1527 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1528 pp_decimal_int (pp, TYPE_PRECISION (node));
1529 pp_string (pp, "_t");
1531 else
1533 pp_string (pp, (TYPE_UNSIGNED (node)
1534 ? "<unnamed-unsigned:"
1535 : "<unnamed-signed:"));
1536 pp_decimal_int (pp, TYPE_PRECISION (node));
1537 pp_greater (pp);
1540 else if (TREE_CODE (node) == COMPLEX_TYPE)
1542 pp_string (pp, "__complex__ ");
1543 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1545 else if (TREE_CODE (node) == REAL_TYPE)
1547 pp_string (pp, "<float:");
1548 pp_decimal_int (pp, TYPE_PRECISION (node));
1549 pp_greater (pp);
1551 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1553 pp_string (pp, "<fixed-point-");
1554 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1555 pp_decimal_int (pp, TYPE_PRECISION (node));
1556 pp_greater (pp);
1558 else if (TREE_CODE (node) == VOID_TYPE)
1559 pp_string (pp, "void");
1560 else
1561 pp_string (pp, "<unnamed type>");
1563 break;
1566 case POINTER_TYPE:
1567 case REFERENCE_TYPE:
1568 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1570 if (TREE_TYPE (node) == NULL)
1572 pp_string (pp, str);
1573 pp_string (pp, "<null type>");
1575 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1577 tree fnode = TREE_TYPE (node);
1579 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1580 pp_space (pp);
1581 pp_left_paren (pp);
1582 pp_string (pp, str);
1583 if (TYPE_IDENTIFIER (node))
1584 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1585 else if (flags & TDF_NOUID)
1586 pp_printf (pp, "<Txxxx>");
1587 else
1588 pp_printf (pp, "<T%x>", TYPE_UID (node));
1590 pp_right_paren (pp);
1591 dump_function_declaration (pp, fnode, spc, flags);
1593 else
1595 unsigned int quals = TYPE_QUALS (node);
1597 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1598 pp_space (pp);
1599 pp_string (pp, str);
1601 if (quals & TYPE_QUAL_CONST)
1602 pp_string (pp, " const");
1603 if (quals & TYPE_QUAL_VOLATILE)
1604 pp_string (pp, " volatile");
1605 if (quals & TYPE_QUAL_RESTRICT)
1606 pp_string (pp, " restrict");
1608 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1610 pp_string (pp, " <address-space-");
1611 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1612 pp_greater (pp);
1615 if (TYPE_REF_CAN_ALIAS_ALL (node))
1616 pp_string (pp, " {ref-all}");
1618 break;
1620 case OFFSET_TYPE:
1621 NIY;
1622 break;
1624 case MEM_REF:
1626 if (flags & TDF_GIMPLE)
1628 pp_string (pp, "__MEM <");
1629 dump_generic_node (pp, TREE_TYPE (node),
1630 spc, flags | TDF_SLIM, false);
1631 if (TYPE_ALIGN (TREE_TYPE (node))
1632 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1634 pp_string (pp, ", ");
1635 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1637 pp_greater (pp);
1638 pp_string (pp, " (");
1639 if (TREE_TYPE (TREE_OPERAND (node, 0))
1640 != TREE_TYPE (TREE_OPERAND (node, 1)))
1642 pp_left_paren (pp);
1643 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1644 spc, flags | TDF_SLIM, false);
1645 pp_right_paren (pp);
1647 dump_generic_node (pp, TREE_OPERAND (node, 0),
1648 spc, flags | TDF_SLIM, false);
1649 if (! integer_zerop (TREE_OPERAND (node, 1)))
1651 pp_string (pp, " + ");
1652 dump_generic_node (pp, TREE_OPERAND (node, 1),
1653 spc, flags | TDF_SLIM, false);
1655 pp_right_paren (pp);
1657 else if (integer_zerop (TREE_OPERAND (node, 1))
1658 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1659 infer them and MEM_ATTR caching will share MEM_REFs
1660 with differently-typed op0s. */
1661 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1662 /* Released SSA_NAMES have no TREE_TYPE. */
1663 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1664 /* Same pointer types, but ignoring POINTER_TYPE vs.
1665 REFERENCE_TYPE. */
1666 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1667 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1668 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1669 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1670 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1671 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1672 /* Same value types ignoring qualifiers. */
1673 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1674 == TYPE_MAIN_VARIANT
1675 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1676 && (!(flags & TDF_ALIAS)
1677 || MR_DEPENDENCE_CLIQUE (node) == 0))
1679 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1681 pp_star (pp);
1682 dump_generic_node (pp, TREE_OPERAND (node, 0),
1683 spc, flags, false);
1685 else
1686 dump_generic_node (pp,
1687 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1688 spc, flags, false);
1690 else
1692 tree ptype;
1694 pp_string (pp, "MEM[");
1695 pp_left_paren (pp);
1696 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1697 dump_generic_node (pp, ptype,
1698 spc, flags | TDF_SLIM, false);
1699 pp_right_paren (pp);
1700 dump_generic_node (pp, TREE_OPERAND (node, 0),
1701 spc, flags, false);
1702 if (!integer_zerop (TREE_OPERAND (node, 1)))
1704 pp_string (pp, " + ");
1705 dump_generic_node (pp, TREE_OPERAND (node, 1),
1706 spc, flags, false);
1708 if ((flags & TDF_ALIAS)
1709 && MR_DEPENDENCE_CLIQUE (node) != 0)
1711 pp_string (pp, " clique ");
1712 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1713 pp_string (pp, " base ");
1714 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1716 pp_right_bracket (pp);
1718 break;
1721 case TARGET_MEM_REF:
1723 const char *sep = "";
1724 tree tmp;
1726 pp_string (pp, "MEM[");
1728 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1730 pp_string (pp, sep);
1731 sep = ", ";
1732 pp_string (pp, "symbol: ");
1733 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1734 spc, flags, false);
1736 else
1738 pp_string (pp, sep);
1739 sep = ", ";
1740 pp_string (pp, "base: ");
1741 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1743 tmp = TMR_INDEX2 (node);
1744 if (tmp)
1746 pp_string (pp, sep);
1747 sep = ", ";
1748 pp_string (pp, "base: ");
1749 dump_generic_node (pp, tmp, spc, flags, false);
1751 tmp = TMR_INDEX (node);
1752 if (tmp)
1754 pp_string (pp, sep);
1755 sep = ", ";
1756 pp_string (pp, "index: ");
1757 dump_generic_node (pp, tmp, spc, flags, false);
1759 tmp = TMR_STEP (node);
1760 if (tmp)
1762 pp_string (pp, sep);
1763 sep = ", ";
1764 pp_string (pp, "step: ");
1765 dump_generic_node (pp, tmp, spc, flags, false);
1767 tmp = TMR_OFFSET (node);
1768 if (tmp)
1770 pp_string (pp, sep);
1771 sep = ", ";
1772 pp_string (pp, "offset: ");
1773 dump_generic_node (pp, tmp, spc, flags, false);
1775 pp_right_bracket (pp);
1777 break;
1779 case ARRAY_TYPE:
1781 tree tmp;
1783 /* Print the innermost component type. */
1784 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1785 tmp = TREE_TYPE (tmp))
1787 dump_generic_node (pp, tmp, spc, flags, false);
1789 /* Print the dimensions. */
1790 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1791 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1792 break;
1795 case RECORD_TYPE:
1796 case UNION_TYPE:
1797 case QUAL_UNION_TYPE:
1799 unsigned int quals = TYPE_QUALS (node);
1801 if (quals & TYPE_QUAL_ATOMIC)
1802 pp_string (pp, "atomic ");
1803 if (quals & TYPE_QUAL_CONST)
1804 pp_string (pp, "const ");
1805 if (quals & TYPE_QUAL_VOLATILE)
1806 pp_string (pp, "volatile ");
1808 /* Print the name of the structure. */
1809 if (TREE_CODE (node) == RECORD_TYPE)
1810 pp_string (pp, "struct ");
1811 else if (TREE_CODE (node) == UNION_TYPE)
1812 pp_string (pp, "union ");
1814 if (TYPE_NAME (node))
1815 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1816 else if (!(flags & TDF_SLIM))
1817 /* FIXME: If we eliminate the 'else' above and attempt
1818 to show the fields for named types, we may get stuck
1819 following a cycle of pointers to structs. The alleged
1820 self-reference check in print_struct_decl will not detect
1821 cycles involving more than one pointer or struct type. */
1822 print_struct_decl (pp, node, spc, flags);
1823 break;
1826 case LANG_TYPE:
1827 NIY;
1828 break;
1830 case INTEGER_CST:
1831 if (flags & TDF_GIMPLE
1832 && (POINTER_TYPE_P (TREE_TYPE (node))
1833 || (TYPE_PRECISION (TREE_TYPE (node))
1834 < TYPE_PRECISION (integer_type_node))
1835 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1837 pp_string (pp, "_Literal (");
1838 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1839 pp_string (pp, ") ");
1841 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1842 && ! (flags & TDF_GIMPLE))
1844 /* In the case of a pointer, one may want to divide by the
1845 size of the pointed-to type. Unfortunately, this not
1846 straightforward. The C front-end maps expressions
1848 (int *) 5
1849 int *p; (p + 5)
1851 in such a way that the two INTEGER_CST nodes for "5" have
1852 different values but identical types. In the latter
1853 case, the 5 is multiplied by sizeof (int) in c-common.c
1854 (pointer_int_sum) to convert it to a byte address, and
1855 yet the type of the node is left unchanged. Argh. What
1856 is consistent though is that the number value corresponds
1857 to bytes (UNITS) offset.
1859 NB: Neither of the following divisors can be trivially
1860 used to recover the original literal:
1862 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1863 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1864 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1865 pp_string (pp, "B"); /* pseudo-unit */
1867 else if (tree_fits_shwi_p (node))
1868 pp_wide_integer (pp, tree_to_shwi (node));
1869 else if (tree_fits_uhwi_p (node))
1870 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1871 else
1873 wide_int val = wi::to_wide (node);
1875 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1877 pp_minus (pp);
1878 val = -val;
1880 print_hex (val, pp_buffer (pp)->digit_buffer);
1881 pp_string (pp, pp_buffer (pp)->digit_buffer);
1883 if ((flags & TDF_GIMPLE)
1884 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1885 || (TYPE_PRECISION (TREE_TYPE (node))
1886 < TYPE_PRECISION (integer_type_node))
1887 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1889 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1890 pp_character (pp, 'u');
1891 if (TYPE_PRECISION (TREE_TYPE (node))
1892 == TYPE_PRECISION (unsigned_type_node))
1894 else if (TYPE_PRECISION (TREE_TYPE (node))
1895 == TYPE_PRECISION (long_unsigned_type_node))
1896 pp_character (pp, 'l');
1897 else if (TYPE_PRECISION (TREE_TYPE (node))
1898 == TYPE_PRECISION (long_long_unsigned_type_node))
1899 pp_string (pp, "ll");
1901 if (TREE_OVERFLOW (node))
1902 pp_string (pp, "(OVF)");
1903 break;
1905 case POLY_INT_CST:
1906 pp_string (pp, "POLY_INT_CST [");
1907 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
1908 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
1910 pp_string (pp, ", ");
1911 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
1912 spc, flags, false);
1914 pp_string (pp, "]");
1915 break;
1917 case REAL_CST:
1918 /* Code copied from print_node. */
1920 REAL_VALUE_TYPE d;
1921 if (TREE_OVERFLOW (node))
1922 pp_string (pp, " overflow");
1924 d = TREE_REAL_CST (node);
1925 if (REAL_VALUE_ISINF (d))
1926 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1927 else if (REAL_VALUE_ISNAN (d))
1928 pp_string (pp, " Nan");
1929 else
1931 char string[100];
1932 real_to_decimal (string, &d, sizeof (string), 0, 1);
1933 pp_string (pp, string);
1935 break;
1938 case FIXED_CST:
1940 char string[100];
1941 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1942 pp_string (pp, string);
1943 break;
1946 case COMPLEX_CST:
1947 pp_string (pp, "__complex__ (");
1948 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1949 pp_string (pp, ", ");
1950 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1951 pp_right_paren (pp);
1952 break;
1954 case STRING_CST:
1956 pp_string (pp, "\"");
1957 if (unsigned nbytes = TREE_STRING_LENGTH (node))
1958 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
1959 pp_string (pp, "\"");
1960 break;
1963 case VECTOR_CST:
1965 unsigned i;
1966 pp_string (pp, "{ ");
1967 unsigned HOST_WIDE_INT nunits;
1968 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
1969 nunits = vector_cst_encoded_nelts (node);
1970 for (i = 0; i < nunits; ++i)
1972 if (i != 0)
1973 pp_string (pp, ", ");
1974 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1975 spc, flags, false);
1977 if (!VECTOR_CST_NELTS (node).is_constant ())
1978 pp_string (pp, ", ...");
1979 pp_string (pp, " }");
1981 break;
1983 case FUNCTION_TYPE:
1984 case METHOD_TYPE:
1985 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1986 pp_space (pp);
1987 if (TREE_CODE (node) == METHOD_TYPE)
1989 if (TYPE_METHOD_BASETYPE (node))
1990 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1991 spc, flags, false);
1992 else
1993 pp_string (pp, "<null method basetype>");
1994 pp_colon_colon (pp);
1996 if (TYPE_IDENTIFIER (node))
1997 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1998 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1999 dump_decl_name (pp, TYPE_NAME (node), flags);
2000 else if (flags & TDF_NOUID)
2001 pp_printf (pp, "<Txxxx>");
2002 else
2003 pp_printf (pp, "<T%x>", TYPE_UID (node));
2004 dump_function_declaration (pp, node, spc, flags);
2005 break;
2007 case FUNCTION_DECL:
2008 case CONST_DECL:
2009 dump_decl_name (pp, node, flags);
2010 break;
2012 case LABEL_DECL:
2013 if (DECL_NAME (node))
2014 dump_decl_name (pp, node, flags);
2015 else if (LABEL_DECL_UID (node) != -1)
2017 if (flags & TDF_GIMPLE)
2018 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
2019 else
2020 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
2022 else
2024 if (flags & TDF_NOUID)
2025 pp_string (pp, "<D.xxxx>");
2026 else
2028 if (flags & TDF_GIMPLE)
2029 pp_printf (pp, "<D%u>", DECL_UID (node));
2030 else
2031 pp_printf (pp, "<D.%u>", DECL_UID (node));
2034 break;
2036 case TYPE_DECL:
2037 if (DECL_IS_BUILTIN (node))
2039 /* Don't print the declaration of built-in types. */
2040 break;
2042 if (DECL_NAME (node))
2043 dump_decl_name (pp, node, flags);
2044 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2046 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2047 ? "union" : "struct "));
2048 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2050 else
2051 pp_string (pp, "<anon>");
2052 break;
2054 case VAR_DECL:
2055 case PARM_DECL:
2056 case FIELD_DECL:
2057 case DEBUG_EXPR_DECL:
2058 case NAMESPACE_DECL:
2059 case NAMELIST_DECL:
2060 dump_decl_name (pp, node, flags);
2061 break;
2063 case RESULT_DECL:
2064 pp_string (pp, "<retval>");
2065 break;
2067 case COMPONENT_REF:
2068 op0 = TREE_OPERAND (node, 0);
2069 str = ".";
2070 if (op0
2071 && (TREE_CODE (op0) == INDIRECT_REF
2072 || (TREE_CODE (op0) == MEM_REF
2073 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2074 && integer_zerop (TREE_OPERAND (op0, 1))
2075 /* Dump the types of INTEGER_CSTs explicitly, for we
2076 can't infer them and MEM_ATTR caching will share
2077 MEM_REFs with differently-typed op0s. */
2078 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2079 /* Released SSA_NAMES have no TREE_TYPE. */
2080 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2081 /* Same pointer types, but ignoring POINTER_TYPE vs.
2082 REFERENCE_TYPE. */
2083 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2084 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2085 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2086 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2087 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2088 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2089 /* Same value types ignoring qualifiers. */
2090 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2091 == TYPE_MAIN_VARIANT
2092 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2093 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2095 op0 = TREE_OPERAND (op0, 0);
2096 str = "->";
2098 if (op_prio (op0) < op_prio (node))
2099 pp_left_paren (pp);
2100 dump_generic_node (pp, op0, spc, flags, false);
2101 if (op_prio (op0) < op_prio (node))
2102 pp_right_paren (pp);
2103 pp_string (pp, str);
2104 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2105 op0 = component_ref_field_offset (node);
2106 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2108 pp_string (pp, "{off: ");
2109 dump_generic_node (pp, op0, spc, flags, false);
2110 pp_right_brace (pp);
2112 break;
2114 case BIT_FIELD_REF:
2115 pp_string (pp, "BIT_FIELD_REF <");
2116 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2117 pp_string (pp, ", ");
2118 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2119 pp_string (pp, ", ");
2120 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2121 pp_greater (pp);
2122 break;
2124 case BIT_INSERT_EXPR:
2125 pp_string (pp, "BIT_INSERT_EXPR <");
2126 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2127 pp_string (pp, ", ");
2128 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2129 pp_string (pp, ", ");
2130 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2131 pp_string (pp, " (");
2132 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2133 pp_decimal_int (pp,
2134 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2135 else
2136 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2137 spc, flags, false);
2138 pp_string (pp, " bits)>");
2139 break;
2141 case ARRAY_REF:
2142 case ARRAY_RANGE_REF:
2143 op0 = TREE_OPERAND (node, 0);
2144 if (op_prio (op0) < op_prio (node))
2145 pp_left_paren (pp);
2146 dump_generic_node (pp, op0, spc, flags, false);
2147 if (op_prio (op0) < op_prio (node))
2148 pp_right_paren (pp);
2149 pp_left_bracket (pp);
2150 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2151 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2152 pp_string (pp, " ...");
2153 pp_right_bracket (pp);
2155 op0 = array_ref_low_bound (node);
2156 op1 = array_ref_element_size (node);
2158 if (!integer_zerop (op0)
2159 || TREE_OPERAND (node, 2)
2160 || TREE_OPERAND (node, 3))
2162 pp_string (pp, "{lb: ");
2163 dump_generic_node (pp, op0, spc, flags, false);
2164 pp_string (pp, " sz: ");
2165 dump_generic_node (pp, op1, spc, flags, false);
2166 pp_right_brace (pp);
2168 break;
2170 case CONSTRUCTOR:
2172 unsigned HOST_WIDE_INT ix;
2173 tree field, val;
2174 bool is_struct_init = false;
2175 bool is_array_init = false;
2176 widest_int curidx;
2177 pp_left_brace (pp);
2178 if (TREE_CLOBBER_P (node))
2179 pp_string (pp, "CLOBBER");
2180 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2181 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2182 is_struct_init = true;
2183 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2184 && TYPE_DOMAIN (TREE_TYPE (node))
2185 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2186 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2187 == INTEGER_CST)
2189 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2190 is_array_init = true;
2191 curidx = wi::to_widest (minv);
2193 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2195 if (field)
2197 if (is_struct_init)
2199 pp_dot (pp);
2200 dump_generic_node (pp, field, spc, flags, false);
2201 pp_equal (pp);
2203 else if (is_array_init
2204 && (TREE_CODE (field) != INTEGER_CST
2205 || curidx != wi::to_widest (field)))
2207 pp_left_bracket (pp);
2208 if (TREE_CODE (field) == RANGE_EXPR)
2210 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2211 flags, false);
2212 pp_string (pp, " ... ");
2213 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2214 flags, false);
2215 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2216 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2218 else
2219 dump_generic_node (pp, field, spc, flags, false);
2220 if (TREE_CODE (field) == INTEGER_CST)
2221 curidx = wi::to_widest (field);
2222 pp_string (pp, "]=");
2225 if (is_array_init)
2226 curidx += 1;
2227 if (val && TREE_CODE (val) == ADDR_EXPR)
2228 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2229 val = TREE_OPERAND (val, 0);
2230 if (val && TREE_CODE (val) == FUNCTION_DECL)
2231 dump_decl_name (pp, val, flags);
2232 else
2233 dump_generic_node (pp, val, spc, flags, false);
2234 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2236 pp_comma (pp);
2237 pp_space (pp);
2240 pp_right_brace (pp);
2242 break;
2244 case COMPOUND_EXPR:
2246 tree *tp;
2247 if (flags & TDF_SLIM)
2249 pp_string (pp, "<COMPOUND_EXPR>");
2250 break;
2253 dump_generic_node (pp, TREE_OPERAND (node, 0),
2254 spc, flags, !(flags & TDF_SLIM));
2255 if (flags & TDF_SLIM)
2256 newline_and_indent (pp, spc);
2257 else
2259 pp_comma (pp);
2260 pp_space (pp);
2263 for (tp = &TREE_OPERAND (node, 1);
2264 TREE_CODE (*tp) == COMPOUND_EXPR;
2265 tp = &TREE_OPERAND (*tp, 1))
2267 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2268 spc, flags, !(flags & TDF_SLIM));
2269 if (flags & TDF_SLIM)
2270 newline_and_indent (pp, spc);
2271 else
2273 pp_comma (pp);
2274 pp_space (pp);
2278 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2280 break;
2282 case STATEMENT_LIST:
2284 tree_stmt_iterator si;
2285 bool first = true;
2287 if (flags & TDF_SLIM)
2289 pp_string (pp, "<STATEMENT_LIST>");
2290 break;
2293 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2295 if (!first)
2296 newline_and_indent (pp, spc);
2297 else
2298 first = false;
2299 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2302 break;
2304 case MODIFY_EXPR:
2305 case INIT_EXPR:
2306 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2307 false);
2308 pp_space (pp);
2309 pp_equal (pp);
2310 pp_space (pp);
2311 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2312 false);
2313 break;
2315 case TARGET_EXPR:
2316 pp_string (pp, "TARGET_EXPR <");
2317 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2318 pp_comma (pp);
2319 pp_space (pp);
2320 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2321 pp_greater (pp);
2322 break;
2324 case DECL_EXPR:
2325 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2326 is_stmt = false;
2327 break;
2329 case COND_EXPR:
2330 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2332 pp_string (pp, "if (");
2333 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2334 pp_right_paren (pp);
2335 /* The lowered cond_exprs should always be printed in full. */
2336 if (COND_EXPR_THEN (node)
2337 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2338 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2339 && COND_EXPR_ELSE (node)
2340 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2341 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2343 pp_space (pp);
2344 dump_generic_node (pp, COND_EXPR_THEN (node),
2345 0, flags, true);
2346 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2348 pp_string (pp, " else ");
2349 dump_generic_node (pp, COND_EXPR_ELSE (node),
2350 0, flags, true);
2353 else if (!(flags & TDF_SLIM))
2355 /* Output COND_EXPR_THEN. */
2356 if (COND_EXPR_THEN (node))
2358 newline_and_indent (pp, spc+2);
2359 pp_left_brace (pp);
2360 newline_and_indent (pp, spc+4);
2361 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2362 flags, true);
2363 newline_and_indent (pp, spc+2);
2364 pp_right_brace (pp);
2367 /* Output COND_EXPR_ELSE. */
2368 if (COND_EXPR_ELSE (node)
2369 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2371 newline_and_indent (pp, spc);
2372 pp_string (pp, "else");
2373 newline_and_indent (pp, spc+2);
2374 pp_left_brace (pp);
2375 newline_and_indent (pp, spc+4);
2376 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2377 flags, true);
2378 newline_and_indent (pp, spc+2);
2379 pp_right_brace (pp);
2382 is_expr = false;
2384 else
2386 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2387 pp_space (pp);
2388 pp_question (pp);
2389 pp_space (pp);
2390 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2391 pp_space (pp);
2392 pp_colon (pp);
2393 pp_space (pp);
2394 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2396 break;
2398 case BIND_EXPR:
2399 pp_left_brace (pp);
2400 if (!(flags & TDF_SLIM))
2402 if (BIND_EXPR_VARS (node))
2404 pp_newline (pp);
2406 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2408 print_declaration (pp, op0, spc+2, flags);
2409 pp_newline (pp);
2413 newline_and_indent (pp, spc+2);
2414 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2415 newline_and_indent (pp, spc);
2416 pp_right_brace (pp);
2418 is_expr = false;
2419 break;
2421 case CALL_EXPR:
2422 if (CALL_EXPR_FN (node) != NULL_TREE)
2423 print_call_name (pp, CALL_EXPR_FN (node), flags);
2424 else
2426 pp_dot (pp);
2427 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2430 /* Print parameters. */
2431 pp_space (pp);
2432 pp_left_paren (pp);
2434 tree arg;
2435 call_expr_arg_iterator iter;
2436 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2438 dump_generic_node (pp, arg, spc, flags, false);
2439 if (more_call_expr_args_p (&iter))
2441 pp_comma (pp);
2442 pp_space (pp);
2446 if (CALL_EXPR_VA_ARG_PACK (node))
2448 if (call_expr_nargs (node) > 0)
2450 pp_comma (pp);
2451 pp_space (pp);
2453 pp_string (pp, "__builtin_va_arg_pack ()");
2455 pp_right_paren (pp);
2457 op1 = CALL_EXPR_STATIC_CHAIN (node);
2458 if (op1)
2460 pp_string (pp, " [static-chain: ");
2461 dump_generic_node (pp, op1, spc, flags, false);
2462 pp_right_bracket (pp);
2465 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2466 pp_string (pp, " [return slot optimization]");
2467 if (CALL_EXPR_TAILCALL (node))
2468 pp_string (pp, " [tail call]");
2469 break;
2471 case WITH_CLEANUP_EXPR:
2472 NIY;
2473 break;
2475 case CLEANUP_POINT_EXPR:
2476 pp_string (pp, "<<cleanup_point ");
2477 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2478 pp_string (pp, ">>");
2479 break;
2481 case PLACEHOLDER_EXPR:
2482 pp_string (pp, "<PLACEHOLDER_EXPR ");
2483 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2484 pp_greater (pp);
2485 break;
2487 /* Binary arithmetic and logic expressions. */
2488 case WIDEN_SUM_EXPR:
2489 case WIDEN_MULT_EXPR:
2490 case MULT_EXPR:
2491 case MULT_HIGHPART_EXPR:
2492 case PLUS_EXPR:
2493 case POINTER_PLUS_EXPR:
2494 case POINTER_DIFF_EXPR:
2495 case MINUS_EXPR:
2496 case TRUNC_DIV_EXPR:
2497 case CEIL_DIV_EXPR:
2498 case FLOOR_DIV_EXPR:
2499 case ROUND_DIV_EXPR:
2500 case TRUNC_MOD_EXPR:
2501 case CEIL_MOD_EXPR:
2502 case FLOOR_MOD_EXPR:
2503 case ROUND_MOD_EXPR:
2504 case RDIV_EXPR:
2505 case EXACT_DIV_EXPR:
2506 case LSHIFT_EXPR:
2507 case RSHIFT_EXPR:
2508 case LROTATE_EXPR:
2509 case RROTATE_EXPR:
2510 case WIDEN_LSHIFT_EXPR:
2511 case BIT_IOR_EXPR:
2512 case BIT_XOR_EXPR:
2513 case BIT_AND_EXPR:
2514 case TRUTH_ANDIF_EXPR:
2515 case TRUTH_ORIF_EXPR:
2516 case TRUTH_AND_EXPR:
2517 case TRUTH_OR_EXPR:
2518 case TRUTH_XOR_EXPR:
2519 case LT_EXPR:
2520 case LE_EXPR:
2521 case GT_EXPR:
2522 case GE_EXPR:
2523 case EQ_EXPR:
2524 case NE_EXPR:
2525 case UNLT_EXPR:
2526 case UNLE_EXPR:
2527 case UNGT_EXPR:
2528 case UNGE_EXPR:
2529 case UNEQ_EXPR:
2530 case LTGT_EXPR:
2531 case ORDERED_EXPR:
2532 case UNORDERED_EXPR:
2534 const char *op = op_symbol (node);
2535 op0 = TREE_OPERAND (node, 0);
2536 op1 = TREE_OPERAND (node, 1);
2538 /* When the operands are expressions with less priority,
2539 keep semantics of the tree representation. */
2540 if (op_prio (op0) <= op_prio (node))
2542 pp_left_paren (pp);
2543 dump_generic_node (pp, op0, spc, flags, false);
2544 pp_right_paren (pp);
2546 else
2547 dump_generic_node (pp, op0, spc, flags, false);
2549 pp_space (pp);
2550 pp_string (pp, op);
2551 pp_space (pp);
2553 /* When the operands are expressions with less priority,
2554 keep semantics of the tree representation. */
2555 if (op_prio (op1) <= op_prio (node))
2557 pp_left_paren (pp);
2558 dump_generic_node (pp, op1, spc, flags, false);
2559 pp_right_paren (pp);
2561 else
2562 dump_generic_node (pp, op1, spc, flags, false);
2564 break;
2566 /* Unary arithmetic and logic expressions. */
2567 case NEGATE_EXPR:
2568 case BIT_NOT_EXPR:
2569 case TRUTH_NOT_EXPR:
2570 case ADDR_EXPR:
2571 case PREDECREMENT_EXPR:
2572 case PREINCREMENT_EXPR:
2573 case INDIRECT_REF:
2574 if (TREE_CODE (node) == ADDR_EXPR
2575 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2576 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2577 ; /* Do not output '&' for strings and function pointers. */
2578 else
2579 pp_string (pp, op_symbol (node));
2581 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2583 pp_left_paren (pp);
2584 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2585 pp_right_paren (pp);
2587 else
2588 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2589 break;
2591 case POSTDECREMENT_EXPR:
2592 case POSTINCREMENT_EXPR:
2593 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2595 pp_left_paren (pp);
2596 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2597 pp_right_paren (pp);
2599 else
2600 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2601 pp_string (pp, op_symbol (node));
2602 break;
2604 case MIN_EXPR:
2605 pp_string (pp, "MIN_EXPR <");
2606 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2607 pp_string (pp, ", ");
2608 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2609 pp_greater (pp);
2610 break;
2612 case MAX_EXPR:
2613 pp_string (pp, "MAX_EXPR <");
2614 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2615 pp_string (pp, ", ");
2616 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2617 pp_greater (pp);
2618 break;
2620 case ABS_EXPR:
2621 pp_string (pp, "ABS_EXPR <");
2622 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2623 pp_greater (pp);
2624 break;
2626 case ABSU_EXPR:
2627 pp_string (pp, "ABSU_EXPR <");
2628 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2629 pp_greater (pp);
2630 break;
2632 case RANGE_EXPR:
2633 NIY;
2634 break;
2636 case ADDR_SPACE_CONVERT_EXPR:
2637 case FIXED_CONVERT_EXPR:
2638 case FIX_TRUNC_EXPR:
2639 case FLOAT_EXPR:
2640 CASE_CONVERT:
2641 type = TREE_TYPE (node);
2642 op0 = TREE_OPERAND (node, 0);
2643 if (type != TREE_TYPE (op0))
2645 pp_left_paren (pp);
2646 dump_generic_node (pp, type, spc, flags, false);
2647 pp_string (pp, ") ");
2649 if (op_prio (op0) < op_prio (node))
2650 pp_left_paren (pp);
2651 dump_generic_node (pp, op0, spc, flags, false);
2652 if (op_prio (op0) < op_prio (node))
2653 pp_right_paren (pp);
2654 break;
2656 case VIEW_CONVERT_EXPR:
2657 pp_string (pp, "VIEW_CONVERT_EXPR<");
2658 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2659 pp_string (pp, ">(");
2660 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2661 pp_right_paren (pp);
2662 break;
2664 case PAREN_EXPR:
2665 pp_string (pp, "((");
2666 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2667 pp_string (pp, "))");
2668 break;
2670 case NON_LVALUE_EXPR:
2671 pp_string (pp, "NON_LVALUE_EXPR <");
2672 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2673 pp_greater (pp);
2674 break;
2676 case SAVE_EXPR:
2677 pp_string (pp, "SAVE_EXPR <");
2678 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2679 pp_greater (pp);
2680 break;
2682 case COMPLEX_EXPR:
2683 pp_string (pp, "COMPLEX_EXPR <");
2684 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2685 pp_string (pp, ", ");
2686 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2687 pp_greater (pp);
2688 break;
2690 case CONJ_EXPR:
2691 pp_string (pp, "CONJ_EXPR <");
2692 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2693 pp_greater (pp);
2694 break;
2696 case REALPART_EXPR:
2697 if (flags & TDF_GIMPLE)
2699 pp_string (pp, "__real ");
2700 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2702 else
2704 pp_string (pp, "REALPART_EXPR <");
2705 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2706 pp_greater (pp);
2708 break;
2710 case IMAGPART_EXPR:
2711 if (flags & TDF_GIMPLE)
2713 pp_string (pp, "__imag ");
2714 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2716 else
2718 pp_string (pp, "IMAGPART_EXPR <");
2719 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2720 pp_greater (pp);
2722 break;
2724 case VA_ARG_EXPR:
2725 pp_string (pp, "VA_ARG_EXPR <");
2726 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2727 pp_greater (pp);
2728 break;
2730 case TRY_FINALLY_EXPR:
2731 case TRY_CATCH_EXPR:
2732 pp_string (pp, "try");
2733 newline_and_indent (pp, spc+2);
2734 pp_left_brace (pp);
2735 newline_and_indent (pp, spc+4);
2736 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2737 newline_and_indent (pp, spc+2);
2738 pp_right_brace (pp);
2739 newline_and_indent (pp, spc);
2740 pp_string (pp,
2741 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2742 newline_and_indent (pp, spc+2);
2743 pp_left_brace (pp);
2744 newline_and_indent (pp, spc+4);
2745 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2746 newline_and_indent (pp, spc+2);
2747 pp_right_brace (pp);
2748 is_expr = false;
2749 break;
2751 case CATCH_EXPR:
2752 pp_string (pp, "catch (");
2753 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2754 pp_right_paren (pp);
2755 newline_and_indent (pp, spc+2);
2756 pp_left_brace (pp);
2757 newline_and_indent (pp, spc+4);
2758 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2759 newline_and_indent (pp, spc+2);
2760 pp_right_brace (pp);
2761 is_expr = false;
2762 break;
2764 case EH_FILTER_EXPR:
2765 pp_string (pp, "<<<eh_filter (");
2766 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2767 pp_string (pp, ")>>>");
2768 newline_and_indent (pp, spc+2);
2769 pp_left_brace (pp);
2770 newline_and_indent (pp, spc+4);
2771 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2772 newline_and_indent (pp, spc+2);
2773 pp_right_brace (pp);
2774 is_expr = false;
2775 break;
2777 case LABEL_EXPR:
2778 op0 = TREE_OPERAND (node, 0);
2779 /* If this is for break or continue, don't bother printing it. */
2780 if (DECL_NAME (op0))
2782 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2783 if (strcmp (name, "break") == 0
2784 || strcmp (name, "continue") == 0)
2785 break;
2787 dump_generic_node (pp, op0, spc, flags, false);
2788 pp_colon (pp);
2789 if (DECL_NONLOCAL (op0))
2790 pp_string (pp, " [non-local]");
2791 break;
2793 case LOOP_EXPR:
2794 pp_string (pp, "while (1)");
2795 if (!(flags & TDF_SLIM))
2797 newline_and_indent (pp, spc+2);
2798 pp_left_brace (pp);
2799 newline_and_indent (pp, spc+4);
2800 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2801 newline_and_indent (pp, spc+2);
2802 pp_right_brace (pp);
2804 is_expr = false;
2805 break;
2807 case PREDICT_EXPR:
2808 pp_string (pp, "// predicted ");
2809 if (PREDICT_EXPR_OUTCOME (node))
2810 pp_string (pp, "likely by ");
2811 else
2812 pp_string (pp, "unlikely by ");
2813 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2814 pp_string (pp, " predictor.");
2815 break;
2817 case ANNOTATE_EXPR:
2818 pp_string (pp, "ANNOTATE_EXPR <");
2819 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2820 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2822 case annot_expr_ivdep_kind:
2823 pp_string (pp, ", ivdep");
2824 break;
2825 case annot_expr_unroll_kind:
2826 pp_printf (pp, ", unroll %d",
2827 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2828 break;
2829 case annot_expr_no_vector_kind:
2830 pp_string (pp, ", no-vector");
2831 break;
2832 case annot_expr_vector_kind:
2833 pp_string (pp, ", vector");
2834 break;
2835 case annot_expr_parallel_kind:
2836 pp_string (pp, ", parallel");
2837 break;
2838 default:
2839 gcc_unreachable ();
2841 pp_greater (pp);
2842 break;
2844 case RETURN_EXPR:
2845 pp_string (pp, "return");
2846 op0 = TREE_OPERAND (node, 0);
2847 if (op0)
2849 pp_space (pp);
2850 if (TREE_CODE (op0) == MODIFY_EXPR)
2851 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2852 spc, flags, false);
2853 else
2854 dump_generic_node (pp, op0, spc, flags, false);
2856 break;
2858 case EXIT_EXPR:
2859 pp_string (pp, "if (");
2860 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2861 pp_string (pp, ") break");
2862 break;
2864 case SWITCH_EXPR:
2865 pp_string (pp, "switch (");
2866 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2867 pp_right_paren (pp);
2868 if (!(flags & TDF_SLIM))
2870 newline_and_indent (pp, spc+2);
2871 pp_left_brace (pp);
2872 if (SWITCH_BODY (node))
2874 newline_and_indent (pp, spc+4);
2875 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2876 true);
2878 newline_and_indent (pp, spc+2);
2879 pp_right_brace (pp);
2881 is_expr = false;
2882 break;
2884 case GOTO_EXPR:
2885 op0 = GOTO_DESTINATION (node);
2886 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2888 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2889 if (strcmp (name, "break") == 0
2890 || strcmp (name, "continue") == 0)
2892 pp_string (pp, name);
2893 break;
2896 pp_string (pp, "goto ");
2897 dump_generic_node (pp, op0, spc, flags, false);
2898 break;
2900 case ASM_EXPR:
2901 pp_string (pp, "__asm__");
2902 if (ASM_VOLATILE_P (node))
2903 pp_string (pp, " __volatile__");
2904 pp_left_paren (pp);
2905 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2906 pp_colon (pp);
2907 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2908 pp_colon (pp);
2909 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2910 if (ASM_CLOBBERS (node))
2912 pp_colon (pp);
2913 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2915 pp_right_paren (pp);
2916 break;
2918 case CASE_LABEL_EXPR:
2919 if (CASE_LOW (node) && CASE_HIGH (node))
2921 pp_string (pp, "case ");
2922 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2923 pp_string (pp, " ... ");
2924 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2926 else if (CASE_LOW (node))
2928 pp_string (pp, "case ");
2929 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2931 else
2932 pp_string (pp, "default");
2933 pp_colon (pp);
2934 break;
2936 case OBJ_TYPE_REF:
2937 pp_string (pp, "OBJ_TYPE_REF(");
2938 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2939 pp_semicolon (pp);
2940 /* We omit the class type for -fcompare-debug because we may
2941 drop TYPE_BINFO early depending on debug info, and then
2942 virtual_method_call_p would return false, whereas when
2943 TYPE_BINFO is preserved it may still return true and then
2944 we'd print the class type. Compare tree and rtl dumps for
2945 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
2946 for example, at occurrences of OBJ_TYPE_REF. */
2947 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
2948 && virtual_method_call_p (node))
2950 pp_string (pp, "(");
2951 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2952 pp_string (pp, ")");
2954 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2955 pp_arrow (pp);
2956 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2957 pp_right_paren (pp);
2958 break;
2960 case SSA_NAME:
2961 if (SSA_NAME_IDENTIFIER (node))
2963 if ((flags & TDF_NOUID)
2964 && SSA_NAME_VAR (node)
2965 && DECL_NAMELESS (SSA_NAME_VAR (node)))
2966 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
2967 else if (! (flags & TDF_GIMPLE)
2968 || SSA_NAME_VAR (node))
2969 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2970 spc, flags, false);
2972 pp_underscore (pp);
2973 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2974 if (SSA_NAME_IS_DEFAULT_DEF (node))
2975 pp_string (pp, "(D)");
2976 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2977 pp_string (pp, "(ab)");
2978 break;
2980 case WITH_SIZE_EXPR:
2981 pp_string (pp, "WITH_SIZE_EXPR <");
2982 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2983 pp_string (pp, ", ");
2984 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2985 pp_greater (pp);
2986 break;
2988 case ASSERT_EXPR:
2989 pp_string (pp, "ASSERT_EXPR <");
2990 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2991 pp_string (pp, ", ");
2992 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2993 pp_greater (pp);
2994 break;
2996 case SCEV_KNOWN:
2997 pp_string (pp, "scev_known");
2998 break;
3000 case SCEV_NOT_KNOWN:
3001 pp_string (pp, "scev_not_known");
3002 break;
3004 case POLYNOMIAL_CHREC:
3005 pp_left_brace (pp);
3006 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3007 pp_string (pp, ", +, ");
3008 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3009 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
3010 is_stmt = false;
3011 break;
3013 case REALIGN_LOAD_EXPR:
3014 pp_string (pp, "REALIGN_LOAD <");
3015 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3016 pp_string (pp, ", ");
3017 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3018 pp_string (pp, ", ");
3019 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3020 pp_greater (pp);
3021 break;
3023 case VEC_COND_EXPR:
3024 pp_string (pp, " VEC_COND_EXPR < ");
3025 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3026 pp_string (pp, " , ");
3027 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3028 pp_string (pp, " , ");
3029 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3030 pp_string (pp, " > ");
3031 break;
3033 case VEC_PERM_EXPR:
3034 pp_string (pp, " VEC_PERM_EXPR < ");
3035 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3036 pp_string (pp, " , ");
3037 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3038 pp_string (pp, " , ");
3039 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3040 pp_string (pp, " > ");
3041 break;
3043 case DOT_PROD_EXPR:
3044 pp_string (pp, " DOT_PROD_EXPR < ");
3045 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3046 pp_string (pp, ", ");
3047 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3048 pp_string (pp, ", ");
3049 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3050 pp_string (pp, " > ");
3051 break;
3053 case WIDEN_MULT_PLUS_EXPR:
3054 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3055 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3056 pp_string (pp, ", ");
3057 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3058 pp_string (pp, ", ");
3059 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3060 pp_string (pp, " > ");
3061 break;
3063 case WIDEN_MULT_MINUS_EXPR:
3064 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3065 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3066 pp_string (pp, ", ");
3067 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3068 pp_string (pp, ", ");
3069 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3070 pp_string (pp, " > ");
3071 break;
3073 case OACC_PARALLEL:
3074 pp_string (pp, "#pragma acc parallel");
3075 goto dump_omp_clauses_body;
3077 case OACC_KERNELS:
3078 pp_string (pp, "#pragma acc kernels");
3079 goto dump_omp_clauses_body;
3081 case OACC_DATA:
3082 pp_string (pp, "#pragma acc data");
3083 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3084 goto dump_omp_body;
3086 case OACC_HOST_DATA:
3087 pp_string (pp, "#pragma acc host_data");
3088 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3089 goto dump_omp_body;
3091 case OACC_DECLARE:
3092 pp_string (pp, "#pragma acc declare");
3093 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3094 break;
3096 case OACC_UPDATE:
3097 pp_string (pp, "#pragma acc update");
3098 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3099 break;
3101 case OACC_ENTER_DATA:
3102 pp_string (pp, "#pragma acc enter data");
3103 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3104 break;
3106 case OACC_EXIT_DATA:
3107 pp_string (pp, "#pragma acc exit data");
3108 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3109 break;
3111 case OACC_CACHE:
3112 pp_string (pp, "#pragma acc cache");
3113 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3114 break;
3116 case OMP_PARALLEL:
3117 pp_string (pp, "#pragma omp parallel");
3118 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3119 goto dump_omp_body;
3121 dump_omp_clauses_body:
3122 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3123 goto dump_omp_body;
3125 dump_omp_body:
3126 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3128 newline_and_indent (pp, spc + 2);
3129 pp_left_brace (pp);
3130 newline_and_indent (pp, spc + 4);
3131 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3132 newline_and_indent (pp, spc + 2);
3133 pp_right_brace (pp);
3135 is_expr = false;
3136 break;
3138 case OMP_TASK:
3139 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3140 : "#pragma omp taskwait");
3141 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3142 goto dump_omp_body;
3144 case OMP_FOR:
3145 pp_string (pp, "#pragma omp for");
3146 goto dump_omp_loop;
3148 case OMP_SIMD:
3149 pp_string (pp, "#pragma omp simd");
3150 goto dump_omp_loop;
3152 case OMP_DISTRIBUTE:
3153 pp_string (pp, "#pragma omp distribute");
3154 goto dump_omp_loop;
3156 case OMP_TASKLOOP:
3157 pp_string (pp, "#pragma omp taskloop");
3158 goto dump_omp_loop;
3160 case OACC_LOOP:
3161 pp_string (pp, "#pragma acc loop");
3162 goto dump_omp_loop;
3164 case OMP_TEAMS:
3165 pp_string (pp, "#pragma omp teams");
3166 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3167 goto dump_omp_body;
3169 case OMP_TARGET_DATA:
3170 pp_string (pp, "#pragma omp target data");
3171 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3172 goto dump_omp_body;
3174 case OMP_TARGET_ENTER_DATA:
3175 pp_string (pp, "#pragma omp target enter data");
3176 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3177 is_expr = false;
3178 break;
3180 case OMP_TARGET_EXIT_DATA:
3181 pp_string (pp, "#pragma omp target exit data");
3182 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3183 is_expr = false;
3184 break;
3186 case OMP_TARGET:
3187 pp_string (pp, "#pragma omp target");
3188 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3189 goto dump_omp_body;
3191 case OMP_TARGET_UPDATE:
3192 pp_string (pp, "#pragma omp target update");
3193 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3194 is_expr = false;
3195 break;
3197 dump_omp_loop:
3198 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3199 if (!(flags & TDF_SLIM))
3201 int i;
3203 if (OMP_FOR_PRE_BODY (node))
3205 newline_and_indent (pp, spc + 2);
3206 pp_left_brace (pp);
3207 spc += 4;
3208 newline_and_indent (pp, spc);
3209 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3210 spc, flags, false);
3212 if (OMP_FOR_INIT (node))
3214 spc -= 2;
3215 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3217 spc += 2;
3218 newline_and_indent (pp, spc);
3219 pp_string (pp, "for (");
3220 dump_generic_node (pp,
3221 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3222 spc, flags, false);
3223 pp_string (pp, "; ");
3224 dump_generic_node (pp,
3225 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3226 spc, flags, false);
3227 pp_string (pp, "; ");
3228 dump_generic_node (pp,
3229 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3230 spc, flags, false);
3231 pp_right_paren (pp);
3234 if (OMP_FOR_BODY (node))
3236 newline_and_indent (pp, spc + 2);
3237 pp_left_brace (pp);
3238 newline_and_indent (pp, spc + 4);
3239 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3240 false);
3241 newline_and_indent (pp, spc + 2);
3242 pp_right_brace (pp);
3244 if (OMP_FOR_INIT (node))
3245 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3246 if (OMP_FOR_PRE_BODY (node))
3248 spc -= 4;
3249 newline_and_indent (pp, spc + 2);
3250 pp_right_brace (pp);
3253 is_expr = false;
3254 break;
3256 case OMP_SECTIONS:
3257 pp_string (pp, "#pragma omp sections");
3258 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3259 goto dump_omp_body;
3261 case OMP_SECTION:
3262 pp_string (pp, "#pragma omp section");
3263 goto dump_omp_body;
3265 case OMP_MASTER:
3266 pp_string (pp, "#pragma omp master");
3267 goto dump_omp_body;
3269 case OMP_TASKGROUP:
3270 pp_string (pp, "#pragma omp taskgroup");
3271 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3272 goto dump_omp_body;
3274 case OMP_ORDERED:
3275 pp_string (pp, "#pragma omp ordered");
3276 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3277 goto dump_omp_body;
3279 case OMP_CRITICAL:
3280 pp_string (pp, "#pragma omp critical");
3281 if (OMP_CRITICAL_NAME (node))
3283 pp_space (pp);
3284 pp_left_paren (pp);
3285 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3286 flags, false);
3287 pp_right_paren (pp);
3289 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3290 goto dump_omp_body;
3292 case OMP_ATOMIC:
3293 pp_string (pp, "#pragma omp atomic");
3294 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3295 newline_and_indent (pp, spc + 2);
3296 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3297 pp_space (pp);
3298 pp_equal (pp);
3299 pp_space (pp);
3300 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3301 break;
3303 case OMP_ATOMIC_READ:
3304 pp_string (pp, "#pragma omp atomic read");
3305 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3306 newline_and_indent (pp, spc + 2);
3307 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3308 pp_space (pp);
3309 break;
3311 case OMP_ATOMIC_CAPTURE_OLD:
3312 case OMP_ATOMIC_CAPTURE_NEW:
3313 pp_string (pp, "#pragma omp atomic capture");
3314 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3315 newline_and_indent (pp, spc + 2);
3316 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3317 pp_space (pp);
3318 pp_equal (pp);
3319 pp_space (pp);
3320 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3321 break;
3323 case OMP_SINGLE:
3324 pp_string (pp, "#pragma omp single");
3325 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3326 goto dump_omp_body;
3328 case OMP_CLAUSE:
3329 dump_omp_clause (pp, node, spc, flags);
3330 is_expr = false;
3331 break;
3333 case TRANSACTION_EXPR:
3334 if (TRANSACTION_EXPR_OUTER (node))
3335 pp_string (pp, "__transaction_atomic [[outer]]");
3336 else if (TRANSACTION_EXPR_RELAXED (node))
3337 pp_string (pp, "__transaction_relaxed");
3338 else
3339 pp_string (pp, "__transaction_atomic");
3340 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3342 newline_and_indent (pp, spc);
3343 pp_left_brace (pp);
3344 newline_and_indent (pp, spc + 2);
3345 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3346 spc + 2, flags, false);
3347 newline_and_indent (pp, spc);
3348 pp_right_brace (pp);
3350 is_expr = false;
3351 break;
3353 case VEC_SERIES_EXPR:
3354 case VEC_WIDEN_MULT_HI_EXPR:
3355 case VEC_WIDEN_MULT_LO_EXPR:
3356 case VEC_WIDEN_MULT_EVEN_EXPR:
3357 case VEC_WIDEN_MULT_ODD_EXPR:
3358 case VEC_WIDEN_LSHIFT_HI_EXPR:
3359 case VEC_WIDEN_LSHIFT_LO_EXPR:
3360 pp_space (pp);
3361 for (str = get_tree_code_name (code); *str; str++)
3362 pp_character (pp, TOUPPER (*str));
3363 pp_string (pp, " < ");
3364 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3365 pp_string (pp, ", ");
3366 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3367 pp_string (pp, " > ");
3368 break;
3370 case VEC_DUPLICATE_EXPR:
3371 pp_space (pp);
3372 for (str = get_tree_code_name (code); *str; str++)
3373 pp_character (pp, TOUPPER (*str));
3374 pp_string (pp, " < ");
3375 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3376 pp_string (pp, " > ");
3377 break;
3379 case VEC_UNPACK_HI_EXPR:
3380 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3381 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3382 pp_string (pp, " > ");
3383 break;
3385 case VEC_UNPACK_LO_EXPR:
3386 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3387 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3388 pp_string (pp, " > ");
3389 break;
3391 case VEC_UNPACK_FLOAT_HI_EXPR:
3392 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3393 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3394 pp_string (pp, " > ");
3395 break;
3397 case VEC_UNPACK_FLOAT_LO_EXPR:
3398 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3399 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3400 pp_string (pp, " > ");
3401 break;
3403 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3404 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3405 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3406 pp_string (pp, " > ");
3407 break;
3409 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3410 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3411 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3412 pp_string (pp, " > ");
3413 break;
3415 case VEC_PACK_TRUNC_EXPR:
3416 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3417 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3418 pp_string (pp, ", ");
3419 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3420 pp_string (pp, " > ");
3421 break;
3423 case VEC_PACK_SAT_EXPR:
3424 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3425 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3426 pp_string (pp, ", ");
3427 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3428 pp_string (pp, " > ");
3429 break;
3431 case VEC_PACK_FIX_TRUNC_EXPR:
3432 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3433 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3434 pp_string (pp, ", ");
3435 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3436 pp_string (pp, " > ");
3437 break;
3439 case VEC_PACK_FLOAT_EXPR:
3440 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3441 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3442 pp_string (pp, ", ");
3443 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3444 pp_string (pp, " > ");
3445 break;
3447 case BLOCK:
3448 dump_block_node (pp, node, spc, flags);
3449 break;
3451 case DEBUG_BEGIN_STMT:
3452 pp_string (pp, "# DEBUG BEGIN STMT");
3453 break;
3455 default:
3456 NIY;
3459 if (is_stmt && is_expr)
3460 pp_semicolon (pp);
3462 return spc;
3465 /* Print the declaration of a variable. */
3467 void
3468 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3470 INDENT (spc);
3472 if (TREE_CODE(t) == NAMELIST_DECL)
3474 pp_string(pp, "namelist ");
3475 dump_decl_name (pp, t, flags);
3476 pp_semicolon (pp);
3477 return;
3480 if (TREE_CODE (t) == TYPE_DECL)
3481 pp_string (pp, "typedef ");
3483 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3484 pp_string (pp, "register ");
3486 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3487 pp_string (pp, "extern ");
3488 else if (TREE_STATIC (t))
3489 pp_string (pp, "static ");
3491 /* Print the type and name. */
3492 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3494 tree tmp;
3496 /* Print array's type. */
3497 tmp = TREE_TYPE (t);
3498 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3499 tmp = TREE_TYPE (tmp);
3500 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3502 /* Print variable's name. */
3503 pp_space (pp);
3504 dump_generic_node (pp, t, spc, flags, false);
3506 /* Print the dimensions. */
3507 tmp = TREE_TYPE (t);
3508 while (TREE_CODE (tmp) == ARRAY_TYPE)
3510 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3511 tmp = TREE_TYPE (tmp);
3514 else if (TREE_CODE (t) == FUNCTION_DECL)
3516 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3517 pp_space (pp);
3518 dump_decl_name (pp, t, flags);
3519 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3521 else
3523 /* Print type declaration. */
3524 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3526 /* Print variable's name. */
3527 pp_space (pp);
3528 dump_generic_node (pp, t, spc, flags, false);
3531 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3533 pp_string (pp, " __asm__ ");
3534 pp_left_paren (pp);
3535 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3536 pp_right_paren (pp);
3539 /* The initial value of a function serves to determine whether the function
3540 is declared or defined. So the following does not apply to function
3541 nodes. */
3542 if (TREE_CODE (t) != FUNCTION_DECL)
3544 /* Print the initial value. */
3545 if (DECL_INITIAL (t))
3547 pp_space (pp);
3548 pp_equal (pp);
3549 pp_space (pp);
3550 if (!(flags & TDF_SLIM))
3551 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3552 else
3553 pp_string (pp, "<<< omitted >>>");
3557 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3559 pp_string (pp, " [value-expr: ");
3560 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3561 pp_right_bracket (pp);
3564 pp_semicolon (pp);
3568 /* Prints a structure: name, fields, and methods.
3569 FIXME: Still incomplete. */
3571 static void
3572 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3573 dump_flags_t flags)
3575 /* Print the name of the structure. */
3576 if (TYPE_NAME (node))
3578 INDENT (spc);
3579 if (TREE_CODE (node) == RECORD_TYPE)
3580 pp_string (pp, "struct ");
3581 else if ((TREE_CODE (node) == UNION_TYPE
3582 || TREE_CODE (node) == QUAL_UNION_TYPE))
3583 pp_string (pp, "union ");
3585 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3588 /* Print the contents of the structure. */
3589 pp_newline (pp);
3590 INDENT (spc);
3591 pp_left_brace (pp);
3592 pp_newline (pp);
3594 /* Print the fields of the structure. */
3596 tree tmp;
3597 tmp = TYPE_FIELDS (node);
3598 while (tmp)
3600 /* Avoid to print recursively the structure. */
3601 /* FIXME : Not implemented correctly...,
3602 what about the case when we have a cycle in the contain graph? ...
3603 Maybe this could be solved by looking at the scope in which the
3604 structure was declared. */
3605 if (TREE_TYPE (tmp) != node
3606 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3607 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3609 print_declaration (pp, tmp, spc+2, flags);
3610 pp_newline (pp);
3612 tmp = DECL_CHAIN (tmp);
3615 INDENT (spc);
3616 pp_right_brace (pp);
3619 /* Return the priority of the operator CODE.
3621 From lowest to highest precedence with either left-to-right (L-R)
3622 or right-to-left (R-L) associativity]:
3624 1 [L-R] ,
3625 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3626 3 [R-L] ?:
3627 4 [L-R] ||
3628 5 [L-R] &&
3629 6 [L-R] |
3630 7 [L-R] ^
3631 8 [L-R] &
3632 9 [L-R] == !=
3633 10 [L-R] < <= > >=
3634 11 [L-R] << >>
3635 12 [L-R] + -
3636 13 [L-R] * / %
3637 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3638 15 [L-R] fn() [] -> .
3640 unary +, - and * have higher precedence than the corresponding binary
3641 operators. */
3644 op_code_prio (enum tree_code code)
3646 switch (code)
3648 case TREE_LIST:
3649 case COMPOUND_EXPR:
3650 case BIND_EXPR:
3651 return 1;
3653 case MODIFY_EXPR:
3654 case INIT_EXPR:
3655 return 2;
3657 case COND_EXPR:
3658 return 3;
3660 case TRUTH_OR_EXPR:
3661 case TRUTH_ORIF_EXPR:
3662 return 4;
3664 case TRUTH_AND_EXPR:
3665 case TRUTH_ANDIF_EXPR:
3666 return 5;
3668 case BIT_IOR_EXPR:
3669 return 6;
3671 case BIT_XOR_EXPR:
3672 case TRUTH_XOR_EXPR:
3673 return 7;
3675 case BIT_AND_EXPR:
3676 return 8;
3678 case EQ_EXPR:
3679 case NE_EXPR:
3680 return 9;
3682 case UNLT_EXPR:
3683 case UNLE_EXPR:
3684 case UNGT_EXPR:
3685 case UNGE_EXPR:
3686 case UNEQ_EXPR:
3687 case LTGT_EXPR:
3688 case ORDERED_EXPR:
3689 case UNORDERED_EXPR:
3690 case LT_EXPR:
3691 case LE_EXPR:
3692 case GT_EXPR:
3693 case GE_EXPR:
3694 return 10;
3696 case LSHIFT_EXPR:
3697 case RSHIFT_EXPR:
3698 case LROTATE_EXPR:
3699 case RROTATE_EXPR:
3700 case VEC_WIDEN_LSHIFT_HI_EXPR:
3701 case VEC_WIDEN_LSHIFT_LO_EXPR:
3702 case WIDEN_LSHIFT_EXPR:
3703 return 11;
3705 case WIDEN_SUM_EXPR:
3706 case PLUS_EXPR:
3707 case POINTER_PLUS_EXPR:
3708 case POINTER_DIFF_EXPR:
3709 case MINUS_EXPR:
3710 return 12;
3712 case VEC_WIDEN_MULT_HI_EXPR:
3713 case VEC_WIDEN_MULT_LO_EXPR:
3714 case WIDEN_MULT_EXPR:
3715 case DOT_PROD_EXPR:
3716 case WIDEN_MULT_PLUS_EXPR:
3717 case WIDEN_MULT_MINUS_EXPR:
3718 case MULT_EXPR:
3719 case MULT_HIGHPART_EXPR:
3720 case TRUNC_DIV_EXPR:
3721 case CEIL_DIV_EXPR:
3722 case FLOOR_DIV_EXPR:
3723 case ROUND_DIV_EXPR:
3724 case RDIV_EXPR:
3725 case EXACT_DIV_EXPR:
3726 case TRUNC_MOD_EXPR:
3727 case CEIL_MOD_EXPR:
3728 case FLOOR_MOD_EXPR:
3729 case ROUND_MOD_EXPR:
3730 return 13;
3732 case TRUTH_NOT_EXPR:
3733 case BIT_NOT_EXPR:
3734 case POSTINCREMENT_EXPR:
3735 case POSTDECREMENT_EXPR:
3736 case PREINCREMENT_EXPR:
3737 case PREDECREMENT_EXPR:
3738 case NEGATE_EXPR:
3739 case INDIRECT_REF:
3740 case ADDR_EXPR:
3741 case FLOAT_EXPR:
3742 CASE_CONVERT:
3743 case FIX_TRUNC_EXPR:
3744 case TARGET_EXPR:
3745 return 14;
3747 case CALL_EXPR:
3748 case ARRAY_REF:
3749 case ARRAY_RANGE_REF:
3750 case COMPONENT_REF:
3751 return 15;
3753 /* Special expressions. */
3754 case MIN_EXPR:
3755 case MAX_EXPR:
3756 case ABS_EXPR:
3757 case REALPART_EXPR:
3758 case IMAGPART_EXPR:
3759 case VEC_UNPACK_HI_EXPR:
3760 case VEC_UNPACK_LO_EXPR:
3761 case VEC_UNPACK_FLOAT_HI_EXPR:
3762 case VEC_UNPACK_FLOAT_LO_EXPR:
3763 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3764 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3765 case VEC_PACK_TRUNC_EXPR:
3766 case VEC_PACK_SAT_EXPR:
3767 return 16;
3769 default:
3770 /* Return an arbitrarily high precedence to avoid surrounding single
3771 VAR_DECLs in ()s. */
3772 return 9999;
3776 /* Return the priority of the operator OP. */
3779 op_prio (const_tree op)
3781 enum tree_code code;
3783 if (op == NULL)
3784 return 9999;
3786 code = TREE_CODE (op);
3787 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3788 return op_prio (TREE_OPERAND (op, 0));
3790 return op_code_prio (code);
3793 /* Return the symbol associated with operator CODE. */
3795 const char *
3796 op_symbol_code (enum tree_code code)
3798 switch (code)
3800 case MODIFY_EXPR:
3801 return "=";
3803 case TRUTH_OR_EXPR:
3804 case TRUTH_ORIF_EXPR:
3805 return "||";
3807 case TRUTH_AND_EXPR:
3808 case TRUTH_ANDIF_EXPR:
3809 return "&&";
3811 case BIT_IOR_EXPR:
3812 return "|";
3814 case TRUTH_XOR_EXPR:
3815 case BIT_XOR_EXPR:
3816 return "^";
3818 case ADDR_EXPR:
3819 case BIT_AND_EXPR:
3820 return "&";
3822 case ORDERED_EXPR:
3823 return "ord";
3824 case UNORDERED_EXPR:
3825 return "unord";
3827 case EQ_EXPR:
3828 return "==";
3829 case UNEQ_EXPR:
3830 return "u==";
3832 case NE_EXPR:
3833 return "!=";
3835 case LT_EXPR:
3836 return "<";
3837 case UNLT_EXPR:
3838 return "u<";
3840 case LE_EXPR:
3841 return "<=";
3842 case UNLE_EXPR:
3843 return "u<=";
3845 case GT_EXPR:
3846 return ">";
3847 case UNGT_EXPR:
3848 return "u>";
3850 case GE_EXPR:
3851 return ">=";
3852 case UNGE_EXPR:
3853 return "u>=";
3855 case LTGT_EXPR:
3856 return "<>";
3858 case LSHIFT_EXPR:
3859 return "<<";
3861 case RSHIFT_EXPR:
3862 return ">>";
3864 case LROTATE_EXPR:
3865 return "r<<";
3867 case RROTATE_EXPR:
3868 return "r>>";
3870 case WIDEN_LSHIFT_EXPR:
3871 return "w<<";
3873 case POINTER_PLUS_EXPR:
3874 return "+";
3876 case PLUS_EXPR:
3877 return "+";
3879 case WIDEN_SUM_EXPR:
3880 return "w+";
3882 case WIDEN_MULT_EXPR:
3883 return "w*";
3885 case MULT_HIGHPART_EXPR:
3886 return "h*";
3888 case NEGATE_EXPR:
3889 case MINUS_EXPR:
3890 case POINTER_DIFF_EXPR:
3891 return "-";
3893 case BIT_NOT_EXPR:
3894 return "~";
3896 case TRUTH_NOT_EXPR:
3897 return "!";
3899 case MULT_EXPR:
3900 case INDIRECT_REF:
3901 return "*";
3903 case TRUNC_DIV_EXPR:
3904 case RDIV_EXPR:
3905 return "/";
3907 case CEIL_DIV_EXPR:
3908 return "/[cl]";
3910 case FLOOR_DIV_EXPR:
3911 return "/[fl]";
3913 case ROUND_DIV_EXPR:
3914 return "/[rd]";
3916 case EXACT_DIV_EXPR:
3917 return "/[ex]";
3919 case TRUNC_MOD_EXPR:
3920 return "%";
3922 case CEIL_MOD_EXPR:
3923 return "%[cl]";
3925 case FLOOR_MOD_EXPR:
3926 return "%[fl]";
3928 case ROUND_MOD_EXPR:
3929 return "%[rd]";
3931 case PREDECREMENT_EXPR:
3932 return " --";
3934 case PREINCREMENT_EXPR:
3935 return " ++";
3937 case POSTDECREMENT_EXPR:
3938 return "-- ";
3940 case POSTINCREMENT_EXPR:
3941 return "++ ";
3943 case MAX_EXPR:
3944 return "max";
3946 case MIN_EXPR:
3947 return "min";
3949 default:
3950 return "<<< ??? >>>";
3954 /* Return the symbol associated with operator OP. */
3956 static const char *
3957 op_symbol (const_tree op)
3959 return op_symbol_code (TREE_CODE (op));
3962 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3963 the gimple_call_fn of a GIMPLE_CALL. */
3965 void
3966 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
3968 tree op0 = node;
3970 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3971 op0 = TREE_OPERAND (op0, 0);
3973 again:
3974 switch (TREE_CODE (op0))
3976 case VAR_DECL:
3977 case PARM_DECL:
3978 case FUNCTION_DECL:
3979 dump_function_name (pp, op0, flags);
3980 break;
3982 case ADDR_EXPR:
3983 case INDIRECT_REF:
3984 CASE_CONVERT:
3985 op0 = TREE_OPERAND (op0, 0);
3986 goto again;
3988 case COND_EXPR:
3989 pp_left_paren (pp);
3990 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3991 pp_string (pp, ") ? ");
3992 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3993 pp_string (pp, " : ");
3994 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3995 break;
3997 case ARRAY_REF:
3998 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3999 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4000 else
4001 dump_generic_node (pp, op0, 0, flags, false);
4002 break;
4004 case MEM_REF:
4005 if (integer_zerop (TREE_OPERAND (op0, 1)))
4007 op0 = TREE_OPERAND (op0, 0);
4008 goto again;
4010 /* Fallthru. */
4011 case COMPONENT_REF:
4012 case SSA_NAME:
4013 case OBJ_TYPE_REF:
4014 dump_generic_node (pp, op0, 0, flags, false);
4015 break;
4017 default:
4018 NIY;
4022 /* Print the first N characters in the array STR, replacing non-printable
4023 characters (including embedded nuls) with unambiguous escape sequences. */
4025 static void
4026 pretty_print_string (pretty_printer *pp, const char *str, unsigned n)
4028 if (str == NULL)
4029 return;
4031 for ( ; n; --n, ++str)
4033 switch (str[0])
4035 case '\b':
4036 pp_string (pp, "\\b");
4037 break;
4039 case '\f':
4040 pp_string (pp, "\\f");
4041 break;
4043 case '\n':
4044 pp_string (pp, "\\n");
4045 break;
4047 case '\r':
4048 pp_string (pp, "\\r");
4049 break;
4051 case '\t':
4052 pp_string (pp, "\\t");
4053 break;
4055 case '\v':
4056 pp_string (pp, "\\v");
4057 break;
4059 case '\\':
4060 pp_string (pp, "\\\\");
4061 break;
4063 case '\"':
4064 pp_string (pp, "\\\"");
4065 break;
4067 case '\'':
4068 pp_string (pp, "\\'");
4069 break;
4071 default:
4072 if (str[0] || n > 1)
4074 if (!ISPRINT (str[0]))
4076 char buf[5];
4077 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4078 pp_string (pp, buf);
4080 else
4081 pp_character (pp, str[0]);
4082 break;
4088 static void
4089 maybe_init_pretty_print (FILE *file)
4091 if (!tree_pp)
4093 tree_pp = new pretty_printer ();
4094 pp_needs_newline (tree_pp) = true;
4095 pp_translate_identifiers (tree_pp) = false;
4098 tree_pp->buffer->stream = file;
4101 static void
4102 newline_and_indent (pretty_printer *pp, int spc)
4104 pp_newline (pp);
4105 INDENT (spc);
4108 /* Handle the %K format for TEXT. Separate from default_tree_printer
4109 so it can also be used in front ends.
4110 The location LOC and BLOCK are expected to be extracted by the caller
4111 from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
4113 void
4114 percent_K_format (text_info *text, location_t loc, tree block)
4116 text->set_location (0, loc, SHOW_RANGE_WITH_CARET);
4117 gcc_assert (pp_ti_abstract_origin (text) != NULL);
4118 *pp_ti_abstract_origin (text) = NULL;
4120 while (block
4121 && TREE_CODE (block) == BLOCK
4122 && BLOCK_ABSTRACT_ORIGIN (block))
4124 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4125 if (TREE_CODE (ao) == FUNCTION_DECL)
4127 *pp_ti_abstract_origin (text) = block;
4128 break;
4130 block = BLOCK_SUPERCONTEXT (block);
4134 /* Print the identifier ID to PRETTY-PRINTER. */
4136 void
4137 pp_tree_identifier (pretty_printer *pp, tree id)
4139 if (pp_translate_identifiers (pp))
4141 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4142 pp_append_text (pp, text, text + strlen (text));
4144 else
4145 pp_append_text (pp, IDENTIFIER_POINTER (id),
4146 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4149 /* A helper function that is used to dump function information before the
4150 function dump. */
4152 void
4153 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4155 const char *dname, *aname;
4156 struct cgraph_node *node = cgraph_node::get (fdecl);
4157 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4159 dname = lang_hooks.decl_printable_name (fdecl, 1);
4161 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4162 aname = (IDENTIFIER_POINTER
4163 (DECL_ASSEMBLER_NAME (fdecl)));
4164 else
4165 aname = "<unset-asm-name>";
4167 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4168 dname, aname, fun->funcdef_no);
4169 if (!(flags & TDF_NOUID))
4170 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4171 if (node)
4173 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4174 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4175 node->frequency == NODE_FREQUENCY_HOT
4176 ? " (hot)"
4177 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4178 ? " (unlikely executed)"
4179 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4180 ? " (executed once)"
4181 : "");
4183 else
4184 fprintf (dump_file, ")\n\n");
4187 /* Dump double_int D to pretty_printer PP. UNS is true
4188 if D is unsigned and false otherwise. */
4189 void
4190 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4192 if (d.fits_shwi ())
4193 pp_wide_integer (pp, d.low);
4194 else if (d.fits_uhwi ())
4195 pp_unsigned_wide_integer (pp, d.low);
4196 else
4198 unsigned HOST_WIDE_INT low = d.low;
4199 HOST_WIDE_INT high = d.high;
4200 if (!uns && d.is_negative ())
4202 pp_minus (pp);
4203 high = ~high + !low;
4204 low = -low;
4206 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4207 systems? */
4208 sprintf (pp_buffer (pp)->digit_buffer,
4209 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4210 (unsigned HOST_WIDE_INT) high, low);
4211 pp_string (pp, pp_buffer (pp)->digit_buffer);