ipa-inline-analysis.c (simple_edge_hints): Fix check for cross-module inlining.
[official-gcc.git] / gcc / tree-pretty-print.c
blobd7c049f1f443b94f76a8f3d1a88b6b263970f237
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 Adapted from c-pretty-print.c by Diego Novillo <dnovillo@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "tm.h"
25 #include "hash-set.h"
26 #include "machmode.h"
27 #include "vec.h"
28 #include "double-int.h"
29 #include "input.h"
30 #include "alias.h"
31 #include "symtab.h"
32 #include "wide-int.h"
33 #include "inchash.h"
34 #include "tree.h"
35 #include "stor-layout.h"
36 #include "hashtab.h"
37 #include "hard-reg-set.h"
38 #include "function.h"
39 #include "rtl.h"
40 #include "flags.h"
41 #include "statistics.h"
42 #include "real.h"
43 #include "fixed-value.h"
44 #include "insn-config.h"
45 #include "expmed.h"
46 #include "dojump.h"
47 #include "explow.h"
48 #include "calls.h"
49 #include "emit-rtl.h"
50 #include "varasm.h"
51 #include "stmt.h"
52 #include "expr.h"
53 #include "tree-pretty-print.h"
54 #include "gimple-expr.h"
55 #include "predict.h"
56 #include "hash-map.h"
57 #include "is-a.h"
58 #include "plugin-api.h"
59 #include "ipa-ref.h"
60 #include "cgraph.h"
61 #include "langhooks.h"
62 #include "tree-iterator.h"
63 #include "tree-chrec.h"
64 #include "dumpfile.h"
65 #include "value-prof.h"
66 #include "wide-int-print.h"
67 #include "internal-fn.h"
68 #include "gomp-constants.h"
70 /* Local functions, macros and variables. */
71 static const char *op_symbol (const_tree);
72 static void pretty_print_string (pretty_printer *, const char*);
73 static void newline_and_indent (pretty_printer *, int);
74 static void maybe_init_pretty_print (FILE *);
75 static void print_struct_decl (pretty_printer *, const_tree, int, int);
76 static void do_niy (pretty_printer *, const_tree);
78 #define INDENT(SPACE) do { \
79 int i; for (i = 0; i<SPACE; i++) pp_space (pp); } while (0)
81 #define NIY do_niy (pp, node)
83 static pretty_printer *tree_pp;
85 /* Try to print something for an unknown tree code. */
87 static void
88 do_niy (pretty_printer *pp, const_tree node)
90 int i, len;
92 pp_string (pp, "<<< Unknown tree: ");
93 pp_string (pp, get_tree_code_name (TREE_CODE (node)));
95 if (EXPR_P (node))
97 len = TREE_OPERAND_LENGTH (node);
98 for (i = 0; i < len; ++i)
100 newline_and_indent (pp, 2);
101 dump_generic_node (pp, TREE_OPERAND (node, i), 2, 0, false);
105 pp_string (pp, " >>>");
108 /* Debugging function to print out a generic expression. */
110 DEBUG_FUNCTION void
111 debug_generic_expr (tree t)
113 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
114 fprintf (stderr, "\n");
117 /* Debugging function to print out a generic statement. */
119 DEBUG_FUNCTION void
120 debug_generic_stmt (tree t)
122 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
123 fprintf (stderr, "\n");
126 /* Debugging function to print out a chain of trees . */
128 DEBUG_FUNCTION void
129 debug_tree_chain (tree t)
131 hash_set<tree> seen;
133 while (t)
135 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
136 fprintf (stderr, " ");
137 t = TREE_CHAIN (t);
138 if (seen.add (t))
140 fprintf (stderr, "... [cycled back to ");
141 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
142 fprintf (stderr, "]");
143 break;
146 fprintf (stderr, "\n");
149 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
150 void
151 print_generic_decl (FILE *file, tree decl, int flags)
153 maybe_init_pretty_print (file);
154 print_declaration (tree_pp, decl, 2, flags);
155 pp_write_text_to_stream (tree_pp);
158 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
159 to show in the dump. See TDF_* in dumpfile.h. */
161 void
162 print_generic_stmt (FILE *file, tree t, int flags)
164 maybe_init_pretty_print (file);
165 dump_generic_node (tree_pp, t, 0, flags, true);
166 pp_newline_and_flush (tree_pp);
169 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
170 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
171 INDENT spaces. */
173 void
174 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
176 int i;
178 maybe_init_pretty_print (file);
180 for (i = 0; i < indent; i++)
181 pp_space (tree_pp);
182 dump_generic_node (tree_pp, t, indent, flags, true);
183 pp_newline_and_flush (tree_pp);
186 /* Print a single expression T on file FILE. FLAGS specifies details to show
187 in the dump. See TDF_* in dumpfile.h. */
189 void
190 print_generic_expr (FILE *file, tree t, int flags)
192 maybe_init_pretty_print (file);
193 dump_generic_node (tree_pp, t, 0, flags, false);
194 pp_flush (tree_pp);
197 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
198 in FLAGS. */
200 static void
201 dump_decl_name (pretty_printer *pp, tree node, int flags)
203 if (DECL_NAME (node))
205 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
206 pp_tree_identifier (pp, DECL_ASSEMBLER_NAME (node));
207 else
208 pp_tree_identifier (pp, DECL_NAME (node));
210 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
212 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
213 pp_printf (pp, "L.%d", (int) LABEL_DECL_UID (node));
214 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
216 if (flags & TDF_NOUID)
217 pp_string (pp, "D#xxxx");
218 else
219 pp_printf (pp, "D#%i", DEBUG_TEMP_UID (node));
221 else
223 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
224 if (flags & TDF_NOUID)
225 pp_printf (pp, "%c.xxxx", c);
226 else
227 pp_printf (pp, "%c.%u", c, DECL_UID (node));
230 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
232 if (flags & TDF_NOUID)
233 pp_printf (pp, "ptD.xxxx");
234 else
235 pp_printf (pp, "ptD.%u", DECL_PT_UID (node));
239 /* Like the above, but used for pretty printing function calls. */
241 static void
242 dump_function_name (pretty_printer *pp, tree node, int flags)
244 if (CONVERT_EXPR_P (node))
245 node = TREE_OPERAND (node, 0);
246 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
247 pp_string (pp, lang_hooks.decl_printable_name (node, 1));
248 else
249 dump_decl_name (pp, node, flags);
252 /* Dump a function declaration. NODE is the FUNCTION_TYPE. PP, SPC and
253 FLAGS are as in dump_generic_node. */
255 static void
256 dump_function_declaration (pretty_printer *pp, tree node,
257 int spc, int flags)
259 bool wrote_arg = false;
260 tree arg;
262 pp_space (pp);
263 pp_left_paren (pp);
265 /* Print the argument types. */
266 arg = TYPE_ARG_TYPES (node);
267 while (arg && arg != void_list_node && arg != error_mark_node)
269 if (wrote_arg)
271 pp_comma (pp);
272 pp_space (pp);
274 wrote_arg = true;
275 dump_generic_node (pp, TREE_VALUE (arg), spc, flags, false);
276 arg = TREE_CHAIN (arg);
279 /* Drop the trailing void_type_node if we had any previous argument. */
280 if (arg == void_list_node && !wrote_arg)
281 pp_string (pp, "void");
282 /* Properly dump vararg function types. */
283 else if (!arg && wrote_arg)
284 pp_string (pp, ", ...");
285 /* Avoid printing any arg for unprototyped functions. */
287 pp_right_paren (pp);
290 /* Dump the domain associated with an array. */
292 static void
293 dump_array_domain (pretty_printer *pp, tree domain, int spc, int flags)
295 pp_left_bracket (pp);
296 if (domain)
298 tree min = TYPE_MIN_VALUE (domain);
299 tree max = TYPE_MAX_VALUE (domain);
301 if (min && max
302 && integer_zerop (min)
303 && tree_fits_shwi_p (max))
304 pp_wide_integer (pp, tree_to_shwi (max) + 1);
305 else
307 if (min)
308 dump_generic_node (pp, min, spc, flags, false);
309 pp_colon (pp);
310 if (max)
311 dump_generic_node (pp, max, spc, flags, false);
314 else
315 pp_string (pp, "<unknown>");
316 pp_right_bracket (pp);
320 /* Dump OpenMP clause CLAUSE. PP, CLAUSE, SPC and FLAGS are as in
321 dump_generic_node. */
323 static void
324 dump_omp_clause (pretty_printer *pp, tree clause, int spc, int flags)
326 const char *name;
328 switch (OMP_CLAUSE_CODE (clause))
330 case OMP_CLAUSE_PRIVATE:
331 name = "private";
332 goto print_remap;
333 case OMP_CLAUSE_SHARED:
334 name = "shared";
335 goto print_remap;
336 case OMP_CLAUSE_FIRSTPRIVATE:
337 name = "firstprivate";
338 goto print_remap;
339 case OMP_CLAUSE_LASTPRIVATE:
340 name = "lastprivate";
341 goto print_remap;
342 case OMP_CLAUSE_COPYIN:
343 name = "copyin";
344 goto print_remap;
345 case OMP_CLAUSE_COPYPRIVATE:
346 name = "copyprivate";
347 goto print_remap;
348 case OMP_CLAUSE_UNIFORM:
349 name = "uniform";
350 goto print_remap;
351 case OMP_CLAUSE__LOOPTEMP_:
352 name = "_looptemp_";
353 goto print_remap;
354 case OMP_CLAUSE_DEVICE_RESIDENT:
355 name = "device_resident";
356 goto print_remap;
357 case OMP_CLAUSE_USE_DEVICE:
358 name = "use_device";
359 goto print_remap;
360 print_remap:
361 pp_string (pp, name);
362 pp_left_paren (pp);
363 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
364 spc, flags, false);
365 pp_right_paren (pp);
366 break;
368 case OMP_CLAUSE_REDUCTION:
369 pp_string (pp, "reduction(");
370 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
372 pp_string (pp,
373 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
374 pp_colon (pp);
376 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
377 spc, flags, false);
378 pp_right_paren (pp);
379 break;
381 case OMP_CLAUSE_IF:
382 pp_string (pp, "if(");
383 dump_generic_node (pp, OMP_CLAUSE_IF_EXPR (clause),
384 spc, flags, false);
385 pp_right_paren (pp);
386 break;
388 case OMP_CLAUSE_NUM_THREADS:
389 pp_string (pp, "num_threads(");
390 dump_generic_node (pp, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
391 spc, flags, false);
392 pp_right_paren (pp);
393 break;
395 case OMP_CLAUSE__CILK_FOR_COUNT_:
396 pp_string (pp, "_Cilk_for_count_(");
397 dump_generic_node (pp, OMP_CLAUSE_OPERAND (clause, 0),
398 spc, flags, false);
399 pp_right_paren (pp);
400 break;
402 case OMP_CLAUSE_NOWAIT:
403 pp_string (pp, "nowait");
404 break;
405 case OMP_CLAUSE_ORDERED:
406 pp_string (pp, "ordered");
407 break;
409 case OMP_CLAUSE_DEFAULT:
410 pp_string (pp, "default(");
411 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
413 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
414 break;
415 case OMP_CLAUSE_DEFAULT_SHARED:
416 pp_string (pp, "shared");
417 break;
418 case OMP_CLAUSE_DEFAULT_NONE:
419 pp_string (pp, "none");
420 break;
421 case OMP_CLAUSE_DEFAULT_PRIVATE:
422 pp_string (pp, "private");
423 break;
424 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
425 pp_string (pp, "firstprivate");
426 break;
427 default:
428 gcc_unreachable ();
430 pp_right_paren (pp);
431 break;
433 case OMP_CLAUSE_SCHEDULE:
434 pp_string (pp, "schedule(");
435 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
437 case OMP_CLAUSE_SCHEDULE_STATIC:
438 pp_string (pp, "static");
439 break;
440 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
441 pp_string (pp, "dynamic");
442 break;
443 case OMP_CLAUSE_SCHEDULE_GUIDED:
444 pp_string (pp, "guided");
445 break;
446 case OMP_CLAUSE_SCHEDULE_RUNTIME:
447 pp_string (pp, "runtime");
448 break;
449 case OMP_CLAUSE_SCHEDULE_AUTO:
450 pp_string (pp, "auto");
451 break;
452 case OMP_CLAUSE_SCHEDULE_CILKFOR:
453 pp_string (pp, "cilk-for grain");
454 break;
455 default:
456 gcc_unreachable ();
458 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
460 pp_comma (pp);
461 dump_generic_node (pp, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
462 spc, flags, false);
464 pp_right_paren (pp);
465 break;
467 case OMP_CLAUSE_UNTIED:
468 pp_string (pp, "untied");
469 break;
471 case OMP_CLAUSE_COLLAPSE:
472 pp_string (pp, "collapse(");
473 dump_generic_node (pp, OMP_CLAUSE_COLLAPSE_EXPR (clause),
474 spc, flags, false);
475 pp_right_paren (pp);
476 break;
478 case OMP_CLAUSE_FINAL:
479 pp_string (pp, "final(");
480 dump_generic_node (pp, OMP_CLAUSE_FINAL_EXPR (clause),
481 spc, flags, false);
482 pp_right_paren (pp);
483 break;
485 case OMP_CLAUSE_MERGEABLE:
486 pp_string (pp, "mergeable");
487 break;
489 case OMP_CLAUSE_LINEAR:
490 pp_string (pp, "linear(");
491 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
492 spc, flags, false);
493 pp_colon (pp);
494 dump_generic_node (pp, OMP_CLAUSE_LINEAR_STEP (clause),
495 spc, flags, false);
496 pp_right_paren (pp);
497 break;
499 case OMP_CLAUSE_ALIGNED:
500 pp_string (pp, "aligned(");
501 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
502 spc, flags, false);
503 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
505 pp_colon (pp);
506 dump_generic_node (pp, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
507 spc, flags, false);
509 pp_right_paren (pp);
510 break;
512 case OMP_CLAUSE_DEPEND:
513 pp_string (pp, "depend(");
514 switch (OMP_CLAUSE_DEPEND_KIND (clause))
516 case OMP_CLAUSE_DEPEND_IN:
517 pp_string (pp, "in");
518 break;
519 case OMP_CLAUSE_DEPEND_OUT:
520 pp_string (pp, "out");
521 break;
522 case OMP_CLAUSE_DEPEND_INOUT:
523 pp_string (pp, "inout");
524 break;
525 default:
526 gcc_unreachable ();
528 pp_colon (pp);
529 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
530 spc, flags, false);
531 pp_right_paren (pp);
532 break;
534 case OMP_CLAUSE_MAP:
535 pp_string (pp, "map(");
536 switch (OMP_CLAUSE_MAP_KIND (clause))
538 case GOMP_MAP_ALLOC:
539 case GOMP_MAP_POINTER:
540 pp_string (pp, "alloc");
541 break;
542 case GOMP_MAP_TO:
543 case GOMP_MAP_TO_PSET:
544 pp_string (pp, "to");
545 break;
546 case GOMP_MAP_FROM:
547 pp_string (pp, "from");
548 break;
549 case GOMP_MAP_TOFROM:
550 pp_string (pp, "tofrom");
551 break;
552 case GOMP_MAP_FORCE_ALLOC:
553 pp_string (pp, "force_alloc");
554 break;
555 case GOMP_MAP_FORCE_TO:
556 pp_string (pp, "force_to");
557 break;
558 case GOMP_MAP_FORCE_FROM:
559 pp_string (pp, "force_from");
560 break;
561 case GOMP_MAP_FORCE_TOFROM:
562 pp_string (pp, "force_tofrom");
563 break;
564 case GOMP_MAP_FORCE_PRESENT:
565 pp_string (pp, "force_present");
566 break;
567 case GOMP_MAP_FORCE_DEALLOC:
568 pp_string (pp, "force_dealloc");
569 break;
570 case GOMP_MAP_FORCE_DEVICEPTR:
571 pp_string (pp, "force_deviceptr");
572 break;
573 default:
574 gcc_unreachable ();
576 pp_colon (pp);
577 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
578 spc, flags, false);
579 print_clause_size:
580 if (OMP_CLAUSE_SIZE (clause))
582 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
583 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_POINTER)
584 pp_string (pp, " [pointer assign, bias: ");
585 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
586 && OMP_CLAUSE_MAP_KIND (clause) == GOMP_MAP_TO_PSET)
587 pp_string (pp, " [pointer set, len: ");
588 else
589 pp_string (pp, " [len: ");
590 dump_generic_node (pp, OMP_CLAUSE_SIZE (clause),
591 spc, flags, false);
592 pp_right_bracket (pp);
594 pp_right_paren (pp);
595 break;
597 case OMP_CLAUSE_FROM:
598 pp_string (pp, "from(");
599 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
600 spc, flags, false);
601 goto print_clause_size;
603 case OMP_CLAUSE_TO:
604 pp_string (pp, "to(");
605 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
606 spc, flags, false);
607 goto print_clause_size;
609 case OMP_CLAUSE__CACHE_:
610 pp_string (pp, "(");
611 dump_generic_node (pp, OMP_CLAUSE_DECL (clause),
612 spc, flags, false);
613 goto print_clause_size;
615 case OMP_CLAUSE_NUM_TEAMS:
616 pp_string (pp, "num_teams(");
617 dump_generic_node (pp, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
618 spc, flags, false);
619 pp_right_paren (pp);
620 break;
622 case OMP_CLAUSE_THREAD_LIMIT:
623 pp_string (pp, "thread_limit(");
624 dump_generic_node (pp, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
625 spc, flags, false);
626 pp_right_paren (pp);
627 break;
629 case OMP_CLAUSE_DEVICE:
630 pp_string (pp, "device(");
631 dump_generic_node (pp, OMP_CLAUSE_DEVICE_ID (clause),
632 spc, flags, false);
633 pp_right_paren (pp);
634 break;
636 case OMP_CLAUSE_DIST_SCHEDULE:
637 pp_string (pp, "dist_schedule(static");
638 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
640 pp_comma (pp);
641 dump_generic_node (pp,
642 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
643 spc, flags, false);
645 pp_right_paren (pp);
646 break;
648 case OMP_CLAUSE_PROC_BIND:
649 pp_string (pp, "proc_bind(");
650 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
652 case OMP_CLAUSE_PROC_BIND_MASTER:
653 pp_string (pp, "master");
654 break;
655 case OMP_CLAUSE_PROC_BIND_CLOSE:
656 pp_string (pp, "close");
657 break;
658 case OMP_CLAUSE_PROC_BIND_SPREAD:
659 pp_string (pp, "spread");
660 break;
661 default:
662 gcc_unreachable ();
664 pp_right_paren (pp);
665 break;
667 case OMP_CLAUSE_SAFELEN:
668 pp_string (pp, "safelen(");
669 dump_generic_node (pp, OMP_CLAUSE_SAFELEN_EXPR (clause),
670 spc, flags, false);
671 pp_right_paren (pp);
672 break;
674 case OMP_CLAUSE_SIMDLEN:
675 pp_string (pp, "simdlen(");
676 dump_generic_node (pp, OMP_CLAUSE_SIMDLEN_EXPR (clause),
677 spc, flags, false);
678 pp_right_paren (pp);
679 break;
681 case OMP_CLAUSE__SIMDUID_:
682 pp_string (pp, "_simduid_(");
683 dump_generic_node (pp, OMP_CLAUSE__SIMDUID__DECL (clause),
684 spc, flags, false);
685 pp_right_paren (pp);
686 break;
688 case OMP_CLAUSE_GANG:
689 pp_string (pp, "gang");
690 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE)
692 pp_string (pp, "(num: ");
693 dump_generic_node (pp, OMP_CLAUSE_GANG_EXPR (clause),
694 spc, flags, false);
696 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
698 if (OMP_CLAUSE_GANG_EXPR (clause) == NULL_TREE)
699 pp_left_paren (pp);
700 else
701 pp_space (pp);
702 pp_string (pp, "static:");
703 if (OMP_CLAUSE_GANG_STATIC_EXPR (clause)
704 == integer_minus_one_node)
705 pp_character (pp, '*');
706 else
707 dump_generic_node (pp, OMP_CLAUSE_GANG_STATIC_EXPR (clause),
708 spc, flags, false);
710 if (OMP_CLAUSE_GANG_EXPR (clause) != NULL_TREE
711 || OMP_CLAUSE_GANG_STATIC_EXPR (clause) != NULL_TREE)
712 pp_right_paren (pp);
713 break;
715 case OMP_CLAUSE_ASYNC:
716 pp_string (pp, "async");
717 if (OMP_CLAUSE_ASYNC_EXPR (clause))
719 pp_character(pp, '(');
720 dump_generic_node (pp, OMP_CLAUSE_ASYNC_EXPR (clause),
721 spc, flags, false);
722 pp_character(pp, ')');
724 break;
726 case OMP_CLAUSE_AUTO:
727 case OMP_CLAUSE_SEQ:
728 pp_string (pp, omp_clause_code_name[OMP_CLAUSE_CODE (clause)]);
729 break;
731 case OMP_CLAUSE_WAIT:
732 pp_string (pp, "wait(");
733 dump_generic_node (pp, OMP_CLAUSE_WAIT_EXPR (clause),
734 spc, flags, false);
735 pp_character(pp, ')');
736 break;
738 case OMP_CLAUSE_WORKER:
739 pp_string (pp, "worker");
740 if (OMP_CLAUSE_WORKER_EXPR (clause) != NULL_TREE)
742 pp_left_paren (pp);
743 dump_generic_node (pp, OMP_CLAUSE_WORKER_EXPR (clause),
744 spc, flags, false);
745 pp_right_paren (pp);
747 break;
749 case OMP_CLAUSE_VECTOR:
750 pp_string (pp, "vector");
751 if (OMP_CLAUSE_VECTOR_EXPR (clause) != NULL_TREE)
753 pp_left_paren (pp);
754 dump_generic_node (pp, OMP_CLAUSE_VECTOR_EXPR (clause),
755 spc, flags, false);
756 pp_right_paren (pp);
758 break;
760 case OMP_CLAUSE_NUM_GANGS:
761 pp_string (pp, "num_gangs(");
762 dump_generic_node (pp, OMP_CLAUSE_NUM_GANGS_EXPR (clause),
763 spc, flags, false);
764 pp_character (pp, ')');
765 break;
767 case OMP_CLAUSE_NUM_WORKERS:
768 pp_string (pp, "num_workers(");
769 dump_generic_node (pp, OMP_CLAUSE_NUM_WORKERS_EXPR (clause),
770 spc, flags, false);
771 pp_character (pp, ')');
772 break;
774 case OMP_CLAUSE_VECTOR_LENGTH:
775 pp_string (pp, "vector_length(");
776 dump_generic_node (pp, OMP_CLAUSE_VECTOR_LENGTH_EXPR (clause),
777 spc, flags, false);
778 pp_character (pp, ')');
779 break;
781 case OMP_CLAUSE_INBRANCH:
782 pp_string (pp, "inbranch");
783 break;
784 case OMP_CLAUSE_NOTINBRANCH:
785 pp_string (pp, "notinbranch");
786 break;
787 case OMP_CLAUSE_FOR:
788 pp_string (pp, "for");
789 break;
790 case OMP_CLAUSE_PARALLEL:
791 pp_string (pp, "parallel");
792 break;
793 case OMP_CLAUSE_SECTIONS:
794 pp_string (pp, "sections");
795 break;
796 case OMP_CLAUSE_TASKGROUP:
797 pp_string (pp, "taskgroup");
798 break;
799 case OMP_CLAUSE_INDEPENDENT:
800 pp_string (pp, "independent");
801 break;
803 default:
804 /* Should never happen. */
805 dump_generic_node (pp, clause, spc, flags, false);
806 break;
811 /* Dump the list of OpenMP clauses. PP, SPC and FLAGS are as in
812 dump_generic_node. */
814 void
815 dump_omp_clauses (pretty_printer *pp, tree clause, int spc, int flags)
817 if (clause == NULL)
818 return;
820 pp_space (pp);
821 while (1)
823 dump_omp_clause (pp, clause, spc, flags);
824 clause = OMP_CLAUSE_CHAIN (clause);
825 if (clause == NULL)
826 return;
827 pp_space (pp);
832 /* Dump location LOC to PP. */
834 void
835 dump_location (pretty_printer *pp, location_t loc)
837 expanded_location xloc = expand_location (loc);
839 pp_left_bracket (pp);
840 if (xloc.file)
842 pp_string (pp, xloc.file);
843 pp_string (pp, ":");
845 pp_decimal_int (pp, xloc.line);
846 pp_colon (pp);
847 pp_decimal_int (pp, xloc.column);
848 pp_string (pp, "] ");
852 /* Dump lexical block BLOCK. PP, SPC and FLAGS are as in
853 dump_generic_node. */
855 static void
856 dump_block_node (pretty_printer *pp, tree block, int spc, int flags)
858 tree t;
860 pp_printf (pp, "BLOCK #%d ", BLOCK_NUMBER (block));
862 if (flags & TDF_ADDRESS)
863 pp_printf (pp, "[%p] ", (void *) block);
865 if (BLOCK_ABSTRACT (block))
866 pp_string (pp, "[abstract] ");
868 if (TREE_ASM_WRITTEN (block))
869 pp_string (pp, "[written] ");
871 if (flags & TDF_SLIM)
872 return;
874 if (BLOCK_SOURCE_LOCATION (block))
875 dump_location (pp, BLOCK_SOURCE_LOCATION (block));
877 newline_and_indent (pp, spc + 2);
879 if (BLOCK_SUPERCONTEXT (block))
881 pp_string (pp, "SUPERCONTEXT: ");
882 dump_generic_node (pp, BLOCK_SUPERCONTEXT (block), 0,
883 flags | TDF_SLIM, false);
884 newline_and_indent (pp, spc + 2);
887 if (BLOCK_SUBBLOCKS (block))
889 pp_string (pp, "SUBBLOCKS: ");
890 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
892 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
893 pp_space (pp);
895 newline_and_indent (pp, spc + 2);
898 if (BLOCK_CHAIN (block))
900 pp_string (pp, "SIBLINGS: ");
901 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
903 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
904 pp_space (pp);
906 newline_and_indent (pp, spc + 2);
909 if (BLOCK_VARS (block))
911 pp_string (pp, "VARS: ");
912 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
914 dump_generic_node (pp, t, 0, flags, false);
915 pp_space (pp);
917 newline_and_indent (pp, spc + 2);
920 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
922 unsigned i;
923 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
925 pp_string (pp, "NONLOCALIZED_VARS: ");
926 FOR_EACH_VEC_ELT (*nlv, i, t)
928 dump_generic_node (pp, t, 0, flags, false);
929 pp_space (pp);
931 newline_and_indent (pp, spc + 2);
934 if (BLOCK_ABSTRACT_ORIGIN (block))
936 pp_string (pp, "ABSTRACT_ORIGIN: ");
937 dump_generic_node (pp, BLOCK_ABSTRACT_ORIGIN (block), 0,
938 flags | TDF_SLIM, false);
939 newline_and_indent (pp, spc + 2);
942 if (BLOCK_FRAGMENT_ORIGIN (block))
944 pp_string (pp, "FRAGMENT_ORIGIN: ");
945 dump_generic_node (pp, BLOCK_FRAGMENT_ORIGIN (block), 0,
946 flags | TDF_SLIM, false);
947 newline_and_indent (pp, spc + 2);
950 if (BLOCK_FRAGMENT_CHAIN (block))
952 pp_string (pp, "FRAGMENT_CHAIN: ");
953 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
955 dump_generic_node (pp, t, 0, flags | TDF_SLIM, false);
956 pp_space (pp);
958 newline_and_indent (pp, spc + 2);
963 /* Dump the node NODE on the pretty_printer PP, SPC spaces of
964 indent. FLAGS specifies details to show in the dump (see TDF_* in
965 dumpfile.h). If IS_STMT is true, the object printed is considered
966 to be a statement and it is terminated by ';' if appropriate. */
969 dump_generic_node (pretty_printer *pp, tree node, int spc, int flags,
970 bool is_stmt)
972 tree type;
973 tree op0, op1;
974 const char *str;
975 bool is_expr;
976 enum tree_code code;
978 if (node == NULL_TREE)
979 return spc;
981 is_expr = EXPR_P (node);
983 if (is_stmt && (flags & TDF_STMTADDR))
984 pp_printf (pp, "<&%p> ", (void *)node);
986 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
987 dump_location (pp, EXPR_LOCATION (node));
989 code = TREE_CODE (node);
990 switch (code)
992 case ERROR_MARK:
993 pp_string (pp, "<<< error >>>");
994 break;
996 case IDENTIFIER_NODE:
997 pp_tree_identifier (pp, node);
998 break;
1000 case TREE_LIST:
1001 while (node && node != error_mark_node)
1003 if (TREE_PURPOSE (node))
1005 dump_generic_node (pp, TREE_PURPOSE (node), spc, flags, false);
1006 pp_space (pp);
1008 dump_generic_node (pp, TREE_VALUE (node), spc, flags, false);
1009 node = TREE_CHAIN (node);
1010 if (node && TREE_CODE (node) == TREE_LIST)
1012 pp_comma (pp);
1013 pp_space (pp);
1016 break;
1018 case TREE_BINFO:
1019 dump_generic_node (pp, BINFO_TYPE (node), spc, flags, false);
1020 break;
1022 case TREE_VEC:
1024 size_t i;
1025 if (TREE_VEC_LENGTH (node) > 0)
1027 size_t len = TREE_VEC_LENGTH (node);
1028 for (i = 0; i < len - 1; i++)
1030 dump_generic_node (pp, TREE_VEC_ELT (node, i), spc, flags,
1031 false);
1032 pp_comma (pp);
1033 pp_space (pp);
1035 dump_generic_node (pp, TREE_VEC_ELT (node, len - 1), spc,
1036 flags, false);
1039 break;
1041 case VOID_TYPE:
1042 case POINTER_BOUNDS_TYPE:
1043 case INTEGER_TYPE:
1044 case REAL_TYPE:
1045 case FIXED_POINT_TYPE:
1046 case COMPLEX_TYPE:
1047 case VECTOR_TYPE:
1048 case ENUMERAL_TYPE:
1049 case BOOLEAN_TYPE:
1051 unsigned int quals = TYPE_QUALS (node);
1052 enum tree_code_class tclass;
1054 if (quals & TYPE_QUAL_ATOMIC)
1055 pp_string (pp, "atomic ");
1056 if (quals & TYPE_QUAL_CONST)
1057 pp_string (pp, "const ");
1058 else if (quals & TYPE_QUAL_VOLATILE)
1059 pp_string (pp, "volatile ");
1060 else if (quals & TYPE_QUAL_RESTRICT)
1061 pp_string (pp, "restrict ");
1063 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1065 pp_string (pp, "<address-space-");
1066 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1067 pp_string (pp, "> ");
1070 tclass = TREE_CODE_CLASS (TREE_CODE (node));
1072 if (tclass == tcc_declaration)
1074 if (DECL_NAME (node))
1075 dump_decl_name (pp, node, flags);
1076 else
1077 pp_string (pp, "<unnamed type decl>");
1079 else if (tclass == tcc_type)
1081 if (TYPE_NAME (node))
1083 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
1084 pp_tree_identifier (pp, TYPE_NAME (node));
1085 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
1086 && DECL_NAME (TYPE_NAME (node)))
1087 dump_decl_name (pp, TYPE_NAME (node), flags);
1088 else
1089 pp_string (pp, "<unnamed type>");
1091 else if (TREE_CODE (node) == VECTOR_TYPE)
1093 pp_string (pp, "vector");
1094 pp_left_paren (pp);
1095 pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (node));
1096 pp_string (pp, ") ");
1097 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1099 else if (TREE_CODE (node) == INTEGER_TYPE)
1101 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
1102 pp_string (pp, (TYPE_UNSIGNED (node)
1103 ? "unsigned char"
1104 : "signed char"));
1105 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
1106 pp_string (pp, (TYPE_UNSIGNED (node)
1107 ? "unsigned short"
1108 : "signed short"));
1109 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
1110 pp_string (pp, (TYPE_UNSIGNED (node)
1111 ? "unsigned int"
1112 : "signed int"));
1113 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
1114 pp_string (pp, (TYPE_UNSIGNED (node)
1115 ? "unsigned long"
1116 : "signed long"));
1117 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
1118 pp_string (pp, (TYPE_UNSIGNED (node)
1119 ? "unsigned long long"
1120 : "signed long long"));
1121 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
1122 && exact_log2 (TYPE_PRECISION (node)) != -1)
1124 pp_string (pp, (TYPE_UNSIGNED (node) ? "uint" : "int"));
1125 pp_decimal_int (pp, TYPE_PRECISION (node));
1126 pp_string (pp, "_t");
1128 else
1130 pp_string (pp, (TYPE_UNSIGNED (node)
1131 ? "<unnamed-unsigned:"
1132 : "<unnamed-signed:"));
1133 pp_decimal_int (pp, TYPE_PRECISION (node));
1134 pp_greater (pp);
1137 else if (TREE_CODE (node) == COMPLEX_TYPE)
1139 pp_string (pp, "__complex__ ");
1140 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1142 else if (TREE_CODE (node) == REAL_TYPE)
1144 pp_string (pp, "<float:");
1145 pp_decimal_int (pp, TYPE_PRECISION (node));
1146 pp_greater (pp);
1148 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
1150 pp_string (pp, "<fixed-point-");
1151 pp_string (pp, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
1152 pp_decimal_int (pp, TYPE_PRECISION (node));
1153 pp_greater (pp);
1155 else if (TREE_CODE (node) == VOID_TYPE)
1156 pp_string (pp, "void");
1157 else
1158 pp_string (pp, "<unnamed type>");
1160 break;
1163 case POINTER_TYPE:
1164 case REFERENCE_TYPE:
1165 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1167 if (TREE_TYPE (node) == NULL)
1169 pp_string (pp, str);
1170 pp_string (pp, "<null type>");
1172 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1174 tree fnode = TREE_TYPE (node);
1176 dump_generic_node (pp, TREE_TYPE (fnode), spc, flags, false);
1177 pp_space (pp);
1178 pp_left_paren (pp);
1179 pp_string (pp, str);
1180 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1181 dump_decl_name (pp, TYPE_NAME (node), flags);
1182 else if (flags & TDF_NOUID)
1183 pp_printf (pp, "<Txxxx>");
1184 else
1185 pp_printf (pp, "<T%x>", TYPE_UID (node));
1187 pp_right_paren (pp);
1188 dump_function_declaration (pp, fnode, spc, flags);
1190 else
1192 unsigned int quals = TYPE_QUALS (node);
1194 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1195 pp_space (pp);
1196 pp_string (pp, str);
1198 if (quals & TYPE_QUAL_CONST)
1199 pp_string (pp, " const");
1200 if (quals & TYPE_QUAL_VOLATILE)
1201 pp_string (pp, " volatile");
1202 if (quals & TYPE_QUAL_RESTRICT)
1203 pp_string (pp, " restrict");
1205 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1207 pp_string (pp, " <address-space-");
1208 pp_decimal_int (pp, TYPE_ADDR_SPACE (node));
1209 pp_greater (pp);
1212 if (TYPE_REF_CAN_ALIAS_ALL (node))
1213 pp_string (pp, " {ref-all}");
1215 break;
1217 case OFFSET_TYPE:
1218 NIY;
1219 break;
1221 case MEM_REF:
1223 if (integer_zerop (TREE_OPERAND (node, 1))
1224 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1225 infer them and MEM_ATTR caching will share MEM_REFs
1226 with differently-typed op0s. */
1227 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1228 /* Released SSA_NAMES have no TREE_TYPE. */
1229 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1230 /* Same pointer types, but ignoring POINTER_TYPE vs.
1231 REFERENCE_TYPE. */
1232 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1233 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1234 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1235 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1236 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1237 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1238 /* Same value types ignoring qualifiers. */
1239 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1240 == TYPE_MAIN_VARIANT
1241 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1)))))
1242 && (!(flags & TDF_ALIAS)
1243 || MR_DEPENDENCE_CLIQUE (node) == 0))
1245 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1247 pp_star (pp);
1248 dump_generic_node (pp, TREE_OPERAND (node, 0),
1249 spc, flags, false);
1251 else
1252 dump_generic_node (pp,
1253 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1254 spc, flags, false);
1256 else
1258 tree ptype;
1260 pp_string (pp, "MEM[");
1261 pp_left_paren (pp);
1262 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1263 dump_generic_node (pp, ptype,
1264 spc, flags | TDF_SLIM, false);
1265 pp_right_paren (pp);
1266 dump_generic_node (pp, TREE_OPERAND (node, 0),
1267 spc, flags, false);
1268 if (!integer_zerop (TREE_OPERAND (node, 1)))
1270 pp_string (pp, " + ");
1271 dump_generic_node (pp, TREE_OPERAND (node, 1),
1272 spc, flags, false);
1274 if ((flags & TDF_ALIAS)
1275 && MR_DEPENDENCE_CLIQUE (node) != 0)
1277 pp_string (pp, " clique ");
1278 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_CLIQUE (node));
1279 pp_string (pp, " base ");
1280 pp_unsigned_wide_integer (pp, MR_DEPENDENCE_BASE (node));
1282 pp_right_bracket (pp);
1284 break;
1287 case TARGET_MEM_REF:
1289 const char *sep = "";
1290 tree tmp;
1292 pp_string (pp, "MEM[");
1294 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1296 pp_string (pp, sep);
1297 sep = ", ";
1298 pp_string (pp, "symbol: ");
1299 dump_generic_node (pp, TREE_OPERAND (TMR_BASE (node), 0),
1300 spc, flags, false);
1302 else
1304 pp_string (pp, sep);
1305 sep = ", ";
1306 pp_string (pp, "base: ");
1307 dump_generic_node (pp, TMR_BASE (node), spc, flags, false);
1309 tmp = TMR_INDEX2 (node);
1310 if (tmp)
1312 pp_string (pp, sep);
1313 sep = ", ";
1314 pp_string (pp, "base: ");
1315 dump_generic_node (pp, tmp, spc, flags, false);
1317 tmp = TMR_INDEX (node);
1318 if (tmp)
1320 pp_string (pp, sep);
1321 sep = ", ";
1322 pp_string (pp, "index: ");
1323 dump_generic_node (pp, tmp, spc, flags, false);
1325 tmp = TMR_STEP (node);
1326 if (tmp)
1328 pp_string (pp, sep);
1329 sep = ", ";
1330 pp_string (pp, "step: ");
1331 dump_generic_node (pp, tmp, spc, flags, false);
1333 tmp = TMR_OFFSET (node);
1334 if (tmp)
1336 pp_string (pp, sep);
1337 sep = ", ";
1338 pp_string (pp, "offset: ");
1339 dump_generic_node (pp, tmp, spc, flags, false);
1341 pp_right_bracket (pp);
1343 break;
1345 case ARRAY_TYPE:
1347 tree tmp;
1349 /* Print the innermost component type. */
1350 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1351 tmp = TREE_TYPE (tmp))
1353 dump_generic_node (pp, tmp, spc, flags, false);
1355 /* Print the dimensions. */
1356 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1357 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
1358 break;
1361 case RECORD_TYPE:
1362 case UNION_TYPE:
1363 case QUAL_UNION_TYPE:
1365 unsigned int quals = TYPE_QUALS (node);
1367 if (quals & TYPE_QUAL_ATOMIC)
1368 pp_string (pp, "atomic ");
1369 if (quals & TYPE_QUAL_CONST)
1370 pp_string (pp, "const ");
1371 if (quals & TYPE_QUAL_VOLATILE)
1372 pp_string (pp, "volatile ");
1374 /* Print the name of the structure. */
1375 if (TREE_CODE (node) == RECORD_TYPE)
1376 pp_string (pp, "struct ");
1377 else if (TREE_CODE (node) == UNION_TYPE)
1378 pp_string (pp, "union ");
1380 if (TYPE_NAME (node))
1381 dump_generic_node (pp, TYPE_NAME (node), spc, flags, false);
1382 else if (!(flags & TDF_SLIM))
1383 /* FIXME: If we eliminate the 'else' above and attempt
1384 to show the fields for named types, we may get stuck
1385 following a cycle of pointers to structs. The alleged
1386 self-reference check in print_struct_decl will not detect
1387 cycles involving more than one pointer or struct type. */
1388 print_struct_decl (pp, node, spc, flags);
1389 break;
1392 case LANG_TYPE:
1393 NIY;
1394 break;
1396 case INTEGER_CST:
1397 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1399 /* In the case of a pointer, one may want to divide by the
1400 size of the pointed-to type. Unfortunately, this not
1401 straightforward. The C front-end maps expressions
1403 (int *) 5
1404 int *p; (p + 5)
1406 in such a way that the two INTEGER_CST nodes for "5" have
1407 different values but identical types. In the latter
1408 case, the 5 is multiplied by sizeof (int) in c-common.c
1409 (pointer_int_sum) to convert it to a byte address, and
1410 yet the type of the node is left unchanged. Argh. What
1411 is consistent though is that the number value corresponds
1412 to bytes (UNITS) offset.
1414 NB: Neither of the following divisors can be trivially
1415 used to recover the original literal:
1417 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1418 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1419 pp_wide_integer (pp, TREE_INT_CST_LOW (node));
1420 pp_string (pp, "B"); /* pseudo-unit */
1422 else if (tree_fits_shwi_p (node))
1423 pp_wide_integer (pp, tree_to_shwi (node));
1424 else if (tree_fits_uhwi_p (node))
1425 pp_unsigned_wide_integer (pp, tree_to_uhwi (node));
1426 else
1428 wide_int val = node;
1430 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1432 pp_minus (pp);
1433 val = -val;
1435 print_hex (val, pp_buffer (pp)->digit_buffer);
1436 pp_string (pp, pp_buffer (pp)->digit_buffer);
1438 if (TREE_OVERFLOW (node))
1439 pp_string (pp, "(OVF)");
1440 break;
1442 case REAL_CST:
1443 /* Code copied from print_node. */
1445 REAL_VALUE_TYPE d;
1446 if (TREE_OVERFLOW (node))
1447 pp_string (pp, " overflow");
1449 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1450 d = TREE_REAL_CST (node);
1451 if (REAL_VALUE_ISINF (d))
1452 pp_string (pp, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1453 else if (REAL_VALUE_ISNAN (d))
1454 pp_string (pp, " Nan");
1455 else
1457 char string[100];
1458 real_to_decimal (string, &d, sizeof (string), 0, 1);
1459 pp_string (pp, string);
1461 #else
1463 HOST_WIDE_INT i;
1464 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1465 pp_string (pp, "0x");
1466 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1467 output_formatted_integer (pp, "%02x", *p++);
1469 #endif
1470 break;
1473 case FIXED_CST:
1475 char string[100];
1476 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1477 pp_string (pp, string);
1478 break;
1481 case COMPLEX_CST:
1482 pp_string (pp, "__complex__ (");
1483 dump_generic_node (pp, TREE_REALPART (node), spc, flags, false);
1484 pp_string (pp, ", ");
1485 dump_generic_node (pp, TREE_IMAGPART (node), spc, flags, false);
1486 pp_right_paren (pp);
1487 break;
1489 case STRING_CST:
1490 pp_string (pp, "\"");
1491 pretty_print_string (pp, TREE_STRING_POINTER (node));
1492 pp_string (pp, "\"");
1493 break;
1495 case VECTOR_CST:
1497 unsigned i;
1498 pp_string (pp, "{ ");
1499 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1501 if (i != 0)
1502 pp_string (pp, ", ");
1503 dump_generic_node (pp, VECTOR_CST_ELT (node, i),
1504 spc, flags, false);
1506 pp_string (pp, " }");
1508 break;
1510 case FUNCTION_TYPE:
1511 case METHOD_TYPE:
1512 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1513 pp_space (pp);
1514 if (TREE_CODE (node) == METHOD_TYPE)
1516 if (TYPE_METHOD_BASETYPE (node))
1517 dump_decl_name (pp, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1518 flags);
1519 else
1520 pp_string (pp, "<null method basetype>");
1521 pp_colon_colon (pp);
1523 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1524 dump_decl_name (pp, TYPE_NAME (node), flags);
1525 else if (flags & TDF_NOUID)
1526 pp_printf (pp, "<Txxxx>");
1527 else
1528 pp_printf (pp, "<T%x>", TYPE_UID (node));
1529 dump_function_declaration (pp, node, spc, flags);
1530 break;
1532 case FUNCTION_DECL:
1533 case CONST_DECL:
1534 dump_decl_name (pp, node, flags);
1535 break;
1537 case LABEL_DECL:
1538 if (DECL_NAME (node))
1539 dump_decl_name (pp, node, flags);
1540 else if (LABEL_DECL_UID (node) != -1)
1541 pp_printf (pp, "<L%d>", (int) LABEL_DECL_UID (node));
1542 else
1544 if (flags & TDF_NOUID)
1545 pp_string (pp, "<D.xxxx>");
1546 else
1547 pp_printf (pp, "<D.%u>", DECL_UID (node));
1549 break;
1551 case TYPE_DECL:
1552 if (DECL_IS_BUILTIN (node))
1554 /* Don't print the declaration of built-in types. */
1555 break;
1557 if (DECL_NAME (node))
1558 dump_decl_name (pp, node, flags);
1559 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1561 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1562 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1563 && TYPE_METHODS (TREE_TYPE (node)))
1565 /* The type is a c++ class: all structures have at least
1566 4 methods. */
1567 pp_string (pp, "class ");
1568 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1570 else
1572 pp_string (pp,
1573 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1574 ? "union" : "struct "));
1575 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1578 else
1579 pp_string (pp, "<anon>");
1580 break;
1582 case VAR_DECL:
1583 case PARM_DECL:
1584 case FIELD_DECL:
1585 case DEBUG_EXPR_DECL:
1586 case NAMESPACE_DECL:
1587 case NAMELIST_DECL:
1588 dump_decl_name (pp, node, flags);
1589 break;
1591 case RESULT_DECL:
1592 pp_string (pp, "<retval>");
1593 break;
1595 case COMPONENT_REF:
1596 op0 = TREE_OPERAND (node, 0);
1597 str = ".";
1598 if (op0
1599 && (TREE_CODE (op0) == INDIRECT_REF
1600 || (TREE_CODE (op0) == MEM_REF
1601 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1602 && integer_zerop (TREE_OPERAND (op0, 1))
1603 /* Dump the types of INTEGER_CSTs explicitly, for we
1604 can't infer them and MEM_ATTR caching will share
1605 MEM_REFs with differently-typed op0s. */
1606 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1607 /* Released SSA_NAMES have no TREE_TYPE. */
1608 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1609 /* Same pointer types, but ignoring POINTER_TYPE vs.
1610 REFERENCE_TYPE. */
1611 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1612 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1613 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1614 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1615 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1616 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1617 /* Same value types ignoring qualifiers. */
1618 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1619 == TYPE_MAIN_VARIANT
1620 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1)))))
1621 && MR_DEPENDENCE_CLIQUE (op0) == 0)))
1623 op0 = TREE_OPERAND (op0, 0);
1624 str = "->";
1626 if (op_prio (op0) < op_prio (node))
1627 pp_left_paren (pp);
1628 dump_generic_node (pp, op0, spc, flags, false);
1629 if (op_prio (op0) < op_prio (node))
1630 pp_right_paren (pp);
1631 pp_string (pp, str);
1632 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1633 op0 = component_ref_field_offset (node);
1634 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1636 pp_string (pp, "{off: ");
1637 dump_generic_node (pp, op0, spc, flags, false);
1638 pp_right_brace (pp);
1640 break;
1642 case BIT_FIELD_REF:
1643 pp_string (pp, "BIT_FIELD_REF <");
1644 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1645 pp_string (pp, ", ");
1646 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1647 pp_string (pp, ", ");
1648 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1649 pp_greater (pp);
1650 break;
1652 case ARRAY_REF:
1653 case ARRAY_RANGE_REF:
1654 op0 = TREE_OPERAND (node, 0);
1655 if (op_prio (op0) < op_prio (node))
1656 pp_left_paren (pp);
1657 dump_generic_node (pp, op0, spc, flags, false);
1658 if (op_prio (op0) < op_prio (node))
1659 pp_right_paren (pp);
1660 pp_left_bracket (pp);
1661 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1662 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1663 pp_string (pp, " ...");
1664 pp_right_bracket (pp);
1666 op0 = array_ref_low_bound (node);
1667 op1 = array_ref_element_size (node);
1669 if (!integer_zerop (op0)
1670 || TREE_OPERAND (node, 2)
1671 || TREE_OPERAND (node, 3))
1673 pp_string (pp, "{lb: ");
1674 dump_generic_node (pp, op0, spc, flags, false);
1675 pp_string (pp, " sz: ");
1676 dump_generic_node (pp, op1, spc, flags, false);
1677 pp_right_brace (pp);
1679 break;
1681 case CONSTRUCTOR:
1683 unsigned HOST_WIDE_INT ix;
1684 tree field, val;
1685 bool is_struct_init = false;
1686 bool is_array_init = false;
1687 widest_int curidx;
1688 pp_left_brace (pp);
1689 if (TREE_CLOBBER_P (node))
1690 pp_string (pp, "CLOBBER");
1691 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1692 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1693 is_struct_init = true;
1694 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1695 && TYPE_DOMAIN (TREE_TYPE (node))
1696 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1697 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1698 == INTEGER_CST)
1700 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1701 is_array_init = true;
1702 curidx = wi::to_widest (minv);
1704 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1706 if (field)
1708 if (is_struct_init)
1710 pp_dot (pp);
1711 dump_generic_node (pp, field, spc, flags, false);
1712 pp_equal (pp);
1714 else if (is_array_init
1715 && (TREE_CODE (field) != INTEGER_CST
1716 || curidx != wi::to_widest (field)))
1718 pp_left_bracket (pp);
1719 if (TREE_CODE (field) == RANGE_EXPR)
1721 dump_generic_node (pp, TREE_OPERAND (field, 0), spc,
1722 flags, false);
1723 pp_string (pp, " ... ");
1724 dump_generic_node (pp, TREE_OPERAND (field, 1), spc,
1725 flags, false);
1726 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1727 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1729 else
1730 dump_generic_node (pp, field, spc, flags, false);
1731 if (TREE_CODE (field) == INTEGER_CST)
1732 curidx = wi::to_widest (field);
1733 pp_string (pp, "]=");
1736 if (is_array_init)
1737 curidx += 1;
1738 if (val && TREE_CODE (val) == ADDR_EXPR)
1739 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1740 val = TREE_OPERAND (val, 0);
1741 if (val && TREE_CODE (val) == FUNCTION_DECL)
1742 dump_decl_name (pp, val, flags);
1743 else
1744 dump_generic_node (pp, val, spc, flags, false);
1745 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1747 pp_comma (pp);
1748 pp_space (pp);
1751 pp_right_brace (pp);
1753 break;
1755 case COMPOUND_EXPR:
1757 tree *tp;
1758 if (flags & TDF_SLIM)
1760 pp_string (pp, "<COMPOUND_EXPR>");
1761 break;
1764 dump_generic_node (pp, TREE_OPERAND (node, 0),
1765 spc, flags, !(flags & TDF_SLIM));
1766 if (flags & TDF_SLIM)
1767 newline_and_indent (pp, spc);
1768 else
1770 pp_comma (pp);
1771 pp_space (pp);
1774 for (tp = &TREE_OPERAND (node, 1);
1775 TREE_CODE (*tp) == COMPOUND_EXPR;
1776 tp = &TREE_OPERAND (*tp, 1))
1778 dump_generic_node (pp, TREE_OPERAND (*tp, 0),
1779 spc, flags, !(flags & TDF_SLIM));
1780 if (flags & TDF_SLIM)
1781 newline_and_indent (pp, spc);
1782 else
1784 pp_comma (pp);
1785 pp_space (pp);
1789 dump_generic_node (pp, *tp, spc, flags, !(flags & TDF_SLIM));
1791 break;
1793 case STATEMENT_LIST:
1795 tree_stmt_iterator si;
1796 bool first = true;
1798 if (flags & TDF_SLIM)
1800 pp_string (pp, "<STATEMENT_LIST>");
1801 break;
1804 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1806 if (!first)
1807 newline_and_indent (pp, spc);
1808 else
1809 first = false;
1810 dump_generic_node (pp, tsi_stmt (si), spc, flags, true);
1813 break;
1815 case MODIFY_EXPR:
1816 case INIT_EXPR:
1817 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags,
1818 false);
1819 pp_space (pp);
1820 pp_equal (pp);
1821 pp_space (pp);
1822 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags,
1823 false);
1824 break;
1826 case TARGET_EXPR:
1827 pp_string (pp, "TARGET_EXPR <");
1828 dump_generic_node (pp, TARGET_EXPR_SLOT (node), spc, flags, false);
1829 pp_comma (pp);
1830 pp_space (pp);
1831 dump_generic_node (pp, TARGET_EXPR_INITIAL (node), spc, flags, false);
1832 pp_greater (pp);
1833 break;
1835 case DECL_EXPR:
1836 print_declaration (pp, DECL_EXPR_DECL (node), spc, flags);
1837 is_stmt = false;
1838 break;
1840 case COND_EXPR:
1841 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1843 pp_string (pp, "if (");
1844 dump_generic_node (pp, COND_EXPR_COND (node), spc, flags, false);
1845 pp_right_paren (pp);
1846 /* The lowered cond_exprs should always be printed in full. */
1847 if (COND_EXPR_THEN (node)
1848 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1849 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1850 && COND_EXPR_ELSE (node)
1851 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1852 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1854 pp_space (pp);
1855 dump_generic_node (pp, COND_EXPR_THEN (node),
1856 0, flags, true);
1857 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1859 pp_string (pp, " else ");
1860 dump_generic_node (pp, COND_EXPR_ELSE (node),
1861 0, flags, true);
1864 else if (!(flags & TDF_SLIM))
1866 /* Output COND_EXPR_THEN. */
1867 if (COND_EXPR_THEN (node))
1869 newline_and_indent (pp, spc+2);
1870 pp_left_brace (pp);
1871 newline_and_indent (pp, spc+4);
1872 dump_generic_node (pp, COND_EXPR_THEN (node), spc+4,
1873 flags, true);
1874 newline_and_indent (pp, spc+2);
1875 pp_right_brace (pp);
1878 /* Output COND_EXPR_ELSE. */
1879 if (COND_EXPR_ELSE (node)
1880 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1882 newline_and_indent (pp, spc);
1883 pp_string (pp, "else");
1884 newline_and_indent (pp, spc+2);
1885 pp_left_brace (pp);
1886 newline_and_indent (pp, spc+4);
1887 dump_generic_node (pp, COND_EXPR_ELSE (node), spc+4,
1888 flags, true);
1889 newline_and_indent (pp, spc+2);
1890 pp_right_brace (pp);
1893 is_expr = false;
1895 else
1897 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1898 pp_space (pp);
1899 pp_question (pp);
1900 pp_space (pp);
1901 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
1902 pp_space (pp);
1903 pp_colon (pp);
1904 pp_space (pp);
1905 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
1907 break;
1909 case BIND_EXPR:
1910 pp_left_brace (pp);
1911 if (!(flags & TDF_SLIM))
1913 if (BIND_EXPR_VARS (node))
1915 pp_newline (pp);
1917 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1919 print_declaration (pp, op0, spc+2, flags);
1920 pp_newline (pp);
1924 newline_and_indent (pp, spc+2);
1925 dump_generic_node (pp, BIND_EXPR_BODY (node), spc+2, flags, true);
1926 newline_and_indent (pp, spc);
1927 pp_right_brace (pp);
1929 is_expr = false;
1930 break;
1932 case CALL_EXPR:
1933 if (CALL_EXPR_FN (node) != NULL_TREE)
1934 print_call_name (pp, CALL_EXPR_FN (node), flags);
1935 else
1936 pp_string (pp, internal_fn_name (CALL_EXPR_IFN (node)));
1938 /* Print parameters. */
1939 pp_space (pp);
1940 pp_left_paren (pp);
1942 tree arg;
1943 call_expr_arg_iterator iter;
1944 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1946 dump_generic_node (pp, arg, spc, flags, false);
1947 if (more_call_expr_args_p (&iter))
1949 pp_comma (pp);
1950 pp_space (pp);
1954 if (CALL_EXPR_VA_ARG_PACK (node))
1956 if (call_expr_nargs (node) > 0)
1958 pp_comma (pp);
1959 pp_space (pp);
1961 pp_string (pp, "__builtin_va_arg_pack ()");
1963 pp_right_paren (pp);
1965 op1 = CALL_EXPR_STATIC_CHAIN (node);
1966 if (op1)
1968 pp_string (pp, " [static-chain: ");
1969 dump_generic_node (pp, op1, spc, flags, false);
1970 pp_right_bracket (pp);
1973 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1974 pp_string (pp, " [return slot optimization]");
1975 if (CALL_EXPR_TAILCALL (node))
1976 pp_string (pp, " [tail call]");
1977 break;
1979 case WITH_CLEANUP_EXPR:
1980 NIY;
1981 break;
1983 case CLEANUP_POINT_EXPR:
1984 pp_string (pp, "<<cleanup_point ");
1985 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
1986 pp_string (pp, ">>");
1987 break;
1989 case PLACEHOLDER_EXPR:
1990 pp_string (pp, "<PLACEHOLDER_EXPR ");
1991 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
1992 pp_greater (pp);
1993 break;
1995 /* Binary arithmetic and logic expressions. */
1996 case WIDEN_SUM_EXPR:
1997 case WIDEN_MULT_EXPR:
1998 case MULT_EXPR:
1999 case MULT_HIGHPART_EXPR:
2000 case PLUS_EXPR:
2001 case POINTER_PLUS_EXPR:
2002 case MINUS_EXPR:
2003 case TRUNC_DIV_EXPR:
2004 case CEIL_DIV_EXPR:
2005 case FLOOR_DIV_EXPR:
2006 case ROUND_DIV_EXPR:
2007 case TRUNC_MOD_EXPR:
2008 case CEIL_MOD_EXPR:
2009 case FLOOR_MOD_EXPR:
2010 case ROUND_MOD_EXPR:
2011 case RDIV_EXPR:
2012 case EXACT_DIV_EXPR:
2013 case LSHIFT_EXPR:
2014 case RSHIFT_EXPR:
2015 case LROTATE_EXPR:
2016 case RROTATE_EXPR:
2017 case WIDEN_LSHIFT_EXPR:
2018 case BIT_IOR_EXPR:
2019 case BIT_XOR_EXPR:
2020 case BIT_AND_EXPR:
2021 case TRUTH_ANDIF_EXPR:
2022 case TRUTH_ORIF_EXPR:
2023 case TRUTH_AND_EXPR:
2024 case TRUTH_OR_EXPR:
2025 case TRUTH_XOR_EXPR:
2026 case LT_EXPR:
2027 case LE_EXPR:
2028 case GT_EXPR:
2029 case GE_EXPR:
2030 case EQ_EXPR:
2031 case NE_EXPR:
2032 case UNLT_EXPR:
2033 case UNLE_EXPR:
2034 case UNGT_EXPR:
2035 case UNGE_EXPR:
2036 case UNEQ_EXPR:
2037 case LTGT_EXPR:
2038 case ORDERED_EXPR:
2039 case UNORDERED_EXPR:
2041 const char *op = op_symbol (node);
2042 op0 = TREE_OPERAND (node, 0);
2043 op1 = TREE_OPERAND (node, 1);
2045 /* When the operands are expressions with less priority,
2046 keep semantics of the tree representation. */
2047 if (op_prio (op0) <= op_prio (node))
2049 pp_left_paren (pp);
2050 dump_generic_node (pp, op0, spc, flags, false);
2051 pp_right_paren (pp);
2053 else
2054 dump_generic_node (pp, op0, spc, flags, false);
2056 pp_space (pp);
2057 pp_string (pp, op);
2058 pp_space (pp);
2060 /* When the operands are expressions with less priority,
2061 keep semantics of the tree representation. */
2062 if (op_prio (op1) <= op_prio (node))
2064 pp_left_paren (pp);
2065 dump_generic_node (pp, op1, spc, flags, false);
2066 pp_right_paren (pp);
2068 else
2069 dump_generic_node (pp, op1, spc, flags, false);
2071 break;
2073 /* Unary arithmetic and logic expressions. */
2074 case NEGATE_EXPR:
2075 case BIT_NOT_EXPR:
2076 case TRUTH_NOT_EXPR:
2077 case ADDR_EXPR:
2078 case PREDECREMENT_EXPR:
2079 case PREINCREMENT_EXPR:
2080 case INDIRECT_REF:
2081 if (TREE_CODE (node) == ADDR_EXPR
2082 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
2083 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
2084 ; /* Do not output '&' for strings and function pointers. */
2085 else
2086 pp_string (pp, op_symbol (node));
2088 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2090 pp_left_paren (pp);
2091 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2092 pp_right_paren (pp);
2094 else
2095 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2096 break;
2098 case POSTDECREMENT_EXPR:
2099 case POSTINCREMENT_EXPR:
2100 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
2102 pp_left_paren (pp);
2103 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2104 pp_right_paren (pp);
2106 else
2107 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2108 pp_string (pp, op_symbol (node));
2109 break;
2111 case MIN_EXPR:
2112 pp_string (pp, "MIN_EXPR <");
2113 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2114 pp_string (pp, ", ");
2115 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2116 pp_greater (pp);
2117 break;
2119 case MAX_EXPR:
2120 pp_string (pp, "MAX_EXPR <");
2121 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2122 pp_string (pp, ", ");
2123 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2124 pp_greater (pp);
2125 break;
2127 case ABS_EXPR:
2128 pp_string (pp, "ABS_EXPR <");
2129 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2130 pp_greater (pp);
2131 break;
2133 case RANGE_EXPR:
2134 NIY;
2135 break;
2137 case ADDR_SPACE_CONVERT_EXPR:
2138 case FIXED_CONVERT_EXPR:
2139 case FIX_TRUNC_EXPR:
2140 case FLOAT_EXPR:
2141 CASE_CONVERT:
2142 type = TREE_TYPE (node);
2143 op0 = TREE_OPERAND (node, 0);
2144 if (type != TREE_TYPE (op0))
2146 pp_left_paren (pp);
2147 dump_generic_node (pp, type, spc, flags, false);
2148 pp_string (pp, ") ");
2150 if (op_prio (op0) < op_prio (node))
2151 pp_left_paren (pp);
2152 dump_generic_node (pp, op0, spc, flags, false);
2153 if (op_prio (op0) < op_prio (node))
2154 pp_right_paren (pp);
2155 break;
2157 case VIEW_CONVERT_EXPR:
2158 pp_string (pp, "VIEW_CONVERT_EXPR<");
2159 dump_generic_node (pp, TREE_TYPE (node), spc, flags, false);
2160 pp_string (pp, ">(");
2161 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2162 pp_right_paren (pp);
2163 break;
2165 case PAREN_EXPR:
2166 pp_string (pp, "((");
2167 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2168 pp_string (pp, "))");
2169 break;
2171 case NON_LVALUE_EXPR:
2172 pp_string (pp, "NON_LVALUE_EXPR <");
2173 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2174 pp_greater (pp);
2175 break;
2177 case SAVE_EXPR:
2178 pp_string (pp, "SAVE_EXPR <");
2179 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2180 pp_greater (pp);
2181 break;
2183 case COMPLEX_EXPR:
2184 pp_string (pp, "COMPLEX_EXPR <");
2185 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2186 pp_string (pp, ", ");
2187 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2188 pp_greater (pp);
2189 break;
2191 case CONJ_EXPR:
2192 pp_string (pp, "CONJ_EXPR <");
2193 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2194 pp_greater (pp);
2195 break;
2197 case REALPART_EXPR:
2198 pp_string (pp, "REALPART_EXPR <");
2199 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2200 pp_greater (pp);
2201 break;
2203 case IMAGPART_EXPR:
2204 pp_string (pp, "IMAGPART_EXPR <");
2205 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2206 pp_greater (pp);
2207 break;
2209 case VA_ARG_EXPR:
2210 pp_string (pp, "VA_ARG_EXPR <");
2211 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2212 pp_greater (pp);
2213 break;
2215 case TRY_FINALLY_EXPR:
2216 case TRY_CATCH_EXPR:
2217 pp_string (pp, "try");
2218 newline_and_indent (pp, spc+2);
2219 pp_left_brace (pp);
2220 newline_and_indent (pp, spc+4);
2221 dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, flags, true);
2222 newline_and_indent (pp, spc+2);
2223 pp_right_brace (pp);
2224 newline_and_indent (pp, spc);
2225 pp_string (pp,
2226 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2227 newline_and_indent (pp, spc+2);
2228 pp_left_brace (pp);
2229 newline_and_indent (pp, spc+4);
2230 dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true);
2231 newline_and_indent (pp, spc+2);
2232 pp_right_brace (pp);
2233 is_expr = false;
2234 break;
2236 case CATCH_EXPR:
2237 pp_string (pp, "catch (");
2238 dump_generic_node (pp, CATCH_TYPES (node), spc+2, flags, false);
2239 pp_right_paren (pp);
2240 newline_and_indent (pp, spc+2);
2241 pp_left_brace (pp);
2242 newline_and_indent (pp, spc+4);
2243 dump_generic_node (pp, CATCH_BODY (node), spc+4, flags, true);
2244 newline_and_indent (pp, spc+2);
2245 pp_right_brace (pp);
2246 is_expr = false;
2247 break;
2249 case EH_FILTER_EXPR:
2250 pp_string (pp, "<<<eh_filter (");
2251 dump_generic_node (pp, EH_FILTER_TYPES (node), spc+2, flags, false);
2252 pp_string (pp, ")>>>");
2253 newline_and_indent (pp, spc+2);
2254 pp_left_brace (pp);
2255 newline_and_indent (pp, spc+4);
2256 dump_generic_node (pp, EH_FILTER_FAILURE (node), spc+4, flags, true);
2257 newline_and_indent (pp, spc+2);
2258 pp_right_brace (pp);
2259 is_expr = false;
2260 break;
2262 case LABEL_EXPR:
2263 op0 = TREE_OPERAND (node, 0);
2264 /* If this is for break or continue, don't bother printing it. */
2265 if (DECL_NAME (op0))
2267 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2268 if (strcmp (name, "break") == 0
2269 || strcmp (name, "continue") == 0)
2270 break;
2272 dump_generic_node (pp, op0, spc, flags, false);
2273 pp_colon (pp);
2274 if (DECL_NONLOCAL (op0))
2275 pp_string (pp, " [non-local]");
2276 break;
2278 case LOOP_EXPR:
2279 pp_string (pp, "while (1)");
2280 if (!(flags & TDF_SLIM))
2282 newline_and_indent (pp, spc+2);
2283 pp_left_brace (pp);
2284 newline_and_indent (pp, spc+4);
2285 dump_generic_node (pp, LOOP_EXPR_BODY (node), spc+4, flags, true);
2286 newline_and_indent (pp, spc+2);
2287 pp_right_brace (pp);
2289 is_expr = false;
2290 break;
2292 case PREDICT_EXPR:
2293 pp_string (pp, "// predicted ");
2294 if (PREDICT_EXPR_OUTCOME (node))
2295 pp_string (pp, "likely by ");
2296 else
2297 pp_string (pp, "unlikely by ");
2298 pp_string (pp, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2299 pp_string (pp, " predictor.");
2300 break;
2302 case ANNOTATE_EXPR:
2303 pp_string (pp, "ANNOTATE_EXPR <");
2304 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2305 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2307 case annot_expr_ivdep_kind:
2308 pp_string (pp, ", ivdep");
2309 break;
2310 case annot_expr_no_vector_kind:
2311 pp_string (pp, ", no-vector");
2312 break;
2313 case annot_expr_vector_kind:
2314 pp_string (pp, ", vector");
2315 break;
2316 default:
2317 gcc_unreachable ();
2319 pp_greater (pp);
2320 break;
2322 case RETURN_EXPR:
2323 pp_string (pp, "return");
2324 op0 = TREE_OPERAND (node, 0);
2325 if (op0)
2327 pp_space (pp);
2328 if (TREE_CODE (op0) == MODIFY_EXPR)
2329 dump_generic_node (pp, TREE_OPERAND (op0, 1),
2330 spc, flags, false);
2331 else
2332 dump_generic_node (pp, op0, spc, flags, false);
2334 break;
2336 case EXIT_EXPR:
2337 pp_string (pp, "if (");
2338 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2339 pp_string (pp, ") break");
2340 break;
2342 case SWITCH_EXPR:
2343 pp_string (pp, "switch (");
2344 dump_generic_node (pp, SWITCH_COND (node), spc, flags, false);
2345 pp_right_paren (pp);
2346 if (!(flags & TDF_SLIM))
2348 newline_and_indent (pp, spc+2);
2349 pp_left_brace (pp);
2350 if (SWITCH_BODY (node))
2352 newline_and_indent (pp, spc+4);
2353 dump_generic_node (pp, SWITCH_BODY (node), spc+4, flags,
2354 true);
2356 else
2358 tree vec = SWITCH_LABELS (node);
2359 size_t i, n = TREE_VEC_LENGTH (vec);
2360 for (i = 0; i < n; ++i)
2362 tree elt = TREE_VEC_ELT (vec, i);
2363 newline_and_indent (pp, spc+4);
2364 if (elt)
2366 dump_generic_node (pp, elt, spc+4, flags, false);
2367 pp_string (pp, " goto ");
2368 dump_generic_node (pp, CASE_LABEL (elt), spc+4,
2369 flags, true);
2370 pp_semicolon (pp);
2372 else
2373 pp_string (pp, "case ???: goto ???;");
2376 newline_and_indent (pp, spc+2);
2377 pp_right_brace (pp);
2379 is_expr = false;
2380 break;
2382 case GOTO_EXPR:
2383 op0 = GOTO_DESTINATION (node);
2384 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2386 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2387 if (strcmp (name, "break") == 0
2388 || strcmp (name, "continue") == 0)
2390 pp_string (pp, name);
2391 break;
2394 pp_string (pp, "goto ");
2395 dump_generic_node (pp, op0, spc, flags, false);
2396 break;
2398 case ASM_EXPR:
2399 pp_string (pp, "__asm__");
2400 if (ASM_VOLATILE_P (node))
2401 pp_string (pp, " __volatile__");
2402 pp_left_paren (pp);
2403 dump_generic_node (pp, ASM_STRING (node), spc, flags, false);
2404 pp_colon (pp);
2405 dump_generic_node (pp, ASM_OUTPUTS (node), spc, flags, false);
2406 pp_colon (pp);
2407 dump_generic_node (pp, ASM_INPUTS (node), spc, flags, false);
2408 if (ASM_CLOBBERS (node))
2410 pp_colon (pp);
2411 dump_generic_node (pp, ASM_CLOBBERS (node), spc, flags, false);
2413 pp_right_paren (pp);
2414 break;
2416 case CASE_LABEL_EXPR:
2417 if (CASE_LOW (node) && CASE_HIGH (node))
2419 pp_string (pp, "case ");
2420 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2421 pp_string (pp, " ... ");
2422 dump_generic_node (pp, CASE_HIGH (node), spc, flags, false);
2424 else if (CASE_LOW (node))
2426 pp_string (pp, "case ");
2427 dump_generic_node (pp, CASE_LOW (node), spc, flags, false);
2429 else
2430 pp_string (pp, "default");
2431 pp_colon (pp);
2432 break;
2434 case OBJ_TYPE_REF:
2435 pp_string (pp, "OBJ_TYPE_REF(");
2436 dump_generic_node (pp, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2437 pp_semicolon (pp);
2438 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2440 pp_string (pp, "(");
2441 dump_generic_node (pp, obj_type_ref_class (node), spc, flags, false);
2442 pp_string (pp, ")");
2444 dump_generic_node (pp, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2445 pp_arrow (pp);
2446 dump_generic_node (pp, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2447 pp_right_paren (pp);
2448 break;
2450 case SSA_NAME:
2451 if (SSA_NAME_IDENTIFIER (node))
2452 dump_generic_node (pp, SSA_NAME_IDENTIFIER (node),
2453 spc, flags, false);
2454 pp_underscore (pp);
2455 pp_decimal_int (pp, SSA_NAME_VERSION (node));
2456 if (SSA_NAME_IS_DEFAULT_DEF (node))
2457 pp_string (pp, "(D)");
2458 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2459 pp_string (pp, "(ab)");
2460 break;
2462 case WITH_SIZE_EXPR:
2463 pp_string (pp, "WITH_SIZE_EXPR <");
2464 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2465 pp_string (pp, ", ");
2466 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2467 pp_greater (pp);
2468 break;
2470 case ASSERT_EXPR:
2471 pp_string (pp, "ASSERT_EXPR <");
2472 dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
2473 pp_string (pp, ", ");
2474 dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
2475 pp_greater (pp);
2476 break;
2478 case SCEV_KNOWN:
2479 pp_string (pp, "scev_known");
2480 break;
2482 case SCEV_NOT_KNOWN:
2483 pp_string (pp, "scev_not_known");
2484 break;
2486 case POLYNOMIAL_CHREC:
2487 pp_left_brace (pp);
2488 dump_generic_node (pp, CHREC_LEFT (node), spc, flags, false);
2489 pp_string (pp, ", +, ");
2490 dump_generic_node (pp, CHREC_RIGHT (node), spc, flags, false);
2491 pp_string (pp, "}_");
2492 dump_generic_node (pp, CHREC_VAR (node), spc, flags, false);
2493 is_stmt = false;
2494 break;
2496 case REALIGN_LOAD_EXPR:
2497 pp_string (pp, "REALIGN_LOAD <");
2498 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2499 pp_string (pp, ", ");
2500 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2501 pp_string (pp, ", ");
2502 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2503 pp_greater (pp);
2504 break;
2506 case VEC_COND_EXPR:
2507 pp_string (pp, " VEC_COND_EXPR < ");
2508 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2509 pp_string (pp, " , ");
2510 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2511 pp_string (pp, " , ");
2512 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2513 pp_string (pp, " > ");
2514 break;
2516 case VEC_PERM_EXPR:
2517 pp_string (pp, " VEC_PERM_EXPR < ");
2518 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2519 pp_string (pp, " , ");
2520 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2521 pp_string (pp, " , ");
2522 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2523 pp_string (pp, " > ");
2524 break;
2526 case DOT_PROD_EXPR:
2527 pp_string (pp, " DOT_PROD_EXPR < ");
2528 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2529 pp_string (pp, ", ");
2530 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2531 pp_string (pp, ", ");
2532 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2533 pp_string (pp, " > ");
2534 break;
2536 case WIDEN_MULT_PLUS_EXPR:
2537 pp_string (pp, " WIDEN_MULT_PLUS_EXPR < ");
2538 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2539 pp_string (pp, ", ");
2540 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2541 pp_string (pp, ", ");
2542 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2543 pp_string (pp, " > ");
2544 break;
2546 case WIDEN_MULT_MINUS_EXPR:
2547 pp_string (pp, " WIDEN_MULT_MINUS_EXPR < ");
2548 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2549 pp_string (pp, ", ");
2550 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2551 pp_string (pp, ", ");
2552 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2553 pp_string (pp, " > ");
2554 break;
2556 case FMA_EXPR:
2557 pp_string (pp, " FMA_EXPR < ");
2558 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2559 pp_string (pp, ", ");
2560 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2561 pp_string (pp, ", ");
2562 dump_generic_node (pp, TREE_OPERAND (node, 2), spc, flags, false);
2563 pp_string (pp, " > ");
2564 break;
2566 case OACC_PARALLEL:
2567 pp_string (pp, "#pragma acc parallel");
2568 dump_omp_clauses (pp, OACC_PARALLEL_CLAUSES (node), spc, flags);
2569 goto dump_omp_body;
2571 case OACC_KERNELS:
2572 pp_string (pp, "#pragma acc kernels");
2573 dump_omp_clauses (pp, OACC_KERNELS_CLAUSES (node), spc, flags);
2574 goto dump_omp_body;
2576 case OACC_DATA:
2577 pp_string (pp, "#pragma acc data");
2578 dump_omp_clauses (pp, OACC_DATA_CLAUSES (node), spc, flags);
2579 goto dump_omp_body;
2581 case OACC_HOST_DATA:
2582 pp_string (pp, "#pragma acc host_data");
2583 dump_omp_clauses (pp, OACC_HOST_DATA_CLAUSES (node), spc, flags);
2584 goto dump_omp_body;
2586 case OACC_DECLARE:
2587 pp_string (pp, "#pragma acc declare");
2588 dump_omp_clauses (pp, OACC_DECLARE_CLAUSES (node), spc, flags);
2589 break;
2591 case OACC_UPDATE:
2592 pp_string (pp, "#pragma acc update");
2593 dump_omp_clauses (pp, OACC_UPDATE_CLAUSES (node), spc, flags);
2594 break;
2596 case OACC_ENTER_DATA:
2597 pp_string (pp, "#pragma acc enter data");
2598 dump_omp_clauses (pp, OACC_ENTER_DATA_CLAUSES (node), spc, flags);
2599 break;
2601 case OACC_EXIT_DATA:
2602 pp_string (pp, "#pragma acc exit data");
2603 dump_omp_clauses (pp, OACC_EXIT_DATA_CLAUSES (node), spc, flags);
2604 break;
2606 case OACC_CACHE:
2607 pp_string (pp, "#pragma acc cache");
2608 dump_omp_clauses (pp, OACC_CACHE_CLAUSES (node), spc, flags);
2609 break;
2611 case OMP_PARALLEL:
2612 pp_string (pp, "#pragma omp parallel");
2613 dump_omp_clauses (pp, OMP_PARALLEL_CLAUSES (node), spc, flags);
2615 dump_omp_body:
2616 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2618 newline_and_indent (pp, spc + 2);
2619 pp_left_brace (pp);
2620 newline_and_indent (pp, spc + 4);
2621 dump_generic_node (pp, OMP_BODY (node), spc + 4, flags, false);
2622 newline_and_indent (pp, spc + 2);
2623 pp_right_brace (pp);
2625 is_expr = false;
2626 break;
2628 case OMP_TASK:
2629 pp_string (pp, "#pragma omp task");
2630 dump_omp_clauses (pp, OMP_TASK_CLAUSES (node), spc, flags);
2631 goto dump_omp_body;
2633 case OMP_FOR:
2634 pp_string (pp, "#pragma omp for");
2635 goto dump_omp_loop;
2637 case OMP_SIMD:
2638 pp_string (pp, "#pragma omp simd");
2639 goto dump_omp_loop;
2641 case CILK_SIMD:
2642 pp_string (pp, "#pragma simd");
2643 goto dump_omp_loop;
2645 case CILK_FOR:
2646 /* This label points one line after dumping the clauses.
2647 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2648 parameters are printed out. */
2649 goto dump_omp_loop_cilk_for;
2651 case OMP_DISTRIBUTE:
2652 pp_string (pp, "#pragma omp distribute");
2653 goto dump_omp_loop;
2655 case OACC_LOOP:
2656 pp_string (pp, "#pragma acc loop");
2657 goto dump_omp_loop;
2659 case OMP_TEAMS:
2660 pp_string (pp, "#pragma omp teams");
2661 dump_omp_clauses (pp, OMP_TEAMS_CLAUSES (node), spc, flags);
2662 goto dump_omp_body;
2664 case OMP_TARGET_DATA:
2665 pp_string (pp, "#pragma omp target data");
2666 dump_omp_clauses (pp, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2667 goto dump_omp_body;
2669 case OMP_TARGET:
2670 pp_string (pp, "#pragma omp target");
2671 dump_omp_clauses (pp, OMP_TARGET_CLAUSES (node), spc, flags);
2672 goto dump_omp_body;
2674 case OMP_TARGET_UPDATE:
2675 pp_string (pp, "#pragma omp target update");
2676 dump_omp_clauses (pp, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2677 is_expr = false;
2678 break;
2680 dump_omp_loop:
2681 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2683 dump_omp_loop_cilk_for:
2684 if (!(flags & TDF_SLIM))
2686 int i;
2688 if (OMP_FOR_PRE_BODY (node))
2690 if (TREE_CODE (node) == CILK_FOR)
2691 pp_string (pp, " ");
2692 else
2693 newline_and_indent (pp, spc + 2);
2694 pp_left_brace (pp);
2695 spc += 4;
2696 newline_and_indent (pp, spc);
2697 dump_generic_node (pp, OMP_FOR_PRE_BODY (node),
2698 spc, flags, false);
2700 if (OMP_FOR_INIT (node))
2702 spc -= 2;
2703 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2705 spc += 2;
2706 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2707 newline_and_indent (pp, spc);
2708 if (TREE_CODE (node) == CILK_FOR)
2709 pp_string (pp, "_Cilk_for (");
2710 else
2711 pp_string (pp, "for (");
2712 dump_generic_node (pp,
2713 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2714 spc, flags, false);
2715 pp_string (pp, "; ");
2716 dump_generic_node (pp,
2717 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2718 spc, flags, false);
2719 pp_string (pp, "; ");
2720 dump_generic_node (pp,
2721 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2722 spc, flags, false);
2723 pp_right_paren (pp);
2725 if (TREE_CODE (node) == CILK_FOR)
2726 dump_omp_clauses (pp, OMP_FOR_CLAUSES (node), spc, flags);
2728 if (OMP_FOR_BODY (node))
2730 newline_and_indent (pp, spc + 2);
2731 pp_left_brace (pp);
2732 newline_and_indent (pp, spc + 4);
2733 dump_generic_node (pp, OMP_FOR_BODY (node), spc + 4, flags,
2734 false);
2735 newline_and_indent (pp, spc + 2);
2736 pp_right_brace (pp);
2738 if (OMP_FOR_INIT (node))
2739 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2740 if (OMP_FOR_PRE_BODY (node))
2742 spc -= 4;
2743 newline_and_indent (pp, spc + 2);
2744 pp_right_brace (pp);
2747 is_expr = false;
2748 break;
2750 case OMP_SECTIONS:
2751 pp_string (pp, "#pragma omp sections");
2752 dump_omp_clauses (pp, OMP_SECTIONS_CLAUSES (node), spc, flags);
2753 goto dump_omp_body;
2755 case OMP_SECTION:
2756 pp_string (pp, "#pragma omp section");
2757 goto dump_omp_body;
2759 case OMP_MASTER:
2760 pp_string (pp, "#pragma omp master");
2761 goto dump_omp_body;
2763 case OMP_TASKGROUP:
2764 pp_string (pp, "#pragma omp taskgroup");
2765 goto dump_omp_body;
2767 case OMP_ORDERED:
2768 pp_string (pp, "#pragma omp ordered");
2769 goto dump_omp_body;
2771 case OMP_CRITICAL:
2772 pp_string (pp, "#pragma omp critical");
2773 if (OMP_CRITICAL_NAME (node))
2775 pp_space (pp);
2776 pp_left_paren (pp);
2777 dump_generic_node (pp, OMP_CRITICAL_NAME (node), spc,
2778 flags, false);
2779 pp_right_paren (pp);
2781 goto dump_omp_body;
2783 case OMP_ATOMIC:
2784 pp_string (pp, "#pragma omp atomic");
2785 if (OMP_ATOMIC_SEQ_CST (node))
2786 pp_string (pp, " seq_cst");
2787 newline_and_indent (pp, spc + 2);
2788 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2789 pp_space (pp);
2790 pp_equal (pp);
2791 pp_space (pp);
2792 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2793 break;
2795 case OMP_ATOMIC_READ:
2796 pp_string (pp, "#pragma omp atomic read");
2797 if (OMP_ATOMIC_SEQ_CST (node))
2798 pp_string (pp, " seq_cst");
2799 newline_and_indent (pp, spc + 2);
2800 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2801 pp_space (pp);
2802 break;
2804 case OMP_ATOMIC_CAPTURE_OLD:
2805 case OMP_ATOMIC_CAPTURE_NEW:
2806 pp_string (pp, "#pragma omp atomic capture");
2807 if (OMP_ATOMIC_SEQ_CST (node))
2808 pp_string (pp, " seq_cst");
2809 newline_and_indent (pp, spc + 2);
2810 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2811 pp_space (pp);
2812 pp_equal (pp);
2813 pp_space (pp);
2814 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2815 break;
2817 case OMP_SINGLE:
2818 pp_string (pp, "#pragma omp single");
2819 dump_omp_clauses (pp, OMP_SINGLE_CLAUSES (node), spc, flags);
2820 goto dump_omp_body;
2822 case OMP_CLAUSE:
2823 dump_omp_clause (pp, node, spc, flags);
2824 is_expr = false;
2825 break;
2827 case TRANSACTION_EXPR:
2828 if (TRANSACTION_EXPR_OUTER (node))
2829 pp_string (pp, "__transaction_atomic [[outer]]");
2830 else if (TRANSACTION_EXPR_RELAXED (node))
2831 pp_string (pp, "__transaction_relaxed");
2832 else
2833 pp_string (pp, "__transaction_atomic");
2834 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2836 newline_and_indent (pp, spc);
2837 pp_left_brace (pp);
2838 newline_and_indent (pp, spc + 2);
2839 dump_generic_node (pp, TRANSACTION_EXPR_BODY (node),
2840 spc + 2, flags, false);
2841 newline_and_indent (pp, spc);
2842 pp_right_brace (pp);
2844 is_expr = false;
2845 break;
2847 case REDUC_MAX_EXPR:
2848 pp_string (pp, " REDUC_MAX_EXPR < ");
2849 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2850 pp_string (pp, " > ");
2851 break;
2853 case REDUC_MIN_EXPR:
2854 pp_string (pp, " REDUC_MIN_EXPR < ");
2855 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2856 pp_string (pp, " > ");
2857 break;
2859 case REDUC_PLUS_EXPR:
2860 pp_string (pp, " REDUC_PLUS_EXPR < ");
2861 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2862 pp_string (pp, " > ");
2863 break;
2865 case VEC_WIDEN_MULT_HI_EXPR:
2866 case VEC_WIDEN_MULT_LO_EXPR:
2867 case VEC_WIDEN_MULT_EVEN_EXPR:
2868 case VEC_WIDEN_MULT_ODD_EXPR:
2869 case VEC_WIDEN_LSHIFT_HI_EXPR:
2870 case VEC_WIDEN_LSHIFT_LO_EXPR:
2871 pp_space (pp);
2872 for (str = get_tree_code_name (code); *str; str++)
2873 pp_character (pp, TOUPPER (*str));
2874 pp_string (pp, " < ");
2875 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2876 pp_string (pp, ", ");
2877 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2878 pp_string (pp, " > ");
2879 break;
2881 case VEC_UNPACK_HI_EXPR:
2882 pp_string (pp, " VEC_UNPACK_HI_EXPR < ");
2883 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2884 pp_string (pp, " > ");
2885 break;
2887 case VEC_UNPACK_LO_EXPR:
2888 pp_string (pp, " VEC_UNPACK_LO_EXPR < ");
2889 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2890 pp_string (pp, " > ");
2891 break;
2893 case VEC_UNPACK_FLOAT_HI_EXPR:
2894 pp_string (pp, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2895 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2896 pp_string (pp, " > ");
2897 break;
2899 case VEC_UNPACK_FLOAT_LO_EXPR:
2900 pp_string (pp, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2901 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2902 pp_string (pp, " > ");
2903 break;
2905 case VEC_PACK_TRUNC_EXPR:
2906 pp_string (pp, " VEC_PACK_TRUNC_EXPR < ");
2907 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2908 pp_string (pp, ", ");
2909 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2910 pp_string (pp, " > ");
2911 break;
2913 case VEC_PACK_SAT_EXPR:
2914 pp_string (pp, " VEC_PACK_SAT_EXPR < ");
2915 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2916 pp_string (pp, ", ");
2917 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2918 pp_string (pp, " > ");
2919 break;
2921 case VEC_PACK_FIX_TRUNC_EXPR:
2922 pp_string (pp, " VEC_PACK_FIX_TRUNC_EXPR < ");
2923 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2924 pp_string (pp, ", ");
2925 dump_generic_node (pp, TREE_OPERAND (node, 1), spc, flags, false);
2926 pp_string (pp, " > ");
2927 break;
2929 case BLOCK:
2930 dump_block_node (pp, node, spc, flags);
2931 break;
2933 case CILK_SPAWN_STMT:
2934 pp_string (pp, "_Cilk_spawn ");
2935 dump_generic_node (pp, TREE_OPERAND (node, 0), spc, flags, false);
2936 break;
2938 case CILK_SYNC_STMT:
2939 pp_string (pp, "_Cilk_sync");
2940 break;
2942 default:
2943 NIY;
2946 if (is_stmt && is_expr)
2947 pp_semicolon (pp);
2949 return spc;
2952 /* Print the declaration of a variable. */
2954 void
2955 print_declaration (pretty_printer *pp, tree t, int spc, int flags)
2957 INDENT (spc);
2959 if (TREE_CODE(t) == NAMELIST_DECL)
2961 pp_string(pp, "namelist ");
2962 dump_decl_name (pp, t, flags);
2963 pp_semicolon (pp);
2964 return;
2967 if (TREE_CODE (t) == TYPE_DECL)
2968 pp_string (pp, "typedef ");
2970 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2971 pp_string (pp, "register ");
2973 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2974 pp_string (pp, "extern ");
2975 else if (TREE_STATIC (t))
2976 pp_string (pp, "static ");
2978 /* Print the type and name. */
2979 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2981 tree tmp;
2983 /* Print array's type. */
2984 tmp = TREE_TYPE (t);
2985 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2986 tmp = TREE_TYPE (tmp);
2987 dump_generic_node (pp, TREE_TYPE (tmp), spc, flags, false);
2989 /* Print variable's name. */
2990 pp_space (pp);
2991 dump_generic_node (pp, t, spc, flags, false);
2993 /* Print the dimensions. */
2994 tmp = TREE_TYPE (t);
2995 while (TREE_CODE (tmp) == ARRAY_TYPE)
2997 dump_array_domain (pp, TYPE_DOMAIN (tmp), spc, flags);
2998 tmp = TREE_TYPE (tmp);
3001 else if (TREE_CODE (t) == FUNCTION_DECL)
3003 dump_generic_node (pp, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
3004 pp_space (pp);
3005 dump_decl_name (pp, t, flags);
3006 dump_function_declaration (pp, TREE_TYPE (t), spc, flags);
3008 else
3010 /* Print type declaration. */
3011 dump_generic_node (pp, TREE_TYPE (t), spc, flags, false);
3013 /* Print variable's name. */
3014 pp_space (pp);
3015 dump_generic_node (pp, t, spc, flags, false);
3018 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
3020 pp_string (pp, " __asm__ ");
3021 pp_left_paren (pp);
3022 dump_generic_node (pp, DECL_ASSEMBLER_NAME (t), spc, flags, false);
3023 pp_right_paren (pp);
3026 /* The initial value of a function serves to determine whether the function
3027 is declared or defined. So the following does not apply to function
3028 nodes. */
3029 if (TREE_CODE (t) != FUNCTION_DECL)
3031 /* Print the initial value. */
3032 if (DECL_INITIAL (t))
3034 pp_space (pp);
3035 pp_equal (pp);
3036 pp_space (pp);
3037 dump_generic_node (pp, DECL_INITIAL (t), spc, flags, false);
3041 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
3043 pp_string (pp, " [value-expr: ");
3044 dump_generic_node (pp, DECL_VALUE_EXPR (t), spc, flags, false);
3045 pp_right_bracket (pp);
3048 pp_semicolon (pp);
3052 /* Prints a structure: name, fields, and methods.
3053 FIXME: Still incomplete. */
3055 static void
3056 print_struct_decl (pretty_printer *pp, const_tree node, int spc, int flags)
3058 /* Print the name of the structure. */
3059 if (TYPE_NAME (node))
3061 INDENT (spc);
3062 if (TREE_CODE (node) == RECORD_TYPE)
3063 pp_string (pp, "struct ");
3064 else if ((TREE_CODE (node) == UNION_TYPE
3065 || TREE_CODE (node) == QUAL_UNION_TYPE))
3066 pp_string (pp, "union ");
3068 dump_generic_node (pp, TYPE_NAME (node), spc, 0, false);
3071 /* Print the contents of the structure. */
3072 pp_newline (pp);
3073 INDENT (spc);
3074 pp_left_brace (pp);
3075 pp_newline (pp);
3077 /* Print the fields of the structure. */
3079 tree tmp;
3080 tmp = TYPE_FIELDS (node);
3081 while (tmp)
3083 /* Avoid to print recursively the structure. */
3084 /* FIXME : Not implemented correctly...,
3085 what about the case when we have a cycle in the contain graph? ...
3086 Maybe this could be solved by looking at the scope in which the
3087 structure was declared. */
3088 if (TREE_TYPE (tmp) != node
3089 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
3090 || TREE_TYPE (TREE_TYPE (tmp)) != node))
3092 print_declaration (pp, tmp, spc+2, flags);
3093 pp_newline (pp);
3095 tmp = DECL_CHAIN (tmp);
3098 INDENT (spc);
3099 pp_right_brace (pp);
3102 /* Return the priority of the operator CODE.
3104 From lowest to highest precedence with either left-to-right (L-R)
3105 or right-to-left (R-L) associativity]:
3107 1 [L-R] ,
3108 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
3109 3 [R-L] ?:
3110 4 [L-R] ||
3111 5 [L-R] &&
3112 6 [L-R] |
3113 7 [L-R] ^
3114 8 [L-R] &
3115 9 [L-R] == !=
3116 10 [L-R] < <= > >=
3117 11 [L-R] << >>
3118 12 [L-R] + -
3119 13 [L-R] * / %
3120 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
3121 15 [L-R] fn() [] -> .
3123 unary +, - and * have higher precedence than the corresponding binary
3124 operators. */
3127 op_code_prio (enum tree_code code)
3129 switch (code)
3131 case TREE_LIST:
3132 case COMPOUND_EXPR:
3133 case BIND_EXPR:
3134 return 1;
3136 case MODIFY_EXPR:
3137 case INIT_EXPR:
3138 return 2;
3140 case COND_EXPR:
3141 return 3;
3143 case TRUTH_OR_EXPR:
3144 case TRUTH_ORIF_EXPR:
3145 return 4;
3147 case TRUTH_AND_EXPR:
3148 case TRUTH_ANDIF_EXPR:
3149 return 5;
3151 case BIT_IOR_EXPR:
3152 return 6;
3154 case BIT_XOR_EXPR:
3155 case TRUTH_XOR_EXPR:
3156 return 7;
3158 case BIT_AND_EXPR:
3159 return 8;
3161 case EQ_EXPR:
3162 case NE_EXPR:
3163 return 9;
3165 case UNLT_EXPR:
3166 case UNLE_EXPR:
3167 case UNGT_EXPR:
3168 case UNGE_EXPR:
3169 case UNEQ_EXPR:
3170 case LTGT_EXPR:
3171 case ORDERED_EXPR:
3172 case UNORDERED_EXPR:
3173 case LT_EXPR:
3174 case LE_EXPR:
3175 case GT_EXPR:
3176 case GE_EXPR:
3177 return 10;
3179 case LSHIFT_EXPR:
3180 case RSHIFT_EXPR:
3181 case LROTATE_EXPR:
3182 case RROTATE_EXPR:
3183 case VEC_WIDEN_LSHIFT_HI_EXPR:
3184 case VEC_WIDEN_LSHIFT_LO_EXPR:
3185 case WIDEN_LSHIFT_EXPR:
3186 return 11;
3188 case WIDEN_SUM_EXPR:
3189 case PLUS_EXPR:
3190 case POINTER_PLUS_EXPR:
3191 case MINUS_EXPR:
3192 return 12;
3194 case VEC_WIDEN_MULT_HI_EXPR:
3195 case VEC_WIDEN_MULT_LO_EXPR:
3196 case WIDEN_MULT_EXPR:
3197 case DOT_PROD_EXPR:
3198 case WIDEN_MULT_PLUS_EXPR:
3199 case WIDEN_MULT_MINUS_EXPR:
3200 case MULT_EXPR:
3201 case MULT_HIGHPART_EXPR:
3202 case TRUNC_DIV_EXPR:
3203 case CEIL_DIV_EXPR:
3204 case FLOOR_DIV_EXPR:
3205 case ROUND_DIV_EXPR:
3206 case RDIV_EXPR:
3207 case EXACT_DIV_EXPR:
3208 case TRUNC_MOD_EXPR:
3209 case CEIL_MOD_EXPR:
3210 case FLOOR_MOD_EXPR:
3211 case ROUND_MOD_EXPR:
3212 case FMA_EXPR:
3213 return 13;
3215 case TRUTH_NOT_EXPR:
3216 case BIT_NOT_EXPR:
3217 case POSTINCREMENT_EXPR:
3218 case POSTDECREMENT_EXPR:
3219 case PREINCREMENT_EXPR:
3220 case PREDECREMENT_EXPR:
3221 case NEGATE_EXPR:
3222 case INDIRECT_REF:
3223 case ADDR_EXPR:
3224 case FLOAT_EXPR:
3225 CASE_CONVERT:
3226 case FIX_TRUNC_EXPR:
3227 case TARGET_EXPR:
3228 return 14;
3230 case CALL_EXPR:
3231 case ARRAY_REF:
3232 case ARRAY_RANGE_REF:
3233 case COMPONENT_REF:
3234 return 15;
3236 /* Special expressions. */
3237 case MIN_EXPR:
3238 case MAX_EXPR:
3239 case ABS_EXPR:
3240 case REALPART_EXPR:
3241 case IMAGPART_EXPR:
3242 case REDUC_MAX_EXPR:
3243 case REDUC_MIN_EXPR:
3244 case REDUC_PLUS_EXPR:
3245 case VEC_UNPACK_HI_EXPR:
3246 case VEC_UNPACK_LO_EXPR:
3247 case VEC_UNPACK_FLOAT_HI_EXPR:
3248 case VEC_UNPACK_FLOAT_LO_EXPR:
3249 case VEC_PACK_TRUNC_EXPR:
3250 case VEC_PACK_SAT_EXPR:
3251 return 16;
3253 default:
3254 /* Return an arbitrarily high precedence to avoid surrounding single
3255 VAR_DECLs in ()s. */
3256 return 9999;
3260 /* Return the priority of the operator OP. */
3263 op_prio (const_tree op)
3265 enum tree_code code;
3267 if (op == NULL)
3268 return 9999;
3270 code = TREE_CODE (op);
3271 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3272 return op_prio (TREE_OPERAND (op, 0));
3274 return op_code_prio (code);
3277 /* Return the symbol associated with operator CODE. */
3279 const char *
3280 op_symbol_code (enum tree_code code)
3282 switch (code)
3284 case MODIFY_EXPR:
3285 return "=";
3287 case TRUTH_OR_EXPR:
3288 case TRUTH_ORIF_EXPR:
3289 return "||";
3291 case TRUTH_AND_EXPR:
3292 case TRUTH_ANDIF_EXPR:
3293 return "&&";
3295 case BIT_IOR_EXPR:
3296 return "|";
3298 case TRUTH_XOR_EXPR:
3299 case BIT_XOR_EXPR:
3300 return "^";
3302 case ADDR_EXPR:
3303 case BIT_AND_EXPR:
3304 return "&";
3306 case ORDERED_EXPR:
3307 return "ord";
3308 case UNORDERED_EXPR:
3309 return "unord";
3311 case EQ_EXPR:
3312 return "==";
3313 case UNEQ_EXPR:
3314 return "u==";
3316 case NE_EXPR:
3317 return "!=";
3319 case LT_EXPR:
3320 return "<";
3321 case UNLT_EXPR:
3322 return "u<";
3324 case LE_EXPR:
3325 return "<=";
3326 case UNLE_EXPR:
3327 return "u<=";
3329 case GT_EXPR:
3330 return ">";
3331 case UNGT_EXPR:
3332 return "u>";
3334 case GE_EXPR:
3335 return ">=";
3336 case UNGE_EXPR:
3337 return "u>=";
3339 case LTGT_EXPR:
3340 return "<>";
3342 case LSHIFT_EXPR:
3343 return "<<";
3345 case RSHIFT_EXPR:
3346 return ">>";
3348 case LROTATE_EXPR:
3349 return "r<<";
3351 case RROTATE_EXPR:
3352 return "r>>";
3354 case WIDEN_LSHIFT_EXPR:
3355 return "w<<";
3357 case POINTER_PLUS_EXPR:
3358 return "+";
3360 case PLUS_EXPR:
3361 return "+";
3363 case REDUC_PLUS_EXPR:
3364 return "r+";
3366 case WIDEN_SUM_EXPR:
3367 return "w+";
3369 case WIDEN_MULT_EXPR:
3370 return "w*";
3372 case MULT_HIGHPART_EXPR:
3373 return "h*";
3375 case NEGATE_EXPR:
3376 case MINUS_EXPR:
3377 return "-";
3379 case BIT_NOT_EXPR:
3380 return "~";
3382 case TRUTH_NOT_EXPR:
3383 return "!";
3385 case MULT_EXPR:
3386 case INDIRECT_REF:
3387 return "*";
3389 case TRUNC_DIV_EXPR:
3390 case RDIV_EXPR:
3391 return "/";
3393 case CEIL_DIV_EXPR:
3394 return "/[cl]";
3396 case FLOOR_DIV_EXPR:
3397 return "/[fl]";
3399 case ROUND_DIV_EXPR:
3400 return "/[rd]";
3402 case EXACT_DIV_EXPR:
3403 return "/[ex]";
3405 case TRUNC_MOD_EXPR:
3406 return "%";
3408 case CEIL_MOD_EXPR:
3409 return "%[cl]";
3411 case FLOOR_MOD_EXPR:
3412 return "%[fl]";
3414 case ROUND_MOD_EXPR:
3415 return "%[rd]";
3417 case PREDECREMENT_EXPR:
3418 return " --";
3420 case PREINCREMENT_EXPR:
3421 return " ++";
3423 case POSTDECREMENT_EXPR:
3424 return "-- ";
3426 case POSTINCREMENT_EXPR:
3427 return "++ ";
3429 case MAX_EXPR:
3430 return "max";
3432 case MIN_EXPR:
3433 return "min";
3435 default:
3436 return "<<< ??? >>>";
3440 /* Return the symbol associated with operator OP. */
3442 static const char *
3443 op_symbol (const_tree op)
3445 return op_symbol_code (TREE_CODE (op));
3448 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3449 the gimple_call_fn of a GIMPLE_CALL. */
3451 void
3452 print_call_name (pretty_printer *pp, tree node, int flags)
3454 tree op0 = node;
3456 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3457 op0 = TREE_OPERAND (op0, 0);
3459 again:
3460 switch (TREE_CODE (op0))
3462 case VAR_DECL:
3463 case PARM_DECL:
3464 case FUNCTION_DECL:
3465 dump_function_name (pp, op0, flags);
3466 break;
3468 case ADDR_EXPR:
3469 case INDIRECT_REF:
3470 CASE_CONVERT:
3471 op0 = TREE_OPERAND (op0, 0);
3472 goto again;
3474 case COND_EXPR:
3475 pp_left_paren (pp);
3476 dump_generic_node (pp, TREE_OPERAND (op0, 0), 0, flags, false);
3477 pp_string (pp, ") ? ");
3478 dump_generic_node (pp, TREE_OPERAND (op0, 1), 0, flags, false);
3479 pp_string (pp, " : ");
3480 dump_generic_node (pp, TREE_OPERAND (op0, 2), 0, flags, false);
3481 break;
3483 case ARRAY_REF:
3484 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3485 dump_function_name (pp, TREE_OPERAND (op0, 0), flags);
3486 else
3487 dump_generic_node (pp, op0, 0, flags, false);
3488 break;
3490 case MEM_REF:
3491 if (integer_zerop (TREE_OPERAND (op0, 1)))
3493 op0 = TREE_OPERAND (op0, 0);
3494 goto again;
3496 /* Fallthru. */
3497 case COMPONENT_REF:
3498 case SSA_NAME:
3499 case OBJ_TYPE_REF:
3500 dump_generic_node (pp, op0, 0, flags, false);
3501 break;
3503 default:
3504 NIY;
3508 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3510 static void
3511 pretty_print_string (pretty_printer *pp, const char *str)
3513 if (str == NULL)
3514 return;
3516 while (*str)
3518 switch (str[0])
3520 case '\b':
3521 pp_string (pp, "\\b");
3522 break;
3524 case '\f':
3525 pp_string (pp, "\\f");
3526 break;
3528 case '\n':
3529 pp_string (pp, "\\n");
3530 break;
3532 case '\r':
3533 pp_string (pp, "\\r");
3534 break;
3536 case '\t':
3537 pp_string (pp, "\\t");
3538 break;
3540 case '\v':
3541 pp_string (pp, "\\v");
3542 break;
3544 case '\\':
3545 pp_string (pp, "\\\\");
3546 break;
3548 case '\"':
3549 pp_string (pp, "\\\"");
3550 break;
3552 case '\'':
3553 pp_string (pp, "\\'");
3554 break;
3556 /* No need to handle \0; the loop terminates on \0. */
3558 case '\1':
3559 pp_string (pp, "\\1");
3560 break;
3562 case '\2':
3563 pp_string (pp, "\\2");
3564 break;
3566 case '\3':
3567 pp_string (pp, "\\3");
3568 break;
3570 case '\4':
3571 pp_string (pp, "\\4");
3572 break;
3574 case '\5':
3575 pp_string (pp, "\\5");
3576 break;
3578 case '\6':
3579 pp_string (pp, "\\6");
3580 break;
3582 case '\7':
3583 pp_string (pp, "\\7");
3584 break;
3586 default:
3587 pp_character (pp, str[0]);
3588 break;
3590 str++;
3594 static void
3595 maybe_init_pretty_print (FILE *file)
3597 if (!tree_pp)
3599 tree_pp = new pretty_printer ();
3600 pp_needs_newline (tree_pp) = true;
3601 pp_translate_identifiers (tree_pp) = false;
3604 tree_pp->buffer->stream = file;
3607 static void
3608 newline_and_indent (pretty_printer *pp, int spc)
3610 pp_newline (pp);
3611 INDENT (spc);
3614 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3615 it can also be used in front ends.
3616 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3619 void
3620 percent_K_format (text_info *text)
3622 tree t = va_arg (*text->args_ptr, tree), block;
3623 gcc_assert (text->locus != NULL);
3624 *text->locus = EXPR_LOCATION (t);
3625 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3626 block = TREE_BLOCK (t);
3627 *pp_ti_abstract_origin (text) = NULL;
3629 if (in_lto_p)
3631 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3632 representing the outermost block of an inlined function.
3633 So walk the BLOCK tree until we hit such a scope. */
3634 while (block
3635 && TREE_CODE (block) == BLOCK)
3637 if (inlined_function_outer_scope_p (block))
3639 *pp_ti_abstract_origin (text) = block;
3640 break;
3642 block = BLOCK_SUPERCONTEXT (block);
3644 return;
3647 while (block
3648 && TREE_CODE (block) == BLOCK
3649 && BLOCK_ABSTRACT_ORIGIN (block))
3651 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3653 while (TREE_CODE (ao) == BLOCK
3654 && BLOCK_ABSTRACT_ORIGIN (ao)
3655 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3656 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3658 if (TREE_CODE (ao) == FUNCTION_DECL)
3660 *pp_ti_abstract_origin (text) = block;
3661 break;
3663 block = BLOCK_SUPERCONTEXT (block);
3667 /* Print the identifier ID to PRETTY-PRINTER. */
3669 void
3670 pp_tree_identifier (pretty_printer *pp, tree id)
3672 if (pp_translate_identifiers (pp))
3674 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3675 pp_append_text (pp, text, text + strlen (text));
3677 else
3678 pp_append_text (pp, IDENTIFIER_POINTER (id),
3679 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3682 /* A helper function that is used to dump function information before the
3683 function dump. */
3685 void
3686 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3688 const char *dname, *aname;
3689 struct cgraph_node *node = cgraph_node::get (fdecl);
3690 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3692 dname = lang_hooks.decl_printable_name (fdecl, 2);
3694 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3695 aname = (IDENTIFIER_POINTER
3696 (DECL_ASSEMBLER_NAME (fdecl)));
3697 else
3698 aname = "<unset-asm-name>";
3700 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3701 dname, aname, fun->funcdef_no);
3702 if (!(flags & TDF_NOUID))
3703 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3704 if (node)
3706 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3707 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3708 node->frequency == NODE_FREQUENCY_HOT
3709 ? " (hot)"
3710 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3711 ? " (unlikely executed)"
3712 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3713 ? " (executed once)"
3714 : "");
3716 else
3717 fprintf (dump_file, ")\n\n");
3720 /* Dump double_int D to pretty_printer PP. UNS is true
3721 if D is unsigned and false otherwise. */
3722 void
3723 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3725 if (d.fits_shwi ())
3726 pp_wide_integer (pp, d.low);
3727 else if (d.fits_uhwi ())
3728 pp_unsigned_wide_integer (pp, d.low);
3729 else
3731 unsigned HOST_WIDE_INT low = d.low;
3732 HOST_WIDE_INT high = d.high;
3733 if (!uns && d.is_negative ())
3735 pp_minus (pp);
3736 high = ~high + !low;
3737 low = -low;
3739 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3740 systems? */
3741 sprintf (pp_buffer (pp)->digit_buffer,
3742 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3743 (unsigned HOST_WIDE_INT) high, low);
3744 pp_string (pp, pp_buffer (pp)->digit_buffer);