[Ada] Crash on Loop_Entry for while_loop involving substrings
[official-gcc.git] / gcc / tree-pretty-print.c
blob53b3f55a3e6a14d4df19e65deb7eb5829b5b06ae
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_USE_DEVICE_ADDR:
469 name = "use_device_addr";
470 goto print_remap;
471 case OMP_CLAUSE_IS_DEVICE_PTR:
472 name = "is_device_ptr";
473 goto print_remap;
474 case OMP_CLAUSE_INCLUSIVE:
475 name = "inclusive";
476 goto print_remap;
477 case OMP_CLAUSE_EXCLUSIVE:
478 name = "exclusive";
479 goto print_remap;
480 case OMP_CLAUSE__LOOPTEMP_:
481 name = "_looptemp_";
482 goto print_remap;
483 case OMP_CLAUSE__REDUCTEMP_:
484 name = "_reductemp_";
485 goto print_remap;
486 case OMP_CLAUSE__CONDTEMP_:
487 name = "_condtemp_";
488 goto print_remap;
489 case OMP_CLAUSE__SCANTEMP_:
490 name = "_scantemp_";
491 goto print_remap;
492 case OMP_CLAUSE_TO_DECLARE:
493 name = "to";
494 goto print_remap;
495 case OMP_CLAUSE_LINK:
496 name = "link";
497 goto print_remap;
498 case OMP_CLAUSE_NONTEMPORAL:
499 name = "nontemporal";
500 goto print_remap;
501 print_remap:
502 pp_string (pp, name);
503 pp_left_paren (pp);
504 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
505 spc, flags, false);
506 pp_right_paren (pp);
507 break;
509 case OMP_CLAUSE_TASK_REDUCTION:
510 case OMP_CLAUSE_IN_REDUCTION:
511 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
512 ? "in_" : "task_");
513 /* FALLTHRU */
514 case OMP_CLAUSE_REDUCTION:
515 pp_string (pp, "reduction(");
516 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
518 if (OMP_CLAUSE_REDUCTION_TASK (clause))
519 pp_string (pp, "task,");
520 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
521 pp_string (pp, "inscan,");
523 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
525 pp_string (pp,
526 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
527 pp_colon (pp);
529 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
530 spc, flags, false);
531 pp_right_paren (pp);
532 break;
534 case OMP_CLAUSE_IF:
535 pp_string (pp, "if(");
536 switch (OMP_CLAUSE_IF_MODIFIER (clause))
538 case ERROR_MARK: break;
539 case VOID_CST: pp_string (pp, "cancel:"); break;
540 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
541 case OMP_SIMD: pp_string (pp, "simd:"); break;
542 case OMP_TASK: pp_string (pp, "task:"); break;
543 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
544 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
545 case OMP_TARGET: pp_string (pp, "target:"); break;
546 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
547 case OMP_TARGET_ENTER_DATA:
548 pp_string (pp, "target enter data:"); break;
549 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
550 default: gcc_unreachable ();
552 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
553 spc, flags, false);
554 pp_right_paren (pp);
555 break;
557 case OMP_CLAUSE_NUM_THREADS:
558 pp_string (pp, "num_threads(");
559 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
560 spc, flags, false);
561 pp_right_paren (pp);
562 break;
564 case OMP_CLAUSE_NOWAIT:
565 pp_string (pp, "nowait");
566 break;
567 case OMP_CLAUSE_ORDERED:
568 pp_string (pp, "ordered");
569 if (OMP_CLAUSE_ORDERED_EXPR (clause))
571 pp_left_paren (pp);
572 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
573 spc, flags, false);
574 pp_right_paren (pp);
576 break;
578 case OMP_CLAUSE_DEFAULT:
579 pp_string (pp, "default(");
580 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
582 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
583 break;
584 case OMP_CLAUSE_DEFAULT_SHARED:
585 pp_string (pp, "shared");
586 break;
587 case OMP_CLAUSE_DEFAULT_NONE:
588 pp_string (pp, "none");
589 break;
590 case OMP_CLAUSE_DEFAULT_PRIVATE:
591 pp_string (pp, "private");
592 break;
593 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
594 pp_string (pp, "firstprivate");
595 break;
596 case OMP_CLAUSE_DEFAULT_PRESENT:
597 pp_string (pp, "present");
598 break;
599 default:
600 gcc_unreachable ();
602 pp_right_paren (pp);
603 break;
605 case OMP_CLAUSE_SCHEDULE:
606 pp_string (pp, "schedule(");
607 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
608 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
609 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
611 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
612 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
613 pp_string (pp, "monotonic");
614 else
615 pp_string (pp, "nonmonotonic");
616 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
617 pp_comma (pp);
618 else
619 pp_colon (pp);
621 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
622 pp_string (pp, "simd:");
624 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
626 case OMP_CLAUSE_SCHEDULE_STATIC:
627 pp_string (pp, "static");
628 break;
629 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
630 pp_string (pp, "dynamic");
631 break;
632 case OMP_CLAUSE_SCHEDULE_GUIDED:
633 pp_string (pp, "guided");
634 break;
635 case OMP_CLAUSE_SCHEDULE_RUNTIME:
636 pp_string (pp, "runtime");
637 break;
638 case OMP_CLAUSE_SCHEDULE_AUTO:
639 pp_string (pp, "auto");
640 break;
641 default:
642 gcc_unreachable ();
644 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
646 pp_comma (pp);
647 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
648 spc, flags, false);
650 pp_right_paren (pp);
651 break;
653 case OMP_CLAUSE_UNTIED:
654 pp_string (pp, "untied");
655 break;
657 case OMP_CLAUSE_COLLAPSE:
658 pp_string (pp, "collapse(");
659 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
660 spc, flags, false);
661 pp_right_paren (pp);
662 break;
664 case OMP_CLAUSE_FINAL:
665 pp_string (pp, "final(");
666 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
667 spc, flags, false);
668 pp_right_paren (pp);
669 break;
671 case OMP_CLAUSE_MERGEABLE:
672 pp_string (pp, "mergeable");
673 break;
675 case OMP_CLAUSE_LINEAR:
676 pp_string (pp, "linear(");
677 switch (OMP_CLAUSE_LINEAR_KIND (clause))
679 case OMP_CLAUSE_LINEAR_DEFAULT:
680 break;
681 case OMP_CLAUSE_LINEAR_REF:
682 pp_string (pp, "ref(");
683 break;
684 case OMP_CLAUSE_LINEAR_VAL:
685 pp_string (pp, "val(");
686 break;
687 case OMP_CLAUSE_LINEAR_UVAL:
688 pp_string (pp, "uval(");
689 break;
690 default:
691 gcc_unreachable ();
693 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
694 spc, flags, false);
695 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
696 pp_right_paren (pp);
697 pp_colon (pp);
698 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
699 spc, flags, false);
700 pp_right_paren (pp);
701 break;
703 case OMP_CLAUSE_ALIGNED:
704 pp_string (pp, "aligned(");
705 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
706 spc, flags, false);
707 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
709 pp_colon (pp);
710 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
711 spc, flags, false);
713 pp_right_paren (pp);
714 break;
716 case OMP_CLAUSE_DEPEND:
717 pp_string (pp, "depend(");
718 switch (OMP_CLAUSE_DEPEND_KIND (clause))
720 case OMP_CLAUSE_DEPEND_DEPOBJ:
721 name = "depobj";
722 break;
723 case OMP_CLAUSE_DEPEND_IN:
724 name = "in";
725 break;
726 case OMP_CLAUSE_DEPEND_OUT:
727 name = "out";
728 break;
729 case OMP_CLAUSE_DEPEND_INOUT:
730 name = "inout";
731 break;
732 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
733 name = "mutexinoutset";
734 break;
735 case OMP_CLAUSE_DEPEND_SOURCE:
736 pp_string (pp, "source)");
737 return;
738 case OMP_CLAUSE_DEPEND_LAST:
739 name = "__internal__";
740 break;
741 case OMP_CLAUSE_DEPEND_SINK:
742 pp_string (pp, "sink:");
743 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
744 if (TREE_CODE (t) == TREE_LIST)
746 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
747 if (TREE_PURPOSE (t) != integer_zero_node)
749 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
750 pp_minus (pp);
751 else
752 pp_plus (pp);
753 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
754 false);
756 if (TREE_CHAIN (t))
757 pp_comma (pp);
759 else
760 gcc_unreachable ();
761 pp_right_paren (pp);
762 return;
763 default:
764 gcc_unreachable ();
767 tree t = OMP_CLAUSE_DECL (clause);
768 if (TREE_CODE (t) == TREE_LIST
769 && TREE_PURPOSE (t)
770 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
772 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
773 pp_colon (pp);
774 t = TREE_VALUE (t);
776 pp_string (pp, name);
777 pp_colon (pp);
778 dump_generic_node (pp, t, spc, flags, false);
779 pp_right_paren (pp);
781 break;
783 case OMP_CLAUSE_MAP:
784 pp_string (pp, "map(");
785 switch (OMP_CLAUSE_MAP_KIND (clause))
787 case GOMP_MAP_ALLOC:
788 case GOMP_MAP_POINTER:
789 pp_string (pp, "alloc");
790 break;
791 case GOMP_MAP_TO:
792 case GOMP_MAP_TO_PSET:
793 pp_string (pp, "to");
794 break;
795 case GOMP_MAP_FROM:
796 pp_string (pp, "from");
797 break;
798 case GOMP_MAP_TOFROM:
799 pp_string (pp, "tofrom");
800 break;
801 case GOMP_MAP_FORCE_ALLOC:
802 pp_string (pp, "force_alloc");
803 break;
804 case GOMP_MAP_FORCE_TO:
805 pp_string (pp, "force_to");
806 break;
807 case GOMP_MAP_FORCE_FROM:
808 pp_string (pp, "force_from");
809 break;
810 case GOMP_MAP_FORCE_TOFROM:
811 pp_string (pp, "force_tofrom");
812 break;
813 case GOMP_MAP_FORCE_PRESENT:
814 pp_string (pp, "force_present");
815 break;
816 case GOMP_MAP_DELETE:
817 pp_string (pp, "delete");
818 break;
819 case GOMP_MAP_FORCE_DEVICEPTR:
820 pp_string (pp, "force_deviceptr");
821 break;
822 case GOMP_MAP_ALWAYS_TO:
823 pp_string (pp, "always,to");
824 break;
825 case GOMP_MAP_ALWAYS_FROM:
826 pp_string (pp, "always,from");
827 break;
828 case GOMP_MAP_ALWAYS_TOFROM:
829 pp_string (pp, "always,tofrom");
830 break;
831 case GOMP_MAP_RELEASE:
832 pp_string (pp, "release");
833 break;
834 case GOMP_MAP_FIRSTPRIVATE_POINTER:
835 pp_string (pp, "firstprivate");
836 break;
837 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
838 pp_string (pp, "firstprivate ref");
839 break;
840 case GOMP_MAP_STRUCT:
841 pp_string (pp, "struct");
842 break;
843 case GOMP_MAP_ALWAYS_POINTER:
844 pp_string (pp, "always_pointer");
845 break;
846 case GOMP_MAP_DEVICE_RESIDENT:
847 pp_string (pp, "device_resident");
848 break;
849 case GOMP_MAP_LINK:
850 pp_string (pp, "link");
851 break;
852 default:
853 gcc_unreachable ();
855 pp_colon (pp);
856 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
857 spc, flags, false);
858 print_clause_size:
859 if (OMP_CLAUSE_SIZE (clause))
861 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
862 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
864 case GOMP_MAP_POINTER:
865 case GOMP_MAP_FIRSTPRIVATE_POINTER:
866 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
867 case GOMP_MAP_ALWAYS_POINTER:
868 pp_string (pp, " [pointer assign, bias: ");
869 break;
870 case GOMP_MAP_TO_PSET:
871 pp_string (pp, " [pointer set, len: ");
872 break;
873 default:
874 pp_string (pp, " [len: ");
875 break;
877 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
878 spc, flags, false);
879 pp_right_bracket (pp);
881 pp_right_paren (pp);
882 break;
884 case OMP_CLAUSE_FROM:
885 pp_string (pp, "from(");
886 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
887 spc, flags, false);
888 goto print_clause_size;
890 case OMP_CLAUSE_TO:
891 pp_string (pp, "to(");
892 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
893 spc, flags, false);
894 goto print_clause_size;
896 case OMP_CLAUSE__CACHE_:
897 pp_string (pp, "(");
898 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
899 spc, flags, false);
900 goto print_clause_size;
902 case OMP_CLAUSE_NUM_TEAMS:
903 pp_string (pp, "num_teams(");
904 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
905 spc, flags, false);
906 pp_right_paren (pp);
907 break;
909 case OMP_CLAUSE_THREAD_LIMIT:
910 pp_string (pp, "thread_limit(");
911 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
912 spc, flags, false);
913 pp_right_paren (pp);
914 break;
916 case OMP_CLAUSE_DEVICE:
917 pp_string (pp, "device(");
918 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
919 spc, flags, false);
920 pp_right_paren (pp);
921 break;
923 case OMP_CLAUSE_DIST_SCHEDULE:
924 pp_string (pp, "dist_schedule(static");
925 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
927 pp_comma (pp);
928 dump_generic_node (pp,
929 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
930 spc, flags, false);
932 pp_right_paren (pp);
933 break;
935 case OMP_CLAUSE_PROC_BIND:
936 pp_string (pp, "proc_bind(");
937 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
939 case OMP_CLAUSE_PROC_BIND_MASTER:
940 pp_string (pp, "master");
941 break;
942 case OMP_CLAUSE_PROC_BIND_CLOSE:
943 pp_string (pp, "close");
944 break;
945 case OMP_CLAUSE_PROC_BIND_SPREAD:
946 pp_string (pp, "spread");
947 break;
948 default:
949 gcc_unreachable ();
951 pp_right_paren (pp);
952 break;
954 case OMP_CLAUSE_DEVICE_TYPE:
955 pp_string (pp, "device_type(");
956 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
958 case OMP_CLAUSE_DEVICE_TYPE_HOST:
959 pp_string (pp, "host");
960 break;
961 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
962 pp_string (pp, "nohost");
963 break;
964 case OMP_CLAUSE_DEVICE_TYPE_ANY:
965 pp_string (pp, "any");
966 break;
967 default:
968 gcc_unreachable ();
970 pp_right_paren (pp);
971 break;
973 case OMP_CLAUSE_SAFELEN:
974 pp_string (pp, "safelen(");
975 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
976 spc, flags, false);
977 pp_right_paren (pp);
978 break;
980 case OMP_CLAUSE_SIMDLEN:
981 pp_string (pp, "simdlen(");
982 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
983 spc, flags, false);
984 pp_right_paren (pp);
985 break;
987 case OMP_CLAUSE_PRIORITY:
988 pp_string (pp, "priority(");
989 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
990 spc, flags, false);
991 pp_right_paren (pp);
992 break;
994 case OMP_CLAUSE_GRAINSIZE:
995 pp_string (pp, "grainsize(");
996 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
997 spc, flags, false);
998 pp_right_paren (pp);
999 break;
1001 case OMP_CLAUSE_NUM_TASKS:
1002 pp_string (pp, "num_tasks(");
1003 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1004 spc, flags, false);
1005 pp_right_paren (pp);
1006 break;
1008 case OMP_CLAUSE_HINT:
1009 pp_string (pp, "hint(");
1010 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1011 spc, flags, false);
1012 pp_right_paren (pp);
1013 break;
1015 case OMP_CLAUSE_DEFAULTMAP:
1016 pp_string (pp, "defaultmap(");
1017 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1019 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1020 pp_string (pp, "alloc");
1021 break;
1022 case OMP_CLAUSE_DEFAULTMAP_TO:
1023 pp_string (pp, "to");
1024 break;
1025 case OMP_CLAUSE_DEFAULTMAP_FROM:
1026 pp_string (pp, "from");
1027 break;
1028 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1029 pp_string (pp, "tofrom");
1030 break;
1031 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1032 pp_string (pp, "firstprivate");
1033 break;
1034 case OMP_CLAUSE_DEFAULTMAP_NONE:
1035 pp_string (pp, "none");
1036 break;
1037 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1038 pp_string (pp, "default");
1039 break;
1040 default:
1041 gcc_unreachable ();
1043 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1045 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1046 break;
1047 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1048 pp_string (pp, ":scalar");
1049 break;
1050 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1051 pp_string (pp, ":aggregate");
1052 break;
1053 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1054 pp_string (pp, ":allocatable");
1055 break;
1056 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1057 pp_string (pp, ":pointer");
1058 break;
1059 default:
1060 gcc_unreachable ();
1062 pp_right_paren (pp);
1063 break;
1065 case OMP_CLAUSE_ORDER:
1066 pp_string (pp, "order(concurrent)");
1067 break;
1069 case OMP_CLAUSE_BIND:
1070 pp_string (pp, "bind(");
1071 switch (OMP_CLAUSE_BIND_KIND (clause))
1073 case OMP_CLAUSE_BIND_TEAMS:
1074 pp_string (pp, "teams");
1075 break;
1076 case OMP_CLAUSE_BIND_PARALLEL:
1077 pp_string (pp, "parallel");
1078 break;
1079 case OMP_CLAUSE_BIND_THREAD:
1080 pp_string (pp, "thread");
1081 break;
1082 default:
1083 gcc_unreachable ();
1085 pp_right_paren (pp);
1086 break;
1088 case OMP_CLAUSE__SIMDUID_:
1089 pp_string (pp, "_simduid_(");
1090 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1091 spc, flags, false);
1092 pp_right_paren (pp);
1093 break;
1095 case OMP_CLAUSE__SIMT_:
1096 pp_string (pp, "_simt_");
1097 break;
1099 case OMP_CLAUSE_GANG:
1100 pp_string (pp, "gang");
1101 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1103 pp_string (pp, "(num: ");
1104 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1105 spc, flags, false);
1107 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1109 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1110 pp_left_paren (pp);
1111 else
1112 pp_space (pp);
1113 pp_string (pp, "static:");
1114 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1115 == integer_minus_one_node)
1116 pp_character (pp, '*');
1117 else
1118 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1119 spc, flags, false);
1121 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1122 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1123 pp_right_paren (pp);
1124 break;
1126 case OMP_CLAUSE_ASYNC:
1127 pp_string (pp, "async");
1128 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1130 pp_character(pp, '(');
1131 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1132 spc, flags, false);
1133 pp_character(pp, ')');
1135 break;
1137 case OMP_CLAUSE_AUTO:
1138 case OMP_CLAUSE_SEQ:
1139 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1140 break;
1142 case OMP_CLAUSE_WAIT:
1143 pp_string (pp, "wait(");
1144 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1145 spc, flags, false);
1146 pp_character(pp, ')');
1147 break;
1149 case OMP_CLAUSE_WORKER:
1150 pp_string (pp, "worker");
1151 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1153 pp_left_paren (pp);
1154 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1155 spc, flags, false);
1156 pp_right_paren (pp);
1158 break;
1160 case OMP_CLAUSE_VECTOR:
1161 pp_string (pp, "vector");
1162 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1164 pp_left_paren (pp);
1165 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1166 spc, flags, false);
1167 pp_right_paren (pp);
1169 break;
1171 case OMP_CLAUSE_NUM_GANGS:
1172 pp_string (pp, "num_gangs(");
1173 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1174 spc, flags, false);
1175 pp_character (pp, ')');
1176 break;
1178 case OMP_CLAUSE_NUM_WORKERS:
1179 pp_string (pp, "num_workers(");
1180 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1181 spc, flags, false);
1182 pp_character (pp, ')');
1183 break;
1185 case OMP_CLAUSE_VECTOR_LENGTH:
1186 pp_string (pp, "vector_length(");
1187 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1188 spc, flags, false);
1189 pp_character (pp, ')');
1190 break;
1192 case OMP_CLAUSE_INBRANCH:
1193 pp_string (pp, "inbranch");
1194 break;
1195 case OMP_CLAUSE_NOTINBRANCH:
1196 pp_string (pp, "notinbranch");
1197 break;
1198 case OMP_CLAUSE_FOR:
1199 pp_string (pp, "for");
1200 break;
1201 case OMP_CLAUSE_PARALLEL:
1202 pp_string (pp, "parallel");
1203 break;
1204 case OMP_CLAUSE_SECTIONS:
1205 pp_string (pp, "sections");
1206 break;
1207 case OMP_CLAUSE_TASKGROUP:
1208 pp_string (pp, "taskgroup");
1209 break;
1210 case OMP_CLAUSE_NOGROUP:
1211 pp_string (pp, "nogroup");
1212 break;
1213 case OMP_CLAUSE_THREADS:
1214 pp_string (pp, "threads");
1215 break;
1216 case OMP_CLAUSE_SIMD:
1217 pp_string (pp, "simd");
1218 break;
1219 case OMP_CLAUSE_INDEPENDENT:
1220 pp_string (pp, "independent");
1221 break;
1222 case OMP_CLAUSE_TILE:
1223 pp_string (pp, "tile(");
1224 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1225 spc, flags, false);
1226 pp_right_paren (pp);
1227 break;
1229 case OMP_CLAUSE__GRIDDIM_:
1230 pp_string (pp, "_griddim_(");
1231 pp_unsigned_wide_integer (pp, OMP_CLAUSE__GRIDDIM__DIMENSION (clause));
1232 pp_colon (pp);
1233 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__SIZE (clause), spc, flags,
1234 false);
1235 pp_comma (pp);
1236 dump_generic_node (pp, OMP_CLAUSE__GRIDDIM__GROUP (clause), spc, flags,
1237 false);
1238 pp_right_paren (pp);
1239 break;
1240 case OMP_CLAUSE_IF_PRESENT:
1241 pp_string (pp, "if_present");
1242 break;
1243 case OMP_CLAUSE_FINALIZE:
1244 pp_string (pp, "finalize");
1245 break;
1247 default:
1248 gcc_unreachable ();
1253 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1254 dump_generic_node. */
1256 void
1257 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1259 if (clause == NULL)
1260 return;
1262 pp_space (pp);
1263 while (1)
1265 dump_omp_clause (pp, clause, spc, flags);
1266 clause = OMP_CLAUSE_CHAIN (clause);
1267 if (clause == NULL)
1268 return;
1269 pp_space (pp);
1274 /* Dump location LOC to PP. */
1276 void
1277 dump_location (pretty_printer *pp, location_t loc)
1279 expanded_location xloc = expand_location (loc);
1281 pp_left_bracket (pp);
1282 if (xloc.file)
1284 pp_string (pp, xloc.file);
1285 pp_string (pp, ":");
1287 pp_decimal_int (pp, xloc.line);
1288 pp_colon (pp);
1289 pp_decimal_int (pp, xloc.column);
1290 pp_string (pp, "] ");
1294 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1295 dump_generic_node. */
1297 static void
1298 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1300 tree t;
1302 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1304 if (flags & TDF_ADDRESS)
1305 pp_printf (pp, "[%p] ", (void *) block);
1307 if (TREE_ASM_WRITTEN (block))
1308 pp_string (pp, "[written] ");
1310 if (flags & TDF_SLIM)
1311 return;
1313 if (BLOCK_SOURCE_LOCATION (block))
1314 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1316 newline_and_indent (pp, spc + 2);
1318 if (BLOCK_SUPERCONTEXT (block))
1320 pp_string (pp, "SUPERCONTEXT: ");
1321 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1322 flags | TDF_SLIM, false);
1323 newline_and_indent (pp, spc + 2);
1326 if (BLOCK_SUBBLOCKS (block))
1328 pp_string (pp, "SUBBLOCKS: ");
1329 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1331 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1332 pp_space (pp);
1334 newline_and_indent (pp, spc + 2);
1337 if (BLOCK_CHAIN (block))
1339 pp_string (pp, "SIBLINGS: ");
1340 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1342 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1343 pp_space (pp);
1345 newline_and_indent (pp, spc + 2);
1348 if (BLOCK_VARS (block))
1350 pp_string (pp, "VARS: ");
1351 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1353 dump_generic_node (pp, t, 0, flags, false);
1354 pp_space (pp);
1356 newline_and_indent (pp, spc + 2);
1359 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1361 unsigned i;
1362 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1364 pp_string (pp, "NONLOCALIZED_VARS: ");
1365 FOR_EACH_VEC_ELT (*nlv, i, t)
1367 dump_generic_node (pp, t, 0, flags, false);
1368 pp_space (pp);
1370 newline_and_indent (pp, spc + 2);
1373 if (BLOCK_ABSTRACT_ORIGIN (block))
1375 pp_string (pp, "ABSTRACT_ORIGIN: ");
1376 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1377 flags | TDF_SLIM, false);
1378 newline_and_indent (pp, spc + 2);
1381 if (BLOCK_FRAGMENT_ORIGIN (block))
1383 pp_string (pp, "FRAGMENT_ORIGIN: ");
1384 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1385 flags | TDF_SLIM, false);
1386 newline_and_indent (pp, spc + 2);
1389 if (BLOCK_FRAGMENT_CHAIN (block))
1391 pp_string (pp, "FRAGMENT_CHAIN: ");
1392 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1394 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1395 pp_space (pp);
1397 newline_and_indent (pp, spc + 2);
1401 /* Dump #pragma omp atomic memory order clause. */
1403 void
1404 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1406 switch (mo)
1408 case OMP_MEMORY_ORDER_RELAXED:
1409 pp_string (pp, " relaxed");
1410 break;
1411 case OMP_MEMORY_ORDER_SEQ_CST:
1412 pp_string (pp, " seq_cst");
1413 break;
1414 case OMP_MEMORY_ORDER_ACQ_REL:
1415 pp_string (pp, " acq_rel");
1416 break;
1417 case OMP_MEMORY_ORDER_ACQUIRE:
1418 pp_string (pp, " acquire");
1419 break;
1420 case OMP_MEMORY_ORDER_RELEASE:
1421 pp_string (pp, " release");
1422 break;
1423 case OMP_MEMORY_ORDER_UNSPECIFIED:
1424 break;
1425 default:
1426 gcc_unreachable ();
1430 /* Helper to dump a MEM_REF node. */
1432 static void
1433 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1435 if (flags & TDF_GIMPLE)
1437 pp_string (pp, "__MEM <");
1438 dump_generic_node (pp, TREE_TYPE (node),
1439 spc, flags | TDF_SLIM, false);
1440 if (TYPE_ALIGN (TREE_TYPE (node))
1441 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1443 pp_string (pp, ", ");
1444 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1446 pp_greater (pp);
1447 pp_string (pp, " (");
1448 if (TREE_TYPE (TREE_OPERAND (node, 0))
1449 != TREE_TYPE (TREE_OPERAND (node, 1)))
1451 pp_left_paren (pp);
1452 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1453 spc, flags | TDF_SLIM, false);
1454 pp_right_paren (pp);
1456 dump_generic_node (pp, TREE_OPERAND (node, 0),
1457 spc, flags | TDF_SLIM, false);
1458 if (! integer_zerop (TREE_OPERAND (node, 1)))
1460 pp_string (pp, " + ");
1461 dump_generic_node (pp, TREE_OPERAND (node, 1),
1462 spc, flags | TDF_SLIM, false);
1464 pp_right_paren (pp);
1466 else if (integer_zerop (TREE_OPERAND (node, 1))
1467 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1468 infer them and MEM_ATTR caching will share MEM_REFs
1469 with differently-typed op0s. */
1470 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1471 /* Released SSA_NAMES have no TREE_TYPE. */
1472 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1473 /* Same pointer types, but ignoring POINTER_TYPE vs.
1474 REFERENCE_TYPE. */
1475 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1476 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1477 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1478 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1479 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1480 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1481 /* Same value types ignoring qualifiers. */
1482 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1483 == TYPE_MAIN_VARIANT
1484 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1485 && (!(flags & TDF_ALIAS)
1486 || MR_DEPENDENCE_CLIQUE (node) == 0))
1488 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1490 /* Enclose pointers to arrays in parentheses. */
1491 tree op0 = TREE_OPERAND (node, 0);
1492 tree op0type = TREE_TYPE (op0);
1493 if (POINTER_TYPE_P (op0type)
1494 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1495 pp_left_paren (pp);
1496 pp_star (pp);
1497 dump_generic_node (pp, op0, spc, flags, false);
1498 if (POINTER_TYPE_P (op0type)
1499 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1500 pp_right_paren (pp);
1502 else
1503 dump_generic_node (pp,
1504 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1505 spc, flags, false);
1507 else
1509 pp_string (pp, "MEM");
1511 tree nodetype = TREE_TYPE (node);
1512 tree op0 = TREE_OPERAND (node, 0);
1513 tree op1 = TREE_OPERAND (node, 1);
1514 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1516 tree op0size = TYPE_SIZE (nodetype);
1517 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1519 if (!op0size || !op1size
1520 || !operand_equal_p (op0size, op1size, 0))
1522 pp_string (pp, " <");
1523 /* If the size of the type of the operand is not the same
1524 as the size of the MEM_REF expression include the type
1525 of the latter similar to the TDF_GIMPLE output to make
1526 it clear how many bytes of memory are being accessed. */
1527 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1528 pp_string (pp, "> ");
1531 pp_string (pp, "[(");
1532 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1533 pp_right_paren (pp);
1534 dump_generic_node (pp, op0, spc, flags, false);
1535 if (!integer_zerop (op1))
1536 if (!integer_zerop (TREE_OPERAND (node, 1)))
1538 pp_string (pp, " + ");
1539 dump_generic_node (pp, op1, spc, flags, false);
1541 if ((flags & TDF_ALIAS)
1542 && MR_DEPENDENCE_CLIQUE (node) != 0)
1544 pp_string (pp, " clique ");
1545 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1546 pp_string (pp, " base ");
1547 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1549 pp_right_bracket (pp);
1553 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1554 indent. FLAGS specifies details to show in the dump (see TDF_* in
1555 dumpfile.h). If IS_STMT is true, the object printed is considered
1556 to be a statement and it is terminated by ';' if appropriate. */
1559 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1560 bool is_stmt)
1562 tree type;
1563 tree op0, op1;
1564 const char *str;
1565 bool is_expr;
1566 enum tree_code code;
1568 if (node == NULL_TREE)
1569 return spc;
1571 is_expr = EXPR_P (node);
1573 if (is_stmt && (flags & TDF_STMTADDR))
1574 pp_printf (pp, "<&%p> ", (void *)node);
1576 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1577 dump_location (pp, EXPR_LOCATION (node));
1579 code = TREE_CODE (node);
1580 switch (code)
1582 case ERROR_MARK:
1583 pp_string (pp, "<<< error >>>");
1584 break;
1586 case IDENTIFIER_NODE:
1587 pp_tree_identifier (pp, node);
1588 break;
1590 case TREE_LIST:
1591 while (node && node != error_mark_node)
1593 if (TREE_PURPOSE (node))
1595 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1596 pp_space (pp);
1598 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1599 node = TREE_CHAIN (node);
1600 if (node && TREE_CODE (node) == TREE_LIST)
1602 pp_comma (pp);
1603 pp_space (pp);
1606 break;
1608 case TREE_BINFO:
1609 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1610 break;
1612 case TREE_VEC:
1614 size_t i;
1615 if (TREE_VEC_LENGTH (node) > 0)
1617 size_t len = TREE_VEC_LENGTH (node);
1618 for (i = 0; i < len - 1; i++)
1620 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1621 false);
1622 pp_comma (pp);
1623 pp_space (pp);
1625 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1626 flags, false);
1629 break;
1631 case VOID_TYPE:
1632 case INTEGER_TYPE:
1633 case REAL_TYPE:
1634 case FIXED_POINT_TYPE:
1635 case COMPLEX_TYPE:
1636 case VECTOR_TYPE:
1637 case ENUMERAL_TYPE:
1638 case BOOLEAN_TYPE:
1640 unsigned int quals = TYPE_QUALS (node);
1641 enum tree_code_class tclass;
1643 if (quals & TYPE_QUAL_ATOMIC)
1644 pp_string (pp, "atomic ");
1645 if (quals & TYPE_QUAL_CONST)
1646 pp_string (pp, "const ");
1647 else if (quals & TYPE_QUAL_VOLATILE)
1648 pp_string (pp, "volatile ");
1649 else if (quals & TYPE_QUAL_RESTRICT)
1650 pp_string (pp, "restrict ");
1652 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1654 pp_string (pp, "<address-space-");
1655 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1656 pp_string (pp, "> ");
1659 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1661 if (tclass == tcc_declaration)
1663 if (DECL_NAME (node))
1664 dump_decl_name (pp, node, flags);
1665 else
1666 pp_string (pp, "<unnamed type decl>");
1668 else if (tclass == tcc_type)
1670 if (TYPE_NAME (node))
1672 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1673 pp_tree_identifier (pp, TYPE_NAME (node));
1674 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1675 && DECL_NAME (TYPE_NAME (node)))
1676 dump_decl_name (pp, TYPE_NAME (node), flags);
1677 else
1678 pp_string (pp, "<unnamed type>");
1680 else if (TREE_CODE (node) == VECTOR_TYPE)
1682 pp_string (pp, "vector");
1683 pp_left_paren (pp);
1684 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1685 pp_string (pp, ") ");
1686 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1688 else if (TREE_CODE (node) == INTEGER_TYPE)
1690 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1691 pp_string (pp, (TYPE_UNSIGNED (node)
1692 ? "unsigned char"
1693 : "signed char"));
1694 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1695 pp_string (pp, (TYPE_UNSIGNED (node)
1696 ? "unsigned short"
1697 : "signed short"));
1698 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1699 pp_string (pp, (TYPE_UNSIGNED (node)
1700 ? "unsigned int"
1701 : "signed int"));
1702 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1703 pp_string (pp, (TYPE_UNSIGNED (node)
1704 ? "unsigned long"
1705 : "signed long"));
1706 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1707 pp_string (pp, (TYPE_UNSIGNED (node)
1708 ? "unsigned long long"
1709 : "signed long long"));
1710 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1711 && pow2p_hwi (TYPE_PRECISION (node)))
1713 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1714 pp_decimal_int (pp, TYPE_PRECISION (node));
1715 pp_string (pp, "_t");
1717 else
1719 pp_string (pp, (TYPE_UNSIGNED (node)
1720 ? "<unnamed-unsigned:"
1721 : "<unnamed-signed:"));
1722 pp_decimal_int (pp, TYPE_PRECISION (node));
1723 pp_greater (pp);
1726 else if (TREE_CODE (node) == COMPLEX_TYPE)
1728 pp_string (pp, "__complex__ ");
1729 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1731 else if (TREE_CODE (node) == REAL_TYPE)
1733 pp_string (pp, "<float:");
1734 pp_decimal_int (pp, TYPE_PRECISION (node));
1735 pp_greater (pp);
1737 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1739 pp_string (pp, "<fixed-point-");
1740 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1741 pp_decimal_int (pp, TYPE_PRECISION (node));
1742 pp_greater (pp);
1744 else if (TREE_CODE (node) == VOID_TYPE)
1745 pp_string (pp, "void");
1746 else
1747 pp_string (pp, "<unnamed type>");
1749 break;
1752 case POINTER_TYPE:
1753 case REFERENCE_TYPE:
1754 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1756 if (TREE_TYPE (node) == NULL)
1758 pp_string (pp, str);
1759 pp_string (pp, "<null type>");
1761 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1763 tree fnode = TREE_TYPE (node);
1765 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1766 pp_space (pp);
1767 pp_left_paren (pp);
1768 pp_string (pp, str);
1769 if (TYPE_IDENTIFIER (node))
1770 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1771 else if (flags & TDF_NOUID)
1772 pp_printf (pp, "<Txxxx>");
1773 else
1774 pp_printf (pp, "<T%x>", TYPE_UID (node));
1776 pp_right_paren (pp);
1777 dump_function_declaration (pp, fnode, spc, flags);
1779 else
1781 unsigned int quals = TYPE_QUALS (node);
1783 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1784 pp_space (pp);
1785 pp_string (pp, str);
1787 if (quals & TYPE_QUAL_CONST)
1788 pp_string (pp, " const");
1789 if (quals & TYPE_QUAL_VOLATILE)
1790 pp_string (pp, " volatile");
1791 if (quals & TYPE_QUAL_RESTRICT)
1792 pp_string (pp, " restrict");
1794 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1796 pp_string (pp, " <address-space-");
1797 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1798 pp_greater (pp);
1801 if (TYPE_REF_CAN_ALIAS_ALL (node))
1802 pp_string (pp, " {ref-all}");
1804 break;
1806 case OFFSET_TYPE:
1807 NIY;
1808 break;
1810 case MEM_REF:
1811 dump_mem_ref (pp, node, spc, flags);
1812 break;
1814 case TARGET_MEM_REF:
1816 const char *sep = "";
1817 tree tmp;
1819 pp_string (pp, "MEM[");
1821 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1823 pp_string (pp, sep);
1824 sep = ", ";
1825 pp_string (pp, "symbol: ");
1826 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1827 spc, flags, false);
1829 else
1831 pp_string (pp, sep);
1832 sep = ", ";
1833 pp_string (pp, "base: ");
1834 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1836 tmp = TMR_INDEX2 (node);
1837 if (tmp)
1839 pp_string (pp, sep);
1840 sep = ", ";
1841 pp_string (pp, "base: ");
1842 dump_generic_node (pp, tmp, spc, flags, false);
1844 tmp = TMR_INDEX (node);
1845 if (tmp)
1847 pp_string (pp, sep);
1848 sep = ", ";
1849 pp_string (pp, "index: ");
1850 dump_generic_node (pp, tmp, spc, flags, false);
1852 tmp = TMR_STEP (node);
1853 if (tmp)
1855 pp_string (pp, sep);
1856 sep = ", ";
1857 pp_string (pp, "step: ");
1858 dump_generic_node (pp, tmp, spc, flags, false);
1860 tmp = TMR_OFFSET (node);
1861 if (tmp)
1863 pp_string (pp, sep);
1864 sep = ", ";
1865 pp_string (pp, "offset: ");
1866 dump_generic_node (pp, tmp, spc, flags, false);
1868 pp_right_bracket (pp);
1870 break;
1872 case ARRAY_TYPE:
1874 tree tmp;
1876 /* Print the innermost component type. */
1877 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1878 tmp = TREE_TYPE (tmp))
1880 dump_generic_node (pp, tmp, spc, flags, false);
1882 /* Print the dimensions. */
1883 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1884 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1885 break;
1888 case RECORD_TYPE:
1889 case UNION_TYPE:
1890 case QUAL_UNION_TYPE:
1892 unsigned int quals = TYPE_QUALS (node);
1894 if (quals & TYPE_QUAL_ATOMIC)
1895 pp_string (pp, "atomic ");
1896 if (quals & TYPE_QUAL_CONST)
1897 pp_string (pp, "const ");
1898 if (quals & TYPE_QUAL_VOLATILE)
1899 pp_string (pp, "volatile ");
1901 /* Print the name of the structure. */
1902 if (TREE_CODE (node) == RECORD_TYPE)
1903 pp_string (pp, "struct ");
1904 else if (TREE_CODE (node) == UNION_TYPE)
1905 pp_string (pp, "union ");
1907 if (TYPE_NAME (node))
1908 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1909 else if (!(flags & TDF_SLIM))
1910 /* FIXME: If we eliminate the 'else' above and attempt
1911 to show the fields for named types, we may get stuck
1912 following a cycle of pointers to structs. The alleged
1913 self-reference check in print_struct_decl will not detect
1914 cycles involving more than one pointer or struct type. */
1915 print_struct_decl (pp, node, spc, flags);
1916 break;
1919 case LANG_TYPE:
1920 NIY;
1921 break;
1923 case INTEGER_CST:
1924 if (flags & TDF_GIMPLE
1925 && (POINTER_TYPE_P (TREE_TYPE (node))
1926 || (TYPE_PRECISION (TREE_TYPE (node))
1927 < TYPE_PRECISION (integer_type_node))
1928 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
1929 || tree_int_cst_sgn (node) < 0))
1931 pp_string (pp, "_Literal (");
1932 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1933 pp_string (pp, ") ");
1935 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1936 && ! (flags & TDF_GIMPLE))
1938 /* In the case of a pointer, one may want to divide by the
1939 size of the pointed-to type. Unfortunately, this not
1940 straightforward. The C front-end maps expressions
1942 (int *) 5
1943 int *p; (p + 5)
1945 in such a way that the two INTEGER_CST nodes for "5" have
1946 different values but identical types. In the latter
1947 case, the 5 is multiplied by sizeof (int) in c-common.c
1948 (pointer_int_sum) to convert it to a byte address, and
1949 yet the type of the node is left unchanged. Argh. What
1950 is consistent though is that the number value corresponds
1951 to bytes (UNITS) offset.
1953 NB: Neither of the following divisors can be trivially
1954 used to recover the original literal:
1956 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1957 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1958 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1959 pp_string (pp, "B"); /* pseudo-unit */
1961 else if (tree_fits_shwi_p (node))
1962 pp_wide_integer (pp, tree_to_shwi (node));
1963 else if (tree_fits_uhwi_p (node))
1964 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1965 else
1967 wide_int val = wi::to_wide (node);
1969 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1971 pp_minus (pp);
1972 val = -val;
1974 print_hex (val, pp_buffer (pp)->digit_buffer);
1975 pp_string (pp, pp_buffer (pp)->digit_buffer);
1977 if ((flags & TDF_GIMPLE)
1978 && ! (POINTER_TYPE_P (TREE_TYPE (node))
1979 || (TYPE_PRECISION (TREE_TYPE (node))
1980 < TYPE_PRECISION (integer_type_node))
1981 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
1983 if (TYPE_UNSIGNED (TREE_TYPE (node)))
1984 pp_character (pp, 'u');
1985 if (TYPE_PRECISION (TREE_TYPE (node))
1986 == TYPE_PRECISION (unsigned_type_node))
1988 else if (TYPE_PRECISION (TREE_TYPE (node))
1989 == TYPE_PRECISION (long_unsigned_type_node))
1990 pp_character (pp, 'l');
1991 else if (TYPE_PRECISION (TREE_TYPE (node))
1992 == TYPE_PRECISION (long_long_unsigned_type_node))
1993 pp_string (pp, "ll");
1995 if (TREE_OVERFLOW (node))
1996 pp_string (pp, "(OVF)");
1997 break;
1999 case POLY_INT_CST:
2000 pp_string (pp, "POLY_INT_CST [");
2001 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2002 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2004 pp_string (pp, ", ");
2005 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2006 spc, flags, false);
2008 pp_string (pp, "]");
2009 break;
2011 case REAL_CST:
2012 /* Code copied from print_node. */
2014 REAL_VALUE_TYPE d;
2015 if (TREE_OVERFLOW (node))
2016 pp_string (pp, " overflow");
2018 d = TREE_REAL_CST (node);
2019 if (REAL_VALUE_ISINF (d))
2020 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2021 else if (REAL_VALUE_ISNAN (d))
2022 pp_string (pp, " Nan");
2023 else
2025 char string[100];
2026 real_to_decimal (string, &d, sizeof (string), 0, 1);
2027 pp_string (pp, string);
2029 break;
2032 case FIXED_CST:
2034 char string[100];
2035 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2036 pp_string (pp, string);
2037 break;
2040 case COMPLEX_CST:
2041 pp_string (pp, "__complex__ (");
2042 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2043 pp_string (pp, ", ");
2044 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2045 pp_right_paren (pp);
2046 break;
2048 case STRING_CST:
2050 pp_string (pp, "\"");
2051 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2052 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2053 pp_string (pp, "\"");
2054 break;
2057 case VECTOR_CST:
2059 unsigned i;
2060 pp_string (pp, "{ ");
2061 unsigned HOST_WIDE_INT nunits;
2062 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2063 nunits = vector_cst_encoded_nelts (node);
2064 for (i = 0; i < nunits; ++i)
2066 if (i != 0)
2067 pp_string (pp, ", ");
2068 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2069 spc, flags, false);
2071 if (!VECTOR_CST_NELTS (node).is_constant ())
2072 pp_string (pp, ", ...");
2073 pp_string (pp, " }");
2075 break;
2077 case FUNCTION_TYPE:
2078 case METHOD_TYPE:
2079 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2080 pp_space (pp);
2081 if (TREE_CODE (node) == METHOD_TYPE)
2083 if (TYPE_METHOD_BASETYPE (node))
2084 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2085 spc, flags, false);
2086 else
2087 pp_string (pp, "<null method basetype>");
2088 pp_colon_colon (pp);
2090 if (TYPE_IDENTIFIER (node))
2091 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2092 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2093 dump_decl_name (pp, TYPE_NAME (node), flags);
2094 else if (flags & TDF_NOUID)
2095 pp_printf (pp, "<Txxxx>");
2096 else
2097 pp_printf (pp, "<T%x>", TYPE_UID (node));
2098 dump_function_declaration (pp, node, spc, flags);
2099 break;
2101 case FUNCTION_DECL:
2102 case CONST_DECL:
2103 dump_decl_name (pp, node, flags);
2104 break;
2106 case LABEL_DECL:
2107 if (DECL_NAME (node))
2108 dump_decl_name (pp, node, flags);
2109 else if (LABEL_DECL_UID (node) != -1)
2111 if (flags & TDF_GIMPLE)
2112 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
2113 else
2114 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
2116 else
2118 if (flags & TDF_NOUID)
2119 pp_string (pp, "<D.xxxx>");
2120 else
2122 if (flags & TDF_GIMPLE)
2123 pp_printf (pp, "<D%u>", DECL_UID (node));
2124 else
2125 pp_printf (pp, "<D.%u>", DECL_UID (node));
2128 break;
2130 case TYPE_DECL:
2131 if (DECL_IS_BUILTIN (node))
2133 /* Don't print the declaration of built-in types. */
2134 break;
2136 if (DECL_NAME (node))
2137 dump_decl_name (pp, node, flags);
2138 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2140 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2141 ? "union" : "struct "));
2142 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2144 else
2145 pp_string (pp, "<anon>");
2146 break;
2148 case VAR_DECL:
2149 case PARM_DECL:
2150 case FIELD_DECL:
2151 case DEBUG_EXPR_DECL:
2152 case NAMESPACE_DECL:
2153 case NAMELIST_DECL:
2154 dump_decl_name (pp, node, flags);
2155 break;
2157 case RESULT_DECL:
2158 pp_string (pp, "<retval>");
2159 break;
2161 case COMPONENT_REF:
2162 op0 = TREE_OPERAND (node, 0);
2163 str = ".";
2164 if (op0
2165 && (TREE_CODE (op0) == INDIRECT_REF
2166 || (TREE_CODE (op0) == MEM_REF
2167 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2168 && integer_zerop (TREE_OPERAND (op0, 1))
2169 /* Dump the types of INTEGER_CSTs explicitly, for we
2170 can't infer them and MEM_ATTR caching will share
2171 MEM_REFs with differently-typed op0s. */
2172 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2173 /* Released SSA_NAMES have no TREE_TYPE. */
2174 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2175 /* Same pointer types, but ignoring POINTER_TYPE vs.
2176 REFERENCE_TYPE. */
2177 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2178 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2179 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2180 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2181 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2182 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2183 /* Same value types ignoring qualifiers. */
2184 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2185 == TYPE_MAIN_VARIANT
2186 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2187 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2189 op0 = TREE_OPERAND (op0, 0);
2190 str = "->";
2192 if (op_prio (op0) < op_prio (node))
2193 pp_left_paren (pp);
2194 dump_generic_node (pp, op0, spc, flags, false);
2195 if (op_prio (op0) < op_prio (node))
2196 pp_right_paren (pp);
2197 pp_string (pp, str);
2198 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2199 op0 = component_ref_field_offset (node);
2200 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2202 pp_string (pp, "{off: ");
2203 dump_generic_node (pp, op0, spc, flags, false);
2204 pp_right_brace (pp);
2206 break;
2208 case BIT_FIELD_REF:
2209 if (flags & TDF_GIMPLE)
2211 pp_string (pp, "__BIT_FIELD_REF <");
2212 dump_generic_node (pp, TREE_TYPE (node),
2213 spc, flags | TDF_SLIM, false);
2214 if (TYPE_ALIGN (TREE_TYPE (node))
2215 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2217 pp_string (pp, ", ");
2218 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2220 pp_greater (pp);
2221 pp_string (pp, " (");
2222 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2223 flags | TDF_SLIM, false);
2224 pp_string (pp, ", ");
2225 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2226 flags | TDF_SLIM, false);
2227 pp_string (pp, ", ");
2228 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2229 flags | TDF_SLIM, false);
2230 pp_right_paren (pp);
2232 else
2234 pp_string (pp, "BIT_FIELD_REF <");
2235 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2236 pp_string (pp, ", ");
2237 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2238 pp_string (pp, ", ");
2239 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2240 pp_greater (pp);
2242 break;
2244 case BIT_INSERT_EXPR:
2245 pp_string (pp, "BIT_INSERT_EXPR <");
2246 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2247 pp_string (pp, ", ");
2248 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2249 pp_string (pp, ", ");
2250 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2251 pp_string (pp, " (");
2252 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2253 pp_decimal_int (pp,
2254 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2255 else
2256 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2257 spc, flags, false);
2258 pp_string (pp, " bits)>");
2259 break;
2261 case ARRAY_REF:
2262 case ARRAY_RANGE_REF:
2263 op0 = TREE_OPERAND (node, 0);
2264 if (op_prio (op0) < op_prio (node))
2265 pp_left_paren (pp);
2266 dump_generic_node (pp, op0, spc, flags, false);
2267 if (op_prio (op0) < op_prio (node))
2268 pp_right_paren (pp);
2269 pp_left_bracket (pp);
2270 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2271 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2272 pp_string (pp, " ...");
2273 pp_right_bracket (pp);
2275 op0 = array_ref_low_bound (node);
2276 op1 = array_ref_element_size (node);
2278 if (!integer_zerop (op0)
2279 || TREE_OPERAND (node, 2)
2280 || TREE_OPERAND (node, 3))
2282 pp_string (pp, "{lb: ");
2283 dump_generic_node (pp, op0, spc, flags, false);
2284 pp_string (pp, " sz: ");
2285 dump_generic_node (pp, op1, spc, flags, false);
2286 pp_right_brace (pp);
2288 break;
2290 case CONSTRUCTOR:
2292 unsigned HOST_WIDE_INT ix;
2293 tree field, val;
2294 bool is_struct_init = false;
2295 bool is_array_init = false;
2296 widest_int curidx;
2297 pp_left_brace (pp);
2298 if (TREE_CLOBBER_P (node))
2299 pp_string (pp, "CLOBBER");
2300 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2301 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2302 is_struct_init = true;
2303 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2304 && TYPE_DOMAIN (TREE_TYPE (node))
2305 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2306 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2307 == INTEGER_CST)
2309 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2310 is_array_init = true;
2311 curidx = wi::to_widest (minv);
2313 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2315 if (field)
2317 if (is_struct_init)
2319 pp_dot (pp);
2320 dump_generic_node (pp, field, spc, flags, false);
2321 pp_equal (pp);
2323 else if (is_array_init
2324 && (TREE_CODE (field) != INTEGER_CST
2325 || curidx != wi::to_widest (field)))
2327 pp_left_bracket (pp);
2328 if (TREE_CODE (field) == RANGE_EXPR)
2330 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2331 flags, false);
2332 pp_string (pp, " ... ");
2333 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2334 flags, false);
2335 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2336 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2338 else
2339 dump_generic_node (pp, field, spc, flags, false);
2340 if (TREE_CODE (field) == INTEGER_CST)
2341 curidx = wi::to_widest (field);
2342 pp_string (pp, "]=");
2345 if (is_array_init)
2346 curidx += 1;
2347 if (val && TREE_CODE (val) == ADDR_EXPR)
2348 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2349 val = TREE_OPERAND (val, 0);
2350 if (val && TREE_CODE (val) == FUNCTION_DECL)
2351 dump_decl_name (pp, val, flags);
2352 else
2353 dump_generic_node (pp, val, spc, flags, false);
2354 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2356 pp_comma (pp);
2357 pp_space (pp);
2360 pp_right_brace (pp);
2362 break;
2364 case COMPOUND_EXPR:
2366 tree *tp;
2367 if (flags & TDF_SLIM)
2369 pp_string (pp, "<COMPOUND_EXPR>");
2370 break;
2373 dump_generic_node (pp, TREE_OPERAND (node, 0),
2374 spc, flags, !(flags & TDF_SLIM));
2375 if (flags & TDF_SLIM)
2376 newline_and_indent (pp, spc);
2377 else
2379 pp_comma (pp);
2380 pp_space (pp);
2383 for (tp = &TREE_OPERAND (node, 1);
2384 TREE_CODE (*tp) == COMPOUND_EXPR;
2385 tp = &TREE_OPERAND (*tp, 1))
2387 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2388 spc, flags, !(flags & TDF_SLIM));
2389 if (flags & TDF_SLIM)
2390 newline_and_indent (pp, spc);
2391 else
2393 pp_comma (pp);
2394 pp_space (pp);
2398 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2400 break;
2402 case STATEMENT_LIST:
2404 tree_stmt_iterator si;
2405 bool first = true;
2407 if (flags & TDF_SLIM)
2409 pp_string (pp, "<STATEMENT_LIST>");
2410 break;
2413 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2415 if (!first)
2416 newline_and_indent (pp, spc);
2417 else
2418 first = false;
2419 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2422 break;
2424 case MODIFY_EXPR:
2425 case INIT_EXPR:
2426 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2427 false);
2428 pp_space (pp);
2429 pp_equal (pp);
2430 pp_space (pp);
2431 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2432 false);
2433 break;
2435 case TARGET_EXPR:
2436 pp_string (pp, "TARGET_EXPR <");
2437 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2438 pp_comma (pp);
2439 pp_space (pp);
2440 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2441 pp_greater (pp);
2442 break;
2444 case DECL_EXPR:
2445 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2446 is_stmt = false;
2447 break;
2449 case COND_EXPR:
2450 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2452 pp_string (pp, "if (");
2453 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2454 pp_right_paren (pp);
2455 /* The lowered cond_exprs should always be printed in full. */
2456 if (COND_EXPR_THEN (node)
2457 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2458 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2459 && COND_EXPR_ELSE (node)
2460 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2461 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2463 pp_space (pp);
2464 dump_generic_node (pp, COND_EXPR_THEN (node),
2465 0, flags, true);
2466 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2468 pp_string (pp, " else ");
2469 dump_generic_node (pp, COND_EXPR_ELSE (node),
2470 0, flags, true);
2473 else if (!(flags & TDF_SLIM))
2475 /* Output COND_EXPR_THEN. */
2476 if (COND_EXPR_THEN (node))
2478 newline_and_indent (pp, spc+2);
2479 pp_left_brace (pp);
2480 newline_and_indent (pp, spc+4);
2481 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2482 flags, true);
2483 newline_and_indent (pp, spc+2);
2484 pp_right_brace (pp);
2487 /* Output COND_EXPR_ELSE. */
2488 if (COND_EXPR_ELSE (node)
2489 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2491 newline_and_indent (pp, spc);
2492 pp_string (pp, "else");
2493 newline_and_indent (pp, spc+2);
2494 pp_left_brace (pp);
2495 newline_and_indent (pp, spc+4);
2496 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2497 flags, true);
2498 newline_and_indent (pp, spc+2);
2499 pp_right_brace (pp);
2502 is_expr = false;
2504 else
2506 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2507 pp_space (pp);
2508 pp_question (pp);
2509 pp_space (pp);
2510 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2511 pp_space (pp);
2512 pp_colon (pp);
2513 pp_space (pp);
2514 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2516 break;
2518 case BIND_EXPR:
2519 pp_left_brace (pp);
2520 if (!(flags & TDF_SLIM))
2522 if (BIND_EXPR_VARS (node))
2524 pp_newline (pp);
2526 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2528 print_declaration (pp, op0, spc+2, flags);
2529 pp_newline (pp);
2533 newline_and_indent (pp, spc+2);
2534 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2535 newline_and_indent (pp, spc);
2536 pp_right_brace (pp);
2538 is_expr = false;
2539 break;
2541 case CALL_EXPR:
2542 if (CALL_EXPR_FN (node) != NULL_TREE)
2543 print_call_name (pp, CALL_EXPR_FN (node), flags);
2544 else
2546 pp_dot (pp);
2547 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2550 /* Print parameters. */
2551 pp_space (pp);
2552 pp_left_paren (pp);
2554 tree arg;
2555 call_expr_arg_iterator iter;
2556 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2558 dump_generic_node (pp, arg, spc, flags, false);
2559 if (more_call_expr_args_p (&iter))
2561 pp_comma (pp);
2562 pp_space (pp);
2566 if (CALL_EXPR_VA_ARG_PACK (node))
2568 if (call_expr_nargs (node) > 0)
2570 pp_comma (pp);
2571 pp_space (pp);
2573 pp_string (pp, "__builtin_va_arg_pack ()");
2575 pp_right_paren (pp);
2577 op1 = CALL_EXPR_STATIC_CHAIN (node);
2578 if (op1)
2580 pp_string (pp, " [static-chain: ");
2581 dump_generic_node (pp, op1, spc, flags, false);
2582 pp_right_bracket (pp);
2585 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2586 pp_string (pp, " [return slot optimization]");
2587 if (CALL_EXPR_TAILCALL (node))
2588 pp_string (pp, " [tail call]");
2589 break;
2591 case WITH_CLEANUP_EXPR:
2592 NIY;
2593 break;
2595 case CLEANUP_POINT_EXPR:
2596 pp_string (pp, "<<cleanup_point ");
2597 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2598 pp_string (pp, ">>");
2599 break;
2601 case PLACEHOLDER_EXPR:
2602 pp_string (pp, "<PLACEHOLDER_EXPR ");
2603 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2604 pp_greater (pp);
2605 break;
2607 /* Binary arithmetic and logic expressions. */
2608 case WIDEN_SUM_EXPR:
2609 case WIDEN_MULT_EXPR:
2610 case MULT_EXPR:
2611 case MULT_HIGHPART_EXPR:
2612 case PLUS_EXPR:
2613 case POINTER_PLUS_EXPR:
2614 case POINTER_DIFF_EXPR:
2615 case MINUS_EXPR:
2616 case TRUNC_DIV_EXPR:
2617 case CEIL_DIV_EXPR:
2618 case FLOOR_DIV_EXPR:
2619 case ROUND_DIV_EXPR:
2620 case TRUNC_MOD_EXPR:
2621 case CEIL_MOD_EXPR:
2622 case FLOOR_MOD_EXPR:
2623 case ROUND_MOD_EXPR:
2624 case RDIV_EXPR:
2625 case EXACT_DIV_EXPR:
2626 case LSHIFT_EXPR:
2627 case RSHIFT_EXPR:
2628 case LROTATE_EXPR:
2629 case RROTATE_EXPR:
2630 case WIDEN_LSHIFT_EXPR:
2631 case BIT_IOR_EXPR:
2632 case BIT_XOR_EXPR:
2633 case BIT_AND_EXPR:
2634 case TRUTH_ANDIF_EXPR:
2635 case TRUTH_ORIF_EXPR:
2636 case TRUTH_AND_EXPR:
2637 case TRUTH_OR_EXPR:
2638 case TRUTH_XOR_EXPR:
2639 case LT_EXPR:
2640 case LE_EXPR:
2641 case GT_EXPR:
2642 case GE_EXPR:
2643 case EQ_EXPR:
2644 case NE_EXPR:
2645 case UNLT_EXPR:
2646 case UNLE_EXPR:
2647 case UNGT_EXPR:
2648 case UNGE_EXPR:
2649 case UNEQ_EXPR:
2650 case LTGT_EXPR:
2651 case ORDERED_EXPR:
2652 case UNORDERED_EXPR:
2654 const char *op = op_symbol (node);
2655 op0 = TREE_OPERAND (node, 0);
2656 op1 = TREE_OPERAND (node, 1);
2658 /* When the operands are expressions with less priority,
2659 keep semantics of the tree representation. */
2660 if (op_prio (op0) <= op_prio (node))
2662 pp_left_paren (pp);
2663 dump_generic_node (pp, op0, spc, flags, false);
2664 pp_right_paren (pp);
2666 else
2667 dump_generic_node (pp, op0, spc, flags, false);
2669 pp_space (pp);
2670 pp_string (pp, op);
2671 pp_space (pp);
2673 /* When the operands are expressions with less priority,
2674 keep semantics of the tree representation. */
2675 if (op_prio (op1) <= op_prio (node))
2677 pp_left_paren (pp);
2678 dump_generic_node (pp, op1, spc, flags, false);
2679 pp_right_paren (pp);
2681 else
2682 dump_generic_node (pp, op1, spc, flags, false);
2684 break;
2686 /* Unary arithmetic and logic expressions. */
2687 case NEGATE_EXPR:
2688 case BIT_NOT_EXPR:
2689 case TRUTH_NOT_EXPR:
2690 case ADDR_EXPR:
2691 case PREDECREMENT_EXPR:
2692 case PREINCREMENT_EXPR:
2693 case INDIRECT_REF:
2694 if (TREE_CODE (node) == ADDR_EXPR
2695 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2696 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2697 ; /* Do not output '&' for strings and function pointers. */
2698 else
2699 pp_string (pp, op_symbol (node));
2701 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2703 pp_left_paren (pp);
2704 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2705 pp_right_paren (pp);
2707 else
2708 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2709 break;
2711 case POSTDECREMENT_EXPR:
2712 case POSTINCREMENT_EXPR:
2713 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2715 pp_left_paren (pp);
2716 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2717 pp_right_paren (pp);
2719 else
2720 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2721 pp_string (pp, op_symbol (node));
2722 break;
2724 case MIN_EXPR:
2725 pp_string (pp, "MIN_EXPR <");
2726 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2727 pp_string (pp, ", ");
2728 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2729 pp_greater (pp);
2730 break;
2732 case MAX_EXPR:
2733 pp_string (pp, "MAX_EXPR <");
2734 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2735 pp_string (pp, ", ");
2736 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2737 pp_greater (pp);
2738 break;
2740 case ABS_EXPR:
2741 pp_string (pp, "ABS_EXPR <");
2742 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2743 pp_greater (pp);
2744 break;
2746 case ABSU_EXPR:
2747 pp_string (pp, "ABSU_EXPR <");
2748 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2749 pp_greater (pp);
2750 break;
2752 case RANGE_EXPR:
2753 NIY;
2754 break;
2756 case ADDR_SPACE_CONVERT_EXPR:
2757 case FIXED_CONVERT_EXPR:
2758 case FIX_TRUNC_EXPR:
2759 case FLOAT_EXPR:
2760 CASE_CONVERT:
2761 type = TREE_TYPE (node);
2762 op0 = TREE_OPERAND (node, 0);
2763 if (type != TREE_TYPE (op0))
2765 pp_left_paren (pp);
2766 dump_generic_node (pp, type, spc, flags, false);
2767 pp_string (pp, ") ");
2769 if (op_prio (op0) < op_prio (node))
2770 pp_left_paren (pp);
2771 dump_generic_node (pp, op0, spc, flags, false);
2772 if (op_prio (op0) < op_prio (node))
2773 pp_right_paren (pp);
2774 break;
2776 case VIEW_CONVERT_EXPR:
2777 if (flags & TDF_GIMPLE)
2778 pp_string (pp, "__VIEW_CONVERT <");
2779 else
2780 pp_string (pp, "VIEW_CONVERT_EXPR<");
2781 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2782 pp_string (pp, ">(");
2783 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2784 pp_right_paren (pp);
2785 break;
2787 case PAREN_EXPR:
2788 pp_string (pp, "((");
2789 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2790 pp_string (pp, "))");
2791 break;
2793 case NON_LVALUE_EXPR:
2794 pp_string (pp, "NON_LVALUE_EXPR <");
2795 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2796 pp_greater (pp);
2797 break;
2799 case SAVE_EXPR:
2800 pp_string (pp, "SAVE_EXPR <");
2801 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2802 pp_greater (pp);
2803 break;
2805 case COMPLEX_EXPR:
2806 pp_string (pp, "COMPLEX_EXPR <");
2807 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2808 pp_string (pp, ", ");
2809 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2810 pp_greater (pp);
2811 break;
2813 case CONJ_EXPR:
2814 pp_string (pp, "CONJ_EXPR <");
2815 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2816 pp_greater (pp);
2817 break;
2819 case REALPART_EXPR:
2820 if (flags & TDF_GIMPLE)
2822 pp_string (pp, "__real ");
2823 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2825 else
2827 pp_string (pp, "REALPART_EXPR <");
2828 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2829 pp_greater (pp);
2831 break;
2833 case IMAGPART_EXPR:
2834 if (flags & TDF_GIMPLE)
2836 pp_string (pp, "__imag ");
2837 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2839 else
2841 pp_string (pp, "IMAGPART_EXPR <");
2842 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2843 pp_greater (pp);
2845 break;
2847 case VA_ARG_EXPR:
2848 pp_string (pp, "VA_ARG_EXPR <");
2849 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2850 pp_greater (pp);
2851 break;
2853 case TRY_FINALLY_EXPR:
2854 case TRY_CATCH_EXPR:
2855 pp_string (pp, "try");
2856 newline_and_indent (pp, spc+2);
2857 pp_left_brace (pp);
2858 newline_and_indent (pp, spc+4);
2859 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2860 newline_and_indent (pp, spc+2);
2861 pp_right_brace (pp);
2862 newline_and_indent (pp, spc);
2863 if (TREE_CODE (node) == TRY_CATCH_EXPR)
2865 node = TREE_OPERAND (node, 1);
2866 pp_string (pp, "catch");
2868 else
2870 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
2871 node = TREE_OPERAND (node, 1);
2872 pp_string (pp, "finally");
2873 if (TREE_CODE (node) == EH_ELSE_EXPR)
2875 newline_and_indent (pp, spc+2);
2876 pp_left_brace (pp);
2877 newline_and_indent (pp, spc+4);
2878 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
2879 flags, true);
2880 newline_and_indent (pp, spc+2);
2881 pp_right_brace (pp);
2882 newline_and_indent (pp, spc);
2883 node = TREE_OPERAND (node, 1);
2884 pp_string (pp, "else");
2887 newline_and_indent (pp, spc+2);
2888 pp_left_brace (pp);
2889 newline_and_indent (pp, spc+4);
2890 dump_generic_node (pp, node, spc+4, flags, true);
2891 newline_and_indent (pp, spc+2);
2892 pp_right_brace (pp);
2893 is_expr = false;
2894 break;
2896 case CATCH_EXPR:
2897 pp_string (pp, "catch (");
2898 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2899 pp_right_paren (pp);
2900 newline_and_indent (pp, spc+2);
2901 pp_left_brace (pp);
2902 newline_and_indent (pp, spc+4);
2903 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2904 newline_and_indent (pp, spc+2);
2905 pp_right_brace (pp);
2906 is_expr = false;
2907 break;
2909 case EH_FILTER_EXPR:
2910 pp_string (pp, "<<<eh_filter (");
2911 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2912 pp_string (pp, ")>>>");
2913 newline_and_indent (pp, spc+2);
2914 pp_left_brace (pp);
2915 newline_and_indent (pp, spc+4);
2916 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2917 newline_and_indent (pp, spc+2);
2918 pp_right_brace (pp);
2919 is_expr = false;
2920 break;
2922 case LABEL_EXPR:
2923 op0 = TREE_OPERAND (node, 0);
2924 /* If this is for break or continue, don't bother printing it. */
2925 if (DECL_NAME (op0))
2927 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2928 if (strcmp (name, "break") == 0
2929 || strcmp (name, "continue") == 0)
2930 break;
2932 dump_generic_node (pp, op0, spc, flags, false);
2933 pp_colon (pp);
2934 if (DECL_NONLOCAL (op0))
2935 pp_string (pp, " [non-local]");
2936 break;
2938 case LOOP_EXPR:
2939 pp_string (pp, "while (1)");
2940 if (!(flags & TDF_SLIM))
2942 newline_and_indent (pp, spc+2);
2943 pp_left_brace (pp);
2944 newline_and_indent (pp, spc+4);
2945 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2946 newline_and_indent (pp, spc+2);
2947 pp_right_brace (pp);
2949 is_expr = false;
2950 break;
2952 case PREDICT_EXPR:
2953 pp_string (pp, "// predicted ");
2954 if (PREDICT_EXPR_OUTCOME (node))
2955 pp_string (pp, "likely by ");
2956 else
2957 pp_string (pp, "unlikely by ");
2958 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2959 pp_string (pp, " predictor.");
2960 break;
2962 case ANNOTATE_EXPR:
2963 pp_string (pp, "ANNOTATE_EXPR <");
2964 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2965 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2967 case annot_expr_ivdep_kind:
2968 pp_string (pp, ", ivdep");
2969 break;
2970 case annot_expr_unroll_kind:
2971 pp_printf (pp, ", unroll %d",
2972 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
2973 break;
2974 case annot_expr_no_vector_kind:
2975 pp_string (pp, ", no-vector");
2976 break;
2977 case annot_expr_vector_kind:
2978 pp_string (pp, ", vector");
2979 break;
2980 case annot_expr_parallel_kind:
2981 pp_string (pp, ", parallel");
2982 break;
2983 default:
2984 gcc_unreachable ();
2986 pp_greater (pp);
2987 break;
2989 case RETURN_EXPR:
2990 pp_string (pp, "return");
2991 op0 = TREE_OPERAND (node, 0);
2992 if (op0)
2994 pp_space (pp);
2995 if (TREE_CODE (op0) == MODIFY_EXPR)
2996 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2997 spc, flags, false);
2998 else
2999 dump_generic_node (pp, op0, spc, flags, false);
3001 break;
3003 case EXIT_EXPR:
3004 pp_string (pp, "if (");
3005 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3006 pp_string (pp, ") break");
3007 break;
3009 case SWITCH_EXPR:
3010 pp_string (pp, "switch (");
3011 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3012 pp_right_paren (pp);
3013 if (!(flags & TDF_SLIM))
3015 newline_and_indent (pp, spc+2);
3016 pp_left_brace (pp);
3017 if (SWITCH_BODY (node))
3019 newline_and_indent (pp, spc+4);
3020 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3021 true);
3023 newline_and_indent (pp, spc+2);
3024 pp_right_brace (pp);
3026 is_expr = false;
3027 break;
3029 case GOTO_EXPR:
3030 op0 = GOTO_DESTINATION (node);
3031 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3033 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3034 if (strcmp (name, "break") == 0
3035 || strcmp (name, "continue") == 0)
3037 pp_string (pp, name);
3038 break;
3041 pp_string (pp, "goto ");
3042 dump_generic_node (pp, op0, spc, flags, false);
3043 break;
3045 case ASM_EXPR:
3046 pp_string (pp, "__asm__");
3047 if (ASM_VOLATILE_P (node))
3048 pp_string (pp, " __volatile__");
3049 pp_left_paren (pp);
3050 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3051 pp_colon (pp);
3052 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3053 pp_colon (pp);
3054 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3055 if (ASM_CLOBBERS (node))
3057 pp_colon (pp);
3058 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3060 pp_right_paren (pp);
3061 break;
3063 case CASE_LABEL_EXPR:
3064 if (CASE_LOW (node) && CASE_HIGH (node))
3066 pp_string (pp, "case ");
3067 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3068 pp_string (pp, " ... ");
3069 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3071 else if (CASE_LOW (node))
3073 pp_string (pp, "case ");
3074 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3076 else
3077 pp_string (pp, "default");
3078 pp_colon (pp);
3079 break;
3081 case OBJ_TYPE_REF:
3082 pp_string (pp, "OBJ_TYPE_REF(");
3083 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3084 pp_semicolon (pp);
3085 /* We omit the class type for -fcompare-debug because we may
3086 drop TYPE_BINFO early depending on debug info, and then
3087 virtual_method_call_p would return false, whereas when
3088 TYPE_BINFO is preserved it may still return true and then
3089 we'd print the class type. Compare tree and rtl dumps for
3090 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3091 for example, at occurrences of OBJ_TYPE_REF. */
3092 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3093 && virtual_method_call_p (node))
3095 pp_string (pp, "(");
3096 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
3097 pp_string (pp, ")");
3099 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3100 pp_arrow (pp);
3101 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3102 pp_right_paren (pp);
3103 break;
3105 case SSA_NAME:
3106 if (SSA_NAME_IDENTIFIER (node))
3108 if ((flags & TDF_NOUID)
3109 && SSA_NAME_VAR (node)
3110 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3111 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3112 else if (! (flags & TDF_GIMPLE)
3113 || SSA_NAME_VAR (node))
3114 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3115 spc, flags, false);
3117 pp_underscore (pp);
3118 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3119 if (SSA_NAME_IS_DEFAULT_DEF (node))
3120 pp_string (pp, "(D)");
3121 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3122 pp_string (pp, "(ab)");
3123 break;
3125 case WITH_SIZE_EXPR:
3126 pp_string (pp, "WITH_SIZE_EXPR <");
3127 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3128 pp_string (pp, ", ");
3129 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3130 pp_greater (pp);
3131 break;
3133 case ASSERT_EXPR:
3134 pp_string (pp, "ASSERT_EXPR <");
3135 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3136 pp_string (pp, ", ");
3137 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3138 pp_greater (pp);
3139 break;
3141 case SCEV_KNOWN:
3142 pp_string (pp, "scev_known");
3143 break;
3145 case SCEV_NOT_KNOWN:
3146 pp_string (pp, "scev_not_known");
3147 break;
3149 case POLYNOMIAL_CHREC:
3150 pp_left_brace (pp);
3151 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3152 pp_string (pp, ", +, ");
3153 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3154 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
3155 is_stmt = false;
3156 break;
3158 case REALIGN_LOAD_EXPR:
3159 pp_string (pp, "REALIGN_LOAD <");
3160 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3161 pp_string (pp, ", ");
3162 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3163 pp_string (pp, ", ");
3164 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3165 pp_greater (pp);
3166 break;
3168 case VEC_COND_EXPR:
3169 pp_string (pp, " VEC_COND_EXPR < ");
3170 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3171 pp_string (pp, " , ");
3172 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3173 pp_string (pp, " , ");
3174 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3175 pp_string (pp, " > ");
3176 break;
3178 case VEC_PERM_EXPR:
3179 pp_string (pp, " VEC_PERM_EXPR < ");
3180 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3181 pp_string (pp, " , ");
3182 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3183 pp_string (pp, " , ");
3184 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3185 pp_string (pp, " > ");
3186 break;
3188 case DOT_PROD_EXPR:
3189 pp_string (pp, " DOT_PROD_EXPR < ");
3190 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3191 pp_string (pp, ", ");
3192 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3193 pp_string (pp, ", ");
3194 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3195 pp_string (pp, " > ");
3196 break;
3198 case WIDEN_MULT_PLUS_EXPR:
3199 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3200 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3201 pp_string (pp, ", ");
3202 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3203 pp_string (pp, ", ");
3204 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3205 pp_string (pp, " > ");
3206 break;
3208 case WIDEN_MULT_MINUS_EXPR:
3209 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3210 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3211 pp_string (pp, ", ");
3212 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3213 pp_string (pp, ", ");
3214 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3215 pp_string (pp, " > ");
3216 break;
3218 case OACC_PARALLEL:
3219 pp_string (pp, "#pragma acc parallel");
3220 goto dump_omp_clauses_body;
3222 case OACC_KERNELS:
3223 pp_string (pp, "#pragma acc kernels");
3224 goto dump_omp_clauses_body;
3226 case OACC_DATA:
3227 pp_string (pp, "#pragma acc data");
3228 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3229 goto dump_omp_body;
3231 case OACC_HOST_DATA:
3232 pp_string (pp, "#pragma acc host_data");
3233 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3234 goto dump_omp_body;
3236 case OACC_DECLARE:
3237 pp_string (pp, "#pragma acc declare");
3238 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3239 break;
3241 case OACC_UPDATE:
3242 pp_string (pp, "#pragma acc update");
3243 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3244 break;
3246 case OACC_ENTER_DATA:
3247 pp_string (pp, "#pragma acc enter data");
3248 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3249 break;
3251 case OACC_EXIT_DATA:
3252 pp_string (pp, "#pragma acc exit data");
3253 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3254 break;
3256 case OACC_CACHE:
3257 pp_string (pp, "#pragma acc cache");
3258 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3259 break;
3261 case OMP_PARALLEL:
3262 pp_string (pp, "#pragma omp parallel");
3263 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3264 goto dump_omp_body;
3266 dump_omp_clauses_body:
3267 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3268 goto dump_omp_body;
3270 dump_omp_body:
3271 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3273 newline_and_indent (pp, spc + 2);
3274 pp_left_brace (pp);
3275 newline_and_indent (pp, spc + 4);
3276 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3277 newline_and_indent (pp, spc + 2);
3278 pp_right_brace (pp);
3280 is_expr = false;
3281 break;
3283 case OMP_TASK:
3284 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3285 : "#pragma omp taskwait");
3286 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3287 goto dump_omp_body;
3289 case OMP_FOR:
3290 pp_string (pp, "#pragma omp for");
3291 goto dump_omp_loop;
3293 case OMP_SIMD:
3294 pp_string (pp, "#pragma omp simd");
3295 goto dump_omp_loop;
3297 case OMP_DISTRIBUTE:
3298 pp_string (pp, "#pragma omp distribute");
3299 goto dump_omp_loop;
3301 case OMP_TASKLOOP:
3302 pp_string (pp, "#pragma omp taskloop");
3303 goto dump_omp_loop;
3305 case OMP_LOOP:
3306 pp_string (pp, "#pragma omp loop");
3307 goto dump_omp_loop;
3309 case OACC_LOOP:
3310 pp_string (pp, "#pragma acc loop");
3311 goto dump_omp_loop;
3313 case OMP_TEAMS:
3314 pp_string (pp, "#pragma omp teams");
3315 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3316 goto dump_omp_body;
3318 case OMP_TARGET_DATA:
3319 pp_string (pp, "#pragma omp target data");
3320 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3321 goto dump_omp_body;
3323 case OMP_TARGET_ENTER_DATA:
3324 pp_string (pp, "#pragma omp target enter data");
3325 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3326 is_expr = false;
3327 break;
3329 case OMP_TARGET_EXIT_DATA:
3330 pp_string (pp, "#pragma omp target exit data");
3331 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3332 is_expr = false;
3333 break;
3335 case OMP_TARGET:
3336 pp_string (pp, "#pragma omp target");
3337 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3338 goto dump_omp_body;
3340 case OMP_TARGET_UPDATE:
3341 pp_string (pp, "#pragma omp target update");
3342 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3343 is_expr = false;
3344 break;
3346 dump_omp_loop:
3347 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3348 if (!(flags & TDF_SLIM))
3350 int i;
3352 if (OMP_FOR_PRE_BODY (node))
3354 newline_and_indent (pp, spc + 2);
3355 pp_left_brace (pp);
3356 spc += 4;
3357 newline_and_indent (pp, spc);
3358 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3359 spc, flags, false);
3361 if (OMP_FOR_INIT (node))
3363 spc -= 2;
3364 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3366 spc += 2;
3367 newline_and_indent (pp, spc);
3368 pp_string (pp, "for (");
3369 dump_generic_node (pp,
3370 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
3371 spc, flags, false);
3372 pp_string (pp, "; ");
3373 dump_generic_node (pp,
3374 TREE_VEC_ELT (OMP_FOR_COND (node), i),
3375 spc, flags, false);
3376 pp_string (pp, "; ");
3377 dump_generic_node (pp,
3378 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3379 spc, flags, false);
3380 pp_right_paren (pp);
3383 if (OMP_FOR_BODY (node))
3385 newline_and_indent (pp, spc + 2);
3386 pp_left_brace (pp);
3387 newline_and_indent (pp, spc + 4);
3388 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3389 false);
3390 newline_and_indent (pp, spc + 2);
3391 pp_right_brace (pp);
3393 if (OMP_FOR_INIT (node))
3394 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3395 if (OMP_FOR_PRE_BODY (node))
3397 spc -= 4;
3398 newline_and_indent (pp, spc + 2);
3399 pp_right_brace (pp);
3402 is_expr = false;
3403 break;
3405 case OMP_SECTIONS:
3406 pp_string (pp, "#pragma omp sections");
3407 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3408 goto dump_omp_body;
3410 case OMP_SECTION:
3411 pp_string (pp, "#pragma omp section");
3412 goto dump_omp_body;
3414 case OMP_SCAN:
3415 if (OMP_SCAN_CLAUSES (node))
3417 pp_string (pp, "#pragma omp scan");
3418 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3420 goto dump_omp_body;
3422 case OMP_MASTER:
3423 pp_string (pp, "#pragma omp master");
3424 goto dump_omp_body;
3426 case OMP_TASKGROUP:
3427 pp_string (pp, "#pragma omp taskgroup");
3428 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3429 goto dump_omp_body;
3431 case OMP_ORDERED:
3432 pp_string (pp, "#pragma omp ordered");
3433 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3434 goto dump_omp_body;
3436 case OMP_CRITICAL:
3437 pp_string (pp, "#pragma omp critical");
3438 if (OMP_CRITICAL_NAME (node))
3440 pp_space (pp);
3441 pp_left_paren (pp);
3442 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3443 flags, false);
3444 pp_right_paren (pp);
3446 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3447 goto dump_omp_body;
3449 case OMP_ATOMIC:
3450 pp_string (pp, "#pragma omp atomic");
3451 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3452 newline_and_indent (pp, spc + 2);
3453 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3454 pp_space (pp);
3455 pp_equal (pp);
3456 pp_space (pp);
3457 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3458 break;
3460 case OMP_ATOMIC_READ:
3461 pp_string (pp, "#pragma omp atomic read");
3462 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3463 newline_and_indent (pp, spc + 2);
3464 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3465 pp_space (pp);
3466 break;
3468 case OMP_ATOMIC_CAPTURE_OLD:
3469 case OMP_ATOMIC_CAPTURE_NEW:
3470 pp_string (pp, "#pragma omp atomic capture");
3471 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3472 newline_and_indent (pp, spc + 2);
3473 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3474 pp_space (pp);
3475 pp_equal (pp);
3476 pp_space (pp);
3477 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3478 break;
3480 case OMP_SINGLE:
3481 pp_string (pp, "#pragma omp single");
3482 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3483 goto dump_omp_body;
3485 case OMP_CLAUSE:
3486 dump_omp_clause (pp, node, spc, flags);
3487 is_expr = false;
3488 break;
3490 case TRANSACTION_EXPR:
3491 if (TRANSACTION_EXPR_OUTER (node))
3492 pp_string (pp, "__transaction_atomic [[outer]]");
3493 else if (TRANSACTION_EXPR_RELAXED (node))
3494 pp_string (pp, "__transaction_relaxed");
3495 else
3496 pp_string (pp, "__transaction_atomic");
3497 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3499 newline_and_indent (pp, spc);
3500 pp_left_brace (pp);
3501 newline_and_indent (pp, spc + 2);
3502 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3503 spc + 2, flags, false);
3504 newline_and_indent (pp, spc);
3505 pp_right_brace (pp);
3507 is_expr = false;
3508 break;
3510 case VEC_SERIES_EXPR:
3511 case VEC_WIDEN_MULT_HI_EXPR:
3512 case VEC_WIDEN_MULT_LO_EXPR:
3513 case VEC_WIDEN_MULT_EVEN_EXPR:
3514 case VEC_WIDEN_MULT_ODD_EXPR:
3515 case VEC_WIDEN_LSHIFT_HI_EXPR:
3516 case VEC_WIDEN_LSHIFT_LO_EXPR:
3517 pp_space (pp);
3518 for (str = get_tree_code_name (code); *str; str++)
3519 pp_character (pp, TOUPPER (*str));
3520 pp_string (pp, " < ");
3521 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3522 pp_string (pp, ", ");
3523 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3524 pp_string (pp, " > ");
3525 break;
3527 case VEC_DUPLICATE_EXPR:
3528 pp_space (pp);
3529 for (str = get_tree_code_name (code); *str; str++)
3530 pp_character (pp, TOUPPER (*str));
3531 pp_string (pp, " < ");
3532 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3533 pp_string (pp, " > ");
3534 break;
3536 case VEC_UNPACK_HI_EXPR:
3537 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3538 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3539 pp_string (pp, " > ");
3540 break;
3542 case VEC_UNPACK_LO_EXPR:
3543 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3544 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3545 pp_string (pp, " > ");
3546 break;
3548 case VEC_UNPACK_FLOAT_HI_EXPR:
3549 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3550 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3551 pp_string (pp, " > ");
3552 break;
3554 case VEC_UNPACK_FLOAT_LO_EXPR:
3555 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3556 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3557 pp_string (pp, " > ");
3558 break;
3560 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3561 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3562 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3563 pp_string (pp, " > ");
3564 break;
3566 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3567 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3568 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3569 pp_string (pp, " > ");
3570 break;
3572 case VEC_PACK_TRUNC_EXPR:
3573 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3574 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3575 pp_string (pp, ", ");
3576 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3577 pp_string (pp, " > ");
3578 break;
3580 case VEC_PACK_SAT_EXPR:
3581 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3582 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3583 pp_string (pp, ", ");
3584 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3585 pp_string (pp, " > ");
3586 break;
3588 case VEC_PACK_FIX_TRUNC_EXPR:
3589 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3590 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3591 pp_string (pp, ", ");
3592 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3593 pp_string (pp, " > ");
3594 break;
3596 case VEC_PACK_FLOAT_EXPR:
3597 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3598 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3599 pp_string (pp, ", ");
3600 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3601 pp_string (pp, " > ");
3602 break;
3604 case BLOCK:
3605 dump_block_node (pp, node, spc, flags);
3606 break;
3608 case DEBUG_BEGIN_STMT:
3609 pp_string (pp, "# DEBUG BEGIN STMT");
3610 break;
3612 default:
3613 NIY;
3616 if (is_stmt && is_expr)
3617 pp_semicolon (pp);
3619 return spc;
3622 /* Print the declaration of a variable. */
3624 void
3625 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3627 INDENT (spc);
3629 if (TREE_CODE(t) == NAMELIST_DECL)
3631 pp_string(pp, "namelist ");
3632 dump_decl_name (pp, t, flags);
3633 pp_semicolon (pp);
3634 return;
3637 if (TREE_CODE (t) == TYPE_DECL)
3638 pp_string (pp, "typedef ");
3640 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3641 pp_string (pp, "register ");
3643 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3644 pp_string (pp, "extern ");
3645 else if (TREE_STATIC (t))
3646 pp_string (pp, "static ");
3648 /* Print the type and name. */
3649 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3651 tree tmp;
3653 /* Print array's type. */
3654 tmp = TREE_TYPE (t);
3655 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3656 tmp = TREE_TYPE (tmp);
3657 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3659 /* Print variable's name. */
3660 pp_space (pp);
3661 dump_generic_node (pp, t, spc, flags, false);
3663 /* Print the dimensions. */
3664 tmp = TREE_TYPE (t);
3665 while (TREE_CODE (tmp) == ARRAY_TYPE)
3667 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3668 tmp = TREE_TYPE (tmp);
3671 else if (TREE_CODE (t) == FUNCTION_DECL)
3673 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3674 pp_space (pp);
3675 dump_decl_name (pp, t, flags);
3676 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3678 else
3680 /* Print type declaration. */
3681 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3683 /* Print variable's name. */
3684 pp_space (pp);
3685 dump_generic_node (pp, t, spc, flags, false);
3688 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3690 pp_string (pp, " __asm__ ");
3691 pp_left_paren (pp);
3692 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3693 pp_right_paren (pp);
3696 /* The initial value of a function serves to determine whether the function
3697 is declared or defined. So the following does not apply to function
3698 nodes. */
3699 if (TREE_CODE (t) != FUNCTION_DECL)
3701 /* Print the initial value. */
3702 if (DECL_INITIAL (t))
3704 pp_space (pp);
3705 pp_equal (pp);
3706 pp_space (pp);
3707 if (!(flags & TDF_SLIM))
3708 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3709 else
3710 pp_string (pp, "<<< omitted >>>");
3714 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3716 pp_string (pp, " [value-expr: ");
3717 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3718 pp_right_bracket (pp);
3721 pp_semicolon (pp);
3725 /* Prints a structure: name, fields, and methods.
3726 FIXME: Still incomplete. */
3728 static void
3729 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3730 dump_flags_t flags)
3732 /* Print the name of the structure. */
3733 if (TYPE_NAME (node))
3735 INDENT (spc);
3736 if (TREE_CODE (node) == RECORD_TYPE)
3737 pp_string (pp, "struct ");
3738 else if ((TREE_CODE (node) == UNION_TYPE
3739 || TREE_CODE (node) == QUAL_UNION_TYPE))
3740 pp_string (pp, "union ");
3742 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3745 /* Print the contents of the structure. */
3746 pp_newline (pp);
3747 INDENT (spc);
3748 pp_left_brace (pp);
3749 pp_newline (pp);
3751 /* Print the fields of the structure. */
3753 tree tmp;
3754 tmp = TYPE_FIELDS (node);
3755 while (tmp)
3757 /* Avoid to print recursively the structure. */
3758 /* FIXME : Not implemented correctly...,
3759 what about the case when we have a cycle in the contain graph? ...
3760 Maybe this could be solved by looking at the scope in which the
3761 structure was declared. */
3762 if (TREE_TYPE (tmp) != node
3763 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3764 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3766 print_declaration (pp, tmp, spc+2, flags);
3767 pp_newline (pp);
3769 tmp = DECL_CHAIN (tmp);
3772 INDENT (spc);
3773 pp_right_brace (pp);
3776 /* Return the priority of the operator CODE.
3778 From lowest to highest precedence with either left-to-right (L-R)
3779 or right-to-left (R-L) associativity]:
3781 1 [L-R] ,
3782 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3783 3 [R-L] ?:
3784 4 [L-R] ||
3785 5 [L-R] &&
3786 6 [L-R] |
3787 7 [L-R] ^
3788 8 [L-R] &
3789 9 [L-R] == !=
3790 10 [L-R] < <= > >=
3791 11 [L-R] << >>
3792 12 [L-R] + -
3793 13 [L-R] * / %
3794 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3795 15 [L-R] fn() [] -> .
3797 unary +, - and * have higher precedence than the corresponding binary
3798 operators. */
3801 op_code_prio (enum tree_code code)
3803 switch (code)
3805 case TREE_LIST:
3806 case COMPOUND_EXPR:
3807 case BIND_EXPR:
3808 return 1;
3810 case MODIFY_EXPR:
3811 case INIT_EXPR:
3812 return 2;
3814 case COND_EXPR:
3815 return 3;
3817 case TRUTH_OR_EXPR:
3818 case TRUTH_ORIF_EXPR:
3819 return 4;
3821 case TRUTH_AND_EXPR:
3822 case TRUTH_ANDIF_EXPR:
3823 return 5;
3825 case BIT_IOR_EXPR:
3826 return 6;
3828 case BIT_XOR_EXPR:
3829 case TRUTH_XOR_EXPR:
3830 return 7;
3832 case BIT_AND_EXPR:
3833 return 8;
3835 case EQ_EXPR:
3836 case NE_EXPR:
3837 return 9;
3839 case UNLT_EXPR:
3840 case UNLE_EXPR:
3841 case UNGT_EXPR:
3842 case UNGE_EXPR:
3843 case UNEQ_EXPR:
3844 case LTGT_EXPR:
3845 case ORDERED_EXPR:
3846 case UNORDERED_EXPR:
3847 case LT_EXPR:
3848 case LE_EXPR:
3849 case GT_EXPR:
3850 case GE_EXPR:
3851 return 10;
3853 case LSHIFT_EXPR:
3854 case RSHIFT_EXPR:
3855 case LROTATE_EXPR:
3856 case RROTATE_EXPR:
3857 case VEC_WIDEN_LSHIFT_HI_EXPR:
3858 case VEC_WIDEN_LSHIFT_LO_EXPR:
3859 case WIDEN_LSHIFT_EXPR:
3860 return 11;
3862 case WIDEN_SUM_EXPR:
3863 case PLUS_EXPR:
3864 case POINTER_PLUS_EXPR:
3865 case POINTER_DIFF_EXPR:
3866 case MINUS_EXPR:
3867 return 12;
3869 case VEC_WIDEN_MULT_HI_EXPR:
3870 case VEC_WIDEN_MULT_LO_EXPR:
3871 case WIDEN_MULT_EXPR:
3872 case DOT_PROD_EXPR:
3873 case WIDEN_MULT_PLUS_EXPR:
3874 case WIDEN_MULT_MINUS_EXPR:
3875 case MULT_EXPR:
3876 case MULT_HIGHPART_EXPR:
3877 case TRUNC_DIV_EXPR:
3878 case CEIL_DIV_EXPR:
3879 case FLOOR_DIV_EXPR:
3880 case ROUND_DIV_EXPR:
3881 case RDIV_EXPR:
3882 case EXACT_DIV_EXPR:
3883 case TRUNC_MOD_EXPR:
3884 case CEIL_MOD_EXPR:
3885 case FLOOR_MOD_EXPR:
3886 case ROUND_MOD_EXPR:
3887 return 13;
3889 case TRUTH_NOT_EXPR:
3890 case BIT_NOT_EXPR:
3891 case POSTINCREMENT_EXPR:
3892 case POSTDECREMENT_EXPR:
3893 case PREINCREMENT_EXPR:
3894 case PREDECREMENT_EXPR:
3895 case NEGATE_EXPR:
3896 case INDIRECT_REF:
3897 case ADDR_EXPR:
3898 case FLOAT_EXPR:
3899 CASE_CONVERT:
3900 case FIX_TRUNC_EXPR:
3901 case TARGET_EXPR:
3902 return 14;
3904 case CALL_EXPR:
3905 case ARRAY_REF:
3906 case ARRAY_RANGE_REF:
3907 case COMPONENT_REF:
3908 return 15;
3910 /* Special expressions. */
3911 case MIN_EXPR:
3912 case MAX_EXPR:
3913 case ABS_EXPR:
3914 case REALPART_EXPR:
3915 case IMAGPART_EXPR:
3916 case VEC_UNPACK_HI_EXPR:
3917 case VEC_UNPACK_LO_EXPR:
3918 case VEC_UNPACK_FLOAT_HI_EXPR:
3919 case VEC_UNPACK_FLOAT_LO_EXPR:
3920 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3921 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3922 case VEC_PACK_TRUNC_EXPR:
3923 case VEC_PACK_SAT_EXPR:
3924 return 16;
3926 default:
3927 /* Return an arbitrarily high precedence to avoid surrounding single
3928 VAR_DECLs in ()s. */
3929 return 9999;
3933 /* Return the priority of the operator OP. */
3936 op_prio (const_tree op)
3938 enum tree_code code;
3940 if (op == NULL)
3941 return 9999;
3943 code = TREE_CODE (op);
3944 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3945 return op_prio (TREE_OPERAND (op, 0));
3947 return op_code_prio (code);
3950 /* Return the symbol associated with operator CODE. */
3952 const char *
3953 op_symbol_code (enum tree_code code)
3955 switch (code)
3957 case MODIFY_EXPR:
3958 return "=";
3960 case TRUTH_OR_EXPR:
3961 case TRUTH_ORIF_EXPR:
3962 return "||";
3964 case TRUTH_AND_EXPR:
3965 case TRUTH_ANDIF_EXPR:
3966 return "&&";
3968 case BIT_IOR_EXPR:
3969 return "|";
3971 case TRUTH_XOR_EXPR:
3972 case BIT_XOR_EXPR:
3973 return "^";
3975 case ADDR_EXPR:
3976 case BIT_AND_EXPR:
3977 return "&";
3979 case ORDERED_EXPR:
3980 return "ord";
3981 case UNORDERED_EXPR:
3982 return "unord";
3984 case EQ_EXPR:
3985 return "==";
3986 case UNEQ_EXPR:
3987 return "u==";
3989 case NE_EXPR:
3990 return "!=";
3992 case LT_EXPR:
3993 return "<";
3994 case UNLT_EXPR:
3995 return "u<";
3997 case LE_EXPR:
3998 return "<=";
3999 case UNLE_EXPR:
4000 return "u<=";
4002 case GT_EXPR:
4003 return ">";
4004 case UNGT_EXPR:
4005 return "u>";
4007 case GE_EXPR:
4008 return ">=";
4009 case UNGE_EXPR:
4010 return "u>=";
4012 case LTGT_EXPR:
4013 return "<>";
4015 case LSHIFT_EXPR:
4016 return "<<";
4018 case RSHIFT_EXPR:
4019 return ">>";
4021 case LROTATE_EXPR:
4022 return "r<<";
4024 case RROTATE_EXPR:
4025 return "r>>";
4027 case WIDEN_LSHIFT_EXPR:
4028 return "w<<";
4030 case POINTER_PLUS_EXPR:
4031 return "+";
4033 case PLUS_EXPR:
4034 return "+";
4036 case WIDEN_SUM_EXPR:
4037 return "w+";
4039 case WIDEN_MULT_EXPR:
4040 return "w*";
4042 case MULT_HIGHPART_EXPR:
4043 return "h*";
4045 case NEGATE_EXPR:
4046 case MINUS_EXPR:
4047 case POINTER_DIFF_EXPR:
4048 return "-";
4050 case BIT_NOT_EXPR:
4051 return "~";
4053 case TRUTH_NOT_EXPR:
4054 return "!";
4056 case MULT_EXPR:
4057 case INDIRECT_REF:
4058 return "*";
4060 case TRUNC_DIV_EXPR:
4061 case RDIV_EXPR:
4062 return "/";
4064 case CEIL_DIV_EXPR:
4065 return "/[cl]";
4067 case FLOOR_DIV_EXPR:
4068 return "/[fl]";
4070 case ROUND_DIV_EXPR:
4071 return "/[rd]";
4073 case EXACT_DIV_EXPR:
4074 return "/[ex]";
4076 case TRUNC_MOD_EXPR:
4077 return "%";
4079 case CEIL_MOD_EXPR:
4080 return "%[cl]";
4082 case FLOOR_MOD_EXPR:
4083 return "%[fl]";
4085 case ROUND_MOD_EXPR:
4086 return "%[rd]";
4088 case PREDECREMENT_EXPR:
4089 return " --";
4091 case PREINCREMENT_EXPR:
4092 return " ++";
4094 case POSTDECREMENT_EXPR:
4095 return "-- ";
4097 case POSTINCREMENT_EXPR:
4098 return "++ ";
4100 case MAX_EXPR:
4101 return "max";
4103 case MIN_EXPR:
4104 return "min";
4106 default:
4107 return "<<< ??? >>>";
4111 /* Return the symbol associated with operator OP. */
4113 static const char *
4114 op_symbol (const_tree op)
4116 return op_symbol_code (TREE_CODE (op));
4119 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4120 the gimple_call_fn of a GIMPLE_CALL. */
4122 void
4123 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4125 tree op0 = node;
4127 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4128 op0 = TREE_OPERAND (op0, 0);
4130 again:
4131 switch (TREE_CODE (op0))
4133 case VAR_DECL:
4134 case PARM_DECL:
4135 case FUNCTION_DECL:
4136 dump_function_name (pp, op0, flags);
4137 break;
4139 case ADDR_EXPR:
4140 case INDIRECT_REF:
4141 CASE_CONVERT:
4142 op0 = TREE_OPERAND (op0, 0);
4143 goto again;
4145 case COND_EXPR:
4146 pp_left_paren (pp);
4147 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4148 pp_string (pp, ") ? ");
4149 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4150 pp_string (pp, " : ");
4151 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4152 break;
4154 case ARRAY_REF:
4155 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4156 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4157 else
4158 dump_generic_node (pp, op0, 0, flags, false);
4159 break;
4161 case MEM_REF:
4162 if (integer_zerop (TREE_OPERAND (op0, 1)))
4164 op0 = TREE_OPERAND (op0, 0);
4165 goto again;
4167 /* Fallthru. */
4168 case COMPONENT_REF:
4169 case SSA_NAME:
4170 case OBJ_TYPE_REF:
4171 dump_generic_node (pp, op0, 0, flags, false);
4172 break;
4174 default:
4175 NIY;
4179 /* Print the first N characters in the array STR, replacing non-printable
4180 characters (including embedded nuls) with unambiguous escape sequences. */
4182 static void
4183 pretty_print_string (pretty_printer *pp, const char *str, unsigned n)
4185 if (str == NULL)
4186 return;
4188 for ( ; n; --n, ++str)
4190 switch (str[0])
4192 case '\b':
4193 pp_string (pp, "\\b");
4194 break;
4196 case '\f':
4197 pp_string (pp, "\\f");
4198 break;
4200 case '\n':
4201 pp_string (pp, "\\n");
4202 break;
4204 case '\r':
4205 pp_string (pp, "\\r");
4206 break;
4208 case '\t':
4209 pp_string (pp, "\\t");
4210 break;
4212 case '\v':
4213 pp_string (pp, "\\v");
4214 break;
4216 case '\\':
4217 pp_string (pp, "\\\\");
4218 break;
4220 case '\"':
4221 pp_string (pp, "\\\"");
4222 break;
4224 case '\'':
4225 pp_string (pp, "\\'");
4226 break;
4228 default:
4229 if (str[0] || n > 1)
4231 if (!ISPRINT (str[0]))
4233 char buf[5];
4234 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4235 pp_string (pp, buf);
4237 else
4238 pp_character (pp, str[0]);
4239 break;
4245 static void
4246 maybe_init_pretty_print (FILE *file)
4248 if (!tree_pp)
4250 tree_pp = new pretty_printer ();
4251 pp_needs_newline (tree_pp) = true;
4252 pp_translate_identifiers (tree_pp) = false;
4255 tree_pp->buffer->stream = file;
4258 static void
4259 newline_and_indent (pretty_printer *pp, int spc)
4261 pp_newline (pp);
4262 INDENT (spc);
4265 /* Handle the %K format for TEXT. Separate from default_tree_printer
4266 so it can also be used in front ends.
4267 The location LOC and BLOCK are expected to be extracted by the caller
4268 from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
4270 void
4271 percent_K_format (text_info *text, location_t loc, tree block)
4273 text->set_location (0, loc, SHOW_RANGE_WITH_CARET);
4274 gcc_assert (pp_ti_abstract_origin (text) != NULL);
4275 *pp_ti_abstract_origin (text) = NULL;
4277 while (block
4278 && TREE_CODE (block) == BLOCK
4279 && BLOCK_ABSTRACT_ORIGIN (block))
4281 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4282 if (TREE_CODE (ao) == FUNCTION_DECL)
4284 *pp_ti_abstract_origin (text) = block;
4285 break;
4287 block = BLOCK_SUPERCONTEXT (block);
4291 /* Print the identifier ID to PRETTY-PRINTER. */
4293 void
4294 pp_tree_identifier (pretty_printer *pp, tree id)
4296 if (pp_translate_identifiers (pp))
4298 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4299 pp_append_text (pp, text, text + strlen (text));
4301 else
4302 pp_append_text (pp, IDENTIFIER_POINTER (id),
4303 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4306 /* A helper function that is used to dump function information before the
4307 function dump. */
4309 void
4310 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4312 const char *dname, *aname;
4313 struct cgraph_node *node = cgraph_node::get (fdecl);
4314 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4316 dname = lang_hooks.decl_printable_name (fdecl, 1);
4318 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4319 aname = (IDENTIFIER_POINTER
4320 (DECL_ASSEMBLER_NAME (fdecl)));
4321 else
4322 aname = "<unset-asm-name>";
4324 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4325 dname, aname, fun->funcdef_no);
4326 if (!(flags & TDF_NOUID))
4327 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4328 if (node)
4330 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4331 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4332 node->frequency == NODE_FREQUENCY_HOT
4333 ? " (hot)"
4334 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4335 ? " (unlikely executed)"
4336 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4337 ? " (executed once)"
4338 : "");
4340 else
4341 fprintf (dump_file, ")\n\n");
4344 /* Dump double_int D to pretty_printer PP. UNS is true
4345 if D is unsigned and false otherwise. */
4346 void
4347 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4349 if (d.fits_shwi ())
4350 pp_wide_integer (pp, d.low);
4351 else if (d.fits_uhwi ())
4352 pp_unsigned_wide_integer (pp, d.low);
4353 else
4355 unsigned HOST_WIDE_INT low = d.low;
4356 HOST_WIDE_INT high = d.high;
4357 if (!uns && d.is_negative ())
4359 pp_minus (pp);
4360 high = ~high + !low;
4361 low = -low;
4363 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4364 systems? */
4365 sprintf (pp_buffer (pp)->digit_buffer,
4366 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4367 (unsigned HOST_WIDE_INT) high, low);
4368 pp_string (pp, pp_buffer (pp)->digit_buffer);
4372 #if __GNUC__ >= 10
4373 # pragma GCC diagnostic pop
4374 #endif