* rtl.h (insn_location): Declare.
[official-gcc.git] / gcc / tree-pretty-print.c
blobc5b4aeeb4cdcc64831aaf2678acd6b0008d821d0
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 "pointer-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"
41 #include <new> // For placement-new.
43 /* Local functions, macros and variables. */
44 static const char *op_symbol (const_tree);
45 static void pretty_print_string (pretty_printer *, const char*);
46 static void newline_and_indent (pretty_printer *, int);
47 static void maybe_init_pretty_print (FILE *);
48 static void print_struct_decl (pretty_printer *, const_tree, int, int);
49 static void do_niy (pretty_printer *, const_tree);
51 #define INDENT(SPACE) do { \
52 int i; for (i = 0; i<SPACE; i++) pp_space (buffer); } while (0)
54 #define NIY do_niy (buffer, node)
56 static pretty_printer buffer;
57 static int initialized = 0;
59 /* Try to print something for an unknown tree code. */
61 static void
62 do_niy (pretty_printer *buffer, const_tree node)
64 int i, len;
66 pp_string (buffer, "<<< Unknown tree: ");
67 pp_string (buffer, get_tree_code_name (TREE_CODE (node)));
69 if (EXPR_P (node))
71 len = TREE_OPERAND_LENGTH (node);
72 for (i = 0; i < len; ++i)
74 newline_and_indent (buffer, 2);
75 dump_generic_node (buffer, TREE_OPERAND (node, i), 2, 0, false);
79 pp_string (buffer, " >>>");
82 /* Debugging function to print out a generic expression. */
84 DEBUG_FUNCTION void
85 debug_generic_expr (tree t)
87 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS);
88 fprintf (stderr, "\n");
91 /* Debugging function to print out a generic statement. */
93 DEBUG_FUNCTION void
94 debug_generic_stmt (tree t)
96 print_generic_stmt (stderr, t, TDF_VOPS|TDF_MEMSYMS);
97 fprintf (stderr, "\n");
100 /* Debugging function to print out a chain of trees . */
102 DEBUG_FUNCTION void
103 debug_tree_chain (tree t)
105 struct pointer_set_t *seen = pointer_set_create ();
107 while (t)
109 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
110 fprintf (stderr, " ");
111 t = TREE_CHAIN (t);
112 if (pointer_set_insert (seen, t))
114 fprintf (stderr, "... [cycled back to ");
115 print_generic_expr (stderr, t, TDF_VOPS|TDF_MEMSYMS|TDF_UID);
116 fprintf (stderr, "]");
117 break;
120 fprintf (stderr, "\n");
122 pointer_set_destroy (seen);
125 /* Prints declaration DECL to the FILE with details specified by FLAGS. */
126 void
127 print_generic_decl (FILE *file, tree decl, int flags)
129 maybe_init_pretty_print (file);
130 print_declaration (&buffer, decl, 2, flags);
131 pp_write_text_to_stream (&buffer);
134 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
135 to show in the dump. See TDF_* in dumpfile.h. */
137 void
138 print_generic_stmt (FILE *file, tree t, int flags)
140 maybe_init_pretty_print (file);
141 dump_generic_node (&buffer, t, 0, flags, true);
142 pp_newline_and_flush (&buffer);
145 /* Print tree T, and its successors, on file FILE. FLAGS specifies details
146 to show in the dump. See TDF_* in dumpfile.h. The output is indented by
147 INDENT spaces. */
149 void
150 print_generic_stmt_indented (FILE *file, tree t, int flags, int indent)
152 int i;
154 maybe_init_pretty_print (file);
156 for (i = 0; i < indent; i++)
157 pp_space (&buffer);
158 dump_generic_node (&buffer, t, indent, flags, true);
159 pp_newline_and_flush (&buffer);
162 /* Print a single expression T on file FILE. FLAGS specifies details to show
163 in the dump. See TDF_* in dumpfile.h. */
165 void
166 print_generic_expr (FILE *file, tree t, int flags)
168 maybe_init_pretty_print (file);
169 dump_generic_node (&buffer, t, 0, flags, false);
170 pp_flush (&buffer);
173 /* Dump the name of a _DECL node and its DECL_UID if TDF_UID is set
174 in FLAGS. */
176 static void
177 dump_decl_name (pretty_printer *buffer, tree node, int flags)
179 if (DECL_NAME (node))
181 if ((flags & TDF_ASMNAME) && DECL_ASSEMBLER_NAME_SET_P (node))
182 pp_tree_identifier (buffer, DECL_ASSEMBLER_NAME (node));
183 else
184 pp_tree_identifier (buffer, DECL_NAME (node));
186 if ((flags & TDF_UID) || DECL_NAME (node) == NULL_TREE)
188 if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
189 pp_printf (buffer, "L.%d", (int) LABEL_DECL_UID (node));
190 else if (TREE_CODE (node) == DEBUG_EXPR_DECL)
192 if (flags & TDF_NOUID)
193 pp_string (buffer, "D#xxxx");
194 else
195 pp_printf (buffer, "D#%i", DEBUG_TEMP_UID (node));
197 else
199 char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
200 if (flags & TDF_NOUID)
201 pp_printf (buffer, "%c.xxxx", c);
202 else
203 pp_printf (buffer, "%c.%u", c, DECL_UID (node));
206 if ((flags & TDF_ALIAS) && DECL_PT_UID (node) != DECL_UID (node))
208 if (flags & TDF_NOUID)
209 pp_printf (buffer, "ptD.xxxx");
210 else
211 pp_printf (buffer, "ptD.%u", DECL_PT_UID (node));
215 /* Like the above, but used for pretty printing function calls. */
217 static void
218 dump_function_name (pretty_printer *buffer, tree node, int flags)
220 if (TREE_CODE (node) == NOP_EXPR)
221 node = TREE_OPERAND (node, 0);
222 if (DECL_NAME (node) && (flags & TDF_ASMNAME) == 0)
223 pp_string (buffer, lang_hooks.decl_printable_name (node, 1));
224 else
225 dump_decl_name (buffer, node, flags);
228 /* Dump a function declaration. NODE is the FUNCTION_TYPE. BUFFER, SPC and
229 FLAGS are as in dump_generic_node. */
231 static void
232 dump_function_declaration (pretty_printer *buffer, tree node,
233 int spc, int flags)
235 bool wrote_arg = false;
236 tree arg;
238 pp_space (buffer);
239 pp_left_paren (buffer);
241 /* Print the argument types. */
242 arg = TYPE_ARG_TYPES (node);
243 while (arg && arg != void_list_node && arg != error_mark_node)
245 if (wrote_arg)
247 pp_comma (buffer);
248 pp_space (buffer);
250 wrote_arg = true;
251 dump_generic_node (buffer, TREE_VALUE (arg), spc, flags, false);
252 arg = TREE_CHAIN (arg);
255 /* Drop the trailing void_type_node if we had any previous argument. */
256 if (arg == void_list_node && !wrote_arg)
257 pp_string (buffer, "void");
258 /* Properly dump vararg function types. */
259 else if (!arg && wrote_arg)
260 pp_string (buffer, ", ...");
261 /* Avoid printing any arg for unprototyped functions. */
263 pp_right_paren (buffer);
266 /* Dump the domain associated with an array. */
268 static void
269 dump_array_domain (pretty_printer *buffer, tree domain, int spc, int flags)
271 pp_left_bracket (buffer);
272 if (domain)
274 tree min = TYPE_MIN_VALUE (domain);
275 tree max = TYPE_MAX_VALUE (domain);
277 if (min && max
278 && integer_zerop (min)
279 && tree_fits_shwi_p (max))
280 pp_wide_integer (buffer, tree_to_shwi (max) + 1);
281 else
283 if (min)
284 dump_generic_node (buffer, min, spc, flags, false);
285 pp_colon (buffer);
286 if (max)
287 dump_generic_node (buffer, max, spc, flags, false);
290 else
291 pp_string (buffer, "<unknown>");
292 pp_right_bracket (buffer);
296 /* Dump OpenMP clause CLAUSE. BUFFER, CLAUSE, SPC and FLAGS are as in
297 dump_generic_node. */
299 static void
300 dump_omp_clause (pretty_printer *buffer, tree clause, int spc, int flags)
302 const char *name;
304 switch (OMP_CLAUSE_CODE (clause))
306 case OMP_CLAUSE_PRIVATE:
307 name = "private";
308 goto print_remap;
309 case OMP_CLAUSE_SHARED:
310 name = "shared";
311 goto print_remap;
312 case OMP_CLAUSE_FIRSTPRIVATE:
313 name = "firstprivate";
314 goto print_remap;
315 case OMP_CLAUSE_LASTPRIVATE:
316 name = "lastprivate";
317 goto print_remap;
318 case OMP_CLAUSE_COPYIN:
319 name = "copyin";
320 goto print_remap;
321 case OMP_CLAUSE_COPYPRIVATE:
322 name = "copyprivate";
323 goto print_remap;
324 case OMP_CLAUSE_UNIFORM:
325 name = "uniform";
326 goto print_remap;
327 case OMP_CLAUSE__LOOPTEMP_:
328 name = "_looptemp_";
329 goto print_remap;
330 print_remap:
331 pp_string (buffer, name);
332 pp_left_paren (buffer);
333 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
334 spc, flags, false);
335 pp_right_paren (buffer);
336 break;
338 case OMP_CLAUSE_REDUCTION:
339 pp_string (buffer, "reduction(");
340 if (OMP_CLAUSE_REDUCTION_CODE (clause) != ERROR_MARK)
342 pp_string (buffer,
343 op_symbol_code (OMP_CLAUSE_REDUCTION_CODE (clause)));
344 pp_colon (buffer);
346 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
347 spc, flags, false);
348 pp_right_paren (buffer);
349 break;
351 case OMP_CLAUSE_IF:
352 pp_string (buffer, "if(");
353 dump_generic_node (buffer, OMP_CLAUSE_IF_EXPR (clause),
354 spc, flags, false);
355 pp_right_paren (buffer);
356 break;
358 case OMP_CLAUSE_NUM_THREADS:
359 pp_string (buffer, "num_threads(");
360 dump_generic_node (buffer, OMP_CLAUSE_NUM_THREADS_EXPR (clause),
361 spc, flags, false);
362 pp_right_paren (buffer);
363 break;
365 case OMP_CLAUSE_NOWAIT:
366 pp_string (buffer, "nowait");
367 break;
368 case OMP_CLAUSE_ORDERED:
369 pp_string (buffer, "ordered");
370 break;
372 case OMP_CLAUSE_DEFAULT:
373 pp_string (buffer, "default(");
374 switch (OMP_CLAUSE_DEFAULT_KIND (clause))
376 case OMP_CLAUSE_DEFAULT_UNSPECIFIED:
377 break;
378 case OMP_CLAUSE_DEFAULT_SHARED:
379 pp_string (buffer, "shared");
380 break;
381 case OMP_CLAUSE_DEFAULT_NONE:
382 pp_string (buffer, "none");
383 break;
384 case OMP_CLAUSE_DEFAULT_PRIVATE:
385 pp_string (buffer, "private");
386 break;
387 case OMP_CLAUSE_DEFAULT_FIRSTPRIVATE:
388 pp_string (buffer, "firstprivate");
389 break;
390 default:
391 gcc_unreachable ();
393 pp_right_paren (buffer);
394 break;
396 case OMP_CLAUSE_SCHEDULE:
397 pp_string (buffer, "schedule(");
398 switch (OMP_CLAUSE_SCHEDULE_KIND (clause))
400 case OMP_CLAUSE_SCHEDULE_STATIC:
401 pp_string (buffer, "static");
402 break;
403 case OMP_CLAUSE_SCHEDULE_DYNAMIC:
404 pp_string (buffer, "dynamic");
405 break;
406 case OMP_CLAUSE_SCHEDULE_GUIDED:
407 pp_string (buffer, "guided");
408 break;
409 case OMP_CLAUSE_SCHEDULE_RUNTIME:
410 pp_string (buffer, "runtime");
411 break;
412 case OMP_CLAUSE_SCHEDULE_AUTO:
413 pp_string (buffer, "auto");
414 break;
415 default:
416 gcc_unreachable ();
418 if (OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause))
420 pp_comma (buffer);
421 dump_generic_node (buffer, OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (clause),
422 spc, flags, false);
424 pp_right_paren (buffer);
425 break;
427 case OMP_CLAUSE_UNTIED:
428 pp_string (buffer, "untied");
429 break;
431 case OMP_CLAUSE_COLLAPSE:
432 pp_string (buffer, "collapse(");
433 dump_generic_node (buffer, OMP_CLAUSE_COLLAPSE_EXPR (clause),
434 spc, flags, false);
435 pp_right_paren (buffer);
436 break;
438 case OMP_CLAUSE_FINAL:
439 pp_string (buffer, "final(");
440 dump_generic_node (buffer, OMP_CLAUSE_FINAL_EXPR (clause),
441 spc, flags, false);
442 pp_right_paren (buffer);
443 break;
445 case OMP_CLAUSE_MERGEABLE:
446 pp_string (buffer, "mergeable");
447 break;
449 case OMP_CLAUSE_LINEAR:
450 pp_string (buffer, "linear(");
451 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
452 spc, flags, false);
453 pp_colon (buffer);
454 dump_generic_node (buffer, OMP_CLAUSE_LINEAR_STEP (clause),
455 spc, flags, false);
456 pp_right_paren (buffer);
457 break;
459 case OMP_CLAUSE_ALIGNED:
460 pp_string (buffer, "aligned(");
461 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
462 spc, flags, false);
463 if (OMP_CLAUSE_ALIGNED_ALIGNMENT (clause))
465 pp_colon (buffer);
466 dump_generic_node (buffer, OMP_CLAUSE_ALIGNED_ALIGNMENT (clause),
467 spc, flags, false);
469 pp_right_paren (buffer);
470 break;
472 case OMP_CLAUSE_DEPEND:
473 pp_string (buffer, "depend(");
474 switch (OMP_CLAUSE_DEPEND_KIND (clause))
476 case OMP_CLAUSE_DEPEND_IN:
477 pp_string (buffer, "in");
478 break;
479 case OMP_CLAUSE_DEPEND_OUT:
480 pp_string (buffer, "out");
481 break;
482 case OMP_CLAUSE_DEPEND_INOUT:
483 pp_string (buffer, "inout");
484 break;
485 default:
486 gcc_unreachable ();
488 pp_colon (buffer);
489 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
490 spc, flags, false);
491 pp_right_paren (buffer);
492 break;
494 case OMP_CLAUSE_MAP:
495 pp_string (buffer, "map(");
496 switch (OMP_CLAUSE_MAP_KIND (clause))
498 case OMP_CLAUSE_MAP_ALLOC:
499 case OMP_CLAUSE_MAP_POINTER:
500 pp_string (buffer, "alloc");
501 break;
502 case OMP_CLAUSE_MAP_TO:
503 pp_string (buffer, "to");
504 break;
505 case OMP_CLAUSE_MAP_FROM:
506 pp_string (buffer, "from");
507 break;
508 case OMP_CLAUSE_MAP_TOFROM:
509 pp_string (buffer, "tofrom");
510 break;
511 default:
512 gcc_unreachable ();
514 pp_colon (buffer);
515 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
516 spc, flags, false);
517 print_clause_size:
518 if (OMP_CLAUSE_SIZE (clause))
520 if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP
521 && OMP_CLAUSE_MAP_KIND (clause) == OMP_CLAUSE_MAP_POINTER)
522 pp_string (buffer, " [pointer assign, bias: ");
523 else
524 pp_string (buffer, " [len: ");
525 dump_generic_node (buffer, OMP_CLAUSE_SIZE (clause),
526 spc, flags, false);
527 pp_right_bracket (buffer);
529 pp_right_paren (buffer);
530 break;
532 case OMP_CLAUSE_FROM:
533 pp_string (buffer, "from(");
534 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
535 spc, flags, false);
536 goto print_clause_size;
538 case OMP_CLAUSE_TO:
539 pp_string (buffer, "to(");
540 dump_generic_node (buffer, OMP_CLAUSE_DECL (clause),
541 spc, flags, false);
542 goto print_clause_size;
544 case OMP_CLAUSE_NUM_TEAMS:
545 pp_string (buffer, "num_teams(");
546 dump_generic_node (buffer, OMP_CLAUSE_NUM_TEAMS_EXPR (clause),
547 spc, flags, false);
548 pp_right_paren (buffer);
549 break;
551 case OMP_CLAUSE_THREAD_LIMIT:
552 pp_string (buffer, "thread_limit(");
553 dump_generic_node (buffer, OMP_CLAUSE_THREAD_LIMIT_EXPR (clause),
554 spc, flags, false);
555 pp_right_paren (buffer);
556 break;
558 case OMP_CLAUSE_DEVICE:
559 pp_string (buffer, "device(");
560 dump_generic_node (buffer, OMP_CLAUSE_DEVICE_ID (clause),
561 spc, flags, false);
562 pp_right_paren (buffer);
563 break;
565 case OMP_CLAUSE_DIST_SCHEDULE:
566 pp_string (buffer, "dist_schedule(static");
567 if (OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause))
569 pp_comma (buffer);
570 dump_generic_node (buffer,
571 OMP_CLAUSE_DIST_SCHEDULE_CHUNK_EXPR (clause),
572 spc, flags, false);
574 pp_right_paren (buffer);
575 break;
577 case OMP_CLAUSE_PROC_BIND:
578 pp_string (buffer, "proc_bind(");
579 switch (OMP_CLAUSE_PROC_BIND_KIND (clause))
581 case OMP_CLAUSE_PROC_BIND_MASTER:
582 pp_string (buffer, "master");
583 break;
584 case OMP_CLAUSE_PROC_BIND_CLOSE:
585 pp_string (buffer, "close");
586 break;
587 case OMP_CLAUSE_PROC_BIND_SPREAD:
588 pp_string (buffer, "spread");
589 break;
590 default:
591 gcc_unreachable ();
593 pp_right_paren (buffer);
594 break;
596 case OMP_CLAUSE_SAFELEN:
597 pp_string (buffer, "safelen(");
598 dump_generic_node (buffer, OMP_CLAUSE_SAFELEN_EXPR (clause),
599 spc, flags, false);
600 pp_right_paren (buffer);
601 break;
603 case OMP_CLAUSE_SIMDLEN:
604 pp_string (buffer, "simdlen(");
605 dump_generic_node (buffer, OMP_CLAUSE_SIMDLEN_EXPR (clause),
606 spc, flags, false);
607 pp_right_paren (buffer);
608 break;
610 case OMP_CLAUSE__SIMDUID_:
611 pp_string (buffer, "_simduid_(");
612 dump_generic_node (buffer, OMP_CLAUSE__SIMDUID__DECL (clause),
613 spc, flags, false);
614 pp_right_paren (buffer);
615 break;
617 case OMP_CLAUSE_INBRANCH:
618 pp_string (buffer, "inbranch");
619 break;
620 case OMP_CLAUSE_NOTINBRANCH:
621 pp_string (buffer, "notinbranch");
622 break;
623 case OMP_CLAUSE_FOR:
624 pp_string (buffer, "for");
625 break;
626 case OMP_CLAUSE_PARALLEL:
627 pp_string (buffer, "parallel");
628 break;
629 case OMP_CLAUSE_SECTIONS:
630 pp_string (buffer, "sections");
631 break;
632 case OMP_CLAUSE_TASKGROUP:
633 pp_string (buffer, "taskgroup");
634 break;
636 default:
637 /* Should never happen. */
638 dump_generic_node (buffer, clause, spc, flags, false);
639 break;
644 /* Dump the list of OpenMP clauses. BUFFER, SPC and FLAGS are as in
645 dump_generic_node. */
647 void
648 dump_omp_clauses (pretty_printer *buffer, tree clause, int spc, int flags)
650 if (clause == NULL)
651 return;
653 pp_space (buffer);
654 while (1)
656 dump_omp_clause (buffer, clause, spc, flags);
657 clause = OMP_CLAUSE_CHAIN (clause);
658 if (clause == NULL)
659 return;
660 pp_space (buffer);
665 /* Dump location LOC to BUFFER. */
667 static void
668 dump_location (pretty_printer *buffer, location_t loc)
670 expanded_location xloc = expand_location (loc);
672 pp_left_bracket (buffer);
673 if (xloc.file)
675 pp_string (buffer, xloc.file);
676 pp_string (buffer, " : ");
678 pp_decimal_int (buffer, xloc.line);
679 pp_string (buffer, "] ");
683 /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in
684 dump_generic_node. */
686 static void
687 dump_block_node (pretty_printer *buffer, tree block, int spc, int flags)
689 tree t;
691 pp_printf (buffer, "BLOCK #%d ", BLOCK_NUMBER (block));
693 if (flags & TDF_ADDRESS)
694 pp_printf (buffer, "[%p] ", (void *) block);
696 if (BLOCK_ABSTRACT (block))
697 pp_string (buffer, "[abstract] ");
699 if (TREE_ASM_WRITTEN (block))
700 pp_string (buffer, "[written] ");
702 if (flags & TDF_SLIM)
703 return;
705 if (BLOCK_SOURCE_LOCATION (block))
706 dump_location (buffer, BLOCK_SOURCE_LOCATION (block));
708 newline_and_indent (buffer, spc + 2);
710 if (BLOCK_SUPERCONTEXT (block))
712 pp_string (buffer, "SUPERCONTEXT: ");
713 dump_generic_node (buffer, BLOCK_SUPERCONTEXT (block), 0,
714 flags | TDF_SLIM, false);
715 newline_and_indent (buffer, spc + 2);
718 if (BLOCK_SUBBLOCKS (block))
720 pp_string (buffer, "SUBBLOCKS: ");
721 for (t = BLOCK_SUBBLOCKS (block); t; t = BLOCK_CHAIN (t))
723 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
724 pp_space (buffer);
726 newline_and_indent (buffer, spc + 2);
729 if (BLOCK_CHAIN (block))
731 pp_string (buffer, "SIBLINGS: ");
732 for (t = BLOCK_CHAIN (block); t; t = BLOCK_CHAIN (t))
734 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
735 pp_space (buffer);
737 newline_and_indent (buffer, spc + 2);
740 if (BLOCK_VARS (block))
742 pp_string (buffer, "VARS: ");
743 for (t = BLOCK_VARS (block); t; t = TREE_CHAIN (t))
745 dump_generic_node (buffer, t, 0, flags, false);
746 pp_space (buffer);
748 newline_and_indent (buffer, spc + 2);
751 if (vec_safe_length (BLOCK_NONLOCALIZED_VARS (block)) > 0)
753 unsigned i;
754 vec<tree, va_gc> *nlv = BLOCK_NONLOCALIZED_VARS (block);
756 pp_string (buffer, "NONLOCALIZED_VARS: ");
757 FOR_EACH_VEC_ELT (*nlv, i, t)
759 dump_generic_node (buffer, t, 0, flags, false);
760 pp_space (buffer);
762 newline_and_indent (buffer, spc + 2);
765 if (BLOCK_ABSTRACT_ORIGIN (block))
767 pp_string (buffer, "ABSTRACT_ORIGIN: ");
768 dump_generic_node (buffer, BLOCK_ABSTRACT_ORIGIN (block), 0,
769 flags | TDF_SLIM, false);
770 newline_and_indent (buffer, spc + 2);
773 if (BLOCK_FRAGMENT_ORIGIN (block))
775 pp_string (buffer, "FRAGMENT_ORIGIN: ");
776 dump_generic_node (buffer, BLOCK_FRAGMENT_ORIGIN (block), 0,
777 flags | TDF_SLIM, false);
778 newline_and_indent (buffer, spc + 2);
781 if (BLOCK_FRAGMENT_CHAIN (block))
783 pp_string (buffer, "FRAGMENT_CHAIN: ");
784 for (t = BLOCK_FRAGMENT_CHAIN (block); t; t = BLOCK_FRAGMENT_CHAIN (t))
786 dump_generic_node (buffer, t, 0, flags | TDF_SLIM, false);
787 pp_space (buffer);
789 newline_and_indent (buffer, spc + 2);
794 /* Dump the node NODE on the pretty_printer BUFFER, SPC spaces of
795 indent. FLAGS specifies details to show in the dump (see TDF_* in
796 dumpfile.h). If IS_STMT is true, the object printed is considered
797 to be a statement and it is terminated by ';' if appropriate. */
800 dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
801 bool is_stmt)
803 tree type;
804 tree op0, op1;
805 const char *str;
806 bool is_expr;
807 enum tree_code code;
809 if (node == NULL_TREE)
810 return spc;
812 is_expr = EXPR_P (node);
814 if (is_stmt && (flags & TDF_STMTADDR))
815 pp_printf (buffer, "<&%p> ", (void *)node);
817 if ((flags & TDF_LINENO) && EXPR_HAS_LOCATION (node))
818 dump_location (buffer, EXPR_LOCATION (node));
820 code = TREE_CODE (node);
821 switch (code)
823 case ERROR_MARK:
824 pp_string (buffer, "<<< error >>>");
825 break;
827 case IDENTIFIER_NODE:
828 pp_tree_identifier (buffer, node);
829 break;
831 case TREE_LIST:
832 while (node && node != error_mark_node)
834 if (TREE_PURPOSE (node))
836 dump_generic_node (buffer, TREE_PURPOSE (node), spc, flags, false);
837 pp_space (buffer);
839 dump_generic_node (buffer, TREE_VALUE (node), spc, flags, false);
840 node = TREE_CHAIN (node);
841 if (node && TREE_CODE (node) == TREE_LIST)
843 pp_comma (buffer);
844 pp_space (buffer);
847 break;
849 case TREE_BINFO:
850 dump_generic_node (buffer, BINFO_TYPE (node), spc, flags, false);
851 break;
853 case TREE_VEC:
855 size_t i;
856 if (TREE_VEC_LENGTH (node) > 0)
858 size_t len = TREE_VEC_LENGTH (node);
859 for (i = 0; i < len - 1; i++)
861 dump_generic_node (buffer, TREE_VEC_ELT (node, i), spc, flags,
862 false);
863 pp_comma (buffer);
864 pp_space (buffer);
866 dump_generic_node (buffer, TREE_VEC_ELT (node, len - 1), spc,
867 flags, false);
870 break;
872 case VOID_TYPE:
873 case INTEGER_TYPE:
874 case REAL_TYPE:
875 case FIXED_POINT_TYPE:
876 case COMPLEX_TYPE:
877 case VECTOR_TYPE:
878 case ENUMERAL_TYPE:
879 case BOOLEAN_TYPE:
881 unsigned int quals = TYPE_QUALS (node);
882 enum tree_code_class tclass;
884 if (quals & TYPE_QUAL_ATOMIC)
885 pp_string (buffer, "atomic ");
886 if (quals & TYPE_QUAL_CONST)
887 pp_string (buffer, "const ");
888 else if (quals & TYPE_QUAL_VOLATILE)
889 pp_string (buffer, "volatile ");
890 else if (quals & TYPE_QUAL_RESTRICT)
891 pp_string (buffer, "restrict ");
893 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
895 pp_string (buffer, "<address-space-");
896 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
897 pp_string (buffer, "> ");
900 tclass = TREE_CODE_CLASS (TREE_CODE (node));
902 if (tclass == tcc_declaration)
904 if (DECL_NAME (node))
905 dump_decl_name (buffer, node, flags);
906 else
907 pp_string (buffer, "<unnamed type decl>");
909 else if (tclass == tcc_type)
911 if (TYPE_NAME (node))
913 if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
914 pp_tree_identifier (buffer, TYPE_NAME (node));
915 else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
916 && DECL_NAME (TYPE_NAME (node)))
917 dump_decl_name (buffer, TYPE_NAME (node), flags);
918 else
919 pp_string (buffer, "<unnamed type>");
921 else if (TREE_CODE (node) == VECTOR_TYPE)
923 pp_string (buffer, "vector");
924 pp_left_paren (buffer);
925 pp_wide_integer (buffer, TYPE_VECTOR_SUBPARTS (node));
926 pp_string (buffer, ") ");
927 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
929 else if (TREE_CODE (node) == INTEGER_TYPE)
931 if (TYPE_PRECISION (node) == CHAR_TYPE_SIZE)
932 pp_string (buffer, (TYPE_UNSIGNED (node)
933 ? "unsigned char"
934 : "signed char"));
935 else if (TYPE_PRECISION (node) == SHORT_TYPE_SIZE)
936 pp_string (buffer, (TYPE_UNSIGNED (node)
937 ? "unsigned short"
938 : "signed short"));
939 else if (TYPE_PRECISION (node) == INT_TYPE_SIZE)
940 pp_string (buffer, (TYPE_UNSIGNED (node)
941 ? "unsigned int"
942 : "signed int"));
943 else if (TYPE_PRECISION (node) == LONG_TYPE_SIZE)
944 pp_string (buffer, (TYPE_UNSIGNED (node)
945 ? "unsigned long"
946 : "signed long"));
947 else if (TYPE_PRECISION (node) == LONG_LONG_TYPE_SIZE)
948 pp_string (buffer, (TYPE_UNSIGNED (node)
949 ? "unsigned long long"
950 : "signed long long"));
951 else if (TYPE_PRECISION (node) >= CHAR_TYPE_SIZE
952 && exact_log2 (TYPE_PRECISION (node)) != -1)
954 pp_string (buffer, (TYPE_UNSIGNED (node) ? "uint" : "int"));
955 pp_decimal_int (buffer, TYPE_PRECISION (node));
956 pp_string (buffer, "_t");
958 else
960 pp_string (buffer, (TYPE_UNSIGNED (node)
961 ? "<unnamed-unsigned:"
962 : "<unnamed-signed:"));
963 pp_decimal_int (buffer, TYPE_PRECISION (node));
964 pp_greater (buffer);
967 else if (TREE_CODE (node) == COMPLEX_TYPE)
969 pp_string (buffer, "__complex__ ");
970 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
972 else if (TREE_CODE (node) == REAL_TYPE)
974 pp_string (buffer, "<float:");
975 pp_decimal_int (buffer, TYPE_PRECISION (node));
976 pp_greater (buffer);
978 else if (TREE_CODE (node) == FIXED_POINT_TYPE)
980 pp_string (buffer, "<fixed-point-");
981 pp_string (buffer, TYPE_SATURATING (node) ? "sat:" : "nonsat:");
982 pp_decimal_int (buffer, TYPE_PRECISION (node));
983 pp_greater (buffer);
985 else if (TREE_CODE (node) == VOID_TYPE)
986 pp_string (buffer, "void");
987 else
988 pp_string (buffer, "<unnamed type>");
990 break;
993 case POINTER_TYPE:
994 case REFERENCE_TYPE:
995 str = (TREE_CODE (node) == POINTER_TYPE ? "*" : "&");
997 if (TREE_TYPE (node) == NULL)
999 pp_string (buffer, str);
1000 pp_string (buffer, "<null type>");
1002 else if (TREE_CODE (TREE_TYPE (node)) == FUNCTION_TYPE)
1004 tree fnode = TREE_TYPE (node);
1006 dump_generic_node (buffer, TREE_TYPE (fnode), spc, flags, false);
1007 pp_space (buffer);
1008 pp_left_paren (buffer);
1009 pp_string (buffer, str);
1010 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1011 dump_decl_name (buffer, TYPE_NAME (node), flags);
1012 else if (flags & TDF_NOUID)
1013 pp_printf (buffer, "<Txxxx>");
1014 else
1015 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1017 pp_right_paren (buffer);
1018 dump_function_declaration (buffer, fnode, spc, flags);
1020 else
1022 unsigned int quals = TYPE_QUALS (node);
1024 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1025 pp_space (buffer);
1026 pp_string (buffer, str);
1028 if (quals & TYPE_QUAL_CONST)
1029 pp_string (buffer, " const");
1030 if (quals & TYPE_QUAL_VOLATILE)
1031 pp_string (buffer, " volatile");
1032 if (quals & TYPE_QUAL_RESTRICT)
1033 pp_string (buffer, " restrict");
1035 if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (node)))
1037 pp_string (buffer, " <address-space-");
1038 pp_decimal_int (buffer, TYPE_ADDR_SPACE (node));
1039 pp_greater (buffer);
1042 if (TYPE_REF_CAN_ALIAS_ALL (node))
1043 pp_string (buffer, " {ref-all}");
1045 break;
1047 case OFFSET_TYPE:
1048 NIY;
1049 break;
1051 case MEM_REF:
1053 if (integer_zerop (TREE_OPERAND (node, 1))
1054 /* Dump the types of INTEGER_CSTs explicitly, for we can't
1055 infer them and MEM_ATTR caching will share MEM_REFs
1056 with differently-typed op0s. */
1057 && TREE_CODE (TREE_OPERAND (node, 0)) != INTEGER_CST
1058 /* Released SSA_NAMES have no TREE_TYPE. */
1059 && TREE_TYPE (TREE_OPERAND (node, 0)) != NULL_TREE
1060 /* Same pointer types, but ignoring POINTER_TYPE vs.
1061 REFERENCE_TYPE. */
1062 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 0)))
1063 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))
1064 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 0)))
1065 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (node, 1))))
1066 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 0)))
1067 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (node, 1))))
1068 /* Same value types ignoring qualifiers. */
1069 && (TYPE_MAIN_VARIANT (TREE_TYPE (node))
1070 == TYPE_MAIN_VARIANT
1071 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (node, 1))))))
1073 if (TREE_CODE (TREE_OPERAND (node, 0)) != ADDR_EXPR)
1075 pp_star (buffer);
1076 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1077 spc, flags, false);
1079 else
1080 dump_generic_node (buffer,
1081 TREE_OPERAND (TREE_OPERAND (node, 0), 0),
1082 spc, flags, false);
1084 else
1086 tree ptype;
1088 pp_string (buffer, "MEM[");
1089 pp_left_paren (buffer);
1090 ptype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (node, 1)));
1091 dump_generic_node (buffer, ptype,
1092 spc, flags | TDF_SLIM, false);
1093 pp_right_paren (buffer);
1094 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1095 spc, flags, false);
1096 if (!integer_zerop (TREE_OPERAND (node, 1)))
1098 pp_string (buffer, " + ");
1099 dump_generic_node (buffer, TREE_OPERAND (node, 1),
1100 spc, flags, false);
1102 pp_right_bracket (buffer);
1104 break;
1107 case TARGET_MEM_REF:
1109 const char *sep = "";
1110 tree tmp;
1112 pp_string (buffer, "MEM[");
1114 if (TREE_CODE (TMR_BASE (node)) == ADDR_EXPR)
1116 pp_string (buffer, sep);
1117 sep = ", ";
1118 pp_string (buffer, "symbol: ");
1119 dump_generic_node (buffer, TREE_OPERAND (TMR_BASE (node), 0),
1120 spc, flags, false);
1122 else
1124 pp_string (buffer, sep);
1125 sep = ", ";
1126 pp_string (buffer, "base: ");
1127 dump_generic_node (buffer, TMR_BASE (node), spc, flags, false);
1129 tmp = TMR_INDEX2 (node);
1130 if (tmp)
1132 pp_string (buffer, sep);
1133 sep = ", ";
1134 pp_string (buffer, "base: ");
1135 dump_generic_node (buffer, tmp, spc, flags, false);
1137 tmp = TMR_INDEX (node);
1138 if (tmp)
1140 pp_string (buffer, sep);
1141 sep = ", ";
1142 pp_string (buffer, "index: ");
1143 dump_generic_node (buffer, tmp, spc, flags, false);
1145 tmp = TMR_STEP (node);
1146 if (tmp)
1148 pp_string (buffer, sep);
1149 sep = ", ";
1150 pp_string (buffer, "step: ");
1151 dump_generic_node (buffer, tmp, spc, flags, false);
1153 tmp = TMR_OFFSET (node);
1154 if (tmp)
1156 pp_string (buffer, sep);
1157 sep = ", ";
1158 pp_string (buffer, "offset: ");
1159 dump_generic_node (buffer, tmp, spc, flags, false);
1161 pp_right_bracket (buffer);
1163 break;
1165 case ARRAY_TYPE:
1167 tree tmp;
1169 /* Print the innermost component type. */
1170 for (tmp = TREE_TYPE (node); TREE_CODE (tmp) == ARRAY_TYPE;
1171 tmp = TREE_TYPE (tmp))
1173 dump_generic_node (buffer, tmp, spc, flags, false);
1175 /* Print the dimensions. */
1176 for (tmp = node; TREE_CODE (tmp) == ARRAY_TYPE; tmp = TREE_TYPE (tmp))
1177 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
1178 break;
1181 case RECORD_TYPE:
1182 case UNION_TYPE:
1183 case QUAL_UNION_TYPE:
1185 unsigned int quals = TYPE_QUALS (node);
1187 if (quals & TYPE_QUAL_ATOMIC)
1188 pp_string (buffer, "atomic ");
1189 if (quals & TYPE_QUAL_CONST)
1190 pp_string (buffer, "const ");
1191 if (quals & TYPE_QUAL_VOLATILE)
1192 pp_string (buffer, "volatile ");
1194 /* Print the name of the structure. */
1195 if (TREE_CODE (node) == RECORD_TYPE)
1196 pp_string (buffer, "struct ");
1197 else if (TREE_CODE (node) == UNION_TYPE)
1198 pp_string (buffer, "union ");
1200 if (TYPE_NAME (node))
1201 dump_generic_node (buffer, TYPE_NAME (node), spc, flags, false);
1202 else if (!(flags & TDF_SLIM))
1203 /* FIXME: If we eliminate the 'else' above and attempt
1204 to show the fields for named types, we may get stuck
1205 following a cycle of pointers to structs. The alleged
1206 self-reference check in print_struct_decl will not detect
1207 cycles involving more than one pointer or struct type. */
1208 print_struct_decl (buffer, node, spc, flags);
1209 break;
1212 case LANG_TYPE:
1213 NIY;
1214 break;
1216 case INTEGER_CST:
1217 if (TREE_CODE (TREE_TYPE (node)) == POINTER_TYPE)
1219 /* In the case of a pointer, one may want to divide by the
1220 size of the pointed-to type. Unfortunately, this not
1221 straightforward. The C front-end maps expressions
1223 (int *) 5
1224 int *p; (p + 5)
1226 in such a way that the two INTEGER_CST nodes for "5" have
1227 different values but identical types. In the latter
1228 case, the 5 is multiplied by sizeof (int) in c-common.c
1229 (pointer_int_sum) to convert it to a byte address, and
1230 yet the type of the node is left unchanged. Argh. What
1231 is consistent though is that the number value corresponds
1232 to bytes (UNITS) offset.
1234 NB: Neither of the following divisors can be trivially
1235 used to recover the original literal:
1237 TREE_INT_CST_LOW (TYPE_SIZE_UNIT (TREE_TYPE (node)))
1238 TYPE_PRECISION (TREE_TYPE (TREE_TYPE (node))) */
1239 pp_wide_integer (buffer, TREE_INT_CST_LOW (node));
1240 pp_string (buffer, "B"); /* pseudo-unit */
1242 else if (tree_fits_shwi_p (node))
1243 pp_wide_integer (buffer, tree_to_shwi (node));
1244 else if (tree_fits_uhwi_p (node))
1245 pp_unsigned_wide_integer (buffer, tree_to_uhwi (node));
1246 else
1248 wide_int val = node;
1250 if (wi::neg_p (val, TYPE_SIGN (TREE_TYPE (node))))
1252 pp_minus (buffer);
1253 val = -val;
1255 print_hex (val, pp_buffer (buffer)->digit_buffer);
1256 pp_string (buffer, pp_buffer (buffer)->digit_buffer);
1258 if (TREE_OVERFLOW (node))
1259 pp_string (buffer, "(OVF)");
1260 break;
1262 case REAL_CST:
1263 /* Code copied from print_node. */
1265 REAL_VALUE_TYPE d;
1266 if (TREE_OVERFLOW (node))
1267 pp_string (buffer, " overflow");
1269 #if !defined(REAL_IS_NOT_DOUBLE) || defined(REAL_ARITHMETIC)
1270 d = TREE_REAL_CST (node);
1271 if (REAL_VALUE_ISINF (d))
1272 pp_string (buffer, REAL_VALUE_NEGATIVE (d) ? " -Inf" : " Inf");
1273 else if (REAL_VALUE_ISNAN (d))
1274 pp_string (buffer, " Nan");
1275 else
1277 char string[100];
1278 real_to_decimal (string, &d, sizeof (string), 0, 1);
1279 pp_string (buffer, string);
1281 #else
1283 HOST_WIDE_INT i;
1284 unsigned char *p = (unsigned char *) &TREE_REAL_CST (node);
1285 pp_string (buffer, "0x");
1286 for (i = 0; i < sizeof TREE_REAL_CST (node); i++)
1287 output_formatted_integer (buffer, "%02x", *p++);
1289 #endif
1290 break;
1293 case FIXED_CST:
1295 char string[100];
1296 fixed_to_decimal (string, TREE_FIXED_CST_PTR (node), sizeof (string));
1297 pp_string (buffer, string);
1298 break;
1301 case COMPLEX_CST:
1302 pp_string (buffer, "__complex__ (");
1303 dump_generic_node (buffer, TREE_REALPART (node), spc, flags, false);
1304 pp_string (buffer, ", ");
1305 dump_generic_node (buffer, TREE_IMAGPART (node), spc, flags, false);
1306 pp_right_paren (buffer);
1307 break;
1309 case STRING_CST:
1310 pp_string (buffer, "\"");
1311 pretty_print_string (buffer, TREE_STRING_POINTER (node));
1312 pp_string (buffer, "\"");
1313 break;
1315 case VECTOR_CST:
1317 unsigned i;
1318 pp_string (buffer, "{ ");
1319 for (i = 0; i < VECTOR_CST_NELTS (node); ++i)
1321 if (i != 0)
1322 pp_string (buffer, ", ");
1323 dump_generic_node (buffer, VECTOR_CST_ELT (node, i),
1324 spc, flags, false);
1326 pp_string (buffer, " }");
1328 break;
1330 case FUNCTION_TYPE:
1331 case METHOD_TYPE:
1332 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1333 pp_space (buffer);
1334 if (TREE_CODE (node) == METHOD_TYPE)
1336 if (TYPE_METHOD_BASETYPE (node))
1337 dump_decl_name (buffer, TYPE_NAME (TYPE_METHOD_BASETYPE (node)),
1338 flags);
1339 else
1340 pp_string (buffer, "<null method basetype>");
1341 pp_colon_colon (buffer);
1343 if (TYPE_NAME (node) && DECL_NAME (TYPE_NAME (node)))
1344 dump_decl_name (buffer, TYPE_NAME (node), flags);
1345 else if (flags & TDF_NOUID)
1346 pp_printf (buffer, "<Txxxx>");
1347 else
1348 pp_printf (buffer, "<T%x>", TYPE_UID (node));
1349 dump_function_declaration (buffer, node, spc, flags);
1350 break;
1352 case FUNCTION_DECL:
1353 case CONST_DECL:
1354 dump_decl_name (buffer, node, flags);
1355 break;
1357 case LABEL_DECL:
1358 if (DECL_NAME (node))
1359 dump_decl_name (buffer, node, flags);
1360 else if (LABEL_DECL_UID (node) != -1)
1361 pp_printf (buffer, "<L%d>", (int) LABEL_DECL_UID (node));
1362 else
1364 if (flags & TDF_NOUID)
1365 pp_string (buffer, "<D.xxxx>");
1366 else
1367 pp_printf (buffer, "<D.%u>", DECL_UID (node));
1369 break;
1371 case TYPE_DECL:
1372 if (DECL_IS_BUILTIN (node))
1374 /* Don't print the declaration of built-in types. */
1375 break;
1377 if (DECL_NAME (node))
1378 dump_decl_name (buffer, node, flags);
1379 else if (TYPE_NAME (TREE_TYPE (node)) != node)
1381 if ((TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1382 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1383 && TYPE_METHODS (TREE_TYPE (node)))
1385 /* The type is a c++ class: all structures have at least
1386 4 methods. */
1387 pp_string (buffer, "class ");
1388 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1390 else
1392 pp_string (buffer,
1393 (TREE_CODE (TREE_TYPE (node)) == UNION_TYPE
1394 ? "union" : "struct "));
1395 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1398 else
1399 pp_string (buffer, "<anon>");
1400 break;
1402 case VAR_DECL:
1403 case PARM_DECL:
1404 case FIELD_DECL:
1405 case DEBUG_EXPR_DECL:
1406 case NAMESPACE_DECL:
1407 case NAMELIST_DECL:
1408 dump_decl_name (buffer, node, flags);
1409 break;
1411 case RESULT_DECL:
1412 pp_string (buffer, "<retval>");
1413 break;
1415 case COMPONENT_REF:
1416 op0 = TREE_OPERAND (node, 0);
1417 str = ".";
1418 if (op0
1419 && (TREE_CODE (op0) == INDIRECT_REF
1420 || (TREE_CODE (op0) == MEM_REF
1421 && TREE_CODE (TREE_OPERAND (op0, 0)) != ADDR_EXPR
1422 && integer_zerop (TREE_OPERAND (op0, 1))
1423 /* Dump the types of INTEGER_CSTs explicitly, for we
1424 can't infer them and MEM_ATTR caching will share
1425 MEM_REFs with differently-typed op0s. */
1426 && TREE_CODE (TREE_OPERAND (op0, 0)) != INTEGER_CST
1427 /* Released SSA_NAMES have no TREE_TYPE. */
1428 && TREE_TYPE (TREE_OPERAND (op0, 0)) != NULL_TREE
1429 /* Same pointer types, but ignoring POINTER_TYPE vs.
1430 REFERENCE_TYPE. */
1431 && (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1432 == TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1433 && (TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 0)))
1434 == TYPE_MODE (TREE_TYPE (TREE_OPERAND (op0, 1))))
1435 && (TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 0)))
1436 == TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (TREE_OPERAND (op0, 1))))
1437 /* Same value types ignoring qualifiers. */
1438 && (TYPE_MAIN_VARIANT (TREE_TYPE (op0))
1439 == TYPE_MAIN_VARIANT
1440 (TREE_TYPE (TREE_TYPE (TREE_OPERAND (op0, 1))))))))
1442 op0 = TREE_OPERAND (op0, 0);
1443 str = "->";
1445 if (op_prio (op0) < op_prio (node))
1446 pp_left_paren (buffer);
1447 dump_generic_node (buffer, op0, spc, flags, false);
1448 if (op_prio (op0) < op_prio (node))
1449 pp_right_paren (buffer);
1450 pp_string (buffer, str);
1451 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1452 op0 = component_ref_field_offset (node);
1453 if (op0 && TREE_CODE (op0) != INTEGER_CST)
1455 pp_string (buffer, "{off: ");
1456 dump_generic_node (buffer, op0, spc, flags, false);
1457 pp_right_brace (buffer);
1459 break;
1461 case BIT_FIELD_REF:
1462 pp_string (buffer, "BIT_FIELD_REF <");
1463 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1464 pp_string (buffer, ", ");
1465 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1466 pp_string (buffer, ", ");
1467 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1468 pp_greater (buffer);
1469 break;
1471 case ARRAY_REF:
1472 case ARRAY_RANGE_REF:
1473 op0 = TREE_OPERAND (node, 0);
1474 if (op_prio (op0) < op_prio (node))
1475 pp_left_paren (buffer);
1476 dump_generic_node (buffer, op0, spc, flags, false);
1477 if (op_prio (op0) < op_prio (node))
1478 pp_right_paren (buffer);
1479 pp_left_bracket (buffer);
1480 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1481 if (TREE_CODE (node) == ARRAY_RANGE_REF)
1482 pp_string (buffer, " ...");
1483 pp_right_bracket (buffer);
1485 op0 = array_ref_low_bound (node);
1486 op1 = array_ref_element_size (node);
1488 if (!integer_zerop (op0)
1489 || TREE_OPERAND (node, 2)
1490 || TREE_OPERAND (node, 3))
1492 pp_string (buffer, "{lb: ");
1493 dump_generic_node (buffer, op0, spc, flags, false);
1494 pp_string (buffer, " sz: ");
1495 dump_generic_node (buffer, op1, spc, flags, false);
1496 pp_right_brace (buffer);
1498 break;
1500 case CONSTRUCTOR:
1502 unsigned HOST_WIDE_INT ix;
1503 tree field, val;
1504 bool is_struct_init = false;
1505 bool is_array_init = false;
1506 widest_int curidx;
1507 pp_left_brace (buffer);
1508 if (TREE_CLOBBER_P (node))
1509 pp_string (buffer, "CLOBBER");
1510 else if (TREE_CODE (TREE_TYPE (node)) == RECORD_TYPE
1511 || TREE_CODE (TREE_TYPE (node)) == UNION_TYPE)
1512 is_struct_init = true;
1513 else if (TREE_CODE (TREE_TYPE (node)) == ARRAY_TYPE
1514 && TYPE_DOMAIN (TREE_TYPE (node))
1515 && TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)))
1516 && TREE_CODE (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node))))
1517 == INTEGER_CST)
1519 tree minv = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (node)));
1520 is_array_init = true;
1521 curidx = wi::to_widest (minv);
1523 FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node), ix, field, val)
1525 if (field)
1527 if (is_struct_init)
1529 pp_dot (buffer);
1530 dump_generic_node (buffer, field, spc, flags, false);
1531 pp_equal (buffer);
1533 else if (is_array_init
1534 && (TREE_CODE (field) != INTEGER_CST
1535 || curidx != wi::to_widest (field)))
1537 pp_left_bracket (buffer);
1538 if (TREE_CODE (field) == RANGE_EXPR)
1540 dump_generic_node (buffer, TREE_OPERAND (field, 0), spc,
1541 flags, false);
1542 pp_string (buffer, " ... ");
1543 dump_generic_node (buffer, TREE_OPERAND (field, 1), spc,
1544 flags, false);
1545 if (TREE_CODE (TREE_OPERAND (field, 1)) == INTEGER_CST)
1546 curidx = wi::to_widest (TREE_OPERAND (field, 1));
1548 else
1549 dump_generic_node (buffer, field, spc, flags, false);
1550 if (TREE_CODE (field) == INTEGER_CST)
1551 curidx = wi::to_widest (field);
1552 pp_string (buffer, "]=");
1555 if (is_array_init)
1556 curidx += 1;
1557 if (val && TREE_CODE (val) == ADDR_EXPR)
1558 if (TREE_CODE (TREE_OPERAND (val, 0)) == FUNCTION_DECL)
1559 val = TREE_OPERAND (val, 0);
1560 if (val && TREE_CODE (val) == FUNCTION_DECL)
1561 dump_decl_name (buffer, val, flags);
1562 else
1563 dump_generic_node (buffer, val, spc, flags, false);
1564 if (ix != vec_safe_length (CONSTRUCTOR_ELTS (node)) - 1)
1566 pp_comma (buffer);
1567 pp_space (buffer);
1570 pp_right_brace (buffer);
1572 break;
1574 case COMPOUND_EXPR:
1576 tree *tp;
1577 if (flags & TDF_SLIM)
1579 pp_string (buffer, "<COMPOUND_EXPR>");
1580 break;
1583 dump_generic_node (buffer, TREE_OPERAND (node, 0),
1584 spc, flags, !(flags & TDF_SLIM));
1585 if (flags & TDF_SLIM)
1586 newline_and_indent (buffer, spc);
1587 else
1589 pp_comma (buffer);
1590 pp_space (buffer);
1593 for (tp = &TREE_OPERAND (node, 1);
1594 TREE_CODE (*tp) == COMPOUND_EXPR;
1595 tp = &TREE_OPERAND (*tp, 1))
1597 dump_generic_node (buffer, TREE_OPERAND (*tp, 0),
1598 spc, flags, !(flags & TDF_SLIM));
1599 if (flags & TDF_SLIM)
1600 newline_and_indent (buffer, spc);
1601 else
1603 pp_comma (buffer);
1604 pp_space (buffer);
1608 dump_generic_node (buffer, *tp, spc, flags, !(flags & TDF_SLIM));
1610 break;
1612 case STATEMENT_LIST:
1614 tree_stmt_iterator si;
1615 bool first = true;
1617 if (flags & TDF_SLIM)
1619 pp_string (buffer, "<STATEMENT_LIST>");
1620 break;
1623 for (si = tsi_start (node); !tsi_end_p (si); tsi_next (&si))
1625 if (!first)
1626 newline_and_indent (buffer, spc);
1627 else
1628 first = false;
1629 dump_generic_node (buffer, tsi_stmt (si), spc, flags, true);
1632 break;
1634 case MODIFY_EXPR:
1635 case INIT_EXPR:
1636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags,
1637 false);
1638 pp_space (buffer);
1639 pp_equal (buffer);
1640 pp_space (buffer);
1641 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags,
1642 false);
1643 break;
1645 case TARGET_EXPR:
1646 pp_string (buffer, "TARGET_EXPR <");
1647 dump_generic_node (buffer, TARGET_EXPR_SLOT (node), spc, flags, false);
1648 pp_comma (buffer);
1649 pp_space (buffer);
1650 dump_generic_node (buffer, TARGET_EXPR_INITIAL (node), spc, flags, false);
1651 pp_greater (buffer);
1652 break;
1654 case DECL_EXPR:
1655 print_declaration (buffer, DECL_EXPR_DECL (node), spc, flags);
1656 is_stmt = false;
1657 break;
1659 case COND_EXPR:
1660 if (TREE_TYPE (node) == NULL || TREE_TYPE (node) == void_type_node)
1662 pp_string (buffer, "if (");
1663 dump_generic_node (buffer, COND_EXPR_COND (node), spc, flags, false);
1664 pp_right_paren (buffer);
1665 /* The lowered cond_exprs should always be printed in full. */
1666 if (COND_EXPR_THEN (node)
1667 && (IS_EMPTY_STMT (COND_EXPR_THEN (node))
1668 || TREE_CODE (COND_EXPR_THEN (node)) == GOTO_EXPR)
1669 && COND_EXPR_ELSE (node)
1670 && (IS_EMPTY_STMT (COND_EXPR_ELSE (node))
1671 || TREE_CODE (COND_EXPR_ELSE (node)) == GOTO_EXPR))
1673 pp_space (buffer);
1674 dump_generic_node (buffer, COND_EXPR_THEN (node),
1675 0, flags, true);
1676 if (!IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1678 pp_string (buffer, " else ");
1679 dump_generic_node (buffer, COND_EXPR_ELSE (node),
1680 0, flags, true);
1683 else if (!(flags & TDF_SLIM))
1685 /* Output COND_EXPR_THEN. */
1686 if (COND_EXPR_THEN (node))
1688 newline_and_indent (buffer, spc+2);
1689 pp_left_brace (buffer);
1690 newline_and_indent (buffer, spc+4);
1691 dump_generic_node (buffer, COND_EXPR_THEN (node), spc+4,
1692 flags, true);
1693 newline_and_indent (buffer, spc+2);
1694 pp_right_brace (buffer);
1697 /* Output COND_EXPR_ELSE. */
1698 if (COND_EXPR_ELSE (node)
1699 && !IS_EMPTY_STMT (COND_EXPR_ELSE (node)))
1701 newline_and_indent (buffer, spc);
1702 pp_string (buffer, "else");
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_ELSE (node), spc+4,
1707 flags, true);
1708 newline_and_indent (buffer, spc+2);
1709 pp_right_brace (buffer);
1712 is_expr = false;
1714 else
1716 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1717 pp_space (buffer);
1718 pp_question (buffer);
1719 pp_space (buffer);
1720 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1721 pp_space (buffer);
1722 pp_colon (buffer);
1723 pp_space (buffer);
1724 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
1726 break;
1728 case BIND_EXPR:
1729 pp_left_brace (buffer);
1730 if (!(flags & TDF_SLIM))
1732 if (BIND_EXPR_VARS (node))
1734 pp_newline (buffer);
1736 for (op0 = BIND_EXPR_VARS (node); op0; op0 = DECL_CHAIN (op0))
1738 print_declaration (buffer, op0, spc+2, flags);
1739 pp_newline (buffer);
1743 newline_and_indent (buffer, spc+2);
1744 dump_generic_node (buffer, BIND_EXPR_BODY (node), spc+2, flags, true);
1745 newline_and_indent (buffer, spc);
1746 pp_right_brace (buffer);
1748 is_expr = false;
1749 break;
1751 case CALL_EXPR:
1752 print_call_name (buffer, CALL_EXPR_FN (node), flags);
1754 /* Print parameters. */
1755 pp_space (buffer);
1756 pp_left_paren (buffer);
1758 tree arg;
1759 call_expr_arg_iterator iter;
1760 FOR_EACH_CALL_EXPR_ARG (arg, iter, node)
1762 dump_generic_node (buffer, arg, spc, flags, false);
1763 if (more_call_expr_args_p (&iter))
1765 pp_comma (buffer);
1766 pp_space (buffer);
1770 if (CALL_EXPR_VA_ARG_PACK (node))
1772 if (call_expr_nargs (node) > 0)
1774 pp_comma (buffer);
1775 pp_space (buffer);
1777 pp_string (buffer, "__builtin_va_arg_pack ()");
1779 pp_right_paren (buffer);
1781 op1 = CALL_EXPR_STATIC_CHAIN (node);
1782 if (op1)
1784 pp_string (buffer, " [static-chain: ");
1785 dump_generic_node (buffer, op1, spc, flags, false);
1786 pp_right_bracket (buffer);
1789 if (CALL_EXPR_RETURN_SLOT_OPT (node))
1790 pp_string (buffer, " [return slot optimization]");
1791 if (CALL_EXPR_TAILCALL (node))
1792 pp_string (buffer, " [tail call]");
1793 break;
1795 case WITH_CLEANUP_EXPR:
1796 NIY;
1797 break;
1799 case CLEANUP_POINT_EXPR:
1800 pp_string (buffer, "<<cleanup_point ");
1801 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1802 pp_string (buffer, ">>");
1803 break;
1805 case PLACEHOLDER_EXPR:
1806 pp_string (buffer, "<PLACEHOLDER_EXPR ");
1807 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1808 pp_greater (buffer);
1809 break;
1811 /* Binary arithmetic and logic expressions. */
1812 case WIDEN_SUM_EXPR:
1813 case WIDEN_MULT_EXPR:
1814 case MULT_EXPR:
1815 case MULT_HIGHPART_EXPR:
1816 case PLUS_EXPR:
1817 case POINTER_PLUS_EXPR:
1818 case MINUS_EXPR:
1819 case TRUNC_DIV_EXPR:
1820 case CEIL_DIV_EXPR:
1821 case FLOOR_DIV_EXPR:
1822 case ROUND_DIV_EXPR:
1823 case TRUNC_MOD_EXPR:
1824 case CEIL_MOD_EXPR:
1825 case FLOOR_MOD_EXPR:
1826 case ROUND_MOD_EXPR:
1827 case RDIV_EXPR:
1828 case EXACT_DIV_EXPR:
1829 case LSHIFT_EXPR:
1830 case RSHIFT_EXPR:
1831 case LROTATE_EXPR:
1832 case RROTATE_EXPR:
1833 case VEC_LSHIFT_EXPR:
1834 case VEC_RSHIFT_EXPR:
1835 case WIDEN_LSHIFT_EXPR:
1836 case BIT_IOR_EXPR:
1837 case BIT_XOR_EXPR:
1838 case BIT_AND_EXPR:
1839 case TRUTH_ANDIF_EXPR:
1840 case TRUTH_ORIF_EXPR:
1841 case TRUTH_AND_EXPR:
1842 case TRUTH_OR_EXPR:
1843 case TRUTH_XOR_EXPR:
1844 case LT_EXPR:
1845 case LE_EXPR:
1846 case GT_EXPR:
1847 case GE_EXPR:
1848 case EQ_EXPR:
1849 case NE_EXPR:
1850 case UNLT_EXPR:
1851 case UNLE_EXPR:
1852 case UNGT_EXPR:
1853 case UNGE_EXPR:
1854 case UNEQ_EXPR:
1855 case LTGT_EXPR:
1856 case ORDERED_EXPR:
1857 case UNORDERED_EXPR:
1859 const char *op = op_symbol (node);
1860 op0 = TREE_OPERAND (node, 0);
1861 op1 = TREE_OPERAND (node, 1);
1863 /* When the operands are expressions with less priority,
1864 keep semantics of the tree representation. */
1865 if (op_prio (op0) <= op_prio (node))
1867 pp_left_paren (buffer);
1868 dump_generic_node (buffer, op0, spc, flags, false);
1869 pp_right_paren (buffer);
1871 else
1872 dump_generic_node (buffer, op0, spc, flags, false);
1874 pp_space (buffer);
1875 pp_string (buffer, op);
1876 pp_space (buffer);
1878 /* When the operands are expressions with less priority,
1879 keep semantics of the tree representation. */
1880 if (op_prio (op1) <= op_prio (node))
1882 pp_left_paren (buffer);
1883 dump_generic_node (buffer, op1, spc, flags, false);
1884 pp_right_paren (buffer);
1886 else
1887 dump_generic_node (buffer, op1, spc, flags, false);
1889 break;
1891 /* Unary arithmetic and logic expressions. */
1892 case NEGATE_EXPR:
1893 case BIT_NOT_EXPR:
1894 case TRUTH_NOT_EXPR:
1895 case ADDR_EXPR:
1896 case PREDECREMENT_EXPR:
1897 case PREINCREMENT_EXPR:
1898 case INDIRECT_REF:
1899 if (TREE_CODE (node) == ADDR_EXPR
1900 && (TREE_CODE (TREE_OPERAND (node, 0)) == STRING_CST
1901 || TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL))
1902 ; /* Do not output '&' for strings and function pointers. */
1903 else
1904 pp_string (buffer, op_symbol (node));
1906 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1908 pp_left_paren (buffer);
1909 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1910 pp_right_paren (buffer);
1912 else
1913 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1914 break;
1916 case POSTDECREMENT_EXPR:
1917 case POSTINCREMENT_EXPR:
1918 if (op_prio (TREE_OPERAND (node, 0)) < op_prio (node))
1920 pp_left_paren (buffer);
1921 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1922 pp_right_paren (buffer);
1924 else
1925 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1926 pp_string (buffer, op_symbol (node));
1927 break;
1929 case MIN_EXPR:
1930 pp_string (buffer, "MIN_EXPR <");
1931 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1932 pp_string (buffer, ", ");
1933 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1934 pp_greater (buffer);
1935 break;
1937 case MAX_EXPR:
1938 pp_string (buffer, "MAX_EXPR <");
1939 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1940 pp_string (buffer, ", ");
1941 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
1942 pp_greater (buffer);
1943 break;
1945 case ABS_EXPR:
1946 pp_string (buffer, "ABS_EXPR <");
1947 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1948 pp_greater (buffer);
1949 break;
1951 case RANGE_EXPR:
1952 NIY;
1953 break;
1955 case ADDR_SPACE_CONVERT_EXPR:
1956 case FIXED_CONVERT_EXPR:
1957 case FIX_TRUNC_EXPR:
1958 case FLOAT_EXPR:
1959 CASE_CONVERT:
1960 type = TREE_TYPE (node);
1961 op0 = TREE_OPERAND (node, 0);
1962 if (type != TREE_TYPE (op0))
1964 pp_left_paren (buffer);
1965 dump_generic_node (buffer, type, spc, flags, false);
1966 pp_string (buffer, ") ");
1968 if (op_prio (op0) < op_prio (node))
1969 pp_left_paren (buffer);
1970 dump_generic_node (buffer, op0, spc, flags, false);
1971 if (op_prio (op0) < op_prio (node))
1972 pp_right_paren (buffer);
1973 break;
1975 case VIEW_CONVERT_EXPR:
1976 pp_string (buffer, "VIEW_CONVERT_EXPR<");
1977 dump_generic_node (buffer, TREE_TYPE (node), spc, flags, false);
1978 pp_string (buffer, ">(");
1979 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1980 pp_right_paren (buffer);
1981 break;
1983 case PAREN_EXPR:
1984 pp_string (buffer, "((");
1985 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1986 pp_string (buffer, "))");
1987 break;
1989 case NON_LVALUE_EXPR:
1990 pp_string (buffer, "NON_LVALUE_EXPR <");
1991 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1992 pp_greater (buffer);
1993 break;
1995 case SAVE_EXPR:
1996 pp_string (buffer, "SAVE_EXPR <");
1997 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
1998 pp_greater (buffer);
1999 break;
2001 case COMPLEX_EXPR:
2002 pp_string (buffer, "COMPLEX_EXPR <");
2003 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2004 pp_string (buffer, ", ");
2005 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2006 pp_greater (buffer);
2007 break;
2009 case CONJ_EXPR:
2010 pp_string (buffer, "CONJ_EXPR <");
2011 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2012 pp_greater (buffer);
2013 break;
2015 case REALPART_EXPR:
2016 pp_string (buffer, "REALPART_EXPR <");
2017 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2018 pp_greater (buffer);
2019 break;
2021 case IMAGPART_EXPR:
2022 pp_string (buffer, "IMAGPART_EXPR <");
2023 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2024 pp_greater (buffer);
2025 break;
2027 case VA_ARG_EXPR:
2028 pp_string (buffer, "VA_ARG_EXPR <");
2029 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2030 pp_greater (buffer);
2031 break;
2033 case TRY_FINALLY_EXPR:
2034 case TRY_CATCH_EXPR:
2035 pp_string (buffer, "try");
2036 newline_and_indent (buffer, spc+2);
2037 pp_left_brace (buffer);
2038 newline_and_indent (buffer, spc+4);
2039 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc+4, flags, true);
2040 newline_and_indent (buffer, spc+2);
2041 pp_right_brace (buffer);
2042 newline_and_indent (buffer, spc);
2043 pp_string (buffer,
2044 (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally");
2045 newline_and_indent (buffer, spc+2);
2046 pp_left_brace (buffer);
2047 newline_and_indent (buffer, spc+4);
2048 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc+4, flags, true);
2049 newline_and_indent (buffer, spc+2);
2050 pp_right_brace (buffer);
2051 is_expr = false;
2052 break;
2054 case CATCH_EXPR:
2055 pp_string (buffer, "catch (");
2056 dump_generic_node (buffer, CATCH_TYPES (node), spc+2, flags, false);
2057 pp_right_paren (buffer);
2058 newline_and_indent (buffer, spc+2);
2059 pp_left_brace (buffer);
2060 newline_and_indent (buffer, spc+4);
2061 dump_generic_node (buffer, CATCH_BODY (node), spc+4, flags, true);
2062 newline_and_indent (buffer, spc+2);
2063 pp_right_brace (buffer);
2064 is_expr = false;
2065 break;
2067 case EH_FILTER_EXPR:
2068 pp_string (buffer, "<<<eh_filter (");
2069 dump_generic_node (buffer, EH_FILTER_TYPES (node), spc+2, flags, false);
2070 pp_string (buffer, ")>>>");
2071 newline_and_indent (buffer, spc+2);
2072 pp_left_brace (buffer);
2073 newline_and_indent (buffer, spc+4);
2074 dump_generic_node (buffer, EH_FILTER_FAILURE (node), spc+4, flags, true);
2075 newline_and_indent (buffer, spc+2);
2076 pp_right_brace (buffer);
2077 is_expr = false;
2078 break;
2080 case LABEL_EXPR:
2081 op0 = TREE_OPERAND (node, 0);
2082 /* If this is for break or continue, don't bother printing it. */
2083 if (DECL_NAME (op0))
2085 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2086 if (strcmp (name, "break") == 0
2087 || strcmp (name, "continue") == 0)
2088 break;
2090 dump_generic_node (buffer, op0, spc, flags, false);
2091 pp_colon (buffer);
2092 if (DECL_NONLOCAL (op0))
2093 pp_string (buffer, " [non-local]");
2094 break;
2096 case LOOP_EXPR:
2097 pp_string (buffer, "while (1)");
2098 if (!(flags & TDF_SLIM))
2100 newline_and_indent (buffer, spc+2);
2101 pp_left_brace (buffer);
2102 newline_and_indent (buffer, spc+4);
2103 dump_generic_node (buffer, LOOP_EXPR_BODY (node), spc+4, flags, true);
2104 newline_and_indent (buffer, spc+2);
2105 pp_right_brace (buffer);
2107 is_expr = false;
2108 break;
2110 case PREDICT_EXPR:
2111 pp_string (buffer, "// predicted ");
2112 if (PREDICT_EXPR_OUTCOME (node))
2113 pp_string (buffer, "likely by ");
2114 else
2115 pp_string (buffer, "unlikely by ");
2116 pp_string (buffer, predictor_name (PREDICT_EXPR_PREDICTOR (node)));
2117 pp_string (buffer, " predictor.");
2118 break;
2120 case ANNOTATE_EXPR:
2121 pp_string (buffer, "ANNOTATE_EXPR <");
2122 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2123 switch ((enum annot_expr_kind) TREE_INT_CST_LOW (TREE_OPERAND (node, 1)))
2125 case annot_expr_ivdep_kind:
2126 pp_string (buffer, ", ivdep");
2127 break;
2128 case annot_expr_no_vector_kind:
2129 pp_string (buffer, ", no-vector");
2130 break;
2131 case annot_expr_vector_kind:
2132 pp_string (buffer, ", vector");
2133 break;
2134 default:
2135 gcc_unreachable ();
2137 pp_greater (buffer);
2138 break;
2140 case RETURN_EXPR:
2141 pp_string (buffer, "return");
2142 op0 = TREE_OPERAND (node, 0);
2143 if (op0)
2145 pp_space (buffer);
2146 if (TREE_CODE (op0) == MODIFY_EXPR)
2147 dump_generic_node (buffer, TREE_OPERAND (op0, 1),
2148 spc, flags, false);
2149 else
2150 dump_generic_node (buffer, op0, spc, flags, false);
2152 break;
2154 case EXIT_EXPR:
2155 pp_string (buffer, "if (");
2156 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2157 pp_string (buffer, ") break");
2158 break;
2160 case SWITCH_EXPR:
2161 pp_string (buffer, "switch (");
2162 dump_generic_node (buffer, SWITCH_COND (node), spc, flags, false);
2163 pp_right_paren (buffer);
2164 if (!(flags & TDF_SLIM))
2166 newline_and_indent (buffer, spc+2);
2167 pp_left_brace (buffer);
2168 if (SWITCH_BODY (node))
2170 newline_and_indent (buffer, spc+4);
2171 dump_generic_node (buffer, SWITCH_BODY (node), spc+4, flags,
2172 true);
2174 else
2176 tree vec = SWITCH_LABELS (node);
2177 size_t i, n = TREE_VEC_LENGTH (vec);
2178 for (i = 0; i < n; ++i)
2180 tree elt = TREE_VEC_ELT (vec, i);
2181 newline_and_indent (buffer, spc+4);
2182 if (elt)
2184 dump_generic_node (buffer, elt, spc+4, flags, false);
2185 pp_string (buffer, " goto ");
2186 dump_generic_node (buffer, CASE_LABEL (elt), spc+4,
2187 flags, true);
2188 pp_semicolon (buffer);
2190 else
2191 pp_string (buffer, "case ???: goto ???;");
2194 newline_and_indent (buffer, spc+2);
2195 pp_right_brace (buffer);
2197 is_expr = false;
2198 break;
2200 case GOTO_EXPR:
2201 op0 = GOTO_DESTINATION (node);
2202 if (TREE_CODE (op0) != SSA_NAME && DECL_P (op0) && DECL_NAME (op0))
2204 const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
2205 if (strcmp (name, "break") == 0
2206 || strcmp (name, "continue") == 0)
2208 pp_string (buffer, name);
2209 break;
2212 pp_string (buffer, "goto ");
2213 dump_generic_node (buffer, op0, spc, flags, false);
2214 break;
2216 case ASM_EXPR:
2217 pp_string (buffer, "__asm__");
2218 if (ASM_VOLATILE_P (node))
2219 pp_string (buffer, " __volatile__");
2220 pp_left_paren (buffer);
2221 dump_generic_node (buffer, ASM_STRING (node), spc, flags, false);
2222 pp_colon (buffer);
2223 dump_generic_node (buffer, ASM_OUTPUTS (node), spc, flags, false);
2224 pp_colon (buffer);
2225 dump_generic_node (buffer, ASM_INPUTS (node), spc, flags, false);
2226 if (ASM_CLOBBERS (node))
2228 pp_colon (buffer);
2229 dump_generic_node (buffer, ASM_CLOBBERS (node), spc, flags, false);
2231 pp_right_paren (buffer);
2232 break;
2234 case CASE_LABEL_EXPR:
2235 if (CASE_LOW (node) && CASE_HIGH (node))
2237 pp_string (buffer, "case ");
2238 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2239 pp_string (buffer, " ... ");
2240 dump_generic_node (buffer, CASE_HIGH (node), spc, flags, false);
2242 else if (CASE_LOW (node))
2244 pp_string (buffer, "case ");
2245 dump_generic_node (buffer, CASE_LOW (node), spc, flags, false);
2247 else
2248 pp_string (buffer, "default");
2249 pp_colon (buffer);
2250 break;
2252 case OBJ_TYPE_REF:
2253 pp_string (buffer, "OBJ_TYPE_REF(");
2254 dump_generic_node (buffer, OBJ_TYPE_REF_EXPR (node), spc, flags, false);
2255 pp_semicolon (buffer);
2256 if (!(flags & TDF_SLIM) && virtual_method_call_p (node))
2258 pp_string (buffer, "(");
2259 dump_generic_node (buffer, obj_type_ref_class (node), spc, flags, false);
2260 pp_string (buffer, ")");
2262 dump_generic_node (buffer, OBJ_TYPE_REF_OBJECT (node), spc, flags, false);
2263 pp_arrow (buffer);
2264 dump_generic_node (buffer, OBJ_TYPE_REF_TOKEN (node), spc, flags, false);
2265 pp_right_paren (buffer);
2266 break;
2268 case SSA_NAME:
2269 if (SSA_NAME_IDENTIFIER (node))
2270 dump_generic_node (buffer, SSA_NAME_IDENTIFIER (node),
2271 spc, flags, false);
2272 pp_underscore (buffer);
2273 pp_decimal_int (buffer, SSA_NAME_VERSION (node));
2274 if (SSA_NAME_IS_DEFAULT_DEF (node))
2275 pp_string (buffer, "(D)");
2276 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (node))
2277 pp_string (buffer, "(ab)");
2278 break;
2280 case WITH_SIZE_EXPR:
2281 pp_string (buffer, "WITH_SIZE_EXPR <");
2282 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2283 pp_string (buffer, ", ");
2284 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2285 pp_greater (buffer);
2286 break;
2288 case ASSERT_EXPR:
2289 pp_string (buffer, "ASSERT_EXPR <");
2290 dump_generic_node (buffer, ASSERT_EXPR_VAR (node), spc, flags, false);
2291 pp_string (buffer, ", ");
2292 dump_generic_node (buffer, ASSERT_EXPR_COND (node), spc, flags, false);
2293 pp_greater (buffer);
2294 break;
2296 case SCEV_KNOWN:
2297 pp_string (buffer, "scev_known");
2298 break;
2300 case SCEV_NOT_KNOWN:
2301 pp_string (buffer, "scev_not_known");
2302 break;
2304 case POLYNOMIAL_CHREC:
2305 pp_left_brace (buffer);
2306 dump_generic_node (buffer, CHREC_LEFT (node), spc, flags, false);
2307 pp_string (buffer, ", +, ");
2308 dump_generic_node (buffer, CHREC_RIGHT (node), spc, flags, false);
2309 pp_string (buffer, "}_");
2310 dump_generic_node (buffer, CHREC_VAR (node), spc, flags, false);
2311 is_stmt = false;
2312 break;
2314 case REALIGN_LOAD_EXPR:
2315 pp_string (buffer, "REALIGN_LOAD <");
2316 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2317 pp_string (buffer, ", ");
2318 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2319 pp_string (buffer, ", ");
2320 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2321 pp_greater (buffer);
2322 break;
2324 case VEC_COND_EXPR:
2325 pp_string (buffer, " VEC_COND_EXPR < ");
2326 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2327 pp_string (buffer, " , ");
2328 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2329 pp_string (buffer, " , ");
2330 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2331 pp_string (buffer, " > ");
2332 break;
2334 case VEC_PERM_EXPR:
2335 pp_string (buffer, " VEC_PERM_EXPR < ");
2336 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2337 pp_string (buffer, " , ");
2338 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2339 pp_string (buffer, " , ");
2340 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2341 pp_string (buffer, " > ");
2342 break;
2344 case DOT_PROD_EXPR:
2345 pp_string (buffer, " DOT_PROD_EXPR < ");
2346 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2347 pp_string (buffer, ", ");
2348 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2349 pp_string (buffer, ", ");
2350 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2351 pp_string (buffer, " > ");
2352 break;
2354 case WIDEN_MULT_PLUS_EXPR:
2355 pp_string (buffer, " WIDEN_MULT_PLUS_EXPR < ");
2356 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2357 pp_string (buffer, ", ");
2358 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2359 pp_string (buffer, ", ");
2360 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2361 pp_string (buffer, " > ");
2362 break;
2364 case WIDEN_MULT_MINUS_EXPR:
2365 pp_string (buffer, " WIDEN_MULT_MINUS_EXPR < ");
2366 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2367 pp_string (buffer, ", ");
2368 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2369 pp_string (buffer, ", ");
2370 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2371 pp_string (buffer, " > ");
2372 break;
2374 case FMA_EXPR:
2375 pp_string (buffer, " FMA_EXPR < ");
2376 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2377 pp_string (buffer, ", ");
2378 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2379 pp_string (buffer, ", ");
2380 dump_generic_node (buffer, TREE_OPERAND (node, 2), spc, flags, false);
2381 pp_string (buffer, " > ");
2382 break;
2384 case OMP_PARALLEL:
2385 pp_string (buffer, "#pragma omp parallel");
2386 dump_omp_clauses (buffer, OMP_PARALLEL_CLAUSES (node), spc, flags);
2388 dump_omp_body:
2389 if (!(flags & TDF_SLIM) && OMP_BODY (node))
2391 newline_and_indent (buffer, spc + 2);
2392 pp_left_brace (buffer);
2393 newline_and_indent (buffer, spc + 4);
2394 dump_generic_node (buffer, OMP_BODY (node), spc + 4, flags, false);
2395 newline_and_indent (buffer, spc + 2);
2396 pp_right_brace (buffer);
2398 is_expr = false;
2399 break;
2401 case OMP_TASK:
2402 pp_string (buffer, "#pragma omp task");
2403 dump_omp_clauses (buffer, OMP_TASK_CLAUSES (node), spc, flags);
2404 goto dump_omp_body;
2406 case OMP_FOR:
2407 pp_string (buffer, "#pragma omp for");
2408 goto dump_omp_loop;
2410 case OMP_SIMD:
2411 pp_string (buffer, "#pragma omp simd");
2412 goto dump_omp_loop;
2414 case CILK_SIMD:
2415 pp_string (buffer, "#pragma simd");
2416 goto dump_omp_loop;
2418 case OMP_DISTRIBUTE:
2419 pp_string (buffer, "#pragma omp distribute");
2420 goto dump_omp_loop;
2422 case OMP_TEAMS:
2423 pp_string (buffer, "#pragma omp teams");
2424 dump_omp_clauses (buffer, OMP_TEAMS_CLAUSES (node), spc, flags);
2425 goto dump_omp_body;
2427 case OMP_TARGET_DATA:
2428 pp_string (buffer, "#pragma omp target data");
2429 dump_omp_clauses (buffer, OMP_TARGET_DATA_CLAUSES (node), spc, flags);
2430 goto dump_omp_body;
2432 case OMP_TARGET:
2433 pp_string (buffer, "#pragma omp target");
2434 dump_omp_clauses (buffer, OMP_TARGET_CLAUSES (node), spc, flags);
2435 goto dump_omp_body;
2437 case OMP_TARGET_UPDATE:
2438 pp_string (buffer, "#pragma omp target update");
2439 dump_omp_clauses (buffer, OMP_TARGET_UPDATE_CLAUSES (node), spc, flags);
2440 is_expr = false;
2441 break;
2443 dump_omp_loop:
2444 dump_omp_clauses (buffer, OMP_FOR_CLAUSES (node), spc, flags);
2446 if (!(flags & TDF_SLIM))
2448 int i;
2450 if (OMP_FOR_PRE_BODY (node))
2452 newline_and_indent (buffer, spc + 2);
2453 pp_left_brace (buffer);
2454 spc += 4;
2455 newline_and_indent (buffer, spc);
2456 dump_generic_node (buffer, OMP_FOR_PRE_BODY (node),
2457 spc, flags, false);
2459 if (OMP_FOR_INIT (node))
2461 spc -= 2;
2462 for (i = 0; i < TREE_VEC_LENGTH (OMP_FOR_INIT (node)); i++)
2464 spc += 2;
2465 newline_and_indent (buffer, spc);
2466 pp_string (buffer, "for (");
2467 dump_generic_node (buffer,
2468 TREE_VEC_ELT (OMP_FOR_INIT (node), i),
2469 spc, flags, false);
2470 pp_string (buffer, "; ");
2471 dump_generic_node (buffer,
2472 TREE_VEC_ELT (OMP_FOR_COND (node), i),
2473 spc, flags, false);
2474 pp_string (buffer, "; ");
2475 dump_generic_node (buffer,
2476 TREE_VEC_ELT (OMP_FOR_INCR (node), i),
2477 spc, flags, false);
2478 pp_right_paren (buffer);
2481 if (OMP_FOR_BODY (node))
2483 newline_and_indent (buffer, spc + 2);
2484 pp_left_brace (buffer);
2485 newline_and_indent (buffer, spc + 4);
2486 dump_generic_node (buffer, OMP_FOR_BODY (node), spc + 4, flags,
2487 false);
2488 newline_and_indent (buffer, spc + 2);
2489 pp_right_brace (buffer);
2491 if (OMP_FOR_INIT (node))
2492 spc -= 2 * TREE_VEC_LENGTH (OMP_FOR_INIT (node)) - 2;
2493 if (OMP_FOR_PRE_BODY (node))
2495 spc -= 4;
2496 newline_and_indent (buffer, spc + 2);
2497 pp_right_brace (buffer);
2500 is_expr = false;
2501 break;
2503 case OMP_SECTIONS:
2504 pp_string (buffer, "#pragma omp sections");
2505 dump_omp_clauses (buffer, OMP_SECTIONS_CLAUSES (node), spc, flags);
2506 goto dump_omp_body;
2508 case OMP_SECTION:
2509 pp_string (buffer, "#pragma omp section");
2510 goto dump_omp_body;
2512 case OMP_MASTER:
2513 pp_string (buffer, "#pragma omp master");
2514 goto dump_omp_body;
2516 case OMP_TASKGROUP:
2517 pp_string (buffer, "#pragma omp taskgroup");
2518 goto dump_omp_body;
2520 case OMP_ORDERED:
2521 pp_string (buffer, "#pragma omp ordered");
2522 goto dump_omp_body;
2524 case OMP_CRITICAL:
2525 pp_string (buffer, "#pragma omp critical");
2526 if (OMP_CRITICAL_NAME (node))
2528 pp_space (buffer);
2529 pp_left_paren (buffer);
2530 dump_generic_node (buffer, OMP_CRITICAL_NAME (node), spc,
2531 flags, false);
2532 pp_right_paren (buffer);
2534 goto dump_omp_body;
2536 case OMP_ATOMIC:
2537 pp_string (buffer, "#pragma omp atomic");
2538 if (OMP_ATOMIC_SEQ_CST (node))
2539 pp_string (buffer, " seq_cst");
2540 newline_and_indent (buffer, spc + 2);
2541 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2542 pp_space (buffer);
2543 pp_equal (buffer);
2544 pp_space (buffer);
2545 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2546 break;
2548 case OMP_ATOMIC_READ:
2549 pp_string (buffer, "#pragma omp atomic read");
2550 if (OMP_ATOMIC_SEQ_CST (node))
2551 pp_string (buffer, " seq_cst");
2552 newline_and_indent (buffer, spc + 2);
2553 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2554 pp_space (buffer);
2555 break;
2557 case OMP_ATOMIC_CAPTURE_OLD:
2558 case OMP_ATOMIC_CAPTURE_NEW:
2559 pp_string (buffer, "#pragma omp atomic capture");
2560 if (OMP_ATOMIC_SEQ_CST (node))
2561 pp_string (buffer, " seq_cst");
2562 newline_and_indent (buffer, spc + 2);
2563 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2564 pp_space (buffer);
2565 pp_equal (buffer);
2566 pp_space (buffer);
2567 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2568 break;
2570 case OMP_SINGLE:
2571 pp_string (buffer, "#pragma omp single");
2572 dump_omp_clauses (buffer, OMP_SINGLE_CLAUSES (node), spc, flags);
2573 goto dump_omp_body;
2575 case OMP_CLAUSE:
2576 dump_omp_clause (buffer, node, spc, flags);
2577 is_expr = false;
2578 break;
2580 case TRANSACTION_EXPR:
2581 if (TRANSACTION_EXPR_OUTER (node))
2582 pp_string (buffer, "__transaction_atomic [[outer]]");
2583 else if (TRANSACTION_EXPR_RELAXED (node))
2584 pp_string (buffer, "__transaction_relaxed");
2585 else
2586 pp_string (buffer, "__transaction_atomic");
2587 if (!(flags & TDF_SLIM) && TRANSACTION_EXPR_BODY (node))
2589 newline_and_indent (buffer, spc);
2590 pp_left_brace (buffer);
2591 newline_and_indent (buffer, spc + 2);
2592 dump_generic_node (buffer, TRANSACTION_EXPR_BODY (node),
2593 spc + 2, flags, false);
2594 newline_and_indent (buffer, spc);
2595 pp_right_brace (buffer);
2597 is_expr = false;
2598 break;
2600 case REDUC_MAX_EXPR:
2601 pp_string (buffer, " REDUC_MAX_EXPR < ");
2602 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2603 pp_string (buffer, " > ");
2604 break;
2606 case REDUC_MIN_EXPR:
2607 pp_string (buffer, " REDUC_MIN_EXPR < ");
2608 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2609 pp_string (buffer, " > ");
2610 break;
2612 case REDUC_PLUS_EXPR:
2613 pp_string (buffer, " REDUC_PLUS_EXPR < ");
2614 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2615 pp_string (buffer, " > ");
2616 break;
2618 case VEC_WIDEN_MULT_HI_EXPR:
2619 case VEC_WIDEN_MULT_LO_EXPR:
2620 case VEC_WIDEN_MULT_EVEN_EXPR:
2621 case VEC_WIDEN_MULT_ODD_EXPR:
2622 case VEC_WIDEN_LSHIFT_HI_EXPR:
2623 case VEC_WIDEN_LSHIFT_LO_EXPR:
2624 pp_space (buffer);
2625 for (str = get_tree_code_name (code); *str; str++)
2626 pp_character (buffer, TOUPPER (*str));
2627 pp_string (buffer, " < ");
2628 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2629 pp_string (buffer, ", ");
2630 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2631 pp_string (buffer, " > ");
2632 break;
2634 case VEC_UNPACK_HI_EXPR:
2635 pp_string (buffer, " VEC_UNPACK_HI_EXPR < ");
2636 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2637 pp_string (buffer, " > ");
2638 break;
2640 case VEC_UNPACK_LO_EXPR:
2641 pp_string (buffer, " VEC_UNPACK_LO_EXPR < ");
2642 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2643 pp_string (buffer, " > ");
2644 break;
2646 case VEC_UNPACK_FLOAT_HI_EXPR:
2647 pp_string (buffer, " VEC_UNPACK_FLOAT_HI_EXPR < ");
2648 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2649 pp_string (buffer, " > ");
2650 break;
2652 case VEC_UNPACK_FLOAT_LO_EXPR:
2653 pp_string (buffer, " VEC_UNPACK_FLOAT_LO_EXPR < ");
2654 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2655 pp_string (buffer, " > ");
2656 break;
2658 case VEC_PACK_TRUNC_EXPR:
2659 pp_string (buffer, " VEC_PACK_TRUNC_EXPR < ");
2660 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2661 pp_string (buffer, ", ");
2662 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2663 pp_string (buffer, " > ");
2664 break;
2666 case VEC_PACK_SAT_EXPR:
2667 pp_string (buffer, " VEC_PACK_SAT_EXPR < ");
2668 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2669 pp_string (buffer, ", ");
2670 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2671 pp_string (buffer, " > ");
2672 break;
2674 case VEC_PACK_FIX_TRUNC_EXPR:
2675 pp_string (buffer, " VEC_PACK_FIX_TRUNC_EXPR < ");
2676 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2677 pp_string (buffer, ", ");
2678 dump_generic_node (buffer, TREE_OPERAND (node, 1), spc, flags, false);
2679 pp_string (buffer, " > ");
2680 break;
2682 case BLOCK:
2683 dump_block_node (buffer, node, spc, flags);
2684 break;
2686 case CILK_SPAWN_STMT:
2687 pp_string (buffer, "_Cilk_spawn ");
2688 dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false);
2689 break;
2691 case CILK_SYNC_STMT:
2692 pp_string (buffer, "_Cilk_sync");
2693 break;
2695 default:
2696 NIY;
2699 if (is_stmt && is_expr)
2700 pp_semicolon (buffer);
2702 return spc;
2705 /* Print the declaration of a variable. */
2707 void
2708 print_declaration (pretty_printer *buffer, tree t, int spc, int flags)
2710 INDENT (spc);
2712 if (TREE_CODE(t) == NAMELIST_DECL)
2714 pp_string(buffer, "namelist ");
2715 dump_decl_name (buffer, t, flags);
2716 pp_semicolon (buffer);
2717 return;
2720 if (TREE_CODE (t) == TYPE_DECL)
2721 pp_string (buffer, "typedef ");
2723 if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL) && DECL_REGISTER (t))
2724 pp_string (buffer, "register ");
2726 if (TREE_PUBLIC (t) && DECL_EXTERNAL (t))
2727 pp_string (buffer, "extern ");
2728 else if (TREE_STATIC (t))
2729 pp_string (buffer, "static ");
2731 /* Print the type and name. */
2732 if (TREE_TYPE (t) && TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
2734 tree tmp;
2736 /* Print array's type. */
2737 tmp = TREE_TYPE (t);
2738 while (TREE_CODE (TREE_TYPE (tmp)) == ARRAY_TYPE)
2739 tmp = TREE_TYPE (tmp);
2740 dump_generic_node (buffer, TREE_TYPE (tmp), spc, flags, false);
2742 /* Print variable's name. */
2743 pp_space (buffer);
2744 dump_generic_node (buffer, t, spc, flags, false);
2746 /* Print the dimensions. */
2747 tmp = TREE_TYPE (t);
2748 while (TREE_CODE (tmp) == ARRAY_TYPE)
2750 dump_array_domain (buffer, TYPE_DOMAIN (tmp), spc, flags);
2751 tmp = TREE_TYPE (tmp);
2754 else if (TREE_CODE (t) == FUNCTION_DECL)
2756 dump_generic_node (buffer, TREE_TYPE (TREE_TYPE (t)), spc, flags, false);
2757 pp_space (buffer);
2758 dump_decl_name (buffer, t, flags);
2759 dump_function_declaration (buffer, TREE_TYPE (t), spc, flags);
2761 else
2763 /* Print type declaration. */
2764 dump_generic_node (buffer, TREE_TYPE (t), spc, flags, false);
2766 /* Print variable's name. */
2767 pp_space (buffer);
2768 dump_generic_node (buffer, t, spc, flags, false);
2771 if (TREE_CODE (t) == VAR_DECL && DECL_HARD_REGISTER (t))
2773 pp_string (buffer, " __asm__ ");
2774 pp_left_paren (buffer);
2775 dump_generic_node (buffer, DECL_ASSEMBLER_NAME (t), spc, flags, false);
2776 pp_right_paren (buffer);
2779 /* The initial value of a function serves to determine whether the function
2780 is declared or defined. So the following does not apply to function
2781 nodes. */
2782 if (TREE_CODE (t) != FUNCTION_DECL)
2784 /* Print the initial value. */
2785 if (DECL_INITIAL (t))
2787 pp_space (buffer);
2788 pp_equal (buffer);
2789 pp_space (buffer);
2790 dump_generic_node (buffer, DECL_INITIAL (t), spc, flags, false);
2794 if (TREE_CODE (t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (t))
2796 pp_string (buffer, " [value-expr: ");
2797 dump_generic_node (buffer, DECL_VALUE_EXPR (t), spc, flags, false);
2798 pp_right_bracket (buffer);
2801 pp_semicolon (buffer);
2805 /* Prints a structure: name, fields, and methods.
2806 FIXME: Still incomplete. */
2808 static void
2809 print_struct_decl (pretty_printer *buffer, const_tree node, int spc, int flags)
2811 /* Print the name of the structure. */
2812 if (TYPE_NAME (node))
2814 INDENT (spc);
2815 if (TREE_CODE (node) == RECORD_TYPE)
2816 pp_string (buffer, "struct ");
2817 else if ((TREE_CODE (node) == UNION_TYPE
2818 || TREE_CODE (node) == QUAL_UNION_TYPE))
2819 pp_string (buffer, "union ");
2821 dump_generic_node (buffer, TYPE_NAME (node), spc, 0, false);
2824 /* Print the contents of the structure. */
2825 pp_newline (buffer);
2826 INDENT (spc);
2827 pp_left_brace (buffer);
2828 pp_newline (buffer);
2830 /* Print the fields of the structure. */
2832 tree tmp;
2833 tmp = TYPE_FIELDS (node);
2834 while (tmp)
2836 /* Avoid to print recursively the structure. */
2837 /* FIXME : Not implemented correctly...,
2838 what about the case when we have a cycle in the contain graph? ...
2839 Maybe this could be solved by looking at the scope in which the
2840 structure was declared. */
2841 if (TREE_TYPE (tmp) != node
2842 && (TREE_CODE (TREE_TYPE (tmp)) != POINTER_TYPE
2843 || TREE_TYPE (TREE_TYPE (tmp)) != node))
2845 print_declaration (buffer, tmp, spc+2, flags);
2846 pp_newline (buffer);
2848 tmp = DECL_CHAIN (tmp);
2851 INDENT (spc);
2852 pp_right_brace (buffer);
2855 /* Return the priority of the operator CODE.
2857 From lowest to highest precedence with either left-to-right (L-R)
2858 or right-to-left (R-L) associativity]:
2860 1 [L-R] ,
2861 2 [R-L] = += -= *= /= %= &= ^= |= <<= >>=
2862 3 [R-L] ?:
2863 4 [L-R] ||
2864 5 [L-R] &&
2865 6 [L-R] |
2866 7 [L-R] ^
2867 8 [L-R] &
2868 9 [L-R] == !=
2869 10 [L-R] < <= > >=
2870 11 [L-R] << >>
2871 12 [L-R] + -
2872 13 [L-R] * / %
2873 14 [R-L] ! ~ ++ -- + - * & (type) sizeof
2874 15 [L-R] fn() [] -> .
2876 unary +, - and * have higher precedence than the corresponding binary
2877 operators. */
2880 op_code_prio (enum tree_code code)
2882 switch (code)
2884 case TREE_LIST:
2885 case COMPOUND_EXPR:
2886 case BIND_EXPR:
2887 return 1;
2889 case MODIFY_EXPR:
2890 case INIT_EXPR:
2891 return 2;
2893 case COND_EXPR:
2894 return 3;
2896 case TRUTH_OR_EXPR:
2897 case TRUTH_ORIF_EXPR:
2898 return 4;
2900 case TRUTH_AND_EXPR:
2901 case TRUTH_ANDIF_EXPR:
2902 return 5;
2904 case BIT_IOR_EXPR:
2905 return 6;
2907 case BIT_XOR_EXPR:
2908 case TRUTH_XOR_EXPR:
2909 return 7;
2911 case BIT_AND_EXPR:
2912 return 8;
2914 case EQ_EXPR:
2915 case NE_EXPR:
2916 return 9;
2918 case UNLT_EXPR:
2919 case UNLE_EXPR:
2920 case UNGT_EXPR:
2921 case UNGE_EXPR:
2922 case UNEQ_EXPR:
2923 case LTGT_EXPR:
2924 case ORDERED_EXPR:
2925 case UNORDERED_EXPR:
2926 case LT_EXPR:
2927 case LE_EXPR:
2928 case GT_EXPR:
2929 case GE_EXPR:
2930 return 10;
2932 case LSHIFT_EXPR:
2933 case RSHIFT_EXPR:
2934 case LROTATE_EXPR:
2935 case RROTATE_EXPR:
2936 case VEC_WIDEN_LSHIFT_HI_EXPR:
2937 case VEC_WIDEN_LSHIFT_LO_EXPR:
2938 case WIDEN_LSHIFT_EXPR:
2939 return 11;
2941 case WIDEN_SUM_EXPR:
2942 case PLUS_EXPR:
2943 case POINTER_PLUS_EXPR:
2944 case MINUS_EXPR:
2945 return 12;
2947 case VEC_WIDEN_MULT_HI_EXPR:
2948 case VEC_WIDEN_MULT_LO_EXPR:
2949 case WIDEN_MULT_EXPR:
2950 case DOT_PROD_EXPR:
2951 case WIDEN_MULT_PLUS_EXPR:
2952 case WIDEN_MULT_MINUS_EXPR:
2953 case MULT_EXPR:
2954 case MULT_HIGHPART_EXPR:
2955 case TRUNC_DIV_EXPR:
2956 case CEIL_DIV_EXPR:
2957 case FLOOR_DIV_EXPR:
2958 case ROUND_DIV_EXPR:
2959 case RDIV_EXPR:
2960 case EXACT_DIV_EXPR:
2961 case TRUNC_MOD_EXPR:
2962 case CEIL_MOD_EXPR:
2963 case FLOOR_MOD_EXPR:
2964 case ROUND_MOD_EXPR:
2965 case FMA_EXPR:
2966 return 13;
2968 case TRUTH_NOT_EXPR:
2969 case BIT_NOT_EXPR:
2970 case POSTINCREMENT_EXPR:
2971 case POSTDECREMENT_EXPR:
2972 case PREINCREMENT_EXPR:
2973 case PREDECREMENT_EXPR:
2974 case NEGATE_EXPR:
2975 case INDIRECT_REF:
2976 case ADDR_EXPR:
2977 case FLOAT_EXPR:
2978 CASE_CONVERT:
2979 case FIX_TRUNC_EXPR:
2980 case TARGET_EXPR:
2981 return 14;
2983 case CALL_EXPR:
2984 case ARRAY_REF:
2985 case ARRAY_RANGE_REF:
2986 case COMPONENT_REF:
2987 return 15;
2989 /* Special expressions. */
2990 case MIN_EXPR:
2991 case MAX_EXPR:
2992 case ABS_EXPR:
2993 case REALPART_EXPR:
2994 case IMAGPART_EXPR:
2995 case REDUC_MAX_EXPR:
2996 case REDUC_MIN_EXPR:
2997 case REDUC_PLUS_EXPR:
2998 case VEC_LSHIFT_EXPR:
2999 case VEC_RSHIFT_EXPR:
3000 case VEC_UNPACK_HI_EXPR:
3001 case VEC_UNPACK_LO_EXPR:
3002 case VEC_UNPACK_FLOAT_HI_EXPR:
3003 case VEC_UNPACK_FLOAT_LO_EXPR:
3004 case VEC_PACK_TRUNC_EXPR:
3005 case VEC_PACK_SAT_EXPR:
3006 return 16;
3008 default:
3009 /* Return an arbitrarily high precedence to avoid surrounding single
3010 VAR_DECLs in ()s. */
3011 return 9999;
3015 /* Return the priority of the operator OP. */
3018 op_prio (const_tree op)
3020 enum tree_code code;
3022 if (op == NULL)
3023 return 9999;
3025 code = TREE_CODE (op);
3026 if (code == SAVE_EXPR || code == NON_LVALUE_EXPR)
3027 return op_prio (TREE_OPERAND (op, 0));
3029 return op_code_prio (code);
3032 /* Return the symbol associated with operator CODE. */
3034 const char *
3035 op_symbol_code (enum tree_code code)
3037 switch (code)
3039 case MODIFY_EXPR:
3040 return "=";
3042 case TRUTH_OR_EXPR:
3043 case TRUTH_ORIF_EXPR:
3044 return "||";
3046 case TRUTH_AND_EXPR:
3047 case TRUTH_ANDIF_EXPR:
3048 return "&&";
3050 case BIT_IOR_EXPR:
3051 return "|";
3053 case TRUTH_XOR_EXPR:
3054 case BIT_XOR_EXPR:
3055 return "^";
3057 case ADDR_EXPR:
3058 case BIT_AND_EXPR:
3059 return "&";
3061 case ORDERED_EXPR:
3062 return "ord";
3063 case UNORDERED_EXPR:
3064 return "unord";
3066 case EQ_EXPR:
3067 return "==";
3068 case UNEQ_EXPR:
3069 return "u==";
3071 case NE_EXPR:
3072 return "!=";
3074 case LT_EXPR:
3075 return "<";
3076 case UNLT_EXPR:
3077 return "u<";
3079 case LE_EXPR:
3080 return "<=";
3081 case UNLE_EXPR:
3082 return "u<=";
3084 case GT_EXPR:
3085 return ">";
3086 case UNGT_EXPR:
3087 return "u>";
3089 case GE_EXPR:
3090 return ">=";
3091 case UNGE_EXPR:
3092 return "u>=";
3094 case LTGT_EXPR:
3095 return "<>";
3097 case LSHIFT_EXPR:
3098 return "<<";
3100 case RSHIFT_EXPR:
3101 return ">>";
3103 case LROTATE_EXPR:
3104 return "r<<";
3106 case RROTATE_EXPR:
3107 return "r>>";
3109 case VEC_LSHIFT_EXPR:
3110 return "v<<";
3112 case VEC_RSHIFT_EXPR:
3113 return "v>>";
3115 case WIDEN_LSHIFT_EXPR:
3116 return "w<<";
3118 case POINTER_PLUS_EXPR:
3119 return "+";
3121 case PLUS_EXPR:
3122 return "+";
3124 case REDUC_PLUS_EXPR:
3125 return "r+";
3127 case WIDEN_SUM_EXPR:
3128 return "w+";
3130 case WIDEN_MULT_EXPR:
3131 return "w*";
3133 case MULT_HIGHPART_EXPR:
3134 return "h*";
3136 case NEGATE_EXPR:
3137 case MINUS_EXPR:
3138 return "-";
3140 case BIT_NOT_EXPR:
3141 return "~";
3143 case TRUTH_NOT_EXPR:
3144 return "!";
3146 case MULT_EXPR:
3147 case INDIRECT_REF:
3148 return "*";
3150 case TRUNC_DIV_EXPR:
3151 case RDIV_EXPR:
3152 return "/";
3154 case CEIL_DIV_EXPR:
3155 return "/[cl]";
3157 case FLOOR_DIV_EXPR:
3158 return "/[fl]";
3160 case ROUND_DIV_EXPR:
3161 return "/[rd]";
3163 case EXACT_DIV_EXPR:
3164 return "/[ex]";
3166 case TRUNC_MOD_EXPR:
3167 return "%";
3169 case CEIL_MOD_EXPR:
3170 return "%[cl]";
3172 case FLOOR_MOD_EXPR:
3173 return "%[fl]";
3175 case ROUND_MOD_EXPR:
3176 return "%[rd]";
3178 case PREDECREMENT_EXPR:
3179 return " --";
3181 case PREINCREMENT_EXPR:
3182 return " ++";
3184 case POSTDECREMENT_EXPR:
3185 return "-- ";
3187 case POSTINCREMENT_EXPR:
3188 return "++ ";
3190 case MAX_EXPR:
3191 return "max";
3193 case MIN_EXPR:
3194 return "min";
3196 default:
3197 return "<<< ??? >>>";
3201 /* Return the symbol associated with operator OP. */
3203 static const char *
3204 op_symbol (const_tree op)
3206 return op_symbol_code (TREE_CODE (op));
3209 /* Prints the name of a call. NODE is the CALL_EXPR_FN of a CALL_EXPR or
3210 the gimple_call_fn of a GIMPLE_CALL. */
3212 void
3213 print_call_name (pretty_printer *buffer, tree node, int flags)
3215 tree op0 = node;
3217 if (TREE_CODE (op0) == NON_LVALUE_EXPR)
3218 op0 = TREE_OPERAND (op0, 0);
3220 again:
3221 switch (TREE_CODE (op0))
3223 case VAR_DECL:
3224 case PARM_DECL:
3225 case FUNCTION_DECL:
3226 dump_function_name (buffer, op0, flags);
3227 break;
3229 case ADDR_EXPR:
3230 case INDIRECT_REF:
3231 case NOP_EXPR:
3232 op0 = TREE_OPERAND (op0, 0);
3233 goto again;
3235 case COND_EXPR:
3236 pp_left_paren (buffer);
3237 dump_generic_node (buffer, TREE_OPERAND (op0, 0), 0, flags, false);
3238 pp_string (buffer, ") ? ");
3239 dump_generic_node (buffer, TREE_OPERAND (op0, 1), 0, flags, false);
3240 pp_string (buffer, " : ");
3241 dump_generic_node (buffer, TREE_OPERAND (op0, 2), 0, flags, false);
3242 break;
3244 case ARRAY_REF:
3245 if (TREE_CODE (TREE_OPERAND (op0, 0)) == VAR_DECL)
3246 dump_function_name (buffer, TREE_OPERAND (op0, 0), flags);
3247 else
3248 dump_generic_node (buffer, op0, 0, flags, false);
3249 break;
3251 case MEM_REF:
3252 if (integer_zerop (TREE_OPERAND (op0, 1)))
3254 op0 = TREE_OPERAND (op0, 0);
3255 goto again;
3257 /* Fallthru. */
3258 case COMPONENT_REF:
3259 case SSA_NAME:
3260 case OBJ_TYPE_REF:
3261 dump_generic_node (buffer, op0, 0, flags, false);
3262 break;
3264 default:
3265 NIY;
3269 /* Parses the string STR and replaces new-lines by '\n', tabs by '\t', ... */
3271 static void
3272 pretty_print_string (pretty_printer *buffer, const char *str)
3274 if (str == NULL)
3275 return;
3277 while (*str)
3279 switch (str[0])
3281 case '\b':
3282 pp_string (buffer, "\\b");
3283 break;
3285 case '\f':
3286 pp_string (buffer, "\\f");
3287 break;
3289 case '\n':
3290 pp_string (buffer, "\\n");
3291 break;
3293 case '\r':
3294 pp_string (buffer, "\\r");
3295 break;
3297 case '\t':
3298 pp_string (buffer, "\\t");
3299 break;
3301 case '\v':
3302 pp_string (buffer, "\\v");
3303 break;
3305 case '\\':
3306 pp_string (buffer, "\\\\");
3307 break;
3309 case '\"':
3310 pp_string (buffer, "\\\"");
3311 break;
3313 case '\'':
3314 pp_string (buffer, "\\'");
3315 break;
3317 /* No need to handle \0; the loop terminates on \0. */
3319 case '\1':
3320 pp_string (buffer, "\\1");
3321 break;
3323 case '\2':
3324 pp_string (buffer, "\\2");
3325 break;
3327 case '\3':
3328 pp_string (buffer, "\\3");
3329 break;
3331 case '\4':
3332 pp_string (buffer, "\\4");
3333 break;
3335 case '\5':
3336 pp_string (buffer, "\\5");
3337 break;
3339 case '\6':
3340 pp_string (buffer, "\\6");
3341 break;
3343 case '\7':
3344 pp_string (buffer, "\\7");
3345 break;
3347 default:
3348 pp_character (buffer, str[0]);
3349 break;
3351 str++;
3355 static void
3356 maybe_init_pretty_print (FILE *file)
3358 if (!initialized)
3360 new (&buffer) pretty_printer ();
3361 pp_needs_newline (&buffer) = true;
3362 pp_translate_identifiers (&buffer) = false;
3363 initialized = 1;
3366 buffer.buffer->stream = file;
3369 static void
3370 newline_and_indent (pretty_printer *buffer, int spc)
3372 pp_newline (buffer);
3373 INDENT (spc);
3376 /* Handle a %K format for TEXT. Separate from default_tree_printer so
3377 it can also be used in front ends.
3378 %K: a statement, from which EXPR_LOCATION and TREE_BLOCK will be recorded.
3381 void
3382 percent_K_format (text_info *text)
3384 tree t = va_arg (*text->args_ptr, tree), block;
3385 gcc_assert (text->locus != NULL);
3386 *text->locus = EXPR_LOCATION (t);
3387 gcc_assert (pp_ti_abstract_origin (text) != NULL);
3388 block = TREE_BLOCK (t);
3389 *pp_ti_abstract_origin (text) = NULL;
3391 if (in_lto_p)
3393 /* ??? LTO drops all BLOCK_ABSTRACT_ORIGINs apart from those
3394 representing the outermost block of an inlined function.
3395 So walk the BLOCK tree until we hit such a scope. */
3396 while (block
3397 && TREE_CODE (block) == BLOCK)
3399 if (inlined_function_outer_scope_p (block))
3401 *pp_ti_abstract_origin (text) = block;
3402 break;
3404 block = BLOCK_SUPERCONTEXT (block);
3406 return;
3409 while (block
3410 && TREE_CODE (block) == BLOCK
3411 && BLOCK_ABSTRACT_ORIGIN (block))
3413 tree ao = BLOCK_ABSTRACT_ORIGIN (block);
3415 while (TREE_CODE (ao) == BLOCK
3416 && BLOCK_ABSTRACT_ORIGIN (ao)
3417 && BLOCK_ABSTRACT_ORIGIN (ao) != ao)
3418 ao = BLOCK_ABSTRACT_ORIGIN (ao);
3420 if (TREE_CODE (ao) == FUNCTION_DECL)
3422 *pp_ti_abstract_origin (text) = block;
3423 break;
3425 block = BLOCK_SUPERCONTEXT (block);
3429 /* Print the identifier ID to PRETTY-PRINTER. */
3431 void
3432 pp_tree_identifier (pretty_printer *pp, tree id)
3434 if (pp_translate_identifiers (pp))
3436 const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
3437 pp_append_text (pp, text, text + strlen (text));
3439 else
3440 pp_append_text (pp, IDENTIFIER_POINTER (id),
3441 IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
3444 /* A helper function that is used to dump function information before the
3445 function dump. */
3447 void
3448 dump_function_header (FILE *dump_file, tree fdecl, int flags)
3450 const char *dname, *aname;
3451 struct cgraph_node *node = cgraph_get_node (fdecl);
3452 struct function *fun = DECL_STRUCT_FUNCTION (fdecl);
3454 dname = lang_hooks.decl_printable_name (fdecl, 2);
3456 if (DECL_ASSEMBLER_NAME_SET_P (fdecl))
3457 aname = (IDENTIFIER_POINTER
3458 (DECL_ASSEMBLER_NAME (fdecl)));
3459 else
3460 aname = "<unset-asm-name>";
3462 fprintf (dump_file, "\n;; Function %s (%s, funcdef_no=%d",
3463 dname, aname, fun->funcdef_no);
3464 if (!(flags & TDF_NOUID))
3465 fprintf (dump_file, ", decl_uid=%d", DECL_UID (fdecl));
3466 if (node)
3468 fprintf (dump_file, ", symbol_order=%d)%s\n\n", node->order,
3469 node->frequency == NODE_FREQUENCY_HOT
3470 ? " (hot)"
3471 : node->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED
3472 ? " (unlikely executed)"
3473 : node->frequency == NODE_FREQUENCY_EXECUTED_ONCE
3474 ? " (executed once)"
3475 : "");
3477 else
3478 fprintf (dump_file, ")\n\n");
3481 /* Dump double_int D to pretty_printer PP. UNS is true
3482 if D is unsigned and false otherwise. */
3483 void
3484 pp_double_int (pretty_printer *pp, double_int d, bool uns)
3486 if (d.fits_shwi ())
3487 pp_wide_integer (pp, d.low);
3488 else if (d.fits_uhwi ())
3489 pp_unsigned_wide_integer (pp, d.low);
3490 else
3492 unsigned HOST_WIDE_INT low = d.low;
3493 HOST_WIDE_INT high = d.high;
3494 if (!uns && d.is_negative ())
3496 pp_minus (pp);
3497 high = ~high + !low;
3498 low = -low;
3500 /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
3501 systems? */
3502 sprintf (pp_buffer (pp)->digit_buffer,
3503 HOST_WIDE_INT_PRINT_DOUBLE_HEX,
3504 (unsigned HOST_WIDE_INT) high, low);
3505 pp_string (pp, pp_buffer (pp)->digit_buffer);