Daily bump.
[official-gcc.git] / gcc / tree-pretty-print.c
blob275dc7d8af737ab620dd576c7c77501c26ca8018
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2021 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 /* Routines in this file get invoked via the default tree printer
40 used by diagnostics and thus they are called from pp_printf which
41 isn't reentrant. Avoid using pp_printf in this file. */
42 #pragma GCC poison pp_printf
44 /* Disable warnings about quoting issues in the pp_xxx calls below
45 that (intentionally) don't follow GCC diagnostic conventions. */
46 #if __GNUC__ >= 10
47 # pragma GCC diagnostic push
48 # pragma GCC diagnostic ignored "-Wformat-diag"
49 #endif
51 /* Local functions, macros and variables. */
52 static const char *op_symbol (const_tree);
53 static void newline_and_indent (pretty_printer *, int);
54 static void maybe_init_pretty_print (FILE *);
55 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
56 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
58 #define INDENT(SPACE) do { \
59 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
61 #define NIY do_niy (pp, node, flags)
63 static pretty_printer *tree_pp;
65 /* Try to print something for an unknown tree code. */
67 static void
68 do_niy (pretty_printer *pp, const_tree node, dump_flags_t flags)
70 int i, len;
72 pp_string (pp, "<<< Unknown tree: ");
73 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
75 if (EXPR_P (node))
77 len = TREE_OPERAND_LENGTH (node);
78 for (i = 0; i < len; ++i)
80 newline_and_indent (pp, 2);
81 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
85 pp_string (pp, " >>>");
88 /* Debugging function to print out a generic expression. */
90 DEBUG_FUNCTION void
91 debug_generic_expr (tree t)
93 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
94 fprintf (stderr, "\n");
97 /* Debugging function to print out a generic statement. */
99 DEBUG_FUNCTION void
100 debug_generic_stmt (tree t)
102 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
103 fprintf (stderr, "\n");
106 /* Debugging function to print out a chain of trees . */
108 DEBUG_FUNCTION void
109 debug_tree_chain (tree t)
111 hash_set<tree> seen;
113 while (t)
115 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
116 fprintf (stderr, " ");
117 t = TREE_CHAIN (t);
118 if (seen.add (t))
120 fprintf (stderr, "... [cycled back to ");
121 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
122 fprintf (stderr, "]");
123 break;
126 fprintf (stderr, "\n");
129 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
130 void
131 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
133 maybe_init_pretty_print (file);
134 print_declaration (tree_pp, decl, 2, flags);
135 pp_write_text_to_stream (tree_pp);
138 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
139 to show in the dump. See TDF_* in dumpfile.h. */
141 void
142 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
144 maybe_init_pretty_print (file);
145 dump_generic_node (tree_pp, t, 0, flags, true);
146 pp_newline_and_flush (tree_pp);
149 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
150 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
151 INDENT spaces. */
153 void
154 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
156 int i;
158 maybe_init_pretty_print (file);
160 for (i = 0; i < indent; i++)
161 pp_space (tree_pp);
162 dump_generic_node (tree_pp, t, indent, flags, true);
163 pp_newline_and_flush (tree_pp);
166 /* Print a single expression T on file FILE. FLAGS specifies details to show
167 in the dump. See TDF_* in dumpfile.h. */
169 void
170 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
172 maybe_init_pretty_print (file);
173 dump_generic_node (tree_pp, t, 0, flags, false);
174 pp_flush (tree_pp);
177 /* Print a single expression T to string, and return it. The caller
178 must free the returned memory. */
180 char *
181 print_generic_expr_to_str (tree t)
183 pretty_printer pp;
184 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
185 return xstrdup (pp_formatted_text (&pp));
188 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
189 in it are replaced with Dxxxx, as long as they are at the start or
190 preceded by $ and at the end or followed by $. See make_fancy_name
191 in tree-sra.c. */
193 static void
194 dump_fancy_name (pretty_printer *pp, tree name)
196 int cnt = 0;
197 int length = IDENTIFIER_LENGTH (name);
198 const char *n = IDENTIFIER_POINTER (name);
201 n = strchr (n, 'D');
202 if (n == NULL)
203 break;
204 if (ISDIGIT (n[1])
205 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
207 int l = 2;
208 while (ISDIGIT (n[l]))
209 l++;
210 if (n[l] == '\0' || n[l] == '$')
212 cnt++;
213 length += 5 - l;
215 n += l;
217 else
218 n++;
220 while (1);
221 if (cnt == 0)
223 pp_tree_identifier (pp, name);
224 return;
227 char *str = XNEWVEC (char, length + 1);
228 char *p = str;
229 const char *q;
230 q = n = IDENTIFIER_POINTER (name);
233 q = strchr (q, 'D');
234 if (q == NULL)
235 break;
236 if (ISDIGIT (q[1])
237 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
239 int l = 2;
240 while (ISDIGIT (q[l]))
241 l++;
242 if (q[l] == '\0' || q[l] == '$')
244 memcpy (p, n, q - n);
245 memcpy (p + (q - n), "Dxxxx", 5);
246 p += (q - n) + 5;
247 n = q + l;
249 q += l;
251 else
252 q++;
254 while (1);
255 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
256 str[length] = '\0';
257 if (pp_translate_identifiers (pp))
259 const char *text = identifier_to_locale (str);
260 pp_append_text (pp, text, text + strlen (text));
262 else
263 pp_append_text (pp, str, str + length);
264 XDELETEVEC (str);
267 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
268 in FLAGS. */
270 static void
271 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
273 tree name = DECL_NAME (node);
274 if (name)
276 if ((flags & TDF_ASMNAME)
277 && HAS_DECL_ASSEMBLER_NAME_P (node)
278 && DECL_ASSEMBLER_NAME_SET_P (node))
279 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
280 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
281 -g might have created more fancy names and their indexes
282 could get out of sync. Usually those should be DECL_IGNORED_P
283 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
284 names, let's hope those never get out of sync after doing the
285 dump_fancy_name sanitization. */
286 else if ((flags & TDF_COMPARE_DEBUG)
287 && DECL_NAMELESS (node)
288 && DECL_IGNORED_P (node))
289 name = NULL_TREE;
290 /* For DECL_NAMELESS names look for embedded uids in the
291 names and sanitize them for TDF_NOUID. */
292 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
293 dump_fancy_name (pp, name);
294 else
295 pp_tree_identifier (pp, name);
297 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
298 if ((flags & TDF_UID) || name == NULL_TREE)
300 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
302 pp_character (pp, 'L');
303 pp_character (pp, uid_sep);
304 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
306 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
308 if (flags & TDF_NOUID)
309 pp_string (pp, "D#xxxx");
310 else
312 pp_string (pp, "D#");
313 pp_decimal_int (pp, (int) DEBUG_TEMP_UID (node));
316 else
318 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
319 pp_character (pp, c);
320 pp_character (pp, uid_sep);
321 if (flags & TDF_NOUID)
322 pp_string (pp, "xxxx");
323 else
324 pp_scalar (pp, "%u", DECL_UID (node));
327 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
329 if (flags & TDF_NOUID)
330 pp_string (pp, "ptD.xxxx");
331 else
333 pp_string (pp, "ptD.");
334 pp_scalar (pp, "%u", DECL_PT_UID (node));
339 /* Like the above, but used for pretty printing function calls. */
341 static void
342 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
344 if (CONVERT_EXPR_P (node))
345 node = TREE_OPERAND (node, 0);
346 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
348 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
349 if (flags & TDF_UID)
351 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
352 pp_character (pp, 'D');
353 pp_character (pp, uid_sep);
354 pp_scalar (pp, "%u", DECL_UID (node));
357 else
358 dump_decl_name (pp, node, flags);
361 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
362 FLAGS are as in dump_generic_node. */
364 static void
365 dump_function_declaration (pretty_printer *pp, tree node,
366 int spc, dump_flags_t flags)
368 bool wrote_arg = false;
369 tree arg;
371 pp_space (pp);
372 pp_left_paren (pp);
374 /* Print the argument types. */
375 arg = TYPE_ARG_TYPES (node);
376 while (arg && arg != void_list_node && arg != error_mark_node)
378 if (wrote_arg)
380 pp_comma (pp);
381 pp_space (pp);
383 wrote_arg = true;
384 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
385 arg = TREE_CHAIN (arg);
388 /* Drop the trailing void_type_node if we had any previous argument. */
389 if (arg == void_list_node && !wrote_arg)
390 pp_string (pp, "void");
391 /* Properly dump vararg function types. */
392 else if (!arg && wrote_arg)
393 pp_string (pp, ", ...");
394 /* Avoid printing any arg for unprototyped functions. */
396 pp_right_paren (pp);
399 /* Dump the domain associated with an array. */
401 static void
402 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
404 pp_left_bracket (pp);
405 if (domain)
407 tree min = TYPE_MIN_VALUE (domain);
408 tree max = TYPE_MAX_VALUE (domain);
410 if (min && max
411 && integer_zerop (min)
412 && tree_fits_shwi_p (max))
413 pp_wide_integer (pp, tree_to_shwi (max) + 1);
414 else
416 if (min)
417 dump_generic_node (pp, min, spc, flags, false);
418 pp_colon (pp);
419 if (max)
420 dump_generic_node (pp, max, spc, flags, false);
423 else
424 pp_string (pp, "<unknown>");
425 pp_right_bracket (pp);
429 /* Dump OpenMP iterators ITER. */
431 static void
432 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
434 pp_string (pp, "iterator(");
435 for (tree it = iter; it; it = TREE_CHAIN (it))
437 if (it != iter)
438 pp_string (pp, ", ");
439 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
440 false);
441 pp_space (pp);
442 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
443 pp_equal (pp);
444 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
445 pp_colon (pp);
446 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
447 pp_colon (pp);
448 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
450 pp_right_paren (pp);
454 /* Dump OMP clause CLAUSE, without following OMP_CLAUSE_CHAIN.
456 PP, CLAUSE, SPC and FLAGS are as in dump_generic_node. */
458 static void
459 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
461 const char *name;
462 const char *modifier = NULL;
463 switch (OMP_CLAUSE_CODE (clause))
465 case OMP_CLAUSE_PRIVATE:
466 name = "private";
467 goto print_remap;
468 case OMP_CLAUSE_SHARED:
469 name = "shared";
470 goto print_remap;
471 case OMP_CLAUSE_FIRSTPRIVATE:
472 name = "firstprivate";
473 goto print_remap;
474 case OMP_CLAUSE_LASTPRIVATE:
475 name = "lastprivate";
476 if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
477 modifier = "conditional:";
478 goto print_remap;
479 case OMP_CLAUSE_COPYIN:
480 name = "copyin";
481 goto print_remap;
482 case OMP_CLAUSE_COPYPRIVATE:
483 name = "copyprivate";
484 goto print_remap;
485 case OMP_CLAUSE_UNIFORM:
486 name = "uniform";
487 goto print_remap;
488 case OMP_CLAUSE_USE_DEVICE_PTR:
489 name = "use_device_ptr";
490 if (OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT (clause))
491 modifier = "if_present:";
492 goto print_remap;
493 case OMP_CLAUSE_USE_DEVICE_ADDR:
494 name = "use_device_addr";
495 goto print_remap;
496 case OMP_CLAUSE_IS_DEVICE_PTR:
497 name = "is_device_ptr";
498 goto print_remap;
499 case OMP_CLAUSE_INCLUSIVE:
500 name = "inclusive";
501 goto print_remap;
502 case OMP_CLAUSE_EXCLUSIVE:
503 name = "exclusive";
504 goto print_remap;
505 case OMP_CLAUSE__LOOPTEMP_:
506 name = "_looptemp_";
507 goto print_remap;
508 case OMP_CLAUSE__REDUCTEMP_:
509 name = "_reductemp_";
510 goto print_remap;
511 case OMP_CLAUSE__CONDTEMP_:
512 name = "_condtemp_";
513 goto print_remap;
514 case OMP_CLAUSE__SCANTEMP_:
515 name = "_scantemp_";
516 goto print_remap;
517 case OMP_CLAUSE_TO_DECLARE:
518 name = "to";
519 goto print_remap;
520 case OMP_CLAUSE_LINK:
521 name = "link";
522 goto print_remap;
523 case OMP_CLAUSE_NONTEMPORAL:
524 name = "nontemporal";
525 goto print_remap;
526 print_remap:
527 pp_string (pp, name);
528 pp_left_paren (pp);
529 if (modifier)
530 pp_string (pp, modifier);
531 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
532 spc, flags, false);
533 pp_right_paren (pp);
534 break;
536 case OMP_CLAUSE_TASK_REDUCTION:
537 case OMP_CLAUSE_IN_REDUCTION:
538 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
539 ? "in_" : "task_");
540 /* FALLTHRU */
541 case OMP_CLAUSE_REDUCTION:
542 pp_string (pp, "reduction(");
543 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
545 if (OMP_CLAUSE_REDUCTION_TASK (clause))
546 pp_string (pp, "task,");
547 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
548 pp_string (pp, "inscan,");
550 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
552 pp_string (pp,
553 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
554 pp_colon (pp);
556 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
557 spc, flags, false);
558 pp_right_paren (pp);
559 break;
561 case OMP_CLAUSE_IF:
562 pp_string (pp, "if(");
563 switch (OMP_CLAUSE_IF_MODIFIER (clause))
565 case ERROR_MARK: break;
566 case VOID_CST: pp_string (pp, "cancel:"); break;
567 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
568 case OMP_SIMD: pp_string (pp, "simd:"); break;
569 case OMP_TASK: pp_string (pp, "task:"); break;
570 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
571 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
572 case OMP_TARGET: pp_string (pp, "target:"); break;
573 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
574 case OMP_TARGET_ENTER_DATA:
575 pp_string (pp, "target enter data:"); break;
576 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
577 default: gcc_unreachable ();
579 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
580 spc, flags, false);
581 pp_right_paren (pp);
582 break;
584 case OMP_CLAUSE_NUM_THREADS:
585 pp_string (pp, "num_threads(");
586 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
587 spc, flags, false);
588 pp_right_paren (pp);
589 break;
591 case OMP_CLAUSE_NOWAIT:
592 pp_string (pp, "nowait");
593 break;
594 case OMP_CLAUSE_ORDERED:
595 pp_string (pp, "ordered");
596 if (OMP_CLAUSE_ORDERED_EXPR (clause))
598 pp_left_paren (pp);
599 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
600 spc, flags, false);
601 pp_right_paren (pp);
603 break;
605 case OMP_CLAUSE_DEFAULT:
606 pp_string (pp, "default(");
607 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
609 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
610 break;
611 case OMP_CLAUSE_DEFAULT_SHARED:
612 pp_string (pp, "shared");
613 break;
614 case OMP_CLAUSE_DEFAULT_NONE:
615 pp_string (pp, "none");
616 break;
617 case OMP_CLAUSE_DEFAULT_PRIVATE:
618 pp_string (pp, "private");
619 break;
620 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
621 pp_string (pp, "firstprivate");
622 break;
623 case OMP_CLAUSE_DEFAULT_PRESENT:
624 pp_string (pp, "present");
625 break;
626 default:
627 gcc_unreachable ();
629 pp_right_paren (pp);
630 break;
632 case OMP_CLAUSE_SCHEDULE:
633 pp_string (pp, "schedule(");
634 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
635 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
636 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
638 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
639 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
640 pp_string (pp, "monotonic");
641 else
642 pp_string (pp, "nonmonotonic");
643 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
644 pp_comma (pp);
645 else
646 pp_colon (pp);
648 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
649 pp_string (pp, "simd:");
651 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
653 case OMP_CLAUSE_SCHEDULE_STATIC:
654 pp_string (pp, "static");
655 break;
656 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
657 pp_string (pp, "dynamic");
658 break;
659 case OMP_CLAUSE_SCHEDULE_GUIDED:
660 pp_string (pp, "guided");
661 break;
662 case OMP_CLAUSE_SCHEDULE_RUNTIME:
663 pp_string (pp, "runtime");
664 break;
665 case OMP_CLAUSE_SCHEDULE_AUTO:
666 pp_string (pp, "auto");
667 break;
668 default:
669 gcc_unreachable ();
671 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
673 pp_comma (pp);
674 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
675 spc, flags, false);
677 pp_right_paren (pp);
678 break;
680 case OMP_CLAUSE_UNTIED:
681 pp_string (pp, "untied");
682 break;
684 case OMP_CLAUSE_COLLAPSE:
685 pp_string (pp, "collapse(");
686 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
687 spc, flags, false);
688 pp_right_paren (pp);
689 break;
691 case OMP_CLAUSE_FINAL:
692 pp_string (pp, "final(");
693 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
694 spc, flags, false);
695 pp_right_paren (pp);
696 break;
698 case OMP_CLAUSE_MERGEABLE:
699 pp_string (pp, "mergeable");
700 break;
702 case OMP_CLAUSE_LINEAR:
703 pp_string (pp, "linear(");
704 switch (OMP_CLAUSE_LINEAR_KIND (clause))
706 case OMP_CLAUSE_LINEAR_DEFAULT:
707 break;
708 case OMP_CLAUSE_LINEAR_REF:
709 pp_string (pp, "ref(");
710 break;
711 case OMP_CLAUSE_LINEAR_VAL:
712 pp_string (pp, "val(");
713 break;
714 case OMP_CLAUSE_LINEAR_UVAL:
715 pp_string (pp, "uval(");
716 break;
717 default:
718 gcc_unreachable ();
720 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
721 spc, flags, false);
722 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
723 pp_right_paren (pp);
724 pp_colon (pp);
725 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
726 spc, flags, false);
727 pp_right_paren (pp);
728 break;
730 case OMP_CLAUSE_ALIGNED:
731 pp_string (pp, "aligned(");
732 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
733 spc, flags, false);
734 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
736 pp_colon (pp);
737 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
738 spc, flags, false);
740 pp_right_paren (pp);
741 break;
743 case OMP_CLAUSE_ALLOCATE:
744 pp_string (pp, "allocate(");
745 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
747 pp_string (pp, "allocator(");
748 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause),
749 spc, flags, false);
750 pp_right_paren (pp);
752 if (OMP_CLAUSE_ALLOCATE_ALIGN (clause))
754 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
755 pp_comma (pp);
756 pp_string (pp, "align(");
757 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALIGN (clause),
758 spc, flags, false);
759 pp_right_paren (pp);
761 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause)
762 || OMP_CLAUSE_ALLOCATE_ALIGN (clause))
763 pp_colon (pp);
764 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
765 spc, flags, false);
766 pp_right_paren (pp);
767 break;
769 case OMP_CLAUSE_AFFINITY:
770 pp_string (pp, "affinity(");
772 tree t = OMP_CLAUSE_DECL (clause);
773 if (TREE_CODE (t) == TREE_LIST
774 && TREE_PURPOSE (t)
775 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
777 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
778 pp_colon (pp);
779 t = TREE_VALUE (t);
781 dump_generic_node (pp, t, spc, flags, false);
783 pp_right_paren (pp);
784 break;
785 case OMP_CLAUSE_DEPEND:
786 pp_string (pp, "depend(");
787 switch (OMP_CLAUSE_DEPEND_KIND (clause))
789 case OMP_CLAUSE_DEPEND_DEPOBJ:
790 name = "depobj";
791 break;
792 case OMP_CLAUSE_DEPEND_IN:
793 name = "in";
794 break;
795 case OMP_CLAUSE_DEPEND_OUT:
796 name = "out";
797 break;
798 case OMP_CLAUSE_DEPEND_INOUT:
799 name = "inout";
800 break;
801 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
802 name = "mutexinoutset";
803 break;
804 case OMP_CLAUSE_DEPEND_SOURCE:
805 pp_string (pp, "source)");
806 return;
807 case OMP_CLAUSE_DEPEND_LAST:
808 name = "__internal__";
809 break;
810 case OMP_CLAUSE_DEPEND_SINK:
811 pp_string (pp, "sink:");
812 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
813 if (TREE_CODE (t) == TREE_LIST)
815 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
816 if (TREE_PURPOSE (t) != integer_zero_node)
818 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
819 pp_minus (pp);
820 else
821 pp_plus (pp);
822 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
823 false);
825 if (TREE_CHAIN (t))
826 pp_comma (pp);
828 else
829 gcc_unreachable ();
830 pp_right_paren (pp);
831 return;
832 default:
833 gcc_unreachable ();
836 tree t = OMP_CLAUSE_DECL (clause);
837 if (TREE_CODE (t) == TREE_LIST
838 && TREE_PURPOSE (t)
839 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
841 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
842 pp_colon (pp);
843 t = TREE_VALUE (t);
845 if (name[0])
847 pp_string (pp, name);
848 pp_colon (pp);
850 dump_generic_node (pp, t, spc, flags, false);
851 pp_right_paren (pp);
853 break;
855 case OMP_CLAUSE_MAP:
856 pp_string (pp, "map(");
857 switch (OMP_CLAUSE_MAP_KIND (clause))
859 case GOMP_MAP_ALLOC:
860 case GOMP_MAP_POINTER:
861 pp_string (pp, "alloc");
862 break;
863 case GOMP_MAP_IF_PRESENT:
864 pp_string (pp, "no_alloc");
865 break;
866 case GOMP_MAP_TO:
867 case GOMP_MAP_TO_PSET:
868 pp_string (pp, "to");
869 break;
870 case GOMP_MAP_FROM:
871 pp_string (pp, "from");
872 break;
873 case GOMP_MAP_TOFROM:
874 pp_string (pp, "tofrom");
875 break;
876 case GOMP_MAP_FORCE_ALLOC:
877 pp_string (pp, "force_alloc");
878 break;
879 case GOMP_MAP_FORCE_TO:
880 pp_string (pp, "force_to");
881 break;
882 case GOMP_MAP_FORCE_FROM:
883 pp_string (pp, "force_from");
884 break;
885 case GOMP_MAP_FORCE_TOFROM:
886 pp_string (pp, "force_tofrom");
887 break;
888 case GOMP_MAP_FORCE_PRESENT:
889 pp_string (pp, "force_present");
890 break;
891 case GOMP_MAP_DELETE:
892 pp_string (pp, "delete");
893 break;
894 case GOMP_MAP_FORCE_DEVICEPTR:
895 pp_string (pp, "force_deviceptr");
896 break;
897 case GOMP_MAP_ALWAYS_TO:
898 pp_string (pp, "always,to");
899 break;
900 case GOMP_MAP_ALWAYS_FROM:
901 pp_string (pp, "always,from");
902 break;
903 case GOMP_MAP_ALWAYS_TOFROM:
904 pp_string (pp, "always,tofrom");
905 break;
906 case GOMP_MAP_RELEASE:
907 pp_string (pp, "release");
908 break;
909 case GOMP_MAP_FIRSTPRIVATE_POINTER:
910 pp_string (pp, "firstprivate");
911 break;
912 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
913 pp_string (pp, "firstprivate ref");
914 break;
915 case GOMP_MAP_STRUCT:
916 pp_string (pp, "struct");
917 break;
918 case GOMP_MAP_ALWAYS_POINTER:
919 pp_string (pp, "always_pointer");
920 break;
921 case GOMP_MAP_DEVICE_RESIDENT:
922 pp_string (pp, "device_resident");
923 break;
924 case GOMP_MAP_LINK:
925 pp_string (pp, "link");
926 break;
927 case GOMP_MAP_ATTACH:
928 pp_string (pp, "attach");
929 break;
930 case GOMP_MAP_DETACH:
931 pp_string (pp, "detach");
932 break;
933 case GOMP_MAP_FORCE_DETACH:
934 pp_string (pp, "force_detach");
935 break;
936 case GOMP_MAP_ATTACH_DETACH:
937 pp_string (pp, "attach_detach");
938 break;
939 default:
940 gcc_unreachable ();
942 pp_colon (pp);
943 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
944 spc, flags, false);
945 print_clause_size:
946 if (OMP_CLAUSE_SIZE (clause))
948 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
949 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
951 case GOMP_MAP_POINTER:
952 case GOMP_MAP_FIRSTPRIVATE_POINTER:
953 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
954 case GOMP_MAP_ALWAYS_POINTER:
955 pp_string (pp, " [pointer assign, bias: ");
956 break;
957 case GOMP_MAP_TO_PSET:
958 pp_string (pp, " [pointer set, len: ");
959 break;
960 case GOMP_MAP_ATTACH:
961 case GOMP_MAP_DETACH:
962 case GOMP_MAP_FORCE_DETACH:
963 case GOMP_MAP_ATTACH_DETACH:
964 pp_string (pp, " [bias: ");
965 break;
966 default:
967 pp_string (pp, " [len: ");
968 break;
970 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
971 spc, flags, false);
972 pp_right_bracket (pp);
974 pp_right_paren (pp);
975 break;
977 case OMP_CLAUSE_FROM:
978 pp_string (pp, "from(");
979 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
980 spc, flags, false);
981 goto print_clause_size;
983 case OMP_CLAUSE_TO:
984 pp_string (pp, "to(");
985 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
986 spc, flags, false);
987 goto print_clause_size;
989 case OMP_CLAUSE__CACHE_:
990 pp_string (pp, "(");
991 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
992 spc, flags, false);
993 goto print_clause_size;
995 case OMP_CLAUSE_NUM_TEAMS:
996 pp_string (pp, "num_teams(");
997 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
998 spc, flags, false);
999 pp_right_paren (pp);
1000 break;
1002 case OMP_CLAUSE_THREAD_LIMIT:
1003 pp_string (pp, "thread_limit(");
1004 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
1005 spc, flags, false);
1006 pp_right_paren (pp);
1007 break;
1009 case OMP_CLAUSE_DEVICE:
1010 pp_string (pp, "device(");
1011 if (OMP_CLAUSE_DEVICE_ANCESTOR (clause))
1012 pp_string (pp, "ancestor:");
1013 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
1014 spc, flags, false);
1015 pp_right_paren (pp);
1016 break;
1018 case OMP_CLAUSE_DIST_SCHEDULE:
1019 pp_string (pp, "dist_schedule(static");
1020 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
1022 pp_comma (pp);
1023 dump_generic_node (pp,
1024 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
1025 spc, flags, false);
1027 pp_right_paren (pp);
1028 break;
1030 case OMP_CLAUSE_PROC_BIND:
1031 pp_string (pp, "proc_bind(");
1032 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
1034 case OMP_CLAUSE_PROC_BIND_MASTER:
1035 /* Same enum value: case OMP_CLAUSE_PROC_BIND_PRIMARY: */
1036 /* TODO: Change to 'primary' for OpenMP 5.1. */
1037 pp_string (pp, "master");
1038 break;
1039 case OMP_CLAUSE_PROC_BIND_CLOSE:
1040 pp_string (pp, "close");
1041 break;
1042 case OMP_CLAUSE_PROC_BIND_SPREAD:
1043 pp_string (pp, "spread");
1044 break;
1045 default:
1046 gcc_unreachable ();
1048 pp_right_paren (pp);
1049 break;
1051 case OMP_CLAUSE_DEVICE_TYPE:
1052 pp_string (pp, "device_type(");
1053 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
1055 case OMP_CLAUSE_DEVICE_TYPE_HOST:
1056 pp_string (pp, "host");
1057 break;
1058 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
1059 pp_string (pp, "nohost");
1060 break;
1061 case OMP_CLAUSE_DEVICE_TYPE_ANY:
1062 pp_string (pp, "any");
1063 break;
1064 default:
1065 gcc_unreachable ();
1067 pp_right_paren (pp);
1068 break;
1070 case OMP_CLAUSE_SAFELEN:
1071 pp_string (pp, "safelen(");
1072 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
1073 spc, flags, false);
1074 pp_right_paren (pp);
1075 break;
1077 case OMP_CLAUSE_SIMDLEN:
1078 pp_string (pp, "simdlen(");
1079 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
1080 spc, flags, false);
1081 pp_right_paren (pp);
1082 break;
1084 case OMP_CLAUSE_PRIORITY:
1085 pp_string (pp, "priority(");
1086 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
1087 spc, flags, false);
1088 pp_right_paren (pp);
1089 break;
1091 case OMP_CLAUSE_GRAINSIZE:
1092 pp_string (pp, "grainsize(");
1093 if (OMP_CLAUSE_GRAINSIZE_STRICT (clause))
1094 pp_string (pp, "strict:");
1095 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
1096 spc, flags, false);
1097 pp_right_paren (pp);
1098 break;
1100 case OMP_CLAUSE_NUM_TASKS:
1101 pp_string (pp, "num_tasks(");
1102 if (OMP_CLAUSE_NUM_TASKS_STRICT (clause))
1103 pp_string (pp, "strict:");
1104 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1105 spc, flags, false);
1106 pp_right_paren (pp);
1107 break;
1109 case OMP_CLAUSE_HINT:
1110 pp_string (pp, "hint(");
1111 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1112 spc, flags, false);
1113 pp_right_paren (pp);
1114 break;
1116 case OMP_CLAUSE_FILTER:
1117 pp_string (pp, "filter(");
1118 dump_generic_node (pp, OMP_CLAUSE_FILTER_EXPR (clause),
1119 spc, flags, false);
1120 pp_right_paren (pp);
1121 break;
1123 case OMP_CLAUSE_DEFAULTMAP:
1124 pp_string (pp, "defaultmap(");
1125 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1127 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1128 pp_string (pp, "alloc");
1129 break;
1130 case OMP_CLAUSE_DEFAULTMAP_TO:
1131 pp_string (pp, "to");
1132 break;
1133 case OMP_CLAUSE_DEFAULTMAP_FROM:
1134 pp_string (pp, "from");
1135 break;
1136 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1137 pp_string (pp, "tofrom");
1138 break;
1139 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1140 pp_string (pp, "firstprivate");
1141 break;
1142 case OMP_CLAUSE_DEFAULTMAP_NONE:
1143 pp_string (pp, "none");
1144 break;
1145 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1146 pp_string (pp, "default");
1147 break;
1148 default:
1149 gcc_unreachable ();
1151 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1153 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1154 break;
1155 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1156 pp_string (pp, ":scalar");
1157 break;
1158 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1159 pp_string (pp, ":aggregate");
1160 break;
1161 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1162 pp_string (pp, ":allocatable");
1163 break;
1164 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1165 pp_string (pp, ":pointer");
1166 break;
1167 default:
1168 gcc_unreachable ();
1170 pp_right_paren (pp);
1171 break;
1173 case OMP_CLAUSE_ORDER:
1174 pp_string (pp, "order(");
1175 if (OMP_CLAUSE_ORDER_UNCONSTRAINED (clause))
1176 pp_string (pp, "unconstrained:");
1177 else if (OMP_CLAUSE_ORDER_REPRODUCIBLE (clause))
1178 pp_string (pp, "reproducible:");
1179 pp_string (pp, "concurrent)");
1180 break;
1182 case OMP_CLAUSE_BIND:
1183 pp_string (pp, "bind(");
1184 switch (OMP_CLAUSE_BIND_KIND (clause))
1186 case OMP_CLAUSE_BIND_TEAMS:
1187 pp_string (pp, "teams");
1188 break;
1189 case OMP_CLAUSE_BIND_PARALLEL:
1190 pp_string (pp, "parallel");
1191 break;
1192 case OMP_CLAUSE_BIND_THREAD:
1193 pp_string (pp, "thread");
1194 break;
1195 default:
1196 gcc_unreachable ();
1198 pp_right_paren (pp);
1199 break;
1201 case OMP_CLAUSE__SIMDUID_:
1202 pp_string (pp, "_simduid_(");
1203 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1204 spc, flags, false);
1205 pp_right_paren (pp);
1206 break;
1208 case OMP_CLAUSE__SIMT_:
1209 pp_string (pp, "_simt_");
1210 break;
1212 case OMP_CLAUSE_GANG:
1213 pp_string (pp, "gang");
1214 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1216 pp_string (pp, "(num: ");
1217 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1218 spc, flags, false);
1220 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1222 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1223 pp_left_paren (pp);
1224 else
1225 pp_space (pp);
1226 pp_string (pp, "static:");
1227 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1228 == integer_minus_one_node)
1229 pp_character (pp, '*');
1230 else
1231 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1232 spc, flags, false);
1234 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1235 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1236 pp_right_paren (pp);
1237 break;
1239 case OMP_CLAUSE_ASYNC:
1240 pp_string (pp, "async");
1241 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1243 pp_character(pp, '(');
1244 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1245 spc, flags, false);
1246 pp_character(pp, ')');
1248 break;
1250 case OMP_CLAUSE_AUTO:
1251 case OMP_CLAUSE_SEQ:
1252 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1253 break;
1255 case OMP_CLAUSE_WAIT:
1256 pp_string (pp, "wait(");
1257 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1258 spc, flags, false);
1259 pp_character(pp, ')');
1260 break;
1262 case OMP_CLAUSE_WORKER:
1263 pp_string (pp, "worker");
1264 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1266 pp_left_paren (pp);
1267 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1268 spc, flags, false);
1269 pp_right_paren (pp);
1271 break;
1273 case OMP_CLAUSE_VECTOR:
1274 pp_string (pp, "vector");
1275 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1277 pp_left_paren (pp);
1278 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1279 spc, flags, false);
1280 pp_right_paren (pp);
1282 break;
1284 case OMP_CLAUSE_NUM_GANGS:
1285 pp_string (pp, "num_gangs(");
1286 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1287 spc, flags, false);
1288 pp_character (pp, ')');
1289 break;
1291 case OMP_CLAUSE_NUM_WORKERS:
1292 pp_string (pp, "num_workers(");
1293 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1294 spc, flags, false);
1295 pp_character (pp, ')');
1296 break;
1298 case OMP_CLAUSE_VECTOR_LENGTH:
1299 pp_string (pp, "vector_length(");
1300 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1301 spc, flags, false);
1302 pp_character (pp, ')');
1303 break;
1305 case OMP_CLAUSE_INBRANCH:
1306 pp_string (pp, "inbranch");
1307 break;
1308 case OMP_CLAUSE_NOTINBRANCH:
1309 pp_string (pp, "notinbranch");
1310 break;
1311 case OMP_CLAUSE_FOR:
1312 pp_string (pp, "for");
1313 break;
1314 case OMP_CLAUSE_PARALLEL:
1315 pp_string (pp, "parallel");
1316 break;
1317 case OMP_CLAUSE_SECTIONS:
1318 pp_string (pp, "sections");
1319 break;
1320 case OMP_CLAUSE_TASKGROUP:
1321 pp_string (pp, "taskgroup");
1322 break;
1323 case OMP_CLAUSE_NOGROUP:
1324 pp_string (pp, "nogroup");
1325 break;
1326 case OMP_CLAUSE_THREADS:
1327 pp_string (pp, "threads");
1328 break;
1329 case OMP_CLAUSE_SIMD:
1330 pp_string (pp, "simd");
1331 break;
1332 case OMP_CLAUSE_INDEPENDENT:
1333 pp_string (pp, "independent");
1334 break;
1335 case OMP_CLAUSE_TILE:
1336 pp_string (pp, "tile(");
1337 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1338 spc, flags, false);
1339 pp_right_paren (pp);
1340 break;
1342 case OMP_CLAUSE_IF_PRESENT:
1343 pp_string (pp, "if_present");
1344 break;
1345 case OMP_CLAUSE_FINALIZE:
1346 pp_string (pp, "finalize");
1347 break;
1348 case OMP_CLAUSE_NOHOST:
1349 pp_string (pp, "nohost");
1350 break;
1351 case OMP_CLAUSE_DETACH:
1352 pp_string (pp, "detach(");
1353 dump_generic_node (pp, OMP_CLAUSE_DECL (clause), spc, flags,
1354 false);
1355 pp_right_paren (pp);
1356 break;
1358 default:
1359 gcc_unreachable ();
1364 /* Dump chain of OMP clauses.
1366 PP, SPC and FLAGS are as in dump_generic_node. */
1368 void
1369 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags,
1370 bool leading_space)
1372 while (clause)
1374 if (leading_space)
1375 pp_space (pp);
1376 dump_omp_clause (pp, clause, spc, flags);
1377 leading_space = true;
1379 clause = OMP_CLAUSE_CHAIN (clause);
1384 /* Dump location LOC to PP. */
1386 void
1387 dump_location (pretty_printer *pp, location_t loc)
1389 expanded_location xloc = expand_location (loc);
1391 pp_left_bracket (pp);
1392 if (xloc.file)
1394 pp_string (pp, xloc.file);
1395 pp_string (pp, ":");
1397 pp_decimal_int (pp, xloc.line);
1398 pp_colon (pp);
1399 pp_decimal_int (pp, xloc.column);
1400 pp_string (pp, "] ");
1404 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1405 dump_generic_node. */
1407 static void
1408 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1410 tree t;
1412 pp_string (pp, "BLOCK #");
1413 pp_decimal_int (pp, BLOCK_NUMBER (block));
1414 pp_character (pp, ' ');
1416 if (flags & TDF_ADDRESS)
1418 pp_character (pp, '[');
1419 pp_scalar (pp, "%p", (void *) block);
1420 pp_string (pp, "] ");
1423 if (TREE_ASM_WRITTEN (block))
1424 pp_string (pp, "[written] ");
1426 if (flags & TDF_SLIM)
1427 return;
1429 if (BLOCK_SOURCE_LOCATION (block))
1430 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1432 newline_and_indent (pp, spc + 2);
1434 if (BLOCK_SUPERCONTEXT (block))
1436 pp_string (pp, "SUPERCONTEXT: ");
1437 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1438 flags | TDF_SLIM, false);
1439 newline_and_indent (pp, spc + 2);
1442 if (BLOCK_SUBBLOCKS (block))
1444 pp_string (pp, "SUBBLOCKS: ");
1445 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1447 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1448 pp_space (pp);
1450 newline_and_indent (pp, spc + 2);
1453 if (BLOCK_CHAIN (block))
1455 pp_string (pp, "SIBLINGS: ");
1456 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1458 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1459 pp_space (pp);
1461 newline_and_indent (pp, spc + 2);
1464 if (BLOCK_VARS (block))
1466 pp_string (pp, "VARS: ");
1467 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1469 dump_generic_node (pp, t, 0, flags, false);
1470 pp_space (pp);
1472 newline_and_indent (pp, spc + 2);
1475 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1477 unsigned i;
1478 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1480 pp_string (pp, "NONLOCALIZED_VARS: ");
1481 FOR_EACH_VEC_ELT (*nlv, i, t)
1483 dump_generic_node (pp, t, 0, flags, false);
1484 pp_space (pp);
1486 newline_and_indent (pp, spc + 2);
1489 if (BLOCK_ABSTRACT_ORIGIN (block))
1491 pp_string (pp, "ABSTRACT_ORIGIN: ");
1492 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1493 flags | TDF_SLIM, false);
1494 newline_and_indent (pp, spc + 2);
1497 if (BLOCK_FRAGMENT_ORIGIN (block))
1499 pp_string (pp, "FRAGMENT_ORIGIN: ");
1500 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1501 flags | TDF_SLIM, false);
1502 newline_and_indent (pp, spc + 2);
1505 if (BLOCK_FRAGMENT_CHAIN (block))
1507 pp_string (pp, "FRAGMENT_CHAIN: ");
1508 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1510 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1511 pp_space (pp);
1513 newline_and_indent (pp, spc + 2);
1517 /* Dump #pragma omp atomic memory order clause. */
1519 void
1520 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1522 switch (mo & OMP_MEMORY_ORDER_MASK)
1524 case OMP_MEMORY_ORDER_RELAXED:
1525 pp_string (pp, " relaxed");
1526 break;
1527 case OMP_MEMORY_ORDER_SEQ_CST:
1528 pp_string (pp, " seq_cst");
1529 break;
1530 case OMP_MEMORY_ORDER_ACQ_REL:
1531 pp_string (pp, " acq_rel");
1532 break;
1533 case OMP_MEMORY_ORDER_ACQUIRE:
1534 pp_string (pp, " acquire");
1535 break;
1536 case OMP_MEMORY_ORDER_RELEASE:
1537 pp_string (pp, " release");
1538 break;
1539 case OMP_MEMORY_ORDER_UNSPECIFIED:
1540 break;
1541 default:
1542 gcc_unreachable ();
1544 switch (mo & OMP_FAIL_MEMORY_ORDER_MASK)
1546 case OMP_FAIL_MEMORY_ORDER_RELAXED:
1547 pp_string (pp, " fail(relaxed)");
1548 break;
1549 case OMP_FAIL_MEMORY_ORDER_SEQ_CST:
1550 pp_string (pp, " fail(seq_cst)");
1551 break;
1552 case OMP_FAIL_MEMORY_ORDER_ACQUIRE:
1553 pp_string (pp, " fail(acquire)");
1554 break;
1555 case OMP_FAIL_MEMORY_ORDER_UNSPECIFIED:
1556 break;
1557 default:
1558 gcc_unreachable ();
1562 /* Helper to dump a MEM_REF node. */
1564 static void
1565 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1567 if (TREE_CODE (node) == MEM_REF && (flags & TDF_GIMPLE))
1569 pp_string (pp, "__MEM <");
1570 dump_generic_node (pp, TREE_TYPE (node),
1571 spc, flags | TDF_SLIM, false);
1572 if (TYPE_ALIGN (TREE_TYPE (node))
1573 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1575 pp_string (pp, ", ");
1576 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1578 pp_greater (pp);
1579 pp_string (pp, " (");
1580 if (TREE_TYPE (TREE_OPERAND (node, 0))
1581 != TREE_TYPE (TREE_OPERAND (node, 1)))
1583 pp_left_paren (pp);
1584 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1585 spc, flags | TDF_SLIM, false);
1586 pp_right_paren (pp);
1588 dump_generic_node (pp, TREE_OPERAND (node, 0),
1589 spc, flags | TDF_SLIM, false);
1590 if (! integer_zerop (TREE_OPERAND (node, 1)))
1592 pp_string (pp, " + ");
1593 dump_generic_node (pp, TREE_OPERAND (node, 1),
1594 spc, flags | TDF_SLIM, false);
1596 pp_right_paren (pp);
1598 else if (TREE_CODE (node) == MEM_REF
1599 && integer_zerop (TREE_OPERAND (node, 1))
1600 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1601 infer them and MEM_ATTR caching will share MEM_REFs
1602 with differently-typed op0s. */
1603 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1604 /* Released SSA_NAMES have no TREE_TYPE. */
1605 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1606 /* Same pointer types, but ignoring POINTER_TYPE vs.
1607 REFERENCE_TYPE. */
1608 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1609 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1610 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1611 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1612 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1613 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1614 /* Same value types ignoring qualifiers. */
1615 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1616 == TYPE_MAIN_VARIANT
1617 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1618 && (!(flags & TDF_ALIAS)
1619 || MR_DEPENDENCE_CLIQUE (node) == 0))
1621 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1623 /* Enclose pointers to arrays in parentheses. */
1624 tree op0 = TREE_OPERAND (node, 0);
1625 tree op0type = TREE_TYPE (op0);
1626 if (POINTER_TYPE_P (op0type)
1627 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1628 pp_left_paren (pp);
1629 pp_star (pp);
1630 dump_generic_node (pp, op0, spc, flags, false);
1631 if (POINTER_TYPE_P (op0type)
1632 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1633 pp_right_paren (pp);
1635 else
1636 dump_generic_node (pp,
1637 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1638 spc, flags, false);
1640 else
1642 pp_string (pp, "MEM");
1644 tree nodetype = TREE_TYPE (node);
1645 tree op0 = TREE_OPERAND (node, 0);
1646 tree op1 = TREE_OPERAND (node, 1);
1647 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1649 tree op0size = TYPE_SIZE (nodetype);
1650 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1652 if (!op0size || !op1size
1653 || !operand_equal_p (op0size, op1size, 0))
1655 pp_string (pp, " <");
1656 /* If the size of the type of the operand is not the same
1657 as the size of the MEM_REF expression include the type
1658 of the latter similar to the TDF_GIMPLE output to make
1659 it clear how many bytes of memory are being accessed. */
1660 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1661 pp_string (pp, "> ");
1664 pp_string (pp, "[(");
1665 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1666 pp_right_paren (pp);
1667 dump_generic_node (pp, op0, spc, flags, false);
1668 if (!integer_zerop (op1))
1670 pp_string (pp, " + ");
1671 dump_generic_node (pp, op1, spc, flags, false);
1673 if (TREE_CODE (node) == TARGET_MEM_REF)
1675 tree tmp = TMR_INDEX2 (node);
1676 if (tmp)
1678 pp_string (pp, " + ");
1679 dump_generic_node (pp, tmp, spc, flags, false);
1681 tmp = TMR_INDEX (node);
1682 if (tmp)
1684 pp_string (pp, " + ");
1685 dump_generic_node (pp, tmp, spc, flags, false);
1686 tmp = TMR_STEP (node);
1687 pp_string (pp, " * ");
1688 if (tmp)
1689 dump_generic_node (pp, tmp, spc, flags, false);
1690 else
1691 pp_string (pp, "1");
1694 if ((flags & TDF_ALIAS)
1695 && MR_DEPENDENCE_CLIQUE (node) != 0)
1697 pp_string (pp, " clique ");
1698 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1699 pp_string (pp, " base ");
1700 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1702 pp_right_bracket (pp);
1706 /* Helper function for dump_generic_node. Dump INIT or COND expression for
1707 OpenMP loop non-rectangular iterators. */
1709 void
1710 dump_omp_loop_non_rect_expr (pretty_printer *pp, tree node, int spc,
1711 dump_flags_t flags)
1713 gcc_assert (TREE_CODE (node) == TREE_VEC);
1714 dump_generic_node (pp, TREE_VEC_ELT (node, 0), spc, flags, false);
1715 pp_string (pp, " * ");
1716 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (MULT_EXPR))
1718 pp_left_paren (pp);
1719 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1720 pp_right_paren (pp);
1722 else
1723 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1724 pp_string (pp, " + ");
1725 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (PLUS_EXPR))
1727 pp_left_paren (pp);
1728 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1729 pp_right_paren (pp);
1731 else
1732 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1735 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1736 indent. FLAGS specifies details to show in the dump (see TDF_* in
1737 dumpfile.h). If IS_STMT is true, the object printed is considered
1738 to be a statement and it is terminated by ';' if appropriate. */
1741 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1742 bool is_stmt)
1744 tree type;
1745 tree op0, op1;
1746 const char *str;
1747 bool is_expr;
1748 enum tree_code code;
1750 if (node == NULL_TREE)
1751 return spc;
1753 is_expr = EXPR_P (node);
1755 if (is_stmt && (flags & TDF_STMTADDR))
1757 pp_string (pp, "<&");
1758 pp_scalar (pp, "%p", (void *)node);
1759 pp_string (pp, "> ");
1762 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1763 dump_location (pp, EXPR_LOCATION (node));
1765 code = TREE_CODE (node);
1766 switch (code)
1768 case ERROR_MARK:
1769 pp_string (pp, "<<< error >>>");
1770 break;
1772 case IDENTIFIER_NODE:
1773 pp_tree_identifier (pp, node);
1774 break;
1776 case TREE_LIST:
1777 while (node && node != error_mark_node)
1779 if (TREE_PURPOSE (node))
1781 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1782 pp_space (pp);
1784 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1785 node = TREE_CHAIN (node);
1786 if (node && TREE_CODE (node) == TREE_LIST)
1788 pp_comma (pp);
1789 pp_space (pp);
1792 break;
1794 case TREE_BINFO:
1795 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1796 break;
1798 case TREE_VEC:
1800 size_t i;
1801 if (TREE_VEC_LENGTH (node) > 0)
1803 size_t len = TREE_VEC_LENGTH (node);
1804 for (i = 0; i < len - 1; i++)
1806 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1807 false);
1808 pp_comma (pp);
1809 pp_space (pp);
1811 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1812 flags, false);
1815 break;
1817 case VOID_TYPE:
1818 case INTEGER_TYPE:
1819 case REAL_TYPE:
1820 case FIXED_POINT_TYPE:
1821 case COMPLEX_TYPE:
1822 case VECTOR_TYPE:
1823 case ENUMERAL_TYPE:
1824 case BOOLEAN_TYPE:
1825 case OPAQUE_TYPE:
1827 unsigned int quals = TYPE_QUALS (node);
1828 enum tree_code_class tclass;
1830 if (quals & TYPE_QUAL_ATOMIC)
1831 pp_string (pp, "atomic ");
1832 if (quals & TYPE_QUAL_CONST)
1833 pp_string (pp, "const ");
1834 if (quals & TYPE_QUAL_VOLATILE)
1835 pp_string (pp, "volatile ");
1836 if (quals & TYPE_QUAL_RESTRICT)
1837 pp_string (pp, "restrict ");
1839 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1841 pp_string (pp, "<address-space-");
1842 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1843 pp_string (pp, "> ");
1846 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1848 if (tclass == tcc_declaration)
1850 if (DECL_NAME (node))
1851 dump_decl_name (pp, node, flags);
1852 else
1853 pp_string (pp, "<unnamed type decl>");
1855 else if (tclass == tcc_type)
1857 if (TYPE_NAME (node))
1859 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1860 pp_tree_identifier (pp, TYPE_NAME (node));
1861 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1862 && DECL_NAME (TYPE_NAME (node)))
1863 dump_decl_name (pp, TYPE_NAME (node), flags);
1864 else
1865 pp_string (pp, "<unnamed type>");
1867 else if (TREE_CODE (node) == VECTOR_TYPE)
1869 pp_string (pp, "vector");
1870 pp_left_paren (pp);
1871 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1872 pp_string (pp, ") ");
1873 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1875 else if (TREE_CODE (node) == INTEGER_TYPE)
1877 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1878 pp_string (pp, (TYPE_UNSIGNED (node)
1879 ? "unsigned char"
1880 : "signed char"));
1881 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1882 pp_string (pp, (TYPE_UNSIGNED (node)
1883 ? "unsigned short"
1884 : "signed short"));
1885 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1886 pp_string (pp, (TYPE_UNSIGNED (node)
1887 ? "unsigned int"
1888 : "signed int"));
1889 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1890 pp_string (pp, (TYPE_UNSIGNED (node)
1891 ? "unsigned long"
1892 : "signed long"));
1893 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1894 pp_string (pp, (TYPE_UNSIGNED (node)
1895 ? "unsigned long long"
1896 : "signed long long"));
1897 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1898 && pow2p_hwi (TYPE_PRECISION (node)))
1900 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1901 pp_decimal_int (pp, TYPE_PRECISION (node));
1902 pp_string (pp, "_t");
1904 else
1906 pp_string (pp, (TYPE_UNSIGNED (node)
1907 ? "<unnamed-unsigned:"
1908 : "<unnamed-signed:"));
1909 pp_decimal_int (pp, TYPE_PRECISION (node));
1910 pp_greater (pp);
1913 else if (TREE_CODE (node) == COMPLEX_TYPE)
1915 pp_string (pp, "__complex__ ");
1916 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1918 else if (TREE_CODE (node) == REAL_TYPE)
1920 pp_string (pp, "<float:");
1921 pp_decimal_int (pp, TYPE_PRECISION (node));
1922 pp_greater (pp);
1924 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1926 pp_string (pp, "<fixed-point-");
1927 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1928 pp_decimal_int (pp, TYPE_PRECISION (node));
1929 pp_greater (pp);
1931 else if (TREE_CODE (node) == BOOLEAN_TYPE)
1933 pp_string (pp, (TYPE_UNSIGNED (node)
1934 ? "<unsigned-boolean:"
1935 : "<signed-boolean:"));
1936 pp_decimal_int (pp, TYPE_PRECISION (node));
1937 pp_greater (pp);
1939 else if (TREE_CODE (node) == VOID_TYPE)
1940 pp_string (pp, "void");
1941 else
1942 pp_string (pp, "<unnamed type>");
1944 break;
1947 case POINTER_TYPE:
1948 case REFERENCE_TYPE:
1949 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1951 if (TREE_TYPE (node) == NULL)
1953 pp_string (pp, str);
1954 pp_string (pp, "<null type>");
1956 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1958 tree fnode = TREE_TYPE (node);
1960 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1961 pp_space (pp);
1962 pp_left_paren (pp);
1963 pp_string (pp, str);
1964 if (TYPE_IDENTIFIER (node))
1965 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1966 else if (flags & TDF_NOUID)
1967 pp_string (pp, "<Txxxx>");
1968 else
1970 pp_string (pp, "<T");
1971 pp_scalar (pp, "%x", TYPE_UID (node));
1972 pp_character (pp, '>');
1975 pp_right_paren (pp);
1976 dump_function_declaration (pp, fnode, spc, flags);
1978 else
1980 unsigned int quals = TYPE_QUALS (node);
1982 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1983 pp_space (pp);
1984 pp_string (pp, str);
1986 if (quals & TYPE_QUAL_CONST)
1987 pp_string (pp, " const");
1988 if (quals & TYPE_QUAL_VOLATILE)
1989 pp_string (pp, " volatile");
1990 if (quals & TYPE_QUAL_RESTRICT)
1991 pp_string (pp, " restrict");
1993 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1995 pp_string (pp, " <address-space-");
1996 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1997 pp_greater (pp);
2000 if (TYPE_REF_CAN_ALIAS_ALL (node))
2001 pp_string (pp, " {ref-all}");
2003 break;
2005 case OFFSET_TYPE:
2006 NIY;
2007 break;
2009 case MEM_REF:
2010 case TARGET_MEM_REF:
2011 dump_mem_ref (pp, node, spc, flags);
2012 break;
2014 case ARRAY_TYPE:
2016 unsigned int quals = TYPE_QUALS (node);
2017 tree tmp;
2019 if (quals & TYPE_QUAL_ATOMIC)
2020 pp_string (pp, "atomic ");
2021 if (quals & TYPE_QUAL_CONST)
2022 pp_string (pp, "const ");
2023 if (quals & TYPE_QUAL_VOLATILE)
2024 pp_string (pp, "volatile ");
2026 /* Print the innermost component type. */
2027 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
2028 tmp = TREE_TYPE (tmp))
2030 dump_generic_node (pp, tmp, spc, flags, false);
2032 /* Print the dimensions. */
2033 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
2034 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2035 break;
2038 case RECORD_TYPE:
2039 case UNION_TYPE:
2040 case QUAL_UNION_TYPE:
2042 unsigned int quals = TYPE_QUALS (node);
2044 if (quals & TYPE_QUAL_ATOMIC)
2045 pp_string (pp, "atomic ");
2046 if (quals & TYPE_QUAL_CONST)
2047 pp_string (pp, "const ");
2048 if (quals & TYPE_QUAL_VOLATILE)
2049 pp_string (pp, "volatile ");
2051 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2053 pp_string (pp, "<address-space-");
2054 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2055 pp_string (pp, "> ");
2058 /* Print the name of the structure. */
2059 if (TREE_CODE (node) == RECORD_TYPE)
2060 pp_string (pp, "struct ");
2061 else if (TREE_CODE (node) == UNION_TYPE)
2062 pp_string (pp, "union ");
2064 if (TYPE_NAME (node))
2065 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2066 else if (!(flags & TDF_SLIM))
2067 /* FIXME: If we eliminate the 'else' above and attempt
2068 to show the fields for named types, we may get stuck
2069 following a cycle of pointers to structs. The alleged
2070 self-reference check in print_struct_decl will not detect
2071 cycles involving more than one pointer or struct type. */
2072 print_struct_decl (pp, node, spc, flags);
2073 break;
2076 case LANG_TYPE:
2077 NIY;
2078 break;
2080 case INTEGER_CST:
2081 if (flags & TDF_GIMPLE
2082 && (POINTER_TYPE_P (TREE_TYPE (node))
2083 || (TYPE_PRECISION (TREE_TYPE (node))
2084 < TYPE_PRECISION (integer_type_node))
2085 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
2086 || tree_int_cst_sgn (node) < 0))
2088 pp_string (pp, "_Literal (");
2089 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2090 pp_string (pp, ") ");
2092 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
2093 && ! (flags & TDF_GIMPLE))
2095 /* In the case of a pointer, one may want to divide by the
2096 size of the pointed-to type. Unfortunately, this not
2097 straightforward. The C front-end maps expressions
2099 (int *) 5
2100 int *p; (p + 5)
2102 in such a way that the two INTEGER_CST nodes for "5" have
2103 different values but identical types. In the latter
2104 case, the 5 is multiplied by sizeof (int) in c-common.c
2105 (pointer_int_sum) to convert it to a byte address, and
2106 yet the type of the node is left unchanged. Argh. What
2107 is consistent though is that the number value corresponds
2108 to bytes (UNITS) offset.
2110 NB: Neither of the following divisors can be trivially
2111 used to recover the original literal:
2113 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
2114 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
2115 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
2116 pp_string (pp, "B"); /* pseudo-unit */
2118 else if (tree_fits_shwi_p (node))
2119 pp_wide_integer (pp, tree_to_shwi (node));
2120 else if (tree_fits_uhwi_p (node))
2121 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
2122 else
2124 wide_int val = wi::to_wide (node);
2126 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
2128 pp_minus (pp);
2129 val = -val;
2131 print_hex (val, pp_buffer (pp)->digit_buffer);
2132 pp_string (pp, pp_buffer (pp)->digit_buffer);
2134 if ((flags & TDF_GIMPLE)
2135 && ! (POINTER_TYPE_P (TREE_TYPE (node))
2136 || (TYPE_PRECISION (TREE_TYPE (node))
2137 < TYPE_PRECISION (integer_type_node))
2138 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
2140 if (TYPE_UNSIGNED (TREE_TYPE (node)))
2141 pp_character (pp, 'u');
2142 if (TYPE_PRECISION (TREE_TYPE (node))
2143 == TYPE_PRECISION (unsigned_type_node))
2145 else if (TYPE_PRECISION (TREE_TYPE (node))
2146 == TYPE_PRECISION (long_unsigned_type_node))
2147 pp_character (pp, 'l');
2148 else if (TYPE_PRECISION (TREE_TYPE (node))
2149 == TYPE_PRECISION (long_long_unsigned_type_node))
2150 pp_string (pp, "ll");
2152 if (TREE_OVERFLOW (node))
2153 pp_string (pp, "(OVF)");
2154 break;
2156 case POLY_INT_CST:
2157 pp_string (pp, "POLY_INT_CST [");
2158 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2159 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2161 pp_string (pp, ", ");
2162 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2163 spc, flags, false);
2165 pp_string (pp, "]");
2166 break;
2168 case REAL_CST:
2169 /* Code copied from print_node. */
2171 REAL_VALUE_TYPE d;
2172 if (TREE_OVERFLOW (node))
2173 pp_string (pp, " overflow");
2175 d = TREE_REAL_CST (node);
2176 if (REAL_VALUE_ISINF (d))
2177 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2178 else if (REAL_VALUE_ISNAN (d))
2179 pp_string (pp, " Nan");
2180 else
2182 char string[100];
2183 real_to_decimal (string, &d, sizeof (string), 0, 1);
2184 pp_string (pp, string);
2186 break;
2189 case FIXED_CST:
2191 char string[100];
2192 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2193 pp_string (pp, string);
2194 break;
2197 case COMPLEX_CST:
2198 pp_string (pp, "__complex__ (");
2199 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2200 pp_string (pp, ", ");
2201 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2202 pp_right_paren (pp);
2203 break;
2205 case STRING_CST:
2207 pp_string (pp, "\"");
2208 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2209 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2210 pp_string (pp, "\"");
2211 break;
2214 case VECTOR_CST:
2216 unsigned i;
2217 if (flags & TDF_GIMPLE)
2219 pp_string (pp, "_Literal (");
2220 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2221 pp_string (pp, ") ");
2223 pp_string (pp, "{ ");
2224 unsigned HOST_WIDE_INT nunits;
2225 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2226 nunits = vector_cst_encoded_nelts (node);
2227 for (i = 0; i < nunits; ++i)
2229 if (i != 0)
2230 pp_string (pp, ", ");
2231 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2232 spc, flags, false);
2234 if (!VECTOR_CST_NELTS (node).is_constant ())
2235 pp_string (pp, ", ...");
2236 pp_string (pp, " }");
2238 break;
2240 case FUNCTION_TYPE:
2241 case METHOD_TYPE:
2242 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2243 pp_space (pp);
2244 if (TREE_CODE (node) == METHOD_TYPE)
2246 if (TYPE_METHOD_BASETYPE (node))
2247 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2248 spc, flags, false);
2249 else
2250 pp_string (pp, "<null method basetype>");
2251 pp_colon_colon (pp);
2253 if (TYPE_IDENTIFIER (node))
2254 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2255 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2256 dump_decl_name (pp, TYPE_NAME (node), flags);
2257 else if (flags & TDF_NOUID)
2258 pp_string (pp, "<Txxxx>");
2259 else
2261 pp_string (pp, "<T");
2262 pp_scalar (pp, "%x", TYPE_UID (node));
2263 pp_character (pp, '>');
2265 dump_function_declaration (pp, node, spc, flags);
2266 break;
2268 case FUNCTION_DECL:
2269 case CONST_DECL:
2270 dump_decl_name (pp, node, flags);
2271 break;
2273 case LABEL_DECL:
2274 if (DECL_NAME (node))
2275 dump_decl_name (pp, node, flags);
2276 else if (LABEL_DECL_UID (node) != -1)
2278 if (flags & TDF_GIMPLE)
2280 pp_character (pp, 'L');
2281 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2283 else
2285 pp_string (pp, "<L");
2286 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2287 pp_character (pp, '>');
2290 else
2292 if (flags & TDF_NOUID)
2293 pp_string (pp, "<D.xxxx>");
2294 else
2296 if (flags & TDF_GIMPLE)
2298 pp_character (pp, 'D');
2299 pp_scalar (pp, "%u", DECL_UID (node));
2301 else
2303 pp_string (pp, "<D.");
2304 pp_scalar (pp, "%u", DECL_UID (node));
2305 pp_character (pp, '>');
2309 break;
2311 case TYPE_DECL:
2312 if (DECL_IS_UNDECLARED_BUILTIN (node))
2314 /* Don't print the declaration of built-in types. */
2315 break;
2317 if (DECL_NAME (node))
2318 dump_decl_name (pp, node, flags);
2319 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2321 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2322 ? "union" : "struct "));
2323 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2325 else
2326 pp_string (pp, "<anon>");
2327 break;
2329 case VAR_DECL:
2330 case PARM_DECL:
2331 case FIELD_DECL:
2332 case DEBUG_EXPR_DECL:
2333 case NAMESPACE_DECL:
2334 case NAMELIST_DECL:
2335 dump_decl_name (pp, node, flags);
2336 break;
2338 case RESULT_DECL:
2339 pp_string (pp, "<retval>");
2340 break;
2342 case COMPONENT_REF:
2343 op0 = TREE_OPERAND (node, 0);
2344 str = ".";
2345 if (op0
2346 && (TREE_CODE (op0) == INDIRECT_REF
2347 || (TREE_CODE (op0) == MEM_REF
2348 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2349 && integer_zerop (TREE_OPERAND (op0, 1))
2350 /* Dump the types of INTEGER_CSTs explicitly, for we
2351 can't infer them and MEM_ATTR caching will share
2352 MEM_REFs with differently-typed op0s. */
2353 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2354 /* Released SSA_NAMES have no TREE_TYPE. */
2355 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2356 /* Same pointer types, but ignoring POINTER_TYPE vs.
2357 REFERENCE_TYPE. */
2358 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2359 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2360 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2361 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2362 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2363 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2364 /* Same value types ignoring qualifiers. */
2365 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2366 == TYPE_MAIN_VARIANT
2367 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2368 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2370 op0 = TREE_OPERAND (op0, 0);
2371 str = "->";
2373 if (op_prio (op0) < op_prio (node))
2374 pp_left_paren (pp);
2375 dump_generic_node (pp, op0, spc, flags, false);
2376 if (op_prio (op0) < op_prio (node))
2377 pp_right_paren (pp);
2378 pp_string (pp, str);
2379 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2380 op0 = component_ref_field_offset (node);
2381 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2383 pp_string (pp, "{off: ");
2384 dump_generic_node (pp, op0, spc, flags, false);
2385 pp_right_brace (pp);
2387 break;
2389 case BIT_FIELD_REF:
2390 if (flags & TDF_GIMPLE)
2392 pp_string (pp, "__BIT_FIELD_REF <");
2393 dump_generic_node (pp, TREE_TYPE (node),
2394 spc, flags | TDF_SLIM, false);
2395 if (TYPE_ALIGN (TREE_TYPE (node))
2396 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2398 pp_string (pp, ", ");
2399 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2401 pp_greater (pp);
2402 pp_string (pp, " (");
2403 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2404 flags | TDF_SLIM, false);
2405 pp_string (pp, ", ");
2406 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2407 flags | TDF_SLIM, false);
2408 pp_string (pp, ", ");
2409 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2410 flags | TDF_SLIM, false);
2411 pp_right_paren (pp);
2413 else
2415 pp_string (pp, "BIT_FIELD_REF <");
2416 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2417 pp_string (pp, ", ");
2418 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2419 pp_string (pp, ", ");
2420 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2421 pp_greater (pp);
2423 break;
2425 case BIT_INSERT_EXPR:
2426 pp_string (pp, "BIT_INSERT_EXPR <");
2427 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2428 pp_string (pp, ", ");
2429 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2430 pp_string (pp, ", ");
2431 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2432 pp_string (pp, " (");
2433 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2434 pp_decimal_int (pp,
2435 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2436 else
2437 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2438 spc, flags, false);
2439 pp_string (pp, " bits)>");
2440 break;
2442 case ARRAY_REF:
2443 case ARRAY_RANGE_REF:
2444 op0 = TREE_OPERAND (node, 0);
2445 if (op_prio (op0) < op_prio (node))
2446 pp_left_paren (pp);
2447 dump_generic_node (pp, op0, spc, flags, false);
2448 if (op_prio (op0) < op_prio (node))
2449 pp_right_paren (pp);
2450 pp_left_bracket (pp);
2451 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2452 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2453 pp_string (pp, " ...");
2454 pp_right_bracket (pp);
2456 op0 = array_ref_low_bound (node);
2457 op1 = array_ref_element_size (node);
2459 if (!integer_zerop (op0)
2460 || TREE_OPERAND (node, 2)
2461 || TREE_OPERAND (node, 3))
2463 pp_string (pp, "{lb: ");
2464 dump_generic_node (pp, op0, spc, flags, false);
2465 pp_string (pp, " sz: ");
2466 dump_generic_node (pp, op1, spc, flags, false);
2467 pp_right_brace (pp);
2469 break;
2471 case CONSTRUCTOR:
2473 unsigned HOST_WIDE_INT ix;
2474 tree field, val;
2475 bool is_struct_init = false;
2476 bool is_array_init = false;
2477 widest_int curidx;
2478 if (flags & TDF_GIMPLE)
2480 pp_string (pp, "_Literal (");
2481 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2482 pp_string (pp, ") ");
2484 pp_left_brace (pp);
2485 if (TREE_CLOBBER_P (node))
2486 pp_string (pp, "CLOBBER");
2487 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2488 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2489 is_struct_init = true;
2490 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2491 && TYPE_DOMAIN (TREE_TYPE (node))
2492 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2493 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2494 == INTEGER_CST)
2496 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2497 is_array_init = true;
2498 curidx = wi::to_widest (minv);
2500 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2502 if (field)
2504 if (is_struct_init)
2506 pp_dot (pp);
2507 dump_generic_node (pp, field, spc, flags, false);
2508 pp_equal (pp);
2510 else if (is_array_init
2511 && (TREE_CODE (field) != INTEGER_CST
2512 || curidx != wi::to_widest (field)))
2514 pp_left_bracket (pp);
2515 if (TREE_CODE (field) == RANGE_EXPR)
2517 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2518 flags, false);
2519 pp_string (pp, " ... ");
2520 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2521 flags, false);
2522 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2523 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2525 else
2526 dump_generic_node (pp, field, spc, flags, false);
2527 if (TREE_CODE (field) == INTEGER_CST)
2528 curidx = wi::to_widest (field);
2529 pp_string (pp, "]=");
2532 if (is_array_init)
2533 curidx += 1;
2534 if (val && TREE_CODE (val) == ADDR_EXPR)
2535 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2536 val = TREE_OPERAND (val, 0);
2537 if (val && TREE_CODE (val) == FUNCTION_DECL)
2538 dump_decl_name (pp, val, flags);
2539 else
2540 dump_generic_node (pp, val, spc, flags, false);
2541 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2543 pp_comma (pp);
2544 pp_space (pp);
2547 pp_right_brace (pp);
2549 break;
2551 case COMPOUND_EXPR:
2553 tree *tp;
2554 if (flags & TDF_SLIM)
2556 pp_string (pp, "<COMPOUND_EXPR>");
2557 break;
2560 dump_generic_node (pp, TREE_OPERAND (node, 0),
2561 spc, flags, !(flags & TDF_SLIM));
2562 if (flags & TDF_SLIM)
2563 newline_and_indent (pp, spc);
2564 else
2566 pp_comma (pp);
2567 pp_space (pp);
2570 for (tp = &TREE_OPERAND (node, 1);
2571 TREE_CODE (*tp) == COMPOUND_EXPR;
2572 tp = &TREE_OPERAND (*tp, 1))
2574 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2575 spc, flags, !(flags & TDF_SLIM));
2576 if (flags & TDF_SLIM)
2577 newline_and_indent (pp, spc);
2578 else
2580 pp_comma (pp);
2581 pp_space (pp);
2585 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2587 break;
2589 case STATEMENT_LIST:
2591 tree_stmt_iterator si;
2592 bool first = true;
2594 if (flags & TDF_SLIM)
2596 pp_string (pp, "<STATEMENT_LIST>");
2597 break;
2600 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2602 if (!first)
2603 newline_and_indent (pp, spc);
2604 else
2605 first = false;
2606 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2609 break;
2611 case MODIFY_EXPR:
2612 case INIT_EXPR:
2613 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2614 false);
2615 pp_space (pp);
2616 pp_equal (pp);
2617 pp_space (pp);
2618 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2619 false);
2620 break;
2622 case TARGET_EXPR:
2623 pp_string (pp, "TARGET_EXPR <");
2624 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2625 pp_comma (pp);
2626 pp_space (pp);
2627 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2628 pp_greater (pp);
2629 break;
2631 case DECL_EXPR:
2632 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2633 is_stmt = false;
2634 break;
2636 case COND_EXPR:
2637 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2639 pp_string (pp, "if (");
2640 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2641 pp_right_paren (pp);
2642 /* The lowered cond_exprs should always be printed in full. */
2643 if (COND_EXPR_THEN (node)
2644 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2645 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2646 && COND_EXPR_ELSE (node)
2647 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2648 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2650 pp_space (pp);
2651 dump_generic_node (pp, COND_EXPR_THEN (node),
2652 0, flags, true);
2653 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2655 pp_string (pp, " else ");
2656 dump_generic_node (pp, COND_EXPR_ELSE (node),
2657 0, flags, true);
2660 else if (!(flags & TDF_SLIM))
2662 /* Output COND_EXPR_THEN. */
2663 if (COND_EXPR_THEN (node))
2665 newline_and_indent (pp, spc+2);
2666 pp_left_brace (pp);
2667 newline_and_indent (pp, spc+4);
2668 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2669 flags, true);
2670 newline_and_indent (pp, spc+2);
2671 pp_right_brace (pp);
2674 /* Output COND_EXPR_ELSE. */
2675 if (COND_EXPR_ELSE (node)
2676 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2678 newline_and_indent (pp, spc);
2679 pp_string (pp, "else");
2680 newline_and_indent (pp, spc+2);
2681 pp_left_brace (pp);
2682 newline_and_indent (pp, spc+4);
2683 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2684 flags, true);
2685 newline_and_indent (pp, spc+2);
2686 pp_right_brace (pp);
2689 is_expr = false;
2691 else
2693 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2694 pp_space (pp);
2695 pp_question (pp);
2696 pp_space (pp);
2697 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2698 pp_space (pp);
2699 pp_colon (pp);
2700 pp_space (pp);
2701 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2703 break;
2705 case BIND_EXPR:
2706 pp_left_brace (pp);
2707 if (!(flags & TDF_SLIM))
2709 if (BIND_EXPR_VARS (node))
2711 pp_newline (pp);
2713 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2715 print_declaration (pp, op0, spc+2, flags);
2716 pp_newline (pp);
2720 newline_and_indent (pp, spc+2);
2721 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2722 newline_and_indent (pp, spc);
2723 pp_right_brace (pp);
2725 is_expr = false;
2726 break;
2728 case CALL_EXPR:
2729 if (CALL_EXPR_FN (node) != NULL_TREE)
2730 print_call_name (pp, CALL_EXPR_FN (node), flags);
2731 else
2733 pp_dot (pp);
2734 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2737 /* Print parameters. */
2738 pp_space (pp);
2739 pp_left_paren (pp);
2741 tree arg;
2742 call_expr_arg_iterator iter;
2743 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2745 dump_generic_node (pp, arg, spc, flags, false);
2746 if (more_call_expr_args_p (&iter))
2748 pp_comma (pp);
2749 pp_space (pp);
2753 if (CALL_EXPR_VA_ARG_PACK (node))
2755 if (call_expr_nargs (node) > 0)
2757 pp_comma (pp);
2758 pp_space (pp);
2760 pp_string (pp, "__builtin_va_arg_pack ()");
2762 pp_right_paren (pp);
2764 op1 = CALL_EXPR_STATIC_CHAIN (node);
2765 if (op1)
2767 pp_string (pp, " [static-chain: ");
2768 dump_generic_node (pp, op1, spc, flags, false);
2769 pp_right_bracket (pp);
2772 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2773 pp_string (pp, " [return slot optimization]");
2774 if (CALL_EXPR_TAILCALL (node))
2775 pp_string (pp, " [tail call]");
2776 break;
2778 case WITH_CLEANUP_EXPR:
2779 NIY;
2780 break;
2782 case CLEANUP_POINT_EXPR:
2783 pp_string (pp, "<<cleanup_point ");
2784 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2785 pp_string (pp, ">>");
2786 break;
2788 case PLACEHOLDER_EXPR:
2789 pp_string (pp, "<PLACEHOLDER_EXPR ");
2790 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2791 pp_greater (pp);
2792 break;
2794 /* Binary arithmetic and logic expressions. */
2795 case WIDEN_PLUS_EXPR:
2796 case WIDEN_MINUS_EXPR:
2797 case WIDEN_SUM_EXPR:
2798 case WIDEN_MULT_EXPR:
2799 case MULT_EXPR:
2800 case MULT_HIGHPART_EXPR:
2801 case PLUS_EXPR:
2802 case POINTER_PLUS_EXPR:
2803 case POINTER_DIFF_EXPR:
2804 case MINUS_EXPR:
2805 case TRUNC_DIV_EXPR:
2806 case CEIL_DIV_EXPR:
2807 case FLOOR_DIV_EXPR:
2808 case ROUND_DIV_EXPR:
2809 case TRUNC_MOD_EXPR:
2810 case CEIL_MOD_EXPR:
2811 case FLOOR_MOD_EXPR:
2812 case ROUND_MOD_EXPR:
2813 case RDIV_EXPR:
2814 case EXACT_DIV_EXPR:
2815 case LSHIFT_EXPR:
2816 case RSHIFT_EXPR:
2817 case LROTATE_EXPR:
2818 case RROTATE_EXPR:
2819 case WIDEN_LSHIFT_EXPR:
2820 case BIT_IOR_EXPR:
2821 case BIT_XOR_EXPR:
2822 case BIT_AND_EXPR:
2823 case TRUTH_ANDIF_EXPR:
2824 case TRUTH_ORIF_EXPR:
2825 case TRUTH_AND_EXPR:
2826 case TRUTH_OR_EXPR:
2827 case TRUTH_XOR_EXPR:
2828 case LT_EXPR:
2829 case LE_EXPR:
2830 case GT_EXPR:
2831 case GE_EXPR:
2832 case EQ_EXPR:
2833 case NE_EXPR:
2834 case UNLT_EXPR:
2835 case UNLE_EXPR:
2836 case UNGT_EXPR:
2837 case UNGE_EXPR:
2838 case UNEQ_EXPR:
2839 case LTGT_EXPR:
2840 case ORDERED_EXPR:
2841 case UNORDERED_EXPR:
2843 const char *op = op_symbol (node);
2844 op0 = TREE_OPERAND (node, 0);
2845 op1 = TREE_OPERAND (node, 1);
2847 /* When the operands are expressions with less priority,
2848 keep semantics of the tree representation. */
2849 if (op_prio (op0) <= op_prio (node))
2851 pp_left_paren (pp);
2852 dump_generic_node (pp, op0, spc, flags, false);
2853 pp_right_paren (pp);
2855 else
2856 dump_generic_node (pp, op0, spc, flags, false);
2858 pp_space (pp);
2859 pp_string (pp, op);
2860 pp_space (pp);
2862 /* When the operands are expressions with less priority,
2863 keep semantics of the tree representation. */
2864 if (op_prio (op1) <= op_prio (node))
2866 pp_left_paren (pp);
2867 dump_generic_node (pp, op1, spc, flags, false);
2868 pp_right_paren (pp);
2870 else
2871 dump_generic_node (pp, op1, spc, flags, false);
2873 break;
2875 /* Unary arithmetic and logic expressions. */
2876 case ADDR_EXPR:
2877 if (flags & TDF_GIMPLE_VAL)
2879 pp_string (pp, "_Literal (");
2880 dump_generic_node (pp, TREE_TYPE (node), spc,
2881 flags & ~TDF_GIMPLE_VAL, false);
2882 pp_character (pp, ')');
2884 /* Fallthru. */
2885 case NEGATE_EXPR:
2886 case BIT_NOT_EXPR:
2887 case TRUTH_NOT_EXPR:
2888 case PREDECREMENT_EXPR:
2889 case PREINCREMENT_EXPR:
2890 case INDIRECT_REF:
2891 if (!(flags & TDF_GIMPLE)
2892 && TREE_CODE (node) == ADDR_EXPR
2893 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2894 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2895 /* Do not output '&' for strings and function pointers when not
2896 dumping GIMPLE FE syntax. */
2898 else
2899 pp_string (pp, op_symbol (node));
2901 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2903 pp_left_paren (pp);
2904 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2905 pp_right_paren (pp);
2907 else
2908 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2909 break;
2911 case POSTDECREMENT_EXPR:
2912 case POSTINCREMENT_EXPR:
2913 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2915 pp_left_paren (pp);
2916 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2917 pp_right_paren (pp);
2919 else
2920 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2921 pp_string (pp, op_symbol (node));
2922 break;
2924 case MIN_EXPR:
2925 pp_string (pp, "MIN_EXPR <");
2926 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2927 pp_string (pp, ", ");
2928 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2929 pp_greater (pp);
2930 break;
2932 case MAX_EXPR:
2933 pp_string (pp, "MAX_EXPR <");
2934 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2935 pp_string (pp, ", ");
2936 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2937 pp_greater (pp);
2938 break;
2940 case ABS_EXPR:
2941 pp_string (pp, "ABS_EXPR <");
2942 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2943 pp_greater (pp);
2944 break;
2946 case ABSU_EXPR:
2947 pp_string (pp, "ABSU_EXPR <");
2948 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2949 pp_greater (pp);
2950 break;
2952 case RANGE_EXPR:
2953 NIY;
2954 break;
2956 case ADDR_SPACE_CONVERT_EXPR:
2957 case FIXED_CONVERT_EXPR:
2958 case FIX_TRUNC_EXPR:
2959 case FLOAT_EXPR:
2960 CASE_CONVERT:
2961 type = TREE_TYPE (node);
2962 op0 = TREE_OPERAND (node, 0);
2963 if (type != TREE_TYPE (op0))
2965 pp_left_paren (pp);
2966 dump_generic_node (pp, type, spc, flags, false);
2967 pp_string (pp, ") ");
2969 if (op_prio (op0) < op_prio (node))
2970 pp_left_paren (pp);
2971 dump_generic_node (pp, op0, spc, flags, false);
2972 if (op_prio (op0) < op_prio (node))
2973 pp_right_paren (pp);
2974 break;
2976 case VIEW_CONVERT_EXPR:
2977 if (flags & TDF_GIMPLE)
2978 pp_string (pp, "__VIEW_CONVERT <");
2979 else
2980 pp_string (pp, "VIEW_CONVERT_EXPR<");
2981 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2982 pp_string (pp, ">(");
2983 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2984 pp_right_paren (pp);
2985 break;
2987 case PAREN_EXPR:
2988 pp_string (pp, "((");
2989 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2990 pp_string (pp, "))");
2991 break;
2993 case NON_LVALUE_EXPR:
2994 pp_string (pp, "NON_LVALUE_EXPR <");
2995 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2996 pp_greater (pp);
2997 break;
2999 case SAVE_EXPR:
3000 pp_string (pp, "SAVE_EXPR <");
3001 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3002 pp_greater (pp);
3003 break;
3005 case COMPLEX_EXPR:
3006 pp_string (pp, "COMPLEX_EXPR <");
3007 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3008 pp_string (pp, ", ");
3009 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3010 pp_greater (pp);
3011 break;
3013 case CONJ_EXPR:
3014 pp_string (pp, "CONJ_EXPR <");
3015 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3016 pp_greater (pp);
3017 break;
3019 case REALPART_EXPR:
3020 if (flags & TDF_GIMPLE)
3022 pp_string (pp, "__real ");
3023 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3025 else
3027 pp_string (pp, "REALPART_EXPR <");
3028 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3029 pp_greater (pp);
3031 break;
3033 case IMAGPART_EXPR:
3034 if (flags & TDF_GIMPLE)
3036 pp_string (pp, "__imag ");
3037 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3039 else
3041 pp_string (pp, "IMAGPART_EXPR <");
3042 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3043 pp_greater (pp);
3045 break;
3047 case VA_ARG_EXPR:
3048 pp_string (pp, "VA_ARG_EXPR <");
3049 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3050 pp_greater (pp);
3051 break;
3053 case TRY_FINALLY_EXPR:
3054 case TRY_CATCH_EXPR:
3055 pp_string (pp, "try");
3056 newline_and_indent (pp, spc+2);
3057 pp_left_brace (pp);
3058 newline_and_indent (pp, spc+4);
3059 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
3060 newline_and_indent (pp, spc+2);
3061 pp_right_brace (pp);
3062 newline_and_indent (pp, spc);
3063 if (TREE_CODE (node) == TRY_CATCH_EXPR)
3065 node = TREE_OPERAND (node, 1);
3066 pp_string (pp, "catch");
3068 else
3070 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
3071 node = TREE_OPERAND (node, 1);
3072 pp_string (pp, "finally");
3073 if (TREE_CODE (node) == EH_ELSE_EXPR)
3075 newline_and_indent (pp, spc+2);
3076 pp_left_brace (pp);
3077 newline_and_indent (pp, spc+4);
3078 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
3079 flags, true);
3080 newline_and_indent (pp, spc+2);
3081 pp_right_brace (pp);
3082 newline_and_indent (pp, spc);
3083 node = TREE_OPERAND (node, 1);
3084 pp_string (pp, "else");
3087 newline_and_indent (pp, spc+2);
3088 pp_left_brace (pp);
3089 newline_and_indent (pp, spc+4);
3090 dump_generic_node (pp, node, spc+4, flags, true);
3091 newline_and_indent (pp, spc+2);
3092 pp_right_brace (pp);
3093 is_expr = false;
3094 break;
3096 case CATCH_EXPR:
3097 pp_string (pp, "catch (");
3098 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
3099 pp_right_paren (pp);
3100 newline_and_indent (pp, spc+2);
3101 pp_left_brace (pp);
3102 newline_and_indent (pp, spc+4);
3103 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
3104 newline_and_indent (pp, spc+2);
3105 pp_right_brace (pp);
3106 is_expr = false;
3107 break;
3109 case EH_FILTER_EXPR:
3110 pp_string (pp, "<<<eh_filter (");
3111 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
3112 pp_string (pp, ")>>>");
3113 newline_and_indent (pp, spc+2);
3114 pp_left_brace (pp);
3115 newline_and_indent (pp, spc+4);
3116 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
3117 newline_and_indent (pp, spc+2);
3118 pp_right_brace (pp);
3119 is_expr = false;
3120 break;
3122 case LABEL_EXPR:
3123 op0 = TREE_OPERAND (node, 0);
3124 /* If this is for break or continue, don't bother printing it. */
3125 if (DECL_NAME (op0))
3127 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3128 if (strcmp (name, "break") == 0
3129 || strcmp (name, "continue") == 0)
3130 break;
3132 dump_generic_node (pp, op0, spc, flags, false);
3133 pp_colon (pp);
3134 if (DECL_NONLOCAL (op0))
3135 pp_string (pp, " [non-local]");
3136 break;
3138 case LOOP_EXPR:
3139 pp_string (pp, "while (1)");
3140 if (!(flags & TDF_SLIM))
3142 newline_and_indent (pp, spc+2);
3143 pp_left_brace (pp);
3144 newline_and_indent (pp, spc+4);
3145 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
3146 newline_and_indent (pp, spc+2);
3147 pp_right_brace (pp);
3149 is_expr = false;
3150 break;
3152 case PREDICT_EXPR:
3153 pp_string (pp, "// predicted ");
3154 if (PREDICT_EXPR_OUTCOME (node))
3155 pp_string (pp, "likely by ");
3156 else
3157 pp_string (pp, "unlikely by ");
3158 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
3159 pp_string (pp, " predictor.");
3160 break;
3162 case ANNOTATE_EXPR:
3163 pp_string (pp, "ANNOTATE_EXPR <");
3164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3165 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
3167 case annot_expr_ivdep_kind:
3168 pp_string (pp, ", ivdep");
3169 break;
3170 case annot_expr_unroll_kind:
3172 pp_string (pp, ", unroll ");
3173 pp_decimal_int (pp,
3174 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
3175 break;
3177 case annot_expr_no_vector_kind:
3178 pp_string (pp, ", no-vector");
3179 break;
3180 case annot_expr_vector_kind:
3181 pp_string (pp, ", vector");
3182 break;
3183 case annot_expr_parallel_kind:
3184 pp_string (pp, ", parallel");
3185 break;
3186 default:
3187 gcc_unreachable ();
3189 pp_greater (pp);
3190 break;
3192 case RETURN_EXPR:
3193 pp_string (pp, "return");
3194 op0 = TREE_OPERAND (node, 0);
3195 if (op0)
3197 pp_space (pp);
3198 if (TREE_CODE (op0) == MODIFY_EXPR)
3199 dump_generic_node (pp, TREE_OPERAND (op0, 1),
3200 spc, flags, false);
3201 else
3202 dump_generic_node (pp, op0, spc, flags, false);
3204 break;
3206 case EXIT_EXPR:
3207 pp_string (pp, "if (");
3208 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3209 pp_string (pp, ") break");
3210 break;
3212 case SWITCH_EXPR:
3213 pp_string (pp, "switch (");
3214 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3215 pp_right_paren (pp);
3216 if (!(flags & TDF_SLIM))
3218 newline_and_indent (pp, spc+2);
3219 pp_left_brace (pp);
3220 if (SWITCH_BODY (node))
3222 newline_and_indent (pp, spc+4);
3223 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3224 true);
3226 newline_and_indent (pp, spc+2);
3227 pp_right_brace (pp);
3229 is_expr = false;
3230 break;
3232 case GOTO_EXPR:
3233 op0 = GOTO_DESTINATION (node);
3234 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3236 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3237 if (strcmp (name, "break") == 0
3238 || strcmp (name, "continue") == 0)
3240 pp_string (pp, name);
3241 break;
3244 pp_string (pp, "goto ");
3245 dump_generic_node (pp, op0, spc, flags, false);
3246 break;
3248 case ASM_EXPR:
3249 pp_string (pp, "__asm__");
3250 if (ASM_VOLATILE_P (node))
3251 pp_string (pp, " __volatile__");
3252 pp_left_paren (pp);
3253 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3254 pp_colon (pp);
3255 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3256 pp_colon (pp);
3257 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3258 if (ASM_CLOBBERS (node))
3260 pp_colon (pp);
3261 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3263 pp_right_paren (pp);
3264 break;
3266 case CASE_LABEL_EXPR:
3267 if (CASE_LOW (node) && CASE_HIGH (node))
3269 pp_string (pp, "case ");
3270 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3271 pp_string (pp, " ... ");
3272 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3274 else if (CASE_LOW (node))
3276 pp_string (pp, "case ");
3277 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3279 else
3280 pp_string (pp, "default");
3281 pp_colon (pp);
3282 break;
3284 case OBJ_TYPE_REF:
3285 pp_string (pp, "OBJ_TYPE_REF(");
3286 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3287 pp_semicolon (pp);
3288 /* We omit the class type for -fcompare-debug because we may
3289 drop TYPE_BINFO early depending on debug info, and then
3290 virtual_method_call_p would return false, whereas when
3291 TYPE_BINFO is preserved it may still return true and then
3292 we'd print the class type. Compare tree and rtl dumps for
3293 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3294 for example, at occurrences of OBJ_TYPE_REF. */
3295 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3296 && virtual_method_call_p (node, true))
3298 pp_string (pp, "(");
3299 dump_generic_node (pp, obj_type_ref_class (node, true),
3300 spc, flags, false);
3301 pp_string (pp, ")");
3303 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3304 pp_arrow (pp);
3305 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3306 pp_right_paren (pp);
3307 break;
3309 case SSA_NAME:
3310 if (SSA_NAME_IDENTIFIER (node))
3312 if ((flags & TDF_NOUID)
3313 && SSA_NAME_VAR (node)
3314 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3315 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3316 else if (! (flags & TDF_GIMPLE)
3317 || SSA_NAME_VAR (node))
3318 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3319 spc, flags, false);
3321 pp_underscore (pp);
3322 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3323 if (SSA_NAME_IS_DEFAULT_DEF (node))
3324 pp_string (pp, "(D)");
3325 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3326 pp_string (pp, "(ab)");
3327 break;
3329 case WITH_SIZE_EXPR:
3330 pp_string (pp, "WITH_SIZE_EXPR <");
3331 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3332 pp_string (pp, ", ");
3333 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3334 pp_greater (pp);
3335 break;
3337 case ASSERT_EXPR:
3338 pp_string (pp, "ASSERT_EXPR <");
3339 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3340 pp_string (pp, ", ");
3341 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3342 pp_greater (pp);
3343 break;
3345 case SCEV_KNOWN:
3346 pp_string (pp, "scev_known");
3347 break;
3349 case SCEV_NOT_KNOWN:
3350 pp_string (pp, "scev_not_known");
3351 break;
3353 case POLYNOMIAL_CHREC:
3354 pp_left_brace (pp);
3355 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3356 pp_string (pp, ", +, ");
3357 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3358 pp_string (pp, "}_");
3359 pp_scalar (pp, "%u", CHREC_VARIABLE (node));
3360 is_stmt = false;
3361 break;
3363 case REALIGN_LOAD_EXPR:
3364 pp_string (pp, "REALIGN_LOAD <");
3365 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3366 pp_string (pp, ", ");
3367 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3368 pp_string (pp, ", ");
3369 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3370 pp_greater (pp);
3371 break;
3373 case VEC_COND_EXPR:
3374 pp_string (pp, " VEC_COND_EXPR < ");
3375 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3376 pp_string (pp, " , ");
3377 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3378 pp_string (pp, " , ");
3379 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3380 pp_string (pp, " > ");
3381 break;
3383 case VEC_PERM_EXPR:
3384 pp_string (pp, " VEC_PERM_EXPR < ");
3385 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3386 pp_string (pp, " , ");
3387 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3388 pp_string (pp, " , ");
3389 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3390 pp_string (pp, " > ");
3391 break;
3393 case DOT_PROD_EXPR:
3394 pp_string (pp, " DOT_PROD_EXPR < ");
3395 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3396 pp_string (pp, ", ");
3397 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3398 pp_string (pp, ", ");
3399 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3400 pp_string (pp, " > ");
3401 break;
3403 case WIDEN_MULT_PLUS_EXPR:
3404 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3405 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3406 pp_string (pp, ", ");
3407 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3408 pp_string (pp, ", ");
3409 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3410 pp_string (pp, " > ");
3411 break;
3413 case WIDEN_MULT_MINUS_EXPR:
3414 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3415 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3416 pp_string (pp, ", ");
3417 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3418 pp_string (pp, ", ");
3419 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3420 pp_string (pp, " > ");
3421 break;
3423 case OACC_PARALLEL:
3424 pp_string (pp, "#pragma acc parallel");
3425 goto dump_omp_clauses_body;
3427 case OACC_KERNELS:
3428 pp_string (pp, "#pragma acc kernels");
3429 goto dump_omp_clauses_body;
3431 case OACC_SERIAL:
3432 pp_string (pp, "#pragma acc serial");
3433 goto dump_omp_clauses_body;
3435 case OACC_DATA:
3436 pp_string (pp, "#pragma acc data");
3437 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3438 goto dump_omp_body;
3440 case OACC_HOST_DATA:
3441 pp_string (pp, "#pragma acc host_data");
3442 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3443 goto dump_omp_body;
3445 case OACC_DECLARE:
3446 pp_string (pp, "#pragma acc declare");
3447 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3448 break;
3450 case OACC_UPDATE:
3451 pp_string (pp, "#pragma acc update");
3452 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3453 break;
3455 case OACC_ENTER_DATA:
3456 pp_string (pp, "#pragma acc enter data");
3457 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3458 break;
3460 case OACC_EXIT_DATA:
3461 pp_string (pp, "#pragma acc exit data");
3462 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3463 break;
3465 case OACC_CACHE:
3466 pp_string (pp, "#pragma acc cache");
3467 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3468 break;
3470 case OMP_PARALLEL:
3471 pp_string (pp, "#pragma omp parallel");
3472 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3473 goto dump_omp_body;
3475 dump_omp_clauses_body:
3476 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3477 goto dump_omp_body;
3479 dump_omp_body:
3480 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3482 newline_and_indent (pp, spc + 2);
3483 pp_left_brace (pp);
3484 newline_and_indent (pp, spc + 4);
3485 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3486 newline_and_indent (pp, spc + 2);
3487 pp_right_brace (pp);
3489 is_expr = false;
3490 break;
3492 case OMP_TASK:
3493 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3494 : "#pragma omp taskwait");
3495 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3496 goto dump_omp_body;
3498 case OMP_FOR:
3499 pp_string (pp, "#pragma omp for");
3500 goto dump_omp_loop;
3502 case OMP_SIMD:
3503 pp_string (pp, "#pragma omp simd");
3504 goto dump_omp_loop;
3506 case OMP_DISTRIBUTE:
3507 pp_string (pp, "#pragma omp distribute");
3508 goto dump_omp_loop;
3510 case OMP_TASKLOOP:
3511 pp_string (pp, "#pragma omp taskloop");
3512 goto dump_omp_loop;
3514 case OMP_LOOP:
3515 pp_string (pp, "#pragma omp loop");
3516 goto dump_omp_loop;
3518 case OACC_LOOP:
3519 pp_string (pp, "#pragma acc loop");
3520 goto dump_omp_loop;
3522 case OMP_TEAMS:
3523 pp_string (pp, "#pragma omp teams");
3524 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3525 goto dump_omp_body;
3527 case OMP_TARGET_DATA:
3528 pp_string (pp, "#pragma omp target data");
3529 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3530 goto dump_omp_body;
3532 case OMP_TARGET_ENTER_DATA:
3533 pp_string (pp, "#pragma omp target enter data");
3534 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3535 is_expr = false;
3536 break;
3538 case OMP_TARGET_EXIT_DATA:
3539 pp_string (pp, "#pragma omp target exit data");
3540 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3541 is_expr = false;
3542 break;
3544 case OMP_TARGET:
3545 pp_string (pp, "#pragma omp target");
3546 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3547 goto dump_omp_body;
3549 case OMP_TARGET_UPDATE:
3550 pp_string (pp, "#pragma omp target update");
3551 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3552 is_expr = false;
3553 break;
3555 dump_omp_loop:
3556 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3557 if (!(flags & TDF_SLIM))
3559 int i;
3561 if (OMP_FOR_PRE_BODY (node))
3563 newline_and_indent (pp, spc + 2);
3564 pp_left_brace (pp);
3565 spc += 4;
3566 newline_and_indent (pp, spc);
3567 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3568 spc, flags, false);
3570 if (OMP_FOR_INIT (node))
3572 spc -= 2;
3573 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3575 spc += 2;
3576 newline_and_indent (pp, spc);
3577 pp_string (pp, "for (");
3578 tree init = TREE_VEC_ELT (OMP_FOR_INIT (node), i);
3579 if (TREE_CODE (init) != MODIFY_EXPR
3580 || TREE_CODE (TREE_OPERAND (init, 1)) != TREE_VEC)
3581 dump_generic_node (pp, init, spc, flags, false);
3582 else
3584 dump_generic_node (pp, TREE_OPERAND (init, 0),
3585 spc, flags, false);
3586 pp_string (pp, " = ");
3587 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (init, 1),
3588 spc, flags);
3590 pp_string (pp, "; ");
3591 tree cond = TREE_VEC_ELT (OMP_FOR_COND (node), i);
3592 if (!COMPARISON_CLASS_P (cond)
3593 || TREE_CODE (TREE_OPERAND (cond, 1)) != TREE_VEC)
3594 dump_generic_node (pp, cond, spc, flags, false);
3595 else
3597 dump_generic_node (pp, TREE_OPERAND (cond, 0),
3598 spc, flags, false);
3599 const char *op = op_symbol (cond);
3600 pp_space (pp);
3601 pp_string (pp, op);
3602 pp_space (pp);
3603 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (cond, 1),
3604 spc, flags);
3606 pp_string (pp, "; ");
3607 dump_generic_node (pp,
3608 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3609 spc, flags, false);
3610 pp_right_paren (pp);
3613 if (OMP_FOR_BODY (node))
3615 newline_and_indent (pp, spc + 2);
3616 pp_left_brace (pp);
3617 newline_and_indent (pp, spc + 4);
3618 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3619 false);
3620 newline_and_indent (pp, spc + 2);
3621 pp_right_brace (pp);
3623 if (OMP_FOR_INIT (node))
3624 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3625 if (OMP_FOR_PRE_BODY (node))
3627 spc -= 4;
3628 newline_and_indent (pp, spc + 2);
3629 pp_right_brace (pp);
3632 is_expr = false;
3633 break;
3635 case OMP_SECTIONS:
3636 pp_string (pp, "#pragma omp sections");
3637 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3638 goto dump_omp_body;
3640 case OMP_SECTION:
3641 pp_string (pp, "#pragma omp section");
3642 goto dump_omp_body;
3644 case OMP_SCAN:
3645 if (OMP_SCAN_CLAUSES (node))
3647 pp_string (pp, "#pragma omp scan");
3648 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3650 goto dump_omp_body;
3652 case OMP_MASTER:
3653 pp_string (pp, "#pragma omp master");
3654 goto dump_omp_body;
3656 case OMP_MASKED:
3657 pp_string (pp, "#pragma omp masked");
3658 dump_omp_clauses (pp, OMP_MASKED_CLAUSES (node), spc, flags);
3659 goto dump_omp_body;
3661 case OMP_TASKGROUP:
3662 pp_string (pp, "#pragma omp taskgroup");
3663 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3664 goto dump_omp_body;
3666 case OMP_ORDERED:
3667 pp_string (pp, "#pragma omp ordered");
3668 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3669 goto dump_omp_body;
3671 case OMP_CRITICAL:
3672 pp_string (pp, "#pragma omp critical");
3673 if (OMP_CRITICAL_NAME (node))
3675 pp_space (pp);
3676 pp_left_paren (pp);
3677 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3678 flags, false);
3679 pp_right_paren (pp);
3681 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3682 goto dump_omp_body;
3684 case OMP_ATOMIC:
3685 pp_string (pp, "#pragma omp atomic");
3686 if (OMP_ATOMIC_WEAK (node))
3687 pp_string (pp, " weak");
3688 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3689 newline_and_indent (pp, spc + 2);
3690 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3691 pp_space (pp);
3692 pp_equal (pp);
3693 pp_space (pp);
3694 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3695 break;
3697 case OMP_ATOMIC_READ:
3698 pp_string (pp, "#pragma omp atomic read");
3699 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3700 newline_and_indent (pp, spc + 2);
3701 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3702 pp_space (pp);
3703 break;
3705 case OMP_ATOMIC_CAPTURE_OLD:
3706 case OMP_ATOMIC_CAPTURE_NEW:
3707 pp_string (pp, "#pragma omp atomic capture");
3708 if (OMP_ATOMIC_WEAK (node))
3709 pp_string (pp, " weak");
3710 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3711 newline_and_indent (pp, spc + 2);
3712 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3713 pp_space (pp);
3714 pp_equal (pp);
3715 pp_space (pp);
3716 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3717 break;
3719 case OMP_SINGLE:
3720 pp_string (pp, "#pragma omp single");
3721 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3722 goto dump_omp_body;
3724 case OMP_SCOPE:
3725 pp_string (pp, "#pragma omp scope");
3726 dump_omp_clauses (pp, OMP_SCOPE_CLAUSES (node), spc, flags);
3727 goto dump_omp_body;
3729 case OMP_CLAUSE:
3730 /* If we come here, we're dumping something that's not an OMP construct,
3731 for example, OMP clauses attached to a function's '__attribute__'.
3732 Dump the whole OMP clause chain. */
3733 dump_omp_clauses (pp, node, spc, flags, false);
3734 is_expr = false;
3735 break;
3737 case TRANSACTION_EXPR:
3738 if (TRANSACTION_EXPR_OUTER (node))
3739 pp_string (pp, "__transaction_atomic [[outer]]");
3740 else if (TRANSACTION_EXPR_RELAXED (node))
3741 pp_string (pp, "__transaction_relaxed");
3742 else
3743 pp_string (pp, "__transaction_atomic");
3744 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3746 newline_and_indent (pp, spc);
3747 pp_left_brace (pp);
3748 newline_and_indent (pp, spc + 2);
3749 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3750 spc + 2, flags, false);
3751 newline_and_indent (pp, spc);
3752 pp_right_brace (pp);
3754 is_expr = false;
3755 break;
3757 case VEC_SERIES_EXPR:
3758 case VEC_WIDEN_MULT_HI_EXPR:
3759 case VEC_WIDEN_MULT_LO_EXPR:
3760 case VEC_WIDEN_PLUS_HI_EXPR:
3761 case VEC_WIDEN_PLUS_LO_EXPR:
3762 case VEC_WIDEN_MINUS_HI_EXPR:
3763 case VEC_WIDEN_MINUS_LO_EXPR:
3764 case VEC_WIDEN_MULT_EVEN_EXPR:
3765 case VEC_WIDEN_MULT_ODD_EXPR:
3766 case VEC_WIDEN_LSHIFT_HI_EXPR:
3767 case VEC_WIDEN_LSHIFT_LO_EXPR:
3768 pp_space (pp);
3769 for (str = get_tree_code_name (code); *str; str++)
3770 pp_character (pp, TOUPPER (*str));
3771 pp_string (pp, " < ");
3772 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3773 pp_string (pp, ", ");
3774 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3775 pp_string (pp, " > ");
3776 break;
3778 case VEC_DUPLICATE_EXPR:
3779 pp_space (pp);
3780 for (str = get_tree_code_name (code); *str; str++)
3781 pp_character (pp, TOUPPER (*str));
3782 pp_string (pp, " < ");
3783 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3784 pp_string (pp, " > ");
3785 break;
3787 case VEC_UNPACK_HI_EXPR:
3788 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3789 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3790 pp_string (pp, " > ");
3791 break;
3793 case VEC_UNPACK_LO_EXPR:
3794 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3795 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3796 pp_string (pp, " > ");
3797 break;
3799 case VEC_UNPACK_FLOAT_HI_EXPR:
3800 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3801 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3802 pp_string (pp, " > ");
3803 break;
3805 case VEC_UNPACK_FLOAT_LO_EXPR:
3806 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3807 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3808 pp_string (pp, " > ");
3809 break;
3811 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3812 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3813 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3814 pp_string (pp, " > ");
3815 break;
3817 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3818 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3819 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3820 pp_string (pp, " > ");
3821 break;
3823 case VEC_PACK_TRUNC_EXPR:
3824 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3825 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3826 pp_string (pp, ", ");
3827 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3828 pp_string (pp, " > ");
3829 break;
3831 case VEC_PACK_SAT_EXPR:
3832 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3833 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3834 pp_string (pp, ", ");
3835 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3836 pp_string (pp, " > ");
3837 break;
3839 case VEC_PACK_FIX_TRUNC_EXPR:
3840 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3841 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3842 pp_string (pp, ", ");
3843 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3844 pp_string (pp, " > ");
3845 break;
3847 case VEC_PACK_FLOAT_EXPR:
3848 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3849 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3850 pp_string (pp, ", ");
3851 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3852 pp_string (pp, " > ");
3853 break;
3855 case BLOCK:
3856 dump_block_node (pp, node, spc, flags);
3857 break;
3859 case DEBUG_BEGIN_STMT:
3860 pp_string (pp, "# DEBUG BEGIN STMT");
3861 break;
3863 default:
3864 NIY;
3867 if (is_stmt && is_expr)
3868 pp_semicolon (pp);
3870 return spc;
3873 /* Print the declaration of a variable. */
3875 void
3876 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3878 INDENT (spc);
3880 if (TREE_CODE(t) == NAMELIST_DECL)
3882 pp_string(pp, "namelist ");
3883 dump_decl_name (pp, t, flags);
3884 pp_semicolon (pp);
3885 return;
3888 if (TREE_CODE (t) == TYPE_DECL)
3889 pp_string (pp, "typedef ");
3891 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3892 pp_string (pp, "register ");
3894 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3895 pp_string (pp, "extern ");
3896 else if (TREE_STATIC (t))
3897 pp_string (pp, "static ");
3899 /* Print the type and name. */
3900 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3902 tree tmp;
3904 /* Print array's type. */
3905 tmp = TREE_TYPE (t);
3906 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3907 tmp = TREE_TYPE (tmp);
3908 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3910 /* Print variable's name. */
3911 pp_space (pp);
3912 dump_generic_node (pp, t, spc, flags, false);
3914 /* Print the dimensions. */
3915 tmp = TREE_TYPE (t);
3916 while (TREE_CODE (tmp) == ARRAY_TYPE)
3918 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3919 tmp = TREE_TYPE (tmp);
3922 else if (TREE_CODE (t) == FUNCTION_DECL)
3924 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3925 pp_space (pp);
3926 dump_decl_name (pp, t, flags);
3927 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3929 else
3931 /* Print type declaration. */
3932 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3934 /* Print variable's name. */
3935 pp_space (pp);
3936 dump_generic_node (pp, t, spc, flags, false);
3939 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3941 pp_string (pp, " __asm__ ");
3942 pp_left_paren (pp);
3943 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3944 pp_right_paren (pp);
3947 /* The initial value of a function serves to determine whether the function
3948 is declared or defined. So the following does not apply to function
3949 nodes. */
3950 if (TREE_CODE (t) != FUNCTION_DECL)
3952 /* Print the initial value. */
3953 if (DECL_INITIAL (t))
3955 pp_space (pp);
3956 pp_equal (pp);
3957 pp_space (pp);
3958 if (!(flags & TDF_SLIM))
3959 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3960 else
3961 pp_string (pp, "<<< omitted >>>");
3965 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3967 pp_string (pp, " [value-expr: ");
3968 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3969 pp_right_bracket (pp);
3972 pp_semicolon (pp);
3976 /* Prints a structure: name, fields, and methods.
3977 FIXME: Still incomplete. */
3979 static void
3980 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3981 dump_flags_t flags)
3983 /* Print the name of the structure. */
3984 if (TYPE_NAME (node))
3986 INDENT (spc);
3987 if (TREE_CODE (node) == RECORD_TYPE)
3988 pp_string (pp, "struct ");
3989 else if ((TREE_CODE (node) == UNION_TYPE
3990 || TREE_CODE (node) == QUAL_UNION_TYPE))
3991 pp_string (pp, "union ");
3993 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3996 /* Print the contents of the structure. */
3997 pp_newline (pp);
3998 INDENT (spc);
3999 pp_left_brace (pp);
4000 pp_newline (pp);
4002 /* Print the fields of the structure. */
4004 tree tmp;
4005 tmp = TYPE_FIELDS (node);
4006 while (tmp)
4008 /* Avoid to print recursively the structure. */
4009 /* FIXME : Not implemented correctly...,
4010 what about the case when we have a cycle in the contain graph? ...
4011 Maybe this could be solved by looking at the scope in which the
4012 structure was declared. */
4013 if (TREE_TYPE (tmp) != node
4014 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
4015 || TREE_TYPE (TREE_TYPE (tmp)) != node))
4017 print_declaration (pp, tmp, spc+2, flags);
4018 pp_newline (pp);
4020 tmp = DECL_CHAIN (tmp);
4023 INDENT (spc);
4024 pp_right_brace (pp);
4027 /* Return the priority of the operator CODE.
4029 From lowest to highest precedence with either left-to-right (L-R)
4030 or right-to-left (R-L) associativity]:
4032 1 [L-R] ,
4033 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
4034 3 [R-L] ?:
4035 4 [L-R] ||
4036 5 [L-R] &&
4037 6 [L-R] |
4038 7 [L-R] ^
4039 8 [L-R] &
4040 9 [L-R] == !=
4041 10 [L-R] < <= > >=
4042 11 [L-R] << >>
4043 12 [L-R] + -
4044 13 [L-R] * / %
4045 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
4046 15 [L-R] fn() [] -> .
4048 unary +, - and * have higher precedence than the corresponding binary
4049 operators. */
4052 op_code_prio (enum tree_code code)
4054 switch (code)
4056 case TREE_LIST:
4057 case COMPOUND_EXPR:
4058 case BIND_EXPR:
4059 return 1;
4061 case MODIFY_EXPR:
4062 case INIT_EXPR:
4063 return 2;
4065 case COND_EXPR:
4066 return 3;
4068 case TRUTH_OR_EXPR:
4069 case TRUTH_ORIF_EXPR:
4070 return 4;
4072 case TRUTH_AND_EXPR:
4073 case TRUTH_ANDIF_EXPR:
4074 return 5;
4076 case BIT_IOR_EXPR:
4077 return 6;
4079 case BIT_XOR_EXPR:
4080 case TRUTH_XOR_EXPR:
4081 return 7;
4083 case BIT_AND_EXPR:
4084 return 8;
4086 case EQ_EXPR:
4087 case NE_EXPR:
4088 return 9;
4090 case UNLT_EXPR:
4091 case UNLE_EXPR:
4092 case UNGT_EXPR:
4093 case UNGE_EXPR:
4094 case UNEQ_EXPR:
4095 case LTGT_EXPR:
4096 case ORDERED_EXPR:
4097 case UNORDERED_EXPR:
4098 case LT_EXPR:
4099 case LE_EXPR:
4100 case GT_EXPR:
4101 case GE_EXPR:
4102 return 10;
4104 case LSHIFT_EXPR:
4105 case RSHIFT_EXPR:
4106 case LROTATE_EXPR:
4107 case RROTATE_EXPR:
4108 case VEC_WIDEN_LSHIFT_HI_EXPR:
4109 case VEC_WIDEN_LSHIFT_LO_EXPR:
4110 case WIDEN_LSHIFT_EXPR:
4111 return 11;
4113 case WIDEN_SUM_EXPR:
4114 case PLUS_EXPR:
4115 case POINTER_PLUS_EXPR:
4116 case POINTER_DIFF_EXPR:
4117 case MINUS_EXPR:
4118 return 12;
4120 case VEC_WIDEN_MULT_HI_EXPR:
4121 case VEC_WIDEN_MULT_LO_EXPR:
4122 case WIDEN_MULT_EXPR:
4123 case DOT_PROD_EXPR:
4124 case WIDEN_MULT_PLUS_EXPR:
4125 case WIDEN_MULT_MINUS_EXPR:
4126 case MULT_EXPR:
4127 case MULT_HIGHPART_EXPR:
4128 case TRUNC_DIV_EXPR:
4129 case CEIL_DIV_EXPR:
4130 case FLOOR_DIV_EXPR:
4131 case ROUND_DIV_EXPR:
4132 case RDIV_EXPR:
4133 case EXACT_DIV_EXPR:
4134 case TRUNC_MOD_EXPR:
4135 case CEIL_MOD_EXPR:
4136 case FLOOR_MOD_EXPR:
4137 case ROUND_MOD_EXPR:
4138 return 13;
4140 case TRUTH_NOT_EXPR:
4141 case BIT_NOT_EXPR:
4142 case POSTINCREMENT_EXPR:
4143 case POSTDECREMENT_EXPR:
4144 case PREINCREMENT_EXPR:
4145 case PREDECREMENT_EXPR:
4146 case NEGATE_EXPR:
4147 case INDIRECT_REF:
4148 case ADDR_EXPR:
4149 case FLOAT_EXPR:
4150 CASE_CONVERT:
4151 case FIX_TRUNC_EXPR:
4152 case TARGET_EXPR:
4153 return 14;
4155 case CALL_EXPR:
4156 case ARRAY_REF:
4157 case ARRAY_RANGE_REF:
4158 case COMPONENT_REF:
4159 return 15;
4161 /* Special expressions. */
4162 case MIN_EXPR:
4163 case MAX_EXPR:
4164 case ABS_EXPR:
4165 case REALPART_EXPR:
4166 case IMAGPART_EXPR:
4167 case VEC_UNPACK_HI_EXPR:
4168 case VEC_UNPACK_LO_EXPR:
4169 case VEC_UNPACK_FLOAT_HI_EXPR:
4170 case VEC_UNPACK_FLOAT_LO_EXPR:
4171 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
4172 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
4173 case VEC_PACK_TRUNC_EXPR:
4174 case VEC_PACK_SAT_EXPR:
4175 return 16;
4177 default:
4178 /* Return an arbitrarily high precedence to avoid surrounding single
4179 VAR_DECLs in ()s. */
4180 return 9999;
4184 /* Return the priority of the operator OP. */
4187 op_prio (const_tree op)
4189 enum tree_code code;
4191 if (op == NULL)
4192 return 9999;
4194 code = TREE_CODE (op);
4195 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
4196 return op_prio (TREE_OPERAND (op, 0));
4198 return op_code_prio (code);
4201 /* Return the symbol associated with operator CODE. */
4203 const char *
4204 op_symbol_code (enum tree_code code)
4206 switch (code)
4208 case MODIFY_EXPR:
4209 return "=";
4211 case TRUTH_OR_EXPR:
4212 case TRUTH_ORIF_EXPR:
4213 return "||";
4215 case TRUTH_AND_EXPR:
4216 case TRUTH_ANDIF_EXPR:
4217 return "&&";
4219 case BIT_IOR_EXPR:
4220 return "|";
4222 case TRUTH_XOR_EXPR:
4223 case BIT_XOR_EXPR:
4224 return "^";
4226 case ADDR_EXPR:
4227 case BIT_AND_EXPR:
4228 return "&";
4230 case ORDERED_EXPR:
4231 return "ord";
4232 case UNORDERED_EXPR:
4233 return "unord";
4235 case EQ_EXPR:
4236 return "==";
4237 case UNEQ_EXPR:
4238 return "u==";
4240 case NE_EXPR:
4241 return "!=";
4243 case LT_EXPR:
4244 return "<";
4245 case UNLT_EXPR:
4246 return "u<";
4248 case LE_EXPR:
4249 return "<=";
4250 case UNLE_EXPR:
4251 return "u<=";
4253 case GT_EXPR:
4254 return ">";
4255 case UNGT_EXPR:
4256 return "u>";
4258 case GE_EXPR:
4259 return ">=";
4260 case UNGE_EXPR:
4261 return "u>=";
4263 case LTGT_EXPR:
4264 return "<>";
4266 case LSHIFT_EXPR:
4267 return "<<";
4269 case RSHIFT_EXPR:
4270 return ">>";
4272 case LROTATE_EXPR:
4273 return "r<<";
4275 case RROTATE_EXPR:
4276 return "r>>";
4278 case WIDEN_LSHIFT_EXPR:
4279 return "w<<";
4281 case WIDEN_PLUS_EXPR:
4282 return "w+";
4284 case WIDEN_MINUS_EXPR:
4285 return "w-";
4287 case POINTER_PLUS_EXPR:
4288 return "+";
4290 case PLUS_EXPR:
4291 return "+";
4293 case WIDEN_SUM_EXPR:
4294 return "w+";
4296 case WIDEN_MULT_EXPR:
4297 return "w*";
4299 case MULT_HIGHPART_EXPR:
4300 return "h*";
4302 case NEGATE_EXPR:
4303 case MINUS_EXPR:
4304 case POINTER_DIFF_EXPR:
4305 return "-";
4307 case BIT_NOT_EXPR:
4308 return "~";
4310 case TRUTH_NOT_EXPR:
4311 return "!";
4313 case MULT_EXPR:
4314 case INDIRECT_REF:
4315 return "*";
4317 case TRUNC_DIV_EXPR:
4318 case RDIV_EXPR:
4319 return "/";
4321 case CEIL_DIV_EXPR:
4322 return "/[cl]";
4324 case FLOOR_DIV_EXPR:
4325 return "/[fl]";
4327 case ROUND_DIV_EXPR:
4328 return "/[rd]";
4330 case EXACT_DIV_EXPR:
4331 return "/[ex]";
4333 case TRUNC_MOD_EXPR:
4334 return "%";
4336 case CEIL_MOD_EXPR:
4337 return "%[cl]";
4339 case FLOOR_MOD_EXPR:
4340 return "%[fl]";
4342 case ROUND_MOD_EXPR:
4343 return "%[rd]";
4345 case PREDECREMENT_EXPR:
4346 return " --";
4348 case PREINCREMENT_EXPR:
4349 return " ++";
4351 case POSTDECREMENT_EXPR:
4352 return "-- ";
4354 case POSTINCREMENT_EXPR:
4355 return "++ ";
4357 case MAX_EXPR:
4358 return "max";
4360 case MIN_EXPR:
4361 return "min";
4363 default:
4364 return "<<< ??? >>>";
4368 /* Return the symbol associated with operator OP. */
4370 static const char *
4371 op_symbol (const_tree op)
4373 return op_symbol_code (TREE_CODE (op));
4376 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4377 the gimple_call_fn of a GIMPLE_CALL. */
4379 void
4380 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4382 tree op0 = node;
4384 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4385 op0 = TREE_OPERAND (op0, 0);
4387 again:
4388 switch (TREE_CODE (op0))
4390 case VAR_DECL:
4391 case PARM_DECL:
4392 case FUNCTION_DECL:
4393 dump_function_name (pp, op0, flags);
4394 break;
4396 case ADDR_EXPR:
4397 case INDIRECT_REF:
4398 CASE_CONVERT:
4399 op0 = TREE_OPERAND (op0, 0);
4400 goto again;
4402 case COND_EXPR:
4403 pp_left_paren (pp);
4404 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4405 pp_string (pp, ") ? ");
4406 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4407 pp_string (pp, " : ");
4408 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4409 break;
4411 case ARRAY_REF:
4412 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4413 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4414 else
4415 dump_generic_node (pp, op0, 0, flags, false);
4416 break;
4418 case MEM_REF:
4419 if (integer_zerop (TREE_OPERAND (op0, 1)))
4421 op0 = TREE_OPERAND (op0, 0);
4422 goto again;
4424 /* Fallthru. */
4425 case COMPONENT_REF:
4426 case SSA_NAME:
4427 case OBJ_TYPE_REF:
4428 dump_generic_node (pp, op0, 0, flags, false);
4429 break;
4431 default:
4432 NIY;
4436 /* Print the first N characters in the array STR, replacing non-printable
4437 characters (including embedded nuls) with unambiguous escape sequences. */
4439 void
4440 pretty_print_string (pretty_printer *pp, const char *str, size_t n)
4442 if (str == NULL)
4443 return;
4445 for ( ; n; --n, ++str)
4447 switch (str[0])
4449 case '\b':
4450 pp_string (pp, "\\b");
4451 break;
4453 case '\f':
4454 pp_string (pp, "\\f");
4455 break;
4457 case '\n':
4458 pp_string (pp, "\\n");
4459 break;
4461 case '\r':
4462 pp_string (pp, "\\r");
4463 break;
4465 case '\t':
4466 pp_string (pp, "\\t");
4467 break;
4469 case '\v':
4470 pp_string (pp, "\\v");
4471 break;
4473 case '\\':
4474 pp_string (pp, "\\\\");
4475 break;
4477 case '\"':
4478 pp_string (pp, "\\\"");
4479 break;
4481 case '\'':
4482 pp_string (pp, "\\'");
4483 break;
4485 default:
4486 if (str[0] || n > 1)
4488 if (!ISPRINT (str[0]))
4490 char buf[5];
4491 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4492 pp_string (pp, buf);
4494 else
4495 pp_character (pp, str[0]);
4496 break;
4502 static void
4503 maybe_init_pretty_print (FILE *file)
4505 if (!tree_pp)
4507 tree_pp = new pretty_printer ();
4508 pp_needs_newline (tree_pp) = true;
4509 pp_translate_identifiers (tree_pp) = false;
4512 tree_pp->buffer->stream = file;
4515 static void
4516 newline_and_indent (pretty_printer *pp, int spc)
4518 pp_newline (pp);
4519 INDENT (spc);
4522 /* Print the identifier ID to PRETTY-PRINTER. */
4524 void
4525 pp_tree_identifier (pretty_printer *pp, tree id)
4527 if (pp_translate_identifiers (pp))
4529 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4530 pp_append_text (pp, text, text + strlen (text));
4532 else
4533 pp_append_text (pp, IDENTIFIER_POINTER (id),
4534 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4537 /* A helper function that is used to dump function information before the
4538 function dump. */
4540 void
4541 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4543 const char *dname, *aname;
4544 struct cgraph_node *node = cgraph_node::get (fdecl);
4545 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4547 dname = lang_hooks.decl_printable_name (fdecl, 1);
4549 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4550 aname = (IDENTIFIER_POINTER
4551 (DECL_ASSEMBLER_NAME (fdecl)));
4552 else
4553 aname = "<unset-asm-name>";
4555 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4556 dname, aname, fun->funcdef_no);
4557 if (!(flags & TDF_NOUID))
4558 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4559 if (node)
4561 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4562 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4563 node->frequency == NODE_FREQUENCY_HOT
4564 ? " (hot)"
4565 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4566 ? " (unlikely executed)"
4567 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4568 ? " (executed once)"
4569 : "");
4571 else
4572 fprintf (dump_file, ")\n\n");
4575 /* Dump double_int D to pretty_printer PP. UNS is true
4576 if D is unsigned and false otherwise. */
4577 void
4578 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4580 if (d.fits_shwi ())
4581 pp_wide_integer (pp, d.low);
4582 else if (d.fits_uhwi ())
4583 pp_unsigned_wide_integer (pp, d.low);
4584 else
4586 unsigned HOST_WIDE_INT low = d.low;
4587 HOST_WIDE_INT high = d.high;
4588 if (!uns && d.is_negative ())
4590 pp_minus (pp);
4591 high = ~high + !low;
4592 low = -low;
4594 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4595 systems? */
4596 sprintf (pp_buffer (pp)->digit_buffer,
4597 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4598 (unsigned HOST_WIDE_INT) high, low);
4599 pp_string (pp, pp_buffer (pp)->digit_buffer);
4603 #if __GNUC__ >= 10
4604 # pragma GCC diagnostic pop
4605 #endif