hppa: Export main in pr104869.C on hpux
[official-gcc.git] / gcc / tree-pretty-print.cc
blob1fadd752d0591721e2f47827589a3d195f0f5cce
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2023 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.cc by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "backend.h"
25 #include "rtl.h"
26 #include "tree.h"
27 #include "predict.h"
28 #include "cgraph.h"
29 #include "tree-pretty-print.h"
30 #include "stor-layout.h"
31 #include "langhooks.h"
32 #include "tree-iterator.h"
33 #include "dumpfile.h"
34 #include "internal-fn.h"
35 #include "gomp-constants.h"
36 #include "gimple.h"
37 #include "fold-const.h"
39 /* Routines in this file get invoked via the default tree printer
40 used by diagnostics and thus they are called from pp_printf which
41 isn't reentrant. Avoid using pp_printf in this file. */
42 #pragma GCC poison pp_printf
44 /* Disable warnings about quoting issues in the pp_xxx calls below
45 that (intentionally) don't follow GCC diagnostic conventions. */
46 #if __GNUC__ >= 10
47 # pragma GCC diagnostic push
48 # pragma GCC diagnostic ignored "-Wformat-diag"
49 #endif
51 /* Local functions, macros and variables. */
52 static const char *op_symbol (const_tree, dump_flags_t = TDF_NONE);
53 static void newline_and_indent (pretty_printer *, int);
54 static void maybe_init_pretty_print (FILE *);
55 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
56 static void do_niy (pretty_printer *, const_tree, int, dump_flags_t);
58 #define INDENT(SPACE) do { \
59 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
61 #define NIY do_niy (pp, node, spc, flags)
63 static pretty_printer *tree_pp;
65 /* Try to print something for an unknown tree code. */
67 static void
68 do_niy (pretty_printer *pp, const_tree node, int spc, dump_flags_t flags)
70 int i, len;
72 pp_string (pp, "<<< Unknown tree: ");
73 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
75 if (EXPR_P (node))
77 len = TREE_OPERAND_LENGTH (node);
78 for (i = 0; i < len; ++i)
80 newline_and_indent (pp, spc+2);
81 dump_generic_node (pp, TREE_OPERAND (node, i), spc+2, flags, false);
85 pp_string (pp, " >>>");
88 /* Debugging function to print out a generic expression. */
90 DEBUG_FUNCTION void
91 debug_generic_expr (tree t)
93 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
94 fprintf (stderr, "\n");
97 /* Debugging function to print out a generic statement. */
99 DEBUG_FUNCTION void
100 debug_generic_stmt (tree t)
102 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
103 fprintf (stderr, "\n");
106 /* Debugging function to print out a chain of trees . */
108 DEBUG_FUNCTION void
109 debug_tree_chain (tree t)
111 hash_set<tree> seen;
113 while (t)
115 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
116 fprintf (stderr, " ");
117 t = TREE_CHAIN (t);
118 if (seen.add (t))
120 fprintf (stderr, "... [cycled back to ");
121 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
122 fprintf (stderr, "]");
123 break;
126 fprintf (stderr, "\n");
129 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
130 void
131 print_generic_decl (FILE *file, tree decl, dump_flags_t flags)
133 maybe_init_pretty_print (file);
134 print_declaration (tree_pp, decl, 2, flags);
135 pp_write_text_to_stream (tree_pp);
138 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
139 to show in the dump. See TDF_* in dumpfile.h. */
141 void
142 print_generic_stmt (FILE *file, tree t, dump_flags_t flags)
144 maybe_init_pretty_print (file);
145 dump_generic_node (tree_pp, t, 0, flags, true);
146 pp_newline_and_flush (tree_pp);
149 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
150 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
151 INDENT spaces. */
153 void
154 print_generic_stmt_indented (FILE *file, tree t, dump_flags_t flags, int indent)
156 int i;
158 maybe_init_pretty_print (file);
160 for (i = 0; i < indent; i++)
161 pp_space (tree_pp);
162 dump_generic_node (tree_pp, t, indent, flags, true);
163 pp_newline_and_flush (tree_pp);
166 /* Print a single expression T on file FILE. FLAGS specifies details to show
167 in the dump. See TDF_* in dumpfile.h. */
169 void
170 print_generic_expr (FILE *file, tree t, dump_flags_t flags)
172 maybe_init_pretty_print (file);
173 dump_generic_node (tree_pp, t, 0, flags, false);
174 pp_flush (tree_pp);
177 /* Print a single expression T to string, and return it. The caller
178 must free the returned memory. */
180 char *
181 print_generic_expr_to_str (tree t)
183 pretty_printer pp;
184 dump_generic_node (&pp, t, 0, TDF_VOPS|TDF_MEMSYMS, false);
185 return xstrdup (pp_formatted_text (&pp));
188 /* Dump NAME, an IDENTIFIER_POINTER, sanitized so that D<num> sequences
189 in it are replaced with Dxxxx, as long as they are at the start or
190 preceded by $ and at the end or followed by $. See make_fancy_name
191 in tree-sra.cc. */
193 static void
194 dump_fancy_name (pretty_printer *pp, tree name)
196 int cnt = 0;
197 int length = IDENTIFIER_LENGTH (name);
198 const char *n = IDENTIFIER_POINTER (name);
201 n = strchr (n, 'D');
202 if (n == NULL)
203 break;
204 if (ISDIGIT (n[1])
205 && (n == IDENTIFIER_POINTER (name) || n[-1] == '$'))
207 int l = 2;
208 while (ISDIGIT (n[l]))
209 l++;
210 if (n[l] == '\0' || n[l] == '$')
212 cnt++;
213 length += 5 - l;
215 n += l;
217 else
218 n++;
220 while (1);
221 if (cnt == 0)
223 pp_tree_identifier (pp, name);
224 return;
227 char *str = XNEWVEC (char, length + 1);
228 char *p = str;
229 const char *q;
230 q = n = IDENTIFIER_POINTER (name);
233 q = strchr (q, 'D');
234 if (q == NULL)
235 break;
236 if (ISDIGIT (q[1])
237 && (q == IDENTIFIER_POINTER (name) || q[-1] == '$'))
239 int l = 2;
240 while (ISDIGIT (q[l]))
241 l++;
242 if (q[l] == '\0' || q[l] == '$')
244 memcpy (p, n, q - n);
245 memcpy (p + (q - n), "Dxxxx", 5);
246 p += (q - n) + 5;
247 n = q + l;
249 q += l;
251 else
252 q++;
254 while (1);
255 memcpy (p, n, IDENTIFIER_LENGTH (name) - (n - IDENTIFIER_POINTER (name)));
256 str[length] = '\0';
257 if (pp_translate_identifiers (pp))
259 const char *text = identifier_to_locale (str);
260 pp_append_text (pp, text, text + strlen (text));
262 else
263 pp_append_text (pp, str, str + length);
264 XDELETEVEC (str);
267 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
268 in FLAGS. */
270 static void
271 dump_decl_name (pretty_printer *pp, tree node, dump_flags_t flags)
273 tree name = DECL_NAME (node);
274 if (name)
276 if ((flags & TDF_ASMNAME)
277 && HAS_DECL_ASSEMBLER_NAME_P (node)
278 && DECL_ASSEMBLER_NAME_SET_P (node))
279 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME_RAW (node));
280 /* For -fcompare-debug don't dump DECL_NAMELESS names at all,
281 -g might have created more fancy names and their indexes
282 could get out of sync. Usually those should be DECL_IGNORED_P
283 too, SRA can create even non-DECL_IGNORED_P DECL_NAMELESS fancy
284 names, let's hope those never get out of sync after doing the
285 dump_fancy_name sanitization. */
286 else if ((flags & TDF_COMPARE_DEBUG)
287 && DECL_NAMELESS (node)
288 && DECL_IGNORED_P (node))
289 name = NULL_TREE;
290 /* For DECL_NAMELESS names look for embedded uids in the
291 names and sanitize them for TDF_NOUID. */
292 else if ((flags & TDF_NOUID) && DECL_NAMELESS (node))
293 dump_fancy_name (pp, name);
294 else
295 pp_tree_identifier (pp, name);
297 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
298 if ((flags & TDF_UID) || name == NULL_TREE)
300 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
302 pp_character (pp, 'L');
303 pp_character (pp, uid_sep);
304 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
306 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
308 if (flags & TDF_NOUID)
309 pp_string (pp, "D#xxxx");
310 else
312 pp_string (pp, "D#");
313 pp_decimal_int (pp, (int) DEBUG_TEMP_UID (node));
316 else
318 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
319 pp_character (pp, c);
320 pp_character (pp, uid_sep);
321 if (flags & TDF_NOUID)
322 pp_string (pp, "xxxx");
323 else
324 pp_scalar (pp, "%u", DECL_UID (node));
327 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
329 if (flags & TDF_NOUID)
330 pp_string (pp, "ptD.xxxx");
331 else
333 pp_string (pp, "ptD.");
334 pp_scalar (pp, "%u", DECL_PT_UID (node));
339 /* Like the above, but used for pretty printing function calls. */
341 static void
342 dump_function_name (pretty_printer *pp, tree node, dump_flags_t flags)
344 if (CONVERT_EXPR_P (node))
345 node = TREE_OPERAND (node, 0);
346 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
348 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
349 if (flags & TDF_UID)
351 char uid_sep = (flags & TDF_GIMPLE) ? '_' : '.';
352 pp_character (pp, 'D');
353 pp_character (pp, uid_sep);
354 pp_scalar (pp, "%u", DECL_UID (node));
357 else
358 dump_decl_name (pp, node, flags);
361 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
362 FLAGS are as in dump_generic_node. */
364 static void
365 dump_function_declaration (pretty_printer *pp, tree node,
366 int spc, dump_flags_t flags)
368 bool wrote_arg = false;
369 tree arg;
371 pp_space (pp);
372 pp_left_paren (pp);
374 /* Print the argument types. */
375 arg = TYPE_ARG_TYPES (node);
376 while (arg && arg != void_list_node && arg != error_mark_node)
378 if (wrote_arg)
380 pp_comma (pp);
381 pp_space (pp);
383 wrote_arg = true;
384 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
385 arg = TREE_CHAIN (arg);
388 /* Drop the trailing void_type_node if we had any previous argument. */
389 if (arg == void_list_node && !wrote_arg)
390 pp_string (pp, "void");
391 /* Properly dump vararg function types. */
392 else if (!arg && wrote_arg)
393 pp_string (pp, ", ...");
394 /* Avoid printing any arg for unprototyped functions. */
396 pp_right_paren (pp);
399 /* Dump the domain associated with an array. */
401 static void
402 dump_array_domain (pretty_printer *pp, tree domain, int spc, dump_flags_t flags)
404 pp_left_bracket (pp);
405 if (domain)
407 tree min = TYPE_MIN_VALUE (domain);
408 tree max = TYPE_MAX_VALUE (domain);
410 if (min && max
411 && integer_zerop (min)
412 && tree_fits_shwi_p (max))
413 pp_wide_integer (pp, tree_to_shwi (max) + 1);
414 else
416 if (min)
417 dump_generic_node (pp, min, spc, flags, false);
418 pp_colon (pp);
419 if (max)
420 dump_generic_node (pp, max, spc, flags, false);
423 else
424 pp_string (pp, "<unknown>");
425 pp_right_bracket (pp);
429 /* Dump OpenMP iterators ITER. */
431 static void
432 dump_omp_iterators (pretty_printer *pp, tree iter, int spc, dump_flags_t flags)
434 pp_string (pp, "iterator(");
435 for (tree it = iter; it; it = TREE_CHAIN (it))
437 if (it != iter)
438 pp_string (pp, ", ");
439 dump_generic_node (pp, TREE_TYPE (TREE_VEC_ELT (it, 0)), spc, flags,
440 false);
441 pp_space (pp);
442 dump_generic_node (pp, TREE_VEC_ELT (it, 0), spc, flags, false);
443 pp_equal (pp);
444 dump_generic_node (pp, TREE_VEC_ELT (it, 1), spc, flags, false);
445 pp_colon (pp);
446 dump_generic_node (pp, TREE_VEC_ELT (it, 2), spc, flags, false);
447 pp_colon (pp);
448 dump_generic_node (pp, TREE_VEC_ELT (it, 3), spc, flags, false);
450 pp_right_paren (pp);
454 /* Dump OMP clause CLAUSE, without following OMP_CLAUSE_CHAIN.
456 PP, CLAUSE, SPC and FLAGS are as in dump_generic_node. */
458 static void
459 dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags)
461 const char *name;
462 const char *modifier = NULL;
463 switch (OMP_CLAUSE_CODE (clause))
465 case OMP_CLAUSE_PRIVATE:
466 name = "private";
467 goto print_remap;
468 case OMP_CLAUSE_SHARED:
469 name = "shared";
470 goto print_remap;
471 case OMP_CLAUSE_FIRSTPRIVATE:
472 name = "firstprivate";
473 goto print_remap;
474 case OMP_CLAUSE_LASTPRIVATE:
475 name = "lastprivate";
476 if (OMP_CLAUSE_LASTPRIVATE_CONDITIONAL (clause))
477 modifier = "conditional:";
478 goto print_remap;
479 case OMP_CLAUSE_COPYIN:
480 name = "copyin";
481 goto print_remap;
482 case OMP_CLAUSE_COPYPRIVATE:
483 name = "copyprivate";
484 goto print_remap;
485 case OMP_CLAUSE_UNIFORM:
486 name = "uniform";
487 goto print_remap;
488 case OMP_CLAUSE_USE_DEVICE_PTR:
489 name = "use_device_ptr";
490 if (OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT (clause))
491 modifier = "if_present:";
492 goto print_remap;
493 case OMP_CLAUSE_USE_DEVICE_ADDR:
494 name = "use_device_addr";
495 goto print_remap;
496 case OMP_CLAUSE_HAS_DEVICE_ADDR:
497 name = "has_device_addr";
498 goto print_remap;
499 case OMP_CLAUSE_IS_DEVICE_PTR:
500 name = "is_device_ptr";
501 goto print_remap;
502 case OMP_CLAUSE_INCLUSIVE:
503 name = "inclusive";
504 goto print_remap;
505 case OMP_CLAUSE_EXCLUSIVE:
506 name = "exclusive";
507 goto print_remap;
508 case OMP_CLAUSE__LOOPTEMP_:
509 name = "_looptemp_";
510 goto print_remap;
511 case OMP_CLAUSE__REDUCTEMP_:
512 name = "_reductemp_";
513 goto print_remap;
514 case OMP_CLAUSE__CONDTEMP_:
515 name = "_condtemp_";
516 goto print_remap;
517 case OMP_CLAUSE__SCANTEMP_:
518 name = "_scantemp_";
519 goto print_remap;
520 case OMP_CLAUSE_ENTER:
521 if (OMP_CLAUSE_ENTER_TO (clause))
522 name = "to";
523 else
524 name = "enter";
525 goto print_remap;
526 case OMP_CLAUSE_LINK:
527 name = "link";
528 goto print_remap;
529 case OMP_CLAUSE_NONTEMPORAL:
530 name = "nontemporal";
531 goto print_remap;
532 print_remap:
533 pp_string (pp, name);
534 pp_left_paren (pp);
535 if (modifier)
536 pp_string (pp, modifier);
537 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
538 spc, flags, false);
539 pp_right_paren (pp);
540 break;
542 case OMP_CLAUSE_TASK_REDUCTION:
543 case OMP_CLAUSE_IN_REDUCTION:
544 pp_string (pp, OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_IN_REDUCTION
545 ? "in_" : "task_");
546 /* FALLTHRU */
547 case OMP_CLAUSE_REDUCTION:
548 pp_string (pp, "reduction(");
549 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_REDUCTION)
551 if (OMP_CLAUSE_REDUCTION_TASK (clause))
552 pp_string (pp, "task,");
553 else if (OMP_CLAUSE_REDUCTION_INSCAN (clause))
554 pp_string (pp, "inscan,");
556 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
558 pp_string (pp,
559 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
560 pp_colon (pp);
562 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
563 spc, flags, false);
564 pp_right_paren (pp);
565 break;
567 case OMP_CLAUSE_IF:
568 pp_string (pp, "if(");
569 switch (OMP_CLAUSE_IF_MODIFIER (clause))
571 case ERROR_MARK: break;
572 case VOID_CST: pp_string (pp, "cancel:"); break;
573 case OMP_PARALLEL: pp_string (pp, "parallel:"); break;
574 case OMP_SIMD: pp_string (pp, "simd:"); break;
575 case OMP_TASK: pp_string (pp, "task:"); break;
576 case OMP_TASKLOOP: pp_string (pp, "taskloop:"); break;
577 case OMP_TARGET_DATA: pp_string (pp, "target data:"); break;
578 case OMP_TARGET: pp_string (pp, "target:"); break;
579 case OMP_TARGET_UPDATE: pp_string (pp, "target update:"); break;
580 case OMP_TARGET_ENTER_DATA:
581 pp_string (pp, "target enter data:"); break;
582 case OMP_TARGET_EXIT_DATA: pp_string (pp, "target exit data:"); break;
583 default: gcc_unreachable ();
585 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
586 spc, flags, false);
587 pp_right_paren (pp);
588 break;
590 case OMP_CLAUSE_SELF:
591 pp_string (pp, "self(");
592 dump_generic_node (pp, OMP_CLAUSE_SELF_EXPR (clause),
593 spc, flags, false);
594 pp_right_paren (pp);
595 break;
597 case OMP_CLAUSE_NUM_THREADS:
598 pp_string (pp, "num_threads(");
599 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
600 spc, flags, false);
601 pp_right_paren (pp);
602 break;
604 case OMP_CLAUSE_NOWAIT:
605 pp_string (pp, "nowait");
606 break;
607 case OMP_CLAUSE_ORDERED:
608 pp_string (pp, "ordered");
609 if (OMP_CLAUSE_ORDERED_EXPR (clause))
611 pp_left_paren (pp);
612 dump_generic_node (pp, OMP_CLAUSE_ORDERED_EXPR (clause),
613 spc, flags, false);
614 pp_right_paren (pp);
616 break;
618 case OMP_CLAUSE_DEFAULT:
619 pp_string (pp, "default(");
620 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
622 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
623 break;
624 case OMP_CLAUSE_DEFAULT_SHARED:
625 pp_string (pp, "shared");
626 break;
627 case OMP_CLAUSE_DEFAULT_NONE:
628 pp_string (pp, "none");
629 break;
630 case OMP_CLAUSE_DEFAULT_PRIVATE:
631 pp_string (pp, "private");
632 break;
633 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
634 pp_string (pp, "firstprivate");
635 break;
636 case OMP_CLAUSE_DEFAULT_PRESENT:
637 pp_string (pp, "present");
638 break;
639 default:
640 gcc_unreachable ();
642 pp_right_paren (pp);
643 break;
645 case OMP_CLAUSE_SCHEDULE:
646 pp_string (pp, "schedule(");
647 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
648 & (OMP_CLAUSE_SCHEDULE_MONOTONIC
649 | OMP_CLAUSE_SCHEDULE_NONMONOTONIC))
651 if (OMP_CLAUSE_SCHEDULE_KIND (clause)
652 & OMP_CLAUSE_SCHEDULE_MONOTONIC)
653 pp_string (pp, "monotonic");
654 else
655 pp_string (pp, "nonmonotonic");
656 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
657 pp_comma (pp);
658 else
659 pp_colon (pp);
661 if (OMP_CLAUSE_SCHEDULE_SIMD (clause))
662 pp_string (pp, "simd:");
664 switch (OMP_CLAUSE_SCHEDULE_KIND (clause) & OMP_CLAUSE_SCHEDULE_MASK)
666 case OMP_CLAUSE_SCHEDULE_STATIC:
667 pp_string (pp, "static");
668 break;
669 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
670 pp_string (pp, "dynamic");
671 break;
672 case OMP_CLAUSE_SCHEDULE_GUIDED:
673 pp_string (pp, "guided");
674 break;
675 case OMP_CLAUSE_SCHEDULE_RUNTIME:
676 pp_string (pp, "runtime");
677 break;
678 case OMP_CLAUSE_SCHEDULE_AUTO:
679 pp_string (pp, "auto");
680 break;
681 default:
682 gcc_unreachable ();
684 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
686 pp_comma (pp);
687 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
688 spc, flags, false);
690 pp_right_paren (pp);
691 break;
693 case OMP_CLAUSE_UNTIED:
694 pp_string (pp, "untied");
695 break;
697 case OMP_CLAUSE_COLLAPSE:
698 pp_string (pp, "collapse(");
699 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
700 spc, flags, false);
701 pp_right_paren (pp);
702 break;
704 case OMP_CLAUSE_FINAL:
705 pp_string (pp, "final(");
706 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
707 spc, flags, false);
708 pp_right_paren (pp);
709 break;
711 case OMP_CLAUSE_MERGEABLE:
712 pp_string (pp, "mergeable");
713 break;
715 case OMP_CLAUSE_LINEAR:
716 pp_string (pp, "linear(");
717 if (OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (clause))
718 switch (OMP_CLAUSE_LINEAR_KIND (clause))
720 case OMP_CLAUSE_LINEAR_DEFAULT:
721 break;
722 case OMP_CLAUSE_LINEAR_REF:
723 pp_string (pp, "ref(");
724 break;
725 case OMP_CLAUSE_LINEAR_VAL:
726 pp_string (pp, "val(");
727 break;
728 case OMP_CLAUSE_LINEAR_UVAL:
729 pp_string (pp, "uval(");
730 break;
731 default:
732 gcc_unreachable ();
734 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
735 spc, flags, false);
736 if (OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (clause)
737 && OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
738 pp_right_paren (pp);
739 pp_colon (pp);
740 if (!OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (clause)
741 && OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
742 switch (OMP_CLAUSE_LINEAR_KIND (clause))
744 case OMP_CLAUSE_LINEAR_REF:
745 pp_string (pp, "ref,step(");
746 break;
747 case OMP_CLAUSE_LINEAR_VAL:
748 pp_string (pp, "val,step(");
749 break;
750 case OMP_CLAUSE_LINEAR_UVAL:
751 pp_string (pp, "uval,step(");
752 break;
753 default:
754 gcc_unreachable ();
756 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
757 spc, flags, false);
758 if (!OMP_CLAUSE_LINEAR_OLD_LINEAR_MODIFIER (clause)
759 && OMP_CLAUSE_LINEAR_KIND (clause) != OMP_CLAUSE_LINEAR_DEFAULT)
760 pp_right_paren (pp);
761 pp_right_paren (pp);
762 break;
764 case OMP_CLAUSE_ALIGNED:
765 pp_string (pp, "aligned(");
766 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
767 spc, flags, false);
768 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
770 pp_colon (pp);
771 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
772 spc, flags, false);
774 pp_right_paren (pp);
775 break;
777 case OMP_CLAUSE_ALLOCATE:
778 pp_string (pp, "allocate(");
779 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
781 pp_string (pp, "allocator(");
782 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause),
783 spc, flags, false);
784 pp_right_paren (pp);
786 if (OMP_CLAUSE_ALLOCATE_ALIGN (clause))
788 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause))
789 pp_comma (pp);
790 pp_string (pp, "align(");
791 dump_generic_node (pp, OMP_CLAUSE_ALLOCATE_ALIGN (clause),
792 spc, flags, false);
793 pp_right_paren (pp);
795 if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (clause)
796 || OMP_CLAUSE_ALLOCATE_ALIGN (clause))
797 pp_colon (pp);
798 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
799 spc, flags, false);
800 pp_right_paren (pp);
801 break;
803 case OMP_CLAUSE_AFFINITY:
804 pp_string (pp, "affinity(");
806 tree t = OMP_CLAUSE_DECL (clause);
807 if (TREE_CODE (t) == TREE_LIST
808 && TREE_PURPOSE (t)
809 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
811 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
812 pp_colon (pp);
813 t = TREE_VALUE (t);
815 dump_generic_node (pp, t, spc, flags, false);
817 pp_right_paren (pp);
818 break;
819 case OMP_CLAUSE_DEPEND:
820 pp_string (pp, "depend(");
821 switch (OMP_CLAUSE_DEPEND_KIND (clause))
823 case OMP_CLAUSE_DEPEND_DEPOBJ:
824 name = "depobj";
825 break;
826 case OMP_CLAUSE_DEPEND_IN:
827 name = "in";
828 break;
829 case OMP_CLAUSE_DEPEND_OUT:
830 name = "out";
831 break;
832 case OMP_CLAUSE_DEPEND_INOUT:
833 name = "inout";
834 break;
835 case OMP_CLAUSE_DEPEND_MUTEXINOUTSET:
836 name = "mutexinoutset";
837 break;
838 case OMP_CLAUSE_DEPEND_INOUTSET:
839 name = "inoutset";
840 break;
841 case OMP_CLAUSE_DEPEND_LAST:
842 name = "__internal__";
843 break;
844 default:
845 gcc_unreachable ();
848 tree t = OMP_CLAUSE_DECL (clause);
849 if (TREE_CODE (t) == TREE_LIST
850 && TREE_PURPOSE (t)
851 && TREE_CODE (TREE_PURPOSE (t)) == TREE_VEC)
853 dump_omp_iterators (pp, TREE_PURPOSE (t), spc, flags);
854 pp_colon (pp);
855 t = TREE_VALUE (t);
857 if (name[0])
859 pp_string (pp, name);
860 pp_colon (pp);
862 if (t == null_pointer_node)
863 pp_string (pp, "omp_all_memory");
864 else
865 dump_generic_node (pp, t, spc, flags, false);
866 pp_right_paren (pp);
868 break;
870 case OMP_CLAUSE_DOACROSS:
871 pp_string (pp, OMP_CLAUSE_DOACROSS_DEPEND (clause)
872 ? "depend(" : "doacross(");
873 switch (OMP_CLAUSE_DOACROSS_KIND (clause))
875 case OMP_CLAUSE_DOACROSS_SOURCE:
876 if (OMP_CLAUSE_DOACROSS_DEPEND (clause))
877 pp_string (pp, "source)");
878 else
879 pp_string (pp, "source:)");
880 break;
881 case OMP_CLAUSE_DOACROSS_SINK:
882 pp_string (pp, "sink:");
883 if (OMP_CLAUSE_DECL (clause) == NULL_TREE)
885 pp_string (pp, "omp_cur_iteration-1)");
886 break;
888 for (tree t = OMP_CLAUSE_DECL (clause); t; t = TREE_CHAIN (t))
889 if (TREE_CODE (t) == TREE_LIST)
891 dump_generic_node (pp, TREE_VALUE (t), spc, flags, false);
892 if (TREE_PURPOSE (t) != integer_zero_node)
894 if (OMP_CLAUSE_DOACROSS_SINK_NEGATIVE (t))
895 pp_minus (pp);
896 else
897 pp_plus (pp);
898 dump_generic_node (pp, TREE_PURPOSE (t), spc, flags,
899 false);
901 if (TREE_CHAIN (t))
902 pp_comma (pp);
904 else
905 gcc_unreachable ();
906 pp_right_paren (pp);
907 break;
908 default:
909 gcc_unreachable ();
911 break;
913 case OMP_CLAUSE_MAP:
914 pp_string (pp, "map(");
915 switch (OMP_CLAUSE_MAP_KIND (clause))
917 case GOMP_MAP_ALLOC:
918 case GOMP_MAP_POINTER:
919 case GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION:
920 pp_string (pp, "alloc");
921 break;
922 case GOMP_MAP_IF_PRESENT:
923 pp_string (pp, "no_alloc");
924 break;
925 case GOMP_MAP_TO:
926 case GOMP_MAP_TO_PSET:
927 pp_string (pp, "to");
928 break;
929 case GOMP_MAP_FROM:
930 pp_string (pp, "from");
931 break;
932 case GOMP_MAP_TOFROM:
933 pp_string (pp, "tofrom");
934 break;
935 case GOMP_MAP_FORCE_ALLOC:
936 pp_string (pp, "force_alloc");
937 break;
938 case GOMP_MAP_FORCE_TO:
939 pp_string (pp, "force_to");
940 break;
941 case GOMP_MAP_FORCE_FROM:
942 pp_string (pp, "force_from");
943 break;
944 case GOMP_MAP_FORCE_TOFROM:
945 pp_string (pp, "force_tofrom");
946 break;
947 case GOMP_MAP_FORCE_PRESENT:
948 pp_string (pp, "force_present");
949 break;
950 case GOMP_MAP_DELETE:
951 pp_string (pp, "delete");
952 break;
953 case GOMP_MAP_FORCE_DEVICEPTR:
954 pp_string (pp, "force_deviceptr");
955 break;
956 case GOMP_MAP_ALWAYS_TO:
957 pp_string (pp, "always,to");
958 break;
959 case GOMP_MAP_ALWAYS_FROM:
960 pp_string (pp, "always,from");
961 break;
962 case GOMP_MAP_ALWAYS_TOFROM:
963 pp_string (pp, "always,tofrom");
964 break;
965 case GOMP_MAP_RELEASE:
966 pp_string (pp, "release");
967 break;
968 case GOMP_MAP_FIRSTPRIVATE_POINTER:
969 pp_string (pp, "firstprivate");
970 break;
971 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
972 pp_string (pp, "firstprivate ref");
973 break;
974 case GOMP_MAP_STRUCT:
975 pp_string (pp, "struct");
976 break;
977 case GOMP_MAP_ALWAYS_POINTER:
978 pp_string (pp, "always_pointer");
979 break;
980 case GOMP_MAP_DEVICE_RESIDENT:
981 pp_string (pp, "device_resident");
982 break;
983 case GOMP_MAP_LINK:
984 pp_string (pp, "link");
985 break;
986 case GOMP_MAP_ATTACH:
987 pp_string (pp, "attach");
988 break;
989 case GOMP_MAP_DETACH:
990 pp_string (pp, "detach");
991 break;
992 case GOMP_MAP_FORCE_DETACH:
993 pp_string (pp, "force_detach");
994 break;
995 case GOMP_MAP_ATTACH_DETACH:
996 pp_string (pp, "attach_detach");
997 break;
998 case GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION:
999 pp_string (pp, "attach_zero_length_array_section");
1000 break;
1001 case GOMP_MAP_PRESENT_ALLOC:
1002 pp_string (pp, "present,alloc");
1003 break;
1004 case GOMP_MAP_PRESENT_TO:
1005 pp_string (pp, "present,to");
1006 break;
1007 case GOMP_MAP_PRESENT_FROM:
1008 pp_string (pp, "present,from");
1009 break;
1010 case GOMP_MAP_PRESENT_TOFROM:
1011 pp_string (pp, "present,tofrom");
1012 break;
1013 case GOMP_MAP_ALWAYS_PRESENT_TO:
1014 pp_string (pp, "always,present,to");
1015 break;
1016 case GOMP_MAP_ALWAYS_PRESENT_FROM:
1017 pp_string (pp, "always,present,from");
1018 break;
1019 case GOMP_MAP_ALWAYS_PRESENT_TOFROM:
1020 pp_string (pp, "always,present,tofrom");
1021 break;
1022 default:
1023 gcc_unreachable ();
1025 pp_colon (pp);
1026 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
1027 spc, flags, false);
1028 print_clause_size:
1029 if (OMP_CLAUSE_SIZE (clause))
1031 switch (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
1032 ? OMP_CLAUSE_MAP_KIND (clause) : GOMP_MAP_TO)
1034 case GOMP_MAP_POINTER:
1035 case GOMP_MAP_FIRSTPRIVATE_POINTER:
1036 case GOMP_MAP_FIRSTPRIVATE_REFERENCE:
1037 case GOMP_MAP_ALWAYS_POINTER:
1038 pp_string (pp, " [pointer assign, bias: ");
1039 break;
1040 case GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION:
1041 pp_string (pp, " [pointer assign, zero-length array section, bias: ");
1042 break;
1043 case GOMP_MAP_TO_PSET:
1044 pp_string (pp, " [pointer set, len: ");
1045 break;
1046 case GOMP_MAP_ATTACH:
1047 case GOMP_MAP_DETACH:
1048 case GOMP_MAP_FORCE_DETACH:
1049 case GOMP_MAP_ATTACH_DETACH:
1050 case GOMP_MAP_ATTACH_ZERO_LENGTH_ARRAY_SECTION:
1051 pp_string (pp, " [bias: ");
1052 break;
1053 default:
1054 pp_string (pp, " [len: ");
1055 break;
1057 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
1058 spc, flags, false);
1059 pp_right_bracket (pp);
1061 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
1062 && OMP_CLAUSE_MAP_RUNTIME_IMPLICIT_P (clause))
1063 pp_string (pp, "[implicit]");
1064 pp_right_paren (pp);
1065 break;
1067 case OMP_CLAUSE_FROM:
1068 pp_string (pp, "from(");
1069 if (OMP_CLAUSE_MOTION_PRESENT (clause))
1070 pp_string (pp, "present:");
1071 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
1072 spc, flags, false);
1073 goto print_clause_size;
1075 case OMP_CLAUSE_TO:
1076 pp_string (pp, "to(");
1077 if (OMP_CLAUSE_MOTION_PRESENT (clause))
1078 pp_string (pp, "present:");
1079 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
1080 spc, flags, false);
1081 goto print_clause_size;
1083 case OMP_CLAUSE__CACHE_:
1084 pp_string (pp, "(");
1085 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
1086 spc, flags, false);
1087 goto print_clause_size;
1089 case OMP_CLAUSE_NUM_TEAMS:
1090 pp_string (pp, "num_teams(");
1091 if (OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (clause))
1093 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_LOWER_EXPR (clause),
1094 spc, flags, false);
1095 pp_colon (pp);
1097 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_UPPER_EXPR (clause),
1098 spc, flags, false);
1099 pp_right_paren (pp);
1100 break;
1102 case OMP_CLAUSE_THREAD_LIMIT:
1103 pp_string (pp, "thread_limit(");
1104 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
1105 spc, flags, false);
1106 pp_right_paren (pp);
1107 break;
1109 case OMP_CLAUSE_DEVICE:
1110 pp_string (pp, "device(");
1111 if (OMP_CLAUSE_DEVICE_ANCESTOR (clause))
1112 pp_string (pp, "ancestor:");
1113 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
1114 spc, flags, false);
1115 pp_right_paren (pp);
1116 break;
1118 case OMP_CLAUSE_DIST_SCHEDULE:
1119 pp_string (pp, "dist_schedule(static");
1120 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
1122 pp_comma (pp);
1123 dump_generic_node (pp,
1124 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
1125 spc, flags, false);
1127 pp_right_paren (pp);
1128 break;
1130 case OMP_CLAUSE_PROC_BIND:
1131 pp_string (pp, "proc_bind(");
1132 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
1134 case OMP_CLAUSE_PROC_BIND_MASTER:
1135 /* Same enum value: case OMP_CLAUSE_PROC_BIND_PRIMARY: */
1136 /* TODO: Change to 'primary' for OpenMP 5.1. */
1137 pp_string (pp, "master");
1138 break;
1139 case OMP_CLAUSE_PROC_BIND_CLOSE:
1140 pp_string (pp, "close");
1141 break;
1142 case OMP_CLAUSE_PROC_BIND_SPREAD:
1143 pp_string (pp, "spread");
1144 break;
1145 default:
1146 gcc_unreachable ();
1148 pp_right_paren (pp);
1149 break;
1151 case OMP_CLAUSE_DEVICE_TYPE:
1152 pp_string (pp, "device_type(");
1153 switch (OMP_CLAUSE_DEVICE_TYPE_KIND (clause))
1155 case OMP_CLAUSE_DEVICE_TYPE_HOST:
1156 pp_string (pp, "host");
1157 break;
1158 case OMP_CLAUSE_DEVICE_TYPE_NOHOST:
1159 pp_string (pp, "nohost");
1160 break;
1161 case OMP_CLAUSE_DEVICE_TYPE_ANY:
1162 pp_string (pp, "any");
1163 break;
1164 default:
1165 gcc_unreachable ();
1167 pp_right_paren (pp);
1168 break;
1170 case OMP_CLAUSE_SAFELEN:
1171 pp_string (pp, "safelen(");
1172 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
1173 spc, flags, false);
1174 pp_right_paren (pp);
1175 break;
1177 case OMP_CLAUSE_SIMDLEN:
1178 pp_string (pp, "simdlen(");
1179 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
1180 spc, flags, false);
1181 pp_right_paren (pp);
1182 break;
1184 case OMP_CLAUSE_PRIORITY:
1185 pp_string (pp, "priority(");
1186 dump_generic_node (pp, OMP_CLAUSE_PRIORITY_EXPR (clause),
1187 spc, flags, false);
1188 pp_right_paren (pp);
1189 break;
1191 case OMP_CLAUSE_GRAINSIZE:
1192 pp_string (pp, "grainsize(");
1193 if (OMP_CLAUSE_GRAINSIZE_STRICT (clause))
1194 pp_string (pp, "strict:");
1195 dump_generic_node (pp, OMP_CLAUSE_GRAINSIZE_EXPR (clause),
1196 spc, flags, false);
1197 pp_right_paren (pp);
1198 break;
1200 case OMP_CLAUSE_NUM_TASKS:
1201 pp_string (pp, "num_tasks(");
1202 if (OMP_CLAUSE_NUM_TASKS_STRICT (clause))
1203 pp_string (pp, "strict:");
1204 dump_generic_node (pp, OMP_CLAUSE_NUM_TASKS_EXPR (clause),
1205 spc, flags, false);
1206 pp_right_paren (pp);
1207 break;
1209 case OMP_CLAUSE_HINT:
1210 pp_string (pp, "hint(");
1211 dump_generic_node (pp, OMP_CLAUSE_HINT_EXPR (clause),
1212 spc, flags, false);
1213 pp_right_paren (pp);
1214 break;
1216 case OMP_CLAUSE_FILTER:
1217 pp_string (pp, "filter(");
1218 dump_generic_node (pp, OMP_CLAUSE_FILTER_EXPR (clause),
1219 spc, flags, false);
1220 pp_right_paren (pp);
1221 break;
1223 case OMP_CLAUSE_DEFAULTMAP:
1224 pp_string (pp, "defaultmap(");
1225 switch (OMP_CLAUSE_DEFAULTMAP_BEHAVIOR (clause))
1227 case OMP_CLAUSE_DEFAULTMAP_ALLOC:
1228 pp_string (pp, "alloc");
1229 break;
1230 case OMP_CLAUSE_DEFAULTMAP_TO:
1231 pp_string (pp, "to");
1232 break;
1233 case OMP_CLAUSE_DEFAULTMAP_FROM:
1234 pp_string (pp, "from");
1235 break;
1236 case OMP_CLAUSE_DEFAULTMAP_TOFROM:
1237 pp_string (pp, "tofrom");
1238 break;
1239 case OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE:
1240 pp_string (pp, "firstprivate");
1241 break;
1242 case OMP_CLAUSE_DEFAULTMAP_NONE:
1243 pp_string (pp, "none");
1244 break;
1245 case OMP_CLAUSE_DEFAULTMAP_PRESENT:
1246 pp_string (pp, "present");
1247 break;
1248 case OMP_CLAUSE_DEFAULTMAP_DEFAULT:
1249 pp_string (pp, "default");
1250 break;
1251 default:
1252 gcc_unreachable ();
1254 switch (OMP_CLAUSE_DEFAULTMAP_CATEGORY (clause))
1256 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED:
1257 break;
1258 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALL:
1259 pp_string (pp, ":all");
1260 break;
1261 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_SCALAR:
1262 pp_string (pp, ":scalar");
1263 break;
1264 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_AGGREGATE:
1265 pp_string (pp, ":aggregate");
1266 break;
1267 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_ALLOCATABLE:
1268 pp_string (pp, ":allocatable");
1269 break;
1270 case OMP_CLAUSE_DEFAULTMAP_CATEGORY_POINTER:
1271 pp_string (pp, ":pointer");
1272 break;
1273 default:
1274 gcc_unreachable ();
1276 pp_right_paren (pp);
1277 break;
1279 case OMP_CLAUSE_ORDER:
1280 pp_string (pp, "order(");
1281 if (OMP_CLAUSE_ORDER_UNCONSTRAINED (clause))
1282 pp_string (pp, "unconstrained:");
1283 else if (OMP_CLAUSE_ORDER_REPRODUCIBLE (clause))
1284 pp_string (pp, "reproducible:");
1285 pp_string (pp, "concurrent)");
1286 break;
1288 case OMP_CLAUSE_BIND:
1289 pp_string (pp, "bind(");
1290 switch (OMP_CLAUSE_BIND_KIND (clause))
1292 case OMP_CLAUSE_BIND_TEAMS:
1293 pp_string (pp, "teams");
1294 break;
1295 case OMP_CLAUSE_BIND_PARALLEL:
1296 pp_string (pp, "parallel");
1297 break;
1298 case OMP_CLAUSE_BIND_THREAD:
1299 pp_string (pp, "thread");
1300 break;
1301 default:
1302 gcc_unreachable ();
1304 pp_right_paren (pp);
1305 break;
1307 case OMP_CLAUSE__SIMDUID_:
1308 pp_string (pp, "_simduid_(");
1309 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
1310 spc, flags, false);
1311 pp_right_paren (pp);
1312 break;
1314 case OMP_CLAUSE__SIMT_:
1315 pp_string (pp, "_simt_");
1316 break;
1318 case OMP_CLAUSE_GANG:
1319 pp_string (pp, "gang");
1320 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
1322 pp_string (pp, "(num: ");
1323 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
1324 spc, flags, false);
1326 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1328 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
1329 pp_left_paren (pp);
1330 else
1331 pp_space (pp);
1332 pp_string (pp, "static:");
1333 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
1334 == integer_minus_one_node)
1335 pp_character (pp, '*');
1336 else
1337 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
1338 spc, flags, false);
1340 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
1341 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
1342 pp_right_paren (pp);
1343 break;
1345 case OMP_CLAUSE_ASYNC:
1346 pp_string (pp, "async");
1347 if (OMP_CLAUSE_ASYNC_EXPR (clause))
1349 pp_character(pp, '(');
1350 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
1351 spc, flags, false);
1352 pp_character(pp, ')');
1354 break;
1356 case OMP_CLAUSE_AUTO:
1357 case OMP_CLAUSE_SEQ:
1358 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
1359 break;
1361 case OMP_CLAUSE_WAIT:
1362 pp_string (pp, "wait(");
1363 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
1364 spc, flags, false);
1365 pp_character(pp, ')');
1366 break;
1368 case OMP_CLAUSE_WORKER:
1369 pp_string (pp, "worker");
1370 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
1372 pp_left_paren (pp);
1373 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
1374 spc, flags, false);
1375 pp_right_paren (pp);
1377 break;
1379 case OMP_CLAUSE_VECTOR:
1380 pp_string (pp, "vector");
1381 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
1383 pp_left_paren (pp);
1384 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
1385 spc, flags, false);
1386 pp_right_paren (pp);
1388 break;
1390 case OMP_CLAUSE_NUM_GANGS:
1391 pp_string (pp, "num_gangs(");
1392 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
1393 spc, flags, false);
1394 pp_character (pp, ')');
1395 break;
1397 case OMP_CLAUSE_NUM_WORKERS:
1398 pp_string (pp, "num_workers(");
1399 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
1400 spc, flags, false);
1401 pp_character (pp, ')');
1402 break;
1404 case OMP_CLAUSE_VECTOR_LENGTH:
1405 pp_string (pp, "vector_length(");
1406 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
1407 spc, flags, false);
1408 pp_character (pp, ')');
1409 break;
1411 case OMP_CLAUSE_INBRANCH:
1412 pp_string (pp, "inbranch");
1413 break;
1414 case OMP_CLAUSE_NOTINBRANCH:
1415 pp_string (pp, "notinbranch");
1416 break;
1417 case OMP_CLAUSE_FOR:
1418 pp_string (pp, "for");
1419 break;
1420 case OMP_CLAUSE_PARALLEL:
1421 pp_string (pp, "parallel");
1422 break;
1423 case OMP_CLAUSE_SECTIONS:
1424 pp_string (pp, "sections");
1425 break;
1426 case OMP_CLAUSE_TASKGROUP:
1427 pp_string (pp, "taskgroup");
1428 break;
1429 case OMP_CLAUSE_NOGROUP:
1430 pp_string (pp, "nogroup");
1431 break;
1432 case OMP_CLAUSE_THREADS:
1433 pp_string (pp, "threads");
1434 break;
1435 case OMP_CLAUSE_SIMD:
1436 pp_string (pp, "simd");
1437 break;
1438 case OMP_CLAUSE_INDEPENDENT:
1439 pp_string (pp, "independent");
1440 break;
1441 case OMP_CLAUSE_TILE:
1442 pp_string (pp, "tile(");
1443 dump_generic_node (pp, OMP_CLAUSE_TILE_LIST (clause),
1444 spc, flags, false);
1445 pp_right_paren (pp);
1446 break;
1448 case OMP_CLAUSE_IF_PRESENT:
1449 pp_string (pp, "if_present");
1450 break;
1451 case OMP_CLAUSE_FINALIZE:
1452 pp_string (pp, "finalize");
1453 break;
1454 case OMP_CLAUSE_NOHOST:
1455 pp_string (pp, "nohost");
1456 break;
1457 case OMP_CLAUSE_DETACH:
1458 pp_string (pp, "detach(");
1459 dump_generic_node (pp, OMP_CLAUSE_DECL (clause), spc, flags,
1460 false);
1461 pp_right_paren (pp);
1462 break;
1463 default:
1464 gcc_unreachable ();
1469 /* Dump chain of OMP clauses.
1471 PP, SPC and FLAGS are as in dump_generic_node. */
1473 void
1474 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, dump_flags_t flags,
1475 bool leading_space)
1477 while (clause)
1479 if (leading_space)
1480 pp_space (pp);
1481 dump_omp_clause (pp, clause, spc, flags);
1482 leading_space = true;
1484 clause = OMP_CLAUSE_CHAIN (clause);
1489 /* Dump location LOC to PP. */
1491 void
1492 dump_location (pretty_printer *pp, location_t loc)
1494 expanded_location xloc = expand_location (loc);
1495 int discriminator = get_discriminator_from_loc (loc);
1497 pp_left_bracket (pp);
1498 if (xloc.file)
1500 pp_string (pp, xloc.file);
1501 pp_string (pp, ":");
1503 pp_decimal_int (pp, xloc.line);
1504 pp_colon (pp);
1505 pp_decimal_int (pp, xloc.column);
1506 if (discriminator)
1508 pp_string (pp, " discrim ");
1509 pp_decimal_int (pp, discriminator);
1511 pp_string (pp, "] ");
1515 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
1516 dump_generic_node. */
1518 static void
1519 dump_block_node (pretty_printer *pp, tree block, int spc, dump_flags_t flags)
1521 tree t;
1523 pp_string (pp, "BLOCK #");
1524 pp_decimal_int (pp, BLOCK_NUMBER (block));
1525 pp_character (pp, ' ');
1527 if (flags & TDF_ADDRESS)
1529 pp_character (pp, '[');
1530 pp_scalar (pp, "%p", (void *) block);
1531 pp_string (pp, "] ");
1534 if (TREE_ASM_WRITTEN (block))
1535 pp_string (pp, "[written] ");
1537 if (flags & TDF_SLIM)
1538 return;
1540 if (BLOCK_SOURCE_LOCATION (block))
1541 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
1543 newline_and_indent (pp, spc + 2);
1545 if (BLOCK_SUPERCONTEXT (block))
1547 pp_string (pp, "SUPERCONTEXT: ");
1548 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
1549 flags | TDF_SLIM, false);
1550 newline_and_indent (pp, spc + 2);
1553 if (BLOCK_SUBBLOCKS (block))
1555 pp_string (pp, "SUBBLOCKS: ");
1556 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
1558 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1559 pp_space (pp);
1561 newline_and_indent (pp, spc + 2);
1564 if (BLOCK_CHAIN (block))
1566 pp_string (pp, "SIBLINGS: ");
1567 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
1569 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1570 pp_space (pp);
1572 newline_and_indent (pp, spc + 2);
1575 if (BLOCK_VARS (block))
1577 pp_string (pp, "VARS: ");
1578 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
1580 dump_generic_node (pp, t, 0, flags, false);
1581 pp_space (pp);
1583 newline_and_indent (pp, spc + 2);
1586 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
1588 unsigned i;
1589 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
1591 pp_string (pp, "NONLOCALIZED_VARS: ");
1592 FOR_EACH_VEC_ELT (*nlv, i, t)
1594 dump_generic_node (pp, t, 0, flags, false);
1595 pp_space (pp);
1597 newline_and_indent (pp, spc + 2);
1600 if (BLOCK_ABSTRACT_ORIGIN (block))
1602 pp_string (pp, "ABSTRACT_ORIGIN: ");
1603 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
1604 flags | TDF_SLIM, false);
1605 newline_and_indent (pp, spc + 2);
1608 if (BLOCK_FRAGMENT_ORIGIN (block))
1610 pp_string (pp, "FRAGMENT_ORIGIN: ");
1611 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
1612 flags | TDF_SLIM, false);
1613 newline_and_indent (pp, spc + 2);
1616 if (BLOCK_FRAGMENT_CHAIN (block))
1618 pp_string (pp, "FRAGMENT_CHAIN: ");
1619 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
1621 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
1622 pp_space (pp);
1624 newline_and_indent (pp, spc + 2);
1628 /* Dump #pragma omp atomic memory order clause. */
1630 void
1631 dump_omp_atomic_memory_order (pretty_printer *pp, enum omp_memory_order mo)
1633 switch (mo & OMP_MEMORY_ORDER_MASK)
1635 case OMP_MEMORY_ORDER_RELAXED:
1636 pp_string (pp, " relaxed");
1637 break;
1638 case OMP_MEMORY_ORDER_SEQ_CST:
1639 pp_string (pp, " seq_cst");
1640 break;
1641 case OMP_MEMORY_ORDER_ACQ_REL:
1642 pp_string (pp, " acq_rel");
1643 break;
1644 case OMP_MEMORY_ORDER_ACQUIRE:
1645 pp_string (pp, " acquire");
1646 break;
1647 case OMP_MEMORY_ORDER_RELEASE:
1648 pp_string (pp, " release");
1649 break;
1650 case OMP_MEMORY_ORDER_UNSPECIFIED:
1651 break;
1652 default:
1653 gcc_unreachable ();
1655 switch (mo & OMP_FAIL_MEMORY_ORDER_MASK)
1657 case OMP_FAIL_MEMORY_ORDER_RELAXED:
1658 pp_string (pp, " fail(relaxed)");
1659 break;
1660 case OMP_FAIL_MEMORY_ORDER_SEQ_CST:
1661 pp_string (pp, " fail(seq_cst)");
1662 break;
1663 case OMP_FAIL_MEMORY_ORDER_ACQUIRE:
1664 pp_string (pp, " fail(acquire)");
1665 break;
1666 case OMP_FAIL_MEMORY_ORDER_UNSPECIFIED:
1667 break;
1668 default:
1669 gcc_unreachable ();
1673 /* Helper to dump a MEM_REF node. */
1675 static void
1676 dump_mem_ref (pretty_printer *pp, tree node, int spc, dump_flags_t flags)
1678 if (TREE_CODE (node) == MEM_REF && (flags & TDF_GIMPLE))
1680 pp_string (pp, "__MEM <");
1681 dump_generic_node (pp, TREE_TYPE (node),
1682 spc, flags | TDF_SLIM, false);
1683 if (TYPE_ALIGN (TREE_TYPE (node))
1684 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
1686 pp_string (pp, ", ");
1687 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
1689 pp_greater (pp);
1690 pp_string (pp, " (");
1691 if (TREE_TYPE (TREE_OPERAND (node, 0))
1692 != TREE_TYPE (TREE_OPERAND (node, 1)))
1694 pp_left_paren (pp);
1695 dump_generic_node (pp, TREE_TYPE (TREE_OPERAND (node, 1)),
1696 spc, flags | TDF_SLIM, false);
1697 pp_right_paren (pp);
1699 dump_generic_node (pp, TREE_OPERAND (node, 0),
1700 spc, flags | TDF_SLIM, false);
1701 if (! integer_zerop (TREE_OPERAND (node, 1)))
1703 pp_string (pp, " + ");
1704 dump_generic_node (pp, TREE_OPERAND (node, 1),
1705 spc, flags | TDF_SLIM, false);
1707 pp_right_paren (pp);
1709 else if (TREE_CODE (node) == MEM_REF
1710 && integer_zerop (TREE_OPERAND (node, 1))
1711 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1712 infer them and MEM_ATTR caching will share MEM_REFs
1713 with differently-typed op0s. */
1714 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1715 /* Released SSA_NAMES have no TREE_TYPE. */
1716 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1717 /* Same pointer types, but ignoring POINTER_TYPE vs.
1718 REFERENCE_TYPE. */
1719 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1720 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1721 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1722 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1723 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1724 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1725 /* Same value types ignoring qualifiers. */
1726 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1727 == TYPE_MAIN_VARIANT
1728 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1729 && (!(flags & TDF_ALIAS)
1730 || MR_DEPENDENCE_CLIQUE (node) == 0))
1732 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1734 /* Enclose pointers to arrays in parentheses. */
1735 tree op0 = TREE_OPERAND (node, 0);
1736 tree op0type = TREE_TYPE (op0);
1737 if (POINTER_TYPE_P (op0type)
1738 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1739 pp_left_paren (pp);
1740 pp_star (pp);
1741 dump_generic_node (pp, op0, spc, flags, false);
1742 if (POINTER_TYPE_P (op0type)
1743 && TREE_CODE (TREE_TYPE (op0type)) == ARRAY_TYPE)
1744 pp_right_paren (pp);
1746 else
1747 dump_generic_node (pp,
1748 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1749 spc, flags, false);
1751 else
1753 pp_string (pp, "MEM");
1755 tree nodetype = TREE_TYPE (node);
1756 tree op0 = TREE_OPERAND (node, 0);
1757 tree op1 = TREE_OPERAND (node, 1);
1758 tree op1type = TYPE_MAIN_VARIANT (TREE_TYPE (op1));
1760 tree op0size = TYPE_SIZE (nodetype);
1761 tree op1size = TYPE_SIZE (TREE_TYPE (op1type));
1763 if (!op0size || !op1size
1764 || !operand_equal_p (op0size, op1size, 0))
1766 pp_string (pp, " <");
1767 /* If the size of the type of the operand is not the same
1768 as the size of the MEM_REF expression include the type
1769 of the latter similar to the TDF_GIMPLE output to make
1770 it clear how many bytes of memory are being accessed. */
1771 dump_generic_node (pp, nodetype, spc, flags | TDF_SLIM, false);
1772 pp_string (pp, "> ");
1775 pp_string (pp, "[(");
1776 dump_generic_node (pp, op1type, spc, flags | TDF_SLIM, false);
1777 pp_right_paren (pp);
1778 dump_generic_node (pp, op0, spc, flags, false);
1779 if (!integer_zerop (op1))
1781 pp_string (pp, " + ");
1782 dump_generic_node (pp, op1, spc, flags, false);
1784 if (TREE_CODE (node) == TARGET_MEM_REF)
1786 tree tmp = TMR_INDEX2 (node);
1787 if (tmp)
1789 pp_string (pp, " + ");
1790 dump_generic_node (pp, tmp, spc, flags, false);
1792 tmp = TMR_INDEX (node);
1793 if (tmp)
1795 pp_string (pp, " + ");
1796 dump_generic_node (pp, tmp, spc, flags, false);
1797 tmp = TMR_STEP (node);
1798 pp_string (pp, " * ");
1799 if (tmp)
1800 dump_generic_node (pp, tmp, spc, flags, false);
1801 else
1802 pp_string (pp, "1");
1805 if ((flags & TDF_ALIAS)
1806 && MR_DEPENDENCE_CLIQUE (node) != 0)
1808 pp_string (pp, " clique ");
1809 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1810 pp_string (pp, " base ");
1811 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1813 pp_right_bracket (pp);
1817 /* Helper function for dump_generic_node. Dump INIT or COND expression for
1818 OpenMP loop non-rectangular iterators. */
1820 void
1821 dump_omp_loop_non_rect_expr (pretty_printer *pp, tree node, int spc,
1822 dump_flags_t flags)
1824 gcc_assert (TREE_CODE (node) == TREE_VEC);
1825 dump_generic_node (pp, TREE_VEC_ELT (node, 0), spc, flags, false);
1826 pp_string (pp, " * ");
1827 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (MULT_EXPR))
1829 pp_left_paren (pp);
1830 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1831 pp_right_paren (pp);
1833 else
1834 dump_generic_node (pp, TREE_VEC_ELT (node, 1), spc, flags, false);
1835 pp_string (pp, " + ");
1836 if (op_prio (TREE_VEC_ELT (node, 1)) <= op_code_prio (PLUS_EXPR))
1838 pp_left_paren (pp);
1839 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1840 pp_right_paren (pp);
1842 else
1843 dump_generic_node (pp, TREE_VEC_ELT (node, 2), spc, flags, false);
1846 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
1847 indent. FLAGS specifies details to show in the dump (see TDF_* in
1848 dumpfile.h). If IS_STMT is true, the object printed is considered
1849 to be a statement and it is terminated by ';' if appropriate. */
1852 dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
1853 bool is_stmt)
1855 tree type;
1856 tree op0, op1;
1857 const char *str;
1858 bool is_expr;
1859 enum tree_code code;
1861 if (node == NULL_TREE)
1862 return spc;
1864 is_expr = EXPR_P (node);
1866 if (is_stmt && (flags & TDF_STMTADDR))
1868 pp_string (pp, "<&");
1869 pp_scalar (pp, "%p", (void *)node);
1870 pp_string (pp, "> ");
1873 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
1874 dump_location (pp, EXPR_LOCATION (node));
1876 code = TREE_CODE (node);
1877 switch (code)
1879 case ERROR_MARK:
1880 pp_string (pp, "<<< error >>>");
1881 break;
1883 case IDENTIFIER_NODE:
1884 pp_tree_identifier (pp, node);
1885 break;
1887 case TREE_LIST:
1888 while (node && node != error_mark_node)
1890 if (TREE_PURPOSE (node))
1892 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1893 pp_space (pp);
1895 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1896 node = TREE_CHAIN (node);
1897 if (node && TREE_CODE (node) == TREE_LIST)
1899 pp_comma (pp);
1900 pp_space (pp);
1903 break;
1905 case TREE_BINFO:
1906 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1907 break;
1909 case TREE_VEC:
1911 size_t i;
1912 pp_left_brace (pp);
1913 if (TREE_VEC_LENGTH (node) > 0)
1915 size_t len = TREE_VEC_LENGTH (node);
1916 for (i = 0; i < len - 1; i++)
1918 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1919 false);
1920 pp_comma (pp);
1921 pp_space (pp);
1923 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1924 flags, false);
1926 pp_right_brace (pp);
1928 break;
1930 case VOID_TYPE:
1931 case INTEGER_TYPE:
1932 case REAL_TYPE:
1933 case FIXED_POINT_TYPE:
1934 case COMPLEX_TYPE:
1935 case VECTOR_TYPE:
1936 case ENUMERAL_TYPE:
1937 case BOOLEAN_TYPE:
1938 case BITINT_TYPE:
1939 case OPAQUE_TYPE:
1941 unsigned int quals = TYPE_QUALS (node);
1942 enum tree_code_class tclass;
1944 if (quals & TYPE_QUAL_ATOMIC)
1945 pp_string (pp, "atomic ");
1946 if (quals & TYPE_QUAL_CONST)
1947 pp_string (pp, "const ");
1948 if (quals & TYPE_QUAL_VOLATILE)
1949 pp_string (pp, "volatile ");
1950 if (quals & TYPE_QUAL_RESTRICT)
1951 pp_string (pp, "restrict ");
1953 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1955 pp_string (pp, "<address-space-");
1956 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1957 pp_string (pp, "> ");
1960 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1962 if (tclass == tcc_declaration)
1964 if (DECL_NAME (node))
1965 dump_decl_name (pp, node, flags);
1966 else
1967 pp_string (pp, "<unnamed type decl>");
1969 else if (tclass == tcc_type)
1971 if (TYPE_NAME (node))
1973 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1974 pp_tree_identifier (pp, TYPE_NAME (node));
1975 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1976 && DECL_NAME (TYPE_NAME (node)))
1977 dump_decl_name (pp, TYPE_NAME (node), flags);
1978 else
1979 pp_string (pp, "<unnamed type>");
1981 else if (TREE_CODE (node) == VECTOR_TYPE)
1983 pp_string (pp, "vector");
1984 pp_left_paren (pp);
1985 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1986 pp_string (pp, ") ");
1987 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1989 else if (TREE_CODE (node) == INTEGER_TYPE)
1991 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1992 pp_string (pp, (TYPE_UNSIGNED (node)
1993 ? "unsigned char"
1994 : "signed char"));
1995 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1996 pp_string (pp, (TYPE_UNSIGNED (node)
1997 ? "unsigned short"
1998 : "signed short"));
1999 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
2000 pp_string (pp, (TYPE_UNSIGNED (node)
2001 ? "unsigned int"
2002 : "signed int"));
2003 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
2004 pp_string (pp, (TYPE_UNSIGNED (node)
2005 ? "unsigned long"
2006 : "signed long"));
2007 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
2008 pp_string (pp, (TYPE_UNSIGNED (node)
2009 ? "unsigned long long"
2010 : "signed long long"));
2011 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
2012 && pow2p_hwi (TYPE_PRECISION (node)))
2014 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
2015 pp_decimal_int (pp, TYPE_PRECISION (node));
2016 pp_string (pp, "_t");
2018 else
2020 pp_string (pp, (TYPE_UNSIGNED (node)
2021 ? "<unnamed-unsigned:"
2022 : "<unnamed-signed:"));
2023 pp_decimal_int (pp, TYPE_PRECISION (node));
2024 pp_greater (pp);
2027 else if (TREE_CODE (node) == COMPLEX_TYPE)
2029 pp_string (pp, "__complex__ ");
2030 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2032 else if (TREE_CODE (node) == REAL_TYPE)
2034 pp_string (pp, "<float:");
2035 pp_decimal_int (pp, TYPE_PRECISION (node));
2036 pp_greater (pp);
2038 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
2040 pp_string (pp, "<fixed-point-");
2041 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
2042 pp_decimal_int (pp, TYPE_PRECISION (node));
2043 pp_greater (pp);
2045 else if (TREE_CODE (node) == BOOLEAN_TYPE)
2047 pp_string (pp, (TYPE_UNSIGNED (node)
2048 ? "<unsigned-boolean:"
2049 : "<signed-boolean:"));
2050 pp_decimal_int (pp, TYPE_PRECISION (node));
2051 pp_greater (pp);
2053 else if (TREE_CODE (node) == BITINT_TYPE)
2055 if (TYPE_UNSIGNED (node))
2056 pp_string (pp, "unsigned ");
2057 pp_string (pp, "_BitInt(");
2058 pp_decimal_int (pp, TYPE_PRECISION (node));
2059 pp_right_paren (pp);
2061 else if (TREE_CODE (node) == VOID_TYPE)
2062 pp_string (pp, "void");
2063 else
2064 pp_string (pp, "<unnamed type>");
2066 break;
2069 case POINTER_TYPE:
2070 case REFERENCE_TYPE:
2071 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
2073 if (TREE_TYPE (node) == NULL)
2075 pp_string (pp, str);
2076 pp_string (pp, "<null type>");
2078 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
2080 tree fnode = TREE_TYPE (node);
2082 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
2083 pp_space (pp);
2084 pp_left_paren (pp);
2085 pp_string (pp, str);
2086 if (TYPE_IDENTIFIER (node))
2087 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2088 else if (flags & TDF_NOUID)
2089 pp_string (pp, "<Txxxx>");
2090 else
2092 pp_string (pp, "<T");
2093 pp_scalar (pp, "%x", TYPE_UID (node));
2094 pp_character (pp, '>');
2097 pp_right_paren (pp);
2098 dump_function_declaration (pp, fnode, spc, flags);
2100 else
2102 unsigned int quals = TYPE_QUALS (node);
2104 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2105 pp_space (pp);
2106 pp_string (pp, str);
2108 if (quals & TYPE_QUAL_CONST)
2109 pp_string (pp, " const");
2110 if (quals & TYPE_QUAL_VOLATILE)
2111 pp_string (pp, " volatile");
2112 if (quals & TYPE_QUAL_RESTRICT)
2113 pp_string (pp, " restrict");
2115 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2117 pp_string (pp, " <address-space-");
2118 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2119 pp_greater (pp);
2122 if (TYPE_REF_CAN_ALIAS_ALL (node))
2123 pp_string (pp, " {ref-all}");
2125 break;
2127 case OFFSET_TYPE:
2128 NIY;
2129 break;
2131 case MEM_REF:
2132 case TARGET_MEM_REF:
2133 dump_mem_ref (pp, node, spc, flags);
2134 break;
2136 case ARRAY_TYPE:
2138 unsigned int quals = TYPE_QUALS (node);
2139 tree tmp;
2141 if (quals & TYPE_QUAL_ATOMIC)
2142 pp_string (pp, "atomic ");
2143 if (quals & TYPE_QUAL_CONST)
2144 pp_string (pp, "const ");
2145 if (quals & TYPE_QUAL_VOLATILE)
2146 pp_string (pp, "volatile ");
2148 /* Print the innermost component type. */
2149 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
2150 tmp = TREE_TYPE (tmp))
2153 /* Avoid to print recursively the array. */
2154 /* FIXME : Not implemented correctly, see print_struct_decl. */
2155 if (TREE_CODE (tmp) != POINTER_TYPE || TREE_TYPE (tmp) != node)
2156 dump_generic_node (pp, tmp, spc, flags, false);
2158 /* Print the dimensions. */
2159 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
2160 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2161 break;
2164 case RECORD_TYPE:
2165 case UNION_TYPE:
2166 case QUAL_UNION_TYPE:
2168 unsigned int quals = TYPE_QUALS (node);
2170 if (quals & TYPE_QUAL_ATOMIC)
2171 pp_string (pp, "atomic ");
2172 if (quals & TYPE_QUAL_CONST)
2173 pp_string (pp, "const ");
2174 if (quals & TYPE_QUAL_VOLATILE)
2175 pp_string (pp, "volatile ");
2177 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
2179 pp_string (pp, "<address-space-");
2180 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
2181 pp_string (pp, "> ");
2184 /* Print the name of the structure. */
2185 if (TREE_CODE (node) == RECORD_TYPE)
2186 pp_string (pp, "struct ");
2187 else if (TREE_CODE (node) == UNION_TYPE)
2188 pp_string (pp, "union ");
2190 if (TYPE_NAME (node))
2191 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2192 else if (!(flags & TDF_SLIM))
2193 /* FIXME: If we eliminate the 'else' above and attempt
2194 to show the fields for named types, we may get stuck
2195 following a cycle of pointers to structs. The alleged
2196 self-reference check in print_struct_decl will not detect
2197 cycles involving more than one pointer or struct type. */
2198 print_struct_decl (pp, node, spc, flags);
2199 break;
2202 case LANG_TYPE:
2203 NIY;
2204 break;
2206 case INTEGER_CST:
2207 if (flags & TDF_GIMPLE
2208 && (POINTER_TYPE_P (TREE_TYPE (node))
2209 || (TYPE_PRECISION (TREE_TYPE (node))
2210 < TYPE_PRECISION (integer_type_node))
2211 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1
2212 || tree_int_cst_sgn (node) < 0))
2214 pp_string (pp, "_Literal (");
2215 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2216 pp_string (pp, ") ");
2218 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE
2219 && ! (flags & TDF_GIMPLE))
2221 /* In the case of a pointer, one may want to divide by the
2222 size of the pointed-to type. Unfortunately, this not
2223 straightforward. The C front-end maps expressions
2225 (int *) 5
2226 int *p; (p + 5)
2228 in such a way that the two INTEGER_CST nodes for "5" have
2229 different values but identical types. In the latter
2230 case, the 5 is multiplied by sizeof (int) in c-common.cc
2231 (pointer_int_sum) to convert it to a byte address, and
2232 yet the type of the node is left unchanged. Argh. What
2233 is consistent though is that the number value corresponds
2234 to bytes (UNITS) offset.
2236 NB: Neither of the following divisors can be trivially
2237 used to recover the original literal:
2239 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
2240 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
2241 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
2242 pp_string (pp, "B"); /* pseudo-unit */
2244 else if (tree_fits_shwi_p (node))
2245 pp_wide_integer (pp, tree_to_shwi (node));
2246 else if (tree_fits_uhwi_p (node))
2247 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
2248 else
2250 wide_int val = wi::to_wide (node);
2252 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
2254 pp_minus (pp);
2255 val = -val;
2257 unsigned int len;
2258 print_hex_buf_size (val, &len);
2259 if (UNLIKELY (len > sizeof (pp_buffer (pp)->digit_buffer)))
2261 char *buf = XALLOCAVEC (char, len);
2262 print_hex (val, buf);
2263 pp_string (pp, buf);
2265 else
2267 print_hex (val, pp_buffer (pp)->digit_buffer);
2268 pp_string (pp, pp_buffer (pp)->digit_buffer);
2271 if ((flags & TDF_GIMPLE)
2272 && ! (POINTER_TYPE_P (TREE_TYPE (node))
2273 || (TYPE_PRECISION (TREE_TYPE (node))
2274 < TYPE_PRECISION (integer_type_node))
2275 || exact_log2 (TYPE_PRECISION (TREE_TYPE (node))) == -1))
2277 if (TYPE_UNSIGNED (TREE_TYPE (node)))
2278 pp_character (pp, 'u');
2279 if (TYPE_PRECISION (TREE_TYPE (node))
2280 == TYPE_PRECISION (unsigned_type_node))
2282 else if (TYPE_PRECISION (TREE_TYPE (node))
2283 == TYPE_PRECISION (long_unsigned_type_node))
2284 pp_character (pp, 'l');
2285 else if (TYPE_PRECISION (TREE_TYPE (node))
2286 == TYPE_PRECISION (long_long_unsigned_type_node))
2287 pp_string (pp, "ll");
2289 if (TREE_OVERFLOW (node))
2290 pp_string (pp, "(OVF)");
2291 break;
2293 case POLY_INT_CST:
2294 pp_string (pp, "POLY_INT_CST [");
2295 dump_generic_node (pp, POLY_INT_CST_COEFF (node, 0), spc, flags, false);
2296 for (unsigned int i = 1; i < NUM_POLY_INT_COEFFS; ++i)
2298 pp_string (pp, ", ");
2299 dump_generic_node (pp, POLY_INT_CST_COEFF (node, i),
2300 spc, flags, false);
2302 pp_string (pp, "]");
2303 break;
2305 case REAL_CST:
2306 /* Code copied from print_node. */
2308 REAL_VALUE_TYPE d;
2309 if (TREE_OVERFLOW (node))
2310 pp_string (pp, " overflow");
2312 d = TREE_REAL_CST (node);
2313 if (REAL_VALUE_ISINF (d))
2314 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
2315 else if (REAL_VALUE_ISNAN (d))
2316 pp_string (pp, " Nan");
2317 else
2319 char string[100];
2320 real_to_decimal (string, &d, sizeof (string), 0, 1);
2321 pp_string (pp, string);
2323 break;
2326 case FIXED_CST:
2328 char string[100];
2329 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
2330 pp_string (pp, string);
2331 break;
2334 case COMPLEX_CST:
2335 pp_string (pp, "__complex__ (");
2336 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
2337 pp_string (pp, ", ");
2338 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
2339 pp_right_paren (pp);
2340 break;
2342 case STRING_CST:
2344 pp_string (pp, "\"");
2345 if (unsigned nbytes = TREE_STRING_LENGTH (node))
2346 pretty_print_string (pp, TREE_STRING_POINTER (node), nbytes);
2347 pp_string (pp, "\"");
2348 break;
2351 case VECTOR_CST:
2353 unsigned i;
2354 if (flags & TDF_GIMPLE)
2356 pp_string (pp, "_Literal (");
2357 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2358 pp_string (pp, ") ");
2360 pp_string (pp, "{ ");
2361 unsigned HOST_WIDE_INT nunits;
2362 if (!VECTOR_CST_NELTS (node).is_constant (&nunits))
2363 nunits = vector_cst_encoded_nelts (node);
2364 for (i = 0; i < nunits; ++i)
2366 if (i != 0)
2367 pp_string (pp, ", ");
2368 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
2369 spc, flags, false);
2371 if (!VECTOR_CST_NELTS (node).is_constant ())
2372 pp_string (pp, ", ...");
2373 pp_string (pp, " }");
2375 break;
2377 case FUNCTION_TYPE:
2378 case METHOD_TYPE:
2379 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2380 pp_space (pp);
2381 if (TREE_CODE (node) == METHOD_TYPE)
2383 if (TYPE_METHOD_BASETYPE (node))
2384 dump_generic_node (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
2385 spc, flags, false);
2386 else
2387 pp_string (pp, "<null method basetype>");
2388 pp_colon_colon (pp);
2390 if (TYPE_IDENTIFIER (node))
2391 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
2392 else if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
2393 dump_decl_name (pp, TYPE_NAME (node), flags);
2394 else if (flags & TDF_NOUID)
2395 pp_string (pp, "<Txxxx>");
2396 else
2398 pp_string (pp, "<T");
2399 pp_scalar (pp, "%x", TYPE_UID (node));
2400 pp_character (pp, '>');
2402 dump_function_declaration (pp, node, spc, flags);
2403 break;
2405 case FUNCTION_DECL:
2406 case CONST_DECL:
2407 dump_decl_name (pp, node, flags);
2408 break;
2410 case LABEL_DECL:
2411 if (DECL_NAME (node))
2412 dump_decl_name (pp, node, flags);
2413 else if (LABEL_DECL_UID (node) != -1)
2415 if (flags & TDF_GIMPLE)
2417 pp_character (pp, 'L');
2418 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2420 else
2422 pp_string (pp, "<L");
2423 pp_decimal_int (pp, (int) LABEL_DECL_UID (node));
2424 pp_character (pp, '>');
2427 else
2429 if (flags & TDF_NOUID)
2430 pp_string (pp, "<D.xxxx>");
2431 else
2433 if (flags & TDF_GIMPLE)
2435 pp_character (pp, 'D');
2436 pp_scalar (pp, "%u", DECL_UID (node));
2438 else
2440 pp_string (pp, "<D.");
2441 pp_scalar (pp, "%u", DECL_UID (node));
2442 pp_character (pp, '>');
2446 break;
2448 case TYPE_DECL:
2449 if (DECL_IS_UNDECLARED_BUILTIN (node))
2451 /* Don't print the declaration of built-in types. */
2452 break;
2454 if (DECL_NAME (node))
2455 dump_decl_name (pp, node, flags);
2456 else if (TYPE_NAME (TREE_TYPE (node)) != node)
2458 pp_string (pp, (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
2459 ? "union" : "struct "));
2460 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2462 else
2463 pp_string (pp, "<anon>");
2464 break;
2466 case VAR_DECL:
2467 case PARM_DECL:
2468 case FIELD_DECL:
2469 case DEBUG_EXPR_DECL:
2470 case NAMESPACE_DECL:
2471 case NAMELIST_DECL:
2472 dump_decl_name (pp, node, flags);
2473 break;
2475 case RESULT_DECL:
2476 pp_string (pp, "<retval>");
2477 break;
2479 case COMPONENT_REF:
2480 op0 = TREE_OPERAND (node, 0);
2481 str = ".";
2482 if (op0
2483 && (TREE_CODE (op0) == INDIRECT_REF
2484 || (TREE_CODE (op0) == MEM_REF
2485 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
2486 && integer_zerop (TREE_OPERAND (op0, 1))
2487 /* Dump the types of INTEGER_CSTs explicitly, for we
2488 can't infer them and MEM_ATTR caching will share
2489 MEM_REFs with differently-typed op0s. */
2490 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
2491 /* Released SSA_NAMES have no TREE_TYPE. */
2492 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
2493 /* Same pointer types, but ignoring POINTER_TYPE vs.
2494 REFERENCE_TYPE. */
2495 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2496 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2497 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
2498 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
2499 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
2500 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
2501 /* Same value types ignoring qualifiers. */
2502 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
2503 == TYPE_MAIN_VARIANT
2504 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
2505 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
2507 op0 = TREE_OPERAND (op0, 0);
2508 str = "->";
2510 if (op_prio (op0) < op_prio (node))
2511 pp_left_paren (pp);
2512 dump_generic_node (pp, op0, spc, flags, false);
2513 if (op_prio (op0) < op_prio (node))
2514 pp_right_paren (pp);
2515 pp_string (pp, str);
2516 op1 = TREE_OPERAND (node, 1);
2517 dump_generic_node (pp, op1, spc, flags, false);
2518 if (DECL_P (op1)) /* Not always a decl in the C++ FE. */
2519 if (tree off = component_ref_field_offset (node))
2520 if (TREE_CODE (off) != INTEGER_CST)
2522 pp_string (pp, "{off: ");
2523 dump_generic_node (pp, off, spc, flags, false);
2524 pp_right_brace (pp);
2526 break;
2528 case BIT_FIELD_REF:
2529 if (flags & TDF_GIMPLE)
2531 pp_string (pp, "__BIT_FIELD_REF <");
2532 dump_generic_node (pp, TREE_TYPE (node),
2533 spc, flags | TDF_SLIM, false);
2534 if (TYPE_ALIGN (TREE_TYPE (node))
2535 != TYPE_ALIGN (TYPE_MAIN_VARIANT (TREE_TYPE (node))))
2537 pp_string (pp, ", ");
2538 pp_decimal_int (pp, TYPE_ALIGN (TREE_TYPE (node)));
2540 pp_greater (pp);
2541 pp_string (pp, " (");
2542 dump_generic_node (pp, TREE_OPERAND (node, 0), spc,
2543 flags | TDF_SLIM, false);
2544 pp_string (pp, ", ");
2545 dump_generic_node (pp, TREE_OPERAND (node, 1), spc,
2546 flags | TDF_SLIM, false);
2547 pp_string (pp, ", ");
2548 dump_generic_node (pp, TREE_OPERAND (node, 2), spc,
2549 flags | TDF_SLIM, false);
2550 pp_right_paren (pp);
2552 else
2554 pp_string (pp, "BIT_FIELD_REF <");
2555 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2556 pp_string (pp, ", ");
2557 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2558 pp_string (pp, ", ");
2559 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2560 pp_greater (pp);
2562 break;
2564 case BIT_INSERT_EXPR:
2565 pp_string (pp, "BIT_INSERT_EXPR <");
2566 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2567 pp_string (pp, ", ");
2568 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2569 pp_string (pp, ", ");
2570 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2571 pp_string (pp, " (");
2572 if (INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 1))))
2573 pp_decimal_int (pp,
2574 TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (node, 1))));
2575 else
2576 dump_generic_node (pp, TYPE_SIZE (TREE_TYPE (TREE_OPERAND (node, 1))),
2577 spc, flags, false);
2578 pp_string (pp, " bits)>");
2579 break;
2581 case ARRAY_REF:
2582 case ARRAY_RANGE_REF:
2583 op0 = TREE_OPERAND (node, 0);
2584 if (op_prio (op0) < op_prio (node))
2585 pp_left_paren (pp);
2586 dump_generic_node (pp, op0, spc, flags, false);
2587 if (op_prio (op0) < op_prio (node))
2588 pp_right_paren (pp);
2589 pp_left_bracket (pp);
2590 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2591 if (TREE_CODE (node) == ARRAY_RANGE_REF)
2592 pp_string (pp, " ...");
2593 pp_right_bracket (pp);
2595 op0 = array_ref_low_bound (node);
2596 op1 = array_ref_element_size (node);
2598 if (!integer_zerop (op0)
2599 || TREE_OPERAND (node, 2)
2600 || TREE_OPERAND (node, 3))
2602 pp_string (pp, "{lb: ");
2603 dump_generic_node (pp, op0, spc, flags, false);
2604 pp_string (pp, " sz: ");
2605 dump_generic_node (pp, op1, spc, flags, false);
2606 pp_right_brace (pp);
2608 break;
2610 case CONSTRUCTOR:
2612 unsigned HOST_WIDE_INT ix;
2613 tree field, val;
2614 bool is_struct_init = false;
2615 bool is_array_init = false;
2616 widest_int curidx;
2617 if (flags & TDF_GIMPLE)
2619 pp_string (pp, "_Literal (");
2620 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2621 pp_string (pp, ") ");
2623 pp_left_brace (pp);
2624 if (TREE_CLOBBER_P (node))
2626 pp_string (pp, "CLOBBER");
2627 if (CLOBBER_KIND (node) == CLOBBER_EOL)
2628 pp_string (pp, "(eol)");
2630 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
2631 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
2632 is_struct_init = true;
2633 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
2634 && TYPE_DOMAIN (TREE_TYPE (node))
2635 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
2636 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
2637 == INTEGER_CST)
2639 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
2640 is_array_init = true;
2641 curidx = wi::to_widest (minv);
2643 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
2645 if (field)
2647 if (is_struct_init)
2649 pp_dot (pp);
2650 dump_generic_node (pp, field, spc, flags, false);
2651 pp_equal (pp);
2653 else if (is_array_init
2654 && (TREE_CODE (field) != INTEGER_CST
2655 || curidx != wi::to_widest (field)))
2657 pp_left_bracket (pp);
2658 if (TREE_CODE (field) == RANGE_EXPR)
2660 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
2661 flags, false);
2662 pp_string (pp, " ... ");
2663 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
2664 flags, false);
2665 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
2666 curidx = wi::to_widest (TREE_OPERAND (field, 1));
2668 else
2669 dump_generic_node (pp, field, spc, flags, false);
2670 if (TREE_CODE (field) == INTEGER_CST)
2671 curidx = wi::to_widest (field);
2672 pp_string (pp, "]=");
2675 if (is_array_init)
2676 curidx += 1;
2677 if (val && TREE_CODE (val) == ADDR_EXPR)
2678 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
2679 val = TREE_OPERAND (val, 0);
2680 if (val && TREE_CODE (val) == FUNCTION_DECL)
2681 dump_decl_name (pp, val, flags);
2682 else
2683 dump_generic_node (pp, val, spc, flags, false);
2684 if (ix != CONSTRUCTOR_NELTS (node) - 1)
2686 pp_comma (pp);
2687 pp_space (pp);
2690 pp_right_brace (pp);
2692 break;
2694 case COMPOUND_EXPR:
2696 tree *tp;
2697 if (flags & TDF_SLIM)
2699 pp_string (pp, "<COMPOUND_EXPR>");
2700 break;
2703 dump_generic_node (pp, TREE_OPERAND (node, 0),
2704 spc, flags, !(flags & TDF_SLIM));
2705 if (flags & TDF_SLIM)
2706 newline_and_indent (pp, spc);
2707 else
2709 pp_comma (pp);
2710 pp_space (pp);
2713 for (tp = &TREE_OPERAND (node, 1);
2714 TREE_CODE (*tp) == COMPOUND_EXPR;
2715 tp = &TREE_OPERAND (*tp, 1))
2717 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
2718 spc, flags, !(flags & TDF_SLIM));
2719 if (flags & TDF_SLIM)
2720 newline_and_indent (pp, spc);
2721 else
2723 pp_comma (pp);
2724 pp_space (pp);
2728 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
2730 break;
2732 case STATEMENT_LIST:
2734 tree_stmt_iterator si;
2735 bool first = true;
2737 if (flags & TDF_SLIM)
2739 pp_string (pp, "<STATEMENT_LIST>");
2740 break;
2743 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
2745 if (!first)
2746 newline_and_indent (pp, spc);
2747 else
2748 first = false;
2749 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
2752 break;
2754 case MODIFY_EXPR:
2755 case INIT_EXPR:
2756 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
2757 false);
2758 pp_space (pp);
2759 pp_equal (pp);
2760 pp_space (pp);
2761 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
2762 false);
2763 break;
2765 case TARGET_EXPR:
2766 pp_string (pp, "TARGET_EXPR <");
2767 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
2768 pp_comma (pp);
2769 pp_space (pp);
2770 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
2771 pp_greater (pp);
2772 break;
2774 case DECL_EXPR:
2775 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
2776 is_stmt = false;
2777 break;
2779 case COND_EXPR:
2780 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
2782 pp_string (pp, "if (");
2783 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
2784 pp_right_paren (pp);
2785 /* The lowered cond_exprs should always be printed in full. */
2786 if (COND_EXPR_THEN (node)
2787 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
2788 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
2789 && COND_EXPR_ELSE (node)
2790 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
2791 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
2793 pp_space (pp);
2794 dump_generic_node (pp, COND_EXPR_THEN (node),
2795 0, flags, true);
2796 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2798 pp_string (pp, " else ");
2799 dump_generic_node (pp, COND_EXPR_ELSE (node),
2800 0, flags, true);
2803 else if (!(flags & TDF_SLIM))
2805 /* Output COND_EXPR_THEN. */
2806 if (COND_EXPR_THEN (node))
2808 newline_and_indent (pp, spc+2);
2809 pp_left_brace (pp);
2810 newline_and_indent (pp, spc+4);
2811 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
2812 flags, true);
2813 newline_and_indent (pp, spc+2);
2814 pp_right_brace (pp);
2817 /* Output COND_EXPR_ELSE. */
2818 if (COND_EXPR_ELSE (node)
2819 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
2821 newline_and_indent (pp, spc);
2822 pp_string (pp, "else");
2823 newline_and_indent (pp, spc+2);
2824 pp_left_brace (pp);
2825 newline_and_indent (pp, spc+4);
2826 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
2827 flags, true);
2828 newline_and_indent (pp, spc+2);
2829 pp_right_brace (pp);
2832 is_expr = false;
2834 else
2836 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2837 pp_space (pp);
2838 pp_question (pp);
2839 pp_space (pp);
2840 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2841 pp_space (pp);
2842 pp_colon (pp);
2843 pp_space (pp);
2844 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2846 break;
2848 case BIND_EXPR:
2849 pp_left_brace (pp);
2850 if (!(flags & TDF_SLIM))
2852 if (BIND_EXPR_VARS (node))
2854 pp_newline (pp);
2856 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
2858 print_declaration (pp, op0, spc+2, flags);
2859 pp_newline (pp);
2863 newline_and_indent (pp, spc+2);
2864 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
2865 newline_and_indent (pp, spc);
2866 pp_right_brace (pp);
2868 is_expr = false;
2869 break;
2871 case CALL_EXPR:
2872 if (CALL_EXPR_FN (node) != NULL_TREE)
2873 print_call_name (pp, CALL_EXPR_FN (node), flags);
2874 else
2876 pp_dot (pp);
2877 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
2880 /* Print parameters. */
2881 pp_space (pp);
2882 pp_left_paren (pp);
2884 tree arg;
2885 call_expr_arg_iterator iter;
2886 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
2888 dump_generic_node (pp, arg, spc, flags, false);
2889 if (more_call_expr_args_p (&iter))
2891 pp_comma (pp);
2892 pp_space (pp);
2896 if (CALL_EXPR_VA_ARG_PACK (node))
2898 if (call_expr_nargs (node) > 0)
2900 pp_comma (pp);
2901 pp_space (pp);
2903 pp_string (pp, "__builtin_va_arg_pack ()");
2905 pp_right_paren (pp);
2907 op1 = CALL_EXPR_STATIC_CHAIN (node);
2908 if (op1)
2910 pp_string (pp, " [static-chain: ");
2911 dump_generic_node (pp, op1, spc, flags, false);
2912 pp_right_bracket (pp);
2915 if (CALL_EXPR_RETURN_SLOT_OPT (node))
2916 pp_string (pp, " [return slot optimization]");
2917 if (CALL_EXPR_TAILCALL (node))
2918 pp_string (pp, " [tail call]");
2919 break;
2921 case WITH_CLEANUP_EXPR:
2922 NIY;
2923 break;
2925 case CLEANUP_POINT_EXPR:
2926 pp_string (pp, "<<cleanup_point ");
2927 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2928 pp_string (pp, ">>");
2929 break;
2931 case PLACEHOLDER_EXPR:
2932 pp_string (pp, "<PLACEHOLDER_EXPR ");
2933 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2934 pp_greater (pp);
2935 break;
2937 /* Binary arithmetic and logic expressions. */
2938 case WIDEN_SUM_EXPR:
2939 case WIDEN_MULT_EXPR:
2940 case MULT_EXPR:
2941 case MULT_HIGHPART_EXPR:
2942 case PLUS_EXPR:
2943 case POINTER_PLUS_EXPR:
2944 case POINTER_DIFF_EXPR:
2945 case MINUS_EXPR:
2946 case TRUNC_DIV_EXPR:
2947 case CEIL_DIV_EXPR:
2948 case FLOOR_DIV_EXPR:
2949 case ROUND_DIV_EXPR:
2950 case TRUNC_MOD_EXPR:
2951 case CEIL_MOD_EXPR:
2952 case FLOOR_MOD_EXPR:
2953 case ROUND_MOD_EXPR:
2954 case RDIV_EXPR:
2955 case EXACT_DIV_EXPR:
2956 case LSHIFT_EXPR:
2957 case RSHIFT_EXPR:
2958 case LROTATE_EXPR:
2959 case RROTATE_EXPR:
2960 case WIDEN_LSHIFT_EXPR:
2961 case BIT_IOR_EXPR:
2962 case BIT_XOR_EXPR:
2963 case BIT_AND_EXPR:
2964 case TRUTH_ANDIF_EXPR:
2965 case TRUTH_ORIF_EXPR:
2966 case TRUTH_AND_EXPR:
2967 case TRUTH_OR_EXPR:
2968 case TRUTH_XOR_EXPR:
2969 case LT_EXPR:
2970 case LE_EXPR:
2971 case GT_EXPR:
2972 case GE_EXPR:
2973 case EQ_EXPR:
2974 case NE_EXPR:
2975 case UNLT_EXPR:
2976 case UNLE_EXPR:
2977 case UNGT_EXPR:
2978 case UNGE_EXPR:
2979 case UNEQ_EXPR:
2980 case LTGT_EXPR:
2981 case ORDERED_EXPR:
2982 case UNORDERED_EXPR:
2984 const char *op = op_symbol (node);
2985 op0 = TREE_OPERAND (node, 0);
2986 op1 = TREE_OPERAND (node, 1);
2988 /* When the operands are expressions with less priority,
2989 keep semantics of the tree representation. */
2990 if (op_prio (op0) <= op_prio (node))
2992 pp_left_paren (pp);
2993 dump_generic_node (pp, op0, spc, flags, false);
2994 pp_right_paren (pp);
2996 else
2997 dump_generic_node (pp, op0, spc, flags, false);
2999 pp_space (pp);
3000 pp_string (pp, op);
3001 pp_space (pp);
3003 /* When the operands are expressions with less priority,
3004 keep semantics of the tree representation. */
3005 if (op_prio (op1) <= op_prio (node))
3007 pp_left_paren (pp);
3008 dump_generic_node (pp, op1, spc, flags, false);
3009 pp_right_paren (pp);
3011 else
3012 dump_generic_node (pp, op1, spc, flags, false);
3014 break;
3016 /* Unary arithmetic and logic expressions. */
3017 case ADDR_EXPR:
3018 if (flags & TDF_GIMPLE_VAL)
3020 pp_string (pp, "_Literal (");
3021 dump_generic_node (pp, TREE_TYPE (node), spc,
3022 flags & ~TDF_GIMPLE_VAL, false);
3023 pp_character (pp, ')');
3025 /* Fallthru. */
3026 case NEGATE_EXPR:
3027 case BIT_NOT_EXPR:
3028 case TRUTH_NOT_EXPR:
3029 case PREDECREMENT_EXPR:
3030 case PREINCREMENT_EXPR:
3031 case INDIRECT_REF:
3032 if (!(flags & TDF_GIMPLE)
3033 && TREE_CODE (node) == ADDR_EXPR
3034 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
3035 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
3036 /* Do not output '&' for strings and function pointers when not
3037 dumping GIMPLE FE syntax. */
3039 else
3040 pp_string (pp, op_symbol (node));
3042 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
3044 pp_left_paren (pp);
3045 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3046 pp_right_paren (pp);
3048 else
3049 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3050 break;
3052 case POSTDECREMENT_EXPR:
3053 case POSTINCREMENT_EXPR:
3054 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
3056 pp_left_paren (pp);
3057 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3058 pp_right_paren (pp);
3060 else
3061 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3062 pp_string (pp, op_symbol (node));
3063 break;
3065 case MIN_EXPR:
3066 pp_string (pp, "MIN_EXPR <");
3067 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3068 pp_string (pp, ", ");
3069 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3070 pp_greater (pp);
3071 break;
3073 case MAX_EXPR:
3074 pp_string (pp, "MAX_EXPR <");
3075 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3076 pp_string (pp, ", ");
3077 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3078 pp_greater (pp);
3079 break;
3081 case ABS_EXPR:
3082 pp_string (pp, "ABS_EXPR <");
3083 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3084 pp_greater (pp);
3085 break;
3087 case ABSU_EXPR:
3088 pp_string (pp, "ABSU_EXPR <");
3089 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3090 pp_greater (pp);
3091 break;
3093 case RANGE_EXPR:
3094 NIY;
3095 break;
3097 case ADDR_SPACE_CONVERT_EXPR:
3098 case FIXED_CONVERT_EXPR:
3099 case FIX_TRUNC_EXPR:
3100 case FLOAT_EXPR:
3101 CASE_CONVERT:
3102 type = TREE_TYPE (node);
3103 op0 = TREE_OPERAND (node, 0);
3104 if (type != TREE_TYPE (op0))
3106 pp_left_paren (pp);
3107 dump_generic_node (pp, type, spc, flags, false);
3108 pp_string (pp, ") ");
3110 if (op_prio (op0) < op_prio (node))
3111 pp_left_paren (pp);
3112 dump_generic_node (pp, op0, spc, flags, false);
3113 if (op_prio (op0) < op_prio (node))
3114 pp_right_paren (pp);
3115 break;
3117 case VIEW_CONVERT_EXPR:
3118 if (flags & TDF_GIMPLE)
3119 pp_string (pp, "__VIEW_CONVERT <");
3120 else
3121 pp_string (pp, "VIEW_CONVERT_EXPR<");
3122 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
3123 pp_string (pp, ">(");
3124 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3125 pp_right_paren (pp);
3126 break;
3128 case PAREN_EXPR:
3129 pp_string (pp, "((");
3130 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3131 pp_string (pp, "))");
3132 break;
3134 case NON_LVALUE_EXPR:
3135 pp_string (pp, "NON_LVALUE_EXPR <");
3136 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3137 pp_greater (pp);
3138 break;
3140 case SAVE_EXPR:
3141 pp_string (pp, "SAVE_EXPR <");
3142 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3143 pp_greater (pp);
3144 break;
3146 case COMPLEX_EXPR:
3147 pp_string (pp, "COMPLEX_EXPR <");
3148 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3149 pp_string (pp, ", ");
3150 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3151 pp_greater (pp);
3152 break;
3154 case CONJ_EXPR:
3155 pp_string (pp, "CONJ_EXPR <");
3156 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3157 pp_greater (pp);
3158 break;
3160 case REALPART_EXPR:
3161 if (flags & TDF_GIMPLE)
3163 pp_string (pp, "__real ");
3164 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3166 else
3168 pp_string (pp, "REALPART_EXPR <");
3169 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3170 pp_greater (pp);
3172 break;
3174 case IMAGPART_EXPR:
3175 if (flags & TDF_GIMPLE)
3177 pp_string (pp, "__imag ");
3178 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3180 else
3182 pp_string (pp, "IMAGPART_EXPR <");
3183 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3184 pp_greater (pp);
3186 break;
3188 case VA_ARG_EXPR:
3189 pp_string (pp, "VA_ARG_EXPR <");
3190 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3191 pp_greater (pp);
3192 break;
3194 case TRY_FINALLY_EXPR:
3195 case TRY_CATCH_EXPR:
3196 pp_string (pp, "try");
3197 newline_and_indent (pp, spc+2);
3198 pp_left_brace (pp);
3199 newline_and_indent (pp, spc+4);
3200 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
3201 newline_and_indent (pp, spc+2);
3202 pp_right_brace (pp);
3203 newline_and_indent (pp, spc);
3204 if (TREE_CODE (node) == TRY_CATCH_EXPR)
3206 node = TREE_OPERAND (node, 1);
3207 pp_string (pp, "catch");
3209 else
3211 gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR);
3212 node = TREE_OPERAND (node, 1);
3213 pp_string (pp, "finally");
3214 if (TREE_CODE (node) == EH_ELSE_EXPR)
3216 newline_and_indent (pp, spc+2);
3217 pp_left_brace (pp);
3218 newline_and_indent (pp, spc+4);
3219 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4,
3220 flags, true);
3221 newline_and_indent (pp, spc+2);
3222 pp_right_brace (pp);
3223 newline_and_indent (pp, spc);
3224 node = TREE_OPERAND (node, 1);
3225 pp_string (pp, "else");
3228 newline_and_indent (pp, spc+2);
3229 pp_left_brace (pp);
3230 newline_and_indent (pp, spc+4);
3231 dump_generic_node (pp, node, spc+4, flags, true);
3232 newline_and_indent (pp, spc+2);
3233 pp_right_brace (pp);
3234 is_expr = false;
3235 break;
3237 case CATCH_EXPR:
3238 pp_string (pp, "catch (");
3239 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
3240 pp_right_paren (pp);
3241 newline_and_indent (pp, spc+2);
3242 pp_left_brace (pp);
3243 newline_and_indent (pp, spc+4);
3244 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
3245 newline_and_indent (pp, spc+2);
3246 pp_right_brace (pp);
3247 is_expr = false;
3248 break;
3250 case EH_FILTER_EXPR:
3251 pp_string (pp, "<<<eh_filter (");
3252 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
3253 pp_string (pp, ")>>>");
3254 newline_and_indent (pp, spc+2);
3255 pp_left_brace (pp);
3256 newline_and_indent (pp, spc+4);
3257 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
3258 newline_and_indent (pp, spc+2);
3259 pp_right_brace (pp);
3260 is_expr = false;
3261 break;
3263 case LABEL_EXPR:
3264 op0 = TREE_OPERAND (node, 0);
3265 /* If this is for break or continue, don't bother printing it. */
3266 if (DECL_NAME (op0))
3268 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3269 if (strcmp (name, "break") == 0
3270 || strcmp (name, "continue") == 0)
3271 break;
3273 dump_generic_node (pp, op0, spc, flags, false);
3274 pp_colon (pp);
3275 if (DECL_NONLOCAL (op0))
3276 pp_string (pp, " [non-local]");
3277 break;
3279 case LOOP_EXPR:
3280 pp_string (pp, "while (1)");
3281 if (!(flags & TDF_SLIM))
3283 newline_and_indent (pp, spc+2);
3284 pp_left_brace (pp);
3285 newline_and_indent (pp, spc+4);
3286 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
3287 newline_and_indent (pp, spc+2);
3288 pp_right_brace (pp);
3290 is_expr = false;
3291 break;
3293 case PREDICT_EXPR:
3294 pp_string (pp, "// predicted ");
3295 if (PREDICT_EXPR_OUTCOME (node))
3296 pp_string (pp, "likely by ");
3297 else
3298 pp_string (pp, "unlikely by ");
3299 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
3300 pp_string (pp, " predictor.");
3301 break;
3303 case ANNOTATE_EXPR:
3304 pp_string (pp, "ANNOTATE_EXPR <");
3305 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3306 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
3308 case annot_expr_ivdep_kind:
3309 pp_string (pp, ", ivdep");
3310 break;
3311 case annot_expr_unroll_kind:
3313 pp_string (pp, ", unroll ");
3314 pp_decimal_int (pp,
3315 (int) TREE_INT_CST_LOW (TREE_OPERAND (node, 2)));
3316 break;
3318 case annot_expr_no_vector_kind:
3319 pp_string (pp, ", no-vector");
3320 break;
3321 case annot_expr_vector_kind:
3322 pp_string (pp, ", vector");
3323 break;
3324 case annot_expr_parallel_kind:
3325 pp_string (pp, ", parallel");
3326 break;
3327 default:
3328 gcc_unreachable ();
3330 pp_greater (pp);
3331 break;
3333 case RETURN_EXPR:
3334 pp_string (pp, "return");
3335 op0 = TREE_OPERAND (node, 0);
3336 if (op0)
3338 pp_space (pp);
3339 if (TREE_CODE (op0) == MODIFY_EXPR)
3340 dump_generic_node (pp, TREE_OPERAND (op0, 1),
3341 spc, flags, false);
3342 else
3343 dump_generic_node (pp, op0, spc, flags, false);
3345 break;
3347 case EXIT_EXPR:
3348 pp_string (pp, "if (");
3349 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3350 pp_string (pp, ") break");
3351 break;
3353 case SWITCH_EXPR:
3354 pp_string (pp, "switch (");
3355 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
3356 pp_right_paren (pp);
3357 if (!(flags & TDF_SLIM))
3359 newline_and_indent (pp, spc+2);
3360 pp_left_brace (pp);
3361 if (SWITCH_BODY (node))
3363 newline_and_indent (pp, spc+4);
3364 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
3365 true);
3367 newline_and_indent (pp, spc+2);
3368 pp_right_brace (pp);
3370 is_expr = false;
3371 break;
3373 case GOTO_EXPR:
3374 op0 = GOTO_DESTINATION (node);
3375 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
3377 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
3378 if (strcmp (name, "break") == 0
3379 || strcmp (name, "continue") == 0)
3381 pp_string (pp, name);
3382 break;
3385 pp_string (pp, "goto ");
3386 dump_generic_node (pp, op0, spc, flags, false);
3387 break;
3389 case ASM_EXPR:
3390 pp_string (pp, "__asm__");
3391 if (ASM_VOLATILE_P (node))
3392 pp_string (pp, " __volatile__");
3393 pp_left_paren (pp);
3394 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
3395 pp_colon (pp);
3396 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
3397 pp_colon (pp);
3398 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
3399 if (ASM_CLOBBERS (node))
3401 pp_colon (pp);
3402 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
3404 pp_right_paren (pp);
3405 break;
3407 case CASE_LABEL_EXPR:
3408 if (CASE_LOW (node) && CASE_HIGH (node))
3410 pp_string (pp, "case ");
3411 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3412 pp_string (pp, " ... ");
3413 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
3415 else if (CASE_LOW (node))
3417 pp_string (pp, "case ");
3418 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
3420 else
3421 pp_string (pp, "default");
3422 pp_colon (pp);
3423 break;
3425 case OBJ_TYPE_REF:
3426 pp_string (pp, "OBJ_TYPE_REF(");
3427 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
3428 pp_semicolon (pp);
3429 /* We omit the class type for -fcompare-debug because we may
3430 drop TYPE_BINFO early depending on debug info, and then
3431 virtual_method_call_p would return false, whereas when
3432 TYPE_BINFO is preserved it may still return true and then
3433 we'd print the class type. Compare tree and rtl dumps for
3434 libstdc++-prettyprinters/shared_ptr.cc with and without -g,
3435 for example, at occurrences of OBJ_TYPE_REF. */
3436 if (!(flags & (TDF_SLIM | TDF_COMPARE_DEBUG))
3437 && virtual_method_call_p (node, true))
3439 pp_string (pp, "(");
3440 dump_generic_node (pp, obj_type_ref_class (node, true),
3441 spc, flags, false);
3442 pp_string (pp, ")");
3444 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
3445 pp_arrow (pp);
3446 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
3447 pp_right_paren (pp);
3448 break;
3450 case SSA_NAME:
3451 if (SSA_NAME_IDENTIFIER (node))
3453 if ((flags & TDF_NOUID)
3454 && SSA_NAME_VAR (node)
3455 && DECL_NAMELESS (SSA_NAME_VAR (node)))
3456 dump_fancy_name (pp, SSA_NAME_IDENTIFIER (node));
3457 else if (! (flags & TDF_GIMPLE)
3458 || SSA_NAME_VAR (node))
3459 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
3460 spc, flags, false);
3462 pp_underscore (pp);
3463 pp_decimal_int (pp, SSA_NAME_VERSION (node));
3464 if (SSA_NAME_IS_DEFAULT_DEF (node))
3465 pp_string (pp, "(D)");
3466 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
3467 pp_string (pp, "(ab)");
3468 break;
3470 case WITH_SIZE_EXPR:
3471 pp_string (pp, "WITH_SIZE_EXPR <");
3472 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3473 pp_string (pp, ", ");
3474 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3475 pp_greater (pp);
3476 break;
3478 case SCEV_KNOWN:
3479 pp_string (pp, "scev_known");
3480 break;
3482 case SCEV_NOT_KNOWN:
3483 pp_string (pp, "scev_not_known");
3484 break;
3486 case POLYNOMIAL_CHREC:
3487 pp_left_brace (pp);
3488 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
3489 pp_string (pp, ", +, ");
3490 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
3491 pp_string (pp, "}_");
3492 pp_scalar (pp, "%u", CHREC_VARIABLE (node));
3493 is_stmt = false;
3494 break;
3496 case REALIGN_LOAD_EXPR:
3497 pp_string (pp, "REALIGN_LOAD <");
3498 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3499 pp_string (pp, ", ");
3500 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3501 pp_string (pp, ", ");
3502 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3503 pp_greater (pp);
3504 break;
3506 case VEC_COND_EXPR:
3507 pp_string (pp, " VEC_COND_EXPR < ");
3508 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3509 pp_string (pp, " , ");
3510 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3511 pp_string (pp, " , ");
3512 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3513 pp_string (pp, " > ");
3514 break;
3516 case VEC_PERM_EXPR:
3517 pp_string (pp, " VEC_PERM_EXPR < ");
3518 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3519 pp_string (pp, " , ");
3520 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3521 pp_string (pp, " , ");
3522 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3523 pp_string (pp, " > ");
3524 break;
3526 case DOT_PROD_EXPR:
3527 pp_string (pp, " DOT_PROD_EXPR < ");
3528 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3529 pp_string (pp, ", ");
3530 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3531 pp_string (pp, ", ");
3532 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3533 pp_string (pp, " > ");
3534 break;
3536 case WIDEN_MULT_PLUS_EXPR:
3537 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
3538 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3539 pp_string (pp, ", ");
3540 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3541 pp_string (pp, ", ");
3542 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3543 pp_string (pp, " > ");
3544 break;
3546 case WIDEN_MULT_MINUS_EXPR:
3547 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
3548 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3549 pp_string (pp, ", ");
3550 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3551 pp_string (pp, ", ");
3552 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
3553 pp_string (pp, " > ");
3554 break;
3556 case OACC_PARALLEL:
3557 pp_string (pp, "#pragma acc parallel");
3558 goto dump_omp_clauses_body;
3560 case OACC_KERNELS:
3561 pp_string (pp, "#pragma acc kernels");
3562 goto dump_omp_clauses_body;
3564 case OACC_SERIAL:
3565 pp_string (pp, "#pragma acc serial");
3566 goto dump_omp_clauses_body;
3568 case OACC_DATA:
3569 pp_string (pp, "#pragma acc data");
3570 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
3571 goto dump_omp_body;
3573 case OACC_HOST_DATA:
3574 pp_string (pp, "#pragma acc host_data");
3575 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
3576 goto dump_omp_body;
3578 case OACC_DECLARE:
3579 pp_string (pp, "#pragma acc declare");
3580 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
3581 break;
3583 case OACC_UPDATE:
3584 pp_string (pp, "#pragma acc update");
3585 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
3586 break;
3588 case OACC_ENTER_DATA:
3589 pp_string (pp, "#pragma acc enter data");
3590 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
3591 break;
3593 case OACC_EXIT_DATA:
3594 pp_string (pp, "#pragma acc exit data");
3595 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
3596 break;
3598 case OACC_CACHE:
3599 pp_string (pp, "#pragma acc cache");
3600 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
3601 break;
3603 case OMP_PARALLEL:
3604 pp_string (pp, "#pragma omp parallel");
3605 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
3606 goto dump_omp_body;
3608 dump_omp_clauses_body:
3609 dump_omp_clauses (pp, OMP_CLAUSES (node), spc, flags);
3610 goto dump_omp_body;
3612 dump_omp_body:
3613 if (!(flags & TDF_SLIM) && OMP_BODY (node))
3615 newline_and_indent (pp, spc + 2);
3616 pp_left_brace (pp);
3617 newline_and_indent (pp, spc + 4);
3618 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
3619 newline_and_indent (pp, spc + 2);
3620 pp_right_brace (pp);
3622 is_expr = false;
3623 break;
3625 case OMP_TASK:
3626 pp_string (pp, OMP_TASK_BODY (node) ? "#pragma omp task"
3627 : "#pragma omp taskwait");
3628 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
3629 goto dump_omp_body;
3631 case OMP_FOR:
3632 pp_string (pp, "#pragma omp for");
3633 goto dump_omp_loop;
3635 case OMP_SIMD:
3636 pp_string (pp, "#pragma omp simd");
3637 goto dump_omp_loop;
3639 case OMP_DISTRIBUTE:
3640 pp_string (pp, "#pragma omp distribute");
3641 goto dump_omp_loop;
3643 case OMP_TASKLOOP:
3644 pp_string (pp, "#pragma omp taskloop");
3645 goto dump_omp_loop;
3647 case OMP_LOOP:
3648 pp_string (pp, "#pragma omp loop");
3649 goto dump_omp_loop;
3651 case OACC_LOOP:
3652 pp_string (pp, "#pragma acc loop");
3653 goto dump_omp_loop;
3655 case OMP_TEAMS:
3656 pp_string (pp, "#pragma omp teams");
3657 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
3658 goto dump_omp_body;
3660 case OMP_TARGET_DATA:
3661 pp_string (pp, "#pragma omp target data");
3662 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
3663 goto dump_omp_body;
3665 case OMP_TARGET_ENTER_DATA:
3666 pp_string (pp, "#pragma omp target enter data");
3667 dump_omp_clauses (pp, OMP_TARGET_ENTER_DATA_CLAUSES (node), spc, flags);
3668 is_expr = false;
3669 break;
3671 case OMP_TARGET_EXIT_DATA:
3672 pp_string (pp, "#pragma omp target exit data");
3673 dump_omp_clauses (pp, OMP_TARGET_EXIT_DATA_CLAUSES (node), spc, flags);
3674 is_expr = false;
3675 break;
3677 case OMP_TARGET:
3678 pp_string (pp, "#pragma omp target");
3679 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
3680 goto dump_omp_body;
3682 case OMP_TARGET_UPDATE:
3683 pp_string (pp, "#pragma omp target update");
3684 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
3685 is_expr = false;
3686 break;
3688 dump_omp_loop:
3689 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
3690 if (!(flags & TDF_SLIM))
3692 int i;
3694 if (OMP_FOR_PRE_BODY (node))
3696 newline_and_indent (pp, spc + 2);
3697 pp_left_brace (pp);
3698 spc += 4;
3699 newline_and_indent (pp, spc);
3700 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
3701 spc, flags, false);
3703 if (OMP_FOR_INIT (node))
3705 spc -= 2;
3706 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
3708 spc += 2;
3709 newline_and_indent (pp, spc);
3710 pp_string (pp, "for (");
3711 tree init = TREE_VEC_ELT (OMP_FOR_INIT (node), i);
3712 if (TREE_CODE (init) != MODIFY_EXPR
3713 || TREE_CODE (TREE_OPERAND (init, 1)) != TREE_VEC)
3714 dump_generic_node (pp, init, spc, flags, false);
3715 else
3717 dump_generic_node (pp, TREE_OPERAND (init, 0),
3718 spc, flags, false);
3719 pp_string (pp, " = ");
3720 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (init, 1),
3721 spc, flags);
3723 pp_string (pp, "; ");
3724 tree cond = TREE_VEC_ELT (OMP_FOR_COND (node), i);
3725 if (!COMPARISON_CLASS_P (cond)
3726 || TREE_CODE (TREE_OPERAND (cond, 1)) != TREE_VEC)
3727 dump_generic_node (pp, cond, spc, flags, false);
3728 else
3730 dump_generic_node (pp, TREE_OPERAND (cond, 0),
3731 spc, flags, false);
3732 const char *op = op_symbol (cond);
3733 pp_space (pp);
3734 pp_string (pp, op);
3735 pp_space (pp);
3736 dump_omp_loop_non_rect_expr (pp, TREE_OPERAND (cond, 1),
3737 spc, flags);
3739 pp_string (pp, "; ");
3740 dump_generic_node (pp,
3741 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
3742 spc, flags, false);
3743 pp_right_paren (pp);
3746 if (OMP_FOR_BODY (node))
3748 newline_and_indent (pp, spc + 2);
3749 pp_left_brace (pp);
3750 newline_and_indent (pp, spc + 4);
3751 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
3752 false);
3753 newline_and_indent (pp, spc + 2);
3754 pp_right_brace (pp);
3756 if (OMP_FOR_INIT (node))
3757 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
3758 if (OMP_FOR_PRE_BODY (node))
3760 spc -= 4;
3761 newline_and_indent (pp, spc + 2);
3762 pp_right_brace (pp);
3765 is_expr = false;
3766 break;
3768 case OMP_SECTIONS:
3769 pp_string (pp, "#pragma omp sections");
3770 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
3771 goto dump_omp_body;
3773 case OMP_SECTION:
3774 pp_string (pp, "#pragma omp section");
3775 goto dump_omp_body;
3777 case OMP_STRUCTURED_BLOCK:
3778 pp_string (pp, "#pragma omp __structured_block");
3779 goto dump_omp_body;
3781 case OMP_SCAN:
3782 if (OMP_SCAN_CLAUSES (node))
3784 pp_string (pp, "#pragma omp scan");
3785 dump_omp_clauses (pp, OMP_SCAN_CLAUSES (node), spc, flags);
3787 goto dump_omp_body;
3789 case OMP_MASTER:
3790 pp_string (pp, "#pragma omp master");
3791 goto dump_omp_body;
3793 case OMP_MASKED:
3794 pp_string (pp, "#pragma omp masked");
3795 dump_omp_clauses (pp, OMP_MASKED_CLAUSES (node), spc, flags);
3796 goto dump_omp_body;
3798 case OMP_TASKGROUP:
3799 pp_string (pp, "#pragma omp taskgroup");
3800 dump_omp_clauses (pp, OMP_TASKGROUP_CLAUSES (node), spc, flags);
3801 goto dump_omp_body;
3803 case OMP_ORDERED:
3804 pp_string (pp, "#pragma omp ordered");
3805 dump_omp_clauses (pp, OMP_ORDERED_CLAUSES (node), spc, flags);
3806 goto dump_omp_body;
3808 case OMP_CRITICAL:
3809 pp_string (pp, "#pragma omp critical");
3810 if (OMP_CRITICAL_NAME (node))
3812 pp_space (pp);
3813 pp_left_paren (pp);
3814 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
3815 flags, false);
3816 pp_right_paren (pp);
3818 dump_omp_clauses (pp, OMP_CRITICAL_CLAUSES (node), spc, flags);
3819 goto dump_omp_body;
3821 case OMP_ATOMIC:
3822 pp_string (pp, "#pragma omp atomic");
3823 if (OMP_ATOMIC_WEAK (node))
3824 pp_string (pp, " weak");
3825 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3826 newline_and_indent (pp, spc + 2);
3827 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3828 pp_space (pp);
3829 pp_equal (pp);
3830 pp_space (pp);
3831 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3832 break;
3834 case OMP_ATOMIC_READ:
3835 pp_string (pp, "#pragma omp atomic read");
3836 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3837 newline_and_indent (pp, spc + 2);
3838 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3839 pp_space (pp);
3840 break;
3842 case OMP_ATOMIC_CAPTURE_OLD:
3843 case OMP_ATOMIC_CAPTURE_NEW:
3844 pp_string (pp, "#pragma omp atomic capture");
3845 if (OMP_ATOMIC_WEAK (node))
3846 pp_string (pp, " weak");
3847 dump_omp_atomic_memory_order (pp, OMP_ATOMIC_MEMORY_ORDER (node));
3848 newline_and_indent (pp, spc + 2);
3849 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3850 pp_space (pp);
3851 pp_equal (pp);
3852 pp_space (pp);
3853 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3854 break;
3856 case OMP_SINGLE:
3857 pp_string (pp, "#pragma omp single");
3858 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
3859 goto dump_omp_body;
3861 case OMP_SCOPE:
3862 pp_string (pp, "#pragma omp scope");
3863 dump_omp_clauses (pp, OMP_SCOPE_CLAUSES (node), spc, flags);
3864 goto dump_omp_body;
3866 case OMP_CLAUSE:
3867 /* If we come here, we're dumping something that's not an OMP construct,
3868 for example, OMP clauses attached to a function's '__attribute__'.
3869 Dump the whole OMP clause chain. */
3870 dump_omp_clauses (pp, node, spc, flags, false);
3871 is_expr = false;
3872 break;
3874 case TRANSACTION_EXPR:
3875 if (TRANSACTION_EXPR_OUTER (node))
3876 pp_string (pp, "__transaction_atomic [[outer]]");
3877 else if (TRANSACTION_EXPR_RELAXED (node))
3878 pp_string (pp, "__transaction_relaxed");
3879 else
3880 pp_string (pp, "__transaction_atomic");
3881 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
3883 newline_and_indent (pp, spc);
3884 pp_left_brace (pp);
3885 newline_and_indent (pp, spc + 2);
3886 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
3887 spc + 2, flags, false);
3888 newline_and_indent (pp, spc);
3889 pp_right_brace (pp);
3891 is_expr = false;
3892 break;
3894 case VEC_SERIES_EXPR:
3895 case VEC_WIDEN_MULT_HI_EXPR:
3896 case VEC_WIDEN_MULT_LO_EXPR:
3897 case VEC_WIDEN_MULT_EVEN_EXPR:
3898 case VEC_WIDEN_MULT_ODD_EXPR:
3899 case VEC_WIDEN_LSHIFT_HI_EXPR:
3900 case VEC_WIDEN_LSHIFT_LO_EXPR:
3901 pp_space (pp);
3902 for (str = get_tree_code_name (code); *str; str++)
3903 pp_character (pp, TOUPPER (*str));
3904 pp_string (pp, " < ");
3905 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3906 pp_string (pp, ", ");
3907 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3908 pp_string (pp, " > ");
3909 break;
3911 case VEC_DUPLICATE_EXPR:
3912 pp_space (pp);
3913 for (str = get_tree_code_name (code); *str; str++)
3914 pp_character (pp, TOUPPER (*str));
3915 pp_string (pp, " < ");
3916 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3917 pp_string (pp, " > ");
3918 break;
3920 case VEC_UNPACK_HI_EXPR:
3921 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
3922 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3923 pp_string (pp, " > ");
3924 break;
3926 case VEC_UNPACK_LO_EXPR:
3927 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
3928 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3929 pp_string (pp, " > ");
3930 break;
3932 case VEC_UNPACK_FLOAT_HI_EXPR:
3933 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
3934 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3935 pp_string (pp, " > ");
3936 break;
3938 case VEC_UNPACK_FLOAT_LO_EXPR:
3939 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
3940 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3941 pp_string (pp, " > ");
3942 break;
3944 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
3945 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_HI_EXPR < ");
3946 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3947 pp_string (pp, " > ");
3948 break;
3950 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
3951 pp_string (pp, " VEC_UNPACK_FIX_TRUNC_LO_EXPR < ");
3952 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3953 pp_string (pp, " > ");
3954 break;
3956 case VEC_PACK_TRUNC_EXPR:
3957 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
3958 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3959 pp_string (pp, ", ");
3960 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3961 pp_string (pp, " > ");
3962 break;
3964 case VEC_PACK_SAT_EXPR:
3965 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
3966 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3967 pp_string (pp, ", ");
3968 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3969 pp_string (pp, " > ");
3970 break;
3972 case VEC_PACK_FIX_TRUNC_EXPR:
3973 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
3974 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3975 pp_string (pp, ", ");
3976 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3977 pp_string (pp, " > ");
3978 break;
3980 case VEC_PACK_FLOAT_EXPR:
3981 pp_string (pp, " VEC_PACK_FLOAT_EXPR < ");
3982 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
3983 pp_string (pp, ", ");
3984 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
3985 pp_string (pp, " > ");
3986 break;
3988 case BLOCK:
3989 dump_block_node (pp, node, spc, flags);
3990 break;
3992 case DEBUG_BEGIN_STMT:
3993 pp_string (pp, "# DEBUG BEGIN STMT");
3994 break;
3996 default:
3997 NIY;
4000 if (is_stmt && is_expr)
4001 pp_semicolon (pp);
4003 return spc;
4006 /* Print the declaration of a variable. */
4008 void
4009 print_declaration (pretty_printer *pp, tree t, int spc, dump_flags_t flags)
4011 INDENT (spc);
4013 if (TREE_CODE(t) == NAMELIST_DECL)
4015 pp_string(pp, "namelist ");
4016 dump_decl_name (pp, t, flags);
4017 pp_semicolon (pp);
4018 return;
4021 if (TREE_CODE (t) == TYPE_DECL)
4022 pp_string (pp, "typedef ");
4024 if (HAS_RTL_P (t) && DECL_REGISTER (t))
4025 pp_string (pp, "register ");
4027 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
4028 pp_string (pp, "extern ");
4029 else if (TREE_STATIC (t))
4030 pp_string (pp, "static ");
4032 /* Print the type and name. */
4033 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
4035 tree tmp;
4037 /* Print array's type. */
4038 tmp = TREE_TYPE (t);
4039 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
4040 tmp = TREE_TYPE (tmp);
4041 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
4043 /* Print variable's name. */
4044 pp_space (pp);
4045 dump_generic_node (pp, t, spc, flags, false);
4047 /* Print the dimensions. */
4048 tmp = TREE_TYPE (t);
4049 while (TREE_CODE (tmp) == ARRAY_TYPE)
4051 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
4052 tmp = TREE_TYPE (tmp);
4055 else if (TREE_CODE (t) == FUNCTION_DECL)
4057 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
4058 pp_space (pp);
4059 dump_decl_name (pp, t, flags);
4060 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
4062 else
4064 /* Print type declaration. */
4065 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
4067 /* Print variable's name. */
4068 pp_space (pp);
4069 dump_generic_node (pp, t, spc, flags, false);
4072 if (VAR_P (t) && DECL_HARD_REGISTER (t))
4074 pp_string (pp, " __asm__ ");
4075 pp_left_paren (pp);
4076 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
4077 pp_right_paren (pp);
4080 /* The initial value of a function serves to determine whether the function
4081 is declared or defined. So the following does not apply to function
4082 nodes. */
4083 if (TREE_CODE (t) != FUNCTION_DECL)
4085 /* Print the initial value. */
4086 if (DECL_INITIAL (t))
4088 pp_space (pp);
4089 pp_equal (pp);
4090 pp_space (pp);
4091 if (!(flags & TDF_SLIM))
4092 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
4093 else
4094 pp_string (pp, "<<< omitted >>>");
4098 if (VAR_P (t) && DECL_HAS_VALUE_EXPR_P (t))
4100 pp_string (pp, " [value-expr: ");
4101 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
4102 pp_right_bracket (pp);
4105 pp_semicolon (pp);
4109 /* Prints a structure: name, fields, and methods.
4110 FIXME: Still incomplete. */
4112 static void
4113 print_struct_decl (pretty_printer *pp, const_tree node, int spc,
4114 dump_flags_t flags)
4116 /* Print the name of the structure. */
4117 if (TYPE_NAME (node))
4119 INDENT (spc);
4120 if (TREE_CODE (node) == RECORD_TYPE)
4121 pp_string (pp, "struct ");
4122 else if ((TREE_CODE (node) == UNION_TYPE
4123 || TREE_CODE (node) == QUAL_UNION_TYPE))
4124 pp_string (pp, "union ");
4126 dump_generic_node (pp, TYPE_NAME (node), spc, TDF_NONE, false);
4129 /* Print the contents of the structure. */
4130 pp_newline (pp);
4131 INDENT (spc);
4132 pp_left_brace (pp);
4133 pp_newline (pp);
4135 /* Print the fields of the structure. */
4137 tree tmp;
4138 tmp = TYPE_FIELDS (node);
4139 while (tmp)
4141 /* Avoid to print recursively the structure. */
4142 /* FIXME : Not implemented correctly...,
4143 what about the case when we have a cycle in the contain graph? ...
4144 Maybe this could be solved by looking at the scope in which the
4145 structure was declared. */
4146 if (TREE_TYPE (tmp) != node
4147 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
4148 || TREE_TYPE (TREE_TYPE (tmp)) != node))
4150 print_declaration (pp, tmp, spc+2, flags);
4151 pp_newline (pp);
4153 tmp = DECL_CHAIN (tmp);
4156 INDENT (spc);
4157 pp_right_brace (pp);
4160 /* Return the priority of the operator CODE.
4162 From lowest to highest precedence with either left-to-right (L-R)
4163 or right-to-left (R-L) associativity]:
4165 1 [L-R] ,
4166 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
4167 3 [R-L] ?:
4168 4 [L-R] ||
4169 5 [L-R] &&
4170 6 [L-R] |
4171 7 [L-R] ^
4172 8 [L-R] &
4173 9 [L-R] == !=
4174 10 [L-R] < <= > >=
4175 11 [L-R] << >>
4176 12 [L-R] + -
4177 13 [L-R] * / %
4178 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
4179 15 [L-R] fn() [] -> .
4181 unary +, - and * have higher precedence than the corresponding binary
4182 operators. */
4185 op_code_prio (enum tree_code code)
4187 switch (code)
4189 case TREE_LIST:
4190 case COMPOUND_EXPR:
4191 case BIND_EXPR:
4192 return 1;
4194 case MODIFY_EXPR:
4195 case INIT_EXPR:
4196 return 2;
4198 case COND_EXPR:
4199 return 3;
4201 case TRUTH_OR_EXPR:
4202 case TRUTH_ORIF_EXPR:
4203 return 4;
4205 case TRUTH_AND_EXPR:
4206 case TRUTH_ANDIF_EXPR:
4207 return 5;
4209 case BIT_IOR_EXPR:
4210 return 6;
4212 case BIT_XOR_EXPR:
4213 case TRUTH_XOR_EXPR:
4214 return 7;
4216 case BIT_AND_EXPR:
4217 return 8;
4219 case EQ_EXPR:
4220 case NE_EXPR:
4221 return 9;
4223 case UNLT_EXPR:
4224 case UNLE_EXPR:
4225 case UNGT_EXPR:
4226 case UNGE_EXPR:
4227 case UNEQ_EXPR:
4228 case LTGT_EXPR:
4229 case ORDERED_EXPR:
4230 case UNORDERED_EXPR:
4231 case LT_EXPR:
4232 case LE_EXPR:
4233 case GT_EXPR:
4234 case GE_EXPR:
4235 return 10;
4237 case LSHIFT_EXPR:
4238 case RSHIFT_EXPR:
4239 case LROTATE_EXPR:
4240 case RROTATE_EXPR:
4241 case VEC_WIDEN_LSHIFT_HI_EXPR:
4242 case VEC_WIDEN_LSHIFT_LO_EXPR:
4243 case WIDEN_LSHIFT_EXPR:
4244 return 11;
4246 case WIDEN_SUM_EXPR:
4247 case PLUS_EXPR:
4248 case POINTER_PLUS_EXPR:
4249 case POINTER_DIFF_EXPR:
4250 case MINUS_EXPR:
4251 return 12;
4253 case VEC_WIDEN_MULT_HI_EXPR:
4254 case VEC_WIDEN_MULT_LO_EXPR:
4255 case WIDEN_MULT_EXPR:
4256 case DOT_PROD_EXPR:
4257 case WIDEN_MULT_PLUS_EXPR:
4258 case WIDEN_MULT_MINUS_EXPR:
4259 case MULT_EXPR:
4260 case MULT_HIGHPART_EXPR:
4261 case TRUNC_DIV_EXPR:
4262 case CEIL_DIV_EXPR:
4263 case FLOOR_DIV_EXPR:
4264 case ROUND_DIV_EXPR:
4265 case RDIV_EXPR:
4266 case EXACT_DIV_EXPR:
4267 case TRUNC_MOD_EXPR:
4268 case CEIL_MOD_EXPR:
4269 case FLOOR_MOD_EXPR:
4270 case ROUND_MOD_EXPR:
4271 return 13;
4273 case TRUTH_NOT_EXPR:
4274 case BIT_NOT_EXPR:
4275 case POSTINCREMENT_EXPR:
4276 case POSTDECREMENT_EXPR:
4277 case PREINCREMENT_EXPR:
4278 case PREDECREMENT_EXPR:
4279 case NEGATE_EXPR:
4280 case INDIRECT_REF:
4281 case ADDR_EXPR:
4282 case FLOAT_EXPR:
4283 CASE_CONVERT:
4284 case FIX_TRUNC_EXPR:
4285 case TARGET_EXPR:
4286 return 14;
4288 case CALL_EXPR:
4289 case ARRAY_REF:
4290 case ARRAY_RANGE_REF:
4291 case COMPONENT_REF:
4292 return 15;
4294 /* Special expressions. */
4295 case MIN_EXPR:
4296 case MAX_EXPR:
4297 case ABS_EXPR:
4298 case REALPART_EXPR:
4299 case IMAGPART_EXPR:
4300 case VEC_UNPACK_HI_EXPR:
4301 case VEC_UNPACK_LO_EXPR:
4302 case VEC_UNPACK_FLOAT_HI_EXPR:
4303 case VEC_UNPACK_FLOAT_LO_EXPR:
4304 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
4305 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
4306 case VEC_PACK_TRUNC_EXPR:
4307 case VEC_PACK_SAT_EXPR:
4308 return 16;
4310 default:
4311 /* Return an arbitrarily high precedence to avoid surrounding single
4312 VAR_DECLs in ()s. */
4313 return 9999;
4317 /* Return the priority of the operator OP. */
4320 op_prio (const_tree op)
4322 enum tree_code code;
4324 if (op == NULL)
4325 return 9999;
4327 code = TREE_CODE (op);
4328 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
4329 return op_prio (TREE_OPERAND (op, 0));
4331 return op_code_prio (code);
4334 /* Return the symbol associated with operator CODE. */
4336 const char *
4337 op_symbol_code (enum tree_code code, dump_flags_t flags)
4339 switch (code)
4341 case MODIFY_EXPR:
4342 return "=";
4344 case TRUTH_OR_EXPR:
4345 case TRUTH_ORIF_EXPR:
4346 return "||";
4348 case TRUTH_AND_EXPR:
4349 case TRUTH_ANDIF_EXPR:
4350 return "&&";
4352 case BIT_IOR_EXPR:
4353 return "|";
4355 case TRUTH_XOR_EXPR:
4356 case BIT_XOR_EXPR:
4357 return "^";
4359 case ADDR_EXPR:
4360 case BIT_AND_EXPR:
4361 return "&";
4363 case ORDERED_EXPR:
4364 return (flags & TDF_GIMPLE) ? "__ORDERED" : "ord";
4365 case UNORDERED_EXPR:
4366 return (flags & TDF_GIMPLE) ? "__UNORDERED" : "unord";
4368 case EQ_EXPR:
4369 return "==";
4370 case UNEQ_EXPR:
4371 return (flags & TDF_GIMPLE) ? "__UNEQ" : "u==";
4373 case NE_EXPR:
4374 return "!=";
4376 case LT_EXPR:
4377 return "<";
4378 case UNLT_EXPR:
4379 return (flags & TDF_GIMPLE) ? "__UNLT" : "u<";
4381 case LE_EXPR:
4382 return "<=";
4383 case UNLE_EXPR:
4384 return (flags & TDF_GIMPLE) ? "__UNLE" : "u<=";
4386 case GT_EXPR:
4387 return ">";
4388 case UNGT_EXPR:
4389 return (flags & TDF_GIMPLE) ? "__UNGT" : "u>";
4391 case GE_EXPR:
4392 return ">=";
4393 case UNGE_EXPR:
4394 return (flags & TDF_GIMPLE) ? "__UNGE" : "u>=";
4396 case LTGT_EXPR:
4397 return (flags & TDF_GIMPLE) ? "__LTGT" : "<>";
4399 case LSHIFT_EXPR:
4400 return "<<";
4402 case RSHIFT_EXPR:
4403 return ">>";
4405 case LROTATE_EXPR:
4406 return "r<<";
4408 case RROTATE_EXPR:
4409 return "r>>";
4411 case WIDEN_LSHIFT_EXPR:
4412 return "w<<";
4414 case POINTER_PLUS_EXPR:
4415 return "+";
4417 case PLUS_EXPR:
4418 return "+";
4420 case WIDEN_SUM_EXPR:
4421 return "w+";
4423 case WIDEN_MULT_EXPR:
4424 return "w*";
4426 case MULT_HIGHPART_EXPR:
4427 return (flags & TDF_GIMPLE) ? "__MULT_HIGHPART" : "h*";
4429 case NEGATE_EXPR:
4430 case MINUS_EXPR:
4431 case POINTER_DIFF_EXPR:
4432 return "-";
4434 case BIT_NOT_EXPR:
4435 return "~";
4437 case TRUTH_NOT_EXPR:
4438 return "!";
4440 case MULT_EXPR:
4441 case INDIRECT_REF:
4442 return "*";
4444 case TRUNC_DIV_EXPR:
4445 case RDIV_EXPR:
4446 return "/";
4448 case CEIL_DIV_EXPR:
4449 return "/[cl]";
4451 case FLOOR_DIV_EXPR:
4452 return "/[fl]";
4454 case ROUND_DIV_EXPR:
4455 return "/[rd]";
4457 case EXACT_DIV_EXPR:
4458 return "/[ex]";
4460 case TRUNC_MOD_EXPR:
4461 return "%";
4463 case CEIL_MOD_EXPR:
4464 return "%[cl]";
4466 case FLOOR_MOD_EXPR:
4467 return "%[fl]";
4469 case ROUND_MOD_EXPR:
4470 return "%[rd]";
4472 case PREDECREMENT_EXPR:
4473 return " --";
4475 case PREINCREMENT_EXPR:
4476 return " ++";
4478 case POSTDECREMENT_EXPR:
4479 return "-- ";
4481 case POSTINCREMENT_EXPR:
4482 return "++ ";
4484 case MAX_EXPR:
4485 return "max";
4487 case MIN_EXPR:
4488 return "min";
4490 default:
4491 return "<<< ??? >>>";
4495 /* Return the symbol associated with operator OP. */
4497 static const char *
4498 op_symbol (const_tree op, dump_flags_t flags)
4500 return op_symbol_code (TREE_CODE (op), flags);
4503 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
4504 the gimple_call_fn of a GIMPLE_CALL. */
4506 void
4507 print_call_name (pretty_printer *pp, tree node, dump_flags_t flags)
4509 tree op0 = node;
4510 int spc = 0;
4512 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
4513 op0 = TREE_OPERAND (op0, 0);
4515 again:
4516 switch (TREE_CODE (op0))
4518 case VAR_DECL:
4519 case PARM_DECL:
4520 case FUNCTION_DECL:
4521 dump_function_name (pp, op0, flags);
4522 break;
4524 case ADDR_EXPR:
4525 case INDIRECT_REF:
4526 CASE_CONVERT:
4527 op0 = TREE_OPERAND (op0, 0);
4528 goto again;
4530 case COND_EXPR:
4531 pp_left_paren (pp);
4532 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
4533 pp_string (pp, ") ? ");
4534 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
4535 pp_string (pp, " : ");
4536 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
4537 break;
4539 case ARRAY_REF:
4540 if (VAR_P (TREE_OPERAND (op0, 0)))
4541 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
4542 else
4543 dump_generic_node (pp, op0, 0, flags, false);
4544 break;
4546 case MEM_REF:
4547 if (integer_zerop (TREE_OPERAND (op0, 1)))
4549 op0 = TREE_OPERAND (op0, 0);
4550 goto again;
4552 /* Fallthru. */
4553 case COMPONENT_REF:
4554 case SSA_NAME:
4555 case OBJ_TYPE_REF:
4556 dump_generic_node (pp, op0, 0, flags, false);
4557 break;
4559 default:
4560 NIY;
4564 /* Print the first N characters in the array STR, replacing non-printable
4565 characters (including embedded nuls) with unambiguous escape sequences. */
4567 void
4568 pretty_print_string (pretty_printer *pp, const char *str, size_t n)
4570 if (str == NULL)
4571 return;
4573 for ( ; n; --n, ++str)
4575 switch (str[0])
4577 case '\b':
4578 pp_string (pp, "\\b");
4579 break;
4581 case '\f':
4582 pp_string (pp, "\\f");
4583 break;
4585 case '\n':
4586 pp_string (pp, "\\n");
4587 break;
4589 case '\r':
4590 pp_string (pp, "\\r");
4591 break;
4593 case '\t':
4594 pp_string (pp, "\\t");
4595 break;
4597 case '\v':
4598 pp_string (pp, "\\v");
4599 break;
4601 case '\\':
4602 pp_string (pp, "\\\\");
4603 break;
4605 case '\"':
4606 pp_string (pp, "\\\"");
4607 break;
4609 case '\'':
4610 pp_string (pp, "\\'");
4611 break;
4613 default:
4614 if (str[0] || n > 1)
4616 if (!ISPRINT (str[0]))
4618 char buf[5];
4619 sprintf (buf, "\\x%02x", (unsigned char)str[0]);
4620 pp_string (pp, buf);
4622 else
4623 pp_character (pp, str[0]);
4624 break;
4630 static void
4631 maybe_init_pretty_print (FILE *file)
4633 if (!tree_pp)
4635 tree_pp = new pretty_printer ();
4636 pp_needs_newline (tree_pp) = true;
4637 pp_translate_identifiers (tree_pp) = false;
4640 tree_pp->buffer->stream = file;
4643 static void
4644 newline_and_indent (pretty_printer *pp, int spc)
4646 pp_newline (pp);
4647 INDENT (spc);
4650 /* Print the identifier ID to PRETTY-PRINTER. */
4652 void
4653 pp_tree_identifier (pretty_printer *pp, tree id)
4655 if (pp_translate_identifiers (pp))
4657 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
4658 pp_append_text (pp, text, text + strlen (text));
4660 else
4661 pp_append_text (pp, IDENTIFIER_POINTER (id),
4662 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
4665 /* A helper function that is used to dump function information before the
4666 function dump. */
4668 void
4669 dump_function_header (FILE *dump_file, tree fdecl, dump_flags_t flags)
4671 const char *dname, *aname;
4672 struct cgraph_node *node = cgraph_node::get (fdecl);
4673 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
4675 dname = lang_hooks.decl_printable_name (fdecl, 1);
4677 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
4678 aname = (IDENTIFIER_POINTER
4679 (DECL_ASSEMBLER_NAME (fdecl)));
4680 else
4681 aname = "<unset-asm-name>";
4683 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
4684 dname, aname, fun->funcdef_no);
4685 if (!(flags & TDF_NOUID))
4686 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
4687 if (node)
4689 fprintf (dump_file, ", cgraph_uid=%d", node->get_uid ());
4690 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
4691 node->frequency == NODE_FREQUENCY_HOT
4692 ? " (hot)"
4693 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
4694 ? " (unlikely executed)"
4695 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
4696 ? " (executed once)"
4697 : "");
4699 else
4700 fprintf (dump_file, ")\n\n");
4703 /* Dump double_int D to pretty_printer PP. UNS is true
4704 if D is unsigned and false otherwise. */
4705 void
4706 pp_double_int (pretty_printer *pp, double_int d, bool uns)
4708 if (d.fits_shwi ())
4709 pp_wide_integer (pp, d.low);
4710 else if (d.fits_uhwi ())
4711 pp_unsigned_wide_integer (pp, d.low);
4712 else
4714 unsigned HOST_WIDE_INT low = d.low;
4715 HOST_WIDE_INT high = d.high;
4716 if (!uns && d.is_negative ())
4718 pp_minus (pp);
4719 high = ~high + !low;
4720 low = -low;
4722 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
4723 systems? */
4724 sprintf (pp_buffer (pp)->digit_buffer,
4725 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
4726 (unsigned HOST_WIDE_INT) high, low);
4727 pp_string (pp, pp_buffer (pp)->digit_buffer);
4731 #if __GNUC__ >= 10
4732 # pragma GCC diagnostic pop
4733 #endif