[Ada] Missing range check on assignment to bit-packed array
[official-gcc.git] / gcc / tree-pretty-print.c
blob742c2840cd530551af26fd4345317f22d7787aee
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2019 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"
37 #include "fold-const.h"
39 /* Disable warnings about quoting issues in the pp_xxx calls below
40 that (intentionally) don't follow GCC diagnostic conventions. */
41 #if __GNUC__ >= 10
42 # pragma GCC diagnostic push
43 # pragma GCC diagnostic ignored "-Wformat-diag"
44 #endif
46 /* Local functions, macros and variables. */
47 static const char *op_symbol (const_tree);
48 static void pretty_print_string (pretty_printer *, const char*, unsigned);
49 static void newline_and_indent (pretty_printer *, int);
50 static void maybe_init_pretty_print (FILE *);
51 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
52 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
54 #define INDENT(SPACE) do { \
55 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
57 #define NIY do_niy (pp, node, flags)
59 static pretty_printer *tree_pp;
61 /* Try to print something for an unknown tree code. */
63 static void
64 do_niy (pretty_printer *pp, const_tree node, dump_flags_t flags)
66 int i, len;
68 pp_string (pp, "<<< Unknown tree: ");
69 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
71 if (EXPR_P (node))
73 len = TREE_OPERAND_LENGTH (node);
74 for (i = 0; i < len; ++i)
76 newline_and_indent (pp, 2);
77 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
81 pp_string (pp, " >>>");
84 /* Debugging function to print out a generic expression. */
86 DEBUG_FUNCTION void
87 debug_generic_expr (tree t)
89 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
90 fprintf (stderr, "\n");
93 /* Debugging function to print out a generic statement. */
95 DEBUG_FUNCTION void
96 debug_generic_stmt (tree t)
98 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
99 fprintf (stderr, "\n");
102 /* Debugging function to print out a chain of trees . */
104 DEBUG_FUNCTION void
105 debug_tree_chain (tree t)
107 hash_set<tree> seen;
109 while (t)
111 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
112 fprintf (stderr, " ");
113 t = TREE_CHAIN (t);
114 if (seen.add (t))
116 fprintf (stderr, "... [cycled back to ");
117 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
118 fprintf (stderr, "]");
119 break;
122 fprintf (stderr, "\n");
125 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
126 void
127 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
129 maybe_init_pretty_print (file);
130 print_declaration (tree_pp, decl, 2, flags);
131 pp_write_text_to_stream (tree_pp);
134 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
135 to show in the dump. See TDF_* in dumpfile.h. */
137 void
138 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
140 maybe_init_pretty_print (file);
141 dump_generic_node (tree_pp, t, 0, flags, true);
142 pp_newline_and_flush (tree_pp);
145 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
146 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
147 INDENT spaces. */
149 void
150 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
152 int i;
154 maybe_init_pretty_print (file);
156 for (i = 0; i < indent; i++)
157 pp_space (tree_pp);
158 dump_generic_node (tree_pp, t, indent, flags, true);
159 pp_newline_and_flush (tree_pp);
162 /* Print a single expression T on file FILE. FLAGS specifies details to show
163 in the dump. See TDF_* in dumpfile.h. */
165 void
166 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
168 maybe_init_pretty_print (file);
169 dump_generic_node (tree_pp, t, 0, flags, false);
170 pp_flush (tree_pp);
173 /* Print a single expression T to string, and return it. */
175 char *
176 print_generic_expr_to_str (tree t)
178 pretty_printer pp;
179 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
180 return xstrdup (pp_formatted_text (&pp));
183 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
184 in it are replaced with Dxxxx, as long as they are at the start or
185 preceded by $ and at the end or followed by $. See make_fancy_name
186 in tree-sra.c. */
188 static void
189 dump_fancy_name (pretty_printer *pp, tree name)
191 int cnt = 0;
192 int length = IDENTIFIER_LENGTH (name);
193 const char *n = IDENTIFIER_POINTER (name);
196 n = strchr (n, 'D');
197 if (n == NULL)
198 break;
199 if (ISDIGIT (n[1])
200 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
202 int l = 2;
203 while (ISDIGIT (n[l]))
204 l++;
205 if (n[l] == '\0' || n[l] == '$')
207 cnt++;
208 length += 5 - l;
210 n += l;
212 else
213 n++;
215 while (1);
216 if (cnt == 0)
218 pp_tree_identifier (pp, name);
219 return;
222 char *str = XNEWVEC (char, length + 1);
223 char *p = str;
224 const char *q;
225 q = n = IDENTIFIER_POINTER (name);
228 q = strchr (q, 'D');
229 if (q == NULL)
230 break;
231 if (ISDIGIT (q[1])
232 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
234 int l = 2;
235 while (ISDIGIT (q[l]))
236 l++;
237 if (q[l] == '\0' || q[l] == '$')
239 memcpy (p, n, q - n);
240 memcpy (p + (q - n), "Dxxxx", 5);
241 p += (q - n) + 5;
242 n = q + l;
244 q += l;
246 else
247 q++;
249 while (1);
250 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
251 str[length] = '\0';
252 if (pp_translate_identifiers (pp))
254 const char *text = identifier_to_locale (str);
255 pp_append_text (pp, text, text + strlen (text));
257 else
258 pp_append_text (pp, str, str + length);
259 XDELETEVEC (str);
262 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
263 in FLAGS. */
265 static void
266 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
268 tree name = DECL_NAME (node);
269 if (name)
271 if ((flags & TDF_ASMNAME)
272 && HAS_DECL_ASSEMBLER_NAME_P (node)
273 && DECL_ASSEMBLER_NAME_SET_P (node))
274 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
275 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
276 -g might have created more fancy names and their indexes
277 could get out of sync. Usually those should be DECL_IGNORED_P
278 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
279 names, let's hope those never get out of sync after doing the
280 dump_fancy_name sanitization. */
281 else if ((flags & TDF_COMPARE_DEBUG)
282 && DECL_NAMELESS (node)
283 && DECL_IGNORED_P (node))
284 name = NULL_TREE;
285 /* For DECL_NAMELESS names look for embedded uids in the
286 names and sanitize them for TDF_NOUID. */
287 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
288 dump_fancy_name (pp, name);
289 else
290 pp_tree_identifier (pp, name);
292 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
293 if ((flags & TDF_UID) || name == NULL_TREE)
295 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
296 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
297 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
299 if (flags & TDF_NOUID)
300 pp_string (pp, "D#xxxx");
301 else
302 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
304 else
306 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
307 if (flags & TDF_NOUID)
308 pp_printf (pp, "%c.xxxx", c);
309 else
310 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
313 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
315 if (flags & TDF_NOUID)
316 pp_printf (pp, "ptD.xxxx");
317 else
318 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
322 /* Like the above, but used for pretty printing function calls. */
324 static void
325 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
327 if (CONVERT_EXPR_P (node))
328 node = TREE_OPERAND (node, 0);
329 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
330 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
331 else
332 dump_decl_name (pp, node, flags);
335 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
336 FLAGS are as in dump_generic_node. */
338 static void
339 dump_function_declaration (pretty_printer *pp, tree node,
340 int spc, dump_flags_t flags)
342 bool wrote_arg = false;
343 tree arg;
345 pp_space (pp);
346 pp_left_paren (pp);
348 /* Print the argument types. */
349 arg = TYPE_ARG_TYPES (node);
350 while (arg && arg != void_list_node && arg != error_mark_node)
352 if (wrote_arg)
354 pp_comma (pp);
355 pp_space (pp);
357 wrote_arg = true;
358 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
359 arg = TREE_CHAIN (arg);
362 /* Drop the trailing void_type_node if we had any previous argument. */
363 if (arg == void_list_node && !wrote_arg)
364 pp_string (pp, "void");
365 /* Properly dump vararg function types. */
366 else if (!arg && wrote_arg)
367 pp_string (pp, ", ...");
368 /* Avoid printing any arg for unprototyped functions. */
370 pp_right_paren (pp);
373 /* Dump the domain associated with an array. */
375 static void
376 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
378 pp_left_bracket (pp);
379 if (domain)
381 tree min = TYPE_MIN_VALUE (domain);
382 tree max = TYPE_MAX_VALUE (domain);
384 if (min && max
385 && integer_zerop (min)
386 && tree_fits_shwi_p (max))
387 pp_wide_integer (pp, tree_to_shwi (max) + 1);
388 else
390 if (min)
391 dump_generic_node (pp, min, spc, flags, false);
392 pp_colon (pp);
393 if (max)
394 dump_generic_node (pp, max, spc, flags, false);
397 else
398 pp_string (pp, "<unknown>");
399 pp_right_bracket (pp);
403 /* Dump OpenMP iterators ITER. */
405 static void
406 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
408 pp_string (pp, "iterator(");
409 for (tree it = iter; it; it = TREE_CHAIN (it))
411 if (it != iter)
412 pp_string (pp, ", ");
413 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
414 false);
415 pp_space (pp);
416 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
417 pp_equal (pp);
418 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
419 pp_colon (pp);
420 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
421 pp_colon (pp);
422 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
424 pp_right_paren (pp);
428 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
429 dump_generic_node. */
431 static void
432 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
434 const char *name;
436 switch (OMP_CLAUSE_CODE (clause))
438 case OMP_CLAUSE_PRIVATE:
439 name = "private";
440 goto print_remap;
441 case OMP_CLAUSE_SHARED:
442 name = "shared";
443 goto print_remap;
444 case OMP_CLAUSE_FIRSTPRIVATE:
445 name = "firstprivate";
446 goto print_remap;
447 case OMP_CLAUSE_LASTPRIVATE:
448 name = "lastprivate";
449 if (!OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
450 goto print_remap;
451 pp_string (pp, "lastprivate(conditional:");
452 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
453 spc, flags, false);
454 pp_right_paren (pp);
455 break;
456 case OMP_CLAUSE_COPYIN:
457 name = "copyin";
458 goto print_remap;
459 case OMP_CLAUSE_COPYPRIVATE:
460 name = "copyprivate";
461 goto print_remap;
462 case OMP_CLAUSE_UNIFORM:
463 name = "uniform";
464 goto print_remap;
465 case OMP_CLAUSE_USE_DEVICE_PTR:
466 name = "use_device_ptr";
467 goto print_remap;
468 case OMP_CLAUSE_IS_DEVICE_PTR:
469 name = "is_device_ptr";
470 goto print_remap;
471 case OMP_CLAUSE_INCLUSIVE:
472 name = "inclusive";
473 goto print_remap;
474 case OMP_CLAUSE_EXCLUSIVE:
475 name = "exclusive";
476 goto print_remap;
477 case OMP_CLAUSE__LOOPTEMP_:
478 name = "_looptemp_";
479 goto print_remap;
480 case OMP_CLAUSE__REDUCTEMP_:
481 name = "_reductemp_";
482 goto print_remap;
483 case OMP_CLAUSE__CONDTEMP_:
484 name = "_condtemp_";
485 goto print_remap;
486 case OMP_CLAUSE__SCANTEMP_:
487 name = "_scantemp_";
488 goto print_remap;
489 case OMP_CLAUSE_TO_DECLARE:
490 name = "to";
491 goto print_remap;
492 case OMP_CLAUSE_LINK:
493 name = "link";
494 goto print_remap;
495 case OMP_CLAUSE_NONTEMPORAL:
496 name = "nontemporal";
497 goto print_remap;
498 print_remap:
499 pp_string (pp, name);
500 pp_left_paren (pp);
501 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
502 spc, flags, false);
503 pp_right_paren (pp);
504 break;
506 case OMP_CLAUSE_TASK_REDUCTION:
507 case OMP_CLAUSE_IN_REDUCTION:
508 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
509 ? "in_" : "task_");
510 /* FALLTHRU */
511 case OMP_CLAUSE_REDUCTION:
512 pp_string (pp, "reduction(");
513 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
515 if (OMP_CLAUSE_REDUCTION_TASK (clause))
516 pp_string (pp, "task,");
517 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
518 pp_string (pp, "inscan,");
520 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
522 pp_string (pp,
523 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
524 pp_colon (pp);
526 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
527 spc, flags, false);
528 pp_right_paren (pp);
529 break;
531 case OMP_CLAUSE_IF:
532 pp_string (pp, "if(");
533 switch (OMP_CLAUSE_IF_MODIFIER (clause))
535 case ERROR_MARK: break;
536 case VOID_CST: pp_string (pp, "cancel:"); break;
537 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
538 case OMP_SIMD: pp_string (pp, "simd:"); break;
539 case OMP_TASK: pp_string (pp, "task:"); break;
540 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
541 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
542 case OMP_TARGET: pp_string (pp, "target:"); break;
543 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
544 case OMP_TARGET_ENTER_DATA:
545 pp_string (pp, "target enter data:"); break;
546 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
547 default: gcc_unreachable ();
549 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
550 spc, flags, false);
551 pp_right_paren (pp);
552 break;
554 case OMP_CLAUSE_NUM_THREADS:
555 pp_string (pp, "num_threads(");
556 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
557 spc, flags, false);
558 pp_right_paren (pp);
559 break;
561 case OMP_CLAUSE_NOWAIT:
562 pp_string (pp, "nowait");
563 break;
564 case OMP_CLAUSE_ORDERED:
565 pp_string (pp, "ordered");
566 if (OMP_CLAUSE_ORDERED_EXPR (clause))
568 pp_left_paren (pp);
569 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
570 spc, flags, false);
571 pp_right_paren (pp);
573 break;
575 case OMP_CLAUSE_DEFAULT:
576 pp_string (pp, "default(");
577 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
579 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
580 break;
581 case OMP_CLAUSE_DEFAULT_SHARED:
582 pp_string (pp, "shared");
583 break;
584 case OMP_CLAUSE_DEFAULT_NONE:
585 pp_string (pp, "none");
586 break;
587 case OMP_CLAUSE_DEFAULT_PRIVATE:
588 pp_string (pp, "private");
589 break;
590 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
591 pp_string (pp, "firstprivate");
592 break;
593 case OMP_CLAUSE_DEFAULT_PRESENT:
594 pp_string (pp, "present");
595 break;
596 default:
597 gcc_unreachable ();
599 pp_right_paren (pp);
600 break;
602 case OMP_CLAUSE_SCHEDULE:
603 pp_string (pp, "schedule(");
604 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
605 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
606 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
608 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
609 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
610 pp_string (pp, "monotonic");
611 else
612 pp_string (pp, "nonmonotonic");
613 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
614 pp_comma (pp);
615 else
616 pp_colon (pp);
618 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
619 pp_string (pp, "simd:");
621 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
623 case OMP_CLAUSE_SCHEDULE_STATIC:
624 pp_string (pp, "static");
625 break;
626 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
627 pp_string (pp, "dynamic");
628 break;
629 case OMP_CLAUSE_SCHEDULE_GUIDED:
630 pp_string (pp, "guided");
631 break;
632 case OMP_CLAUSE_SCHEDULE_RUNTIME:
633 pp_string (pp, "runtime");
634 break;
635 case OMP_CLAUSE_SCHEDULE_AUTO:
636 pp_string (pp, "auto");
637 break;
638 default:
639 gcc_unreachable ();
641 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
643 pp_comma (pp);
644 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
645 spc, flags, false);
647 pp_right_paren (pp);
648 break;
650 case OMP_CLAUSE_UNTIED:
651 pp_string (pp, "untied");
652 break;
654 case OMP_CLAUSE_COLLAPSE:
655 pp_string (pp, "collapse(");
656 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
657 spc, flags, false);
658 pp_right_paren (pp);
659 break;
661 case OMP_CLAUSE_FINAL:
662 pp_string (pp, "final(");
663 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
664 spc, flags, false);
665 pp_right_paren (pp);
666 break;
668 case OMP_CLAUSE_MERGEABLE:
669 pp_string (pp, "mergeable");
670 break;
672 case OMP_CLAUSE_LINEAR:
673 pp_string (pp, "linear(");
674 switch (OMP_CLAUSE_LINEAR_KIND (clause))
676 case OMP_CLAUSE_LINEAR_DEFAULT:
677 break;
678 case OMP_CLAUSE_LINEAR_REF:
679 pp_string (pp, "ref(");
680 break;
681 case OMP_CLAUSE_LINEAR_VAL:
682 pp_string (pp, "val(");
683 break;
684 case OMP_CLAUSE_LINEAR_UVAL:
685 pp_string (pp, "uval(");
686 break;
687 default:
688 gcc_unreachable ();
690 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
691 spc, flags, false);
692 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
693 pp_right_paren (pp);
694 pp_colon (pp);
695 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
696 spc, flags, false);
697 pp_right_paren (pp);
698 break;
700 case OMP_CLAUSE_ALIGNED:
701 pp_string (pp, "aligned(");
702 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
703 spc, flags, false);
704 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
706 pp_colon (pp);
707 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
708 spc, flags, false);
710 pp_right_paren (pp);
711 break;
713 case OMP_CLAUSE_DEPEND:
714 pp_string (pp, "depend(");
715 switch (OMP_CLAUSE_DEPEND_KIND (clause))
717 case OMP_CLAUSE_DEPEND_DEPOBJ:
718 name = "depobj";
719 break;
720 case OMP_CLAUSE_DEPEND_IN:
721 name = "in";
722 break;
723 case OMP_CLAUSE_DEPEND_OUT:
724 name = "out";
725 break;
726 case OMP_CLAUSE_DEPEND_INOUT:
727 name = "inout";
728 break;
729 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
730 name = "mutexinoutset";
731 break;
732 case OMP_CLAUSE_DEPEND_SOURCE:
733 pp_string (pp, "source)");
734 return;
735 case OMP_CLAUSE_DEPEND_LAST:
736 name = "__internal__";
737 break;
738 case OMP_CLAUSE_DEPEND_SINK:
739 pp_string (pp, "sink:");
740 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
741 if (TREE_CODE (t) == TREE_LIST)
743 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
744 if (TREE_PURPOSE (t) != integer_zero_node)
746 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
747 pp_minus (pp);
748 else
749 pp_plus (pp);
750 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
751 false);
753 if (TREE_CHAIN (t))
754 pp_comma (pp);
756 else
757 gcc_unreachable ();
758 pp_right_paren (pp);
759 return;
760 default:
761 gcc_unreachable ();
764 tree t = OMP_CLAUSE_DECL (clause);
765 if (TREE_CODE (t) == TREE_LIST
766 && TREE_PURPOSE (t)
767 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
769 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
770 pp_colon (pp);
771 t = TREE_VALUE (t);
773 pp_string (pp, name);
774 pp_colon (pp);
775 dump_generic_node (pp, t, spc, flags, false);
776 pp_right_paren (pp);
778 break;
780 case OMP_CLAUSE_MAP:
781 pp_string (pp, "map(");
782 switch (OMP_CLAUSE_MAP_KIND (clause))
784 case GOMP_MAP_ALLOC:
785 case GOMP_MAP_POINTER:
786 pp_string (pp, "alloc");
787 break;
788 case GOMP_MAP_TO:
789 case GOMP_MAP_TO_PSET:
790 pp_string (pp, "to");
791 break;
792 case GOMP_MAP_FROM:
793 pp_string (pp, "from");
794 break;
795 case GOMP_MAP_TOFROM:
796 pp_string (pp, "tofrom");
797 break;
798 case GOMP_MAP_FORCE_ALLOC:
799 pp_string (pp, "force_alloc");
800 break;
801 case GOMP_MAP_FORCE_TO:
802 pp_string (pp, "force_to");
803 break;
804 case GOMP_MAP_FORCE_FROM:
805 pp_string (pp, "force_from");
806 break;
807 case GOMP_MAP_FORCE_TOFROM:
808 pp_string (pp, "force_tofrom");
809 break;
810 case GOMP_MAP_FORCE_PRESENT:
811 pp_string (pp, "force_present");
812 break;
813 case GOMP_MAP_DELETE:
814 pp_string (pp, "delete");
815 break;
816 case GOMP_MAP_FORCE_DEVICEPTR:
817 pp_string (pp, "force_deviceptr");
818 break;
819 case GOMP_MAP_ALWAYS_TO:
820 pp_string (pp, "always,to");
821 break;
822 case GOMP_MAP_ALWAYS_FROM:
823 pp_string (pp, "always,from");
824 break;
825 case GOMP_MAP_ALWAYS_TOFROM:
826 pp_string (pp, "always,tofrom");
827 break;
828 case GOMP_MAP_RELEASE:
829 pp_string (pp, "release");
830 break;
831 case GOMP_MAP_FIRSTPRIVATE_POINTER:
832 pp_string (pp, "firstprivate");
833 break;
834 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
835 pp_string (pp, "firstprivate ref");
836 break;
837 case GOMP_MAP_STRUCT:
838 pp_string (pp, "struct");
839 break;
840 case GOMP_MAP_ALWAYS_POINTER:
841 pp_string (pp, "always_pointer");
842 break;
843 case GOMP_MAP_DEVICE_RESIDENT:
844 pp_string (pp, "device_resident");
845 break;
846 case GOMP_MAP_LINK:
847 pp_string (pp, "link");
848 break;
849 default:
850 gcc_unreachable ();
852 pp_colon (pp);
853 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
854 spc, flags, false);
855 print_clause_size:
856 if (OMP_CLAUSE_SIZE (clause))
858 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
859 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
861 case GOMP_MAP_POINTER:
862 case GOMP_MAP_FIRSTPRIVATE_POINTER:
863 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
864 case GOMP_MAP_ALWAYS_POINTER:
865 pp_string (pp, " [pointer assign, bias: ");
866 break;
867 case GOMP_MAP_TO_PSET:
868 pp_string (pp, " [pointer set, len: ");
869 break;
870 default:
871 pp_string (pp, " [len: ");
872 break;
874 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
875 spc, flags, false);
876 pp_right_bracket (pp);
878 pp_right_paren (pp);
879 break;
881 case OMP_CLAUSE_FROM:
882 pp_string (pp, "from(");
883 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
884 spc, flags, false);
885 goto print_clause_size;
887 case OMP_CLAUSE_TO:
888 pp_string (pp, "to(");
889 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
890 spc, flags, false);
891 goto print_clause_size;
893 case OMP_CLAUSE__CACHE_:
894 pp_string (pp, "(");
895 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
896 spc, flags, false);
897 goto print_clause_size;
899 case OMP_CLAUSE_NUM_TEAMS:
900 pp_string (pp, "num_teams(");
901 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
902 spc, flags, false);
903 pp_right_paren (pp);
904 break;
906 case OMP_CLAUSE_THREAD_LIMIT:
907 pp_string (pp, "thread_limit(");
908 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
909 spc, flags, false);
910 pp_right_paren (pp);
911 break;
913 case OMP_CLAUSE_DEVICE:
914 pp_string (pp, "device(");
915 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
916 spc, flags, false);
917 pp_right_paren (pp);
918 break;
920 case OMP_CLAUSE_DIST_SCHEDULE:
921 pp_string (pp, "dist_schedule(static");
922 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
924 pp_comma (pp);
925 dump_generic_node (pp,
926 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
927 spc, flags, false);
929 pp_right_paren (pp);
930 break;
932 case OMP_CLAUSE_PROC_BIND:
933 pp_string (pp, "proc_bind(");
934 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
936 case OMP_CLAUSE_PROC_BIND_MASTER:
937 pp_string (pp, "master");
938 break;
939 case OMP_CLAUSE_PROC_BIND_CLOSE:
940 pp_string (pp, "close");
941 break;
942 case OMP_CLAUSE_PROC_BIND_SPREAD:
943 pp_string (pp, "spread");
944 break;
945 default:
946 gcc_unreachable ();
948 pp_right_paren (pp);
949 break;
951 case OMP_CLAUSE_SAFELEN:
952 pp_string (pp, "safelen(");
953 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
954 spc, flags, false);
955 pp_right_paren (pp);
956 break;
958 case OMP_CLAUSE_SIMDLEN:
959 pp_string (pp, "simdlen(");
960 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
961 spc, flags, false);
962 pp_right_paren (pp);
963 break;
965 case OMP_CLAUSE_PRIORITY:
966 pp_string (pp, "priority(");
967 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
968 spc, flags, false);
969 pp_right_paren (pp);
970 break;
972 case OMP_CLAUSE_GRAINSIZE:
973 pp_string (pp, "grainsize(");
974 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
975 spc, flags, false);
976 pp_right_paren (pp);
977 break;
979 case OMP_CLAUSE_NUM_TASKS:
980 pp_string (pp, "num_tasks(");
981 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
982 spc, flags, false);
983 pp_right_paren (pp);
984 break;
986 case OMP_CLAUSE_HINT:
987 pp_string (pp, "hint(");
988 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
989 spc, flags, false);
990 pp_right_paren (pp);
991 break;
993 case OMP_CLAUSE_DEFAULTMAP:
994 pp_string (pp, "defaultmap(");
995 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
997 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
998 pp_string (pp, "alloc");
999 break;
1000 case OMP_CLAUSE_DEFAULTMAP_TO:
1001 pp_string (pp, "to");
1002 break;
1003 case OMP_CLAUSE_DEFAULTMAP_FROM:
1004 pp_string (pp, "from");
1005 break;
1006 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1007 pp_string (pp, "tofrom");
1008 break;
1009 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1010 pp_string (pp, "firstprivate");
1011 break;
1012 case OMP_CLAUSE_DEFAULTMAP_NONE:
1013 pp_string (pp, "none");
1014 break;
1015 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1016 pp_string (pp, "default");
1017 break;
1018 default:
1019 gcc_unreachable ();
1021 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1023 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1024 break;
1025 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1026 pp_string (pp, ":scalar");
1027 break;
1028 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1029 pp_string (pp, ":aggregate");
1030 break;
1031 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1032 pp_string (pp, ":allocatable");
1033 break;
1034 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1035 pp_string (pp, ":pointer");
1036 break;
1037 default:
1038 gcc_unreachable ();
1040 pp_right_paren (pp);
1041 break;
1043 case OMP_CLAUSE__SIMDUID_:
1044 pp_string (pp, "_simduid_(");
1045 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1046 spc, flags, false);
1047 pp_right_paren (pp);
1048 break;
1050 case OMP_CLAUSE__SIMT_:
1051 pp_string (pp, "_simt_");
1052 break;
1054 case OMP_CLAUSE_GANG:
1055 pp_string (pp, "gang");
1056 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1058 pp_string (pp, "(num: ");
1059 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1060 spc, flags, false);
1062 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1064 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1065 pp_left_paren (pp);
1066 else
1067 pp_space (pp);
1068 pp_string (pp, "static:");
1069 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1070 == integer_minus_one_node)
1071 pp_character (pp, '*');
1072 else
1073 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1074 spc, flags, false);
1076 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1077 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1078 pp_right_paren (pp);
1079 break;
1081 case OMP_CLAUSE_ASYNC:
1082 pp_string (pp, "async");
1083 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1085 pp_character(pp, '(');
1086 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1087 spc, flags, false);
1088 pp_character(pp, ')');
1090 break;
1092 case OMP_CLAUSE_AUTO:
1093 case OMP_CLAUSE_SEQ:
1094 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1095 break;
1097 case OMP_CLAUSE_WAIT:
1098 pp_string (pp, "wait(");
1099 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1100 spc, flags, false);
1101 pp_character(pp, ')');
1102 break;
1104 case OMP_CLAUSE_WORKER:
1105 pp_string (pp, "worker");
1106 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1108 pp_left_paren (pp);
1109 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1110 spc, flags, false);
1111 pp_right_paren (pp);
1113 break;
1115 case OMP_CLAUSE_VECTOR:
1116 pp_string (pp, "vector");
1117 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1119 pp_left_paren (pp);
1120 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1121 spc, flags, false);
1122 pp_right_paren (pp);
1124 break;
1126 case OMP_CLAUSE_NUM_GANGS:
1127 pp_string (pp, "num_gangs(");
1128 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1129 spc, flags, false);
1130 pp_character (pp, ')');
1131 break;
1133 case OMP_CLAUSE_NUM_WORKERS:
1134 pp_string (pp, "num_workers(");
1135 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1136 spc, flags, false);
1137 pp_character (pp, ')');
1138 break;
1140 case OMP_CLAUSE_VECTOR_LENGTH:
1141 pp_string (pp, "vector_length(");
1142 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1143 spc, flags, false);
1144 pp_character (pp, ')');
1145 break;
1147 case OMP_CLAUSE_INBRANCH:
1148 pp_string (pp, "inbranch");
1149 break;
1150 case OMP_CLAUSE_NOTINBRANCH:
1151 pp_string (pp, "notinbranch");
1152 break;
1153 case OMP_CLAUSE_FOR:
1154 pp_string (pp, "for");
1155 break;
1156 case OMP_CLAUSE_PARALLEL:
1157 pp_string (pp, "parallel");
1158 break;
1159 case OMP_CLAUSE_SECTIONS:
1160 pp_string (pp, "sections");
1161 break;
1162 case OMP_CLAUSE_TASKGROUP:
1163 pp_string (pp, "taskgroup");
1164 break;
1165 case OMP_CLAUSE_NOGROUP:
1166 pp_string (pp, "nogroup");
1167 break;
1168 case OMP_CLAUSE_THREADS:
1169 pp_string (pp, "threads");
1170 break;
1171 case OMP_CLAUSE_SIMD:
1172 pp_string (pp, "simd");
1173 break;
1174 case OMP_CLAUSE_INDEPENDENT:
1175 pp_string (pp, "independent");
1176 break;
1177 case OMP_CLAUSE_TILE:
1178 pp_string (pp, "tile(");
1179 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1180 spc, flags, false);
1181 pp_right_paren (pp);
1182 break;
1184 case OMP_CLAUSE__GRIDDIM_:
1185 pp_string (pp, "_griddim_(");
1186 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1187 pp_colon (pp);
1188 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1189 false);
1190 pp_comma (pp);
1191 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1192 false);
1193 pp_right_paren (pp);
1194 break;
1195 case OMP_CLAUSE_IF_PRESENT:
1196 pp_string (pp, "if_present");
1197 break;
1198 case OMP_CLAUSE_FINALIZE:
1199 pp_string (pp, "finalize");
1200 break;
1202 default:
1203 gcc_unreachable ();
1208 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1209 dump_generic_node. */
1211 void
1212 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1214 if (clause == NULL)
1215 return;
1217 pp_space (pp);
1218 while (1)
1220 dump_omp_clause (pp, clause, spc, flags);
1221 clause = OMP_CLAUSE_CHAIN (clause);
1222 if (clause == NULL)
1223 return;
1224 pp_space (pp);
1229 /* Dump location LOC to PP. */
1231 void
1232 dump_location (pretty_printer *pp, location_t loc)
1234 expanded_location xloc = expand_location (loc);
1236 pp_left_bracket (pp);
1237 if (xloc.file)
1239 pp_string (pp, xloc.file);
1240 pp_string (pp, ":");
1242 pp_decimal_int (pp, xloc.line);
1243 pp_colon (pp);
1244 pp_decimal_int (pp, xloc.column);
1245 pp_string (pp, "] ");
1249 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1250 dump_generic_node. */
1252 static void
1253 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1255 tree t;
1257 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1259 if (flags & TDF_ADDRESS)
1260 pp_printf (pp, "[%p] ", (void *) block);
1262 if (TREE_ASM_WRITTEN (block))
1263 pp_string (pp, "[written] ");
1265 if (flags & TDF_SLIM)
1266 return;
1268 if (BLOCK_SOURCE_LOCATION (block))
1269 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1271 newline_and_indent (pp, spc + 2);
1273 if (BLOCK_SUPERCONTEXT (block))
1275 pp_string (pp, "SUPERCONTEXT: ");
1276 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1277 flags | TDF_SLIM, false);
1278 newline_and_indent (pp, spc + 2);
1281 if (BLOCK_SUBBLOCKS (block))
1283 pp_string (pp, "SUBBLOCKS: ");
1284 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1286 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1287 pp_space (pp);
1289 newline_and_indent (pp, spc + 2);
1292 if (BLOCK_CHAIN (block))
1294 pp_string (pp, "SIBLINGS: ");
1295 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1297 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1298 pp_space (pp);
1300 newline_and_indent (pp, spc + 2);
1303 if (BLOCK_VARS (block))
1305 pp_string (pp, "VARS: ");
1306 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1308 dump_generic_node (pp, t, 0, flags, false);
1309 pp_space (pp);
1311 newline_and_indent (pp, spc + 2);
1314 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1316 unsigned i;
1317 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1319 pp_string (pp, "NONLOCALIZED_VARS: ");
1320 FOR_EACH_VEC_ELT (*nlv, i, t)
1322 dump_generic_node (pp, t, 0, flags, false);
1323 pp_space (pp);
1325 newline_and_indent (pp, spc + 2);
1328 if (BLOCK_ABSTRACT_ORIGIN (block))
1330 pp_string (pp, "ABSTRACT_ORIGIN: ");
1331 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1332 flags | TDF_SLIM, false);
1333 newline_and_indent (pp, spc + 2);
1336 if (BLOCK_FRAGMENT_ORIGIN (block))
1338 pp_string (pp, "FRAGMENT_ORIGIN: ");
1339 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1340 flags | TDF_SLIM, false);
1341 newline_and_indent (pp, spc + 2);
1344 if (BLOCK_FRAGMENT_CHAIN (block))
1346 pp_string (pp, "FRAGMENT_CHAIN: ");
1347 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1349 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1350 pp_space (pp);
1352 newline_and_indent (pp, spc + 2);
1356 /* Dump #pragma omp atomic memory order clause. */
1358 void
1359 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1361 switch (mo)
1363 case OMP_MEMORY_ORDER_RELAXED:
1364 pp_string (pp, " relaxed");
1365 break;
1366 case OMP_MEMORY_ORDER_SEQ_CST:
1367 pp_string (pp, " seq_cst");
1368 break;
1369 case OMP_MEMORY_ORDER_ACQ_REL:
1370 pp_string (pp, " acq_rel");
1371 break;
1372 case OMP_MEMORY_ORDER_ACQUIRE:
1373 pp_string (pp, " acquire");
1374 break;
1375 case OMP_MEMORY_ORDER_RELEASE:
1376 pp_string (pp, " release");
1377 break;
1378 case OMP_MEMORY_ORDER_UNSPECIFIED:
1379 break;
1380 default:
1381 gcc_unreachable ();
1385 /* Helper to dump a MEM_REF node. */
1387 static void
1388 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1390 if (flags & TDF_GIMPLE)
1392 pp_string (pp, "__MEM <");
1393 dump_generic_node (pp, TREE_TYPE (node),
1394 spc, flags | TDF_SLIM, false);
1395 if (TYPE_ALIGN (TREE_TYPE (node))
1396 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1398 pp_string (pp, ", ");
1399 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1401 pp_greater (pp);
1402 pp_string (pp, " (");
1403 if (TREE_TYPE (TREE_OPERAND (node, 0))
1404 != TREE_TYPE (TREE_OPERAND (node, 1)))
1406 pp_left_paren (pp);
1407 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1408 spc, flags | TDF_SLIM, false);
1409 pp_right_paren (pp);
1411 dump_generic_node (pp, TREE_OPERAND (node, 0),
1412 spc, flags | TDF_SLIM, false);
1413 if (! integer_zerop (TREE_OPERAND (node, 1)))
1415 pp_string (pp, " + ");
1416 dump_generic_node (pp, TREE_OPERAND (node, 1),
1417 spc, flags | TDF_SLIM, false);
1419 pp_right_paren (pp);
1421 else if (integer_zerop (TREE_OPERAND (node, 1))
1422 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1423 infer them and MEM_ATTR caching will share MEM_REFs
1424 with differently-typed op0s. */
1425 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1426 /* Released SSA_NAMES have no TREE_TYPE. */
1427 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1428 /* Same pointer types, but ignoring POINTER_TYPE vs.
1429 REFERENCE_TYPE. */
1430 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1431 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1432 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1433 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1434 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1435 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1436 /* Same value types ignoring qualifiers. */
1437 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1438 == TYPE_MAIN_VARIANT
1439 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1440 && (!(flags & TDF_ALIAS)
1441 || MR_DEPENDENCE_CLIQUE (node) == 0))
1443 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1445 /* Enclose pointers to arrays in parentheses. */
1446 tree op0 = TREE_OPERAND (node, 0);
1447 tree op0type = TREE_TYPE (op0);
1448 if (POINTER_TYPE_P (op0type)
1449 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1450 pp_left_paren (pp);
1451 pp_star (pp);
1452 dump_generic_node (pp, op0, spc, flags, false);
1453 if (POINTER_TYPE_P (op0type)
1454 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1455 pp_right_paren (pp);
1457 else
1458 dump_generic_node (pp,
1459 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1460 spc, flags, false);
1462 else
1464 pp_string (pp, "MEM");
1466 tree nodetype = TREE_TYPE (node);
1467 tree op0 = TREE_OPERAND (node, 0);
1468 tree op1 = TREE_OPERAND (node, 1);
1469 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1471 tree op0size = TYPE_SIZE (nodetype);
1472 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1474 if (!op0size || !op1size
1475 || !operand_equal_p (op0size, op1size, 0))
1477 pp_string (pp, " <");
1478 /* If the size of the type of the operand is not the same
1479 as the size of the MEM_REF expression include the type
1480 of the latter similar to the TDF_GIMPLE output to make
1481 it clear how many bytes of memory are being accessed. */
1482 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1483 pp_string (pp, "> ");
1486 pp_string (pp, "[(");
1487 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1488 pp_right_paren (pp);
1489 dump_generic_node (pp, op0, spc, flags, false);
1490 if (!integer_zerop (op1))
1491 if (!integer_zerop (TREE_OPERAND (node, 1)))
1493 pp_string (pp, " + ");
1494 dump_generic_node (pp, op1, spc, flags, false);
1496 if ((flags & TDF_ALIAS)
1497 && MR_DEPENDENCE_CLIQUE (node) != 0)
1499 pp_string (pp, " clique ");
1500 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1501 pp_string (pp, " base ");
1502 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1504 pp_right_bracket (pp);
1508 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1509 indent. FLAGS specifies details to show in the dump (see TDF_* in
1510 dumpfile.h). If IS_STMT is true, the object printed is considered
1511 to be a statement and it is terminated by ';' if appropriate. */
1514 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1515 bool is_stmt)
1517 tree type;
1518 tree op0, op1;
1519 const char *str;
1520 bool is_expr;
1521 enum tree_code code;
1523 if (node == NULL_TREE)
1524 return spc;
1526 is_expr = EXPR_P (node);
1528 if (is_stmt && (flags & TDF_STMTADDR))
1529 pp_printf (pp, "<&%p> ", (void *)node);
1531 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1532 dump_location (pp, EXPR_LOCATION (node));
1534 code = TREE_CODE (node);
1535 switch (code)
1537 case ERROR_MARK:
1538 pp_string (pp, "<<< error >>>");
1539 break;
1541 case IDENTIFIER_NODE:
1542 pp_tree_identifier (pp, node);
1543 break;
1545 case TREE_LIST:
1546 while (node && node != error_mark_node)
1548 if (TREE_PURPOSE (node))
1550 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1551 pp_space (pp);
1553 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1554 node = TREE_CHAIN (node);
1555 if (node && TREE_CODE (node) == TREE_LIST)
1557 pp_comma (pp);
1558 pp_space (pp);
1561 break;
1563 case TREE_BINFO:
1564 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1565 break;
1567 case TREE_VEC:
1569 size_t i;
1570 if (TREE_VEC_LENGTH (node) > 0)
1572 size_t len = TREE_VEC_LENGTH (node);
1573 for (i = 0; i < len - 1; i++)
1575 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1576 false);
1577 pp_comma (pp);
1578 pp_space (pp);
1580 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1581 flags, false);
1584 break;
1586 case VOID_TYPE:
1587 case INTEGER_TYPE:
1588 case REAL_TYPE:
1589 case FIXED_POINT_TYPE:
1590 case COMPLEX_TYPE:
1591 case VECTOR_TYPE:
1592 case ENUMERAL_TYPE:
1593 case BOOLEAN_TYPE:
1595 unsigned int quals = TYPE_QUALS (node);
1596 enum tree_code_class tclass;
1598 if (quals & TYPE_QUAL_ATOMIC)
1599 pp_string (pp, "atomic ");
1600 if (quals & TYPE_QUAL_CONST)
1601 pp_string (pp, "const ");
1602 else if (quals & TYPE_QUAL_VOLATILE)
1603 pp_string (pp, "volatile ");
1604 else if (quals & TYPE_QUAL_RESTRICT)
1605 pp_string (pp, "restrict ");
1607 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1609 pp_string (pp, "<address-space-");
1610 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1611 pp_string (pp, "> ");
1614 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1616 if (tclass == tcc_declaration)
1618 if (DECL_NAME (node))
1619 dump_decl_name (pp, node, flags);
1620 else
1621 pp_string (pp, "<unnamed type decl>");
1623 else if (tclass == tcc_type)
1625 if (TYPE_NAME (node))
1627 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1628 pp_tree_identifier (pp, TYPE_NAME (node));
1629 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1630 && DECL_NAME (TYPE_NAME (node)))
1631 dump_decl_name (pp, TYPE_NAME (node), flags);
1632 else
1633 pp_string (pp, "<unnamed type>");
1635 else if (TREE_CODE (node) == VECTOR_TYPE)
1637 pp_string (pp, "vector");
1638 pp_left_paren (pp);
1639 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1640 pp_string (pp, ") ");
1641 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1643 else if (TREE_CODE (node) == INTEGER_TYPE)
1645 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1646 pp_string (pp, (TYPE_UNSIGNED (node)
1647 ? "unsigned char"
1648 : "signed char"));
1649 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1650 pp_string (pp, (TYPE_UNSIGNED (node)
1651 ? "unsigned short"
1652 : "signed short"));
1653 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1654 pp_string (pp, (TYPE_UNSIGNED (node)
1655 ? "unsigned int"
1656 : "signed int"));
1657 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1658 pp_string (pp, (TYPE_UNSIGNED (node)
1659 ? "unsigned long"
1660 : "signed long"));
1661 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1662 pp_string (pp, (TYPE_UNSIGNED (node)
1663 ? "unsigned long long"
1664 : "signed long long"));
1665 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1666 && pow2p_hwi (TYPE_PRECISION (node)))
1668 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1669 pp_decimal_int (pp, TYPE_PRECISION (node));
1670 pp_string (pp, "_t");
1672 else
1674 pp_string (pp, (TYPE_UNSIGNED (node)
1675 ? "<unnamed-unsigned:"
1676 : "<unnamed-signed:"));
1677 pp_decimal_int (pp, TYPE_PRECISION (node));
1678 pp_greater (pp);
1681 else if (TREE_CODE (node) == COMPLEX_TYPE)
1683 pp_string (pp, "__complex__ ");
1684 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1686 else if (TREE_CODE (node) == REAL_TYPE)
1688 pp_string (pp, "<float:");
1689 pp_decimal_int (pp, TYPE_PRECISION (node));
1690 pp_greater (pp);
1692 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1694 pp_string (pp, "<fixed-point-");
1695 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1696 pp_decimal_int (pp, TYPE_PRECISION (node));
1697 pp_greater (pp);
1699 else if (TREE_CODE (node) == VOID_TYPE)
1700 pp_string (pp, "void");
1701 else
1702 pp_string (pp, "<unnamed type>");
1704 break;
1707 case POINTER_TYPE:
1708 case REFERENCE_TYPE:
1709 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1711 if (TREE_TYPE (node) == NULL)
1713 pp_string (pp, str);
1714 pp_string (pp, "<null type>");
1716 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1718 tree fnode = TREE_TYPE (node);
1720 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1721 pp_space (pp);
1722 pp_left_paren (pp);
1723 pp_string (pp, str);
1724 if (TYPE_IDENTIFIER (node))
1725 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1726 else if (flags & TDF_NOUID)
1727 pp_printf (pp, "<Txxxx>");
1728 else
1729 pp_printf (pp, "<T%x>", TYPE_UID (node));
1731 pp_right_paren (pp);
1732 dump_function_declaration (pp, fnode, spc, flags);
1734 else
1736 unsigned int quals = TYPE_QUALS (node);
1738 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1739 pp_space (pp);
1740 pp_string (pp, str);
1742 if (quals & TYPE_QUAL_CONST)
1743 pp_string (pp, " const");
1744 if (quals & TYPE_QUAL_VOLATILE)
1745 pp_string (pp, " volatile");
1746 if (quals & TYPE_QUAL_RESTRICT)
1747 pp_string (pp, " restrict");
1749 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1751 pp_string (pp, " <address-space-");
1752 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1753 pp_greater (pp);
1756 if (TYPE_REF_CAN_ALIAS_ALL (node))
1757 pp_string (pp, " {ref-all}");
1759 break;
1761 case OFFSET_TYPE:
1762 NIY;
1763 break;
1765 case MEM_REF:
1766 dump_mem_ref (pp, node, spc, flags);
1767 break;
1769 case TARGET_MEM_REF:
1771 const char *sep = "";
1772 tree tmp;
1774 pp_string (pp, "MEM[");
1776 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1778 pp_string (pp, sep);
1779 sep = ", ";
1780 pp_string (pp, "symbol: ");
1781 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1782 spc, flags, false);
1784 else
1786 pp_string (pp, sep);
1787 sep = ", ";
1788 pp_string (pp, "base: ");
1789 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1791 tmp = TMR_INDEX2 (node);
1792 if (tmp)
1794 pp_string (pp, sep);
1795 sep = ", ";
1796 pp_string (pp, "base: ");
1797 dump_generic_node (pp, tmp, spc, flags, false);
1799 tmp = TMR_INDEX (node);
1800 if (tmp)
1802 pp_string (pp, sep);
1803 sep = ", ";
1804 pp_string (pp, "index: ");
1805 dump_generic_node (pp, tmp, spc, flags, false);
1807 tmp = TMR_STEP (node);
1808 if (tmp)
1810 pp_string (pp, sep);
1811 sep = ", ";
1812 pp_string (pp, "step: ");
1813 dump_generic_node (pp, tmp, spc, flags, false);
1815 tmp = TMR_OFFSET (node);
1816 if (tmp)
1818 pp_string (pp, sep);
1819 sep = ", ";
1820 pp_string (pp, "offset: ");
1821 dump_generic_node (pp, tmp, spc, flags, false);
1823 pp_right_bracket (pp);
1825 break;
1827 case ARRAY_TYPE:
1829 tree tmp;
1831 /* Print the innermost component type. */
1832 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1833 tmp = TREE_TYPE (tmp))
1835 dump_generic_node (pp, tmp, spc, flags, false);
1837 /* Print the dimensions. */
1838 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1839 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1840 break;
1843 case RECORD_TYPE:
1844 case UNION_TYPE:
1845 case QUAL_UNION_TYPE:
1847 unsigned int quals = TYPE_QUALS (node);
1849 if (quals & TYPE_QUAL_ATOMIC)
1850 pp_string (pp, "atomic ");
1851 if (quals & TYPE_QUAL_CONST)
1852 pp_string (pp, "const ");
1853 if (quals & TYPE_QUAL_VOLATILE)
1854 pp_string (pp, "volatile ");
1856 /* Print the name of the structure. */
1857 if (TREE_CODE (node) == RECORD_TYPE)
1858 pp_string (pp, "struct ");
1859 else if (TREE_CODE (node) == UNION_TYPE)
1860 pp_string (pp, "union ");
1862 if (TYPE_NAME (node))
1863 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1864 else if (!(flags & TDF_SLIM))
1865 /* FIXME: If we eliminate the 'else' above and attempt
1866 to show the fields for named types, we may get stuck
1867 following a cycle of pointers to structs. The alleged
1868 self-reference check in print_struct_decl will not detect
1869 cycles involving more than one pointer or struct type. */
1870 print_struct_decl (pp, node, spc, flags);
1871 break;
1874 case LANG_TYPE:
1875 NIY;
1876 break;
1878 case INTEGER_CST:
1879 if (flags & TDF_GIMPLE
1880 && (POINTER_TYPE_P (TREE_TYPE (node))
1881 || (TYPE_PRECISION (TREE_TYPE (node))
1882 < TYPE_PRECISION (integer_type_node))
1883 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
1884 || tree_int_cst_sgn (node) < 0))
1886 pp_string (pp, "_Literal (");
1887 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1888 pp_string (pp, ") ");
1890 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1891 && ! (flags & TDF_GIMPLE))
1893 /* In the case of a pointer, one may want to divide by the
1894 size of the pointed-to type. Unfortunately, this not
1895 straightforward. The C front-end maps expressions
1897 (int *) 5
1898 int *p; (p + 5)
1900 in such a way that the two INTEGER_CST nodes for "5" have
1901 different values but identical types. In the latter
1902 case, the 5 is multiplied by sizeof (int) in c-common.c
1903 (pointer_int_sum) to convert it to a byte address, and
1904 yet the type of the node is left unchanged. Argh. What
1905 is consistent though is that the number value corresponds
1906 to bytes (UNITS) offset.
1908 NB: Neither of the following divisors can be trivially
1909 used to recover the original literal:
1911 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1912 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1913 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1914 pp_string (pp, "B"); /* pseudo-unit */
1916 else if (tree_fits_shwi_p (node))
1917 pp_wide_integer (pp, tree_to_shwi (node));
1918 else if (tree_fits_uhwi_p (node))
1919 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1920 else
1922 wide_int val = wi::to_wide (node);
1924 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1926 pp_minus (pp);
1927 val = -val;
1929 print_hex (val, pp_buffer (pp)->digit_buffer);
1930 pp_string (pp, pp_buffer (pp)->digit_buffer);
1932 if ((flags & TDF_GIMPLE)
1933 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1934 || (TYPE_PRECISION (TREE_TYPE (node))
1935 < TYPE_PRECISION (integer_type_node))
1936 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1938 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1939 pp_character (pp, 'u');
1940 if (TYPE_PRECISION (TREE_TYPE (node))
1941 == TYPE_PRECISION (unsigned_type_node))
1943 else if (TYPE_PRECISION (TREE_TYPE (node))
1944 == TYPE_PRECISION (long_unsigned_type_node))
1945 pp_character (pp, 'l');
1946 else if (TYPE_PRECISION (TREE_TYPE (node))
1947 == TYPE_PRECISION (long_long_unsigned_type_node))
1948 pp_string (pp, "ll");
1950 if (TREE_OVERFLOW (node))
1951 pp_string (pp, "(OVF)");
1952 break;
1954 case POLY_INT_CST:
1955 pp_string (pp, "POLY_INT_CST [");
1956 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
1957 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
1959 pp_string (pp, ", ");
1960 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
1961 spc, flags, false);
1963 pp_string (pp, "]");
1964 break;
1966 case REAL_CST:
1967 /* Code copied from print_node. */
1969 REAL_VALUE_TYPE d;
1970 if (TREE_OVERFLOW (node))
1971 pp_string (pp, " overflow");
1973 d = TREE_REAL_CST (node);
1974 if (REAL_VALUE_ISINF (d))
1975 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1976 else if (REAL_VALUE_ISNAN (d))
1977 pp_string (pp, " Nan");
1978 else
1980 char string[100];
1981 real_to_decimal (string, &d, sizeof (string), 0, 1);
1982 pp_string (pp, string);
1984 break;
1987 case FIXED_CST:
1989 char string[100];
1990 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1991 pp_string (pp, string);
1992 break;
1995 case COMPLEX_CST:
1996 pp_string (pp, "__complex__ (");
1997 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1998 pp_string (pp, ", ");
1999 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2000 pp_right_paren (pp);
2001 break;
2003 case STRING_CST:
2005 pp_string (pp, "\"");
2006 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2007 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2008 pp_string (pp, "\"");
2009 break;
2012 case VECTOR_CST:
2014 unsigned i;
2015 pp_string (pp, "{ ");
2016 unsigned HOST_WIDE_INT nunits;
2017 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2018 nunits = vector_cst_encoded_nelts (node);
2019 for (i = 0; i < nunits; ++i)
2021 if (i != 0)
2022 pp_string (pp, ", ");
2023 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2024 spc, flags, false);
2026 if (!VECTOR_CST_NELTS (node).is_constant ())
2027 pp_string (pp, ", ...");
2028 pp_string (pp, " }");
2030 break;
2032 case FUNCTION_TYPE:
2033 case METHOD_TYPE:
2034 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2035 pp_space (pp);
2036 if (TREE_CODE (node) == METHOD_TYPE)
2038 if (TYPE_METHOD_BASETYPE (node))
2039 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2040 spc, flags, false);
2041 else
2042 pp_string (pp, "<null method basetype>");
2043 pp_colon_colon (pp);
2045 if (TYPE_IDENTIFIER (node))
2046 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2047 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2048 dump_decl_name (pp, TYPE_NAME (node), flags);
2049 else if (flags & TDF_NOUID)
2050 pp_printf (pp, "<Txxxx>");
2051 else
2052 pp_printf (pp, "<T%x>", TYPE_UID (node));
2053 dump_function_declaration (pp, node, spc, flags);
2054 break;
2056 case FUNCTION_DECL:
2057 case CONST_DECL:
2058 dump_decl_name (pp, node, flags);
2059 break;
2061 case LABEL_DECL:
2062 if (DECL_NAME (node))
2063 dump_decl_name (pp, node, flags);
2064 else if (LABEL_DECL_UID (node) != -1)
2066 if (flags & TDF_GIMPLE)
2067 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
2068 else
2069 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
2071 else
2073 if (flags & TDF_NOUID)
2074 pp_string (pp, "<D.xxxx>");
2075 else
2077 if (flags & TDF_GIMPLE)
2078 pp_printf (pp, "<D%u>", DECL_UID (node));
2079 else
2080 pp_printf (pp, "<D.%u>", DECL_UID (node));
2083 break;
2085 case TYPE_DECL:
2086 if (DECL_IS_BUILTIN (node))
2088 /* Don't print the declaration of built-in types. */
2089 break;
2091 if (DECL_NAME (node))
2092 dump_decl_name (pp, node, flags);
2093 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2095 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2096 ? "union" : "struct "));
2097 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2099 else
2100 pp_string (pp, "<anon>");
2101 break;
2103 case VAR_DECL:
2104 case PARM_DECL:
2105 case FIELD_DECL:
2106 case DEBUG_EXPR_DECL:
2107 case NAMESPACE_DECL:
2108 case NAMELIST_DECL:
2109 dump_decl_name (pp, node, flags);
2110 break;
2112 case RESULT_DECL:
2113 pp_string (pp, "<retval>");
2114 break;
2116 case COMPONENT_REF:
2117 op0 = TREE_OPERAND (node, 0);
2118 str = ".";
2119 if (op0
2120 && (TREE_CODE (op0) == INDIRECT_REF
2121 || (TREE_CODE (op0) == MEM_REF
2122 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2123 && integer_zerop (TREE_OPERAND (op0, 1))
2124 /* Dump the types of INTEGER_CSTs explicitly, for we
2125 can't infer them and MEM_ATTR caching will share
2126 MEM_REFs with differently-typed op0s. */
2127 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2128 /* Released SSA_NAMES have no TREE_TYPE. */
2129 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2130 /* Same pointer types, but ignoring POINTER_TYPE vs.
2131 REFERENCE_TYPE. */
2132 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2133 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2134 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2135 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2136 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2137 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2138 /* Same value types ignoring qualifiers. */
2139 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2140 == TYPE_MAIN_VARIANT
2141 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2142 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2144 op0 = TREE_OPERAND (op0, 0);
2145 str = "->";
2147 if (op_prio (op0) < op_prio (node))
2148 pp_left_paren (pp);
2149 dump_generic_node (pp, op0, spc, flags, false);
2150 if (op_prio (op0) < op_prio (node))
2151 pp_right_paren (pp);
2152 pp_string (pp, str);
2153 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2154 op0 = component_ref_field_offset (node);
2155 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2157 pp_string (pp, "{off: ");
2158 dump_generic_node (pp, op0, spc, flags, false);
2159 pp_right_brace (pp);
2161 break;
2163 case BIT_FIELD_REF:
2164 if (flags & TDF_GIMPLE)
2166 pp_string (pp, "__BIT_FIELD_REF <");
2167 dump_generic_node (pp, TREE_TYPE (node),
2168 spc, flags | TDF_SLIM, false);
2169 if (TYPE_ALIGN (TREE_TYPE (node))
2170 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2172 pp_string (pp, ", ");
2173 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2175 pp_greater (pp);
2176 pp_string (pp, " (");
2177 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2178 flags | TDF_SLIM, false);
2179 pp_string (pp, ", ");
2180 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2181 flags | TDF_SLIM, false);
2182 pp_string (pp, ", ");
2183 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2184 flags | TDF_SLIM, false);
2185 pp_right_paren (pp);
2187 else
2189 pp_string (pp, "BIT_FIELD_REF <");
2190 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2191 pp_string (pp, ", ");
2192 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2193 pp_string (pp, ", ");
2194 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2195 pp_greater (pp);
2197 break;
2199 case BIT_INSERT_EXPR:
2200 pp_string (pp, "BIT_INSERT_EXPR <");
2201 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2202 pp_string (pp, ", ");
2203 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2204 pp_string (pp, ", ");
2205 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2206 pp_string (pp, " (");
2207 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2208 pp_decimal_int (pp,
2209 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2210 else
2211 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2212 spc, flags, false);
2213 pp_string (pp, " bits)>");
2214 break;
2216 case ARRAY_REF:
2217 case ARRAY_RANGE_REF:
2218 op0 = TREE_OPERAND (node, 0);
2219 if (op_prio (op0) < op_prio (node))
2220 pp_left_paren (pp);
2221 dump_generic_node (pp, op0, spc, flags, false);
2222 if (op_prio (op0) < op_prio (node))
2223 pp_right_paren (pp);
2224 pp_left_bracket (pp);
2225 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2226 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2227 pp_string (pp, " ...");
2228 pp_right_bracket (pp);
2230 op0 = array_ref_low_bound (node);
2231 op1 = array_ref_element_size (node);
2233 if (!integer_zerop (op0)
2234 || TREE_OPERAND (node, 2)
2235 || TREE_OPERAND (node, 3))
2237 pp_string (pp, "{lb: ");
2238 dump_generic_node (pp, op0, spc, flags, false);
2239 pp_string (pp, " sz: ");
2240 dump_generic_node (pp, op1, spc, flags, false);
2241 pp_right_brace (pp);
2243 break;
2245 case CONSTRUCTOR:
2247 unsigned HOST_WIDE_INT ix;
2248 tree field, val;
2249 bool is_struct_init = false;
2250 bool is_array_init = false;
2251 widest_int curidx;
2252 pp_left_brace (pp);
2253 if (TREE_CLOBBER_P (node))
2254 pp_string (pp, "CLOBBER");
2255 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2256 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2257 is_struct_init = true;
2258 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2259 && TYPE_DOMAIN (TREE_TYPE (node))
2260 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2261 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2262 == INTEGER_CST)
2264 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2265 is_array_init = true;
2266 curidx = wi::to_widest (minv);
2268 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2270 if (field)
2272 if (is_struct_init)
2274 pp_dot (pp);
2275 dump_generic_node (pp, field, spc, flags, false);
2276 pp_equal (pp);
2278 else if (is_array_init
2279 && (TREE_CODE (field) != INTEGER_CST
2280 || curidx != wi::to_widest (field)))
2282 pp_left_bracket (pp);
2283 if (TREE_CODE (field) == RANGE_EXPR)
2285 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2286 flags, false);
2287 pp_string (pp, " ... ");
2288 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2289 flags, false);
2290 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2291 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2293 else
2294 dump_generic_node (pp, field, spc, flags, false);
2295 if (TREE_CODE (field) == INTEGER_CST)
2296 curidx = wi::to_widest (field);
2297 pp_string (pp, "]=");
2300 if (is_array_init)
2301 curidx += 1;
2302 if (val && TREE_CODE (val) == ADDR_EXPR)
2303 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2304 val = TREE_OPERAND (val, 0);
2305 if (val && TREE_CODE (val) == FUNCTION_DECL)
2306 dump_decl_name (pp, val, flags);
2307 else
2308 dump_generic_node (pp, val, spc, flags, false);
2309 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2311 pp_comma (pp);
2312 pp_space (pp);
2315 pp_right_brace (pp);
2317 break;
2319 case COMPOUND_EXPR:
2321 tree *tp;
2322 if (flags & TDF_SLIM)
2324 pp_string (pp, "<COMPOUND_EXPR>");
2325 break;
2328 dump_generic_node (pp, TREE_OPERAND (node, 0),
2329 spc, flags, !(flags & TDF_SLIM));
2330 if (flags & TDF_SLIM)
2331 newline_and_indent (pp, spc);
2332 else
2334 pp_comma (pp);
2335 pp_space (pp);
2338 for (tp = &TREE_OPERAND (node, 1);
2339 TREE_CODE (*tp) == COMPOUND_EXPR;
2340 tp = &TREE_OPERAND (*tp, 1))
2342 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2343 spc, flags, !(flags & TDF_SLIM));
2344 if (flags & TDF_SLIM)
2345 newline_and_indent (pp, spc);
2346 else
2348 pp_comma (pp);
2349 pp_space (pp);
2353 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2355 break;
2357 case STATEMENT_LIST:
2359 tree_stmt_iterator si;
2360 bool first = true;
2362 if (flags & TDF_SLIM)
2364 pp_string (pp, "<STATEMENT_LIST>");
2365 break;
2368 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2370 if (!first)
2371 newline_and_indent (pp, spc);
2372 else
2373 first = false;
2374 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2377 break;
2379 case MODIFY_EXPR:
2380 case INIT_EXPR:
2381 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2382 false);
2383 pp_space (pp);
2384 pp_equal (pp);
2385 pp_space (pp);
2386 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2387 false);
2388 break;
2390 case TARGET_EXPR:
2391 pp_string (pp, "TARGET_EXPR <");
2392 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2393 pp_comma (pp);
2394 pp_space (pp);
2395 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2396 pp_greater (pp);
2397 break;
2399 case DECL_EXPR:
2400 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2401 is_stmt = false;
2402 break;
2404 case COND_EXPR:
2405 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2407 pp_string (pp, "if (");
2408 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2409 pp_right_paren (pp);
2410 /* The lowered cond_exprs should always be printed in full. */
2411 if (COND_EXPR_THEN (node)
2412 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2413 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2414 && COND_EXPR_ELSE (node)
2415 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2416 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2418 pp_space (pp);
2419 dump_generic_node (pp, COND_EXPR_THEN (node),
2420 0, flags, true);
2421 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2423 pp_string (pp, " else ");
2424 dump_generic_node (pp, COND_EXPR_ELSE (node),
2425 0, flags, true);
2428 else if (!(flags & TDF_SLIM))
2430 /* Output COND_EXPR_THEN. */
2431 if (COND_EXPR_THEN (node))
2433 newline_and_indent (pp, spc+2);
2434 pp_left_brace (pp);
2435 newline_and_indent (pp, spc+4);
2436 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2437 flags, true);
2438 newline_and_indent (pp, spc+2);
2439 pp_right_brace (pp);
2442 /* Output COND_EXPR_ELSE. */
2443 if (COND_EXPR_ELSE (node)
2444 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2446 newline_and_indent (pp, spc);
2447 pp_string (pp, "else");
2448 newline_and_indent (pp, spc+2);
2449 pp_left_brace (pp);
2450 newline_and_indent (pp, spc+4);
2451 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2452 flags, true);
2453 newline_and_indent (pp, spc+2);
2454 pp_right_brace (pp);
2457 is_expr = false;
2459 else
2461 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2462 pp_space (pp);
2463 pp_question (pp);
2464 pp_space (pp);
2465 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2466 pp_space (pp);
2467 pp_colon (pp);
2468 pp_space (pp);
2469 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2471 break;
2473 case BIND_EXPR:
2474 pp_left_brace (pp);
2475 if (!(flags & TDF_SLIM))
2477 if (BIND_EXPR_VARS (node))
2479 pp_newline (pp);
2481 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2483 print_declaration (pp, op0, spc+2, flags);
2484 pp_newline (pp);
2488 newline_and_indent (pp, spc+2);
2489 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2490 newline_and_indent (pp, spc);
2491 pp_right_brace (pp);
2493 is_expr = false;
2494 break;
2496 case CALL_EXPR:
2497 if (CALL_EXPR_FN (node) != NULL_TREE)
2498 print_call_name (pp, CALL_EXPR_FN (node), flags);
2499 else
2501 pp_dot (pp);
2502 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2505 /* Print parameters. */
2506 pp_space (pp);
2507 pp_left_paren (pp);
2509 tree arg;
2510 call_expr_arg_iterator iter;
2511 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2513 dump_generic_node (pp, arg, spc, flags, false);
2514 if (more_call_expr_args_p (&iter))
2516 pp_comma (pp);
2517 pp_space (pp);
2521 if (CALL_EXPR_VA_ARG_PACK (node))
2523 if (call_expr_nargs (node) > 0)
2525 pp_comma (pp);
2526 pp_space (pp);
2528 pp_string (pp, "__builtin_va_arg_pack ()");
2530 pp_right_paren (pp);
2532 op1 = CALL_EXPR_STATIC_CHAIN (node);
2533 if (op1)
2535 pp_string (pp, " [static-chain: ");
2536 dump_generic_node (pp, op1, spc, flags, false);
2537 pp_right_bracket (pp);
2540 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2541 pp_string (pp, " [return slot optimization]");
2542 if (CALL_EXPR_TAILCALL (node))
2543 pp_string (pp, " [tail call]");
2544 break;
2546 case WITH_CLEANUP_EXPR:
2547 NIY;
2548 break;
2550 case CLEANUP_POINT_EXPR:
2551 pp_string (pp, "<<cleanup_point ");
2552 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2553 pp_string (pp, ">>");
2554 break;
2556 case PLACEHOLDER_EXPR:
2557 pp_string (pp, "<PLACEHOLDER_EXPR ");
2558 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2559 pp_greater (pp);
2560 break;
2562 /* Binary arithmetic and logic expressions. */
2563 case WIDEN_SUM_EXPR:
2564 case WIDEN_MULT_EXPR:
2565 case MULT_EXPR:
2566 case MULT_HIGHPART_EXPR:
2567 case PLUS_EXPR:
2568 case POINTER_PLUS_EXPR:
2569 case POINTER_DIFF_EXPR:
2570 case MINUS_EXPR:
2571 case TRUNC_DIV_EXPR:
2572 case CEIL_DIV_EXPR:
2573 case FLOOR_DIV_EXPR:
2574 case ROUND_DIV_EXPR:
2575 case TRUNC_MOD_EXPR:
2576 case CEIL_MOD_EXPR:
2577 case FLOOR_MOD_EXPR:
2578 case ROUND_MOD_EXPR:
2579 case RDIV_EXPR:
2580 case EXACT_DIV_EXPR:
2581 case LSHIFT_EXPR:
2582 case RSHIFT_EXPR:
2583 case LROTATE_EXPR:
2584 case RROTATE_EXPR:
2585 case WIDEN_LSHIFT_EXPR:
2586 case BIT_IOR_EXPR:
2587 case BIT_XOR_EXPR:
2588 case BIT_AND_EXPR:
2589 case TRUTH_ANDIF_EXPR:
2590 case TRUTH_ORIF_EXPR:
2591 case TRUTH_AND_EXPR:
2592 case TRUTH_OR_EXPR:
2593 case TRUTH_XOR_EXPR:
2594 case LT_EXPR:
2595 case LE_EXPR:
2596 case GT_EXPR:
2597 case GE_EXPR:
2598 case EQ_EXPR:
2599 case NE_EXPR:
2600 case UNLT_EXPR:
2601 case UNLE_EXPR:
2602 case UNGT_EXPR:
2603 case UNGE_EXPR:
2604 case UNEQ_EXPR:
2605 case LTGT_EXPR:
2606 case ORDERED_EXPR:
2607 case UNORDERED_EXPR:
2609 const char *op = op_symbol (node);
2610 op0 = TREE_OPERAND (node, 0);
2611 op1 = TREE_OPERAND (node, 1);
2613 /* When the operands are expressions with less priority,
2614 keep semantics of the tree representation. */
2615 if (op_prio (op0) <= op_prio (node))
2617 pp_left_paren (pp);
2618 dump_generic_node (pp, op0, spc, flags, false);
2619 pp_right_paren (pp);
2621 else
2622 dump_generic_node (pp, op0, spc, flags, false);
2624 pp_space (pp);
2625 pp_string (pp, op);
2626 pp_space (pp);
2628 /* When the operands are expressions with less priority,
2629 keep semantics of the tree representation. */
2630 if (op_prio (op1) <= op_prio (node))
2632 pp_left_paren (pp);
2633 dump_generic_node (pp, op1, spc, flags, false);
2634 pp_right_paren (pp);
2636 else
2637 dump_generic_node (pp, op1, spc, flags, false);
2639 break;
2641 /* Unary arithmetic and logic expressions. */
2642 case NEGATE_EXPR:
2643 case BIT_NOT_EXPR:
2644 case TRUTH_NOT_EXPR:
2645 case ADDR_EXPR:
2646 case PREDECREMENT_EXPR:
2647 case PREINCREMENT_EXPR:
2648 case INDIRECT_REF:
2649 if (TREE_CODE (node) == ADDR_EXPR
2650 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2651 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2652 ; /* Do not output '&' for strings and function pointers. */
2653 else
2654 pp_string (pp, op_symbol (node));
2656 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2658 pp_left_paren (pp);
2659 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2660 pp_right_paren (pp);
2662 else
2663 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2664 break;
2666 case POSTDECREMENT_EXPR:
2667 case POSTINCREMENT_EXPR:
2668 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2670 pp_left_paren (pp);
2671 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2672 pp_right_paren (pp);
2674 else
2675 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2676 pp_string (pp, op_symbol (node));
2677 break;
2679 case MIN_EXPR:
2680 pp_string (pp, "MIN_EXPR <");
2681 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2682 pp_string (pp, ", ");
2683 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2684 pp_greater (pp);
2685 break;
2687 case MAX_EXPR:
2688 pp_string (pp, "MAX_EXPR <");
2689 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2690 pp_string (pp, ", ");
2691 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2692 pp_greater (pp);
2693 break;
2695 case ABS_EXPR:
2696 pp_string (pp, "ABS_EXPR <");
2697 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2698 pp_greater (pp);
2699 break;
2701 case ABSU_EXPR:
2702 pp_string (pp, "ABSU_EXPR <");
2703 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2704 pp_greater (pp);
2705 break;
2707 case RANGE_EXPR:
2708 NIY;
2709 break;
2711 case ADDR_SPACE_CONVERT_EXPR:
2712 case FIXED_CONVERT_EXPR:
2713 case FIX_TRUNC_EXPR:
2714 case FLOAT_EXPR:
2715 CASE_CONVERT:
2716 type = TREE_TYPE (node);
2717 op0 = TREE_OPERAND (node, 0);
2718 if (type != TREE_TYPE (op0))
2720 pp_left_paren (pp);
2721 dump_generic_node (pp, type, spc, flags, false);
2722 pp_string (pp, ") ");
2724 if (op_prio (op0) < op_prio (node))
2725 pp_left_paren (pp);
2726 dump_generic_node (pp, op0, spc, flags, false);
2727 if (op_prio (op0) < op_prio (node))
2728 pp_right_paren (pp);
2729 break;
2731 case VIEW_CONVERT_EXPR:
2732 if (flags & TDF_GIMPLE)
2733 pp_string (pp, "__VIEW_CONVERT <");
2734 else
2735 pp_string (pp, "VIEW_CONVERT_EXPR<");
2736 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2737 pp_string (pp, ">(");
2738 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2739 pp_right_paren (pp);
2740 break;
2742 case PAREN_EXPR:
2743 pp_string (pp, "((");
2744 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2745 pp_string (pp, "))");
2746 break;
2748 case NON_LVALUE_EXPR:
2749 pp_string (pp, "NON_LVALUE_EXPR <");
2750 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2751 pp_greater (pp);
2752 break;
2754 case SAVE_EXPR:
2755 pp_string (pp, "SAVE_EXPR <");
2756 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2757 pp_greater (pp);
2758 break;
2760 case COMPLEX_EXPR:
2761 pp_string (pp, "COMPLEX_EXPR <");
2762 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2763 pp_string (pp, ", ");
2764 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2765 pp_greater (pp);
2766 break;
2768 case CONJ_EXPR:
2769 pp_string (pp, "CONJ_EXPR <");
2770 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2771 pp_greater (pp);
2772 break;
2774 case REALPART_EXPR:
2775 if (flags & TDF_GIMPLE)
2777 pp_string (pp, "__real ");
2778 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2780 else
2782 pp_string (pp, "REALPART_EXPR <");
2783 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2784 pp_greater (pp);
2786 break;
2788 case IMAGPART_EXPR:
2789 if (flags & TDF_GIMPLE)
2791 pp_string (pp, "__imag ");
2792 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2794 else
2796 pp_string (pp, "IMAGPART_EXPR <");
2797 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2798 pp_greater (pp);
2800 break;
2802 case VA_ARG_EXPR:
2803 pp_string (pp, "VA_ARG_EXPR <");
2804 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2805 pp_greater (pp);
2806 break;
2808 case TRY_FINALLY_EXPR:
2809 case TRY_CATCH_EXPR:
2810 pp_string (pp, "try");
2811 newline_and_indent (pp, spc+2);
2812 pp_left_brace (pp);
2813 newline_and_indent (pp, spc+4);
2814 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2815 newline_and_indent (pp, spc+2);
2816 pp_right_brace (pp);
2817 newline_and_indent (pp, spc);
2818 if (TREE_CODE (node) == TRY_CATCH_EXPR)
2820 node = TREE_OPERAND (node, 1);
2821 pp_string (pp, "catch");
2823 else
2825 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
2826 node = TREE_OPERAND (node, 1);
2827 pp_string (pp, "finally");
2828 if (TREE_CODE (node) == EH_ELSE_EXPR)
2830 newline_and_indent (pp, spc+2);
2831 pp_left_brace (pp);
2832 newline_and_indent (pp, spc+4);
2833 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
2834 flags, true);
2835 newline_and_indent (pp, spc+2);
2836 pp_right_brace (pp);
2837 newline_and_indent (pp, spc);
2838 node = TREE_OPERAND (node, 1);
2839 pp_string (pp, "else");
2842 newline_and_indent (pp, spc+2);
2843 pp_left_brace (pp);
2844 newline_and_indent (pp, spc+4);
2845 dump_generic_node (pp, node, spc+4, flags, true);
2846 newline_and_indent (pp, spc+2);
2847 pp_right_brace (pp);
2848 is_expr = false;
2849 break;
2851 case CATCH_EXPR:
2852 pp_string (pp, "catch (");
2853 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2854 pp_right_paren (pp);
2855 newline_and_indent (pp, spc+2);
2856 pp_left_brace (pp);
2857 newline_and_indent (pp, spc+4);
2858 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2859 newline_and_indent (pp, spc+2);
2860 pp_right_brace (pp);
2861 is_expr = false;
2862 break;
2864 case EH_FILTER_EXPR:
2865 pp_string (pp, "<<<eh_filter (");
2866 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2867 pp_string (pp, ")>>>");
2868 newline_and_indent (pp, spc+2);
2869 pp_left_brace (pp);
2870 newline_and_indent (pp, spc+4);
2871 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2872 newline_and_indent (pp, spc+2);
2873 pp_right_brace (pp);
2874 is_expr = false;
2875 break;
2877 case LABEL_EXPR:
2878 op0 = TREE_OPERAND (node, 0);
2879 /* If this is for break or continue, don't bother printing it. */
2880 if (DECL_NAME (op0))
2882 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2883 if (strcmp (name, "break") == 0
2884 || strcmp (name, "continue") == 0)
2885 break;
2887 dump_generic_node (pp, op0, spc, flags, false);
2888 pp_colon (pp);
2889 if (DECL_NONLOCAL (op0))
2890 pp_string (pp, " [non-local]");
2891 break;
2893 case LOOP_EXPR:
2894 pp_string (pp, "while (1)");
2895 if (!(flags & TDF_SLIM))
2897 newline_and_indent (pp, spc+2);
2898 pp_left_brace (pp);
2899 newline_and_indent (pp, spc+4);
2900 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2901 newline_and_indent (pp, spc+2);
2902 pp_right_brace (pp);
2904 is_expr = false;
2905 break;
2907 case PREDICT_EXPR:
2908 pp_string (pp, "// predicted ");
2909 if (PREDICT_EXPR_OUTCOME (node))
2910 pp_string (pp, "likely by ");
2911 else
2912 pp_string (pp, "unlikely by ");
2913 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2914 pp_string (pp, " predictor.");
2915 break;
2917 case ANNOTATE_EXPR:
2918 pp_string (pp, "ANNOTATE_EXPR <");
2919 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2920 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2922 case annot_expr_ivdep_kind:
2923 pp_string (pp, ", ivdep");
2924 break;
2925 case annot_expr_unroll_kind:
2926 pp_printf (pp, ", unroll %d",
2927 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2928 break;
2929 case annot_expr_no_vector_kind:
2930 pp_string (pp, ", no-vector");
2931 break;
2932 case annot_expr_vector_kind:
2933 pp_string (pp, ", vector");
2934 break;
2935 case annot_expr_parallel_kind:
2936 pp_string (pp, ", parallel");
2937 break;
2938 default:
2939 gcc_unreachable ();
2941 pp_greater (pp);
2942 break;
2944 case RETURN_EXPR:
2945 pp_string (pp, "return");
2946 op0 = TREE_OPERAND (node, 0);
2947 if (op0)
2949 pp_space (pp);
2950 if (TREE_CODE (op0) == MODIFY_EXPR)
2951 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2952 spc, flags, false);
2953 else
2954 dump_generic_node (pp, op0, spc, flags, false);
2956 break;
2958 case EXIT_EXPR:
2959 pp_string (pp, "if (");
2960 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2961 pp_string (pp, ") break");
2962 break;
2964 case SWITCH_EXPR:
2965 pp_string (pp, "switch (");
2966 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2967 pp_right_paren (pp);
2968 if (!(flags & TDF_SLIM))
2970 newline_and_indent (pp, spc+2);
2971 pp_left_brace (pp);
2972 if (SWITCH_BODY (node))
2974 newline_and_indent (pp, spc+4);
2975 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2976 true);
2978 newline_and_indent (pp, spc+2);
2979 pp_right_brace (pp);
2981 is_expr = false;
2982 break;
2984 case GOTO_EXPR:
2985 op0 = GOTO_DESTINATION (node);
2986 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2988 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2989 if (strcmp (name, "break") == 0
2990 || strcmp (name, "continue") == 0)
2992 pp_string (pp, name);
2993 break;
2996 pp_string (pp, "goto ");
2997 dump_generic_node (pp, op0, spc, flags, false);
2998 break;
3000 case ASM_EXPR:
3001 pp_string (pp, "__asm__");
3002 if (ASM_VOLATILE_P (node))
3003 pp_string (pp, " __volatile__");
3004 pp_left_paren (pp);
3005 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3006 pp_colon (pp);
3007 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3008 pp_colon (pp);
3009 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3010 if (ASM_CLOBBERS (node))
3012 pp_colon (pp);
3013 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3015 pp_right_paren (pp);
3016 break;
3018 case CASE_LABEL_EXPR:
3019 if (CASE_LOW (node) && CASE_HIGH (node))
3021 pp_string (pp, "case ");
3022 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3023 pp_string (pp, " ... ");
3024 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3026 else if (CASE_LOW (node))
3028 pp_string (pp, "case ");
3029 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3031 else
3032 pp_string (pp, "default");
3033 pp_colon (pp);
3034 break;
3036 case OBJ_TYPE_REF:
3037 pp_string (pp, "OBJ_TYPE_REF(");
3038 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3039 pp_semicolon (pp);
3040 /* We omit the class type for -fcompare-debug because we may
3041 drop TYPE_BINFO early depending on debug info, and then
3042 virtual_method_call_p would return false, whereas when
3043 TYPE_BINFO is preserved it may still return true and then
3044 we'd print the class type. Compare tree and rtl dumps for
3045 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3046 for example, at occurrences of OBJ_TYPE_REF. */
3047 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3048 && virtual_method_call_p (node))
3050 pp_string (pp, "(");
3051 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
3052 pp_string (pp, ")");
3054 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3055 pp_arrow (pp);
3056 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3057 pp_right_paren (pp);
3058 break;
3060 case SSA_NAME:
3061 if (SSA_NAME_IDENTIFIER (node))
3063 if ((flags & TDF_NOUID)
3064 && SSA_NAME_VAR (node)
3065 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3066 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3067 else if (! (flags & TDF_GIMPLE)
3068 || SSA_NAME_VAR (node))
3069 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3070 spc, flags, false);
3072 pp_underscore (pp);
3073 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3074 if (SSA_NAME_IS_DEFAULT_DEF (node))
3075 pp_string (pp, "(D)");
3076 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3077 pp_string (pp, "(ab)");
3078 break;
3080 case WITH_SIZE_EXPR:
3081 pp_string (pp, "WITH_SIZE_EXPR <");
3082 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3083 pp_string (pp, ", ");
3084 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3085 pp_greater (pp);
3086 break;
3088 case ASSERT_EXPR:
3089 pp_string (pp, "ASSERT_EXPR <");
3090 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3091 pp_string (pp, ", ");
3092 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3093 pp_greater (pp);
3094 break;
3096 case SCEV_KNOWN:
3097 pp_string (pp, "scev_known");
3098 break;
3100 case SCEV_NOT_KNOWN:
3101 pp_string (pp, "scev_not_known");
3102 break;
3104 case POLYNOMIAL_CHREC:
3105 pp_left_brace (pp);
3106 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3107 pp_string (pp, ", +, ");
3108 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3109 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
3110 is_stmt = false;
3111 break;
3113 case REALIGN_LOAD_EXPR:
3114 pp_string (pp, "REALIGN_LOAD <");
3115 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3116 pp_string (pp, ", ");
3117 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3118 pp_string (pp, ", ");
3119 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3120 pp_greater (pp);
3121 break;
3123 case VEC_COND_EXPR:
3124 pp_string (pp, " VEC_COND_EXPR < ");
3125 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3126 pp_string (pp, " , ");
3127 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3128 pp_string (pp, " , ");
3129 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3130 pp_string (pp, " > ");
3131 break;
3133 case VEC_PERM_EXPR:
3134 pp_string (pp, " VEC_PERM_EXPR < ");
3135 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3136 pp_string (pp, " , ");
3137 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3138 pp_string (pp, " , ");
3139 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3140 pp_string (pp, " > ");
3141 break;
3143 case DOT_PROD_EXPR:
3144 pp_string (pp, " DOT_PROD_EXPR < ");
3145 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3146 pp_string (pp, ", ");
3147 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3148 pp_string (pp, ", ");
3149 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3150 pp_string (pp, " > ");
3151 break;
3153 case WIDEN_MULT_PLUS_EXPR:
3154 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3155 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3156 pp_string (pp, ", ");
3157 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3158 pp_string (pp, ", ");
3159 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3160 pp_string (pp, " > ");
3161 break;
3163 case WIDEN_MULT_MINUS_EXPR:
3164 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3165 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3166 pp_string (pp, ", ");
3167 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3168 pp_string (pp, ", ");
3169 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3170 pp_string (pp, " > ");
3171 break;
3173 case OACC_PARALLEL:
3174 pp_string (pp, "#pragma acc parallel");
3175 goto dump_omp_clauses_body;
3177 case OACC_KERNELS:
3178 pp_string (pp, "#pragma acc kernels");
3179 goto dump_omp_clauses_body;
3181 case OACC_DATA:
3182 pp_string (pp, "#pragma acc data");
3183 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3184 goto dump_omp_body;
3186 case OACC_HOST_DATA:
3187 pp_string (pp, "#pragma acc host_data");
3188 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3189 goto dump_omp_body;
3191 case OACC_DECLARE:
3192 pp_string (pp, "#pragma acc declare");
3193 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3194 break;
3196 case OACC_UPDATE:
3197 pp_string (pp, "#pragma acc update");
3198 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3199 break;
3201 case OACC_ENTER_DATA:
3202 pp_string (pp, "#pragma acc enter data");
3203 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3204 break;
3206 case OACC_EXIT_DATA:
3207 pp_string (pp, "#pragma acc exit data");
3208 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3209 break;
3211 case OACC_CACHE:
3212 pp_string (pp, "#pragma acc cache");
3213 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3214 break;
3216 case OMP_PARALLEL:
3217 pp_string (pp, "#pragma omp parallel");
3218 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3219 goto dump_omp_body;
3221 dump_omp_clauses_body:
3222 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3223 goto dump_omp_body;
3225 dump_omp_body:
3226 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3228 newline_and_indent (pp, spc + 2);
3229 pp_left_brace (pp);
3230 newline_and_indent (pp, spc + 4);
3231 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3232 newline_and_indent (pp, spc + 2);
3233 pp_right_brace (pp);
3235 is_expr = false;
3236 break;
3238 case OMP_TASK:
3239 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3240 : "#pragma omp taskwait");
3241 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3242 goto dump_omp_body;
3244 case OMP_FOR:
3245 pp_string (pp, "#pragma omp for");
3246 goto dump_omp_loop;
3248 case OMP_SIMD:
3249 pp_string (pp, "#pragma omp simd");
3250 goto dump_omp_loop;
3252 case OMP_DISTRIBUTE:
3253 pp_string (pp, "#pragma omp distribute");
3254 goto dump_omp_loop;
3256 case OMP_TASKLOOP:
3257 pp_string (pp, "#pragma omp taskloop");
3258 goto dump_omp_loop;
3260 case OACC_LOOP:
3261 pp_string (pp, "#pragma acc loop");
3262 goto dump_omp_loop;
3264 case OMP_TEAMS:
3265 pp_string (pp, "#pragma omp teams");
3266 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3267 goto dump_omp_body;
3269 case OMP_TARGET_DATA:
3270 pp_string (pp, "#pragma omp target data");
3271 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3272 goto dump_omp_body;
3274 case OMP_TARGET_ENTER_DATA:
3275 pp_string (pp, "#pragma omp target enter data");
3276 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3277 is_expr = false;
3278 break;
3280 case OMP_TARGET_EXIT_DATA:
3281 pp_string (pp, "#pragma omp target exit data");
3282 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3283 is_expr = false;
3284 break;
3286 case OMP_TARGET:
3287 pp_string (pp, "#pragma omp target");
3288 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3289 goto dump_omp_body;
3291 case OMP_TARGET_UPDATE:
3292 pp_string (pp, "#pragma omp target update");
3293 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3294 is_expr = false;
3295 break;
3297 dump_omp_loop:
3298 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3299 if (!(flags & TDF_SLIM))
3301 int i;
3303 if (OMP_FOR_PRE_BODY (node))
3305 newline_and_indent (pp, spc + 2);
3306 pp_left_brace (pp);
3307 spc += 4;
3308 newline_and_indent (pp, spc);
3309 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3310 spc, flags, false);
3312 if (OMP_FOR_INIT (node))
3314 spc -= 2;
3315 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3317 spc += 2;
3318 newline_and_indent (pp, spc);
3319 pp_string (pp, "for (");
3320 dump_generic_node (pp,
3321 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3322 spc, flags, false);
3323 pp_string (pp, "; ");
3324 dump_generic_node (pp,
3325 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3326 spc, flags, false);
3327 pp_string (pp, "; ");
3328 dump_generic_node (pp,
3329 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3330 spc, flags, false);
3331 pp_right_paren (pp);
3334 if (OMP_FOR_BODY (node))
3336 newline_and_indent (pp, spc + 2);
3337 pp_left_brace (pp);
3338 newline_and_indent (pp, spc + 4);
3339 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3340 false);
3341 newline_and_indent (pp, spc + 2);
3342 pp_right_brace (pp);
3344 if (OMP_FOR_INIT (node))
3345 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3346 if (OMP_FOR_PRE_BODY (node))
3348 spc -= 4;
3349 newline_and_indent (pp, spc + 2);
3350 pp_right_brace (pp);
3353 is_expr = false;
3354 break;
3356 case OMP_SECTIONS:
3357 pp_string (pp, "#pragma omp sections");
3358 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3359 goto dump_omp_body;
3361 case OMP_SECTION:
3362 pp_string (pp, "#pragma omp section");
3363 goto dump_omp_body;
3365 case OMP_SCAN:
3366 if (OMP_SCAN_CLAUSES (node))
3368 pp_string (pp, "#pragma omp scan");
3369 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3371 goto dump_omp_body;
3373 case OMP_MASTER:
3374 pp_string (pp, "#pragma omp master");
3375 goto dump_omp_body;
3377 case OMP_TASKGROUP:
3378 pp_string (pp, "#pragma omp taskgroup");
3379 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3380 goto dump_omp_body;
3382 case OMP_ORDERED:
3383 pp_string (pp, "#pragma omp ordered");
3384 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3385 goto dump_omp_body;
3387 case OMP_CRITICAL:
3388 pp_string (pp, "#pragma omp critical");
3389 if (OMP_CRITICAL_NAME (node))
3391 pp_space (pp);
3392 pp_left_paren (pp);
3393 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3394 flags, false);
3395 pp_right_paren (pp);
3397 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3398 goto dump_omp_body;
3400 case OMP_ATOMIC:
3401 pp_string (pp, "#pragma omp atomic");
3402 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3403 newline_and_indent (pp, spc + 2);
3404 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3405 pp_space (pp);
3406 pp_equal (pp);
3407 pp_space (pp);
3408 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3409 break;
3411 case OMP_ATOMIC_READ:
3412 pp_string (pp, "#pragma omp atomic read");
3413 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3414 newline_and_indent (pp, spc + 2);
3415 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3416 pp_space (pp);
3417 break;
3419 case OMP_ATOMIC_CAPTURE_OLD:
3420 case OMP_ATOMIC_CAPTURE_NEW:
3421 pp_string (pp, "#pragma omp atomic capture");
3422 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3423 newline_and_indent (pp, spc + 2);
3424 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3425 pp_space (pp);
3426 pp_equal (pp);
3427 pp_space (pp);
3428 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3429 break;
3431 case OMP_SINGLE:
3432 pp_string (pp, "#pragma omp single");
3433 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3434 goto dump_omp_body;
3436 case OMP_CLAUSE:
3437 dump_omp_clause (pp, node, spc, flags);
3438 is_expr = false;
3439 break;
3441 case TRANSACTION_EXPR:
3442 if (TRANSACTION_EXPR_OUTER (node))
3443 pp_string (pp, "__transaction_atomic [[outer]]");
3444 else if (TRANSACTION_EXPR_RELAXED (node))
3445 pp_string (pp, "__transaction_relaxed");
3446 else
3447 pp_string (pp, "__transaction_atomic");
3448 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3450 newline_and_indent (pp, spc);
3451 pp_left_brace (pp);
3452 newline_and_indent (pp, spc + 2);
3453 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3454 spc + 2, flags, false);
3455 newline_and_indent (pp, spc);
3456 pp_right_brace (pp);
3458 is_expr = false;
3459 break;
3461 case VEC_SERIES_EXPR:
3462 case VEC_WIDEN_MULT_HI_EXPR:
3463 case VEC_WIDEN_MULT_LO_EXPR:
3464 case VEC_WIDEN_MULT_EVEN_EXPR:
3465 case VEC_WIDEN_MULT_ODD_EXPR:
3466 case VEC_WIDEN_LSHIFT_HI_EXPR:
3467 case VEC_WIDEN_LSHIFT_LO_EXPR:
3468 pp_space (pp);
3469 for (str = get_tree_code_name (code); *str; str++)
3470 pp_character (pp, TOUPPER (*str));
3471 pp_string (pp, " < ");
3472 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3473 pp_string (pp, ", ");
3474 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3475 pp_string (pp, " > ");
3476 break;
3478 case VEC_DUPLICATE_EXPR:
3479 pp_space (pp);
3480 for (str = get_tree_code_name (code); *str; str++)
3481 pp_character (pp, TOUPPER (*str));
3482 pp_string (pp, " < ");
3483 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3484 pp_string (pp, " > ");
3485 break;
3487 case VEC_UNPACK_HI_EXPR:
3488 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3489 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3490 pp_string (pp, " > ");
3491 break;
3493 case VEC_UNPACK_LO_EXPR:
3494 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3495 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3496 pp_string (pp, " > ");
3497 break;
3499 case VEC_UNPACK_FLOAT_HI_EXPR:
3500 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3501 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3502 pp_string (pp, " > ");
3503 break;
3505 case VEC_UNPACK_FLOAT_LO_EXPR:
3506 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3507 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3508 pp_string (pp, " > ");
3509 break;
3511 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3512 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3513 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3514 pp_string (pp, " > ");
3515 break;
3517 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3518 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3519 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3520 pp_string (pp, " > ");
3521 break;
3523 case VEC_PACK_TRUNC_EXPR:
3524 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3525 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3526 pp_string (pp, ", ");
3527 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3528 pp_string (pp, " > ");
3529 break;
3531 case VEC_PACK_SAT_EXPR:
3532 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3533 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3534 pp_string (pp, ", ");
3535 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3536 pp_string (pp, " > ");
3537 break;
3539 case VEC_PACK_FIX_TRUNC_EXPR:
3540 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3541 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3542 pp_string (pp, ", ");
3543 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3544 pp_string (pp, " > ");
3545 break;
3547 case VEC_PACK_FLOAT_EXPR:
3548 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3549 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3550 pp_string (pp, ", ");
3551 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3552 pp_string (pp, " > ");
3553 break;
3555 case BLOCK:
3556 dump_block_node (pp, node, spc, flags);
3557 break;
3559 case DEBUG_BEGIN_STMT:
3560 pp_string (pp, "# DEBUG BEGIN STMT");
3561 break;
3563 default:
3564 NIY;
3567 if (is_stmt && is_expr)
3568 pp_semicolon (pp);
3570 return spc;
3573 /* Print the declaration of a variable. */
3575 void
3576 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3578 INDENT (spc);
3580 if (TREE_CODE(t) == NAMELIST_DECL)
3582 pp_string(pp, "namelist ");
3583 dump_decl_name (pp, t, flags);
3584 pp_semicolon (pp);
3585 return;
3588 if (TREE_CODE (t) == TYPE_DECL)
3589 pp_string (pp, "typedef ");
3591 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3592 pp_string (pp, "register ");
3594 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3595 pp_string (pp, "extern ");
3596 else if (TREE_STATIC (t))
3597 pp_string (pp, "static ");
3599 /* Print the type and name. */
3600 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3602 tree tmp;
3604 /* Print array's type. */
3605 tmp = TREE_TYPE (t);
3606 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3607 tmp = TREE_TYPE (tmp);
3608 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3610 /* Print variable's name. */
3611 pp_space (pp);
3612 dump_generic_node (pp, t, spc, flags, false);
3614 /* Print the dimensions. */
3615 tmp = TREE_TYPE (t);
3616 while (TREE_CODE (tmp) == ARRAY_TYPE)
3618 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3619 tmp = TREE_TYPE (tmp);
3622 else if (TREE_CODE (t) == FUNCTION_DECL)
3624 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3625 pp_space (pp);
3626 dump_decl_name (pp, t, flags);
3627 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3629 else
3631 /* Print type declaration. */
3632 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3634 /* Print variable's name. */
3635 pp_space (pp);
3636 dump_generic_node (pp, t, spc, flags, false);
3639 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3641 pp_string (pp, " __asm__ ");
3642 pp_left_paren (pp);
3643 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3644 pp_right_paren (pp);
3647 /* The initial value of a function serves to determine whether the function
3648 is declared or defined. So the following does not apply to function
3649 nodes. */
3650 if (TREE_CODE (t) != FUNCTION_DECL)
3652 /* Print the initial value. */
3653 if (DECL_INITIAL (t))
3655 pp_space (pp);
3656 pp_equal (pp);
3657 pp_space (pp);
3658 if (!(flags & TDF_SLIM))
3659 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3660 else
3661 pp_string (pp, "<<< omitted >>>");
3665 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3667 pp_string (pp, " [value-expr: ");
3668 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3669 pp_right_bracket (pp);
3672 pp_semicolon (pp);
3676 /* Prints a structure: name, fields, and methods.
3677 FIXME: Still incomplete. */
3679 static void
3680 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3681 dump_flags_t flags)
3683 /* Print the name of the structure. */
3684 if (TYPE_NAME (node))
3686 INDENT (spc);
3687 if (TREE_CODE (node) == RECORD_TYPE)
3688 pp_string (pp, "struct ");
3689 else if ((TREE_CODE (node) == UNION_TYPE
3690 || TREE_CODE (node) == QUAL_UNION_TYPE))
3691 pp_string (pp, "union ");
3693 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3696 /* Print the contents of the structure. */
3697 pp_newline (pp);
3698 INDENT (spc);
3699 pp_left_brace (pp);
3700 pp_newline (pp);
3702 /* Print the fields of the structure. */
3704 tree tmp;
3705 tmp = TYPE_FIELDS (node);
3706 while (tmp)
3708 /* Avoid to print recursively the structure. */
3709 /* FIXME : Not implemented correctly...,
3710 what about the case when we have a cycle in the contain graph? ...
3711 Maybe this could be solved by looking at the scope in which the
3712 structure was declared. */
3713 if (TREE_TYPE (tmp) != node
3714 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3715 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3717 print_declaration (pp, tmp, spc+2, flags);
3718 pp_newline (pp);
3720 tmp = DECL_CHAIN (tmp);
3723 INDENT (spc);
3724 pp_right_brace (pp);
3727 /* Return the priority of the operator CODE.
3729 From lowest to highest precedence with either left-to-right (L-R)
3730 or right-to-left (R-L) associativity]:
3732 1 [L-R] ,
3733 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3734 3 [R-L] ?:
3735 4 [L-R] ||
3736 5 [L-R] &&
3737 6 [L-R] |
3738 7 [L-R] ^
3739 8 [L-R] &
3740 9 [L-R] == !=
3741 10 [L-R] < <= > >=
3742 11 [L-R] << >>
3743 12 [L-R] + -
3744 13 [L-R] * / %
3745 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3746 15 [L-R] fn() [] -> .
3748 unary +, - and * have higher precedence than the corresponding binary
3749 operators. */
3752 op_code_prio (enum tree_code code)
3754 switch (code)
3756 case TREE_LIST:
3757 case COMPOUND_EXPR:
3758 case BIND_EXPR:
3759 return 1;
3761 case MODIFY_EXPR:
3762 case INIT_EXPR:
3763 return 2;
3765 case COND_EXPR:
3766 return 3;
3768 case TRUTH_OR_EXPR:
3769 case TRUTH_ORIF_EXPR:
3770 return 4;
3772 case TRUTH_AND_EXPR:
3773 case TRUTH_ANDIF_EXPR:
3774 return 5;
3776 case BIT_IOR_EXPR:
3777 return 6;
3779 case BIT_XOR_EXPR:
3780 case TRUTH_XOR_EXPR:
3781 return 7;
3783 case BIT_AND_EXPR:
3784 return 8;
3786 case EQ_EXPR:
3787 case NE_EXPR:
3788 return 9;
3790 case UNLT_EXPR:
3791 case UNLE_EXPR:
3792 case UNGT_EXPR:
3793 case UNGE_EXPR:
3794 case UNEQ_EXPR:
3795 case LTGT_EXPR:
3796 case ORDERED_EXPR:
3797 case UNORDERED_EXPR:
3798 case LT_EXPR:
3799 case LE_EXPR:
3800 case GT_EXPR:
3801 case GE_EXPR:
3802 return 10;
3804 case LSHIFT_EXPR:
3805 case RSHIFT_EXPR:
3806 case LROTATE_EXPR:
3807 case RROTATE_EXPR:
3808 case VEC_WIDEN_LSHIFT_HI_EXPR:
3809 case VEC_WIDEN_LSHIFT_LO_EXPR:
3810 case WIDEN_LSHIFT_EXPR:
3811 return 11;
3813 case WIDEN_SUM_EXPR:
3814 case PLUS_EXPR:
3815 case POINTER_PLUS_EXPR:
3816 case POINTER_DIFF_EXPR:
3817 case MINUS_EXPR:
3818 return 12;
3820 case VEC_WIDEN_MULT_HI_EXPR:
3821 case VEC_WIDEN_MULT_LO_EXPR:
3822 case WIDEN_MULT_EXPR:
3823 case DOT_PROD_EXPR:
3824 case WIDEN_MULT_PLUS_EXPR:
3825 case WIDEN_MULT_MINUS_EXPR:
3826 case MULT_EXPR:
3827 case MULT_HIGHPART_EXPR:
3828 case TRUNC_DIV_EXPR:
3829 case CEIL_DIV_EXPR:
3830 case FLOOR_DIV_EXPR:
3831 case ROUND_DIV_EXPR:
3832 case RDIV_EXPR:
3833 case EXACT_DIV_EXPR:
3834 case TRUNC_MOD_EXPR:
3835 case CEIL_MOD_EXPR:
3836 case FLOOR_MOD_EXPR:
3837 case ROUND_MOD_EXPR:
3838 return 13;
3840 case TRUTH_NOT_EXPR:
3841 case BIT_NOT_EXPR:
3842 case POSTINCREMENT_EXPR:
3843 case POSTDECREMENT_EXPR:
3844 case PREINCREMENT_EXPR:
3845 case PREDECREMENT_EXPR:
3846 case NEGATE_EXPR:
3847 case INDIRECT_REF:
3848 case ADDR_EXPR:
3849 case FLOAT_EXPR:
3850 CASE_CONVERT:
3851 case FIX_TRUNC_EXPR:
3852 case TARGET_EXPR:
3853 return 14;
3855 case CALL_EXPR:
3856 case ARRAY_REF:
3857 case ARRAY_RANGE_REF:
3858 case COMPONENT_REF:
3859 return 15;
3861 /* Special expressions. */
3862 case MIN_EXPR:
3863 case MAX_EXPR:
3864 case ABS_EXPR:
3865 case REALPART_EXPR:
3866 case IMAGPART_EXPR:
3867 case VEC_UNPACK_HI_EXPR:
3868 case VEC_UNPACK_LO_EXPR:
3869 case VEC_UNPACK_FLOAT_HI_EXPR:
3870 case VEC_UNPACK_FLOAT_LO_EXPR:
3871 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3872 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3873 case VEC_PACK_TRUNC_EXPR:
3874 case VEC_PACK_SAT_EXPR:
3875 return 16;
3877 default:
3878 /* Return an arbitrarily high precedence to avoid surrounding single
3879 VAR_DECLs in ()s. */
3880 return 9999;
3884 /* Return the priority of the operator OP. */
3887 op_prio (const_tree op)
3889 enum tree_code code;
3891 if (op == NULL)
3892 return 9999;
3894 code = TREE_CODE (op);
3895 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3896 return op_prio (TREE_OPERAND (op, 0));
3898 return op_code_prio (code);
3901 /* Return the symbol associated with operator CODE. */
3903 const char *
3904 op_symbol_code (enum tree_code code)
3906 switch (code)
3908 case MODIFY_EXPR:
3909 return "=";
3911 case TRUTH_OR_EXPR:
3912 case TRUTH_ORIF_EXPR:
3913 return "||";
3915 case TRUTH_AND_EXPR:
3916 case TRUTH_ANDIF_EXPR:
3917 return "&&";
3919 case BIT_IOR_EXPR:
3920 return "|";
3922 case TRUTH_XOR_EXPR:
3923 case BIT_XOR_EXPR:
3924 return "^";
3926 case ADDR_EXPR:
3927 case BIT_AND_EXPR:
3928 return "&";
3930 case ORDERED_EXPR:
3931 return "ord";
3932 case UNORDERED_EXPR:
3933 return "unord";
3935 case EQ_EXPR:
3936 return "==";
3937 case UNEQ_EXPR:
3938 return "u==";
3940 case NE_EXPR:
3941 return "!=";
3943 case LT_EXPR:
3944 return "<";
3945 case UNLT_EXPR:
3946 return "u<";
3948 case LE_EXPR:
3949 return "<=";
3950 case UNLE_EXPR:
3951 return "u<=";
3953 case GT_EXPR:
3954 return ">";
3955 case UNGT_EXPR:
3956 return "u>";
3958 case GE_EXPR:
3959 return ">=";
3960 case UNGE_EXPR:
3961 return "u>=";
3963 case LTGT_EXPR:
3964 return "<>";
3966 case LSHIFT_EXPR:
3967 return "<<";
3969 case RSHIFT_EXPR:
3970 return ">>";
3972 case LROTATE_EXPR:
3973 return "r<<";
3975 case RROTATE_EXPR:
3976 return "r>>";
3978 case WIDEN_LSHIFT_EXPR:
3979 return "w<<";
3981 case POINTER_PLUS_EXPR:
3982 return "+";
3984 case PLUS_EXPR:
3985 return "+";
3987 case WIDEN_SUM_EXPR:
3988 return "w+";
3990 case WIDEN_MULT_EXPR:
3991 return "w*";
3993 case MULT_HIGHPART_EXPR:
3994 return "h*";
3996 case NEGATE_EXPR:
3997 case MINUS_EXPR:
3998 case POINTER_DIFF_EXPR:
3999 return "-";
4001 case BIT_NOT_EXPR:
4002 return "~";
4004 case TRUTH_NOT_EXPR:
4005 return "!";
4007 case MULT_EXPR:
4008 case INDIRECT_REF:
4009 return "*";
4011 case TRUNC_DIV_EXPR:
4012 case RDIV_EXPR:
4013 return "/";
4015 case CEIL_DIV_EXPR:
4016 return "/[cl]";
4018 case FLOOR_DIV_EXPR:
4019 return "/[fl]";
4021 case ROUND_DIV_EXPR:
4022 return "/[rd]";
4024 case EXACT_DIV_EXPR:
4025 return "/[ex]";
4027 case TRUNC_MOD_EXPR:
4028 return "%";
4030 case CEIL_MOD_EXPR:
4031 return "%[cl]";
4033 case FLOOR_MOD_EXPR:
4034 return "%[fl]";
4036 case ROUND_MOD_EXPR:
4037 return "%[rd]";
4039 case PREDECREMENT_EXPR:
4040 return " --";
4042 case PREINCREMENT_EXPR:
4043 return " ++";
4045 case POSTDECREMENT_EXPR:
4046 return "-- ";
4048 case POSTINCREMENT_EXPR:
4049 return "++ ";
4051 case MAX_EXPR:
4052 return "max";
4054 case MIN_EXPR:
4055 return "min";
4057 default:
4058 return "<<< ??? >>>";
4062 /* Return the symbol associated with operator OP. */
4064 static const char *
4065 op_symbol (const_tree op)
4067 return op_symbol_code (TREE_CODE (op));
4070 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4071 the gimple_call_fn of a GIMPLE_CALL. */
4073 void
4074 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4076 tree op0 = node;
4078 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4079 op0 = TREE_OPERAND (op0, 0);
4081 again:
4082 switch (TREE_CODE (op0))
4084 case VAR_DECL:
4085 case PARM_DECL:
4086 case FUNCTION_DECL:
4087 dump_function_name (pp, op0, flags);
4088 break;
4090 case ADDR_EXPR:
4091 case INDIRECT_REF:
4092 CASE_CONVERT:
4093 op0 = TREE_OPERAND (op0, 0);
4094 goto again;
4096 case COND_EXPR:
4097 pp_left_paren (pp);
4098 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4099 pp_string (pp, ") ? ");
4100 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4101 pp_string (pp, " : ");
4102 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4103 break;
4105 case ARRAY_REF:
4106 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4107 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4108 else
4109 dump_generic_node (pp, op0, 0, flags, false);
4110 break;
4112 case MEM_REF:
4113 if (integer_zerop (TREE_OPERAND (op0, 1)))
4115 op0 = TREE_OPERAND (op0, 0);
4116 goto again;
4118 /* Fallthru. */
4119 case COMPONENT_REF:
4120 case SSA_NAME:
4121 case OBJ_TYPE_REF:
4122 dump_generic_node (pp, op0, 0, flags, false);
4123 break;
4125 default:
4126 NIY;
4130 /* Print the first N characters in the array STR, replacing non-printable
4131 characters (including embedded nuls) with unambiguous escape sequences. */
4133 static void
4134 pretty_print_string (pretty_printer *pp, const char *str, unsigned n)
4136 if (str == NULL)
4137 return;
4139 for ( ; n; --n, ++str)
4141 switch (str[0])
4143 case '\b':
4144 pp_string (pp, "\\b");
4145 break;
4147 case '\f':
4148 pp_string (pp, "\\f");
4149 break;
4151 case '\n':
4152 pp_string (pp, "\\n");
4153 break;
4155 case '\r':
4156 pp_string (pp, "\\r");
4157 break;
4159 case '\t':
4160 pp_string (pp, "\\t");
4161 break;
4163 case '\v':
4164 pp_string (pp, "\\v");
4165 break;
4167 case '\\':
4168 pp_string (pp, "\\\\");
4169 break;
4171 case '\"':
4172 pp_string (pp, "\\\"");
4173 break;
4175 case '\'':
4176 pp_string (pp, "\\'");
4177 break;
4179 default:
4180 if (str[0] || n > 1)
4182 if (!ISPRINT (str[0]))
4184 char buf[5];
4185 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4186 pp_string (pp, buf);
4188 else
4189 pp_character (pp, str[0]);
4190 break;
4196 static void
4197 maybe_init_pretty_print (FILE *file)
4199 if (!tree_pp)
4201 tree_pp = new pretty_printer ();
4202 pp_needs_newline (tree_pp) = true;
4203 pp_translate_identifiers (tree_pp) = false;
4206 tree_pp->buffer->stream = file;
4209 static void
4210 newline_and_indent (pretty_printer *pp, int spc)
4212 pp_newline (pp);
4213 INDENT (spc);
4216 /* Handle the %K format for TEXT. Separate from default_tree_printer
4217 so it can also be used in front ends.
4218 The location LOC and BLOCK are expected to be extracted by the caller
4219 from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
4221 void
4222 percent_K_format (text_info *text, location_t loc, tree block)
4224 text->set_location (0, loc, SHOW_RANGE_WITH_CARET);
4225 gcc_assert (pp_ti_abstract_origin (text) != NULL);
4226 *pp_ti_abstract_origin (text) = NULL;
4228 while (block
4229 && TREE_CODE (block) == BLOCK
4230 && BLOCK_ABSTRACT_ORIGIN (block))
4232 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4233 if (TREE_CODE (ao) == FUNCTION_DECL)
4235 *pp_ti_abstract_origin (text) = block;
4236 break;
4238 block = BLOCK_SUPERCONTEXT (block);
4242 /* Print the identifier ID to PRETTY-PRINTER. */
4244 void
4245 pp_tree_identifier (pretty_printer *pp, tree id)
4247 if (pp_translate_identifiers (pp))
4249 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4250 pp_append_text (pp, text, text + strlen (text));
4252 else
4253 pp_append_text (pp, IDENTIFIER_POINTER (id),
4254 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4257 /* A helper function that is used to dump function information before the
4258 function dump. */
4260 void
4261 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4263 const char *dname, *aname;
4264 struct cgraph_node *node = cgraph_node::get (fdecl);
4265 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4267 dname = lang_hooks.decl_printable_name (fdecl, 1);
4269 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4270 aname = (IDENTIFIER_POINTER
4271 (DECL_ASSEMBLER_NAME (fdecl)));
4272 else
4273 aname = "<unset-asm-name>";
4275 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4276 dname, aname, fun->funcdef_no);
4277 if (!(flags & TDF_NOUID))
4278 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4279 if (node)
4281 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4282 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4283 node->frequency == NODE_FREQUENCY_HOT
4284 ? " (hot)"
4285 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4286 ? " (unlikely executed)"
4287 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4288 ? " (executed once)"
4289 : "");
4291 else
4292 fprintf (dump_file, ")\n\n");
4295 /* Dump double_int D to pretty_printer PP. UNS is true
4296 if D is unsigned and false otherwise. */
4297 void
4298 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4300 if (d.fits_shwi ())
4301 pp_wide_integer (pp, d.low);
4302 else if (d.fits_uhwi ())
4303 pp_unsigned_wide_integer (pp, d.low);
4304 else
4306 unsigned HOST_WIDE_INT low = d.low;
4307 HOST_WIDE_INT high = d.high;
4308 if (!uns && d.is_negative ())
4310 pp_minus (pp);
4311 high = ~high + !low;
4312 low = -low;
4314 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4315 systems? */
4316 sprintf (pp_buffer (pp)->digit_buffer,
4317 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4318 (unsigned HOST_WIDE_INT) high, low);
4319 pp_string (pp, pp_buffer (pp)->digit_buffer);
4323 #if __GNUC__ >= 10
4324 # pragma GCC diagnostic pop
4325 #endif