Fix gnu11 fallout on SPARC
[official-gcc.git] / gcc / tree-pretty-print.c
blob0a59aac6572c267a3924659bb828e5fbc5f3cc1b
1 /* Pretty formatting of GENERIC trees in C syntax.
2 Copyright (C) 2001-2014 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 "tree.h"
26 #include "stor-layout.h"
27 #include "expr.h"
28 #include "tree-pretty-print.h"
29 #include "hashtab.h"
30 #include "hash-set.h"
31 #include "gimple-expr.h"
32 #include "cgraph.h"
33 #include "langhooks.h"
34 #include "tree-iterator.h"
35 #include "tree-chrec.h"
36 #include "dumpfile.h"
37 #include "value-prof.h"
38 #include "predict.h"
39 #include "wide-int-print.h"
40 #include "internal-fn.h"
42 #include <new> // For placement-new.
44 /* Local functions, macros and variables. */
45 static const char *op_symbol (const_tree);
46 static void pretty_print_string (pretty_printer *, const char*);
47 static void newline_and_indent (pretty_printer *, int);
48 static void maybe_init_pretty_print (FILE *);
49 static void print_struct_decl (pretty_printer *, const_tree, int, int);
50 static void do_niy (pretty_printer *, const_tree);
52 #define INDENT(SPACE) do { \
53 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
55 #define NIY do_niy (buffer, node)
57 static pretty_printer buffer;
58 static int initialized = 0;
60 /* Try to print something for an unknown tree code. */
62 static void
63 do_niy (pretty_printer *buffer, const_tree node)
65 int i, len;
67 pp_string (buffer, "<<< Unknown tree: ");
68 pp_string (buffer, get_tree_code_name (TREE_CODE (node)));
70 if (EXPR_P (node))
72 len = TREE_OPERAND_LENGTH (node);
73 for (i = 0; i < len; ++i)
75 newline_and_indent (buffer, 2);
76 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
80 pp_string (buffer, " >>>");
83 /* Debugging function to print out a generic expression. */
85 DEBUG_FUNCTION void
86 debug_generic_expr (tree t)
88 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
89 fprintf (stderr, "\n");
92 /* Debugging function to print out a generic statement. */
94 DEBUG_FUNCTION void
95 debug_generic_stmt (tree t)
97 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
98 fprintf (stderr, "\n");
101 /* Debugging function to print out a chain of trees . */
103 DEBUG_FUNCTION void
104 debug_tree_chain (tree t)
106 hash_set<tree> seen;
108 while (t)
110 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
111 fprintf (stderr, " ");
112 t = TREE_CHAIN (t);
113 if (seen.add (t))
115 fprintf (stderr, "... [cycled back to ");
116 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
117 fprintf (stderr, "]");
118 break;
121 fprintf (stderr, "\n");
124 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
125 void
126 print_generic_decl (FILE *file, tree decl, int flags)
128 maybe_init_pretty_print (file);
129 print_declaration (&buffer, decl, 2, flags);
130 pp_write_text_to_stream (&buffer);
133 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
134 to show in the dump. See TDF_* in dumpfile.h. */
136 void
137 print_generic_stmt (FILE *file, tree t, int flags)
139 maybe_init_pretty_print (file);
140 dump_generic_node (&buffer, t, 0, flags, true);
141 pp_newline_and_flush (&buffer);
144 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
145 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
146 INDENT spaces. */
148 void
149 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
151 int i;
153 maybe_init_pretty_print (file);
155 for (i = 0; i < indent; i++)
156 pp_space (&buffer);
157 dump_generic_node (&buffer, t, indent, flags, true);
158 pp_newline_and_flush (&buffer);
161 /* Print a single expression T on file FILE. FLAGS specifies details to show
162 in the dump. See TDF_* in dumpfile.h. */
164 void
165 print_generic_expr (FILE *file, tree t, int flags)
167 maybe_init_pretty_print (file);
168 dump_generic_node (&buffer, t, 0, flags, false);
169 pp_flush (&buffer);
172 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
173 in FLAGS. */
175 static void
176 dump_decl_name (pretty_printer *buffer, tree node, int flags)
178 if (DECL_NAME (node))
180 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
181 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
182 else
183 pp_tree_identifier (buffer, DECL_NAME (node));
185 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
187 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
188 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
189 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
191 if (flags & TDF_NOUID)
192 pp_string (buffer, "D#xxxx");
193 else
194 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
196 else
198 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
199 if (flags & TDF_NOUID)
200 pp_printf (buffer, "%c.xxxx", c);
201 else
202 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
205 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
207 if (flags & TDF_NOUID)
208 pp_printf (buffer, "ptD.xxxx");
209 else
210 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
214 /* Like the above, but used for pretty printing function calls. */
216 static void
217 dump_function_name (pretty_printer *buffer, tree node, int flags)
219 if (TREE_CODE (node) == NOP_EXPR)
220 node = TREE_OPERAND (node, 0);
221 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
222 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
223 else
224 dump_decl_name (buffer, node, flags);
227 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
228 FLAGS are as in dump_generic_node. */
230 static void
231 dump_function_declaration (pretty_printer *buffer, tree node,
232 int spc, int flags)
234 bool wrote_arg = false;
235 tree arg;
237 pp_space (buffer);
238 pp_left_paren (buffer);
240 /* Print the argument types. */
241 arg = TYPE_ARG_TYPES (node);
242 while (arg && arg != void_list_node && arg != error_mark_node)
244 if (wrote_arg)
246 pp_comma (buffer);
247 pp_space (buffer);
249 wrote_arg = true;
250 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
251 arg = TREE_CHAIN (arg);
254 /* Drop the trailing void_type_node if we had any previous argument. */
255 if (arg == void_list_node && !wrote_arg)
256 pp_string (buffer, "void");
257 /* Properly dump vararg function types. */
258 else if (!arg && wrote_arg)
259 pp_string (buffer, ", ...");
260 /* Avoid printing any arg for unprototyped functions. */
262 pp_right_paren (buffer);
265 /* Dump the domain associated with an array. */
267 static void
268 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
270 pp_left_bracket (buffer);
271 if (domain)
273 tree min = TYPE_MIN_VALUE (domain);
274 tree max = TYPE_MAX_VALUE (domain);
276 if (min && max
277 && integer_zerop (min)
278 && tree_fits_shwi_p (max))
279 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
280 else
282 if (min)
283 dump_generic_node (buffer, min, spc, flags, false);
284 pp_colon (buffer);
285 if (max)
286 dump_generic_node (buffer, max, spc, flags, false);
289 else
290 pp_string (buffer, "<unknown>");
291 pp_right_bracket (buffer);
295 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
296 dump_generic_node. */
298 static void
299 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
301 const char *name;
303 switch (OMP_CLAUSE_CODE (clause))
305 case OMP_CLAUSE_PRIVATE:
306 name = "private";
307 goto print_remap;
308 case OMP_CLAUSE_SHARED:
309 name = "shared";
310 goto print_remap;
311 case OMP_CLAUSE_FIRSTPRIVATE:
312 name = "firstprivate";
313 goto print_remap;
314 case OMP_CLAUSE_LASTPRIVATE:
315 name = "lastprivate";
316 goto print_remap;
317 case OMP_CLAUSE_COPYIN:
318 name = "copyin";
319 goto print_remap;
320 case OMP_CLAUSE_COPYPRIVATE:
321 name = "copyprivate";
322 goto print_remap;
323 case OMP_CLAUSE_UNIFORM:
324 name = "uniform";
325 goto print_remap;
326 case OMP_CLAUSE__LOOPTEMP_:
327 name = "_looptemp_";
328 goto print_remap;
329 print_remap:
330 pp_string (buffer, name);
331 pp_left_paren (buffer);
332 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
333 spc, flags, false);
334 pp_right_paren (buffer);
335 break;
337 case OMP_CLAUSE_REDUCTION:
338 pp_string (buffer, "reduction(");
339 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
341 pp_string (buffer,
342 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
343 pp_colon (buffer);
345 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
346 spc, flags, false);
347 pp_right_paren (buffer);
348 break;
350 case OMP_CLAUSE_IF:
351 pp_string (buffer, "if(");
352 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
353 spc, flags, false);
354 pp_right_paren (buffer);
355 break;
357 case OMP_CLAUSE_NUM_THREADS:
358 pp_string (buffer, "num_threads(");
359 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
360 spc, flags, false);
361 pp_right_paren (buffer);
362 break;
364 case OMP_CLAUSE__CILK_FOR_COUNT_:
365 pp_string (buffer, "_Cilk_for_count_(");
366 dump_generic_node (buffer, OMP_CLAUSE_OPERAND (clause, 0),
367 spc, flags, false);
368 pp_right_paren (buffer);
369 break;
371 case OMP_CLAUSE_NOWAIT:
372 pp_string (buffer, "nowait");
373 break;
374 case OMP_CLAUSE_ORDERED:
375 pp_string (buffer, "ordered");
376 break;
378 case OMP_CLAUSE_DEFAULT:
379 pp_string (buffer, "default(");
380 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
382 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
383 break;
384 case OMP_CLAUSE_DEFAULT_SHARED:
385 pp_string (buffer, "shared");
386 break;
387 case OMP_CLAUSE_DEFAULT_NONE:
388 pp_string (buffer, "none");
389 break;
390 case OMP_CLAUSE_DEFAULT_PRIVATE:
391 pp_string (buffer, "private");
392 break;
393 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
394 pp_string (buffer, "firstprivate");
395 break;
396 default:
397 gcc_unreachable ();
399 pp_right_paren (buffer);
400 break;
402 case OMP_CLAUSE_SCHEDULE:
403 pp_string (buffer, "schedule(");
404 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
406 case OMP_CLAUSE_SCHEDULE_STATIC:
407 pp_string (buffer, "static");
408 break;
409 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
410 pp_string (buffer, "dynamic");
411 break;
412 case OMP_CLAUSE_SCHEDULE_GUIDED:
413 pp_string (buffer, "guided");
414 break;
415 case OMP_CLAUSE_SCHEDULE_RUNTIME:
416 pp_string (buffer, "runtime");
417 break;
418 case OMP_CLAUSE_SCHEDULE_AUTO:
419 pp_string (buffer, "auto");
420 break;
421 case OMP_CLAUSE_SCHEDULE_CILKFOR:
422 pp_string (buffer, "cilk-for grain");
423 break;
424 default:
425 gcc_unreachable ();
427 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
429 pp_comma (buffer);
430 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
431 spc, flags, false);
433 pp_right_paren (buffer);
434 break;
436 case OMP_CLAUSE_UNTIED:
437 pp_string (buffer, "untied");
438 break;
440 case OMP_CLAUSE_COLLAPSE:
441 pp_string (buffer, "collapse(");
442 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
443 spc, flags, false);
444 pp_right_paren (buffer);
445 break;
447 case OMP_CLAUSE_FINAL:
448 pp_string (buffer, "final(");
449 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
450 spc, flags, false);
451 pp_right_paren (buffer);
452 break;
454 case OMP_CLAUSE_MERGEABLE:
455 pp_string (buffer, "mergeable");
456 break;
458 case OMP_CLAUSE_LINEAR:
459 pp_string (buffer, "linear(");
460 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
461 spc, flags, false);
462 pp_colon (buffer);
463 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
464 spc, flags, false);
465 pp_right_paren (buffer);
466 break;
468 case OMP_CLAUSE_ALIGNED:
469 pp_string (buffer, "aligned(");
470 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
471 spc, flags, false);
472 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
474 pp_colon (buffer);
475 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
476 spc, flags, false);
478 pp_right_paren (buffer);
479 break;
481 case OMP_CLAUSE_DEPEND:
482 pp_string (buffer, "depend(");
483 switch (OMP_CLAUSE_DEPEND_KIND (clause))
485 case OMP_CLAUSE_DEPEND_IN:
486 pp_string (buffer, "in");
487 break;
488 case OMP_CLAUSE_DEPEND_OUT:
489 pp_string (buffer, "out");
490 break;
491 case OMP_CLAUSE_DEPEND_INOUT:
492 pp_string (buffer, "inout");
493 break;
494 default:
495 gcc_unreachable ();
497 pp_colon (buffer);
498 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
499 spc, flags, false);
500 pp_right_paren (buffer);
501 break;
503 case OMP_CLAUSE_MAP:
504 pp_string (buffer, "map(");
505 switch (OMP_CLAUSE_MAP_KIND (clause))
507 case OMP_CLAUSE_MAP_ALLOC:
508 case OMP_CLAUSE_MAP_POINTER:
509 pp_string (buffer, "alloc");
510 break;
511 case OMP_CLAUSE_MAP_TO:
512 case OMP_CLAUSE_MAP_TO_PSET:
513 pp_string (buffer, "to");
514 break;
515 case OMP_CLAUSE_MAP_FROM:
516 pp_string (buffer, "from");
517 break;
518 case OMP_CLAUSE_MAP_TOFROM:
519 pp_string (buffer, "tofrom");
520 break;
521 default:
522 gcc_unreachable ();
524 pp_colon (buffer);
525 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
526 spc, flags, false);
527 print_clause_size:
528 if (OMP_CLAUSE_SIZE (clause))
530 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
531 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
532 pp_string (buffer, " [pointer assign, bias: ");
533 else if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
534 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_TO_PSET)
535 pp_string (buffer, " [pointer set, len: ");
536 else
537 pp_string (buffer, " [len: ");
538 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
539 spc, flags, false);
540 pp_right_bracket (buffer);
542 pp_right_paren (buffer);
543 break;
545 case OMP_CLAUSE_FROM:
546 pp_string (buffer, "from(");
547 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
548 spc, flags, false);
549 goto print_clause_size;
551 case OMP_CLAUSE_TO:
552 pp_string (buffer, "to(");
553 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
554 spc, flags, false);
555 goto print_clause_size;
557 case OMP_CLAUSE_NUM_TEAMS:
558 pp_string (buffer, "num_teams(");
559 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
560 spc, flags, false);
561 pp_right_paren (buffer);
562 break;
564 case OMP_CLAUSE_THREAD_LIMIT:
565 pp_string (buffer, "thread_limit(");
566 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
567 spc, flags, false);
568 pp_right_paren (buffer);
569 break;
571 case OMP_CLAUSE_DEVICE:
572 pp_string (buffer, "device(");
573 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
574 spc, flags, false);
575 pp_right_paren (buffer);
576 break;
578 case OMP_CLAUSE_DIST_SCHEDULE:
579 pp_string (buffer, "dist_schedule(static");
580 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
582 pp_comma (buffer);
583 dump_generic_node (buffer,
584 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
585 spc, flags, false);
587 pp_right_paren (buffer);
588 break;
590 case OMP_CLAUSE_PROC_BIND:
591 pp_string (buffer, "proc_bind(");
592 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
594 case OMP_CLAUSE_PROC_BIND_MASTER:
595 pp_string (buffer, "master");
596 break;
597 case OMP_CLAUSE_PROC_BIND_CLOSE:
598 pp_string (buffer, "close");
599 break;
600 case OMP_CLAUSE_PROC_BIND_SPREAD:
601 pp_string (buffer, "spread");
602 break;
603 default:
604 gcc_unreachable ();
606 pp_right_paren (buffer);
607 break;
609 case OMP_CLAUSE_SAFELEN:
610 pp_string (buffer, "safelen(");
611 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
612 spc, flags, false);
613 pp_right_paren (buffer);
614 break;
616 case OMP_CLAUSE_SIMDLEN:
617 pp_string (buffer, "simdlen(");
618 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
619 spc, flags, false);
620 pp_right_paren (buffer);
621 break;
623 case OMP_CLAUSE__SIMDUID_:
624 pp_string (buffer, "_simduid_(");
625 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
626 spc, flags, false);
627 pp_right_paren (buffer);
628 break;
630 case OMP_CLAUSE_INBRANCH:
631 pp_string (buffer, "inbranch");
632 break;
633 case OMP_CLAUSE_NOTINBRANCH:
634 pp_string (buffer, "notinbranch");
635 break;
636 case OMP_CLAUSE_FOR:
637 pp_string (buffer, "for");
638 break;
639 case OMP_CLAUSE_PARALLEL:
640 pp_string (buffer, "parallel");
641 break;
642 case OMP_CLAUSE_SECTIONS:
643 pp_string (buffer, "sections");
644 break;
645 case OMP_CLAUSE_TASKGROUP:
646 pp_string (buffer, "taskgroup");
647 break;
649 default:
650 /* Should never happen. */
651 dump_generic_node (buffer, clause, spc, flags, false);
652 break;
657 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
658 dump_generic_node. */
660 void
661 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
663 if (clause == NULL)
664 return;
666 pp_space (buffer);
667 while (1)
669 dump_omp_clause (buffer, clause, spc, flags);
670 clause = OMP_CLAUSE_CHAIN (clause);
671 if (clause == NULL)
672 return;
673 pp_space (buffer);
678 /* Dump location LOC to BUFFER. */
680 void
681 dump_location (pretty_printer *buffer, location_t loc)
683 expanded_location xloc = expand_location (loc);
685 pp_left_bracket (buffer);
686 if (xloc.file)
688 pp_string (buffer, xloc.file);
689 pp_string (buffer, ":");
691 pp_decimal_int (buffer, xloc.line);
692 pp_colon (buffer);
693 pp_decimal_int (buffer, xloc.column);
694 pp_string (buffer, "] ");
698 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
699 dump_generic_node. */
701 static void
702 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
704 tree t;
706 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
708 if (flags & TDF_ADDRESS)
709 pp_printf (buffer, "[%p] ", (void *) block);
711 if (BLOCK_ABSTRACT (block))
712 pp_string (buffer, "[abstract] ");
714 if (TREE_ASM_WRITTEN (block))
715 pp_string (buffer, "[written] ");
717 if (flags & TDF_SLIM)
718 return;
720 if (BLOCK_SOURCE_LOCATION (block))
721 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
723 newline_and_indent (buffer, spc + 2);
725 if (BLOCK_SUPERCONTEXT (block))
727 pp_string (buffer, "SUPERCONTEXT: ");
728 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
729 flags | TDF_SLIM, false);
730 newline_and_indent (buffer, spc + 2);
733 if (BLOCK_SUBBLOCKS (block))
735 pp_string (buffer, "SUBBLOCKS: ");
736 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
738 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
739 pp_space (buffer);
741 newline_and_indent (buffer, spc + 2);
744 if (BLOCK_CHAIN (block))
746 pp_string (buffer, "SIBLINGS: ");
747 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
749 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
750 pp_space (buffer);
752 newline_and_indent (buffer, spc + 2);
755 if (BLOCK_VARS (block))
757 pp_string (buffer, "VARS: ");
758 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
760 dump_generic_node (buffer, t, 0, flags, false);
761 pp_space (buffer);
763 newline_and_indent (buffer, spc + 2);
766 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
768 unsigned i;
769 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
771 pp_string (buffer, "NONLOCALIZED_VARS: ");
772 FOR_EACH_VEC_ELT (*nlv, i, t)
774 dump_generic_node (buffer, t, 0, flags, false);
775 pp_space (buffer);
777 newline_and_indent (buffer, spc + 2);
780 if (BLOCK_ABSTRACT_ORIGIN (block))
782 pp_string (buffer, "ABSTRACT_ORIGIN: ");
783 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
784 flags | TDF_SLIM, false);
785 newline_and_indent (buffer, spc + 2);
788 if (BLOCK_FRAGMENT_ORIGIN (block))
790 pp_string (buffer, "FRAGMENT_ORIGIN: ");
791 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
792 flags | TDF_SLIM, false);
793 newline_and_indent (buffer, spc + 2);
796 if (BLOCK_FRAGMENT_CHAIN (block))
798 pp_string (buffer, "FRAGMENT_CHAIN: ");
799 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
801 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
802 pp_space (buffer);
804 newline_and_indent (buffer, spc + 2);
809 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
810 indent. FLAGS specifies details to show in the dump (see TDF_* in
811 dumpfile.h). If IS_STMT is true, the object printed is considered
812 to be a statement and it is terminated by ';' if appropriate. */
815 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
816 bool is_stmt)
818 tree type;
819 tree op0, op1;
820 const char *str;
821 bool is_expr;
822 enum tree_code code;
824 if (node == NULL_TREE)
825 return spc;
827 is_expr = EXPR_P (node);
829 if (is_stmt && (flags & TDF_STMTADDR))
830 pp_printf (buffer, "<&%p> ", (void *)node);
832 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
833 dump_location (buffer, EXPR_LOCATION (node));
835 code = TREE_CODE (node);
836 switch (code)
838 case ERROR_MARK:
839 pp_string (buffer, "<<< error >>>");
840 break;
842 case IDENTIFIER_NODE:
843 pp_tree_identifier (buffer, node);
844 break;
846 case TREE_LIST:
847 while (node && node != error_mark_node)
849 if (TREE_PURPOSE (node))
851 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
852 pp_space (buffer);
854 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
855 node = TREE_CHAIN (node);
856 if (node && TREE_CODE (node) == TREE_LIST)
858 pp_comma (buffer);
859 pp_space (buffer);
862 break;
864 case TREE_BINFO:
865 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
866 break;
868 case TREE_VEC:
870 size_t i;
871 if (TREE_VEC_LENGTH (node) > 0)
873 size_t len = TREE_VEC_LENGTH (node);
874 for (i = 0; i < len - 1; i++)
876 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
877 false);
878 pp_comma (buffer);
879 pp_space (buffer);
881 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
882 flags, false);
885 break;
887 case VOID_TYPE:
888 case INTEGER_TYPE:
889 case REAL_TYPE:
890 case FIXED_POINT_TYPE:
891 case COMPLEX_TYPE:
892 case VECTOR_TYPE:
893 case ENUMERAL_TYPE:
894 case BOOLEAN_TYPE:
896 unsigned int quals = TYPE_QUALS (node);
897 enum tree_code_class tclass;
899 if (quals & TYPE_QUAL_ATOMIC)
900 pp_string (buffer, "atomic ");
901 if (quals & TYPE_QUAL_CONST)
902 pp_string (buffer, "const ");
903 else if (quals & TYPE_QUAL_VOLATILE)
904 pp_string (buffer, "volatile ");
905 else if (quals & TYPE_QUAL_RESTRICT)
906 pp_string (buffer, "restrict ");
908 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
910 pp_string (buffer, "<address-space-");
911 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
912 pp_string (buffer, "> ");
915 tclass = TREE_CODE_CLASS (TREE_CODE (node));
917 if (tclass == tcc_declaration)
919 if (DECL_NAME (node))
920 dump_decl_name (buffer, node, flags);
921 else
922 pp_string (buffer, "<unnamed type decl>");
924 else if (tclass == tcc_type)
926 if (TYPE_NAME (node))
928 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
929 pp_tree_identifier (buffer, TYPE_NAME (node));
930 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
931 && DECL_NAME (TYPE_NAME (node)))
932 dump_decl_name (buffer, TYPE_NAME (node), flags);
933 else
934 pp_string (buffer, "<unnamed type>");
936 else if (TREE_CODE (node) == VECTOR_TYPE)
938 pp_string (buffer, "vector");
939 pp_left_paren (buffer);
940 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
941 pp_string (buffer, ") ");
942 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
944 else if (TREE_CODE (node) == INTEGER_TYPE)
946 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
947 pp_string (buffer, (TYPE_UNSIGNED (node)
948 ? "unsigned char"
949 : "signed char"));
950 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
951 pp_string (buffer, (TYPE_UNSIGNED (node)
952 ? "unsigned short"
953 : "signed short"));
954 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
955 pp_string (buffer, (TYPE_UNSIGNED (node)
956 ? "unsigned int"
957 : "signed int"));
958 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
959 pp_string (buffer, (TYPE_UNSIGNED (node)
960 ? "unsigned long"
961 : "signed long"));
962 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
963 pp_string (buffer, (TYPE_UNSIGNED (node)
964 ? "unsigned long long"
965 : "signed long long"));
966 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
967 && exact_log2 (TYPE_PRECISION (node)) != -1)
969 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
970 pp_decimal_int (buffer, TYPE_PRECISION (node));
971 pp_string (buffer, "_t");
973 else
975 pp_string (buffer, (TYPE_UNSIGNED (node)
976 ? "<unnamed-unsigned:"
977 : "<unnamed-signed:"));
978 pp_decimal_int (buffer, TYPE_PRECISION (node));
979 pp_greater (buffer);
982 else if (TREE_CODE (node) == COMPLEX_TYPE)
984 pp_string (buffer, "__complex__ ");
985 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
987 else if (TREE_CODE (node) == REAL_TYPE)
989 pp_string (buffer, "<float:");
990 pp_decimal_int (buffer, TYPE_PRECISION (node));
991 pp_greater (buffer);
993 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
995 pp_string (buffer, "<fixed-point-");
996 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
997 pp_decimal_int (buffer, TYPE_PRECISION (node));
998 pp_greater (buffer);
1000 else if (TREE_CODE (node) == VOID_TYPE)
1001 pp_string (buffer, "void");
1002 else
1003 pp_string (buffer, "<unnamed type>");
1005 break;
1008 case POINTER_TYPE:
1009 case REFERENCE_TYPE:
1010 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
1012 if (TREE_TYPE (node) == NULL)
1014 pp_string (buffer, str);
1015 pp_string (buffer, "<null type>");
1017 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1019 tree fnode = TREE_TYPE (node);
1021 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1022 pp_space (buffer);
1023 pp_left_paren (buffer);
1024 pp_string (buffer, str);
1025 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1026 dump_decl_name (buffer, TYPE_NAME (node), flags);
1027 else if (flags & TDF_NOUID)
1028 pp_printf (buffer, "<Txxxx>");
1029 else
1030 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1032 pp_right_paren (buffer);
1033 dump_function_declaration (buffer, fnode, spc, flags);
1035 else
1037 unsigned int quals = TYPE_QUALS (node);
1039 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1040 pp_space (buffer);
1041 pp_string (buffer, str);
1043 if (quals & TYPE_QUAL_CONST)
1044 pp_string (buffer, " const");
1045 if (quals & TYPE_QUAL_VOLATILE)
1046 pp_string (buffer, " volatile");
1047 if (quals & TYPE_QUAL_RESTRICT)
1048 pp_string (buffer, " restrict");
1050 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1052 pp_string (buffer, " <address-space-");
1053 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1054 pp_greater (buffer);
1057 if (TYPE_REF_CAN_ALIAS_ALL (node))
1058 pp_string (buffer, " {ref-all}");
1060 break;
1062 case OFFSET_TYPE:
1063 NIY;
1064 break;
1066 case MEM_REF:
1068 if (integer_zerop (TREE_OPERAND (node, 1))
1069 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1070 infer them and MEM_ATTR caching will share MEM_REFs
1071 with differently-typed op0s. */
1072 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1073 /* Released SSA_NAMES have no TREE_TYPE. */
1074 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1075 /* Same pointer types, but ignoring POINTER_TYPE vs.
1076 REFERENCE_TYPE. */
1077 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1078 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1079 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1080 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1081 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1082 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1083 /* Same value types ignoring qualifiers. */
1084 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1085 == TYPE_MAIN_VARIANT
1086 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1088 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1090 pp_star (buffer);
1091 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1092 spc, flags, false);
1094 else
1095 dump_generic_node (buffer,
1096 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1097 spc, flags, false);
1099 else
1101 tree ptype;
1103 pp_string (buffer, "MEM[");
1104 pp_left_paren (buffer);
1105 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1106 dump_generic_node (buffer, ptype,
1107 spc, flags | TDF_SLIM, false);
1108 pp_right_paren (buffer);
1109 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1110 spc, flags, false);
1111 if (!integer_zerop (TREE_OPERAND (node, 1)))
1113 pp_string (buffer, " + ");
1114 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1115 spc, flags, false);
1117 pp_right_bracket (buffer);
1119 break;
1122 case TARGET_MEM_REF:
1124 const char *sep = "";
1125 tree tmp;
1127 pp_string (buffer, "MEM[");
1129 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1131 pp_string (buffer, sep);
1132 sep = ", ";
1133 pp_string (buffer, "symbol: ");
1134 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1135 spc, flags, false);
1137 else
1139 pp_string (buffer, sep);
1140 sep = ", ";
1141 pp_string (buffer, "base: ");
1142 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1144 tmp = TMR_INDEX2 (node);
1145 if (tmp)
1147 pp_string (buffer, sep);
1148 sep = ", ";
1149 pp_string (buffer, "base: ");
1150 dump_generic_node (buffer, tmp, spc, flags, false);
1152 tmp = TMR_INDEX (node);
1153 if (tmp)
1155 pp_string (buffer, sep);
1156 sep = ", ";
1157 pp_string (buffer, "index: ");
1158 dump_generic_node (buffer, tmp, spc, flags, false);
1160 tmp = TMR_STEP (node);
1161 if (tmp)
1163 pp_string (buffer, sep);
1164 sep = ", ";
1165 pp_string (buffer, "step: ");
1166 dump_generic_node (buffer, tmp, spc, flags, false);
1168 tmp = TMR_OFFSET (node);
1169 if (tmp)
1171 pp_string (buffer, sep);
1172 sep = ", ";
1173 pp_string (buffer, "offset: ");
1174 dump_generic_node (buffer, tmp, spc, flags, false);
1176 pp_right_bracket (buffer);
1178 break;
1180 case ARRAY_TYPE:
1182 tree tmp;
1184 /* Print the innermost component type. */
1185 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1186 tmp = TREE_TYPE (tmp))
1188 dump_generic_node (buffer, tmp, spc, flags, false);
1190 /* Print the dimensions. */
1191 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1192 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1193 break;
1196 case RECORD_TYPE:
1197 case UNION_TYPE:
1198 case QUAL_UNION_TYPE:
1200 unsigned int quals = TYPE_QUALS (node);
1202 if (quals & TYPE_QUAL_ATOMIC)
1203 pp_string (buffer, "atomic ");
1204 if (quals & TYPE_QUAL_CONST)
1205 pp_string (buffer, "const ");
1206 if (quals & TYPE_QUAL_VOLATILE)
1207 pp_string (buffer, "volatile ");
1209 /* Print the name of the structure. */
1210 if (TREE_CODE (node) == RECORD_TYPE)
1211 pp_string (buffer, "struct ");
1212 else if (TREE_CODE (node) == UNION_TYPE)
1213 pp_string (buffer, "union ");
1215 if (TYPE_NAME (node))
1216 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1217 else if (!(flags & TDF_SLIM))
1218 /* FIXME: If we eliminate the 'else' above and attempt
1219 to show the fields for named types, we may get stuck
1220 following a cycle of pointers to structs. The alleged
1221 self-reference check in print_struct_decl will not detect
1222 cycles involving more than one pointer or struct type. */
1223 print_struct_decl (buffer, node, spc, flags);
1224 break;
1227 case LANG_TYPE:
1228 NIY;
1229 break;
1231 case INTEGER_CST:
1232 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1234 /* In the case of a pointer, one may want to divide by the
1235 size of the pointed-to type. Unfortunately, this not
1236 straightforward. The C front-end maps expressions
1238 (int *) 5
1239 int *p; (p + 5)
1241 in such a way that the two INTEGER_CST nodes for "5" have
1242 different values but identical types. In the latter
1243 case, the 5 is multiplied by sizeof (int) in c-common.c
1244 (pointer_int_sum) to convert it to a byte address, and
1245 yet the type of the node is left unchanged. Argh. What
1246 is consistent though is that the number value corresponds
1247 to bytes (UNITS) offset.
1249 NB: Neither of the following divisors can be trivially
1250 used to recover the original literal:
1252 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1253 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1254 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1255 pp_string (buffer, "B"); /* pseudo-unit */
1257 else if (tree_fits_shwi_p (node))
1258 pp_wide_integer (buffer, tree_to_shwi (node));
1259 else if (tree_fits_uhwi_p (node))
1260 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1261 else
1263 wide_int val = node;
1265 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1267 pp_minus (buffer);
1268 val = -val;
1270 print_hex (val, pp_buffer (buffer)->digit_buffer);
1271 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1273 if (TREE_OVERFLOW (node))
1274 pp_string (buffer, "(OVF)");
1275 break;
1277 case REAL_CST:
1278 /* Code copied from print_node. */
1280 REAL_VALUE_TYPE d;
1281 if (TREE_OVERFLOW (node))
1282 pp_string (buffer, " overflow");
1284 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1285 d = TREE_REAL_CST (node);
1286 if (REAL_VALUE_ISINF (d))
1287 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1288 else if (REAL_VALUE_ISNAN (d))
1289 pp_string (buffer, " Nan");
1290 else
1292 char string[100];
1293 real_to_decimal (string, &d, sizeof (string), 0, 1);
1294 pp_string (buffer, string);
1296 #else
1298 HOST_WIDE_INT i;
1299 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1300 pp_string (buffer, "0x");
1301 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1302 output_formatted_integer (buffer, "%02x", *p++);
1304 #endif
1305 break;
1308 case FIXED_CST:
1310 char string[100];
1311 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1312 pp_string (buffer, string);
1313 break;
1316 case COMPLEX_CST:
1317 pp_string (buffer, "__complex__ (");
1318 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1319 pp_string (buffer, ", ");
1320 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1321 pp_right_paren (buffer);
1322 break;
1324 case STRING_CST:
1325 pp_string (buffer, "\"");
1326 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1327 pp_string (buffer, "\"");
1328 break;
1330 case VECTOR_CST:
1332 unsigned i;
1333 pp_string (buffer, "{ ");
1334 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1336 if (i != 0)
1337 pp_string (buffer, ", ");
1338 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1339 spc, flags, false);
1341 pp_string (buffer, " }");
1343 break;
1345 case FUNCTION_TYPE:
1346 case METHOD_TYPE:
1347 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1348 pp_space (buffer);
1349 if (TREE_CODE (node) == METHOD_TYPE)
1351 if (TYPE_METHOD_BASETYPE (node))
1352 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1353 flags);
1354 else
1355 pp_string (buffer, "<null method basetype>");
1356 pp_colon_colon (buffer);
1358 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1359 dump_decl_name (buffer, TYPE_NAME (node), flags);
1360 else if (flags & TDF_NOUID)
1361 pp_printf (buffer, "<Txxxx>");
1362 else
1363 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1364 dump_function_declaration (buffer, node, spc, flags);
1365 break;
1367 case FUNCTION_DECL:
1368 case CONST_DECL:
1369 dump_decl_name (buffer, node, flags);
1370 break;
1372 case LABEL_DECL:
1373 if (DECL_NAME (node))
1374 dump_decl_name (buffer, node, flags);
1375 else if (LABEL_DECL_UID (node) != -1)
1376 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1377 else
1379 if (flags & TDF_NOUID)
1380 pp_string (buffer, "<D.xxxx>");
1381 else
1382 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1384 break;
1386 case TYPE_DECL:
1387 if (DECL_IS_BUILTIN (node))
1389 /* Don't print the declaration of built-in types. */
1390 break;
1392 if (DECL_NAME (node))
1393 dump_decl_name (buffer, node, flags);
1394 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1396 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1397 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1398 && TYPE_METHODS (TREE_TYPE (node)))
1400 /* The type is a c++ class: all structures have at least
1401 4 methods. */
1402 pp_string (buffer, "class ");
1403 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1405 else
1407 pp_string (buffer,
1408 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1409 ? "union" : "struct "));
1410 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1413 else
1414 pp_string (buffer, "<anon>");
1415 break;
1417 case VAR_DECL:
1418 case PARM_DECL:
1419 case FIELD_DECL:
1420 case DEBUG_EXPR_DECL:
1421 case NAMESPACE_DECL:
1422 case NAMELIST_DECL:
1423 dump_decl_name (buffer, node, flags);
1424 break;
1426 case RESULT_DECL:
1427 pp_string (buffer, "<retval>");
1428 break;
1430 case COMPONENT_REF:
1431 op0 = TREE_OPERAND (node, 0);
1432 str = ".";
1433 if (op0
1434 && (TREE_CODE (op0) == INDIRECT_REF
1435 || (TREE_CODE (op0) == MEM_REF
1436 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1437 && integer_zerop (TREE_OPERAND (op0, 1))
1438 /* Dump the types of INTEGER_CSTs explicitly, for we
1439 can't infer them and MEM_ATTR caching will share
1440 MEM_REFs with differently-typed op0s. */
1441 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1442 /* Released SSA_NAMES have no TREE_TYPE. */
1443 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1444 /* Same pointer types, but ignoring POINTER_TYPE vs.
1445 REFERENCE_TYPE. */
1446 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1447 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1448 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1449 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1450 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1451 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1452 /* Same value types ignoring qualifiers. */
1453 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1454 == TYPE_MAIN_VARIANT
1455 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1457 op0 = TREE_OPERAND (op0, 0);
1458 str = "->";
1460 if (op_prio (op0) < op_prio (node))
1461 pp_left_paren (buffer);
1462 dump_generic_node (buffer, op0, spc, flags, false);
1463 if (op_prio (op0) < op_prio (node))
1464 pp_right_paren (buffer);
1465 pp_string (buffer, str);
1466 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1467 op0 = component_ref_field_offset (node);
1468 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1470 pp_string (buffer, "{off: ");
1471 dump_generic_node (buffer, op0, spc, flags, false);
1472 pp_right_brace (buffer);
1474 break;
1476 case BIT_FIELD_REF:
1477 pp_string (buffer, "BIT_FIELD_REF <");
1478 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1479 pp_string (buffer, ", ");
1480 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1481 pp_string (buffer, ", ");
1482 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1483 pp_greater (buffer);
1484 break;
1486 case ARRAY_REF:
1487 case ARRAY_RANGE_REF:
1488 op0 = TREE_OPERAND (node, 0);
1489 if (op_prio (op0) < op_prio (node))
1490 pp_left_paren (buffer);
1491 dump_generic_node (buffer, op0, spc, flags, false);
1492 if (op_prio (op0) < op_prio (node))
1493 pp_right_paren (buffer);
1494 pp_left_bracket (buffer);
1495 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1496 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1497 pp_string (buffer, " ...");
1498 pp_right_bracket (buffer);
1500 op0 = array_ref_low_bound (node);
1501 op1 = array_ref_element_size (node);
1503 if (!integer_zerop (op0)
1504 || TREE_OPERAND (node, 2)
1505 || TREE_OPERAND (node, 3))
1507 pp_string (buffer, "{lb: ");
1508 dump_generic_node (buffer, op0, spc, flags, false);
1509 pp_string (buffer, " sz: ");
1510 dump_generic_node (buffer, op1, spc, flags, false);
1511 pp_right_brace (buffer);
1513 break;
1515 case CONSTRUCTOR:
1517 unsigned HOST_WIDE_INT ix;
1518 tree field, val;
1519 bool is_struct_init = false;
1520 bool is_array_init = false;
1521 widest_int curidx;
1522 pp_left_brace (buffer);
1523 if (TREE_CLOBBER_P (node))
1524 pp_string (buffer, "CLOBBER");
1525 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1526 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1527 is_struct_init = true;
1528 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1529 && TYPE_DOMAIN (TREE_TYPE (node))
1530 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1531 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1532 == INTEGER_CST)
1534 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1535 is_array_init = true;
1536 curidx = wi::to_widest (minv);
1538 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1540 if (field)
1542 if (is_struct_init)
1544 pp_dot (buffer);
1545 dump_generic_node (buffer, field, spc, flags, false);
1546 pp_equal (buffer);
1548 else if (is_array_init
1549 && (TREE_CODE (field) != INTEGER_CST
1550 || curidx != wi::to_widest (field)))
1552 pp_left_bracket (buffer);
1553 if (TREE_CODE (field) == RANGE_EXPR)
1555 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1556 flags, false);
1557 pp_string (buffer, " ... ");
1558 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1559 flags, false);
1560 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1561 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1563 else
1564 dump_generic_node (buffer, field, spc, flags, false);
1565 if (TREE_CODE (field) == INTEGER_CST)
1566 curidx = wi::to_widest (field);
1567 pp_string (buffer, "]=");
1570 if (is_array_init)
1571 curidx += 1;
1572 if (val && TREE_CODE (val) == ADDR_EXPR)
1573 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1574 val = TREE_OPERAND (val, 0);
1575 if (val && TREE_CODE (val) == FUNCTION_DECL)
1576 dump_decl_name (buffer, val, flags);
1577 else
1578 dump_generic_node (buffer, val, spc, flags, false);
1579 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1581 pp_comma (buffer);
1582 pp_space (buffer);
1585 pp_right_brace (buffer);
1587 break;
1589 case COMPOUND_EXPR:
1591 tree *tp;
1592 if (flags & TDF_SLIM)
1594 pp_string (buffer, "<COMPOUND_EXPR>");
1595 break;
1598 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1599 spc, flags, !(flags & TDF_SLIM));
1600 if (flags & TDF_SLIM)
1601 newline_and_indent (buffer, spc);
1602 else
1604 pp_comma (buffer);
1605 pp_space (buffer);
1608 for (tp = &TREE_OPERAND (node, 1);
1609 TREE_CODE (*tp) == COMPOUND_EXPR;
1610 tp = &TREE_OPERAND (*tp, 1))
1612 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1613 spc, flags, !(flags & TDF_SLIM));
1614 if (flags & TDF_SLIM)
1615 newline_and_indent (buffer, spc);
1616 else
1618 pp_comma (buffer);
1619 pp_space (buffer);
1623 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1625 break;
1627 case STATEMENT_LIST:
1629 tree_stmt_iterator si;
1630 bool first = true;
1632 if (flags & TDF_SLIM)
1634 pp_string (buffer, "<STATEMENT_LIST>");
1635 break;
1638 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1640 if (!first)
1641 newline_and_indent (buffer, spc);
1642 else
1643 first = false;
1644 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1647 break;
1649 case MODIFY_EXPR:
1650 case INIT_EXPR:
1651 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1652 false);
1653 pp_space (buffer);
1654 pp_equal (buffer);
1655 pp_space (buffer);
1656 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1657 false);
1658 break;
1660 case TARGET_EXPR:
1661 pp_string (buffer, "TARGET_EXPR <");
1662 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1663 pp_comma (buffer);
1664 pp_space (buffer);
1665 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1666 pp_greater (buffer);
1667 break;
1669 case DECL_EXPR:
1670 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1671 is_stmt = false;
1672 break;
1674 case COND_EXPR:
1675 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1677 pp_string (buffer, "if (");
1678 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1679 pp_right_paren (buffer);
1680 /* The lowered cond_exprs should always be printed in full. */
1681 if (COND_EXPR_THEN (node)
1682 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1683 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1684 && COND_EXPR_ELSE (node)
1685 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1686 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1688 pp_space (buffer);
1689 dump_generic_node (buffer, COND_EXPR_THEN (node),
1690 0, flags, true);
1691 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1693 pp_string (buffer, " else ");
1694 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1695 0, flags, true);
1698 else if (!(flags & TDF_SLIM))
1700 /* Output COND_EXPR_THEN. */
1701 if (COND_EXPR_THEN (node))
1703 newline_and_indent (buffer, spc+2);
1704 pp_left_brace (buffer);
1705 newline_and_indent (buffer, spc+4);
1706 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1707 flags, true);
1708 newline_and_indent (buffer, spc+2);
1709 pp_right_brace (buffer);
1712 /* Output COND_EXPR_ELSE. */
1713 if (COND_EXPR_ELSE (node)
1714 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1716 newline_and_indent (buffer, spc);
1717 pp_string (buffer, "else");
1718 newline_and_indent (buffer, spc+2);
1719 pp_left_brace (buffer);
1720 newline_and_indent (buffer, spc+4);
1721 dump_generic_node (buffer, COND_EXPR_ELSE (node), spc+4,
1722 flags, true);
1723 newline_and_indent (buffer, spc+2);
1724 pp_right_brace (buffer);
1727 is_expr = false;
1729 else
1731 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1732 pp_space (buffer);
1733 pp_question (buffer);
1734 pp_space (buffer);
1735 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1736 pp_space (buffer);
1737 pp_colon (buffer);
1738 pp_space (buffer);
1739 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1741 break;
1743 case BIND_EXPR:
1744 pp_left_brace (buffer);
1745 if (!(flags & TDF_SLIM))
1747 if (BIND_EXPR_VARS (node))
1749 pp_newline (buffer);
1751 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1753 print_declaration (buffer, op0, spc+2, flags);
1754 pp_newline (buffer);
1758 newline_and_indent (buffer, spc+2);
1759 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1760 newline_and_indent (buffer, spc);
1761 pp_right_brace (buffer);
1763 is_expr = false;
1764 break;
1766 case CALL_EXPR:
1767 if (CALL_EXPR_FN (node) != NULL_TREE)
1768 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1769 else
1770 pp_string (buffer, internal_fn_name (CALL_EXPR_IFN (node)));
1772 /* Print parameters. */
1773 pp_space (buffer);
1774 pp_left_paren (buffer);
1776 tree arg;
1777 call_expr_arg_iterator iter;
1778 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1780 dump_generic_node (buffer, arg, spc, flags, false);
1781 if (more_call_expr_args_p (&iter))
1783 pp_comma (buffer);
1784 pp_space (buffer);
1788 if (CALL_EXPR_VA_ARG_PACK (node))
1790 if (call_expr_nargs (node) > 0)
1792 pp_comma (buffer);
1793 pp_space (buffer);
1795 pp_string (buffer, "__builtin_va_arg_pack ()");
1797 pp_right_paren (buffer);
1799 op1 = CALL_EXPR_STATIC_CHAIN (node);
1800 if (op1)
1802 pp_string (buffer, " [static-chain: ");
1803 dump_generic_node (buffer, op1, spc, flags, false);
1804 pp_right_bracket (buffer);
1807 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1808 pp_string (buffer, " [return slot optimization]");
1809 if (CALL_EXPR_TAILCALL (node))
1810 pp_string (buffer, " [tail call]");
1811 break;
1813 case WITH_CLEANUP_EXPR:
1814 NIY;
1815 break;
1817 case CLEANUP_POINT_EXPR:
1818 pp_string (buffer, "<<cleanup_point ");
1819 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1820 pp_string (buffer, ">>");
1821 break;
1823 case PLACEHOLDER_EXPR:
1824 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1825 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1826 pp_greater (buffer);
1827 break;
1829 /* Binary arithmetic and logic expressions. */
1830 case WIDEN_SUM_EXPR:
1831 case WIDEN_MULT_EXPR:
1832 case MULT_EXPR:
1833 case MULT_HIGHPART_EXPR:
1834 case PLUS_EXPR:
1835 case POINTER_PLUS_EXPR:
1836 case MINUS_EXPR:
1837 case TRUNC_DIV_EXPR:
1838 case CEIL_DIV_EXPR:
1839 case FLOOR_DIV_EXPR:
1840 case ROUND_DIV_EXPR:
1841 case TRUNC_MOD_EXPR:
1842 case CEIL_MOD_EXPR:
1843 case FLOOR_MOD_EXPR:
1844 case ROUND_MOD_EXPR:
1845 case RDIV_EXPR:
1846 case EXACT_DIV_EXPR:
1847 case LSHIFT_EXPR:
1848 case RSHIFT_EXPR:
1849 case LROTATE_EXPR:
1850 case RROTATE_EXPR:
1851 case VEC_LSHIFT_EXPR:
1852 case VEC_RSHIFT_EXPR:
1853 case WIDEN_LSHIFT_EXPR:
1854 case BIT_IOR_EXPR:
1855 case BIT_XOR_EXPR:
1856 case BIT_AND_EXPR:
1857 case TRUTH_ANDIF_EXPR:
1858 case TRUTH_ORIF_EXPR:
1859 case TRUTH_AND_EXPR:
1860 case TRUTH_OR_EXPR:
1861 case TRUTH_XOR_EXPR:
1862 case LT_EXPR:
1863 case LE_EXPR:
1864 case GT_EXPR:
1865 case GE_EXPR:
1866 case EQ_EXPR:
1867 case NE_EXPR:
1868 case UNLT_EXPR:
1869 case UNLE_EXPR:
1870 case UNGT_EXPR:
1871 case UNGE_EXPR:
1872 case UNEQ_EXPR:
1873 case LTGT_EXPR:
1874 case ORDERED_EXPR:
1875 case UNORDERED_EXPR:
1877 const char *op = op_symbol (node);
1878 op0 = TREE_OPERAND (node, 0);
1879 op1 = TREE_OPERAND (node, 1);
1881 /* When the operands are expressions with less priority,
1882 keep semantics of the tree representation. */
1883 if (op_prio (op0) <= op_prio (node))
1885 pp_left_paren (buffer);
1886 dump_generic_node (buffer, op0, spc, flags, false);
1887 pp_right_paren (buffer);
1889 else
1890 dump_generic_node (buffer, op0, spc, flags, false);
1892 pp_space (buffer);
1893 pp_string (buffer, op);
1894 pp_space (buffer);
1896 /* When the operands are expressions with less priority,
1897 keep semantics of the tree representation. */
1898 if (op_prio (op1) <= op_prio (node))
1900 pp_left_paren (buffer);
1901 dump_generic_node (buffer, op1, spc, flags, false);
1902 pp_right_paren (buffer);
1904 else
1905 dump_generic_node (buffer, op1, spc, flags, false);
1907 break;
1909 /* Unary arithmetic and logic expressions. */
1910 case NEGATE_EXPR:
1911 case BIT_NOT_EXPR:
1912 case TRUTH_NOT_EXPR:
1913 case ADDR_EXPR:
1914 case PREDECREMENT_EXPR:
1915 case PREINCREMENT_EXPR:
1916 case INDIRECT_REF:
1917 if (TREE_CODE (node) == ADDR_EXPR
1918 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1919 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1920 ; /* Do not output '&' for strings and function pointers. */
1921 else
1922 pp_string (buffer, op_symbol (node));
1924 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1926 pp_left_paren (buffer);
1927 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1928 pp_right_paren (buffer);
1930 else
1931 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1932 break;
1934 case POSTDECREMENT_EXPR:
1935 case POSTINCREMENT_EXPR:
1936 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1938 pp_left_paren (buffer);
1939 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1940 pp_right_paren (buffer);
1942 else
1943 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1944 pp_string (buffer, op_symbol (node));
1945 break;
1947 case MIN_EXPR:
1948 pp_string (buffer, "MIN_EXPR <");
1949 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1950 pp_string (buffer, ", ");
1951 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1952 pp_greater (buffer);
1953 break;
1955 case MAX_EXPR:
1956 pp_string (buffer, "MAX_EXPR <");
1957 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1958 pp_string (buffer, ", ");
1959 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1960 pp_greater (buffer);
1961 break;
1963 case ABS_EXPR:
1964 pp_string (buffer, "ABS_EXPR <");
1965 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1966 pp_greater (buffer);
1967 break;
1969 case RANGE_EXPR:
1970 NIY;
1971 break;
1973 case ADDR_SPACE_CONVERT_EXPR:
1974 case FIXED_CONVERT_EXPR:
1975 case FIX_TRUNC_EXPR:
1976 case FLOAT_EXPR:
1977 CASE_CONVERT:
1978 type = TREE_TYPE (node);
1979 op0 = TREE_OPERAND (node, 0);
1980 if (type != TREE_TYPE (op0))
1982 pp_left_paren (buffer);
1983 dump_generic_node (buffer, type, spc, flags, false);
1984 pp_string (buffer, ") ");
1986 if (op_prio (op0) < op_prio (node))
1987 pp_left_paren (buffer);
1988 dump_generic_node (buffer, op0, spc, flags, false);
1989 if (op_prio (op0) < op_prio (node))
1990 pp_right_paren (buffer);
1991 break;
1993 case VIEW_CONVERT_EXPR:
1994 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1995 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1996 pp_string (buffer, ">(");
1997 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1998 pp_right_paren (buffer);
1999 break;
2001 case PAREN_EXPR:
2002 pp_string (buffer, "((");
2003 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2004 pp_string (buffer, "))");
2005 break;
2007 case NON_LVALUE_EXPR:
2008 pp_string (buffer, "NON_LVALUE_EXPR <");
2009 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2010 pp_greater (buffer);
2011 break;
2013 case SAVE_EXPR:
2014 pp_string (buffer, "SAVE_EXPR <");
2015 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2016 pp_greater (buffer);
2017 break;
2019 case COMPLEX_EXPR:
2020 pp_string (buffer, "COMPLEX_EXPR <");
2021 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2022 pp_string (buffer, ", ");
2023 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2024 pp_greater (buffer);
2025 break;
2027 case CONJ_EXPR:
2028 pp_string (buffer, "CONJ_EXPR <");
2029 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2030 pp_greater (buffer);
2031 break;
2033 case REALPART_EXPR:
2034 pp_string (buffer, "REALPART_EXPR <");
2035 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2036 pp_greater (buffer);
2037 break;
2039 case IMAGPART_EXPR:
2040 pp_string (buffer, "IMAGPART_EXPR <");
2041 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2042 pp_greater (buffer);
2043 break;
2045 case VA_ARG_EXPR:
2046 pp_string (buffer, "VA_ARG_EXPR <");
2047 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2048 pp_greater (buffer);
2049 break;
2051 case TRY_FINALLY_EXPR:
2052 case TRY_CATCH_EXPR:
2053 pp_string (buffer, "try");
2054 newline_and_indent (buffer, spc+2);
2055 pp_left_brace (buffer);
2056 newline_and_indent (buffer, spc+4);
2057 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2058 newline_and_indent (buffer, spc+2);
2059 pp_right_brace (buffer);
2060 newline_and_indent (buffer, spc);
2061 pp_string (buffer,
2062 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2063 newline_and_indent (buffer, spc+2);
2064 pp_left_brace (buffer);
2065 newline_and_indent (buffer, spc+4);
2066 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2067 newline_and_indent (buffer, spc+2);
2068 pp_right_brace (buffer);
2069 is_expr = false;
2070 break;
2072 case CATCH_EXPR:
2073 pp_string (buffer, "catch (");
2074 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2075 pp_right_paren (buffer);
2076 newline_and_indent (buffer, spc+2);
2077 pp_left_brace (buffer);
2078 newline_and_indent (buffer, spc+4);
2079 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2080 newline_and_indent (buffer, spc+2);
2081 pp_right_brace (buffer);
2082 is_expr = false;
2083 break;
2085 case EH_FILTER_EXPR:
2086 pp_string (buffer, "<<<eh_filter (");
2087 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2088 pp_string (buffer, ")>>>");
2089 newline_and_indent (buffer, spc+2);
2090 pp_left_brace (buffer);
2091 newline_and_indent (buffer, spc+4);
2092 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2093 newline_and_indent (buffer, spc+2);
2094 pp_right_brace (buffer);
2095 is_expr = false;
2096 break;
2098 case LABEL_EXPR:
2099 op0 = TREE_OPERAND (node, 0);
2100 /* If this is for break or continue, don't bother printing it. */
2101 if (DECL_NAME (op0))
2103 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2104 if (strcmp (name, "break") == 0
2105 || strcmp (name, "continue") == 0)
2106 break;
2108 dump_generic_node (buffer, op0, spc, flags, false);
2109 pp_colon (buffer);
2110 if (DECL_NONLOCAL (op0))
2111 pp_string (buffer, " [non-local]");
2112 break;
2114 case LOOP_EXPR:
2115 pp_string (buffer, "while (1)");
2116 if (!(flags & TDF_SLIM))
2118 newline_and_indent (buffer, spc+2);
2119 pp_left_brace (buffer);
2120 newline_and_indent (buffer, spc+4);
2121 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2122 newline_and_indent (buffer, spc+2);
2123 pp_right_brace (buffer);
2125 is_expr = false;
2126 break;
2128 case PREDICT_EXPR:
2129 pp_string (buffer, "// predicted ");
2130 if (PREDICT_EXPR_OUTCOME (node))
2131 pp_string (buffer, "likely by ");
2132 else
2133 pp_string (buffer, "unlikely by ");
2134 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2135 pp_string (buffer, " predictor.");
2136 break;
2138 case ANNOTATE_EXPR:
2139 pp_string (buffer, "ANNOTATE_EXPR <");
2140 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2141 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2143 case annot_expr_ivdep_kind:
2144 pp_string (buffer, ", ivdep");
2145 break;
2146 case annot_expr_no_vector_kind:
2147 pp_string (buffer, ", no-vector");
2148 break;
2149 case annot_expr_vector_kind:
2150 pp_string (buffer, ", vector");
2151 break;
2152 default:
2153 gcc_unreachable ();
2155 pp_greater (buffer);
2156 break;
2158 case RETURN_EXPR:
2159 pp_string (buffer, "return");
2160 op0 = TREE_OPERAND (node, 0);
2161 if (op0)
2163 pp_space (buffer);
2164 if (TREE_CODE (op0) == MODIFY_EXPR)
2165 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2166 spc, flags, false);
2167 else
2168 dump_generic_node (buffer, op0, spc, flags, false);
2170 break;
2172 case EXIT_EXPR:
2173 pp_string (buffer, "if (");
2174 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2175 pp_string (buffer, ") break");
2176 break;
2178 case SWITCH_EXPR:
2179 pp_string (buffer, "switch (");
2180 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2181 pp_right_paren (buffer);
2182 if (!(flags & TDF_SLIM))
2184 newline_and_indent (buffer, spc+2);
2185 pp_left_brace (buffer);
2186 if (SWITCH_BODY (node))
2188 newline_and_indent (buffer, spc+4);
2189 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2190 true);
2192 else
2194 tree vec = SWITCH_LABELS (node);
2195 size_t i, n = TREE_VEC_LENGTH (vec);
2196 for (i = 0; i < n; ++i)
2198 tree elt = TREE_VEC_ELT (vec, i);
2199 newline_and_indent (buffer, spc+4);
2200 if (elt)
2202 dump_generic_node (buffer, elt, spc+4, flags, false);
2203 pp_string (buffer, " goto ");
2204 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2205 flags, true);
2206 pp_semicolon (buffer);
2208 else
2209 pp_string (buffer, "case ???: goto ???;");
2212 newline_and_indent (buffer, spc+2);
2213 pp_right_brace (buffer);
2215 is_expr = false;
2216 break;
2218 case GOTO_EXPR:
2219 op0 = GOTO_DESTINATION (node);
2220 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2222 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2223 if (strcmp (name, "break") == 0
2224 || strcmp (name, "continue") == 0)
2226 pp_string (buffer, name);
2227 break;
2230 pp_string (buffer, "goto ");
2231 dump_generic_node (buffer, op0, spc, flags, false);
2232 break;
2234 case ASM_EXPR:
2235 pp_string (buffer, "__asm__");
2236 if (ASM_VOLATILE_P (node))
2237 pp_string (buffer, " __volatile__");
2238 pp_left_paren (buffer);
2239 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2240 pp_colon (buffer);
2241 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2242 pp_colon (buffer);
2243 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2244 if (ASM_CLOBBERS (node))
2246 pp_colon (buffer);
2247 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2249 pp_right_paren (buffer);
2250 break;
2252 case CASE_LABEL_EXPR:
2253 if (CASE_LOW (node) && CASE_HIGH (node))
2255 pp_string (buffer, "case ");
2256 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2257 pp_string (buffer, " ... ");
2258 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2260 else if (CASE_LOW (node))
2262 pp_string (buffer, "case ");
2263 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2265 else
2266 pp_string (buffer, "default");
2267 pp_colon (buffer);
2268 break;
2270 case OBJ_TYPE_REF:
2271 pp_string (buffer, "OBJ_TYPE_REF(");
2272 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2273 pp_semicolon (buffer);
2274 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2276 pp_string (buffer, "(");
2277 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2278 pp_string (buffer, ")");
2280 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2281 pp_arrow (buffer);
2282 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2283 pp_right_paren (buffer);
2284 break;
2286 case SSA_NAME:
2287 if (SSA_NAME_IDENTIFIER (node))
2288 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2289 spc, flags, false);
2290 pp_underscore (buffer);
2291 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2292 if (SSA_NAME_IS_DEFAULT_DEF (node))
2293 pp_string (buffer, "(D)");
2294 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2295 pp_string (buffer, "(ab)");
2296 break;
2298 case WITH_SIZE_EXPR:
2299 pp_string (buffer, "WITH_SIZE_EXPR <");
2300 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2301 pp_string (buffer, ", ");
2302 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2303 pp_greater (buffer);
2304 break;
2306 case ASSERT_EXPR:
2307 pp_string (buffer, "ASSERT_EXPR <");
2308 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2309 pp_string (buffer, ", ");
2310 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2311 pp_greater (buffer);
2312 break;
2314 case SCEV_KNOWN:
2315 pp_string (buffer, "scev_known");
2316 break;
2318 case SCEV_NOT_KNOWN:
2319 pp_string (buffer, "scev_not_known");
2320 break;
2322 case POLYNOMIAL_CHREC:
2323 pp_left_brace (buffer);
2324 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2325 pp_string (buffer, ", +, ");
2326 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2327 pp_string (buffer, "}_");
2328 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2329 is_stmt = false;
2330 break;
2332 case REALIGN_LOAD_EXPR:
2333 pp_string (buffer, "REALIGN_LOAD <");
2334 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2335 pp_string (buffer, ", ");
2336 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2337 pp_string (buffer, ", ");
2338 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2339 pp_greater (buffer);
2340 break;
2342 case VEC_COND_EXPR:
2343 pp_string (buffer, " VEC_COND_EXPR < ");
2344 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2345 pp_string (buffer, " , ");
2346 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2347 pp_string (buffer, " , ");
2348 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2349 pp_string (buffer, " > ");
2350 break;
2352 case VEC_PERM_EXPR:
2353 pp_string (buffer, " VEC_PERM_EXPR < ");
2354 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2355 pp_string (buffer, " , ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2357 pp_string (buffer, " , ");
2358 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2359 pp_string (buffer, " > ");
2360 break;
2362 case DOT_PROD_EXPR:
2363 pp_string (buffer, " DOT_PROD_EXPR < ");
2364 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2365 pp_string (buffer, ", ");
2366 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2367 pp_string (buffer, ", ");
2368 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2369 pp_string (buffer, " > ");
2370 break;
2372 case WIDEN_MULT_PLUS_EXPR:
2373 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2374 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2375 pp_string (buffer, ", ");
2376 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2377 pp_string (buffer, ", ");
2378 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2379 pp_string (buffer, " > ");
2380 break;
2382 case WIDEN_MULT_MINUS_EXPR:
2383 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2384 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2385 pp_string (buffer, ", ");
2386 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2387 pp_string (buffer, ", ");
2388 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2389 pp_string (buffer, " > ");
2390 break;
2392 case FMA_EXPR:
2393 pp_string (buffer, " FMA_EXPR < ");
2394 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2395 pp_string (buffer, ", ");
2396 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2397 pp_string (buffer, ", ");
2398 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2399 pp_string (buffer, " > ");
2400 break;
2402 case OMP_PARALLEL:
2403 pp_string (buffer, "#pragma omp parallel");
2404 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2406 dump_omp_body:
2407 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2409 newline_and_indent (buffer, spc + 2);
2410 pp_left_brace (buffer);
2411 newline_and_indent (buffer, spc + 4);
2412 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2413 newline_and_indent (buffer, spc + 2);
2414 pp_right_brace (buffer);
2416 is_expr = false;
2417 break;
2419 case OMP_TASK:
2420 pp_string (buffer, "#pragma omp task");
2421 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2422 goto dump_omp_body;
2424 case OMP_FOR:
2425 pp_string (buffer, "#pragma omp for");
2426 goto dump_omp_loop;
2428 case OMP_SIMD:
2429 pp_string (buffer, "#pragma omp simd");
2430 goto dump_omp_loop;
2432 case CILK_SIMD:
2433 pp_string (buffer, "#pragma simd");
2434 goto dump_omp_loop;
2436 case CILK_FOR:
2437 /* This label points one line after dumping the clauses.
2438 For _Cilk_for the clauses are dumped after the _Cilk_for (...)
2439 parameters are printed out. */
2440 goto dump_omp_loop_cilk_for;
2442 case OMP_DISTRIBUTE:
2443 pp_string (buffer, "#pragma omp distribute");
2444 goto dump_omp_loop;
2446 case OMP_TEAMS:
2447 pp_string (buffer, "#pragma omp teams");
2448 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2449 goto dump_omp_body;
2451 case OMP_TARGET_DATA:
2452 pp_string (buffer, "#pragma omp target data");
2453 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2454 goto dump_omp_body;
2456 case OMP_TARGET:
2457 pp_string (buffer, "#pragma omp target");
2458 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2459 goto dump_omp_body;
2461 case OMP_TARGET_UPDATE:
2462 pp_string (buffer, "#pragma omp target update");
2463 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2464 is_expr = false;
2465 break;
2467 dump_omp_loop:
2468 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2470 dump_omp_loop_cilk_for:
2471 if (!(flags & TDF_SLIM))
2473 int i;
2475 if (OMP_FOR_PRE_BODY (node))
2477 if (TREE_CODE (node) == CILK_FOR)
2478 pp_string (buffer, " ");
2479 else
2480 newline_and_indent (buffer, spc + 2);
2481 pp_left_brace (buffer);
2482 spc += 4;
2483 newline_and_indent (buffer, spc);
2484 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2485 spc, flags, false);
2487 if (OMP_FOR_INIT (node))
2489 spc -= 2;
2490 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2492 spc += 2;
2493 if (TREE_CODE (node) != CILK_FOR || OMP_FOR_PRE_BODY (node))
2494 newline_and_indent (buffer, spc);
2495 if (TREE_CODE (node) == CILK_FOR)
2496 pp_string (buffer, "_Cilk_for (");
2497 else
2498 pp_string (buffer, "for (");
2499 dump_generic_node (buffer,
2500 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2501 spc, flags, false);
2502 pp_string (buffer, "; ");
2503 dump_generic_node (buffer,
2504 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2505 spc, flags, false);
2506 pp_string (buffer, "; ");
2507 dump_generic_node (buffer,
2508 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2509 spc, flags, false);
2510 pp_right_paren (buffer);
2512 if (TREE_CODE (node) == CILK_FOR)
2513 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2515 if (OMP_FOR_BODY (node))
2517 newline_and_indent (buffer, spc + 2);
2518 pp_left_brace (buffer);
2519 newline_and_indent (buffer, spc + 4);
2520 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2521 false);
2522 newline_and_indent (buffer, spc + 2);
2523 pp_right_brace (buffer);
2525 if (OMP_FOR_INIT (node))
2526 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2527 if (OMP_FOR_PRE_BODY (node))
2529 spc -= 4;
2530 newline_and_indent (buffer, spc + 2);
2531 pp_right_brace (buffer);
2534 is_expr = false;
2535 break;
2537 case OMP_SECTIONS:
2538 pp_string (buffer, "#pragma omp sections");
2539 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2540 goto dump_omp_body;
2542 case OMP_SECTION:
2543 pp_string (buffer, "#pragma omp section");
2544 goto dump_omp_body;
2546 case OMP_MASTER:
2547 pp_string (buffer, "#pragma omp master");
2548 goto dump_omp_body;
2550 case OMP_TASKGROUP:
2551 pp_string (buffer, "#pragma omp taskgroup");
2552 goto dump_omp_body;
2554 case OMP_ORDERED:
2555 pp_string (buffer, "#pragma omp ordered");
2556 goto dump_omp_body;
2558 case OMP_CRITICAL:
2559 pp_string (buffer, "#pragma omp critical");
2560 if (OMP_CRITICAL_NAME (node))
2562 pp_space (buffer);
2563 pp_left_paren (buffer);
2564 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2565 flags, false);
2566 pp_right_paren (buffer);
2568 goto dump_omp_body;
2570 case OMP_ATOMIC:
2571 pp_string (buffer, "#pragma omp atomic");
2572 if (OMP_ATOMIC_SEQ_CST (node))
2573 pp_string (buffer, " seq_cst");
2574 newline_and_indent (buffer, spc + 2);
2575 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2576 pp_space (buffer);
2577 pp_equal (buffer);
2578 pp_space (buffer);
2579 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2580 break;
2582 case OMP_ATOMIC_READ:
2583 pp_string (buffer, "#pragma omp atomic read");
2584 if (OMP_ATOMIC_SEQ_CST (node))
2585 pp_string (buffer, " seq_cst");
2586 newline_and_indent (buffer, spc + 2);
2587 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2588 pp_space (buffer);
2589 break;
2591 case OMP_ATOMIC_CAPTURE_OLD:
2592 case OMP_ATOMIC_CAPTURE_NEW:
2593 pp_string (buffer, "#pragma omp atomic capture");
2594 if (OMP_ATOMIC_SEQ_CST (node))
2595 pp_string (buffer, " seq_cst");
2596 newline_and_indent (buffer, spc + 2);
2597 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2598 pp_space (buffer);
2599 pp_equal (buffer);
2600 pp_space (buffer);
2601 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2602 break;
2604 case OMP_SINGLE:
2605 pp_string (buffer, "#pragma omp single");
2606 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2607 goto dump_omp_body;
2609 case OMP_CLAUSE:
2610 dump_omp_clause (buffer, node, spc, flags);
2611 is_expr = false;
2612 break;
2614 case TRANSACTION_EXPR:
2615 if (TRANSACTION_EXPR_OUTER (node))
2616 pp_string (buffer, "__transaction_atomic [[outer]]");
2617 else if (TRANSACTION_EXPR_RELAXED (node))
2618 pp_string (buffer, "__transaction_relaxed");
2619 else
2620 pp_string (buffer, "__transaction_atomic");
2621 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2623 newline_and_indent (buffer, spc);
2624 pp_left_brace (buffer);
2625 newline_and_indent (buffer, spc + 2);
2626 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2627 spc + 2, flags, false);
2628 newline_and_indent (buffer, spc);
2629 pp_right_brace (buffer);
2631 is_expr = false;
2632 break;
2634 case REDUC_MAX_EXPR:
2635 pp_string (buffer, " REDUC_MAX_EXPR < ");
2636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2637 pp_string (buffer, " > ");
2638 break;
2640 case REDUC_MIN_EXPR:
2641 pp_string (buffer, " REDUC_MIN_EXPR < ");
2642 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2643 pp_string (buffer, " > ");
2644 break;
2646 case REDUC_PLUS_EXPR:
2647 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2648 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2649 pp_string (buffer, " > ");
2650 break;
2652 case VEC_WIDEN_MULT_HI_EXPR:
2653 case VEC_WIDEN_MULT_LO_EXPR:
2654 case VEC_WIDEN_MULT_EVEN_EXPR:
2655 case VEC_WIDEN_MULT_ODD_EXPR:
2656 case VEC_WIDEN_LSHIFT_HI_EXPR:
2657 case VEC_WIDEN_LSHIFT_LO_EXPR:
2658 pp_space (buffer);
2659 for (str = get_tree_code_name (code); *str; str++)
2660 pp_character (buffer, TOUPPER (*str));
2661 pp_string (buffer, " < ");
2662 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2663 pp_string (buffer, ", ");
2664 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2665 pp_string (buffer, " > ");
2666 break;
2668 case VEC_UNPACK_HI_EXPR:
2669 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2670 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2671 pp_string (buffer, " > ");
2672 break;
2674 case VEC_UNPACK_LO_EXPR:
2675 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2676 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2677 pp_string (buffer, " > ");
2678 break;
2680 case VEC_UNPACK_FLOAT_HI_EXPR:
2681 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2682 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2683 pp_string (buffer, " > ");
2684 break;
2686 case VEC_UNPACK_FLOAT_LO_EXPR:
2687 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2688 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2689 pp_string (buffer, " > ");
2690 break;
2692 case VEC_PACK_TRUNC_EXPR:
2693 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2694 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2695 pp_string (buffer, ", ");
2696 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2697 pp_string (buffer, " > ");
2698 break;
2700 case VEC_PACK_SAT_EXPR:
2701 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2702 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2703 pp_string (buffer, ", ");
2704 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2705 pp_string (buffer, " > ");
2706 break;
2708 case VEC_PACK_FIX_TRUNC_EXPR:
2709 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2710 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2711 pp_string (buffer, ", ");
2712 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2713 pp_string (buffer, " > ");
2714 break;
2716 case BLOCK:
2717 dump_block_node (buffer, node, spc, flags);
2718 break;
2720 case CILK_SPAWN_STMT:
2721 pp_string (buffer, "_Cilk_spawn ");
2722 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2723 break;
2725 case CILK_SYNC_STMT:
2726 pp_string (buffer, "_Cilk_sync");
2727 break;
2729 default:
2730 NIY;
2733 if (is_stmt && is_expr)
2734 pp_semicolon (buffer);
2736 return spc;
2739 /* Print the declaration of a variable. */
2741 void
2742 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2744 INDENT (spc);
2746 if (TREE_CODE(t) == NAMELIST_DECL)
2748 pp_string(buffer, "namelist ");
2749 dump_decl_name (buffer, t, flags);
2750 pp_semicolon (buffer);
2751 return;
2754 if (TREE_CODE (t) == TYPE_DECL)
2755 pp_string (buffer, "typedef ");
2757 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2758 pp_string (buffer, "register ");
2760 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2761 pp_string (buffer, "extern ");
2762 else if (TREE_STATIC (t))
2763 pp_string (buffer, "static ");
2765 /* Print the type and name. */
2766 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2768 tree tmp;
2770 /* Print array's type. */
2771 tmp = TREE_TYPE (t);
2772 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2773 tmp = TREE_TYPE (tmp);
2774 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2776 /* Print variable's name. */
2777 pp_space (buffer);
2778 dump_generic_node (buffer, t, spc, flags, false);
2780 /* Print the dimensions. */
2781 tmp = TREE_TYPE (t);
2782 while (TREE_CODE (tmp) == ARRAY_TYPE)
2784 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2785 tmp = TREE_TYPE (tmp);
2788 else if (TREE_CODE (t) == FUNCTION_DECL)
2790 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2791 pp_space (buffer);
2792 dump_decl_name (buffer, t, flags);
2793 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2795 else
2797 /* Print type declaration. */
2798 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2800 /* Print variable's name. */
2801 pp_space (buffer);
2802 dump_generic_node (buffer, t, spc, flags, false);
2805 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2807 pp_string (buffer, " __asm__ ");
2808 pp_left_paren (buffer);
2809 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2810 pp_right_paren (buffer);
2813 /* The initial value of a function serves to determine whether the function
2814 is declared or defined. So the following does not apply to function
2815 nodes. */
2816 if (TREE_CODE (t) != FUNCTION_DECL)
2818 /* Print the initial value. */
2819 if (DECL_INITIAL (t))
2821 pp_space (buffer);
2822 pp_equal (buffer);
2823 pp_space (buffer);
2824 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2828 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2830 pp_string (buffer, " [value-expr: ");
2831 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2832 pp_right_bracket (buffer);
2835 pp_semicolon (buffer);
2839 /* Prints a structure: name, fields, and methods.
2840 FIXME: Still incomplete. */
2842 static void
2843 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2845 /* Print the name of the structure. */
2846 if (TYPE_NAME (node))
2848 INDENT (spc);
2849 if (TREE_CODE (node) == RECORD_TYPE)
2850 pp_string (buffer, "struct ");
2851 else if ((TREE_CODE (node) == UNION_TYPE
2852 || TREE_CODE (node) == QUAL_UNION_TYPE))
2853 pp_string (buffer, "union ");
2855 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2858 /* Print the contents of the structure. */
2859 pp_newline (buffer);
2860 INDENT (spc);
2861 pp_left_brace (buffer);
2862 pp_newline (buffer);
2864 /* Print the fields of the structure. */
2866 tree tmp;
2867 tmp = TYPE_FIELDS (node);
2868 while (tmp)
2870 /* Avoid to print recursively the structure. */
2871 /* FIXME : Not implemented correctly...,
2872 what about the case when we have a cycle in the contain graph? ...
2873 Maybe this could be solved by looking at the scope in which the
2874 structure was declared. */
2875 if (TREE_TYPE (tmp) != node
2876 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2877 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2879 print_declaration (buffer, tmp, spc+2, flags);
2880 pp_newline (buffer);
2882 tmp = DECL_CHAIN (tmp);
2885 INDENT (spc);
2886 pp_right_brace (buffer);
2889 /* Return the priority of the operator CODE.
2891 From lowest to highest precedence with either left-to-right (L-R)
2892 or right-to-left (R-L) associativity]:
2894 1 [L-R] ,
2895 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2896 3 [R-L] ?:
2897 4 [L-R] ||
2898 5 [L-R] &&
2899 6 [L-R] |
2900 7 [L-R] ^
2901 8 [L-R] &
2902 9 [L-R] == !=
2903 10 [L-R] < <= > >=
2904 11 [L-R] << >>
2905 12 [L-R] + -
2906 13 [L-R] * / %
2907 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2908 15 [L-R] fn() [] -> .
2910 unary +, - and * have higher precedence than the corresponding binary
2911 operators. */
2914 op_code_prio (enum tree_code code)
2916 switch (code)
2918 case TREE_LIST:
2919 case COMPOUND_EXPR:
2920 case BIND_EXPR:
2921 return 1;
2923 case MODIFY_EXPR:
2924 case INIT_EXPR:
2925 return 2;
2927 case COND_EXPR:
2928 return 3;
2930 case TRUTH_OR_EXPR:
2931 case TRUTH_ORIF_EXPR:
2932 return 4;
2934 case TRUTH_AND_EXPR:
2935 case TRUTH_ANDIF_EXPR:
2936 return 5;
2938 case BIT_IOR_EXPR:
2939 return 6;
2941 case BIT_XOR_EXPR:
2942 case TRUTH_XOR_EXPR:
2943 return 7;
2945 case BIT_AND_EXPR:
2946 return 8;
2948 case EQ_EXPR:
2949 case NE_EXPR:
2950 return 9;
2952 case UNLT_EXPR:
2953 case UNLE_EXPR:
2954 case UNGT_EXPR:
2955 case UNGE_EXPR:
2956 case UNEQ_EXPR:
2957 case LTGT_EXPR:
2958 case ORDERED_EXPR:
2959 case UNORDERED_EXPR:
2960 case LT_EXPR:
2961 case LE_EXPR:
2962 case GT_EXPR:
2963 case GE_EXPR:
2964 return 10;
2966 case LSHIFT_EXPR:
2967 case RSHIFT_EXPR:
2968 case LROTATE_EXPR:
2969 case RROTATE_EXPR:
2970 case VEC_WIDEN_LSHIFT_HI_EXPR:
2971 case VEC_WIDEN_LSHIFT_LO_EXPR:
2972 case WIDEN_LSHIFT_EXPR:
2973 return 11;
2975 case WIDEN_SUM_EXPR:
2976 case PLUS_EXPR:
2977 case POINTER_PLUS_EXPR:
2978 case MINUS_EXPR:
2979 return 12;
2981 case VEC_WIDEN_MULT_HI_EXPR:
2982 case VEC_WIDEN_MULT_LO_EXPR:
2983 case WIDEN_MULT_EXPR:
2984 case DOT_PROD_EXPR:
2985 case WIDEN_MULT_PLUS_EXPR:
2986 case WIDEN_MULT_MINUS_EXPR:
2987 case MULT_EXPR:
2988 case MULT_HIGHPART_EXPR:
2989 case TRUNC_DIV_EXPR:
2990 case CEIL_DIV_EXPR:
2991 case FLOOR_DIV_EXPR:
2992 case ROUND_DIV_EXPR:
2993 case RDIV_EXPR:
2994 case EXACT_DIV_EXPR:
2995 case TRUNC_MOD_EXPR:
2996 case CEIL_MOD_EXPR:
2997 case FLOOR_MOD_EXPR:
2998 case ROUND_MOD_EXPR:
2999 case FMA_EXPR:
3000 return 13;
3002 case TRUTH_NOT_EXPR:
3003 case BIT_NOT_EXPR:
3004 case POSTINCREMENT_EXPR:
3005 case POSTDECREMENT_EXPR:
3006 case PREINCREMENT_EXPR:
3007 case PREDECREMENT_EXPR:
3008 case NEGATE_EXPR:
3009 case INDIRECT_REF:
3010 case ADDR_EXPR:
3011 case FLOAT_EXPR:
3012 CASE_CONVERT:
3013 case FIX_TRUNC_EXPR:
3014 case TARGET_EXPR:
3015 return 14;
3017 case CALL_EXPR:
3018 case ARRAY_REF:
3019 case ARRAY_RANGE_REF:
3020 case COMPONENT_REF:
3021 return 15;
3023 /* Special expressions. */
3024 case MIN_EXPR:
3025 case MAX_EXPR:
3026 case ABS_EXPR:
3027 case REALPART_EXPR:
3028 case IMAGPART_EXPR:
3029 case REDUC_MAX_EXPR:
3030 case REDUC_MIN_EXPR:
3031 case REDUC_PLUS_EXPR:
3032 case VEC_LSHIFT_EXPR:
3033 case VEC_RSHIFT_EXPR:
3034 case VEC_UNPACK_HI_EXPR:
3035 case VEC_UNPACK_LO_EXPR:
3036 case VEC_UNPACK_FLOAT_HI_EXPR:
3037 case VEC_UNPACK_FLOAT_LO_EXPR:
3038 case VEC_PACK_TRUNC_EXPR:
3039 case VEC_PACK_SAT_EXPR:
3040 return 16;
3042 default:
3043 /* Return an arbitrarily high precedence to avoid surrounding single
3044 VAR_DECLs in ()s. */
3045 return 9999;
3049 /* Return the priority of the operator OP. */
3052 op_prio (const_tree op)
3054 enum tree_code code;
3056 if (op == NULL)
3057 return 9999;
3059 code = TREE_CODE (op);
3060 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3061 return op_prio (TREE_OPERAND (op, 0));
3063 return op_code_prio (code);
3066 /* Return the symbol associated with operator CODE. */
3068 const char *
3069 op_symbol_code (enum tree_code code)
3071 switch (code)
3073 case MODIFY_EXPR:
3074 return "=";
3076 case TRUTH_OR_EXPR:
3077 case TRUTH_ORIF_EXPR:
3078 return "||";
3080 case TRUTH_AND_EXPR:
3081 case TRUTH_ANDIF_EXPR:
3082 return "&&";
3084 case BIT_IOR_EXPR:
3085 return "|";
3087 case TRUTH_XOR_EXPR:
3088 case BIT_XOR_EXPR:
3089 return "^";
3091 case ADDR_EXPR:
3092 case BIT_AND_EXPR:
3093 return "&";
3095 case ORDERED_EXPR:
3096 return "ord";
3097 case UNORDERED_EXPR:
3098 return "unord";
3100 case EQ_EXPR:
3101 return "==";
3102 case UNEQ_EXPR:
3103 return "u==";
3105 case NE_EXPR:
3106 return "!=";
3108 case LT_EXPR:
3109 return "<";
3110 case UNLT_EXPR:
3111 return "u<";
3113 case LE_EXPR:
3114 return "<=";
3115 case UNLE_EXPR:
3116 return "u<=";
3118 case GT_EXPR:
3119 return ">";
3120 case UNGT_EXPR:
3121 return "u>";
3123 case GE_EXPR:
3124 return ">=";
3125 case UNGE_EXPR:
3126 return "u>=";
3128 case LTGT_EXPR:
3129 return "<>";
3131 case LSHIFT_EXPR:
3132 return "<<";
3134 case RSHIFT_EXPR:
3135 return ">>";
3137 case LROTATE_EXPR:
3138 return "r<<";
3140 case RROTATE_EXPR:
3141 return "r>>";
3143 case VEC_LSHIFT_EXPR:
3144 return "v<<";
3146 case VEC_RSHIFT_EXPR:
3147 return "v>>";
3149 case WIDEN_LSHIFT_EXPR:
3150 return "w<<";
3152 case POINTER_PLUS_EXPR:
3153 return "+";
3155 case PLUS_EXPR:
3156 return "+";
3158 case REDUC_PLUS_EXPR:
3159 return "r+";
3161 case WIDEN_SUM_EXPR:
3162 return "w+";
3164 case WIDEN_MULT_EXPR:
3165 return "w*";
3167 case MULT_HIGHPART_EXPR:
3168 return "h*";
3170 case NEGATE_EXPR:
3171 case MINUS_EXPR:
3172 return "-";
3174 case BIT_NOT_EXPR:
3175 return "~";
3177 case TRUTH_NOT_EXPR:
3178 return "!";
3180 case MULT_EXPR:
3181 case INDIRECT_REF:
3182 return "*";
3184 case TRUNC_DIV_EXPR:
3185 case RDIV_EXPR:
3186 return "/";
3188 case CEIL_DIV_EXPR:
3189 return "/[cl]";
3191 case FLOOR_DIV_EXPR:
3192 return "/[fl]";
3194 case ROUND_DIV_EXPR:
3195 return "/[rd]";
3197 case EXACT_DIV_EXPR:
3198 return "/[ex]";
3200 case TRUNC_MOD_EXPR:
3201 return "%";
3203 case CEIL_MOD_EXPR:
3204 return "%[cl]";
3206 case FLOOR_MOD_EXPR:
3207 return "%[fl]";
3209 case ROUND_MOD_EXPR:
3210 return "%[rd]";
3212 case PREDECREMENT_EXPR:
3213 return " --";
3215 case PREINCREMENT_EXPR:
3216 return " ++";
3218 case POSTDECREMENT_EXPR:
3219 return "-- ";
3221 case POSTINCREMENT_EXPR:
3222 return "++ ";
3224 case MAX_EXPR:
3225 return "max";
3227 case MIN_EXPR:
3228 return "min";
3230 default:
3231 return "<<< ??? >>>";
3235 /* Return the symbol associated with operator OP. */
3237 static const char *
3238 op_symbol (const_tree op)
3240 return op_symbol_code (TREE_CODE (op));
3243 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3244 the gimple_call_fn of a GIMPLE_CALL. */
3246 void
3247 print_call_name (pretty_printer *buffer, tree node, int flags)
3249 tree op0 = node;
3251 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3252 op0 = TREE_OPERAND (op0, 0);
3254 again:
3255 switch (TREE_CODE (op0))
3257 case VAR_DECL:
3258 case PARM_DECL:
3259 case FUNCTION_DECL:
3260 dump_function_name (buffer, op0, flags);
3261 break;
3263 case ADDR_EXPR:
3264 case INDIRECT_REF:
3265 case NOP_EXPR:
3266 op0 = TREE_OPERAND (op0, 0);
3267 goto again;
3269 case COND_EXPR:
3270 pp_left_paren (buffer);
3271 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3272 pp_string (buffer, ") ? ");
3273 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3274 pp_string (buffer, " : ");
3275 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3276 break;
3278 case ARRAY_REF:
3279 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3280 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3281 else
3282 dump_generic_node (buffer, op0, 0, flags, false);
3283 break;
3285 case MEM_REF:
3286 if (integer_zerop (TREE_OPERAND (op0, 1)))
3288 op0 = TREE_OPERAND (op0, 0);
3289 goto again;
3291 /* Fallthru. */
3292 case COMPONENT_REF:
3293 case SSA_NAME:
3294 case OBJ_TYPE_REF:
3295 dump_generic_node (buffer, op0, 0, flags, false);
3296 break;
3298 default:
3299 NIY;
3303 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3305 static void
3306 pretty_print_string (pretty_printer *buffer, const char *str)
3308 if (str == NULL)
3309 return;
3311 while (*str)
3313 switch (str[0])
3315 case '\b':
3316 pp_string (buffer, "\\b");
3317 break;
3319 case '\f':
3320 pp_string (buffer, "\\f");
3321 break;
3323 case '\n':
3324 pp_string (buffer, "\\n");
3325 break;
3327 case '\r':
3328 pp_string (buffer, "\\r");
3329 break;
3331 case '\t':
3332 pp_string (buffer, "\\t");
3333 break;
3335 case '\v':
3336 pp_string (buffer, "\\v");
3337 break;
3339 case '\\':
3340 pp_string (buffer, "\\\\");
3341 break;
3343 case '\"':
3344 pp_string (buffer, "\\\"");
3345 break;
3347 case '\'':
3348 pp_string (buffer, "\\'");
3349 break;
3351 /* No need to handle \0; the loop terminates on \0. */
3353 case '\1':
3354 pp_string (buffer, "\\1");
3355 break;
3357 case '\2':
3358 pp_string (buffer, "\\2");
3359 break;
3361 case '\3':
3362 pp_string (buffer, "\\3");
3363 break;
3365 case '\4':
3366 pp_string (buffer, "\\4");
3367 break;
3369 case '\5':
3370 pp_string (buffer, "\\5");
3371 break;
3373 case '\6':
3374 pp_string (buffer, "\\6");
3375 break;
3377 case '\7':
3378 pp_string (buffer, "\\7");
3379 break;
3381 default:
3382 pp_character (buffer, str[0]);
3383 break;
3385 str++;
3389 static void
3390 maybe_init_pretty_print (FILE *file)
3392 if (!initialized)
3394 new (&buffer) pretty_printer ();
3395 pp_needs_newline (&buffer) = true;
3396 pp_translate_identifiers (&buffer) = false;
3397 initialized = 1;
3400 buffer.buffer->stream = file;
3403 static void
3404 newline_and_indent (pretty_printer *buffer, int spc)
3406 pp_newline (buffer);
3407 INDENT (spc);
3410 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3411 it can also be used in front ends.
3412 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3415 void
3416 percent_K_format (text_info *text)
3418 tree t = va_arg (*text->args_ptr, tree), block;
3419 gcc_assert (text->locus != NULL);
3420 *text->locus = EXPR_LOCATION (t);
3421 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3422 block = TREE_BLOCK (t);
3423 *pp_ti_abstract_origin (text) = NULL;
3425 if (in_lto_p)
3427 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3428 representing the outermost block of an inlined function.
3429 So walk the BLOCK tree until we hit such a scope. */
3430 while (block
3431 && TREE_CODE (block) == BLOCK)
3433 if (inlined_function_outer_scope_p (block))
3435 *pp_ti_abstract_origin (text) = block;
3436 break;
3438 block = BLOCK_SUPERCONTEXT (block);
3440 return;
3443 while (block
3444 && TREE_CODE (block) == BLOCK
3445 && BLOCK_ABSTRACT_ORIGIN (block))
3447 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3449 while (TREE_CODE (ao) == BLOCK
3450 && BLOCK_ABSTRACT_ORIGIN (ao)
3451 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3452 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3454 if (TREE_CODE (ao) == FUNCTION_DECL)
3456 *pp_ti_abstract_origin (text) = block;
3457 break;
3459 block = BLOCK_SUPERCONTEXT (block);
3463 /* Print the identifier ID to PRETTY-PRINTER. */
3465 void
3466 pp_tree_identifier (pretty_printer *pp, tree id)
3468 if (pp_translate_identifiers (pp))
3470 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3471 pp_append_text (pp, text, text + strlen (text));
3473 else
3474 pp_append_text (pp, IDENTIFIER_POINTER (id),
3475 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3478 /* A helper function that is used to dump function information before the
3479 function dump. */
3481 void
3482 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3484 const char *dname, *aname;
3485 struct cgraph_node *node = cgraph_node::get (fdecl);
3486 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3488 dname = lang_hooks.decl_printable_name (fdecl, 2);
3490 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3491 aname = (IDENTIFIER_POINTER
3492 (DECL_ASSEMBLER_NAME (fdecl)));
3493 else
3494 aname = "<unset-asm-name>";
3496 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3497 dname, aname, fun->funcdef_no);
3498 if (!(flags & TDF_NOUID))
3499 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3500 if (node)
3502 fprintf (dump_file, ", cgraph_uid=%d", node->uid);
3503 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3504 node->frequency == NODE_FREQUENCY_HOT
3505 ? " (hot)"
3506 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3507 ? " (unlikely executed)"
3508 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3509 ? " (executed once)"
3510 : "");
3512 else
3513 fprintf (dump_file, ")\n\n");
3516 /* Dump double_int D to pretty_printer PP. UNS is true
3517 if D is unsigned and false otherwise. */
3518 void
3519 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3521 if (d.fits_shwi ())
3522 pp_wide_integer (pp, d.low);
3523 else if (d.fits_uhwi ())
3524 pp_unsigned_wide_integer (pp, d.low);
3525 else
3527 unsigned HOST_WIDE_INT low = d.low;
3528 HOST_WIDE_INT high = d.high;
3529 if (!uns && d.is_negative ())
3531 pp_minus (pp);
3532 high = ~high + !low;
3533 low = -low;
3535 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3536 systems? */
3537 sprintf (pp_buffer (pp)->digit_buffer,
3538 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3539 (unsigned HOST_WIDE_INT) high, low);
3540 pp_string (pp, pp_buffer (pp)->digit_buffer);