testsuite: Update pr79251 ilp32 store counts.
[official-gcc.git] / gcc / tree-pretty-print.c
blobaabe6bb23b9c407a666bec1df3f8cf94aebcacb1
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 /* Disable warnings about quoting issues in the pp_xxx calls below
40 that (intentionally) don't follow GCC diagnostic conventions. */
41 #if __GNUC__ >= 10
42 # pragma GCC diagnostic push
43 # pragma GCC diagnostic ignored "-Wformat-diag"
44 #endif
46 /* Local functions, macros and variables. */
47 static const char *op_symbol (const_tree);
48 static void newline_and_indent (pretty_printer *, int);
49 static void maybe_init_pretty_print (FILE *);
50 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
51 static void do_niy (pretty_printer *, const_tree, dump_flags_t);
53 #define INDENT(SPACE) do { \
54 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
56 #define NIY do_niy (pp, node, flags)
58 static pretty_printer *tree_pp;
60 /* Try to print something for an unknown tree code. */
62 static void
63 do_niy (pretty_printer *pp, const_tree node, dump_flags_t flags)
65 int i, len;
67 pp_string (pp, "<<< Unknown tree: ");
68 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
70 if (EXPR_P (node))
72 len = TREE_OPERAND_LENGTH (node);
73 for (i = 0; i < len; ++i)
75 newline_and_indent (pp, 2);
76 dump_generic_node (pp, TREE_OPERAND (node, i), 2, flags, false);
80 pp_string (pp, " >>>");
83 /* Debugging function to print out a generic expression. */
85 DEBUG_FUNCTION void
86 debug_generic_expr (tree t)
88 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
89 fprintf (stderr, "\n");
92 /* Debugging function to print out a generic statement. */
94 DEBUG_FUNCTION void
95 debug_generic_stmt (tree t)
97 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
98 fprintf (stderr, "\n");
101 /* Debugging function to print out a chain of trees . */
103 DEBUG_FUNCTION void
104 debug_tree_chain (tree t)
106 hash_set<tree> seen;
108 while (t)
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
111 fprintf (stderr, " ");
112 t = TREE_CHAIN (t);
113 if (seen.add (t))
115 fprintf (stderr, "... [cycled back to ");
116 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
117 fprintf (stderr, "]");
118 break;
121 fprintf (stderr, "\n");
124 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
125 void
126 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
128 maybe_init_pretty_print (file);
129 print_declaration (tree_pp, decl, 2, flags);
130 pp_write_text_to_stream (tree_pp);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in dumpfile.h. */
136 void
137 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
139 maybe_init_pretty_print (file);
140 dump_generic_node (tree_pp, t, 0, flags, true);
141 pp_newline_and_flush (tree_pp);
144 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
145 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
146 INDENT spaces. */
148 void
149 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
151 int i;
153 maybe_init_pretty_print (file);
155 for (i = 0; i < indent; i++)
156 pp_space (tree_pp);
157 dump_generic_node (tree_pp, t, indent, flags, true);
158 pp_newline_and_flush (tree_pp);
161 /* Print a single expression T on file FILE. FLAGS specifies details to show
162 in the dump. See TDF_* in dumpfile.h. */
164 void
165 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
167 maybe_init_pretty_print (file);
168 dump_generic_node (tree_pp, t, 0, flags, false);
169 pp_flush (tree_pp);
172 /* Print a single expression T to string, and return it. */
174 char *
175 print_generic_expr_to_str (tree t)
177 pretty_printer pp;
178 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
179 return xstrdup (pp_formatted_text (&pp));
182 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
183 in it are replaced with Dxxxx, as long as they are at the start or
184 preceded by $ and at the end or followed by $. See make_fancy_name
185 in tree-sra.c. */
187 static void
188 dump_fancy_name (pretty_printer *pp, tree name)
190 int cnt = 0;
191 int length = IDENTIFIER_LENGTH (name);
192 const char *n = IDENTIFIER_POINTER (name);
195 n = strchr (n, 'D');
196 if (n == NULL)
197 break;
198 if (ISDIGIT (n[1])
199 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
201 int l = 2;
202 while (ISDIGIT (n[l]))
203 l++;
204 if (n[l] == '\0' || n[l] == '$')
206 cnt++;
207 length += 5 - l;
209 n += l;
211 else
212 n++;
214 while (1);
215 if (cnt == 0)
217 pp_tree_identifier (pp, name);
218 return;
221 char *str = XNEWVEC (char, length + 1);
222 char *p = str;
223 const char *q;
224 q = n = IDENTIFIER_POINTER (name);
227 q = strchr (q, 'D');
228 if (q == NULL)
229 break;
230 if (ISDIGIT (q[1])
231 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
233 int l = 2;
234 while (ISDIGIT (q[l]))
235 l++;
236 if (q[l] == '\0' || q[l] == '$')
238 memcpy (p, n, q - n);
239 memcpy (p + (q - n), "Dxxxx", 5);
240 p += (q - n) + 5;
241 n = q + l;
243 q += l;
245 else
246 q++;
248 while (1);
249 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
250 str[length] = '\0';
251 if (pp_translate_identifiers (pp))
253 const char *text = identifier_to_locale (str);
254 pp_append_text (pp, text, text + strlen (text));
256 else
257 pp_append_text (pp, str, str + length);
258 XDELETEVEC (str);
261 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
262 in FLAGS. */
264 static void
265 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
267 tree name = DECL_NAME (node);
268 if (name)
270 if ((flags & TDF_ASMNAME)
271 && HAS_DECL_ASSEMBLER_NAME_P (node)
272 && DECL_ASSEMBLER_NAME_SET_P (node))
273 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
274 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
275 -g might have created more fancy names and their indexes
276 could get out of sync. Usually those should be DECL_IGNORED_P
277 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
278 names, let's hope those never get out of sync after doing the
279 dump_fancy_name sanitization. */
280 else if ((flags & TDF_COMPARE_DEBUG)
281 && DECL_NAMELESS (node)
282 && DECL_IGNORED_P (node))
283 name = NULL_TREE;
284 /* For DECL_NAMELESS names look for embedded uids in the
285 names and sanitize them for TDF_NOUID. */
286 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
287 dump_fancy_name (pp, name);
288 else
289 pp_tree_identifier (pp, name);
291 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
292 if ((flags & TDF_UID) || name == NULL_TREE)
294 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
295 pp_printf (pp, "L%c%d", uid_sep, (int) LABEL_DECL_UID (node));
296 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
298 if (flags & TDF_NOUID)
299 pp_string (pp, "D#xxxx");
300 else
301 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
303 else
305 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
306 if (flags & TDF_NOUID)
307 pp_printf (pp, "%c.xxxx", c);
308 else
309 pp_printf (pp, "%c%c%u", c, uid_sep, DECL_UID (node));
312 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
314 if (flags & TDF_NOUID)
315 pp_printf (pp, "ptD.xxxx");
316 else
317 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
321 /* Like the above, but used for pretty printing function calls. */
323 static void
324 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
326 if (CONVERT_EXPR_P (node))
327 node = TREE_OPERAND (node, 0);
328 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
329 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
330 else
331 dump_decl_name (pp, node, flags);
334 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
335 FLAGS are as in dump_generic_node. */
337 static void
338 dump_function_declaration (pretty_printer *pp, tree node,
339 int spc, dump_flags_t flags)
341 bool wrote_arg = false;
342 tree arg;
344 pp_space (pp);
345 pp_left_paren (pp);
347 /* Print the argument types. */
348 arg = TYPE_ARG_TYPES (node);
349 while (arg && arg != void_list_node && arg != error_mark_node)
351 if (wrote_arg)
353 pp_comma (pp);
354 pp_space (pp);
356 wrote_arg = true;
357 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
358 arg = TREE_CHAIN (arg);
361 /* Drop the trailing void_type_node if we had any previous argument. */
362 if (arg == void_list_node && !wrote_arg)
363 pp_string (pp, "void");
364 /* Properly dump vararg function types. */
365 else if (!arg && wrote_arg)
366 pp_string (pp, ", ...");
367 /* Avoid printing any arg for unprototyped functions. */
369 pp_right_paren (pp);
372 /* Dump the domain associated with an array. */
374 static void
375 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
377 pp_left_bracket (pp);
378 if (domain)
380 tree min = TYPE_MIN_VALUE (domain);
381 tree max = TYPE_MAX_VALUE (domain);
383 if (min && max
384 && integer_zerop (min)
385 && tree_fits_shwi_p (max))
386 pp_wide_integer (pp, tree_to_shwi (max) + 1);
387 else
389 if (min)
390 dump_generic_node (pp, min, spc, flags, false);
391 pp_colon (pp);
392 if (max)
393 dump_generic_node (pp, max, spc, flags, false);
396 else
397 pp_string (pp, "<unknown>");
398 pp_right_bracket (pp);
402 /* Dump OpenMP iterators ITER. */
404 static void
405 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
407 pp_string (pp, "iterator(");
408 for (tree it = iter; it; it = TREE_CHAIN (it))
410 if (it != iter)
411 pp_string (pp, ", ");
412 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
413 false);
414 pp_space (pp);
415 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
416 pp_equal (pp);
417 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
418 pp_colon (pp);
419 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
420 pp_colon (pp);
421 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
423 pp_right_paren (pp);
427 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
428 dump_generic_node. */
430 static void
431 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
433 const char *name;
434 const char *modifier = NULL;
435 switch (OMP_CLAUSE_CODE (clause))
437 case OMP_CLAUSE_PRIVATE:
438 name = "private";
439 goto print_remap;
440 case OMP_CLAUSE_SHARED:
441 name = "shared";
442 goto print_remap;
443 case OMP_CLAUSE_FIRSTPRIVATE:
444 name = "firstprivate";
445 goto print_remap;
446 case OMP_CLAUSE_LASTPRIVATE:
447 name = "lastprivate";
448 if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
449 modifier = "conditional:";
450 goto print_remap;
451 case OMP_CLAUSE_COPYIN:
452 name = "copyin";
453 goto print_remap;
454 case OMP_CLAUSE_COPYPRIVATE:
455 name = "copyprivate";
456 goto print_remap;
457 case OMP_CLAUSE_UNIFORM:
458 name = "uniform";
459 goto print_remap;
460 case OMP_CLAUSE_USE_DEVICE_PTR:
461 name = "use_device_ptr";
462 if (OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT (clause))
463 modifier = "if_present:";
464 goto print_remap;
465 case OMP_CLAUSE_USE_DEVICE_ADDR:
466 name = "use_device_addr";
467 goto print_remap;
468 case OMP_CLAUSE_IS_DEVICE_PTR:
469 name = "is_device_ptr";
470 goto print_remap;
471 case OMP_CLAUSE_INCLUSIVE:
472 name = "inclusive";
473 goto print_remap;
474 case OMP_CLAUSE_EXCLUSIVE:
475 name = "exclusive";
476 goto print_remap;
477 case OMP_CLAUSE__LOOPTEMP_:
478 name = "_looptemp_";
479 goto print_remap;
480 case OMP_CLAUSE__REDUCTEMP_:
481 name = "_reductemp_";
482 goto print_remap;
483 case OMP_CLAUSE__CONDTEMP_:
484 name = "_condtemp_";
485 goto print_remap;
486 case OMP_CLAUSE__SCANTEMP_:
487 name = "_scantemp_";
488 goto print_remap;
489 case OMP_CLAUSE_TO_DECLARE:
490 name = "to";
491 goto print_remap;
492 case OMP_CLAUSE_LINK:
493 name = "link";
494 goto print_remap;
495 case OMP_CLAUSE_NONTEMPORAL:
496 name = "nontemporal";
497 goto print_remap;
498 print_remap:
499 pp_string (pp, name);
500 pp_left_paren (pp);
501 if (modifier)
502 pp_string (pp, modifier);
503 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
504 spc, flags, false);
505 pp_right_paren (pp);
506 break;
508 case OMP_CLAUSE_TASK_REDUCTION:
509 case OMP_CLAUSE_IN_REDUCTION:
510 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
511 ? "in_" : "task_");
512 /* FALLTHRU */
513 case OMP_CLAUSE_REDUCTION:
514 pp_string (pp, "reduction(");
515 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
517 if (OMP_CLAUSE_REDUCTION_TASK (clause))
518 pp_string (pp, "task,");
519 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
520 pp_string (pp, "inscan,");
522 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
524 pp_string (pp,
525 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
526 pp_colon (pp);
528 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
529 spc, flags, false);
530 pp_right_paren (pp);
531 break;
533 case OMP_CLAUSE_IF:
534 pp_string (pp, "if(");
535 switch (OMP_CLAUSE_IF_MODIFIER (clause))
537 case ERROR_MARK: break;
538 case VOID_CST: pp_string (pp, "cancel:"); break;
539 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
540 case OMP_SIMD: pp_string (pp, "simd:"); break;
541 case OMP_TASK: pp_string (pp, "task:"); break;
542 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
543 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
544 case OMP_TARGET: pp_string (pp, "target:"); break;
545 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
546 case OMP_TARGET_ENTER_DATA:
547 pp_string (pp, "target enter data:"); break;
548 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
549 default: gcc_unreachable ();
551 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
552 spc, flags, false);
553 pp_right_paren (pp);
554 break;
556 case OMP_CLAUSE_NUM_THREADS:
557 pp_string (pp, "num_threads(");
558 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
559 spc, flags, false);
560 pp_right_paren (pp);
561 break;
563 case OMP_CLAUSE_NOWAIT:
564 pp_string (pp, "nowait");
565 break;
566 case OMP_CLAUSE_ORDERED:
567 pp_string (pp, "ordered");
568 if (OMP_CLAUSE_ORDERED_EXPR (clause))
570 pp_left_paren (pp);
571 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
572 spc, flags, false);
573 pp_right_paren (pp);
575 break;
577 case OMP_CLAUSE_DEFAULT:
578 pp_string (pp, "default(");
579 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
581 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
582 break;
583 case OMP_CLAUSE_DEFAULT_SHARED:
584 pp_string (pp, "shared");
585 break;
586 case OMP_CLAUSE_DEFAULT_NONE:
587 pp_string (pp, "none");
588 break;
589 case OMP_CLAUSE_DEFAULT_PRIVATE:
590 pp_string (pp, "private");
591 break;
592 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
593 pp_string (pp, "firstprivate");
594 break;
595 case OMP_CLAUSE_DEFAULT_PRESENT:
596 pp_string (pp, "present");
597 break;
598 default:
599 gcc_unreachable ();
601 pp_right_paren (pp);
602 break;
604 case OMP_CLAUSE_SCHEDULE:
605 pp_string (pp, "schedule(");
606 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
607 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
608 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
610 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
611 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
612 pp_string (pp, "monotonic");
613 else
614 pp_string (pp, "nonmonotonic");
615 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
616 pp_comma (pp);
617 else
618 pp_colon (pp);
620 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
621 pp_string (pp, "simd:");
623 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
625 case OMP_CLAUSE_SCHEDULE_STATIC:
626 pp_string (pp, "static");
627 break;
628 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
629 pp_string (pp, "dynamic");
630 break;
631 case OMP_CLAUSE_SCHEDULE_GUIDED:
632 pp_string (pp, "guided");
633 break;
634 case OMP_CLAUSE_SCHEDULE_RUNTIME:
635 pp_string (pp, "runtime");
636 break;
637 case OMP_CLAUSE_SCHEDULE_AUTO:
638 pp_string (pp, "auto");
639 break;
640 default:
641 gcc_unreachable ();
643 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
645 pp_comma (pp);
646 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
647 spc, flags, false);
649 pp_right_paren (pp);
650 break;
652 case OMP_CLAUSE_UNTIED:
653 pp_string (pp, "untied");
654 break;
656 case OMP_CLAUSE_COLLAPSE:
657 pp_string (pp, "collapse(");
658 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
659 spc, flags, false);
660 pp_right_paren (pp);
661 break;
663 case OMP_CLAUSE_FINAL:
664 pp_string (pp, "final(");
665 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
666 spc, flags, false);
667 pp_right_paren (pp);
668 break;
670 case OMP_CLAUSE_MERGEABLE:
671 pp_string (pp, "mergeable");
672 break;
674 case OMP_CLAUSE_LINEAR:
675 pp_string (pp, "linear(");
676 switch (OMP_CLAUSE_LINEAR_KIND (clause))
678 case OMP_CLAUSE_LINEAR_DEFAULT:
679 break;
680 case OMP_CLAUSE_LINEAR_REF:
681 pp_string (pp, "ref(");
682 break;
683 case OMP_CLAUSE_LINEAR_VAL:
684 pp_string (pp, "val(");
685 break;
686 case OMP_CLAUSE_LINEAR_UVAL:
687 pp_string (pp, "uval(");
688 break;
689 default:
690 gcc_unreachable ();
692 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
693 spc, flags, false);
694 if (OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
695 pp_right_paren (pp);
696 pp_colon (pp);
697 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
698 spc, flags, false);
699 pp_right_paren (pp);
700 break;
702 case OMP_CLAUSE_ALIGNED:
703 pp_string (pp, "aligned(");
704 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
705 spc, flags, false);
706 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
708 pp_colon (pp);
709 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
710 spc, flags, false);
712 pp_right_paren (pp);
713 break;
715 case OMP_CLAUSE_ALLOCATE:
716 pp_string (pp, "allocate(");
717 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
719 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause),
720 spc, flags, false);
721 pp_colon (pp);
723 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
724 spc, flags, false);
725 pp_right_paren (pp);
726 break;
728 case OMP_CLAUSE_DEPEND:
729 pp_string (pp, "depend(");
730 switch (OMP_CLAUSE_DEPEND_KIND (clause))
732 case OMP_CLAUSE_DEPEND_DEPOBJ:
733 name = "depobj";
734 break;
735 case OMP_CLAUSE_DEPEND_IN:
736 name = "in";
737 break;
738 case OMP_CLAUSE_DEPEND_OUT:
739 name = "out";
740 break;
741 case OMP_CLAUSE_DEPEND_INOUT:
742 name = "inout";
743 break;
744 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
745 name = "mutexinoutset";
746 break;
747 case OMP_CLAUSE_DEPEND_SOURCE:
748 pp_string (pp, "source)");
749 return;
750 case OMP_CLAUSE_DEPEND_LAST:
751 name = "__internal__";
752 break;
753 case OMP_CLAUSE_DEPEND_SINK:
754 pp_string (pp, "sink:");
755 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
756 if (TREE_CODE (t) == TREE_LIST)
758 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
759 if (TREE_PURPOSE (t) != integer_zero_node)
761 if (OMP_CLAUSE_DEPEND_SINK_NEGATIVE (t))
762 pp_minus (pp);
763 else
764 pp_plus (pp);
765 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
766 false);
768 if (TREE_CHAIN (t))
769 pp_comma (pp);
771 else
772 gcc_unreachable ();
773 pp_right_paren (pp);
774 return;
775 default:
776 gcc_unreachable ();
779 tree t = OMP_CLAUSE_DECL (clause);
780 if (TREE_CODE (t) == TREE_LIST
781 && TREE_PURPOSE (t)
782 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
784 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
785 pp_colon (pp);
786 t = TREE_VALUE (t);
788 pp_string (pp, name);
789 pp_colon (pp);
790 dump_generic_node (pp, t, spc, flags, false);
791 pp_right_paren (pp);
793 break;
795 case OMP_CLAUSE_MAP:
796 pp_string (pp, "map(");
797 switch (OMP_CLAUSE_MAP_KIND (clause))
799 case GOMP_MAP_ALLOC:
800 case GOMP_MAP_POINTER:
801 pp_string (pp, "alloc");
802 break;
803 case GOMP_MAP_IF_PRESENT:
804 pp_string (pp, "no_alloc");
805 break;
806 case GOMP_MAP_TO:
807 case GOMP_MAP_TO_PSET:
808 pp_string (pp, "to");
809 break;
810 case GOMP_MAP_FROM:
811 pp_string (pp, "from");
812 break;
813 case GOMP_MAP_TOFROM:
814 pp_string (pp, "tofrom");
815 break;
816 case GOMP_MAP_FORCE_ALLOC:
817 pp_string (pp, "force_alloc");
818 break;
819 case GOMP_MAP_FORCE_TO:
820 pp_string (pp, "force_to");
821 break;
822 case GOMP_MAP_FORCE_FROM:
823 pp_string (pp, "force_from");
824 break;
825 case GOMP_MAP_FORCE_TOFROM:
826 pp_string (pp, "force_tofrom");
827 break;
828 case GOMP_MAP_FORCE_PRESENT:
829 pp_string (pp, "force_present");
830 break;
831 case GOMP_MAP_DELETE:
832 pp_string (pp, "delete");
833 break;
834 case GOMP_MAP_FORCE_DEVICEPTR:
835 pp_string (pp, "force_deviceptr");
836 break;
837 case GOMP_MAP_ALWAYS_TO:
838 pp_string (pp, "always,to");
839 break;
840 case GOMP_MAP_ALWAYS_FROM:
841 pp_string (pp, "always,from");
842 break;
843 case GOMP_MAP_ALWAYS_TOFROM:
844 pp_string (pp, "always,tofrom");
845 break;
846 case GOMP_MAP_RELEASE:
847 pp_string (pp, "release");
848 break;
849 case GOMP_MAP_FIRSTPRIVATE_POINTER:
850 pp_string (pp, "firstprivate");
851 break;
852 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
853 pp_string (pp, "firstprivate ref");
854 break;
855 case GOMP_MAP_STRUCT:
856 pp_string (pp, "struct");
857 break;
858 case GOMP_MAP_ALWAYS_POINTER:
859 pp_string (pp, "always_pointer");
860 break;
861 case GOMP_MAP_DEVICE_RESIDENT:
862 pp_string (pp, "device_resident");
863 break;
864 case GOMP_MAP_LINK:
865 pp_string (pp, "link");
866 break;
867 case GOMP_MAP_ATTACH:
868 pp_string (pp, "attach");
869 break;
870 case GOMP_MAP_DETACH:
871 pp_string (pp, "detach");
872 break;
873 case GOMP_MAP_FORCE_DETACH:
874 pp_string (pp, "force_detach");
875 break;
876 case GOMP_MAP_ATTACH_DETACH:
877 pp_string (pp, "attach_detach");
878 break;
879 default:
880 gcc_unreachable ();
882 pp_colon (pp);
883 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
884 spc, flags, false);
885 print_clause_size:
886 if (OMP_CLAUSE_SIZE (clause))
888 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
889 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
891 case GOMP_MAP_POINTER:
892 case GOMP_MAP_FIRSTPRIVATE_POINTER:
893 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
894 case GOMP_MAP_ALWAYS_POINTER:
895 pp_string (pp, " [pointer assign, bias: ");
896 break;
897 case GOMP_MAP_TO_PSET:
898 pp_string (pp, " [pointer set, len: ");
899 break;
900 case GOMP_MAP_ATTACH:
901 case GOMP_MAP_DETACH:
902 case GOMP_MAP_FORCE_DETACH:
903 case GOMP_MAP_ATTACH_DETACH:
904 pp_string (pp, " [bias: ");
905 break;
906 default:
907 pp_string (pp, " [len: ");
908 break;
910 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
911 spc, flags, false);
912 pp_right_bracket (pp);
914 pp_right_paren (pp);
915 break;
917 case OMP_CLAUSE_FROM:
918 pp_string (pp, "from(");
919 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
920 spc, flags, false);
921 goto print_clause_size;
923 case OMP_CLAUSE_TO:
924 pp_string (pp, "to(");
925 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
926 spc, flags, false);
927 goto print_clause_size;
929 case OMP_CLAUSE__CACHE_:
930 pp_string (pp, "(");
931 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
932 spc, flags, false);
933 goto print_clause_size;
935 case OMP_CLAUSE_NUM_TEAMS:
936 pp_string (pp, "num_teams(");
937 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
938 spc, flags, false);
939 pp_right_paren (pp);
940 break;
942 case OMP_CLAUSE_THREAD_LIMIT:
943 pp_string (pp, "thread_limit(");
944 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
945 spc, flags, false);
946 pp_right_paren (pp);
947 break;
949 case OMP_CLAUSE_DEVICE:
950 pp_string (pp, "device(");
951 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
952 spc, flags, false);
953 pp_right_paren (pp);
954 break;
956 case OMP_CLAUSE_DIST_SCHEDULE:
957 pp_string (pp, "dist_schedule(static");
958 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
960 pp_comma (pp);
961 dump_generic_node (pp,
962 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
963 spc, flags, false);
965 pp_right_paren (pp);
966 break;
968 case OMP_CLAUSE_PROC_BIND:
969 pp_string (pp, "proc_bind(");
970 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
972 case OMP_CLAUSE_PROC_BIND_MASTER:
973 pp_string (pp, "master");
974 break;
975 case OMP_CLAUSE_PROC_BIND_CLOSE:
976 pp_string (pp, "close");
977 break;
978 case OMP_CLAUSE_PROC_BIND_SPREAD:
979 pp_string (pp, "spread");
980 break;
981 default:
982 gcc_unreachable ();
984 pp_right_paren (pp);
985 break;
987 case OMP_CLAUSE_DEVICE_TYPE:
988 pp_string (pp, "device_type(");
989 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
991 case OMP_CLAUSE_DEVICE_TYPE_HOST:
992 pp_string (pp, "host");
993 break;
994 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
995 pp_string (pp, "nohost");
996 break;
997 case OMP_CLAUSE_DEVICE_TYPE_ANY:
998 pp_string (pp, "any");
999 break;
1000 default:
1001 gcc_unreachable ();
1003 pp_right_paren (pp);
1004 break;
1006 case OMP_CLAUSE_SAFELEN:
1007 pp_string (pp, "safelen(");
1008 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
1009 spc, flags, false);
1010 pp_right_paren (pp);
1011 break;
1013 case OMP_CLAUSE_SIMDLEN:
1014 pp_string (pp, "simdlen(");
1015 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
1016 spc, flags, false);
1017 pp_right_paren (pp);
1018 break;
1020 case OMP_CLAUSE_PRIORITY:
1021 pp_string (pp, "priority(");
1022 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
1023 spc, flags, false);
1024 pp_right_paren (pp);
1025 break;
1027 case OMP_CLAUSE_GRAINSIZE:
1028 pp_string (pp, "grainsize(");
1029 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
1030 spc, flags, false);
1031 pp_right_paren (pp);
1032 break;
1034 case OMP_CLAUSE_NUM_TASKS:
1035 pp_string (pp, "num_tasks(");
1036 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1037 spc, flags, false);
1038 pp_right_paren (pp);
1039 break;
1041 case OMP_CLAUSE_HINT:
1042 pp_string (pp, "hint(");
1043 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1044 spc, flags, false);
1045 pp_right_paren (pp);
1046 break;
1048 case OMP_CLAUSE_DEFAULTMAP:
1049 pp_string (pp, "defaultmap(");
1050 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1052 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1053 pp_string (pp, "alloc");
1054 break;
1055 case OMP_CLAUSE_DEFAULTMAP_TO:
1056 pp_string (pp, "to");
1057 break;
1058 case OMP_CLAUSE_DEFAULTMAP_FROM:
1059 pp_string (pp, "from");
1060 break;
1061 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1062 pp_string (pp, "tofrom");
1063 break;
1064 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1065 pp_string (pp, "firstprivate");
1066 break;
1067 case OMP_CLAUSE_DEFAULTMAP_NONE:
1068 pp_string (pp, "none");
1069 break;
1070 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1071 pp_string (pp, "default");
1072 break;
1073 default:
1074 gcc_unreachable ();
1076 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1078 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1079 break;
1080 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1081 pp_string (pp, ":scalar");
1082 break;
1083 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1084 pp_string (pp, ":aggregate");
1085 break;
1086 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1087 pp_string (pp, ":allocatable");
1088 break;
1089 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1090 pp_string (pp, ":pointer");
1091 break;
1092 default:
1093 gcc_unreachable ();
1095 pp_right_paren (pp);
1096 break;
1098 case OMP_CLAUSE_ORDER:
1099 pp_string (pp, "order(concurrent)");
1100 break;
1102 case OMP_CLAUSE_BIND:
1103 pp_string (pp, "bind(");
1104 switch (OMP_CLAUSE_BIND_KIND (clause))
1106 case OMP_CLAUSE_BIND_TEAMS:
1107 pp_string (pp, "teams");
1108 break;
1109 case OMP_CLAUSE_BIND_PARALLEL:
1110 pp_string (pp, "parallel");
1111 break;
1112 case OMP_CLAUSE_BIND_THREAD:
1113 pp_string (pp, "thread");
1114 break;
1115 default:
1116 gcc_unreachable ();
1118 pp_right_paren (pp);
1119 break;
1121 case OMP_CLAUSE__SIMDUID_:
1122 pp_string (pp, "_simduid_(");
1123 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1124 spc, flags, false);
1125 pp_right_paren (pp);
1126 break;
1128 case OMP_CLAUSE__SIMT_:
1129 pp_string (pp, "_simt_");
1130 break;
1132 case OMP_CLAUSE_GANG:
1133 pp_string (pp, "gang");
1134 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1136 pp_string (pp, "(num: ");
1137 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1138 spc, flags, false);
1140 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1142 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1143 pp_left_paren (pp);
1144 else
1145 pp_space (pp);
1146 pp_string (pp, "static:");
1147 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1148 == integer_minus_one_node)
1149 pp_character (pp, '*');
1150 else
1151 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1152 spc, flags, false);
1154 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1155 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1156 pp_right_paren (pp);
1157 break;
1159 case OMP_CLAUSE_ASYNC:
1160 pp_string (pp, "async");
1161 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1163 pp_character(pp, '(');
1164 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1165 spc, flags, false);
1166 pp_character(pp, ')');
1168 break;
1170 case OMP_CLAUSE_AUTO:
1171 case OMP_CLAUSE_SEQ:
1172 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1173 break;
1175 case OMP_CLAUSE_WAIT:
1176 pp_string (pp, "wait(");
1177 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1178 spc, flags, false);
1179 pp_character(pp, ')');
1180 break;
1182 case OMP_CLAUSE_WORKER:
1183 pp_string (pp, "worker");
1184 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1186 pp_left_paren (pp);
1187 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1188 spc, flags, false);
1189 pp_right_paren (pp);
1191 break;
1193 case OMP_CLAUSE_VECTOR:
1194 pp_string (pp, "vector");
1195 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1197 pp_left_paren (pp);
1198 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1199 spc, flags, false);
1200 pp_right_paren (pp);
1202 break;
1204 case OMP_CLAUSE_NUM_GANGS:
1205 pp_string (pp, "num_gangs(");
1206 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1207 spc, flags, false);
1208 pp_character (pp, ')');
1209 break;
1211 case OMP_CLAUSE_NUM_WORKERS:
1212 pp_string (pp, "num_workers(");
1213 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1214 spc, flags, false);
1215 pp_character (pp, ')');
1216 break;
1218 case OMP_CLAUSE_VECTOR_LENGTH:
1219 pp_string (pp, "vector_length(");
1220 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1221 spc, flags, false);
1222 pp_character (pp, ')');
1223 break;
1225 case OMP_CLAUSE_INBRANCH:
1226 pp_string (pp, "inbranch");
1227 break;
1228 case OMP_CLAUSE_NOTINBRANCH:
1229 pp_string (pp, "notinbranch");
1230 break;
1231 case OMP_CLAUSE_FOR:
1232 pp_string (pp, "for");
1233 break;
1234 case OMP_CLAUSE_PARALLEL:
1235 pp_string (pp, "parallel");
1236 break;
1237 case OMP_CLAUSE_SECTIONS:
1238 pp_string (pp, "sections");
1239 break;
1240 case OMP_CLAUSE_TASKGROUP:
1241 pp_string (pp, "taskgroup");
1242 break;
1243 case OMP_CLAUSE_NOGROUP:
1244 pp_string (pp, "nogroup");
1245 break;
1246 case OMP_CLAUSE_THREADS:
1247 pp_string (pp, "threads");
1248 break;
1249 case OMP_CLAUSE_SIMD:
1250 pp_string (pp, "simd");
1251 break;
1252 case OMP_CLAUSE_INDEPENDENT:
1253 pp_string (pp, "independent");
1254 break;
1255 case OMP_CLAUSE_TILE:
1256 pp_string (pp, "tile(");
1257 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1258 spc, flags, false);
1259 pp_right_paren (pp);
1260 break;
1262 case OMP_CLAUSE_IF_PRESENT:
1263 pp_string (pp, "if_present");
1264 break;
1265 case OMP_CLAUSE_FINALIZE:
1266 pp_string (pp, "finalize");
1267 break;
1268 case OMP_CLAUSE_DETACH:
1269 pp_string (pp, "detach(");
1270 dump_generic_node (pp, OMP_CLAUSE_DECL (clause), spc, flags,
1271 false);
1272 pp_right_paren (pp);
1273 break;
1275 default:
1276 gcc_unreachable ();
1281 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
1282 dump_generic_node. */
1284 void
1285 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
1287 if (clause == NULL)
1288 return;
1290 pp_space (pp);
1291 while (1)
1293 dump_omp_clause (pp, clause, spc, flags);
1294 clause = OMP_CLAUSE_CHAIN (clause);
1295 if (clause == NULL)
1296 return;
1297 pp_space (pp);
1302 /* Dump location LOC to PP. */
1304 void
1305 dump_location (pretty_printer *pp, location_t loc)
1307 expanded_location xloc = expand_location (loc);
1309 pp_left_bracket (pp);
1310 if (xloc.file)
1312 pp_string (pp, xloc.file);
1313 pp_string (pp, ":");
1315 pp_decimal_int (pp, xloc.line);
1316 pp_colon (pp);
1317 pp_decimal_int (pp, xloc.column);
1318 pp_string (pp, "] ");
1322 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1323 dump_generic_node. */
1325 static void
1326 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1328 tree t;
1330 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
1332 if (flags & TDF_ADDRESS)
1333 pp_printf (pp, "[%p] ", (void *) block);
1335 if (TREE_ASM_WRITTEN (block))
1336 pp_string (pp, "[written] ");
1338 if (flags & TDF_SLIM)
1339 return;
1341 if (BLOCK_SOURCE_LOCATION (block))
1342 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1344 newline_and_indent (pp, spc + 2);
1346 if (BLOCK_SUPERCONTEXT (block))
1348 pp_string (pp, "SUPERCONTEXT: ");
1349 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1350 flags | TDF_SLIM, false);
1351 newline_and_indent (pp, spc + 2);
1354 if (BLOCK_SUBBLOCKS (block))
1356 pp_string (pp, "SUBBLOCKS: ");
1357 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1359 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1360 pp_space (pp);
1362 newline_and_indent (pp, spc + 2);
1365 if (BLOCK_CHAIN (block))
1367 pp_string (pp, "SIBLINGS: ");
1368 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1370 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1371 pp_space (pp);
1373 newline_and_indent (pp, spc + 2);
1376 if (BLOCK_VARS (block))
1378 pp_string (pp, "VARS: ");
1379 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1381 dump_generic_node (pp, t, 0, flags, false);
1382 pp_space (pp);
1384 newline_and_indent (pp, spc + 2);
1387 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1389 unsigned i;
1390 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1392 pp_string (pp, "NONLOCALIZED_VARS: ");
1393 FOR_EACH_VEC_ELT (*nlv, i, t)
1395 dump_generic_node (pp, t, 0, flags, false);
1396 pp_space (pp);
1398 newline_and_indent (pp, spc + 2);
1401 if (BLOCK_ABSTRACT_ORIGIN (block))
1403 pp_string (pp, "ABSTRACT_ORIGIN: ");
1404 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1405 flags | TDF_SLIM, false);
1406 newline_and_indent (pp, spc + 2);
1409 if (BLOCK_FRAGMENT_ORIGIN (block))
1411 pp_string (pp, "FRAGMENT_ORIGIN: ");
1412 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1413 flags | TDF_SLIM, false);
1414 newline_and_indent (pp, spc + 2);
1417 if (BLOCK_FRAGMENT_CHAIN (block))
1419 pp_string (pp, "FRAGMENT_CHAIN: ");
1420 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1422 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1423 pp_space (pp);
1425 newline_and_indent (pp, spc + 2);
1429 /* Dump #pragma omp atomic memory order clause. */
1431 void
1432 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1434 switch (mo)
1436 case OMP_MEMORY_ORDER_RELAXED:
1437 pp_string (pp, " relaxed");
1438 break;
1439 case OMP_MEMORY_ORDER_SEQ_CST:
1440 pp_string (pp, " seq_cst");
1441 break;
1442 case OMP_MEMORY_ORDER_ACQ_REL:
1443 pp_string (pp, " acq_rel");
1444 break;
1445 case OMP_MEMORY_ORDER_ACQUIRE:
1446 pp_string (pp, " acquire");
1447 break;
1448 case OMP_MEMORY_ORDER_RELEASE:
1449 pp_string (pp, " release");
1450 break;
1451 case OMP_MEMORY_ORDER_UNSPECIFIED:
1452 break;
1453 default:
1454 gcc_unreachable ();
1458 /* Helper to dump a MEM_REF node. */
1460 static void
1461 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1463 if (TREE_CODE (node) == MEM_REF && (flags & TDF_GIMPLE))
1465 pp_string (pp, "__MEM <");
1466 dump_generic_node (pp, TREE_TYPE (node),
1467 spc, flags | TDF_SLIM, false);
1468 if (TYPE_ALIGN (TREE_TYPE (node))
1469 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1471 pp_string (pp, ", ");
1472 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1474 pp_greater (pp);
1475 pp_string (pp, " (");
1476 if (TREE_TYPE (TREE_OPERAND (node, 0))
1477 != TREE_TYPE (TREE_OPERAND (node, 1)))
1479 pp_left_paren (pp);
1480 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1481 spc, flags | TDF_SLIM, false);
1482 pp_right_paren (pp);
1484 dump_generic_node (pp, TREE_OPERAND (node, 0),
1485 spc, flags | TDF_SLIM, false);
1486 if (! integer_zerop (TREE_OPERAND (node, 1)))
1488 pp_string (pp, " + ");
1489 dump_generic_node (pp, TREE_OPERAND (node, 1),
1490 spc, flags | TDF_SLIM, false);
1492 pp_right_paren (pp);
1494 else if (TREE_CODE (node) == MEM_REF
1495 && integer_zerop (TREE_OPERAND (node, 1))
1496 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1497 infer them and MEM_ATTR caching will share MEM_REFs
1498 with differently-typed op0s. */
1499 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1500 /* Released SSA_NAMES have no TREE_TYPE. */
1501 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1502 /* Same pointer types, but ignoring POINTER_TYPE vs.
1503 REFERENCE_TYPE. */
1504 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1505 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1506 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1507 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1508 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1509 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1510 /* Same value types ignoring qualifiers. */
1511 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1512 == TYPE_MAIN_VARIANT
1513 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1514 && (!(flags & TDF_ALIAS)
1515 || MR_DEPENDENCE_CLIQUE (node) == 0))
1517 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1519 /* Enclose pointers to arrays in parentheses. */
1520 tree op0 = TREE_OPERAND (node, 0);
1521 tree op0type = TREE_TYPE (op0);
1522 if (POINTER_TYPE_P (op0type)
1523 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1524 pp_left_paren (pp);
1525 pp_star (pp);
1526 dump_generic_node (pp, op0, spc, flags, false);
1527 if (POINTER_TYPE_P (op0type)
1528 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1529 pp_right_paren (pp);
1531 else
1532 dump_generic_node (pp,
1533 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1534 spc, flags, false);
1536 else
1538 pp_string (pp, "MEM");
1540 tree nodetype = TREE_TYPE (node);
1541 tree op0 = TREE_OPERAND (node, 0);
1542 tree op1 = TREE_OPERAND (node, 1);
1543 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1545 tree op0size = TYPE_SIZE (nodetype);
1546 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1548 if (!op0size || !op1size
1549 || !operand_equal_p (op0size, op1size, 0))
1551 pp_string (pp, " <");
1552 /* If the size of the type of the operand is not the same
1553 as the size of the MEM_REF expression include the type
1554 of the latter similar to the TDF_GIMPLE output to make
1555 it clear how many bytes of memory are being accessed. */
1556 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1557 pp_string (pp, "> ");
1560 pp_string (pp, "[(");
1561 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1562 pp_right_paren (pp);
1563 dump_generic_node (pp, op0, spc, flags, false);
1564 if (!integer_zerop (op1))
1566 pp_string (pp, " + ");
1567 dump_generic_node (pp, op1, spc, flags, false);
1569 if (TREE_CODE (node) == TARGET_MEM_REF)
1571 tree tmp = TMR_INDEX2 (node);
1572 if (tmp)
1574 pp_string (pp, " + ");
1575 dump_generic_node (pp, tmp, spc, flags, false);
1577 tmp = TMR_INDEX (node);
1578 if (tmp)
1580 pp_string (pp, " + ");
1581 dump_generic_node (pp, tmp, spc, flags, false);
1582 tmp = TMR_STEP (node);
1583 pp_string (pp, " * ");
1584 if (tmp)
1585 dump_generic_node (pp, tmp, spc, flags, false);
1586 else
1587 pp_string (pp, "1");
1590 if ((flags & TDF_ALIAS)
1591 && MR_DEPENDENCE_CLIQUE (node) != 0)
1593 pp_string (pp, " clique ");
1594 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1595 pp_string (pp, " base ");
1596 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1598 pp_right_bracket (pp);
1602 /* Helper function for dump_generic_node. Dump INIT or COND expression for
1603 OpenMP loop non-rectangular iterators. */
1605 void
1606 dump_omp_loop_non_rect_expr (pretty_printer *pp, tree node, int spc,
1607 dump_flags_t flags)
1609 gcc_assert (TREE_CODE (node) == TREE_VEC);
1610 dump_generic_node (pp, TREE_VEC_ELT (node, 0), spc, flags, false);
1611 pp_string (pp, " * ");
1612 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (MULT_EXPR))
1614 pp_left_paren (pp);
1615 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1616 pp_right_paren (pp);
1618 else
1619 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1620 pp_string (pp, " + ");
1621 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (PLUS_EXPR))
1623 pp_left_paren (pp);
1624 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1625 pp_right_paren (pp);
1627 else
1628 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1631 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1632 indent. FLAGS specifies details to show in the dump (see TDF_* in
1633 dumpfile.h). If IS_STMT is true, the object printed is considered
1634 to be a statement and it is terminated by ';' if appropriate. */
1637 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1638 bool is_stmt)
1640 tree type;
1641 tree op0, op1;
1642 const char *str;
1643 bool is_expr;
1644 enum tree_code code;
1646 if (node == NULL_TREE)
1647 return spc;
1649 is_expr = EXPR_P (node);
1651 if (is_stmt && (flags & TDF_STMTADDR))
1652 pp_printf (pp, "<&%p> ", (void *)node);
1654 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1655 dump_location (pp, EXPR_LOCATION (node));
1657 code = TREE_CODE (node);
1658 switch (code)
1660 case ERROR_MARK:
1661 pp_string (pp, "<<< error >>>");
1662 break;
1664 case IDENTIFIER_NODE:
1665 pp_tree_identifier (pp, node);
1666 break;
1668 case TREE_LIST:
1669 while (node && node != error_mark_node)
1671 if (TREE_PURPOSE (node))
1673 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1674 pp_space (pp);
1676 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1677 node = TREE_CHAIN (node);
1678 if (node && TREE_CODE (node) == TREE_LIST)
1680 pp_comma (pp);
1681 pp_space (pp);
1684 break;
1686 case TREE_BINFO:
1687 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1688 break;
1690 case TREE_VEC:
1692 size_t i;
1693 if (TREE_VEC_LENGTH (node) > 0)
1695 size_t len = TREE_VEC_LENGTH (node);
1696 for (i = 0; i < len - 1; i++)
1698 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1699 false);
1700 pp_comma (pp);
1701 pp_space (pp);
1703 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1704 flags, false);
1707 break;
1709 case VOID_TYPE:
1710 case INTEGER_TYPE:
1711 case REAL_TYPE:
1712 case FIXED_POINT_TYPE:
1713 case COMPLEX_TYPE:
1714 case VECTOR_TYPE:
1715 case ENUMERAL_TYPE:
1716 case BOOLEAN_TYPE:
1717 case OPAQUE_TYPE:
1719 unsigned int quals = TYPE_QUALS (node);
1720 enum tree_code_class tclass;
1722 if (quals & TYPE_QUAL_ATOMIC)
1723 pp_string (pp, "atomic ");
1724 if (quals & TYPE_QUAL_CONST)
1725 pp_string (pp, "const ");
1726 if (quals & TYPE_QUAL_VOLATILE)
1727 pp_string (pp, "volatile ");
1728 if (quals & TYPE_QUAL_RESTRICT)
1729 pp_string (pp, "restrict ");
1731 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1733 pp_string (pp, "<address-space-");
1734 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1735 pp_string (pp, "> ");
1738 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1740 if (tclass == tcc_declaration)
1742 if (DECL_NAME (node))
1743 dump_decl_name (pp, node, flags);
1744 else
1745 pp_string (pp, "<unnamed type decl>");
1747 else if (tclass == tcc_type)
1749 if (TYPE_NAME (node))
1751 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1752 pp_tree_identifier (pp, TYPE_NAME (node));
1753 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1754 && DECL_NAME (TYPE_NAME (node)))
1755 dump_decl_name (pp, TYPE_NAME (node), flags);
1756 else
1757 pp_string (pp, "<unnamed type>");
1759 else if (TREE_CODE (node) == VECTOR_TYPE)
1761 pp_string (pp, "vector");
1762 pp_left_paren (pp);
1763 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1764 pp_string (pp, ") ");
1765 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1767 else if (TREE_CODE (node) == INTEGER_TYPE)
1769 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1770 pp_string (pp, (TYPE_UNSIGNED (node)
1771 ? "unsigned char"
1772 : "signed char"));
1773 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1774 pp_string (pp, (TYPE_UNSIGNED (node)
1775 ? "unsigned short"
1776 : "signed short"));
1777 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1778 pp_string (pp, (TYPE_UNSIGNED (node)
1779 ? "unsigned int"
1780 : "signed int"));
1781 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1782 pp_string (pp, (TYPE_UNSIGNED (node)
1783 ? "unsigned long"
1784 : "signed long"));
1785 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1786 pp_string (pp, (TYPE_UNSIGNED (node)
1787 ? "unsigned long long"
1788 : "signed long long"));
1789 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1790 && pow2p_hwi (TYPE_PRECISION (node)))
1792 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1793 pp_decimal_int (pp, TYPE_PRECISION (node));
1794 pp_string (pp, "_t");
1796 else
1798 pp_string (pp, (TYPE_UNSIGNED (node)
1799 ? "<unnamed-unsigned:"
1800 : "<unnamed-signed:"));
1801 pp_decimal_int (pp, TYPE_PRECISION (node));
1802 pp_greater (pp);
1805 else if (TREE_CODE (node) == COMPLEX_TYPE)
1807 pp_string (pp, "__complex__ ");
1808 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1810 else if (TREE_CODE (node) == REAL_TYPE)
1812 pp_string (pp, "<float:");
1813 pp_decimal_int (pp, TYPE_PRECISION (node));
1814 pp_greater (pp);
1816 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1818 pp_string (pp, "<fixed-point-");
1819 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1820 pp_decimal_int (pp, TYPE_PRECISION (node));
1821 pp_greater (pp);
1823 else if (TREE_CODE (node) == BOOLEAN_TYPE)
1825 pp_string (pp, (TYPE_UNSIGNED (node)
1826 ? "<unsigned-boolean:"
1827 : "<signed-boolean:"));
1828 pp_decimal_int (pp, TYPE_PRECISION (node));
1829 pp_greater (pp);
1831 else if (TREE_CODE (node) == VOID_TYPE)
1832 pp_string (pp, "void");
1833 else
1834 pp_string (pp, "<unnamed type>");
1836 break;
1839 case POINTER_TYPE:
1840 case REFERENCE_TYPE:
1841 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1843 if (TREE_TYPE (node) == NULL)
1845 pp_string (pp, str);
1846 pp_string (pp, "<null type>");
1848 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1850 tree fnode = TREE_TYPE (node);
1852 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1853 pp_space (pp);
1854 pp_left_paren (pp);
1855 pp_string (pp, str);
1856 if (TYPE_IDENTIFIER (node))
1857 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1858 else if (flags & TDF_NOUID)
1859 pp_printf (pp, "<Txxxx>");
1860 else
1861 pp_printf (pp, "<T%x>", TYPE_UID (node));
1863 pp_right_paren (pp);
1864 dump_function_declaration (pp, fnode, spc, flags);
1866 else
1868 unsigned int quals = TYPE_QUALS (node);
1870 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1871 pp_space (pp);
1872 pp_string (pp, str);
1874 if (quals & TYPE_QUAL_CONST)
1875 pp_string (pp, " const");
1876 if (quals & TYPE_QUAL_VOLATILE)
1877 pp_string (pp, " volatile");
1878 if (quals & TYPE_QUAL_RESTRICT)
1879 pp_string (pp, " restrict");
1881 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1883 pp_string (pp, " <address-space-");
1884 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1885 pp_greater (pp);
1888 if (TYPE_REF_CAN_ALIAS_ALL (node))
1889 pp_string (pp, " {ref-all}");
1891 break;
1893 case OFFSET_TYPE:
1894 NIY;
1895 break;
1897 case MEM_REF:
1898 case TARGET_MEM_REF:
1899 dump_mem_ref (pp, node, spc, flags);
1900 break;
1902 case ARRAY_TYPE:
1904 unsigned int quals = TYPE_QUALS (node);
1905 tree tmp;
1907 if (quals & TYPE_QUAL_ATOMIC)
1908 pp_string (pp, "atomic ");
1909 if (quals & TYPE_QUAL_CONST)
1910 pp_string (pp, "const ");
1911 if (quals & TYPE_QUAL_VOLATILE)
1912 pp_string (pp, "volatile ");
1914 /* Print the innermost component type. */
1915 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1916 tmp = TREE_TYPE (tmp))
1918 dump_generic_node (pp, tmp, spc, flags, false);
1920 /* Print the dimensions. */
1921 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1922 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1923 break;
1926 case RECORD_TYPE:
1927 case UNION_TYPE:
1928 case QUAL_UNION_TYPE:
1930 unsigned int quals = TYPE_QUALS (node);
1932 if (quals & TYPE_QUAL_ATOMIC)
1933 pp_string (pp, "atomic ");
1934 if (quals & TYPE_QUAL_CONST)
1935 pp_string (pp, "const ");
1936 if (quals & TYPE_QUAL_VOLATILE)
1937 pp_string (pp, "volatile ");
1939 /* Print the name of the structure. */
1940 if (TREE_CODE (node) == RECORD_TYPE)
1941 pp_string (pp, "struct ");
1942 else if (TREE_CODE (node) == UNION_TYPE)
1943 pp_string (pp, "union ");
1945 if (TYPE_NAME (node))
1946 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1947 else if (!(flags & TDF_SLIM))
1948 /* FIXME: If we eliminate the 'else' above and attempt
1949 to show the fields for named types, we may get stuck
1950 following a cycle of pointers to structs. The alleged
1951 self-reference check in print_struct_decl will not detect
1952 cycles involving more than one pointer or struct type. */
1953 print_struct_decl (pp, node, spc, flags);
1954 break;
1957 case LANG_TYPE:
1958 NIY;
1959 break;
1961 case INTEGER_CST:
1962 if (flags & TDF_GIMPLE
1963 && (POINTER_TYPE_P (TREE_TYPE (node))
1964 || (TYPE_PRECISION (TREE_TYPE (node))
1965 < TYPE_PRECISION (integer_type_node))
1966 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
1967 || tree_int_cst_sgn (node) < 0))
1969 pp_string (pp, "_Literal (");
1970 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1971 pp_string (pp, ") ");
1973 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
1974 && ! (flags & TDF_GIMPLE))
1976 /* In the case of a pointer, one may want to divide by the
1977 size of the pointed-to type. Unfortunately, this not
1978 straightforward. The C front-end maps expressions
1980 (int *) 5
1981 int *p; (p + 5)
1983 in such a way that the two INTEGER_CST nodes for "5" have
1984 different values but identical types. In the latter
1985 case, the 5 is multiplied by sizeof (int) in c-common.c
1986 (pointer_int_sum) to convert it to a byte address, and
1987 yet the type of the node is left unchanged. Argh. What
1988 is consistent though is that the number value corresponds
1989 to bytes (UNITS) offset.
1991 NB: Neither of the following divisors can be trivially
1992 used to recover the original literal:
1994 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1995 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1996 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1997 pp_string (pp, "B"); /* pseudo-unit */
1999 else if (tree_fits_shwi_p (node))
2000 pp_wide_integer (pp, tree_to_shwi (node));
2001 else if (tree_fits_uhwi_p (node))
2002 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
2003 else
2005 wide_int val = wi::to_wide (node);
2007 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
2009 pp_minus (pp);
2010 val = -val;
2012 print_hex (val, pp_buffer (pp)->digit_buffer);
2013 pp_string (pp, pp_buffer (pp)->digit_buffer);
2015 if ((flags & TDF_GIMPLE)
2016 && ! (POINTER_TYPE_P (TREE_TYPE (node))
2017 || (TYPE_PRECISION (TREE_TYPE (node))
2018 < TYPE_PRECISION (integer_type_node))
2019 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
2021 if (TYPE_UNSIGNED (TREE_TYPE (node)))
2022 pp_character (pp, 'u');
2023 if (TYPE_PRECISION (TREE_TYPE (node))
2024 == TYPE_PRECISION (unsigned_type_node))
2026 else if (TYPE_PRECISION (TREE_TYPE (node))
2027 == TYPE_PRECISION (long_unsigned_type_node))
2028 pp_character (pp, 'l');
2029 else if (TYPE_PRECISION (TREE_TYPE (node))
2030 == TYPE_PRECISION (long_long_unsigned_type_node))
2031 pp_string (pp, "ll");
2033 if (TREE_OVERFLOW (node))
2034 pp_string (pp, "(OVF)");
2035 break;
2037 case POLY_INT_CST:
2038 pp_string (pp, "POLY_INT_CST [");
2039 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2040 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2042 pp_string (pp, ", ");
2043 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2044 spc, flags, false);
2046 pp_string (pp, "]");
2047 break;
2049 case REAL_CST:
2050 /* Code copied from print_node. */
2052 REAL_VALUE_TYPE d;
2053 if (TREE_OVERFLOW (node))
2054 pp_string (pp, " overflow");
2056 d = TREE_REAL_CST (node);
2057 if (REAL_VALUE_ISINF (d))
2058 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2059 else if (REAL_VALUE_ISNAN (d))
2060 pp_string (pp, " Nan");
2061 else
2063 char string[100];
2064 real_to_decimal (string, &d, sizeof (string), 0, 1);
2065 pp_string (pp, string);
2067 break;
2070 case FIXED_CST:
2072 char string[100];
2073 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2074 pp_string (pp, string);
2075 break;
2078 case COMPLEX_CST:
2079 pp_string (pp, "__complex__ (");
2080 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2081 pp_string (pp, ", ");
2082 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2083 pp_right_paren (pp);
2084 break;
2086 case STRING_CST:
2088 pp_string (pp, "\"");
2089 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2090 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2091 pp_string (pp, "\"");
2092 break;
2095 case VECTOR_CST:
2097 unsigned i;
2098 if (flags & TDF_GIMPLE)
2100 pp_string (pp, "_Literal (");
2101 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2102 pp_string (pp, ") ");
2104 pp_string (pp, "{ ");
2105 unsigned HOST_WIDE_INT nunits;
2106 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2107 nunits = vector_cst_encoded_nelts (node);
2108 for (i = 0; i < nunits; ++i)
2110 if (i != 0)
2111 pp_string (pp, ", ");
2112 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2113 spc, flags, false);
2115 if (!VECTOR_CST_NELTS (node).is_constant ())
2116 pp_string (pp, ", ...");
2117 pp_string (pp, " }");
2119 break;
2121 case FUNCTION_TYPE:
2122 case METHOD_TYPE:
2123 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2124 pp_space (pp);
2125 if (TREE_CODE (node) == METHOD_TYPE)
2127 if (TYPE_METHOD_BASETYPE (node))
2128 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2129 spc, flags, false);
2130 else
2131 pp_string (pp, "<null method basetype>");
2132 pp_colon_colon (pp);
2134 if (TYPE_IDENTIFIER (node))
2135 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2136 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2137 dump_decl_name (pp, TYPE_NAME (node), flags);
2138 else if (flags & TDF_NOUID)
2139 pp_printf (pp, "<Txxxx>");
2140 else
2141 pp_printf (pp, "<T%x>", TYPE_UID (node));
2142 dump_function_declaration (pp, node, spc, flags);
2143 break;
2145 case FUNCTION_DECL:
2146 case CONST_DECL:
2147 dump_decl_name (pp, node, flags);
2148 break;
2150 case LABEL_DECL:
2151 if (DECL_NAME (node))
2152 dump_decl_name (pp, node, flags);
2153 else if (LABEL_DECL_UID (node) != -1)
2155 if (flags & TDF_GIMPLE)
2156 pp_printf (pp, "L%d", (int) LABEL_DECL_UID (node));
2157 else
2158 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
2160 else
2162 if (flags & TDF_NOUID)
2163 pp_string (pp, "<D.xxxx>");
2164 else
2166 if (flags & TDF_GIMPLE)
2167 pp_printf (pp, "<D%u>", DECL_UID (node));
2168 else
2169 pp_printf (pp, "<D.%u>", DECL_UID (node));
2172 break;
2174 case TYPE_DECL:
2175 if (DECL_IS_UNDECLARED_BUILTIN (node))
2177 /* Don't print the declaration of built-in types. */
2178 break;
2180 if (DECL_NAME (node))
2181 dump_decl_name (pp, node, flags);
2182 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2184 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2185 ? "union" : "struct "));
2186 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2188 else
2189 pp_string (pp, "<anon>");
2190 break;
2192 case VAR_DECL:
2193 case PARM_DECL:
2194 case FIELD_DECL:
2195 case DEBUG_EXPR_DECL:
2196 case NAMESPACE_DECL:
2197 case NAMELIST_DECL:
2198 dump_decl_name (pp, node, flags);
2199 break;
2201 case RESULT_DECL:
2202 pp_string (pp, "<retval>");
2203 break;
2205 case COMPONENT_REF:
2206 op0 = TREE_OPERAND (node, 0);
2207 str = ".";
2208 if (op0
2209 && (TREE_CODE (op0) == INDIRECT_REF
2210 || (TREE_CODE (op0) == MEM_REF
2211 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2212 && integer_zerop (TREE_OPERAND (op0, 1))
2213 /* Dump the types of INTEGER_CSTs explicitly, for we
2214 can't infer them and MEM_ATTR caching will share
2215 MEM_REFs with differently-typed op0s. */
2216 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2217 /* Released SSA_NAMES have no TREE_TYPE. */
2218 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2219 /* Same pointer types, but ignoring POINTER_TYPE vs.
2220 REFERENCE_TYPE. */
2221 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2222 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2223 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2224 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2225 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2226 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2227 /* Same value types ignoring qualifiers. */
2228 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2229 == TYPE_MAIN_VARIANT
2230 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2231 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2233 op0 = TREE_OPERAND (op0, 0);
2234 str = "->";
2236 if (op_prio (op0) < op_prio (node))
2237 pp_left_paren (pp);
2238 dump_generic_node (pp, op0, spc, flags, false);
2239 if (op_prio (op0) < op_prio (node))
2240 pp_right_paren (pp);
2241 pp_string (pp, str);
2242 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2243 op0 = component_ref_field_offset (node);
2244 if (op0 && TREE_CODE (op0) != INTEGER_CST)
2246 pp_string (pp, "{off: ");
2247 dump_generic_node (pp, op0, spc, flags, false);
2248 pp_right_brace (pp);
2250 break;
2252 case BIT_FIELD_REF:
2253 if (flags & TDF_GIMPLE)
2255 pp_string (pp, "__BIT_FIELD_REF <");
2256 dump_generic_node (pp, TREE_TYPE (node),
2257 spc, flags | TDF_SLIM, false);
2258 if (TYPE_ALIGN (TREE_TYPE (node))
2259 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2261 pp_string (pp, ", ");
2262 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2264 pp_greater (pp);
2265 pp_string (pp, " (");
2266 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2267 flags | TDF_SLIM, false);
2268 pp_string (pp, ", ");
2269 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2270 flags | TDF_SLIM, false);
2271 pp_string (pp, ", ");
2272 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2273 flags | TDF_SLIM, false);
2274 pp_right_paren (pp);
2276 else
2278 pp_string (pp, "BIT_FIELD_REF <");
2279 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2280 pp_string (pp, ", ");
2281 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2282 pp_string (pp, ", ");
2283 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2284 pp_greater (pp);
2286 break;
2288 case BIT_INSERT_EXPR:
2289 pp_string (pp, "BIT_INSERT_EXPR <");
2290 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2291 pp_string (pp, ", ");
2292 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2293 pp_string (pp, ", ");
2294 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2295 pp_string (pp, " (");
2296 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2297 pp_decimal_int (pp,
2298 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2299 else
2300 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2301 spc, flags, false);
2302 pp_string (pp, " bits)>");
2303 break;
2305 case ARRAY_REF:
2306 case ARRAY_RANGE_REF:
2307 op0 = TREE_OPERAND (node, 0);
2308 if (op_prio (op0) < op_prio (node))
2309 pp_left_paren (pp);
2310 dump_generic_node (pp, op0, spc, flags, false);
2311 if (op_prio (op0) < op_prio (node))
2312 pp_right_paren (pp);
2313 pp_left_bracket (pp);
2314 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2315 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2316 pp_string (pp, " ...");
2317 pp_right_bracket (pp);
2319 op0 = array_ref_low_bound (node);
2320 op1 = array_ref_element_size (node);
2322 if (!integer_zerop (op0)
2323 || TREE_OPERAND (node, 2)
2324 || TREE_OPERAND (node, 3))
2326 pp_string (pp, "{lb: ");
2327 dump_generic_node (pp, op0, spc, flags, false);
2328 pp_string (pp, " sz: ");
2329 dump_generic_node (pp, op1, spc, flags, false);
2330 pp_right_brace (pp);
2332 break;
2334 case CONSTRUCTOR:
2336 unsigned HOST_WIDE_INT ix;
2337 tree field, val;
2338 bool is_struct_init = false;
2339 bool is_array_init = false;
2340 widest_int curidx;
2341 if (flags & TDF_GIMPLE)
2343 pp_string (pp, "_Literal (");
2344 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2345 pp_string (pp, ") ");
2347 pp_left_brace (pp);
2348 if (TREE_CLOBBER_P (node))
2349 pp_string (pp, "CLOBBER");
2350 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2351 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2352 is_struct_init = true;
2353 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2354 && TYPE_DOMAIN (TREE_TYPE (node))
2355 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2356 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2357 == INTEGER_CST)
2359 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2360 is_array_init = true;
2361 curidx = wi::to_widest (minv);
2363 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2365 if (field)
2367 if (is_struct_init)
2369 pp_dot (pp);
2370 dump_generic_node (pp, field, spc, flags, false);
2371 pp_equal (pp);
2373 else if (is_array_init
2374 && (TREE_CODE (field) != INTEGER_CST
2375 || curidx != wi::to_widest (field)))
2377 pp_left_bracket (pp);
2378 if (TREE_CODE (field) == RANGE_EXPR)
2380 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2381 flags, false);
2382 pp_string (pp, " ... ");
2383 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2384 flags, false);
2385 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2386 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2388 else
2389 dump_generic_node (pp, field, spc, flags, false);
2390 if (TREE_CODE (field) == INTEGER_CST)
2391 curidx = wi::to_widest (field);
2392 pp_string (pp, "]=");
2395 if (is_array_init)
2396 curidx += 1;
2397 if (val && TREE_CODE (val) == ADDR_EXPR)
2398 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2399 val = TREE_OPERAND (val, 0);
2400 if (val && TREE_CODE (val) == FUNCTION_DECL)
2401 dump_decl_name (pp, val, flags);
2402 else
2403 dump_generic_node (pp, val, spc, flags, false);
2404 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2406 pp_comma (pp);
2407 pp_space (pp);
2410 pp_right_brace (pp);
2412 break;
2414 case COMPOUND_EXPR:
2416 tree *tp;
2417 if (flags & TDF_SLIM)
2419 pp_string (pp, "<COMPOUND_EXPR>");
2420 break;
2423 dump_generic_node (pp, TREE_OPERAND (node, 0),
2424 spc, flags, !(flags & TDF_SLIM));
2425 if (flags & TDF_SLIM)
2426 newline_and_indent (pp, spc);
2427 else
2429 pp_comma (pp);
2430 pp_space (pp);
2433 for (tp = &TREE_OPERAND (node, 1);
2434 TREE_CODE (*tp) == COMPOUND_EXPR;
2435 tp = &TREE_OPERAND (*tp, 1))
2437 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2438 spc, flags, !(flags & TDF_SLIM));
2439 if (flags & TDF_SLIM)
2440 newline_and_indent (pp, spc);
2441 else
2443 pp_comma (pp);
2444 pp_space (pp);
2448 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2450 break;
2452 case STATEMENT_LIST:
2454 tree_stmt_iterator si;
2455 bool first = true;
2457 if (flags & TDF_SLIM)
2459 pp_string (pp, "<STATEMENT_LIST>");
2460 break;
2463 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2465 if (!first)
2466 newline_and_indent (pp, spc);
2467 else
2468 first = false;
2469 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2472 break;
2474 case MODIFY_EXPR:
2475 case INIT_EXPR:
2476 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2477 false);
2478 pp_space (pp);
2479 pp_equal (pp);
2480 pp_space (pp);
2481 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2482 false);
2483 break;
2485 case TARGET_EXPR:
2486 pp_string (pp, "TARGET_EXPR <");
2487 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2488 pp_comma (pp);
2489 pp_space (pp);
2490 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2491 pp_greater (pp);
2492 break;
2494 case DECL_EXPR:
2495 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2496 is_stmt = false;
2497 break;
2499 case COND_EXPR:
2500 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2502 pp_string (pp, "if (");
2503 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2504 pp_right_paren (pp);
2505 /* The lowered cond_exprs should always be printed in full. */
2506 if (COND_EXPR_THEN (node)
2507 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2508 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2509 && COND_EXPR_ELSE (node)
2510 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2511 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2513 pp_space (pp);
2514 dump_generic_node (pp, COND_EXPR_THEN (node),
2515 0, flags, true);
2516 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2518 pp_string (pp, " else ");
2519 dump_generic_node (pp, COND_EXPR_ELSE (node),
2520 0, flags, true);
2523 else if (!(flags & TDF_SLIM))
2525 /* Output COND_EXPR_THEN. */
2526 if (COND_EXPR_THEN (node))
2528 newline_and_indent (pp, spc+2);
2529 pp_left_brace (pp);
2530 newline_and_indent (pp, spc+4);
2531 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2532 flags, true);
2533 newline_and_indent (pp, spc+2);
2534 pp_right_brace (pp);
2537 /* Output COND_EXPR_ELSE. */
2538 if (COND_EXPR_ELSE (node)
2539 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2541 newline_and_indent (pp, spc);
2542 pp_string (pp, "else");
2543 newline_and_indent (pp, spc+2);
2544 pp_left_brace (pp);
2545 newline_and_indent (pp, spc+4);
2546 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2547 flags, true);
2548 newline_and_indent (pp, spc+2);
2549 pp_right_brace (pp);
2552 is_expr = false;
2554 else
2556 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2557 pp_space (pp);
2558 pp_question (pp);
2559 pp_space (pp);
2560 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2561 pp_space (pp);
2562 pp_colon (pp);
2563 pp_space (pp);
2564 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2566 break;
2568 case BIND_EXPR:
2569 pp_left_brace (pp);
2570 if (!(flags & TDF_SLIM))
2572 if (BIND_EXPR_VARS (node))
2574 pp_newline (pp);
2576 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2578 print_declaration (pp, op0, spc+2, flags);
2579 pp_newline (pp);
2583 newline_and_indent (pp, spc+2);
2584 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2585 newline_and_indent (pp, spc);
2586 pp_right_brace (pp);
2588 is_expr = false;
2589 break;
2591 case CALL_EXPR:
2592 if (CALL_EXPR_FN (node) != NULL_TREE)
2593 print_call_name (pp, CALL_EXPR_FN (node), flags);
2594 else
2596 pp_dot (pp);
2597 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2600 /* Print parameters. */
2601 pp_space (pp);
2602 pp_left_paren (pp);
2604 tree arg;
2605 call_expr_arg_iterator iter;
2606 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2608 dump_generic_node (pp, arg, spc, flags, false);
2609 if (more_call_expr_args_p (&iter))
2611 pp_comma (pp);
2612 pp_space (pp);
2616 if (CALL_EXPR_VA_ARG_PACK (node))
2618 if (call_expr_nargs (node) > 0)
2620 pp_comma (pp);
2621 pp_space (pp);
2623 pp_string (pp, "__builtin_va_arg_pack ()");
2625 pp_right_paren (pp);
2627 op1 = CALL_EXPR_STATIC_CHAIN (node);
2628 if (op1)
2630 pp_string (pp, " [static-chain: ");
2631 dump_generic_node (pp, op1, spc, flags, false);
2632 pp_right_bracket (pp);
2635 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2636 pp_string (pp, " [return slot optimization]");
2637 if (CALL_EXPR_TAILCALL (node))
2638 pp_string (pp, " [tail call]");
2639 break;
2641 case WITH_CLEANUP_EXPR:
2642 NIY;
2643 break;
2645 case CLEANUP_POINT_EXPR:
2646 pp_string (pp, "<<cleanup_point ");
2647 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2648 pp_string (pp, ">>");
2649 break;
2651 case PLACEHOLDER_EXPR:
2652 pp_string (pp, "<PLACEHOLDER_EXPR ");
2653 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2654 pp_greater (pp);
2655 break;
2657 /* Binary arithmetic and logic expressions. */
2658 case WIDEN_PLUS_EXPR:
2659 case WIDEN_MINUS_EXPR:
2660 case WIDEN_SUM_EXPR:
2661 case WIDEN_MULT_EXPR:
2662 case MULT_EXPR:
2663 case MULT_HIGHPART_EXPR:
2664 case PLUS_EXPR:
2665 case POINTER_PLUS_EXPR:
2666 case POINTER_DIFF_EXPR:
2667 case MINUS_EXPR:
2668 case TRUNC_DIV_EXPR:
2669 case CEIL_DIV_EXPR:
2670 case FLOOR_DIV_EXPR:
2671 case ROUND_DIV_EXPR:
2672 case TRUNC_MOD_EXPR:
2673 case CEIL_MOD_EXPR:
2674 case FLOOR_MOD_EXPR:
2675 case ROUND_MOD_EXPR:
2676 case RDIV_EXPR:
2677 case EXACT_DIV_EXPR:
2678 case LSHIFT_EXPR:
2679 case RSHIFT_EXPR:
2680 case LROTATE_EXPR:
2681 case RROTATE_EXPR:
2682 case WIDEN_LSHIFT_EXPR:
2683 case BIT_IOR_EXPR:
2684 case BIT_XOR_EXPR:
2685 case BIT_AND_EXPR:
2686 case TRUTH_ANDIF_EXPR:
2687 case TRUTH_ORIF_EXPR:
2688 case TRUTH_AND_EXPR:
2689 case TRUTH_OR_EXPR:
2690 case TRUTH_XOR_EXPR:
2691 case LT_EXPR:
2692 case LE_EXPR:
2693 case GT_EXPR:
2694 case GE_EXPR:
2695 case EQ_EXPR:
2696 case NE_EXPR:
2697 case UNLT_EXPR:
2698 case UNLE_EXPR:
2699 case UNGT_EXPR:
2700 case UNGE_EXPR:
2701 case UNEQ_EXPR:
2702 case LTGT_EXPR:
2703 case ORDERED_EXPR:
2704 case UNORDERED_EXPR:
2706 const char *op = op_symbol (node);
2707 op0 = TREE_OPERAND (node, 0);
2708 op1 = TREE_OPERAND (node, 1);
2710 /* When the operands are expressions with less priority,
2711 keep semantics of the tree representation. */
2712 if (op_prio (op0) <= op_prio (node))
2714 pp_left_paren (pp);
2715 dump_generic_node (pp, op0, spc, flags, false);
2716 pp_right_paren (pp);
2718 else
2719 dump_generic_node (pp, op0, spc, flags, false);
2721 pp_space (pp);
2722 pp_string (pp, op);
2723 pp_space (pp);
2725 /* When the operands are expressions with less priority,
2726 keep semantics of the tree representation. */
2727 if (op_prio (op1) <= op_prio (node))
2729 pp_left_paren (pp);
2730 dump_generic_node (pp, op1, spc, flags, false);
2731 pp_right_paren (pp);
2733 else
2734 dump_generic_node (pp, op1, spc, flags, false);
2736 break;
2738 /* Unary arithmetic and logic expressions. */
2739 case NEGATE_EXPR:
2740 case BIT_NOT_EXPR:
2741 case TRUTH_NOT_EXPR:
2742 case ADDR_EXPR:
2743 case PREDECREMENT_EXPR:
2744 case PREINCREMENT_EXPR:
2745 case INDIRECT_REF:
2746 if (TREE_CODE (node) == ADDR_EXPR
2747 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2748 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2749 ; /* Do not output '&' for strings and function pointers. */
2750 else
2751 pp_string (pp, op_symbol (node));
2753 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2755 pp_left_paren (pp);
2756 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2757 pp_right_paren (pp);
2759 else
2760 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2761 break;
2763 case POSTDECREMENT_EXPR:
2764 case POSTINCREMENT_EXPR:
2765 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2767 pp_left_paren (pp);
2768 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2769 pp_right_paren (pp);
2771 else
2772 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2773 pp_string (pp, op_symbol (node));
2774 break;
2776 case MIN_EXPR:
2777 pp_string (pp, "MIN_EXPR <");
2778 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2779 pp_string (pp, ", ");
2780 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2781 pp_greater (pp);
2782 break;
2784 case MAX_EXPR:
2785 pp_string (pp, "MAX_EXPR <");
2786 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2787 pp_string (pp, ", ");
2788 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2789 pp_greater (pp);
2790 break;
2792 case ABS_EXPR:
2793 pp_string (pp, "ABS_EXPR <");
2794 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2795 pp_greater (pp);
2796 break;
2798 case ABSU_EXPR:
2799 pp_string (pp, "ABSU_EXPR <");
2800 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2801 pp_greater (pp);
2802 break;
2804 case RANGE_EXPR:
2805 NIY;
2806 break;
2808 case ADDR_SPACE_CONVERT_EXPR:
2809 case FIXED_CONVERT_EXPR:
2810 case FIX_TRUNC_EXPR:
2811 case FLOAT_EXPR:
2812 CASE_CONVERT:
2813 type = TREE_TYPE (node);
2814 op0 = TREE_OPERAND (node, 0);
2815 if (type != TREE_TYPE (op0))
2817 pp_left_paren (pp);
2818 dump_generic_node (pp, type, spc, flags, false);
2819 pp_string (pp, ") ");
2821 if (op_prio (op0) < op_prio (node))
2822 pp_left_paren (pp);
2823 dump_generic_node (pp, op0, spc, flags, false);
2824 if (op_prio (op0) < op_prio (node))
2825 pp_right_paren (pp);
2826 break;
2828 case VIEW_CONVERT_EXPR:
2829 if (flags & TDF_GIMPLE)
2830 pp_string (pp, "__VIEW_CONVERT <");
2831 else
2832 pp_string (pp, "VIEW_CONVERT_EXPR<");
2833 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2834 pp_string (pp, ">(");
2835 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2836 pp_right_paren (pp);
2837 break;
2839 case PAREN_EXPR:
2840 pp_string (pp, "((");
2841 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2842 pp_string (pp, "))");
2843 break;
2845 case NON_LVALUE_EXPR:
2846 pp_string (pp, "NON_LVALUE_EXPR <");
2847 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2848 pp_greater (pp);
2849 break;
2851 case SAVE_EXPR:
2852 pp_string (pp, "SAVE_EXPR <");
2853 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2854 pp_greater (pp);
2855 break;
2857 case COMPLEX_EXPR:
2858 pp_string (pp, "COMPLEX_EXPR <");
2859 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2860 pp_string (pp, ", ");
2861 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2862 pp_greater (pp);
2863 break;
2865 case CONJ_EXPR:
2866 pp_string (pp, "CONJ_EXPR <");
2867 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2868 pp_greater (pp);
2869 break;
2871 case REALPART_EXPR:
2872 if (flags & TDF_GIMPLE)
2874 pp_string (pp, "__real ");
2875 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2877 else
2879 pp_string (pp, "REALPART_EXPR <");
2880 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2881 pp_greater (pp);
2883 break;
2885 case IMAGPART_EXPR:
2886 if (flags & TDF_GIMPLE)
2888 pp_string (pp, "__imag ");
2889 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2891 else
2893 pp_string (pp, "IMAGPART_EXPR <");
2894 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2895 pp_greater (pp);
2897 break;
2899 case VA_ARG_EXPR:
2900 pp_string (pp, "VA_ARG_EXPR <");
2901 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2902 pp_greater (pp);
2903 break;
2905 case TRY_FINALLY_EXPR:
2906 case TRY_CATCH_EXPR:
2907 pp_string (pp, "try");
2908 newline_and_indent (pp, spc+2);
2909 pp_left_brace (pp);
2910 newline_and_indent (pp, spc+4);
2911 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2912 newline_and_indent (pp, spc+2);
2913 pp_right_brace (pp);
2914 newline_and_indent (pp, spc);
2915 if (TREE_CODE (node) == TRY_CATCH_EXPR)
2917 node = TREE_OPERAND (node, 1);
2918 pp_string (pp, "catch");
2920 else
2922 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
2923 node = TREE_OPERAND (node, 1);
2924 pp_string (pp, "finally");
2925 if (TREE_CODE (node) == EH_ELSE_EXPR)
2927 newline_and_indent (pp, spc+2);
2928 pp_left_brace (pp);
2929 newline_and_indent (pp, spc+4);
2930 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
2931 flags, true);
2932 newline_and_indent (pp, spc+2);
2933 pp_right_brace (pp);
2934 newline_and_indent (pp, spc);
2935 node = TREE_OPERAND (node, 1);
2936 pp_string (pp, "else");
2939 newline_and_indent (pp, spc+2);
2940 pp_left_brace (pp);
2941 newline_and_indent (pp, spc+4);
2942 dump_generic_node (pp, node, spc+4, flags, true);
2943 newline_and_indent (pp, spc+2);
2944 pp_right_brace (pp);
2945 is_expr = false;
2946 break;
2948 case CATCH_EXPR:
2949 pp_string (pp, "catch (");
2950 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2951 pp_right_paren (pp);
2952 newline_and_indent (pp, spc+2);
2953 pp_left_brace (pp);
2954 newline_and_indent (pp, spc+4);
2955 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2956 newline_and_indent (pp, spc+2);
2957 pp_right_brace (pp);
2958 is_expr = false;
2959 break;
2961 case EH_FILTER_EXPR:
2962 pp_string (pp, "<<<eh_filter (");
2963 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2964 pp_string (pp, ")>>>");
2965 newline_and_indent (pp, spc+2);
2966 pp_left_brace (pp);
2967 newline_and_indent (pp, spc+4);
2968 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2969 newline_and_indent (pp, spc+2);
2970 pp_right_brace (pp);
2971 is_expr = false;
2972 break;
2974 case LABEL_EXPR:
2975 op0 = TREE_OPERAND (node, 0);
2976 /* If this is for break or continue, don't bother printing it. */
2977 if (DECL_NAME (op0))
2979 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2980 if (strcmp (name, "break") == 0
2981 || strcmp (name, "continue") == 0)
2982 break;
2984 dump_generic_node (pp, op0, spc, flags, false);
2985 pp_colon (pp);
2986 if (DECL_NONLOCAL (op0))
2987 pp_string (pp, " [non-local]");
2988 break;
2990 case LOOP_EXPR:
2991 pp_string (pp, "while (1)");
2992 if (!(flags & TDF_SLIM))
2994 newline_and_indent (pp, spc+2);
2995 pp_left_brace (pp);
2996 newline_and_indent (pp, spc+4);
2997 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2998 newline_and_indent (pp, spc+2);
2999 pp_right_brace (pp);
3001 is_expr = false;
3002 break;
3004 case PREDICT_EXPR:
3005 pp_string (pp, "// predicted ");
3006 if (PREDICT_EXPR_OUTCOME (node))
3007 pp_string (pp, "likely by ");
3008 else
3009 pp_string (pp, "unlikely by ");
3010 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
3011 pp_string (pp, " predictor.");
3012 break;
3014 case ANNOTATE_EXPR:
3015 pp_string (pp, "ANNOTATE_EXPR <");
3016 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3017 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
3019 case annot_expr_ivdep_kind:
3020 pp_string (pp, ", ivdep");
3021 break;
3022 case annot_expr_unroll_kind:
3023 pp_printf (pp, ", unroll %d",
3024 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
3025 break;
3026 case annot_expr_no_vector_kind:
3027 pp_string (pp, ", no-vector");
3028 break;
3029 case annot_expr_vector_kind:
3030 pp_string (pp, ", vector");
3031 break;
3032 case annot_expr_parallel_kind:
3033 pp_string (pp, ", parallel");
3034 break;
3035 default:
3036 gcc_unreachable ();
3038 pp_greater (pp);
3039 break;
3041 case RETURN_EXPR:
3042 pp_string (pp, "return");
3043 op0 = TREE_OPERAND (node, 0);
3044 if (op0)
3046 pp_space (pp);
3047 if (TREE_CODE (op0) == MODIFY_EXPR)
3048 dump_generic_node (pp, TREE_OPERAND (op0, 1),
3049 spc, flags, false);
3050 else
3051 dump_generic_node (pp, op0, spc, flags, false);
3053 break;
3055 case EXIT_EXPR:
3056 pp_string (pp, "if (");
3057 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3058 pp_string (pp, ") break");
3059 break;
3061 case SWITCH_EXPR:
3062 pp_string (pp, "switch (");
3063 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3064 pp_right_paren (pp);
3065 if (!(flags & TDF_SLIM))
3067 newline_and_indent (pp, spc+2);
3068 pp_left_brace (pp);
3069 if (SWITCH_BODY (node))
3071 newline_and_indent (pp, spc+4);
3072 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3073 true);
3075 newline_and_indent (pp, spc+2);
3076 pp_right_brace (pp);
3078 is_expr = false;
3079 break;
3081 case GOTO_EXPR:
3082 op0 = GOTO_DESTINATION (node);
3083 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3085 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3086 if (strcmp (name, "break") == 0
3087 || strcmp (name, "continue") == 0)
3089 pp_string (pp, name);
3090 break;
3093 pp_string (pp, "goto ");
3094 dump_generic_node (pp, op0, spc, flags, false);
3095 break;
3097 case ASM_EXPR:
3098 pp_string (pp, "__asm__");
3099 if (ASM_VOLATILE_P (node))
3100 pp_string (pp, " __volatile__");
3101 pp_left_paren (pp);
3102 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3103 pp_colon (pp);
3104 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3105 pp_colon (pp);
3106 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3107 if (ASM_CLOBBERS (node))
3109 pp_colon (pp);
3110 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3112 pp_right_paren (pp);
3113 break;
3115 case CASE_LABEL_EXPR:
3116 if (CASE_LOW (node) && CASE_HIGH (node))
3118 pp_string (pp, "case ");
3119 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3120 pp_string (pp, " ... ");
3121 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3123 else if (CASE_LOW (node))
3125 pp_string (pp, "case ");
3126 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3128 else
3129 pp_string (pp, "default");
3130 pp_colon (pp);
3131 break;
3133 case OBJ_TYPE_REF:
3134 pp_string (pp, "OBJ_TYPE_REF(");
3135 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3136 pp_semicolon (pp);
3137 /* We omit the class type for -fcompare-debug because we may
3138 drop TYPE_BINFO early depending on debug info, and then
3139 virtual_method_call_p would return false, whereas when
3140 TYPE_BINFO is preserved it may still return true and then
3141 we'd print the class type. Compare tree and rtl dumps for
3142 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3143 for example, at occurrences of OBJ_TYPE_REF. */
3144 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3145 && virtual_method_call_p (node, true))
3147 pp_string (pp, "(");
3148 dump_generic_node (pp, obj_type_ref_class (node, true),
3149 spc, flags, false);
3150 pp_string (pp, ")");
3152 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3153 pp_arrow (pp);
3154 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3155 pp_right_paren (pp);
3156 break;
3158 case SSA_NAME:
3159 if (SSA_NAME_IDENTIFIER (node))
3161 if ((flags & TDF_NOUID)
3162 && SSA_NAME_VAR (node)
3163 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3164 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3165 else if (! (flags & TDF_GIMPLE)
3166 || SSA_NAME_VAR (node))
3167 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3168 spc, flags, false);
3170 pp_underscore (pp);
3171 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3172 if (SSA_NAME_IS_DEFAULT_DEF (node))
3173 pp_string (pp, "(D)");
3174 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3175 pp_string (pp, "(ab)");
3176 break;
3178 case WITH_SIZE_EXPR:
3179 pp_string (pp, "WITH_SIZE_EXPR <");
3180 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3181 pp_string (pp, ", ");
3182 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3183 pp_greater (pp);
3184 break;
3186 case ASSERT_EXPR:
3187 pp_string (pp, "ASSERT_EXPR <");
3188 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
3189 pp_string (pp, ", ");
3190 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
3191 pp_greater (pp);
3192 break;
3194 case SCEV_KNOWN:
3195 pp_string (pp, "scev_known");
3196 break;
3198 case SCEV_NOT_KNOWN:
3199 pp_string (pp, "scev_not_known");
3200 break;
3202 case POLYNOMIAL_CHREC:
3203 pp_left_brace (pp);
3204 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3205 pp_string (pp, ", +, ");
3206 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3207 pp_printf (pp, "}_%u", CHREC_VARIABLE (node));
3208 is_stmt = false;
3209 break;
3211 case REALIGN_LOAD_EXPR:
3212 pp_string (pp, "REALIGN_LOAD <");
3213 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3214 pp_string (pp, ", ");
3215 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3216 pp_string (pp, ", ");
3217 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3218 pp_greater (pp);
3219 break;
3221 case VEC_COND_EXPR:
3222 pp_string (pp, " VEC_COND_EXPR < ");
3223 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3224 pp_string (pp, " , ");
3225 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3226 pp_string (pp, " , ");
3227 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3228 pp_string (pp, " > ");
3229 break;
3231 case VEC_PERM_EXPR:
3232 pp_string (pp, " VEC_PERM_EXPR < ");
3233 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3234 pp_string (pp, " , ");
3235 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3236 pp_string (pp, " , ");
3237 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3238 pp_string (pp, " > ");
3239 break;
3241 case DOT_PROD_EXPR:
3242 pp_string (pp, " DOT_PROD_EXPR < ");
3243 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3244 pp_string (pp, ", ");
3245 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3246 pp_string (pp, ", ");
3247 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3248 pp_string (pp, " > ");
3249 break;
3251 case WIDEN_MULT_PLUS_EXPR:
3252 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3253 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3254 pp_string (pp, ", ");
3255 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3256 pp_string (pp, ", ");
3257 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3258 pp_string (pp, " > ");
3259 break;
3261 case WIDEN_MULT_MINUS_EXPR:
3262 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3263 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3264 pp_string (pp, ", ");
3265 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3266 pp_string (pp, ", ");
3267 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3268 pp_string (pp, " > ");
3269 break;
3271 case OACC_PARALLEL:
3272 pp_string (pp, "#pragma acc parallel");
3273 goto dump_omp_clauses_body;
3275 case OACC_KERNELS:
3276 pp_string (pp, "#pragma acc kernels");
3277 goto dump_omp_clauses_body;
3279 case OACC_SERIAL:
3280 pp_string (pp, "#pragma acc serial");
3281 goto dump_omp_clauses_body;
3283 case OACC_DATA:
3284 pp_string (pp, "#pragma acc data");
3285 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3286 goto dump_omp_body;
3288 case OACC_HOST_DATA:
3289 pp_string (pp, "#pragma acc host_data");
3290 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3291 goto dump_omp_body;
3293 case OACC_DECLARE:
3294 pp_string (pp, "#pragma acc declare");
3295 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3296 break;
3298 case OACC_UPDATE:
3299 pp_string (pp, "#pragma acc update");
3300 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3301 break;
3303 case OACC_ENTER_DATA:
3304 pp_string (pp, "#pragma acc enter data");
3305 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3306 break;
3308 case OACC_EXIT_DATA:
3309 pp_string (pp, "#pragma acc exit data");
3310 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3311 break;
3313 case OACC_CACHE:
3314 pp_string (pp, "#pragma acc cache");
3315 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3316 break;
3318 case OMP_PARALLEL:
3319 pp_string (pp, "#pragma omp parallel");
3320 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3321 goto dump_omp_body;
3323 dump_omp_clauses_body:
3324 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3325 goto dump_omp_body;
3327 dump_omp_body:
3328 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3330 newline_and_indent (pp, spc + 2);
3331 pp_left_brace (pp);
3332 newline_and_indent (pp, spc + 4);
3333 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3334 newline_and_indent (pp, spc + 2);
3335 pp_right_brace (pp);
3337 is_expr = false;
3338 break;
3340 case OMP_TASK:
3341 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3342 : "#pragma omp taskwait");
3343 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3344 goto dump_omp_body;
3346 case OMP_FOR:
3347 pp_string (pp, "#pragma omp for");
3348 goto dump_omp_loop;
3350 case OMP_SIMD:
3351 pp_string (pp, "#pragma omp simd");
3352 goto dump_omp_loop;
3354 case OMP_DISTRIBUTE:
3355 pp_string (pp, "#pragma omp distribute");
3356 goto dump_omp_loop;
3358 case OMP_TASKLOOP:
3359 pp_string (pp, "#pragma omp taskloop");
3360 goto dump_omp_loop;
3362 case OMP_LOOP:
3363 pp_string (pp, "#pragma omp loop");
3364 goto dump_omp_loop;
3366 case OACC_LOOP:
3367 pp_string (pp, "#pragma acc loop");
3368 goto dump_omp_loop;
3370 case OMP_TEAMS:
3371 pp_string (pp, "#pragma omp teams");
3372 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3373 goto dump_omp_body;
3375 case OMP_TARGET_DATA:
3376 pp_string (pp, "#pragma omp target data");
3377 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3378 goto dump_omp_body;
3380 case OMP_TARGET_ENTER_DATA:
3381 pp_string (pp, "#pragma omp target enter data");
3382 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3383 is_expr = false;
3384 break;
3386 case OMP_TARGET_EXIT_DATA:
3387 pp_string (pp, "#pragma omp target exit data");
3388 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3389 is_expr = false;
3390 break;
3392 case OMP_TARGET:
3393 pp_string (pp, "#pragma omp target");
3394 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3395 goto dump_omp_body;
3397 case OMP_TARGET_UPDATE:
3398 pp_string (pp, "#pragma omp target update");
3399 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3400 is_expr = false;
3401 break;
3403 dump_omp_loop:
3404 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3405 if (!(flags & TDF_SLIM))
3407 int i;
3409 if (OMP_FOR_PRE_BODY (node))
3411 newline_and_indent (pp, spc + 2);
3412 pp_left_brace (pp);
3413 spc += 4;
3414 newline_and_indent (pp, spc);
3415 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3416 spc, flags, false);
3418 if (OMP_FOR_INIT (node))
3420 spc -= 2;
3421 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3423 spc += 2;
3424 newline_and_indent (pp, spc);
3425 pp_string (pp, "for (");
3426 tree init = TREE_VEC_ELT (OMP_FOR_INIT (node), i);
3427 if (TREE_CODE (init) != MODIFY_EXPR
3428 || TREE_CODE (TREE_OPERAND (init, 1)) != TREE_VEC)
3429 dump_generic_node (pp, init, spc, flags, false);
3430 else
3432 dump_generic_node (pp, TREE_OPERAND (init, 0),
3433 spc, flags, false);
3434 pp_string (pp, " = ");
3435 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (init, 1),
3436 spc, flags);
3438 pp_string (pp, "; ");
3439 tree cond = TREE_VEC_ELT (OMP_FOR_COND (node), i);
3440 if (!COMPARISON_CLASS_P (cond)
3441 || TREE_CODE (TREE_OPERAND (cond, 1)) != TREE_VEC)
3442 dump_generic_node (pp, cond, spc, flags, false);
3443 else
3445 dump_generic_node (pp, TREE_OPERAND (cond, 0),
3446 spc, flags, false);
3447 const char *op = op_symbol (cond);
3448 pp_space (pp);
3449 pp_string (pp, op);
3450 pp_space (pp);
3451 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (cond, 1),
3452 spc, flags);
3454 pp_string (pp, "; ");
3455 dump_generic_node (pp,
3456 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3457 spc, flags, false);
3458 pp_right_paren (pp);
3461 if (OMP_FOR_BODY (node))
3463 newline_and_indent (pp, spc + 2);
3464 pp_left_brace (pp);
3465 newline_and_indent (pp, spc + 4);
3466 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3467 false);
3468 newline_and_indent (pp, spc + 2);
3469 pp_right_brace (pp);
3471 if (OMP_FOR_INIT (node))
3472 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3473 if (OMP_FOR_PRE_BODY (node))
3475 spc -= 4;
3476 newline_and_indent (pp, spc + 2);
3477 pp_right_brace (pp);
3480 is_expr = false;
3481 break;
3483 case OMP_SECTIONS:
3484 pp_string (pp, "#pragma omp sections");
3485 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3486 goto dump_omp_body;
3488 case OMP_SECTION:
3489 pp_string (pp, "#pragma omp section");
3490 goto dump_omp_body;
3492 case OMP_SCAN:
3493 if (OMP_SCAN_CLAUSES (node))
3495 pp_string (pp, "#pragma omp scan");
3496 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3498 goto dump_omp_body;
3500 case OMP_MASTER:
3501 pp_string (pp, "#pragma omp master");
3502 goto dump_omp_body;
3504 case OMP_TASKGROUP:
3505 pp_string (pp, "#pragma omp taskgroup");
3506 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3507 goto dump_omp_body;
3509 case OMP_ORDERED:
3510 pp_string (pp, "#pragma omp ordered");
3511 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3512 goto dump_omp_body;
3514 case OMP_CRITICAL:
3515 pp_string (pp, "#pragma omp critical");
3516 if (OMP_CRITICAL_NAME (node))
3518 pp_space (pp);
3519 pp_left_paren (pp);
3520 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3521 flags, false);
3522 pp_right_paren (pp);
3524 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3525 goto dump_omp_body;
3527 case OMP_ATOMIC:
3528 pp_string (pp, "#pragma omp atomic");
3529 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3530 newline_and_indent (pp, spc + 2);
3531 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3532 pp_space (pp);
3533 pp_equal (pp);
3534 pp_space (pp);
3535 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3536 break;
3538 case OMP_ATOMIC_READ:
3539 pp_string (pp, "#pragma omp atomic read");
3540 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3541 newline_and_indent (pp, spc + 2);
3542 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3543 pp_space (pp);
3544 break;
3546 case OMP_ATOMIC_CAPTURE_OLD:
3547 case OMP_ATOMIC_CAPTURE_NEW:
3548 pp_string (pp, "#pragma omp atomic capture");
3549 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3550 newline_and_indent (pp, spc + 2);
3551 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3552 pp_space (pp);
3553 pp_equal (pp);
3554 pp_space (pp);
3555 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3556 break;
3558 case OMP_SINGLE:
3559 pp_string (pp, "#pragma omp single");
3560 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3561 goto dump_omp_body;
3563 case OMP_CLAUSE:
3564 dump_omp_clause (pp, node, spc, flags);
3565 is_expr = false;
3566 break;
3568 case TRANSACTION_EXPR:
3569 if (TRANSACTION_EXPR_OUTER (node))
3570 pp_string (pp, "__transaction_atomic [[outer]]");
3571 else if (TRANSACTION_EXPR_RELAXED (node))
3572 pp_string (pp, "__transaction_relaxed");
3573 else
3574 pp_string (pp, "__transaction_atomic");
3575 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3577 newline_and_indent (pp, spc);
3578 pp_left_brace (pp);
3579 newline_and_indent (pp, spc + 2);
3580 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3581 spc + 2, flags, false);
3582 newline_and_indent (pp, spc);
3583 pp_right_brace (pp);
3585 is_expr = false;
3586 break;
3588 case VEC_SERIES_EXPR:
3589 case VEC_WIDEN_MULT_HI_EXPR:
3590 case VEC_WIDEN_MULT_LO_EXPR:
3591 case VEC_WIDEN_PLUS_HI_EXPR:
3592 case VEC_WIDEN_PLUS_LO_EXPR:
3593 case VEC_WIDEN_MINUS_HI_EXPR:
3594 case VEC_WIDEN_MINUS_LO_EXPR:
3595 case VEC_WIDEN_MULT_EVEN_EXPR:
3596 case VEC_WIDEN_MULT_ODD_EXPR:
3597 case VEC_WIDEN_LSHIFT_HI_EXPR:
3598 case VEC_WIDEN_LSHIFT_LO_EXPR:
3599 pp_space (pp);
3600 for (str = get_tree_code_name (code); *str; str++)
3601 pp_character (pp, TOUPPER (*str));
3602 pp_string (pp, " < ");
3603 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3604 pp_string (pp, ", ");
3605 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3606 pp_string (pp, " > ");
3607 break;
3609 case VEC_DUPLICATE_EXPR:
3610 pp_space (pp);
3611 for (str = get_tree_code_name (code); *str; str++)
3612 pp_character (pp, TOUPPER (*str));
3613 pp_string (pp, " < ");
3614 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3615 pp_string (pp, " > ");
3616 break;
3618 case VEC_UNPACK_HI_EXPR:
3619 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3620 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3621 pp_string (pp, " > ");
3622 break;
3624 case VEC_UNPACK_LO_EXPR:
3625 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3626 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3627 pp_string (pp, " > ");
3628 break;
3630 case VEC_UNPACK_FLOAT_HI_EXPR:
3631 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3632 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3633 pp_string (pp, " > ");
3634 break;
3636 case VEC_UNPACK_FLOAT_LO_EXPR:
3637 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3638 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3639 pp_string (pp, " > ");
3640 break;
3642 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3643 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3644 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3645 pp_string (pp, " > ");
3646 break;
3648 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3649 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3650 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3651 pp_string (pp, " > ");
3652 break;
3654 case VEC_PACK_TRUNC_EXPR:
3655 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3656 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3657 pp_string (pp, ", ");
3658 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3659 pp_string (pp, " > ");
3660 break;
3662 case VEC_PACK_SAT_EXPR:
3663 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3664 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3665 pp_string (pp, ", ");
3666 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3667 pp_string (pp, " > ");
3668 break;
3670 case VEC_PACK_FIX_TRUNC_EXPR:
3671 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3672 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3673 pp_string (pp, ", ");
3674 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3675 pp_string (pp, " > ");
3676 break;
3678 case VEC_PACK_FLOAT_EXPR:
3679 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3680 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3681 pp_string (pp, ", ");
3682 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3683 pp_string (pp, " > ");
3684 break;
3686 case BLOCK:
3687 dump_block_node (pp, node, spc, flags);
3688 break;
3690 case DEBUG_BEGIN_STMT:
3691 pp_string (pp, "# DEBUG BEGIN STMT");
3692 break;
3694 default:
3695 NIY;
3698 if (is_stmt && is_expr)
3699 pp_semicolon (pp);
3701 return spc;
3704 /* Print the declaration of a variable. */
3706 void
3707 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
3709 INDENT (spc);
3711 if (TREE_CODE(t) == NAMELIST_DECL)
3713 pp_string(pp, "namelist ");
3714 dump_decl_name (pp, t, flags);
3715 pp_semicolon (pp);
3716 return;
3719 if (TREE_CODE (t) == TYPE_DECL)
3720 pp_string (pp, "typedef ");
3722 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
3723 pp_string (pp, "register ");
3725 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
3726 pp_string (pp, "extern ");
3727 else if (TREE_STATIC (t))
3728 pp_string (pp, "static ");
3730 /* Print the type and name. */
3731 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
3733 tree tmp;
3735 /* Print array's type. */
3736 tmp = TREE_TYPE (t);
3737 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
3738 tmp = TREE_TYPE (tmp);
3739 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
3741 /* Print variable's name. */
3742 pp_space (pp);
3743 dump_generic_node (pp, t, spc, flags, false);
3745 /* Print the dimensions. */
3746 tmp = TREE_TYPE (t);
3747 while (TREE_CODE (tmp) == ARRAY_TYPE)
3749 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
3750 tmp = TREE_TYPE (tmp);
3753 else if (TREE_CODE (t) == FUNCTION_DECL)
3755 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3756 pp_space (pp);
3757 dump_decl_name (pp, t, flags);
3758 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3760 else
3762 /* Print type declaration. */
3763 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3765 /* Print variable's name. */
3766 pp_space (pp);
3767 dump_generic_node (pp, t, spc, flags, false);
3770 if (VAR_P (t) && DECL_HARD_REGISTER (t))
3772 pp_string (pp, " __asm__ ");
3773 pp_left_paren (pp);
3774 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3775 pp_right_paren (pp);
3778 /* The initial value of a function serves to determine whether the function
3779 is declared or defined. So the following does not apply to function
3780 nodes. */
3781 if (TREE_CODE (t) != FUNCTION_DECL)
3783 /* Print the initial value. */
3784 if (DECL_INITIAL (t))
3786 pp_space (pp);
3787 pp_equal (pp);
3788 pp_space (pp);
3789 if (!(flags & TDF_SLIM))
3790 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3791 else
3792 pp_string (pp, "<<< omitted >>>");
3796 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
3798 pp_string (pp, " [value-expr: ");
3799 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3800 pp_right_bracket (pp);
3803 pp_semicolon (pp);
3807 /* Prints a structure: name, fields, and methods.
3808 FIXME: Still incomplete. */
3810 static void
3811 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
3812 dump_flags_t flags)
3814 /* Print the name of the structure. */
3815 if (TYPE_NAME (node))
3817 INDENT (spc);
3818 if (TREE_CODE (node) == RECORD_TYPE)
3819 pp_string (pp, "struct ");
3820 else if ((TREE_CODE (node) == UNION_TYPE
3821 || TREE_CODE (node) == QUAL_UNION_TYPE))
3822 pp_string (pp, "union ");
3824 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
3827 /* Print the contents of the structure. */
3828 pp_newline (pp);
3829 INDENT (spc);
3830 pp_left_brace (pp);
3831 pp_newline (pp);
3833 /* Print the fields of the structure. */
3835 tree tmp;
3836 tmp = TYPE_FIELDS (node);
3837 while (tmp)
3839 /* Avoid to print recursively the structure. */
3840 /* FIXME : Not implemented correctly...,
3841 what about the case when we have a cycle in the contain graph? ...
3842 Maybe this could be solved by looking at the scope in which the
3843 structure was declared. */
3844 if (TREE_TYPE (tmp) != node
3845 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3846 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3848 print_declaration (pp, tmp, spc+2, flags);
3849 pp_newline (pp);
3851 tmp = DECL_CHAIN (tmp);
3854 INDENT (spc);
3855 pp_right_brace (pp);
3858 /* Return the priority of the operator CODE.
3860 From lowest to highest precedence with either left-to-right (L-R)
3861 or right-to-left (R-L) associativity]:
3863 1 [L-R] ,
3864 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3865 3 [R-L] ?:
3866 4 [L-R] ||
3867 5 [L-R] &&
3868 6 [L-R] |
3869 7 [L-R] ^
3870 8 [L-R] &
3871 9 [L-R] == !=
3872 10 [L-R] < <= > >=
3873 11 [L-R] << >>
3874 12 [L-R] + -
3875 13 [L-R] * / %
3876 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3877 15 [L-R] fn() [] -> .
3879 unary +, - and * have higher precedence than the corresponding binary
3880 operators. */
3883 op_code_prio (enum tree_code code)
3885 switch (code)
3887 case TREE_LIST:
3888 case COMPOUND_EXPR:
3889 case BIND_EXPR:
3890 return 1;
3892 case MODIFY_EXPR:
3893 case INIT_EXPR:
3894 return 2;
3896 case COND_EXPR:
3897 return 3;
3899 case TRUTH_OR_EXPR:
3900 case TRUTH_ORIF_EXPR:
3901 return 4;
3903 case TRUTH_AND_EXPR:
3904 case TRUTH_ANDIF_EXPR:
3905 return 5;
3907 case BIT_IOR_EXPR:
3908 return 6;
3910 case BIT_XOR_EXPR:
3911 case TRUTH_XOR_EXPR:
3912 return 7;
3914 case BIT_AND_EXPR:
3915 return 8;
3917 case EQ_EXPR:
3918 case NE_EXPR:
3919 return 9;
3921 case UNLT_EXPR:
3922 case UNLE_EXPR:
3923 case UNGT_EXPR:
3924 case UNGE_EXPR:
3925 case UNEQ_EXPR:
3926 case LTGT_EXPR:
3927 case ORDERED_EXPR:
3928 case UNORDERED_EXPR:
3929 case LT_EXPR:
3930 case LE_EXPR:
3931 case GT_EXPR:
3932 case GE_EXPR:
3933 return 10;
3935 case LSHIFT_EXPR:
3936 case RSHIFT_EXPR:
3937 case LROTATE_EXPR:
3938 case RROTATE_EXPR:
3939 case VEC_WIDEN_LSHIFT_HI_EXPR:
3940 case VEC_WIDEN_LSHIFT_LO_EXPR:
3941 case WIDEN_LSHIFT_EXPR:
3942 return 11;
3944 case WIDEN_SUM_EXPR:
3945 case PLUS_EXPR:
3946 case POINTER_PLUS_EXPR:
3947 case POINTER_DIFF_EXPR:
3948 case MINUS_EXPR:
3949 return 12;
3951 case VEC_WIDEN_MULT_HI_EXPR:
3952 case VEC_WIDEN_MULT_LO_EXPR:
3953 case WIDEN_MULT_EXPR:
3954 case DOT_PROD_EXPR:
3955 case WIDEN_MULT_PLUS_EXPR:
3956 case WIDEN_MULT_MINUS_EXPR:
3957 case MULT_EXPR:
3958 case MULT_HIGHPART_EXPR:
3959 case TRUNC_DIV_EXPR:
3960 case CEIL_DIV_EXPR:
3961 case FLOOR_DIV_EXPR:
3962 case ROUND_DIV_EXPR:
3963 case RDIV_EXPR:
3964 case EXACT_DIV_EXPR:
3965 case TRUNC_MOD_EXPR:
3966 case CEIL_MOD_EXPR:
3967 case FLOOR_MOD_EXPR:
3968 case ROUND_MOD_EXPR:
3969 return 13;
3971 case TRUTH_NOT_EXPR:
3972 case BIT_NOT_EXPR:
3973 case POSTINCREMENT_EXPR:
3974 case POSTDECREMENT_EXPR:
3975 case PREINCREMENT_EXPR:
3976 case PREDECREMENT_EXPR:
3977 case NEGATE_EXPR:
3978 case INDIRECT_REF:
3979 case ADDR_EXPR:
3980 case FLOAT_EXPR:
3981 CASE_CONVERT:
3982 case FIX_TRUNC_EXPR:
3983 case TARGET_EXPR:
3984 return 14;
3986 case CALL_EXPR:
3987 case ARRAY_REF:
3988 case ARRAY_RANGE_REF:
3989 case COMPONENT_REF:
3990 return 15;
3992 /* Special expressions. */
3993 case MIN_EXPR:
3994 case MAX_EXPR:
3995 case ABS_EXPR:
3996 case REALPART_EXPR:
3997 case IMAGPART_EXPR:
3998 case VEC_UNPACK_HI_EXPR:
3999 case VEC_UNPACK_LO_EXPR:
4000 case VEC_UNPACK_FLOAT_HI_EXPR:
4001 case VEC_UNPACK_FLOAT_LO_EXPR:
4002 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
4003 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
4004 case VEC_PACK_TRUNC_EXPR:
4005 case VEC_PACK_SAT_EXPR:
4006 return 16;
4008 default:
4009 /* Return an arbitrarily high precedence to avoid surrounding single
4010 VAR_DECLs in ()s. */
4011 return 9999;
4015 /* Return the priority of the operator OP. */
4018 op_prio (const_tree op)
4020 enum tree_code code;
4022 if (op == NULL)
4023 return 9999;
4025 code = TREE_CODE (op);
4026 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
4027 return op_prio (TREE_OPERAND (op, 0));
4029 return op_code_prio (code);
4032 /* Return the symbol associated with operator CODE. */
4034 const char *
4035 op_symbol_code (enum tree_code code)
4037 switch (code)
4039 case MODIFY_EXPR:
4040 return "=";
4042 case TRUTH_OR_EXPR:
4043 case TRUTH_ORIF_EXPR:
4044 return "||";
4046 case TRUTH_AND_EXPR:
4047 case TRUTH_ANDIF_EXPR:
4048 return "&&";
4050 case BIT_IOR_EXPR:
4051 return "|";
4053 case TRUTH_XOR_EXPR:
4054 case BIT_XOR_EXPR:
4055 return "^";
4057 case ADDR_EXPR:
4058 case BIT_AND_EXPR:
4059 return "&";
4061 case ORDERED_EXPR:
4062 return "ord";
4063 case UNORDERED_EXPR:
4064 return "unord";
4066 case EQ_EXPR:
4067 return "==";
4068 case UNEQ_EXPR:
4069 return "u==";
4071 case NE_EXPR:
4072 return "!=";
4074 case LT_EXPR:
4075 return "<";
4076 case UNLT_EXPR:
4077 return "u<";
4079 case LE_EXPR:
4080 return "<=";
4081 case UNLE_EXPR:
4082 return "u<=";
4084 case GT_EXPR:
4085 return ">";
4086 case UNGT_EXPR:
4087 return "u>";
4089 case GE_EXPR:
4090 return ">=";
4091 case UNGE_EXPR:
4092 return "u>=";
4094 case LTGT_EXPR:
4095 return "<>";
4097 case LSHIFT_EXPR:
4098 return "<<";
4100 case RSHIFT_EXPR:
4101 return ">>";
4103 case LROTATE_EXPR:
4104 return "r<<";
4106 case RROTATE_EXPR:
4107 return "r>>";
4109 case WIDEN_LSHIFT_EXPR:
4110 return "w<<";
4112 case WIDEN_PLUS_EXPR:
4113 return "w+";
4115 case WIDEN_MINUS_EXPR:
4116 return "w-";
4118 case POINTER_PLUS_EXPR:
4119 return "+";
4121 case PLUS_EXPR:
4122 return "+";
4124 case WIDEN_SUM_EXPR:
4125 return "w+";
4127 case WIDEN_MULT_EXPR:
4128 return "w*";
4130 case MULT_HIGHPART_EXPR:
4131 return "h*";
4133 case NEGATE_EXPR:
4134 case MINUS_EXPR:
4135 case POINTER_DIFF_EXPR:
4136 return "-";
4138 case BIT_NOT_EXPR:
4139 return "~";
4141 case TRUTH_NOT_EXPR:
4142 return "!";
4144 case MULT_EXPR:
4145 case INDIRECT_REF:
4146 return "*";
4148 case TRUNC_DIV_EXPR:
4149 case RDIV_EXPR:
4150 return "/";
4152 case CEIL_DIV_EXPR:
4153 return "/[cl]";
4155 case FLOOR_DIV_EXPR:
4156 return "/[fl]";
4158 case ROUND_DIV_EXPR:
4159 return "/[rd]";
4161 case EXACT_DIV_EXPR:
4162 return "/[ex]";
4164 case TRUNC_MOD_EXPR:
4165 return "%";
4167 case CEIL_MOD_EXPR:
4168 return "%[cl]";
4170 case FLOOR_MOD_EXPR:
4171 return "%[fl]";
4173 case ROUND_MOD_EXPR:
4174 return "%[rd]";
4176 case PREDECREMENT_EXPR:
4177 return " --";
4179 case PREINCREMENT_EXPR:
4180 return " ++";
4182 case POSTDECREMENT_EXPR:
4183 return "-- ";
4185 case POSTINCREMENT_EXPR:
4186 return "++ ";
4188 case MAX_EXPR:
4189 return "max";
4191 case MIN_EXPR:
4192 return "min";
4194 default:
4195 return "<<< ??? >>>";
4199 /* Return the symbol associated with operator OP. */
4201 static const char *
4202 op_symbol (const_tree op)
4204 return op_symbol_code (TREE_CODE (op));
4207 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4208 the gimple_call_fn of a GIMPLE_CALL. */
4210 void
4211 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4213 tree op0 = node;
4215 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4216 op0 = TREE_OPERAND (op0, 0);
4218 again:
4219 switch (TREE_CODE (op0))
4221 case VAR_DECL:
4222 case PARM_DECL:
4223 case FUNCTION_DECL:
4224 dump_function_name (pp, op0, flags);
4225 break;
4227 case ADDR_EXPR:
4228 case INDIRECT_REF:
4229 CASE_CONVERT:
4230 op0 = TREE_OPERAND (op0, 0);
4231 goto again;
4233 case COND_EXPR:
4234 pp_left_paren (pp);
4235 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4236 pp_string (pp, ") ? ");
4237 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4238 pp_string (pp, " : ");
4239 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4240 break;
4242 case ARRAY_REF:
4243 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
4244 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4245 else
4246 dump_generic_node (pp, op0, 0, flags, false);
4247 break;
4249 case MEM_REF:
4250 if (integer_zerop (TREE_OPERAND (op0, 1)))
4252 op0 = TREE_OPERAND (op0, 0);
4253 goto again;
4255 /* Fallthru. */
4256 case COMPONENT_REF:
4257 case SSA_NAME:
4258 case OBJ_TYPE_REF:
4259 dump_generic_node (pp, op0, 0, flags, false);
4260 break;
4262 default:
4263 NIY;
4267 /* Print the first N characters in the array STR, replacing non-printable
4268 characters (including embedded nuls) with unambiguous escape sequences. */
4270 void
4271 pretty_print_string (pretty_printer *pp, const char *str, size_t n)
4273 if (str == NULL)
4274 return;
4276 for ( ; n; --n, ++str)
4278 switch (str[0])
4280 case '\b':
4281 pp_string (pp, "\\b");
4282 break;
4284 case '\f':
4285 pp_string (pp, "\\f");
4286 break;
4288 case '\n':
4289 pp_string (pp, "\\n");
4290 break;
4292 case '\r':
4293 pp_string (pp, "\\r");
4294 break;
4296 case '\t':
4297 pp_string (pp, "\\t");
4298 break;
4300 case '\v':
4301 pp_string (pp, "\\v");
4302 break;
4304 case '\\':
4305 pp_string (pp, "\\\\");
4306 break;
4308 case '\"':
4309 pp_string (pp, "\\\"");
4310 break;
4312 case '\'':
4313 pp_string (pp, "\\'");
4314 break;
4316 default:
4317 if (str[0] || n > 1)
4319 if (!ISPRINT (str[0]))
4321 char buf[5];
4322 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4323 pp_string (pp, buf);
4325 else
4326 pp_character (pp, str[0]);
4327 break;
4333 static void
4334 maybe_init_pretty_print (FILE *file)
4336 if (!tree_pp)
4338 tree_pp = new pretty_printer ();
4339 pp_needs_newline (tree_pp) = true;
4340 pp_translate_identifiers (tree_pp) = false;
4343 tree_pp->buffer->stream = file;
4346 static void
4347 newline_and_indent (pretty_printer *pp, int spc)
4349 pp_newline (pp);
4350 INDENT (spc);
4353 /* Handle the %K format for TEXT. Separate from default_tree_printer
4354 so it can also be used in front ends.
4355 The location LOC and BLOCK are expected to be extracted by the caller
4356 from the %K argument arg via EXPR_LOCATION(arg) and TREE_BLOCK(arg). */
4358 void
4359 percent_K_format (text_info *text, location_t loc, tree block)
4361 text->set_location (0, loc, SHOW_RANGE_WITH_CARET);
4362 gcc_assert (pp_ti_abstract_origin (text) != NULL);
4363 *pp_ti_abstract_origin (text) = NULL;
4365 while (block
4366 && TREE_CODE (block) == BLOCK
4367 && BLOCK_ABSTRACT_ORIGIN (block))
4369 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
4370 if (TREE_CODE (ao) == FUNCTION_DECL)
4372 *pp_ti_abstract_origin (text) = block;
4373 break;
4375 block = BLOCK_SUPERCONTEXT (block);
4379 /* Print the identifier ID to PRETTY-PRINTER. */
4381 void
4382 pp_tree_identifier (pretty_printer *pp, tree id)
4384 if (pp_translate_identifiers (pp))
4386 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4387 pp_append_text (pp, text, text + strlen (text));
4389 else
4390 pp_append_text (pp, IDENTIFIER_POINTER (id),
4391 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4394 /* A helper function that is used to dump function information before the
4395 function dump. */
4397 void
4398 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4400 const char *dname, *aname;
4401 struct cgraph_node *node = cgraph_node::get (fdecl);
4402 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4404 dname = lang_hooks.decl_printable_name (fdecl, 1);
4406 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4407 aname = (IDENTIFIER_POINTER
4408 (DECL_ASSEMBLER_NAME (fdecl)));
4409 else
4410 aname = "<unset-asm-name>";
4412 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4413 dname, aname, fun->funcdef_no);
4414 if (!(flags & TDF_NOUID))
4415 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4416 if (node)
4418 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4419 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4420 node->frequency == NODE_FREQUENCY_HOT
4421 ? " (hot)"
4422 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4423 ? " (unlikely executed)"
4424 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4425 ? " (executed once)"
4426 : "");
4428 else
4429 fprintf (dump_file, ")\n\n");
4432 /* Dump double_int D to pretty_printer PP. UNS is true
4433 if D is unsigned and false otherwise. */
4434 void
4435 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4437 if (d.fits_shwi ())
4438 pp_wide_integer (pp, d.low);
4439 else if (d.fits_uhwi ())
4440 pp_unsigned_wide_integer (pp, d.low);
4441 else
4443 unsigned HOST_WIDE_INT low = d.low;
4444 HOST_WIDE_INT high = d.high;
4445 if (!uns && d.is_negative ())
4447 pp_minus (pp);
4448 high = ~high + !low;
4449 low = -low;
4451 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4452 systems? */
4453 sprintf (pp_buffer (pp)->digit_buffer,
4454 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4455 (unsigned HOST_WIDE_INT) high, low);
4456 pp_string (pp, pp_buffer (pp)->digit_buffer);
4460 #if __GNUC__ >= 10
4461 # pragma GCC diagnostic pop
4462 #endif