rs6000: inline ldouble __gcc_qsub
[official-gcc.git] / gcc / tree-pretty-print.c
blobe103d2c6bd44623b81d83a0a3798204ad34fb4a0
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)
347 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
348 else
349 dump_decl_name (pp, node, flags);
352 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
353 FLAGS are as in dump_generic_node. */
355 static void
356 dump_function_declaration (pretty_printer *pp, tree node,
357 int spc, dump_flags_t flags)
359 bool wrote_arg = false;
360 tree arg;
362 pp_space (pp);
363 pp_left_paren (pp);
365 /* Print the argument types. */
366 arg = TYPE_ARG_TYPES (node);
367 while (arg && arg != void_list_node && arg != error_mark_node)
369 if (wrote_arg)
371 pp_comma (pp);
372 pp_space (pp);
374 wrote_arg = true;
375 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
376 arg = TREE_CHAIN (arg);
379 /* Drop the trailing void_type_node if we had any previous argument. */
380 if (arg == void_list_node && !wrote_arg)
381 pp_string (pp, "void");
382 /* Properly dump vararg function types. */
383 else if (!arg && wrote_arg)
384 pp_string (pp, ", ...");
385 /* Avoid printing any arg for unprototyped functions. */
387 pp_right_paren (pp);
390 /* Dump the domain associated with an array. */
392 static void
393 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
395 pp_left_bracket (pp);
396 if (domain)
398 tree min = TYPE_MIN_VALUE (domain);
399 tree max = TYPE_MAX_VALUE (domain);
401 if (min && max
402 && integer_zerop (min)
403 && tree_fits_shwi_p (max))
404 pp_wide_integer (pp, tree_to_shwi (max) + 1);
405 else
407 if (min)
408 dump_generic_node (pp, min, spc, flags, false);
409 pp_colon (pp);
410 if (max)
411 dump_generic_node (pp, max, spc, flags, false);
414 else
415 pp_string (pp, "<unknown>");
416 pp_right_bracket (pp);
420 /* Dump OpenMP iterators ITER. */
422 static void
423 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
425 pp_string (pp, "iterator(");
426 for (tree it = iter; it; it = TREE_CHAIN (it))
428 if (it != iter)
429 pp_string (pp, ", ");
430 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
431 false);
432 pp_space (pp);
433 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
434 pp_equal (pp);
435 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
436 pp_colon (pp);
437 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
438 pp_colon (pp);
439 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
441 pp_right_paren (pp);
445 /* Dump OMP clause CLAUSE, without following OMP_CLAUSE_CHAIN.
447 PP, CLAUSE, SPC and FLAGS are as in dump_generic_node. */
449 static void
450 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
452 const char *name;
453 const char *modifier = NULL;
454 switch (OMP_CLAUSE_CODE (clause))
456 case OMP_CLAUSE_PRIVATE:
457 name = "private";
458 goto print_remap;
459 case OMP_CLAUSE_SHARED:
460 name = "shared";
461 goto print_remap;
462 case OMP_CLAUSE_FIRSTPRIVATE:
463 name = "firstprivate";
464 goto print_remap;
465 case OMP_CLAUSE_LASTPRIVATE:
466 name = "lastprivate";
467 if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
468 modifier = "conditional:";
469 goto print_remap;
470 case OMP_CLAUSE_COPYIN:
471 name = "copyin";
472 goto print_remap;
473 case OMP_CLAUSE_COPYPRIVATE:
474 name = "copyprivate";
475 goto print_remap;
476 case OMP_CLAUSE_UNIFORM:
477 name = "uniform";
478 goto print_remap;
479 case OMP_CLAUSE_USE_DEVICE_PTR:
480 name = "use_device_ptr";
481 if (OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT (clause))
482 modifier = "if_present:";
483 goto print_remap;
484 case OMP_CLAUSE_USE_DEVICE_ADDR:
485 name = "use_device_addr";
486 goto print_remap;
487 case OMP_CLAUSE_IS_DEVICE_PTR:
488 name = "is_device_ptr";
489 goto print_remap;
490 case OMP_CLAUSE_INCLUSIVE:
491 name = "inclusive";
492 goto print_remap;
493 case OMP_CLAUSE_EXCLUSIVE:
494 name = "exclusive";
495 goto print_remap;
496 case OMP_CLAUSE__LOOPTEMP_:
497 name = "_looptemp_";
498 goto print_remap;
499 case OMP_CLAUSE__REDUCTEMP_:
500 name = "_reductemp_";
501 goto print_remap;
502 case OMP_CLAUSE__CONDTEMP_:
503 name = "_condtemp_";
504 goto print_remap;
505 case OMP_CLAUSE__SCANTEMP_:
506 name = "_scantemp_";
507 goto print_remap;
508 case OMP_CLAUSE_TO_DECLARE:
509 name = "to";
510 goto print_remap;
511 case OMP_CLAUSE_LINK:
512 name = "link";
513 goto print_remap;
514 case OMP_CLAUSE_NONTEMPORAL:
515 name = "nontemporal";
516 goto print_remap;
517 print_remap:
518 pp_string (pp, name);
519 pp_left_paren (pp);
520 if (modifier)
521 pp_string (pp, modifier);
522 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
523 spc, flags, false);
524 pp_right_paren (pp);
525 break;
527 case OMP_CLAUSE_TASK_REDUCTION:
528 case OMP_CLAUSE_IN_REDUCTION:
529 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
530 ? "in_" : "task_");
531 /* FALLTHRU */
532 case OMP_CLAUSE_REDUCTION:
533 pp_string (pp, "reduction(");
534 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
536 if (OMP_CLAUSE_REDUCTION_TASK (clause))
537 pp_string (pp, "task,");
538 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
539 pp_string (pp, "inscan,");
541 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
543 pp_string (pp,
544 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
545 pp_colon (pp);
547 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
548 spc, flags, false);
549 pp_right_paren (pp);
550 break;
552 case OMP_CLAUSE_IF:
553 pp_string (pp, "if(");
554 switch (OMP_CLAUSE_IF_MODIFIER (clause))
556 case ERROR_MARK: break;
557 case VOID_CST: pp_string (pp, "cancel:"); break;
558 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
559 case OMP_SIMD: pp_string (pp, "simd:"); break;
560 case OMP_TASK: pp_string (pp, "task:"); break;
561 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
562 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
563 case OMP_TARGET: pp_string (pp, "target:"); break;
564 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
565 case OMP_TARGET_ENTER_DATA:
566 pp_string (pp, "target enter data:"); break;
567 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
568 default: gcc_unreachable ();
570 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
571 spc, flags, false);
572 pp_right_paren (pp);
573 break;
575 case OMP_CLAUSE_NUM_THREADS:
576 pp_string (pp, "num_threads(");
577 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
578 spc, flags, false);
579 pp_right_paren (pp);
580 break;
582 case OMP_CLAUSE_NOWAIT:
583 pp_string (pp, "nowait");
584 break;
585 case OMP_CLAUSE_ORDERED:
586 pp_string (pp, "ordered");
587 if (OMP_CLAUSE_ORDERED_EXPR (clause))
589 pp_left_paren (pp);
590 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
591 spc, flags, false);
592 pp_right_paren (pp);
594 break;
596 case OMP_CLAUSE_DEFAULT:
597 pp_string (pp, "default(");
598 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
600 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
601 break;
602 case OMP_CLAUSE_DEFAULT_SHARED:
603 pp_string (pp, "shared");
604 break;
605 case OMP_CLAUSE_DEFAULT_NONE:
606 pp_string (pp, "none");
607 break;
608 case OMP_CLAUSE_DEFAULT_PRIVATE:
609 pp_string (pp, "private");
610 break;
611 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
612 pp_string (pp, "firstprivate");
613 break;
614 case OMP_CLAUSE_DEFAULT_PRESENT:
615 pp_string (pp, "present");
616 break;
617 default:
618 gcc_unreachable ();
620 pp_right_paren (pp);
621 break;
623 case OMP_CLAUSE_SCHEDULE:
624 pp_string (pp, "schedule(");
625 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
626 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
627 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
629 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
630 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
631 pp_string (pp, "monotonic");
632 else
633 pp_string (pp, "nonmonotonic");
634 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
635 pp_comma (pp);
636 else
637 pp_colon (pp);
639 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
640 pp_string (pp, "simd:");
642 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
644 case OMP_CLAUSE_SCHEDULE_STATIC:
645 pp_string (pp, "static");
646 break;
647 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
648 pp_string (pp, "dynamic");
649 break;
650 case OMP_CLAUSE_SCHEDULE_GUIDED:
651 pp_string (pp, "guided");
652 break;
653 case OMP_CLAUSE_SCHEDULE_RUNTIME:
654 pp_string (pp, "runtime");
655 break;
656 case OMP_CLAUSE_SCHEDULE_AUTO:
657 pp_string (pp, "auto");
658 break;
659 default:
660 gcc_unreachable ();
662 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
664 pp_comma (pp);
665 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
666 spc, flags, false);
668 pp_right_paren (pp);
669 break;
671 case OMP_CLAUSE_UNTIED:
672 pp_string (pp, "untied");
673 break;
675 case OMP_CLAUSE_COLLAPSE:
676 pp_string (pp, "collapse(");
677 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
678 spc, flags, false);
679 pp_right_paren (pp);
680 break;
682 case OMP_CLAUSE_FINAL:
683 pp_string (pp, "final(");
684 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
685 spc, flags, false);
686 pp_right_paren (pp);
687 break;
689 case OMP_CLAUSE_MERGEABLE:
690 pp_string (pp, "mergeable");
691 break;
693 case OMP_CLAUSE_LINEAR:
694 pp_string (pp, "linear(");
695 switch (OMP_CLAUSE_LINEAR_KIND (clause))
697 case OMP_CLAUSE_LINEAR_DEFAULT:
698 break;
699 case OMP_CLAUSE_LINEAR_REF:
700 pp_string (pp, "ref(");
701 break;
702 case OMP_CLAUSE_LINEAR_VAL:
703 pp_string (pp, "val(");
704 break;
705 case OMP_CLAUSE_LINEAR_UVAL:
706 pp_string (pp, "uval(");
707 break;
708 default:
709 gcc_unreachable ();
711 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
712 spc, flags, false);
713 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
714 pp_right_paren (pp);
715 pp_colon (pp);
716 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
717 spc, flags, false);
718 pp_right_paren (pp);
719 break;
721 case OMP_CLAUSE_ALIGNED:
722 pp_string (pp, "aligned(");
723 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
724 spc, flags, false);
725 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
727 pp_colon (pp);
728 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
729 spc, flags, false);
731 pp_right_paren (pp);
732 break;
734 case OMP_CLAUSE_ALLOCATE:
735 pp_string (pp, "allocate(");
736 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
738 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause),
739 spc, flags, false);
740 pp_colon (pp);
742 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
743 spc, flags, false);
744 pp_right_paren (pp);
745 break;
747 case OMP_CLAUSE_AFFINITY:
748 pp_string (pp, "affinity(");
750 tree t = OMP_CLAUSE_DECL (clause);
751 if (TREE_CODE (t) == TREE_LIST
752 && TREE_PURPOSE (t)
753 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
755 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
756 pp_colon (pp);
757 t = TREE_VALUE (t);
759 dump_generic_node (pp, t, spc, flags, false);
761 pp_right_paren (pp);
762 break;
763 case OMP_CLAUSE_DEPEND:
764 pp_string (pp, "depend(");
765 switch (OMP_CLAUSE_DEPEND_KIND (clause))
767 case OMP_CLAUSE_DEPEND_DEPOBJ:
768 name = "depobj";
769 break;
770 case OMP_CLAUSE_DEPEND_IN:
771 name = "in";
772 break;
773 case OMP_CLAUSE_DEPEND_OUT:
774 name = "out";
775 break;
776 case OMP_CLAUSE_DEPEND_INOUT:
777 name = "inout";
778 break;
779 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
780 name = "mutexinoutset";
781 break;
782 case OMP_CLAUSE_DEPEND_SOURCE:
783 pp_string (pp, "source)");
784 return;
785 case OMP_CLAUSE_DEPEND_LAST:
786 name = "__internal__";
787 break;
788 case OMP_CLAUSE_DEPEND_SINK:
789 pp_string (pp, "sink:");
790 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
791 if (TREE_CODE (t) == TREE_LIST)
793 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
794 if (TREE_PURPOSE (t) != integer_zero_node)
796 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
797 pp_minus (pp);
798 else
799 pp_plus (pp);
800 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
801 false);
803 if (TREE_CHAIN (t))
804 pp_comma (pp);
806 else
807 gcc_unreachable ();
808 pp_right_paren (pp);
809 return;
810 default:
811 gcc_unreachable ();
814 tree t = OMP_CLAUSE_DECL (clause);
815 if (TREE_CODE (t) == TREE_LIST
816 && TREE_PURPOSE (t)
817 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
819 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
820 pp_colon (pp);
821 t = TREE_VALUE (t);
823 if (name[0])
825 pp_string (pp, name);
826 pp_colon (pp);
828 dump_generic_node (pp, t, spc, flags, false);
829 pp_right_paren (pp);
831 break;
833 case OMP_CLAUSE_MAP:
834 pp_string (pp, "map(");
835 switch (OMP_CLAUSE_MAP_KIND (clause))
837 case GOMP_MAP_ALLOC:
838 case GOMP_MAP_POINTER:
839 pp_string (pp, "alloc");
840 break;
841 case GOMP_MAP_IF_PRESENT:
842 pp_string (pp, "no_alloc");
843 break;
844 case GOMP_MAP_TO:
845 case GOMP_MAP_TO_PSET:
846 pp_string (pp, "to");
847 break;
848 case GOMP_MAP_FROM:
849 pp_string (pp, "from");
850 break;
851 case GOMP_MAP_TOFROM:
852 pp_string (pp, "tofrom");
853 break;
854 case GOMP_MAP_FORCE_ALLOC:
855 pp_string (pp, "force_alloc");
856 break;
857 case GOMP_MAP_FORCE_TO:
858 pp_string (pp, "force_to");
859 break;
860 case GOMP_MAP_FORCE_FROM:
861 pp_string (pp, "force_from");
862 break;
863 case GOMP_MAP_FORCE_TOFROM:
864 pp_string (pp, "force_tofrom");
865 break;
866 case GOMP_MAP_FORCE_PRESENT:
867 pp_string (pp, "force_present");
868 break;
869 case GOMP_MAP_DELETE:
870 pp_string (pp, "delete");
871 break;
872 case GOMP_MAP_FORCE_DEVICEPTR:
873 pp_string (pp, "force_deviceptr");
874 break;
875 case GOMP_MAP_ALWAYS_TO:
876 pp_string (pp, "always,to");
877 break;
878 case GOMP_MAP_ALWAYS_FROM:
879 pp_string (pp, "always,from");
880 break;
881 case GOMP_MAP_ALWAYS_TOFROM:
882 pp_string (pp, "always,tofrom");
883 break;
884 case GOMP_MAP_RELEASE:
885 pp_string (pp, "release");
886 break;
887 case GOMP_MAP_FIRSTPRIVATE_POINTER:
888 pp_string (pp, "firstprivate");
889 break;
890 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
891 pp_string (pp, "firstprivate ref");
892 break;
893 case GOMP_MAP_STRUCT:
894 pp_string (pp, "struct");
895 break;
896 case GOMP_MAP_ALWAYS_POINTER:
897 pp_string (pp, "always_pointer");
898 break;
899 case GOMP_MAP_DEVICE_RESIDENT:
900 pp_string (pp, "device_resident");
901 break;
902 case GOMP_MAP_LINK:
903 pp_string (pp, "link");
904 break;
905 case GOMP_MAP_ATTACH:
906 pp_string (pp, "attach");
907 break;
908 case GOMP_MAP_DETACH:
909 pp_string (pp, "detach");
910 break;
911 case GOMP_MAP_FORCE_DETACH:
912 pp_string (pp, "force_detach");
913 break;
914 case GOMP_MAP_ATTACH_DETACH:
915 pp_string (pp, "attach_detach");
916 break;
917 default:
918 gcc_unreachable ();
920 pp_colon (pp);
921 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
922 spc, flags, false);
923 print_clause_size:
924 if (OMP_CLAUSE_SIZE (clause))
926 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
927 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
929 case GOMP_MAP_POINTER:
930 case GOMP_MAP_FIRSTPRIVATE_POINTER:
931 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
932 case GOMP_MAP_ALWAYS_POINTER:
933 pp_string (pp, " [pointer assign, bias: ");
934 break;
935 case GOMP_MAP_TO_PSET:
936 pp_string (pp, " [pointer set, len: ");
937 break;
938 case GOMP_MAP_ATTACH:
939 case GOMP_MAP_DETACH:
940 case GOMP_MAP_FORCE_DETACH:
941 case GOMP_MAP_ATTACH_DETACH:
942 pp_string (pp, " [bias: ");
943 break;
944 default:
945 pp_string (pp, " [len: ");
946 break;
948 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
949 spc, flags, false);
950 pp_right_bracket (pp);
952 pp_right_paren (pp);
953 break;
955 case OMP_CLAUSE_FROM:
956 pp_string (pp, "from(");
957 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
958 spc, flags, false);
959 goto print_clause_size;
961 case OMP_CLAUSE_TO:
962 pp_string (pp, "to(");
963 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
964 spc, flags, false);
965 goto print_clause_size;
967 case OMP_CLAUSE__CACHE_:
968 pp_string (pp, "(");
969 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
970 spc, flags, false);
971 goto print_clause_size;
973 case OMP_CLAUSE_NUM_TEAMS:
974 pp_string (pp, "num_teams(");
975 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
976 spc, flags, false);
977 pp_right_paren (pp);
978 break;
980 case OMP_CLAUSE_THREAD_LIMIT:
981 pp_string (pp, "thread_limit(");
982 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
983 spc, flags, false);
984 pp_right_paren (pp);
985 break;
987 case OMP_CLAUSE_DEVICE:
988 pp_string (pp, "device(");
989 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
990 spc, flags, false);
991 pp_right_paren (pp);
992 break;
994 case OMP_CLAUSE_DIST_SCHEDULE:
995 pp_string (pp, "dist_schedule(static");
996 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
998 pp_comma (pp);
999 dump_generic_node (pp,
1000 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
1001 spc, flags, false);
1003 pp_right_paren (pp);
1004 break;
1006 case OMP_CLAUSE_PROC_BIND:
1007 pp_string (pp, "proc_bind(");
1008 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
1010 case OMP_CLAUSE_PROC_BIND_MASTER:
1011 /* Same enum value: case OMP_CLAUSE_PROC_BIND_PRIMARY: */
1012 /* TODO: Change to 'primary' for OpenMP 5.1. */
1013 pp_string (pp, "master");
1014 break;
1015 case OMP_CLAUSE_PROC_BIND_CLOSE:
1016 pp_string (pp, "close");
1017 break;
1018 case OMP_CLAUSE_PROC_BIND_SPREAD:
1019 pp_string (pp, "spread");
1020 break;
1021 default:
1022 gcc_unreachable ();
1024 pp_right_paren (pp);
1025 break;
1027 case OMP_CLAUSE_DEVICE_TYPE:
1028 pp_string (pp, "device_type(");
1029 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
1031 case OMP_CLAUSE_DEVICE_TYPE_HOST:
1032 pp_string (pp, "host");
1033 break;
1034 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
1035 pp_string (pp, "nohost");
1036 break;
1037 case OMP_CLAUSE_DEVICE_TYPE_ANY:
1038 pp_string (pp, "any");
1039 break;
1040 default:
1041 gcc_unreachable ();
1043 pp_right_paren (pp);
1044 break;
1046 case OMP_CLAUSE_SAFELEN:
1047 pp_string (pp, "safelen(");
1048 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
1049 spc, flags, false);
1050 pp_right_paren (pp);
1051 break;
1053 case OMP_CLAUSE_SIMDLEN:
1054 pp_string (pp, "simdlen(");
1055 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
1056 spc, flags, false);
1057 pp_right_paren (pp);
1058 break;
1060 case OMP_CLAUSE_PRIORITY:
1061 pp_string (pp, "priority(");
1062 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
1063 spc, flags, false);
1064 pp_right_paren (pp);
1065 break;
1067 case OMP_CLAUSE_GRAINSIZE:
1068 pp_string (pp, "grainsize(");
1069 if (OMP_CLAUSE_GRAINSIZE_STRICT (clause))
1070 pp_string (pp, "strict:");
1071 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
1072 spc, flags, false);
1073 pp_right_paren (pp);
1074 break;
1076 case OMP_CLAUSE_NUM_TASKS:
1077 pp_string (pp, "num_tasks(");
1078 if (OMP_CLAUSE_NUM_TASKS_STRICT (clause))
1079 pp_string (pp, "strict:");
1080 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1081 spc, flags, false);
1082 pp_right_paren (pp);
1083 break;
1085 case OMP_CLAUSE_HINT:
1086 pp_string (pp, "hint(");
1087 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1088 spc, flags, false);
1089 pp_right_paren (pp);
1090 break;
1092 case OMP_CLAUSE_FILTER:
1093 pp_string (pp, "filter(");
1094 dump_generic_node (pp, OMP_CLAUSE_FILTER_EXPR (clause),
1095 spc, flags, false);
1096 pp_right_paren (pp);
1097 break;
1099 case OMP_CLAUSE_DEFAULTMAP:
1100 pp_string (pp, "defaultmap(");
1101 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1103 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1104 pp_string (pp, "alloc");
1105 break;
1106 case OMP_CLAUSE_DEFAULTMAP_TO:
1107 pp_string (pp, "to");
1108 break;
1109 case OMP_CLAUSE_DEFAULTMAP_FROM:
1110 pp_string (pp, "from");
1111 break;
1112 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1113 pp_string (pp, "tofrom");
1114 break;
1115 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1116 pp_string (pp, "firstprivate");
1117 break;
1118 case OMP_CLAUSE_DEFAULTMAP_NONE:
1119 pp_string (pp, "none");
1120 break;
1121 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1122 pp_string (pp, "default");
1123 break;
1124 default:
1125 gcc_unreachable ();
1127 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1129 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1130 break;
1131 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1132 pp_string (pp, ":scalar");
1133 break;
1134 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1135 pp_string (pp, ":aggregate");
1136 break;
1137 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1138 pp_string (pp, ":allocatable");
1139 break;
1140 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1141 pp_string (pp, ":pointer");
1142 break;
1143 default:
1144 gcc_unreachable ();
1146 pp_right_paren (pp);
1147 break;
1149 case OMP_CLAUSE_ORDER:
1150 pp_string (pp, "order(concurrent)");
1151 break;
1153 case OMP_CLAUSE_BIND:
1154 pp_string (pp, "bind(");
1155 switch (OMP_CLAUSE_BIND_KIND (clause))
1157 case OMP_CLAUSE_BIND_TEAMS:
1158 pp_string (pp, "teams");
1159 break;
1160 case OMP_CLAUSE_BIND_PARALLEL:
1161 pp_string (pp, "parallel");
1162 break;
1163 case OMP_CLAUSE_BIND_THREAD:
1164 pp_string (pp, "thread");
1165 break;
1166 default:
1167 gcc_unreachable ();
1169 pp_right_paren (pp);
1170 break;
1172 case OMP_CLAUSE__SIMDUID_:
1173 pp_string (pp, "_simduid_(");
1174 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1175 spc, flags, false);
1176 pp_right_paren (pp);
1177 break;
1179 case OMP_CLAUSE__SIMT_:
1180 pp_string (pp, "_simt_");
1181 break;
1183 case OMP_CLAUSE_GANG:
1184 pp_string (pp, "gang");
1185 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1187 pp_string (pp, "(num: ");
1188 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1189 spc, flags, false);
1191 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1193 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1194 pp_left_paren (pp);
1195 else
1196 pp_space (pp);
1197 pp_string (pp, "static:");
1198 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1199 == integer_minus_one_node)
1200 pp_character (pp, '*');
1201 else
1202 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1203 spc, flags, false);
1205 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1206 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1207 pp_right_paren (pp);
1208 break;
1210 case OMP_CLAUSE_ASYNC:
1211 pp_string (pp, "async");
1212 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1214 pp_character(pp, '(');
1215 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1216 spc, flags, false);
1217 pp_character(pp, ')');
1219 break;
1221 case OMP_CLAUSE_AUTO:
1222 case OMP_CLAUSE_SEQ:
1223 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1224 break;
1226 case OMP_CLAUSE_WAIT:
1227 pp_string (pp, "wait(");
1228 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1229 spc, flags, false);
1230 pp_character(pp, ')');
1231 break;
1233 case OMP_CLAUSE_WORKER:
1234 pp_string (pp, "worker");
1235 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1237 pp_left_paren (pp);
1238 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1239 spc, flags, false);
1240 pp_right_paren (pp);
1242 break;
1244 case OMP_CLAUSE_VECTOR:
1245 pp_string (pp, "vector");
1246 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1248 pp_left_paren (pp);
1249 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1250 spc, flags, false);
1251 pp_right_paren (pp);
1253 break;
1255 case OMP_CLAUSE_NUM_GANGS:
1256 pp_string (pp, "num_gangs(");
1257 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1258 spc, flags, false);
1259 pp_character (pp, ')');
1260 break;
1262 case OMP_CLAUSE_NUM_WORKERS:
1263 pp_string (pp, "num_workers(");
1264 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1265 spc, flags, false);
1266 pp_character (pp, ')');
1267 break;
1269 case OMP_CLAUSE_VECTOR_LENGTH:
1270 pp_string (pp, "vector_length(");
1271 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1272 spc, flags, false);
1273 pp_character (pp, ')');
1274 break;
1276 case OMP_CLAUSE_INBRANCH:
1277 pp_string (pp, "inbranch");
1278 break;
1279 case OMP_CLAUSE_NOTINBRANCH:
1280 pp_string (pp, "notinbranch");
1281 break;
1282 case OMP_CLAUSE_FOR:
1283 pp_string (pp, "for");
1284 break;
1285 case OMP_CLAUSE_PARALLEL:
1286 pp_string (pp, "parallel");
1287 break;
1288 case OMP_CLAUSE_SECTIONS:
1289 pp_string (pp, "sections");
1290 break;
1291 case OMP_CLAUSE_TASKGROUP:
1292 pp_string (pp, "taskgroup");
1293 break;
1294 case OMP_CLAUSE_NOGROUP:
1295 pp_string (pp, "nogroup");
1296 break;
1297 case OMP_CLAUSE_THREADS:
1298 pp_string (pp, "threads");
1299 break;
1300 case OMP_CLAUSE_SIMD:
1301 pp_string (pp, "simd");
1302 break;
1303 case OMP_CLAUSE_INDEPENDENT:
1304 pp_string (pp, "independent");
1305 break;
1306 case OMP_CLAUSE_TILE:
1307 pp_string (pp, "tile(");
1308 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1309 spc, flags, false);
1310 pp_right_paren (pp);
1311 break;
1313 case OMP_CLAUSE_IF_PRESENT:
1314 pp_string (pp, "if_present");
1315 break;
1316 case OMP_CLAUSE_FINALIZE:
1317 pp_string (pp, "finalize");
1318 break;
1319 case OMP_CLAUSE_NOHOST:
1320 pp_string (pp, "nohost");
1321 break;
1322 case OMP_CLAUSE_DETACH:
1323 pp_string (pp, "detach(");
1324 dump_generic_node (pp, OMP_CLAUSE_DECL (clause), spc, flags,
1325 false);
1326 pp_right_paren (pp);
1327 break;
1329 default:
1330 gcc_unreachable ();
1335 /* Dump chain of OMP clauses.
1337 PP, SPC and FLAGS are as in dump_generic_node. */
1339 void
1340 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags,
1341 bool leading_space)
1343 while (clause)
1345 if (leading_space)
1346 pp_space (pp);
1347 dump_omp_clause (pp, clause, spc, flags);
1348 leading_space = true;
1350 clause = OMP_CLAUSE_CHAIN (clause);
1355 /* Dump location LOC to PP. */
1357 void
1358 dump_location (pretty_printer *pp, location_t loc)
1360 expanded_location xloc = expand_location (loc);
1362 pp_left_bracket (pp);
1363 if (xloc.file)
1365 pp_string (pp, xloc.file);
1366 pp_string (pp, ":");
1368 pp_decimal_int (pp, xloc.line);
1369 pp_colon (pp);
1370 pp_decimal_int (pp, xloc.column);
1371 pp_string (pp, "] ");
1375 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1376 dump_generic_node. */
1378 static void
1379 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1381 tree t;
1383 pp_string (pp, "BLOCK #");
1384 pp_decimal_int (pp, BLOCK_NUMBER (block));
1385 pp_character (pp, ' ');
1387 if (flags & TDF_ADDRESS)
1389 pp_character (pp, '[');
1390 pp_scalar (pp, "%p", (void *) block);
1391 pp_string (pp, "] ");
1394 if (TREE_ASM_WRITTEN (block))
1395 pp_string (pp, "[written] ");
1397 if (flags & TDF_SLIM)
1398 return;
1400 if (BLOCK_SOURCE_LOCATION (block))
1401 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1403 newline_and_indent (pp, spc + 2);
1405 if (BLOCK_SUPERCONTEXT (block))
1407 pp_string (pp, "SUPERCONTEXT: ");
1408 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1409 flags | TDF_SLIM, false);
1410 newline_and_indent (pp, spc + 2);
1413 if (BLOCK_SUBBLOCKS (block))
1415 pp_string (pp, "SUBBLOCKS: ");
1416 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1418 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1419 pp_space (pp);
1421 newline_and_indent (pp, spc + 2);
1424 if (BLOCK_CHAIN (block))
1426 pp_string (pp, "SIBLINGS: ");
1427 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1429 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1430 pp_space (pp);
1432 newline_and_indent (pp, spc + 2);
1435 if (BLOCK_VARS (block))
1437 pp_string (pp, "VARS: ");
1438 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1440 dump_generic_node (pp, t, 0, flags, false);
1441 pp_space (pp);
1443 newline_and_indent (pp, spc + 2);
1446 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1448 unsigned i;
1449 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1451 pp_string (pp, "NONLOCALIZED_VARS: ");
1452 FOR_EACH_VEC_ELT (*nlv, i, t)
1454 dump_generic_node (pp, t, 0, flags, false);
1455 pp_space (pp);
1457 newline_and_indent (pp, spc + 2);
1460 if (BLOCK_ABSTRACT_ORIGIN (block))
1462 pp_string (pp, "ABSTRACT_ORIGIN: ");
1463 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1464 flags | TDF_SLIM, false);
1465 newline_and_indent (pp, spc + 2);
1468 if (BLOCK_FRAGMENT_ORIGIN (block))
1470 pp_string (pp, "FRAGMENT_ORIGIN: ");
1471 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1472 flags | TDF_SLIM, false);
1473 newline_and_indent (pp, spc + 2);
1476 if (BLOCK_FRAGMENT_CHAIN (block))
1478 pp_string (pp, "FRAGMENT_CHAIN: ");
1479 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1481 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1482 pp_space (pp);
1484 newline_and_indent (pp, spc + 2);
1488 /* Dump #pragma omp atomic memory order clause. */
1490 void
1491 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1493 switch (mo)
1495 case OMP_MEMORY_ORDER_RELAXED:
1496 pp_string (pp, " relaxed");
1497 break;
1498 case OMP_MEMORY_ORDER_SEQ_CST:
1499 pp_string (pp, " seq_cst");
1500 break;
1501 case OMP_MEMORY_ORDER_ACQ_REL:
1502 pp_string (pp, " acq_rel");
1503 break;
1504 case OMP_MEMORY_ORDER_ACQUIRE:
1505 pp_string (pp, " acquire");
1506 break;
1507 case OMP_MEMORY_ORDER_RELEASE:
1508 pp_string (pp, " release");
1509 break;
1510 case OMP_MEMORY_ORDER_UNSPECIFIED:
1511 break;
1512 default:
1513 gcc_unreachable ();
1517 /* Helper to dump a MEM_REF node. */
1519 static void
1520 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1522 if (TREE_CODE (node) == MEM_REF && (flags & TDF_GIMPLE))
1524 pp_string (pp, "__MEM <");
1525 dump_generic_node (pp, TREE_TYPE (node),
1526 spc, flags | TDF_SLIM, false);
1527 if (TYPE_ALIGN (TREE_TYPE (node))
1528 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1530 pp_string (pp, ", ");
1531 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1533 pp_greater (pp);
1534 pp_string (pp, " (");
1535 if (TREE_TYPE (TREE_OPERAND (node, 0))
1536 != TREE_TYPE (TREE_OPERAND (node, 1)))
1538 pp_left_paren (pp);
1539 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1540 spc, flags | TDF_SLIM, false);
1541 pp_right_paren (pp);
1543 dump_generic_node (pp, TREE_OPERAND (node, 0),
1544 spc, flags | TDF_SLIM, false);
1545 if (! integer_zerop (TREE_OPERAND (node, 1)))
1547 pp_string (pp, " + ");
1548 dump_generic_node (pp, TREE_OPERAND (node, 1),
1549 spc, flags | TDF_SLIM, false);
1551 pp_right_paren (pp);
1553 else if (TREE_CODE (node) == MEM_REF
1554 && integer_zerop (TREE_OPERAND (node, 1))
1555 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1556 infer them and MEM_ATTR caching will share MEM_REFs
1557 with differently-typed op0s. */
1558 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1559 /* Released SSA_NAMES have no TREE_TYPE. */
1560 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1561 /* Same pointer types, but ignoring POINTER_TYPE vs.
1562 REFERENCE_TYPE. */
1563 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1564 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1565 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1566 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1567 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1568 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1569 /* Same value types ignoring qualifiers. */
1570 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1571 == TYPE_MAIN_VARIANT
1572 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1573 && (!(flags & TDF_ALIAS)
1574 || MR_DEPENDENCE_CLIQUE (node) == 0))
1576 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1578 /* Enclose pointers to arrays in parentheses. */
1579 tree op0 = TREE_OPERAND (node, 0);
1580 tree op0type = TREE_TYPE (op0);
1581 if (POINTER_TYPE_P (op0type)
1582 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1583 pp_left_paren (pp);
1584 pp_star (pp);
1585 dump_generic_node (pp, op0, spc, flags, false);
1586 if (POINTER_TYPE_P (op0type)
1587 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1588 pp_right_paren (pp);
1590 else
1591 dump_generic_node (pp,
1592 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1593 spc, flags, false);
1595 else
1597 pp_string (pp, "MEM");
1599 tree nodetype = TREE_TYPE (node);
1600 tree op0 = TREE_OPERAND (node, 0);
1601 tree op1 = TREE_OPERAND (node, 1);
1602 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1604 tree op0size = TYPE_SIZE (nodetype);
1605 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1607 if (!op0size || !op1size
1608 || !operand_equal_p (op0size, op1size, 0))
1610 pp_string (pp, " <");
1611 /* If the size of the type of the operand is not the same
1612 as the size of the MEM_REF expression include the type
1613 of the latter similar to the TDF_GIMPLE output to make
1614 it clear how many bytes of memory are being accessed. */
1615 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1616 pp_string (pp, "> ");
1619 pp_string (pp, "[(");
1620 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1621 pp_right_paren (pp);
1622 dump_generic_node (pp, op0, spc, flags, false);
1623 if (!integer_zerop (op1))
1625 pp_string (pp, " + ");
1626 dump_generic_node (pp, op1, spc, flags, false);
1628 if (TREE_CODE (node) == TARGET_MEM_REF)
1630 tree tmp = TMR_INDEX2 (node);
1631 if (tmp)
1633 pp_string (pp, " + ");
1634 dump_generic_node (pp, tmp, spc, flags, false);
1636 tmp = TMR_INDEX (node);
1637 if (tmp)
1639 pp_string (pp, " + ");
1640 dump_generic_node (pp, tmp, spc, flags, false);
1641 tmp = TMR_STEP (node);
1642 pp_string (pp, " * ");
1643 if (tmp)
1644 dump_generic_node (pp, tmp, spc, flags, false);
1645 else
1646 pp_string (pp, "1");
1649 if ((flags & TDF_ALIAS)
1650 && MR_DEPENDENCE_CLIQUE (node) != 0)
1652 pp_string (pp, " clique ");
1653 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1654 pp_string (pp, " base ");
1655 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1657 pp_right_bracket (pp);
1661 /* Helper function for dump_generic_node. Dump INIT or COND expression for
1662 OpenMP loop non-rectangular iterators. */
1664 void
1665 dump_omp_loop_non_rect_expr (pretty_printer *pp, tree node, int spc,
1666 dump_flags_t flags)
1668 gcc_assert (TREE_CODE (node) == TREE_VEC);
1669 dump_generic_node (pp, TREE_VEC_ELT (node, 0), spc, flags, false);
1670 pp_string (pp, " * ");
1671 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (MULT_EXPR))
1673 pp_left_paren (pp);
1674 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1675 pp_right_paren (pp);
1677 else
1678 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1679 pp_string (pp, " + ");
1680 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (PLUS_EXPR))
1682 pp_left_paren (pp);
1683 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1684 pp_right_paren (pp);
1686 else
1687 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1690 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1691 indent. FLAGS specifies details to show in the dump (see TDF_* in
1692 dumpfile.h). If IS_STMT is true, the object printed is considered
1693 to be a statement and it is terminated by ';' if appropriate. */
1696 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1697 bool is_stmt)
1699 tree type;
1700 tree op0, op1;
1701 const char *str;
1702 bool is_expr;
1703 enum tree_code code;
1705 if (node == NULL_TREE)
1706 return spc;
1708 is_expr = EXPR_P (node);
1710 if (is_stmt && (flags & TDF_STMTADDR))
1712 pp_string (pp, "<&");
1713 pp_scalar (pp, "%p", (void *)node);
1714 pp_string (pp, "> ");
1717 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1718 dump_location (pp, EXPR_LOCATION (node));
1720 code = TREE_CODE (node);
1721 switch (code)
1723 case ERROR_MARK:
1724 pp_string (pp, "<<< error >>>");
1725 break;
1727 case IDENTIFIER_NODE:
1728 pp_tree_identifier (pp, node);
1729 break;
1731 case TREE_LIST:
1732 while (node && node != error_mark_node)
1734 if (TREE_PURPOSE (node))
1736 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1737 pp_space (pp);
1739 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1740 node = TREE_CHAIN (node);
1741 if (node && TREE_CODE (node) == TREE_LIST)
1743 pp_comma (pp);
1744 pp_space (pp);
1747 break;
1749 case TREE_BINFO:
1750 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1751 break;
1753 case TREE_VEC:
1755 size_t i;
1756 if (TREE_VEC_LENGTH (node) > 0)
1758 size_t len = TREE_VEC_LENGTH (node);
1759 for (i = 0; i < len - 1; i++)
1761 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1762 false);
1763 pp_comma (pp);
1764 pp_space (pp);
1766 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1767 flags, false);
1770 break;
1772 case VOID_TYPE:
1773 case INTEGER_TYPE:
1774 case REAL_TYPE:
1775 case FIXED_POINT_TYPE:
1776 case COMPLEX_TYPE:
1777 case VECTOR_TYPE:
1778 case ENUMERAL_TYPE:
1779 case BOOLEAN_TYPE:
1780 case OPAQUE_TYPE:
1782 unsigned int quals = TYPE_QUALS (node);
1783 enum tree_code_class tclass;
1785 if (quals & TYPE_QUAL_ATOMIC)
1786 pp_string (pp, "atomic ");
1787 if (quals & TYPE_QUAL_CONST)
1788 pp_string (pp, "const ");
1789 if (quals & TYPE_QUAL_VOLATILE)
1790 pp_string (pp, "volatile ");
1791 if (quals & TYPE_QUAL_RESTRICT)
1792 pp_string (pp, "restrict ");
1794 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1796 pp_string (pp, "<address-space-");
1797 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1798 pp_string (pp, "> ");
1801 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1803 if (tclass == tcc_declaration)
1805 if (DECL_NAME (node))
1806 dump_decl_name (pp, node, flags);
1807 else
1808 pp_string (pp, "<unnamed type decl>");
1810 else if (tclass == tcc_type)
1812 if (TYPE_NAME (node))
1814 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1815 pp_tree_identifier (pp, TYPE_NAME (node));
1816 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1817 && DECL_NAME (TYPE_NAME (node)))
1818 dump_decl_name (pp, TYPE_NAME (node), flags);
1819 else
1820 pp_string (pp, "<unnamed type>");
1822 else if (TREE_CODE (node) == VECTOR_TYPE)
1824 pp_string (pp, "vector");
1825 pp_left_paren (pp);
1826 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1827 pp_string (pp, ") ");
1828 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1830 else if (TREE_CODE (node) == INTEGER_TYPE)
1832 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1833 pp_string (pp, (TYPE_UNSIGNED (node)
1834 ? "unsigned char"
1835 : "signed char"));
1836 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1837 pp_string (pp, (TYPE_UNSIGNED (node)
1838 ? "unsigned short"
1839 : "signed short"));
1840 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1841 pp_string (pp, (TYPE_UNSIGNED (node)
1842 ? "unsigned int"
1843 : "signed int"));
1844 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1845 pp_string (pp, (TYPE_UNSIGNED (node)
1846 ? "unsigned long"
1847 : "signed long"));
1848 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1849 pp_string (pp, (TYPE_UNSIGNED (node)
1850 ? "unsigned long long"
1851 : "signed long long"));
1852 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1853 && pow2p_hwi (TYPE_PRECISION (node)))
1855 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1856 pp_decimal_int (pp, TYPE_PRECISION (node));
1857 pp_string (pp, "_t");
1859 else
1861 pp_string (pp, (TYPE_UNSIGNED (node)
1862 ? "<unnamed-unsigned:"
1863 : "<unnamed-signed:"));
1864 pp_decimal_int (pp, TYPE_PRECISION (node));
1865 pp_greater (pp);
1868 else if (TREE_CODE (node) == COMPLEX_TYPE)
1870 pp_string (pp, "__complex__ ");
1871 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1873 else if (TREE_CODE (node) == REAL_TYPE)
1875 pp_string (pp, "<float:");
1876 pp_decimal_int (pp, TYPE_PRECISION (node));
1877 pp_greater (pp);
1879 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1881 pp_string (pp, "<fixed-point-");
1882 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1883 pp_decimal_int (pp, TYPE_PRECISION (node));
1884 pp_greater (pp);
1886 else if (TREE_CODE (node) == BOOLEAN_TYPE)
1888 pp_string (pp, (TYPE_UNSIGNED (node)
1889 ? "<unsigned-boolean:"
1890 : "<signed-boolean:"));
1891 pp_decimal_int (pp, TYPE_PRECISION (node));
1892 pp_greater (pp);
1894 else if (TREE_CODE (node) == VOID_TYPE)
1895 pp_string (pp, "void");
1896 else
1897 pp_string (pp, "<unnamed type>");
1899 break;
1902 case POINTER_TYPE:
1903 case REFERENCE_TYPE:
1904 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1906 if (TREE_TYPE (node) == NULL)
1908 pp_string (pp, str);
1909 pp_string (pp, "<null type>");
1911 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1913 tree fnode = TREE_TYPE (node);
1915 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1916 pp_space (pp);
1917 pp_left_paren (pp);
1918 pp_string (pp, str);
1919 if (TYPE_IDENTIFIER (node))
1920 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1921 else if (flags & TDF_NOUID)
1922 pp_string (pp, "<Txxxx>");
1923 else
1925 pp_string (pp, "<T");
1926 pp_scalar (pp, "%x", TYPE_UID (node));
1927 pp_character (pp, '>');
1930 pp_right_paren (pp);
1931 dump_function_declaration (pp, fnode, spc, flags);
1933 else
1935 unsigned int quals = TYPE_QUALS (node);
1937 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1938 pp_space (pp);
1939 pp_string (pp, str);
1941 if (quals & TYPE_QUAL_CONST)
1942 pp_string (pp, " const");
1943 if (quals & TYPE_QUAL_VOLATILE)
1944 pp_string (pp, " volatile");
1945 if (quals & TYPE_QUAL_RESTRICT)
1946 pp_string (pp, " restrict");
1948 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1950 pp_string (pp, " <address-space-");
1951 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1952 pp_greater (pp);
1955 if (TYPE_REF_CAN_ALIAS_ALL (node))
1956 pp_string (pp, " {ref-all}");
1958 break;
1960 case OFFSET_TYPE:
1961 NIY;
1962 break;
1964 case MEM_REF:
1965 case TARGET_MEM_REF:
1966 dump_mem_ref (pp, node, spc, flags);
1967 break;
1969 case ARRAY_TYPE:
1971 unsigned int quals = TYPE_QUALS (node);
1972 tree tmp;
1974 if (quals & TYPE_QUAL_ATOMIC)
1975 pp_string (pp, "atomic ");
1976 if (quals & TYPE_QUAL_CONST)
1977 pp_string (pp, "const ");
1978 if (quals & TYPE_QUAL_VOLATILE)
1979 pp_string (pp, "volatile ");
1981 /* Print the innermost component type. */
1982 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1983 tmp = TREE_TYPE (tmp))
1985 dump_generic_node (pp, tmp, spc, flags, false);
1987 /* Print the dimensions. */
1988 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1989 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1990 break;
1993 case RECORD_TYPE:
1994 case UNION_TYPE:
1995 case QUAL_UNION_TYPE:
1997 unsigned int quals = TYPE_QUALS (node);
1999 if (quals & TYPE_QUAL_ATOMIC)
2000 pp_string (pp, "atomic ");
2001 if (quals & TYPE_QUAL_CONST)
2002 pp_string (pp, "const ");
2003 if (quals & TYPE_QUAL_VOLATILE)
2004 pp_string (pp, "volatile ");
2006 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2008 pp_string (pp, "<address-space-");
2009 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2010 pp_string (pp, "> ");
2013 /* Print the name of the structure. */
2014 if (TREE_CODE (node) == RECORD_TYPE)
2015 pp_string (pp, "struct ");
2016 else if (TREE_CODE (node) == UNION_TYPE)
2017 pp_string (pp, "union ");
2019 if (TYPE_NAME (node))
2020 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2021 else if (!(flags & TDF_SLIM))
2022 /* FIXME: If we eliminate the 'else' above and attempt
2023 to show the fields for named types, we may get stuck
2024 following a cycle of pointers to structs. The alleged
2025 self-reference check in print_struct_decl will not detect
2026 cycles involving more than one pointer or struct type. */
2027 print_struct_decl (pp, node, spc, flags);
2028 break;
2031 case LANG_TYPE:
2032 NIY;
2033 break;
2035 case INTEGER_CST:
2036 if (flags & TDF_GIMPLE
2037 && (POINTER_TYPE_P (TREE_TYPE (node))
2038 || (TYPE_PRECISION (TREE_TYPE (node))
2039 < TYPE_PRECISION (integer_type_node))
2040 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
2041 || tree_int_cst_sgn (node) < 0))
2043 pp_string (pp, "_Literal (");
2044 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2045 pp_string (pp, ") ");
2047 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
2048 && ! (flags & TDF_GIMPLE))
2050 /* In the case of a pointer, one may want to divide by the
2051 size of the pointed-to type. Unfortunately, this not
2052 straightforward. The C front-end maps expressions
2054 (int *) 5
2055 int *p; (p + 5)
2057 in such a way that the two INTEGER_CST nodes for "5" have
2058 different values but identical types. In the latter
2059 case, the 5 is multiplied by sizeof (int) in c-common.c
2060 (pointer_int_sum) to convert it to a byte address, and
2061 yet the type of the node is left unchanged. Argh. What
2062 is consistent though is that the number value corresponds
2063 to bytes (UNITS) offset.
2065 NB: Neither of the following divisors can be trivially
2066 used to recover the original literal:
2068 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
2069 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
2070 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
2071 pp_string (pp, "B"); /* pseudo-unit */
2073 else if (tree_fits_shwi_p (node))
2074 pp_wide_integer (pp, tree_to_shwi (node));
2075 else if (tree_fits_uhwi_p (node))
2076 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
2077 else
2079 wide_int val = wi::to_wide (node);
2081 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
2083 pp_minus (pp);
2084 val = -val;
2086 print_hex (val, pp_buffer (pp)->digit_buffer);
2087 pp_string (pp, pp_buffer (pp)->digit_buffer);
2089 if ((flags & TDF_GIMPLE)
2090 && ! (POINTER_TYPE_P (TREE_TYPE (node))
2091 || (TYPE_PRECISION (TREE_TYPE (node))
2092 < TYPE_PRECISION (integer_type_node))
2093 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
2095 if (TYPE_UNSIGNED (TREE_TYPE (node)))
2096 pp_character (pp, 'u');
2097 if (TYPE_PRECISION (TREE_TYPE (node))
2098 == TYPE_PRECISION (unsigned_type_node))
2100 else if (TYPE_PRECISION (TREE_TYPE (node))
2101 == TYPE_PRECISION (long_unsigned_type_node))
2102 pp_character (pp, 'l');
2103 else if (TYPE_PRECISION (TREE_TYPE (node))
2104 == TYPE_PRECISION (long_long_unsigned_type_node))
2105 pp_string (pp, "ll");
2107 if (TREE_OVERFLOW (node))
2108 pp_string (pp, "(OVF)");
2109 break;
2111 case POLY_INT_CST:
2112 pp_string (pp, "POLY_INT_CST [");
2113 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2114 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2116 pp_string (pp, ", ");
2117 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2118 spc, flags, false);
2120 pp_string (pp, "]");
2121 break;
2123 case REAL_CST:
2124 /* Code copied from print_node. */
2126 REAL_VALUE_TYPE d;
2127 if (TREE_OVERFLOW (node))
2128 pp_string (pp, " overflow");
2130 d = TREE_REAL_CST (node);
2131 if (REAL_VALUE_ISINF (d))
2132 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2133 else if (REAL_VALUE_ISNAN (d))
2134 pp_string (pp, " Nan");
2135 else
2137 char string[100];
2138 real_to_decimal (string, &d, sizeof (string), 0, 1);
2139 pp_string (pp, string);
2141 break;
2144 case FIXED_CST:
2146 char string[100];
2147 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2148 pp_string (pp, string);
2149 break;
2152 case COMPLEX_CST:
2153 pp_string (pp, "__complex__ (");
2154 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2155 pp_string (pp, ", ");
2156 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2157 pp_right_paren (pp);
2158 break;
2160 case STRING_CST:
2162 pp_string (pp, "\"");
2163 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2164 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2165 pp_string (pp, "\"");
2166 break;
2169 case VECTOR_CST:
2171 unsigned i;
2172 if (flags & TDF_GIMPLE)
2174 pp_string (pp, "_Literal (");
2175 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2176 pp_string (pp, ") ");
2178 pp_string (pp, "{ ");
2179 unsigned HOST_WIDE_INT nunits;
2180 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2181 nunits = vector_cst_encoded_nelts (node);
2182 for (i = 0; i < nunits; ++i)
2184 if (i != 0)
2185 pp_string (pp, ", ");
2186 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2187 spc, flags, false);
2189 if (!VECTOR_CST_NELTS (node).is_constant ())
2190 pp_string (pp, ", ...");
2191 pp_string (pp, " }");
2193 break;
2195 case FUNCTION_TYPE:
2196 case METHOD_TYPE:
2197 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2198 pp_space (pp);
2199 if (TREE_CODE (node) == METHOD_TYPE)
2201 if (TYPE_METHOD_BASETYPE (node))
2202 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2203 spc, flags, false);
2204 else
2205 pp_string (pp, "<null method basetype>");
2206 pp_colon_colon (pp);
2208 if (TYPE_IDENTIFIER (node))
2209 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2210 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2211 dump_decl_name (pp, TYPE_NAME (node), flags);
2212 else if (flags & TDF_NOUID)
2213 pp_string (pp, "<Txxxx>");
2214 else
2216 pp_string (pp, "<T");
2217 pp_scalar (pp, "%x", TYPE_UID (node));
2218 pp_character (pp, '>');
2220 dump_function_declaration (pp, node, spc, flags);
2221 break;
2223 case FUNCTION_DECL:
2224 case CONST_DECL:
2225 dump_decl_name (pp, node, flags);
2226 break;
2228 case LABEL_DECL:
2229 if (DECL_NAME (node))
2230 dump_decl_name (pp, node, flags);
2231 else if (LABEL_DECL_UID (node) != -1)
2233 if (flags & TDF_GIMPLE)
2235 pp_character (pp, 'L');
2236 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2238 else
2240 pp_string (pp, "<L");
2241 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2242 pp_character (pp, '>');
2245 else
2247 if (flags & TDF_NOUID)
2248 pp_string (pp, "<D.xxxx>");
2249 else
2251 if (flags & TDF_GIMPLE)
2253 pp_character (pp, 'D');
2254 pp_scalar (pp, "%u", DECL_UID (node));
2256 else
2258 pp_string (pp, "<D.");
2259 pp_scalar (pp, "%u", DECL_UID (node));
2260 pp_character (pp, '>');
2264 break;
2266 case TYPE_DECL:
2267 if (DECL_IS_UNDECLARED_BUILTIN (node))
2269 /* Don't print the declaration of built-in types. */
2270 break;
2272 if (DECL_NAME (node))
2273 dump_decl_name (pp, node, flags);
2274 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2276 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2277 ? "union" : "struct "));
2278 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2280 else
2281 pp_string (pp, "<anon>");
2282 break;
2284 case VAR_DECL:
2285 case PARM_DECL:
2286 case FIELD_DECL:
2287 case DEBUG_EXPR_DECL:
2288 case NAMESPACE_DECL:
2289 case NAMELIST_DECL:
2290 dump_decl_name (pp, node, flags);
2291 break;
2293 case RESULT_DECL:
2294 pp_string (pp, "<retval>");
2295 break;
2297 case COMPONENT_REF:
2298 op0 = TREE_OPERAND (node, 0);
2299 str = ".";
2300 if (op0
2301 && (TREE_CODE (op0) == INDIRECT_REF
2302 || (TREE_CODE (op0) == MEM_REF
2303 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2304 && integer_zerop (TREE_OPERAND (op0, 1))
2305 /* Dump the types of INTEGER_CSTs explicitly, for we
2306 can't infer them and MEM_ATTR caching will share
2307 MEM_REFs with differently-typed op0s. */
2308 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2309 /* Released SSA_NAMES have no TREE_TYPE. */
2310 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2311 /* Same pointer types, but ignoring POINTER_TYPE vs.
2312 REFERENCE_TYPE. */
2313 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2314 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2315 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2316 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2317 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2318 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2319 /* Same value types ignoring qualifiers. */
2320 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2321 == TYPE_MAIN_VARIANT
2322 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2323 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2325 op0 = TREE_OPERAND (op0, 0);
2326 str = "->";
2328 if (op_prio (op0) < op_prio (node))
2329 pp_left_paren (pp);
2330 dump_generic_node (pp, op0, spc, flags, false);
2331 if (op_prio (op0) < op_prio (node))
2332 pp_right_paren (pp);
2333 pp_string (pp, str);
2334 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2335 op0 = component_ref_field_offset (node);
2336 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2338 pp_string (pp, "{off: ");
2339 dump_generic_node (pp, op0, spc, flags, false);
2340 pp_right_brace (pp);
2342 break;
2344 case BIT_FIELD_REF:
2345 if (flags & TDF_GIMPLE)
2347 pp_string (pp, "__BIT_FIELD_REF <");
2348 dump_generic_node (pp, TREE_TYPE (node),
2349 spc, flags | TDF_SLIM, false);
2350 if (TYPE_ALIGN (TREE_TYPE (node))
2351 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2353 pp_string (pp, ", ");
2354 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2356 pp_greater (pp);
2357 pp_string (pp, " (");
2358 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2359 flags | TDF_SLIM, false);
2360 pp_string (pp, ", ");
2361 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2362 flags | TDF_SLIM, false);
2363 pp_string (pp, ", ");
2364 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2365 flags | TDF_SLIM, false);
2366 pp_right_paren (pp);
2368 else
2370 pp_string (pp, "BIT_FIELD_REF <");
2371 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2372 pp_string (pp, ", ");
2373 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2374 pp_string (pp, ", ");
2375 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2376 pp_greater (pp);
2378 break;
2380 case BIT_INSERT_EXPR:
2381 pp_string (pp, "BIT_INSERT_EXPR <");
2382 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2383 pp_string (pp, ", ");
2384 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2385 pp_string (pp, ", ");
2386 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2387 pp_string (pp, " (");
2388 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2389 pp_decimal_int (pp,
2390 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2391 else
2392 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2393 spc, flags, false);
2394 pp_string (pp, " bits)>");
2395 break;
2397 case ARRAY_REF:
2398 case ARRAY_RANGE_REF:
2399 op0 = TREE_OPERAND (node, 0);
2400 if (op_prio (op0) < op_prio (node))
2401 pp_left_paren (pp);
2402 dump_generic_node (pp, op0, spc, flags, false);
2403 if (op_prio (op0) < op_prio (node))
2404 pp_right_paren (pp);
2405 pp_left_bracket (pp);
2406 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2407 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2408 pp_string (pp, " ...");
2409 pp_right_bracket (pp);
2411 op0 = array_ref_low_bound (node);
2412 op1 = array_ref_element_size (node);
2414 if (!integer_zerop (op0)
2415 || TREE_OPERAND (node, 2)
2416 || TREE_OPERAND (node, 3))
2418 pp_string (pp, "{lb: ");
2419 dump_generic_node (pp, op0, spc, flags, false);
2420 pp_string (pp, " sz: ");
2421 dump_generic_node (pp, op1, spc, flags, false);
2422 pp_right_brace (pp);
2424 break;
2426 case CONSTRUCTOR:
2428 unsigned HOST_WIDE_INT ix;
2429 tree field, val;
2430 bool is_struct_init = false;
2431 bool is_array_init = false;
2432 widest_int curidx;
2433 if (flags & TDF_GIMPLE)
2435 pp_string (pp, "_Literal (");
2436 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2437 pp_string (pp, ") ");
2439 pp_left_brace (pp);
2440 if (TREE_CLOBBER_P (node))
2441 pp_string (pp, "CLOBBER");
2442 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2443 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2444 is_struct_init = true;
2445 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2446 && TYPE_DOMAIN (TREE_TYPE (node))
2447 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2448 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2449 == INTEGER_CST)
2451 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2452 is_array_init = true;
2453 curidx = wi::to_widest (minv);
2455 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2457 if (field)
2459 if (is_struct_init)
2461 pp_dot (pp);
2462 dump_generic_node (pp, field, spc, flags, false);
2463 pp_equal (pp);
2465 else if (is_array_init
2466 && (TREE_CODE (field) != INTEGER_CST
2467 || curidx != wi::to_widest (field)))
2469 pp_left_bracket (pp);
2470 if (TREE_CODE (field) == RANGE_EXPR)
2472 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2473 flags, false);
2474 pp_string (pp, " ... ");
2475 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2476 flags, false);
2477 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2478 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2480 else
2481 dump_generic_node (pp, field, spc, flags, false);
2482 if (TREE_CODE (field) == INTEGER_CST)
2483 curidx = wi::to_widest (field);
2484 pp_string (pp, "]=");
2487 if (is_array_init)
2488 curidx += 1;
2489 if (val && TREE_CODE (val) == ADDR_EXPR)
2490 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2491 val = TREE_OPERAND (val, 0);
2492 if (val && TREE_CODE (val) == FUNCTION_DECL)
2493 dump_decl_name (pp, val, flags);
2494 else
2495 dump_generic_node (pp, val, spc, flags, false);
2496 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2498 pp_comma (pp);
2499 pp_space (pp);
2502 pp_right_brace (pp);
2504 break;
2506 case COMPOUND_EXPR:
2508 tree *tp;
2509 if (flags & TDF_SLIM)
2511 pp_string (pp, "<COMPOUND_EXPR>");
2512 break;
2515 dump_generic_node (pp, TREE_OPERAND (node, 0),
2516 spc, flags, !(flags & TDF_SLIM));
2517 if (flags & TDF_SLIM)
2518 newline_and_indent (pp, spc);
2519 else
2521 pp_comma (pp);
2522 pp_space (pp);
2525 for (tp = &TREE_OPERAND (node, 1);
2526 TREE_CODE (*tp) == COMPOUND_EXPR;
2527 tp = &TREE_OPERAND (*tp, 1))
2529 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2530 spc, flags, !(flags & TDF_SLIM));
2531 if (flags & TDF_SLIM)
2532 newline_and_indent (pp, spc);
2533 else
2535 pp_comma (pp);
2536 pp_space (pp);
2540 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2542 break;
2544 case STATEMENT_LIST:
2546 tree_stmt_iterator si;
2547 bool first = true;
2549 if (flags & TDF_SLIM)
2551 pp_string (pp, "<STATEMENT_LIST>");
2552 break;
2555 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2557 if (!first)
2558 newline_and_indent (pp, spc);
2559 else
2560 first = false;
2561 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2564 break;
2566 case MODIFY_EXPR:
2567 case INIT_EXPR:
2568 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2569 false);
2570 pp_space (pp);
2571 pp_equal (pp);
2572 pp_space (pp);
2573 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2574 false);
2575 break;
2577 case TARGET_EXPR:
2578 pp_string (pp, "TARGET_EXPR <");
2579 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2580 pp_comma (pp);
2581 pp_space (pp);
2582 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2583 pp_greater (pp);
2584 break;
2586 case DECL_EXPR:
2587 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2588 is_stmt = false;
2589 break;
2591 case COND_EXPR:
2592 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2594 pp_string (pp, "if (");
2595 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2596 pp_right_paren (pp);
2597 /* The lowered cond_exprs should always be printed in full. */
2598 if (COND_EXPR_THEN (node)
2599 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2600 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2601 && COND_EXPR_ELSE (node)
2602 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2603 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2605 pp_space (pp);
2606 dump_generic_node (pp, COND_EXPR_THEN (node),
2607 0, flags, true);
2608 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2610 pp_string (pp, " else ");
2611 dump_generic_node (pp, COND_EXPR_ELSE (node),
2612 0, flags, true);
2615 else if (!(flags & TDF_SLIM))
2617 /* Output COND_EXPR_THEN. */
2618 if (COND_EXPR_THEN (node))
2620 newline_and_indent (pp, spc+2);
2621 pp_left_brace (pp);
2622 newline_and_indent (pp, spc+4);
2623 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2624 flags, true);
2625 newline_and_indent (pp, spc+2);
2626 pp_right_brace (pp);
2629 /* Output COND_EXPR_ELSE. */
2630 if (COND_EXPR_ELSE (node)
2631 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2633 newline_and_indent (pp, spc);
2634 pp_string (pp, "else");
2635 newline_and_indent (pp, spc+2);
2636 pp_left_brace (pp);
2637 newline_and_indent (pp, spc+4);
2638 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2639 flags, true);
2640 newline_and_indent (pp, spc+2);
2641 pp_right_brace (pp);
2644 is_expr = false;
2646 else
2648 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2649 pp_space (pp);
2650 pp_question (pp);
2651 pp_space (pp);
2652 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2653 pp_space (pp);
2654 pp_colon (pp);
2655 pp_space (pp);
2656 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2658 break;
2660 case BIND_EXPR:
2661 pp_left_brace (pp);
2662 if (!(flags & TDF_SLIM))
2664 if (BIND_EXPR_VARS (node))
2666 pp_newline (pp);
2668 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2670 print_declaration (pp, op0, spc+2, flags);
2671 pp_newline (pp);
2675 newline_and_indent (pp, spc+2);
2676 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2677 newline_and_indent (pp, spc);
2678 pp_right_brace (pp);
2680 is_expr = false;
2681 break;
2683 case CALL_EXPR:
2684 if (CALL_EXPR_FN (node) != NULL_TREE)
2685 print_call_name (pp, CALL_EXPR_FN (node), flags);
2686 else
2688 pp_dot (pp);
2689 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2692 /* Print parameters. */
2693 pp_space (pp);
2694 pp_left_paren (pp);
2696 tree arg;
2697 call_expr_arg_iterator iter;
2698 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2700 dump_generic_node (pp, arg, spc, flags, false);
2701 if (more_call_expr_args_p (&iter))
2703 pp_comma (pp);
2704 pp_space (pp);
2708 if (CALL_EXPR_VA_ARG_PACK (node))
2710 if (call_expr_nargs (node) > 0)
2712 pp_comma (pp);
2713 pp_space (pp);
2715 pp_string (pp, "__builtin_va_arg_pack ()");
2717 pp_right_paren (pp);
2719 op1 = CALL_EXPR_STATIC_CHAIN (node);
2720 if (op1)
2722 pp_string (pp, " [static-chain: ");
2723 dump_generic_node (pp, op1, spc, flags, false);
2724 pp_right_bracket (pp);
2727 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2728 pp_string (pp, " [return slot optimization]");
2729 if (CALL_EXPR_TAILCALL (node))
2730 pp_string (pp, " [tail call]");
2731 break;
2733 case WITH_CLEANUP_EXPR:
2734 NIY;
2735 break;
2737 case CLEANUP_POINT_EXPR:
2738 pp_string (pp, "<<cleanup_point ");
2739 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2740 pp_string (pp, ">>");
2741 break;
2743 case PLACEHOLDER_EXPR:
2744 pp_string (pp, "<PLACEHOLDER_EXPR ");
2745 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2746 pp_greater (pp);
2747 break;
2749 /* Binary arithmetic and logic expressions. */
2750 case WIDEN_PLUS_EXPR:
2751 case WIDEN_MINUS_EXPR:
2752 case WIDEN_SUM_EXPR:
2753 case WIDEN_MULT_EXPR:
2754 case MULT_EXPR:
2755 case MULT_HIGHPART_EXPR:
2756 case PLUS_EXPR:
2757 case POINTER_PLUS_EXPR:
2758 case POINTER_DIFF_EXPR:
2759 case MINUS_EXPR:
2760 case TRUNC_DIV_EXPR:
2761 case CEIL_DIV_EXPR:
2762 case FLOOR_DIV_EXPR:
2763 case ROUND_DIV_EXPR:
2764 case TRUNC_MOD_EXPR:
2765 case CEIL_MOD_EXPR:
2766 case FLOOR_MOD_EXPR:
2767 case ROUND_MOD_EXPR:
2768 case RDIV_EXPR:
2769 case EXACT_DIV_EXPR:
2770 case LSHIFT_EXPR:
2771 case RSHIFT_EXPR:
2772 case LROTATE_EXPR:
2773 case RROTATE_EXPR:
2774 case WIDEN_LSHIFT_EXPR:
2775 case BIT_IOR_EXPR:
2776 case BIT_XOR_EXPR:
2777 case BIT_AND_EXPR:
2778 case TRUTH_ANDIF_EXPR:
2779 case TRUTH_ORIF_EXPR:
2780 case TRUTH_AND_EXPR:
2781 case TRUTH_OR_EXPR:
2782 case TRUTH_XOR_EXPR:
2783 case LT_EXPR:
2784 case LE_EXPR:
2785 case GT_EXPR:
2786 case GE_EXPR:
2787 case EQ_EXPR:
2788 case NE_EXPR:
2789 case UNLT_EXPR:
2790 case UNLE_EXPR:
2791 case UNGT_EXPR:
2792 case UNGE_EXPR:
2793 case UNEQ_EXPR:
2794 case LTGT_EXPR:
2795 case ORDERED_EXPR:
2796 case UNORDERED_EXPR:
2798 const char *op = op_symbol (node);
2799 op0 = TREE_OPERAND (node, 0);
2800 op1 = TREE_OPERAND (node, 1);
2802 /* When the operands are expressions with less priority,
2803 keep semantics of the tree representation. */
2804 if (op_prio (op0) <= op_prio (node))
2806 pp_left_paren (pp);
2807 dump_generic_node (pp, op0, spc, flags, false);
2808 pp_right_paren (pp);
2810 else
2811 dump_generic_node (pp, op0, spc, flags, false);
2813 pp_space (pp);
2814 pp_string (pp, op);
2815 pp_space (pp);
2817 /* When the operands are expressions with less priority,
2818 keep semantics of the tree representation. */
2819 if (op_prio (op1) <= op_prio (node))
2821 pp_left_paren (pp);
2822 dump_generic_node (pp, op1, spc, flags, false);
2823 pp_right_paren (pp);
2825 else
2826 dump_generic_node (pp, op1, spc, flags, false);
2828 break;
2830 /* Unary arithmetic and logic expressions. */
2831 case NEGATE_EXPR:
2832 case BIT_NOT_EXPR:
2833 case TRUTH_NOT_EXPR:
2834 case ADDR_EXPR:
2835 case PREDECREMENT_EXPR:
2836 case PREINCREMENT_EXPR:
2837 case INDIRECT_REF:
2838 if (TREE_CODE (node) == ADDR_EXPR
2839 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2840 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2841 ; /* Do not output '&' for strings and function pointers. */
2842 else
2843 pp_string (pp, op_symbol (node));
2845 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2847 pp_left_paren (pp);
2848 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2849 pp_right_paren (pp);
2851 else
2852 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2853 break;
2855 case POSTDECREMENT_EXPR:
2856 case POSTINCREMENT_EXPR:
2857 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2859 pp_left_paren (pp);
2860 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2861 pp_right_paren (pp);
2863 else
2864 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2865 pp_string (pp, op_symbol (node));
2866 break;
2868 case MIN_EXPR:
2869 pp_string (pp, "MIN_EXPR <");
2870 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2871 pp_string (pp, ", ");
2872 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2873 pp_greater (pp);
2874 break;
2876 case MAX_EXPR:
2877 pp_string (pp, "MAX_EXPR <");
2878 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2879 pp_string (pp, ", ");
2880 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2881 pp_greater (pp);
2882 break;
2884 case ABS_EXPR:
2885 pp_string (pp, "ABS_EXPR <");
2886 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2887 pp_greater (pp);
2888 break;
2890 case ABSU_EXPR:
2891 pp_string (pp, "ABSU_EXPR <");
2892 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2893 pp_greater (pp);
2894 break;
2896 case RANGE_EXPR:
2897 NIY;
2898 break;
2900 case ADDR_SPACE_CONVERT_EXPR:
2901 case FIXED_CONVERT_EXPR:
2902 case FIX_TRUNC_EXPR:
2903 case FLOAT_EXPR:
2904 CASE_CONVERT:
2905 type = TREE_TYPE (node);
2906 op0 = TREE_OPERAND (node, 0);
2907 if (type != TREE_TYPE (op0))
2909 pp_left_paren (pp);
2910 dump_generic_node (pp, type, spc, flags, false);
2911 pp_string (pp, ") ");
2913 if (op_prio (op0) < op_prio (node))
2914 pp_left_paren (pp);
2915 dump_generic_node (pp, op0, spc, flags, false);
2916 if (op_prio (op0) < op_prio (node))
2917 pp_right_paren (pp);
2918 break;
2920 case VIEW_CONVERT_EXPR:
2921 if (flags & TDF_GIMPLE)
2922 pp_string (pp, "__VIEW_CONVERT <");
2923 else
2924 pp_string (pp, "VIEW_CONVERT_EXPR<");
2925 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2926 pp_string (pp, ">(");
2927 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2928 pp_right_paren (pp);
2929 break;
2931 case PAREN_EXPR:
2932 pp_string (pp, "((");
2933 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2934 pp_string (pp, "))");
2935 break;
2937 case NON_LVALUE_EXPR:
2938 pp_string (pp, "NON_LVALUE_EXPR <");
2939 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2940 pp_greater (pp);
2941 break;
2943 case SAVE_EXPR:
2944 pp_string (pp, "SAVE_EXPR <");
2945 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2946 pp_greater (pp);
2947 break;
2949 case COMPLEX_EXPR:
2950 pp_string (pp, "COMPLEX_EXPR <");
2951 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2952 pp_string (pp, ", ");
2953 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2954 pp_greater (pp);
2955 break;
2957 case CONJ_EXPR:
2958 pp_string (pp, "CONJ_EXPR <");
2959 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2960 pp_greater (pp);
2961 break;
2963 case REALPART_EXPR:
2964 if (flags & TDF_GIMPLE)
2966 pp_string (pp, "__real ");
2967 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2969 else
2971 pp_string (pp, "REALPART_EXPR <");
2972 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2973 pp_greater (pp);
2975 break;
2977 case IMAGPART_EXPR:
2978 if (flags & TDF_GIMPLE)
2980 pp_string (pp, "__imag ");
2981 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2983 else
2985 pp_string (pp, "IMAGPART_EXPR <");
2986 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2987 pp_greater (pp);
2989 break;
2991 case VA_ARG_EXPR:
2992 pp_string (pp, "VA_ARG_EXPR <");
2993 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2994 pp_greater (pp);
2995 break;
2997 case TRY_FINALLY_EXPR:
2998 case TRY_CATCH_EXPR:
2999 pp_string (pp, "try");
3000 newline_and_indent (pp, spc+2);
3001 pp_left_brace (pp);
3002 newline_and_indent (pp, spc+4);
3003 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
3004 newline_and_indent (pp, spc+2);
3005 pp_right_brace (pp);
3006 newline_and_indent (pp, spc);
3007 if (TREE_CODE (node) == TRY_CATCH_EXPR)
3009 node = TREE_OPERAND (node, 1);
3010 pp_string (pp, "catch");
3012 else
3014 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
3015 node = TREE_OPERAND (node, 1);
3016 pp_string (pp, "finally");
3017 if (TREE_CODE (node) == EH_ELSE_EXPR)
3019 newline_and_indent (pp, spc+2);
3020 pp_left_brace (pp);
3021 newline_and_indent (pp, spc+4);
3022 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
3023 flags, true);
3024 newline_and_indent (pp, spc+2);
3025 pp_right_brace (pp);
3026 newline_and_indent (pp, spc);
3027 node = TREE_OPERAND (node, 1);
3028 pp_string (pp, "else");
3031 newline_and_indent (pp, spc+2);
3032 pp_left_brace (pp);
3033 newline_and_indent (pp, spc+4);
3034 dump_generic_node (pp, node, spc+4, flags, true);
3035 newline_and_indent (pp, spc+2);
3036 pp_right_brace (pp);
3037 is_expr = false;
3038 break;
3040 case CATCH_EXPR:
3041 pp_string (pp, "catch (");
3042 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
3043 pp_right_paren (pp);
3044 newline_and_indent (pp, spc+2);
3045 pp_left_brace (pp);
3046 newline_and_indent (pp, spc+4);
3047 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
3048 newline_and_indent (pp, spc+2);
3049 pp_right_brace (pp);
3050 is_expr = false;
3051 break;
3053 case EH_FILTER_EXPR:
3054 pp_string (pp, "<<<eh_filter (");
3055 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
3056 pp_string (pp, ")>>>");
3057 newline_and_indent (pp, spc+2);
3058 pp_left_brace (pp);
3059 newline_and_indent (pp, spc+4);
3060 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
3061 newline_and_indent (pp, spc+2);
3062 pp_right_brace (pp);
3063 is_expr = false;
3064 break;
3066 case LABEL_EXPR:
3067 op0 = TREE_OPERAND (node, 0);
3068 /* If this is for break or continue, don't bother printing it. */
3069 if (DECL_NAME (op0))
3071 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3072 if (strcmp (name, "break") == 0
3073 || strcmp (name, "continue") == 0)
3074 break;
3076 dump_generic_node (pp, op0, spc, flags, false);
3077 pp_colon (pp);
3078 if (DECL_NONLOCAL (op0))
3079 pp_string (pp, " [non-local]");
3080 break;
3082 case LOOP_EXPR:
3083 pp_string (pp, "while (1)");
3084 if (!(flags & TDF_SLIM))
3086 newline_and_indent (pp, spc+2);
3087 pp_left_brace (pp);
3088 newline_and_indent (pp, spc+4);
3089 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
3090 newline_and_indent (pp, spc+2);
3091 pp_right_brace (pp);
3093 is_expr = false;
3094 break;
3096 case PREDICT_EXPR:
3097 pp_string (pp, "// predicted ");
3098 if (PREDICT_EXPR_OUTCOME (node))
3099 pp_string (pp, "likely by ");
3100 else
3101 pp_string (pp, "unlikely by ");
3102 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
3103 pp_string (pp, " predictor.");
3104 break;
3106 case ANNOTATE_EXPR:
3107 pp_string (pp, "ANNOTATE_EXPR <");
3108 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3109 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
3111 case annot_expr_ivdep_kind:
3112 pp_string (pp, ", ivdep");
3113 break;
3114 case annot_expr_unroll_kind:
3116 pp_string (pp, ", unroll ");
3117 pp_decimal_int (pp,
3118 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
3119 break;
3121 case annot_expr_no_vector_kind:
3122 pp_string (pp, ", no-vector");
3123 break;
3124 case annot_expr_vector_kind:
3125 pp_string (pp, ", vector");
3126 break;
3127 case annot_expr_parallel_kind:
3128 pp_string (pp, ", parallel");
3129 break;
3130 default:
3131 gcc_unreachable ();
3133 pp_greater (pp);
3134 break;
3136 case RETURN_EXPR:
3137 pp_string (pp, "return");
3138 op0 = TREE_OPERAND (node, 0);
3139 if (op0)
3141 pp_space (pp);
3142 if (TREE_CODE (op0) == MODIFY_EXPR)
3143 dump_generic_node (pp, TREE_OPERAND (op0, 1),
3144 spc, flags, false);
3145 else
3146 dump_generic_node (pp, op0, spc, flags, false);
3148 break;
3150 case EXIT_EXPR:
3151 pp_string (pp, "if (");
3152 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3153 pp_string (pp, ") break");
3154 break;
3156 case SWITCH_EXPR:
3157 pp_string (pp, "switch (");
3158 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3159 pp_right_paren (pp);
3160 if (!(flags & TDF_SLIM))
3162 newline_and_indent (pp, spc+2);
3163 pp_left_brace (pp);
3164 if (SWITCH_BODY (node))
3166 newline_and_indent (pp, spc+4);
3167 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3168 true);
3170 newline_and_indent (pp, spc+2);
3171 pp_right_brace (pp);
3173 is_expr = false;
3174 break;
3176 case GOTO_EXPR:
3177 op0 = GOTO_DESTINATION (node);
3178 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3180 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3181 if (strcmp (name, "break") == 0
3182 || strcmp (name, "continue") == 0)
3184 pp_string (pp, name);
3185 break;
3188 pp_string (pp, "goto ");
3189 dump_generic_node (pp, op0, spc, flags, false);
3190 break;
3192 case ASM_EXPR:
3193 pp_string (pp, "__asm__");
3194 if (ASM_VOLATILE_P (node))
3195 pp_string (pp, " __volatile__");
3196 pp_left_paren (pp);
3197 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3198 pp_colon (pp);
3199 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3200 pp_colon (pp);
3201 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3202 if (ASM_CLOBBERS (node))
3204 pp_colon (pp);
3205 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3207 pp_right_paren (pp);
3208 break;
3210 case CASE_LABEL_EXPR:
3211 if (CASE_LOW (node) && CASE_HIGH (node))
3213 pp_string (pp, "case ");
3214 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3215 pp_string (pp, " ... ");
3216 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3218 else if (CASE_LOW (node))
3220 pp_string (pp, "case ");
3221 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3223 else
3224 pp_string (pp, "default");
3225 pp_colon (pp);
3226 break;
3228 case OBJ_TYPE_REF:
3229 pp_string (pp, "OBJ_TYPE_REF(");
3230 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3231 pp_semicolon (pp);
3232 /* We omit the class type for -fcompare-debug because we may
3233 drop TYPE_BINFO early depending on debug info, and then
3234 virtual_method_call_p would return false, whereas when
3235 TYPE_BINFO is preserved it may still return true and then
3236 we'd print the class type. Compare tree and rtl dumps for
3237 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3238 for example, at occurrences of OBJ_TYPE_REF. */
3239 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3240 && virtual_method_call_p (node, true))
3242 pp_string (pp, "(");
3243 dump_generic_node (pp, obj_type_ref_class (node, true),
3244 spc, flags, false);
3245 pp_string (pp, ")");
3247 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3248 pp_arrow (pp);
3249 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3250 pp_right_paren (pp);
3251 break;
3253 case SSA_NAME:
3254 if (SSA_NAME_IDENTIFIER (node))
3256 if ((flags & TDF_NOUID)
3257 && SSA_NAME_VAR (node)
3258 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3259 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3260 else if (! (flags & TDF_GIMPLE)
3261 || SSA_NAME_VAR (node))
3262 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3263 spc, flags, false);
3265 pp_underscore (pp);
3266 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3267 if (SSA_NAME_IS_DEFAULT_DEF (node))
3268 pp_string (pp, "(D)");
3269 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3270 pp_string (pp, "(ab)");
3271 break;
3273 case WITH_SIZE_EXPR:
3274 pp_string (pp, "WITH_SIZE_EXPR <");
3275 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3276 pp_string (pp, ", ");
3277 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3278 pp_greater (pp);
3279 break;
3281 case ASSERT_EXPR:
3282 pp_string (pp, "ASSERT_EXPR <");
3283 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3284 pp_string (pp, ", ");
3285 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3286 pp_greater (pp);
3287 break;
3289 case SCEV_KNOWN:
3290 pp_string (pp, "scev_known");
3291 break;
3293 case SCEV_NOT_KNOWN:
3294 pp_string (pp, "scev_not_known");
3295 break;
3297 case POLYNOMIAL_CHREC:
3298 pp_left_brace (pp);
3299 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3300 pp_string (pp, ", +, ");
3301 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3302 pp_string (pp, "}_");
3303 pp_scalar (pp, "%u", CHREC_VARIABLE (node));
3304 is_stmt = false;
3305 break;
3307 case REALIGN_LOAD_EXPR:
3308 pp_string (pp, "REALIGN_LOAD <");
3309 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3310 pp_string (pp, ", ");
3311 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3312 pp_string (pp, ", ");
3313 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3314 pp_greater (pp);
3315 break;
3317 case VEC_COND_EXPR:
3318 pp_string (pp, " VEC_COND_EXPR < ");
3319 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3320 pp_string (pp, " , ");
3321 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3322 pp_string (pp, " , ");
3323 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3324 pp_string (pp, " > ");
3325 break;
3327 case VEC_PERM_EXPR:
3328 pp_string (pp, " VEC_PERM_EXPR < ");
3329 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3330 pp_string (pp, " , ");
3331 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3332 pp_string (pp, " , ");
3333 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3334 pp_string (pp, " > ");
3335 break;
3337 case DOT_PROD_EXPR:
3338 pp_string (pp, " DOT_PROD_EXPR < ");
3339 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3340 pp_string (pp, ", ");
3341 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3342 pp_string (pp, ", ");
3343 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3344 pp_string (pp, " > ");
3345 break;
3347 case WIDEN_MULT_PLUS_EXPR:
3348 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3349 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3350 pp_string (pp, ", ");
3351 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3352 pp_string (pp, ", ");
3353 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3354 pp_string (pp, " > ");
3355 break;
3357 case WIDEN_MULT_MINUS_EXPR:
3358 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3359 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3360 pp_string (pp, ", ");
3361 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3362 pp_string (pp, ", ");
3363 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3364 pp_string (pp, " > ");
3365 break;
3367 case OACC_PARALLEL:
3368 pp_string (pp, "#pragma acc parallel");
3369 goto dump_omp_clauses_body;
3371 case OACC_KERNELS:
3372 pp_string (pp, "#pragma acc kernels");
3373 goto dump_omp_clauses_body;
3375 case OACC_SERIAL:
3376 pp_string (pp, "#pragma acc serial");
3377 goto dump_omp_clauses_body;
3379 case OACC_DATA:
3380 pp_string (pp, "#pragma acc data");
3381 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3382 goto dump_omp_body;
3384 case OACC_HOST_DATA:
3385 pp_string (pp, "#pragma acc host_data");
3386 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3387 goto dump_omp_body;
3389 case OACC_DECLARE:
3390 pp_string (pp, "#pragma acc declare");
3391 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3392 break;
3394 case OACC_UPDATE:
3395 pp_string (pp, "#pragma acc update");
3396 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3397 break;
3399 case OACC_ENTER_DATA:
3400 pp_string (pp, "#pragma acc enter data");
3401 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3402 break;
3404 case OACC_EXIT_DATA:
3405 pp_string (pp, "#pragma acc exit data");
3406 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3407 break;
3409 case OACC_CACHE:
3410 pp_string (pp, "#pragma acc cache");
3411 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3412 break;
3414 case OMP_PARALLEL:
3415 pp_string (pp, "#pragma omp parallel");
3416 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3417 goto dump_omp_body;
3419 dump_omp_clauses_body:
3420 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3421 goto dump_omp_body;
3423 dump_omp_body:
3424 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3426 newline_and_indent (pp, spc + 2);
3427 pp_left_brace (pp);
3428 newline_and_indent (pp, spc + 4);
3429 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3430 newline_and_indent (pp, spc + 2);
3431 pp_right_brace (pp);
3433 is_expr = false;
3434 break;
3436 case OMP_TASK:
3437 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3438 : "#pragma omp taskwait");
3439 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3440 goto dump_omp_body;
3442 case OMP_FOR:
3443 pp_string (pp, "#pragma omp for");
3444 goto dump_omp_loop;
3446 case OMP_SIMD:
3447 pp_string (pp, "#pragma omp simd");
3448 goto dump_omp_loop;
3450 case OMP_DISTRIBUTE:
3451 pp_string (pp, "#pragma omp distribute");
3452 goto dump_omp_loop;
3454 case OMP_TASKLOOP:
3455 pp_string (pp, "#pragma omp taskloop");
3456 goto dump_omp_loop;
3458 case OMP_LOOP:
3459 pp_string (pp, "#pragma omp loop");
3460 goto dump_omp_loop;
3462 case OACC_LOOP:
3463 pp_string (pp, "#pragma acc loop");
3464 goto dump_omp_loop;
3466 case OMP_TEAMS:
3467 pp_string (pp, "#pragma omp teams");
3468 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3469 goto dump_omp_body;
3471 case OMP_TARGET_DATA:
3472 pp_string (pp, "#pragma omp target data");
3473 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3474 goto dump_omp_body;
3476 case OMP_TARGET_ENTER_DATA:
3477 pp_string (pp, "#pragma omp target enter data");
3478 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3479 is_expr = false;
3480 break;
3482 case OMP_TARGET_EXIT_DATA:
3483 pp_string (pp, "#pragma omp target exit data");
3484 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3485 is_expr = false;
3486 break;
3488 case OMP_TARGET:
3489 pp_string (pp, "#pragma omp target");
3490 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3491 goto dump_omp_body;
3493 case OMP_TARGET_UPDATE:
3494 pp_string (pp, "#pragma omp target update");
3495 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3496 is_expr = false;
3497 break;
3499 dump_omp_loop:
3500 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3501 if (!(flags & TDF_SLIM))
3503 int i;
3505 if (OMP_FOR_PRE_BODY (node))
3507 newline_and_indent (pp, spc + 2);
3508 pp_left_brace (pp);
3509 spc += 4;
3510 newline_and_indent (pp, spc);
3511 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3512 spc, flags, false);
3514 if (OMP_FOR_INIT (node))
3516 spc -= 2;
3517 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3519 spc += 2;
3520 newline_and_indent (pp, spc);
3521 pp_string (pp, "for (");
3522 tree init = TREE_VEC_ELT (OMP_FOR_INIT (node), i);
3523 if (TREE_CODE (init) != MODIFY_EXPR
3524 || TREE_CODE (TREE_OPERAND (init, 1)) != TREE_VEC)
3525 dump_generic_node (pp, init, spc, flags, false);
3526 else
3528 dump_generic_node (pp, TREE_OPERAND (init, 0),
3529 spc, flags, false);
3530 pp_string (pp, " = ");
3531 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (init, 1),
3532 spc, flags);
3534 pp_string (pp, "; ");
3535 tree cond = TREE_VEC_ELT (OMP_FOR_COND (node), i);
3536 if (!COMPARISON_CLASS_P (cond)
3537 || TREE_CODE (TREE_OPERAND (cond, 1)) != TREE_VEC)
3538 dump_generic_node (pp, cond, spc, flags, false);
3539 else
3541 dump_generic_node (pp, TREE_OPERAND (cond, 0),
3542 spc, flags, false);
3543 const char *op = op_symbol (cond);
3544 pp_space (pp);
3545 pp_string (pp, op);
3546 pp_space (pp);
3547 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (cond, 1),
3548 spc, flags);
3550 pp_string (pp, "; ");
3551 dump_generic_node (pp,
3552 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3553 spc, flags, false);
3554 pp_right_paren (pp);
3557 if (OMP_FOR_BODY (node))
3559 newline_and_indent (pp, spc + 2);
3560 pp_left_brace (pp);
3561 newline_and_indent (pp, spc + 4);
3562 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3563 false);
3564 newline_and_indent (pp, spc + 2);
3565 pp_right_brace (pp);
3567 if (OMP_FOR_INIT (node))
3568 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3569 if (OMP_FOR_PRE_BODY (node))
3571 spc -= 4;
3572 newline_and_indent (pp, spc + 2);
3573 pp_right_brace (pp);
3576 is_expr = false;
3577 break;
3579 case OMP_SECTIONS:
3580 pp_string (pp, "#pragma omp sections");
3581 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3582 goto dump_omp_body;
3584 case OMP_SECTION:
3585 pp_string (pp, "#pragma omp section");
3586 goto dump_omp_body;
3588 case OMP_SCAN:
3589 if (OMP_SCAN_CLAUSES (node))
3591 pp_string (pp, "#pragma omp scan");
3592 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3594 goto dump_omp_body;
3596 case OMP_MASTER:
3597 pp_string (pp, "#pragma omp master");
3598 goto dump_omp_body;
3600 case OMP_MASKED:
3601 pp_string (pp, "#pragma omp masked");
3602 dump_omp_clauses (pp, OMP_MASKED_CLAUSES (node), spc, flags);
3603 goto dump_omp_body;
3605 case OMP_TASKGROUP:
3606 pp_string (pp, "#pragma omp taskgroup");
3607 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3608 goto dump_omp_body;
3610 case OMP_ORDERED:
3611 pp_string (pp, "#pragma omp ordered");
3612 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3613 goto dump_omp_body;
3615 case OMP_CRITICAL:
3616 pp_string (pp, "#pragma omp critical");
3617 if (OMP_CRITICAL_NAME (node))
3619 pp_space (pp);
3620 pp_left_paren (pp);
3621 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3622 flags, false);
3623 pp_right_paren (pp);
3625 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3626 goto dump_omp_body;
3628 case OMP_ATOMIC:
3629 pp_string (pp, "#pragma omp atomic");
3630 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3631 newline_and_indent (pp, spc + 2);
3632 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3633 pp_space (pp);
3634 pp_equal (pp);
3635 pp_space (pp);
3636 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3637 break;
3639 case OMP_ATOMIC_READ:
3640 pp_string (pp, "#pragma omp atomic read");
3641 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3642 newline_and_indent (pp, spc + 2);
3643 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3644 pp_space (pp);
3645 break;
3647 case OMP_ATOMIC_CAPTURE_OLD:
3648 case OMP_ATOMIC_CAPTURE_NEW:
3649 pp_string (pp, "#pragma omp atomic capture");
3650 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3651 newline_and_indent (pp, spc + 2);
3652 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3653 pp_space (pp);
3654 pp_equal (pp);
3655 pp_space (pp);
3656 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3657 break;
3659 case OMP_SINGLE:
3660 pp_string (pp, "#pragma omp single");
3661 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3662 goto dump_omp_body;
3664 case OMP_SCOPE:
3665 pp_string (pp, "#pragma omp scope");
3666 dump_omp_clauses (pp, OMP_SCOPE_CLAUSES (node), spc, flags);
3667 goto dump_omp_body;
3669 case OMP_CLAUSE:
3670 /* If we come here, we're dumping something that's not an OMP construct,
3671 for example, OMP clauses attached to a function's '__attribute__'.
3672 Dump the whole OMP clause chain. */
3673 dump_omp_clauses (pp, node, spc, flags, false);
3674 is_expr = false;
3675 break;
3677 case TRANSACTION_EXPR:
3678 if (TRANSACTION_EXPR_OUTER (node))
3679 pp_string (pp, "__transaction_atomic [[outer]]");
3680 else if (TRANSACTION_EXPR_RELAXED (node))
3681 pp_string (pp, "__transaction_relaxed");
3682 else
3683 pp_string (pp, "__transaction_atomic");
3684 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3686 newline_and_indent (pp, spc);
3687 pp_left_brace (pp);
3688 newline_and_indent (pp, spc + 2);
3689 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3690 spc + 2, flags, false);
3691 newline_and_indent (pp, spc);
3692 pp_right_brace (pp);
3694 is_expr = false;
3695 break;
3697 case VEC_SERIES_EXPR:
3698 case VEC_WIDEN_MULT_HI_EXPR:
3699 case VEC_WIDEN_MULT_LO_EXPR:
3700 case VEC_WIDEN_PLUS_HI_EXPR:
3701 case VEC_WIDEN_PLUS_LO_EXPR:
3702 case VEC_WIDEN_MINUS_HI_EXPR:
3703 case VEC_WIDEN_MINUS_LO_EXPR:
3704 case VEC_WIDEN_MULT_EVEN_EXPR:
3705 case VEC_WIDEN_MULT_ODD_EXPR:
3706 case VEC_WIDEN_LSHIFT_HI_EXPR:
3707 case VEC_WIDEN_LSHIFT_LO_EXPR:
3708 pp_space (pp);
3709 for (str = get_tree_code_name (code); *str; str++)
3710 pp_character (pp, TOUPPER (*str));
3711 pp_string (pp, " < ");
3712 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3713 pp_string (pp, ", ");
3714 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3715 pp_string (pp, " > ");
3716 break;
3718 case VEC_DUPLICATE_EXPR:
3719 pp_space (pp);
3720 for (str = get_tree_code_name (code); *str; str++)
3721 pp_character (pp, TOUPPER (*str));
3722 pp_string (pp, " < ");
3723 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3724 pp_string (pp, " > ");
3725 break;
3727 case VEC_UNPACK_HI_EXPR:
3728 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3729 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3730 pp_string (pp, " > ");
3731 break;
3733 case VEC_UNPACK_LO_EXPR:
3734 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3735 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3736 pp_string (pp, " > ");
3737 break;
3739 case VEC_UNPACK_FLOAT_HI_EXPR:
3740 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3741 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3742 pp_string (pp, " > ");
3743 break;
3745 case VEC_UNPACK_FLOAT_LO_EXPR:
3746 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3747 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3748 pp_string (pp, " > ");
3749 break;
3751 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3752 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3753 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3754 pp_string (pp, " > ");
3755 break;
3757 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3758 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3759 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3760 pp_string (pp, " > ");
3761 break;
3763 case VEC_PACK_TRUNC_EXPR:
3764 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3765 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3766 pp_string (pp, ", ");
3767 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3768 pp_string (pp, " > ");
3769 break;
3771 case VEC_PACK_SAT_EXPR:
3772 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3773 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3774 pp_string (pp, ", ");
3775 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3776 pp_string (pp, " > ");
3777 break;
3779 case VEC_PACK_FIX_TRUNC_EXPR:
3780 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3781 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3782 pp_string (pp, ", ");
3783 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3784 pp_string (pp, " > ");
3785 break;
3787 case VEC_PACK_FLOAT_EXPR:
3788 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3789 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3790 pp_string (pp, ", ");
3791 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3792 pp_string (pp, " > ");
3793 break;
3795 case BLOCK:
3796 dump_block_node (pp, node, spc, flags);
3797 break;
3799 case DEBUG_BEGIN_STMT:
3800 pp_string (pp, "# DEBUG BEGIN STMT");
3801 break;
3803 default:
3804 NIY;
3807 if (is_stmt && is_expr)
3808 pp_semicolon (pp);
3810 return spc;
3813 /* Print the declaration of a variable. */
3815 void
3816 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3818 INDENT (spc);
3820 if (TREE_CODE(t) == NAMELIST_DECL)
3822 pp_string(pp, "namelist ");
3823 dump_decl_name (pp, t, flags);
3824 pp_semicolon (pp);
3825 return;
3828 if (TREE_CODE (t) == TYPE_DECL)
3829 pp_string (pp, "typedef ");
3831 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3832 pp_string (pp, "register ");
3834 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3835 pp_string (pp, "extern ");
3836 else if (TREE_STATIC (t))
3837 pp_string (pp, "static ");
3839 /* Print the type and name. */
3840 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3842 tree tmp;
3844 /* Print array's type. */
3845 tmp = TREE_TYPE (t);
3846 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3847 tmp = TREE_TYPE (tmp);
3848 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3850 /* Print variable's name. */
3851 pp_space (pp);
3852 dump_generic_node (pp, t, spc, flags, false);
3854 /* Print the dimensions. */
3855 tmp = TREE_TYPE (t);
3856 while (TREE_CODE (tmp) == ARRAY_TYPE)
3858 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3859 tmp = TREE_TYPE (tmp);
3862 else if (TREE_CODE (t) == FUNCTION_DECL)
3864 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3865 pp_space (pp);
3866 dump_decl_name (pp, t, flags);
3867 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3869 else
3871 /* Print type declaration. */
3872 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3874 /* Print variable's name. */
3875 pp_space (pp);
3876 dump_generic_node (pp, t, spc, flags, false);
3879 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3881 pp_string (pp, " __asm__ ");
3882 pp_left_paren (pp);
3883 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3884 pp_right_paren (pp);
3887 /* The initial value of a function serves to determine whether the function
3888 is declared or defined. So the following does not apply to function
3889 nodes. */
3890 if (TREE_CODE (t) != FUNCTION_DECL)
3892 /* Print the initial value. */
3893 if (DECL_INITIAL (t))
3895 pp_space (pp);
3896 pp_equal (pp);
3897 pp_space (pp);
3898 if (!(flags & TDF_SLIM))
3899 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3900 else
3901 pp_string (pp, "<<< omitted >>>");
3905 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3907 pp_string (pp, " [value-expr: ");
3908 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3909 pp_right_bracket (pp);
3912 pp_semicolon (pp);
3916 /* Prints a structure: name, fields, and methods.
3917 FIXME: Still incomplete. */
3919 static void
3920 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3921 dump_flags_t flags)
3923 /* Print the name of the structure. */
3924 if (TYPE_NAME (node))
3926 INDENT (spc);
3927 if (TREE_CODE (node) == RECORD_TYPE)
3928 pp_string (pp, "struct ");
3929 else if ((TREE_CODE (node) == UNION_TYPE
3930 || TREE_CODE (node) == QUAL_UNION_TYPE))
3931 pp_string (pp, "union ");
3933 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3936 /* Print the contents of the structure. */
3937 pp_newline (pp);
3938 INDENT (spc);
3939 pp_left_brace (pp);
3940 pp_newline (pp);
3942 /* Print the fields of the structure. */
3944 tree tmp;
3945 tmp = TYPE_FIELDS (node);
3946 while (tmp)
3948 /* Avoid to print recursively the structure. */
3949 /* FIXME : Not implemented correctly...,
3950 what about the case when we have a cycle in the contain graph? ...
3951 Maybe this could be solved by looking at the scope in which the
3952 structure was declared. */
3953 if (TREE_TYPE (tmp) != node
3954 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3955 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3957 print_declaration (pp, tmp, spc+2, flags);
3958 pp_newline (pp);
3960 tmp = DECL_CHAIN (tmp);
3963 INDENT (spc);
3964 pp_right_brace (pp);
3967 /* Return the priority of the operator CODE.
3969 From lowest to highest precedence with either left-to-right (L-R)
3970 or right-to-left (R-L) associativity]:
3972 1 [L-R] ,
3973 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3974 3 [R-L] ?:
3975 4 [L-R] ||
3976 5 [L-R] &&
3977 6 [L-R] |
3978 7 [L-R] ^
3979 8 [L-R] &
3980 9 [L-R] == !=
3981 10 [L-R] < <= > >=
3982 11 [L-R] << >>
3983 12 [L-R] + -
3984 13 [L-R] * / %
3985 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3986 15 [L-R] fn() [] -> .
3988 unary +, - and * have higher precedence than the corresponding binary
3989 operators. */
3992 op_code_prio (enum tree_code code)
3994 switch (code)
3996 case TREE_LIST:
3997 case COMPOUND_EXPR:
3998 case BIND_EXPR:
3999 return 1;
4001 case MODIFY_EXPR:
4002 case INIT_EXPR:
4003 return 2;
4005 case COND_EXPR:
4006 return 3;
4008 case TRUTH_OR_EXPR:
4009 case TRUTH_ORIF_EXPR:
4010 return 4;
4012 case TRUTH_AND_EXPR:
4013 case TRUTH_ANDIF_EXPR:
4014 return 5;
4016 case BIT_IOR_EXPR:
4017 return 6;
4019 case BIT_XOR_EXPR:
4020 case TRUTH_XOR_EXPR:
4021 return 7;
4023 case BIT_AND_EXPR:
4024 return 8;
4026 case EQ_EXPR:
4027 case NE_EXPR:
4028 return 9;
4030 case UNLT_EXPR:
4031 case UNLE_EXPR:
4032 case UNGT_EXPR:
4033 case UNGE_EXPR:
4034 case UNEQ_EXPR:
4035 case LTGT_EXPR:
4036 case ORDERED_EXPR:
4037 case UNORDERED_EXPR:
4038 case LT_EXPR:
4039 case LE_EXPR:
4040 case GT_EXPR:
4041 case GE_EXPR:
4042 return 10;
4044 case LSHIFT_EXPR:
4045 case RSHIFT_EXPR:
4046 case LROTATE_EXPR:
4047 case RROTATE_EXPR:
4048 case VEC_WIDEN_LSHIFT_HI_EXPR:
4049 case VEC_WIDEN_LSHIFT_LO_EXPR:
4050 case WIDEN_LSHIFT_EXPR:
4051 return 11;
4053 case WIDEN_SUM_EXPR:
4054 case PLUS_EXPR:
4055 case POINTER_PLUS_EXPR:
4056 case POINTER_DIFF_EXPR:
4057 case MINUS_EXPR:
4058 return 12;
4060 case VEC_WIDEN_MULT_HI_EXPR:
4061 case VEC_WIDEN_MULT_LO_EXPR:
4062 case WIDEN_MULT_EXPR:
4063 case DOT_PROD_EXPR:
4064 case WIDEN_MULT_PLUS_EXPR:
4065 case WIDEN_MULT_MINUS_EXPR:
4066 case MULT_EXPR:
4067 case MULT_HIGHPART_EXPR:
4068 case TRUNC_DIV_EXPR:
4069 case CEIL_DIV_EXPR:
4070 case FLOOR_DIV_EXPR:
4071 case ROUND_DIV_EXPR:
4072 case RDIV_EXPR:
4073 case EXACT_DIV_EXPR:
4074 case TRUNC_MOD_EXPR:
4075 case CEIL_MOD_EXPR:
4076 case FLOOR_MOD_EXPR:
4077 case ROUND_MOD_EXPR:
4078 return 13;
4080 case TRUTH_NOT_EXPR:
4081 case BIT_NOT_EXPR:
4082 case POSTINCREMENT_EXPR:
4083 case POSTDECREMENT_EXPR:
4084 case PREINCREMENT_EXPR:
4085 case PREDECREMENT_EXPR:
4086 case NEGATE_EXPR:
4087 case INDIRECT_REF:
4088 case ADDR_EXPR:
4089 case FLOAT_EXPR:
4090 CASE_CONVERT:
4091 case FIX_TRUNC_EXPR:
4092 case TARGET_EXPR:
4093 return 14;
4095 case CALL_EXPR:
4096 case ARRAY_REF:
4097 case ARRAY_RANGE_REF:
4098 case COMPONENT_REF:
4099 return 15;
4101 /* Special expressions. */
4102 case MIN_EXPR:
4103 case MAX_EXPR:
4104 case ABS_EXPR:
4105 case REALPART_EXPR:
4106 case IMAGPART_EXPR:
4107 case VEC_UNPACK_HI_EXPR:
4108 case VEC_UNPACK_LO_EXPR:
4109 case VEC_UNPACK_FLOAT_HI_EXPR:
4110 case VEC_UNPACK_FLOAT_LO_EXPR:
4111 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
4112 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
4113 case VEC_PACK_TRUNC_EXPR:
4114 case VEC_PACK_SAT_EXPR:
4115 return 16;
4117 default:
4118 /* Return an arbitrarily high precedence to avoid surrounding single
4119 VAR_DECLs in ()s. */
4120 return 9999;
4124 /* Return the priority of the operator OP. */
4127 op_prio (const_tree op)
4129 enum tree_code code;
4131 if (op == NULL)
4132 return 9999;
4134 code = TREE_CODE (op);
4135 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
4136 return op_prio (TREE_OPERAND (op, 0));
4138 return op_code_prio (code);
4141 /* Return the symbol associated with operator CODE. */
4143 const char *
4144 op_symbol_code (enum tree_code code)
4146 switch (code)
4148 case MODIFY_EXPR:
4149 return "=";
4151 case TRUTH_OR_EXPR:
4152 case TRUTH_ORIF_EXPR:
4153 return "||";
4155 case TRUTH_AND_EXPR:
4156 case TRUTH_ANDIF_EXPR:
4157 return "&&";
4159 case BIT_IOR_EXPR:
4160 return "|";
4162 case TRUTH_XOR_EXPR:
4163 case BIT_XOR_EXPR:
4164 return "^";
4166 case ADDR_EXPR:
4167 case BIT_AND_EXPR:
4168 return "&";
4170 case ORDERED_EXPR:
4171 return "ord";
4172 case UNORDERED_EXPR:
4173 return "unord";
4175 case EQ_EXPR:
4176 return "==";
4177 case UNEQ_EXPR:
4178 return "u==";
4180 case NE_EXPR:
4181 return "!=";
4183 case LT_EXPR:
4184 return "<";
4185 case UNLT_EXPR:
4186 return "u<";
4188 case LE_EXPR:
4189 return "<=";
4190 case UNLE_EXPR:
4191 return "u<=";
4193 case GT_EXPR:
4194 return ">";
4195 case UNGT_EXPR:
4196 return "u>";
4198 case GE_EXPR:
4199 return ">=";
4200 case UNGE_EXPR:
4201 return "u>=";
4203 case LTGT_EXPR:
4204 return "<>";
4206 case LSHIFT_EXPR:
4207 return "<<";
4209 case RSHIFT_EXPR:
4210 return ">>";
4212 case LROTATE_EXPR:
4213 return "r<<";
4215 case RROTATE_EXPR:
4216 return "r>>";
4218 case WIDEN_LSHIFT_EXPR:
4219 return "w<<";
4221 case WIDEN_PLUS_EXPR:
4222 return "w+";
4224 case WIDEN_MINUS_EXPR:
4225 return "w-";
4227 case POINTER_PLUS_EXPR:
4228 return "+";
4230 case PLUS_EXPR:
4231 return "+";
4233 case WIDEN_SUM_EXPR:
4234 return "w+";
4236 case WIDEN_MULT_EXPR:
4237 return "w*";
4239 case MULT_HIGHPART_EXPR:
4240 return "h*";
4242 case NEGATE_EXPR:
4243 case MINUS_EXPR:
4244 case POINTER_DIFF_EXPR:
4245 return "-";
4247 case BIT_NOT_EXPR:
4248 return "~";
4250 case TRUTH_NOT_EXPR:
4251 return "!";
4253 case MULT_EXPR:
4254 case INDIRECT_REF:
4255 return "*";
4257 case TRUNC_DIV_EXPR:
4258 case RDIV_EXPR:
4259 return "/";
4261 case CEIL_DIV_EXPR:
4262 return "/[cl]";
4264 case FLOOR_DIV_EXPR:
4265 return "/[fl]";
4267 case ROUND_DIV_EXPR:
4268 return "/[rd]";
4270 case EXACT_DIV_EXPR:
4271 return "/[ex]";
4273 case TRUNC_MOD_EXPR:
4274 return "%";
4276 case CEIL_MOD_EXPR:
4277 return "%[cl]";
4279 case FLOOR_MOD_EXPR:
4280 return "%[fl]";
4282 case ROUND_MOD_EXPR:
4283 return "%[rd]";
4285 case PREDECREMENT_EXPR:
4286 return " --";
4288 case PREINCREMENT_EXPR:
4289 return " ++";
4291 case POSTDECREMENT_EXPR:
4292 return "-- ";
4294 case POSTINCREMENT_EXPR:
4295 return "++ ";
4297 case MAX_EXPR:
4298 return "max";
4300 case MIN_EXPR:
4301 return "min";
4303 default:
4304 return "<<< ??? >>>";
4308 /* Return the symbol associated with operator OP. */
4310 static const char *
4311 op_symbol (const_tree op)
4313 return op_symbol_code (TREE_CODE (op));
4316 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4317 the gimple_call_fn of a GIMPLE_CALL. */
4319 void
4320 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4322 tree op0 = node;
4324 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4325 op0 = TREE_OPERAND (op0, 0);
4327 again:
4328 switch (TREE_CODE (op0))
4330 case VAR_DECL:
4331 case PARM_DECL:
4332 case FUNCTION_DECL:
4333 dump_function_name (pp, op0, flags);
4334 break;
4336 case ADDR_EXPR:
4337 case INDIRECT_REF:
4338 CASE_CONVERT:
4339 op0 = TREE_OPERAND (op0, 0);
4340 goto again;
4342 case COND_EXPR:
4343 pp_left_paren (pp);
4344 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4345 pp_string (pp, ") ? ");
4346 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4347 pp_string (pp, " : ");
4348 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4349 break;
4351 case ARRAY_REF:
4352 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4353 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4354 else
4355 dump_generic_node (pp, op0, 0, flags, false);
4356 break;
4358 case MEM_REF:
4359 if (integer_zerop (TREE_OPERAND (op0, 1)))
4361 op0 = TREE_OPERAND (op0, 0);
4362 goto again;
4364 /* Fallthru. */
4365 case COMPONENT_REF:
4366 case SSA_NAME:
4367 case OBJ_TYPE_REF:
4368 dump_generic_node (pp, op0, 0, flags, false);
4369 break;
4371 default:
4372 NIY;
4376 /* Print the first N characters in the array STR, replacing non-printable
4377 characters (including embedded nuls) with unambiguous escape sequences. */
4379 void
4380 pretty_print_string (pretty_printer *pp, const char *str, size_t n)
4382 if (str == NULL)
4383 return;
4385 for ( ; n; --n, ++str)
4387 switch (str[0])
4389 case '\b':
4390 pp_string (pp, "\\b");
4391 break;
4393 case '\f':
4394 pp_string (pp, "\\f");
4395 break;
4397 case '\n':
4398 pp_string (pp, "\\n");
4399 break;
4401 case '\r':
4402 pp_string (pp, "\\r");
4403 break;
4405 case '\t':
4406 pp_string (pp, "\\t");
4407 break;
4409 case '\v':
4410 pp_string (pp, "\\v");
4411 break;
4413 case '\\':
4414 pp_string (pp, "\\\\");
4415 break;
4417 case '\"':
4418 pp_string (pp, "\\\"");
4419 break;
4421 case '\'':
4422 pp_string (pp, "\\'");
4423 break;
4425 default:
4426 if (str[0] || n > 1)
4428 if (!ISPRINT (str[0]))
4430 char buf[5];
4431 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4432 pp_string (pp, buf);
4434 else
4435 pp_character (pp, str[0]);
4436 break;
4442 static void
4443 maybe_init_pretty_print (FILE *file)
4445 if (!tree_pp)
4447 tree_pp = new pretty_printer ();
4448 pp_needs_newline (tree_pp) = true;
4449 pp_translate_identifiers (tree_pp) = false;
4452 tree_pp->buffer->stream = file;
4455 static void
4456 newline_and_indent (pretty_printer *pp, int spc)
4458 pp_newline (pp);
4459 INDENT (spc);
4462 /* Print the identifier ID to PRETTY-PRINTER. */
4464 void
4465 pp_tree_identifier (pretty_printer *pp, tree id)
4467 if (pp_translate_identifiers (pp))
4469 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4470 pp_append_text (pp, text, text + strlen (text));
4472 else
4473 pp_append_text (pp, IDENTIFIER_POINTER (id),
4474 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4477 /* A helper function that is used to dump function information before the
4478 function dump. */
4480 void
4481 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4483 const char *dname, *aname;
4484 struct cgraph_node *node = cgraph_node::get (fdecl);
4485 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4487 dname = lang_hooks.decl_printable_name (fdecl, 1);
4489 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4490 aname = (IDENTIFIER_POINTER
4491 (DECL_ASSEMBLER_NAME (fdecl)));
4492 else
4493 aname = "<unset-asm-name>";
4495 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4496 dname, aname, fun->funcdef_no);
4497 if (!(flags & TDF_NOUID))
4498 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4499 if (node)
4501 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4502 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4503 node->frequency == NODE_FREQUENCY_HOT
4504 ? " (hot)"
4505 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4506 ? " (unlikely executed)"
4507 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4508 ? " (executed once)"
4509 : "");
4511 else
4512 fprintf (dump_file, ")\n\n");
4515 /* Dump double_int D to pretty_printer PP. UNS is true
4516 if D is unsigned and false otherwise. */
4517 void
4518 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4520 if (d.fits_shwi ())
4521 pp_wide_integer (pp, d.low);
4522 else if (d.fits_uhwi ())
4523 pp_unsigned_wide_integer (pp, d.low);
4524 else
4526 unsigned HOST_WIDE_INT low = d.low;
4527 HOST_WIDE_INT high = d.high;
4528 if (!uns && d.is_negative ())
4530 pp_minus (pp);
4531 high = ~high + !low;
4532 low = -low;
4534 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4535 systems? */
4536 sprintf (pp_buffer (pp)->digit_buffer,
4537 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4538 (unsigned HOST_WIDE_INT) high, low);
4539 pp_string (pp, pp_buffer (pp)->digit_buffer);
4543 #if __GNUC__ >= 10
4544 # pragma GCC diagnostic pop
4545 #endif