Daily bump.
[official-gcc.git] / gcc / tree-pretty-print.c
blobf6383b91efae8626a402e0e048f54d3d39835c19
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 if (OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (clause))
999 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (clause),
1000 spc, flags, false);
1001 pp_colon (pp);
1003 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR (clause),
1004 spc, flags, false);
1005 pp_right_paren (pp);
1006 break;
1008 case OMP_CLAUSE_THREAD_LIMIT:
1009 pp_string (pp, "thread_limit(");
1010 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
1011 spc, flags, false);
1012 pp_right_paren (pp);
1013 break;
1015 case OMP_CLAUSE_DEVICE:
1016 pp_string (pp, "device(");
1017 if (OMP_CLAUSE_DEVICE_ANCESTOR (clause))
1018 pp_string (pp, "ancestor:");
1019 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
1020 spc, flags, false);
1021 pp_right_paren (pp);
1022 break;
1024 case OMP_CLAUSE_DIST_SCHEDULE:
1025 pp_string (pp, "dist_schedule(static");
1026 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
1028 pp_comma (pp);
1029 dump_generic_node (pp,
1030 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
1031 spc, flags, false);
1033 pp_right_paren (pp);
1034 break;
1036 case OMP_CLAUSE_PROC_BIND:
1037 pp_string (pp, "proc_bind(");
1038 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
1040 case OMP_CLAUSE_PROC_BIND_MASTER:
1041 /* Same enum value: case OMP_CLAUSE_PROC_BIND_PRIMARY: */
1042 /* TODO: Change to 'primary' for OpenMP 5.1. */
1043 pp_string (pp, "master");
1044 break;
1045 case OMP_CLAUSE_PROC_BIND_CLOSE:
1046 pp_string (pp, "close");
1047 break;
1048 case OMP_CLAUSE_PROC_BIND_SPREAD:
1049 pp_string (pp, "spread");
1050 break;
1051 default:
1052 gcc_unreachable ();
1054 pp_right_paren (pp);
1055 break;
1057 case OMP_CLAUSE_DEVICE_TYPE:
1058 pp_string (pp, "device_type(");
1059 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
1061 case OMP_CLAUSE_DEVICE_TYPE_HOST:
1062 pp_string (pp, "host");
1063 break;
1064 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
1065 pp_string (pp, "nohost");
1066 break;
1067 case OMP_CLAUSE_DEVICE_TYPE_ANY:
1068 pp_string (pp, "any");
1069 break;
1070 default:
1071 gcc_unreachable ();
1073 pp_right_paren (pp);
1074 break;
1076 case OMP_CLAUSE_SAFELEN:
1077 pp_string (pp, "safelen(");
1078 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
1079 spc, flags, false);
1080 pp_right_paren (pp);
1081 break;
1083 case OMP_CLAUSE_SIMDLEN:
1084 pp_string (pp, "simdlen(");
1085 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
1086 spc, flags, false);
1087 pp_right_paren (pp);
1088 break;
1090 case OMP_CLAUSE_PRIORITY:
1091 pp_string (pp, "priority(");
1092 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
1093 spc, flags, false);
1094 pp_right_paren (pp);
1095 break;
1097 case OMP_CLAUSE_GRAINSIZE:
1098 pp_string (pp, "grainsize(");
1099 if (OMP_CLAUSE_GRAINSIZE_STRICT (clause))
1100 pp_string (pp, "strict:");
1101 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
1102 spc, flags, false);
1103 pp_right_paren (pp);
1104 break;
1106 case OMP_CLAUSE_NUM_TASKS:
1107 pp_string (pp, "num_tasks(");
1108 if (OMP_CLAUSE_NUM_TASKS_STRICT (clause))
1109 pp_string (pp, "strict:");
1110 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1111 spc, flags, false);
1112 pp_right_paren (pp);
1113 break;
1115 case OMP_CLAUSE_HINT:
1116 pp_string (pp, "hint(");
1117 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1118 spc, flags, false);
1119 pp_right_paren (pp);
1120 break;
1122 case OMP_CLAUSE_FILTER:
1123 pp_string (pp, "filter(");
1124 dump_generic_node (pp, OMP_CLAUSE_FILTER_EXPR (clause),
1125 spc, flags, false);
1126 pp_right_paren (pp);
1127 break;
1129 case OMP_CLAUSE_DEFAULTMAP:
1130 pp_string (pp, "defaultmap(");
1131 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1133 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1134 pp_string (pp, "alloc");
1135 break;
1136 case OMP_CLAUSE_DEFAULTMAP_TO:
1137 pp_string (pp, "to");
1138 break;
1139 case OMP_CLAUSE_DEFAULTMAP_FROM:
1140 pp_string (pp, "from");
1141 break;
1142 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1143 pp_string (pp, "tofrom");
1144 break;
1145 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1146 pp_string (pp, "firstprivate");
1147 break;
1148 case OMP_CLAUSE_DEFAULTMAP_NONE:
1149 pp_string (pp, "none");
1150 break;
1151 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1152 pp_string (pp, "default");
1153 break;
1154 default:
1155 gcc_unreachable ();
1157 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1159 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1160 break;
1161 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1162 pp_string (pp, ":scalar");
1163 break;
1164 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1165 pp_string (pp, ":aggregate");
1166 break;
1167 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1168 pp_string (pp, ":allocatable");
1169 break;
1170 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1171 pp_string (pp, ":pointer");
1172 break;
1173 default:
1174 gcc_unreachable ();
1176 pp_right_paren (pp);
1177 break;
1179 case OMP_CLAUSE_ORDER:
1180 pp_string (pp, "order(");
1181 if (OMP_CLAUSE_ORDER_UNCONSTRAINED (clause))
1182 pp_string (pp, "unconstrained:");
1183 else if (OMP_CLAUSE_ORDER_REPRODUCIBLE (clause))
1184 pp_string (pp, "reproducible:");
1185 pp_string (pp, "concurrent)");
1186 break;
1188 case OMP_CLAUSE_BIND:
1189 pp_string (pp, "bind(");
1190 switch (OMP_CLAUSE_BIND_KIND (clause))
1192 case OMP_CLAUSE_BIND_TEAMS:
1193 pp_string (pp, "teams");
1194 break;
1195 case OMP_CLAUSE_BIND_PARALLEL:
1196 pp_string (pp, "parallel");
1197 break;
1198 case OMP_CLAUSE_BIND_THREAD:
1199 pp_string (pp, "thread");
1200 break;
1201 default:
1202 gcc_unreachable ();
1204 pp_right_paren (pp);
1205 break;
1207 case OMP_CLAUSE__SIMDUID_:
1208 pp_string (pp, "_simduid_(");
1209 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1210 spc, flags, false);
1211 pp_right_paren (pp);
1212 break;
1214 case OMP_CLAUSE__SIMT_:
1215 pp_string (pp, "_simt_");
1216 break;
1218 case OMP_CLAUSE_GANG:
1219 pp_string (pp, "gang");
1220 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1222 pp_string (pp, "(num: ");
1223 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1224 spc, flags, false);
1226 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1228 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1229 pp_left_paren (pp);
1230 else
1231 pp_space (pp);
1232 pp_string (pp, "static:");
1233 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1234 == integer_minus_one_node)
1235 pp_character (pp, '*');
1236 else
1237 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1238 spc, flags, false);
1240 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1241 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1242 pp_right_paren (pp);
1243 break;
1245 case OMP_CLAUSE_ASYNC:
1246 pp_string (pp, "async");
1247 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1249 pp_character(pp, '(');
1250 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1251 spc, flags, false);
1252 pp_character(pp, ')');
1254 break;
1256 case OMP_CLAUSE_AUTO:
1257 case OMP_CLAUSE_SEQ:
1258 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1259 break;
1261 case OMP_CLAUSE_WAIT:
1262 pp_string (pp, "wait(");
1263 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1264 spc, flags, false);
1265 pp_character(pp, ')');
1266 break;
1268 case OMP_CLAUSE_WORKER:
1269 pp_string (pp, "worker");
1270 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1272 pp_left_paren (pp);
1273 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1274 spc, flags, false);
1275 pp_right_paren (pp);
1277 break;
1279 case OMP_CLAUSE_VECTOR:
1280 pp_string (pp, "vector");
1281 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1283 pp_left_paren (pp);
1284 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1285 spc, flags, false);
1286 pp_right_paren (pp);
1288 break;
1290 case OMP_CLAUSE_NUM_GANGS:
1291 pp_string (pp, "num_gangs(");
1292 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1293 spc, flags, false);
1294 pp_character (pp, ')');
1295 break;
1297 case OMP_CLAUSE_NUM_WORKERS:
1298 pp_string (pp, "num_workers(");
1299 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1300 spc, flags, false);
1301 pp_character (pp, ')');
1302 break;
1304 case OMP_CLAUSE_VECTOR_LENGTH:
1305 pp_string (pp, "vector_length(");
1306 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1307 spc, flags, false);
1308 pp_character (pp, ')');
1309 break;
1311 case OMP_CLAUSE_INBRANCH:
1312 pp_string (pp, "inbranch");
1313 break;
1314 case OMP_CLAUSE_NOTINBRANCH:
1315 pp_string (pp, "notinbranch");
1316 break;
1317 case OMP_CLAUSE_FOR:
1318 pp_string (pp, "for");
1319 break;
1320 case OMP_CLAUSE_PARALLEL:
1321 pp_string (pp, "parallel");
1322 break;
1323 case OMP_CLAUSE_SECTIONS:
1324 pp_string (pp, "sections");
1325 break;
1326 case OMP_CLAUSE_TASKGROUP:
1327 pp_string (pp, "taskgroup");
1328 break;
1329 case OMP_CLAUSE_NOGROUP:
1330 pp_string (pp, "nogroup");
1331 break;
1332 case OMP_CLAUSE_THREADS:
1333 pp_string (pp, "threads");
1334 break;
1335 case OMP_CLAUSE_SIMD:
1336 pp_string (pp, "simd");
1337 break;
1338 case OMP_CLAUSE_INDEPENDENT:
1339 pp_string (pp, "independent");
1340 break;
1341 case OMP_CLAUSE_TILE:
1342 pp_string (pp, "tile(");
1343 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1344 spc, flags, false);
1345 pp_right_paren (pp);
1346 break;
1348 case OMP_CLAUSE_IF_PRESENT:
1349 pp_string (pp, "if_present");
1350 break;
1351 case OMP_CLAUSE_FINALIZE:
1352 pp_string (pp, "finalize");
1353 break;
1354 case OMP_CLAUSE_NOHOST:
1355 pp_string (pp, "nohost");
1356 break;
1357 case OMP_CLAUSE_DETACH:
1358 pp_string (pp, "detach(");
1359 dump_generic_node (pp, OMP_CLAUSE_DECL (clause), spc, flags,
1360 false);
1361 pp_right_paren (pp);
1362 break;
1364 default:
1365 gcc_unreachable ();
1370 /* Dump chain of OMP clauses.
1372 PP, SPC and FLAGS are as in dump_generic_node. */
1374 void
1375 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags,
1376 bool leading_space)
1378 while (clause)
1380 if (leading_space)
1381 pp_space (pp);
1382 dump_omp_clause (pp, clause, spc, flags);
1383 leading_space = true;
1385 clause = OMP_CLAUSE_CHAIN (clause);
1390 /* Dump location LOC to PP. */
1392 void
1393 dump_location (pretty_printer *pp, location_t loc)
1395 expanded_location xloc = expand_location (loc);
1397 pp_left_bracket (pp);
1398 if (xloc.file)
1400 pp_string (pp, xloc.file);
1401 pp_string (pp, ":");
1403 pp_decimal_int (pp, xloc.line);
1404 pp_colon (pp);
1405 pp_decimal_int (pp, xloc.column);
1406 pp_string (pp, "] ");
1410 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1411 dump_generic_node. */
1413 static void
1414 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1416 tree t;
1418 pp_string (pp, "BLOCK #");
1419 pp_decimal_int (pp, BLOCK_NUMBER (block));
1420 pp_character (pp, ' ');
1422 if (flags & TDF_ADDRESS)
1424 pp_character (pp, '[');
1425 pp_scalar (pp, "%p", (void *) block);
1426 pp_string (pp, "] ");
1429 if (TREE_ASM_WRITTEN (block))
1430 pp_string (pp, "[written] ");
1432 if (flags & TDF_SLIM)
1433 return;
1435 if (BLOCK_SOURCE_LOCATION (block))
1436 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1438 newline_and_indent (pp, spc + 2);
1440 if (BLOCK_SUPERCONTEXT (block))
1442 pp_string (pp, "SUPERCONTEXT: ");
1443 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1444 flags | TDF_SLIM, false);
1445 newline_and_indent (pp, spc + 2);
1448 if (BLOCK_SUBBLOCKS (block))
1450 pp_string (pp, "SUBBLOCKS: ");
1451 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1453 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1454 pp_space (pp);
1456 newline_and_indent (pp, spc + 2);
1459 if (BLOCK_CHAIN (block))
1461 pp_string (pp, "SIBLINGS: ");
1462 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1464 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1465 pp_space (pp);
1467 newline_and_indent (pp, spc + 2);
1470 if (BLOCK_VARS (block))
1472 pp_string (pp, "VARS: ");
1473 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1475 dump_generic_node (pp, t, 0, flags, false);
1476 pp_space (pp);
1478 newline_and_indent (pp, spc + 2);
1481 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1483 unsigned i;
1484 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1486 pp_string (pp, "NONLOCALIZED_VARS: ");
1487 FOR_EACH_VEC_ELT (*nlv, i, t)
1489 dump_generic_node (pp, t, 0, flags, false);
1490 pp_space (pp);
1492 newline_and_indent (pp, spc + 2);
1495 if (BLOCK_ABSTRACT_ORIGIN (block))
1497 pp_string (pp, "ABSTRACT_ORIGIN: ");
1498 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1499 flags | TDF_SLIM, false);
1500 newline_and_indent (pp, spc + 2);
1503 if (BLOCK_FRAGMENT_ORIGIN (block))
1505 pp_string (pp, "FRAGMENT_ORIGIN: ");
1506 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1507 flags | TDF_SLIM, false);
1508 newline_and_indent (pp, spc + 2);
1511 if (BLOCK_FRAGMENT_CHAIN (block))
1513 pp_string (pp, "FRAGMENT_CHAIN: ");
1514 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1516 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1517 pp_space (pp);
1519 newline_and_indent (pp, spc + 2);
1523 /* Dump #pragma omp atomic memory order clause. */
1525 void
1526 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1528 switch (mo & OMP_MEMORY_ORDER_MASK)
1530 case OMP_MEMORY_ORDER_RELAXED:
1531 pp_string (pp, " relaxed");
1532 break;
1533 case OMP_MEMORY_ORDER_SEQ_CST:
1534 pp_string (pp, " seq_cst");
1535 break;
1536 case OMP_MEMORY_ORDER_ACQ_REL:
1537 pp_string (pp, " acq_rel");
1538 break;
1539 case OMP_MEMORY_ORDER_ACQUIRE:
1540 pp_string (pp, " acquire");
1541 break;
1542 case OMP_MEMORY_ORDER_RELEASE:
1543 pp_string (pp, " release");
1544 break;
1545 case OMP_MEMORY_ORDER_UNSPECIFIED:
1546 break;
1547 default:
1548 gcc_unreachable ();
1550 switch (mo & OMP_FAIL_MEMORY_ORDER_MASK)
1552 case OMP_FAIL_MEMORY_ORDER_RELAXED:
1553 pp_string (pp, " fail(relaxed)");
1554 break;
1555 case OMP_FAIL_MEMORY_ORDER_SEQ_CST:
1556 pp_string (pp, " fail(seq_cst)");
1557 break;
1558 case OMP_FAIL_MEMORY_ORDER_ACQUIRE:
1559 pp_string (pp, " fail(acquire)");
1560 break;
1561 case OMP_FAIL_MEMORY_ORDER_UNSPECIFIED:
1562 break;
1563 default:
1564 gcc_unreachable ();
1568 /* Helper to dump a MEM_REF node. */
1570 static void
1571 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1573 if (TREE_CODE (node) == MEM_REF && (flags & TDF_GIMPLE))
1575 pp_string (pp, "__MEM <");
1576 dump_generic_node (pp, TREE_TYPE (node),
1577 spc, flags | TDF_SLIM, false);
1578 if (TYPE_ALIGN (TREE_TYPE (node))
1579 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1581 pp_string (pp, ", ");
1582 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1584 pp_greater (pp);
1585 pp_string (pp, " (");
1586 if (TREE_TYPE (TREE_OPERAND (node, 0))
1587 != TREE_TYPE (TREE_OPERAND (node, 1)))
1589 pp_left_paren (pp);
1590 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1591 spc, flags | TDF_SLIM, false);
1592 pp_right_paren (pp);
1594 dump_generic_node (pp, TREE_OPERAND (node, 0),
1595 spc, flags | TDF_SLIM, false);
1596 if (! integer_zerop (TREE_OPERAND (node, 1)))
1598 pp_string (pp, " + ");
1599 dump_generic_node (pp, TREE_OPERAND (node, 1),
1600 spc, flags | TDF_SLIM, false);
1602 pp_right_paren (pp);
1604 else if (TREE_CODE (node) == MEM_REF
1605 && integer_zerop (TREE_OPERAND (node, 1))
1606 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1607 infer them and MEM_ATTR caching will share MEM_REFs
1608 with differently-typed op0s. */
1609 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1610 /* Released SSA_NAMES have no TREE_TYPE. */
1611 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1612 /* Same pointer types, but ignoring POINTER_TYPE vs.
1613 REFERENCE_TYPE. */
1614 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1615 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1616 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1617 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1618 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1619 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1620 /* Same value types ignoring qualifiers. */
1621 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1622 == TYPE_MAIN_VARIANT
1623 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1624 && (!(flags & TDF_ALIAS)
1625 || MR_DEPENDENCE_CLIQUE (node) == 0))
1627 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1629 /* Enclose pointers to arrays in parentheses. */
1630 tree op0 = TREE_OPERAND (node, 0);
1631 tree op0type = TREE_TYPE (op0);
1632 if (POINTER_TYPE_P (op0type)
1633 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1634 pp_left_paren (pp);
1635 pp_star (pp);
1636 dump_generic_node (pp, op0, spc, flags, false);
1637 if (POINTER_TYPE_P (op0type)
1638 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1639 pp_right_paren (pp);
1641 else
1642 dump_generic_node (pp,
1643 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1644 spc, flags, false);
1646 else
1648 pp_string (pp, "MEM");
1650 tree nodetype = TREE_TYPE (node);
1651 tree op0 = TREE_OPERAND (node, 0);
1652 tree op1 = TREE_OPERAND (node, 1);
1653 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1655 tree op0size = TYPE_SIZE (nodetype);
1656 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1658 if (!op0size || !op1size
1659 || !operand_equal_p (op0size, op1size, 0))
1661 pp_string (pp, " <");
1662 /* If the size of the type of the operand is not the same
1663 as the size of the MEM_REF expression include the type
1664 of the latter similar to the TDF_GIMPLE output to make
1665 it clear how many bytes of memory are being accessed. */
1666 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1667 pp_string (pp, "> ");
1670 pp_string (pp, "[(");
1671 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1672 pp_right_paren (pp);
1673 dump_generic_node (pp, op0, spc, flags, false);
1674 if (!integer_zerop (op1))
1676 pp_string (pp, " + ");
1677 dump_generic_node (pp, op1, spc, flags, false);
1679 if (TREE_CODE (node) == TARGET_MEM_REF)
1681 tree tmp = TMR_INDEX2 (node);
1682 if (tmp)
1684 pp_string (pp, " + ");
1685 dump_generic_node (pp, tmp, spc, flags, false);
1687 tmp = TMR_INDEX (node);
1688 if (tmp)
1690 pp_string (pp, " + ");
1691 dump_generic_node (pp, tmp, spc, flags, false);
1692 tmp = TMR_STEP (node);
1693 pp_string (pp, " * ");
1694 if (tmp)
1695 dump_generic_node (pp, tmp, spc, flags, false);
1696 else
1697 pp_string (pp, "1");
1700 if ((flags & TDF_ALIAS)
1701 && MR_DEPENDENCE_CLIQUE (node) != 0)
1703 pp_string (pp, " clique ");
1704 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1705 pp_string (pp, " base ");
1706 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1708 pp_right_bracket (pp);
1712 /* Helper function for dump_generic_node. Dump INIT or COND expression for
1713 OpenMP loop non-rectangular iterators. */
1715 void
1716 dump_omp_loop_non_rect_expr (pretty_printer *pp, tree node, int spc,
1717 dump_flags_t flags)
1719 gcc_assert (TREE_CODE (node) == TREE_VEC);
1720 dump_generic_node (pp, TREE_VEC_ELT (node, 0), spc, flags, false);
1721 pp_string (pp, " * ");
1722 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (MULT_EXPR))
1724 pp_left_paren (pp);
1725 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1726 pp_right_paren (pp);
1728 else
1729 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1730 pp_string (pp, " + ");
1731 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (PLUS_EXPR))
1733 pp_left_paren (pp);
1734 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1735 pp_right_paren (pp);
1737 else
1738 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1741 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1742 indent. FLAGS specifies details to show in the dump (see TDF_* in
1743 dumpfile.h). If IS_STMT is true, the object printed is considered
1744 to be a statement and it is terminated by ';' if appropriate. */
1747 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1748 bool is_stmt)
1750 tree type;
1751 tree op0, op1;
1752 const char *str;
1753 bool is_expr;
1754 enum tree_code code;
1756 if (node == NULL_TREE)
1757 return spc;
1759 is_expr = EXPR_P (node);
1761 if (is_stmt && (flags & TDF_STMTADDR))
1763 pp_string (pp, "<&");
1764 pp_scalar (pp, "%p", (void *)node);
1765 pp_string (pp, "> ");
1768 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1769 dump_location (pp, EXPR_LOCATION (node));
1771 code = TREE_CODE (node);
1772 switch (code)
1774 case ERROR_MARK:
1775 pp_string (pp, "<<< error >>>");
1776 break;
1778 case IDENTIFIER_NODE:
1779 pp_tree_identifier (pp, node);
1780 break;
1782 case TREE_LIST:
1783 while (node && node != error_mark_node)
1785 if (TREE_PURPOSE (node))
1787 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1788 pp_space (pp);
1790 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1791 node = TREE_CHAIN (node);
1792 if (node && TREE_CODE (node) == TREE_LIST)
1794 pp_comma (pp);
1795 pp_space (pp);
1798 break;
1800 case TREE_BINFO:
1801 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1802 break;
1804 case TREE_VEC:
1806 size_t i;
1807 if (TREE_VEC_LENGTH (node) > 0)
1809 size_t len = TREE_VEC_LENGTH (node);
1810 for (i = 0; i < len - 1; i++)
1812 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1813 false);
1814 pp_comma (pp);
1815 pp_space (pp);
1817 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1818 flags, false);
1821 break;
1823 case VOID_TYPE:
1824 case INTEGER_TYPE:
1825 case REAL_TYPE:
1826 case FIXED_POINT_TYPE:
1827 case COMPLEX_TYPE:
1828 case VECTOR_TYPE:
1829 case ENUMERAL_TYPE:
1830 case BOOLEAN_TYPE:
1831 case OPAQUE_TYPE:
1833 unsigned int quals = TYPE_QUALS (node);
1834 enum tree_code_class tclass;
1836 if (quals & TYPE_QUAL_ATOMIC)
1837 pp_string (pp, "atomic ");
1838 if (quals & TYPE_QUAL_CONST)
1839 pp_string (pp, "const ");
1840 if (quals & TYPE_QUAL_VOLATILE)
1841 pp_string (pp, "volatile ");
1842 if (quals & TYPE_QUAL_RESTRICT)
1843 pp_string (pp, "restrict ");
1845 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1847 pp_string (pp, "<address-space-");
1848 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1849 pp_string (pp, "> ");
1852 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1854 if (tclass == tcc_declaration)
1856 if (DECL_NAME (node))
1857 dump_decl_name (pp, node, flags);
1858 else
1859 pp_string (pp, "<unnamed type decl>");
1861 else if (tclass == tcc_type)
1863 if (TYPE_NAME (node))
1865 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1866 pp_tree_identifier (pp, TYPE_NAME (node));
1867 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1868 && DECL_NAME (TYPE_NAME (node)))
1869 dump_decl_name (pp, TYPE_NAME (node), flags);
1870 else
1871 pp_string (pp, "<unnamed type>");
1873 else if (TREE_CODE (node) == VECTOR_TYPE)
1875 pp_string (pp, "vector");
1876 pp_left_paren (pp);
1877 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1878 pp_string (pp, ") ");
1879 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1881 else if (TREE_CODE (node) == INTEGER_TYPE)
1883 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1884 pp_string (pp, (TYPE_UNSIGNED (node)
1885 ? "unsigned char"
1886 : "signed char"));
1887 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1888 pp_string (pp, (TYPE_UNSIGNED (node)
1889 ? "unsigned short"
1890 : "signed short"));
1891 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1892 pp_string (pp, (TYPE_UNSIGNED (node)
1893 ? "unsigned int"
1894 : "signed int"));
1895 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1896 pp_string (pp, (TYPE_UNSIGNED (node)
1897 ? "unsigned long"
1898 : "signed long"));
1899 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1900 pp_string (pp, (TYPE_UNSIGNED (node)
1901 ? "unsigned long long"
1902 : "signed long long"));
1903 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1904 && pow2p_hwi (TYPE_PRECISION (node)))
1906 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1907 pp_decimal_int (pp, TYPE_PRECISION (node));
1908 pp_string (pp, "_t");
1910 else
1912 pp_string (pp, (TYPE_UNSIGNED (node)
1913 ? "<unnamed-unsigned:"
1914 : "<unnamed-signed:"));
1915 pp_decimal_int (pp, TYPE_PRECISION (node));
1916 pp_greater (pp);
1919 else if (TREE_CODE (node) == COMPLEX_TYPE)
1921 pp_string (pp, "__complex__ ");
1922 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1924 else if (TREE_CODE (node) == REAL_TYPE)
1926 pp_string (pp, "<float:");
1927 pp_decimal_int (pp, TYPE_PRECISION (node));
1928 pp_greater (pp);
1930 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1932 pp_string (pp, "<fixed-point-");
1933 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1934 pp_decimal_int (pp, TYPE_PRECISION (node));
1935 pp_greater (pp);
1937 else if (TREE_CODE (node) == BOOLEAN_TYPE)
1939 pp_string (pp, (TYPE_UNSIGNED (node)
1940 ? "<unsigned-boolean:"
1941 : "<signed-boolean:"));
1942 pp_decimal_int (pp, TYPE_PRECISION (node));
1943 pp_greater (pp);
1945 else if (TREE_CODE (node) == VOID_TYPE)
1946 pp_string (pp, "void");
1947 else
1948 pp_string (pp, "<unnamed type>");
1950 break;
1953 case POINTER_TYPE:
1954 case REFERENCE_TYPE:
1955 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1957 if (TREE_TYPE (node) == NULL)
1959 pp_string (pp, str);
1960 pp_string (pp, "<null type>");
1962 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1964 tree fnode = TREE_TYPE (node);
1966 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1967 pp_space (pp);
1968 pp_left_paren (pp);
1969 pp_string (pp, str);
1970 if (TYPE_IDENTIFIER (node))
1971 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1972 else if (flags & TDF_NOUID)
1973 pp_string (pp, "<Txxxx>");
1974 else
1976 pp_string (pp, "<T");
1977 pp_scalar (pp, "%x", TYPE_UID (node));
1978 pp_character (pp, '>');
1981 pp_right_paren (pp);
1982 dump_function_declaration (pp, fnode, spc, flags);
1984 else
1986 unsigned int quals = TYPE_QUALS (node);
1988 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1989 pp_space (pp);
1990 pp_string (pp, str);
1992 if (quals & TYPE_QUAL_CONST)
1993 pp_string (pp, " const");
1994 if (quals & TYPE_QUAL_VOLATILE)
1995 pp_string (pp, " volatile");
1996 if (quals & TYPE_QUAL_RESTRICT)
1997 pp_string (pp, " restrict");
1999 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2001 pp_string (pp, " <address-space-");
2002 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2003 pp_greater (pp);
2006 if (TYPE_REF_CAN_ALIAS_ALL (node))
2007 pp_string (pp, " {ref-all}");
2009 break;
2011 case OFFSET_TYPE:
2012 NIY;
2013 break;
2015 case MEM_REF:
2016 case TARGET_MEM_REF:
2017 dump_mem_ref (pp, node, spc, flags);
2018 break;
2020 case ARRAY_TYPE:
2022 unsigned int quals = TYPE_QUALS (node);
2023 tree tmp;
2025 if (quals & TYPE_QUAL_ATOMIC)
2026 pp_string (pp, "atomic ");
2027 if (quals & TYPE_QUAL_CONST)
2028 pp_string (pp, "const ");
2029 if (quals & TYPE_QUAL_VOLATILE)
2030 pp_string (pp, "volatile ");
2032 /* Print the innermost component type. */
2033 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
2034 tmp = TREE_TYPE (tmp))
2036 dump_generic_node (pp, tmp, spc, flags, false);
2038 /* Print the dimensions. */
2039 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
2040 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2041 break;
2044 case RECORD_TYPE:
2045 case UNION_TYPE:
2046 case QUAL_UNION_TYPE:
2048 unsigned int quals = TYPE_QUALS (node);
2050 if (quals & TYPE_QUAL_ATOMIC)
2051 pp_string (pp, "atomic ");
2052 if (quals & TYPE_QUAL_CONST)
2053 pp_string (pp, "const ");
2054 if (quals & TYPE_QUAL_VOLATILE)
2055 pp_string (pp, "volatile ");
2057 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2059 pp_string (pp, "<address-space-");
2060 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2061 pp_string (pp, "> ");
2064 /* Print the name of the structure. */
2065 if (TREE_CODE (node) == RECORD_TYPE)
2066 pp_string (pp, "struct ");
2067 else if (TREE_CODE (node) == UNION_TYPE)
2068 pp_string (pp, "union ");
2070 if (TYPE_NAME (node))
2071 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2072 else if (!(flags & TDF_SLIM))
2073 /* FIXME: If we eliminate the 'else' above and attempt
2074 to show the fields for named types, we may get stuck
2075 following a cycle of pointers to structs. The alleged
2076 self-reference check in print_struct_decl will not detect
2077 cycles involving more than one pointer or struct type. */
2078 print_struct_decl (pp, node, spc, flags);
2079 break;
2082 case LANG_TYPE:
2083 NIY;
2084 break;
2086 case INTEGER_CST:
2087 if (flags & TDF_GIMPLE
2088 && (POINTER_TYPE_P (TREE_TYPE (node))
2089 || (TYPE_PRECISION (TREE_TYPE (node))
2090 < TYPE_PRECISION (integer_type_node))
2091 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
2092 || tree_int_cst_sgn (node) < 0))
2094 pp_string (pp, "_Literal (");
2095 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2096 pp_string (pp, ") ");
2098 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
2099 && ! (flags & TDF_GIMPLE))
2101 /* In the case of a pointer, one may want to divide by the
2102 size of the pointed-to type. Unfortunately, this not
2103 straightforward. The C front-end maps expressions
2105 (int *) 5
2106 int *p; (p + 5)
2108 in such a way that the two INTEGER_CST nodes for "5" have
2109 different values but identical types. In the latter
2110 case, the 5 is multiplied by sizeof (int) in c-common.c
2111 (pointer_int_sum) to convert it to a byte address, and
2112 yet the type of the node is left unchanged. Argh. What
2113 is consistent though is that the number value corresponds
2114 to bytes (UNITS) offset.
2116 NB: Neither of the following divisors can be trivially
2117 used to recover the original literal:
2119 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
2120 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
2121 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
2122 pp_string (pp, "B"); /* pseudo-unit */
2124 else if (tree_fits_shwi_p (node))
2125 pp_wide_integer (pp, tree_to_shwi (node));
2126 else if (tree_fits_uhwi_p (node))
2127 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
2128 else
2130 wide_int val = wi::to_wide (node);
2132 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
2134 pp_minus (pp);
2135 val = -val;
2137 print_hex (val, pp_buffer (pp)->digit_buffer);
2138 pp_string (pp, pp_buffer (pp)->digit_buffer);
2140 if ((flags & TDF_GIMPLE)
2141 && ! (POINTER_TYPE_P (TREE_TYPE (node))
2142 || (TYPE_PRECISION (TREE_TYPE (node))
2143 < TYPE_PRECISION (integer_type_node))
2144 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
2146 if (TYPE_UNSIGNED (TREE_TYPE (node)))
2147 pp_character (pp, 'u');
2148 if (TYPE_PRECISION (TREE_TYPE (node))
2149 == TYPE_PRECISION (unsigned_type_node))
2151 else if (TYPE_PRECISION (TREE_TYPE (node))
2152 == TYPE_PRECISION (long_unsigned_type_node))
2153 pp_character (pp, 'l');
2154 else if (TYPE_PRECISION (TREE_TYPE (node))
2155 == TYPE_PRECISION (long_long_unsigned_type_node))
2156 pp_string (pp, "ll");
2158 if (TREE_OVERFLOW (node))
2159 pp_string (pp, "(OVF)");
2160 break;
2162 case POLY_INT_CST:
2163 pp_string (pp, "POLY_INT_CST [");
2164 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2165 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2167 pp_string (pp, ", ");
2168 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2169 spc, flags, false);
2171 pp_string (pp, "]");
2172 break;
2174 case REAL_CST:
2175 /* Code copied from print_node. */
2177 REAL_VALUE_TYPE d;
2178 if (TREE_OVERFLOW (node))
2179 pp_string (pp, " overflow");
2181 d = TREE_REAL_CST (node);
2182 if (REAL_VALUE_ISINF (d))
2183 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2184 else if (REAL_VALUE_ISNAN (d))
2185 pp_string (pp, " Nan");
2186 else
2188 char string[100];
2189 real_to_decimal (string, &d, sizeof (string), 0, 1);
2190 pp_string (pp, string);
2192 break;
2195 case FIXED_CST:
2197 char string[100];
2198 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2199 pp_string (pp, string);
2200 break;
2203 case COMPLEX_CST:
2204 pp_string (pp, "__complex__ (");
2205 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2206 pp_string (pp, ", ");
2207 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2208 pp_right_paren (pp);
2209 break;
2211 case STRING_CST:
2213 pp_string (pp, "\"");
2214 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2215 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2216 pp_string (pp, "\"");
2217 break;
2220 case VECTOR_CST:
2222 unsigned i;
2223 if (flags & TDF_GIMPLE)
2225 pp_string (pp, "_Literal (");
2226 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2227 pp_string (pp, ") ");
2229 pp_string (pp, "{ ");
2230 unsigned HOST_WIDE_INT nunits;
2231 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2232 nunits = vector_cst_encoded_nelts (node);
2233 for (i = 0; i < nunits; ++i)
2235 if (i != 0)
2236 pp_string (pp, ", ");
2237 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2238 spc, flags, false);
2240 if (!VECTOR_CST_NELTS (node).is_constant ())
2241 pp_string (pp, ", ...");
2242 pp_string (pp, " }");
2244 break;
2246 case FUNCTION_TYPE:
2247 case METHOD_TYPE:
2248 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2249 pp_space (pp);
2250 if (TREE_CODE (node) == METHOD_TYPE)
2252 if (TYPE_METHOD_BASETYPE (node))
2253 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2254 spc, flags, false);
2255 else
2256 pp_string (pp, "<null method basetype>");
2257 pp_colon_colon (pp);
2259 if (TYPE_IDENTIFIER (node))
2260 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2261 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2262 dump_decl_name (pp, TYPE_NAME (node), flags);
2263 else if (flags & TDF_NOUID)
2264 pp_string (pp, "<Txxxx>");
2265 else
2267 pp_string (pp, "<T");
2268 pp_scalar (pp, "%x", TYPE_UID (node));
2269 pp_character (pp, '>');
2271 dump_function_declaration (pp, node, spc, flags);
2272 break;
2274 case FUNCTION_DECL:
2275 case CONST_DECL:
2276 dump_decl_name (pp, node, flags);
2277 break;
2279 case LABEL_DECL:
2280 if (DECL_NAME (node))
2281 dump_decl_name (pp, node, flags);
2282 else if (LABEL_DECL_UID (node) != -1)
2284 if (flags & TDF_GIMPLE)
2286 pp_character (pp, 'L');
2287 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2289 else
2291 pp_string (pp, "<L");
2292 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2293 pp_character (pp, '>');
2296 else
2298 if (flags & TDF_NOUID)
2299 pp_string (pp, "<D.xxxx>");
2300 else
2302 if (flags & TDF_GIMPLE)
2304 pp_character (pp, 'D');
2305 pp_scalar (pp, "%u", DECL_UID (node));
2307 else
2309 pp_string (pp, "<D.");
2310 pp_scalar (pp, "%u", DECL_UID (node));
2311 pp_character (pp, '>');
2315 break;
2317 case TYPE_DECL:
2318 if (DECL_IS_UNDECLARED_BUILTIN (node))
2320 /* Don't print the declaration of built-in types. */
2321 break;
2323 if (DECL_NAME (node))
2324 dump_decl_name (pp, node, flags);
2325 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2327 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2328 ? "union" : "struct "));
2329 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2331 else
2332 pp_string (pp, "<anon>");
2333 break;
2335 case VAR_DECL:
2336 case PARM_DECL:
2337 case FIELD_DECL:
2338 case DEBUG_EXPR_DECL:
2339 case NAMESPACE_DECL:
2340 case NAMELIST_DECL:
2341 dump_decl_name (pp, node, flags);
2342 break;
2344 case RESULT_DECL:
2345 pp_string (pp, "<retval>");
2346 break;
2348 case COMPONENT_REF:
2349 op0 = TREE_OPERAND (node, 0);
2350 str = ".";
2351 if (op0
2352 && (TREE_CODE (op0) == INDIRECT_REF
2353 || (TREE_CODE (op0) == MEM_REF
2354 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2355 && integer_zerop (TREE_OPERAND (op0, 1))
2356 /* Dump the types of INTEGER_CSTs explicitly, for we
2357 can't infer them and MEM_ATTR caching will share
2358 MEM_REFs with differently-typed op0s. */
2359 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2360 /* Released SSA_NAMES have no TREE_TYPE. */
2361 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2362 /* Same pointer types, but ignoring POINTER_TYPE vs.
2363 REFERENCE_TYPE. */
2364 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2365 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2366 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2367 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2368 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2369 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2370 /* Same value types ignoring qualifiers. */
2371 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2372 == TYPE_MAIN_VARIANT
2373 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2374 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2376 op0 = TREE_OPERAND (op0, 0);
2377 str = "->";
2379 if (op_prio (op0) < op_prio (node))
2380 pp_left_paren (pp);
2381 dump_generic_node (pp, op0, spc, flags, false);
2382 if (op_prio (op0) < op_prio (node))
2383 pp_right_paren (pp);
2384 pp_string (pp, str);
2385 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2386 op0 = component_ref_field_offset (node);
2387 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2389 pp_string (pp, "{off: ");
2390 dump_generic_node (pp, op0, spc, flags, false);
2391 pp_right_brace (pp);
2393 break;
2395 case BIT_FIELD_REF:
2396 if (flags & TDF_GIMPLE)
2398 pp_string (pp, "__BIT_FIELD_REF <");
2399 dump_generic_node (pp, TREE_TYPE (node),
2400 spc, flags | TDF_SLIM, false);
2401 if (TYPE_ALIGN (TREE_TYPE (node))
2402 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2404 pp_string (pp, ", ");
2405 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2407 pp_greater (pp);
2408 pp_string (pp, " (");
2409 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2410 flags | TDF_SLIM, false);
2411 pp_string (pp, ", ");
2412 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2413 flags | TDF_SLIM, false);
2414 pp_string (pp, ", ");
2415 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2416 flags | TDF_SLIM, false);
2417 pp_right_paren (pp);
2419 else
2421 pp_string (pp, "BIT_FIELD_REF <");
2422 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2423 pp_string (pp, ", ");
2424 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2425 pp_string (pp, ", ");
2426 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2427 pp_greater (pp);
2429 break;
2431 case BIT_INSERT_EXPR:
2432 pp_string (pp, "BIT_INSERT_EXPR <");
2433 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2434 pp_string (pp, ", ");
2435 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2436 pp_string (pp, ", ");
2437 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2438 pp_string (pp, " (");
2439 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2440 pp_decimal_int (pp,
2441 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2442 else
2443 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2444 spc, flags, false);
2445 pp_string (pp, " bits)>");
2446 break;
2448 case ARRAY_REF:
2449 case ARRAY_RANGE_REF:
2450 op0 = TREE_OPERAND (node, 0);
2451 if (op_prio (op0) < op_prio (node))
2452 pp_left_paren (pp);
2453 dump_generic_node (pp, op0, spc, flags, false);
2454 if (op_prio (op0) < op_prio (node))
2455 pp_right_paren (pp);
2456 pp_left_bracket (pp);
2457 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2458 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2459 pp_string (pp, " ...");
2460 pp_right_bracket (pp);
2462 op0 = array_ref_low_bound (node);
2463 op1 = array_ref_element_size (node);
2465 if (!integer_zerop (op0)
2466 || TREE_OPERAND (node, 2)
2467 || TREE_OPERAND (node, 3))
2469 pp_string (pp, "{lb: ");
2470 dump_generic_node (pp, op0, spc, flags, false);
2471 pp_string (pp, " sz: ");
2472 dump_generic_node (pp, op1, spc, flags, false);
2473 pp_right_brace (pp);
2475 break;
2477 case CONSTRUCTOR:
2479 unsigned HOST_WIDE_INT ix;
2480 tree field, val;
2481 bool is_struct_init = false;
2482 bool is_array_init = false;
2483 widest_int curidx;
2484 if (flags & TDF_GIMPLE)
2486 pp_string (pp, "_Literal (");
2487 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2488 pp_string (pp, ") ");
2490 pp_left_brace (pp);
2491 if (TREE_CLOBBER_P (node))
2492 pp_string (pp, "CLOBBER");
2493 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2494 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2495 is_struct_init = true;
2496 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2497 && TYPE_DOMAIN (TREE_TYPE (node))
2498 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2499 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2500 == INTEGER_CST)
2502 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2503 is_array_init = true;
2504 curidx = wi::to_widest (minv);
2506 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2508 if (field)
2510 if (is_struct_init)
2512 pp_dot (pp);
2513 dump_generic_node (pp, field, spc, flags, false);
2514 pp_equal (pp);
2516 else if (is_array_init
2517 && (TREE_CODE (field) != INTEGER_CST
2518 || curidx != wi::to_widest (field)))
2520 pp_left_bracket (pp);
2521 if (TREE_CODE (field) == RANGE_EXPR)
2523 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2524 flags, false);
2525 pp_string (pp, " ... ");
2526 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2527 flags, false);
2528 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2529 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2531 else
2532 dump_generic_node (pp, field, spc, flags, false);
2533 if (TREE_CODE (field) == INTEGER_CST)
2534 curidx = wi::to_widest (field);
2535 pp_string (pp, "]=");
2538 if (is_array_init)
2539 curidx += 1;
2540 if (val && TREE_CODE (val) == ADDR_EXPR)
2541 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2542 val = TREE_OPERAND (val, 0);
2543 if (val && TREE_CODE (val) == FUNCTION_DECL)
2544 dump_decl_name (pp, val, flags);
2545 else
2546 dump_generic_node (pp, val, spc, flags, false);
2547 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2549 pp_comma (pp);
2550 pp_space (pp);
2553 pp_right_brace (pp);
2555 break;
2557 case COMPOUND_EXPR:
2559 tree *tp;
2560 if (flags & TDF_SLIM)
2562 pp_string (pp, "<COMPOUND_EXPR>");
2563 break;
2566 dump_generic_node (pp, TREE_OPERAND (node, 0),
2567 spc, flags, !(flags & TDF_SLIM));
2568 if (flags & TDF_SLIM)
2569 newline_and_indent (pp, spc);
2570 else
2572 pp_comma (pp);
2573 pp_space (pp);
2576 for (tp = &TREE_OPERAND (node, 1);
2577 TREE_CODE (*tp) == COMPOUND_EXPR;
2578 tp = &TREE_OPERAND (*tp, 1))
2580 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2581 spc, flags, !(flags & TDF_SLIM));
2582 if (flags & TDF_SLIM)
2583 newline_and_indent (pp, spc);
2584 else
2586 pp_comma (pp);
2587 pp_space (pp);
2591 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2593 break;
2595 case STATEMENT_LIST:
2597 tree_stmt_iterator si;
2598 bool first = true;
2600 if (flags & TDF_SLIM)
2602 pp_string (pp, "<STATEMENT_LIST>");
2603 break;
2606 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2608 if (!first)
2609 newline_and_indent (pp, spc);
2610 else
2611 first = false;
2612 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2615 break;
2617 case MODIFY_EXPR:
2618 case INIT_EXPR:
2619 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2620 false);
2621 pp_space (pp);
2622 pp_equal (pp);
2623 pp_space (pp);
2624 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2625 false);
2626 break;
2628 case TARGET_EXPR:
2629 pp_string (pp, "TARGET_EXPR <");
2630 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2631 pp_comma (pp);
2632 pp_space (pp);
2633 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2634 pp_greater (pp);
2635 break;
2637 case DECL_EXPR:
2638 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2639 is_stmt = false;
2640 break;
2642 case COND_EXPR:
2643 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2645 pp_string (pp, "if (");
2646 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2647 pp_right_paren (pp);
2648 /* The lowered cond_exprs should always be printed in full. */
2649 if (COND_EXPR_THEN (node)
2650 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2651 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2652 && COND_EXPR_ELSE (node)
2653 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2654 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2656 pp_space (pp);
2657 dump_generic_node (pp, COND_EXPR_THEN (node),
2658 0, flags, true);
2659 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2661 pp_string (pp, " else ");
2662 dump_generic_node (pp, COND_EXPR_ELSE (node),
2663 0, flags, true);
2666 else if (!(flags & TDF_SLIM))
2668 /* Output COND_EXPR_THEN. */
2669 if (COND_EXPR_THEN (node))
2671 newline_and_indent (pp, spc+2);
2672 pp_left_brace (pp);
2673 newline_and_indent (pp, spc+4);
2674 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2675 flags, true);
2676 newline_and_indent (pp, spc+2);
2677 pp_right_brace (pp);
2680 /* Output COND_EXPR_ELSE. */
2681 if (COND_EXPR_ELSE (node)
2682 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2684 newline_and_indent (pp, spc);
2685 pp_string (pp, "else");
2686 newline_and_indent (pp, spc+2);
2687 pp_left_brace (pp);
2688 newline_and_indent (pp, spc+4);
2689 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2690 flags, true);
2691 newline_and_indent (pp, spc+2);
2692 pp_right_brace (pp);
2695 is_expr = false;
2697 else
2699 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2700 pp_space (pp);
2701 pp_question (pp);
2702 pp_space (pp);
2703 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2704 pp_space (pp);
2705 pp_colon (pp);
2706 pp_space (pp);
2707 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2709 break;
2711 case BIND_EXPR:
2712 pp_left_brace (pp);
2713 if (!(flags & TDF_SLIM))
2715 if (BIND_EXPR_VARS (node))
2717 pp_newline (pp);
2719 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2721 print_declaration (pp, op0, spc+2, flags);
2722 pp_newline (pp);
2726 newline_and_indent (pp, spc+2);
2727 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2728 newline_and_indent (pp, spc);
2729 pp_right_brace (pp);
2731 is_expr = false;
2732 break;
2734 case CALL_EXPR:
2735 if (CALL_EXPR_FN (node) != NULL_TREE)
2736 print_call_name (pp, CALL_EXPR_FN (node), flags);
2737 else
2739 pp_dot (pp);
2740 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2743 /* Print parameters. */
2744 pp_space (pp);
2745 pp_left_paren (pp);
2747 tree arg;
2748 call_expr_arg_iterator iter;
2749 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2751 dump_generic_node (pp, arg, spc, flags, false);
2752 if (more_call_expr_args_p (&iter))
2754 pp_comma (pp);
2755 pp_space (pp);
2759 if (CALL_EXPR_VA_ARG_PACK (node))
2761 if (call_expr_nargs (node) > 0)
2763 pp_comma (pp);
2764 pp_space (pp);
2766 pp_string (pp, "__builtin_va_arg_pack ()");
2768 pp_right_paren (pp);
2770 op1 = CALL_EXPR_STATIC_CHAIN (node);
2771 if (op1)
2773 pp_string (pp, " [static-chain: ");
2774 dump_generic_node (pp, op1, spc, flags, false);
2775 pp_right_bracket (pp);
2778 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2779 pp_string (pp, " [return slot optimization]");
2780 if (CALL_EXPR_TAILCALL (node))
2781 pp_string (pp, " [tail call]");
2782 break;
2784 case WITH_CLEANUP_EXPR:
2785 NIY;
2786 break;
2788 case CLEANUP_POINT_EXPR:
2789 pp_string (pp, "<<cleanup_point ");
2790 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2791 pp_string (pp, ">>");
2792 break;
2794 case PLACEHOLDER_EXPR:
2795 pp_string (pp, "<PLACEHOLDER_EXPR ");
2796 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2797 pp_greater (pp);
2798 break;
2800 /* Binary arithmetic and logic expressions. */
2801 case WIDEN_PLUS_EXPR:
2802 case WIDEN_MINUS_EXPR:
2803 case WIDEN_SUM_EXPR:
2804 case WIDEN_MULT_EXPR:
2805 case MULT_EXPR:
2806 case MULT_HIGHPART_EXPR:
2807 case PLUS_EXPR:
2808 case POINTER_PLUS_EXPR:
2809 case POINTER_DIFF_EXPR:
2810 case MINUS_EXPR:
2811 case TRUNC_DIV_EXPR:
2812 case CEIL_DIV_EXPR:
2813 case FLOOR_DIV_EXPR:
2814 case ROUND_DIV_EXPR:
2815 case TRUNC_MOD_EXPR:
2816 case CEIL_MOD_EXPR:
2817 case FLOOR_MOD_EXPR:
2818 case ROUND_MOD_EXPR:
2819 case RDIV_EXPR:
2820 case EXACT_DIV_EXPR:
2821 case LSHIFT_EXPR:
2822 case RSHIFT_EXPR:
2823 case LROTATE_EXPR:
2824 case RROTATE_EXPR:
2825 case WIDEN_LSHIFT_EXPR:
2826 case BIT_IOR_EXPR:
2827 case BIT_XOR_EXPR:
2828 case BIT_AND_EXPR:
2829 case TRUTH_ANDIF_EXPR:
2830 case TRUTH_ORIF_EXPR:
2831 case TRUTH_AND_EXPR:
2832 case TRUTH_OR_EXPR:
2833 case TRUTH_XOR_EXPR:
2834 case LT_EXPR:
2835 case LE_EXPR:
2836 case GT_EXPR:
2837 case GE_EXPR:
2838 case EQ_EXPR:
2839 case NE_EXPR:
2840 case UNLT_EXPR:
2841 case UNLE_EXPR:
2842 case UNGT_EXPR:
2843 case UNGE_EXPR:
2844 case UNEQ_EXPR:
2845 case LTGT_EXPR:
2846 case ORDERED_EXPR:
2847 case UNORDERED_EXPR:
2849 const char *op = op_symbol (node);
2850 op0 = TREE_OPERAND (node, 0);
2851 op1 = TREE_OPERAND (node, 1);
2853 /* When the operands are expressions with less priority,
2854 keep semantics of the tree representation. */
2855 if (op_prio (op0) <= op_prio (node))
2857 pp_left_paren (pp);
2858 dump_generic_node (pp, op0, spc, flags, false);
2859 pp_right_paren (pp);
2861 else
2862 dump_generic_node (pp, op0, spc, flags, false);
2864 pp_space (pp);
2865 pp_string (pp, op);
2866 pp_space (pp);
2868 /* When the operands are expressions with less priority,
2869 keep semantics of the tree representation. */
2870 if (op_prio (op1) <= op_prio (node))
2872 pp_left_paren (pp);
2873 dump_generic_node (pp, op1, spc, flags, false);
2874 pp_right_paren (pp);
2876 else
2877 dump_generic_node (pp, op1, spc, flags, false);
2879 break;
2881 /* Unary arithmetic and logic expressions. */
2882 case ADDR_EXPR:
2883 if (flags & TDF_GIMPLE_VAL)
2885 pp_string (pp, "_Literal (");
2886 dump_generic_node (pp, TREE_TYPE (node), spc,
2887 flags & ~TDF_GIMPLE_VAL, false);
2888 pp_character (pp, ')');
2890 /* Fallthru. */
2891 case NEGATE_EXPR:
2892 case BIT_NOT_EXPR:
2893 case TRUTH_NOT_EXPR:
2894 case PREDECREMENT_EXPR:
2895 case PREINCREMENT_EXPR:
2896 case INDIRECT_REF:
2897 if (!(flags & TDF_GIMPLE)
2898 && TREE_CODE (node) == ADDR_EXPR
2899 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2900 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2901 /* Do not output '&' for strings and function pointers when not
2902 dumping GIMPLE FE syntax. */
2904 else
2905 pp_string (pp, op_symbol (node));
2907 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2909 pp_left_paren (pp);
2910 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2911 pp_right_paren (pp);
2913 else
2914 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2915 break;
2917 case POSTDECREMENT_EXPR:
2918 case POSTINCREMENT_EXPR:
2919 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2921 pp_left_paren (pp);
2922 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2923 pp_right_paren (pp);
2925 else
2926 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2927 pp_string (pp, op_symbol (node));
2928 break;
2930 case MIN_EXPR:
2931 pp_string (pp, "MIN_EXPR <");
2932 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2933 pp_string (pp, ", ");
2934 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2935 pp_greater (pp);
2936 break;
2938 case MAX_EXPR:
2939 pp_string (pp, "MAX_EXPR <");
2940 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2941 pp_string (pp, ", ");
2942 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2943 pp_greater (pp);
2944 break;
2946 case ABS_EXPR:
2947 pp_string (pp, "ABS_EXPR <");
2948 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2949 pp_greater (pp);
2950 break;
2952 case ABSU_EXPR:
2953 pp_string (pp, "ABSU_EXPR <");
2954 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2955 pp_greater (pp);
2956 break;
2958 case RANGE_EXPR:
2959 NIY;
2960 break;
2962 case ADDR_SPACE_CONVERT_EXPR:
2963 case FIXED_CONVERT_EXPR:
2964 case FIX_TRUNC_EXPR:
2965 case FLOAT_EXPR:
2966 CASE_CONVERT:
2967 type = TREE_TYPE (node);
2968 op0 = TREE_OPERAND (node, 0);
2969 if (type != TREE_TYPE (op0))
2971 pp_left_paren (pp);
2972 dump_generic_node (pp, type, spc, flags, false);
2973 pp_string (pp, ") ");
2975 if (op_prio (op0) < op_prio (node))
2976 pp_left_paren (pp);
2977 dump_generic_node (pp, op0, spc, flags, false);
2978 if (op_prio (op0) < op_prio (node))
2979 pp_right_paren (pp);
2980 break;
2982 case VIEW_CONVERT_EXPR:
2983 if (flags & TDF_GIMPLE)
2984 pp_string (pp, "__VIEW_CONVERT <");
2985 else
2986 pp_string (pp, "VIEW_CONVERT_EXPR<");
2987 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2988 pp_string (pp, ">(");
2989 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2990 pp_right_paren (pp);
2991 break;
2993 case PAREN_EXPR:
2994 pp_string (pp, "((");
2995 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2996 pp_string (pp, "))");
2997 break;
2999 case NON_LVALUE_EXPR:
3000 pp_string (pp, "NON_LVALUE_EXPR <");
3001 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3002 pp_greater (pp);
3003 break;
3005 case SAVE_EXPR:
3006 pp_string (pp, "SAVE_EXPR <");
3007 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3008 pp_greater (pp);
3009 break;
3011 case COMPLEX_EXPR:
3012 pp_string (pp, "COMPLEX_EXPR <");
3013 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3014 pp_string (pp, ", ");
3015 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3016 pp_greater (pp);
3017 break;
3019 case CONJ_EXPR:
3020 pp_string (pp, "CONJ_EXPR <");
3021 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3022 pp_greater (pp);
3023 break;
3025 case REALPART_EXPR:
3026 if (flags & TDF_GIMPLE)
3028 pp_string (pp, "__real ");
3029 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3031 else
3033 pp_string (pp, "REALPART_EXPR <");
3034 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3035 pp_greater (pp);
3037 break;
3039 case IMAGPART_EXPR:
3040 if (flags & TDF_GIMPLE)
3042 pp_string (pp, "__imag ");
3043 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3045 else
3047 pp_string (pp, "IMAGPART_EXPR <");
3048 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3049 pp_greater (pp);
3051 break;
3053 case VA_ARG_EXPR:
3054 pp_string (pp, "VA_ARG_EXPR <");
3055 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3056 pp_greater (pp);
3057 break;
3059 case TRY_FINALLY_EXPR:
3060 case TRY_CATCH_EXPR:
3061 pp_string (pp, "try");
3062 newline_and_indent (pp, spc+2);
3063 pp_left_brace (pp);
3064 newline_and_indent (pp, spc+4);
3065 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
3066 newline_and_indent (pp, spc+2);
3067 pp_right_brace (pp);
3068 newline_and_indent (pp, spc);
3069 if (TREE_CODE (node) == TRY_CATCH_EXPR)
3071 node = TREE_OPERAND (node, 1);
3072 pp_string (pp, "catch");
3074 else
3076 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
3077 node = TREE_OPERAND (node, 1);
3078 pp_string (pp, "finally");
3079 if (TREE_CODE (node) == EH_ELSE_EXPR)
3081 newline_and_indent (pp, spc+2);
3082 pp_left_brace (pp);
3083 newline_and_indent (pp, spc+4);
3084 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
3085 flags, true);
3086 newline_and_indent (pp, spc+2);
3087 pp_right_brace (pp);
3088 newline_and_indent (pp, spc);
3089 node = TREE_OPERAND (node, 1);
3090 pp_string (pp, "else");
3093 newline_and_indent (pp, spc+2);
3094 pp_left_brace (pp);
3095 newline_and_indent (pp, spc+4);
3096 dump_generic_node (pp, node, spc+4, flags, true);
3097 newline_and_indent (pp, spc+2);
3098 pp_right_brace (pp);
3099 is_expr = false;
3100 break;
3102 case CATCH_EXPR:
3103 pp_string (pp, "catch (");
3104 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
3105 pp_right_paren (pp);
3106 newline_and_indent (pp, spc+2);
3107 pp_left_brace (pp);
3108 newline_and_indent (pp, spc+4);
3109 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
3110 newline_and_indent (pp, spc+2);
3111 pp_right_brace (pp);
3112 is_expr = false;
3113 break;
3115 case EH_FILTER_EXPR:
3116 pp_string (pp, "<<<eh_filter (");
3117 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
3118 pp_string (pp, ")>>>");
3119 newline_and_indent (pp, spc+2);
3120 pp_left_brace (pp);
3121 newline_and_indent (pp, spc+4);
3122 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
3123 newline_and_indent (pp, spc+2);
3124 pp_right_brace (pp);
3125 is_expr = false;
3126 break;
3128 case LABEL_EXPR:
3129 op0 = TREE_OPERAND (node, 0);
3130 /* If this is for break or continue, don't bother printing it. */
3131 if (DECL_NAME (op0))
3133 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3134 if (strcmp (name, "break") == 0
3135 || strcmp (name, "continue") == 0)
3136 break;
3138 dump_generic_node (pp, op0, spc, flags, false);
3139 pp_colon (pp);
3140 if (DECL_NONLOCAL (op0))
3141 pp_string (pp, " [non-local]");
3142 break;
3144 case LOOP_EXPR:
3145 pp_string (pp, "while (1)");
3146 if (!(flags & TDF_SLIM))
3148 newline_and_indent (pp, spc+2);
3149 pp_left_brace (pp);
3150 newline_and_indent (pp, spc+4);
3151 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
3152 newline_and_indent (pp, spc+2);
3153 pp_right_brace (pp);
3155 is_expr = false;
3156 break;
3158 case PREDICT_EXPR:
3159 pp_string (pp, "// predicted ");
3160 if (PREDICT_EXPR_OUTCOME (node))
3161 pp_string (pp, "likely by ");
3162 else
3163 pp_string (pp, "unlikely by ");
3164 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
3165 pp_string (pp, " predictor.");
3166 break;
3168 case ANNOTATE_EXPR:
3169 pp_string (pp, "ANNOTATE_EXPR <");
3170 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3171 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
3173 case annot_expr_ivdep_kind:
3174 pp_string (pp, ", ivdep");
3175 break;
3176 case annot_expr_unroll_kind:
3178 pp_string (pp, ", unroll ");
3179 pp_decimal_int (pp,
3180 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
3181 break;
3183 case annot_expr_no_vector_kind:
3184 pp_string (pp, ", no-vector");
3185 break;
3186 case annot_expr_vector_kind:
3187 pp_string (pp, ", vector");
3188 break;
3189 case annot_expr_parallel_kind:
3190 pp_string (pp, ", parallel");
3191 break;
3192 default:
3193 gcc_unreachable ();
3195 pp_greater (pp);
3196 break;
3198 case RETURN_EXPR:
3199 pp_string (pp, "return");
3200 op0 = TREE_OPERAND (node, 0);
3201 if (op0)
3203 pp_space (pp);
3204 if (TREE_CODE (op0) == MODIFY_EXPR)
3205 dump_generic_node (pp, TREE_OPERAND (op0, 1),
3206 spc, flags, false);
3207 else
3208 dump_generic_node (pp, op0, spc, flags, false);
3210 break;
3212 case EXIT_EXPR:
3213 pp_string (pp, "if (");
3214 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3215 pp_string (pp, ") break");
3216 break;
3218 case SWITCH_EXPR:
3219 pp_string (pp, "switch (");
3220 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3221 pp_right_paren (pp);
3222 if (!(flags & TDF_SLIM))
3224 newline_and_indent (pp, spc+2);
3225 pp_left_brace (pp);
3226 if (SWITCH_BODY (node))
3228 newline_and_indent (pp, spc+4);
3229 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3230 true);
3232 newline_and_indent (pp, spc+2);
3233 pp_right_brace (pp);
3235 is_expr = false;
3236 break;
3238 case GOTO_EXPR:
3239 op0 = GOTO_DESTINATION (node);
3240 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3242 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3243 if (strcmp (name, "break") == 0
3244 || strcmp (name, "continue") == 0)
3246 pp_string (pp, name);
3247 break;
3250 pp_string (pp, "goto ");
3251 dump_generic_node (pp, op0, spc, flags, false);
3252 break;
3254 case ASM_EXPR:
3255 pp_string (pp, "__asm__");
3256 if (ASM_VOLATILE_P (node))
3257 pp_string (pp, " __volatile__");
3258 pp_left_paren (pp);
3259 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3260 pp_colon (pp);
3261 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3262 pp_colon (pp);
3263 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3264 if (ASM_CLOBBERS (node))
3266 pp_colon (pp);
3267 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3269 pp_right_paren (pp);
3270 break;
3272 case CASE_LABEL_EXPR:
3273 if (CASE_LOW (node) && CASE_HIGH (node))
3275 pp_string (pp, "case ");
3276 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3277 pp_string (pp, " ... ");
3278 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3280 else if (CASE_LOW (node))
3282 pp_string (pp, "case ");
3283 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3285 else
3286 pp_string (pp, "default");
3287 pp_colon (pp);
3288 break;
3290 case OBJ_TYPE_REF:
3291 pp_string (pp, "OBJ_TYPE_REF(");
3292 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3293 pp_semicolon (pp);
3294 /* We omit the class type for -fcompare-debug because we may
3295 drop TYPE_BINFO early depending on debug info, and then
3296 virtual_method_call_p would return false, whereas when
3297 TYPE_BINFO is preserved it may still return true and then
3298 we'd print the class type. Compare tree and rtl dumps for
3299 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3300 for example, at occurrences of OBJ_TYPE_REF. */
3301 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3302 && virtual_method_call_p (node, true))
3304 pp_string (pp, "(");
3305 dump_generic_node (pp, obj_type_ref_class (node, true),
3306 spc, flags, false);
3307 pp_string (pp, ")");
3309 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3310 pp_arrow (pp);
3311 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3312 pp_right_paren (pp);
3313 break;
3315 case SSA_NAME:
3316 if (SSA_NAME_IDENTIFIER (node))
3318 if ((flags & TDF_NOUID)
3319 && SSA_NAME_VAR (node)
3320 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3321 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3322 else if (! (flags & TDF_GIMPLE)
3323 || SSA_NAME_VAR (node))
3324 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3325 spc, flags, false);
3327 pp_underscore (pp);
3328 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3329 if (SSA_NAME_IS_DEFAULT_DEF (node))
3330 pp_string (pp, "(D)");
3331 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3332 pp_string (pp, "(ab)");
3333 break;
3335 case WITH_SIZE_EXPR:
3336 pp_string (pp, "WITH_SIZE_EXPR <");
3337 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3338 pp_string (pp, ", ");
3339 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3340 pp_greater (pp);
3341 break;
3343 case ASSERT_EXPR:
3344 pp_string (pp, "ASSERT_EXPR <");
3345 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3346 pp_string (pp, ", ");
3347 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3348 pp_greater (pp);
3349 break;
3351 case SCEV_KNOWN:
3352 pp_string (pp, "scev_known");
3353 break;
3355 case SCEV_NOT_KNOWN:
3356 pp_string (pp, "scev_not_known");
3357 break;
3359 case POLYNOMIAL_CHREC:
3360 pp_left_brace (pp);
3361 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3362 pp_string (pp, ", +, ");
3363 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3364 pp_string (pp, "}_");
3365 pp_scalar (pp, "%u", CHREC_VARIABLE (node));
3366 is_stmt = false;
3367 break;
3369 case REALIGN_LOAD_EXPR:
3370 pp_string (pp, "REALIGN_LOAD <");
3371 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3372 pp_string (pp, ", ");
3373 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3374 pp_string (pp, ", ");
3375 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3376 pp_greater (pp);
3377 break;
3379 case VEC_COND_EXPR:
3380 pp_string (pp, " VEC_COND_EXPR < ");
3381 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3382 pp_string (pp, " , ");
3383 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3384 pp_string (pp, " , ");
3385 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3386 pp_string (pp, " > ");
3387 break;
3389 case VEC_PERM_EXPR:
3390 pp_string (pp, " VEC_PERM_EXPR < ");
3391 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3392 pp_string (pp, " , ");
3393 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3394 pp_string (pp, " , ");
3395 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3396 pp_string (pp, " > ");
3397 break;
3399 case DOT_PROD_EXPR:
3400 pp_string (pp, " DOT_PROD_EXPR < ");
3401 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3402 pp_string (pp, ", ");
3403 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3404 pp_string (pp, ", ");
3405 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3406 pp_string (pp, " > ");
3407 break;
3409 case WIDEN_MULT_PLUS_EXPR:
3410 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3411 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3412 pp_string (pp, ", ");
3413 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3414 pp_string (pp, ", ");
3415 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3416 pp_string (pp, " > ");
3417 break;
3419 case WIDEN_MULT_MINUS_EXPR:
3420 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3421 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3422 pp_string (pp, ", ");
3423 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3424 pp_string (pp, ", ");
3425 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3426 pp_string (pp, " > ");
3427 break;
3429 case OACC_PARALLEL:
3430 pp_string (pp, "#pragma acc parallel");
3431 goto dump_omp_clauses_body;
3433 case OACC_KERNELS:
3434 pp_string (pp, "#pragma acc kernels");
3435 goto dump_omp_clauses_body;
3437 case OACC_SERIAL:
3438 pp_string (pp, "#pragma acc serial");
3439 goto dump_omp_clauses_body;
3441 case OACC_DATA:
3442 pp_string (pp, "#pragma acc data");
3443 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3444 goto dump_omp_body;
3446 case OACC_HOST_DATA:
3447 pp_string (pp, "#pragma acc host_data");
3448 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3449 goto dump_omp_body;
3451 case OACC_DECLARE:
3452 pp_string (pp, "#pragma acc declare");
3453 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3454 break;
3456 case OACC_UPDATE:
3457 pp_string (pp, "#pragma acc update");
3458 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3459 break;
3461 case OACC_ENTER_DATA:
3462 pp_string (pp, "#pragma acc enter data");
3463 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3464 break;
3466 case OACC_EXIT_DATA:
3467 pp_string (pp, "#pragma acc exit data");
3468 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3469 break;
3471 case OACC_CACHE:
3472 pp_string (pp, "#pragma acc cache");
3473 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3474 break;
3476 case OMP_PARALLEL:
3477 pp_string (pp, "#pragma omp parallel");
3478 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3479 goto dump_omp_body;
3481 dump_omp_clauses_body:
3482 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3483 goto dump_omp_body;
3485 dump_omp_body:
3486 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3488 newline_and_indent (pp, spc + 2);
3489 pp_left_brace (pp);
3490 newline_and_indent (pp, spc + 4);
3491 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3492 newline_and_indent (pp, spc + 2);
3493 pp_right_brace (pp);
3495 is_expr = false;
3496 break;
3498 case OMP_TASK:
3499 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3500 : "#pragma omp taskwait");
3501 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3502 goto dump_omp_body;
3504 case OMP_FOR:
3505 pp_string (pp, "#pragma omp for");
3506 goto dump_omp_loop;
3508 case OMP_SIMD:
3509 pp_string (pp, "#pragma omp simd");
3510 goto dump_omp_loop;
3512 case OMP_DISTRIBUTE:
3513 pp_string (pp, "#pragma omp distribute");
3514 goto dump_omp_loop;
3516 case OMP_TASKLOOP:
3517 pp_string (pp, "#pragma omp taskloop");
3518 goto dump_omp_loop;
3520 case OMP_LOOP:
3521 pp_string (pp, "#pragma omp loop");
3522 goto dump_omp_loop;
3524 case OACC_LOOP:
3525 pp_string (pp, "#pragma acc loop");
3526 goto dump_omp_loop;
3528 case OMP_TEAMS:
3529 pp_string (pp, "#pragma omp teams");
3530 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3531 goto dump_omp_body;
3533 case OMP_TARGET_DATA:
3534 pp_string (pp, "#pragma omp target data");
3535 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3536 goto dump_omp_body;
3538 case OMP_TARGET_ENTER_DATA:
3539 pp_string (pp, "#pragma omp target enter data");
3540 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3541 is_expr = false;
3542 break;
3544 case OMP_TARGET_EXIT_DATA:
3545 pp_string (pp, "#pragma omp target exit data");
3546 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3547 is_expr = false;
3548 break;
3550 case OMP_TARGET:
3551 pp_string (pp, "#pragma omp target");
3552 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3553 goto dump_omp_body;
3555 case OMP_TARGET_UPDATE:
3556 pp_string (pp, "#pragma omp target update");
3557 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3558 is_expr = false;
3559 break;
3561 dump_omp_loop:
3562 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3563 if (!(flags & TDF_SLIM))
3565 int i;
3567 if (OMP_FOR_PRE_BODY (node))
3569 newline_and_indent (pp, spc + 2);
3570 pp_left_brace (pp);
3571 spc += 4;
3572 newline_and_indent (pp, spc);
3573 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3574 spc, flags, false);
3576 if (OMP_FOR_INIT (node))
3578 spc -= 2;
3579 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3581 spc += 2;
3582 newline_and_indent (pp, spc);
3583 pp_string (pp, "for (");
3584 tree init = TREE_VEC_ELT (OMP_FOR_INIT (node), i);
3585 if (TREE_CODE (init) != MODIFY_EXPR
3586 || TREE_CODE (TREE_OPERAND (init, 1)) != TREE_VEC)
3587 dump_generic_node (pp, init, spc, flags, false);
3588 else
3590 dump_generic_node (pp, TREE_OPERAND (init, 0),
3591 spc, flags, false);
3592 pp_string (pp, " = ");
3593 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (init, 1),
3594 spc, flags);
3596 pp_string (pp, "; ");
3597 tree cond = TREE_VEC_ELT (OMP_FOR_COND (node), i);
3598 if (!COMPARISON_CLASS_P (cond)
3599 || TREE_CODE (TREE_OPERAND (cond, 1)) != TREE_VEC)
3600 dump_generic_node (pp, cond, spc, flags, false);
3601 else
3603 dump_generic_node (pp, TREE_OPERAND (cond, 0),
3604 spc, flags, false);
3605 const char *op = op_symbol (cond);
3606 pp_space (pp);
3607 pp_string (pp, op);
3608 pp_space (pp);
3609 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (cond, 1),
3610 spc, flags);
3612 pp_string (pp, "; ");
3613 dump_generic_node (pp,
3614 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3615 spc, flags, false);
3616 pp_right_paren (pp);
3619 if (OMP_FOR_BODY (node))
3621 newline_and_indent (pp, spc + 2);
3622 pp_left_brace (pp);
3623 newline_and_indent (pp, spc + 4);
3624 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3625 false);
3626 newline_and_indent (pp, spc + 2);
3627 pp_right_brace (pp);
3629 if (OMP_FOR_INIT (node))
3630 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3631 if (OMP_FOR_PRE_BODY (node))
3633 spc -= 4;
3634 newline_and_indent (pp, spc + 2);
3635 pp_right_brace (pp);
3638 is_expr = false;
3639 break;
3641 case OMP_SECTIONS:
3642 pp_string (pp, "#pragma omp sections");
3643 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3644 goto dump_omp_body;
3646 case OMP_SECTION:
3647 pp_string (pp, "#pragma omp section");
3648 goto dump_omp_body;
3650 case OMP_SCAN:
3651 if (OMP_SCAN_CLAUSES (node))
3653 pp_string (pp, "#pragma omp scan");
3654 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3656 goto dump_omp_body;
3658 case OMP_MASTER:
3659 pp_string (pp, "#pragma omp master");
3660 goto dump_omp_body;
3662 case OMP_MASKED:
3663 pp_string (pp, "#pragma omp masked");
3664 dump_omp_clauses (pp, OMP_MASKED_CLAUSES (node), spc, flags);
3665 goto dump_omp_body;
3667 case OMP_TASKGROUP:
3668 pp_string (pp, "#pragma omp taskgroup");
3669 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3670 goto dump_omp_body;
3672 case OMP_ORDERED:
3673 pp_string (pp, "#pragma omp ordered");
3674 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3675 goto dump_omp_body;
3677 case OMP_CRITICAL:
3678 pp_string (pp, "#pragma omp critical");
3679 if (OMP_CRITICAL_NAME (node))
3681 pp_space (pp);
3682 pp_left_paren (pp);
3683 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3684 flags, false);
3685 pp_right_paren (pp);
3687 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3688 goto dump_omp_body;
3690 case OMP_ATOMIC:
3691 pp_string (pp, "#pragma omp atomic");
3692 if (OMP_ATOMIC_WEAK (node))
3693 pp_string (pp, " weak");
3694 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3695 newline_and_indent (pp, spc + 2);
3696 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3697 pp_space (pp);
3698 pp_equal (pp);
3699 pp_space (pp);
3700 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3701 break;
3703 case OMP_ATOMIC_READ:
3704 pp_string (pp, "#pragma omp atomic read");
3705 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3706 newline_and_indent (pp, spc + 2);
3707 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3708 pp_space (pp);
3709 break;
3711 case OMP_ATOMIC_CAPTURE_OLD:
3712 case OMP_ATOMIC_CAPTURE_NEW:
3713 pp_string (pp, "#pragma omp atomic capture");
3714 if (OMP_ATOMIC_WEAK (node))
3715 pp_string (pp, " weak");
3716 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3717 newline_and_indent (pp, spc + 2);
3718 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3719 pp_space (pp);
3720 pp_equal (pp);
3721 pp_space (pp);
3722 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3723 break;
3725 case OMP_SINGLE:
3726 pp_string (pp, "#pragma omp single");
3727 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3728 goto dump_omp_body;
3730 case OMP_SCOPE:
3731 pp_string (pp, "#pragma omp scope");
3732 dump_omp_clauses (pp, OMP_SCOPE_CLAUSES (node), spc, flags);
3733 goto dump_omp_body;
3735 case OMP_CLAUSE:
3736 /* If we come here, we're dumping something that's not an OMP construct,
3737 for example, OMP clauses attached to a function's '__attribute__'.
3738 Dump the whole OMP clause chain. */
3739 dump_omp_clauses (pp, node, spc, flags, false);
3740 is_expr = false;
3741 break;
3743 case TRANSACTION_EXPR:
3744 if (TRANSACTION_EXPR_OUTER (node))
3745 pp_string (pp, "__transaction_atomic [[outer]]");
3746 else if (TRANSACTION_EXPR_RELAXED (node))
3747 pp_string (pp, "__transaction_relaxed");
3748 else
3749 pp_string (pp, "__transaction_atomic");
3750 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3752 newline_and_indent (pp, spc);
3753 pp_left_brace (pp);
3754 newline_and_indent (pp, spc + 2);
3755 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3756 spc + 2, flags, false);
3757 newline_and_indent (pp, spc);
3758 pp_right_brace (pp);
3760 is_expr = false;
3761 break;
3763 case VEC_SERIES_EXPR:
3764 case VEC_WIDEN_MULT_HI_EXPR:
3765 case VEC_WIDEN_MULT_LO_EXPR:
3766 case VEC_WIDEN_PLUS_HI_EXPR:
3767 case VEC_WIDEN_PLUS_LO_EXPR:
3768 case VEC_WIDEN_MINUS_HI_EXPR:
3769 case VEC_WIDEN_MINUS_LO_EXPR:
3770 case VEC_WIDEN_MULT_EVEN_EXPR:
3771 case VEC_WIDEN_MULT_ODD_EXPR:
3772 case VEC_WIDEN_LSHIFT_HI_EXPR:
3773 case VEC_WIDEN_LSHIFT_LO_EXPR:
3774 pp_space (pp);
3775 for (str = get_tree_code_name (code); *str; str++)
3776 pp_character (pp, TOUPPER (*str));
3777 pp_string (pp, " < ");
3778 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3779 pp_string (pp, ", ");
3780 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3781 pp_string (pp, " > ");
3782 break;
3784 case VEC_DUPLICATE_EXPR:
3785 pp_space (pp);
3786 for (str = get_tree_code_name (code); *str; str++)
3787 pp_character (pp, TOUPPER (*str));
3788 pp_string (pp, " < ");
3789 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3790 pp_string (pp, " > ");
3791 break;
3793 case VEC_UNPACK_HI_EXPR:
3794 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3795 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3796 pp_string (pp, " > ");
3797 break;
3799 case VEC_UNPACK_LO_EXPR:
3800 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3801 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3802 pp_string (pp, " > ");
3803 break;
3805 case VEC_UNPACK_FLOAT_HI_EXPR:
3806 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3807 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3808 pp_string (pp, " > ");
3809 break;
3811 case VEC_UNPACK_FLOAT_LO_EXPR:
3812 pp_string (pp, " VEC_UNPACK_FLOAT_LO_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_HI_EXPR:
3818 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3819 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3820 pp_string (pp, " > ");
3821 break;
3823 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3824 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3825 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3826 pp_string (pp, " > ");
3827 break;
3829 case VEC_PACK_TRUNC_EXPR:
3830 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3831 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3832 pp_string (pp, ", ");
3833 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3834 pp_string (pp, " > ");
3835 break;
3837 case VEC_PACK_SAT_EXPR:
3838 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3839 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3840 pp_string (pp, ", ");
3841 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3842 pp_string (pp, " > ");
3843 break;
3845 case VEC_PACK_FIX_TRUNC_EXPR:
3846 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3847 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3848 pp_string (pp, ", ");
3849 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3850 pp_string (pp, " > ");
3851 break;
3853 case VEC_PACK_FLOAT_EXPR:
3854 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3855 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3856 pp_string (pp, ", ");
3857 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3858 pp_string (pp, " > ");
3859 break;
3861 case BLOCK:
3862 dump_block_node (pp, node, spc, flags);
3863 break;
3865 case DEBUG_BEGIN_STMT:
3866 pp_string (pp, "# DEBUG BEGIN STMT");
3867 break;
3869 default:
3870 NIY;
3873 if (is_stmt && is_expr)
3874 pp_semicolon (pp);
3876 return spc;
3879 /* Print the declaration of a variable. */
3881 void
3882 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3884 INDENT (spc);
3886 if (TREE_CODE(t) == NAMELIST_DECL)
3888 pp_string(pp, "namelist ");
3889 dump_decl_name (pp, t, flags);
3890 pp_semicolon (pp);
3891 return;
3894 if (TREE_CODE (t) == TYPE_DECL)
3895 pp_string (pp, "typedef ");
3897 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3898 pp_string (pp, "register ");
3900 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3901 pp_string (pp, "extern ");
3902 else if (TREE_STATIC (t))
3903 pp_string (pp, "static ");
3905 /* Print the type and name. */
3906 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3908 tree tmp;
3910 /* Print array's type. */
3911 tmp = TREE_TYPE (t);
3912 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3913 tmp = TREE_TYPE (tmp);
3914 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3916 /* Print variable's name. */
3917 pp_space (pp);
3918 dump_generic_node (pp, t, spc, flags, false);
3920 /* Print the dimensions. */
3921 tmp = TREE_TYPE (t);
3922 while (TREE_CODE (tmp) == ARRAY_TYPE)
3924 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3925 tmp = TREE_TYPE (tmp);
3928 else if (TREE_CODE (t) == FUNCTION_DECL)
3930 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3931 pp_space (pp);
3932 dump_decl_name (pp, t, flags);
3933 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3935 else
3937 /* Print type declaration. */
3938 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3940 /* Print variable's name. */
3941 pp_space (pp);
3942 dump_generic_node (pp, t, spc, flags, false);
3945 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3947 pp_string (pp, " __asm__ ");
3948 pp_left_paren (pp);
3949 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3950 pp_right_paren (pp);
3953 /* The initial value of a function serves to determine whether the function
3954 is declared or defined. So the following does not apply to function
3955 nodes. */
3956 if (TREE_CODE (t) != FUNCTION_DECL)
3958 /* Print the initial value. */
3959 if (DECL_INITIAL (t))
3961 pp_space (pp);
3962 pp_equal (pp);
3963 pp_space (pp);
3964 if (!(flags & TDF_SLIM))
3965 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3966 else
3967 pp_string (pp, "<<< omitted >>>");
3971 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3973 pp_string (pp, " [value-expr: ");
3974 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3975 pp_right_bracket (pp);
3978 pp_semicolon (pp);
3982 /* Prints a structure: name, fields, and methods.
3983 FIXME: Still incomplete. */
3985 static void
3986 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3987 dump_flags_t flags)
3989 /* Print the name of the structure. */
3990 if (TYPE_NAME (node))
3992 INDENT (spc);
3993 if (TREE_CODE (node) == RECORD_TYPE)
3994 pp_string (pp, "struct ");
3995 else if ((TREE_CODE (node) == UNION_TYPE
3996 || TREE_CODE (node) == QUAL_UNION_TYPE))
3997 pp_string (pp, "union ");
3999 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
4002 /* Print the contents of the structure. */
4003 pp_newline (pp);
4004 INDENT (spc);
4005 pp_left_brace (pp);
4006 pp_newline (pp);
4008 /* Print the fields of the structure. */
4010 tree tmp;
4011 tmp = TYPE_FIELDS (node);
4012 while (tmp)
4014 /* Avoid to print recursively the structure. */
4015 /* FIXME : Not implemented correctly...,
4016 what about the case when we have a cycle in the contain graph? ...
4017 Maybe this could be solved by looking at the scope in which the
4018 structure was declared. */
4019 if (TREE_TYPE (tmp) != node
4020 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
4021 || TREE_TYPE (TREE_TYPE (tmp)) != node))
4023 print_declaration (pp, tmp, spc+2, flags);
4024 pp_newline (pp);
4026 tmp = DECL_CHAIN (tmp);
4029 INDENT (spc);
4030 pp_right_brace (pp);
4033 /* Return the priority of the operator CODE.
4035 From lowest to highest precedence with either left-to-right (L-R)
4036 or right-to-left (R-L) associativity]:
4038 1 [L-R] ,
4039 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
4040 3 [R-L] ?:
4041 4 [L-R] ||
4042 5 [L-R] &&
4043 6 [L-R] |
4044 7 [L-R] ^
4045 8 [L-R] &
4046 9 [L-R] == !=
4047 10 [L-R] < <= > >=
4048 11 [L-R] << >>
4049 12 [L-R] + -
4050 13 [L-R] * / %
4051 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
4052 15 [L-R] fn() [] -> .
4054 unary +, - and * have higher precedence than the corresponding binary
4055 operators. */
4058 op_code_prio (enum tree_code code)
4060 switch (code)
4062 case TREE_LIST:
4063 case COMPOUND_EXPR:
4064 case BIND_EXPR:
4065 return 1;
4067 case MODIFY_EXPR:
4068 case INIT_EXPR:
4069 return 2;
4071 case COND_EXPR:
4072 return 3;
4074 case TRUTH_OR_EXPR:
4075 case TRUTH_ORIF_EXPR:
4076 return 4;
4078 case TRUTH_AND_EXPR:
4079 case TRUTH_ANDIF_EXPR:
4080 return 5;
4082 case BIT_IOR_EXPR:
4083 return 6;
4085 case BIT_XOR_EXPR:
4086 case TRUTH_XOR_EXPR:
4087 return 7;
4089 case BIT_AND_EXPR:
4090 return 8;
4092 case EQ_EXPR:
4093 case NE_EXPR:
4094 return 9;
4096 case UNLT_EXPR:
4097 case UNLE_EXPR:
4098 case UNGT_EXPR:
4099 case UNGE_EXPR:
4100 case UNEQ_EXPR:
4101 case LTGT_EXPR:
4102 case ORDERED_EXPR:
4103 case UNORDERED_EXPR:
4104 case LT_EXPR:
4105 case LE_EXPR:
4106 case GT_EXPR:
4107 case GE_EXPR:
4108 return 10;
4110 case LSHIFT_EXPR:
4111 case RSHIFT_EXPR:
4112 case LROTATE_EXPR:
4113 case RROTATE_EXPR:
4114 case VEC_WIDEN_LSHIFT_HI_EXPR:
4115 case VEC_WIDEN_LSHIFT_LO_EXPR:
4116 case WIDEN_LSHIFT_EXPR:
4117 return 11;
4119 case WIDEN_SUM_EXPR:
4120 case PLUS_EXPR:
4121 case POINTER_PLUS_EXPR:
4122 case POINTER_DIFF_EXPR:
4123 case MINUS_EXPR:
4124 return 12;
4126 case VEC_WIDEN_MULT_HI_EXPR:
4127 case VEC_WIDEN_MULT_LO_EXPR:
4128 case WIDEN_MULT_EXPR:
4129 case DOT_PROD_EXPR:
4130 case WIDEN_MULT_PLUS_EXPR:
4131 case WIDEN_MULT_MINUS_EXPR:
4132 case MULT_EXPR:
4133 case MULT_HIGHPART_EXPR:
4134 case TRUNC_DIV_EXPR:
4135 case CEIL_DIV_EXPR:
4136 case FLOOR_DIV_EXPR:
4137 case ROUND_DIV_EXPR:
4138 case RDIV_EXPR:
4139 case EXACT_DIV_EXPR:
4140 case TRUNC_MOD_EXPR:
4141 case CEIL_MOD_EXPR:
4142 case FLOOR_MOD_EXPR:
4143 case ROUND_MOD_EXPR:
4144 return 13;
4146 case TRUTH_NOT_EXPR:
4147 case BIT_NOT_EXPR:
4148 case POSTINCREMENT_EXPR:
4149 case POSTDECREMENT_EXPR:
4150 case PREINCREMENT_EXPR:
4151 case PREDECREMENT_EXPR:
4152 case NEGATE_EXPR:
4153 case INDIRECT_REF:
4154 case ADDR_EXPR:
4155 case FLOAT_EXPR:
4156 CASE_CONVERT:
4157 case FIX_TRUNC_EXPR:
4158 case TARGET_EXPR:
4159 return 14;
4161 case CALL_EXPR:
4162 case ARRAY_REF:
4163 case ARRAY_RANGE_REF:
4164 case COMPONENT_REF:
4165 return 15;
4167 /* Special expressions. */
4168 case MIN_EXPR:
4169 case MAX_EXPR:
4170 case ABS_EXPR:
4171 case REALPART_EXPR:
4172 case IMAGPART_EXPR:
4173 case VEC_UNPACK_HI_EXPR:
4174 case VEC_UNPACK_LO_EXPR:
4175 case VEC_UNPACK_FLOAT_HI_EXPR:
4176 case VEC_UNPACK_FLOAT_LO_EXPR:
4177 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
4178 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
4179 case VEC_PACK_TRUNC_EXPR:
4180 case VEC_PACK_SAT_EXPR:
4181 return 16;
4183 default:
4184 /* Return an arbitrarily high precedence to avoid surrounding single
4185 VAR_DECLs in ()s. */
4186 return 9999;
4190 /* Return the priority of the operator OP. */
4193 op_prio (const_tree op)
4195 enum tree_code code;
4197 if (op == NULL)
4198 return 9999;
4200 code = TREE_CODE (op);
4201 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
4202 return op_prio (TREE_OPERAND (op, 0));
4204 return op_code_prio (code);
4207 /* Return the symbol associated with operator CODE. */
4209 const char *
4210 op_symbol_code (enum tree_code code)
4212 switch (code)
4214 case MODIFY_EXPR:
4215 return "=";
4217 case TRUTH_OR_EXPR:
4218 case TRUTH_ORIF_EXPR:
4219 return "||";
4221 case TRUTH_AND_EXPR:
4222 case TRUTH_ANDIF_EXPR:
4223 return "&&";
4225 case BIT_IOR_EXPR:
4226 return "|";
4228 case TRUTH_XOR_EXPR:
4229 case BIT_XOR_EXPR:
4230 return "^";
4232 case ADDR_EXPR:
4233 case BIT_AND_EXPR:
4234 return "&";
4236 case ORDERED_EXPR:
4237 return "ord";
4238 case UNORDERED_EXPR:
4239 return "unord";
4241 case EQ_EXPR:
4242 return "==";
4243 case UNEQ_EXPR:
4244 return "u==";
4246 case NE_EXPR:
4247 return "!=";
4249 case LT_EXPR:
4250 return "<";
4251 case UNLT_EXPR:
4252 return "u<";
4254 case LE_EXPR:
4255 return "<=";
4256 case UNLE_EXPR:
4257 return "u<=";
4259 case GT_EXPR:
4260 return ">";
4261 case UNGT_EXPR:
4262 return "u>";
4264 case GE_EXPR:
4265 return ">=";
4266 case UNGE_EXPR:
4267 return "u>=";
4269 case LTGT_EXPR:
4270 return "<>";
4272 case LSHIFT_EXPR:
4273 return "<<";
4275 case RSHIFT_EXPR:
4276 return ">>";
4278 case LROTATE_EXPR:
4279 return "r<<";
4281 case RROTATE_EXPR:
4282 return "r>>";
4284 case WIDEN_LSHIFT_EXPR:
4285 return "w<<";
4287 case WIDEN_PLUS_EXPR:
4288 return "w+";
4290 case WIDEN_MINUS_EXPR:
4291 return "w-";
4293 case POINTER_PLUS_EXPR:
4294 return "+";
4296 case PLUS_EXPR:
4297 return "+";
4299 case WIDEN_SUM_EXPR:
4300 return "w+";
4302 case WIDEN_MULT_EXPR:
4303 return "w*";
4305 case MULT_HIGHPART_EXPR:
4306 return "h*";
4308 case NEGATE_EXPR:
4309 case MINUS_EXPR:
4310 case POINTER_DIFF_EXPR:
4311 return "-";
4313 case BIT_NOT_EXPR:
4314 return "~";
4316 case TRUTH_NOT_EXPR:
4317 return "!";
4319 case MULT_EXPR:
4320 case INDIRECT_REF:
4321 return "*";
4323 case TRUNC_DIV_EXPR:
4324 case RDIV_EXPR:
4325 return "/";
4327 case CEIL_DIV_EXPR:
4328 return "/[cl]";
4330 case FLOOR_DIV_EXPR:
4331 return "/[fl]";
4333 case ROUND_DIV_EXPR:
4334 return "/[rd]";
4336 case EXACT_DIV_EXPR:
4337 return "/[ex]";
4339 case TRUNC_MOD_EXPR:
4340 return "%";
4342 case CEIL_MOD_EXPR:
4343 return "%[cl]";
4345 case FLOOR_MOD_EXPR:
4346 return "%[fl]";
4348 case ROUND_MOD_EXPR:
4349 return "%[rd]";
4351 case PREDECREMENT_EXPR:
4352 return " --";
4354 case PREINCREMENT_EXPR:
4355 return " ++";
4357 case POSTDECREMENT_EXPR:
4358 return "-- ";
4360 case POSTINCREMENT_EXPR:
4361 return "++ ";
4363 case MAX_EXPR:
4364 return "max";
4366 case MIN_EXPR:
4367 return "min";
4369 default:
4370 return "<<< ??? >>>";
4374 /* Return the symbol associated with operator OP. */
4376 static const char *
4377 op_symbol (const_tree op)
4379 return op_symbol_code (TREE_CODE (op));
4382 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4383 the gimple_call_fn of a GIMPLE_CALL. */
4385 void
4386 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4388 tree op0 = node;
4390 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4391 op0 = TREE_OPERAND (op0, 0);
4393 again:
4394 switch (TREE_CODE (op0))
4396 case VAR_DECL:
4397 case PARM_DECL:
4398 case FUNCTION_DECL:
4399 dump_function_name (pp, op0, flags);
4400 break;
4402 case ADDR_EXPR:
4403 case INDIRECT_REF:
4404 CASE_CONVERT:
4405 op0 = TREE_OPERAND (op0, 0);
4406 goto again;
4408 case COND_EXPR:
4409 pp_left_paren (pp);
4410 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4411 pp_string (pp, ") ? ");
4412 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4413 pp_string (pp, " : ");
4414 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4415 break;
4417 case ARRAY_REF:
4418 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4419 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4420 else
4421 dump_generic_node (pp, op0, 0, flags, false);
4422 break;
4424 case MEM_REF:
4425 if (integer_zerop (TREE_OPERAND (op0, 1)))
4427 op0 = TREE_OPERAND (op0, 0);
4428 goto again;
4430 /* Fallthru. */
4431 case COMPONENT_REF:
4432 case SSA_NAME:
4433 case OBJ_TYPE_REF:
4434 dump_generic_node (pp, op0, 0, flags, false);
4435 break;
4437 default:
4438 NIY;
4442 /* Print the first N characters in the array STR, replacing non-printable
4443 characters (including embedded nuls) with unambiguous escape sequences. */
4445 void
4446 pretty_print_string (pretty_printer *pp, const char *str, size_t n)
4448 if (str == NULL)
4449 return;
4451 for ( ; n; --n, ++str)
4453 switch (str[0])
4455 case '\b':
4456 pp_string (pp, "\\b");
4457 break;
4459 case '\f':
4460 pp_string (pp, "\\f");
4461 break;
4463 case '\n':
4464 pp_string (pp, "\\n");
4465 break;
4467 case '\r':
4468 pp_string (pp, "\\r");
4469 break;
4471 case '\t':
4472 pp_string (pp, "\\t");
4473 break;
4475 case '\v':
4476 pp_string (pp, "\\v");
4477 break;
4479 case '\\':
4480 pp_string (pp, "\\\\");
4481 break;
4483 case '\"':
4484 pp_string (pp, "\\\"");
4485 break;
4487 case '\'':
4488 pp_string (pp, "\\'");
4489 break;
4491 default:
4492 if (str[0] || n > 1)
4494 if (!ISPRINT (str[0]))
4496 char buf[5];
4497 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4498 pp_string (pp, buf);
4500 else
4501 pp_character (pp, str[0]);
4502 break;
4508 static void
4509 maybe_init_pretty_print (FILE *file)
4511 if (!tree_pp)
4513 tree_pp = new pretty_printer ();
4514 pp_needs_newline (tree_pp) = true;
4515 pp_translate_identifiers (tree_pp) = false;
4518 tree_pp->buffer->stream = file;
4521 static void
4522 newline_and_indent (pretty_printer *pp, int spc)
4524 pp_newline (pp);
4525 INDENT (spc);
4528 /* Print the identifier ID to PRETTY-PRINTER. */
4530 void
4531 pp_tree_identifier (pretty_printer *pp, tree id)
4533 if (pp_translate_identifiers (pp))
4535 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4536 pp_append_text (pp, text, text + strlen (text));
4538 else
4539 pp_append_text (pp, IDENTIFIER_POINTER (id),
4540 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4543 /* A helper function that is used to dump function information before the
4544 function dump. */
4546 void
4547 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4549 const char *dname, *aname;
4550 struct cgraph_node *node = cgraph_node::get (fdecl);
4551 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4553 dname = lang_hooks.decl_printable_name (fdecl, 1);
4555 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4556 aname = (IDENTIFIER_POINTER
4557 (DECL_ASSEMBLER_NAME (fdecl)));
4558 else
4559 aname = "<unset-asm-name>";
4561 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4562 dname, aname, fun->funcdef_no);
4563 if (!(flags & TDF_NOUID))
4564 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4565 if (node)
4567 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4568 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4569 node->frequency == NODE_FREQUENCY_HOT
4570 ? " (hot)"
4571 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4572 ? " (unlikely executed)"
4573 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4574 ? " (executed once)"
4575 : "");
4577 else
4578 fprintf (dump_file, ")\n\n");
4581 /* Dump double_int D to pretty_printer PP. UNS is true
4582 if D is unsigned and false otherwise. */
4583 void
4584 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4586 if (d.fits_shwi ())
4587 pp_wide_integer (pp, d.low);
4588 else if (d.fits_uhwi ())
4589 pp_unsigned_wide_integer (pp, d.low);
4590 else
4592 unsigned HOST_WIDE_INT low = d.low;
4593 HOST_WIDE_INT high = d.high;
4594 if (!uns && d.is_negative ())
4596 pp_minus (pp);
4597 high = ~high + !low;
4598 low = -low;
4600 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4601 systems? */
4602 sprintf (pp_buffer (pp)->digit_buffer,
4603 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4604 (unsigned HOST_WIDE_INT) high, low);
4605 pp_string (pp, pp_buffer (pp)->digit_buffer);
4609 #if __GNUC__ >= 10
4610 # pragma GCC diagnostic pop
4611 #endif